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-------------------------------------------------------------------------------
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::sphereImplicitFunction
29
30Description
31 Creates a sphere
32
33 Original code supplied by Henning Scheufler, DLR (2019)
34
35SourceFiles
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
48namespace Foam
49{
50namespace implicitFunctions
51{
52
53/*---------------------------------------------------------------------------*\
54 Class sphereImplicitFunction Declaration
55\*---------------------------------------------------------------------------*/
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
72public:
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
98 virtual scalar value(const vector& p) const
99 {
100 return (-mag(p - origin_) + radius_)*scale_;
101 }
103 virtual vector grad(const vector& p) const
104 {
105 return (origin_ - p)*scale_;
106 }
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// ************************************************************************* //
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.
sphereImplicitFunction(const dictionary &dict)
Construct from dictionary.
virtual scalar distanceToSurfaces(const vector &p) const
virtual vector grad(const vector &p) const
TypeName("sphere")
Runtime type information.
sphereImplicitFunction(const point &, const scalar radius, const scalar scale)
Construct from components.
virtual ~sphereImplicitFunction()=default
Destructor.
virtual scalar value(const vector &p) const
volScalarField & p
Namespace for OpenFOAM.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73