Repository navigation
Feature: mesh deformation with RBFs (TPS and CPC2) - #2470
Lena-Richter wants to merge 17 commits into
Conversation
…o the rbf_node struct and the interpolate function. add some minor changes to the mesh deformation to include the rbf_node struct to save the node data.
bbfd954 to
d05a2e2
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2470 +/- ##
==========================================
+ Coverage 82.76% 83.11% +0.34%
==========================================
Files 139 138 -1
Lines 21593 21504 -89
==========================================
Hits 17872 17872
+ Misses 3721 3632 -89 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ole-alb
left a comment
There was a problem hiding this comment.
Thank you for this very cool contribution and implementation. I have a couple general remarks.
Can you check if ervything that can be const is const?
Please add tests for your functionality as it is not tested yet. Please also test the new dependecy on the newly added thirdparty library Eigen.
After the PR is merged, please keep in mind to update the wiki accordingly (Eigen, CMake,..).
Also I thought if there could be the option to use a system Eigen like it is for SC and p4est?
And last but not least, I coudn't find you in the CITATION.cff and in doc/auther_. Please add yourself here.
| /** Calculate the distance between the current pair of boundary nodes. */ | ||
| const double distance = t8_dist (boundary_nodes[row].position, boundary_nodes[col].position); | ||
| /** Evaluate the radial basis function for the current distance and write the value to the matrix A. */ | ||
| A (row, col) = rbf_function->evaluate (distance, 0.0); |
There was a problem hiding this comment.
Is it possible to solve that with a default value? As tps doesn't have a radius, adding 0 could be misunterstood.
| double r = distance / radius; | ||
| if (r < 1.0) { | ||
| double d = 1.0 - r; | ||
| return (d * d * d * d) * (4.0 * r + 1.0); | ||
| } | ||
| return 0.0; |
There was a problem hiding this comment.
In genearal, the use of variables consisting of only one letter is stronlgy discouraged in t8code. For me this could be an exemption, as it's only four lines and just math, but maybe you can come up with a better way.
There was a problem hiding this comment.
Okay renamed r to normalized_distance and removed d by using std::pow
| std::unordered_map<t8_gloidx_t, t8_3D_vec> | ||
| t8_cmesh_mesh_deformation::calculate_displacement_surface_vertices (const t8_cad_handle *cad) | ||
| static double | ||
| calculate_local_support_radius (t8_cmesh_t cmesh, const std::vector<std::pair<t8_locidx_t, int>> &tree_list, |
There was a problem hiding this comment.
This function is specific to RBF, why is it here and not in t8_rbf.cxx? Also please add documentation and a "t8_" prefix to the function name.
| t8_cmesh_mesh_deformation::calculate_displacement_surface_vertices (const t8_cad_handle *cad) | ||
| static double | ||
| calculate_local_support_radius (t8_cmesh_t cmesh, const std::vector<std::pair<t8_locidx_t, int>> &tree_list, | ||
| int current_global_vertex_id, const t8_3D_vec &displacements) |
There was a problem hiding this comment.
This is an int here, but in the usage a t8_gloidx_t is used a input. So I'd suggest to make this also a t8_gloidx_t
| } | ||
| } | ||
| /* If the boundary node can not be found in the list of boundary nodes.*/ | ||
| t8_errorf ("ERROR: The boundary node %ld is missing in the boundary node list.\n", global_id); |
There was a problem hiding this comment.
| t8_errorf ("ERROR: The boundary node %ld is missing in the boundary node list.\n", global_id); | |
| t8_errorf ("ERROR: The boundary node % " T8_GLOIDX_FORMAT " is missing in the boundary node list.\n", global_id); |
|
|
||
| double displacement_magnitude = std::sqrt (displacements[0] * displacements[0] + displacements[1] * displacements[1] | ||
| + displacements[2] * displacements[2]); | ||
| /** Get the first tree where this vertex exists. */ |
| } | ||
| } | ||
| /** Fill the sparse matrix A with the triplets. */ | ||
| Eigen::SparseMatrix<double> A (num_boundary_nodes, num_boundary_nodes); |
There was a problem hiding this comment.
A might not be the best name.
| A.setFromTriplets (coefficients.begin (), coefficients.end ()); | ||
| /** Solve the linear system using the conjugate gradient method. */ | ||
| Eigen::BiCGSTAB<Eigen::SparseMatrix<double>> solver; | ||
| solver.setTolerance (1e-10); |
There was a problem hiding this comment.
Is that an experimental value?
| /** Because of the symmetric property of the distance between nodes, we only need to compute the upper triangular part of the matrix | ||
| * and can mirror the values to the lower triangular part. */ |
| option( T8CODE_ENABLE_MPI "Enable t8code's features which rely on MPI" ON ) | ||
| option( T8CODE_ENABLE_VTK "Enable t8code's features which rely on VTK" OFF ) | ||
| option( T8CODE_ENABLE_OCC "Enable t8code's features which rely on OpenCASCADE" OFF ) | ||
| option( T8CODE_ENABLE_EIGEN "Enable t8code's features which rely on eigen" OFF ) |
There was a problem hiding this comment.
| option( T8CODE_ENABLE_EIGEN "Enable t8code's features which rely on eigen" OFF ) | |
| option( T8CODE_ENABLE_EIGEN "Enable t8code's features which rely on Eigen" OFF ) |
…on.cxx Co-authored-by: Ole Albers <122293607+ole-alb@users.noreply.github.com>
Closes #2471
Describe your changes here:
This PR introduces an RBF-based mesh deformation, using OpenCASCADE and Eigen. It implements support for the compactly supported (
CPC2) and globally supported (TPS) basis functions to compute the deformation for the inner nodes from the displacement of the boundary nodes. Additionally, for CPC2, a dynamic radius is implemented as well as a grading factor. The deformed geometry needs to have the same parametrization as the input geometry, otherwise the deformation will not work.All these boxes must be checked by the AUTHOR before requesting review:
Documentation:,Bugfix:,Feature:,Improvement:orOther:.All these boxes must be checked by the REVIEWERS before merging the pull request:
As a reviewer please read through all the code lines and make sure that the code is fully understood, bug free, well-documented and well-structured.
General
Tests
If the Pull request introduces code that is not covered by the github action (for example coupling with a new library):
Scripts and Wiki
scripts/internal/find_all_source_files.shto check the indentation of these files.License
doc/(or already has one).