Solver Class Reference

#include <solver.h>

Inheritance diagram for Solver:

List of all members.

Public Types

typedef EquationSystems sys_type

Public Member Functions

 ~Solver ()
virtual void init ()
virtual void pre_process ()
virtual void solve ()
virtual void post_process ()
const sys_typesystem () const
const MeshBasemesh () const

Static Public Member Functions

static std::string get_info ()
static void print_info ()
static unsigned int n_objects ()

Protected Types

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

Protected Member Functions

 Solver (EquationSystems &es)
 Solver (EquationSystems &es, const std::string &name, const unsigned int number)
sys_typesystem ()
MeshBasemesh ()
void increment_constructor_count (const std::string &name)
void increment_destructor_count (const std::string &name)

Protected Attributes

sys_type_system
MeshBase_mesh

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 be used in a simulation. A user can define a solver by deriving from this class and implementing certain functions.

Author:
Benjamin S. Kirk, 2003-2004.

Definition at line 46 of file 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.

The type of system

Definition at line 76 of file solver.h.


Constructor & Destructor Documentation

Solver::Solver ( EquationSystems es  )  [inline, protected]

Constructor. Requires a reference to the system to be solved. The constructor is protected since it should not be instantiated by users.

Definition at line 143 of file solver.h.

00143                                    :
00144   _system (es),
00145   _mesh   (es.get_mesh())
00146 {
00147 libmesh_deprecated();
00148 }

Solver::Solver ( EquationSystems es,
const std::string &  name,
const unsigned int  number 
) [protected]

Constructor. Requires a reference to the EquationSystems object, a name for the system, and the system number.

Solver::~Solver (  )  [inline]

Destructor.

Definition at line 153 of file solver.h.

00154 {
00155 }


Member Function Documentation

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 QuadratureRules::name().

Referenced by ReferenceCounter::print_info().

00046 {
00047 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
00048 
00049   std::ostringstream out;
00050   
00051   out << '\n'
00052       << " ---------------------------------------------------------------------------- \n"
00053       << "| Reference count information                                                |\n"
00054       << " ---------------------------------------------------------------------------- \n";
00055   
00056   for (Counts::iterator it = _counts.begin();
00057        it != _counts.end(); ++it)
00058     {
00059       const std::string name(it->first);
00060       const unsigned int creations    = it->second.first;
00061       const unsigned int destructions = it->second.second;
00062 
00063       out << "| " << name << " reference count information:\n"
00064           << "|  Creations:    " << creations    << '\n'
00065           << "|  Destructions: " << destructions << '\n';
00066     }
00067   
00068   out << " ---------------------------------------------------------------------------- \n";
00069 
00070   return out.str();
00071 
00072 #else
00073 
00074   return "";
00075   
00076 #endif
00077 }

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, and Threads::spin_mtx.

Referenced by ReferenceCountedObject< SparseMatrix< T > >::ReferenceCountedObject().

00150 {
00151   Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
00152   std::pair<unsigned int, unsigned int>& p = _counts[name];
00153 
00154   p.first++;
00155 }

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, and Threads::spin_mtx.

Referenced by ReferenceCountedObject< SparseMatrix< T > >::~ReferenceCountedObject().

00168 {
00169   Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
00170   std::pair<unsigned int, unsigned int>& p = _counts[name];
00171 
00172   p.second++;
00173 }

void Solver::init (  )  [inline, virtual]

The initialization function. This method is used to initialize data structures befor a simulation begins.

Definition at line 160 of file solver.h.

References EquationSystems::init(), and system().

00161 {
00162   std::cout << "Initializing $Id: solver.h 3549 2009-11-09 17:39:52Z roystgnr $"
00163             << std::endl;
00164   
00165   // Initialize the system.
00166   this->system().init ();
00167 }

MeshBase& Solver::mesh (  )  [inline, protected]

Returns:
a reference to the Mesh.

Definition at line 124 of file solver.h.

References _mesh.

00124 { return _mesh; }

const MeshBase& Solver::mesh (  )  const [inline]

Returns:
a reference to the Mesh.

Definition at line 111 of file solver.h.

References _mesh.

00111 { return _mesh; }

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.

00077   { return _n_objects; }

void Solver::post_process (  )  [inline, virtual]

This method may be called after each solve step in order to perform any required post-processing.

Definition at line 199 of file solver.h.

Referenced by solve().

00200 {
00201 //  std::cout << "Post-processing"
00202 //          << std::endl;
00203 }

void Solver::pre_process (  )  [inline, virtual]

This method may be called before each solve step in order to perform any required pre-processing.

Definition at line 172 of file solver.h.

Referenced by solve().

00173 {
00174 //  std::cout << "Pre-processing"
00175 //          << std::endl;
00176 }

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().

00084 {
00085 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
00086   
00087   std::cout << ReferenceCounter::get_info();
00088   
00089 #endif
00090 }

void Solver::solve (  )  [inline, virtual]

This method performs a solve step. What occurs in this method will depend on the type of solver. See the example programs for more details.

Definition at line 181 of file solver.h.

References post_process(), pre_process(), EquationSystems::solve(), and system().

00182 {
00183   // Perform any necessary pre-processing
00184   Solver::pre_process ();
00185   
00186 //  std::cout << "Solving $Id: solver.h 3549 2009-11-09 17:39:52Z roystgnr $"
00187 //          << std::endl;
00188 
00189   // Solve the system
00190   this->system().solve ();
00191   
00192   // Perform any necessary post-processing
00193   Solver::post_process ();  
00194 }

sys_type& Solver::system (  )  [inline, protected]

Returns:
a writeable reference to the system we are solving.

Definition at line 119 of file solver.h.

References _system.

00119 { return _system; }

const sys_type& Solver::system (  )  const [inline]

Returns:
a constant reference to the system we are solving.

Definition at line 106 of file solver.h.

References _system.

Referenced by init(), and solve().

00106 { return _system; }


Member Data Documentation

MeshBase& Solver::_mesh [protected]

A reference to the Mesh for the system we are solving.

Definition at line 135 of file solver.h.

Referenced by mesh().

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& Solver::_system [protected]

A reference to the system we are solving.

Definition at line 129 of file solver.h.

Referenced by system().


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

Site Created By: libMesh Developers
Last modified: November 25 2009 03:44:58.

Hosted By:
SourceForge.net Logo