ENH: UniformDimensionedField: do READ_IF_PRESENT for 2 argument constructor

This commit is contained in:
mattijs
2012-03-28 18:01:24 +01:00
parent 39426e88dd
commit 6aecbac20f
2 changed files with 19 additions and 4 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -36,7 +36,22 @@ Foam::UniformDimensionedField<Type>::UniformDimensionedField
:
regIOobject(io),
dimensioned<Type>(dt)
{}
{
// Read value
if
(
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
dictionary dict(readStream(typeName));
this->dimensions().reset(dict.lookup("dimensions"));
dict.lookup("value") >> this->value();
}
}
template<class Type>

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -64,7 +64,7 @@ public:
// Constructors
//- Construct from components
//- Construct from components. Either reads or uses supplied value.
UniformDimensionedField(const IOobject&, const dimensioned<Type>&);
//- Construct as copy