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-2020 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 #include "demandDrivenData.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  defineTypeNameAndDebug(sampledSurface, 0);
38  defineRunTimeSelectionTable(sampledSurface, word);
39 }
40 
41 
43 ({
44  "surfaceScalarField",
45  "surfaceVectorField",
46  "surfaceSphericalTensorField",
47  "surfaceSymmTensorField",
48  "surfaceTensorField"
49 });
50 
51 
52 
53 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
54 
56 {
57  area_ = -1;
58 }
59 
60 
61 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
62 
64 (
65  const word& name,
66  const polyMesh& mesh,
67  const dictionary& dict
68 )
69 {
70  const word sampleType(dict.get<word>("type"));
71 
72  DebugInfo
73  << "Selecting sampledType " << sampleType << endl;
74 
75  auto cstrIter = wordConstructorTablePtr_->cfind(sampleType);
76 
77  if (!cstrIter.found())
78  {
80  (
81  dict,
82  "sample",
83  sampleType,
84  *wordConstructorTablePtr_
85  ) << exit(FatalIOError);
86  }
87 
88  return autoPtr<sampledSurface>(cstrIter()(name, mesh, dict));
89 }
90 
91 
92 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
93 
95 :
96  name_(name),
97  mesh_(NullObjectRef<polyMesh>()),
98  enabled_(true),
99  invariant_(false),
100  interpolate_(false),
101  area_(-1)
102 {}
103 
104 
106 (
107  const word& name,
108  const polyMesh& mesh,
109  const bool interpolate
110 )
111 :
112  name_(name),
113  mesh_(mesh),
114  enabled_(true),
115  invariant_(false),
116  interpolate_(interpolate),
117  area_(-1)
118 {}
119 
120 
122 (
123  const word& name,
124  const polyMesh& mesh,
125  const dictionary& dict
126 )
127 :
128  name_(dict.getOrDefault<word>("name", name)),
129  mesh_(mesh),
130  enabled_(dict.getOrDefault("enabled", true)),
131  invariant_(dict.getOrDefault("invariant", false)),
132  interpolate_(dict.getOrDefault("interpolate", false)),
133  area_(-1)
134 {}
135 
136 
137 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
138 
140 {
141  clearGeom();
142 }
143 
144 
145 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
146 
147 Foam::scalar Foam::sampledSurface::area() const
148 {
149  if (area_ < 0)
150  {
151  area_ = gSum(magSf());
152  }
153 
154  return area_;
155 }
156 
157 
159 {
160  return false;
161 }
162 
163 
165 (
166  const surfaceScalarField& sField
167 ) const
168 {
170  return nullptr;
171 }
172 
173 
175 (
176  const surfaceVectorField& sField
177 ) const
178 {
180  return nullptr;
181 }
182 
183 
185 (
186  const surfaceSphericalTensorField& sField
187 ) const
188 {
190  return nullptr;
191 }
192 
193 
195 (
196  const surfaceSymmTensorField& sField
197 ) const
198 {
200  return nullptr;
201 }
202 
203 
205 (
206  const surfaceTensorField& sField
207 ) const
208 {
210  return nullptr;
211 }
212 
213 
215 {
216  os << type();
217 }
218 
219 
220 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
221 
223 {
224  s.print(os);
225  os.check(FUNCTION_NAME);
226  return os;
227 }
228 
229 
230 // ************************************************************************* //
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:64
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
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
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::sampledSurface::area
scalar area() const
The total surface area.
Definition: sampledSurface.C:147
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
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:129
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:81
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:445
FatalIOErrorInLookup
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:406
Foam::interpolate
bool interpolate(const vector &p1, const vector &p2, const vector &o, vector &n, scalar l)
Definition: curveTools.C:75
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
sampledSurface.H
Foam::sampledSurface
An abstract class for surfaces with sampling.
Definition: sampledSurface.H:120
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:51
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
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:359
Foam::sampledSurface::withSurfaceFields
virtual bool withSurfaceFields() const
Can it sample surface-fields?
Definition: sampledSurface.C:158
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:139
Foam::sampledSurface::clearGeom
virtual void clearGeom() const
Additional cleanup when clearing the geometry.
Definition: sampledSurface.C:55
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:270
Foam::sampledSurface::print
virtual void print(Ostream &os) const
Print information.
Definition: sampledSurface.C:214
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:122
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:94