-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
394 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
//---------------------------------Spheral++----------------------------------// | ||
// ClippedSphereSolidBoundary -- N-dimensional spherical solid boundary for DEM. | ||
// | ||
// J.M. Pearl 2023 | ||
//----------------------------------------------------------------------------// | ||
|
||
#include "DataBase/DataBase.hh" | ||
#include "DataBase/State.hh" | ||
#include "DataBase/StateDerivatives.hh" | ||
|
||
#include "DEM/SolidBoundary/ClippedSphereSolidBoundary.hh" | ||
|
||
#include <cmath> | ||
|
||
namespace Spheral { | ||
|
||
template<typename Dimension> | ||
ClippedSphereSolidBoundary<Dimension>:: | ||
ClippedSphereSolidBoundary(const Vector& center, | ||
const Scalar radius, | ||
const Vector& clipPoint, | ||
const Vector& clipAxis): | ||
SolidBoundaryBase<Dimension>(), | ||
mCenter(center), | ||
mRadius(radius), | ||
mClipPoint(clipPoint), | ||
mClipAxis(clipAxis), | ||
mClipIntersectionRadius(0.0), | ||
mVelocity(Vector::zero){ | ||
this->setClipIntersectionRadius(); | ||
mClipAxis = mClipAxis.unitVector(); | ||
} | ||
|
||
template<typename Dimension> | ||
ClippedSphereSolidBoundary<Dimension>:: | ||
~ClippedSphereSolidBoundary(){ | ||
} | ||
|
||
|
||
template<typename Dimension> | ||
typename Dimension::Vector | ||
ClippedSphereSolidBoundary<Dimension>:: | ||
distance(const Vector& position) const { | ||
|
||
// contacting sphere | ||
const auto contactPoint = (position - mCenter).unitVector()*mRadius + mCenter; | ||
Vector dist = position - contactPoint; | ||
|
||
const auto planeSignedDistance = (contactPoint - mClipPoint).dot(mClipAxis); | ||
|
||
// if contant pt above clip plane check for edge contact | ||
if (planeSignedDistance > 0.0){ | ||
|
||
// break into perp and in-plane components | ||
const auto q = (position-mClipPoint); | ||
const auto qnMag = q.dot(mClipAxis); | ||
const auto qn = qnMag * mClipAxis; | ||
const auto qr = q - qn; | ||
|
||
// if outside circle enforce planar solid bc | ||
dist = min(qr.magnitude() - mClipIntersectionRadius,0.0)*qr.unitVector() + qn; | ||
|
||
} | ||
return dist; | ||
} | ||
|
||
template<typename Dimension> | ||
typename Dimension::Vector | ||
ClippedSphereSolidBoundary<Dimension>:: | ||
localVelocity(const Vector& position) const { | ||
return mVelocity; | ||
} | ||
|
||
template<typename Dimension> | ||
void | ||
ClippedSphereSolidBoundary<Dimension>:: | ||
registerState(DataBase<Dimension>& dataBase, | ||
State<Dimension>& state) { | ||
|
||
const auto boundaryKey = "ClippedSphereSolidBoundary_" + std::to_string(std::abs(this->uniqueIndex())); | ||
const auto pointKey = boundaryKey +"_point"; | ||
const auto clipPointKey = boundaryKey +"_clipPoint"; | ||
const auto velocityKey = boundaryKey +"_velocity"; | ||
|
||
state.enrollAny(pointKey,mCenter); | ||
state.enrollAny(clipPointKey,mClipPoint); | ||
state.enrollAny(pointKey,mVelocity); | ||
|
||
} | ||
|
||
template<typename Dimension> | ||
void | ||
ClippedSphereSolidBoundary<Dimension>:: | ||
update(const double multiplier, const double t, const double dt) { | ||
mCenter += multiplier*mVelocity; | ||
mClipPoint += multiplier*mVelocity; | ||
} | ||
|
||
|
||
template<typename Dimension> | ||
void | ||
ClippedSphereSolidBoundary<Dimension>:: | ||
setClipIntersectionRadius() { | ||
const auto rcMag = (mClipPoint - mCenter).dot(mClipAxis); | ||
mClipIntersectionRadius = (rcMag < mRadius ? std::sqrt(mRadius*mRadius-rcMag*rcMag) : 0.0); | ||
mClipPoint = rcMag * mClipAxis + mCenter; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
//---------------------------------Spheral++----------------------------------// | ||
// ClippedSphereSolidBoundary -- cylinder with finite length solid boundary for DEM | ||
// | ||
// J.M. Pearl 2023 | ||
//----------------------------------------------------------------------------// | ||
|
||
#ifndef __Spheral_ClippedSphereSolidBoundary_hh__ | ||
#define __Spheral_ClippedSphereSolidBoundary_hh__ | ||
|
||
#include "DEM/SolidBoundary/SolidBoundaryBase.hh" | ||
|
||
namespace Spheral { | ||
|
||
template<typename Dimension> class State; | ||
template<typename Dimension> class StateDerivatives; | ||
template<typename Dimension> class DataBase; | ||
|
||
template<typename Dimension> | ||
class ClippedSphereSolidBoundary : public SolidBoundaryBase<Dimension> { | ||
|
||
typedef typename Dimension::Scalar Scalar; | ||
typedef typename Dimension::Vector Vector; | ||
typedef typename Dimension::Tensor Tensor; | ||
|
||
public: | ||
//--------------------------- Public Interface ---------------------------// | ||
|
||
ClippedSphereSolidBoundary(const Vector& center, | ||
const Scalar radius, | ||
const Vector& clipPoint, | ||
const Vector& clipAxis); | ||
|
||
~ClippedSphereSolidBoundary(); | ||
|
||
virtual Vector distance(const Vector& position) const override; | ||
virtual Vector localVelocity(const Vector& position) const override; | ||
|
||
virtual void registerState(DataBase<Dimension>& dataBase, | ||
State<Dimension>& state) override; | ||
|
||
|
||
virtual void update(const double multiplier, | ||
const double time, | ||
const double dt) override; | ||
|
||
const Vector& center() const; | ||
void center(const Vector& value); | ||
|
||
Scalar radius() const; | ||
void radius(Scalar value); | ||
|
||
const Vector& clipPoint() const; | ||
void clipPoint(const Vector& value); | ||
|
||
const Vector& clipAxis() const; | ||
void clipAxis(const Vector& value); | ||
|
||
const Vector& velocity() const; | ||
void velocity(const Vector& value); | ||
|
||
void setClipIntersectionRadius(); | ||
protected: | ||
//-------------------------- Protected Interface --------------------------// | ||
Vector mCenter; | ||
Scalar mRadius; | ||
Vector mClipPoint; | ||
Vector mClipAxis; | ||
Scalar mClipIntersectionRadius; | ||
|
||
Vector mVelocity; | ||
|
||
private: | ||
//--------------------------- Private Interface ---------------------------// | ||
// No default constructor, copying, or assignment. | ||
ClippedSphereSolidBoundary(); | ||
ClippedSphereSolidBoundary(const ClippedSphereSolidBoundary&); | ||
ClippedSphereSolidBoundary& operator=(const ClippedSphereSolidBoundary&); | ||
}; | ||
|
||
} | ||
|
||
#include "ClippedSphereSolidBoundaryInline.hh" | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
namespace Spheral { | ||
|
||
template<typename Dimension> | ||
inline | ||
const typename Dimension::Vector& | ||
ClippedSphereSolidBoundary<Dimension>:: | ||
center() const { | ||
return mCenter; | ||
} | ||
|
||
template<typename Dimension> | ||
inline | ||
void | ||
ClippedSphereSolidBoundary<Dimension>:: | ||
center(const typename Dimension::Vector& value) { | ||
mCenter=value; | ||
} | ||
|
||
template<typename Dimension> | ||
inline | ||
typename Dimension::Scalar | ||
ClippedSphereSolidBoundary<Dimension>:: | ||
radius() const { | ||
return mRadius; | ||
} | ||
|
||
template<typename Dimension> | ||
inline | ||
void | ||
ClippedSphereSolidBoundary<Dimension>:: | ||
radius(typename Dimension::Scalar value) { | ||
mRadius=value; | ||
} | ||
|
||
|
||
template<typename Dimension> | ||
inline | ||
const typename Dimension::Vector& | ||
ClippedSphereSolidBoundary<Dimension>:: | ||
clipPoint() const { | ||
return mClipPoint; | ||
} | ||
|
||
template<typename Dimension> | ||
inline | ||
void | ||
ClippedSphereSolidBoundary<Dimension>:: | ||
clipPoint(const typename Dimension::Vector& value) { | ||
mClipPoint=value; | ||
this->setClipIntersectionRadius(); | ||
} | ||
|
||
|
||
template<typename Dimension> | ||
inline | ||
const typename Dimension::Vector& | ||
ClippedSphereSolidBoundary<Dimension>:: | ||
clipAxis() const { | ||
return mClipAxis; | ||
} | ||
|
||
template<typename Dimension> | ||
inline | ||
void | ||
ClippedSphereSolidBoundary<Dimension>:: | ||
clipAxis(const typename Dimension::Vector& value) { | ||
mClipAxis=value.unitVector(); | ||
this->setClipIntersectionRadius(); | ||
} | ||
|
||
template<typename Dimension> | ||
inline | ||
const typename Dimension::Vector& | ||
ClippedSphereSolidBoundary<Dimension>:: | ||
velocity() const { | ||
return mVelocity; | ||
} | ||
|
||
template<typename Dimension> | ||
inline | ||
void | ||
ClippedSphereSolidBoundary<Dimension>:: | ||
velocity(const typename Dimension::Vector& value) { | ||
mVelocity=value; | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
src/DEM/SolidBoundary/ClippedSphereSolidBoundaryInst.cc.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
text = """ | ||
//------------------------------------------------------------------------------ | ||
// Explict instantiation. | ||
//------------------------------------------------------------------------------ | ||
#include "DEM/SolidBoundary/ClippedSphereSolidBoundary.cc" | ||
#include "Geometry/Dimension.hh" | ||
namespace Spheral { | ||
template class ClippedSphereSolidBoundary< Dim< %(ndim)s > >; | ||
} | ||
""" |
Oops, something went wrong.