Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Construct shapes in memory and support more shapes #1436

Open
wants to merge 48 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
04c3971
Add const to input arguments to assure they are not changed.
gunney1 Jul 19, 2024
7bd74e5
Preliminary ability to generate shape in memory.
gunney1 Jul 31, 2024
88e8222
Add 2 more checks and exit with number of failures found.
gunney1 Jul 31, 2024
126934b
Fix bug that fails to apply GeometryOperators that are not composites.
gunney1 Aug 1, 2024
03b3f07
Add optional scaling to test the use of geometry operator.
gunney1 Aug 1, 2024
2cbfb3c
Add analytical sphere test and factor out code to generate discrete s…
gunney1 Aug 6, 2024
758b7ab
Remove obsolete code from Shaper.
gunney1 Aug 7, 2024
711b29a
Some name changes to fit accepted terminology.
gunney1 Aug 8, 2024
63358e9
Add SOR, cylinder and cone to in-memory shaping.
gunney1 Aug 8, 2024
cf58388
Small changes to comments.
gunney1 Aug 9, 2024
e3e8974
Implement arbitrary locations for VOR (not always on x-axis).
gunney1 Aug 10, 2024
381a75a
Add hexahedron shaping (in-memory only for now, not through klee).
gunney1 Aug 11, 2024
931d1ba
Set DiscreteShape default behavior for adaptive refinement of SOR.
gunney1 Aug 13, 2024
4bee170
Fix mesh pointers that get passed into classes then deleted.
gunney1 Aug 13, 2024
b409d47
Get in-memory shaping working on rzansel host execution.
gunney1 Aug 13, 2024
e5ac6bd
Enable multi-policy testing for in-memory shaping.
gunney1 Aug 14, 2024
df21a07
Merge remote-tracking branch 'gh/develop' into feature/gunney/constru…
gunney1 Aug 20, 2024
6815047
Support single tet shape in in-memory shaping.
gunney1 Aug 30, 2024
ae8bfb2
Support plane shape.
gunney1 Sep 1, 2024
d51a85f
Merge remote-tracking branch 'gh/develop' into feature/gunney/constru…
gunney1 Sep 30, 2024
382313e
Make some groups and views const where they are not modified.
gunney1 Oct 2, 2024
d73df72
More robust way to get temporary unique Group name.
gunney1 Oct 2, 2024
933e4e3
Change parameter ordering.
gunney1 Oct 2, 2024
42bf676
Rename memory-blueprint format to blueprint-tet and add checks
gunney1 Oct 2, 2024
6585fa2
Factor out code to shorten a method for readability.
gunney1 Oct 2, 2024
408b427
Reformat.
gunney1 Oct 2, 2024
39232fd
Check for valid sidre Group in cases where it's required.
gunney1 Oct 2, 2024
7507658
Temporary work-around for data re-allocation crash in docker tests.
gunney1 Oct 6, 2024
d9a7fc3
Autoformat and change parameter comment.
gunney1 Oct 6, 2024
8d6db24
Temporarily disable a sanity check that causes weird crash in
gunney1 Oct 9, 2024
848a449
Fix error in non-Umpire build.
gunney1 Oct 9, 2024
5c76ae5
In-memory shaping example requires RAJA, so disable if no raja.
gunney1 Oct 9, 2024
ec440d6
Merge remote-tracking branch 'gh/develop' into feature/gunney/constru…
gunney1 Oct 10, 2024
8b38891
Fix non-umpire build.
gunney1 Oct 11, 2024
c17f102
Undo the work-around for the (now fixed) Umpire reallocate crash.
gunney1 Oct 11, 2024
6bc441d
Comment changes from code review.
gunney1 Oct 11, 2024
4b8d9f3
Remove support for reading in MFEM mesh in the new test.
gunney1 Oct 14, 2024
8f12aa9
Remove unused code (for sampling shaping) in the new test.
gunney1 Oct 14, 2024
4b99328
Re-enable blueprint check on input mesh.
gunney1 Oct 14, 2024
9af7adf
Minor changes from code review comments.
gunney1 Oct 21, 2024
370ba11
Merge remote-tracking branch 'gh/develop' into feature/gunney/constru…
gunney1 Nov 5, 2024
d290616
Merge remote-tracking branch 'gh/develop' into feature/gunney/constru…
gunney1 Nov 6, 2024
fa54103
Remove redundant line left in by merge.
gunney1 Nov 6, 2024
ac42dc5
Add test option "all" to test multiple shapes and let more shape resp…
gunney1 Nov 25, 2024
72e8769
Remove need to enter explicit mesh dimension.
gunney1 Nov 26, 2024
7cb17c6
Add TODO note about problems with using huge tets to represent plane.
gunney1 Nov 26, 2024
6a497aa
Autoformat.
gunney1 Nov 26, 2024
1b87370
Tweak shapes to make them about the same size.
gunney1 Nov 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175 changes: 172 additions & 3 deletions src/axom/klee/Geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,134 @@
#include "axom/klee/Geometry.hpp"

#include "axom/klee/GeometryOperators.hpp"
#include "conduit_blueprint_mesh.hpp"

#include <utility>

