This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

How to set DirichletBC in NonlinearProblem

0 votes

I'm using the NewtonSolver and a NonlinearProblem. Where do I set the Dirichlet boundary conditions?

asked Dec 12, 2013 by nschloe FEniCS User (7,120 points)

1 Answer

0 votes
 
Best answer

The example at tests/unit/book/python/chapter_10.py explains it: Incorporate it into the NonlinearProblem by applying it to both the nonlinear residual and the Jacobian:

class MyNonlinearProblem(NonlinearProblem):
    def __init__(self, L, a, bc):
        NonlinearProblem.__init__(self)
        self.L = L
        self.a = a
        self.bc = bc

    def F(self, b, x):
        assemble(self.L, tensor=b)
        self.bc.apply(b, x)

    def J(self, A, x):
        assemble(self.a, tensor=A)
        self.bc.apply(A)
answered Dec 12, 2013 by nschloe FEniCS User (7,120 points)
edited Jan 13, 2014 by nschloe
...