Processing math: 0%
libMesh
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
libMesh::AdaptiveTimeSolver Class Referenceabstract

This class wraps another UnsteadySolver derived class, and compares the results of timestepping with deltat and timestepping with 2*deltat to adjust future timestep lengths. More...

#include <adaptive_time_solver.h>

Inheritance diagram for libMesh::AdaptiveTimeSolver:
[legend]

Public Types

typedef FirstOrderUnsteadySolver Parent
 The parent class. More...
 
typedef DifferentiableSystem sys_type
 The type of system. More...
 

Public Member Functions

 AdaptiveTimeSolver (sys_type &s)
 Constructor. More...
 
virtual ~AdaptiveTimeSolver ()
 Destructor. More...
 
virtual void init () override
 The initialization function. More...
 
virtual void reinit () override
 The reinitialization function. More...
 
virtual void solve () override=0
 This method solves for the solution at the next timestep. More...
 
virtual std::pair< unsigned int, Realadjoint_solve (const QoISet &qoi_indices) override=0
 This method solves for the adjoint solution at the next adjoint timestep (or a steady state adjoint solve) More...
 
virtual void advance_timestep () override
 This method advances the solution to the next timestep, after a solve() has been performed. More...
 
virtual void adjoint_advance_timestep () override
 This method advances the adjoint solution to the previous timestep, after an adjoint_solve() has been performed. More...
 
virtual void retrieve_timestep () override
 This method retrieves all the stored solutions at the current system.time. More...
 
virtual void integrate_qoi_timestep () override=0
 A method to integrate the system::QoI functionals. More...
 
virtual void integrate_adjoint_sensitivity (const QoISet &qois, const ParameterVector &parameter_vector, SensitivityData &sensitivities) override=0
 A method to integrate the adjoint sensitivity w.r.t a given parameter vector. More...
 
virtual void integrate_adjoint_refinement_error_estimate (AdjointRefinementEstimator &adjoint_refinement_error_estimator, ErrorVector &QoI_elementwise_error) override=0
 A method to compute the adjoint refinement error estimate at the current timestep. More...
 
virtual Real last_completed_timestep_size () override
 Returns system.deltat if fixed timestep solver is used, the complete timestep size (sum of all substeps) if the adaptive time solver is used. More...
 
virtual Real error_order () const override
 This method is passed on to the core_time_solver. More...
 
virtual bool element_residual (bool get_jacobian, DiffContext &) override
 This method is passed on to the core_time_solver. More...
 
virtual bool side_residual (bool get_jacobian, DiffContext &) override
 This method is passed on to the core_time_solver. More...
 
virtual bool nonlocal_residual (bool get_jacobian, DiffContext &) override
 This method is passed on to the core_time_solver. More...
 
virtual std::unique_ptr< DiffSolver > & diff_solver () override
 An implicit linear or nonlinear solver to use at each timestep. More...
 
virtual std::unique_ptr< LinearSolver< Number > > & linear_solver () override
 An implicit linear solver to use for adjoint and sensitivity problems. More...
 
virtual unsigned int time_order () const override
 
virtual void init_adjoints () override
 Add adjoint vectors and old_adjoint_vectors as per the indices of QoISet. More...
 
virtual void init_data () override
 The data initialization function. More...
 
void update ()
 
Number old_nonlinear_solution (const dof_id_type global_dof_number) const
 
virtual Real du (const SystemNorm &norm) const override
 Computes the size of ||u^{n+1} - u^{n}|| in some norm. More...
 
virtual bool is_steady () const override
 This is not a steady-state solver. More...
 
void set_first_adjoint_step (bool first_adjoint_step_setting)
 A setter for the first_adjoint_step boolean. More...
 
void set_first_solve (bool first_solve_setting)
 
virtual void before_timestep ()
 This method is for subclasses or users to override to do arbitrary processing between timesteps. More...
 
const sys_typesystem () const
 
sys_typesystem ()
 
void set_solution_history (const SolutionHistory &_solution_history)
 A setter function users will employ if they need to do something other than save no solution history. More...
 
SolutionHistoryget_solution_history ()
 A getter function that returns a reference to the solution history object owned by TimeSolver. More...
 
bool is_adjoint () const
 Accessor for querying whether we need to do a primal or adjoint solve. More...
 
void set_is_adjoint (bool _is_adjoint_value)
 Accessor for setting whether we need to do a primal or adjoint solve. More...
 

Static Public Member Functions

static std::string get_info ()
 Gets a string containing the reference information. More...
 
static void print_info (std::ostream &out_stream=libMesh::out)
 Prints the reference information, by default to libMesh::out. More...
 
static unsigned int n_objects ()
 Prints the number of outstanding (created, but not yet destroyed) objects. More...
 
static void enable_print_counter_info ()
 Methods to enable/disable the reference counter output from print_info() More...
 
static void disable_print_counter_info ()
 

Public Attributes

std::unique_ptr< UnsteadySolvercore_time_solver
 This object is used to take timesteps. More...
 
SystemNorm component_norm
 Error calculations are done in this norm, DISCRETE_L2 by default. More...
 
std::vector< float > component_scale
 If component_norms is non-empty, each variable's contribution to the error of a system will also be scaled by component_scale[var], unless component_scale is empty in which case all variables will be weighted equally. More...
 
Real target_tolerance
 This tolerance is the target relative error between an exact time integration and a single time step output, scaled by deltat. More...
 
Real upper_tolerance
 This tolerance is the maximum relative error between an exact time integration and a single time step output, scaled by deltat. More...
 
Real max_deltat
 Do not allow the adaptive time solver to select deltat > max_deltat. More...
 
Real min_deltat
 Do not allow the adaptive time solver to select deltat < min_deltat. More...
 
Real max_growth
 Do not allow the adaptive time solver to select a new deltat greater than max_growth times the old deltat. More...
 
Real completed_timestep_size
 The adaptive time solver's have two notions of deltat. More...
 
bool global_tolerance
 This flag, which is true by default, grows (shrinks) the timestep based on the expected global accuracy of the timestepping scheme. More...
 
std::shared_ptr< NumericVector< Number > > old_local_nonlinear_solution
 Serial vector of _system.get_vector("_old_nonlinear_solution") This is a shared_ptr so that it can be shared between different derived class instances, as in e.g. More...
 
bool quiet
 Print extra debugging information if quiet == false. More...
 
unsigned int reduce_deltat_on_diffsolver_failure
 This value (which defaults to zero) is the number of times the TimeSolver is allowed to halve deltat and let the DiffSolver repeat the latest failed solve with a reduced timestep. More...
 

Protected Types

typedef bool(DifferentiablePhysics::* ResFuncType) (bool, DiffContext &)
 Definitions of argument types for use in refactoring subclasses. More...
 
typedef void(DiffContext::* ReinitFuncType) (Real)
 
typedef std::map< std::string, std::pair< unsigned int, unsigned int > > Counts
 Data structure to log the information. More...
 

Protected Member Functions

virtual Real calculate_norm (System &, NumericVector< Number > &)
 A helper function to calculate error norms. More...
 
void prepare_accel (DiffContext &context)
 If there are second order variables in the system, then we also prepare the accel for those variables so the user can treat them as such. More...
 
bool compute_second_order_eqns (bool compute_jacobian, DiffContext &c)
 If there are second order variables, then we need to compute their residual equations and corresponding Jacobian. More...
 
void increment_constructor_count (const std::string &name) noexcept
 Increments the construction counter. More...
 
void increment_destructor_count (const std::string &name) noexcept
 Increments the destruction counter. More...
 

Protected Attributes

bool first_solve
 A bool that will be true the first time solve() is called, and false thereafter. More...
 
bool first_adjoint_step
 A bool that will be true the first time adjoint_advance_timestep() is called, (when the primal solution is to be used to set adjoint boundary conditions) and false thereafter. More...
 
std::vector< std::unique_ptr< NumericVector< Number > > > old_adjoints
 A vector of pointers to vectors holding the adjoint solution at the last time step. More...
 
Real last_step_deltat
 We will need to move the system.time around to ensure that residuals are built with the right deltat and the right time. More...
 
Real next_step_deltat
 
std::unique_ptr< DiffSolver_diff_solver
 An implicit linear or nonlinear solver to use at each timestep. More...
 
std::unique_ptr< LinearSolver< Number > > _linear_solver
 An implicit linear solver to use for adjoint problems. More...
 
sys_type_system
 A reference to the system we are solving. More...
 
std::unique_ptr< SolutionHistorysolution_history
 A std::unique_ptr to a SolutionHistory object. More...
 
Real last_deltat
 The deltat for the last completed timestep before the current one. More...
 

Static Protected Attributes

static Counts _counts
 Actually holds the data. More...
 
static Threads::atomic< unsigned int_n_objects
 The number of objects. More...
 
static Threads::spin_mutex _mutex
 Mutual exclusion object to enable thread-safe reference counting. More...
 
static bool _enable_print_counter = true
 Flag to control whether reference count information is printed when print_info is called. More...
 

Detailed Description

This class wraps another UnsteadySolver derived class, and compares the results of timestepping with deltat and timestepping with 2*deltat to adjust future timestep lengths.

Currently this class only works on fully coupled Systems

This class is part of the new DifferentiableSystem framework, which is still experimental. Users of this framework should beware of bugs and future API changes.

Author
Roy H. Stogner
Date
2007

Definition at line 49 of file adaptive_time_solver.h.

Member Typedef Documentation

◆ Counts

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts
protectedinherited

Data structure to log the information.

The log is identified by the class name.

Definition at line 119 of file reference_counter.h.

◆ Parent

The parent class.

Definition at line 55 of file adaptive_time_solver.h.

◆ ReinitFuncType

typedef void(DiffContext::* libMesh::TimeSolver::ReinitFuncType) (Real)
protectedinherited

Definition at line 327 of file time_solver.h.

◆ ResFuncType

typedef bool(DifferentiablePhysics::* libMesh::TimeSolver::ResFuncType) (bool, DiffContext &)
protectedinherited

Definitions of argument types for use in refactoring subclasses.

Definition at line 325 of file time_solver.h.

◆ sys_type

The type of system.

Definition at line 69 of file time_solver.h.

Constructor & Destructor Documentation

◆ AdaptiveTimeSolver()

libMesh::AdaptiveTimeSolver::AdaptiveTimeSolver ( sys_type s)
explicit

Constructor.

Requires a reference to the system to be solved.

Definition at line 33 of file adaptive_time_solver.C.

36  target_tolerance(1.e-3),
37  upper_tolerance(0.0),
38  max_deltat(0.),
39  min_deltat(0.),
40  max_growth(0.),
41  completed_timestep_size(s.deltat),
42  global_tolerance(true)
43 {
44  // the child class must populate core_time_solver
45  // with whatever actual time solver is to be used
46 }
Real completed_timestep_size
The adaptive time solver&#39;s have two notions of deltat.
Real target_tolerance
This tolerance is the target relative error between an exact time integration and a single time step ...
FirstOrderUnsteadySolver(sys_type &s)
Constructor.
bool global_tolerance
This flag, which is true by default, grows (shrinks) the timestep based on the expected global accura...
Real max_deltat
Do not allow the adaptive time solver to select deltat > max_deltat.
Real upper_tolerance
This tolerance is the maximum relative error between an exact time integration and a single time step...
Real min_deltat
Do not allow the adaptive time solver to select deltat < min_deltat.
std::unique_ptr< UnsteadySolver > core_time_solver
This object is used to take timesteps.
Real max_growth
Do not allow the adaptive time solver to select a new deltat greater than max_growth times the old de...

◆ ~AdaptiveTimeSolver()

libMesh::AdaptiveTimeSolver::~AdaptiveTimeSolver ( )
virtualdefault

Destructor.

Member Function Documentation

◆ adjoint_advance_timestep()

void libMesh::AdaptiveTimeSolver::adjoint_advance_timestep ( )
overridevirtual

This method advances the adjoint solution to the previous timestep, after an adjoint_solve() has been performed.

This will be done before every UnsteadySolver::adjoint_solve().

Reimplemented from libMesh::UnsteadySolver.

Definition at line 126 of file adaptive_time_solver.C.

References libMesh::TimeSolver::_system, core_time_solver, libMesh::DifferentiableSystem::deltat, libMesh::UnsteadySolver::first_adjoint_step, libMesh::System::get_adjoint_solution(), libMesh::System::get_dof_map(), libMesh::DofMap::get_send_list(), libMesh::System::get_vector(), libMesh::NumericVector< T >::localize(), libMesh::make_range(), libMesh::System::n_qois(), libMesh::UnsteadySolver::old_local_nonlinear_solution, and libMesh::System::time.

127 {
128  // Store the computed full step adjoint solution for future use (sub steps are handled internally by the core time solver)
129  core_time_solver->get_solution_history().store(true, _system.time);
130 
131  // For the first adjoint step ensure that we use the last primal timestep.
132  if (first_adjoint_step)
133  {
134  _system.deltat = dynamic_cast<DifferentiableSystem &>(_system).time_solver->TimeSolver::last_completed_timestep_size();
135  first_adjoint_step = false;
136  }
137 
138  // Before moving to the next time instant, copy over the current adjoint solutions into _old_adjoint_solutions
139  for(auto i : make_range(_system.n_qois()))
140  {
141  std::string old_adjoint_solution_name = "_old_adjoint_solution";
142  old_adjoint_solution_name+= std::to_string(i);
143  NumericVector<Number> & old_adjoint_solution_i = _system.get_vector(old_adjoint_solution_name);
144  NumericVector<Number> & adjoint_solution_i = _system.get_adjoint_solution(i);
145  old_adjoint_solution_i = adjoint_solution_i;
146  }
147 
149 
150  // For the adaptive time solver, all SH operations
151  // are handled by the core_time_solver's SH object
152  // Retrieve the primal solution for the next adjoint calculation,
153  // by using the core time solver's solution history object.
154  core_time_solver->get_solution_history().retrieve(true, _system.time);
155 
156  // We also need to tell the core time solver that the adjoint initial conditions have been set
157  core_time_solver->set_first_adjoint_step(false);
158 
159  // Dont forget to localize the old_nonlinear_solution !
160  _system.get_vector("_old_nonlinear_solution").localize
163 }
Real time
For time-dependent problems, this is the time t at the beginning of the current timestep.
Definition: system.h:1615
unsigned int n_qois() const
Number of currently active quantities of interest.
Definition: system.h:2621
sys_type & _system
A reference to the system we are solving.
Definition: time_solver.h:312
std::shared_ptr< NumericVector< Number > > old_local_nonlinear_solution
Serial vector of _system.get_vector("_old_nonlinear_solution") This is a shared_ptr so that it can be...
Real deltat
For time-dependent problems, this is the amount delta t to advance the solution in time...
Definition: diff_system.h:280
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:140
NumericVector< Number > & get_adjoint_solution(unsigned int i=0)
Definition: system.C:1245
const DofMap & get_dof_map() const
Definition: system.h:2374
template class LIBMESH_EXPORT NumericVector< Number >
std::unique_ptr< UnsteadySolver > core_time_solver
This object is used to take timesteps.
const std::vector< dof_id_type > & get_send_list() const
Definition: dof_map.h:526
bool first_adjoint_step
A bool that will be true the first time adjoint_advance_timestep() is called, (when the primal soluti...
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition: system.C:943
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.

◆ adjoint_solve()

virtual std::pair<unsigned int, Real> libMesh::AdaptiveTimeSolver::adjoint_solve ( const QoISet qoi_indices)
overridepure virtual

This method solves for the adjoint solution at the next adjoint timestep (or a steady state adjoint solve)

Reimplemented from libMesh::UnsteadySolver.

Implemented in libMesh::TwostepTimeSolver.

◆ advance_timestep()

void libMesh::AdaptiveTimeSolver::advance_timestep ( )
overridevirtual

This method advances the solution to the next timestep, after a solve() has been performed.

Often this will be done after every UnsteadySolver::solve(), but adaptive mesh refinement and/or adaptive time step selection may require some solve() steps to be repeated.

Reimplemented from libMesh::UnsteadySolver.

Definition at line 89 of file adaptive_time_solver.C.

References libMesh::TimeSolver::_system, completed_timestep_size, core_time_solver, libMesh::UnsteadySolver::first_solve, libMesh::System::get_dof_map(), libMesh::DofMap::get_send_list(), libMesh::System::get_vector(), libMesh::NumericVector< T >::localize(), libMesh::UnsteadySolver::old_local_nonlinear_solution, libMesh::System::solution, and libMesh::System::time.

Referenced by libMesh::TwostepTimeSolver::solve().

90 {
91  // The first access of advance_timestep happens via solve, not user code
92  // It is used here to store any initial conditions data
93  if (!first_solve)
94  {
96  }
97  else
98  {
99  // We are here because of a call to advance_timestep that happens
100  // via solve, the very first solve. All we are doing here is storing
101  // the initial condition. The actual solution computed via this solve
102  // will be stored when we call advance_timestep in the user's timestep loop
103  first_solve = false;
104  core_time_solver->set_first_solve(false);
105  }
106 
107  // For the adaptive time solver, all SH operations
108  // are handled by the core_time_solver's SH object
109  // Sub solution storage is handled internally by the core time solver,
110  // but the 'full step' solution is stored here to maintain consistency
111  // with the fixed timestep scheme.
112  core_time_solver->get_solution_history().store(false, _system.time);
113 
114  NumericVector<Number> & old_nonlinear_soln =
115  _system.get_vector("_old_nonlinear_solution");
116  NumericVector<Number> & nonlinear_solution =
117  *(_system.solution);
118 
119  old_nonlinear_soln = nonlinear_solution;
120 
121  old_nonlinear_soln.localize
124 }
Real time
For time-dependent problems, this is the time t at the beginning of the current timestep.
Definition: system.h:1615
Real completed_timestep_size
The adaptive time solver&#39;s have two notions of deltat.
sys_type & _system
A reference to the system we are solving.
Definition: time_solver.h:312
std::shared_ptr< NumericVector< Number > > old_local_nonlinear_solution
Serial vector of _system.get_vector("_old_nonlinear_solution") This is a shared_ptr so that it can be...
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
const DofMap & get_dof_map() const
Definition: system.h:2374
template class LIBMESH_EXPORT NumericVector< Number >
std::unique_ptr< UnsteadySolver > core_time_solver
This object is used to take timesteps.
const std::vector< dof_id_type > & get_send_list() const
Definition: dof_map.h:526
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition: system.C:943
bool first_solve
A bool that will be true the first time solve() is called, and false thereafter.

◆ before_timestep()

virtual void libMesh::TimeSolver::before_timestep ( )
inlinevirtualinherited

This method is for subclasses or users to override to do arbitrary processing between timesteps.

Definition at line 205 of file time_solver.h.

205 {}

◆ calculate_norm()

Real libMesh::AdaptiveTimeSolver::calculate_norm ( System s,
NumericVector< Number > &  v 
)
protectedvirtual

A helper function to calculate error norms.

Definition at line 225 of file adaptive_time_solver.C.

References libMesh::System::calculate_norm(), and component_norm.

Referenced by libMesh::TwostepTimeSolver::solve().

227 {
228  return s.calculate_norm(v, component_norm);
229 }
SystemNorm component_norm
Error calculations are done in this norm, DISCRETE_L2 by default.

◆ compute_second_order_eqns()

bool libMesh::FirstOrderUnsteadySolver::compute_second_order_eqns ( bool  compute_jacobian,
DiffContext c 
)
protectedinherited

If there are second order variables, then we need to compute their residual equations and corresponding Jacobian.

The residual equation will simply be \dot{u} - v = 0 , where u is the second order variable add by the user and v is the variable added by the time-solver as the "velocity" variable.

Definition at line 32 of file first_order_unsteady_solver.C.

References libMesh::TimeSolver::_system, compute_jacobian(), libMesh::DiffContext::get_dof_indices(), libMesh::DiffContext::get_elem_jacobian(), libMesh::DiffContext::get_elem_residual(), libMesh::DiffContext::get_elem_solution_derivative(), libMesh::DiffContext::get_elem_solution_rate_derivative(), libMesh::FEMContext::get_element_fe(), libMesh::FEMContext::get_element_qrule(), libMesh::DifferentiableSystem::get_second_order_dot_var(), libMesh::DiffContext::get_system(), libMesh::FEMContext::interior_rate(), libMesh::FEMContext::interior_value(), libMesh::DifferentiablePhysics::is_second_order_var(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::QBase::n_points(), libMesh::DiffContext::n_vars(), libMesh::Variable::type(), and libMesh::System::variable().

Referenced by libMesh::EulerSolver::_general_residual(), libMesh::Euler2Solver::_general_residual(), libMesh::EulerSolver::element_residual(), libMesh::Euler2Solver::element_residual(), libMesh::EulerSolver::nonlocal_residual(), and libMesh::Euler2Solver::nonlocal_residual().

33 {
34  FEMContext & context = cast_ref<FEMContext &>(c);
35 
36  unsigned int n_qpoints = context.get_element_qrule().n_points();
37 
38  for (auto var : make_range(context.n_vars()))
39  {
40  if (!this->_system.is_second_order_var(var))
41  continue;
42 
43  unsigned int dot_var = this->_system.get_second_order_dot_var(var);
44 
45  // We're assuming that the FE space for var and dot_var are the same
46  libmesh_assert( context.get_system().variable(var).type() ==
47  context.get_system().variable(dot_var).type() );
48 
49  FEBase * elem_fe = nullptr;
50  context.get_element_fe( var, elem_fe );
51 
52  const std::vector<Real> & JxW = elem_fe->get_JxW();
53 
54  const std::vector<std::vector<Real>> & phi = elem_fe->get_phi();
55 
56  const unsigned int n_dofs = cast_int<unsigned int>
57  (context.get_dof_indices(dot_var).size());
58 
59  DenseSubVector<Number> & Fu = context.get_elem_residual(var);
60  DenseSubMatrix<Number> & Kuu = context.get_elem_jacobian( var, var );
61  DenseSubMatrix<Number> & Kuv = context.get_elem_jacobian( var, dot_var );
62 
63  for (unsigned int qp = 0; qp != n_qpoints; ++qp)
64  {
65  Number udot, v;
66  context.interior_rate(var, qp, udot);
67  context.interior_value(dot_var, qp, v);
68 
69  for (unsigned int i = 0; i < n_dofs; i++)
70  {
71  Fu(i) += JxW[qp]*(udot-v)*phi[i][qp];
72 
73  if (compute_jacobian)
74  {
75  Number rate_factor = JxW[qp]*context.get_elem_solution_rate_derivative()*phi[i][qp];
76  Number soln_factor = JxW[qp]*context.get_elem_solution_derivative()*phi[i][qp];
77 
78  Kuu(i,i) += rate_factor*phi[i][qp];
79  Kuv(i,i) -= soln_factor*phi[i][qp];
80 
81  for (unsigned int j = i+1; j < n_dofs; j++)
82  {
83  Kuu(i,j) += rate_factor*phi[j][qp];
84  Kuu(j,i) += rate_factor*phi[j][qp];
85 
86  Kuv(i,j) -= soln_factor*phi[j][qp];
87  Kuv(j,i) -= soln_factor*phi[j][qp];
88  }
89  }
90  }
91  }
92  }
93 
94  return compute_jacobian;
95 }
bool is_second_order_var(unsigned int var) const
Definition: diff_physics.h:522
void compute_jacobian(const NumericVector< Number > &, SparseMatrix< Number > &J, NonlinearImplicitSystem &system)
Definition: assembly.C:315
sys_type & _system
A reference to the system we are solving.
Definition: time_solver.h:312
unsigned int get_second_order_dot_var(unsigned int var) const
For a given second order (in time) variable var, this method will return the index to the correspondi...
Definition: diff_system.C:306
libmesh_assert(ctx)
FEGenericBase< Real > FEBase
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:140

◆ diff_solver()

std::unique_ptr< DiffSolver > & libMesh::AdaptiveTimeSolver::diff_solver ( )
overridevirtual

An implicit linear or nonlinear solver to use at each timestep.

Reimplemented from libMesh::TimeSolver.

Definition at line 211 of file adaptive_time_solver.C.

References core_time_solver.

212 {
213  return core_time_solver->diff_solver();
214 }
std::unique_ptr< UnsteadySolver > core_time_solver
This object is used to take timesteps.

◆ disable_print_counter_info()

void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 100 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

101 {
102  _enable_print_counter = false;
103  return;
104 }
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...

◆ du()

Real libMesh::UnsteadySolver::du ( const SystemNorm norm) const
overridevirtualinherited

Computes the size of ||u^{n+1} - u^{n}|| in some norm.

Note
While you can always call this function, its result may or may not be very meaningful. For example, if you call this function right after calling advance_timestep() then you'll get a result of zero since old_nonlinear_solution is set equal to nonlinear_solution in this function.

Implements libMesh::TimeSolver.

Definition at line 348 of file unsteady_solver.C.

References libMesh::TimeSolver::_system, libMesh::System::calculate_norm(), libMesh::System::get_vector(), libMesh::TensorTools::norm(), and libMesh::System::solution.

349 {
350 
351  std::unique_ptr<NumericVector<Number>> solution_copy =
352  _system.solution->clone();
353 
354  solution_copy->add(-1., _system.get_vector("_old_nonlinear_solution"));
355 
356  solution_copy->close();
357 
358  return _system.calculate_norm(*solution_copy, norm);
359 }
sys_type & _system
A reference to the system we are solving.
Definition: time_solver.h:312
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
Real calculate_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
Definition: system.C:1724
auto norm(const T &a) -> decltype(std::abs(a))
Definition: tensor_tools.h:74
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition: system.C:943

◆ element_residual()

bool libMesh::AdaptiveTimeSolver::element_residual ( bool  get_jacobian,
DiffContext context 
)
overridevirtual

This method is passed on to the core_time_solver.

Implements libMesh::TimeSolver.

Definition at line 181 of file adaptive_time_solver.C.

References core_time_solver, and libMesh::libmesh_assert().

183 {
185 
186  return core_time_solver->element_residual(request_jacobian, context);
187 }
libmesh_assert(ctx)
std::unique_ptr< UnsteadySolver > core_time_solver
This object is used to take timesteps.

◆ enable_print_counter_info()

void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

Methods to enable/disable the reference counter output from print_info()

Definition at line 94 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

95 {
96  _enable_print_counter = true;
97  return;
98 }
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...

◆ error_order()

Real libMesh::AdaptiveTimeSolver::error_order ( ) const
overridevirtual

This method is passed on to the core_time_solver.

Implements libMesh::UnsteadySolver.

Definition at line 172 of file adaptive_time_solver.C.

References core_time_solver, and libMesh::libmesh_assert().

173 {
175 
176  return core_time_solver->error_order();
177 }
libmesh_assert(ctx)
std::unique_ptr< UnsteadySolver > core_time_solver
This object is used to take timesteps.

◆ get_info()

std::string libMesh::ReferenceCounter::get_info ( )
staticinherited

Gets a string containing the reference information.

Definition at line 47 of file reference_counter.C.

References libMesh::ReferenceCounter::_counts, and libMesh::Quality::name().

Referenced by libMesh::ReferenceCounter::print_info().

48 {
49 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
50 
51  std::ostringstream oss;
52 
53  oss << '\n'
54  << " ---------------------------------------------------------------------------- \n"
55  << "| Reference count information |\n"
56  << " ---------------------------------------------------------------------------- \n";
57 
58  for (const auto & [name, cd] : _counts)
59  oss << "| " << name << " reference count information:\n"
60  << "| Creations: " << cd.first << '\n'
61  << "| Destructions: " << cd.second << '\n';
62 
63  oss << " ---------------------------------------------------------------------------- \n";
64 
65  return oss.str();
66 
67 #else
68 
69  return "";
70 
71 #endif
72 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
static Counts _counts
Actually holds the data.

◆ get_solution_history()

SolutionHistory & libMesh::TimeSolver::get_solution_history ( )
inherited

A getter function that returns a reference to the solution history object owned by TimeSolver.

Definition at line 124 of file time_solver.C.

References libMesh::TimeSolver::solution_history.

Referenced by init().

125 {
126  return *solution_history;
127 }
std::unique_ptr< SolutionHistory > solution_history
A std::unique_ptr to a SolutionHistory object.
Definition: time_solver.h:319

◆ increment_constructor_count()

void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name)
inlineprotectednoexceptinherited

Increments the construction counter.

Should be called in the constructor of any derived class that will be reference counted.

Definition at line 183 of file reference_counter.h.

References libMesh::err, libMesh::BasicOStreamProxy< charT, traits >::get(), libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().

184 {
185  libmesh_try
186  {
187  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
188  std::pair<unsigned int, unsigned int> & p = _counts[name];
189  p.first++;
190  }
191  libmesh_catch (...)
192  {
193  auto stream = libMesh::err.get();
194  stream->exceptions(stream->goodbit); // stream must not throw
195  libMesh::err << "Encountered unrecoverable error while calling "
196  << "ReferenceCounter::increment_constructor_count() "
197  << "for a(n) " << name << " object." << std::endl;
198  std::terminate();
199  }
200 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
OStreamProxy err
static Counts _counts
Actually holds the data.
streamT * get()
Rather than implement every ostream/ios/ios_base function, we&#39;ll be lazy and make esoteric uses go th...
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.
Definition: threads.C:30

◆ increment_destructor_count()

void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name)
inlineprotectednoexceptinherited

Increments the destruction counter.

Should be called in the destructor of any derived class that will be reference counted.

Definition at line 207 of file reference_counter.h.

References libMesh::err, libMesh::BasicOStreamProxy< charT, traits >::get(), libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().

208 {
209  libmesh_try
210  {
211  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
212  std::pair<unsigned int, unsigned int> & p = _counts[name];
213  p.second++;
214  }
215  libmesh_catch (...)
216  {
217  auto stream = libMesh::err.get();
218  stream->exceptions(stream->goodbit); // stream must not throw
219  libMesh::err << "Encountered unrecoverable error while calling "
220  << "ReferenceCounter::increment_destructor_count() "
221  << "for a(n) " << name << " object." << std::endl;
222  std::terminate();
223  }
224 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
OStreamProxy err
static Counts _counts
Actually holds the data.
streamT * get()
Rather than implement every ostream/ios/ios_base function, we&#39;ll be lazy and make esoteric uses go th...
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.
Definition: threads.C:30

◆ init()

void libMesh::AdaptiveTimeSolver::init ( )
overridevirtual

The initialization function.

This method is used to initialize internal data structures before a simulation begins.

Reimplemented from libMesh::UnsteadySolver.

Definition at line 54 of file adaptive_time_solver.C.

References core_time_solver, libMesh::TimeSolver::get_solution_history(), libMesh::libmesh_assert(), libMesh::UnsteadySolver::old_local_nonlinear_solution, and libMesh::TimeSolver::set_solution_history().

55 {
57 
58  // We override this because our core_time_solver is the one that
59  // needs to handle new vectors, diff_solver->init(), etc
60  core_time_solver->init();
61 
62  // Set the core_time_solver's solution history object to be the same one as
63  // that for the outer adaptive time solver
64  core_time_solver->set_solution_history((this->get_solution_history()));
65 
66  // Now that we have set the SolutionHistory object for the coretimesolver,
67  // we set the SolutionHistory type for the timesolver to be NoSolutionHistory
68  // All storage and retrieval will be handled by the coretimesolver directly.
69  NoSolutionHistory outersolver_solution_history;
70  this->set_solution_history(outersolver_solution_history);
71 
72  // As an UnsteadySolver, we have an old_local_nonlinear_solution, but it
73  // isn't pointing to the right place - fix it
74  old_local_nonlinear_solution = core_time_solver->old_local_nonlinear_solution;
75 }
std::shared_ptr< NumericVector< Number > > old_local_nonlinear_solution
Serial vector of _system.get_vector("_old_nonlinear_solution") This is a shared_ptr so that it can be...
libmesh_assert(ctx)
void set_solution_history(const SolutionHistory &_solution_history)
A setter function users will employ if they need to do something other than save no solution history...
Definition: time_solver.C:119
std::unique_ptr< UnsteadySolver > core_time_solver
This object is used to take timesteps.
SolutionHistory & get_solution_history()
A getter function that returns a reference to the solution history object owned by TimeSolver...
Definition: time_solver.C:124

◆ init_adjoints()

void libMesh::UnsteadySolver::init_adjoints ( )
overridevirtualinherited

Add adjoint vectors and old_adjoint_vectors as per the indices of QoISet.

Reimplemented from libMesh::TimeSolver.

Definition at line 68 of file unsteady_solver.C.

References libMesh::TimeSolver::_system, libMesh::System::add_vector(), libMesh::GHOSTED, libMesh::TimeSolver::init_adjoints(), libMesh::make_range(), and libMesh::System::n_qois().

69 {
71 
72  // Add old adjoint solutions
73  // To keep the number of vectors consistent between the primal and adjoint
74  // time loops, we will also add the adjoint rhs vector during initialization
75  for(auto i : make_range(_system.n_qois()))
76  {
77  std::string old_adjoint_solution_name = "_old_adjoint_solution";
78  old_adjoint_solution_name+= std::to_string(i);
79  _system.add_vector(old_adjoint_solution_name, false, GHOSTED);
80 
81  std::string adjoint_rhs_name = "adjoint_rhs";
82  adjoint_rhs_name+= std::to_string(i);
83  _system.add_vector(adjoint_rhs_name, false, GHOSTED);
84  }
85 
86 }
unsigned int n_qois() const
Number of currently active quantities of interest.
Definition: system.h:2621
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
Definition: system.C:768
sys_type & _system
A reference to the system we are solving.
Definition: time_solver.h:312
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:140
virtual void init_adjoints()
Initialize any adjoint related data structures, based on the number of qois.
Definition: time_solver.C:83

◆ init_data()

void libMesh::UnsteadySolver::init_data ( )
overridevirtualinherited

The data initialization function.

This method is used to initialize internal data structures after the underlying System has been initialized

Reimplemented from libMesh::TimeSolver.

Reimplemented in libMesh::SecondOrderUnsteadySolver.

Definition at line 89 of file unsteady_solver.C.

References libMesh::TimeSolver::_system, libMesh::System::get_dof_map(), libMesh::DofMap::get_send_list(), libMesh::GHOSTED, libMesh::TimeSolver::init_data(), libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), libMesh::UnsteadySolver::old_local_nonlinear_solution, and libMesh::SERIAL.

Referenced by libMesh::SecondOrderUnsteadySolver::init_data().

90 {
92 
93 #ifdef LIBMESH_ENABLE_GHOSTED
96  GHOSTED);
97 #else
99 #endif
100 }
virtual void init_data()
The data initialization function.
Definition: time_solver.C:97
dof_id_type n_local_dofs() const
Definition: system.C:158
dof_id_type n_dofs() const
Definition: system.C:121
sys_type & _system
A reference to the system we are solving.
Definition: time_solver.h:312
std::shared_ptr< NumericVector< Number > > old_local_nonlinear_solution
Serial vector of _system.get_vector("_old_nonlinear_solution") This is a shared_ptr so that it can be...
const DofMap & get_dof_map() const
Definition: system.h:2374
const std::vector< dof_id_type > & get_send_list() const
Definition: dof_map.h:526

◆ integrate_adjoint_refinement_error_estimate()

virtual void libMesh::AdaptiveTimeSolver::integrate_adjoint_refinement_error_estimate ( AdjointRefinementEstimator ,
ErrorVector  
)
overridepure virtual

A method to compute the adjoint refinement error estimate at the current timestep.

int_{tstep_start}^{tstep_end} R(u^h,z) dt The user provides an initialized ARefEE object. Fills in an ErrorVector that contains the weighted sum of errors from all the QoIs and can be used to guide AMR. CURRENTLY ONLY SUPPORTED for Backward Euler.

Implements libMesh::FirstOrderUnsteadySolver.

Implemented in libMesh::TwostepTimeSolver.

◆ integrate_adjoint_sensitivity()

virtual void libMesh::AdaptiveTimeSolver::integrate_adjoint_sensitivity ( const QoISet qois,
const ParameterVector parameter_vector,
SensitivityData sensitivities 
)
overridepure virtual

A method to integrate the adjoint sensitivity w.r.t a given parameter vector.

int_{tstep_start}^{tstep_end} dQ/dp dt = int_{tstep_start}^{tstep_end} ( / p) - ( R (u,z) / p ) dt The trapezoidal rule is used to numerically integrate the timestep.

Reimplemented from libMesh::UnsteadySolver.

Implemented in libMesh::TwostepTimeSolver.

◆ integrate_qoi_timestep()

virtual void libMesh::AdaptiveTimeSolver::integrate_qoi_timestep ( )
overridepure virtual

A method to integrate the system::QoI functionals.

Implements libMesh::FirstOrderUnsteadySolver.

Implemented in libMesh::TwostepTimeSolver.

◆ is_adjoint()

bool libMesh::TimeSolver::is_adjoint ( ) const
inlineinherited

Accessor for querying whether we need to do a primal or adjoint solve.

Definition at line 277 of file time_solver.h.

References libMesh::TimeSolver::_is_adjoint.

Referenced by libMesh::FEMSystem::build_context().

278  { return _is_adjoint; }
bool _is_adjoint
This boolean tells the TimeSolver whether we are solving a primal or adjoint problem.
Definition: time_solver.h:340

◆ is_steady()

virtual bool libMesh::UnsteadySolver::is_steady ( ) const
inlineoverridevirtualinherited

This is not a steady-state solver.

Implements libMesh::TimeSolver.

Definition at line 194 of file unsteady_solver.h.

194 { return false; }

◆ last_completed_timestep_size()

virtual Real libMesh::AdaptiveTimeSolver::last_completed_timestep_size ( )
inlineoverridevirtual

Returns system.deltat if fixed timestep solver is used, the complete timestep size (sum of all substeps) if the adaptive time solver is used.

Returns the change in system.time, deltat, for the last timestep which was successfully completed. This only returns the outermost step size in the case of nested time solvers. If no time step has yet been successfully completed, then returns system.deltat.

Reimplemented from libMesh::TimeSolver.

Definition at line 91 of file adaptive_time_solver.h.

References completed_timestep_size.

91 { return completed_timestep_size; };
Real completed_timestep_size
The adaptive time solver&#39;s have two notions of deltat.

◆ linear_solver()

std::unique_ptr< LinearSolver< Number > > & libMesh::AdaptiveTimeSolver::linear_solver ( )
overridevirtual

An implicit linear solver to use for adjoint and sensitivity problems.

Reimplemented from libMesh::TimeSolver.

Definition at line 218 of file adaptive_time_solver.C.

References core_time_solver.

219 {
220  return core_time_solver->linear_solver();
221 }
std::unique_ptr< UnsteadySolver > core_time_solver
This object is used to take timesteps.

◆ n_objects()

static unsigned int libMesh::ReferenceCounter::n_objects ( )
inlinestaticinherited

Prints the number of outstanding (created, but not yet destroyed) objects.

Definition at line 85 of file reference_counter.h.

References libMesh::ReferenceCounter::_n_objects.

Referenced by libMesh::LibMeshInit::~LibMeshInit().

86  { return _n_objects; }
static Threads::atomic< unsigned int > _n_objects
The number of objects.

◆ nonlocal_residual()

bool libMesh::AdaptiveTimeSolver::nonlocal_residual ( bool  get_jacobian,
DiffContext context 
)
overridevirtual

This method is passed on to the core_time_solver.

Implements libMesh::TimeSolver.

Definition at line 201 of file adaptive_time_solver.C.

References core_time_solver, and libMesh::libmesh_assert().

203 {
205 
206  return core_time_solver->nonlocal_residual(request_jacobian, context);
207 }
libmesh_assert(ctx)
std::unique_ptr< UnsteadySolver > core_time_solver
This object is used to take timesteps.

◆ old_nonlinear_solution()

Number libMesh::UnsteadySolver::old_nonlinear_solution ( const dof_id_type  global_dof_number) const
inherited
Returns
The old nonlinear solution for the specified global DOF.

Definition at line 337 of file unsteady_solver.C.

References libMesh::TimeSolver::_system, libMesh::System::get_dof_map(), libMesh::DofMap::n_dofs(), and libMesh::UnsteadySolver::old_local_nonlinear_solution.

Referenced by libMesh::EulerSolver::_general_residual(), libMesh::Euler2Solver::_general_residual(), libMesh::NewmarkSolver::_general_residual(), and libMesh::FEMPhysics::eulerian_residual().

339 {
340  libmesh_assert_less (global_dof_number, _system.get_dof_map().n_dofs());
341  libmesh_assert_less (global_dof_number, old_local_nonlinear_solution->size());
342 
343  return (*old_local_nonlinear_solution)(global_dof_number);
344 }
dof_id_type n_dofs(const unsigned int vn) const
Definition: dof_map.h:668
sys_type & _system
A reference to the system we are solving.
Definition: time_solver.h:312
std::shared_ptr< NumericVector< Number > > old_local_nonlinear_solution
Serial vector of _system.get_vector("_old_nonlinear_solution") This is a shared_ptr so that it can be...
const DofMap & get_dof_map() const
Definition: system.h:2374

◆ prepare_accel()

void libMesh::FirstOrderUnsteadySolver::prepare_accel ( DiffContext context)
protectedinherited

If there are second order variables in the system, then we also prepare the accel for those variables so the user can treat them as such.

Definition at line 25 of file first_order_unsteady_solver.C.

References libMesh::DiffContext::elem_solution_accel_derivative, libMesh::DiffContext::get_elem_solution_accel(), libMesh::DiffContext::get_elem_solution_rate(), and libMesh::DiffContext::get_elem_solution_rate_derivative().

Referenced by libMesh::EulerSolver::_general_residual(), and libMesh::Euler2Solver::_general_residual().

26 {
27  context.get_elem_solution_accel() = context.get_elem_solution_rate();
28 
29  context.elem_solution_accel_derivative = context.get_elem_solution_rate_derivative();
30 }

◆ print_info()

void libMesh::ReferenceCounter::print_info ( std::ostream &  out_stream = libMesh::out)
staticinherited

Prints the reference information, by default to libMesh::out.

Definition at line 81 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter, and libMesh::ReferenceCounter::get_info().

Referenced by libMesh::LibMeshInit::~LibMeshInit().

82 {
84  out_stream << ReferenceCounter::get_info();
85 }
static std::string get_info()
Gets a string containing the reference information.
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...

◆ reinit()

void libMesh::AdaptiveTimeSolver::reinit ( )
overridevirtual

The reinitialization function.

This method is used to resize internal data vectors after a mesh change.

Reimplemented from libMesh::UnsteadySolver.

Definition at line 79 of file adaptive_time_solver.C.

References core_time_solver, and libMesh::libmesh_assert().

80 {
82 
83  // We override this because our core_time_solver is the one that
84  // needs to handle new vectors, diff_solver->reinit(), etc
85  core_time_solver->reinit();
86 }
libmesh_assert(ctx)
std::unique_ptr< UnsteadySolver > core_time_solver
This object is used to take timesteps.

◆ retrieve_timestep()

void libMesh::AdaptiveTimeSolver::retrieve_timestep ( )
overridevirtual

This method retrieves all the stored solutions at the current system.time.

Reimplemented from libMesh::UnsteadySolver.

Definition at line 165 of file adaptive_time_solver.C.

References core_time_solver.

166 {
167  // Ask the core time solver to retrieve all the stored vectors
168  // at the current time
169  core_time_solver->retrieve_timestep();
170 }
std::unique_ptr< UnsteadySolver > core_time_solver
This object is used to take timesteps.

◆ set_first_adjoint_step()

void libMesh::UnsteadySolver::set_first_adjoint_step ( bool  first_adjoint_step_setting)
inlineinherited

A setter for the first_adjoint_step boolean.

Needed for nested time solvers.

Definition at line 199 of file unsteady_solver.h.

References libMesh::UnsteadySolver::first_adjoint_step.

200  {
201  first_adjoint_step = first_adjoint_step_setting;
202  }
bool first_adjoint_step
A bool that will be true the first time adjoint_advance_timestep() is called, (when the primal soluti...

◆ set_first_solve()

void libMesh::UnsteadySolver::set_first_solve ( bool  first_solve_setting)
inlineinherited

Definition at line 209 of file unsteady_solver.h.

References libMesh::UnsteadySolver::first_solve.

210  {
211  first_solve = first_solve_setting;
212  }
bool first_solve
A bool that will be true the first time solve() is called, and false thereafter.

◆ set_is_adjoint()

void libMesh::TimeSolver::set_is_adjoint ( bool  _is_adjoint_value)
inlineinherited

Accessor for setting whether we need to do a primal or adjoint solve.

Definition at line 284 of file time_solver.h.

References libMesh::TimeSolver::_is_adjoint.

Referenced by libMesh::DifferentiableSystem::adjoint_solve(), libMesh::FEMSystem::postprocess(), and libMesh::DifferentiableSystem::solve().

285  { _is_adjoint = _is_adjoint_value; }
bool _is_adjoint
This boolean tells the TimeSolver whether we are solving a primal or adjoint problem.
Definition: time_solver.h:340

◆ set_solution_history()

void libMesh::TimeSolver::set_solution_history ( const SolutionHistory _solution_history)
inherited

A setter function users will employ if they need to do something other than save no solution history.

Definition at line 119 of file time_solver.C.

References libMesh::SolutionHistory::clone(), and libMesh::TimeSolver::solution_history.

Referenced by init().

120 {
121  solution_history = _solution_history.clone();
122 }
std::unique_ptr< SolutionHistory > solution_history
A std::unique_ptr to a SolutionHistory object.
Definition: time_solver.h:319

◆ side_residual()

bool libMesh::AdaptiveTimeSolver::side_residual ( bool  get_jacobian,
DiffContext context 
)
overridevirtual

This method is passed on to the core_time_solver.

Implements libMesh::TimeSolver.

Definition at line 191 of file adaptive_time_solver.C.

References core_time_solver, and libMesh::libmesh_assert().

193 {
195 
196  return core_time_solver->side_residual(request_jacobian, context);
197 }
libmesh_assert(ctx)
std::unique_ptr< UnsteadySolver > core_time_solver
This object is used to take timesteps.

◆ solve()

virtual void libMesh::AdaptiveTimeSolver::solve ( )
overridepure virtual

This method solves for the solution at the next timestep.

Usually we will only need to solve one (non)linear system per timestep, but more complex subclasses may override this.

Reimplemented from libMesh::UnsteadySolver.

Implemented in libMesh::TwostepTimeSolver.

◆ system() [1/2]

const sys_type& libMesh::TimeSolver::system ( ) const
inlineinherited
Returns
A constant reference to the system we are solving.

Definition at line 210 of file time_solver.h.

References libMesh::TimeSolver::_system.

Referenced by libMesh::TimeSolver::adjoint_solve(), libMesh::TimeSolver::reinit(), and libMesh::TimeSolver::solve().

210 { return _system; }
sys_type & _system
A reference to the system we are solving.
Definition: time_solver.h:312

◆ system() [2/2]

sys_type& libMesh::TimeSolver::system ( )
inlineinherited
Returns
A writable reference to the system we are solving.

Definition at line 215 of file time_solver.h.

References libMesh::TimeSolver::_system.

215 { return _system; }
sys_type & _system
A reference to the system we are solving.
Definition: time_solver.h:312

◆ time_order()

virtual unsigned int libMesh::FirstOrderUnsteadySolver::time_order ( ) const
inlineoverridevirtualinherited
Returns
The maximum order of time derivatives for which the UnsteadySolver subclass is capable of handling.

For example, EulerSolver will have time_order() = 1 and NewmarkSolver will have time_order() = 2.

Implements libMesh::UnsteadySolver.

Definition at line 90 of file first_order_unsteady_solver.h.

91  { return 1; }

◆ update()

void libMesh::UnsteadySolver::update ( )
inherited

Definition at line 361 of file unsteady_solver.C.

References libMesh::TimeSolver::_system, libMesh::System::get_dof_map(), libMesh::DofMap::get_send_list(), libMesh::System::get_vector(), libMesh::NumericVector< T >::localize(), and libMesh::UnsteadySolver::old_local_nonlinear_solution.

362 {
363  // Dont forget to localize the old_nonlinear_solution !
364  _system.get_vector("_old_nonlinear_solution").localize
367 }
sys_type & _system
A reference to the system we are solving.
Definition: time_solver.h:312
std::shared_ptr< NumericVector< Number > > old_local_nonlinear_solution
Serial vector of _system.get_vector("_old_nonlinear_solution") This is a shared_ptr so that it can be...
const DofMap & get_dof_map() const
Definition: system.h:2374
const std::vector< dof_id_type > & get_send_list() const
Definition: dof_map.h:526
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition: system.C:943
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.

Member Data Documentation

◆ _counts

ReferenceCounter::Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited

Actually holds the data.

Definition at line 124 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::get_info().

◆ _diff_solver

std::unique_ptr<DiffSolver> libMesh::TimeSolver::_diff_solver
protectedinherited

An implicit linear or nonlinear solver to use at each timestep.

Definition at line 302 of file time_solver.h.

Referenced by libMesh::NewmarkSolver::compute_initial_accel(), libMesh::TimeSolver::diff_solver(), and libMesh::UnsteadySolver::solve().

◆ _enable_print_counter

bool libMesh::ReferenceCounter::_enable_print_counter = true
staticprotectedinherited

Flag to control whether reference count information is printed when print_info is called.

Definition at line 143 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info(), and libMesh::ReferenceCounter::print_info().

◆ _linear_solver

std::unique_ptr<LinearSolver<Number> > libMesh::TimeSolver::_linear_solver
protectedinherited

An implicit linear solver to use for adjoint problems.

Definition at line 307 of file time_solver.h.

Referenced by libMesh::TimeSolver::linear_solver(), and libMesh::TimeSolver::reinit().

◆ _mutex

Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotectedinherited

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 137 of file reference_counter.h.

◆ _n_objects

Threads::atomic< unsigned int > libMesh::ReferenceCounter::_n_objects
staticprotectedinherited

The number of objects.

Print the reference count information when the number returns to 0.

Definition at line 132 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::n_objects(), libMesh::ReferenceCounter::ReferenceCounter(), and libMesh::ReferenceCounter::~ReferenceCounter().

◆ _system

sys_type& libMesh::TimeSolver::_system
protectedinherited

A reference to the system we are solving.

Definition at line 312 of file time_solver.h.

Referenced by libMesh::EulerSolver::_general_residual(), libMesh::Euler2Solver::_general_residual(), libMesh::SteadySolver::_general_residual(), libMesh::NewmarkSolver::_general_residual(), adjoint_advance_timestep(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::TwostepTimeSolver::adjoint_solve(), libMesh::UnsteadySolver::adjoint_solve(), libMesh::TimeSolver::adjoint_solve(), libMesh::NewmarkSolver::advance_timestep(), advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::NewmarkSolver::compute_initial_accel(), libMesh::FirstOrderUnsteadySolver::compute_second_order_eqns(), libMesh::UnsteadySolver::du(), libMesh::EulerSolver::element_residual(), libMesh::Euler2Solver::element_residual(), libMesh::EigenTimeSolver::element_residual(), libMesh::SecondOrderUnsteadySolver::init(), libMesh::UnsteadySolver::init(), libMesh::TimeSolver::init(), libMesh::EigenTimeSolver::init(), libMesh::UnsteadySolver::init_adjoints(), libMesh::TimeSolver::init_adjoints(), libMesh::SecondOrderUnsteadySolver::init_data(), libMesh::UnsteadySolver::init_data(), libMesh::TimeSolver::init_data(), libMesh::Euler2Solver::integrate_adjoint_refinement_error_estimate(), libMesh::TwostepTimeSolver::integrate_adjoint_refinement_error_estimate(), libMesh::EulerSolver::integrate_adjoint_refinement_error_estimate(), libMesh::TwostepTimeSolver::integrate_adjoint_sensitivity(), libMesh::SteadySolver::integrate_adjoint_sensitivity(), libMesh::UnsteadySolver::integrate_adjoint_sensitivity(), libMesh::Euler2Solver::integrate_qoi_timestep(), libMesh::TwostepTimeSolver::integrate_qoi_timestep(), libMesh::EulerSolver::integrate_qoi_timestep(), libMesh::SteadySolver::integrate_qoi_timestep(), libMesh::EulerSolver::nonlocal_residual(), libMesh::Euler2Solver::nonlocal_residual(), libMesh::EigenTimeSolver::nonlocal_residual(), libMesh::UnsteadySolver::old_nonlinear_solution(), libMesh::SecondOrderUnsteadySolver::old_solution_accel(), libMesh::SecondOrderUnsteadySolver::old_solution_rate(), libMesh::NewmarkSolver::project_initial_accel(), libMesh::SecondOrderUnsteadySolver::project_initial_rate(), libMesh::SecondOrderUnsteadySolver::reinit(), libMesh::UnsteadySolver::reinit(), libMesh::TimeSolver::reinit(), libMesh::UnsteadySolver::retrieve_timestep(), libMesh::EigenTimeSolver::side_residual(), libMesh::TwostepTimeSolver::solve(), libMesh::UnsteadySolver::solve(), libMesh::EigenTimeSolver::solve(), libMesh::TimeSolver::system(), and libMesh::UnsteadySolver::update().

◆ completed_timestep_size

Real libMesh::AdaptiveTimeSolver::completed_timestep_size

The adaptive time solver's have two notions of deltat.

The deltat the solver ended up using for the completed timestep. And the deltat the solver determined would be workable for the coming timestep. The latter gets set as system.deltat. We need a variable to save the deltat used for the completed timestep.

Definition at line 205 of file adaptive_time_solver.h.

Referenced by libMesh::TwostepTimeSolver::adjoint_solve(), advance_timestep(), last_completed_timestep_size(), and libMesh::TwostepTimeSolver::solve().

◆ component_norm

SystemNorm libMesh::AdaptiveTimeSolver::component_norm

Error calculations are done in this norm, DISCRETE_L2 by default.

Definition at line 135 of file adaptive_time_solver.h.

Referenced by calculate_norm().

◆ component_scale

std::vector<float> libMesh::AdaptiveTimeSolver::component_scale

If component_norms is non-empty, each variable's contribution to the error of a system will also be scaled by component_scale[var], unless component_scale is empty in which case all variables will be weighted equally.

Definition at line 143 of file adaptive_time_solver.h.

◆ core_time_solver

std::unique_ptr<UnsteadySolver> libMesh::AdaptiveTimeSolver::core_time_solver

◆ first_adjoint_step

bool libMesh::UnsteadySolver::first_adjoint_step
protectedinherited

A bool that will be true the first time adjoint_advance_timestep() is called, (when the primal solution is to be used to set adjoint boundary conditions) and false thereafter.

Definition at line 226 of file unsteady_solver.h.

Referenced by adjoint_advance_timestep(), and libMesh::UnsteadySolver::set_first_adjoint_step().

◆ first_solve

bool libMesh::UnsteadySolver::first_solve
protectedinherited

◆ global_tolerance

bool libMesh::AdaptiveTimeSolver::global_tolerance

This flag, which is true by default, grows (shrinks) the timestep based on the expected global accuracy of the timestepping scheme.

Global in this sense means the cumulative final-time accuracy of the scheme. For example, the backward Euler scheme's truncation error is locally of order 2, so that after N timesteps of size deltat, the result is first-order accurate. If you set this to false, you can grow (shrink) your timestep based on the local accuracy rather than the global accuracy of the core TimeSolver.

Note
By setting this value to false you may fail to achieve the predicted convergence in time of the underlying method, however it may be possible to get more fine-grained control over step sizes as well.

Definition at line 222 of file adaptive_time_solver.h.

Referenced by libMesh::TwostepTimeSolver::solve().

◆ last_deltat

Real libMesh::TimeSolver::last_deltat
protectedinherited

◆ last_step_deltat

Real libMesh::UnsteadySolver::last_step_deltat
protectedinherited

We will need to move the system.time around to ensure that residuals are built with the right deltat and the right time.

Definition at line 237 of file unsteady_solver.h.

Referenced by libMesh::Euler2Solver::integrate_adjoint_refinement_error_estimate(), and libMesh::EulerSolver::integrate_adjoint_refinement_error_estimate().

◆ max_deltat

Real libMesh::AdaptiveTimeSolver::max_deltat

Do not allow the adaptive time solver to select deltat > max_deltat.

If you use the default max_deltat=0.0, then deltat is unlimited.

Definition at line 183 of file adaptive_time_solver.h.

Referenced by libMesh::TwostepTimeSolver::solve().

◆ max_growth

Real libMesh::AdaptiveTimeSolver::max_growth

Do not allow the adaptive time solver to select a new deltat greater than max_growth times the old deltat.

If you use the default max_growth=0.0, then the deltat growth is unlimited.

Definition at line 197 of file adaptive_time_solver.h.

Referenced by libMesh::TwostepTimeSolver::solve().

◆ min_deltat

Real libMesh::AdaptiveTimeSolver::min_deltat

Do not allow the adaptive time solver to select deltat < min_deltat.

The default value is 0.0.

Definition at line 189 of file adaptive_time_solver.h.

Referenced by libMesh::TwostepTimeSolver::solve().

◆ next_step_deltat

Real libMesh::UnsteadySolver::next_step_deltat
protectedinherited

◆ old_adjoints

std::vector< std::unique_ptr<NumericVector<Number> > > libMesh::UnsteadySolver::old_adjoints
protectedinherited

A vector of pointers to vectors holding the adjoint solution at the last time step.

Definition at line 231 of file unsteady_solver.h.

Referenced by libMesh::Euler2Solver::integrate_adjoint_refinement_error_estimate(), libMesh::EulerSolver::integrate_adjoint_refinement_error_estimate(), and libMesh::UnsteadySolver::UnsteadySolver().

◆ old_local_nonlinear_solution

std::shared_ptr<NumericVector<Number> > libMesh::UnsteadySolver::old_local_nonlinear_solution
inherited

◆ quiet

bool libMesh::TimeSolver::quiet
inherited

Print extra debugging information if quiet == false.

Definition at line 230 of file time_solver.h.

Referenced by libMesh::TwostepTimeSolver::solve(), libMesh::UnsteadySolver::solve(), and libMesh::EigenTimeSolver::solve().

◆ reduce_deltat_on_diffsolver_failure

unsigned int libMesh::TimeSolver::reduce_deltat_on_diffsolver_failure
inherited

This value (which defaults to zero) is the number of times the TimeSolver is allowed to halve deltat and let the DiffSolver repeat the latest failed solve with a reduced timestep.

Note
This has no effect for SteadySolvers.
You must set at least one of the DiffSolver flags "continue_after_max_iterations" or "continue_after_backtrack_failure" to allow the TimeSolver to retry the solve.

Definition at line 259 of file time_solver.h.

Referenced by libMesh::TwostepTimeSolver::solve(), and libMesh::UnsteadySolver::solve().

◆ solution_history

std::unique_ptr<SolutionHistory> libMesh::TimeSolver::solution_history
protectedinherited

◆ target_tolerance

Real libMesh::AdaptiveTimeSolver::target_tolerance

This tolerance is the target relative error between an exact time integration and a single time step output, scaled by deltat.

integrator, scaled by deltat. If the estimated error exceeds or undershoots the target error tolerance, future timesteps will be run with deltat shrunk or grown to compensate.

The default value is 1.0e-2; obviously users should select their own tolerance.

If a negative target_tolerance is specified, then its absolute value is used to scale the estimated error from the first simulation time step, and this becomes the target tolerance of all future time steps.

Definition at line 160 of file adaptive_time_solver.h.

Referenced by libMesh::TwostepTimeSolver::solve().

◆ upper_tolerance

Real libMesh::AdaptiveTimeSolver::upper_tolerance

This tolerance is the maximum relative error between an exact time integration and a single time step output, scaled by deltat.

If this error tolerance is exceeded by the estimated error of the current time step, that time step will be repeated with a smaller deltat.

If you use the default upper_tolerance=0.0, then the current time step will not be repeated regardless of estimated error.

If a negative upper_tolerance is specified, then its absolute value is used to scale the estimated error from the first simulation time step, and this becomes the upper tolerance of all future time steps.

Definition at line 177 of file adaptive_time_solver.h.

Referenced by libMesh::TwostepTimeSolver::solve().


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