Commit febecdcc authored by mattijs's avatar mattijs
Browse files

Merge branch 'master' of /home/noisy3/OpenFOAM/OpenFOAM-dev

parents 8551bfd3 35f74367
Info<< "Reading transportProperties\n" << endl;
Info<< "\nReading transportProperties\n" << endl;
IOdictionary transportProperties
(
......@@ -31,7 +31,7 @@
rhoInfValue
);
Info<< "\nReading field U\n" << endl;
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
......@@ -127,7 +127,7 @@
if (HdotGradHheader.headerOk())
{
Info<< "\nReading field HdotGradH\n" << endl;
Info<< "Reading field HdotGradH" << endl;
HdotGradHPtr_.reset
(
......
......@@ -110,13 +110,11 @@ class timeVaryingMappedFixedValueFvPatchField
label& hi
) const;
//- Read boundary points and determine interpolation weights to patch
// faceCentres
void readSamplePoints();
//- Find boundary data inbetween current time and interpolate
void checkTable();
//- Do actual interpolation using current weights
tmp<Field<Type> > interpolate(const Field<Type>&) const;
......@@ -199,6 +197,12 @@ public:
return referenceCS_;
}
//- Return startSampledValues
const Field<Type> startSampledValues()
{
return startSampledValues_;
}
// Mapping functions
......@@ -216,6 +220,12 @@ public:
);
// Utility functions
//- Find boundary data inbetween current time and interpolate
void checkTable();
// Evaluation functions
//- Update the coefficients associated with the patch field
......
......@@ -287,10 +287,13 @@ public:
wallFaceIndexAndTransformToDistribute() const;
//- Return access to the referred wall faces
const List<referredWallFace>& referredWallFaces() const;
inline const List<referredWallFace>& referredWallFaces() const;
//- Return the name of the velocity field
inline const word& UName() const;
//- Return access to the referred wall data
const List<vector>& referredWallData() const;
inline const List<vector>& referredWallData() const;
//- Return access to the referred particle container
inline const List<IDLList<ParticleType> >&
......
......@@ -128,6 +128,13 @@ Foam::InteractionLists<ParticleType>::referredWallFaces() const
}
template<class ParticleType>
const Foam::word& Foam::InteractionLists<ParticleType>::UName() const
{
return UName_;
}
template<class ParticleType>
const Foam::List<Foam::vector>&
Foam::InteractionLists<ParticleType>::referredWallData() const
......
......@@ -42,7 +42,7 @@ template<class ParcelType>
void Foam::KinematicCloud<ParcelType>::preEvolve()
{
this->dispersion().cacheFields(true);
forces_.cacheFields(true);
forces_.cacheFields(true, interpolationSchemes_);
}
......@@ -152,7 +152,7 @@ void Foam::KinematicCloud<ParcelType>::postEvolve()
}
this->dispersion().cacheFields(false);
forces_.cacheFields(false);
forces_.cacheFields(false, interpolationSchemes_);
this->postProcessing().post();
}
......
......@@ -162,6 +162,7 @@ const Foam::vector Foam::KinematicParcel<ParcelType>::calcVelocity
// Momentum source due to particle forces
const vector FCoupled = mass*td.cloud().forces().calcCoupled
(
this->position(),
cellI,
dt,
rhoc_,
......@@ -173,6 +174,7 @@ const Foam::vector Foam::KinematicParcel<ParcelType>::calcVelocity
const vector FNonCoupled = mass*td.cloud().forces().calcNonCoupled
(
this->position(),
cellI,
dt,
rhoc_,
......
......@@ -182,8 +182,8 @@ public:
// Constructors
//- Construct from components
inline trackData
//- Construct from components
inline trackData
(
KinematicCloud<ParcelType>& cloud,
const constantProperties& constProps,
......
......@@ -439,14 +439,23 @@ inline Foam::scalar Foam::KinematicParcel<ParcelType>::wallImpactDistance
const vector&
) const
{
// Do not use a wall impact distance to allow proper multiple face
// collisions. In a twisted mesh the particle can be within range
// of a wall but not in the cell attached to a wall face, hence
// miss the interaction.
const KinematicCloud<ParcelType>& c =
dynamic_cast<const KinematicCloud<ParcelType>&>(this->cloud());
return 0.0;
if (c.collision().controlsWallInteraction())
{
// Do not use a wall impact distance if the collision model
// controls wall interactions to allow proper multiple face
// collisions. In a twisted mesh the particle can be within
// range of a wall but not in the cell attached to a wall
// face, hence miss the interaction.
// return 0.5*d_;
return 0.0;
}
else
{
return 0.5*d_;
}
}
......
......@@ -30,6 +30,24 @@ License
#include "mathematicalConstants.H"
#include "electromagneticConstants.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::particleForces::deleteFields()
{
if (gradUPtr_)
{
delete gradUPtr_;
gradUPtr_ = NULL;
}
if (HdotGradHInterPtr_)
{
delete HdotGradHInterPtr_;
HdotGradHInterPtr_ = NULL;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::particleForces::particleForces
......@@ -85,7 +103,7 @@ Foam::particleForces::particleForces(const particleForces& f)
Foam::particleForces::~particleForces()
{
cacheFields(false);
deleteFields();
}
......@@ -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_);
gradUPtr_ = fvc::grad(U).ptr();
if (pressureGradient_)
{
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
{
if (gradUPtr_)
{
delete gradUPtr_;
gradUPtr_ = NULL;
}
deleteFields();
}
}
Foam::vector Foam::particleForces::calcCoupled
(
const vector& position,
const label cellI,
const scalar dt,
const scalar rhoc,
......@@ -205,6 +243,7 @@ Foam::vector Foam::particleForces::calcCoupled
Foam::vector Foam::particleForces::calcNonCoupled
(
const vector& position,
const label cellI,
const scalar dt,
const scalar rhoc,
......@@ -226,15 +265,12 @@ Foam::vector Foam::particleForces::calcNonCoupled
if (paramagnetic_)
{
const volVectorField& HdotGradH = mesh_.lookupObject<volVectorField>
(
HdotGradHName_
);
const interpolation<vector>& HdotGradHInter = *HdotGradHInterPtr_;
accelTot +=
3.0*constant::electromagnetic::mu0.value()/rho
*magneticSusceptibility_/(magneticSusceptibility_ + 3)
*HdotGradH[cellI];
*HdotGradHInter.interpolate(position, cellI);
// force is:
......
......@@ -40,6 +40,7 @@ SourceFiles
#include "Switch.H"
#include "vector.H"
#include "volFieldsFwd.H"
#include "interpolation.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -69,6 +70,9 @@ class particleForces
//- Velocity gradient field
const volTensorField* gradUPtr_;
//- HdotGradH interpolator
const interpolation<vector>* HdotGradHInterPtr_;
// Forces to include in particle motion evaluation
......@@ -101,6 +105,12 @@ class particleForces
const word HdotGradHName_;
// Private Member Functions
//- Delete cached carrier fields
void deleteFields();
public:
// Constructors
......@@ -159,11 +169,16 @@ public:
// Evaluation
//- Cache carrier fields
void cacheFields(const bool store);
void cacheFields
(
const bool store,
const dictionary& interpolationSchemes
);
//- Calculate action/reaction forces between carrier and particles
vector calcCoupled
(
const vector& position,
const label cellI,
const scalar dt,
const scalar rhoc,
......@@ -176,6 +191,7 @@ public:
//- Calculate external forces applied to the particles
vector calcNonCoupled
(
const vector& position,
const label cellI,
const scalar dt,
const scalar rhoc,
......
......@@ -141,6 +141,10 @@ public:
//- Flag to indicate whether model activates injection model
virtual bool active() const = 0;
//- Indicates whether model determines wall collisions or not,
// used to determine what value to use for wallImpactDistance
virtual bool controlsWallInteraction() const = 0;
// Collision function
virtual void collide() = 0;
};
......
......@@ -61,6 +61,13 @@ bool Foam::NoCollision<CloudType>::active() const
}
template<class CloudType>
bool Foam::NoCollision<CloudType>::controlsWallInteraction() const
{
return false;
}
template<class CloudType>
void Foam::NoCollision<CloudType>::collide()
{}
......
......@@ -82,6 +82,10 @@ public:
//- Flag to indicate whether model activates injection model
virtual bool active() const;
//- Indicates whether model determines wall collisions or not,
// used to determine what value to use for wallImpactDistance
virtual bool controlsWallInteraction() const;
// Collision function
virtual void collide();
};
......
......@@ -175,13 +175,20 @@ void Foam::PairCollision<CloudType>::wallInteraction()
const labelListList directWallFaces = il_.dwfil();
const labelList& patchID = mesh.boundaryMesh().patchID();
const volVectorField& U = mesh.lookupObject<volVectorField>(il_.UName());
// Storage for the wall interaction sites
DynamicList<point> flatSites;
DynamicList<point> flatSitePoints;
DynamicList<scalar> flatSiteExclusionDistancesSqr;
DynamicList<point> otherSites;
DynamicList<WallSiteData<vector> > flatSiteData;
DynamicList<point> otherSitePoints;
DynamicList<scalar> otherSiteDistances;
DynamicList<point> sharpSites;
DynamicList<WallSiteData<vector> > otherSiteData;
DynamicList<point> sharpSitePoints;
DynamicList<scalar> sharpSiteExclusionDistancesSqr;
DynamicList<WallSiteData<vector> > sharpSiteData;
forAll(dil, realCellI)
{
......@@ -191,19 +198,22 @@ void Foam::PairCollision<CloudType>::wallInteraction()
// Loop over all Parcels in cell
forAll(cellOccupancy_[realCellI], cellParticleI)
{
flatSites.clear();
flatSitePoints.clear();
flatSiteExclusionDistancesSqr.clear();
otherSites.clear();
flatSiteData.clear();
otherSitePoints.clear();
otherSiteDistances.clear();
sharpSites.clear();
otherSiteData.clear();
sharpSitePoints.clear();
sharpSiteExclusionDistancesSqr.clear();
sharpSiteData.clear();
typename CloudType::parcelType& p =
*cellOccupancy_[realCellI][cellParticleI];
*cellOccupancy_[realCellI][cellParticleI];
const point& pos = p.position();
scalar r = p.d()/2;
scalar r = wallModel_->pREff(p);
// real wallFace interactions
......@@ -229,6 +239,18 @@ void Foam::PairCollision<CloudType>::wallInteraction()
scalar normalAlignment = normal & pW/mag(pW);
// Find the patchIndex and wallData for WallSiteData object
label patchI = patchID[realFaceI - mesh.nInternalFaces()];
label patchFaceI =
realFaceI - mesh.boundaryMesh()[patchI].start();
WallSiteData<vector> wSD
(
patchI,
U.boundaryField()[patchI][patchFaceI]
);
if (normalAlignment > cosPhiMinFlatWall)
{
// Guard against a flat interaction being
......@@ -239,25 +261,29 @@ void Foam::PairCollision<CloudType>::wallInteraction()
(
!duplicatePointInList
(
flatSites,
flatSitePoints,
nearPt,
sqr(r*flatWallDuplicateExclusion)
)
)
{
flatSites.append(nearPt);
flatSitePoints.append(nearPt);
flatSiteExclusionDistancesSqr.append
(
sqr(r) - sqr(nearest.distance())
);
flatSiteData.append(wSD);
}
}
else
{
otherSites.append(nearPt);
otherSitePoints.append(nearPt);
otherSiteDistances.append(nearest.distance());
otherSiteData.append(wSD);
}
}
}
......@@ -269,8 +295,10 @@ void Foam::PairCollision<CloudType>::wallInteraction()
forAll(cellRefWallFaces, rWFI)
{
label refWallFaceI = cellRefWallFaces[rWFI];
const referredWallFace& rwf =
il_.referredWallFaces()[cellRefWallFaces[rWFI]];
il_.referredWallFaces()[refWallFaceI];
const pointField& pts = rwf.points();
......@@ -288,6 +316,14 @@ void Foam::PairCollision<CloudType>::wallInteraction()
scalar normalAlignment = normal & pW/mag(pW);
// Find the patchIndex and wallData for WallSiteData object
WallSiteData<vector> wSD
(
rwf.patchIndex(),
il_.referredWallData()[refWallFaceI]
);
if (normalAlignment > cosPhiMinFlatWall)
{
// Guard against a flat interaction being
......@@ -298,25 +334,29 @@ void Foam::PairCollision<CloudType>::wallInteraction()
(
!duplicatePointInList
(
flatSites,
flatSitePoints,
nearPt,
sqr(r*flatWallDuplicateExclusion)
)
)
{
flatSites.append(nearPt);
flatSitePoints.append(nearPt);
flatSiteExclusionDistancesSqr.append
(
sqr(r) - sqr(nearest.distance())
);
flatSiteData.append(wSD);
}
}
else
{
otherSites.append(nearPt);
otherSitePoints.append(nearPt);
otherSiteDistances.append(nearest.distance());
otherSiteData.append(wSD);
}
}
}
......@@ -338,13 +378,13 @@ void Foam::PairCollision<CloudType>::wallInteraction()
{
label orderedIndex = sortedOtherSiteIndices[siteI];
const point& otherPt = otherSites[orderedIndex];
const point& otherPt = otherSitePoints[orderedIndex];
if
(
!duplicatePointInList
(
flatSites,
flatSitePoints,
otherPt,
flatSiteExclusionDistancesSqr
)
......@@ -357,23 +397,32 @@ void Foam::PairCollision<CloudType>::wallInteraction()
(
!duplicatePointInList
(
sharpSites,
sharpSitePoints,
otherPt,
sharpSiteExclusionDistancesSqr
)
)
{
sharpSites.append(otherPt);
sharpSitePoints.append(otherPt);
sharpSiteExclusionDistancesSqr.append
(
sqr(r) - sqr(otherSiteDistances[orderedIndex])
);
sharpSiteData.append(otherSiteData[orderedIndex]);
}
}
}
evaluateWall(p, flatSites, sharpSites);
evaluateWall
(
p,
flatSitePoints,
flatSiteData,
sharpSitePoints,
sharpSiteData