Skip to content

Commit

Permalink
Merge pull request #1436 from LLNL/feature/gunney/construct-shapes-in…
Browse files Browse the repository at this point in the history
…-memory

Construct shapes in memory and support more shapes
  • Loading branch information
gunney1 authored Jan 14, 2025
2 parents b811391 + 8dbe147 commit 550b991
Show file tree
Hide file tree
Showing 33 changed files with 3,105 additions and 407 deletions.
4 changes: 4 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ The Axom project release numbers follow [Semantic Versioning](http://semver.org/
## [Unreleased] - Release date yyyy-mm-dd

### Added
- A number of new `klee::Geometry` constructors are added, for the different shapes now supported.
This is a temporary change. The class will be subclassed in the future to support a diversity of geometries.
- Support some analytical shapes in `IntersectionShaper`.
- Support generating shapes in memory (not requiring input files).
- `sidre::View` holding array data may now be re-shaped. See `sidre::View::reshapeArray`.
- Sina C++ library is now a component of Axom
- Adds optional dependency on [Open Cascade](https://dev.opencascade.org). The initial intention is
Expand Down
127 changes: 124 additions & 3 deletions src/axom/klee/Geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,128 @@
#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* simplexMeshGroup,
const std::string& topology,
std::shared_ptr<GeometryOperator const> operator_)
: m_startProperties(startProperties)
, m_format("blueprint-tets")
, m_path()
, m_meshGroup(simplexMeshGroup)
, m_topology(topology)
, m_levelOfRefinement(0)
, m_operator(std::move(operator_))
{ }

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 +137,27 @@ 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;
}

} // namespace klee
} // namespace axom
Loading

0 comments on commit 550b991

Please sign in to comment.