Skip to content

Fast way to compute "extrapolated average" in cell #1927

Answered by pazner
vkorchagova asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @vkorchagova,

It's hard to say why GetElementAverages is too slow for you, but you can compute the cell averages of your extrapolated values by numerically integrating over the relevant cells using an IntegrationRule and ElementTransformation to compute the quadrature weights. You could adapt something like the following:

// To compute cell average of element i
const IntegrationRule &ir = IntRules.Get(mesh.GetElementBaseGeometry(i), order);
ElementTransformation &tr = *mesh.GetElementTransformation(i);
Vector vals;
gf.GetValues(i, ir, vals);
double cell_avg = 0.0;
for (int j=0; j<ir.Size(); ++j)
{
   const IntegrationPoint &ip = ir[j];
   tr.SetIntPoint(&ip);
   cell_avg += vals[j]*ir[j].

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@vkorchagova
Comment options

@pazner
Comment options

@vkorchagova
Comment options

@pazner
Comment options

Answer selected by tzanio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1927 on December 08, 2020 20:02.