Actual source code: daimpl.h

  1: #pragma once

  3: #include <petscda.h>
  4: #include <petsc/private/petscimpl.h>
  5: #include <petsc/private/hashmapi.h>

  7: PETSC_EXTERN PetscClassId PETSCDA_CLASSID;

  9: typedef struct _PetscDAOps *PetscDAOps;
 10: struct _PetscDAOps {
 11:   PetscErrorCode (*destroy)(PetscDA);
 12:   PetscErrorCode (*setup)(PetscDA);
 13:   PetscErrorCode (*view)(PetscDA, PetscViewer);
 14:   PetscErrorCode (*setfromoptions)(PetscDA, PetscOptionItems *);
 15: };

 17: struct _p_PetscDA {
 18:   PETSCHEADER(struct _PetscDAOps);
 19:   PetscInt obs_size;         /* Observation vector dimension (p) */
 20:   PetscInt local_obs_size;   /* Local observation vector dimension */
 21:   PetscInt state_size;       /* State vector dimension (n) */
 22:   PetscInt local_state_size; /* Local state vector dimension */
 23:   Vec      obs_error_var;    /* Observation error variance (diagonal of R), length p */
 24:   Mat      R;                /* Observation error covariance matrix (p x p) */
 25:   PetscInt ndof;             /* Number of degrees of freedom per grid point; must be the same for all grid points */
 26:   void    *data;
 27: };

 29: /* data common to all the ensemble based PetscDAType */
 30: typedef struct {
 31:   PetscErrorCode (*analysis)(PetscDA, Vec, Mat);
 32:   PetscErrorCode (*forecast)(PetscDA, PetscErrorCode (*)(Vec, Vec, PetscCtx), PetscCtx);
 33:   PetscInt  size;      /* Number of ensemble members (m) */
 34:   Mat       ensemble;  /* Ensemble matrix (n x m) */
 35:   PetscReal inflation; /* Inflation factor */

 37:   /* Algorithm state */
 38:   PetscBool assembled; /* Is the PetscDA object assembled/ready */

 40:   /* T-matrix factorization data (shared across implementations) */
 41:   PetscDASqrtType sqrt_type;       /* Square root factorization type */
 42:   Mat             V;               /* Eigen vectors (LAPACK column-major storage) */
 43:   Mat             L_cholesky;      /* Lower triangular Cholesky factor */
 44:   Vec             sqrt_eigen_vals; /* Square root of eigen values */
 45:   Mat             I_StS;           /* T = I + S^T * S matrix */
 46: } PetscDA_Ensemble;

 48: /* Internal utility functions shared across PetscDA implementations */
 49: PETSC_INTERN PetscErrorCode PetscDASymmetricEigenSqrt_Private(Mat, Mat *);