-
Notifications
You must be signed in to change notification settings - Fork 471
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
Implementing smoothness indicators with ProjectGrad #4269
Comments
I realized the integral computation was way off. I think after projecting the gradient degrees of freedom back onto the finite dimensional space of the solution, the integral, vfes->GetElementVDofs(indx, vdof_indices);
sol.GetSubVector(vdof_indices, el_vdofs);
fe->ProjectGrad(*fe, *Tr, grad_matrix);
DenseMatrix vdof_mat(el_vdofs.GetData(), ndofs, num_equations);
// beta is num_equations x num_stencil array
// columns of which are the beta values for the given element in the stencil
beta.GetColumnReference(j, beta_col);
.
.
.
Vector grad_vec(ndofs), Mdx(ndofs);
DenseMatrix mass_matrix(ndofs);
if (dim == 1)
{
grad_vdof_mat = vdof_mat;
for (int grad_level = 1; grad_level < order + 1; grad_level++)
{
int_order = 2 * fe->GetOrder() + Tr->OrderW();
const IntegrationRule* ir = &IntRules.Get(fe->GetGeomType(), int_order);
mfem::Mult(grad_matrix, grad_vdof_mat, tmp_mat);
grad_vdof_mat = tmp_mat;
integrand = 0.0;
mass_matrix = 0.0;
// Calculating the (extrapolated) mass integrator
for (int k = 0; k < ir->GetNPoints(); k++)
{
const IntegrationPoint &ip = ir->IntPoint(k);
// j = 0 is the index of the target/troubled element; this is where the integral is evaluated
if (j != 0)
{
Tr_target->Transform(ip, phys_ip);
Tr->TransformBack(phys_ip, extrap_ip);
Tr->SetIntPoint(&extrap_ip);
fe->CalcPhysShape(*Tr, shape);
}
else
{
Tr->SetIntPoint(&ip);
fe->CalcPhysShape(*Tr, shape);
}
w = Tr->Weight() * ip.weight;
AddMult_a_VVt(w, shape, mass_matrix);
}
// x^T M x quadratic form calculation where x are the gradient degrees of freedom
for (int eq = 0 ; eq < num_equations; eq++)
{
grad_vdof_mat.GetColumn(eq, grad_vect);
mass_matrix.Mult(grad_vect, Mdx);
integrand(eq) = grad_vect * Mdx;
}
integrand /= pow(factorial(grad_level), 2);
integrand *= pow(target_el_size, 2 * grad_level - 1);
beta_col += integrand;
}
} Thank you very much. |
I would appreciate if anyone could offer some insight. Thank you. |
Hi,
I am trying to implement smoothness indicators of the form
This is in the context of calculating non-linear WENO weights for reconstructing the DG polynomial in the troubled (the one with sharp gradients) element.
As you can see, I need to repeatedly calculate the derivatives of the polynomials and integrate in the target element. Following the methodology described in #1118, I wrote a piece of code that is supposed to perform these operations but my solution blows up and the implementation of smoothness indicators is my primary suspect. Here is the relevant part of the code:
where beta_col are the values of$b_i$ for a given element and for different equations in the system. I am using the output of
ProjectGrad
extensively to first get the gradient degrees of freedom and then multiply by the output ofCalcShape
to interpolate at the quadrature points.Does anything look wrong or stand out to you in this implementation? I feel like this is the where the problem lies.
Thank you very much.
Farhad
The text was updated successfully, but these errors were encountered: