ENH: InteractionLists/CollisionModel. Referring wall data, creating

referredWallFace class to hold patch information was well as face and
pointField.
This commit is contained in:
graham
2010-04-16 19:04:06 +01:00
parent 014fbd603d
commit adb9389846
11 changed files with 487 additions and 66 deletions

View File

@ -372,7 +372,8 @@ void Foam::InteractionLists<ParticleType>::fillReferredParticleCloud()
{ {
forAll(referredParticles_, refCellI) forAll(referredParticles_, refCellI)
{ {
const IDLList<ParticleType>& refCell = referredParticles_[refCellI]; const IDLList<ParticleType>& refCell =
referredParticles_[refCellI];
forAllConstIter(typename IDLList<ParticleType>, refCell, iter) forAllConstIter(typename IDLList<ParticleType>, refCell, iter)
{ {
@ -383,6 +384,43 @@ void Foam::InteractionLists<ParticleType>::fillReferredParticleCloud()
} }
template<class ParticleType>
void Foam::InteractionLists<ParticleType>::prepareWallDataToRefer()
{
referredWallData_.setSize
(
wallFaceIndexAndTransformToDistribute_.size()
);
const volVectorField& U = mesh_.lookupObject<volVectorField>(UName_);
forAll(referredWallData_, rWVI)
{
const labelPair& wfiat = wallFaceIndexAndTransformToDistribute_[rWVI];
label wallFaceIndex = globalTransforms_.index(wfiat);
// const vector& transform = globalTransforms_.transform
// (
// globalTransforms_.transformIndex(wfiat)
// );
label patchI = mesh_.boundaryMesh().patchID()
[
wallFaceIndex - mesh_.nInternalFaces()
];
label patchFaceI =
wallFaceIndex
- mesh_.boundaryMesh()[patchI].start();
// Need to transform velocity when tensor transforms are
// supported
referredWallData_[rWVI] = U.boundaryField()[patchI][patchFaceI];
}
}
template<class ParticleType> template<class ParticleType>
void Foam::InteractionLists<ParticleType>::writeReferredWallFaces() const void Foam::InteractionLists<ParticleType>::writeReferredWallFaces() const
{ {
@ -394,27 +432,23 @@ void Foam::InteractionLists<ParticleType>::writeReferredWallFaces() const
forAll(referredWallFaces_, rWFI) forAll(referredWallFaces_, rWFI)
{ {
const Tuple2<face, pointField>& rwf = referredWallFaces_[rWFI]; const referredWallFace& rwf = referredWallFaces_[rWFI];
forAll(rwf.first(), fPtI) forAll(rwf, fPtI)
{ {
meshTools::writeOBJ meshTools::writeOBJ(str, rwf.points()[rwf[fPtI]]);
(
str,
rwf.second()[rwf.first()[fPtI]]
);
} }
str<< 'f'; str<< 'f';
forAll(rwf.first(), fPtI) forAll(rwf, fPtI)
{ {
str<< ' ' << fPtI + offset; str<< ' ' << fPtI + offset;
} }
str<< nl; str<< nl;
offset += rwf.first().size(); offset += rwf.size();
} }
} }
@ -426,7 +460,8 @@ Foam::InteractionLists<ParticleType>::InteractionLists
( (
const polyMesh& mesh, const polyMesh& mesh,
scalar maxDistance, scalar maxDistance,
Switch writeCloud Switch writeCloud,
const word& UName
) )
: :
mesh_(mesh), mesh_(mesh),
@ -443,9 +478,12 @@ Foam::InteractionLists<ParticleType>::InteractionLists
cellIndexAndTransformToDistribute_(), cellIndexAndTransformToDistribute_(),
wallFaceIndexAndTransformToDistribute_(), wallFaceIndexAndTransformToDistribute_(),
referredWallFaces_(), referredWallFaces_(),
UName_(UName),
referredWallData_(),
referredParticles_() referredParticles_()
{ {
Info<< "Building InteractionLists" << endl; Info<< "Building InteractionLists with interaction distance "
<< maxDistance_ << endl;
Random rndGen(419715); Random rndGen(419715);
@ -704,6 +742,10 @@ Foam::InteractionLists<ParticleType>::InteractionLists
// Determine which wall faces to refer // Determine which wall faces to refer
// The referring of wall patch data relies on patches having the same
// index on each processor.
mesh_.boundaryMesh().checkParallelSync(true);
// Determine the index of all of the wall faces on this processor // Determine the index of all of the wall faces on this processor
DynamicList<label> localWallFaces; DynamicList<label> localWallFaces;
@ -913,9 +955,9 @@ Foam::InteractionLists<ParticleType>::InteractionLists
// Refer wall faces to the appropriate processor // Refer wall faces to the appropriate processor
referredWallFaces_.setSize(wallFaceIndexAndTransformToDistribute_.size()); referredWallFaces_.setSize(wallFaceIndexAndTransformToDistribute_.size());
forAll(referredWallFaces_, rwfI) forAll(referredWallFaces_, rWFI)
{ {
const labelPair& wfiat = wallFaceIndexAndTransformToDistribute_[rwfI]; const labelPair& wfiat = wallFaceIndexAndTransformToDistribute_[rWFI];
label wallFaceIndex = globalTransforms_.index(wfiat); label wallFaceIndex = globalTransforms_.index(wfiat);
@ -924,18 +966,19 @@ Foam::InteractionLists<ParticleType>::InteractionLists
globalTransforms_.transformIndex(wfiat) globalTransforms_.transformIndex(wfiat)
); );
Tuple2<face, pointField>& rwf = referredWallFaces_[rwfI]; const face& f = mesh_.faces()[wallFaceIndex];
const labelList& facePts = mesh_.faces()[wallFaceIndex]; label patchI = mesh_.boundaryMesh().patchID()
[
wallFaceIndex - mesh_.nInternalFaces()
];
rwf.first() = face(identity(facePts.size())); referredWallFaces_[rWFI] = referredWallFace
(
rwf.second().setSize(facePts.size()); face(identity(f.size())),
f.points(mesh_.points()) - transform,
forAll(facePts, fPtI) patchI
{ );
rwf.second()[fPtI] = mesh_.points()[facePts[fPtI]] - transform;
}
} }
wallFaceMap().distribute(referredWallFaces_); wallFaceMap().distribute(referredWallFaces_);
@ -1034,6 +1077,8 @@ void Foam::InteractionLists<ParticleType>::sendReferredData
PstreamBuffers& pBufs PstreamBuffers& pBufs
) )
{ {
prepareWallDataToRefer();
prepareParticlesToRefer(cellOccupancy); prepareParticlesToRefer(cellOccupancy);
for (label domain = 0; domain < Pstream::nProcs(); domain++) for (label domain = 0; domain < Pstream::nProcs(); domain++)
@ -1057,8 +1102,10 @@ void Foam::InteractionLists<ParticleType>::sendReferredData
} }
} }
// Start sending and receiving but do not block. // Using the mapDistribute to start sending and receiving the
pBufs.finishedSends(false); // buffer but not block, i.e. it is calling
// pBufs.finishedSends(false);
wallFaceMap().send(pBufs, referredWallData_);
}; };
@ -1092,6 +1139,8 @@ void Foam::InteractionLists<ParticleType>::receiveReferredData
} }
fillReferredParticleCloud(); fillReferredParticleCloud();
wallFaceMap().receive(pBufs, referredWallData_);
} }

View File

@ -61,6 +61,7 @@ SourceFiles
#include "polyMesh.H" #include "polyMesh.H"
#include "globalIndexAndTransform.H" #include "globalIndexAndTransform.H"
#include "referredWallFace.H"
#include "indexedOctree.H" #include "indexedOctree.H"
#include "Tuple2.H" #include "Tuple2.H"
#include "treeDataCell.H" #include "treeDataCell.H"
@ -142,7 +143,13 @@ class InteractionLists
List<labelPair> wallFaceIndexAndTransformToDistribute_; List<labelPair> wallFaceIndexAndTransformToDistribute_;
//- Referred wall faces //- Referred wall faces
List<Tuple2<face, pointField> > referredWallFaces_; List<referredWallFace> referredWallFaces_;
//- Velocity field name, default to "U"
const word UName_;
//- Referred wall face velocity field values;
List<vector> referredWallData_;
//- Referred particle container //- Referred particle container
List<IDLList<ParticleType> > referredParticles_; List<IDLList<ParticleType> > referredParticles_;
@ -187,6 +194,10 @@ class InteractionLists
//- Fill the referredParticles so that it will be written out //- Fill the referredParticles so that it will be written out
void fillReferredParticleCloud(); void fillReferredParticleCloud();
//- Populate the referredWallData container with data that
// will be referred.
void prepareWallDataToRefer();
//- Write the referred wall faces out for debug //- Write the referred wall faces out for debug
void writeReferredWallFaces() const; void writeReferredWallFaces() const;
@ -206,7 +217,8 @@ public:
( (
const polyMesh& mesh, const polyMesh& mesh,
scalar maxDistance, scalar maxDistance,
Switch writeCloud = false Switch writeCloud = false,
const word& UName = "U"
); );
// Destructor // Destructor
@ -270,7 +282,10 @@ public:
wallFaceIndexAndTransformToDistribute() const; wallFaceIndexAndTransformToDistribute() const;
//- Return access to the referred wall faces //- Return access to the referred wall faces
const List<Tuple2<face, pointField> >& referredWallFaces() const; const List<referredWallFace>& referredWallFaces() const;
//- Return access to the referred wall data
const List<vector>& referredWallData() const;
//- Return access to the referred particle container //- Return access to the referred particle container
inline const List<IDLList<ParticleType> >& inline const List<IDLList<ParticleType> >&
@ -278,7 +293,6 @@ public:
//- Return non-const access to the referred particle container //- Return non-const access to the referred particle container
inline List<IDLList<ParticleType> >& referredParticles(); inline List<IDLList<ParticleType> >& referredParticles();
}; };

View File

@ -121,13 +121,21 @@ wallFaceIndexAndTransformToDistribute() const
template<class ParticleType> template<class ParticleType>
const Foam::List<Foam::Tuple2<Foam::face, Foam::pointField> >& const Foam::List<Foam::referredWallFace>&
Foam::InteractionLists<ParticleType>::referredWallFaces() const Foam::InteractionLists<ParticleType>::referredWallFaces() const
{ {
return referredWallFaces_; return referredWallFaces_;
} }
template<class ParticleType>
const Foam::List<Foam::vector>&
Foam::InteractionLists<ParticleType>::referredWallData() const
{
return referredWallData_;
}
template<class ParticleType> template<class ParticleType>
const Foam::List<Foam::IDLList<ParticleType> >& const Foam::List<Foam::IDLList<ParticleType> >&
Foam::InteractionLists<ParticleType>::referredParticles() const Foam::InteractionLists<ParticleType>::referredParticles() const

View File

@ -0,0 +1,144 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "referredWallFace.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::referredWallFace::referredWallFace()
:
face(),
pts_(),
patchI_()
{}
Foam::referredWallFace::referredWallFace
(
const face& f,
const pointField& pts,
label patchI
)
:
face(f),
pts_(pts),
patchI_(patchI)
{
if (this->size() != pts_.size())
{
FatalErrorIn
(
"Foam::referredWallFace::referredWallFace"
"("
"const face& f, "
"const pointField& pts, "
"label patchI"
")"
) << "Face and pointField are not the same size. " << nl << (*this)
<< abort(FatalError);
}
}
Foam::referredWallFace::referredWallFace(const referredWallFace& rWF)
:
face(rWF),
pts_(rWF.pts_),
patchI_(rWF.patchI_)
{
if (this->size() != pts_.size())
{
FatalErrorIn
(
"Foam::referredWallFace::referredWallFace"
"("
"const referredWallFace& rWF"
")"
) << "Face and pointField are not the same size. " << nl << (*this)
<< abort(FatalError);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::referredWallFace::~referredWallFace()
{}
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
bool Foam::referredWallFace::operator==(const referredWallFace& rhs) const
{
return
(
static_cast<const face&>(rhs) == static_cast<face>(*this)
&& rhs.pts_ == pts_
&& rhs.patchI_ == patchI_
);
}
bool Foam::referredWallFace::operator!=(const referredWallFace& rhs) const
{
return !(*this == rhs);
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Istream& Foam::operator>>(Istream& is, referredWallFace& rWF)
{
is >> static_cast<face&>(rWF) >> rWF.pts_ >> rWF.patchI_;
// Check state of Istream
is.check
(
"Foam::Istream& "
"Foam::operator>>(Foam::Istream&, Foam::referredWallFace&)"
);
return is;
}
Foam::Ostream& Foam::operator<<(Ostream& os, const referredWallFace& rWF)
{
os << static_cast<const face&>(rWF) << token::SPACE
<< rWF.pts_ << token::SPACE
<< rWF.patchI_;
// Check state of Ostream
os.check
(
"Foam::Ostream& Foam::operator<<(Foam::Ostream&, "
"const Foam::referredWallFace&)"
);
return os;
}
// ************************************************************************* //

View File

@ -0,0 +1,139 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::referredWallFace
Description
Storage for referred wall faces. Stores patch index, face and
associated points
SourceFiles
referredWallFaceI.H
referredWallFace.C
\*---------------------------------------------------------------------------*/
#ifndef referredWallFace_H
#define referredWallFace_H
#include "face.H"
#include "pointField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class Istream;
class Ostream;
// Forward declaration of friend functions and operators
class referredWallFace;
Istream& operator>>(Istream&, referredWallFace&);
Ostream& operator<<(Ostream&, const referredWallFace&);
/*---------------------------------------------------------------------------*\
Class referredWallFace Declaration
\*---------------------------------------------------------------------------*/
class referredWallFace
:
public face
{
// Private data
//- Points of face
pointField pts_;
//- Index of originating patch
label patchI_;
public:
// Constructors
//- Construct null
referredWallFace();
//- Construct from components
referredWallFace
(
const face& f,
const pointField& pts,
label patchI
);
//- Construct as copy
referredWallFace(const referredWallFace&);
//- Destructor
~referredWallFace();
// Member Functions
// Access
//- Return access to the stored points
inline const pointField& points() const;
//- Return non-const access to the stored points
inline pointField& points();
//- Return access to the patch index
inline label patchIndex() const;
//- Return non-const access to the patch index
inline label& patchIndex();
// Member Operators
bool operator==(const referredWallFace&) const;
bool operator!=(const referredWallFace&) const;
// IOstream Operators
friend Istream& operator>>(Istream&, referredWallFace&);
friend Ostream& operator<<(Ostream&, const referredWallFace&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "referredWallFaceI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,54 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::pointField& Foam::referredWallFace::points() const
{
return pts_;
}
Foam::pointField& Foam::referredWallFace::points()
{
return pts_;
}
Foam::label Foam::referredWallFace::patchIndex() const
{
return patchI_;
}
Foam::label& Foam::referredWallFace::patchIndex()
{
return patchI_;
}
// ************************************************************************* //

View File

@ -5,5 +5,6 @@ $(passiveParticle)/passiveParticleCloud.C
$(indexedParticle)/indexedParticleCloud.C $(indexedParticle)/indexedParticleCloud.C
InteractionLists/globalIndexAndTransform/globalIndexAndTransform.C InteractionLists/globalIndexAndTransform/globalIndexAndTransform.C
InteractionLists/referredWallFace/referredWallFace.C
LIB = $(FOAM_LIBBIN)/liblagrangian LIB = $(FOAM_LIBBIN)/liblagrangian

View File

@ -269,18 +269,16 @@ void Foam::PairCollision<CloudType>::wallInteraction()
forAll(cellRefWallFaces, rWFI) forAll(cellRefWallFaces, rWFI)
{ {
const Tuple2<face, pointField>& rwf = const referredWallFace& rwf =
il_.referredWallFaces()[cellRefWallFaces[rWFI]]; il_.referredWallFaces()[cellRefWallFaces[rWFI]];
const face& f = rwf.first(); const pointField& pts = rwf.points();
const pointField& pts = rwf.second(); pointHit nearest = rwf.nearestPoint(pos, pts);
pointHit nearest = f.nearestPoint(pos, pts);
if (nearest.distance() < r) if (nearest.distance() < r)
{ {
vector normal = f.normal(pts); vector normal = rwf.normal(pts);
normal /= mag(normal); normal /= mag(normal);

View File

@ -129,7 +129,7 @@ public:
// allowable timestep // allowable timestep
virtual label nSubCycles() const = 0; virtual label nSubCycles() const = 0;
//- Calculate the wall interaction between parcels //- Calculate the wall interaction for a parcel
virtual void evaluateWall virtual void evaluateWall
( (
typename CloudType::parcelType& p, typename CloudType::parcelType& p,

View File

@ -61,6 +61,32 @@ void Foam::WallSpringSliderDashpot<CloudType>::findMinMaxProperties
rMin /= 2.0; rMin /= 2.0;
} }
template <class CloudType>
void Foam::WallSpringSliderDashpot<CloudType>::evaluateWall
(
typename CloudType::parcelType& p,
const point& site,
scalar pNu,
scalar pE,
scalar Estar,
scalar kN
) const
{
vector r_PW = p.position() - site;
scalar normalOverlapMag = p.d()/2 - mag(r_PW);
vector rHat_PW = r_PW/(mag(r_PW) + VSMALL);
scalar etaN = alpha_*sqrt(p.mass()*kN)*pow025(normalOverlapMag);
vector fN_PW =
rHat_PW
*(kN*pow(normalOverlapMag, b_) - etaN*(p.U() & rHat_PW));
p.f() += fN_PW;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -152,38 +178,14 @@ void Foam::WallSpringSliderDashpot<CloudType>::evaluateWall
forAll(flatSites, siteI) forAll(flatSites, siteI)
{ {
vector r_PW = p.position() - flatSites[siteI]; evaluateWall(p, flatSites[siteI], pNu, pE, Estar, kN);
scalar normalOverlapMag = p.d()/2 - mag(r_PW);
vector rHat_PW = r_PW/(mag(r_PW) + VSMALL);
scalar etaN = alpha_*sqrt(p.mass()*kN)*pow025(normalOverlapMag);
vector fN_PW =
rHat_PW
*(kN*pow(normalOverlapMag, b_) - etaN*(p.U() & rHat_PW));
p.f() += fN_PW;
} }
// Treating sharp sites like flat sites
forAll(sharpSites, siteI) forAll(sharpSites, siteI)
{ {
vector r_PW = p.position() - sharpSites[siteI]; // Treating sharp sites like flat sites
scalar normalOverlapMag = p.d()/2 - mag(r_PW); evaluateWall(p, sharpSites[siteI], pNu, pE, Estar, kN);
vector rHat_PW = r_PW/(mag(r_PW) + VSMALL);
scalar etaN = alpha_*sqrt(p.mass()*kN)*pow025(normalOverlapMag);
vector fN_PW =
rHat_PW
*(kN*pow(normalOverlapMag, b_) - etaN*(p.U() & rHat_PW));
p.f() += fN_PW;
} }
} }

View File

@ -81,6 +81,18 @@ class WallSpringSliderDashpot
scalar& vMagMax scalar& vMagMax
) const; ) const;
//- Calculate the wall interaction for a parcel at a given site
void evaluateWall
(
typename CloudType::parcelType& p,
const point& site,
scalar pNu,
scalar pE,
scalar Estar,
scalar kN
) const;
public: public:
//- Runtime type information //- Runtime type information
@ -108,7 +120,7 @@ public:
// allowable timestep // allowable timestep
virtual label nSubCycles() const; virtual label nSubCycles() const;
//- Calculate the wall interaction between parcels //- Calculate the wall interaction for a parcel
virtual void evaluateWall virtual void evaluateWall
( (
typename CloudType::parcelType& p, typename CloudType::parcelType& p,