From ea85942c512b3c5eac501716e4a89367d0ab415b Mon Sep 17 00:00:00 2001 From: romainhild Date: Wed, 5 Jun 2019 17:14:00 +0200 Subject: [PATCH] fix eim tests and opusapp --- feelpp/feel/feelcrb/deimbase.hpp | 2 +- feelpp/feel/feelcrb/eim.hpp | 18 +++++++++++------- feelpp/feel/feelcrb/opusapp_impl.hpp | 10 +++++----- mor/grepldeim/grepldeim.hpp | 1 - testsuite/feelcrb/test_deim.cpp | 16 ++++++---------- testsuite/feelcrb/test_eim.cpp | 2 ++ testsuite/feelcrb/test_eim_composite.cpp | 1 + testsuite/feelcrb/test_eim_grepl.cpp | 1 + 8 files changed, 27 insertions(+), 24 deletions(-) diff --git a/feelpp/feel/feelcrb/deimbase.hpp b/feelpp/feel/feelcrb/deimbase.hpp index 348b520f280..16ed7e6ee58 100644 --- a/feelpp/feel/feelcrb/deimbase.hpp +++ b/feelpp/feel/feelcrb/deimbase.hpp @@ -225,7 +225,7 @@ public : * Update the RB stored in DEIM. This RB is projected on the interpolation mesh * \p XN the reduced basis space containing the RB */ - virtual void updateRb( rbspace_ptrtype const& XN, std::vector> subN )=0; + virtual void updateRb( rbspace_ptrtype const& XN, std::vector> const& subN )=0; //! Set the value of M_offline_step. Used with SER void setOfflineStep( bool b ) { M_offline_step = b; } diff --git a/feelpp/feel/feelcrb/eim.hpp b/feelpp/feel/feelcrb/eim.hpp index 012cf44f8ce..0990f17c281 100644 --- a/feelpp/feel/feelcrb/eim.hpp +++ b/feelpp/feel/feelcrb/eim.hpp @@ -1328,9 +1328,10 @@ class EIMFunctionBase : public CRBDB sampling_ptrtype const& sampling, std::string const& modelname, std::string const& name, - uuids::uuid const& uid ) + uuids::uuid const& uid, + std::string const& prefix ) : - EIMFunctionBase( pspace, sampling, modelname, name, uid ) + EIMFunctionBase( pspace, sampling, modelname, name, uid, prefix ) { M_fspace = fspace; } @@ -1832,8 +1833,8 @@ class EIMFunction M_B(), M_offline_error(), M_eim(), - M_write_nl_solutions( boption(_prefix=this->M_prefix, "eim.elements.write") ), - M_write_nl_directory( soption(_prefix=this->M_prefix, "eim.elements.directory") ) + M_write_nl_solutions( boption(_prefix=this->M_prefix, _name="eim.elements.write") ), + M_write_nl_directory( soption(_prefix=this->M_prefix, _name="eim.elements.directory") ) { if ( model ) M_eimFeSpaceDb.setModel( model ); @@ -1901,7 +1902,7 @@ class EIMFunction if ( this->worldComm().isMasterRank() ) { boost::filesystem::path dir( M_write_nl_directory ); - if ( boost::filesystem::exists(dir) && boption(_prefix=this->M_prefix, "eim.elements.clean-directory" ) ) + if ( boost::filesystem::exists(dir) && boption(_prefix=this->M_prefix, _name="eim.elements.clean-directory" ) ) { boost::filesystem::remove_all(dir); boost::filesystem::create_directory(dir); @@ -3448,9 +3449,10 @@ struct EimFunctionNoSolve : public EimFunctionNoSolveBase fusion::vector< mpl::int_<0>, mpl::int_<1>, mpl::int_<2>, mpl::int_<3>, mpl::int_<4> > >::type >::type >::type index_vector_type; - EimFunctionNoSolve( model_ptrtype const& model ) + EimFunctionNoSolve( model_ptrtype const& model, std::string const& prefix = "" ) : - M_model( model ) + M_model( model ), + M_prefix( prefix ) { if ( model->functionSpace() ) { @@ -3488,6 +3490,7 @@ struct EimFunctionNoSolve : public EimFunctionNoSolveBase #endif std::string /*const&*/ modelName() const { return M_model.lock()->modelName(); } + std::string prefix() const { return M_prefix; } uuids::uuid uuid() const { return M_model.lock()->uuid(); } functionspace_ptrtype const& functionSpace() const { return M_model.lock()->functionSpace(); } parameterspace_ptrtype const& parameterSpace() const { return M_model.lock()->parameterSpace(); } @@ -3520,6 +3523,7 @@ struct EimFunctionNoSolve : public EimFunctionNoSolveBase #endif // model_ptrtype M_model; model_weakptrtype M_model; + std::string M_prefix; element_ptrtype M_elt; }; diff --git a/feelpp/feel/feelcrb/opusapp_impl.hpp b/feelpp/feel/feelcrb/opusapp_impl.hpp index 7e612f3b0c1..c8b4d6c1879 100644 --- a/feelpp/feel/feelcrb/opusapp_impl.hpp +++ b/feelpp/feel/feelcrb/opusapp_impl.hpp @@ -631,7 +631,7 @@ OpusApp::run() std::ofstream res(soption(_name="result-file") ); res << "output="<< o[0] << "\n"; - if( this->vm().count("crb.minimization-func") ) + if( this->vm().count("crb.minimization-func") && !soption("crb.minimization-func").empty() ) { auto min_func = expr( min_func_str, "min_func" ); min_map[soption(_name="crb.minimization-param-name")] = output_fem; @@ -848,7 +848,7 @@ OpusApp::run() } } - if( this->vm().count("crb.minimization-func") ) + if( this->vm().count("crb.minimization-func") && !soption("crb.minimization-func").empty() ) { auto min_func = expr( min_func_str, "min_func" ); min_map[soption(_name="crb.minimization-param-name")] = ofem[0]; @@ -888,7 +888,7 @@ OpusApp::run() std::ofstream res(soption(_name="result-file") ); res << "output="<< ocrb << "\n"; - if( this->vm().count("crb.minimization-func") ) + if( this->vm().count("crb.minimization-func") && !soption("crb.minimization-func").empty() ) { auto min_func = expr( min_func_str, "min_func" ); min_map[soption(_name="crb.minimization-param-name")] = ocrb; @@ -932,7 +932,7 @@ OpusApp::run() std::ofstream res(soption(_name="result-file") ); res << "output="<< ocrb << "\n"; - if( this->vm().count("crb.minimization-func") ) + if( this->vm().count("crb.minimization-func") && !soption("crb.minimization-func").empty() ) { auto min_func = expr( min_func_str, "min_func" ); min_map[soption(_name="crb.minimization-param-name")] = ocrb; @@ -1829,7 +1829,7 @@ OpusApp::run() }//end of compute-stat CRB // Find the output which minimize user-defined functional - if( this->vm().count("crb.minimization-func") && proc_number == Environment::worldComm().masterRank() ) + if( this->vm().count("crb.minimization-func") && !soption("crb.minimization-func").empty() && proc_number == Environment::worldComm().masterRank() ) { if( M_mode==CRBModelMode::PFEM || compute_fem ) { diff --git a/mor/grepldeim/grepldeim.hpp b/mor/grepldeim/grepldeim.hpp index 8ebf0343b22..21c05007889 100644 --- a/mor/grepldeim/grepldeim.hpp +++ b/mor/grepldeim/grepldeim.hpp @@ -578,7 +578,6 @@ GreplDEIM::updateJacobianMonolithic( vector_ptrtype const& X, u=*X; double gamma = doption(_name="gamma"); - auto g = exp( mu(1)*idv(u) ); J->zero(); form2( _test=Xh, _trial=Xh, _matrix=J ) = diff --git a/testsuite/feelcrb/test_deim.cpp b/testsuite/feelcrb/test_deim.cpp index 6ad3239675d..a07d3f688e1 100644 --- a/testsuite/feelcrb/test_deim.cpp +++ b/testsuite/feelcrb/test_deim.cpp @@ -59,14 +59,6 @@ public : typedef std::shared_ptr space_ptrtype; typedef typename space_type::element_type element_type; - typedef Pch_type scalarspace_type; - typedef Pchv_type vectorialspace_type; - typedef typename mpl::if_< mpl::bool_, - vectorialspace_type, - scalarspace_type>::type space_type; - typedef boost::shared_ptr space_ptrtype; - typedef typename space_type::element_type element_type; - typedef Backend backend_type; typedef std::shared_ptr backend_ptrtype; typedef backend_type::vector_type vector_type; @@ -87,10 +79,11 @@ public : typedef std::shared_ptr deim_ptrtype; - DeimTest() : + DeimTest( std::string const& prefix = "") : M_backend( backend() ), Dmu( parameterspace_type::New(2) ), - M_uuid( Environment::randomUUID( true ) ) + M_uuid( Environment::randomUUID( true ) ), + M_prefix(prefix) { auto mesh = loadMesh( _mesh=new mesh_type, _filename="test_deim.geo"); Xh = space_type::New( mesh ); @@ -112,7 +105,9 @@ public : } uuids::uuid uuid() const { return M_uuid; } + std::string prefix() const { return M_prefix; } parameterspace_ptrtype parameterSpace() { return Dmu;} + void setOnlineModel() {} void run() { @@ -327,6 +322,7 @@ private : deim_ptrtype M_deim; std::vector betas; + std::string M_prefix; }; FEELPP_ENVIRONMENT_WITH_OPTIONS( makeAbout(), makeOptions() ) diff --git a/testsuite/feelcrb/test_eim.cpp b/testsuite/feelcrb/test_eim.cpp index 8e242b7c51c..413e7f4b58c 100644 --- a/testsuite/feelcrb/test_eim.cpp +++ b/testsuite/feelcrb/test_eim.cpp @@ -223,6 +223,7 @@ class EimModel: return Dmu; } std::string modelName() const { return std::string("test_eim_model1" );} + std::string prefix() const { return ""; } uuids::uuid uuid() const { return boost::uuids::nil_uuid(); } space_ptrtype const& functionSpace() const { return Xh; } @@ -403,6 +404,7 @@ class EimModelCircle: } std::string modelName() const { return std::string("test_eim_model2" );} + std::string prefix() const { return ""; } uuids::uuid uuid() const { return boost::uuids::nil_uuid(); } //! return the parameter space diff --git a/testsuite/feelcrb/test_eim_composite.cpp b/testsuite/feelcrb/test_eim_composite.cpp index 1919a775b56..f468ba3984c 100644 --- a/testsuite/feelcrb/test_eim_composite.cpp +++ b/testsuite/feelcrb/test_eim_composite.cpp @@ -198,6 +198,7 @@ class EimModel: return Dmu; } std::string modelName() const { return std::string("test_eim_composite" );} + std::string prefix() const { return ""; } uuids::uuid uuid() const { return boost::uuids::nil_uuid(); } space_ptrtype const& functionSpace() const { return Xh; } diff --git a/testsuite/feelcrb/test_eim_grepl.cpp b/testsuite/feelcrb/test_eim_grepl.cpp index 01d2a2b44bd..7c2fd830f01 100644 --- a/testsuite/feelcrb/test_eim_grepl.cpp +++ b/testsuite/feelcrb/test_eim_grepl.cpp @@ -152,6 +152,7 @@ class EimModel: return Dmu; } std::string modelName() const { return std::string("test_eim_grepl" );} + std::string prefix() const { return ""; } uuids::uuid uuid() const { return Environment::nameUUID( boost::uuids::nil_uuid(), (boost::format("%1%_%2%")%this->modelName() %Environment::worldComm().localSize()).str() );