med_err
MEDstructElementInfoByName(const med_idt             fid,
			   const char *        const modelname,
			   med_geometry_type * const mgeotype,
			   med_int*            const modeldim,
			   char*               const supportmeshname,
			   med_entity_type*    const sentitytype,
			   med_int*            const snnode,
			   med_int*            const sncell,
			   med_geometry_type*  const sgeotype,
			   med_int*            const nconstantattribute,
			   med_bool*           const anyprofile,
			   med_int*            const nvariableattribute
			   )
{

  med_err           _ret=-1;
  med_idt            _elemid=0, _cstid=0;
  char              _path[MED_TAILLE_STRCT+MED_NAME_SIZE+1]=MED_STRCT;
  char              __profilename   [MED_NAME_SIZE+1]=MED_NO_PROFILE_INTERNAL;
  const char*       _profilename   = __profilename;
  med_int           _intentitytype = MED_UNDEF_ENTITY_TYPE;
  med_int           _nentity       = 0;
  med_size          _tmpn          = 0;
  med_bool          _chgt=MED_FALSE,_trsf=MED_FALSE;
  med_int           _medintmgeotype = MED_NONE;
  med_int           _medintsgeotype = MED_NONE;
  med_int           _intanyprofile  = 0;

  strcat(_path,modelname);

  /*
   * Si le DataGroup /STRUCT/<modelname> n'existe pas => erreur
   */
  if ((_elemid = _MEDdatagroupOpen(fid,_path)) < 0)  {
    MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_path);
    goto ERROR;
  }

  /*
   * Lecture de l'attribut MED_NOM_NEO (numéro de type géométrique associé à un élément de structure)
   */
  if ( _MEDattrEntierLire(_elemid,MED_NOM_NEO,&_medintmgeotype) < 0 ) {
    MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
    SSCRUTE(MED_NOM_NEO);ISCRUTE(_medintmgeotype);
    goto ERROR;
  }
  *mgeotype=_medintmgeotype;

  /*
   * Lecture de l'attribut MED_NOM_DIM (dimension de l'élément)
   */
  if ( _MEDattrEntierLire(_elemid,MED_NOM_DIM,modeldim) < 0 ) {
    MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
    SSCRUTE(MED_NOM_DIM);ISCRUTE(*modeldim);
    goto ERROR;
  }

  /*
   * Lecture  de l'attribut MED_NOM_NOM (nom du maillage support)
   */
  /* Chercher plutôt ds le maillage support et supprimer les attributs NBM et NBN */
  if ( _MEDattrStringLire(_elemid,MED_NOM_NOM,MED_NAME_SIZE,supportmeshname) < 0) {
    MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
    SSCRUTE(MED_NOM_NOM);SSCRUTE(supportmeshname);
    goto ERROR;
  }

  /*
   * Lecture de l'attribut MED_NOM_ENT (type d'entité support)
   */
  if ( _MEDattrEntierLire(_elemid,MED_NOM_ENT,&_intentitytype) < 0 ) {
    MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
    SSCRUTE(MED_NOM_ENT);ISCRUTE(_intentitytype);
    goto ERROR;
  }

  *sentitytype = (med_entity_type) _intentitytype;

  /*
   * Lecture de l'attribut MED_NOM_GEO (type géométrique des mailles support)
   */
  if ( _MEDattrEntierLire(_elemid,MED_NOM_GEO,&_medintsgeotype) < 0 ) {
    MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
    SSCRUTE(MED_NOM_GEO);ISCRUTE(_medintsgeotype);
    goto ERROR;
  }
  *sgeotype=_medintsgeotype;

  /*
   * Lecture du nombre de noeuds support
   */
  if (strlen(supportmeshname)) {
    if ( (*snnode = MEDmeshnEntity(fid,supportmeshname,MED_NO_DT,MED_NO_IT,
				     MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,
				     &_chgt,&_trsf) )  <= 0) {
      MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshnEntity");
      ISCRUTE(*snnode);goto ERROR;
    }
  } else {
    *snnode=1;
  }
  /*
   * Lecture du nombre de mailles support
   */

  if (strlen(supportmeshname)) {
    if ( (*sncell = MEDmeshnEntity(fid,supportmeshname,MED_NO_DT,MED_NO_IT,
				     MED_CELL,*sgeotype,MED_CONNECTIVITY,MED_NODAL,
				     &_chgt,&_trsf) )  < 0) {
      MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshnEntity");
      ISCRUTE(*sncell);goto ERROR;
    }
  } else {
    *sncell=0;
  }


  _MEDnObjects(_elemid,MED_CSTATR_NOM,&_tmpn);

  if ( _tmpn > 0) {

    if ((_cstid = _MEDdatagroupOpen(_elemid,MED_CSTATR_NOM)) < 0) {
      MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,MED_CSTATR_NOM);
      SSCRUTE(_path);goto ERROR;
    }

    if ( _MEDattrEntierLire(_cstid,MED_NOM_PFU,&_intanyprofile) < 0) {
      MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_STRUCT_MSG);
      SSCRUTE(modelname);SSCRUTE(MED_NOM_PFU);
      goto ERROR;
    }
    *anyprofile=_intanyprofile;

    *nconstantattribute = (med_int) _tmpn;

  } else {
    *anyprofile = MED_FALSE;
    *nconstantattribute = 0;
  }

  _MEDnObjects(_elemid,MED_VARATR_NOM,&_tmpn);
  if ( _tmpn > 0)
    *nvariableattribute = (med_int) _tmpn;
  else
    *nvariableattribute = (med_int) 0;

  _ret=0;

 ERROR:

  if (_cstid>0)            if (_MEDdatagroupFermer(_cstid) < 0) {
    MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_CSTATR_NOM);
    ISCRUTE_id(_cstid);
  }

  if (_elemid>0)            if (_MEDdatagroupFermer(_elemid) < 0) {
    MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,modelname);
    ISCRUTE_id(_elemid);
  }

  return _ret;
}
Example #2
0
/**\ingroup MEDinterp
  \brief \MEDinterpCrBrief
  \param fid           \fid
  \param interpname    \interpname
  \param geotype       \geotype
  \param cellnode      \cellnode
  \param nvariable  \nvariable
  \param maxdegree     \maxdegree
  \param nmaxcoef      \nmaxcoef

  \return \error
  \details \MEDinterpCrDetails
  \see MEDinterpBaseFunctionWr
  \remarks
  \li \MEDinterpCrcellnodeCm1
  \li \MEDinterpCrcellnodeCm2
 */
