11 #ifndef _INVERSE_VI_VEL_SOLVER_H_ 12 #define _INVERSE_VI_VEL_SOLVER_H_ 15 #include "LevelDataOps.H" 22 #include "NamespaceHeader.H" 38 static void copyAMR ( Vector<RefCountedPtr<LevelData<FArrayBox> > >&a_copy,
39 const Vector<LevelData<FArrayBox>*>& a_orig )
43 for (
int lev = 0; lev < a_orig.size(); lev++)
47 const DisjointBoxLayout& dbl = a_orig[lev]->disjointBoxLayout();
48 LevelData<FArrayBox>* lptr =
new LevelData<FArrayBox>
49 (dbl, a_orig[lev]->nComp(),a_orig[lev]->ghostVect());
50 for (DataIterator dit(dbl); dit.ok(); ++dit)
52 (*lptr)[dit].copy( (*a_orig[lev])[dit]);
54 a_copy.push_back(RefCountedPtr<LevelData<FArrayBox> >( lptr));
73 (
const Vector<LevelData<FArrayBox>*>& a_C,
const Vector<int>& a_ratio,
const RealVect& a_dxCrse )
75 Vector<RefCountedPtr<LevelData<FArrayBox> > > C;
90 (
const Vector<LevelData<FArrayBox>*>& a_mu,
const Vector<int>& a_ratio,
const RealVect& a_dxCrse )
92 Vector<RefCountedPtr<LevelData<FArrayBox> > > mu;
176 void parse(
const char* a_prefix =
"control");
341 Vector<LevelDataOps<FArrayBox> > m_vectOps;
345 void create(Vector<LevelData<T>*>& a_data,
346 const int a_ncomp,
const IntVect& a_ghost)
348 if (a_data.size() <= m_finest_level)
349 a_data.resize(m_finest_level+1);
351 for (
int lev =0; lev <= m_finest_level; lev++)
353 if (a_data[lev] != NULL)
355 a_data[lev] =
new LevelData<T>(m_grids[lev], a_ncomp, a_ghost);
361 void free(Vector<LevelData<T>*>& a_data)
363 for (
int lev =0; lev < a_data.size(); lev++)
365 if (a_data[lev] != NULL)
374 void setToZero(Vector<LevelData<FArrayBox>* >& a_a);
377 void mapX(
const Vector<LevelData<FArrayBox>* >& a_x);
380 (
const std::string& a_file,
int a_counter,
381 const Vector<LevelData<FArrayBox>* >& a_x,
382 const Vector<LevelData<FArrayBox>* >& a_g)
const;
389 void computeAdjointRhs();
392 void computeGradient(Vector<LevelData<FArrayBox>* >& a_g,
393 const Vector<LevelData<FArrayBox>* >& a_x);
396 void regularizeGradient(Vector<LevelData<FArrayBox>* >& a_g,
397 const Vector<LevelData<FArrayBox>* >& a_x);
400 void applyProjection(Vector<LevelData<FArrayBox>* >& a_g,
401 const Vector<LevelData<FArrayBox>* >& a_x);
404 void solveStressEqn (Vector<LevelData<FArrayBox>* >& a_u,
405 const bool a_adjoint,
406 const Vector<LevelData<FArrayBox>* >& a_rhs,
407 const Vector<LevelData<FArrayBox>* >& a_C,
408 const Vector<LevelData<FArrayBox>* >& a_C0,
409 const Vector<LevelData<FArrayBox>* >& a_A,
410 const Vector<LevelData<FArrayBox>* >& a_muCoef);
420 return (m_time > m_prev_time + TINY_NORM)?( 1.0 / (m_time-m_prev_time)):0.0;
424 Real X0Regularization()
430 Real X1Regularization()
435 int m_innerCounter, m_outerCounter;
437 bool m_velocityInitialised;
443 Vector<DisjointBoxLayout> m_grids;
446 Vector<int> m_refRatio;
449 Vector<RealVect> m_dx;
452 Vector<ProblemDomain> m_domain;
455 std::string outerStateFile()
const;
458 std::string innerStateFile()
const;
461 Vector<RefCountedPtr<LevelSigmaCS > > m_coordSys;
464 Vector<LevelData<FArrayBox>*> m_A;
467 Vector<LevelData<FArrayBox>*> m_C0;
471 Vector<LevelData<FArrayBox>*> m_COrigin;
472 Vector<LevelData<FArrayBox>*> m_C ;
473 Vector<LevelData<FArrayBox>*> m_Cmasked ;
474 Vector<LevelData<FArrayBox>*> m_lapC;
475 Vector<LevelData<FArrayBox>*> m_gradCSq;
479 Vector<LevelData<FArrayBox>*> m_muCoefOrigin;
480 Vector<LevelData<FArrayBox>*> m_muCoef ;
481 Vector<LevelData<FArrayBox>*> m_lapMuCoef;
482 Vector<LevelData<FArrayBox>*> m_gradMuCoefSq;
486 Vector<LevelData<FArrayBox>*> m_lapX;
487 Vector<LevelData<FArrayBox>*> m_gradXSq;
490 Vector<LevelData<FArrayBox>*> m_rhs;
493 Vector<LevelData<FArrayBox>*> m_adjRhs;
496 Vector<LevelData<FArrayBox>*> m_adjVel;
499 Vector<LevelData<FArrayBox>*> m_velObs;
502 Vector<LevelData<FArrayBox>*> m_velCoef;
505 Vector<LevelData<FArrayBox>*> m_divuhObs;
508 Vector<LevelData<FArrayBox>*> m_divuhCoef;
511 Vector<LevelData<FArrayBox>*> m_velb;
514 Vector<LevelData<FArrayBox>*> m_vels;
517 Vector<LevelData<FArrayBox>*> m_divuh;
520 Vector<LevelData<FArrayBox>*> m_velocityMisfit;
523 Vector<LevelData<FArrayBox>*> m_divuhMisfit;
531 Vector<LevelData<FArrayBox>*> m_bestVel;
532 Vector<LevelData<FArrayBox>*> m_bestC;
533 Vector<LevelData<FArrayBox>*> m_bestMuCoef;
534 bool m_optimization_done;
539 Vector<LevelData<FArrayBox>* > m_calvedIce, m_addedIce, m_removedIce;
549 m_prev_time = a_time;
552 void define(
const ProblemDomain& a_coarseDomain,
555 const Vector<DisjointBoxLayout>& a_grids,
556 const Vector<int>& a_refRatio,
557 const RealVect& a_dxCrse,
561 MayDay::Error(
"not sure why we got here...");
565 const ProblemDomain& a_coarseDomain,
568 const Vector<DisjointBoxLayout>& a_grids,
569 const Vector<int>& a_refRatio,
570 const RealVect& a_dxCrse,
575 int solve(Vector<LevelData<FArrayBox>* >& a_horizontalVel,
576 Vector<LevelData<FArrayBox>* >& a_calvedIce,
577 Vector<LevelData<FArrayBox>* >& a_addedIce,
578 Vector<LevelData<FArrayBox>* >& a_removedIce,
579 Real& a_initialResidualNorm, Real& a_finalResidualNorm,
580 const Real a_convergenceMetric,
581 const Vector<LevelData<FArrayBox>* >& a_rhs,
582 const Vector<LevelData<FArrayBox>* >& a_C,
583 const Vector<LevelData<FArrayBox>* >& a_C0,
584 const Vector<LevelData<FArrayBox>* >& a_A,
585 const Vector<LevelData<FArrayBox>* >& a_muCoef,
586 Vector<RefCountedPtr<LevelSigmaCS > >& a_coordSys,
588 int a_lbase,
int a_maxLevel);
594 void computeObjectiveAndGradient
595 (Real& a_fm, Real& a_fp,
596 Vector<LevelData<FArrayBox>* >& a_g,
597 const Vector<LevelData<FArrayBox>* >& a_x,
603 void create(Vector<LevelData<FArrayBox>* >& a_a,
const Vector<LevelData<FArrayBox>* >& a_b);
606 void preCond(Vector<LevelData<FArrayBox>* >& a_s,
const Vector<LevelData<FArrayBox>* >& a_r);
610 void free(Vector<LevelData<FArrayBox>*>& a_data)
612 free<FArrayBox>(a_data);
617 void plus(Vector<LevelData<FArrayBox>* >& a_a, Real a_r );
620 void scale(Vector<LevelData<FArrayBox>* >& a_x,
624 void assign(Vector<LevelData<FArrayBox>* >& a_y,
625 const Vector<LevelData<FArrayBox>* >& a_x);
628 void incr(Vector<LevelData<FArrayBox>* >& y,
629 const Vector<LevelData<FArrayBox>* >& x, Real s);
632 Real dotProduct(Vector<LevelData<FArrayBox>* >& a_y,
633 const Vector<LevelData<FArrayBox>* >& a_x);
636 int nDoF(
const Vector<LevelData<FArrayBox>* >& x);
641 if (m_optimization_done)
649 if (m_optimization_done)
657 #include "NamespaceFooter.H" bool m_writeInnerSteps
write inner (secant) steps to plot files
Definition: InverseVerticallyIntegratedVelocitySolver.H:313
Real m_CGtol
Tolerance for the 'outer' nonlinear conjugate gradient method. Set with <prefix>.CGtol, default 1.0e-3.
Definition: InverseVerticallyIntegratedVelocitySolver.H:281
Implementation of InverseIceVelocitySolver for the vertically integrated (SSA,SSA*,L1L2) stress models.
Definition: InverseVerticallyIntegratedVelocitySolver.H:157
Real m_X0Regularization
Coefficient of in . Set with <prefix>.X0Regularization.
Definition: InverseVerticallyIntegratedVelocitySolver.H:263
Real m_dtTypical
estimate of typical timestep. Just here to turn times into integers for file names ...
Definition: InverseVerticallyIntegratedVelocitySolver.H:197
Real m_initialLowerMuCoef
Lower bound on . Set with <prefix>.initialLowerMuCoef.
Definition: InverseVerticallyIntegratedVelocitySolver.H:227
Real m_X1TimeRegularization
Coefficient of in . Set with <prefix>.X1TimeRegularization.
Definition: InverseVerticallyIntegratedVelocitySolver.H:272
Definition: MuCoefficient.H:230
Definition: MuCoefficient.H:25
SurfaceData * m_velObs_x
observed x-velocity data
Definition: InverseVerticallyIntegratedVelocitySolver.H:305
SurfaceData * m_velObs_c
observed velocity data coefficient
Definition: InverseVerticallyIntegratedVelocitySolver.H:302
SurfaceData * m_divuhObs_c
observed flux divergence data coefficient
Definition: InverseVerticallyIntegratedVelocitySolver.H:322
Real m_lowerX0
Lower bound on . Set with with <prefix>.lowerX0.
Definition: InverseVerticallyIntegratedVelocitySolver.H:215
std::string m_innerStepFileNameBase
base of filename for 'inner' plots
Definition: InverseVerticallyIntegratedVelocitySolver.H:316
Abstract class to manage the nonlinear solve for the ice-sheet momentum.
Definition: IceVelocitySolver.H:32
Real m_gradX1sqRegularization
Coefficient of in . Set with <prefix>.gradX1sqRegularization.
Definition: InverseVerticallyIntegratedVelocitySolver.H:260
Real m_gradCsqRegularization
Coefficient of in . Set with <prefix>.gradCsqRegularization.
Definition: InverseVerticallyIntegratedVelocitySolver.H:248
Abstract class around the englacial constitutive relations for ice.
Definition: ConstitutiveRelation.H:34
void setPreviousTime(Real a_time)
Definition: InverseVerticallyIntegratedVelocitySolver.H:547
BasalFriction * basalFriction()
Create a BasalFriction object containing the solution .
Definition: InverseVerticallyIntegratedVelocitySolver.H:638
VelocityMisfitType m_velMisfitType
Type of velocity misfit : speed, velocity, or log_speed. Set with <prefix>.vel_misfit_type, default speed.
Definition: InverseVerticallyIntegratedVelocitySolver.H:205
virtual MuCoefficient * muCoefficient()=0
is the basal friction an improvement on the initial guess?
BasalFriction that computes from data on a non-uniform grid.
Definition: LevelDataBasalFriction.H:129
Real m_thicknessThreshold
Limit domain of integration to regions where ice thickness exceeds this value. Set with <prefix>...
Definition: InverseVerticallyIntegratedVelocitySolver.H:275
Real m_CGsecantTol
Tolerance for the 'inner' secant method. Set with <prefix>.CGsecantTol, default 1.0e-1.
Definition: InverseVerticallyIntegratedVelocitySolver.H:293
Real m_divuhMisfitCoefficient
Coefficient of in . Set with <prefix>.divuhMisfitCoefficient default 1.0.
Definition: InverseVerticallyIntegratedVelocitySolver.H:242
Physical/domain initial and boundary conditions for ice-sheet problems.
Definition: IceThicknessIBC.H:84
Real m_initialUpperMuCoef
Upper bound on . Set with <prefix>.initialUpperMuCoef.
Definition: InverseVerticallyIntegratedVelocitySolver.H:230
Real m_X0TimeRegularization
Coefficient of in . Set with <prefix>.X0TimeRegularization.
Definition: InverseVerticallyIntegratedVelocitySolver.H:269
Real m_initialLowerC
Lower bound on . Set with <prefix>.initialLowerC.
Definition: InverseVerticallyIntegratedVelocitySolver.H:233
Real m_minTimeBetweenOptimizations
Definition: InverseVerticallyIntegratedVelocitySolver.H:194
SurfaceData * m_gradientFactor
used to amplify (damp) the gradient non-uniformly
Definition: InverseVerticallyIntegratedVelocitySolver.H:328
VelocityMisfitType
Definition: InverseVerticallyIntegratedVelocitySolver.H:203
Definition: InverseVerticallyIntegratedVelocitySolver.H:199
int m_CGsecantMaxIter
Maximum number of 'outer' secant iterations. Set with <prefix>.CGsecantMaxIter, default 20...
Definition: InverseVerticallyIntegratedVelocitySolver.H:290
Real m_CGhang
Give up when succesive CG steps don't progress quickly enough . Set with <prefix>.CGhang, default 0.999.
Definition: InverseVerticallyIntegratedVelocitySolver.H:296
virtual void setPreviousTime(Real a_time)=0
Real m_CGrestartInterval
Restart CG at a fixed interval. Set with <prefix>.CGrestartInterval, default 9999.
Definition: InverseVerticallyIntegratedVelocitySolver.H:299
BoundMethod m_boundMethod
Method to enforce constraints: none, or projection. default projection.
Definition: InverseVerticallyIntegratedVelocitySolver.H:201
std::string m_outerStepFileNameBase
base of filename for 'outer' plots
Definition: InverseVerticallyIntegratedVelocitySolver.H:319
Real m_gradMuCoefsqRegularization
Coefficient of in . Set with <prefix>.gradMuCoefsqRegularization.
Definition: InverseVerticallyIntegratedVelocitySolver.H:251
int m_outerCounter
Definition: InverseVerticallyIntegratedVelocitySolver.H:330
Real m_upperX0
Upper bound on . Set with with <prefix>.upperX0.
Definition: InverseVerticallyIntegratedVelocitySolver.H:218
Real m_CGsecantStepMaxGrow
such that secant step has a maximum length . Set with <prefix>.CGsecantStepMaxGrow, default 2.0
Definition: InverseVerticallyIntegratedVelocitySolver.H:287
Real m_initialUpperC
Upper bound on . Set with <prefix>.initialUpperC.
Definition: InverseVerticallyIntegratedVelocitySolver.H:236
virtual void define(const ProblemDomain &a_coarseDomain, ConstitutiveRelation *a_constRel, BasalFrictionRelation *a_FrictionRel, const Vector< DisjointBoxLayout > &a_vectGrids, const Vector< int > &a_vectRefRatio, const RealVect &a_dxCrse, IceThicknessIBC *a_bc, int a_numLevels)=0
(Re-)define IceVelocitySolver object for a given mesh and set of physics rules
Real m_upperX1
Upper bound on . Set with with <prefix>.upperX1.
Definition: InverseVerticallyIntegratedVelocitySolver.H:224
Data read through ParmParse.
Definition: InverseVerticallyIntegratedVelocitySolver.H:164
MuCoefficient * muCoefficient()
is the basal friction an improvement on the initial guess?
Definition: InverseVerticallyIntegratedVelocitySolver.H:646
abstract class defining the surface flux interface
Definition: SurfaceFlux.H:39
Real m_lowerX1
Lower bound on . Set with with <prefix>.lowerX1.
Definition: InverseVerticallyIntegratedVelocitySolver.H:221
Specify operations required to carry out gradient based optimization.
Definition: CGOptimize.H:32
Real m_gradX0sqRegularization
Coefficient of in . Set with <prefix>.gradX0sqRegularization.
Definition: InverseVerticallyIntegratedVelocitySolver.H:257
SurfaceData * m_divuhObs_a
observed flux divergence data
Definition: InverseVerticallyIntegratedVelocitySolver.H:325
int m_minLevelForOptimization
Do not attempt to optimize unless the mesh has at least m_minLevel levels.
Definition: InverseVerticallyIntegratedVelocitySolver.H:190
virtual int solve(Vector< LevelData< FArrayBox > * > &a_horizontalVel, Vector< LevelData< FArrayBox > * > &a_calvedIce, Vector< LevelData< FArrayBox > * > &a_addedIce, Vector< LevelData< FArrayBox > * > &a_removedIce, Real &a_initialResidualNorm, Real &a_finalResidualNorm, const Real a_convergenceMetric, const Vector< LevelData< FArrayBox > * > &a_rhs, const Vector< LevelData< FArrayBox > * > &a_C, const Vector< LevelData< FArrayBox > * > &a_C0, const Vector< LevelData< FArrayBox > * > &a_A, const Vector< LevelData< FArrayBox > * > &a_muCoef, Vector< RefCountedPtr< LevelSigmaCS > > &a_coordSys, Real a_time, int a_lbase, int a_maxLevel)=0
Compute the horizontal, cell centered ice velocity ( u(x,y), v(x,y) ) [VERTICALLY INTEGRATED MODELS!]...
bool m_gradMuCoefShelfOnly
evaluate unregluarized gradient of objective with respect to mucoef (or rather, X1) in the shelf only...
Definition: InverseVerticallyIntegratedVelocitySolver.H:212
Virtual base class for basal friction relations.
Definition: BasalFrictionRelation.H:27
bool m_optimizeX0
attempt to optimize w.r.t X0?
Definition: InverseVerticallyIntegratedVelocitySolver.H:208
void define(const ProblemDomain &a_coarseDomain, ConstitutiveRelation *a_constRel, BasalFrictionRelation *a_FrictionRel, const Vector< DisjointBoxLayout > &a_grids, const Vector< int > &a_refRatio, const RealVect &a_dxCrse, IceThicknessIBC *a_bc, int a_numLevels)
(Re-)define IceVelocitySolver object for a given mesh and set of physics rules
Definition: InverseVerticallyIntegratedVelocitySolver.H:552
void restart()
carry out whatver operations are required prior to a restart
Definition: InverseVerticallyIntegratedVelocitySolver.H:600
void free(Vector< LevelData< FArrayBox > *> &a_data)
need to make this explicit
Definition: InverseVerticallyIntegratedVelocitySolver.H:610
Real m_CGsecantParameter
Size of the initial 'inner' secant step. Set with <prefix>.CGsecantParameter, default 1...
Definition: InverseVerticallyIntegratedVelocitySolver.H:284
bool m_optimizeX1
attempt to optimize w.r.t X1?
Definition: InverseVerticallyIntegratedVelocitySolver.H:210
Real m_CGmaxIter
Maximum number of 'outer' nonlinear conjugate gradient iterations. Set with <prefix>.CGmaxIter, default 16.
Definition: InverseVerticallyIntegratedVelocitySolver.H:278
Abstract subclass of IceVelocitySolver that supports inverse velocity problems.
Definition: InverseVerticallyIntegratedVelocitySolver.H:35
virtual BasalFriction * basalFriction()=0
Create a BasalFriction object containing the solution .
Definition: BasalFriction.H:28
abstract base class for amr ice sheet models (AmrIce, AMRIceControl)
Definition: AmrIceBase.H:21
BoundMethod
Definition: InverseVerticallyIntegratedVelocitySolver.H:199
Real m_divuhMisfitSmooth
If , smooth . Set with <prefix>.divuhMisfitSmooth, default 0.0.
Definition: InverseVerticallyIntegratedVelocitySolver.H:245
Real m_X1Regularization
Coefficient of in . Set with <prefix>.X1Regularization.
Definition: InverseVerticallyIntegratedVelocitySolver.H:266
Real m_velMisfitCoefficient
Coefficient of in . Set with <prefix>.velMisfitCoefficient, default 1.0.
Definition: InverseVerticallyIntegratedVelocitySolver.H:239