Feel++  0.92.0
Friends
Feel::CRB< TruthModelType > Class Template Reference

Certifed Reduced Basis class. More...

#include <crb.hpp>

Inheritance diagram for Feel::CRB< TruthModelType >:
Feel::CRBDB

List of all members.

Public Types

Typedefs
typedef TruthModelType truth_model_type
typedef truth_model_type model_type
typedef boost::shared_ptr
< truth_model_type > 
truth_model_ptrtype
typedef double value_type
typedef boost::tuple< double,
double > 
bounds_type
typedef ParameterSpace
< TruthModelType::ParameterSpaceDimension > 
parameterspace_type
typedef boost::shared_ptr
< parameterspace_type
parameterspace_ptrtype
typedef
parameterspace_type::element_type 
parameter_type
typedef
parameterspace_type::element_ptrtype 
parameter_ptrtype
typedef
parameterspace_type::sampling_type 
sampling_type
typedef
parameterspace_type::sampling_ptrtype 
sampling_ptrtype
typedef boost::tuple< double,
parameter_type, size_type,
double, double > 
relative_error_type
typedef relative_error_type max_error_type
typedef boost::tuple< double,
std::vector< std::vector
< double > >, std::vector
< std::vector< double >
>, double, double > 
error_estimation_type
typedef boost::tuple< double,
std::vector< double > > 
residual_error_type
typedef boost::bimap< int,
boost::tuple< double, double,
double > > 
convergence_type
typedef
convergence_type::value_type 
convergence
typedef CRBSCM< truth_model_type > scm_type
 scm
typedef boost::shared_ptr
< scm_type
scm_ptrtype
typedef POD< truth_model_type > pod_type
 POD.
typedef boost::shared_ptr
< pod_type
pod_ptrtype
typedef
model_type::functionspace_type 
functionspace_type
 function space type
typedef
model_type::functionspace_ptrtype 
functionspace_ptrtype
typedef model_type::element_type element_type
 element of the functionspace type
typedef model_type::element_ptrtype element_ptrtype
typedef model_type::backend_type backend_type
typedef boost::shared_ptr
< backend_type > 
backend_ptrtype
typedef
model_type::sparse_matrix_ptrtype 
sparse_matrix_ptrtype
typedef model_type::vector_ptrtype vector_ptrtype
typedef
model_type::theta_vector_type 
theta_vector_type
typedef Eigen::VectorXd y_type
typedef std::vector< y_type > y_set_type
typedef std::vector
< boost::tuple< double, double > > 
y_bounds_type
typedef std::vector< element_typewn_type
typedef boost::tuple
< std::vector< wn_type >
, std::vector< std::string > > 
export_vector_wn_type
typedef std::vector< double > vector_double_type
typedef boost::shared_ptr
< vector_double_type > 
vector_double_ptrtype
typedef Eigen::VectorXd vectorN_type
typedef Eigen::MatrixXd matrixN_type
typedef std::vector< element_typemode_set_type
typedef boost::shared_ptr
< mode_set_type > 
mode_set_ptrtype
typedef boost::multi_array
< value_type, 2 > 
array_2_type
typedef boost::multi_array
< vectorN_type, 2 > 
array_3_type
typedef boost::multi_array
< matrixN_type, 2 > 
array_4_type
typedef model_type::mesh_type mesh_type
 mesh type
typedef boost::shared_ptr
< mesh_type
mesh_ptrtype
typedef model_type::space_type space_type
 space type
typedef Bdf< space_typebdf_type
 time discretization
typedef boost::shared_ptr
< bdf_type
bdf_ptrtype
typedef Exporter< mesh_typeexport_type
typedef boost::shared_ptr
< export_type
export_ptrtype

Public Member Functions

Constructors, destructor
 CRB ()
 default constructor
 CRB (std::string name, po::variables_map const &vm)
 constructor from command line options
 CRB (CRB const &o)
 copy constructor
 ~CRB ()
 destructor
Operator overloads
CRBoperator= (CRB const &o)
 copy operator
Accessors
int factor () const
 return factor
