9#include <kernel/shape.hpp>
10#include <kernel/meshopt/base.hpp>
11#include <kernel/meshopt/rumpf_functional.hpp>
25 template<
typename DataType_>
26 class RumpfFunctionalUnrolled<DataType_,
27 Trafo::Standard::Mapping<Geometry::ConformalMesh<Shape::Simplex<2>, 2, DataType_>>> :
28 public RumpfFunctionalBase<DataType_>
32 typedef RumpfFunctionalBase<DataType_> BaseClass;
35 typedef DataType_ DataType;
37 typedef Shape::Simplex<2> ShapeType;
39 typedef Trafo::Standard::Mapping<Geometry::ConformalMesh<ShapeType, 2, DataType_>> TrafoType;
41 static constexpr int world_dim = TrafoType::world_dim;
43 static constexpr int shape_dim = ShapeType::dimension;
45 typedef typename Intern::TrafoFE<TrafoType>::Space TrafoSpace;
48 typedef Tiny::Matrix<DataType_, Shape::FaceTraits<ShapeType,0>::count, world_dim> Tx;
50 typedef Tiny::Vector<DataType_, Shape::FaceTraits<ShapeType,0>::count*world_dim> Tgradh;
53 typedef Tiny::Matrix<DataType_, shape_dim, world_dim> TgradR;
56 typedef typename TrafoType::template Evaluator<ShapeType, DataType>::Type TrafoEvaluator;
58 typedef typename TrafoSpace::template Evaluator<TrafoEvaluator>::Type SpaceEvaluator;
62 const int _exponent_det;
64 const bool _compute_frobenius;
66 const bool _compute_cof;
68 const bool _compute_det;
74 explicit RumpfFunctionalUnrolled(
75 const DataType fac_frobenius_,
76 const DataType fac_det_,
77 const DataType fac_cof_,
78 const DataType fac_reg_,
79 const int exponent_det_) :
80 BaseClass( fac_frobenius_,
82 fac_det_*(Math::
sqrt( Math::
sqr(fac_reg_) + DataType(1) )*Math::
pow( DataType(1) + Math::
sqrt(Math::
sqr(fac_reg_) + DataType(1)), DataType(exponent_det_))),
85 _exponent_det(exponent_det_),
86 _compute_frobenius( (fac_frobenius_ > DataType(0)) ),
87 _compute_cof( false ),
88 _compute_det( (fac_det_ > 0) )
90 XASSERTM(exponent_det_ == 1 || exponent_det_ == 2,
"exponent_det must be 1 or 2!");
91 XASSERTM(fac_cof_ == DataType(0),
"In 2d, the cofactor term is redundant, so set fac_cof == 0.");
101 return "RumpfFunctionalUnrolled<"+ShapeType::name()+
">";
109 const Index pad_width(30);
110 return name() +
":" + BaseClass::info() + String(
"\nexponent_det").pad_back(pad_width,
'.')
111 + String(
": ") +
stringify(_exponent_det);
117 void eval_fval_grad(DataType& fval, Tx& grad,
const TgradR& DOXY(mat_tensor),
const TrafoEvaluator& DOXY(trafo_eval),
const SpaceEvaluator& DOXY(space_eval),
const Tx& x,
const DataType& h)
121 grad.format(DataType(0));
123 DataType fval_frobenius(0);
124 DataType fval_det(0);
125 DataType fval_rec_det(0);
127 if(_compute_frobenius)
129 fval_frobenius = this->_fac_frobenius*compute_frobenius_part(x,h);
130 add_grad_frobenius_part(grad, x, h);
135 if(_exponent_det == 1)
137 fval_det = this->_fac_det*compute_det_1_part(x,h);
138 fval_rec_det = this->_fac_rec_det*compute_rec_det_1_part(x,h);
139 add_grad_det_1_part(grad, x, h);
140 add_grad_rec_det_1_part(grad, x, h);
144 fval_det = this->_fac_det*compute_det_2_part(x,h);
145 fval_rec_det = this->_fac_rec_det*compute_rec_det_2_part(x,h);
146 add_grad_det_2_part(grad, x, h);
147 add_grad_rec_det_2_part(grad, x, h);
151 fval = fval_frobenius + fval_det + fval_rec_det;
155 void eval_fval_cellwise(DataType& fval,
const TgradR& DOXY(mat_tensor),
const TrafoEvaluator& DOXY(trafo_eval),
const SpaceEvaluator& DOXY(space_eval),
const Tx& x,
const DataType& h, DataType& fval_frobenius, DataType& fval_cof, DataType& fval_det)
158 fval_frobenius = DataType(0);
159 fval_cof = DataType(0);
160 fval_det = DataType(0);
162 if(_compute_frobenius)
164 fval_frobenius = this->_fac_frobenius*compute_frobenius_part(x,h);
169 if(_exponent_det == 1)
171 fval_det = this->_fac_det*compute_det_1_part(x,h);
172 fval_det += this->_fac_rec_det*compute_rec_det_1_part(x,h);
176 fval_det = this->_fac_det*compute_det_2_part(x,h);
177 fval_det += this->_fac_rec_det*compute_rec_det_2_part(x,h);
181 fval = fval_frobenius + fval_det;
188 void NOINLINE add_grad_h_part(Tx& grad,
const TgradR& DOXY(mat_tensor),
const TrafoEvaluator& DOXY(trafo_eval),
const SpaceEvaluator& DOXY(space_eval),
const Tx& x,
const DataType& h,
const Tgradh& grad_h)
191 DataType frobenius_der_h(0);
192 DataType det_der_h(0);
193 DataType rec_det_der_h(0);
195 if(_compute_frobenius)
197 frobenius_der_h = this->_fac_frobenius*compute_frobenius_der_h_part(x,h);
202 if(_exponent_det == 1)
204 det_der_h = this->_fac_det * compute_det_1_der_h_part(x,h);
205 rec_det_der_h = this->_fac_rec_det * compute_rec_det_1_der_h_part(x,h);
209 det_der_h = this->_fac_det * compute_det_2_der_h_part(x,h);
210 rec_det_der_h = this->_fac_rec_det * compute_rec_det_2_der_h_part(x,h);
215 DataType der_h(frobenius_der_h + det_der_h + rec_det_der_h);
217 for(
int i(0); i < Tx::m; ++i)
219 for(
int d(0); d < Tx::n; ++d)
221 grad(i,d) += der_h*grad_h(i*Tx::n + d);
230 DataType NOINLINE compute_frobenius_part(
const Tx& x,
const DataType& h)
232 DataType fval_frobenius_part(0);
233 fval_frobenius_part = DataType(4)/DataType(9)*Math::pow(DataType(3)*h*h-DataType(2)*Math::sqr(x(0,0))+DataType(2)*x(0,0)*x(1,0)+DataType(2)*x(0,0)*x(2,0)-DataType(2)*Math::sqr(x(0,1))+DataType(2)*x(0,1)*x(1,1)+DataType(2)*x(0,1)*x(2,1)-DataType(2)*Math::sqr(x(1,0))+DataType(2)*x(1,0)*x(2,0)-DataType(2)*Math::sqr(x(1,1))+DataType(2)*x(1,1)*x(2,1)-DataType(2)*Math::sqr(x(2,0))-DataType(2)*Math::sqr(x(2,1)),DataType(2))/(h*h*h*h);
234 return fval_frobenius_part;
240 DataType NOINLINE compute_det_1_part(
const Tx& x,
const DataType& h)
242 DataType fval_det_1_part(0);
243 fval_det_1_part = DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/Math::sqr(h);
244 return fval_det_1_part;
249 DataType NOINLINE compute_det_2_part(
const Tx& x,
const DataType& h)
251 DataType fval_det_2_part(0);
252 fval_det_2_part = DataType(4)/DataType(3)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h);
253 return fval_det_2_part;
259 DataType NOINLINE compute_rec_det_1_part(
const Tx& x,
const DataType& h)
261 DataType fval_rec_det_1_part(0);
262 fval_rec_det_1_part = DataType(1)/(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/Math::sqr(h)+Math::sqrt(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h))/DataType(3));
263 return fval_rec_det_1_part;
269 DataType NOINLINE compute_rec_det_2_part(
const Tx& x,
const DataType& h)
271 DataType fval_rec_det_2_part(0);
272 fval_rec_det_2_part = Math::pow(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/Math::sqr(h)+Math::sqrt(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h))/DataType(3),-DataType(2));
273 return fval_rec_det_2_part;
278 DataType NOINLINE compute_frobenius_der_h_part(
const Tx& x,
const DataType& h)
280 DataType frobenius_der_h_part(0);
281 frobenius_der_h_part = DataType(16)/DataType(3)*(DataType(3)*h*h-DataType(2)*Math::sqr(x(0,0))+DataType(2)*x(0,0)*x(1,0)+DataType(2)*x(0,0)*x(2,0)-DataType(2)*Math::sqr(x(0,1))+DataType(2)*x(0,1)*x(1,1)+DataType(2)*x(0,1)*x(2,1)-DataType(2)*Math::sqr(x(1,0))+DataType(2)*x(1,0)*x(2,0)-DataType(2)*Math::sqr(x(1,1))+DataType(2)*x(1,1)*x(2,1)-DataType(2)*Math::sqr(x(2,0))-DataType(2)*Math::sqr(x(2,1)))/(h*h*h)-DataType(16)/DataType(9)*Math::pow(DataType(3)*h*h-DataType(2)*Math::sqr(x(0,0))+DataType(2)*x(0,0)*x(1,0)+DataType(2)*x(0,0)*x(2,0)-DataType(2)*Math::sqr(x(0,1))+DataType(2)*x(0,1)*x(1,1)+DataType(2)*x(0,1)*x(2,1)-DataType(2)*Math::sqr(x(1,0))+DataType(2)*x(1,0)*x(2,0)-DataType(2)*Math::sqr(x(1,1))+DataType(2)*x(1,1)*x(2,1)-DataType(2)*Math::sqr(x(2,0))-DataType(2)*Math::sqr(x(2,1)),DataType(2))/(h*h*h*h*h);
282 return frobenius_der_h_part;
288 DataType NOINLINE compute_det_1_der_h_part(
const Tx& x,
const DataType& h)
290 DataType det_1_der_h_part(0);
291 det_1_der_h_part = -DataType(4)/DataType(3)*Math::sqrt(DataType(3))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/(h*h*h);
292 return det_1_der_h_part;
297 DataType NOINLINE compute_det_2_der_h_part(
const Tx& x,
const DataType& h)
299 DataType det_2_der_h_part(0);
300 det_2_der_h_part = -DataType(16)/DataType(3)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h*h);
301 return det_2_der_h_part;
307 DataType NOINLINE compute_rec_det_1_der_h_part(
const Tx& x,
const DataType& h)
309 DataType rec_det_1_der_h_part(0);
310 rec_det_1_der_h_part = -Math::pow(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/Math::sqr(h)+Math::sqrt(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h))/DataType(3),-DataType(2))*(-DataType(4)/DataType(3)*Math::sqrt(DataType(3))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/(h*h*h)-DataType(8)*Math::pow(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h),-DataType(1)/DataType(2))*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h*h));
311 return rec_det_1_der_h_part;
317 DataType NOINLINE compute_rec_det_2_der_h_part(
const Tx& x,
const DataType& h)
319 DataType rec_det_2_der_h_part(0);
320 rec_det_2_der_h_part = -DataType(2)*Math::pow(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/Math::sqr(h)+Math::sqrt(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h))/DataType(3),-DataType(3))*(-DataType(4)/DataType(3)*Math::sqrt(DataType(3))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/(h*h*h)-DataType(8)*Math::pow(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h),-DataType(1)/DataType(2))*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h*h));
321 return rec_det_2_der_h_part;
327 void NOINLINE add_grad_frobenius_part(Tx& grad_frobenius_part,
const Tx& x,
const DataType& h)
329 grad_frobenius_part(0,0) += DataType(8)/DataType(9)*this->_fac_frobenius*(DataType(3)*h*h-DataType(2)*Math::sqr(x(0,0))+DataType(2)*x(0,0)*x(1,0)+DataType(2)*x(0,0)*x(2,0)-DataType(2)*Math::sqr(x(0,1))+DataType(2)*x(0,1)*x(1,1)+DataType(2)*x(0,1)*x(2,1)-DataType(2)*Math::sqr(x(1,0))+DataType(2)*x(1,0)*x(2,0)-DataType(2)*Math::sqr(x(1,1))+DataType(2)*x(1,1)*x(2,1)-DataType(2)*Math::sqr(x(2,0))-DataType(2)*Math::sqr(x(2,1)))/(h*h*h*h)*(-DataType(4)*x(0,0)+DataType(2)*x(1,0)+DataType(2)*x(2,0));
331 grad_frobenius_part(0,1) += DataType(8)/DataType(9)*this->_fac_frobenius*(DataType(3)*h*h-DataType(2)*Math::sqr(x(0,0))+DataType(2)*x(0,0)*x(1,0)+DataType(2)*x(0,0)*x(2,0)-DataType(2)*Math::sqr(x(0,1))+DataType(2)*x(0,1)*x(1,1)+DataType(2)*x(0,1)*x(2,1)-DataType(2)*Math::sqr(x(1,0))+DataType(2)*x(1,0)*x(2,0)-DataType(2)*Math::sqr(x(1,1))+DataType(2)*x(1,1)*x(2,1)-DataType(2)*Math::sqr(x(2,0))-DataType(2)*Math::sqr(x(2,1)))/(h*h*h*h)*(-DataType(4)*x(0,1)+DataType(2)*x(1,1)+DataType(2)*x(2,1));
333 grad_frobenius_part(1,0) += DataType(8)/DataType(9)*this->_fac_frobenius*(DataType(3)*h*h-DataType(2)*Math::sqr(x(0,0))+DataType(2)*x(0,0)*x(1,0)+DataType(2)*x(0,0)*x(2,0)-DataType(2)*Math::sqr(x(0,1))+DataType(2)*x(0,1)*x(1,1)+DataType(2)*x(0,1)*x(2,1)-DataType(2)*Math::sqr(x(1,0))+DataType(2)*x(1,0)*x(2,0)-DataType(2)*Math::sqr(x(1,1))+DataType(2)*x(1,1)*x(2,1)-DataType(2)*Math::sqr(x(2,0))-DataType(2)*Math::sqr(x(2,1)))/(h*h*h*h)*(DataType(2)*x(0,0)-DataType(4)*x(1,0)+DataType(2)*x(2,0));
335 grad_frobenius_part(1,1) += DataType(8)/DataType(9)*this->_fac_frobenius*(DataType(3)*h*h-DataType(2)*Math::sqr(x(0,0))+DataType(2)*x(0,0)*x(1,0)+DataType(2)*x(0,0)*x(2,0)-DataType(2)*Math::sqr(x(0,1))+DataType(2)*x(0,1)*x(1,1)+DataType(2)*x(0,1)*x(2,1)-DataType(2)*Math::sqr(x(1,0))+DataType(2)*x(1,0)*x(2,0)-DataType(2)*Math::sqr(x(1,1))+DataType(2)*x(1,1)*x(2,1)-DataType(2)*Math::sqr(x(2,0))-DataType(2)*Math::sqr(x(2,1)))/(h*h*h*h)*(DataType(2)*x(0,1)-DataType(4)*x(1,1)+DataType(2)*x(2,1));
337 grad_frobenius_part(2,0) += DataType(8)/DataType(9)*this->_fac_frobenius*(DataType(3)*h*h-DataType(2)*Math::sqr(x(0,0))+DataType(2)*x(0,0)*x(1,0)+DataType(2)*x(0,0)*x(2,0)-DataType(2)*Math::sqr(x(0,1))+DataType(2)*x(0,1)*x(1,1)+DataType(2)*x(0,1)*x(2,1)-DataType(2)*Math::sqr(x(1,0))+DataType(2)*x(1,0)*x(2,0)-DataType(2)*Math::sqr(x(1,1))+DataType(2)*x(1,1)*x(2,1)-DataType(2)*Math::sqr(x(2,0))-DataType(2)*Math::sqr(x(2,1)))/(h*h*h*h)*(DataType(2)*x(0,0)+DataType(2)*x(1,0)-DataType(4)*x(2,0));
339 grad_frobenius_part(2,1) += DataType(8)/DataType(9)*this->_fac_frobenius*(DataType(3)*h*h-DataType(2)*Math::sqr(x(0,0))+DataType(2)*x(0,0)*x(1,0)+DataType(2)*x(0,0)*x(2,0)-DataType(2)*Math::sqr(x(0,1))+DataType(2)*x(0,1)*x(1,1)+DataType(2)*x(0,1)*x(2,1)-DataType(2)*Math::sqr(x(1,0))+DataType(2)*x(1,0)*x(2,0)-DataType(2)*Math::sqr(x(1,1))+DataType(2)*x(1,1)*x(2,1)-DataType(2)*Math::sqr(x(2,0))-DataType(2)*Math::sqr(x(2,1)))/(h*h*h*h)*(DataType(2)*x(0,1)+DataType(2)*x(1,1)-DataType(4)*x(2,1));
347 void NOINLINE add_grad_det_1_part(Tx& grad_det_1_part,
const Tx& x,
const DataType& h)
349 grad_det_1_part(0,0) += DataType(2)/DataType(3)*this->_fac_det*Math::sqrt(DataType(3))*(x(1,1)-x(2,1))/Math::sqr(h);
351 grad_det_1_part(0,1) += DataType(2)/DataType(3)*this->_fac_det*Math::sqrt(DataType(3))*(-x(1,0)+x(2,0))/Math::sqr(h);
353 grad_det_1_part(1,0) += DataType(2)/DataType(3)*this->_fac_det*Math::sqrt(DataType(3))*(-x(0,1)+x(2,1))/Math::sqr(h);
355 grad_det_1_part(1,1) += DataType(2)/DataType(3)*this->_fac_det*Math::sqrt(DataType(3))*(x(0,0)-x(2,0))/Math::sqr(h);
357 grad_det_1_part(2,0) += DataType(2)/DataType(3)*this->_fac_det*Math::sqrt(DataType(3))*(x(0,1)-x(1,1))/Math::sqr(h);
359 grad_det_1_part(2,1) += DataType(2)/DataType(3)*this->_fac_det*Math::sqrt(DataType(3))*(-x(0,0)+x(1,0))/Math::sqr(h);
365 void NOINLINE add_grad_det_2_part(Tx& grad_det_2_part,
const Tx& x,
const DataType& h)
367 grad_det_2_part(0,0) += DataType(8)/DataType(3)*this->_fac_det*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/(h*h*h*h)*(x(1,1)-x(2,1));
369 grad_det_2_part(0,1) += DataType(8)/DataType(3)*this->_fac_det*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/(h*h*h*h)*(-x(1,0)+x(2,0));
371 grad_det_2_part(1,0) += DataType(8)/DataType(3)*this->_fac_det*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/(h*h*h*h)*(-x(0,1)+x(2,1));
373 grad_det_2_part(1,1) += DataType(8)/DataType(3)*this->_fac_det*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/(h*h*h*h)*(x(0,0)-x(2,0));
375 grad_det_2_part(2,0) += DataType(8)/DataType(3)*this->_fac_det*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/(h*h*h*h)*(x(0,1)-x(1,1));
377 grad_det_2_part(2,1) += DataType(8)/DataType(3)*this->_fac_det*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/(h*h*h*h)*(-x(0,0)+x(1,0));
383 void NOINLINE add_grad_rec_det_1_part(Tx& grad_rec_det_1_part,
const Tx& x,
const DataType& h)
385 grad_rec_det_1_part(0,0) += -this->_fac_rec_det*Math::pow(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/Math::sqr(h)+Math::sqrt(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h))/DataType(3),-DataType(2))*(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(x(1,1)-x(2,1))/Math::sqr(h)+DataType(4)*Math::pow(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h),-DataType(1)/DataType(2))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/(h*h*h*h)*(x(1,1)-x(2,1)));
387 grad_rec_det_1_part(0,1) += -this->_fac_rec_det*Math::pow(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/Math::sqr(h)+Math::sqrt(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h))/DataType(3),-DataType(2))*(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(-x(1,0)+x(2,0))/Math::sqr(h)+DataType(4)*Math::pow(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h),-DataType(1)/DataType(2))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/(h*h*h*h)*(-x(1,0)+x(2,0)));
389 grad_rec_det_1_part(1,0) += -this->_fac_rec_det*Math::pow(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/Math::sqr(h)+Math::sqrt(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h))/DataType(3),-DataType(2))*(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(-x(0,1)+x(2,1))/Math::sqr(h)+DataType(4)*Math::pow(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h),-DataType(1)/DataType(2))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/(h*h*h*h)*(-x(0,1)+x(2,1)));
391 grad_rec_det_1_part(1,1) += -this->_fac_rec_det*Math::pow(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/Math::sqr(h)+Math::sqrt(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h))/DataType(3),-DataType(2))*(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(x(0,0)-x(2,0))/Math::sqr(h)+DataType(4)*Math::pow(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h),-DataType(1)/DataType(2))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/(h*h*h*h)*(x(0,0)-x(2,0)));
393 grad_rec_det_1_part(2,0) += -this->_fac_rec_det*Math::pow(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/Math::sqr(h)+Math::sqrt(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h))/DataType(3),-DataType(2))*(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(x(0,1)-x(1,1))/Math::sqr(h)+DataType(4)*Math::pow(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h),-DataType(1)/DataType(2))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/(h*h*h*h)*(x(0,1)-x(1,1)));
395 grad_rec_det_1_part(2,1) += -this->_fac_rec_det*Math::pow(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/Math::sqr(h)+Math::sqrt(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h))/DataType(3),-DataType(2))*(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(-x(0,0)+x(1,0))/Math::sqr(h)+DataType(4)*Math::pow(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h),-DataType(1)/DataType(2))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/(h*h*h*h)*(-x(0,0)+x(1,0)));
401 void NOINLINE add_grad_rec_det_2_part(Tx& grad_rec_det_2_part,
const Tx& x,
const DataType& h)
403 grad_rec_det_2_part(0,0) += -DataType(2)*this->_fac_rec_det*Math::pow(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/Math::sqr(h)+Math::sqrt(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h))/DataType(3),-DataType(3))*(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(x(1,1)-x(2,1))/Math::sqr(h)+DataType(4)*Math::pow(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h),-DataType(1)/DataType(2))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/(h*h*h*h)*(x(1,1)-x(2,1)));
405 grad_rec_det_2_part(0,1) += -DataType(2)*this->_fac_rec_det*Math::pow(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/Math::sqr(h)+Math::sqrt(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h))/DataType(3),-DataType(3))*(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(-x(1,0)+x(2,0))/Math::sqr(h)+DataType(4)*Math::pow(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h),-DataType(1)/DataType(2))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/(h*h*h*h)*(-x(1,0)+x(2,0)));
407 grad_rec_det_2_part(1,0) += -DataType(2)*this->_fac_rec_det*Math::pow(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/Math::sqr(h)+Math::sqrt(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h))/DataType(3),-DataType(3))*(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(-x(0,1)+x(2,1))/Math::sqr(h)+DataType(4)*Math::pow(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h),-DataType(1)/DataType(2))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/(h*h*h*h)*(-x(0,1)+x(2,1)));
409 grad_rec_det_2_part(1,1) += -DataType(2)*this->_fac_rec_det*Math::pow(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/Math::sqr(h)+Math::sqrt(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h))/DataType(3),-DataType(3))*(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(x(0,0)-x(2,0))/Math::sqr(h)+DataType(4)*Math::pow(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h),-DataType(1)/DataType(2))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/(h*h*h*h)*(x(0,0)-x(2,0)));
411 grad_rec_det_2_part(2,0) += -DataType(2)*this->_fac_rec_det*Math::pow(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/Math::sqr(h)+Math::sqrt(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h))/DataType(3),-DataType(3))*(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(x(0,1)-x(1,1))/Math::sqr(h)+DataType(4)*Math::pow(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h),-DataType(1)/DataType(2))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/(h*h*h*h)*(x(0,1)-x(1,1)));
413 grad_rec_det_2_part(2,1) += -DataType(2)*this->_fac_rec_det*Math::pow(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/Math::sqr(h)+Math::sqrt(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h))/DataType(3),-DataType(3))*(DataType(2)/DataType(3)*Math::sqrt(DataType(3))*(-x(0,0)+x(1,0))/Math::sqr(h)+DataType(4)*Math::pow(DataType(9)*this->_fac_reg*this->_fac_reg+DataType(12)*Math::pow(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0),DataType(2))/(h*h*h*h),-DataType(1)/DataType(2))*(x(0,0)*x(1,1)-x(0,0)*x(2,1)-x(1,0)*x(0,1)+x(2,0)*x(0,1)+x(1,0)*x(2,1)-x(1,1)*x(2,0))/(h*h*h*h)*(-x(0,0)+x(1,0)));
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
T_ sqrt(T_ x)
Returns the square-root of a value.
T_ pow(T_ x, T_ y)
Returns x raised to the power of y.
T_ sqr(T_ x)
Returns the square of a value.
String stringify(const T_ &item)
Converts an item into a String.
@ grad
specifies whether the space should supply basis function gradients
std::uint64_t Index
Index data type.