OpenLB 1.7
Loading...
Searching...
No Matches
indicMod.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2021 Jan E. Marquardt
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24#ifndef INDIC_MOD_HH
25#define INDIC_MOD_HH
26
27#include "indicMod.h"
28
29namespace olb {
30
31template <typename S, unsigned D>
33 PhysR<S, D> min, PhysR<S, D> max)
34 : _f(std::move(f))
35{
36 this->_myMin = min;
37 this->_myMax = max;
38}
39
40
42
46template <typename S, unsigned D>
48 : _f(std::move(f))
49{
50 this->_myMin = f->getMin();
51 this->_myMax = f->getMax();
52}
53
54template <typename S, unsigned D>
56{
57 return -this->_f->signedDistance(input);
58}
59
60template <typename S, unsigned D>
62 : _f(std::move(f))
63{
64 setScalingFactor(scalingFactor);
65}
66
67template <typename S, unsigned D>
69{
70 _scalingFactor = scalingFactor;
71 this->_myMin = _f->getMin() - scalingFactor*_f->getMin();
72 this->_myMax = _f->getMax() + scalingFactor*_f->getMax();
73}
74
75template <typename S, unsigned D>
77{
78 return _scalingFactor;
79}
80
81template <typename S, unsigned D>
83{
84 return 0.5 * (_f->getMin() + _f->getMax());
85}
86
87
88template <typename S, unsigned D>
90{
91 std::function<S(const Vector<S, D>&)> sdf =
92 [this](const Vector<S, D>& input) {
93 return this->_f->signedDistance(input);
94 };
95
96 return sdf::scale(sdf, input, _scalingFactor);
97}
98
99template <typename S, unsigned D>
101 : _f(std::move(f))
102{
103 setElongation(elongation);
104}
105
106template <typename S, unsigned D>
108{
109 _elongation = elongation;
110 this->_myMin = _f->getMin() - elongation;
111 this->_myMax = _f->getMax() + elongation;
112}
113
114template <typename S, unsigned D>
116{
117 return _elongation;
118}
119
120template <typename S, unsigned D>
122{
123 return 0.5 * (_f->getMin() + _f->getMax());
124}
125
126template <typename S, unsigned D>
128{
129 std::function<S(const Vector<S, D>&)> sdf =
130 [this](const Vector<S, D>& input) {
131 return this->_f->signedDistance(input);
132 };
133
134 return sdf::elongation(sdf, input, _elongation, getEstimatedCenter());
135}
136
137} // namespace olb
138#endif
Smart pointer for managing the various ways of passing functors around.
Definition functorPtr.h:60
void setElongation(const Vector< S, D > &elongation)
Definition indicMod.hh:107
Vector< S, D > getEstimatedCenter()
Definition indicMod.hh:121
S signedDistance(const Vector< S, D > &input)
Definition indicMod.hh:127
Vector< S, D > getElongation()
Definition indicMod.hh:115
IndicElongation(FunctorPtr< IndicatorF< S, D > > f, const Vector< S, D > &elongation=Vector< S, D >(0.))
Definition indicMod.hh:100
IndicInverse(FunctorPtr< IndicatorF< S, D > > f, PhysR< S, D > min, PhysR< S, D > max)
Definition indicMod.hh:32
S signedDistance(const Vector< S, D > &input)
Definition indicMod.hh:55
IndicScale(FunctorPtr< IndicatorF< S, D > > f, S scalingFactor=S {1})
Definition indicMod.hh:61
S signedDistance(const Vector< S, D > &input)
Definition indicMod.hh:89
Vector< S, D > getEstimatedCenter()
Definition indicMod.hh:82
void setScalingFactor(const S scalingFactor)
Definition indicMod.hh:68
Plain old scalar vector.
Definition vector.h:47
T elongation(std::function< T(const Vector< T, 3 > &)> sdf, const Vector< T, 3 > &p, const Vector< T, 3 > &h, const Vector< T, 3 > &center=(T(0))) any_platform
Elongation splits the object in 2 (4 or 8) parts, moves them apart and connects them again The object...
Definition sdf.h:386
T scale(std::function< T(const Vector< T, D > &)> sdf, const Vector< T, D > &p, T s, const Vector< T, D > &center=(T(0))) any_platform
Function to scale a geometry The object has to be placed in the origin of the coodinate system.
Definition sdf.h:437
Top level namespace for all of OpenLB.
std::conditional_t< D==2, IndicatorF2D< T >, IndicatorF3D< T > > IndicatorF
Definition aliases.h:258