Skip to content
Snippets Groups Projects
Commit 827511cd authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add checkpoint/resume of IInterfaceDescriptor and IZoneDescriptor

parent c28bce2b
No related branches found
No related tags found
1 merge request!199Integrate checkpointing
...@@ -329,4 +329,30 @@ MeshModule::registerCheckpointResume() const ...@@ -329,4 +329,30 @@ MeshModule::registerCheckpointResume() const
const HighFive::Group& symbol_table_group) -> EmbeddedData { const HighFive::Group& symbol_table_group) -> EmbeddedData {
return readIBoundaryDescriptor(symbol_name, symbol_table_group); return readIBoundaryDescriptor(symbol_name, symbol_table_group);
})); }));
CheckpointResumeRepository::instance()
.addCheckpointResume(ast_node_data_type_from<std::shared_ptr<const IInterfaceDescriptor>>,
std::function([](const std::string& symbol_name, const EmbeddedData& embedded_data,
HighFive::File& file, HighFive::Group& checkpoint_group,
HighFive::Group& symbol_table_group) {
writeIInterfaceDescriptor(symbol_name, embedded_data, file, checkpoint_group,
symbol_table_group);
}),
std::function([](const std::string& symbol_name,
const HighFive::Group& symbol_table_group) -> EmbeddedData {
return readIInterfaceDescriptor(symbol_name, symbol_table_group);
}));
CheckpointResumeRepository::instance()
.addCheckpointResume(ast_node_data_type_from<std::shared_ptr<const IZoneDescriptor>>,
std::function([](const std::string& symbol_name, const EmbeddedData& embedded_data,
HighFive::File& file, HighFive::Group& checkpoint_group,
HighFive::Group& symbol_table_group) {
writeIZoneDescriptor(symbol_name, embedded_data, file, checkpoint_group, symbol_table_group);
}),
std::function([](const std::string& symbol_name,
const HighFive::Group& symbol_table_group) -> EmbeddedData {
return readIZoneDescriptor(symbol_name, symbol_table_group);
}));
} }
...@@ -25,6 +25,12 @@ class NamedInterfaceDescriptor final : public IInterfaceDescriptor ...@@ -25,6 +25,12 @@ class NamedInterfaceDescriptor final : public IInterfaceDescriptor
return m_name == ref_id.tagName(); return m_name == ref_id.tagName();
} }
[[nodiscard]] const std::string&
name() const
{
return m_name;
}
[[nodiscard]] Type [[nodiscard]] Type
type() const final type() const final
{ {
......
...@@ -25,7 +25,13 @@ class NamedZoneDescriptor final : public IZoneDescriptor ...@@ -25,7 +25,13 @@ class NamedZoneDescriptor final : public IZoneDescriptor
return m_name == ref_id.tagName(); return m_name == ref_id.tagName();
} }
Type [[nodiscard]] const std::string&
name() const
{
return m_name;
}
[[nodiscard]] Type
type() const final type() const final
{ {
return Type::named; return Type::named;
......
...@@ -24,6 +24,12 @@ class NumberedInterfaceDescriptor final : public IInterfaceDescriptor ...@@ -24,6 +24,12 @@ class NumberedInterfaceDescriptor final : public IInterfaceDescriptor
} }
public: public:
[[nodiscard]] unsigned int
number() const
{
return m_number;
}
[[nodiscard]] Type [[nodiscard]] Type
type() const final type() const final
{ {
......
...@@ -24,7 +24,13 @@ class NumberedZoneDescriptor final : public IZoneDescriptor ...@@ -24,7 +24,13 @@ class NumberedZoneDescriptor final : public IZoneDescriptor
} }
public: public:
Type [[nodiscard]] unsigned int
number() const
{
return m_number;
}
[[nodiscard]] Type
type() const final type() const final
{ {
return Type::numbered; return Type::numbered;
......
...@@ -5,12 +5,17 @@ ...@@ -5,12 +5,17 @@
#include <language/utils/DataHandler.hpp> #include <language/utils/DataHandler.hpp>
#include <mesh/MeshVariant.hpp> #include <mesh/MeshVariant.hpp>
#include <utils/checkpointing/IBoundaryDescriptorHFType.hpp> #include <utils/checkpointing/IBoundaryDescriptorHFType.hpp>
#include <utils/checkpointing/IInterfaceDescriptorHFType.hpp>
#include <utils/checkpointing/IZoneDescriptorHFType.hpp>
#include <utils/checkpointing/RefItemListHFType.hpp> #include <utils/checkpointing/RefItemListHFType.hpp>
#include <mesh/IBoundaryDescriptor.hpp>
#include <mesh/Mesh.hpp> #include <mesh/Mesh.hpp>
#include <mesh/NamedBoundaryDescriptor.hpp> #include <mesh/NamedBoundaryDescriptor.hpp>
#include <mesh/NamedInterfaceDescriptor.hpp>
#include <mesh/NamedZoneDescriptor.hpp>
#include <mesh/NumberedBoundaryDescriptor.hpp> #include <mesh/NumberedBoundaryDescriptor.hpp>
#include <mesh/NumberedInterfaceDescriptor.hpp>
#include <mesh/NumberedZoneDescriptor.hpp>
template <ItemType item_type, size_t Dimension> template <ItemType item_type, size_t Dimension>
void void
...@@ -215,3 +220,68 @@ writeIBoundaryDescriptor(const std::string& symbol_name, ...@@ -215,3 +220,68 @@ writeIBoundaryDescriptor(const std::string& symbol_name,
} }
} }
} }
void
writeIInterfaceDescriptor(const std::string& symbol_name,
const EmbeddedData& embedded_data,
HighFive::File&,
HighFive::Group&,
HighFive::Group& symbol_table_group)
{
HighFive::Group variable_group = symbol_table_group.createGroup("embedded/" + symbol_name);
std::shared_ptr<const IInterfaceDescriptor> iinterface_descriptor_p =
dynamic_cast<const DataHandler<const IInterfaceDescriptor>&>(embedded_data.get()).data_ptr();
const IInterfaceDescriptor& iinterface_descriptor = *iinterface_descriptor_p;
variable_group.createAttribute("type", dataTypeName(ast_node_data_type_from<decltype(iinterface_descriptor_p)>));
variable_group.createAttribute("iinterface_descriptor_type", iinterface_descriptor.type());
switch (iinterface_descriptor.type()) {
case IInterfaceDescriptor::Type::named: {
const NamedInterfaceDescriptor& named_interface_descriptor =
dynamic_cast<const NamedInterfaceDescriptor&>(iinterface_descriptor);
variable_group.createAttribute("name", named_interface_descriptor.name());
break;
}
case IInterfaceDescriptor::Type::numbered: {
const NumberedInterfaceDescriptor& numbered_boundary_descriptor =
dynamic_cast<const NumberedInterfaceDescriptor&>(iinterface_descriptor);
variable_group.createAttribute("number", numbered_boundary_descriptor.number());
break;
}
}
}
void
writeIZoneDescriptor(const std::string& symbol_name,
const EmbeddedData& embedded_data,
HighFive::File&,
HighFive::Group&,
HighFive::Group& symbol_table_group)
{
HighFive::Group variable_group = symbol_table_group.createGroup("embedded/" + symbol_name);
std::shared_ptr<const IZoneDescriptor> izone_descriptor_p =
dynamic_cast<const DataHandler<const IZoneDescriptor>&>(embedded_data.get()).data_ptr();
const IZoneDescriptor& izone_descriptor = *izone_descriptor_p;
variable_group.createAttribute("type", dataTypeName(ast_node_data_type_from<decltype(izone_descriptor_p)>));
variable_group.createAttribute("izone_descriptor_type", izone_descriptor.type());
switch (izone_descriptor.type()) {
case IZoneDescriptor::Type::named: {
const NamedZoneDescriptor& named_zone_descriptor = dynamic_cast<const NamedZoneDescriptor&>(izone_descriptor);
variable_group.createAttribute("name", named_zone_descriptor.name());
break;
}
case IZoneDescriptor::Type::numbered: {
const NumberedZoneDescriptor& numbered_boundary_descriptor =
dynamic_cast<const NumberedZoneDescriptor&>(izone_descriptor);
variable_group.createAttribute("number", numbered_boundary_descriptor.number());
break;
}
}
}
...@@ -54,4 +54,16 @@ void writeIBoundaryDescriptor(const std::string& symbol_name, ...@@ -54,4 +54,16 @@ void writeIBoundaryDescriptor(const std::string& symbol_name,
HighFive::Group& checkpoint_group, HighFive::Group& checkpoint_group,
HighFive::Group& symbol_table_group); HighFive::Group& symbol_table_group);
void writeIInterfaceDescriptor(const std::string& symbol_name,
const EmbeddedData& embedded_data,
HighFive::File& file,
HighFive::Group& checkpoint_group,
HighFive::Group& symbol_table_group);
void writeIZoneDescriptor(const std::string& symbol_name,
const EmbeddedData& embedded_data,
HighFive::File& file,
HighFive::Group& checkpoint_group,
HighFive::Group& symbol_table_group);
#endif // CHECKPOINT_UTILS_HPP #endif // CHECKPOINT_UTILS_HPP
#ifndef I_INTERFACE_DESCRIPTOR_HF_TYPE_HPP
#define I_INTERFACE_DESCRIPTOR_HF_TYPE_HPP
#include <mesh/IInterfaceDescriptor.hpp>
#include <utils/checkpointing/CheckpointUtils.hpp>
HighFive::EnumType<IInterfaceDescriptor::Type> PUGS_INLINE
create_enum_i_interface_descriptor_type()
{
return {{"named", IInterfaceDescriptor::Type::named}, {"numbered", IInterfaceDescriptor::Type::numbered}};
}
HIGHFIVE_REGISTER_TYPE(IInterfaceDescriptor::Type, create_enum_i_interface_descriptor_type);
#endif // I_INTERFACE_DESCRIPTOR_HF_TYPE_HPP
#ifndef I_ZONE_DESCRIPTOR_HF_TYPE_HPP
#define I_ZONE_DESCRIPTOR_HF_TYPE_HPP
#include <mesh/IZoneDescriptor.hpp>
#include <utils/checkpointing/CheckpointUtils.hpp>
HighFive::EnumType<IZoneDescriptor::Type> PUGS_INLINE
create_enum_i_zone_descriptor_type()
{
return {{"named", IZoneDescriptor::Type::named}, {"numbered", IZoneDescriptor::Type::numbered}};
}
HIGHFIVE_REGISTER_TYPE(IZoneDescriptor::Type, create_enum_i_zone_descriptor_type);
#endif // I_ZONE_DESCRIPTOR_HF_TYPE_HPP
...@@ -3,8 +3,14 @@ ...@@ -3,8 +3,14 @@
#include <language/utils/DataHandler.hpp> #include <language/utils/DataHandler.hpp>
#include <language/utils/SymbolTable.hpp> #include <language/utils/SymbolTable.hpp>
#include <mesh/NamedBoundaryDescriptor.hpp> #include <mesh/NamedBoundaryDescriptor.hpp>
#include <mesh/NamedInterfaceDescriptor.hpp>
#include <mesh/NamedZoneDescriptor.hpp>
#include <mesh/NumberedBoundaryDescriptor.hpp> #include <mesh/NumberedBoundaryDescriptor.hpp>
#include <mesh/NumberedInterfaceDescriptor.hpp>
#include <mesh/NumberedZoneDescriptor.hpp>
#include <utils/checkpointing/IBoundaryDescriptorHFType.hpp> #include <utils/checkpointing/IBoundaryDescriptorHFType.hpp>
#include <utils/checkpointing/IInterfaceDescriptorHFType.hpp>
#include <utils/checkpointing/IZoneDescriptorHFType.hpp>
#include <utils/checkpointing/ResumingData.hpp> #include <utils/checkpointing/ResumingData.hpp>
EmbeddedData EmbeddedData
...@@ -45,3 +51,61 @@ readIBoundaryDescriptor(const std::string& symbol_name, const HighFive::Group& s ...@@ -45,3 +51,61 @@ readIBoundaryDescriptor(const std::string& symbol_name, const HighFive::Group& s
return embedded_data; return embedded_data;
} }
EmbeddedData
readIInterfaceDescriptor(const std::string& symbol_name, const HighFive::Group& symbol_table_group)
{
const HighFive::Group iinterfacedecriptor_group = symbol_table_group.getGroup("embedded/" + symbol_name);
const IInterfaceDescriptor::Type iinterface_descriptor_type =
iinterfacedecriptor_group.getAttribute("iinterface_descriptor_type").read<IInterfaceDescriptor::Type>();
EmbeddedData embedded_data;
switch (iinterface_descriptor_type) {
case IInterfaceDescriptor::Type::named: {
const std::string name = iinterfacedecriptor_group.getAttribute("name").read<std::string>();
embedded_data = {std::make_shared<DataHandler<const IInterfaceDescriptor>>(
std::make_shared<const NamedInterfaceDescriptor>(name))};
break;
}
case IInterfaceDescriptor::Type::numbered: {
const unsigned int number = iinterfacedecriptor_group.getAttribute("number").read<unsigned int>();
embedded_data = {std::make_shared<DataHandler<const IInterfaceDescriptor>>(
std::make_shared<const NumberedInterfaceDescriptor>(number))};
break;
}
}
return embedded_data;
}
EmbeddedData
readIZoneDescriptor(const std::string& symbol_name, const HighFive::Group& symbol_table_group)
{
const HighFive::Group izonedecriptor_group = symbol_table_group.getGroup("embedded/" + symbol_name);
const IZoneDescriptor::Type izone_descriptor_type =
izonedecriptor_group.getAttribute("izone_descriptor_type").read<IZoneDescriptor::Type>();
EmbeddedData embedded_data;
switch (izone_descriptor_type) {
case IZoneDescriptor::Type::named: {
const std::string name = izonedecriptor_group.getAttribute("name").read<std::string>();
embedded_data = {
std::make_shared<DataHandler<const IZoneDescriptor>>(std::make_shared<const NamedZoneDescriptor>(name))};
break;
}
case IZoneDescriptor::Type::numbered: {
const unsigned int number = izonedecriptor_group.getAttribute("number").read<unsigned int>();
embedded_data = {
std::make_shared<DataHandler<const IZoneDescriptor>>(std::make_shared<const NumberedZoneDescriptor>(number))};
break;
}
}
return embedded_data;
}
...@@ -30,5 +30,7 @@ read(const HighFive::Group& group, const std::string& name) ...@@ -30,5 +30,7 @@ read(const HighFive::Group& group, const std::string& name)
EmbeddedData readMesh(const std::string& symbol_name, const HighFive::Group& symbol_table_group); EmbeddedData readMesh(const std::string& symbol_name, const HighFive::Group& symbol_table_group);
EmbeddedData readIBoundaryDescriptor(const std::string& symbol_name, const HighFive::Group& symbol_table_group); EmbeddedData readIBoundaryDescriptor(const std::string& symbol_name, const HighFive::Group& symbol_table_group);
EmbeddedData readIInterfaceDescriptor(const std::string& symbol_name, const HighFive::Group& symbol_table_group);
EmbeddedData readIZoneDescriptor(const std::string& symbol_name, const HighFive::Group& symbol_table_group);
#endif // RESUME_UTILS_HPP #endif // RESUME_UTILS_HPP
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment