Skip to content

Commit 6e3db2b

Browse files
authored
Merge pull request #32153 from grmnptr/frozen-fields-32151
Make sure we can disable different parts of the segregated solve after restart.
2 parents 4e20664 + 71a8f9f commit 6e3db2b

12 files changed

Lines changed: 483 additions & 74 deletions

File tree

framework/include/base/Moose.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "libmesh/libmesh_common.h"
1515
#include "XTermConstants.h"
1616

17+
#include <limits>
1718
#include <memory>
1819
#include <set>
1920
#include <string>
@@ -161,6 +162,9 @@ static_assert(LIBMESH_DIM == 3,
161162
*/
162163
static constexpr std::size_t dim = LIBMESH_DIM;
163164

165+
/// Value for invalid size_t indices
166+
inline constexpr std::size_t invalid_size_t = std::numeric_limits<std::size_t>::max();
167+
164168
/**
165169
* Used by the signal handler to determine if we should write a checkpoint file out at any point
166170
* during operation.

modules/navier_stokes/doc/config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Content:
44
- modules/fluid_properties/doc/content
55
- modules/heat_transfer/doc/content
66
- modules/ray_tracing/doc/content
7+
- utility:
8+
root_dir: ${MOOSE_DIR}/modules/doc/content
9+
content:
10+
- application_usage/restart_recover.md
711

812
Renderer:
913
type: MooseDocs.base.MaterializeRenderer

modules/navier_stokes/doc/content/source/executioners/PIMPLE.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,37 @@ block is different:
4040

4141
!listing modules/navier_stokes/test/tests/finite_volume/ins/channel-flow/linear-segregated/2d/2d-boussinesq-transient.i block=Executioner
4242

43+
### Restarting and keeping certain solution fields unchanged
44+
45+
When recovering from a checkpoint, it can be useful to hold the thermal-hydraulics fields fixed
46+
and only advance other systems. The `PIMPLE` executioner exposes flags that selectively disable parts
47+
of the segregated solve:
48+
49+
- [!param](/Executioner/PIMPLE/should_solve_momentum)
50+
- [!param](/Executioner/PIMPLE/should_solve_pressure)
51+
- [!param](/Executioner/PIMPLE/should_solve_energy)
52+
- [!param](/Executioner/PIMPLE/should_solve_solid_energy)
53+
- [!param](/Executioner/PIMPLE/should_solve_turbulence)
54+
- [!param](/Executioner/PIMPLE/should_solve_active_scalars)
55+
- [!param](/Executioner/PIMPLE/should_solve_passive_scalars)
56+
57+
For example, to load a converged flow/temperature field from a steady-state run and only march
58+
passive scalars, enable [restart and recovery](restart_recover.md optional=True), keep the scalar solves enabled, and disable the momentum,
59+
pressure, and energy solves:
60+
61+
```
62+
[Problem]
63+
restart_file_base=converged_run_cp/LATEST
64+
[]
65+
[Executioner]
66+
type = PIMPLE
67+
...
68+
should_solve_momentum = false
69+
should_solve_pressure = false
70+
should_solve_energy = false
71+
[]
72+
```
73+
4374
!syntax parameters /Executioner/PIMPLE
4475

4576
!syntax inputs /Executioner/PIMPLE

modules/navier_stokes/doc/content/source/executioners/SIMPLE.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,37 @@ Several systems may be used, for each passive scalar.
157157

158158
For the conjuagate heat transfer capabilities visit the [corresponding design page](linear_fv_cht.md)
159159

160+
### Restarting and keeping certain solution fields unchanged
161+
162+
When recovering from a checkpoint, it can be useful to hold the thermal-hydraulics fields fixed
163+
and only advance other systems. The `PIMPLE` executioner exposes flags that selectively disable parts
164+
of the segregated solve:
165+
166+
- [!param](/Executioner/SIMPLE/should_solve_momentum)
167+
- [!param](/Executioner/SIMPLE/should_solve_pressure)
168+
- [!param](/Executioner/SIMPLE/should_solve_energy)
169+
- [!param](/Executioner/SIMPLE/should_solve_solid_energy)
170+
- [!param](/Executioner/SIMPLE/should_solve_turbulence)
171+
- [!param](/Executioner/SIMPLE/should_solve_active_scalars)
172+
- [!param](/Executioner/SIMPLE/should_solve_passive_scalars)
173+
174+
For example, to load a converged flow/temperature field from a steady-state run and only march
175+
passive scalars, enable [restart and recovery](restart_recover.md optional=True), keep the scalar solves enabled, and disable the momentum,
176+
pressure, and energy solves:
177+
178+
```
179+
[Problem]
180+
restart_file_base=converged_run_cp/LATEST
181+
[]
182+
[Executioner]
183+
type = SIMPLE
184+
...
185+
should_solve_momentum = false
186+
should_solve_pressure = false
187+
should_solve_energy = false
188+
[]
189+
```
190+
160191
!syntax parameters /Executioner/SIMPLE
161192

162193
!syntax inputs /Executioner/SIMPLE

modules/navier_stokes/include/executioners/LinearAssemblySegregatedSolve.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,35 @@ class LinearAssemblySegregatedSolve : public SIMPLESolveBase
7272
const Real field_relaxation = 1.0,
7373
const Real min_value_limiter = std::numeric_limits<Real>::min());
7474

75+
/// Aggregated storage for residuals, tolerances, and indices used in convergence checks
76+
struct ResidualStorage
77+
{
78+
/// (linear iterations, normalized residual) entries in the order used by NS::FV::converged()
79+
std::vector<std::pair<unsigned int, Real>> ns_residuals;
80+
/// Absolute tolerances matching ns_residuals
81+
std::vector<Real> ns_abs_tols;
82+
/// Indices of momentum equations in ns_residuals
83+
std::vector<std::size_t> momentum_indices;
84+
/// Index of the pressure equation in ns_residuals
85+
std::size_t pressure_index = Moose::invalid_size_t;
86+
/// Index of the energy equation in ns_residuals
87+
std::size_t energy_index = Moose::invalid_size_t;
88+
/// Index of the solid energy equation in ns_residuals
89+
std::size_t solid_energy_index = Moose::invalid_size_t;
90+
/// Indices of active scalar equations in ns_residuals
91+
std::vector<std::size_t> active_scalar_indices;
92+
/// Indices of turbulence surrogate equations in ns_residuals
93+
std::vector<std::size_t> turbulence_indices;
94+
/// This will be an initial indicator if we have something to solve.
95+
/// If we dont have anything we just set this to true.
96+
bool converged = false;
97+
};
98+
99+
/**
100+
* Build residual/tolerance vectors and associated indices for all enabled systems.
101+
*/
102+
ResidualStorage setupResidualStorage() const;
103+
75104
/// Solve an equation which contains the solid energy conservation.
76105
std::pair<unsigned int, Real> solveSolidEnergy();
77106

@@ -114,6 +143,15 @@ class LinearAssemblySegregatedSolve : public SIMPLESolveBase
114143
/// Shortcut to every linear system that we solve for here
115144
std::vector<LinearSystem *> _systems_to_solve;
116145

146+
/// Flags controlling which systems are actively solved (can be used with restart to freeze flow)
147+
const bool _should_solve_momentum;
148+
const bool _should_solve_pressure;
149+
const bool _should_solve_energy;
150+
const bool _should_solve_solid_energy;
151+
const bool _should_solve_turbulence;
152+
const bool _should_solve_passive_scalars;
153+
const bool _should_solve_active_scalars;
154+
117155
// ************************ Active Scalar Variables ************************ //
118156

119157
/// The names of the active scalar systems

0 commit comments

Comments
 (0)