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

Draft
wants to merge 29 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 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
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
23 changes: 22 additions & 1 deletion src/axom/core/memory_management.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,28 @@ inline T* reallocate(T* pointer, std::size_t n, int allocID) noexcept
}
else
{
pointer = static_cast<T*>(rm.reallocate(pointer, numbytes));
auto oldPointer = pointer;
auto foundAllocator = rm.getAllocator(pointer);
auto size = foundAllocator.getSize(pointer);
constexpr bool workAround = true;
if(workAround)
{
/*
This empty-buffer work-around addresses issue #1287 and PR
#1271. The reproducer is the immediate_ug_reserve test in
file axom/src/axom/quest/test/quest_initialize.cpp. This
work-around doesn't address the actual cause of the problem,
something we should try to identify and fix.
*/
pointer = static_cast<T*>(foundAllocator.allocate(numbytes));
auto copysize = std::min(size, numbytes);
axom::copy(pointer, oldPointer, copysize);
axom::deallocate(oldPointer);
}
else
{
pointer = static_cast<T*>(rm.reallocate(pointer, numbytes));
}
}

#else
Expand Down
173 changes: 170 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" ||
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,67 @@ 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);
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