namespace axom
{
namespace klee
{
bool operator==(const TransformableGeometryProperties &lhs,
const TransformableGeometryProperties &rhs)
bool operator==(const TransformableGeometryProperties& lhs,
const TransformableGeometryProperties& rhs)
{
return lhs.dimensions == rhs.dimensions && lhs.units == rhs.units;
}

Geometry::Geometry(const TransformableGeometryProperties &startProperties,
Geometry::Geometry(const TransformableGeometryProperties& startProperties,
std::string format,
std::string path,
std::shared_ptr<GeometryOperator const> operator_)
: m_startProperties(startProperties)
, m_format(std::move(format))
, m_path(std::move(path))
, m_levelOfRefinement(0)
, m_operator(std::move(operator_))
{ }

Geometry::Geometry(const TransformableGeometryProperties& startProperties,
const axom::sidre::Group* meshGroup,
const std::string& topology,
std::shared_ptr<GeometryOperator const> operator_)
: m_startProperties(startProperties)
, m_format("blueprint-tets")
, m_path()
, m_meshGroup(meshGroup)
, m_topology(topology)
, m_levelOfRefinement(0)
, m_operator(std::move(operator_))
{
#ifdef AXOM_DEBUG
SLIC_ASSERT_MSG(isBlueprintTetMesh(m_meshGroup),
"Mesh provided to Geometry is not a valid blueprint "
"unstructured tetrahedral mesh.");
#endif
}

Geometry::Geometry(const TransformableGeometryProperties& startProperties,
const axom::primal::Tetrahedron<double, 3>& tet,
std::shared_ptr<GeometryOperator const> operator_)
: m_startProperties(startProperties)
, m_format("tet3D")
, m_path()
, m_meshGroup(nullptr)
, m_topology()
, m_tet(tet)
, m_levelOfRefinement(0)
, m_operator(std::move(operator_))
{ }

Geometry::Geometry(const TransformableGeometryProperties& startProperties,
const axom::primal::Hexahedron<double, 3>& hex,
std::shared_ptr<GeometryOperator const> operator_)
: m_startProperties(startProperties)
, m_format("hex3D")
, m_path()
, m_meshGroup(nullptr)
, m_topology()
, m_hex(hex)
, m_levelOfRefinement(0)
, m_operator(std::move(operator_))
{ }

Geometry::Geometry(const TransformableGeometryProperties& startProperties,
const Sphere3D& sphere,
axom::IndexType levelOfRefinement,
std::shared_ptr<GeometryOperator const> operator_)
: m_startProperties(startProperties)
, m_format("sphere3D")
, m_path()
, m_meshGroup(nullptr)
, m_topology()
, m_sphere(sphere)
, m_levelOfRefinement(levelOfRefinement)
, m_operator(std::move(operator_))
{ }

Geometry::Geometry(const TransformableGeometryProperties& startProperties,
const axom::Array<double, 2>& discreteFunction,
const Point3D& vorBase,
const Vector3D& vorDirection,
axom::IndexType levelOfRefinement,
std::shared_ptr<GeometryOperator const> operator_)
: m_startProperties(startProperties)
, m_format("vor3D")
, m_path()
, m_meshGroup(nullptr)
, m_topology()
, m_sphere()
, m_discreteFunction(discreteFunction)
, m_vorBase(vorBase)
, m_vorDirection(vorDirection)
, m_levelOfRefinement(levelOfRefinement)
, m_operator(std::move(operator_))
{ }

Geometry::Geometry(const TransformableGeometryProperties& startProperties,
const axom::primal::Plane<double, 3>& plane,
std::shared_ptr<GeometryOperator const> operator_)
: m_startProperties(startProperties)
, m_format("plane3D")
, m_path()
, m_meshGroup(nullptr)
, m_topology()
, m_plane(plane)
, m_levelOfRefinement(0)
, m_operator(std::move(operator_))
{ }

bool Geometry::hasGeometry() const
{
bool isInMemory = m_format == "blueprint-tets" || m_format == "sphere3D" ||
gunney1 marked this conversation as resolved.
Show resolved Hide resolved
m_format == "tet3D" || m_format == "hex3D" || m_format == "plane3D" ||
m_format == "cone3D" || m_format == "cylinder3D";
if(isInMemory)
{
return true;
}
return !m_path.empty();
}

TransformableGeometryProperties Geometry::getEndProperties() const
{
if(m_operator)
Expand All @@ -38,5 +143,69 @@ TransformableGeometryProperties Geometry::getEndProperties() const
return m_startProperties;
}

const axom::sidre::Group* Geometry::getBlueprintMesh() const
{
SLIC_ASSERT_MSG(
m_meshGroup,
axom::fmt::format(
"The Geometry format '{}' is not specified "
"as a blueprint mesh and/or has not been converted into one.",
m_format));
return m_meshGroup;
}

const std::string& Geometry::getBlueprintTopology() const
{
SLIC_ASSERT_MSG(
m_meshGroup,
axom::fmt::format(
"The Geometry format '{}' is not specified "
"as a blueprint mesh and/or has not been converted into one.",
m_format));
return m_topology;
}

bool Geometry::isBlueprintTetMesh(const axom::sidre::Group* meshGroup) const
{
conduit::Node bpMesh;
meshGroup->createNativeLayout(bpMesh);

conduit::Node info;
bool isValid = conduit::blueprint::mesh::verify(bpMesh, info);
// The above call to verify causes the crash, even though this
// function is never entered.
if(!isValid)
{
return false;
}

const auto& topology =
bpMesh.fetch_existing(axom::fmt::format("topologies/{}", m_topology));

std::string coordsetName = topology.fetch_existing("coordset").as_string();
const auto& coordSet =
bpMesh.fetch_existing(axom::fmt::format("coordsets/{}", coordsetName));

auto dim = conduit::blueprint::mesh::coordset::dims(coordSet);
if(dim != 3)
{
return false;
}

auto topoType = topology.fetch_existing("type").as_string();
if(topoType != "unstructured")
{
return false;
}

auto shapeType = topology.fetch_existing("elements/shape").as_string();
if(shapeType != "tet")
{
return false;
}

return true;
}

} // namespace klee
} // namespace axom
Loading
Loading