From: eap Date: Thu, 3 Nov 2011 09:46:23 +0000 (+0000) Subject: 0021336: EDF 1717 SMESH: New algorithm "body fitting" cartesian unstructured X-Git-Tag: V6_4_0b1~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=adefda04042e7e85d93b9ad0e66230e6ea4483ef;p=modules%2Fsmesh.git 0021336: EDF 1717 SMESH: New algorithm "body fitting" cartesian unstructured --- diff --git a/doc/salome/gui/SMESH/images/cartesian3D_hyp.png b/doc/salome/gui/SMESH/images/cartesian3D_hyp.png new file mode 100644 index 000000000..b8373ed6d Binary files /dev/null and b/doc/salome/gui/SMESH/images/cartesian3D_hyp.png differ diff --git a/doc/salome/gui/SMESH/images/cartesian3D_sphere.png b/doc/salome/gui/SMESH/images/cartesian3D_sphere.png new file mode 100644 index 000000000..45bffdabe Binary files /dev/null and b/doc/salome/gui/SMESH/images/cartesian3D_sphere.png differ diff --git a/doc/salome/gui/SMESH/input/basic_meshing_algos.doc b/doc/salome/gui/SMESH/input/basic_meshing_algos.doc index 274ab7438..1047397b4 100644 --- a/doc/salome/gui/SMESH/input/basic_meshing_algos.doc +++ b/doc/salome/gui/SMESH/input/basic_meshing_algos.doc @@ -23,10 +23,8 @@ shape of a mesh. \image html image123.gif "Example of a triangular 2D mesh" @@ -36,10 +34,14 @@ are split into triangular and quadrangle elements.
  • For meshing of 3D entities (volume objects):
  • \image html image125.gif "Example of a tetrahedral 3D mesh" diff --git a/doc/salome/gui/SMESH/input/cartesian_algo.doc b/doc/salome/gui/SMESH/input/cartesian_algo.doc new file mode 100644 index 000000000..d093a57c1 --- /dev/null +++ b/doc/salome/gui/SMESH/input/cartesian_algo.doc @@ -0,0 +1,75 @@ +/*! + +\page cartesian_algo_page Body Fitting 3D meshing algorithm + +Body Fitting algorithm generates hexahedrones of a Cartesian grid in +the internal part of geometry and polyhedra and other types of +elements at intersection of Cartesian cells with the geometrical +boundary. + +\image html cartesian3D_sphere.png "A shpere meshed by Body Fitting algorithm" + +Algorithm of meshing is following. +
      +
    1. Lines of a Cartesian structured grid defined by +\ref cartesian_hyp_anchor "Body Fitting Parameters" hypothesis are +intersected with the geometry boundary, thus nodes laying on the +boundary are found. This step also allows finding out for each node of +the Cartesian grid if it is inside or outside the geometry.
    2. +
    3. For each cell of the grid, check how many of it's nodes are outside +of the geometry boundary. Depending on a result of this check +
        +
      • skip a cell, if all it's nodes are outside
      • +
      • skip a cell, if it is too small according to Size + Threshold paremeter
      • +
      • add a hexahedron in the mesh, if all nodes are inside
      • +
      • add a polyhedron or a cell of other type in the mesh, if some +nodes are inside and some outside
      • +
      +
    4. +
    +To apply this algorithm, when you define your mesh, select Body + Fitting in the list of 3D algorithms and click "Add + Hypothesis" button and "Body Fitting Parameters"" menu + item. Dialog of Body Fitting Parameters + hypothesis will appear. + +
    +\anchor cartesian_hyp_anchor +

    Body Fitting Parameters hypothesis

    + +\image html cartesian3D_hyp.png "Body Fitting Parameters hypothesis dialog" + +This dialog lets you define + + +
    +See Also a sample TUI Script of a +\ref tui_cartesian_algo "Usage of Body Fitting algorithm". + +*/ diff --git a/doc/salome/gui/SMESH/input/tui_cartesian_algo.doc b/doc/salome/gui/SMESH/input/tui_cartesian_algo.doc new file mode 100644 index 000000000..f1218439b --- /dev/null +++ b/doc/salome/gui/SMESH/input/tui_cartesian_algo.doc @@ -0,0 +1,49 @@ +/*! + +\page tui_cartesian_algo Usage of Body Fitting algorithm + +\code +from smesh import * +SetCurrentStudy(salome.myStudy) + +# create a sphere +sphere = geompy.MakeSphereR( 50 ) +geompy.addToStudy( sphere, "sphere" ) + +# create a mesh and assign a "Body Fitting" algo +mesh = Mesh( sphere ) +cartAlgo = mesh.BodyFitted() + +# define a cartesian grid using Coordinates +coords = range(-100,100,10) +cartHyp = cartAlgo.SetGrid( coords,coords,coords, 1000000) + +# compute the mesh +mesh.Compute() +print "nb hexahedra",mesh.NbHexas() +print "nb tetrahedra",mesh.NbTetras() +print "nb polyhedra",mesh.NbPolyhedrons() +print + +# define the grid by sitting constant spacing +cartHyp = cartAlgo.SetGrid( "10","10","10", 1000000) + +mesh.Compute() +print "nb hexahedra",mesh.NbHexas() +print "nb tetrahedra",mesh.NbTetras() +print "nb polyhedra",mesh.NbPolyhedrons() + + +# define the grid by sitting different spacing in 2 sub-ranges of geometry +spaceFuns = ["5","10+10*t"] +cartAlgo.SetGrid( [spaceFuns, [0.5]], [spaceFuns, [0.5]], [spaceFuns, [0.25]], 2 ) + +mesh.Compute() +print "nb hexahedra",mesh.NbHexas() +print "nb tetrahedra",mesh.NbTetras() +print "nb polyhedra",mesh.NbPolyhedrons() +print + +\endcode + +*/ diff --git a/src/SMESH_I/SMESH_2smeshpy.cxx b/src/SMESH_I/SMESH_2smeshpy.cxx index 96e6e422d..fd59f5c86 100644 --- a/src/SMESH_I/SMESH_2smeshpy.cxx +++ b/src/SMESH_I/SMESH_2smeshpy.cxx @@ -1665,6 +1665,16 @@ Handle(_pyHypothesis) _pyHypothesis::NewHypothesis( const Handle(_pyCommand)& th hyp = new _pyLayerDistributionHypo( theCreationCmd, "Get3DHypothesis" ); hyp->SetConvMethodAndType( "LayerDistribution", "RadialPrism_3D"); } + // Cartesian 3D --------- + else if ( hypType == "Cartesian_3D" ) { + algo->SetConvMethodAndType( "BodyFitted", hypType.ToCString()); + } + else if ( hypType == "CartesianParameters3D" ) { + hyp = new _pyComplexParamHypo( theCreationCmd ); + hyp->SetConvMethodAndType( "SetGrid", "Cartesian_3D"); + for ( int iArg = 0; iArg < 4; ++iArg ) + hyp->myArgs.Append("[]"); + } return algo->IsValid() ? algo : hyp; } @@ -1835,12 +1845,44 @@ void _pyHypothesis::Assign( const Handle(_pyHypothesis)& theOther, //================================================================================ /*! * \brief Remember hypothesis parameter values - * \param theCommand - The called hypothesis method + * \param theCommand - The called hypothesis method */ //================================================================================ void _pyComplexParamHypo::Process( const Handle(_pyCommand)& theCommand) { + if ( GetAlgoType() == "Cartesian_3D" ) + { + // CartesianParameters3D hyp + + if ( theCommand->GetMethod() == "SetSizeThreshold" ) + { + myArgs( 4 ) = theCommand->GetArg( 1 ); + myArgCommands.push_back( theCommand ); + return; + } + if ( theCommand->GetMethod() == "SetGrid" || + theCommand->GetMethod() == "SetGridSpacing" ) + { + TCollection_AsciiString axis = theCommand->GetArg( theCommand->GetNbArgs() ); + int iArg = 1 + ( axis.Value(1) - '0' ); + if ( theCommand->GetMethod() == "SetGrid" ) + { + myArgs( iArg ) = theCommand->GetArg( 1 ); + } + else + { + myArgs( iArg ) = "[ "; + myArgs( iArg ) += theCommand->GetArg( 1 ); + myArgs( iArg ) += ", "; + myArgs( iArg ) += theCommand->GetArg( 2 ); + myArgs( iArg ) += "]"; + } + myArgCommands.push_back( theCommand ); + return; + } + } + if( theCommand->GetMethod() == "SetLength" ) { // NOW it becomes OBSOLETE