19 #ifndef IP_SSATAUCTIKHONOVGN_HH_SIU7F33G
20 #define IP_SSATAUCTIKHONOVGN_HH_SIU7F33G
22 #include "pism/inverse/IP_SSATaucForwardProblem.hh"
23 #include "pism/util/TerminationReason.hh"
24 #include "pism/util/error_handling.hh"
25 #include "pism/util/petscwrappers/KSP.hh"
26 #include "pism/inverse/functional/IPFunctional.hh"
31 template<
class C,
void (C::*MultiplyCallback)(Vec,Vec) >
36 ierr = MatShellSetOperation(A, MATOP_MULT,
38 PISM_CHK(ierr,
"MatShellSetOperation");
41 static PetscErrorCode
callback(Mat A, Vec x, Vec y) {
44 PetscErrorCode ierr = MatShellGetContext(A,&ctx);
45 PISM_CHK(ierr,
"MatShellGetContext");
46 (ctx->*MultiplyCallback)(x,y);
48 MPI_Comm com = MPI_COMM_SELF;
49 PetscErrorCode ierr = PetscObjectGetComm((PetscObject)A, &com); CHKERRQ(ierr);
51 SETERRQ(com, 1,
"A PISM callback failed");
92 virtual void apply_GN(Vec h, Vec out);
94 virtual std::shared_ptr<TerminationReason>
init();
98 virtual std::shared_ptr<TerminationReason>
solve();
110 virtual std::shared_ptr<TerminationReason>
linesearch();
130 std::shared_ptr<DesignVecGhosted>
m_d;
std::shared_ptr< const Logger > ConstPtr
Abstract base class for IPFunctionals arising from an inner product.
virtual std::shared_ptr< array::Vector > solution()
Returns the last solution of the SSA as computed by linearize_at.
Implements the forward problem of the map taking to the corresponding solution of the SSA.
const unsigned int m_state_stencil_width
virtual std::shared_ptr< TerminationReason > linesearch()
virtual void apply_GN(array::Scalar &h, array::Scalar &out)
virtual void evaluateGNFunctional(DesignVec &h, double *value)
virtual void setInitialGuess(DesignVec &d)
virtual void assemble_GN_rhs(DesignVec &out)
virtual std::shared_ptr< TerminationReason > init()
DesignVecGhosted m_tmp_D2Local
std::shared_ptr< DesignVecGhosted > m_d
virtual std::shared_ptr< TerminationReason > evaluate_objective_and_gradient()
DesignVecGhosted m_d_diff_lin
IPInnerProductFunctional< StateVec > & m_stateFunctional
virtual std::shared_ptr< DesignVec > designSolution()
DesignVec m_dh_dalphaGlobal
IPInnerProductFunctional< DesignVec > & m_designFunctional
DesignVecGhosted m_tmp_D1Local
virtual std::shared_ptr< TerminationReason > compute_dlogalpha(double *dalpha)
DesignVecGhosted m_d_diff
virtual std::shared_ptr< TerminationReason > solve()
const unsigned int m_design_stencil_width
array::Scalar1 DesignVecGhosted
virtual std::shared_ptr< TerminationReason > check_convergence()
virtual std::shared_ptr< TerminationReason > solve_linearized()
~IP_SSATaucTikhonovGNSolver()=default
IP_SSATaucForwardProblem & m_ssaforward
virtual void setTargetMisfit(double misfit)
Sets the desired target misfit (in units of ).
virtual std::shared_ptr< StateVec > stateSolution()
IP_SSATaucTikhonovGNSolver(IP_SSATaucForwardProblem &ssaforward, DesignVec &d0, StateVec &u_obs, double eta, IPInnerProductFunctional< DesignVec > &designFunctional, IPInnerProductFunctional< StateVec > &stateFunctional)
static void connect(Mat A)
static PetscErrorCode callback(Mat A, Vec x, Vec y)
#define PISM_CHK(errcode, name)
void handle_fatal_errors(MPI_Comm com)