En este artículo te diré cómo puedes ensamblar tu paquete de manera fácil, rápida y económica para modelar problemas de dinámica de fluidos en la nube. Haré esto usando una combinación de dos herramientas: el simulador numérico de mecánica continua de OpenFOAM y el kit de herramientas de visualización de conjuntos de datos ParaView.
Soy un desarrollador ordinario y no soy un experto en este campo científico. Enfrenté este tipo de tareas por primera vez en el marco del hackathon FIT-M 2020 celebrado recientemente , donde tuve la suerte de participar como coorganizador y mentor. La experiencia me pareció interesante, en particular, por la oportunidad de tocar el campo de la informática de alto rendimiento (High Performance Computing en inglés), que a menudo se ejecutan en supercomputadoras . Descubrí cómo se puede configurar rápidamente el lanzamiento de los cálculos en un servidor en la nube y ver el resultado directamente a través del navegador, ¡incluso desde una tableta o teléfono!
Me pareció que no hay tantos materiales en ruso sobre el tema de la visualización de resultados en la web, aunque el tema en sí es bastante útil e interesante. Esperamos que esta guía paso a paso ayude a alguien con sus tareas diarias muy prácticas. O tal vez sea para alguien el primer paso hacia un nuevo e interesante campo de la ciencia.
Imagen tomada del Barcelona Supercomputing Center
Descargo de responsabilidad
Me propuse la tarea de mostrar la posibilidad misma de una rápida puesta en marcha y ajuste de los cálculos, para dar un punto de partida, pero de ninguna manera crear una aplicación web completa. No se hablará sobre la arquitectura potencial de tales soluciones, ni sobre el código fuente listo para usar. La solución está en la rodilla, pero rápida.
Breve introducción
, . , , ? : , , .
: , ? , , , ?
, (, - ).
(. Computational fluid dynamics — CFD). , . — , OpenFOAM (Open-source Field Operation And Manipulation). , , . , , , , , .. .
. CFD .
, , , , . , , , , : « ».
. .
, , (. mesh). , , (. cells). . , ( ). , . , , .
, :
- . , , , ;
- . , , (, , , , . .), ;
- (. postprocessing). , .
- . , , / , .
, . , (, . CAD). , .
, .
OpenFOAM — open-source , . , . : (. CPU) (. RAM). (. GPU) , .
. - . motorBike tutorial: 3D- . ( , ).
vCPU. ., Amazon, Microsoft, IBM, ..
, .
, SSH . Linux powershell/cmd Windows 10 :
$ ssh-keygen -t rsa -b 2048
. <>.pub, .
-
- https://console.cloud.yandex.ru " "
- Compute Cloud
- " "
( , ) . :
- 6 vCPU ( , tutorial-),
- 12
- 10 SSD .
- SSH , .
- , "" , . , .
- , "team01". " "
, , "Running".
. .
OpenFOAM
SSH , (Linux) powershell/cmd (Windows) :
$ ssh -i <_> <_>@<_ip_>
, .
, , OpenFOAM:
$ sudo sh -c "wget -O - https://dl.openfoam.org/gpg.key | apt-key add -" $ sudo add-apt-repository http://dl.openfoam.org/ubuntu $ sudo apt-get update $ sudo apt-get -y install openfoam8
. vi:
$ vi ~/.bashrc
- , i
- , : source /opt/openfoam8/etc/bashrc
- x!
SSH
$ exit
Bash:
$ simpleFoam -help
, OpenFOAM.
, , /opt/openfoam8/tutorials/incompressible/simpleFoam/
:
$ cd $HOME $ sudo mkdir -p $FOAM_RUN
$ cd $FOAM_RUN $ sudo cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/motorBike/ . $ sudo chmod -R a+rwx motorBike $ cd motorBike
, :
$ ./Allrun
, . output:
team01@team01:~/OpenFOAM/team01-8/run/motorBike$ ./Allrun Running surfaceFeatures on /home/team01/OpenFOAM/team01-8/run/motorBike Running blockMesh on /home/team01/OpenFOAM/team01-8/run/motorBike Running decomposePar on /home/team01/OpenFOAM/team01-8/run/motorBike Running snappyHexMesh in parallel on /home/team01/OpenFOAM/team01-8/run/motorBike using 6 processes Running patchSummary in parallel on /home/team01/OpenFOAM/team01-8/run/motorBike using 6 processes Running potentialFoam in parallel on /home/team01/OpenFOAM/team01-8/run/motorBike using 6 processes Running simpleFoam in parallel on /home/team01/OpenFOAM/team01-8/run/motorBike using 6 processes Running reconstructParMesh on /home/team01/OpenFOAM/team01-8/run/motorBike Running reconstructPar on /home/team01/OpenFOAM/team01-8/run/motorBike
Allrun. , OpenFOAM, . . , . , ( ):
$ blockMesh <-- $ decomposePar -copyZero <-- $ snappyHexMesh -overwrite <-- $ potentialFoam <-- $ reconstruct... <--
, . , . , , .. , - Intel Core i7 (, Windows 10 WSL) , : /system/decomposeParDict
numberOfSubdomains simpleCoeffs:
numberOfSubdomains 6; <--
method hierarchical;
// method ptscotch;
simpleCoeffs
{
n (4 1 1); <-- numberOfSubdomains
delta 0.001;
}
...
ParaView – open-source - . ParaView , . , ParaView , . OpenFOAM, . , ParaView , .
ParaView ( desktop), ( web).
. ParaView.
ParaView Visualization Toolkit (VTK), OpenGL MPI, . ParaView Server ( desktop web) . , Python QT. , :
- ParaView GUI, QT, . , Custom App, API .
- pvpython, Python.
- Paraview Catalyst, . , , - (, , , , ..).
- ParaViewWeb – web-framework, ParaView VTK Web- JavaScript. Three.js, VTK.js – VTK JavaScript.
, 3 OpenFOAM:
desktop ParaView. , , , .
desktop , X11-forwarding GUI . , "" "".
- ParaView . web- , : Visualizer, LightViz, ArticViewer, SimPut HPCCloud.
. , . , web-, API ( multi-user). , Python . .
ParaViewWeb
, , . Kitware web- docker-. , , . , . ParaView.
ParaView, Python dockerhub. :
- ParaViewWeb, Type = pvw
- GPU , Rendering = osmesa
- Major Python 2.x.x, Python = py2
Docker :
$ sudo apt install docker.io $ export DEMO_HOST=84.201.179.235 <-- IP $ export DEMO_PORT=9000 <-- "" $ export IMAGE_TO_RUN=kitware/paraview:pvw-v5.7.1-osmesa-py2 <--
demo web-:
$ mkdir -p demo $ cd demo $ curl -OL https://github.com/Kitware/paraviewweb-demo/archive/master.zip $ unzip master.zip
web- :
$ sudo docker pull kitware/paraview:pvw-v5.7.1-osmesa-py2
: OpenFOAM:
$ sudo docker run -v /home/team01/OpenFOAM/team01-8/demo/paraviewweb-demo-master/pvw:/pvw -v /home/team01/OpenFOAM/team01-8/run/motorBike:/data -p 0.0.0.0:9000:80 -e SERVER_NAME="${DEMO_HOST}:${DEMO_PORT}" -e PROTOCOL="ws" -ti ${IMAGE_TO_RUN}
-
. web- ParaViewWeb.
Visualizer " ". , : .
OpenFOAM " ". ParaView , , ParaView, Open FOAM. desktop OpenFOAM:
$ paraFoam
: *.foam. , ParaView .
GUI , paraFoam "" QT.
, :
$ touch motorBike.foam
, OpenFOAM. ParaViewWeb.

.
. ParaViewWeb
: .



. , . , . , . . .
, web-. Web - POST HTTP OpenFOAM , . -, .
. , Amazon (AWS Lambda):
.
,…
50 , . , , . , . , , — , .
Por supuesto, OpenFOAM y ParaView no son los únicos paquetes de software de simulación de ingeniería disponibles. Ya hay muchos de ellos. Pero debido a la complejidad de la configuración, por regla general, los especialistas y científicos involucrados en tales cálculos simplemente estudian una herramienta e intentan aplicarla en todas las tareas. Si hacemos que las herramientas sean más accesibles, creo que veremos muchas más aplicaciones de modelado en nuestras vidas, y esto puede ser muy útil. No en vano hay un proverbio: ¡mide siete veces, corta una vez!