Commit ae6d9359 authored by andy's avatar andy
Browse files

BUG: Corrected basic source and derived classes I/O

parent dd506c3f
......@@ -75,11 +75,11 @@ Foam::actuationDiskSource::actuationDiskSource
)
:
basicSource(name, modelType, dict, mesh),
dict_(dict.subDict(modelType + "Coeffs")),
diskDir_(dict_.lookup("diskDir")),
Cp_(readScalar(dict_.lookup("Cp"))),
Ct_(readScalar(dict_.lookup("Ct"))),
diskArea_(readScalar(dict_.lookup("diskArea")))
coeffs_(dict.subDict(modelType + "Coeffs")),
diskDir_(coeffs_.lookup("diskDir")),
Cp_(readScalar(coeffs_.lookup("Cp"))),
Ct_(readScalar(coeffs_.lookup("Ct"))),
diskArea_(readScalar(coeffs_.lookup("diskArea")))
{
Info<< " - creating actuation disk zone: "
<< this->name() << endl;
......@@ -132,20 +132,8 @@ void Foam::actuationDiskSource::addSu(fvMatrix<vector>& UEqn)
void Foam::actuationDiskSource::writeData(Ostream& os) const
{
os << indent << token::BEGIN_BLOCK << incrIndent << nl;
os.writeKeyword("name") << this->name() << token::END_STATEMENT << nl;
if (dict_.found("note"))
{
os.writeKeyword("note") << string(dict_.lookup("note"))
<< token::END_STATEMENT << nl;
}
os << indent << "actuationDisk";
os << indent << name_ << endl;
dict_.write(os);
os << decrIndent << indent << token::END_BLOCK << endl;
}
......@@ -153,13 +141,11 @@ bool Foam::actuationDiskSource::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
const dictionary& sourceDict = dict.subDict(name());
const dictionary& subDictCoeffs =
sourceDict.subDict(typeName + "Coeffs");
subDictCoeffs.readIfPresent("diskDir", diskDir_);
subDictCoeffs.readIfPresent("Cp", Cp_);
subDictCoeffs.readIfPresent("Ct", Ct_);
subDictCoeffs.readIfPresent("diskArea", diskArea_);
coeffs_ = dict.subDict(typeName + "Coeffs");
coeffs_.readIfPresent("diskDir", diskDir_);
coeffs_.readIfPresent("Cp", Cp_);
coeffs_.readIfPresent("Ct", Ct_);
coeffs_.readIfPresent("diskArea", diskArea_);
checkData();
......
......@@ -74,8 +74,8 @@ protected:
// Protected data
//- Sub dictionary with actuationDisk information
const dictionary& dict_;
//- Coefficients dictionary
dictionary coeffs_;
//- Disk area normal
vector diskDir_;
......
......@@ -277,28 +277,20 @@ bool Foam::basicSource::isActive()
void Foam::basicSource::addSu(Foam::fvMatrix<vector>& Eqn)
{
notImplemented
(
"Foam::basicSource addSu(Foam::fvMatrix<vector>& Eqn)"
);
notImplemented("Foam::basicSource addSu(Foam::fvMatrix<vector>& Eqn)");
}
void Foam::basicSource::addSu(Foam::fvMatrix<scalar>& Eqn)
{
notImplemented
(
"Foam::basicSource addSu(Foam::fvMatrix<scalar>& Eqn)"
);
notImplemented("Foam::basicSource addSu(Foam::fvMatrix<scalar>& Eqn)");
}
void Foam::basicSource::setValue(Foam::fvMatrix<scalar>& Eqn)
{
notImplemented
(
"Foam::basicSource setValue(Foam::fvMatrix<scalar>& Eqn)"
);
notImplemented("Foam::basicSource setValue(Foam::fvMatrix<scalar>& Eqn)");
}
// ************************************************************************* //
......@@ -77,10 +77,9 @@ void Foam::basicSource::writeData(Ostream& os) const
bool Foam::basicSource::read(const dictionary& dict)
{
const dictionary& sourceDict = dict.subDict(name_);
active_ = readBool(sourceDict.lookup("active"));
timeStart_ = readScalar(sourceDict.lookup("timeStart"));
duration_ = readScalar(sourceDict.lookup("duration"));
active_ = readBool(dict.lookup("active"));
timeStart_ = readScalar(dict.lookup("timeStart"));
duration_ = readScalar(dict.lookup("duration"));
return true;
}
......
......@@ -51,12 +51,12 @@ Foam::basicSourceList::basicSourceList
forAllConstIter(dictionary, dict, iter)
{
const word& name = iter().keyword();
const dictionary& dict = iter().dict();
const dictionary& sourceDict = iter().dict();
this->set
(
i++,
basicSource::New(name, dict, mesh)
basicSource::New(name, sourceDict, mesh)
);
}
}
......@@ -108,7 +108,8 @@ bool Foam::basicSourceList::read(const dictionary& dict)
bool allOk = true;
forAll(*this, i)
{
bool ok = this->operator[](i).read(dict);
basicSource& bs = this->operator[](i);
bool ok = bs.read(dict.subDict(bs.name()));
allOk = (allOk && ok);
}
return allOk;
......@@ -117,12 +118,6 @@ bool Foam::basicSourceList::read(const dictionary& dict)
bool Foam::basicSourceList::writeData(Ostream& os) const
{
// Write size of list
os << nl << this->size();
// Write beginning of contents
os << nl << token::BEGIN_LIST;
// Write list contents
forAll(*this, i)
{
......@@ -130,9 +125,6 @@ bool Foam::basicSourceList::writeData(Ostream& os) const
this->operator[](i).writeData(os);
}
// Write end of contents
os << token::END_LIST << token::END_STATEMENT << nl;
// Check state of IOstream
return os.good();
}
......
......@@ -72,11 +72,9 @@ void Foam::explicitSetValue::setFieldData(const dictionary& dict)
}
else
{
FatalErrorIn
(
"explicitSetValue::setFieldData"
) << "header not OK " << io.name()
<< exit(FatalError);
FatalErrorIn("explicitSetValue::setFieldData")
<< "header not OK for field " << io.name()
<< abort(FatalError);
}
}
......@@ -96,9 +94,9 @@ Foam::explicitSetValue::explicitSetValue
)
:
basicSource(name, modelType, dict, mesh),
dict_(dict.subDict(modelType + "Coeffs"))
coeffs_(dict.subDict(modelType + "Coeffs"))
{
setFieldData(dict_.subDict("fieldData"));
setFieldData(coeffs_.subDict("fieldData"));
}
......
......@@ -89,8 +89,8 @@ protected:
// Protected data
//- Sub dictionary for time activated explicit sources
const dictionary& dict_;
//- Coefficients dictionary
dictionary coeffs_;
// Protected functions
......@@ -119,10 +119,7 @@ public:
//- Return clone
autoPtr<explicitSetValue> clone() const
{
notImplemented
(
"autoPtr<explicitSetValue> clone() const"
);
notImplemented("autoPtr<explicitSetValue> clone() const");
return autoPtr<explicitSetValue>(NULL);
}
......
......@@ -29,22 +29,8 @@ License
void Foam::explicitSetValue::writeData(Ostream& os) const
{
os << indent << name_ << nl
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
if (scalarFields_.size() > 0)
{
os.writeKeyword("scalarFields") << scalarFields_
<< token::END_STATEMENT << nl;
}
if (vectorFields_.size() > 0)
{
os.writeKeyword("vectorFields") << vectorFields_
<< token::END_STATEMENT << nl;
}
os << decrIndent << indent << token::END_BLOCK << endl;
os << indent << name_ << endl;
dict_.write(os);
}
......@@ -52,12 +38,8 @@ bool Foam::explicitSetValue::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
const dictionary& sourceDict = dict.subDict(name());
const dictionary& subDictCoeffs = sourceDict.subDict
(
typeName + "Coeffs"
);
setFieldData(subDictCoeffs.subDict("fieldData"));
coeffs_ = dict.subDict(typeName + "Coeffs");
setFieldData(coeffs_.subDict("fieldData"));
return true;
}
else
......
......@@ -112,8 +112,8 @@ Foam::explicitSource::explicitSource
)
:
basicSource(name, modelType, dict, mesh),
dict_(dict.subDict(modelType + "Coeffs")),
volumeMode_(volumeModeTypeNames_.read(dict_.lookup("volumeMode")))
coeffs_(dict.subDict(modelType + "Coeffs")),
volumeMode_(volumeModeTypeNames_.read(coeffs_.lookup("volumeMode")))
{
setFieldData(dict_.subDict("fieldData"));
}
......
......@@ -110,8 +110,8 @@ protected:
// Protected data
//- Sub dictionary for time activated explicit sources
const dictionary& dict_;
//- Coefficients dictionary
dictionary coeffs_;
//- Volume mode
volumeModeType volumeMode_;
......
......@@ -29,25 +29,8 @@ License
void Foam::explicitSource::writeData(Ostream& os) const
{
os << indent << name_ << nl
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
os.writeKeyword("volumeMode") << volumeModeTypeNames_[volumeMode_]
<< token::END_STATEMENT << nl;
if (scalarFields_.size() > 0)
{
os.writeKeyword("scalarFields") << scalarFields_
<< token::END_STATEMENT << nl;
}
if (vectorFields_.size() > 0)
{
os.writeKeyword("vectorFields") << vectorFields_
<< token::END_STATEMENT << nl;
}
os << decrIndent << indent << token::END_BLOCK << endl;
os << indent << name_ << endl;
dict_.write(os);
}
......@@ -55,12 +38,8 @@ bool Foam::explicitSource::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
const dictionary& sourceDict = dict.subDict(name());
const dictionary& subDictCoeffs = sourceDict.subDict
(
typeName + "Coeffs"
);
setFieldData(subDictCoeffs.subDict("fieldData"));
coeffs_ = dict.subDict(typeName + "Coeffs");
setFieldData(coeffs_.subDict("fieldData"));
return true;
}
else
......
......@@ -53,10 +53,10 @@ Foam::radialActuationDiskSource::radialActuationDiskSource
)
:
actuationDiskSource(name, modelType, dict, mesh),
dict_(dict.subDict(modelType + "Coeffs")),
coeffsDict_(dict.subDict(modelType + "Coeffs")),
coeffs_()
{
dict_.lookup("coeffs") >> coeffs_;
coeffsDict_.lookup("coeffs") >> coeffs_;
Info<< " - creating radial actuation disk zone: "
<< this->name() << endl;
}
......@@ -114,14 +114,12 @@ bool Foam::radialActuationDiskSource::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
const dictionary& sourceDict = dict.subDict(name());
const dictionary& subDictCoeffs =
sourceDict.subDict(typeName + "Coeffs");
subDictCoeffs.readIfPresent("diskDir", diskDir_);
subDictCoeffs.readIfPresent("Cp", Cp_);
subDictCoeffs.readIfPresent("Ct", Ct_);
subDictCoeffs.readIfPresent("diskArea", diskArea_);
subDictCoeffs.lookup("coeffs") >> coeffs_;
const dictionary& coeffsDict_ = dict.subDict(typeName + "Coeffs");
coeffsDict_.readIfPresent("diskDir", diskDir_);
coeffsDict_.readIfPresent("Cp", Cp_);
coeffsDict_.readIfPresent("Ct", Ct_);
coeffsDict_.readIfPresent("diskArea", diskArea_);
coeffsDict_.lookup("coeffs") >> coeffs_;
return true;
}
else
......
......@@ -62,7 +62,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class radialActuationDiskSource Declaration
Class radialActuationDiskSource Declaration
\*---------------------------------------------------------------------------*/
class radialActuationDiskSource
......@@ -71,8 +71,8 @@ class radialActuationDiskSource
{
// Private data
//- Sub dictionary with model information
const dictionary& dict_;
//- Coefficients dictionary
dictionary coeffsDict_;
//- Coeffcients for the radial distribution
FixedList<scalar, 3> coeffs_;
......@@ -123,7 +123,7 @@ public:
// Public Functions
//-Source term to fvMatrix<vector>
//- Source term to fvMatrix<vector>
virtual void addSu(fvMatrix<vector>& UEqn);
......
Markdown is supported
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