-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Grid Topology
concept
#489
Comments
@ali-ramadhan do you have any thoughts on the design of |
My biggest concern is that introducing a grid topology and keeping the current implementation of boundary conditions will cause confusion as they perform overlapping functions. But I think with a bit of thinking there can be lots of benefits to adding a grid topology as you say.
That would be great I think. If each field now carries around its own boundary conditions and horizontally periodic and channel BCs are treated a grid topology then we can get rid of
True. We currently don't have a clean way of eliding unnecessary operations for 1D and 2D models. Dispatching on the grid topology would provide a way of doing this very cleanly. |
Following up from our discussion: We can just add three parametric types to grid = RegularCartesianGrid(size=(256, 256, 512), length=(500, 500, 100), topology=(Periodic, Periodic, Bounded) This will be a breaking change. Initially the grid topology won't actually be used, that will come in later PRs. The grid topology can then be used to construct boundary conditions. We can get rid of model boundary conditions and solution boundary conditions. Here's the API I'm thinking of: Passing (the default) boundary_conditions = nothing # Not sure what else to put? to the To assign explicit boundary conditions: u_bcs = FieldBoundaryConditions(top = BoundaryCondition(Flux, 1e-5))
T_bcs = FieldBoundaryConditions(top = BoundaryCondition(Flux, -5e-4),
bottom = BoundaryCondition(Gradient, 0.01))
...
model = Model(
...
boundary_conditions = (u=u_bcs, T=T_bcs)
) will assign specific boundary conditions on So users will only have to specify a named tuple of
Thinking a bit ahead: If we want boundary conditions to be a property of each field, we need to create the boundary conditions first then create the fields. Currently fields are instantiated in the I think we can get around this (and make #416 easier to resolve) by adding something like a X-Ref: #606 |
It will break the boundary condition constructors, but need not break the grid constructor if we use a doubly-periodic default.
I think we want to write a constructor to create default boundary conditions. This can be the default in the
It does seem that we unfortunately need to manually check these cases. Ideas welcome for alternative solutions...
u_bcs = FieldBoundaryConditions(top = BoundaryCondition(Flux, 1e-5))
T_bcs = FieldBoundaryConditions(top = BoundaryCondition(Flux, -5e-4),
bottom = BoundaryCondition(Gradient, 0.01)) Your
Rather than requiring users to constructor field arrays, which I think will introduce a lot of boilerplate to scripts and make the code harder to use, we can move the construction of fields from the constructor function signature into the constructor function body. This way we can ensure that boundary conditions are set after the fields are created in the case that users do not create the fields themselves, and also allow users to directly pass in the velocity fields with pre-set boundary conditions to |
I think the concept of grid
Topology
will be useful.The
Topology
codifies information about the domain in which the grid is defined. We have three (currently implicit) topologies for each orthogonal directionx
,y
,z
:Flat
,Bounded
, andPeriodic
.A
Flat
topology hasN=1
. ABounded
topology has boundaries (either closed or open, though we only supported closed boundaries right now) on left and right. APeriodic
topology is periodic in the specified direction.I propose that we create 3 new type parameters of the grid that codify whether the grid is
Flat
,Bounded
, orPeriodic
in each ofx
,y
,z
.We can add a keyword to the constructors for grids that allow users to specify the grid topology. For example, the topology that we call a 'Channel Model' would be specified via
A two-dimensional grid can also be defined.
Topologies imply default boundary conditions: a
Bounded
direction has no-flux boundary conditions; aPeriodic
direction hasPeriodic
boundary conditions. For aFlat
direction we can also use no flux conditions, though it should be irrelevant.This change will eliminate the need for a special
ChannelModel
constructor, and also eliminates the need for constructors with names likeHorizontallyPeriodicBCs
. Instead, we have a generic constructor forFieldBoundaryConditions
that lets a user specify boundary conditions in any direction. User-supplied boundary conditions are then checked for consistency with the specified topology, and missing default boundary conditions are added where none exist.A
Flat
topology will enable us to set halo sizes to 0 forFlat
directions, and elide the unnecessary interpolation and differentiation operations inFlat
directions that currently plagues two and one-dimensional models.A related issue is #330, but this proposal has wider-ranging consequences so I decided to open a new issue.
The text was updated successfully, but these errors were encountered: