Fem: add Support for loads and supports on edges to CalculiX file

This commit is contained in:
Bernd Hahnebach 2015-03-24 19:22:05 +01:00 committed by wmayer
parent e4c2421350
commit a15ea4ca18
5 changed files with 96 additions and 19 deletions

View File

@ -443,6 +443,46 @@ std::set<long> FemMesh::getSurfaceNodes(const TopoDS_Face &face)const
return result;
}
std::set<long> FemMesh::getSurfaceNodes(const TopoDS_Edge &edge)const
{
std::set<long> result;
Bnd_Box box;
BRepBndLib::Add(edge, box);
// limit where the mesh node belongs to the edge:
double limit = box.SquareExtent()/10000.0;
box.Enlarge(limit);
// get the actuall transform of the FemMesh
const Base::Matrix4D Mtrx(getTransform());
SMDS_NodeIteratorPtr aNodeIter = myMesh->GetMeshDS()->nodesIterator();
while (aNodeIter->more()) {
const SMDS_MeshNode* aNode = aNodeIter->next();
Base::Vector3d vec(aNode->X(),aNode->Y(),aNode->Z());
// Apply the matrix to hold the BoundBox in absolute space.
vec = Mtrx * vec;
if(!box.IsOut(gp_Pnt(vec.x,vec.y,vec.z))){
// create a Vertex
BRepBuilderAPI_MakeVertex aBuilder(gp_Pnt(vec.x,vec.y,vec.z));
TopoDS_Shape s = aBuilder.Vertex();
// measure distance
BRepExtrema_DistShapeShape measure(edge,s);
measure.Perform();
if (!measure.IsDone() || measure.NbSolution() < 1)
continue;
if(measure.Value() < limit)
result.insert(aNode->GetID());
}
}
return result;
}
void FemMesh::readNastran(const std::string &Filename)
@ -1058,7 +1098,7 @@ struct Fem::FemMesh::FemMeshInfo FemMesh::getInfo(void) const{
return rtrn;
}
}
// for(unsigned int i=0;i<all_elements.size();i++)
// {
// //Die Reihenfolge wie hier die Elemente hinzugefügt werden ist sehr wichtig.
@ -1077,9 +1117,9 @@ struct Fem::FemMesh::FemMeshInfo FemMesh::getInfo(void) const{
// element_id[i]
// );
// }
Base::Quantity FemMesh::getVolume(void)const
{
Base::Quantity FemMesh::getVolume(void)const
{
SMDS_VolumeIteratorPtr aVolIter = myMesh->GetMeshDS()->volumesIterator();
//Calculate Mesh Volume
@ -1156,8 +1196,8 @@ Base::Quantity FemMesh::getVolume(void)const
volume += 1.0/6.0 * fabs((a_b_product.x * c.x)+ (a_b_product.y * c.y)+(a_b_product.z * c.z));
}
return Base::Quantity(volume,Unit::Volume);
return Base::Quantity(volume,Unit::Volume);
}

View File

@ -37,6 +37,7 @@ class SMESH_Mesh;
class SMESH_Hypothesis;
class TopoDS_Shape;
class TopoDS_Face;
class TopoDS_Edge;
namespace Fem
{
@ -87,6 +88,8 @@ public:
std::set<long> getSurfaceNodes(long ElemId,short FaceId, float Angle=360)const;
/// retrivinb by face
std::set<long> getSurfaceNodes(const TopoDS_Face &face)const;
/// retrivinb by edge
std::set<long> getSurfaceNodes(const TopoDS_Edge &edge)const;
//@}
/** @name Placement control */

View File

@ -94,6 +94,11 @@
<UserDocu>Return a list of node IDs which belong to a TopoFace</UserDocu>
</Documentation>
</Methode>
<Methode Name="getNodesByEdge" Const="true">
<Documentation>
<UserDocu>Return a list of node IDs which belong to a TopoEdge</UserDocu>
</Documentation>
</Methode>
<Attribute Name="Nodes" ReadOnly="true">
<Documentation>
<UserDocu>Dictionary of Nodes by ID (int ID:Vector())</UserDocu>

View File

@ -39,6 +39,7 @@
#include <Mod/Part/App/TopoShapePy.h>
#include <Mod/Part/App/TopoShapeFacePy.h>
#include <Mod/Part/App/TopoShapeEdgePy.h>
#include <Mod/Part/App/TopoShape.h>
#include "Mod/Fem/App/FemMesh.h"
@ -534,9 +535,9 @@ PyObject* FemMeshPy::getNodeById(PyObject *args)
PyObject* FemMeshPy::getNodesByFace(PyObject *args)
{
PyObject *pW;
if (!PyArg_ParseTuple(args, "O!", &(Part::TopoShapeFacePy::Type), &pW))
return 0;
if (!PyArg_ParseTuple(args, "O!", &(Part::TopoShapeFacePy::Type), &pW))
return 0;
try {
const TopoDS_Shape& sh = static_cast<Part::TopoShapeFacePy*>(pW)->getTopoShapePtr()->_Shape;
const TopoDS_Face& fc = TopoDS::Face(sh);
@ -548,18 +549,46 @@ PyObject* FemMeshPy::getNodesByFace(PyObject *args)
std::set<long> resultSet = getFemMeshPtr()->getSurfaceNodes(fc);
for( std::set<long>::const_iterator it = resultSet.begin();it!=resultSet.end();++it)
ret.append(Py::Int(*it));
return Py::new_reference_to(ret);
}
catch (Standard_Failure) {
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(Base::BaseExceptionFreeCADError, e->GetMessageString());
PyErr_SetString(Base::BaseExceptionFreeCADError, e->GetMessageString());
return 0;
}
}
}
PyObject* FemMeshPy::getNodesByEdge(PyObject *args)
{
PyObject *pW;
if (!PyArg_ParseTuple(args, "O!", &(Part::TopoShapeEdgePy::Type), &pW))
return 0;
try {
const TopoDS_Shape& sh = static_cast<Part::TopoShapeEdgePy*>(pW)->getTopoShapePtr()->_Shape;
const TopoDS_Edge& fc = TopoDS::Edge(sh);
if (sh.IsNull()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Edge is empty");
return 0;
}
Py::List ret;
std::set<long> resultSet = getFemMeshPtr()->getSurfaceNodes(fc);
for( std::set<long>::const_iterator it = resultSet.begin();it!=resultSet.end();++it)
ret.append(Py::Int(*it));
return Py::new_reference_to(ret);
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(Base::BaseExceptionFreeCADError, e->GetMessageString());
return 0;
}
}
// ===== Atributes ============================================================

View File

@ -411,8 +411,8 @@ class _JobControlTaskPanel:
print ' Face Support (fixed face) on: ', f
n = MeshObject.FemMesh.getNodesByFace(fo)
elif fo.ShapeType == 'Edge':
print ' Line Support (fixed edge) on: ', f, ' --> not supported yet'
#n = MeshObject.FemMesh.getNodesByEdge(fo) # ToDo
print ' Line Support (fixed edge) on: ', f
n = MeshObject.FemMesh.getNodesByEdge(fo)
elif fo.ShapeType == 'Vertex':
print ' Point Support (fixed vertex) on: ', f, ' --> not supported yet'
#n = MeshObject.FemMesh.getNodesByVertex(fo) # ToDo
@ -434,8 +434,8 @@ class _JobControlTaskPanel:
print ' AreaLoad (face load) on: ', f
n = MeshObject.FemMesh.getNodesByFace(fo)
elif fo.ShapeType == 'Edge':
print ' Line Load (edge load) on: ', f, ' --> not supported yet'
#n = MeshObject.FemMesh.getNodesByEdge(fo) # ToDo
print ' Line Load (edge load) on: ', f
n = MeshObject.FemMesh.getNodesByEdge(fo)
elif fo.ShapeType == 'Vertex':
print ' Point Load (vertex load) on: ', f, ' --> not supported yet'
#n = MeshObject.FemMesh.getNodesByVertex(fo) # ToDo