-
Notifications
You must be signed in to change notification settings - Fork 57
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
Draft
zasexton
wants to merge
51
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.
Draft
Changes from all commits
Commits
Show all changes
51 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 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,156 @@ | ||
| // 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 <cassert> | ||
| #include <cmath> | ||
| #include <string> | ||
| #include <utility> | ||
|
|
||
| namespace svmp::FE::quadrature { | ||
| namespace { | ||
|
|
||
| constexpr int reference_dimension(svmp::CellFamily family) noexcept | ||
| { | ||
| switch (family) { | ||
| case svmp::CellFamily::Point: | ||
| return 0; | ||
| case svmp::CellFamily::Line: | ||
| return 1; | ||
| case svmp::CellFamily::Triangle: | ||
| case svmp::CellFamily::Quad: | ||
| return 2; | ||
| case svmp::CellFamily::Tetra: | ||
| case svmp::CellFamily::Hex: | ||
| case svmp::CellFamily::Wedge: | ||
| return 3; | ||
| default: | ||
| return -1; | ||
| } | ||
| } | ||
|
|
||
| constexpr double reference_measure(svmp::CellFamily family) noexcept | ||
| { | ||
| 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: | ||
| return -1.0; | ||
| } | ||
| } | ||
|
|
||
| void validate_point( | ||
| const QuadPoint& point, | ||
| int dimension, | ||
| std::size_t point_index) | ||
| { | ||
| for (std::size_t component = 0; component < 3u; ++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 >= | ||
| static_cast<std::size_t>(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)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void validate_weights(const std::vector<double>& weights) | ||
| { | ||
| for (std::size_t point_index = 0; | ||
| point_index < weights.size(); | ||
| ++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 | ||
|
|
||
| int QuadratureRule::dimension() const noexcept | ||
| { | ||
| const int dimension = reference_dimension(cell_family_); | ||
| assert(dimension >= 0); | ||
| return dimension; | ||
| } | ||
|
|
||
| double QuadratureRule::reference_cell_measure() const noexcept | ||
| { | ||
| const double measure = reference_measure(cell_family_); | ||
| assert(measure > 0.0); | ||
| return measure; | ||
| } | ||
|
|
||
| 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 int dimension = reference_dimension(cell_family_); | ||
| svmp::check<InvalidArgumentException>( | ||
| dimension >= 0, | ||
| "QuadratureRule: unsupported reference-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) { | ||
| validate_point( | ||
| points_[point_index], | ||
| dimension, | ||
| point_index); | ||
| } | ||
|
|
||
| validate_weights(weights_); | ||
| } | ||
|
|
||
| } // 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,126 @@ | ||
| // 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 Reference-space quadrature rule value type. | ||
| * @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 are Point, Line, Triangle, Quad, Tetra, Hex, and Wedge. | ||
| * The family determines the reference dimension and cell measure. 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 quadrature rule on a canonical reference cell. | ||
| * | ||
| * Construction requires: | ||
| * | ||
| * - a supported cell family and non-negative polynomial exactness; | ||
| * - at least one point and the same number of points and weights; | ||
| * - finite coordinates and weights; and | ||
| * - inactive coordinates equal to zero. | ||
| * | ||
| * 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 final { | ||
| public: | ||
| /** | ||
| * @brief Construct a 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); | ||
|
|
||
| /** @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. | ||
| */ | ||
| int dimension() const noexcept; | ||
|
|
||
| /** @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]; } | ||
|
|
||
| /** @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 noexcept; | ||
|
|
||
| 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 |
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.
Uh oh!
There was an error while loading. Please reload this page.