OFDataCommittee / openfoam-smartsim

Sub-module for OpenFOAM that provides a solver for embedding SmartSim and its external dependencies (i.e. SmartRedis) into OpenFOAM.
GNU General Public License v3.0
22 stars 11 forks source link

Using different solvers #28

Open mijanr opened 1 month ago

mijanr commented 1 month ago

I am new to OpenFOAM, so I don't have almost any OpenFOAM programming experience. I would like to build DL models in Python, and use the smartsim/smartredis infrastructure to to make communication between OpenFOAM and ML models.

However, I don't understand if I need to code my own solvers like you did in:

I went through the Allwamke script, and I it tries to build these files. So, my question is, if I want to, let's say, use icoFoam solver for the lid-driven-cavity case, and I want to get field values at every seconds, and use these values to train my PINN model, do I need to change anything in the icoFoam solver?

I appreciate your answer to my question.

Thank you.

FoamScience commented 1 month ago

Hi, seems you want to look at this functionObject tutorials as it showcases exactly what you want: Send OpenFOAM fields to a SmartRedis database and run an SVD algorithm on them...

OpenFOAM's function objects are basically UDFs that can hook to any solver, without requiring changes to the solver itself.

AndreWeiner commented 1 month ago

Hi @mijanr, as Elwardi mentioned, fieldsToSmartRedis is a suitable option for processing OpenFOAM data elsewhere, e.g., in a Python script, especially if you want the processing to happen during the simulation. Alternatively, if you only use OpenFOAM to generate flow data once, you can also write the data to disk and process it later. If you need two-way communication, i.e., you want to send data back to OpenFOAM during the simulation, have a look at the svdToFoam utility (communication to OpenFOAM once at the end for postprocessing) or at the displacementSmartSimMotionSolver (communication every couple of time steps). The accompanying Python scripts under tutorials give you plenty of code snippets demonstrating how to receive and send data on the Python side. Cheers, Andre