Skip to content
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

feat: averaging of stress components using quadrature #3279

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

ryar9534
Copy link
Contributor

@ryar9534 ryar9534 commented Aug 12, 2024

Implementation of a new averaged stress output per cell, where the averaging for each component is done using the quadrature rule of the finite element.

The new field is averageStress (6 components per cell) and is registered/owned by the solid mechanics solver, like the average strain (which I have made some minor changes to in order to unify with this new stress). This average stress is stored in addition to the stress at the quadrature points, but the stress owned by the constitutive law is no longer output (using the arithmetic mean).

An annoying rebaseline will be required, as this is gonna change all of the mechanics/poromechanics.

@ryar9534 ryar9534 self-assigned this Aug 12, 2024
@ryar9534 ryar9534 added the type: feature New feature or request label Aug 12, 2024
@ryar9534 ryar9534 requested a review from CusiniM August 12, 2024 22:14
@ryar9534 ryar9534 marked this pull request as ready for review August 12, 2024 22:17
Copy link
Collaborator

@CusiniM CusiniM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should make the stress NO_PLOT.

@ryar9534
Copy link
Contributor Author

we should make the stress NO_PLOT.

The new average stress or the old stresses?

@CusiniM
Copy link
Collaborator

CusiniM commented Aug 12, 2024

we should make the stress NO_PLOT.

The new average stress or the old stresses?

the old ones should disappear I guess.

@ryar9534
Copy link
Contributor Author

ryar9534 commented Aug 12, 2024

we should make the stress NO_PLOT.

The new average stress or the old stresses?

the old ones should disappear I guess.

So are we ok with the overall increased memory footprint? The advantage of the old stresses is that the average is never stored explicitly

@CusiniM
Copy link
Collaborator

CusiniM commented Aug 12, 2024

we should make the stress NO_PLOT.

The new average stress or the old stresses?

the old ones should disappear I guess.

So are we ok with the overall increased memory footprint? The advantage of the old stresses is that the average is never stored explicitly

well, yes, but it's also wrong and we certainly don't want the output to depend on FE.

Copy link

codecov bot commented Aug 12, 2024

Codecov Report

Attention: Patch coverage is 5.55556% with 17 lines in your changes missing coverage. Please review.

Project coverage is 56.45%. Comparing base (42966e9) to head (6a5f2a7).

Files Patch % Lines
...ers/solidMechanics/SolidMechanicsLagrangianFEM.cpp 0.00% 9 Missing ⚠️
...idMechanics/kernels/StressStrainAverageKernels.hpp 0.00% 6 Missing ⚠️
...icsSolvers/solidMechanics/SolidMechanicsFields.hpp 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3279      +/-   ##
===========================================
- Coverage    56.46%   56.45%   -0.01%     
===========================================
  Files         1059     1059              
  Lines        89458    89468      +10     
===========================================
- Hits         50512    50510       -2     
- Misses       38946    38958      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 296 to 297
GEOS_HOST_DEVICE
void quadraturePointKernel( localIndex const k,
Copy link
Contributor

@castelletto1 castelletto1 Aug 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file contains two functions quadraturePointKernel once for the strain and one for the stress. In my opinion only one function should exist to perform the averaging of a second order symmetric stress tensor -- and probably of any scalar (rank 0), vector (rank 1), ... . The class AverageOverQuadraturePointsBase should be responsible for this task, and the quantity to be averaged should either provided directly or with a lambda function that evaluates such property.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could generalize it and come up with a single kernel. We could try to make it accept a list of views instead of a specific one. It would also mean that we do all averaging in a single kernel launch which it is indeed better. We could use something similar to the elementViewAccessors and create an array1d of all scalars, one for all vectors and one for all tensors to be averaged and have the averagingKernel only ask for the keys of the fields that need to be averaged.
The strain probably remains a bit of a special case though and i don't know that we do any averaging for other quantities.

Copy link
Contributor

@castelletto1 castelletto1 Aug 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the long term, such computations should be managed by a numerical quadrature library (i.e. --> Shiva)


for( int icomp = 0; icomp < 6; ++icomp )
{
m_avgStress[k][icomp] += detJxW*m_stress[k][q][icomp]/m_elementVolume[k];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we divide by the cell element volume (m_elementVolume[k]) to compute the increment to the average value. In AverageOverQuadraturePointsBase the cell element contribution is directly included in the weight definition. Both correct, but it would be nice to be consistent

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we should divide only once at the end.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally speaking, I would argue that m_elementVolume[k] should not even be required and computed directly in the quadrature process. For this specific case:

real64 cellVolume{0.0}
for( int icomp = 0; icomp < 6; ++icomp )
{
  m_avgStress[k][icomp] += detJxW*m_stress[k][q][icomp];
  cellVolume += detJxW;
}
m_avgStress[k][icomp] /= cellVolume;

@CusiniM
Copy link
Collaborator

CusiniM commented Nov 5, 2024

what's the status of this PR?

@ryar9534
Copy link
Contributor Author

ryar9534 commented Nov 5, 2024

what's the status of this PR?

@CusiniM I just didnt know if this is still something folks want in develop. I originally did it to see if it helped with some stress oscillations in NL but it didnt.

@rrsettgast
Copy link
Member

@herve-gross @jhuang2601
Can we figure out if this is needed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants