Div(a*Grad(v))

Hello all,
i am trying to calculate almost an Laplacian div( a * Grad(v) ) for 1-dim a and 2-dim v. They are both “ComponentGridFunctions”.
However, I get the error that the Coefficient Functions object does not have the attribute ‘derivname’.

Hi,
that’s not expected to work. You can apply (certain) differential operators to Grid- and Proxy-Functions, but not to arbitrary expressions.
Joachim

Hello Joachim,
Thank you for your fast response.
I have tried to construct a GridFunction and use .Set() to interpolate the term a*Grad(v) to use the Div operator on that Grid function, but get the following error:

NgException: CompoundFESpace does not have an evaluator for VOL!

Is there another way to achive this laplacian in NGSolve or should I try to export my variables to numpy and do numerical differentation there.

The aim is to do post-processing and it would be nice to do it within ngsovle.

this one is working:

from ngsolve import *
from ngsolve.webgui import Draw

mesh = Mesh(unit_square.GenerateMesh(maxh=0.1))

gfu = GridFunction(VectorH1(mesh, order=3))
gfu.Set ( (x*x*x, x*y*y) )

gfflux = GridFunction(HDiv(mesh, order=2)**2)
gfflux.Set ( 1/2 * Grad(gfu))

Draw (div(gfflux)[0], mesh)
Draw (div(gfflux)[1], mesh)

Product-spaces don’t provide differential operators, only their component spaces. Multiple copies of the same space (like HDiv(…)**2) inherit the diffops from the underlying space.

Joachim

1 Like