34 template<
unsigned DIM>
36 const Shape& q_basis_local,
41 const unsigned n_node = this->nnode();
46 this->dshape_local(
s, psi, dpsi);
52 double det = local_to_eulerian_mapping(dpsi, jacobian, inverse_jacobian);
55 const unsigned n_q_basis = this->nq_basis();
58 for (
unsigned l = 0; l < n_q_basis; l++)
61 for (
unsigned i = 0;
i < DIM;
i++)
69 for (
unsigned i = 0;
i < DIM;
i++)
72 for (
unsigned j = 0; j < DIM; j++)
76 double jac_trans = jacobian(j,
i) / det;
79 for (
unsigned l = 0; l < n_q_basis; l++)
82 q_basis(l,
i) += jac_trans * q_basis_local(l, j);
97 template<
unsigned DIM>
99 std::ostream& outfile,
100 const unsigned& nplot,
107 outfile << this->tecplot_zone_string(nplot);
110 unsigned num_plot_points = this->nplot_points(nplot);
112 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
115 this->get_s_plot(iplot, nplot,
s);
118 for (
unsigned i = 0;
i < DIM;
i++)
120 outfile << this->interpolated_x(
s,
i) <<
" ";
124 for (
unsigned i = 0;
i < DIM;
i++)
126 outfile << this->interpolated_q(
s,
i) <<
" ";
130 outfile << this->interpolated_div_q(
s) <<
" ";
133 outfile << this->interpolated_p(
s) <<
" ";
137 for (
unsigned i = 0;
i < 2;
i++)
139 flux += this->interpolated_q(
s,
i) * unit_normal[
i];
141 outfile << flux <<
" ";
143 outfile << std::endl;
147 this->write_tecplot_zone_footer(outfile, nplot);
155 template<
unsigned DIM>
162 outfile << tecplot_zone_string(nplot);
165 unsigned num_plot_points = nplot_points(nplot);
167 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
170 get_s_plot(iplot, nplot,
s);
173 for (
unsigned i = 0;
i < DIM;
i++)
175 outfile << interpolated_x(
s,
i) <<
" ";
179 for (
unsigned i = 0;
i < DIM;
i++)
181 outfile << interpolated_q(
s,
i) <<
" ";
185 outfile << interpolated_div_q(
s) <<
" ";
188 outfile << interpolated_p(
s) <<
" ";
190 outfile << std::endl;
194 this->write_tecplot_zone_footer(outfile, nplot);
201 template<
unsigned DIM>
203 std::ostream& outfile,
204 const unsigned& nplot,
214 outfile << this->tecplot_zone_string(nplot);
220 unsigned num_plot_points = this->nplot_points(nplot);
222 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
225 this->get_s_plot(iplot, nplot,
s);
228 this->interpolated_x(
s, x);
231 (*exact_soln_pt)(x, exact_soln);
234 for (
unsigned i = 0;
i < DIM;
i++)
236 outfile << x[
i] <<
" ";
238 for (
unsigned i = 0;
i < DIM + 2;
i++)
240 outfile << exact_soln[
i] <<
" ";
242 outfile << std::endl;
246 this->write_tecplot_zone_footer(outfile, nplot);
253 template<
unsigned DIM>
255 std::ostream& outfile,
260 for (
unsigned i = 0;
i < 2;
i++)
273 unsigned n_intpt = this->integral_pt()->nweight();
275 outfile <<
"ZONE" << std::endl;
281 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
284 for (
unsigned i = 0;
i < DIM;
i++)
286 s[
i] = this->integral_pt()->knot(ipt,
i);
290 double w = this->integral_pt()->weight(ipt);
293 double J = this->J_eulerian(
s);
299 this->interpolated_x(
s, x);
302 (*exact_soln_pt)(x, exact_soln);
305 for (
unsigned i = 0;
i < DIM;
i++)
307 norm[0] += exact_soln[
i] * exact_soln[
i] *
W;
309 error[0] += (exact_soln[
i] - this->interpolated_q(
s,
i)) *
310 (exact_soln[
i] - this->interpolated_q(
s,
i)) *
W;
319 norm[1] += exact_soln[DIM + 1] * exact_soln[DIM + 1] *
W;
320 error[1] += (exact_soln[DIM + 1] - this->interpolated_p(
s)) *
321 (exact_soln[DIM + 1] - this->interpolated_p(
s)) *
W;
324 for (
unsigned i = 0;
i < DIM;
i++)
326 outfile << x[
i] <<
" ";
330 for (
unsigned i = 0;
i < DIM;
i++)
332 outfile << exact_soln[
i] - this->interpolated_q(
s,
i) <<
" ";
336 outfile << exact_soln[DIM + 1] - this->interpolated_p(
s) <<
" ";
338 outfile << std::endl;
345 template<
unsigned DIM>
351 const unsigned n_node = nnode();
352 const unsigned n_q_basis = nq_basis();
353 const unsigned n_q_basis_edge = nq_basis_edge();
354 const unsigned n_p_basis = np_basis();
357 Shape psi(n_node), q_basis(n_q_basis, DIM), q_test(n_q_basis, DIM),
358 p_basis(n_p_basis), p_test(n_p_basis), div_q_basis_ds(n_q_basis),
359 div_q_test_ds(n_q_basis);
362 unsigned n_intpt = integral_pt()->nweight();
371 double mass_source_local;
377 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
380 for (
unsigned i = 0;
i < DIM;
i++)
382 s[
i] = integral_pt()->knot(ipt,
i);
386 double w = integral_pt()->weight(ipt);
390 double J = shape_basis_test_local_at_knot(ipt,
402 double interpolated_div_q_ds = 0.0;
403 double interpolated_p = 0.0;
406 for (
unsigned l = 0; l < n_node; l++)
408 for (
unsigned i = 0;
i < DIM;
i++)
410 interpolated_x[
i] += nodal_position(l,
i) * psi[l];
416 for (
unsigned i = 0;
i < DIM;
i++)
419 for (
unsigned l = 0; l < n_q_basis_edge; l++)
421 interpolated_q[
i] += q_edge(l) * q_basis(l,
i);
424 for (
unsigned l = n_q_basis_edge; l < n_q_basis; l++)
426 interpolated_q[
i] += q_internal(l - n_q_basis_edge) * q_basis(l,
i);
431 for (
unsigned l = 0; l < n_p_basis; l++)
433 interpolated_p += p_value(l) * p_basis(l);
438 for (
unsigned l = 0; l < n_q_basis_edge; l++)
440 interpolated_div_q_ds += q_edge(l) * div_q_basis_ds(l);
442 for (
unsigned l = n_q_basis_edge; l < n_q_basis; l++)
444 interpolated_div_q_ds +=
445 q_internal(l - n_q_basis_edge) * div_q_basis_ds(l);
449 this->source(interpolated_x, f);
452 this->mass_source(interpolated_x, mass_source_local);
455 for (
unsigned l = 0; l < n_q_basis; l++)
457 if (l < n_q_basis_edge)
459 local_eqn = q_edge_local_eqn(l);
463 local_eqn = q_internal_local_eqn(l - n_q_basis_edge);
469 for (
unsigned i = 0;
i < DIM;
i++)
471 residuals[local_eqn] +=
472 (interpolated_q[
i] - f[
i]) * q_test(l,
i) * w * J;
476 residuals[local_eqn] -= (interpolated_p * div_q_test_ds(l)) * w;
481 for (
unsigned l = 0; l < n_p_basis; l++)
484 local_eqn = p_local_eqn(l);
490 residuals[local_eqn] += interpolated_div_q_ds * p_test(l) * w;
491 residuals[local_eqn] -= mass_source_local * p_test(l) * w * J;
A Class for the derivatives of shape functions The class design is essentially the same as Shape,...
void output_fct(std::ostream &outfile, const unsigned &nplot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Output FE representation of exact soln: x,y,q1,q2,div_q,p at Nplot^DIM plot points.
void output_with_projected_flux(std::ostream &outfile, const unsigned &nplot, const Vector< double > unit_normal)
Output incl. projection of fluxes into direction of the specified unit vector.
virtual void fill_in_generic_residual_contribution(Vector< double > &residuals, DenseMatrix< double > &jacobian, bool flag)
Fill in residuals and, if flag==true, jacobian.
double transform_basis(const Vector< double > &s, const Shape &q_basis_local, Shape &psi, Shape &q_basis) const
Performs a div-conserving transformation of the vector basis functions from the reference element to ...
void compute_error(std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt, Vector< double > &error, Vector< double > &norm)
Compute the error between the FE solution and the exact solution using the H(div) norm for q and L^2 ...
void output(std::ostream &outfile)
Output with default number of plot points.
void(* SteadyExactSolutionFctPt)(const Vector< double > &, Vector< double > &)
Function pointer for function that computes vector-valued steady "exact solution" as .
A Class for shape functions. In simple cases, the shape functions have only one index that can be tho...
//////////////////////////////////////////////////////////////////// ////////////////////////////////...