Personal tools
You are here: Home Forum Extension of the platform How to define a submesh in c++?

How to define a submesh in c++?

Up to Extension of the platform

How to define a submesh in c++?

Posted by zhang chunyu at December 22. 2018

Dear all,

    I am using the stand-alone SMESH module in my C++ program and it works very well.  Now I am trying to refine the mesh around a hole by defining a submesh as follows,

 

   SMESH_Gen *meshGenerator=GetMeshGenerator();   

   SMESH_Mesh* partMesh = meshGenerator->CreateMesh(0,false);

 

    //define the global size

      NETGENPlugin_NETGEN_2D3D *alg2D3D=new NETGENPlugin_NETGEN_2D3D(0,0,meshGenerator);  

      partMesh->AddHypothesis(partMesh->GetShapeToMesh(),0);

      NETGENPlugin_Hypothesis *hyp2D=new NETGENPlugin_Hypothesis(1,0,meshGenerator);

hyp2D->SetMaxSize(maxsize);

hyp2D->SetMinSize(minsize);

hyp2D->SetFineness(NETGENPlugin_Hypothesis::Fineness(finess)); 

partMesh->AddHypothesis(partMesh->GetShapeToMesh(),1);

 // define the local size on selected small faces 

      TopoDS_Compound smallFaces=GetFacesSmallerThan(partMesh->GetShapeToMesh(),100);

      NETGENPlugin_Hypothesis *hyp2D_fine=new NETGENPlugin_Hypothesis(2,0,meshGenerator);

     hyp2D->SetMaxSize(0.1*maxsize); 

      hyp2D->SetMinSize(0.1*minsize);

      partMesh->AddHypothesis( smallFaces,2); 

  // generate the mesh

     meshGenerator->Compute(*partMesh,partMesh->GetShapeToMesh());

    

But the local refinement does not work. I also tried to define a new SMESH_subMesh but it is not a 'true' mesh so a local size cannot be assigned. I read the 'Compute' function but did not find the answer.

 

Any suggestion on proper using submesh for local refinement is greatly apprecited.

And Merry Chirstmas!

    

Re: How to define a submesh in c++?

Posted by SMESH expert at December 24. 2018

Hello,

I suspect it is an trivial copy/paste error:

NETGENPlugin_Hypothesis *hyp2D_fine=new NETGENPlugin_Hypothesis(2,0,meshGenerator);

     hyp2D->SetMaxSize(0.1*maxsize); 

Best regards

Edward

Powered by Ploneboard
Document Actions