MCPcopy Create free account
hub / github.com/NGSolve/ngsolve / AddTransSIMDIR

Method AddTransSIMDIR

comp/l2hofespace.cpp:3580–3639  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3578
3579 using DiffOp<DiffOpGradVectorL2Piola>::AddTransSIMDIR;
3580 static void AddTransSIMDIR (const FiniteElement & bfel, const SIMD_BaseMappedIntegrationRule & bmir,
3581 BareSliceMatrix<SIMD<double>> y, BareSliceVector<double> x)
3582 {
3583 auto & mir = static_cast<const SIMD_MappedIntegrationRule<DIM_SPACE,DIM_SPACE>&> (bmir);
3584 auto & fel = static_cast<const VectorFiniteElement&> (bfel);
3585 auto & feli = static_cast<const BaseScalarFiniteElement&> (fel[0]);
3586 size_t ndofi = feli.GetNDof();
3587
3588 STACK_ARRAY(SIMD<double>, mem, DIM_SPC*DIM_SPC*mir.Size());
3589 FlatMatrix<SIMD<double>> grad(DIM_SPC*DIM_SPC, mir.Size(), &mem[0]);
3590 grad = SIMD<double>(0.0);
3591
3592 for (size_t i = 0; i < mir.Size(); i++)
3593 {
3594 auto trans = 1/(mir[i].GetJacobiDet())*mir[i].GetJacobian();
3595 for (int j = 0; j < DIM_SPC; j++)
3596 for (int k = 0; k < DIM_SPC; k++)
3597 for (int l = 0; l < DIM_SPC; l++)
3598 grad(j*DIM_SPC+k, i) += trans(l,j)*y(l*DIM_SPC+k, i);
3599 }
3600
3601 for (size_t k = 0; k < DIM_SPC; k++)
3602 feli.AddGradTrans (mir, grad.Rows(k*DIM_SPC, (k+1)*DIM_SPC), x.Range(k*ndofi, (k+1)*ndofi));
3603
3604 if (!mir.GetTransformation().IsCurvedElement())
3605 return;
3606
3607 STACK_ARRAY(SIMD<double>, mem2, DIM_SPC*mir.Size());
3608 FlatMatrix<SIMD<double>> val(DIM_SPC, mir.Size(), &mem2[0]);
3609 val = SIMD<double>(0.0);
3610
3611 for (size_t ip = 0; ip < mir.Size(); ip++)
3612 {
3613 auto jac = mir[ip].GetJacobian();
3614 auto inv = mir[ip].GetJacobianInverse();
3615 auto invJ = 1/mir[ip].GetJacobiDet();
3616 Vec<DIM_SPC, Mat<DIM_SPC,DIM_SPC,SIMD<double>>> hesse;
3617 mir[ip].CalcHesse(hesse);
3618
3619 Vec<DIM_SPC, Mat<DIM_SPC,DIM_SPC,SIMD<double>>> invjac_hesse;
3620 for (int i = 0; i < DIM_SPC; i++)
3621 invjac_hesse(i) = Trans(inv) * hesse(i);
3622
3623 Vec<DIM_SPC,SIMD<double>> inv_hesse = SIMD<double>(0.0);
3624 for (int i = 0; i < DIM_SPC; i++)
3625 for (int j = 0; j < DIM_SPC; j++)
3626 inv_hesse(i) += invjac_hesse(j)(j,i);
3627 inv_hesse = Trans(inv) * inv_hesse;
3628
3629 for (int i = 0; i < DIM_SPC; i++)
3630 for (int j = 0; j < DIM_SPC; j++)
3631 for (int k = 0; k < DIM_SPC; k++)
3632 val(k,ip) +=
3633 invJ * (invjac_hesse(i)(j,k)-inv_hesse(j)*jac(i,k)) *
3634 y(i*DIM_SPC+j,ip);
3635 }
3636
3637 for (size_t k = 0; k < DIM_SPC; k++)

Callers

nothing calls this directly

Calls 14

gradFunction · 0.85
GetJacobianMethod · 0.80
AddGradTransMethod · 0.80
GetTransformationMethod · 0.80
CalcHesseMethod · 0.80
TransFunction · 0.50
GetNDofMethod · 0.45
SizeMethod · 0.45
GetJacobiDetMethod · 0.45
RowsMethod · 0.45
RangeMethod · 0.45
GetJacobianInverseMethod · 0.45

Tested by

no test coverage detected