Update the NetgenPlugin of Salomemesh with the patched version

This commit is contained in:
jriegel 2013-03-29 16:53:00 +01:00
parent 70fd001c7e
commit 82e07c46c9
17 changed files with 106 additions and 520 deletions

View File

@ -27,7 +27,7 @@
#define _NETGENPlugin_DEFS_HXX_
#ifdef WIN32
#if defined NETGENPLUGIN_EXPORTS || defined NETGENEngine_EXPORTS
#ifdef NETGENPLUGIN_EXPORTS
#define NETGENPLUGIN_EXPORT __declspec( dllexport )
#else
#define NETGENPLUGIN_EXPORT __declspec( dllimport )

View File

@ -24,6 +24,8 @@
// Author : Michael Sazonov (OCN)
// Date : 27/03/2006
// Project : SALOME
// $Header: /home/server/cvs/NETGENPLUGIN/NETGENPLUGIN_SRC/src/NETGENPlugin/NETGENPlugin_Hypothesis.hxx,v 1.4.2.2 2008/11/27 14:29:44 abd Exp $
//=============================================================================
//
#ifndef _NETGENPlugin_Hypothesis_HXX_
#define _NETGENPlugin_Hypothesis_HXX_
@ -31,13 +33,11 @@
#include "NETGENPlugin_Defs.hxx"
#include "SMESH_Hypothesis.hxx"
#include "Utils_SALOME_Exception.hxx"
#include "SMESH_Exception.hxx"
// Parameters for work of NETGEN
//
using namespace std;
class NETGENPLUGIN_EXPORT NETGENPlugin_Hypothesis: public SMESH_Hypothesis
{
public:
@ -88,10 +88,10 @@ public:
static bool GetDefaultOptimize();
// Persistence
virtual ostream & SaveTo(ostream & save);
virtual istream & LoadFrom(istream & load);
friend NETGENPLUGIN_EXPORT ostream & operator <<(ostream & save, NETGENPlugin_Hypothesis & hyp);
friend NETGENPLUGIN_EXPORT istream & operator >>(istream & load, NETGENPlugin_Hypothesis & hyp);
virtual std::ostream & SaveTo(std::ostream & save);
virtual std::istream & LoadFrom(std::istream & load);
friend NETGENPLUGIN_EXPORT std::ostream & operator <<(std::ostream & save, NETGENPlugin_Hypothesis & hyp);
friend NETGENPLUGIN_EXPORT std::istream & operator >>(std::istream & load, NETGENPlugin_Hypothesis & hyp);
/*!
* \brief Does nothing
@ -100,8 +100,8 @@ public:
* \retval bool - always false
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
/*!
/*!
* \brief Initialize my parameter values by default parameters.
* \retval bool - true if parameter values have been successfully defined
*/

View File

@ -24,7 +24,7 @@
// Author : Michael Sazonov (OCN)
// Date : 27/03/2006
// Project : SALOME
// $Header$
// $Header: /home/server/cvs/NETGENPLUGIN/NETGENPLUGIN_SRC/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D.hxx,v 1.4.2.2 2008/11/27 14:29:44 abd Exp $
//=============================================================================
//
#ifndef _NETGENPlugin_Hypothesis_2D_HXX_
@ -33,7 +33,7 @@
#include "NETGENPlugin_Defs.hxx"
#include "NETGENPlugin_Hypothesis.hxx"
#include "Utils_SALOME_Exception.hxx"
#include "SMESH_Exception.hxx"
// Parameters for work of NETGEN.
// This class is just to give 2D dimension, actually
@ -50,8 +50,8 @@ public:
static bool GetDefaultQuadAllowed();
// Persistence
virtual ostream & SaveTo(ostream & save);
virtual istream & LoadFrom(istream & load);
virtual std::ostream & SaveTo(std::ostream & save);
virtual std::istream & LoadFrom(std::istream & load);
private:
bool _quadAllowed;

View File

@ -24,7 +24,7 @@
// Author : Michael Sazonov (OCN)
// Date : 31/03/2006
// Project : SALOME
// $Header$
// $Header: /home/server/cvs/NETGENPLUGIN/NETGENPLUGIN_SRC/src/NETGENPlugin/NETGENPlugin_Mesher.hxx,v 1.4.2.2 2008/11/27 14:29:44 abd Exp $
//=============================================================================
//
#ifndef _NETGENPlugin_Mesher_HXX_
@ -61,8 +61,6 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Mesher
bool Compute();
bool Evaluate(MapShapeNbElems& aResMap);
static void PrepareOCCgeometry(netgen::OCCGeometry& occgeom,
const TopoDS_Shape& shape,
SMESH_Mesh& mesh,

View File

@ -24,7 +24,7 @@
// Author : Michael Sazonov (OCN)
// Date : 20/03/2006
// Project : SALOME
// $Header$
// $Header: /home/server/cvs/NETGENPLUGIN/NETGENPLUGIN_SRC/src/NETGENPlugin/NETGENPlugin_NETGEN_2D.hxx,v 1.4.2.2 2008/11/27 14:29:44 abd Exp $
//=============================================================================
//
#ifndef _NETGENPlugin_NETGEN_2D_HXX_
@ -35,7 +35,7 @@
#include "SMESH_2D_Algo.hxx"
#include "SMESH_Mesh.hxx"
#include "StdMeshers_MaxElementVolume.hxx"
#include "Utils_SALOME_Exception.hxx"
#include "SMESH_Exception.hxx"
//class NETGENPlugin_Hypothesis_2D;
@ -52,9 +52,6 @@ public:
virtual bool Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape);
virtual bool Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape,
MapShapeNbElems& aResMap);
protected:
const SMESHDS_Hypothesis* _hypothesis;
};

View File

@ -24,7 +24,7 @@
// Author : Michael Sazonov (OCN)
// Date : 20/03/2006
// Project : SALOME
// $Header$
// $Header: /home/server/cvs/NETGENPLUGIN/NETGENPLUGIN_SRC/src/NETGENPlugin/NETGENPlugin_NETGEN_2D3D.hxx,v 1.4.2.2 2008/11/27 14:29:44 abd Exp $
//=============================================================================
//
#ifndef _NETGENPlugin_NETGEN_2D3D_HXX_
@ -35,7 +35,7 @@
#include "SMESH_3D_Algo.hxx"
#include "SMESH_Mesh.hxx"
#include "StdMeshers_MaxElementVolume.hxx"
#include "Utils_SALOME_Exception.hxx"
#include "SMESH_Exception.hxx"
//class NETGENPlugin_Hypothesis;
@ -52,10 +52,6 @@ public:
virtual bool Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape);
virtual bool Evaluate(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
MapShapeNbElems& aResMap);
protected:
const SMESHDS_Hypothesis* _hypothesis;
};

View File

@ -70,9 +70,6 @@ public:
virtual bool Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape);
virtual bool Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape,
MapShapeNbElems& aResMap);
/*static TError AddSegmentsToMesh(netgen::Mesh& ngMesh,
OCCGeometry& geom,
const TSideVector& wires,

View File

@ -25,7 +25,7 @@
// Created : lundi 27 Janvier 2003
// Author : Nadir BOUHAMOU (CEA)
// Project : SALOME
// $Header$
// $Header: /home/server/cvs/NETGENPLUGIN/NETGENPLUGIN_SRC/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.hxx,v 1.4.2.1 2008/11/27 14:29:45 abd Exp $
//=============================================================================
//
#ifndef _NETGENPlugin_NETGEN_3D_HXX_
@ -36,7 +36,7 @@
#include "SMESH_3D_Algo.hxx"
#include "SMESH_Mesh.hxx"
#include "StdMeshers_MaxElementVolume.hxx"
#include "Utils_SALOME_Exception.hxx"
#include "SMESH_Exception.hxx"
class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D: public SMESH_3D_Algo
{
@ -54,10 +54,6 @@ public:
virtual bool Compute(SMESH_Mesh& aMesh,
SMESH_MesherHelper* aHelper);
virtual bool Evaluate(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
MapShapeNbElems& aResMap);
protected:
double _maxElementVolume;

View File

@ -31,13 +31,11 @@
#include "NETGENPlugin_Defs.hxx"
#include "SMESH_Hypothesis.hxx"
#include "Utils_SALOME_Exception.hxx"
#include "SMESH_Exception.hxx"
// Simplified parameters of NETGEN
//
using namespace std;
class NETGENPLUGIN_EXPORT NETGENPlugin_SimpleHypothesis_2D: public SMESH_Hypothesis
{
public:
@ -47,7 +45,7 @@ public:
/*!
* Sets <number of segments> value
*/
void SetNumberOfSegments(int nb) throw (SALOME_Exception);
void SetNumberOfSegments(int nb) throw (SMESH_Exception);
/*!
* Returns <number of segments> value.
* Can be zero in case if LocalLength() has been set
@ -57,7 +55,7 @@ public:
/*!
* Sets <segment length> value
*/
void SetLocalLength(double segmentLength) throw (SALOME_Exception);
void SetLocalLength(double segmentLength) throw (SMESH_Exception);
/*!
* Returns <segment length> value.
* Can be zero in case if NumberOfSegments() has been set
@ -81,8 +79,8 @@ public:
double GetMaxElementArea() const { return _area; }
// Persistence
virtual ostream & SaveTo(ostream & save);
virtual istream & LoadFrom(istream & load);
virtual std::ostream & SaveTo(std::ostream & save);
virtual std::istream & LoadFrom(std::istream & load);
/*!
* \brief Set parameters by mesh
@ -91,13 +89,13 @@ public:
* \retval bool - true if theShape is meshed
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
/*!
/*!
* \brief Initialize my parameter values by default parameters.
* \retval bool - true if parameter values have been successfully defined
*/
virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0);
private:
int _nbSegments;
double _segmentLength, _area;

View File

@ -31,13 +31,11 @@
#include "NETGENPlugin_Defs.hxx"
#include "NETGENPlugin_SimpleHypothesis_2D.hxx"
#include <Utils_SALOME_Exception.hxx>
#include <SMESH_Exception.hxx>
// Simplified parameters of NETGEN
//
using namespace std;
class NETGENPLUGIN_EXPORT NETGENPlugin_SimpleHypothesis_3D: public NETGENPlugin_SimpleHypothesis_2D
{
public:
@ -50,8 +48,8 @@ public:
double GetMaxElementVolume() const { return _volume; }
// Persistence
virtual ostream & SaveTo(ostream & save);
virtual istream & LoadFrom(istream & load);
virtual std::ostream & SaveTo(std::ostream & save);
virtual std::istream & LoadFrom(std::istream & load);
/*!
* \brief Set parameters by mesh

View File

@ -24,10 +24,10 @@
// Author : Michael Sazonov (OCN)
// Date : 28/03/2006
// Project : SALOME
// $Header$
// $Header: /home/server/cvs/NETGENPLUGIN/NETGENPLUGIN_SRC/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D.cxx,v 1.4.2.1 2008/11/27 14:29:44 abd Exp $
//=============================================================================
//
#include "NETGENPlugin_Hypothesis_2D.hxx"
#include <NETGENPlugin_Hypothesis_2D.hxx>
#include <utilities.h>
using namespace std;

View File

@ -41,7 +41,6 @@
#include <utilities.h>
#include <vector>
#include <limits>
#include <BRep_Tool.hxx>
#include <TopExp.hxx>
@ -52,9 +51,7 @@
#include <OSD_File.hxx>
#include <TCollection_AsciiString.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_DataMapOfShapeInteger.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_ProgramError.hxx>
// Netgen include files
namespace nglib {
@ -65,22 +62,12 @@ namespace nglib {
#include <meshing.hpp>
//#include <ngexception.hpp>
namespace netgen {
extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, int, int, char*);
extern MeshingParameters mparam;
__declspec(dllimport) extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, int, int, char*);
__declspec(dllimport) extern MeshingParameters mparam;
}
using namespace std;
static void removeFile( const TCollection_AsciiString& fileName )
{
try {
OSD_File( fileName ).Remove();
}
catch ( Standard_ProgramError ) {
MESSAGE("Can't remove file: " << fileName.ToCString() << " ; file does not exist or permission denied");
}
}
//=============================================================================
/*!
*
@ -107,11 +94,11 @@ NETGENPlugin_Mesher::NETGENPlugin_Mesher (SMESH_Mesh* mesh,
void NETGENPlugin_Mesher::defaultParameters()
{
#ifdef WNT
netgen::MeshingParameters& mparams = netgen::GlobalMeshingParameters();
#else
//#ifdef WNT
// netgen::MeshingParameters& mparams = netgen::GlobalMeshingParameters();
//#else
netgen::MeshingParameters& mparams = netgen::mparam;
#endif
//#endif
// maximal mesh edge size
mparams.maxh = NETGENPlugin_Hypothesis::GetDefaultMaxSize();
// minimal number of segments per edge
@ -138,11 +125,11 @@ void NETGENPlugin_Mesher::SetParameters(const NETGENPlugin_Hypothesis* hyp)
{
if (hyp)
{
#ifdef WNT
netgen::MeshingParameters& mparams = netgen::GlobalMeshingParameters();
#else
//#ifdef WNT
// netgen::MeshingParameters& mparams = netgen::GlobalMeshingParameters();
//#else
netgen::MeshingParameters& mparams = netgen::mparam;
#endif
//#endif
// Initialize global NETGEN parameters:
// maximal mesh segment size
mparams.maxh = hyp->GetMaxSize();
@ -257,7 +244,7 @@ void NETGENPlugin_Mesher::PrepareOCCgeometry(netgen::OCCGeometry& occgeo,
TopExp::MapShapes(root->GetSubShape(), subShapes);
while ( smIt->more() ) {
SMESH_subMesh* sm = smIt->next();
if ( !meshedSM || sm->IsEmpty() ) {
if ( sm->IsEmpty() ) {
TopoDS_Shape shape = sm->GetSubShape();
if ( shape.ShapeType() != TopAbs_VERTEX )
shape = subShapes( subShapes.FindIndex( shape ));// - shape->index->oriented shape
@ -278,6 +265,11 @@ void NETGENPlugin_Mesher::PrepareOCCgeometry(netgen::OCCGeometry& occgeo,
occgeo.facemeshstatus.SetSize (occgeo.fmap.Extent());
occgeo.facemeshstatus = 0;
occgeo.face_maxh.DeleteAll();
occgeo.face_maxh.SetSize (occgeo.fmap.Extent());
occgeo.face_maxh = netgen::mparam.maxh;
}
//================================================================================
@ -385,8 +377,8 @@ bool NETGENPlugin_Mesher::fillNgMesh(netgen::OCCGeometry& occgeom,
netgen::Segment seg;
// ng node ids
seg.p1 = prevNgId;
seg.p2 = prevNgId = ngNodeId( p2.node, ngMesh, nodeNgIdMap );
seg.pnums[0] = prevNgId;
seg.pnums[1] = prevNgId = ngNodeId( p2.node, ngMesh, nodeNgIdMap );
// node param on curve
seg.epgeominfo[ 0 ].dist = p1.param;
seg.epgeominfo[ 1 ].dist = p2.param;
@ -412,7 +404,7 @@ bool NETGENPlugin_Mesher::fillNgMesh(netgen::OCCGeometry& occgeom,
seg.epgeominfo[ 1 ].v = otherSeamParam;
swap (seg.epgeominfo[0].u, seg.epgeominfo[1].u);
}
swap (seg.p1, seg.p2);
swap (seg.pnums[0], seg.pnums[1]);
swap (seg.epgeominfo[0].dist, seg.epgeominfo[1].dist);
seg.edgenr = ngMesh.GetNSeg() + 1; // segment id
ngMesh.AddSegment (seg);
@ -530,11 +522,11 @@ bool NETGENPlugin_Mesher::fillNgMesh(netgen::OCCGeometry& occgeom,
//=============================================================================
bool NETGENPlugin_Mesher::Compute()
{
#ifdef WNT
netgen::MeshingParameters& mparams = netgen::GlobalMeshingParameters();
#else
//#ifdef WNT
// netgen::MeshingParameters& mparams = netgen::GlobalMeshingParameters();
//#else
netgen::MeshingParameters& mparams = netgen::mparam;
#endif
//#endif
MESSAGE("Compute with:\n"
" max size = " << mparams.maxh << "\n"
" segments per edge = " << mparams.segmentsperedge);
@ -591,7 +583,8 @@ bool NETGENPlugin_Mesher::Compute()
char *optstr = 0;
int startWith = netgen::MESHCONST_ANALYSE;
int endWith = netgen::MESHCONST_ANALYSE;
err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
//err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
err = netgen::OCCGenerateMesh(occgeo, ngMesh,mparams, startWith, endWith);
if (err) comment << "Error in netgen::OCCGenerateMesh() at MESHCONST_ANALYSE step";
// fill ngMesh with nodes and elements of computed submeshes
@ -604,7 +597,8 @@ bool NETGENPlugin_Mesher::Compute()
if (!err)
{
startWith = endWith = netgen::MESHCONST_MESHEDGES;
err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
//err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
err = netgen::OCCGenerateMesh(occgeo, ngMesh,mparams, startWith, endWith);
if (err) comment << "Error in netgen::OCCGenerateMesh() at 1D mesh generation";
}
// ---------------------
@ -622,31 +616,25 @@ bool NETGENPlugin_Mesher::Compute()
else {
// length from edges
double length = 0;
TopTools_MapOfShape tmpMap;
for ( TopExp_Explorer exp( _shape, TopAbs_EDGE ); exp.More(); exp.Next() )
if( tmpMap.Add(exp.Current()) )
length += SMESH_Algo::EdgeLength( TopoDS::Edge( exp.Current() ));
if ( ngMesh->GetNSeg() ) {
// we have to multiply length by 2 since for each TopoDS_Edge there
// are double set of NETGEN edges or, in other words, we have to
// divide ngMesh->GetNSeg() on 2.
mparams.maxh = 2*length / ngMesh->GetNSeg();
}
length += SMESH_Algo::EdgeLength( TopoDS::Edge( exp.Current() ));
if ( ngMesh->GetNSeg() )
mparams.maxh = length / ngMesh->GetNSeg();
else
mparams.maxh = 1000;
mparams.grading = 0.2; // slow size growth
}
mparams.maxh = min( mparams.maxh, occgeo.boundingbox.Diam()/2 );
ngMesh->SetGlobalH (mparams.maxh);
netgen::Box<3> bb = occgeo.GetBoundingBox();
bb.Increase (bb.Diam()/20);
netgen::Box<3> bb = occgeo.GetBoundingBox();
bb.Increase (bb.Diam()/20);
ngMesh->SetLocalH (bb.PMin(), bb.PMax(), mparams.grading);
}
// let netgen compute 2D mesh
startWith = netgen::MESHCONST_MESHSURFACE;
endWith = _optimize ? netgen::MESHCONST_OPTSURFACE : netgen::MESHCONST_MESHSURFACE;
err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
//err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
err = netgen::OCCGenerateMesh(occgeo, ngMesh,mparams, startWith, endWith);
if (err) comment << "Error in netgen::OCCGenerateMesh() at surface mesh generation";
}
// ---------------------
@ -675,18 +663,19 @@ bool NETGENPlugin_Mesher::Compute()
// length from faces
mparams.maxh = ngMesh->AverageH();
}
// netgen::ARRAY<double> maxhdom;
// maxhdom.SetSize (occgeo.NrSolids());
// maxhdom = mparams.maxh;
// ngMesh->SetMaxHDomain (maxhdom);
// netgen::ARRAY<double> maxhdom;
// maxhdom.SetSize (occgeo.NrSolids());
// maxhdom = mparams.maxh;
// ngMesh->SetMaxHDomain (maxhdom);
ngMesh->SetGlobalH (mparams.maxh);
mparams.grading = 0.4;
ngMesh->CalcLocalH();
ngMesh->CalcLocalH(0.4);
}
// let netgen compute 3D mesh
startWith = netgen::MESHCONST_MESHVOLUME;
endWith = _optimize ? netgen::MESHCONST_OPTVOLUME : netgen::MESHCONST_MESHVOLUME;
err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
//err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
err = netgen::OCCGenerateMesh(occgeo, ngMesh,mparams, startWith, endWith);
if (err) comment << "Error in netgen::OCCGenerateMesh()";
}
if (!err && mparams.secondorder > 0)
@ -749,7 +738,7 @@ bool NETGENPlugin_Mesher::Compute()
newNodeOnVertex = true;
}
if (!node)
node = meshDS->AddNode(ngPoint.X(), ngPoint.Y(), ngPoint.Z());
node = meshDS->AddNode(ngPoint(0), ngPoint(1), ngPoint(2));
if (!node)
{
MESSAGE("Cannot create a mesh node");
@ -771,12 +760,12 @@ bool NETGENPlugin_Mesher::Compute()
for (i = nbInitSeg+1; i <= nbSeg/* && isOK*/; ++i )
{
const netgen::Segment& seg = ngMesh->LineSegment(i);
Link link(seg.p1, seg.p2);
Link link(seg.pnums[0], seg.pnums[1]);
if (linkMap.Contains(link))
continue;
linkMap.Add(link);
TopoDS_Edge aEdge;
int pinds[3] = { seg.p1, seg.p2, seg.pmid };
int pinds[3] = { seg.pnums[0], seg.pnums[1], seg.pnums[2] };
int nbp = 0;
double param2 = 0;
for (int j=0; j < 3; ++j)
@ -952,7 +941,7 @@ bool NETGENPlugin_Mesher::Compute()
nglib::Ng_DeleteMesh((nglib::Ng_Mesh*)ngMesh);
nglib::Ng_Exit();
RemoveTmpFiles();
//RemoveTmpFiles();
return error->IsOK();
}
@ -965,182 +954,12 @@ bool NETGENPlugin_Mesher::Compute()
void NETGENPlugin_Mesher::RemoveTmpFiles()
{
removeFile("test.out");
removeFile("problemfaces");
}
//=============================================================================
/*!
* Evaluate
*/
//=============================================================================
bool NETGENPlugin_Mesher::Evaluate(MapShapeNbElems& aResMap)
{
#ifdef WNT
netgen::MeshingParameters& mparams = netgen::GlobalMeshingParameters();
#else
netgen::MeshingParameters& mparams = netgen::mparam;
#endif
// -------------------------
// Prepare OCC geometry
// -------------------------
netgen::OCCGeometry occgeo;
list< SMESH_subMesh* > meshedSM;
PrepareOCCgeometry( occgeo, _shape, *_mesh, &meshedSM );
bool tooManyElems = false;
const int hugeNb = std::numeric_limits<int>::max() / 100;
// ----------------
// evaluate 1D
// ----------------
// pass 1D simple parameters to NETGEN
int nbs = 0;
if ( _simpleHyp ) {
if ( int nbSeg = _simpleHyp->GetNumberOfSegments() ) {
nbs = nbSeg;
// nb of segments
mparams.segmentsperedge = nbSeg + 0.1;
mparams.maxh = occgeo.boundingbox.Diam();
mparams.grading = 0.01;
}
else {
// segment length
mparams.segmentsperedge = 1;
mparams.maxh = _simpleHyp->GetLocalLength();
}
}
TopTools_DataMapOfShapeInteger EdgesMap;
double fullLen = 0.0;
double fullNbSeg = 0;
for (TopExp_Explorer exp(_shape, TopAbs_EDGE); exp.More(); exp.Next()) {
TopoDS_Edge E = TopoDS::Edge( exp.Current() );
if( EdgesMap.IsBound(E) )
continue;
SMESH_subMesh *sm = _mesh->GetSubMesh(E);
std::vector<int> aVec(SMDSEntity_Last, 0);
double aLen = SMESH_Algo::EdgeLength(E);
fullLen += aLen;
int nb1d = nbs;
tooManyElems = ( aLen/hugeNb > mparams.maxh );
if(nb1d==0 && !tooManyElems) {
nb1d = (int)( aLen/mparams.maxh + 1 );
}
if ( tooManyElems ) // avoid FPE
{
aVec[SMDSEntity_Node] = hugeNb;
aVec[ mparams.secondorder > 0 ? SMDSEntity_Quad_Edge : SMDSEntity_Edge] = hugeNb;
}
else
{
fullNbSeg += nb1d;
if( mparams.secondorder > 0 ) {
aVec[SMDSEntity_Node] = 2*nb1d - 1;
aVec[SMDSEntity_Quad_Edge] = nb1d;
}
else {
aVec[SMDSEntity_Node] = nb1d - 1;
aVec[SMDSEntity_Edge] = nb1d;
}
}
aResMap.insert(std::make_pair(sm,aVec));
EdgesMap.Bind(E,nb1d);
}
// ----------------
// evaluate 2D
// ----------------
if ( _simpleHyp ) {
if ( double area = _simpleHyp->GetMaxElementArea() ) {
// face area
mparams.maxh = sqrt(2. * area/sqrt(3.0));
mparams.grading = 0.4; // moderate size growth
}
else {
// length from edges
mparams.maxh = fullLen/fullNbSeg;
mparams.grading = 0.2; // slow size growth
}
mparams.maxh = min( mparams.maxh, occgeo.boundingbox.Diam()/2 );
}
for (TopExp_Explorer exp(_shape, TopAbs_FACE); exp.More(); exp.Next())
{
TopoDS_Face F = TopoDS::Face( exp.Current() );
SMESH_subMesh *sm = _mesh->GetSubMesh(F);
GProp_GProps G;
BRepGProp::SurfaceProperties(F,G);
double anArea = G.Mass();
tooManyElems = tooManyElems || ( anArea/hugeNb > mparams.maxh*mparams.maxh );
int nb1d = 0;
if ( !tooManyElems )
for (TopExp_Explorer exp1(F,TopAbs_EDGE); exp1.More(); exp1.Next())
nb1d += EdgesMap.Find(exp1.Current());
int nbFaces = tooManyElems ? hugeNb : int( 4*anArea / mparams.maxh*mparams.maxh*sqrt(3.));
int nbNodes = tooManyElems ? hugeNb : (( nbFaces*3 - (nb1d-1)*2 ) / 6 + 1 );
std::vector<int> aVec(SMDSEntity_Last, 0);
if( mparams.secondorder > 0 ) {
int nb1d_in = (nbFaces*3 - nb1d) / 2;
aVec[SMDSEntity_Node] = nbNodes + nb1d_in;
aVec[SMDSEntity_Quad_Triangle] = nbFaces;
}
else {
aVec[SMDSEntity_Node] = nbNodes;
aVec[SMDSEntity_Triangle] = nbFaces;
}
aResMap.insert(std::make_pair(sm,aVec));
}
// ----------------
// evaluate 3D
// ----------------
if(_isVolume) {
// pass 3D simple parameters to NETGEN
const NETGENPlugin_SimpleHypothesis_3D* simple3d =
dynamic_cast< const NETGENPlugin_SimpleHypothesis_3D* > ( _simpleHyp );
if ( simple3d ) {
if ( double vol = simple3d->GetMaxElementVolume() ) {
// max volume
mparams.maxh = pow( 72, 1/6. ) * pow( vol, 1/3. );
mparams.maxh = min( mparams.maxh, occgeo.boundingbox.Diam()/2 );
}
else {
// using previous length from faces
}
mparams.grading = 0.4;
}
GProp_GProps G;
BRepGProp::VolumeProperties(_shape,G);
double aVolume = G.Mass();
double tetrVol = 0.1179*mparams.maxh*mparams.maxh*mparams.maxh;
tooManyElems = tooManyElems || ( aVolume/hugeNb > tetrVol );
int nbVols = tooManyElems ? hugeNb : int(aVolume/tetrVol);
int nb1d_in = int(( nbVols*6 - fullNbSeg ) / 6 );
std::vector<int> aVec(SMDSEntity_Last, 0 );
if ( tooManyElems ) // avoid FPE
{
aVec[SMDSEntity_Node] = hugeNb;
aVec[ mparams.secondorder > 0 ? SMDSEntity_Quad_Tetra : SMDSEntity_Tetra] = hugeNb;
}
else
{
if( mparams.secondorder > 0 ) {
aVec[SMDSEntity_Node] = nb1d_in/3 + 1 + nb1d_in;
aVec[SMDSEntity_Quad_Tetra] = nbVols;
}
else {
aVec[SMDSEntity_Node] = nb1d_in/3 + 1;
aVec[SMDSEntity_Tetra] = nbVols;
}
}
SMESH_subMesh *sm = _mesh->GetSubMesh(_shape);
aResMap.insert(std::make_pair(sm,aVec));
}
return true;
TCollection_AsciiString str("test.out");
OSD_Path path1( str );
OSD_File file1( path1 );
file1.Remove();
str = "problemfaces";
OSD_Path path2( str );
OSD_File file2( path2 );
file2.Remove();
}

