ENH: minor update of particle methods

This commit is contained in:
Mark Olesen
2022-07-04 15:43:02 +02:00
parent b4a482751b
commit 71246b94b7
21 changed files with 206 additions and 524 deletions

View File

@ -38,8 +38,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef passivePositionParticle_H
#define passivePositionParticle_H
#ifndef Foam_passivePositionParticle_H
#define Foam_passivePositionParticle_H
#include "particle.H"
#include "IOstream.H"
@ -82,7 +82,6 @@ public:
location_(position())
{}
//- Construct from components (supplied location)
passivePositionParticle
(
@ -98,7 +97,6 @@ public:
location_(position)
{}
//- Construct from Istream
passivePositionParticle
(
@ -165,39 +163,39 @@ public:
// Member Functions
//- Return current particle position
inline const point& location() const
//- The cached particle position
const point& location() const noexcept
{
return location_;
}
//- Write the particle position and cell id
// Uses cached location() instead of calculated position()
virtual void writePosition(Ostream& os) const
{
if (os.format() == IOstream::ASCII)
{
return location_;
os << location() << token::SPACE << cell();
}
else
{
positionsCompat1706 p;
const size_t s =
(
offsetof(positionsCompat1706, facei)
- offsetof(positionsCompat1706, position)
);
p.position = location();
p.celli = cell();
os.write(reinterpret_cast<const char*>(&p.position), s);
}
//- Write the particle position and cell id
virtual void writePosition(Ostream& os) const
{
// Use cached location() instead of calculated position()
if (os.format() == IOstream::ASCII)
{
os << location() << token::SPACE << cell();
}
else
{
positionsCompat1706 p;
const size_t s =
(
offsetof(positionsCompat1706, facei)
- offsetof(positionsCompat1706, position)
);
p.position = location();
p.celli = cell();
os.write(reinterpret_cast<const char*>(&p.position), s);
}
// Check state of Ostream
os.check(FUNCTION_NAME);
}
// Check state of Ostream
os.check(FUNCTION_NAME);
}
};