Transport solver
transport_solver
This module provides a minimal solver, independent of any approximation, for generic
transport equations, which may include advection, diffusion, sink, and source terms, and
a fine-tuned solver class for the energy conservation equation. Users instantiate the
GenericTransportSolver
or EnergySolver
classes by providing the appropriate
documented parameters and call the solve
method to request a solver update.
iterative_energy_solver_parameters: dict[str, Any] = {'mat_type': 'aij', 'snes_type': 'ksponly', 'ksp_type': 'gmres', 'ksp_rtol': 1e-05, 'pc_type': 'sor'}
module-attribute
Default iterative solver parameters for solution of energy equation.
Configured to use the GMRES Krylov scheme with Successive Over Relaxation (SOR) preconditioning. Note that default energy solver parameters can be augmented or adjusted by accessing the solver_parameter dictionary.
Examples:
>>> energy_solver.solver_parameters['ksp_converged_reason'] = None
>>> energy_solver.solver_parameters['ksp_rtol'] = 1e-4
Note
G-ADOPT defaults to iterative solvers in 3-D.
direct_energy_solver_parameters: dict[str, Any] = {'mat_type': 'aij', 'snes_type': 'ksponly', 'ksp_type': 'preonly', 'pc_type': 'lu', 'pc_factor_mat_solver_type': 'mumps'}
module-attribute
Default direct solver parameters for solution of energy equation.
Configured to use LU factorisation performed via the MUMPS library.
Note
G-ADOPT defaults to direct solvers in 2-D.
GenericTransportBase(solution, /, delta_t, timestepper, *, solution_old=None, eq_attrs={}, bcs={}, solver_parameters=None, su_diffusivity=None)
Bases: ABC
Base class for advancing a generic transport equation in time.
All combinations of advection, diffusion, sink, and source terms are handled.
Note: The solution field is updated in place.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
solution |
Function
|
Firedrake function for the field of interest |
required |
delta_t |
Constant
|
Simulation time step |
required |
timestepper |
RungeKuttaTimeIntegrator
|
Runge-Kutta time integrator employing an explicit or implicit numerical scheme |
required |
solution_old |
Function | None
|
Firedrake function holding the solution field at the previous time step |
None
|
eq_attrs |
dict[str, float]
|
Dictionary of terms arguments and their values |
{}
|
bcs |
dict[int, dict[str, Number]]
|
Dictionary specifying boundary conditions (identifier, type, and value) |
{}
|
solver_parameters |
dict[str, str | Number] | str | None
|
Dictionary of solver parameters or a string specifying a default configuration provided to PETSc |
None
|
su_diffusivity |
float | None
|
Float activating the streamline-upwind stabilisation scheme and specifying the corresponding diffusivity |
None
|
Source code in g-adopt/gadopt/transport_solver.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
|
set_boundary_conditions()
Sets up boundary conditions.
Source code in g-adopt/gadopt/transport_solver.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
|
set_su_nubar()
Sets up the advection streamline-upwind scheme (Donea & Huerta, 2003).
Columns of Jacobian J are the vectors that span the quad/hex and can be seen as unit vectors scaled with the dx/dy/dz in that direction (assuming physical coordinates x, y, z aligned with local coordinates). Thus u^T J is (dx * u , dy * v). Following (2.44c), Pe = u^T J / 2 kappa, and beta(Pe) is the xibar vector in (2.44a). Finally, we get the artificial diffusion nubar from (2.49).
Donea, J., & Huerta, A. (2003). Finite element methods for flow problems. John Wiley & Sons.
Source code in g-adopt/gadopt/transport_solver.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|
set_equation()
abstractmethod
Sets up the term contributions in the equation.
Source code in g-adopt/gadopt/transport_solver.py
194 195 196 197 |
|
set_solver_options()
Sets PETSc solver parameters.
Source code in g-adopt/gadopt/transport_solver.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
|
setup_solver()
Sets up the timestepper using specified parameters.
Source code in g-adopt/gadopt/transport_solver.py
224 225 226 227 228 229 230 231 232 233 234 235 |
|
solver_callback()
Optional instructions to execute right after a solve.
Source code in g-adopt/gadopt/transport_solver.py
237 238 239 |
|
solve(t=0, update_forcings=None)
Advances solver in time.
Source code in g-adopt/gadopt/transport_solver.py
241 242 243 244 245 246 247 248 |
|
GenericTransportSolver(terms, solution, /, delta_t, timestepper, **kwargs)
Bases: GenericTransportBase
Advances in time a generic transport equation.
Note: The solution field is updated in place.
Terms and Attributes
This solver handles all combinations of advection, diffusion, sink, and source terms. Depending on the included terms, specific attributes must be provided according to:
Term | Required attribute(s) | Optional attribute(s) |
---|---|---|
advection | u | advective_velocity_scaling, su_nubar |
diffusion | diffusivity | reference_for_diffusion, interior_penalty |
source | source | |
sink | sink_coeff |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
terms |
str | list[str]
|
List of equation terms to include (a string for a single term is accepted) |
required |
solution |
Function
|
Firedrake function for the field of interest |
required |
delta_t |
Constant
|
Simulation time step |
required |
timestepper |
RungeKuttaTimeIntegrator
|
Runge-Kutta time integrator employing an explicit or implicit numerical scheme |
required |
solution_old |
Firedrake function holding the solution field at the previous time step |
required | |
eq_attrs |
Dictionary of terms arguments and their values |
required | |
bcs |
Dictionary specifying boundary conditions (identifier, type, and value) |
required | |
solver_parameters |
Dictionary of solver parameters or a string specifying a default configuration provided to PETSc |
required | |
su_diffusivity |
Float activating the streamline-upwind stabilisation scheme and specifying the corresponding diffusivity |
required |
Source code in g-adopt/gadopt/transport_solver.py
294 295 296 297 298 299 300 301 302 303 304 305 |
|
EnergySolver(solution, u, approximation, /, delta_t, timestepper, **kwargs)
Bases: GenericTransportBase
Advances in time the energy conservation equation.
Note: The solution field is updated in place.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
solution |
Function
|
Firedrake function for temperature |
required |
u |
Function
|
Firedrake function for velocity |
required |
approximation |
BaseApproximation
|
G-ADOPT approximation defining terms in the system of equations |
required |
delta_t |
Constant
|
Simulation time step |
required |
timestepper |
RungeKuttaTimeIntegrator
|
Runge-Kutta time integrator employing an explicit or implicit numerical scheme |
required |
solution_old |
Firedrake function holding the solution field at the previous time step |
required | |
bcs |
Dictionary specifying boundary conditions (identifier, type, and value) |
required | |
solver_parameters |
Dictionary of solver parameters or a string specifying a default configuration provided to PETSc |
required | |
su_diffusivity |
Float activating the streamline-upwind stabilisation scheme and specifying the corresponding diffusivity |
required |
Source code in g-adopt/gadopt/transport_solver.py
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
|