ellipsoidImplicitFunction.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::ellipsoidImplicitFunction
29 
30 Description
31  creates an ellipsoidImplicitFunction
32 
33  Original code supplied by Henning Scheufler, DLR (2019)
34 
35 SourceFiles
36  ellipsoidImplicitFunction.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef implicitFunction_ellipsoidImplicitFunction_H
41 #define implicitFunction_ellipsoidImplicitFunction_H
42 
43 #include "implicitFunction.H"
44 #include "mathematicalConstants.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 namespace implicitFunctions
51 {
52 
53 /*---------------------------------------------------------------------------*\
54  Class ellipsoidImplicitFunction Declaration
55 \*---------------------------------------------------------------------------*/
56 
58 :
59  public implicitFunction
60 {
61  // Private Member Data
62 
63  //- Axis
64  const vector semiAxis_;
65 
66  //- Origin point
67  const vector origin_;
68 
69 
70 public:
71 
72  //- Runtime type information
73  TypeName("ellipsoidImplicitFunction");
74 
75 
76  // Constructors
77 
78  //- Construct from components
79  explicit ellipsoidImplicitFunction(const vector& semiAxis);
80 
81  //- Construct from dictionary
82  explicit ellipsoidImplicitFunction(const dictionary& dict);
83 
84 
85  //- Destructor
86  virtual ~ellipsoidImplicitFunction() = default;
87 
88 
89  // Member Functions
90 
91  virtual scalar value(const vector& p) const
92  {
93  return
94  -sqrt
95  (
96  sqr((p.x() - origin_.x())/semiAxis_.x())
97  + sqr((p.y() - origin_.y())/semiAxis_.y())
98  + sqr((p.z() - origin_.z())/semiAxis_.z())
99  ) + 1;
100  }
101 
102 
103  virtual vector grad(const vector& p) const
104  {
105  // normal_ has the length of one
106  return vector
107  (
108  2*(p.x() - origin_.x())/sqr(semiAxis_.x()),
109  2*(p.y() - origin_.y())/sqr(semiAxis_.y()),
110  2*(p.z() - origin_.z())/sqr(semiAxis_.z())
111  );
112  }
113 
114  virtual scalar distanceToSurfaces(const vector& p) const
115  {
117  return GREAT;
118  }
119 };
120 
121 
122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
123 
124 } // End namespace implicitFunctions
125 } // End namespace Foam
126 
127 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
128 
129 #endif
130 
131 // ************************************************************************* //
Foam::implicitFunctions::ellipsoidImplicitFunction::grad
virtual vector grad(const vector &p) const
Definition: ellipsoidImplicitFunction.H:102
Foam::implicitFunctions::ellipsoidImplicitFunction::distanceToSurfaces
virtual scalar distanceToSurfaces(const vector &p) const
Definition: ellipsoidImplicitFunction.H:113
Foam::Vector::x
const Cmpt & x() const
Access to the vector x component.
Definition: VectorI.H:73
mathematicalConstants.H
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::implicitFunction
Base class for implicit functions.
Definition: implicitFunction.H:56
Foam::implicitFunctions::ellipsoidImplicitFunction::value
virtual scalar value(const vector &p) const
Definition: ellipsoidImplicitFunction.H:90
Foam::Vector::z
const Cmpt & z() const
Access to the vector z component.
Definition: VectorI.H:85
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:445
Foam::implicitFunctions::ellipsoidImplicitFunction
creates an ellipsoidImplicitFunction
Definition: ellipsoidImplicitFunction.H:56
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:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:51
Foam::implicitFunctions::ellipsoidImplicitFunction::ellipsoidImplicitFunction
ellipsoidImplicitFunction(const vector &semiAxis)
Construct from components.
implicitFunction.H
Foam::Vector::y
const Cmpt & y() const
Access to the vector y component.
Definition: VectorI.H:79
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
Foam::Vector< scalar >
Foam::sqrt
dimensionedScalar sqrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:144
Foam::implicitFunctions::ellipsoidImplicitFunction::TypeName
TypeName("ellipsoidImplicitFunction")
Runtime type information.
Foam::implicitFunctions::ellipsoidImplicitFunction::~ellipsoidImplicitFunction
virtual ~ellipsoidImplicitFunction()=default
Destructor.