Poster of Linux kernelThe best gift for a Linux geek
TimeSolver

TimeSolver

Section: C Library Functions (3) Updated: Thu Apr 7 2011
Local index Up
 

NAME

TimeSolver -  

SYNOPSIS


#include <time_solver.h>

Inherits ReferenceCountedObject< TimeSolver >.

Inherited by EigenTimeSolver, SteadySolver, and UnsteadySolver.  

Public Types


typedef DifferentiableSystem sys_type
 

Public Member Functions


TimeSolver (sys_type &s)

virtual ~TimeSolver ()

virtual void init ()

virtual void reinit ()

virtual void solve ()

virtual void adjoint_solve ()

virtual void advance_timestep ()

virtual void adjoint_recede_timestep ()

virtual bool element_residual (bool request_jacobian, DiffContext &)=0

virtual bool side_residual (bool request_jacobian, DiffContext &)=0

virtual void before_timestep ()

const sys_type & system () const

virtual AutoPtr< DiffSolver > & diff_solver ()

virtual AutoPtr< DiffSolver > & adjoint_solver ()

virtual Real du (const SystemNorm &norm) const =0
 

Static Public Member Functions


static std::string get_info ()

static void print_info ()

static unsigned int n_objects ()
 

Public Attributes


bool quiet

unsigned int reduce_deltat_on_diffsolver_failure
 

Protected Types


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

Protected Member Functions


sys_type & system ()

void increment_constructor_count (const std::string &name)

void increment_destructor_count (const std::string &name)
 

Protected Attributes


AutoPtr< DiffSolver > _diff_solver

AutoPtr< DiffSolver > _adjoint_solver

sys_type & _system

bool first_solve

AutoPtr< NumericVector< Number > > old_local_nonlinear_solution
 

Static Protected Attributes


static Counts _counts

static Threads::atomic< unsigned int > _n_objects

static Threads::spin_mutex _mutex
 

Detailed Description

This is a generic class that defines a solver to handle time integration of DifferentiableSystems.

A user can define a solver by deriving from this class and implementing certain functions.

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 2006

Definition at line 56 of file time_solver.h.  

Member Typedef Documentation

 

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > ReferenceCounter::Counts [protected, inherited]Data structure to log the information. The log is identified by the class name.

Definition at line 105 of file reference_counter.h.  

typedef DifferentiableSystem TimeSolver::sys_typeThe type of system

Reimplemented in EigenTimeSolver, and SteadySolver.

Definition at line 62 of file time_solver.h.  

Constructor & Destructor Documentation

 

TimeSolver::TimeSolver (sys_type &s)Constructor. Requires a reference to the system to be solved.

Definition at line 29 of file time_solver.C.

  : quiet (true),
    reduce_deltat_on_diffsolver_failure (0),
    _diff_solver (NULL),
    _adjoint_solver (NULL),
    _system (s)
{
}
 

TimeSolver::~TimeSolver () [virtual]Destructor.

Definition at line 40 of file time_solver.C.

{
}
 

Member Function Documentation

 

void TimeSolver::adjoint_recede_timestep () [virtual]This method advances the adjoint solution to the previous timestep, after an adjoint_solve() has been performed. This will probably be done after every UnsteadySolver::adjoint_solve().

Definition at line 90 of file time_solver.C.

{
}
 

void TimeSolver::adjoint_solve () [virtual]This method solves for the adjoint solution at the previous timestep (or solves a steady adjoint problem). Usually we will only need to solve one linear system per timestep, but more complex subclasses may override this.

Definition at line 77 of file time_solver.C.

References _adjoint_solver.

{
  _adjoint_solver->adjoint_solve();
}
 

virtual AutoPtr<DiffSolver>& TimeSolver::adjoint_solver () [inline, virtual]An implicit linear solver to use for adjoint problems.

Definition at line 157 of file time_solver.h.

References _adjoint_solver.

{ return _adjoint_solver; }
 

void TimeSolver::advance_timestep () [virtual]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 in AdaptiveTimeSolver, EigenTimeSolver, and UnsteadySolver.

Definition at line 84 of file time_solver.C.

{
}
 

virtual void TimeSolver::before_timestep () [inline, virtual]This method is for subclasses or users to override to do arbitrary processing between timesteps

Definition at line 142 of file time_solver.h.

{}
 

virtual AutoPtr<DiffSolver>& TimeSolver::diff_solver () [inline, virtual]An implicit linear or nonlinear solver to use at each timestep.

Reimplemented in AdaptiveTimeSolver.

Definition at line 152 of file time_solver.h.

References _diff_solver.

{ return _diff_solver; }
 

virtual Real TimeSolver::du (const SystemNorm &norm) const [pure virtual]Computes the size of ||u^{n+1} - u^{n}|| in some norm.

Note that, 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.

Implemented in EigenTimeSolver, SteadySolver, and UnsteadySolver.  

virtual bool TimeSolver::element_residual (boolrequest_jacobian, DiffContext &) [pure virtual]This method uses the DifferentiableSystem's element_time_derivative() and element_constraint() to build a full residual on an element. What combination it uses will depend on the type of solver. See the subclasses for more details.

Implemented in AdaptiveTimeSolver, EigenTimeSolver, Euler2Solver, EulerSolver, and SteadySolver.

Referenced by FEMSystem::numerical_elem_jacobian().  

std::string ReferenceCounter::get_info () [static, inherited]Gets a string containing the reference information.

Definition at line 45 of file reference_counter.C.

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

Referenced by ReferenceCounter::print_info().

{
#if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)

  std::ostringstream out;
  
  out << '
      << ' ---------------------------------------------------------------------------- 
      << '| Reference count information                                                |
      << ' ---------------------------------------------------------------------------- ;
  
  for (Counts::iterator it = _counts.begin();
       it != _counts.end(); ++it)
    {
      const std::string name(it->first);
      const unsigned int creations    = it->second.first;
      const unsigned int destructions = it->second.second;

      out << '| ' << name << ' reference count information:
          << '|  Creations:    ' << creations    << '
          << '|  Destructions: ' << destructions << ';
    }
  
  out << ' ---------------------------------------------------------------------------- ;

  return out.str();

#else

  return '';
  
#endif
}
 

void ReferenceCounter::increment_constructor_count (const std::string &name) [inline, protected, inherited]Increments the construction counter. Should be called in the constructor of any derived class that will be reference counted.

Definition at line 149 of file reference_counter.h.

References ReferenceCounter::_counts, Quality::name(), and Threads::spin_mtx.

Referenced by ReferenceCountedObject< Value >::ReferenceCountedObject().

{
  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
  std::pair<unsigned int, unsigned int>& p = _counts[name];

  p.first++;
}
 

void ReferenceCounter::increment_destructor_count (const std::string &name) [inline, protected, inherited]Increments the destruction counter. Should be called in the destructor of any derived class that will be reference counted.

Definition at line 167 of file reference_counter.h.

References ReferenceCounter::_counts, Quality::name(), and Threads::spin_mtx.

Referenced by ReferenceCountedObject< Value >::~ReferenceCountedObject().

{
  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
  std::pair<unsigned int, unsigned int>& p = _counts[name];

  p.second++;
}
 

void TimeSolver::init () [virtual]The initialization function. This method is used to initialize internal data structures before a simulation begins.

Reimplemented in AdaptiveTimeSolver, EigenTimeSolver, and UnsteadySolver.

Definition at line 54 of file time_solver.C.

References _adjoint_solver, _diff_solver, _system, DiffSolver::build(), and AutoPtr< Tp >::get().

{
  // If the user hasn't given us a solver to use,
  // just build a default solver
  if (_diff_solver.get() == NULL)
    _diff_solver = DiffSolver::build(_system);

  if (_adjoint_solver.get() == NULL)
    _adjoint_solver = DiffSolver::build(_system);

  _diff_solver->init();
  _adjoint_solver->init();
}
 

static unsigned int ReferenceCounter::n_objects () [inline, static, inherited]Prints the number of outstanding (created, but not yet destroyed) objects.

Definition at line 76 of file reference_counter.h.

References ReferenceCounter::_n_objects.

Referenced by System::read_serialized_blocked_dof_objects(), and System::write_serialized_blocked_dof_objects().

  { return _n_objects; }
 

void ReferenceCounter::print_info () [static, inherited]Prints the reference information to std::cout.

Definition at line 83 of file reference_counter.C.

References ReferenceCounter::get_info().

{
#if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
  
  std::cout << ReferenceCounter::get_info();
  
#endif
}
 

void TimeSolver::reinit () [virtual]The reinitialization function. This method is used after changes in the mesh

Reimplemented in AdaptiveTimeSolver, and EigenTimeSolver.

Definition at line 46 of file time_solver.C.

References _adjoint_solver, and _diff_solver.

{
  _diff_solver->reinit();
  _adjoint_solver->reinit();
}
 

virtual bool TimeSolver::side_residual (boolrequest_jacobian, DiffContext &) [pure virtual]This method uses the DifferentiableSystem's side_time_derivative() and side_constraint() to build a full residual on an element's side. What combination it uses will depend on the type of solver. See the subclasses for more details.

Implemented in AdaptiveTimeSolver, EigenTimeSolver, Euler2Solver, EulerSolver, and SteadySolver.

Referenced by FEMSystem::numerical_side_jacobian().  

void TimeSolver::solve () [virtual]This method solves for the solution at the next timestep (or solves for a steady-state solution). Usually we will only need to solve one (non)linear system per timestep, but more complex subclasses may override this.

Reimplemented in AdaptiveTimeSolver, EigenTimeSolver, TwostepTimeSolver, and UnsteadySolver.

Definition at line 70 of file time_solver.C.

References _diff_solver.

{
  _diff_solver->solve();
}
 

const sys_type& TimeSolver::system () const [inline]Returns:

a constant reference to the system we are solving.

Definition at line 147 of file time_solver.h.

References _system.

{ return _system; }
 

sys_type& TimeSolver::system () [inline, protected]Returns:

a writeable reference to the system we are solving.

Definition at line 202 of file time_solver.h.

References _system.

{ return _system; }
 

Member Data Documentation

 

AutoPtr<DiffSolver> TimeSolver::_adjoint_solver [protected]An implicit linear solver to use for adjoint problems.

Definition at line 197 of file time_solver.h.

Referenced by adjoint_solve(), adjoint_solver(), init(), and reinit().  

ReferenceCounter::Counts ReferenceCounter::_counts [static, protected, inherited]Actually holds the data.

Definition at line 110 of file reference_counter.h.

Referenced by ReferenceCounter::get_info(), ReferenceCounter::increment_constructor_count(), and ReferenceCounter::increment_destructor_count().  

AutoPtr<DiffSolver> TimeSolver::_diff_solver [protected]An implicit linear or nonlinear solver to use at each timestep.

Definition at line 192 of file time_solver.h.

Referenced by diff_solver(), init(), reinit(), UnsteadySolver::solve(), and solve().  

Threads::spin_mutex ReferenceCounter::_mutex [static, protected, inherited]Mutual exclusion object to enable thread-safe reference counting.

Definition at line 123 of file reference_counter.h.  

Threads::atomic< unsigned int > ReferenceCounter::_n_objects [static, protected, inherited]The number of objects. Print the reference count information when the number returns to 0.

Definition at line 118 of file reference_counter.h.

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

sys_type& TimeSolver::_system [protected]A reference to the system we are solving.

Definition at line 207 of file time_solver.h.

Referenced by UnsteadySolver::advance_timestep(), AdaptiveTimeSolver::advance_timestep(), UnsteadySolver::du(), SteadySolver::element_residual(), EulerSolver::element_residual(), Euler2Solver::element_residual(), EigenTimeSolver::element_residual(), UnsteadySolver::init(), init(), EigenTimeSolver::init(), UnsteadySolver::old_nonlinear_solution(), SteadySolver::side_residual(), EulerSolver::side_residual(), Euler2Solver::side_residual(), EigenTimeSolver::side_residual(), UnsteadySolver::solve(), TwostepTimeSolver::solve(), EigenTimeSolver::solve(), and system().  

bool TimeSolver::first_solve [protected]A bool that will be true the first time solve() is called, and false thereafter

Reimplemented in UnsteadySolver.

Definition at line 213 of file time_solver.h.  

AutoPtr<NumericVector<Number> > TimeSolver::old_local_nonlinear_solution [protected]Serial vector of _system.get_vector('_old_nonlinear_solution')

Reimplemented in UnsteadySolver.

Definition at line 218 of file time_solver.h.  

bool TimeSolver::quietPrint extra debugging information if quiet == false.

Definition at line 162 of file time_solver.h.

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

unsigned int TimeSolver::reduce_deltat_on_diffsolver_failureThis 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 that this has no effect for SteadySolvers. Note that 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 185 of file time_solver.h.

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

 

Author

Generated automatically by Doxygen for libMesh from the source code.


 

Index

NAME
SYNOPSIS
Public Types
Public Member Functions
Static Public Member Functions
Public Attributes
Protected Types
Protected Member Functions
Protected Attributes
Static Protected Attributes
Detailed Description
Member Typedef Documentation
typedef std::map<std::string, std::pair<unsigned int, unsigned int> > ReferenceCounter::Counts [protected, inherited]Data structure to log the information. The log is identified by the class name.
typedef DifferentiableSystem TimeSolver::sys_typeThe type of system
Constructor & Destructor Documentation
TimeSolver::TimeSolver (sys_type &s)Constructor. Requires a reference to the system to be solved.
TimeSolver::~TimeSolver () [virtual]Destructor.
Member Function Documentation
void TimeSolver::adjoint_recede_timestep () [virtual]This method advances the adjoint solution to the previous timestep, after an adjoint_solve() has been performed. This will probably be done after every UnsteadySolver::adjoint_solve().
void TimeSolver::adjoint_solve () [virtual]This method solves for the adjoint solution at the previous timestep (or solves a steady adjoint problem). Usually we will only need to solve one linear system per timestep, but more complex subclasses may override this.
virtual AutoPtr<DiffSolver>& TimeSolver::adjoint_solver () [inline, virtual]An implicit linear solver to use for adjoint problems.
void TimeSolver::advance_timestep () [virtual]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.
virtual void TimeSolver::before_timestep () [inline, virtual]This method is for subclasses or users to override to do arbitrary processing between timesteps
virtual AutoPtr<DiffSolver>& TimeSolver::diff_solver () [inline, virtual]An implicit linear or nonlinear solver to use at each timestep.
virtual Real TimeSolver::du (const SystemNorm &norm) const [pure virtual]Computes the size of ||u^{n+1} - u^{n}|| in some norm.
virtual bool TimeSolver::element_residual (boolrequest_jacobian, DiffContext &) [pure virtual]This method uses the DifferentiableSystem's element_time_derivative() and element_constraint() to build a full residual on an element. What combination it uses will depend on the type of solver. See the subclasses for more details.
std::string ReferenceCounter::get_info () [static, inherited]Gets a string containing the reference information.
void ReferenceCounter::increment_constructor_count (const std::string &name) [inline, protected, inherited]Increments the construction counter. Should be called in the constructor of any derived class that will be reference counted.
void ReferenceCounter::increment_destructor_count (const std::string &name) [inline, protected, inherited]Increments the destruction counter. Should be called in the destructor of any derived class that will be reference counted.
void TimeSolver::init () [virtual]The initialization function. This method is used to initialize internal data structures before a simulation begins.
static unsigned int ReferenceCounter::n_objects () [inline, static, inherited]Prints the number of outstanding (created, but not yet destroyed) objects.
void ReferenceCounter::print_info () [static, inherited]Prints the reference information to std::cout.
void TimeSolver::reinit () [virtual]The reinitialization function. This method is used after changes in the mesh
virtual bool TimeSolver::side_residual (boolrequest_jacobian, DiffContext &) [pure virtual]This method uses the DifferentiableSystem's side_time_derivative() and side_constraint() to build a full residual on an element's side. What combination it uses will depend on the type of solver. See the subclasses for more details.
void TimeSolver::solve () [virtual]This method solves for the solution at the next timestep (or solves for a steady-state solution). Usually we will only need to solve one (non)linear system per timestep, but more complex subclasses may override this.
const sys_type& TimeSolver::system () const [inline]Returns:
sys_type& TimeSolver::system () [inline, protected]Returns:
Member Data Documentation
AutoPtr<DiffSolver> TimeSolver::_adjoint_solver [protected]An implicit linear solver to use for adjoint problems.
ReferenceCounter::Counts ReferenceCounter::_counts [static, protected, inherited]Actually holds the data.
AutoPtr<DiffSolver> TimeSolver::_diff_solver [protected]An implicit linear or nonlinear solver to use at each timestep.
Threads::spin_mutex ReferenceCounter::_mutex [static, protected, inherited]Mutual exclusion object to enable thread-safe reference counting.
Threads::atomic< unsigned int > ReferenceCounter::_n_objects [static, protected, inherited]The number of objects. Print the reference count information when the number returns to 0.
sys_type& TimeSolver::_system [protected]A reference to the system we are solving.
bool TimeSolver::first_solve [protected]A bool that will be true the first time solve() is called, and false thereafter
AutoPtr<NumericVector<Number> > TimeSolver::old_local_nonlinear_solution [protected]Serial vector of _system.get_vector('_old_nonlinear_solution')
bool TimeSolver::quietPrint extra debugging information if quiet == false.
unsigned int TimeSolver::reduce_deltat_on_diffsolver_failureThis 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 that this has no effect for SteadySolvers. Note that 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.
Author

This document was created by man2html, using the manual pages.
Time: 21:57:28 GMT, April 16, 2011