-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_rect_grid.cpp
39 lines (33 loc) · 966 Bytes
/
create_rect_grid.cpp
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
/** @brief Creates a rectilinear grid from data passed as command-line arguments.
*
* Requires 5 arguments:
* - Number of points in i-direction
* - Number of points in j-direction
* - Length of domain in i-direction
* - Length of domain in j-direction
* - Output mesh file name.
*/
#include <structmesh2d.hpp>
using namespace amat;
using namespace acfd;
using namespace std;
int main(int argc, char* argv[])
{
if(argc < 4) {
cout << "Need 5 arguments: No. of points in i-dir, number of points in j-dir, x-length, y-length and output file name." << endl;
return -1;
}
int imx = stoi(argv[1]);
int jmx = stoi(argv[2]);
double xlength = stod(argv[3]);
double ylength = stod(argv[4]);
ofstream fout(argv[5]);
fout << setprecision(20);
fout << imx << " " << jmx << '\n';
for(int j = 0; j < jmx; j++)
for(int i = 0; i < imx; i++)
fout << xlength/(imx-1)*i << " " << ylength/(jmx-1)*j << '\n';
fout.close();
cout << endl;
return 0;
}