Skip to content

Commit

Permalink
Merge pull request #594 from MFraters/add_tag_system_to_properties
Browse files Browse the repository at this point in the history
Add tag system to properties
  • Loading branch information
MFraters authored Feb 15, 2024
2 parents 6f2dbbe + 9e151ab commit 180ea68
Show file tree
Hide file tree
Showing 68 changed files with 2,827 additions and 2,291 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Added
- Added an option to use the plate model as the reference model for the mass conserving temperature of the slab. \[Haoyuan Li; 2024-02-02; [#471](https://github.com/GeodynamicWorldBuilder/WorldBuilder/pull/471)\]
- Added a cookbook for making a transform fault and using this model in ASPECT. \[Juliane Dannberg; 2024-02-14; [#563](https://github.com/GeodynamicWorldBuilder/WorldBuilder/pull/563)\]
- Added a system which allows users to tag features. The tag index can then be written out throught the gwb-dat program. \[Menno Fraters and Timo Heister; 2024-02-15; [[#598](https://github.com/GeodynamicWorldBuilder/WorldBuilder/pull/598)]\]

### Changed
- Unified the directories `cookbooks/` and `doc/sphinx/user_manual/cookbooks`. All information about cookbooks including the documentation is now bundled in the top-level `cookbooks/` directory. \[Rene Gassmoeller; 2024-02-14; [#558](github.com/GeodynamicWorldBuilder/WorldBuilder/pull/558)\]
Expand Down
35 changes: 30 additions & 5 deletions doc/world_builder_declarations.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,12 @@
"name": {
"default value": "",
"type": "string",
"description": "The name which the user has given to the feature."
"description": "The name which the user has given to the feature. This is mostly used for documentation purposes, and should in most cases be unique, although this is not enforced."
},
"tag": {
"default value": "",
"type": "string",
"description": "A tag which can be given to a feature. This is meant to catagorize different features. If the tag is not provided or empty, it is set to the model name."
},
"coordinates": {
"type": "array",
Expand Down Expand Up @@ -1219,7 +1224,12 @@
"name": {
"default value": "",
"type": "string",
"description": "The name which the user has given to the feature."
"description": "The name which the user has given to the feature. This is mostly used for documentation purposes, and should in most cases be unique, although this is not enforced."
},
"tag": {
"default value": "",
"type": "string",
"description": "A tag which can be given to a feature. This is meant to catagorize different features. If the tag is not provided or empty, it is set to the model name."
},
"coordinates": {
"type": "array",
Expand Down Expand Up @@ -3380,7 +3390,12 @@
"name": {
"default value": "",
"type": "string",
"description": "The name which the user has given to the feature."
"description": "The name which the user has given to the feature. This is mostly used for documentation purposes, and should in most cases be unique, although this is not enforced."
},
"tag": {
"default value": "",
"type": "string",
"description": "A tag which can be given to a feature. This is meant to catagorize different features. If the tag is not provided or empty, it is set to the model name."
},
"coordinates": {
"type": "array",
Expand Down Expand Up @@ -4410,7 +4425,12 @@
"name": {
"default value": "",
"type": "string",
"description": "The name which the user has given to the feature."
"description": "The name which the user has given to the feature. This is mostly used for documentation purposes, and should in most cases be unique, although this is not enforced."
},
"tag": {
"default value": "",
"type": "string",
"description": "A tag which can be given to a feature. This is meant to catagorize different features. If the tag is not provided or empty, it is set to the model name."
},
"coordinates": {
"type": "array",
Expand Down Expand Up @@ -5890,7 +5910,12 @@
"name": {
"default value": "",
"type": "string",
"description": "The name which the user has given to the feature."
"description": "The name which the user has given to the feature. This is mostly used for documentation purposes, and should in most cases be unique, although this is not enforced."
},
"tag": {
"default value": "",
"type": "string",
"description": "A tag which can be given to a feature. This is meant to catagorize different features. If the tag is not provided or empty, it is set to the model name."
},
"coordinates": {
"type": "array",
Expand Down
50 changes: 45 additions & 5 deletions doc/world_builder_declarations_closed.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,15 @@

- **default value**:
- **type**:string
- **description**:The name which the user has given to the feature.
- **description**:The name which the user has given to the feature. This is mostly used for documentation purposes, and should in most cases be unique, although this is not enforced.
::::::::::::::::::::

::::::::::::::::::::{dropdown} /features/items/oneOf/1/tag
:name: closed_features_items_oneOf_1_tag

- **default value**:
- **type**:string
- **description**:A tag which can be given to a feature. This is meant to catagorize different features. If the tag is not provided or empty, it is set to the model name.
::::::::::::::::::::

::::::::::::::::::::{dropdown} /features/items/oneOf/1/coordinates
Expand Down Expand Up @@ -1855,7 +1863,15 @@

- **default value**:
- **type**:string
- **description**:The name which the user has given to the feature.
- **description**:The name which the user has given to the feature. This is mostly used for documentation purposes, and should in most cases be unique, although this is not enforced.
::::::::::::::::::::

::::::::::::::::::::{dropdown} /features/items/oneOf/2/tag
:name: closed_features_items_oneOf_2_tag

- **default value**:
- **type**:string
- **description**:A tag which can be given to a feature. This is meant to catagorize different features. If the tag is not provided or empty, it is set to the model name.
::::::::::::::::::::

::::::::::::::::::::{dropdown} /features/items/oneOf/2/coordinates
Expand Down Expand Up @@ -4816,7 +4832,15 @@

- **default value**:
- **type**:string
- **description**:The name which the user has given to the feature.
- **description**:The name which the user has given to the feature. This is mostly used for documentation purposes, and should in most cases be unique, although this is not enforced.
::::::::::::::::::::

::::::::::::::::::::{dropdown} /features/items/oneOf/3/tag
:name: closed_features_items_oneOf_3_tag

- **default value**:
- **type**:string
- **description**:A tag which can be given to a feature. This is meant to catagorize different features. If the tag is not provided or empty, it is set to the model name.
::::::::::::::::::::

::::::::::::::::::::{dropdown} /features/items/oneOf/3/coordinates
Expand Down Expand Up @@ -6413,7 +6437,15 @@

- **default value**:
- **type**:string
- **description**:The name which the user has given to the feature.
- **description**:The name which the user has given to the feature. This is mostly used for documentation purposes, and should in most cases be unique, although this is not enforced.
::::::::::::::::::::

::::::::::::::::::::{dropdown} /features/items/oneOf/4/tag
:name: closed_features_items_oneOf_4_tag

- **default value**:
- **type**:string
- **description**:A tag which can be given to a feature. This is meant to catagorize different features. If the tag is not provided or empty, it is set to the model name.
::::::::::::::::::::

::::::::::::::::::::{dropdown} /features/items/oneOf/4/coordinates
Expand Down Expand Up @@ -8698,7 +8730,15 @@

- **default value**:
- **type**:string
- **description**:The name which the user has given to the feature.
- **description**:The name which the user has given to the feature. This is mostly used for documentation purposes, and should in most cases be unique, although this is not enforced.
::::::::::::::::::::

::::::::::::::::::::{dropdown} /features/items/oneOf/5/tag
:name: closed_features_items_oneOf_5_tag

- **default value**:
- **type**:string
- **description**:A tag which can be given to a feature. This is meant to catagorize different features. If the tag is not provided or empty, it is set to the model name.
::::::::::::::::::::

::::::::::::::::::::{dropdown} /features/items/oneOf/5/coordinates
Expand Down
55 changes: 50 additions & 5 deletions doc/world_builder_declarations_open.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,16 @@

- **default value**:
- **type**:string
- **description**:The name which the user has given to the feature.
- **description**:The name which the user has given to the feature. This is mostly used for documentation purposes, and should in most cases be unique, although this is not enforced.
::::::::::::::::::::

::::::::::::::::::::{dropdown} /features/items/oneOf/1/tag
:open:
:name: open_features_items_oneOf_1_tag

- **default value**:
- **type**:string
- **description**:A tag which can be given to a feature. This is meant to catagorize different features. If the tag is not provided or empty, it is set to the model name.
::::::::::::::::::::

::::::::::::::::::::{dropdown} /features/items/oneOf/1/coordinates
Expand Down Expand Up @@ -2102,7 +2111,16 @@

- **default value**:
- **type**:string
- **description**:The name which the user has given to the feature.
- **description**:The name which the user has given to the feature. This is mostly used for documentation purposes, and should in most cases be unique, although this is not enforced.
::::::::::::::::::::

::::::::::::::::::::{dropdown} /features/items/oneOf/2/tag
:open:
:name: open_features_items_oneOf_2_tag

- **default value**:
- **type**:string
- **description**:A tag which can be given to a feature. This is meant to catagorize different features. If the tag is not provided or empty, it is set to the model name.
::::::::::::::::::::

::::::::::::::::::::{dropdown} /features/items/oneOf/2/coordinates
Expand Down Expand Up @@ -5407,7 +5425,16 @@

- **default value**:
- **type**:string
- **description**:The name which the user has given to the feature.
- **description**:The name which the user has given to the feature. This is mostly used for documentation purposes, and should in most cases be unique, although this is not enforced.
::::::::::::::::::::

::::::::::::::::::::{dropdown} /features/items/oneOf/3/tag
:open:
:name: open_features_items_oneOf_3_tag

- **default value**:
- **type**:string
- **description**:A tag which can be given to a feature. This is meant to catagorize different features. If the tag is not provided or empty, it is set to the model name.
::::::::::::::::::::

::::::::::::::::::::{dropdown} /features/items/oneOf/3/coordinates
Expand Down Expand Up @@ -7219,7 +7246,16 @@

- **default value**:
- **type**:string
- **description**:The name which the user has given to the feature.
- **description**:The name which the user has given to the feature. This is mostly used for documentation purposes, and should in most cases be unique, although this is not enforced.
::::::::::::::::::::

::::::::::::::::::::{dropdown} /features/items/oneOf/4/tag
:open:
:name: open_features_items_oneOf_4_tag

- **default value**:
- **type**:string
- **description**:A tag which can be given to a feature. This is meant to catagorize different features. If the tag is not provided or empty, it is set to the model name.
::::::::::::::::::::

::::::::::::::::::::{dropdown} /features/items/oneOf/4/coordinates
Expand Down Expand Up @@ -9811,7 +9847,16 @@

- **default value**:
- **type**:string
- **description**:The name which the user has given to the feature.
- **description**:The name which the user has given to the feature. This is mostly used for documentation purposes, and should in most cases be unique, although this is not enforced.
::::::::::::::::::::

::::::::::::::::::::{dropdown} /features/items/oneOf/5/tag
:open:
:name: open_features_items_oneOf_5_tag

- **default value**:
- **type**:string
- **description**:A tag which can be given to a feature. This is meant to catagorize different features. If the tag is not provided or empty, it is set to the model name.
::::::::::::::::::::

::::::::::::::::::::{dropdown} /features/items/oneOf/5/coordinates
Expand Down
10 changes: 10 additions & 0 deletions include/world_builder/features/feature_utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#define WORLD_BUILDER_FEATURES_FEATURE_UTILITIES_H

#include <limits>
#include <vector>

#include "world_builder/assert.h"

Expand Down Expand Up @@ -84,6 +85,15 @@ namespace WorldBuilder
// The local thickness of the segment at the location of the plane.
double local_thickness;
};


/**
* Add a string to a vector of strings, if the exact string isn't already
* in the vector. Returns the location of the string in the final vector.
*/
size_t
add_vector_unique(std::vector<std::string> &vector,const std::string &add_string);

} // namespace Utilities
} // namespace Features
} // namespace WorldBuilder
Expand Down
6 changes: 6 additions & 0 deletions include/world_builder/features/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ namespace WorldBuilder
*/
std::string name;

/**
* The index of the tag for this feature.
* This corresponds to the index in the feature_tags variable which is store in the World.
*/
size_t tag_index;

/**
* The type of interpolation used to get the line position between the points.
*/
Expand Down
14 changes: 11 additions & 3 deletions include/world_builder/world.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,19 @@ namespace WorldBuilder
*
* Composition is identified by 2. This produces one
* value in the output. The second entry identifies the composition number and the third
* number is not used. So a commposition query asking about composition 1 looks like this:
* number is not used. So a composition query asking about composition 1 looks like this:
* {2,1,0}. A composition query prodoces one entry in the output vector.
*
* Grains are identified by 2. The second entry is the grain composition number and the third
* Grains are identified by 3. The second entry is the grain composition number and the third
* entry is the number of grains. A query about the grains, where it asks about composition 1
* (for example enstatite) and 500 grains, looks like this: {2,1,500}.
* (for example enstatite) and 500 grains, looks like this: {3,1,500}.
* A composition query prodoces n_grains*10 entries in the output vector. The first n_grains
* entries are the sizes of all the grains, and the other 9 entries are sets of rotation
* matrices. The rotation matrix entries are ordered [0][0],[0][1],[0][2],[1][0],[1][1],etc.
*
* The tag is identified by 4 and no extra information is needed. So the tag
* input usually looks like {4,0,0}. A tag query prodoces one entry in the output
* vector, representing the index of the tag of the last/dominant feature.
*/
std::vector<double> properties(const std::array<double, 3> &point,
const double depth,
Expand Down Expand Up @@ -275,6 +279,10 @@ namespace WorldBuilder
*/
std::string interpolation;

/**
* A list of all the feature tags.
*/
std::vector<std::string> feature_tags;

private:
/**
Expand Down
10 changes: 7 additions & 3 deletions source/gwb-dat/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ int main(int argc, char **argv)
return 0;
}

if ((argc == 3 && !(limit_debug_consistency_checks && output_json_files)) || (argc == 4 && !(!limit_debug_consistency_checks != !output_json_files)) || (argc == 5 && (!limit_debug_consistency_checks && !output_json_files)) || argc > 5)
if ((argc == 3 && limit_debug_consistency_checks && output_json_files) || (argc == 4 && !(!limit_debug_consistency_checks != !output_json_files)) || (argc == 5 && (!limit_debug_consistency_checks && !output_json_files)) || argc > 5)
{
std::cout << "Only exactly two command line arguments may be given, which should be the world builder file location and the data file location (in that order) "
<< "or exactly three command line arguments, which should be the world builder file location, the data file location and --limit-debug-consistency-checks or --output-json-files (in that order),"
Expand Down Expand Up @@ -203,6 +203,8 @@ int main(int argc, char **argv)
for (size_t gc = 0; gc < grain_compositions; ++gc)
properties.push_back({{3,(unsigned int)gc,(unsigned int)n_grains}}); // grains gc

properties.push_back({{4,0,0}}); // tag


switch (dim)
{
Expand All @@ -221,6 +223,7 @@ int main(int argc, char **argv)
<< "gm" << gc << '-' << g << "[1:0] " << "gm" << gc << '-' << g << "[1:1] " << "gm" << gc << '-' << g << "[1:2] "
<< "gm" << gc << '-' << g << "[2:0] " << "gm" << gc << '-' << g << "[2:1] " << "gm" << gc << '-' << g << "[2:2] ";

std::cout << "tag ";
std::cout <<std::endl;

// set the values
Expand Down Expand Up @@ -256,7 +259,7 @@ int main(int argc, char **argv)

}
}
std::cout << std::endl;
std::cout << " " << output[output.size()-1] << std::endl;

}
break;
Expand All @@ -274,6 +277,7 @@ int main(int argc, char **argv)
<< "gm" << gc << '-' << g << "[1:0] " << "gm" << gc << '-' << g << "[1:1] " << "gm" << gc << '-' << g << "[1:2] "
<< "gm" << gc << '-' << g << "[2:0] " << "gm" << gc << '-' << g << "[2:1] " << "gm" << gc << '-' << g << "[2:2] ";

std::cout << "tag ";
std::cout <<std::endl;

// set the values
Expand Down Expand Up @@ -315,7 +319,7 @@ int main(int argc, char **argv)

}
}
std::cout << std::endl;
std::cout << " " << output[output.size()-1] << std::endl;

}
break;
Expand Down
Loading

0 comments on commit 180ea68

Please sign in to comment.