BaseCoupling< M, O > Class Template Reference

#include <BaseCoupling.h>

+ Inheritance diagram for BaseCoupling< M, O >:

Public Member Functions

 BaseCoupling ()=default
 
void setName (std::string name)
 
std::string getName () const
 
void removeOldFiles () const
 
void writeEneTimeStep (std::ostream &os) const override
 
void writeEneHeader (std::ostream &os) const override
 
void solveOomph ()
 
void solveMercury (unsigned long nt)
 
void setCGWidth (const double &width)
 
double getCGWidth ()
 
bool useCGMapping ()
 
CGFunctions::LucyXYZ getCGFunction ()
 

Private Attributes

bool CGMapping_ = false
 
CGFunctions::LucyXYZ cgFunction_
 

Detailed Description

template<class M, class O>
class BaseCoupling< M, O >

Common functionality for both surface- and volume-coupled problems:

  • defines a cg function
  • getParticlesInCell to find particles in a particular region
  • modifies the ene files to add coupled mass and energy
  • solveOomph and solveMercury functions to advance the two solutions in time
    Author
    Hongyang Cheng chyal.nosp@m.exch.nosp@m.eng@g.nosp@m.mail.nosp@m..com

Constructor & Destructor Documentation

◆ BaseCoupling()

template<class M , class O >
BaseCoupling< M, O >::BaseCoupling ( )
default

Member Function Documentation

◆ getCGFunction()

template<class M , class O >
CGFunctions::LucyXYZ BaseCoupling< M, O >::getCGFunction ( )
inline
185  { return cgFunction_; }
CGFunctions::LucyXYZ cgFunction_
Definition: BaseCoupling.h:191

References BaseCoupling< M, O >::cgFunction_.

Referenced by VolumeCoupling::getProjectionMatrix().

◆ getCGWidth()

template<class M , class O >
double BaseCoupling< M, O >::getCGWidth ( )
inline

get the dimensionalized CG width to be used in MercuryProblem

177  {
178  return cgFunction_.getWidth();
179  }
Mdouble getWidth() const

References BaseCoupling< M, O >::cgFunction_, and CGFunctions::Polynomial< Coordinates >::getWidth().

Referenced by VolumeCoupling::checkParticlesInFiniteElems(), and SCoupling< M, O >::getElementBoundingBox().

◆ getName()

template<class M , class O >
std::string BaseCoupling< M, O >::getName ( ) const
inline
64  {
65  return M::getName();
66  }
std::string getName(int argc, char *argv[])
Definition: CombineParallelDataFiles.cpp:12

References getName().

Referenced by ScaleCoupledBeam::actionsBeforeSolve(), CoupledBeam::actionsBeforeSolve(), CoupledProblem::CoupledProblem(), and CoupledProblem::getSolidDeflection().

◆ removeOldFiles()

template<class M , class O >
void BaseCoupling< M, O >::removeOldFiles ( ) const
inline
68  {
69  M::removeOldFiles();
70  O::removeOldFiles();
71  }

Referenced by CoupledBeam::CoupledBeam(), CoupledProblem::CoupledProblem(), ElementAnalysis::ElementAnalysis(), and ScaleCoupledBeam::ScaleCoupledBeam().

◆ setCGWidth()

template<class M , class O >
void BaseCoupling< M, O >::setCGWidth ( const double width)
inline
159  {
160  if (width == 0)
161  {
162  CGMapping_ = false;
163  }
164  else
165  {
166  CGMapping_ = true;
167  // note CG function needs to be nondimensionalized
168  // fixme CG width is not set with respect to particle radius. Should we do that?
169  cgFunction_.setWidth(width);
170  }
171  }
bool CGMapping_
Definition: BaseCoupling.h:189
void setWidth(Mdouble width)
Set the cutoff radius.

References BaseCoupling< M, O >::cgFunction_, BaseCoupling< M, O >::CGMapping_, and CGFunctions::Polynomial< Coordinates >::setWidth().

Referenced by VolumeCoupling::solveVolumeCoupling().

◆ setName()

template<class M , class O >
void BaseCoupling< M, O >::setName ( std::string  name)
inline
59  {
60  M::setName(name);
61  O::setName(name);
62  }
std::string name
Definition: MercuryProb.h:48

References units::name.

Referenced by CoupledBeam::CoupledBeam(), CoupledProblem::CoupledProblem(), ElementAnalysis::ElementAnalysis(), main(), and ScaleCoupledBeam::ScaleCoupledBeam().

◆ solveMercury()

template<class M , class O >
void BaseCoupling< M, O >::solveMercury ( unsigned long  nt)
inline

solve a given number of time steps nt in Mercury

151  {
152  for (int n = 0; n < nt; ++n)
153  {
154  M::computeOneTimeStep();
155  }
156  }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:32

References n.

Referenced by SCoupling< M, O >::computeOneTimeStepForSCoupling(), and VolumeCoupling::computeOneTimeStepForVCoupling().

◆ solveOomph()

template<class M , class O >
void BaseCoupling< M, O >::solveOomph ( )
inline

used in OomphMercuryCoupling::computeOneTimeStepForV/SCoupling to do a oomph timestep (V/SCoupling)

142  {
143  O::actionsBeforeOomphTimeStep();
144  this->unsteady_newton_solve(this->time_pt()->dt());
145  }

Referenced by SCoupling< M, O >::computeOneTimeStepForSCoupling(), and VolumeCoupling::computeOneTimeStepForVCoupling().

◆ useCGMapping()

◆ writeEneHeader()

template<class M , class O >
void BaseCoupling< M, O >::writeEneHeader ( std::ostream &  os) const
inlineoverride

override writeEneHeader in DPMBase class for the coupling

113  {
114  //only write if we don't restart
115  if (M::getAppend()) {
116  return;
117  }
118 
119  long width = os.precision() + 6;
120  os << std::setw(width)
121  << "time " << std::setw(width)
122  << "mass " << std::setw(width)
123  << "momentum_X " << std::setw(width)
124  << "momentum_Y " << std::setw(width)
125  << "momentum_Z " << std::setw(width)
126  << "angMomentum_X " << std::setw(width)
127  << "angMomentum_Y " << std::setw(width)
128  << "angMomentum_Z " << std::setw(width)
129  << "gravitEnergy " << std::setw(width) //gravitational potential energy
130  << "traKineticEnergy " << std::setw(width) //translational kinetic energy
131  << "rotKineticEnergy " << std::setw(width) //rotational kE
132  << "elasticEnergy " << std::setw(width)
133  << "centerOfMassX " << std::setw(width)
134  << "centerOfMassY " << std::setw(width)
135  << "centerOfMassZ\n";
136  }

Referenced by BaseCoupling< M, O >::writeEneTimeStep().

◆ writeEneTimeStep()

template<class M , class O >
void BaseCoupling< M, O >::writeEneTimeStep ( std::ostream &  os) const
inlineoverride

override writeEneTimeStep because mass and elastic energy are computed different for the coupling; also adds momentum and angular momentum

77  {
78  if (M::eneFile.getCounter() == 1 || M::eneFile.getFileType() == FileType::MULTIPLE_FILES ||
79  M::eneFile.getFileType() == FileType::MULTIPLE_FILES_PADDED)
80  {
81  writeEneHeader(os);
82  }
83 
84  const Mdouble m = M::particleHandler.getMass();
85  const Vec3D com = M::particleHandler.getMassTimesPosition();
86  //Ensure the numbers fit into a constant width column: for this we need the precision given by the operating system,
87  //plus a few extra characters for characters like a minus and scientific notation.
88  const static long int width = os.precision() + 6;
89  os << std::setw(width) << M::getTime()
90 // << " " << std::setw(width) << getCoupledMass()
91  << " " << std::setw(width) << M::particleHandler.getMomentum().getX()
92  << " " << std::setw(width) << M::particleHandler.getMomentum().getY()
93  << " " << std::setw(width) << M::particleHandler.getMomentum().getZ()
94  << " " << std::setw(width) << M::particleHandler.getAngularMomentum().getX()
95  << " " << std::setw(width) << M::particleHandler.getAngularMomentum().getY()
96  << " " << std::setw(width) << M::particleHandler.getAngularMomentum().getZ()
97  << " " << std::setw(width) << -Vec3D::dot(M::getGravity(), com)
98  << " " << std::setw(width) << M::particleHandler.getKineticEnergy()
99  << " " << std::setw(width) << M::particleHandler.getRotationalEnergy()
100  //<< " " << std::setw(width) << M::getElasticEnergyCoupled()
101  // we need to write x, y and z coordinates separately, otherwise the width of the columns is incorrect
102  << " " << std::setw(width)
103  << ( m == 0 ? constants::NaN : com.X / m ) //set to nan because 0/0 implementation in gcc and clang differs
104  << " " << std::setw(width) << ( m == 0 ? constants::NaN : com.Y / m )
105  << " " << std::setw(width) << ( m == 0 ? constants::NaN : com.Z / m )
106  << std::endl;
107  }
@ MULTIPLE_FILES
each time-step will be written into/read from separate files numbered consecutively: name_....
@ MULTIPLE_FILES_PADDED
each time-step will be written into/read from separate files numbered consecutively,...
double Mdouble
Definition: GeneralDefine.h:34
void writeEneHeader(std::ostream &os) const override
Definition: BaseCoupling.h:112
Definition: Vector.h:51
Mdouble Y
Definition: Vector.h:66
Mdouble Z
Definition: Vector.h:66
Mdouble X
the vector components
Definition: Vector.h:66
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
Mdouble getX() const
Definition: Vector.h:402
const Mdouble NaN
Definition: GeneralDefine.h:43

References Vec3D::dot(), Vec3D::getX(), MULTIPLE_FILES, MULTIPLE_FILES_PADDED, constants::NaN, BaseCoupling< M, O >::writeEneHeader(), Vec3D::X, Vec3D::Y, and Vec3D::Z.

Member Data Documentation

◆ cgFunction_

◆ CGMapping_

template<class M , class O >
bool BaseCoupling< M, O >::CGMapping_ = false
private

The documentation for this class was generated from the following file: