lagrangian: Improved handling of binary transfers

Now using memory offsets to calculate transfer block sizes rather than
sum of 'sizeof' to ensure word alignment is accounted for
This commit is contained in:
Henry
2015-02-22 12:14:46 +00:00
parent 5daf22d9d7
commit cf07fdc957
26 changed files with 286 additions and 455 deletions

View File

@ -41,7 +41,6 @@ SourceFiles
#include "IOstream.H" #include "IOstream.H"
#include "autoPtr.H" #include "autoPtr.H"
#include "contiguous.H" #include "contiguous.H"
#include "DSMCCloud.H" #include "DSMCCloud.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -70,6 +69,12 @@ class DSMCParcel
: :
public ParcelType public ParcelType
{ {
// Private member data
//- Size in bytes of the fields
static const std::size_t sizeofFields_;
public: public:
//- Class to hold DSMC particle constant properties //- Class to hold DSMC particle constant properties
@ -92,7 +97,7 @@ public:
public: public:
// Constrcutors // Constructors
//- Null constructor, allows List of constantProperties to be //- Null constructor, allows List of constantProperties to be
// created before the contents is initialised // created before the contents is initialised
@ -104,10 +109,10 @@ public:
// Member functions // Member functions
//- Return const access to the particle density //- Return const access to the particle mass [kg]
inline scalar mass() const; inline scalar mass() const;
//- Return const access to the minimum particle mass //- Return const access to the hard sphere diameter [m]
inline scalar d() const; inline scalar d() const;
//- Return the reference total collision cross section //- Return the reference total collision cross section
@ -196,7 +201,6 @@ public:
return autoPtr<particle>(new DSMCParcel<ParcelType>(*this)); return autoPtr<particle>(new DSMCParcel<ParcelType>(*this));
} }
//- Factory class to read-construct particles used for //- Factory class to read-construct particles used for
// parallel transfer // parallel transfer
class iNew class iNew
@ -233,6 +237,7 @@ public:
//- Return const access to internal energy //- Return const access to internal energy
inline scalar Ei() const; inline scalar Ei() const;
// Edit // Edit
//- Return access to velocity //- Return access to velocity

View File

@ -28,6 +28,15 @@ License
#include "IOField.H" #include "IOField.H"
#include "Cloud.H" #include "Cloud.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<class ParcelType>
const std::size_t Foam::DSMCParcel<ParcelType>::sizeofFields_
(
sizeof(DSMCParcel<ParcelType>) - sizeof(ParcelType)
);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class ParcelType> template<class ParcelType>
@ -53,13 +62,7 @@ Foam::DSMCParcel<ParcelType>::DSMCParcel
} }
else else
{ {
is.read is.read(reinterpret_cast<char*>(&U_), sizeofFields_);
(
reinterpret_cast<char*>(&U_),
sizeof(U_)
+ sizeof(Ei_)
+ sizeof(typeId_)
);
} }
} }
@ -157,9 +160,7 @@ Foam::Ostream& Foam::operator<<
os.write os.write
( (
reinterpret_cast<const char*>(&p.U_), reinterpret_cast<const char*>(&p.U_),
sizeof(p.U()) DSMCParcel<ParcelType>::sizeofFields_
+ sizeof(p.Ei())
+ sizeof(p.typeId())
); );
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -68,11 +68,7 @@ bool Foam::IOPosition<CloudType>::writeData(Ostream& os) const
forAllConstIter(typename CloudType, cloud_, iter) forAllConstIter(typename CloudType, cloud_, iter)
{ {
const typename CloudType::particleType& p = iter(); iter().writePosition(os);
// Prevent writing additional fields
p.write(os, false);
os << nl; os << nl;
} }
@ -100,7 +96,7 @@ void Foam::IOPosition<CloudType>::readData(CloudType& c, bool checkClass)
for (label i=0; i<s; i++) for (label i=0; i<s; i++)
{ {
// Do not read any fields, position only // Read position only
c.append(new typename CloudType::particleType(mesh, is, false)); c.append(new typename CloudType::particleType(mesh, is, false));
} }
@ -129,7 +125,8 @@ void Foam::IOPosition<CloudType>::readData(CloudType& c, bool checkClass)
) )
{ {
is.putBack(lastToken); is.putBack(lastToken);
// Do not read any fields, position only
// Write position only
c.append(new typename CloudType::particleType(mesh, is, false)); c.append(new typename CloudType::particleType(mesh, is, false));
is >> lastToken; is >> lastToken;
} }

View File

