Skip to content

Commit

Permalink
Merge pull request #1199 from LLNL/feature/gunney/topology-centric
Browse files Browse the repository at this point in the history
Blueprint mesh topology vs coordset
  • Loading branch information
gunney1 committed Oct 12, 2023
2 parents 5285396 + 5d1c897 commit 9506163
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 16 deletions.
25 changes: 25 additions & 0 deletions src/axom/quest/DistributedClosestPoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1638,6 +1638,7 @@ class DistributedClosestPoint
conduit::blueprint::mesh::to_multi_domain(meshNode, *tmpNode);
}
const conduit::Node& mdMeshNode(isMultidomain ? meshNode : *tmpNode);
verifyTopologyName(mdMeshNode, topologyName);

auto domainCount = conduit::blueprint::mesh::number_of_domains(mdMeshNode);

Expand Down Expand Up @@ -1778,6 +1779,30 @@ class DistributedClosestPoint
return success;
}

void verifyTopologyName(const conduit::Node& meshNode,
const std::string& topologyName)
{
std::string coordsetPath;
const std::string topologyPath =
axom::fmt::format("topologies/{}", topologyName);
for(axom::IndexType d = 0; d < meshNode.number_of_children(); ++d)
{
const auto& domain = meshNode.child(d);
if(!domain.has_path(topologyPath))
{
auto errMsg = fmt::format("No such topology '{}' found.", topologyName);
if(domain.has_path("coordsets/" + topologyName))
{
errMsg += fmt::format(
" You may have mistakenly specified a coordset name."
" The interface has changed to use topology name"
" instead of coordset.");
}
SLIC_ERROR(errMsg);
}
}
}

private:
RuntimePolicy m_runtimePolicy {RuntimePolicy::seq};
MPI_Comm m_mpiComm;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,21 @@ struct BlueprintParticleMesh
using PointArray2D = axom::Array<Point2D>;
using PointArray3D = axom::Array<Point3D>;

explicit BlueprintParticleMesh(sidre::Group* group = nullptr,
const std::string& coordset = "coords",
const std::string& topology = "mesh")
: m_coordsetName(coordset)
, m_topologyName(topology)
explicit BlueprintParticleMesh(sidre::Group* group,
const std::string& topology,
const std::string& coordset)
: m_topologyName(topology)
, m_coordsetName(coordset)
, m_group(group)
, m_domainGroups()
{
MPI_Comm_rank(MPI_COMM_WORLD, &m_rank);
MPI_Comm_size(MPI_COMM_WORLD, &m_nranks);
}

explicit BlueprintParticleMesh(sidre::Group* group)
: m_topologyName()
, m_coordsetName()
, m_group(group)
, m_domainGroups()
{
Expand Down Expand Up @@ -278,16 +288,16 @@ struct BlueprintParticleMesh
return false;
}

/// Returns the number of points in a particle mesh domain
/*!
@brief Returns the number of points in a particle mesh domain
including ghost points.
*/
int numPoints(axom::IndexType dIdx) const
{
int rval = 0;
auto* cg = m_coordsGroups[dIdx];
//BTNG: The following if-check is probably not a use-case
if(cg != nullptr && cg->hasView("values/x"))
{
rval = cg->getView("values/x")->getNumElements();
}
SLIC_ASSERT(cg != nullptr && cg->hasView("values/x"));
rval = cg->getView("values/x")->getNumElements();
return rval;
}
/// Returns the number of points in the particle mesh
Expand All @@ -306,6 +316,10 @@ struct BlueprintParticleMesh

/*!
@brief Read a blueprint mesh and store it internally in m_group.
If the topology wasn't specified in the constructor, the first
topology from the file is used. The coordset name will be
replaced with the one corresponding to the topology.
*/
void read_blueprint_mesh(const std::string& meshFilename)
{
Expand All @@ -323,13 +337,22 @@ struct BlueprintParticleMesh
assert(conduit::blueprint::mesh::is_multi_domain(mdMesh));
conduit::index_t domCount =
conduit::blueprint::mesh::number_of_domains(mdMesh);

if(domCount > 0)
{
if(m_topologyName.empty())
{
// No topology given. Pick the first one.
m_topologyName = mdMesh[0].fetch_existing("topologies")[0].name();
}
auto topologyPath = axom::fmt::format("topologies/{}", m_topologyName);

m_coordsetName =
mdMesh[0].fetch_existing(topologyPath + "/coordset").as_string();
const conduit::Node coordsetNode =
mdMesh[0].fetch_existing("coordsets").fetch_existing(m_coordsetName);
m_dimension = conduit::blueprint::mesh::coordset::dims(coordsetNode);
}

MPI_Allreduce(MPI_IN_PLACE, &m_dimension, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD);
SLIC_ASSERT(m_dimension > 0);

Expand Down Expand Up @@ -431,7 +454,7 @@ struct BlueprintParticleMesh
}

// set the default connectivity
// Maybe be required by an old version of visit. May not be needed by newer versions of visit.
// May be required by an old version of visit. May not be needed by newer versions of visit.
sidre::Array<int> arr(
m_topoGroups[domainIdx]->createView("elements/connectivity"),
SZ,
Expand Down Expand Up @@ -646,8 +669,8 @@ struct BlueprintParticleMesh
}

private:
const std::string m_coordsetName;
const std::string m_topologyName;
std::string m_topologyName;
std::string m_coordsetName;
/// Parent group for the entire mesh
sidre::Group* m_group;
/// Group for each domain in multidomain mesh
Expand All @@ -671,7 +694,7 @@ class ObjectMeshWrapper
public:
using Circle = primal::Sphere<double, 2>;

ObjectMeshWrapper(sidre::Group* group) : m_objectMesh(group)
ObjectMeshWrapper(sidre::Group* group) : m_objectMesh(group, "mesh", "coords")
{
SLIC_ASSERT(group != nullptr);
}
Expand Down

0 comments on commit 9506163

Please sign in to comment.