-
Notifications
You must be signed in to change notification settings - Fork 58
FE Quadrature Phase 01 abstract contract #593
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
Open
zasexton
wants to merge
62
commits into
SimVascular:main
Choose a base branch
from
zasexton:quadrature-P01
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
62 commits
Select commit
Hold shift + click to select a range
4e47613
Merge pull request #3 from SimVascular/main
zasexton 3bdfb91
Merge branch 'SimVascular:main' into main
zasexton 3fb5364
Merge branch 'SimVascular:main' into main
zasexton 4749c70
Merge branch 'SimVascular:main' into main
zasexton 47a7985
Merge branch 'SimVascular:main' into main
zasexton 2d4f8ed
Merge pull request #5 from SimVascular/main
zasexton 1154fe8
Merge branch 'SimVascular:main' into main
zasexton 690a92c
Merge branch 'SimVascular:main' into main
zasexton e6dd7e9
Merge branch 'SimVascular:main' into main
zasexton b831ea1
Merge branch 'SimVascular:main' into main
zasexton 1e117c2
Merge branch 'SimVascular:main' into main
zasexton 35cc8fe
Merge branch 'SimVascular:main' into main
zasexton 42b23df
Merge branch 'SimVascular:main' into main
zasexton f412876
Merge branch 'SimVascular:main' into main
zasexton 3a6af11
Merge branch 'SimVascular:main' into main
zasexton c5e934f
Merge branch 'SimVascular:main' into main
zasexton b34bfb3
Merge branch 'SimVascular:main' into main
zasexton a2f1677
Define the FE Quadrature module boundary
zasexton a07b87b
Add immutable reference-space quadrature rules
zasexton fbf3630
Establish Quadrature Phase 01 baselines
zasexton 6110849
Run API documentation from the repository root
zasexton 593f765
Polish quadrature validation result handling
zasexton 4449885
Simplify reference-cell validation
zasexton 454c7dd
Use FE vectors for quadrature points
zasexton f9ec988
Separate quadrature dimensions and zeroth moment
zasexton 2e48f4c
Inline binary64 weight accumulation
zasexton 0b4d7bf
Simplify quadrature validation diagnostics
zasexton 02aff30
Keep quadrature validation policy internal
zasexton bad9188
Remove redundant reference measure alias
zasexton 752bbee
Clarify the quadrature rule contract
zasexton fba6733
Simplify quadrature rule validation
zasexton b1433cb
Use exact summation for quadrature validation
zasexton ce8ca07
fixing spacing for exact binary summation
zasexton d66e30c
Document binary64 validation assumptions
zasexton e8d3680
Qualify quadrature vector include
zasexton 42c9e9e
Use reference cell measure terminology
zasexton 4feee78
Complete reference cell measure documentation
zasexton 6fb1dad
Focus quadrature tests on new infrastructure
zasexton 970f3c0
Merge branch 'main' into quadrature-P01
zasexton dbc6a6c
Pass quadrature construction data directly
zasexton ae426e8
Inline reference cell metadata validation
zasexton 49d0568
Derive quadrature dimension from cell family
zasexton ee8a927
Make QuadratureRule a concrete value type
zasexton fe657df
Flatten quadrature rule validation
zasexton c0beffd
Simplify quadrature weight summation
zasexton 30bfaa9
Reduce quadrature point validation
zasexton a719342
Derive reference-cell measure from family
zasexton 1c28f9e
Merge branch 'main' into quadrature-P01
zasexton 413acf3
Condense quadrature rule documentation
zasexton 6264ee9
Merge remote-tracking branch 'origin/quadrature-P01' into quadrature-P01
zasexton d7172e0
Limit quadrature validation to structure
zasexton 2b59827
Make QuadratureRule an abstract base
zasexton 991aea3
Merge branch 'main' into quadrature-P01
zasexton 3c3163e
Keep CMake documentation in build tree
zasexton a4e14cc
Align reference-cell table
zasexton 5ee42cb
Clarify quadrature construction requirements
zasexton 261e66d
Document construction-time validation
zasexton 8c6735a
Raise on unsupported cell families
zasexton 7c74acf
Use size type for reference dimensions
zasexton ec18918
Iterate over quadrature point size
zasexton f41839c
Inline quadrature data validation
zasexton 0fb7416
Demonstrate concrete quadrature construction
zasexton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,131 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) Stanford University, The Regents of the University of California, and others. | ||
| // SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| /** | ||
| * @file QuadratureRule.cpp | ||
| * @brief Internal construction and structural validation for quadrature rules. | ||
| * @ingroup FE_Quadrature | ||
| */ | ||
|
|
||
| #include "FE/Quadrature/QuadratureRule.h" | ||
|
|
||
| #include "FE/Common/FEException.h" | ||
|
|
||
| #include <cmath> | ||
| #include <string> | ||
| #include <utility> | ||
|
|
||
| namespace svmp::FE::quadrature { | ||
| namespace { | ||
|
|
||
| std::size_t reference_dimension(svmp::CellFamily family) | ||
| { | ||
| switch (family) { | ||
| case svmp::CellFamily::Point: | ||
| return 0u; | ||
| case svmp::CellFamily::Line: | ||
| return 1u; | ||
| case svmp::CellFamily::Triangle: | ||
| case svmp::CellFamily::Quad: | ||
| return 2u; | ||
| case svmp::CellFamily::Tetra: | ||
| case svmp::CellFamily::Hex: | ||
| case svmp::CellFamily::Wedge: | ||
| return 3u; | ||
| default: | ||
| svmp::raise<InvalidArgumentException>( | ||
| "QuadratureRule: unsupported reference-cell family"); | ||
| } | ||
| } | ||
|
|
||
| double reference_measure(svmp::CellFamily family) | ||
| { | ||
| switch (family) { | ||
| case svmp::CellFamily::Point: | ||
| return 1.0; | ||
| case svmp::CellFamily::Line: | ||
| return 2.0; | ||
| case svmp::CellFamily::Triangle: | ||
| return 0.5; | ||
| case svmp::CellFamily::Quad: | ||
| return 4.0; | ||
| case svmp::CellFamily::Tetra: | ||
| return 1.0 / 6.0; | ||
| case svmp::CellFamily::Hex: | ||
| return 8.0; | ||
| case svmp::CellFamily::Wedge: | ||
| return 1.0; | ||
| default: | ||
| svmp::raise<InvalidArgumentException>( | ||
| "QuadratureRule: unsupported reference-cell family"); | ||
| } | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
| QuadratureRule::~QuadratureRule() = default; | ||
|
|
||
| std::size_t QuadratureRule::dimension() const | ||
| { | ||
| return reference_dimension(cell_family_); | ||
| } | ||
|
|
||
| double QuadratureRule::reference_cell_measure() const | ||
| { | ||
| return reference_measure(cell_family_); | ||
| } | ||
|
|
||
| QuadratureRule::QuadratureRule( | ||
| svmp::CellFamily family, | ||
| int polynomial_exactness, | ||
| std::vector<QuadPoint> points, | ||
| std::vector<double> weights) | ||
| : cell_family_(family), | ||
| polynomial_exactness_(polynomial_exactness), | ||
| points_(std::move(points)), | ||
| weights_(std::move(weights)) | ||
| { | ||
| const std::size_t dimension = reference_dimension(cell_family_); | ||
| svmp::check<InvalidArgumentException>( | ||
| polynomial_exactness_ >= 0, | ||
| "QuadratureRule: polynomial exactness must be non-negative"); | ||
| svmp::check<InvalidArgumentException>( | ||
| !points_.empty(), | ||
| "QuadratureRule: a rule must contain at least one point"); | ||
| svmp::check<InvalidArgumentException>( | ||
| points_.size() == weights_.size(), | ||
| "QuadratureRule: points/weights size mismatch"); | ||
|
|
||
| for (std::size_t point_index = 0; | ||
| point_index < points_.size(); | ||
| ++point_index) { | ||
| const QuadPoint& point = points_[point_index]; | ||
| for (std::size_t component = 0; | ||
| component < point.size(); | ||
| ++component) { | ||
| if (!std::isfinite(point[component])) { | ||
| svmp::raise<InvalidArgumentException>( | ||
| std::string{ | ||
| "QuadratureRule: quadrature point contains a non-finite " | ||
| "coordinate at point index "} + | ||
| std::to_string(point_index)); | ||
| } | ||
| if (component >= dimension && point[component] != 0.0) { | ||
| svmp::raise<InvalidArgumentException>( | ||
| std::string{ | ||
| "QuadratureRule: quadrature point has a nonzero inactive " | ||
| "coordinate at point index "} + | ||
| std::to_string(point_index)); | ||
| } | ||
| } | ||
| if (!std::isfinite(weights_[point_index])) { | ||
| svmp::raise<InvalidArgumentException>( | ||
| std::string{ | ||
| "QuadratureRule: quadrature weight must be finite at point " | ||
| "index "} + | ||
| std::to_string(point_index)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } // namespace svmp::FE::quadrature |
This file contains hidden or 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,152 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) Stanford University, The Regents of the University of California, and others. | ||
| // SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| #ifndef SVMP_FE_QUADRATURE_RULE_H | ||
| #define SVMP_FE_QUADRATURE_RULE_H | ||
|
|
||
| /** | ||
| * @file QuadratureRule.h | ||
| * @brief Abstract base for reference-space quadrature rules. | ||
| * @ingroup FE_Quadrature | ||
| */ | ||
|
|
||
| /** | ||
| * @defgroup FE_Quadrature Quadrature | ||
| * @ingroup FE | ||
| * @brief Integration rules on canonical reference cells. | ||
| * | ||
| * @details | ||
| * A QuadratureRule owns ordered reference coordinates and weights for | ||
| * @f[ | ||
| * \int_{\hat K} f(\hat x)\,d\hat x | ||
| * \approx \sum_q w_q f(\hat x_q). | ||
| * @f] | ||
| * Supported families use these canonical reference cells: | ||
| * | ||
| * | Family | Reference cell | Measure | | ||
| * |----------|-------------------------------------------|-----------| | ||
| * | Point | @f$(0,0,0)@f$ | @f$1@f$ | | ||
| * | Line | @f$[-1,1]@f$ | @f$2@f$ | | ||
| * | Triangle | @f$\{(x,y):x,y\geq0,\ x+y\leq1\}@f$ | @f$1/2@f$ | | ||
| * | Quad | @f$[-1,1]^2@f$ | @f$4@f$ | | ||
| * | Tetra | @f$\{(x,y,z):x,y,z\geq0,\ x+y+z\leq1\}@f$ | @f$1/6@f$ | | ||
| * | Hex | @f$[-1,1]^3@f$ | @f$8@f$ | | ||
| * | Wedge | unit triangle @f$\times[-1,1]@f$ | @f$1@f$ | | ||
| * | ||
| * The family therefore determines both reference dimension and cell measure. | ||
| * Quadrature points are not required to lie inside the reference cell. | ||
| * Generating code is responsible for verifying weight normalization and | ||
| * declared polynomial exactness through analytic moment tests. | ||
| */ | ||
|
|
||
| #include "FE/Common/Types.h" | ||
| #include "FE/Math/Vector.h" | ||
|
|
||
| #include <cstddef> | ||
| #include <vector> | ||
|
|
||
| namespace svmp::FE::quadrature { | ||
|
|
||
| /** @addtogroup FE_Quadrature | ||
| * @{ | ||
| */ | ||
|
|
||
| /** | ||
| * @brief Three-component coordinate used for every reference quadrature point. | ||
| * | ||
| * Only the first QuadratureRule::dimension() components are active; remaining | ||
| * components must be zero. | ||
| */ | ||
| using QuadPoint = math::Vector<double, 3>; | ||
|
|
||
| /** | ||
| * @brief Owning abstract base for quadrature rules on canonical reference cells. | ||
| * | ||
| * Construction requires: | ||
| * | ||
| * - a supported cell family and non-negative polynomial exactness; | ||
| * - a vector of points, with at least one element; | ||
| * - for all points, coordinates must be finite; | ||
| * - for all points, coordinates beyond the reference dimension of the cell | ||
| * family must be equal to zero; and | ||
| * - a vector of finite weights, with as many elements as the points. | ||
| * | ||
| * The constructor checks each requirement and throws InvalidArgumentException | ||
| * when one is violated. | ||
| * | ||
| * Points may be duplicate or outside the reference cell, and weights may be | ||
| * zero or negative. Construction does not verify weight normalization or | ||
| * polynomial exactness. | ||
| */ | ||
| class QuadratureRule { | ||
| public: | ||
| /** @brief Enable polymorphic destruction of concrete quadrature rules. */ | ||
| virtual ~QuadratureRule() = 0; | ||
|
|
||
| /** @brief Return the number of point/weight pairs. */ | ||
| std::size_t num_points() const noexcept { return points_.size(); } | ||
|
|
||
| /** @brief Return the declared total-degree polynomial exactness. */ | ||
| int polynomial_exactness() const noexcept { return polynomial_exactness_; } | ||
|
|
||
| /** | ||
| * @brief Return the reference dimension and active QuadPoint component count. | ||
| */ | ||
| std::size_t dimension() const; | ||
|
|
||
| /** @brief Return the canonical reference-cell family. */ | ||
| svmp::CellFamily cell_family() const noexcept { return cell_family_; } | ||
|
|
||
| /** | ||
| * @brief Return point @p i without bounds checking. | ||
| * @pre @p i is less than num_points(). | ||
| */ | ||
| const QuadPoint& point(std::size_t i) const noexcept { return points_[i]; } | ||
|
|
||
| /** | ||
| * @brief Return the weight paired with point @p i without bounds checking. | ||
| * @pre @p i is less than num_points(). | ||
| */ | ||
| double weight(std::size_t i) const noexcept { return weights_[i]; } | ||
|
zasexton marked this conversation as resolved.
|
||
|
|
||
| /** @brief Return all points in integration order. */ | ||
| const std::vector<QuadPoint>& points() const noexcept { return points_; } | ||
|
|
||
| /** @brief Return all weights in point order. */ | ||
| const std::vector<double>& weights() const noexcept { return weights_; } | ||
|
|
||
| /** @brief Return the reference-cell measure derived from cell_family(). */ | ||
| double reference_cell_measure() const; | ||
|
|
||
| protected: | ||
| /** | ||
| * @brief Initialize a concrete rule from complete point and weight data. | ||
| * @param family Reference-cell family; also determines dimension and measure. | ||
| * @param polynomial_exactness Declared total-degree polynomial exactness. | ||
| * @param points Ordered reference coordinates. | ||
| * @param weights Weights paired with @p points. | ||
| * @throws InvalidArgumentException If a construction requirement is violated. | ||
| */ | ||
| explicit QuadratureRule( | ||
| svmp::CellFamily family, | ||
| int polynomial_exactness, | ||
| std::vector<QuadPoint> points, | ||
| std::vector<double> weights); | ||
|
Comment on lines
+133
to
+134
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| QuadratureRule(const QuadratureRule&) = default; | ||
| QuadratureRule(QuadratureRule&&) noexcept = default; | ||
| QuadratureRule& operator=(const QuadratureRule&) = default; | ||
| QuadratureRule& operator=(QuadratureRule&&) noexcept = default; | ||
|
|
||
| private: | ||
| svmp::CellFamily cell_family_; ///< Canonical reference topology. | ||
| int polynomial_exactness_; ///< Exactness declared by the generator. | ||
| std::vector<QuadPoint> points_; ///< Ordered reference coordinates. | ||
| std::vector<double> weights_; ///< Weights paired with points_. | ||
| }; | ||
|
|
||
| /** @} */ | ||
|
|
||
| } // namespace svmp::FE::quadrature | ||
|
|
||
| #endif // SVMP_FE_QUADRATURE_RULE_H | ||
This file contains hidden or 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,5 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) Stanford University, The Regents of the University of California, and others. | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| @INCLUDE = "@SV_SOURCE_DIR@/../Documentation/Doxyfile" | ||
| OUTPUT_DIRECTORY = "@SV_DOCS_DIR@" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand this right, the purpose of this is to fix the
make docrecipe (whereas as of now the documentation would have to be built by callingdoxygenmanually from the repository root folder). Is this correct?If so, is the documentation now generated into the build folder, or into the source folder as in the current main branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes here should remove any stale documents generated prior to regenerating a doxygen build but they should not be relocating the written destination of generated. The
Documentation/buildis still the appropriate target location since this is used by current github actions.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarifying. I understand this is the current state of the GitHub pipelines (and that it is unrelated to this PR), but.
In my local installation, running
make docfrombuild/svMultiPhysics-buildfails to generate the documentation. If I interpret the error correctly, this is because there is a mismatch between the paths used in theDoxyfileand the paths thatmake docruns with. This command changes the target so thatmake docrunsdoxygenfrom the repository's source directory, so I believe that these issues should be fixed.Having said all this, do you know the rationale behind generating the documentation in a separate build folder, rather than in the already existing, CMake-configured build folder? I would think the latter to be the more natural thing to do, and I'm generally wary of situations where running
makein a folder generates/modifies files outside of that folder.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a combination of my changes and the existing paths... I think the mismatch with
make docmight have already been around, but yes this should definitely be addressed. I'll make sure that we are generating within the already built folder