Hermes2D
2.0
|
Represents a finite element space over a domain. More...
#include <space.h>
Classes | |
struct | BaseComponent |
class | ElementData |
union | NodeData |
class | ReferenceSpaceCreator |
Class for creating reference space. More... | |
Public Member Functions | |
Space (const Mesh *mesh, Shapeset *shapeset, EssentialBCs< Scalar > *essential_bcs) | |
void | init () |
Common code for constructors. | |
virtual bool | isOkay () const |
State querying helpers. | |
std::string | getClassName () const |
Get class name, for the purpose of messaging. | |
virtual | ~Space () |
Destructor. | |
virtual void | set_element_order (int id, int order) |
virtual void | set_element_orders (int *elem_orders) |
Sets polynomial order to all elements. | |
int | get_element_order (int id) const |
Returns element polynomial order. | |
void | set_uniform_order (int order, std::string marker=HERMES_ANY) |
void | adjust_element_order (int order_change, int min_order) |
void | adjust_element_order (int horizontal_order_change, int vertical_order_change, unsigned int horizontal_min_order, unsigned int vertical_min_order) |
Version for quads. | |
void | unrefine_all_mesh_elements (bool keep_initial_refinements=true) |
void | update_element_orders_after_refinement () |
Updates element orders when the underlying mesh has been refined. | |
virtual void | set_shapeset (Shapeset *shapeset)=0 |
Sets the shapeset. | |
int | get_num_dofs () const |
Returns the number of basis functions contained in the space. | |
Mesh * | get_mesh () const |
void | set_mesh (Mesh *mesh) |
Sets a (new) mesh and calls assign_dofs(). | |
void | set_mesh_seq (int seq) |
Sets a (new) mesh seq, and mesh_seq. | |
void | set_essential_bcs (EssentialBCs< Scalar > *essential_bcs) |
Sets the boundary condition. | |
EssentialBCs< Scalar > * | get_essential_bcs () const |
Obtains an boundary conditions. | |
void | update_essential_bc_values () |
Shapeset * | get_shapeset () const |
bool | save (const char *filename) const |
Saves this space into a file. | |
virtual void | get_element_assembly_list (Element *e, AsmList< Scalar > *al, unsigned int first_dof=0) const |
Obtains an assembly list for the given element. | |
virtual void | copy (const Space< Scalar > *space, Mesh *new_mesh) |
Copy from Space instance 'space'. | |
virtual void | set_element_order_internal (int id, int order) |
virtual int | assign_dofs (int first_dof=0, int stride=1) |
Builds basis functions and assigns DOF numbers to them. More... | |
virtual Scalar * | get_bc_projection (SurfPos *surf_pos, int order, EssentialBoundaryCondition< Scalar > *bc)=0 |
virtual SpaceType | get_type () const =0 |
void | distribute_orders (Mesh *mesh, int *parents) |
Sets polynomial orders to elements created by Mesh::regularize() using "parents". | |
virtual int | get_edge_order (Element *e, int edge) const |
Internal. Obtains the order of an edge, according to the minimum rule. | |
int | get_max_dof () const |
Returns the DOF number of the last basis function. | |
bool | is_up_to_date () const |
Returns true if the space is ready for computation, false otherwise. | |
void | get_boundary_assembly_list (Element *e, int surf_num, AsmList< Scalar > *al, unsigned int first_dof=0) const |
Obtains an edge assembly list (contains shape functions that are nonzero on the specified edge). | |
void | set_uniform_order_internal (int order, int marker) |
void | free () |
int | get_vertex_functions_count () |
int | get_edge_functions_count () |
Returns the total (global) number of edge functions. | |
int | get_bubble_functions_count () |
Returns the total (global) number of bubble functions. | |
template<> | |
void | init () |
template<> | |
void | init () |
template<> | |
void | free () |
template<> | |
void | free () |
template<> | |
Space (const Mesh *mesh, Shapeset *shapeset, EssentialBCs< double > *essential_bcs) | |
template<> | |
Space (const Mesh *mesh, Shapeset *shapeset, EssentialBCs< std::complex< double > > *essential_bcs) | |
![]() | |
void | check () const |
Method to handle the state. | |
![]() | |
XMLParsing () | |
Constructor. | |
void | set_validation (bool to_set) |
Set to validate / not to validate. | |
Static Public Member Functions | |
static int | get_num_dofs (Hermes::vector< const Space< Scalar > * > spaces) |
Returns the number of basis functions contained in the spaces. | |
static int | get_num_dofs (Hermes::vector< Space< Scalar > * > spaces) |
static int | get_num_dofs (const Space< Scalar > *space) |
Returns the number of basis functions contained in the space. | |
static int | get_num_dofs (Space< Scalar > *space) |
static Space< Scalar > * | load (const char *filename, Mesh *mesh, bool validate, EssentialBCs< Scalar > *essential_bcs=NULL, Shapeset *shapeset=NULL) |
Loads a space from a file. | |
static int | assign_dofs (Hermes::vector< Space< Scalar > * > spaces) |
Assings the degrees of freedom to all Spaces in the Hermes::vector. | |
static void | update_essential_bc_values (Hermes::vector< Space< Scalar > * > spaces, double time) |
static void | update_essential_bc_values (Space< Scalar > *s, double time) |
static Node * | get_mid_edge_vertex_node (Element *e, int i, int j) |
Protected Member Functions | |
virtual int | get_edge_order_internal (Node *en) const |
virtual void | resize_tables () |
Updates internal node and element tables. More... | |
void | update_orders_recurrent (Element *e, int order) |
virtual void | reset_dof_assignment () |
Resets assignment of DOF to an unassigned state. | |
virtual void | assign_vertex_dofs ()=0 |
virtual void | assign_edge_dofs ()=0 |
virtual void | assign_bubble_dofs ()=0 |
virtual void | get_vertex_assembly_list (Element *e, int iv, AsmList< Scalar > *al) const =0 |
virtual void | get_boundary_assembly_list_internal (Element *e, int surf_num, AsmList< Scalar > *al) const =0 |
virtual void | get_bubble_assembly_list (Element *e, AsmList< Scalar > *al) const |
void | precalculate_projection_matrix (int nv, double **&mat, double *&p) |
void | update_edge_bc (Element *e, SurfPos *surf_pos) |
virtual void | update_constraints () |
virtual void | post_assign () |
void | free_bc_data () |
int | get_seq () const |
Internal. Used by DiscreteProblem to detect changes in the space. | |
Protected Attributes | |
int | ndof |
Number of degrees of freedom (dimension of the space). | |
Shapeset * | shapeset |
bool | own_shapeset |
true if default shapeset is created in the constructor, false if shapeset is supplied by user. | |
EssentialBCs< Scalar > * | essential_bcs |
Boundary conditions. | |
const Mesh * | mesh |
FE mesh. | |
int | default_tri_order |
int | default_quad_order |
int | vertex_functions_count |
int | edge_functions_count |
int | bubble_functions_count |
int | first_dof |
int | next_dof |
int | stride |
int | seq |
int | mesh_seq |
int | was_assigned |
NodeData * | ndata |
node data table | |
ElementData * | edata |
element data table | |
int | nsize |
int | ndata_allocated |
number of items in ndata, allocated space | |
int | esize |
double ** | proj_mat |
double * | chol_p |
Hermes::vector< void * > | bc_data |
Used for bc projection. | |
![]() | |
bool | validate |
Internal. | |
Static Protected Attributes | |
static const int | H2D_UNASSIGNED_DOF = -2 |
DOF which was not assigned yet. | |
static const int | H2D_CONSTRAINED_DOF = -1 |
DOF which is constrained. | |
Represents a finite element space over a domain.
The Space class represents a finite element space over a domain defined by 'mesh', spanned by basis functions constructed using 'shapeset'. It serves as a base class for H1Space, HcurlSpace, HdivSpace and L2Space, since most of the functionality is common for all these spaces.
There are four main functions the Space class provides:
It handles the Dirichlet (essential) boundary conditions. The user provides a pointer to an instance of the EssentialBCs class that determines which markers represent the Dirichlet part of the boundary, and which markers represent the Neumann and Newton parts (all other than those with an Essential BC specified on them). Handling of these conditions is done naturally - through weak formulation.
It stores element polynomial degrees, or 'orders'. All active elements need to have an order set for the Space to be valid. Individual orders can be set by calling set_element_order(). You can also set the same order for all elements using set_uniform_order(). Quadrilateral elements can have different orders in the vertical and horizontal directions. It is therefore necessary to form the order using the macro H2D_MAKE_QUAD_ORDER() when calling the aforementioned functions.
It builds and enumerates the basis functions. After all element orders have been set, you must call the function assign_dofs(). This function assigns the DOF (degree-of- freedom) numbers to basis functions, starting with 'first_dof' (optional parameter). It also determines constraining relationships in the mesh due to hanging nodes and builds constrained basis functions. The total number of basis functions can then be obtained by calling (). Standard basis functions are assigned positive numbers from 'first_dof' to ('first_dof' + (get_num_dofs() - 1) * 'stride'). All shape functions belonging to the Dirichlet lift are assigned DOF number of -1. This way the Dirichlet lift becomes a (virtual) basis function. This simplifies assembling.
Finally, and most importantly, the Space is able to deliver a list of shape functions existing on each element. Such a list is called an "assembly list" and is represented by the class AsmList<Scalar>. The assembly list contains the triplets (idx, dof, coef). 'idx' is the shape function index, as understood by the Shapeset. 'dof' is the number of the basis function, whose part the shape function forms. 'coef' is a Real constant, with which the shape function must be multiplied in order to fit into the basis function. This is typically 1, but can be less than that for constrained functions. Constrained vertex functions can belong to more than one basis functions. This results in more triplets with the same 'idx'. However, the assembling procedure or the Solution class do not have to worry about that. For instance, the Solution class simply obtains the values of all shape functions contained in the list, multiplies them by 'coef', and forms a linear combination of them by taking the solution vector values at the 'dof' positions. This way the solution to the PDE is obtained.
Space is an abstract class and cannot be instatiated. Use one of the specializations H1Space, HcurlSpace or L2Space instead.
The handling of irregular meshes is desribed in H1Space and HcurlSpace.
void Hermes::Hermes2D::Space< Scalar >::adjust_element_order | ( | int | order_change, |
int | min_order | ||
) |
|
virtual |
Builds basis functions and assigns DOF numbers to them.
This functions must be called after assigning element orders, and before using the space in a computation, otherwise an error will occur.
first_dof[in] | The DOF number of the first basis function. |
stride[in] | The difference between the DOF numbers of successive basis functions. |
Definition at line 875 of file space.cpp.
Referenced by Hermes::Hermes2D::Space< Scalar >::assign_dofs(), Hermes::Hermes2D::Space< Scalar >::ReferenceSpaceCreator::create_ref_space(), Hermes::Hermes2D::DiscreteProblem< Scalar >::create_sparse_structure(), Hermes::Hermes2D::HdivSpace< Scalar >::init(), Hermes::Hermes2D::L2Space< Scalar >::init(), and Hermes::Hermes2D::Space< Scalar >::load().
|
pure virtual |
Internal. Return type of this space (H1 = HERMES_H1_SPACE, Hcurl = HERMES_HCURL_SPACE, Hdiv = HERMES_HDIV_SPACE, L2 = HERMES_L2_SPACE)
Implemented in Hermes::Hermes2D::H1Space< Scalar >, Hermes::Hermes2D::HdivSpace< Scalar >, Hermes::Hermes2D::L2Space< Scalar >, and Hermes::Hermes2D::HcurlSpace< Scalar >.
Referenced by Hermes::Hermes2D::CalculationContinuity< Scalar >::Record::load_solution(), Hermes::Hermes2D::OGProjection< Scalar >::project_global(), Hermes::Hermes2D::Space< Scalar >::save(), Hermes::Hermes2D::Solution< Scalar >::set_coeff_vector(), and Hermes::Hermes2D::Solution< Scalar >::set_dirichlet_lift().
int Hermes::Hermes2D::Space< Scalar >::get_vertex_functions_count | ( | ) |
|
protectedvirtual |
Auxiliary function the descendants may implement to perform additional tasks after the DOFs have been assigned.
Reimplemented in Hermes::Hermes2D::H1Space< Scalar >.
Definition at line 846 of file space.cpp.
Referenced by Hermes::Hermes2D::Space< Scalar >::assign_dofs().
|
protectedvirtual |
Updates internal node and element tables.
Since meshes only contain geometric information, the Space class keeps two tables with FEM-related information. The first one, 'ndata', contains DOF numbers and other things for each node. The second table, 'edata', holds element orders and bubble DOF numbers. Both tables are directly indexed by the node and element IDs. The function resize_tables() is called to check whether the tables are large enough to contain all node and element id's, and to reallocate them if not.
Reimplemented in Hermes::Hermes2D::L2Space< Scalar >.
Definition at line 202 of file space.cpp.
Referenced by Hermes::Hermes2D::Space< Scalar >::assign_dofs(), Hermes::Hermes2D::Space< Scalar >::load(), and Hermes::Hermes2D::L2Space< Scalar >::resize_tables().
|
virtual |
Sets element polynomial order. Can be called by the user. Should not be called for many elements at once, since assign_dofs() is called at the end of this function.
|
virtual |
Sets element polynomial order. This version does not call assign_dofs() and is intended primarily for internal use.
Definition at line 314 of file space.cpp.
Referenced by Hermes::Hermes2D::Adapt< Scalar >::apply_refinement(), and Hermes::Hermes2D::Space< Scalar >::distribute_orders().
void Hermes::Hermes2D::Space< Scalar >::set_uniform_order | ( | int | order, |
std::string | marker = HERMES_ANY |
||
) |
Sets the same polynomial order for all elements in the mesh. Intended for the user and thus assign_dofs() is called at the end of this function.
void Hermes::Hermes2D::Space< Scalar >::set_uniform_order_internal | ( | int | order, |
int | marker | ||
) |
Sets the same polynomial order for all elements in the mesh. Does not call assign_dofs(). For internal use.
Definition at line 412 of file space.cpp.
Referenced by Hermes::Hermes2D::HdivSpace< Scalar >::init(), and Hermes::Hermes2D::L2Space< Scalar >::init().
void Hermes::Hermes2D::Space< Scalar >::unrefine_all_mesh_elements | ( | bool | keep_initial_refinements = true | ) |
|
protectedvirtual |
Called by Space to update constraining relationships between shape functions due to hanging nodes in the mesh. As this is space-specific, this function is reimplemented in H1Space and HcurlSpace.
Reimplemented in Hermes::Hermes2D::H1Space< Scalar >, Hermes::Hermes2D::HdivSpace< Scalar >, and Hermes::Hermes2D::HcurlSpace< Scalar >.
Definition at line 841 of file space.cpp.
Referenced by Hermes::Hermes2D::Space< Scalar >::assign_dofs().
void Hermes::Hermes2D::Space< Scalar >::update_essential_bc_values | ( | ) |
Updates essential BC values. Typically used for time-dependent essnetial boundary conditions.
Definition at line 1114 of file space.cpp.
Referenced by Hermes::Hermes2D::Space< Scalar >::assign_dofs(), Hermes::Hermes2D::PicardSolver< Scalar >::set_time(), Hermes::Hermes2D::DiscreteProblem< Scalar >::set_time(), and Hermes::Hermes2D::NewtonSolver< Scalar >::set_time().