diff --git a/src/DEM/LinearSpringDEM.cc b/src/DEM/LinearSpringDEM.cc index 1fc539648..c658e387e 100644 --- a/src/DEM/LinearSpringDEM.cc +++ b/src/DEM/LinearSpringDEM.cc @@ -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" @@ -40,6 +42,7 @@ #include #include +using std::string; using std::make_pair; using std::to_string; @@ -823,5 +826,66 @@ setMomentOfInertia() { } // loop nodes } // loop nodelists } // method -} // namespace + + + +//------------------------------------------------------------------------------ +// Apply the ghost boundary conditions for linear dem state fields. +//------------------------------------------------------------------------------ +template +void +LinearSpringDEM:: +applyGhostBoundaries(State& state, + StateDerivatives& derivs) { + DEMBase::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 +void +LinearSpringDEM:: +enforceBoundaries(State& state, + StateDerivatives& derivs) { + + DEMBase::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 +void +LinearSpringDEM:: +dumpState(FileIO& file, const string& pathName) const { + DEMBase::dumpState(file,pathName); + file.write(mMomentOfInertia, pathName + "/momentOfInertia"); +} + +//------------------------------------------------------------------------------ +// Restore the state from the given file. +//------------------------------------------------------------------------------ +template +void +LinearSpringDEM:: +restoreState(const FileIO& file, const string& pathName) { + DEMBase::restoreState(file,pathName); + file.read(mMomentOfInertia, pathName + "/momentOfInertia"); +} +} // namespace diff --git a/src/DEM/LinearSpringDEM.hh b/src/DEM/LinearSpringDEM.hh index ede322207..bc8790390 100644 --- a/src/DEM/LinearSpringDEM.hh +++ b/src/DEM/LinearSpringDEM.hh @@ -35,7 +35,8 @@ public: typedef typename Dimension::Vector Vector; typedef typename DEMBase::TimeStepType TimeStepType; - + typedef typename Physics::ConstBoundaryIterator ConstBoundaryIterator; + LinearSpringDEM(const DataBase& dataBase, const Scalar normalSpringConstant, const Scalar normalRestitutionCoefficient, @@ -69,6 +70,12 @@ public: const DataBase& dataBase, const State& state, StateDerivatives& derivs) const override; + virtual + void applyGhostBoundaries(State& state, + StateDerivatives& derivs) override; + virtual + void enforceBoundaries(State& state, + StateDerivatives& derivs) override; // set/gets Scalar normalSpringConstant() const; @@ -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 ---------------------------//