MPPIC: Optimised the averaging methods
The averaging methods now take the particle barycentric coordinates as inputs rather than global positions. This change significantly optimises Dual averaging, which is the most commonly used method. The run time of the lagrangian/MPPICFoam/Goldschmidt tutorial has been reduced by a factor of about two.
This commit is contained in:
@ -180,10 +180,10 @@ Foam::MPPICParcel<ParcelType>::TrackingData<CloudType>::updateAverages
|
|||||||
|
|
||||||
const scalar m = p.nParticle()*p.mass();
|
const scalar m = p.nParticle()*p.mass();
|
||||||
|
|
||||||
volumeAverage_->add(p.position(), tetIs, p.nParticle()*p.volume());
|
volumeAverage_->add(p.coordinates(), tetIs, p.nParticle()*p.volume());
|
||||||
rhoAverage_->add(p.position(), tetIs, m*p.rho());
|
rhoAverage_->add(p.coordinates(), tetIs, m*p.rho());
|
||||||
uAverage_->add(p.position(), tetIs, m*p.U());
|
uAverage_->add(p.coordinates(), tetIs, m*p.U());
|
||||||
massAverage_->add(p.position(), tetIs, m);
|
massAverage_->add(p.coordinates(), tetIs, m);
|
||||||
}
|
}
|
||||||
volumeAverage_->average();
|
volumeAverage_->average();
|
||||||
massAverage_->average();
|
massAverage_->average();
|
||||||
@ -196,11 +196,11 @@ Foam::MPPICParcel<ParcelType>::TrackingData<CloudType>::updateAverages
|
|||||||
const typename CloudType::parcelType& p = iter();
|
const typename CloudType::parcelType& p = iter();
|
||||||
const tetIndices tetIs = p.currentTetIndices();
|
const tetIndices tetIs = p.currentTetIndices();
|
||||||
|
|
||||||
const vector u = uAverage_->interpolate(p.position(), tetIs);
|
const vector u = uAverage_->interpolate(p.coordinates(), tetIs);
|
||||||
|
|
||||||
uSqrAverage_->add
|
uSqrAverage_->add
|
||||||
(
|
(
|
||||||
p.position(),
|
p.coordinates(),
|
||||||
tetIs,
|
tetIs,
|
||||||
p.nParticle()*p.mass()*magSqr(p.U() - u)
|
p.nParticle()*p.mass()*magSqr(p.U() - u)
|
||||||
);
|
);
|
||||||
@ -217,7 +217,7 @@ Foam::MPPICParcel<ParcelType>::TrackingData<CloudType>::updateAverages
|
|||||||
|
|
||||||
weightAverage.add
|
weightAverage.add
|
||||||
(
|
(
|
||||||
p.position(),
|
p.coordinates(),
|
||||||
tetIs,
|
tetIs,
|
||||||
p.nParticle()*pow(p.volume(), 2.0/3.0)
|
p.nParticle()*pow(p.volume(), 2.0/3.0)
|
||||||
);
|
);
|
||||||
@ -232,15 +232,15 @@ Foam::MPPICParcel<ParcelType>::TrackingData<CloudType>::updateAverages
|
|||||||
const typename CloudType::parcelType& p = iter();
|
const typename CloudType::parcelType& p = iter();
|
||||||
const tetIndices tetIs = p.currentTetIndices();
|
const tetIndices tetIs = p.currentTetIndices();
|
||||||
|
|
||||||
const scalar a = volumeAverage_->interpolate(p.position(), tetIs);
|
const scalar a = volumeAverage_->interpolate(p.coordinates(), tetIs);
|
||||||
const scalar r = radiusAverage_->interpolate(p.position(), tetIs);
|
const scalar r = radiusAverage_->interpolate(p.coordinates(), tetIs);
|
||||||
const vector u = uAverage_->interpolate(p.position(), tetIs);
|
const vector u = uAverage_->interpolate(p.coordinates(), tetIs);
|
||||||
|
|
||||||
const scalar f = 0.75*a/pow3(r)*sqr(0.5*p.d() + r)*mag(p.U() - u);
|
const scalar f = 0.75*a/pow3(r)*sqr(0.5*p.d() + r)*mag(p.U() - u);
|
||||||
|
|
||||||
frequencyAverage_->add(p.position(), tetIs, p.nParticle()*f*f);
|
frequencyAverage_->add(p.coordinates(), tetIs, p.nParticle()*f*f);
|
||||||
|
|
||||||
weightAverage.add(p.position(), tetIs, p.nParticle()*f);
|
weightAverage.add(p.coordinates(), tetIs, p.nParticle()*f);
|
||||||
}
|
}
|
||||||
frequencyAverage_->average(weightAverage);
|
frequencyAverage_->average(weightAverage);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -195,6 +195,16 @@ bool Foam::AveragingMethod<Type>::write() const
|
|||||||
dimensioned<TypeGrad>("zero", dimless, Zero)
|
dimensioned<TypeGrad>("zero", dimless, Zero)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Barycentric coordinates of the tet vertices
|
||||||
|
const FixedList<barycentric, 4>
|
||||||
|
tetCrds
|
||||||
|
({
|
||||||
|
barycentric(1, 0, 0, 0),
|
||||||
|
barycentric(0, 1, 0, 0),
|
||||||
|
barycentric(0, 0, 1, 0),
|
||||||
|
barycentric(0, 0, 0, 1)
|
||||||
|
});
|
||||||
|
|
||||||
// tet-volume weighted sums
|
// tet-volume weighted sums
|
||||||
forAll(mesh_.C(), celli)
|
forAll(mesh_.C(), celli)
|
||||||
{
|
{
|
||||||
@ -207,18 +217,16 @@ bool Foam::AveragingMethod<Type>::write() const
|
|||||||
const triFace triIs = tetIs.faceTriIs(mesh_);
|
const triFace triIs = tetIs.faceTriIs(mesh_);
|
||||||
const scalar v = tetIs.tet(mesh_).mag();
|
const scalar v = tetIs.tet(mesh_).mag();
|
||||||
|
|
||||||
cellValue[celli] += v*interpolate(mesh_.C()[celli], tetIs);
|
cellValue[celli] += v*interpolate(tetCrds[0], tetIs);
|
||||||
cellGrad[celli] += v*interpolateGrad(mesh_.C()[celli], tetIs);
|
cellGrad[celli] += v*interpolateGrad(tetCrds[0], tetIs);
|
||||||
|
|
||||||
forAll(triIs, vertexI)
|
forAll(triIs, vertexI)
|
||||||
{
|
{
|
||||||
const label pointi = triIs[vertexI];
|
const label pointi = triIs[vertexI];
|
||||||
|
|
||||||
pointVolume[pointi] += v;
|
pointVolume[pointi] += v;
|
||||||
pointValue[pointi] +=
|
pointValue[pointi] += v*interpolate(tetCrds[vertexI], tetIs);
|
||||||
v*interpolate(mesh_.points()[pointi], tetIs);
|
pointGrad[pointi] += v*interpolateGrad(tetCrds[vertexI], tetIs);
|
||||||
pointGrad[pointi] +=
|
|
||||||
v*interpolateGrad(mesh_.points()[pointi], tetIs);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2013-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -38,6 +38,7 @@ SourceFiles
|
|||||||
|
|
||||||
#include "IOdictionary.H"
|
#include "IOdictionary.H"
|
||||||
#include "autoPtr.H"
|
#include "autoPtr.H"
|
||||||
|
#include "barycentric.H"
|
||||||
#include "runTimeSelectionTables.H"
|
#include "runTimeSelectionTables.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -134,7 +135,7 @@ public:
|
|||||||
//- Add point value to interpolation
|
//- Add point value to interpolation
|
||||||
virtual void add
|
virtual void add
|
||||||
(
|
(
|
||||||
const point position,
|
const barycentric& coordinates,
|
||||||
const tetIndices& tetIs,
|
const tetIndices& tetIs,
|
||||||
const Type& value
|
const Type& value
|
||||||
) = 0;
|
) = 0;
|
||||||
@ -142,14 +143,14 @@ public:
|
|||||||
//- Interpolate
|
//- Interpolate
|
||||||
virtual Type interpolate
|
virtual Type interpolate
|
||||||
(
|
(
|
||||||
const point position,
|
const barycentric& coordinates,
|
||||||
const tetIndices& tetIs
|
const tetIndices& tetIs
|
||||||
) const = 0;
|
) const = 0;
|
||||||
|
|
||||||
//- Interpolate gradient
|
//- Interpolate gradient
|
||||||
virtual TypeGrad interpolateGrad
|
virtual TypeGrad interpolateGrad
|
||||||
(
|
(
|
||||||
const point position,
|
const barycentric& coordinates,
|
||||||
const tetIndices& tetIs
|
const tetIndices& tetIs
|
||||||
) const = 0;
|
) const = 0;
|
||||||
|
|
||||||
|
|||||||
@ -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-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2013-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -91,7 +91,7 @@ void Foam::AveragingMethods::Basic<Type>::updateGrad()
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::AveragingMethods::Basic<Type>::add
|
void Foam::AveragingMethods::Basic<Type>::add
|
||||||
(
|
(
|
||||||
const point position,
|
const barycentric& coordinates,
|
||||||
const tetIndices& tetIs,
|
const tetIndices& tetIs,
|
||||||
const Type& value
|
const Type& value
|
||||||
)
|
)
|
||||||
@ -103,7 +103,7 @@ void Foam::AveragingMethods::Basic<Type>::add
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
Type Foam::AveragingMethods::Basic<Type>::interpolate
|
Type Foam::AveragingMethods::Basic<Type>::interpolate
|
||||||
(
|
(
|
||||||
const point position,
|
const barycentric& coordinates,
|
||||||
const tetIndices& tetIs
|
const tetIndices& tetIs
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
@ -115,7 +115,7 @@ template<class Type>
|
|||||||
typename Foam::AveragingMethods::Basic<Type>::TypeGrad
|
typename Foam::AveragingMethods::Basic<Type>::TypeGrad
|
||||||
Foam::AveragingMethods::Basic<Type>::interpolateGrad
|
Foam::AveragingMethods::Basic<Type>::interpolateGrad
|
||||||
(
|
(
|
||||||
const point position,
|
const barycentric& coordinates,
|
||||||
const tetIndices& tetIs
|
const tetIndices& tetIs
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
|
|||||||
@ -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-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2013-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -125,7 +125,7 @@ public:
|
|||||||
//- Add point value to interpolation
|
//- Add point value to interpolation
|
||||||
void add
|
void add
|
||||||
(
|
(
|
||||||
const point position,
|
const barycentric& coordinates,
|
||||||
const tetIndices& tetIs,
|
const tetIndices& tetIs,
|
||||||
const Type& value
|
const Type& value
|
||||||
);
|
);
|
||||||
@ -133,14 +133,14 @@ public:
|
|||||||
//- Interpolate
|
//- Interpolate
|
||||||
Type interpolate
|
Type interpolate
|
||||||
(
|
(
|
||||||
const point position,
|
const barycentric& coordinates,
|
||||||
const tetIndices& tetIs
|
const tetIndices& tetIs
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Interpolate gradient
|
//- Interpolate gradient
|
||||||
TypeGrad interpolateGrad
|
TypeGrad interpolateGrad
|
||||||
(
|
(
|
||||||
const point position,
|
const barycentric& coordinates,
|
||||||
const tetIndices& tetIs
|
const tetIndices& tetIs
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|||||||
@ -91,9 +91,7 @@ Foam::AveragingMethods::Dual<Type>::Dual
|
|||||||
volumeCell_(am.volumeCell_),
|
volumeCell_(am.volumeCell_),
|
||||||
volumeDual_(am.volumeDual_),
|
volumeDual_(am.volumeDual_),
|
||||||
dataCell_(FieldField<Field, Type>::operator[](0)),
|
dataCell_(FieldField<Field, Type>::operator[](0)),
|
||||||
dataDual_(FieldField<Field, Type>::operator[](1)),
|
dataDual_(FieldField<Field, Type>::operator[](1))
|
||||||
tetVertices_(am.tetVertices_),
|
|
||||||
tetCoordinates_(am.tetCoordinates_)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -106,24 +104,6 @@ Foam::AveragingMethods::Dual<Type>::~Dual()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::AveragingMethods::Dual<Type>::tetGeometry
|
|
||||||
(
|
|
||||||
const point position,
|
|
||||||
const tetIndices& tetIs
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
tetVertices_ = tetIs.faceTriIs(this->mesh_);
|
|
||||||
|
|
||||||
tetIs.tet(this->mesh_).barycentric(position, tetCoordinates_);
|
|
||||||
|
|
||||||
forAll(tetCoordinates_, i)
|
|
||||||
{
|
|
||||||
tetCoordinates_[i] = max(tetCoordinates_[i], scalar(0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::AveragingMethods::Dual<Type>::syncDualData()
|
void Foam::AveragingMethods::Dual<Type>::syncDualData()
|
||||||
{
|
{
|
||||||
@ -141,22 +121,22 @@ void Foam::AveragingMethods::Dual<Type>::syncDualData()
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::AveragingMethods::Dual<Type>::add
|
void Foam::AveragingMethods::Dual<Type>::add
|
||||||
(
|
(
|
||||||
const point position,
|
const barycentric& coordinates,
|
||||||
const tetIndices& tetIs,
|
const tetIndices& tetIs,
|
||||||
const Type& value
|
const Type& value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
tetGeometry(position, tetIs);
|
const triFace triIs(tetIs.faceTriIs(this->mesh_));
|
||||||
|
|
||||||
dataCell_[tetIs.cell()] +=
|
dataCell_[tetIs.cell()] +=
|
||||||
tetCoordinates_[0]*value
|
coordinates[0]*value
|
||||||
/ (0.25*volumeCell_[tetIs.cell()]);
|
/ (0.25*volumeCell_[tetIs.cell()]);
|
||||||
|
|
||||||
for(label i = 0; i < 3; i ++)
|
for(label i = 0; i < 3; i ++)
|
||||||
{
|
{
|
||||||
dataDual_[tetVertices_[i]] +=
|
dataDual_[triIs[i]] +=
|
||||||
tetCoordinates_[i+1]*value
|
coordinates[i+1]*value
|
||||||
/ (0.25*volumeDual_[tetVertices_[i]]);
|
/ (0.25*volumeDual_[triIs[i]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,17 +144,17 @@ void Foam::AveragingMethods::Dual<Type>::add
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
Type Foam::AveragingMethods::Dual<Type>::interpolate
|
Type Foam::AveragingMethods::Dual<Type>::interpolate
|
||||||
(
|
(
|
||||||
const point position,
|
const barycentric& coordinates,
|
||||||
const tetIndices& tetIs
|
const tetIndices& tetIs
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
tetGeometry(position, tetIs);
|
const triFace triIs(tetIs.faceTriIs(this->mesh_));
|
||||||
|
|
||||||
return
|
return
|
||||||
tetCoordinates_[0]*dataCell_[tetIs.cell()]
|
coordinates[0]*dataCell_[tetIs.cell()]
|
||||||
+ tetCoordinates_[1]*dataDual_[tetVertices_[0]]
|
+ coordinates[1]*dataDual_[triIs[0]]
|
||||||
+ tetCoordinates_[2]*dataDual_[tetVertices_[1]]
|
+ coordinates[2]*dataDual_[triIs[1]]
|
||||||
+ tetCoordinates_[3]*dataDual_[tetVertices_[2]];
|
+ coordinates[3]*dataDual_[triIs[2]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -182,11 +162,11 @@ template<class Type>
|
|||||||
typename Foam::AveragingMethods::Dual<Type>::TypeGrad
|
typename Foam::AveragingMethods::Dual<Type>::TypeGrad
|
||||||
Foam::AveragingMethods::Dual<Type>::interpolateGrad
|
Foam::AveragingMethods::Dual<Type>::interpolateGrad
|
||||||
(
|
(
|
||||||
const point position,
|
const barycentric& coordinates,
|
||||||
const tetIndices& tetIs
|
const tetIndices& tetIs
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
tetGeometry(position, tetIs);
|
const triFace triIs(tetIs.faceTriIs(this->mesh_));
|
||||||
|
|
||||||
const label celli(tetIs.cell());
|
const label celli(tetIs.cell());
|
||||||
|
|
||||||
@ -196,9 +176,9 @@ Foam::AveragingMethods::Dual<Type>::interpolateGrad
|
|||||||
(
|
(
|
||||||
tensor
|
tensor
|
||||||
(
|
(
|
||||||
this->mesh_.points()[tetVertices_[0]] - this->mesh_.C()[celli],
|
this->mesh_.points()[triIs[0]] - this->mesh_.C()[celli],
|
||||||
this->mesh_.points()[tetVertices_[1]] - this->mesh_.C()[celli],
|
this->mesh_.points()[triIs[1]] - this->mesh_.C()[celli],
|
||||||
this->mesh_.points()[tetVertices_[2]] - this->mesh_.C()[celli]
|
this->mesh_.points()[triIs[2]] - this->mesh_.C()[celli]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -207,9 +187,9 @@ Foam::AveragingMethods::Dual<Type>::interpolateGrad
|
|||||||
|
|
||||||
const TypeGrad S
|
const TypeGrad S
|
||||||
(
|
(
|
||||||
dataDual_[tetVertices_[0]],
|
dataDual_[triIs[0]],
|
||||||
dataDual_[tetVertices_[1]],
|
dataDual_[triIs[1]],
|
||||||
dataDual_[tetVertices_[2]]
|
dataDual_[triIs[2]]
|
||||||
);
|
);
|
||||||
|
|
||||||
const Type s(dataCell_[celli]);
|
const Type s(dataCell_[celli]);
|
||||||
|
|||||||
@ -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-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2013-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -90,12 +90,6 @@ private:
|
|||||||
//- Data on the points
|
//- Data on the points
|
||||||
Field<Type>& dataDual_;
|
Field<Type>& dataDual_;
|
||||||
|
|
||||||
//- Tet vertex labels
|
|
||||||
mutable FixedList<label, 3> tetVertices_;
|
|
||||||
|
|
||||||
//- Tet barycentric coordinates
|
|
||||||
mutable FixedList<scalar, 4> tetCoordinates_;
|
|
||||||
|
|
||||||
|
|
||||||
//- Private static member functions
|
//- Private static member functions
|
||||||
|
|
||||||
@ -105,13 +99,6 @@ private:
|
|||||||
|
|
||||||
//- Private member functions
|
//- Private member functions
|
||||||
|
|
||||||
//- Calculate indices and barycentric coordinates within a tetrahedron
|
|
||||||
void tetGeometry
|
|
||||||
(
|
|
||||||
const point position,
|
|
||||||
const tetIndices& tetIs
|
|
||||||
) const;
|
|
||||||
|
|
||||||
//- Sync point data over processor boundaries
|
//- Sync point data over processor boundaries
|
||||||
void syncDualData();
|
void syncDualData();
|
||||||
|
|
||||||
@ -154,7 +141,7 @@ public:
|
|||||||
//- Add point value to interpolation
|
//- Add point value to interpolation
|
||||||
void add
|
void add
|
||||||
(
|
(
|
||||||
const point position,
|
const barycentric& coordinates,
|
||||||
const tetIndices& tetIs,
|
const tetIndices& tetIs,
|
||||||
const Type& value
|
const Type& value
|
||||||
);
|
);
|
||||||
@ -162,14 +149,14 @@ public:
|
|||||||
//- Interpolate
|
//- Interpolate
|
||||||
Type interpolate
|
Type interpolate
|
||||||
(
|
(
|
||||||
const point position,
|
const barycentric& coordinates,
|
||||||
const tetIndices& tetIs
|
const tetIndices& tetIs
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Interpolate gradient
|
//- Interpolate gradient
|
||||||
TypeGrad interpolateGrad
|
TypeGrad interpolateGrad
|
||||||
(
|
(
|
||||||
const point position,
|
const barycentric& coordinates,
|
||||||
const tetIndices& tetIs
|
const tetIndices& tetIs
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|||||||
@ -128,21 +128,22 @@ void Foam::AveragingMethods::Moment<Type>::updateGrad()
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::AveragingMethods::Moment<Type>::add
|
void Foam::AveragingMethods::Moment<Type>::add
|
||||||
(
|
(
|
||||||
const point position,
|
const barycentric& coordinates,
|
||||||
const tetIndices& tetIs,
|
const tetIndices& tetIs,
|
||||||
const Type& value
|
const Type& value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const label celli = tetIs.cell();
|
const label celli = tetIs.cell();
|
||||||
|
const triFace triIs = tetIs.faceTriIs(this->mesh_);
|
||||||
|
|
||||||
|
const point delta =
|
||||||
|
(coordinates[0] - 1)*this->mesh_.C()[celli]
|
||||||
|
+ coordinates[1]*this->mesh_.points()[triIs[0]]
|
||||||
|
+ coordinates[2]*this->mesh_.points()[triIs[1]]
|
||||||
|
+ coordinates[3]*this->mesh_.points()[triIs[2]];
|
||||||
|
|
||||||
const Type v = value/this->mesh_.V()[celli];
|
const Type v = value/this->mesh_.V()[celli];
|
||||||
const TypeGrad dv =
|
const TypeGrad dv = transform_[celli] & (v*delta/scale_[celli]);
|
||||||
transform_[celli]
|
|
||||||
& (
|
|
||||||
v
|
|
||||||
* (position - this->mesh_.C()[celli])
|
|
||||||
/ scale_[celli]
|
|
||||||
);
|
|
||||||
|
|
||||||
data_[celli] += v;
|
data_[celli] += v;
|
||||||
dataX_[celli] += v + dv.x();
|
dataX_[celli] += v + dv.x();
|
||||||
@ -154,11 +155,18 @@ void Foam::AveragingMethods::Moment<Type>::add
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
Type Foam::AveragingMethods::Moment<Type>::interpolate
|
Type Foam::AveragingMethods::Moment<Type>::interpolate
|
||||||
(
|
(
|
||||||
const point position,
|
const barycentric& coordinates,
|
||||||
const tetIndices& tetIs
|
const tetIndices& tetIs
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const label celli = tetIs.cell();
|
const label celli = tetIs.cell();
|
||||||
|
const triFace triIs = tetIs.faceTriIs(this->mesh_);
|
||||||
|
|
||||||
|
const point delta =
|
||||||
|
(coordinates[0] - 1)*this->mesh_.C()[celli]
|
||||||
|
+ coordinates[1]*this->mesh_.points()[triIs[0]]
|
||||||
|
+ coordinates[2]*this->mesh_.points()[triIs[1]]
|
||||||
|
+ coordinates[3]*this->mesh_.points()[triIs[2]];
|
||||||
|
|
||||||
return
|
return
|
||||||
data_[celli]
|
data_[celli]
|
||||||
@ -169,8 +177,7 @@ Type Foam::AveragingMethods::Moment<Type>::interpolate
|
|||||||
dataY_[celli] - data_[celli],
|
dataY_[celli] - data_[celli],
|
||||||
dataZ_[celli] - data_[celli]
|
dataZ_[celli] - data_[celli]
|
||||||
)
|
)
|
||||||
& (position - this->mesh_.C()[celli])
|
& delta/scale_[celli]
|
||||||
/ scale_[celli]
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +186,7 @@ template<class Type>
|
|||||||
typename Foam::AveragingMethods::Moment<Type>::TypeGrad
|
typename Foam::AveragingMethods::Moment<Type>::TypeGrad
|
||||||
Foam::AveragingMethods::Moment<Type>::interpolateGrad
|
Foam::AveragingMethods::Moment<Type>::interpolateGrad
|
||||||
(
|
(
|
||||||
const point position,
|
const barycentric& coordinates,
|
||||||
const tetIndices& tetIs
|
const tetIndices& tetIs
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
|
|||||||
@ -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-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2013-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -138,7 +138,7 @@ public:
|
|||||||
//- Add point value to interpolation
|
//- Add point value to interpolation
|
||||||
void add
|
void add
|
||||||
(
|
(
|
||||||
const point position,
|
const barycentric& coordinates,
|
||||||
const tetIndices& tetIs,
|
const tetIndices& tetIs,
|
||||||
const Type& value
|
const Type& value
|
||||||
);
|
);
|
||||||
@ -146,14 +146,14 @@ public:
|
|||||||
//- Interpolate
|
//- Interpolate
|
||||||
Type interpolate
|
Type interpolate
|
||||||
(
|
(
|
||||||
const point position,
|
const barycentric& coordinates,
|
||||||
const tetIndices& tetIs
|
const tetIndices& tetIs
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Interpolate gradient
|
//- Interpolate gradient
|
||||||
TypeGrad interpolateGrad
|
TypeGrad interpolateGrad
|
||||||
(
|
(
|
||||||
const point position,
|
const barycentric& coordinates,
|
||||||
const tetIndices& tetIs
|
const tetIndices& tetIs
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|||||||
@ -142,9 +142,9 @@ Foam::vector Foam::DampingModels::Relaxation<CloudType>::velocityCorrection
|
|||||||
const tetIndices tetIs(p.currentTetIndices());
|
const tetIndices tetIs(p.currentTetIndices());
|
||||||
|
|
||||||
const scalar x =
|
const scalar x =
|
||||||
deltaT*oneByTimeScaleAverage_->interpolate(p.position(), tetIs);
|
deltaT*oneByTimeScaleAverage_->interpolate(p.coordinates(), tetIs);
|
||||||
|
|
||||||
const vector u = uAverage_->interpolate(p.position(), tetIs);
|
const vector u = uAverage_->interpolate(p.coordinates(), tetIs);
|
||||||
|
|
||||||
return (u - p.U())*x/(x + 2.0);
|
return (u - p.U())*x/(x + 2.0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -168,15 +168,15 @@ void Foam::IsotropyModels::Stochastic<CloudType>::calculate()
|
|||||||
typename CloudType::parcelType& p = iter();
|
typename CloudType::parcelType& p = iter();
|
||||||
const tetIndices tetIs(p.currentTetIndices());
|
const tetIndices tetIs(p.currentTetIndices());
|
||||||
|
|
||||||
const scalar x = exponentAverage.interpolate(p.position(), tetIs);
|
const scalar x = exponentAverage.interpolate(p.coordinates(), tetIs);
|
||||||
|
|
||||||
if (x < rndGen.sample01<scalar>())
|
if (x < rndGen.sample01<scalar>())
|
||||||
{
|
{
|
||||||
const vector r(sampleGauss(), sampleGauss(), sampleGauss());
|
const vector r(sampleGauss(), sampleGauss(), sampleGauss());
|
||||||
|
|
||||||
const vector u = uAverage.interpolate(p.position(), tetIs);
|
const vector u = uAverage.interpolate(p.coordinates(), tetIs);
|
||||||
const scalar uRms =
|
const scalar uRms =
|
||||||
sqrt(max(uSqrAverage.interpolate(p.position(), tetIs), 0.0));
|
sqrt(max(uSqrAverage.interpolate(p.coordinates(), tetIs), 0.0));
|
||||||
|
|
||||||
p.U() = u + r*uRms*oneBySqrtThree;
|
p.U() = u + r*uRms*oneBySqrtThree;
|
||||||
}
|
}
|
||||||
@ -202,7 +202,7 @@ void Foam::IsotropyModels::Stochastic<CloudType>::calculate()
|
|||||||
{
|
{
|
||||||
typename CloudType::parcelType& p = iter();
|
typename CloudType::parcelType& p = iter();
|
||||||
const tetIndices tetIs(p.currentTetIndices());
|
const tetIndices tetIs(p.currentTetIndices());
|
||||||
uTildeAverage.add(p.position(), tetIs, p.nParticle()*p.mass()*p.U());
|
uTildeAverage.add(p.coordinates(), tetIs, p.nParticle()*p.mass()*p.U());
|
||||||
}
|
}
|
||||||
uTildeAverage.average(massAverage);
|
uTildeAverage.average(massAverage);
|
||||||
|
|
||||||
@ -225,10 +225,10 @@ void Foam::IsotropyModels::Stochastic<CloudType>::calculate()
|
|||||||
{
|
{
|
||||||
typename CloudType::parcelType& p = iter();
|
typename CloudType::parcelType& p = iter();
|
||||||
const tetIndices tetIs(p.currentTetIndices());
|
const tetIndices tetIs(p.currentTetIndices());
|
||||||
const vector uTilde = uTildeAverage.interpolate(p.position(), tetIs);
|
const vector uTilde = uTildeAverage.interpolate(p.coordinates(), tetIs);
|
||||||
uTildeSqrAverage.add
|
uTildeSqrAverage.add
|
||||||
(
|
(
|
||||||
p.position(),
|
p.coordinates(),
|
||||||
tetIs,
|
tetIs,
|
||||||
p.nParticle()*p.mass()*magSqr(p.U() - uTilde)
|
p.nParticle()*p.mass()*magSqr(p.U() - uTilde)
|
||||||
);
|
);
|
||||||
@ -241,13 +241,16 @@ void Foam::IsotropyModels::Stochastic<CloudType>::calculate()
|
|||||||
typename CloudType::parcelType& p = iter();
|
typename CloudType::parcelType& p = iter();
|
||||||
const tetIndices tetIs(p.currentTetIndices());
|
const tetIndices tetIs(p.currentTetIndices());
|
||||||
|
|
||||||
const vector u = uAverage.interpolate(p.position(), tetIs);
|
const vector u = uAverage.interpolate(p.coordinates(), tetIs);
|
||||||
const scalar uRms =
|
const scalar uRms =
|
||||||
sqrt(max(uSqrAverage.interpolate(p.position(), tetIs), 0.0));
|
sqrt(max(uSqrAverage.interpolate(p.coordinates(), tetIs), 0.0));
|
||||||
|
|
||||||
const vector uTilde = uTildeAverage.interpolate(p.position(), tetIs);
|
const vector uTilde = uTildeAverage.interpolate(p.coordinates(), tetIs);
|
||||||
const scalar uTildeRms =
|
const scalar uTildeRms =
|
||||||
sqrt(max(uTildeSqrAverage.interpolate(p.position(), tetIs), 0.0));
|
sqrt
|
||||||
|
(
|
||||||
|
max(uTildeSqrAverage.interpolate(p.coordinates(), tetIs), 0.0)
|
||||||
|
);
|
||||||
|
|
||||||
p.U() = u + (p.U() - uTilde)*uRms/max(uTildeRms, SMALL);
|
p.U() = u + (p.U() - uTilde)*uRms/max(uTildeRms, SMALL);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -147,15 +147,15 @@ Foam::vector Foam::PackingModels::Explicit<CloudType>::velocityCorrection
|
|||||||
|
|
||||||
// interpolated quantities
|
// interpolated quantities
|
||||||
const scalar alpha =
|
const scalar alpha =
|
||||||
this->volumeAverage_->interpolate(p.position(), tetIs);
|
this->volumeAverage_->interpolate(p.coordinates(), tetIs);
|
||||||
const vector alphaGrad =
|
const vector alphaGrad =
|
||||||
this->volumeAverage_->interpolateGrad(p.position(), tetIs);
|
this->volumeAverage_->interpolateGrad(p.coordinates(), tetIs);
|
||||||
const vector uMean =
|
const vector uMean =
|
||||||
this->uAverage_->interpolate(p.position(), tetIs);
|
this->uAverage_->interpolate(p.coordinates(), tetIs);
|
||||||
|
|
||||||
// stress gradient
|
// stress gradient
|
||||||
const vector tauGrad =
|
const vector tauGrad =
|
||||||
stressAverage_->interpolateGrad(p.position(), tetIs);
|
stressAverage_->interpolateGrad(p.coordinates(), tetIs);
|
||||||
|
|
||||||
// parcel relative velocity
|
// parcel relative velocity
|
||||||
const vector uRelative = p.U() - uMean;
|
const vector uRelative = p.U() - uMean;
|
||||||
|
|||||||
@ -339,9 +339,6 @@ Foam::vector Foam::PackingModels::Implicit<CloudType>::velocityCorrection
|
|||||||
// containing tetrahedron and parcel coordinates within
|
// containing tetrahedron and parcel coordinates within
|
||||||
const label celli = p.cell();
|
const label celli = p.cell();
|
||||||
const label facei = p.tetFace();
|
const label facei = p.tetFace();
|
||||||
const tetIndices tetIs(p.currentTetIndices());
|
|
||||||
FixedList<scalar, 4> tetCoordinates;
|
|
||||||
tetIs.tet(mesh).barycentric(p.position(), tetCoordinates);
|
|
||||||
|
|
||||||
// cell velocity
|
// cell velocity
|
||||||
const vector U = uCorrect_()[celli];
|
const vector U = uCorrect_()[celli];
|
||||||
@ -368,7 +365,7 @@ Foam::vector Foam::PackingModels::Implicit<CloudType>::velocityCorrection
|
|||||||
}
|
}
|
||||||
|
|
||||||
// interpolant equal to 1 at the cell centre and 0 at the face
|
// interpolant equal to 1 at the cell centre and 0 at the face
|
||||||
const scalar t = tetCoordinates[0];
|
const scalar t = p.coordinates()[0];
|
||||||
|
|
||||||
// the normal component of the velocity correction is interpolated linearly
|
// the normal component of the velocity correction is interpolated linearly
|
||||||
// the tangential component is equal to that at the cell centre
|
// the tangential component is equal to that at the cell centre
|
||||||
|
|||||||
Reference in New Issue
Block a user