Re: [firedrake] Solving adjoint equation
What output do you get? On 29 March 2016 at 16:09, George Ovchinnikov <lives9@gmail.com> wrote:
Dear All,
I have trilinear form a(w,u,v) and usually solve a(w,u,v) = l(v), for u with fixed w.
Here I have:
a = w dot(grad(u), grad(v)) * dx, and l(v) = f * v * dx.
Now, given u_tilde I want to solve for w, i.e. find w_tilde such, that a(w_tilde, u_tilde, v) = l(v), for any v in suitable subspace.
I'm trying the following:
mesh = UnitSquareMesh(size, size) V = FunctionSpace(mesh, "CG", 1)
f = Function(V) f.interpolate(Expression("1"))
u_tilde = Function(V) u_tilde.interpolate(Expression("1/(1+exp(-1*x[0])) * 1/(1+exp(-1*(1-x[0]))) *1/(1+exp(-1*x[1])) * 1/(1+exp(-1*(1-x[1])))" ))
w_tilde = TrialFunction(V) v = TestFunction(V)
a_tilde = (w_tilde * dot(grad(u_tilde), grad(v))) * dx frm_tilde = assemble( a_tilde )
L = f * v * dx rhs = assemble(L)
w_sol = Function(V) solve(frm_tilde, rhs, w_sol, solver_parameters={"ksp_type": "preonly", "pc_type": "lu"}) File("w_sol.pvd") << w_sol
It fails to converge: 140 r = self.ksp.getConvergedReason() 141 if r < 0: --> 142 raise RuntimeError("LinearSolver failed to converge after %d iterations with reason: %s", self.ksp.getIterationNumber(), solving_utils.KSPReasons[r])
KeyError: -11
I'm using direct method, not the iterative one, so what is happening here?
_______________________________________________ firedrake mailing list firedrake@imperial.ac.uk https://mailman.ic.ac.uk/mailman/listinfo/firedrake
Here it is --------------------------------------------------------------------------- KeyError Traceback (most recent call last) <ipython-input-8-752634385ffb> in <module>() 22 23 w_sol = Function(V) ---> 24 solve(frm_tilde, rhs, w_sol, solver_parameters={"ksp_type": "preonly", "pc_type": "lu"}) 25 File("w_sol.pvd") << w_sol /home/george/polygon/firedrake_new/firedrake/local/lib/python2.7/site-packages/firedrake/solving.pyc in solve(*args, **kwargs) 121 else: 122 # Solve pre-assembled system --> 123 return _la_solve(*args, **kwargs) 124 125 /home/george/polygon/firedrake_new/firedrake/local/lib/python2.7/site-packages/firedrake/solving.pyc in _la_solve(A, x, b, **kwargs) 209 options_prefix=options_prefix) 210 --> 211 solver.solve(x, b) 212 213 /home/george/polygon/firedrake_new/firedrake/local/lib/python2.7/site-packages/firedrake/linear_solver.pyc in solve(self, x, b) 140 r = self.ksp.getConvergedReason() 141 if r < 0: --> 142 raise RuntimeError("LinearSolver failed to converge after %d iterations with reason: %s", self.ksp.getIterationNumber(), solving_utils.KSPReasons[r]) KeyError: -11 On 29.03.2016 18:10, Andrew McRae wrote:
What output do you get?
On 29 March 2016 at 16:09, George Ovchinnikov <lives9@gmail.com <mailto:lives9@gmail.com>> wrote:
Dear All,
I have trilinear form a(w,u,v) and usually solve a(w,u,v) = l(v), for u with fixed w.
Here I have:
a = w dot(grad(u), grad(v)) * dx, and l(v) = f * v * dx.
Now, given u_tilde I want to solve for w, i.e. find w_tilde such, that a(w_tilde, u_tilde, v) = l(v), for any v in suitable subspace.
I'm trying the following:
mesh = UnitSquareMesh(size, size) V = FunctionSpace(mesh, "CG", 1)
f = Function(V) f.interpolate(Expression("1"))
u_tilde = Function(V) u_tilde.interpolate(Expression("1/(1+exp(-1*x[0])) * 1/(1+exp(-1*(1-x[0]))) *1/(1+exp(-1*x[1])) * 1/(1+exp(-1*(1-x[1])))" ))
w_tilde = TrialFunction(V) v = TestFunction(V)
a_tilde = (w_tilde * dot(grad(u_tilde), grad(v))) * dx frm_tilde = assemble( a_tilde )
L = f * v * dx rhs = assemble(L)
w_sol = Function(V) solve(frm_tilde, rhs, w_sol, solver_parameters={"ksp_type": "preonly", "pc_type": "lu"}) File("w_sol.pvd") << w_sol
It fails to converge: 140 r = self.ksp.getConvergedReason() 141 if r < 0: --> 142 raise RuntimeError("LinearSolver failed to converge after %d iterations with reason: %s", self.ksp.getIterationNumber(), solving_utils.KSPReasons[r])
KeyError: -11
I'm using direct method, not the iterative one, so what is happening here?
_______________________________________________ firedrake mailing list firedrake@imperial.ac.uk <mailto:firedrake@imperial.ac.uk> https://mailman.ic.ac.uk/mailman/listinfo/firedrake
_______________________________________________ firedrake mailing list firedrake@imperial.ac.uk https://mailman.ic.ac.uk/mailman/listinfo/firedrake
participants (2)
- 
                
                Andrew McRae
- 
                
                George Ovchinnikov