numerics 0.1.0
Loading...
Searching...
No Matches
grid2d.hpp
Go to the documentation of this file.
1/// @file fields/grid2d.hpp
2/// @brief 2D uniform interior grid: geometry only, no field data.
3///
4/// Grid2D describes the spatial discretization of [0,1]^2 into N x N
5/// interior nodes with spacing h = 1/(N+1). It carries no field values
6/// and no boundary conditions -- those belong to the operator and the field.
7#pragma once
8
9#include "core/types.hpp"
10
11namespace num {
12
13struct Grid2D {
14 int N; ///< interior nodes per side
15 double h; ///< grid spacing = 1/(N+1)
16
17 double x(int i) const { return (i + 1) * h; }
18 double y(int j) const { return (j + 1) * h; }
19 int flat(int i, int j) const { return (i * N) + j; }
20 int size() const { return N * N; }
21};
22
23} // namespace num
Core type definitions.
int flat(int i, int j) const
Definition grid2d.hpp:19
int N
interior nodes per side
Definition grid2d.hpp:14
double x(int i) const
Definition grid2d.hpp:17
double y(int j) const
Definition grid2d.hpp:18
double h
grid spacing = 1/(N+1)
Definition grid2d.hpp:15
int size() const
Definition grid2d.hpp:20