@@ -461,13 +461,34 @@ namespace aspect
461461 // dilation term, but also the LHS dilation term should be included in the
462462 // system residual
463463 if (enable_prescribed_dilation)
464- data.local_rhs (i) += (
465- - pressure_scaling
466- * (prescribed_dilation->dilation_rhs_term [q] -
467- prescribed_dilation->dilation_lhs_term [q] *
468- scratch.material_model_inputs .pressure [q])
469- * scratch.phi_p [i]
470- ) * JxW;
464+ {
465+ const unsigned int index_direction=fe.system_to_component_index (i).first ;
466+ // Only want the velocity components and not the pressure one (which is the last one), so add 1
467+ if (introspection.is_stokes_component (index_direction+1 ))
468+ data.local_rhs (i) += (
469+ // RHS of - (div u,q) = - (R,q)
470+ - pressure_scaling
471+ * (prescribed_dilation->dilation_rhs_term [index_direction][q] -
472+ prescribed_dilation->dilation_lhs_term [q] *
473+ scrasch.material_model_inputs .pressure [q])
474+ * scratch.phi_p [i]
475+ ) * JxW;
476+ }
477+
478+ // Only assemble this term if we are running incompressible, otherwise this term
479+ // is already included on the LHS of the equation.
480+ if (enable_prescribed_dilation && !material_model_is_compressible)
481+ {
482+ const unsigned int index_direction=fe.system_to_component_index (i).first ;
483+ // Only want the velocity components and not the pressure one (which is the last one), so add 1
484+ if (introspection.is_stokes_component (index_direction+1 ))
485+ data.local_rhs (i) += (
486+ // RHS of momentum eqn: - \int 2/3 eta R, div v
487+ - 2.0 / 3.0 * eta
488+ * prescribed_dilation->dilation_rhs_term [index_direction][q]
489+ * scratch.div_phi_u [i]
490+ ) * JxW;
491+ }
471492 }
472493
473494 // and then the matrix, if necessary
@@ -665,7 +686,10 @@ namespace aspect
665686 Assert (!this ->get_parameters ().enable_prescribed_dilation
666687 ||
667688 (outputs.template get_additional_output_object <MaterialModel::PrescribedPlasticDilation<dim>>()->dilation_lhs_term .size () == n_points &&
668- outputs.template get_additional_output_object <MaterialModel::PrescribedPlasticDilation<dim>>()->dilation_rhs_term .size () == n_points),
689+ outputs.template get_additional_output_object <MaterialModel::PrescribedPlasticDilation<dim>>()->dilation_rhs_term .size () == dim &&
690+ outputs.template get_additional_output_object <MaterialModel::PrescribedPlasticDilation<dim>>()->dilation_rhs_term [0 ].size () == n_points &&
691+ outputs.template get_additional_output_object <MaterialModel::PrescribedPlasticDilation<dim>>()->dilation_rhs_term [1 ].size () == n_points &&
692+ (dim == 2 || (dim == 3 && outputs.template get_additional_output_object <MaterialModel::PrescribedPlasticDilation<dim>>()->dilation_rhs_term [2 ].size () == n_points))),
669693 ExcInternalError ());
670694
671695 if (this ->get_newton_handler ().parameters .newton_derivative_scaling_factor != 0 )
0 commit comments