@ -80,6 +80,15 @@ class particle
: :
public IDLList<particle>::link public IDLList<particle>::link
{ {
// Private member data
//- Size in bytes of the position data
static const std::size_t sizeofPosition_;
//- Size in bytes of the fields
static const std::size_t sizeofFields_;
public: public:
template<class CloudType> template<class CloudType>
@ -358,7 +367,6 @@ public:
return autoPtr<particle>(new particle(*this)); return autoPtr<particle>(new particle(*this));
} }
//- Factory class to read-construct particles used for //- Factory class to read-construct particles used for
// parallel transfer // parallel transfer
class iNew class iNew
@ -556,8 +564,8 @@ public:
template<class CloudType> template<class CloudType>
static void writeFields(const CloudType& c); static void writeFields(const CloudType& c);
//- Write the particle data //- Write the particle position and cell
void write(Ostream& os, bool writeFields) const; void writePosition(Ostream&) const;
// Friend Operators // Friend Operators

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -25,12 +25,21 @@ License
#include "particle.H" #include "particle.H"
#include "IOstreams.H" #include "IOstreams.H"
#include "IOPosition.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
Foam::string Foam::particle::propertyList_ = Foam::particle::propertyList(); Foam::string Foam::particle::propertyList_ = Foam::particle::propertyList();
const std::size_t Foam::particle::sizeofPosition_
(
offsetof(particle, faceI_) - offsetof(particle, position_)
);
const std::size_t Foam::particle::sizeofFields_
(
sizeof(particle) - offsetof(particle, position_)
);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -46,45 +55,29 @@ Foam::particle::particle(const polyMesh& mesh, Istream& is, bool readFields)
origProc_(Pstream::myProcNo()), origProc_(Pstream::myProcNo()),
origId_(-1) origId_(-1)
{ {
// readFields : read additional data. Should be consistent with writeFields.
if (is.format() == IOstream::ASCII) if (is.format() == IOstream::ASCII)
{ {
is >> position_ >> cellI_; is >> position_ >> cellI_;
if (readFields) if (readFields)
{ {
is >> tetFaceI_ >> tetPtI_ >> origProc_ >> origId_; is >> faceI_
>> stepFraction_
>> tetFaceI_
>> tetPtI_
>> origProc_
>> origId_;
} }
} }
else else
{ {
// In binary read all particle data - needed for parallel transfer
if (readFields) if (readFields)
{ {
is.read is.read(reinterpret_cast<char*>(&position_), sizeofFields_);
(
reinterpret_cast<char*>(&position_),
sizeof(position_)
+ sizeof(cellI_)
+ sizeof(faceI_)
+ sizeof(stepFraction_)
+ sizeof(tetFaceI_)
+ sizeof(tetPtI_)
+ sizeof(origProc_)
+ sizeof(origId_)
);
} }
else else
{ {
is.read is.read(reinterpret_cast<char*>(&position_), sizeofPosition_);
(
reinterpret_cast<char*>(&position_),
sizeof(position_)
+ sizeof(cellI_)
+ sizeof(faceI_)
+ sizeof(stepFraction_)
);
} }
} }
@ -93,66 +86,43 @@ Foam::particle::particle(const polyMesh& mesh, Istream& is, bool readFields)
} }
void Foam::particle::write(Ostream& os, bool writeFields) const void Foam::particle::writePosition(Ostream& os) const
{ {
if (os.format() == IOstream::ASCII) if (os.format() == IOstream::ASCII)
{ {
if (writeFields) os << position_ << token::SPACE << cellI_;
{
// Write the additional entries
os << position_
<< token::SPACE << cellI_
<< token::SPACE << tetFaceI_
<< token::SPACE << tetPtI_
<< token::SPACE << origProc_
<< token::SPACE << origId_;
} }
else else
{ {
os << position_ os.write(reinterpret_cast<const char*>(&position_), sizeofPosition_);
<< token::SPACE << cellI_;
}
}
else
{
// In binary write both cellI_ and faceI_, needed for parallel transfer
if (writeFields)
{
os.write
(
reinterpret_cast<const char*>(&position_),
sizeof(position_)
+ sizeof(cellI_)
+ sizeof(faceI_)
+ sizeof(stepFraction_)
+ sizeof(tetFaceI_)
+ sizeof(tetPtI_)
+ sizeof(origProc_)
+ sizeof(origId_)
);
}
else
{
os.write
(
reinterpret_cast<const char*>(&position_),
sizeof(position_)
+ sizeof(cellI_)
+ sizeof(faceI_)
+ sizeof(stepFraction_)
);
}
} }
// Check state of Ostream // Check state of Ostream
os.check("particle::write(Ostream& os, bool) const"); os.check("particle::writePosition(Ostream& os, bool) const");
} }
Foam::Ostream& Foam::operator<<(Ostream& os, const particle& p) Foam::Ostream& Foam::operator<<(Ostream& os, const particle& p)
{ {
// Write all data if (os.format() == IOstream::ASCII)
p.write(os, true); {
os << p.position_
<< token::SPACE << p.cellI_
<< token::SPACE << p.faceI_
<< token::SPACE << p.stepFraction_
<< token::SPACE << p.tetFaceI_
<< token::SPACE << p.tetPtI_
<< token::SPACE << p.origProc_
<< token::SPACE << p.origId_;
}
else
{
os.write
(
reinterpret_cast<const char*>(&p.position_),
particle::sizeofFields_
);
}
return os; return os;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -38,12 +38,10 @@ SourceFiles
#define CollidingParcel_H #define CollidingParcel_H
#include "particle.H" #include "particle.H"
#include "CollisionRecordList.H" #include "CollisionRecordList.H"
#include "labelFieldIOField.H" #include "labelFieldIOField.H"
#include "vectorFieldIOField.H" #include "vectorFieldIOField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
@ -74,6 +72,12 @@ class CollidingParcel
: :
public ParcelType public ParcelType
{ {
// Private member data
//- Size in bytes of the fields
static const std::size_t sizeofFields_;
public: public:
//- Class to hold thermo particle constant properties //- Class to hold thermo particle constant properties

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -33,6 +33,13 @@ template<class ParcelType>
Foam::string Foam::CollidingParcel<ParcelType>::propertyList_ = Foam::string Foam::CollidingParcel<ParcelType>::propertyList_ =
Foam::CollidingParcel<ParcelType>::propertyList(); Foam::CollidingParcel<ParcelType>::propertyList();
template<class ParcelType>
const std::size_t Foam::CollidingParcel<ParcelType>::sizeofFields_
(
offsetof(CollidingParcel<ParcelType>, collisionRecords_)
- offsetof(CollidingParcel<ParcelType>, f_)
);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -60,13 +67,7 @@ Foam::CollidingParcel<ParcelType>::CollidingParcel
} }
else else
{ {
is.read is.read(reinterpret_cast<char*>(&f_), sizeofFields_);
(
reinterpret_cast<char*>(&f_),
+ sizeof(f_)
+ sizeof(angularMomentum_)
+ sizeof(torque_)
);
} }
is >> collisionRecords_; is >> collisionRecords_;
@ -285,10 +286,10 @@ Foam::Ostream& Foam::operator<<
if (os.format() == IOstream::ASCII) if (os.format() == IOstream::ASCII)
{ {
os << static_cast<const ParcelType&>(p) os << static_cast<const ParcelType&>(p)
<< token::SPACE << p.f() << token::SPACE << p.f_
<< token::SPACE << p.angularMomentum() << token::SPACE << p.angularMomentum_
<< token::SPACE << p.torque() << token::SPACE << p.torque_
<< token::SPACE << p.collisionRecords(); << token::SPACE << p.collisionRecords_;
} }
else else
{ {
@ -296,9 +297,7 @@ Foam::Ostream& Foam::operator<<
os.write os.write
( (
reinterpret_cast<const char*>(&p.f_), reinterpret_cast<const char*>(&p.f_),
+ sizeof(p.f()) CollidingParcel<ParcelType>::sizeofFields_
+ sizeof(p.angularMomentum())
+ sizeof(p.torque())
); );
os << p.collisionRecords(); os << p.collisionRecords();
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -78,6 +78,15 @@ class KinematicParcel
: :
public ParcelType public ParcelType
{ {
// Private data
//- Size in bytes of the fields
static const std::size_t sizeofFields_;
//- Number of particle tracking attempts before we assume that it stalls
static label maxTrackAttempts;
public: public:
//- Class to hold kinematic particle constant properties //- Class to hold kinematic particle constant properties
@ -137,7 +146,7 @@ public:
//- Return const access to the particle density //- Return const access to the particle density
inline scalar rho0() const; inline scalar rho0() const;
//- Return const access to the minimum particle mass //- Return const access to the minimum parcel mass
inline scalar minParcelMass() const; inline scalar minParcelMass() const;
}; };
@ -218,10 +227,6 @@ public:
}; };
//- Number of particle tracking attempts before we assume that it stalls
static label maxTrackAttempts;
protected: protected:
// Protected data // Protected data

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -34,6 +34,14 @@ template<class ParcelType>
Foam::string Foam::KinematicParcel<ParcelType>::propertyList_ = Foam::string Foam::KinematicParcel<ParcelType>::propertyList_ =
Foam::KinematicParcel<ParcelType>::propertyList(); Foam::KinematicParcel<ParcelType>::propertyList();
template<class ParcelType>
const std::size_t Foam::KinematicParcel<ParcelType>::sizeofFields_
(
offsetof(KinematicParcel<ParcelType>, rhoc_)
- offsetof(KinematicParcel<ParcelType>, active_)
);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class ParcelType> template<class ParcelType>
@ -76,8 +84,7 @@ Foam::KinematicParcel<ParcelType>::KinematicParcel
} }
else else
{ {
label size = long(&UTurb_) - long(&active_) + sizeof(UTurb_); is.read(reinterpret_cast<char*>(&active_), sizeofFields_);
is.read(reinterpret_cast<char*>(&active_), size);
} }
} }
@ -236,9 +243,11 @@ Foam::Ostream& Foam::operator<<
else else
{ {
os << static_cast<const ParcelType&>(p); os << static_cast<const ParcelType&>(p);
os.write
label size = long(&p.UTurb_) - long(&p.active_) + sizeof(p.UTurb_); (
os.write(reinterpret_cast<const char*>(&p.active_), size); reinterpret_cast<const char*>(&p.active_),
KinematicParcel<ParcelType>::sizeofFields_
);
} }
// Check state of Ostream // Check state of Ostream

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -73,6 +73,12 @@ class MPPICParcel
: :
public ParcelType public ParcelType
{ {
// Private data
//- Size in bytes of the fields
static const std::size_t sizeofFields_;
public: public:
template<class CloudType> template<class CloudType>

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -33,6 +33,12 @@ template<class ParcelType>
Foam::string Foam::MPPICParcel<ParcelType>::propertyList_ = Foam::string Foam::MPPICParcel<ParcelType>::propertyList_ =
Foam::MPPICParcel<ParcelType>::propertyList(); Foam::MPPICParcel<ParcelType>::propertyList();
template<class ParcelType>
const std::size_t Foam::MPPICParcel<ParcelType>::sizeofFields_
(
sizeof(MPPICParcel<ParcelType>) - sizeof(ParcelType)
);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -55,11 +61,7 @@ Foam::MPPICParcel<ParcelType>::MPPICParcel
} }
else else
{ {
is.read is.read(reinterpret_cast<char*>(&UCorrect_), sizeofFields_);
(
reinterpret_cast<char*>(&UCorrect_),
+ sizeof(UCorrect_)
);
} }
} }
@ -144,7 +146,7 @@ Foam::Ostream& Foam::operator<<
os.write os.write
( (
reinterpret_cast<const char*>(&p.UCorrect_), reinterpret_cast<const char*>(&p.UCorrect_),
+ sizeof(p.UCorrect()) MPPICParcel<ParcelType>::sizeofFields_
); );
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -66,6 +66,12 @@ class ReactingMultiphaseParcel
: :
public ParcelType public ParcelType
{ {
// Private data
//- Size in bytes of the fields
static const std::size_t sizeofFields_;
public: public:
// IDs of phases in ReacingParcel phase list (Y) // IDs of phases in ReacingParcel phase list (Y)

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -32,6 +32,12 @@ template<class ParcelType>
Foam::string Foam::ReactingMultiphaseParcel<ParcelType>::propertyList_ = Foam::string Foam::ReactingMultiphaseParcel<ParcelType>::propertyList_ =
Foam::ReactingMultiphaseParcel<ParcelType>::propertyList(); Foam::ReactingMultiphaseParcel<ParcelType>::propertyList();
template<class ParcelType>
const std::size_t Foam::ReactingMultiphaseParcel<ParcelType>::sizeofFields_
(
0
);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -57,6 +57,7 @@ Ostream& operator<<
const ReactingParcel<ParcelType>& const ReactingParcel<ParcelType>&
); );
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class ReactingParcel Declaration Class ReactingParcel Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -66,9 +67,15 @@ class ReactingParcel
: :
public ParcelType public ParcelType
{ {
// Private data
//- Size in bytes of the fields
static const std::size_t sizeofFields_;
public: public:
//- Class to hold reacting particle constant properties //- Class to hold reacting parcel constant properties
class constantProperties class constantProperties
: :
public ParcelType::constantProperties public ParcelType::constantProperties
@ -151,7 +158,7 @@ protected:
// Parcel properties // Parcel properties
//- Initial particle mass [kg] //- Initial mass [kg]
scalar mass0_; scalar mass0_;
//- Mass fractions of mixture [] //- Mass fractions of mixture []
@ -183,9 +190,9 @@ protected:
const label idPhase, // id of phase involved in phase change const label idPhase, // id of phase involved in phase change
const scalar YPhase, // total mass fraction const scalar YPhase, // total mass fraction
const scalarField& YComponents, // component mass fractions const scalarField& YComponents, // component mass fractions
scalarField& dMassPC, // mass transfer - local to particle scalarField& dMassPC, // mass transfer - local to parcel
scalar& Sh, // explicit particle enthalpy source scalar& Sh, // explicit parcel enthalpy source
scalar& N, // flux of species emitted from particle scalar& N, // flux of species emitted from parcel
scalar& NCpW, // sum of N*Cp*W of emission species scalar& NCpW, // sum of N*Cp*W of emission species
scalarField& Cs // carrier conc. of emission species scalarField& Cs // carrier conc. of emission species
); );
@ -308,7 +315,7 @@ public:
// Access // Access
//- Return const access to initial particle mass [kg] //- Return const access to initial mass [kg]
inline scalar mass0() const; inline scalar mass0() const;
//- Return const access to mass fractions of mixture [] //- Return const access to mass fractions of mixture []
@ -323,7 +330,7 @@ public:
// Edit // Edit
//- Return access to initial particle mass [kg] //- Return access to initial mass [kg]
inline scalar& mass0(); inline scalar& mass0();
//- Return access to mass fractions of mixture [] //- Return access to mass fractions of mixture []

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -32,6 +32,12 @@ template<class ParcelType>
Foam::string Foam::ReactingParcel<ParcelType>::propertyList_ = Foam::string Foam::ReactingParcel<ParcelType>::propertyList_ =
Foam::ReactingParcel<ParcelType>::propertyList(); Foam::ReactingParcel<ParcelType>::propertyList();
template<class ParcelType>
const std::size_t Foam::ReactingParcel<ParcelType>::sizeofFields_
(
sizeof(scalar)
);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -58,11 +64,7 @@ Foam::ReactingParcel<ParcelType>::ReactingParcel
} }
else else
{ {
is.read is.read(reinterpret_cast<char*>(&mass0_), sizeofFields_);
(
reinterpret_cast<char*>(&mass0_),
+ sizeof(mass0_)
);
is >> Ymix; is >> Ymix;
} }
@ -249,7 +251,7 @@ Foam::Ostream& Foam::operator<<
os.write os.write
( (
reinterpret_cast<const char*>(&p.mass0_), reinterpret_cast<const char*>(&p.mass0_),
sizeof(p.mass0()) ReactingParcel<ParcelType>::sizeofFields_
); );
os << p.Y(); os << p.Y();
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -67,6 +67,12 @@ class ThermoParcel
: :
public ParcelType public ParcelType
{ {
// Private data
//- Size in bytes of the fields
static const std::size_t sizeofFields_;
public: public:
//- Class to hold thermo particle constant properties //- Class to hold thermo particle constant properties

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -32,6 +32,13 @@ template<class ParcelType>
Foam::string Foam::ThermoParcel<ParcelType>::propertyList_ = Foam::string Foam::ThermoParcel<ParcelType>::propertyList_ =
Foam::ThermoParcel<ParcelType>::propertyList(); Foam::ThermoParcel<ParcelType>::propertyList();
template<class ParcelType>
const std::size_t Foam::ThermoParcel<ParcelType>::sizeofFields_
(
offsetof(ThermoParcel<ParcelType>, Tc_)
- offsetof(ThermoParcel<ParcelType>, T_)
);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -58,8 +65,7 @@ Foam::ThermoParcel<ParcelType>::ThermoParcel
} }
else else
{ {
label size = long(&Cp_) - long(&T_) + sizeof(Cp_); is.read(reinterpret_cast<char*>(&T_), sizeofFields_);
is.read(reinterpret_cast<char*>(&T_), size);
} }
} }
@ -145,9 +151,11 @@ Foam::Ostream& Foam::operator<<
else else
{ {
os << static_cast<const ParcelType&>(p); os << static_cast<const ParcelType&>(p);
os.write
label size = long(&p.Cp_) - long(&p.T_) + sizeof(p.Cp_); (
os.write(reinterpret_cast<const char*>(&p.T_), size); reinterpret_cast<const char*>(&p.T_),
ThermoParcel<ParcelType>::sizeofFields_
);
} }
// Check state of Ostream // Check state of Ostream

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -58,6 +58,11 @@ class molecule
: :
public particle public particle
{ {
// Private data
//- Size in bytes of the fields
static const std::size_t sizeofFields_;
public: public:

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -27,6 +27,14 @@ License
#include "IOstreams.H" #include "IOstreams.H"
#include "moleculeCloud.H" #include "moleculeCloud.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const std::size_t Foam::molecule::sizeofFields_
(
offsetof(molecule, siteForces_) - offsetof(molecule, Q_)
);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::molecule::molecule Foam::molecule::molecule
@ -59,31 +67,17 @@ Foam::molecule::molecule
is >> a_; is >> a_;
is >> pi_; is >> pi_;
is >> tau_; is >> tau_;
is >> siteForces_; is >> specialPosition_;
potentialEnergy_ = readScalar(is); potentialEnergy_ = readScalar(is);
is >> rf_; is >> rf_;
special_ = readLabel(is); special_ = readLabel(is);
id_ = readLabel(is); id_ = readLabel(is);
is >> siteForces_;
is >> sitePositions_; is >> sitePositions_;
is >> specialPosition_;
} }
else else
{ {
is.read is.read(reinterpret_cast<char*>(&Q_), sizeofFields_);
(
reinterpret_cast<char*>(&Q_),
sizeof(Q_)
+ sizeof(v_)
+ sizeof(a_)
+ sizeof(pi_)
+ sizeof(tau_)
+ sizeof(specialPosition_)
+ sizeof(potentialEnergy_)
+ sizeof(rf_)
+ sizeof(special_)
+ sizeof(id_)
);
is >> siteForces_ >> sitePositions_; is >> siteForces_ >> sitePositions_;
} }
} }
@ -263,8 +257,6 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const molecule& mol)
if (os.format() == IOstream::ASCII) if (os.format() == IOstream::ASCII)
{ {
os << token::SPACE << static_cast<const particle&>(mol) os << token::SPACE << static_cast<const particle&>(mol)
<< token::SPACE << mol.face()
<< token::SPACE << mol.stepFraction()
<< token::SPACE << mol.Q_ << token::SPACE << mol.Q_
<< token::SPACE << mol.v_ << token::SPACE << mol.v_
<< token::SPACE << mol.a_ << token::SPACE << mol.a_
@ -284,16 +276,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const molecule& mol)
os.write os.write
( (
reinterpret_cast<const char*>(&mol.Q_), reinterpret_cast<const char*>(&mol.Q_),
sizeof(mol.Q_) molecule::sizeofFields_
+ sizeof(mol.v_)
+ sizeof(mol.a_)
+ sizeof(mol.pi_)
+ sizeof(mol.tau_)
+ sizeof(mol.specialPosition_)
+ sizeof(mol.potentialEnergy_)
+ sizeof(mol.rf_)
+ sizeof(mol.special_)
+ sizeof(mol.id_)
); );
os << mol.siteForces_ << mol.sitePositions_; os << mol.siteForces_ << mol.sitePositions_;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -59,7 +59,10 @@ class solidParticle
: :
public particle public particle
{ {
// Private member data // Private data
//- Size in bytes of the fields
static const std::size_t sizeofFields_;
//- Diameter //- Diameter
scalar d_; scalar d_;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -26,6 +26,14 @@ License
#include "solidParticle.H" #include "solidParticle.H"
#include "IOstreams.H" #include "IOstreams.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const std::size_t Foam::solidParticle::sizeofFields_
(
sizeof(solidParticle) - sizeof(particle)
);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::solidParticle::solidParticle Foam::solidParticle::solidParticle
@ -46,11 +54,7 @@ Foam::solidParticle::solidParticle
} }
else else
{ {
is.read is.read(reinterpret_cast<char*>(&d_), sizeofFields_);
(
reinterpret_cast<char*>(&d_),
sizeof(d_) + sizeof(U_)
);
} }
} }
@ -126,7 +130,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const solidParticle& p)
os.write os.write
( (
reinterpret_cast<const char*>(&p.d_), reinterpret_cast<const char*>(&p.d_),
sizeof(p.d_) + sizeof(p.U_) solidParticle::sizeofFields_
); );
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -59,6 +59,11 @@ class SprayParcel
: :
public ParcelType public ParcelType
{ {
// Private data
//- Size in bytes of the fields
static const std::size_t sizeofFields_;
public: public:
@ -173,9 +178,6 @@ public:
// Static data members // Static data members
//- String representation of properties
static string propHeader;
//- Runtime type information //- Runtime type information
TypeName("SprayParcel"); TypeName("SprayParcel");

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -29,21 +29,10 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<class ParcelType> template<class ParcelType>
Foam::string Foam::SprayParcel<ParcelType>::propHeader = const std::size_t Foam::SprayParcel<ParcelType>::sizeofFields_
ParcelType::propHeader (
+ " d0" sizeof(SprayParcel<ParcelType>) - sizeof(ParcelType)
+ " position0" );
+ " sigma"
+ " mu"
+ " liquidCore"
+ " KHindex"
+ " y"
+ " yDot"
+ " tc"
+ " ms"
+ " injector"
+ " tMom"
+ " user";
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -73,7 +62,6 @@ Foam::SprayParcel<ParcelType>::SprayParcel
{ {
if (readFields) if (readFields)
{ {
if (is.format() == IOstream::ASCII) if (is.format() == IOstream::ASCII)
{ {
d0_ = readScalar(is); d0_ = readScalar(is);
@ -92,23 +80,7 @@ Foam::SprayParcel<ParcelType>::SprayParcel
} }
else else
{ {
is.read is.read(reinterpret_cast<char*>(&d0_), sizeofFields_);
(
reinterpret_cast<char*>(&d0_),
sizeof(d0_)
+ sizeof(position0_)
+ sizeof(sigma_)
+ sizeof(mu_)
+ sizeof(liquidCore_)
+ sizeof(KHindex_)
+ sizeof(y_)
+ sizeof(yDot_)
+ sizeof(tc_)
+ sizeof(ms_)
+ sizeof(injector_)
+ sizeof(tMom_)
+ sizeof(user_)
);
} }
} }
@ -334,19 +306,7 @@ Foam::Ostream& Foam::operator<<
os.write os.write
( (
reinterpret_cast<const char*>(&p.d0_), reinterpret_cast<const char*>(&p.d0_),
sizeof(p.d0()) SprayParcel<ParcelType>::sizeofFields_
+ sizeof(p.position0())
+ sizeof(p.sigma())
+ sizeof(p.mu())
+ sizeof(p.liquidCore())
+ sizeof(p.KHindex())
+ sizeof(p.y())
+ sizeof(p.yDot())
+ sizeof(p.tc())
+ sizeof(p.ms())
+ sizeof(p.injector())
+ sizeof(p.tMom())
+ sizeof(p.user())
); );
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -24,88 +24,23 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "wallBoundedParticle.H" #include "wallBoundedParticle.H"
#include "vectorFieldIOField.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam const std::size_t Foam::wallBoundedParticle::sizeofFields_
{ (
// defineParticleTypeNameAndDebug(wallBoundedParticle, 0); sizeof(wallBoundedParticle) - sizeof(particle)
} );
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
//// Check position is inside tet
//void Foam::wallBoundedParticle::checkInside() const
//{
// const tetIndices ti(currentTetIndices());
// const tetPointRef tpr(ti.tet(mesh_));
// if (!tpr.inside(position()))
// {
// FatalErrorIn("wallBoundedParticle::checkInside(..)")
// << "Particle:" //<< static_cast<const particle&>(*this)
// << info()
// << "is not inside " << tpr
// << abort(FatalError);
// }
//}
//
//
//void Foam::wallBoundedParticle::checkOnEdge() const
//{
// // Check that edge (as indicated by meshEdgeStart_, diagEdge_) is
// // indeed one that contains the position.
// const edge e = currentEdge();
//
// linePointRef ln(e.line(mesh_.points()));
//
// pointHit ph(ln.nearestDist(position()));
//
// if (ph.distance() > 1e-6)
// {
// FatalErrorIn
// (
// "wallBoundedParticle::checkOnEdge()"
// ) << "Problem :"
// << " particle:" //<< static_cast<const particle&>(*this)
// << info()
// << "edge:" << e
// << " at:" << ln
// << " distance:" << ph.distance()
// << abort(FatalError);
// }
//}
//
//
//void Foam::wallBoundedParticle::checkOnTriangle(const point& p)
//const
//{
// const triFace tri(currentTetIndices().faceTriIs(mesh_));
// pointHit ph = tri.nearestPoint(p, mesh_.points());
// if (ph.distance() > 1e-9)
// {
// FatalErrorIn
// (
// "wallBoundedParticle::checkOnTriangle(const point&)"
// ) << "Problem :"
// << " particle:" //<< static_cast<const particle&>(*this)
// << info()
// << "point:" << p
// << " distance:" << ph.distance()
// << abort(FatalError);
// }
//}
// Construct the edge the particle is on (according to meshEdgeStart_,
// diagEdge_)
Foam::edge Foam::wallBoundedParticle::currentEdge() const Foam::edge Foam::wallBoundedParticle::currentEdge() const
{ {
if ((meshEdgeStart_ != -1) == (diagEdge_ != -1)) if ((meshEdgeStart_ != -1) == (diagEdge_ != -1))
{ {
FatalErrorIn("wallBoundedParticle::currentEdge() const") FatalErrorIn("wallBoundedParticle::currentEdge() const")
<< "Particle:" //<< static_cast<const particle&>(*this) << "Particle:"
<< info() << info()
<< "cannot both be on a mesh edge and a face-diagonal edge." << "cannot both be on a mesh edge and a face-diagonal edge."
<< " meshEdgeStart_:" << meshEdgeStart_ << " meshEdgeStart_:" << meshEdgeStart_
@ -123,6 +58,7 @@ Foam::edge Foam::wallBoundedParticle::currentEdge() const
{ {
label faceBasePtI = mesh_.tetBasePtIs()[tetFace()]; label faceBasePtI = mesh_.tetBasePtIs()[tetFace()];
label diagPtI = (faceBasePtI+diagEdge_)%f.size(); label diagPtI = (faceBasePtI+diagEdge_)%f.size();
return edge(f[faceBasePtI], f[diagPtI]); return edge(f[faceBasePtI], f[diagPtI]);
} }
} }
@ -133,15 +69,12 @@ void Foam::wallBoundedParticle::crossEdgeConnectedFace
const edge& meshEdge const edge& meshEdge
) )
{ {
//label oldFaceI = tetFace();
// Update tetFace, tetPt // Update tetFace, tetPt
particle::crossEdgeConnectedFace(cell(), tetFace(), tetPt(), meshEdge); particle::crossEdgeConnectedFace(cell(), tetFace(), tetPt(), meshEdge);
// Update face to be same as tracking one // Update face to be same as tracking one
face() = tetFace(); face() = tetFace();
// And adapt meshEdgeStart_. // And adapt meshEdgeStart_.
const Foam::face& f = mesh_.faces()[tetFace()]; const Foam::face& f = mesh_.faces()[tetFace()];
label fp = findIndex(f, meshEdge[0]); label fp = findIndex(f, meshEdge[0]);
@ -165,7 +98,7 @@ void Foam::wallBoundedParticle::crossEdgeConnectedFace
"wallBoundedParticle::crossEdgeConnectedFace" "wallBoundedParticle::crossEdgeConnectedFace"
"(const edge&)" "(const edge&)"
) << "Problem :" ) << "Problem :"
<< " particle:" //<< static_cast<const particle&>(*this) << " particle:"
<< info() << info()
<< "face:" << tetFace() << "face:" << tetFace()
<< " verts:" << f << " verts:" << f
@ -176,14 +109,7 @@ void Foam::wallBoundedParticle::crossEdgeConnectedFace
diagEdge_ = -1; diagEdge_ = -1;
//Pout<< " crossed meshEdge "
// << meshEdge.line(mesh().points())
// << " from face:" << oldFaceI
// << " to face:" << tetFace() << endl;
// Check that still on same mesh edge // Check that still on same mesh edge
const edge eNew(f[meshEdgeStart_], f.nextLabel(meshEdgeStart_)); const edge eNew(f[meshEdgeStart_], f.nextLabel(meshEdgeStart_));
if (eNew != meshEdge) if (eNew != meshEdge)
{ {
@ -193,11 +119,6 @@ void Foam::wallBoundedParticle::crossEdgeConnectedFace
"(const edge&)" "(const edge&)"
) << "Problem" << abort(FatalError); ) << "Problem" << abort(FatalError);
} }
// Check that edge (as indicated by meshEdgeStart_) is indeed one that
// contains the position.
//checkOnEdge();
} }
@ -206,20 +127,18 @@ void Foam::wallBoundedParticle::crossDiagonalEdge()
if (diagEdge_ == -1) if (diagEdge_ == -1)
{ {
FatalErrorIn("wallBoundedParticle::crossDiagonalEdge()") FatalErrorIn("wallBoundedParticle::crossDiagonalEdge()")
<< "Particle:" //<< static_cast<const particle&>(*this) << "Particle:"
<< info() << info()
<< "not on a diagonal edge" << abort(FatalError); << "not on a diagonal edge" << abort(FatalError);
} }
if (meshEdgeStart_ != -1) if (meshEdgeStart_ != -1)
{ {
FatalErrorIn("wallBoundedParticle::crossDiagonalEdge()") FatalErrorIn("wallBoundedParticle::crossDiagonalEdge()")
<< "Particle:" //<< static_cast<const particle&>(*this) << "Particle:"
<< info() << info()
<< "meshEdgeStart_:" << meshEdgeStart_ << abort(FatalError); << "meshEdgeStart_:" << meshEdgeStart_ << abort(FatalError);
} }
//label oldTetPt = tetPt();
const Foam::face& f = mesh_.faces()[tetFace()]; const Foam::face& f = mesh_.faces()[tetFace()];
// tetPtI starts from 1, goes up to f.size()-2 // tetPtI starts from 1, goes up to f.size()-2
@ -238,7 +157,7 @@ void Foam::wallBoundedParticle::crossDiagonalEdge()
else else
{ {
FatalErrorIn("wallBoundedParticle::crossDiagonalEdge()") FatalErrorIn("wallBoundedParticle::crossDiagonalEdge()")
<< "Particle:" //<< static_cast<const particle&>(*this) << "Particle:"
<< info() << info()
<< "tetPt:" << tetPt() << "tetPt:" << tetPt()
<< " diagEdge:" << diagEdge_ << abort(FatalError); << " diagEdge:" << diagEdge_ << abort(FatalError);
@ -246,17 +165,9 @@ void Foam::wallBoundedParticle::crossDiagonalEdge()
} }
meshEdgeStart_ = -1; meshEdgeStart_ = -1;
//Pout<< " crossed diagonalEdge "
// << currentEdge().line(mesh().points())
// << " from tetPt:" << oldTetPt
// << " to tetPt:" << tetPt() << endl;
} }
//- Track through a single triangle.
// Gets passed tet+triangle the particle is in. Updates position() but nothing
// else. Returns the triangle edge the particle is now on.
Foam::scalar Foam::wallBoundedParticle::trackFaceTri Foam::scalar Foam::wallBoundedParticle::trackFaceTri
( (
const vector& endPosition, const vector& endPosition,
@ -266,14 +177,6 @@ Foam::scalar Foam::wallBoundedParticle::trackFaceTri
// Track p from position to endPosition // Track p from position to endPosition
const triFace tri(currentTetIndices().faceTriIs(mesh_)); const triFace tri(currentTetIndices().faceTriIs(mesh_));
vector n = tri.normal(mesh_.points()); vector n = tri.normal(mesh_.points());
//if (mag(n) < sqr(SMALL))
//{
// FatalErrorIn("wallBoundedParticle::trackFaceTri(..)")
// << "Small triangle." //<< static_cast<const particle&>(*this)
// << info()
// << "n:" << n
// << abort(FatalError);
//}
n /= mag(n)+VSMALL; n /= mag(n)+VSMALL;
// Check which edge intersects the trajectory. // Check which edge intersects the trajectory.
@ -281,9 +184,6 @@ Foam::scalar Foam::wallBoundedParticle::trackFaceTri
minEdgeI = -1; minEdgeI = -1;
scalar minS = 1; // end position scalar minS = 1; // end position
//const point oldPosition(position());
edge currentE(-1, -1); edge currentE(-1, -1);
if (meshEdgeStart_ != -1 || diagEdge_ != -1) if (meshEdgeStart_ != -1 || diagEdge_ != -1)
{ {
@ -309,21 +209,6 @@ Foam::scalar Foam::wallBoundedParticle::trackFaceTri
// Outwards pointing normal // Outwards pointing normal
vector edgeNormal = (pt1-pt0)^n; vector edgeNormal = (pt1-pt0)^n;
//if (mag(edgeNormal) < SMALL)
//{
// FatalErrorIn("wallBoundedParticle::trackFaceTri(..)")
// << "Edge not perpendicular to triangle."
// //<< static_cast<const particle&>(*this)
// << info()
// << "triangle n:" << n
// << " edgeNormal:" << edgeNormal
// << " on tri:" << tri
// << " at:" << pt0
// << " at:" << pt1
// << abort(FatalError);
//}
edgeNormal /= mag(edgeNormal)+VSMALL; edgeNormal /= mag(edgeNormal)+VSMALL;
// Determine whether position and end point on either side of edge. // Determine whether position and end point on either side of edge.
@ -362,25 +247,10 @@ Foam::scalar Foam::wallBoundedParticle::trackFaceTri
const point& triPt = mesh_.points()[tri[0]]; const point& triPt = mesh_.points()[tri[0]];
position() -= ((position()-triPt)&n)*n; position() -= ((position()-triPt)&n)*n;
//Pout<< " tracked from:" << oldPosition << " to:" << position()
// << " projectedEnd:" << endPosition
// << " at s:" << minS << endl;
//if (minEdgeI != -1)
//{
// Pout<< " on edge:" << minEdgeI
// << " on edge:"
// << mesh_.points()[tri[minEdgeI]]
// << mesh_.points()[tri[tri.fcIndex(minEdgeI)]]
// << endl;
//}
return minS; return minS;
} }
// See if the current triangle has got a point on the
// correct side of the edge.
bool Foam::wallBoundedParticle::isTriAlongTrack bool Foam::wallBoundedParticle::isTriAlongTrack
( (
const point& endPosition const point& endPosition
@ -454,18 +324,7 @@ Foam::wallBoundedParticle::wallBoundedParticle
particle(mesh, position, cellI, tetFaceI, tetPtI), particle(mesh, position, cellI, tetFaceI, tetPtI),
meshEdgeStart_(meshEdgeStart), meshEdgeStart_(meshEdgeStart),
diagEdge_(diagEdge) diagEdge_(diagEdge)
{ {}
//checkInside();
//if (meshEdgeStart_ != -1 || diagEdge_ != -1)
//{
// checkOnEdge();
//}
// Unfortunately have no access to trackdata so cannot check if particle
// is on a wallPatch or has an mesh edge set (either of which is
// a requirement).
}
Foam::wallBoundedParticle::wallBoundedParticle Foam::wallBoundedParticle::wallBoundedParticle
@ -514,46 +373,6 @@ Foam::wallBoundedParticle::wallBoundedParticle
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::wallBoundedParticle::write(Ostream& os, bool writeFields) const
{
const particle& p = static_cast<const particle&>(*this);
if (os.format() == IOstream::ASCII)
{
// Write base particle
p.write(os, writeFields);
if (writeFields)
{
// Write the additional entries
os << token::SPACE << meshEdgeStart_
<< token::SPACE << diagEdge_;
}
}
else
{
// Write base particle
p.write(os, writeFields);
// Write additional entries
if (writeFields)
{
os.write
(
reinterpret_cast<const char*>(&meshEdgeStart_),
sizeof(meshEdgeStart_)
+ sizeof(diagEdge_)
);
}
}
// Check state of Ostream
os.check("wallBoundedParticle::write(Ostream& os, bool) const");
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<< Foam::Ostream& Foam::operator<<
@ -562,8 +381,21 @@ Foam::Ostream& Foam::operator<<
const wallBoundedParticle& p const wallBoundedParticle& p
) )
{ {
// Write all data if (os.format() == IOstream::ASCII)
p.write(os, true); {
os << static_cast<const particle&>(p)
<< token::SPACE << p.meshEdgeStart_
<< token::SPACE << p.diagEdge_;
}
else
{
os << static_cast<const particle&>(p);
os.write
(
reinterpret_cast<const char*>(&p.meshEdgeStart_),
wallBoundedParticle::sizeofFields_
);
}
return os; return os;
} }
@ -602,5 +434,4 @@ Foam::Ostream& Foam::operator<<
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -54,6 +54,11 @@ class wallBoundedParticle
: :
public particle public particle
{ {
// Private data
//- Size in bytes of the fields
static const std::size_t sizeofFields_;
public: public:
@ -317,9 +322,6 @@ public:
template<class CloudType> template<class CloudType>
static void writeFields(const CloudType&); static void writeFields(const CloudType&);
//- Write the particle data
void write(Ostream& os, bool writeFields) const;
// Ostream Operator // Ostream Operator