Skip to content

Commit

Permalink
improving serialization, workign now
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroCornejo committed Aug 3, 2023
1 parent c648610 commit b605df5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
11 changes: 8 additions & 3 deletions kratos/sources/table_accessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,20 @@ double TableAccessor::GetValueFromTable(

void TableAccessor::save(Serializer& rSerializer) const
{
rSerializer.save("InputVariable", mpInputVariable->Key());
rSerializer.save("InputVariable", mpInputVariable->Name());
// // we must do the int cast to be able to compile
rSerializer.save("InputVariableType", static_cast<int>(mInputVariableType));
}
void TableAccessor::load(Serializer& rSerializer)
{
rSerializer.load("InputVariable", mpInputVariable->Key());
std::string variable_name;
rSerializer.load("InputVariable", variable_name);
mpInputVariable = static_cast<Variable<double> *>(KratosComponents<VariableData>::pGet(variable_name));

// // we must do the int cast to be able to compile
rSerializer.load("InputVariableType", static_cast<int>(mInputVariableType));
int enum_value;
rSerializer.load("InputVariableType", enum_value);
mInputVariableType = static_cast<Globals::DataLocation>(enum_value);
}

/***********************************************************************************/
Expand Down
5 changes: 1 addition & 4 deletions kratos/tests/cpp_tests/includes/test_property_accessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,7 @@ KRATOS_TEST_CASE_IN_SUITE(TableTableAccessorSerialization, KratosCoreFastSuite)

auto& d = table_accessor_loaded.GetInputVariable();

KRATOS_WATCH(d.Key())
KRATOS_WATCH(TEMPERATURE.Key())

// KRATOS_CHECK_EQUAL(TEMPERATURE.Key(), table_accessor_loaded.GetInputVariable().Key());
KRATOS_CHECK_EQUAL(TEMPERATURE.Key(), table_accessor_loaded.GetInputVariable().Key());
}

} // namespace Kratos::Testing.

0 comments on commit b605df5

Please sign in to comment.