LifeV
HyperbolicFluxNumerical.hpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3 *******************************************************************************
4  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
5  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
6  This file is part of LifeV.
7  LifeV is free software; you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11  LifeV is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15  You should have received a copy of the GNU Lesser General Public License
16  along with LifeV. If not, see <http://www.gnu.org/licenses/>.
17 *******************************************************************************
18 */
19 //@HEADER
20 /*!
21  * @file
22  * @brief Numerical fluxes for hyperbolic scalar equations.
23  *
24  *
25  * @date 30-09-2010
26  *
27  * @author Alessio Fumagalli <alessio.fumagalli@mail.polimi.it>
28  * @author Michel Kern <michel.kern@inria.fr>
29  *
30  * @contributor
31  *
32  * @mantainer Alessio Fumagalli <alessio.fumagalli@mail.polimi.it>
33  *
34  */
35 
36 #ifndef _HYPERBOLICNUMERICALFLUXES_H_
37 #define _HYPERBOLICNUMERICALFLUXES_H_ 1
38 
39 #include <boost/bind.hpp>
40 #include <lifev/core/fem/FESpace.hpp>
41 #include <lifev/core/algorithm/SolverAztecOO.hpp>
42 #include <lifev/core/fem/Assembly.hpp>
43 #include <lifev/core/algorithm/NonLinearBrent.hpp>
44 
45 namespace
46 {
47 
48 using namespace LifeV;
49 
50 typedef std::function < Vector ( const Real&, const Real&,
51  const Real&, const Real&,
52  const std::vector<Real>& ) >
54 
55 // Compute plus or minus the function dot normal vector
56 Real functionDotNormal ( const Real& unknown,
57  const vectorFunction& function,
58  const KN<Real>& normal,
59  const Real& t,
60  const Real& x,
61  const Real& y,
62  const Real& z,
63  const Real& plusMinus,
64  const std::vector<Real>& fieldsValues )
65 {
66  Real valueFunctionDotNormal (0);
67  const UInt problemDimension ( normal.size() );
68  std::vector<Real> unknownAndFields ( 1, 0. );
69 
70  // Add to the vector unknownAndFields the values of the unknown then the value of the external fields.
71  unknownAndFields[0] = unknown;
72  unknownAndFields.insert ( unknownAndFields.begin() + 1,
73  fieldsValues.begin(), fieldsValues.end() );
74 
75  // Compute \sum_{i} physicalFlux(i) * n(i)
76  for ( UInt nDim (0); nDim < problemDimension; ++nDim )
77  {
78  valueFunctionDotNormal += plusMinus * function ( t, x, y, z, unknownAndFields ) [nDim] * normal[nDim];
79  }
80 
81  return valueFunctionDotNormal;
82 }
83 
84 // Compute plus or minus the absolute value of function dot normal vector
85 Real absFunctionDotNormal ( const Real& unknown,
86  const vectorFunction& function,
87  const KN<Real>& normal,
88  const Real& t,
89  const Real& x,
90  const Real& y,
91  const Real& z,
92  const Real& plusMinus,
93  const std::vector<Real>& fieldsValues)
94 {
95  Real valueFunctionDotNormal (0);
96  const UInt problemDimension ( normal.size() );
97  std::vector<Real> unknownAndFields ( fieldsValues.size() + 1, 0. );
98 
99  // Add to the vector unknownAndFields the values of the unknown then the value of the external fields.
100  unknownAndFields[0] = unknown;
101  unknownAndFields.insert ( unknownAndFields.begin() + 1,
102  fieldsValues.begin(), fieldsValues.end() );
103 
104  // Compute \sum_{i} physicalFlux(i) * n(i)
105  for ( LifeV::UInt nDim (0); nDim < problemDimension; ++nDim )
106  {
107  valueFunctionDotNormal += function ( t, x, y, z, unknownAndFields ) [nDim] * normal[nDim];
108  }
109 
110  return plusMinus * std::fabs ( valueFunctionDotNormal );
111 }
112 
113 }
114 
115 
116 // LifeV namespace.
117 namespace LifeV
118 {
119 //! AbstractNumericalFlux Gives a common interface for hyperbolic's flux function.
120 /*!
121  @author Alessio Fumagalli <alessio.fumagalli@mail.polimi.it>
122  @author Michel Kern <michel.kern@inria.fr>
123 
124  This class gives a common interface for hyperbolic's flux functions \f$ \mathbf{F}( u ) \f$, in particoular it computes
125  <ol>
126  <li> the flux function dot product the outward unit normal \f$ \mathbf{n} \f$;</li>
127  <li> the first derivative of the flux function, respect to \f$ u \f$, dot product the outward unit normal;</li>
128  <li> the maximum value of \f$ \hat{\mathbf{F}} \cdot \mathbf{n} \f$ between to adjacent elements; </li>
129  <li> the value of \f$ \Vert \mathbf{F}^\prime \cdot \mathbf{n}_{e, K} \Vert_{L^\infty(a_0, b_0) } \f$ between to adjacent elements.</li>
130  </ol>
131  The class can handle the dependeces of the flux function \f$ \mathbf{F} \f$ of external vector or scalar fields.
132  @note In the implementation of the physical flux \f$ \mathbf{F} \f$ we suppose that the first parameter of the vector is the unknown.
133  See the test case for an example.
134 */
135 template < typename Mesh,
136  typename SolverType = LifeV::SolverAztecOO >
138 {
139 
140 public:
141 
142  //! @name Public Types
143  //@{
144 
145  typedef std::function < Vector ( const Real&, const Real&,
146  const Real&, const Real&,
147  const std::vector<Real>& ) >
149 
150  typedef std::function< Real ( const Real& ) > scalarFunction_Type;
151 
152  typedef typename SolverType::vector_type vector_Type;
154 
155  typedef GetPot dataFile_Type;
156  typedef KN< Real > normal_Type;
157 
158  //@}
159 
160  // Constructors & destructor.
161  //! @name Constructors and destructor
162  //@{
163 
164  //! Constructor for the class
165  /*!
166  @param physicalFlux Physical flux for the problem.
167  @param firstDerivativePhysicalFlux First derivative, respect the the unknown, of the physical flux.
168  @param fESpace Finite element space of the hyperbolic problem.
169  @param data Data for the problem.
170  @param section Section for read the data from GetPot file.
171  */
172  AbstractNumericalFlux ( const vectorFunction_Type& physicalFlux,
173  const vectorFunction_Type& firstDerivativePhysicalFlux,
174  const FESpace<Mesh, MapEpetra>& fESpace,
175  const dataFile_Type& data,
176  const std::string& section = "numerical_flux/");
177 
178  //! Virtual destructor.
179  virtual ~AbstractNumericalFlux ();
180 
181  //@}
182 
183  //! @name Operators
184  //@{
185 
186  //! Computes the face contribution of the flux.
187  /*!
188  Given a face \f$ e \in \partial K \f$ it evaluates
189  \f[
190  \max \hat{\mathbf{F}} \cdot \mathbf{n}
191  \f]
192  between to elements sharing the face.
193  @param leftState Left value of the unknown respect to the face.
194  @param rightValue Right value of the unknown respect to the face.
195  @param normal Normal of the face.
196  @param iElem The ID of the current element in the mesh.
197  @param t Current time.
198  @param x Abscissa.
199  @param y Ordinate.
200  @param z Quota.
201  @note We assume left and right side of \f$ e \f$ is given by: the normal direction goes
202  from the left side to the right side.
203  */
204  virtual Real operator() ( const Real& leftState,
205  const Real& rightState,
206  const normal_Type& normal,
207  const UInt& iElem,
208  const Real& t = 0,
209  const Real& x = 0,
210  const Real& y = 0,
211  const Real& z = 0 ) const = 0;
212  //@}
213 
214 
215  //! @name Set Methods
216  //@{
217 
218  //! Add one external field.
219  /*!
220  Add one extra field for the dependece from \f$ \mathbf{F} \f$.
221  @param field The filed to be added.
222  */
223  inline void setExternalField ( const vectorPtr_Type& field )
224  {
225  M_fields.push_back ( &field );
226  }
227 
228  //@}
229 
230  //! @name Get Methods
231  //@{
232 
233  //! Return the physical flux.
234  /*!
235  @return The physical flux.
236  */
238  {
239  return M_physicalFlux;
240  }
241 
242  //! Return the first derivative, respect to the unknown, of the physical flux.
243  /*!
244  @return The first derivative of the physical flux.
245  */
247  {
249  }
250 
251  //! Evaluate the flux dot normal in a given point of a face.
252  /*!
253  @param normal The normal of the face.
254  @param iElem The ID of the current element in the mesh.
255  @param t Current time.
256  @param x Abscissa.
257  @param y Ordinate.
258  @param z Quota.
259  @param unknown The value of the unknown.
260  @return The value of \f$ \mathbf{ \hat{ F } } \cdot \mathbf{ n }\f$ in the point \f$ (x, y, z, t, u) \f$.
261  */
262  inline Real physicalFluxDotNormal ( const normal_Type& normal,
263  const UInt& iElem,
264  const Real& t,
265  const Real& x,
266  const Real& y,
267  const Real& z,
268  const Real& unknown ) const
269  {
270  return computeFunctionDotNormal ( M_physicalFlux, normal, iElem, t, x, y, z, +1 ) ( unknown );
271  }
272 
273  //! Evaluate the first derivative of the flux dot normal in a given point of a face.
274  /*!
275  @param normal The normal of the face.
276  @param iElem The ID of the current element in the mesh.
277  @param t Current time.
278  @param x Abscissa.
279  @param y Ordinate.
280  @param z Quota.
281  @param unknown The value of the unknown.
282  @return The value of \f$ \mathbf{ \hat{ F^\prime } } \cdot \mathbf{ n }\f$ in the point \f$ (x, y, z, t, u) \f$.
283  */
285  const UInt& iElem,
286  const Real& t,
287  const Real& x,
288  const Real& y,
289  const Real& z,
290  const Real& unknown ) const
291  {
292  return computeFunctionDotNormal ( M_firstDerivativePhysicalFlux, normal, iElem, t, x, y, z, +1 ) ( unknown );
293  }
294 
295  //! Computes the local infinity norm of the first derivative of the flux dot normal.
296  /*!
297  Given a face \f$ e \in \partial K \f$ it evaluates
298  \f[
299  \displaystyle \max_{e \in \partial K^- \cap \partial K^+} \vert \hat{\mathbf{F^\prime}} \cdot \mathbf{n} \vert
300  \f]
301  between to elements sharing the face.
302  @param leftState Left value of the unknown respect to the face.
303  @param rightValue Right value of the unknown respect to the face.
304  @param normal Normal of the face.
305  @param iElem The ID of the current element in the mesh.
306  @param t Current time.
307  @param x Abscissa.
308  @param y Ordinate.
309  @param z Quota.
310  @note We assume left and right side of \f$ e \f$ is given by: the normal direction goes
311  from the left side to the right side.
312  */
313  Real normInfinity ( const Real& leftState,
314  const Real& rightState,
315  const normal_Type& normal,
316  const UInt& iElem,
317  const Real& t = 0,
318  const Real& x = 0,
319  const Real& y = 0,
320  const Real& z = 0 ) const;
321 
322  //@}
323 
324 protected:
325 
326  //! @name Protected Methods
327  //@{
328 
329  //! Return a scalar function from a general vector function dot normal in a given point of a face.
330  /*!
331  @param function Function to be reduced.
332  @param normal The normal of the face.
333  @param iElem The ID of the current element in the mesh.
334  @param t Current time.
335  @param x Abscissa.
336  @param y Ordinate.
337  @param z Quota.
338  @param plusMinus
339  @return The function \f$ g(u) = \pm \mathbf{f}(x,y,z,t,u) \cdot \mathbf{n} \f$.
340  */
342  const normal_Type& normal,
343  const UInt& iElem,
344  const Real& t,
345  const Real& x,
346  const Real& y,
347  const Real& z,
348  const Real& plusMinus ) const;
349 
350  //! Return a scalar function from the absolute value of a general vector function dot normal in a given point of a face.
351  /*!
352  @param function Function to be reduced.
353  @param normal The normal of the face.
354  @param iElem The ID of the current element in the mesh.
355  @param t Current time.
356  @param x Abscissa.
357  @param y Ordinate.
358  @param z Quota.
359  @param plusMinus
360  @return The function \f$ g(u) = \pm \vert \mathbf{f}(x,y,z,t,u) \cdot \mathbf{n} \vert \f$.
361  */
363  const normal_Type& normal,
364  const UInt& iElem,
365  const Real& t,
366  const Real& x,
367  const Real& y,
368  const Real& z,
369  const Real& plusMinus ) const;
370 
371  //@}
372 
373  //! Physical flux function.
375 
376  //! First derivative, respect to unknown, of physical flux function.
378 
379  //! Tollerance for the Brent algorithm for computing the CFL condition.
381 
382  //! Maximum of iterations for the Brent algorithm for computing the CFL condition.
384 
385  //! Finite element space of the hyperbolic solver.
386  const FESpace<Mesh, MapEpetra>& M_fESpace;
387 
388  //! Vector of pointers for the dependences of the permeability to external vector fields.
390 
391 }; // AbstractNumericalFlux
392 
393 // ===================================================
394 // Constructors & Destructor
395 // ===================================================
396 
397 // Constructor of the class
398 template < typename Mesh, typename SolverType >
399 AbstractNumericalFlux<Mesh, SolverType>::
401  const vectorFunction_Type& firstDerivativePhysicalFlux,
402  const FESpace<Mesh, MapEpetra>& fESpace,
403  const dataFile_Type& data,
404  const std::string& section ) :
405  M_physicalFlux ( physicalFlux ),
406  M_firstDerivativePhysicalFlux ( firstDerivativePhysicalFlux ),
407  M_CFLBrentToll ( data ( ( section + "CFL/brent_toll" ).data(), 1e-4 ) ),
408  M_CFLBrentMaxIter ( data ( ( section + "CFL/brent_maxIter" ).data(), 20 ) ),
409  M_fESpace ( fESpace ),
410  M_fields ( std::vector< const vectorPtr_Type* > (0) )
411 {
412 
413 } // Constructor
414 
415 // Destructor of the class
416 template < typename Mesh, typename SolverType >
417 AbstractNumericalFlux<Mesh, SolverType>::
419 {
420 
421 } // Destructor
422 
423 // ===================================================
424 // Methods
425 // ===================================================
426 
427 // Return the norm infinity
428 template< typename Mesh, typename SolverType >
429 Real
430 AbstractNumericalFlux<Mesh, SolverType>::
431 normInfinity ( const Real& leftState, const Real& rightState, const normal_Type& normal, const UInt& iElem,
432  const Real& t, const Real& x, const Real& y, const Real& z ) const
433 {
434 
435  std::vector<Real> values ( M_fields.size() * M_fESpace.fieldDim(), 0 );
436  const UInt totalDofsPresent ( M_fESpace.dof().numTotalDof() );
437  const UInt fieldDim ( M_fESpace.fieldDim() );
438  scalarFunction_Type absFunctionDotNormalBound;
439 
440  // Takes the value of all the external fields in the current element.
441  for ( UInt i (0); i < M_fields.size(); ++i )
442  {
443  // Select if the external field is a scalar or vector field
444  for ( UInt iComponent (0); iComponent < fieldDim; ++iComponent )
445  {
446  values[ i * fieldDim + iComponent ] = (* ( * (M_fields) [i] ) ) [ iComponent * totalDofsPresent + M_fESpace.dof().localToGlobalMap ( iElem, 0) ];
447  }
448 
449  }
450 
451  // Bind the function which depends on all the parameter to obatin a scalar function, which depend just on the unknown
452  absFunctionDotNormalBound = std::bind ( &absFunctionDotNormal, std::placeholders::_1,
453  M_firstDerivativePhysicalFlux,
454  normal, t, x, y, z, -1, values );
455 
456  // Compute the minumum of minus absFunctionDotNormal
457  const Real maxValue = NonLinearBrent ( absFunctionDotNormalBound, leftState, rightState,
459 
460  // Return minus the value
461  return - absFunctionDotNormalBound ( maxValue );
462 
463 } // getNormInfty
464 
465 // Create the fluxDotNormal function
466 template < typename Mesh, typename SolverType >
467 std::function< Real ( const Real& ) >
468 AbstractNumericalFlux< Mesh, SolverType >::
470  const Real& t, const Real& x, const Real& y, const Real& z, const Real& plusMinus ) const
471 {
472 
473  std::vector<Real> values ( M_fields.size() * M_fESpace.fieldDim(), 0 );
474  const UInt totalDofsPresent ( M_fESpace.dof().numTotalDof() );
475  const UInt fieldDim ( M_fESpace.fieldDim() );
476  scalarFunction_Type functionDotNormalBound;
477 
478  // Takes the value of all the external fields in the current element.
479  for ( UInt i (0); i < M_fields.size(); ++i )
480  {
481  // Select if the external field is a scalar or vector field
482  for ( UInt iComponent (0); iComponent < fieldDim; ++iComponent )
483  {
484  values[ i * fieldDim + iComponent ] = (* ( * (M_fields) [i] ) ) [ iComponent * totalDofsPresent + M_fESpace.dof().localToGlobalMap ( iElem, 0) ];
485  }
486 
487  }
488 
489  // Bind the fluxDotNormal function with known quantities.
490  functionDotNormalBound = std::bind ( &functionDotNormal, std::placeholders::_1, function,
491  normal, t, x, y, z, plusMinus, values );
492 
493  return functionDotNormalBound;
494 
495 } // computeFluxDotNormal
496 
497 // ######################################################################### //
498 
499 //! GodunovNumericalFlux Gives an implementation for Godunov solver for hyperbolic's flux function.
500 /*!
501  @author Alessio Fumagalli <alessio.fumagalli@mail.polimi.it>
502  @author Michel Kern <michel.kern@inria.fr>
503 
504  This class gives an implementation for Godunov solver for hyperbolic's flux functions \f$ \mathbf{F}( u ) \f$. In particular it implements
505  <ol>
506  <li> the flux function dot product the outward unit normal \f$ \mathbf{n} \f$;</li>
507  <li> the first derivative of the flux function, respect to \f$ u \f$, dot product the outward unit normal;</li>
508  <li> the maximum value of \f$ \hat{\mathbf{F}} \cdot \mathbf{n} \f$ between to adjacent elements computed using Godunov solver
509  \f[
510  \hat{\mathbf{F}} \cdot \mathbf{n} (a,b)=
511  \left\{
512  \begin{array}{l l}
513  \displaystyle \min_{a \leq u \leq b} \mathbf{F} \cdot \mathbf{n} ( u ) & \mathrm{if} \quad a \leq b\,, \\
514  \displaystyle \max_{b \leq u \leq a} \mathbf{F} \cdot \mathbf{n} ( u ) & \mathrm{otherwise}\,.
515  \end{array}
516  \right.
517  \f]
518  </li>
519  <li> the value of \f$ \Vert \mathbf{F}^\prime \cdot \mathbf{n}_{e, K} \Vert_{L^\infty(a_0, b_0) } \f$ between to adjacent elements.</li>
520  </ol>
521  The class can handle the dependeces of the flux function \f$ \mathbf{F} \f$ of external vector or scalar fields.
522  @note In the implementation of the physical flux \f$ \mathbf{F} \f$ we suppose that the first parameter of the vector is the unknown.
523  See the test case for an example.
524 */
525 template < typename Mesh,
526  typename SolverType = LifeV::SolverAztecOO >
527 class GodunovNumericalFlux : public AbstractNumericalFlux<Mesh, SolverType>
528 {
529 
530 public:
531 
532  //! @name Public Types
533  //@{
534 
535  typedef typename AbstractNumericalFlux<Mesh, SolverType>::vectorFunction_Type vectorFunction_Type;
536  typedef typename AbstractNumericalFlux<Mesh, SolverType>::scalarFunction_Type scalarFunction_Type;
537  typedef typename AbstractNumericalFlux<Mesh, SolverType>::dataFile_Type dataFile_Type;
538  typedef typename AbstractNumericalFlux<Mesh, SolverType>::normal_Type normal_Type;
539 
540  //@}
541 
542  // Constructors & destructor.
543  //! @name Constructors and destructor
544  //@{
545 
546  //! Constructor for the class
547  /*!
548  @param physicalFlux Physical flux for the problem.
549  @param firstDerivativePhysicalFlux First derivative, respect the the unknown, of the physical flux.
550  @param fESpace Finite element space of the hyperbolic problem.
551  @param data Data for the problem.
552  @param section Section for read the data from GetPot file.
553  */
554  GodunovNumericalFlux ( const vectorFunction_Type& physicalFlux,
555  const vectorFunction_Type& firstDerivativePhysicalFlux,
556  const FESpace<Mesh, MapEpetra>& fESpace,
557  const dataFile_Type& data,
558  const std::string& section = "numerical_flux/" );
559 
560  //! Virtual destructor
561  virtual ~GodunovNumericalFlux ();
562 
563  //@}
564 
565  //! @name Operators
566  //@{
567 
568  //! Computes the face contribution of the flux.
569  /*!
570  Given a face \f$ e \in \partial K \f$ it evaluates
571  \f[
572  \max \hat{\mathbf{F}} \cdot \mathbf{n}
573  \f]
574  between to elements sharing the face, using Godunov flux.
575  @param leftState Left value of the unknown respect to the face.
576  @param rightValue Right value of the unknown respect to the face.
577  @param normal Normal of the face.
578  @param iElem The ID of the current element in the mesh.
579  @param t Current time.
580  @param x Abscissa.
581  @param y Ordinate.
582  @param z Quota.
583  @note We assume left and right side of \f$ e \f$ is given by: the normal direction goes
584  from the left side to the right side.
585  */
586  virtual Real operator() ( const Real& leftState,
587  const Real& rightState,
588  const normal_Type& normal,
589  const UInt& iElem,
590  const Real& t = 0,
591  const Real& x = 0,
592  const Real& y = 0,
593  const Real& z = 0 ) const;
594 
595  //@}
596 
597 protected:
598 
599  //! Tollerance for the Brent algorithm used for Godunov flux.
601 
602  //! Maximum of iteration for the Brent algorithm used for Godunov flux.
604 
605 }; // GodunovNumericalFlux
606 
607 // ===================================================
608 // Constructors & Destructor
609 // ===================================================
610 
611 // Constructor of the class
612 template < typename Mesh, typename SolverType >
613 GodunovNumericalFlux<Mesh, SolverType>::
615  const vectorFunction_Type& firstDerivativePhysicalFlux,
616  const FESpace<Mesh, MapEpetra>& fESpace,
617  const dataFile_Type& data,
618  const std::string& section ) :
621  fESpace,
622  data,
623  section ),
624  M_brentToll ( data ( ( section + "godunov/brent_toll" ).data(), 1e-4 ) ),
625  M_brentMaxIter ( data ( ( section + "godunov/brent_maxIter" ).data(), 20) )
626 {
627 
628 } // Constructor
629 
630 // Destructor of the class
631 template < typename Mesh, typename SolverType >
632 GodunovNumericalFlux<Mesh, SolverType>::
634 {
635 
636 } // Destructor
637 
638 // ===================================================
639 // Operators
640 // ===================================================
641 
642 template < typename Mesh, typename SolverType >
643 Real
644 GodunovNumericalFlux<Mesh, SolverType>::
645 operator() ( const Real& leftState, const Real& rightState, const normal_Type& normal,
646  const UInt& iElem, const Real& t, const Real& x, const Real& y, const Real& z ) const
647 {
648 
649  // It will store the value of the flux
650  Real fluxValue ( static_cast<Real> (0) );
651 
652  // It will store the argmin or argmax of flux dot normal
653  Real minMax ( static_cast<Real> (0) );
654 
655  // The normal flux function
656  scalarFunction_Type normalFlux;
657 
658  // Select where it is the upwind direction
659  if ( rightState > leftState )
660  {
661  // Create the function f \cdot n
662  normalFlux = this->computeFunctionDotNormal ( this->M_physicalFlux, normal, iElem, t, x, y, z, +1 );
663 
664  // Compute the argmin f \cdot n
665  minMax = NonLinearBrent ( normalFlux, leftState, rightState, M_brentToll, M_brentMaxIter );
666 
667  // Compute the flux value
668  fluxValue = normalFlux ( minMax );
669  }
670  else
671  {
672  // Create the function - f \cdot n
673  normalFlux = this->computeFunctionDotNormal ( this->M_physicalFlux, normal, iElem, t, x, y, z, -1 );
674 
675  // Compute the argmin - f \cdot n
676  minMax = NonLinearBrent ( normalFlux, leftState, rightState, M_brentToll, M_brentMaxIter );
677 
678  // Compute the flux value
679  fluxValue = - normalFlux ( minMax );
680  }
681 
682  return fluxValue;
683 
684 } // operator()
685 
686 } // Namespace LifeV
687 
688 #endif //_HYPERBOLICNUMERICALFLUXES_H_
virtual Real operator()(const Real &leftState, const Real &rightState, const normal_Type &normal, const UInt &iElem, const Real &t=0, const Real &x=0, const Real &y=0, const Real &z=0) const =0
Computes the face contribution of the flux.
GodunovNumericalFlux(const vectorFunction_Type &physicalFlux, const vectorFunction_Type &firstDerivativePhysicalFlux, const FESpace< Mesh, MapEpetra > &fESpace, const dataFile_Type &data, const std::string &section="numerical_flux/")
Constructor for the class.
Real M_CFLBrentToll
Tollerance for the Brent algorithm for computing the CFL condition.
UInt M_brentMaxIter
Maximum of iteration for the Brent algorithm used for Godunov flux.
std::function< Real(const Real &) > scalarFunction_Type
FESpace - Short description here please!
Definition: FESpace.hpp:78
UInt M_CFLBrentMaxIter
Maximum of iterations for the Brent algorithm for computing the CFL condition.
AbstractNumericalFlux< Mesh, SolverType >::dataFile_Type dataFile_Type
std::function< Vector(const Real &, const Real &, const Real &, const Real &, const std::vector< Real > &) > vectorFunction
Real absFunctionDotNormal(const Real &unknown, const vectorFunction &function, const KN< Real > &normal, const Real &t, const Real &x, const Real &y, const Real &z, const Real &plusMinus, const std::vector< Real > &fieldsValues)
AbstractNumericalFlux< Mesh, SolverType >::vectorFunction_Type vectorFunction_Type
std::vector< const vectorPtr_Type *> M_fields
Vector of pointers for the dependences of the permeability to external vector fields.
AbstractNumericalFlux(const vectorFunction_Type &physicalFlux, const vectorFunction_Type &firstDerivativePhysicalFlux, const FESpace< Mesh, MapEpetra > &fESpace, const dataFile_Type &data, const std::string &section="numerical_flux/")
Constructor for the class.
Real M_brentToll
Tollerance for the Brent algorithm used for Godunov flux.
Real normInfinity(const Real &leftState, const Real &rightState, const normal_Type &normal, const UInt &iElem, const Real &t=0, const Real &x=0, const Real &y=0, const Real &z=0) const
Computes the local infinity norm of the first derivative of the flux dot normal.
virtual ~GodunovNumericalFlux()
Virtual destructor.
scalarFunction_Type computeAbsFunctionDotNormal(const vectorFunction_Type &function, const normal_Type &normal, const UInt &iElem, const Real &t, const Real &x, const Real &y, const Real &z, const Real &plusMinus) const
Return a scalar function from the absolute value of a general vector function dot normal in a given p...
AbstractNumericalFlux Gives a common interface for hyperbolic&#39;s flux function.
void setExternalField(const vectorPtr_Type &field)
Add one external field.
AbstractNumericalFlux< Mesh, SolverType >::normal_Type normal_Type
scalarFunction_Type computeFunctionDotNormal(const vectorFunction_Type &function, const normal_Type &normal, const UInt &iElem, const Real &t, const Real &x, const Real &y, const Real &z, const Real &plusMinus) const
Return a scalar function from a general vector function dot normal in a given point of a face...
virtual Real operator()(const Real &leftState, const Real &rightState, const normal_Type &normal, const UInt &iElem, const Real &t=0, const Real &x=0, const Real &y=0, const Real &z=0) const
Computes the face contribution of the flux.
std::shared_ptr< vector_Type > vectorPtr_Type
AbstractNumericalFlux< Mesh, SolverType >::scalarFunction_Type scalarFunction_Type
Real physicalFluxDotNormal(const normal_Type &normal, const UInt &iElem, const Real &t, const Real &x, const Real &y, const Real &z, const Real &unknown) const
Evaluate the flux dot normal in a given point of a face.
vectorFunction_Type M_firstDerivativePhysicalFlux
First derivative, respect to unknown, of physical flux function.
virtual ~AbstractNumericalFlux()
Virtual destructor.
double Real
Generic real data.
Definition: LifeV.hpp:175
std::function< Vector(const Real &, const Real &, const Real &, const Real &, const std::vector< Real > &) > vectorFunction_Type
vectorFunction_Type M_physicalFlux
Physical flux function.
GodunovNumericalFlux Gives an implementation for Godunov solver for hyperbolic&#39;s flux function...
const FESpace< Mesh, MapEpetra > & M_fESpace
Finite element space of the hyperbolic solver.
Real functionDotNormal(const Real &unknown, const vectorFunction &function, const KN< Real > &normal, const Real &t, const Real &x, const Real &y, const Real &z, const Real &plusMinus, const std::vector< Real > &fieldsValues)
vectorFunction_Type physicalFlux() const
Return the physical flux.
vectorFunction_Type firstDerivativePhysicalFlux() const
Return the first derivative, respect to the unknown, of the physical flux.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
Real firstDerivativePhysicalFluxDotNormal(const normal_Type &normal, const UInt &iElem, const Real &t, const Real &x, const Real &y, const Real &z, const Real &unknown) const
Evaluate the first derivative of the flux dot normal in a given point of a face.