Guest User

Untitled

a guest
Jun 21st, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. double f(double,double,double,double,double);
  8.  
  9. int main()
  10. {
  11. ofstream myfile;
  12. myfile.open("example.vtk",ios::out|ios::app|ios::binary);
  13. myfile <<"# vtk DataFile Version 2.0\n";
  14. myfile<<"Testdata \n";
  15. myfile<<"BINARY \n";
  16. myfile<<"DATASET STRUCTURED_POINTS \n";
  17. myfile<<"DIMENSIONS 5 5 5 5 5 \n";
  18. myfile<<"ORIGIN -2 -2 -2 -2 -2 \n";
  19. myfile<<"SPACING 1 1 1 1 1 \n";
  20. myfile<<"POINT_DATA 3125\n";
  21. myfile<<"SCALARS scalarfield double\n";
  22. myfile<<"LOOKUP_TABLE default\n";
  23.  
  24. double p1,p2,p3,p4,p5;
  25. double start1=-2.0; double spacing1=1.0; int nre=5;
  26. double start2=-2.0; double spacing2=1.0; int nrd=5;
  27. double start3=-2.0; double spacing3=1.0; int nrc=5;
  28. double start4=-2.0; double spacing4=1.0; int nrb=5;
  29. double start5=-2.0; double spacing5=1.0; int nra=5;
  30.  
  31.  
  32. for(int a=0;a<nra;a++)
  33. {
  34. for(int b=0;b<nrb;b++)
  35. {
  36. for(int c=0;c<nrc;c++)
  37. {
  38. for(int d=0;d<nra;d++)
  39. {
  40. for(int e=0;e<nre;e++)
  41. {
  42. p1=start5+e*spacing1;
  43. p2=start5+d*spacing2;
  44. p3=start5+c*spacing3;
  45. p4=start5+b*spacing4;
  46. p5=start5+a*spacing5;
  47. myfile<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<" "<<p5<<" "<<f(p1,p2,p3,p4,p5)<<endl;
  48. //myfile.write((char *)&f(p1,p2,p3,p4,p5), sizeof(double));
  49.  
  50. }
  51.  
  52. }
  53.  
  54. }
  55. }
  56.  
  57. }
  58.  
  59. myfile.close();
  60. return 0;
  61.  
  62. }
  63.  
  64.  
  65. double f(double p1,double p2,double p3,double p4,double p5)
  66. {
  67. return (p1*p1+p2*p2+p3*p3+p4*p4+p5*p5);
  68. }
Add Comment
Please, Sign In to add comment