def __init__(self, form, Space, bcs=[], name="x", matvec=[None, None], method="default", solver_type="cg", preconditioner_type="default"): Function.__init__(self, Space, name=name) self.form = form self.method = method self.bcs = bcs self.matvec = matvec self.trial = trial = TrialFunction(Space) self.test = test = TestFunction(Space) Mass = inner(trial, test) * dx() self.bf = inner(form, test) * dx() self.rhs = Vector(self.vector()) if method.lower() == "default": self.A = A_cache[(Mass, tuple(bcs))] self.sol = Solver_cache[(Mass, tuple( bcs), solver_type, preconditioner_type)] elif method.lower() == "lumping": assert Space.ufl_element().degree() < 2 self.A = A_cache[(Mass, tuple(bcs))] ones = Function(Space) ones.vector()[:] = 1. self.ML = self.A * ones.vector() self.ML.set_local(1. / self.ML.array())
def __init__(self, form, Space, bcs=[], name="x", matvec=[None, None], method="default", solver_type="cg", preconditioner_type="default"): Function.__init__(self, Space, name=name) self.form = form self.method = method self.bcs = bcs self.matvec = matvec self.trial = trial = TrialFunction(Space) self.test = test = TestFunction(Space) Mass = inner(trial, test)*dx() self.bf = inner(form, test)*dx() self.rhs = Vector(self.vector()) if method.lower() == "default": self.A = A_cache[(Mass, tuple(bcs))] self.sol = KrylovSolver(solver_type, preconditioner_type) self.sol.parameters["preconditioner"]["structure"] = "same" self.sol.parameters["error_on_nonconvergence"] = False self.sol.parameters["monitor_convergence"] = False self.sol.parameters["report"] = False elif method.lower() == "lumping": assert Space.ufl_element().degree() < 2 self.A = A_cache[(Mass, tuple(bcs))] ones = Function(Space) ones.vector()[:] = 1. self.ML = self.A * ones.vector() self.ML.set_local(1. / self.ML.array())
def __init__(self, nut, u, Space, bcs=[], name=""): Function.__init__(self, Space, name=name) dim = Space.mesh().geometry().dim() test = TestFunction(Space) self.bf = [inner(inner(grad(nut), u.dx(i)), test)*dx for i in range(dim)]
def __init__(self, form, Space, bcs=[], name="x", matvec=[None, None], method="default", solver_type="cg", preconditioner_type="default"): Function.__init__(self, Space, name=name) self.form = form self.method = method self.bcs = bcs self.matvec = matvec self.trial = trial = TrialFunction(Space) self.test = test = TestFunction(Space) Mass = inner(trial, test) * dx() self.bf = inner(form, test) * dx() self.rhs = Vector(self.vector()) if method.lower() == "default": self.A = A_cache[(Mass, tuple(bcs))] self.sol = Solver_cache[(Mass, tuple(bcs), solver_type, preconditioner_type)] elif method.lower() == "lumping": assert Space.ufl_element().degree() < 2 self.A = A_cache[(Mass, tuple(bcs))] ones = Function(Space) ones.vector()[:] = 1. self.ML = self.A * ones.vector() self.ML.set_local(1. / self.ML.array())
def __init__(self, nut, u, Space, bcs=[], name=""): Function.__init__(self, Space, name=name) dim = Space.mesh().geometry().dim() test = TestFunction(Space) self.bf = [ inner(inner(grad(nut), u.dx(i)), test) * dx for i in range(dim) ]
def __init__(self, u, name="Assigned Vector Function"): self.u = u assert isinstance(u, ListTensor) V = u[0].function_space() mesh = V.mesh() family = V.ufl_element().family() degree = V.ufl_element().degree() constrained_domain = V.dofmap().constrained_domain Vv = VectorFunctionSpace(mesh, family, degree, constrained_domain=constrained_domain) Function.__init__(self, Vv, name=name) self.fa = [FunctionAssigner(Vv.sub(i), V) for i, _u in enumerate(u)]
def __init__(self, ft_pairs): # NOTE: this is derived from Function just to allow nice # interplay with the interpreter. If there were space time # elements then we could have eval f(t, x) support functions, times = list(zip(*ft_pairs)) # Check that every f has same f V = space_of(functions) # Time interval check dt = np.diff(times) assert (dt > 0).all() self.functions = functions self.times = times self.V = V Function.__init__(self, V)
def __init__(self, ft_pairs): # NOTE: this is derived from Function just to allow nice # interplay with the interpreter. If there were space time # elements then we could have eval f(t, x) support nodes, times = list(zip(*ft_pairs)) # Checks some necessaru conditions for compatibility of nodes in the series assert check_nodes(nodes) # Optimistically take the function space V = interpreter.Eval(next(iter(nodes))).function_space() # Time interval check dt = np.diff(times) assert (dt > 0).all() self.nodes = nodes self.times = times self.V = V Function.__init__(self, V)
def __init__(self, V): Function.__init__(self, V)