22 static void printBanner(
ILogger& logger) {
23 logger.
write(
"*******************************************************************************");
24 logger.
write(
"******************************** OpenSPH CLI **********************************");
25 logger.
write(
"*******************************************************************************");
47 entry.
set(input.
get<
bool>(name));
50 entry.
set(input.
get<
int>(name));
62 entry.
set(input.
get<std::string>(name));
85 logger.
write(
"Failed to load value, keeping the default.\n", e.
what());
91 static void registerJobs() {
99 #ifdef SPH_USE_CHAISCRIPT
100 static ChaiScriptJob sScript(
"");
106 logger.
write(
"Running opensph-cli (version ",
SPH_STR(SPH_VERSION),
")");
108 logger.
write(
"Running opensph-cli (unknown version)");
110 const Path projectPath(parser.
getArg<std::string>(
"p"));
111 const std::string nodeToRun(parser.
getArg<std::string>(
"n"));
114 config.
load(projectPath);
122 inNodes->enumerateChildren([&nodes, &allToConnect, &logger](std::string name,
ConfigNode& input) {
123 const std::string className = input.
get<std::string>(
"class_name");
126 throw Exception(
"Cannot find desc for node '" + className +
"'");
137 const std::string slotName = node->
getSlot(i).
name;
145 for (
auto& toConnect : allToConnect) {
146 for (
auto& element : nodes) {
147 if (element.key == toConnect.get<2>()) {
148 element.value->connect(toConnect.get<0>(), toConnect.get<1>());
155 throw Exception(
"No node '" + nodeToRun +
"' found in the project");
158 logger.
write(
"Running node tree:");
172 runner.
value()->run(globals, callbacks);
175 int main(
int argc,
char* argv[]) {
181 parser.
parse(argc, argv);
#define NOT_IMPLEMENTED
Helper macro marking missing implementation.
Interface for the configuration files storing job data.
uint32_t Size
Integral type used to index arrays (by default).
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
RawPtr< IJobDesc > getJobDesc(const std::string &name)
Returns a job descriptor for given class name.
int main(int argc, char *argv[])
Additional bindings to IVirtualSettings.
INLINE auto makeTuple(TArgs &&... args)
Creates a tuple from a pack of values, utilizing type deduction.
Provides functions for parsing command-line arguments.
void parse(const int argc, char **argv)
Parses the input arguments and stored the parsed values.
TValue getArg(const std::string &name) const
Returns the value of an argument, given its short name (without the dash).
INLINE void push(U &&u)
Adds new element to the end of the array, resizing the array if necessary.
Represents a single node in the hierarchy written into config file.
Optional< Type > tryGet(const std::string &name)
Tries to return a value stored in the node.
Type get(const std::string &name)
Returns a value stored in the node.
Provides functionality for reading and writing configuration files.
SharedPtr< ConfigNode > getNode(const std::string &name)
Returns a node with given name.
void load(const Path &path)
Reads content of given file and deserializes the config from the loaded string.
virtual const char * what() const noexcept
Container of key-value pairs.
INLINE TValue & insert(const TKey &key, const TValue &value)
Adds a new element into the map or sets new value of element with the same key.
Exception thrown when used passes -h or –help parameter.
Interface providing generic (text, human readable) output of the program.
void write(TArgs &&... args)
Creates and logs a message by concatenating arguments.
Represents a virtual entry in the settings.
virtual bool set(const Value &value)=0
Modifies the current value of the entry.
virtual Value get() const =0
Returns the currently stored value.
virtual Type getType() const =0
Returns the type of this entry.
Object representing a 1D interval of real numbers.
Size getSlotCnt() const
Returns the number of provider slots of this node.
std::string instanceName() const
Returns the instance name of the job.
SlotData getSlot(const Size index) const
Returns the information about given slot.
VirtualSettings getSettings() const
Returns settings object allowing to access and modify the state of the job.
virtual void onCategory(const std::string &UNUSED(name)) const override
LoadProc(ConfigNode &input, ILogger &logger)
virtual void onEntry(const std::string &name, IVirtualEntry &entry) const override
Called for every entry in the current category.
Creates a single monolithic body.
INLINE Type & value()
Returns the reference to the stored value.
Object representing a path on a filesystem.
Non-owning wrapper of pointer.
Settings & set(const TEnum idx, TValue &&value, std::enable_if_t<!std::is_enum< std::decay_t< TValue >>::value, int >=0)
Saves a value into the settings.
Interface allowing to enumerate all entries in the settings.
Holds a map of virtual entries, associated with a unique name.
void enumerate(const IEntryProc &proc)
Enumerates all entries stored in the settings.
@ UNIFORM
Mersenne Twister PRNG from Standard library.
const EmptySettingsTag EMPTY_SETTINGS
@ CUBIC_SPLINE
M4 B-spline (piecewise cubic polynomial)
@ SPH_KERNEL
Index of SPH Kernel, see KernelEnum.
@ GENERATE_UVWS
If true, the mapping coordinates will be computed and saved for all bodies in the simulation.
@ RUN_THREAD_CNT
Number of threads used by the code. If 0, all available threads are used.
@ RUN_RNG
Selected random-number generator used within the run.
@ RUN_RNG_SEED
Seed for the random-number generator.
std::string name
Identifier of the slot, used by the job to obtain the provided data.