Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/dem #228

Merged
merged 2 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
66 changes: 65 additions & 1 deletion src/DEM/LinearSpringDEM.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "Neighbor/ConnectivityMap.hh"
#include "Hydro/HydroFieldNames.hh"

#include "Boundary/Boundary.hh"

#include "DEM/ReplaceAndIncrementPairFieldList.hh"
#include "DEM/DEMFieldNames.hh"
#include "DEM/DEMDimension.hh"
Expand All @@ -40,6 +42,7 @@
#include <cmath>
#include <limits>

using std::string;
using std::make_pair;
using std::to_string;

Expand Down Expand Up @@ -823,5 +826,66 @@ setMomentOfInertia() {
} // loop nodes
} // loop nodelists
} // method
} // namespace



//------------------------------------------------------------------------------
// Apply the ghost boundary conditions for linear dem state fields.
//------------------------------------------------------------------------------
template<typename Dimension>
void
LinearSpringDEM<Dimension>::
applyGhostBoundaries(State<Dimension>& state,
StateDerivatives<Dimension>& derivs) {
DEMBase<Dimension>::applyGhostBoundaries(state,derivs);
auto I = state.fields(DEMFieldNames::momentOfInertia,0.0);
for (ConstBoundaryIterator boundaryItr = this->boundaryBegin();
boundaryItr != this->boundaryEnd();
++boundaryItr) {
(*boundaryItr)->applyFieldListGhostBoundary(I);
}
}

//------------------------------------------------------------------------------
// Enforce the boundary conditions for linear dem state fields.
//------------------------------------------------------------------------------
template<typename Dimension>
void
LinearSpringDEM<Dimension>::
enforceBoundaries(State<Dimension>& state,
StateDerivatives<Dimension>& derivs) {

DEMBase<Dimension>::enforceBoundaries(state,derivs);

auto I = state.fields(DEMFieldNames::momentOfInertia,0.0);

for (ConstBoundaryIterator boundaryItr = this->boundaryBegin();
boundaryItr != this->boundaryEnd();
++boundaryItr) {
(*boundaryItr)->enforceFieldListBoundary(I);
}
}

//------------------------------------------------------------------------------
// Dump the current state to the given file.
//------------------------------------------------------------------------------
template<typename Dimension>
void
LinearSpringDEM<Dimension>::
dumpState(FileIO& file, const string& pathName) const {
DEMBase<Dimension>::dumpState(file,pathName);
file.write(mMomentOfInertia, pathName + "/momentOfInertia");
}

//------------------------------------------------------------------------------
// Restore the state from the given file.
//------------------------------------------------------------------------------
template<typename Dimension>
void
LinearSpringDEM<Dimension>::
restoreState(const FileIO& file, const string& pathName) {
DEMBase<Dimension>::restoreState(file,pathName);
file.read(mMomentOfInertia, pathName + "/momentOfInertia");
}
} // namespace

13 changes: 10 additions & 3 deletions src/DEM/LinearSpringDEM.hh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public:
typedef typename Dimension::Vector Vector;

typedef typename DEMBase<Dimension>::TimeStepType TimeStepType;

typedef typename Physics<Dimension>::ConstBoundaryIterator ConstBoundaryIterator;

LinearSpringDEM(const DataBase<Dimension>& dataBase,
const Scalar normalSpringConstant,
const Scalar normalRestitutionCoefficient,
Expand Down Expand Up @@ -69,6 +70,12 @@ public:
const DataBase<Dimension>& dataBase,
const State<Dimension>& state,
StateDerivatives<Dimension>& derivs) const override;
virtual
void applyGhostBoundaries(State<Dimension>& state,
StateDerivatives<Dimension>& derivs) override;
virtual
void enforceBoundaries(State<Dimension>& state,
StateDerivatives<Dimension>& derivs) override;

// set/gets
Scalar normalSpringConstant() const;
Expand Down Expand Up @@ -121,8 +128,8 @@ public:
//****************************************************************************
// Methods required for restarting.
virtual std::string label() const override { return "LinearSpringDEM" ; }
//virtual void dumpState(FileIO& file, const std::string& pathName) const;
//virtual void restoreState(const FileIO& file, const std::string& pathName);
virtual void dumpState(FileIO& file, const std::string& pathName) const;
virtual void restoreState(const FileIO& file, const std::string& pathName);
//****************************************************************************
private:
//--------------------------- Private Interface ---------------------------//
Expand Down