Skip to content

Commit 6b50b64

Browse files
committed
Enhance legacy section metadata with more info
Useful for FourCIPP
1 parent 8c4306f commit 6b50b64

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

src/global_data/4C_global_data_read.cpp

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -163,24 +163,36 @@ Core::IO::InputFile Global::set_up_input_file(MPI_Comm comm)
163163
};
164164

165165

166-
using namespace Core::IO::InputSpecBuilders;
167-
168-
std::vector<Core::IO::InputSpec> all_element_specs;
169-
Core::Elements::ElementDefinition element_definition;
170-
element_definition.setup_valid_element_lines();
171-
for (const auto& [element_type, cell_specs] : element_definition.definitions())
166+
std::map<std::string, Core::IO::InputSpec> legacy_partial_specs;
167+
// We know quite a lot about the legacy sections. Even though we cannot parse them via
168+
// the InputSpec engine, we can still emit as much information as possible to the metadata.
169+
//
170+
// A parameter named "_positional_<index>_<name>" implies that the parameter needs to appear
171+
// at the specified position without a key. This is very useful for the geometry information
172+
// which often contains enumerators.
172173
{
173-
std::vector<Core::IO::InputSpec> element_specs;
174-
for (const auto& [cell_type, spec] : cell_specs)
174+
using namespace Core::IO::InputSpecBuilders;
175+
std::vector<Core::IO::InputSpec> all_element_specs;
176+
Core::Elements::ElementDefinition element_definition;
177+
element_definition.setup_valid_element_lines();
178+
for (const auto& [element_type, cell_specs] : element_definition.definitions())
175179
{
176-
element_specs.emplace_back(group(cell_type, {spec}));
180+
std::vector<Core::IO::InputSpec> element_specs;
181+
for (const auto& [cell_type, spec] : cell_specs)
182+
{
183+
element_specs.emplace_back(group(cell_type, {spec}));
184+
}
185+
all_element_specs.emplace_back(group(element_type, {one_of(std::move(element_specs))}));
177186
}
178-
all_element_specs.emplace_back(group(element_type, {one_of(std::move(element_specs))}));
179-
}
180187

188+
legacy_partial_specs["legacy_element_specs"] = all_of({
189+
parameter<int>("_positional_0_id"),
190+
one_of(std::move(all_element_specs)),
191+
});
192+
}
181193

182194
return Core::IO::InputFile{std::move(valid_sections), std::move(legacy_section_names),
183-
{{"legacy_element_specs", one_of(std::move(all_element_specs))}}, comm};
195+
std::move(legacy_partial_specs), comm};
184196
}
185197

186198
void Global::read_fields(Global::Problem& problem, Core::IO::InputFile& input, const bool read_mesh)

0 commit comments

Comments
 (0)