int maxIter () const
parameterspace_ptrtype Dmu () const
int outputIndex () const
int dimension () const
sampling_ptrtype trainSampling () const
CRBErrorType errorType () const
scm_ptrtype scm () const
Mutators
void setOutputIndex (uint16_type oindex)
 set the output index
void setCRBErrorType (CRBErrorType error)
 set the crb error type
void setTolerance (double tolerance)
 set offline tolerance
void setTruthModel (truth_model_ptrtype const &model)
 set the truth offline model
void setMaxIter (int K)
 set max iteration number
void setFactor (int Factor)
 set factor
Methods
void orthonormalize (size_type N, wn_type &wn, int Nm=1)
void checkResidual (parameter_type const &mu, std::vector< std::vector< double > > const &primal_residual_coeffs, std::vector< std::vector< double > > const &dual_residual_coeffs) const
void compareResidualsForTransientProblems (parameter_type const &mu, std::vector< element_ptrtype > const &Un, std::vector< element_ptrtype > const &Unold, std::vector< element_ptrtype > const &Undu, std::vector< element_ptrtype > const &Unduold, std::vector< std::vector< double > > const &primal_residual_coeffs, std::vector< std::vector< double > > const &dual_residual_coeffs) const
void buildFunctionFromRbCoefficients (std::vector< vectorN_type > const &RBcoeff, wn_type const &WN, std::vector< element_ptrtype > &FEMsolutions)
void checkOrthonormality (int N, const wn_type &wn) const
void check (size_type N) const
void computeErrorEstimationEfficiencyIndicator (parameterspace_ptrtype const &Dmu, double &max_ei, double &min_ei, int N=4)
void exportBasisFunctions (const export_vector_wn_type &wn) const
boost::tuple< double, double > lb (size_type N, parameter_type const &mu, std::vector< vectorN_type > &uN, std::vector< vectorN_type > &uNdu, std::vector< vectorN_type > &uNold, std::vector< vectorN_type > &uNduold, int K=0) const
boost::tuple< double, double > lb (parameter_ptrtype const &mu, size_type N, std::vector< vectorN_type > &uN, std::vector< vectorN_type > &uNdu) const
value_type ub (size_type N, parameter_type const &mu, std::vector< vectorN_type > &uN, std::vector< vectorN_type > &uNdu) const
value_type delta (size_type N, parameter_ptrtype const &mu, std::vector< vectorN_type > const &uN, std::vector< vectorN_type > const &uNdu, std::vector< vectorN_type > const &uNold, std::vector< vectorN_type > const &uNduold, int k=0) const
error_estimation_type delta (size_type N, parameter_type const &mu, std::vector< vectorN_type > const &uN, std::vector< vectorN_type > const &uNdu, std::vector< vectorN_type > const &uNold, std::vector< vectorN_type > const &uNduold, int k=0) const
value_type ub (size_type K, parameter_ptrtype const &mu, std::vector< vectorN_type > &uN, std::vector< vectorN_type > &uNdu) const
convergence_type offline ()
max_error_type maxErrorBounds (size_type N) const
 Retuns maximum value of the relative error.
residual_error_type transientPrimalResidual (int Ncur, parameter_type const &mu, vectorN_type const &Un, vectorN_type const &Unold=vectorN_type(), double time_step=1, double time=1e30) const
residual_error_type steadyPrimalResidual (int Ncur, parameter_type const &mu, vectorN_type const &Un, double time=0) const
residual_error_type transientDualResidual (int Ncur, parameter_type const &mu, vectorN_type const &Un, vectorN_type const &Unold=vectorN_type(), double time_step=1, double time=1e30) const
residual_error_type steadyDualResidual (int Ncur, parameter_type const &mu, vectorN_type const &Un, double time=0) const
value_type initialDualResidual (int Ncur, parameter_type const &mu, vectorN_type const &Uduini, double time_step) const
void offlineResidual (int Ncur, int number_of_added_elements=1)
void offlineResidual (int Ncur, mpl::bool_< true >, int number_of_added_elements=1)
void offlineResidual (int Ncur, mpl::bool_< false >, int number_of_added_elements=1)
value_type empiricalErrorEstimation (int Ncur, parameter_type const &mu, int k) const
boost::tuple< double, double,
double, double > 
run (parameter_type const &mu, double eps=1e-6)
void run (const double *X, unsigned long N, double *Y, unsigned long P)
void run (const double *X, unsigned long N, double *Y, unsigned long P, mpl::bool_< true >)
void run (const double *X, unsigned long N, double *Y, unsigned long P, mpl::bool_< false >)
sampling_type randomSampling (int N)
sampling_type equidistributedSampling (int N)
void saveDB ()
bool loadDB ()
void projectionOnPodSpace (const element_ptrtype &u, element_ptrtype &projection, const std::string &name_of_space="primal")
bool rebuildDB ()
bool showMuSelection ()
bool printErrorDuringOfflineStep ()
void printMuSelection (void)
void printErrorsDuringRbConstruction (void)
double correctionTerms (parameter_type const &mu, std::vector< vectorN_type > const &uN, std::vector< vectorN_type > const &uNdu, std::vector< vectorN_type > const &uNold, int const K=0) const
void buildVarianceMatrixPhi (int const N)

Friends

class boost::serialization::access

Detailed Description

template<typename TruthModelType>
class Feel::CRB< TruthModelType >

Certifed Reduced Basis class.

Implements the certified reduced basis method

Author:
Christophe Prud'homme
See also:

Member Function Documentation

template<typename TruthModelType >
void Feel::CRB< TruthModelType >::check ( size_type  N) const

check the reduced basis space invariant properties

Parameters:
Ndimension of $W_N$

References Feel::CRB< TruthModelType >::delta(), Feel::CRB< TruthModelType >::lb(), and Feel::CRBDB::vm().

Referenced by Feel::CRB< TruthModelType >::offline().

template<typename TruthModelType >
void Feel::CRB< TruthModelType >::computeErrorEstimationEfficiencyIndicator ( parameterspace_ptrtype const &  Dmu,
double &  max_ei,
double &  min_ei,
int  N = 4 
)

compute effectivity indicator of the error estimation overall a given parameter space

Parameters:
max_ei: maximum efficiency indicator (output)
min_ei: minimum efficiency indicator (output)
Dmu(input) parameter space
N: sampling size (optional input with default value)

References Feel::CRB< TruthModelType >::delta(), and Feel::CRB< TruthModelType >::lb().

template<typename TruthModelType>
value_type Feel::CRB< TruthModelType >::delta ( size_type  N,
parameter_ptrtype const &  mu,
std::vector< vectorN_type > const &  uN,
std::vector< vectorN_type > const &  uNdu,
std::vector< vectorN_type > const &  uNold,
std::vector< vectorN_type > const &  uNduold,
int  k = 0 
) const [inline]

Returns the error bound on the output

Parameters:
mu$ \mu$ the parameter at which to evaluate the output
Nthe size of the reduced basis space to use
uNprimal solution
uNdudual solution
Returns:
compute online the lower bound

Referenced by Feel::CRB< TruthModelType >::check(), Feel::CRB< TruthModelType >::computeErrorEstimationEfficiencyIndicator(), Feel::CRB< TruthModelType >::maxErrorBounds(), Feel::CRB< TruthModelType >::run(), and Feel::CRB< TruthModelType >::ub().

template<typename TruthModelType >
CRB< TruthModelType >::error_estimation_type Feel::CRB< TruthModelType >::delta ( size_type  N,
parameter_type const &  mu,
std::vector< vectorN_type > const &  uN,
std::vector< vectorN_type > const &  uNdu,
std::vector< vectorN_type > const &  uNold,
std::vector< vectorN_type > const &  uNduold,
int  k = 0 
) const

Returns the error bound on the output associed to $\mu$

Parameters:
mu$ \mu$ the parameter at which to evaluate the output
Nthe dimension of $W_N$
uNprimal solution
uNdudual solution
Returns:
compute online the lower bound

References Feel::CRB< TruthModelType >::transientPrimalResidual().