View File

@ -24,7 +24,7 @@
// Author : Michael Sazonov (OCN)
// Date : 20/03/2006
// Project : SALOME
// $Header$
// $Header: /home/server/cvs/NETGENPLUGIN/NETGENPLUGIN_SRC/src/NETGENPlugin/NETGENPlugin_NETGEN_2D.cxx,v 1.4.2.2 2008/11/27 14:29:44 abd Exp $
//=============================================================================
//
#include "NETGENPlugin_NETGEN_2D.hxx"
@ -129,21 +129,3 @@ bool NETGENPlugin_NETGEN_2D::Compute(SMESH_Mesh& aMesh,
mesher.SetParameters(dynamic_cast<const NETGENPlugin_SimpleHypothesis_2D*>(_hypothesis));
return mesher.Compute();
}
//=============================================================================
/*!
*
*/
//=============================================================================
bool NETGENPlugin_NETGEN_2D::Evaluate(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
MapShapeNbElems& aResMap)
{
NETGENPlugin_Mesher mesher(&aMesh, aShape, false);
mesher.SetParameters(dynamic_cast<const NETGENPlugin_Hypothesis*>(_hypothesis));
mesher.SetParameters(dynamic_cast<const NETGENPlugin_SimpleHypothesis_2D*>(_hypothesis));
return mesher.Evaluate(aResMap);
}

View File

@ -24,7 +24,7 @@
// Author : Michael Sazonov (OCN)
// Date : 20/03/2006
// Project : SALOME
// $Header$
// $Header: /home/server/cvs/NETGENPLUGIN/NETGENPLUGIN_SRC/src/NETGENPlugin/NETGENPlugin_NETGEN_2D3D.cxx,v 1.4.2.2 2008/11/27 14:29:44 abd Exp $
//=============================================================================
//
#include "NETGENPlugin_NETGEN_2D3D.hxx"
@ -132,20 +132,3 @@ bool NETGENPlugin_NETGEN_2D3D::Compute(SMESH_Mesh& aMesh,
mesher.SetParameters(dynamic_cast<const NETGENPlugin_SimpleHypothesis_2D*>(_hypothesis));
return mesher.Compute();
}
//=============================================================================
/*!
*
*/
//=============================================================================
bool NETGENPlugin_NETGEN_2D3D::Evaluate(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
MapShapeNbElems& aResMap)
{
NETGENPlugin_Mesher mesher(&aMesh, aShape, true);
mesher.SetParameters(dynamic_cast<const NETGENPlugin_Hypothesis*>(_hypothesis));
mesher.SetParameters(dynamic_cast<const NETGENPlugin_SimpleHypothesis_2D*>(_hypothesis));
return mesher.Evaluate(aResMap);
}