med_err
MEDinterpCr(const med_idt                 fid,
	    const char*             const interpname,
	    const med_geometry_type       geotype,
	    const med_bool                cellnode,
	    const med_int                 nvariable,
	    const med_int                 maxdegree,
	    const med_int                 nmaxcoef
	    )
{
  med_access_mode   _MED_ACCESS_MODE;
  med_idt           _root=0,_interpid=0;
  med_int           _ret=-1;
  char              _path[MED_INTERPOLATION_GRP_SIZE+MED_NAME_SIZE+1]=MED_INTERPOLATION_GRP;
  med_int           _cellnodes = cellnode;
  med_int           _geotype = geotype;
  /*
   * On inhibe le gestionnaire d'erreur
   */
  _MEDmodeErreurVerrouiller();
 if (_MEDcheckVersion30(fid) < 0) goto ERROR;

  if ( (_MED_ACCESS_MODE = _MEDmodeAcces(fid) ) == MED_ACC_UNDEF ) {
    MED_ERR_(_ret,MED_ERR_UNRECOGNIZED,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
    goto ERROR;
  }

  if ( _MED_ACCESS_MODE == MED_ACC_RDONLY) {
    MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
    ISCRUTE_int(_MED_ACCESS_MODE);
    goto ERROR;
  }

  /*
   * Si le DataGroup /INTERP/ n'existe pas, on le cree
   */
  if ((_root = _MEDdatagroupOpen(fid,_path)) < 0)
    if ((_root = _MEDdatagroupCreer(fid,_path)) < 0) {
      MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,_path);
     goto ERROR;
    }

  NOFINALBLANK(interpname,ERROR);

  /*
   * Si le DataGroup /INTERP/<interpname> n'existe pas, on le cree
   */
  if ((_interpid = _MEDdatagroupOpen(_root,interpname)) < 0)
    if ((_interpid = _MEDdatagroupCreer(_root,interpname)) < 0) {
      MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,interpname);
      SSCRUTE(_path);goto ERROR;
    }

  strcat(_path,interpname);

  /*
   * Creation/Ecriture de l'attribut MED_NOM_GEO
   */
  if ( _MEDattributeIntWr(_interpid,MED_NOM_GEO,&_geotype) < 0 ) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
    SSCRUTE(MED_NOM_GEO);ISCRUTE(_geotype);
    goto ERROR;
  }

  /*
   * Creation/Ecriture de l'attribut MED_NOM_NBB
   */
