composedFunctionImplicitFunction.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2019 OpenCFD Ltd.
9 Copyright (C) 2019-2020 DLR
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::implicitFunctions::composedFunctionImplicitFunction
29
30Description
31 Handles multiple implicit functions and offers multiple ways to combine
32 them
33
34Usage
35 Example of function object partial specification:
36 \verbatim
37 function composedFunctionImplicitFunction;
38 mode minDist;
39 // following mode are available:
40 // "add" "subtract" "minDist" "intersect"
41 composedFunctionImplicitFunctions
42 {
43 plane
44 {
45 function plane;
46 origin (0 1. 0);
47 normal (0 1 0);
48 }
49
50 sphere
51 {
52 function sphere;
53 radius 0.4;
54 origin (0.5 1.5 0.5);
55 scale 1;
56 }
57
58 sphere2
59 {
60 function sphere;
61 radius 0.4;
62 origin (0.5 0.5 0.5);
63 scale -1;
64 }
65 }
66 \endverbatim
67
68 Original code supplied by Henning Scheufler, DLR (2019)
69
70SourceFiles
71 composedFunctionImplicitFunction.C
72
73\*---------------------------------------------------------------------------*/
74
75#ifndef implicitFunctions_composedFunctionImplicitFunction_H
76#define implicitFunctions_composedFunctionImplicitFunction_H
77
78#include "implicitFunction.H"
79#include "scalarField.H"
80
81// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
82
83namespace Foam
85namespace implicitFunctions
86{
87
88/*---------------------------------------------------------------------------*\
89 Class composedFunctionImplicitFunction Declaration
90\*---------------------------------------------------------------------------*/
93:
94 public implicitFunction
95{
96 // Private Member Data
97
98 //- Enumeration defining the valid actions
99 enum class modeType
100 {
101 ADD,
102 SUBTRACT,
103 MINDIST,
104 INTERSECT
105 };
106
107 //- The setActions text representations
108 static const Enum<modeType> modeTypeNames;
109
110 //- Stores the functions
111 PtrList<implicitFunction> functions_;
112
113 //- Mode
114 modeType mode_;
115
116 //- Needed for finding the closest function.
117 // Note: avoid creation every call
118 mutable scalarField values_;
119
120
121 // Private Member Functions
122
123 label selectFunction(const scalarField& values) const;
124
125 //- No copy construct
127 (
129 ) = delete;
130
131 //- No copy assignment
132 void operator=(const composedFunctionImplicitFunction&) = delete;
133
134
135public:
136
137 //- Runtime type information
138 TypeName("composedFunction");
139
140
141 // Constructors
142
143 //- Construct from dictionary
145
146
147 //- Destructor
148 virtual ~composedFunctionImplicitFunction() = default;
149
150
151 // Member Functions
153 virtual scalar value(const vector& p) const;
155 virtual vector grad(const vector& p) const;
157 virtual scalar distanceToSurfaces(const vector& p) const;
158};
159
160
161// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162} // End namespace implicitFunctions
163} // End namespace Foam
164
165// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166
167#endif
168
169// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: Enum.H:61
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Base class for implicit functions.
Handles multiple implicit functions and offers multiple ways to combine them.
virtual scalar distanceToSurfaces(const vector &p) const
virtual vector grad(const vector &p) const
TypeName("composedFunction")
Runtime type information.
composedFunctionImplicitFunction(const dictionary &dict)
Construct from dictionary.
virtual ~composedFunctionImplicitFunction()=default
Destructor.
virtual scalar value(const vector &p) const
volScalarField & p
Namespace for OpenFOAM.
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73