discontinuous_galerkin_space_time_unsteady_heat_mixed_order_elements.cc
Go to the documentation of this file.
1 // LIC// ====================================================================
2 // LIC// This file forms part of oomph-lib, the object-oriented,
3 // LIC// multi-physics finite-element library, available
4 // LIC// at http://www.oomph-lib.org.
5 // LIC//
6 // LIC// Copyright (C) 2006-2023 Matthias Heil and Andrew Hazel
7 // LIC//
8 // LIC// This library is free software; you can redistribute it and/or
9 // LIC// modify it under the terms of the GNU Lesser General Public
10 // LIC// License as published by the Free Software Foundation; either
11 // LIC// version 2.1 of the License, or (at your option) any later version.
12 // LIC//
13 // LIC// This library is distributed in the hope that it will be useful,
14 // LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // LIC// Lesser General Public License for more details.
17 // LIC//
18 // LIC// You should have received a copy of the GNU Lesser General Public
19 // LIC// License along with this library; if not, write to the Free Software
20 // LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 // LIC// 02110-1301 USA.
22 // LIC//
23 // LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
24 // LIC//
25 // LIC//====================================================================
26 // Non-inline functions for SpaceTimeUnsteadyHeatMixedOrder elements
28 
29 /// //////////////////////////////////////////////////////////////////////
30 /// //////////////////////////////////////////////////////////////////////
31 /// //////////////////////////////////////////////////////////////////////
32 
33 namespace oomph
34 {
35  //======================================================================
36  // Default parameters
37  //======================================================================
38  /// Default value for Alpha parameter (thermal inertia)
39  template<unsigned SPATIAL_DIM>
40  double SpaceTimeUnsteadyHeatMixedOrderEquations<
41  SPATIAL_DIM>::Default_alpha_parameter = 1.0;
42 
43  /// Default value for Beta parameter (thermal conductivity)
44  template<unsigned SPATIAL_DIM>
45  double SpaceTimeUnsteadyHeatMixedOrderEquations<
46  SPATIAL_DIM>::Default_beta_parameter = 1.0;
47 
48  //======================================================================
49  // Set the data for the number of variables at each node
50  //======================================================================
51  template<unsigned SPATIAL_DIM, unsigned NNODE_1D>
52  const unsigned
53  QUnsteadyHeatMixedOrderSpaceTimeElement<SPATIAL_DIM,
54  NNODE_1D>::Initial_Nvalue = 1;
55 
56  //======================================================================
57  /// Compute element residual vector and/or element Jacobian matrix
58  ///
59  /// flag=0: compute only residual vector
60  /// flag=1: compute both
61  ///
62  /// Pure version without hanging nodes
63  //======================================================================
64  template<unsigned SPATIAL_DIM>
67  Vector<double>& residuals,
68  DenseMatrix<double>& jacobian,
69  const unsigned& flag)
70  {
71  // Find out how many nodes there are
72  unsigned n_node = nnode();
73 
74  // Find the index at which the variable is stored
75  unsigned u_nodal_index = u_index_ust_heat();
76 
77  // Set up memory for the shape functions
78  Shape psi(n_node);
79 
80  // Set up memory for the test functions
81  Shape test(n_node);
82 
83  // Allocate space for the derivatives of the shape functions
84  DShape dpsidx(n_node, SPATIAL_DIM + 1);
85 
86  // Allocate space for the derivatives of the test functions
87  DShape dtestdx(n_node, SPATIAL_DIM + 1);
88 
89  // Set the value of n_intpt
90  unsigned n_intpt = integral_pt()->nweight();
91 
92  // Storage for the local coordinates
93  Vector<double> s(SPATIAL_DIM + 1, 0.0);
94 
95  // Get the Alpha parameter
96  double alpha_local = alpha();
97 
98  // Get the Beta parameter
99  double beta_local = beta();
100 
101  // Integer to hold the local equation
102  int local_eqn = 0;
103 
104  // Integer to hold the local unknowns
105  int local_unknown = 0;
106 
107  // Loop over the integration points
108  for (unsigned ipt = 0; ipt < n_intpt; ipt++)
109  {
110  // Assign values of s
111  for (unsigned i = 0; i < SPATIAL_DIM + 1; i++)
112  {
113  // Calculate the i-th local coordinate
114  s[i] = integral_pt()->knot(ipt, i);
115  }
116 
117  // Get the integral weight
118  double w = integral_pt()->weight(ipt);
119 
120  // Call the derivatives of the shape and test functions
121  double J = dshape_and_dtest_eulerian_at_knot_ust_heat(
122  ipt, psi, dpsidx, test, dtestdx);
123 
124  // Premultiply the weights and the Jacobian
125  double W = w * J;
126 
127  // Storage for the interpolated time value
128  double interpolated_t = 0.0;
129 
130  // Storage for the interpolated solution value
131  double interpolated_u = 0.0;
132 
133  // Storage for the interpolated time-derivative of the solution
134  double interpolated_dudt = 0.0;
135 
136  // Storage for the spatial coordinates
137  Vector<double> interpolated_x(SPATIAL_DIM, 0.0);
138 
139  // Storage for the spatial derivatives of the solution
140  Vector<double> interpolated_dudx(SPATIAL_DIM, 0.0);
141 
142  // Storage for the mesh velocity
143  Vector<double> mesh_velocity(SPATIAL_DIM, 0.0);
144 
145  //-------------------------------------------------
146  // Calculate derivatives and source function value:
147  //-------------------------------------------------
148  // Loop over the nodes
149  for (unsigned l = 0; l < n_node; l++)
150  {
151  // Get the nodal value at the l-th node
152  double u_value = raw_nodal_value(l, u_nodal_index);
153 
154  // Update the interpolated time value
155  interpolated_t += raw_nodal_position(l, SPATIAL_DIM) * psi(l);
156 
157  // Loop over the coordinate directions (both spatial AND time)
158  for (unsigned j = 0; j < SPATIAL_DIM; j++)
159  {
160  // Update the interpolated x value
161  interpolated_x[j] += raw_nodal_position(l, j) * psi(l);
162 
163  // Update the interpolated du/dx_j value
164  interpolated_dudx[j] += u_value * dpsidx(l, j);
165  }
166 
167  // Update the interpolated u value
168  interpolated_u += u_value * psi(l);
169 
170  // Update the interpolated du/dt value
171  interpolated_dudt += u_value * dpsidx(l, SPATIAL_DIM);
172  } // for (unsigned l=0;l<n_node;l++)
173 
174  // Initialise the source term value
175  double source = 0.0;
176 
177  // Get the interpolated source term value
178  get_source_ust_heat(interpolated_t, ipt, interpolated_x, source);
179 
180  //---------------------------------
181  // Assemble residuals and Jacobian:
182  //---------------------------------
183  // Loop over the nodes (or equivalently the test functions)
184  for (unsigned l = 0; l < n_node; l++)
185  {
186  // Get the local equation number
187  local_eqn = nodal_local_eqn(l, u_nodal_index);
188 
189  // If it's not a boundary condition
190  if (local_eqn >= 0)
191  {
192  // Add source term and time derivative
193  residuals[local_eqn] +=
194  (source + alpha_local * interpolated_dudt) * test(l) * W;
195 
196  // Loop over the coordinate directions
197  for (unsigned k = 0; k < SPATIAL_DIM; k++)
198  {
199  // Add in the contribution from the Laplace operator
200  residuals[local_eqn] +=
201  beta_local * interpolated_dudx[k] * dtestdx(l, k) * W;
202  }
203 
204  //------------------------
205  // Calculate the Jacobian:
206  //------------------------
207  // If we also need to construct the Jacobian
208  if (flag)
209  {
210  // Loop over the velocity shape functions again
211  for (unsigned l2 = 0; l2 < n_node; l2++)
212  {
213  // Get the local equation number
214  local_unknown = nodal_local_eqn(l2, u_nodal_index);
215 
216  // If we're at a non-zero degree of freedom add in the entry
217  if (local_unknown >= 0)
218  {
219  // Add in the time derivative contribution
220  jacobian(local_eqn, local_unknown) +=
221  (alpha_local * test(l) * dpsidx(l2, SPATIAL_DIM) * W);
222 
223  // Laplace operator
224  for (unsigned i = 0; i < SPATIAL_DIM; i++)
225  {
226  // Add the test function contribution to the Jacobian
227  jacobian(local_eqn, local_unknown) +=
228  (beta_local * dpsidx(l2, i) * dtestdx(l, i) * W);
229  }
230  } // if (local_unknown>=0)
231  } // for (unsigned l2=0;l2<n_node;l2++)
232  } // if (flag)
233  } // if (local_eqn>=0)
234  } // for (unsigned l=0;l<n_node;l++)
235  } // for (unsigned ipt=0;ipt<n_intpt;ipt++)
236  } // End of fill_in_generic_residual_contribution_ust_heat
237 
238 
239  //======================================================================
240  /// Compute norm of FE solution
241  //======================================================================
242  template<unsigned SPATIAL_DIM>
244  double& norm)
245  {
246  // Initialise
247  norm = 0.0;
248 
249  // Vector of local coordinates
250  Vector<double> s(SPATIAL_DIM + 1, 0.0);
251 
252  // Vector for coordinates
253  Vector<double> x(SPATIAL_DIM + 1, 0.0);
254 
255  // Set the value of n_intpt
256  unsigned n_intpt = integral_pt()->nweight();
257 
258  // Loop over the integration points
259  for (unsigned ipt = 0; ipt < n_intpt; ipt++)
260  {
261  // Assign values of s
262  for (unsigned i = 0; i < SPATIAL_DIM + 1; i++)
263  {
264  // Get the i-th local coordinate at the ipt-th integration point
265  s[i] = integral_pt()->knot(ipt, i);
266  }
267 
268  // Get the integral weight
269  double w = integral_pt()->weight(ipt);
270 
271  // Get Jacobian of mapping
272  double J = J_eulerian(s);
273 
274  // Pre-multiply the weights and the Jacobian
275  double W = w * J;
276 
277  // Get FE function value
278  double u = interpolated_u_ust_heat(s);
279 
280  // Update the norm value
281  norm += u * u * W;
282  } // for (unsigned ipt=0;ipt<n_intpt;ipt++)
283  } // End of compute_norm
284 
285 
286  //======================================================================
287  /// Self-test: Return 0 for OK
288  //======================================================================
289  template<unsigned SPATIAL_DIM>
291  {
292  // Initialise the boolean variable
293  bool passed = true;
294 
295  // Check lower-level stuff
296  if (FiniteElement::self_test() != 0)
297  {
298  // If we get here then the lower-level self-tests did not pass
299  passed = false;
300  }
301 
302  // If the self-tests passed
303  if (passed)
304  {
305  // Return the value zero
306  return 0;
307  }
308  // If the self-tests didn't pass
309  else
310  {
311  // Return the value one
312  return 1;
313  }
314  } // End of self_test
315 
316 
317  //======================================================================
318  /// Output function:
319  /// x,t,u or x,y,t,u
320  /// at nplot points in each coordinate direction
321  //======================================================================
322  template<unsigned SPATIAL_DIM>
324  std::ostream& outfile, const unsigned& nplot)
325  {
326  // Vector of local coordinates
327  Vector<double> s(SPATIAL_DIM + 1, 0.0);
328 
329  // Tecplot header info
330  outfile << tecplot_zone_string(nplot);
331 
332  // Get the number of plot points
333  unsigned num_plot_points = nplot_points(nplot);
334 
335  // Loop over plot points
336  for (unsigned iplot = 0; iplot < num_plot_points; iplot++)
337  {
338  // Get local coordinates of plot point
339  get_s_plot(iplot, nplot, s);
340 
341  // Loop over the coordinate directions
342  for (unsigned i = 0; i < SPATIAL_DIM + 1; i++)
343  {
344  // Output the interpolated coordinate
345  outfile << interpolated_x(s, i) << " ";
346  }
347 
348  // Calculate the interpolated solution value
349  outfile << interpolated_u_ust_heat(s) << std::endl;
350  } // for (unsigned iplot=0;iplot<num_plot_points;iplot++)
351 
352  // Write tecplot footer (e.g. FE connectivity lists)
353  write_tecplot_zone_footer(outfile, nplot);
354  } // End of output
355 
356 
357  //======================================================================
358  /// C-style output function:
359  /// x,t,u or x,y,t,u
360  /// at nplot points in each coordinate direction
361  //======================================================================
362  template<unsigned SPATIAL_DIM>
364  FILE* file_pt, const unsigned& nplot)
365  {
366  // Vector of local coordinates
367  Vector<double> s(SPATIAL_DIM + 1, 0.0);
368 
369  // Tecplot header info
370  fprintf(file_pt, "%s", tecplot_zone_string(nplot).c_str());
371 
372  // Get the number of plot points
373  unsigned num_plot_points = nplot_points(nplot);
374 
375  // Loop over plot points
376  for (unsigned iplot = 0; iplot < num_plot_points; iplot++)
377  {
378  // Get local coordinates of plot point
379  get_s_plot(iplot, nplot, s);
380 
381  // Loop over the coordinate directions
382  for (unsigned i = 0; i < SPATIAL_DIM + 1; i++)
383  {
384  // Print the i-th coordinate value at local coordinate s
385  fprintf(file_pt, "%g ", interpolated_x(s, i));
386  }
387 
388  // Output the interpolated solution value at local coordinate s
389  fprintf(file_pt, "%g \n", interpolated_u_ust_heat(s));
390  } // for (unsigned iplot=0;iplot<num_plot_points;iplot++)
391 
392  // Write tecplot footer (e.g. FE connectivity lists)
393  write_tecplot_zone_footer(file_pt, nplot);
394  } // End of output
395 
396 
397  //======================================================================
398  /// Output exact solution at a given number of plot points:
399  /// x,t,u_exact or x,y,t,u_exact
400  /// Solution is provided via function pointer.
401  //======================================================================
402  template<unsigned SPATIAL_DIM>
404  std::ostream& outfile,
405  const unsigned& nplot,
407  {
408  // Vector of local coordinates
409  Vector<double> s(SPATIAL_DIM + 1, 0.0);
410 
411  // Vector for spatial coordinates
412  Vector<double> spatial_coordinates(SPATIAL_DIM, 0.0);
413 
414  // Tecplot header info
415  outfile << tecplot_zone_string(nplot);
416 
417  // Exact solution vector (here it's simply a scalar)
418  Vector<double> exact_soln(1, 0.0);
419 
420  // Get the number of plot points
421  unsigned num_plot_points = nplot_points(nplot);
422 
423  // Loop over plot points
424  for (unsigned iplot = 0; iplot < num_plot_points; iplot++)
425  {
426  // Get local coordinates of plot point
427  get_s_plot(iplot, nplot, s);
428 
429  // Loop over the spatial coordinates
430  for (unsigned i = 0; i < SPATIAL_DIM; i++)
431  {
432  // Assign the i-th spatial coordinate
433  spatial_coordinates[i] = interpolated_x(s, i);
434 
435  // Output the i-th coordinate at the point
436  outfile << spatial_coordinates[i] << " ";
437  }
438 
439  // Output the time value at this point
440  outfile << interpolated_x(s, SPATIAL_DIM) << " ";
441 
442  // Get the exact solution at this point
443  (*exact_soln_pt)(spatial_coordinates, exact_soln);
444 
445  // Output the exact solution at this point
446  outfile << exact_soln[0] << std::endl;
447  } // for (unsigned iplot=0;iplot<num_plot_points;iplot++)
448 
449  // Write tecplot footer (e.g. FE connectivity lists)
450  write_tecplot_zone_footer(outfile, nplot);
451  } // End of output_fct
452 
453 
454  //======================================================================
455  /// Output exact solution at a given number of plot points:
456  /// x,t,u_exact or x,y,t,u_exact
457  /// Solution is provided via function pointer.
458  //======================================================================
459  template<unsigned SPATIAL_DIM>
461  std::ostream& outfile,
462  const unsigned& nplot,
463  const double& time,
465  {
466  // Storage for the time value
467  double interpolated_t = 0.0;
468 
469  // Vector of local coordinates
470  Vector<double> s(SPATIAL_DIM + 1, 0.0);
471 
472  // Vector for spatial coordinates
473  Vector<double> spatial_coordinates(SPATIAL_DIM, 0.0);
474 
475  // Tecplot header info
476  outfile << tecplot_zone_string(nplot);
477 
478  // Exact solution vector (here it's simply a scalar)
479  Vector<double> exact_soln(1, 0.0);
480 
481  // Get the number of plot points
482  unsigned num_plot_points = nplot_points(nplot);
483 
484  // Loop over plot points
485  for (unsigned iplot = 0; iplot < num_plot_points; iplot++)
486  {
487  // Get local coordinates of plot point
488  get_s_plot(iplot, nplot, s);
489 
490  // Loop over the spatial coordinates
491  for (unsigned i = 0; i < SPATIAL_DIM; i++)
492  {
493  // Assign the i-th spatial coordinate
494  spatial_coordinates[i] = interpolated_x(s, i);
495 
496  // Output the i-th coordinate at the point
497  outfile << spatial_coordinates[i] << " ";
498  }
499 
500  // Get the time value
501  interpolated_t = interpolated_x(s, SPATIAL_DIM);
502 
503  // Output the time value at this point
504  outfile << interpolated_t << " ";
505 
506  // Get the exact solution at this point
507  (*exact_soln_pt)(interpolated_t, spatial_coordinates, exact_soln);
508 
509  // Output the exact solution at this point
510  outfile << exact_soln[0] << std::endl;
511  } // for (unsigned iplot=0;iplot<num_plot_points;iplot++)
512 
513  // Write tecplot footer (e.g. FE connectivity lists)
514  write_tecplot_zone_footer(outfile, nplot);
515  } // End of output_fct
516 
517 
518  //======================================================================
519  /// Validate against exact solution
520  ///
521  /// Solution is provided via function pointer.
522  /// Plot error at a given number of plot points.
523  //======================================================================
524  template<unsigned SPATIAL_DIM>
526  std::ostream& outfile,
528  double& error,
529  double& norm)
530  {
531  // Initialise error value
532  error = 0.0;
533 
534  // Initialise norm value
535  norm = 0.0;
536 
537  // Vector of local coordinates
538  Vector<double> s(SPATIAL_DIM + 1, 0.0);
539 
540  // Vector for spatial coordinates
541  Vector<double> spatial_coordinates(SPATIAL_DIM, 0.0);
542 
543  // Set the value of n_intpt
544  unsigned n_intpt = integral_pt()->nweight();
545 
546  // Tecplot header info
547  outfile << "ZONE" << std::endl;
548 
549  // Exact solution vector (here it's simply a scalar)
550  Vector<double> exact_soln(1, 0.0);
551 
552  // Loop over the integration points
553  for (unsigned ipt = 0; ipt < n_intpt; ipt++)
554  {
555  // Assign values of s
556  for (unsigned i = 0; i < SPATIAL_DIM + 1; i++)
557  {
558  // Get the i-th local coordinate at the ipt-th integration point
559  s[i] = integral_pt()->knot(ipt, i);
560  }
561 
562  // Get the integral weight
563  double w = integral_pt()->weight(ipt);
564 
565  // Get jacobian of mapping
566  double J = J_eulerian(s);
567 
568  // Premultiply the weights and the Jacobian
569  double W = w * J;
570 
571  // Get FE function value
572  double u_fe = interpolated_u_ust_heat(s);
573 
574  // Loop over the spatial coordinates
575  for (unsigned i = 0; i < SPATIAL_DIM; i++)
576  {
577  // Assign the i-th spatial coordinate
578  spatial_coordinates[i] = interpolated_x(s, i);
579 
580  // Output the i-th coordinate at the point
581  outfile << spatial_coordinates[i] << " ";
582  }
583 
584  // Output the i-th coordinate at this point
585  outfile << interpolated_x(s, SPATIAL_DIM) << " ";
586 
587  // Get exact solution at this point
588  (*exact_soln_pt)(spatial_coordinates, exact_soln);
589 
590  // Output the error
591  outfile << exact_soln[0] << " " << exact_soln[0] - u_fe << std::endl;
592 
593  // Add to (exact) solution norm value
594  norm += exact_soln[0] * exact_soln[0] * W;
595 
596  // Update the error norm value
597  error += (exact_soln[0] - u_fe) * (exact_soln[0] - u_fe) * W;
598  } // for (unsigned ipt=0;ipt<n_intpt;ipt++)
599  } // End of compute_error
600 
601 
602  //======================================================================
603  /// Validate against exact solution at time t.
604  ///
605  /// Solution is provided via function pointer.
606  /// Plot error at a given number of plot points.
607  //======================================================================
608  template<unsigned SPATIAL_DIM>
610  std::ostream& outfile,
612  const double& time,
613  double& error,
614  double& norm)
615  {
616  // Initialise error value
617  error = 0.0;
618 
619  // Initialise norm value
620  norm = 0.0;
621 
622  // Storage for the time value
623  double interpolated_t = 0.0;
624 
625  // Vector of local coordinates
626  Vector<double> s(SPATIAL_DIM + 1, 0.0);
627 
628  // Vector for spatial coordinates
629  Vector<double> spatial_coordinates(SPATIAL_DIM, 0.0);
630 
631  // Set the value of n_intpt
632  unsigned n_int_pt = integral_pt()->nweight();
633 
634  // Exact solution vector (here it's simply a scalar)
635  Vector<double> exact_soln(1, 0.0);
636 
637  // Loop over the integration points
638  for (unsigned ipt = 0; ipt < n_int_pt; ipt++)
639  {
640  // Assign values of s
641  for (unsigned i = 0; i < SPATIAL_DIM + 1; i++)
642  {
643  s[i] = integral_pt()->knot(ipt, i);
644  }
645 
646  // Get the integral weight
647  double w = integral_pt()->weight(ipt);
648 
649  // Get jacobian of mapping
650  double J = J_eulerian(s);
651 
652  // Premultiply the weights and the Jacobian
653  double W = w * J;
654 
655  // Get FE function value
656  double u_fe = interpolated_u_ust_heat(s);
657 
658  // Loop over the spatial coordinates
659  for (unsigned i = 0; i < SPATIAL_DIM; i++)
660  {
661  // Assign the i-th spatial coordinate
662  spatial_coordinates[i] = interpolated_x(s, i);
663  }
664 
665  // Get the time value
666  interpolated_t = interpolated_x(s, SPATIAL_DIM);
667 
668  // Get the exact solution at this point
669  (*exact_soln_pt)(interpolated_t, spatial_coordinates, exact_soln);
670 
671  // Add to (exact) solution norm value
672  norm += exact_soln[0] * exact_soln[0] * W;
673 
674  // Update the error norm value
675  error += (exact_soln[0] - u_fe) * (exact_soln[0] - u_fe) * W;
676  } // for (unsigned ipt=0;ipt<n_intpt;ipt++)
677 
678  // The number of plot points
679  unsigned n_plot = 3;
680 
681  // Tecplot header info
682  outfile << tecplot_zone_string(n_plot);
683 
684  // Get the number of plot points
685  unsigned num_plot_points = nplot_points(n_plot);
686 
687  // Loop over plot points
688  for (unsigned iplot = 0; iplot < num_plot_points; iplot++)
689  {
690  // Get local coordinates of plot point
691  get_s_plot(iplot, n_plot, s);
692 
693  // Loop over the spatial coordinates
694  for (unsigned i = 0; i < SPATIAL_DIM; i++)
695  {
696  // Assign the i-th spatial coordinate
697  spatial_coordinates[i] = interpolated_x(s, i);
698 
699  // Output the i-th coordinate at the point
700  outfile << spatial_coordinates[i] << " ";
701  }
702 
703  // Get the time value
704  interpolated_t = interpolated_x(s, SPATIAL_DIM);
705 
706  // Get FE function value
707  double u_fe = interpolated_u_ust_heat(s);
708 
709  // Output the time value at this point
710  outfile << interpolated_t << " ";
711 
712  // Get the exact solution at this point
713  (*exact_soln_pt)(interpolated_t, spatial_coordinates, exact_soln);
714 
715  // Output the exact solution at this point
716  outfile << exact_soln[0] - u_fe << std::endl;
717  } // for (unsigned iplot=0;iplot<num_plot_points;iplot++)
718 
719  // Write tecplot footer (e.g. FE connectivity lists)
720  write_tecplot_zone_footer(outfile, n_plot);
721  } // End of compute_error
722 
723 
724  //======================================================================
725  /// Output function:
726  /// x,t,u or x,y,t,u
727  /// at nplot points in each coordinate direction
728  //======================================================================
729  template<unsigned SPATIAL_DIM>
731  SPATIAL_DIM>::output_element_paraview(std::ofstream& file_out,
732  const unsigned& nplot)
733  {
734  // Change the scientific format so that E is used rather than e
735  file_out.setf(std::ios_base::uppercase);
736 
737  // Make variables to hold the number of nodes and elements
738  unsigned number_of_nodes = this->nplot_points_paraview(nplot);
739 
740  // Make variables to hold the number of elements
741  unsigned total_number_of_elements = this->nsub_elements_paraview(nplot);
742 
743  //------------------
744  // File Declaration:
745  //------------------
746  // Insert the necessary lines plus header of file, and
747  // number of nodes and elements
748  file_out << "<?xml version=\"1.0\"?>\n"
749  << "<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" "
750  << "byte_order=\"LittleEndian\">\n"
751  << "<UnstructuredGrid>\n"
752  << "<Piece NumberOfPoints=\"" << number_of_nodes
753  << "\" NumberOfCells=\"" << total_number_of_elements << "\">\n";
754 
755  //------------
756  // Point Data:
757  //------------
758  // Check the number of degrees of freedom
759  unsigned ndof = this->nscalar_paraview();
760 
761  // Point data is going in here
762  file_out << "<PointData ";
763 
764  // Insert just the first scalar name, since paraview reads everything
765  // else after that as being of the same type. Get information from
766  // first element.
767  file_out << "Scalars=\"" << this->scalar_name_paraview(0) << "\">\n";
768 
769  // Loop over i scalar fields and j number of elements
770  for (unsigned i = 0; i < ndof; i++)
771  {
772  file_out << "<DataArray type=\"Float32\" "
773  << "Name=\"" << this->scalar_name_paraview(i) << "\" "
774  << "format=\"ascii\""
775  << ">\n";
776 
777  // Output the i-th scalar field with nplot plot points
778  this->scalar_value_paraview(file_out, i, nplot);
779 
780  // Close of the DataArray
781  file_out << "</DataArray>\n";
782  }
783 
784  // Close off the PointData set
785  file_out << "</PointData>\n";
786 
787  //------------------
788  // Geometric Points:
789  //------------------
790  // Always has to be 3 components for an unstructured grid
791  file_out << "<Points>\n"
792  << "<DataArray type=\"Float32\""
793  << " NumberOfComponents=\"" << 3 << "\" "
794  << "format=\"ascii\">\n";
795 
796  // Print the plot points
797  this->output_paraview(file_out, nplot);
798 
799  // Close off the geometric points set
800  file_out << "</DataArray>\n"
801  << "</Points>\n";
802 
803  //-------
804  // Cells:
805  //-------
806  file_out << "<Cells>\n"
807  << "<DataArray type=\"Int32\" Name=\""
808  << "connectivity\" format=\"ascii\">\n";
809 
810  // Make counter for keeping track of all the local elements,
811  // because Paraview requires global coordinates
812  unsigned counter = 0;
813 
814  // Write connectivity with the local elements
815  this->write_paraview_output_offset_information(file_out, nplot, counter);
816 
817  // Output header stuff
818  file_out << "</DataArray>\n"
819  << "<DataArray type=\"Int32\" "
820  << "Name=\"offsets\" format=\"ascii\">\n";
821 
822  // Make variable that holds the current offset number
823  unsigned offset_sum = 0;
824 
825  // Write the offset for the specific elements
826  this->write_paraview_offsets(file_out, nplot, offset_sum);
827 
828  // Add in header information
829  file_out << "</DataArray>\n"
830  << "<DataArray type=\"UInt8\" Name=\"types\">\n";
831 
832  // Get the type the element has
833  this->write_paraview_type(file_out, nplot);
834 
835  // Finish off the data set
836  file_out << "</DataArray>\n"
837  << "</Cells>\n";
838 
839  //--------------
840  // File Closure:
841  //--------------
842  file_out << "</Piece>\n"
843  << "</UnstructuredGrid>\n"
844  << "</VTKFile>";
845  } // End of output_element_paraview
846 
847 
848  //====================================================================
849  // Force build of templates
850  //====================================================================
854 } // End of namespace oomph
static char t char * s
Definition: cfortran.h:568
cstr elem_len * i
Definition: cfortran.h:603
A Class for the derivatives of shape functions The class design is essentially the same as Shape,...
Definition: shape.h:278
void(* SteadyExactSolutionFctPt)(const Vector< double > &, Vector< double > &)
Function pointer for function that computes vector-valued steady "exact solution" as .
Definition: elements.h:1759
void(* UnsteadyExactSolutionFctPt)(const double &, const Vector< double > &, Vector< double > &)
Function pointer for function that computes Vector-valued time-dependent function as .
Definition: elements.h:1765
virtual unsigned self_test()
Self-test: Check inversion of element & do self-test for GeneralisedElement. Return 0 if OK.
Definition: elements.cc:4440
//////////////////////////////////////////////////////////////////////// ////////////////////////////...
A Class for shape functions. In simple cases, the shape functions have only one index that can be tho...
Definition: shape.h:76
A class for all isoparametric elements that solve the SpaceTimeUnsteadyHeatMixedOrder equations.
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 compute_error(std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt, double &error, double &norm)
Get error and norm against exact solution.
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.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...