Commit 6748f10d authored by Andrew Heather's avatar Andrew Heather Committed by Mark OLESEN
Browse files

ENH: Lagrangian - added particle output to stream functions

parent deeb2789
......@@ -294,6 +294,18 @@ public:
);
// I-O
//- Write individual parcel properties to stream
void writeProperties
(
Ostream& os,
const wordRes& filters,
const word& delim,
const bool namesOnly = false
) const;
// Ostream Operator
friend Ostream& operator<<(Ostream& os, const DTRMParticle& p);
......
......@@ -88,6 +88,31 @@ Foam::DTRMParticle::DTRMParticle
}
void Foam::DTRMParticle::writeProperties
(
Ostream& os,
const wordRes& filters,
const word& delim,
const bool namesOnly
) const
{
particle::writeProperties(os, filters, delim, namesOnly);
#undef writeProp
#define writeProp(Name, Value) \
particle::writeProperty(os, Name, Value, namesOnly, delim, filters)
writeProp("p0", p0_);
writeProp("p1", p1_);
writeProp("I0", I0_);
writeProp("I", I_);
writeProp("dA", dA_);
writeProp("transmissiveId", transmissiveId_);
#undef writeProp
}
Foam::Ostream& Foam::operator<<(Ostream& os, const DTRMParticle& p)
{
if (os.format() == IOstream::ASCII)
......
......@@ -219,6 +219,15 @@ public:
//- Read fields
static void readFields(Cloud<injectedParticle>& c);
//- Write individual parcel properties to stream
void writeProperties
(
Ostream& os,
const wordRes& filters,
const word& delim,
const bool namesOnly
) const;
//- Write fields
static void writeFields(const Cloud<injectedParticle>& c);
......
......@@ -172,6 +172,29 @@ void Foam::injectedParticle::writeFields(const Cloud<injectedParticle>& c)
}
void Foam::injectedParticle::writeProperties
(
Ostream& os,
const wordRes& filters,
const word& delim,
const bool namesOnly
) const
{
particle::writeProperties(os, filters, delim, namesOnly);
#undef writeProp
#define writeProp(Name, Value) \
particle::writeProperty(os, Name, Value, namesOnly, delim, filters)
writeProp("tag", tag_);
writeProp("soi", soi_);
writeProp("d", d_);
writeProp("U", U_);
#undef writeProp
}
void Foam::injectedParticle::readObjects
(
Cloud<injectedParticle>& c,
......
......@@ -666,6 +666,41 @@ public:
// I-O
//- Write the name representation to stream
template<class Type>
static void writePropertyName
(
Ostream& os,
const word& name,
const word& delim
);
//- Write a named particle property to stream,
//- optionally filtered based on its name
template<class Type>
static void writeProperty
(
Ostream& os,
const word& name,
const Type& value,
const bool nameOnly,
const word& delim,
const wordRes& filters = wordRes::null()
);
//- Write a named particle property list to stream,
//- optionally filtered based on its name
template<class Type>
static void writeProperty
(
Ostream& os,
const word& name,
const Field<Type>& values,
const bool nameOnly,
const word& delim,
const wordRes& filters = wordRes::null()
);
//- Read the fields associated with the owner cloud
template<class TrackCloudType>
static void readFields(TrackCloudType& c);
......@@ -674,6 +709,15 @@ public:
template<class TrackCloudType>
static void writeFields(const TrackCloudType& c);
//- Write individual particle properties to stream
void writeProperties
(
Ostream& os,
const wordRes& filters,
const word& delim,
const bool namesOnly
) const;
//- Read particle fields as objects from the obr registry
template<class CloudType>
static void readObjects(CloudType& c, const objectRegistry& obr);
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2018 OpenCFD Ltd.
Copyright (C) 2016-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -193,6 +193,32 @@ Foam::particle::particle
}
void Foam::particle::writeProperties
(
Ostream& os,
const wordRes& filters,
const word& delim,
const bool namesOnly
) const
{
#undef writeProp
#define writeProp(Name, Value) \
particle::writeProperty(os, Name, Value, namesOnly, delim, filters)
writeProp("coordinates", coordinates_);
writeProp("position", position());
writeProp("celli", celli_);
writeProp("tetFacei", tetFacei_);
writeProp("tetPti", tetPti_);
writeProp("facei", facei_);
writeProp("stepFraction", stepFraction_);
writeProp("origProc", origProc_);
writeProp("origId", origId_);
#undef writeProp
}
void Foam::particle::writeCoordinates(Ostream& os) const
{
if (os.format() == IOstream::ASCII)
......
......@@ -40,6 +40,102 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::particle::writePropertyName
(
Ostream& os,
const word& name,
const word& delim
)
{
if (pTraits<Type>::nComponents == 1)
{
os << name;
}
else
{
os << '(';
for (int i = 0; i < pTraits<Type>::nComponents; ++i)
{
if (i) os << delim;
os << name << Foam::name(i);
}
os << ')';
}
}
template<class Type>
void Foam::particle::writeProperty
(
Ostream& os,
const word& name,
const Type& value,
const bool nameOnly,
const word& delim,
const wordRes& filters
)
{
if (!filters.empty() && !filters.match(name))
{
return;
}
os << delim;
if (nameOnly)
{
writePropertyName<Type>(os, name, delim);
}
else
{
os << value;
}
}
template<class Type>
void Foam::particle::writeProperty
(
Ostream& os,
const word& name,
const Field<Type>& values,
const bool nameOnly,
const word& delim,
const wordRes& filters
)
{
if (!filters.empty() && !filters.match(name))
{
return;
}
if (nameOnly)
{
os << delim;
os << "N(";
if (values.size())
{
forAll(values, i)
{
if (i) os << delim;
const word tag(name + Foam::name(i));
writePropertyName<Type>(os, tag, delim);
}
}
else
{
os << name;
}
os << ')';
}
else
{
os << delim << values;
}
}
template<class TrackCloudType>
void Foam::particle::readFields(TrackCloudType& c)
{
......
......@@ -323,6 +323,15 @@ public:
template<class CloudType>
static void writeFields(const CloudType& c);
//- Write individual parcel properties to stream
void writeProperties
(
Ostream& os,
const wordRes& filters,
const word& delim,
const bool namesOnly
) const;
//- Read particle fields as objects from the obr registry
template<class CloudType>
static void readObjects(CloudType& c, const objectRegistry& obr);
......
......@@ -291,6 +291,30 @@ void Foam::CollidingParcel<ParcelType>::writeFields(const CloudType& c)
}
template<class ParcelType>
void Foam::CollidingParcel<ParcelType>::writeProperties
(
Ostream& os,
const wordRes& filters,
const word& delim,
const bool namesOnly
) const
{
ParcelType::writeProperties(os, filters, delim, namesOnly);
#undef writeProp
#define writeProp(Name, Value) \
ParcelType::writeProperty(os, Name, Value, namesOnly, delim, filters)
writeProp("f", f_);
writeProp("angularMomentum", angularMomentum_);
writeProp("torque", torque_);
//writeProp("collisionRecords", collisionRecords_);
#undef writeProp
}
template<class ParcelType>
template<class CloudType>
void Foam::CollidingParcel<ParcelType>::readObjects
......
......@@ -659,6 +659,15 @@ public:
template<class TrackCloudType>
static void writeFields(const TrackCloudType& c);
//- Write individual parcel properties to stream
void writeProperties
(
Ostream& os,
const wordRes& filters,
const word& delim,
const bool namesOnly = false
) const;
//- Read particle fields as objects from the obr registry
template<class CloudType>
static void readObjects(CloudType& c, const objectRegistry& obr);
......
......@@ -266,6 +266,36 @@ void Foam::KinematicParcel<ParcelType>::writeFields(const CloudType& c)
}
template<class ParcelType>
void Foam::KinematicParcel<ParcelType>::writeProperties
(
Ostream& os,
const wordRes& filters,
const word& delim,
const bool namesOnly
) const
{
ParcelType::writeProperties(os, filters, delim, namesOnly);
#undef writeProp
#define writeProp(Name, Value) \
ParcelType::writeProperty(os, Name, Value, namesOnly, delim, filters)
writeProp("active", active_);
writeProp("typeId", typeId_);
writeProp("nParticle", nParticle_);
writeProp("d", d_);
writeProp("dTarget", dTarget_);
writeProp("U", U_);
writeProp("rho", rho_);
writeProp("age", age_);
writeProp("tTurb", tTurb_);
writeProp("UTurb", UTurb_);
#undef writeProp
}
template<class ParcelType>
template<class CloudType>
void Foam::KinematicParcel<ParcelType>::readObjects
......
......@@ -308,6 +308,15 @@ public:
template<class CloudType>
static void writeFields(const CloudType& c);
//- Write individual parcel properties to stream
void writeProperties
(
Ostream& os,
const wordRes& filters,
const word& delim,
const bool namesOnly = false
) const;
//- Read particle fields as objects from the obr registry
template<class CloudType>
static void readObjects(CloudType& c, const objectRegistry& obr);
......
......@@ -133,6 +133,27 @@ void Foam::MPPICParcel<ParcelType>::writeFields(const CloudType& c)
}
template<class ParcelType>
void Foam::MPPICParcel<ParcelType>::writeProperties
(
Ostream& os,
const wordRes& filters,
const word& delim,
const bool namesOnly
) const
{
ParcelType::writeProperties(os, filters, delim, namesOnly);
#undef writeProp
#define writeProp(Name, Value) \
ParcelType::writeProperty(os, Name, Value, namesOnly, delim, filters)
writeProp("UCorrect", UCorrect_);
#undef writeProp
}
template<class ParcelType>
template<class CloudType>
void Foam::MPPICParcel<ParcelType>::readObjects
......
......@@ -371,6 +371,15 @@ public:
template<class CloudType>
static void writeFields(const CloudType& c);
//- Write individual parcel properties to stream
void writeProperties
(
Ostream& os,
const wordRes& filters,
const word& delim,
const bool namesOnly
) const;
//- Read particle fields as objects from the obr registry
// - no composition
template<class CloudType>
......
......@@ -251,6 +251,28 @@ void Foam::ReactingHeterogeneousParcel<ParcelType>::writeFields
}
template<class ParcelType>
void Foam::ReactingHeterogeneousParcel<ParcelType>::writeProperties
(
Ostream& os,
const wordRes& filters,
const word& delim,
const bool namesOnly
) const
{
ParcelType::writeProperties(os, filters, delim, namesOnly);
#undef writeProp
#define writeProp(Name, Value) \
ParcelType::writeProperty(os, Name, Value, namesOnly, delim, filters)
writeProp("F", F_);
writeProp("canCombust", canCombust_);
#undef writeProp
}
template<class ParcelType>
template<class CloudType>
void Foam::ReactingHeterogeneousParcel<ParcelType>::readObjects
......
......@@ -462,6 +462,15 @@ public:
template<class CloudType>
static void writeFields(const CloudType& c);
//- Write individual parcel properties to stream
void writeProperties
(
Ostream& os,
const wordRes& filters,
const word& delim,
const bool namesOnly = false
) const;
//- Read particle fields as objects from the obr registry
// - no composition
template<class CloudType>
......
......@@ -282,6 +282,30 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::writeFields
}
template<class ParcelType>
void Foam::ReactingMultiphaseParcel<ParcelType>::writeProperties
(
Ostream& os,
const wordRes& filters,
const word& delim,
const bool namesOnly
) const
{
ParcelType::writeProperties(os, filters, delim, namesOnly);
#undef writeProp
#define writeProp(Name, Value) \
ParcelType::writeProperty(os, Name, Value, namesOnly, delim, filters)
writeProp("YGas", YGas_);
writeProp("YLiquid", YLiquid_);
writeProp("YSolid", YSolid_);
writeProp("canCombust", canCombust_);
#undef writeProp
}
template<class ParcelType>
template<class CloudType>
void Foam::ReactingMultiphaseParcel<ParcelType>::readObjects
......
......@@ -414,6 +414,14 @@ public:
template<class CloudType>
static void writeFields(const CloudType& c);
//- Write individual parcel properties to stream
void writeProperties
(
Ostream& os,
const wordRes& filters,
const word& delim,
const bool namesOnly = false
) const;
//- Read particle fields as objects from the obr registry
// - no composition
......
......@@ -231,6 +231,28 @@ void Foam::ReactingParcel<ParcelType>::writeFields
}
template<class ParcelType>
void Foam::ReactingParcel<ParcelType>::writeProperties
(
Ostream& os,
const wordRes& filters,
const word& delim,
const bool namesOnly
) const
{
ParcelType::writeProperties(os, filters, delim, namesOnly);
#undef writeProp
#define writeProp(Name, Value) \
ParcelType::writeProperty(os, Name, Value, namesOnly, delim, filters)
writeProp("mass0", mass0_);