Commit 69bf24e1 authored by GILLES Sebastien's avatar GILLES Sebastien

#1467 Following #1432, there is no need to keep track of the LuaOptionFile...

#1467 Following #1432, there is no need to keep track of the LuaOptionFile used to interpret input data file.
parent 3025d204
...@@ -51,7 +51,7 @@ BOOST_FIXTURE_TEST_CASE(check_value, TestNS::FixtureNS::Environment) ...@@ -51,7 +51,7 @@ BOOST_FIXTURE_TEST_CASE(check_value, TestNS::FixtureNS::Environment)
FilesystemNS::Folder::Create(output_directory, __FILE__, __LINE__); FilesystemNS::Folder::Create(output_directory, __FILE__, __LINE__);
auto generated_lua = environment.SubstituteValues(output_directory + "generated_lua_file.lua"); auto generated_lua = environment.SubstituteValues(output_directory + "generated_default_lua_file.lua");
if (FilesystemNS::File::DoExist(generated_lua)) if (FilesystemNS::File::DoExist(generated_lua))
FilesystemNS::File::Remove(generated_lua, __FILE__, __LINE__); FilesystemNS::File::Remove(generated_lua, __FILE__, __LINE__);
...@@ -66,14 +66,16 @@ BOOST_FIXTURE_TEST_CASE(check_value, TestNS::FixtureNS::Environment) ...@@ -66,14 +66,16 @@ BOOST_FIXTURE_TEST_CASE(check_value, TestNS::FixtureNS::Environment)
TestNS::InitializeTestMoReFEMData<input_data_type> init(std::move(full_fledged_lua_file)); TestNS::InitializeTestMoReFEMData<input_data_type> init(std::move(full_fledged_lua_file));
auto generated_by_direct_call_lua_file = output_directory + "/generated_by_direct_call_lua_file.lua"; auto generated_by_direct_call_lua_file = output_directory + "/generated_by_direct_call_default_lua_file.lua";
Utilities::InputDataNS::CreateDefaultInputFile<input_data_type::Tuple>(generated_by_direct_call_lua_file); Utilities::InputDataNS::CreateDefaultInputFile<input_data_type::Tuple>(generated_by_direct_call_lua_file);
BOOST_CHECK(FilesystemNS::File::AreEquals(generated_lua, generated_by_direct_call_lua_file, __FILE__, __LINE__)); BOOST_CHECK(FilesystemNS::File::AreEquals(generated_lua, generated_by_direct_call_lua_file, __FILE__, __LINE__));
decltype(auto) morefem_data = init.GetMoReFEMData();
auto lua_file_with_content = output_directory + "/generated_with_content.lua";
// Utilities::InputDataNS::Print(morefem_data.GetInputData(), lua_file_with_content);
} }
PRAGMA_DIAGNOSTIC(pop) PRAGMA_DIAGNOSTIC(pop)
......
...@@ -198,13 +198,6 @@ namespace MoReFEM ...@@ -198,13 +198,6 @@ namespace MoReFEM
//! \return Path to the input data file. //! \return Path to the input data file.
const std::string& GetInputFile() const; const std::string& GetInputFile() const;
private:
//! Get the underlying \a LuaOptionFile object.
//! \return Get the underlying \a LuaOptionFile object.
const LuaOptionFile& GetLuaOptionFile() const noexcept;
private: private:
...@@ -319,10 +312,13 @@ namespace MoReFEM ...@@ -319,10 +312,13 @@ namespace MoReFEM
* file tuple. * file tuple.
* *
* \param[in] filename Path to the input file. * \param[in] filename Path to the input file.
* \param[in] lua_option_file The object that helps interpreting the content of the Lua file.
* \param[in] do_track_unused_fields See constructor. * \param[in] do_track_unused_fields See constructor.
* *
*/ */
void CheckUnboundInputData(const std::string& filename, DoTrackUnusedFields do_track_unused_fields) const; void CheckUnboundInputData(const std::string& filename,
LuaOptionFile& lua_option_file,
DoTrackUnusedFields do_track_unused_fields) const;
public: public:
...@@ -335,27 +331,9 @@ namespace MoReFEM ...@@ -335,27 +331,9 @@ namespace MoReFEM
//! Number of elements in the tuple. //! Number of elements in the tuple.
enum { tuple_size_ = std::tuple_size<Tuple>::value }; enum { tuple_size_ = std::tuple_size<Tuple>::value };
//! The tuple that actually stores all the relevant quantities for the problem. //! The tuple that actually stores all the relevant quantities for the problem.
Tuple tuple_; Tuple tuple_;
/*!
* \brief Keep track of which input parameter was actually used in the program.
*
* The bitset ordering is exactly the same as the tuple, so if bitset[10] is set, it simply means
* the 11th element of the Tuple was actually used.
*/
// mutable std::bitset<tuple_size_> used_;
/*!
* \brief Store the underlying \a Lua object.
*
* \internal <b><tt>[internal]</tt></b> It is still required past construction to deal with functions
* defined in the input data file: it is this object which handles the calls to Lua to provide
* the function outputs.
*/
LuaOptionFile::unique_ptr lua_option_file_ = nullptr;
//! Path of the input data file. //! Path of the input data file.
std::string input_data_file_; std::string input_data_file_;
......
...@@ -34,7 +34,6 @@ namespace MoReFEM ...@@ -34,7 +34,6 @@ namespace MoReFEM
const Wrappers::Mpi& mpi, const Wrappers::Mpi& mpi,
DoTrackUnusedFields do_track_unused_fields) DoTrackUnusedFields do_track_unused_fields)
: mpi_parent(mpi), : mpi_parent(mpi),
lua_option_file_(nullptr),
input_data_file_(filename) input_data_file_(filename)
{ {
int is_initialized; int is_initialized;
...@@ -49,13 +48,12 @@ namespace MoReFEM ...@@ -49,13 +48,12 @@ namespace MoReFEM
CheckNoDuplicateKeysInTuple(); CheckNoDuplicateKeysInTuple();
// Init Lua option file. LuaOptionFile lua_option_file(filename, __FILE__, __LINE__);
lua_option_file_ = std::make_unique<LuaOptionFile>(filename, __FILE__, __LINE__);
CheckUnboundInputData(filename, do_track_unused_fields); CheckUnboundInputData(filename, lua_option_file, do_track_unused_fields);
// Fill from the file all the objects in tuple_. // Fill from the file all the objects in tuple_.
Internal::InputDataNS::FillTuple<TupleT>(this, lua_option_file_.get(), tuple_); Internal::InputDataNS::FillTuple<TupleT>(this, lua_option_file, tuple_);
} }
...@@ -206,13 +204,12 @@ namespace MoReFEM ...@@ -206,13 +204,12 @@ namespace MoReFEM
template<class DerivedT, class TupleT> template<class DerivedT, class TupleT>
void Base<DerivedT, TupleT>::CheckUnboundInputData(const std::string& filename, void Base<DerivedT, TupleT>::CheckUnboundInputData(const std::string& filename,
DoTrackUnusedFields do_track_unused_fields) const LuaOptionFile& lua_option_file,
DoTrackUnusedFields do_track_unused_fields) const
{ {
// Check there are no parameters undefined in the tuple. // Check there are no parameters undefined in the tuple.
if (do_track_unused_fields == DoTrackUnusedFields::yes) if (do_track_unused_fields == DoTrackUnusedFields::yes)
{ {
decltype(auto) lua_option_file = GetLuaOptionFile();
decltype(auto) entry_key_list = lua_option_file.GetEntryKeyList(); decltype(auto) entry_key_list = lua_option_file.GetEntryKeyList();
for (decltype(auto) entry_key : entry_key_list) for (decltype(auto) entry_key : entry_key_list)
...@@ -332,14 +329,6 @@ namespace MoReFEM ...@@ -332,14 +329,6 @@ namespace MoReFEM
} }
template<class DerivedT, class TupleT>
const LuaOptionFile& Base<DerivedT, TupleT>::GetLuaOptionFile() const noexcept
{
assert(!(!lua_option_file_));
return *lua_option_file_;
}
} // namespace InputDataNS } // namespace InputDataNS
......
...@@ -77,7 +77,7 @@ namespace MoReFEM ...@@ -77,7 +77,7 @@ namespace MoReFEM
static void Set(TupleEltTypeT& element, static void Set(TupleEltTypeT& element,
const InputDataT* input_data, const InputDataT* input_data,
const std::string& fullname, const std::string& fullname,
LuaOptionFile* lua_option_file); LuaOptionFile& lua_option_file);
}; };
......
...@@ -38,9 +38,8 @@ namespace MoReFEM ...@@ -38,9 +38,8 @@ namespace MoReFEM
void ElementType<TupleEltTypeT>::Set(TupleEltTypeT& element, void ElementType<TupleEltTypeT>::Set(TupleEltTypeT& element,
const InputDataT* input_data, const InputDataT* input_data,
const std::string& full_name, const std::string& full_name,
LuaOptionFile* lua_option_file) LuaOptionFile& lua_option_file)
{ {
assert(lua_option_file != nullptr);
static_cast<void>(input_data); // as it might ot be used in one of the static if/else case below. static_cast<void>(input_data); // as it might ot be used in one of the static if/else case below.
using return_type = typename TupleEltTypeT::return_type; using return_type = typename TupleEltTypeT::return_type;
...@@ -50,7 +49,7 @@ namespace MoReFEM ...@@ -50,7 +49,7 @@ namespace MoReFEM
if constexpr(HAS_MEMBER_Selector<TupleEltTypeT>::value) if constexpr(HAS_MEMBER_Selector<TupleEltTypeT>::value)
{ {
lua_option_file->Read(full_name, lua_option_file.Read(full_name,
TupleEltTypeT::Constraint(), TupleEltTypeT::Constraint(),
ret, ret,
__FILE__, __LINE__, __FILE__, __LINE__,
...@@ -58,7 +57,7 @@ namespace MoReFEM ...@@ -58,7 +57,7 @@ namespace MoReFEM
} }
else else
{ {
lua_option_file->Read(full_name, lua_option_file.Read(full_name,
TupleEltTypeT::Constraint(), TupleEltTypeT::Constraint(),
ret, ret,
__FILE__, __LINE__, __FILE__, __LINE__,
......
...@@ -123,7 +123,7 @@ namespace MoReFEM ...@@ -123,7 +123,7 @@ namespace MoReFEM
*/ */
template<class InputDataT> template<class InputDataT>
static void Fill(const InputDataT* input_data, static void Fill(const InputDataT* input_data,
LuaOptionFile* lua_option_file, LuaOptionFile& lua_option_file,
TupleT& tuple); TupleT& tuple);
...@@ -227,7 +227,7 @@ namespace MoReFEM ...@@ -227,7 +227,7 @@ namespace MoReFEM
template<class InputDataT> template<class InputDataT>
static void Fill(const InputDataT* input_data, LuaOptionFile* , TupleT& ); static void Fill(const InputDataT* input_data, LuaOptionFile& , TupleT& );
static void PrepareDefaultEntries(std::vector<std::pair<std::string, std::string>>& static void PrepareDefaultEntries(std::vector<std::pair<std::string, std::string>>&
...@@ -314,7 +314,7 @@ namespace MoReFEM ...@@ -314,7 +314,7 @@ namespace MoReFEM
template<class InputDataT> template<class InputDataT>
static void Fill(const InputDataT* input_data, LuaOptionFile* lua_option_file, TupleEltTypeT& item); static void Fill(const InputDataT* input_data, LuaOptionFile& lua_option_file, TupleEltTypeT& item);
static void PrintKeys(std::ostream& stream); static void PrintKeys(std::ostream& stream);
...@@ -364,7 +364,7 @@ namespace MoReFEM ...@@ -364,7 +364,7 @@ namespace MoReFEM
const TupleEltTypeT*& parameter_if_found); const TupleEltTypeT*& parameter_if_found);
template<class InputDataT> template<class InputDataT>
static void Fill(const InputDataT* input_data, LuaOptionFile* lua_option_file, TupleEltTypeT& item); static void Fill(const InputDataT* input_data, LuaOptionFile& lua_option_file, TupleEltTypeT& item);
static void PrintKeys(std::ostream& stream); static void PrintKeys(std::ostream& stream);
...@@ -415,7 +415,7 @@ namespace MoReFEM ...@@ -415,7 +415,7 @@ namespace MoReFEM
* \param[in,out] tuple Should be the data attribute tuple_ nested in Base class. * \param[in,out] tuple Should be the data attribute tuple_ nested in Base class.
*/ */
template<class TupleT, class InputDataT> template<class TupleT, class InputDataT>
void FillTuple(const InputDataT* input_data, LuaOptionFile* lua_option_file, TupleT& tuple); void FillTuple(const InputDataT* input_data, LuaOptionFile& lua_option_file, TupleT& tuple);
/*! /*!
......
...@@ -199,7 +199,7 @@ namespace MoReFEM ...@@ -199,7 +199,7 @@ namespace MoReFEM
template<class TupleT, class InputDataT> template<class TupleT, class InputDataT>
void FillTuple(const InputDataT* input_data, LuaOptionFile* lua_option_file, TupleT& tuple) void FillTuple(const InputDataT* input_data,LuaOptionFile& lua_option_file, TupleT& tuple)
{ {
enum { size = std::tuple_size<TupleT>::value }; enum { size = std::tuple_size<TupleT>::value };
TupleIteration<TupleT, 0, size>::Fill(input_data, lua_option_file, tuple); TupleIteration<TupleT, 0, size>::Fill(input_data, lua_option_file, tuple);
...@@ -209,7 +209,7 @@ namespace MoReFEM ...@@ -209,7 +209,7 @@ namespace MoReFEM
template<class TupleEltTypeT> template<class TupleEltTypeT>
template<class InputDataT> template<class InputDataT>
void SectionOrParameter<TupleEltTypeT, Nature::parameter> void SectionOrParameter<TupleEltTypeT, Nature::parameter>
::Fill(const InputDataT* input_data, LuaOptionFile* lua_option_file, TupleEltTypeT& item) ::Fill(const InputDataT* input_data, LuaOptionFile& lua_option_file, TupleEltTypeT& item)
{ {
// Read in the input data file the whole identifier, which is 'section.name' or 'name' // Read in the input data file the whole identifier, which is 'section.name' or 'name'
// if no section is provided. // if no section is provided.
...@@ -224,7 +224,7 @@ namespace MoReFEM ...@@ -224,7 +224,7 @@ namespace MoReFEM
template<class TupleEltTypeT> template<class TupleEltTypeT>
template<class InputDataT> template<class InputDataT>
void SectionOrParameter<TupleEltTypeT, Nature::section> void SectionOrParameter<TupleEltTypeT, Nature::section>
::Fill(const InputDataT* input_data, LuaOptionFile* lua_option_file, TupleEltTypeT& item) ::Fill(const InputDataT* input_data, LuaOptionFile& lua_option_file, TupleEltTypeT& item)
{ {
tuple_iteration::Fill(input_data, lua_option_file, item.GetNonCstSectionContent()); tuple_iteration::Fill(input_data, lua_option_file, item.GetNonCstSectionContent());
} }
...@@ -238,7 +238,7 @@ namespace MoReFEM ...@@ -238,7 +238,7 @@ namespace MoReFEM
> >
template<class InputDataT> template<class InputDataT>
void TupleIteration<TupleT, Index, Length> void TupleIteration<TupleT, Index, Length>
::Fill(const InputDataT* input_data, LuaOptionFile* lua_option_file, TupleT& tuple) ::Fill(const InputDataT* input_data, LuaOptionFile& lua_option_file, TupleT& tuple)
{ {
static_assert(Utilities::IsSpecializationOf<std::tuple, TupleT>::value, static_assert(Utilities::IsSpecializationOf<std::tuple, TupleT>::value,
"TupleT should be a std::tuple."); "TupleT should be a std::tuple.");
...@@ -256,7 +256,7 @@ namespace MoReFEM ...@@ -256,7 +256,7 @@ namespace MoReFEM
template<class TupleT, unsigned int Length> template<class TupleT, unsigned int Length>
template<class InputDataT> template<class InputDataT>
void TupleIteration<TupleT, Length, Length> void TupleIteration<TupleT, Length, Length>
::Fill(const InputDataT* , LuaOptionFile*, TupleT&) ::Fill(const InputDataT* , LuaOptionFile&, TupleT&)
{ {
// Do nothing. // Do nothing.
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment