-
Notifications
You must be signed in to change notification settings - Fork 1
fix boundary classifier #256
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 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
781f2c4
Fix bug on boundary faces in domain decomposition
acitrain 6b8887c
split boundary classifiers and simplify API
Bubusch 84775e8
remove default
Bubusch 8bc8249
clang format
Bubusch bda87f8
simplify struct classifier
Bubusch 333b733
calng format
Bubusch c3096bf
remove some pragam once
Bubusch 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
102 changes: 102 additions & 0 deletions
102
src/model/mesh/impl/builder/cartesian/include/cartesian_struct_boundary_classifier.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,102 @@ | ||
| #ifndef FUNTIDES_MODEL_MESH_IMPL_BUILDER_CARTESIAN_INCLUDE_CARTESIAN_STRUCT_BOUNDARY_CLASSIFIER_H_ | ||
| #define FUNTIDES_MODEL_MESH_IMPL_BUILDER_CARTESIAN_INCLUDE_CARTESIAN_STRUCT_BOUNDARY_CLASSIFIER_H_ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <data_type.h> | ||
| #include <model.h> | ||
| #include <model_struct.h> | ||
|
|
||
| #include <cmath> | ||
|
|
||
| namespace model | ||
| { | ||
| /** | ||
| * @brief Classifies boundary flags for nodes of a structured Cartesian mesh. | ||
| * | ||
| * Nodes are classified against the *global* domain bounds so that nodes on | ||
| * interior partition boundaries (e.g. MPI subdomain edges) are not marked as | ||
| * physical boundaries. | ||
| * | ||
| * Classification rules: | ||
| * - Not on any global face → InteriorNode | ||
| * - On the z_max global face AND | ||
| * free_surface_on_top == true → Surface | ||
| * - On any other global face → Damping | ||
| * | ||
| * @tparam FloatType Floating-point type for coordinates and bounds | ||
| * @tparam ScalarType Integer type used to cast BoundaryFlag values | ||
| * @tparam Order Polynomial order of the spectral elements | ||
| */ | ||
| template <typename FloatType, typename ScalarType, int Order> | ||
| class CartesianStructBoundaryClassifier | ||
| { | ||
| public: | ||
| CartesianStructBoundaryClassifier(FloatType x_min, FloatType x_max, | ||
| FloatType y_min, FloatType y_max, | ||
| FloatType z_min, FloatType z_max, | ||
| bool free_surface_on_top) | ||
| : x_min_(x_min), | ||
| x_max_(x_max), | ||
| y_min_(y_min), | ||
| y_max_(y_max), | ||
| z_min_(z_min), | ||
| z_max_(z_max), | ||
| free_surface_on_top_(free_surface_on_top) | ||
| { | ||
| } | ||
|
|
||
| /** | ||
| * @brief Classify every node of @p model against the global domain bounds. | ||
| * | ||
| * Tolerance is derived from the minimum grid spacing of the model. | ||
| * | ||
| * @param model Structured mesh whose nodes are to be classified | ||
| * @return VECTOR_INT_VIEW of size model.getNumberOfNodes() with BoundaryFlag | ||
| * values | ||
| */ | ||
| VECTOR_INT_VIEW classify( | ||
| const model::ModelStruct<FloatType, ScalarType, Order>& model) const | ||
| { | ||
| const int n_node = model.getNumberOfNodes(); | ||
| const FloatType tol = model.getMinSpacing() * static_cast<FloatType>(1e-4); | ||
|
|
||
| auto boundaries_t = allocateVector<VECTOR_INT_VIEW>(n_node, "boundaries_t"); | ||
|
|
||
| for (int n = 0; n < n_node; ++n) | ||
| { | ||
| const FloatType x = model.nodeCoord(n, 0); | ||
| const FloatType y = model.nodeCoord(n, 1); | ||
| const FloatType z = model.nodeCoord(n, 2); | ||
|
|
||
| const bool at_xmin = (fabs(x - x_min_) < tol); | ||
| const bool at_xmax = (fabs(x - x_max_) < tol); | ||
| const bool at_ymin = (fabs(y - y_min_) < tol); | ||
| const bool at_ymax = (fabs(y - y_max_) < tol); | ||
| const bool at_zmin = (fabs(z - z_min_) < tol); | ||
| const bool at_zmax = (fabs(z - z_max_) < tol); | ||
|
|
||
| const bool on_boundary = | ||
| at_xmin || at_xmax || at_ymin || at_ymax || at_zmin || at_zmax; | ||
|
|
||
| if (!on_boundary) | ||
| boundaries_t(n) = static_cast<ScalarType>(BoundaryFlag::InteriorNode); | ||
| else if (free_surface_on_top_ && at_zmax) | ||
| boundaries_t(n) = static_cast<ScalarType>(BoundaryFlag::Surface); | ||
| else | ||
| boundaries_t(n) = static_cast<ScalarType>(BoundaryFlag::Damping); | ||
| } | ||
|
|
||
| return boundaries_t; | ||
| } | ||
|
|
||
| private: | ||
| FloatType x_min_, x_max_; | ||
| FloatType y_min_, y_max_; | ||
| FloatType z_min_, z_max_; | ||
| bool free_surface_on_top_; | ||
| }; | ||
|
|
||
| } // namespace model | ||
|
|
||
| #endif // FUNTIDES_MODEL_MESH_IMPL_BUILDER_CARTESIAN_INCLUDE_CARTESIAN_STRUCT_BOUNDARY_CLASSIFIER_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
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.