-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generalized Axis specification for AxiSymmetric Mesh (#519)
* abstracted out the 1D mesh used for axisymmetric * added a fixed point input * cleaned up the mesh mapper * renamed the axis generator stuff * working on regions and mesh mapping * bug fix * version bump
- Loading branch information
Showing
25 changed files
with
564 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
target_sources(ablateLibrary | ||
PRIVATE | ||
axisymmetric.cpp | ||
generatedAxis.cpp | ||
specifiedAxis.cpp | ||
|
||
PUBLIC | ||
meshDescription.hpp | ||
axisymmetric.hpp | ||
axisDescription.hpp | ||
generatedAxis.hpp | ||
specifiedAxis.hpp | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef ABLATELIBRARY_AXISDESCRIPTION_HPP | ||
#define ABLATELIBRARY_AXISDESCRIPTION_HPP | ||
|
||
#include <petsc.h> | ||
#include <domain/region.hpp> | ||
#include <set> | ||
|
||
namespace ablate::domain::descriptions { | ||
/** | ||
* A simple interface that describes points a long a line on axis | ||
*/ | ||
class AxisDescription { | ||
public: | ||
virtual ~AxisDescription() = default; | ||
/** | ||
* Total number of nodes/vertices in the entire mesh | ||
* @return | ||
*/ | ||
[[nodiscard]] virtual const PetscInt& GetNumberVertices() const = 0; | ||
|
||
/** | ||
* Builds the node coordinate for each vertex | ||
* @return | ||
*/ | ||
virtual void SetCoordinate(PetscInt node, PetscReal coordinate[3]) const = 0; | ||
}; | ||
} // namespace ablate::domain::descriptions | ||
|
||
#endif // ABLATELIBRARY_AXISDESCRIPTION_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "generatedAxis.hpp" | ||
|
||
#include "utilities/vectorUtilities.hpp" | ||
|
||
ablate::domain::descriptions::GeneratedAxis::GeneratedAxis(const std::vector<PetscReal> &startLocation, PetscReal length, PetscInt numberNodes) | ||
: startLocation(utilities::VectorUtilities::ToArray<PetscReal, 3>(startLocation)), length(length), numberNodes(numberNodes) { | ||
// make sure there are at least 2 nodes | ||
if (this->numberNodes < 2) { | ||
throw std::invalid_argument("GeneratedAxis requires at least 2 nodes"); | ||
} | ||
} | ||
|
||
void ablate::domain::descriptions::GeneratedAxis::SetCoordinate(PetscInt node, PetscReal coordinate[3]) const { | ||
// start the coordinate at the start location | ||
coordinate[0] = startLocation[0]; | ||
coordinate[1] = startLocation[1]; | ||
coordinate[2] = startLocation[2]; | ||
|
||
// offset along z | ||
auto delta = length / (numberNodes - 1); | ||
auto offset = delta * node; | ||
coordinate[2] += offset; | ||
} | ||
|
||
#include "registrar.hpp" | ||
REGISTER_DEFAULT(ablate::domain::descriptions::AxisDescription, ablate::domain::descriptions::GeneratedAxis, "Creates a simple fixed spacing along z axis", | ||
ARG(std::vector<double>, "start", "the start coordinate of the mesh, must be 3D"), ARG(double, "length", "the length of the domain starting at the start coordinate"), | ||
ARG(int, "nodes", "number of nodes along the z-axis")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#ifndef ABLATELIBRARY_GENERATEDAXIS_HPP | ||
#define ABLATELIBRARY_GENERATEDAXIS_HPP | ||
|
||
#include <array> | ||
#include <memory> | ||
#include <vector> | ||
#include "axisDescription.hpp" | ||
#include "mathFunctions/mathFunction.hpp" | ||
|
||
namespace ablate::domain::descriptions { | ||
|
||
/** | ||
* Describes a simple strait line along the z axis | ||
*/ | ||
class GeneratedAxis : public ablate::domain::descriptions::AxisDescription { | ||
private: | ||
//! Store the start and end location of the mesh | ||
const std::array<PetscReal, 3> startLocation; | ||
|
||
//! the length of the domain | ||
const PetscReal length; // this is in z | ||
|
||
//! the number of nodes in the axis | ||
const PetscInt numberNodes; | ||
|
||
public: | ||
/** | ||
* generate and precompute a bunch of the required parameters | ||
* @param startLocation the start coordinate of the mesh, must be 3D | ||
* @param length the length of the domain starting at the start coordinate | ||
* @param numberNodes the number of nodes along the axis | ||
*/ | ||
GeneratedAxis(const std::vector<PetscReal>& startLocation, PetscReal length, PetscInt numberNodes); | ||
|
||
/** | ||
* Total number of nodes/vertices in the entire mesh | ||
* @return | ||
*/ | ||
[[nodiscard]] const PetscInt& GetNumberVertices() const override { return numberNodes; } | ||
|
||
/** | ||
* Sets the axis coordinate for this node | ||
* @return | ||
*/ | ||
void SetCoordinate(PetscInt node, PetscReal coordinate[3]) const override; | ||
}; | ||
} // namespace ablate::domain::descriptions | ||
#endif // ABLATELIBRARY_AXISYMMETRIC_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "specifiedAxis.hpp" | ||
|
||
#include <algorithm> | ||
#include "utilities/vectorUtilities.hpp" | ||
|
||
ablate::domain::descriptions::SpecifiedAxis::SpecifiedAxis(const std::vector<PetscReal>& nodeOffsets, const std::vector<PetscReal>& startLocation) | ||
: startLocation(startLocation.empty() ? std::array<PetscReal, 3>{0.0, 0.0, 0.0} : utilities::VectorUtilities::ToArray<PetscReal, 3>(startLocation)), | ||
zOffset(nodeOffsets), | ||
numberNodes((PetscInt)nodeOffsets.size()) { | ||
// make sure there are at least 2 nodes | ||
if (this->numberNodes < 2) { | ||
throw std::invalid_argument("SpecifiedAxis requires at least 2 nodes"); | ||
} | ||
if (!std::is_sorted(zOffset.begin(), zOffset.end())) { | ||
throw std::invalid_argument("SpecifiedAxis requires zOffset vector be sorted from smallest to largest"); | ||
} | ||
} | ||
|
||
void ablate::domain::descriptions::SpecifiedAxis::SetCoordinate(PetscInt node, PetscReal coordinate[3]) const { | ||
// start the coordinate at the start location | ||
coordinate[0] = startLocation[0]; | ||
coordinate[1] = startLocation[1]; | ||
coordinate[2] = startLocation[2]; | ||
|
||
// offset along z | ||
coordinate[2] += zOffset[node]; | ||
} | ||
|
||
#include "registrar.hpp" | ||
REGISTER(ablate::domain::descriptions::AxisDescription, ablate::domain::descriptions::SpecifiedAxis, "Describes a simple strait line along the z axis with specified offsets", | ||
ARG(std::vector<double>, "offsets", "an ordered list of offsets in z"), OPT(std::vector<double>, "start", "the start coordinate of the mesh, must be 3D")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#ifndef ABLATELIBRARY_SPECIFIEDAXIS_HPP | ||
#define ABLATELIBRARY_SPECIFIEDAXIS_HPP | ||
|
||
#include <array> | ||
#include <memory> | ||
#include <vector> | ||
#include "axisDescription.hpp" | ||
#include "mathFunctions/mathFunction.hpp" | ||
|
||
namespace ablate::domain::descriptions { | ||
|
||
/** | ||
* Describes a simple strait line along the z axis with specified offsets | ||
*/ | ||
class SpecifiedAxis : public ablate::domain::descriptions::AxisDescription { | ||
private: | ||
//! Store the start and end location of the mesh | ||
const std::array<PetscReal, 3> startLocation; | ||
|
||
//! Store the z offset from each node | ||
const std::vector<PetscReal> zOffset; | ||
|
||
//! store the number of vertices for quick lookup | ||
const PetscInt numberNodes; | ||
|
||
public: | ||
/** | ||
* read in and compute the axis from a list of z offsets and optional start location | ||
* @param nodeOffsets z offsets from the start location | ||
* @param startLocation optional start location (default is {0, 0, 0}) | ||
*/ | ||
explicit SpecifiedAxis(const std::vector<PetscReal>& nodeOffsets, const std::vector<PetscReal>& startLocation = {}); | ||
|
||
/** | ||
* Total number of nodes/vertices in the entire mesh | ||
* @return | ||
*/ | ||
[[nodiscard]] const PetscInt& GetNumberVertices() const override { return numberNodes; } | ||
|
||
/** | ||
* Sets the axis coordinate for this node | ||
* @return | ||
*/ | ||
void SetCoordinate(PetscInt node, PetscReal coordinate[3]) const override; | ||
}; | ||
} // namespace ablate::domain::descriptions | ||
#endif // ABLATELIBRARY_SPECIFIEDAXIS_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.