Commit ebd90fcc authored by Andrew Heather's avatar Andrew Heather
Browse files

ENH: Updated DimensionedField I/O for readIfPresent

parent b3a72cbd
......@@ -81,14 +81,20 @@ DimensionedField<Type, GeoMesh>::DimensionedField
(
const IOobject& io,
const Mesh& mesh,
const dimensionSet& dims
const dimensionSet& dims,
const bool checkIOFlags
)
:
regIOobject(io),
Field<Type>(GeoMesh::size(mesh)),
mesh_(mesh),
dimensions_(dims)
{}
{
if (checkIOFlags)
{
readIfPresent();
}
}
template<class Type, class GeoMesh>
......@@ -96,14 +102,20 @@ DimensionedField<Type, GeoMesh>::DimensionedField
(
const IOobject& io,
const Mesh& mesh,
const dimensioned<Type>& dt
const dimensioned<Type>& dt,
const bool checkIOFlags
)
:
regIOobject(io),
Field<Type>(GeoMesh::size(mesh), dt.value()),
mesh_(mesh),
dimensions_(dt.dimensions())
{}
{
if (checkIOFlags)
{
readIfPresent();
}
}
template<class Type, class GeoMesh>
......
......@@ -94,6 +94,11 @@ private:
dimensionSet dimensions_;
// Private Member Functions
void readIfPresent(const word& fieldDictEntry = "value");
public:
//- Runtime type information
......@@ -122,7 +127,8 @@ public:
(
const IOobject&,
const Mesh& mesh,
const dimensionSet&
const dimensionSet&,
const bool checkIOFlags = true
);
//- Construct from components
......@@ -130,7 +136,8 @@ public:
(
const IOobject&,
const Mesh& mesh,
const dimensioned<Type>&
const dimensioned<Type>&,
const bool checkIOFlags = true
);
//- Construct from Istream
......@@ -141,12 +148,6 @@ public:
const word& fieldDictEntry="value"
);
void readField
(
const dictionary& fieldDict,
const word& fieldDictEntry="value"
);
//- Construct as copy
DimensionedField
(
......@@ -222,6 +223,12 @@ public:
// Member Functions
void readField
(
const dictionary& fieldDict,
const word& fieldDictEntry = "value"
);
//- Return mesh
inline const Mesh& mesh() const;
......
......@@ -47,6 +47,21 @@ void DimensionedField<Type, GeoMesh>::readField
}
template<class Type, class GeoMesh>
void DimensionedField<Type, GeoMesh>::readIfPresent(const word& fieldDictEntry)
{
if
(
(this->headerOk() && this->readOpt() == IOobject::READ_IF_PRESENT)
|| this->readOpt() == IOobject::MUST_READ
|| this->readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
{
readField(dictionary(readStream(typeName)), fieldDictEntry);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type, class GeoMesh>
......
......@@ -209,7 +209,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
const word& patchFieldType
)
:
DimensionedField<Type, GeoMesh>(io, mesh, ds),
DimensionedField<Type, GeoMesh>(io, mesh, ds, false),
timeIndex_(this->time().timeIndex()),
field0Ptr_(NULL),
fieldPrevIterPtr_(NULL),
......@@ -240,7 +240,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
const wordList& actualPatchTypes
)
:
DimensionedField<Type, GeoMesh>(io, mesh, ds),
DimensionedField<Type, GeoMesh>(io, mesh, ds, false),
timeIndex_(this->time().timeIndex()),
field0Ptr_(NULL),
fieldPrevIterPtr_(NULL),
......@@ -267,7 +267,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
const word& patchFieldType
)
:
DimensionedField<Type, GeoMesh>(io, mesh, dt),
DimensionedField<Type, GeoMesh>(io, mesh, dt, false),
timeIndex_(this->time().timeIndex()),
field0Ptr_(NULL),
fieldPrevIterPtr_(NULL),
......@@ -297,7 +297,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
const wordList& actualPatchTypes
)
:
DimensionedField<Type, GeoMesh>(io, mesh, dt),
DimensionedField<Type, GeoMesh>(io, mesh, dt, false),
timeIndex_(this->time().timeIndex()),
field0Ptr_(NULL),
fieldPrevIterPtr_(NULL),
......@@ -327,7 +327,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
const PtrList<PatchField<Type> >& ptfl
)
:
DimensionedField<Type, GeoMesh>(io, mesh, ds, iField),
DimensionedField<Type, GeoMesh>(io, mesh, ds, iField, false),
timeIndex_(this->time().timeIndex()),
field0Ptr_(NULL),
fieldPrevIterPtr_(NULL),
......@@ -351,7 +351,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
const Mesh& mesh
)
:
DimensionedField<Type, GeoMesh>(io, mesh, dimless),
DimensionedField<Type, GeoMesh>(io, mesh, dimless, false),
timeIndex_(this->time().timeIndex()),
field0Ptr_(NULL),
fieldPrevIterPtr_(NULL),
......@@ -392,7 +392,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
Istream& is
)
:
DimensionedField<Type, GeoMesh>(io, mesh, dimless),
DimensionedField<Type, GeoMesh>(io, mesh, dimless, false),
timeIndex_(this->time().timeIndex()),
field0Ptr_(NULL),
fieldPrevIterPtr_(NULL),
......@@ -431,7 +431,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
const dictionary& dict
)
:
DimensionedField<Type, GeoMesh>(io, mesh, dimless),
DimensionedField<Type, GeoMesh>(io, mesh, dimless, false),
timeIndex_(this->time().timeIndex()),
field0Ptr_(NULL),
fieldPrevIterPtr_(NULL),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment