Commit 61978441 authored by graham's avatar graham
Browse files

ENH. Adding collision records to wall collisions to record tangential

overlap.

Matching wall collision records by storing and comparing location of
wall impact relative to paticle centre.
parent 8e7d6507
......@@ -28,37 +28,41 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::CollisionRecordList<Type>::CollisionRecordList()
template<class PairType, class WallType>
Foam::CollisionRecordList<PairType, WallType>::CollisionRecordList()
:
DynamicList<CollisionRecord<Type> >()
pairRecords_(),
wallRecords_()
{}
template<class Type>
Foam::CollisionRecordList<Type>::CollisionRecordList(Istream& is)
template<class PairType, class WallType>
Foam::CollisionRecordList<PairType, WallType>::CollisionRecordList(Istream& is)
:
DynamicList<CollisionRecord<Type> >(is)
pairRecords_(is),
wallRecords_(is)
{
// Check state of Istream
is.check
(
"Foam::CollisionRecordList<Type>::CollisionRecordList(Foam::Istream&)"
"Foam::CollisionRecordList<PairType, WallType>::"
"CollisionRecordList(Foam::Istream&)"
);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * /
template<class Type>
Foam::CollisionRecordList<Type>::~CollisionRecordList()
template<class PairType, class WallType>
Foam::CollisionRecordList<PairType, WallType>::~CollisionRecordList()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
template<class Type>
Foam::CollisionRecord<Type>& Foam::CollisionRecordList<Type>::matchRecord
template<class PairType, class WallType>
Foam::PairCollisionRecord<PairType>&
Foam::CollisionRecordList<PairType, WallType>::matchPairRecord
(
label origProcOfOther,
label origIdOfOther
......@@ -68,15 +72,15 @@ Foam::CollisionRecord<Type>& Foam::CollisionRecordList<Type>::matchRecord
// identifiers. Two records with the same identification is not
// supported.
forAll(*this, i)
forAll(pairRecords_, i)
{
CollisionRecord<Type>& cR = (*this)[i];
PairCollisionRecord<PairType>& pCR = pairRecords_[i];
if (cR.match(origProcOfOther, origIdOfOther))
if (pCR.match(origProcOfOther, origIdOfOther))
{
cR.setAccessed();
pCR.setAccessed();
return cR;
return pCR;
}
}
......@@ -84,28 +88,179 @@ Foam::CollisionRecord<Type>& Foam::CollisionRecordList<Type>::matchRecord
// member of the list. The status of the record will be accessed
// by construction.
append(CollisionRecord<Type>(origProcOfOther, origIdOfOther));
pairRecords_.append
(
PairCollisionRecord<PairType>(origProcOfOther, origIdOfOther)
);
return pairRecords_.last();
}
template<class PairType, class WallType>
Foam::WallCollisionRecord<WallType>&
Foam::CollisionRecordList<PairType, WallType>::matchWallRecord
(
const vector& pRel,
scalar radius
)
{
// Returning the first record that matches the relative position.
// Two records with the same relative position is not supported.
forAll(wallRecords_, i)
{
WallCollisionRecord<WallType>& wCR = wallRecords_[i];
if (wCR.match(pRel, radius))
{
wCR.setAccessed();
return wCR;
}
}
// Record not found, create a new one and return it as the last
// member of the list. The status of the record will be accessed
// by construction.
return (*this)[this->size() - 1];
wallRecords_.append(WallCollisionRecord<WallType>(pRel));
return wallRecords_.last();
}
template<class Type>
void Foam::CollisionRecordList<Type>::update()
template<class PairType, class WallType>
void Foam::CollisionRecordList<PairType, WallType>::update()
{
DynamicList<CollisionRecord<Type> > updatedRecords;
{
DynamicList<PairCollisionRecord<PairType> > updatedRecords;
forAll(pairRecords_, i)
{
if (pairRecords_[i].accessed())
{
pairRecords_[i].setUnaccessed();
updatedRecords.append(pairRecords_[i]);
}
}
pairRecords_ = updatedRecords;
}
forAll(*this, i)
{
if ((*this)[i].accessed())
DynamicList<WallCollisionRecord<WallType> > updatedRecords;
forAll(wallRecords_, i)
{
(*this)[i].setUnaccessed();
if (wallRecords_[i].accessed())
{
wallRecords_[i].setUnaccessed();
updatedRecords.append((*this)[i]);
updatedRecords.append(wallRecords_[i]);
}
}
wallRecords_ = updatedRecords;
}
}
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
template<class PairType, class WallType>
void Foam::CollisionRecordList<PairType, WallType>::operator=
(
const CollisionRecordList<PairType, WallType>& rhs
)
{
// Check for assignment to self
if (this == &rhs)
{
FatalErrorIn
(
"Foam::CollisionRecordList<PairType, WallType>::operator="
"(const Foam::CollisionRecordList<PairType, WallType>&)"
)
<< "Attempted assignment to self"
<< abort(FatalError);
}
DynamicList<CollisionRecord<Type> >::operator=(updatedRecords);
pairRecords_ = rhs.pairRecords_;
wallRecords_ = rhs.wallRecords_;
}
// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * //
template<class PairType, class WallType>
inline bool Foam::operator==
(
const CollisionRecordList<PairType, WallType>& a,
const CollisionRecordList<PairType, WallType>& b
)
{
return
(
a.pairRecords_ == b.pairRecords_
&& a.wallRecords_ == b.wallRecords_
);
}
template<class PairType, class WallType>
inline bool Foam::operator!=
(
const CollisionRecordList<PairType, WallType>& a,
const CollisionRecordList<PairType, WallType>& b
)
{
return !(a == b);
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class PairType, class WallType>
Foam::Istream& Foam::operator>>
(
Istream& is,
CollisionRecordList<PairType, WallType>& cRL
)
{
is >> cRL.pairRecords_ >> cRL.wallRecords_;
// Check state of Istream
is.check
(
"Foam::Istream& Foam::operator>>"
"(Foam::Istream&, Foam::CollisionRecordList<PairType, WallType>&)"
);
return is;
}
template<class PairType, class WallType>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const CollisionRecordList<PairType, WallType>& cRL
)
{
os << cRL.pairRecords_ << cRL.wallRecords_;
// Check state of Ostream
os.check
(
"Foam::Ostream& Foam::operator<<(Foam::Ostream&, "
"const Foam::CollisionRecordList<PairType, WallType>&)"
);
return os;
}
// ************************************************************************* //
......@@ -37,22 +37,53 @@ SourceFiles
#define CollisionRecordList_H
#include "DynamicList.H"
#include "CollisionRecord.H"
#include "PairCollisionRecord.H"
#include "WallCollisionRecord.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of friend functions and operators
template<class PairType, class WallType>
class CollisionRecordList;
template<class PairType, class WallType>
inline bool operator==
(
const CollisionRecordList<PairType, WallType>&,
const CollisionRecordList<PairType, WallType>&
);
template<class PairType, class WallType>
inline bool operator!=
(
const CollisionRecordList<PairType, WallType>&,
const CollisionRecordList<PairType, WallType>&
);
template<class PairType, class WallType>
Istream& operator>>(Istream&, CollisionRecordList<PairType, WallType>&);
template<class PairType, class WallType>
Ostream& operator<<(Ostream&, const CollisionRecordList<PairType, WallType>&);
/*---------------------------------------------------------------------------*\
Class CollisionRecordList Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
template<class PairType, class WallType>
class CollisionRecordList
:
public DynamicList<CollisionRecord<Type> >
{
// Private data
//- List of active pair collisions
DynamicList<PairCollisionRecord<PairType> > pairRecords_;
//- List of active wall collisions
DynamicList<WallCollisionRecord<WallType> > wallRecords_;
public:
......@@ -72,19 +103,66 @@ public:
// Member Functions
//- Enquires if the proc and id pair of the other particle are
// present in the records. If so, return access to the
// collisionData and mark the CollisionRecord as accessed this
// step, if not, create the record and return access to it.
CollisionRecord<Type>& matchRecord
// present in the records. If so, return non-const access to
// the PairCollisionRecord (hence the data) and mark the
// PairCollisionRecord as accessed this step, if not, create
// the record and return access to it.
PairCollisionRecord<PairType>& matchPairRecord
(
label origProcOfOther,
label origIdOfOther
);
//- Enquires if the position of wall impact relative to the
// particle centre is present in the records. If so, return
// access to the WallCollisionRecord (hence the data) and
// mark the WallCollisionRecord as accesses this step, if
// not, create the record and return access to it.
WallCollisionRecord<WallType>& matchWallRecord
(
const vector& pRel,
scalar radius
);
//- Update the collision records, deleting any records not
// marked as having been accessed, then mark all records as
// not accessed ready for the next evaluation
void update();
// Member Operators
void operator=(const CollisionRecordList&);
// Friend Operators
friend bool operator== <PairType, WallType>
(
const CollisionRecordList<PairType, WallType>&,
const CollisionRecordList<PairType, WallType>&
);
friend bool operator!= <PairType, WallType>
(
const CollisionRecordList<PairType, WallType>&,
const CollisionRecordList<PairType, WallType>&
);
// IOstream Operators
friend Istream& operator>> <PairType, WallType>
(
Istream&,
CollisionRecordList<PairType, WallType>&
);
friend Ostream& operator<< <PairType, WallType>
(
Ostream&,
const CollisionRecordList<PairType, WallType>&
);
};
......
......@@ -23,12 +23,12 @@ License
\*---------------------------------------------------------------------------*/
#include "CollisionRecord.H"
#include "PairCollisionRecord.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::CollisionRecord<Type>::CollisionRecord()
Foam::PairCollisionRecord<Type>::PairCollisionRecord()
:
origProcOfOther_(-VGREAT),
origIdOfOther_(-VGREAT),
......@@ -37,7 +37,7 @@ Foam::CollisionRecord<Type>::CollisionRecord()
template<class Type>
Foam::CollisionRecord<Type>::CollisionRecord
Foam::PairCollisionRecord<Type>::PairCollisionRecord
(
label origProcOfOther,
label origIdOfOther,
......@@ -51,33 +51,39 @@ Foam::CollisionRecord<Type>::CollisionRecord
template<class Type>
Foam::CollisionRecord<Type>::CollisionRecord(const CollisionRecord<Type>& cR)
Foam::PairCollisionRecord<Type>::PairCollisionRecord
(
const PairCollisionRecord<Type>& pCR
)
:
origProcOfOther_(cR.origProcOfOther() + 1),
origIdOfOther_(cR.origIdOfOther_),
data_(cR.data_)
origProcOfOther_(pCR.origProcOfOther() + 1),
origIdOfOther_(pCR.origIdOfOther_),
data_(pCR.data_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::CollisionRecord<Type>::~CollisionRecord()
Foam::PairCollisionRecord<Type>::~PairCollisionRecord()
{}
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
template<class Type>
void Foam::CollisionRecord<Type>::operator=(const CollisionRecord<Type>& rhs)
void Foam::PairCollisionRecord<Type>::operator=
(
const PairCollisionRecord<Type>& rhs
)
{
// Check for assignment to self
if (this == &rhs)
{
FatalErrorIn
(
"Foam::CollisionRecord<Type>::operator="
"(const Foam::CollisionRecord<Type>&)"
"Foam::PairCollisionRecord<Type>::operator="
"(const Foam::PairCollisionRecord<Type>&)"
)
<< "Attempted assignment to self"
<< abort(FatalError);
......@@ -91,7 +97,7 @@ void Foam::CollisionRecord<Type>::operator=(const CollisionRecord<Type>& rhs)
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
#include "CollisionRecordIO.C"
#include "PairCollisionRecordIO.C"
// ************************************************************************* //
......@@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::CollisionRecord
Foam::PairCollisionRecord
Description
......@@ -35,14 +35,14 @@ Description
positive means that it has.
SourceFiles
CollisionRecordI.H
CollisionRecord.C
CollisionRecordIO.C
PairCollisionRecordI.H
PairCollisionRecord.C
PairCollisionRecordIO.C
\*---------------------------------------------------------------------------*/
#ifndef CollisionRecord_H
#define CollisionRecord_H
#ifndef PairCollisionRecord_H
#define PairCollisionRecord_H
#include "label.H"
#include "vector.H"
......@@ -54,35 +54,35 @@ namespace Foam
// Forward declaration of friend functions and operators
template<class Type>
class CollisionRecord;
class PairCollisionRecord;
template<class Type>
inline bool operator==
(
const CollisionRecord<Type>&,
const CollisionRecord<Type>&
const PairCollisionRecord<Type>&,
const PairCollisionRecord<Type>&
);
template<class Type>
inline bool operator!=
(
const CollisionRecord<Type>&,
const CollisionRecord<Type>&
const PairCollisionRecord<Type>&,
const PairCollisionRecord<Type>&
);
template<class Type>
Istream& operator>>(Istream&, CollisionRecord<Type>&);
Istream& operator>>(Istream&, PairCollisionRecord<Type>&);
template<class Type>
Ostream& operator<<(Ostream&, const CollisionRecord<Type>&);
Ostream& operator<<(Ostream&, const PairCollisionRecord<Type>&);
/*---------------------------------------------------------------------------*\
Class CollisionRecord Declaration
Class PairCollisionRecord Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class CollisionRecord
class PairCollisionRecord
{
// Private data
......@@ -103,10 +103,10 @@ public:
// Constructors
//- Construct null
CollisionRecord();
PairCollisionRecord();
//- Construct from components
CollisionRecord
PairCollisionRecord
(
label origProcOfOther,
label origIdOfOther,
......@@ -114,14 +114,14 @@ public:
);
//- Construct from Istream
CollisionRecord(Istream&);
PairCollisionRecord(Istream&);
//- Construct as copy
CollisionRecord(const CollisionRecord&);
PairCollisionRecord(const PairCollisionRecord&);
//- Destructor