#include <crb.hpp>
Certifed Reduced Basis class.
Implements the certified reduced basis method
Public Member Functions | |
Constructors, destructor | |
CRB () | |
default constructor | |
CRB (std::string name, po::variables_map const &vm) | |
constructor from command line options | |
CRB (std::string name, po::variables_map const &vm, truth_model_ptrtype const &model) | |
constructor from command line options | |
CRB (CRB const &o) | |
copy constructor | |
~CRB () | |
destructor | |
Operator overloads | |
CRB & | operator= (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 |
void | loadSCMDB () |
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 | |
void | setOfflineStep (bool b) |
set boolean indicates if we are in offline_step or not | |
Methods | |
double | 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, element_type &u, element_type &udu) const |
void | compareResidualsForTransientProblems (int N, parameter_type const &mu, std::vector< element_type > const &Un, std::vector< element_type > const &Unold, std::vector< element_type > const &Undu, std::vector< element_type > const &Unduold, std::vector< std::vector< double > > const &primal_residual_coeffs, std::vector< std::vector< double > > const &dual_residual_coeffs) const |
void | buildFunctionFromRbCoefficients (int N, std::vector< vectorN_type > const &RBcoeff, wn_type const &WN, std::vector< element_ptrtype > &FEMsolutions) |
double | 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 |
void | updateJacobian (const map_dense_vector_type &map_X, map_dense_matrix_type &map_J, const parameter_type &mu, int N) const |
void | updateResidual (const map_dense_vector_type &map_X, map_dense_vector_type &map_R, const parameter_type &mu, int N) const |
void | computeProjectionInitialGuess (const parameter_type &mu, int N, vectorN_type &initial_guess) const |
void | newton (size_type N, parameter_type const &mu, vectorN_type &uN, double &condition_number, double &output) const |
element_type | offlineFixedPointPrimal (parameter_type const &mu, sparse_matrix_ptrtype &A, bool zero_iteration) |
element_type | offlineFixedPointDual (parameter_type const &mu, element_ptrtype &dual_initial_field, const sparse_matrix_ptrtype &A, const element_type &u, bool zero_iteration) |
void | fixedPointPrimal (size_type N, parameter_type const &mu, std::vector< vectorN_type > &uN, std::vector< vectorN_type > &uNold, double &condition_number, std::vector< double > &output_vector, int K=0) const |
void | fixedPointDual (size_type N, parameter_type const &mu, std::vector< vectorN_type > &uNdu, std::vector< vectorN_type > &uNduold, std::vector< double > &output_vector, int K=0) const |
void | fixedPoint (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, double &condition_number, std::vector< double > &output_vector, int K=0) const |
double | computeConditioning (matrixN_type &A) 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. More... | |
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 |
element_type | expansion (parameter_type const &mu, int N=-1, int time_index=-1) |
element_type | expansion (vectorN_type const &u, int const N, wn_type const &WN) const |
void | checkInitialGuess (const element_type expansion_uN, parameter_type const &mu, vectorN_type &error) const |
void | checkInitialGuess (const element_type expansion_uN, parameter_type const &mu, vectorN_type &error, mpl::bool_< true >) const |
void | checkInitialGuess (const element_type expansion_uN, parameter_type const &mu, vectorN_type &error, mpl::bool_< false >) const |
boost::tuple< double, double, solutions_tuple, double, double, double, upper_bounds_tuple > | run (parameter_type const &mu, double eps=1e-6, int N=-1) |
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) |
sampling_ptrtype | wnmu () const |
wn_type | wn () const |
wn_type | wndu () const |
void | saveDB () |
bool | loadDB () |
void | projectionOnPodSpace (const element_type &u, element_ptrtype &projection, const std::string &name_of_space="primal") |
bool | useWNmu () |
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) |
void | buildVarianceMatrixPhi (int const N, mpl::bool_< true >) |
void | buildVarianceMatrixPhi (int const N, mpl::bool_< false >) |
WorldComm const & | worldComm () const |
void | computationalTimeStatistics (std::string appname) |
![]() | |
CRBDB () | |
default constructor | |
CRBDB (std::string prefixdir, std::string name, std::string dbprefix, po::variables_map const &vm) | |
constructor from command line options | |
CRBDB (CRBDB const &) | |
copy constructor | |
virtual | ~CRBDB () |
destructor | |
CRBDB & | operator= (CRBDB const &o) |
copy operator | |
std::string const & | prefixDirectory () const |
std::string const & | name () const |
std::string const & | dbFilename () const |
fs::path | dbLocalPath () const |
fs::path | dbSystemPath () const |
fs::path | lookForDB () const |
po::variables_map | vm () |
po::variables_map | vm () const |
bool | isDBLoaded () const |
void | setDBFilename (std::string const &filename) |
set the DB filename | |
Friends | |
class | boost::serialization::access |
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 CRB | self_type |
typedef CRBSCM< truth_model_type > | scm_type |
scm | |
typedef boost::shared_ptr < scm_type > | scm_ptrtype |
typedef CRBElementsDB < truth_model_type > | crb_elements_db_type |
elements database | |
typedef boost::shared_ptr < crb_elements_db_type > | crb_elements_db_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::beta_vector_type | beta_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_type > | wn_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 Eigen::Map < Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > > | map_dense_matrix_type |
typedef Eigen::Map < Eigen::Matrix< double, Eigen::Dynamic, 1 > > | map_dense_vector_type |
typedef boost::tuple < std::vector< vectorN_type > , std::vector< vectorN_type > , std::vector< vectorN_type > , std::vector< vectorN_type > > | solutions_tuple |
typedef boost::tuple< double, double, double, std::vector < std::vector< double > >, std::vector< std::vector < double > > > | upper_bounds_tuple |
typedef std::vector< element_type > | mode_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 boost::shared_ptr < space_type > | space_ptrtype |
typedef Bdf< space_type > | bdf_type |
time discretization | |
typedef boost::shared_ptr < bdf_type > | bdf_ptrtype |
typedef Exporter< mesh_type > | export_type |
typedef boost::shared_ptr < export_type > | export_ptrtype |
typedef Preconditioner< double > | preconditioner_type |
typedef boost::shared_ptr < preconditioner_type > | preconditioner_ptrtype |
typedef mpl::if_ < boost::is_same< mpl::int_ < nb_spaces >, mpl::int_ < 2 > >, fusion::vector < mpl::int_< 0 >, mpl::int_ < 1 > >, typename mpl::if_ < boost::is_same< mpl::int_ < nb_spaces >, mpl::int_ < 3 > >, fusion::vector < mpl::int_< 0 >, mpl::int_ < 1 >, mpl::int_ < 2 > >, typename mpl::if_ < boost::is_same< mpl::int_ < nb_spaces >, mpl::int_ < 4 > >, fusion::vector < mpl::int_< 0 >, mpl::int_ < 1 >, mpl::int_ < 2 >, mpl::int_ < 3 > >, fusion::vector < mpl::int_< 0 >, mpl::int_ < 1 >, mpl::int_ < 2 >, mpl::int_ < 3 >, mpl::int_ < 4 > > >::type >::type > ::type | index_vector_type |
static const int | nb_spaces = functionspace_type::nSpaces |
Additional Inherited Members | |
![]() | |
template<class Archive > | |
void | load (Archive &ar, const unsigned int version) |
template<class Archive > | |
void | save (Archive &ar, const unsigned int version) const |
void | setIsLoaded (bool isloaded) |
check the reduced basis space invariant properties
N | dimension of ![]() |
References Feel::CRB< TruthModelType >::delta(), Feel::CRB< TruthModelType >::lb(), and Feel::CRBDB::vm().
void Feel::CRB< TruthModelType >::computationalTimeStatistics | ( | std::string | appname) |
evaluate online time via the option crb.computational-time-neval
References Feel::CRB< TruthModelType >::dimension(), and Feel::CRB< TruthModelType >::run().
double Feel::CRB< TruthModelType >::computeConditioning | ( | matrixN_type & | A) | const |
computation of the conditioning number of a given matrix
A | : reduced matrix |
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
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().
|
inline |
Returns the error bound on the output
mu | ![]() |
N | the size of the reduced basis space to use |
uN | primal solution |
uNdu | dual solution |
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 | ![]() |
N | the dimension of ![]() |
uN | primal solution |
uNdu | dual solution |
References Feel::CRB< TruthModelType >::transientPrimalResidual(), and Feel::CRBDB::vm().
|
inline |
|
inline |
|
inline |
|
inline |
CRB< TruthModelType >::element_type Feel::CRB< TruthModelType >::expansion | ( | parameter_type const & | mu, |
int | N = -1 , |
||
int | time_index = -1 |
||
) |
return the crb expansion at parameter , ie
where $, i=1...N$ are the basis function of the reduced basis space if N>0 take the N^th first elements, else take all elements
References Feel::CRB< TruthModelType >::lb().
CRB< TruthModelType >::element_type Feel::CRB< TruthModelType >::expansion | ( | vectorN_type const & | u, |
int const | N, | ||
wn_type const & | WN | ||
) | const |
return the crb expansion at parameter , ie
where $, i=1...N$ are the basis function of the reduced basis space
void Feel::CRB< TruthModelType >::exportBasisFunctions | ( | const export_vector_wn_type & | wn) | const |
export basis functions to visualize it
wn | : tuple composed of a vector of wn_type and a vector of string (used to name basis) |
References Feel::CRBDB::name().
void Feel::CRB< TruthModelType >::fixedPoint | ( | 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, | ||
double & | condition_number, | ||
std::vector< double > & | output_vector, | ||
int | K = 0 |
||
) | const |
fixed point ( main ) - ONLINE step
N | : dimension of the reduced basis |
mu | :current parameter |
uN | : dual reduced solution ( vectorN_type ) |
uNdu | : dual reduced solution ( vectorN_type ) |
uNold | : dual old reduced solution ( vectorN_type ) |
uNduold | : dual old reduced solution ( vectorN_type ) |
output | : vector of outpus at each time step |
K | : number of time step ( default value, must be >0 if used ) |
References Feel::CRBDB::vm().
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
mu | ![]() |
N | the size of the reduced basis space to use |
uN | primal solution |
uNdu | dual 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 |
References Feel::CRB< TruthModelType >::fixedPoint(), Feel::CRBDB::name(), and Feel::CRBDB::vm().
|
inline |
Returns the lower bound of the output
mu | ![]() |
N | the size of the reduced basis space to use |
uN | primal solution |
uNdu | dual solution |
References Feel::CRB< TruthModelType >::lb().
|
virtual |
load the CRB database
Reimplemented from Feel::CRBDB.
References Feel::CRBDB::isDBLoaded(), Feel::CRBDB::lookForDB(), and Feel::CRB< TruthModelType >::rebuildDB().
CRB< TruthModelType >::max_error_type Feel::CRB< TruthModelType >::maxErrorBounds | ( | size_type | N) | const |
Retuns maximum value of the relative error.
N | number of elements in the reduced basis <=> M_N |
References Feel::CRB< TruthModelType >::delta(), Feel::CRB< TruthModelType >::lb(), and Feel::CRBDB::vm().
|
inline |
CRB< TruthModelType >::convergence_type Feel::CRB< TruthModelType >::offline | ( | ) |
Offline computation
References Feel::CRB< TruthModelType >::check(), Feel::CRB< TruthModelType >::exportBasisFunctions(), Feel::inner_product(), Feel::CRB< TruthModelType >::maxErrorBounds(), Feel::CRB< TruthModelType >::offlineResidual(), Feel::CRB< TruthModelType >::orthonormalize(), Feel::CRB< TruthModelType >::saveDB(), and Feel::CRBDB::vm().
void Feel::CRB< TruthModelType >::offlineResidual | ( | int | Ncur, |
int | number_of_added_elements = 1 |
||
) |
generate offline the residual
double Feel::CRB< TruthModelType >::orthonormalize | ( | size_type | N, |
wn_type & | wn, | ||
int | Nm = 1 |
||
) |
orthonormalize the basis return the norm of the matrix A(i,j)=M_model->scalarProduct( WN[j], WN[i] ), should be 0
|
inline |
bool Feel::CRB< TruthModelType >::printErrorDuringOfflineStep | ( | ) |
if true, print the max error (absolute) during the offline stage
References Feel::CRBDB::vm().
void Feel::CRB< TruthModelType >::printErrorsDuringRbConstruction | ( | void | ) |
print max errors (total error and also primal and dual contributions) during offline stage
void Feel::CRB< TruthModelType >::printMuSelection | ( | void | ) |
print parameters set mu selected during the offline stage
void Feel::CRB< TruthModelType >::projectionOnPodSpace | ( | const element_type & | u, |
element_ptrtype & | projection, | ||
const std::string & | name_of_space = "primal" |
||
) |
do the projection on the POD space of u (for transient problems)
u | : the solution to project (input parameter) |
projection | : the projection (output parameter) |
name_of_space | : primal or dual |
|
inline |
bool Feel::CRB< TruthModelType >::rebuildDB | ( | ) |
if true, rebuild the database (if already exist)
References Feel::CRBDB::vm().
boost::tuple< double, double, typename CRB< TruthModelType >::solutions_tuple, double, double, double, typename CRB< TruthModelType >::upper_bounds_tuple > Feel::CRB< TruthModelType >::run | ( | parameter_type const & | mu, |
double | eps = 1e-6 , |
||
int | N = -1 |
||
) |
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().
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().
|
virtual |
save the CRB database
Reimplemented from Feel::CRBDB.
References Feel::CRBDB::dbFilename(), and Feel::CRBDB::dbLocalPath().
|
inline |
bool Feel::CRB< TruthModelType >::showMuSelection | ( | ) |
if true, show the mu selected during the offline stage
References Feel::CRBDB::vm().
|
inline |
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
|
inline |
Returns the upper bound of the output associed to
mu | ![]() |
N | the dimension of ![]() |
uN | primal solution |
uNdu | dual solution |
References Feel::CRB< TruthModelType >::delta(), and Feel::CRB< TruthModelType >::lb().
|
inline |
Returns the upper bound of the output associed to
mu | ![]() |
N | the dimension of ![]() |
References Feel::CRB< TruthModelType >::ub().