/*   if ( _MEDattributeIntWr(_interpid,MED_NOM_NBB,&nbasisfunc) < 0 ) { */
/*     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path); */
/*     SSCRUTE(MED_NOM_NBB);ISCRUTE(nbasisfunc); */
/*     goto ERROR; */
/*   } */

  /*
   * Creation/Ecriture de l'attribut MED_NOM_NBV
   */
  if ( _MEDattributeIntWr(_interpid,MED_NOM_NBV,&nvariable) < 0 ) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
    SSCRUTE(MED_NOM_NBV);ISCRUTE(nvariable);
    goto ERROR;
  }

  /*
   * Creation/Ecriture de l'attribut MED_NOM_MDG
   */
  if ( _MEDattributeIntWr(_interpid,MED_NOM_MDG,&maxdegree) < 0 ) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
    SSCRUTE(MED_NOM_MDG);ISCRUTE(maxdegree);
    goto ERROR;
  }

  /*
   * Creation/Ecriture de l'attribut MED_NOM_MCF
   */
  if ( _MEDattributeIntWr(_interpid,MED_NOM_MCF,&nmaxcoef) < 0 ) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
    SSCRUTE(MED_NOM_MCF);ISCRUTE(nmaxcoef);
    goto ERROR;
  }

  /*
   * Creation/Ecriture de l'attribut MED_NOM_FCN
   */
  if ( _MEDattributeIntWr(_interpid,MED_NOM_FCN,&_cellnodes) < 0 ) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
    SSCRUTE(MED_NOM_FCN);ISCRUTE(_cellnodes);
    goto ERROR;
  }

  _ret = 0;

 ERROR:

  if (_interpid>0)     if (_MEDdatagroupFermer(_interpid) < 0) {
    MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
    ISCRUTE_id(_interpid);
  }

  if (_root>0)            if (_MEDdatagroupFermer(_root) < 0) {
    MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_INTERPOLATION_GRP);
    ISCRUTE_id(_root);
  }

  return _ret;

}
Example #3
0
med_geometry_type
MEDstructElementCr(const med_idt                 fid,
		   const char*             const modelname,
		   const med_int                 modeldim,
		   const char*             const supportmeshname,
		   const med_entity_type         sentitytype,
		   const med_geometry_type       sgeotype
		   )
{
  med_access_mode   _MED_ACCESS_MODE;
  med_err           _err=-1;
  med_idt           _root=0,_elemid=0;
  med_int           _ret=-1;
  char              _path[MED_TAILLE_STRCT+MED_NAME_SIZE+1]=MED_STRCT;
  med_size          _tmpn=0;
  med_geometry_type _stgeotype=0;
  med_int           _medintstgeotype = 0;
  med_int           _medintsgeotype  = sgeotype;
  med_int           _intentitytype   = sentitytype;
  med_int           _nnode=0,_ncell=0;
  med_bool          _chgt=MED_FALSE,_trsf=MED_FALSE;

/*   char           _entitytypename[MED_TAILLE_NOM_ENTITE+1]=""; */

  /*
   * On inhibe le gestionnaire d'erreur
   */
  _MEDmodeErreurVerrouiller();
 if (_MEDcheckVersion30(fid) < 0) goto ERROR;

  if ( (_MED_ACCESS_MODE = _MEDmodeAcces(fid) ) == MED_ACC_UNDEF ) {
    MED_ERR_(_ret,MED_ERR_UNRECOGNIZED,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
    goto ERROR;
  }

  if ( _MED_ACCESS_MODE == MED_ACC_RDONLY) {
    MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
    ISCRUTE_int(_MED_ACCESS_MODE);
    goto ERROR;
  }

  /*
   * Si le DataGroup /STRUCT/ n'existe pas, on le cree
   */
  if ((_root = _MEDdatagroupOpen(fid,_path)) < 0)
    if ((_root = _MEDdatagroupCrOrderCr(fid,_path)) < 0) {
      MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,_path);
     goto ERROR;
    }

  NOFINALBLANK(modelname,ERROR);

  /*
   * Si le DataGroup /STRUCT/<modelname> n'existe pas, on le cree
   */
  if ((_elemid = _MEDdatagroupOpen(_root,modelname)) < 0) {
    if ((_elemid = _MEDdatagroupCreer(_root,modelname)) < 0) {
      MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,modelname);
      SSCRUTE(_path);goto ERROR;
    }
  } else {
    /*
     * Lecture de l'attribut MED_NOM_NEO (num�ro de type g�om�trique associ� � un �l�ment de structure)
     */
    if ( _MEDattrEntierLire(_elemid,MED_NOM_NEO,&_medintstgeotype) < 0 ) {
      MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
      SSCRUTE(MED_NOM_NEO);ISCRUTE(_medintstgeotype);
      goto ERROR;
    }
    _stgeotype = _medintstgeotype;
  }
  strcat(_path,modelname);

  /*
   * Creation/Ecriture de l'attribut MED_NOM_DIM (dimension de l'�l�ment)
   */
  if ( _MEDattributeIntWr(_elemid,MED_NOM_DIM,&modeldim) < 0 ) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
    SSCRUTE(MED_NOM_DIM);ISCRUTE(modeldim);
    goto ERROR;
  }

  /*
   * Creation/Ecriture de l'attribut MED_NOM_NOM (nom du maillage support)
   */
  if ( _MEDattributeStringWr(_elemid,MED_NOM_NOM,MED_NAME_SIZE,supportmeshname) < 0) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
    SSCRUTE(MED_NOM_NOM);SSCRUTE(supportmeshname);
    goto ERROR;
  }

  /*
   * Creation/Ecriture de l'attribut MED_NOM_ENT (type d'entit� support)
   */
