PISM, A Parallel Ice Sheet Model 2.3.0-79cae578d committed by Constantine Khrulev on 2026-03-22
Loading...
Searching...
No Matches
GeometryEvolution.cc
Go to the documentation of this file.
1/* Copyright (C) 2016--2025 PISM Authors
2 *
3 * This file is part of PISM.
4 *
5 * PISM is free software; you can redistribute it and/or modify it under the
6 * terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * PISM is distributed in the hope that it will be useful, but WITHOUT ANY
11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with PISM; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18*/
19
20#include "pism/geometry/GeometryEvolution.hh"
21
22#include "pism/util/Grid.hh"
23#include "pism/util/Mask.hh"
24#include "pism/util/array/CellType.hh"
25#include "pism/util/array/Scalar.hh"
26#include "pism/util/array/Staggered.hh"
27#include "pism/util/array/Vector.hh"
28
29#include "pism/geometry/part_grid_threshold_thickness.hh"
30#include "pism/util/Context.hh"
31#include "pism/util/Logger.hh"
32#include "pism/util/Profiling.hh"
33#include "pism/util/Interpolation1D.hh"
34#include "pism/util/pism_utilities.hh"
35
36#include "pism/geometry/flux_limiter.hh"
37
38namespace pism {
39
42using mask::ice_free;
45using mask::icy;
46
48 Impl(std::shared_ptr<const Grid> g);
49
51
53
54 //! True if the basal melt rate contributes to geometry evolution.
55 bool use_bmr;
56
57 //! True if the part-grid scheme is enabled.
59
60 //! Flux divergence (used to track thickness changes due to flow).
62
63 //! Conservation error due to enforcing non-negativity of ice thickness and enforcing
64 //! thickness BC.
66
67 //! Effective surface mass balance.
69
70 //! Effective basal mass balance.
72
73 //! Change in ice thickness due to flow during the last time step.
75
76 //! Change in the ice area-specific volume due to flow during the last time step.
78
79 //! Flux through cell interfaces. Ghosted.
81 //! Temporary storage for the flux limiter.
83
84 // Work space
85 array::Vector1 input_velocity; // a ghosted copy; not modified
86 array::Scalar1 bed_elevation; // a copy; not modified
87 array::Scalar1 sea_level; // a copy; not modified
88 array::Scalar1 ice_thickness; // updated in place
90 array::Scalar1 surface_elevation; // updated to maintain consistency
91 array::CellType1 cell_type; // updated to maintain consistency
92 array::Scalar1 residual; // temporary storage
93 array::Scalar1 thickness; // temporary storage
94};
95
96GeometryEvolution::Impl::Impl(std::shared_ptr<const Grid> grid)
97 : gc(*grid->ctx()->config()),
98 flux_divergence(grid, "flux_divergence"),
99 conservation_error(grid, "conservation_error"),
100 effective_SMB(grid, "effective_SMB"),
101 effective_BMB(grid, "effective_BMB"),
102 thickness_change(grid, "thickness_change"),
103 ice_area_specific_volume_change(grid, "ice_area_specific_volume_change"),
104 flux_staggered(grid, "flux_staggered"),
105 flux_limited(grid, "flux_limited"),
106 input_velocity(grid, "input_velocity"),
107 bed_elevation(grid, "bed_elevation"),
108 sea_level(grid, "sea_level"),
109 ice_thickness(grid, "ice_thickness"),
110 area_specific_volume(grid, "area_specific_volume"),
111 surface_elevation(grid, "surface_elevation"),
112 cell_type(grid, "cell_type"),
113 residual(grid, "residual"),
114 thickness(grid, "thickness") {
115
116 auto config = grid->ctx()->config();
117
118 gc.set_icefree_thickness(config->get_number("geometry.ice_free_thickness_standard"));
119
120 // constants
121 {
122 ice_density = config->get_number("constants.ice.density");
123 use_bmr = config->get_flag("geometry.update.use_basal_melt_rate");
124 use_part_grid = config->get_flag("geometry.part_grid.enabled");
125 }
126
127 // reported quantities
128 {
129 // This is the only reported field that is ghosted (we need ghosts to compute flux divergence).
131 .long_name("fluxes through cell interfaces (sides) on the staggered grid (x-offset)")
132 .units("m^2 s^-1")
133 .output_units("m^2 year^-1");
135 .long_name("fluxes through cell interfaces (sides) on the staggered grid (y-offset)")
136 .units("m^2 s^-1")
137 .output_units("m^2 year^-1");
138
140 .long_name("flux divergence")
141 .units("m s^-1")
142 .output_units("m year^-1");
143
145 .long_name(
146 "conservation error due to enforcing non-negativity of ice thickness (over the last time step)")
147 .units("meters");
148
150 .long_name("effective surface mass balance over the last time step")
151 .units("meters");
152
154 .long_name("effective basal mass balance over the last time step")
155 .units("meters");
156
157 thickness_change.metadata(0).long_name("change in thickness due to flow").units("meters");
158
160 .long_name("change in area-specific volume due to flow")
161 .units("meters^3 / meters^2");
162 }
163
164 // internal storage
165 {
167 .long_name("ghosted copy of the input velocity")
168 .units("meters / second");
169
170 bed_elevation.metadata(0).long_name("ghosted copy of the bed elevation").units("meters");
171
172 sea_level.metadata(0).long_name("ghosted copy of the sea level elevation").units("meters");
173
175 .long_name("working (ghosted) copy of the ice thickness")
176 .units("meters");
177
179 .long_name("working (ghosted) copy of the area specific volume")
180 .units("meters^3 / meters^2");
181
183 .long_name("working (ghosted) copy of the surface elevation")
184 .units("meters");
185
186 cell_type.metadata(0).long_name("working (ghosted) copy of the cell type mask");
187
188 residual.metadata(0).long_name("residual area specific volume").units("meters^3 / meters^2");
189
190 thickness.metadata(0).long_name("thickness (temporary storage)").units("meters");
191 }
192}
193
195 m_impl = new Impl(grid);
196}
197
201
203 this->init_impl(opts);
204}
205
207 (void)opts;
208 // empty: the default implementation has no state
209}
210
214
218
222
226
230
234
238
242
243/*!
244 * @param[in] geometry ice geometry
245 * @param[in] dt time step, seconds
246 * @param[in] advective_velocity advective (SSA) velocity
247 * @param[in] diffusive_flux diffusive (SIA) flux
248 * @param[in] velocity_bc_values advective velocity Dirichlet B.C. values
249 * @param[in] thickness_bc_mask ice thickness Dirichlet B.C. mask
250 *
251 * Results are stored in internal fields accessible using getters.
252 */
253void GeometryEvolution::flow_step(const Geometry &geometry, double dt,
254 const array::Vector &advective_velocity,
255 const array::Staggered &diffusive_flux,
256 const array::Scalar &thickness_bc_mask) {
257
258 profiling().begin("ge.update_ghosted_copies");
259 {
260 // make ghosted copies of input fields
265 m_impl->input_velocity.copy_from(advective_velocity);
266
267 // Compute cell_type and surface_elevation. Ghosts of results are updated.
268 m_impl->gc.compute(m_impl->sea_level, // in (uses ghosts)
269 m_impl->bed_elevation, // in (uses ghosts)
270 m_impl->ice_thickness, // in (uses ghosts)
271 m_impl->cell_type, // out (ghosts are updated)
272 m_impl->surface_elevation); // out (ghosts are updated)
273 }
274 profiling().end("ge.update_ghosted_copies");
275
276 // Derived classes can include modifications for regional runs.
277 profiling().begin("ge.interface_fluxes");
278 compute_interface_fluxes(m_impl->cell_type, // in (uses ghosts)
279 m_impl->ice_thickness, // in (uses ghosts)
280 m_impl->input_velocity, // in (uses ghosts)
281 diffusive_flux, // in
282 m_impl->flux_staggered); // out
283 profiling().end("ge.interface_fluxes");
284
286
287 {
288 int limiter_count = make_nonnegative_preserving(dt,
289 m_impl->ice_thickness, // in (uses ghosts)
290 m_impl->flux_staggered, // in (uses ghosts)
292 if (limiter_count > 0) {
293 m_log->message(2, "limited ice flux at %d locations\n", limiter_count);
294 }
295
297 }
298
299 profiling().begin("ge.flux_divergence");
301 m_impl->flux_staggered, // in (uses ghosts)
302 thickness_bc_mask, // in
303 m_impl->conservation_error, // in/out
304 m_impl->flux_divergence); // out
305 profiling().end("ge.flux_divergence");
306
307 // This is where part_grid is implemented.
308 profiling().begin("ge.update_in_place");
309 update_in_place(dt, // in
310 m_impl->bed_elevation, // in
311 m_impl->sea_level, // in
312 m_impl->flux_divergence, // in
313 m_impl->ice_thickness, // in/out
314 m_impl->area_specific_volume); // in/out
315 profiling().end("ge.update_in_place");
316
317 // Compute ice thickness and area specific volume changes.
318 profiling().begin("ge.compute_changes");
319 {
323 }
324 profiling().end("ge.compute_changes");
325
326 // Computes the numerical conservation error and corrects ice_thickness_change and
327 // ice_area_specific_volume_change. We can do this here because
328 // compute_surface_and_basal_mass_balance() preserves non-negativity.
329 //
330 // Note that here we use the "old" ice geometry.
331 //
332 // This computation is purely local.
333 profiling().begin("ge.ensure_nonnegativity");
334 ensure_nonnegativity(geometry.ice_thickness, // in
335 geometry.ice_area_specific_volume, // in
336 m_impl->thickness_change, // in/out
338 m_impl->conservation_error); // in/out
339 profiling().end("ge.ensure_nonnegativity");
340
341 // Now the caller can compute
342 //
343 // H_new = H_old + thickness_change
344 // Href_new = Href_old + ice_area_specific_volume_change.
345
346 // calving is a separate issue
347}
348
349void GeometryEvolution::source_term_step(const Geometry &geometry, double dt,
350 const array::Scalar &thickness_bc_mask,
351 const array::Scalar &surface_mass_balance_rate,
352 const array::Scalar &basal_melt_rate) {
353
354 profiling().begin("ge.source_terms");
356 thickness_bc_mask, // in
357 geometry.ice_thickness, // in
358 geometry.cell_type, // in
359 surface_mass_balance_rate, // in
360 basal_melt_rate, // in
361 m_impl->effective_SMB, // out
362 m_impl->effective_BMB); // out
363 profiling().end("ge.source_terms");
364}
365
366/*!
367 * Apply changes due to flow to ice geometry and ice area specific volume.
368 */
373
374/*!
375 * Update geometry by applying changes due to surface and basal mass fluxes.
376 *
377 * Note: This method performs these changes in the same order as the code ensuring
378 * non-negativity. This is important.
379 */
381
383 array::Scalar &H = geometry.ice_thickness;
384
385 array::AccessScope list{ &H, &dH_SMB, &dH_BMB };
386 ParallelSection loop(m_grid->com);
387 try {
388 for (auto p : m_grid->points()) {
389 const int i = p.i(), j = p.j();
390
391 // To preserve non-negativity of thickness we need to apply changes in this exact order.
392 // (Recall that floating-point arithmetic is not associative.)
393 const double H_new = (H(i, j) + dH_SMB(i, j)) + dH_BMB(i, j);
394
395#if (Pism_DEBUG == 1)
396 if (H_new < 0.0) {
397 throw RuntimeError::formatted(PISM_ERROR_LOCATION, "H = %f (negative) at i=%d, j=%d", H_new,
398 i, j);
399 }
400#endif
401
402 H(i, j) = H_new;
403 }
404 } catch (...) {
405 loop.failed();
406 }
407 loop.check();
408}
409
410
411/*!
412 * Prevent advective ice flow from floating ice to ice-free land, as well as in the
413 * ice-free areas.
414 *
415 * Note: positive `input` corresponds to the flux from `current` to `neighbor`.
416 */
417static double limit_advective_flux(int current, int neighbor, double input) {
418
419 // No flow from ice-free ocean:
420 if ((ice_free_ocean(current) and input > 0.0) or (ice_free_ocean(neighbor) and input < 0.0)) {
421 return 0.0;
422 }
423
424 // No flow from ice-free land:
425 if ((ice_free_land(current) and input > 0.0) or (ice_free_land(neighbor) and input < 0.0)) {
426 return 0.0;
427 }
428
429 // Case 1: Flow between grounded_ice and grounded_ice.
430 if (grounded_ice(current) and grounded_ice(neighbor)) {
431 return input;
432 }
433
434 // Cases 2 and 3: Flow between grounded_ice and floating_ice.
435 if ((grounded_ice(current) and floating_ice(neighbor)) or
436 (floating_ice(current) and grounded_ice(neighbor))) {
437 return input;
438 }
439
440 // Cases 4 and 5: Flow between grounded_ice and ice_free_land.
441 if ((grounded_ice(current) and ice_free_land(neighbor)) or
442 (ice_free_land(current) and grounded_ice(neighbor))) {
443 return input;
444 }
445
446 // Cases 6 and 7: Flow between grounded_ice and ice_free_ocean.
447 if ((grounded_ice(current) and ice_free_ocean(neighbor)) or
448 (ice_free_ocean(current) and grounded_ice(neighbor))) {
449 return input;
450 }
451
452 // Case 8: Flow between floating_ice and floating_ice.
453 if (floating_ice(current) and floating_ice(neighbor)) {
454 return input;
455 }
456
457 // Cases 9 and 10: Flow between floating_ice and ice_free_land.
458 if ((floating_ice(current) and ice_free_land(neighbor)) or
459 (ice_free_land(current) and floating_ice(neighbor))) {
460 // Disable all flow. This ensures that an ice shelf does not climb up a cliff.
461 return 0.0;
462 }
463
464 // Cases 11 and 12: Flow between floating_ice and ice_free_ocean.
465 if ((floating_ice(current) and ice_free_ocean(neighbor)) or
466 (ice_free_ocean(current) and floating_ice(neighbor))) {
467 return input;
468 }
469
470 // Case 13: Flow between ice_free_land and ice_free_land.
471 if (ice_free_land(current) and ice_free_land(neighbor)) {
472 return 0.0;
473 }
474
475 // Cases 14 and 15: Flow between ice_free_land and ice_free_ocean.
476 if ((ice_free_land(current) and ice_free_ocean(neighbor)) or
477 (ice_free_ocean(current) and ice_free_land(neighbor))) {
478 return 0.0;
479 }
480
481 // Case 16: Flow between ice_free_ocean and ice_free_ocean.
482 if (ice_free_ocean(current) and ice_free_ocean(neighbor)) {
483 return 0.0;
484 }
485
487 PISM_ERROR_LOCATION, "cannot handle the case current=%d, neighbor=%d", current, neighbor);
488}
489
490/*!
491 * Prevent SIA-driven flow in ice shelves and ice-free areas.
492 *
493 * Note: positive `flux` corresponds to the flux from `current` to `neighbor`.
494 */
495static double limit_diffusive_flux(int current, int neighbor, double flux) {
496
497 // No flow from ice-free ocean:
498 if ((ice_free_ocean(current) and flux > 0.0) or (ice_free_ocean(neighbor) and flux < 0.0)) {
499 return 0.0;
500 }
501
502 // No flow from ice-free land:
503 if ((ice_free_land(current) and flux > 0.0) or (ice_free_land(neighbor) and flux < 0.0)) {
504 return 0.0;
505 }
506
507 // Case 1: Flow between grounded_ice and grounded_ice.
508 if (grounded_ice(current) and grounded_ice(neighbor)) {
509 return flux;
510 }
511
512 // Cases 2 and 3: Flow between grounded_ice and floating_ice.
513 if ((grounded_ice(current) and floating_ice(neighbor)) or
514 (floating_ice(current) and grounded_ice(neighbor))) {
515 return flux;
516 }
517
518 // Cases 4 and 5: Flow between grounded_ice and ice_free_land.
519 if ((grounded_ice(current) and ice_free_land(neighbor)) or
520 (ice_free_land(current) and grounded_ice(neighbor))) {
521 return flux;
522 }
523
524 // Cases 6 and 7: Flow between grounded_ice and ice_free_ocean.
525 if ((grounded_ice(current) and ice_free_ocean(neighbor)) or
526 (ice_free_ocean(current) and grounded_ice(neighbor))) {
527 return flux;
528 }
529
530 // Case 8: Flow between floating_ice and floating_ice.
531 if (floating_ice(current) and floating_ice(neighbor)) {
532 // no diffusive flux in ice shelves
533 return 0.0;
534 }
535
536 // Cases 9 and 10: Flow between floating_ice and ice_free_land.
537 if ((floating_ice(current) and ice_free_land(neighbor)) or
538 (ice_free_land(current) and floating_ice(neighbor))) {
539 // Disable all flow. This ensures that an ice shelf does not climb up a cliff.
540 return 0.0;
541 }
542
543 // Cases 11 and 12: Flow between floating_ice and ice_free_ocean.
544 if ((floating_ice(current) and ice_free_ocean(neighbor)) or
545 (ice_free_ocean(current) and floating_ice(neighbor))) {
546 return 0.0;
547 }
548
549 // Case 13: Flow between ice_free_land and ice_free_land.
550 if (ice_free_land(current) and ice_free_land(neighbor)) {
551 return 0.0;
552 }
553
554 // Cases 14 and 15: Flow between ice_free_land and ice_free_ocean.
555 if ((ice_free_land(current) and ice_free_ocean(neighbor)) or
556 (ice_free_ocean(current) and ice_free_land(neighbor))) {
557 return 0.0;
558 }
559
560 // Case 16: Flow between ice_free_ocean and ice_free_ocean.
561 if (ice_free_ocean(current) and ice_free_ocean(neighbor)) {
562 return 0.0;
563 }
564
566 PISM_ERROR_LOCATION, "cannot handle the case current=%d, neighbor=%d", current, neighbor);
567}
568
569/*!
570 * Combine advective velocity and the diffusive flux on the staggered grid with the ice thickness to
571 * compute the total flux through cell interfaces.
572 *
573 * Uses first-order upwinding to compute the advective flux.
574 *
575 * Limits the diffusive flux to prevent SIA-driven flow in the ocean and ice-free areas.
576 */
578 const array::Scalar &ice_thickness,
579 const array::Vector &velocity,
580 const array::Staggered &diffusive_flux,
581 array::Staggered &output) {
582
583 array::AccessScope list{ &cell_type, &velocity, &ice_thickness, &diffusive_flux, &output };
584
585 ParallelSection loop(m_grid->com);
586 try {
587 // compute advective fluxes and put them in output
588 for (auto p : m_grid->points()) {
589 const int i = p.i(), j = p.j(), M = cell_type.as_int(i, j);
590
591 const double H = ice_thickness(i, j);
592 const Vector2d& V = velocity(i, j);
593
594 for (int n = 0; n < 2; ++n) {
595 const int oi = 1 - n, // offset in the i direction
596 oj = n, // offset in the j direction
597 i_n = i + oi, // i index of a neighbor
598 j_n = j + oj; // j index of a neighbor
599
600 const int M_n = cell_type.as_int(i_n, j_n);
601
602 // advective velocity at the current interface
603 double v = 0.0;
604 {
605 const Vector2d& V_n = velocity(i_n, j_n);
606 int W = static_cast<int>(icy(M)), W_n = static_cast<int>(icy(M_n));
607
608 auto v_staggered = (W * V + W_n * V_n) / std::max(W + W_n, 1);
609 v = n == 0 ? v_staggered.u : v_staggered.v;
610 }
611
612 // advective flux
613 const double H_n = ice_thickness(i_n, j_n),
614 Q_advective = v * (v > 0.0 ? H : H_n); // first order upwinding
615
616 output(i, j, n) = Q_advective;
617 } // end of the loop over neighbors (n)
618 }
619
620 // limit the advective flux and add the diffusive flux to it to get the total
621 for (auto p : m_grid->points()) {
622 const int i = p.i(), j = p.j(), M = cell_type.as_int(i, j);
623
624 for (int n = 0; n < 2; ++n) {
625 const int oi = 1 - n, // offset in the i direction
626 oj = n, // offset in the j direction
627 i_n = i + oi, // i index of a neighbor
628 j_n = j + oj; // j index of a neighbor
629
630 const int M_n = cell_type.as_int(i_n, j_n);
631
632 // diffusive flux
633 const double Q_diffusive = limit_diffusive_flux(M, M_n, diffusive_flux(i, j, n)),
634 Q_advective = limit_advective_flux(M, M_n, output(i, j, n));
635
636 output(i, j, n) = Q_diffusive + Q_advective;
637 } // end of the loop over n
638 }
639
640 } catch (...) {
641 loop.failed();
642 }
643 loop.check();
644}
645
646/*!
647 * Compute flux divergence using cell interface fluxes on the staggered grid.
648 *
649 * The flux divergence at *ice thickness* Dirichlet B.C. locations is set to zero.
650 */
652 const array::Scalar &thickness_bc_mask,
653 array::Scalar &conservation_error,
654 array::Scalar &output) {
655 const double dx = m_grid->dx(), dy = m_grid->dy();
656
657 array::AccessScope list{ &flux, &thickness_bc_mask, &conservation_error, &output };
658
659 ParallelSection loop(m_grid->com);
660 try {
661 for (auto p : m_grid->points()) {
662 const int i = p.i(), j = p.j();
663
664 auto Q = flux.star(i, j);
665
666 double divQ = (Q.e - Q.w) / dx + (Q.n - Q.s) / dy;
667
668 if (thickness_bc_mask(i, j) > 0.5) {
669 // the thickness change would have been equal to -divQ*dt. By keeping ice
670 // thickness fixed we *add* divQ*dt meters of ice.
671 conservation_error(i, j) += divQ * dt; // units: meters
672 output(i, j) = 0.0;
673 } else {
674 output(i, j) = divQ;
675 }
676 }
677 } catch (...) {
678 loop.failed();
679 }
680 loop.check();
681}
682
683/*!
684 * Update ice thickness and area_specific_volume *in place*.
685 *
686 * It would be better to compute the change in ice thickness and area_specific_volume and then apply
687 * them, but it would require re-writing all the part-grid code from scratch. So, I make copies of
688 * ice thickness and area_specific_volume, use this old code, then compute differences to get changes.
689 * Compute ice thickness changes due to the flow of the ice.
690 *
691 * @param[in] dt time step, seconds
692 * @param[in] bed_elevation bed elevation, meters
693 * @param[in] sea_level sea level elevation
694 * @param[in] ice_thickness ice thickness
695 * @param[in] area_specific_volume area-specific volume (m3/m2)
696 * @param[in] flux_divergence flux divergence
697 * @param[out] thickness_change ice thickness change due to flow
698 * @param[out] area_specific_volume_change area specific volume change due to flow
699 */
700void GeometryEvolution::update_in_place(double dt, const array::Scalar &bed_topography,
701 const array::Scalar &sea_level,
702 const array::Scalar &flux_divergence,
703 array::Scalar &ice_thickness,
704 array::Scalar &area_specific_volume) {
705
706 m_impl->gc.compute(sea_level, bed_topography, ice_thickness, m_impl->cell_type,
708
709 array::AccessScope list{ &ice_thickness, &flux_divergence };
710
711 if (m_impl->use_part_grid) {
712 m_impl->residual.set(0.0);
713
714 // Store ice thickness. We need this copy to make sure that modifying ice_thickness in the loop
715 // below does not affect the computation of the threshold thickness. (Note that
716 // part_grid_threshold_thickness uses neighboring values of the mask, ice thickness, and surface
717 // elevation.)
718 m_impl->thickness.copy_from(ice_thickness);
719
720 list.add({ &area_specific_volume, &m_impl->residual, &m_impl->thickness,
721 &m_impl->surface_elevation, &bed_topography, &m_impl->cell_type });
722 }
723
724 const double Lz = m_grid->Lz();
725
726 ParallelSection loop(m_grid->com);
727 try {
728 for (auto p : m_grid->points()) {
729 const int i = p.i(), j = p.j();
730
731 double divQ = flux_divergence(i, j);
732
733 if (m_impl->use_part_grid) {
735 assert(divQ <= 0.0);
736 // Add the flow contribution to this partially filled cell.
737 area_specific_volume(i, j) += -divQ * dt;
738
739 double threshold = part_grid_threshold_thickness(
741 m_impl->surface_elevation.star(i, j), bed_topography(i, j));
742
743 // if threshold is zero, turn all the area specific volume into ice thickness, with zero
744 // residual
745 if (threshold == 0.0) {
746 threshold = area_specific_volume(i, j);
747 }
748
749 if (area_specific_volume(i, j) >= threshold) {
750 ice_thickness(i, j) += threshold;
751 m_impl->residual(i, j) = area_specific_volume(i, j) - threshold;
752 area_specific_volume(i, j) = 0.0;
753 }
754
755 // In this case the flux goes into the area_specific_volume variable and does not directly
756 // contribute to ice thickness at this location.
757 divQ = 0.0;
758 }
759 } // end of if (use_part_grid)
760
761 ice_thickness(i, j) += -dt * divQ;
762
763 if (ice_thickness(i, j) > Lz) {
765 "ice thickness would exceed Lz at i=%d, j=%d (H=%f, Lz=%f)",
766 i, j, ice_thickness(i, j), Lz);
767 }
768 }
769 } catch (...) {
770 loop.failed();
771 }
772 loop.check();
773
774 ice_thickness.update_ghosts();
775
776 // Compute the mask corresponding to the new thickness.
777 m_impl->gc.compute_mask(sea_level, bed_topography, ice_thickness, m_impl->cell_type);
778
779 /*
780 Redistribute residual ice mass from subgrid-scale parameterization.
781
782 See [@ref Albrechtetal2011].
783 */
784 if (m_impl->use_part_grid) {
785 const int max_n_iterations = (int)m_config->get_number("geometry.part_grid.max_iterations");
786
787 bool done = false;
788 for (int i = 0; i < max_n_iterations and not done; ++i) {
789 m_log->message(4, "redistribution iteration %d\n", i);
790
791 // this call may set done to true
793 ice_thickness, m_impl->cell_type, area_specific_volume,
794 m_impl->residual, done);
795 }
796
797 if (not done) {
798 m_log->message(
799 2,
800 "WARNING: not done redistributing mass after %d iterations, remaining residual: %f m^3.\n",
801 max_n_iterations, sum(m_impl->residual) * m_grid->cell_area());
802
803 // Add residual to ice thickness, preserving total ice mass. (This is not great, but
804 // better than losing mass.)
805 ice_thickness.add(1.0, m_impl->residual);
806 m_impl->residual.set(0.0);
807 }
808
809 if (max(ice_thickness) > m_grid->Lz()) {
810 throw RuntimeError::formatted(PISM_ERROR_LOCATION, "ice thickness would exceed Lz "
811 "after part_grid residual redistribution");
812 }
813 }
814}
815
816//! @brief Perform one iteration of the residual mass redistribution.
817/*!
818 @param[in] bed_topography bed elevation
819 @param[in] sea_level sea level elevation
820 @param[in,out] ice_surface_elevation surface elevation; used as temp. storage
821 @param[in,out] ice_thickness ice thickness; updated
822 @param[in,out] cell_type cell type mask; used as temp. storage
823 @param[in,out] area_specific_volume area specific volume; updated
824 @param[in,out] residual ice volume that still needs to be distributed; updated
825 @param[in,out] done result flag: true if this iteration should be the last one
826 */
828 const array::Scalar &sea_level,
829 array::Scalar1 &ice_surface_elevation,
830 array::Scalar &ice_thickness,
831 array::CellType1 &cell_type,
832 array::Scalar &area_specific_volume,
833 array::Scalar1 &residual, bool &done) {
834
835 m_impl->gc.compute_mask(sea_level, bed_topography, ice_thickness, cell_type);
836
837 // First step: distribute residual mass
838 {
839 // will be destroyed at the end of the block
840 array::AccessScope list{ &cell_type, &ice_thickness, &area_specific_volume, &residual };
841
842 for (auto p : m_grid->points()) {
843 const int i = p.i(), j = p.j();
844
845 if (residual(i, j) <= 0.0) {
846 continue;
847 }
848
849 auto m = cell_type.star_int(i, j);
850
851 int N = 0; // number of empty or partially filled neighbors
852 for (auto d : { North, East, South, West }) {
853 N += ice_free_ocean(m[d]) ? 1 : 0;
854 }
855
856 if (N > 0) {
857 // Remaining ice mass will be redistributed equally among all adjacent
858 // ice-free-ocean cells (is there a more physical way?)
859 residual(i, j) /= N;
860 } else {
861 // Conserve mass, but (possibly) create a "ridge" at the shelf
862 // front
863 ice_thickness(i, j) += residual(i, j);
864 residual(i, j) = 0.0;
865 }
866 }
867
868 residual.update_ghosts();
869
870 // update area_specific_volume using adjusted residuals
871 for (auto p : m_grid->points()) {
872 const int i = p.i(), j = p.j();
873
874 auto R = residual.star(i, j);
875
876 if (cell_type.ice_free_ocean(i, j)) {
877 area_specific_volume(i, j) += (R.e + R.w + R.n + R.s);
878 }
879 }
880
881 residual.set(0.0);
882 }
883
884 ice_thickness.update_ghosts();
885
886 // Store ice thickness. We need this copy to make sure that modifying ice_thickness in the loop
887 // below does not affect the computation of the threshold thickness. (Note that
888 // part_grid_threshold_thickness uses neighboring values of the mask, ice thickness, and surface
889 // elevation.)
890 m_impl->thickness.copy_from(ice_thickness);
891
892 // The loop above updated ice_thickness, so we need to re-calculate the mask and the
893 // surface elevation:
894 m_impl->gc.compute(sea_level, bed_topography, ice_thickness, cell_type, ice_surface_elevation);
895
896 double remaining_residual = 0.0;
897
898 // Second step: we need to redistribute residual ice volume if
899 // neighbors which gained redistributed ice also become full.
900 {
901 // will be destroyed at the end of the block
902 array::AccessScope list{ &m_impl->thickness, &ice_thickness, &ice_surface_elevation,
903 &bed_topography, &cell_type };
904
905 for (auto p : m_grid->points()) {
906 const int i = p.i(), j = p.j();
907
908 if (area_specific_volume(i, j) <= 0.0) {
909 continue;
910 }
911
912 double threshold =
914 ice_surface_elevation.star(i, j), bed_topography(i, j));
915
916 // if threshold is zero, turn all the area specific volume into ice thickness, with zero
917 // residual
918 if (threshold == 0.0) {
919 threshold = area_specific_volume(i, j);
920 }
921
922 if (area_specific_volume(i, j) >= threshold) {
923 ice_thickness(i, j) += threshold;
924 residual(i, j) = area_specific_volume(i, j) - threshold;
925 area_specific_volume(i, j) = 0.0;
926
927 remaining_residual += residual(i, j);
928 }
929 }
930 }
931
932 // check if redistribution should be run once more
933 remaining_residual = GlobalSum(m_grid->com, remaining_residual);
934
935 done = remaining_residual <= 0.0;
936
937 ice_thickness.update_ghosts();
938}
939
940/*!
941 * Correct `thickness_change` and `area_specific_volume_change` so that applying them will not
942 * result in negative `ice_thickness` and `area_specific_volume`.
943 *
944 * Compute the the amount of ice that is added to preserve non-negativity of ice thickness.
945 *
946 * @param[in] ice_thickness ice thickness (m)
947 * @param[in] area_specific_volume area-specific volume (m3/m2)
948 * @param[in,out] thickness_change "proposed" thickness change (m)
949 * @param[in,out] area_specific_volume_change "proposed" area-specific volume change (m3/m2)
950 * @param[in,out] conservation_error computed conservation error (m)
951 *
952 * This computation is purely local.
953 */
955 const array::Scalar &area_specific_volume,
956 array::Scalar &thickness_change,
957 array::Scalar &area_specific_volume_change,
958 array::Scalar &conservation_error) {
959
960 array::AccessScope list{ &ice_thickness, &area_specific_volume, &thickness_change,
961 &area_specific_volume_change, &conservation_error };
962
963 ParallelSection loop(m_grid->com);
964 try {
965 for (auto p : m_grid->points()) {
966 const int i = p.i(), j = p.j();
967
968 const double H = ice_thickness(i, j), dH = thickness_change(i, j);
969
970 // applying thickness_change will lead to negative thickness
971 if (H + dH < 0.0) {
972 thickness_change(i, j) = -H;
973 conservation_error(i, j) += -(H + dH);
974 }
975
976 const double V = area_specific_volume(i, j), dV = area_specific_volume_change(i, j);
977
978 if (V + dV < 0.0) {
979 area_specific_volume_change(i, j) = -V;
980 conservation_error(i, j) += -(V + dV);
981 }
982 }
983 } catch (...) {
984 loop.failed();
985 }
986 loop.check();
987}
988
989/*!
990 * Given ice thickness `H` and the "proposed" change `dH`, compute the corrected change preserving
991 * non-negativity.
992 */
993static inline double effective_change(double H, double dH) {
994 if (H + dH <= 0) {
995 return -H;
996 }
997 return dH;
998}
999
1000/*!
1001 * Compute effective surface and basal mass balance.
1002 *
1003 * @param[in] dt time step, seconds
1004 * @param[in] thickness_bc_mask mask specifying ice thickness Dirichlet B.C. locations
1005 * @param[in] ice_thickness ice thickness, m
1006 * @param[in] thickness_change thickness change due to flow, m
1007 * @param[in] cell_type cell type mask
1008 * @param[in] smb_rate top surface mass balance rate, kg m-2 s-1
1009 * @param[in] basal_melt_rate basal melt rate, m s-1
1010 * @param[out] effective_smb effective top surface mass balance, m
1011 * @param[out] effective_bmb effective basal mass balance, m
1012 *
1013 * This computation is purely local.
1014 *
1015 * Positive outputs correspond to mass gain.
1016 */
1018 double dt, const array::Scalar &thickness_bc_mask, const array::Scalar &ice_thickness,
1019 const array::CellType &cell_type, const array::Scalar &surface_mass_flux,
1020 const array::Scalar &basal_melt_rate, array::Scalar &effective_SMB,
1021 array::Scalar &effective_BMB) {
1022
1023 array::AccessScope list{ &ice_thickness, &surface_mass_flux, &basal_melt_rate, &cell_type,
1024 &thickness_bc_mask, &effective_SMB, &effective_BMB };
1025
1026 ParallelSection loop(m_grid->com);
1027 try {
1028 for (auto p : m_grid->points()) {
1029 const int i = p.i(), j = p.j();
1030
1031 // Don't modify ice thickness at Dirichlet B.C. locations and in the ice-free ocean.
1032 if (thickness_bc_mask.as_int(i, j) == 1 or cell_type.ice_free_ocean(i, j)) {
1033 effective_SMB(i, j) = 0.0;
1034 effective_BMB(i, j) = 0.0;
1035 continue;
1036 }
1037
1038 const double H = ice_thickness(i, j);
1039
1040 // Thickness change due to the surface mass balance
1041 //
1042 // Note that here we convert surface mass balance from [kg m-2 s-1] to [m s-1].
1043 double dH_SMB = effective_change(H, dt * surface_mass_flux(i, j) / m_impl->ice_density);
1044
1045 // Thickness change due to the basal mass balance
1046 //
1047 // Note that basal_melt_rate is in [m s-1]. Here the negative sign converts the melt rate into
1048 // mass balance.
1049 double dH_BMB =
1050 effective_change(H + dH_SMB, dt * (m_impl->use_bmr ? -basal_melt_rate(i, j) : 0.0));
1051
1052 effective_SMB(i, j) = dH_SMB;
1053 effective_BMB(i, j) = dH_BMB;
1054 }
1055 } catch (...) {
1056 loop.failed();
1057 }
1058 loop.check();
1059}
1060
1061namespace diagnostics {
1062
1063/*! @brief Report the divergence of the ice flux. */
1064class FluxDivergence : public Diag<GeometryEvolution> {
1065public:
1069
1070protected:
1071 std::shared_ptr<array::Array> compute_impl() const {
1072 auto result = allocate<array::Scalar>("flux_divergence");
1073
1074 result->copy_from(model->flux_divergence());
1075
1076 return result;
1077 }
1078};
1079
1080/*! @brief Report mass flux on the staggered grid. */
1081class FluxStaggered : public Diag<GeometryEvolution> {
1082public:
1086
1087protected:
1088 std::shared_ptr<array::Array> compute_impl() const {
1089 auto result = allocate<array::Staggered>("flux_staggered");
1090
1091 result->copy_from(model->flux_staggered());
1092
1093 return result;
1094 }
1095};
1096
1097} // end of namespace diagnostics
1098
1100 using namespace diagnostics;
1101 using Ptr = Diagnostic::Ptr;
1102
1103 std::map<std::string, Ptr> result;
1104 result = {
1105 { "flux_staggered", Ptr(new FluxStaggered(this)) },
1106 { "flux_divergence", Ptr(new FluxDivergence(this)) },
1107 };
1108 return result;
1109}
1110
1112 : GeometryEvolution(grid), m_no_model_mask(m_grid, "no_model_mask") {
1113
1115
1116 m_no_model_mask.metadata(0).long_name("'no model' mask");
1117}
1118
1122
1123/*!
1124 * Disable ice flow in "no model" areas.
1125 */
1127 const array::Scalar &ice_thickness,
1128 const array::Vector &velocity,
1129 const array::Staggered &diffusive_flux,
1130 array::Staggered &output) {
1131
1132 GeometryEvolution::compute_interface_fluxes(cell_type, ice_thickness,
1133 velocity, diffusive_flux,
1134 output);
1135
1136 array::AccessScope list{&m_no_model_mask, &output};
1137
1138 ParallelSection loop(m_grid->com);
1139 try {
1140 for (auto p : m_grid->points()) {
1141 const int i = p.i(), j = p.j();
1142
1143 const int M = m_no_model_mask.as_int(i, j);
1144
1145 for (int n : {0, 1}) {
1146 const int
1147 oi = 1 - n, // offset in the i direction
1148 oj = n, // offset in the j direction
1149 i_n = i + oi, // i index of a neighbor
1150 j_n = j + oj; // j index of a neighbor
1151
1152 const int M_n = m_no_model_mask.as_int(i_n, j_n);
1153
1154 if (not (M == 0 and M_n == 0)) {
1155 output(i, j, n) = 0.0;
1156 }
1157 }
1158 }
1159 } catch (...) {
1160 loop.failed();
1161 }
1162 loop.check();
1163}
1164
1165/*!
1166 * Set surface and basal mass balance to zero in "no model" areas.
1167 */
1169 const array::Scalar &thickness_bc_mask,
1170 const array::Scalar &ice_thickness,
1171 const array::CellType &cell_type,
1172 const array::Scalar &surface_mass_flux,
1173 const array::Scalar &basal_melt_rate,
1174 array::Scalar &effective_SMB,
1175 array::Scalar &effective_BMB) {
1177 thickness_bc_mask,
1178 ice_thickness,
1179 cell_type,
1180 surface_mass_flux,
1181 basal_melt_rate,
1182 effective_SMB,
1183 effective_BMB);
1184
1185 array::AccessScope list{&m_no_model_mask, &effective_SMB, &effective_BMB};
1186
1187 ParallelSection loop(m_grid->com);
1188 try {
1189 for (auto p : m_grid->points()) {
1190 const int i = p.i(), j = p.j();
1191
1192 if (m_no_model_mask(i, j) > 0.5) {
1193 effective_SMB(i, j) = 0.0;
1194 effective_BMB(i, j) = 0.0;
1195 }
1196 }
1197 } catch (...) {
1198 loop.failed();
1199 }
1200 loop.check();
1201}
1202
1206
1208 (void) mask;
1209 // the default implementation is a no-op
1210}
1211/*!
1212 * Return the volumetric ice flow rate from land to water (across the grounding line), in
1213 * m^3 / s. Positive values correspond to ice moving from the grounded side to the
1214 * floating (ocean) side.
1215 *
1216 * Mass continuity equation without source terms:
1217 *
1218 * dH/dt = - div(Q)
1219 *
1220 * Approximating the flux divergence, we get
1221 *
1222 * - div(Q) ~= - ((Q.e - Q.w) / dx + (Q.n - Q.s) / dy)
1223 *
1224 * Multiplying by the cell area we get the volume flow rate
1225 *
1226 * dV/dt = - dx *dy * div(Q)
1227 *
1228 * which can be approximated by
1229 *
1230 * - (dy * (Q.e - Q.w) + dx * (Q.n - Q.s)) = dy * (Q.w - Q.e) + dx * (Q.s - Q.n)
1231 */
1233 const stencils::Star<double> &flux, double dx,
1234 double dy) {
1235 using mask::grounded;
1236
1237 auto Q = flux; // units: m^2 / s
1238
1239 // zero out fluxes between the current (floating or ocean) cell and other (floating or
1240 // ocean) cells
1241 Q.n *= (int)grounded(cell_type.n);
1242 Q.e *= (int)grounded(cell_type.e);
1243 Q.s *= (int)grounded(cell_type.s);
1244 Q.w *= (int)grounded(cell_type.w);
1245
1246 return dy * (Q.w - Q.e) + dx * (Q.s - Q.n); // units: m^3 / s
1247}
1248
1249/*!
1250 * Compute the ice flow rate across the grounding line, adding to `output` to accumulate
1251 * contributions from multiple time steps.
1252 *
1253 * When `unit_conversion_factor` is 1 the units of `output` are "m^3 / s".
1254 *
1255 * Negative flux corresponds to ice moving into the ocean, i.e. from grounded to floating
1256 * areas. (This convention makes it easier to compare this quantity to the surface mass
1257 * balance or calving fluxes.)
1258 *
1259 * Different choices of the `unit_conversion_factor` make it possible to use this in
1260 *
1261 * - the grounding line flux diagnostic (in kg / (m^2 s)),
1262 * - the volume flow rate diagnostic (in m^3 / s),
1263 * - or the mass flow rate diagnostic (in kg / s).
1264 */
1266 const array::Staggered1 &flux,
1267 double unit_conversion_factor, array::Scalar &output) {
1268 auto grid = output.grid();
1269
1270 const double dx = grid->dx(), // units: m
1271 dy = grid->dy(); // units: m
1272
1273 array::AccessScope list{ &cell_type, &flux, &output };
1274
1275 ParallelSection loop(grid->com);
1276 try {
1277 for (auto p : grid->points()) {
1278 const int i = p.i(), j = p.j();
1279
1280 double result = 0.0;
1281
1282 if (cell_type.ocean(i, j)) {
1283 auto M = cell_type.star_int(i, j);
1284 auto Q = flux.star(i, j); // units: m^2 / s
1285
1286 // note the sign change: here *negative* values correspond to ice moving from
1287 // grounded to floating areas since it can sometimes be interpreted as "mass loss"
1288 result = -volume_flow_rate_from_land_to_water(M, Q, dx, dy); // units: m^3 / s
1289
1290 // convert from "m^3 / s" to "kg"
1291 result *= unit_conversion_factor;
1292 }
1293
1294 output(i, j) += result;
1295 }
1296 } catch (...) {
1297 loop.failed();
1298 }
1299 loop.check();
1300}
1301
1303 const array::Staggered1 &flux,
1304 double dt) {
1305 auto grid = cell_type.grid();
1306
1307 const double
1308 dx = grid->dx(), // units: m
1309 dy = grid->dy(); // units: m
1310
1311 auto ice_density = grid->ctx()->config()->get_number("constants.ice.density"); // units: kg / m^3
1312
1313 double conversion_factor = dt * ice_density;
1314
1315 double total_flux = 0.0;
1316
1317 array::AccessScope list{&cell_type, &flux};
1318
1319 ParallelSection loop(grid->com);
1320 try {
1321 for (auto p : grid->points()) {
1322 const int i = p.i(), j = p.j();
1323
1324 if (cell_type.ocean(i, j)) {
1325 auto M = cell_type.star_int(i, j);
1326 auto Q = flux.star(i, j); // units: m^2 / s
1327
1328 // note the sign change: here *negative* values correspond to ice moving from
1329 // grounded to floating areas since it can sometimes be interpreted as "mass loss"
1330 double volume_flux = -volume_flow_rate_from_land_to_water(M, Q, dx, dy); // units: m^3 / s
1331 // convert from "m^3 / s" to "kg" and sum up
1332 total_flux += volume_flux * conversion_factor;
1333 }
1334 }
1335 } catch (...) {
1336 loop.failed();
1337 }
1338 loop.check();
1339
1340 return GlobalSum(grid->com, total_flux);
1341}
1342
1343} // end of namespace pism
std::shared_ptr< const Grid > grid() const
Definition Component.cc:107
std::shared_ptr< const Config > m_config
configuration database used by this component
Definition Component.hh:160
const std::shared_ptr< const Grid > m_grid
grid used by this component
Definition Component.hh:158
const Profiling & profiling() const
Definition Component.cc:115
std::shared_ptr< const Logger > m_log
logger (for easy access)
Definition Component.hh:164
A class defining a common interface for most PISM sub-models.
Definition Component.hh:118
const GeometryEvolution * model
A template derived from Diagnostic, adding a "Model".
std::vector< VariableMetadata > m_vars
metadata corresponding to NetCDF variables
std::shared_ptr< Diagnostic > Ptr
Definition Diagnostic.hh:67
void compute_mask(const array::Scalar &sea_level, const array::Scalar &bed, const array::Scalar &thickness, array::Scalar &result) const
Definition Mask.cc:36
void set_icefree_thickness(double threshold)
Definition Mask.hh:81
void compute(const array::Scalar &sea_level, const array::Scalar &bed, const array::Scalar &thickness, array::Scalar &out_mask, array::Scalar &out_surface) const
Definition Mask.cc:27
const array::Scalar & thickness_change_due_to_flow() const
virtual void set_no_model_mask(const array::Scalar &mask)
virtual void init_impl(const InputOptions &opts)
virtual void compute_surface_and_basal_mass_balance(double dt, const array::Scalar &thickness_bc_mask, const array::Scalar &ice_thickness, const array::CellType &cell_type, const array::Scalar &surface_mass_flux, const array::Scalar &basal_melt_rate, array::Scalar &effective_SMB, array::Scalar &effective_BMB)
const array::Scalar & bottom_surface_mass_balance() const
void apply_mass_fluxes(Geometry &geometry) const
virtual void set_no_model_mask_impl(const array::Scalar &mask)
void source_term_step(const Geometry &geometry, double dt, const array::Scalar &thickness_bc_mask, const array::Scalar &surface_mass_balance_rate, const array::Scalar &basal_melt_rate)
const array::Scalar & flux_divergence() const
void update_in_place(double dt, const array::Scalar &bed_topography, const array::Scalar &sea_level, const array::Scalar &flux_divergence, array::Scalar &ice_thickness, array::Scalar &area_specific_volume)
void residual_redistribution_iteration(const array::Scalar &bed_topography, const array::Scalar &sea_level, array::Scalar1 &ice_surface_elevation, array::Scalar &ice_thickness, array::CellType1 &cell_type, array::Scalar &area_specific_volume, array::Scalar1 &residual, bool &done)
Perform one iteration of the residual mass redistribution.
virtual void ensure_nonnegativity(const array::Scalar &ice_thickness, const array::Scalar &area_specific_volume, array::Scalar &thickness_change, array::Scalar &area_specific_volume_change, array::Scalar &conservation_error)
virtual void compute_interface_fluxes(const array::CellType1 &cell_type, const array::Scalar &ice_thickness, const array::Vector &velocity, const array::Staggered &diffusive_flux, array::Staggered &output)
GeometryEvolution(std::shared_ptr< const Grid > grid)
std::map< std::string, Diagnostic::Ptr > spatial_diagnostics_impl() const
void flow_step(const Geometry &ice_geometry, double dt, const array::Vector &advective_velocity, const array::Staggered &diffusive_flux, const array::Scalar &thickness_bc_mask)
const array::Scalar & top_surface_mass_balance() const
void apply_flux_divergence(Geometry &geometry) const
const array::Scalar & area_specific_volume_change_due_to_flow() const
virtual void compute_flux_divergence(double dt, const array::Staggered1 &flux, const array::Scalar &thickness_bc_mask, array::Scalar &conservation_error, array::Scalar &output)
const array::Scalar & conservation_error() const
const array::Staggered1 & flux_staggered() const
void init(const InputOptions &opts)
array::Scalar1 sea_level_elevation
Definition Geometry.hh:48
array::Scalar1 ice_area_specific_volume
Definition Geometry.hh:52
array::CellType2 cell_type
Definition Geometry.hh:55
array::Scalar2 ice_thickness
Definition Geometry.hh:51
array::Scalar2 bed_elevation
Definition Geometry.hh:47
void failed()
Indicates a failure of a parallel section.
void begin(const char *name) const
Definition Profiling.cc:75
void end(const char *name) const
Definition Profiling.cc:91
RegionalGeometryEvolution(std::shared_ptr< const Grid > grid)
void compute_surface_and_basal_mass_balance(double dt, const array::Scalar &thickness_bc_mask, const array::Scalar &ice_thickness, const array::CellType &cell_type, const array::Scalar &surface_mass_flux, const array::Scalar &basal_melt_rate, array::Scalar &effective_SMB, array::Scalar &effective_BMB)
void compute_interface_fluxes(const array::CellType1 &cell_type, const array::Scalar &ice_thickness, const array::Vector &velocity, const array::Staggered &diffusive_flux, array::Staggered &output)
void set_no_model_mask_impl(const array::Scalar &mask)
static RuntimeError formatted(const ErrorLocation &location, const char format[],...) __attribute__((format(printf
build a RuntimeError with a formatted message
VariableMetadata & long_name(const std::string &input)
VariableMetadata & units(const std::string &input)
VariableMetadata & output_units(const std::string &input)
This class represents a 2D vector field (such as ice velocity) at a certain grid point.
Definition Vector2d.hh:29
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
Definition Array.hh:66
void copy_from(const Array2D< T > &source)
Definition Array2D.hh:101
stencils::Star< T > star(int i, int j) const
Definition Array2D.hh:107
void add(double alpha, const Array2D< T > &x)
Definition Array2D.hh:93
void set_interpolation_type(InterpolationType type)
Definition Array.cc:181
std::shared_ptr< const Grid > grid() const
Definition Array.cc:134
void set(double c)
Result: v[j] <- c for all j.
Definition Array.cc:659
void update_ghosts()
Updates ghost points.
Definition Array.cc:645
VariableMetadata & metadata(unsigned int N=0)
Returns a reference to the VariableMetadata object containing metadata for the compoment N.
Definition Array.cc:467
bool next_to_ice(int i, int j) const
Ice-free margin (at least one of four neighbors has ice).
Definition CellType.hh:87
stencils::Star< int > star_int(int i, int j) const
Definition Scalar.hh:72
bool ice_free_ocean(int i, int j) const
Definition CellType.hh:58
bool ocean(int i, int j) const
Definition CellType.hh:34
"Cell type" mask. Adds convenience methods to array::Scalar.
Definition CellType.hh:30
int as_int(int i, int j) const
Definition Scalar.hh:45
stencils::Star< double > star(int i, int j) const
Returns the values at interfaces of the cell i,j using the staggered grid.
Definition Staggered.hh:75
void copy_from(const array::Staggered &input)
Definition Staggered.cc:42
A class for storing and accessing internal staggered-grid 2D fields. Uses dof=2 storage....
Definition Staggered.hh:37
std::shared_ptr< array::Array > compute_impl() const
FluxDivergence(const GeometryEvolution *m)
Report the divergence of the ice flux.
std::shared_ptr< array::Array > compute_impl() const
FluxStaggered(const GeometryEvolution *m)
Report mass flux on the staggered grid.
#define PISM_ERROR_LOCATION
#define n
Definition exactTestM.c:37
bool icy(int M)
Ice-filled cell (grounded or floating).
Definition Mask.hh:48
bool grounded_ice(int M)
Definition Mask.hh:51
bool ice_free_land(int M)
Definition Mask.hh:64
bool ice_free_ocean(int M)
Definition Mask.hh:61
bool grounded(int M)
Grounded cell (grounded ice or ice-free).
Definition Mask.hh:44
bool ice_free(int M)
Ice-free cell (grounded or ocean).
Definition Mask.hh:58
bool floating_ice(int M)
Definition Mask.hh:54
int make_nonnegative_preserving(double dt, const array::Scalar1 &x, const array::Staggered1 &flux, array::Staggered &result)
static double effective_change(double H, double dH)
static const double g
Definition exactTestP.cc:36
static double limit_advective_flux(int current, int neighbor, double input)
std::map< std::string, Diagnostic::Ptr > DiagnosticList
static double volume_flow_rate_from_land_to_water(const stencils::Star< int > &cell_type, const stencils::Star< double > &flux, double dx, double dy)
double part_grid_threshold_thickness(stencils::Star< int > cell_type, stencils::Star< double > ice_thickness, stencils::Star< double > surface_elevation, double bed_elevation)
Compute threshold thickness used when deciding if a partially-filled cell should be considered 'full'...
double total_grounding_line_flux(const array::CellType1 &cell_type, const array::Staggered1 &flux, double dt)
@ North
Definition stencils.hh:24
@ East
Definition stencils.hh:24
@ South
Definition stencils.hh:24
@ West
Definition stencils.hh:24
void ice_flow_rate_across_grounding_line(const array::CellType1 &cell_type, const array::Staggered1 &flux, double unit_conversion_factor, array::Scalar &output)
void GlobalSum(MPI_Comm comm, double *local, double *result, int count)
static double limit_diffusive_flux(int current, int neighbor, double flux)
array::Scalar flux_divergence
Flux divergence (used to track thickness changes due to flow).
array::Scalar thickness_change
Change in ice thickness due to flow during the last time step.
bool use_bmr
True if the basal melt rate contributes to geometry evolution.
Impl(std::shared_ptr< const Grid > g)
array::Scalar ice_area_specific_volume_change
Change in the ice area-specific volume due to flow during the last time step.
array::Staggered flux_limited
Temporary storage for the flux limiter.
array::Scalar effective_BMB
Effective basal mass balance.
bool use_part_grid
True if the part-grid scheme is enabled.
array::Staggered1 flux_staggered
Flux through cell interfaces. Ghosted.
array::Scalar effective_SMB
Effective surface mass balance.
Star stencil points (in the map-plane).
Definition stencils.hh:30