Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
803 changes: 572 additions & 231 deletions doc/world_builder_declarations.schema.json

Large diffs are not rendered by default.

1,108 changes: 810 additions & 298 deletions doc/world_builder_declarations_closed.md

Large diffs are not rendered by default.

1,251 changes: 924 additions & 327 deletions doc/world_builder_declarations_open.md

Large diffs are not rendered by default.

26 changes: 18 additions & 8 deletions include/world_builder/parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ namespace WorldBuilder
*/
~Parameters();

struct composition_property
{
unsigned int index;
std::string name;
double reference_density;
};

/**
* Initializes the parameter file
* \param filename A string with the path to the world builder file
Expand All @@ -110,11 +117,21 @@ namespace WorldBuilder

/**
* A specialized version of get which can return vectors/arrays.
*
* Note: The specialization get_vector<unsigned int>() also supports
* mixed input of unsigned-int indices and string composition names for
* entries that allow it (e.g. composition identifier arrays). String
* names are resolved to indices using the global composition properties
* table.
* \param name The name of the entry to retrieved
*/
template<class T>
std::vector<T> get_vector(const std::string &name);

template<class T>
std::vector<T> get_vector(const std::string &name,
const std::vector<Parameters::composition_property> &global_composition_properties);

std::vector<std::vector<double>> get_vector_or_double(const std::string &name);

/**
Expand Down Expand Up @@ -181,20 +198,13 @@ namespace WorldBuilder
bool
check_entry(const std::string &name) const;

struct composition_properties
{
unsigned int index;
std::string name;
double reference_density;
};

/**
* Parse composition properties.
* The index is required, while name and reference density are optional.
* If the entry is absent, the vector is empty.
* \param name The name of the entry to be declared
*/
std::vector<composition_properties>
std::vector<composition_property>
get_composition_properties(const std::string &name) const;

/**
Expand Down
4 changes: 2 additions & 2 deletions include/world_builder/world.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ namespace WorldBuilder
* Return all composition properties from its index.
* If the index is unknown, returns fallback properties with a generated name.
*/
Parameters::composition_properties get_composition_properties(const unsigned int composition_index) const;
Parameters::composition_property get_composition_properties(const unsigned int composition_index) const;

/**
* This is the parameter class, which stores all the values loaded in
Expand Down Expand Up @@ -350,7 +350,7 @@ namespace WorldBuilder
/**
* A map from composition index to its properties for quick lookups.
*/
std::map<unsigned int, Parameters::composition_properties> composition_properties;
std::vector<Parameters::composition_property> composition_properties;

private:
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace WorldBuilder
Types::String("")),
"The depth in meters to which the composition of this feature is present.");

prm.declare_entry("compositions", Types::Array(Types::UnsignedInt(),0),
prm.declare_entry("compositions", Types::Array(Types::OneOf(Types::UnsignedInt(), Types::String("")),0),
"A list with the labels of the composition which are present there.");

prm.declare_entry("min value", Types::Array(Types::Double(0.0),1),
Expand All @@ -101,7 +101,7 @@ namespace WorldBuilder
max_depth_surface = Objects::Surface(prm.get("max depth",coordinates));
max_depth = max_depth_surface.maximum;

compositions = prm.get_vector<unsigned int>("compositions");
compositions = prm.get_vector<unsigned int>("compositions", this->world->composition_properties);
min_value = prm.get_vector<double>("min value");
max_value = prm.get_vector<double>("max value");
operation = string_operations_to_enum(prm.get<std::string>("operation"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ namespace WorldBuilder
Types::String("")),
"The depth in meters to which the composition of this feature is present.");

prm.declare_entry("compositions", Types::Array(Types::UnsignedInt(),0),
prm.declare_entry("compositions", Types::Array(Types::OneOf(Types::UnsignedInt(), Types::String("")),0),
"A list with the labels of the composition which are present there.");

prm.declare_entry("fractions", Types::Array(Types::Double(1.0),1),
"TA list of compositional fractions corresponding to the compositions list.");
"A list of compositional fractions corresponding to the compositions list.");

prm.declare_entry("operation", Types::String("replace", std::vector<std::string> {"replace", "replace defined only", "add", "subtract"}),
"Whether the value should replace any value previously defined at this location (replace) or "
Expand All @@ -93,7 +93,7 @@ namespace WorldBuilder
max_depth_surface = Objects::Surface(prm.get("max depth",coordinates));
max_depth = max_depth_surface.maximum;

compositions = prm.get_vector<unsigned int>("compositions");
compositions = prm.get_vector<unsigned int>("compositions", this->world->composition_properties);
fractions = prm.get_vector<double>("fractions");
operation = string_operations_to_enum(prm.get<std::string>("operation"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ namespace WorldBuilder
min_depth = min_depth_surface.minimum;
max_depth_surface = Objects::Surface(prm.get("max depth",coordinates));
max_depth = max_depth_surface.maximum;
compositions = prm.get_vector<unsigned int>("compositions");
compositions = prm.get_vector<unsigned int>("compositions", this->world->composition_properties);

operation = prm.get<std::string>("orientation operation");
grain_sizes = prm.get_vector<double>("grain sizes");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ namespace WorldBuilder
min_depth = min_depth_surface.minimum;
max_depth_surface = Objects::Surface(prm.get("max depth",coordinates));
max_depth = max_depth_surface.maximum;
compositions = prm.get_vector<unsigned int>("compositions");
compositions = prm.get_vector<unsigned int>("compositions", this->world->composition_properties);

const bool set_euler_angles = prm.check_entry("basis Euler angles z-x-z");
const bool set_rotation_matrices = prm.check_entry("basis rotation matrices");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ namespace WorldBuilder
min_depth = min_depth_surface.minimum;
max_depth_surface = Objects::Surface(prm.get("max depth",coordinates));
max_depth = max_depth_surface.maximum;
compositions = prm.get_vector<unsigned int>("compositions");
compositions = prm.get_vector<unsigned int>("compositions", this->world->composition_properties);

const bool set_euler_angles = prm.check_entry("Euler angles z-x-z");
const bool set_rotation_matrices = prm.check_entry("rotation matrices");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace WorldBuilder
"The composition fraction at the center of the fault.");
prm.declare_entry("side fractions", Types::Array(Types::Double(0.0),1),
"The composition fraction at the sides of this feature.");
prm.declare_entry("compositions", Types::Array(Types::UnsignedInt(),0),
prm.declare_entry("compositions", Types::Array(Types::OneOf(Types::UnsignedInt(), Types::String("")),0),
"A list with the labels of the composition which are present there.");
prm.declare_entry("operation", Types::String("replace", std::vector<std::string> {"replace", "replace defined only", "add", "subtract"}),
"Whether the value should replace any value previously defined at this location (replace) or "
Expand All @@ -85,7 +85,7 @@ namespace WorldBuilder
operation = string_operations_to_enum(prm.get<std::string>("operation"));
center_fraction = prm.get_vector<double>("center fractions");
side_fraction = prm.get_vector<double>("side fractions");
compositions = prm.get_vector<unsigned int>("compositions");
compositions = prm.get_vector<unsigned int>("compositions", this->world->composition_properties);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ namespace WorldBuilder
"The distance in meters from which the composition of this feature is present.");
prm.declare_entry("max distance fault center", Types::Double(std::numeric_limits<double>::max()),
"The distance in meters to which the composition of this feature is present.");
prm.declare_entry("compositions", Types::Array(Types::UnsignedInt(),0),
prm.declare_entry("compositions", Types::Array(Types::OneOf(Types::UnsignedInt(), Types::String("")),0),
"A list with the labels of the composition which are present there.");
prm.declare_entry("fractions", Types::Array(Types::Double(1.0),1),
"TA list of compositional fractions corresponding to the compositions list.");
Expand All @@ -81,7 +81,7 @@ namespace WorldBuilder
{
min_depth = prm.get<double>("min distance fault center");
max_depth = prm.get<double>("max distance fault center");
compositions = prm.get_vector<unsigned int>("compositions");
compositions = prm.get_vector<unsigned int>("compositions", this->world->composition_properties);
fractions = prm.get_vector<double>("fractions");
operation = string_operations_to_enum(prm.get<std::string>("operation"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ namespace WorldBuilder
{
min_depth = prm.get<double>("min distance fault center");
max_depth = prm.get<double>("max distance fault center");
compositions = prm.get_vector<unsigned int>("compositions");
compositions = prm.get_vector<unsigned int>("compositions", this->world->composition_properties);

operation = prm.get<std::string>("orientation operation");
grain_sizes = prm.get_vector<double>("grain sizes");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ namespace WorldBuilder
{
min_depth = prm.get<double>("min distance fault center");
max_depth = prm.get<double>("max distance fault center");
compositions = prm.get_vector<unsigned int>("compositions");
compositions = prm.get_vector<unsigned int>("compositions", this->world->composition_properties);

const bool set_euler_angles = prm.check_entry("basis Euler angles z-x-z");
const bool set_rotation_matrices = prm.check_entry("basis rotation matrices");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace WorldBuilder
{
min_depth = prm.get<double>("min distance fault center");
max_depth = prm.get<double>("max distance fault center");
compositions = prm.get_vector<unsigned int>("compositions");
compositions = prm.get_vector<unsigned int>("compositions", this->world->composition_properties);

const bool set_euler_angles = prm.check_entry("Euler angles z-x-z");
const bool set_rotation_matrices = prm.check_entry("rotation matrices");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace WorldBuilder
"The depth in meters from which the composition of this feature is present.");
prm.declare_entry("max depth", Types::OneOf(Types::Double(std::numeric_limits<double>::max()),Types::Array(Types::ValueAtPoints(std::numeric_limits<double>::max(),2))),
"The depth in meters to which the composition of this feature is present.");
prm.declare_entry("compositions", Types::Array(Types::UnsignedInt(),0),
prm.declare_entry("compositions", Types::Array(Types::OneOf(Types::UnsignedInt(), Types::String("")),0),
"A list with the labels of the composition which are present there.");
prm.declare_entry("fractions", Types::Array(Types::Double(1.0),1),
"TA list of compositional fractions corresponding to the compositions list.");
Expand All @@ -84,7 +84,7 @@ namespace WorldBuilder
min_depth = min_depth_surface.minimum;
max_depth_surface = Objects::Surface(prm.get("max depth",coordinates));
max_depth = max_depth_surface.maximum;
compositions = prm.get_vector<unsigned int>("compositions");
compositions = prm.get_vector<unsigned int>("compositions", this->world->composition_properties);
fractions = prm.get_vector<double>("fractions");
operation = string_operations_to_enum(prm.get<std::string>("operation"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ namespace WorldBuilder
min_depth = min_depth_surface.minimum;
max_depth_surface = Objects::Surface(prm.get("max depth",coordinates));
max_depth = max_depth_surface.maximum;
compositions = prm.get_vector<unsigned int>("compositions");
compositions = prm.get_vector<unsigned int>("compositions", this->world->composition_properties);

operation = prm.get<std::string>("orientation operation");
grain_sizes = prm.get_vector<double>("grain sizes");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ namespace WorldBuilder
min_depth = min_depth_surface.minimum;
max_depth_surface = Objects::Surface(prm.get("max depth",coordinates));
max_depth = max_depth_surface.maximum;
compositions = prm.get_vector<unsigned int>("compositions");
compositions = prm.get_vector<unsigned int>("compositions", this->world->composition_properties);

const bool set_euler_angles = prm.check_entry("basis Euler angles z-x-z");
const bool set_rotation_matrices = prm.check_entry("basis rotation matrices");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ namespace WorldBuilder
min_depth = min_depth_surface.minimum;
max_depth_surface = Objects::Surface(prm.get("max depth",coordinates));
max_depth = max_depth_surface.maximum;
compositions = prm.get_vector<unsigned int>("compositions");
compositions = prm.get_vector<unsigned int>("compositions", this->world->composition_properties);

const bool set_euler_angles = prm.check_entry("Euler angles z-x-z");
const bool set_rotation_matrices = prm.check_entry("rotation matrices");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace WorldBuilder
Types::String("")),
"The depth in meters to which the composition of this feature is present.");

prm.declare_entry("compositions", Types::Array(Types::UnsignedInt(),0),
prm.declare_entry("compositions", Types::Array(Types::OneOf(Types::UnsignedInt(), Types::String("")),0),
"A list with the labels of the composition which are present there.");
prm.declare_entry("density", Types::Double(3000.0),
"The reference density used for determining the lithostatic pressure for calculating "
Expand Down Expand Up @@ -110,7 +110,7 @@ namespace WorldBuilder
max_depth_surface = Objects::Surface(prm.get("max depth",coordinates));
max_depth = max_depth_surface.maximum;
density = prm.get<double>("density");
compositions = prm.get_vector<unsigned int>("compositions");
compositions = prm.get_vector<unsigned int>("compositions", this->world->composition_properties);
max_water_content = prm.get<double>("initial water content");
operation = string_operations_to_enum(prm.get<std::string>("operation"));
cutoff_pressure = prm.get<double>("cutoff pressure");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace WorldBuilder
Types::String("")),
"The depth in meters to which the composition of this feature is present.");

prm.declare_entry("compositions", Types::Array(Types::UnsignedInt(),0),
prm.declare_entry("compositions", Types::Array(Types::OneOf(Types::UnsignedInt(), Types::String("")),0),
"A list with the labels of the composition which are present there.");
prm.declare_entry("fractions", Types::Array(Types::Double(1.0),1),
"TA list of compositional fractions corresponding to the compositions list.");
Expand All @@ -88,7 +88,7 @@ namespace WorldBuilder
min_depth = min_depth_surface.minimum;
max_depth_surface = Objects::Surface(prm.get("max depth",coordinates));
max_depth = max_depth_surface.maximum;
compositions = prm.get_vector<unsigned int>("compositions");
compositions = prm.get_vector<unsigned int>("compositions", this->world->composition_properties);
fractions = prm.get_vector<double>("fractions");
operation = string_operations_to_enum(prm.get<std::string>("operation"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ namespace WorldBuilder
min_depth = min_depth_surface.minimum;
max_depth_surface = Objects::Surface(prm.get("max depth",coordinates));
max_depth = max_depth_surface.maximum;
compositions = prm.get_vector<unsigned int>("compositions");
compositions = prm.get_vector<unsigned int>("compositions", this->world->composition_properties);

operation = prm.get<std::string>("orientation operation");
grain_sizes = prm.get_vector<double>("grain sizes");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ namespace WorldBuilder
min_depth = min_depth_surface.minimum;
max_depth_surface = Objects::Surface(prm.get("max depth",coordinates));
max_depth = max_depth_surface.maximum;
compositions = prm.get_vector<unsigned int>("compositions");
compositions = prm.get_vector<unsigned int>("compositions", this->world->composition_properties);

const bool set_euler_angles = prm.check_entry("basis Euler angles z-x-z");
const bool set_rotation_matrices = prm.check_entry("basis rotation matrices");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ namespace WorldBuilder
min_depth = min_depth_surface.minimum;
max_depth_surface = Objects::Surface(prm.get("max depth",coordinates));
max_depth = max_depth_surface.maximum;
compositions = prm.get_vector<unsigned int>("compositions");
compositions = prm.get_vector<unsigned int>("compositions", this->world->composition_properties);

const bool set_euler_angles = prm.check_entry("Euler angles z-x-z");
const bool set_rotation_matrices = prm.check_entry("rotation matrices");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace WorldBuilder
prm.declare_entry("max depth", Types::Double(std::numeric_limits<double>::max()),
"The depth in meters to which the composition of this feature is present.");

prm.declare_entry("compositions", Types::Array(Types::UnsignedInt(),0),
prm.declare_entry("compositions", Types::Array(Types::OneOf(Types::UnsignedInt(), Types::String("")),0),
"A list with the labels of the composition which are present there.");

prm.declare_entry("fractions", Types::Array(Types::Double(1.0),1),
Expand All @@ -86,7 +86,7 @@ namespace WorldBuilder
min_depth = prm.get<double>("min depth");
max_depth = prm.get<double>("max depth");

compositions = prm.get_vector<unsigned int>("compositions");
compositions = prm.get_vector<unsigned int>("compositions", this->world->composition_properties);
fractions = prm.get_vector<double>("fractions");
operation = string_operations_to_enum(prm.get<std::string>("operation"));

Expand Down
Loading
Loading