Back to index

salome-med  6.5.0
Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes
ParaMEDMEM::MEDFileUMeshL2 Class Reference

#include <MEDFileMeshLL.hxx>

Inheritance diagram for ParaMEDMEM::MEDFileUMeshL2:
Inheritance graph
[legend]
Collaboration diagram for ParaMEDMEM::MEDFileUMeshL2:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 MEDFileUMeshL2 ()
void loadAll (med_idt fid, int mId, const char *mName, int dt, int it)
void loadConnectivity (med_idt fid, int mdim, const char *mName, int dt, int it)
void loadCoords (med_idt fid, int mId, const std::vector< std::string > &infosOnComp, const char *mName, int dt, int it) throw (INTERP_KERNEL::Exception)
int getNumberOfLevels () const
bool emptyLev (int levId) const
const std::vector
< MEDCouplingAutoRefCountObjectPtr
< MEDFileUMeshPerType > > & 
getLev (int levId) const
bool isFamDefinedOnLev (int levId) const
bool isNumDefinedOnLev (int levId) const
MEDCouplingAutoRefCountObjectPtr
< DataArrayDouble
getCoords () const
MEDCouplingAutoRefCountObjectPtr
< DataArrayInt
getCoordsFamily () const
MEDCouplingAutoRefCountObjectPtr
< DataArrayInt
getCoordsNum () const
const char * getName () const
const char * getDescription () const
const char * getTimeUnit () const
int getIteration () const
int getOrder () const
double getTime ()
std::vector< std::string > getAxisInfoOnMesh (med_idt fid, int mId, const char *mName, ParaMEDMEM::MEDCouplingMeshType &meshType, int &nstep, int &Mdim) throw (INTERP_KERNEL::Exception)
def incrRef
def getHiddenCppPointer

Static Public Member Functions

static void WriteCoords (med_idt fid, const char *mname, int dt, int it, double time, const DataArrayDouble *coords, const DataArrayInt *famCoords, const DataArrayInt *numCoords)
static int GetMeshIdFromName (med_idt fid, const char *mName, ParaMEDMEM::MEDCouplingMeshType &meshType, int &dt, int &it, std::string &dtunit1) throw (INTERP_KERNEL::Exception)
static double CheckMeshTimeStep (med_idt fid, const char *mname, int nstep, int dt, int it) throw (INTERP_KERNEL::Exception)
static void ReadFamiliesAndGrps (med_idt fid, const char *mname, std::map< std::string, int > &fams, std::map< std::string, std::vector< std::string > > &grps)
static void WriteFamiliesAndGrps (med_idt fid, const char *mname, const std::map< std::string, int > &fams, const std::map< std::string, std::vector< std::string > > &grps, int tooLongStrPol)

Protected Attributes

MEDFileString _name
MEDFileString _description
MEDFileString _dt_unit
int _iteration
int _order
double _time

Private Member Functions

void sortTypes ()

Private Attributes

std::vector< std::vector
< MEDCouplingAutoRefCountObjectPtr
< MEDFileUMeshPerType > > > 
_per_type_mesh
MEDCouplingAutoRefCountObjectPtr
< DataArrayDouble
_coords
MEDCouplingAutoRefCountObjectPtr
< DataArrayInt
_fam_coords
MEDCouplingAutoRefCountObjectPtr
< DataArrayInt
_num_coords

Detailed Description

Definition at line 60 of file MEDFileMeshLL.hxx.


Constructor & Destructor Documentation

Definition at line 198 of file MEDFileMeshLL.cxx.

{
}

Member Function Documentation

double MEDFileMeshL2::CheckMeshTimeStep ( med_idt  fid,
const char *  mname,
int  nstep,
int  dt,
int  it 
) throw (INTERP_KERNEL::Exception) [static, inherited]

Definition at line 95 of file MEDFileMeshLL.cxx.

{
  bool found=false;
  med_int numdt,numit;
  med_float dtt;
  std::vector< std::pair<int,int> > p(nstep);
  for(int i=0;i<nstep;i++)
    {
      MEDmeshComputationStepInfo(fid,mName,i+1,&numdt,&numit,&dtt);
      p[i]=std::make_pair<int,int>(numdt,numit);
      found=(numdt==dt) && (numit==numit);
    }
  if(!found)
    {
      std::ostringstream oss; oss << "No such iteration=" << dt << ",order=" << it << " numbers found for mesh '" << mName << "' ! ";
      oss << "Possibilities are : ";
      for(int i=0;i<nstep;i++)
        oss << "(" << p[i].first << "," << p[i].second << "), ";
      throw INTERP_KERNEL::Exception(oss.str().c_str());
    }
  return dtt;
}

