Planetary Orbital Evolution due to Tides
Orbital evolution of two objects experiencing tides
StoppingCondition.h
Go to the documentation of this file.
1 
8 #ifndef __STOPPING_CONDITION_H
9 #define __STOPPING_CONDITION_H
10 
11 #include "../Core/SharedLibraryExportMacros.h"
12 #include "../Core/Common.h"
13 
14 #include <cassert>
15 
16 namespace Evolve {
17 
22 
26 
29 
32 
36 
39 
42 
46  }; //End StoppingConditionType enumeration.
47 
49  LIB_LOCAL std::ostream &operator<<(std::ostream &os,
50  const StoppingConditionType &stop_cond_type);
51 
58  class LIB_LOCAL StoppingCondition {
59  private:
63  public:
66  short expected_crossing_deriv_sign = 0
67  )
68  : __expected_crossing_deriv_sign(expected_crossing_deriv_sign)
69  {}
70 
75  virtual std::valarray<double> operator()(
79  Core::EvolModeType evol_mode,
80 
83  const std::valarray<double> &orbit,
84 
87  const std::valarray<double> &derivatives,
88 
91  std::valarray<double> &stop_deriv
92  ) const = 0;
93 
95  virtual size_t num_subconditions() const {return 1;}
96 
98  virtual StoppingConditionType type(unsigned index=0) const=0;
99 
106  virtual void reached(
109  short deriv_sign,
110 
112  unsigned
113 #ifndef NDEBUG
114  index
115 #endif
116  =0)
117  {
118  assert(index == 0);
119  assert(__expected_crossing_deriv_sign == deriv_sign);
120 
121  __expected_crossing_deriv_sign = -deriv_sign;
122  }
123 
129  unsigned
130 #ifndef NDEBUG
131  index
132 #endif
133  =0) const
134  {
135  assert(index == 0);
136 
137  return __expected_crossing_deriv_sign;
138  }
139 
142  virtual std::string describe(int index = -1) const = 0;
143 
144  virtual ~StoppingCondition() {}
145  };//End StoppingCondition class.
146 
150  class LIB_LOCAL NoStopCondition : public StoppingCondition {
151  public:
156  std::valarray<double> operator()(
157  Core::EvolModeType, const std::valarray<double> &,
158  const std::valarray<double> &,
159  std::valarray<double> &stop_deriv) const
160  {stop_deriv.resize(1, Core::NaN); return std::valarray<double>(1, 1);}
161 
163  StoppingConditionType type(unsigned =0) const {return NO_STOP;}
164 
166  void reached(short, unsigned=0)
167  {assert(false);}
168  }; //End NoStopCondition class.
169 
173  class LIB_LOCAL ExternalStoppingCondition : public StoppingCondition {
174  public:
176  StoppingConditionType type(unsigned =0) const {return EXTERNAL;}
177  };
178 
179 }//End Evolve namespace.
180 
181 #endif
A stopping condition that is never satisfied.
StoppingConditionType type(unsigned=0) const
Identifies the condition as NO_STOP.
The spin-orbit lock can no longer be maintaned.
std::ostream & operator<<(std::ostream &os, const ZoneEvolutionQuantities &evol_var)
More civilized output for EvolVarType variables.
A base class for all external stopping conditions.
std::valarray< double > operator()(Core::EvolModeType, const std::valarray< double > &, const std::valarray< double > &, std::valarray< double > &stop_deriv) const
The error due to truncating the eccentricity expansion is too small.
virtual size_t num_subconditions() const
The number of subconditions in the current condition.
StoppingConditionType
The reasons for stopping the evolution currently supported.
Orientations of zones of bodies in a binary system.
StoppingConditionType type(unsigned=0) const
Identify this as an EXTERNAL condition.
The error due to truncating the eccentricity expansion is too large.
No reason to stop.
The planet died.
virtual short expected_crossing_deriv_sign(unsigned index=0) const
The expected sign of the derivative at the next zero-crossing.
A base class for all stopping conditions.
StoppingCondition(short expected_crossing_deriv_sign=0)
Create a generic stopping condition.
short __expected_crossing_deriv_sign
The sign of the first derivative at the next zero-crossing of this condition.
EvolModeType
The various evolution modes.
Definition: Common.h:42
void reached(short, unsigned=0)
See StoppingCondition::reached().
virtual void reached(short deriv_sign, unsigned index=0)
Called when a stopping condition has been reached by the evolution.