Hermes2D  2.0
global.h
Go to the documentation of this file.
1 // This file is part of Hermes2D
2 //
3 // Copyright (c) 2009 hp-FEM group at the University of Nevada, Reno (UNR).
4 // Email: hpfem-group@unr.edu, home page: http://hpfem.org/.
5 //
6 // Hermes2D is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published
8 // by the Free Software Foundation; either version 2 of the License,
9 // or (at your option) any later version.
10 //
11 // Hermes2D is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with Hermes2D; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 #ifndef __H2D_COMMON_H_
24 #define __H2D_COMMON_H_
25 
26 #include "hermes_common.h"
27 #include "config.h"
28 
30 #define H2D_MAX_ELEMENT_SONS 4
31 #define H2D_MAX_NUMBER_EDGES 4
32 #define H2D_MAX_NUMBER_VERTICES 4
33 
34 
35 #define H2D_NUM_MODES 2
36 #define H2D_SOLUTION_ELEMENT_CACHE_SIZE 2
37 #define H2D_MAX_NODE_ID 10000000
38 #define H2D_MAX_SOLUTION_COMPONENTS 2
39 
40 #define HERMES_ONE NULL
41 #define HERMES_DEFAULT_FUNCTION NULL
42 #define HERMES_DEFAULT_SPLINE NULL
43 
45 #define HERMES_TOTAL_ERROR_REL 0x00
46 
47 
48 #define HERMES_TOTAL_ERROR_ABS 0x01
49 
50 
51 #define HERMES_ELEMENT_ERROR_REL 0x00
52 
53 
54 
55 
56 #define HERMES_ELEMENT_ERROR_ABS 0x10
57 
58 
59 
60 
61  static const int H2D_TRF_TRI_NUM = 4;
63  static const int H2D_TRF_QUAD_NUM = 8;
65  static const int H2D_TRF_NUM = (H2D_TRF_QUAD_NUM + 1);
67  static const int H2D_TRF_IDENTITY = H2D_TRF_QUAD_NUM;
68 
69 #define H2DRS_ASSUMED_MAX_CANDS 512
70 
71 //TODO: find out why 20 used used, should'n be there 2*(H2DRS_MAX_ORDER+1)
72 #define H2DRS_INTR_GIP_ORDER 20
73 #define H2DRS_MAX_ORDER_INC 1
74 
75 #define H2DRS_SCORE_DIFF_ZERO 1E-13
76 
77 #define H2DRS_ORDER_ANY -1
78 
79 # define H2DRS_DEFAULT_ERR_WEIGHT_H 2.0
80 # define H2DRS_DEFAULT_ERR_WEIGHT_P 1.0
81 # define H2DRS_DEFAULT_ERR_WEIGHT_ANISO 1.414214
82 
83 namespace Hermes
84 {
86  namespace Hermes2D
87  {
88  class RefMap;
89  template<typename Scalar> class DiscreteProblem;
90  template<typename Scalar> class Space;
91  template<typename Scalar> class WeakForm;
92  template<typename Scalar> class MeshFunction;
93  template<typename Scalar> class Solution;
94  class Quad2D;
95  class Quad1DStd;
96  class Quad2DStd;
97 
99  const int H2D_ORDER_BITS = 5;
100  const int H2D_ORDER_MASK = (1 << H2D_ORDER_BITS) - 1;
101 
103  #define H2D_GET_H_ORDER(encoded_order) ((encoded_order) & H2D_ORDER_MASK)
104  #define H2D_GET_V_ORDER(encoded_order) ((encoded_order) >> H2D_ORDER_BITS)
105  #define H2D_MAKE_QUAD_ORDER(h_encoded_order, v_encoded_order) (((v_encoded_order) << H2D_ORDER_BITS) + (h_encoded_order))
106  #define H2D_MAKE_EDGE_ORDER(mode, edge, order) ((mode == HERMES_MODE_TRIANGLE || edge == 0 || edge == 2) ? H2D_GET_H_ORDER(order) : H2D_GET_V_ORDER(order))
107 
109  template<typename Scalar>
110  class HERMES_API Global : public Hermes::Mixins::Loggable
111  {
112  public:
113  Global() : Hermes::Mixins::Loggable() {};
114  friend void warn_order();
115  public:
117  // Note: coarse mesh sln has to be first, then
118  // ref_sln (because the abs. error is divided
119  // by the norm of the latter).
120  static double calc_rel_error(MeshFunction<Scalar>* sln1, MeshFunction<Scalar>* sln2, int norm_type);
121 
122  static double calc_abs_error(MeshFunction<Scalar>* sln1, MeshFunction<Scalar>* sln2, int norm_type);
123 
124  static double calc_norm(MeshFunction<Scalar>* sln, int norm_type);
125 
128  static double calc_norms(Hermes::vector<Solution<Scalar>*> slns);
129  static double calc_abs_errors(Hermes::vector<Solution<Scalar>*> slns1, Hermes::vector<Solution<Scalar>*> slns2);
130  static double calc_rel_errors(Hermes::vector<Solution<Scalar>*> slns1, Hermes::vector<Solution<Scalar>*> slns2);
131 
132  static double error_fn_l2(MeshFunction<Scalar>* sln1, MeshFunction<Scalar>* sln2, RefMap* ru, RefMap* rv);
133  static double norm_fn_l2(MeshFunction<Scalar>* sln, RefMap* ru);
134 
135  static double error_fn_h1(MeshFunction<Scalar>* sln1, MeshFunction<Scalar>* sln2, RefMap* ru, RefMap* rv);
136  static double norm_fn_h1(MeshFunction<Scalar>* sln, RefMap* ru);
137 
138  static double error_fn_hc(MeshFunction<Scalar>* sln1, MeshFunction<Scalar>* sln2, RefMap* ru, RefMap* rv);
139  static double norm_fn_hc(MeshFunction<Scalar>* sln, RefMap* ru);
140 
141  static double error_fn_hcl2(MeshFunction<Scalar>* sln1, MeshFunction<Scalar>* sln2, RefMap* ru, RefMap* rv);
142  static double norm_fn_hcl2(MeshFunction<Scalar>* sln, RefMap* ru);
143 
144  static double error_fn_hdiv(MeshFunction<Scalar>* sln1, MeshFunction<Scalar>* sln2, RefMap* ru, RefMap* rv);
145  static double norm_fn_hdiv(MeshFunction<Scalar>* sln, RefMap* ru);
146 
147  static double get_l2_norm(Vector<Scalar>* vec);
148  };
149 
153  {
154  HERMES_L2_NORM,
155  HERMES_H1_NORM,
156  HERMES_H1_SEMINORM,
157  HERMES_HCURL_NORM,
158  HERMES_HDIV_NORM,
159  HERMES_UNSET_NORM
160  };
161 
162  enum ElementMode2D {
163  HERMES_MODE_TRIANGLE = 0,
164  HERMES_MODE_QUAD = 1
165  };
166  }
167 }
168 #endif