I have a little background in writing toy finite volume CFD codes. In 2D Cartesian scenarios, I typically take $x_{\min}$, $x_{\max}$, $y_{\min}$, $y_{\max}$, and the number of points in $x$ and $y$ to calculate $\Delta x$ and $\Delta y$. Then, I compute cell centers and assemble a 1D array of cells. To perform field operations, I loop over this array of cells, storing items at node centers and interpolating to faces as necessary.
In researching more advanced projects, I see that a face-based data structure is advantageous in terms of conservation, flexibility, and application of boundary conditions.
My question: For a Cartesian 2D domain, how does one generate a list of faces from arrays of vertex coordinates? These faces should compose quadrilateral cells. Can this be done explicitly?
Obviously, I could create an extremely simple 2D Cartesian mesh in something like Gmsh
, but then I'd have to read in a mesh and parse the file.
I can write this functionality eventually, but for my own edification, I want to quickly explore a face-based code.