Multiple bodies from Salome to Elmer

From Elmer Wiki
Jump to: navigation, search

This wiki page describes how to create a mesh that contains multiple bodies with Salome MECA 2009 and how to import it in Elmer.

Define your geometry in Salomé

First, you need to define a geometry. In this example we deal with a simple one, with three boxes. We create two boxes which are intersecting each other. The intersection will be the third box. (You don't actually need to use the intersection operation, just make the two boxes.) Of course, you might as well define three separate boxes that share their respective surfaces geometrically. In this example, let's stick with the two intersecting ones (Figure 1).

Fig. 1: Draw the two boxes

Now we have defined our geometry, but it is not ready for meshing. Because, in order to mesh you need a single object and now you have two. Therefore we need to combine those solids together.

IT WOULD be natural to create a compound object which contains two solids, but this is not right way to do it. Because, when you create a compound, Salome will consider the solids as individuals and tries to create two separate meshes for each solid. For example in this case it would fail miserably.

What we need to do is to use the partition operation. You can find it from: Operations -> Partition (You need to be in geometry module). Then you pick up the objects, in this case the boxes we created. And you must not put anything at the tool object. This will create a partition object which you can mesh. (Figure 2.)

Fig. 2: Use the partition tool

Before we mesh anything, we must create volume groups for the geometry. These are needed later, when we create mesh groups (these are the things, to have different bodies in Elmer).

You can find the geometry group creation tool at: New Entity -> Group -> Create. Now, you pick volumes of course. You can either pick them from the picture or you can click the "Add All" button, and afterwards the "remove" button to get rid of the not wanted volumes. If you decide to pick them from the picture, it is recommended to show only the partition object (click the right mouse button and select "Show only"). In this case we have three volumes in the partition object. Make a group from each one of the volumes. (Figure 3)

Fig. 3: Pick volumes at the partition

Now, you should have a partition, made of two intersecting boxes, which contains three geometry groups. (Figure 4)

Fig. 4: The three boxes in the partition

To define boundaries, proceed in a similar manner: Create groups of faces (you can also explode your geometry so that you have all faces defined as groups at once).

Create the mesh

At this point you can move to the mesh module, to create a mesh for the partition object and compute it. In this example we use automatic netgen 1D-2D-3D (Figures 5 and 6).

Fig. 5: Define the mesh
Fig. 6: Compute the mesh

The mesh already obeys the internal surfaces of our three body assembly now, but does not separate them for Elmer to attribute boundary or body conditions later.

So, you have the mesh now but you are not yet having the mesh groups. You can find the mesh group creation tool in mesh module at: Mesh -> Create Group. There you have to pick your mesh, select the volumes radio button, and pick the groups you defined before in the geometry section: You push the "geometrical object" button, and after that you choose "Direct geometry selection" (Figure 7).

Fig. 7: Choose the groups

Then you pick one GEOMETRY GROUP at a time and create the same groups that you already defined in the geometry module (Figure 8).

Fig. 8: Pick the groups

Now you have everything you need. You need just to export the mesh in UNV format (from the file menu: Export -> UNV file).

Import & use the created mesh in Elmer

1st alternative:

To get the native elmer mesh format, you need to convert the mesh using ElmerGrid. Open your terminal, and change to the directory where you exported the unv -file. Then use the command:

ElmerGrid 8 2 nameOfYourFile.unv -autoclean

And there you have it. In ElmerGUI you use the "load mesh" button to open it.

In case you need parallel runs, you may partition the mesh with:

ElmerGrid 2 2 nameOfYourFile -metis [number of procs] [method]

where number of procs is obviously the number of your parallel processes and method is an integer number. Please do not use ".unv" after the name of the file (since actually now we are not operating to the unv file any more but the native Elmer mesh (it is actually a directory with the base name of the transformed unv file) that was generated with the previous command. For example:

ElmerGrid 2 2 nameOfYourFile -metis 16 4

is for partitioning the mesh in with metis in 16 partiotions with a metis method number 4. The partitioned mesh data will be found in the nameOfYourFile directory.

2nd alternative:

Load the UNV mesh directly into ElmerGUI by the command File -> Open. (This works at least for ElmerGUI versions later than April 2010.) Depending on the locale setting of the used machine you may need to change the pure text format of the UNV file from a "." representation to a "," representation prior to loading, though: An indication that this step is necessary is an obviously wrong geometrical representation of the geometry in ElmerGUI. This has e.g. been necessary for a german Ubuntu machine. One way to perform this step is the usage of the sed command:

sed "s/\./,/g" <Salome-out.unv >Elmer-in.unv

If you didn't define face groups in your mesh before, the individual boundaries of the defined boxes are not separated. With a simple "divide surface" operation from ElmerGUI's icon menu, or by the menu operation Mesh -> Divide surface, this is dealt with. Choose a value of 70° for rectangular boxes - at least this value always worked for me. For bended edges, please experiment and check by marking individual result surfaces in ElmerGUI by double-clicking on them!

After this step the body indexes and your individual surfaces exist, and boundary conditions can be attributed to them.