Ejemplo n.º 1
0
  void ME_Delete(MEdge_ptr e, int keep) {
    RepType RTYPE = MEnt_RepType((MEntity_ptr) e);
    Mesh_ptr mesh;

    (*ME_Delete_jmp[RTYPE])(e,keep);

    if (MEnt_Dim((MEntity_ptr) e) != MDELETED) {
      mesh = MEnt_Mesh((MEntity_ptr) e);

      if (mesh) {
#ifdef MSTK_HAVE_MPI
      if (ME_PType(e) == PGHOST)
	MESH_Rem_GhostEdge(mesh,e);
      else
#endif
	MESH_Rem_Edge(mesh,e);
      }

      MEnt_Set_DelFlag((MEntity_ptr) e);
    }

    if (!keep) {
      MEnt_Free_CmnData((MEntity_ptr) e);
      free((MEntity_ptr) e);
    }
  }
Ejemplo n.º 2
0
  void MR_Delete(MRegion_ptr r, int keep) {
    RepType RTYPE = MEnt_RepType((MEntity_ptr) r);
    Mesh_ptr mesh;

    (*MR_Delete_jmp[RTYPE])(r,keep);

    if (MEnt_Dim((MEntity_ptr) r) != MDELETED) {
      mesh = MEnt_Mesh((MEntity_ptr) r);

      if (mesh) {
#ifdef MSTK_HAVE_MPI
      if (MR_PType(r) == PGHOST)
	MESH_Rem_GhostRegion(mesh,r);
      else
#endif
	MESH_Rem_Region(mesh,r);
      }

      MEnt_Set_DelFlag((MEntity_ptr) r);
    }

    if (!keep) {
      MEnt_Free_CmnData((MEntity_ptr) r);
      free(r);
    }
  }
Ejemplo n.º 3
0
  void ME_Restore(MEdge_ptr e) {
    RepType RTYPE = MEnt_RepType((MEntity_ptr) e);
    Mesh_ptr mesh = MEnt_Mesh((MEntity_ptr) e);

#ifdef DEBUG
    if (MEnt_Dim((MEntity_ptr) e) != MDELETED) {
      MSTK_Report("ME_Restore",
		  "Trying to restore edge that is not deleted",MSTK_WARN);
      return;
    }
#endif

    MEnt_Rem_DelFlag((MEntity_ptr) e);

#ifdef MSTK_HAVE_MPI
    if (ME_PType(e) == PGHOST)
      MESH_Add_GhostEdge(mesh,e);
    else
#endif
      MESH_Add_Edge(mesh,e);

    (*ME_Restore_jmp[RTYPE])(e);
  }
Ejemplo n.º 4
0
  void MR_Restore(MRegion_ptr r) {
    RepType RTYPE = MEnt_RepType((MEntity_ptr) r);
    Mesh_ptr mesh = MEnt_Mesh((MEntity_ptr) r);

#ifdef DEBUG
    if (MEnt_Dim((MEntity_ptr) r) != MDELETED) {
      MSTK_Report("MR_Restore",
		  "Trying to restore region that is not deleted",MSTK_WARN);
      return;
    }
#endif

    MEnt_Rem_DelFlag((MEntity_ptr) r);

#ifdef MSTK_HAVE_MPI
    if (MR_PType(r) == PGHOST)
      MESH_Add_GhostRegion(mesh,r);
    else
#endif
      MESH_Add_Region(mesh,r);

    (*MR_Restore_jmp[RTYPE])(r);
  }
Ejemplo n.º 5
0
  List_ptr MF_Edges_R4(MFace_ptr f, int dir, MVertex_ptr v0) {
    MFace_Adj_R4 *adj = (MFace_Adj_R4 *) f->adj;
    int i, j, k, ne, nv;
    List_ptr fedges;
    MVertex_ptr v, evtx[2], vtmp;
    MEdge_ptr e;

    k = 0;
    if (v0) {
      int fnd = 0, idx = 0;
      while (!fnd && (v = List_Next_Entry(adj->fvertices,&idx))) {
	if (v == v0)
	  fnd = 1;
	else
	  k++;
      }

      if (!fnd) {
	MSTK_Report("MF_Edges_R4","Cannot find vertex in face",MSTK_ERROR);
	return NULL;
      }
    }
    
    nv = ne = List_Num_Entries(adj->fvertices);
    fedges = List_New(ne);
    for (i = 0; i < ne; i++) {
      j = dir ? (k+i)%ne : (k-i+ne)%ne;
      evtx[0] = List_Entry(adj->fvertices,j);
      j = dir ? (k+(i+1))%ne : (k-(i+1)+ne)%ne;
      evtx[1] = List_Entry(adj->fvertices,j);

#ifdef HASHTABLE
      if (evtx[0]>evtx[1]) {
	vtmp = evtx[0];
	evtx[0] = evtx[1];
	evtx[1] = vtmp;
      }

      e = Hash_Entry(MESH_Hash_Edges(MEnt_Mesh((MEntity_ptr) f)), 2, evtx);
      if (e == NULL) {
	e = ME_New(MEnt_Mesh((MEntity_ptr) f));
	MEnt_Set_Volatile(e);

	ME_Set_Vertex(e,0,evtx[0]);
	ME_Set_Vertex(e,1,evtx[1]);

	ME_Set_GInfo_Auto(e);
	Hash_Add(MESH_Hash_Edges(MEnt_Mesh((MEntity_ptr) f)), e, 2, evtx);
      }
#else
      e = ME_New(MEnt_Mesh((MEntity_ptr)f));
      MEnt_Set_Volatile(e);

      ME_Set_Vertex(e,0,evtx[0]);
      ME_Set_Vertex(e,1,evtx[1]);

      ME_Set_GInfo_Auto(e);
#endif

      List_Add(fedges,e);
      ME_Lock(e);
    }

    if (!MESH_AutoLock(MEnt_Mesh((MEntity_ptr) f))) {
       i = 0;
       while ((e = List_Next_Entry(fedges, &i))) {
	 ME_UnLock(e);
       }
    }

    return fedges;
  }
Ejemplo n.º 6
0
 Mesh_ptr ME_Mesh(MEdge_ptr e) {
   return MEnt_Mesh((MEntity_ptr) e);
 }
