Add indicator field#886
Conversation
|
Currently, this is only added to the oceanic plate, so a lot of the tests will fail, because this field is required in the main function of gwb-grid. |
|
I also haven't modified the gwb-dat function yet. @MFraters, please let me know if this is the right way to move forward. I think in order to make this work, we essentially need to add this field and models to every feature. |
cde2f8a to
5db2e31
Compare
|
Following @MFraters's suggestion. I modelled this like the composition field to have a list of entry. In usage, they don't specify which component of velocity or which component of composition I am going to prescribe, but only indicate I am going to prescribe these fields in general. I would incorporate this additional information as inputs to ASPECT instead. I also decided to move the number of the entry later (i.e. 7 to 8), after Derek's PR with another new field is merged. This way, it would be easier to test the feature for now. |
alarshi
left a comment
There was a problem hiding this comment.
@lhy11009 : Thank you for the contribution! I just looked at your changes in the features folder and added my comments. I will take another look after I understand your goal more clearly. I have two comments that might help me in this process:
-
Have you tested your path with multiple indicator models? For example, if you include another indicator model in "second oceanic plate" that only defines indicator for velocity and have some overlap in the geometries of the two, are the indicators for temperature and velocity as what you would expect? I don't fully understand how the
operationworks in your case. -
Since your goal is to identify regions within your wb feature geometries that can then use some prescribed values from ASPECT, would it be possible to achieve this by assigning some nonphysical values at those locations (say, nan) and then checking for them in ASPECT ? I guess nan is not an option because that might trigger several assertions, but you get the idea. My comment is arising from not being able to fully understand how to use this property, so feel free to ignore it if it doesn't make sense.
| // The type needs to be stored in a separate value, otherwise there are memory issues | ||
| const Types::String type = Types::String("replace", std::vector<std::string> {"replace", "add", "subtract"}); | ||
|
|
||
| prm.declare_model_entries("temperature",parent_name, get_declare_map(),required_entries, | ||
| { | ||
| std::tuple<std::string,const WorldBuilder::Types::Interface &, std::string> | ||
| { | ||
| "operation", type, | ||
| "Whether the value should replace any value previously defined at this location (replace), " | ||
| "add the value to the previously define value (add) or subtract the value to the previously " | ||
| "define value (subtract)." | ||
| } | ||
| }); |
There was a problem hiding this comment.
This code block is leftover from a copy. I don't think you need the operation for what you are trying to achieve, right? I am just thinking whether there would be a scenario where you would have multiple indicator models and you would want to combine them in some way. Therefore, I would replace this with: prm.declare_model_entries("indicator",parent_name, get_declare_map(),required_entries); But, if you think otherwise, let me know.
There was a problem hiding this comment.
If I were to delete these, I would get the following error:
[lochy@lochy-shilofue1 oceanic_plate_indicator]$ /home/lochy/Softwares/WorldBuilder/build/bin/gwb-grid oceanic_plate_indicator.wb oceanic_plate_indicator.grid
Could not start the World Builder from file 'oceanic_plate_indicator.wb', error: AssertThrow value != nullptr failed in /home/lochy/Softwares/WorldBuilder/source/world_builder/parameters.cc at line 244: internal error: could not retrieve the default value at: /features/0/indicator models/0/operation/default value
Can you suggest a fix to this? I am actually not sure how this interface works and why this is called in the plate_model.cc like this:
prm.declare_entry("indicator models",
Types::PluginSystem("", Features::OceanicPlateModels::Indicator::Interface::declare_entries, {"model"}),
| operation(Operations::REPLACE) | ||
| { | ||
| this->world = world_; | ||
| this->name = "depth range"; |
There was a problem hiding this comment.
I am curious why you chose this name. I am looking similarly implemented properties, temperature and composition, which use uniform to describe what you want to do with indicator model here, and it might just preserve some uniformity ;)
There was a problem hiding this comment.
I am not opposed to the name if "uniform", but would still support "depth range". This name better describes the usage case of this. Where the prescribed condition is by "depth range".
There was a problem hiding this comment.
While I see your point @lhy11009, I agree with @alarshi, all worldbuilder features are specified within a depth range so this name does not really say what you are doing to the return field within that depth range. What the name of each .cc file represents to me, is what you set the value to WITHIN the desired depth range (i.e. a uniform value, or a linear profile, or a half space cooling profile etc.). Since it also preserves uniformity, my vote would be to change the name to uniform.
| for (unsigned int i =0; i < indicators.size(); ++i) | ||
| { | ||
| const double new_indicator = 1.0; | ||
| if (i == indicator_number) |
There was a problem hiding this comment.
I am confused how that would work if your indicator_number is 2 and size is 1, see my comment in the PR.
There was a problem hiding this comment.
Good catch! I think it should be:
indicator[i] == indicator_number
tjhei
left a comment
There was a problem hiding this comment.
I am not sure I understand what this does and how this is different than a composition. Can you explain what you are trying to achieve?
| { | ||
| class ObjectFactory; | ||
|
|
||
| class Interface |
There was a problem hiding this comment.
Documents are before the "namespace" in this part. I think this seems to be the convention of WB file as in other places.
This is to have a separate indicator field that can indicate, say, a region in ASPECT that I could prescribe the solution of temperature, velocity, and composition from the WorldBuilder. |
Here I made this new test with two plate overlapping. The first plate spans 0 - 500 km in x, while the second plate spans 300 - 1000 km in x. So the second plate should replace the first plate in the range of 300 - 500 km. And for the second plate I assigned indicator 2. And the results are listed:
|
5db2e31 to
97a0aba
Compare
| } | ||
| } | ||
| else | ||
| // else if (depth <= feature_max_depth && depth >= feature_min_depth) |
There was a problem hiding this comment.
@MFraters, I am actually surprised that this "else if" condition would behave differently from the "else" condition and doesn't give me what I want. Can you tell me why that is the case?
Here, I want to enforce zero value if it's outside of the assigned depth range but still inside the feature depth range.
There was a problem hiding this comment.
I think we'll discuss this question between us before moving further. No worry, I keep tracking a few things that I'll discuss with you.
|
@MFraters, can you take a look at this piece and some of the unresolved conversations before I duplicate it to other features? |
97a0aba to
a012b8c
Compare
|
As @MFraters recommended, I added "indicator properties" to the parameters and used names of "temperature", "velocity", and "composition" to represent entries in the wb file. @alarshi Feel free to take a second look. I really appreciate the time you guys spent. |
| /** | ||
| * A map from indicator index to its properties for quick lookups. | ||
| */ | ||
| std::map<unsigned int, Parameters::indicator_property> indicator_properties; |
There was a problem hiding this comment.
I modeled this after the composition_properties, but actually, I don't quite get it why it has to be a map object. Would it be sufficient to go with just Parameters::indicator_property.
There was a problem hiding this comment.
I originally implemented this as a map, so when users define a composition with a random index, the composition can still be mapped to the global properties table. I experimented with storing it as a vector, but supporting arbitrary indices becomes more convoluted with vectors. "composition_property" (struct) stores all compositional properties for one composition, and "composition_properties" (map) indicates the table for all compositions.
There was a problem hiding this comment.
Yeah, this makes sense to me. Thanks for the explanation. Then having your example in these other PRs is very helpful to implement the current structure.
Pull Request Test Coverage Report for Build 23773804128Details
💛 - Coveralls |
|
| template<> | ||
| std::vector<unsigned int> | ||
| Parameters::get_vector(const std::string &name, | ||
| const std::map<unsigned int, Parameters::indicator_property> &indicator_properties) |
There was a problem hiding this comment.
Related to the last question, this get_vector function is a little bit complex. I tried to model from the unmerged PR and get it to work. But I am not sure whether my implementation is good enough.
There was a problem hiding this comment.
I think we can come back to this after #926 is merged.









In the PR, I introduce a new field "indicator". In the example, an indicator field is derived from the depth of points in a feature of an oceanic plate.
@mibillen Here is how I am going to connect the prescribed solution to GWB.