Hermes2D
3.0
|
A general projection-based selector. More...
#include <proj_based_selector.h>
Classes | |
struct | ElemGIP |
Integration points in the reference domain of an element of a candidate. More... | |
struct | ElemProj |
Projection of an element of a candidate. More... | |
struct | ElemSubShapeFunc |
A shape function on subdomain of an element. More... | |
struct | ElemSubTrf |
A transformation from a reference domain of a subdomain to a reference domain of an element of a candidate. More... | |
class | TrfShapeExp |
A transform shaped function expansions. More... | |
struct | ValueCacheItem |
An item of a value cache. More... | |
Public Types | |
typedef std::vector< TrfShapeExp > | TrfShape [H2D_TRF_NUM] |
Evaluated shapes for all possible transformations for all points. The first index is a transformation, the second index is an index of a shape function. | |
Public Member Functions | |
virtual | ~ProjBasedSelector () |
Destructor. | |
void | set_error_weights (double weight_h=H2DRS_DEFAULT_ERR_WEIGHT_H, double weight_p=H2DRS_DEFAULT_ERR_WEIGHT_P, double weight_aniso=H2DRS_DEFAULT_ERR_WEIGHT_ANISO) |
Sets error weights. More... | |
double | get_error_weight_h () const |
double | get_error_weight_p () const |
double | get_error_weight_aniso () const |
Public Member Functions inherited from Hermes::Hermes2D::RefinementSelectors::OptimumSelector< Scalar > | |
virtual | ~OptimumSelector () |
Destructor. | |
void | set_dof_score_exponent (double exponent) |
Set the score DOF exponent. | |
Public Attributes | |
bool * | cached_shape_vals_valid |
True if shape values were already initialized. | |
TrfShape * | cached_shape_ortho_vals |
Precalculated valus of orthogonalized shape functions. | |
TrfShape * | cached_shape_vals |
Precalculate values of shape functions. | |
Protected Types | |
typedef double ** | ProjMatrixCache [H2DRS_MAX_ORDER+2][H2DRS_MAX_ORDER+2] |
A projection matrix cache type. More... | |
Protected Types inherited from Hermes::Hermes2D::RefinementSelectors::OptimumSelector< Scalar > | |
enum | ShapeType { H2DST_VERTEX = 0x01, H2DST_HORIZ_EDGE = 0x02, H2DST_VERT_EDGE = 0x04, H2DST_TRI_EDGE = 0x08, H2DST_BUBBLE = 0x10 } |
A shape function type. More... | |
enum | ShapeTypeInt { H2DSI_VERTEX, H2DSI_HORIZ_EDGE, H2DSI_VERT_EDGE, H2DSI_TRI_EDGE, H2DSI_BUBBLE, H2DSI_ANY } |
Protected Member Functions | |
virtual void | precalc_shapes (const double3 *gip_points, const int num_gip_points, const Trf *trfs, const int num_noni_trfs, const std::vector< typename OptimumSelector< Scalar >::ShapeInx > &shapes, const int max_shape_inx, TrfShape &svals, ElementMode2D mode) |
Calculates values of shape function at GIP for all transformations. More... | |
virtual void | precalc_ortho_shapes (const double3 *gip_points, const int num_gip_points, const Trf *trfs, const int num_noni_trfs, const std::vector< typename OptimumSelector< Scalar >::ShapeInx > &shapes, const int max_shape_inx, TrfShape &ortho_svals, ElementMode2D mode) |
Calculates values of orthogonalized shape function at GIP for all transformations. More... | |
ProjBasedSelector (CandList cand_list, int max_order, Shapeset *shapeset, const Range &vertex_order, const Range &edge_bubble_order) | |
Constructor. More... | |
virtual void | evaluate_cands_error (std::vector< Cand > &candidates, Element *e, MeshFunction< Scalar > *rsln) |
Calculates error of candidates. More... | |
virtual void | calc_projection_errors (Element *e, const typename OptimumSelector< Scalar >::CandsInfo &info_h, const typename OptimumSelector< Scalar >::CandsInfo &info_p, const typename OptimumSelector< Scalar >::CandsInfo &info_aniso, MeshFunction< Scalar > *rsln, CandElemProjError herr[H2D_MAX_ELEMENT_SONS], CandElemProjError perr, CandElemProjError anisoerr[H2D_MAX_ELEMENT_SONS]) |
Calculates projection errors of an elements of candidates for all permutations of orders. More... | |
void | calc_error_cand_element (const ElementMode2D mode, double3 *gip_points, int num_gip_points, const int num_sub, Element **sub_domains, Trf **sub_trfs, int *sons, std::vector< TrfShapeExp > **sub_nonortho_svals, std::vector< TrfShapeExp > **sub_ortho_svals, const typename OptimumSelector< Scalar >::CandsInfo &info, CandElemProjError errors_squared, Scalar *rval[H2D_MAX_ELEMENT_SONS][MAX_NUMBER_FUNCTION_VALUES_FOR_SELECTORS]) |
Calculate projection errors of an element of an candidate considering multiple orders. More... | |
virtual void | precalc_ref_solution (int inx_son, MeshFunction< Scalar > *rsln, Element *element, int intr_gip_order, Scalar *rval[H2D_MAX_ELEMENT_SONS][MAX_NUMBER_FUNCTION_VALUES_FOR_SELECTORS])=0 |
Returns an array of values of the reference solution at integration points. More... | |
virtual void | free_ref_solution_data (int inx_son, Scalar *rval[H2D_MAX_ELEMENT_SONS][MAX_NUMBER_FUNCTION_VALUES_FOR_SELECTORS])=0 |
Frees the data allocated in precalc_ref_solution. | |
virtual double ** | build_projection_matrix (double3 *gip_points, int num_gip_points, const int *shape_inx, const int num_shapes, ElementMode2D)=0 |
Builds projection matrix using a given set of shapes. More... | |
virtual Scalar | evaluate_rhs_subdomain (Element *sub_elem, const ElemGIP &sub_gip, int son, const ElemSubTrf &sub_trf, const ElemSubShapeFunc &sub_shape, Scalar *rval[H2D_MAX_ELEMENT_SONS][MAX_NUMBER_FUNCTION_VALUES_FOR_SELECTORS])=0 |
Evaluates a value of the right-hande side in a subdomain. More... | |
virtual double | evaluate_error_squared_subdomain (Element *sub_elem, const ElemGIP &sub_gip, int son, const ElemSubTrf &sub_trf, const ElemProj &elem_proj, Scalar *rval[H2D_MAX_ELEMENT_SONS][MAX_NUMBER_FUNCTION_VALUES_FOR_SELECTORS])=0 |
Evaluates an squared error of a projection of an element of a candidate onto subdomains. More... | |
Protected Member Functions inherited from Hermes::Hermes2D::RefinementSelectors::OptimumSelector< Scalar > | |
OptimumSelector (CandList cand_list, int max_order, Shapeset *shapeset, const Range &vertex_order, const Range &edge_bubble_order) | |
Constructor. More... | |
void | update_cands_info (std::vector< Cand > &candidates, CandsInfo &info_h, CandsInfo &info_p, CandsInfo &info_aniso) const |
Updates information about candidates. Initial information is provided. More... | |
void | append_candidates_split (std::vector< Cand > &candidates, const int start_quad_order, const int last_order, const RefinementType split, bool iso_p) |
Appends cancidates of a given refinement and a given range of orders. More... | |
virtual std::vector< Cand > | create_candidates (Element *e, int quad_order) |
Fill a list of candidates. More... | |
void | evaluate_candidates (std::vector< Cand > &candidates, Element *e, MeshFunction< Scalar > *rsln) |
Calculates error, dofs, and score of candidates. More... | |
virtual void | select_best_candidate (std::vector< Cand > &candidates, Element *e, Cand *&best_candidate, Cand *best_candidates_specific_type[4]) |
Sorts and selects the best candidate and the best H-candidate according to the score. More... | |
virtual void | evaluate_cands_dof (std::vector< Cand > &candidates, Element *e, MeshFunction< Scalar > *rsln) |
Calculates DOF of candidates. More... | |
virtual void | evaluate_cands_score (std::vector< Cand > &candidates, Element *e) |
Evalutes score of candidates. More... | |
virtual void | get_current_order_range (Element *element, int &min_order, int &max_order)=0 |
Sets OptimumSelector::current_max_order and OptimumSelector::current_min_order. More... | |
void | add_bubble_shape_index (int order_h, int order_v, std::map< int, bool > &used_shape_index, std::vector< ShapeInx > &indices, ElementMode2D mode) |
Adds an index (or indices) of a bubble function of a given order if the shape index was not used yet. More... | |
void | build_shape_indices (const ElementMode2D mode, const Range &vertex_order, const Range &edge_bubble_order) |
Builds shape index table OptimumSelector::shape_indices. More... | |
int | calc_num_shapes (int mode, int order_h, int order_v, int allowed_type_mask) |
Returns a number of shapes that may be contained in an element of a given order. More... | |
virtual bool | select_refinement (Element *element, int quad_order, MeshFunction< Scalar > *rsln, ElementToRefine &refinement) |
Selects a refinement. More... | |
Protected Member Functions inherited from Hermes::Hermes2D::RefinementSelectors::Selector< Scalar > | |
Selector (int min_order=1, int max_order=H2DRS_DEFAULT_ORDER) | |
Constructor. More... | |
Protected Attributes | |
bool | warn_uniform_orders |
True if the selector has already warned about possible inefficiency. More... | |
ProjMatrixCache | proj_matrix_cache [H2D_NUM_MODES] |
An array of projection matrices. More... | |
double | error_weight_h |
A coefficient that multiplies error of H-candidate. The default value is H2DRS_DEFAULT_ERR_WEIGHT_H. | |
double | error_weight_p |
A coefficient that multiplies error of P-candidate. The default value is H2DRS_DEFAULT_ERR_WEIGHT_P. | |
double | error_weight_aniso |
A coefficient that multiplies error of ANISO-candidate. The default value is H2DRS_DEFAULT_ERR_WEIGHT_ANISO. | |
Protected Attributes inherited from Hermes::Hermes2D::RefinementSelectors::OptimumSelector< Scalar > | |
CandList | cand_list |
Allowed candidate types. | |
int **** | num_shapes |
Shapeset * | shapeset |
A shapeset used to calculate error. | |
std::vector< ShapeInx > | shape_indices [H2D_NUM_MODES] |
Shape indices. The first index is a mode (ElementMode2D). | |
int | max_shape_inx [H2D_NUM_MODES] |
A maximum index of a shape function. The first index is a mode (ElementMode2D). | |
int | next_order_shape [H2D_NUM_MODES][H2DRS_MAX_ORDER+1] |
An index to the array OptimumSelector::shape_indices of a shape function of the next uniform order. The first index is a mode (ElementMode2D), the second index is an order. | |
bool | has_vertex_shape [H2D_NUM_MODES] |
True if the shapeset OptimumSelector::shapeset contains vertex functions. The index is a mode (ElementMode2D). | |
bool | has_edge_shape [H2D_NUM_MODES] |
True if the shapeset OptimumSelector::shapeset contains edge functions. The index is a mode (ElementMode2D). | |
bool | has_bubble_shape [H2D_NUM_MODES] |
True if the shapeset OptimumSelector::shapeset contains bubble functions. The index is a mode (ElementMode2D). | |
double | dof_score_exponent |
Score DOF exponent. Used in evaluate_cands_score. | |
Protected Attributes inherited from Hermes::Hermes2D::RefinementSelectors::Selector< Scalar > | |
const int | min_order |
A minimum allowed order. | |
const int | max_order |
A maximum allowed order. | |
Static Protected Attributes | |
static const int | H2DRS_VALCACHE_INVALID = 0 |
State of value cache: item contains undefined or invalid value. | |
static const int | H2DRS_VALCACHE_VALID = 1 |
State of value cache: item contains a valid value. | |
static const int | H2DRS_VALCACHE_USER = 2 |
State of value cache: the first state ID which can be used by the user. | |
Additional Inherited Members | |
Static Protected Member Functions inherited from Hermes::Hermes2D::RefinementSelectors::OptimumSelector< Scalar > | |
static bool | compare_cand_score (const Cand &a, const Cand &b) |
Compares scores. Used to sort scores ascending. More... | |
A general projection-based selector.
Calculates an error of a candidate as a combination of errors of elements of a candidate. Each element of a candidate is calculated separatelly.
In order to implement a support for a new space or a new approach to calculation of squared error, implement following methods:
Definition at line 33 of file function.h.
|
protected |
A projection matrix cache type.
Defines a cache of projection matrices for all possible permutations of orders.
Definition at line 233 of file proj_based_selector.h.
|
protected |
Constructor.
Intializes attributes, projection matrix cache (ProjBasedSelector::proj_matrix_cache), and allocates rhs cache (ProjBasedSelector::rhs_cache).
[in] | cand_list | A predefined list of candidates. |
[in] | max_order | A maximum order which considered. If H2DRS_DEFAULT_ORDER, a maximum order supported by the selector is used. |
[in] | shapeset | A shapeset. It cannot be nullptr. |
[in] | vertex_order | A range of orders for vertex functions. Use an empty range (i.e. Range()) to skip vertex functions. |
[in] | edge_bubble_order | A range of orders for edge and bubble functions. Use an empty range (i.e. Range()) to skip edge and bubble functions. |
Definition at line 31 of file proj_based_selector.cpp.
|
protectedpure virtual |
Builds projection matrix using a given set of shapes.
Override to calculate a projection matrix.
[in] | gip_points | Integration points. The first index is an index of an integration point, the second index is defined through the enum GIP2DIndices. |
[in] | num_gip_points | A number of integration points. |
[in] | shape_inx | An array of shape indices. |
[in] | num_shapes | A number of shape indices in the array. |
Implemented in Hermes::Hermes2D::RefinementSelectors::HcurlProjBasedSelector< Scalar >, Hermes::Hermes2D::RefinementSelectors::H1ProjBasedSelector< Scalar >, and Hermes::Hermes2D::RefinementSelectors::L2ProjBasedSelector< Scalar >.
Referenced by Hermes::Hermes2D::RefinementSelectors::ProjBasedSelector< Scalar >::calc_error_cand_element().
|
protected |
Calculate projection errors of an element of an candidate considering multiple orders.
An element of a candidate may span over multiple sub-domains. All integration uses the reference domain.
Modify this method in order to add ortho-adaptivity.
[in] | mode | A mode (enum ElementMode2D). |
[in] | gip_points | Integration points in the reference domain. |
[in] | num_gip_points | A number of integration points. |
[in] | num_sub | A number of subdomains. |
[in] | sub_domains | Subdomains (elements of a reference mesh) that occupy the element of a candidate. The first index is an index of the subdomain. |
[in] | sub_trfs | Transformation from a reference domain of a subdomain to a reference domain of the element of a candidate. The first index is an index of the subdomain. |
[in] | sub_rvals | Values at integration points for every subdomain. Contents of this array (the second index) is defined by the method precalc_ref_solution(). The first index is an index of the subdomain. |
[in] | sub_nonortho_svals | |
[in] | sub_ortho_svals | |
[in] | info | Information about candidates: range of orders, etc. |
[out] | errors_squared | Calculated squared errors for all orders specified through info. |
Definition at line 431 of file proj_based_selector.cpp.
Referenced by Hermes::Hermes2D::RefinementSelectors::ProjBasedSelector< Scalar >::calc_projection_errors().
|
protectedvirtual |
Calculates projection errors of an elements of candidates for all permutations of orders.
Errors are not normalized and they are squared. The range of orders is defined through parameters info_h, info_h, and info_aniso.
If defining a new evalution (e.g. using a difference space) of errors, follows instructions in Expanding.
[in] | e | An element that is being examined by the selector. |
[in] | info_h | Information about H-candidates: range of orders, etc. |
[in] | info_p | Information about P-candidates: range of orders, etc. |
[in] | info_aniso | Information about ANISO-candidates: range of orders, etc. |
[in] | rsln | A reference solution. |
[out] | herr | An error of elements of H-candidates of various permutation of orders. |
[out] | perr | An error of elements of P-candidates of various permutation of orders. |
[out] | anisoerr | An error of elements of ANISO-candidates of various permutation of orders. |
Definition at line 235 of file proj_based_selector.cpp.
Referenced by Hermes::Hermes2D::RefinementSelectors::ProjBasedSelector< Scalar >::evaluate_cands_error().
|
protectedvirtual |
Calculates error of candidates.
Overriden function. For details, see OptimumSelector::evaluate_cands_error().
Implements Hermes::Hermes2D::RefinementSelectors::OptimumSelector< Scalar >.
Definition at line 130 of file proj_based_selector.cpp.
|
protectedpure virtual |
Evaluates an squared error of a projection of an element of a candidate onto subdomains.
Override to calculate an error using a provided projection and subdomains.
[in] | sub_elem | An element of a reference mesh that corresponds to a subdomain. |
[in] | sub_gip | Integration points. Locations of integration points are defined in the reference domain. Use sub_trf to transform it to the reference domain of an element of a candidate. |
[in] | sub_trf | A transformation from a reference domain of a subdomain to the reference domain of an element of a candidate. |
[in] | elem_proj | A projection of an element of a candidate on subdomains. |
Referenced by Hermes::Hermes2D::RefinementSelectors::ProjBasedSelector< Scalar >::calc_error_cand_element().
|
protectedpure virtual |
Evaluates a value of the right-hande side in a subdomain.
Override to calculate a value of the right-hand side.
[in] | sub_elem | An element of a reference mesh that corresponds to a subdomain. |
[in] | sub_gip | Integration points. Locations of integration points are defined in the reference domain. Use sub_trf to transform it to the reference domain of an element of a candidate. |
[in] | sub_trf | A transformation from a reference domain of a subdomain to the reference domain of an element of a candidate. |
[in] | sub_shape | Information about a shape function: shape index and calculated expansions at integration points, if any. |
Referenced by Hermes::Hermes2D::RefinementSelectors::ProjBasedSelector< Scalar >::calc_error_cand_element().
|
inlineprotectedvirtual |
Calculates values of orthogonalized shape function at GIP for all transformations.
Override this method to supply a pre-calculated vales of orthonormalized shape function expansions at integration points. If override, the method has to supply precalculate expansions for all transformations plus an identity transformation. An index of the identity transformation is ::H2D_TRF_IDENTITY.
If overridden and if this method orthonormalizes shape functions at the integration points, it is suggested to use the method precalc_shapes() in order to obtain initial values of shape functions at integration points.
[in] | gip_points | Integration points. The first index is an index of an integration point, the second index is an element of the enum GIP2DIndices. |
[in] | num_gip_points | A number of integration points. |
[in] | trfs | A transformations. The array has ::H2D_TRF_NUM elements. The index of the identity transformation is ::H2D_TRF_IDENTITY. |
[in] | num_noni_trfs | A number of transformations which are not identity. This number might be lower than than ::H2D_TRF_NUM. |
[in] | shapes | Shape functions. |
[in] | max_shape_inx | A maximum index of a shape function. This is used to resize a sub-array of the array svals. |
[out] | svals | A precalculated values of shape functions. The user has to resize the array of shape functions for every used transformation including the identity to the a size defined by max_shape_inx. The system will assume that shape functions are precalculated if the array corresponding to the identity function is not empty. |
Definition at line 172 of file proj_based_selector.h.
Referenced by Hermes::Hermes2D::RefinementSelectors::ProjBasedSelector< Scalar >::calc_projection_errors().
|
protectedpure virtual |
Returns an array of values of the reference solution at integration points.
The method have to set an active element and an quadrature on its own.
Override to provide all necessary values. Provided pointers should stay valid through an execution of the method calc_projection_errors(). Since an explicit deallocation of these pointers is not done, it is suggested to provide pointers to attributes of the class rather than to dynamically allocate an array. The method can assume that the an element is refined into H2D_MAX_ELEMENT_SONS elements (sons) in the reference mesh.
[in] | inx_son | An index of a son of an element, i.e., an index of a subdomain. The index is in a range[0, H2D_MAX_ELEMENT_SONS - 1]. |
[in] | rsln | A reference solution. |
[in] | element | An element of the coarse solution. An element of both the same geometry and the same ID have to be present in the mesh of the reference solution. |
[in] | intr_gip_order | An order of quadrature integration. The number of quadrature points should be retrieved through a quadrature stored in the paremeter rsln. |
Implemented in Hermes::Hermes2D::RefinementSelectors::HcurlProjBasedSelector< Scalar >, Hermes::Hermes2D::RefinementSelectors::H1ProjBasedSelector< Scalar >, and Hermes::Hermes2D::RefinementSelectors::L2ProjBasedSelector< Scalar >.
Referenced by Hermes::Hermes2D::RefinementSelectors::ProjBasedSelector< Scalar >::calc_projection_errors().
|
inlineprotectedvirtual |
Calculates values of shape function at GIP for all transformations.
Override this method to supply a pre-calculated vales of shape function expansions at integration points. If override, the method has to supply precalculate expansions for all transformations plus an identity transformation. An index of the identity transformation is ::H2D_TRF_IDENTITY.
[in] | gip_points | Integration points. The first index is an index of an integration point, the second index is an element of the enum GIP2DIndices. |
[in] | num_gip_points | A number of integration points. |
[in] | trfs | A transformations. The array has ::H2D_TRF_NUM elements. The index of the identity transformation is ::H2D_TRF_IDENTITY. |
[in] | num_noni_trfs | A number of transformations which are not identity. This number might be lower than than ::H2D_TRF_NUM. |
[in] | shapes | Shape functions. |
[in] | max_shape_inx | A maximum index of a shape function. This is used to resize a sub-array of the array svals. |
[out] | svals | A precalculated values of shape functions. The user has to resize the array of shape functions for every used transformation including the identity to the a size defined by max_shape_inx. The system will assume that shape functions are precalculated if the array corresponding to the identity function is not empty. |
Definition at line 152 of file proj_based_selector.h.
Referenced by Hermes::Hermes2D::RefinementSelectors::ProjBasedSelector< Scalar >::calc_projection_errors().
void Hermes::Hermes2D::RefinementSelectors::ProjBasedSelector< Scalar >::set_error_weights | ( | double | weight_h = H2DRS_DEFAULT_ERR_WEIGHT_H , |
double | weight_p = H2DRS_DEFAULT_ERR_WEIGHT_P , |
||
double | weight_aniso = H2DRS_DEFAULT_ERR_WEIGHT_ANISO |
||
) |
Sets error weights.
An error weight is a multiplicative coefficient that modifies an error of candidate. Error weights can be used to proritize refinements. Error weights are applied in the method evaluate_cands_error().
[in] | weight_h | An error weight of H-candidate. The default value is H2DRS_DEFAULT_ERR_WEIGHT_H. |
[in] | weight_p | An error weight of P-candidate. The default value is H2DRS_DEFAULT_ERR_WEIGHT_P. |
[in] | weight_aniso | An error weight of ANISO-candidate. The default value is H2DRS_DEFAULT_ERR_WEIGHT_ANISO. |
Definition at line 74 of file proj_based_selector.cpp.
|
protected |
An array of projection matrices.
The first index is the mode (see the enum ElementMode2D). The second and the third index is the horizontal and the vertical order respectively.
All matrices are square dense matrices and they have to be created through the function new_matrix(). If record is nullptr, the corresponding matrix has to be calculated.
Definition at line 241 of file proj_based_selector.h.
Referenced by Hermes::Hermes2D::RefinementSelectors::ProjBasedSelector< Scalar >::calc_error_cand_element(), and Hermes::Hermes2D::RefinementSelectors::ProjBasedSelector< Scalar >::ProjBasedSelector().
|
protected |
True if the selector has already warned about possible inefficiency.
If OptimumSelector::cand_list does not generate candidates with elements of non-uniform orders and if the precalculate orthonormal base is available, the user should not use non-uniform order in the meshed in order to gain efficiency.
Definition at line 190 of file proj_based_selector.h.
Referenced by Hermes::Hermes2D::RefinementSelectors::ProjBasedSelector< Scalar >::calc_projection_errors().