- Create a new C++ project.
- In this new project, create a new class named Grid2D. It will be used to represent 2dimensional grids with N M points uniformly distributed over [xmin,xmax] [ymin,ymax]. Nodes will be numbered according to the standard z-ordering. x,y will be the spatial resolutions.
- In which file should that class be defined? (hint: modularity )
- In the Grid2D class, define N,M,xmin,xmax,ymin,ymax,x,y as private variables. What types should they be? Why should they be private?
- Implement a constructor Grid2D(N,M,xmin,xmax,ymin,ymax]) that initialize the grid with the prescribed parameters and initialize the resolutions x,y.
- Write two public functions ifromn(int n) and jfromn(int n) that take the index n of a grid point and return its logical coordinates (i,j) on the grid.
- Write the reverse function nfromij(int i,int j).
- Write a function xfromn(int n), that take the index of a node and return its position in the direction. Write the same function for the y-direction.
- Use the outputVTK.txt file to implement two functions initializeVTKfile and printQuantityintoVTKfile that create a vtk file with the grid information and output the values of a given quantity (defined on that grid) in a specified vtk file.
- Install paraview.
- Write a main file that
- Create a Grid2D with your choice of parameters
- Create a vector of size N M representing the function cos(x)cos(y) over the grid.
- Output the grid and the vector into one .vtk file
- Open your file in paraview. Does it look right?
- (Further reading) what is the difference between a class and a struct?
MATH233
[Solved] MATH 233: Scientific Computing Lab 1 Grid2D class
$25
File Name: MATH_233__Scientific_Computing_Lab_1_Grid2D_class.zip
File Size: 461.58 KB
Only logged in customers who have purchased this product may leave a review.

![[Solved] MATH 233: Scientific Computing Lab 1 Grid2D class](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip.jpg)

![[Solved] MATH 233: Scientific Computing Assignment 1 Hello World](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip-1200x1200.jpg)
Reviews
There are no reviews yet.