Skip to content
Snippets Groups Projects
Commit 7fa1ff79 authored by graham's avatar graham
Browse files

ENH: Adding HdotGradH interpolator to particleForces.

parent dcb348dd
No related merge requests found
...@@ -42,7 +42,7 @@ template<class ParcelType> ...@@ -42,7 +42,7 @@ template<class ParcelType>
void Foam::KinematicCloud<ParcelType>::preEvolve() void Foam::KinematicCloud<ParcelType>::preEvolve()
{ {
this->dispersion().cacheFields(true); this->dispersion().cacheFields(true);
forces_.cacheFields(true); forces_.cacheFields(true, interpolationSchemes_);
} }
...@@ -152,7 +152,7 @@ void Foam::KinematicCloud<ParcelType>::postEvolve() ...@@ -152,7 +152,7 @@ void Foam::KinematicCloud<ParcelType>::postEvolve()
} }
this->dispersion().cacheFields(false); this->dispersion().cacheFields(false);
forces_.cacheFields(false); forces_.cacheFields(false, interpolationSchemes_);
this->postProcessing().post(); this->postProcessing().post();
} }
......
...@@ -162,6 +162,7 @@ const Foam::vector Foam::KinematicParcel<ParcelType>::calcVelocity ...@@ -162,6 +162,7 @@ const Foam::vector Foam::KinematicParcel<ParcelType>::calcVelocity
// Momentum source due to particle forces // Momentum source due to particle forces
const vector FCoupled = mass*td.cloud().forces().calcCoupled const vector FCoupled = mass*td.cloud().forces().calcCoupled
( (
this->position(),
cellI, cellI,
dt, dt,
rhoc_, rhoc_,
...@@ -173,6 +174,7 @@ const Foam::vector Foam::KinematicParcel<ParcelType>::calcVelocity ...@@ -173,6 +174,7 @@ const Foam::vector Foam::KinematicParcel<ParcelType>::calcVelocity
const vector FNonCoupled = mass*td.cloud().forces().calcNonCoupled const vector FNonCoupled = mass*td.cloud().forces().calcNonCoupled
( (
this->position(),
cellI, cellI,
dt, dt,
rhoc_, rhoc_,
......
...@@ -30,6 +30,24 @@ License ...@@ -30,6 +30,24 @@ License
#include "mathematicalConstants.H" #include "mathematicalConstants.H"
#include "electromagneticConstants.H" #include "electromagneticConstants.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::particleForces::deleteFields()
{
if (gradUPtr_)
{
delete gradUPtr_;
gradUPtr_ = NULL;
}
if (HdotGradHInterPtr_)
{
delete HdotGradHInterPtr_;
HdotGradHInterPtr_ = NULL;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::particleForces::particleForces Foam::particleForces::particleForces
...@@ -85,7 +103,7 @@ Foam::particleForces::particleForces(const particleForces& f) ...@@ -85,7 +103,7 @@ Foam::particleForces::particleForces(const particleForces& f)
Foam::particleForces::~particleForces() Foam::particleForces::~particleForces()
{ {
cacheFields(false); deleteFields();
} }
...@@ -151,26 +169,46 @@ const Foam::word& Foam::particleForces::HdotGradHName() const ...@@ -151,26 +169,46 @@ const Foam::word& Foam::particleForces::HdotGradHName() const
} }
void Foam::particleForces::cacheFields(const bool store) void Foam::particleForces::cacheFields
(
const bool store,
const dictionary& interpolationSchemes
)
{ {
if (store && pressureGradient_) if (store)
{ {
const volVectorField& U = mesh_.lookupObject<volVectorField>(UName_); if (pressureGradient_)
gradUPtr_ = fvc::grad(U).ptr(); {
const volVectorField& U =
mesh_.lookupObject<volVectorField>(UName_);
gradUPtr_ = fvc::grad(U).ptr();
}
if (paramagnetic_)
{
const volVectorField& HdotGradH = mesh_.lookupObject<volVectorField>
(
HdotGradHName_
);
HdotGradHInterPtr_ = interpolation<vector>::New
(
interpolationSchemes,
HdotGradH
).ptr();
}
} }
else else
{ {
if (gradUPtr_) deleteFields();
{
delete gradUPtr_;
gradUPtr_ = NULL;
}
} }
} }
Foam::vector Foam::particleForces::calcCoupled Foam::vector Foam::particleForces::calcCoupled
( (
const vector& position,
const label cellI, const label cellI,
const scalar dt, const scalar dt,
const scalar rhoc, const scalar rhoc,
...@@ -205,6 +243,7 @@ Foam::vector Foam::particleForces::calcCoupled ...@@ -205,6 +243,7 @@ Foam::vector Foam::particleForces::calcCoupled
Foam::vector Foam::particleForces::calcNonCoupled Foam::vector Foam::particleForces::calcNonCoupled
( (
const vector& position,
const label cellI, const label cellI,
const scalar dt, const scalar dt,
const scalar rhoc, const scalar rhoc,
...@@ -226,15 +265,12 @@ Foam::vector Foam::particleForces::calcNonCoupled ...@@ -226,15 +265,12 @@ Foam::vector Foam::particleForces::calcNonCoupled
if (paramagnetic_) if (paramagnetic_)
{ {
const volVectorField& HdotGradH = mesh_.lookupObject<volVectorField> const interpolation<vector>& HdotGradHInter = *HdotGradHInterPtr_;
(
HdotGradHName_
);
accelTot += accelTot +=
3.0*constant::electromagnetic::mu0.value()/rho 3.0*constant::electromagnetic::mu0.value()/rho
*magneticSusceptibility_/(magneticSusceptibility_ + 3) *magneticSusceptibility_/(magneticSusceptibility_ + 3)
*HdotGradH[cellI]; *HdotGradHInter.interpolate(position, cellI);
// force is: // force is:
......
...@@ -40,6 +40,7 @@ SourceFiles ...@@ -40,6 +40,7 @@ SourceFiles
#include "Switch.H" #include "Switch.H"
#include "vector.H" #include "vector.H"
#include "volFieldsFwd.H" #include "volFieldsFwd.H"
#include "interpolation.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...@@ -69,6 +70,9 @@ class particleForces ...@@ -69,6 +70,9 @@ class particleForces
//- Velocity gradient field //- Velocity gradient field
const volTensorField* gradUPtr_; const volTensorField* gradUPtr_;
//- HdotGradH interpolator
const interpolation<vector>* HdotGradHInterPtr_;
// Forces to include in particle motion evaluation // Forces to include in particle motion evaluation
...@@ -101,6 +105,12 @@ class particleForces ...@@ -101,6 +105,12 @@ class particleForces
const word HdotGradHName_; const word HdotGradHName_;
// Private Member Functions
//- Delete cached carrier fields
void deleteFields();
public: public:
// Constructors // Constructors
...@@ -159,11 +169,16 @@ public: ...@@ -159,11 +169,16 @@ public:
// Evaluation // Evaluation
//- Cache carrier fields //- Cache carrier fields
void cacheFields(const bool store); void cacheFields
(
const bool store,
const dictionary& interpolationSchemes
);
//- Calculate action/reaction forces between carrier and particles //- Calculate action/reaction forces between carrier and particles
vector calcCoupled vector calcCoupled
( (
const vector& position,
const label cellI, const label cellI,
const scalar dt, const scalar dt,
const scalar rhoc, const scalar rhoc,
...@@ -176,6 +191,7 @@ public: ...@@ -176,6 +191,7 @@ public:
//- Calculate external forces applied to the particles //- Calculate external forces applied to the particles
vector calcNonCoupled vector calcNonCoupled
( (
const vector& position,
const label cellI, const label cellI,
const scalar dt, const scalar dt,
const scalar rhoc, const scalar rhoc,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment