- 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?
[SOLVED] MATH 233: Scientific Computing Lab 1— Grid2D class
35.00 $
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
Securely Powered by:
- Lab1-vuaphe.zip



