Hermes2D
3.0
|
A projection-based selector for L2 space. More...
#include <l2_proj_based_selector.h>
Public Member Functions | |
L2ProjBasedSelector (CandList cand_list=H2D_HP_ANISO, int max_order=H2DRS_DEFAULT_ORDER, L2Shapeset *user_shapeset=nullptr) | |
Constructor. More... | |
~L2ProjBasedSelector () | |
Destructor. | |
Public Member Functions inherited from Hermes::Hermes2D::RefinementSelectors::ProjBasedSelector< Scalar > | |
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. | |
Protected Types | |
enum | LocalFuncExpansion { H2D_L2FE_VALUE = 0, H2D_L2FE_NUM = 1 } |
A function expansion of a function f used by this selector. More... | |
Protected Types inherited from Hermes::Hermes2D::RefinementSelectors::ProjBasedSelector< Scalar > | |
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 | get_current_order_range (Element *element, int &min_order, int &max_order) |
Sets OptimumSelector::current_max_order and OptimumSelector::current_min_order. 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]) |
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]) |
Frees the data allocated in precalc_ref_solution. | |
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, typename ProjBasedSelector< Scalar >::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, typename ProjBasedSelector< Scalar >::TrfShape &svals, ElementMode2D mode) |
Calculates values of orthogonalized shape function at GIP for all transformations. More... | |
virtual double ** | build_projection_matrix (double3 *gip_points, int num_gip_points, const int *shape_inx, const int num_shapes, ElementMode2D mode) |
Builds projection matrix using a given set of shapes. More... | |
virtual Scalar | evaluate_rhs_subdomain (Element *sub_elem, const typename ProjBasedSelector< Scalar >::ElemGIP &sub_gip, int son, const typename ProjBasedSelector< Scalar >::ElemSubTrf &sub_trf, const typename ProjBasedSelector< Scalar >::ElemSubShapeFunc &sub_shape, Scalar *rval[H2D_MAX_ELEMENT_SONS][MAX_NUMBER_FUNCTION_VALUES_FOR_SELECTORS]) |
Evaluates a value of the right-hande side in a subdomain. More... | |
virtual double | evaluate_error_squared_subdomain (Element *sub_elem, const typename ProjBasedSelector< Scalar >::ElemGIP &sub_gip, int son, const typename ProjBasedSelector< Scalar >::ElemSubTrf &sub_trf, const typename ProjBasedSelector< Scalar >::ElemProj &elem_proj, Scalar *rval[H2D_MAX_ELEMENT_SONS][MAX_NUMBER_FUNCTION_VALUES_FOR_SELECTORS]) |
Evaluates an squared error of a projection of an element of a candidate onto subdomains. More... | |
Protected Member Functions inherited from Hermes::Hermes2D::RefinementSelectors::ProjBasedSelector< Scalar > | |
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 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... | |
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 | user_shapeset |
If the shapeset is not from the user, we shall delete it in the destructor. | |
Protected Attributes inherited from Hermes::Hermes2D::RefinementSelectors::ProjBasedSelector< Scalar > | |
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. | |
Additional Inherited Members | |
Public Types inherited from Hermes::Hermes2D::RefinementSelectors::ProjBasedSelector< Scalar > | |
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 Attributes inherited from Hermes::Hermes2D::RefinementSelectors::ProjBasedSelector< Scalar > | |
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. | |
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... | |
Static Protected Attributes inherited from Hermes::Hermes2D::RefinementSelectors::ProjBasedSelector< Scalar > | |
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. | |
A projection-based selector for L2 space.
This class is designed to be used with the class L2Adapt. Since an initialization of the class may take a long time, it is suggested to create the instance outside the adaptivity loop.
Definition at line 34 of file function.h.
Hermes::Hermes2D::RefinementSelectors::L2ProjBasedSelector< Scalar >::L2ProjBasedSelector | ( | CandList | cand_list = H2D_HP_ANISO , |
int | max_order = H2DRS_DEFAULT_ORDER , |
||
L2Shapeset * | user_shapeset = nullptr |
||
) |
Constructor.
[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, see HcurlProjBasedSelector::H2DRS_MAX_L2_ORDER. |
[in] | user_shapeset | A shapeset. If nullptr, it will use internal instance of the class L2Shapeset. |
Definition at line 11 of file l2_proj_based_selector.cpp.
|
protectedvirtual |
Builds projection matrix using a given set of shapes.
Overriden function. For details, see ProjBasedSelector::build_projection_matrix().
Implements Hermes::Hermes2D::RefinementSelectors::ProjBasedSelector< Scalar >.
Definition at line 197 of file l2_proj_based_selector.cpp.
|
protectedvirtual |
Evaluates an squared error of a projection of an element of a candidate onto subdomains.
Overriden function. For details, see ProjBasedSelector::evaluate_error_squared_subdomain().
Definition at line 255 of file l2_proj_based_selector.cpp.
|
protectedvirtual |
Evaluates a value of the right-hande side in a subdomain.
Overriden function. For details, see ProjBasedSelector::evaluate_rhs_subdomain().
Definition at line 231 of file l2_proj_based_selector.cpp.
|
protectedvirtual |
Sets OptimumSelector::current_max_order and OptimumSelector::current_min_order.
The default order range is[1, 8]. If curved, the upper boundary of the range becomes lower. Overriden function. For details, see OptimumSelector::set_current_order_range().
Replace calculations inside with calculations that uses symbolic constants instead of fixed numbers.
The original implementation uses subtracts 1 in H1 and Hcurl while L2 subtracts 2. Why?
Implements Hermes::Hermes2D::RefinementSelectors::OptimumSelector< Scalar >.
Definition at line 29 of file l2_proj_based_selector.cpp.
|
protectedvirtual |
Calculates values of orthogonalized shape function at GIP for all transformations.
Overriden function. For details, see ProjBasedSelector::precalc_ortho_shapes().
Definition at line 91 of file l2_proj_based_selector.cpp.
|
protectedvirtual |
Returns an array of values of the reference solution at integration points.
Overriden function. For details, see ProjBasedSelector::precalc_ref_solution().
Implements Hermes::Hermes2D::RefinementSelectors::ProjBasedSelector< Scalar >.
Definition at line 183 of file l2_proj_based_selector.cpp.
|
protectedvirtual |
Calculates values of shape function at GIP for all transformations.
Overriden function. For details, see ProjBasedSelector::precalc_shapes().
Definition at line 40 of file l2_proj_based_selector.cpp.