FEM: Make FEM compatible with SMESH7
This commit is contained in:
parent
61f503ad51
commit
47f21309dd
|
@ -26,6 +26,8 @@ include(cMake/FreeCadMacros.cmake)
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cMake")
|
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cMake")
|
||||||
|
|
||||||
|
find_package(VTK REQUIRED)
|
||||||
|
include(${VTK_USE_FILE})
|
||||||
|
|
||||||
#if(CMAKE_CFG_INTDIR STREQUAL .)
|
#if(CMAKE_CFG_INTDIR STREQUAL .)
|
||||||
# No Debug/Release output paths
|
# No Debug/Release output paths
|
||||||
|
|
54
cMake/FindMEDFile.cmake
Normal file
54
cMake/FindMEDFile.cmake
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
# - Find MED file installation
|
||||||
|
#
|
||||||
|
# The following variable are set:
|
||||||
|
# MEDFILE_INCLUDE_DIRS
|
||||||
|
# MEDFILE_LIBRARIES
|
||||||
|
# MEDFILE_C_LIBRARIES
|
||||||
|
# MEDFILE_F_LIBRARIES
|
||||||
|
#
|
||||||
|
# The CMake (or environment) variable MEDFILE_ROOT_DIR can be set to
|
||||||
|
# guide the detection and indicate a root directory to look into.
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
# Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
#
|
||||||
|
# This library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2.1 of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This library is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this library; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
|
#
|
||||||
|
|
||||||
|
# ------
|
||||||
|
|
||||||
|
MESSAGE(STATUS "Check for medfile (libmed and libmedc) ...")
|
||||||
|
|
||||||
|
# ------
|
||||||
|
|
||||||
|
SET(MEDFILE_ROOT_DIR $ENV{MEDFILE_ROOT_DIR} CACHE PATH "Path to the MEDFile.")
|
||||||
|
IF(MEDFILE_ROOT_DIR)
|
||||||
|
LIST(APPEND CMAKE_PREFIX_PATH "${MEDFILE_ROOT_DIR}")
|
||||||
|
ENDIF(MEDFILE_ROOT_DIR)
|
||||||
|
|
||||||
|
FIND_PATH(MEDFILE_INCLUDE_DIRS med.h)
|
||||||
|
#FIND_PROGRAM(MDUMP mdump)
|
||||||
|
FIND_LIBRARY(MEDFILE_C_LIBRARIES NAMES medC)
|
||||||
|
FIND_LIBRARY(MEDFILE_F_LIBRARIES NAMES med)
|
||||||
|
IF(MEDFILE_F_LIBRARIES)
|
||||||
|
SET(MEDFILE_LIBRARIES ${MEDFILE_C_LIBRARIES} ${MEDFILE_F_LIBRARIES})
|
||||||
|
ELSE(MEDFILE_F_LIBRARIES)
|
||||||
|
SET(MEDFILE_LIBRARIES ${MEDFILE_C_LIBRARIES})
|
||||||
|
ENDIF(MEDFILE_F_LIBRARIES)
|
||||||
|
|
||||||
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MEDFile REQUIRED_VARS MEDFILE_INCLUDE_DIRS MEDFILE_LIBRARIES)
|
|
@ -8,6 +8,8 @@ if(BUILD_FEM_NETGEN)
|
||||||
add_definitions(-DFCWithNetgen ${NETGEN_DEFINITIONS})
|
add_definitions(-DFCWithNetgen ${NETGEN_DEFINITIONS})
|
||||||
endif(BUILD_FEM_NETGEN)
|
endif(BUILD_FEM_NETGEN)
|
||||||
|
|
||||||
|
find_package(VTK REQUIRED)
|
||||||
|
include(${VTK_USE_FILE})
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
${CMAKE_BINARY_DIR}
|
${CMAKE_BINARY_DIR}
|
||||||
|
@ -22,6 +24,7 @@ include_directories(
|
||||||
${ZLIB_INCLUDE_DIR}
|
${ZLIB_INCLUDE_DIR}
|
||||||
${XercesC_INCLUDE_DIRS}
|
${XercesC_INCLUDE_DIRS}
|
||||||
${SMESH_INCLUDE_DIR}
|
${SMESH_INCLUDE_DIR}
|
||||||
|
${VTK_INCLUDE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
link_directories(${OCC_LIBRARY_DIR})
|
link_directories(${OCC_LIBRARY_DIR})
|
||||||
|
@ -227,7 +230,7 @@ SET(Fem_SRCS
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(Fem SHARED ${Fem_SRCS})
|
add_library(Fem SHARED ${Fem_SRCS})
|
||||||
target_link_libraries(Fem ${Fem_LIBS})
|
target_link_libraries(Fem ${Fem_LIBS} ${VTK_LIBRARIES})
|
||||||
|
|
||||||
|
|
||||||
fc_target_copy_resource(Fem
|
fc_target_copy_resource(Fem
|
||||||
|
|
|
@ -68,6 +68,8 @@
|
||||||
#include <StdMeshers_QuadraticMesh.hxx>
|
#include <StdMeshers_QuadraticMesh.hxx>
|
||||||
|
|
||||||
# include <TopoDS_Face.hxx>
|
# include <TopoDS_Face.hxx>
|
||||||
|
# include <TopoDS_Solid.hxx>
|
||||||
|
# include <TopoDS_Shape.hxx>
|
||||||
|
|
||||||
//to simplify parsing input files we use the boost lib
|
//to simplify parsing input files we use the boost lib
|
||||||
#include <boost/tokenizer.hpp>
|
#include <boost/tokenizer.hpp>
|
||||||
|
@ -115,6 +117,8 @@ FemMesh::~FemMesh()
|
||||||
FemMesh &FemMesh::operator=(const FemMesh& mesh)
|
FemMesh &FemMesh::operator=(const FemMesh& mesh)
|
||||||
{
|
{
|
||||||
if (this != &mesh) {
|
if (this != &mesh) {
|
||||||
|
myGen = new SMESH_Gen();
|
||||||
|
myMesh = myGen->CreateMesh(0,true);
|
||||||
copyMeshData(mesh);
|
copyMeshData(mesh);
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -122,26 +126,18 @@ FemMesh &FemMesh::operator=(const FemMesh& mesh)
|
||||||
|
|
||||||
void FemMesh::copyMeshData(const FemMesh& mesh)
|
void FemMesh::copyMeshData(const FemMesh& mesh)
|
||||||
{
|
{
|
||||||
//const SMDS_MeshInfo& info = mesh.myMesh->GetMeshDS()->GetMeshInfo();
|
SMESH_Mesh *test;
|
||||||
//int numPoly = info.NbPolygons();
|
|
||||||
//int numVolu = info.NbVolumes();
|
|
||||||
//int numTetr = info.NbTetras();
|
|
||||||
//int numHexa = info.NbHexas();
|
|
||||||
//int numPyrd = info.NbPyramids();
|
|
||||||
//int numPris = info.NbPrisms();
|
|
||||||
//int numHedr = info.NbPolyhedrons();
|
|
||||||
|
|
||||||
_Mtrx = mesh._Mtrx;
|
_Mtrx = mesh._Mtrx;
|
||||||
|
|
||||||
SMESHDS_Mesh* meshds = this->myMesh->GetMeshDS();
|
SMESHDS_Mesh* meshds = this->myMesh->GetMeshDS();
|
||||||
meshds->ClearMesh();
|
|
||||||
|
|
||||||
SMDS_NodeIteratorPtr aNodeIter = mesh.myMesh->GetMeshDS()->nodesIterator();
|
SMDS_NodeIteratorPtr aNodeIter = mesh.myMesh->GetMeshDS()->nodesIterator();
|
||||||
for (;aNodeIter->more();) {
|
for (;aNodeIter->more();) {
|
||||||
const SMDS_MeshNode* aNode = aNodeIter->next();
|
const SMDS_MeshNode* aNode = aNodeIter->next();
|
||||||
meshds->AddNodeWithID(aNode->X(),aNode->Y(),aNode->Z(), aNode->GetID());
|
double temp[3];
|
||||||
|
aNode->GetXYZ(temp);
|
||||||
|
meshds->AddNodeWithID(temp[0],temp[1],temp[2], aNode->GetID());
|
||||||
}
|
}
|
||||||
|
|
||||||
SMDS_EdgeIteratorPtr aEdgeIter = mesh.myMesh->GetMeshDS()->edgesIterator();
|
SMDS_EdgeIteratorPtr aEdgeIter = mesh.myMesh->GetMeshDS()->edgesIterator();
|
||||||
for (;aEdgeIter->more();) {
|
for (;aEdgeIter->more();) {
|
||||||
const SMDS_MeshEdge* aEdge = aEdgeIter->next();
|
const SMDS_MeshEdge* aEdge = aEdgeIter->next();
|
||||||
|
@ -559,7 +555,6 @@ std::set<int> FemMesh::getNodesBySolid(const TopoDS_Solid &solid) const
|
||||||
result.insert(aNode->GetID());
|
result.insert(aNode->GetID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -873,6 +868,7 @@ void FemMesh::read(const char *FileName)
|
||||||
}
|
}
|
||||||
else if (File.hasExtension("dat") ) {
|
else if (File.hasExtension("dat") ) {
|
||||||
// read brep-file
|
// read brep-file
|
||||||
|
// vejmarie disable
|
||||||
myMesh->DATToMesh(File.filePath().c_str());
|
myMesh->DATToMesh(File.filePath().c_str());
|
||||||
}
|
}
|
||||||
else if (File.hasExtension("bdf") ) {
|
else if (File.hasExtension("bdf") ) {
|
||||||
|
|
|
@ -143,6 +143,9 @@ public:
|
||||||
void read(const char *FileName);
|
void read(const char *FileName);
|
||||||
void write(const char *FileName) const;
|
void write(const char *FileName) const;
|
||||||
void writeABAQUS(const std::string &Filename) const;
|
void writeABAQUS(const std::string &Filename) const;
|
||||||
|
Base::Matrix4D _Mtrx;
|
||||||
|
SMESH_Gen *myGen;
|
||||||
|
SMESH_Mesh *myMesh;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void copyMeshData(const FemMesh&);
|
void copyMeshData(const FemMesh&);
|
||||||
|
@ -150,9 +153,9 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// positioning matrix
|
/// positioning matrix
|
||||||
Base::Matrix4D _Mtrx;
|
// Base::Matrix4D _Mtrx;
|
||||||
SMESH_Gen *myGen;
|
// SMESH_Gen *myGen;
|
||||||
SMESH_Mesh *myMesh;
|
// SMESH_Mesh *myMesh;
|
||||||
|
|
||||||
std::list<SMESH_HypothesisPtr> hypoth;
|
std::list<SMESH_HypothesisPtr> hypoth;
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include <Base/Console.h>
|
#include <Base/Console.h>
|
||||||
|
|
||||||
#include <SMESH_Gen.hxx>
|
#include <SMESH_Gen.hxx>
|
||||||
|
|
||||||
#include <SMESH_Mesh.hxx>
|
#include <SMESH_Mesh.hxx>
|
||||||
#include <SMDS_PolyhedralVolumeOfNodes.hxx>
|
#include <SMDS_PolyhedralVolumeOfNodes.hxx>
|
||||||
#include <SMDS_VolumeTool.hxx>
|
#include <SMDS_VolumeTool.hxx>
|
||||||
|
@ -76,32 +77,37 @@ App::DocumentObjectExecReturn *FemMeshShapeNetgenObject::execute(void)
|
||||||
#ifdef FCWithNetgen
|
#ifdef FCWithNetgen
|
||||||
|
|
||||||
Fem::FemMesh newMesh;
|
Fem::FemMesh newMesh;
|
||||||
|
// SMESH_Gen *myGen = newMesh.getGenerator();
|
||||||
|
// vejmarie NEEDED TO MAKE IT WORK
|
||||||
|
newMesh.myMesh = newMesh.myGen->CreateMesh(0, true);
|
||||||
Part::Feature *feat = Shape.getValue<Part::Feature*>();
|
Part::Feature *feat = Shape.getValue<Part::Feature*>();
|
||||||
|
|
||||||
|
|
||||||
TopoDS_Shape shape = feat->Shape.getValue();
|
TopoDS_Shape shape = feat->Shape.getValue();
|
||||||
|
|
||||||
|
|
||||||
newMesh.getSMesh()->ShapeToMesh(shape);
|
// newMesh.myMesh->ShapeToMesh(shape);
|
||||||
SMESH_Gen *myGen = newMesh.getGenerator();
|
// SMESH_Gen *myGen = newMesh.getGenerator();
|
||||||
|
// meshgen->CreateMesh(0, true);
|
||||||
|
|
||||||
int hyp=0;
|
int hyp=0;
|
||||||
|
|
||||||
NETGENPlugin_Mesher myNetGenMesher(newMesh.getSMesh(),shape,true);
|
NETGENPlugin_Mesher myNetGenMesher(newMesh.getSMesh(),shape,true);
|
||||||
|
/*
|
||||||
|
NETGENPlugin_SimpleHypothesis_2D * tet2 = new NETGENPlugin_SimpleHypothesis_2D(hyp++,1,myGen);
|
||||||
|
static_cast<NETGENPlugin_SimpleHypothesis_2D*>(tet2.get())->SetNumberOfSegments(5);
|
||||||
|
static_cast<NETGENPlugin_SimpleHypothesis_2D*>(tet2.get())->SetLocalLength(0.1);
|
||||||
|
static_cast<NETGENPlugin_SimpleHypothesis_2D*>(tet2.get())->LengthFromEdges();
|
||||||
|
myNetGenMesher.SetParameters(tet2);
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
NETGENPlugin_SimpleHypothesis_3D* tet= new NETGENPlugin_SimpleHypothesis_3D(hyp++,1,myGen);
|
||||||
|
static_cast<NETGENPlugin_SimpleHypothesis_3D*>(tet.get())->LengthFromFaces();
|
||||||
|
static_cast<NETGENPlugin_SimpleHypothesis_3D*>(tet.get())->SetMaxElementVolume(0.1);
|
||||||
|
myNetGenMesher.SetParameters( tet);
|
||||||
|
*/
|
||||||
|
|
||||||
//NETGENPlugin_SimpleHypothesis_2D * tet2 = new NETGENPlugin_SimpleHypothesis_2D(hyp++,1,myGen);
|
NETGENPlugin_Hypothesis* tet= new NETGENPlugin_Hypothesis(hyp++,1,newMesh.myGen);
|
||||||
//static_cast<NETGENPlugin_SimpleHypothesis_2D*>(tet2.get())->SetNumberOfSegments(5);
|
|
||||||
//static_cast<NETGENPlugin_SimpleHypothesis_2D*>(tet2.get())->SetLocalLength(0.1);
|
|
||||||
//static_cast<NETGENPlugin_SimpleHypothesis_2D*>(tet2.get())->LengthFromEdges();
|
|
||||||
//myNetGenMesher.SetParameters(tet2);
|
|
||||||
|
|
||||||
//NETGENPlugin_SimpleHypothesis_3D* tet= new NETGENPlugin_SimpleHypothesis_3D(hyp++,1,myGen);
|
|
||||||
//static_cast<NETGENPlugin_SimpleHypothesis_3D*>(tet.get())->LengthFromFaces();
|
|
||||||
//static_cast<NETGENPlugin_SimpleHypothesis_3D*>(tet.get())->SetMaxElementVolume(0.1);
|
|
||||||
//myNetGenMesher.SetParameters( tet);
|
|
||||||
|
|
||||||
NETGENPlugin_Hypothesis* tet= new NETGENPlugin_Hypothesis(hyp++,1,myGen);
|
|
||||||
tet->SetMaxSize(MaxSize.getValue());
|
tet->SetMaxSize(MaxSize.getValue());
|
||||||
tet->SetSecondOrder(SecondOrder.getValue());
|
tet->SetSecondOrder(SecondOrder.getValue());
|
||||||
tet->SetOptimize(Optimize.getValue());
|
tet->SetOptimize(Optimize.getValue());
|
||||||
|
@ -113,9 +119,11 @@ App::DocumentObjectExecReturn *FemMeshShapeNetgenObject::execute(void)
|
||||||
tet->SetNbSegPerRadius(NbSegsPerRadius.getValue());
|
tet->SetNbSegPerRadius(NbSegsPerRadius.getValue());
|
||||||
}
|
}
|
||||||
myNetGenMesher.SetParameters( tet);
|
myNetGenMesher.SetParameters( tet);
|
||||||
|
newMesh.myMesh->ShapeToMesh(shape);
|
||||||
|
|
||||||
myNetGenMesher.Compute();
|
myNetGenMesher.Compute();
|
||||||
|
|
||||||
|
// throw Base::Exception("Compute Done\n");
|
||||||
|
|
||||||
SMESHDS_Mesh* data = const_cast<SMESH_Mesh*>(newMesh.getSMesh())->GetMeshDS();
|
SMESHDS_Mesh* data = const_cast<SMESH_Mesh*>(newMesh.getSMesh())->GetMeshDS();
|
||||||
const SMDS_MeshInfo& info = data->GetMeshInfo();
|
const SMDS_MeshInfo& info = data->GetMeshInfo();
|
||||||
|
@ -135,7 +143,6 @@ App::DocumentObjectExecReturn *FemMeshShapeNetgenObject::execute(void)
|
||||||
|
|
||||||
// set the value to the object
|
// set the value to the object
|
||||||
FemMesh.setValue(newMesh);
|
FemMesh.setValue(newMesh);
|
||||||
|
|
||||||
return App::DocumentObject::StdReturn;
|
return App::DocumentObject::StdReturn;
|
||||||
#else
|
#else
|
||||||
return new App::DocumentObjectExecReturn("The FEM module is built without NETGEN support. Meshing will not work!!!", this);
|
return new App::DocumentObjectExecReturn("The FEM module is built without NETGEN support. Meshing will not work!!!", this);
|
||||||
|
|
|
@ -7,6 +7,8 @@ endif(MSVC)
|
||||||
if(BUILD_FEM_NETGEN)
|
if(BUILD_FEM_NETGEN)
|
||||||
add_definitions(-DFCWithNetgen)
|
add_definitions(-DFCWithNetgen)
|
||||||
endif(BUILD_FEM_NETGEN)
|
endif(BUILD_FEM_NETGEN)
|
||||||
|
find_package(VTK REQUIRED)
|
||||||
|
include(${VTK_USE_FILE})
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
${CMAKE_BINARY_DIR}
|
${CMAKE_BINARY_DIR}
|
||||||
|
@ -20,6 +22,7 @@ include_directories(
|
||||||
${PYTHON_INCLUDE_DIRS}
|
${PYTHON_INCLUDE_DIRS}
|
||||||
${XercesC_INCLUDE_DIRS}
|
${XercesC_INCLUDE_DIRS}
|
||||||
${SMESH_INCLUDE_DIR}
|
${SMESH_INCLUDE_DIR}
|
||||||
|
${VTK_INCLUDE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
link_directories(${OCC_LIBRARY_DIR})
|
link_directories(${OCC_LIBRARY_DIR})
|
||||||
|
|
|
@ -91,6 +91,7 @@ class FemTest(unittest.TestCase):
|
||||||
self.mesh.addVolume([int(v[2]), int(v[1]), int(v[3]), int(v[4]), int(v[5]),
|
self.mesh.addVolume([int(v[2]), int(v[1]), int(v[3]), int(v[4]), int(v[5]),
|
||||||
int(v[7]), int(v[6]), int(v[9]), int(v[8]), int(v[10])],
|
int(v[7]), int(v[6]), int(v[9]), int(v[8]), int(v[10])],
|
||||||
int(v[0]))
|
int(v[0]))
|
||||||
|
|
||||||
self.mesh_object.FemMesh = self.mesh
|
self.mesh_object.FemMesh = self.mesh
|
||||||
self.active_doc.recompute()
|
self.active_doc.recompute()
|
||||||
|
|
||||||
|
|
|
@ -362,8 +362,6 @@ Mesh::MeshObject* Mesher::createMesh() const
|
||||||
}
|
}
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
delete meshgen;
|
|
||||||
|
|
||||||
TopoDS_Shape aNull;
|
TopoDS_Shape aNull;
|
||||||
mesh->ShapeToMesh(aNull);
|
mesh->ShapeToMesh(aNull);
|
||||||
mesh->Clear();
|
mesh->Clear();
|
||||||
|
@ -371,6 +369,8 @@ Mesh::MeshObject* Mesher::createMesh() const
|
||||||
for (std::list<SMESH_Hypothesis*>::iterator it = hypoth.begin(); it != hypoth.end(); ++it)
|
for (std::list<SMESH_Hypothesis*>::iterator it = hypoth.begin(); it != hypoth.end(); ++it)
|
||||||
delete *it;
|
delete *it;
|
||||||
|
|
||||||
|
delete meshgen;
|
||||||
|
|
||||||
MeshCore::MeshKernel kernel;
|
MeshCore::MeshKernel kernel;
|
||||||
kernel.Adopt(verts, faces, true);
|
kernel.Adopt(verts, faces, true);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user