19 #include <boost/geometry.hpp>
27 using namespace magic_enum::bitwise_operators;
33 template <
int dim,
int spacedim>
35 const std::string §ion_name,
36 const dealii::ComponentMask &embedded_mask,
37 const dealii::ComponentMask &space_mask,
41 const unsigned int space_pre_refinement,
42 const unsigned int embedded_post_refinement,
43 const std::string &quadrature_type,
44 const unsigned int quadrature_order,
45 const unsigned int quadrature_repetitions,
46 double quadrature_tolerance)
48 , embedded_mask(embedded_mask)
49 , space_mask(space_mask)
50 , coupling_type(coupling_type)
51 , refinement_strategy(refinement_strategy)
52 , space_pre_refinement(space_pre_refinement)
53 , embedded_post_refinement(embedded_post_refinement)
54 , embedded_quadrature_type(quadrature_type)
55 , quadrature_order(quadrature_order)
56 , embedded_quadrature_repetitions(quadrature_repetitions)
57 , quadrature_tolerance(quadrature_tolerance)
61 add_parameter(
"Refinement strategy", this->refinement_strategy);
63 add_parameter(
"Space pre-refinement", this->space_pre_refinement);
65 add_parameter(
"Embedded post-refinement", this->embedded_post_refinement);
74 add_parameter(
"Embedded quadrature order", this->quadrature_order);
80 "Quadrature tolerance",
81 this->quadrature_tolerance,
82 "If an intersection integrates to a value smaller than this tolerance, "
83 "it is discarded during exact intersection.");
88 template <
int dim,
int spacedim>
92 return this->coupling_type;
97 template <
int dim,
int spacedim>
107 this->space_cache = &space_cache;
108 this->space_dh = &space_dh;
109 this->space_constraints = &space_constraints;
110 this->embedded_cache = &embedded_cache;
111 this->embedded_dh = &embedded_dh;
112 this->embedded_constraints = &embedded_constraints;
114 embedded_quadrature =
116 this->quadrature_order),
117 this->embedded_quadrature_repetitions);
122 template <
int dim,
int spacedim>
127 const bool apply_delta_refinements)
const
132 "The passed embedded triangulation must be the same as the "
133 "one used by the embedded DoFHandler with which you "
134 "initialized this class."));
136 ExcMessage(
"The passed space triangulation must be the same as the "
137 "one used by the space DoFHandler with which you "
138 "initialized this class."));
142 auto refine = [&]() {
145 double min_embedded = 1e10;
146 double max_embedded = 0;
147 double min_space = 1e10;
148 double max_space = 0;
150 while (done ==
false)
157 const auto &embedded_tree =
164 const bool use_space =
165 ((this->refinement_strategy & RefinementStrategy::refine_space) ==
166 RefinementStrategy::refine_space);
168 const bool use_embedded = ((this->refinement_strategy &
169 RefinementStrategy::refine_embedded) ==
170 RefinementStrategy::refine_embedded);
172 ExcMessage(
"You can't refine both the embedded and "
173 "the space grid at the same time."));
175 for (
const auto &[embedded_box, embedded_cell] : embedded_tree)
177 const auto &[p1, p2] = embedded_box.get_boundary_points();
178 const auto diameter = p1.distance(p2);
182 for (
const auto &[space_box, space_cell] :
183 tree | bgi::adaptors::queried(bgi::intersects(embedded_box)))
185 const auto &[sp1, sp2] = space_box.get_boundary_points();
186 const auto space_diameter = sp1.distance(sp2);
187 min_space =
std::min(min_space, space_diameter);
188 max_space =
std::max(max_space, space_diameter);
190 if (use_embedded && space_diameter <
diameter)
192 embedded_cell->set_refine_flag();
195 if (use_space &&
diameter < space_diameter)
197 space_cell->set_refine_flag();
208 embedded_post_refinemnt_signal();
214 space_post_refinemnt_signal();
218 return std::make_tuple(min_space, max_space, min_embedded, max_embedded);
225 if (apply_delta_refinements && space_pre_refinement != 0)
226 for (
unsigned int i = 0; i < space_pre_refinement; ++i)
231 const auto &embedded_tree =
234 for (
const auto &[embedded_box, embedded_cell] : embedded_tree)
235 for (
const auto &[space_box, space_cell] :
236 tree | bgi::adaptors::queried(bgi::intersects(embedded_box)))
237 space_cell->set_refine_flag();
241 space_post_refinemnt_signal();
248 if (apply_delta_refinements && embedded_post_refinement != 0)
251 embedded_post_refinemnt_signal();
255 const auto [sm, sM, em, eM] =
refine();
257 deallog <<
"Space local min/max diameters : " << sm <<
"/" << sM
259 <<
"Embedded space min/max diameters: " << em <<
"/" << eM
265 template class NonMatchingCoupling<1, 1>;
266 template class NonMatchingCoupling<1, 2>;
267 template class NonMatchingCoupling<1, 3>;
268 template class NonMatchingCoupling<2, 2>;
269 template class NonMatchingCoupling<2, 3>;
270 template class NonMatchingCoupling<3, 3>;
const Triangulation< dim, spacedim > & get_triangulation() const
static ParameterHandler prm
void add_parameter(const std::string &entry, ParameterType ¶meter, const std::string &documentation="", ParameterHandler &prm_=prm, const Patterns::PatternBase &pattern=*Patterns::Tools::Convert< ParameterType >::to_pattern())
void refine_global(const unsigned int times=1)
virtual void execute_coarsening_and_refinement()
#define Assert(cond, exc)
static ::ExceptionBase & ExcNotInitialized()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
void refine(Triangulation< dim, spacedim > &tria, const Vector< Number > &criteria, const double threshold, const unsigned int max_to_mark=numbers::invalid_unsigned_int)
::VectorizedArray< Number, width > min(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)