-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discuss nonlinear problems and nonuniform data in the paper #430
Comments
Let's see. These are all handled easily by scikit-fem as it stands, I believe. I think the techniques are covered in the suite of examples. Going back to #24 (2018-08-07), quite new to scikit-fem, I wrote:
That became ex16 ‘spatially varying coefficient’. It's a diffusion operator, but the same technique would apply to uneven Lamé coefficients in linear elasticity, nonuniform source terms. That's for a coefficient that varies with position; for coefficients varying by subdomain, there's ex17, fufilling #89 ‘piecewise-definition of coefficients on subdomains’ (2018-11). Then there are coefficients that are functions of finite element functions, like the Young–Laplace equation ex10, the Bratu–Gelfand equation ex23, and the Navier–Stokes equation ex27. I think that covers the kind of nonlinear cases asked about. The Bratu–Gelfand equation is handled a bit differently; I'm not sure why. I guess it's simpler so can be, but I think it could be handled in the same way as the others if that was of interest, to have only one way of doing things. Apart from the Bratu–Gelfand example, the fundamental notion is |
From #426
I've been reading an example from Chapter 26 of https://launchpadlibrarian.net/83776282/fenics-book-2011-10-27-final.pdf from dolfin import *
# Sub domain for Dirichlet boundary condition
class DirichletBoundary(SubDomain):
def inside(self, x, on_boundary):
return abs(x[0] - 0.0) < DOLFIN_EPS and on_boundary
# Class for interfacing with the Newton solver
class NonlinearModelProblem(NonlinearProblem):
def __init__(self, a, L, u, C, S, Q, bc):
NonlinearProblem.__init__(self)
self.a, self.L = a, L
self.u, self.C, self.S, self.Q, self.bc = u, C, S, Q, 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)
def form(self, A, b, x):
C = project((1.0 + self.u**2), self.Q)
self.C.vector()[:] = C.vector()
S = project(Dx(self.u, 0), self.Q)
self.S.vector()[:] = S.vector()
self.S.vector()[:] = self.S.vector()*self.C.vector()
# Create mesh and define function spaces
mesh = UnitInterval(8)
V = FunctionSpace(mesh, "Lagrange", 2)
Q = FunctionSpace(mesh, "Q", 2)
# Define boundary condition
bc = DirichletBC(V, Constant(1.0), DirichletBoundary())
# Define source and functions
f = Expression("x[0]*x[0] - 4")
u, C, S = Function(V), Function(Q), Function(Q)
# Define variational problems
w = TestFunction(V)
du = TrialFunction(V)
L = S*Dx(w, 0)*dx - f*w*dx
a = C*Dx(du, 0)*Dx(w, 0)*dx + 2*u*Dx(u, 0)*du*Dx(w, 0)*dx
# Create nonlinear problem, solver and solve
problem = NonlinearModelProblem(a, L, u, C, S, Q, bc)
solver = NewtonSolver()
solver.solve(problem, u.vector()) |
It seems to me that C = project((1.0 + self.u**2), self.Q) Does it mean that https://github.com/kinnala/scikit-fem/blob/master/skfem/element/discrete_field.py |
Yes, that's it, nothing new. |
From #426
Should we discuss these in the paper?
The text was updated successfully, but these errors were encountered: