A general projection-based selector. More...
#include <proj_based_selector.h>
Inherits RefinementSelectors::OptimumSelector.
Inherited by RefinementSelectors::H1ProjBasedSelector, and RefinementSelectors::L2ProjBasedSelector.
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 |
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. | |
Protected 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. | |
| typedef double ** | ProjMatrixCache [H2DRS_MAX_ORDER+2][H2DRS_MAX_ORDER+2] |
| A projection matrix cache type. | |
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< ShapeInx > &shapes, const int max_shape_inx, TrfShape &svals) |
| Calculates values of shape function at GIP for all transformations. | |
| 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< ShapeInx > &shapes, const int max_shape_inx, TrfShape &ortho_svals) |
| Calculates values of orthogonalized shape function at GIP for all transformations. | |
| ProjBasedSelector (CandList cand_list, double conv_exp, int max_order, Shapeset *shapeset, const Range< int > &vertex_order, const Range< int > &edge_bubble_order) | |
| Constructor. | |
| virtual void | evaluate_cands_error (Element *e, Solution *rsln, double *avg_error, double *dev_error) |
| Calculates error of candidates. | |
| virtual void | calc_projection_errors (Element *e, const CandsInfo &info_h, const CandsInfo &info_p, const CandsInfo &info_aniso, Solution *rsln, CandElemProjError herr[4], CandElemProjError perr, CandElemProjError anisoerr[4]) |
| Calculates projection errors of an elements of candidates for all permitations of orders. | |
| void | calc_error_cand_element (const int mode, double3 *gip_points, int num_gip_points, const int num_sub, Element **sub_domains, Trf **sub_trfs, scalar ***sub_rvals, std::vector< TrfShapeExp > **sub_nonortho_svals, std::vector< TrfShapeExp > **sub_ortho_svals, const CandsInfo &info, CandElemProjError errors_squared) |
| Calculate projection errors of an element of an candidate considering multiple orders. | |
| virtual scalar ** | precalc_ref_solution (int inx_son, Solution *rsln, Element *element, int intr_gip_order)=0 |
| Returns an array of values of the reference solution at integration points. | |
| virtual double ** | build_projection_matrix (double3 *gip_points, int num_gip_points, const int *shape_inx, const int num_shapes)=0 |
| Builds projection matrix using a given set of shapes. | |
| virtual scalar | evaluate_rhs_subdomain (Element *sub_elem, const ElemGIP &sub_gip, const ElemSubTrf &sub_trf, const ElemSubShapeFunc &sub_shape)=0 |
| Evaluates a value of the right-hande side in a subdomain. | |
| virtual double | evaluate_error_squared_subdomain (Element *sub_elem, const ElemGIP &sub_gip, const ElemSubTrf &sub_trf, const ElemProj &elem_proj)=0 |
| Evaluates an squared error of a projection of an element of a candidate onto subdomains. | |
Protected Attributes | |
| bool | cached_shape_vals_valid [H2D_NUM_MODES] |
| True if shape values were already initialized. | |
| TrfShape | cached_shape_ortho_vals [H2D_NUM_MODES] |
| Precalculated valus of orthogonalized shape functions. | |
| TrfShape | cached_shape_vals [H2D_NUM_MODES] |
| Precalculate values of shape functions. | |
| bool | warn_uniform_orders |
| True if the selector has already warned about possible inefficiency. | |
| ProjMatrixCache | proj_matrix_cache [H2D_NUM_MODES] |
| An array of projection matrices. | |
| std::vector< ValueCacheItem < scalar > > | nonortho_rhs_cache |
| An array of cached right-hand side values. | |
| std::vector< ValueCacheItem < scalar > > | ortho_rhs_cache |
| 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. | |
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:
typedef double** RefinementSelectors::ProjBasedSelector::ProjMatrixCache[H2DRS_MAX_ORDER+2][H2DRS_MAX_ORDER+2] [protected] |
A projection matrix cache type.
Defines a cache of projection matrices for all possible permutations of orders.
typedef std::vector<TrfShapeExp> RefinementSelectors::ProjBasedSelector::TrfShape[H2D_TRF_NUM] [protected] |
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.
| RefinementSelectors::ProjBasedSelector::~ProjBasedSelector | ( | ) | [virtual] |
Destructor.
| RefinementSelectors::ProjBasedSelector::ProjBasedSelector | ( | CandList | cand_list, | |
| double | conv_exp, | |||
| int | max_order, | |||
| Shapeset * | shapeset, | |||
| const Range< int > & | vertex_order, | |||
| const Range< int > & | edge_bubble_order | |||
| ) | [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] | conv_exp | A conversion exponent, see evaluate_cands_score(). |
| [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 NULL. |
| [in] | vertex_order | A range of orders for vertex functions. Use an empty range (i.e. Range<int>()) to skip vertex functions. |
| [in] | edge_bubble_order | A range of orders for edge and bubble functions. Use an empty range (i.e. Range<int>()) to skip edge and bubble functions. |
| virtual double** RefinementSelectors::ProjBasedSelector::build_projection_matrix | ( | double3 * | gip_points, | |
| int | num_gip_points, | |||
| const int * | shape_inx, | |||
| const int | num_shapes | |||
| ) | [protected, pure 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 RefinementSelectors::H1ProjBasedSelector, and RefinementSelectors::L2ProjBasedSelector.
| void RefinementSelectors::ProjBasedSelector::calc_error_cand_element | ( | const int | mode, | |
| double3 * | gip_points, | |||
| int | num_gip_points, | |||
| const int | num_sub, | |||
| Element ** | sub_domains, | |||
| Trf ** | sub_trfs, | |||
| scalar *** | sub_rvals, | |||
| std::vector< TrfShapeExp > ** | sub_nonortho_svals, | |||
| std::vector< TrfShapeExp > ** | sub_ortho_svals, | |||
| const CandsInfo & | info, | |||
| CandElemProjError | errors_squared | |||
| ) | [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 ElementMode). |
| [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. |
| void RefinementSelectors::ProjBasedSelector::calc_projection_errors | ( | Element * | e, | |
| const CandsInfo & | info_h, | |||
| const CandsInfo & | info_p, | |||
| const CandsInfo & | info_aniso, | |||
| Solution * | rsln, | |||
| CandElemProjError | herr[4], | |||
| CandElemProjError | perr, | |||
| CandElemProjError | anisoerr[4] | |||
| ) | [protected, virtual] |
Calculates projection errors of an elements of candidates for all permitations 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. |
| void RefinementSelectors::ProjBasedSelector::evaluate_cands_error | ( | Element * | e, | |
| Solution * | rsln, | |||
| double * | avg_error, | |||
| double * | dev_error | |||
| ) | [protected, virtual] |
Calculates error of candidates.
Overriden function. For details, see OptimumSelector::evaluate_cands_error().
Implements RefinementSelectors::OptimumSelector.
| virtual double RefinementSelectors::ProjBasedSelector::evaluate_error_squared_subdomain | ( | Element * | sub_elem, | |
| const ElemGIP & | sub_gip, | |||
| const ElemSubTrf & | sub_trf, | |||
| const ElemProj & | elem_proj | |||
| ) | [protected, pure 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. |
Implemented in RefinementSelectors::H1ProjBasedSelector, and RefinementSelectors::L2ProjBasedSelector.
| virtual scalar RefinementSelectors::ProjBasedSelector::evaluate_rhs_subdomain | ( | Element * | sub_elem, | |
| const ElemGIP & | sub_gip, | |||
| const ElemSubTrf & | sub_trf, | |||
| const ElemSubShapeFunc & | sub_shape | |||
| ) | [protected, pure 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. |
Implemented in RefinementSelectors::H1ProjBasedSelector, and RefinementSelectors::L2ProjBasedSelector.
| virtual void RefinementSelectors::ProjBasedSelector::precalc_ortho_shapes | ( | const double3 * | gip_points, | |
| const int | num_gip_points, | |||
| const Trf * | trfs, | |||
| const int | num_noni_trfs, | |||
| const std::vector< ShapeInx > & | shapes, | |||
| const int | max_shape_inx, | |||
| TrfShape & | ortho_svals | |||
| ) | [inline, protected, virtual] |
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 overriden 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. |
Reimplemented in RefinementSelectors::H1ProjBasedSelector, and RefinementSelectors::L2ProjBasedSelector.
| virtual scalar** RefinementSelectors::ProjBasedSelector::precalc_ref_solution | ( | int | inx_son, | |
| Solution * | rsln, | |||
| Element * | element, | |||
| int | intr_gip_order | |||
| ) | [protected, pure 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 RefinementSelectors::H1ProjBasedSelector, and RefinementSelectors::L2ProjBasedSelector.
| virtual void RefinementSelectors::ProjBasedSelector::precalc_shapes | ( | const double3 * | gip_points, | |
| const int | num_gip_points, | |||
| const Trf * | trfs, | |||
| const int | num_noni_trfs, | |||
| const std::vector< ShapeInx > & | shapes, | |||
| const int | max_shape_inx, | |||
| TrfShape & | svals | |||
| ) | [inline, protected, virtual] |
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. |
Reimplemented in RefinementSelectors::H1ProjBasedSelector, and RefinementSelectors::L2ProjBasedSelector.
| void RefinementSelectors::ProjBasedSelector::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. |
TrfShape RefinementSelectors::ProjBasedSelector::cached_shape_ortho_vals[H2D_NUM_MODES] [protected] |
Precalculated valus of orthogonalized shape functions.
TrfShape RefinementSelectors::ProjBasedSelector::cached_shape_vals[H2D_NUM_MODES] [protected] |
Precalculate values of shape functions.
bool RefinementSelectors::ProjBasedSelector::cached_shape_vals_valid[H2D_NUM_MODES] [protected] |
True if shape values were already initialized.
double RefinementSelectors::ProjBasedSelector::error_weight_aniso [protected] |
A coefficient that multiplies error of ANISO-candidate. The default value is H2DRS_DEFAULT_ERR_WEIGHT_ANISO.
double RefinementSelectors::ProjBasedSelector::error_weight_h [protected] |
A coefficient that multiplies error of H-candidate. The default value is H2DRS_DEFAULT_ERR_WEIGHT_H.
double RefinementSelectors::ProjBasedSelector::error_weight_p [protected] |
A coefficient that multiplies error of P-candidate. The default value is H2DRS_DEFAULT_ERR_WEIGHT_P.
std::vector< ValueCacheItem<scalar> > RefinementSelectors::ProjBasedSelector::nonortho_rhs_cache [protected] |
An array of cached right-hand side values.
The first index is an index of the shape function.
Contents of the array is valid in the method calc_error_cand_element(). The array is allocated in the constructor, the size of the array is equal to the maximum index of a shape function + 1.
std::vector< ValueCacheItem<scalar> > RefinementSelectors::ProjBasedSelector::ortho_rhs_cache [protected] |
ProjMatrixCache RefinementSelectors::ProjBasedSelector::proj_matrix_cache[H2D_NUM_MODES] [protected] |
An array of projection matrices.
The first index is the mode (see the enum ElementMode). 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 NULL, the corresponding matrix has to be calculated.
bool RefinementSelectors::ProjBasedSelector::warn_uniform_orders [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.
1.6.3