cylinder.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2025 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "cylinder.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33  namespace zoneGenerators
34  {
37  }
38 }
39 
40 
41 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
42 
43 inline bool Foam::zoneGenerators::cylinder::contains(const point& p) const
44 {
45  const vector d = p - point1_;
46  const scalar magda = d & axis_;
47 
48  if ((magda > 0) && (magda < magAxis2_))
49  {
50  const scalar d2 = magSqr(d) - sqr(magda)/magAxis2_;
51 
52  if (d2 < rad2_)
53  {
54  return true;
55  }
56  }
57 
58  return false;
59 }
60 
61 
62 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
63 
65 (
66  const word& name,
67  const polyMesh& mesh,
68  const dictionary& dict
69 )
70 :
71  volume(name, mesh, dict),
72  point1_(dict.lookup<point>("point1", dimLength)),
73  point2_(dict.lookup<point>("point2", dimLength)),
74  radius_(dict.lookup<scalar>("radius", dimLength)),
75  axis_(point2_ - point1_),
76  rad2_(sqr(radius_)),
77  magAxis2_(magSqr(axis_))
78 {}
79 
80 
81 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
82 
84 {}
85 
86 
87 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
88 
90 {
91  return volume::generate(*this);
92 }
93 
94 
95 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
A class for handling words, derived from string.
Definition: word.H:62
Abstract base class for all zoneGenerators, providing runtime selection.
Definition: zoneGenerator.H:57
A zoneGenerator which selects points, cells or faces with centres either inside or outside a cylinder...
Definition: cylinder.H:149
virtual ~cylinder()
Destructor.
Definition: cylinder.C:83
virtual zoneSet generate() const
Generate and return the zoneSet.
Definition: cylinder.C:89
cylinder(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
Definition: cylinder.C:65
A zoneGenerator which looks-up and returns a zoneSet containing point, and/or cell and/or faces zones...
Definition: lookup.H:139
A zoneGenerator which converts the point, cell and face zones from a list of zoneGenerators into a po...
Abstract zoneGenerator which selects points, cells or faces with centres either inside a volume.
Definition: volume.H:114
virtual zoneSet generate() const =0
Generate and return the zoneSet.
Zone container returned by zoneGenerator::generate.
Definition: zoneSet.H:94
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
defineTypeNameAndDebug(cylinderHeadPoints, 0)
addToRunTimeSelectionTable(zoneGenerator, cylinderHeadPoints, dictionary)
Namespace for OpenFOAM.
const dimensionSet dimLength
vector point
Point is a vector.
Definition: point.H:41
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
void sqr(LagrangianPatchField< typename outerProduct< Type, Type >::type > &f, const LagrangianPatchField< Type > &f1)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
void magSqr(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
dictionary dict
volScalarField & p