36 #ifndef _HYPERBOLICNUMERICALFLUXES_H_ 37 #define _HYPERBOLICNUMERICALFLUXES_H_ 1
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> 48 using namespace LifeV;
58 const KN<
Real>& normal,
63 const Real& plusMinus,
64 const std::vector<Real>& fieldsValues )
66 Real valueFunctionDotNormal (0);
67 const UInt problemDimension ( normal.size() );
68 std::vector<Real> unknownAndFields ( 1, 0. );
71 unknownAndFields[0] = unknown;
72 unknownAndFields.insert ( unknownAndFields.begin() + 1,
73 fieldsValues.begin(), fieldsValues.end() );
76 for (
UInt nDim (0); nDim < problemDimension; ++nDim )
78 valueFunctionDotNormal += plusMinus * function ( t, x, y, z, unknownAndFields ) [nDim] * normal[nDim];
81 return valueFunctionDotNormal;
87 const KN<
Real>& normal,
92 const Real& plusMinus,
93 const std::vector<Real>& fieldsValues)
95 Real valueFunctionDotNormal (0);
96 const UInt problemDimension ( normal.size() );
97 std::vector<Real> unknownAndFields ( fieldsValues.size() + 1, 0. );
100 unknownAndFields[0] = unknown;
101 unknownAndFields.insert ( unknownAndFields.begin() + 1,
102 fieldsValues.begin(), fieldsValues.end() );
105 for ( LifeV::UInt nDim (0); nDim < problemDimension; ++nDim )
107 valueFunctionDotNormal += function ( t, x, y, z, unknownAndFields ) [nDim] * normal[nDim];
110 return plusMinus * std::fabs ( valueFunctionDotNormal );
135 template <
typename Mesh,
136 typename SolverType = LifeV::SolverAztecOO >
174 const FESpace<Mesh, MapEpetra>& fESpace,
176 const std::string& section =
"numerical_flux/");
205 const Real& rightState,
211 const Real& z = 0 )
const = 0;
225 M_fields.push_back ( &field );
268 const Real& unknown )
const 290 const Real& unknown )
const 314 const Real& rightState,
320 const Real& z = 0 )
const;
348 const Real& plusMinus )
const;
369 const Real& plusMinus )
const;
398 template <
typename Mesh,
typename SolverType >
402 const FESpace<Mesh, MapEpetra>& fESpace,
404 const std::string& section ) :
416 template <
typename Mesh,
typename SolverType >
428 template<
typename Mesh,
typename SolverType >
435 std::vector<Real> values ( M_fields.size() * M_fESpace.fieldDim(), 0 );
436 const UInt totalDofsPresent (
M_fESpace.dof().numTotalDof() );
441 for ( UInt i (0); i < M_fields.size(); ++i )
444 for ( UInt iComponent (0); iComponent < fieldDim; ++iComponent )
446 values[ i * fieldDim + iComponent ] = (* ( * (M_fields) [i] ) ) [ iComponent * totalDofsPresent + M_fESpace.dof().localToGlobalMap ( iElem, 0) ];
452 absFunctionDotNormalBound = std::bind ( &absFunctionDotNormal, std::placeholders::_1,
453 M_firstDerivativePhysicalFlux,
454 normal, t, x, y, z, -1, values );
457 const Real maxValue = NonLinearBrent ( absFunctionDotNormalBound, leftState, rightState,
461 return - absFunctionDotNormalBound ( maxValue );
466 template <
typename Mesh,
typename SolverType >
473 std::vector<Real> values ( M_fields.size() * M_fESpace.fieldDim(), 0 );
474 const UInt totalDofsPresent (
M_fESpace.dof().numTotalDof() );
479 for ( UInt i (0); i < M_fields.size(); ++i )
482 for ( UInt iComponent (0); iComponent < fieldDim; ++iComponent )
484 values[ i * fieldDim + iComponent ] = (* ( * (M_fields) [i] ) ) [ iComponent * totalDofsPresent + M_fESpace.dof().localToGlobalMap ( iElem, 0) ];
490 functionDotNormalBound = std::bind ( &functionDotNormal, std::placeholders::_1, function,
491 normal, t, x, y, z, plusMinus, values );
493 return functionDotNormalBound;
525 template <
typename Mesh,
526 typename SolverType = LifeV::SolverAztecOO >
556 const FESpace<Mesh, MapEpetra>& fESpace,
558 const std::string& section =
"numerical_flux/" );
587 const Real& rightState,
593 const Real& z = 0 )
const;
612 template <
typename Mesh,
typename SolverType >
616 const FESpace<Mesh, MapEpetra>& fESpace,
618 const std::string& section ) :
631 template <
typename Mesh,
typename SolverType >
642 template <
typename Mesh,
typename SolverType >
650 Real fluxValue (
static_cast<
Real> (0) );
653 Real minMax (
static_cast<
Real> (0) );
659 if ( rightState > leftState )
662 normalFlux =
this->computeFunctionDotNormal (
this->M_physicalFlux, normal, iElem, t, x, y, z, +1 );
668 fluxValue = normalFlux ( minMax );
673 normalFlux =
this->computeFunctionDotNormal (
this->M_physicalFlux, normal, iElem, t, x, y, z, -1 );
679 fluxValue = - normalFlux ( minMax );
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 §ion="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!
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 §ion="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's flux function.
void setExternalField(const vectorPtr_Type &field)
Add one external field.
AbstractNumericalFlux< Mesh, SolverType >::normal_Type normal_Type
SolverType::vector_type vector_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.
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'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)
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.