sampledSurface.C
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) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2018-2022 OpenCFD Ltd.
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
27\*---------------------------------------------------------------------------*/
28
29#include "sampledSurface.H"
30#include "polyMesh.H"
31
32// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33
34namespace Foam
35{
38}
39
40
41// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
42
44{
45 area_ = -1;
46}
47
48
49// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
50
52(
53 const word& name,
54 const polyMesh& mesh,
55 const dictionary& dict
56)
57{
58 const word sampleType(dict.get<word>("type"));
59
61 << "Selecting sampledType " << sampleType << endl;
62
63 auto* ctorPtr = wordConstructorTable(sampleType);
64
65 if (!ctorPtr)
66 {
68 (
69 dict,
70 "sample",
71 sampleType,
72 *wordConstructorTablePtr_
73 ) << exit(FatalIOError);
74 }
75
76 return autoPtr<sampledSurface>(ctorPtr(name, mesh, dict));
77}
78
79
80// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
81
83:
84 name_(name),
85 mesh_(NullObjectRef<polyMesh>()),
86 enabled_(true),
87 invariant_(false),
88 isPointData_(false),
89 area_(-1)
90{}
91
92
94(
95 const word& name,
96 const polyMesh& mesh,
97 const bool interpolateToPoints
98)
99:
100 name_(name),
101 mesh_(mesh),
102 enabled_(true),
103 invariant_(false),
104 isPointData_(interpolateToPoints),
105 area_(-1)
106{}
107
108
110(
111 const word& name,
112 const polyMesh& mesh,
113 const dictionary& dict
114)
115:
116 name_(dict.getOrDefault<word>("name", name)),
117 mesh_(mesh),
118 enabled_(dict.getOrDefault("enabled", true)),
119 invariant_(dict.getOrDefault("invariant", false)),
120 isPointData_(dict.getOrDefault("interpolate", false)),
121 area_(-1)
122{}
123
124
125// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
126
128{
129 clearGeom();
130}
131
132
133// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
134
135Foam::scalar Foam::sampledSurface::area() const
136{
137 if (area_ < 0)
138 {
139 area_ = gSum(magSf());
140 }
141
142 return area_;
143}
144
145
147{
148 bool old(isPointData_);
149 isPointData_ = on;
150 return old;
151}
152
153
155{
156 return false;
157}
158
159
161(
162 const surfaceScalarField& sField
163) const
164{
166 return nullptr;
167}
168
169
171(
172 const surfaceVectorField& sField
173) const
174{
176 return nullptr;
177}
178
179
181(
182 const surfaceSphericalTensorField& sField
183) const
184{
186 return nullptr;
187}
188
189
191(
192 const surfaceSymmTensorField& sField
193) const
194{
196 return nullptr;
197}
198
199
201(
202 const surfaceTensorField& sField
203) const
204{
206 return nullptr;
207}
208
209
211{
212 os << type();
213}
214
215
216// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
217
219{
220 // Print with more information
221 s.print(os, 1);
223 return os;
224}
225
226
227// ************************************************************************* //
Minimal example by using system/controlDict.functions:
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:58
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
scalar print()
Print to screen.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
An abstract class for surfaces with sampling.
bool isPointData() const noexcept
Using interpolation to surface points.
virtual void clearGeom() const
Additional cleanup when clearing the geometry.
virtual ~sampledSurface()
Destructor - calls clearGeom()
virtual bool withSurfaceFields() const
Can it sample surface-fields?
scalar area() const
The total surface area.
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
dynamicFvMesh & mesh
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:478
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
OBJstream os(runTime.globalPath()/outputName)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
#define DebugInfo
Report an information message using Foam::Info.
#define FUNCTION_NAME
Namespace for OpenFOAM.
Type gSum(const FieldField< Field, Type > &f)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
const T & NullObjectRef()
Reference (of type T) to the nullObject.
Definition: nullObject.H:184
IOerror FatalIOError
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
dictionary dict