13 #include "../config/config.hpp"
20 #include <sidre/IOManager.hpp>
27 namespace sidre = axom::sidre;
35 Mesh * the_mesh,
bool own_mesh_data)
37 m_owns_datastore(true),
38 m_owns_mesh_data(own_mesh_data),
39 m_meshNodesGFName(
"mesh_nodes")
41 m_datastore_ptr =
new sidre::DataStore();
43 sidre::Group * global_grp =
44 m_datastore_ptr->getRoot()->createGroup(collection_name +
"_global");
45 sidre::Group * domain_grp =
46 m_datastore_ptr->getRoot()->createGroup(collection_name);
48 m_bp_grp = domain_grp->createGroup(
"blueprint");
50 m_bp_index_grp = global_grp->createGroup(
"blueprint_index/" +
name);
52 m_named_bufs_grp = domain_grp->createGroup(
"named_buffers");
73 axom::sidre::Group* bp_index_grp,
74 axom::sidre::Group* domain_grp,
77 m_owns_datastore(false),
78 m_owns_mesh_data(own_mesh_data),
79 m_meshNodesGFName(
"mesh_nodes"),
80 m_datastore_ptr(NULL),
81 m_bp_index_grp(bp_index_grp)
83 m_bp_grp = domain_grp->createGroup(
"blueprint");
85 m_named_bufs_grp = domain_grp->createGroup(
"named_buffers");
97 delete m_datastore_ptr;
115 MFEM_ASSERT(m_named_bufs_grp != NULL,
116 "No group 'named_buffers' in data collection. Verify that"
117 " SetMesh was called to set the mesh in the data collection.");
118 return m_named_bufs_grp;
124 const std::string &view_name)
126 MFEM_ASSERT(grp,
"Group pointer is NULL");
127 sidre::View *v = NULL;
129 if (! grp->hasView(view_name) )
131 v = grp->createView(view_name);
132 MFEM_ASSERT(v,
"error allocating View " << view_name
133 <<
" in group " << grp->getPathName());
137 v = grp->getView(view_name);
146 const std::string &view_name,
147 const axom::sidre::DataType &dtype)
149 MFEM_ASSERT(grp,
"Group pointer is NULL");
150 sidre::View *v = NULL;
152 if (! grp->hasView(view_name))
154 v = grp->createView(view_name, dtype);
155 MFEM_ASSERT(v,
"error allocating View " << view_name
156 <<
" in group " << grp->getPathName());
160 v = grp->getView(view_name);
161 MFEM_ASSERT(v->getSchema().dtype().equals(dtype),
"");
169 const std::string &group_name)
171 MFEM_ASSERT(grp,
"Group pointer is NULL");
172 sidre::Group *g = NULL;
174 if (! grp->hasGroup(group_name) )
176 g = grp->createGroup(group_name);
177 MFEM_ASSERT(g,
"error allocating Group " << group_name
178 <<
" in group " << grp->getPathName());
182 g = grp->getGroup(group_name);
191 std::stringstream fNameSstr;
202 return fNameSstr.str();
207 axom::sidre::SidreLength sz,
208 axom::sidre::TypeID type)
210 sz = std::max(sz, sidre::SidreLength(0));
212 sidre::View *v = NULL;
214 if (! f->hasView(buffer_name) )
217 v = f->createViewAndAllocate(buffer_name, type, sz);
221 v = f->getView(buffer_name);
222 MFEM_ASSERT(v->getTypeID() == type,
"type does not match existing type");
228 if (!v->isApplied() || v->getNumElements() < sz)
232 sidre::DataType dtype(v->getSchema().dtype());
233 dtype.set_number_of_elements(sz);
234 f->destroyViewAndData(buffer_name);
235 v = f->createViewAndAllocate(buffer_name, dtype);
238 MFEM_ASSERT(v && v->isApplied(),
"allocation failed");
243 void SidreDataCollection::createMeshBlueprintStubs(
bool hasBP)
247 m_bp_grp->createGroup(
"state");
248 m_bp_grp->createGroup(
"coordsets");
249 m_bp_grp->createGroup(
"topologies");
250 m_bp_grp->createGroup(
"fields");
256 m_bp_index_grp->createGroup(
"state");
257 m_bp_index_grp->createGroup(
"coordsets");
258 m_bp_index_grp->createGroup(
"topologies");
259 m_bp_index_grp->createGroup(
"fields");
264 void SidreDataCollection::createMeshBlueprintState(
bool hasBP)
269 m_bp_grp->createViewScalar(
"state/cycle", 0);
270 m_bp_grp->createViewScalar(
"state/time", 0.);
271 m_bp_grp->createViewScalar(
"state/domain",
myid);
272 m_bp_grp->createViewScalar(
"state/time_step", 0.);
278 m_bp_index_grp->createViewScalar(
"state/cycle", 0);
279 m_bp_index_grp->createViewScalar(
"state/time", 0.);
280 m_bp_index_grp->createViewScalar(
"state/number_of_domains",
num_procs);
285 void SidreDataCollection::createMeshBlueprintCoordset(
bool hasBP)
288 MFEM_ASSERT(dim >= 1 && dim <= 3,
"invalid mesh dimension");
291 const int NUM_COORDS =
sizeof(
mfem::Vertex) /
sizeof(
double);
294 const int coordset_len = NUM_COORDS * num_vertices;
299 m_bp_grp->createViewString(
"coordsets/coords/type",
"explicit");
301 sidre::DataType dtype =
302 sidre::DataType::c_double(num_vertices);
303 const size_t stride = dtype.stride();
304 dtype.set_stride(stride*NUM_COORDS);
307 sidre::View *vx, *vy = NULL, *vz = NULL;
308 vx = m_bp_grp->createView(
"coordsets/coords/values/x", dtype);
312 dtype.set_offset(dtype.offset() + stride);
313 vy = m_bp_grp->createView(
"coordsets/coords/values/y", dtype);
317 dtype.set_offset(dtype.offset() + stride);
318 vz = m_bp_grp->createView(
"coordsets/coords/values/z", dtype);
321 if (m_owns_mesh_data)
324 sidre::Buffer* coordbuf =
327 vx->attachBuffer(coordbuf);
328 if (dim >= 2) { vy->attachBuffer(coordbuf); }
329 if (dim >= 3) { vz->attachBuffer(coordbuf); }
335 vx->setExternalDataPtr(coordbuf);
336 if (dim >= 2) { vy->setExternalDataPtr(coordbuf); }
337 if (dim >= 3) { vz->setExternalDataPtr(coordbuf); }
345 m_bp_index_grp->createViewString(
346 "coordsets/coords/path", m_bp_grp->getPathName() +
"/coordsets/coords");
348 m_bp_index_grp->getGroup(
"coordsets/coords")->copyView(
349 m_bp_grp->getView(
"coordsets/coords/type") );
351 m_bp_index_grp->createViewString(
352 "coordsets/coords/coord_system/type",
"cartesian");
356 m_bp_index_grp->createView(
"coordsets/coords/coord_system/axes/x");
360 m_bp_index_grp->createView(
"coordsets/coords/coord_system/axes/y");
365 m_bp_index_grp->createView(
"coordsets/coords/coord_system/axes/z");
369 if (m_owns_mesh_data)
371 double *coord_values =
GetNamedBuffer(
"vertex_coords")->getData();
378 void SidreDataCollection::
379 createMeshBlueprintTopologies(
bool hasBP,
const std::string& mesh_name)
381 const bool isBdry = (mesh_name ==
"boundary");
383 const int num_elements = !isBdry
387 const std::string mesh_topo_str =
"topologies/" + mesh_name;
388 const std::string mesh_attr_str = mesh_name +
"_material_attribute";
390 int element_size = 0;
393 std::string eltTypeStr =
"point";
395 if (num_elements > 0)
402 num_indices = num_elements * element_size;
407 eltTypeStr = getElementName(elem->
GetType());
413 sidre::Group* topology_grp = m_bp_grp->createGroup(mesh_topo_str);
415 topology_grp->createViewString(
"type",
"unstructured");
416 topology_grp->createViewString(
"elements/shape", eltTypeStr);
417 topology_grp->createViewAndAllocate(
418 "elements/connectivity", sidre::INT_ID, num_indices);
419 topology_grp->createViewString(
"coordset",
"coords");
425 topology_grp->createViewString(
"grid_function",m_meshNodesGFName);
433 if (num_elements > 0)
435 sidre::View* conn_view =
436 m_bp_grp->getGroup(mesh_topo_str)->getView(
"elements/connectivity");
439 Array<int> conn_array(conn_view->getData<
int*>(), num_indices);
440 Array<int>* attr_array =
attr_map.
Get(mesh_attr_str);
449 MFEM_ASSERT(!conn_array.OwnsData(),
"");
450 MFEM_ASSERT(!attr_array->OwnsData(),
"");
456 const std::string m_bp_grp_path = m_bp_grp->getPathName();
463 m_bp_index_grp->getGroup(
"topologies/mesh")
464 ->copyView( m_bp_grp->getView(
"topologies/mesh/boundary_topology") );
467 sidre::Group *bp_index_topo_grp =
468 m_bp_index_grp->createGroup(mesh_topo_str);
469 sidre::Group *topology_grp = m_bp_grp->getGroup(mesh_topo_str);
471 bp_index_topo_grp->createViewString(
472 "path", m_bp_grp_path +
"/" + mesh_topo_str);
473 bp_index_topo_grp->copyView( topology_grp->getView(
"type") );
474 bp_index_topo_grp->copyView( topology_grp->getView(
"coordset") );
480 bp_index_topo_grp->copyView(topology_grp->getView(
"grid_function"));
487 void SidreDataCollection::createMeshBlueprintAdjacencies(
bool hasBP)
489 ParMesh *pmesh =
dynamic_cast<ParMesh*
>(
mesh);
491 const int GRP_SZ = 25;
492 char group_str[GRP_SZ];
496 MFEM_VERIFY(hasBP ==
false,
"The case hasBP == true is not supported yet!");
498 sidre::Group* adjset_grp = NULL;
499 if (pmesh->GetNGroups() > 1)
501 adjset_grp = m_bp_grp->createGroup(
"adjsets/mesh");
502 adjset_grp->createViewString(
"association",
"vertex");
503 adjset_grp->createViewString(
"topology",
"mesh");
505 if (
myid == 0) { m_bp_index_grp->createGroup(
"adjsets"); }
508 for (
int gi = 1; gi < pmesh->GetNGroups(); ++gi)
510 int num_gneighbors = pmesh->gtopo.GetGroupSize(gi);
511 int num_gvertices = pmesh->GroupNVertices(gi);
514 if (num_gneighbors > 1 && num_gvertices > 0)
516 std::snprintf(group_str, GRP_SZ,
"groups/g%d_%d",
517 pmesh->gtopo.GetGroupMasterRank(gi),
518 pmesh->gtopo.GetGroupMasterGroup(gi));
519 sidre::Group* group_grp = adjset_grp->createGroup(group_str);
521 sidre::View* gneighbors_view =
522 group_grp->createViewAndAllocate(
523 "neighbors", sidre::INT_ID, num_gneighbors - 1);
524 int* gneighbors_data = gneighbors_view->getData<
int*>();
527 const int* gneighbors = pmesh->gtopo.GetGroup(gi);
528 for (
int ni = 0, noff = 0; ni < num_gneighbors; ++ni)
530 if ( gneighbors[ni] == 0 )
536 gneighbors_data[ni - noff] =
537 pmesh->gtopo.GetNeighborRank(gneighbors[ni]);
541 sidre::View* gvertices_view =
542 group_grp->createViewAndAllocate(
543 "values", sidre::INT_ID, num_gvertices);
544 int* gvertices_data = gvertices_view->getData<
int*>();
546 for (
int vi = 0; vi < num_gvertices; ++vi)
548 gvertices_data[vi] = pmesh->GroupVertex(gi, vi);
556 void SidreDataCollection::verifyMeshBlueprint()
574 MPI_Allreduce(&hasBndElts, &hasBndElts_g, 1,
575 MPI_INT, MPI_MAX,pmesh->
GetComm());
577 hasBndElts = hasBndElts_g;
581 return hasBndElts > 0?
true :
false;
590 bool hasBP = m_bp_grp->getNumViews() > 0 || m_bp_grp->getNumGroups() > 0;
593 createMeshBlueprintStubs(hasBP);
594 createMeshBlueprintState(hasBP);
595 createMeshBlueprintCoordset(hasBP);
600 createMeshBlueprintTopologies(hasBP,
"mesh");
605 m_bp_grp->createViewString(
"topologies/mesh/boundary_topology",
"boundary");
608 createMeshBlueprintTopologies(hasBP,
"boundary");
616 createMeshBlueprintAdjacencies(hasBP);
626 sidre::View *v_bp_nodes_name =
627 m_bp_grp->getView(
"topologies/mesh/grid_function");
628 std::string bp_nodes_name(v_bp_nodes_name->getString());
631 MFEM_VERIFY(m_meshNodesGFName == bp_nodes_name,
632 "mismatch of requested and blueprint mesh nodes names");
636 if (m_owns_mesh_data)
647 MFEM_ASSERT(nodes->
Size() == sz,
"");
648 std::memcpy(gfData, nodes->
GetData(),
sizeof(double) * sz);
669 MFEM_VERIFY(new_mesh->
OwnsNodes(),
"mesh does not own its nodes, "
670 "can not take ownership");
683 MPI_Comm_rank(comm, &
myid);
690 axom::sidre::Group *domain_grp)
692 MFEM_VERIFY(domain_grp->hasGroup(
"blueprint"),
693 "Domain group does not contain a blueprint group.");
695 m_bp_grp = domain_grp->getGroup(
"blueprint");
696 m_bp_index_grp = bp_index_grp;
697 m_named_bufs_grp = domain_grp->getGroup(
"named_buffers");
701 const std::string& protocol)
707 if (
m_comm != MPI_COMM_NULL)
709 axom::sidre::IOManager reader(
m_comm);
710 reader.read(m_bp_grp->getDataStore()->getRoot(), path);
715 m_bp_grp->load(path, protocol);
724 if (m_owns_datastore)
727 m_datastore_ptr->getRoot()->getGroup(
name));
736 if (
m_comm != MPI_COMM_NULL)
738 axom::sidre::IOManager reader(
m_comm);
739 reader.loadExternalData(m_bp_grp->getDataStore()->getRoot(), path);
744 m_bp_grp->loadExternalData(path);
750 SetTime( m_bp_grp->getView(
"state/time")->getData<
double>() );
751 SetCycle( m_bp_grp->getView(
"state/cycle")->getData<
int>() );
752 SetTimeStep( m_bp_grp->getView(
"state/time_step")->getData<
double>() );
757 m_bp_grp->getView(
"state/cycle")->setScalar(
GetCycle());
758 m_bp_grp->getView(
"state/time")->setScalar(
GetTime());
759 m_bp_grp->getView(
"state/time_step")->setScalar(
GetTimeStep());
763 m_bp_index_grp->getView(
"state/cycle")->setScalar(
GetCycle());
764 m_bp_index_grp->getView(
"state/time")->setScalar(
time);
770 verifyMeshBlueprint();
776 std::string filename =
name;
777 std::string protocol =
"sidre_hdf5";
779 Save(filename, protocol);
783 const std::string& protocol)
791 sidre::Group * blueprint_indicies_grp = m_bp_index_grp->getParent();
793 if (
m_comm != MPI_COMM_NULL)
795 axom::sidre::IOManager writer(
m_comm);
796 sidre::DataStore *datastore = m_bp_grp->getDataStore();
797 writer.write(datastore->getRoot(),
num_procs, file_path, protocol);
800 if (protocol ==
"sidre_hdf5")
802 writer.writeGroupToRootFile(blueprint_indicies_grp,
803 file_path +
".root");
808 writer.write(blueprint_indicies_grp, 1,
809 file_path +
".root", protocol);
817 m_bp_grp->save(file_path, protocol);
819 blueprint_indicies_grp
820 ->save(file_path +
".root", protocol);
825 void SidreDataCollection::
826 addScalarBasedGridFunction(
const std::string &field_name,
GridFunction *gf,
827 const std::string &buffer_name,
828 axom::sidre::SidreLength offset)
830 sidre::Group* grp = m_bp_grp->getGroup(
"fields/" + field_name);
831 MFEM_ASSERT(grp != NULL,
"field " << field_name <<
" does not exist");
858 MFEM_ASSERT(bv->hasBuffer() && bv->isDescribed(),
"");
861 MFEM_ASSERT(bv->getSchema().dtype().offset() == 0,
"");
862 MFEM_ASSERT(bv->getNumElements() >= offset + numDofs,
"");
866 vv->attachBuffer(bv->getBuffer())
867 ->apply(sidre::DOUBLE_ID, numDofs, offset);
876 vv->setExternalDataPtr(sidre::DOUBLE_ID, numDofs, gf->
GetData());
878 MFEM_ASSERT((numDofs > 0 && vv->isApplied()) ||
879 (numDofs == 0 && vv->isEmpty() && vv->isDescribed()),
880 "invalid View state");
881 MFEM_ASSERT(numDofs == 0 || vv->getData() == gf->
GetData(),
882 "View data is different from GridFunction data");
883 MFEM_ASSERT(vv->getNumElements() == numDofs,
884 "View size is different from GridFunction size");
888 void SidreDataCollection::
889 addVectorBasedGridFunction(
const std::string& field_name, GridFunction *gf,
890 const std::string &buffer_name,
891 axom::sidre::SidreLength offset)
893 sidre::Group* grp = m_bp_grp->getGroup(
"fields/" + field_name);
894 MFEM_ASSERT(grp != NULL,
"field " << field_name <<
" does not exist");
896 const int FLD_SZ = 20;
897 char fidxName[FLD_SZ];
899 int vdim = gf->FESpace()->GetVDim();
900 int ndof = gf->FESpace()->GetNDofs();
903 if (gf->GetData() == NULL)
926 sidre::DataType dtype = sidre::DataType::c_double(ndof);
929 dtype.set_stride(dtype.stride()*entry_stride);
934 MFEM_ASSERT(bv->hasBuffer() && bv->isDescribed(),
"");
937 MFEM_ASSERT(bv->getSchema().dtype().offset() == 0,
"");
938 dtype.set_offset(dtype.element_bytes()*offset);
940 for (
int d = 0; d < vdim; d++)
942 std::snprintf(fidxName, FLD_SZ,
"x%d", d);
943 sidre::View *xv =
alloc_view(vg, fidxName, dtype);
944 xv->attachBuffer(bv->getBuffer());
945 dtype.set_offset(dtype.offset() + dtype.element_bytes()*vdim_stride);
948 gf->NewDataAndSize(bv->getData<
double*>() + offset, vdim*ndof);
952 for (
int d = 0; d < vdim; d++)
954 std::snprintf(fidxName, FLD_SZ,
"x%d", d);
955 sidre::View *xv =
alloc_view(vg, fidxName, dtype);
956 xv->setExternalDataPtr(gf->GetData());
957 dtype.set_offset(dtype.offset() + dtype.element_bytes()*vdim_stride);
962 for (
int d = 0; d < vdim; d++)
964 std::snprintf(fidxName, FLD_SZ,
"x%d", d);
965 sidre::View *xv = vg->getView(fidxName);
966 MFEM_ASSERT((ndof > 0 && xv->isApplied()) ||
967 (ndof == 0 && xv->isEmpty() && xv->isDescribed()),
968 "invalid View state");
969 MFEM_ASSERT(ndof == 0 || xv->getData() == gf->GetData() + d*vdim_stride,
970 "View data is different from GridFunction data");
971 MFEM_ASSERT(xv->getNumElements() == ndof,
972 "View size is different from GridFunction size");
979 void SidreDataCollection::
980 RegisterFieldInBPIndex(
const std::string& field_name, GridFunction *gf)
982 sidre::Group *bp_field_grp = m_bp_grp->getGroup(
"fields/" + field_name);
983 sidre::Group *bp_index_field_grp =
984 m_bp_index_grp->createGroup(
"fields/" + field_name);
986 bp_index_field_grp->createViewString(
"path", bp_field_grp->getPathName() );
987 bp_index_field_grp->copyView( bp_field_grp->getView(
"topology") );
988 bp_index_field_grp->copyView( bp_field_grp->getView(
"basis") );
993 const int number_of_components = gf->VectorDim();
994 bp_index_field_grp->createViewScalar(
"number_of_components",
995 number_of_components);
1000 void SidreDataCollection::
1001 DeregisterFieldInBPIndex(
const std::string& field_name)
1003 sidre::Group * fields_grp = m_bp_index_grp->getGroup(
"fields");
1004 MFEM_VERIFY(fields_grp->hasGroup(field_name),
1005 "No field exists in blueprint index with name " <<
name);
1010 fields_grp->destroyGroup(field_name);
1015 const std::string &buffer_name,
1016 axom::sidre::SidreLength offset)
1018 if ( field_name.empty() || buffer_name.empty() ||
1019 gf == NULL || gf->
FESpace() == NULL )
1025 sidre::Group* f = m_bp_grp->getGroup(
"fields");
1027 if (f->hasGroup( field_name ))
1039 if (field_name != m_meshNodesGFName)
1041 MFEM_WARNING(
"field with the name '" << field_name<<
"' is already "
1042 "registered, overwriting the old field");
1049 sidre::Group* grp = f->createGroup( field_name );
1059 v =
alloc_view(grp,
"topology")->setString(
"mesh");
1062 "GridFunction size does not match FiniteElementSpace size");
1071 addScalarBasedGridFunction(field_name, gf, buffer_name, offset);
1076 addVectorBasedGridFunction(field_name, gf, buffer_name, offset);
1082 RegisterFieldInBPIndex(field_name, gf);
1094 "Need to set mesh before registering attributes in SidreDataCollection.");
1097 sidre::Group* f = m_bp_grp->getGroup(
"fields");
1098 if (f->hasGroup( attr_name ))
1105 MFEM_WARNING(
"field with the name '" << attr_name <<
"' is already "
1106 " registered as an attribute, overwriting old values.");
1111 MFEM_WARNING(
"field with the name '" << attr_name <<
"' is already "
1112 " registered as a field, skipping register attribute.");
1118 addIntegerAttributeField(attr_name, is_bdry);
1122 RegisterAttributeFieldInBPIndex(attr_name);
1127 m_bp_grp->getGroup(
"fields")->getGroup(attr_name)->getView(
"values");
1133 void SidreDataCollection::RegisterAttributeFieldInBPIndex(
1134 const std::string& attr_name)
1136 const std::string m_bp_grp_path = m_bp_grp->getPathName();
1138 MFEM_ASSERT(m_bp_grp->getGroup(
"fields") != NULL,
1139 "Mesh blueprint does not have 'fields' group");
1140 MFEM_ASSERT(m_bp_index_grp->getGroup(
"fields") != NULL,
1141 "Mesh blueprint index does not have 'fields' group");
1144 sidre::Group* attr_grp =
1145 m_bp_grp->getGroup(
"fields")->getGroup(attr_name);
1148 sidre::Group *bp_index_attr_grp =
1149 m_bp_index_grp->getGroup(
"fields")->createGroup(attr_name);
1151 bp_index_attr_grp->createViewString(
"path", attr_grp->getPathName() );
1152 bp_index_attr_grp->copyView( attr_grp->getView(
"association") );
1153 bp_index_attr_grp->copyView( attr_grp->getView(
"topology") );
1154 bp_index_attr_grp->createViewScalar(
"number_of_components", 1);
1161 sidre::Group * attr_grp = m_bp_grp->getGroup(
"fields");
1162 MFEM_VERIFY(attr_grp->hasGroup(attr_name),
1163 "No field exists in blueprint with name " << attr_name);
1170 attr_grp->destroyGroup(attr_name);
1175 DeregisterAttributeFieldInBPIndex(attr_name);
1182 void SidreDataCollection::DeregisterAttributeFieldInBPIndex(
1183 const std::string& attr_name)
1185 sidre::Group * fields_grp = m_bp_index_grp->getGroup(
"fields");
1186 MFEM_VERIFY(fields_grp->hasGroup(attr_name),
1187 "No attribute exists in blueprint index with name " << attr_name);
1192 fields_grp->destroyGroup(attr_name);
1195 void SidreDataCollection::
1196 addIntegerAttributeField(
const std::string& attr_name,
bool is_bdry)
1198 sidre::Group* fld_grp = m_bp_grp->getGroup(
"fields");
1199 MFEM_ASSERT(fld_grp != NULL,
"'fields' group does not exist");
1202 std::string topo_name = is_bdry ?
"boundary" :
"mesh";
1204 sidre::Group* attr_grp = fld_grp->createGroup(attr_name);
1205 attr_grp->createViewString(
"association",
"element");
1206 attr_grp->createViewAndAllocate(
"values", sidre::INT_ID, num_elem);
1207 attr_grp->createViewString(
"topology", topo_name);
1215 sidre::Group * fields_grp = m_bp_grp->getGroup(
"fields");
1216 MFEM_VERIFY(fields_grp->hasGroup(field_name),
1217 "No field exists in blueprint with name " << field_name);
1224 fields_grp->destroyGroup(field_name);
1229 DeregisterFieldInBPIndex(field_name);
1237 std::string SidreDataCollection::getElementName(
Element::Type elementEnum)
1244 switch (elementEnum)
axom::sidre::View * alloc_view(axom::sidre::Group *grp, const std::string &view_name)
Geometry::Type GetGeometryType() const
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
const double * GetVertex(int i) const
Return pointer to vertex i's coordinates.
void NewDataAndSize(double *d, int s)
Set the Vector data and size, deleting the old data, if owned.
Class for grid function - Vector with associated FE space.
void Load(const std::string &path, const std::string &protocol)
Load the Sidre DataStore from file.
void SetCycle(int c)
Set time cycle (for time-dependent simulations)
double GetTime() const
Get physical time (for time-dependent simulations)
bool appendRankToFileName
Append rank to any output file names.
virtual void SetMesh(Mesh *new_mesh)
Set/change the mesh associated with the collection.
void DeleteAll()
Delete data owned by the DataCollection including field information.
virtual void RegisterField(const std::string &field_name, GridFunction *gf)
Register a GridFunction in the Sidre DataStore.
int GetNBE() const
Returns number of boundary elements.
int pad_digits_cycle
Number of digits used for the cycle and MPI rank in filenames.
int Size() const
Returns the size of the vector.
int GetNE() const
Returns number of elements.
bool HasField(const std::string &name) const
Check if a grid function is part of the collection.
SidreDataCollection(const std::string &collection_name, Mesh *the_mesh=NULL, bool owns_mesh_data=false)
Constructor that allocates and initializes a Sidre DataStore.
void LoadExternalData(const std::string &path)
Load external data after registering externally owned fields.
bool Has(const std::string &fname) const
Predicate to check if a field is associated with name fname.
axom::sidre::View * AllocNamedBuffer(const std::string &buffer_name, axom::sidre::SidreLength sz, axom::sidre::TypeID type=axom::sidre::DOUBLE_ID)
Return newly allocated or existing named buffer for buffer_name.
virtual void DeregisterField(const std::string &field_name)
De-register field_name from the SidreDataCollection.
bool own_data
Should the collection delete its mesh and fields.
axom::sidre::View * GetNamedBuffer(const std::string &buffer_name) const
Get a pointer to the sidre::View holding the named buffer for buffer_name.
double * GetData() const
Return a pointer to the beginning of the Vector data.
double GetTimeStep() const
Get the simulation time step (for time-dependent simulations)
MPI_Comm m_comm
Associated MPI communicator.
double time
Physical time (for time-dependent simulations)
Mesh * mesh
The (common) mesh for the collected fields.
virtual void RegisterField(const std::string &field_name, GridFunction *gf)
Add a grid function to the collection.
bool serial
Serial or parallel run? False iff mesh is a ParMesh.
bool HasBoundaryMesh() const
int GetCycle() const
Get time cycle (for time-dependent simulations)
void RegisterAttributeField(const std::string &name, bool is_bdry)
Registers an attribute field in the Sidre DataStore.
Type
Constants for the classes derived from Element.
static int create_directory(const std::string &dir_name, const Mesh *mesh, int myid)
void SetNodesOwner(bool nodes_owner)
Set the mesh nodes ownership flag.
void Register(const std::string &fname, T *field, bool own_data)
Register field field with name fname.
const Element * GetElement(int i) const
void SetGroupPointers(axom::sidre::Group *global_grp, axom::sidre::Group *domain_grp)
Reset the domain and global datastore group pointers.
int GetVDim() const
Returns vector dimension.
FiniteElementSpace * FESpace()
void UpdateStateToDS()
Updates the data store's cycle, time, and time-step variables with the values from the SidreDataColle...
void SetTime(double t)
Set physical time (for time-dependent simulations)
void Deregister(const std::string &fname, bool own_data)
Unregister association between field field and name fname.
int SpaceDimension() const
void UpdateStateFromDS()
Updates the DataCollection's cycle, time, and time-step variables with the values from the data store...
virtual ~SidreDataCollection()
Delete all owned data.
AttributeFieldMap attr_map
int myid
MPI rank (in parallel)
std::string get_file_path(const std::string &filename) const
virtual void PrepareToSave()
Prepare the DataStore for writing.
axom::sidre::Group * alloc_group(axom::sidre::Group *grp, const std::string &group_name)
int GetNV() const
Returns number of vertices. Vertices are only at the corners of elements, where you would expect them...
void SetTimeStep(double ts)
Set the simulation time step (for time-dependent simulations)
virtual const char * Name() const
bool OwnsNodes() const
Return the mesh nodes ownership flag.
const FiniteElementSpace * GetNodalFESpace() const
void GetBdrElementData(int geom, Array< int > &bdr_elem_vtx, Array< int > &bdr_attr) const
virtual void Save()
Save the collection to file.
std::string prefix_path
A path where the directory with results is saved. If not empty, it has '/' at the end...
virtual int GetNVertices() const =0
void FreeNamedBuffer(const std::string &buffer_name)
Deallocate the named buffer buffer_name.
virtual void DeregisterField(const std::string &field_name)
Remove a grid function from the collection.
const FiniteElementCollection * FEColl() const
void GetNodes(Vector &node_coord) const
void SetComm(MPI_Comm comm)
Associate an MPI communicator with the collection.
T * Get(const std::string &fname) const
Get a pointer to the field associated with name fname.
virtual void SetMesh(Mesh *new_mesh)
Set/change the mesh associated with the collection.
void ChangeVertexDataOwnership(double *vertices, int len_vertices, bool zerocopy=false)
Set the internal Vertex array to point to the given vertices array without assuming ownership of the ...
std::string name
Name of the collection, used as a directory name when saving.
void DeleteData(bool own_data)
Clear all associations between names and fields.
int num_procs
Number of MPI ranks (in parallel)
Class for parallel meshes.
Abstract data type element.
virtual Type GetType() const =0
Returns element's type.
const Element * GetBdrElement(int i) const
void GetElementData(const Array< Element * > &elem_array, int geom, Array< int > &elem_vtx, Array< int > &attr) const
void DeregisterAttributeField(const std::string &name)
axom::sidre::Group * named_buffers_grp() const