Rename sample_source -> sample.
Use std::string as type of argument to openmc_create_source.
Use reinterpret_cast when accessing dlsym.
Also moves check for dlerror to be before the attempt to create the
source (avoids null reference if fails) and capture error message
before dlclose, so that the error message is still available.
Formatting updates and some refactoring for examples and tests.
Custom sources are now created only through the new class-based method,
which supports parameterization.
New method also slightly adjusted to create the source as managed by a
unique_ptr.
Examples and tests updated to align with this approach.
Documentation updated.
This new function lives inside include/openmc/error.h and
checks if a message will be written by checking the current
verbosity level prior to formatting the message. This works very
similar to python logging modules and the spdlog project, where
the call to the logging function accepts a formattable message
string and the format arguments separately, e.g.
write_message(1, "Writing data for statepoint {}", point)
The function accepts any number and type of argument after the
format message and passes directly to fmt::format and in-turn to
the non-templated write_message. While this later function does
similar checking with the level and MPI rank, the real goal is the
output function in src/error.cpp which is not currently exposed
through the error header file
Thanks to @paulromano for feedback and suggestions
Updates to examples and tests to refer to parameterized sources rather
than serialized sources.
Small update to source.h to remove reference to serialized parameters.
In the existing custom_source implementation, the source will only be
created once. This is much more efficient than the custom serialized
source, where each sampling will create a new instance of the class.
As there could be many samples, this introduces an overhead,
particularly if the operations to instantiate the class are not trivial.
This implementation defines an abstract class, which is then used by the
custom classes to allow the custom serialized class to be created based
on the plugin, sampled from, and then destroyed.
Update documentation and test to reflect this.
If the destructor of an object tries to remove an entry from the map, there's no
guarantee it exists if the map has already been destroyed (because it was
declared after the vector of objects), resulting in a segfault. By declaring the
map first, we avoid this. Currently an issue for Nuclide, but potentially other
classes in the future.