18 #include <deal.II/base/tensor_product_polynomials_bubbles.h> 19 #include <deal.II/base/exceptions.h> 20 #include <deal.II/base/table.h> 22 DEAL_II_NAMESPACE_OPEN
34 const unsigned int q_degree = this->polynomials.size()-1;
35 const unsigned int max_q_indices = this->n_tensor_pols;
36 const unsigned int n_bubbles = ((q_degree<=1)?1:dim);
38 Assert (i<max_q_indices+n_bubbles, ExcInternalError());
44 const unsigned int comp = i - this->n_tensor_pols;
48 for (
unsigned int j=0; j<dim; ++j)
49 value*=4*p(j)*(1-p(j));
51 for (
unsigned int i=0; i<q_degree-1; ++i)
63 Assert (
false, ExcNotImplemented());
73 const unsigned int q_degree = this->polynomials.size()-1;
74 const unsigned int max_q_indices = this->n_tensor_pols;
75 const unsigned int n_bubbles = ((q_degree<=1)?1:dim);
77 Assert (i<max_q_indices+n_bubbles, ExcInternalError());
83 const unsigned int comp = i - this->n_tensor_pols;
86 for (
unsigned int d=0; d<dim ; ++d)
90 for (
unsigned j=0; j<dim; ++j)
91 grad[d] *= (d==j ? 4*(1-2*p(j)) : 4*p(j)*(1-p(j)));
93 for (
unsigned int i=0; i<q_degree-1; ++i)
101 for (
unsigned int j=0; j < dim; ++j)
102 value*=4*p(j)*(1-p(j));
104 double tmp=value*2*(q_degree-1);
105 for (
unsigned int i=0; i<q_degree-2; ++i)
120 const unsigned int q_degree = this->polynomials.size()-1;
121 const unsigned int max_q_indices = this->n_tensor_pols;
122 const unsigned int n_bubbles = ((q_degree<=1)?1:dim);
124 Assert (i<max_q_indices+n_bubbles, ExcInternalError());
130 const unsigned int comp = i - this->n_tensor_pols;
134 for (
unsigned int c=0; c<dim; ++c)
136 v[c][0] = 4*p(c)*(1-p(c));
137 v[c][1] = 4*(1-2*p(c));
142 for (
unsigned int i=0; i<q_degree-1; ++i)
148 double tmp = 2*(q_degree-1);
149 for (
unsigned int i=0; i<q_degree-2; ++i)
158 double tmp=4*(q_degree-2)*(q_degree-1);
159 for (
unsigned int i=0; i<q_degree-3; ++i)
169 for (
unsigned int d1=0; d1<dim; ++d1)
170 for (
unsigned int d2=0; d2<dim; ++d2)
172 grad_grad_1[d1][d2] = v[dim][0];
173 for (
unsigned int x=0; x<dim; ++x)
175 unsigned int derivative=0;
183 grad_grad_1[d1][d2] *= v[x][derivative];
191 for (
unsigned int d=0; d<dim; ++d)
193 grad_grad_2[d][comp] = v[dim][1];
194 grad_grad_3[comp][d] = v[dim][1];
195 for (
unsigned int x=0; x<dim; ++x)
197 grad_grad_2[d][comp] *= v[x][d==x];
198 grad_grad_3[comp][d] *= v[x][d==x];
204 double psi_value = 1.;
205 for (
unsigned int x=0; x<dim; ++x)
206 psi_value *= v[x][0];
208 for (
unsigned int d1=0; d1<dim; ++d1)
209 for (
unsigned int d2=0; d2<dim; ++d2)
210 grad_grad[d1][d2] = grad_grad_1[d1][d2]
212 +grad_grad_3[d1][d2];
213 grad_grad[comp][comp]+=psi_value*v[dim][2];
222 std::vector<double> &values,
228 const unsigned int q_degree = this->polynomials.size()-1;
229 const unsigned int max_q_indices = this->n_tensor_pols;
230 (void) max_q_indices;
231 const unsigned int n_bubbles = ((q_degree<=1)?1:dim);
232 Assert (values.size()==max_q_indices+n_bubbles || values.size()==0,
233 ExcDimensionMismatch2(values.size(), max_q_indices+n_bubbles, 0));
234 Assert (grads.size()==max_q_indices+n_bubbles || grads.size()==0,
235 ExcDimensionMismatch2(grads.size(), max_q_indices+n_bubbles, 0));
236 Assert (grad_grads.size()==max_q_indices+n_bubbles || grad_grads.size()==0,
237 ExcDimensionMismatch2(grad_grads.size(), max_q_indices+n_bubbles, 0));
238 Assert (third_derivatives.size()==max_q_indices+n_bubbles || third_derivatives.size()==0,
239 ExcDimensionMismatch2(third_derivatives.size(), max_q_indices+n_bubbles, 0));
240 Assert (fourth_derivatives.size()==max_q_indices+n_bubbles || fourth_derivatives.size()==0,
241 ExcDimensionMismatch2(fourth_derivatives.size(), max_q_indices+n_bubbles, 0));
243 bool do_values =
false, do_grads =
false, do_grad_grads =
false;
244 bool do_3rd_derivatives =
false, do_4th_derivatives =
false;
245 if (values.empty() ==
false)
247 values.resize(this->n_tensor_pols);
250 if (grads.empty() ==
false)
252 grads.resize(this->n_tensor_pols);
255 if (grad_grads.empty() ==
false)
257 grad_grads.resize(this->n_tensor_pols);
258 do_grad_grads =
true;
260 if (third_derivatives.empty() ==
false)
262 third_derivatives.resize(this->n_tensor_pols);
263 do_3rd_derivatives =
true;
265 if (fourth_derivatives.empty() ==
false)
267 fourth_derivatives.resize(this->n_tensor_pols);
268 do_4th_derivatives =
true;
273 for (
unsigned int i=this->n_tensor_pols; i<this->n_tensor_pols+n_bubbles; ++i)
276 values.push_back(compute_value(i,p));
278 grads.push_back(compute_grad(i,p));
280 grad_grads.push_back(compute_grad_grad(i,p));
281 if (do_3rd_derivatives)
282 third_derivatives.push_back(compute_derivative<3>(i,p));
283 if (do_4th_derivatives)
284 fourth_derivatives.push_back(compute_derivative<4>(i,p));
294 DEAL_II_NAMESPACE_CLOSE
Tensor< 1, dim > compute_grad(const unsigned int i, const Point< dim > &p) const
Tensor< 1, dim > compute_grad(const unsigned int i, const Point< dim > &p) const
void compute(const Point< dim > &unit_point, std::vector< double > &values, std::vector< Tensor< 1, dim > > &grads, std::vector< Tensor< 2, dim > > &grad_grads, std::vector< Tensor< 3, dim > > &third_derivatives, std::vector< Tensor< 4, dim > > &fourth_derivatives) const
#define Assert(cond, exc)
void compute(const Point< dim > &unit_point, std::vector< double > &values, std::vector< Tensor< 1, dim > > &grads, std::vector< Tensor< 2, dim > > &grad_grads, std::vector< Tensor< 3, dim > > &third_derivatives, std::vector< Tensor< 4, dim > > &fourth_derivatives) const
Tensor< 2, dim > compute_grad_grad(const unsigned int i, const Point< dim > &p) const
double compute_value(const unsigned int i, const Point< dim > &p) const
Tensor< 2, dim > compute_grad_grad(const unsigned int i, const Point< dim > &p) const
double compute_value(const unsigned int i, const Point< dim > &p) const