]> SALOME platform Git repositories - tools/solverlab.git/commitdiff
Salome HOME
Added function getElementComponent in class Field
authormichael <michael@localhost.localdomain>
Fri, 5 Nov 2021 22:40:52 +0000 (23:40 +0100)
committermichael <michael@localhost.localdomain>
Fri, 5 Nov 2021 22:40:52 +0000 (23:40 +0100)
CDMATH/mesh/inc/Field.hxx
CDMATH/mesh/src/Field.cxx

index bc4ff85bd0166235838b39a0f60c467ff9e14659..542a68828597d9764bd0e6f49bf72ce216199ce1 100755 (executable)
@@ -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
index b7a4e94c363105167337b89efc0127702074a129..6887ea06d7aeb1cfd7d23b1a80602e92468605c0 100755 (executable)
@@ -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" <<endl;
+                                       throw CdmathException("Field::getElementComponent : Wrong component number");
+                       }
+               case NODES:
+                       switch( comp )
+                       {
+                               case 0:
+                                       return _mesh.getNode(i).x();
+                               case 1:
+                                       return _mesh.getNode(i).y();
+                               case 2:
+                                       return _mesh.getNode(i).z();
+                               default:
+                                       cout<<"Wrong component number "<< comp <<" , dimension is "<< _mesh.getSpaceDimension() << ", field values are on NODES" <<endl;
+                                       throw CdmathException("Field::getElementComponent : Wrong component number");
+                       }
+               case FACES:
+                       switch( comp )
+                       {
+                               case 0:
+                                       return _mesh.getFace(i).x();
+                               case 1:
+                                       return _mesh.getFace(i).y();
+                               case 2:
+                                       return _mesh.getFace(i).z();
+                               default:
+                                       cout<<"Wrong component number "<< comp <<" , dimension is "<< _mesh.getSpaceDimension() << ", field values are on FACES"<<endl;
+                                       throw CdmathException("Field::getElementComponent : Wrong component number");
+                       }
+               default:
+                       throw CdmathException("Accepted field supports are CELLS, NODES and FACES");
+       }
+       
+}
 //----------------------------------------------------------------------
 void
 Field::setName ( const string fieldName )