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
New melt solver rebase #2138
New melt solver rebase #2138
Conversation
not part of pull request (yet) [temp prm file for testing] add missing flag melt 3.0, constraints and everything add test files add comment add kd1 files iteration numbers and indent enable force vector in examples switch to CG for S, hack around other bugs add simple testcase add rising_melt_blob melt_solver/ files fix and cleanup compute_initial_pressure_field() add a postprocessor for the volumetric strain rate output p_c_bar, constant k_d with cutoff, DG p_c update:is_melt_cell - output darcy coefficient and is_melt_cell - split is_melt_cell decision - growing of layer (disabled) add tests, many not working clean up and fix melt advection add average density as fluid boundary pressure
228471e
to
2b2ac56
Compare
6775a48
to
027a018
Compare
33837fc
to
a1865a3
Compare
@tjhei, do you know what's going on with the tester? It seems like it doesn't run tests any more... |
a1865a3
to
863839d
Compare
Okay, I have checked that all the tests are still working and the output makes sense (it seems the tester is currently not working, but @gassmoeller has set up a tester locally on his machine so that I could update the test output), so it would be great if someone could have a look now! Although the pull request changes many files, most of them are just tests (and because we now use a new type of solver for the melt transport problem, all melt tests have changed). The main advantages are that this pull request should make the solver for melt models much faster (in some cases it reduces the iteration count by an order of magnitude), in particular in cases with low or zero porosity in a part of the domain. So that would be a big step forward. There are a number of things that are not clear to me and that we should discuss:
|
82c1b6b
to
2b3aa5e
Compare
2b3aa5e
to
069c31b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First set of comments
include/aspect/compat.h
Outdated
@@ -59,8 +59,9 @@ namespace aspect | |||
{ | |||
dealii::SolverControl::State return_value = dealii::SolverControl::check(step, check_value); | |||
|
|||
if (step == 0) | |||
history_data.resize(history_data.size()+1); | |||
if (history_data_enabled) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please try removing this and see if tests fail
include/aspect/melt.h
Outdated
double p_c_scale (const MaterialModel::MaterialModelInputs<dim> &inputs, | ||
const MaterialModel::MaterialModelOutputs<dim> &outputs, | ||
const MeltHandler<dim> &handler, | ||
bool consider_is_melt_cell) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const
include/aspect/melt.h
Outdated
* The last input argument consider_is_melt_cell determines if | ||
* this computation takes into account if a cell is a "melt cell" | ||
* (cells where we solve the melt transport equations, as | ||
* indicated by the entries stored in the is_melt_cell vector of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rewrite in shorter sentences what happens if consider_is_melt_cell
is true or false.
include/aspect/melt.h
Outdated
|
||
/** | ||
* Given the Darcy coefficient as computed by the material model, limit the | ||
* coefficient to a minimum value based on the reference Darcy coefficient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... to a minimum value (1e-3 times the reference Darcy coefficient) in melt cells. If @p is_melt_cell
is false it returns zero.
/** | ||
* Whether to use a discontinuous element for the compaction pressure or not. | ||
*/ | ||
bool use_discontinuous_p_c; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make private
source/simulator/melt.cc
Outdated
: | ||
0.0); | ||
|
||
const double K_D = this->get_melt_handler().limited_darcy_coefficient(melt_outputs->permeabilities[q] / melt_outputs->fluid_viscosities[q], p_c_scale > 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Break line
source/simulator/melt.cc
Outdated
@@ -483,8 +535,9 @@ namespace aspect | |||
const FEValuesExtractors::Scalar ex_p_f = introspection.variable("fluid pressure").extractor_scalar(); | |||
const unsigned int p_f_component_index = introspection.variable("fluid pressure").first_component_index; | |||
const unsigned int p_c_component_index = introspection.variable("compaction pressure").first_component_index; | |||
const double p_c_scale = dynamic_cast<const MaterialModel::MeltInterface<dim>*>(&this->get_material_model())->p_c_scale(scratch.material_model_inputs, scratch.material_model_outputs, this->get_melt_handler(), true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
source/simulator/melt.cc
Outdated
melt_outputs->permeabilities[q] / melt_outputs->fluid_viscosities[q] | ||
: | ||
0.0); | ||
const double K_D = this->get_melt_handler().limited_darcy_coefficient(melt_outputs->permeabilities[q] / melt_outputs->fluid_viscosities[q], p_c_scale > 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
source/simulator/melt.cc
Outdated
this->get_material_model().evaluate(in, out); | ||
|
||
const double p_c_scale = dynamic_cast<const MaterialModel::MeltInterface<dim>*>(&this->get_material_model())->p_c_scale(in,out,this->get_melt_handler(), true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
break line
@@ -1180,7 +1265,12 @@ namespace aspect | |||
FEValues<dim> fe_values (this->get_mapping(), | |||
this->get_fe(), | |||
quadrature, | |||
update_quadrature_points | update_values); | |||
update_quadrature_points | update_gradients | update_values); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check if you can remove the gradients and change compute_material_model_input_values
argument to false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can set use_strain_rate to false, but we still need the gradients (as the material model inputs always compute the pressure gradients).
Oh, and I changed the compute_material_model_input_values
to material_model_inputs.reinit
, as this is our new way to write this, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok then do that.
Yes I think it is.
We discussed the mentioned questions with @jdannberg and @naliboff and came to the following conclusions:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the large number of comments I would like to take another look after you addressed them. Please keep your updates in a separate commit.
source/simulator/melt.cc
Outdated
@@ -1211,8 +1310,8 @@ namespace aspect | |||
const double phi = std::max(0.0, porosity_values[j]); | |||
|
|||
double p = p_f_values[j]; | |||
if (phi < 1.0-this->get_melt_handler().melt_transport_threshold) | |||
p = (p_c_values[j] - (phi-1.0) * p_f_values[j]) / (1.0-phi); | |||
if (p_c_scale > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should also prevent division by zero in the next line
source/simulator/melt.cc
Outdated
namespace | ||
{ | ||
template <int dim> | ||
struct PcAssembleData |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to find a more expressive name, e.g. PcConstraintAssembleData
and add a comment, e.g. This is a scratch object for the assembly of the Pc constraints outside of the melt region.
source/simulator/melt.cc
Outdated
material_model_inputs(scratch.material_model_inputs), | ||
material_model_outputs(scratch.material_model_outputs) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove empty line
source/simulator/melt.cc
Outdated
template <int dim> | ||
struct PcAssembleData | ||
{ | ||
PcAssembleData (const FiniteElement<dim> &finite_element, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// standard constructor
source/simulator/melt.cc
Outdated
{} | ||
|
||
|
||
PcAssembleData (const PcAssembleData &scratch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Copy constructor
source/simulator/parameters.cc
Outdated
@@ -1287,8 +1287,7 @@ namespace aspect | |||
&& !use_discontinuous_composition_discretization, | |||
ExcMessage ("Using discontinuous elements for temperature " | |||
"or composition in models with melt transport is currently not implemented.")); | |||
// We can not have a DG p_f. While it would be possible to use a | |||
// discontinuous p_c, this is not tested, so we disable it for now. | |||
// We can not have a DG p_f. | |||
AssertThrow(!use_locally_conservative_discretization, | |||
ExcMessage ("Discontinuous elements for the pressure " | |||
"in models with melt transport are not supported")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add dot at end of sentence
source/simulator/solver.cc
Outdated
@@ -280,10 +280,10 @@ namespace aspect | |||
// first solve with the bottom left block, which we have built | |||
// as a mass matrix with the inverse of the viscosity | |||
{ | |||
SolverControl solver_control(1000, src.block(1).l2_norm() * S_block_tolerance); | |||
aspect::SolverControl solver_control(1000, src.block(1).l2_norm() * S_block_tolerance); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you need this? should be fixed on master already
source/simulator/solver.cc
Outdated
|
||
#ifdef ASPECT_USE_PETSC | ||
SolverCG<LinearAlgebra::Vector> solver(solver_control); | ||
SolverGMRES<LinearAlgebra::Vector> solver(solver_control); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert this to CG as before
source/simulator/solver.cc
Outdated
@@ -835,6 +836,7 @@ namespace aspect | |||
{ | |||
// output solver history | |||
std::ofstream f((parameters.output_directory+"solver_history.txt").c_str()); | |||
f << std::setprecision(16); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave that out
tests/rising_melt_blob.prm
Outdated
# simple model, but with a different melting rate. | ||
|
||
# The melting rate has the form of a Gaussian function | ||
# and every timestep a fixed amount of material is melting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update description
source/simulator/melt.cc
Outdated
|
||
|
||
void | ||
local_assemble (const typename DoFHandler<dim>::active_cell_iterator &cell, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that I am looking over this, should I also give this a different name (something like local_save_nonzero_pc_dofs
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, sounds good
e984d99
to
399fb84
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only functional change I found was in the preconditioner. Not sure that is the reason, but give it a try, since it was correct before and is wrong now.
source/simulator/melt.cc
Outdated
pressure_scaling) | ||
* scratch.phi_p_c[i] * scratch.phi_p[j] | ||
) | ||
* JxW; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above lines might be the cause for the test changes. Previously you always added these line (if(true)
, although that condition is unnecessary), now you only add them if the condition above is true (component_index == component_index). Revert to the old state, but remove the if(true)
. Its only the preconditioner though, not sure this is the only reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see, I'll try it. Thanks!
MeltHandler(ParameterHandler &prm); | ||
|
||
template <int dim> | ||
struct Parameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This struct should only contain the input or other parameters for MeltHandler, not internal variables. In particular boundary_fluid_pressure
, is_melt_cell_vector
, and current_constraints
should be private member variables of the class and not in this struct. If you need them outside, make get_
functions for them.
source/simulator/melt.cc
Outdated
"should probably be set to 'false'."); | ||
prm.enter_subsection ("Melt settings"); | ||
{ | ||
prm.declare_entry ("Darcy coefficient variation threshold", "1e-3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not like the variation
a lot. What about Relative Darcy coefficient threshold
? Variation sounds like you are measuring the spatial derivatives of darcy coefficients.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like it's not really clear what a relative threshold should be, so that name feels a bit weird to me. I thought one other way to express this would be to say, how much is K_D allowed to vary (or deviate) from the reference value? I could call it "Global Darcy coefficient variation threshold" to make clear it doesn't have anything to do with derivatives.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I am not really happy with that either. Lets discuss it later today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked for parameters with a similar meaning in the code, and the closest thing I could find was something like the "Maximum lateral viscosity variation" in the Steinberger material model. But sure, let's discuss this later.
source/simulator/melt.cc
Outdated
{ | ||
prm.enter_subsection ("Melt settings"); | ||
{ | ||
K_D_variation_threshold = prm.get_double("Darcy coefficient variation threshold"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
relative_K_D_threshold
?
source/simulator/parameters.cc
Outdated
"or composition in models with melt transport is currently not implemented.")); | ||
// We can not have a DG p_f. | ||
AssertThrow(!use_locally_conservative_discretization, | ||
ExcMessage ("Discontinuous elements for the pressure " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this part 😄, less melt code in the general code.
@@ -110,10 +110,6 @@ subsection Model settings | |||
set Include melt transport = true | |||
end | |||
|
|||
subsection Melt settings | |||
set Melt transport threshold = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be what is causing the changes? Or was the melt transport threshold not used before as well?
cd89ec5
to
291e56f
Compare
291e56f
to
3aa6ca3
Compare
I think I have addressed all of your comments. Can you have another look? |
4d97497
to
45849cf
Compare
Thanks for working through the multiple reviews. I think if we missed anything, we need to address it as a fix later. Melt 2.0 done, 🎉 |
yay -- good work y'all! |
Supersedes #1600. For now, I mainly want to see which tests fail.