src/expde/grid/p_opendx.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 //
00019 // p_OpenDx.cc
00020 //
00021 // ------------------------------------------------------------
00022 
00024 // for OpenDx
00026 
00027 
00028 // Include level 0:
00029 #ifdef COMP_GNUOLD
00030  #include <iostream.h>
00031  #include <fstream.h>
00032  #include <time.h>
00033  #include <math.h>
00034 #else
00035  #include <iostream>
00036  #include <fstream>
00037  #include <ctime>
00038  #include <cmath>
00039 #endif 
00040 
00041   
00042 // Include level 0:
00043 #include "../parser.h"
00044 
00045 // Include level 1:
00046 #include "../paramete.h"
00047 #include "../abbrevi.h"
00048 #include "../math_lib/math_lib.h"
00049  
00050 // Include level 2:
00051 #include "../basic/basic.h"
00052 
00053 // Include level 3:
00054 #include "../domain/domain.h"
00055 
00056 // Include level 4:
00057 #include "../formulas/boundy.h"
00058 #include "../formulas/loc_sten.h"
00059 
00060 // Include level 5:
00061 #include "gpar.h"
00062 #include "parallel.h"
00063 #include "mgcoeff.h"
00064 #include "sto_man.h"
00065 #include "gridbase.h"
00066 #include "grid.h"
00067 
00069 // a)  for AVS
00071 
00072 void Grid_base::Print_ec_opendx(IndexBo indexbo_A, IndexBo indexbo_B,
00073                                    ofstream *Datei, int number) {
00074   *Datei << number << "  1  line  ";
00075   *Datei << hashtable3_point(indexbo_A)->nummer  << "  ";
00076   *Datei << hashtable3_point(indexbo_B)->nummer  << "  ";
00077   *Datei << endl; 
00078 }
00079 
00080 // Ausgabe der Tetraeder
00081 int Grid_base::opendx_bo_cell(BoCell* bo,ofstream *datei,bool print_or_calc, 
00082                            int number) {
00083   Tetraeder_storage* tets;
00084   int num;
00085   Index3D I;
00086   Cell_type_points typ;
00087 
00088 #ifdef PERIODIC
00089   if(bo->Give_Index().neighbour_non_periodic(WSDd).Is_non_periodic()) {
00090     return number;
00091   }
00092 #endif
00093 
00094 
00095   if(print_or_calc==false) {
00096     for(tets = bo->Give_tets();tets!=NULL;tets = tets->Next()) {
00097       number++;
00098     }
00099   }
00100   else {
00101     I = bo->Give_Index();
00102 
00103     for(tets = bo->Give_tets();tets!=NULL;tets = tets->Next()) {
00104       ++number; 
00105       // Punkt 0:
00106       num = tets->N0();
00107       typ = bo->edge_point(num);
00108       if(typ==edge_poi_typ) {
00109         *datei << Give_Nummer(I.neighbour(bo->corner(num)),
00110                               bo->edge_dir(num)) << "  ";
00111       }
00112       if(typ==corner_poi_typ) {
00113         *datei << Give_Nummer(I.neighbour(bo->corner(num)))
00114                << "  "; 
00115       }
00116       if(typ==cell_poi_typ) {
00117         *datei << Give_Nummer_cellpoi(I) << "  ";       
00118       }
00119       // Punkt 1:
00120       num = tets->N1();
00121       typ = bo->edge_point(num);
00122       if(typ==edge_poi_typ) {
00123         *datei << Give_Nummer(I.neighbour(bo->corner(num)),
00124                               bo->edge_dir(num)) << "  ";
00125       }
00126       if(typ==corner_poi_typ) {
00127         *datei << Give_Nummer(I.neighbour(bo->corner(num)))
00128                << "  "; 
00129       }
00130       if(typ==cell_poi_typ) {
00131         *datei << Give_Nummer_cellpoi(I) << "  ";       
00132       }
00133       // Punkt 2:
00134       num = tets->N2();
00135       typ = bo->edge_point(num);
00136       if(typ==edge_poi_typ) {
00137         *datei << Give_Nummer(I.neighbour(bo->corner(num)),
00138                               bo->edge_dir(num)) << "  ";
00139       }
00140       if(typ==corner_poi_typ) {
00141         *datei << Give_Nummer(I.neighbour(bo->corner(num)))
00142                << "  "; 
00143       }
00144       if(typ==cell_poi_typ) {
00145         *datei << Give_Nummer_cellpoi(I) << "  ";       
00146       }
00147       // Punkt 3:
00148       num = tets->N3();
00149       typ = bo->edge_point(num);
00150       if(typ==edge_poi_typ) {
00151         *datei << Give_Nummer(I.neighbour(bo->corner(num)),
00152                               bo->edge_dir(num)) << "  ";
00153       }
00154       if(typ==corner_poi_typ) {
00155         *datei << Give_Nummer(I.neighbour(bo->corner(num)))
00156                << "  "; 
00157       }
00158       if(typ==cell_poi_typ) {
00159         *datei << Give_Nummer_cellpoi(I) << "  ";       
00160       }
00161       *datei << endl;
00162     }
00163   }
00164   return number;
00165 }
00166 
00167 
00168 
00169 int Grid_base::Recursion_Cells_OPENDX(Index3D I, ofstream *Datei, int nummer) {
00170   int i;
00171   Index3D Ison;
00172   for(i=0;i<8;++i) {
00173     if(Exists_Point(I.son((dir_sons)i)))
00174       nummer = Recursion_Cells_OPENDX(I.son((dir_sons)i),Datei,nummer);
00175     else {
00176       Ison = I.son((dir_sons)i);
00177 
00178      // periodic
00179 #ifdef PERIODIC
00180       if(Ison.neighbour_non_periodic(WSDd).Is_non_periodic()
00181          && Give_cell_typ(Ison) == int_cell) {
00182 #else
00183       if(Give_cell_typ(Ison) == int_cell) {
00184 #endif
00185         nummer++;
00186 
00187         // 0. Tet: WND, WNT, WST, EST 
00188         *Datei << Give_Nummer(Ison.neighbour(WNTd))  << "  ";
00189         *Datei << Give_Nummer(Ison.neighbour(WNDd))  << "  ";
00190         *Datei << Give_Nummer(Ison.neighbour(WSTd))  << "  ";
00191         *Datei << Give_Nummer(Ison.neighbour(ESTd))  << "  ";
00192         *Datei << "\n";
00193         
00194         nummer++;
00195         // 1. Tet: EST, WND, WST, ESD  
00196         *Datei << Give_Nummer(Ison.neighbour(ESTd))  << "  ";
00197         *Datei << Give_Nummer(Ison.neighbour(WNDd))  << "  ";
00198         *Datei << Give_Nummer(Ison.neighbour(WSTd))  << "  ";
00199         *Datei << Give_Nummer(Ison.neighbour(ESDd))  << "  ";
00200         *Datei << "\n";
00201         
00202         nummer++;
00203         // 2. Tet: WND, WSD, WST, ESD        
00204         *Datei << Give_Nummer(Ison.neighbour(WNDd))  << "  ";
00205         *Datei << Give_Nummer(Ison.neighbour(WSDd))  << "  ";
00206         *Datei << Give_Nummer(Ison.neighbour(WSTd))  << "  ";
00207         *Datei << Give_Nummer(Ison.neighbour(ESDd))  << "  ";
00208         *Datei << "\n";
00209         
00210         nummer++;
00211         // 3. Tet: EST, WND, ESD, END
00212         *Datei << Give_Nummer(Ison.neighbour(ESTd))  << "  ";
00213         *Datei << Give_Nummer(Ison.neighbour(WNDd))  << "  ";
00214         *Datei << Give_Nummer(Ison.neighbour(ESDd))  << "  ";
00215         *Datei << Give_Nummer(Ison.neighbour(ENDd))  << "  ";
00216         *Datei << "\n";
00217         
00218         nummer++;
00219         // 4. Tet: ENT, WNT, EST, END
00220         *Datei << Give_Nummer(Ison.neighbour(ENTd))  << "  ";
00221         *Datei << Give_Nummer(Ison.neighbour(WNTd))  << "  ";
00222         *Datei << Give_Nummer(Ison.neighbour(ESTd))  << "  ";
00223         *Datei << Give_Nummer(Ison.neighbour(ENDd))  << "  ";
00224         *Datei << "\n";
00225         
00226         nummer++;
00227         // 5. Tet: WNT, WND, EST, END
00228         *Datei << Give_Nummer(Ison.neighbour(WNTd))  << "  ";
00229         *Datei << Give_Nummer(Ison.neighbour(WNDd))  << "  ";
00230         *Datei << Give_Nummer(Ison.neighbour(ESTd))  << "  ";
00231         *Datei << Give_Nummer(Ison.neighbour(ENDd))  << "  ";
00232         *Datei << "\n";
00233       }
00234     }
00235   }
00236   return nummer;
00237 }
00238 
00239 
00241 // There are the main print functions
00243 void Grid_base::Print_Variable_OpenDx(ofstream *Datei, int number_var) {
00244   int number_cells, number, ebene;
00245   int number_points;
00246   Index3D ind;
00247   Pointtype typ_point;
00248 
00249   if(Is_storage_initialized()==false) { 
00250     cout << " \n Fehler in Print_Variable_OpenDx! Initialisierung fehlt! "
00251          << endl;
00252     return;
00253   }
00254   if(Give_max_num_var() <= number_var) {
00255     cout << " \n Fehler in Print_Variable_OPENDX! number_var zu gross! " << endl;
00256   }
00257   else {
00258     // Teil 0: Write information
00259     *Datei << "# File created by ExPDE " << endl;
00260     *Datei << "# dx file format for OpenDx " << endl;
00261     *Datei << "# scalar value " << endl;
00262 
00263     // Teil 1: Anzahl der Zellen zaehlen
00264     // Teil 1.1: Innerer Zellen
00265     ind = Index3D(2,2,2);
00266     number_cells = Recursion_Count_Cells(ind);
00267     // Teil 1.2: Randzellen
00268     iterate_hash2 {
00269       number_cells = opendx_bo_cell(bocell,Datei,false,number_cells);
00270     }
00271     // Teil 1.3: Anzahl der Punkte
00272     // a) innen und randnah
00273     number_points=0;
00274     iterate_hash1 {
00275       if(point1->typ >= interior) {
00276         point1->nummer = number_points;
00277         number_points++;
00278       }
00279       else point1->nummer = -1;
00280     }
00281     // b) Randpunkte
00282     iterate_hash3 {
00283       bo2point->Set_number_avs(number_points);
00284       ++number_points;
00285     }
00286     // c) Randzellfreiheitsgrad
00287     iterate_hash2 {
00288       if(bocell->Exists_bocellpoint()) {
00289         bocell->Set_number_avs(number_points);
00290         number_points++;
00291       }
00292     }
00293 
00294     // Teil 2: Koordinaten der Punkte eingeben
00295     // Teil 2.0: Header file for points
00296     *Datei << "object 1 class array type float rank 1 shape 3 items "
00297            << number_points << " data follows" << endl;
00298 
00299     // Teil 2.1 alle inneren Punkte
00300     iterate_hash1 {
00301       if(point1->nummer != -1) {
00302         *Datei << " " ;
00303         transform_coord(point1->ind.coordinate()).Print(Datei);
00304         *Datei  << "\n";
00305       }
00306     }
00307     // Teil 2.2 alle Randpunkte (Kantenpunkte)
00308     iterate_hash3 {
00309       *Datei << " " ;
00310       (bo2point->transform_coord(Give_A(),
00311                                  H_mesh())).Print(Datei);
00312       *Datei  << "\n";
00313     }
00314     // Teil 2.3 alle Randzellfreiheitsgrad
00315     iterate_hash2 {
00316       if(bocell->Exists_bocellpoint()) {
00317         *Datei << " " ;
00318         (transform_coord(bocell->ind.coordinate()) + 
00319          bocell->Local_coord_bocellpoint()).Print(Datei);
00320         *Datei  << "\n";
00321       }
00322     }
00323     // Teil 3: Zellen ausgeben
00324     // Teil 3.0: Header file for tetrahedra:
00325     *Datei << "object 2 class array type int rank 1 shape 4 items "
00326            << number_cells << " data follows" << endl;
00327     // Teil 3.1: Innere Zellen ausgeben
00328     ind = Index3D(2,2,2);
00329     number=Recursion_Cells_OPENDX(ind,Datei,0);
00330     // Teil 3.2: Randzellen
00331     iterate_hash2 {
00332       number = opendx_bo_cell(bocell,Datei,true,number);
00333     }
00334     // Teil 3.3: end for tetrahedra
00335     *Datei << "attribute " << '"' << "element type" 
00336            << '"' << " string " << '"' << "tetrahedra" << '"' << "" << endl;
00337     *Datei << "attribute " << '"' << "ref" << '"' 
00338            << " string " << '"' << "positions" << '"' << "" << endl;
00339 
00340     // Teil 4: Header file for one variable:
00341     *Datei << "object 3 class array type float rank 0 items "
00342            << number_points << " data follows" << endl;
00343     
00344     // Teil 6: Ausgabe der Werte der Variablen
00345     // Teil 6.1: Werte im Inneren
00346     iterate_hash1 {
00347       if(point1->nummer != -1) {
00348         //      *Datei << point1->nummer << "  ";
00349         typ_point = point1->typ;
00350         if(typ_point==exterior)
00351           cout << " Fehler in Print_Variable_OPENDX! " << endl;
00352         if(typ_point!=multigrid) {
00353           ebene = Give_finest_level(point1->ind);
00354           *Datei << Give_variable(point1->ind,ebene)[number_var];
00355           *Datei << "\n";
00356         }
00357         else *Datei << " 1.0 \n";
00358       }
00359     }
00360     // Teil 6.2: Werte am Rand
00361     iterate_hash3 {
00362       //  *Datei << bo2point->nummer+hashtable1_occ << "  ";
00363       *Datei << Give_variable(bo2point->ind,bo2point->direction)[number_var];
00364       *Datei << " \n";
00365     }
00366     // Teil 6.3 Werte bei Randzellfreiheitsgrad
00367     iterate_hash2 {
00368       if(bocell->Exists_bocellpoint()) {
00369         //      *Datei << bocell->Number_avs() << " " ;
00370         *Datei << bocell->Give_var()[number_var];
00371         *Datei  << "\n";
00372       }
00373     }
00374     // Teil 6.4: end variable
00375     *Datei << "attribute " 
00376            << '"' << "dep" 
00377            << '"' << " string " << '"' << "positions" << '"' << "" << endl;
00378 
00379     // Teil 7: end remarks
00380     *Datei << "object " << '"' 
00381            << "irregular positions irregular connections"
00382            << '"' << " class field" << 
00383       endl;
00384     *Datei << "component " << '"' << "positions" << '"' << " value 1" << endl;
00385     *Datei << "component " 
00386            << '"' << "connections" << '"' << " value 2" << endl;
00387     *Datei << "component " << '"' << "data" << '"' << " value 3" << endl;
00388     *Datei << "end" << endl; 
00389 
00390 //cout << " Hi: no point "; 
00391 
00392   }
00393 }
00394 
00395 
00396 
00397 
00398 void Grid_base::Print_Variable_OpenDx_moved(ofstream *Datei, int number_var,
00399                                             int number_var_a,
00400                                             int number_var_b, 
00401                                             int number_var_c) {
00402   int number_cells, number, ebene;
00403   int number_points;
00404   Index3D ind;
00405   Pointtype typ_point;
00406 
00407   if(Is_storage_initialized()==false) { 
00408     cout << 
00409       " \n Fehler in Print_Variable_OpenDx_moved! Initialisierung fehlt! "
00410          << endl;
00411     return;
00412   }
00413   if(Give_max_num_var() <= number_var) {
00414     cout << " \n Fehler in Print_Variable_OPENDX! number_var zu gross! " << endl;
00415   }
00416   else {
00417     // Teil 0: Write information
00418     *Datei << "# File created by ExPDE " << endl;
00419     *Datei << "# dx file format for OpenDx " << endl;
00420     *Datei << "# scalar value moved by a vector" << endl;
00421 
00422     // Teil 1: Anzahl der Zellen zaehlen
00423     // Teil 1.1: Innerer Zellen
00424     ind = Index3D(2,2,2);
00425     number_cells = Recursion_Count_Cells(ind);
00426     // Teil 1.2: Randzellen
00427     iterate_hash2 {
00428       number_cells = opendx_bo_cell(bocell,Datei,false,number_cells);
00429     }
00430     // Teil 1.3: Anzahl der Punkte
00431     // a) innen und randnah
00432     number_points=0;
00433     iterate_hash1 {
00434       if(point1->typ >= interior) {
00435         point1->nummer = number_points;
00436         number_points++;
00437       }
00438       else point1->nummer = -1;
00439     }
00440     // b) Randpunkte
00441     iterate_hash3 {
00442       bo2point->Set_number_avs(number_points);
00443       ++number_points;
00444     }
00445     // c) Randzellfreiheitsgrad
00446     iterate_hash2 {
00447       if(bocell->Exists_bocellpoint()) {
00448         bocell->Set_number_avs(number_points);
00449         number_points++;
00450       }
00451     }
00452     // Teil 2: Koordinaten der Punkte eingeben
00453     // Teil 2.0: Header file for points
00454     *Datei << "object 1 class array type float rank 1 shape 3 items "
00455            << number_points << " data follows" << endl;
00456 
00457     // Teil 2.1 alle inneren Punkte
00458     iterate_hash1 {
00459       if(point1->nummer != -1) {
00460         *Datei << " " ;
00461         (transform_coord(point1->ind.coordinate()) +
00462          D3vector(Give_variable(point1->ind,Max_level())[number_var_a],
00463                   Give_variable(point1->ind,Max_level())[number_var_b],
00464                   Give_variable(point1->ind,Max_level())[number_var_c])
00465          ).Print(Datei);
00466         *Datei  << "\n";
00467       }
00468     }
00469     // Teil 2.2 alle Randpunkte (Kantenpunkte)
00470     iterate_hash3 {
00471       *Datei << " " ;
00472       ((bo2point->transform_coord(Give_A(),
00473                                   H_mesh())) +
00474        D3vector(Give_variable(bo2point->ind,bo2point->direction)[number_var_a],
00475                 Give_variable(bo2point->ind,bo2point->direction)[number_var_b],
00476                 Give_variable(bo2point->ind,bo2point->direction)[number_var_c])
00477        ).Print(Datei);
00478       *Datei  << "\n";
00479     }
00480     // Teil 2.3 alle Randzellfreiheitsgrad
00481     iterate_hash2 {
00482       if(bocell->Exists_bocellpoint()) {
00483         *Datei << " " ;
00484         (transform_coord(bocell->ind.coordinate()) + 
00485          bocell->Local_coord_bocellpoint() +
00486          D3vector(bocell->Give_var()[number_var_a],
00487                   bocell->Give_var()[number_var_b],
00488                   bocell->Give_var()[number_var_c])
00489          ).Print(Datei);
00490         *Datei  << "\n";
00491       }
00492     }
00493     // Teil 3: Zellen ausgeben
00494     // Teil 3.0: Header file for tetrahedra:
00495     *Datei << "object 2 class array type int rank 1 shape 4 items "
00496            << number_cells << " data follows" << endl;
00497     // Teil 3.1: Innere Zellen ausgeben
00498     ind = Index3D(2,2,2);
00499     number=Recursion_Cells_OPENDX(ind,Datei,0);
00500     // Teil 3.2: Randzellen
00501     iterate_hash2 {
00502       number = opendx_bo_cell(bocell,Datei,true,number);
00503     }
00504     // Teil 3.3: end for tetrahedra
00505     *Datei << "attribute " << '"' << "element type" 
00506            << '"' << " string " << '"' << "tetrahedra" << '"' << "" << endl;
00507     *Datei << "attribute " << '"' << "ref" << '"' 
00508            << " string " << '"' << "positions" << '"' << "" << endl;
00509 
00510     // Teil 4: Header file for one variable:
00511     *Datei << "object 3 class array type float rank 0 items "
00512            << number_points << " data follows" << endl;
00513     
00514     // Teil 6: Ausgabe der Werte der Variablen
00515     // Teil 6.1: Werte im Inneren
00516     iterate_hash1 {
00517       if(point1->nummer != -1) {
00518         //      *Datei << point1->nummer << "  ";
00519         typ_point = point1->typ;
00520         if(typ_point==exterior)
00521           cout << " Fehler in Print_Variable_OPENDX! " << endl;
00522         if(typ_point!=multigrid) {
00523           ebene = Give_finest_level(point1->ind);
00524           *Datei << Give_variable(point1->ind,ebene)[number_var];
00525           //     *Datei << 2.0;
00526           *Datei << "\n";
00527         }
00528         else *Datei << " 1.0 \n";
00529       }
00530     }
00531     // Teil 6.2: Werte am Rand
00532     iterate_hash3 {
00533       //  *Datei << bo2point->nummer+hashtable1_occ << "  ";
00534       *Datei << Give_variable(bo2point->ind,bo2point->direction)[number_var];
00535       *Datei << " \n";
00536     }
00537     // Teil 6.3 Werte bei Randzellfreiheitsgrad
00538     iterate_hash2 {
00539       if(bocell->Exists_bocellpoint()) {
00540         //      *Datei << bocell->Number_avs() << " " ;
00541         *Datei << bocell->Give_var()[number_var];
00542         *Datei  << "\n";
00543       }
00544     }
00545     // Teil 6.4: end variable
00546     *Datei << "attribute " 
00547            << '"' << "dep" 
00548            << '"' << " string " << '"' << "positions" << '"' << "" << endl;
00549 
00550     // Teil 7: end remarks
00551     *Datei << "object " << '"' 
00552            << "irregular positions irregular connections"
00553            << '"' << " class field" << 
00554       endl;
00555     *Datei << "component " << '"' << "positions" << '"' << " value 1" << endl;
00556     *Datei << "component " 
00557            << '"' << "connections" << '"' << " value 2" << endl;
00558     *Datei << "component " << '"' << "data" << '"' << " value 3" << endl;
00559     *Datei << "end" << endl; 
00560   }
00561 }
00562 

Generated on Mon Jan 16 13:23:41 2006 for IPPL by  doxygen 1.4.6