discretize.operators.DiffOperators.set_cell_gradient_BC#
- DiffOperators.set_cell_gradient_BC(BC)[source]#
Set boundary conditions for derivative operators acting on cell-centered quantities.
This method is used to set zero Dirichlet and/or zero Neumann boundary conditions for differential operators that act on cell-centered quantities. The user may apply the same boundary conditions to all boundaries, or define the boundary conditions of boundary face (x, y and z) separately. The user may also apply boundary conditions to the lower and upper boundary face separately.
Cell gradient boundary conditions are enforced when constructing the following properties:
By default, the mesh assumes a zero Neumann boundary condition on the entire boundary. To define robin boundary conditions, see
cell_gradient_weak_form_robin
.- Parameters:
Examples
Here we demonstrate how to apply zero Dirichlet and/or Neumann boundary conditions for cell-centers differential operators.
>>> from discretize import TensorMesh >>> mesh = TensorMesh([[(1, 20)], [(1, 20)], [(1, 20)]])
Define zero Neumann conditions for all boundaries
>>> BC = 'neumann' >>> mesh.set_cell_gradient_BC(BC)
Define zero Dirichlet on y boundaries and zero Neumann otherwise
>>> BC = ['neumann', 'dirichlet', 'neumann'] >>> mesh.set_cell_gradient_BC(BC)
Define zero Neumann on the bottom x-boundary and zero Dirichlet otherwise
>>> BC = [['neumann', 'dirichlet'], 'dirichlet', 'dirichlet'] >>> mesh.set_cell_gradient_BC(BC)