template<typename TruthModelType>
int Feel::CRB< TruthModelType >::dimension ( ) const [inline]
Returns:
the dimension of the reduced basis space
template<typename TruthModelType>
parameterspace_ptrtype Feel::CRB< TruthModelType >::Dmu ( ) const [inline]
Returns:
the parameter space
template<typename TruthModelType>
sampling_type Feel::CRB< TruthModelType >::equidistributedSampling ( int  N) [inline]
Returns:
a equidistributed sampling
template<typename TruthModelType>
CRBErrorType Feel::CRB< TruthModelType >::errorType ( ) const [inline]
Returns:
the error type
template<typename TruthModelType >
void Feel::CRB< TruthModelType >::exportBasisFunctions ( const export_vector_wn_type &  wn) const

export basis functions to visualize it

Parameters:
wn: tuple composed of a vector of wn_type and a vector of string (used to name basis)

References Feel::CRBDB::name().

Referenced by Feel::CRB< TruthModelType >::offline().

template<typename TruthModelType >
boost::tuple< double, double > Feel::CRB< TruthModelType >::lb ( size_type  N,
parameter_type const &  mu,
std::vector< vectorN_type > &  uN,
std::vector< vectorN_type > &  uNdu,
std::vector< vectorN_type > &  uNold,
std::vector< vectorN_type > &  uNduold,
int  K = 0 
) const

Returns the lower bound of the output

Parameters:
mu$ \mu$ the parameter at which to evaluate the output
Nthe size of the reduced basis space to use
uNprimal solution
uNdudual solution
K: index of time ( time = K*dt) at which we want to evaluate the output Note : K as a default value for non time-dependent problems
Returns:
compute online the lower bound also condition number of matrix A

References Feel::CRBDB::name(), and Feel::CRBDB::vm().

Referenced by Feel::CRB< TruthModelType >::check(), Feel::CRB< TruthModelType >::computeErrorEstimationEfficiencyIndicator(), Feel::CRB< TruthModelType >::lb(), Feel::CRB< TruthModelType >::maxErrorBounds(), Feel::CRB< TruthModelType >::run(), and Feel::CRB< TruthModelType >::ub().

template<typename TruthModelType>
boost::tuple<double,double> Feel::CRB< TruthModelType >::lb ( parameter_ptrtype const &  mu,
size_type  N,
std::vector< vectorN_type > &  uN,
std::vector< vectorN_type > &  uNdu 
) const [inline]

Returns the lower bound of the output

Parameters:
mu$ \mu$ the parameter at which to evaluate the output
Nthe size of the reduced basis space to use
uNprimal solution
uNdudual solution
Returns:
compute online the lower bound and condition number of matrix A

References Feel::CRB< TruthModelType >::lb().

template<typename TruthModelType >
bool Feel::CRB< TruthModelType >::loadDB ( ) [virtual]
template<typename TruthModelType >
CRB< TruthModelType >::max_error_type Feel::CRB< TruthModelType >::maxErrorBounds ( size_type  N) const

Retuns maximum value of the relative error.

Parameters:
Nnumber of elements in the reduced basis <=> M_N

References Feel::CRB< TruthModelType >::delta(), Feel::CRB< TruthModelType >::lb(), and Feel::CRBDB::vm().

Referenced by Feel::CRB< TruthModelType >::offline().

template<typename TruthModelType>
int Feel::CRB< TruthModelType >::maxIter ( ) const [inline]
Returns:
max iterations
template<typename TruthModelType >
CRB< TruthModelType >::convergence_type Feel::CRB< TruthModelType >::offline ( )
template<typename TruthModelType >
void Feel::CRB< TruthModelType >::offlineResidual ( int  Ncur,
int  number_of_added_elements = 1 
)

generate offline the residual

Referenced by Feel::CRB< TruthModelType >::offline().

template<typename TruthModelType >
void Feel::CRB< TruthModelType >::orthonormalize ( size_type  N,
wn_type &  wn,
int  Nm = 1 
)

orthonormalize the basis

References Feel::CRBDB::vm().

Referenced by Feel::CRB< TruthModelType >::offline().

template<typename TruthModelType>
int Feel::CRB< TruthModelType >::outputIndex ( ) const [inline]
Returns:
the output index
template<typename TruthModelType >
bool Feel::CRB< TruthModelType >::printErrorDuringOfflineStep ( )

if true, print the max error (absolute) during the offline stage

References Feel::CRBDB::vm().

template<typename TruthModelType >
void Feel::CRB< TruthModelType >::printErrorsDuringRbConstruction ( void  )

