GIT: relocate rawIOField to src/OpenFOAM (closer to IOField classes)
STYLE: RunFunctions - missed message for failure to find nFaces
This commit is contained in:
parent
1afd27db6c
commit
8b1514c99b
@ -157,7 +157,7 @@ getNumberOfPatchFaces()
|
||||
'/^ *'"$patch"' *$/,/}/{s/^ *nFaces *\([0-9][0-9]*\) *;.*$/\1/p}' \
|
||||
"$file")
|
||||
|
||||
if [ -n "nFaces" ]
|
||||
if [ -n "$nFaces" ]
|
||||
then
|
||||
echo "$nFaces"
|
||||
else
|
||||
|
@ -6,7 +6,7 @@
|
||||
# \\ / A nd | www.openfoam.com
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
# Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -65,7 +65,7 @@ die()
|
||||
echo "Error encountered:"
|
||||
while [ "$#" -ge 1 ]; do echo " $1"; shift; done
|
||||
echo
|
||||
echo "See '${Script##*/} -help' for usage"
|
||||
echo "See '${0##*/} -help' for usage"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
@ -73,7 +73,7 @@ die()
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
optSyntax=sh
|
||||
optSyntax="sh"
|
||||
unset verboseOutput
|
||||
|
||||
# Parse options
|
||||
|
@ -339,9 +339,8 @@ $(IOdictionary)/IOdictionary.C
|
||||
db/IOobjects/IOMap/IOMaps.C
|
||||
db/IOobjects/decomposedBlockData/decomposedBlockData.C
|
||||
db/IOobjects/decomposedBlockData/decomposedBlockDataHeader.C
|
||||
db/IOobjects/rawIOField/rawIOFields.C
|
||||
db/IOobjects/GlobalIOField/GlobalIOFields.C
|
||||
|
||||
|
||||
db/IOobjects/GlobalIOList/globalIOLists.C
|
||||
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -34,6 +34,7 @@ template<class Type>
|
||||
Foam::rawIOField<Type>::rawIOField(const IOobject& io, const bool readAverage)
|
||||
:
|
||||
regIOobject(io),
|
||||
hasAverage_(false),
|
||||
average_(Zero)
|
||||
{
|
||||
// Check for MUST_READ_IF_MODIFIED
|
||||
@ -61,15 +62,13 @@ Foam::rawIOField<Type>::rawIOField(const IOobject& io, const bool readAverage)
|
||||
{
|
||||
haveFile = true;
|
||||
|
||||
ISstream& is = isPtr();
|
||||
auto& is = *isPtr;
|
||||
|
||||
const token firstToken(is);
|
||||
|
||||
headerOk = is.good() && firstToken.isWord("FoamFile");
|
||||
}
|
||||
|
||||
isPtr.clear();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "rawIOField : object:" << io.name()
|
||||
@ -90,18 +89,31 @@ Foam::rawIOField<Type>::rawIOField(const IOobject& io, const bool readAverage)
|
||||
is >> static_cast<Field<Type>&>(*this);
|
||||
if (readAverage)
|
||||
{
|
||||
average_ = pTraits<Type>(is);
|
||||
hasAverage_ = true;
|
||||
is >> average_;
|
||||
}
|
||||
close();
|
||||
}
|
||||
}
|
||||
else if (haveFile)
|
||||
{
|
||||
// Failed reading - fall back to IFstream
|
||||
// Failed reading header - fall back to IFstream
|
||||
autoPtr<ISstream> isPtr(fileHandler().NewIFstream(io.objectPath()));
|
||||
|
||||
if (!isPtr || !isPtr->good())
|
||||
if (isPtr && isPtr->good())
|
||||
{
|
||||
auto& is = *isPtr;
|
||||
|
||||
is >> static_cast<Field<Type>&>(*this);
|
||||
if (readAverage)
|
||||
{
|
||||
hasAverage_ = true;
|
||||
is >> average_;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Error if missing and MUST_READ or MUST_READ_IF_MODIFIED
|
||||
if (io.readOpt() != IOobject::READ_IF_PRESENT)
|
||||
{
|
||||
FatalIOErrorInFunction(*isPtr)
|
||||
@ -109,16 +121,6 @@ Foam::rawIOField<Type>::rawIOField(const IOobject& io, const bool readAverage)
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ISstream& is = isPtr();
|
||||
|
||||
is >> static_cast<Field<Type>&>(*this);
|
||||
if (readAverage)
|
||||
{
|
||||
average_ = pTraits<Type>(is);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
@ -132,11 +134,19 @@ Foam::rawIOField<Type>::rawIOField(const IOobject& io, const bool readAverage)
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::rawIOField<Type>::setAverage(const Type& val)
|
||||
{
|
||||
hasAverage_ = true;
|
||||
average_ = val;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
bool Foam::rawIOField<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
os << static_cast<const Field<Type>&>(*this);
|
||||
if (average_ != pTraits<Type>::zero)
|
||||
if (hasAverage_)
|
||||
{
|
||||
os << token::NL << average_;
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -35,8 +35,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef rawIOField_H
|
||||
#define rawIOField_H
|
||||
#ifndef Foam_rawIOField_H
|
||||
#define Foam_rawIOField_H
|
||||
|
||||
#include "IOField.H"
|
||||
|
||||
@ -57,7 +57,10 @@ class rawIOField
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- The average of the field (Zero if not used)
|
||||
//- Has an average value
|
||||
bool hasAverage_;
|
||||
|
||||
//- The average for the field (zero if not used)
|
||||
Type average_;
|
||||
|
||||
|
||||
@ -72,7 +75,7 @@ public:
|
||||
rawIOField(const rawIOField&) = default;
|
||||
|
||||
//- Construct from IOobject
|
||||
explicit rawIOField(const IOobject& io, const bool readAverage);
|
||||
explicit rawIOField(const IOobject& io, const bool readAverage=false);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -81,11 +84,21 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
const Type& average() const
|
||||
//- Has an average value
|
||||
bool hasAverage() const noexcept
|
||||
{
|
||||
return hasAverage_;
|
||||
}
|
||||
|
||||
//- The average value (if any)
|
||||
const Type& average() const noexcept
|
||||
{
|
||||
return average_;
|
||||
}
|
||||
|
||||
//- Set an average value
|
||||
void setAverage(const Type& val);
|
||||
|
||||
bool writeData(Ostream& os) const;
|
||||
|
||||
|
@ -325,7 +325,6 @@ PatchFunction1/PatchFunction1/patchFunction1Base.C
|
||||
PatchFunction1/makePatchFunction1s.C
|
||||
PatchFunction1/coordinateScaling/coordinateScalings.C
|
||||
PatchFunction1/CodedField/makeCodedFields.C
|
||||
PatchFunction1/MappedFile/rawIOFields.C
|
||||
|
||||
meshStructure/meshStructure.C
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user