Skip to content

Commit

Permalink
fix eim tests and opusapp
Browse files Browse the repository at this point in the history
  • Loading branch information
romainhild committed Jun 5, 2019
1 parent 513c470 commit ea85942
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 24 deletions.
2 changes: 1 addition & 1 deletion feelpp/feel/feelcrb/deimbase.hpp
Expand Up @@ -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<std::vector<int>> subN )=0;
virtual void updateRb( rbspace_ptrtype const& XN, std::vector<std::vector<int>> const& subN )=0;

//! Set the value of M_offline_step. Used with SER
void setOfflineStep( bool b ) { M_offline_step = b; }
Expand Down
18 changes: 11 additions & 7 deletions feelpp/feel/feelcrb/eim.hpp
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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() )
{
Expand Down Expand Up @@ -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(); }
Expand Down Expand Up @@ -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;
};

Expand Down
10 changes: 5 additions & 5 deletions feelpp/feel/feelcrb/opusapp_impl.hpp
Expand Up @@ -631,7 +631,7 @@ OpusApp<ModelType,RM,Model>::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;
Expand Down Expand Up @@ -848,7 +848,7 @@ OpusApp<ModelType,RM,Model>::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];
Expand Down Expand Up @@ -888,7 +888,7 @@ OpusApp<ModelType,RM,Model>::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;
Expand Down Expand Up @@ -932,7 +932,7 @@ OpusApp<ModelType,RM,Model>::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;
Expand Down Expand Up @@ -1829,7 +1829,7 @@ OpusApp<ModelType,RM,Model>::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 )
{
Expand Down
1 change: 0 additions & 1 deletion mor/grepldeim/grepldeim.hpp
Expand Up @@ -578,7 +578,6 @@ GreplDEIM<Order,Dim>::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 ) =
Expand Down
16 changes: 6 additions & 10 deletions testsuite/feelcrb/test_deim.cpp
Expand Up @@ -59,14 +59,6 @@ public :
typedef std::shared_ptr<space_type> space_ptrtype;
typedef typename space_type::element_type element_type;

typedef Pch_type<mesh_type,POrder> scalarspace_type;
typedef Pchv_type<mesh_type,POrder> vectorialspace_type;
typedef typename mpl::if_< mpl::bool_<is_vect>,
vectorialspace_type,
scalarspace_type>::type space_type;
typedef boost::shared_ptr<space_type> space_ptrtype;
typedef typename space_type::element_type element_type;

typedef Backend<double> backend_type;
typedef std::shared_ptr<backend_type> backend_ptrtype;
typedef backend_type::vector_type vector_type;
Expand All @@ -87,10 +79,11 @@ public :
typedef std::shared_ptr<deim_type> 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 );
Expand All @@ -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()
{
Expand Down Expand Up @@ -327,6 +322,7 @@ private :
deim_ptrtype M_deim;
std::vector<vectorN_type> betas;

std::string M_prefix;
};

FEELPP_ENVIRONMENT_WITH_OPTIONS( makeAbout(), makeOptions() )
Expand Down
2 changes: 2 additions & 0 deletions testsuite/feelcrb/test_eim.cpp
Expand Up @@ -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; }
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions testsuite/feelcrb/test_eim_composite.cpp
Expand Up @@ -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; }

Expand Down
1 change: 1 addition & 0 deletions testsuite/feelcrb/test_eim_grepl.cpp
Expand Up @@ -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() );
Expand Down

0 comments on commit ea85942

Please sign in to comment.