sphereImplicitFunction.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::sphereImplicitFunction
29 
30 Description
31  Creates a sphere
32 
33  Original code supplied by Henning Scheufler, DLR (2019)
34 
35 SourceFiles
36  sphereImplicitFunction.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef implicitFunction_sphereImplicitFunction_H
41 #define implicitFunction_sphereImplicitFunction_H
42 
43 #include "implicitFunction.H"
44 #include "point.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 namespace implicitFunctions
51 {
52 
53 /*---------------------------------------------------------------------------*\
54  Class sphereImplicitFunction Declaration
55 \*---------------------------------------------------------------------------*/
56 
58 :
59  public implicitFunction
60 {
61  // Private Data
62 
63  //- Origin point
64  const point origin_;
65 
66  //- Radius
67  const scalar radius_;
68 
69  const scalar scale_;
70 
71 
72 public:
73 
74  //- Runtime type information
75  TypeName("sphere");
76 
77 
78  // Constructors
79 
80  //- Construct from components
82  (
83  const point&,
84  const scalar radius,
85  const scalar scale
86  );
87 
88  //- Construct from dictionary
89  explicit sphereImplicitFunction(const dictionary& dict);
90 
91 
92  //- Destructor
93  virtual ~sphereImplicitFunction() = default;
94 
95 
96  // Member Functions
97 
98  virtual scalar value(const vector& p) const
99  {
100  return (-mag(p - origin_) + radius_)*scale_;
101  }
102 
103  virtual vector grad(const vector& p) const
104  {
105  return (origin_ - p)*scale_;
106  }
107 
108  virtual scalar distanceToSurfaces(const vector& p) const
109  {
110  return mag(mag(p - origin_) - radius_)*scale_;
111  }
112 };
113 
114 
115 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
116 
117 } // End namespace implicitFunctions
118 } // End namespace Foam
119 
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121 
122 #endif
123 
124 // ************************************************************************* //
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::implicitFunctions::sphereImplicitFunction::grad
virtual vector grad(const vector &p) const
Definition: sphereImplicitFunction.H:102
Foam::implicitFunction
Base class for implicit functions.
Definition: implicitFunction.H:56
point.H
Foam::implicitFunctions::sphereImplicitFunction::value
virtual scalar value(const vector &p) const
Definition: sphereImplicitFunction.H:97
Foam::implicitFunctions::sphereImplicitFunction
Creates a sphere.
Definition: sphereImplicitFunction.H:56
Foam::implicitFunctions::sphereImplicitFunction::distanceToSurfaces
virtual scalar distanceToSurfaces(const vector &p) const
Definition: sphereImplicitFunction.H:107
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::implicitFunctions::sphereImplicitFunction::sphereImplicitFunction
sphereImplicitFunction(const point &, const scalar radius, const scalar scale)
Construct from components.
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::implicitFunctions::sphereImplicitFunction::TypeName
TypeName("sphere")
Runtime type information.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
implicitFunction.H
Foam::implicitFunctions::sphereImplicitFunction::~sphereImplicitFunction
virtual ~sphereImplicitFunction()=default
Destructor.
Foam::Vector< scalar >
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)