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")
|
||||
|
||||
find_package(VTK REQUIRED)
|
||||
include(${VTK_USE_FILE})
|
||||
|
||||
#if(CMAKE_CFG_INTDIR STREQUAL .)
|
||||
# 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})
|
||||
endif(BUILD_FEM_NETGEN)
|
||||
|
||||
find_package(VTK REQUIRED)
|
||||
include(${VTK_USE_FILE})
|
||||
|
||||
include_directories(
|
||||
${CMAKE_BINARY_DIR}
|
||||
|
@ -22,6 +24,7 @@ include_directories(
|
|||
${ZLIB_INCLUDE_DIR}
|
||||
${XercesC_INCLUDE_DIRS}
|
||||
${SMESH_INCLUDE_DIR}
|
||||
${VTK_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
link_directories(${OCC_LIBRARY_DIR})
|
||||
|
@ -227,7 +230,7 @@ SET(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
|
||||
|
|
|
@ -68,6 +68,8 @@
|
|||
#include <StdMeshers_QuadraticMesh.hxx>
|
||||
|
||||
# include <TopoDS_Face.hxx>
|
||||
# include <TopoDS_Solid.hxx>
|
||||
# include <TopoDS_Shape.hxx>
|
||||
|
||||
//to simplify parsing input files we use the boost lib
|
||||
#include <boost/tokenizer.hpp>
|
||||
|
@ -115,6 +117,8 @@ FemMesh::~FemMesh()
|
|||
FemMesh &FemMesh::operator=(const FemMesh& mesh)
|
||||
{
|
||||
if (this != &mesh) {
|
||||
myGen = new SMESH_Gen();
|
||||
myMesh = myGen->CreateMesh(0,true);
|
||||
copyMeshData(mesh);
|
||||
}
|
||||
return *this;
|
||||
|
@ -122,26 +126,18 @@ FemMesh &FemMesh::operator=(const FemMesh& mesh)
|
|||
|
||||
void FemMesh::copyMeshData(const FemMesh& mesh)
|
||||
{
|
||||
//const SMDS_MeshInfo& info = mesh.myMesh->GetMeshDS()->GetMeshInfo();
|
||||
//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();
|
||||
|
||||
SMESH_Mesh *test;
|
||||
_Mtrx = mesh._Mtrx;
|
||||
|
||||
SMESHDS_Mesh* meshds = this->myMesh->GetMeshDS();
|
||||
meshds->ClearMesh();
|
||||
|
||||
|
||||
SMDS_NodeIteratorPtr aNodeIter = mesh.myMesh->GetMeshDS()->nodesIterator();
|
||||
for (;aNodeIter->more();) {
|
||||
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();
|
||||
for (;aEdgeIter->more();) {
|
||||
const SMDS_MeshEdge* aEdge = aEdgeIter->next();
|
||||
|
@ -559,7 +555,6 @@ std::set<int> FemMesh::getNodesBySolid(const TopoDS_Solid &solid) const
|
|||
result.insert(aNode->GetID());
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -873,6 +868,7 @@ void FemMesh::read(const char *FileName)
|
|||
}
|
||||
else if (File.hasExtension("dat") ) {
|
||||
// read brep-file
|
||||
// vejmarie disable
|
||||
myMesh->DATToMesh(File.filePath().c_str());
|
||||
}
|
||||
else if (File.hasExtension("bdf") ) {
|
||||
|
|
|
@ -143,6 +143,9 @@ public:
|
|||
void read(const char *FileName);
|
||||
void write(const char *FileName) const;
|
||||
void writeABAQUS(const std::string &Filename) const;
|
||||
Base::Matrix4D _Mtrx;
|
||||
SMESH_Gen *myGen;
|
||||
SMESH_Mesh *myMesh;
|
||||
|
||||
private:
|
||||
void copyMeshData(const FemMesh&);
|
||||
|
@ -150,9 +153,9 @@ private:
|
|||
|
||||
private:
|
||||
/// positioning matrix
|
||||
Base::Matrix4D _Mtrx;
|
||||
SMESH_Gen *myGen;
|
||||
SMESH_Mesh *myMesh;
|
||||
// Base::Matrix4D _Mtrx;
|
||||
// SMESH_Gen *myGen;
|
||||
// SMESH_Mesh *myMesh;
|
||||
|
||||
std::list<SMESH_HypothesisPtr> hypoth;
|
||||
};
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <Base/Console.h>
|
||||
|
||||
#include <SMESH_Gen.hxx>
|
||||
|
||||
#include <SMESH_Mesh.hxx>
|
||||
#include <SMDS_PolyhedralVolumeOfNodes.hxx>
|
||||
#include <SMDS_VolumeTool.hxx>
|
||||
|
@ -76,32 +77,37 @@ App::DocumentObjectExecReturn *FemMeshShapeNetgenObject::execute(void)
|
|||
#ifdef FCWithNetgen
|
||||
|
||||
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*>();
|
||||
|
||||
|
||||
TopoDS_Shape shape = feat->Shape.getValue();
|
||||
|
||||
|
||||
newMesh.getSMesh()->ShapeToMesh(shape);
|
||||
SMESH_Gen *myGen = newMesh.getGenerator();
|
||||
// newMesh.myMesh->ShapeToMesh(shape);
|
||||
// SMESH_Gen *myGen = newMesh.getGenerator();
|
||||
// meshgen->CreateMesh(0, true);
|
||||
|
||||
int hyp=0;
|
||||
|
||||
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);
|
||||
//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);
|
||||
NETGENPlugin_Hypothesis* tet= new NETGENPlugin_Hypothesis(hyp++,1,newMesh.myGen);
|
||||
tet->SetMaxSize(MaxSize.getValue());
|
||||
tet->SetSecondOrder(SecondOrder.getValue());
|
||||
tet->SetOptimize(Optimize.getValue());
|
||||
|
@ -113,9 +119,11 @@ App::DocumentObjectExecReturn *FemMeshShapeNetgenObject::execute(void)
|
|||
tet->SetNbSegPerRadius(NbSegsPerRadius.getValue());
|
||||
}
|
||||
myNetGenMesher.SetParameters( tet);
|
||||
newMesh.myMesh->ShapeToMesh(shape);
|
||||
|
||||
myNetGenMesher.Compute();
|
||||
|
||||
// throw Base::Exception("Compute Done\n");
|
||||
|
||||
SMESHDS_Mesh* data = const_cast<SMESH_Mesh*>(newMesh.getSMesh())->GetMeshDS();
|
||||
const SMDS_MeshInfo& info = data->GetMeshInfo();
|
||||
|
@ -134,8 +142,7 @@ App::DocumentObjectExecReturn *FemMeshShapeNetgenObject::execute(void)
|
|||
Base::Console().Log("NetgenMesh: %i Nodes, %i Volumes, %i Faces\n",numNode,numVolu,numFaces);
|
||||
|
||||
// set the value to the object
|
||||
FemMesh.setValue(newMesh);
|
||||
|
||||
FemMesh.setValue(newMesh);
|
||||
return App::DocumentObject::StdReturn;
|
||||
#else
|
||||
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)
|
||||
add_definitions(-DFCWithNetgen)
|
||||
endif(BUILD_FEM_NETGEN)
|
||||
find_package(VTK REQUIRED)
|
||||
include(${VTK_USE_FILE})
|
||||
|
||||
include_directories(
|
||||
${CMAKE_BINARY_DIR}
|
||||
|
@ -20,6 +22,7 @@ include_directories(
|
|||
${PYTHON_INCLUDE_DIRS}
|
||||
${XercesC_INCLUDE_DIRS}
|
||||
${SMESH_INCLUDE_DIR}
|
||||
${VTK_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
link_directories(${OCC_LIBRARY_DIR})
|
||||
|
|
|
@ -84,13 +84,14 @@ class FemTest(unittest.TestCase):
|
|||
reader = csv.reader(points_file)
|
||||
for p in reader:
|
||||
self.mesh.addNode(float(p[1]), float(p[2]), float(p[3]), int(p[0]))
|
||||
|
||||
|
||||
with open(mesh_volumes_file, 'r') as volumes_file:
|
||||
reader = csv.reader(volumes_file)
|
||||
for v in reader:
|
||||
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[0]))
|
||||
|
||||
self.mesh_object.FemMesh = self.mesh
|
||||
self.active_doc.recompute()
|
||||
|
||||
|
|
|
@ -362,8 +362,6 @@ Mesh::MeshObject* Mesher::createMesh() const
|
|||
}
|
||||
|
||||
// clean up
|
||||
delete meshgen;
|
||||
|
||||
TopoDS_Shape aNull;
|
||||
mesh->ShapeToMesh(aNull);
|
||||
mesh->Clear();
|
||||
|
@ -371,6 +369,8 @@ Mesh::MeshObject* Mesher::createMesh() const
|
|||
for (std::list<SMESH_Hypothesis*>::iterator it = hypoth.begin(); it != hypoth.end(); ++it)
|
||||
delete *it;
|
||||
|
||||
delete meshgen;
|
||||
|
||||
MeshCore::MeshKernel kernel;
|
||||
kernel.Adopt(verts, faces, true);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user