# Differential Operators¶

discretize.DiffOperators.checkBC(bc)[source]

Checks if boundary condition ‘bc’ is valid.

Each bc must be either ‘dirichlet’ or ‘neumann’

discretize.DiffOperators.ddxCellGrad(n, bc)[source]

Create 1D derivative operator from cell-centers to nodes this means we go from n to n+1

For Cell-Centered Dirichlet, use a ghost point:

(u_1 - u_g)/hf = grad

u_g       u_1      u_2
*    |    *   |    *     ...
^
0

u_g = - u_1
negitive on the other side.


For Cell-Centered Neumann, use a ghost point:

(u_1 - u_g)/hf = 0

u_g       u_1      u_2
*    |    *   |    *     ...

u_g = u_1
grad = 0;  put a zero in.

discretize.DiffOperators.ddxCellGradBC(n, bc)[source]

Create 1D derivative operator from cell-centers to nodes this means we go from n to n+1

For Cell-Centered Dirichlet, use a ghost point:

(u_1 - u_g)/hf = grad

u_g       u_1      u_2
*    |    *   |    *     ...
^
u_b


We know the value at the boundary (u_b):

(u_g+u_1)/2 = u_b               (the average)
u_g = 2*u_b - u_1

So plug in to gradient:

(u_1 - (2*u_b - u_1))/hf = grad


Separate, because BC are known (and can move to RHS later):

( 2/hf )*u_1 + ( -2/hf )*u_b = grad

(   ^   ) JUST RETURN THIS

class discretize.DiffOperators.DiffOperators[source]

Class creates the differential operators that you need!

faceDiv

Construct divergence operator (face-stg to cell-centres).

faceDivx

Construct divergence operator in the x component (face-stg to cell-centres).

faceDivy
faceDivz

Construct divergence operator in the z component (face-stg to cell-centers).

nodalGrad

Construct gradient operator (nodes to edges).

nodalLaplacian

Construct laplacian operator (nodes to edges).

setCellGradBC(BC)[source]

Function that sets the boundary conditions for cell-centred derivative operators.

Examples::

# Neumann in all directions BC = ‘neumann’

# 3D, Dirichlet in y Neumann else BC = [‘neumann’, ‘dirichlet’, ‘neumann’]

# 3D, Neumann in x on bottom of domain, Dirichlet else BC = [[‘neumann’, ‘dirichlet’], ‘dirichlet’, ‘dirichlet’]

cellGrad

The cell centered Gradient, takes you to cell faces.

cellGradBC

The cell centered Gradient boundary condition matrix

cellGradx

Cell centered Gradient in the x dimension. Has neumann boundary conditions.

cellGrady
cellGradz

Cell centered Gradient in the x dimension. Has neumann boundary conditions.

edgeCurl

Construct the 3D curl operator.

getBCProjWF(BC, discretization='CC')[source]

The weak form boundary condition projection matrices.

Examples::

# Neumann in all directions BC = ‘neumann’

# 3D, Dirichlet in y Neumann else BC = [‘neumann’, ‘dirichlet’, ‘neumann’]

# 3D, Neumann in x on bottom of domain, Dirichlet else BC = [[‘neumann’, ‘dirichlet’], ‘dirichlet’, ‘dirichlet’]

getBCProjWF_simple(discretization='CC')[source]

The weak form boundary condition projection matrices when mixed boundary condition is used

aveF2CC

Construct the averaging operator on cell faces to cell centers.

aveF2CCV

Construct the averaging operator on cell faces to cell centers.

aveFx2CC

Construct the averaging operator on cell faces in the x direction to cell centers.

aveFy2CC

Construct the averaging operator on cell faces in the y direction to cell centers.

aveFz2CC

Construct the averaging operator on cell faces in the z direction to cell centers.

aveCC2F

Construct the averaging operator on cell centers to faces.

aveCCV2F

Construct the averaging operator on cell centers to faces as a vector.

aveE2CC

Construct the averaging operator on cell edges to cell centers.

aveE2CCV

Construct the averaging operator on cell edges to cell centers.

aveEx2CC

Construct the averaging operator on cell edges in the x direction to cell centers.

aveEy2CC

Construct the averaging operator on cell edges in the y direction to cell centers.

aveEz2CC

Construct the averaging operator on cell edges in the z direction to cell centers.

aveN2CC

Construct the averaging operator on cell nodes to cell centers.

aveN2E

Construct the averaging operator on cell nodes to cell edges, keeping each dimension separate.

aveN2F

Construct the averaging operator on cell nodes to cell faces, keeping each dimension separate.