| 20 | } |
| 21 | |
| 22 | void TestCoefficientFunction(shared_ptr<CoefficientFunction> cf, |
| 23 | shared_ptr<CoefficientFunction> c_cf_f, |
| 24 | shared_ptr<CoefficientFunction> c_cf_t) |
| 25 | { |
| 26 | LocalHeap lh(100000, "lh"); |
| 27 | IntegrationRule ir(ET_TET, 3); |
| 28 | FE_ElementTransformation<3,3> trafo(ET_TET); |
| 29 | MappedIntegrationRule<3,3> mir(ir, trafo, lh); |
| 30 | |
| 31 | SIMD_IntegrationRule simd_ir(ET_TET, 3); |
| 32 | SIMD_MappedIntegrationRule<3,3> simd_mir(simd_ir, trafo, lh); |
| 33 | |
| 34 | // we compute directional derivative by the first proxy ... |
| 35 | Array<ProxyFunction*> proxies; |
| 36 | cf->TraverseTree |
| 37 | ([&] (CoefficientFunction & nodecf) |
| 38 | { |
| 39 | auto proxy = dynamic_cast<ProxyFunction*> (&nodecf); |
| 40 | if (proxy && !proxies.Contains(proxy)) |
| 41 | proxies.Append (proxy); |
| 42 | }); |
| 43 | |
| 44 | ProxyUserData ud(proxies.Size(), lh); |
| 45 | trafo.userdata = &ud; |
| 46 | ScalarDummyFE<ET_TET> dummy_fe; |
| 47 | Vector<> dummy_elvec; |
| 48 | ud.fel = &dummy_fe; |
| 49 | // ud.elx = &dummy_elvec; |
| 50 | // ud.lh = &lh; |
| 51 | // we give some value to the proxy functions |
| 52 | for (ProxyFunction * proxy : proxies) |
| 53 | { |
| 54 | ud.AssignMemory (proxy, ir.GetNIP(), proxy->Dimension(), lh); |
| 55 | ud.GetAMemory(proxy) = 100; |
| 56 | ud.GetMemory(proxy) = 100; |
| 57 | } |
| 58 | ud.trialfunction = nullptr; |
| 59 | if (proxies.Size()) |
| 60 | ud.trialfunction = proxies[0]; |
| 61 | ud.trial_comp = 0; |
| 62 | ud.testfunction = nullptr; |
| 63 | ud.test_comp = 0; |
| 64 | |
| 65 | |
| 66 | Matrix<> vals(ir.Size(),cf->Dimension()); |
| 67 | cf->Evaluate(mir,vals); |
| 68 | Matrix<SIMD<double>> simd_vals (cf->Dimension(), simd_ir.Size()); |
| 69 | SliceMatrix<> simd_vals_ref(cf->Dimension(), simd_ir.GetNIP(), SIMD<double>::Size()*simd_ir.Size(), |
| 70 | &simd_vals(0)[0]); |
| 71 | |
| 72 | // AutoDiff<SIMD> alignment not working !!!! |
| 73 | Matrix<AutoDiff<1,SIMD<double>>> simd_ad(cf->Dimension(), simd_ir.Size()); |
| 74 | // Array<SIMD<double>> mem(2*cf->Dimension()*simd_ir.Size()); |
| 75 | // FlatMatrix<AutoDiff<1,SIMD<double>>> simd_ad(cf->Dimension(), simd_ir.Size(), (AutoDiff<1,SIMD<double>>*)(void*)mem.Addr(0)); |
| 76 | Matrix<> c_vals(ir.Size(), cf->Dimension()); |
| 77 | Matrix<> derivs(ir.Size(), cf->Dimension()); |
| 78 | Matrix<AutoDiff<1>> dvals(ir.Size(), cf->Dimension()); |
| 79 | // cf->EvaluateDeriv(mir,vals,derivs); |
nothing calls this directly
no test coverage detected