Using the solution of a function from a previous time step
Hi Everyone,
I'm a bit of a newcomer to FEniCS, and I'm working on an advection-
mesh = Rectangle(0, 0, 2, 1, 100, 1, 'crossed')
V = FunctionSpace(mesh, "CG", 1)
# Define Dirichlet boundary
def Dirichlet_
return x[0] < DOLFIN_EPS
dt = 60
T = 14400
t = dt
C1 = Constant(1.5)
bc1 = DirichletBC(V, C1, Dirichlet_
C0 = Constant(0)
C0.t = 0
C_prev = interpolate(C0, V)
C_prev2 = interpolate(C_prev, V)
S0 = Constant(0)
S0.t = 0
S_prev = interpolate(S0, V)
# Define variational problem
C = TrialFunction(V)
w = TestFunction(V)
S = Function
f = Constant(0) #Flux() # Source
alphdisp=
q = Constant(8.19e-5) #Darcy Velocity
De = Constant(2.807e-7)
D = Expression(
#D = Constant(0)
k = Constant(5.53e-5) # Constant removal term
#k = Constant(0)
n = Constant(0.34) # Porosity
vs = Constant(3.35e-4) # Seepage Velocity
Smax = Constant(1.999e-3) # Maximum possible Sorption
pb = Constant(2531) # Density kg/m3
den = 1658
def katt():
return (1-S_prev/
def S():
return S_prev+
a = C*w*dx + dt*w*C.dx(0)*vs*dx + dt*D*inner(
L = (C_prev + dt*f)*w*dx
C = Function(V)
A = assemble(a)
# Save solution in VTK format
file = File("transport
while t <= T:
b = assemble(L)
C0.t = t
bc1.apply(A,b)
solve(
t += dt
S_prev=S()
C_prev2.
C_prev.assign(C)
file << (C)
# Plot solution
plot(C, interactive=True)
plot(S(), interactive=True)
The program begins to run but then slows down before giving this error
File "trans.py", line 90, in <module>
S_prev=S()
File "trans.py", line 69, in S
return S_prev+
File "trans.py", line 66, in katt
return (1-S_prev/
File "/usr/lib/
return Sum(o, -self)
File "/usr/lib/
return -1*self
File "/usr/lib/
return _mult(o, self)
File "/usr/lib/
p = Product(a, b)
File "/usr/lib/
self.
File "/usr/lib/
self._repr = "Product(%s)" % ", ".join(repr(o) for o in self._operands)
MemoryError
Thanks in advance for the help.
Best,
David Estrella
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Marie Rognes
- Solved:
- Last query:
- Last reply: