FEM: Use single smesh mesh generator throughout FreeCAD
Creating a mesh generator resets a critical data structure and makes all existing meshes invalid. Hence the SMESH_gen is made a singleton and all FreeCAD code is changed accordingly.
This commit is contained in:
@@ -86,17 +86,13 @@ TYPESYSTEM_SOURCE(Fem::FemMesh , Base::Persistence);
|
||||
FemMesh::FemMesh()
|
||||
{
|
||||
//Base::Console().Log("FemMesh::FemMesh():%p (id=%i)\n",this,StatCount);
|
||||
myGen = new SMESH_Gen();
|
||||
// create a mesh allways with new StudyId to avoid overlapping destruction
|
||||
myMesh = myGen->CreateMesh(StatCount++,false);
|
||||
|
||||
myMesh = getGenerator()->CreateMesh(StatCount++,false);
|
||||
}
|
||||
|
||||
FemMesh::FemMesh(const FemMesh& mesh)
|
||||
{
|
||||
//Base::Console().Log("FemMesh::FemMesh(mesh):%p (id=%i)\n",this,StatCount);
|
||||
myGen = new SMESH_Gen();
|
||||
myMesh = myGen->CreateMesh(StatCount++,false);
|
||||
{
|
||||
myMesh = getGenerator()->CreateMesh(StatCount++,false);
|
||||
copyMeshData(mesh);
|
||||
}
|
||||
|
||||
@@ -109,16 +105,12 @@ FemMesh::~FemMesh()
|
||||
myMesh->Clear();
|
||||
//myMesh->ClearLog();
|
||||
delete myMesh;
|
||||
#if defined(__GNUC__)
|
||||
delete myGen; // crashes with MSVC
|
||||
#endif
|
||||
}
|
||||
|
||||
FemMesh &FemMesh::operator=(const FemMesh& mesh)
|
||||
{
|
||||
if (this != &mesh) {
|
||||
myGen = new SMESH_Gen();
|
||||
myMesh = myGen->CreateMesh(0,true);
|
||||
myMesh = getGenerator()->CreateMesh(0,true);
|
||||
copyMeshData(mesh);
|
||||
}
|
||||
return *this;
|
||||
@@ -134,7 +126,9 @@ void FemMesh::copyMeshData(const FemMesh& mesh)
|
||||
SMDS_NodeIteratorPtr aNodeIter = mesh.myMesh->GetMeshDS()->nodesIterator();
|
||||
for (;aNodeIter->more();) {
|
||||
const SMDS_MeshNode* aNode = aNodeIter->next();
|
||||
int id = aNode->GetID();
|
||||
double temp[3];
|
||||
Base::Console().Message("CopyData Mesh ID: %i\n", aNode->getMeshId());
|
||||
aNode->GetXYZ(temp);
|
||||
meshds->AddNodeWithID(temp[0],temp[1],temp[2], aNode->GetID());
|
||||
}
|
||||
@@ -331,7 +325,7 @@ SMESH_Mesh* FemMesh::getSMesh()
|
||||
|
||||
SMESH_Gen * FemMesh::getGenerator()
|
||||
{
|
||||
return myGen;
|
||||
return SMESH_Gen::get();
|
||||
}
|
||||
|
||||
void FemMesh::addHypothesis(const TopoDS_Shape & aSubShape, SMESH_HypothesisPtr hyp)
|
||||
@@ -346,37 +340,37 @@ void FemMesh::setStanardHypotheses()
|
||||
if (!hypoth.empty())
|
||||
return;
|
||||
int hyp=0;
|
||||
SMESH_HypothesisPtr len(new StdMeshers_MaxLength(hyp++, 1, myGen));
|
||||
SMESH_HypothesisPtr len(new StdMeshers_MaxLength(hyp++, 1, getGenerator()));
|
||||
static_cast<StdMeshers_MaxLength*>(len.get())->SetLength(1.0);
|
||||
hypoth.push_back(len);
|
||||
|
||||
SMESH_HypothesisPtr loc(new StdMeshers_LocalLength(hyp++, 1, myGen));
|
||||
SMESH_HypothesisPtr loc(new StdMeshers_LocalLength(hyp++, 1, getGenerator()));
|
||||
static_cast<StdMeshers_LocalLength*>(loc.get())->SetLength(1.0);
|
||||
hypoth.push_back(loc);
|
||||
|
||||
SMESH_HypothesisPtr area(new StdMeshers_MaxElementArea(hyp++, 1, myGen));
|
||||
SMESH_HypothesisPtr area(new StdMeshers_MaxElementArea(hyp++, 1, getGenerator()));
|
||||
static_cast<StdMeshers_MaxElementArea*>(area.get())->SetMaxArea(1.0);
|
||||
hypoth.push_back(area);
|
||||
|
||||
SMESH_HypothesisPtr segm(new StdMeshers_NumberOfSegments(hyp++, 1, myGen));
|
||||
SMESH_HypothesisPtr segm(new StdMeshers_NumberOfSegments(hyp++, 1, getGenerator()));
|
||||
static_cast<StdMeshers_NumberOfSegments*>(segm.get())->SetNumberOfSegments(1);
|
||||
hypoth.push_back(segm);
|
||||
|
||||
SMESH_HypothesisPtr defl(new StdMeshers_Deflection1D(hyp++, 1, myGen));
|
||||
SMESH_HypothesisPtr defl(new StdMeshers_Deflection1D(hyp++, 1, getGenerator()));
|
||||
static_cast<StdMeshers_Deflection1D*>(defl.get())->SetDeflection(0.01);
|
||||
hypoth.push_back(defl);
|
||||
|
||||
SMESH_HypothesisPtr reg(new StdMeshers_Regular_1D(hyp++, 1, myGen));
|
||||
SMESH_HypothesisPtr reg(new StdMeshers_Regular_1D(hyp++, 1, getGenerator()));
|
||||
hypoth.push_back(reg);
|
||||
|
||||
//SMESH_HypothesisPtr sel(new StdMeshers_StartEndLength(hyp++, 1, myGen));
|
||||
//SMESH_HypothesisPtr sel(new StdMeshers_StartEndLength(hyp++, 1, getGenerator()));
|
||||
//static_cast<StdMeshers_StartEndLength*>(sel.get())->SetLength(1.0, true);
|
||||
//hypoth.push_back(sel);
|
||||
|
||||
SMESH_HypothesisPtr qdp(new StdMeshers_QuadranglePreference(hyp++,1,myGen));
|
||||
SMESH_HypothesisPtr qdp(new StdMeshers_QuadranglePreference(hyp++,1,getGenerator()));
|
||||
hypoth.push_back(qdp);
|
||||
|
||||
SMESH_HypothesisPtr q2d(new StdMeshers_Quadrangle_2D(hyp++,1,myGen));
|
||||
SMESH_HypothesisPtr q2d(new StdMeshers_Quadrangle_2D(hyp++,1,getGenerator()));
|
||||
hypoth.push_back(q2d);
|
||||
|
||||
// Apply hypothesis
|
||||
@@ -386,7 +380,7 @@ void FemMesh::setStanardHypotheses()
|
||||
|
||||
void FemMesh::compute()
|
||||
{
|
||||
myGen->Compute(*myMesh, myMesh->GetShapeToMesh());
|
||||
getGenerator()->Compute(*myMesh, myMesh->GetShapeToMesh());
|
||||
}
|
||||
|
||||
std::set<long> FemMesh::getSurfaceNodes(long ElemId, short FaceId, float Angle) const
|
||||
|
||||
Reference in New Issue
Block a user