mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +00:00
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:
@ -41,7 +41,6 @@ SourceFiles
|
||||
#include "IOstream.H"
|
||||
#include "autoPtr.H"
|
||||
#include "contiguous.H"
|
||||
|
||||
#include "DSMCCloud.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -70,6 +69,12 @@ class DSMCParcel
|
||||
:
|
||||
public ParcelType
|
||||
{
|
||||
// Private member data
|
||||
|
||||
//- Size in bytes of the fields
|
||||
static const std::size_t sizeofFields_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Class to hold DSMC particle constant properties
|
||||
@ -92,7 +97,7 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
// Constrcutors
|
||||
// Constructors
|
||||
|
||||
//- Null constructor, allows List of constantProperties to be
|
||||
// created before the contents is initialised
|
||||
@ -104,10 +109,10 @@ public:
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Return const access to the particle density
|
||||
//- Return const access to the particle mass [kg]
|
||||
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;
|
||||
|
||||
//- Return the reference total collision cross section
|
||||
@ -152,7 +157,7 @@ protected:
|
||||
vector U_;
|
||||
|
||||
//- Internal energy of the Parcel, covering all non-translational
|
||||
// degrees of freedom [J]
|
||||
// degrees of freedom [J]
|
||||
scalar Ei_;
|
||||
|
||||
//- Parcel type id
|
||||
@ -196,7 +201,6 @@ public:
|
||||
return autoPtr<particle>(new DSMCParcel<ParcelType>(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Factory class to read-construct particles used for
|
||||
// parallel transfer
|
||||
class iNew
|
||||
@ -233,6 +237,7 @@ public:
|
||||
//- Return const access to internal energy
|
||||
inline scalar Ei() const;
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Return access to velocity
|
||||
|
||||
@ -28,6 +28,15 @@ License
|
||||
#include "IOField.H"
|
||||
#include "Cloud.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
template<class ParcelType>
|
||||
const std::size_t Foam::DSMCParcel<ParcelType>::sizeofFields_
|
||||
(
|
||||
sizeof(DSMCParcel<ParcelType>) - sizeof(ParcelType)
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class ParcelType>
|
||||
@ -53,13 +62,7 @@ Foam::DSMCParcel<ParcelType>::DSMCParcel
|
||||
}
|
||||
else
|
||||
{
|
||||
is.read
|
||||
(
|
||||
reinterpret_cast<char*>(&U_),
|
||||
sizeof(U_)
|
||||
+ sizeof(Ei_)
|
||||
+ sizeof(typeId_)
|
||||
);
|
||||
is.read(reinterpret_cast<char*>(&U_), sizeofFields_);
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,9 +160,7 @@ Foam::Ostream& Foam::operator<<
|
||||
os.write
|
||||
(
|
||||
reinterpret_cast<const char*>(&p.U_),
|
||||
sizeof(p.U())
|
||||
+ sizeof(p.Ei())
|
||||
+ sizeof(p.typeId())
|
||||
DSMCParcel<ParcelType>::sizeofFields_
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -68,11 +68,7 @@ bool Foam::IOPosition<CloudType>::writeData(Ostream& os) const
|
||||
|
||||
forAllConstIter(typename CloudType, cloud_, iter)
|
||||
{
|
||||
const typename CloudType::particleType& p = iter();
|
||||
|
||||
// Prevent writing additional fields
|
||||
p.write(os, false);
|
||||
|
||||
iter().writePosition(os);
|
||||
os << nl;
|
||||
}
|
||||
|
||||
@ -100,7 +96,7 @@ void Foam::IOPosition<CloudType>::readData(CloudType& c, bool checkClass)
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
@ -129,7 +125,8 @@ void Foam::IOPosition<CloudType>::readData(CloudType& c, bool checkClass)
|
||||
)
|
||||
{
|
||||
is.putBack(lastToken);
|
||||
// Do not read any fields, position only
|
||||
|
||||
// Write position only
|
||||
c.append(new typename CloudType::particleType(mesh, is, false));
|
||||
is >> lastToken;
|
||||
}
|
||||
|
||||
@ -80,6 +80,15 @@ class particle
|
||||
:
|
||||
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:
|
||||
|
||||
template<class CloudType>
|
||||
@ -358,7 +367,6 @@ public:
|
||||
return autoPtr<particle>(new particle(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Factory class to read-construct particles used for
|
||||
// parallel transfer
|
||||
class iNew
|
||||
@ -556,8 +564,8 @@ public:
|
||||
template<class CloudType>
|
||||
static void writeFields(const CloudType& c);
|
||||
|
||||
//- Write the particle data
|
||||
void write(Ostream& os, bool writeFields) const;
|
||||
//- Write the particle position and cell
|
||||
void writePosition(Ostream&) const;
|
||||
|
||||
|
||||
// Friend Operators
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,12 +25,21 @@ License
|
||||
|
||||
#include "particle.H"
|
||||
#include "IOstreams.H"
|
||||
#include "IOPosition.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
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 * * * * * * * * * * * * * * //
|
||||
|
||||
@ -46,45 +55,29 @@ Foam::particle::particle(const polyMesh& mesh, Istream& is, bool readFields)
|
||||
origProc_(Pstream::myProcNo()),
|
||||
origId_(-1)
|
||||
{
|
||||
// readFields : read additional data. Should be consistent with writeFields.
|
||||
|
||||
if (is.format() == IOstream::ASCII)
|
||||
{
|
||||
is >> position_ >> cellI_;
|
||||
|
||||
if (readFields)
|
||||
{
|
||||
is >> tetFaceI_ >> tetPtI_ >> origProc_ >> origId_;
|
||||
is >> faceI_
|
||||
>> stepFraction_
|
||||
>> tetFaceI_
|
||||
>> tetPtI_
|
||||
>> origProc_
|
||||
>> origId_;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// In binary read all particle data - needed for parallel transfer
|
||||
if (readFields)
|
||||
{
|
||||
is.read
|
||||
(
|
||||
reinterpret_cast<char*>(&position_),
|
||||
sizeof(position_)
|
||||
+ sizeof(cellI_)
|
||||
+ sizeof(faceI_)
|
||||
+ sizeof(stepFraction_)
|
||||
+ sizeof(tetFaceI_)
|
||||
+ sizeof(tetPtI_)
|
||||
+ sizeof(origProc_)
|
||||
+ sizeof(origId_)
|
||||
);
|
||||
is.read(reinterpret_cast<char*>(&position_), sizeofFields_);
|
||||
}
|
||||
else
|
||||
{
|
||||
is.read
|
||||
(
|
||||
reinterpret_cast<char*>(&position_),
|
||||
sizeof(position_)
|
||||
+ sizeof(cellI_)
|
||||
+ sizeof(faceI_)
|
||||
+ sizeof(stepFraction_)
|
||||
);
|
||||
is.read(reinterpret_cast<char*>(&position_), sizeofPosition_);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 (writeFields)
|
||||
{
|
||||
// Write the additional entries
|
||||
os << position_
|
||||
<< token::SPACE << cellI_
|
||||
<< token::SPACE << tetFaceI_
|
||||
<< token::SPACE << tetPtI_
|
||||
<< token::SPACE << origProc_
|
||||
<< token::SPACE << origId_;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << position_
|
||||
<< token::SPACE << cellI_;
|
||||
}
|
||||
os << position_ << 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_)
|
||||
);
|
||||
}
|
||||
os.write(reinterpret_cast<const char*>(&position_), sizeofPosition_);
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
// Write all data
|
||||
p.write(os, true);
|
||||
if (os.format() == IOstream::ASCII)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -38,12 +38,10 @@ SourceFiles
|
||||
#define CollidingParcel_H
|
||||
|
||||
#include "particle.H"
|
||||
|
||||
#include "CollisionRecordList.H"
|
||||
#include "labelFieldIOField.H"
|
||||
#include "vectorFieldIOField.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
@ -74,6 +72,12 @@ class CollidingParcel
|
||||
:
|
||||
public ParcelType
|
||||
{
|
||||
// Private member data
|
||||
|
||||
//- Size in bytes of the fields
|
||||
static const std::size_t sizeofFields_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Class to hold thermo particle constant properties
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -33,6 +33,13 @@ template<class ParcelType>
|
||||
Foam::string 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 * * * * * * * * * * * * * * //
|
||||
|
||||
@ -60,13 +67,7 @@ Foam::CollidingParcel<ParcelType>::CollidingParcel
|
||||
}
|
||||
else
|
||||
{
|
||||
is.read
|
||||
(
|
||||
reinterpret_cast<char*>(&f_),
|
||||
+ sizeof(f_)
|
||||
+ sizeof(angularMomentum_)
|
||||
+ sizeof(torque_)
|
||||
);
|
||||
is.read(reinterpret_cast<char*>(&f_), sizeofFields_);
|
||||
}
|
||||
|
||||
is >> collisionRecords_;
|
||||
@ -285,10 +286,10 @@ Foam::Ostream& Foam::operator<<
|
||||
if (os.format() == IOstream::ASCII)
|
||||
{
|
||||
os << static_cast<const ParcelType&>(p)
|
||||
<< token::SPACE << p.f()
|
||||
<< token::SPACE << p.angularMomentum()
|
||||
<< token::SPACE << p.torque()
|
||||
<< token::SPACE << p.collisionRecords();
|
||||
<< token::SPACE << p.f_
|
||||
<< token::SPACE << p.angularMomentum_
|
||||
<< token::SPACE << p.torque_
|
||||
<< token::SPACE << p.collisionRecords_;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -296,9 +297,7 @@ Foam::Ostream& Foam::operator<<
|
||||
os.write
|
||||
(
|
||||
reinterpret_cast<const char*>(&p.f_),
|
||||
+ sizeof(p.f())
|
||||
+ sizeof(p.angularMomentum())
|
||||
+ sizeof(p.torque())
|
||||
CollidingParcel<ParcelType>::sizeofFields_
|
||||
);
|
||||
os << p.collisionRecords();
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -78,6 +78,15 @@ class KinematicParcel
|
||||
:
|
||||
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:
|
||||
|
||||
//- Class to hold kinematic particle constant properties
|
||||
@ -137,7 +146,7 @@ public:
|
||||
//- Return const access to the particle density
|
||||
inline scalar rho0() const;
|
||||
|
||||
//- Return const access to the minimum particle mass
|
||||
//- Return const access to the minimum parcel mass
|
||||
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 data
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -34,6 +34,14 @@ template<class ParcelType>
|
||||
Foam::string 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 * * * * * * * * * * * * * * //
|
||||
|
||||
template<class ParcelType>
|
||||
@ -76,8 +84,7 @@ Foam::KinematicParcel<ParcelType>::KinematicParcel
|
||||
}
|
||||
else
|
||||
{
|
||||
label size = long(&UTurb_) - long(&active_) + sizeof(UTurb_);
|
||||
is.read(reinterpret_cast<char*>(&active_), size);
|
||||
is.read(reinterpret_cast<char*>(&active_), sizeofFields_);
|
||||
}
|
||||
}
|
||||
|
||||
@ -236,9 +243,11 @@ Foam::Ostream& Foam::operator<<
|
||||
else
|
||||
{
|
||||
os << static_cast<const ParcelType&>(p);
|
||||
|
||||
label size = long(&p.UTurb_) - long(&p.active_) + sizeof(p.UTurb_);
|
||||
os.write(reinterpret_cast<const char*>(&p.active_), size);
|
||||
os.write
|
||||
(
|
||||
reinterpret_cast<const char*>(&p.active_),
|
||||
KinematicParcel<ParcelType>::sizeofFields_
|
||||
);
|
||||
}
|
||||
|
||||
// Check state of Ostream
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -73,6 +73,12 @@ class MPPICParcel
|
||||
:
|
||||
public ParcelType
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Size in bytes of the fields
|
||||
static const std::size_t sizeofFields_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
template<class CloudType>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -33,6 +33,12 @@ template<class ParcelType>
|
||||
Foam::string 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 * * * * * * * * * * * * * * //
|
||||
|
||||
@ -55,11 +61,7 @@ Foam::MPPICParcel<ParcelType>::MPPICParcel
|
||||
}
|
||||
else
|
||||
{
|
||||
is.read
|
||||
(
|
||||
reinterpret_cast<char*>(&UCorrect_),
|
||||
+ sizeof(UCorrect_)
|
||||
);
|
||||
is.read(reinterpret_cast<char*>(&UCorrect_), sizeofFields_);
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,7 +146,7 @@ Foam::Ostream& Foam::operator<<
|
||||
os.write
|
||||
(
|
||||
reinterpret_cast<const char*>(&p.UCorrect_),
|
||||
+ sizeof(p.UCorrect())
|
||||
MPPICParcel<ParcelType>::sizeofFields_
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -66,6 +66,12 @@ class ReactingMultiphaseParcel
|
||||
:
|
||||
public ParcelType
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Size in bytes of the fields
|
||||
static const std::size_t sizeofFields_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// IDs of phases in ReacingParcel phase list (Y)
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -32,6 +32,12 @@ template<class ParcelType>
|
||||
Foam::string Foam::ReactingMultiphaseParcel<ParcelType>::propertyList_ =
|
||||
Foam::ReactingMultiphaseParcel<ParcelType>::propertyList();
|
||||
|
||||
template<class ParcelType>
|
||||
const std::size_t Foam::ReactingMultiphaseParcel<ParcelType>::sizeofFields_
|
||||
(
|
||||
0
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -57,6 +57,7 @@ Ostream& operator<<
|
||||
const ReactingParcel<ParcelType>&
|
||||
);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ReactingParcel Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -66,9 +67,15 @@ class ReactingParcel
|
||||
:
|
||||
public ParcelType
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Size in bytes of the fields
|
||||
static const std::size_t sizeofFields_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Class to hold reacting particle constant properties
|
||||
//- Class to hold reacting parcel constant properties
|
||||
class constantProperties
|
||||
:
|
||||
public ParcelType::constantProperties
|
||||
@ -151,7 +158,7 @@ protected:
|
||||
|
||||
// Parcel properties
|
||||
|
||||
//- Initial particle mass [kg]
|
||||
//- Initial mass [kg]
|
||||
scalar mass0_;
|
||||
|
||||
//- Mass fractions of mixture []
|
||||
@ -183,9 +190,9 @@ protected:
|
||||
const label idPhase, // id of phase involved in phase change
|
||||
const scalar YPhase, // total mass fraction
|
||||
const scalarField& YComponents, // component mass fractions
|
||||
scalarField& dMassPC, // mass transfer - local to particle
|
||||
scalar& Sh, // explicit particle enthalpy source
|
||||
scalar& N, // flux of species emitted from particle
|
||||
scalarField& dMassPC, // mass transfer - local to parcel
|
||||
scalar& Sh, // explicit parcel enthalpy source
|
||||
scalar& N, // flux of species emitted from parcel
|
||||
scalar& NCpW, // sum of N*Cp*W of emission species
|
||||
scalarField& Cs // carrier conc. of emission species
|
||||
);
|
||||
@ -308,7 +315,7 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
//- Return const access to initial particle mass [kg]
|
||||
//- Return const access to initial mass [kg]
|
||||
inline scalar mass0() const;
|
||||
|
||||
//- Return const access to mass fractions of mixture []
|
||||
@ -323,7 +330,7 @@ public:
|
||||
|
||||
// Edit
|
||||
|
||||
//- Return access to initial particle mass [kg]
|
||||
//- Return access to initial mass [kg]
|
||||
inline scalar& mass0();
|
||||
|
||||
//- Return access to mass fractions of mixture []
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -32,6 +32,12 @@ template<class ParcelType>
|
||||
Foam::string Foam::ReactingParcel<ParcelType>::propertyList_ =
|
||||
Foam::ReactingParcel<ParcelType>::propertyList();
|
||||
|
||||
template<class ParcelType>
|
||||
const std::size_t Foam::ReactingParcel<ParcelType>::sizeofFields_
|
||||
(
|
||||
sizeof(scalar)
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -58,11 +64,7 @@ Foam::ReactingParcel<ParcelType>::ReactingParcel
|
||||
}
|
||||
else
|
||||
{
|
||||
is.read
|
||||
(
|
||||
reinterpret_cast<char*>(&mass0_),
|
||||
+ sizeof(mass0_)
|
||||
);
|
||||
is.read(reinterpret_cast<char*>(&mass0_), sizeofFields_);
|
||||
is >> Ymix;
|
||||
}
|
||||
|
||||
@ -249,7 +251,7 @@ Foam::Ostream& Foam::operator<<
|
||||
os.write
|
||||
(
|
||||
reinterpret_cast<const char*>(&p.mass0_),
|
||||
sizeof(p.mass0())
|
||||
ReactingParcel<ParcelType>::sizeofFields_
|
||||
);
|
||||
os << p.Y();
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -67,6 +67,12 @@ class ThermoParcel
|
||||
:
|
||||
public ParcelType
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Size in bytes of the fields
|
||||
static const std::size_t sizeofFields_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Class to hold thermo particle constant properties
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -32,6 +32,13 @@ template<class ParcelType>
|
||||
Foam::string 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 * * * * * * * * * * * * * * //
|
||||
|
||||
@ -58,8 +65,7 @@ Foam::ThermoParcel<ParcelType>::ThermoParcel
|
||||
}
|
||||
else
|
||||
{
|
||||
label size = long(&Cp_) - long(&T_) + sizeof(Cp_);
|
||||
is.read(reinterpret_cast<char*>(&T_), size);
|
||||
is.read(reinterpret_cast<char*>(&T_), sizeofFields_);
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,9 +151,11 @@ Foam::Ostream& Foam::operator<<
|
||||
else
|
||||
{
|
||||
os << static_cast<const ParcelType&>(p);
|
||||
|
||||
label size = long(&p.Cp_) - long(&p.T_) + sizeof(p.Cp_);
|
||||
os.write(reinterpret_cast<const char*>(&p.T_), size);
|
||||
os.write
|
||||
(
|
||||
reinterpret_cast<const char*>(&p.T_),
|
||||
ThermoParcel<ParcelType>::sizeofFields_
|
||||
);
|
||||
}
|
||||
|
||||
// Check state of Ostream
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -32,7 +32,7 @@ Description
|
||||
terahedrons surrounding each point. The latter forms a type of dual mesh.
|
||||
The interpolation is weighted by proximity to the cell centre or point, as
|
||||
calculated by the barycentric coordinate within the tethrahedron.
|
||||
|
||||
|
||||
Values are interpolated linearly across the tethrahedron. Gradients are
|
||||
calculated directly from the point values using a first order finite
|
||||
element basis. The computed gradient is assumed constant over the
|
||||
@ -98,7 +98,7 @@ private:
|
||||
|
||||
|
||||
//- Private static member functions
|
||||
|
||||
|
||||
//- Return the size of the FieldField parts
|
||||
static autoPtr<labelList> size(const fvMesh &mesh);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -58,6 +58,11 @@ class molecule
|
||||
:
|
||||
public particle
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Size in bytes of the fields
|
||||
static const std::size_t sizeofFields_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -27,6 +27,14 @@ License
|
||||
#include "IOstreams.H"
|
||||
#include "moleculeCloud.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const std::size_t Foam::molecule::sizeofFields_
|
||||
(
|
||||
offsetof(molecule, siteForces_) - offsetof(molecule, Q_)
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::molecule::molecule
|
||||
@ -59,31 +67,17 @@ Foam::molecule::molecule
|
||||
is >> a_;
|
||||
is >> pi_;
|
||||
is >> tau_;
|
||||
is >> siteForces_;
|
||||
is >> specialPosition_;
|
||||
potentialEnergy_ = readScalar(is);
|
||||
is >> rf_;
|
||||
special_ = readLabel(is);
|
||||
id_ = readLabel(is);
|
||||
is >> siteForces_;
|
||||
is >> sitePositions_;
|
||||
is >> specialPosition_;
|
||||
}
|
||||
else
|
||||
{
|
||||
is.read
|
||||
(
|
||||
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.read(reinterpret_cast<char*>(&Q_), sizeofFields_);
|
||||
is >> siteForces_ >> sitePositions_;
|
||||
}
|
||||
}
|
||||
@ -263,8 +257,6 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const molecule& mol)
|
||||
if (os.format() == IOstream::ASCII)
|
||||
{
|
||||
os << token::SPACE << static_cast<const particle&>(mol)
|
||||
<< token::SPACE << mol.face()
|
||||
<< token::SPACE << mol.stepFraction()
|
||||
<< token::SPACE << mol.Q_
|
||||
<< token::SPACE << mol.v_
|
||||
<< token::SPACE << mol.a_
|
||||
@ -284,16 +276,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const molecule& mol)
|
||||
os.write
|
||||
(
|
||||
reinterpret_cast<const char*>(&mol.Q_),
|
||||
sizeof(mol.Q_)
|
||||
+ 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_)
|
||||
molecule::sizeofFields_
|
||||
);
|
||||
os << mol.siteForces_ << mol.sitePositions_;
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -59,7 +59,10 @@ class solidParticle
|
||||
:
|
||||
public particle
|
||||
{
|
||||
// Private member data
|
||||
// Private data
|
||||
|
||||
//- Size in bytes of the fields
|
||||
static const std::size_t sizeofFields_;
|
||||
|
||||
//- Diameter
|
||||
scalar d_;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -26,6 +26,14 @@ License
|
||||
#include "solidParticle.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const std::size_t Foam::solidParticle::sizeofFields_
|
||||
(
|
||||
sizeof(solidParticle) - sizeof(particle)
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::solidParticle::solidParticle
|
||||
@ -46,11 +54,7 @@ Foam::solidParticle::solidParticle
|
||||
}
|
||||
else
|
||||
{
|
||||
is.read
|
||||
(
|
||||
reinterpret_cast<char*>(&d_),
|
||||
sizeof(d_) + sizeof(U_)
|
||||
);
|
||||
is.read(reinterpret_cast<char*>(&d_), sizeofFields_);
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,7 +130,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const solidParticle& p)
|
||||
os.write
|
||||
(
|
||||
reinterpret_cast<const char*>(&p.d_),
|
||||
sizeof(p.d_) + sizeof(p.U_)
|
||||
solidParticle::sizeofFields_
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -59,6 +59,11 @@ class SprayParcel
|
||||
:
|
||||
public ParcelType
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Size in bytes of the fields
|
||||
static const std::size_t sizeofFields_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -173,9 +178,6 @@ public:
|
||||
|
||||
// Static data members
|
||||
|
||||
//- String representation of properties
|
||||
static string propHeader;
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("SprayParcel");
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -29,21 +29,10 @@ License
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
template<class ParcelType>
|
||||
Foam::string Foam::SprayParcel<ParcelType>::propHeader =
|
||||
ParcelType::propHeader
|
||||
+ " d0"
|
||||
+ " position0"
|
||||
+ " sigma"
|
||||
+ " mu"
|
||||
+ " liquidCore"
|
||||
+ " KHindex"
|
||||
+ " y"
|
||||
+ " yDot"
|
||||
+ " tc"
|
||||
+ " ms"
|
||||
+ " injector"
|
||||
+ " tMom"
|
||||
+ " user";
|
||||
const std::size_t Foam::SprayParcel<ParcelType>::sizeofFields_
|
||||
(
|
||||
sizeof(SprayParcel<ParcelType>) - sizeof(ParcelType)
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
@ -73,7 +62,6 @@ Foam::SprayParcel<ParcelType>::SprayParcel
|
||||
{
|
||||
if (readFields)
|
||||
{
|
||||
|
||||
if (is.format() == IOstream::ASCII)
|
||||
{
|
||||
d0_ = readScalar(is);
|
||||
@ -92,23 +80,7 @@ Foam::SprayParcel<ParcelType>::SprayParcel
|
||||
}
|
||||
else
|
||||
{
|
||||
is.read
|
||||
(
|
||||
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_)
|
||||
);
|
||||
is.read(reinterpret_cast<char*>(&d0_), sizeofFields_);
|
||||
}
|
||||
}
|
||||
|
||||
@ -334,19 +306,7 @@ Foam::Ostream& Foam::operator<<
|
||||
os.write
|
||||
(
|
||||
reinterpret_cast<const char*>(&p.d0_),
|
||||
sizeof(p.d0())
|
||||
+ 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())
|
||||
SprayParcel<ParcelType>::sizeofFields_
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -24,88 +24,23 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "wallBoundedParticle.H"
|
||||
#include "vectorFieldIOField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
// defineParticleTypeNameAndDebug(wallBoundedParticle, 0);
|
||||
}
|
||||
const std::size_t Foam::wallBoundedParticle::sizeofFields_
|
||||
(
|
||||
sizeof(wallBoundedParticle) - sizeof(particle)
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * 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
|
||||
{
|
||||
if ((meshEdgeStart_ != -1) == (diagEdge_ != -1))
|
||||
{
|
||||
FatalErrorIn("wallBoundedParticle::currentEdge() const")
|
||||
<< "Particle:" //<< static_cast<const particle&>(*this)
|
||||
<< "Particle:"
|
||||
<< info()
|
||||
<< "cannot both be on a mesh edge and a face-diagonal edge."
|
||||
<< " meshEdgeStart_:" << meshEdgeStart_
|
||||
@ -123,6 +58,7 @@ Foam::edge Foam::wallBoundedParticle::currentEdge() const
|
||||
{
|
||||
label faceBasePtI = mesh_.tetBasePtIs()[tetFace()];
|
||||
label diagPtI = (faceBasePtI+diagEdge_)%f.size();
|
||||
|
||||
return edge(f[faceBasePtI], f[diagPtI]);
|
||||
}
|
||||
}
|
||||
@ -133,15 +69,12 @@ void Foam::wallBoundedParticle::crossEdgeConnectedFace
|
||||
const edge& meshEdge
|
||||
)
|
||||
{
|
||||
//label oldFaceI = tetFace();
|
||||
|
||||
// Update tetFace, tetPt
|
||||
particle::crossEdgeConnectedFace(cell(), tetFace(), tetPt(), meshEdge);
|
||||
|
||||
// Update face to be same as tracking one
|
||||
face() = tetFace();
|
||||
|
||||
|
||||
// And adapt meshEdgeStart_.
|
||||
const Foam::face& f = mesh_.faces()[tetFace()];
|
||||
label fp = findIndex(f, meshEdge[0]);
|
||||
@ -165,7 +98,7 @@ void Foam::wallBoundedParticle::crossEdgeConnectedFace
|
||||
"wallBoundedParticle::crossEdgeConnectedFace"
|
||||
"(const edge&)"
|
||||
) << "Problem :"
|
||||
<< " particle:" //<< static_cast<const particle&>(*this)
|
||||
<< " particle:"
|
||||
<< info()
|
||||
<< "face:" << tetFace()
|
||||
<< " verts:" << f
|
||||
@ -176,14 +109,7 @@ void Foam::wallBoundedParticle::crossEdgeConnectedFace
|
||||
|
||||
diagEdge_ = -1;
|
||||
|
||||
//Pout<< " crossed meshEdge "
|
||||
// << meshEdge.line(mesh().points())
|
||||
// << " from face:" << oldFaceI
|
||||
// << " to face:" << tetFace() << endl;
|
||||
|
||||
|
||||
// Check that still on same mesh edge
|
||||
|
||||
const edge eNew(f[meshEdgeStart_], f.nextLabel(meshEdgeStart_));
|
||||
if (eNew != meshEdge)
|
||||
{
|
||||
@ -193,11 +119,6 @@ void Foam::wallBoundedParticle::crossEdgeConnectedFace
|
||||
"(const edge&)"
|
||||
) << "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)
|
||||
{
|
||||
FatalErrorIn("wallBoundedParticle::crossDiagonalEdge()")
|
||||
<< "Particle:" //<< static_cast<const particle&>(*this)
|
||||
<< "Particle:"
|
||||
<< info()
|
||||
<< "not on a diagonal edge" << abort(FatalError);
|
||||
}
|
||||
if (meshEdgeStart_ != -1)
|
||||
{
|
||||
FatalErrorIn("wallBoundedParticle::crossDiagonalEdge()")
|
||||
<< "Particle:" //<< static_cast<const particle&>(*this)
|
||||
<< "Particle:"
|
||||
<< info()
|
||||
<< "meshEdgeStart_:" << meshEdgeStart_ << abort(FatalError);
|
||||
}
|
||||
|
||||
//label oldTetPt = tetPt();
|
||||
|
||||
const Foam::face& f = mesh_.faces()[tetFace()];
|
||||
|
||||
// tetPtI starts from 1, goes up to f.size()-2
|
||||
@ -238,7 +157,7 @@ void Foam::wallBoundedParticle::crossDiagonalEdge()
|
||||
else
|
||||
{
|
||||
FatalErrorIn("wallBoundedParticle::crossDiagonalEdge()")
|
||||
<< "Particle:" //<< static_cast<const particle&>(*this)
|
||||
<< "Particle:"
|
||||
<< info()
|
||||
<< "tetPt:" << tetPt()
|
||||
<< " diagEdge:" << diagEdge_ << abort(FatalError);
|
||||
@ -246,17 +165,9 @@ void Foam::wallBoundedParticle::crossDiagonalEdge()
|
||||
}
|
||||
|
||||
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
|
||||
(
|
||||
const vector& endPosition,
|
||||
@ -266,14 +177,6 @@ Foam::scalar Foam::wallBoundedParticle::trackFaceTri
|
||||
// Track p from position to endPosition
|
||||
const triFace tri(currentTetIndices().faceTriIs(mesh_));
|
||||
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;
|
||||
|
||||
// Check which edge intersects the trajectory.
|
||||
@ -281,9 +184,6 @@ Foam::scalar Foam::wallBoundedParticle::trackFaceTri
|
||||
minEdgeI = -1;
|
||||
scalar minS = 1; // end position
|
||||
|
||||
//const point oldPosition(position());
|
||||
|
||||
|
||||
edge currentE(-1, -1);
|
||||
if (meshEdgeStart_ != -1 || diagEdge_ != -1)
|
||||
{
|
||||
@ -309,21 +209,6 @@ Foam::scalar Foam::wallBoundedParticle::trackFaceTri
|
||||
// Outwards pointing normal
|
||||
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;
|
||||
|
||||
// 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]];
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
// See if the current triangle has got a point on the
|
||||
// correct side of the edge.
|
||||
bool Foam::wallBoundedParticle::isTriAlongTrack
|
||||
(
|
||||
const point& endPosition
|
||||
@ -454,18 +324,7 @@ Foam::wallBoundedParticle::wallBoundedParticle
|
||||
particle(mesh, position, cellI, tetFaceI, tetPtI),
|
||||
meshEdgeStart_(meshEdgeStart),
|
||||
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
|
||||
@ -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 * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<
|
||||
@ -562,8 +381,21 @@ Foam::Ostream& Foam::operator<<
|
||||
const wallBoundedParticle& p
|
||||
)
|
||||
{
|
||||
// Write all data
|
||||
p.write(os, true);
|
||||
if (os.format() == IOstream::ASCII)
|
||||
{
|
||||
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;
|
||||
}
|
||||
@ -602,5 +434,4 @@ Foam::Ostream& Foam::operator<<
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -54,6 +54,11 @@ class wallBoundedParticle
|
||||
:
|
||||
public particle
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Size in bytes of the fields
|
||||
static const std::size_t sizeofFields_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -317,9 +322,6 @@ public:
|
||||
template<class CloudType>
|
||||
static void writeFields(const CloudType&);
|
||||
|
||||
//- Write the particle data
|
||||
void write(Ostream& os, bool writeFields) const;
|
||||
|
||||
|
||||
// Ostream Operator
|
||||
|
||||
|
||||
Reference in New Issue
Block a user