//----------------------------------------------------------------------
{
_field=NULL;
- _ff=NULL;
_typeField=typeField;
_numberOfComponents=0;
}
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;
}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)
{
int iteration, int order, int meshLevel)
{
_field = NULL;
- _ff=NULL;
- _mesh=Mesh(filename + ".med", meshLevel);
_typeField=type;
_fieldName=fieldName;
}
Field::Field(const std::string meshFileName, EntityType type, const std::vector<double> 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;
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();
Field::Field(const Mesh& M, EntityType type, const vector<double> Vconstant, const std::string & fieldName, double time)
{
_field = NULL;
- _ff=NULL;
_mesh=Mesh(M);
_typeField=type;
_numberOfComponents=Vconstant.size();
const std::string & fieldName, double time,double epsilon)
{
_field = NULL;
- _ff=NULL;
_typeField=type;
_numberOfComponents=Vconstant.size();
_time=time;
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();
}
_field = NULL;
- _ff=NULL;
_mesh=Mesh(M);
_typeField=type;
_numberOfComponents=Vout.size();
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 == "") {
_numberOfComponents = _field->getNumberOfComponents() ;
_time = _field->getTime(iteration, order);
- cout<<"Found field " << fieldName << " in file " << completeFileName <<endl;
+ cout<<"Found field " << fieldName << " in file " << completeFileName << " on mesh named "<< _field->getMesh()->getName()<< endl;
+ _mesh=Mesh( completeFileName, _field->getMesh()->getName());
}
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);
//----------------------------------------------------------------------
void
-Field::writeMED ( const std::string fileName, bool fromScratch) const
+Field::writeMED ( const std::string fileName, bool fromScratch)
//----------------------------------------------------------------------
{
string fname=fileName+".med";
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<MEDCoupling::MEDCouplingUMesh*> (_field->getMesh()->deepCopy());
- //cout<<" checkConsecutiveCellTypes : "<< fmesh->checkConsecutiveCellTypes() <<endl;
- //cout<<" advancedRepr() : "<< fmesh->advancedRepr() <<endl;
- //cout<<" checkConsecutiveCellTypes : "<< _field->getMesh()->buildUnstructured()->checkConsecutiveCellTypes()<<endl;
- MEDFileField1TS *ff=MEDFileField1TS::New();
- _ff->setFieldNoProfileSBT( _field );
- _ff->write(fname.c_str(), fromScratch);
+ if ( not fromScratch)
+ {
+ MEDCoupling::MCAuto<MEDCoupling::MEDFileField1TS> 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");
}
}
return out;
}
-void Field::deleteMEDCouplingUMesh()
+void Field::deleteMEDCouplingMesh()
{
- return _mesh.deleteMEDCouplingUMesh();
+ return _mesh.deleteMEDCouplingMesh();
}