29 #ifndef __OpusEadsCrbApp_H
30 #define __OpusEadsCrbApp_H 1
44 template<
typename ModelType>
51 typedef boost::shared_ptr<crbmodel_type> crbmodel_ptrtype;
53 typedef boost::shared_ptr<crb_type> crb_ptrtype;
62 CRBApp(
int argc,
char** argv,
AboutData const& ad, po::options_description
const& od )
64 super( argc, argv, ad, crbOptions().
add( od ) )
70 std::srand( static_cast<unsigned>( std::time( 0 ) ) );
71 std::cerr <<
"[CRBApp] constructor " << this->
about().
appName() << std::endl;
73 if ( this->
vm().count(
"crb.output-index" ) )
75 % this->
about().appName()
76 % this->
vm()[
"hsize"].
template as<double>()
77 % this->
vm()[
"crb.output-index"].
template as<int>()
82 % this->
about().appName()
83 % this->
vm()[
"hsize"].
template as<double>()
86 std::cerr <<
"[CRBApp] ch repo" << std::endl;
88 std::cerr <<
"[CRBApp] set Logs" << std::endl;
90 std::cerr <<
"[CRBApp] get model done" << std::endl;
94 std::cerr <<
"[CRBApp] get crb done" << std::endl;
95 crb->setTruthModel( opus );
96 std::cerr <<
"[CRBApp] constructor done" << std::endl;
99 void setOutput(
int i = 0,
CRBErrorType error_type = (
int )CRB_RESIDUAL ,
int maxiter = 10 )
101 auto ckconv = crb->offline();
108 crb->computeErrorEstimationEfficiencyIndicator ( opus->parameterSpace(), max_ei, min_ei,10 );
111 for (
auto it = ckconv.left.begin(); it != ckconv.left.end(); ++it )
113 LOG(INFO) <<
"ckconv[" << it->first <<
"]=" << it->second <<
"\n";
119 if ( this->
vm().count(
"help" ) )
125 if ( !crb->isDBLoaded() )
127 std::cout <<
"No DB available, do offline computations first...\n";
131 typename crb_type::sampling_ptrtype Sampling(
new typename crb_type::sampling_type( opus->parameterSpace() ) );
132 Sampling->randomize( 10 );
133 int crb_error_type = crb->errorType();
134 int output_index = crb->outputIndex();
135 BOOST_FOREACH(
auto mu, *Sampling )
137 double sfem = opus->output( output_index, mu );
138 int size = mu.size();
139 std::cout <<
"------------------------------------------------------------\n";
140 std::cout <<
"tolerance : " << this->
vm()[
"crb.online-tolerance"].template as<double>() <<
"\n";
141 std::cout <<
"mu = [ ";
143 for (
int i=0; i<size-1; i++ ) std::cout<< mu[i] <<
" , ";
145 std::cout<< mu[size-1]<<
" ] \n";
146 auto o = crb->run( mu, this->
vm()[
"crb.online-tolerance"].
template as<double>() );
148 if ( crb_error_type==2 )
150 std::cout <<
"output=" << o.get<0>() <<
" with " << o.get<2>() <<
" basis functions\n";
151 std::cout <<
"output obtained using FEM : "<<sfem<<std::endl;
156 std::cout <<
"output=" << o.get<0>() <<
" with " << o.get<2>() <<
" basis functions (error estimation on this output : " << o.get<1>()<<
") \n";
157 std::cout <<
"output obtained using FEM : "<<sfem<<std::endl;
160 std::cout <<
"------------------------------------------------------------\n";
163 void run(
const double * X,
unsigned long N,
164 double * Y,
unsigned long P )
166 crb->run( X, N, Y, P );
169 crbmodel_ptrtype opus;