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 bp_grp = domain_grp->createGroup(
"blueprint");
50 bp_index_grp = global_grp->createGroup(
"blueprint_index/" +
name);
52 named_bufs_grp = domain_grp->createGroup(
"named_buffers");
73 axom::sidre::Group* global_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"),
82 bp_grp = domain_grp->createGroup(
"blueprint");
85 bp_index_grp = global_grp->createGroup(
"blueprint_index/" +
name);
87 named_bufs_grp = domain_grp->createGroup(
"named_buffers");
98 delete m_datastore_ptr;
116 MFEM_ASSERT(named_bufs_grp != NULL,
117 "No group 'named_buffers' in data collection. Verify that"
118 " SetMesh was called to set the mesh in the data collection.");
119 return named_bufs_grp;
125 const std::string &view_name)
127 MFEM_ASSERT(grp,
"Group pointer is NULL");
128 sidre::View *v = NULL;
130 if (! grp->hasView(view_name) )
132 v = grp->createView(view_name);
133 MFEM_ASSERT(v,
"error allocating View " << view_name
134 <<
" in group " << grp->getPathName());
138 v = grp->getView(view_name);
147 const std::string &view_name,
148 const axom::sidre::DataType &dtype)
150 MFEM_ASSERT(grp,
"Group pointer is NULL");
151 sidre::View *v = NULL;
153 if (! grp->hasView(view_name))
155 v = grp->createView(view_name, dtype);
156 MFEM_ASSERT(v,
"error allocating View " << view_name
157 <<
" in group " << grp->getPathName());
161 v = grp->getView(view_name);
162 MFEM_ASSERT(v->getSchema().dtype().equals(dtype),
"");
170 const std::string &group_name)
172 MFEM_ASSERT(grp,
"Group pointer is NULL");
173 sidre::Group *g = NULL;
175 if (! grp->hasGroup(group_name) )
177 g = grp->createGroup(group_name);
178 MFEM_ASSERT(g,
"error allocating Group " << group_name
179 <<
" in group " << grp->getPathName());
183 g = grp->getGroup(group_name);
192 std::stringstream fNameSstr;
203 return fNameSstr.str();
208 axom::sidre::SidreLength sz,
209 axom::sidre::TypeID type)
211 sz = std::max(sz, sidre::SidreLength(0));
213 sidre::View *v = NULL;
215 if (! f->hasView(buffer_name) )
218 v = f->createViewAndAllocate(buffer_name, type, sz);
222 v = f->getView(buffer_name);
223 MFEM_ASSERT(v->getTypeID() == type,
"type does not match existing type");
229 if (!v->isApplied() || v->getNumElements() < sz)
233 sidre::DataType dtype(v->getSchema().dtype());
234 dtype.set_number_of_elements(sz);
235 f->destroyViewAndData(buffer_name);
236 v = f->createViewAndAllocate(buffer_name, dtype);
239 MFEM_ASSERT(v && v->isApplied(),
"allocation failed");
244 void SidreDataCollection::createMeshBlueprintStubs(
bool hasBP)
248 bp_grp->createGroup(
"state");
249 bp_grp->createGroup(
"coordsets");
250 bp_grp->createGroup(
"topologies");
251 bp_grp->createGroup(
"fields");
257 bp_index_grp->createGroup(
"state");
258 bp_index_grp->createGroup(
"coordsets");
259 bp_index_grp->createGroup(
"topologies");
260 bp_index_grp->createGroup(
"fields");
265 void SidreDataCollection::createMeshBlueprintState(
bool hasBP)
270 bp_grp->createViewScalar(
"state/cycle", 0);
271 bp_grp->createViewScalar(
"state/time", 0.);
272 bp_grp->createViewScalar(
"state/domain",
myid);
273 bp_grp->createViewScalar(
"state/time_step", 0.);
279 bp_index_grp->createViewScalar(
"state/cycle", 0);
280 bp_index_grp->createViewScalar(
"state/time", 0.);
281 bp_index_grp->createViewScalar(
"state/number_of_domains",
num_procs);
286 void SidreDataCollection::createMeshBlueprintCoordset(
bool hasBP)
289 MFEM_ASSERT(dim >= 1 && dim <= 3,
"invalid mesh dimension");
292 const int NUM_COORDS =
sizeof(
mfem::Vertex) /
sizeof(
double);
295 const int coordset_len = NUM_COORDS * num_vertices;
300 bp_grp->createViewString(
"coordsets/coords/type",
"explicit");
302 sidre::DataType dtype =
303 sidre::DataType::c_double(num_vertices);
304 const size_t stride = dtype.stride();
305 dtype.set_stride(stride*NUM_COORDS);
308 sidre::View *vx, *vy = NULL, *vz = NULL;
309 vx = bp_grp->createView(
"coordsets/coords/values/x", dtype);
313 dtype.set_offset(dtype.offset() + stride);
314 vy = bp_grp->createView(
"coordsets/coords/values/y", dtype);
318 dtype.set_offset(dtype.offset() + stride);
319 vz = bp_grp->createView(
"coordsets/coords/values/z", dtype);
322 if (m_owns_mesh_data)
325 sidre::Buffer* coordbuf =
328 vx->attachBuffer(coordbuf);
329 if (dim >= 2) { vy->attachBuffer(coordbuf); }
330 if (dim >= 3) { vz->attachBuffer(coordbuf); }
336 vx->setExternalDataPtr(coordbuf);
337 if (dim >= 2) { vy->setExternalDataPtr(coordbuf); }
338 if (dim >= 3) { vz->setExternalDataPtr(coordbuf); }
346 bp_index_grp->createViewString(
347 "coordsets/coords/path", bp_grp->getPathName() +
"/coordsets/coords");
349 bp_index_grp->getGroup(
"coordsets/coords")->copyView(
350 bp_grp->getView(
"coordsets/coords/type") );
352 bp_index_grp->createViewString(
353 "coordsets/coords/coord_system/type",
"cartesian");
357 bp_index_grp->createView(
"coordsets/coords/coord_system/axes/x");
361 bp_index_grp->createView(
"coordsets/coords/coord_system/axes/y");
366 bp_index_grp->createView(
"coordsets/coords/coord_system/axes/z");
370 if (m_owns_mesh_data)
372 double *coord_values =
GetNamedBuffer(
"vertex_coords")->getData();
379 void SidreDataCollection::
380 createMeshBlueprintTopologies(
bool hasBP,
const std::string& mesh_name)
382 const bool isBdry = (mesh_name ==
"boundary");
384 const int num_elements = !isBdry
388 const std::string mesh_topo_str =
"topologies/" + mesh_name;
389 const std::string mesh_attr_str = mesh_name +
"_material_attribute";
391 int element_size = 0;
394 std::string eltTypeStr =
"point";
396 if (num_elements > 0)
398 element_size = !isBdry
402 num_indices = num_elements * element_size;
411 ? getElementName( static_cast<Element::Type>(
413 : getElementName( static_cast<Element::Type>(
414 mesh->GetBdrElement(0)->GetType() ) );
420 sidre::Group* topology_grp = bp_grp->createGroup(mesh_topo_str);
422 topology_grp->createViewString(
"type",
"unstructured");
423 topology_grp->createViewString(
"elements/shape", eltTypeStr);
424 topology_grp->createViewAndAllocate(
425 "elements/connectivity", sidre::INT_ID, num_indices);
426 topology_grp->createViewString(
"coordset",
"coords");
432 topology_grp->createViewString(
"grid_function",m_meshNodesGFName);
440 if (num_elements > 0)
442 sidre::View* conn_view =
443 bp_grp->getGroup(mesh_topo_str)->getView(
"elements/connectivity");
446 Array<int> conn_array(conn_view->getData<
int*>(), num_indices);
447 Array<int>* attr_array =
attr_map.
Get(mesh_attr_str);
456 MFEM_ASSERT(!conn_array.OwnsData(),
"");
457 MFEM_ASSERT(!attr_array->OwnsData(),
"");
463 const std::string bp_grp_path = bp_grp->getPathName();
470 bp_index_grp->getGroup(
"topologies/mesh")
471 ->copyView( bp_grp->getView(
"topologies/mesh/boundary_topology") );
474 sidre::Group *bp_index_topo_grp =
475 bp_index_grp->createGroup(mesh_topo_str);
476 sidre::Group *topology_grp = bp_grp->getGroup(mesh_topo_str);
478 bp_index_topo_grp->createViewString(
479 "path", bp_grp_path +
"/" + mesh_topo_str);
480 bp_index_topo_grp->copyView( topology_grp->getView(
"type") );
481 bp_index_topo_grp->copyView( topology_grp->getView(
"coordset") );
487 bp_index_topo_grp->copyView(topology_grp->getView(
"grid_function"));
494 void SidreDataCollection::createMeshBlueprintAdjacencies(
bool hasBP)
496 ParMesh *pmesh =
dynamic_cast<ParMesh*
>(
mesh);
498 const int GRP_SZ = 25;
499 char group_str[GRP_SZ];
503 MFEM_VERIFY(hasBP ==
false,
"The case hasBP == true is not supported yet!");
505 sidre::Group* adjset_grp = NULL;
506 if (pmesh->GetNGroups() > 1)
508 adjset_grp = bp_grp->createGroup(
"adjsets/mesh");
509 adjset_grp->createViewString(
"association",
"vertex");
510 adjset_grp->createViewString(
"topology",
"mesh");
512 if (
myid == 0) { bp_index_grp->createGroup(
"adjsets"); }
515 for (
int gi = 1; gi < pmesh->GetNGroups(); ++gi)
517 int num_gneighbors = pmesh->gtopo.GetGroupSize(gi);
518 int num_gvertices = pmesh->GroupNVertices(gi);
521 if (num_gneighbors > 1 && num_gvertices > 0)
523 std::snprintf(group_str, GRP_SZ,
"groups/g%d_%d",
524 pmesh->gtopo.GetGroupMasterRank(gi),
525 pmesh->gtopo.GetGroupMasterGroup(gi));
526 sidre::Group* group_grp = adjset_grp->createGroup(group_str);
528 sidre::View* gneighbors_view =
529 group_grp->createViewAndAllocate(
530 "neighbors", sidre::INT_ID, num_gneighbors - 1);
531 int* gneighbors_data = gneighbors_view->getData<
int*>();
534 const int* gneighbors = pmesh->gtopo.GetGroup(gi);
535 for (
int ni = 0, noff = 0; ni < num_gneighbors; ++ni)
537 if ( gneighbors[ni] == 0 )
543 gneighbors_data[ni - noff] =
544 pmesh->gtopo.GetNeighborRank(gneighbors[ni]);
548 sidre::View* gvertices_view =
549 group_grp->createViewAndAllocate(
550 "values", sidre::INT_ID, num_gvertices);
551 int* gvertices_data = gvertices_view->getData<
int*>();
553 for (
int vi = 0; vi < num_gvertices; ++vi)
555 gvertices_data[vi] = pmesh->GroupVertex(gi, vi);
563 void SidreDataCollection::verifyMeshBlueprint()
581 MPI_Allreduce(&hasBndElts, &hasBndElts_g, 1,
582 MPI_INT, MPI_MAX,pmesh->
GetComm());
584 hasBndElts = hasBndElts_g;
588 return hasBndElts > 0?
true :
false;
597 bool hasBP = bp_grp->getNumViews() > 0 || bp_grp->getNumGroups() > 0;
600 createMeshBlueprintStubs(hasBP);
601 createMeshBlueprintState(hasBP);
602 createMeshBlueprintCoordset(hasBP);
607 createMeshBlueprintTopologies(hasBP,
"mesh");
612 bp_grp->createViewString(
"topologies/mesh/boundary_topology",
"boundary");
615 createMeshBlueprintTopologies(hasBP,
"boundary");
623 createMeshBlueprintAdjacencies(hasBP);
633 sidre::View *v_bp_nodes_name =
634 bp_grp->getView(
"topologies/mesh/grid_function");
635 std::string bp_nodes_name(v_bp_nodes_name->getString());
638 MFEM_VERIFY(m_meshNodesGFName == bp_nodes_name,
639 "mismatch of requested and blueprint mesh nodes names");
643 if (m_owns_mesh_data)
654 MFEM_ASSERT(nodes->
Size() == sz,
"");
655 std::memcpy(gfData, nodes->
GetData(),
sizeof(double) * sz);
676 MFEM_VERIFY(new_mesh->
OwnsNodes(),
"mesh does not own its nodes, "
677 "can not take ownership");
690 MPI_Comm_rank(comm, &
myid);
697 axom::sidre::Group *domain_grp)
699 MFEM_VERIFY(domain_grp->hasGroup(
"blueprint"),
700 "Domain group does not contain a blueprint group.");
701 MFEM_VERIFY(global_grp->hasGroup(
"blueprint_index/" +
name),
702 "Global group does not contain a blueprint index group.");
704 bp_grp = domain_grp->getGroup(
"blueprint");
705 bp_index_grp = global_grp->getGroup(
"blueprint_index/" +
name);
706 named_bufs_grp = domain_grp->getGroup(
"named_buffers");
710 const std::string& protocol)
716 if (
m_comm != MPI_COMM_NULL)
718 axom::sidre::IOManager reader(
m_comm);
719 reader.read(bp_grp->getDataStore()->getRoot(), path);
724 bp_grp->load(path, protocol);
733 if (m_owns_datastore)
736 m_datastore_ptr->getRoot()->getGroup(
name));
745 if (
m_comm != MPI_COMM_NULL)
747 axom::sidre::IOManager reader(
m_comm);
748 reader.loadExternalData(bp_grp->getDataStore()->getRoot(), path);
753 bp_grp->loadExternalData(path);
759 SetTime( bp_grp->getView(
"state/time")->getData<
double>() );
760 SetCycle( bp_grp->getView(
"state/cycle")->getData<
int>() );
761 SetTimeStep( bp_grp->getView(
"state/time_step")->getData<
double>() );
766 bp_grp->getView(
"state/cycle")->setScalar(
GetCycle());
767 bp_grp->getView(
"state/time")->setScalar(
GetTime());
768 bp_grp->getView(
"state/time_step")->setScalar(
GetTimeStep());
772 bp_index_grp->getView(
"state/cycle")->setScalar(
GetCycle());
773 bp_index_grp->getView(
"state/time")->setScalar(
time);
779 verifyMeshBlueprint();
785 std::string filename =
name;
786 std::string protocol =
"sidre_hdf5";
788 Save(filename, protocol);
792 const std::string& protocol)
800 sidre::Group * blueprint_indicies_grp = bp_index_grp->getParent();
802 if (
m_comm != MPI_COMM_NULL)
804 axom::sidre::IOManager writer(
m_comm);
805 sidre::DataStore *datastore = bp_grp->getDataStore();
806 writer.write(datastore->getRoot(),
num_procs, file_path, protocol);
809 if (protocol ==
"sidre_hdf5")
811 writer.writeGroupToRootFile(blueprint_indicies_grp,
812 file_path +
".root");
817 writer.write(blueprint_indicies_grp, 1,
818 file_path +
".root", protocol);
826 bp_grp->save(file_path, protocol);
828 blueprint_indicies_grp
829 ->save(file_path +
".root", protocol);
834 void SidreDataCollection::
835 addScalarBasedGridFunction(
const std::string &field_name,
GridFunction *gf,
836 const std::string &buffer_name,
837 axom::sidre::SidreLength offset)
839 sidre::Group* grp = bp_grp->getGroup(
"fields/" + field_name);
840 MFEM_ASSERT(grp != NULL,
"field " << field_name <<
" does not exist");
867 MFEM_ASSERT(bv->hasBuffer() && bv->isDescribed(),
"");
870 MFEM_ASSERT(bv->getSchema().dtype().offset() == 0,
"");
871 MFEM_ASSERT(bv->getNumElements() >= offset + numDofs,
"");
875 vv->attachBuffer(bv->getBuffer())
876 ->apply(sidre::DOUBLE_ID, numDofs, offset);
885 vv->setExternalDataPtr(sidre::DOUBLE_ID, numDofs, gf->
GetData());
887 MFEM_ASSERT((numDofs > 0 && vv->isApplied()) ||
888 (numDofs == 0 && vv->isEmpty() && vv->isDescribed()),
889 "invalid View state");
890 MFEM_ASSERT(numDofs == 0 || vv->getData() == gf->
GetData(),
891 "View data is different from GridFunction data");
892 MFEM_ASSERT(vv->getNumElements() == numDofs,
893 "View size is different from GridFunction size");
897 void SidreDataCollection::
898 addVectorBasedGridFunction(
const std::string& field_name, GridFunction *gf,
899 const std::string &buffer_name,
900 axom::sidre::SidreLength offset)
902 sidre::Group* grp = bp_grp->getGroup(
"fields/" + field_name);
903 MFEM_ASSERT(grp != NULL,
"field " << field_name <<
" does not exist");
905 const int FLD_SZ = 20;
906 char fidxName[FLD_SZ];
908 int vdim = gf->FESpace()->GetVDim();
909 int ndof = gf->FESpace()->GetNDofs();
912 if (gf->GetData() == NULL)
935 sidre::DataType dtype = sidre::DataType::c_double(ndof);
938 dtype.set_stride(dtype.stride()*entry_stride);
943 MFEM_ASSERT(bv->hasBuffer() && bv->isDescribed(),
"");
946 MFEM_ASSERT(bv->getSchema().dtype().offset() == 0,
"");
947 dtype.set_offset(dtype.element_bytes()*offset);
949 for (
int d = 0; d < vdim; d++)
951 std::snprintf(fidxName, FLD_SZ,
"x%d", d);
952 sidre::View *xv =
alloc_view(vg, fidxName, dtype);
953 xv->attachBuffer(bv->getBuffer());
954 dtype.set_offset(dtype.offset() + dtype.element_bytes()*vdim_stride);
957 gf->NewDataAndSize(bv->getData<
double*>() + offset, vdim*ndof);
961 for (
int d = 0; d < vdim; d++)
963 std::snprintf(fidxName, FLD_SZ,
"x%d", d);
964 sidre::View *xv =
alloc_view(vg, fidxName, dtype);
965 xv->setExternalDataPtr(gf->GetData());
966 dtype.set_offset(dtype.offset() + dtype.element_bytes()*vdim_stride);
971 for (
int d = 0; d < vdim; d++)
973 std::snprintf(fidxName, FLD_SZ,
"x%d", d);
974 sidre::View *xv = vg->getView(fidxName);
975 MFEM_ASSERT((ndof > 0 && xv->isApplied()) ||
976 (ndof == 0 && xv->isEmpty() && xv->isDescribed()),
977 "invalid View state");
978 MFEM_ASSERT(ndof == 0 || xv->getData() == gf->GetData() + d*vdim_stride,
979 "View data is different from GridFunction data");
980 MFEM_ASSERT(xv->getNumElements() == ndof,
981 "View size is different from GridFunction size");
988 void SidreDataCollection::
989 RegisterFieldInBPIndex(
const std::string& field_name, GridFunction *gf)
991 sidre::Group *bp_field_grp = bp_grp->getGroup(
"fields/" + field_name);
992 sidre::Group *bp_index_field_grp =
993 bp_index_grp->createGroup(
"fields/" + field_name);
995 bp_index_field_grp->createViewString(
"path", bp_field_grp->getPathName() );
996 bp_index_field_grp->copyView( bp_field_grp->getView(
"topology") );
997 bp_index_field_grp->copyView( bp_field_grp->getView(
"basis") );
1002 const int number_of_components = gf->VectorDim();
1003 bp_index_field_grp->createViewScalar(
"number_of_components",
1004 number_of_components);
1009 void SidreDataCollection::
1010 DeregisterFieldInBPIndex(
const std::string& field_name)
1012 sidre::Group * fields_grp = bp_index_grp->getGroup(
"fields");
1013 MFEM_VERIFY(fields_grp->hasGroup(field_name),
1014 "No field exists in blueprint index with name " <<
name);
1019 fields_grp->destroyGroup(field_name);
1024 const std::string &buffer_name,
1025 axom::sidre::SidreLength offset)
1027 if ( field_name.empty() || buffer_name.empty() ||
1028 gf == NULL || gf->
FESpace() == NULL )
1034 sidre::Group* f = bp_grp->getGroup(
"fields");
1036 if (f->hasGroup( field_name ))
1048 if (field_name != m_meshNodesGFName)
1050 MFEM_WARNING(
"field with the name '" << field_name<<
"' is already "
1051 "registered, overwriting the old field");
1058 sidre::Group* grp = f->createGroup( field_name );
1068 v =
alloc_view(grp,
"topology")->setString(
"mesh");
1071 "GridFunction size does not match FiniteElementSpace size");
1080 addScalarBasedGridFunction(field_name, gf, buffer_name, offset);
1085 addVectorBasedGridFunction(field_name, gf, buffer_name, offset);
1091 RegisterFieldInBPIndex(field_name, gf);
1103 "Need to set mesh before registering attributes in SidreDataCollection.");
1106 sidre::Group* f = bp_grp->getGroup(
"fields");
1107 if (f->hasGroup( attr_name ))
1114 MFEM_WARNING(
"field with the name '" << attr_name <<
"' is already "
1115 " registered as an attribute, overwriting old values.");
1120 MFEM_WARNING(
"field with the name '" << attr_name <<
"' is already "
1121 " registered as a field, skipping register attribute.");
1127 addIntegerAttributeField(attr_name, is_bdry);
1131 RegisterAttributeFieldInBPIndex(attr_name);
1136 bp_grp->getGroup(
"fields")->getGroup(attr_name)->getView(
"values");
1142 void SidreDataCollection::RegisterAttributeFieldInBPIndex(
1143 const std::string& attr_name)
1145 const std::string bp_grp_path = bp_grp->getPathName();
1147 MFEM_ASSERT(bp_grp->getGroup(
"fields") != NULL,
1148 "Mesh blueprint does not have 'fields' group");
1149 MFEM_ASSERT(bp_index_grp->getGroup(
"fields") != NULL,
1150 "Mesh blueprint index does not have 'fields' group");
1153 sidre::Group* attr_grp =
1154 bp_grp->getGroup(
"fields")->getGroup(attr_name);
1157 sidre::Group *bp_index_attr_grp =
1158 bp_index_grp->getGroup(
"fields")->createGroup(attr_name);
1160 bp_index_attr_grp->createViewString(
"path", attr_grp->getPathName() );
1161 bp_index_attr_grp->copyView( attr_grp->getView(
"association") );
1162 bp_index_attr_grp->copyView( attr_grp->getView(
"topology") );
1163 bp_index_attr_grp->createViewScalar(
"number_of_components", 1);
1170 sidre::Group * attr_grp = bp_grp->getGroup(
"fields");
1171 MFEM_VERIFY(attr_grp->hasGroup(attr_name),
1172 "No field exists in blueprint with name " << attr_name);
1179 attr_grp->destroyGroup(attr_name);
1184 DeregisterAttributeFieldInBPIndex(attr_name);
1191 void SidreDataCollection::DeregisterAttributeFieldInBPIndex(
1192 const std::string& attr_name)
1194 sidre::Group * fields_grp = bp_index_grp->getGroup(
"fields");
1195 MFEM_VERIFY(fields_grp->hasGroup(attr_name),
1196 "No attribute exists in blueprint index with name " << attr_name);
1201 fields_grp->destroyGroup(attr_name);
1204 void SidreDataCollection::
1205 addIntegerAttributeField(
const std::string& attr_name,
bool is_bdry)
1207 sidre::Group* fld_grp = bp_grp->getGroup(
"fields");
1208 MFEM_ASSERT(fld_grp != NULL,
"'fields' group does not exist");
1211 std::string topo_name = is_bdry ?
"boundary" :
"mesh";
1213 sidre::Group* attr_grp = fld_grp->createGroup(attr_name);
1214 attr_grp->createViewString(
"association",
"element");
1215 attr_grp->createViewAndAllocate(
"values", sidre::INT_ID, num_elem);
1216 attr_grp->createViewString(
"topology", topo_name);
1224 sidre::Group * fields_grp = bp_grp->getGroup(
"fields");
1225 MFEM_VERIFY(fields_grp->hasGroup(field_name),
1226 "No field exists in blueprint with name " << field_name);
1233 fields_grp->destroyGroup(field_name);
1238 DeregisterFieldInBPIndex(field_name);
1246 std::string SidreDataCollection::getElementName(
Element::Type elementEnum)
1253 switch (elementEnum)
axom::sidre::View * alloc_view(axom::sidre::Group *grp, const std::string &view_name)
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 GetElementBaseGeometry(int i=0) const
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.
int num_procs
Number of MPI ranks (in parallel)
Class for parallel meshes.
int GetBdrElementBaseGeometry(int i=0) const
const Element * GetBdrElement(int i) const
void GetElementData(const Array< Element * > &elem_array, int geom, Array< int > &elem_vtx, Array< int > &attr) const
virtual int GetType() const =0
Returns element's type.
void DeregisterAttributeField(const std::string &name)
axom::sidre::Group * named_buffers_grp() const