-
Notifications
You must be signed in to change notification settings - Fork 274
Add viscosity additional outputs #6974
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Added: additional named outputs for diffusion and dislocation viscosities in the visco-plastic material model, including rheology-specific handling of inactive flow laws and visualization support through the additional material output system. | ||
| <br> | ||
| (Haoyuan Li, 2026/05/12) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,6 +84,42 @@ namespace aspect | |
|
|
||
|
|
||
|
|
||
| namespace | ||
| { | ||
| std::vector<std::string> make_viscosity_additional_outputs_names() | ||
| { | ||
| std::vector<std::string> names; | ||
| names.emplace_back("diffusion_viscosity"); | ||
| names.emplace_back("dislocation_viscosity"); | ||
| return names; | ||
| } | ||
| } | ||
|
|
||
|
|
||
|
|
||
| template <int dim> | ||
| ViscosityAdditionalOutputs<dim>::ViscosityAdditionalOutputs(const unsigned int n_points) | ||
| : NamedAdditionalMaterialOutputs<dim>(make_viscosity_additional_outputs_names()), | ||
| diffusion_viscosities(n_points, numbers::signaling_nan<double>()), | ||
| dislocation_viscosities(n_points, numbers::signaling_nan<double>()) | ||
| {} | ||
|
|
||
|
|
||
|
|
||
| template <int dim> | ||
| std::vector<double> | ||
| ViscosityAdditionalOutputs<dim>::get_nth_output(const unsigned int idx) const | ||
| { | ||
| AssertIndexRange(idx, 2); | ||
|
|
||
| if (idx == 0) | ||
| return diffusion_viscosities; | ||
| else | ||
| return dislocation_viscosities; | ||
| } | ||
|
|
||
|
|
||
|
|
||
| namespace Rheology | ||
| { | ||
|
|
||
|
|
@@ -110,6 +146,8 @@ namespace aspect | |
| output_parameters.drucker_prager_parameters.resize(volume_fractions.size()); | ||
| output_parameters.dilation_lhs_terms.resize(volume_fractions.size(), numbers::signaling_nan<double>()); | ||
| output_parameters.dilation_rhs_terms.resize(volume_fractions.size(), numbers::signaling_nan<double>()); | ||
| output_parameters.diffusion_viscosities.resize(volume_fractions.size(), numbers::signaling_nan<double>()); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. However, in the calculation step, it seems the nan value won't trigger issue, as indicated by the examples of other variables. |
||
| output_parameters.dislocation_viscosities.resize(volume_fractions.size(), numbers::signaling_nan<double>()); | ||
|
|
||
| // Assemble current and old stress tensor if elastic behavior is enabled | ||
| SymmetricTensor<2, dim> stress_0_advected = numbers::signaling_nan<SymmetricTensor<2, dim>>(); | ||
|
|
@@ -220,12 +258,14 @@ namespace aspect | |
| { | ||
| non_yielding_viscosity = compositional_viscosity_prefactors.compute_viscosity(in, viscosity_diffusion, j, i, | ||
| CompositionalViscosityPrefactors<dim>::ModifiedFlowLaws::diffusion); | ||
| output_parameters.diffusion_viscosities[j] = non_yielding_viscosity; | ||
| break; | ||
| } | ||
| case dislocation: | ||
| { | ||
| non_yielding_viscosity = compositional_viscosity_prefactors.compute_viscosity(in, viscosity_dislocation, j, i, | ||
| CompositionalViscosityPrefactors<dim>::ModifiedFlowLaws::dislocation); | ||
| output_parameters.dislocation_viscosities[j] = non_yielding_viscosity; | ||
| break; | ||
| } | ||
| case frank_kamenetskii: | ||
|
|
@@ -244,6 +284,9 @@ namespace aspect | |
| CompositionalViscosityPrefactors<dim>::ModifiedFlowLaws::dislocation); | ||
| non_yielding_viscosity = (scaled_viscosity_diffusion * scaled_viscosity_dislocation)/ | ||
| (scaled_viscosity_diffusion + scaled_viscosity_dislocation); | ||
|
|
||
| output_parameters.diffusion_viscosities[j] = scaled_viscosity_diffusion; | ||
| output_parameters.dislocation_viscosities[j] = scaled_viscosity_dislocation; | ||
| break; | ||
| } | ||
| case minimum_diffusion_dislocation: | ||
|
|
@@ -253,6 +296,9 @@ namespace aspect | |
| const double scaled_viscosity_dislocation = compositional_viscosity_prefactors.compute_viscosity(in, viscosity_dislocation, j, i, | ||
| CompositionalViscosityPrefactors<dim>::ModifiedFlowLaws::dislocation); | ||
| non_yielding_viscosity = std::min(scaled_viscosity_diffusion, scaled_viscosity_dislocation); | ||
|
|
||
| output_parameters.diffusion_viscosities[j] = scaled_viscosity_diffusion; | ||
| output_parameters.dislocation_viscosities[j] = scaled_viscosity_dislocation; | ||
| break; | ||
| } | ||
| default: | ||
|
|
@@ -984,6 +1030,95 @@ namespace aspect | |
| } | ||
| } | ||
|
|
||
| template <int dim> | ||
| void | ||
| Rheology::ViscoPlastic<dim>::create_viscosity_outputs (MaterialModel::MaterialModelOutputs<dim> &out) const | ||
| { | ||
| if (out.template has_additional_output_object<ViscosityAdditionalOutputs<dim>>() == false) | ||
| { | ||
| const unsigned int n_points = out.n_evaluation_points(); | ||
|
|
||
| out.additional_outputs.push_back( | ||
| std::make_unique<ViscosityAdditionalOutputs<dim>>(n_points)); | ||
| } | ||
| } | ||
|
|
||
| template <int dim> | ||
| void | ||
| Rheology::ViscoPlastic<dim>::fill_viscosity_outputs( | ||
| const unsigned int i, | ||
| const std::vector<double> &volume_fractions, | ||
| MaterialModel::MaterialModelOutputs<dim> &out, | ||
| const IsostrainViscosities &isostrain_viscosities) const | ||
| { | ||
| if (const std::shared_ptr<ViscosityAdditionalOutputs<dim>> | ||
| viscosity_out = out.template get_additional_output_object<ViscosityAdditionalOutputs<dim>>()) | ||
| { | ||
| switch (viscous_flow_law) | ||
|
lhy11009 marked this conversation as resolved.
|
||
| { | ||
| case diffusion: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently, I assign the value to max limit, if the viscosity is not computed by the viscous flow law (e.g. the dislocation creep would not be calculated if the flow law is diffusion). I'm not entirely sure this is the best approach. I have tested that assigning values to nan doesn't work and will trigger error in the post-processor. The values will be written as "inf" in outputs.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I see. Does the issue persist after #6973 was merged?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, this and 6973 are separated. |
||
| { | ||
| viscosity_out->diffusion_viscosities[i] | ||
| = MaterialUtilities::average_value( | ||
| volume_fractions, | ||
| isostrain_viscosities.diffusion_viscosities, | ||
| viscosity_averaging); | ||
|
|
||
| viscosity_out->dislocation_viscosities[i] | ||
| = std::numeric_limits<double>::max(); | ||
|
|
||
| break; | ||
| } | ||
|
|
||
| case dislocation: | ||
| { | ||
| viscosity_out->diffusion_viscosities[i] | ||
| = std::numeric_limits<double>::max(); | ||
|
|
||
| viscosity_out->dislocation_viscosities[i] | ||
| = MaterialUtilities::average_value( | ||
| volume_fractions, | ||
| isostrain_viscosities.dislocation_viscosities, | ||
| viscosity_averaging); | ||
|
|
||
| break; | ||
| } | ||
|
|
||
| case composite: | ||
| case minimum_diffusion_dislocation: | ||
| { | ||
| viscosity_out->diffusion_viscosities[i] | ||
| = MaterialUtilities::average_value( | ||
| volume_fractions, | ||
| isostrain_viscosities.diffusion_viscosities, | ||
| viscosity_averaging); | ||
|
|
||
| viscosity_out->dislocation_viscosities[i] | ||
| = MaterialUtilities::average_value( | ||
| volume_fractions, | ||
| isostrain_viscosities.dislocation_viscosities, | ||
| viscosity_averaging); | ||
|
|
||
| break; | ||
| } | ||
|
|
||
| case frank_kamenetskii: | ||
| { | ||
| viscosity_out->diffusion_viscosities[i] | ||
| = std::numeric_limits<double>::max(); | ||
|
|
||
| viscosity_out->dislocation_viscosities[i] | ||
| = std::numeric_limits<double>::max(); | ||
|
|
||
| break; | ||
| } | ||
|
|
||
| default: | ||
| AssertThrow(false, ExcInternalError()); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } | ||
| } | ||
| } | ||
|
|
@@ -995,6 +1130,7 @@ namespace aspect | |
| { | ||
| #define INSTANTIATE(dim) \ | ||
| template class PlasticAdditionalOutputs<dim>; \ | ||
| template class ViscosityAdditionalOutputs<dim>; \ | ||
| \ | ||
| namespace Rheology \ | ||
| { \ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.