Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

src/Elasticity/main.cc

Go to the documentation of this file.
00001 // ------------------------------------------------------------
00002 // main_enw.cc
00003 //
00004 // ------------------------------------------------------------
00005 
00006 #include "entw.h"
00007 #include "printlas.h"
00008 #include "eingabe.h"      
00009 
00010 
00011 // new
00012 #define ddx(U) DX_FE(U)*Grid_stretch
00013 #define ddy(U) DY_FE(U)*Grid_stretch
00014 #define ddz(U) DZ_FE(U)
00015                
00016 #define u_exakt zz
00017 
00018 
00019 double Grid_stretch, finest_mesh_size;
00020 double mesh_z;
00021 double stretch_x,stretch_y,stretch_z;
00022 double eps;
00023 
00024 exit_type Solver(// parameter for grid generation
00025                  Grid_gen_parameters ggen_parameter,
00026                  int test_processors,
00027                  double meshsize,
00028                  double grid_stretch, // stretch grid in z-direction
00029                  All_Domains* domain,
00030                  // Parameter for Poisson
00031                  double kappa_x, double kappa_y, double kappa_z,
00032                  bool (*Neumann_boundary)(double x, double y, double z),
00033                  bool (*Third_boundary)(double x, double y, double z),
00034                  double beta_third,
00035                  double (*T_bulk)(double x,double y,double z),
00036                  double (*temp_Dirichlet)(double x,double y,double z),
00037                  double (*heat_source)(double x,double y,double z), 
00038                            // heat beschrieben durch Funktion
00039                            // dies wird verwendet falls input_object==NULL
00040                  Input_data_object* input_object,   // heat beschrieben
00041                                                     // falls nicht verwendet,
00042                                                     // muss Zeiger NULL sein
00043                  bool normalize_heat_integral,  
00044                            // falls normalize_heat_integral==true dann
00045                            // ist das Integral ueber heat folgender Wert:
00046                  double heat_integral, 
00047                  // Parameter for elasticity
00048                  double alpha,
00049                  double mu, double E,
00050                  double T_0,
00051                  // Parameter for linear-nonlinear
00052                  bool nonlinear_kappa,
00053                  bool nonlinear_alpha,
00054                  double (*Material_A)(double x,double y,double z),
00055                  double (*nonlinear_kappa_A)(double x),
00056                  double (*nonlinear_kappa_B)(double x),
00057                  double (*nonlinear_alpha_A)(double x),
00058                  double (*nonlinear_alpha_B)(double x),
00059                  // Parameter solver
00060                  int iteration_Poi,
00061                  int iteration_elas,
00062                  int solver_typ_elas,
00063                  double eps,
00064                  double bound_poiss,
00065                  double bound_elas, 
00066                  // Print Infos?
00067                  bool infos,
00068                  // pointer on ThreadComm-Class
00069                  ThreadComm* comm, 
00070                  // for Parallelization
00071                  MPI_Comm mpi_comm);
00072 
00073 // Parameter for linear-nonlinear
00074 double Material_A(double x,double y,double z) {
00075   // Rueckgabe nur 1.0 und 0.0
00076   // fuer Streckung des Gitters! wichtig!
00077   z = z * Grid_stretch;
00078 
00079   if(z > (0.2))
00080     return 1.0;
00081   return 0.0;
00082 }
00083 
00084 // Kappa_x = nonlinear_kappa * kappa_x
00085 // Kappa_y = nonlinear_kappa * kappa_y
00086 // Kappa_z = nonlinear_kappa * kappa_z
00087 double nonlinear_kappa_A(double T) {
00088   return 33.132 / (T - 42.871) / 0.0103;
00089 }
00090 
00091 double nonlinear_kappa_B(double T) {
00092   return 33.132 / (T - 42.871) / 0.0103;
00093 }
00094   
00095 double nonlinear_alpha_A(double T) {
00096   return 0.0000069;
00097 }
00098 
00099 double nonlinear_alpha_B(double T) {
00100   return 0.0000069;
00101 }
00102 
00103 /*
00104 // Markierung des Randes
00105 bool Neumann_boundary(double x, double y, double z) {
00106   // fuer Streckung des Gitters! wichtig!
00107   z = z * Grid_stretch;
00108   double r;
00109   r = sqrt(x*x+y*y);
00110 
00111   if(z > 0.8-eps) return true;
00112   else return false;
00113 }
00114 
00115 bool Third_boundary(double x, double y, double z) {
00116   // fuer Streckung des Gitters! wichtig!
00117   z = z * Grid_stretch;
00118   double r;
00119   r = sqrt(x*x+y*y);
00120   return false;
00121 }
00122 
00123 // Funktionen fuer den Rand
00124 double T_bulk(double x, double y, double z) {
00125   double r;
00126   r = sqrt(z*z+y*y);
00127 
00128   return 0.0;
00129 }
00130 
00131 double temp_Dirichlet(double x, double y, double z) {
00132   double r;
00133   r = sqrt(x*x+y*y);
00134 
00135   return 100.0;
00136 }
00137 */
00138 
00139 // Markierung des Randes
00140 bool Neumann_boundary(double x, double y, double z) {
00141   // fuer Streckung des Gitters! wichtig!
00142   z = z * Grid_stretch;
00143   double r;
00144   r = sqrt(x*x+y*y);
00145 
00146 // Test ob dann nicht NaN
00147 
00148   return false;
00149 
00150   if(x < 0.0) 
00151     return true;
00152   else 
00153     return false;
00154 
00155 
00156   /*
00157   if(z < 3.0-eps) return true;
00158   // if(z < 2.5) return true;
00159   else return false;
00160   */
00161 }
00162 
00163 bool Third_boundary(double x, double y, double z) {
00164   // fuer Streckung des Gitters! wichtig!
00165   z = z * Grid_stretch;
00166   double r;
00167   r = sqrt(x*x+y*y);
00168   return false;
00169 }
00170 
00171 // Funktionen fuer den Rand
00172 double T_bulk(double x, double y, double z) {
00173   double r;
00174   r = sqrt(z*z+y*y);
00175 
00176   return 0.0;
00177 }
00178 
00179 double temp_Dirichlet(double x, double y, double z) {
00180   double r;
00181   r = sqrt(x*x+y*y);
00182 
00183   return 0.0;
00184 }
00185 
00186 
00187 // Funktion fuer Waerme
00188 double Heat_source(double x, double y, double z) {
00189   double radius2;
00190 
00191   return 1.0;
00192  
00193   /*
00194   // fuer Streckung des Gitters! wichtig!
00195   z = z * Grid_stretch;
00196 
00197   z = z - 1.5;
00198 
00199   //  return 0.5-x;
00200 
00201   radius2 = z*z+y*y;
00202 
00203   if(radius2 <= 0.2)
00204     return 1.0;
00205   else
00206     return 0.0;
00207   */
00208 }
00209 
00210 int main(int argc, char** argv) {
00211   cout.precision(12);
00212   cout.setf(ios::fixed,ios::floatfield);
00213   ifstream PARAMETER;
00214   int test_processors;
00215 
00216   int my_rank;        /* Rank of process */
00217 
00218   //  Index3D(1,1,1).son(ENTd).coordinate().Print();
00219 
00220 
00221   MPI_Init(&argc,&argv);
00222   MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
00223 
00224   PARAMETER.open("para.dat",ios :: in);
00225 
00226   // stretch domain
00227   stretch_x =6.0;
00228   stretch_y =3.0;
00229   stretch_z =3.0;
00230 
00231   // grid mesh size
00232   PARAMETER >> finest_mesh_size;
00233 
00234   // test processors or not
00235   PARAMETER >> test_processors;
00236 
00237   // stretch grid in z-direction
00238   PARAMETER >> Grid_stretch;
00239 
00240   /*
00241   mesh_z = finest_mesh_size * Grid_stretch;
00242   if(my_rank==0) {
00243     fout << "\n Finest meshsize: " << finest_mesh_size << endl;    
00244     fout << "Finest meshsize along z axis: " <<mesh_z<< endl;    
00245   }
00246   */
00247 
00248   // Parameter for elasticity
00249   double alpha;
00250   double mu, E;
00251   double T_0;
00252 
00253   mu    = 0.25;
00254   E     = 30000.0;
00255   alpha = 0.0000069;
00256   T_0   = 0.0;
00257 
00258   // Parameter for Poisson
00259   double heat_integral, kappa_x, kappa_y, kappa_z;
00260   double beta_third;
00261  
00262   PARAMETER >> heat_integral;
00263 
00264   kappa_x = 0.0103;
00265   kappa_y = 0.0103;
00266   kappa_z = 0.0103;
00267   beta_third = 0.2;
00268 
00269   // Print Infos?
00270   bool infos;
00271   infos =true;
00272   
00273   // parameters for solver
00274   int iteration_Poi;
00275   int iteration_elas;
00276   int solver_typ_elas;
00277   double bound_poiss, bound_elas;
00278   double eps;
00279 
00280   PARAMETER >> solver_typ_elas;
00281   PARAMETER >> iteration_Poi;
00282   //  iteration_Poi  = 7;
00283   PARAMETER >> iteration_elas;
00284   //  iteration_elas = 1;
00285   bound_poiss = 0.000000001;
00286   bound_elas  = 0.000000001;
00287 
00288   eps = 0.0001;
00289 
00290   // Parameter for linear-nonlinear
00291   bool nonlinear_kappa;
00292   bool nonlinear_alpha;
00293 
00294   PARAMETER >> nonlinear_kappa;
00295   nonlinear_alpha = true;
00296   //  nonlinear_alpha = false;
00297 
00298   //Exits
00299   exit_type exit_hs;
00300   exit_hs = no_ex;
00301 
00302 
00303   // describtion of domain
00304   D3vector Vm(-0.5, -0.5, 0.0);
00305   // D3vector Vm(-0.0, -0.0, 0.0);
00306   D3vector Vstretch(stretch_x,stretch_y,stretch_z/Grid_stretch);
00307 
00308   Cylinder cylinder;
00309   /*
00310   //  Square cube;
00311   //  Skew_square cube(-0.5, 0.5);
00312 
00313   double alpha_d, alpha_t;
00314   alpha_d = -45;
00315   alpha_t = 45;
00316 
00317   double alpha_d_norm=atan(tan(alpha_d/180.*M_PI)/stretch_z*stretch_x);
00318   double alpha_t_norm=atan(tan(alpha_t/180.*M_PI)/stretch_z*stretch_x);
00319   Skew_square cube(alpha_d_norm, alpha_t_norm);
00320   */
00321 
00322   double alpha_d, alpha_t, alpha_l, alpha_r;
00323   /*
00324   alpha_d = -30;
00325   alpha_t = 30;
00326   
00327   alpha_l = -5;
00328   alpha_r = 7;
00329   */
00330   alpha_d = -60;
00331   alpha_t = 60;
00332   
00333   alpha_l = -5.0;
00334   alpha_r = 7.0;
00335   
00336   double alpha_d_norm=atan(tan(alpha_d/180.*M_PI)/stretch_x*stretch_z);
00337   double alpha_t_norm=atan(tan(alpha_t/180.*M_PI)/stretch_x*stretch_z);
00338 
00339   double alpha_l_norm=atan(tan(alpha_l/180.*M_PI)/stretch_y*stretch_z);
00340   double alpha_r_norm=atan(tan(alpha_r/180.*M_PI)/stretch_y*stretch_z);
00341   
00342 
00343   Skew_squareDTLR cube(alpha_d_norm, alpha_t_norm, alpha_l_norm, alpha_r_norm);
00344 
00345 
00346   Six_corner_pyramid Sechseck(D3vector(0.0,1.0,1.0), 
00347                               D3vector(1.0,0.0,1.0),
00348                               D3vector(2.0,1.0,1.0),
00349                               D3vector(2.0,2.0,1.0), 
00350                               D3vector(1.0,3.0,1.0),
00351                               D3vector(0.0,2.0,1.0),
00352                               
00353                               D3vector(-0.3,1.0,0.0), 
00354                               D3vector(1.0,-0.3,0.0),
00355                               D3vector(2.3,1.0,0.0),
00356                               D3vector(2.3,2.0,0.0), 
00357                               D3vector(1.0,3.3,0.0),
00358                               D3vector(-0.3,2.0,0.0));
00359 
00360 
00361   // Gebiet 1
00362   //  Domain domain((cube + Vm) * Vstretch);
00363   // Gebiet 2
00364   //  Domain domain(Sechseck * Vstretch);
00365   // Gebiet 3
00366   /*
00367   Square square;
00368   D3vector ecke(-5.0,-5.0,-5.0);
00369   double   Laenge = 10.0;
00370   Domain domain((square*Laenge+ecke));
00371   */
00372 
00373   Ball   ball;
00374   Square square;
00375 
00376   D3vector V1(-0.5,0.5,0.0);
00377   D3vector V2(0.5,0.0,0.5);
00378   D3vector V3(1.0,0.5,0.5);
00379 
00380   //  definition of the domain:
00381   Domain domain(ball || ((square*V3) + V1)  || ((square*V3) + V2));
00382 
00383 
00384   // Trace pro Sachen:
00385   Input_data_object* P_input_object;
00386 
00387   /*
00388   PARAMETER.open("file.txt",ios :: in);
00389   Reader_trace_pro reader(PARAMETER);
00390   PARAMETER.close();
00391 
00392   Input_data_object input_object(reader.ort,
00393                                  reader.value,
00394                                  reader.anzahl_punkte,
00395                                  reader.mesh_size);
00396 
00397   P_input_object = NULL;
00398   P_input_object = &input_object;
00399   */
00400 
00401   P_input_object = NULL;
00402 
00403   ThreadComm commObj;
00404   ThreadComm* comm;
00405   comm = &commObj;
00406 
00407   Grid_gen_parameters ggen_parameter;
00408   // ggen_parameter.Set_grid_point(D3vector(0.0,1.5,0.2/Grid_stretch)); 
00409 
00410   double off_par;
00411   double stre_par;
00412   int n_genau;
00413 
00414   PARAMETER >> off_par;
00415   PARAMETER >> stre_par; 
00416   PARAMETER >> n_genau;
00417   PARAMETER.close();
00418 
00419 
00420   ggen_parameter.Set_r_parallel(n_genau);
00421   ggen_parameter.Set_offset_square(off_par);
00422   ggen_parameter.Set_stretch_square(stre_par);
00423 
00424   exit_hs = Solver(// parameter for grid generation
00425                    ggen_parameter,
00426                    test_processors,
00427                    finest_mesh_size,
00428                    Grid_stretch, // stretch grid in z-direction
00429                    &domain,
00430                    // Parameter for Poisson
00431                    kappa_x, kappa_y, kappa_z,
00432                    Neumann_boundary,
00433                    Third_boundary,
00434                    beta_third,
00435                    T_bulk,
00436                    temp_Dirichlet,
00437                    Heat_source, // heat beschrieben 
00438                                 // durch Funktion
00439                                 // dies wird verwendet 
00440                                 // falls input_object==NULL
00441                    P_input_object,        // heat beschrieben
00442                                           // falls nicht verwendet,
00443                                           // muss Zeiger NULL sein
00444                    true, // ( normalize_heat_integral )
00445                            // falls  normalize_heat_integral==true dann
00446                            // ist das Integral ueber heat folgender Wert:
00447                    heat_integral, 
00448                    // Parameter for elasticity
00449                    alpha,
00450                    mu, E,
00451                    T_0,
00452                    // Parameter for linear-nonlinear
00453                    nonlinear_kappa,
00454                    nonlinear_alpha,
00455                    Material_A,
00456                    nonlinear_kappa_A,
00457                    nonlinear_kappa_B,
00458                    nonlinear_alpha_A,
00459                    nonlinear_alpha_B,
00460                    // parameter solver
00461                    iteration_Poi,
00462                    iteration_elas,
00463                    solver_typ_elas,
00464                    eps,
00465                    bound_poiss,
00466                    bound_elas, 
00467                    // Print Infos?
00468                    infos,
00469                    // pointer on ThreadComm-Class
00470                    comm,MPI_COMM_WORLD);
00471 
00472 
00473   if (exit_hs == hard_ex) { 
00474     fout << "Calculation killed. " << endl;
00475   }    
00476 
00477 
00478   if(my_rank==0) cout << " \n End: " << endl;
00479 
00480   MPI_Finalize();
00481 }
00482 
00483 
00484 
00485 
00486 // Output 
00487 void Print_Datas(Variable& ux, Variable& uy, Variable& uz,
00488                  Variable& Temp,
00489                  Variable& rx, Variable& ry, Variable& rz,
00490                  Variable& One,
00491                  Variable& zz,           
00492                  double T_0,
00493                  double F,
00494                  double mu,
00495                  double alpha,
00496                  Cell_Variable& Mat_A,
00497                  ThreadComm* comm) {
00498   double spmax, spmin;
00499   int my_rank;
00500 
00501   my_rank = ux.Give_grid()->Give_my_rank();
00502 
00503   // Output for AVS
00504   ofstream DATEI;
00505 
00506   // Output of stress 
00507   zz  = (((ddx(ux) * (1.0-mu) + (ddy(uy) + ddz(uz)) * mu)
00508           / One) - ((1.0-mu) * alpha + mu * (alpha + alpha)) * (Temp - T_0))
00509     * F  | all_points;
00510 
00511   /*
00512   if(my_rank==0) DATEI.open("stress.dat",ios :: out);
00513   Print_UCD_moved(zz,rx,ry,rz,&DATEI);
00514   if(my_rank==0) DATEI.close();
00515   */
00516 
00517   spmax = Maximum(zz);
00518   spmin = Minimum(zz);
00519   if(my_rank==0) fout <<" Maximum sxx: "<< spmax <<" Minimum sxx: "
00520                       << spmin << endl;
00521 
00522   /*
00523   if(my_rank==0) DATEI.open("temp.dat",ios :: out);
00524   Print_UCD_moved(Temp,rx,ry,rz,&DATEI);
00525   if(my_rank==0) DATEI.close();
00526   */
00527 
00528   /*
00529   if(my_rank==0) DATEI.open("mat_A.dat",ios :: out);
00530   Print_UCD_moved(Mat_A,rx,ry,rz,&DATEI);
00531   if(my_rank==0) DATEI.close();
00532   */
00533 }
00534 

Generated on Fri Nov 2 01:25:55 2007 for IPPL by doxygen 1.3.5