From: eap Date: Wed, 15 Dec 2010 10:56:55 +0000 (+0000) Subject: 0020832: EDF 1359 SMESH : Automatic meshing of boundary layers X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=152bbf593faccdb4aed9b35074cae6bc0fbb56b7;p=plugins%2Fghs3dplugin.git 0020832: EDF 1359 SMESH : Automatic meshing of boundary layers - opt-hypos="GHS3D_Parameters" + opt-hypos="GHS3D_Parameters, ViscousLayers" --- diff --git a/resources/GHS3DPlugin.xml b/resources/GHS3DPlugin.xml index 8570f1d..1e7fe64 100644 --- a/resources/GHS3DPlugin.xml +++ b/resources/GHS3DPlugin.xml @@ -41,7 +41,7 @@ icon-id="mesh_tree_hypo_ghs3d.png" input="TRIA,QUAD" need-geom="false" - opt-hypos="GHS3D_Parameters" + opt-hypos="GHS3D_Parameters, ViscousLayers" dim="3"/> diff --git a/src/GHS3DPlugin_GHS3D.cxx b/src/GHS3DPlugin_GHS3D.cxx index 28ee3aa..25aa593 100644 --- a/src/GHS3DPlugin_GHS3D.cxx +++ b/src/GHS3DPlugin_GHS3D.cxx @@ -42,6 +42,7 @@ #include "SMDS_VolumeOfNodes.hxx" #include +#include #include #include @@ -128,6 +129,7 @@ GHS3DPlugin_GHS3D::GHS3DPlugin_GHS3D(int hypId, int studyId, SMESH_Gen* gen) _iShape=0; _nbShape=0; _compatibleHypothesis.push_back("GHS3D_Parameters"); + _compatibleHypothesis.push_back( StdMeshers_ViscousLayers::GetHypType() ); _requireShape = false; // can work without shape } @@ -154,12 +156,20 @@ bool GHS3DPlugin_GHS3D::CheckHypothesis ( SMESH_Mesh& aMesh, { aStatus = SMESH_Hypothesis::HYP_OK; - // there is only one compatible Hypothesis so far _hyp = 0; + _viscousLayersHyp = 0; _keepFiles = false; - const list & hyps = GetUsedHypothesis(aMesh, aShape); - if ( !hyps.empty() ) - _hyp = static_cast ( hyps.front() ); + + const list & hyps = + GetUsedHypothesis(aMesh, aShape, /*ignoreAuxiliary=*/false); + list ::const_iterator h = hyps.begin(); + for ( ; h != hyps.end(); ++h ) + { + if ( !_hyp ) + _hyp = dynamic_cast< const GHS3DPlugin_Hypothesis*> ( *h ); + if ( !_viscousLayersHyp ) + _viscousLayersHyp = dynamic_cast< const StdMeshers_ViscousLayers*> ( *h ); + } if ( _hyp ) _keepFiles = _hyp->GetKeepFiles(); @@ -230,15 +240,15 @@ static char* readMapIntLine(char* ptr, int tab[]) { //purpose : //======================================================================= -template < class Mesh, class Shape > -static int countShape( Mesh* mesh, Shape shape ) { - TopExp_Explorer expShape ( mesh->ShapeToMesh(), shape ); - int nbShape = 0; - for ( ; expShape.More(); expShape.Next() ) { - nbShape++; - } - return nbShape; -} +// template < class Mesh, class Shape > +// static int countShape( Mesh* mesh, Shape shape ) { +// TopExp_Explorer expShape ( mesh->ShapeToMesh(), shape ); +// int nbShape = 0; +// for ( ; expShape.More(); expShape.Next() ) { +// nbShape++; +// } +// return nbShape; +// } //======================================================================= //function : writeFaces @@ -249,6 +259,7 @@ static bool writeFaces (ofstream & theFile, SMESHDS_Mesh* theMesh, const TopoDS_Shape& theShape, vector& theQuad2Trias, + StdMeshers_ProxyMesh::Ptr& theCdfMesh, const map & theSmdsToGhs3dIdMap) { // record structure: @@ -258,7 +269,7 @@ static bool writeFaces (ofstream & theFile, // NB_NODES NODE_NB_1 NODE_NB_2 ... (NB_NODES + 1) times: DUMMY_INT TopoDS_Shape aShape; - SMESHDS_SubMesh* theSubMesh; + const SMESHDS_SubMesh* theSubMesh; const SMDS_MeshElement* aFace; const char* space = " "; const int dummyint = 0; @@ -275,7 +286,13 @@ static bool writeFaces (ofstream & theFile, // 2 adaptors for each face in facesMap, as a face can belong to 2 solids typedef vector< StdMeshers_QuadToTriaAdaptor* > TwoAdaptors; vector< TwoAdaptors > qttaByFace; - if ( theQuad2Trias.empty() ) + if ( theCdfMesh ) + { + for ( int i = 1; i <= facesMap.Extent(); ++i ) + if (( theSubMesh = theCdfMesh->GetSubMesh( facesMap(i)))) + nbTriangles += theSubMesh->NbElements(); + } + else if ( theQuad2Trias.empty() ) { // case w/o quadrangles for ( int i = 1; i <= facesMap.Extent(); ++i ) @@ -327,7 +344,7 @@ static bool writeFaces (ofstream & theFile, for ( int i = 1; i <= facesMap.Extent(); i++ ) { aShape = facesMap(i); - theSubMesh = theMesh->MeshElements( aShape ); + theSubMesh = theCdfMesh ? theCdfMesh->GetSubMesh( aShape ) : theMesh->MeshElements( aShape ); if ( !theSubMesh ) continue; TwoAdaptors& aTwoAdaptors = qttaByFace[ i-1 ]; itOnSubMesh = theSubMesh->GetElements(); @@ -1341,9 +1358,17 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, for (_iShape = 0, expBox.ReInit(); expBox.More(); expBox.Next()) aQuad2Trias[ _iShape++ ].Compute( theMesh, expBox.Current() ); } + // viscous layers + StdMeshers_ProxyMesh::Ptr cdfMesh; + if ( _viscousLayersHyp && aQuad2Trias.empty() ) + { + cdfMesh = _viscousLayersHyp->Compute( theMesh, theShape ); + if ( !cdfMesh ) + return false; + } Ok = (writePoints( aPointsFile, helper, aSmdsToGhs3dIdMap, aGhs3dIdToNodeMap, enforcedVertices) && - writeFaces ( aFacesFile, meshDS, theShape, aQuad2Trias, aSmdsToGhs3dIdMap )); + writeFaces ( aFacesFile, meshDS, theShape, aQuad2Trias, cdfMesh, aSmdsToGhs3dIdMap )); // Write aSmdsToGhs3dIdMap to temp file TCollection_AsciiString aSmdsToGhs3dIdMapFileName; diff --git a/src/GHS3DPlugin_GHS3D.hxx b/src/GHS3DPlugin_GHS3D.hxx index b05bdde..2054a79 100644 --- a/src/GHS3DPlugin_GHS3D.hxx +++ b/src/GHS3DPlugin_GHS3D.hxx @@ -21,7 +21,6 @@ // File : GHS3DPlugin_GHS3D.hxx // Author : Edward AGAPOV, modified by Lioka RAZAFINDRAZAKA (CEA) 09/02/2007 // Project : SALOME -// $Header$ //============================================================================= // #ifndef _GHS3DPlugin_GHS3D_HXX_ @@ -32,9 +31,10 @@ #include #include -class SMESH_Mesh; class GHS3DPlugin_Hypothesis; class SMDS_MeshNode; +class SMESH_Mesh; +class StdMeshers_ViscousLayers; class TCollection_AsciiString; class _Ghs2smdsConvertor; @@ -66,6 +66,7 @@ private: int _nbShape; bool _keepFiles; const GHS3DPlugin_Hypothesis* _hyp; + const StdMeshers_ViscousLayers* _viscousLayersHyp; }; /*!