extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
extern med_geometry_type typmainoeud[1];
-using namespace ParaMEDMEM;
+using namespace MEDCoupling;
const char MEDFileMeshL2::ZE_SEP_FOR_FAMILY_KILLERS[]="!/__\\!";//important start by - because ord('!')==33 the smallest (!=' ') to preserve orders at most.
return std::vector<const BigMemoryObject *>();
}
-int MEDFileMeshL2::GetMeshIdFromName(med_idt fid, const std::string& mname, ParaMEDMEM::MEDCouplingMeshType& meshType, int& dt, int& it, std::string& dtunit1)
+int MEDFileMeshL2::GetMeshIdFromName(med_idt fid, const std::string& mname, MEDCoupling::MEDCouplingMeshType& meshType, MEDCoupling::MEDCouplingAxisType& axType, int& dt, int& it, std::string& dtunit1)
{
med_mesh_type type_maillage;
char maillage_description[MED_COMMENT_SIZE+1];
int naxis(MEDmeshnAxis(fid,i+1));
INTERP_KERNEL::AutoPtr<char> axisname=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
INTERP_KERNEL::AutoPtr<char> axisunit=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
- MEDFILESAFECALLERRD0(MEDmeshInfo,(fid,i+1,nommaa,&spaceDim,&dim,&type_maillage,maillage_description,dtunit,&stype,&nstep,&axistype,axisname,axisunit));
+ MEDFILESAFECALLERRD0(MEDmeshInfo,(fid,i+1,nommaa,&spaceDim,&dim,&type_maillage,maillage_description,dtunit,&stype,&nstep,&axistype,axisname,axisunit));
dtunit1=MEDLoaderBase::buildStringFromFortran(dtunit,sizeof(dtunit));
std::string cur=MEDLoaderBase::buildStringFromFortran(nommaa,sizeof(nommaa));
ms.push_back(cur);
std::copy(ms.begin(),ms.end(),std::ostream_iterator<std::string>(oss,", "));
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
+ axType=TraduceAxisType(axistype);
switch(type_maillage)
{
case MED_UNSTRUCTURED_MESH:
case MED_CURVILINEAR_GRID:
meshType=CURVE_LINEAR;
break;
+ case MED_POLAR_GRID:// this is not a bug. A MED file POLAR_GRID is deal by CARTESIAN MEDLoader
+ meshType=CARTESIAN;
+ break;
default:
- throw INTERP_KERNEL::Exception("MEDFileUMeshL2::getMeshIdFromName : unrecognized structured mesh type ! Supported are :\n - cartesian\n - curve linear\n");
+ throw INTERP_KERNEL::Exception("MEDFileMeshL2::getMeshIdFromName : unrecognized structured mesh type ! Supported are :\n - cartesian\n - curve linear\n");
}
break;
}
default:
- throw INTERP_KERNEL::Exception("MEDFileUMeshL2::getMeshIdFromName : unrecognized mesh type !");
+ throw INTERP_KERNEL::Exception("MEDFileMeshL2::getMeshIdFromName : unrecognized mesh type !");
}
med_int numdt,numit;
med_float dtt;
return dtt;
}
-std::vector<std::string> MEDFileMeshL2::getAxisInfoOnMesh(med_idt fid, int mId, const std::string& mName, ParaMEDMEM::MEDCouplingMeshType& meshType, int& nstep, int& Mdim)
+/*!
+ * non static and non const method because _description, _dt_unit... are set in this method.
+ */
+std::vector<std::string> MEDFileMeshL2::getAxisInfoOnMesh(med_idt fid, int mId, const std::string& mName, MEDCoupling::MEDCouplingMeshType& meshType, MEDCoupling::MEDCouplingAxisType& axType, int& nstep, int& Mdim)
{
med_mesh_type type_maillage;
med_int spaceDim;
&stype,&nstep,&axistype,axisname,axisunit)!=0)
throw INTERP_KERNEL::Exception("A problem has been detected when trying to get info on mesh !");
MEDmeshUniversalNameRd(fid,nameTmp,_univ_name.getPointer());// do not protect MEDFILESAFECALLERRD0 call : Thanks to fra.med.
+ axType=TraduceAxisType(axistype);
switch(type_maillage)
{
case MED_UNSTRUCTURED_MESH:
case MED_CURVILINEAR_GRID:
meshType=CURVE_LINEAR;
break;
+ case MED_POLAR_GRID:// this is not a bug. A MED file POLAR_GRID is deal by CARTESIAN MEDLoader
+ meshType=CARTESIAN;
+ break;
default:
- throw INTERP_KERNEL::Exception("MEDFileUMeshL2::getAxisInfoOnMesh : unrecognized structured mesh type ! Supported are :\n - cartesian\n - curve linear\n");
+ throw INTERP_KERNEL::Exception("MEDFileMeshL2::getAxisInfoOnMesh : unrecognized structured mesh type ! Supported are :\n - cartesian\n - curve linear\n");
}
break;
}
default:
- throw INTERP_KERNEL::Exception("MEDFileUMeshL2::getMeshIdFromName : unrecognized mesh type !");
+ throw INTERP_KERNEL::Exception("MEDFileMeshL2::getMeshIdFromName : unrecognized mesh type !");
}
//
std::vector<std::string> infosOnComp(naxis);
std::map<std::string,std::string>::iterator it1(zeMap.find(*it));
if(it1!=zeMap.end())
*it=(*it1).second;
- }
-
+ }
return true;
}
+MEDCoupling::MEDCouplingAxisType MEDFileMeshL2::TraduceAxisType(med_axis_type at)
+{
+ switch(at)
+ {
+ case MED_CARTESIAN:
+ return AX_CART;
+ case MED_CYLINDRICAL:
+ return AX_CYL;
+ case MED_SPHERICAL:
+ return AX_SPHER;
+ case MED_UNDEF_AXIS_TYPE:
+ return AX_CART;
+ default:
+ throw INTERP_KERNEL::Exception("MEDFileMeshL2::TraduceAxisType : unrecognized axis type !");
+ }
+}
+
+MEDCoupling::MEDCouplingAxisType MEDFileMeshL2::TraduceAxisTypeStruct(med_grid_type gt)
+{
+ switch(gt)
+ {
+ case MED_CARTESIAN_GRID:
+ return AX_CART;
+ case MED_POLAR_GRID:
+ return AX_CYL;
+ default:
+ throw INTERP_KERNEL::Exception("MEDFileMeshL2::TraduceAxisTypeStruct : only Cartesian and Cylindrical supported by MED file !");
+ }
+}
+
+med_axis_type MEDFileMeshL2::TraduceAxisTypeRev(MEDCoupling::MEDCouplingAxisType at)
+{
+ switch(at)
+ {
+ case AX_CART:
+ return MED_CARTESIAN;
+ case AX_CYL:
+ return MED_CYLINDRICAL;
+ case AX_SPHER:
+ return MED_SPHERICAL;
+ default:
+ throw INTERP_KERNEL::Exception("MEDFileMeshL2::TraduceAxisTypeRev : unrecognized axis type !");
+ }
+}
+
+med_grid_type MEDFileMeshL2::TraduceAxisTypeRevStruct(MEDCoupling::MEDCouplingAxisType at)
+{
+ switch(at)
+ {
+ case AX_CART:
+ return MED_CARTESIAN_GRID;
+ case AX_CYL:
+ return MED_POLAR_GRID;
+ case AX_SPHER:
+ return MED_POLAR_GRID;
+ default:
+ throw INTERP_KERNEL::Exception("MEDFileMeshL2::TraduceAxisTypeRevStruct : unrecognized axis type !");
+ }
+}
+
MEDFileUMeshL2::MEDFileUMeshL2()
{
}
Mdim=-3;
_name.set(mName.c_str());
int nstep;
- ParaMEDMEM::MEDCouplingMeshType meshType;
- std::vector<std::string> ret(getAxisInfoOnMesh(fid,mId,mName.c_str(),meshType,nstep,Mdim));
+ MEDCoupling::MEDCouplingMeshType meshType;
+ MEDCoupling::MEDCouplingAxisType dummy3;
+ std::vector<std::string> ret(getAxisInfoOnMesh(fid,mId,mName.c_str(),meshType,dummy3,nstep,Mdim));
if(nstep==0)
{
Mdim=-4;
return true;
}
-MEDFileCMeshL2::MEDFileCMeshL2()
+MEDFileCMeshL2::MEDFileCMeshL2():_ax_type(AX_CART)
{
}
_name.set(mName.c_str());
int nstep;
int Mdim;
- ParaMEDMEM::MEDCouplingMeshType meshType;
- std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName.c_str(),meshType,nstep,Mdim);
+ MEDCoupling::MEDCouplingMeshType meshType;
+ MEDCoupling::MEDCouplingAxisType dummy3;
+ std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName.c_str(),meshType,dummy3,nstep,Mdim);
if(meshType!=CARTESIAN)
throw INTERP_KERNEL::Exception("Invalid mesh type ! You are expected a structured one whereas in file it is not a structured !");
_time=CheckMeshTimeStep(fid,mName,nstep,dt,it);
//
med_grid_type gridtype;
MEDFILESAFECALLERRD0(MEDmeshGridTypeRd,(fid,mName.c_str(),&gridtype));
- if(gridtype!=MED_CARTESIAN_GRID)
- throw INTERP_KERNEL::Exception("Invalid structured mesh ! Expected cartesian mesh type !");
+ if(gridtype!=MED_CARTESIAN_GRID && gridtype!=MED_POLAR_GRID)
+ throw INTERP_KERNEL::Exception("Invalid rectilinear mesh ! Only cartesian and polar are supported !");
+ _ax_type=TraduceAxisTypeStruct(gridtype);
_cmesh=MEDCouplingCMesh::New();
for(int i=0;i<Mdim;i++)
{
_name.set(mName.c_str());
int nstep;
int Mdim;
- ParaMEDMEM::MEDCouplingMeshType meshType;
- std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName,meshType,nstep,Mdim);
+ MEDCoupling::MEDCouplingMeshType meshType;
+ MEDCoupling::MEDCouplingAxisType dummy3;
+ std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName,meshType,dummy3,nstep,Mdim);
if(meshType!=CURVE_LINEAR)
throw INTERP_KERNEL::Exception("Invalid mesh type ! You are expected a structured one whereas in file it is not a structured !");
_time=CheckMeshTimeStep(fid,mName,nstep,dt,it);
return ret;
}
+MEDFileUMeshSplitL1 *MEDFileUMeshSplitL1::shallowCpyUsingCoords(DataArrayDouble *coords) const
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> ret(new MEDFileUMeshSplitL1(*this));
+ ret->_m_by_types.shallowCpyMeshes();
+ ret->_m_by_types.setCoords(coords);
+ return ret.retn();
+}
+
MEDFileUMeshSplitL1 *MEDFileUMeshSplitL1::deepCpy(DataArrayDouble *coords) const
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> ret=new MEDFileUMeshSplitL1(*this);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> ret(new MEDFileUMeshSplitL1(*this));
ret->_m_by_types=_m_by_types.deepCpy(coords);
if((const DataArrayInt *)_fam)
ret->_fam=_fam->deepCpy();
_m=m;
_m_by_types.assignUMesh(dynamic_cast<MEDCouplingUMesh *>(m->deepCpy()));
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=_m_by_types.getUmesh()->getRenumArrForConsecutiveCellTypesSpec(typmai2,typmai2+MED_N_CELL_FIXED_GEO);
- if(!da->isIdentity())
+ if(!da->isIdentity2(m->getNumberOfCells()))
{
_num=da->invertArrayO2N2N2O(m->getNumberOfCells());
_m.updateTime();
const MEDCoupling1GTUMesh *elt(_m_parts[i]);
if(elt)
{
- ret._m_parts[i]=static_cast<ParaMEDMEM::MEDCoupling1GTUMesh*>(elt->deepCpy());
+ ret._m_parts[i]=static_cast<MEDCoupling::MEDCoupling1GTUMesh*>(elt->deepCpy());
ret._m_parts[i]->setCoords(coords);
}
}
ret._mp_time=_mp_time; ret._m_time=_m_time;
if((const MEDCouplingUMesh *)_m)
{
- ret._m=static_cast<ParaMEDMEM::MEDCouplingUMesh*>(_m->deepCpy());
+ ret._m=static_cast<MEDCoupling::MEDCouplingUMesh*>(_m->deepCpy());
ret._m->setCoords(coords);
}
std::size_t sz(_part_def.size());
return ret;
}
+void MEDFileUMeshAggregateCompute::shallowCpyMeshes()
+{
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::iterator it=_m_parts.begin();it!=_m_parts.end();it++)
+ {
+ const MEDCoupling1GTUMesh *elt(*it);
+ if(elt)
+ {
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> elt2(elt->clone(false));
+ *it=DynamicCastSafe<MEDCouplingMesh,MEDCoupling1GTUMesh>(elt2);
+ }
+ }
+ const MEDCouplingUMesh *m(_m);
+ if(m)
+ _m=m->clone(false);
+}
+
bool MEDFileUMeshAggregateCompute::isEqual(const MEDFileUMeshAggregateCompute& other, double eps, std::string& what) const
{
const MEDCouplingUMesh *m1(getUmesh());