Snoopy Version 6.0 (Albert)
snoopy.h
Go to the documentation of this file.
00001 /*      
00002         This file is part of the Snoopy code.
00003 
00004     Snoopy code is free software: you can redistribute it and/or modify
00005     it under the terms of the GNU General Public License as published by
00006     the Free Software Foundation, either version 3 of the License, or
00007     (at your option) any later version.
00008 
00009     Snoopy code is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012     GNU General Public License for more details.
00013 
00014     You should have received a copy of the GNU General Public License
00015     along with Snoopy code.  If not, see <http://www.gnu.org/licenses/>.
00016 */
00017 
00018 
00019 
00020 #ifndef __SNOOPY_H__
00021 #define __SNOOPY_H__
00022 
00023 #include <math.h>
00024 #include <complex.h>
00025 #include <fftw3.h>
00026 
00027 #ifdef MPI_SUPPORT
00028 #include <mpi.h>
00029 #ifdef FFTW3_MPI_SUPPORT
00030 #include <fftw3-mpi.h>
00031 #endif
00032 #endif
00033 
00034 #ifdef _OPENMP
00035 #include <omp.h>
00036 #endif
00037 
00038 #include "gvars.h"
00039 
00040 #ifdef WITH_2D
00041 #undef NZ
00042 #define NZ              1               // enforce NZ when in 2D
00043 #endif
00044 
00045 #include "error.h"
00046 
00047 // Enforce No elssaser when not using MHD
00048 #ifdef ELSASSER_FORMULATION
00049 #ifndef MHD
00050 #undef ELSASSER_FORMULATION
00051 #endif
00052 #endif
00053 
00054 #ifdef MPI_SUPPORT
00055 #define         MPI_Printf                      if (rank==0) printf
00056 #else
00057 #define         MPI_Printf                      printf
00058 #endif
00059 
00060 
00061 // fix NPROC if MPI_SUPPORT is disabled
00062 #ifndef MPI_SUPPORT
00063 #ifndef         NPROC
00064 #define         NPROC                   1
00065 #endif
00066 #endif
00067 
00068 #define         NTOTAL                  NX * NY * NZ    
00070 #ifdef WITH_2D
00071 #define         NX_COMPLEX              NX                              
00072 #define         NY_COMPLEX              (NY / 2 + 1)    
00073 #define         NZ_COMPLEX              1                               
00074 #else
00075 #define         NX_COMPLEX              NX                              
00076 #define         NY_COMPLEX              NY                              
00077 #define         NZ_COMPLEX              (NZ / 2 + 1)    
00078 #endif
00079 
00080 #define         NTOTAL_COMPLEX  (NX_COMPLEX * NY_COMPLEX * NZ_COMPLEX / NPROC)  
00082 #define         IDX3D                   (k + j * NZ_COMPLEX + NZ_COMPLEX * NY_COMPLEX * i)  
00084 // Filenames
00085 
00086 #define OUTPUT_DUMP                                     "dump.dmp"                      
00087 #define OUTPUT_DUMP_SAV                         "dump_sav.dmp"      
00088 #define OUTPUT_DUMP_WRITE                       "dump_write.dmp"        
00091 // Structures
00092 
00093 #ifdef WITH_PARTICLES
00094 struct Particle {
00095         double x;
00096         double y;
00097         double z;
00098         double vx;
00099         double vy;
00100         double vz;
00101         double mass;    // unused for the moment
00102         double stime;   // Stopping time
00103 };
00104 #endif
00105 
00106 struct Field {
00107         int        nfield;
00108         double complex **farray;
00109         char   **fname;
00110         
00111          // This are the actual fields. 
00112         double complex *vx;
00113         double complex *vy;
00114         double complex *vz;
00115 #ifdef BOUSSINESQ
00116         double complex *th;
00117 #endif
00118 #ifdef MHD
00119         double complex *bx;
00120         double complex *by;
00121         double complex *bz;
00122 #endif
00123 #ifdef COMPRESSIBLE
00124         double complex *d;
00125 #endif
00126 #ifdef WITH_PARTICLES
00127         struct Particle *part;
00128 #endif
00129 };
00130 
00131 struct VarName {
00132         int             length;         // Number of varnames
00133         char**  name;           // Varnames (need to be allocated properly)
00134 };
00135 
00136 struct Parameters {
00137         // Physics Parameters
00138         double lx;                              
00139         double ly;                              
00140         double lz;                              
00142         double reynolds;                
00143         double reynolds_m;              
00145         double reynolds_th;             
00146         double reynolds_B;              
00148         double x_hall;                  
00150         double N2;                              
00152         double omega;                   
00154         double shear;                   
00156         double omega_shear;             
00158         double cs;                              
00160         // Particles parameters
00161         int    particles_n;             
00162         double particles_mass;  
00163         double particles_stime; 
00164         double particles_dg_ratio;      
00165         double particles_epsilon;       
00167         // Code parameters
00168         
00169         double cfl;                             
00170         double safety_source;   
00172         double t_initial;               
00173         double t_final;                 
00174         double max_t_elapsed;   
00176         int    interface_check; 
00177         int    interface_output_file;   
00179         int    force_symmetries;        
00180         int    symmetries_step;         
00182         int    antialiasing;            
00184         int    restart;
00185         
00186         // Output parameters
00187         double toutput_time;            
00188         double toutput_flow;            
00189         double toutput_dump;            
00191         int             output_vorticity;       
00193         struct VarName timevar_vars;    
00195         // initial conditions
00196         int        init_vortex;                 
00197         double vortex_a;                        
00198         double vortex_b;                        
00200         int    init_spatial_structure;  
00202         int        init_large_scale_noise;      
00203         double per_amplitude_large;             
00204         double noise_cut_length;                
00206         int        init_large_scale_2D_noise;   
00207         double per_amplitude_large_2D;          
00208         double noise_cut_length_2D;                 
00210         int    init_white_noise;                
00211         double per_amplitude_noise;             
00213         int    init_mean_field;                 
00214         double bx0;                                             
00215         double by0;                                             
00216         double bz0;                                             
00218         int    init_dump;                               
00220         int        init_bench;                          
00221 };
00222 
00223 #endif
00224