Skip to content

Latest commit

 

History

History
105 lines (78 loc) · 4.35 KB

File metadata and controls

105 lines (78 loc) · 4.35 KB

Mesh overview

All solvers are based on a finite-volume/cell-centered discretization. The basic theory of such methods is discussed in :ref:`notes`.

Note

The core data structure that holds data on the grid is :func:`CellCenterData2d <pyro.mesh.patch.CellCenterData2d>`. This does not distinguish between cell-centered data and cell-averages. This is fine for methods that are second-order accurate, but for higher-order methods, the :func:`FV2d <pyro.mesh.fv.FV2d>` class has methods for converting between the two data centerings.

We import the basic mesh functionality as:

import pyro.mesh.patch as patch
import pyro.mesh.fv as fv
import pyro.mesh.boundary as bnd
import pyro.mesh.array_indexer as ai

There are several main objects in the patch class that we interact with:

The procedure for setting up a grid and the data that lives on it is as follows:

myg = patch.Grid2d(16, 32, xmax=1.0, ymax=2.0)

This creates the 2-d grid object myg with 16 zones in the x-direction and 32 zones in the y-direction. It also specifies the physical coordinate of the rightmost edge in x and y.

mydata = patch.CellCenterData2d(myg)

bc = bnd.BC(xlb="periodic", xrb="periodic", ylb="reflect-even", yrb="outflow")

mydata.register_var("a", bc)
mydata.create()

This creates the cell-centered data object, mydata, that lives on the grid we just built above. Next we create a boundary condition object, specifying the type of boundary conditions for each edge of the domain, and finally use this to register a variable, a that lives on the grid. Once we call the create() method, the storage for the variables is allocated and we can no longer add variables to the grid. Note that each variable needs to specify a BC—this allows us to do different actions for each variable (for example, some may do even reflection while others may do odd reflection).

Tests

The actual filling of the boundary conditions is done by the :func:`fill_BC <pyro.mesh.patch.CellCenterData2d.fill_BC>` method. The script bc_demo.py tests the various types of boundary conditions by initializing a small grid with sequential data, filling the BCs, and printing out the results.