[FEM] shorten too long lines
- reformatting was done by the MSVC formatter according to our current clang file
This commit is contained in:
@@ -143,7 +143,8 @@ void FemMesh::copyMeshData(const FemMesh& mesh)
|
||||
{
|
||||
_Mtrx = mesh._Mtrx;
|
||||
|
||||
// See file SMESH_I/SMESH_Gen_i.cxx in the git repo of smesh at https://git.salome-platform.org
|
||||
// See file SMESH_I/SMESH_Gen_i.cxx in the git repo of smesh at
|
||||
// https://git.salome-platform.org
|
||||
#if 1
|
||||
// 1. Get source mesh
|
||||
SMESHDS_Mesh* srcMeshDS = mesh.myMesh->GetMeshDS();
|
||||
@@ -180,15 +181,11 @@ void FemMesh::copyMeshData(const FemMesh& mesh)
|
||||
switch (elem->GetEntityType()) {
|
||||
case SMDSEntity_Polyhedra:
|
||||
#if SMESH_VERSION_MAJOR >= 9
|
||||
editor.GetMeshDS()->
|
||||
AddPolyhedralVolumeWithID(nodes,
|
||||
static_cast<const SMDS_MeshVolume*>(elem)->GetQuantities(),
|
||||
ID);
|
||||
editor.GetMeshDS()->AddPolyhedralVolumeWithID(
|
||||
nodes, static_cast<const SMDS_MeshVolume*>(elem)->GetQuantities(), ID);
|
||||
#else
|
||||
editor.GetMeshDS()->
|
||||
AddPolyhedralVolumeWithID(nodes,
|
||||
static_cast<const SMDS_VtkVolume*>(elem)->GetQuantities(),
|
||||
ID);
|
||||
editor.GetMeshDS()->AddPolyhedralVolumeWithID(
|
||||
nodes, static_cast<const SMDS_VtkVolume*>(elem)->GetQuantities(), ID);
|
||||
#endif
|
||||
break;
|
||||
case SMDSEntity_Ball:
|
||||
@@ -265,7 +262,8 @@ void FemMesh::copyMeshData(const FemMesh& mesh)
|
||||
#else
|
||||
SMESHDS_Mesh* meshds = this->myMesh->GetMeshDS();
|
||||
|
||||
// Some further information is still not copied: http://forum.freecadweb.org/viewtopic.php?f=18&t=18982#p148114
|
||||
// Some further information is still not copied:
|
||||
// http://forum.freecadweb.org/viewtopic.php?f=18&t=18982#p148114
|
||||
SMDS_NodeIteratorPtr aNodeIter = mesh.myMesh->GetMeshDS()->nodesIterator();
|
||||
for (;aNodeIter->more();) {
|
||||
const SMDS_MeshNode* aNode = aNodeIter->next();
|
||||
@@ -316,14 +314,12 @@ void FemMesh::copyMeshData(const FemMesh& mesh)
|
||||
aFace->GetNode(7),
|
||||
aFace->GetID());
|
||||
break;
|
||||
default:
|
||||
{
|
||||
std::vector<const SMDS_MeshNode*> aNodes;
|
||||
for (int i=0; aFace->NbNodes(); i++)
|
||||
aNodes.push_back(aFace->GetNode(0));
|
||||
meshds->AddPolygonalFaceWithID(aNodes, aFace->GetID());
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
std::vector<const SMDS_MeshNode*> aNodes;
|
||||
for (int i = 0; aFace->NbNodes(); i++)
|
||||
aNodes.push_back(aFace->GetNode(0));
|
||||
meshds->AddPolygonalFaceWithID(aNodes, aFace->GetID());
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -436,19 +432,19 @@ void FemMesh::copyMeshData(const FemMesh& mesh)
|
||||
aVol->GetNode(19),
|
||||
aVol->GetID());
|
||||
break;
|
||||
default:
|
||||
{
|
||||
if (aVol->IsPoly()) {
|
||||
const SMDS_PolyhedralVolumeOfNodes* aPolyVol = dynamic_cast<const SMDS_PolyhedralVolumeOfNodes*>(aVol);
|
||||
if (!aPolyVol) break;
|
||||
default: {
|
||||
if (aVol->IsPoly()) {
|
||||
const SMDS_PolyhedralVolumeOfNodes* aPolyVol =
|
||||
dynamic_cast<const SMDS_PolyhedralVolumeOfNodes*>(aVol);
|
||||
if (!aPolyVol)
|
||||
break;
|
||||
std::vector<const SMDS_MeshNode*> aNodes;
|
||||
for (int i=0; i<aPolyVol->NbNodes(); i++)
|
||||
for (int i = 0; i < aPolyVol->NbNodes(); i++)
|
||||
aNodes.push_back(aPolyVol->GetNode(i));
|
||||
meshds->AddPolyhedralVolumeWithID(aNodes,
|
||||
aPolyVol->GetQuanities(), aPolyVol->GetID());
|
||||
}
|
||||
meshds->AddPolyhedralVolumeWithID(
|
||||
aNodes, aPolyVol->GetQuanities(), aPolyVol->GetID());
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -461,24 +457,28 @@ void FemMesh::copyMeshData(const FemMesh& mesh)
|
||||
|
||||
int aId;
|
||||
if (sourceGroupDS->GetType() == SMDSAbs_Node) {
|
||||
SMESH_Group* targetGroup = this->myMesh->AddGroup(SMDSAbs_Node, sourceGroupDS->GetStoreName(), aId);
|
||||
if (targetGroup) {
|
||||
SMESHDS_Group* targetGroupDS = dynamic_cast<SMESHDS_Group*>(targetGroup->GetGroupDS());
|
||||
if (targetGroupDS) {
|
||||
SMDS_ElemIteratorPtr aIter = sourceGroupDS->GetElements();
|
||||
while (aIter->more()) {
|
||||
const SMDS_MeshElement* aElem = aIter->next();
|
||||
const SMDS_MeshNode* aNode = meshds->FindNode(aElem->GetID());
|
||||
if (aNode)
|
||||
targetGroupDS->SMDSGroup().Add(aNode);
|
||||
SMESH_Group* targetGroup =
|
||||
this->myMesh->AddGroup(SMDSAbs_Node, sourceGroupDS->GetStoreName(), aId);
|
||||
if (targetGroup) {
|
||||
SMESHDS_Group* targetGroupDS =
|
||||
dynamic_cast<SMESHDS_Group*>(targetGroup->GetGroupDS());
|
||||
if (targetGroupDS) {
|
||||
SMDS_ElemIteratorPtr aIter = sourceGroupDS->GetElements();
|
||||
while (aIter->more()) {
|
||||
const SMDS_MeshElement* aElem = aIter->next();
|
||||
const SMDS_MeshNode* aNode = meshds->FindNode(aElem->GetID());
|
||||
if (aNode)
|
||||
targetGroupDS->SMDSGroup().Add(aNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
SMESH_Group* targetGroup = this->myMesh->AddGroup(sourceGroupDS->GetType(), sourceGroupDS->GetStoreName(), aId);
|
||||
SMESH_Group* targetGroup = this->myMesh->AddGroup(
|
||||
sourceGroupDS->GetType(), sourceGroupDS->GetStoreName(), aId);
|
||||
if (targetGroup) {
|
||||
SMESHDS_Group* targetGroupDS = dynamic_cast<SMESHDS_Group*>(targetGroup->GetGroupDS());
|
||||
SMESHDS_Group* targetGroupDS =
|
||||
dynamic_cast<SMESHDS_Group*>(targetGroup->GetGroupDS());
|
||||
if (targetGroupDS) {
|
||||
SMDS_ElemIteratorPtr aIter = sourceGroupDS->GetElements();
|
||||
while (aIter->more()) {
|
||||
@@ -593,7 +593,7 @@ void FemMesh::setStandardHypotheses()
|
||||
#endif
|
||||
|
||||
// Apply hypothesis
|
||||
for (int i=0; i<hyp;i++)
|
||||
for (int i = 0; i < hyp; i++)
|
||||
myMesh->AddHypothesis(myMesh->GetShapeToMesh(), i);
|
||||
}
|
||||
|
||||
@@ -622,7 +622,8 @@ std::list<std::pair<int, int> > FemMesh::getVolumesByFace(const TopoDS_Face &fac
|
||||
std::set<int> nodes_on_face = getNodesByFace(face);
|
||||
|
||||
#if SMESH_VERSION_MAJOR >= 7
|
||||
// SMDS_MeshVolume::facesIterator() is broken with SMESH7 as it is impossible to iterate volume faces
|
||||
// SMDS_MeshVolume::facesIterator() is broken with SMESH7 as it is impossible
|
||||
// to iterate volume faces
|
||||
// In SMESH9 this function has been removed
|
||||
//
|
||||
std::map< int, std::set<int> > face_nodes;
|
||||
@@ -641,8 +642,11 @@ std::list<std::pair<int, int> > FemMesh::getVolumesByFace(const TopoDS_Face &fac
|
||||
}
|
||||
|
||||
std::vector<int> element_face_nodes;
|
||||
std::set_intersection(nodes_on_face.begin(), nodes_on_face.end(), node_ids.begin(), node_ids.end(),
|
||||
std::back_insert_iterator<std::vector<int> >(element_face_nodes));
|
||||
std::set_intersection(nodes_on_face.begin(),
|
||||
nodes_on_face.end(),
|
||||
node_ids.begin(),
|
||||
node_ids.end(),
|
||||
std::back_insert_iterator<std::vector<int>>(element_face_nodes));
|
||||
|
||||
if (element_face_nodes.size() == node_ids.size()) {
|
||||
face_nodes[face->GetID()] = node_ids;
|
||||
@@ -662,8 +666,11 @@ std::list<std::pair<int, int> > FemMesh::getVolumesByFace(const TopoDS_Face &fac
|
||||
|
||||
for (const auto& it : face_nodes) {
|
||||
std::vector<int> element_face_nodes;
|
||||
std::set_intersection(node_ids.begin(), node_ids.end(), it.second.begin(), it.second.end(),
|
||||
std::back_insert_iterator<std::vector<int> >(element_face_nodes));
|
||||
std::set_intersection(node_ids.begin(),
|
||||
node_ids.end(),
|
||||
it.second.begin(),
|
||||
it.second.end(),
|
||||
std::back_insert_iterator<std::vector<int>>(element_face_nodes));
|
||||
|
||||
// For curved faces it is possible that a volume contributes more than one face
|
||||
if (element_face_nodes.size() == it.second.size()) {
|
||||
@@ -682,13 +689,16 @@ std::list<std::pair<int, int> > FemMesh::getVolumesByFace(const TopoDS_Face &fac
|
||||
int numNodes = face->NbNodes();
|
||||
|
||||
std::set<int> face_nodes;
|
||||
for (int i=0; i<numNodes; i++) {
|
||||
for (int i = 0; i < numNodes; i++) {
|
||||
face_nodes.insert(face->GetNode(i)->GetID());
|
||||
}
|
||||
|
||||
std::vector<int> element_face_nodes;
|
||||
std::set_intersection(nodes_on_face.begin(), nodes_on_face.end(), face_nodes.begin(), face_nodes.end(),
|
||||
std::back_insert_iterator<std::vector<int> >(element_face_nodes));
|
||||
std::set_intersection(nodes_on_face.begin(),
|
||||
nodes_on_face.end(),
|
||||
face_nodes.begin(),
|
||||
face_nodes.end(),
|
||||
std::back_insert_iterator<std::vector<int>>(element_face_nodes));
|
||||
|
||||
// For curved faces it is possible that a volume contributes more than one face
|
||||
if (element_face_nodes.size() == static_cast<std::size_t>(numNodes)) {
|
||||
@@ -716,13 +726,16 @@ std::list<int> FemMesh::getFacesByFace(const TopoDS_Face &face) const
|
||||
int numNodes = face->NbNodes();
|
||||
|
||||
std::set<int> face_nodes;
|
||||
for (int i=0; i<numNodes; i++) {
|
||||
for (int i = 0; i < numNodes; i++) {
|
||||
face_nodes.insert(face->GetNode(i)->GetID());
|
||||
}
|
||||
|
||||
std::vector<int> element_face_nodes;
|
||||
std::set_intersection(nodes_on_face.begin(), nodes_on_face.end(), face_nodes.begin(), face_nodes.end(),
|
||||
std::back_insert_iterator<std::vector<int> >(element_face_nodes));
|
||||
std::set_intersection(nodes_on_face.begin(),
|
||||
nodes_on_face.end(),
|
||||
face_nodes.begin(),
|
||||
face_nodes.end(),
|
||||
std::back_insert_iterator<std::vector<int>>(element_face_nodes));
|
||||
|
||||
// For curved faces it is possible that a volume contributes more than one face
|
||||
if (element_face_nodes.size() == static_cast<std::size_t>(numNodes)) {
|
||||
@@ -745,13 +758,16 @@ std::list<int> FemMesh::getEdgesByEdge(const TopoDS_Edge &edge) const
|
||||
int numNodes = edge->NbNodes();
|
||||
|
||||
std::set<int> edge_nodes;
|
||||
for (int i=0; i<numNodes; i++) {
|
||||
for (int i = 0; i < numNodes; i++) {
|
||||
edge_nodes.insert(edge->GetNode(i)->GetID());
|
||||
}
|
||||
|
||||
std::vector<int> element_edge_nodes;
|
||||
std::set_intersection(nodes_on_edge.begin(), nodes_on_edge.end(), edge_nodes.begin(), edge_nodes.end(),
|
||||
std::back_insert_iterator<std::vector<int> >(element_edge_nodes));
|
||||
std::set_intersection(nodes_on_edge.begin(),
|
||||
nodes_on_edge.end(),
|
||||
edge_nodes.begin(),
|
||||
edge_nodes.end(),
|
||||
std::back_insert_iterator<std::vector<int>>(element_edge_nodes));
|
||||
|
||||
if (element_edge_nodes.size() == static_cast<std::size_t>(numNodes)) {
|
||||
result.push_back(edge->GetID());
|
||||
@@ -802,15 +818,19 @@ std::map<int, int> FemMesh::getccxVolumesByFace(const TopoDS_Face &face) const
|
||||
std::vector<int> element_face_nodes;
|
||||
std::set<int> element_nodes;
|
||||
element_nodes.insert(apair.second.begin(), apair.second.end());
|
||||
std::set_intersection(nodes_on_face.begin(), nodes_on_face.end(), element_nodes.begin(), element_nodes.end(),
|
||||
std::back_insert_iterator<std::vector<int> >(element_face_nodes));
|
||||
std::set_intersection(nodes_on_face.begin(),
|
||||
nodes_on_face.end(),
|
||||
element_nodes.begin(),
|
||||
element_nodes.end(),
|
||||
std::back_insert_iterator<std::vector<int>>(element_face_nodes));
|
||||
|
||||
if ((element_face_nodes.size() == 3 && num_of_nodes == 4) ||
|
||||
(element_face_nodes.size() == 6 && num_of_nodes == 10)) {
|
||||
if ((element_face_nodes.size() == 3 && num_of_nodes == 4)
|
||||
|| (element_face_nodes.size() == 6 && num_of_nodes == 10)) {
|
||||
int missing_node = 0;
|
||||
for (int i=0; i<4; i++) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
// search for the ID of the volume which is not part of 'element_face_nodes'
|
||||
if (std::find(element_face_nodes.begin(), element_face_nodes.end(), apair.second[i]) == element_face_nodes.end()) {
|
||||
if (std::find(element_face_nodes.begin(), element_face_nodes.end(), apair.second[i])
|
||||
== element_face_nodes.end()) {
|
||||
missing_node = i + 1;
|
||||
break;
|
||||
}
|
||||
@@ -856,7 +876,8 @@ std::set<int> FemMesh::getNodesBySolid(const TopoDS_Solid &solid) const
|
||||
TopAbs_ShapeEnum shapetype = TopAbs_SHAPE;
|
||||
ShapeAnalysis_ShapeTolerance analysis;
|
||||
double limit = analysis.Tolerance(solid, 1, shapetype);
|
||||
Base::Console().Log("The limit if a node is in or out: %.12lf in scientific: %.4e \n", limit, limit);
|
||||
Base::Console().Log(
|
||||
"The limit if a node is in or out: %.12lf in scientific: %.4e \n", limit, limit);
|
||||
|
||||
// get the current transform of the FemMesh
|
||||
const Base::Matrix4D Mtrx(getTransform());
|
||||
@@ -902,7 +923,10 @@ std::set<int> FemMesh::getNodesByFace(const TopoDS_Face &face) const
|
||||
std::set<int> result;
|
||||
|
||||
Bnd_Box box;
|
||||
BRepBndLib::Add(face, box, Standard_False); // https://forum.freecadweb.org/viewtopic.php?f=18&t=21571&start=70#p221591
|
||||
BRepBndLib::Add(
|
||||
face,
|
||||
box,
|
||||
Standard_False);// https://forum.freecadweb.org/viewtopic.php?f=18&t=21571&start=70#p221591
|
||||
// limit where the mesh node belongs to the face:
|
||||
double limit = BRep_Tool::Tolerance(face);
|
||||
box.Enlarge(limit);
|
||||
@@ -1320,7 +1344,7 @@ public:
|
||||
int id = atoi(str1.substr(8,16).c_str());
|
||||
int offset = 0;
|
||||
|
||||
if(id < 1000000)
|
||||
if (id < 1000000)
|
||||
offset = 0;
|
||||
else if (id < 10000000)
|
||||
offset = 1;
|
||||
@@ -1903,7 +1927,8 @@ void FemMesh::writeABAQUS(const std::string &Filename, int elemParam, bool group
|
||||
static std::map<int, std::string> faceTypeMap;
|
||||
static std::map<int, std::string> volTypeMap;
|
||||
if (elemOrderMap.empty()) {
|
||||
// node order fits with node order in importCcxFrdResults.py module to import CalculiX result meshes
|
||||
// node order fits with node order in importCcxFrdResults.py module to import
|
||||
// CalculiX result meshes
|
||||
|
||||
// dimension 1
|
||||
//
|
||||
@@ -1957,7 +1982,8 @@ void FemMesh::writeABAQUS(const std::string &Filename, int elemParam, bool group
|
||||
//std::vector<int> c3d10 = boost::assign::list_of(0)(2)(1)(3)(6)(5)(4)(7)(9)(8);
|
||||
|
||||
// since master 0.15
|
||||
// added by werner (wmayer) March 2015, http://forum.freecadweb.org/viewtopic.php?f=18&t=10110&start=10#p81681
|
||||
// added by werner (wmayer) March 2015,
|
||||
// http://forum.freecadweb.org/viewtopic.php?f=18&t=10110&start=10#p81681
|
||||
// https://github.com/FreeCAD/FreeCAD/commit/5d159f5cf352a93b1aff4fb7b82e8b747ee4f35b
|
||||
// https://github.com/FreeCAD/FreeCAD/commit/b007bd19e4e4608caa4cdad350a9f480287fac6b
|
||||
// tetra4 FreeCAD --> C3D4 CalculiX
|
||||
@@ -1983,7 +2009,8 @@ void FemMesh::writeABAQUS(const std::string &Filename, int elemParam, bool group
|
||||
//
|
||||
// hexa20 FreeCAD --> C3D20 CalculiX
|
||||
// N6, N7, N8, N5, N2, N3, N4, N1, N14, N15, N16, N13, N10, N11, N12, N9, N18, N19, N20, N17
|
||||
std::vector<int> c3d20 = boost::assign::list_of(5)(6)(7)(4)(1)(2)(3)(0)(13)(14)(15)(12)(9)(10)(11)(8)(17)(18)(19)(16) ;
|
||||
std::vector<int> c3d20 = boost::assign::list_of(5)(6)(7)(4)(1)(2)(3)(0)(13)(14)(15)(12)(9)(
|
||||
10)(11)(8)(17)(18)(19)(16);
|
||||
//
|
||||
// penta6 FreeCAD --> C3D6 CalculiX
|
||||
// N5, N6, N4, N2, N3, N1
|
||||
@@ -1991,7 +2018,7 @@ void FemMesh::writeABAQUS(const std::string &Filename, int elemParam, bool group
|
||||
//
|
||||
// penta15 FreeCAD --> C3D15 CalculiX
|
||||
// N5, N6, N4, N2, N3, N1, N11, N12, N10, N8, N9, N7, N14, N15, N13
|
||||
std::vector<int> c3d15 = boost::assign::list_of(4)(5)(3)(1)(2)(0)(10)(11)(9)(7)(8)(6)(13)(14)(12) ;
|
||||
std::vector<int> c3d15 = boost::assign::list_of(4)(5)(3)(1)(2)(0)(10)(11)(9)(7)(8)(6)(13)(14)(12);
|
||||
|
||||
elemOrderMap.insert(std::make_pair("C3D4", c3d4));
|
||||
volTypeMap.insert(std::make_pair(elemOrderMap["C3D4"].size(), "C3D4"));
|
||||
@@ -2041,7 +2068,8 @@ void FemMesh::writeABAQUS(const std::string &Filename, int elemParam, bool group
|
||||
}
|
||||
|
||||
//get faces
|
||||
ElementsMap elementsMapFac; // empty faces map used for elemParam = 1 and elementsMapVol is not empty
|
||||
ElementsMap elementsMapFac; // empty faces map used for elemParam = 1
|
||||
// and elementsMapVol is not empty
|
||||
if ((elemParam == 0) || (elemParam == 1 && elementsMapVol.empty())) {
|
||||
// for elemParam = 1 we only fill the elementsMapFac if the elmentsMapVol is empty
|
||||
// we're going to fill the elementsMapFac with all faces
|
||||
@@ -2079,10 +2107,11 @@ void FemMesh::writeABAQUS(const std::string &Filename, int elemParam, bool group
|
||||
}
|
||||
|
||||
// get edges
|
||||
ElementsMap elementsMapEdg; // empty edges map used for elemParam == 1 and either elementMapVol or elementsMapFac are not empty
|
||||
ElementsMap elementsMapEdg; // empty edges map used for elemParam == 1
|
||||
// and either elementMapVol or elementsMapFac are not empty
|
||||
if ((elemParam == 0) || (elemParam == 1 && elementsMapVol.empty() && elementsMapFac.empty())) {
|
||||
// for elemParam = 1 we only fill the elementsMapEdg if the elmentsMapVol and elmentsMapFac are empty
|
||||
// we're going to fill the elementsMapEdg with all edges
|
||||
// for elemParam = 1 we only fill the elementsMapEdg if the elmentsMapVol
|
||||
// and elmentsMapFac are empty we're going to fill the elementsMapEdg with all edges
|
||||
SMDS_EdgeIteratorPtr aEdgeIter = myMesh->GetMeshDS()->edgesIterator();
|
||||
while (aEdgeIter->more()) {
|
||||
const SMDS_MeshEdge* aEdge = aEdgeIter->next();
|
||||
@@ -2117,21 +2146,34 @@ void FemMesh::writeABAQUS(const std::string &Filename, int elemParam, bool group
|
||||
}
|
||||
|
||||
// write all data to file
|
||||
// take also care of special characters in path https://forum.freecadweb.org/viewtopic.php?f=10&t=37436
|
||||
// take also care of special characters in path
|
||||
// https://forum.freecadweb.org/viewtopic.php?f=10&t=37436
|
||||
Base::FileInfo fi(Filename);
|
||||
Base::ofstream anABAQUS_Output(fi);
|
||||
anABAQUS_Output.precision(13); // https://forum.freecadweb.org/viewtopic.php?f=18&t=22759#p176669
|
||||
// https://forum.freecadweb.org/viewtopic.php?f=18&t=22759#p176669
|
||||
anABAQUS_Output.precision(13);
|
||||
|
||||
// add some text and make sure one of the known elemParam values is used
|
||||
anABAQUS_Output << "** written by FreeCAD inp file writer for CalculiX,Abaqus meshes" << std::endl;
|
||||
anABAQUS_Output << "** written by FreeCAD inp file writer for CalculiX,Abaqus meshes"
|
||||
<< std::endl;
|
||||
switch(elemParam){
|
||||
case 0: anABAQUS_Output << "** all mesh elements." << std::endl << std::endl; break;
|
||||
case 1: anABAQUS_Output << "** highest dimension mesh elements only." << std::endl << std::endl; break;
|
||||
case 2: anABAQUS_Output << "** FEM mesh elements only (edges if they do not belong to faces and faces if they do not belong to volumes)." << std::endl << std::endl; break;
|
||||
case 0:
|
||||
anABAQUS_Output << "** all mesh elements." << std::endl << std::endl;
|
||||
break;
|
||||
case 1:
|
||||
anABAQUS_Output << "** highest dimension mesh elements only." << std::endl << std::endl;
|
||||
break;
|
||||
case 2:
|
||||
anABAQUS_Output << "** FEM mesh elements only (edges if they do not belong to faces "
|
||||
"and faces if they do not belong to volumes)."
|
||||
<< std::endl
|
||||
<< std::endl;
|
||||
break;
|
||||
default:
|
||||
anABAQUS_Output << "** Problem on writing" << std::endl;
|
||||
anABAQUS_Output.close();
|
||||
throw std::runtime_error("Unknown ABAQUS element choice parameter, [0|1|2] are allowed.");
|
||||
throw std::runtime_error(
|
||||
"Unknown ABAQUS element choice parameter, [0|1|2] are allowed.");
|
||||
}
|
||||
|
||||
// write nodes
|
||||
@@ -2159,7 +2201,8 @@ void FemMesh::writeABAQUS(const std::string &Filename, int elemParam, bool group
|
||||
// Calculix allows max 16 entries in one line, a hexa20 has more !
|
||||
int ct = 0; // counter
|
||||
bool first_line = true;
|
||||
for (std::vector<int>::iterator kt = jt->second.begin(); kt != jt->second.end(); ++kt, ++ct) {
|
||||
for (std::vector<int>::iterator kt = jt->second.begin(); kt != jt->second.end();
|
||||
++kt, ++ct) {
|
||||
if (ct < 15) {
|
||||
anABAQUS_Output << ", " << *kt;
|
||||
}
|
||||
@@ -2185,7 +2228,8 @@ void FemMesh::writeABAQUS(const std::string &Filename, int elemParam, bool group
|
||||
anABAQUS_Output << "*Element, TYPE=" << it->first << ", ELSET=Efaces" << std::endl;
|
||||
for (NodesMap::iterator jt = it->second.begin(); jt != it->second.end(); ++jt) {
|
||||
anABAQUS_Output << jt->first;
|
||||
for (std::vector<int>::iterator kt = jt->second.begin(); kt != jt->second.end(); ++kt) {
|
||||
for (std::vector<int>::iterator kt = jt->second.begin(); kt != jt->second.end();
|
||||
++kt) {
|
||||
anABAQUS_Output << ", " << *kt;
|
||||
}
|
||||
anABAQUS_Output << std::endl;
|
||||
@@ -2205,7 +2249,8 @@ void FemMesh::writeABAQUS(const std::string &Filename, int elemParam, bool group
|
||||
anABAQUS_Output << "*Element, TYPE=" << it->first << ", ELSET=Eedges" << std::endl;
|
||||
for (NodesMap::iterator jt = it->second.begin(); jt != it->second.end(); ++jt) {
|
||||
anABAQUS_Output << jt->first;
|
||||
for (std::vector<int>::iterator kt = jt->second.begin(); kt != jt->second.end(); ++kt) {
|
||||
for (std::vector<int>::iterator kt = jt->second.begin(); kt != jt->second.end();
|
||||
++kt) {
|
||||
anABAQUS_Output << ", " << *kt;
|
||||
}
|
||||
anABAQUS_Output << std::endl;
|
||||
@@ -2235,7 +2280,8 @@ void FemMesh::writeABAQUS(const std::string &Filename, int elemParam, bool group
|
||||
for (std::list<int>::iterator it = groupIDs.begin(); it != groupIDs.end(); ++it) {
|
||||
|
||||
// get and write group info and group definition
|
||||
// TODO group element type code has duplicate code of PyObject* FemMeshPy::getGroupElementType()
|
||||
// TODO group element type code has duplicate code of
|
||||
// PyObject* FemMeshPy::getGroupElementType()
|
||||
SMDSAbs_ElementType aElementType = myMesh->GetGroup(*it)->GetGroupDS()->GetType();
|
||||
const char* groupElementType = "";
|
||||
switch(aElementType) {
|
||||
@@ -2249,7 +2295,8 @@ void FemMesh::writeABAQUS(const std::string &Filename, int elemParam, bool group
|
||||
default : groupElementType = "Unknown"; break;
|
||||
}
|
||||
const char* groupName = myMesh->GetGroup(*it)->GetName();
|
||||
anABAQUS_Output << "** GroupID: " << (*it) << " --> GroupName: " << groupName << " --> GroupElementType: " << groupElementType << std::endl;
|
||||
anABAQUS_Output << "** GroupID: " << (*it) << " --> GroupName: " << groupName
|
||||
<< " --> GroupElementType: " << groupElementType << std::endl;
|
||||
|
||||
if (aElementType == SMDSAbs_Node) {
|
||||
anABAQUS_Output << "*NSET, NSET=" << groupName << std::endl;
|
||||
@@ -2315,9 +2362,12 @@ void FemMesh::write(const char *FileName) const
|
||||
// write UNV file
|
||||
myMesh->ExportUNV(File.filePath().c_str());
|
||||
}
|
||||
else if (File.hasExtension("med") ) {
|
||||
else if (File.hasExtension("med")) {
|
||||
Base::Console().Log("FEM mesh object will be exported to med format.\n");
|
||||
myMesh->ExportMED(File.filePath().c_str(),File.fileNamePure().c_str(),false,2); // 2 means MED_V2_2 version !
|
||||
myMesh->ExportMED(File.filePath().c_str(),
|
||||
File.fileNamePure().c_str(),
|
||||
false,
|
||||
2); // 2 means MED_V2_2 version!
|
||||
}
|
||||
else if (File.hasExtension("stl") ) {
|
||||
Base::Console().Log("FEM mesh object will be exported to stl format.\n");
|
||||
@@ -2332,7 +2382,8 @@ void FemMesh::write(const char *FileName) const
|
||||
else if (File.hasExtension("inp") ) {
|
||||
Base::Console().Log("FEM mesh object will be exported to inp format.\n");
|
||||
// get Abaqus inp prefs
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Fem/Abaqus");
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Mod/Fem/Abaqus");
|
||||
int elemParam = hGrp->GetInt("AbaqusElementChoice", 1);
|
||||
bool groupParam = hGrp->GetBool("AbaqusWriteGroups", false);
|
||||
// write ABAQUS Output
|
||||
@@ -2366,20 +2417,28 @@ void FemMesh::Save (Base::Writer &writer) const
|
||||
{
|
||||
if (!writer.isForceXML()) {
|
||||
//See SaveDocFile(), RestoreDocFile()
|
||||
writer.Stream() << writer.ind() << "<FemMesh file=\"" ;
|
||||
writer.Stream() << writer.ind() << "<FemMesh file=\"";
|
||||
writer.Stream() << writer.addFile("FemMesh.unv", this) << "\"";
|
||||
writer.Stream() << " a11=\"" << _Mtrx[0][0] << "\" a12=\"" << _Mtrx[0][1] << "\" a13=\"" << _Mtrx[0][2] << "\" a14=\"" << _Mtrx[0][3] << "\"";
|
||||
writer.Stream() << " a21=\"" << _Mtrx[1][0] << "\" a22=\"" << _Mtrx[1][1] << "\" a23=\"" << _Mtrx[1][2] << "\" a24=\"" << _Mtrx[1][3] << "\"";
|
||||
writer.Stream() << " a31=\"" << _Mtrx[2][0] << "\" a32=\"" << _Mtrx[2][1] << "\" a33=\"" << _Mtrx[2][2] << "\" a34=\"" << _Mtrx[2][3] << "\"";
|
||||
writer.Stream() << " a41=\"" << _Mtrx[3][0] << "\" a42=\"" << _Mtrx[3][1] << "\" a43=\"" << _Mtrx[3][2] << "\" a44=\"" << _Mtrx[3][3] << "\"";
|
||||
writer.Stream() << " a11=\"" << _Mtrx[0][0] << "\" a12=\"" << _Mtrx[0][1] << "\" a13=\""
|
||||
<< _Mtrx[0][2] << "\" a14=\"" << _Mtrx[0][3] << "\"";
|
||||
writer.Stream() << " a21=\"" << _Mtrx[1][0] << "\" a22=\"" << _Mtrx[1][1] << "\" a23=\""
|
||||
<< _Mtrx[1][2] << "\" a24=\"" << _Mtrx[1][3] << "\"";
|
||||
writer.Stream() << " a31=\"" << _Mtrx[2][0] << "\" a32=\"" << _Mtrx[2][1] << "\" a33=\""
|
||||
<< _Mtrx[2][2] << "\" a34=\"" << _Mtrx[2][3] << "\"";
|
||||
writer.Stream() << " a41=\"" << _Mtrx[3][0] << "\" a42=\"" << _Mtrx[3][1] << "\" a43=\""
|
||||
<< _Mtrx[3][2] << "\" a44=\"" << _Mtrx[3][3] << "\"";
|
||||
writer.Stream() << "/>" << std::endl;
|
||||
}
|
||||
else {
|
||||
writer.Stream() << writer.ind() << "<FemMesh file=\"\"" ;
|
||||
writer.Stream() << " a11=\"" << _Mtrx[0][0] << "\" a12=\"" << _Mtrx[0][1] << "\" a13=\"" << _Mtrx[0][2] << "\" a14=\"" << _Mtrx[0][3] << "\"";
|
||||
writer.Stream() << " a21=\"" << _Mtrx[1][0] << "\" a22=\"" << _Mtrx[1][1] << "\" a23=\"" << _Mtrx[1][2] << "\" a24=\"" << _Mtrx[1][3] << "\"";
|
||||
writer.Stream() << " a31=\"" << _Mtrx[2][0] << "\" a32=\"" << _Mtrx[2][1] << "\" a33=\"" << _Mtrx[2][2] << "\" a34=\"" << _Mtrx[2][3] << "\"";
|
||||
writer.Stream() << " a41=\"" << _Mtrx[3][0] << "\" a42=\"" << _Mtrx[3][1] << "\" a43=\"" << _Mtrx[3][2] << "\" a44=\"" << _Mtrx[3][3] << "\"";
|
||||
writer.Stream() << writer.ind() << "<FemMesh file=\"\"";
|
||||
writer.Stream() << " a11=\"" << _Mtrx[0][0] << "\" a12=\"" << _Mtrx[0][1] << "\" a13=\""
|
||||
<< _Mtrx[0][2] << "\" a14=\"" << _Mtrx[0][3] << "\"";
|
||||
writer.Stream() << " a21=\"" << _Mtrx[1][0] << "\" a22=\"" << _Mtrx[1][1] << "\" a23=\""
|
||||
<< _Mtrx[1][2] << "\" a24=\"" << _Mtrx[1][3] << "\"";
|
||||
writer.Stream() << " a31=\"" << _Mtrx[2][0] << "\" a32=\"" << _Mtrx[2][1] << "\" a33=\""
|
||||
<< _Mtrx[2][2] << "\" a34=\"" << _Mtrx[2][3] << "\"";
|
||||
writer.Stream() << " a41=\"" << _Mtrx[3][0] << "\" a42=\"" << _Mtrx[3][1] << "\" a43=\""
|
||||
<< _Mtrx[3][2] << "\" a44=\"" << _Mtrx[3][3] << "\"";
|
||||
writer.Stream() << "/>" << std::endl;
|
||||
}
|
||||
}
|
||||
@@ -2393,7 +2452,7 @@ void FemMesh::Restore(Base::XMLReader &reader)
|
||||
// initiate a file read
|
||||
reader.addFile(file.c_str(),this);
|
||||
}
|
||||
if( reader.hasAttribute("a11")){
|
||||
if (reader.hasAttribute("a11")) {
|
||||
_Mtrx[0][0] = (float)reader.getAttributeAsFloat("a11");
|
||||
_Mtrx[0][1] = (float)reader.getAttributeAsFloat("a12");
|
||||
_Mtrx[0][2] = (float)reader.getAttributeAsFloat("a13");
|
||||
@@ -2542,7 +2601,7 @@ struct Fem::FemMesh::FemMeshInfo FemMesh::getInfo() const{
|
||||
return rtrn;
|
||||
|
||||
}
|
||||
// for(unsigned int i=0;i<all_elements.size();i++)
|
||||
// for (unsigned int i = 0; i < all_elements.size(); i++)
|
||||
// {
|
||||
// // an consistent data structure is only possible
|
||||
// // if the elements are added in the right order
|
||||
@@ -2591,53 +2650,77 @@ Base::Quantity FemMesh::getVolume()const
|
||||
|
||||
|
||||
//1,5,8,7
|
||||
a = v4 -v0 ;
|
||||
b = v7 -v0 ;
|
||||
c = v6 -v0 ;
|
||||
a_b_product.x = a.y*b.z-b.y*a.z;a_b_product.y = a.z*b.x-b.z*a.x;a_b_product.z = a.x*b.y-b.x*a.y;
|
||||
volume += 1.0/6.0 * fabs((a_b_product.x * c.x)+ (a_b_product.y * c.y)+(a_b_product.z * c.z));
|
||||
a = v4 - v0;
|
||||
b = v7 - v0;
|
||||
c = v6 - v0;
|
||||
a_b_product.x = a.y * b.z - b.y * a.z;
|
||||
a_b_product.y = a.z * b.x - b.z * a.x;
|
||||
a_b_product.z = a.x * b.y - b.x * a.y;
|
||||
volume +=
|
||||
1.0 / 6.0 * fabs((a_b_product.x * c.x) + (a_b_product.y * c.y) + (a_b_product.z * c.z));
|
||||
//5,9,8,7
|
||||
a = v8 -v4 ;
|
||||
b = v7 -v4 ;
|
||||
c = v6 -v4 ;
|
||||
a_b_product.x = a.y*b.z-b.y*a.z;a_b_product.y = a.z*b.x-b.z*a.x;a_b_product.z = a.x*b.y-b.x*a.y;
|
||||
volume += 1.0/6.0 * fabs((a_b_product.x * c.x)+ (a_b_product.y * c.y)+(a_b_product.z * c.z));
|
||||
a = v8 - v4;
|
||||
b = v7 - v4;
|
||||
c = v6 - v4;
|
||||
a_b_product.x = a.y * b.z - b.y * a.z;
|
||||
a_b_product.y = a.z * b.x - b.z * a.x;
|
||||
a_b_product.z = a.x * b.y - b.x * a.y;
|
||||
volume +=
|
||||
1.0 / 6.0 * fabs((a_b_product.x * c.x) + (a_b_product.y * c.y) + (a_b_product.z * c.z));
|
||||
//5,2,9,7
|
||||
a = v1 -v4 ;
|
||||
b = v8 -v4 ;
|
||||
c = v6 -v4 ;
|
||||
a_b_product.x = a.y*b.z-b.y*a.z;a_b_product.y = a.z*b.x-b.z*a.x;a_b_product.z = a.x*b.y-b.x*a.y;
|
||||
volume += 1.0/6.0 * fabs((a_b_product.x * c.x)+ (a_b_product.y * c.y)+(a_b_product.z * c.z));
|
||||
a = v1 - v4;
|
||||
b = v8 - v4;
|
||||
c = v6 - v4;
|
||||
a_b_product.x = a.y * b.z - b.y * a.z;
|
||||
a_b_product.y = a.z * b.x - b.z * a.x;
|
||||
a_b_product.z = a.x * b.y - b.x * a.y;
|
||||
volume +=
|
||||
1.0 / 6.0 * fabs((a_b_product.x * c.x) + (a_b_product.y * c.y) + (a_b_product.z * c.z));
|
||||
//2,6,9,7
|
||||
a = v5 -v1 ;
|
||||
b = v8 -v1 ;
|
||||
c = v6 -v1 ;
|
||||
a_b_product.x = a.y*b.z-b.y*a.z;a_b_product.y = a.z*b.x-b.z*a.x;a_b_product.z = a.x*b.y-b.x*a.y;
|
||||
volume += 1.0/6.0 * fabs((a_b_product.x * c.x)+ (a_b_product.y * c.y)+(a_b_product.z * c.z));
|
||||
a = v5 - v1;
|
||||
b = v8 - v1;
|
||||
c = v6 - v1;
|
||||
a_b_product.x = a.y * b.z - b.y * a.z;
|
||||
a_b_product.y = a.z * b.x - b.z * a.x;
|
||||
a_b_product.z = a.x * b.y - b.x * a.y;
|
||||
volume +=
|
||||
1.0 / 6.0 * fabs((a_b_product.x * c.x) + (a_b_product.y * c.y) + (a_b_product.z * c.z));
|
||||
//9,6,10,7
|
||||
a = v5 -v8 ;
|
||||
b = v9 -v8 ;
|
||||
c = v6 -v8 ;
|
||||
a_b_product.x = a.y*b.z-b.y*a.z;a_b_product.y = a.z*b.x-b.z*a.x;a_b_product.z = a.x*b.y-b.x*a.y;
|
||||
volume += 1.0/6.0 * fabs((a_b_product.x * c.x)+ (a_b_product.y * c.y)+(a_b_product.z * c.z));
|
||||
a = v5 - v8;
|
||||
b = v9 - v8;
|
||||
c = v6 - v8;
|
||||
a_b_product.x = a.y * b.z - b.y * a.z;
|
||||
a_b_product.y = a.z * b.x - b.z * a.x;
|
||||
a_b_product.z = a.x * b.y - b.x * a.y;
|
||||
volume +=
|
||||
1.0 / 6.0 * fabs((a_b_product.x * c.x) + (a_b_product.y * c.y) + (a_b_product.z * c.z));
|
||||
//6,3,10,7
|
||||
a = v2 -v5 ;
|
||||
b = v9 -v5 ;
|
||||
c = v6 -v5 ;
|
||||
a_b_product.x = a.y*b.z-b.y*a.z;a_b_product.y = a.z*b.x-b.z*a.x;a_b_product.z = a.x*b.y-b.x*a.y;
|
||||
volume += 1.0/6.0 * fabs((a_b_product.x * c.x)+ (a_b_product.y * c.y)+(a_b_product.z * c.z));
|
||||
a = v2 - v5;
|
||||
b = v9 - v5;
|
||||
c = v6 - v5;
|
||||
a_b_product.x = a.y * b.z - b.y * a.z;
|
||||
a_b_product.y = a.z * b.x - b.z * a.x;
|
||||
a_b_product.z = a.x * b.y - b.x * a.y;
|
||||
volume +=
|
||||
1.0 / 6.0 * fabs((a_b_product.x * c.x) + (a_b_product.y * c.y) + (a_b_product.z * c.z));
|
||||
//8,9,10,7
|
||||
a = v8 -v7 ;
|
||||
b = v9 -v7 ;
|
||||
c = v6 -v7 ;
|
||||
a_b_product.x = a.y*b.z-b.y*a.z;a_b_product.y = a.z*b.x-b.z*a.x;a_b_product.z = a.x*b.y-b.x*a.y;
|
||||
volume += 1.0/6.0 * fabs((a_b_product.x * c.x)+ (a_b_product.y * c.y)+(a_b_product.z * c.z));
|
||||
a = v8 - v7;
|
||||
b = v9 - v7;
|
||||
c = v6 - v7;
|
||||
a_b_product.x = a.y * b.z - b.y * a.z;
|
||||
a_b_product.y = a.z * b.x - b.z * a.x;
|
||||
a_b_product.z = a.x * b.y - b.x * a.y;
|
||||
volume +=
|
||||
1.0 / 6.0 * fabs((a_b_product.x * c.x) + (a_b_product.y * c.y) + (a_b_product.z * c.z));
|
||||
//8,9,10,4
|
||||
a = v8 -v7 ;
|
||||
b = v9 -v7 ;
|
||||
c = v3 -v7 ;
|
||||
a_b_product.x = a.y*b.z-b.y*a.z;a_b_product.y = a.z*b.x-b.z*a.x;a_b_product.z = a.x*b.y-b.x*a.y;
|
||||
volume += 1.0/6.0 * fabs((a_b_product.x * c.x)+ (a_b_product.y * c.y)+(a_b_product.z * c.z));
|
||||
a = v8 - v7;
|
||||
b = v9 - v7;
|
||||
c = v3 - v7;
|
||||
a_b_product.x = a.y * b.z - b.y * a.z;
|
||||
a_b_product.y = a.z * b.x - b.z * a.x;
|
||||
a_b_product.z = a.x * b.y - b.x * a.y;
|
||||
volume +=
|
||||
1.0 / 6.0 * fabs((a_b_product.x * c.x) + (a_b_product.y * c.y) + (a_b_product.z * c.z));
|
||||
|
||||
}
|
||||
|
||||
@@ -2671,7 +2754,8 @@ int FemMesh::addGroup(const std::string TypeString, const std::string Name, cons
|
||||
typeStringValid = true;
|
||||
}
|
||||
if (!typeStringValid)
|
||||
throw std::runtime_error("AddGroup: Invalid type string! Allowed: All, Node, Edge, Face, Volume, 0DElement, Ball");
|
||||
throw std::runtime_error("AddGroup: Invalid type string! Allowed: All, Node, Edge, Face, "
|
||||
"Volume, 0DElement, Ball");
|
||||
// add group to mesh
|
||||
SMESH_Group* group = this->getSMesh()->AddGroup(mapping[TypeString], Name.c_str(), aId);
|
||||
if (!group)
|
||||
|
||||
Reference in New Issue
Block a user