Ejemplo n.º 7
0
int MESH_CopyAttr(Mesh_ptr mesh, int num, Mesh_ptr *submeshes, const char *attr_name) {
  int i, ncomp, ival, idx;
  double rval, *pval_arr=NULL;
  void *pval;
  MType mtype;
  MAttrib_ptr *local_attrib, global_attrib, g2latt;
  MAttType atttype;


  global_attrib = MESH_AttribByName(mesh,attr_name);
  if(!global_attrib) {
    MSTK_Report("MESH_CopyAttr","Root mesh has no attribute of given name",MSTK_WARN);
    return 0;
  }

  g2latt = MESH_AttribByName(mesh,"Global2Local");

  local_attrib = (MAttrib_ptr *) malloc(num*sizeof(MAttrib_ptr));
  for (i = 0; i < num; i++) {
    local_attrib[i] = MESH_AttribByName(submeshes[i],attr_name);
    /* if there is no such attribute */
    if(!local_attrib[i]) {
      MSTK_Report("MESH_CopyAttr","Submesh has no attribute of given name",MSTK_WARN);
      return 0;
    }
  }
    

  /* get attribute properties */
  ncomp = MAttrib_Get_NumComps(global_attrib);
  mtype = MAttrib_Get_EntDim(global_attrib);
  atttype = MAttrib_Get_Type(global_attrib);

  if (atttype == POINTER) {
    free(local_attrib);
    return 0; /* Don't see why one would want to
                 transmit pointer info to the submesh */
  }
  
  /* attribute entity type */
  
  if (mtype == MVERTEX || mtype == MALLTYPE) {
    MVertex_ptr gmv, lmv;
    List_ptr lmvlist;

    idx = 0;
    while ((gmv = MESH_Next_Vertex(mesh,&idx))) {

      MEnt_Get_AttVal(gmv,global_attrib,&ival,&rval,&pval);

      /* Don't copy null values */

      if ((atttype == INT && ival == 0) || 
          (atttype == DOUBLE  && rval == 0.0) ||
          (atttype == POINTER && pval == NULL))
        continue;

      int dummy_ival;
      double dummy_rval;
      MEnt_Get_AttVal(gmv,g2latt,&dummy_ival,&dummy_rval,&lmvlist);
      if (!lmvlist) continue;

      int idx2 = 0;
      while ((lmv = List_Next_Entry(lmvlist,&idx2))) {
        if (ncomp > 1) {
          pval_arr = (void *)malloc(ncomp*sizeof(double));
          memcpy(pval_arr,pval,ncomp*sizeof(double));
        }
        else
          pval_arr = NULL;

        Mesh_ptr entmesh = MEnt_Mesh(lmv);
        for (i = 0; i < num; i++)
          if (entmesh == submeshes[i]) {
            MEnt_Set_AttVal(lmv,local_attrib[i],ival,rval,(void *)pval_arr);
            break;
          }
      }
    }
  }

  if (mtype == MEDGE || mtype == MALLTYPE) {
    MVertex_ptr gme, lme;
    List_ptr lmelist;

    idx = 0;
    while ((gme = MESH_Next_Edge(mesh,&idx))) {

      MEnt_Get_AttVal(gme,global_attrib,&ival,&rval,&pval);

      /* Don't copy null values */

      if ((atttype == INT && ival == 0) || 
          (atttype == DOUBLE  && rval == 0.0) ||
          (atttype == POINTER && pval == NULL))
        continue;

      int dummy_ival;
      double dummy_rval;
      MEnt_Get_AttVal(gme,g2latt,&dummy_ival,&dummy_rval,&lmelist);
      if (!lmelist) continue;

      int idx2 = 0;
      while ((lme = List_Next_Entry(lmelist,&idx2))) {
        if (ncomp > 1) {
          pval_arr = (void *)malloc(ncomp*sizeof(double));
          memcpy(pval_arr,pval,ncomp*sizeof(double));
        }
        else
          pval_arr = NULL;

        Mesh_ptr entmesh = MEnt_Mesh(lme);
        for (i = 0; i < num; i++)
          if (entmesh == submeshes[i]) {
            MEnt_Set_AttVal(lme,local_attrib[i],ival,rval,(void *)pval_arr);
            break;
          }
      }
    }
  }

  if (mtype == MFACE || mtype == MALLTYPE) {
    MFace_ptr gmf, lmf;
    List_ptr lmflist;

    idx = 0;
    while ((gmf = MESH_Next_Face(mesh,&idx))) {

      MEnt_Get_AttVal(gmf,global_attrib,&ival,&rval,&pval);

      /* Don't copy null values */

      if ((atttype == INT && ival == 0) || 
          (atttype == DOUBLE  && rval == 0.0) ||
          (atttype == POINTER && pval == NULL))
        continue;

      int dummy_ival;
      double dummy_rval;
      MEnt_Get_AttVal(gmf,g2latt,&dummy_ival,&dummy_rval,&lmflist);
      if (!lmflist) continue;

      int idx2 = 0;
      while ((lmf = List_Next_Entry(lmflist,&idx2))) {
        if (ncomp > 1) {
          pval_arr = (void *)malloc(ncomp*sizeof(double));
          memcpy(pval_arr,pval,ncomp*sizeof(double));
        }
        else
          pval_arr = NULL;

        Mesh_ptr entmesh = MEnt_Mesh(lmf);
        for (i = 0; i < num; i++)
          if (entmesh == submeshes[i]) {
            MEnt_Set_AttVal(lmf,local_attrib[i],ival,rval,(void *)pval_arr);
            break;
          }
      }
    }
  }


  if (mtype == MREGION || mtype == MALLTYPE) {
    MRegion_ptr gmr, lmr;
    List_ptr lmrlist;

    idx = 0;
    while ((gmr = MESH_Next_Region(mesh,&idx))) {

      MEnt_Get_AttVal(gmr,global_attrib,&ival,&rval,&pval);

      /* Don't copy null values */

      if ((atttype == INT && ival == 0) || 
          (atttype == DOUBLE  && rval == 0.0) ||
          (atttype == POINTER && pval == NULL))
        continue;

      int dummy_ival;
      double dummy_rval;
      MEnt_Get_AttVal(gmr,g2latt,&dummy_ival,&dummy_rval,&lmrlist);
      if (!lmrlist) continue;

      int idx2 = 0;
      while ((lmr = List_Next_Entry(lmrlist,&idx2))) {
        if (ncomp > 1) {
          pval_arr = (void *)malloc(ncomp*sizeof(double));
          memcpy(pval_arr,pval,ncomp*sizeof(double));
        }
        else
          pval_arr = NULL;

        Mesh_ptr entmesh = MEnt_Mesh(lmr);
        for (i = 0; i < num; i++)
          if (entmesh == submeshes[i]) {
            MEnt_Set_AttVal(lmr,local_attrib[i],ival,rval,(void *)pval_arr);
            break;
          }
      }
    }
  }

  free(local_attrib);
  
  return 1;
}
Ejemplo n.º 8
0
 Mesh_ptr MR_Mesh(MRegion_ptr r) {
   return MEnt_Mesh((MEntity_ptr) r);
 }