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 (int max_adapt=0)
 
void checkResidual ()
 
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

◆ checkResidual()

template<class M , class O >
void BaseCoupling< M, O >::checkResidual ( )
inline
137  {
138  oomph::DoubleVector residual;
139  O::get_residuals(residual);
140  double residualNorm = residual.max();
141  if (residualNorm == 0) {
142  logger(ERROR, "Maximum residuals %; the computation has failed and the code will exit", residualNorm);
143  }
144  }
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ ERROR
Definition: double_vector.h:58
double max() const
returns the maximum coefficient
Definition: double_vector.cc:604
void get_residuals(const Vector< double > &param, const Vector< double > &unknowns, Vector< double > &residuals)
Global residual fct.
Definition: spring_contact.cc:65

References ERROR, GlobalFct::get_residuals(), logger, and oomph::DoubleVector::max().

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

◆ getCGFunction()

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

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

176  {
177  return cgFunction_.getWidth();
178  }
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
43  {
44  return M::getName();
45  }
std::string getName(int argc, char *argv[])
Definition: CombineParallelDataFiles.cpp:16

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
47  {
48  M::removeOldFiles();
49  O::removeOldFiles();
50  }

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
158  {
159  if (width == 0)
160  {
161  CGMapping_ = false;
162  }
163  else
164  {
165  CGMapping_ = true;
166  // note CG function needs to be nondimensionalized
167  // fixme CG width is not set with respect to particle radius. Should we do that?
168  cgFunction_.setWidth(width);
169  }
170  }
bool CGMapping_
Definition: BaseCoupling.h:188
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
38  {
39  M::setName(name);
40  O::setName(name);
41  }
string name
Definition: plotDoE.py:33

References plotDoE::name.

Referenced by CoupledBeam::CoupledBeam(), CoupledProblem::CoupledProblem(), ElementAnalysis::ElementAnalysis(), 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

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

References n.

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

◆ solveOomph()

template<class M , class O >
void BaseCoupling< M, O >::solveOomph ( int  max_adapt = 0)
inline

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

121  {
122  O::actionsBeforeOomphTimeStep();
123  // the coupled codes seem to not work if newton_solve is used
124  //this->newton_solve(this->time_pt()->dt());
125  if(max_adapt <= 0)
126  {
127  this->unsteady_newton_solve(this->time_pt()->dt());
128  }
129  else
130  {
131  this->unsteady_newton_solve(this->time_pt()->dt(), max_adapt, false);
132  }
133  checkResidual();
134  }
void checkResidual()
Definition: BaseCoupling.h:137

References BaseCoupling< M, O >::checkResidual().

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

92  {
93  //only write if we don't restart
94  if (M::getAppend()) {
95  return;
96  }
97 
98  long width = os.precision() + 6;
99  os << std::setw(width)
100  << "time " << std::setw(width)
101  << "mass " << std::setw(width)
102  << "momentum_X " << std::setw(width)
103  << "momentum_Y " << std::setw(width)
104  << "momentum_Z " << std::setw(width)
105  << "angMomentum_X " << std::setw(width)
106  << "angMomentum_Y " << std::setw(width)
107  << "angMomentum_Z " << std::setw(width)
108  << "gravitEnergy " << std::setw(width) //gravitational potential energy
109  << "traKineticEnergy " << std::setw(width) //translational kinetic energy
110  << "rotKineticEnergy " << std::setw(width) //rotational kE
111  << "elasticEnergy " << std::setw(width)
112  << "centerOfMassX " << std::setw(width)
113  << "centerOfMassY " << std::setw(width)
114  << "centerOfMassZ\n";
115  }

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

56  {
57  if (M::eneFile.getCounter() == 1 || M::eneFile.getFileType() == FileType::MULTIPLE_FILES ||
58  M::eneFile.getFileType() == FileType::MULTIPLE_FILES_PADDED)
59  {
60  writeEneHeader(os);
61  }
62 
63  const Mdouble m = M::particleHandler.getMass();
64  const Vec3D com = M::particleHandler.getMassTimesPosition();
65  //Ensure the numbers fit into a constant width column: for this we need the precision given by the operating system,
66  //plus a few extra characters for characters like a minus and scientific notation.
67  const static long int width = os.precision() + 6;
68  os << std::setw(width) << M::getTime()
69 // << " " << std::setw(width) << getCoupledMass()
70  << " " << std::setw(width) << M::particleHandler.getMomentum().getX()
71  << " " << std::setw(width) << M::particleHandler.getMomentum().getY()
72  << " " << std::setw(width) << M::particleHandler.getMomentum().getZ()
73  << " " << std::setw(width) << M::particleHandler.getAngularMomentum().getX()
74  << " " << std::setw(width) << M::particleHandler.getAngularMomentum().getY()
75  << " " << std::setw(width) << M::particleHandler.getAngularMomentum().getZ()
76  << " " << std::setw(width) << -Vec3D::dot(M::getGravity(), com)
77  << " " << std::setw(width) << M::particleHandler.getKineticEnergy()
78  << " " << std::setw(width) << M::particleHandler.getRotationalEnergy()
79  //<< " " << std::setw(width) << M::getElasticEnergyCoupled()
80  // we need to write x, y and z coordinates separately, otherwise the width of the columns is incorrect
81  << " " << std::setw(width)
82  << ( m == 0 ? constants::NaN : com.X / m ) //set to nan because 0/0 implementation in gcc and clang differs
83  << " " << std::setw(width) << ( m == 0 ? constants::NaN : com.Y / m )
84  << " " << std::setw(width) << ( m == 0 ? constants::NaN : com.Z / m )
85  << std::endl;
86  }
@ 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,...
void writeEneHeader(std::ostream &os) const override
Definition: BaseCoupling.h:91
Definition: Kernel/Math/Vector.h:30
Mdouble Y
Definition: Kernel/Math/Vector.h:45
Mdouble Z
Definition: Kernel/Math/Vector.h:45
Mdouble X
the vector components
Definition: Kernel/Math/Vector.h:45
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:56
Mdouble getX() const
Definition: Kernel/Math/Vector.h:431
int * m
Definition: level2_cplx_impl.h:294
const Mdouble NaN
Definition: GeneralDefine.h:22

References Vec3D::dot(), Vec3D::getX(), m, 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: