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 -------------------------------------------------------------------------------
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 {
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 
60  DebugInfo
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 
82 Foam::sampledSurface::sampledSurface(const word& name, std::nullptr_t)
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 
135 Foam::scalar Foam::sampledSurface::area() const
136 {
137  if (area_ < 0)
138  {
139  area_ = gSum(magSf());
140  }
141 
142  return area_;
143 }
144 
145 
146 bool Foam::sampledSurface::isPointData(const bool on)
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 
210 void Foam::sampledSurface::print(Ostream& os, int level) const
211 {
212  os << type();
213 }
214 
215 
216 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
217 
218 Foam::Ostream& Foam::operator<<(Ostream& os, const sampledSurface& s)
219 {
220  // Print with more information
221  s.print(os, 1);
223  return os;
224 }
225 
226 
227 // ************************************************************************* //
dictionary dict
virtual ~sampledSurface()
Destructor - calls clearGeom()
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:45
An abstract class for surfaces with sampling.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
static autoPtr< sampledSurface > New(const word &name, const polyMesh &mesh, const dictionary &dict)
Return a reference to the selected surface.
virtual bool withSurfaceFields() const
Can it sample surface-fields?
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:799
dynamicFvMesh & mesh
Type gSum(const FieldField< Field, Type > &f)
virtual void clearGeom() const
Additional cleanup when clearing the geometry.
GeometricField< symmTensor, fvsPatchField, surfaceMesh > surfaceSymmTensorField
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
A class for handling words, derived from Foam::string.
Definition: word.H:63
scalar area() const
The total surface area.
#define DebugInfo
Report an information message using Foam::Info.
sampledSurface(const word &name, std::nullptr_t)
Construct null.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
OBJstream os(runTime.globalPath()/outputName)
#define FUNCTION_NAME
defineTypeNameAndDebug(combustionModel, 0)
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const =0
Sample volume field onto surface faces.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:77
virtual void print(Ostream &os, int level=0) const
Print information.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
A class for managing temporary objects.
Definition: HashPtrTable.H:50
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 NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:686
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:635
const T & NullObjectRef()
Reference (of type T) to the nullObject.
Definition: nullObject.H:217
Namespace for OpenFOAM.
bool isPointData() const noexcept
Using interpolation to surface points.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL IO ERROR&#39; header text and ...