Here is the caller graph for this function:

bool ParaMEDMEM::MEDFileUMeshL2::emptyLev ( int  levId) const [inline]

Definition at line 68 of file MEDFileMeshLL.hxx.

{ return _per_type_mesh[levId].empty(); }
std::vector< std::string > MEDFileMeshL2::getAxisInfoOnMesh ( med_idt  fid,
int  mId,
const char *  mName,
ParaMEDMEM::MEDCouplingMeshType meshType,
int &  nstep,
int &  Mdim 
) throw (INTERP_KERNEL::Exception) [inherited]

Definition at line 118 of file MEDFileMeshLL.cxx.

{
  med_mesh_type type_maillage;
  med_int spaceDim;
  med_sorting_type stype;
  med_axis_type axistype;
  int naxis=MEDmeshnAxis(fid,mId);
  INTERP_KERNEL::AutoPtr<char> nameTmp=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
  INTERP_KERNEL::AutoPtr<char> axisname=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
  INTERP_KERNEL::AutoPtr<char> axisunit=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
  if(MEDmeshInfo(fid,mId,nameTmp,&spaceDim,&Mdim,&type_maillage,_description.getPointer(),_dt_unit.getPointer(),
                 &stype,&nstep,&axistype,axisname,axisunit)!=0)
    throw INTERP_KERNEL::Exception("A problem has been detected when trying to get info on mesh !");
  switch(type_maillage)
    {
    case MED_UNSTRUCTURED_MESH:
      meshType=UNSTRUCTURED;
      break;
    case MED_STRUCTURED_MESH:
      meshType=CARTESIAN;
      break;
    default:
      throw INTERP_KERNEL::Exception("MEDFileUMeshL2::getMeshIdFromName : unrecognized mesh type !");
    }
  //
  std::vector<std::string> infosOnComp(naxis);
  for(int i=0;i<naxis;i++)
    {
      std::string info=MEDLoaderBase::buildUnionUnit(((char *)axisname)+i*MED_SNAME_SIZE,MED_SNAME_SIZE,((char *)axisunit)+i*MED_SNAME_SIZE,MED_SNAME_SIZE);
      infosOnComp[i]=info;
    }
  return infosOnComp;
}

Here is the caller graph for this function:

Definition at line 72 of file MEDFileMeshLL.hxx.

{ return _coords; }

Here is the caller graph for this function:

Definition at line 73 of file MEDFileMeshLL.hxx.

{ return _fam_coords; }

Definition at line 74 of file MEDFileMeshLL.hxx.

{ return _num_coords; }
const char* ParaMEDMEM::MEDFileMeshL2::getDescription ( ) const [inline, inherited]

Definition at line 41 of file MEDFileMeshLL.hxx.

Here is the call graph for this function:

getHiddenCppPointer(self) -> string

1

Definition at line 345 of file ParaMEDMEM.py.

00345 
00346     def getHiddenCppPointer(self):
00347         """
00348         getHiddenCppPointer(self) -> string
00349 
00350         1
00351         """
00352         return _ParaMEDMEM.RefCountObject_getHiddenCppPointer(self)

int ParaMEDMEM::MEDFileMeshL2::getIteration ( ) const [inline, inherited]

Definition at line 43 of file MEDFileMeshLL.hxx.

{ return _iteration; }
const std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >& ParaMEDMEM::MEDFileUMeshL2::getLev ( int  levId) const [inline]

Definition at line 69 of file MEDFileMeshLL.hxx.

{ return _per_type_mesh[levId]; }

Here is the caller graph for this function:

int MEDFileMeshL2::GetMeshIdFromName ( med_idt  fid,
const char *  mName,
ParaMEDMEM::MEDCouplingMeshType meshType,
int &  dt,
int &  it,
std::string &  dtunit1 
) throw (INTERP_KERNEL::Exception) [static, inherited]

Definition at line 41 of file MEDFileMeshLL.cxx.

{
  med_mesh_type type_maillage;
  char maillage_description[MED_COMMENT_SIZE+1];
  char dtunit[MED_LNAME_SIZE+1];
  med_int spaceDim,dim;
  char nommaa[MED_NAME_SIZE+1];
  med_int n=MEDnMesh(fid);
  bool found=false;
  int ret=-1;
  med_sorting_type stype;
  std::vector<std::string> ms;
  int nstep;
  med_axis_type axistype;
  for(int i=0;i<n && !found;i++)
    {
      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);
      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);
      if(cur==mname)
        {
          found=true;
          ret=i+1;
        }
    }
  if(!found)
    {
      std::ostringstream oss;
      oss << "No such meshname (" << mname <<  ") in file ! Must be in :";
      std::copy(ms.begin(),ms.end(),std::ostream_iterator<std::string>(oss,", "));
      throw INTERP_KERNEL::Exception(oss.str().c_str());
    }
  switch(type_maillage)
    {
    case MED_UNSTRUCTURED_MESH:
      meshType=UNSTRUCTURED;
      break;
    case MED_STRUCTURED_MESH:
      meshType=CARTESIAN;
      break;
    default:
      throw INTERP_KERNEL::Exception("MEDFileUMeshL2::getMeshIdFromName : unrecognized mesh type !");
    }
  med_int numdt,numit;
  med_float dtt;
  MEDmeshComputationStepInfo(fid,mname,1,&numdt,&numit,&dtt);
  dt=numdt; it=numit;
  return ret;
}
const char* ParaMEDMEM::MEDFileMeshL2::getName ( ) const [inline, inherited]

Definition at line 40 of file MEDFileMeshLL.hxx.

{ return _name.getReprForWrite(); }

Here is the call graph for this function:

Definition at line 67 of file MEDFileMeshLL.hxx.

{ return _per_type_mesh.size(); }
int ParaMEDMEM::MEDFileMeshL2::getOrder ( ) const [inline, inherited]

Definition at line 44 of file MEDFileMeshLL.hxx.

{ return _order; }
double ParaMEDMEM::MEDFileMeshL2::getTime ( ) [inline, inherited]

Definition at line 45 of file MEDFileMeshLL.hxx.

{ return _time; }
const char* ParaMEDMEM::MEDFileMeshL2::getTimeUnit ( ) const [inline, inherited]

Definition at line 42 of file MEDFileMeshLL.hxx.

{ return _dt_unit.getReprForWrite(); }

Here is the call graph for this function:

def ParaMEDMEM.RefCountObject.incrRef (   self) [inherited]
incrRef(self)

1

Definition at line 337 of file ParaMEDMEM.py.

00337 
00338     def incrRef(self):
00339         """
00340         incrRef(self)
00341 
00342         1
00343         """
00344         return _ParaMEDMEM.RefCountObject_incrRef(self)

bool MEDFileUMeshL2::isFamDefinedOnLev ( int  levId) const

Definition at line 300 of file MEDFileMeshLL.cxx.

{
  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=_per_type_mesh[levId].begin();it!=_per_type_mesh[levId].end();it++)
    if((*it)->getFam()==0)
      return false;
  return true;
}

Here is the caller graph for this function:

bool MEDFileUMeshL2::isNumDefinedOnLev ( int  levId) const

Definition at line 308 of file MEDFileMeshLL.cxx.

{
  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=_per_type_mesh[levId].begin();it!=_per_type_mesh[levId].end();it++)
    if((*it)->getNum()==0)
      return false;
  return true;
}

Here is the caller graph for this function:

void MEDFileUMeshL2::loadAll ( med_idt  fid,
int  mId,
const char *  mName,
int  dt,
int  it 
)

Definition at line 202 of file MEDFileMeshLL.cxx.

{
  _name.set(mName);
  int nstep;
  int Mdim;
  ParaMEDMEM::MEDCouplingMeshType meshType;
  std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName,meshType,nstep,Mdim);
  if(meshType!=UNSTRUCTURED)
    throw INTERP_KERNEL::Exception("Invalid mesh type ! You are expected an unstructured one whereas in file it is not an unstructured !");
  _time=CheckMeshTimeStep(fid,mName,nstep,dt,it);
  _iteration=dt;
  _order=it;
  loadConnectivity(fid,Mdim,mName,dt,it);//to improve check (dt,it) coherency
  loadCoords(fid,mId,infosOnComp,mName,dt,it);
}

Here is the call graph for this function:

void MEDFileUMeshL2::loadConnectivity ( med_idt  fid,
int  mdim,
const char *  mName,
int  dt,
int  it 
)

Definition at line 218 of file MEDFileMeshLL.cxx.

{
  _per_type_mesh.resize(1);
  _per_type_mesh[0].clear();
  for(int j=0;j<MED_N_CELL_FIXED_GEO;j++)
    {
      MEDFileUMeshPerType *tmp=MEDFileUMeshPerType::New(fid,mName,dt,it,mdim,typmai[j],typmai2[j]);
      if(tmp)
        _per_type_mesh[0].push_back(tmp);
    }
  sortTypes();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void MEDFileUMeshL2::loadCoords ( med_idt  fid,
int  mId,
const std::vector< std::string > &  infosOnComp,
const char *  mName,
int  dt,
int  it 
) throw (INTERP_KERNEL::Exception)

Definition at line 231 of file MEDFileMeshLL.cxx.

{
  int spaceDim=infosOnComp.size();
  med_bool changement,transformation;
  int nCoords=MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&changement,&transformation);
  _coords=DataArrayDouble::New();
  _coords->alloc(nCoords,spaceDim);
  double *coordsPtr=_coords->getPointer();
  MEDmeshNodeCoordinateRd(fid,mName,dt,it,MED_FULL_INTERLACE,coordsPtr);
  _fam_coords=DataArrayInt::New();
  _fam_coords->alloc(nCoords,1);
  _num_coords=DataArrayInt::New();
  _num_coords->alloc(nCoords,1);
  if(MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,MED_FAMILY_NUMBER,MED_NODAL,&changement,&transformation)>0)
    MEDmeshEntityFamilyNumberRd(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,_fam_coords->getPointer());
  else
    _fam_coords=0;
  if(MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,MED_NUMBER,MED_NODAL,&changement,&transformation)>0)
    MEDmeshEntityNumberRd(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,_num_coords->getPointer());
  else
    _num_coords=0;
  for(int i=0;i<spaceDim;i++)
    _coords->setInfoOnComponent(i,infosOnComp[i].c_str());
}

Here is the call graph for this function:

Here is the caller graph for this function:

void MEDFileMeshL2::ReadFamiliesAndGrps ( med_idt  fid,
const char *  mname,
std::map< std::string, int > &  fams,
std::map< std::string, std::vector< std::string > > &  grps 
) [static, inherited]

Definition at line 152 of file MEDFileMeshLL.cxx.

{
  char nomfam[MED_NAME_SIZE+1];
  med_int numfam;
  int nfam=MEDnFamily(fid,meshName);
  for(int i=0;i<nfam;i++)
    {
      int ngro=MEDnFamilyGroup(fid,meshName,i+1);
      med_int natt=MEDnFamily23Attribute(fid,meshName,i+1);
      INTERP_KERNEL::AutoPtr<med_int> attide=new med_int[natt];
      INTERP_KERNEL::AutoPtr<med_int> attval=new med_int[natt];
      INTERP_KERNEL::AutoPtr<char> attdes=new char[MED_COMMENT_SIZE*natt+1];
      INTERP_KERNEL::AutoPtr<char> gro=new char[MED_LNAME_SIZE*ngro+1];
      MEDfamily23Info(fid,meshName,i+1,nomfam,attide,attval,attdes,&numfam,gro);
      std::string famName=MEDLoaderBase::buildStringFromFortran(nomfam,MED_NAME_SIZE);
      fams[famName]=numfam;
      for(int j=0;j<ngro;j++)
        {
          std::string groupname=MEDLoaderBase::buildStringFromFortran(gro+j*MED_LNAME_SIZE,MED_LNAME_SIZE);
          grps[groupname].push_back(famName);
        }
    }
}
void MEDFileUMeshL2::sortTypes ( ) [private]

Definition at line 256 of file MEDFileMeshLL.cxx.

