Optimised the position() function in particle.C
This commit is contained in:
parent
7f7d351b74
commit
4229214ad3
5 changed files with 56 additions and 7 deletions
|
|
@ -51,13 +51,11 @@ void Foam::particle::stationaryTetGeometry
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const triFace triIs(currentTetIndices().faceTriIs(mesh_));
|
const triFace triIs(currentTetIndices().faceTriIs(mesh_));
|
||||||
const vectorField& ccs = mesh_.cellCentres();
|
|
||||||
const pointField& pts = mesh_.points();
|
|
||||||
|
|
||||||
centre = ccs[celli_];
|
centre = cellCentres_[celli_];
|
||||||
base = pts[triIs[0]];
|
base = meshPoints_[triIs[0]];
|
||||||
vertex1 = pts[triIs[1]];
|
vertex1 = meshPoints_[triIs[1]];
|
||||||
vertex2 = pts[triIs[2]];
|
vertex2 = meshPoints_[triIs[2]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -305,6 +303,9 @@ void Foam::particle::changeTet(const label tetTriI)
|
||||||
<< "track is on triangle 1, 2 or 3."
|
<< "track is on triangle 1, 2 or 3."
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the position
|
||||||
|
position_ = position();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -419,6 +420,9 @@ void Foam::particle::changeFace(const label tetTriI)
|
||||||
{
|
{
|
||||||
rotate(false);
|
rotate(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the position
|
||||||
|
position_ = position();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -431,6 +435,9 @@ void Foam::particle::changeCell()
|
||||||
|
|
||||||
// Reflect to account for the change of triangle orientation in the new cell
|
// Reflect to account for the change of triangle orientation in the new cell
|
||||||
reflect();
|
reflect();
|
||||||
|
|
||||||
|
// Update the position
|
||||||
|
position_ = position();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -515,6 +522,9 @@ void Foam::particle::locate
|
||||||
++ nWarnings;
|
++ nWarnings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the position
|
||||||
|
position_ = this->position();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -530,10 +540,13 @@ Foam::particle::particle
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
mesh_(mesh),
|
mesh_(mesh),
|
||||||
|
cellCentres_(mesh_.cellCentres()),
|
||||||
|
meshPoints_(mesh_.points()),
|
||||||
coordinates_(coordinates),
|
coordinates_(coordinates),
|
||||||
celli_(celli),
|
celli_(celli),
|
||||||
tetFacei_(tetFacei),
|
tetFacei_(tetFacei),
|
||||||
tetPti_(tetPti),
|
tetPti_(tetPti),
|
||||||
|
position_(position()),
|
||||||
facei_(-1),
|
facei_(-1),
|
||||||
stepFraction_(0.0),
|
stepFraction_(0.0),
|
||||||
origProc_(Pstream::myProcNo()),
|
origProc_(Pstream::myProcNo()),
|
||||||
|
|
@ -549,10 +562,13 @@ Foam::particle::particle
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
mesh_(mesh),
|
mesh_(mesh),
|
||||||
|
cellCentres_(mesh_.cellCentres()),
|
||||||
|
meshPoints_(mesh_.points()),
|
||||||
coordinates_(- VGREAT, - VGREAT, - VGREAT, - VGREAT),
|
coordinates_(- VGREAT, - VGREAT, - VGREAT, - VGREAT),
|
||||||
celli_(celli),
|
celli_(celli),
|
||||||
tetFacei_(-1),
|
tetFacei_(-1),
|
||||||
tetPti_(-1),
|
tetPti_(-1),
|
||||||
|
position_(vector::zero),
|
||||||
facei_(-1),
|
facei_(-1),
|
||||||
stepFraction_(0.0),
|
stepFraction_(0.0),
|
||||||
origProc_(Pstream::myProcNo()),
|
origProc_(Pstream::myProcNo()),
|
||||||
|
|
@ -572,10 +588,13 @@ Foam::particle::particle
|
||||||
Foam::particle::particle(const particle& p)
|
Foam::particle::particle(const particle& p)
|
||||||
:
|
:
|
||||||
mesh_(p.mesh_),
|
mesh_(p.mesh_),
|
||||||
|
cellCentres_(p.cellCentres_),
|
||||||
|
meshPoints_(p.meshPoints_),
|
||||||
coordinates_(p.coordinates_),
|
coordinates_(p.coordinates_),
|
||||||
celli_(p.celli_),
|
celli_(p.celli_),
|
||||||
tetFacei_(p.tetFacei_),
|
tetFacei_(p.tetFacei_),
|
||||||
tetPti_(p.tetPti_),
|
tetPti_(p.tetPti_),
|
||||||
|
position_(p.position_),
|
||||||
facei_(p.facei_),
|
facei_(p.facei_),
|
||||||
stepFraction_(p.stepFraction_),
|
stepFraction_(p.stepFraction_),
|
||||||
origProc_(p.origProc_),
|
origProc_(p.origProc_),
|
||||||
|
|
@ -586,10 +605,13 @@ Foam::particle::particle(const particle& p)
|
||||||
Foam::particle::particle(const particle& p, const polyMesh& mesh)
|
Foam::particle::particle(const particle& p, const polyMesh& mesh)
|
||||||
:
|
:
|
||||||
mesh_(mesh),
|
mesh_(mesh),
|
||||||
|
cellCentres_(p.cellCentres_),
|
||||||
|
meshPoints_(p.meshPoints_),
|
||||||
coordinates_(p.coordinates_),
|
coordinates_(p.coordinates_),
|
||||||
celli_(p.celli_),
|
celli_(p.celli_),
|
||||||
tetFacei_(p.tetFacei_),
|
tetFacei_(p.tetFacei_),
|
||||||
tetPti_(p.tetPti_),
|
tetPti_(p.tetPti_),
|
||||||
|
position_(p.position_),
|
||||||
facei_(p.facei_),
|
facei_(p.facei_),
|
||||||
stepFraction_(p.stepFraction_),
|
stepFraction_(p.stepFraction_),
|
||||||
origProc_(p.origProc_),
|
origProc_(p.origProc_),
|
||||||
|
|
@ -637,12 +659,20 @@ Foam::scalar Foam::particle::trackToFace
|
||||||
if (tetTriI == -1)
|
if (tetTriI == -1)
|
||||||
{
|
{
|
||||||
// The track has completed within the current tet
|
// The track has completed within the current tet
|
||||||
|
|
||||||
|
// Update the position
|
||||||
|
position_ = this->position();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (tetTriI == 0)
|
else if (tetTriI == 0)
|
||||||
{
|
{
|
||||||
// The track has hit a face, so set the current face and return
|
// The track has hit a face, so set the current face and return
|
||||||
facei_ = tetFacei_;
|
facei_ = tetFacei_;
|
||||||
|
|
||||||
|
// Update the position
|
||||||
|
position_ = this->position();
|
||||||
|
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -889,6 +919,9 @@ Foam::scalar Foam::particle::trackToMovingTri
|
||||||
<< "End global coordinates = " << position() << endl;
|
<< "End global coordinates = " << position() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update position
|
||||||
|
position_ = position();
|
||||||
|
|
||||||
return iH != -1 ? 1 - muH*detA[0] : 0;
|
return iH != -1 ? 1 - muH*detA[0] : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -149,6 +149,8 @@ private:
|
||||||
|
|
||||||
//- Reference to the polyMesh database
|
//- Reference to the polyMesh database
|
||||||
const polyMesh& mesh_;
|
const polyMesh& mesh_;
|
||||||
|
const vectorField& cellCentres_;
|
||||||
|
const pointField& meshPoints_;
|
||||||
|
|
||||||
//- Coordinates of particle
|
//- Coordinates of particle
|
||||||
barycentric coordinates_;
|
barycentric coordinates_;
|
||||||
|
|
@ -165,6 +167,9 @@ private:
|
||||||
// point.
|
// point.
|
||||||
label tetPti_;
|
label tetPti_;
|
||||||
|
|
||||||
|
//- Position of the particle
|
||||||
|
vector position_;
|
||||||
|
|
||||||
//- Face index if the particle is on a face otherwise -1
|
//- Face index if the particle is on a face otherwise -1
|
||||||
label facei_;
|
label facei_;
|
||||||
|
|
||||||
|
|
@ -530,6 +535,9 @@ public:
|
||||||
//- Return current particle position
|
//- Return current particle position
|
||||||
inline vector position() const;
|
inline vector position() const;
|
||||||
|
|
||||||
|
//- Return current particle position
|
||||||
|
inline vector& stationaryPosition();
|
||||||
|
|
||||||
|
|
||||||
// Track
|
// Track
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -207,4 +207,10 @@ inline Foam::vector Foam::particle::position() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::vector& Foam::particle::stationaryPosition()
|
||||||
|
{
|
||||||
|
return position_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,8 @@ const std::size_t Foam::particle::sizeofFields_
|
||||||
Foam::particle::particle(const polyMesh& mesh, Istream& is, bool readFields)
|
Foam::particle::particle(const polyMesh& mesh, Istream& is, bool readFields)
|
||||||
:
|
:
|
||||||
mesh_(mesh),
|
mesh_(mesh),
|
||||||
|
cellCentres_(mesh_.cellCentres()),
|
||||||
|
meshPoints_(mesh_.points()),
|
||||||
coordinates_(),
|
coordinates_(),
|
||||||
celli_(-1),
|
celli_(-1),
|
||||||
tetFacei_(-1),
|
tetFacei_(-1),
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,7 @@ void Foam::PairSpringSliderDashpot<CloudType>::evaluatePair
|
||||||
typename CloudType::parcelType& pB
|
typename CloudType::parcelType& pB
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
vector r_AB = (pA.position() - pB.position());
|
vector r_AB = (pA.stationaryPosition() - pB.stationaryPosition());
|
||||||
|
|
||||||
scalar dAEff = pA.d();
|
scalar dAEff = pA.d();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue