mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 21:25:36 -04:00
Load the serialized representation from file once
The previous implementation had each sampling run reading from the serialized file. This introduced a large I/O overhead and the performance was much slower than the equivalent run with the unserialized source.
This commit is contained in:
parent
d4e7fa5d87
commit
175d57c126
2 changed files with 10 additions and 2 deletions
|
|
@ -23,9 +23,11 @@ class SerialisedSource {
|
|||
|
||||
// The deserialisation routine populates the constructor from well defined elements
|
||||
// in the input XML document.
|
||||
// Note that the source will have already been read from file, so what will be passed
|
||||
// in here is a string-like serialized value (not the path to the serialized value).
|
||||
static SerialisedSource from_xml(char* serialised_source) {
|
||||
pugi::xml_document doc;
|
||||
doc.load_file(serialised_source);
|
||||
doc.load_string(serialised_source);
|
||||
pugi::xml_node root_node = doc.root().child("Source");
|
||||
double radius = root_node.child("Radius").text().as_double();
|
||||
double energy = root_node.child("Energy").text().as_double();
|
||||
|
|
|
|||
|
|
@ -99,7 +99,13 @@ SourceDistribution::SourceDistribution(pugi::xml_node node)
|
|||
}
|
||||
|
||||
if (check_for_node(node, "serialization")) {
|
||||
serialization = get_node_value(node, "serialization", false, true);
|
||||
// If the source is serialized then make sure we only load it from file once, otherwise there will
|
||||
// be a significant I/O overhead.
|
||||
pugi::xml_document doc;
|
||||
doc.load_file(get_node_value(node, "serialization", false, true).c_str());
|
||||
std::stringstream ss;
|
||||
doc.print(ss);
|
||||
serialization = ss.str();
|
||||
}
|
||||
} else {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue