##### Personal tools
You are here: Home Is sharing of sub-meshes possible ?

# Is sharing of sub-meshes possible ?

Up to How to use Salome?

### Is sharing of sub-meshes possible ?

Posted by Roman Lygin at April 07. 2011

As I'm just learning Salome development, I keep on asking .

Imagine you have a 3D geometrical assembly consisting of components with different locations (transformation matrices). For instance, a TopoDS_Compound of 4 TopoDS_Solids sharing the same geometry with 4 different locations. Thus, all solids are 'partners' (in terms of Open CASCADE API TopoDS_Shape::IsPartner()).

When meshing such a shape (via Mefisto, Netgen,...), will resulting SMESH_Mesh contain a shared set of elements (triangles) or will it have 4 instances ? If each box face is split into 2 triangles, will there be 6 * 2 = 12 triangles + 4 locations or will there be 6 * 2 * 4 = 48 independent triangles ? Obviously the former would be preferred as it gives more direct mapping with original geom model and imposes smaller memory footprint.

Though there is a notion of sub-mesh in Salome I could not find a representation of the transformation yet.

Any suggestion would be appreciated.

Thank you,

Roman

### Re: Is sharing of sub-meshes possible ?

Posted by Saint Michael at April 07. 2011

Hi Roman

When meshing such a shape (via Mefisto, Netgen,...), will resulting SMESH_Mesh contain a shared set of elements (triangles) or will it have 4 instances ?

There will be 4 instances.

BR St.Michael

### Re: Is sharing of sub-meshes possible ?

Posted by Roman Lygin at April 07. 2011

Hi St. Michael,

Thank you very much for a lightning-fast response. Great to hear that.

To not abuse your time, I'll try to understand myself how the resulting mesh will look like (with the debugger). Will ask if won't be able to figure it out .

Roman

### Re: Is sharing of sub-meshes possible ?

Posted by Saint Michael at April 07. 2011

To not abuse your time, I'll try to understand myself how the resulting mesh will look like (with the debugger).

You'll find it out faster if you run Salome and mesh such a model.

BR SM

### Re: Is sharing of sub-meshes possible ?

Posted by Roman Lygin at April 08. 2011

St Michael,

Your comment that there is no reuse of meshes for partner sub-shapes (see http://salome-platform.org/forum/forum_11/426837638) made me doubt how then sharing would be possible (you stated in this thread above). So I went and conducted a simple experiment.

Tried to mesh the attached shape (circular face with 3 different locations - i.e. 3 partners) both in Salome GUI (as you suggested) and programmatically. I used Regular1D (with Arithmetic 1D hypothesis) and Mefisto.

I could not figure out visually if there is sharing and exporting into the formats (DAT, STL, MED,...) does not help either - no sharing. I don't know if the format allows that at all (for example, STL does not - all the nodes have to be independently stored). So what way did you imply when recommending GUI ? Checking this via GUI would of course be faster in the future.

Using the debugger confirmed my suspicions . All the edges were meshed independently (3 times - 3 faces of 1 edge each), and all the faces were independently meshed too (3 times). After each iteration the number of nodes, edges and faces increased in associated SMDS_Mesh. So obviously no sharing or reuse of previous computations ever happened. The code is below. It's just experimental with a lot of memory leaks (see earlier posts) but represents the approach.

What am I missing? How to enforce mesh sharing instead of duplication or independent instancing ?

Thank you again for your time and help.

Roman

//shape
TopoDS_Shape aShape;
if (!BRepTools::Read (aShape, "C:/temp/test.brep", BRep_Builder())) {
cerr << "Failed to read" << endl;
return;
}

boost::shared_ptr<SMESH_Gen> aGen (new SMESH_Gen());
const int aStudyId = 0;

//create shared pointers to ensure object destruction afterwards
boost::shared_ptr<StudyContextStruct> aStudyCtx (aGen->GetStudyContext (aStudyId));

boost::shared_ptr<SMESH_Mesh> aMesh (aGen->CreateMesh (aStudyId /*0*/, true));
// # 1D
boost::shared_ptr<StdMeshers_Arithmetic1D> an1DHypothesis (new StdMeshers_Arithmetic1D (
0 /*hypId*/, aStudyId, aGen.get())); //discretization of the wire
// # The smallest and longer distance between edges is computed from the _precision value
double min_dist = 1.;
double max_dist = 10.;
an1DHypothesis->SetLength (min_dist,false); //the smallest distance between 2 points
an1DHypothesis->SetLength (max_dist,true); // the longest distance between 2 points
boost::shared_ptr<StdMeshers_Regular_1D> an1DAlgo (new StdMeshers_Regular_1D (1 /*hypId*/, aStudyId /*0*/, aGen.get())); // interpolation
// # 2D
boost::shared_ptr<SMESH_Algo> a2dAlgo (new StdMeshers_MEFISTO_2D (2 /*hypId*/, aStudyId /*0*/, aGen.get()));
aMesh->ShapeToMesh (aShape);
// #Assign hypothesis to mesh
// #Compute the data
aGen->Compute (*aMesh, aShape);

Attachments

### Re: Is sharing of sub-meshes possible ?

Posted by Saint Michael at April 08. 2011

I could not figure out visually if there is sharing

Sorry, I did not understand what sharing you meant. I thought of sharing of mesh surfaces between 3D mesh domains created on solids not connected topologically.

Reuse of mesh entities built on partner shapes with different location is a interesting idea. It is not realized in SMESH.

On the other hand, partner shapes encounter not so often in real world models.

If you want to realize this idea in your own application, it is necessary to take into account that two partner shapes can be tessellated  with different meshing parameters and then mesh on them should not be shared.

BR

### Re: Is sharing of sub-meshes possible ?

Posted by Roman Lygin at April 08. 2011

Hi St Michael,

Thanks for returning comments and clarification.

On the other hand, partner shapes encounter not so often in real world models.

Of course, they are not part of every model. But they are part of every typical complex assembly consisting of multiple reusable components. This is an approach used in CAD modeling, so a STEP file describing a complex assembly will likely contain such. And given that complex assemblies are likely to be the most resource-consuming (both for calculation and memory footprint), reusing mesh components would likely be one of the most efficient ways to go. So please consider this enhancement request.

If you want to realize this idea in your own application, it is necessary to take into account that two partner shapes can be tessellated  with different meshing parameters and then mesh on them should not be shared.

This is a valid point but it can also be easily addressed in efficient implementation. You create shared sub-meshes by default. As soon as you need to refine or change one, you create a copy and modify it. That is a 'pay-as-you-go' principle.

Thanks again,

Roman