12 #include "ParmParse.H" 14 #include "CornerCopier.H" 15 #include "CoarseAverage.H" 16 #include "CoarseAverageFace.H" 17 #include "ExtrapBCF_F.H" 20 #include "NamespaceHeader.H" 29 const DisjointBoxLayout &a_grid,
34 AMRFAS_LDFOp( a_o, a_grid ),
35 m_constThetaVal(238.15),
36 m_vtopSafety(VTOP_DEFAULT_SAFETY),
37 m_constRelPtr(a_constRelPtr),
38 m_basalFrictionRelPtr(a_basalFrictionRelPtr),
43 m_Beta = RefCountedPtr<LevelData<FArrayBox> >(
new LevelData<FArrayBox>(a_grid,
46 m_Beta0 = RefCountedPtr<LevelData<FArrayBox> >(
new LevelData<FArrayBox>(a_grid,
56 const LevelData<FArrayBox>& a_phiCoarse )
58 m_VTO->cfinterp( a_phi, a_phiCoarse );
66 const LevelData<FArrayBox>& a_phi )
68 CH_TIME(
"FASIceViscouseTensorOp::applyLevel");
73 LevelData<FArrayBox>& phi = (LevelData<FArrayBox>&)a_phi;
79 scale(
m_VTO->m_relaxCoef, m_smoothing_damping_factor );
83 m_VTO->applyOp( a_lhs, a_phi,
true );
91 const RefCountedPtr<LevelData<FArrayBox> > a_rhs
94 CH_TIME(
"FASIceViscouseTensorOp::levelGSRB");
98 LevelData<FArrayBox>& phi = *a_phi;
103 scale(
m_VTO->m_relaxCoef, m_smoothing_damping_factor );
106 m_VTO->relax( *a_phi, *a_rhs, 1 );
114 const RefCountedPtr<LevelData<FArrayBox> > a_rhs
117 CH_TIME(
"FASIceViscouseTensorOp::levelRich");
119 CH_assert(a_phi->isDefined());
120 CH_assert(a_rhs->isDefined());
121 CH_assert(a_phi->ghostVect() >= IntVect::Unit);
122 CH_assert(a_phi->nComp() == a_rhs->nComp());
126 LevelData<FArrayBox> tmp;
127 create( tmp, *a_rhs );
130 apply( tmp, *a_phi, 0,
false );
133 axby( tmp, tmp, *a_rhs, -1.0, 1.0 );
135 mult( tmp,
m_VTO->m_relaxCoef );
137 axby( *a_phi, *a_phi, tmp, 1.0, omega );
146 CH_TIME(
"FASIceViscouseTensorOp::restrictState");
149 int nRef = fop->refToCoarser();
158 const LevelData<FluxBox> &f_faceA = *fop->
m_faceA;
159 const DisjointBoxLayout& fdbl = fop->m_grid;
160 CH_assert( fdbl.coarsenable(nRef) );
161 const int aNC = fop->
m_faceA->nComp();
164 m_faceA = RefCountedPtr<LevelData<FluxBox> >(
new LevelData<FluxBox>( m_grid,
168 DataIterator dit =
m_faceA->dataIterator();
169 for (dit.begin(); dit.ok(); ++dit)
171 (*m_faceA)[dit].setVal(0.);
176 CoarseAverageFace face_crs( fdbl, aNC, nRef );
177 face_crs.averageToCoarse( *
m_faceA, f_faceA );
181 const LevelData<FArrayBox> &f_beta = *fop->
m_Beta, &f_beta0 = *fop->
m_Beta0;
182 LevelData<FArrayBox> crs_beta, &c_beta = *
m_Beta, &c_beta0 = *
m_Beta0;
184 DisjointBoxLayout dblCoarsenedFine;
185 coarsen( dblCoarsenedFine, f_beta.disjointBoxLayout(), nRef );
186 crs_beta.define( dblCoarsenedFine, f_beta.nComp(), f_beta.ghostVect() );
187 fop->AMRRestrict( c_beta, f_beta, crs_beta, a_copier );
188 fop->AMRRestrict( c_beta0, f_beta0, crs_beta, a_copier );
196 const RefCountedPtr<LevelData<FArrayBox> > a_CrsPhi,
197 const RefCountedPtr<LevelData<FArrayBox> > a_FinePhi
200 CH_TIME(
"FASIceViscouseTensorOp::recomputeState");
203 computeMu( *a_phi, a_CrsPhi, a_FinePhi );
207 scale(
m_VTO->m_relaxCoef, m_smoothing_damping_factor );
217 const LevelData<FArrayBox>& a_phi,
218 LevelData<FArrayBox>& a_residual,
219 AMRFASOp<LevelData<FArrayBox> >* a_finerOp )
221 CH_TIME(
"FASIceViscouseTensorOp::reflux");
226 m_VTO->reflux( a_phiFine,
242 AMRFAS_LDFOpFactory( 1, 2 ),
248 AMRFASOpFactory<LevelData<FArrayBox> >::define( a_bc->
velocitySolveBC() );
255 RefCountedPtr<AMRFASOp<LevelData<FArrayBox> > >
258 RefCountedPtr<FASIceViscouseTensorOp> newOp =
267 AMRFAS_LDFOpFactory::AMRNewOp( a_ilev, newOp,
false );
270 CH_assert(newOp->m_VTO == NULL);
271 CH_assert(m_VTOFactory != NULL);
272 newOp->m_VTO = m_VTOFactory->AMRnewOp( m_domains[a_ilev] );
288 const Vector<DisjointBoxLayout>& a_vectGrids,
289 const Vector<int>& a_vectRefRatio,
290 const RealVect& a_dxCrse,
295 CH_TIME(
"FASIceSolver::define");
301 m_opFactoryPtr = RefCountedPtr<FASIceViscouseTensorOpFactory>
305 AMRFAS<LevelData<FArrayBox> >::define( a_coarseDomain,
320 const RealVect& a_crsDx,
321 const Vector<DisjointBoxLayout>& a_grids,
322 const Vector<int>& a_refRatios,
326 CH_TIME(
"FASIceViscouseTensorOpFactory::define");
329 AMRFASOpFactory<LevelData<FArrayBox> >::define( a_coarseDomain,
337 const Real alpha = -1.0;
338 const Real beta = 1.0;
340 int num_levels = a_grids.size();
341 Vector<RefCountedPtr<LevelData<FluxBox> > > eta(num_levels);
342 Vector<RefCountedPtr<LevelData<FluxBox> > > lambda(num_levels);
343 Vector<RefCountedPtr<LevelData<FArrayBox> > > c(num_levels);
345 for (
int i = 0; i < num_levels; i++)
347 eta[i] = RefCountedPtr<LevelData<FluxBox> >(
new LevelData<FluxBox>( a_grids[i],
351 lambda[i] = RefCountedPtr<LevelData<FluxBox> >(
new LevelData<FluxBox>( a_grids[i],
355 c[i] = RefCountedPtr<LevelData<FArrayBox> >(
new LevelData<FArrayBox>( a_grids[i],
360 DataIterator dit = c[i]->dataIterator();
361 for (dit.begin(); dit.ok(); ++dit)
363 (*c[i])[dit].setVal(1.0);
364 (*lambda[i])[dit].setVal(1.0);
365 (*eta[i])[dit].setVal(1.0);
369 CH_assert(m_VTOFactory == NULL);
372 m_VTOFactory =
new ViscousTensorOpFactory( a_grids,
390 Vector<LevelData<FArrayBox>* >& a_calvedIce,
391 Vector<LevelData<FArrayBox>* >& a_addedIce,
392 Vector<LevelData<FArrayBox>* >& a_removedIce,
393 Real& a_initialResidualNorm,
394 Real& a_finalResidualNorm,
395 const Real a_convergenceMetric,
396 const Vector<LevelData<FArrayBox>* >& a_rhs,
397 const Vector<LevelData<FArrayBox>* >& a_beta,
398 const Vector<LevelData<FArrayBox>* >& a_beta0,
399 const Vector<LevelData<FArrayBox>* >& a_A,
400 const Vector<LevelData<FluxBox>* >& a_muCoef,
401 Vector<RefCountedPtr<LevelSigmaCS > >& a_coordSys,
407 CH_TIME(
"FASIceSolver::solve");
411 for (
int lev = 0; lev < a_maxLevel + 1; ++lev, crs_op = op )
418 op->m_faceA = RefCountedPtr<LevelData<FluxBox> >(
new LevelData<FluxBox>( op->m_grid,
423 LevelData<FArrayBox>& argA = *a_A[lev];
424 CellToEdge( argA, *op->m_faceA );
427 LevelData<FArrayBox>& localBeta = *op->m_Beta;
428 LevelData<FArrayBox>& argBeta = *a_beta[lev];
429 LevelData<FArrayBox>& localBeta0 = *op->m_Beta0;
430 LevelData<FArrayBox>& argBeta0 = *a_beta0[lev];
431 CH_assert(localBeta.nComp() == argBeta.nComp());
433 DataIterator dit = localBeta.dataIterator();
434 for (dit.begin(); dit.ok(); ++dit)
436 localBeta[dit].copy(argBeta[dit]);
437 localBeta0[dit].copy(argBeta0[dit]);
442 op->m_coordSys = a_coordSys[lev];
447 Vector<RefCountedPtr<LevelData<FArrayBox> > > phi(a_maxLevel + 1);
448 Vector<RefCountedPtr<LevelData<FArrayBox> > > rhs(a_maxLevel + 1);
449 for (
int lev = 0; lev < a_maxLevel + 1; ++lev)
451 phi[lev] = RefCountedPtr<LevelData<FArrayBox> >(
new LevelData<FArrayBox>);
452 rhs[lev] = RefCountedPtr<LevelData<FArrayBox> >(
new LevelData<FArrayBox>);
457 phi[lev]->define( op->m_grid, a_horizontalVel[0]->nComp(), a_horizontalVel[0]->ghostVect() );
458 op->assignLocal( *phi[lev], *a_horizontalVel[lev] );
459 rhs[lev]->define( op->m_grid, a_rhs[0]->nComp(), IntVect::Zero );
460 op->assignLocal( *rhs[lev], *a_rhs[lev] );
465 a_finalResidualNorm = AMRFAS<LevelData<FArrayBox> >::solve( phi, rhs, &returnCode );
467 a_initialResidualNorm = 1.0;
470 for (
int lev = 0; lev < a_maxLevel + 1; ++lev)
474 op->assignLocal( *a_horizontalVel[lev], *phi[lev] );
477 if( !m_avoid_norms && m_plot_residual )
480 string fname =
"residualFAS.";
482 sprintf(suffix,
"%dd.hdf5",SpaceDim);
485 Vector<string> varNames(SpaceDim);
486 varNames[0] =
"residual-x";
487 varNames[1] =
"residual-y";
494 Real n1 = op->norm( *phi[a_maxLevel], 0, 0);
495 Real n2 = op->norm( *phi[a_maxLevel], 0, 1);
496 pout() <<
"FASIceSolver::solve plot residual " << m_residual.size() <<
" levels, |phi_x|= " << setprecision(15) << n1 <<
" |phi_y|= " << n2 << endl;
499 Vector<LevelData<FArrayBox>*> res( m_residual.size() );
500 for (
int lev = 0; lev < m_residual.size() ; ++lev)
502 res[lev] = &(*m_temp[lev]);
505 WriteAMRHierarchyHDF5(fname,
506 m_opFactoryPtr->m_grids,
509 m_op[0]->m_domain.domainBox(),
513 m_opFactoryPtr->m_refRatios,
515 #endif // end if HDF5 527 const LevelData<FArrayBox>* a_crsVel,
528 const LevelData<FArrayBox>* a_fineVel
531 const DisjointBoxLayout& levelGrids = m_grid;
533 LevelData<FArrayBox>& levelVel = a_horizontalVel;
534 LevelData<FluxBox>& levelMu = *
m_VTO->getEta();
535 LevelData<FluxBox>& levelLambda = *
m_VTO->getLambda();
536 const LevelData<FluxBox>&levelA = *
m_faceA;
537 const LevelData<FArrayBox>& levelBeta = *
m_Beta;
538 const LevelData<FArrayBox>& levelBeta0 = *
m_Beta0;
539 LevelData<FArrayBox>& levelC = *
m_VTO->getACoef();
543 CoarseAverage averager(a_fineVel->getBoxes(),
548 averager.averageToCoarse(levelVel, *a_fineVel);
551 levelVel.exchange( m_exchangeCopier );
562 DataIterator dit = levelGrids.dataIterator();
590 const LevelData<FluxBox>& faceH = levelCS.
getFaceH();
593 for (dit.begin(); dit.ok(); ++dit)
596 for (
int dir=0; dir<SpaceDim; dir++)
598 FArrayBox& thisMu = levelMu[dit][dir];
599 const Box& box = thisMu.box();
605 thisMu.mult(faceH[dit][dir],box,0,0,1);
606 CH_assert(thisMu.min() >= 0.0);
614 const Box& gridBox = levelGrids[dit];
619 levelC[dit] += levelBeta0[dit];
638 FluxBox& lambda = levelLambda[dit];
639 for (
int dir=0; dir<SpaceDim; dir++)
641 lambda[dir].copy(levelMu[dit][dir]);
647 #include "NamespaceFooter.H" RefCountedPtr< LevelData< FluxBox > > m_faceA
Definition: FASIceSolver.H:132
virtual void reflux(const LevelData< FArrayBox > &a_phiFine, const LevelData< FArrayBox > &a_phi, LevelData< FArrayBox > &a_residual, AMRFASOp< LevelData< FArrayBox > > *a_finerOp)
Definition: FASIceSolverI.H:216
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< FluxBox > * > &a_muCoef, Vector< RefCountedPtr< LevelSigmaCS > > &a_coordSys, Real a_time, int a_lbase, int a_maxLevel)
full solve for non-isothermal ice
Definition: FASIceSolverI.H:389
Definition: FASIceSolver.H:66
RefCountedPtr< LevelData< FArrayBox > > m_Beta0
Definition: FASIceSolver.H:131
Abstract class around the englacial constitutive relations for ice.
Definition: ConstitutiveRelation.H:34
virtual void CFInterp(LevelData< FArrayBox > &a_phi, const LevelData< FArrayBox > &a_phiCoarse)
Definition: FASIceSolverI.H:55
ViscousTensorOp * m_VTO
Definition: FASIceSolver.H:134
virtual void define(const ProblemDomain &a_coarseDomain, ConstitutiveRelation *a_constRel, BasalFrictionRelation *a_basalFrictionRel, const Vector< DisjointBoxLayout > &a_vectGrids, const Vector< int > &a_vectRefRatio, const RealVect &a_dxCrse, IceThicknessIBC *a_bc, int a_numLevels)
Definition: FASIceSolverI.H:285
virtual RefCountedPtr< CompGridVTOBC > velocitySolveBC()=0
return boundary condition for Ice velocity solve
Physical/domain initial and boundary conditions for ice-sheet problems.
Definition: IceThicknessIBC.H:84
const ConstitutiveRelation * m_constRelPtr
Definition: FASIceSolver.H:122
virtual void computeFaceMu(LevelData< FluxBox > &a_mu, LevelData< FArrayBox > &a_vel, const Real &a_scale, const LevelData< FArrayBox > *a_crseVel, int a_nRefCrse, const LevelData< FluxBox > &a_A, const LevelSigmaCS &a_coordSys, const ProblemDomain &a_domain, const IntVect &a_ghostVect=IntVect::Zero) const =0
compute face-centered effective viscosity based on cell-centered velocity
RefCountedPtr< LevelData< FArrayBox > > m_Beta
Definition: FASIceSolver.H:130
FASIceViscouseTensorOp(int a_o, const DisjointBoxLayout &a_grid, const ConstitutiveRelation *a_constRelPtr, const BasalFrictionRelation *a_basalFrictionRelPtr, IceThicknessIBC *a_bc)
Constructor.
Definition: FASIceSolverI.H:28
Real m_time
Definition: FASIceSolver.H:126
virtual void define(const ProblemDomain &a_coarseDomain, const RealVect &a_crsDx, const Vector< DisjointBoxLayout > &a_grids, const Vector< int > &a_refRatios, int a_nSRGrids=0)
Definition: FASIceSolverI.H:319
RefCountedPtr< LevelSigmaCS > m_coordSys
Definition: FASIceSolver.H:127
virtual RefCountedPtr< AMRFASOp< LevelData< FArrayBox > > > AMRNewOp(int a_ilev, const DisjointBoxLayout &a_grid, bool a_isSR=false)
override base
Definition: FASIceSolverI.H:256
LevelData< FluxBox > & getFaceH()
returns modifiable face-centered H
Definition: LevelSigmaCS.cpp:356
virtual void computeAlpha(FArrayBox &a_alpha, const FArrayBox &a_basalVel, const FArrayBox &a_C, const Real &a_scale, const LevelSigmaCS &a_coords, const DataIterator &a_dit, int a_level, const Box &a_box) const =0
Computes cell-centered effective basal friction coeffcient such that .
void computeMu(LevelData< FArrayBox > &a_vel, const LevelData< FArrayBox > *a_crseVel, const LevelData< FArrayBox > *)
Definition: FASIceSolverI.H:526
virtual void levelGSRB(RefCountedPtr< LevelData< FArrayBox > > a_phi, const RefCountedPtr< LevelData< FArrayBox > > a_rhs)
Definition: FASIceSolverI.H:90
virtual void velocityGhostBC(LevelData< FArrayBox > &a_velocity, const LevelSigmaCS &a_coords, const ProblemDomain &a_domain, Real a_time)
fill ghost cells on velocity
Definition: IceThicknessIBC.H:199
Basic Sigma fourth-order coordinate system on an AMR level.
Definition: LevelSigmaCS.H:48
const LevelData< FArrayBox > & getThicknessOverFlotation() const
Definition: LevelSigmaCS.cpp:516
friend class FASIceViscouseTensorOpFactory
Definition: FASIceSolver.H:68
virtual void levelRich(RefCountedPtr< LevelData< FArrayBox > > a_phi, const RefCountedPtr< LevelData< FArrayBox > > a_rhs)
Definition: FASIceSolverI.H:113
Virtual base class for basal friction relations.
Definition: BasalFrictionRelation.H:27
static bool s_always_recompute_mu
Definition: FASIceSolverI.H:22
const LevelData< BaseFab< int > > & getFloatingMask() const
returns floating mask specifying whether ice is grounded or floating
Definition: LevelSigmaCS.H:187
virtual void applyLevel(LevelData< FArrayBox > &a_LofPhi, const LevelData< FArrayBox > &a_phi)
Definition: FASIceSolverI.H:65
const BasalFrictionRelation * m_basalFrictionRelPtr
Definition: FASIceSolver.H:123
IceThicknessIBC * m_bc
Definition: FASIceSolver.H:135
virtual void restrictState(RefCountedPtr< AMRFASOp< LevelData< FArrayBox > > >, Copier &a_copier)
Definition: FASIceSolverI.H:143
virtual bool computeState(RefCountedPtr< LevelData< FArrayBox > > a_phi, const RefCountedPtr< LevelData< FArrayBox > > a_CrsPhi, const RefCountedPtr< LevelData< FArrayBox > > a_FinePhi)
Definition: FASIceSolverI.H:195
FASIceViscouseTensorOpFactory(ConstitutiveRelation *a_constRelPtr, BasalFrictionRelation *a_basalFrictionRelPtr, IceThicknessIBC *a_bc)
Constructor.
Definition: FASIceSolverI.H:238