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-2023 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 "Time.H"
31 
32 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
33 
34 template<class Type>
37 (
38  const Time& runTime,
39  const fileName& baseDir,
40  const instant& timeDir,
41  const word& fieldName,
42  Type& avg
43 )
44 {
45  // Reread values and interpolate
46  fileName valuesFile(baseDir/timeDir.name()/fieldName);
47  valuesFile.toAbsolute();
48 
49  IOobject io
50  (
51  valuesFile, // absolute path
52  runTime,
56  true // global object (currently not used)
57  );
58 
59  DebugInfo
60  << "File: " << io.objectPath() << endl;
61 
62  // Read data (TDB: setAverage)
64 
65  if (rawData.hasAverage())
66  {
67  avg = rawData.average();
68  }
69 
70  DebugInfo
71  << "File: " << io.objectPath()
72  << " " << rawData.size() << " values" << endl;
73 
74  return tmp<Field<Type>>::New(std::move(rawData.field()));
75 }
76 
77 
78 template<class Type>
81 (
82  const fileName& baseDir,
83  const instant& timeDir,
84  const word& fieldName,
85  Type& avg
86 )
87 {
89 
90  return readField<Type>(*timePtr, baseDir, timeDir, fieldName, avg);
91 }
92 
93 
94 // ************************************************************************* //
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
A class for handling file names.
Definition: fileName.H:72
static autoPtr< Time > NewGlobalTime()
Construct (dummy) global Time - no functionObjects or libraries, using the global path information st...
Definition: TimeNew.C:78
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
const Type & average() const noexcept
The average value (if any)
Definition: rawIOField.H:155
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.
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:163
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
Reading is optional [identical to READ_IF_PRESENT].
const Field< Type > & field() const noexcept
The field content.
Definition: rawIOField.H:139
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
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:172
Do not request registration (bool: false)