Commit a817ead4 authored by GILLES Sebastien's avatar GILLES Sebastien

#1465 The mechanism to write the input data is now in place. I now must adjust...

#1465 The mechanism to write the input data is now in place. I now must adjust the outputs (add the quots for strings for instance...) and deal with the more complicated cases I have left behind at the moment (containers and variants - especially containers with variants inside...).
parent f1ab5f2a
......@@ -529,6 +529,9 @@
BE353B9B22E7527100A06A8F /* Extract.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BE353B9822E7527100A06A8F /* Extract.hpp */; };
BE353B9F22E7539E00A06A8F /* Enum.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE353B9C22E7539E00A06A8F /* Enum.cpp */; };
BE353BA122E7539E00A06A8F /* Enum.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BE353B9E22E7539E00A06A8F /* Enum.hpp */; };
BE353BA622E76CF500A06A8F /* ConvertEntryToString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE353BA322E76CF500A06A8F /* ConvertEntryToString.cpp */; };
BE353BA722E76CF500A06A8F /* ConvertEntryToString.hxx in Headers */ = {isa = PBXBuildFile; fileRef = BE353BA422E76CF500A06A8F /* ConvertEntryToString.hxx */; };
BE353BA822E76CF500A06A8F /* ConvertEntryToString.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BE353BA522E76CF500A06A8F /* ConvertEntryToString.hpp */; };
BE3AB281183503C7009E1B76 /* libCore.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BE05B52916D238FE000E248D /* libCore.a */; };
BE3AB283183503C7009E1B76 /* libFiniteElement.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BE9C4D121807F5DC005B94BC /* libFiniteElement.a */; };
BE3AB284183503C7009E1B76 /* libGeometry.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BE05B4DD16D23573000E248D /* libGeometry.a */; };
......@@ -3418,6 +3421,9 @@
BE353B9822E7527100A06A8F /* Extract.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Extract.hpp; sourceTree = "<group>"; };
BE353B9C22E7539E00A06A8F /* Enum.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Enum.cpp; sourceTree = "<group>"; };
BE353B9E22E7539E00A06A8F /* Enum.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Enum.hpp; sourceTree = "<group>"; };
BE353BA322E76CF500A06A8F /* ConvertEntryToString.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ConvertEntryToString.cpp; sourceTree = "<group>"; };
BE353BA422E76CF500A06A8F /* ConvertEntryToString.hxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ConvertEntryToString.hxx; sourceTree = "<group>"; };
BE353BA522E76CF500A06A8F /* ConvertEntryToString.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ConvertEntryToString.hpp; sourceTree = "<group>"; };
BE372DDB18C4802900127212 /* main_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main_test.cpp; sourceTree = "<group>"; };
BE37EFEB1CB308340006C0AD /* FiniteElement.doxygen */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = FiniteElement.doxygen; sourceTree = "<group>"; };
BE390F142108C9BD0049CD3B /* test_input_data.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = test_input_data.cpp; sourceTree = "<group>"; };
......@@ -6783,6 +6789,16 @@
name = "Recovered References";
sourceTree = "<group>";
};
BE353BA222E76C9900A06A8F /* ConvertEntryToString */ = {
isa = PBXGroup;
children = (
BE353BA322E76CF500A06A8F /* ConvertEntryToString.cpp */,
BE353BA522E76CF500A06A8F /* ConvertEntryToString.hpp */,
BE353BA422E76CF500A06A8F /* ConvertEntryToString.hxx */,
);
path = ConvertEntryToString;
sourceTree = "<group>";
};
BE372DCD18C47F0500127212 /* Test */ = {
isa = PBXGroup;
children = (
......@@ -7787,6 +7803,7 @@
children = (
BEACCCBB1E127D1900CBA4F2 /* ExtractParameter */,
BE53FC2F1E0D86B900C5D6F5 /* Subtuple */,
BE353BA222E76C9900A06A8F /* ConvertEntryToString */,
BE53FC0D1E0D7C6800C5D6F5 /* TupleIteration */,
);
path = Internal;
......@@ -11332,6 +11349,7 @@
BE90E1C21A2492AA00CCAFDE /* SeldonFunctions.hxx in Headers */,
BE90E1A81A24929A00CCAFDE /* Parmetis.hpp in Headers */,
BEDE16BA204FFD7900DEFE08 /* Lua.hpp in Headers */,
BE353BA722E76CF500A06A8F /* ConvertEntryToString.hxx in Headers */,
BE90E1681A24926E00CCAFDE /* PointerComparison.hpp in Headers */,
BE90E1841A24929A00CCAFDE /* InputData.hxx in Headers */,
BE90E1C11A2492AA00CCAFDE /* SeldonFunctions.hpp in Headers */,
......@@ -11436,6 +11454,7 @@
BE3FE9D522C500740093E95A /* HasMember.hpp in Headers */,
BE76F2691D7D609E0061B50E /* GlobalVectorTemporary.hpp in Headers */,
BE76F2561D7D5DE90061B50E /* CSRPattern.hxx in Headers */,
BE353BA822E76CF500A06A8F /* ConvertEntryToString.hpp in Headers */,
BECB2E0D213FFBAC0093CB05 /* SnesMacro.hpp in Headers */,
BE3D12C01D9B1FFB00F900F5 /* KspConvergenceReason.hpp in Headers */,
BE8B5F8120778D1A00DC005E /* StringPair.hxx in Headers */,
......@@ -12779,6 +12798,7 @@
BE6E4EE11B2ABE8B0049BB2D /* AccessGhostContent.cpp in Sources */,
BEDEB9251C3C073100B1C71B /* Mumps.cpp in Sources */,
BE90E1B21A24929A00CCAFDE /* AccessVectorContent.cpp in Sources */,
BE353BA622E76CF500A06A8F /* ConvertEntryToString.cpp in Sources */,
BE41A8D11A24AA7F004E4312 /* Petsc.cpp in Sources */,
BECEF91F22DF2A0800D0DDE7 /* VectorInitMethods.cpp in Sources */,
BE90E1AF1A24929A00CCAFDE /* Vector.cpp in Sources */,
......@@ -25,7 +25,6 @@ namespace MoReFEM
{
//! \copydoc doxygen_hide_input_data_tuple
using InputDataTuple = std::tuple
<
......
......@@ -33,7 +33,7 @@ Result = {
-- YYYY_MM_DD_HH_MM_SS.Please do not read the value directly from this Lua file: whenever you need the path
-- to the result directory, use instead MoReFEMData::GetResultDirectory().
-- Expected format: "VALUE"
output_directory = "${MOREFEM_TEST_OUTPUT_DIR}/WriteLuaFile",
output_directory = "${MOREFEM_TEST_OUTPUT_DIR}/TestWriteLuaFile",
-- Enables to skip some printing in the console. Can be used to WriteSolution every n time.
......
......@@ -75,7 +75,60 @@ BOOST_FIXTURE_TEST_CASE(check_value, TestNS::FixtureNS::Environment)
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);
Utilities::InputDataNS::Write(morefem_data.GetInputData(), lua_file_with_content);
const InputDataNS::Result::OutputDirectory* result;
using tuple = TestNS::WriteLuaFileNS::InputDataTuple;
enum { tuple_size = std::tuple_size<tuple>::value };
using tuple_iteration = MoReFEM::Internal::InputDataNS::TupleIteration<tuple, 0, tuple_size>;
tuple_iteration::template ExtractValue<InputDataNS::Result::OutputDirectory>(morefem_data.GetInputData().GetTuple(),
result);
std::cout << "VALUE READ = " << result->GetTheValue() << std::endl;
{
using type = InputDataNS::VectorialTransientSource<4>::Nature;
const type* value;
tuple_iteration::template ExtractValue<type>(morefem_data.GetInputData().GetTuple(),
value);
//std::cout << "VALUE READ = " << value->GetTheValue() << std::endl;
Utilities::PrintContainer(value->GetTheValue(), std::cout);
}
{
using type = InputDataNS::VectorialTransientSource<4>::Value;
const type* value;
tuple_iteration::template ExtractValue<type>(morefem_data.GetInputData().GetTuple(),
value);
//std::cout << "VALUE READ = " << value->GetTheValue() << std::endl;
}
/*
tuple_iteration::template ExtractValue<InputDataNS::VectorialTransientSource<4>>(morefem_data.GetInputData().GetTuple(),
&value);
std::cout << "VALUE READ = " << value << std::endl;
*/
}
PRAGMA_DIAGNOSTIC(pop)
......
//! \file
//
//
// ConvertEntryToString.cpp
// MoReFEM
//
// Created by sebastien on 23/07/2019.
//Copyright © 2019 Inria. All rights reserved.
//
#include "Utilities/InputData/Internal/ConvertEntryToString/ConvertEntryToString.hpp"
namespace MoReFEM::Internal::InputDataNS
{
} // namespace MoReFEM::Internal::InputDataNS
//! \file
//
//
// ConvertEntryToString.hpp
// MoReFEM
//
// Created by sebastien on 23/07/2019.
//Copyright © 2019 Inria. All rights reserved.
//
#ifndef MOREFEM_x_UTILITIES_x_INPUT_DATA_x_INTERNAL_x_CONVERT_ENTRY_TO_STRING_x_CONVERT_ENTRY_TO_STRING_HPP_
# define MOREFEM_x_UTILITIES_x_INPUT_DATA_x_INTERNAL_x_CONVERT_ENTRY_TO_STRING_x_CONVERT_ENTRY_TO_STRING_HPP_
# include <string>
# include <variant>
# include <vector>
# include <map>
# include "Utilities/InputData/LuaFunction.hpp"
# include "Utilities/Miscellaneous.hpp"
namespace MoReFEM::Internal::InputDataNS
{
template<class T>
std::string ConvertEntryToString(T entry);
} // namespace MoReFEM::Internal::InputDataNS
# include "Utilities/InputData/Internal/ConvertEntryToString/ConvertEntryToString.hxx"
#endif // MOREFEM_x_UTILITIES_x_INPUT_DATA_x_INTERNAL_x_CONVERT_ENTRY_TO_STRING_x_CONVERT_ENTRY_TO_STRING_HPP_
//! \file
//
//
// ConvertEntryToString.hxx
// MoReFEM
//
// Created by sebastien on 23/07/2019.
//Copyright © 2019 Inria. All rights reserved.
//
#ifndef MOREFEM_x_UTILITIES_x_INPUT_DATA_x_INTERNAL_x_CONVERT_ENTRY_TO_STRING_x_CONVERT_ENTRY_TO_STRING_HXX_
# define MOREFEM_x_UTILITIES_x_INPUT_DATA_x_INTERNAL_x_CONVERT_ENTRY_TO_STRING_x_CONVERT_ENTRY_TO_STRING_HXX_
namespace MoReFEM::Internal::InputDataNS
{
template<class T>
std::string ConvertEntryToString(T entry)
{
if constexpr(Utilities::IsSpecializationOf
<
std::variant,
T
>())
{
return "Variant case!";
}
else if constexpr (std::is_same<T, bool>())
{
return std::to_string(entry);
}
else if constexpr (std::is_same<T, std::string>())
{
return entry;
}
else if constexpr (std::is_integral<T>())
{
return std::to_string(entry);
}
else if constexpr (std::is_floating_point<T>())
{
return std::to_string(entry);
}
else if constexpr(Utilities::IsSpecializationOf<Utilities::InputDataNS::LuaFunction, T>())
{
return entry.GetString();
}
else if constexpr (Utilities::IsSpecializationOf<std::map, T>())
{
return "Map!";
}
else if constexpr (Utilities::IsSpecializationOf<std::vector, T>())
{
return "Vector!";
}
else
{
assert(false && "Case not foreseen...");
exit(EXIT_FAILURE);
}
}
} // namespace MoReFEM::Internal::InputDataNS
#endif // MOREFEM_x_UTILITIES_x_INPUT_DATA_x_INTERNAL_x_CONVERT_ENTRY_TO_STRING_x_CONVERT_ENTRY_TO_STRING_HXX_
### ===================================================================================
### This file is generated automatically by Scripts/generate_cmake_source_list.py.
### Do not edit it manually!
### Convention is that:
### - When a CMake file is manually managed, it is named canonically CMakeLists.txt.
###. - When it is generated automatically, it is named SourceList.cmake.
### ===================================================================================
target_sources(${MOREFEM_UTILITIES}
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/ConvertEntryToString.cpp"
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/ConvertEntryToString.hpp"
"${CMAKE_CURRENT_LIST_DIR}/ConvertEntryToString.hxx"
)
......@@ -14,5 +14,6 @@ target_sources(${MOREFEM_UTILITIES}
include(${CMAKE_CURRENT_LIST_DIR}/ExtractParameter/SourceList.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/TupleIteration/SourceList.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/ConvertEntryToString/SourceList.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/Subtuple/SourceList.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/ManualParsing/SourceList.cmake)
......@@ -79,7 +79,6 @@ namespace MoReFEM
const std::string& fullname,
LuaOptionFile& lua_option_file);
};
......
......@@ -27,6 +27,7 @@
# include "Utilities/String/String.hpp"
# include "Utilities/InputData/Exceptions/InputData.hpp"
# include "Utilities/InputData/Internal/TupleIteration/Impl/Print.hpp"
# include "Utilities/InputData/Internal/ConvertEntryToString/ConvertEntryToString.hpp"
# include "Core/InputData/Instances/Crtp/Section.hpp"
......
......@@ -349,7 +349,17 @@ namespace MoReFEM
else
{
assert(input_data != nullptr);
oconv << "TMP BLAH BLAH BLAH";
const TupleEltTypeT* value = nullptr;
using tuple = typename InputDataT::Tuple;
enum { tuple_size = std::tuple_size<tuple>::value };
using tuple_iteration = MoReFEM::Internal::InputDataNS::TupleIteration<tuple, 0, tuple_size>;
tuple_iteration::template ExtractValue<TupleEltTypeT>(input_data->GetTuple(),
value);
assert(!(!value));
oconv << ConvertEntryToString(value->GetTheValue());
}
parameter_block_per_identifier.emplace_back(std::make_pair(TupleEltTypeT::GetIdentifier(), oconv.str()));
......
......@@ -114,12 +114,18 @@ namespace MoReFEM
*/
ReturnTypeT operator()(Args... args) const;
//! Returns the string that defined the Lua function in the first place.
const std::string& GetString() const noexcept;
private:
//! Lua stack that will be used for function computations.
lua_State* state_ = nullptr;
//! String content read in the input data file.
std::string content_;
};
......
......@@ -36,7 +36,8 @@ namespace MoReFEM
template<typename ReturnTypeT, typename ...Args>
LuaFunction<ReturnTypeT(Args...)>::LuaFunction(const std::string& content)
: state_(luaL_newstate())
: state_(luaL_newstate()),
content_(content)
{
luaL_openlibs(state_);
......@@ -91,6 +92,13 @@ namespace MoReFEM
return ret;
}
template<typename ReturnTypeT, typename ...Args>
inline const std::string& LuaFunction<ReturnTypeT(Args...)>::GetString() const noexcept
{
return content_;
}
} // namespace InputDataNS
......
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