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

New melt solver rebase #2138

Merged
merged 17 commits into from Apr 7, 2018

Conversation

jdannberg
Copy link
Contributor

Supersedes #1600. For now, I mainly want to see which tests fail.

rrgrove6 and others added 11 commits March 22, 2018 15:11
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
@jdannberg jdannberg force-pushed the new-melt-solver-rebase branch 5 times, most recently from 6775a48 to 027a018 Compare March 24, 2018 05:37
@jdannberg jdannberg force-pushed the new-melt-solver-rebase branch 3 times, most recently from 33837fc to a1865a3 Compare March 27, 2018 05:09
@jdannberg
Copy link
Contributor Author

@tjhei, do you know what's going on with the tester? It seems like it doesn't run tests any more...

@jdannberg
Copy link
Contributor Author

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:

  1. Boundary terms: @tjhei wondered if we have to add special boundary terms between the regions with melt and without melt, but I've tried to do this and the results just didn't make sense any more (and without these terms, all tests I've done looked good to me)
  2. We have implemented the cutoff between melt cells/cells without melt as a fixed number with respect to the reference permeability, and it basically replaces the parameter "Melt transport threshold" we used before. Do we want to keep it like this (and just remove the Melt transport threshold from all input files, as it is not used anymore), or do we instead want to reuse the melt transport threshold somehow and try to make the cutoff an input parameter?
  3. How do we want to compute the nonlinear residual? We introduced a new scaled pressure (p_c_bar), which is now stored in the block of the solution vector where the compaction pressure was before. So we will use p_c_bar to compute the nonlinear residual. Is that what we want? Or is there a good way to use the real compaction pressure instead?

@jdannberg jdannberg force-pushed the new-melt-solver-rebase branch 2 times, most recently from 82c1b6b to 2b3aa5e Compare March 29, 2018 03:28
@jdannberg jdannberg changed the title [WIP] New melt solver rebase New melt solver rebase Mar 29, 2018
@jdannberg jdannberg added this to the 2.0 milestone Mar 29, 2018
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.

First set of comments

@@ -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)
Copy link
Member

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

double p_c_scale (const MaterialModel::MaterialModelInputs<dim> &inputs,
const MaterialModel::MaterialModelOutputs<dim> &outputs,
const MeltHandler<dim> &handler,
bool consider_is_melt_cell) const;
Copy link
Member

Choose a reason for hiding this comment

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

const

* 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
Copy link
Member

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.


/**
* Given the Darcy coefficient as computed by the material model, limit the
* coefficient to a minimum value based on the reference Darcy coefficient
Copy link
Member

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;
Copy link
Member

Choose a reason for hiding this comment

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

make private

:
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);
Copy link
Member

Choose a reason for hiding this comment

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

Break line

@@ -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);
Copy link
Member

Choose a reason for hiding this comment

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

same here

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);
Copy link
Member

Choose a reason for hiding this comment

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

same

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);
Copy link
Member

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);
Copy link
Member

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

Copy link
Contributor Author

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?

Copy link
Member

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.

@gassmoeller
Copy link
Member

We discussed the mentioned questions with @jdannberg and @naliboff and came to the following conclusions:

  1. Since the benchmarks work without the flux terms, and do not with them (maybe wrong terms?) we go ahead without the terms for now. If we need them we can always add them later.

  2. We will remove the outdated parameter and introduce a more appropriate one, something like 'Relative permeability threshold'.

  3. Since the scaling factor remains the same during nonlinear iterations (although it is different per cell) it might make no difference which one to use. Lets stick with the simple assumption that it is sufficient to use the nonlinear residual of the variable we actually have in the equation (pcbar) unless we have evidence we would need to do something else.

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.

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.

@@ -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)
Copy link
Member

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

namespace
{
template <int dim>
struct PcAssembleData
Copy link
Member

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.

material_model_inputs(scratch.material_model_inputs),
material_model_outputs(scratch.material_model_outputs)
{

Copy link
Member

Choose a reason for hiding this comment

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

remove empty line

template <int dim>
struct PcAssembleData
{
PcAssembleData (const FiniteElement<dim> &finite_element,
Copy link
Member

Choose a reason for hiding this comment

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

// standard constructor

{}


PcAssembleData (const PcAssembleData &scratch)
Copy link
Member

Choose a reason for hiding this comment

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

// Copy constructor

@@ -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"));
Copy link
Member

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

@@ -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);
Copy link
Member

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


#ifdef ASPECT_USE_PETSC
SolverCG<LinearAlgebra::Vector> solver(solver_control);
SolverGMRES<LinearAlgebra::Vector> solver(solver_control);
Copy link
Member

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

@@ -835,6 +836,7 @@ namespace aspect
{
// output solver history
std::ofstream f((parameters.output_directory+"solver_history.txt").c_str());
f << std::setprecision(16);
Copy link
Member

Choose a reason for hiding this comment

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

Leave that out

# 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.
Copy link
Member

Choose a reason for hiding this comment

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

Update description



void
local_assemble (const typename DoFHandler<dim>::active_cell_iterator &cell,
Copy link
Contributor Author

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)?

Copy link
Member

Choose a reason for hiding this comment

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

sure, sounds good

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.

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.

pressure_scaling)
* scratch.phi_p_c[i] * scratch.phi_p[j]
)
* JxW;
Copy link
Member

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.

Copy link
Contributor Author

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
Copy link
Member

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.

"should probably be set to 'false'.");
prm.enter_subsection ("Melt settings");
{
prm.declare_entry ("Darcy coefficient variation threshold", "1e-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 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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

{
prm.enter_subsection ("Melt settings");
{
K_D_variation_threshold = prm.get_double("Darcy coefficient variation threshold");
Copy link
Member

Choose a reason for hiding this comment

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

relative_K_D_threshold?

"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 "
Copy link
Member

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
Copy link
Member

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?

@jdannberg jdannberg force-pushed the new-melt-solver-rebase branch 2 times, most recently from cd89ec5 to 291e56f Compare April 5, 2018 22:09
@jdannberg
Copy link
Contributor Author

I think I have addressed all of your comments. Can you have another look?

@jdannberg jdannberg mentioned this pull request Apr 6, 2018
@gassmoeller
Copy link
Member

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, 🎉

@gassmoeller gassmoeller merged commit 014b29d into geodynamics:master Apr 7, 2018
@bangerth
Copy link
Contributor

bangerth commented Apr 7, 2018

yay -- good work y'all!

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.

None yet

5 participants