CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   surfMesh, surfaceMesh, meshedSurface? (https://www.cfd-online.com/Forums/openfoam-programming-development/224305-surfmesh-surfacemesh-meshedsurface.html)

frobaux February 13, 2020 07:43

surfMesh, surfaceMesh, meshedSurface?
 
Hello foamer,

I'm currently trying to implement an special immersed boundary method.



- At a given time step a "surface mesh" is given by an external solver, with openFoam format:

* point

* face.
- It is read and stored by a very simple class I've develloped for now, that is almost a copy of polyMesh.H, but with everything concerning cells removed.



- I would like to further triangulate this surface to obtain a triSurfaceMesh_ to perform some already existing operation.



Does anyone have any idea from which class I should inherit?

There is a lot, like surfMesh, surfaceMesh, meshedSurface,


From what I understand, MeshedSurface would be the best choice, but I do not see any IO capabilities. surfMesh does have some, but I don't see any triangulation method available.


Thank you a lot for your help!
Fabien

HPE February 13, 2020 17:32

There are fair amount of experimental OF implementations for IBM. foam-extend has one as well. I would start to use and modify them instead of reinventing the wheel.

Apart from that, personally I have no idea on ur Qs, Im afraid. Wish u luck.

frobaux February 14, 2020 04:13

Well, actually, that is the idea, but most of the existing IBM I found were using:
1. A fixed IBM
2. A .str (or .ftr) file.

So they have direct access to the triangulated surface.
My goal is to use their function, but for that I need to convert my type of surface into a triangulated one.



Currently what I found is:
- I inherit from MeshedSurface.

- Import my surface with MeshedSurfaceIOAllocator
- Convert to triangulated
- store the triangulated into triSf_
Not the best, because at the end I store twice the triangulated surface (one time as a listFace and one time as a triSurface)

olesen February 23, 2020 06:42

Quote:

Originally Posted by frobaux (Post 757993)
Hello foamer,

I'm currently trying to implement an special immersed boundary method.

- At a given time step a "surface mesh" is given by an external solver, with openFoam format:

* point

* face.
- It is read and stored by a very simple class I've develloped for now, that is almost a copy of polyMesh.H, but with everything concerning cells removed.

- I would like to further triangulate this surface to obtain a triSurfaceMesh_ to perform some already existing operation.

Does anyone have any idea from which class I should inherit?

There is a lot, like surfMesh, surfaceMesh, meshedSurface,


From what I understand, MeshedSurface would be the best choice, but I do not see any IO capabilities. surfMesh does have some, but I don't see any triangulation method available.


Thank you a lot for your help!
Fabien


As you can guess, there are far many options, not all of which are clear.
First off, you should eliminate surfMesh from consideration. It is/was designed to as a registered IO object similar to a polyMesh or fvMesh, which means that it reads/writes from the OpenFOAM time directories in a native OpenFOAM format.


If your mesh should be used in an untriangulated form, you then have the choice of a MeshedSurface and an UnsortedMeshedSurface. The regular MeshedSurface uses the assumption that your surface mesh has surface "regions" that are sorted - much the OpenFOAM boundaries idea (from start/size for each region). This of course also applies if you have zero or one region.
The UnsortedMeshedSurface keeps an additional set of indices to track which region each face belongs to.



Both MeshedSurface and UnsortedMeshedSurface are templated on a face type. If the templated face type is a triFace or labelledTri, the surfaces read will be automatically triangulated. However, even if you template on a face, you can force triangulation at a later stage with the triangulate() method. This method has two signatures. If you need to recover the faceMap to know what the original untriangulated faces where, use the method with the additional parameter.


All of the triSurface, MeshedSurface, UnsortedMeshed surface format share a reasonable amount of common reading/writing routines that are run-time selectable. This is actually where you should be injecting your format.


Take a look under the src/surfMesh/surfaceFormats directory. Perhaps the simplest one to look at is the obj/ code. The OBJsurfaceFormatRunTime.C includes the run-time selection, within the OBJsurfaceFormat.C you will find how the reading looks and where the decision is made to triangulate (eg, based on the faceTraits).


To move this into a triSurfaceMesh will be a bit easier if you are using the openfoam.com version. There you will notice that runtime selection tables are also templated on a labelledTri, which means that these readers are automatically known to be good for a triSurface.

If you are using the openfoam.org version, you will have more trouble since their triSurface reader extensions are hard-coded into triSurface.
You will still be able to get the surfaces across, but will need to strip out a List of labelledTri and pass that into the triSurface constructor. Still doable, but more work and the reading will not happen automatically.


Could be a good topic for a wiki entry?


/mark

frobaux February 24, 2020 07:15

Wow, Thank you a lot for your detailled answer. I have to admit that I didn't understood everything!

I've taken a look into the OBJ format. (which I already saw) it seems to be closed from my format but not exactly that. I just chose the format I currently use thinking that it would be simpler as it is the native OF format for meshes.

As for my surface Mesh, I don't need it in an untriangulated form at all. It just happens that it is in such a form when reading.

From what I've told in #3. , I'm not using the best way to do it for now, but it works, even if I know it's neither clean nor elegant, nor even memory efficient. I inherit my new class from the templated form of MeshedSurface on face, such that faces (untriangulated), points and zones are stored inside stored...(). The reading is done directly inside the new constructor of this class. Then I force the triangulation and save it into a triSurface member.

For your last question so as for it to be a good wiki entry, I completely agree!

Ps. When you talk about region, do you mean what is called in "zone" in the source code? I'm not using any and I works for now. Should I worry about that?


All times are GMT -4. The time now is 04:41.