print max errors (total error and also primal and dual contributions) during offline stage

template<typename TruthModelType >
void Feel::CRB< TruthModelType >::printMuSelection ( void  )

print parameters set mu selected during the offline stage

template<typename TruthModelType >
void Feel::CRB< TruthModelType >::projectionOnPodSpace ( const element_ptrtype &  u,
element_ptrtype &  projection,
const std::string &  name_of_space = "primal" 
)

do the projection on the POD space of u (for transient problems)

Parameters:
u: the solution to project (input parameter)
projection: the projection (output parameter)
name_of_space: primal or dual

Referenced by Feel::CRB< TruthModelType >::offline().

template<typename TruthModelType>
sampling_type Feel::CRB< TruthModelType >::randomSampling ( int  N) [inline]
Returns:
a random sampling
template<typename TruthModelType >
bool Feel::CRB< TruthModelType >::rebuildDB ( )

if true, rebuild the database (if already exist)

References Feel::CRBDB::vm().

Referenced by Feel::CRB< TruthModelType >::loadDB().

template<typename TruthModelType >
boost::tuple< double, double, double, double > Feel::CRB< TruthModelType >::run ( parameter_type const &  mu,
double  eps = 1e-6 
)

run the certified reduced basis with P parameters and returns 1 output

References Feel::CRB< TruthModelType >::delta(), Feel::CRB< TruthModelType >::lb(), and Feel::CRBDB::vm().

Referenced by Feel::CRB< TruthModelType >::run().

template<typename TruthModelType >
void Feel::CRB< TruthModelType >::run ( const double *  X,
unsigned long  N,
double *  Y,
unsigned long  P 
)

run the certified reduced basis with P parameters and returns 1 output

References Feel::CRB< TruthModelType >::run().

template<typename TruthModelType >
void Feel::CRB< TruthModelType >::saveDB ( ) [virtual]

save the CRB database

Reimplemented from Feel::CRBDB.

References Feel::CRBDB::dbFilename(), and Feel::CRBDB::dbLocalPath().

Referenced by Feel::CRB< TruthModelType >::offline().

template<typename TruthModelType>
scm_ptrtype Feel::CRB< TruthModelType >::scm ( ) const [inline]
Returns:
the scm object
template<typename TruthModelType >
bool Feel::CRB< TruthModelType >::showMuSelection ( )

if true, show the mu selected during the offline stage

References Feel::CRBDB::vm().

template<typename TruthModelType>
sampling_ptrtype Feel::CRB< TruthModelType >::trainSampling ( ) const [inline]
Returns:
the train sampling used to generate the reduced basis space
template<typename TruthModelType >
CRB< TruthModelType >::residual_error_type Feel::CRB< TruthModelType >::transientPrimalResidual ( int  Ncur,
parameter_type const &  mu,
vectorN_type const &  Un,
vectorN_type const &  Unold = vectorN_type(),
double  time_step = 1,
double  time = 1e30 
) const

evaluate online the residual

Referenced by Feel::CRB< TruthModelType >::delta().

template<typename TruthModelType>
value_type Feel::CRB< TruthModelType >::ub ( size_type  N,
parameter_type const &  mu,
std::vector< vectorN_type > &  uN,
std::vector< vectorN_type > &  uNdu 
) const [inline]

Returns the upper bound of the output associed to $\mu$

Parameters:
mu$ \mu$ the parameter at which to evaluate the output
Nthe dimension of $W_N$
uNprimal solution
uNdudual solution
Returns:
compute online the lower bound

References Feel::CRB< TruthModelType >::delta(), and Feel::CRB< TruthModelType >::lb().

Referenced by Feel::CRB< TruthModelType >::ub().

template<typename TruthModelType>
value_type Feel::CRB< TruthModelType >::ub ( size_type  K,
parameter_ptrtype const &  mu,
std::vector< vectorN_type > &  uN,
std::vector< vectorN_type > &  uNdu 
) const [inline]

Returns the upper bound of the output associed to $\mu$

Parameters:
mu$ \mu$ the parameter at which to evaluate the output
Nthe dimension of $W_N$
Returns:
compute online the lower bound

References Feel::CRB< TruthModelType >::ub().