LifeV
hyperbolic.cpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3 *******************************************************************************
4 
5  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
7 
8  This file is part of LifeV.
9 
10  LifeV is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  LifeV is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with LifeV. If not, see <http://www.gnu.org/licenses/>.
22 
23 *******************************************************************************
24 */
25 //@HEADER
26 /**
27  \file hyperbolic.cpp
28  \author A. Fumagalli <alessio.fumagalli@mail.polimi.it>
29  \date 2010-07-29
30  */
31 
32 /*!
33  Simple 3D hyperbolic test with Dirichlet, Neumann and Robin Boundary condition.
34 */
35 
36 // ===================================================
37 //! Includes
38 // ===================================================
39 
40 #include "hyperbolic.hpp"
41 // ===================================================
42 //! Namespaces & define
43 // ===================================================
44 
45 using namespace LifeV;
46 
47 enum BCNAME
48 {
49  BACK = 1,
50  FRONT = 2,
51  LEFT = 3,
52  RIGHT = 4,
53  BOTTOM = 5,
54  TOP = 6
55 };
56 
57 // ===================================================
58 //! User functions
59 // ===================================================
60 namespace dataProblem
61 {
62 const Real Pi = 3.14159265358979323846264338328;
63 
64 // Analytical solution
66  const Real& x,
67  const Real& y,
68  const Real& /* z */,
69  const ID& /* ic */)
70 {
71  //Real u1 = 5;
72  //if ( ( x <= u1*(t+0.25)/2 && x >= u1*(t - 0.15)/2 ) && ( y >= 0.25 && y <= 0.75 ) && ( z >= 0.25 && z <= 0.75 ) )
73  /// return 1;
74  //else
75  // return 0;
76  return 20.*std::exp ( - ( std::pow ( x * std::cos (2.*Pi * t) + y * std::sin (2.*Pi * t), 2.) + std::pow ( - x * std::sin (2.*Pi * t) + y * std::cos (2.*Pi * t), 2. ) ) );
77 }
78 
79 // Physical flux function
80 Vector physicalFlux ( const Real& /* t */,
81  const Real& x,
82  const Real& y,
83  const Real& /* z */,
84  const std::vector<Real>& u )
85 {
86  Vector physicalFluxVector ( static_cast<UInt> (3) );
87 
88  // First row
89  Real Entry0 = y * u[0] * u[1]; //u[0]*u[0]*u[1];
90 
91  // Second row
92  Real Entry1 = x * u[0] * u[2]; //u[2];
93 
94  // Third row
95  Real Entry2 = u[3];
96 
97  physicalFluxVector ( static_cast<UInt> (0) ) = Entry0;
98  physicalFluxVector ( static_cast<UInt> (1) ) = Entry1;
99  physicalFluxVector ( static_cast<UInt> (2) ) = Entry2;
100 
101  return physicalFluxVector;
102 }
103 
104 // First derivative in u of the physical flux function
105 Vector firstDerivativePhysicalFlux ( const Real& /* t */,
106  const Real& x,
107  const Real& y,
108  const Real& /* z */,
109  const std::vector<Real>& u )
110 {
111  Vector firstDerivativePhysicalFluxVector ( static_cast<UInt> (3) );
112 
113  // First row
114  Real Entry0 = y * u[1]; //2.*u[0]*u[1];
115 
116  // Second row
117  Real Entry1 = x * u[2]; //0.;
118 
119  // Third row
120  Real Entry2 = 0.;
121 
122  firstDerivativePhysicalFluxVector ( static_cast<UInt> (0) ) = Entry0;
123  firstDerivativePhysicalFluxVector ( static_cast<UInt> (1) ) = Entry1;
124  firstDerivativePhysicalFluxVector ( static_cast<UInt> (2) ) = Entry2;
125 
126  return firstDerivativePhysicalFluxVector;
127 }
128 
129 // Initial time condition
130 Real dual ( const Real& /* t */,
131  const Real& /* x */,
132  const Real& /* y */,
133  const Real& /* z */,
134  const ID& ic )
135 {
136  switch ( ic )
137  {
138  case 0:
139  return -2.*Pi;//5
140  break;
141  case 1:
142  return 2.*Pi; //0
143  break;
144  case 2:
145  return 0.;
146  break;
147  }
148  return 0.;
149 }
150 
151 // Initial time condition
152 Real initialCondition ( const Real& /* t */,
153  const Real& x,
154  const Real& y,
155  const Real& z,
156  const ID& ic )
157 {
158  return analyticalSolution ( 0., x, y, z, ic );
159 }
160 
161 // Mass function
162 Real mass ( const Real& /* t */,
163  const Real& /* x */,
164  const Real& /* y */,
165  const Real& /* z */,
166  const ID& /* ic */ )
167 {
168  return 1.;
169 }
170 
171 // Boundary condition of Dirichlet
172 Real dirichlet ( const Real& t,
173  const Real& x,
174  const Real& y,
175  const Real& z,
176  const ID& ic )
177 {
178  return analyticalSolution ( t, x, y, z, ic );
179 }
180 
181 
182 // Source term
183 Real source_in ( const Real& /* t */,
184  const Real& /* x */,
185  const Real& /* y */,
186  const Real& /* z */,
187  const ID& /* icomp */)
188 {
189  return 0.;
190 }
191 
192 // Standard functions
193 Real UOne ( const Real& /* t */,
194  const Real& /* x */,
195  const Real& /* y */,
196  const Real& /* z */,
197  const ID& /* icomp */)
198 {
199  return 1.;
200 }
201 
202 Real UZero ( const Real& /* t */,
203  const Real& /* x */,
204  const Real& /* y */,
205  const Real& /* z */,
206  const ID& /* icomp */)
207 {
208  return 0.;
209 }
210 
211 }
212 // ===================================================
213 //! Private Members
214 // ===================================================
215 
217 {
218  Private() {}
219 
220  // Policy for scalar functions
221  typedef std::function < Real ( const Real&, const Real&,
222  const Real&, const Real&, const ID& ) >
224 
225  // Policy for the flux function
226  typedef std::function < Vector ( const Real&, const Real&,
227  const Real&, const Real&,
228  const std::vector<Real>& ) >
230 
233 
235 
236  // Function Types
237 
239  {
240  fct_type f;
241  f = std::bind ( &dataProblem::UOne, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 );
242  return f;
243  }
244 
246  {
247  fct_type f;
248  f = std::bind ( &dataProblem::UZero, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 );
249  return f;
250  }
251 
253  {
254  fct_type f;
255  f = std::bind ( &dataProblem::analyticalSolution, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 );
256  return f;
257  }
258 
260  {
261  vectorFct_type f;
262  f = std::bind ( &dataProblem::physicalFlux, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 );
263  return f;
264  }
265 
267  {
268  vectorFct_type f;
269  f = std::bind ( &dataProblem::firstDerivativePhysicalFlux, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 );
270  return f;
271  }
272 
274  {
275  fct_type f;
276  f = std::bind ( &dataProblem::source_in, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 );
277  return f;
278  }
279 
281  {
282  fct_type f;
283  f = std::bind ( &dataProblem::initialCondition, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 );
284  return f;
285  }
286 
288  {
289  fct_type f;
290  f = std::bind ( & dataProblem::initialCondition, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 );
291  return f;
292  }
293 
295  {
296  fct_type f;
297  f = std::bind ( & dataProblem::dual, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 );
298  return f;
299  }
300 
301 };
302 
303 // ===================================================
304 //! Constructors
305 // ===================================================
306 
307 hyperbolic::hyperbolic ( int argc,
308  char** argv )
309  : Members ( new Private )
310 {
311  GetPot command_line (argc, argv);
312  const std::string data_file_name = command_line.follow ("data", 2, "-f", "--file");
313  GetPot dataFile ( data_file_name );
314 
315  Members->data_file_name = data_file_name;
316  Members->discretization_section = "hyperbolic";
317 
318 #ifdef EPETRA_MPI
319  std::cout << "Epetra Initialization" << std::endl;
320  Members->comm.reset ( new Epetra_MpiComm ( MPI_COMM_WORLD ) );
321 #else
322  Members->comm.reset ( new Epetra_SerialComm() );
323 #endif
324 
325 }
326 
327 // ===================================================
328 //! Methods
329 // ===================================================
330 
331 Real
333 {
334  typedef RegionMesh<LinearTetra, neighborMarkerCommon_Type> RegionMesh;
335  typedef SolverAztecOO solver_type;
336  typedef HyperbolicSolver< RegionMesh, solver_type > hyper;
337  typedef hyper::vector_Type vector_type;
338  typedef std::shared_ptr<vector_type> vector_ptrtype;
339  typedef FESpace< RegionMesh, MapEpetra > feSpace_Type;
340  typedef std::shared_ptr< feSpace_Type > feSpacePtr_Type;
341 
342  LifeChrono chronoTotal;
343  LifeChrono chronoReadAndPartitionMesh;
344  LifeChrono chronoBoundaryCondition;
345  LifeChrono chronoFiniteElementSpace;
346  LifeChrono chronoProblem;
347  LifeChrono chronoProcess;
348  LifeChrono chronoTimeStep;
349  LifeChrono chronoError;
350 
351  // Start chronoTotal for measure the total time for the computation
352  chronoTotal.start();
353 
354  // Reading from data file
355  GetPot dataFile ( Members->data_file_name.c_str() );
356 
357  // Create the leader process, i.e. the process with MyPID equal to zero
358  bool isLeader = ( Members->comm->MyPID() == 0 );
359 
360  //
361  // The Hyperbolic Solver
362  //
363 
364  if ( isLeader )
365  {
366  std::cout << "The hyperbolic solver" << std::endl << std::flush;
367  }
368 
369  // Start chronoReadAndPartitionMesh for measure the total time for the creation of the local meshes
370  chronoReadAndPartitionMesh.start();
371 
372  // Create the data file
373  HyperbolicData<RegionMesh> dataHyperbolic;
374 
375  // Set up the data
376  dataHyperbolic.setup ( dataFile );
377 
378  // Create the mesh file handler
379  MeshData meshData;
380 
381  // Set up the mesh file
382  meshData.setup ( dataFile, Members->discretization_section + "/space_discretization");
383 
384  // Create the mesh
385  std::shared_ptr<RegionMesh> fullMeshPtr ( new RegionMesh ( Members->comm ) );
386 
387  // Set up the mesh
388  readMesh ( *fullMeshPtr, meshData );
389 
390  // Partition the mesh using ParMetis
391  std::shared_ptr<RegionMesh> meshPtr;
392  {
393  MeshPartitioner< RegionMesh > meshPart ( fullMeshPtr, Members->comm );
394  meshPtr = meshPart.meshPartition();
395  }
396 
397  // Stop chronoReadAndPartitionMesh
398  chronoReadAndPartitionMesh.stop();
399 
400  // The leader process print chronoReadAndPartitionMesh
401  if ( isLeader )
402  std::cout << "Time for read and partition the mesh " <<
403  chronoReadAndPartitionMesh.diff() << std::endl << std::flush;
404 
405  // Create the boundary conditions
406 
407  // Start chronoBoundaryCondition for measure the total time for create the boundary conditions
408  chronoBoundaryCondition.start();
409 
410  BCFunctionBase dirichletBDfun;
411 
412  dirichletBDfun.setFunction ( dataProblem::dirichlet );
413 
414  BCHandler bcHyperbolic;
415 
416  bcHyperbolic.addBC ( "Top", TOP, Essential, Scalar, dirichletBDfun );
417  bcHyperbolic.addBC ("Bottom", BOTTOM, Essential, Scalar, dirichletBDfun );
418  bcHyperbolic.addBC ( "Left", LEFT, Essential, Scalar, dirichletBDfun );
419  bcHyperbolic.addBC ( "Right", RIGHT, Essential, Scalar, dirichletBDfun );
420  bcHyperbolic.addBC ( "Front", FRONT, Essential, Scalar, dirichletBDfun );
421  bcHyperbolic.addBC ( "Back", BACK, Essential, Scalar, dirichletBDfun );
422 
423  // Stop chronoBoundaryCondition
424  chronoBoundaryCondition.stop();
425 
426  // The leader process print chronoBoundaryCondition
427  if ( isLeader )
428  {
429  std::cout << "Time for create the boundary conditions handler " <<
430  chronoBoundaryCondition.diff() << std::endl << std::flush;
431 
432  }
433 
434  // Create the solution spaces
435 
436  // Start chronoFiniteElementSpace for measure the total time for create the finite element spaces
437  chronoFiniteElementSpace.start();
438 
439  // Primal solution parameters
440  const ReferenceFE* refFE ( static_cast<ReferenceFE*> (NULL) );
441  const QuadratureRule* qR ( static_cast<QuadratureRule*> (NULL) );
442  const QuadratureRule* bdQr ( static_cast<QuadratureRule*> (NULL) );
443 
444  refFE = &feTetraP0;
445  qR = &quadRuleTetra15pt;
446  bdQr = &quadRuleTria1pt;
447 
448  // Interpolate of dual solution parameters.
449  const ReferenceFE* pressure_refFE_dualInterpolate ( static_cast<ReferenceFE*> (NULL) );
450  const QuadratureRule* pressure_qR_dualInterpolate ( static_cast<QuadratureRule*> (NULL) );
451  const QuadratureRule* pressure_bdQr_dualInterpolate ( static_cast<QuadratureRule*> (NULL) );
452 
453  pressure_refFE_dualInterpolate = &feTetraP0;
454  pressure_qR_dualInterpolate = &quadRuleTetra15pt;
455  pressure_bdQr_dualInterpolate = &quadRuleTria4pt;
456 
457  // Finite element space of the interpolation of dual variable.
458  FESpace< RegionMesh, MapEpetra > pressure_uInterpolate_FESpace ( meshPtr, *pressure_refFE_dualInterpolate, *pressure_qR_dualInterpolate,
459  *pressure_bdQr_dualInterpolate, 3, Members->comm );
460 
461  // Vector for the interpolated dual solution.
462  vector_ptrtype pressure_dualInterpolated ( new vector_type ( pressure_uInterpolate_FESpace.map(), Repeated ) );
463 
464  pressure_uInterpolate_FESpace.interpolate ( static_cast<FESpace< RegionMesh, MapEpetra >::function_Type> ( dataProblem::dual ), *pressure_dualInterpolated, 0 );
465 
466  // Finite element space
467  feSpacePtr_Type feSpacePtr ( new feSpace_Type ( meshPtr,
468  *refFE,
469  *qR,
470  *bdQr,
471  1,
472  Members->comm ) );
473 
474  GhostHandler<RegionMesh> ghost ( fullMeshPtr, meshPtr, feSpacePtr->mapPtr(), Members->comm );
475 
476  // Stop chronoFiniteElementSpace
477  chronoFiniteElementSpace.stop();
478 
479  // The leader process print chronoFiniteElementSpace
480  if ( isLeader )
481  std::cout << "Time for create the finite element spaces " <<
482  chronoFiniteElementSpace.diff() << std::endl << std::flush;
483 
484  // Start chronoProblem for measure the total time for create the problem
485  chronoProblem.start();
486 
487  // Instantiation of the HyperbolicSolver class
488  hyper hyperbolicSolver ( dataHyperbolic,
489  *feSpacePtr,
490  ghost.ghostMapOnElementsFV(),
491  Members->comm );
492 
493  // Stop chronoProblem
494  chronoProblem.stop();
495 
496  // The leader process print chronoProblem
497  hyperbolicSolver.getDisplayer().leaderPrint ( "Time for create the problem ",
498  chronoProblem.diff(), "\n" );
499 
500  // Process the problem
501 
502  // Start chronoProcess for measure the total time for the simulation
503  chronoProcess.start();
504 
505  // Setup phase
506  hyperbolicSolver.setup();
507 
508  // Set the source term
509  hyperbolicSolver.setSourceTerm ( Members->getSource() );
510 
511  // Set the initial solution
512  hyperbolicSolver.setInitialSolution ( Members->getInitialCondition() );
513 
514  // Set the mass function
515  hyperbolicSolver.setMassTerm ( Members->getMass() );
516 
517  // Create the numerical flux.
518  GodunovNumericalFlux < RegionMesh > numericalFlux ( Members->getPhysicalFlux(),
519  Members->getFirstDerivativePhysicalFlux(),
520  pressure_uInterpolate_FESpace,
521  dataFile,
522  "hyperbolic/numerical_flux/" );
523 
524  // Set the dependence field
525  numericalFlux.setExternalField ( pressure_dualInterpolated );
526 
527  // Set the numerical flux usign the physical flux
528  hyperbolicSolver.setNumericalFlux ( numericalFlux );
529 
530  // Set the boudary conditions
531  hyperbolicSolver.setBoundaryCondition ( bcHyperbolic );
532 
533  // Set the exporter for the solution
534  std::shared_ptr< Exporter< RegionMesh > > exporter;
535 
536  // Shared pointer used in the exporter for the solution
537  vector_ptrtype exporterSolution;
538 
539  // Type of the exporter
540  std::string const exporterType = dataFile ( "exporter/type", "ensight");
541 
542  // Choose the exporter
543 #ifdef HAVE_HDF5
544  if ( exporterType.compare ("hdf5") == 0 )
545  {
546  exporter.reset ( new ExporterHDF5< RegionMesh > ( dataFile, dataFile ( "exporter/file_name", "Concentration" ) ) );
547 
548  // Set directory where to save the solution
549  exporter->setPostDir ( dataFile ( "exporter/folder", "./" ) );
550 
551  exporter->setMeshProcId ( meshPtr, Members->comm->MyPID() );
552  }
553  else
554 #endif
555  {
556  if ( exporterType.compare ("none") == 0 )
557  {
558  exporter.reset ( new ExporterEmpty< RegionMesh > ( dataFile, dataFile ( "exporter/file_name", "Concentration" ) ) );
559 
560  // Set directory where to save the solution
561  exporter->setPostDir ( dataFile ( "exporter/folder", "./" ) );
562 
563  exporter->setMeshProcId ( meshPtr, Members->comm->MyPID() );
564  }
565  else
566  {
567  exporter.reset ( new ExporterEnsight< RegionMesh > ( dataFile, dataFile ( "exporter/file_name", "Concentration" ) ) );
568 
569  // Set directory where to save the solution
570  exporter->setPostDir ( dataFile ( "exporter/folder", "./" ) );
571 
572  exporter->setMeshProcId ( meshPtr, Members->comm->MyPID() );
573  }
574  }
575 
576  // Export the partitioning
577  exporter->exportPID ( meshPtr, Members->comm );
578 
579  // export the flags set on the mesh
580  exporter->exportFlags ( meshPtr, Members->comm );
581 
582  // Set the exporter solution
583  exporterSolution.reset ( new vector_type ( *hyperbolicSolver.solution(),
584  exporter->mapType() ) );
585 
586  // Add the solution to the exporter
587  exporter->addVariable ( ExporterData<RegionMesh>::ScalarField,
588  "Concentration", feSpacePtr,
589  exporterSolution,
590  static_cast<UInt> ( 0 ),
591  ExporterData<RegionMesh>::UnsteadyRegime,
592  ExporterData<RegionMesh>::Cell );
593 
594  // Display the total number of unknowns
595  hyperbolicSolver.getDisplayer().leaderPrint ( "Number of unknowns : ",
596  feSpacePtr->map().map (Unique)->NumGlobalElements(), "\n" );
597 
598  // Solve the problem
599 
600  // Save the initial primal
601 
602  // Copy the initial solution to the exporter
603  *exporterSolution = *hyperbolicSolver.solution();
604 
605  // Save the initial solution into the exporter
606  exporter->postProcess ( dataHyperbolic.dataTime()->initialTime() );
607 
608  // Changing time step for the simulation
609  Real timeStep (0.);
610 
611  // Flag for the last time step that does not coincide with the last advance
612  bool isLastTimeStep ( false );
613 
614  // A loop for the simulation, it starts from \Delta t and end in N \Delta t = T
615  while ( dataHyperbolic.dataTime()->canAdvance() && !isLastTimeStep )
616  {
617 
618  // Start chronoTimeStep for measure the time for the current time step
619  chronoTimeStep.start();
620 
621  // Check if the time step is consistent, i.e. if innerTimeStep + currentTime < endTime.
622  if ( dataHyperbolic.dataTime()->isLastTimeStep() )
623  {
624  // Compute the last time step.
625  timeStep = dataHyperbolic.dataTime()->leftTime();
626 
627  // This is the last time step in the simulation
628  isLastTimeStep = true;
629  }
630  else
631  {
632  // Compute the new time step according to the CFL condition.
633  timeStep = hyperbolicSolver.CFL();
634  }
635 
636  // Set the last time step for the simulation.
637  dataHyperbolic.dataTime()->setTimeStep ( timeStep );
638 
639  // Update time
640  dataHyperbolic.dataTime()->updateTime();
641 
642  // The leader process prints the temporal data.
643  if ( hyperbolicSolver.getDisplayer().isLeader() )
644  {
645  dataHyperbolic.dataTime()->showMe();
646  }
647 
648  // solve one step of the hyperbolic problem.
649  hyperbolicSolver.solveOneTimeStep();
650 
651  // Save the solution
652 
653  // Copy the solution to the exporter
654  *exporterSolution = *hyperbolicSolver.solution();
655 
656  // update the total time
657  dataHyperbolic.dataTime()->updateTime();
658 
659  // Save the solution into the exporter
660  exporter->postProcess ( dataHyperbolic.dataTime()->time() );
661 
662  // Stop chronoTimeStep
663  chronoTimeStep.stop();
664 
665  // The leader process print chronoTimeStep
666  hyperbolicSolver.getDisplayer().leaderPrint ( "Time for current time step ",
667  chronoTimeStep.diff(), "\n" );
668 
669  }
670 
671  // Stop chronoProcess
672  chronoProcess.stop();
673 
674  // The leader process print chronoProcess
675  hyperbolicSolver.getDisplayer().leaderPrint ( "Time for process ",
676  chronoProcess.diff(), "\n" );
677 
678  // Compute the errors
679 
680  // Start chronoError for measure the total time for computing the errors.
681  chronoError.start();
682 
683  // Compute the error L2 norms
684  Real L2Norm (0), exactL2Norm (0), L2Error (0), L2RelativeError (0);
685 
686  // Norms and errors for the pressure
687  hyperbolicSolver.getDisplayer().leaderPrint ( "\nERROR\n" );
688 
689  // Compute the L2 norm for the solution
690  L2Norm = feSpacePtr->l2Norm ( *hyperbolicSolver.solution() );
691 
692  // Display the L2 norm for the solution
693  hyperbolicSolver.getDisplayer().leaderPrint ( " L2 norm of solution: ",
694  L2Norm, "\n" );
695 
696  // Compute the L2 norm for the analytical solution
697  exactL2Norm = feSpacePtr->l2NormFunction ( Members->getAnalyticalSolution(),
698  dataHyperbolic.dataTime()->endTime() );
699 
700  // Display the L2 norm for the analytical solution
701  hyperbolicSolver.getDisplayer().leaderPrint ( " L2 norm of exact solution: ",
702  exactL2Norm, "\n" );
703 
704  // Compute the L2 error for the solution
705  L2Error = feSpacePtr->l2ErrorWeighted ( Members->getAnalyticalSolution(),
706  *hyperbolicSolver.solution(),
707  Members->getUOne(),
708  dataHyperbolic.dataTime()->endTime() );
709 
710  // Display the L2 error for the solution
711  hyperbolicSolver.getDisplayer().leaderPrint ( " L2 error: ",
712  L2Error, "\n" );
713 
714  // Compute the L2 realative error for the solution
715  L2RelativeError = L2Error / L2Norm;
716 
717  // Display the L2 relative error for the solution
718  hyperbolicSolver.getDisplayer().leaderPrint ( " L2 relative error: ",
719  L2RelativeError, "\n" );
720 
721  // Stop chronoError
722  chronoError.stop();
723 
724  // The leader process print chronoError
725  hyperbolicSolver.getDisplayer().leaderPrint ( "Time for compute errors ",
726  chronoError.diff(), "\n" );
727 
728  // Stop chronoTotal
729  chronoTotal.stop();
730 
731  // The leader process print chronoTotal
732  hyperbolicSolver.getDisplayer().leaderPrint ( "Total time for the computation ",
733  chronoTotal.diff(), "\n" );
734 
735  // Return the error, needed for the succes/failure of the test
736  return L2Error;
737 
738 }
Real UOne(const Real &, const Real &, const Real &, const Real &, const ID &)
Definition: hyperbolic.cpp:193
Real dirichlet(const Real &t, const Real &x, const Real &y, const Real &z, const ID &ic)
Definition: hyperbolic.cpp:172
hyperbolic(int argc, char **argv)
Constructors.
Definition: hyperbolic.cpp:307
Real dual(const Real &, const Real &, const Real &, const Real &, const ID &ic)
Definition: hyperbolic.cpp:130
BCNAME
Definition: impes.cpp:44
FESpace - Short description here please!
Definition: FESpace.hpp:78
const QuadratureRule quadRuleTetra15pt(pt_tetra_15pt, 5, "Quadrature rule 15 points on a tetraedra", TETRA, 15, 5)
const QuadratureRule quadRuleTria4pt(pt_tria_4pt, 3, "Quadrature rule 4 points on a triangle", TRIANGLE, 4, 3)
Real UZero(const Real &, const Real &, const Real &, const Real &, const ID &)
Definition: hyperbolic.cpp:202
vectorFct_type getPhysicalFlux()
Definition: hyperbolic.cpp:259
vectorFct_type getFirstDerivativePhysicalFlux()
Definition: hyperbolic.cpp:266
Includes.
Definition: hyperbolic.hpp:60
Vector firstDerivativePhysicalFlux(const Real &, const Real &x, const Real &y, const Real &, const std::vector< Real > &u)
Definition: hyperbolic.cpp:105
std::string discretization_section
Definition: hyperbolic.cpp:232
Real initialCondition(const Real &, const Real &x, const Real &y, const Real &z, const ID &ic)
Definition: hyperbolic.cpp:152
uint32_type ID
IDs.
Definition: LifeV.hpp:194
Class for 3D, 2D and 1D Mesh.
Definition: RegionMesh.hpp:87
std::function< Real(const Real &, const Real &, const Real &, const Real &, const ID &) > fct_type
Definition: hyperbolic.cpp:223
std::shared_ptr< std::vector< Int > > M_isOnProc
std::function< Vector(const Real &, const Real &, const Real &, const Real &, const std::vector< Real > &) > vectorFct_type
Definition: hyperbolic.cpp:229
MeshData - class for handling spatial discretization.
Definition: MeshData.hpp:72
HyperbolicSolver Implements an hyperbolic solver.
std::shared_ptr< Epetra_Comm > comm
Definition: hyperbolic.cpp:234
Real analyticalSolution(const Real &t, const Real &x, const Real &y, const Real &, const ID &)
Analytical solution.
Definition: hyperbolic.cpp:65
double Real
Generic real data.
Definition: LifeV.hpp:175
LifeV::Real run()
Methods.
Definition: hyperbolic.cpp:332
The class for a reference Lagrangian finite element.
Real source_in(const Real &, const Real &, const Real &, const Real &, const ID &)
Definition: hyperbolic.cpp:183
Real mass(const Real &, const Real &, const Real &, const Real &, const ID &)
Definition: hyperbolic.cpp:162
const Real Pi
Definition: hyperbolic.cpp:62
Vector physicalFlux(const Real &, const Real &x, const Real &y, const Real &, const std::vector< Real > &u)
Definition: hyperbolic.cpp:80
A Geometric Shape.
fct_type getAnalyticalSolution()
Definition: hyperbolic.cpp:252
QuadratureRule - The basis class for storing and accessing quadrature rules.
std::string data_file_name
Definition: hyperbolic.cpp:231
fct_type getSource()
Definition: hyperbolic.cpp:273
Private Members.
Definition: hyperbolic.cpp:216
const QuadratureRule quadRuleTria1pt(pt_tria_1pt, 1, "Quadrature rule 1 point on a triangle", TRIANGLE, 1, 1)
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
fct_type getInitialCondition()
Definition: hyperbolic.cpp:280