21 #ifndef fiber_linear_scalar_shapeset_hpp
22 #define fiber_linear_scalar_shapeset_hpp
24 #include "../common/common.hpp"
28 #include "basis_data.hpp"
29 #include "dune_basis_helper.hpp"
30 #include "CL/piecewise_linear_continuous_scalar_basis.cl.str"
32 #include <dune/localfunctions/lagrange/p1/p1localbasis.hh>
33 #include <dune/localfunctions/lagrange/q1/q1localbasis.hh>
38 template <
int elementVertexCount,
typename CoordinateType,
typename ValueType>
44 template <
typename CoordinateType,
typename ValueType>
48 typedef Dune::Q1LocalBasis<CoordinateType, ValueType, 1> DuneBasis;
52 template <
typename CoordinateType,
typename ValueType>
56 typedef Dune::P1LocalBasis<CoordinateType, ValueType, 2> DuneBasis;
60 template <
typename CoordinateType,
typename ValueType>
64 typedef Dune::Q1LocalBasis<CoordinateType, ValueType, 2> DuneBasis;
68 template <
int elementVertexCount,
typename ValueType>
72 typedef typename Basis<ValueType>::CoordinateType CoordinateType;
76 <elementVertexCount, CoordinateType, ValueType>::DuneBasis DuneBasis;
89 const arma::Mat<CoordinateType>& points,
90 LocalDofIndex localDofIndex,
92 if (localDofIndex != ALL_DOFS &&
93 (localDofIndex < 0 ||
size() <= localDofIndex))
94 throw std::invalid_argument(
"LinearScalarShapeset::"
95 "evaluate(): Invalid localDofIndex");
98 evaluateShapeFunctionsWithDune<CoordinateType, ValueType, DuneBasis>(
99 points, localDofIndex, data.
values);
100 if (what & DERIVATIVES)
101 evaluateShapeFunctionDerivativesWithDune<CoordinateType, ValueType, DuneBasis>(
105 virtual std::pair<const char*,int>
clCodeString (
bool isTestShapeset)
const {
106 static struct StrBuf {
107 std::pair<char*,int> str;
109 } test = {std::pair<char*,int>(NULL,0),
true},
110 trial = {std::pair<char*,int>(NULL,0),
true};
112 StrBuf &buf = (isTestShapeset ? test : trial);
113 const char *modifier = (isTestShapeset ?
"A" :
"B");
115 if (buf.need_setup) {
116 std::string funcName (
"clBasisf");
117 std::string code (piecewise_linear_continuous_scalar_basis_cl,
118 piecewise_linear_continuous_scalar_basis_cl_len);
119 size_t len = funcName.size();
120 size_t n = code.find (funcName);
121 while (n != std::string::npos) {
122 code.insert (n+len, modifier);
123 n = code.find (funcName, n+len);
125 buf.str.second = code.size();
126 buf.str.first =
new char[buf.str.second+1];
127 strcpy (buf.str.first, code.c_str());
128 buf.need_setup =
false;
_4dArray< ValueType > derivatives
Derivatives of shape functions.
Definition: basis_data.hpp:59
virtual int order() const
Return the maximum polynomial order of shape functions.
Definition: linear_scalar_shapeset.hpp:84
virtual std::pair< const char *, int > clCodeString(bool isTestShapeset) const
Returns an OpenCL code snippet for shape function evaluation.
Definition: linear_scalar_shapeset.hpp:105
virtual int size() const
Return the number of shape functions.
Definition: linear_scalar_shapeset.hpp:79
_3dArray< ValueType > values
Values of shape functions.
Definition: basis_data.hpp:51
Definition: linear_scalar_shapeset.hpp:39
Collection of shape functions defined on a reference element.
Definition: basis.hpp:36
Storage of values and/or derivatives of shape functions.
Definition: basis_data.hpp:44
Shapeset composed of the linear nodal functions.
Definition: linear_scalar_shapeset.hpp:69
virtual void evaluate(size_t what, const arma::Mat< CoordinateType > &points, LocalDofIndex localDofIndex, BasisData< ValueType > &data) const
Evaluate the shape functions making up this shapeset and/or their derivatives at specified points...
Definition: linear_scalar_shapeset.hpp:88