-
Notifications
You must be signed in to change notification settings - Fork 274
Only require old stresses for elasticity if necessary #7007
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 all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -405,48 +405,27 @@ namespace aspect | |
| // of the same stress tensor in the computation of the initial residual | ||
| // for the fields that belong to that tensor. In other words, we compute an | ||
| // averaged initial residual using those fields that belong to the ve_stress tensor. | ||
| // The ve_stress_old values are not independent components of the solution vector, | ||
| // so we do not need to compute a residual for them and set their residual to zero. | ||
| // TODO Is this residual calculation representative of a second order tensor? | ||
| if (parameters.enable_elasticity == true) | ||
| if (parameters.enable_elasticity == true && residual) | ||
| { | ||
| const std::vector<unsigned int> &stress_field_indices = introspection.get_indices_for_fields_of_type(CompositionalFieldDescription::stress); | ||
| const double n_stress_fields = stress_field_indices.size(); | ||
|
|
||
| AssertThrow((n_stress_fields == 2*SymmetricTensor<2,dim>::n_independent_components || | ||
| n_stress_fields == SymmetricTensor<2,dim>::n_independent_components), | ||
| ExcMessage("The number of stress tensor element fields does not equal the number of expected components.")); | ||
|
|
||
| double stress_initial_residual = 0.0; | ||
| std::vector<unsigned int> stress_indices; | ||
| std::vector<unsigned int> old_stress_indices; | ||
| stress_indices.push_back(introspection.compositional_index_for_name("ve_stress_xx")); | ||
| stress_indices.push_back(introspection.compositional_index_for_name("ve_stress_yy")); | ||
| old_stress_indices.push_back(introspection.compositional_index_for_name("ve_stress_xx_old")); | ||
| old_stress_indices.push_back(introspection.compositional_index_for_name("ve_stress_yy_old")); | ||
| if (dim == 2) | ||
| { | ||
| stress_indices.push_back(introspection.compositional_index_for_name("ve_stress_xy")); | ||
| old_stress_indices.push_back(introspection.compositional_index_for_name("ve_stress_xy_old")); | ||
| } | ||
| else if (dim == 3) | ||
| { | ||
| stress_indices.push_back(introspection.compositional_index_for_name("ve_stress_zz")); | ||
| stress_indices.push_back(introspection.compositional_index_for_name("ve_stress_xy")); | ||
| stress_indices.push_back(introspection.compositional_index_for_name("ve_stress_xz")); | ||
| stress_indices.push_back(introspection.compositional_index_for_name("ve_stress_yz")); | ||
| old_stress_indices.push_back(introspection.compositional_index_for_name("ve_stress_zz_old")); | ||
| old_stress_indices.push_back(introspection.compositional_index_for_name("ve_stress_xy_old")); | ||
| old_stress_indices.push_back(introspection.compositional_index_for_name("ve_stress_xz_old")); | ||
| old_stress_indices.push_back(introspection.compositional_index_for_name("ve_stress_yz_old")); | ||
| } | ||
|
|
||
| for (unsigned int c=0; c<SymmetricTensor<2,dim>::n_independent_components; ++c) | ||
|
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. As the stress fields do not have to be the first fields, looping over field 0 to |
||
| stress_initial_residual += system_rhs.block(introspection.block_indices.compositional_fields[c]).l2_norm(); | ||
|
|
||
| if (residual) | ||
| { | ||
| const double n_stress_fields = stress_indices.size(); | ||
| for (auto &c : stress_indices) | ||
| stress_initial_residual += system_rhs.block(introspection.block_indices.compositional_fields[c]).l2_norm() / n_stress_fields; | ||
|
|
||
| // Overwrite the initial residual | ||
| for (auto &c : stress_indices) | ||
| (*residual)[c] = stress_initial_residual; | ||
| for (auto &c : old_stress_indices) | ||
| (*residual)[c] = 0.; | ||
| } | ||
| stress_initial_residual /= static_cast<double>(SymmetricTensor<2,dim>::n_independent_components); | ||
|
|
||
| // The ve_stress_old values if they exist are not independent components of the solution vector, | ||
| // so we do not compute a residual for them and set their residual to zero. | ||
| for (unsigned int c=0; c<n_stress_fields; ++c) | ||
| (*residual)[stress_field_indices[c]] = (c<SymmetricTensor<2,dim>::n_independent_components) ? stress_initial_residual : 0.; | ||
| } | ||
|
|
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.