Skip to content

Commit

Permalink
DEM BC updates RotatingDrum working
Browse files Browse the repository at this point in the history
  • Loading branch information
jmpearl committed Apr 15, 2024
1 parent 557887e commit ba25094
Show file tree
Hide file tree
Showing 11 changed files with 394 additions and 120 deletions.
2 changes: 2 additions & 0 deletions src/DEM/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ set(DEM_inst
SolidBoundary/RectangularPlaneSolidBoundary
SolidBoundary/CylinderSolidBoundary
SolidBoundary/SphereSolidBoundary
SolidBoundary/ClippedSphereSolidBoundary
ReplacePairFieldList
IncrementPairFieldList
ReplaceAndIncrementPairFieldList
Expand All @@ -29,6 +30,7 @@ set(DEM_headers
SolidBoundary/RectangularPlaneSolidBoundary.hh
SolidBoundary/CylinderSolidBoundary.hh
SolidBoundary/SphereSolidBoundary.hh
SolidBoundary/ClippedSphereSolidBoundary.hh
ReplacePairFieldList.hh
ReplaceAndIncrementPairFieldList.hh
IncrementPairFieldList.hh
Expand Down
109 changes: 109 additions & 0 deletions src/DEM/SolidBoundary/ClippedSphereSolidBoundary.cc
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;
}

}
84 changes: 84 additions & 0 deletions src/DEM/SolidBoundary/ClippedSphereSolidBoundary.hh
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
87 changes: 87 additions & 0 deletions src/DEM/SolidBoundary/ClippedSphereSolidBoundaryInline.hh
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 src/DEM/SolidBoundary/ClippedSphereSolidBoundaryInst.cc.py
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 > >;
}
"""
Loading

0 comments on commit ba25094

Please sign in to comment.