You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"""Boundary conditions for a PDE variable that are constant in space and time.
44
44
45
+
Attributes:
46
+
types: a tuple of tuples, where `types[i]` is a tuple specifying the lower and upper BC types for dimension `i`. The types can be one of the following:
values: a tuple of tuples, where `values[i]` is a tuple specifying the lower and upper boundary values for dimension `i`. If None, the boundary condition is homogeneous (zero).
49
+
45
50
Example usage:
46
51
grid = Grid((10, 10))
47
52
bc = ConstantBoundaryConditions(((BCType.PERIODIC, BCType.PERIODIC),
48
53
(BCType.DIRICHLET, BCType.DIRICHLET)),
49
54
((0.0, 10.0),(1.0, 0.0)))
55
+
# in dimension 0 is periodic, (0, 10) on left and right (un-used)
56
+
# in dimension 1 is dirichlet, (1, 0) on bottom and top.
50
57
v = GridVariable(torch.zeros((10, 10)), offset=(0.5, 0.5), grid, bc)
58
+
# v.offset is (0.5, 0.5) which is the cell center, so the boundary conditions have no effect in this case
51
59
52
-
Attributes:
53
-
types: `types[i]` is a tuple specifying the lower and upper BC types for
raiseNotImplementedError("Edge-aligned neumann BC are not implemented.")
109
+
if (self.types[dim][0] ==BCType.NEUMANNandmath.isclose(u.offset[dim], 1)) or (self.types[dim][1] ==BCType.NEUMANNandmath.isclose(u.offset[dim], 0)):
110
+
"""
111
+
if lower (or left for dim 0) is Neumann, and the offset is 1 (the variable is on the right edge of a cell), the Neumann bc is not defined; vice versa for upper (or right for dim 0) Neumann bc with offset 0 (the variable is on the left edge of a cell).
112
+
"""
113
+
raiseValueError("Variable not aligned with Neumann BC")
106
114
ifsize_diff<0:
107
115
raiseValueError(
108
116
"the GridVariable does not contain all interior grid values."
0 commit comments