Skip to content

Commit

Permalink
Add developer documentation for astyle
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldouglas92 committed Feb 13, 2024
1 parent 40655ff commit bcbd688
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Astyle
=====

```{todo}
Explain what Astyle does, why it is important and how to get the right version.
```
Astyle (Artistic Style) is a tool that automates the formatting of code. Executing astyle will automatically indent new code to the standard that the Geodynamic WorldBuilder uses, and should be done before each pull request to ensure that the indenter tests do not fail.

GWB requires the use of astyle v2.04, which can be downloaded from sourceforge [here](https://sourceforge.net/projects/astyle/files/astyle/astyle%202.04/) for mac, linux or windows.

After the download is complete, simply unzip the files in your desired directory, and compile the astyle executible. To do this, run `make` in the $ASTYLE_DIR/build/$COMPILER. Here $ASTYLE_DIR is the path to the unzipped astyle directory, and $COMPILER is the directory within $ASTYLE_DIR/build/ that corresponds to the compiler you will use to generate astyle. This should generate the astyle executible in $ASTYLE_DIR/build/$COMPILER/bin/. For the GWB to see this executible, you now need to add this to your $PATH. For mac, open your `~/.bash_profile` and add the following line:

`export PATH=$ASTYLE_DIR/build/$COMPILER/bin/:$PATH`

Now, if you navigate to $WORLDBUILDER_SOURCE_DIR/build and run `make indent`, astyle will run and automatically format all files within $WORLDBUILDER_SOURCE_DIR.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ namespace WorldBuilder
"in degree Kelvin for this feature. If the model has an adiabatic gradient"
"this should be the mantle potential temperature, and T = Tad + Thalf. ");

prm.declare_entry("spreading velocity", Types::Double(-1),
prm.declare_entry("spreading velocity", Types::Array(Types::Array(Types::Double(-1))),
"The spreading velocity of the plate in meter per year. "
"This is the velocity with which one side moves away from the ridge.");

Expand All @@ -106,7 +106,7 @@ namespace WorldBuilder
operation = string_operations_to_enum(prm.get<std::string>("operation"));
top_temperature = prm.get<double>("top temperature");
bottom_temperature = prm.get<double>("bottom temperature");
spreading_velocity = prm.get<double>("spreading velocity")/31557600; // m/seconds
spreading_velocity = prm.get_vector<std::vector<double>>("spreading velocity")/31557600; // m/seconds

mid_oceanic_ridges = prm.get_vector<std::vector<Point<2>>>("ridge coordinates");
const double dtr = prm.coordinate_system->natural_coordinate_system() == spherical ? Consts::PI / 180.0 : 1.0;
Expand Down Expand Up @@ -252,6 +252,10 @@ namespace WorldBuilder
}
}

// I think I really just need to implement spreading_velocity as an array, which would
// effectively make age, and then temperature an array? Which in order to avoid changing how the temperature
// is used in all other functions, maybe it would be better to output temperature at each point in a loop over all
// points?
const double thermal_diffusivity = this->world->thermal_diffusivity;
const double age = distance_ridge / spreading_velocity;

Expand Down Expand Up @@ -285,4 +289,3 @@ namespace WorldBuilder
} // namespace OceanicPlateModels
} // namespace Features
} // namespace WorldBuilder

0 comments on commit bcbd688

Please sign in to comment.