Giter Site home page Giter Site logo

Comments (2)

FH-9 avatar FH-9 commented on June 12, 2024

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, $\int \left( \frac{d}{dx} \tilde{p} \right)^2 dx \approx \int \left(\sum_k \hat{dp}_k \phi_k \right)^2 dx$, can be cast into the the quadratic form $\hat{x}^T M \hat{x}$, where $\hat{x}$ is the vector of gradient degrees of freedom, and $M$ is the extrapolated mass integrator (since the integral is over the target element only). I have updated the code but it is still blowing up. Is my reasoning here correct? And do you notice anything wrong with the code?
Here is the updated code:

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.

from mfem.

FH-9 avatar FH-9 commented on June 12, 2024

I would appreciate if anyone could offer some insight. Thank you.

from mfem.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.