boundaryDataSurfaceReaderTemplates.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) 2022 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
29 #include "rawIOField.H"
30 #include "argList.H"
31 #include "Time.H"
32 
33 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
34 
35 template<class Type>
38 (
39  const Time& runTime,
40  const fileName& baseDir,
41  const instant& timeDir,
42  const word& fieldName,
43  Type& avg
44 )
45 {
46  // Reread values and interpolate
47  fileName valuesFile(baseDir/timeDir.name()/fieldName);
48  valuesFile.toAbsolute();
49 
50  IOobject io
51  (
52  valuesFile, // absolute path
53  runTime,
57  true // global object (currently not used)
58  );
59 
60  DebugInfo
61  << "File: " << io.objectPath() << endl;
62 
63  // Read data (TDB: setAverage)
65 
66  if (rawData.hasAverage())
67  {
68  avg = rawData.average();
69  }
70 
71  DebugInfo
72  << "File: " << io.objectPath()
73  << " " << rawData.size() << " values" << endl;
74 
75  return tmp<Field<Type>>::New(std::move(rawData.field()));
76 }
77 
78 
79 template<class Type>
82 (
83  const fileName& baseDir,
84  const instant& timeDir,
85  const word& fieldName,
86  Type& avg
87 )
88 {
90 
91  return readField<Type>(baseDir, timeDir, fieldName, avg);
92 }
93 
94 
95 // ************************************************************************* //
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:118
A class for handling file names.
Definition: fileName.H:71
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:487
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:697
const Type & average() const noexcept
The average value (if any)
Definition: rawIOField.H:147
Ignore writing from objectRegistry::writeObject()
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
A class for managing references or pointers (no reference counting)
Definition: HashPtrTable.H:49
Like IOField but falls back to raw IFstream if no header found. Optionally reads average value...
Definition: rawIOField.H:48
static tmp< Field< Type > > readField(const Time &runTime, const fileName &baseDir, const instant &timeDir, const word &fieldName, Type &avg)
Read and return given field.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
const T & name() const noexcept
The name/key (const access)
Definition: Instant.H:144
A class for handling words, derived from Foam::string.
Definition: word.H:63
#define DebugInfo
Report an information message using Foam::Info.
bool hasAverage() const noexcept
Has an average value.
Definition: rawIOField.H:155
fileName & toAbsolute()
Convert from relative to absolute.
Definition: fileName.C:370
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name...
Definition: instant.H:53
static autoPtr< surfaceReader > New(const word &readType, const fileName &fName, const dictionary &options=dictionary())
Return a reference to the selected surfaceReader.
Definition: surfaceReader.C:71
static fileName envGlobalPath()
Global case (directory) from environment variable.
Definition: argList.C:590
const Field< Type > & field() const noexcept
The field content.
Definition: rawIOField.H:131
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:166
Do not request registration (bool: false)