Loading...
Searching...
No Matches
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
30#include "polyMesh.H"
31
32// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33
34namespace Foam
35{
40
41// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
42
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 }
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
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
146bool Foam::sampledSurface::isPointData(const bool on)
148 bool old(isPointData_);
149 isPointData_ = on;
150 return old;
151}
152
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
200Foam::tmp<Foam::tensorField> Foam::sampledSurface::sample
201(
202 const surfaceTensorField& sField
203) const
204{
206 return nullptr;
207}
208
209
210void Foam::sampledSurface::print(Ostream& os, int level) const
212 os << type();
213}
214
215
216// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
217
218Foam::Ostream& Foam::operator<<(Ostream& os, const sampledSurface& s)
219{
220 // Print with more information
221 s.print(os, 1);
222 os.check(FUNCTION_NAME);
223 return os;
224}
225
226
227// ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
An abstract class for surfaces with sampling.
virtual const scalarField & magSf() const =0
Face area magnitudes.
bool isPointData() const noexcept
Using interpolation to surface points.
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const =0
Sample volume field onto surface faces.
virtual void print(Ostream &os, int level=0) const
Print information.
sampledSurface(const word &name, std::nullptr_t)
Construct null.
const word & name() const noexcept
Name of surface.
virtual void clearGeom() const
Additional cleanup when clearing the geometry.
static autoPtr< sampledSurface > New(const word &name, const polyMesh &mesh, const dictionary &dict)
Return a reference to the selected surface.
virtual ~sampledSurface()
Destructor - calls clearGeom().
virtual bool withSurfaceFields() const
Can it sample surface-fields?
const polyMesh & mesh() const noexcept
Access to the underlying mesh.
scalar area() const
The total surface area.
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
dynamicFvMesh & mesh
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition error.H:637
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition error.H:688
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.
GeometricField< vector, fvsPatchField, surfaceMesh > surfaceVectorField
Type gSum(const FieldField< Field, Type > &f)
const T & NullObjectRef() noexcept
Const reference (of type T) to the nullObject.
Definition nullObject.H:228
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition POSIX.C:801
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
GeometricField< tensor, fvsPatchField, surfaceMesh > surfaceTensorField
GeometricField< sphericalTensor, fvsPatchField, surfaceMesh > surfaceSphericalTensorField
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
GeometricField< symmTensor, fvsPatchField, surfaceMesh > surfaceSymmTensorField
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
dictionary dict