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 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::implicitFunctions::composedFunctionImplicitFunction
29 
30 Description
31  Handles multiple implicit functions and offers multiple ways to combine
32  them
33 
34 Usage
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 
70 SourceFiles
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 
83 namespace Foam
84 {
85 namespace implicitFunctions
86 {
87 
88 /*---------------------------------------------------------------------------*\
89  Class composedFunctionImplicitFunction Declaration
90 \*---------------------------------------------------------------------------*/
91 
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 
135 public:
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
152 
153  virtual scalar value(const vector& p) const;
154 
155  virtual vector grad(const vector& p) const;
156 
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 // ************************************************************************* //
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::Enum< modeType >
Foam::implicitFunctions::composedFunctionImplicitFunction::distanceToSurfaces
virtual scalar distanceToSurfaces(const vector &p) const
Foam::implicitFunction
Base class for implicit functions.
Definition: implicitFunction.H:56
Foam::implicitFunctions::composedFunctionImplicitFunction::TypeName
TypeName("composedFunction")
Runtime type information.
scalarField.H
Foam::HashTableOps::values
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
Definition: HashOps.H:149
Foam::implicitFunctions::composedFunctionImplicitFunction::grad
virtual vector grad(const vector &p) const
Foam::implicitFunctions::composedFunctionImplicitFunction::~composedFunctionImplicitFunction
virtual ~composedFunctionImplicitFunction()=default
Destructor.
Foam::Field< scalar >
Foam::implicitFunctions::composedFunctionImplicitFunction::value
virtual scalar value(const vector &p) const
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
implicitFunction.H
Foam::implicitFunctions::composedFunctionImplicitFunction
Handles multiple implicit functions and offers multiple ways to combine them.
Definition: composedFunctionImplicitFunction.H:91
Foam::Vector< scalar >