Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
cls_filter.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2023-2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
4#ifndef lethe_cls_filter_h
5#define lethe_cls_filter_h
6
7
9
10/**
11 * @brief Abstract class for filtering phase indicator in Conservative Level Set (CLS)
12 * simulations.
13 */
15{
16public:
17 /**
18 * @brief Default destructor.
19 */
21
22 /**
23 * @brief Instantiate and return a pointer to a ConservativeLevelSetFilterBase
24 * object by casting it to the proper child class.
25 *
26 * @param[in] phase_filter_parameters CLS filtration parameters.
27 *
28 * @return Casted ConservativeLevelSetFilterBase child class object.
29 */
30 static std::shared_ptr<ConservativeLevelSetFilterBase>
31 model_cast(const Parameters::CLS_PhaseFilter &phase_filter_parameters);
32
33 /**
34 * @brief Compute the value of the filtered phase indicator.
35 *
36 * @param[in] unfiltered_phase Value of the phase indicator before applying
37 * the filter.
38 *
39 * @return Value of the computed phase indicator after applying the filter.
40 */
41 virtual double
42 filter_phase(const double &unfiltered_phase) = 0;
43};
44
45/**
46 * @brief Default filter applied to phase indicator. The ConservativeLevelSetNoFilter
47 * filter does not modify the phase indicator value and returns it as it is.
48 */
50{
51public:
52 /**
53 * @brief Constructor of the transparent filter.
54 *
55 * No filter is applied to the computed filtered phase indicator and the
56 * unfiltered phase indicator is returned.
57 */
59
60 /**
61 * @brief Computes the value of the filtered phase indicator.
62 *
63 * Here, the filtered phase indicator value corresponds to the unfiltered one
64 * (@p unfiltered_phase).
65 *
66 * @param[in] unfiltered_phase Value of the phase indicator before applying
67 * the filter.
68 *
69 * @return Value of @p unfiltered_phase.
70 */
71 virtual double
72 filter_phase(const double &unfiltered_phase) override
73 {
74 return unfiltered_phase;
75 }
76};
77
78/**
79 * @brief Filter phase indicator with a hyperbolic tangent function
80 * for CLS simulations.
81 *
82 * The filtered phase is defined as:
83 *
84 * \f$\phi' = 0.5 \tanh(\beta(\phi-0.5)) + 0.5\f$
85 *
86 * where \f$\phi'\f$ is the filtered phase indicator value and \f$\beta\f$
87 * is a model parameter that enables sharper definition when increased.
88 *
89 * The filter allows a sharper definition of the interface and clamps the value
90 * of the phase indicator between 0 and 1.
91 */
93{
94public:
95 /**
96 * @brief Constructor of the hyperbolic tangent phase indicator filter.
97 *
98 * @param[in] beta Value of the \f$\beta\f$ parameter modulating the
99 * interface sharpness.
100 */
102 : beta(beta)
103 {}
104
105 /**
106 * @brief Computes the value of the filtered phase indicator.
107 *
108 * @param[in] unfiltered_phase Value of the phase indicator before applying
109 * the filter.
110 *
111 * @return Value of the computed phase indicator after applying the filter.
112 */
113 virtual double
114 filter_phase(const double &unfiltered_phase) override
115 {
116 return 0.5 * tanh(beta * (unfiltered_phase - 0.5)) + 0.5;
117 }
118
119private:
120 /**
121 * User-defined parameter that influences the sharpness of the interface
122 * between fluids. A greater value leads to a sharper interface. The
123 * recommended value is \f$\beta=20\f$.
124 */
125 const double beta;
126};
127
128#endif
Abstract class for filtering phase indicator in Conservative Level Set (CLS) simulations.
Definition cls_filter.h:15
virtual ~ConservativeLevelSetFilterBase()=default
Default destructor.
static std::shared_ptr< ConservativeLevelSetFilterBase > model_cast(const Parameters::CLS_PhaseFilter &phase_filter_parameters)
Instantiate and return a pointer to a ConservativeLevelSetFilterBase object by casting it to the prop...
Definition cls_filter.cc:7
virtual double filter_phase(const double &unfiltered_phase)=0
Compute the value of the filtered phase indicator.
ConservativeLevelSetNoFilter()=default
Constructor of the transparent filter.
virtual double filter_phase(const double &unfiltered_phase) override
Computes the value of the filtered phase indicator.
Definition cls_filter.h:72
virtual double filter_phase(const double &unfiltered_phase) override
Computes the value of the filtered phase indicator.
Definition cls_filter.h:114
ConservativeLevelSetTanhFilter(const double beta)
Constructor of the hyperbolic tangent phase indicator filter.
Definition cls_filter.h:101
Parameters for the phase filtration.