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-2021 OpenCFD Ltd.
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 \*---------------------------------------------------------------------------*/
28 
29 #include "sampledSurface.H"
30 #include "polyMesh.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(sampledSurface, 0);
37  defineRunTimeSelectionTable(sampledSurface, word);
38 }
39 
40 
42 ({
43  "surfaceScalarField",
44  "surfaceVectorField",
45  "surfaceSphericalTensorField",
46  "surfaceSymmTensorField",
47  "surfaceTensorField"
48 });
49 
50 
51 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
52 
54 {
55  area_ = -1;
56 }
57 
58 
59 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
60 
62 (
63  const word& name,
64  const polyMesh& mesh,
65  const dictionary& dict
66 )
67 {
68  const word sampleType(dict.get<word>("type"));
69 
70  DebugInfo
71  << "Selecting sampledType " << sampleType << endl;
72 
73  auto* ctorPtr = wordConstructorTable(sampleType);
74 
75  if (!ctorPtr)
76  {
78  (
79  dict,
80  "sample",
81  sampleType,
82  *wordConstructorTablePtr_
83  ) << exit(FatalIOError);
84  }
85 
86  return autoPtr<sampledSurface>(ctorPtr(name, mesh, dict));
87 }
88 
89 
90 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
91 
93 :
94  name_(name),
95  mesh_(NullObjectRef<polyMesh>()),
96  enabled_(true),
97  invariant_(false),
98  isPointData_(false),
99  area_(-1)
100 {}
101 
102 
104 (
105  const word& name,
106  const polyMesh& mesh,
107  const bool interpolateToPoints
108 )
109 :
110  name_(name),
111  mesh_(mesh),
112  enabled_(true),
113  invariant_(false),
114  isPointData_(interpolateToPoints),
115  area_(-1)
116 {}
117 
118 
120 (
121  const word& name,
122  const polyMesh& mesh,
123  const dictionary& dict
124 )
125 :
126  name_(dict.getOrDefault<word>("name", name)),
127  mesh_(mesh),
128  enabled_(dict.getOrDefault("enabled", true)),
129  invariant_(dict.getOrDefault("invariant", false)),
130  isPointData_(dict.getOrDefault("interpolate", false)),
131  area_(-1)
132 {}
133 
134 
135 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
136 
138 {
139  clearGeom();
140 }
141 
142 
143 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
144 
145 Foam::scalar Foam::sampledSurface::area() const
146 {
147  if (area_ < 0)
148  {
149  area_ = gSum(magSf());
150  }
151 
152  return area_;
153 }
154 
155 
157 {
158  bool old(isPointData_);
159  isPointData_ = on;
160  return old;
161 }
162 
163 
165 {
166  return false;
167 }
168 
169 
171 (
172  const surfaceScalarField& sField
173 ) const
174 {
176  return nullptr;
177 }
178 
179 
181 (
182  const surfaceVectorField& sField
183 ) const
184 {
186  return nullptr;
187 }
188 
189 
191 (
192  const surfaceSphericalTensorField& sField
193 ) const
194 {
196  return nullptr;
197 }
198 
199 
201 (
202  const surfaceSymmTensorField& sField
203 ) const
204 {
206  return nullptr;
207 }
208 
209 
211 (
212  const surfaceTensorField& sField
213 ) const
214 {
216  return nullptr;
217 }
218 
219 
220 void Foam::sampledSurface::print(Ostream& os, int level) const
221 {
222  os << type();
223 }
224 
225 
226 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
227 
229 {
230  // Print with more information
231  s.print(os, 1);
233  return os;
234 }
235 
236 
237 // ************************************************************************* //
Foam::sampledSurface::New
static autoPtr< sampledSurface > New(const word &name, const polyMesh &mesh, const dictionary &dict)
Return a reference to the selected surface.
Definition: sampledSurface.C:62
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
s
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))
Definition: gmvOutputSpray.H:25
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::sampledSurface::area
scalar area() const
The total surface area.
Definition: sampledSurface.C:145
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::gSum
Type gSum(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:594
Foam::sampledSurface::surfaceFieldTypes
static const wordList surfaceFieldTypes
Class names for surface field types.
Definition: sampledSurface.H:130
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:107
polyMesh.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::sampledSurface::sample
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const =0
Sample volume field onto surface faces.
Foam::NullObjectRef
const T & NullObjectRef()
Reference (of type T) to the nullObject.
Definition: nullObject.H:184
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
FatalIOErrorInLookup
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:478
sampledSurface.H
Foam::sampledSurface
An abstract class for surfaces with sampling.
Definition: sampledSurface.H:121
Foam::sampledSurface::print
virtual void print(Ostream &os, int level=0) const
Print information.
Definition: sampledSurface.C:220
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:58
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::sampledSurface::isPointData
bool isPointData() const noexcept
Using interpolation to surface points.
Definition: sampledSurface.H:340
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::autoPtr< Foam::sampledSurface >
DebugInfo
#define DebugInfo
Report an information message using Foam::Info.
Definition: messageStream.H:382
Foam::sampledSurface::withSurfaceFields
virtual bool withSurfaceFields() const
Can it sample surface-fields?
Definition: sampledSurface.C:164
Foam::List< word >
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::sampledSurface::~sampledSurface
virtual ~sampledSurface()
Destructor - calls clearGeom()
Definition: sampledSurface.C:137
Foam::sampledSurface::clearGeom
virtual void clearGeom() const
Additional cleanup when clearing the geometry.
Definition: sampledSurface.C:53
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:295
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::dictionary::getOrDefault
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:148
Foam::GeometricField< scalar, fvsPatchField, surfaceMesh >
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::sampledSurface::sampledSurface
sampledSurface(const word &name, std::nullptr_t)
Construct null.
Definition: sampledSurface.C:92