Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interface for topography models. #814

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Djneu
Copy link
Contributor

@Djneu Djneu commented Jan 23, 2025

Here is adding the interface for having topography models and defining them in the .wb file. So far the model is named uniform, though I think this will be changed later on to something better fitted to the lowest feature topography model.

Next steps would be:

  1. Make a function that allows world.cc to return the surface type when called from an outer program.
  2. Combine uniform.cc with an actual topography model.

Copy link
Member

@MFraters MFraters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am on two minds about the naming of the class. Originally I thought just naming it none, to indicate that there is no topography. But uniform, with a default of zero would also work. Opinions?

include/world_builder/parameters.h Show resolved Hide resolved
include/world_builder/parameters.h Outdated Show resolved Hide resolved
include/world_builder/topography/uniform.h Outdated Show resolved Hide resolved
Copy link
Contributor

@gassmoeller gassmoeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the structure looks correct to me, but I have a number of suggestions for naming and you will have to update a bunch of comments.

include/world_builder/parameters.h Show resolved Hide resolved
include/world_builder/parameters.h Outdated Show resolved Hide resolved
include/world_builder/topography/interface.h Outdated Show resolved Hide resolved
include/world_builder/topography/interface.h Outdated Show resolved Hide resolved
include/world_builder/topography/interface.h Outdated Show resolved Hide resolved
Comment on lines 75 to 79

/**
* Whether to consider a reference or deformed surface.
*/
const std::string surface_type = "reference_surface";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while a string is flexible, it is also quite expensive to use. In addition it could contain arbitrary new values. I would suggest to introduce an enum type in the public part of this class (or even outside the class, but inside the Topography namespace. Something like:

  enum SurfaceType
  {
    reference_surface,
    deformed_surface};

This also guarantees that only these two values can be used.

include/world_builder/topography/uniform.h Outdated Show resolved Hide resolved
include/world_builder/topography/interface.h Outdated Show resolved Hide resolved
include/world_builder/topography/interface.h Outdated Show resolved Hide resolved
Comment on lines 43 to 45
"Uniform gravity model. It returns the gravity vector in a Cartesian coordinate system at "
"a given position, which has a constant magitude for the whole domain. The vector points "
"down in cartesian coordinates and to the center of the sphere in spherical coordinates.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nothing is parsed below so nothing needs to be declared here either?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the declaration.

@Djneu
Copy link
Contributor Author

Djneu commented Jan 23, 2025

Hi both, I think I've addressed all the previous comments. Next I think I'll need to add a case 7 to world.cc and make sure calling get_topography will return 0 and that I can also return the correct surface type with the get_surface_type function.

Djneu added 2 commits January 23, 2025 17:10
Apply suggestions from code review

Co-authored-by: Rene Gassmoeller <rene.gassmoeller@mailbox.org>

Address comments.

minor changes
Comment on lines +284 to +286
* A pointers to the topography model. This variable is responsible for
* the topography model and has ownership over it. Therefore a unique
* pointer are used.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a random comment as I'm looking at PRs to see what everyone has been working on :)

Suggested change
* A pointers to the topography model. This variable is responsible for
* the topography model and has ownership over it. Therefore a unique
* pointer are used.
* A pointer to the topography model. This variable is responsible for
* the topography model and has ownership over it. Therefore a unique
* pointer is used.

SurfaceType surface_type;

/**
* declare and read in the world builder file into the parameters class
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment doesn't seem right?

get_surface_type() = 0;

/**
* Returns a temperature based on the given position, depth in the model,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Returns a temperature based on the given position, depth in the model,
* Returns a topography based on the given position, depth in the model,

Comment on lines +52 to +63
* declare and read in the world builder file into the topography class
*/
static
void declare_entries(Parameters &prm, const std::string &parent_name = "");

/**
* declare and read in the world builder file into the topography class
*/
void parse_entries(Parameters &prm) override final;

/**
* declare and read in the world builder file into the topography class
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These comments are all the same, which makes them less informative. Maybe make them more specific to the functions?

Copy link
Contributor

@gassmoeller gassmoeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some comments from my previous review are not addressed yet. but generally closer to being ready.

namespace Topography
{
class Interface;
} // namespace GravityModel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Topography

@@ -275,6 +280,14 @@ namespace WorldBuilder
*/
std::unique_ptr<WorldBuilder::GravityModel::Interface> gravity_model;

/**
* A pointers to the topography model. This variable is responsible for
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pointers -> pointer

/**
* A pointers to the topography model. This variable is responsible for
* the topography model and has ownership over it. Therefore a unique
* pointer are used.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* pointer are used.
* pointer is used.

* A pointers to the topography model. This variable is responsible for
* the topography model and has ownership over it. Therefore a unique
* pointer are used.
* @see CoordinateSystem
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are you referring to here?

deformed_surface
};

SurfaceType surface_type;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this variable private. The enum type needs to be public, so that calling functions know that this type exists. But the variable itself (surface_type) should still be private as before so that no one accidentally changes this variable and all access has to go through get_surface_type.

Also add documentation what this variable means.

{
/**
* This implements a minimum depth topography. The minimum depth topography
* finds the minimum depth of a feature and uses that for the topography.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* finds the minimum depth of a feature and uses that for the topography.
* finds the minimum depth of all active features at a location and uses that depth as the topography.

Comment on lines -535 to 549


WorldBuilder::grains
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you delete these lines?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants