Back to index

salome-smesh  6.5.0
Public Member Functions | Private Attributes
VISCOUS::_Shrinker1D Class Reference

Shrinker of nodes on the EDGE. More...

Collaboration diagram for VISCOUS::_Shrinker1D:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void AddEdge (const _LayerEdge *e, SMESH_MesherHelper &helper)
 Add a _LayerEdge inflated along the EDGE.
void Compute (bool set3D, SMESH_MesherHelper &helper)
 Move nodes on EDGE from ends where _LayerEdge's are inflated.
void RestoreParams ()
 Restore initial parameters of nodes on EDGE.
void SwapSrcTgtNodes (SMESHDS_Mesh *mesh)
 Replace source nodes by target nodes in shrinked mesh edges.

Private Attributes

vector< double > _initU
vector< double > _normPar
vector< const SMDS_MeshNode * > _nodes
const _LayerEdge_edges [2]
bool _done

Detailed Description

Shrinker of nodes on the EDGE.

Definition at line 502 of file StdMeshers_ViscousLayers.cxx.


Member Function Documentation

void _Shrinker1D::AddEdge ( const _LayerEdge e,
SMESH_MesherHelper &  helper 
)

Add a _LayerEdge inflated along the EDGE.

Definition at line 4190 of file StdMeshers_ViscousLayers.cxx.

{
  // init
  if ( _nodes.empty() )
  {
    _edges[0] = _edges[1] = 0;
    _done = false;
  }
  // check _LayerEdge
  if ( e == _edges[0] || e == _edges[1] )
    return;
  if ( e->_sWOL.IsNull() || e->_sWOL.ShapeType() != TopAbs_EDGE )
    throw SALOME_Exception(LOCALIZED("Wrong _LayerEdge is added"));
  if ( _edges[0] && _edges[0]->_sWOL != e->_sWOL )
    throw SALOME_Exception(LOCALIZED("Wrong _LayerEdge is added"));

  // store _LayerEdge
  const TopoDS_Edge& E = TopoDS::Edge( e->_sWOL );
  double f,l;
  BRep_Tool::Range( E, f,l );
  double u = helper.GetNodeU( E, e->_nodes[0], e->_nodes.back());
  _edges[ u < 0.5*(f+l) ? 0 : 1 ] = e;

  // Update _nodes

  const SMDS_MeshNode* tgtNode0 = _edges[0] ? _edges[0]->_nodes.back() : 0;
  const SMDS_MeshNode* tgtNode1 = _edges[1] ? _edges[1]->_nodes.back() : 0;

  if ( _nodes.empty() )
  {
    SMESHDS_SubMesh * eSubMesh = helper.GetMeshDS()->MeshElements( E );
    if ( !eSubMesh || eSubMesh->NbNodes() < 1 )
      return;
    TopLoc_Location loc;
    Handle(Geom_Curve) C = BRep_Tool::Curve(E, loc, f,l);
    GeomAdaptor_Curve aCurve(C, f,l);
    const double totLen = GCPnts_AbscissaPoint::Length(aCurve, f, l);

    int nbExpectNodes = eSubMesh->NbNodes() - e->_nodes.size();
    _initU  .reserve( nbExpectNodes );
    _normPar.reserve( nbExpectNodes );
    _nodes  .reserve( nbExpectNodes );
    SMDS_NodeIteratorPtr nIt = eSubMesh->GetNodes();
    while ( nIt->more() )
    {
      const SMDS_MeshNode* node = nIt->next();
      if ( node->NbInverseElements(SMDSAbs_Edge) == 0 ||
           node == tgtNode0 || node == tgtNode1 )
        continue; // refinement nodes
      _nodes.push_back( node );
      _initU.push_back( helper.GetNodeU( E, node ));
      double len = GCPnts_AbscissaPoint::Length(aCurve, f, _initU.back());
      _normPar.push_back(  len / totLen );
    }
  }
  else
  {
    // remove target node of the _LayerEdge from _nodes
    int nbFound = 0;
    for ( unsigned i = 0; i < _nodes.size(); ++i )
      if ( !_nodes[i] || _nodes[i] == tgtNode0 || _nodes[i] == tgtNode1 )
        _nodes[i] = 0, nbFound++;
    if ( nbFound == _nodes.size() )
      _nodes.clear();
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void _Shrinker1D::Compute ( bool  set3D,
SMESH_MesherHelper &  helper 
)

Move nodes on EDGE from ends where _LayerEdge's are inflated.

Definition at line 4263 of file StdMeshers_ViscousLayers.cxx.

{
  if ( _done || _nodes.empty())
    return;
  const _LayerEdge* e = _edges[0];
  if ( !e ) e = _edges[1];
  if ( !e ) return;

  _done =  (( !_edges[0] || _edges[0]->_pos.empty() ) &&
            ( !_edges[1] || _edges[1]->_pos.empty() ));

  const TopoDS_Edge& E = TopoDS::Edge( e->_sWOL );
  double f,l;
  if ( set3D || _done )
  {
    Handle(Geom_Curve) C = BRep_Tool::Curve(E, f,l);
    GeomAdaptor_Curve aCurve(C, f,l);

    if ( _edges[0] )
      f = helper.GetNodeU( E, _edges[0]->_nodes.back(), _nodes[0] );
    if ( _edges[1] )
      l = helper.GetNodeU( E, _edges[1]->_nodes.back(), _nodes.back() );
    double totLen = GCPnts_AbscissaPoint::Length( aCurve, f, l );

    for ( unsigned i = 0; i < _nodes.size(); ++i )
    {
      if ( !_nodes[i] ) continue;
      double len = totLen * _normPar[i];
      GCPnts_AbscissaPoint discret( aCurve, len, f );
      if ( !discret.IsDone() )
        return throw SALOME_Exception(LOCALIZED("GCPnts_AbscissaPoint failed"));
      double u = discret.Parameter();
      SMDS_EdgePosition* pos = static_cast<SMDS_EdgePosition*>( _nodes[i]->GetPosition() );
      pos->SetUParameter( u );
      gp_Pnt p = C->Value( u );
      const_cast< SMDS_MeshNode*>( _nodes[i] )->setXYZ( p.X(), p.Y(), p.Z() );
    }
  }
  else
  {
    BRep_Tool::Range( E, f,l );
    if ( _edges[0] )
      f = helper.GetNodeU( E, _edges[0]->_nodes.back(), _nodes[0] );
    if ( _edges[1] )
      l = helper.GetNodeU( E, _edges[1]->_nodes.back(), _nodes.back() );
    
    for ( unsigned i = 0; i < _nodes.size(); ++i )
    {
      if ( !_nodes[i] ) continue;
      double u = f * ( 1-_normPar[i] ) + l * _normPar[i];
      SMDS_EdgePosition* pos = static_cast<SMDS_EdgePosition*>( _nodes[i]->GetPosition() );
      pos->SetUParameter( u );
    }
  }
}

Here is the call graph for this function:

Restore initial parameters of nodes on EDGE.

Definition at line 4325 of file StdMeshers_ViscousLayers.cxx.

{
  if ( _done )
    for ( unsigned i = 0; i < _nodes.size(); ++i )
    {
      if ( !_nodes[i] ) continue;
      SMDS_EdgePosition* pos = static_cast<SMDS_EdgePosition*>( _nodes[i]->GetPosition() );
      pos->SetUParameter( _initU[i] );
    }
  _done = false;
}

Here is the caller graph for this function:

void _Shrinker1D::SwapSrcTgtNodes ( SMESHDS_Mesh *  mesh)

Replace source nodes by target nodes in shrinked mesh edges.

Definition at line 4343 of file StdMeshers_ViscousLayers.cxx.

{
  const SMDS_MeshNode* nodes[3];
  for ( int i = 0; i < 2; ++i )
  {
    if ( !_edges[i] ) continue;

    SMESHDS_SubMesh * eSubMesh = mesh->MeshElements( _edges[i]->_sWOL );
    if ( !eSubMesh ) return;
    const SMDS_MeshNode* srcNode = _edges[i]->_nodes[0];
    const SMDS_MeshNode* tgtNode = _edges[i]->_nodes.back();
    SMDS_ElemIteratorPtr eIt = srcNode->GetInverseElementIterator(SMDSAbs_Edge);
    while ( eIt->more() )
    {
      const SMDS_MeshElement* e = eIt->next();
      if ( !eSubMesh->Contains( e ))
          continue;
      SMDS_ElemIteratorPtr nIt = e->nodesIterator();
      for ( int iN = 0; iN < e->NbNodes(); ++iN )
      {
        const SMDS_MeshNode* n = static_cast<const SMDS_MeshNode*>( nIt->next() );
        nodes[iN] = ( n == srcNode ? tgtNode : n );
      }
      mesh->ChangeElementNodes( e, nodes, e->NbNodes() );
    }
  }
}

Member Data Documentation

Definition at line 508 of file StdMeshers_ViscousLayers.cxx.

Definition at line 507 of file StdMeshers_ViscousLayers.cxx.

vector<double> VISCOUS::_Shrinker1D::_initU [private]

Definition at line 504 of file StdMeshers_ViscousLayers.cxx.

vector<const SMDS_MeshNode*> VISCOUS::_Shrinker1D::_nodes [private]

Definition at line 506 of file StdMeshers_ViscousLayers.cxx.

vector<double> VISCOUS::_Shrinker1D::_normPar [private]

Definition at line 505 of file StdMeshers_ViscousLayers.cxx.


The documentation for this class was generated from the following file: