21 #ifndef fiber_default_test_kernel_trial_integral_imp_hpp
22 #define fiber_default_test_kernel_trial_integral_imp_hpp
24 #include "default_test_kernel_trial_integral.hpp"
26 #include "geometrical_data.hpp"
33 template <
typename IntegrandFunctor>
34 void DefaultTestKernelTrialIntegral<IntegrandFunctor>::
35 addGeometricalDependencies(
size_t& testGeomDeps,
size_t& trialGeomDeps)
const
37 testGeomDeps |= INTEGRATION_ELEMENTS;
38 trialGeomDeps |= INTEGRATION_ELEMENTS;
40 m_functor.addGeometricalDependencies(testGeomDeps, trialGeomDeps);
43 template <
typename IntegrandFunctor>
44 void DefaultTestKernelTrialIntegral<IntegrandFunctor>::
45 evaluateWithTensorQuadratureRule(
46 const GeometricalData<CoordinateType>& testGeomData,
47 const GeometricalData<CoordinateType>& trialGeomData,
48 const CollectionOf3dArrays<BasisFunctionType>& testValues,
49 const CollectionOf3dArrays<BasisFunctionType>& trialValues,
50 const CollectionOf4dArrays<KernelType>& kernelValues,
51 const std::vector<CoordinateType>& testQuadWeights,
52 const std::vector<CoordinateType>& trialQuadWeights,
53 arma::Mat<ResultType>& result)
const
57 const size_t testDofCount = testValues[0].extent(1);
58 const size_t trialDofCount = trialValues[0].extent(1);
60 const size_t testPointCount = testQuadWeights.size();
61 const size_t trialPointCount = trialQuadWeights.size();
65 for (
size_t i = 0; i < kernelValues.size(); ++i) {
66 assert(kernelValues[i].extent(2) == testPointCount);
67 assert(kernelValues[i].extent(3) == trialPointCount);
69 for (
size_t i = 0; i < testValues.size(); ++i)
70 assert(testValues[i].extent(2) == testPointCount);
71 for (
size_t i = 0; i < trialValues.size(); ++i)
72 assert(trialValues[i].extent(2) == trialPointCount);
74 assert(result.n_rows == testDofCount);
75 assert(result.n_cols == trialDofCount);
79 for (
size_t trialDof = 0; trialDof < trialDofCount; ++trialDof)
80 for (
size_t testDof = 0; testDof < testDofCount; ++testDof)
83 for (
size_t trialPoint = 0; trialPoint < trialPointCount; ++trialPoint) {
84 const CoordinateType trialWeight =
85 trialGeomData.integrationElements(trialPoint) *
86 trialQuadWeights[trialPoint];
87 ResultType partialSum = 0.;
88 for (
size_t testPoint = 0; testPoint < testPointCount; ++testPoint) {
89 const CoordinateType testWeight =
90 testGeomData.integrationElements(testPoint) *
91 testQuadWeights[testPoint];
92 partialSum += m_functor.evaluate(
93 testGeomData.const_slice(testPoint),
94 trialGeomData.const_slice(trialPoint),
95 testValues.const_slice(testDof, testPoint),
96 trialValues.const_slice(trialDof, trialPoint),
97 kernelValues.const_slice(testPoint, trialPoint)) *
100 sum += partialSum * trialWeight;
102 result(testDof, trialDof) = sum;
106 template <
typename IntegrandFunctor>
107 void DefaultTestKernelTrialIntegral<IntegrandFunctor>::
108 evaluateWithNontensorQuadratureRule(
109 const GeometricalData<CoordinateType>& testGeomData,
110 const GeometricalData<CoordinateType>& trialGeomData,
111 const CollectionOf3dArrays<BasisFunctionType>& testValues,
112 const CollectionOf3dArrays<BasisFunctionType>& trialValues,
113 const CollectionOf3dArrays<KernelType>& kernelValues,
114 const std::vector<CoordinateType>& quadWeights,
115 arma::Mat<ResultType>& result)
const
119 const size_t testDofCount = testValues[0].extent(1);
120 const size_t trialDofCount = trialValues[0].extent(1);
122 const size_t pointCount = quadWeights.size();
126 for (
size_t i = 0; i < kernelValues.size(); ++i)
127 assert(kernelValues[i].extent(2) == pointCount);
128 for (
size_t i = 0; i < testValues.size(); ++i)
129 assert(testValues[i].extent(2) == pointCount);
130 for (
size_t i = 0; i < trialValues.size(); ++i)
131 assert(trialValues[i].extent(2) == pointCount);
135 for (
size_t trialDof = 0; trialDof < trialDofCount; ++trialDof)
136 for (
size_t testDof = 0; testDof < testDofCount; ++testDof)
139 for (
size_t point = 0; point < pointCount; ++point)
140 sum += m_functor.evaluate(
141 testGeomData.const_slice(point),
142 trialGeomData.const_slice(point),
143 testValues.const_slice(testDof, point),
144 trialValues.const_slice(trialDof, point),
145 kernelValues.const_slice(point)) *
146 (testGeomData.integrationElements(point) *
147 trialGeomData.integrationElements(point) *
149 result(testDof, trialDof) = sum;