36 template<
unsigned NREAGENT,
unsigned DIM>
45 const unsigned n_node = nnode();
48 unsigned c_nodal_index[NREAGENT];
49 for (
unsigned r = 0; r < NREAGENT; r++)
51 c_nodal_index[r] = this->c_index_adv_diff_react(r);
55 Shape psi(n_node), test(n_node);
56 DShape dpsidx(n_node, DIM), dtestdx(n_node, DIM);
59 const unsigned n_intpt = integral_pt()->nweight();
72 int local_eqn = 0, local_unknown = 0;
75 HangInfo *hang_info_pt = 0, *hang_info2_pt = 0;
78 bool ALE_is_disabled_flag = this->ALE_is_disabled;
81 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
84 for (
unsigned i = 0;
i < DIM;
i++)
s[
i] = integral_pt()->knot(ipt,
i);
87 double w = integral_pt()->weight(ipt);
90 double J = this->dshape_and_dtest_eulerian_at_knot_adv_diff_react(
91 ipt, psi, dpsidx, test, dtestdx);
107 for (
unsigned l = 0; l < n_node; l++)
110 for (
unsigned j = 0; j < DIM; j++)
112 interpolated_x[j] += nodal_position(l, j) * psi(l);
116 for (
unsigned r = 0; r < NREAGENT; r++)
119 const double c_value = nodal_value(l, c_nodal_index[r]);
122 interpolated_c[r] += c_value * psi(l);
123 dcdt[r] += this->dc_dt_adv_diff_react(l, r) * psi(l);
126 for (
unsigned j = 0; j < DIM; j++)
128 interpolated_dcdx(r, j) += c_value * dpsidx(l, j);
134 if (!ALE_is_disabled_flag)
136 for (
unsigned l = 0; l < n_node; l++)
138 for (
unsigned j = 0; j < DIM; j++)
140 mesh_velocity[j] += dnodal_position_dt(l, j) * psi(l);
147 this->get_source_adv_diff_react(ipt, interpolated_x, source);
152 this->get_wind_adv_diff_react(ipt,
s, interpolated_x, wind);
156 this->get_reaction_adv_diff_react(ipt, interpolated_c,
R);
162 this->get_reaction_deriv_adv_diff_react(ipt, interpolated_c, dRdC);
169 for (
unsigned l = 0; l < n_node; l++)
173 unsigned n_master = 1;
174 double hang_weight = 1.0;
176 bool is_node_hanging = this->node_pt(l)->is_hanging();
181 hang_info_pt = this->node_pt(l)->hanging_pt();
182 n_master = hang_info_pt->
nmaster();
191 for (
unsigned m = 0; m < n_master; m++)
194 for (
unsigned r = 0; r < NREAGENT; r++)
210 local_eqn = this->nodal_local_eqn(l, c_nodal_index[r]);
219 residuals[local_eqn] -=
220 (
T[r] * dcdt[r] + source[r] +
R[r]) * test(l) *
W * hang_weight;
223 for (
unsigned k = 0; k < DIM; k++)
226 double tmp = wind[k];
228 if (!ALE_is_disabled_flag)
230 tmp -=
T[r] * mesh_velocity[k];
233 residuals[local_eqn] -= interpolated_dcdx(r, k) *
234 (tmp * test(l) +
D[r] * dtestdx(l, k)) *
243 unsigned n_master2 = 1;
244 double hang_weight2 = 1.0;
246 for (
unsigned l2 = 0; l2 < n_node; l2++)
249 bool is_node2_hanging = this->node_pt(l2)->is_hanging();
251 if (is_node2_hanging)
253 hang_info2_pt = this->node_pt(l2)->hanging_pt();
254 n_master2 = hang_info2_pt->nmaster();
263 for (
unsigned m2 = 0; m2 < n_master2; m2++)
266 for (
unsigned r2 = 0; r2 < NREAGENT; r2++)
270 if (is_node2_hanging)
273 local_unknown = this->local_hang_eqn(
274 hang_info2_pt->master_node_pt(m2), c_nodal_index[r2]);
276 hang_weight2 = hang_info2_pt->master_weight(m2);
283 this->nodal_local_eqn(l2, c_nodal_index[r2]);
289 if (local_unknown >= 0)
295 jacobian(local_eqn, local_unknown) -=
296 T[r] * test(l) * psi(l2) *
297 node_pt(l2)->time_stepper_pt()->weight(1, 0) *
W *
298 hang_weight * hang_weight2;
303 mass_matrix(local_eqn, local_unknown) +=
304 T[r] * test(l) * psi(l2) *
W * hang_weight *
309 for (
unsigned i = 0;
i < DIM;
i++)
312 double tmp = wind[
i];
313 if (!ALE_is_disabled_flag)
315 tmp -=
T[r] * mesh_velocity[
i];
318 jacobian(local_eqn, local_unknown) -=
320 (tmp * test(l) +
D[r] * dtestdx(l,
i)) *
W *
321 hang_weight * hang_weight2;
327 jacobian(local_eqn, local_unknown) -=
328 dRdC(r, r2) * psi(l2) * test(l) *
W * hang_weight *
A Class for the derivatives of shape functions The class design is essentially the same as Shape,...
Class that contains data for hanging nodes.
double const & master_weight(const unsigned &i) const
Return weight for dofs on i-th master node.
Node *const & master_node_pt(const unsigned &i) const
Return a pointer to the i-th master node.
unsigned nmaster() const
Return the number of master nodes.
void fill_in_generic_residual_contribution_adv_diff_react(Vector< double > &residuals, DenseMatrix< double > &jacobian, DenseMatrix< double > &mass_matrix, unsigned flag)
Add the element's contribution to the elemental residual vector and/or Jacobian matrix flag=1: comput...
Refineable version of QAdvectionDiffusionReactionElement. Inherit from the standard QAdvectionDiffusi...
A Class for shape functions. In simple cases, the shape functions have only one index that can be tho...
//////////////////////////////////////////////////////////////////// ////////////////////////////////...