{
  std::set<int> mdims;
  std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> > tmp(_per_type_mesh[0]);
  _per_type_mesh.clear();
  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=tmp.begin();it!=tmp.end();it++)
    mdims.insert((*it)->getDim());
  if(mdims.empty())
    return;
  int mdim=*mdims.rbegin();
  _per_type_mesh.resize(mdim+1);
  for(int dim=mdim+1;dim!=0;dim--)
    {
      std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >& elt=_per_type_mesh[mdim+1-dim];
      for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=tmp.begin();it!=tmp.end();it++)
        if((*it)->getDim()==dim-1)
          elt.push_back(*it);
    }
  // suppression of contiguous empty levels at the end of _per_type_mesh.
  int nbOfUselessLev=0;
  bool isFirst=true;
  for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> > >::reverse_iterator it2=_per_type_mesh.rbegin();it2!=_per_type_mesh.rend();it2++)
    {
      if((*it2).empty() && isFirst)
        {
          nbOfUselessLev++;
        }
      else
        isFirst=false;
    }
  _per_type_mesh.resize(_per_type_mesh.size()-nbOfUselessLev);
}

Here is the caller graph for this function:

void MEDFileUMeshL2::WriteCoords ( med_idt  fid,
const char *  mname,
int  dt,
int  it,
double  time,
const DataArrayDouble coords,
const DataArrayInt famCoords,
const DataArrayInt numCoords 
) [static]

Definition at line 289 of file MEDFileMeshLL.cxx.

{
  if(!coords)
    return ;
  MEDmeshNodeCoordinateWr(fid,mname,dt,it,time,MED_FULL_INTERLACE,coords->getNumberOfTuples(),coords->getConstPointer());
  if(famCoords)
    MEDmeshEntityFamilyNumberWr(fid,mname,dt,it,MED_NODE,MED_NO_GEOTYPE,famCoords->getNumberOfTuples(),famCoords->getConstPointer());
  if(numCoords)
    MEDmeshEntityNumberWr(fid,mname,dt,it,MED_NODE,MED_NO_GEOTYPE,numCoords->getNumberOfTuples(),numCoords->getConstPointer());
}

Here is the call graph for this function:

void MEDFileMeshL2::WriteFamiliesAndGrps ( med_idt  fid,
const char *  mname,
const std::map< std::string, int > &  fams,
const std::map< std::string, std::vector< std::string > > &  grps,
int  tooLongStrPol 
) [static, inherited]

Definition at line 176 of file MEDFileMeshLL.cxx.

{
  for(std::map<std::string,int>::const_iterator it=fams.begin();it!=fams.end();it++)
    {
      std::vector<std::string> grpsOfFam;
      for(std::map<std::string, std::vector<std::string> >::const_iterator it1=grps.begin();it1!=grps.end();it1++)
        {
          if(std::find((*it1).second.begin(),(*it1).second.end(),(*it).first)!=(*it1).second.end())
            grpsOfFam.push_back((*it1).first);
        }
      int ngro=grpsOfFam.size();
      INTERP_KERNEL::AutoPtr<char> groName=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE*ngro);
      int i=0;
      for(std::vector<std::string>::const_iterator it2=grpsOfFam.begin();it2!=grpsOfFam.end();it2++,i++)
        MEDLoaderBase::safeStrCpy2((*it2).c_str(),MED_LNAME_SIZE-1,groName+i*MED_LNAME_SIZE,tooLongStrPol);
      INTERP_KERNEL::AutoPtr<char> famName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
      MEDLoaderBase::safeStrCpy((*it).first.c_str(),MED_NAME_SIZE,famName,tooLongStrPol);
      int ret=MEDfamilyCr(fid,mname,famName,(*it).second,ngro,groName);
      ret++;
    }
}

Member Data Documentation

Definition at line 80 of file MEDFileMeshLL.hxx.

Definition at line 53 of file MEDFileMeshLL.hxx.

Definition at line 54 of file MEDFileMeshLL.hxx.

Definition at line 81 of file MEDFileMeshLL.hxx.

int ParaMEDMEM::MEDFileMeshL2::_iteration [protected, inherited]

Definition at line 55 of file MEDFileMeshLL.hxx.

Definition at line 52 of file MEDFileMeshLL.hxx.

Definition at line 82 of file MEDFileMeshLL.hxx.

int ParaMEDMEM::MEDFileMeshL2::_order [protected, inherited]

Definition at line 56 of file MEDFileMeshLL.hxx.

Definition at line 79 of file MEDFileMeshLL.hxx.

double ParaMEDMEM::MEDFileMeshL2::_time [protected, inherited]

Definition at line 57 of file MEDFileMeshLL.hxx.


The documentation for this class was generated from the following files: