include/meltpooldg/level_set/delta_approximation_phase_weighted.hpp Source File

Developer Documentation: include/meltpooldg/level_set/delta_approximation_phase_weighted.hpp Source File
Developer Documentation
delta_approximation_phase_weighted.hpp
Go to the documentation of this file.
1#pragma once
2#include <deal.II/base/vectorization.h>
3
6
8{
9 template <typename number>
11 {
12 public:
13 virtual ~DeltaApproximationBase() = default;
14
15 virtual number
16 compute_weight(const number ls_heaviside) const = 0;
17
18 virtual dealii::VectorizedArray<number>
19 compute_weight(const dealii::VectorizedArray<number> &ls_heaviside) const = 0;
20 };
21
22
38 template <typename number>
40 {
41 public:
43
44 inline number
45 compute_weight(const number level_set_heaviside) const override
46 {
47 return compute_weight_internal(level_set_heaviside);
48 }
49
50 inline dealii::VectorizedArray<number>
51 compute_weight(const dealii::VectorizedArray<number> &level_set_heaviside) const override
52 {
53 dealii::VectorizedArray<number> temp(0.0);
54 for (unsigned int v = 0; v < dealii::VectorizedArray<number>::size(); ++v)
55 temp = compute_weight_internal(level_set_heaviside[v]);
56 return temp;
57 }
58
59 private:
60 template <typename value_type>
61 inline value_type
62 compute_weight_internal(const value_type &level_set_heaviside) const
63 {
64 if (level_set_heaviside > 0.5)
65 return 2.0;
66 else
67 return 0.0;
68 }
69 };
70
71
101 template <typename number>
103 {
104 public:
107 : w_g(data.gas_phase_weight)
108 , w_h(data.heavy_phase_weight)
109 , correction_factor(2. / (w_g + w_h))
110 {
111 AssertThrow(w_g + w_h != 0.0,
112 dealii::ExcMessage("When using a phase weighted Dirac delta function "
113 "approximation use weights that don't sum up to zero! "
114 "Abort..."));
115 }
116
117 inline number
118 compute_weight(const number level_set_heaviside) const override
119 {
120 return compute_weight_internal(level_set_heaviside);
121 }
122
123 inline dealii::VectorizedArray<number>
124 compute_weight(const dealii::VectorizedArray<number> &level_set_heaviside) const override
125 {
126 return compute_weight_internal(level_set_heaviside);
127 }
128
129 private:
138 template <typename value_type>
139 inline value_type
140 compute_weight_internal(const value_type &level_set_heaviside) const
141 {
142 return Tools::interpolate(level_set_heaviside, w_g, w_h) * correction_factor;
143 }
144
145 const number w_g;
146 const number w_h;
147
148 /*
149 * correction factor
150 *
151 * 2
152 * -----------
153 * w_g + w_h
154 */
155 const number correction_factor;
156 };
157
183 template <typename number>
185 : public DeltaApproximationBase<number>
186 {
187 public:
190 : w_1g(data.gas_phase_weight)
191 , w_1h(data.heavy_phase_weight)
192 , w_2g(data.gas_phase_weight_2)
193 , w_2h(data.heavy_phase_weight_2)
194 , correction_factor(6. / (2. * w_1g * w_2g + w_1g * w_2h + w_1h * w_2g + 2. * w_1h * w_2h))
195 {
196 AssertThrow(std::abs(2. * w_1g * w_2g + w_1g * w_2h + w_1h * w_2g + 2. * w_1h * w_2h) >
197 std::numeric_limits<number>::epsilon(),
198 dealii::ExcMessage("When using a phase quadratic weighted Dirac delta "
199 "function approximation use weights that fulfill this "
200 "condition! Abort..."));
201 }
202
203 inline number
204 compute_weight(const number level_set_heaviside) const override
205 {
206 return compute_weight_internal(level_set_heaviside);
207 }
208
209 inline dealii::VectorizedArray<number>
210 compute_weight(const dealii::VectorizedArray<number> &level_set_heaviside) const override
211 {
212 return compute_weight_internal(level_set_heaviside);
213 }
214
215 private:
224 template <typename value_type>
225 inline value_type
226 compute_weight_internal(const value_type &level_set_heaviside) const
227 {
228 const auto w_1 = Tools::interpolate(level_set_heaviside, w_1g, w_1h);
229 const auto w_2 = Tools::interpolate(level_set_heaviside, w_2g, w_2h);
230 return w_1 * w_2 * correction_factor;
231 }
232
233 const number w_1g;
234 const number w_1h;
235 const number w_2g;
236 const number w_2h;
237
238 /*
239 * correction factor
240 *
241 * 6
242 * ---------------------------------------------------
243 * 2 w_1g w_2g + w_1g w_2h + w_1h w_2g + 2 w_1h w_2h
244 */
245 const number correction_factor;
246 };
247
278 template <typename number>
280 {
281 public:
284 : w_g(data.gas_phase_weight)
285 , w_h(data.heavy_phase_weight)
286 , correction_factor((w_g - w_h) / (w_g * w_h * std::log(w_g / w_h)))
287 {
288 AssertThrow(w_g > 0.0,
289 dealii::ExcMessage("When using the Dirac delta function approximation "
290 "weighted consistent with evaporation use positive weights! "
291 "Abort..."));
292 AssertThrow(w_h > 0.0,
293 dealii::ExcMessage("When using the Dirac delta function approximation "
294 "weighted consistent with evaporation use positive weights! "
295 "Abort..."));
296 AssertThrow(std::abs(w_g - w_h) > std::numeric_limits<number>::epsilon(),
297 dealii::ExcMessage("When using the Dirac delta function approximation "
298 "weighted consistent with evaporation the phase weights must "
299 "differ! Abort..."));
300 }
301
302 inline number
303 compute_weight(const number level_set_heaviside) const override
304 {
305 return compute_weight_internal(level_set_heaviside);
306 }
307
308 inline dealii::VectorizedArray<number>
309 compute_weight(const dealii::VectorizedArray<number> &level_set_heaviside) const override
310 {
311 return compute_weight_internal(level_set_heaviside);
312 }
313
314 private:
323 template <typename value_type>
324 inline value_type
325 compute_weight_internal(const value_type &level_set_heaviside) const
326 {
327 return Tools::interpolate_reciprocal(level_set_heaviside, w_g, w_h) * correction_factor;
328 }
329
330 const number w_g;
331 const number w_h;
332
333 /*
334 * correction factor
335 *
336 * w_g - w_h
337 * -------------------------
338 * w_g w_h ln( w_g / w_h )
339 */
340 const number correction_factor;
341 };
342
388 template <typename number>
390 : public DeltaApproximationBase<number>
391 {
392 public:
395 : w_1g(data.gas_phase_weight)
396 , w_1h(data.heavy_phase_weight)
397 , w_2g(data.gas_phase_weight_2)
398 , w_2h(data.heavy_phase_weight_2)
400 // clang-format off
401 1. / (
402 w_2g * (w_1g * w_1h * std::log(w_1g / w_1h))
403 / (w_1g - w_1h)
404 +
405 (w_2h - w_2g) * (1. / w_1g * (std::log(w_1h / w_1g) - 1.) + 1. / w_1h)
406 / dealii::Utilities::fixed_power<2>(1. / w_1h - 1. / w_1g)
407 )
408 // clang-format on
409 )
410 {
411 AssertThrow(w_1g > 0.0,
412 dealii::ExcMessage(
413 "When using the Dirac delta function approximation that is phase weighted"
414 "reciprocal times heaviside use positive weights! Abort..."));
415 AssertThrow(w_1h > 0.0,
416 dealii::ExcMessage(
417 "When using the Dirac delta function approximation that is phase weighted"
418 "reciprocal times heaviside use positive weights! Abort..."));
419 AssertThrow(std::abs(w_1g - w_1h) > std::numeric_limits<number>::epsilon(),
420 dealii::ExcMessage(
421 "When using the Dirac delta function approximation that is phase weighted"
422 "reciprocal times heaviside the phase weights must differ! Abort..."));
423 AssertThrow(w_2g > 0.0,
424 dealii::ExcMessage(
425 "When using the Dirac delta function approximation that is phase weighted"
426 "reciprocal times heaviside use positive weights! Abort..."));
427 AssertThrow(std::abs(w_2g - w_2h) > std::numeric_limits<number>::epsilon(),
428 dealii::ExcMessage(
429 "When using the Dirac delta function approximation that is phase weighted"
430 "reciprocal times heaviside the phase weights must differ! Abort..."));
431 }
432
433 inline number
434 compute_weight(const number level_set_heaviside) const override
435 {
436 return compute_weight_internal(level_set_heaviside);
437 }
438
439 inline dealii::VectorizedArray<number>
440 compute_weight(const dealii::VectorizedArray<number> &level_set_heaviside) const override
441 {
442 return compute_weight_internal(level_set_heaviside);
443 }
444
445 private:
454 template <typename value_type>
455 inline value_type
456 compute_weight_internal(const value_type &level_set_heaviside) const
457 {
458 const auto w_1 = Tools::interpolate_reciprocal(level_set_heaviside, w_1g, w_1h);
459 const auto w_2 = Tools::interpolate(level_set_heaviside, w_2g, w_2h);
460 return w_1 * w_2 * correction_factor;
461 }
462
463 const number w_1g;
464 const number w_1h;
465 const number w_2g;
466 const number w_2h;
467
468 /*
469 * correction factor
470 *
471 * / w_1g w_1h ln( w_1g / w_1h )
472 * c_corr = | w_2g -----------------------------
473 * \ w_1g - w_1h
474 *
475 * 1 / w_1g ( ln( w_1h / w_1g ) - 1 ) + 1 / w_1h \-1
476 * + (w_2h - w_2g) * ----------------------------------------------- |
477 * ( 1/w_1h - 1/w_1g )² /
478 *
479 */
480 const number correction_factor;
481 };
482
483 template <typename number>
484 std::unique_ptr<DeltaApproximationBase<number>>
486 {
487 switch (data.type)
488 {
489 case DiracDeltaFunctionApproximationType::norm_of_indicator_gradient:
490 return nullptr;
491 case DiracDeltaFunctionApproximationType::heaviside_phase_weighted:
492 return std::make_unique<DeltaApproximationHeavisidePhaseWeighted<number>>(data);
493 case DiracDeltaFunctionApproximationType::heavy_phase_only:
494 return std::make_unique<DeltaApproximationHeavyPhaseOnly<number>>();
495 case DiracDeltaFunctionApproximationType::heaviside_times_heaviside_phase_weighted:
496 return std::make_unique<DeltaApproximationHeavisideTimesHeavisidePhaseWeighted<number>>(
497 data);
498 case DiracDeltaFunctionApproximationType::reciprocal_phase_weighted:
499 return std::make_unique<DeltaApproximationReciprocalPhaseWeighted<number>>(data);
500 case DiracDeltaFunctionApproximationType::reciprocal_times_heaviside_phase_weighted:
501 return std::make_unique<DeltaApproximationReciprocalTimesHeavisidePhaseWeighted<number>>(
502 data);
503 default:
504 Assert(false, dealii::ExcNotImplemented());
505 }
506 return nullptr;
507 }
508} // namespace MeltPoolDG::LevelSet
Definition delta_approximation_phase_weighted.hpp:11
virtual dealii::VectorizedArray< number > compute_weight(const dealii::VectorizedArray< number > &ls_heaviside) const =0
virtual number compute_weight(const number ls_heaviside) const =0
Definition delta_approximation_phase_weighted.hpp:103
const number w_g
Definition delta_approximation_phase_weighted.hpp:145
number compute_weight(const number level_set_heaviside) const override
Definition delta_approximation_phase_weighted.hpp:118
DeltaApproximationHeavisidePhaseWeighted(const DeltaApproximationPhaseWeightedData< number > &data)
Definition delta_approximation_phase_weighted.hpp:105
dealii::VectorizedArray< number > compute_weight(const dealii::VectorizedArray< number > &level_set_heaviside) const override
Definition delta_approximation_phase_weighted.hpp:124
value_type compute_weight_internal(const value_type &level_set_heaviside) const
Definition delta_approximation_phase_weighted.hpp:140
const number correction_factor
Definition delta_approximation_phase_weighted.hpp:155
const number w_h
Definition delta_approximation_phase_weighted.hpp:146
Definition delta_approximation_phase_weighted.hpp:186
const number w_1h
Definition delta_approximation_phase_weighted.hpp:234
const number w_2g
Definition delta_approximation_phase_weighted.hpp:235
const number correction_factor
Definition delta_approximation_phase_weighted.hpp:245
value_type compute_weight_internal(const value_type &level_set_heaviside) const
Definition delta_approximation_phase_weighted.hpp:226
number compute_weight(const number level_set_heaviside) const override
Definition delta_approximation_phase_weighted.hpp:204
DeltaApproximationHeavisideTimesHeavisidePhaseWeighted(const DeltaApproximationPhaseWeightedData< number > &data)
Definition delta_approximation_phase_weighted.hpp:188
const number w_2h
Definition delta_approximation_phase_weighted.hpp:236
const number w_1g
Definition delta_approximation_phase_weighted.hpp:233
dealii::VectorizedArray< number > compute_weight(const dealii::VectorizedArray< number > &level_set_heaviside) const override
Definition delta_approximation_phase_weighted.hpp:210
Definition delta_approximation_phase_weighted.hpp:40
dealii::VectorizedArray< number > compute_weight(const dealii::VectorizedArray< number > &level_set_heaviside) const override
Definition delta_approximation_phase_weighted.hpp:51
number compute_weight(const number level_set_heaviside) const override
Definition delta_approximation_phase_weighted.hpp:45
value_type compute_weight_internal(const value_type &level_set_heaviside) const
Definition delta_approximation_phase_weighted.hpp:62
Definition delta_approximation_phase_weighted.hpp:280
const number w_g
Definition delta_approximation_phase_weighted.hpp:330
value_type compute_weight_internal(const value_type &level_set_heaviside) const
Definition delta_approximation_phase_weighted.hpp:325
dealii::VectorizedArray< number > compute_weight(const dealii::VectorizedArray< number > &level_set_heaviside) const override
Definition delta_approximation_phase_weighted.hpp:309
number compute_weight(const number level_set_heaviside) const override
Definition delta_approximation_phase_weighted.hpp:303
DeltaApproximationReciprocalPhaseWeighted(const DeltaApproximationPhaseWeightedData< number > &data)
Definition delta_approximation_phase_weighted.hpp:282
const number w_h
Definition delta_approximation_phase_weighted.hpp:331
const number correction_factor
Definition delta_approximation_phase_weighted.hpp:340
Definition delta_approximation_phase_weighted.hpp:391
value_type compute_weight_internal(const value_type &level_set_heaviside) const
Definition delta_approximation_phase_weighted.hpp:456
const number w_1h
Definition delta_approximation_phase_weighted.hpp:464
dealii::VectorizedArray< number > compute_weight(const dealii::VectorizedArray< number > &level_set_heaviside) const override
Definition delta_approximation_phase_weighted.hpp:440
const number w_2g
Definition delta_approximation_phase_weighted.hpp:465
DeltaApproximationReciprocalTimesHeavisidePhaseWeighted(const DeltaApproximationPhaseWeightedData< number > &data)
Definition delta_approximation_phase_weighted.hpp:393
const number correction_factor
Definition delta_approximation_phase_weighted.hpp:480
const number w_2h
Definition delta_approximation_phase_weighted.hpp:466
number compute_weight(const number level_set_heaviside) const override
Definition delta_approximation_phase_weighted.hpp:434
const number w_1g
Definition delta_approximation_phase_weighted.hpp:463
value_type1 interpolate_reciprocal(const value_type1 &ls, const value_type2 &val1, const value_type3 &val2)
Definition level_set_tools.hpp:56
value_type1 interpolate(const value_type1 &ls, const value_type2 &val1, const value_type3 &val2)
Definition level_set_tools.hpp:40
This operation solves the reinitialization problem for a CG- or DG-FEM-based discrete level-set field...
Definition advection_DG_operation.hpp:20
std::unique_ptr< DeltaApproximationBase< number > > create_phase_weighted_delta_approximation(const DeltaApproximationPhaseWeightedData< number > &data)
Definition delta_approximation_phase_weighted.hpp:485
Definition dealii_tensor.hpp:10
Definition delta_approximation_phase_weighted_data.hpp:31
DiracDeltaFunctionApproximationType type
Definition delta_approximation_phase_weighted_data.hpp:32