4#ifndef lethe_interface_tools_h
5#define lethe_interface_tools_h
13#include <deal.II/base/conditional_ostream.h>
14#include <deal.II/base/data_out_base.h>
15#include <deal.II/base/function.h>
17#include <deal.II/dofs/dof_handler.h>
19#include <deal.II/fe/fe.h>
20#include <deal.II/fe/fe_q.h>
21#include <deal.II/fe/mapping_fe.h>
23#include <deal.II/lac/lapack_full_matrix.h>
25#include <deal.II/matrix_free/fe_point_evaluation.h>
27#include <deal.II/non_matching/fe_immersed_values.h>
49 typename FEType = FE_Q<dim>>
89 value(
const Point<dim> &point,
90 const unsigned int component = 0)
const override;
106 const unsigned int component = 0)
const override;
119 SymmetricTensor<2, dim>
120 hessian(
const Point<dim> &point,
121 const unsigned int component = 0)
const override;
135 template <
int dim,
typename VectorType,
typename FEType>
138 const Point<dim> &point,
139 const unsigned int component)
const
149 template <
int dim,
typename VectorType,
typename FEType>
150 inline Tensor<1, dim>
152 const Point<dim> &point,
153 const unsigned int component)
const
163 template <
int dim,
typename VectorType,
typename FEType>
164 inline SymmetricTensor<2, dim>
166 const Point<dim> &point,
167 const unsigned int component)
const
204 FEPointEvaluation<1, dim> &fe_point_evaluation,
205 const typename DoFHandler<dim>::active_cell_iterator &cell,
206 Vector<double> cell_dof_level_set_values,
208 const unsigned int n_quad_points);
227 template <
int dim,
typename VectorType>
228 std::pair<double, double>
230 const DoFHandler<dim> &dof_handler,
231 const FiniteElement<dim> &fe,
232 const VectorType &level_set_vector_relevant_copy);
253 template <
int dim,
typename VectorType>
254 std::pair<double, double>
256 const FiniteElement<dim> &fe,
258 const double iso_level);
285 template <
int dim,
typename VectorType>
286 std::pair<Point<dim>, Tensor<1, dim>>
288 const FiniteElement<dim> &fe,
289 const VectorType &level_set_vector_relevant_copy,
290 const Mapping<dim> &mapping_velocity,
291 const DoFHandler<dim> &dof_handler_velocity,
292 const FiniteElement<dim> &fe_velocity,
322 template <
int dim,
typename VectorType>
323 std::pair<Point<dim>, Tensor<1, dim>>
325 const FiniteElement<dim> &fe,
327 const Mapping<dim> &mapping_velocity,
328 const DoFHandler<dim> &dof_handler_velocity,
329 const FiniteElement<dim> &fe_velocity,
331 const double iso_level);
369 template <
int dim,
typename VectorType>
372 const Mapping<dim> &mapping,
373 const DoFHandler<dim> &dof_handler,
374 const FiniteElement<dim> &fe,
376 const double iso_level,
377 std::map<types::global_cell_index, std::vector<Point<dim>>>
378 &interface_reconstruction_vertices,
379 std::map<types::global_cell_index, std::vector<CellData<dim - 1>>>
380 &interface_reconstruction_cells,
381 std::set<types::global_dof_index> &intersected_dofs);
412 const std::map<types::global_cell_index, std::vector<Point<dim>>>
413 &interface_reconstruction_vertices);
419 const std::vector<DataOutBase::Patch<0, dim>> &
428 std::vector<std::string>
436 std::vector<DataOutBase::Patch<0, dim>>
patches;
445 const std::map<types::global_cell_index, std::vector<Point<dim>>>
446 &interface_reconstruction_vertices)
448 for (
auto const &cell : interface_reconstruction_vertices)
450 const std::vector<Point<dim>> &vertices = cell.second;
451 for (
const Point<dim> &vertex : vertices)
453 DataOutBase::Patch<0, dim> temp;
454 temp.vertices[0] = vertex;
468 template <
int dim,
typename VectorType>
493 const std::shared_ptr<parallel::DistributedTriangulationBase<dim>>
494 &background_triangulation,
495 std::shared_ptr<FiniteElement<dim>> background_fe,
496 const double p_max_distance,
497 const double p_iso_level,
498 const double p_scaling,
501 ,
fe(std::move(background_fe))
507 (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0))
512 mapping = std::make_shared<MappingQ<dim>>(
fe->degree);
545 const DoFHandler<dim> &background_dof_handler,
546 const VectorType &background_level_set_vector);
579 const std::string &output_path,
581 const unsigned int it);
596 const std::string &output_path,
598 const unsigned int it);
605 std::vector<OutputStruct<dim, GlobalVectorType>>
685 std::vector<unsigned int> &local_opposite_faces)
687 unsigned int local_dof_id_2d = local_dof_id % 4;
689 local_opposite_faces[0] = (local_dof_id_2d + 1) % 2;
690 local_opposite_faces[1] = 3 - local_dof_id_2d / 2;
692 if constexpr (dim == 3)
693 local_opposite_faces[2] = 5 - local_dof_id / 4;
703 if constexpr (dim == 2)
711 if constexpr (dim == 3)
728 if constexpr (dim == 2)
736 if constexpr (dim == 3)
758 std::vector<unsigned int> &local_opposite_dofs)
773 std::vector<unsigned int> &local_dofs)
793 const DerivativeForm<1, dim, dim> &cell_transformation_jac,
794 const unsigned int local_face_id,
795 LAPACKFullMatrix<double> &face_transformation_jac)
797 for (
int i = 0; i < dim; ++i)
800 for (
unsigned int j = 0; std::cmp_less(j, dim); ++j)
802 if (local_face_id / 2 == j)
806 face_transformation_jac(i, k) = cell_transformation_jac[i][j];
826 const unsigned int local_face_id)
828 Point<dim> x_ref_cell;
831 for (
unsigned int i = 0; std::cmp_less(i, dim); ++i)
833 if (local_face_id / 2 == i)
835 x_ref_cell[i] = double(local_face_id % 2);
838 x_ref_cell[i] = x_ref_face[j];
862 const Tensor<1, dim> &distance_gradient,
863 const LAPACKFullMatrix<double> &transformation_jac,
864 Tensor<1, dim - 1> &residual_ref)
866 Tensor<1, dim> residual_real =
867 distance_gradient - (1.0 / x_n_to_x_I_real.norm()) * x_n_to_x_I_real;
869 for (
int i = 0; i < dim - 1; ++i)
870 for (
int j = 0; j < dim; ++j)
871 residual_ref[i] += transformation_jac(j, i) * residual_real[j];
898 const unsigned int local_face_id,
899 const double perturbation,
900 std::vector<Point<dim>> &stencil)
902 for (
int i = 0; i < 2 * dim - 1; ++i)
907 unsigned int skip_index = local_face_id / 2;
908 std::vector<unsigned int> j_index(dim - 1);
913 for (
unsigned int i = 0; std::cmp_less(i, dim); ++i)
921 for (
int i = 1; i < dim; ++i)
924 stencil[2 * i - 1][j] -= perturbation;
925 stencil[2 * i][j] += perturbation;
941 inline Tensor<1, dim>
943 const Vector<double> &correction_ref_face,
944 const unsigned int local_face_id)
946 Tensor<1, dim> correction_ref_cell;
949 for (
unsigned int i = 0; std::cmp_less(i, dim); ++i)
951 if (local_face_id / 2 == i)
953 correction_ref_cell[i] = 0.0;
956 correction_ref_cell[i] = correction_ref_face[j];
960 return correction_ref_cell;
978 const Tensor<1, dim> &x_n_to_x_I_real_p1,
979 const LAPACKFullMatrix<double> &transformation_jacobian,
980 const std::vector<double> &face_local_dof_values,
981 LAPACKFullMatrix<double> &jacobian_matrix)
983 const double x_n_to_x_I_real_p1_norm = x_n_to_x_I_real_p1.norm();
985 const double x_n_to_x_I_real_p1_norm_inv = 1.0 / x_n_to_x_I_real_p1_norm;
987 const double x_n_to_x_I_real_p1_norm_cubic_inv =
988 x_n_to_x_I_real_p1_norm_inv * x_n_to_x_I_real_p1_norm_inv *
989 x_n_to_x_I_real_p1_norm_inv;
991 for (
int i = 0; i < dim; ++i)
993 double h_ii = -(x_n_to_x_I_real_p1[i] * x_n_to_x_I_real_p1[i]) *
994 x_n_to_x_I_real_p1_norm_cubic_inv +
995 x_n_to_x_I_real_p1_norm_inv;
999 for (
int j = i + 1; j < dim; ++j)
1001 double h_ij = -(x_n_to_x_I_real_p1[i] * x_n_to_x_I_real_p1[j]) *
1002 x_n_to_x_I_real_p1_norm_cubic_inv;
1009 for (
int i = 0; i < dim; ++i)
1011 for (
int j = 0; j < dim - 1; ++j)
1013 double matrix_ij = 0;
1014 for (
int k = 0; k < dim; ++k)
1023 for (
int i = 0; i < dim - 1; ++i)
1025 for (
int j = i; j < dim - 1; ++j)
1027 double matrix_ij = 0;
1028 for (
int k = 0; k < dim; ++k)
1030 matrix_ij += transformation_jacobian(k, i) *
1033 jacobian_matrix(i, j) = matrix_ij;
1034 jacobian_matrix(j, i) = matrix_ij;
1041 double off_diag_H = 0;
1042 if constexpr (dim == 3)
1044 off_diag_H = face_local_dof_values[0] - face_local_dof_values[1] -
1045 face_local_dof_values[2] + face_local_dof_values[3];
1046 jacobian_matrix(0, 1) += off_diag_H;
1047 jacobian_matrix(1, 0) += off_diag_H;
1065 return distance + x_n_to_x_I_real.norm();
1069 std::shared_ptr<FiniteElement<dim>>
fe;
1128 std::map<types::global_cell_index, std::vector<Point<dim>>>
1133 std::map<types::global_cell_index, std::vector<CellData<dim - 1>>>
1203 dealii::Vector<double>
1206 dealii::Vector<double> bounding_values_vec(2 * dim);
1207 for (
int i = 0; i < dim; ++i)
1209 bounding_values_vec[2 * i] = std::numeric_limits<double>::max();
1210 bounding_values_vec[2 * i + 1] = -std::numeric_limits<double>::max();
1212 return bounding_values_vec;
1223 std::array<std::string, 2 * dim>
1226 if constexpr (dim == 2)
1227 return {{
"x_min",
"x_max",
"y_min",
"y_max"}};
1229 return {{
"x_min",
"x_max",
"y_min",
"y_max",
"z_min",
"z_max"}};
1248 template <
int dim,
typename VectorType>
1249 IsocontourBoundingValues<dim>
1252 const double isovalue);
1275 template <
int dim,
typename VectorType>
1280 std::pair<
unsigned int,
1282 dim>::IsocontourBoundingBoxes::Isocontour>>
1283 &ids_and_isocontours_per_variable,
1284 const DoFHandler<dim> &dof_handler,
1286 const double current_time,
1288 const ConditionalOStream &pcout,
1289 std::vector<TableHandler> &isocontour_bounding_values_tables);
1306 const MPI_Comm &mpi_communicator,
1307 const std::string &output_folder,
1310 std::pair<
unsigned int,
1312 dim>::IsocontourBoundingBoxes::Isocontour>>
1313 &ids_and_isocontours_per_variable,
1314 const std::vector<TableHandler> &isocontour_bounding_values_tables);
The PVDHandler class manages the storage of the information required to write pvd file....
Postprocessing - Defines the parameters for the post-processing. In Lethe, post-processing implies th...
Variable
Solution fields of the different physics that are used as an indicator for multiple purposes (e....
GlobalVectorType VectorType
dealii::TrilinosWrappers::MPI::Vector GlobalVectorType