22 template<
typename Scalar>
23 void Function<Scalar>::check_params(
int component,
typename Function<Scalar>::Node* cur_node,
int num_components)
25 if(component < 0 || component > num_components)
26 throw Hermes::Exceptions::Exception(
"Invalid component. You are probably using Scalar-valued shapeset for an Hcurl / Hdiv problem.");
28 throw Hermes::Exceptions::Exception(
"Invalid node. Did you call set_quad_order()?");
32 template<
typename Scalar>
33 void Function<Scalar>::check_table(
int component,
typename Function<Scalar>::Node* cur_node,
int n,
const char* msg)
35 if(cur_node->values[component][n] == NULL)
36 throw Hermes::Exceptions::Exception(
"%s not precalculated for component %d. Did you call set_quad_order() with correct mask?", msg, component);
39 template<
typename Scalar>
52 template<
typename Scalar>
57 template<
typename Scalar>
63 template<
typename Scalar>
69 template<
typename Scalar>
72 return num_components;
75 template<
typename Scalar>
78 if(nodes->present(order)) {
79 cur_node = nodes->get(order);
81 if((cur_node->mask & mask) != mask) {
82 precalculate(order, mask);
83 nodes->add(cur_node, order);
89 precalculate(order, mask);
90 nodes->add(cur_node, order);
94 template<
typename Scalar>
97 check_params(component, cur_node, num_components); check_table(component, cur_node, 0,
"Function values");
98 return cur_node->values[component][0];
101 template<
typename Scalar>
104 check_params(component, cur_node, num_components); check_table(component, cur_node, 1,
"DX values");
105 return cur_node->values[component][1];
108 template<
typename Scalar>
111 check_params(component, cur_node, num_components); check_table(component, cur_node, 2,
"DY values");
112 return cur_node->values[component][2];
115 template<
typename Scalar>
118 check_params(component, cur_node, num_components); check_table(component, cur_node, 1,
"DX values"); check_table(component, cur_node, 2,
"DY values");
119 dx = cur_node->values[component][1];
120 dy = cur_node->values[component][2];
123 template<
typename Scalar>
126 check_params(component, cur_node, num_components); check_table(component, cur_node, 3,
"DXX values");
127 return cur_node->values[component][3];
130 template<
typename Scalar>
133 check_params(component, cur_node, num_components); check_table(component, cur_node, 4,
"DYY values");
134 return cur_node->values[component][4];
137 template<
typename Scalar>
140 check_params(component, cur_node, num_components); check_table(component, cur_node, 5,
"DXY values");
141 return cur_node->values[component][5];
144 template<
typename Scalar>
147 return cur_node->values[a][b];
150 template<
typename Scalar>
156 for (i = 0; i < 4; i++)
157 if(quads[i] == quad_2d)
164 for (i = 0; i < 4; i++)
172 throw Hermes::Exceptions::Exception(
"too many quadratures.");
175 template<
typename Scalar>
178 return quads[cur_quad];
181 template<
typename Scalar>
184 { H2D_FN_VAL_0, H2D_FN_VAL_1 }, { H2D_FN_DX_0, H2D_FN_DX_1 }, { H2D_FN_DY_0, H2D_FN_DY_1 },
185 { H2D_FN_DXX_0, H2D_FN_DXX_1 }, { H2D_FN_DYY_0, H2D_FN_DYY_1 }, { H2D_FN_DXY_0, H2D_FN_DXY_1 }
188 template<
typename Scalar>
192 int nt = 0, m = mask;
193 if(num_components < 2) m &= H2D_FN_VAL_0 | H2D_FN_DX_0 | H2D_FN_DY_0 | H2D_FN_DXX_0 | H2D_FN_DYY_0 | H2D_FN_DXY_0;
194 while (m) { nt += m & 1; m >>= 1; }
197 int size = (
sizeof(
Node) -
sizeof(Scalar)) +
sizeof(Scalar) * num_points * nt;
202 Scalar* data = node->
data;
203 for (
int j = 0; j < num_components; j++) {
204 for (
int i = 0; i < 6; i++)
205 if(mask & idx2mask[i][j]) {
206 node->
values[j][i] = data;
212 if(max_mem < total_mem) max_mem = total_mem;
216 template<
typename Scalar>
219 if(sub_idx > H2D_MAX_IDX)
220 handle_overflow_idx();
222 if(sub_tables->find(sub_idx) == sub_tables->end())
223 sub_tables->insert(std::pair<uint64_t, LightArray<Node*>*>(sub_idx,
new LightArray<Node*>));
224 nodes = sub_tables->find(sub_idx)->second;
228 template<
typename Scalar>
231 this->sub_idx = sub_idx;
236 template<
typename Scalar>
239 if(node == NULL)
throw Exceptions::NullException(1);
240 if(cur_node != NULL) {
241 total_mem -= cur_node->size;
247 template class HERMES_API Function<double>;
248 template class HERMES_API Function<std::complex<double> >;