-
Notifications
You must be signed in to change notification settings - Fork 0
/
Grid2d.h
57 lines (46 loc) · 1.3 KB
/
Grid2d.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//
// Created by Zihan Xu on 10/19/22.
//
#ifndef LAB01_GRID2D_H
#define LAB01_GRID2D_H
#include <iostream>
#include <fstream>
#include <vector>
class Grid2d {
// Objective: creates a 2D grid
private:
double dx; // spacing in x
double dy; // spacing in y
long N; // number of nodes in x
long M; // number of nodes in y
double xmin;
double xmax;
double ymin;
double ymax;
public:
double get_dx(); // return dx to user
double get_dy(); // return dy to user
double get_xmin();
double get_ymin();
double get_xmax();
double get_ymax();
long get_N();
long get_M();
// Constructor to create object
Grid2d();
// Constructor to initialize values
Grid2d(long NN, long MM, double xlo, double xhi, double ylo, double yhi);
// Return coord (i,j) from grid index n
long i_from_n(long n);
long j_from_n(long n);
// Return grid index n from coord (i, j)
long n_from_ij(long i, long j);
// Return position of grid index n
double x_from_n(long n);
double y_from_n(long n);
// output file in VTK format
void print_VTK_format(std::string output_file);
void print_VTK_format(std::vector<double> &F, std::string data_name,
std::string file_name);
};
#endif //LAB01_GRID2D_H