Esempio n. 1
0
 def __init__(self, energy, u, bcs, nullspace=None):
     NonlinearProblem.__init__(self)
     self.z = u
     self.bcs = bcs
     self.nullspace = nullspace
     self.residual = derivative(energy, self.z,
                                TestFunction(self.z.function_space()))
     self.jacobian = derivative(self.residual, self.z,
                                TrialFunction(self.z.function_space()))
 def __init__(self, residual_block_form, block_solution, bcs,
              jacobian_block_form):
     NonlinearProblem.__init__(self)
     # Store the input arguments
     self.residual_block_form = residual_block_form
     self.jacobian_block_form = jacobian_block_form
     self.block_solution = block_solution
     self.bcs = bcs
     # Create block backend for wrapping
     self.block_backend = BlockDefaultFactory()
     self.block_dof_map = self.block_solution.block_function_space(
     ).block_dofmap()
Esempio n. 3
0
 def __init__(self, residual_form_or_eval, block_solution, bcs,
              jacobian_form_or_eval):
     NonlinearProblem.__init__(self)
     # Store the input arguments
     self.residual_form_or_eval = residual_form_or_eval
     self.jacobian_form_or_eval = jacobian_form_or_eval
     self.block_solution = block_solution
     self.bcs = bcs
     # Create block backend for wrapping
     self.block_backend = BlockDefaultFactory()
     self.block_dof_map = self.block_solution.block_function_space(
     ).block_dofmap()
     # =========== PETScSNESSolver::init() workaround for assembled matrices =========== #
     self._J_assemble_failed_in_init = False
Esempio n. 4
0
    def __init__(self, energy, alpha, bcs, lb=None, ub=None):

        NonlinearProblem.__init__(self)
        self.energy = energy
        self.alpha = alpha
        self.V = self.alpha.function_space()
        self.denergy = derivative(self.energy, self.alpha,
                                  TestFunction(self.V))
        self.ddenergy = derivative(self.denergy, self.alpha,
                                   TrialFunction(self.V))
        if lb == None:
            lb = interpolate(Constant("0."), self.V)
        if ub == None:
            ub = interpolate(Constant("1."), self.V)
        self.lb = lb
        self.ub = ub
        self.bcs = bcs
        self.b = PETScVector()
        self.A = PETScMatrix()
Esempio n. 5
0
    def __init__(self, energy, state, bcs=None):
        """
        Initialises the damage problem.

        Arguments:
            * energy
            * state
            * boundary conditions
        """
        NonlinearProblem.__init__(self)
        self.type = "snes"
        self.bcs = bcs
        self.state = state
        alpha = state["alpha"]
        V = alpha.function_space()
        alpha_v = TestFunction(V)
        dalpha = TrialFunction(V)
        self.energy = energy
        self.F = derivative(energy, alpha, alpha_v)
        self.J = derivative(self.F, alpha, dalpha)
        self.lb = alpha.copy(True).vector()
        self.ub = interpolate(Constant(1.), V).vector()
Esempio n. 6
0
    def __init__(self, energy, state, bcs):
        """
        Initialises the elasticity problem.

        Arguments:
            * energy
            * state
            * boundary conditions
        """
        # Initialize the parent
        NonlinearProblem.__init__(self)
        self.bcs = bcs
        self.state = state
        # import pdb; pdb.set_trace()
        u = state['u']

        V = u.function_space()
        v = TestFunction(V)
        du = TrialFunction(V)

        self.residual = derivative(energy, u, v)
        self.jacobian = derivative(self.residual, u, du)
Esempio n. 7
0
 def __init__(self, a, L):
     NonlinearProblem.__init__(self)
     self.L = L
     self.a = a
     self._F = None
     self._J = None