Version 2 of Case Generate#3
Conversation
Reflect new project structure
Exclude logs from git
Updated the schema to reflect new topology, which is more accessible
A custom logger
A class to read and validate the topology
A class to create the precice configuration file based on config-graph nodes
A class to create nodes based on a topology file
Helper functions and values for the node creator
Updated the main to reflect the project structure and functionality
Moved displacement to "extensive-data"
They contain the precice beginner tutorials and a more complex multi coupling
Removed old TODOs
Rearranged entries and added some explanations
Make logs folder hidden on unix
Make `create_config_str()` "private"
Create a new class for patches
Create patch nodes and naming improvements
Create a class for creating adapter configurations
update the main method to include adapter config generation
Updated description to reflect double usage of the method
A schema for the adapter-config.json files.
Validate created adapter configs against the schema
Updated name to "_validate..." to reflect changes in adapter config creator
Changed imports
Add a new helper function for solver i.e. participant directories
Use new helper function
They were adopted from the previous version
Created a new class for creating the utility files. The readme is somewhat inspired by the old version, but contains less words and more information :)
Includes the checking if the exchanges are unique up to patches, as suggested by @uekerman
it now uses textwrap and is cleaner.
fsimonis
left a comment
There was a problem hiding this comment.
The examples currently include the output in the _generated folder, so they will be overwritten when calling the script.
I suggest to either remove them or rename them to _reference or _expected if you plan to use them in tests.
| return parser.parse_args() | ||
|
|
||
|
|
||
| def validate_args(args: argparse.Namespace) -> int: |
There was a problem hiding this comment.
You can set the type argument of argparse.add_argument to a callable. In this callable, you can run your custom error checking.
https://docs.python.org/3/library/argparse.html#type
This keeps the error including formatting inside the argparser framework.
There was a problem hiding this comment.
Not sure why you marked this as resolved.
reordered uniquifier names 😵💫
Switch to 'colored' package instead of manually setting color
add colored as a dependency
Incorporate new config-graph functionality
They now use the correct output path.
Test to ensure correct parsing of scientific notation
The schema is now imported through the "precice-adapter-config" dependency
Fixed a typo
|
|
||
| def main() -> int: | ||
| # Parse the command line arguments | ||
| parser = cli_helper.makeGenerateParser() |
There was a problem hiding this comment.
The makeGenerateParser needs to be visible in this file.
I think you could simply reexport it using from cli_helper import makeGenerateParser.
This line needs to work when you release the new version:
https://github.com/precice/cli/blob/8361729197b0e2d7abc86755e02e04045e2bda4a/precicecli/cli.py#L21
| type=Path, | ||
| nargs="?", | ||
| help="Path to the input YAML topology file.", | ||
| default=Path.cwd() / "topology.yaml" |
There was a problem hiding this comment.
Equivalent to the shorter:
| default=Path.cwd() / "topology.yaml" | |
| default=Path("topology.yaml") |
Same applies to the output path
fsimonis
left a comment
There was a problem hiding this comment.
IMHO the only thing blocking this PR from my perspective is the compatibility with the preicice-cli.
Changes
This changes everything
🤯🤩The biggest overarching change is the inclusion of preCICE Config Graph as a dependency and a change to the topology schema.
Process flow
precice-config.xmlfileadapter-config.jsonbased on the nodesChanges to the topology
The topology only takes the two arguments (or "main" elements)
participantsandexchanges. A detailed overview over the topology can be found inprecicecasegenerate/schemas/README.md.The elements
coupling-schemeandaccelerationwere removed to reduce complexity.Preprocessing
Preprocessing includes checking if the topology is valid. The following checks are executed:
These checks are necessary to guarantee a valid topology and adapter-configs.
Changes to the generating process
Well, it was redesigned from the ground up.
I tried to make everything as modular as possible, so that single functions can be modified without influencing others.
The main logic now relies on the preCICE Config Graph and its nodes. These nodes are created in the following sequence:
The patches names might be altered and this step MUST be executed before data nodes are initialized.
These include: A --Color (scalar)-> B and A --Color (vector) -> B, which needs to be resolved into two data nodes, "Color-Vector" and "Color-Scalar".
Another possibility is A --Color-> B and B --Color-> A, which means that one of the "Color"'s needs to be changed to something unique, like "Pretty-Color". This is why, during preprocessing, it is checked whether any data name contains such a special "uniquifier".
A full list of these uniquifiers, intensive and extensive data, as well as data->data-type map can be found in
precicecasegenerate/cli_helper.pyIf participants with different dimensionalities try to exchange data, the dimension of the mesh with lower dimensionality is increased.
Extensive data leads to a write-conservative mapping, intensive data leads to a read-consistent mapping.
However, since no coupling-scheme configuration is given, any coupling-scheme must be inferred from them. Since "strong" exchanges do no necessarily lead to implicit coupling schemes, only a list of "potential couplings" is created.
First, the list of "potential couplings" is scanned to find bidirectional strong couplings. If any exist, an implicit-, or multi-coupling-scheme, is created.
Next, explicit coupling-scheme are created based on the remaining "potential couplings"
As mentioned above, each of these steps can be modified without influencing the other steps, as long as necessary return values remain in their original format.
The code for this can be found in
precicecasegenereate/node_creator.py.New features
At least I was not aware of them before:
Changes to utility files
The
README.mdtemplate has been reworked slightly, as well as theclean.shfile.Changes to tests
Tests now include validating topologies against predefined ones with the config-graph's new
check_config_equivalence()function as well as running the config-checker.