include/meltpooldg/cut/util.hpp Source File

Developer Documentation: include/meltpooldg/cut/util.hpp Source File
Developer Documentation
util.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <deal.II/base/array_view.h>
4#include <deal.II/base/vectorization.h>
5
6#include <deal.II/dofs/dof_handler.h>
7
8#include <deal.II/grid/tria.h>
9
10#include <deal.II/matrix_free/evaluation_flags.h>
11#include <deal.II/matrix_free/fe_point_evaluation.h>
12#include <deal.II/matrix_free/matrix_free.h>
13
14#include <deal.II/non_matching/mapping_info.h>
15#include <deal.II/non_matching/mesh_classifier.h>
16
19
20#include <memory>
21#include <utility>
22#include <vector>
23
24namespace MeltPoolDG::CutUtil
25{
33 BETTER_ENUM(CutPhaseType, char, not_cut, one_phase_cut, two_phase_cut)
34
35
44 template <int dim>
45 CutPhaseType
46 get_cut_type(const dealii::DoFHandler<dim> &dof_handler);
47
51 template <int dim, typename number>
53 dealii::NonMatching::MappingInfo<dim, dim, dealii::VectorizedArray<number>>;
54
55 template <int dim, typename number>
56 using MappingInfoVectorType = std::vector<std::shared_ptr<MappingInfoType<dim, number>>>;
57
62 {
63 liquid = 0,
65 gas = 2
66 };
67
72 {
76 mixed_face_liquid_intersected, // "inside" cell in liquid phase; "outside" cell intersected
77 mixed_face_intersected_liquid, // "inside" cell intersected; "outside" cell in liquid phase
78 mixed_face_gas_intersected, // "inside" cell in gas phase; "outside" cell intersected
79 mixed_face_intersected_gas // "inside" cell intersected; "outside" cell in gas phase
80 };
81
91 get_face_type(const std::pair<unsigned int, unsigned int> &adjacent_cell_categories);
92
107 template <int dim>
108 void
109 set_fe_index(const dealii::DoFHandler<dim> &dof_handler,
110 const dealii::NonMatching::MeshClassifier<dim> &mesh_classifier,
111 const bool set_future);
112
133 template <int dim>
134 bool
135 cell_classifications_changed(const dealii::Triangulation<dim> &tria,
136 const dealii::NonMatching::MeshClassifier<dim> &mesh_classifier_old,
137 const dealii::NonMatching::MeshClassifier<dim> &mesh_classifier,
138 const MPI_Comm mpi_comm);
139
174 template <int dim, typename number, typename VectorType>
175 void
177 MappingInfoVectorType<dim, number> mapping_info_cells,
178 MappingInfoType<dim, number> &mapping_info_surface,
179 const dealii::DoFHandler<dim> &level_set_dof_handler,
180 const VectorType &level_set,
181 const dealii::MatrixFree<dim, number, dealii::VectorizedArray<number>> &matrix_free,
182 const int fe_degree,
183 const bool is_two_phase,
184 const bool is_dg = false,
185 MappingInfoVectorType<dim, number> mapping_info_faces = {});
186
187
188
217 template <int dim, typename number, typename VectorType>
218 void
220 MappingInfoType<dim, number> &mapping_info_surface,
221 const dealii::DoFHandler<dim> &level_set_dof_handler,
222 const VectorType &level_set,
223 const dealii::MatrixFree<dim, number, dealii::VectorizedArray<number>> &matrix_free,
224 const int fe_degree);
225
226
248 template <int dim, typename number, int n_components = 1>
249 inline void
251 dealii::FEPointEvaluation<n_components, dim, dim, dealii::VectorizedArray<number>> &point_eval,
253 const dealii::EvaluationFlags::EvaluationFlags evaluation_flags,
254 const unsigned int cell_batch,
255 const unsigned int cell_lane,
256 const unsigned int n_dofs_per_cell)
257 {
258 static constexpr unsigned int n_lanes = dealii::VectorizedArray<number>::size();
259
260 point_eval.reinit(cell_batch * n_lanes + cell_lane);
261 point_eval.evaluate(dealii::StridedArrayView<const number, n_lanes>(
262 &cell_eval.begin_dof_values()[0][cell_lane], n_dofs_per_cell),
263 evaluation_flags);
264 }
265
292 template <int dim>
293 bool
294 face_has_ghost_penalty(const dealii::NonMatching::MeshClassifier<dim> &mesh_classifier,
295 const typename dealii::Triangulation<dim>::active_cell_iterator &cell,
296 const unsigned int face_index,
297 const dealii::NonMatching::LocationToLevelSet &inactive_location =
298 dealii::NonMatching::LocationToLevelSet::inside)
299 {
300 if (cell->at_boundary(face_index))
301 return false;
302
303 const dealii::NonMatching::LocationToLevelSet cell_location =
304 mesh_classifier.location_to_level_set(cell);
305 const dealii::NonMatching::LocationToLevelSet neighbor_location =
306 mesh_classifier.location_to_level_set(cell->neighbor(face_index));
307
308 if (cell_location == dealii::NonMatching::LocationToLevelSet::intersected and
309 neighbor_location != inactive_location)
310 return true;
311
312 if (neighbor_location == dealii::NonMatching::LocationToLevelSet::intersected and
313 cell_location != inactive_location)
314 return true;
315
316 return false;
317 }
318
337 constexpr bool
338 face_type_has_ghost_penalty(const FaceType face_type, const bool is_liquid_phase)
339 {
340 if (face_type == FaceType::intersected_face)
341 return true;
342
343 if (is_liquid_phase)
344 return face_type == FaceType::mixed_face_liquid_intersected or
346
347 return face_type == FaceType::mixed_face_gas_intersected or
349 }
350
381 template <int dim>
382 bool
383 is_new_intersected_face(const dealii::NonMatching::MeshClassifier<dim> &mesh_classifier,
384 const dealii::NonMatching::MeshClassifier<dim> &mesh_classifier_old,
385 const typename dealii::Triangulation<dim>::active_cell_iterator &cell,
386 const unsigned int face_index,
387 const dealii::NonMatching::LocationToLevelSet &inactive_location =
388 dealii::NonMatching::LocationToLevelSet::inside)
389 {
390 if (cell->at_boundary(face_index))
391 return false;
392
393 const dealii::NonMatching::LocationToLevelSet cell_location =
394 mesh_classifier.location_to_level_set(cell);
395 const dealii::NonMatching::LocationToLevelSet neighbor_location =
396 mesh_classifier.location_to_level_set(cell->neighbor(face_index));
397
398 const dealii::NonMatching::LocationToLevelSet cell_location_old =
399 mesh_classifier_old.location_to_level_set(cell);
400 const dealii::NonMatching::LocationToLevelSet neighbor_location_old =
401 mesh_classifier_old.location_to_level_set(cell->neighbor(face_index));
402
403 if (cell_location == dealii::NonMatching::LocationToLevelSet::intersected and
404 neighbor_location == dealii::NonMatching::LocationToLevelSet::intersected and
405 cell_location_old == inactive_location and neighbor_location_old == inactive_location)
406 return true;
407
408 return false;
409 }
410} // namespace MeltPoolDG::CutUtil
Utilities for the weighted repartitioning of a parallel::distributed::Triangulation in cutFEM/cutDG a...
Definition amr.hpp:15
bool face_has_ghost_penalty(const dealii::NonMatching::MeshClassifier< dim > &mesh_classifier, const typename dealii::Triangulation< dim >::active_cell_iterator &cell, const unsigned int face_index, const dealii::NonMatching::LocationToLevelSet &inactive_location=dealii::NonMatching::LocationToLevelSet::inside)
This function checks whether the currently considered face requires the application of ghost-penalty ...
Definition util.hpp:294
FaceType
Enumeration for the face type.
Definition util.hpp:72
@ mixed_face_gas_intersected
Definition util.hpp:78
@ mixed_face_liquid_intersected
Definition util.hpp:76
@ mixed_face_intersected_gas
Definition util.hpp:79
@ intersected_face
Definition util.hpp:75
@ mixed_face_intersected_liquid
Definition util.hpp:77
@ inside_face_liquid
Definition util.hpp:73
@ inside_face_gas
Definition util.hpp:74
CutPhaseType get_cut_type(const dealii::DoFHandler< dim > &dof_handler)
Enum that names a type of CutFEM in use.
Definition util.cpp:19
bool cell_classifications_changed(const dealii::Triangulation< dim > &tria, const dealii::NonMatching::MeshClassifier< dim > &mesh_classifier_old, const dealii::NonMatching::MeshClassifier< dim > &mesh_classifier, const MPI_Comm mpi_comm)
Definition util.cpp:126
CellCategory
Definition of the cell category numbering (active FE index).
Definition util.hpp:62
@ liquid
Definition util.hpp:63
@ intersected
Definition util.hpp:64
@ gas
Definition util.hpp:65
std::vector< std::shared_ptr< MappingInfoType< dim, number > > > MappingInfoVectorType
Definition util.hpp:56
void compute_immersed_surface_quadrature(MappingInfoType< dim, number > &mapping_info_surface, const dealii::DoFHandler< dim > &level_set_dof_handler, const VectorType &level_set, const dealii::MatrixFree< dim, number, dealii::VectorizedArray< number > > &matrix_free, const int fe_degree)
This function generates the immersed quadrature rules in the case that the domain is described by a d...
Definition util.cpp:279
dealii::NonMatching::MappingInfo< dim, dim, dealii::VectorizedArray< number > > MappingInfoType
Definition util.hpp:53
void set_fe_index(const dealii::DoFHandler< dim > &dof_handler, const dealii::NonMatching::MeshClassifier< dim > &mesh_classifier, const bool set_future)
This function is setting the FE index for every cell.
Definition util.cpp:94
bool is_new_intersected_face(const dealii::NonMatching::MeshClassifier< dim > &mesh_classifier, const dealii::NonMatching::MeshClassifier< dim > &mesh_classifier_old, const typename dealii::Triangulation< dim >::active_cell_iterator &cell, const unsigned int face_index, const dealii::NonMatching::LocationToLevelSet &inactive_location=dealii::NonMatching::LocationToLevelSet::inside)
This function checks whether the considered face is a newly created intersected face.
Definition util.hpp:383
void evaluate_intersected_domain(dealii::FEPointEvaluation< n_components, dim, dim, dealii::VectorizedArray< number > > &point_eval, const FECellIntegrator< dim, n_components, number > &cell_eval, const dealii::EvaluationFlags::EvaluationFlags evaluation_flags, const unsigned int cell_batch, const unsigned int cell_lane, const unsigned int n_dofs_per_cell)
Evaluates solution values in the intersected domain for a specific SIMD lane within a cell batch.
Definition util.hpp:250
FaceType get_face_type(const std::pair< unsigned int, unsigned int > &adjacent_cell_categories)
This function categorizes the FaceType of the current face range.
Definition util.cpp:38
void compute_intersected_quadrature(MappingInfoVectorType< dim, number > mapping_info_cells, MappingInfoType< dim, number > &mapping_info_surface, const dealii::DoFHandler< dim > &level_set_dof_handler, const VectorType &level_set, const dealii::MatrixFree< dim, number, dealii::VectorizedArray< number > > &matrix_free, const int fe_degree, const bool is_two_phase, const bool is_dg=false, MappingInfoVectorType< dim, number > mapping_info_faces={})
This function generates the immersed quadrature rules in the case that the domain is described by a d...
Definition util.cpp:145
constexpr bool face_type_has_ghost_penalty(const FaceType face_type, const bool is_liquid_phase)
Checks whether the ghost penalty stabilization applies on a face.
Definition util.hpp:338
BETTER_ENUM(MaterialTemplate, char, none, stainless_steel, Ti64, Ti64Benchmark) BETTER_ENUM(SolidLiquidPropertiesTransitionType
dealii::FEEvaluation< dim, -1, 0, n_components, number, VectorizedArrayType > FECellIntegrator
Definition fe_integrator.hpp:14