mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: Corrected basic source and derived classes I/O
This commit is contained in:
@ -75,11 +75,11 @@ Foam::actuationDiskSource::actuationDiskSource
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
basicSource(name, modelType, dict, mesh),
|
basicSource(name, modelType, dict, mesh),
|
||||||
dict_(dict.subDict(modelType + "Coeffs")),
|
coeffs_(dict.subDict(modelType + "Coeffs")),
|
||||||
diskDir_(dict_.lookup("diskDir")),
|
diskDir_(coeffs_.lookup("diskDir")),
|
||||||
Cp_(readScalar(dict_.lookup("Cp"))),
|
Cp_(readScalar(coeffs_.lookup("Cp"))),
|
||||||
Ct_(readScalar(dict_.lookup("Ct"))),
|
Ct_(readScalar(coeffs_.lookup("Ct"))),
|
||||||
diskArea_(readScalar(dict_.lookup("diskArea")))
|
diskArea_(readScalar(coeffs_.lookup("diskArea")))
|
||||||
{
|
{
|
||||||
Info<< " - creating actuation disk zone: "
|
Info<< " - creating actuation disk zone: "
|
||||||
<< this->name() << endl;
|
<< this->name() << endl;
|
||||||
@ -132,20 +132,8 @@ void Foam::actuationDiskSource::addSu(fvMatrix<vector>& UEqn)
|
|||||||
|
|
||||||
void Foam::actuationDiskSource::writeData(Ostream& os) const
|
void Foam::actuationDiskSource::writeData(Ostream& os) const
|
||||||
{
|
{
|
||||||
os << indent << token::BEGIN_BLOCK << incrIndent << nl;
|
os << indent << name_ << endl;
|
||||||
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";
|
|
||||||
|
|
||||||
dict_.write(os);
|
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))
|
if (basicSource::read(dict))
|
||||||
{
|
{
|
||||||
const dictionary& sourceDict = dict.subDict(name());
|
coeffs_ = dict.subDict(typeName + "Coeffs");
|
||||||
const dictionary& subDictCoeffs =
|
coeffs_.readIfPresent("diskDir", diskDir_);
|
||||||
sourceDict.subDict(typeName + "Coeffs");
|
coeffs_.readIfPresent("Cp", Cp_);
|
||||||
subDictCoeffs.readIfPresent("diskDir", diskDir_);
|
coeffs_.readIfPresent("Ct", Ct_);
|
||||||
subDictCoeffs.readIfPresent("Cp", Cp_);
|
coeffs_.readIfPresent("diskArea", diskArea_);
|
||||||
subDictCoeffs.readIfPresent("Ct", Ct_);
|
|
||||||
subDictCoeffs.readIfPresent("diskArea", diskArea_);
|
|
||||||
|
|
||||||
checkData();
|
checkData();
|
||||||
|
|
||||||
|
|||||||
@ -74,8 +74,8 @@ protected:
|
|||||||
|
|
||||||
// Protected data
|
// Protected data
|
||||||
|
|
||||||
//- Sub dictionary with actuationDisk information
|
//- Coefficients dictionary
|
||||||
const dictionary& dict_;
|
dictionary coeffs_;
|
||||||
|
|
||||||
//- Disk area normal
|
//- Disk area normal
|
||||||
vector diskDir_;
|
vector diskDir_;
|
||||||
|
|||||||
@ -277,28 +277,20 @@ bool Foam::basicSource::isActive()
|
|||||||
|
|
||||||
void Foam::basicSource::addSu(Foam::fvMatrix<vector>& Eqn)
|
void Foam::basicSource::addSu(Foam::fvMatrix<vector>& Eqn)
|
||||||
{
|
{
|
||||||
notImplemented
|
notImplemented("Foam::basicSource addSu(Foam::fvMatrix<vector>& Eqn)");
|
||||||
(
|
|
||||||
"Foam::basicSource addSu(Foam::fvMatrix<vector>& Eqn)"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::basicSource::addSu(Foam::fvMatrix<scalar>& Eqn)
|
void Foam::basicSource::addSu(Foam::fvMatrix<scalar>& Eqn)
|
||||||
{
|
{
|
||||||
notImplemented
|
notImplemented("Foam::basicSource addSu(Foam::fvMatrix<scalar>& Eqn)");
|
||||||
(
|
|
||||||
"Foam::basicSource addSu(Foam::fvMatrix<scalar>& Eqn)"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::basicSource::setValue(Foam::fvMatrix<scalar>& Eqn)
|
void Foam::basicSource::setValue(Foam::fvMatrix<scalar>& Eqn)
|
||||||
{
|
{
|
||||||
notImplemented
|
notImplemented("Foam::basicSource setValue(Foam::fvMatrix<scalar>& Eqn)");
|
||||||
(
|
|
||||||
"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)
|
bool Foam::basicSource::read(const dictionary& dict)
|
||||||
{
|
{
|
||||||
const dictionary& sourceDict = dict.subDict(name_);
|
active_ = readBool(dict.lookup("active"));
|
||||||
active_ = readBool(sourceDict.lookup("active"));
|
timeStart_ = readScalar(dict.lookup("timeStart"));
|
||||||
timeStart_ = readScalar(sourceDict.lookup("timeStart"));
|
duration_ = readScalar(dict.lookup("duration"));
|
||||||
duration_ = readScalar(sourceDict.lookup("duration"));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -51,12 +51,12 @@ Foam::basicSourceList::basicSourceList
|
|||||||
forAllConstIter(dictionary, dict, iter)
|
forAllConstIter(dictionary, dict, iter)
|
||||||
{
|
{
|
||||||
const word& name = iter().keyword();
|
const word& name = iter().keyword();
|
||||||
const dictionary& dict = iter().dict();
|
const dictionary& sourceDict = iter().dict();
|
||||||
|
|
||||||
this->set
|
this->set
|
||||||
(
|
(
|
||||||
i++,
|
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;
|
bool allOk = true;
|
||||||
forAll(*this, i)
|
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);
|
allOk = (allOk && ok);
|
||||||
}
|
}
|
||||||
return allOk;
|
return allOk;
|
||||||
@ -117,12 +118,6 @@ bool Foam::basicSourceList::read(const dictionary& dict)
|
|||||||
|
|
||||||
bool Foam::basicSourceList::writeData(Ostream& os) const
|
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
|
// Write list contents
|
||||||
forAll(*this, i)
|
forAll(*this, i)
|
||||||
{
|
{
|
||||||
@ -130,9 +125,6 @@ bool Foam::basicSourceList::writeData(Ostream& os) const
|
|||||||
this->operator[](i).writeData(os);
|
this->operator[](i).writeData(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write end of contents
|
|
||||||
os << token::END_LIST << token::END_STATEMENT << nl;
|
|
||||||
|
|
||||||
// Check state of IOstream
|
// Check state of IOstream
|
||||||
return os.good();
|
return os.good();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,11 +72,9 @@ void Foam::explicitSetValue::setFieldData(const dictionary& dict)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn("explicitSetValue::setFieldData")
|
||||||
(
|
<< "header not OK for field " << io.name()
|
||||||
"explicitSetValue::setFieldData"
|
<< abort(FatalError);
|
||||||
) << "header not OK " << io.name()
|
|
||||||
<< exit(FatalError);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,9 +94,9 @@ Foam::explicitSetValue::explicitSetValue
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
basicSource(name, modelType, dict, mesh),
|
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
|
// Protected data
|
||||||
|
|
||||||
//- Sub dictionary for time activated explicit sources
|
//- Coefficients dictionary
|
||||||
const dictionary& dict_;
|
dictionary coeffs_;
|
||||||
|
|
||||||
|
|
||||||
// Protected functions
|
// Protected functions
|
||||||
@ -119,10 +119,7 @@ public:
|
|||||||
//- Return clone
|
//- Return clone
|
||||||
autoPtr<explicitSetValue> clone() const
|
autoPtr<explicitSetValue> clone() const
|
||||||
{
|
{
|
||||||
notImplemented
|
notImplemented("autoPtr<explicitSetValue> clone() const");
|
||||||
(
|
|
||||||
"autoPtr<explicitSetValue> clone() const"
|
|
||||||
);
|
|
||||||
return autoPtr<explicitSetValue>(NULL);
|
return autoPtr<explicitSetValue>(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -29,22 +29,8 @@ License
|
|||||||
|
|
||||||
void Foam::explicitSetValue::writeData(Ostream& os) const
|
void Foam::explicitSetValue::writeData(Ostream& os) const
|
||||||
{
|
{
|
||||||
os << indent << name_ << nl
|
os << indent << name_ << endl;
|
||||||
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
|
dict_.write(os);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -52,12 +38,8 @@ bool Foam::explicitSetValue::read(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
if (basicSource::read(dict))
|
if (basicSource::read(dict))
|
||||||
{
|
{
|
||||||
const dictionary& sourceDict = dict.subDict(name());
|
coeffs_ = dict.subDict(typeName + "Coeffs");
|
||||||
const dictionary& subDictCoeffs = sourceDict.subDict
|
setFieldData(coeffs_.subDict("fieldData"));
|
||||||
(
|
|
||||||
typeName + "Coeffs"
|
|
||||||
);
|
|
||||||
setFieldData(subDictCoeffs.subDict("fieldData"));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -112,8 +112,8 @@ Foam::explicitSource::explicitSource
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
basicSource(name, modelType, dict, mesh),
|
basicSource(name, modelType, dict, mesh),
|
||||||
dict_(dict.subDict(modelType + "Coeffs")),
|
coeffs_(dict.subDict(modelType + "Coeffs")),
|
||||||
volumeMode_(volumeModeTypeNames_.read(dict_.lookup("volumeMode")))
|
volumeMode_(volumeModeTypeNames_.read(coeffs_.lookup("volumeMode")))
|
||||||
{
|
{
|
||||||
setFieldData(dict_.subDict("fieldData"));
|
setFieldData(dict_.subDict("fieldData"));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -110,8 +110,8 @@ protected:
|
|||||||
|
|
||||||
// Protected data
|
// Protected data
|
||||||
|
|
||||||
//- Sub dictionary for time activated explicit sources
|
//- Coefficients dictionary
|
||||||
const dictionary& dict_;
|
dictionary coeffs_;
|
||||||
|
|
||||||
//- Volume mode
|
//- Volume mode
|
||||||
volumeModeType volumeMode_;
|
volumeModeType volumeMode_;
|
||||||
|
|||||||
@ -29,25 +29,8 @@ License
|
|||||||
|
|
||||||
void Foam::explicitSource::writeData(Ostream& os) const
|
void Foam::explicitSource::writeData(Ostream& os) const
|
||||||
{
|
{
|
||||||
os << indent << name_ << nl
|
os << indent << name_ << endl;
|
||||||
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
|
dict_.write(os);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -55,12 +38,8 @@ bool Foam::explicitSource::read(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
if (basicSource::read(dict))
|
if (basicSource::read(dict))
|
||||||
{
|
{
|
||||||
const dictionary& sourceDict = dict.subDict(name());
|
coeffs_ = dict.subDict(typeName + "Coeffs");
|
||||||
const dictionary& subDictCoeffs = sourceDict.subDict
|
setFieldData(coeffs_.subDict("fieldData"));
|
||||||
(
|
|
||||||
typeName + "Coeffs"
|
|
||||||
);
|
|
||||||
setFieldData(subDictCoeffs.subDict("fieldData"));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -53,10 +53,10 @@ Foam::radialActuationDiskSource::radialActuationDiskSource
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
actuationDiskSource(name, modelType, dict, mesh),
|
actuationDiskSource(name, modelType, dict, mesh),
|
||||||
dict_(dict.subDict(modelType + "Coeffs")),
|
coeffsDict_(dict.subDict(modelType + "Coeffs")),
|
||||||
coeffs_()
|
coeffs_()
|
||||||
{
|
{
|
||||||
dict_.lookup("coeffs") >> coeffs_;
|
coeffsDict_.lookup("coeffs") >> coeffs_;
|
||||||
Info<< " - creating radial actuation disk zone: "
|
Info<< " - creating radial actuation disk zone: "
|
||||||
<< this->name() << endl;
|
<< this->name() << endl;
|
||||||
}
|
}
|
||||||
@ -114,14 +114,12 @@ bool Foam::radialActuationDiskSource::read(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
if (basicSource::read(dict))
|
if (basicSource::read(dict))
|
||||||
{
|
{
|
||||||
const dictionary& sourceDict = dict.subDict(name());
|
const dictionary& coeffsDict_ = dict.subDict(typeName + "Coeffs");
|
||||||
const dictionary& subDictCoeffs =
|
coeffsDict_.readIfPresent("diskDir", diskDir_);
|
||||||
sourceDict.subDict(typeName + "Coeffs");
|
coeffsDict_.readIfPresent("Cp", Cp_);
|
||||||
subDictCoeffs.readIfPresent("diskDir", diskDir_);
|
coeffsDict_.readIfPresent("Ct", Ct_);
|
||||||
subDictCoeffs.readIfPresent("Cp", Cp_);
|
coeffsDict_.readIfPresent("diskArea", diskArea_);
|
||||||
subDictCoeffs.readIfPresent("Ct", Ct_);
|
coeffsDict_.lookup("coeffs") >> coeffs_;
|
||||||
subDictCoeffs.readIfPresent("diskArea", diskArea_);
|
|
||||||
subDictCoeffs.lookup("coeffs") >> coeffs_;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -62,7 +62,7 @@ namespace Foam
|
|||||||
{
|
{
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class radialActuationDiskSource Declaration
|
Class radialActuationDiskSource Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class radialActuationDiskSource
|
class radialActuationDiskSource
|
||||||
@ -71,8 +71,8 @@ class radialActuationDiskSource
|
|||||||
{
|
{
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
//- Sub dictionary with model information
|
//- Coefficients dictionary
|
||||||
const dictionary& dict_;
|
dictionary coeffsDict_;
|
||||||
|
|
||||||
//- Coeffcients for the radial distribution
|
//- Coeffcients for the radial distribution
|
||||||
FixedList<scalar, 3> coeffs_;
|
FixedList<scalar, 3> coeffs_;
|
||||||
@ -123,7 +123,7 @@ public:
|
|||||||
|
|
||||||
// Public Functions
|
// Public Functions
|
||||||
|
|
||||||
//-Source term to fvMatrix<vector>
|
//- Source term to fvMatrix<vector>
|
||||||
virtual void addSu(fvMatrix<vector>& UEqn);
|
virtual void addSu(fvMatrix<vector>& UEqn);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user