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

src/expde/extemp/variable.cc

Go to the documentation of this file.
00001 //    expde: expression templates for partial differential equations.
00002 //    Copyright (C) 2001  Christoph Pflaum
00003 //    This program is free software; you can redistribute it and/or modify
00004 //    it under the terms of the GNU General Public License as published by
00005 //    the Free Software Foundation; either version 2 of the License, or
00006 //    (at your option) any later version.
00007 //
00008 //    This program is distributed in the hope that it will be useful,
00009 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 //    GNU General Public License for more details.
00012 //
00013 //                 SEE  Notice1.doc made by 
00014 //                 LAWRENCE LIVERMORE NATIONAL LABORATORY
00015 //
00016 
00017 // ------------------------------------------------------------
00018 // variable.cc
00019 //
00020 // ------------------------------------------------------------
00021 
00022 // Include level 0:
00023 #ifdef COMP_GNUOLD
00024  #include <iostream.h>
00025  #include <fstream.h>
00026  #include <time.h>
00027  #include <math.h>
00028 #else
00029  #include <iostream>
00030  #include <fstream>
00031  #include <ctime>
00032  #include <cmath>
00033 #endif 
00034 
00035 
00036 // Include level 0:
00037 #include "../parser.h"
00038 
00039 // Include level 1:
00040 #include "../paramete.h"
00041 #include "../abbrevi.h"
00042 #include "../math_lib/math_lib.h"
00043 
00044 // Include level 2:
00045 #include "../basic/basic.h"
00046 
00047 // Include level 3:
00048 #include "../domain/domain.h"
00049 
00050 // Include level 4:
00051 #include "../formulas/boundy.h"
00052 #include "../formulas/loc_sten.h"
00053 
00054 // Include level 5:
00055 #include "../grid/gpar.h"
00056 #include "../grid/parallel.h"
00057 #include "../grid/mgcoeff.h"
00058 #include "../grid/sto_man.h"
00059 #include "../grid/gridbase.h"
00060 #include "../grid/grid.h"
00061 #include "../grid/input.h"
00062 
00063 // Include level 5.1
00064 #include "../evpar/evpar.h"
00065 
00066 // Include level 6:
00067 #include "variable.h"
00068 
00069 
00071                // 1.: Maximum
00072                // 2.: Scalarproduct
00073                // 3.: print
00074                // 4.: calculate normal vector
00075                // 5.: Member functions
00077 
00078 
00080 // 1.: Maximum
00082 
00083 
00084 /* Binary operators */
00085 /* product */
00086 
00087 
00088 double L_infty(Variable& v) {
00089   bool run;
00090   int run_bo;
00091   int lev, color;
00092   double max, total_max;
00093   P_interior *iter_i;
00094   P_nearb    *iter_n;
00095   P_Bo2p     *iter_b;
00096   P_cellpoi  *iter_cf;
00097                          
00098   max=0;
00099 
00100   v.Test_init();  // Grid storage initialization
00101   lev = v.Level();
00102   if(lev < 0)          { cout << "\n Level too coarse! "   << endl; }
00103   else if (lev > v.Max_Level())  { cout << "\n Level too fine! " << endl; }
00104   else { // Start
00105     run = v.run_interior();
00106       if(run) {
00107         // number of operations
00108         v.Give_grid()->Add_operations(1,lev);
00109         // innere Punkte
00110         v.Give_grid()->Start_calc_time_interior();
00111         for(color=0;color<8;++color)
00112           for(iter_i=v.Give_grid()->Start_P_interior(lev,color);
00113               iter_i!=NULL;iter_i=iter_i->Next()) {
00114             if(max<ABS(v.Give_interior_simple(iter_i,v.Give_grid(),lev)))
00115               max = ABS(v.Give_interior_simple(iter_i,v.Give_grid(),lev));
00116           }
00117         v.Give_grid()->Stop_calc_time_interior();
00118       }
00119       run = v.run_nearb();
00120       v.Give_grid()->Start_calc_time_nearbb();
00121       if(run) {
00122         // Randzellfreiheitsgrade
00123         for(iter_cf=v.Give_grid()->Start_P_cellpoi(lev);
00124             iter_cf!=NULL;iter_cf=iter_cf->Next()) {
00125           if(max<ABS(v.Give_cellpoi(iter_cf,v.Give_grid())))
00126             max = ABS(v.Give_cellpoi(iter_cf,v.Give_grid()));
00127         }
00128         // randnahe Punkte
00129         v.Give_grid()->Start_calc_time_nearbb();
00130         for(color=0;color<8;++color)
00131           for(iter_n=v.Give_grid()->Start_P_nearb(lev,color);
00132               iter_n!=NULL;iter_n=iter_n->Next()) {
00133             if(max<ABS(v.Give_nearb(iter_n,v.Give_grid(),0.0,lev)))
00134               max = ABS(v.Give_nearb(iter_n,v.Give_grid(),0.0,lev));
00135           }
00136       }
00137       run_bo = v.run_boundary();
00138       if(run_bo==true) {
00139         // Randpunkte
00140         for(color=0;color<8;++color)
00141           for(iter_b=v.Give_grid()->Start_P_Bo2p(lev,color);
00142               iter_b!=NULL;iter_b=iter_b->Next()) {
00143             if(max<ABS(v.Give_Bo2p(iter_b,v.Give_grid(),lev)))
00144               max = ABS(v.Give_Bo2p(iter_b,v.Give_grid(),lev));
00145           }
00146         // exterior grobe Randpunkte
00147         for(color=0;color<8;++color)
00148           for(iter_n=v.Give_grid()->Start_P_exteri(lev,color);
00149               iter_n!=NULL;iter_n=iter_n->Next()) {
00150             if(max<ABS(v.Give_nearb(iter_n,v.Give_grid(),0.0,lev)))
00151               max = ABS(v.Give_nearb(iter_n,v.Give_grid(),0.0,lev));
00152           }
00153       }
00154       else if(run_bo<false) {
00155         // Randpunkte
00156         for(color=0;color<8;++color)
00157           for(iter_b=v.Give_grid()->Start_P_Bo2p(lev,color);
00158               iter_b!=NULL;iter_b=iter_b->Next()) {
00159             if(iter_b->Give_Label(-run_bo,v.Give_grid())) {
00160               if(max<ABS(v.Give_Bo2p(iter_b,v.Give_grid(),lev)))
00161                 max = ABS(v.Give_Bo2p(iter_b,v.Give_grid(),lev));
00162             }
00163           }
00164         // exterior grobe Randpunkte
00165         for(color=0;color<8;++color)
00166           for(iter_n=v.Give_grid()->Start_P_exteri(lev,color);
00167               iter_n!=NULL;iter_n=iter_n->Next()) {
00168             if(iter_n->Give_Label(-run_bo,lev,v.Give_grid())) {
00169               if(max<ABS(v.Give_nearb(iter_n,v.Give_grid(),0.0,lev)))
00170                 max = ABS(v.Give_nearb(iter_n,v.Give_grid(),0.0,lev));
00171             }
00172           }
00173       }
00174       v.Give_grid()->Stop_calc_time_nearbb();
00175   }
00176   MPI_Allreduce(&max,&total_max,1,MPI_DOUBLE,MPI_MAX,
00177                 v.Give_grid()->Give_comm());
00178 
00179   return total_max;
00180 }
00181 
00182 
00183 double Find_one_value_of_an_active_point(Variable& v, double sign) {
00184   bool run;
00185   int run_bo;
00186   int lev, color;
00187   P_interior *iter_i;
00188   P_nearb    *iter_n;
00189   P_Bo2p     *iter_b;
00190 
00191 
00192   v.Test_init();  // Grid storage initialization
00193   lev = v.Level();
00194   if(lev < 0)          { cout << "\n Level too coarse! "   << endl; }
00195   else if (lev > v.Max_Level())  { cout << "\n Level too fine! " << endl; }
00196   else { // Start
00197     run = v.run_interior();
00198     if(run) {
00199       iter_i=v.Give_grid()->Start_P_interior(lev,0);
00200       if(iter_i!=NULL)
00201         return v.Give_interior_simple(iter_i,v.Give_grid(),lev);
00202     }
00203     run = v.run_nearb();
00204     if(run) {
00205       // randnahe Punkte
00206       iter_n=v.Give_grid()->Start_P_nearb(lev,0);
00207       if(iter_n!=NULL)
00208         return v.Give_nearb(iter_n,v.Give_grid(),0.0,lev);
00209     }
00210     run_bo = v.run_boundary();
00211     if(run_bo==true) {
00212       // Randpunkte
00213       iter_b=v.Give_grid()->Start_P_Bo2p(lev,0);
00214       if(iter_b!=NULL)
00215         return v.Give_Bo2p(iter_b,v.Give_grid(),lev);
00216       // exterior grobe Randpunkte
00217       iter_n=v.Give_grid()->Start_P_exteri(lev,0);
00218       if(iter_n!=NULL)
00219         return v.Give_nearb(iter_n,v.Give_grid(),0.0,lev);
00220     }
00221     else if(run_bo<false) {
00222       // Randpunkte
00223       for(color=0;color<8;++color)
00224         for(iter_b=v.Give_grid()->Start_P_Bo2p(lev,color);
00225             iter_b!=NULL;iter_b=iter_b->Next()) {
00226           if(iter_b->Give_Label(-run_bo,v.Give_grid())) {
00227             return v.Give_Bo2p(iter_b,v.Give_grid(),lev);
00228           }
00229         }
00230       // exterior grobe Randpunkte
00231       for(color=0;color<8;++color)
00232         for(iter_n=v.Give_grid()->Start_P_exteri(lev,color);
00233             iter_n!=NULL;iter_n=iter_n->Next()) {
00234           if(iter_n->Give_Label(-run_bo,lev,v.Give_grid())) {
00235             return v.Give_nearb(iter_n,v.Give_grid(),0.0,lev);
00236           }
00237         }
00238     }
00239   }
00240   return 1.0e99 * sign;
00241 }
00242 
00243 
00244 double Maximum(Variable& v) {
00245   bool run;
00246   int color;
00247   int run_bo;
00248   int lev;
00249   double max, total_max;
00250   P_interior *iter_i;
00251   P_nearb    *iter_n;
00252   P_Bo2p     *iter_b;
00253   P_cellpoi  *iter_cf;
00254                          
00255   max = Find_one_value_of_an_active_point(v,-1.0);
00256 
00257   v.Test_init();  // Grid storage initialization
00258   lev = v.Level();
00259   if(lev < 0)          { cout << "\n Level too coarse! "   << endl; }
00260   else if (lev > v.Max_Level())  { cout << "\n Level too fine! " << endl; }
00261   else { // Start
00262     run = v.run_interior();
00263       if(run) {
00264         // number of operations
00265         v.Give_grid()->Add_operations(1,lev);
00266         // innere Punkte
00267         v.Give_grid()->Start_calc_time_interior();
00268         for(color=0;color<8;++color)
00269           for(iter_i=v.Give_grid()->Start_P_interior(lev,color);
00270               iter_i!=NULL;iter_i=iter_i->Next()) {
00271             if(max<(v.Give_interior_simple(iter_i,v.Give_grid(),lev)))
00272               max = (v.Give_interior_simple(iter_i,v.Give_grid(),lev));
00273           }
00274         v.Give_grid()->Stop_calc_time_interior();
00275       }
00276       run = v.run_nearb();
00277       v.Give_grid()->Start_calc_time_nearbb();
00278       if(run) {
00279         // Randzellfreiheitsgrade
00280         for(iter_cf=v.Give_grid()->Start_P_cellpoi(lev);
00281             iter_cf!=NULL;iter_cf=iter_cf->Next()) {
00282           if(max<(v.Give_cellpoi(iter_cf,v.Give_grid())))
00283             max = (v.Give_cellpoi(iter_cf,v.Give_grid()));
00284         }
00285         // randnahe Punkte
00286         for(color=0;color<8;++color)
00287           for(iter_n=v.Give_grid()->Start_P_nearb(lev,color);
00288               iter_n!=NULL;iter_n=iter_n->Next()) {
00289             if(max<(v.Give_nearb(iter_n,v.Give_grid(),0.0,lev)))
00290               max = (v.Give_nearb(iter_n,v.Give_grid(),0.0,lev));
00291           }
00292       }
00293       run_bo = v.run_boundary();
00294       if(run_bo==true) {
00295         // Randpunkte
00296         for(color=0;color<8;++color)
00297           for(iter_b=v.Give_grid()->Start_P_Bo2p(lev,color);
00298               iter_b!=NULL;iter_b=iter_b->Next()) {
00299             if(max<(v.Give_Bo2p(iter_b,v.Give_grid(),lev)))
00300               max = v.Give_Bo2p(iter_b,v.Give_grid(),lev);
00301           }
00302         // exterior grobe Randpunkte
00303         for(color=0;color<8;++color)
00304           for(iter_n=v.Give_grid()->Start_P_exteri(lev,color);
00305               iter_n!=NULL;iter_n=iter_n->Next()) {
00306             if(max<(v.Give_nearb(iter_n,v.Give_grid(),0.0,lev)))
00307               max = (v.Give_nearb(iter_n,v.Give_grid(),0.0,lev));
00308           }
00309       }
00310       else if(run_bo<false) {
00311         // Randpunkte
00312         for(color=0;color<8;++color)
00313           for(iter_b=v.Give_grid()->Start_P_Bo2p(lev,color);
00314               iter_b!=NULL;iter_b=iter_b->Next()) {
00315             if(iter_b->Give_Label(-run_bo,v.Give_grid())) {
00316               if(max<(v.Give_Bo2p(iter_b,v.Give_grid(),lev)))
00317                 max = v.Give_Bo2p(iter_b,v.Give_grid(),lev);
00318             }
00319           }
00320         // exterior grobe Randpunkte
00321         for(color=0;color<8;++color)
00322           for(iter_n=v.Give_grid()->Start_P_exteri(lev,color);
00323               iter_n!=NULL;iter_n=iter_n->Next()) {
00324             if(iter_n->Give_Label(-run_bo,lev,v.Give_grid())) {
00325               if(max<(v.Give_nearb(iter_n,v.Give_grid(),0.0,lev)))
00326                 max = (v.Give_nearb(iter_n,v.Give_grid(),0.0,lev));
00327             }
00328           }
00329       }
00330       v.Give_grid()->Stop_calc_time_nearbb();
00331   }
00332   MPI_Allreduce(&max,&total_max,1,MPI_DOUBLE,MPI_MAX,
00333                 v.Give_grid()->Give_comm());
00334 
00335   return total_max;
00336 }
00337 
00338 
00339 double Minimum(Variable& v) {
00340   bool run;
00341   int color;
00342   int run_bo;
00343   int lev;
00344   double min, total_min;
00345   P_interior *iter_i;
00346   P_nearb    *iter_n;
00347   P_Bo2p     *iter_b;
00348   P_cellpoi  *iter_cf;
00349                          
00350   min = Find_one_value_of_an_active_point(v,1.0);
00351 
00352   v.Test_init();  // Grid storage initialization
00353   lev = v.Level();
00354   if(lev < 0)          { cout << "\n Level too coarse! "   << endl; }
00355   else if (lev > v.Max_Level())  { cout << "\n Level too fine! " << endl; }
00356   else { // Start
00357     run = v.run_interior();
00358       if(run) {
00359         // number of operations
00360         v.Give_grid()->Add_operations(1,lev);
00361         // innere Punkte
00362         v.Give_grid()->Start_calc_time_interior();
00363         for(color=0;color<8;++color)
00364           for(iter_i=v.Give_grid()->Start_P_interior(lev,color);
00365               iter_i!=NULL;iter_i=iter_i->Next()) {
00366             if(min>(v.Give_interior_simple(iter_i,v.Give_grid(),lev)))
00367               min = (v.Give_interior_simple(iter_i,v.Give_grid(),lev));
00368           }
00369         v.Give_grid()->Stop_calc_time_interior();
00370       }
00371       run = v.run_nearb();
00372       v.Give_grid()->Start_calc_time_nearbb();
00373       if(run) {
00374         // Randzellfreiheitsgrade
00375         for(iter_cf=v.Give_grid()->Start_P_cellpoi(lev);
00376             iter_cf!=NULL;iter_cf=iter_cf->Next()) {
00377           if(min>(v.Give_cellpoi(iter_cf,v.Give_grid())))
00378             min = (v.Give_cellpoi(iter_cf,v.Give_grid()));
00379         }
00380         // randnahe Punkte
00381         for(color=0;color<8;++color)
00382           for(iter_n=v.Give_grid()->Start_P_nearb(lev,color);
00383               iter_n!=NULL;iter_n=iter_n->Next()) {
00384             if(min>(v.Give_nearb(iter_n,v.Give_grid(),0.0,lev)))
00385               min = (v.Give_nearb(iter_n,v.Give_grid(),0.0,lev));
00386           }
00387       }
00388       run_bo = v.run_boundary();
00389       if(run_bo==true) {
00390         // Randpunkte
00391         for(color=0;color<8;++color)
00392           for(iter_b=v.Give_grid()->Start_P_Bo2p(lev,color);
00393               iter_b!=NULL;iter_b=iter_b->Next()) {
00394             if(min>v.Give_Bo2p(iter_b,v.Give_grid(),lev))
00395               min = v.Give_Bo2p(iter_b,v.Give_grid(),lev);
00396           }
00397         // exterior grobe Randpunkte
00398         for(color=0;color<8;++color)
00399           for(iter_n=v.Give_grid()->Start_P_exteri(lev,color);
00400               iter_n!=NULL;iter_n=iter_n->Next()) {
00401             if(min>(v.Give_nearb(iter_n,v.Give_grid(),0.0,lev)))
00402               min = (v.Give_nearb(iter_n,v.Give_grid(),0.0,lev));
00403           }
00404       }
00405       else if(run_bo<false) {
00406         // Randpunkte
00407         for(color=0;color<8;++color)
00408           for(iter_b=v.Give_grid()->Start_P_Bo2p(lev,color);
00409               iter_b!=NULL;iter_b=iter_b->Next()) {
00410             if(iter_b->Give_Label(-run_bo,v.Give_grid())) {
00411               if(min>v.Give_Bo2p(iter_b,v.Give_grid(),lev))
00412                 min = v.Give_Bo2p(iter_b,v.Give_grid(),lev);
00413             }
00414           }
00415         // exterior grobe Randpunkte
00416         for(color=0;color<8;++color)
00417           for(iter_n=v.Give_grid()->Start_P_exteri(lev,color);
00418               iter_n!=NULL;iter_n=iter_n->Next()) {
00419             if(iter_n->Give_Label(-run_bo,lev,v.Give_grid())) {       
00420               if(min>(v.Give_nearb(iter_n,v.Give_grid(),0.0,lev)))
00421                 min = (v.Give_nearb(iter_n,v.Give_grid(),0.0,lev));
00422             }
00423           }
00424       }
00425       v.Give_grid()->Stop_calc_time_nearbb();
00426   }
00427   MPI_Allreduce(&min,&total_min,1,MPI_DOUBLE,MPI_MIN,
00428                 v.Give_grid()->Give_comm());
00429 
00430   return total_min;
00431 }
00432 
00433 
00435 // 2.: Scalarproduct
00437 
00438 
00439 /* Binary operators */
00440 /* product */
00441 
00442 
00443 double product(Variable& b, Variable& a)
00444 {
00445   bool run;
00446   int lev, run_bo, color;
00447   double sum;
00448   P_interior *iter_i;
00449   P_nearb    *iter_n;
00450   P_Bo2p     *iter_b;
00451   P_cellpoi  *iter_cf;
00452   double total_sum;
00453                          
00454   sum=0;
00455 
00456   a.Test_init();  // Grid storage initialization
00457   lev = a.Level();
00458   if(lev < 0)          { cout << "\n Level too coarse! "   << endl; }
00459   else if (lev > a.Max_Level())  { cout << "\n Level too fine! " << endl; }
00460   else { // Start
00461     run = a.run_interior();
00462       if(run) {
00463         // number of operations
00464         a.Give_grid()->Add_operations(2,lev);
00465         // innere Punkte
00466         a.Give_grid()->Start_calc_time_interior();
00467         for(color=0;color<8;++color)
00468           for(iter_i=a.Give_grid()->Start_P_interior(lev,color);
00469               iter_i!=NULL;iter_i=iter_i->Next()) {
00470             sum = sum + a.Give_interior_simple(iter_i,a.Give_grid(),lev) *
00471               b.Give_interior_simple(iter_i,a.Give_grid(),lev);
00472           }
00473         a.Give_grid()->Stop_calc_time_interior();
00474       }
00475 
00476 bool ttt;
00477 ttt =false; 
00478 // ttt =true; 
00479 if(ttt) {     
00480 //if(a.Give_grid()->Give_my_rank()==0) 
00481 cout << " sum interior: " << sum << " my_rank: "
00482      << a.Give_grid()->Give_my_rank() << endl;
00483 }
00484       
00485       run = a.run_nearb();
00486       a.Give_grid()->Start_calc_time_nearbb();  
00487       if(run) {
00488         // Randzellfreiheitsgrade
00489         for(iter_cf=a.Give_grid()->Start_P_cellpoi(lev);
00490             iter_cf!=NULL;iter_cf=iter_cf->Next()) {
00491           sum = sum + a.Give_cellpoi(iter_cf,a.Give_grid()) *
00492             b.Give_cellpoi(iter_cf,a.Give_grid());
00493         } 
00494         // randnahe Punkte
00495         for(color=0;color<8;++color)
00496           for(iter_n=a.Give_grid()->Start_P_nearb(lev,color);
00497               iter_n!=NULL;iter_n=iter_n->Next()) {
00498             sum = sum + a.Give_nearb(iter_n,a.Give_grid(),0.0,lev) *
00499               b.Give_nearb(iter_n,a.Give_grid(),0.0,lev);
00500           }
00501       }
00502  
00503 if(ttt) {     
00504 //if(a.Give_grid()->Give_my_rank()==0)
00505 cout << " sum nearb: " << sum << " my_rank: " 
00506      << a.Give_grid()->Give_my_rank() << endl;
00507 }      
00508 
00509       run_bo = a.run_boundary();
00510       if(run_bo==true) {
00511         // Randpunkte
00512         for(color=0;color<8;++color) {
00513           for(iter_b=a.Give_grid()->Start_P_Bo2p(lev,color);
00514               iter_b!=NULL;iter_b=iter_b->Next()) {
00515             sum = sum + a.Give_Bo2p(iter_b,a.Give_grid(),lev) *
00516               b.Give_Bo2p(iter_b,a.Give_grid(),lev);
00517           }
00518         }
00519         // exterior grobe Randpunkte
00520         for(color=0;color<8;++color) {
00521           for(iter_n=a.Give_grid()->Start_P_exteri(lev,color);
00522               iter_n!=NULL;iter_n=iter_n->Next()) {
00523             sum = sum + a.Give_nearb(iter_n,a.Give_grid(),0.0,lev) *
00524               b.Give_nearb(iter_n,a.Give_grid(),0.0,lev);
00525           }
00526         }
00527       }
00528       else if(run_bo<false) {
00529         // Randpunkte
00530         for(color=0;color<8;++color)
00531           for(iter_b=a.Give_grid()->Start_P_Bo2p(lev,color);
00532               iter_b!=NULL;iter_b=iter_b->Next()) {
00533             if(iter_b->Give_Label(-run_bo,a.Give_grid())) {
00534               sum = sum + a.Give_Bo2p(iter_b,a.Give_grid(),lev) *
00535                 b.Give_Bo2p(iter_b,a.Give_grid(),lev);
00536             }
00537           }
00538         // exterior grobe Randpunkte
00539         for(color=0;color<8;++color) {
00540           for(iter_n=a.Give_grid()->Start_P_exteri(lev,color);
00541               iter_n!=NULL;iter_n=iter_n->Next()) {
00542             if(iter_n->Give_Label(-run_bo,lev,a.Give_grid())) {
00543               sum = sum + a.Give_nearb(iter_n,a.Give_grid(),0.0,lev) *
00544                 b.Give_nearb(iter_n,a.Give_grid(),0.0,lev);
00545 
00546 
00547 
00548               /*
00549 
00550 cout << " sum exterior: " << sum << " my_rank: "
00551      << a.Give_grid()->Give_my_rank() 
00552      << " level: " << lev << endl;
00553 
00554       
00555               */
00556 
00557 
00558 
00559 
00560 
00561 
00562 
00563 
00564 
00565             }
00566           }
00567         }
00568       }
00569       a.Give_grid()->Stop_calc_time_nearbb();   
00570 
00571       
00572 if(ttt) {
00573 cout << " sum all: " << sum << " my_rank: " 
00574      << a.Give_grid()->Give_my_rank() << endl;
00575 }
00576      
00577 
00578   }
00579 
00580 
00581   MPI_Allreduce(&sum,&total_sum,1,MPI_DOUBLE,MPI_SUM,
00582                 a.Give_grid()->Give_comm());
00583 
00584   return total_sum;
00585 }
00586 
00587 
00588 
00589 double product(Variable& a1, Variable& a2, Variable& a3,
00590                Variable& b1, Variable& b2, Variable& b3)
00591 {
00592   bool run; 
00593   int color;
00594   int run_bo;
00595   int lev;
00596   double sum, total_sum;
00597   P_interior *iter_i;
00598   P_nearb    *iter_n;
00599   P_Bo2p     *iter_b;
00600   P_cellpoi  *iter_cf;
00601                          
00602   sum=0;
00603 
00604   a1.Test_init();  // Grid storage initialization
00605   lev = a1.Level();
00606   if(lev < 0)          { cout << "\n Level too coarse! "   << endl; }
00607   else if (lev > a1.Max_Level())  { cout << "\n Level too fine! " << endl; }
00608   else { // Start
00609     run = a1.run_interior();
00610       if(run) {
00611         // number of operations
00612         a1.Give_grid()->Add_operations(6,lev);
00613         // innere Punkte
00614         a1.Give_grid()->Start_calc_time_interior();
00615         for(color=0;color<8;++color)
00616           for(iter_i=a1.Give_grid()->Start_P_interior(lev,color);
00617               iter_i!=NULL;iter_i=iter_i->Next()) {
00618             sum = sum + 
00619               a1.Give_interior_simple(iter_i,a1.Give_grid(),lev) *
00620               b1.Give_interior_simple(iter_i,a1.Give_grid(),lev) +
00621               a2.Give_interior_simple(iter_i,a1.Give_grid(),lev) *
00622               b2.Give_interior_simple(iter_i,a1.Give_grid(),lev) +
00623               a3.Give_interior_simple(iter_i,a1.Give_grid(),lev) *
00624               b3.Give_interior_simple(iter_i,a1.Give_grid(),lev);
00625           }
00626         a1.Give_grid()->Stop_calc_time_interior();
00627       }
00628       run = a1.run_nearb();
00629       a1.Give_grid()->Start_calc_time_nearbb();
00630       if(run) {
00631         // Randzellfreiheitsgrade
00632         for(iter_cf=a1.Give_grid()->Start_P_cellpoi(lev);
00633             iter_cf!=NULL;iter_cf=iter_cf->Next()) {
00634           sum = sum +
00635             a1.Give_cellpoi(iter_cf,a1.Give_grid()) *
00636             b1.Give_cellpoi(iter_cf,a1.Give_grid()) +
00637             a2.Give_cellpoi(iter_cf,a1.Give_grid()) *
00638             b2.Give_cellpoi(iter_cf,a1.Give_grid()) +
00639             a3.Give_cellpoi(iter_cf,a1.Give_grid()) *
00640             b3.Give_cellpoi(iter_cf,a1.Give_grid());
00641         }   
00642         // randnahe Punkte
00643         for(color=0;color<8;++color)
00644           for(iter_n=a1.Give_grid()->Start_P_nearb(lev,color);
00645               iter_n!=NULL;iter_n=iter_n->Next()) {
00646             sum = sum + 
00647               a1.Give_nearb(iter_n,a1.Give_grid(),0.0,lev) *
00648               b1.Give_nearb(iter_n,a1.Give_grid(),0.0,lev) +
00649               a2.Give_nearb(iter_n,a1.Give_grid(),0.0,lev) *
00650               b2.Give_nearb(iter_n,a1.Give_grid(),0.0,lev) +
00651               a3.Give_nearb(iter_n,a1.Give_grid(),0.0,lev) *
00652               b3.Give_nearb(iter_n,a1.Give_grid(),0.0,lev);
00653           }
00654       }
00655       run_bo = a1.run_boundary();
00656       if(run_bo==true) {
00657         // Randpunkte
00658         a1.Give_grid()->Start_calc_time_nearbb();
00659         for(color=0;color<8;++color)
00660           for(iter_b=a1.Give_grid()->Start_P_Bo2p(lev,color);
00661               iter_b!=NULL;iter_b=iter_b->Next()) {
00662             sum = sum +
00663               a1.Give_Bo2p(iter_b,a1.Give_grid(),lev) *
00664               b1.Give_Bo2p(iter_b,a1.Give_grid(),lev) +
00665               a2.Give_Bo2p(iter_b,a1.Give_grid(),lev) *
00666               b2.Give_Bo2p(iter_b,a1.Give_grid(),lev) +
00667               a3.Give_Bo2p(iter_b,a1.Give_grid(),lev) *
00668               b3.Give_Bo2p(iter_b,a1.Give_grid(),lev);
00669           }
00670         // exterior grobe Randpunkte
00671         for(color=0;color<8;++color)
00672           for(iter_n=a1.Give_grid()->Start_P_exteri(lev,color);
00673               iter_n!=NULL;iter_n=iter_n->Next()) {
00674             sum = sum + 
00675               a1.Give_nearb(iter_n,a1.Give_grid(),0.0,lev) *
00676               b1.Give_nearb(iter_n,a1.Give_grid(),0.0,lev) +
00677               a2.Give_nearb(iter_n,a1.Give_grid(),0.0,lev) *
00678               b2.Give_nearb(iter_n,a1.Give_grid(),0.0,lev) +
00679               a3.Give_nearb(iter_n,a1.Give_grid(),0.0,lev) *
00680               b3.Give_nearb(iter_n,a1.Give_grid(),0.0,lev);
00681           }
00682       }
00683       else if(run_bo<false) {
00684         // Randpunkte
00685         for(color=0;color<8;++color)
00686           for(iter_b=a1.Give_grid()->Start_P_Bo2p(lev,color);
00687               iter_b!=NULL;iter_b=iter_b->Next()) {
00688             if(iter_b->Give_Label(-run_bo,a1.Give_grid())) {
00689               sum = sum +
00690                 a1.Give_Bo2p(iter_b,a1.Give_grid(),lev) *
00691                 b1.Give_Bo2p(iter_b,a1.Give_grid(),lev) +
00692                 a2.Give_Bo2p(iter_b,a1.Give_grid(),lev) *
00693                 b2.Give_Bo2p(iter_b,a1.Give_grid(),lev) +
00694                 a3.Give_Bo2p(iter_b,a1.Give_grid(),lev) *
00695                 b3.Give_Bo2p(iter_b,a1.Give_grid(),lev);
00696             }
00697           }
00698         // exterior grobe Randpunkte
00699         for(color=0;color<8;++color)
00700           for(iter_n=a1.Give_grid()->Start_P_exteri(lev,color);
00701               iter_n!=NULL;iter_n=iter_n->Next()) {
00702             if(iter_n->Give_Label(-run_bo,lev,a1.Give_grid())) {
00703               sum = sum + 
00704                 a1.Give_nearb(iter_n,a1.Give_grid(),0.0,lev) *
00705                 b1.Give_nearb(iter_n,a1.Give_grid(),0.0,lev) +
00706                 a2.Give_nearb(iter_n,a1.Give_grid(),0.0,lev) *
00707                 b2.Give_nearb(iter_n,a1.Give_grid(),0.0,lev) +
00708                 a3.Give_nearb(iter_n,a1.Give_grid(),0.0,lev) *
00709                 b3.Give_nearb(iter_n,a1.Give_grid(),0.0,lev);
00710             }
00711           }
00712       }
00713       a1.Give_grid()->Stop_calc_time_nearbb();
00714   }
00715   MPI_Allreduce(&sum,&total_sum,1,MPI_DOUBLE,MPI_SUM,
00716                 a1.Give_grid()->Give_comm());
00717 
00718   return total_sum;
00719 }
00720 
00722 // 3.: Print
00724 
00725 void Print_UCD(Variable& a, ofstream *Datei) {
00726   if(parallel_version) {
00727     if(a.Level() == a.Give_grid()->Max_level())
00728       Print_UCD_parallel(a, Datei);
00729     else
00730       Print_UCD_parallel(a, Datei, a.Level());
00731   }
00732   else {
00733     if(a.Level() == a.Give_grid()->Max_level())
00734       a.Give_grid()->Print_Variable_AVS(Datei,a.Number_variable());
00735     else 
00736       a.Give_grid()->Print_Variable_AVS_coarse(Datei,a.Number_variable(),
00737                                                a.Level());
00738   }
00739 };
00740 
00741 void Print_UCD_parallel(Variable& a, ofstream *Datei) {
00742   Grid *grid;
00743   int array_num[1];
00744   array_num[0] = a.Number_variable();
00745 
00746   grid = a.Give_grid();
00747   
00748   grid->Update_Variable(Wdir,array_num,1,grid->Max_level());
00749   grid->Update_Variable(Edir,array_num,1,grid->Max_level());
00750   grid->Update_Variable(Ndir,array_num,1,grid->Max_level());
00751   grid->Update_Variable(Sdir,array_num,1,grid->Max_level());
00752   grid->Update_Variable(Tdir,array_num,1,grid->Max_level());
00753   grid->Update_Variable(Ddir,array_num,1,grid->Max_level());
00754   
00755   grid->Print_Variable_AVS_parallel(Datei,a.Number_variable());
00756 };
00757 
00758 void Print_UCD_parallel(Variable& a, ofstream *Datei, int level) {
00759   Grid *grid;
00760   int array_num[1];
00761   array_num[0] = a.Number_variable();
00762 
00763   grid = a.Give_grid();
00764   grid->Update_Variable(Wdir,array_num,1,level);
00765   grid->Update_Variable(Edir,array_num,1,level);
00766   grid->Update_Variable(Ndir,array_num,1,level);
00767   grid->Update_Variable(Sdir,array_num,1,level);
00768   grid->Update_Variable(Tdir,array_num,1,level);
00769   grid->Update_Variable(Ddir,array_num,1,level);
00770 
00771   a.Give_grid()->Print_Variable_AVS_parallel(Datei,a.Number_variable(),level);
00772 };
00773 
00774 void Print_UCD_surface_parallel(Variable& a, ofstream *Datei) {
00775   Grid *grid;
00776   int array_num[1];
00777   array_num[0] = a.Number_variable();
00778 
00779   grid = a.Give_grid();
00780   grid->Update_Variable(Wdir,array_num,1,grid->Max_level());
00781   grid->Update_Variable(Edir,array_num,1,grid->Max_level());
00782   grid->Update_Variable(Ndir,array_num,1,grid->Max_level());
00783   grid->Update_Variable(Sdir,array_num,1,grid->Max_level());
00784   grid->Update_Variable(Tdir,array_num,1,grid->Max_level());
00785   grid->Update_Variable(Ddir,array_num,1,grid->Max_level());
00786 
00787   a.Give_grid()->Print_surface_Variable_AVS_parallel(Datei,a.Number_variable());
00788 };
00789 
00790 void Print_UCD(Variable& a, Variable& b, Variable& c, ofstream *Datei) {
00791   if(parallel_version) {
00792     Print_UCD_parallel(a,b,c,Datei);
00793   }
00794   else {
00795     a.Give_grid()->Print_Variable_AVS(Datei,
00796                                       a.Number_variable(),
00797                                       b.Number_variable(),
00798                                       c.Number_variable());
00799   }
00800 };
00801 
00802 void Print_UCD_parallel(Variable& a, Variable& b, Variable& c,
00803                         ofstream *Datei) {
00804   Grid *grid;
00805   int array_num[3];
00806   array_num[0] = a.Number_variable();
00807   array_num[1] = b.Number_variable();
00808   array_num[2] = c.Number_variable();
00809 
00810   grid = a.Give_grid();
00811   grid->Update_Variable(Wdir,array_num,3,grid->Max_level());
00812   grid->Update_Variable(Edir,array_num,3,grid->Max_level());
00813   grid->Update_Variable(Ndir,array_num,3,grid->Max_level());
00814   grid->Update_Variable(Sdir,array_num,3,grid->Max_level());
00815   grid->Update_Variable(Tdir,array_num,3,grid->Max_level());
00816   grid->Update_Variable(Ddir,array_num,3,grid->Max_level());
00817 
00818   a.Give_grid()->Print_Variable_AVS_parallel(Datei,
00819                                              a.Number_variable(),
00820                                              b.Number_variable(),
00821                                              c.Number_variable());
00822 };
00823 
00824 void Print_UCD_moved(Variable& v,
00825                      Variable& a, Variable& b, Variable& c, ofstream *Datei) {
00826   if(parallel_version) {
00827     Print_UCD_moved_parallel(v, a, b, c, Datei);
00828   }
00829   else {
00830     a.Give_grid()->Print_Variable_AVS_moved(Datei,
00831                                             v.Number_variable(),
00832                                             a.Number_variable(),
00833                                             b.Number_variable(),
00834                                             c.Number_variable());
00835   }
00836 }
00837 
00838 void Print_UCD_moved_parallel(Variable& v,
00839                      Variable& a, Variable& b, Variable& c, ofstream *Datei) {
00840   Grid *grid;
00841   int array_num[4];
00842   array_num[0] = a.Number_variable();
00843   array_num[1] = b.Number_variable();
00844   array_num[2] = c.Number_variable();
00845   array_num[3] = v.Number_variable();
00846 
00847   grid = v.Give_grid();
00848   grid->Update_Variable(Wdir,array_num,4,grid->Max_level());
00849   grid->Update_Variable(Edir,array_num,4,grid->Max_level());
00850   grid->Update_Variable(Ndir,array_num,4,grid->Max_level());
00851   grid->Update_Variable(Sdir,array_num,4,grid->Max_level());
00852   grid->Update_Variable(Tdir,array_num,4,grid->Max_level());
00853   grid->Update_Variable(Ddir,array_num,4,grid->Max_level());
00854 
00855   a.Give_grid()->Print_Variable_AVS_moved_parallel(Datei,
00856                                                    v.Number_variable(),
00857                                                    a.Number_variable(),
00858                                                    b.Number_variable(),
00859                                                    c.Number_variable());
00860 }
00861 
00862 void Print_Gnuplot_moved(Variable& a, Variable& b, Variable& c,
00863                              ofstream *Datei) {
00864   a.Give_grid()->Print_Grid_Gnuplot_moved(Datei,
00865                                           a.Number_variable(),
00866                                           b.Number_variable(),
00867                                           c.Number_variable());
00868 }
00869 
00870 
00871 void Print_Dx_parallel(Variable& a, ofstream *Datei) {
00872   a.Give_grid()->Print_Variable_OpenDx_parallel(Datei,a.Number_variable());
00873 };
00874 
00875 
00876 void Print_Dx(Variable& a, ofstream *Datei) {
00877   if(parallel_version) {
00878     Print_Dx_parallel(a,Datei);
00879   }
00880   else {
00881     a.Give_grid()->Print_Variable_OpenDx(Datei,a.Number_variable());
00882   }
00883 };
00884 
00885 
00886 void Print_Dx_moved(Variable& v,
00887                      Variable& a, Variable& b, Variable& c, ofstream *Datei) {
00888   if(parallel_version) {
00889     cout << " Error: No parallel version for Print_Dx_moved !" << endl;
00890   }
00891   a.Give_grid()->Print_Variable_OpenDx_moved(Datei,
00892                                           v.Number_variable(),
00893                                           a.Number_variable(),
00894                                           b.Number_variable(),
00895                                           c.Number_variable());
00896 }
00897 
00898 void Print(Variable& v) {
00899   bool run; 
00900   int color;
00901   int run_bo;
00902   int lev;
00903   P_interior *iter_i;
00904   P_nearb    *iter_n;
00905   P_Bo2p     *iter_b;
00906   P_cellpoi  *iter_cf;
00907   P_parallel *iter_pa;
00908 
00909   int my_rank;
00910    MPI_Comm_rank(v.Give_grid()->Give_comm(), &my_rank);
00911                          
00912   v.Test_init();  // Grid storage initialization
00913   lev = v.Level();
00914   if(lev < 0)          { cout << "\n Level too coarse! "   << endl; }
00915   else if (lev > v.Max_Level())  { cout << "\n Level too fine! " << endl; }
00916   else { // Start
00917     run = v.run_interior();
00918       if(run) {
00919         MPI_Barrier(v.Give_grid()->Give_comm());
00920         if(my_rank==0) cout << " interior points: " << endl;
00921         MPI_Barrier(v.Give_grid()->Give_comm());
00922         // innere Punkte
00923         v.Give_grid()->Start_calc_time_interior();
00924         for(color=0;color<8;++color)
00925           for(iter_i=v.Give_grid()->Start_P_interior(lev,color);
00926               iter_i!=NULL;iter_i=iter_i->Next()) {
00927           cout << "at point: "; 
00928           iter_i->coordinate(v.Give_grid()).Print();
00929           cout << v.Give_interior_simple(iter_i,v.Give_grid(),lev) << endl;
00930         }
00931         MPI_Barrier(v.Give_grid()->Give_comm());
00932         if(my_rank==0) cout << " points in a boundary cell: " << endl;
00933         MPI_Barrier(v.Give_grid()->Give_comm());
00934         // Randzellfreiheitsgrade
00935         v.Give_grid()->Start_calc_time_nearbb();
00936         for(iter_cf=v.Give_grid()->Start_P_cellpoi(lev);
00937             iter_cf!=NULL;iter_cf=iter_cf->Next()) {
00938           cout << "at point: "; 
00939           iter_cf->coordinate(v.Give_grid()).Print();
00940           cout << v.Give_cellpoi(iter_cf,v.Give_grid()) << endl;
00941         }
00942       }
00943       run = v.run_nearb();
00944       if(run) {
00945         MPI_Barrier(v.Give_grid()->Give_comm());
00946         if(my_rank==0) cout << " points near the boundary: " << endl;
00947         MPI_Barrier(v.Give_grid()->Give_comm());
00948         // randnahe Punkte
00949         for(color=0;color<8;++color)
00950           for(iter_n=v.Give_grid()->Start_P_nearb(lev,color);
00951               iter_n!=NULL;iter_n=iter_n->Next()) {
00952             cout << "at point: "; 
00953             iter_n->coordinate(v.Give_grid()).Print();
00954             cout << v.Give_nearb(iter_n,v.Give_grid(),0.0,lev) << endl;
00955           }
00956       }
00957       run_bo = v.run_boundary();
00958       MPI_Barrier(v.Give_grid()->Give_comm());
00959       if(my_rank==0) cout << " boundary points: " << endl;
00960       MPI_Barrier(v.Give_grid()->Give_comm());
00961       if(run_bo==true) {
00962         // Randpunkte
00963         for(color=0;color<8;++color)
00964           for(iter_b=v.Give_grid()->Start_P_Bo2p(lev,color);
00965               iter_b!=NULL;iter_b=iter_b->Next()) {
00966             cout << "at point: "; 
00967             iter_b->coordinate(v.Give_grid()).Print();
00968             cout << v.Give_Bo2p(iter_b,v.Give_grid(),lev) << endl;
00969           }
00970       }
00971       else if(run_bo<false) {
00972         // Randpunkte
00973         for(color=0;color<8;++color)
00974           for(iter_b=v.Give_grid()->Start_P_Bo2p(lev,color);
00975               iter_b!=NULL;iter_b=iter_b->Next()) {
00976             if(iter_b->Give_Label(-run_bo,v.Give_grid())) {
00977               cout << "at point: "; 
00978               iter_b->coordinate(v.Give_grid()).Print();
00979               cout << v.Give_Bo2p(iter_b,v.Give_grid(),lev) << endl;
00980             }
00981           }
00982       }
00983 
00984       // Parallel
00985       MPI_Barrier(v.Give_grid()->Give_comm());
00986       if(my_rank==0) cout << " parallel points: " << endl;
00987       MPI_Barrier(v.Give_grid()->Give_comm());
00988       for(int r=0;r<v.Give_grid()->give_number_of_processes();++r) {
00989         if(r==my_rank) {
00990           cout << " \n rank: " << r << endl;
00991           for(iter_pa=v.Give_grid()->Start_P_parallel(lev);
00992               iter_pa!=NULL;iter_pa=iter_pa->Next()) {
00993             cout << "at point: "; 
00994             iter_pa->coordinate(v.Give_grid()).Print();
00995             cout << iter_pa->varM(v.Give_grid(),lev)[v.Number_variable()] 
00996                  << endl;
00997           }
00998         }
00999         MPI_Barrier(v.Give_grid()->Give_comm());
01000       }
01001   }
01002 }
01003 
01004 
01006 // 4.: calculate normal vector
01008 
01009 void Normal_vector(Variable& vx, Variable& vy, Variable& vz) {
01010   double* h;
01011   Grid *grid;
01012   int i, num, lev, color;
01013   P_Bo2p *iter_b;
01014   BoCeData* bocedata;
01015   Tetraeder_storage* tet;
01016   D3vector normal;
01017   double weight;
01018   Index3D I;
01019 
01020   grid = vx.Give_grid();
01021   h    = new double[30];
01022   lev = grid->Max_level();
01023 
01024   // Randpunkte
01025   for(color=0;color<8;++color)
01026     for(iter_b=grid->Start_P_Bo2p(lev,color);
01027         iter_b!=NULL;iter_b=iter_b->Next()) {
01028       weight = 0.0;
01029       normal = D3vector(0.0,0.0,0.0);
01030       for(i=0;i<8;++i) {    // Durchlaufen aller Nachbarzellen
01031         // Info ueber i-Randzelle
01032         bocedata = iter_b->Give_BoData((dir_sons)i);
01033         I = iter_b->Ind().next((dir_sons)i,grid->Max_level()+1);
01034         
01035         if(bocedata!=NULL) {
01036           // Calc h
01037           for(num=0;num<bocedata->Give_number_points();++num) {
01038             if(bocedata->edge_point(num)==edge_poi_typ) {
01039               h[num] = grid->Give_h(I.neighbour(bocedata->corner(num)),
01040                                     bocedata->edge_dir(num));
01041             }
01042           }
01043           for(tet=bocedata->Give_boundary_tets();tet!=NULL;tet=tet->Next()) {
01044             normal = normal + 
01045               (normal_vector_of_triangle(bocedata->coord(tet->N0(),h),
01046                                          bocedata->coord(tet->N2(),h),
01047                                          bocedata->coord(tet->N1(),h))
01048                * tet->Give_det_surface());
01049           }
01050         }
01051       }
01052       weight = norm(normal);
01053       
01054       iter_b->varM(grid)[vx.Number_variable()] = normal.x / weight;
01055       iter_b->varM(grid)[vy.Number_variable()] = normal.y / weight;
01056       iter_b->varM(grid)[vz.Number_variable()] = normal.z / weight;
01057     }
01058 
01059   vx.Active_boundary(true);
01060   vx.Active_interior(false);
01061   vx.Active_nearb(false);
01062   vx.Active_Level(grid->Max_level());   
01063 
01064   vy.Active_boundary(true);
01065   vy.Active_interior(false);
01066   vy.Active_nearb(false);
01067   vy.Active_Level(grid->Max_level());   
01068 
01069   vz.Active_boundary(true);
01070   vz.Active_interior(false);
01071   vz.Active_nearb(false);
01072   vz.Active_Level(grid->Max_level());   
01073 
01074   delete h;
01075 }
01076 
01077 
01078 
01080 // 5.: member functions
01082 
01083 
01084 Variable::Variable(Grid* gridp) {
01085   grid = NULL;
01086   Initialize(gridp);
01087 }
01088 
01089 Variable::Variable() {
01090   grid = NULL;
01091   number_variable = 0;
01092   level = 0;
01093   r_interior = true;
01094   r_boundary = true;
01095   r_nearb = true;
01096 }
01097 
01098 void Variable::Initialize(Grid* gridp) {
01099   if(grid!=NULL) 
01100     cout << " Error in Initialize. Variable is initialized! " << endl;
01101   grid = gridp;
01102   number_variable = grid->Give_number_variable();
01103   // all points of finest level become active
01104   level = gridp->Max_level();
01105   r_interior = true;
01106   r_boundary = true;
01107   r_nearb = true;
01108   if(gridp->Is_storage_initialized()==true) {
01109     cout << " \n Definition of variable not possible! ";
01110     cout << " \n Define Res_stencil_boundary before ";
01111     cout << " initialization of the grid! " << endl;
01112   }
01113 }
01114 
01115 
01116 void Variable::operator=(const Variable &v) {
01117   bool run; 
01118   int color;
01119   int  run_bo;
01120   int lev;
01121   double *vars;
01122 
01123   Test_init();  // Grid storage initialization
01124   lev = v.Level();
01125   if(lev < 0)          { cout << "\n Level too coarse! "   << endl; }
01126   else if (lev > Max_Level())  { cout << "\n Level too fine! " << endl; }
01127 
01128   if(grid->I_am_active()) {
01129     // for update type
01130     if(parallel_version) {
01131       grid->Set_type_of_update(number_variable,lev,no_update);
01132     }
01133     
01134     run = v.run_interior();
01135     if(run) {
01136       // innere Punkte
01137       for(color=0;color<8;++color)
01138         for(iter_i=grid->Start_P_interior(lev,color);
01139             iter_i!=NULL;iter_i=iter_i->Next()) {
01140           vars = iter_i->varM(grid,lev);
01141           vars[number_variable] = vars[v.Number_variable()];
01142         }
01143     }
01144     Active_interior(run);
01145     run = v.run_nearb();
01146     if(run) {
01147       // Randzellfreiheitsgrade
01148       for(iter_cf=grid->Start_P_cellpoi(lev);
01149           iter_cf!=NULL;iter_cf=iter_cf->Next()) {
01150         vars = iter_cf->varM(grid);
01151         vars[number_variable] = vars[v.Number_variable()];
01152       }
01153       // randnahe Punkte
01154       for(color=0;color<8;++color)
01155         for(iter_n=grid->Start_P_nearb(lev,color);
01156             iter_n!=NULL;iter_n=iter_n->Next()) {
01157           vars = iter_n->varM(grid,lev);
01158           vars[number_variable] = vars[v.Number_variable()];
01159         } 
01160     }
01161     Active_nearb(run);
01162     run_bo = v.run_boundary();
01163     if(run_bo==true) {
01164       // Randpunkte
01165       for(color=0;color<8;++color)
01166         for(iter_b=grid->Start_P_Bo2p(lev,color);
01167             iter_b!=NULL;iter_b=iter_b->Next()) {
01168           vars = iter_b->varM(grid);
01169           vars[number_variable] = vars[v.Number_variable()];
01170         }
01171       // exterior grobe Randpunkte
01172       for(color=0;color<8;++color)
01173         for(iter_n=grid->Start_P_exteri(lev,color);
01174             iter_n!=NULL;iter_n=iter_n->Next()) {
01175           vars = iter_n->varM(grid,lev);
01176           vars[number_variable] = vars[v.Number_variable()];
01177         } 
01178     }
01179     else if(run_bo<false) {
01180       // Randpunkte
01181       for(color=0;color<8;++color)
01182         for(iter_b=grid->Start_P_Bo2p(lev,color);
01183             iter_b!=NULL;iter_b=iter_b->Next()) {
01184           if(iter_b->Give_Label(-run_bo,grid)) {      
01185             vars = iter_b->varM(grid);
01186             vars[number_variable] = vars[v.Number_variable()];
01187           }
01188         }
01189       // exterior grobe Randpunkte
01190       for(color=0;color<8;++color)
01191         for(iter_n=grid->Start_P_exteri(lev,color);
01192             iter_n!=NULL;iter_n=iter_n->Next()) {
01193           if(iter_n->Give_Label(-run_bo,lev,v.Give_grid())) {
01194             vars = iter_n->varM(grid,lev);
01195             vars[number_variable] = vars[v.Number_variable()];
01196           }
01197         }
01198     }
01199     Active_boundary(run_bo);
01200     Active_Level(lev);   
01201   }
01202 }
01203 
01204 
01205 
01206 
01207 void Variable::operator=(double (*Formula)(double x,double y,double z)) {
01208   D3vector V;
01209   int color;
01210   Test_init();  // Grid storage initialization
01211 
01212   if(grid->I_am_active()) {
01213     // for update type
01214     if(parallel_version) {
01215       grid->Set_type_of_update(number_variable,level,no_update);
01216     }
01217     
01218     if(r_interior) {
01219       // innere Punkte
01220       for(color=0;color<8;++color)
01221         for(iter_i=grid->Start_P_interior(level,color);
01222             iter_i!=NULL;iter_i=iter_i->Next()) {
01223           V = iter_i->coordinate(grid);
01224           iter_i->varM(grid,level)[number_variable] = 
01225             Formula(V.x,V.y,V.z);
01226         }
01227     }
01228     if(r_nearb) {
01229       // Randzellfreiheitsgrade
01230       for(iter_cf=grid->Start_P_cellpoi(level);
01231           iter_cf!=NULL;iter_cf=iter_cf->Next()) {
01232         V = iter_cf->coordinate(grid);
01233         iter_cf->varM(grid)[number_variable] = 
01234           Formula(V.x,V.y,V.z);
01235       }
01236       // randnahe Punkte
01237       for(color=0;color<8;++color)
01238         for(iter_n=grid->Start_P_nearb(level,color);
01239             iter_n!=NULL;iter_n=iter_n->Next()) {
01240           V = iter_n->coordinate(grid);
01241           iter_n->varM(grid,level)[number_variable] = 
01242             Formula(V.x,V.y,V.z);
01243         }
01244     }
01245     
01246     if(r_boundary==true) {
01247       // Randpunkte
01248       for(color=0;color<8;++color)
01249         for(iter_b=grid->Start_P_Bo2p(level,color);
01250             iter_b!=NULL;iter_b=iter_b->Next()) {
01251           V = iter_b->coordinate(grid);
01252           iter_b->varM(grid)[number_variable] = 
01253             Formula(V.x,V.y,V.z);
01254         }
01255       // exterior grobe Randpunkte
01256       for(color=0;color<8;++color)
01257         for(iter_n=grid->Start_P_exteri(level,color);
01258             iter_n!=NULL;iter_n=iter_n->Next()) {
01259           V = iter_n->coordinate(grid);
01260           iter_n->varM(grid,level)[number_variable] = 
01261             Formula(V.x,V.y,V.z);
01262         }
01263     }
01264     else if(r_boundary < false) {
01265       // Randpunkte
01266       for(color=0;color<8;++color)
01267         for(iter_b=grid->Start_P_Bo2p(level,color);
01268             iter_b!=NULL;iter_b=iter_b->Next()) {
01269           if(iter_b->Give_Label(-r_boundary,grid)) {      
01270             V = iter_b->coordinate(grid);
01271             iter_b->varM(grid)[number_variable] = 
01272               Formula(V.x,V.y,V.z);
01273           }
01274         }
01275       // exterior grobe Randpunkte
01276       for(color=0;color<8;++color)
01277         for(iter_n=grid->Start_P_exteri(level,color);
01278             iter_n!=NULL;iter_n=iter_n->Next()) {
01279           if(iter_n->Give_Label(-r_boundary,level,grid)) {
01280             V = iter_n->coordinate(grid);
01281             iter_n->varM(grid,level)[number_variable] = 
01282               Formula(V.x,V.y,V.z);
01283           }
01284         }
01285     }
01286   }
01287 }
01288 
01289 
01290 void Variable::operator=(Input_data_object& input_object) {
01291   D3vector V;
01292   int color;
01293   Test_init();  // Grid storage initialization
01294 
01295   if(grid->I_am_active()) {
01296     // for update type
01297     if(parallel_version) {
01298       grid->Set_type_of_update(number_variable,level,no_update);
01299     }
01300     
01301     if(r_interior) {
01302       // innere Punkte
01303       for(color=0;color<8;++color)
01304         for(iter_i=grid->Start_P_interior(level,color);
01305             iter_i!=NULL;iter_i=iter_i->Next()) {
01306           V = iter_i->coordinate(grid);
01307           iter_i->varM(grid,level)[number_variable] = 
01308             input_object.Interpolate_value(V);
01309         }
01310     }
01311     if(r_nearb) {
01312       // Randzellfreiheitsgrade
01313       for(iter_cf=grid->Start_P_cellpoi(level);
01314           iter_cf!=NULL;iter_cf=iter_cf->Next()) {
01315         V = iter_cf->coordinate(grid);
01316         iter_cf->varM(grid)[number_variable] = 
01317           input_object.Interpolate_value(V);
01318       }
01319       // randnahe Punkte
01320       for(color=0;color<8;++color)
01321         for(iter_n=grid->Start_P_nearb(level,color);
01322             iter_n!=NULL;iter_n=iter_n->Next()) {
01323           V = iter_n->coordinate(grid);
01324           iter_n->varM(grid,level)[number_variable] = 
01325             input_object.Interpolate_value(V);
01326         }
01327     }
01328     
01329     if(r_boundary==true) {
01330       // Randpunkte
01331       for(color=0;color<8;++color)
01332         for(iter_b=grid->Start_P_Bo2p(level,color);
01333             iter_b!=NULL;iter_b=iter_b->Next()) {
01334           V = iter_b->coordinate(grid);
01335           iter_b->varM(grid)[number_variable] = 
01336             input_object.Interpolate_value(V);
01337         }
01338       // exterior grobe Randpunkte
01339       for(color=0;color<8;++color)
01340         for(iter_n=grid->Start_P_exteri(level,color);
01341             iter_n!=NULL;iter_n=iter_n->Next()) {
01342           V = iter_n->coordinate(grid);
01343           iter_n->varM(grid,level)[number_variable] = 
01344             input_object.Interpolate_value(V);
01345         }
01346     }
01347     else if(r_boundary < false) {
01348       // Randpunkte
01349       for(color=0;color<8;++color)
01350         for(iter_b=grid->Start_P_Bo2p(level,color);
01351             iter_b!=NULL;iter_b=iter_b->Next()) {
01352           if(iter_b->Give_Label(-r_boundary,grid)) {      
01353             V = iter_b->coordinate(grid);
01354             iter_b->varM(grid)[number_variable] = 
01355               input_object.Interpolate_value(V);
01356           }
01357         }
01358       // exterior grobe Randpunkte
01359       for(color=0;color<8;++color)
01360         for(iter_n=grid->Start_P_exteri(level,color);
01361             iter_n!=NULL;iter_n=iter_n->Next()) {
01362           if(iter_n->Give_Label(-r_boundary,level,grid)) {
01363             V = iter_n->coordinate(grid);
01364             iter_n->varM(grid,level)[number_variable] = 
01365               input_object.Interpolate_value(V);
01366           }
01367         }
01368     }
01369   }
01370 }
01371 
01372 
01373 
01374 
01375 void Variable::operator=(const FunctionClass& function) {
01376   D3vector V;
01377   int run_bo;
01378   int color;
01379   Test_init();  // Grid storage initialization
01380 
01381   if(grid->I_am_active()) {
01382     // for update type
01383     if(parallel_version) {
01384       grid->Set_type_of_update(number_variable,level,no_update);
01385     }
01386     
01387     if(function.run_interior()) {
01388       // innere Punkte
01389       for(color=0;color<8;++color)
01390         for(iter_i=grid->Start_P_interior(level,color);
01391             iter_i!=NULL;iter_i=iter_i->Next()) {
01392           V = iter_i->coordinate(grid);
01393           iter_i->varM(grid,level)[number_variable] = 
01394             function.Formula(V.x,V.y,V.z);
01395         }
01396     }
01397     Active_interior(function.run_interior());
01398     if(function.run_nearb()) {
01399       // Randzellfreiheitsgrade
01400       for(iter_cf=grid->Start_P_cellpoi(level);
01401           iter_cf!=NULL;iter_cf=iter_cf->Next()) {
01402         V = iter_cf->coordinate(grid);
01403         iter_cf->varM(grid)[number_variable] = 
01404           function.Formula(V.x,V.y,V.z);
01405       }
01406       // randnahe Punkte
01407       for(color=0;color<8;++color)
01408         for(iter_n=grid->Start_P_nearb(level,color);
01409             iter_n!=NULL;iter_n=iter_n->Next()) {
01410           V = iter_n->coordinate(grid);
01411           iter_n->varM(grid,level)[number_variable] = 
01412             function.Formula(V.x,V.y,V.z);
01413         }
01414     }
01415     Active_nearb(function.run_nearb());
01416     
01417     run_bo = function.run_boundary();
01418     if(run_bo==true) {
01419       // Randpunkte
01420       for(color=0;color<8;++color)
01421         for(iter_b=grid->Start_P_Bo2p(level,color);
01422             iter_b!=NULL;iter_b=iter_b->Next()) {
01423           V = iter_b->coordinate(grid);
01424           iter_b->varM(grid)[number_variable] = 
01425             function.Formula(V.x,V.y,V.z);
01426         }
01427       // exterior grobe Randpunkte
01428        for(color=0;color<8;++color)
01429         for(iter_n=grid->Start_P_exteri(level,color);
01430             iter_n!=NULL;iter_n=iter_n->Next()) {
01431           V = iter_n->coordinate(grid);
01432           iter_n->varM(grid,level)[number_variable] = 
01433             function.Formula(V.x,V.y,V.z);
01434         }
01435     }
01436     else if(run_bo<false) {
01437       // Randpunkte
01438       for(color=0;color<8;++color)
01439         for(iter_b=grid->Start_P_Bo2p(level,color);
01440             iter_b!=NULL;iter_b=iter_b->Next()) {
01441           if(iter_b->Give_Label(-run_bo,grid)) {     
01442             V = iter_b->coordinate(grid);
01443             iter_b->varM(grid)[number_variable] = 
01444               function.Formula(V.x,V.y,V.z);
01445           }
01446         }
01447       // exterior grobe Randpunkte
01448       for(color=0;color<8;++color)
01449         for(iter_n=grid->Start_P_exteri(level,color);
01450             iter_n!=NULL;iter_n=iter_n->Next()) {
01451           if(iter_n->Give_Label(-run_bo,level,grid)) {
01452             V = iter_n->coordinate(grid);
01453             iter_n->varM(grid,level)[number_variable] = 
01454               function.Formula(V.x,V.y,V.z);
01455           }
01456         }
01457     }
01458     Active_boundary(function.run_boundary());
01459   }
01460 }
01461 
01462 void Variable::operator= (double x) {
01463   Test_init();  // Grid storage initialization
01464   int color;
01465 
01466   if(grid->I_am_active()) {
01467     // for update type
01468     if(parallel_version) {
01469       grid->Set_type_of_update(number_variable,level,no_update);
01470       //      grid->Set_type_of_update(number_variable,level,full_update);
01471     }
01472 
01473     if(r_interior) {
01474       // innere Punkte
01475       for(color=0;color<8;++color)
01476         // for(color=scco;color==scco;++color)
01477         for(iter_i=grid->Start_P_interior(level,color);
01478             iter_i!=NULL;iter_i=iter_i->Next()) {
01479           iter_i->varM(grid,level)[number_variable] = x;
01480         }
01481     }
01482     if(r_nearb) {
01483       // Randzellfreiheitsgrade
01484       for(iter_cf=grid->Start_P_cellpoi(level);
01485           iter_cf!=NULL;iter_cf=iter_cf->Next()) {
01486         iter_cf->varM(grid)[number_variable] = x;
01487       }
01488       // randnahe Punkte
01489       for(color=0;color<8;++color)
01490         // for(color=scco;color==scco;++color)
01491         for(iter_n=grid->Start_P_nearb(level,color);
01492             iter_n!=NULL;iter_n=iter_n->Next()) {
01493           iter_n->varM(grid,level)[number_variable] = x;
01494         }
01495     }
01496     if(r_boundary==true) {
01497       // Randpunkte
01498       for(color=0;color<8;++color)
01499         for(iter_b=grid->Start_P_Bo2p(level,color);
01500             iter_b!=NULL;iter_b=iter_b->Next()) {
01501           iter_b->varM(grid)[number_variable] = x;
01502         }
01503       // exterior grobe Randpunkte
01504       for(color=0;color<8;++color)
01505         for(iter_n=grid->Start_P_exteri(level,color);
01506             iter_n!=NULL;iter_n=iter_n->Next()) {
01507           iter_n->varM(grid,level)[number_variable] = x;
01508         }
01509     }
01510     else if(r_boundary<false) {
01511       // Randpunkte
01512       for(color=0;color<8;++color)
01513         for(iter_b=grid->Start_P_Bo2p(level,color);
01514             iter_b!=NULL;iter_b=iter_b->Next()) {
01515           if(iter_b->Give_Label(-r_boundary,grid)) {     
01516             iter_b->varM(grid)[number_variable] = x;
01517           }
01518         }
01519       // exterior grobe Randpunkte
01520       for(color=0;color<8;++color)
01521         for(iter_n=grid->Start_P_exteri(level,color);
01522             iter_n!=NULL;iter_n=iter_n->Next()) {
01523           if(iter_n->Give_Label(-r_boundary,level,grid)) {
01524             iter_n->varM(grid,level)[number_variable] = x;
01525           }
01526         }
01527     }
01528   }
01529 }
01531 //  Parallel Ghost nodes
01533 
01534 void Sum_ghost_nodes(Variable& v) {
01535   if(parallel_version) {
01536     Grid* grid;
01537     grid = v.Give_grid();
01538     int array_num[1];
01539     array_num[0] = v.Number_variable();
01540     grid->Sum_ghost_nodes_Variable(array_num,1,grid->Max_level());
01541   }
01542 }
01543 
01544 void Update_ghost_nodes(Variable& v) {
01545   if(parallel_version) {
01546     Grid* grid;
01547     grid = v.Give_grid();
01548     int array_num[1];
01549     array_num[0] = v.Number_variable();
01550     
01551     for(int d=0;d<26;++d)
01552       grid->Update_Variable(d,array_num,1,grid->Max_level());
01553   }
01554 }

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