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

[WIP]Add EntropyReader Class #5334

Closed
wants to merge 11 commits into from

Conversation

RanpengLi
Copy link
Contributor

I added an EntropyReader class which reads in entropy-pressure table and gets material properties for a given entropy and pressure. This part was previously done in the entropy plugin.

@gassmoeller
Copy link
Member

/rebuild

@RanpengLi RanpengLi mentioned this pull request Jul 24, 2023
1 task
@RanpengLi RanpengLi changed the title Add EntropyReader Class [WIP]Add EntropyReader Class Jul 27, 2023
Copy link
Member

@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 for now. As you told me further reviews should happen on #5341, we will continue there when you implemented the comments. Feel free to close this PR when ready.

@@ -18,7 +18,6 @@
<http://www.gnu.org/licenses/>.
*/


Copy link
Member

Choose a reason for hiding this comment

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

Keep this empty line

lateral_viscosity_prefactor_lookup = std::make_unique<internal::LateralViscosityLookup>(data_directory+lateral_viscosity_file_name,
this->get_mpi_communicator());
}


Copy link
Member

Choose a reason for hiding this comment

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

We keep 3 empty lines between functions in .cc files, and 1 empty line between them in .h files. Please add the lines here and below.

template <int dim>
bool
EntropyModel<dim>::
is_compressible () const
Copy link
Member

Choose a reason for hiding this comment

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

Keep this space.

@@ -216,17 +211,15 @@ namespace aspect
// fill seismic velocities outputs if they exist
if (SeismicAdditionalOutputs<dim> *seismic_out = out.template get_additional_output<SeismicAdditionalOutputs<dim>>())
{
seismic_out->vp[i] = material_lookup->get_data(entropy_pressure,4);
seismic_out->vs[i] = material_lookup->get_data(entropy_pressure,5);
seismic_out->vp[i] = entropy_reader-> seismic_vp(entropy, pressure);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
seismic_out->vp[i] = entropy_reader-> seismic_vp(entropy, pressure);
seismic_out->vp[i] = entropy_reader->seismic_vp(entropy, pressure);

@@ -467,7 +456,6 @@ namespace aspect
}
}


Copy link
Member

Choose a reason for hiding this comment

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

Keep this empty line.

Comment on lines +338 to +343
/**
* Gets density gradient for a given entropy and pressure
*/
Tensor<1, 2>
calc_density_gradient(const double entropy,
const double pressure) const;
Copy link
Member

Choose a reason for hiding this comment

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

The name of this function deviates from the pattern you established before. By prefixing it with calc_ it suggests that there is a more complicated operation to perform. However the operation is not much more difficult (it simply calls get_gradient instead of get_value of the StructuredDataLookup class). Therefore I would suggest you just use the same naming scheme, which would mean density_gradient would be sufficient as name.

Comment on lines +348 to +349
std::string data_directory;
std::string material_file_name;
Copy link
Member

Choose a reason for hiding this comment

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

Are these parameters actually needed outside of the initialize function? If not you dont need to make them member variables and can just use them as temporary variables inside the initialize function.

Edit: In fact it looks like you do not even set these variables to any value, so you can just delete them.

@@ -487,59 +566,58 @@ namespace aspect
* density or viscosity).
*/
template <int dim>
class PhaseFunction: public ::aspect::SimulatorAccess<dim>
class PhaseFunction : public ::aspect::SimulatorAccess<dim>
Copy link
Member

Choose a reason for hiding this comment

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

Why this space?

material_lookup->load_file(data_directory+material_file_name,
comm);
}

Copy link
Member

Choose a reason for hiding this comment

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

three empty lines here and between all other function implementations

Comment on lines +808 to +809
Point<2> entropy_pressure(entropy, pressure);
const double specific_heat = material_lookup->get_data(entropy_pressure, 3);
Copy link
Member

Choose a reason for hiding this comment

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

I know you moved this from another place, but we now have a better way to write this:

Suggested change
Point<2> entropy_pressure(entropy, pressure);
const double specific_heat = material_lookup->get_data(entropy_pressure, 3);
const double specific_heat = material_lookup->get_data({entropy,pressure}, 3);

This feature is called an initializer_list and used to create the Point implicitly, so we save a line of code (and the point is only available inside of the get_data function.
You can change this for all places below as well.

@RanpengLi RanpengLi closed this Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants