X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=CDMATH%2Fmesh%2Fsrc%2FField.cxx;h=2997451a0cb087136bd9513ca7e9273dbecaba43;hb=258aed605783a5c801e860879cdd4190b407a7d3;hp=3252115340379bb654ac2d38b01a44df313cdd5f;hpb=d24ee6bdea4f04ca85a18b6860faa1affaaeb9d6;p=tools%2Fsolverlab.git diff --git a/CDMATH/mesh/src/Field.cxx b/CDMATH/mesh/src/Field.cxx index 3252115..2997451 100755 --- a/CDMATH/mesh/src/Field.cxx +++ b/CDMATH/mesh/src/Field.cxx @@ -30,7 +30,6 @@ Field::Field( EntityType typeField ) //---------------------------------------------------------------------- { _field=NULL; - _ff=NULL; _typeField=typeField; _numberOfComponents=0; } @@ -47,7 +46,6 @@ Field::~Field( void ) Field::Field(const std::string fieldName, EntityType type, const Mesh& mesh, int numberOfComponents, double time) { _field = NULL; - _ff=NULL; _mesh=Mesh(mesh); _typeField=type; _numberOfComponents=numberOfComponents; @@ -68,7 +66,7 @@ void Field::buildFieldMemoryStructure() }else if(_typeField==NODES) { _field=MEDCouplingFieldDouble::New(ON_NODES); - array->alloc(_mesh.getNumberOfNodes(),_numberOfComponents); + array->alloc(mu->getNumberOfNodes(),_numberOfComponents); _field->setMesh(mu); }else if(_typeField==FACES) { @@ -99,8 +97,6 @@ Field::Field( const std::string filename, EntityType type, int iteration, int order, int meshLevel) { _field = NULL; - _ff=NULL; - _mesh=Mesh(filename + ".med", meshLevel); _typeField=type; _fieldName=fieldName; @@ -108,11 +104,10 @@ Field::Field( const std::string filename, EntityType type, } Field::Field(const std::string meshFileName, EntityType type, const std::vector Vconstant, - const std::string & fieldName, int meshLevel, double time ) + const std::string & fieldName, int meshLevel, double time, std::string meshName ) { _field = NULL; - _ff=NULL; - _mesh=Mesh(meshFileName + ".med", meshLevel); + _mesh=Mesh(meshFileName + ".med", meshName, meshLevel); _typeField=type; _numberOfComponents=Vconstant.size(); _time=time; @@ -130,7 +125,6 @@ Field::Field(const std::string meshFileName, EntityType type, const std::vector< Field::Field(const Mesh& M, EntityType type, const Vector Vconstant, const std::string & fieldName, double time) { _field = NULL; - _ff=NULL; _mesh=Mesh(M); _typeField=type; _numberOfComponents=Vconstant.size(); @@ -149,7 +143,6 @@ Field::Field(const Mesh& M, EntityType type, const Vector Vconstant, const std:: Field::Field(const Mesh& M, EntityType type, const vector Vconstant, const std::string & fieldName, double time) { _field = NULL; - _ff=NULL; _mesh=Mesh(M); _typeField=type; _numberOfComponents=Vconstant.size(); @@ -172,7 +165,6 @@ Field::Field( int nDim, const vector Vconstant, EntityType type, const std::string & fieldName, double time,double epsilon) { _field = NULL; - _ff=NULL; _typeField=type; _numberOfComponents=Vconstant.size(); _time=time; @@ -219,7 +211,6 @@ Field::Field(const Mesh M, const Vector VV_Left, const Vector VV_Right, double d throw CdmathException( "Field::Field: Vectors VV_Left and VV_Right have different sizes"); _field = NULL; - _ff=NULL; _mesh=Mesh(M); _typeField=type; _numberOfComponents=VV_Left.getNumberOfRows(); @@ -297,7 +288,6 @@ Field::Field(const Mesh M, const Vector Vin, const Vector Vout, double radius, } _field = NULL; - _ff=NULL; _mesh=Mesh(M); _typeField=type; _numberOfComponents=Vout.size(); @@ -350,7 +340,6 @@ Field::readFieldMed( const std::string & fileNameRadical, size_t iField = 0; std::string attributedFieldName; _field = NULL; - _ff=NULL; // Get the name of the right field that we will attribute to the Field. if (fieldName == "") { @@ -430,7 +419,8 @@ Field::readFieldMed( const std::string & fileNameRadical, _numberOfComponents = _field->getNumberOfComponents() ; _time = _field->getTime(iteration, order); - cout<<"Found field " << fieldName << " in file " << completeFileName <getMesh()->getName()<< endl; + _mesh=Mesh( completeFileName, _field->getMesh()->getName()); } @@ -992,9 +982,6 @@ void Field::writeVTK (std::string fileName, bool fromScratch) const //---------------------------------------------------------------------- { - if( !_mesh.isStructured() && !_mesh.meshNotDeleted() ) - throw CdmathException("Field::writeVTK : Cannot save field in VTK format : unstructured mesh with no MEDCouplingUMesh loaded. Use med format."); - string fname=fileName+".pvd"; int iter,order; double time=_field->getTime(iter,order); @@ -1128,7 +1115,7 @@ Field::writeCSV ( const std::string fileName ) const //---------------------------------------------------------------------- void -Field::writeMED ( const std::string fileName, bool fromScratch) const +Field::writeMED ( const std::string fileName, bool fromScratch) //---------------------------------------------------------------------- { string fname=fileName+".med"; @@ -1138,20 +1125,16 @@ Field::writeMED ( const std::string fileName, bool fromScratch) const MEDCoupling::WriteField(fname.c_str(),_field,fromScratch); else MEDCoupling::WriteFieldUsingAlreadyWrittenMesh(fname.c_str(),_field); - else//The mesh has ben deleted, use _ff instead of _field to save the values + else//The mesh has ben deleted, use a MEDFileField1TS instead of _field to save the values { - //MEDFileUMesh * meshMEDFile = MEDFileUMesh::New(); - //meshMEDFile->setMeshAtLevel(0,_field->getMesh()->buildUnstructured()); - //meshMEDFile->write(fname.c_str(), fromScratch); - //MEDCoupling::WriteUMesh(fname.c_str(),_field->getMesh()->buildUnstructured(),fromScratch); - //MEDCoupling::WriteMesh(fname.c_str(),_field->getMesh(),fromScratch); - //MEDCoupling::MEDCouplingUMesh* fmesh = dynamic_cast (_field->getMesh()->deepCopy()); - //cout<<" checkConsecutiveCellTypes : "<< fmesh->checkConsecutiveCellTypes() <advancedRepr() <getMesh()->buildUnstructured()->checkConsecutiveCellTypes()<setFieldNoProfileSBT( _field ); - _ff->write(fname.c_str(), fromScratch); + if ( not fromScratch) + { + MEDCoupling::MCAuto ff=MEDFileField1TS::New();//To save the field when the mesh has been deleted + ff->setFieldNoProfileSBT( _field ); + ff->write(fname.c_str(), fromScratch); + } + else + throw CdmathException("Field::writeMED Error !!! The mesh has been deleted, cannot write field from scratch"); } } @@ -1224,7 +1207,7 @@ std::ostream& operator<<(std::ostream& out, const Field& field ) return out; } -void Field::deleteMEDCouplingUMesh() +void Field::deleteMEDCouplingMesh() { - return _mesh.deleteMEDCouplingUMesh(); + return _mesh.deleteMEDCouplingMesh(); }