63 Assert(values.size() == this->n() || values.empty(),
65 Assert(grads.size() == this->n() || grads.empty(),
67 Assert(grad_grads.size() == this->n() || grad_grads.empty(),
69 Assert(third_derivatives.size() == this->n() || third_derivatives.empty(),
71 Assert(fourth_derivatives.size() == this->n() || fourth_derivatives.empty(),
75 (void)third_derivatives;
77 (void)fourth_derivatives;
80 const unsigned int n_sub = polynomial_space.n();
85 std::lock_guard<std::mutex> lock(mutex);
87 p_values.resize((values.empty()) ? 0 : n_sub);
88 p_grads.resize((grads.empty()) ? 0 : n_sub);
89 p_grad_grads.resize((grad_grads.empty()) ? 0 : n_sub);
93 polynomial_space.evaluate(unit_point,
98 p_fourth_derivatives);
101 for (
unsigned int i = 0; i < p_values.size(); ++i)
102 for (
unsigned int j = 0; j < dim; ++j)
103 values[i + j * n_sub][j] = p_values[i];
106 for (
unsigned int i = 0; i < p_grads.size(); ++i)
107 for (
unsigned int j = 0; j < dim; ++j)
108 grads[i + j * n_sub][j] = p_grads[i];
110 std::fill(grad_grads.begin(), grad_grads.end(),
Tensor<3, dim>());
111 for (
unsigned int i = 0; i < p_grad_grads.size(); ++i)
112 for (
unsigned int j = 0; j < dim; ++j)
113 grad_grads[i + j * n_sub][j] = p_grad_grads[i];
117 unsigned int start = dim * n_sub;
120 std::vector<std::vector<double>> monovali(dim, std::vector<double>(4));
121 std::vector<std::vector<double>> monovalk(dim, std::vector<double>(4));
129 "available for dim == 2, or dim == 3"));
133 for (
unsigned int d = 0; d < dim; ++d)
134 monomials[0].value(unit_point[d], monovali[d]);
135 if (values.size() != 0)
137 values[start][0] = monovali[0][0];
138 values[start][1] = -unit_point[1] * monovali[0][1];
139 values[start + 1][0] = unit_point[0] * monovali[1][1];
140 values[start + 1][1] = -monovali[1][0];
142 if (grads.size() != 0)
144 grads[start][0][0] = monovali[0][1];
145 grads[start][0][1] = 0.;
146 grads[start][1][0] = -unit_point[1] * monovali[0][2];
147 grads[start][1][1] = -monovali[0][1];
148 grads[start + 1][0][0] = monovali[1][1];
149 grads[start + 1][0][1] = unit_point[0] * monovali[1][2];
150 grads[start + 1][1][0] = 0.;
151 grads[start + 1][1][1] = -monovali[1][1];
153 if (grad_grads.size() != 0)
155 grad_grads[start][0][0][0] = monovali[0][2];
156 grad_grads[start][0][0][1] = 0.;
157 grad_grads[start][0][1][0] = 0.;
158 grad_grads[start][0][1][1] = 0.;
159 grad_grads[start][1][0][0] = -unit_point[1] * monovali[0][3];
160 grad_grads[start][1][0][1] = -monovali[0][2];
161 grad_grads[start][1][1][0] = -monovali[0][2];
162 grad_grads[start][1][1][1] = 0.;
163 grad_grads[start + 1][0][0][0] = 0;
164 grad_grads[start + 1][0][0][1] = monovali[1][2];
165 grad_grads[start + 1][0][1][0] = monovali[1][2];
166 grad_grads[start + 1][0][1][1] = unit_point[0] * monovali[1][3];
167 grad_grads[start + 1][1][0][0] = 0.;
168 grad_grads[start + 1][1][0][1] = 0.;
169 grad_grads[start + 1][1][1][0] = 0.;
170 grad_grads[start + 1][1][1][1] = -monovali[1][2];
180 const unsigned int n_curls = monomials.size() - 1;
181 for (
unsigned int i = 0; i < n_curls; ++i, start += dim)
183 for (
unsigned int d = 0; d < dim; ++d)
186 monomials[i + 1].value(unit_point[d], monovali[d]);
188 monomials[this->degree() - 1 - i].value(unit_point[d],
192 if (values.size() != 0)
196 unit_point[0] * monovali[1][1] * monovalk[2][0];
198 values[start][1] = -monovali[1][0] * monovalk[2][0];
199 values[start][2] = 0.;
202 values[start + 1][1] =
203 unit_point[1] * monovali[2][1] * monovalk[0][0];
205 values[start + 1][2] = -monovali[2][0] * monovalk[0][0];
206 values[start + 1][0] = 0.;
209 values[start + 2][2] =
210 unit_point[2] * monovali[0][1] * monovalk[1][0];
212 values[start + 2][0] = -monovali[0][0] * monovalk[1][0];
213 values[start + 2][1] = 0.;
216 if (grads.size() != 0)
218 grads[start][0][0] = monovali[1][1] * monovalk[2][0];
220 unit_point[0] * monovali[1][2] * monovalk[2][0];
222 unit_point[0] * monovali[1][1] * monovalk[2][1];
223 grads[start][1][0] = 0.;
224 grads[start][1][1] = -monovali[1][1] * monovalk[2][0];
225 grads[start][1][2] = -monovali[1][0] * monovalk[2][1];
226 grads[start][2][0] = 0.;
227 grads[start][2][1] = 0.;
228 grads[start][2][2] = 0.;
230 grads[start + 1][1][1] = monovali[2][1] * monovalk[0][0];
231 grads[start + 1][1][2] =
232 unit_point[1] * monovali[2][2] * monovalk[0][0];
233 grads[start + 1][1][0] =
234 unit_point[1] * monovali[2][1] * monovalk[0][1];
235 grads[start + 1][2][1] = 0.;
236 grads[start + 1][2][2] = -monovali[2][1] * monovalk[0][0];
237 grads[start + 1][2][0] = -monovali[2][0] * monovalk[0][1];
238 grads[start + 1][0][1] = 0.;
239 grads[start + 1][0][2] = 0.;
240 grads[start + 1][0][0] = 0.;
242 grads[start + 2][2][2] = monovali[0][1] * monovalk[1][0];
243 grads[start + 2][2][0] =
244 unit_point[2] * monovali[0][2] * monovalk[1][0];
245 grads[start + 2][2][1] =
246 unit_point[2] * monovali[0][1] * monovalk[1][1];
247 grads[start + 2][0][2] = 0.;
248 grads[start + 2][0][0] = -monovali[0][1] * monovalk[1][0];
249 grads[start + 2][0][1] = -monovali[0][0] * monovalk[1][1];
250 grads[start + 2][1][2] = 0.;
251 grads[start + 2][1][0] = 0.;
252 grads[start + 2][1][1] = 0.;
255 if (grad_grads.size() != 0)
257 grad_grads[start][0][0][0] = 0.;
258 grad_grads[start][0][0][1] = monovali[1][2] * monovalk[2][0];
259 grad_grads[start][0][0][2] = monovali[1][1] * monovalk[2][1];
260 grad_grads[start][0][1][0] = monovali[1][2] * monovalk[2][0];
261 grad_grads[start][0][1][1] =
262 unit_point[0] * monovali[1][3] * monovalk[2][0];
263 grad_grads[start][0][1][2] =
264 unit_point[0] * monovali[1][2] * monovalk[2][1];
265 grad_grads[start][0][2][0] = monovali[1][1] * monovalk[2][1];
266 grad_grads[start][0][2][1] =
267 unit_point[0] * monovali[1][2] * monovalk[2][1];
268 grad_grads[start][0][2][2] =
269 unit_point[0] * monovali[1][1] * monovalk[2][2];
270 grad_grads[start][1][0][0] = 0.;
271 grad_grads[start][1][0][1] = 0.;
272 grad_grads[start][1][0][2] = 0.;
273 grad_grads[start][1][1][0] = 0.;
274 grad_grads[start][1][1][1] = -monovali[1][2] * monovalk[2][0];
275 grad_grads[start][1][1][2] = -monovali[1][1] * monovalk[2][1];
276 grad_grads[start][1][2][0] = 0.;
277 grad_grads[start][1][2][1] = -monovali[1][1] * monovalk[2][1];
278 grad_grads[start][1][2][2] = -monovali[1][0] * monovalk[2][2];
279 grad_grads[start][2][0][0] = 0.;
280 grad_grads[start][2][0][1] = 0.;
281 grad_grads[start][2][0][2] = 0.;
282 grad_grads[start][2][1][0] = 0.;
283 grad_grads[start][2][1][1] = 0.;
284 grad_grads[start][2][1][2] = 0.;
285 grad_grads[start][2][2][0] = 0.;
286 grad_grads[start][2][2][1] = 0.;
287 grad_grads[start][2][2][2] = 0.;
289 grad_grads[start + 1][0][0][0] = 0.;
290 grad_grads[start + 1][0][0][1] = 0.;
291 grad_grads[start + 1][0][0][2] = 0.;
292 grad_grads[start + 1][0][1][0] = 0.;
293 grad_grads[start + 1][0][1][1] = 0.;
294 grad_grads[start + 1][0][1][2] = 0.;
295 grad_grads[start + 1][0][2][0] = 0.;
296 grad_grads[start + 1][0][2][1] = 0.;
297 grad_grads[start + 1][0][2][2] = 0.;
298 grad_grads[start + 1][1][0][0] =
299 unit_point[1] * monovali[2][1] * monovalk[0][2];
300 grad_grads[start + 1][1][0][1] = monovali[2][1] * monovalk[0][1];
301 grad_grads[start + 1][1][0][2] =
302 unit_point[1] * monovali[2][2] * monovalk[0][1];
303 grad_grads[start + 1][1][1][0] = monovalk[0][1] * monovali[2][1];
304 grad_grads[start + 1][1][1][1] = 0.;
305 grad_grads[start + 1][1][1][2] = monovalk[0][0] * monovali[2][2];
306 grad_grads[start + 1][1][2][0] =
307 unit_point[1] * monovalk[0][1] * monovali[2][2];
308 grad_grads[start + 1][1][2][1] = monovalk[0][0] * monovali[2][2];
309 grad_grads[start + 1][1][2][2] =
310 unit_point[1] * monovalk[0][0] * monovali[2][3];
311 grad_grads[start + 1][2][0][0] = -monovalk[0][2] * monovali[2][0];
312 grad_grads[start + 1][2][0][1] = 0.;
313 grad_grads[start + 1][2][0][2] = -monovalk[0][1] * monovali[2][1];
314 grad_grads[start + 1][2][1][0] = 0.;
315 grad_grads[start + 1][2][1][1] = 0.;
316 grad_grads[start + 1][2][1][2] = 0.;
317 grad_grads[start + 1][2][2][0] = -monovalk[0][1] * monovali[2][1];
318 grad_grads[start + 1][2][2][1] = 0.;
319 grad_grads[start + 1][2][2][2] = -monovalk[0][0] * monovali[2][2];
321 grad_grads[start + 2][0][0][0] = -monovali[0][2] * monovalk[1][0];
322 grad_grads[start + 2][0][0][1] = -monovali[0][1] * monovalk[1][1];
323 grad_grads[start + 2][0][0][2] = 0.;
324 grad_grads[start + 2][0][1][0] = -monovali[0][1] * monovalk[1][1];
325 grad_grads[start + 2][0][1][1] = -monovali[0][0] * monovalk[1][2];
326 grad_grads[start + 2][0][1][2] = 0.;
327 grad_grads[start + 2][0][2][0] = 0.;
328 grad_grads[start + 2][0][2][1] = 0.;
329 grad_grads[start + 2][0][2][2] = 0.;
330 grad_grads[start + 2][1][0][0] = 0.;
331 grad_grads[start + 2][1][0][1] = 0.;
332 grad_grads[start + 2][1][0][2] = 0.;
333 grad_grads[start + 2][1][1][0] = 0.;
334 grad_grads[start + 2][1][1][1] = 0.;
335 grad_grads[start + 2][1][1][2] = 0.;
336 grad_grads[start + 2][1][2][0] = 0.;
337 grad_grads[start + 2][1][2][1] = 0.;
338 grad_grads[start + 2][1][2][2] = 0.;
339 grad_grads[start + 2][2][0][0] =
340 unit_point[2] * monovali[0][3] * monovalk[1][0];
341 grad_grads[start + 2][2][0][1] =
342 unit_point[2] * monovali[0][2] * monovalk[1][1];
343 grad_grads[start + 2][2][0][2] = monovali[0][2] * monovalk[1][0];
344 grad_grads[start + 2][2][1][0] =
345 unit_point[2] * monovali[0][2] * monovalk[1][1];
346 grad_grads[start + 2][2][1][1] =
347 unit_point[2] * monovali[0][1] * monovalk[1][2];
348 grad_grads[start + 2][2][1][2] = monovali[0][1] * monovalk[1][1];
349 grad_grads[start + 2][2][2][0] = monovali[0][2] * monovalk[1][0];
350 grad_grads[start + 2][2][2][1] = monovali[0][1] * monovalk[1][1];
351 grad_grads[start + 2][2][2][2] = 0.;