mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
AverageIOField: Changed the average value to be member data.
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -26,42 +26,37 @@ License
|
|||||||
|
|
||||||
#include "AverageIOField.H"
|
#include "AverageIOField.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
AverageIOField<Type>::AverageIOField
|
Foam::AverageIOField<Type>::AverageIOField
|
||||||
(
|
(
|
||||||
const IOobject& io
|
const IOobject& io
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
regIOobject(io),
|
regIOobject(io)
|
||||||
pTraits<Type>(readStream(typeName)),
|
|
||||||
Field<Type>(readStream(typeName))
|
|
||||||
{
|
{
|
||||||
|
readStream(typeName) >> average_;
|
||||||
|
readStream(typeName) >> static_cast<Field<Type>&>(*this);
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
AverageIOField<Type>::AverageIOField
|
Foam::AverageIOField<Type>::AverageIOField
|
||||||
(
|
(
|
||||||
const IOobject& io,
|
const IOobject& io,
|
||||||
const label size
|
const label size
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
regIOobject(io),
|
regIOobject(io),
|
||||||
pTraits<Type>(pTraits<Type>::zero),
|
Field<Type>(size),
|
||||||
Field<Type>(size)
|
average_(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
AverageIOField<Type>::AverageIOField
|
Foam::AverageIOField<Type>::AverageIOField
|
||||||
(
|
(
|
||||||
const IOobject& io,
|
const IOobject& io,
|
||||||
const Type& average,
|
const Type& average,
|
||||||
@ -69,21 +64,28 @@ AverageIOField<Type>::AverageIOField
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
regIOobject(io),
|
regIOobject(io),
|
||||||
pTraits<Type>(average),
|
Field<Type>(f),
|
||||||
Field<Type>(f)
|
average_(average)
|
||||||
{
|
{
|
||||||
if (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
if (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||||
{
|
{
|
||||||
readStream(typeName)
|
readStream(typeName)
|
||||||
>> static_cast<Type&>(*this)
|
>> average_
|
||||||
>> static_cast<Field<Type>&>(*this);
|
>> static_cast<Field<Type>&>(*this);
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
template<class Type>
|
||||||
|
bool Foam::AverageIOField<Type>::writeData(Ostream& os) const
|
||||||
|
{
|
||||||
|
os << average_
|
||||||
|
<< token::NL
|
||||||
|
<< static_cast<const Field<Type>&>(*this);
|
||||||
|
|
||||||
|
return os.good();
|
||||||
|
}
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -52,9 +52,13 @@ template<class Type>
|
|||||||
class AverageIOField
|
class AverageIOField
|
||||||
:
|
:
|
||||||
public regIOobject,
|
public regIOobject,
|
||||||
public pTraits<Type>,
|
|
||||||
public Field<Type>
|
public Field<Type>
|
||||||
{
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- The average of the field
|
||||||
|
Type average_;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -87,19 +91,17 @@ public:
|
|||||||
|
|
||||||
// Member functions
|
// Member functions
|
||||||
|
|
||||||
const pTraits<Type>& average() const
|
const Type& average() const
|
||||||
{
|
{
|
||||||
return static_cast<const pTraits<Type>&>(*this);
|
return average_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool writeData(Ostream& os) const
|
Type& average()
|
||||||
{
|
{
|
||||||
os << static_cast<const Type&>(*this)
|
return average_;
|
||||||
<< token::NL
|
|
||||||
<< static_cast<const Field<Type>&>(*this);
|
|
||||||
|
|
||||||
return os.good();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool writeData(Ostream& os) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -22,6 +22,8 @@ License
|
|||||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "AverageIOField.H"
|
#include "AverageIOField.H"
|
||||||
|
|||||||
Reference in New Issue
Block a user