In this article I will tell you how you can easily, quickly and cheaply assemble your package for modeling fluid dynamics problems in the cloud. I'll do this using a combination of two tools: the OpenFOAM continuum mechanics numerical simulator and the ParaView dataset visualization toolkit.
I am an ordinary developer and am not an expert in this scientific field. I faced this type of tasks for the first time in the framework of the recently held FIT-M 2020 hackathon , where I was lucky enough to participate as a co-organizer and mentor. The experience seemed interesting to me, in particular, because of the opportunity to touch the field of high performance computing (English High Performance Computing), which are often run on supercomputers . I figured out how you can quickly set up the launch of calculations on a server in the cloud and look at the result directly through the browser, even from a tablet or phone!
It seemed to me that there are not so many materials in Russian on the topic of visualizing results on the web, although the topic itself is quite useful and interesting. Hopefully this step-by-step guide will help someone with their very practical daily tasks. Or maybe it will become for someone the first step into a new and interesting field of science.
Image taken from Barcelona Supercomputing Center
Disclaimer
I set myself the task of showing the very possibility of quick start-up and adjustment of calculations, to give a starting point, but by no means building a full-fledged web application. There will be no talk about the potential architecture of such solutions, nor the ready-made source code. The solution is on the knee, but fast.
Short introduction
, . , , ? : , , .
: , ? , , , ?
, (, - ).
(. 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 , . , , . , . , , — , .
Of course, OpenFOAM and ParaView are not the only engineering simulation software packages available. There are already a lot of them. But due to the complexity of the setup, as a rule, specialists and scientists involved in such calculations simply study one tool and try to apply it in all tasks. If we make the tools more accessible, then I think we will see a lot more applications of modeling in our lives, and this can be very useful. It's not for nothing that there is a proverb: measure seven times, cut once!