[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

SKU: [Solved] MATH 233: Scientific Computing Lab 1— Grid2D class Category: Tag:
5/5 - (1 vote)
  1. Create a new C++ project.
  2. 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.
  3. In which file should that class be defined? (hint: modularity )
  4. 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?
  5. Implement a constructor Grid2D(N,M,xmin,xmax,ymin,ymax]) that initialize the grid with the prescribed parameters and initialize the resolutions x,y.
  6. 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.
  7. Write the reverse function nfromij(int i,int j).
  8. 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.
  9. 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.
  10. Install paraview.
  11. 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
  12. Open your file in paraview. Does it look right?
  13. (Further reading) what is the difference between a class and a struct?

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] MATH 233: Scientific Computing Lab 1 Grid2D class[Solved] MATH 233: Scientific Computing Lab 1 Grid2D class
$25