![]() |
Lethe Open-Source Library version 1.2.0
Developer Guide
|
#include <interface_tools.h>
Public Member Functions | |
| SignedDistanceSolver (const std::shared_ptr< parallel::DistributedTriangulationBase< dim > > &background_triangulation, std::shared_ptr< FiniteElement< dim > > background_fe, const double p_max_distance, const double p_iso_level, const double p_scaling, const Parameters::Verbosity p_verbosity) | |
| void | setup_dofs () |
| void | set_level_set_from_background_mesh (const DoFHandler< dim > &background_dof_handler, const VectorType &background_level_set_vector) |
| void | solve () |
| VectorType & | get_signed_distance () |
| void | output_interface_reconstruction (const std::string &output_name, const std::string &output_path, const double time, const unsigned int it) |
| void | output_signed_distance (const std::string &output_name, const std::string &output_path, const double time, const unsigned int it) |
| std::vector< OutputStruct< dim, GlobalVectorType > > | gather_output_hook () |
Public Attributes | |
| DoFHandler< dim > | dof_handler |
Private Member Functions | |
| void | zero_out_ghost_values () const |
| void | update_ghost_values () const |
| void | exchange_distance () |
| void | initialize_distance () |
| void | compute_first_neighbors_distance () |
| void | compute_second_neighbors_distance () |
| void | compute_signed_distance_from_distance () |
| void | compute_cell_wise_volume_correction () |
| void | conserve_global_volume () |
| void | get_dof_opposite_faces (unsigned int local_dof_id, std::vector< unsigned int > &local_opposite_faces) |
| void | set_face_opposite_dofs_map () |
| void | set_face_dofs_map () |
| void | get_face_opposite_dofs (unsigned int local_face_id, std::vector< unsigned int > &local_opposite_dofs) |
| void | get_face_local_dofs (unsigned int local_face_id, std::vector< unsigned int > &local_dofs) |
| void | get_face_transformation_jacobian (const DerivativeForm< 1, dim, dim > &cell_transformation_jac, const unsigned int local_face_id, LAPACKFullMatrix< double > &face_transformation_jac) |
| Point< dim > | transform_ref_face_point_to_ref_cell (const Point< dim - 1 > &x_ref_face, const unsigned int local_face_id) |
| void | compute_residual (const Tensor< 1, dim > &x_n_to_x_I_real, const Tensor< 1, dim > &distance_gradient, const LAPACKFullMatrix< double > &transformation_jac, Tensor< 1, dim - 1 > &residual_ref) |
| void | compute_numerical_jacobian_stencil (const Point< dim > x_ref, const unsigned int local_face_id, const double perturbation, std::vector< Point< dim > > &stencil) |
| Tensor< 1, dim > | transform_ref_face_correction_to_ref_cell (const Vector< double > &correction_ref_face, const unsigned int local_face_id) |
| void | compute_analytical_jacobian (const Tensor< 1, dim > &x_n_to_x_I_real_p1, const LAPACKFullMatrix< double > &transformation_jacobian, const std::vector< double > &face_local_dof_values, LAPACKFullMatrix< double > &jacobian_matrix) |
| double | compute_distance (const Tensor< 1, dim > &x_n_to_x_I_real, const double distance) |
Private Attributes | |
| std::shared_ptr< FiniteElement< dim > > | fe |
| std::shared_ptr< MappingQ< dim > > | mapping |
| const double | max_distance |
| const double | iso_level |
| const double | scaling |
| const Parameters::Verbosity | verbosity |
| ConditionalOStream | pcout |
| IndexSet | locally_owned_dofs |
| IndexSet | locally_relevant_dofs |
| IndexSet | locally_active_dofs |
| VectorType | level_set |
| LinearAlgebra::distributed::Vector< double > | signed_distance |
| GlobalVectorType | signed_distance_output |
| LinearAlgebra::distributed::Vector< double > | signed_distance_with_ghost |
| LinearAlgebra::distributed::Vector< double > | distance |
| LinearAlgebra::distributed::Vector< double > | distance_with_ghost |
| LinearAlgebra::distributed::Vector< double > | volume_correction |
| AffineConstraints< double > | constraints |
| std::map< types::global_cell_index, std::vector< Point< dim > > > | interface_reconstruction_vertices |
| std::map< types::global_cell_index, std::vector< CellData< dim - 1 > > > | interface_reconstruction_cells |
| std::set< types::global_dof_index > | intersected_dofs |
| PVDHandler | pvd_handler_reconstruction |
| PVDHandler | pvd_handler_signed_distance |
| std::map< unsigned int, std::vector< unsigned int > > | face_opposite_dofs_map |
| std::map< unsigned int, std::vector< unsigned int > > | face_dofs_map |
| LAPACKFullMatrix< double > | hessian_matrix |
| LAPACKFullMatrix< double > | H_x_transformation_jacobian |
Solver to compute the signed distance from a given level of a level-set field. It is based on the method proposed in the following article: Ausas, R.F., Dari, E.A. and Buscaglia, G.C. (2011), A geometric mass-preserving redistancing scheme for the level set function. Int. J. Numer. Meth. Fluids, 65: 989-1010. https://doi.org/10.1002/fld.2227.
| dim | An integer that denotes the dimension of the space in which the problem is solved. |
| VectorType | The vector type of the level-set vector. |
Definition at line 469 of file interface_tools.h.
|
inline |
Base constructor.
| [in] | background_triangulation | Shared pointer to the triangulation of the domain |
| [in] | background_fe | Shared pointer to the finite element discretizing the domain |
| [in] | p_max_distance | Maximum reinitialization distance value |
| [in] | p_iso_level | Iso-level (before scaling) from which the signed distance is computed |
| [in] | p_scaling | Scaling factor to apply to the input level-set field. It is used to switch the inside and outside subdomains, if needed. |
| [in] | p_verbosity | Verbosity level |
Definition at line 492 of file interface_tools.h.
References dof_handler, fe, H_x_transformation_jacobian, hessian_matrix, iso_level, mapping, max_distance, pcout, scaling, set_face_dofs_map(), set_face_opposite_dofs_map(), and verbosity.
|
inlineprivate |
Compute the analytical jacobian at the point x_n of the distance minimization problem for the DoF x_I in the reference face space (dim - 1): J_R = J^T*H*J, where J is the face transformation jacobian, and H is the Hessian matrix in the real space (H = H(d) + H(||x_I - x_n||)).
| [in] | transformation_jacobian | face transformation jacobian |
| [in] | face_local_dof_values | values of the DoFs of the face |
| [out] | jacobian_matrix | jacobian matrix of the minimization problem |
Definition at line 977 of file interface_tools.h.
References H_x_transformation_jacobian, and hessian_matrix.
|
private |
Compute the cell-wise volume correction to match the volume englobed by the given level of the level_set field in each element.
Definition at line 1213 of file interface_tools.cc.
References compute_cell_diameter(), InterfaceTools::compute_cell_wise_volume(), dof_handler, fe, interface_reconstruction_vertices, iso_level, level_set, mapping, signed_distance_with_ghost, and volume_correction.
|
inlineprivate |
Compute the distance according to: d(x_I) = d(x_n) + ||x_I - x_n||.
| [in] | x_n_to_x_I_real | vector from x_n to x_I in the real space |
| [in] | distance | value of the distance at the point x_n |
Definition at line 1062 of file interface_tools.h.
References distance.
|
private |
Compute the geometric distance (brute force) between the interface reconstruction and the DoFs of the intersected cells (first neighbors).
Definition at line 698 of file interface_tools.cc.
References distance, dof_handler, exchange_distance(), LetheGridTools::find_point_triangle_distance(), interface_reconstruction_cells, interface_reconstruction_vertices, intersected_dofs, and mapping.
|
inlineprivate |
Compute the stencil for the numerical jacobian of the distance minimization problem in the face where the problem is solved.
| [in] | x_ref | point in the reference cell space where the jacobian is evaluated |
| [in] | local_face_id | local id of the face in which the numerical jacobian is required |
| [in] | perturbation | value of the perturbation use for the numerical jacobian computation |
1 0 2
3
The entry 0 is the current evaluation point x_ref
Definition at line 897 of file interface_tools.h.
|
inlineprivate |
Compute the residual at the point x_n of the distance minimization problem for the DoF x_I in the reference face space (dim - 1). In the real space the residual correspond to: R = grad(d) - (x_I - x_n)/||x_I - x_n||.
| [in] | x_n_to_x_I_real | vector from x_n to x_I in the real space |
| [in] | distance_gradient | gradient of the distance at the point x_n |
| [in] | transformation_jac | transformation jacobian of the face |
| [out] | residual_ref | residual in the reference face space |
Definition at line 861 of file interface_tools.h.
|
private |
Compute the geometric distance (marching method) between the interface reconstruction and the rest of the DoFs (second neighbors).
Definition at line 765 of file interface_tools.cc.
References compute_analytical_jacobian(), compute_distance(), compute_residual(), constraints, distance, distance_with_ghost, dof_handler, exchange_distance(), fe, LetheGridTools::find_cells_around_cell(), get_face_local_dofs(), get_face_opposite_dofs(), get_face_transformation_jacobian(), interface_reconstruction_vertices, intersected_dofs, mapping, max_distance, pcout, Parameters::quiet, transform_ref_face_correction_to_ref_cell(), transform_ref_face_point_to_ref_cell(), verbosity, and LetheGridTools::vertices_cell_mapping().
|
private |
Compute the signed_distance from the distance vector and the sign of the signed_distance vector entries.
Definition at line 1182 of file interface_tools.cc.
References distance, locally_active_dofs, sgn(), signed_distance, and signed_distance_with_ghost.
|
private |
Correct the global volume to match the volume englobed by the given level of the level_set field.
Definition at line 1389 of file interface_tools.cc.
References distance, dof_handler, exchange_distance(), fe, InterfaceTools::integrate_volume_and_surface(), iso_level, level_set, locally_active_dofs, Parameters::quiet, signed_distance, signed_distance_with_ghost, verbosity, and volume_correction.
|
private |
Exchange the distance and set it to the minimum value across the processors by using the compress(VectorOperation::min) function.
Definition at line 669 of file interface_tools.cc.
References distance, distance_with_ghost, and locally_active_dofs.
| std::vector< OutputStruct< dim, GlobalVectorType > > InterfaceTools::SignedDistanceSolver< dim, VectorType >::gather_output_hook | ( | ) |
Gather and return vector of output structs that are particular to some applications.
Definition at line 1588 of file interface_tools.cc.
References convert_vector_dealii_to_trilinos(), dof_handler, locally_owned_dofs, signed_distance, and signed_distance_output.
|
inlineprivate |
Return the local id of the opposite faces to the given local Dof (works for quad only).
| [in] | local_dof_id | Local id of the DoF in the cell |
| [out] | local_opposite_faces | The vector containing the id of the opposite faces |
Definition at line 684 of file interface_tools.h.
|
inlineprivate |
Return the local id of the face DoFs (works for quad only).
| [in] | local_face_id | Local id of the face in the cell |
| [out] | local_dofs | The vector containing the id of the local DoFs |
Definition at line 772 of file interface_tools.h.
References face_dofs_map.
|
inlineprivate |
Return the local id of the opposite DoFs to the given face (works for quad only).
| [in] | local_face_id | Local id of the face in the cell |
| [out] | local_opposite_dofs | The vector containing the id of the opposite DoFs |
Definition at line 757 of file interface_tools.h.
References face_opposite_dofs_map.
|
inlineprivate |
Return the face transformation jacobian (dim-1 x dim-1). This is required because the distance minimization problem is resolved in the reference face space (dim-1).
| [in] | cell_transformation_jac | transformation jacobian of the cell (dim x dim) |
| [in] | local_face_id | local id of the face |
| [out] | face_transformation_jac | face transformation jacobian (dim-1 x dim-1) faces |
Definition at line 792 of file interface_tools.h.
| VectorType & InterfaceTools::SignedDistanceSolver< dim, VectorType >::get_signed_distance | ( | ) |
Get the computed signed distance field.
Definition at line 621 of file interface_tools.cc.
References dof_handler, level_set, locally_owned_dofs, and signed_distance.
|
private |
Initialize the distance solution vectors to the given max_distance.
Definition at line 602 of file interface_tools.cc.
References distance, distance_with_ghost, iso_level, level_set, locally_active_dofs, max_distance, sgn(), signed_distance, and signed_distance_with_ghost.
| void InterfaceTools::SignedDistanceSolver< dim, VectorType >::output_interface_reconstruction | ( | const std::string & | output_name, |
| const std::string & | output_path, | ||
| const double | time, | ||
| const unsigned int | it ) |
Output the interface reconstruction used for signed distance computations.
This function writes the reconstructed interface vertices and cells to VTU files for visualization purposes.
| [in] | output_name | Name of the output file. |
| [in] | output_path | Path to the output directory. |
| [in] | time | Current simulation time. |
| [in] | it | Iteration number for file naming. |
Definition at line 1539 of file interface_tools.cc.
References InterfaceTools::InterfaceReconstructionDataOut< dim >::build_patches(), dof_handler, interface_reconstruction_vertices, pvd_handler_reconstruction, and write_vtu_and_pvd().
| void InterfaceTools::SignedDistanceSolver< dim, VectorType >::output_signed_distance | ( | const std::string & | output_name, |
| const std::string & | output_path, | ||
| const double | time, | ||
| const unsigned int | it ) |
Output the signed distance field for visualization.
This function writes the computed signed distance field to VTU files for post-processing and visualization.
| [in] | output_name | Name of the output file. |
| [in] | output_path | Path to the output directory. |
| [in] | time | Current simulation time. |
| [in] | it | Iteration number for file naming. |
Definition at line 1562 of file interface_tools.cc.
References dof_handler, mapping, pvd_handler_signed_distance, signed_distance, and write_vtu_and_pvd().
|
inlineprivate |
Set the map of local id of the face DoFs (works for quad only).
Definition at line 726 of file interface_tools.h.
References face_dofs_map.
|
inlineprivate |
Set the map of local id of the opposite DoFs to the given face (works for quad only).
Definition at line 701 of file interface_tools.h.
References face_opposite_dofs_map.
| void InterfaceTools::SignedDistanceSolver< dim, VectorType >::set_level_set_from_background_mesh | ( | const DoFHandler< dim > & | background_dof_handler, |
| const VectorType & | background_level_set_vector ) |
Set the level-set field from the background mesh solver.
This function transfers the level-set field from the main solver to the signed distance solver. For example, when using geometric redistanciation of the CLS phase indicator, the level-set field comes from the CLS solver.
| [in] | background_dof_handler | DoFHandler corresponding to the level-set field solver. |
| [in] | background_level_set_vector | Level-set solution vector from the background solver. |
Definition at line 529 of file interface_tools.cc.
References constraints, dof_handler, level_set, locally_owned_dofs, and scaling.
| void InterfaceTools::SignedDistanceSolver< dim, VectorType >::setup_dofs | ( | ) |
Initialize the degrees of freedom and associated memory.
This function sets up the DoF handler, initializes the solution vectors, and configures the constraints for the signed distance solver.
Definition at line 490 of file interface_tools.cc.
References constraints, distance, distance_with_ghost, dof_handler, fe, level_set, locally_active_dofs, locally_owned_dofs, locally_relevant_dofs, signed_distance, signed_distance_output, signed_distance_with_ghost, and volume_correction.
| void InterfaceTools::SignedDistanceSolver< dim, VectorType >::solve | ( | ) |
Solve for the signed distance from the given level of the level-set vector.
This function computes the signed distance field using the method described in Ausas et al. (2011). The algorithm preserves the interface location while computing accurate distances throughout the domain.
Definition at line 551 of file interface_tools.cc.
References announce_string(), compute_cell_wise_volume_correction(), compute_first_neighbors_distance(), compute_second_neighbors_distance(), compute_signed_distance_from_distance(), conserve_global_volume(), dof_handler, fe, initialize_distance(), interface_reconstruction_cells, interface_reconstruction_vertices, intersected_dofs, iso_level, level_set, mapping, pcout, Parameters::quiet, InterfaceTools::reconstruct_interface(), update_ghost_values(), verbosity, and zero_out_ghost_values().
|
inlineprivate |
Transform the Newton correction in a reference face to a tensor (dim) in the reference cell. This is required because the distance minimization problem is resolved in the reference face space (dim-1).
| [in] | correction_ref_face | Newton correction in the reference face |
| [in] | local_face_id | local id of the face |
Definition at line 942 of file interface_tools.h.
|
inlineprivate |
Transform a point dim-1 in a reference face to a point dim in the reference cell. This is required because the distance minimization problem is resolved in the reference face space (dim-1).
| [in] | x_ref_face | point dim-1 in the reference face |
| [in] | local_face_id | local id of the face |
Definition at line 825 of file interface_tools.h.
|
private |
Update the ghost DoFs entries of the solution vectors to gain read access to the ghost elements.
Definition at line 655 of file interface_tools.cc.
References distance, distance_with_ghost, signed_distance, signed_distance_with_ghost, and volume_correction.
|
private |
Zero the ghost DoFs entries of the solution vectors to gain write access to the ghost elements.
Definition at line 641 of file interface_tools.cc.
References distance, distance_with_ghost, signed_distance, signed_distance_with_ghost, and volume_correction.
|
private |
Hanging node constraints.
Definition at line 1124 of file interface_tools.h.
|
private |
Solution vector of the distance (write only).
Definition at line 1113 of file interface_tools.h.
|
private |
Solution vector of the distance with ghost values (read-only version of distance)
Definition at line 1117 of file interface_tools.h.
| DoFHandler<dim> InterfaceTools::SignedDistanceSolver< dim, VectorType >::dof_handler |
DoFHandler describing the problem.
Definition at line 609 of file interface_tools.h.
|
private |
Definition at line 1147 of file interface_tools.h.
|
private |
Definition at line 1145 of file interface_tools.h.
|
private |
Finite element discretizing the problem.
Definition at line 1069 of file interface_tools.h.
|
private |
Definition at line 1150 of file interface_tools.h.
|
private |
Definition at line 1149 of file interface_tools.h.
|
private |
Surface cells of the interface reconstruction stored in a cell-wise map (volume cell)
Definition at line 1134 of file interface_tools.h.
|
private |
Surface vertices of the interface reconstruction stored in a cell-wise map (volume cell)
Definition at line 1129 of file interface_tools.h.
|
private |
Set of DoFs belonging to intersected cells.
Definition at line 1137 of file interface_tools.h.
|
private |
Iso-level describing the interface from which the signed distance is computed (after scaling!!)
Definition at line 1079 of file interface_tools.h.
|
private |
Level-set field coming from the main solver.
Definition at line 1100 of file interface_tools.h.
|
private |
Set of locally active DoFs.
Definition at line 1097 of file interface_tools.h.
|
private |
Set of locally owned DoFs.
Definition at line 1091 of file interface_tools.h.
|
private |
Set of locally relevant DoFs.
Definition at line 1094 of file interface_tools.h.
|
private |
Mapping between the real and reference space.
Definition at line 1072 of file interface_tools.h.
|
private |
Maximum redistanciation distance.
Definition at line 1075 of file interface_tools.h.
|
private |
Parallel output stream.
Definition at line 1088 of file interface_tools.h.
|
private |
PVDHandler for interface reconstruction.
Definition at line 1140 of file interface_tools.h.
|
private |
PVDHandler for signed distance.
Definition at line 1143 of file interface_tools.h.
|
private |
Scaling factor to apply to the input level-set field.
Definition at line 1082 of file interface_tools.h.
|
private |
Solution vector of the signed distance (write only).
Definition at line 1103 of file interface_tools.h.
|
private |
Solution vector of the signed distance as used for output only.
Definition at line 1106 of file interface_tools.h.
|
private |
Solution vector of the signed distance with ghost values (read-only version of signed_distance)
Definition at line 1110 of file interface_tools.h.
|
private |
Verbosity level.
Definition at line 1085 of file interface_tools.h.
|
private |
Value of the correction to apply to the signed_distance to match the cell-wise volume encompassed by the level 0 of level_set
Definition at line 1121 of file interface_tools.h.