@@ -454,12 +454,14 @@ namespace aspect
454454 active_cell_data.enable_newton_derivatives = (Parameters<dim>::is_defect_correction (this ->get_parameters ().nonlinear_solver )
455455 && this ->get_newton_handler ().parameters .newton_derivative_scaling_factor != 0 );
456456 active_cell_data.enable_prescribed_dilation = this ->get_parameters ().enable_prescribed_dilation ;
457+ active_cell_data.average_newton_factors = (this ->get_parameters ().material_averaging != MaterialModel::MaterialAveraging::none);
457458
458459 // TODO: these are not implemented yet
459460 for (unsigned int level=0 ; level<n_levels; ++level)
460461 {
461462 level_cell_data[level].enable_newton_derivatives = false ;
462463 level_cell_data[level].enable_prescribed_dilation = false ;
464+ level_cell_data[level].average_newton_factors = false ;
463465 }
464466
465467 FEValues<dim> fe_values (this ->get_mapping (),
@@ -556,15 +558,8 @@ namespace aspect
556558
557559 for (unsigned int q=0 ; q<n_q_points; ++q)
558560 {
559- // use the correct strain rate for the Jacobian
560- // when elasticity is enabled use viscoelastic strain rate
561- // when stabilization is enabled, use the deviatoric strain rate because the SPD factor
562- // that is computed is only safe for the deviatoric strain rate (see PR #5580 and issue #5555)
563- SymmetricTensor<2 ,dim> effective_strain_rate = in.strain_rate [q];
564- if (elastic_out != nullptr )
565- effective_strain_rate = elastic_out->viscoelastic_strain_rate [q];
566- else if ((this ->get_newton_handler ().parameters .velocity_block_stabilization & Newton::Parameters::Stabilization::PD) != Newton::Parameters::Stabilization::none)
567- effective_strain_rate = Utilities::Tensors::consistent_deviator (effective_strain_rate);
561+ const SymmetricTensor<2 ,dim> effective_strain_rate
562+ = (elastic_out == nullptr ? in.strain_rate [q] : elastic_out->viscoelastic_strain_rate [q]);
568563
569564 // use the spd factor when the stabilization is PD or SPD.
570565 const double alpha = (this ->get_newton_handler ().parameters .velocity_block_stabilization
@@ -579,14 +574,19 @@ namespace aspect
579574 1.0 ;
580575
581576 active_cell_data.newton_factor_wrt_pressure_table (cell,q)[i]
582- = derivatives->viscosity_derivative_wrt_pressure [q] *
583- derivatives->viscosity_derivative_averaging_weights [q] *
584- newton_derivative_scaling_factor;
577+ = newton_derivative_scaling_factor * derivatives->viscosity_derivative_wrt_pressure [q]
578+ * (active_cell_data.average_newton_factors ? derivatives->viscosity_derivative_averaging_weights [q] : 1.0 );
585579 Assert (std::isfinite (active_cell_data.newton_factor_wrt_pressure_table (cell,q)[i]),
586- ExcMessage (" active_cell_data.newton_factor_wrt_pressure_table is not finite: " + std::to_string (active_cell_data.newton_factor_wrt_pressure_table (cell,q)[i]) +
587- " . Relevant variables are derivatives->viscosity_derivative_wrt_pressure[q] = " + std::to_string (derivatives->viscosity_derivative_wrt_pressure [q]) +
588- " , derivatives->viscosity_derivative_averaging_weights[q] = " + std::to_string (derivatives->viscosity_derivative_averaging_weights [q]) +
589- " , and newton_derivative_scaling_factor = " + std::to_string (newton_derivative_scaling_factor)));
580+ ExcMessage (" active_cell_data.newton_factor_wrt_pressure_table is not finite: "
581+ + std::to_string (active_cell_data.newton_factor_wrt_pressure_table (cell,q)[i])
582+ + " . Relevant variables are derivatives->viscosity_derivative_wrt_pressure[q] = "
583+ + std::to_string (derivatives->viscosity_derivative_wrt_pressure [q])
584+ + (active_cell_data.average_newton_factors ?
585+ " , derivatives->viscosity_derivative_averaging_weights[q] = "
586+ + std::to_string (derivatives->viscosity_derivative_averaging_weights [q])
587+ + " , and newton_derivative_scaling_factor = "
588+ + std::to_string (newton_derivative_scaling_factor) :
589+ " " )));
590590
591591 for (unsigned int m=0 ; m<dim; ++m)
592592 for (unsigned int n=0 ; n<dim; ++n)
@@ -595,24 +595,28 @@ namespace aspect
595595 = effective_strain_rate[m][n];
596596
597597 active_cell_data.newton_factor_wrt_strain_rate_table (cell, q)[m][n][i]
598- = derivatives->viscosity_derivative_wrt_strain_rate [q][m][n] *
599- derivatives->viscosity_derivative_averaging_weights [q] *
600- newton_derivative_scaling_factor * alpha;
598+ = newton_derivative_scaling_factor * alpha * derivatives->viscosity_derivative_wrt_strain_rate [q][m][n]
599+ * (active_cell_data.average_newton_factors ? derivatives->viscosity_derivative_averaging_weights [q] : 1.0 );
601600
602601 Assert (std::isfinite (active_cell_data.strain_rate_table (cell, q)[m][n][i]),
603- ExcMessage (" active_cell_data.strain_rate_table has an element which is not finite: " + std::to_string (active_cell_data.strain_rate_table (cell, q)[m][n][i])));
602+ ExcMessage (" active_cell_data.strain_rate_table has an element which is not finite: "
603+ + std::to_string (active_cell_data.strain_rate_table (cell, q)[m][n][i])));
604604 Assert (std::isfinite (active_cell_data.newton_factor_wrt_strain_rate_table (cell, q)[m][n][i]),
605- ExcMessage (" active_cell_data.newton_factor_wrt_strain_rate_table has an element which is not finite: " + std::to_string (active_cell_data.newton_factor_wrt_strain_rate_table (cell, q)[m][n][i])));
605+ ExcMessage (" active_cell_data.newton_factor_wrt_strain_rate_table has an element which is not finite: "
606+ + std::to_string (active_cell_data.newton_factor_wrt_strain_rate_table (cell, q)[m][n][i])));
606607 }
607608
608609 if (active_cell_data.enable_prescribed_dilation )
609610 {
610611 active_cell_data.dilation_derivative_wrt_pressure_table (cell,q)[i]
611612 = derivatives->dilation_derivative_wrt_pressure [q] * newton_derivative_scaling_factor;
612613 Assert (std::isfinite (active_cell_data.dilation_derivative_wrt_pressure_table (cell,q)[i]),
613- ExcMessage (" active_cell_data.dilation_derivative_wrt_pressure_table is not finite: " + std::to_string (active_cell_data.dilation_derivative_wrt_pressure_table (cell,q)[i]) +
614- " . Relevant variables are derivatives->dilation_derivative_wrt_pressure[q] = " + std::to_string (derivatives->dilation_derivative_wrt_pressure [q]) +
615- " and newton_derivative_scaling_factor = " + std::to_string (newton_derivative_scaling_factor)));
614+ ExcMessage (" active_cell_data.dilation_derivative_wrt_pressure_table is not finite: "
615+ + std::to_string (active_cell_data.dilation_derivative_wrt_pressure_table (cell,q)[i])
616+ + " . Relevant variables are derivatives->dilation_derivative_wrt_pressure[q] = "
617+ + std::to_string (derivatives->dilation_derivative_wrt_pressure [q])
618+ + " and newton_derivative_scaling_factor = "
619+ + std::to_string (newton_derivative_scaling_factor)));
616620
617621 for (unsigned int m=0 ; m<dim; ++m)
618622 for (unsigned int n=0 ; n<dim; ++n)
0 commit comments