Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
DIAZ Jerome
MoReFEM
Commits
7bc0ddd6
Commit
7bc0ddd6
authored
Jul 24, 2019
by
GILLES Sebastien
Browse files
#1465 Rewriting of a Lua files seems to work (with the caveat of bug #1468).
parent
390fab55
Changes
2
Hide whitespace changes
Inline
Side-by-side
Sources/Test/Core/MoReFEMData/WriteLuaFile/test.cpp
View file @
7bc0ddd6
...
...
@@ -76,59 +76,24 @@ BOOST_FIXTURE_TEST_CASE(check_value, TestNS::FixtureNS::Environment)
auto
lua_file_with_content
=
output_directory
+
"/generated_with_content.lua"
;
Utilities
::
InputDataNS
::
Write
(
morefem_data
.
GetInputData
(),
lua_file_with_content
);
}
BOOST_FIXTURE_TEST_CASE
(
reload_and_rewrite
,
TestNS
::
FixtureNS
::
Environment
)
{
decltype
(
auto
)
environment
=
Utilities
::
Environment
::
CreateOrGetInstance
(
__FILE__
,
__LINE__
);
const
std
::
string
output_directory
=
environment
.
SubstituteValues
(
"${MOREFEM_TEST_OUTPUT_DIR}/TestWriteLuaFile/"
);
auto
lua_file_with_content
=
output_directory
+
"/generated_with_content.lua"
;
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
<>::
Do
(
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;
using
input_data_type
=
TestNS
::
WriteLuaFileNS
::
InputData
;
TestNS
::
InitializeTestMoReFEMData
<
input_data_type
>
init
(
std
::
move
(
lua_file_with_content
));
*/
decltype
(
auto
)
morefem_data
=
init
.
GetMoReFEMData
();
auto
regenerated_file
=
output_directory
+
"/regenerated_with_content.lua"
;
Utilities
::
InputDataNS
::
Write
(
morefem_data
.
GetInputData
(),
regenerated_file
);
BOOST_CHECK
(
FilesystemNS
::
File
::
AreEquals
(
lua_file_with_content
,
regenerated_file
,
__FILE__
,
__LINE__
));
}
...
...
Sources/Utilities/InputData/Internal/PrintPolicy/LuaFormat.hxx
View file @
7bc0ddd6
...
...
@@ -37,7 +37,7 @@ namespace MoReFEM::Internal::PrintPolicyNS
{
stream
<<
"
\n
[[
\n
"
;
stream
<<
entry
.
GetString
();
stream
<<
"
\n
]]"
;
stream
<<
"]]"
;
}
else
if
constexpr
(
std
::
is_same
<
type
,
std
::
string
>
())
{
...
...
@@ -45,7 +45,16 @@ namespace MoReFEM::Internal::PrintPolicyNS
}
else
if
constexpr
(
std
::
is_arithmetic
<
type
>
())
{
stream
<<
entry
;
if
constexpr
(
std
::
is_same
<
type
,
bool
>
())
stream
<<
std
::
boolalpha
<<
entry
;
else
stream
<<
entry
;
}
else
if
constexpr
(
Utilities
::
IsSpecializationOf
<
std
::
vector
,
type
>
())
{
// Trick here: current class is used as policy to that the choices here will be applied as well on
// each element of the vector.
Utilities
::
PrintContainer
<
LuaFormat
>::
Do
(
entry
,
stream
,
", "
,
'{'
,
'}'
);
}
else
if
constexpr
(
Utilities
::
IsSpecializationOf
<
std
::
map
,
type
>
())
{
...
...
@@ -54,10 +63,6 @@ namespace MoReFEM::Internal::PrintPolicyNS
::
MoReFEM
::
Utilities
::
PrintPolicyNS
::
Associative
<
Utilities
::
PrintPolicyNS
::
associative_format
::
Lua
>
;
Utilities
::
PrintContainer
<
policy
>::
Do
(
entry
,
stream
,
", "
,
'{'
,
'}'
);
}
else
if
constexpr
(
Utilities
::
IsSpecializationOf
<
std
::
vector
,
type
>
())
{
Utilities
::
PrintContainer
<
LuaFormat
>::
Do
(
entry
,
stream
);
}
else
{
assert
(
false
&&
"Case not foreseen..."
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment