NSF Postdoctoral Research
A set of C++ code developed by Andrew E. Slaughter
SlaughterFEM::EqBase< Type, TypeBoundaryBase > Class Template Reference

A template base class for using libmesh to solve equations. More...

#include <fem/common/eq_base.h>

Inheritance diagram for SlaughterFEM::EqBase< Type, TypeBoundaryBase >:
Collaboration diagram for SlaughterFEM::EqBase< Type, TypeBoundaryBase >:

List of all members.

Public Member Functions

virtual void init_equation_system (Real t_initial=0)
 Initializes the equation system.
virtual void update_solution (Real time, Real dt)
 Updates the solution with time.
void use_refinement (int n=5)
 Enable mesh refinement.
void set_refinement_levels (double refine_fraction, double coarsen_fraction, int max_h_level)
 Sets the mesh refienement critiera.
void add_initial_function (eq_base_init_func_libmesh func)
 Add a function pointer to the initialization function.
void add_initial_function (eq_base_init_func_boost func)
 Add function pointer to act as initialization function using boost::function indirectly.
void add_initial_function (boost::function< void(DenseVector< Number > &output, const Point &, const Real)> bst_fptr)
 Add a boost::function pointer act as initialization function.
template<class TypeNewBoundary >
boost::shared_ptr
< TypeNewBoundary > 
add_boundary (int id)
 Adds a boundary object.
virtual void solve ()
 Solves the equation system for this class.

Protected Member Functions

 EqBase (EquationSystems &sys, string name, const Order order=SECOND)
 Class constructor.
virtual void assemble ()=0
 libMesh assembly function
virtual void initialize ()
 libMesh initilize function
void apply_dirichlet ()
 Apply the libMesh based Dirichlet boundary condition.
vector< int > get_boundary_index (const int id)
 A method for getting a vector of indices for the boundary id.

Protected Attributes

bool using_mesh_refinement
 A flag for using mesh refinement.
boost::shared_ptr< MeshRefinement > refine_ptr
 A shared pointer to the mesh refinement object created.
int max_r_steps
 The maximum number of refinement steps allowed.
eq_base_init_func_libmesh init_func
 A function pointer to the initialization function.
boost::function< void(DenseVector
< Number > &output, const
Point &, const Real)> 
bst_init_func
 A boost::function for initialization.
vector< boost::shared_ptr
< TypeBoundaryBase > > 
bc_ptrs
 Storage vector for added boundaries.

Detailed Description

template<typename Type, class TypeBoundaryBase = EqBoundaryBase>
class SlaughterFEM::EqBase< Type, TypeBoundaryBase >

A template base class for using libmesh to solve equations.

Provides mechanism for defining a libMesh equation system. It utilizes the EqBoundaryBase class for implementing boundary conditions.

This class must be inherited and the pure virtual function must be defined in the inherited class.

The public members are designed to be used by the use in their main program. The protected members, although some must be defined, should not be needed by the user once defined.

See also:
HeatEq
example1.cpp
example2.cpp

Constructor & Destructor Documentation

template<typename Type, class TypeBoundaryBase = EqBoundaryBase>
SlaughterFEM::EqBase< Type, TypeBoundaryBase >::EqBase ( EquationSystems &  sys,
string  name,
const Order  order = SECOND 
) [inline, protected]

Class constructor.

The EqBase class is designed to be inherited, thus the constructor is protected.

When inheriting this class it is import to explicitly call this constructor in the constructor of the inheriting class, otherwise the class will not function properly. See the HeatEq class for an example.

Template Parameters:
TypeThe type of libmesh system to be added, e.g., TransientLinearImplicitSystem as in the HeatEq class.
TypeBoundaryBaseThe base class for the boundary conditions. By default it uses EqBoundaryBase but the user might what to change this to use an inherited class of EqBoundaryBase, again as done in the HeatEq class.
Parameters:
sysA libmesh EquationSystems to work from
nameThe name of the system being created
orderThe order to use for the created equation
See also:
HeatEq

Member Function Documentation

template<typename Type, class TypeBoundaryBase = EqBoundaryBase>
template<class TypeNewBoundary >
boost::shared_ptr<TypeNewBoundary> SlaughterFEM::EqBase< Type, TypeBoundaryBase >::add_boundary ( int  id) [inline]

Adds a boundary object.

A template class for adding a boundary condition

Template Parameters:
TypeNewBoundaryThe type of boundary being added. The type added must be derived from EqBoundaryBase. See example1.cpp for an example.
Parameters:
idThe integer identification for the boundary
See also:
EqBoundaryBase
example1.cpp
template<typename Type, class TypeBoundaryBase = EqBoundaryBase>
void SlaughterFEM::EqBase< Type, TypeBoundaryBase >::add_initial_function ( eq_base_init_func_libmesh  func) [inline]

Add a function pointer to the initialization function.

This version uses the libmesh documented method for adding initial conditions for an equation system. It must be specified in a function with the format given below. (see libMesh help for input format).

Parameters:
funcA function pointer to the initialization function
template<typename Type, class TypeBoundaryBase = EqBoundaryBase>
void SlaughterFEM::EqBase< Type, TypeBoundaryBase >::add_initial_function ( eq_base_init_func_boost  func) [inline]

Add function pointer to act as initialization function using boost::function indirectly.

The initial conditions for the the equation must be specified, this version takes the function pointer and converts it to a boost::function and uses the overloaded version of the add_initial_function to apply the function to the equation system.

Parameters:
funcA function pointer to the initialization function
template<typename Type, class TypeBoundaryBase = EqBoundaryBase>
void SlaughterFEM::EqBase< Type, TypeBoundaryBase >::add_initial_function ( boost::function< void(DenseVector< Number > &output, const Point &, const Real)>  bst_fptr) [inline]

Add a boost::function pointer act as initialization function.

The initial conditions for equation must be specified, this function may be passed to the EqBase class using a boost::function which allows for extreme flexibility when binding is used.

Parameters:
bst_fptrA boost::function that points to the initialization function or class
template<typename Type, class TypeBoundaryBase = EqBoundaryBase>
vector<int> SlaughterFEM::EqBase< Type, TypeBoundaryBase >::get_boundary_index ( const int  id) [inline, protected]

A method for getting a vector of indices for the boundary id.

This is a useful function for finding a boundary object with a specific id or to test if an id has been used.

Returns:
A vector containing the index value of the given id. There should be only one value to this vector, but if empty the boundary doesn't exist. The id's are checked for uniqueness when they are added.
Parameters:
idThe boundary id to search
See also:
HeatEq
template<typename Type, class TypeBoundaryBase = EqBoundaryBase>
virtual void SlaughterFEM::EqBase< Type, TypeBoundaryBase >::init_equation_system ( Real  t_initial = 0) [inline, virtual]

Initializes the equation system.

This function must be called before the equation is solved, but after all of the boundaries are defined. It does two things, adds the dirichlet conditions and then calls the libMesh equation systems init() function.

template<typename Type, class TypeBoundaryBase = EqBoundaryBase>
void SlaughterFEM::EqBase< Type, TypeBoundaryBase >::set_refinement_levels ( double  refine_fraction,
double  coarsen_fraction,
int  max_h_level 
) [inline]

Sets the mesh refienement critiera.

Parameters:
refine_fractionmaximum portion of elements for refinement
coarsen_fractionmaximum portion of elements for coarsening
max_h_levelthe maximum refinements allowed for an element
template<typename Type, class TypeBoundaryBase = EqBoundaryBase>
virtual void SlaughterFEM::EqBase< Type, TypeBoundaryBase >::solve ( ) [inline, virtual]

Solves the equation system for this class.

When mesh refinement is used the equation is iteratively solves using Kelly error estimatition, otherwise it simply uses the libMesh equation systems solve() command.

This is a virtual function to allow the user to change the solution behavior in the derived class.

Todo:
Mesh refinement is not tested.
template<typename Type, class TypeBoundaryBase = EqBoundaryBase>
virtual void SlaughterFEM::EqBase< Type, TypeBoundaryBase >::update_solution ( Real  time,
Real  dt 
) [inline, virtual]

Updates the solution with time.

Passes the current solution to the old solution and reapplies the dirichlet boundary constraints

Parameters:
timeThe current time
dtThe change in time
template<typename Type, class TypeBoundaryBase = EqBoundaryBase>
void SlaughterFEM::EqBase< Type, TypeBoundaryBase >::use_refinement ( int  n = 5) [inline]

Enable mesh refinement.

This enables adaptive mesh refinement using the libMesh KellyErrorEstimation.

Parameters:
nThe maximum number of refinement iterations

The set_refinement_levels function provides the ability to change the various refinement parameters, this function sets the defaults for these parameters at 0.8, 0.07, and 5.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs