Hello NGSolve,

I need to use a coefficient function that depends on the spatial coordinates. I tried the following:

[code]#!/usr/bin/env python

# coding: utf-8

import netgen.gui

from ngsolve import *

from netgen.csg import *

from netgen.geom2d import unit_square

# initialise mpi

comm = mpi_world

rank = comm.rank

nproc= comm.size

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

fes = H1(mesh, complex=True, order=2)

u = fes.TrialFunction()

v = fes.TestFunction()

R=0.8

class myCoeff:

def **init**(self):

self.R = R

```
def eval(self, value, x):
outside = ( x >= R )
coeff = 1. / (x - R)
value = outside * coeff
```

C = CoefficientFunction(myCoeff)

# want to use a coefficient in the bilinear form:

# a = BilinearForm (fes, symmetric=True)

# a += SymbolicBFI (C*grad(u)*grad(v))

[/code]

But the class can not be an argument for the CoefficientFunction. How to incorporate slightly involved functions such as the one above to be used in bilinear form? Thank you!!