NSF Postdoctoral Research
A set of C++ code developed by Andrew E. Slaughter
|
A template base class for using libmesh to solve equations. More...
#include <fem/common/eq_base.h>
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. |
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.
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.
Type | The type of libmesh system to be added, e.g., TransientLinearImplicitSystem as in the HeatEq class. |
TypeBoundaryBase | The 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. |
sys | A libmesh EquationSystems to work from |
name | The name of the system being created |
order | The order to use for the created equation |
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
TypeNewBoundary | The type of boundary being added. The type added must be derived from EqBoundaryBase. See example1.cpp for an example. |
id | The integer identification for the boundary |
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).
func | A function pointer to the initialization function |
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.
func | A function pointer to the initialization function |
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.
bst_fptr | A boost::function that points to the initialization function or class |
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.
id | The boundary id to search |
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.
void SlaughterFEM::EqBase< Type, TypeBoundaryBase >::set_refinement_levels | ( | double | refine_fraction, |
double | coarsen_fraction, | ||
int | max_h_level | ||
) | [inline] |
Sets the mesh refienement critiera.
refine_fraction | maximum portion of elements for refinement |
coarsen_fraction | maximum portion of elements for coarsening |
max_h_level | the maximum refinements allowed for an element |
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.
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
time | The current time |
dt | The change in time |
void SlaughterFEM::EqBase< Type, TypeBoundaryBase >::use_refinement | ( | int | n = 5 | ) | [inline] |
Enable mesh refinement.
This enables adaptive mesh refinement using the libMesh KellyErrorEstimation.
n | The 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.