39 template<
unsigned SPATIAL_DIM>
44 template<
unsigned SPATIAL_DIM>
51 template<
unsigned SPATIAL_DIM,
unsigned NNODE_1D>
63 template<
unsigned SPATIAL_DIM>
71 unsigned n_node = nnode();
74 unsigned u_nodal_index = u_index_ust_heat();
83 DShape dpsidx(n_node, SPATIAL_DIM + 1);
86 DShape dtestdx(n_node, SPATIAL_DIM + 1);
89 unsigned n_intpt = integral_pt()->nweight();
95 double alpha_local = alpha();
98 double beta_local = beta();
104 int local_unknown = 0;
107 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
110 for (
unsigned i = 0;
i < SPATIAL_DIM + 1;
i++)
113 s[
i] = integral_pt()->knot(ipt,
i);
117 double w = integral_pt()->weight(ipt);
120 double J = dshape_and_dtest_eulerian_at_knot_ust_heat(
121 ipt, psi, dpsidx, test, dtestdx);
127 double interpolated_t = 0.0;
130 double interpolated_u = 0.0;
133 double interpolated_dudt = 0.0;
148 for (
unsigned l = 0; l < n_node; l++)
151 double u_value = raw_nodal_value(l, u_nodal_index);
154 interpolated_t += raw_nodal_position(l, SPATIAL_DIM) * psi(l);
157 for (
unsigned j = 0; j < SPATIAL_DIM; j++)
160 interpolated_x[j] += raw_nodal_position(l, j) * psi(l);
163 interpolated_dudx[j] += u_value * dpsidx(l, j);
167 interpolated_u += u_value * psi(l);
170 interpolated_dudt += u_value * dpsidx(l, SPATIAL_DIM);
177 get_source_ust_heat(interpolated_t, ipt, interpolated_x, source);
183 for (
unsigned l = 0; l < n_node; l++)
186 local_eqn = nodal_local_eqn(l, u_nodal_index);
192 residuals[local_eqn] +=
193 (source + alpha_local * interpolated_dudt) * test(l) *
W;
196 for (
unsigned k = 0; k < SPATIAL_DIM; k++)
199 residuals[local_eqn] +=
200 beta_local * interpolated_dudx[k] * dtestdx(l, k) *
W;
210 for (
unsigned l2 = 0; l2 < n_node; l2++)
213 local_unknown = nodal_local_eqn(l2, u_nodal_index);
216 if (local_unknown >= 0)
219 jacobian(local_eqn, local_unknown) +=
220 (alpha_local * test(l) * dpsidx(l2, SPATIAL_DIM) *
W);
223 for (
unsigned i = 0;
i < SPATIAL_DIM;
i++)
226 jacobian(local_eqn, local_unknown) +=
227 (beta_local * dpsidx(l2,
i) * dtestdx(l,
i) *
W);
241 template<
unsigned SPATIAL_DIM>
254 unsigned n_node = nnode();
260 unsigned n_intpt = integral_pt()->nweight();
263 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
266 for (
unsigned i = 0;
i < SPATIAL_DIM + 1;
i++)
269 s[
i] = integral_pt()->knot(ipt,
i);
273 double w = integral_pt()->weight(ipt);
276 double J = J_eulerian(
s);
282 double u = interpolated_u_ust_heat(
s);
293 template<
unsigned SPATIAL_DIM>
326 template<
unsigned SPATIAL_DIM>
328 std::ostream& outfile,
const unsigned& nplot)
334 outfile << tecplot_zone_string(nplot);
337 unsigned num_plot_points = nplot_points(nplot);
340 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
343 get_s_plot(iplot, nplot,
s);
346 for (
unsigned i = 0;
i < SPATIAL_DIM + 1;
i++)
349 outfile << interpolated_x(
s,
i) <<
" ";
353 outfile << interpolated_u_ust_heat(
s) << std::endl;
357 write_tecplot_zone_footer(outfile, nplot);
366 template<
unsigned SPATIAL_DIM>
368 FILE* file_pt,
const unsigned& nplot)
374 fprintf(file_pt,
"%s", tecplot_zone_string(nplot).c_str());
377 unsigned num_plot_points = nplot_points(nplot);
380 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
383 get_s_plot(iplot, nplot,
s);
386 for (
unsigned i = 0;
i < SPATIAL_DIM + 1;
i++)
389 fprintf(file_pt,
"%g ", interpolated_x(
s,
i));
393 fprintf(file_pt,
"%g \n", interpolated_u_ust_heat(
s));
397 write_tecplot_zone_footer(file_pt, nplot);
406 template<
unsigned SPATIAL_DIM>
408 std::ostream& outfile,
409 const unsigned& nplot,
419 outfile << tecplot_zone_string(nplot);
425 unsigned num_plot_points = nplot_points(nplot);
428 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
431 get_s_plot(iplot, nplot,
s);
434 for (
unsigned i = 0;
i < SPATIAL_DIM;
i++)
437 spatial_coordinates[
i] = interpolated_x(
s,
i);
440 outfile << spatial_coordinates[
i] <<
" ";
444 outfile << interpolated_x(
s, SPATIAL_DIM) <<
" ";
447 (*exact_soln_pt)(spatial_coordinates, exact_soln);
450 outfile << exact_soln[0] << std::endl;
454 write_tecplot_zone_footer(outfile, nplot);
463 template<
unsigned SPATIAL_DIM>
465 std::ostream& outfile,
466 const unsigned& nplot,
471 double interpolated_t = 0.0;
480 outfile << tecplot_zone_string(nplot);
486 unsigned num_plot_points = nplot_points(nplot);
489 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
492 get_s_plot(iplot, nplot,
s);
495 for (
unsigned i = 0;
i < SPATIAL_DIM;
i++)
498 spatial_coordinates[
i] = interpolated_x(
s,
i);
501 outfile << spatial_coordinates[
i] <<
" ";
505 interpolated_t = interpolated_x(
s, SPATIAL_DIM);
508 outfile << interpolated_t <<
" ";
511 (*exact_soln_pt)(interpolated_t, spatial_coordinates, exact_soln);
514 outfile << exact_soln[0] << std::endl;
518 write_tecplot_zone_footer(outfile, nplot);
528 template<
unsigned SPATIAL_DIM>
530 std::ostream& outfile,
548 unsigned n_node = nnode();
554 unsigned n_intpt = integral_pt()->nweight();
557 outfile <<
"ZONE" << std::endl;
563 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
566 for (
unsigned i = 0;
i < SPATIAL_DIM + 1;
i++)
569 s[
i] = integral_pt()->knot(ipt,
i);
573 double w = integral_pt()->weight(ipt);
576 double J = J_eulerian(
s);
582 double u_fe = interpolated_u_ust_heat(
s);
585 for (
unsigned i = 0;
i < SPATIAL_DIM;
i++)
588 spatial_coordinates[
i] = interpolated_x(
s,
i);
591 outfile << spatial_coordinates[
i] <<
" ";
595 outfile << interpolated_x(
s, SPATIAL_DIM) <<
" ";
598 (*exact_soln_pt)(spatial_coordinates, exact_soln);
601 outfile << exact_soln[0] <<
" " << exact_soln[0] - u_fe << std::endl;
604 norm += exact_soln[0] * exact_soln[0] *
W;
607 error += (exact_soln[0] - u_fe) * (exact_soln[0] - u_fe) *
W;
618 template<
unsigned SPATIAL_DIM>
620 std::ostream& outfile,
633 double interpolated_t = 0.0;
642 unsigned n_node = nnode();
648 unsigned n_intpt = integral_pt()->nweight();
651 outfile <<
"ZONE" << std::endl;
657 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
660 for (
unsigned i = 0;
i < SPATIAL_DIM + 1;
i++)
662 s[
i] = integral_pt()->knot(ipt,
i);
666 double w = integral_pt()->weight(ipt);
669 double J = J_eulerian(
s);
675 double u_fe = interpolated_u_ust_heat(
s);
678 for (
unsigned i = 0;
i < SPATIAL_DIM;
i++)
681 spatial_coordinates[
i] = interpolated_x(
s,
i);
684 outfile << spatial_coordinates[
i] <<
" ";
688 interpolated_t = interpolated_x(
s, SPATIAL_DIM);
691 outfile << interpolated_t <<
" ";
694 (*exact_soln_pt)(interpolated_t, spatial_coordinates, exact_soln);
697 outfile << exact_soln[0] <<
" " << exact_soln[0] - u_fe << std::endl;
700 norm += exact_soln[0] * exact_soln[0] *
W;
703 error += (exact_soln[0] - u_fe) * (exact_soln[0] - u_fe) *
W;
713 template<
unsigned SPATIAL_DIM>
715 std::ofstream& file_out,
const unsigned& nplot)
718 file_out.setf(std::ios_base::uppercase);
721 unsigned number_of_nodes = this->nplot_points_paraview(nplot);
724 unsigned total_number_of_elements = this->nsub_elements_paraview(nplot);
731 file_out <<
"<?xml version=\"1.0\"?>\n"
732 <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" "
733 <<
"byte_order=\"LittleEndian\">\n"
734 <<
"<UnstructuredGrid>\n"
735 <<
"<Piece NumberOfPoints=\"" << number_of_nodes
736 <<
"\" NumberOfCells=\"" << total_number_of_elements <<
"\">\n";
742 unsigned ndof = this->nscalar_paraview();
745 file_out <<
"<PointData ";
750 file_out <<
"Scalars=\"" << this->scalar_name_paraview(0) <<
"\">\n";
753 for (
unsigned i = 0;
i < ndof;
i++)
755 file_out <<
"<DataArray type=\"Float32\" "
756 <<
"Name=\"" << this->scalar_name_paraview(
i) <<
"\" "
757 <<
"format=\"ascii\""
761 this->scalar_value_paraview(file_out,
i, nplot);
764 file_out <<
"</DataArray>\n";
768 file_out <<
"</PointData>\n";
774 file_out <<
"<Points>\n"
775 <<
"<DataArray type=\"Float32\""
776 <<
" NumberOfComponents=\"" << 3 <<
"\" "
777 <<
"format=\"ascii\">\n";
780 this->output_paraview(file_out, nplot);
783 file_out <<
"</DataArray>\n"
789 file_out <<
"<Cells>\n"
790 <<
"<DataArray type=\"Int32\" Name=\""
791 <<
"connectivity\" format=\"ascii\">\n";
795 unsigned counter = 0;
798 this->write_paraview_output_offset_information(file_out, nplot, counter);
801 file_out <<
"</DataArray>\n"
802 <<
"<DataArray type=\"Int32\" "
803 <<
"Name=\"offsets\" format=\"ascii\">\n";
806 unsigned offset_sum = 0;
809 this->write_paraview_offsets(file_out, nplot, offset_sum);
812 file_out <<
"</DataArray>\n"
813 <<
"<DataArray type=\"UInt8\" Name=\"types\">\n";
816 this->write_paraview_type(file_out, nplot);
819 file_out <<
"</DataArray>\n"
825 file_out <<
"</Piece>\n"
826 <<
"</UnstructuredGrid>\n"
A Class for the derivatives of shape functions The class design is essentially the same as Shape,...
void(* SteadyExactSolutionFctPt)(const Vector< double > &, Vector< double > &)
Function pointer for function that computes vector-valued steady "exact solution" as .
void(* UnsteadyExactSolutionFctPt)(const double &, const Vector< double > &, Vector< double > &)
Function pointer for function that computes Vector-valued time-dependent function as .
virtual unsigned self_test()
Self-test: Check inversion of element & do self-test for GeneralisedElement. Return 0 if OK.
//////////////////////////////////////////////////////////////////////// ////////////////////////////...
static const unsigned Initial_Nvalue
Static array of ints to hold number of variables at nodes: Initial_Nvalue[n].
A Class for shape functions. In simple cases, the shape functions have only one index that can be tho...
void output_fct(std::ostream &outfile, const unsigned &nplot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Output exact soln: x,y,u_exact or x,y,z,u_exact at nplot^SPATIAL_DIM plot points.
void compute_error(std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt, double &error, double &norm)
Get error and norm against exact solution.
void compute_norm(double &norm)
Compute norm of FE solution.
unsigned self_test()
Self-test: Return 0 for OK.
static double Default_beta_parameter
Static default value for the Beta parameter (thermal conductivity): One for natural scaling.
void output(std::ostream &outfile)
Output with default number of plot points.
virtual void fill_in_generic_residual_contribution_ust_heat(Vector< double > &residuals, DenseMatrix< double > &jacobian, const unsigned &flag)
Compute element residual Vector only (if flag=and/or element Jacobian matrix.
void output_element_paraview(std::ofstream &outfile, const unsigned &nplot)
C-style output FE representation of soln: x,y,u or x,y,z,u at nplot^SPATIAL_DIM plot points.
static double Default_alpha_parameter
Static default value for the Alpha parameter (thermal inertia): One for natural scaling.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...