Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions src/DEM/SolidBoundary/CircularPlaneSolidBoundary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ namespace Spheral {

template<typename Dimension>
CircularPlaneSolidBoundary<Dimension>::
CircularPlaneSolidBoundary(const Vector& point, const Vector& normal, const Scalar& extent):
CircularPlaneSolidBoundary(const Vector& point,
const Vector& normal,
const Scalar& extent,
const RotationType& angularVelocity):
SolidBoundaryBase<Dimension>(),
mPoint(point),
mNormal(normal),
mExtent(extent),
mVelocity(Vector::zero){
mVelocity(Vector::zero),
mAngularVelocity(angularVelocity){
}

template<typename Dimension>
Expand All @@ -51,7 +55,15 @@ template<typename Dimension>
typename Dimension::Vector
CircularPlaneSolidBoundary<Dimension>::
localVelocity(const Vector& position) const {
return mVelocity;
// Linear velocity component
Vector linearVelocityComponent = mVelocity;

// Angular velocity component: v = w × r
Vector r = position - mPoint; // Position vector from the point of rotation
Vector angularVelocityComponent = DEMDimension<Dimension>::cross(mAngularVelocity,r);

// Total velocity is the sum of linear and angular components
return linearVelocityComponent + angularVelocityComponent;
}

template<typename Dimension>
Expand All @@ -63,16 +75,22 @@ registerState(DataBase<Dimension>& dataBase,
const auto pointKey = boundaryKey +"_point";
const auto velocityKey = boundaryKey +"_velocity";
const auto normalKey = boundaryKey +"_normal";
const auto angularVelocityKey = boundaryKey + "_angularVelocity"; // New key for angular velocity
state.enroll(pointKey,mPoint);
state.enroll(pointKey,mVelocity);
state.enroll(pointKey,mNormal);
state.enroll(velocityKey,mVelocity);
state.enroll(normalKey,mNormal);
state.enroll(angularVelocityKey, mAngularVelocity); // Enroll angular velocity
}

template<typename Dimension>
void
CircularPlaneSolidBoundary<Dimension>::
update(const double multiplier, const double t, const double dt) {
mPoint += multiplier*mVelocity;
// Update the orientation of the boundary based on angular velocity
// Assuming a simple Euler for rotation
mNormal += multiplier * DEMDimension<Dimension>::cross(mAngularVelocity,mNormal) * dt;
Comment thread
jmpearl marked this conversation as resolved.
Outdated
mNormal = mNormal.unitVector(); // Normalize to maintain unit length
}


Expand All @@ -87,6 +105,7 @@ dumpState(FileIO& file, const string& pathName) const {
file.write(mNormal, pathName + "/normal");
file.write(mExtent, pathName + "/extent");
file.write(mVelocity, pathName + "/velocity");
file.write(mAngularVelocity, pathName + "/omega"); // Write angular velocity
}


Expand All @@ -98,6 +117,7 @@ restoreState(const FileIO& file, const string& pathName) {
file.read(mNormal, pathName + "/normal");
file.read(mExtent, pathName + "/extent");
file.read(mVelocity, pathName + "/velocity");
file.read(mAngularVelocity, pathName + "/omega"); // Read angular velocity
}

}
10 changes: 8 additions & 2 deletions src/DEM/SolidBoundary/CircularPlaneSolidBoundary.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ class CircularPlaneSolidBoundary : public SolidBoundaryBase<Dimension> {

typedef typename Dimension::Scalar Scalar;
typedef typename Dimension::Vector Vector;
typedef typename DEMDimension<Dimension>::AngularVector RotationType;

public:
//--------------------------- Public Interface ---------------------------//

CircularPlaneSolidBoundary(const Vector& point,
const Vector& normal,
const Scalar& exent);
const Vector& normal,
const Scalar& exent,
const RotationType& angularVelocity);

~CircularPlaneSolidBoundary();

Expand All @@ -53,6 +55,9 @@ public:
const Vector& velocity() const;
void velocity(const Vector& value);

const RotationType& angularVelocity() const;
void angularVelocity(const RotationType& value);

virtual std::string label() const override { return "CircularPlaneSolidBoundary" ; }
virtual void dumpState(FileIO& file, const std::string& pathName) const override;
virtual void restoreState(const FileIO& file, const std::string& pathName) override;
Expand All @@ -63,6 +68,7 @@ protected:
Vector mNormal;
Scalar mExtent;
Vector mVelocity;
RotationType mAngularVelocity;

private:
//--------------------------- Private Interface ---------------------------//
Expand Down
17 changes: 17 additions & 0 deletions src/DEM/SolidBoundary/CircularPlaneSolidBoundaryInline.hh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ normal(const typename Dimension::Vector& value) {
mNormal = value;
}


template<typename Dimension>
inline
typename Dimension::Scalar
Expand All @@ -49,6 +50,7 @@ extent(typename Dimension::Scalar value) {
mExtent=value;
}


template<typename Dimension>
inline
const typename Dimension::Vector&
Expand All @@ -65,4 +67,19 @@ velocity(const typename Dimension::Vector& value) {
mVelocity=value;
}


template<typename Dimension>
inline
const typename DEMDimension<Dimension>::AngularVector&
CircularPlaneSolidBoundary<Dimension>::
angularVelocity() const {
return mAngularVelocity;
}

template<typename Dimension>
inline
void
CircularPlaneSolidBoundary<Dimension>::
angularVelocity(const typename DEMDimension<Dimension>::AngularVector& value) {
mAngularVelocity=value;
}
35 changes: 27 additions & 8 deletions src/DEM/SolidBoundary/CylinderSolidBoundary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ namespace Spheral {
template<typename Dimension>
CylinderSolidBoundary<Dimension>::
CylinderSolidBoundary(const Vector& point,
const Vector& axis,
const Scalar radius,
const Scalar length):
const Vector& axis,
const Scalar radius,
const Scalar length,
const RotationType& angularVelocity):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If angularVelocity must be aligned with the axis this should be enforced somehow

Copy link
Copy Markdown
Collaborator Author

@swiggins8 swiggins8 Sep 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would you suggest for enforcement of that? I feel like keeping it a simple vector makes sense for conveying that it can't do complex rotation. But I'm open to ideas.

SolidBoundaryBase<Dimension>(),
mPoint(point),
mAxis(axis),
mRadius(radius),
mLength(length),
mVelocity(Vector::zero){
mVelocity(Vector::zero),
mAngularVelocity(angularVelocity){
}

template<typename Dimension>
Expand All @@ -52,7 +54,15 @@ template<typename Dimension>
typename Dimension::Vector
CylinderSolidBoundary<Dimension>::
localVelocity(const Vector& position) const {
return mVelocity;
// Calculate the vector from the axis of rotation to the position
const auto p = position - mPoint;
const auto pnMag = p.dot(mAxis);
const auto pn = pnMag * mAxis;
const auto r = p - pn; // Radial vector from the axis to the position
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove the radial component here on the position, would that assume that mAngularVelocity and mAxis are aligned?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I assume that the angular velocity is always around the central axis


// Calculate the tangential velocity due to angular velocity
const auto tangentialVelocity = DEMDimension<Dimension>::cross(r,mAngularVelocity);
return mVelocity + tangentialVelocity;
}

template<typename Dimension>
Expand All @@ -62,18 +72,25 @@ registerState(DataBase<Dimension>& dataBase,
State<Dimension>& state) {
const auto boundaryKey = "CylinderSolidBoundary_" + std::to_string(std::abs(this->uniqueIndex()));
const auto pointKey = boundaryKey +"_point";
const auto axisKey = boundaryKey +"_axis";
const auto radiusKey = boundaryKey +"_radius";
const auto lengthKey = boundaryKey +"_length";
const auto velocityKey = boundaryKey +"_velocity";
//const auto normalKey = boundaryKey +"_normal";
const auto angularVelocityKey = boundaryKey + "_angularVelocity"; // Key for angular velocity
state.enroll(pointKey,mPoint);
state.enroll(pointKey,mVelocity);
//state.enroll(pointKey,mNormal);
state.enroll(axisKey,mAxis);
state.enroll(radiusKey,mRadius);
state.enroll(lengthKey,mLength);
state.enroll(velocityKey,mVelocity);
state.enroll(angularVelocityKey, mAngularVelocity); // Enroll angular velocity
}

template<typename Dimension>
void
CylinderSolidBoundary<Dimension>::
update(const double multiplier, const double t, const double dt) {
mPoint += multiplier*mVelocity;
// If we want more complex rotation we'll need more complex logic here.
}

//------------------------------------------------------------------------------
Expand All @@ -88,6 +105,7 @@ dumpState(FileIO& file, const string& pathName) const {
file.write(mRadius, pathName + "/radius");
file.write(mLength, pathName + "/length");
file.write(mVelocity, pathName + "/velocity");
file.write(mAngularVelocity, pathName + "/omega"); // Write angular velocity
}


Expand All @@ -100,6 +118,7 @@ restoreState(const FileIO& file, const string& pathName) {
file.read(mRadius, pathName + "/radius");
file.read(mLength, pathName + "/length");
file.read(mVelocity, pathName + "/velocity");
file.read(mAngularVelocity, pathName + "/omega"); // Read angular velocity
}


Expand Down
12 changes: 9 additions & 3 deletions src/DEM/SolidBoundary/CylinderSolidBoundary.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ class CylinderSolidBoundary : public SolidBoundaryBase<Dimension> {
typedef typename Dimension::Scalar Scalar;
typedef typename Dimension::Vector Vector;
typedef typename Dimension::Tensor Tensor;
typedef typename DEMDimension<Dimension>::AngularVector RotationType;

public:
//--------------------------- Public Interface ---------------------------//

CylinderSolidBoundary(const Vector& point,
const Vector& axis,
const Scalar radius,
const Scalar length);
const Vector& axis,
const Scalar radius,
const Scalar length,
const RotationType& angularVelocity);

~CylinderSolidBoundary();

Expand Down Expand Up @@ -57,6 +59,9 @@ public:
const Vector& velocity() const;
void velocity(const Vector& value);

const RotationType& angularVelocity() const;
void angularVelocity(const RotationType& value);

virtual std::string label() const override { return "CylinderSolidBoundary" ; }
virtual void dumpState(FileIO& file, const std::string& pathName) const override;
virtual void restoreState(const FileIO& file, const std::string& pathName) override;
Expand All @@ -69,6 +74,7 @@ protected:
Scalar mLength;

Vector mVelocity;
RotationType mAngularVelocity;

private:
//--------------------------- Private Interface ---------------------------//
Expand Down
20 changes: 20 additions & 0 deletions src/DEM/SolidBoundary/CylinderSolidBoundaryInline.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ point(const typename Dimension::Vector& value) {
mPoint=value;
}


template<typename Dimension>
inline
const typename Dimension::Vector&
Expand All @@ -32,6 +33,7 @@ axis(const typename Dimension::Vector& value) {
mAxis=value;
}


template<typename Dimension>
inline
typename Dimension::Scalar
Expand All @@ -48,6 +50,7 @@ length(typename Dimension::Scalar value) {
mLength=value;
}


template<typename Dimension>
inline
typename Dimension::Scalar
Expand All @@ -64,6 +67,7 @@ radius(typename Dimension::Scalar value) {
mRadius=value;
}


template<typename Dimension>
inline
const typename Dimension::Vector&
Expand All @@ -80,4 +84,20 @@ velocity(const typename Dimension::Vector& value) {
mVelocity=value;
}


template<typename Dimension>
inline
const typename DEMDimension<Dimension>::AngularVector&
CylinderSolidBoundary<Dimension>::
angularVelocity() const {
return mAngularVelocity;
}

template<typename Dimension>
inline
void
CylinderSolidBoundary<Dimension>::
angularVelocity(const typename DEMDimension<Dimension>::AngularVector& value) {
mAngularVelocity=value;
}
}
16 changes: 13 additions & 3 deletions src/DEM/SolidBoundary/InfinitePlaneSolidBoundary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ namespace Spheral {

template<typename Dimension>
InfinitePlaneSolidBoundary<Dimension>::
InfinitePlaneSolidBoundary(const Vector& point, const Vector& normal):
InfinitePlaneSolidBoundary(const Vector& point,
const Vector& normal,
const RotationType& angularVelocity):
SolidBoundaryBase<Dimension>(),
mPoint(point),
mNormal(normal),
mVelocity(Vector::zero){
mVelocity(Vector::zero),
mAngularVelocity(angularVelocity){
}

template<typename Dimension>
Expand All @@ -42,7 +45,7 @@ template<typename Dimension>
typename Dimension::Vector
InfinitePlaneSolidBoundary<Dimension>::
localVelocity(const Vector& position) const {
return mVelocity;
return mVelocity + DEMDimension<Dimension>::cross((position-mPoint),mAngularVelocity); // Include angular velocity effect
}

template<typename Dimension>
Expand All @@ -57,13 +60,18 @@ registerState(DataBase<Dimension>& dataBase,
state.enroll(pointKey,mPoint);
state.enroll(velocityKey,mVelocity);
state.enroll(normalKey,mNormal);
state.enroll(angularVelocityKey, mAngularVelocity); // Enroll angular velocity
}

template<typename Dimension>
void
InfinitePlaneSolidBoundary<Dimension>::
update(const double multiplier, const double t, const double dt) {
mPoint += multiplier*mVelocity;
// Update the normal vector based on angular velocity
// Using a small angle approximation: newNormal = oldNormal + dt * (angularVelocity x oldNormal)
mNormal += multiplier * DEMDimension<Dimension>::cross(mNormal,mAngularVelocity);
mNormal = mNormal.unitVector(); // Normalize to maintain it as a unit vector
}

//------------------------------------------------------------------------------
Expand All @@ -76,6 +84,7 @@ dumpState(FileIO& file, const string& pathName) const {
file.write(mPoint, pathName + "/point");
file.write(mNormal, pathName + "/normal");
file.write(mVelocity, pathName + "/velocity");
file.write(mAngularVelocity, pathName + "/omega"); // Write angular velocity
}


Expand All @@ -86,6 +95,7 @@ restoreState(const FileIO& file, const string& pathName) {
file.read(mPoint, pathName + "/point");
file.read(mNormal, pathName + "/normal");
file.read(mVelocity, pathName + "/velocity");
file.read(mAngularVelocity, pathName + "/omega"); // Read angular velocity
}

}
Loading