piecewise defined function
Asked by
Achim Schroll
Hi!
My piecewise defined function alpha (see below) just returns zero.
What is wrong? How to define it instead?
Best, Achim
# set parameters
alpha1 = 0.2; alpha2 = 0.8
# create mesh and finite element
mesh = UnitSquare(20, 20)
V = FunctionSpace(mesh, "CG", 1)
# define trial & testfunctions
u_trial = TrialFunction(V); phi = TestFunction(V)
# define diffusion parameter
class alpha(Function):
def __init__(self, V):
def eval(self, v, x):
v[0] = alpha1
if x[0] > 0.5: v[0] = alpha2
d = alpha(V)
print " |d| = %g" %(d.vector(
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Anders Logg
- Solved:
- Last query:
- Last reply:
To post a message you must log in.