21 #ifndef fiber_default_collection_of_kernels_imp_hpp
22 #define fiber_default_collection_of_kernels_imp_hpp
24 #include "default_collection_of_kernels.hpp"
26 #include "collection_of_3d_arrays.hpp"
27 #include "collection_of_4d_arrays.hpp"
28 #include "geometrical_data.hpp"
30 #include <boost/utility/enable_if.hpp>
33 #define FIBER_HAS_MEM_FUNC(func, name) \
34 template<typename T, typename Sign> \
36 typedef char yes[1]; \
37 typedef char no [2]; \
38 template <typename U, U> struct type_check; \
39 template <typename _1> static yes &chk(type_check<Sign, &_1::func> *); \
40 template <typename > static no &chk(...); \
41 static bool const value = sizeof(chk<T>(0)) == sizeof(yes); \
47 FIBER_HAS_MEM_FUNC(estimateRelativeScale, hasEstimateRelativeScale);
75 template<
typename Functor>
76 typename boost::enable_if<hasEstimateRelativeScale<Functor,
77 typename Functor::CoordinateType(Functor::*)(
typename Functor::CoordinateType)
const>,
78 typename Functor::CoordinateType>::type
79 estimateRelativeScaleInternal(
const Functor& functor,
80 typename Functor::CoordinateType distance)
82 return functor.estimateRelativeScale(distance);
85 template<
typename Functor>
86 typename boost::disable_if<hasEstimateRelativeScale<Functor,
87 typename Functor::CoordinateType(Functor::*)(
typename Functor::CoordinateType)
const>,
88 typename Functor::CoordinateType>::type
89 estimateRelativeScaleInternal(
const Functor& functor,
90 typename Functor::CoordinateType distance)
114 template <
typename Functor>
116 size_t& testGeomDeps,
size_t& trialGeomDeps)
const
118 m_functor.addGeometricalDependencies(testGeomDeps, trialGeomDeps);
121 template <
typename Functor>
127 assert(testGeomData.pointCount() == trialGeomData.pointCount());
129 const size_t pointCount = testGeomData.pointCount();
130 const size_t kernelCount = m_functor.kernelCount();
131 result.set_size(kernelCount);
132 for (
size_t k = 0; k < kernelCount; ++k)
133 result[k].set_size(m_functor.kernelRowCount(k),
134 m_functor.kernelColCount(k),
137 for (
size_t p = 0; p < pointCount; ++p)
138 m_functor.evaluate(testGeomData.const_slice(p),
139 trialGeomData.const_slice(p),
140 result.slice(p).self());
143 template <
typename Functor>
144 void DefaultCollectionOfKernels<Functor>::evaluateOnGrid(
145 const GeometricalData<CoordinateType>& testGeomData,
146 const GeometricalData<CoordinateType>& trialGeomData,
147 CollectionOf4dArrays<ValueType>& result)
const
149 const size_t testPointCount = testGeomData.pointCount();
150 const size_t trialPointCount = trialGeomData.pointCount();
151 const size_t kernelCount = m_functor.kernelCount();
152 result.set_size(kernelCount);
153 for (
size_t k = 0; k < kernelCount; ++k)
154 result[k].set_size(m_functor.kernelRowCount(k),
155 m_functor.kernelColCount(k),
160 for (
size_t trialIndex = 0; trialIndex < trialPointCount; ++trialIndex)
161 for (
size_t testIndex = 0; testIndex < testPointCount; ++testIndex)
162 m_functor.evaluate(testGeomData.const_slice(testIndex),
163 trialGeomData.const_slice(trialIndex),
164 result.slice(testIndex, trialIndex).self());
167 template <
typename Functor>
168 std::pair<const char*, int>
170 throw std::runtime_error(
"DefaultCollectionOfKernels::evaluateClCode(): "
171 "not implemented yet");
175 template <
typename Functor>
176 typename DefaultCollectionOfKernels<Functor>::CoordinateType
180 return estimateRelativeScaleInternal(m_functor, distance);
virtual std::pair< const char *, int > evaluateClCode() const
Currently unused.
Definition: default_collection_of_kernels_imp.hpp:169
Storage of geometrical data.
Definition: geometrical_data.hpp:54
Definition: collection_of_3d_arrays.hpp:39
virtual void addGeometricalDependencies(size_t &testGeomDeps, size_t &trialGeomDeps) const
Retrieve types of geometrical data on which the kernels depend.
Definition: default_collection_of_kernels_imp.hpp:115
Default implementation of a collection of kernels.
Definition: default_collection_of_kernels.hpp:87