Equations
equations
This module contains abstract classes to define the structure of mathematical terms and equations within the GADOPT library. Users should not interact with these classes; instead, please use the solvers provided in other modules.
BaseEquation(test_space, trial_space, quad_degree=None, **kwargs)
Produces the UFL for the registered terms constituting an equation.
The equation instance is initialised given test and trial function spaces. Test and trial spaces are only used to determine the employed discretisation (i.e. UFL elements); test and trial functions are provided separately in the residual method.
Keyword arguments provided here are passed on to each collected equation term.
Attributes:
Name  Type  Description 

terms 
list[BaseTerm]

List of equation terms defined through inheritance from BaseTerm. 
Parameters:
Name  Type  Description  Default 

test_space 
WithGeometry

Firedrake function space of the test function 
required 
trial_space 
WithGeometry

Firedrake function space of the trial function 
required 
quad_degree 
Optional[int]

Quadrature degree. Default value is 
None

Source code in gadopt/gadopt/equations.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 

mass_term(test, trial)
Typical mass term used in time discretisations.
Parameters:
Name  Type  Description  Default 

test 
Argument

Firedrake test function 
required 
trial 
Argument  Function

Firedrake trial function 
required 
Returns:
Type  Description 

Expr

The UFL expression associated with the mass term of the equation. 
Source code in gadopt/gadopt/equations.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 

residual(test, trial, trial_lagged=None, fields=None, bcs=None)
Finite element residual.
The final residual is calculated as a sum of all individual term residuals.
Parameters:
Name  Type  Description  Default 

test 
Argument

Firedrake test function 
required 
trial 
Argument  Function

Firedrake trial function 
required 
trial_lagged 
Optional[Argument  Function]

Firedrake trial function from the previous time step 
None

fields 
Optional[dict[str, Constant  Function]]

Dictionary of physical fields from the simulation's state 
None

bcs 
Optional[dict[int, dict[str, int  float]]]

Dictionary of identifiervalue pairs specifying boundary conditions 
None

Returns:
Type  Description 

Expr

The UFL expression associated with all equation terms except the mass term. 
Source code in gadopt/gadopt/equations.py
97 98 99 100 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 

BaseTerm(test_space, trial_space, dx, ds, dS, **kwargs)
Bases: ABC
Defines an equation's term using an UFL expression.
The implemented expression describes the term's contribution to the residual in the finite element discretisation.
Parameters:
Name  Type  Description  Default 

test_space 
WithGeometry

Firedrake function space of the test function 
required 
trial_space 
WithGeometry

Firedrake function space of the trial function 
required 
dx 
Measure

UFL measure for the domain, boundaries excluded 
required 
ds 
Measure

UFL measure for the domain's outer boundaries 
required 
dS 
Measure

UFL measure for the domain's inner boundaries when using a discontinuous function space 
required 
Source code in gadopt/gadopt/equations.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 

residual(test, trial, trial_lagged=None, fields=None, bcs=None)
abstractmethod
Residual associated with the equation's term.
Parameters:
Name  Type  Description  Default 

test 
Argument

Firedrake test function 
required 
trial 
Argument  Function

Firedrake trial function 
required 
trial_lagged 
Optional[Argument  Function]

Firedrake trial function from the previous time step 
None

fields 
Optional[dict[str, Constant  Function]]

Dictionary of physical fields from the simulation's state 
None

bcs 
Optional[dict[int, dict[str, int  float]]]

Dictionary of identifiervalue pairs specifying boundary conditions 
None

Returns:
Type  Description 

Expr

A UFL expression for the term's contribution to the finite element residual. 
Source code in gadopt/gadopt/equations.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 
