Commit 96a4cf40 authored by andy's avatar andy
Browse files

ENH: Updated writing of cloud properties to file for consistent restarts

parent 944af168
......@@ -230,6 +230,16 @@ void Foam::KinematicCloud<CloudType>::postEvolve()
functions_.postEvolve();
solution_.nextIter();
if (this->db().time().outputTime())
{
outputProperties_.writeObject
(
IOstream::ASCII,
IOstream::currentVersion,
this->db().time().writeCompression()
);
}
}
......@@ -281,6 +291,18 @@ Foam::KinematicCloud<CloudType>::KinematicCloud
IOobject::NO_WRITE
)
),
outputProperties_
(
IOobject
(
cloudName + "OutputProperties",
mesh_.time().timeName(),
"uniform"/cloud::prefix/cloudName,
mesh_,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
)
),
solution_(mesh_, particleProperties_.subDict("solution")),
constProps_(particleProperties_, solution_.active()),
subModelProperties_
......@@ -384,6 +406,7 @@ Foam::KinematicCloud<CloudType>::KinematicCloud
cloudCopyPtr_(NULL),
mesh_(c.mesh_),
particleProperties_(c.particleProperties_),
outputProperties_(c.outputProperties_),
solution_(c.solution_),
constProps_(c.constProps_),
subModelProperties_(c.subModelProperties_),
......@@ -460,6 +483,19 @@ Foam::KinematicCloud<CloudType>::KinematicCloud
false
)
),
outputProperties_
(
IOobject
(
name + "OutputProperties",
mesh_.time().timeName(),
"uniform"/cloud::prefix/name,
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
)
),
solution_(mesh),
constProps_(),
subModelProperties_(dictionary::null),
......@@ -639,7 +675,7 @@ void Foam::KinematicCloud<CloudType>::motion(TrackData& td)
template<class CloudType>
void Foam::KinematicCloud<CloudType>::info() const
void Foam::KinematicCloud<CloudType>::info()
{
vector linearMomentum = linearMomentumOfSystem();
reduce(linearMomentum, sumOp<vector>());
......
......@@ -143,6 +143,9 @@ protected:
//- Dictionary of particle properties
IOdictionary particleProperties_;
//- Dictionary of output properties
IOdictionary outputProperties_;
//- Solution properties
cloudSolution solution_;
......@@ -324,6 +327,12 @@ public:
//- Return particle properties dictionary
inline const IOdictionary& particleProperties() const;
//- Return output properties dictionary
inline const IOdictionary& outputProperties() const;
//- Return non-const access to the output properties dictionary
inline IOdictionary& outputProperties();
//- Return const access to the solution properties
inline const cloudSolution& solution() const;
......@@ -546,8 +555,11 @@ public:
template<class TrackData>
void motion(TrackData& td);
// I-O
//- Print cloud information
void info() const;
void info();
};
......
......@@ -50,6 +50,21 @@ Foam::KinematicCloud<CloudType>::particleProperties() const
}
template<class CloudType>
inline const Foam::IOdictionary&
Foam::KinematicCloud<CloudType>::outputProperties() const
{
return outputProperties_;
}
template<class CloudType>
inline Foam::IOdictionary& Foam::KinematicCloud<CloudType>::outputProperties()
{
return outputProperties_;
}
template<class CloudType>
inline const Foam::cloudSolution&
Foam::KinematicCloud<CloudType>::solution() const
......
......@@ -341,20 +341,13 @@ void Foam::ReactingCloud<CloudType>::evolve()
}
template<class CloudType>
void Foam::ReactingCloud<CloudType>::addToMassPhaseChange(const scalar dMass)
{
dMassPhaseChange_ += dMass;
}
template<class CloudType>
void Foam::ReactingCloud<CloudType>::info() const
void Foam::ReactingCloud<CloudType>::info()
{
CloudType::info();
Info<< " Mass transfer phase change = "
<< returnReduce(dMassPhaseChange_, sumOp<scalar>()) << nl;
this->phaseChange().info(Info);
}
......
......@@ -215,14 +215,18 @@ public:
// Sub-models
//- Return reference to reacting composition model
//- Return const access to reacting composition model
inline const CompositionModel<ReactingCloud<CloudType> >&
composition() const;
//- Return reference to reacting phase change model
//- Return const access to reacting phase change model
inline const PhaseChangeModel<ReactingCloud<CloudType> >&
phaseChange() const;
//- Return reference to reacting phase change model
inline PhaseChangeModel<ReactingCloud<CloudType> >&
phaseChange();
// Sources
......@@ -259,12 +263,6 @@ public:
inline tmp<fvScalarMatrix> Srho(volScalarField& rho) const;
// Check
//- Add to cumulative phase change mass transfer
void addToMassPhaseChange(const scalar dMass);
// Cloud evolution functions
//- Set parcel thermo properties
......@@ -300,12 +298,12 @@ public:
//- Evolve the cloud
void evolve();
//- Print cloud information
void info() const;
// I-O
//- Print cloud information
void info();
//- Write the field data for the cloud
virtual void writeFields() const;
};
......
......@@ -57,6 +57,14 @@ Foam::ReactingCloud<CloudType>::phaseChange() const
}
template<class CloudType>
inline Foam::PhaseChangeModel<Foam::ReactingCloud<CloudType> >&
Foam::ReactingCloud<CloudType>::phaseChange()
{
return phaseChangeModel_();
}
template<class CloudType>
inline Foam::DimensionedField<Foam::scalar, Foam::volMesh>&
Foam::ReactingCloud<CloudType>::rhoTrans(const label i)
......
......@@ -253,33 +253,12 @@ void Foam::ReactingMultiphaseCloud<CloudType>::evolve()
template<class CloudType>
void Foam::ReactingMultiphaseCloud<CloudType>::addToMassDevolatilisation
(
const scalar dMass
)
{
dMassDevolatilisation_ += dMass;
}
template<class CloudType>
void Foam::ReactingMultiphaseCloud<CloudType>::addToMassSurfaceReaction
(
const scalar dMass
)
{
dMassSurfaceReaction_ += dMass;
}
template<class CloudType>
void Foam::ReactingMultiphaseCloud<CloudType>::info() const
void Foam::ReactingMultiphaseCloud<CloudType>::info()
{
CloudType::info();
Info<< " Mass transfer devolatilisation = "
<< returnReduce(dMassDevolatilisation_, sumOp<scalar>()) << nl;
Info<< " Mass transfer surface reaction = "
<< returnReduce(dMassSurfaceReaction_, sumOp<scalar>()) << nl;
this->devolatilisation().info(Info);
this->surfaceReaction().info(Info);
}
......
......@@ -214,28 +214,33 @@ public:
// Sub-models
//- Return reference to devolatilisation model
//- Return const access to devolatilisation model
inline const DevolatilisationModel
<
ReactingMultiphaseCloud<CloudType>
>&
devolatilisation() const;
//- Return reference to reacting surface reaction model
//- Return reference to devolatilisation model
inline DevolatilisationModel
<
ReactingMultiphaseCloud<CloudType>
>&
devolatilisation();
//- Return const access to reacting surface reaction model
inline const SurfaceReactionModel
<
ReactingMultiphaseCloud<CloudType>
>&
surfaceReaction() const;
// Check
//- Add to cumulative volatilisation mass transfer
void addToMassDevolatilisation(const scalar dMass);
//- Add to cumulative surface reaction transfer
void addToMassSurfaceReaction(const scalar dMass);
//- Return reference to reacting surface reaction model
inline SurfaceReactionModel
<
ReactingMultiphaseCloud<CloudType>
>&
surfaceReaction();
// Cloud evolution functions
......@@ -267,12 +272,12 @@ public:
//- Evolve the cloud
void evolve();
//- Print cloud information
void info() const;
// I-O
//- Print cloud information
void info();
//- Write the field data for the cloud
virtual void writeFields() const;
};
......
......@@ -52,6 +52,17 @@ Foam::ReactingMultiphaseCloud<CloudType>::devolatilisation() const
}
template<class CloudType>
inline Foam::DevolatilisationModel
<
Foam::ReactingMultiphaseCloud<CloudType>
>&
Foam::ReactingMultiphaseCloud<CloudType>::devolatilisation()
{
return devolatilisationModel_();
}
template<class CloudType>
inline const Foam::SurfaceReactionModel
<
......@@ -63,4 +74,15 @@ Foam::ReactingMultiphaseCloud<CloudType>::surfaceReaction() const
}
template<class CloudType>
inline Foam::SurfaceReactionModel
<
Foam::ReactingMultiphaseCloud<CloudType>
>&
Foam::ReactingMultiphaseCloud<CloudType>::surfaceReaction()
{
return surfaceReactionModel_();
}
// ************************************************************************* //
......@@ -334,7 +334,7 @@ void Foam::ThermoCloud<CloudType>::evolve()
template<class CloudType>
void Foam::ThermoCloud<CloudType>::info() const
void Foam::ThermoCloud<CloudType>::info()
{
CloudType::info();
}
......
......@@ -321,7 +321,7 @@ public:
// Check
//- Print cloud information
void info() const;
void info();
};
......
......@@ -369,7 +369,7 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::calc
td.cloud().hsTrans()[cellI] += dm*HsEff(td, pc, T0, idG, idL, idS);
td.cloud().addToMassPhaseChange(dm);
td.cloud().phaseChange().addToPhaseChangeMass(dm);
}
return;
......@@ -520,7 +520,10 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::calcDevolatilisation
scalar dMassTot = sum(dMassDV);
td.cloud().addToMassDevolatilisation(this->nParticle_*dMassTot);
td.cloud().devolatilisation().addToDevolatilisationMass
(
this->nParticle_*dMassTot
);
Sh -= dMassTot*td.cloud().constProps().LDevol()/dt;
......@@ -608,7 +611,7 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::calcSurfaceReactions
dMassSRCarrier
);
td.cloud().addToMassSurfaceReaction
td.cloud().surfaceReaction().addToSurfaceReactionMass
(
this->nParticle_
*(sum(dMassSRGas) + sum(dMassSRLiquid) + sum(dMassSRSolid))
......
......@@ -385,7 +385,7 @@ void Foam::ReactingParcel<ParcelType>::calc
}
td.cloud().UTrans()[cellI] += dm*U0;
td.cloud().addToMassPhaseChange(dm);
td.cloud().phaseChange().addToPhaseChangeMass(dm);
}
return;
......@@ -519,7 +519,7 @@ void Foam::ReactingParcel<ParcelType>::calcPhaseChange
const scalar dMassTot = sum(dMassPC);
// Add to cumulative phase change mass
td.cloud().addToMassPhaseChange(this->nParticle_*dMassTot);
td.cloud().phaseChange().addToPhaseChangeMass(this->nParticle_*dMassTot);
forAll(dMassPC, i)
{
......
......@@ -51,7 +51,7 @@ Foam::CloudFunctionObject<CloudType>::CloudFunctionObject
const word& type
)
:
SubModelBase<CloudType>(owner, dict, type, "")
SubModelBase<CloudType>(owner, dict, typeName, type, "")
{}
......
......@@ -64,7 +64,7 @@ class CloudFunctionObject
public:
//- Runtime type information
TypeName("postProcessingModel");
TypeName("cloudFunctionObject");
//- Declare runtime constructor selection table
declareRunTimeSelectionTable
......
......@@ -42,7 +42,7 @@ Foam::CollisionModel<CloudType>::CollisionModel
const word& type
)
:
SubModelBase<CloudType>(owner, dict, type)
SubModelBase<CloudType>(owner, dict, typeName, type)
{}
......
......@@ -42,7 +42,7 @@ Foam::DispersionModel<CloudType>::DispersionModel
const word& type
)
:
SubModelBase<CloudType>(owner, dict, type)
SubModelBase<CloudType>(owner, dict, typeName, type)
{}
......
......@@ -31,76 +31,6 @@ using namespace Foam::constant::mathematical;
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
template<class CloudType>
void Foam::InjectionModel<CloudType>::readProps()
{
if (!this->owner().solution().transient())
{
return;
}
IOobject propsDictHeader
(
"injectionProperties",
this->owner().db().time().timeName(),
"uniform"/cloud::prefix/this->owner().name(),
this->owner().db(),
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
);
if (propsDictHeader.headerOk())
{
const IOdictionary propsDict(propsDictHeader);
propsDict.readIfPresent("massInjected", massInjected_);
propsDict.readIfPresent("nInjections", nInjections_);
propsDict.readIfPresent("parcelsAddedTotal", parcelsAddedTotal_);
propsDict.readIfPresent("timeStep0", timeStep0_);
}
}
template<class CloudType>
void Foam::InjectionModel<CloudType>::writeProps()
{
if (!this->owner().solution().transient())
{
return;
}
if (this->owner().db().time().outputTime())
{
IOdictionary propsDict
(
IOobject
(
"injectionProperties",
this->owner().db().time().timeName(),
"uniform"/cloud::prefix/this->owner().name(),
this->owner().db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
)
);
propsDict.add("massInjected", massInjected_);
propsDict.add("nInjections", nInjections_);
propsDict.add("parcelsAddedTotal", parcelsAddedTotal_);
propsDict.add("timeStep0", timeStep0_);
propsDict.writeObject
(
IOstream::ASCII,
IOstream::currentVersion,
this->owner().db().time().writeCompression()
);
}
}
template<class CloudType>
bool Foam::InjectionModel<CloudType>::validInjection(const label parcelI)
{
......@@ -328,9 +258,6 @@ void Foam::InjectionModel<CloudType>::postInjectCheck
// Increment number of injections
nInjections_++;
// Write current state to properties file
writeProps();
}
......@@ -343,16 +270,17 @@ Foam::InjectionModel<CloudType>::InjectionModel(CloudType& owner)
SOI_(0.0),
volumeTotal_(0.0),
massTotal_(0.0),
massInjected_(0.0),
nInjections_(0),
parcelsAddedTotal_(0),
massInjected_(this->template getBaseProperty<scalar>("massInjected")),
nInjections_(this->template getBaseProperty<scalar>("nInjections")),
parcelsAddedTotal_
(
this->template getBaseProperty<scalar>("parcelsAddedTotal")
),
parcelBasis_(pbNumber),
nParticleFixed_(0.0),
time0_(0.0),
timeStep0_(0.0)
{
readProps();
}
timeStep0_(this->template getBaseProperty<scalar>("timeStep0"))
{}
template<class CloudType>
......@@ -363,17 +291,20 @@ Foam::InjectionModel<CloudType>::InjectionModel
const word& type
)
:
SubModelBase<CloudType>(owner, dict, type),
SubModelBase<CloudType>(owner, dict, typeName, type),
SOI_(0.0),
volumeTotal_(0.0),
massTotal_(0.0),
massInjected_(0.0),