NUMCXX  0.13.20181108
Numerical library for small projects and teaching purposes
Functions
23-numcxx-vtkfigrect3D.cxx File Reference
+ Include dependency graph for 23-numcxx-vtkfigrect3D.cxx:

Go to the source code of this file.

Functions

int main (void)
 

Function Documentation

int main ( void  )

Definition at line 10 of file 23-numcxx-vtkfigrect3D.cxx.

11 {
12  const double x0=0.0;
13  const double x1=1.0;
14  double h=0.05;
15  double t0=0.0;
16  double t1=10.0;
17  double dt=0.01;
18 
19  const int N=1+ceil((x1-x0)/h);
20  h=(x1-x0)/(double)(N-1);
21 
22  numcxx::DArray1 X(N);
23  numcxx::DArray1 U(N*N*N);
24 
25  X(0)=x0;
26  for (int i=1;i<N;i++)
27  {
28  X(i)=X(i-1)+h;
29  }
30 
31 
32 
33  auto griddata=vtkfig::DataSet::New();
34  griddata->SetRectilinearGrid(X,X,X);
35 
36 
37  auto frame=vtkfig::Frame::New();
38  auto scview=vtkfig::ScalarView::New();
39  scview->SetData(griddata,"U");
40  frame->AddFigure(scview);
41 
42  double t=t0;
43 
44 
45  while (t<t1)
46  {
47  int ijk=0;
48  for (int i=0; i<N; i++)
49  for (int j=0; j<N; j++)
50  for (int k=0; k<N; k++,ijk++)
51  {
52  U(ijk)=sin(10.0*(X(i)-t))*cos(10.0*(X(j)-2*t))*cos(10.0*X(k)-0.5*t);
53  }
54  char titlebuf[20];
55  snprintf(titlebuf,20,"t=%g",t);
56  griddata->SetPointScalar(U ,"U");
57  frame->Show();
58  t+=dt;
59  }
60 
61 }
One dimensional array class.
Definition: tarray1.hxx:31