Department of Scientific Computing   
Institute for Numerical Simulation   
University of Bonn   
Documentation
Download
Programming References
Bug Reports / Suggestions
FAQ
Authors
Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

Navier.hpp

00001 //
00002 // DataStructure for Navier-Stokes Simulations
00003 //
00004 
00005 #include <stdio.h>
00006 #include <stdlib.h>
00007 
00008 #include "AdaptiveGrid.hpp"
00009 #include "AdaptiveData.hpp"
00010 #include "UniformData.hpp"
00011 #include "Function.hpp"
00012 
00013 template<int DIM>
00014 struct Navier {
00015  
00016        Navier() ;
00017       ~Navier() ;
00018 
00019   //
00020   // Parameters
00021   char ID[200]     ; // Name of problem required for directory data to be stored in
00022   int  prstep      ; // output velocity components of timestep % prstep == 0
00023   int  maxiter     ; // max number of iterations for solver 
00024   double maxres    ; // max residual ;
00025   int  J[DIM]      ; // level of refinement for full grid data, i.e. output/input of velocity fields
00026   
00027   double dt,T      ; // simulate t\in [0,T] with stepsize dt
00028   double nu        ; // viscosity
00029   double gamma     ; // additional parameter
00030 
00031   double umax      ; // max velocity, e.g. timestep size control
00032 
00033   int  BC[DIM][DIM][2] ; // Boundary Conditions for Velocity components u[i]: BC[i][][]
00034 
00035   double XL[DIM] ;
00036   double OutTimes[1000]   ;
00037   int         MovieStep   ; // Output of ... each MovieStep-th time step
00038   int         MovieJ[DIM] ; // Levels for Size of output
00039   UniformData<DIM> MovieTmp    ; // aux. matrix for output.WriteMatLab(...)
00040 
00041   Function *SetF[DIM],*SetUD[DIM] ;
00042   
00043   //
00044   // always required temp. variables
00045   int ts,a[DIM],e[DIM],op[DIM],res[DIM],Level0[DIM] ;
00046   int BG[DIM][2] ;  // 'general' boundary conditions
00047   double t       ;
00048   char st[200]   ;
00049 
00050   UniformData<DIM> U0[DIM],P0 ; // for IO
00051 
00052   void WriteParameters() ;
00053   void ReadParameters (char *NID) ;
00054 
00055   void ReadInitialValues(char *value , char *AddNameExtension , AdaptiveData<DIM> *U) ;
00056 
00057   void SetProblem1() ;
00058   void SetProblem2() ;
00059   void SetProblem3() ;
00060   void SetProblem4() ;
00061   void SetProblem5() ;
00062   void SetProblem6() ;
00063   void SetProblem7() ;
00064   void SetProblem8() ;
00065   void SetProblemStokes() ;
00066   void SetProblemStokes2() ;
00067   void SetProblemStokes3() ;
00068 
00069   void SetBG() ;
00070 
00071   void Print() ;
00072 
00073   Wavelets WC ;
00074   void     ReadWavelets() ;
00075   
00076 } ;
00077 
00078 //
00079 // Implementations
00080 //
00081 template<int DIM>
00082 Navier<DIM>::Navier()  { 
00083  for (int i=0; i<DIM; i++) { 
00084    XL[i]  =1.0 ;
00085    SetF[i]=SetUD[i]=NULL ;
00086    J[i]=0      ;
00087    MovieJ[i]=0 ;
00088   }
00089  MovieStep  =MAXINT ;
00090  prstep     =MAXINT ;
00091  OutTimes[0]=1e+100 ;
00092  T=dt=nu=0.0 ; 
00093 }
00094 
00095 template<int DIM>
00096 Navier<DIM>::~Navier() { 
00097   for (int i=0; i<DIM; i++) { 
00098     delete SetF[i]; 
00099     delete SetUD[i] ; 
00100    }
00101 }
00102 
00103 template<int DIM>
00104 void Navier<DIM>::WriteParameters() {
00105   int i,j ;
00106   FILE *file ;
00107   char name[300] ;
00108 
00109   sprintf(name,"%s/Data/%s/parameter.dat",_WAVELET_ROOT_,ID) ;
00110   if ((file=fopen(name,"w"))==NULL) {
00111     printf("Could not open file for write: %s\n",name) ; 
00112     exit(-1) ;
00113   }
00114 
00115   fprintf(file,"%s\n",ID) ;
00116   fprintf(file,"%d    /prstep\n",prstep) ;
00117   fprintf(file,"%d    /maxiter\n",maxiter) ;
00118   fprintf(file,"%e    /maxres\n",maxres) ;
00119   for (i=0; i<DIM; i++) 
00120      fprintf(file,"%d  ",J[i]) ; 
00121   fprintf(file,"/J[]\n") ;
00122 
00123   fprintf(file,"%e %e  /dt,T\n",dt,T) ;
00124   fprintf(file,"%e /nu\n",nu) ;
00125   
00126   for (i=0;i<DIM;i++) {
00127     for (j=0; j<DIM; j++) fprintf(file,"%d %d    ",BC[i][j][0],BC[i][j][1]) ; 
00128     fprintf(file,"\n") ;
00129   } 
00130   fclose(file) ;
00131 }
00132 
00133 template<int DIM>
00134 void Navier<DIM>::ReadParameters(char *NID) {
00135   int i,j ;
00136   FILE *file ;
00137   char name[300] ;
00138 
00139   sprintf(name,"%s/Data/%s/parameter.dat",_WAVELET_ROOT_,NID) ;
00140   if ((file=fopen(name,"w"))==NULL) {
00141     printf("Could not open file for read: %s\n",name) ; 
00142     exit(-1) ;
00143   }
00144 
00145   fscanf(file,"%s\n",ID) ;
00146   fscanf(file,"%d\n",&prstep) ;
00147   fscanf(file,"%d\n",&maxiter) ;
00148   fscanf(file,"%le\n",&maxres) ;
00149 
00150   for (i=0; i<DIM; i++) 
00151      fscanf(file,"%d",&J[i]) ; 
00152   fscanf(file,"%s\n",name) ;
00153 
00154   fscanf(file,"%le %le\n",&dt,&T) ;
00155   fscanf(file,"%le\n",&nu) ;
00156   
00157   for (i=0;i<DIM;i++) {
00158     for (j=0; j<DIM; j++) fscanf(file,"%d %d    ",&BC[i][j][0],&BC[i][j][1]) ; 
00159     fscanf(file,"%s\n",name) ;
00160   } 
00161   fclose(file) ;
00162 
00163 //
00164 // Init. of some temp. Variables
00165 //
00166   for (i=0;i<DIM;i++) {
00167     a[i]=0 ;
00168     e[i]=(1<<J[i]) ;
00169    }
00170 
00171   for (i=0; i<DIM; i++) U0[i].Init(a,e,&WC) ;
00172   
00173   for (i=0;i<DIM;i++) {
00174     sprintf(name,"%s/Data/%s/%s",_WAVELET_ROOT_,ID,(i==0) ? "U" : "V") ;
00175     U0[i].ba->ReadMatLab(name) ;
00176   }
00177 
00178 printf("%d %d %e\n",prstep,maxiter,maxres) ;
00179 for (i=0;i<DIM;i++) printf("J[%d]=%d\n",i,J[i]) ;
00180 
00181 printf("%e %e %e\n",dt,T,nu) ;
00182 for (i=0;i<DIM;i++) {
00183    for (j=0; j<DIM; j++) printf("%d %d    ",BC[i][j][0],BC[i][j][1]) ; 
00184    printf("\n") ;
00185  }
00186 
00187 }
00188 
00189 //
00190 // Output
00191 template<int DIM>
00192 void Navier<DIM>::Print() {
00193  int i,j ;
00194  printf("Problem: %s in D=%d\n",ID,DIM) ;
00195  printf("nu= %e\n",nu) ;
00196  printf("dt= %e\n",dt) ;
00197  printf("T = %e\n",T ) ;
00198  printf("gamma  = %e\n",gamma ) ;
00199  printf("maxres = %e\n",maxres) ;
00200 
00201  printf ("BC:\n") ;
00202  for (i=0; i<DIM; i++) {
00203    for (j=0; j<DIM; j++) printf("[%d,%d] ",BC[i][j][0] , BC[i][j][1]) ;
00204    printf ("\n") ;
00205  }
00206 }
00207 
00208 //
00209 // Wavelets holen
00210 template<int DIM>
00211 void Navier<DIM>::ReadWavelets() {
00212   WC.GetCoefficients("Interpolet","left" ,6) ;
00213   WC.GetCoefficients("Interpolet","right",6) ;
00214   for (int i=0; i<DIM; i++) Level0[i]=WC.Level0 ;
00215   WC.LiftingFlag=false ;
00216 }
00217 
00218 
00219 //
00220 // Set 'general' boundary conditions
00221 template<int DIM>
00222 void Navier<DIM>::SetBG() {
00223   int i,j ;
00224   for (j=0; j<DIM; j++) {
00225 
00226     BG[j][0]=BG[j][1] = -1 ;
00227 
00228     if (BC[0][j][1]==WAVEPERIODICBC) {
00229       BG[j][1]=WAVEPERIODICBC ;
00230 
00231       assert(BC[0][j][0]==-1) ;
00232       for (i=1; i<DIM; i++) assert((BC[i][j][0]==-1) && (BC[i][j][1]==WAVEPERIODICBC)) ;
00233     }
00234   }
00235 }
00236 
00237 
00238 // Lesen von Anfangswerten + interpolieren auf aktuelles Gitter
00239 template<int DIM>
00240 void Navier<DIM>::ReadInitialValues(char *value , char *ext , AdaptiveData<DIM> *U) {
00241   Matrix<double,DIM> M ;
00242   char name[300] ;
00243   int MJ[DIM],i,a[DIM],e[DIM],ee[DIM] ;
00244   
00245   if (ext) sprintf(name,"../TestDat/%s/%s%s",ID,value,ext) ;
00246      else  sprintf(name,"../TestDat/%s/%s",ID,value) ;
00247 
00248   M.ReadMatLab(name) ;
00249 
00250   M.CalcLevel(MJ) ;
00251   
00252   for (i=0;i<DIM;i++) { 
00253     op[i]=MJ[i]-Level0[i] ;
00254     printf("ReadInitialValues: %d %d\n",MJ[i] , Level0[i]) ;
00255     a[i]=0 ;
00256     e[i]=1<<J[i] ;
00257     ee[i]=1<<min(J[i],MJ[i]) ;
00258    }
00259   
00260   Matrix<double,DIM> K(a,e) ;
00261   K.Set(0.0) ;
00262   M.TensorMatrixOperation(BG , &M , BG , &WC , bwt , op , res) ;
00263 
00264   // copy to right sized matrix
00265   Matrix<double,DIM>::iterator it(a,ee) ;
00266   for (it.Set(a); it<=ee; ++it) K[it.i]=M[it.i] ;
00267 
00268   U->FromFull(&K,J) ;
00269 }
00270 
00271   
00272 //
00273 // Some predefined Test-Problems
00274 //
00275 // einfaches Poblem aus Howell/Bell
00276 //
00277 template<int DIM>
00278 void Navier<DIM>::SetProblem1() {
00279  int i,j ;
00280  this->ReadWavelets() ;
00281 
00282  // Parameters
00283  strcpy(ID,"Vortex") ;
00284  nu=1/15000. ;
00285  dt=1e-4 ;
00286  T =1.0  ;
00287  maxres =1e-5 ;
00288  maxiter=1000 ;
00289 
00290  prstep=10 ;
00291 
00292  // Boundary Conditions
00293  for (i=0;i<DIM;i++) {
00294    J[i]=6 ;
00295    for (j=0;j<DIM;j++) BC[i][j][0]=BC[i][j][1]=0 ;
00296    a[i]=0 ;
00297    e[i]=(1<<J[i]) ;
00298   }
00299 
00300  this->SetBG() ;
00301 
00302  for (i=0; i<DIM; i++) U0[i].Init(a,e,&WC) ;
00303 
00304  // Berechne 1D Geschwingkeitsprofil u(r) aus gegebener Rotationsverteilung um Ursprung
00305 
00306  double si=0.04 ;
00307 
00308  Matrix<double,DIM>::iterator it(U0[0].ba) ;
00309  umax=0.0 ;
00310  for (it=(*U0[0].ba).begin(); it<=(*U0[0].ba).end(); ++it) {
00311 
00312    double x[DIM] , ra ,ur;
00313    for (i=0; i<DIM; i++) x[i]=((double)it.i[i])/e[i] ;
00314 
00315    ra=sqrt((x[0]-0.4)*(x[0]-0.4) + (x[1]-0.5)*(x[1]-0.5)) ;
00316 
00317    ur=(1-exp(-(ra*ra)/(2*si*si)))/ra ;
00318 
00319    U0[0][it]= -ur*(x[1]-0.5)/ra ;
00320    U0[1][it]=  ur*(x[0]-0.4)/ra ;
00321   
00322    if ((it.i[0]==0)||(it.i[1]==0)||(it.i[0]==e[0])||(it.i[1]==e[1])) U0[0][it]=U0[1][it]=0.0 ;
00323 
00324    umax = (umax < fabs(ur)) ? fabs(ur) : umax ; 
00325  }
00326  
00327  U0[0].SetBoundaryConditions(BC[0]) ;
00328  U0[1].SetBoundaryConditions(BC[1]) ;
00329 
00330  for (i=0; i<2; i++)
00331    for (j=0; j<2; j++) U0[i].ApplyOp(BC[i][j], &U0[i], j, TRANSFORM) ;
00332 
00333  double w=0.0 ;
00334  for (i=0; i<DIM; i++) {
00335    U0   [i].SetBoundaryConditions(BG) ;
00336    SetUD[i]=new ConstFunction() ; SetUD[i]->SetParameters(&w) ;
00337    SetF [i]=new ConstFunction() ; SetF [i]->SetParameters(&w) ;
00338   }
00339  
00340  P0.Init(a,e,&WC) ;
00341  P0.SetBoundaryConditions(BG) ;
00342  P0.Set(0.0) ;
00343 
00344 }
00345 
00346 
00347 //
00348 // Channel-flow zwischen zwei Platten
00349 //
00350 template<int DIM>
00351 void Navier<DIM>::SetProblem2() {
00352  int i ;
00353  this->ReadWavelets() ;
00354 
00355  // Parameters
00356  strcpy(ID,"Channel") ;
00357  nu=1/100. ;
00358  dt=1.0e-2 ;
00359  T =100.0  ; 
00360  maxres =1e-5 ;
00361  maxiter=1000 ;
00362 
00363  prstep=10 ;
00364 
00365  // Boundary Conditions
00366  for (i=0;i<DIM;i++) {
00367    J[i]=6 ;
00368    BC[i][0][0]=-1 ;
00369    BC[i][0][1]=WAVEPERIODICBC ;
00370 
00371    BC[i][1][0]=0 ;
00372    BC[i][1][1]=0 ;
00373 
00374    a[i]=0 ;
00375    e[i]=(1<<J[i]) ;
00376   }
00377 
00378  for (i=0; i<DIM; i++) U0[i].Init(a,e,&WC) ;
00379 
00380  Matrix<double,DIM>::iterator it(U0[0].ba) ;
00381  umax=0.0 ;
00382  for (it=(*U0[0].ba).begin(); it<=(*U0[0].ba).end(); ++it) {
00383 
00384    (*U0[0].ba)[it]= 2./3 ;
00385    (*U0[1].ba)[it]= 0.0 ;
00386   
00387    if ((it.i[1]==0)||(it.i[1]==e[1])) U0[0][it]=U0[1][it]=0.0 ;
00388 
00389    umax = 1.0 ;
00390  }
00391 
00392  double w=0.0 ;
00393  SetUD[0]=new ConstFunction() ;SetUD[0]->SetParameters(&w) ;
00394  SetUD[1]=new ConstFunction() ;SetF [1]->SetParameters(&w) ;
00395  
00396  SetF [1]=new ConstFunction() ;SetF [1]->SetParameters(&w) ;
00397  w=8*nu ;
00398  SetF [0]=new ConstFunction() ;SetF [0]->SetParameters(&w) ;
00399 
00400  this->SetBG() ;
00401 }
00402 
00403 
00404 
00405 //
00406 // TestProblem aus A. Prohl
00407 //
00408 template<int DIM>
00409 void Navier<DIM>::SetProblem3() {
00410  int i ;
00411  this->ReadWavelets() ;
00412 
00413  // Parameters
00414  strcpy(ID,"Prohl") ;
00415  nu   =1/10.  ;
00416  dt   =1.0e-3 ;
00417  T    =1.0    ;
00418  gamma=1.0    ;
00419 
00420  maxres =1e-5 ;
00421  maxiter=1000 ;
00422 
00423  prstep=10 ;
00424 
00425  // Boundary Conditions
00426  for (i=0;i<DIM;i++) {
00427    J[i]=7 ;
00428    BC[i][0][0]=0 ;
00429    BC[i][0][1]=0 ;
00430 
00431    BC[i][1][0]=0 ;
00432    BC[i][1][1]=0 ;
00433 
00434    a[i]=0 ;
00435    e[i]=(1<<J[i]) ;
00436   }
00437 
00438  for (i=0; i<DIM; i++) U0[i].Init(a,e,&WC) ;
00439 
00440  Matrix<double,DIM>::iterator it(U0[0].ba) ;
00441  umax=0.0 ;
00442  for (it=(*U0[0].ba).begin(); it<=(*U0[0].ba).end(); ++it) {
00443 
00444    (*U0[0].ba)[it]= 0.0 ;
00445    (*U0[1].ba)[it]= 0.0 ;
00446   
00447    if ((it.i[1]==0)||(it.i[1]==e[1])) U0[0][it]=U0[1][it]=0.0 ;
00448 
00449    umax = 1.0 ;
00450  }
00451 
00452  double w=0.0 ;
00453  SetUD[0]=new ConstFunction() ;SetUD[0]->SetParameters(&w) ;
00454  SetUD[1]=new ConstFunction() ;SetUD[1]->SetParameters(&w) ;
00455  
00456  SetF [0]=new ProhlFunctionF1() ;
00457  SetF [1]=new ProhlFunctionF2() ;
00458   
00459  SetBG() ;
00460 }
00461 
00462 
00463 //
00464 // Driven Cavity flow
00465 //
00466 template<int DIM>
00467 void Navier<DIM>::SetProblem4() {
00468  int i,j ;
00469  ReadWavelets() ;
00470 
00471  // Parameters
00472  strcpy(ID,"DrivC") ;
00473  nu   =1./1000. ;
00474  dt   =0.25e-3  ;
00475  T    =1000.0   ;
00476 
00477  gamma=1e+100 ;
00478 
00479  maxres =1e-5 ;
00480  maxiter=1000 ;
00481 
00482  // Boundary Conditions
00483  for (i=0;i<DIM;i++) {
00484    J[i]=5 ;
00485    for (j=0; j<DIM; j++) BC[i][j][0]=BC[i][j][1]=0 ;
00486 
00487    a[i]=0 ;
00488    e[i]=(1<<J[i]) ;
00489   }
00490  SetBG() ;
00491 
00492  // Domain
00493  XL[0]=1.0  ;
00494  XL[1]=XL[0]  ;
00495  nu *=XL[0]*XL[0] ;
00496 
00497  // OutTimes
00498  for (i=0; i<=20 ;i++) OutTimes[i]=2*i ;
00499  OutTimes[i]=1e+100 ;
00500  prstep=20 ;
00501 
00502  // Movie
00503  MovieStep=MAXINT ;
00504  for (i=0; i<DIM; i++) {
00505    MovieJ[i]=8 ;
00506    a[i]=0 ;
00507    e[i]=(1<<MovieJ[i]) ;
00508   }
00509  MovieTmp.Init(a,e,&WC) ;
00510 
00511  // Initial Conditions.
00512 
00513  for (i=0; i<DIM; i++) U0[i].Init(a,e,&WC) ;
00514  P0.Init(a,e,&WC) ;
00515 
00516  for (j=0; j<DIM; j++) { 
00517    U0[j].Set(0.0) ; 
00518    U0[j].SetBoundaryConditions(BC[i]) ;
00519  }
00520 
00521  P0.Set(0.0) ;
00522  P0.SetBoundaryConditions(BG) ;
00523 
00524  // Values for Dirichlet-Boundary Conditions
00525  double w=0.0 ;
00526  SetUD[0]=new DrivCFunctionUD1() ;
00527  for (i=1; i<DIM; i++) { 
00528    SetUD[i]=new ConstFunction() ;
00529    SetUD[i]->SetParameters(&w)  ;
00530  }
00531  
00532  for (i=0; i<DIM; i++) { 
00533    SetF[i]=new ConstFunction() ;
00534    SetF[i]->SetParameters(&w) ;
00535  }
00536  
00537 }
00538 
00539 
00540 
00541 //
00542 // Modons
00543 //
00544 template<int DIM>
00545 void Navier<DIM>::SetProblem5() {
00546  int i,j,a[DIM],e[DIM] ;
00547 
00548  int    NV  =3 ;
00549  double px[]={3./8 , 5./8 , 5./8} ;
00550  double py[]={1./2 , 1./2 , (1+1/(2*sqrt(2.0)))/2 } ;
00551  //double am[]={-1*PI   , 2*PI   ,-1*PI} ;
00552  double am[]={PI   ,  PI   ,-0.5*PI} ;
00553  double si[]={1/(2*PI*PI) , 1/(2*PI*PI) ,1/(2*PI*PI)} ;
00554  double ommean ;
00555 
00556  // Parameters
00557  strcpy(ID,"Modons")  ;
00558  nu   =5e-5/(4*PI*PI) ;
00559  dt   =5.0e-3 ;
00560  T    =40.1   ;
00561 
00562  gamma=1e+100 ;
00563 
00564  maxres =1e-5 ;
00565  maxiter=100 ;
00566 
00567  // OutTimes
00568  for (i=0; i<=20 ;i++) OutTimes[i]=2*i ;
00569  OutTimes[i]=1e+100 ;
00570 
00571  prstep=100 ;
00572 
00573  // Movie
00574  MovieStep=40 ;
00575  for (i=0; i<DIM; i++) {
00576    MovieJ[i]=8 ;
00577    a[i]=0 ;
00578    e[i]=(1<<MovieJ[i]) ;
00579   }
00580  MovieTmp.Init(a,e,&WC) ;
00581 
00582  // Domain
00583  XL[0]=1.0  ;
00584  XL[1]=XL[0]  ;
00585  for (i=0; i<NV; i++) {
00586    px[i] *=XL[0] ;
00587    py[i] *=XL[1] ;
00588    si[i] *=XL[0] ;
00589  }
00590  nu *=XL[0]*XL[0] ;
00591 
00592  // Boundary Conditions
00593  for (i=0;i<DIM;i++) {
00594    J[i]=8 ;
00595    for (j=0; j<DIM; j++) BC[i][j][0]=-1 , BC[i][j][1]=WAVEPERIODICBC ;
00596 
00597    a[i]=0 ;
00598    e[i]=(1<<J[i]) ;
00599   }
00600  
00601  this->ReadWavelets() ;
00602  this->SetBG() ;
00603  this->Print() ;
00604 
00605  // Initial Conditions.
00606  for (i=0; i<DIM; i++) U0[i].Init(a,e,&WC) ;
00607 
00608  //printf("Allocated\n") ; fflush(stdout) ;
00609 
00610  P0.Init(a,e,&WC) ;
00611  P0.SetBoundaryConditions(BG) ;
00612  P0.Set(0.0) ;
00613 
00614  Matrix<double,DIM>::iterator it(U0[0].ba) ;
00615 
00616  UniformData<DIM> Omega(a,e,&WC) , TMP[Solver<UniformData<DIM>,DIM>::NUMTMP_BICGSTAB2+2] , Psi(a,e,&WC) ;
00617 
00618  for (i=0;i<Solver<UniformData<DIM>,DIM>::NUMTMP_BICGSTAB2+2;i++) TMP[i].Init(a,e,&WC) ;
00619 
00620  ommean=0 ;
00621  for (it.Set(a); it<=e; ++it) {
00622    double x[DIM],r2,s2,dx,dy,om=0.0 ;
00623    for (i=0; i<DIM; i++) x[i]=(it.i[i]*XL[i])/e[i] ;
00624         
00625    for (i=0; i<NV; i++) {
00626      dx =x[0]-px[i] ;
00627      dy =x[1]-py[i] ;
00628 
00629      r2 =dx*dx + dy*dy ;
00630      s2 =si[i]*si[i];
00631      om+=am[i]*exp(-r2/s2) ;
00632    }
00633 
00634    for (i=0; i<DIM; i++) if (it.i[i]==e[i]) om=0 ;
00635    
00636    Omega[it]=om ;
00637    ommean  +=om ;
00638  }
00639  for (j=0; j<DIM; j++) Omega.ismultiscale[j]=false ;
00640  
00641  ommean /=(double)(1<<(2*J[0])) ;
00642  //printf("OmegaMean: %e\n",ommean) ;
00643 
00644  for (it.Set(a); it<=e; ++it) {
00645    bool f=true ;
00646    for (i=0; i<DIM; i++) if (it.i[i]==e[i]) f=false ;
00647    if (f) Omega[it] -=ommean ;
00648  }
00649 
00650  //ommean=0 ;
00651  //for (it.Set(a); it<=e; ++it) ommean +=Omega[it] ;
00652  //printf("Omega: %e\n",ommean) ;
00653 
00654  U0[0].SetBoundaryConditions(BG) ;
00655  U0[1].SetBoundaryConditions(BG) ;
00656  Omega.SetBoundaryConditions(BG) ;
00657    Psi.SetBoundaryConditions(BG) ;
00658 
00659  double f=0.0 ;
00660  for (i=0; i<DIM; i++) { 
00661    SetF [i]=new ConstFunction() ;
00662    SetUD[i]=new ConstFunction() ;
00663    SetF [i]->SetParameters(&f) ;
00664    SetUD[i]->SetParameters(&f) ;
00665  }
00666    
00667  // Berechnung von U,V uber Laplace Problem
00668  // Operatoren ...
00669  HelmholtzOperator< UniformData<DIM> , DIM> MO ;
00670  MO.par[0]=0.0 ;
00671  MO.Tmp =&TMP[Solver<UniformData<DIM>,DIM>::NUMTMP_BICGSTAB2] ;
00672  MO.Tmp2=&TMP[Solver<UniformData<DIM>,DIM>::NUMTMP_BICGSTAB2+1] ;
00673  
00674 
00675  for (i=0; i<DIM; i++) MO.par[i+1]=1/(XL[i]*XL[i]) ;
00676 
00677  Solver<UniformData<DIM>,DIM> MS ;
00678  MS.eps          =1e-10 ;
00679  MS.maxiter      =150 ;
00680  MS.Op           =&MO ;
00681  MS.StopCriterion=StoppingCriterionAbsoluteResidual ;
00682  MS.print        ="MatBiCG:" ;
00683  MS.prstep       =1 ;
00684 
00685  for (i=0; i<Solver<UniformData<DIM>,DIM>::NUMTMP_BICGSTAB2; i++) MS.Tmp[i]=&TMP[i] ;
00686 
00687  // Lap(Psi)=-omega ;
00688  for (j=0; j<DIM; j++) Omega.ApplyOp(BG[j] , &Omega , j , TRANSFORM) ;
00689  Omega.Mul(-1) ;
00690 
00691  MS.BiCGSTAB2(&Psi,&Omega) ;
00692  MS.BiCGSTAB2(&Psi,&Omega) ;
00693 
00694  //for (j=0; j<DIM; j++) Psi.ApplyOp(BG[j] , &Psi , j , INVERSETRANSFORM) ;
00695  Psi.ba->WriteMatLab("PSI") ;
00696 
00697  for (i=0; i<2; i++) {
00698    j= (i==0) ? 1 : 0 ;
00699    U0[i].ApplyOp(BG[j] , &Psi , j , FIRSTDERIVATIVE) ;
00700 
00701    if (i==0) U0[i].Mul( 1/XL[1]) ;
00702    if (i==1) U0[i].Mul(-1/XL[0]) ;
00703    for (j=0; j<DIM; j++) TMP[0].ApplyOp(BG[j] , (j==0) ? &U0[i] : &TMP[0] , j , INVERSETRANSFORM) ;
00704    printf("Umax: %e\n",TMP[0].MaxAbs()) ;
00705 
00706    if (i==0) TMP[0].ba->WriteMatLab("U0") ;
00707    if (i==1) TMP[0].ba->WriteMatLab("U1") ;
00708 
00709  }
00710  //exit(-1) ;
00711 }
00712 
00713 
00714 
00715 //
00716 // mixing layer
00717 //
00718 template<int DIM>
00719 void Navier<DIM>::SetProblem6() {
00720  int i,j,a[DIM],e[DIM] ;
00721  
00722  // Parameters
00723  strcpy(ID,"Mixing")  ;
00724  nu   =5e-5/(4*PI*PI) ;
00725  // dt   =2.5e-3 ;
00726  dt   =3*2.5e-3 ;
00727  T    =80.0   ;
00728 
00729  gamma=1e+100 ;
00730 
00731  maxres =1e-5 ;
00732  maxiter=100  ;
00733 
00734  // IO
00735  prstep=100 ;
00736 
00737  for (i=0; i<=(int)(T/4+1e-10); i++) OutTimes[i]=4*i ;
00738  OutTimes[i++]=12.5   ;
00739  OutTimes[i++]=25     ;
00740  OutTimes[i++]=37.5   ;
00741  OutTimes[i  ]=1e+100 ;
00742  qsort(OutTimes , i , sizeof(double) , doublecmp) ;
00743 
00744  printf("OutTimes\n") ;
00745  for (j=0; j<=i ;j++) printf("%d %e\n",j,OutTimes[j]) ;
00746 
00747  // Movie
00748  MovieStep=50 ;
00749  MovieJ[0]=8 ;
00750  MovieJ[1]=9 ;
00751  for (i=0; i<DIM; i++) {
00752    a[i]=0 ;
00753    e[i]=(1<<MovieJ[i]) ;
00754   }
00755  MovieTmp.Init(a,e,&WC) ;
00756 
00757  // Domain
00758  XL[0]=1.0     ;
00759  XL[1]=2*XL[0] ;
00760 
00761  nu *=XL[0]*XL[0] ;
00762 
00763  // Boundary Conditions
00764  for (i=0;i<DIM;i++) {
00765    if (i==0) J[i]=8 ;
00766       else   J[i]=J[0]+1 ;
00767 
00768    for (j=0; j<DIM; j++) BC[i][j][0]=-1 , BC[i][j][1]=WAVEPERIODICBC ;
00769    a[i]=0 ;
00770    e[i]=(1<<J[i]) ;
00771   }
00772  
00773 
00774  this->ReadWavelets() ;
00775  this->SetBG() ;
00776  this->Print() ;
00777 
00778  // Initial Conditions.
00779  for (i=0; i<DIM; i++) U0[i].Init(a,e,&WC) ;
00780 
00781  P0.Init(a,e,&WC) ;
00782  P0.SetBoundaryConditions(BG) ;
00783  P0.Set(0.0) ;
00784 
00785  Matrix<double,DIM>::iterator it(U0[0].ba) ;
00786 
00787  UniformData<DIM> Omega(a,e,&WC) , TMP[Solver<UniformData<DIM>,DIM>::NUMTMP_BICGSTAB2+2] , Psi(a,e,&WC) ,
00788            *TMP1=&TMP[Solver<UniformData<DIM>,DIM>::NUMTMP_BICGSTAB2+1] ;
00789 
00790  for (i=0; i<Solver<UniformData<DIM>,DIM>::NUMTMP_BICGSTAB2+2; i++) TMP[i].Init(a,e,&WC) ;  
00791  
00792  char name[1000] ;
00793  sprintf(name,"%s/../../tex/Berlin99/ICshear.256",_WAVELET_ROOT_) ;
00794  FILE *fid=fopen(name,"r") ;
00795  if (fid==NULL) {
00796    printf("Could not open: %s\n",name) ;
00797    exit(-1) ;
00798   }
00799  
00800  Omega.Set(0.0) ;
00801  double om ;
00802  for (it.Set(a); it<=e; ++it) {
00803    if ((it.i[0]<e[0])&&(it.i[1]<e[1]))
00804      if (it.i[1]<256) {
00805        int in[2]={it.i[1] , it.i[0] } ;
00806        fscanf(fid,"%le",&om) ;
00807        Omega[in]=om ;
00808      } else {
00809        int in[2]={it.i[0] , 511-it.i[1]} ;
00810        Omega[it]=-Omega[in] ;
00811      }
00812  }
00813  fclose(fid) ; 
00814 
00815  om=0 ;
00816  for (it.Set(a); it<=e; ++it) om +=Omega[it] ;
00817  printf("Omega: %e\n",om) ;
00818  double XA[2]={0},XE[2]={1,2} ;
00819  Omega.ba->WriteUDF("Omega",XA,XE,"omega",NULL,1,false,false) ;
00820  //exit(-1) ;
00821 
00822  U0[0].SetBoundaryConditions(BG) ;
00823  U0[1].SetBoundaryConditions(BG) ;
00824  Omega.SetBoundaryConditions(BG) ;
00825    Psi.SetBoundaryConditions(BG) ;
00826 
00827  double f=0.0 ;
00828  for (i=0; i<DIM; i++) { 
00829    SetF [i]=new ConstFunction() ;
00830    SetUD[i]=new ConstFunction() ;
00831    SetF [i]->SetParameters(&f) ;
00832    SetUD[i]->SetParameters(&f) ;
00833  }
00834    
00835  // Berechnung von U,V uber Laplace Problem
00836  // Operatoren ...
00837  HelmholtzOperator<UniformData<DIM>,DIM> MO ;
00838  MO.par[0]=0.0 ;
00839  MO.Tmp=&TMP[Solver<UniformData<DIM>,DIM>::NUMTMP_BICGSTAB2] ;
00840 
00841  MO.par[1]=1/(XL[0]*XL[0]) ;
00842  MO.par[2]=1/(XL[1]*XL[1]) ;
00843 
00844  Solver<UniformData<DIM>,DIM> MS ;
00845  MS.eps          =1e-20 ;
00846  MS.maxiter      =150 ;
00847  MS.Op           =&MO ;
00848  MS.StopCriterion=StoppingCriterionAbsoluteResidual ;
00849  MS.print        ="MatBiCG:" ;
00850  MS.prstep       =1 ;
00851 
00852  for (i=0; i<Solver<UniformData<DIM>,DIM>::NUMTMP_BICGSTAB2; i++) MS.Tmp[i]=&TMP[i] ;
00853 
00854  // Lap(Psi)=-omega ;
00855  for (j=0; j<DIM; j++) TMP1->ApplyOp(BG[j] , (j==0) ? &Omega : TMP1 , j , TRANSFORM) ;
00856  TMP1->PPlus(-2.0 , TMP1)  ;
00857 
00858  MS.BiCGSTAB2(&Psi,TMP1) ;
00859  MS.BiCGSTAB2(&Psi,TMP1) ;
00860 
00861  for (j=0; j<DIM; j++) Psi.ApplyOp(BG[j] , &Psi , j , INVERSETRANSFORM) ;
00862  Psi.ba->WriteUDF("Psi",XA,XE,"psi",NULL,1,false,false) ;
00863 
00864  for (i=0; i<2; i++) {
00865    j= (i==0) ? 1 : 0 ;
00866    U0[i].ApplyOp(BG[j] , &Psi , j , FIRSTDERIVATIVE) ;
00867 
00868    if (i==0) U0[i].Mul( 1/XL[1]) ;
00869    if (i==1) U0[i].Mul(-1/XL[0]) ;
00870    printf("Umax: %e\n",U0[i].MaxAbs()) ;
00871 
00872    sprintf(name,"%s/Data/%s/U%s",_WAVELET_ROOT_, ID , (i==0) ? "0" : "1" ) ;
00873    U0[i].ba->WriteMatLab(name) ;
00874    U0[i].ba->WriteUDF(name,XA,XE,"u",NULL,1,false,false) ;
00875  }
00876 
00877  // Test der Rotation:
00878  Omega.ApplyOp(BG[0] , &U0[1] , 0 , FIRSTDERIVATIVE) ;
00879  Psi  .ApplyOp(BG[1] , &U0[0] , 1 , FIRSTDERIVATIVE) ;
00880  Omega.Add(1/XL[0],&Omega , -1/XL[1],&Psi) ;
00881  printf("OmegaMax: %e\n",Omega.MaxAbs()) ;
00882  Omega.ba->WriteUDF("Omega.dat",XA,XE,"omega",NULL,1,false,false) ;
00883 }
00884 
00885 
00886 //
00887 // mixing layer mit Einlesen der Anfangsgeschwindigkeiten
00888 //
00889 template<int DIM>
00890 void Navier<DIM>::SetProblem7() {
00891  int i,j,a[DIM],e[DIM];
00892  double XA[2]={0,0}   ;
00893  
00894  // Parameters
00895  strcpy(ID,"Mixing")  ;
00896  nu   =5e-5/(4*PI*PI) ;
00897  // dt   =2.5e-3 ;
00898  dt   =4*2.5e-3 ;
00899  T    =80.0     ;
00900 
00901  gamma=1e+100 ;
00902 
00903  maxres =1e-5 ;
00904  maxiter=100  ;
00905 
00906  // IO
00907  prstep=100 ;
00908 
00909  for (i=0; i<=(int)(T/4+1e-10); i++) OutTimes[i]=40*i ;
00910  OutTimes[i++]=12.5   ;
00911  OutTimes[i++]=25     ;
00912  OutTimes[i++]=37.5   ;
00913  OutTimes[i  ]=1e+100 ;
00914  qsort(OutTimes , i , sizeof(double) , doublecmp) ;
00915 
00916  printf("OutTimes\n") ;
00917  for (j=0; j<=i ;j++) printf("%d %e\n",j,OutTimes[j]) ;
00918 
00919  // Movie
00920  MovieStep=200 ;
00921  MovieJ[0]=9   ;
00922  MovieJ[1]=10  ;
00923  for (i=0; i<DIM; i++) {
00924    a[i]=0 ;
00925    e[i]=(1<<MovieJ[i]) ;
00926   }
00927  MovieTmp.Init(a,e,&WC) ;
00928 
00929  // Domain
00930  XL[0]=1.0     ;
00931  XL[1]=2*XL[0] ;
00932 
00933  nu *=XL[0]*XL[0] ;
00934 
00935  // Boundary Conditions
00936  J[0]=9 ;
00937  J[1]=10 ;
00938  for (i=0;i<DIM;i++) {
00939    for (j=0; j<DIM; j++) BC[i][j][0]=-1 , BC[i][j][1]=WAVEPERIODICBC ;
00940    a[i]=0 ;
00941    e[i]=(1<<J[i]) ;
00942   }
00943  
00944  this->ReadWavelets() ;
00945  this->SetBG() ;
00946  this->Print() ;
00947 
00948  // Initial Conditions.
00949  for (i=0; i<DIM; i++) U0[i].Init(a,e,&WC) ;
00950 
00951  P0.Init(a,e,&WC) ;
00952  P0.SetBoundaryConditions(BG) ;
00953  P0.Set(0.0) ;
00954 
00955  double f=0.0 ;
00956  for (i=0; i<DIM; i++) { 
00957    SetF [i]=new ConstFunction() ;
00958    SetUD[i]=new ConstFunction() ;
00959    SetF [i]->SetParameters(&f) ;
00960    SetUD[i]->SetParameters(&f) ;
00961  }
00962 
00963  // aux. Matrix for Read
00964  int e1[2]={511 , 1023} ; 
00965  Matrix<double , DIM>         M(a,e1) ;
00966  Matrix<double,DIM>::iterator s(&M)   ;
00967 
00968  for (i=0; i<2; i++) {
00969    // Read Matrix
00970    char name[1000] ;
00971    //sprintf(name,"%s/../../C/Spectral/jobs/Mixing/U%s-1024",_WAVELET_ROOT_, (i==0) ? "1" : "0") ;
00972 sprintf(name,"../../Data/Mixing/U%s-1024", (i==0) ? "1" : "0") ;
00973    M.ReadMatLab(name) ;
00974    
00975    // copy into larger initial matrix
00976    U0[i].Set(0.0) ;
00977    U0[i].SetBoundaryConditions(BC[i]) ;
00978    for (j=0; j<DIM; j++) U0[i].Ext.ismultiscale[j]=false ;
00979 
00980    for (s=M.begin(); s<= M.end(); ++s) (*U0[i].ba)[s.i]=M[s] ;
00981  
00982    
00983    // periodize 
00984    int in[2] , im[2] ,j ;
00985    in[0]=0 ;
00986    im[0]=e[0] ;
00987    for (j=0; j<=e[1]; j++) {
00988      in[1]=im[1]=j ;
00989      (*U0[i].ba)[im]=(*U0[i].ba)[in] ;
00990     }
00991 
00992    in[1]=0 ;
00993    im[1]=e[1] ;
00994    for (j=0; j<=e[0]; j++) {
00995      in[0]=im[0]=j ;
00996      (*U0[i].ba)[im]=(*U0[i].ba)[in] ;
00997     }
00998 
00999    in[0]=in[1]=0 ;
01000    im[0]=e[0] , im[1]=e[1] ;
01001    (*U0[i].ba)[im]=(*U0[i].ba)[in] ; 
01002    
01003    // Test-ausgaben:
01004    printf("Umax: %e\n",U0[i].MaxAbs()) ;
01005 
01006    sprintf(name,"%s/Data/%s/U%s",_WAVELET_ROOT_, ID , (i==0) ? "0" : "1" ) ;
01007    U0[i].ba->WriteUDF(name,XA,XL,"u",NULL,1,false,false) ;
01008  }
01009 
01010  // Trafo der Anfangsbedingungen
01011  for (i=0; i<DIM; i++)
01012    for (j=0; j<DIM; j++) U0[i].ApplyOp(BC[i][j] , &U0[i] , j , TRANSFORM) ; 
01013 
01014  // Test der Rotation
01015   
01016  UniformData<DIM> Tmp1(a,e,&WC) , Tmp2(a,e,&WC) ;
01017  Tmp1.SetBoundaryConditions(BG) ;
01018  Tmp2.SetBoundaryConditions(BG) ;
01019 
01020  Tmp1.ApplyOp(BG[0] , &U0[1] , 0 , FIRSTDERIVATIVE) ;
01021  Tmp2.ApplyOp(BG[1] , &U0[0] , 1 , FIRSTDERIVATIVE) ;
01022  Tmp1.Sub(&Tmp1 , &Tmp2) ;
01023  for (j=0; j<DIM; j++) Tmp1.ApplyOp(BG[0] , &Tmp1 , j , INVERSETRANSFORM) ;
01024  
01025  printf("Omega: %e  %e\n",Tmp1.MaxAbs(),Tmp1.InnerProd(&Tmp1)/(e[0]*e[1])/2)   ;
01026  Tmp1.ba->WriteUDF("Omega.dat",XA,XL,"omega",NULL,1,false,false) ;
01027 
01028 }
01029 
01030 
01031 
01032 //
01033 // Merging Modons layer mit Einlesen der Anfangsgeschwindigkeiten
01034 //
01035 template<int DIM>
01036 void Navier<DIM>::SetProblem8() {
01037  int i,j,a[DIM],e[DIM] ;
01038  
01039  // Parameters
01040  strcpy(ID,"Merging")  ;
01041  nu   =5e-5/(4*PI*PI) ;
01042  // dt   =2.5e-3 ;
01043  dt   =1.25e-3/2 ;
01044  T    =40.1      ;
01045 
01046  gamma=1e+100 ;
01047 
01048  maxres =1e-5 ;
01049  maxiter=100  ;
01050 
01051  // IO
01052  prstep=1000 ;
01053 
01054  for (i=0; i<=(int)(T/5+1e-10); i++) OutTimes[i]=5*i ;
01055  OutTimes[i  ]=1e+100 ;
01056 
01057  printf("OutTimes\n") ;
01058  for (j=0; j<=i ;j++) printf("%d %e\n",j,OutTimes[j]) ;
01059 
01060  // Movie
01061  MovieStep=MAXINT ;
01062  MovieJ[0]=9     ;
01063  MovieJ[1]=10    ;
01064  for (i=0; i<DIM; i++) {
01065    a[i]=0 ;
01066    e[i]=(1<<MovieJ[i]) ;
01067   }
01068  MovieTmp.Init(a,e,&WC) ;
01069 
01070  // Domain
01071  XL[0]=1.0 ;
01072  XL[1]=1.0 ;
01073 
01074  nu *=XL[0]*XL[0] ;
01075 
01076  // Boundary Conditions
01077  J[0]=9 ;
01078  J[1]=9 ;
01079  for (i=0;i<DIM;i++) {
01080    for (j=0; j<DIM; j++) BC[i][j][0]=-1 , BC[i][j][1]=WAVEPERIODICBC ;
01081    a[i]=0 ;
01082    e[i]=(1<<J[i]) ;
01083   }
01084  
01085  this->ReadWavelets() ;
01086  this->SetBG() ;
01087  this->Print() ;
01088 
01089  // Initial Conditions.
01090  for (i=0; i<DIM; i++) U0[i].Init(a,e,&WC) ;
01091 
01092  P0.Init(a,e,&WC) ;
01093  P0.SetBoundaryConditions(BG) ;
01094  P0.Set(0.0) ;
01095 
01096  double f=0.0 ;
01097  for (i=0; i<DIM; i++) { 
01098    SetF [i]=new ConstFunction() ;
01099    SetUD[i]=new ConstFunction() ;
01100    SetF [i]->SetParameters(&f) ;
01101    SetUD[i]->SetParameters(&f) ;
01102  }
01103 
01104  // aux. Matrix for Read
01105  int px=2048 , rx=px/(1<<J[0]) ;
01106  int e1[2]={px-1 , px-1} ;
01107  Matrix<double , DIM>         M(a,e1) ;
01108  Matrix<double,DIM>::iterator s(&M)   ;
01109 
01110  for (i=0; i<2; i++) {
01111    // Read Matrix
01112    char name[1000] ;
01113    sprintf(name,"%s/../../C/Spectral/jobs/Merging/U%s-%d-Intel",_WAVELET_ROOT_, (i==0) ? "0" : "1",px) ;
01114    M.ReadMatLab(name) ;
01115    
01116    // copy into larger initial matrix
01117    U0[i].Set(0.0) ;
01118    U0[i].SetBoundaryConditions(BC[i]) ;
01119 
01120    for (s=M.begin(); s<= M.end(); ++s) {
01121      bool cp=true ;
01122      int is[DIM]  ;
01123      for (j=0;j<DIM; j++) {
01124        is[1-j]=s.i[j]/rx ;
01125        if ( (s.i[j]%rx)!=0 )  cp=false ;
01126       }
01127      if (cp) (*U0[i].ba)[is]=M[s] ;
01128    }
01129    
01130    // periodize 
01131    int in[2] , im[2] ,j ;
01132    in[0]=0 ;
01133    im[0]=e[0] ;
01134    for (j=0; j<=e[1]; j++) {
01135      in[1]=im[1]=j ;
01136      (*U0[i].ba)[im]=(*U0[i].ba)[in] ;
01137     }
01138 
01139    in[1]=0 ;
01140    im[1]=e[1] ;
01141    for (j=0; j<=e[0]; j++) {
01142      in[0]=im[0]=j ;
01143      (*U0[i].ba)[im]=(*U0[i].ba)[in] ;
01144     }
01145 
01146    in[0]=in[1]=0 ;
01147    im[0]=e[0] , im[1]=e[1] ;
01148    (*U0[i].ba)[im]=(*U0[i].ba)[in] ; 
01149    
01150    // Test-ausgaben:
01151    printf("Umax: %e\n",U0[i].MaxAbs()) ;
01152 
01153    sprintf(name,"%s/Data/%s/U%s",_WAVELET_ROOT_, ID , (i==0) ? "0" : "1" ) ;
01154    U0[i].ba->WriteMatLab(name) ;
01155  }
01156 
01157  // Test der Rotation
01158   
01159  UniformData<DIM> Tmp1(a,e,&WC) , Tmp2(a,e,&WC) ;
01160  Tmp1.SetBoundaryConditions(BG) ;
01161  Tmp2.SetBoundaryConditions(BG) ;
01162 
01163  Tmp1.ApplyOp(BG[0] , &U0[1] , 0 , FIRSTDERIVATIVE) ;
01164  Tmp2.ApplyOp(BG[1] , &U0[0] , 1 , FIRSTDERIVATIVE) ;
01165  Tmp1.Add(1/XL[0],&Tmp1 , -1/XL[1],&Tmp2) ;
01166  printf("Omega: %e  %e\n",Tmp1.MaxAbs(),Tmp1.InnerProd(&Tmp1)/(e[0]*e[1])/2)   ;
01167  Tmp1.ba->WriteMatLab("Omega.dat") ;
01168 
01169 }
01170 
01171 
01172 //
01173 // Stokes Test Problem
01174 //
01175 template<int DIM>
01176 void Navier<DIM>::SetProblemStokes() {
01177  int i,j,a[DIM],e[DIM] ;
01178 
01179  // Parameters
01180  strcpy(ID,"Stokes")  ;
01181  nu   =1e-1   ;
01182  dt   =1.0e-1 ;
01183  T    =400.1  ;
01184 
01185  gamma=1e+100 ;
01186 
01187  maxres =1e-5 ;
01188  maxiter=100  ;
01189 
01190  // Boundary Conditions
01191  for (i=0;i<DIM;i++) {
01192    J[i]=8 ;
01193    for (j=0; j<DIM; j++) BC[i][j][0]=BC[i][j][1]=0 ;
01194 
01195    a[i]=0 ;
01196    e[i]=(1<<J[i]) ;
01197   }
01198 
01199  // OutTimes
01200  for (i=0; i<=20 ;i++) OutTimes[i]=2*i ;
01201  OutTimes[i]=1e+100 ;
01202  prstep=20 ;
01203 
01204  // Movie
01205  MovieStep=MAXINT ;
01206  for (i=0; i<DIM; i++) {
01207    MovieJ[i]=8 ;
01208    a[i]=0 ;
01209    e[i]=(1<<MovieJ[i]) ;
01210   }
01211  MovieTmp.Init(a,e,&WC) ;
01212 
01213  // Domain
01214  XL[0]=1.0  ;
01215  XL[1]=XL[0]  ;
01216  nu *=XL[0]*XL[0] ;
01217  
01218  this->ReadWavelets() ;
01219  this->SetBG() ;
01220  this->Print() ;
01221 
01222  // Initial Conditions.
01223  for (i=0; i<DIM; i++) U0[i].Init(a,e,&WC) ;
01224 
01225  P0.Init(a,e,&WC) ;
01226  P0.SetBoundaryConditions(BG) ;
01227  P0.Set(0.0) ;
01228 
01229  SetF[0]=new StokesFunctionF1 ;
01230  SetF[1]=new StokesFunctionF2 ;
01231 
01232  double f=0.0 ;
01233  for (i=0; i<DIM; i++) { 
01234    SetUD[i]=new ConstFunction() ;
01235    SetUD[i]->SetParameters (&f) ;
01236  }
01237 
01238  for (i=0; i<DIM; i++) {
01239    SetF[i]->SetParameters(&nu)        ;
01240    U0[i].Set(0.0)                     ;
01241    U0[i].SetBoundaryConditions(BC[i]) ;
01242  }
01243 }
01244 
01245 
01246 
01247 
01248 template<int DIM>
01249 void Navier<DIM>::SetProblemStokes2() {
01250  int i,j,a[DIM],e[DIM] ;
01251 
01252  // Parameters
01253  strcpy(ID,"Stokes")  ;
01254  nu   =0.000100   ;
01255  dt   =1.0e-3 ;
01256  T    =1.0    ;
01257 
01258  gamma=1e+100 ;
01259 
01260  maxres =1e-5 ;
01261  maxiter=100  ;
01262 
01263  // Boundary Conditions
01264  for (i=0;i<DIM;i++) {
01265    J[i]=8 ;
01266    a[i]=0 ;
01267    e[i]=(1<<J[i]) ;
01268    BC[i][0][0]=-1 ;
01269    BC[i][0][1]=WAVEPERIODICBC ;
01270    BC[i][1][0]=-1 ;
01271    BC[i][1][1]=-1 ;
01272   }
01273  
01274 
01275 
01276  // OutTimes
01277  for (i=0; i<=20 ;i++) OutTimes[i]=2*i ;
01278  OutTimes[i]=1e+100 ;
01279  prstep=20 ;
01280 
01281  // Movie
01282  MovieStep=MAXINT ;
01283  for (i=0; i<DIM; i++) {
01284    MovieJ[i]=8 ;
01285    a[i]=0 ;
01286    e[i]=(1<<MovieJ[i]) ;
01287   }
01288  MovieTmp.Init(a,e,&WC) ;
01289 
01290  // Domain
01291  XL[0]=1.0  ;
01292  XL[1]=XL[0]  ;
01293  nu *=XL[0]*XL[0] ;
01294  
01295  this->ReadWavelets() ;
01296  this->SetBG() ;
01297  this->Print() ;
01298 
01299  // Initial Conditions.
01300  for (i=0; i<DIM; i++) U0[i].Init(a,e,&WC) ;
01301 
01302  P0.Init(a,e,&WC) ;
01303  P0.SetBoundaryConditions(BG) ;
01304  P0.Set(0.0) ;
01305 
01306  double pp[2]={nu,0.0} ;
01307  SetF[0]=new StokesFunction2F1 ;
01308  SetF[1]=new StokesFunction2F2 ;
01309  SetUD[0]=new StokesFunction2U1 ;
01310  SetUD[1]=new StokesFunction2U2 ;
01311 
01312  SetF [0]->SetParameters(pp) ;
01313  SetF [1]->SetParameters(pp) ;
01314  SetUD[0]->SetParameters(pp) ;
01315  SetUD[1]->SetParameters(pp) ;
01316 
01317  for (i=0; i<DIM; i++) {
01318    U0[i].SetFunction(SetUD[i]) ;
01319    U0[i].SetBoundaryConditions(BC[i]) ;
01320    for (j=0; j<DIM; j++) U0[i].ApplyOp(U0[i].BC[j], &U0[i], j, TRANSFORM) ;
01321  }
01322 }
01323 
01324 
01325 template<int DIM>
01326 void Navier<DIM>::SetProblemStokes3() {
01327  int i,j,a[DIM],e[DIM] ;
01328 
01329  // Parameters
01330  strcpy(ID,"Stokes")  ;
01331  nu   =1.0   ;
01332  dt   =1.0e-3 ;
01333  T    =1.0    ;
01334 
01335  gamma=1e+100 ;
01336 
01337  maxres =1e-5 ;
01338  maxiter=100  ;
01339 
01340  // Boundary Conditions
01341  for (i=0;i<DIM;i++) {
01342    J[i]=8 ;
01343    a[i]=0 ;
01344    e[i]=(1<<J[i]) ;
01345    BC[i][0][0]=-1 ;
01346    BC[i][0][1]=-1 ;
01347    BC[i][1][0]=-1 ;
01348    BC[i][1][1]=-1 ;
01349   }
01350  
01351 
01352 
01353  // OutTimes
01354  for (i=0; i<=20 ;i++) OutTimes[i]=2*i ;
01355  OutTimes[i]=1e+100 ;
01356  prstep=20 ;
01357 
01358  // Movie
01359  MovieStep=MAXINT ;
01360  for (i=0; i<DIM; i++) {
01361    MovieJ[i]=8 ;
01362    a[i]=0 ;
01363    e[i]=(1<<MovieJ[i]) ;
01364   }
01365  MovieTmp.Init(a,e,&WC) ;
01366 
01367  // Domain
01368  XL[0]=1.0  ;
01369  XL[1]=XL[0]  ;
01370  nu *=XL[0]*XL[0] ;
01371  
01372  this->ReadWavelets() ;
01373  this->SetBG() ;
01374  this->Print() ;
01375 
01376  // Initial Conditions.
01377  for (i=0; i<DIM; i++) U0[i].Init(a,e,&WC) ;
01378 
01379  P0.Init(a,e,&WC) ;
01380  P0.SetBoundaryConditions(BG) ;
01381  P0.Set(0.0) ;
01382 
01383  double pp[2]={nu,0.0} ;
01384  SetF[0]=new StokesFunction3F1 ;
01385  SetF[1]=new StokesFunction3F2 ;
01386  SetUD[0]=new StokesFunction3U1 ;
01387  SetUD[1]=new StokesFunction3U2 ;
01388 
01389  SetF [0]->SetParameters(pp) ;
01390  SetF [1]->SetParameters(pp) ;
01391  SetUD[0]->SetParameters(pp) ;
01392  SetUD[1]->SetParameters(pp) ;
01393 
01394  for (i=0; i<DIM; i++) {
01395    U0[i].SetFunction(SetUD[i]) ;
01396    U0[i].SetBoundaryConditions(BC[i]) ;
01397    for (j=0; j<DIM; j++) U0[i].ApplyOp(U0[i].BC[j], &U0[i], j, TRANSFORM) ;
01398  }
01399 }

Generated at Mon Aug 19 10:02:32 2002 for AWFD by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001