/*   if (_MEDgetEntityTypeName(_entitytypename,sentitytype) < 0) { */
/*     MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ENTITY,MED_ERR_VALUE_MSG); */
/*     ISCRUTE_int(sentitytype);SSCRUTE(_entitytypename);SSCRUTE(_path); */
/*     goto ERROR; */
/*   } */

  if ( _MEDattributeIntWr(_elemid,MED_NOM_ENT,&_intentitytype) < 0 ) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
    SSCRUTE(MED_NOM_ENT);ISCRUTE(_intentitytype);
    goto ERROR;
  }

  /*
    Lecture dans le maillages support du nombre de noeuds
    S'il n'y a pas de maillage support : 1
  */
  if (strlen(supportmeshname)) {
    if ( (_nnode = MEDmeshnEntity(fid,supportmeshname,MED_NO_DT,MED_NO_IT,
				     MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,
				     &_chgt,&_trsf) )  <= 0) {
      MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshnEntity");
      ISCRUTE(_nnode);goto ERROR;
    }
  } else {
    _nnode=1;
  }

  if (strlen(supportmeshname)) {
    if ( (_ncell = MEDmeshnEntity(fid,supportmeshname,MED_NO_DT,MED_NO_IT,
				     MED_CELL,sgeotype,MED_CONNECTIVITY,MED_NODAL,
				     &_chgt,&_trsf) )  < 0) {
      MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshnEntity");
      ISCRUTE(_ncell);goto ERROR;
    }
  } else {
    _ncell=0;
  }

  /*
   * Creation/Ecriture de l'attribut MED_NOM_GEO (type g�om�trique des mailles support)
   */
  _medintsgeotype = sgeotype;
  if ( _MEDattributeIntWr(_elemid,MED_NOM_GEO,&_medintsgeotype) < 0 ) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
    SSCRUTE(MED_NOM_GEO);ISCRUTE(_medintsgeotype);
    goto ERROR;
  }

  /*
   * Creation/Ecriture de l'attribut MED_NOM_NAV (nombre d'attributs variables associ�s � un �l�ment de structure)
   */
/*   if ( _MEDattributeIntWr(_elemid,MED_NOM_NAV,&nvariableattribute) < 0 ) { */
/*     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path); */
/*     SSCRUTE(MED_NOM_NAV);ISCRUTE(nvariableattribute); */
/*     goto ERROR; */
/*   } */

  /*
   * Creation/Ecriture de l'attribut MED_NOM_NAC (nombre d'attributs constant associ�s � un �l�ment de structure)
   */
/*   if ( _MEDattributeIntWr(_elemid,MED_NOM_NAC,&nconstattribute) < 0 ) { */
/*     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path); */
/*     SSCRUTE(MED_NOM_NAC);ISCRUTE(nconstattribute); */
/*     goto ERROR; */
/*   } */


  /*
   *  Nombre d'�l�ments de structure
   */
  if ( !_stgeotype ) {

    /*Si l'�l�ment de struture ne pr�-existait pas,
      il a �t� cr�e en d�but de proc�dure (il y a au moins 1 �l�ment dans le groupe) */
    if ((_err=_MEDnObjects(fid,MED_STRCT,&_tmpn)) <0) {
      MED_ERR_(_ret,MED_ERR_COUNT,MED_ERR_STRUCT,MED_STRCT);
      goto ERROR;
    }

    _stgeotype=_tmpn+MED_STRUCT_GEO_INTERNAL;
    _medintstgeotype=_stgeotype;

    /*
     * Ecriture de l'attribut MED_NOM_NEO (num�ro de type g�om�trique associ� � un �l�ment de structure)
     */
    if ( _MEDattributeIntWr(_elemid,MED_NOM_NEO,&_medintstgeotype) < 0 ) {
      MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
      SSCRUTE(MED_NOM_NEO);ISCRUTE(_medintstgeotype);
      goto ERROR;
    }
  }

  _ret = _stgeotype;

 ERROR:

  if (_elemid>0)     if (_MEDdatagroupFermer(_elemid) < 0) {
    MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
    ISCRUTE_id(_elemid);
  }

  if (_root>0)            if (_MEDdatagroupFermer(_root) < 0) {
    MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_STRCT);
    ISCRUTE_id(_root);
  }

  return _ret;

}