Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/aspect/material_model/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -1247,10 +1247,10 @@ namespace aspect
std::vector<double> dilation_lhs_term;

/**
* A scalar value per evaluation point corresponding to the RHS term
* A scalar value per direction per evaluation point corresponding to the RHS term
* due to plastic dilation.
*/
std::vector<double> dilation_rhs_term;
std::vector<std::vector<double>> dilation_rhs_term;
};


Expand Down
19 changes: 14 additions & 5 deletions source/material_model/interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -999,11 +999,14 @@ namespace aspect

namespace
{
std::vector<std::string> make_prescribed_dilation_outputs_names()
std::vector<std::string> make_prescribed_dilation_outputs_names(int dim)
{
std::vector<std::string> names;
names.emplace_back("dilation_lhs_term");
names.emplace_back("dilation_rhs_term");
names.emplace_back("dilation_rhs_term");
if (dim == 3)
names.emplace_back("dilation_rhs_term");
return names;
}
}
Expand All @@ -1012,24 +1015,30 @@ namespace aspect

template <int dim>
PrescribedPlasticDilation<dim>::PrescribedPlasticDilation (const unsigned int n_points)
: NamedAdditionalMaterialOutputs<dim>(make_prescribed_dilation_outputs_names()),
: NamedAdditionalMaterialOutputs<dim>(make_prescribed_dilation_outputs_names(dim)),
dilation_lhs_term(n_points, numbers::signaling_nan<double>()),
dilation_rhs_term(n_points, numbers::signaling_nan<double>())
dilation_rhs_term(dim, std::vector<double>(n_points, numbers::signaling_nan<double>()))
{}



template <int dim>
std::vector<double> PrescribedPlasticDilation<dim>::get_nth_output(const unsigned int idx) const
{
AssertIndexRange (idx, 2);
AssertIndexRange (idx, 4);
switch (idx)
{
case 0:
return dilation_lhs_term;

case 1:
return dilation_rhs_term;
return dilation_rhs_term[0];

case 2:
return dilation_rhs_term[1];

case 3:
return dilation_rhs_term[2];

default:
AssertThrow(false, ExcInternalError());
Expand Down
10 changes: 8 additions & 2 deletions source/material_model/visco_plastic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,15 @@ namespace aspect
// should cancel out (RHS = LHS * p) so as to satisfy the loading-unloading conditions.
plastic_dilation->dilation_lhs_term[i] = dilation_lhs_term;
if (dilation_rhs_term - dilation_lhs_term * in.pressure[i] > 0)
plastic_dilation->dilation_rhs_term[i] = dilation_rhs_term;
{
for (unsigned int dim_i = 0; dim_i < dim; ++dim_i)
plastic_dilation->dilation_rhs_term[dim_i][i] = dilation_rhs_term;
}
else
plastic_dilation->dilation_rhs_term[i] = dilation_lhs_term * in.pressure[i];
{
for (unsigned int dim_i = 0; dim_i < dim; ++dim_i)
plastic_dilation->dilation_rhs_term[dim_i][i] = dilation_lhs_term * in.pressure[i];
}
}
}

Expand Down
23 changes: 15 additions & 8 deletions source/simulator/assemblers/newton_stokes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -461,13 +461,17 @@ namespace aspect
// dilation term, but also the LHS dilation term should be included in the
// system residual
if (enable_prescribed_dilation)
data.local_rhs(i) += (
- pressure_scaling
* (prescribed_dilation->dilation_rhs_term[q] -
prescribed_dilation->dilation_lhs_term[q] *
scratch.material_model_inputs.pressure[q])
* scratch.phi_p[i]
) * JxW;
{
const unsigned int index_direction=fe.system_to_component_index(i).first;
if (introspection.is_stokes_component(index_direction+1))
data.local_rhs(i) += (
- pressure_scaling
* (prescribed_dilation->dilation_rhs_term[index_direction][q] -
prescribed_dilation->dilation_lhs_term[q] *
scratch.material_model_inputs.pressure[q])
* scratch.phi_p[i]
) * JxW;
}
}

// and then the matrix, if necessary
Expand Down Expand Up @@ -665,7 +669,10 @@ namespace aspect
Assert(!this->get_parameters().enable_prescribed_dilation
||
(outputs.template get_additional_output_object<MaterialModel::PrescribedPlasticDilation<dim>>()->dilation_lhs_term.size() == n_points &&
outputs.template get_additional_output_object<MaterialModel::PrescribedPlasticDilation<dim>>()->dilation_rhs_term.size() == n_points),
outputs.template get_additional_output_object<MaterialModel::PrescribedPlasticDilation<dim>>()->dilation_rhs_term.size() == dim &&
outputs.template get_additional_output_object<MaterialModel::PrescribedPlasticDilation<dim>>()->dilation_rhs_term[0].size() == n_points &&
outputs.template get_additional_output_object<MaterialModel::PrescribedPlasticDilation<dim>>()->dilation_rhs_term[1].size() == n_points &&
(dim == 2 || (dim == 3 && outputs.template get_additional_output_object<MaterialModel::PrescribedPlasticDilation<dim>>()->dilation_rhs_term[2].size() == n_points))),
ExcInternalError());

if (this->get_newton_handler().parameters.newton_derivative_scaling_factor != 0)
Expand Down
24 changes: 18 additions & 6 deletions source/simulator/assemblers/stokes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,20 @@ namespace aspect
* JxW;

if (prescribed_dilation != nullptr)
data.local_rhs(i) += (
- pressure_scaling
* prescribed_dilation->dilation_rhs_term[q]
* scratch.phi_p[i]
) * JxW;
{
const unsigned int index_direction=fe.system_to_component_index(i).first;
// Only want the velocity components and not the pressure one (which is the last one), so add 1
if (introspection.is_stokes_component(index_direction+1))
{
data.local_rhs(i) += (
- pressure_scaling
* (prescribed_dilation->dilation_rhs_term[index_direction][q] -
prescribed_dilation->dilation_lhs_term[q] *
scratch.material_model_inputs.pressure[q])
* scratch.phi_p[i]
) * JxW;
}
}

if (scratch.rebuild_stokes_matrix)
for (unsigned int j=0; j<stokes_dofs_per_cell; ++j)
Expand Down Expand Up @@ -531,7 +540,10 @@ namespace aspect
Assert(!this->get_parameters().enable_prescribed_dilation
||
(outputs.template get_additional_output_object<MaterialModel::PrescribedPlasticDilation<dim>>()->dilation_lhs_term.size() == n_points &&
outputs.template get_additional_output_object<MaterialModel::PrescribedPlasticDilation<dim>>()->dilation_rhs_term.size() == n_points),
outputs.template get_additional_output_object<MaterialModel::PrescribedPlasticDilation<dim>>()->dilation_rhs_term.size() == dim &&
outputs.template get_additional_output_object<MaterialModel::PrescribedPlasticDilation<dim>>()->dilation_rhs_term[0].size() == n_points &&
outputs.template get_additional_output_object<MaterialModel::PrescribedPlasticDilation<dim>>()->dilation_rhs_term[1].size() == n_points &&
(dim == 2 || (dim == 3 && outputs.template get_additional_output_object<MaterialModel::PrescribedPlasticDilation<dim>>()->dilation_rhs_term[2].size() == n_points))),
ExcInternalError());

// Elasticity:
Expand Down
7 changes: 5 additions & 2 deletions tests/prescribed_dilation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,11 @@ namespace aspect
}
if (prescribed_dilation)
{
prescribed_dilation->dilation_rhs_term[i] = x;
prescribed_dilation->dilation_lhs_term[i] = 0.;
prescribed_dilation->dilation_rhs_term[0][i] = x;
prescribed_dilation->dilation_rhs_term[1][i] = x;
if (dim == 3)
prescribed_dilation->dilation_rhs_term[2][i] = x;
prescribed_dilation->dilation_lhs_term[i] = 0;
}

}
Expand Down
Loading