From: michael Date: Fri, 5 Nov 2021 22:40:52 +0000 (+0100) Subject: Added function getElementComponent in class Field X-Git-Tag: V9_8_0~47 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f1e9a090389a41fe09340284fe09515122e56f45;p=tools%2Fsolverlab.git Added function getElementComponent in class Field --- diff --git a/CDMATH/mesh/inc/Field.hxx b/CDMATH/mesh/inc/Field.hxx index bc4ff85..542a688 100755 --- a/CDMATH/mesh/inc/Field.hxx +++ b/CDMATH/mesh/inc/Field.hxx @@ -239,6 +239,8 @@ class Field EntityType getTypeOfField ( void ) const ; + // returns the x, y or z component of the element (node cell or face) with number i + double getElementComponent(int i, int comp) const; /** * return the MEDCouplingField pointer * return _field diff --git a/CDMATH/mesh/src/Field.cxx b/CDMATH/mesh/src/Field.cxx index b7a4e94..6887ea0 100755 --- a/CDMATH/mesh/src/Field.cxx +++ b/CDMATH/mesh/src/Field.cxx @@ -741,6 +741,55 @@ Field::getTypeOfField ( void ) const return _typeField; } +double +Field::getElementComponent(int i, int comp) const +{ + switch( _typeField ) + { + case CELLS: + switch( comp ) + { + case 0: + return _mesh.getCell(i).x(); + case 1: + return _mesh.getCell(i).y(); + case 2: + return _mesh.getCell(i).z(); + default: + cout<<"Wrong component number "<< comp <<" , dimension is "<< _mesh.getSpaceDimension() << ", field values are on CELLS" <