cylinderImplicitFunction.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::cylinderImplicitFunction
29 
30 Description
31  creates a infintite long cylinderImplicitFunction
32 
33  Original code supplied by Henning Scheufler, DLR (2019)
34 
35 SourceFiles
36  cylinderImplicitFunction.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef implicitFunction_cylinderImplicitFunction_H
41 #define implicitFunction_cylinderImplicitFunction_H
42 
43 #include "implicitFunction.H"
44 #include "point.H"
45 #include "tensor.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 namespace implicitFunctions
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class cylinderImplicitFunction Declaration
56 \*---------------------------------------------------------------------------*/
57 
59 :
60  public implicitFunction
61 {
62 private:
63 
64  // Private Data
65 
66  //- Origin point
67  const point origin_;
68 
69  //- Radius
70  const scalar radius_;
71 
72  const scalar scale_;
73 
74  const vector direction_;
75 
76  const tensor project_;
77 
78 
79 public:
80 
81  //- Runtime type information
82  TypeName("cylinder");
83 
84 
85  // Constructors
86 
87  //- Construct from components
89  (
90  const point& origin,
91  const scalar radius,
92  const scalar scale,
93  const vector& direction
94  );
95 
96  //- Construct from dictionary
97  explicit cylinderImplicitFunction(const dictionary& dict);
98 
99 
100  //- Destructor
101  virtual ~cylinderImplicitFunction() = default;
102 
103 
104  // Member Functions
105 
106  virtual scalar value(const vector& p) const
107  {
108  return (-mag(project_ & (p - origin_)) + radius_)*scale_;
109  }
110 
111  virtual vector grad(const vector& p) const
112  {
113  return -(project_ & (p - origin_))*scale_;
114  }
115 
116  virtual scalar distanceToSurfaces(const vector& p) const
117  {
118  return mag(mag(project_ & (p - origin_)) - radius_)*scale_;
119  }
120 };
121 
122 
123 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124 
125 } // End namespace implicitFunctions
126 } // End namespace Foam
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 #endif
131 
132 // ************************************************************************* //
Foam::Tensor< scalar >
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::implicitFunction
Base class for implicit functions.
Definition: implicitFunction.H:56
point.H
Foam::implicitFunctions::cylinderImplicitFunction::value
virtual scalar value(const vector &p) const
Definition: cylinderImplicitFunction.H:105
tensor.H
Foam::implicitFunctions::cylinderImplicitFunction
creates a infintite long cylinderImplicitFunction
Definition: cylinderImplicitFunction.H:57
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
Foam::implicitFunctions::cylinderImplicitFunction::grad
virtual vector grad(const vector &p) const
Definition: cylinderImplicitFunction.H:110
implicitFunction.H
Foam::implicitFunctions::cylinderImplicitFunction::cylinderImplicitFunction
cylinderImplicitFunction(const point &origin, const scalar radius, const scalar scale, const vector &direction)
Construct from components.
Foam::implicitFunctions::cylinderImplicitFunction::TypeName
TypeName("cylinder")
Runtime type information.
Foam::Vector
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition: Vector.H:62
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::direction
uint8_t direction
Definition: direction.H:52
Foam::implicitFunctions::cylinderImplicitFunction::distanceToSurfaces
virtual scalar distanceToSurfaces(const vector &p) const
Definition: cylinderImplicitFunction.H:115
Foam::implicitFunctions::cylinderImplicitFunction::~cylinderImplicitFunction
virtual ~cylinderImplicitFunction()=default
Destructor.