How to apply a different geometry to a trained model?

Hi there,

I’d like to use my trained neural network to apply it to a similar but different geometry. I’ve read about the eval() mode, but I need more information.

I know there are already few basic topics in this forum as well as the three fin example, but which instances does my skript need if I want to use a different geometry instead of another parameterset?
Do I need to define all my Constraints just like when training a model? What do I need to change apart from my geometry?
Basically how should my basic script look like? Which instances are mandatory? Or is this even possible?

A fast forward help would be much appreciated.

Many thanks in advance.

Hi @jflatter

If you want to change the geometry, then its just updating the geometry object that is fed into the constraints/inferencers/monitors. E.g. The (point wise) constraints view the geometry as this point generator, thats it. For example, you could define a circle for the heat_sink geometry used here and the solver should then just sample training points based on this new shape.

Its the same deal for pointwise inferencers. For inference (with a trained model), just define your new geometry (assuming its of the same dimension as your previous geometry) and provide it to a pointwise inferencer thats added to a solver. Assuming all other input variables are provided and the symbolic graph can unroll you should be good to go to call solver.eval().

Hi @ngeneva

Thank you for your reply.

I tried applying a trained model to a different geometry (different size and less obstacles in the channel). All I used was the pointwise validator (for openfoam reference) and I changed my mode to eval(), just like you said. I defined the new geometry including all boundary conditions just like the one I trained on.

However, Modulus just seems to resample the trained interior onto the new domain, without “calculating” any different behavior. I attached a picture for better understanding. There you can see that Modulus doesn’t take the new obstacle into account at all. Where is my mistake?

Many thanks in advance.

Hi @jflatter

Hmmm,

I’m assuming your model has some sort of parameter / input that would reflect the new geometry (i.e. its not just x or y) otherwise your network will have no idea if anything has changed since its point wise.

Consider generating a VTK point cloud output by changing the ouput format in the config (example here). Then display that VTP file in Paraview to see what points were actually sampled and if that reflects your geometry.

Its hard to tell from these matplotlib plots since it actually interpolates the unstructured points onto a grid under the hood for these images.