13 #include "../config/config.hpp"
19 #include <axom/sidre.hpp>
25 namespace sidre = axom::sidre;
33 Mesh * the_mesh,
bool own_mesh_data)
35 m_owns_datastore(true),
36 m_owns_mesh_data(own_mesh_data),
37 m_meshNodesGFName(
"mesh_nodes")
39 m_datastore_ptr =
new sidre::DataStore();
41 sidre::Group * global_grp =
42 m_datastore_ptr->getRoot()->createGroup(collection_name +
"_global");
43 sidre::Group * domain_grp =
44 m_datastore_ptr->getRoot()->createGroup(collection_name);
46 m_bp_grp = domain_grp->createGroup(
"blueprint");
48 m_bp_index_grp = global_grp->createGroup(
"blueprint_index/" +
name);
50 m_named_bufs_grp = domain_grp->createGroup(
"named_buffers");
71 axom::sidre::Group* bp_index_grp,
72 axom::sidre::Group* domain_grp,
75 m_owns_datastore(false),
76 m_owns_mesh_data(own_mesh_data),
77 m_meshNodesGFName(
"mesh_nodes"),
78 m_datastore_ptr(NULL),
79 m_bp_index_grp(bp_index_grp)
81 m_bp_grp = domain_grp->createGroup(
"blueprint");
83 m_named_bufs_grp = domain_grp->createGroup(
"named_buffers");
95 delete m_datastore_ptr;
113 MFEM_ASSERT(m_named_bufs_grp != NULL,
114 "No group 'named_buffers' in data collection. Verify that"
115 " SetMesh was called to set the mesh in the data collection.");
116 return m_named_bufs_grp;
122 const std::string &view_name)
124 MFEM_ASSERT(grp,
"Group pointer is NULL");
125 sidre::View *v = NULL;
127 if (! grp->hasView(view_name) )
129 v = grp->createView(view_name);
130 MFEM_ASSERT(v,
"error allocating View " << view_name
131 <<
" in group " << grp->getPathName());
135 v = grp->getView(view_name);
144 const std::string &view_name,
145 const axom::sidre::DataType &dtype)
147 MFEM_ASSERT(grp,
"Group pointer is NULL");
148 sidre::View *v = NULL;
150 if (! grp->hasView(view_name))
152 v = grp->createView(view_name, dtype);
153 MFEM_ASSERT(v,
"error allocating View " << view_name
154 <<
" in group " << grp->getPathName());
158 v = grp->getView(view_name);
159 MFEM_ASSERT(v->getSchema().dtype().equals(dtype),
"");
167 const std::string &group_name)
169 MFEM_ASSERT(grp,
"Group pointer is NULL");
170 sidre::Group *g = NULL;
172 if (! grp->hasGroup(group_name) )
174 g = grp->createGroup(group_name);
175 MFEM_ASSERT(g,
"error allocating Group " << group_name
176 <<
" in group " << grp->getPathName());
180 g = grp->getGroup(group_name);
189 std::stringstream fNameSstr;
200 return fNameSstr.str();
205 axom::sidre::IndexType sz,
206 axom::sidre::TypeID type)
208 sz = std::max(sz, sidre::IndexType(0));
210 sidre::View *v = NULL;
212 if (! f->hasView(buffer_name) )
215 v = f->createViewAndAllocate(buffer_name, type, sz);
219 v = f->getView(buffer_name);
220 MFEM_ASSERT(v->getTypeID() == type,
"type does not match existing type");
226 if (!v->isApplied() || v->getNumElements() < sz)
230 sidre::DataType dtype(v->getSchema().dtype());
231 dtype.set_number_of_elements(sz);
232 f->destroyViewAndData(buffer_name);
233 v = f->createViewAndAllocate(buffer_name, dtype);
236 MFEM_ASSERT(v && v->isApplied(),
"allocation failed");
241 void SidreDataCollection::createMeshBlueprintStubs(
bool hasBP)
245 m_bp_grp->createGroup(
"state");
246 m_bp_grp->createGroup(
"coordsets");
247 m_bp_grp->createGroup(
"topologies");
248 m_bp_grp->createGroup(
"fields");
254 m_bp_index_grp->createGroup(
"state");
255 m_bp_index_grp->createGroup(
"coordsets");
256 m_bp_index_grp->createGroup(
"topologies");
257 m_bp_index_grp->createGroup(
"fields");
262 void SidreDataCollection::createMeshBlueprintState(
bool hasBP)
267 m_bp_grp->createViewScalar(
"state/cycle", 0);
268 m_bp_grp->createViewScalar(
"state/time", 0.);
269 m_bp_grp->createViewScalar(
"state/domain",
myid);
270 m_bp_grp->createViewScalar(
"state/time_step", 0.);
276 m_bp_index_grp->createViewScalar(
"state/cycle", 0);
277 m_bp_index_grp->createViewScalar(
"state/time", 0.);
278 m_bp_index_grp->createViewScalar(
"state/number_of_domains",
num_procs);
283 void SidreDataCollection::createMeshBlueprintCoordset(
bool hasBP)
286 MFEM_ASSERT(dim >= 1 && dim <= 3,
"invalid mesh dimension");
289 const int NUM_COORDS =
sizeof(
mfem::Vertex) /
sizeof(
double);
292 const int coordset_len = NUM_COORDS * num_vertices;
297 m_bp_grp->createViewString(
"coordsets/coords/type",
"explicit");
299 sidre::DataType dtype =
300 sidre::DataType::c_double(num_vertices);
301 const size_t stride = dtype.stride();
302 dtype.set_stride(stride*NUM_COORDS);
305 sidre::View *vx, *vy = NULL, *vz = NULL;
306 vx = m_bp_grp->createView(
"coordsets/coords/values/x", dtype);
310 dtype.set_offset(dtype.offset() + stride);
311 vy = m_bp_grp->createView(
"coordsets/coords/values/y", dtype);
315 dtype.set_offset(dtype.offset() + stride);
316 vz = m_bp_grp->createView(
"coordsets/coords/values/z", dtype);
319 if (m_owns_mesh_data)
322 sidre::Buffer* coordbuf =
325 vx->attachBuffer(coordbuf);
326 if (dim >= 2) { vy->attachBuffer(coordbuf); }
327 if (dim >= 3) { vz->attachBuffer(coordbuf); }
333 vx->setExternalDataPtr(coordbuf);
334 if (dim >= 2) { vy->setExternalDataPtr(coordbuf); }
335 if (dim >= 3) { vz->setExternalDataPtr(coordbuf); }
343 m_bp_index_grp->createViewString(
344 "coordsets/coords/path", m_bp_grp->getPathName() +
"/coordsets/coords");
346 m_bp_index_grp->getGroup(
"coordsets/coords")->copyView(
347 m_bp_grp->getView(
"coordsets/coords/type") );
349 m_bp_index_grp->createViewString(
350 "coordsets/coords/coord_system/type",
"cartesian");
354 m_bp_index_grp->createView(
"coordsets/coords/coord_system/axes/x");
358 m_bp_index_grp->createView(
"coordsets/coords/coord_system/axes/y");
363 m_bp_index_grp->createView(
"coordsets/coords/coord_system/axes/z");
367 if (m_owns_mesh_data)
369 double *coord_values =
GetNamedBuffer(
"vertex_coords")->getData();
376 void SidreDataCollection::
377 createMeshBlueprintTopologies(
bool hasBP,
const std::string& mesh_name)
379 const bool isBdry = (mesh_name ==
"boundary");
381 const int num_elements = !isBdry
385 const std::string mesh_topo_str =
"topologies/" + mesh_name;
386 const std::string mesh_attr_str = mesh_name +
"_material_attribute";
388 int element_size = 0;
391 std::string eltTypeStr =
"point";
393 if (num_elements > 0)
400 num_indices = num_elements * element_size;
405 eltTypeStr = getElementName(elem->
GetType());
411 sidre::Group* topology_grp = m_bp_grp->createGroup(mesh_topo_str);
413 topology_grp->createViewString(
"type",
"unstructured");
414 topology_grp->createViewString(
"elements/shape", eltTypeStr);
415 topology_grp->createViewAndAllocate(
416 "elements/connectivity", sidre::INT_ID, num_indices);
417 topology_grp->createViewString(
"coordset",
"coords");
423 topology_grp->createViewString(
"grid_function",m_meshNodesGFName);
431 if (num_elements > 0)
433 sidre::View* conn_view =
434 m_bp_grp->getGroup(mesh_topo_str)->getView(
"elements/connectivity");
437 Array<int> conn_array(conn_view->getData<
int*>(), num_indices);
438 Array<int>* attr_array =
attr_map.
Get(mesh_attr_str);
447 MFEM_ASSERT(!conn_array.OwnsData(),
"");
448 MFEM_ASSERT(!attr_array->OwnsData(),
"");
454 const std::string m_bp_grp_path = m_bp_grp->getPathName();
461 m_bp_index_grp->getGroup(
"topologies/mesh")
462 ->copyView( m_bp_grp->getView(
"topologies/mesh/boundary_topology") );
465 sidre::Group *bp_index_topo_grp =
466 m_bp_index_grp->createGroup(mesh_topo_str);
467 sidre::Group *topology_grp = m_bp_grp->getGroup(mesh_topo_str);
469 bp_index_topo_grp->createViewString(
470 "path", m_bp_grp_path +
"/" + mesh_topo_str);
471 bp_index_topo_grp->copyView( topology_grp->getView(
"type") );
472 bp_index_topo_grp->copyView( topology_grp->getView(
"coordset") );
478 bp_index_topo_grp->copyView(topology_grp->getView(
"grid_function"));
485 void SidreDataCollection::createMeshBlueprintAdjacencies(
bool hasBP)
489 const int GRP_SZ = 25;
490 char group_str[GRP_SZ];
494 MFEM_VERIFY(hasBP ==
false,
"The case hasBP == true is not supported yet!");
496 sidre::Group* adjset_grp = NULL;
497 if (pmesh->GetNGroups() > 1)
499 adjset_grp = m_bp_grp->createGroup(
"adjsets/mesh");
500 adjset_grp->createViewString(
"association",
"vertex");
501 adjset_grp->createViewString(
"topology",
"mesh");
503 if (
myid == 0) { m_bp_index_grp->createGroup(
"adjsets"); }
506 for (
int gi = 1; gi < pmesh->GetNGroups(); ++gi)
508 int num_gneighbors = pmesh->gtopo.GetGroupSize(gi);
509 int num_gvertices = pmesh->GroupNVertices(gi);
512 if (num_gneighbors > 1 && num_gvertices > 0)
514 std::snprintf(group_str, GRP_SZ,
"groups/g%d_%d",
515 pmesh->gtopo.GetGroupMasterRank(gi),
516 pmesh->gtopo.GetGroupMasterGroup(gi));
517 sidre::Group* group_grp = adjset_grp->createGroup(group_str);
519 sidre::View* gneighbors_view =
520 group_grp->createViewAndAllocate(
521 "neighbors", sidre::INT_ID, num_gneighbors - 1);
522 int* gneighbors_data = gneighbors_view->getData<
int*>();
525 const int* gneighbors = pmesh->gtopo.GetGroup(gi);
526 for (
int ni = 0, noff = 0; ni < num_gneighbors; ++ni)
528 if ( gneighbors[ni] == 0 )
534 gneighbors_data[ni - noff] =
535 pmesh->gtopo.GetNeighborRank(gneighbors[ni]);
539 sidre::View* gvertices_view =
540 group_grp->createViewAndAllocate(
541 "values", sidre::INT_ID, num_gvertices);
542 int* gvertices_data = gvertices_view->getData<
int*>();
544 for (
int vi = 0; vi < num_gvertices; ++vi)
546 gvertices_data[vi] = pmesh->GroupVertex(gi, vi);
554 void SidreDataCollection::verifyMeshBlueprint()
572 MPI_Allreduce(&hasBndElts, &hasBndElts_g, 1,
573 MPI_INT, MPI_MAX,pmesh->
GetComm());
575 hasBndElts = hasBndElts_g;
579 return hasBndElts > 0?
true :
false;
588 bool hasBP = m_bp_grp->getNumViews() > 0 || m_bp_grp->getNumGroups() > 0;
591 createMeshBlueprintStubs(hasBP);
592 createMeshBlueprintState(hasBP);
593 createMeshBlueprintCoordset(hasBP);
598 createMeshBlueprintTopologies(hasBP,
"mesh");
603 m_bp_grp->createViewString(
"topologies/mesh/boundary_topology",
"boundary");
606 createMeshBlueprintTopologies(hasBP,
"boundary");
614 createMeshBlueprintAdjacencies(hasBP);
624 sidre::View *v_bp_nodes_name =
625 m_bp_grp->getView(
"topologies/mesh/grid_function");
626 std::string bp_nodes_name(v_bp_nodes_name->getString());
629 MFEM_VERIFY(m_meshNodesGFName == bp_nodes_name,
630 "mismatch of requested and blueprint mesh nodes names");
634 if (m_owns_mesh_data)
645 MFEM_ASSERT(nodes->
Size() == sz,
"");
646 std::memcpy(gfData, nodes->
GetData(),
sizeof(double) * sz);
667 MFEM_VERIFY(new_mesh->
OwnsNodes(),
"mesh does not own its nodes, "
668 "can not take ownership");
681 MPI_Comm_rank(comm, &
myid);
688 axom::sidre::Group *domain_grp)
690 MFEM_VERIFY(domain_grp->hasGroup(
"blueprint"),
691 "Domain group does not contain a blueprint group.");
693 m_bp_grp = domain_grp->getGroup(
"blueprint");
694 m_bp_index_grp = bp_index_grp;
695 m_named_bufs_grp = domain_grp->getGroup(
"named_buffers");
699 const std::string& protocol)
705 if (
m_comm != MPI_COMM_NULL)
707 axom::sidre::IOManager reader(
m_comm);
708 reader.read(m_bp_grp->getDataStore()->getRoot(), path);
713 m_bp_grp->load(path, protocol);
722 if (m_owns_datastore)
725 m_datastore_ptr->getRoot()->getGroup(
name));
734 if (
m_comm != MPI_COMM_NULL)
736 axom::sidre::IOManager reader(
m_comm);
737 reader.loadExternalData(m_bp_grp->getDataStore()->getRoot(), path);
742 m_bp_grp->loadExternalData(path);
748 SetTime( m_bp_grp->getView(
"state/time")->getData<
double>() );
749 SetCycle( m_bp_grp->getView(
"state/cycle")->getData<
int>() );
750 SetTimeStep( m_bp_grp->getView(
"state/time_step")->getData<
double>() );
755 m_bp_grp->getView(
"state/cycle")->setScalar(
GetCycle());
756 m_bp_grp->getView(
"state/time")->setScalar(
GetTime());
757 m_bp_grp->getView(
"state/time_step")->setScalar(
GetTimeStep());
761 m_bp_index_grp->getView(
"state/cycle")->setScalar(
GetCycle());
762 m_bp_index_grp->getView(
"state/time")->setScalar(
time);
768 verifyMeshBlueprint();
774 std::string filename =
name;
775 std::string protocol =
"sidre_hdf5";
777 Save(filename, protocol);
781 const std::string& protocol)
789 sidre::Group * blueprint_indicies_grp = m_bp_index_grp->getParent();
791 if (
m_comm != MPI_COMM_NULL)
793 axom::sidre::IOManager writer(
m_comm);
794 sidre::DataStore *datastore = m_bp_grp->getDataStore();
795 writer.write(datastore->getRoot(),
num_procs, file_path, protocol);
798 if (protocol ==
"sidre_hdf5")
800 writer.writeGroupToRootFile(blueprint_indicies_grp,
801 file_path +
".root");
806 writer.write(blueprint_indicies_grp, 1,
807 file_path +
".root", protocol);
815 m_bp_grp->save(file_path, protocol);
817 blueprint_indicies_grp
818 ->save(file_path +
".root", protocol);
823 void SidreDataCollection::
824 addScalarBasedGridFunction(
const std::string &field_name,
GridFunction *gf,
825 const std::string &buffer_name,
826 axom::sidre::IndexType offset)
828 sidre::Group* grp = m_bp_grp->getGroup(
"fields/" + field_name);
829 MFEM_ASSERT(grp != NULL,
"field " << field_name <<
" does not exist");
856 MFEM_ASSERT(bv->hasBuffer() && bv->isDescribed(),
"");
859 MFEM_ASSERT(bv->getSchema().dtype().offset() == 0,
"");
860 MFEM_ASSERT(bv->getNumElements() >= offset + numDofs,
"");
864 vv->attachBuffer(bv->getBuffer())
865 ->apply(sidre::DOUBLE_ID, numDofs, offset);
874 vv->setExternalDataPtr(sidre::DOUBLE_ID, numDofs, gf->
GetData());
876 MFEM_ASSERT((numDofs > 0 && vv->isApplied()) ||
877 (numDofs == 0 && vv->isEmpty() && vv->isDescribed()),
878 "invalid View state");
879 MFEM_ASSERT(numDofs == 0 || vv->getData() == gf->
GetData(),
880 "View data is different from GridFunction data");
881 MFEM_ASSERT(vv->getNumElements() == numDofs,
882 "View size is different from GridFunction size");
886 void SidreDataCollection::
887 addVectorBasedGridFunction(
const std::string& field_name, GridFunction *gf,
888 const std::string &buffer_name,
889 axom::sidre::IndexType offset)
891 sidre::Group* grp = m_bp_grp->getGroup(
"fields/" + field_name);
892 MFEM_ASSERT(grp != NULL,
"field " << field_name <<
" does not exist");
894 const int FLD_SZ = 20;
895 char fidxName[FLD_SZ];
897 int vdim = gf->FESpace()->GetVDim();
898 int ndof = gf->FESpace()->GetNDofs();
901 if (gf->GetData() == NULL)
924 sidre::DataType dtype = sidre::DataType::c_double(ndof);
927 dtype.set_stride(dtype.stride()*entry_stride);
932 MFEM_ASSERT(bv->hasBuffer() && bv->isDescribed(),
"");
935 MFEM_ASSERT(bv->getSchema().dtype().offset() == 0,
"");
936 dtype.set_offset(dtype.element_bytes()*offset);
938 for (
int d = 0; d < vdim; d++)
940 std::snprintf(fidxName, FLD_SZ,
"x%d", d);
941 sidre::View *xv =
alloc_view(vg, fidxName, dtype);
942 xv->attachBuffer(bv->getBuffer());
943 dtype.set_offset(dtype.offset() + dtype.element_bytes()*vdim_stride);
946 gf->NewDataAndSize(bv->getData<
double*>() + offset, vdim*ndof);
950 for (
int d = 0; d < vdim; d++)
952 std::snprintf(fidxName, FLD_SZ,
"x%d", d);
953 sidre::View *xv =
alloc_view(vg, fidxName, dtype);
954 xv->setExternalDataPtr(gf->GetData());
955 dtype.set_offset(dtype.offset() + dtype.element_bytes()*vdim_stride);
960 for (
int d = 0; d < vdim; d++)
962 std::snprintf(fidxName, FLD_SZ,
"x%d", d);
963 sidre::View *xv = vg->getView(fidxName);
964 MFEM_ASSERT((ndof > 0 && xv->isApplied()) ||
965 (ndof == 0 && xv->isEmpty() && xv->isDescribed()),
966 "invalid View state");
967 MFEM_ASSERT(ndof == 0 || xv->getData() == gf->GetData() + d*vdim_stride,
968 "View data is different from GridFunction data");
969 MFEM_ASSERT(xv->getNumElements() == ndof,
970 "View size is different from GridFunction size");
977 void SidreDataCollection::
978 RegisterFieldInBPIndex(
const std::string& field_name, GridFunction *gf)
980 sidre::Group *bp_field_grp = m_bp_grp->getGroup(
"fields/" + field_name);
981 sidre::Group *bp_index_field_grp =
982 m_bp_index_grp->createGroup(
"fields/" + field_name);
984 bp_index_field_grp->createViewString(
"path", bp_field_grp->getPathName() );
985 bp_index_field_grp->copyView( bp_field_grp->getView(
"topology") );
986 bp_index_field_grp->copyView( bp_field_grp->getView(
"basis") );
991 const int number_of_components = gf->VectorDim();
992 bp_index_field_grp->createViewScalar(
"number_of_components",
993 number_of_components);
998 void SidreDataCollection::
999 DeregisterFieldInBPIndex(
const std::string& field_name)
1001 sidre::Group * fields_grp = m_bp_index_grp->getGroup(
"fields");
1002 MFEM_VERIFY(fields_grp->hasGroup(field_name),
1003 "No field exists in blueprint index with name " <<
name);
1008 fields_grp->destroyGroup(field_name);
1013 const std::string &buffer_name,
1014 axom::sidre::IndexType offset)
1016 if ( field_name.empty() || buffer_name.empty() ||
1017 gf == NULL || gf->
FESpace() == NULL )
1023 sidre::Group*
f = m_bp_grp->getGroup(
"fields");
1025 if (f->hasGroup( field_name ))
1037 if (field_name != m_meshNodesGFName)
1039 MFEM_WARNING(
"field with the name '" << field_name<<
"' is already "
1040 "registered, overwriting the old field");
1047 sidre::Group* grp = f->createGroup( field_name );
1057 v =
alloc_view(grp,
"topology")->setString(
"mesh");
1060 "GridFunction size does not match FiniteElementSpace size");
1069 addScalarBasedGridFunction(field_name, gf, buffer_name, offset);
1074 addVectorBasedGridFunction(field_name, gf, buffer_name, offset);
1080 RegisterFieldInBPIndex(field_name, gf);
1092 "Need to set mesh before registering attributes in SidreDataCollection.");
1095 sidre::Group*
f = m_bp_grp->getGroup(
"fields");
1096 if (f->hasGroup( attr_name ))
1103 MFEM_WARNING(
"field with the name '" << attr_name <<
"' is already "
1104 " registered as an attribute, overwriting old values.");
1109 MFEM_WARNING(
"field with the name '" << attr_name <<
"' is already "
1110 " registered as a field, skipping register attribute.");
1116 addIntegerAttributeField(attr_name, is_bdry);
1120 RegisterAttributeFieldInBPIndex(attr_name);
1125 m_bp_grp->getGroup(
"fields")->getGroup(attr_name)->getView(
"values");
1131 void SidreDataCollection::RegisterAttributeFieldInBPIndex(
1132 const std::string& attr_name)
1134 const std::string m_bp_grp_path = m_bp_grp->getPathName();
1136 MFEM_ASSERT(m_bp_grp->getGroup(
"fields") != NULL,
1137 "Mesh blueprint does not have 'fields' group");
1138 MFEM_ASSERT(m_bp_index_grp->getGroup(
"fields") != NULL,
1139 "Mesh blueprint index does not have 'fields' group");
1142 sidre::Group* attr_grp =
1143 m_bp_grp->getGroup(
"fields")->getGroup(attr_name);
1146 sidre::Group *bp_index_attr_grp =
1147 m_bp_index_grp->getGroup(
"fields")->createGroup(attr_name);
1149 bp_index_attr_grp->createViewString(
"path", attr_grp->getPathName() );
1150 bp_index_attr_grp->copyView( attr_grp->getView(
"association") );
1151 bp_index_attr_grp->copyView( attr_grp->getView(
"topology") );
1152 bp_index_attr_grp->createViewScalar(
"number_of_components", 1);
1159 sidre::Group * attr_grp = m_bp_grp->getGroup(
"fields");
1160 MFEM_VERIFY(attr_grp->hasGroup(attr_name),
1161 "No field exists in blueprint with name " << attr_name);
1168 attr_grp->destroyGroup(attr_name);
1173 DeregisterAttributeFieldInBPIndex(attr_name);
1180 void SidreDataCollection::DeregisterAttributeFieldInBPIndex(
1181 const std::string& attr_name)
1183 sidre::Group * fields_grp = m_bp_index_grp->getGroup(
"fields");
1184 MFEM_VERIFY(fields_grp->hasGroup(attr_name),
1185 "No attribute exists in blueprint index with name " << attr_name);
1190 fields_grp->destroyGroup(attr_name);
1193 void SidreDataCollection::
1194 addIntegerAttributeField(
const std::string& attr_name,
bool is_bdry)
1196 sidre::Group* fld_grp = m_bp_grp->getGroup(
"fields");
1197 MFEM_ASSERT(fld_grp != NULL,
"'fields' group does not exist");
1200 std::string topo_name = is_bdry ?
"boundary" :
"mesh";
1202 sidre::Group* attr_grp = fld_grp->createGroup(attr_name);
1203 attr_grp->createViewString(
"association",
"element");
1204 attr_grp->createViewAndAllocate(
"values", sidre::INT_ID, num_elem);
1205 attr_grp->createViewString(
"topology", topo_name);
1213 sidre::Group * fields_grp = m_bp_grp->getGroup(
"fields");
1214 MFEM_VERIFY(fields_grp->hasGroup(field_name),
1215 "No field exists in blueprint with name " << field_name);
1222 fields_grp->destroyGroup(field_name);
1227 DeregisterFieldInBPIndex(field_name);
1235 std::string SidreDataCollection::getElementName(
Element::Type elementEnum)
1242 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.
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.
axom::sidre::View * AllocNamedBuffer(const std::string &buffer_name, axom::sidre::IndexType sz, axom::sidre::TypeID type=axom::sidre::DOUBLE_ID)
Return newly allocated or existing named buffer for buffer_name.
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
double f(const Vector &p)