17 #include "../mesh/element.h"
23 template<
typename Scalar>
24 int Function<Scalar>::idx2mask[H2D_NUM_FUNCTION_VALUES][2] =
26 { H2D_FN_VAL_0, H2D_FN_VAL_1 }, { H2D_FN_DX_0, H2D_FN_DX_1 }, { H2D_FN_DY_0, H2D_FN_DY_1 },
27 #ifdef H2D_USE_SECOND_DERIVATIVES
28 { H2D_FN_DXX_0, H2D_FN_DXX_1 }, { H2D_FN_DYY_0, H2D_FN_DYY_1 }, { H2D_FN_DXY_0, H2D_FN_DXY_1 }
32 template<
typename Scalar>
37 memset(
quads, 0, H2D_MAX_QUADRATURES*
sizeof(
Quad2D*));
41 template<
typename Scalar>
46 template<
typename Scalar>
52 template<
typename Scalar>
58 template<
typename Scalar>
61 precalculate(order, mask);
65 template<
typename Scalar>
69 this->invalidate_values();
72 template<
typename Scalar>
75 return values[component][item];
78 template<
typename Scalar>
82 this->invalidate_values();
85 for (i = 0; i < H2D_MAX_QUADRATURES; i++)
87 if (quads[i] == quad_2d)
95 for (i = 0; i < H2D_MAX_QUADRATURES; i++)
97 if (quads[i] ==
nullptr)
105 throw Hermes::Exceptions::Exception(
"too many quadratures.");
108 template<
typename Scalar>
111 this->values_valid =
true;
114 template<
typename Scalar>
118 this->invalidate_values();
121 template<
typename Scalar>
125 this->invalidate_values();
128 template<
typename Scalar>
131 return quads[cur_quad];
134 template<
typename Scalar>
137 this->values_valid =
false;
140 template<
typename Scalar>
144 this->invalidate_values();
147 template<
typename Scalar>
151 this->invalidate_values();
154 template<
typename Scalar>
158 this->invalidate_values();
161 template<
typename Scalar>
164 return num_components;
167 template<
typename Scalar>
170 assert(this->values_valid);
171 return &values[component][0][0];
174 template<
typename Scalar>
177 assert(this->values_valid);
178 return &values[component][1][0];
181 template<
typename Scalar>
184 assert(this->values_valid);
185 return &values[component][2][0];
188 #ifdef H2D_USE_SECOND_DERIVATIVES
189 template<
typename Scalar>
192 assert(this->values_valid);
193 return &values[component][3][0];
196 template<
typename Scalar>
197 const Scalar* Function<Scalar>::get_dyy_values(
int component)
const
199 assert(this->values_valid);
200 return &values[component][4][0];
203 template<
typename Scalar>
204 const Scalar* Function<Scalar>::get_dxy_values(
int component)
const
206 assert(this->values_valid);
207 return &values[component][5][0];
211 template<
typename Scalar>
214 assert(this->values_valid);
215 unsigned char np = this->quads[this->cur_quad]->get_num_points(this->order, this->element->get_mode());
216 Scalar* toReturn = malloc_with_check<Scalar>(np);
217 memcpy(toReturn, this->get_values(component, item),
sizeof(Scalar)* np);
virtual void set_active_element(Element *e)
Sets the active element.
virtual void push_transform(int son)
Stores one element of a mesh.
virtual int get_edge_fn_order(unsigned char edge) const
Returns the polynomial degree of the function at given edge. To be overridden in derived classes...
Quad2D * get_quad_2d() const
Returns the current quadrature points.
void set_quad_order(unsigned short order, unsigned short mask=H2D_FN_DEFAULT)
unsigned char get_num_components() const
Returns the number of components of the function being represented by the class.
virtual const Scalar * get_dx_values(int component=0) const
Returns the x partial derivative.
virtual const Scalar * get_dy_values(int component=0) const
Returns the y partial derivative.
virtual int get_fn_order() const
Returns the polynomial degree of the function being represented by the class.
virtual void precalculate(unsigned short order, unsigned short mask)
precalculates the current function at the current integration points.
virtual void force_transform(uint64_t sub_idx, Trf *ctm)
For internal use only.
virtual void pop_transform()
virtual void set_transform(uint64_t idx)
Represents an arbitrary function defined on an element.
bool values_valid
Flag that the data are not 'dirty'.
Function()
Default constructor.
Scalar * deep_copy_array(int component=0, int item=0) const
Returns function values.
virtual void set_quad_2d(Quad2D *quad_2d)
Selects the quadrature points in which the function will be evaluated.
virtual const Scalar * get_fn_values(int component=0) const
Returns function values.
Quad2D * quads[H2D_MAX_QUADRATURES]
List of available quadratures.
int order
Current function polynomial order.
virtual void reset_transform()
Empties the stack, loads identity transform.