View File

@ -39,7 +39,6 @@
#include "StdMeshers_LengthFromEdges.hxx"
#include "StdMeshers_QuadranglePreference.hxx"
#include <Precision.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
@ -47,7 +46,6 @@
#include <list>
#include <vector>
#include <limits>
/*
Netgen include files
@ -60,8 +58,8 @@ namespace nglib {
#include <meshing.hpp>
//#include <meshtype.hpp>
namespace netgen {
extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, int, int, char*);
/*extern*/ MeshingParameters mparam;
//__declspec(dllimport) extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, int, int, char*);
__declspec(dllimport) extern MeshingParameters mparam;
}
using namespace std;
@ -80,7 +78,7 @@ NETGENPlugin_NETGEN_2D_ONLY::NETGENPlugin_NETGEN_2D_ONLY(int hypId, int studyId,
{
MESSAGE("NETGENPlugin_NETGEN_2D_ONLY::NETGENPlugin_NETGEN_2D_ONLY");
_name = "NETGEN_2D_ONLY";
_shapeType = (1 << TopAbs_FACE);// 1 bit /shape type
_compatibleHypothesis.push_back("MaxElementArea");
@ -228,8 +226,8 @@ static TError AddSegmentsToMesh(netgen::Mesh& ngMesh,
// Add the segment
Segment seg;
seg.p1 = ngMesh.GetNP(); // ng node id
seg.p2 = seg.p1 + 1; // ng node id
seg.pnums[0] = ngMesh.GetNP(); // ng node id
seg.pnums[1] = seg.pnums[0] + 1; // ng node id
seg.edgenr = ngMesh.GetNSeg() + 1;// segment id
seg.si = faceID; // = geom.fmap.FindIndex (face);
@ -271,7 +269,7 @@ static TError AddSegmentsToMesh(netgen::Mesh& ngMesh,
// << "\tp1 edge: " << seg.epgeominfo[ 1 ].edgenr << endl;
}
Segment& seg = ngMesh.LineSegment( ngMesh.GetNSeg() );
seg.p2 = firstPointID;
seg.pnums[1] = firstPointID;
}
ngMesh.CalcSurfacesOfNode();
@ -366,7 +364,7 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh,
// Generate surface mesh
// -------------------------
char *optstr = 0;
char *optstr;
int startWith = MESHCONST_MESHSURFACE;
int endWith = MESHCONST_OPTSURFACE;
int err = 1;
@ -375,7 +373,9 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh,
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
#endif
err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
//err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
// jriegel: change, cause no such methode in nglib
err = netgen::OCCGenerateMesh(occgeo, ngMesh,netgen::mparam, startWith, endWith);
}
catch (Standard_Failure& ex) {
string comment = ex.DynamicType()->Name();
@ -406,7 +406,7 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh,
for ( int i = nbInputNodes + 1; i <= nbNodes; ++i )
{
const MeshPoint& ngPoint = ngMesh->Point(i);
SMDS_MeshNode * node = meshDS->AddNode(ngPoint.X(), ngPoint.Y(), ngPoint.Z());
SMDS_MeshNode * node = meshDS->AddNode(ngPoint(0), ngPoint(1), ngPoint(2));
nodeVec[ i-1 ] = node;
}
@ -444,89 +444,3 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh,
return !err;
}
//=============================================================================
/*!
*
*/
//=============================================================================
bool NETGENPlugin_NETGEN_2D_ONLY::Evaluate(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
MapShapeNbElems& aResMap)
{
TopoDS_Face F = TopoDS::Face(aShape);
if(F.IsNull())
return false;
// collect info from edges
int nb0d = 0, nb1d = 0;
bool IsQuadratic = false;
bool IsFirst = true;
double fullLen = 0.0;
TopTools_MapOfShape tmpMap;
for (TopExp_Explorer exp(F, TopAbs_EDGE); exp.More(); exp.Next()) {
TopoDS_Edge E = TopoDS::Edge(exp.Current());
if( tmpMap.Contains(E) )
continue;
tmpMap.Add(E);
SMESH_subMesh *aSubMesh = aMesh.GetSubMesh(exp.Current());
MapShapeNbElemsItr anIt = aResMap.find(aSubMesh);
if( anIt==aResMap.end() ) {
SMESH_subMesh *sm = aMesh.GetSubMesh(F);
SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,"Submesh can not be evaluated",this));
return false;
}
std::vector<int> aVec = (*anIt).second;
nb0d += aVec[SMDSEntity_Node];
nb1d += Max(aVec[SMDSEntity_Edge],aVec[SMDSEntity_Quad_Edge]);
double aLen = SMESH_Algo::EdgeLength(E);
fullLen += aLen;
if(IsFirst) {
IsQuadratic = (aVec[SMDSEntity_Quad_Edge] > aVec[SMDSEntity_Edge]);
IsFirst = false;
}
}
tmpMap.Clear();
// compute edge length
double ELen = 0;
if (_hypLengthFromEdges || !_hypLengthFromEdges && !_hypMaxElementArea) {
if ( nb1d > 0 )
ELen = fullLen / nb1d;
}
if ( _hypMaxElementArea ) {
double maxArea = _hypMaxElementArea->GetMaxArea();
ELen = sqrt(2. * maxArea/sqrt(3.0));
}
GProp_GProps G;
BRepGProp::SurfaceProperties(F,G);
double anArea = G.Mass();
const int hugeNb = numeric_limits<int>::max()/10;
if ( anArea / hugeNb > ELen*ELen )
{
SMESH_subMesh *sm = aMesh.GetSubMesh(F);
SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,"Submesh can not be evaluated.\nToo small element length",this));
return false;
}
int nbFaces = (int) ( anArea / ( ELen*ELen*sqrt(3.) / 4 ) );
int nbNodes = (int) ( ( nbFaces*3 - (nb1d-1)*2 ) / 6 + 1 );
std::vector<int> aVec(SMDSEntity_Last);
for(int i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aVec[i]=0;
if( IsQuadratic ) {
aVec[SMDSEntity_Node] = nbNodes;
aVec[SMDSEntity_Quad_Triangle] = nbFaces;
}
else {
aVec[SMDSEntity_Node] = nbNodes;
aVec[SMDSEntity_Triangle] = nbFaces;
}
SMESH_subMesh *sm = aMesh.GetSubMesh(F);
aResMap.insert(std::make_pair(sm,aVec));
return true;
}

View File

@ -43,8 +43,6 @@
#include "StdMeshers_QuadToTriaAdaptor.hxx"
#include <BRep_Tool.hxx>
#include <GProp_GProps.hxx>
#include <BRepGProp.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
@ -353,7 +351,7 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
Ng_Meshing_Parameters Netgen_param;
Netgen_param.secondorder = Netgen_param2ndOrder;
Netgen_param.second_order = Netgen_param2ndOrder;
Netgen_param.fineness = Netgen_paramFine;
Netgen_param.maxh = Netgen_paramSize;
@ -564,7 +562,7 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
Ng_Meshing_Parameters Netgen_param;
Netgen_param.secondorder = Netgen_param2ndOrder;
Netgen_param.second_order = Netgen_param2ndOrder;
Netgen_param.fineness = Netgen_paramFine;
Netgen_param.maxh = Netgen_paramSize;
@ -639,92 +637,3 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
return (status == NG_OK);
}
//=============================================================================
/*!
*
*/
//=============================================================================
bool NETGENPlugin_NETGEN_3D::Evaluate(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
MapShapeNbElems& aResMap)
{
int nbtri = 0, nbqua = 0;
double fullArea = 0.0;
for (TopExp_Explorer exp(aShape, TopAbs_FACE); exp.More(); exp.Next()) {
TopoDS_Face F = TopoDS::Face( exp.Current() );
SMESH_subMesh *sm = aMesh.GetSubMesh(F);
MapShapeNbElemsItr anIt = aResMap.find(sm);
if( anIt==aResMap.end() ) {
SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,"Submesh can not be evaluated",this));
return false;
}
std::vector<int> aVec = (*anIt).second;
nbtri += Max(aVec[SMDSEntity_Triangle],aVec[SMDSEntity_Quad_Triangle]);
nbqua += Max(aVec[SMDSEntity_Quadrangle],aVec[SMDSEntity_Quad_Quadrangle]);
GProp_GProps G;
BRepGProp::SurfaceProperties(F,G);
double anArea = G.Mass();
fullArea += anArea;
}
// collect info from edges
int nb0d_e = 0, nb1d_e = 0;
bool IsQuadratic = false;
bool IsFirst = true;
TopTools_MapOfShape tmpMap;
for (TopExp_Explorer exp(aShape, TopAbs_EDGE); exp.More(); exp.Next()) {
TopoDS_Edge E = TopoDS::Edge(exp.Current());
if( tmpMap.Contains(E) )
continue;
tmpMap.Add(E);
SMESH_subMesh *aSubMesh = aMesh.GetSubMesh(exp.Current());
MapShapeNbElemsItr anIt = aResMap.find(aSubMesh);
if( anIt==aResMap.end() ) {
SMESH_ComputeErrorPtr& smError = aSubMesh->GetComputeError();
smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,
"Submesh can not be evaluated",this));
return false;
}
std::vector<int> aVec = (*anIt).second;
nb0d_e += aVec[SMDSEntity_Node];
nb1d_e += Max(aVec[SMDSEntity_Edge],aVec[SMDSEntity_Quad_Edge]);
if(IsFirst) {
IsQuadratic = (aVec[SMDSEntity_Quad_Edge] > aVec[SMDSEntity_Edge]);
IsFirst = false;
}
}
tmpMap.Clear();
double ELen_face = sqrt(2.* ( fullArea/(nbtri+nbqua*2) ) / sqrt(3.0) );
double ELen_vol = pow( 72, 1/6. ) * pow( _maxElementVolume, 1/3. );
double ELen = Min(ELen_vol,ELen_face*2);
GProp_GProps G;
BRepGProp::VolumeProperties(aShape,G);
double aVolume = G.Mass();
double tetrVol = 0.1179*ELen*ELen*ELen;
double CoeffQuality = 0.9;
int nbVols = (int)aVolume/tetrVol/CoeffQuality;
int nb1d_f = (nbtri*3 + nbqua*4 - nb1d_e) / 2;
int nb1d_in = (int) ( nbVols*6 - nb1d_e - nb1d_f ) / 5;
std::vector<int> aVec(SMDSEntity_Last);
for(int i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aVec[i]=0;
if( IsQuadratic ) {
aVec[SMDSEntity_Node] = nb1d_in/6 + 1 + nb1d_in;
aVec[SMDSEntity_Quad_Tetra] = nbVols - nbqua*2;
aVec[SMDSEntity_Quad_Pyramid] = nbqua;
}
else {
aVec[SMDSEntity_Node] = nb1d_in/6 + 1;
aVec[SMDSEntity_Tetra] = nbVols - nbqua*2;
aVec[SMDSEntity_Pyramid] = nbqua;
}
SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
aResMap.insert(std::make_pair(sm,aVec));
return true;
}

View File

@ -60,10 +60,10 @@ NETGENPlugin_SimpleHypothesis_2D::NETGENPlugin_SimpleHypothesis_2D (int
*
*/
//=============================================================================
void NETGENPlugin_SimpleHypothesis_2D::SetNumberOfSegments(int nb) throw (SALOME_Exception)
void NETGENPlugin_SimpleHypothesis_2D::SetNumberOfSegments(int nb) throw (SMESH_Exception)
{
if ( nb < 1 )
throw SALOME_Exception("Number of segments must be positive");
throw SMESH_Exception("Number of segments must be positive");
if (nb != _nbSegments)
{
_nbSegments = nb;
@ -78,10 +78,10 @@ void NETGENPlugin_SimpleHypothesis_2D::SetNumberOfSegments(int nb) throw (SALOME
*/
//=============================================================================
void NETGENPlugin_SimpleHypothesis_2D::SetLocalLength(double segmentLength)
throw (SALOME_Exception)
throw (SMESH_Exception)
{
if ( segmentLength < DBL_MIN )
throw SALOME_Exception("segment length must be more than zero");
throw SMESH_Exception("segment length must be more than zero");
if (segmentLength != _segmentLength)
{
_segmentLength = segmentLength;
@ -221,4 +221,3 @@ bool NETGENPlugin_SimpleHypothesis_2D::SetParametersByDefaults(const TDefaults&
_segmentLength = dflts._elemLength;
return _nbSegments && _segmentLength > 0;
}