28 class BoundaryConditionManager;
29 class FiniteElementState;
30 class FiniteElementDual;
32 struct NonlinearSolverOptions;
33 struct LinearSolverOptions;
51 virtual std::shared_ptr<smith::FiniteElementState>
solve(
77 std::shared_ptr<smith::FiniteElementState>
solve(
100 std::shared_ptr<smith::FiniteElementState>
solve(
105 std::shared_ptr<smith::FiniteElementState>
solveAdjoint(
111 mutable std::unique_ptr<mfem::HypreParMatrix>
J_;
112 mutable std::unique_ptr<EquationSolver>
127 using MatrixPtr = std::unique_ptr<mfem::HypreParMatrix>;
139 virtual std::vector<FieldPtr>
solve(
140 const std::vector<FieldPtr>& u_guesses,
141 std::function<std::vector<mfem::Vector>(
const std::vector<FieldPtr>&)> residuals,
142 std::function<std::vector<std::vector<MatrixPtr>>(
const std::vector<FieldPtr>&)> jacobians)
const = 0;
148 virtual std::vector<FieldPtr>
solveAdjoint(
const std::vector<DualPtr>& u_bars,
149 std::vector<std::vector<MatrixPtr>>& jacobian_transposed)
const = 0;
166 std::vector<FieldPtr>
solve(
167 const std::vector<FieldPtr>& u_guesses,
168 std::function<std::vector<mfem::Vector>(
const std::vector<FieldPtr>&)> residuals,
169 std::function<std::vector<std::vector<MatrixPtr>>(
const std::vector<FieldPtr>&)> jacobians)
const override;
172 std::vector<FieldPtr>
solveAdjoint(
const std::vector<DualPtr>& u_bars,
173 std::vector<std::vector<MatrixPtr>>& jacobian_transposed)
const override;
190 std::vector<FieldPtr>
solve(
191 const std::vector<FieldPtr>& u_guesses,
192 std::function<std::vector<mfem::Vector>(
const std::vector<FieldPtr>&)> residuals,
193 std::function<std::vector<std::vector<MatrixPtr>>(
const std::vector<FieldPtr>&)> jacobians)
const override;
196 std::vector<FieldPtr>
solveAdjoint(
const std::vector<DualPtr>& u_bars,
197 std::vector<std::vector<MatrixPtr>>& jacobian_transposed)
const override;
199 mutable std::unique_ptr<mfem::BlockOperator>
201 mutable std::vector<std::vector<MatrixPtr>>
205 mutable std::unique_ptr<EquationSolver>
Abstract interface to DifferentiableBlockSolver interface. Each differentiable block solve should pro...
virtual std::vector< FieldPtr > solveAdjoint(const std::vector< DualPtr > &u_bars, std::vector< std::vector< MatrixPtr >> &jacobian_transposed) const =0
Solve the (linear) adjoint set of equations with a vector of FiniteElementState as unknown.
std::shared_ptr< FieldD > DualPtr
using
virtual std::vector< FieldPtr > solve(const std::vector< FieldPtr > &u_guesses, std::function< std::vector< mfem::Vector >(const std::vector< FieldPtr > &)> residuals, std::function< std::vector< std::vector< MatrixPtr >>(const std::vector< FieldPtr > &)> jacobians) const =0
Solve a set of equations with a vector of FiniteElementState as unknown.
virtual ~DifferentiableBlockSolver()
destructor
virtual void clearMemory() const
Interface option to clear memory between solves to avoid high-water mark memory usage.
std::unique_ptr< mfem::HypreParMatrix > MatrixPtr
using
virtual void completeSetup(const std::vector< FieldT > &us)=0
Required for certain solvers/preconditions, e.g. when multigrid algorithms want a near null-space For...
std::shared_ptr< FieldT > FieldPtr
using
Abstract interface to DifferentiableSolver interface. Each differentiable solve should provide both i...
virtual std::shared_ptr< smith::FiniteElementState > solve(const smith::FiniteElementState &u_guess, std::function< mfem::Vector(const smith::FiniteElementState &)> equation, std::function< std::unique_ptr< mfem::HypreParMatrix >(const smith::FiniteElementState &)> jacobian) const =0
Solve a set of equations with a FiniteElementState as unknown.
virtual std::shared_ptr< smith::FiniteElementState > solveAdjoint(const smith::FiniteElementDual &u_bar, std::unique_ptr< mfem::HypreParMatrix > jacobian_transposed) const =0
Solve the (linear) adjoint set of equations with a FiniteElementState as unknown.
virtual void completeSetup(const smith::FiniteElementState &u)=0
Required for certain solvers/preconditioners, e.g. when multigrid algorithms want a near null-space F...
virtual void clearMemory() const
Interface option to clear memory between solves to avoid high-water mark memory usage.
virtual ~DifferentiableSolver()
destructor
Class for encapsulating the dual vector space of a finite element space (i.e. the space of linear for...
Class for encapsulating the critical MFEM components of a primal finite element field.
Implementation of the DifferentiableBlockSolver interface for the special case of linear solves with ...
std::vector< FieldPtr > solve(const std::vector< FieldPtr > &u_guesses, std::function< std::vector< mfem::Vector >(const std::vector< FieldPtr > &)> residuals, std::function< std::vector< std::vector< MatrixPtr >>(const std::vector< FieldPtr > &)> jacobians) const override
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::unique_ptr< mfem::Solver > mfem_preconditioner
stored mfem block preconditioner
std::vector< FieldPtr > solveAdjoint(const std::vector< DualPtr > &u_bars, std::vector< std::vector< MatrixPtr >> &jacobian_transposed) const override
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::unique_ptr< mfem::Solver > mfem_solver
stored mfem block solver
LinearDifferentiableBlockSolver(std::unique_ptr< mfem::Solver > s, std::unique_ptr< mfem::Solver > p)
Construct from a linear solver and linear block precondition which may be used by the linear solver.
void completeSetup(const std::vector< FieldT > &us) override
This is an overloaded member function, provided for convenience. It differs from the above function o...
Implementation of the DifferentiableSolver interface for the special case of linear solves with linea...
std::unique_ptr< mfem::Solver > mfem_preconditioner
optionally used preconditioner
std::shared_ptr< smith::FiniteElementState > solve(const smith::FiniteElementState &u_guess, std::function< mfem::Vector(const smith::FiniteElementState &)> equation, std::function< std::unique_ptr< mfem::HypreParMatrix >(const smith::FiniteElementState &)> jacobian) const override
This is an overloaded member function, provided for convenience. It differs from the above function o...
void completeSetup(const smith::FiniteElementState &u) override
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::unique_ptr< mfem::Solver > mfem_solver
linear solver
LinearDifferentiableSolver(std::unique_ptr< mfem::Solver > s, std::unique_ptr< mfem::Solver > p)
Construct from a linear solver and linear precondition which may also be used by a nonlinear solver.
std::shared_ptr< smith::FiniteElementState > solveAdjoint(const smith::FiniteElementDual &u_bar, std::unique_ptr< mfem::HypreParMatrix > jacobian_transposed) const override
This is an overloaded member function, provided for convenience. It differs from the above function o...
Helper class for constructing a mesh consistent with Smith.
Implementation of the DifferentiableBlockSolver interface for the special case of nonlinear solves wi...
std::vector< std::vector< MatrixPtr > > matrix_of_jacs_
void completeSetup(const std::vector< FieldT > &us) override
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::vector< FieldPtr > solveAdjoint(const std::vector< DualPtr > &u_bars, std::vector< std::vector< MatrixPtr >> &jacobian_transposed) const override
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::vector< FieldPtr > solve(const std::vector< FieldPtr > &u_guesses, std::function< std::vector< mfem::Vector >(const std::vector< FieldPtr > &)> residuals, std::function< std::vector< std::vector< MatrixPtr >>(const std::vector< FieldPtr > &)> jacobians) const override
This is an overloaded member function, provided for convenience. It differs from the above function o...
NonlinearDifferentiableBlockSolver(std::unique_ptr< EquationSolver > s)
Construct from a linear solver and linear block precondition which may be used by the linear solver.
std::unique_ptr< mfem::BlockOperator > block_jac_
Need to hold an instance of a block operator to work with the mfem solver interface.
std::unique_ptr< EquationSolver > nonlinear_solver_
the nonlinear equation solver used for the forward pass
Implementation of the DifferentiableSolver interface for the special case of nonlinear solves with li...
std::shared_ptr< smith::FiniteElementState > solveAdjoint(const smith::FiniteElementDual &u_bar, std::unique_ptr< mfem::HypreParMatrix > jacobian_transposed) const override
This is an overloaded member function, provided for convenience. It differs from the above function o...
void completeSetup(const smith::FiniteElementState &u) override
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::unique_ptr< mfem::HypreParMatrix > J_
stored linearized Jacobian matrix for memory reuse
void clearMemory() const override
This is an overloaded member function, provided for convenience. It differs from the above function o...
NonlinearDifferentiableSolver(std::unique_ptr< EquationSolver > s)
Consruct from a smith nonlinear EquationSolver.
std::unique_ptr< EquationSolver > nonlinear_solver_
the nonlinear equation solver used for the forward pass
std::shared_ptr< smith::FiniteElementState > solve(const smith::FiniteElementState &u_guess, std::function< mfem::Vector(const smith::FiniteElementState &)> equation, std::function< std::unique_ptr< mfem::HypreParMatrix >(const smith::FiniteElementState &)> jacobian) const override
This is an overloaded member function, provided for convenience. It differs from the above function o...
Accelerator functionality.
std::shared_ptr< NonlinearDifferentiableSolver > buildDifferentiableNonlinearSolver(NonlinearSolverOptions nonlinear_opts, LinearSolverOptions linear_opts, const smith::Mesh &mesh)
Create a differentiable nonlinear solver.
std::shared_ptr< LinearDifferentiableSolver > buildDifferentiableLinearSolver(LinearSolverOptions linear_opts, const smith::Mesh &mesh)
Create a differentiable linear solver.
std::shared_ptr< NonlinearDifferentiableBlockSolver > buildDifferentiableNonlinearBlockSolver(NonlinearSolverOptions nonlinear_opts, LinearSolverOptions linear_opts, const smith::Mesh &mesh)
Create a differentiable nonlinear block solver.
Parameters for an iterative linear solution scheme.
Nonlinear solution scheme parameters.