-
Notifications
You must be signed in to change notification settings - Fork 46
Variable Robin boundary condition and generic boundary condition class #437
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
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
ec16cb1
Initial implementation and test case. Works with 1 processor, but fai…
aabrown100-git 30982a9
Put debugging statements inside debugging blocks
aabrown100-git f51fd2f
Add spatially_variable_robin test to pytest suite
aabrown100-git 29b06b1
Rename to VariableRobinBCData, initial VariableRobinBCData once, inst…
aabrown100-git c73758b
Add copyright statement
aabrown100-git 243a96b
Renamed to RobinBC, partial implementation of parallelization
aabrown100-git b832647
Refactored distribute method to use gatherv and scatterv. Dealing wit…
aabrown100-git a7c9aae
Passes test in parallel, fails with index error with 1 proc
aabrown100-git 1f4fa7d
Fixed bug, now passes test in serial
aabrown100-git 340ed6c
clean up debugging statements to make code more readable
aabrown100-git 88bcc8a
Refactor vtp file reading to accept vector of array names, more gener…
aabrown100-git 7317db3
Split implementation into a BC base class and a RobinBC derived class
aabrown100-git 36146d6
Update README.md and add ustruct test case. ustruct result is fairly …
aabrown100-git 1ba1de0
Merge branch 'SimVascular:main' into variable_Robin_BC
aabrown100-git a3c6718
Refactor BC class to improve error handling and code clarity. Introdu…
aabrown100-git 634e396
Rename BC and RobinBC classes as BoundaryCondition and RobinBoundaryC…
aabrown100-git 80138ee
Clean up constructors
aabrown100-git baa9734
Remove extraneous comments and debugging statements
aabrown100-git 0614ed9
Reformat code
aabrown100-git 9a1b579
Move flag to apply in normal direction only inside RobinBoundaryCondi…
aabrown100-git 1cd0112
Split up distribute method into smaller functions
aabrown100-git aacae9a
Add copyrights
aabrown100-git 3be8e84
Merge branch 'main' into variable_Robin_BC
aabrown100-git a385159
Merge branch 'main' into variable_Robin_BC
aabrown100-git 66f6417
Implement copy-and-swap idiom, add noexcept to appropriate methods
aabrown100-git 4756f0e
Catch exceptions in constructors
aabrown100-git f894ef8
Move generate_load.py and generate_spatially_variable_robin.py into u…
aabrown100-git 626788c
Initialize members with default values and use default default constr…
aabrown100-git ee43996
Remove defined_ flag, just check if arrays are allocated, add new exc…
aabrown100-git 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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,34 @@ | ||
| /* Copyright (c) Stanford University, The Regents of the University of California, and others. | ||
| * | ||
| * All Rights Reserved. | ||
| * | ||
| * See Copyright-SimVascular.txt for additional details. | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining | ||
| * a copy of this software and associated documentation files (the | ||
| * "Software"), to deal in the Software without restriction, including | ||
| * without limitation the rights to use, copy, modify, merge, publish, | ||
| * distribute, sublicense, and/or sell copies of the Software, and to | ||
| * permit persons to whom the Software is furnished to do so, subject | ||
| * to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included | ||
| * in all copies or substantial portions of the Software. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
| * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | ||
| * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
| * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER | ||
| * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
| * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
| * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
| * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
| * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
| * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
| * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| */ | ||
|
|
||
| #include "RobinBoundaryCondition.h" | ||
|
|
||
| #define n_debug_robin_bc | ||
|
|
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,129 @@ | ||
| /* Copyright (c) Stanford University, The Regents of the University of California, and others. | ||
| * | ||
| * All Rights Reserved. | ||
| * | ||
| * See Copyright-SimVascular.txt for additional details. | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining | ||
| * a copy of this software and associated documentation files (the | ||
| * "Software"), to deal in the Software without restriction, including | ||
| * without limitation the rights to use, copy, modify, merge, publish, | ||
| * distribute, sublicense, and/or sell copies of the Software, and to | ||
| * permit persons to whom the Software is furnished to do so, subject | ||
| * to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included | ||
| * in all copies or substantial portions of the Software. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
| * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | ||
| * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
| * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER | ||
| * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
| * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
| * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
| * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
| * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
| * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
| * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| */ | ||
|
|
||
| #ifndef ROBIN_BOUNDARY_CONDITION_H | ||
| #define ROBIN_BOUNDARY_CONDITION_H | ||
|
|
||
| #include "BoundaryCondition.h" | ||
| #include <string> | ||
| #include <map> | ||
| #include <vector> | ||
|
|
||
| /// @brief Class to handle Robin boundary condition with potentially spatially variable arrays | ||
| /// | ||
| /// This class extends the generic BoundaryCondition class to handle Robin boundary conditions, which require | ||
| /// stiffness and damping arrays. While it supports any number of named arrays through its base class, | ||
| /// it provides specific validation and convenience methods for stiffness and damping values. | ||
| /// | ||
| /// Example usage: | ||
| /// ```cpp | ||
| /// // Read multiple arrays from VTP file | ||
| /// std::vector<std::string> array_names = {"Stiffness", "Damping"}; | ||
| /// RobinBoundaryCondition bc(vtp_file_path, array_names, face); | ||
| /// | ||
| /// // Access values | ||
| /// double stiffness = bc.get_stiffness(node_id); // Convenience method | ||
| /// double damping = bc.get_damping(node_id); // Convenience method | ||
| /// | ||
| /// // Create with uniform values | ||
| /// std::map<std::string, double> uniform_values = { | ||
| /// {"Stiffness", 1.0}, | ||
| /// {"Damping", 0.5}, | ||
| /// }; | ||
| /// RobinBoundaryCondition bc(uniform_values, face); | ||
| /// ``` | ||
|
|
||
| #define debug_robin_bc | ||
| class RobinBoundaryCondition : public BoundaryCondition { | ||
| public: | ||
| /// @brief Default constructor - creates an empty RobinBoundaryCondition | ||
| RobinBoundaryCondition() : BoundaryCondition() {} | ||
|
|
||
| /// @brief Constructor - reads stiffness and damping from VTP file | ||
| /// @param vtp_file_path Path to VTP file containing Stiffness and Damping point arrays | ||
| /// @param normal_only Flag to apply only along normal direction | ||
| /// @param face Face associated with the Robin BC | ||
| /// @throws BoundaryConditionFileException if file cannot be read | ||
| /// @throws BoundaryConditionVtpArrayException if arrays are missing | ||
| /// @throws BoundaryConditionValidationException if values are invalid | ||
| RobinBoundaryCondition(const std::string& vtp_file_path, bool normal_only, const faceType& face) | ||
| : BoundaryCondition(vtp_file_path, std::vector<std::string>{"Stiffness", "Damping"}, StringBoolMap{{"normal_direction_only", normal_only}}, face) {} | ||
|
|
||
|
|
||
| /// @brief Constructor for uniform values | ||
| /// @param uniform_stiffness Uniform stiffness value for all nodes | ||
| /// @param uniform_damping Uniform damping value for all nodes | ||
| /// @param normal_only Flag to apply only along normal direction | ||
| /// @param face Face associated with the Robin BC | ||
| /// @throws BoundaryConditionValidationException if values are invalid | ||
| RobinBoundaryCondition(double uniform_stiffness, double uniform_damping, bool normal_only, const faceType& face) | ||
| : BoundaryCondition({{"Stiffness", uniform_stiffness}, {"Damping", uniform_damping}}, StringBoolMap{{"normal_direction_only", normal_only}}, face) {} | ||
|
|
||
| /// @brief Apply only along normal direction (getter) | ||
| /// @return true if BC should be applied only along normal direction | ||
| /// @throws BoundaryConditionFlagException if "normal_direction_only" flag not found | ||
| bool normal_direction_only() const { return this->get_flag("normal_direction_only"); } | ||
|
|
||
| /// @brief Get stiffness value for a specific node (convenience method) | ||
| /// @param node_id Node index on the face | ||
| /// @return Stiffness value for the node | ||
| /// @throws BoundaryConditionArrayException if "Stiffness" array not found | ||
| /// @throws BoundaryConditionNodeIdException if node_id is out of range | ||
| double get_stiffness(int node_id) const { | ||
| return get_value("Stiffness", node_id); | ||
| } | ||
|
|
||
| /// @brief Get damping value for a specific node (convenience method) | ||
| /// @param node_id Node index on the face | ||
| /// @return Damping value for the node | ||
| /// @throws BoundaryConditionArrayException if "Damping" array not found | ||
| /// @throws BoundaryConditionNodeIdException if node_id is out of range | ||
| double get_damping(int node_id) const { | ||
| return get_value("Damping", node_id); | ||
| } | ||
|
|
||
| /// @brief Assemble the Robin BC into the global residual vector and stiffness matrix | ||
| /// Currently not implemented | ||
| /// @return 0 | ||
| double assemble() const { return 0; } | ||
|
|
||
| protected: | ||
| /// @brief Validate array values for Robin BC | ||
| /// @param array_name Name of the array being validated | ||
| /// @param value Value to validate | ||
| /// @throws BoundaryConditionValidationException if validation fails | ||
| void validate_array_value(const std::string& array_name, double value) const override { | ||
| if (value < 0.0) { | ||
| throw BoundaryConditionValidationException(array_name, value); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| #endif // ROBIN_BOUNDARY_CONDITION_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.