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

src/expde/domain/domain.h

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 // domain.h
00020 //
00021 // ------------------------------------------------------------
00022 
00023 #ifndef DOMAIN_H_
00024 #define DOMAIN_H_
00025       
00027 // 1.:  basic class
00028 // 2.:  new domain
00029 // 3.:  convex domains
00030 // 4.1:  union domains
00031 // 4.2:  cut domains
00032 // 5.:  move domains
00033 // 6.:  scale domains
00034 // 7.:  operators
00035 // 8.:  member functions 
00036 // 9.:  special domain fuer Andreas  
00037 // examples: d_examp.h
00039 
00040 // 3D unit vector
00041 //-------------------
00042 inline D3vector Unit_vector(dir_3D d) {
00043   if(d>Ndir) return D3vector(0.0,0.0,d-4);
00044   if(d<Sdir) return D3vector(d,0.0,0.0);
00045   return D3vector(0.0,d-2,0.0);
00046 }
00047 
00048 
00050 // 1.:  basic class
00051 
00052 class All_Domains {
00053  public:
00054   // constructor 
00055   All_Domains() {}; 
00056   
00057   // size of minimal uniform grid (in levels) (only for error messages!!)
00058   virtual int Give_n_uniform() =0;
00059   // is it possible to calculate whether edge in domain?
00060   virtual bool calc_edge(D3vector V1, D3vector V2) =0;
00061   // is edge in domain?
00062   virtual bool edge(D3vector V1, D3vector V2) =0;
00063   //  is it possible to calculate distance to the boundary?
00064   virtual calc_dis calc_distance(D3vector V, dir_3D d) =0;
00065   // distance to the boundary in direction d
00066   virtual double distance(D3vector V, dir_3D d) =0;
00067   // is point in domain? This function should be used only 
00068   // at the beginning of the grid generation
00069   virtual bool point_in_domain(D3vector V) =0;
00070 
00071   bool Test(double x) { return 1.0; }
00072 
00073   // describtion of the square, in which the domain is contained
00074   // [a1,a1+h]x[a2,a2+h]x[a3,a3+h]
00075   virtual D3vector GiveA() const =0;
00076   virtual double   GiveH() const =0;
00077   virtual D3vector GiveVecH() const =0;
00078 
00079   // Periodoic object??
00080   virtual bool Is_periodic() =0;
00081  protected: 
00082   // for  square, in which the domain is contained
00083   D3vector A;
00084   double H;
00085   D3vector VecH;
00086   // size of minimal uniform grid (in levels)
00087   int n_uniform;
00088 
00089   // Periodoic object??
00090   bool is_periodic;
00091 
00092   // ...
00093   PointtypeD (*function)(D3vector);   // point in domain?
00094   double (*func_distance)(D3vector,dir_3D);  // distance to the boundary
00095 
00096   PointtypeD (*function_2P)(D3vector,double,double); // point in domain?
00097   double (*func_distance_2P)(D3vector,dir_3D,double,double); 
00098                                         // distance to the boundary
00099 
00100   PointtypeD (*function_4P)(D3vector,double,double,double,double); 
00101                                         // point in domain?
00102   double (*func_distance_4P)(D3vector,dir_3D,double,double,double,double); 
00103                                         // distance to the boundary
00104  
00105   All_Domains *domain_A;
00106   All_Domains *domain_B;
00107 
00108   D3vector V_move;
00109   D3vector V_scale;
00110 
00111   // for parameters:
00112   double R_down;
00113   double R_top;
00114 
00115   double R_left;
00116   double R_right;
00117 };
00118 
00120 // 2.:  new domains
00121 
00122 class Domain : public All_Domains {
00123  public:
00124   // constructor
00125   Domain(All_Domains* dom) {
00126     domain_A = dom;
00127   }
00128   Domain(Domain* dom) {
00129     domain_A = dom;
00130   }
00131   Domain(const Domain& dom) {
00132     domain_A = new Domain(dom.domain_A);
00133   }
00134 
00135   // size of minimal uniform grid (in levels)
00136   int  Give_n_uniform() { return domain_A->Give_n_uniform(); } ;
00137   // is it possible to calculate whether edge in domain?
00138   bool calc_edge(D3vector V1, D3vector V2) { return true; }
00139   // is edge in domain?
00140   bool edge(D3vector V1, D3vector V2) { return domain_A->edge(V1,V2); };
00141   //  is it possible to calculate distance to the boundary?
00142   calc_dis calc_distance(D3vector V, dir_3D d) {return yes; }
00143   // distance to the boundary in direction d
00144   double distance(D3vector V, dir_3D d) { return domain_A->distance(V,d); };
00145   // is point in domain?
00146   bool point_in_domain(D3vector V) { return domain_A->point_in_domain(V); }
00147 
00148   // Periodoic object??
00149   bool Is_periodic() { return domain_A->Is_periodic(); }
00150 
00151   // describtion of the square, in which the domain is contained
00152   D3vector GiveA()    const { return domain_A->GiveA(); }
00153   double   GiveH()    const { return domain_A->GiveH(); }
00154   D3vector GiveVecH() const { return domain_A->GiveVecH(); }
00155 };
00156 
00158 // 3.:  convex domains
00159 
00160 class Convex_domains : public All_Domains {
00161  public:
00162   // Konstruktoren, n ist fuer Parameter n_uniform 
00163   Convex_domains(PointtypeD (*f)(D3vector),
00164                  double (*fd)(D3vector,dir_3D),
00165                  int n) {
00166     function = f;
00167     func_distance = fd;
00168     A = D3vector(0.0,0.0,0.0);
00169     H = 1.0;
00170     VecH.x = 1.0;
00171     VecH.y = 1.0;
00172     VecH.z = 1.0;
00173     n_uniform = n;
00174     is_periodic = false;
00175   }
00176 
00177   // Groesse eines uniformen Grundgitters, Angabe in Levels:
00178   int  Give_n_uniform() { return n_uniform; } ;
00179   // Kann berechnet werden ob Kante im Gebiet?
00180   bool calc_edge(D3vector V1, D3vector V2) { return true; }
00181   // ist Kante im Gebiet?
00182   bool edge(D3vector V1, D3vector V2);
00183   // Kann der Abstand zum Rand in Richting d berechnet werden?
00184   calc_dis calc_distance(D3vector V, dir_3D d) {return yes; }
00185   // Abstand zum Rand in Richting d
00186   double distance(D3vector V, dir_3D d);
00187   // ist Punkt im Gebiet? Diese Funktion sollte nur amAnfang verwendet werden.
00188   bool point_in_domain(D3vector V) {  return function(V); }
00189 
00190   // Periodoic object??
00191   bool Is_periodic() { return is_periodic; }
00192 
00193   // Beschreibung des Umgebenden Quadrates
00194   D3vector GiveA()    const { return A; }
00195   double   GiveH()    const { return H; }
00196   D3vector GiveVecH() const { return VecH; }
00197 };
00198 
00199 // convex domains with two parameters
00200 class Convex_domains_2P : public All_Domains {
00201  public:
00202   // Konstruktoren, n ist fuer Parameter n_uniform 
00203   Convex_domains_2P(PointtypeD (*f)(D3vector,double,double),
00204                  double (*fd)(D3vector,dir_3D,double,double),
00205                  int n) {
00206     function_2P = f;
00207     func_distance_2P = fd;
00208     n_uniform = n;
00209     is_periodic = false;
00210   }
00211 
00212   // Groesse eines uniformen Grundgitters, Angabe in Levels:
00213   int  Give_n_uniform() { return n_uniform; } ;
00214   // Kann berechnet werden ob Kante im Gebiet?
00215   bool calc_edge(D3vector V1, D3vector V2) { return true; }
00216   // ist Kante im Gebiet?
00217   bool edge(D3vector V1, D3vector V2);
00218   // Kann der Abstand zum Rand in Richting d berechnet werden?
00219   calc_dis calc_distance(D3vector V, dir_3D d) {return yes; }
00220   // Abstand zum Rand in Richting d
00221   double distance(D3vector V, dir_3D d);
00222   // ist Punkt im Gebiet? Diese Funktion sollte nur amAnfang verwendet werden.
00223   bool point_in_domain(D3vector V) { 
00224     return function_2P(V,R_down,R_top);
00225   }
00226 
00227   // Periodoic object??
00228   bool Is_periodic() { return is_periodic; }
00229 
00230   // Beschreibung des Umgebenden Quadrates
00231   D3vector GiveA()    const { return A; }
00232   double   GiveH()    const { return H; }
00233   D3vector GiveVecH() const { return VecH; }
00234 };
00235 
00236 // convex domains with four parameters
00237 class Convex_domains_4P : public All_Domains {
00238  public:
00239   // Konstruktoren, n ist fuer Parameter n_uniform 
00240   Convex_domains_4P(PointtypeD (*f)(D3vector,double,double,double,double),
00241                  double (*fd)(D3vector,dir_3D,double,double,double,double),
00242                  int n) {
00243     function_4P = f;
00244     func_distance_4P = fd;
00245     n_uniform = n;
00246     is_periodic = false;
00247   }
00248 
00249   // Groesse eines uniformen Grundgitters, Angabe in Levels:
00250   int  Give_n_uniform() { return n_uniform; } ;
00251   // Kann berechnet werden ob Kante im Gebiet?
00252   bool calc_edge(D3vector V1, D3vector V2) { return true; }
00253   // ist Kante im Gebiet?
00254   bool edge(D3vector V1, D3vector V2);
00255   // Kann der Abstand zum Rand in Richting d berechnet werden?
00256   calc_dis calc_distance(D3vector V, dir_3D d) {return yes; }
00257   // Abstand zum Rand in Richting d
00258   double distance(D3vector V, dir_3D d);
00259   // ist Punkt im Gebiet? Diese Funktion sollte nur amAnfang verwendet werden.
00260   bool point_in_domain(D3vector V) { 
00261     return function_4P(V,R_down,R_top,R_left,R_right);
00262   }
00263 
00264   // Periodoic object??
00265   bool Is_periodic() { return is_periodic; }
00266 
00267   // Beschreibung des Umgebenden Quadrates
00268   D3vector GiveA()    const { return A; }
00269   double   GiveH()    const { return H; }
00270   D3vector GiveVecH() const { return VecH; }
00271 };
00272 
00274 // 4.1:  union of domains
00275 
00276 class Union_domains : public All_Domains {
00277  public:
00278   // constructors
00279   Union_domains(All_Domains* dom_a, All_Domains *dom_b) {
00280     D3vector A_a;
00281     D3vector A_b;
00282     D3vector VH_a;
00283     D3vector VH_b;
00284     domain_A = dom_a;
00285     domain_B = dom_b;
00286     A_a  = domain_A->GiveA();
00287     A_b  = domain_B->GiveA();
00288     VH_a = domain_A->GiveVecH();
00289     VH_b = domain_B->GiveVecH();
00290     A = D3vector(MIN(A_a.x,A_b.x),MIN(A_a.y,A_b.y),MIN(A_a.z,A_b.z));
00291     H = MAX(domain_A->GiveH(),domain_B->GiveH());
00292     VecH = D3vector(MAX(VH_a.x,VH_b.x),MAX(VH_a.y,VH_b.y),MAX(VH_a.z,VH_b.z));
00293     // x
00294     if(A_a.x < A_b.x) {
00295       H = MAX(A_b.x - A_a.x + domain_B->GiveH(),H);
00296       VecH.x = MAX(A_b.x - A_a.x + domain_B->GiveVecH().x,VecH.x);
00297     }
00298     if(A_a.x > A_b.x) {
00299       H = MAX(A_a.x - A_b.x + domain_A->GiveH(),H);
00300       VecH.x = MAX(A_a.x - A_b.x + domain_A->GiveVecH().x,VecH.x);
00301     }
00302     // y
00303     if(A_a.y < A_b.y) {
00304       H = MAX(A_b.y - A_a.y + domain_B->GiveH(),H);
00305       VecH.y = MAX(A_b.y - A_a.y + domain_B->GiveVecH().y,VecH.y);
00306     }
00307     if(A_a.y > A_b.y) {
00308       H = MAX(A_a.y - A_b.y + domain_A->GiveH(),H);
00309       VecH.y = MAX(A_a.y - A_b.y + domain_A->GiveVecH().y,VecH.y);
00310     }
00311     // z
00312     if(A_a.z < A_b.z) {
00313       H = MAX(A_b.z - A_a.z + domain_B->GiveH(),H);
00314       VecH.z = MAX(A_b.z - A_a.z + domain_B->GiveVecH().z,VecH.z);
00315     }
00316     if(A_a.z > A_b.z) {
00317       H = MAX(A_a.z - A_b.z + domain_A->GiveH(),H);
00318       VecH.z = MAX(A_a.z - A_b.z + domain_A->GiveVecH().z,VecH.z);
00319     }
00320 
00321     n_uniform = MAX(domain_A->Give_n_uniform(),domain_B->Give_n_uniform());
00322   }
00323 
00324   // Periodoic object??
00325   bool Is_periodic() { 
00326     return (domain_A->Is_periodic() || domain_B->Is_periodic());
00327   }
00328   
00329   // size of minimal uniform grid (in levels)
00330   int  Give_n_uniform() { return n_uniform; } ;
00331   // is it possible to calculate whether edge in domain?
00332   bool calc_edge(D3vector V1, D3vector V2) { return true; }
00333   // is edge in domain?
00334   bool edge(D3vector V1, D3vector V2);
00335   //  is it possible to calculate distance to the boundary?
00336   calc_dis calc_distance(D3vector V, dir_3D d) {return yes; }
00337   // distance to the boundary in direction d
00338   double distance(D3vector V, dir_3D d);
00339   // is point in domain?
00340   bool point_in_domain(D3vector V) {  
00341     return domain_A->point_in_domain(V)==interiorD ||
00342       domain_B->point_in_domain(V)==interiorD; }
00343   
00344   // describtion of the square, in which the domain is contained
00345   D3vector GiveA() const { return A; }
00346   double   GiveH() const { return H; }
00347   D3vector GiveVecH() const { return VecH; }
00348 };
00349 
00350 
00351 
00353 // 4.2:  cut of domains
00354 
00355 class Cut_domains : public All_Domains {
00356  public:
00357   // constructors
00358   Cut_domains(All_Domains* dom_a, All_Domains *dom_b) {
00359     D3vector A_a;
00360     D3vector A_b;
00361     D3vector B_a;
00362     D3vector B_b;
00363     D3vector B;
00364     domain_A = dom_a;
00365     domain_B = dom_b;
00366     A_a = domain_A->GiveA();
00367     A_b = domain_B->GiveA();
00368     B_a = domain_A->GiveH() + A_a;
00369     B_b = domain_B->GiveH() + A_b;
00370     A = D3vector(MAX(A_a.x,A_b.x),MAX(A_a.y,A_b.y),MAX(A_a.z,A_b.z));
00371     B = D3vector(MIN(B_a.x,B_b.x),MIN(B_a.y,B_b.y),MIN(B_a.z,B_b.z));
00372     H = MAX(B.x-A.x,B.y-A.y,B.z-A.z);
00373     VecH = D3vector(B.x-A.x,B.y-A.y,B.z-A.z);
00374     //    H = MIN(domain_A->GiveH(),domain_B->GiveH());
00375     n_uniform = MAX(domain_A->Give_n_uniform(),domain_B->Give_n_uniform());
00376   }
00377   
00378   // size of minimal uniform grid (in levels)
00379   int  Give_n_uniform() { return n_uniform; } ;
00380   // is it possible to calculate whether edge in domain?
00381   bool calc_edge(D3vector V1, D3vector V2) { return true; }
00382   // is edge in domain?
00383   bool edge(D3vector V1, D3vector V2);
00384   //  is it possible to calculate distance to the boundary?
00385   calc_dis calc_distance(D3vector V, dir_3D d) {return yes; }
00386   // distance to the boundary in direction d
00387   double distance(D3vector V, dir_3D d);
00388   // is point in domain?
00389   bool point_in_domain(D3vector V) {  
00390     return domain_A->point_in_domain(V)==interiorD &&
00391       domain_B->point_in_domain(V)==interiorD; }
00392   
00393   // Periodoic object??
00394   bool Is_periodic() { 
00395     return (domain_A->Is_periodic() || domain_B->Is_periodic());
00396   }
00397 
00398 
00399   // describtion of the square, in which the domain is contained
00400   D3vector GiveA() const { return A; }
00401   double   GiveH() const { return H; }
00402   D3vector GiveVecH() const { return VecH; }
00403 };
00404 
00405 
00407 // 5.:  move domain
00408 
00409 class Move_domain : public All_Domains {
00410  public:
00411   // constructor
00412   Move_domain(All_Domains *dom_a, D3vector Vmove)  {
00413     domain_A = dom_a;
00414     V_move = Vmove;
00415     A = domain_A->GiveA() + V_move;
00416     H = domain_A->GiveH();
00417     VecH = domain_A->GiveVecH();
00418     n_uniform = domain_A->Give_n_uniform();
00419   }
00420 
00421   // size of minimal uniform grid (in levels)
00422   int  Give_n_uniform() { return n_uniform; }
00423   // is it possible to calculate whether edge in domain?
00424   bool calc_edge(D3vector V1, D3vector V2) { return true; }
00425   // is edge in domain?
00426   bool edge(D3vector V1, D3vector V2);
00427   //  is it possible to calculate distance to the boundary?
00428   calc_dis calc_distance(D3vector V, dir_3D d) {return yes; }
00429   // distance to the boundary in direction d
00430   double distance(D3vector V, dir_3D d);
00431   // is point in domain? 
00432   bool point_in_domain(D3vector V) {  
00433     return domain_A->point_in_domain(V-V_move)==interiorD; }
00434 
00435   // Periodoic object??
00436   bool Is_periodic() { 
00437     return domain_A->Is_periodic();
00438   }
00439 
00440 
00441   // describtion of the square, in which the domain is contained
00442   D3vector GiveA() const { return A; }
00443   double   GiveH() const { return H; }
00444   D3vector GiveVecH() const { return VecH; }
00445 };
00446 
00448 // 6.:  scale domain
00449 
00450 class Scale_domain : public All_Domains {
00451  public:
00452   // constructor
00453   Scale_domain(All_Domains *dom_a, D3vector Vscale)  {
00454     domain_A = dom_a;
00455     V_scale.x = ABS(Vscale.x);
00456     V_scale.y = ABS(Vscale.y);
00457     V_scale.z = ABS(Vscale.z);
00458     A = domain_A->GiveA() * Vscale;
00459     H = domain_A->GiveH() * MAX(V_scale.x,V_scale.y,V_scale.z);
00460     VecH = domain_A->GiveVecH() * D3vector(V_scale.x,V_scale.y,V_scale.z);
00461     n_uniform = domain_A->Give_n_uniform();
00462   }
00463 
00464   // size of minimal uniform grid (in levels)
00465   int  Give_n_uniform() { return n_uniform; }
00466   // is it possible to calculate whether edge in domain?
00467   bool calc_edge(D3vector V1, D3vector V2) { return true; }
00468   // is edge in domain?
00469   bool edge(D3vector V1, D3vector V2);
00470   //  is it possible to calculate distance to the boundary?
00471   calc_dis calc_distance(D3vector V, dir_3D d) {return yes; }
00472   // distance to the boundary in direction d
00473   double distance(D3vector V, dir_3D d);
00474  // is point in domain? 
00475   bool point_in_domain(D3vector V) {  
00476     return domain_A->point_in_domain(V/V_scale)==interiorD; }
00477 
00478   // Periodoic object??
00479   bool Is_periodic() { 
00480     return domain_A->Is_periodic();
00481   }
00482 
00483   // describtion of the square, in which the domain is contained
00484   D3vector GiveA() const { return A; }
00485   double   GiveH() const { return H; }
00486   D3vector GiveVecH() const { return VecH; }
00487 };
00488 
00490 // 7.:  operators
00491 // operator +
00492 inline Domain
00493 operator+(All_Domains& a, D3vector V)
00494 {
00495   return Domain(new Move_domain(&a,V));
00496 }
00497 
00498 inline Domain
00499 operator+(D3vector V, All_Domains& a)
00500 {
00501   return Domain(new Move_domain(&a,V));
00502 }
00503 
00504 inline Domain
00505 operator+(const Domain& a, D3vector V)
00506 {
00507   return Domain(new Move_domain(new Domain(a),V));
00508 }
00509 
00510 inline Domain
00511 operator+(D3vector V, const Domain& a)
00512 {
00513   return Domain(new Move_domain(new Domain(a),V));
00514 }
00515 // operator *
00516 inline Domain
00517 operator*(All_Domains& a, const D3vector V)
00518 {
00519   return Domain(new Scale_domain(&a,V));
00520 }
00521 
00522 inline Domain
00523 operator*(const Domain& a, const D3vector V)
00524 {
00525   return Domain(new Scale_domain(new Domain(a),V));
00526 }
00527 
00528 inline Domain
00529 operator*(All_Domains& a, double s)
00530 {
00531   return Domain(new Scale_domain(&a,D3vector(s,s,s)));
00532 }
00533 
00534 inline Domain
00535 operator*(double s, All_Domains& a)
00536 {
00537   return Domain(new Scale_domain(&a,D3vector(s,s,s)));
00538 }
00539 
00540 inline Domain
00541 operator*(const Domain& a, double s)
00542 {
00543   return Domain(new Scale_domain(new Domain(a),D3vector(s,s,s)));
00544 }
00545 
00546 inline Domain
00547 operator*(double s, const Domain& a)
00548 {
00549   return Domain(new Scale_domain(new Domain(a),D3vector(s,s,s)));
00550 }
00551 
00552 // operator ||
00553 inline Domain
00554 operator||(All_Domains& a, const Domain& b)
00555 {
00556   return Domain(new Union_domains(&a,new Domain(b)));
00557 }
00558 
00559 inline Domain
00560 operator||(All_Domains& a, All_Domains& b)
00561 {
00562   return Domain(new Union_domains(&a,&b));
00563 }
00564 
00565 inline Domain
00566 operator||(const Domain& a, All_Domains& b)
00567 {
00568   return Domain(new Union_domains(new Domain(a),&b));
00569 }
00570 
00571 inline Domain
00572 operator||(const Domain& a, const Domain& b)
00573 {
00574   return Domain(new Union_domains(new Domain(a),new Domain(b)));
00575 }
00576 
00577 // operator &&
00578 inline Domain
00579 operator&&(All_Domains& a, const Domain& b)
00580 {
00581   return Domain(new Cut_domains(&a,new Domain(b)));
00582 }
00583 
00584 inline Domain
00585 operator&&(All_Domains& a, All_Domains& b)
00586 {
00587   return Domain(new Cut_domains(&a,&b));
00588 }
00589 
00590 inline Domain
00591 operator&&(const Domain& a, All_Domains& b)
00592 {
00593   return Domain(new Cut_domains(new Domain(a),&b));
00594 }
00595 
00596 inline Domain
00597 operator&&(const Domain& a, const Domain& b)
00598 {
00599   return Domain(new Cut_domains(new Domain(a),new Domain(b)));
00600 }
00601 
00602 
00603 // some elementary member functions
00604 // --------------------------------------
00605 // Convex_domains
00606 inline double Convex_domains::distance(D3vector V, dir_3D d) {
00607   return func_distance(V,d);
00608 }
00609 
00610 inline bool Convex_domains::edge(D3vector V1, D3vector V2) {
00611   if(function(V1) == exteriorD || function(V2) == exteriorD)
00612     return false;
00613   else return true;
00614 }
00615 
00616 // Convex_domains
00617 inline double Convex_domains_2P::distance(D3vector V, dir_3D d) {
00618   return func_distance_2P(V,d,R_down,R_top);
00619 }
00620 inline double Convex_domains_4P::distance(D3vector V, dir_3D d) {
00621   return func_distance_4P(V,d,R_down,R_top,R_left,R_right);
00622 }
00623 
00624 inline bool Convex_domains_2P::edge(D3vector V1, D3vector V2) {
00625   if(function_2P(V1,R_down,R_top) == exteriorD ||
00626      function_2P(V2,R_down,R_top) == exteriorD)
00627     return false;
00628   else return true;
00629 }
00630 
00631 inline bool Convex_domains_4P::edge(D3vector V1, D3vector V2) {
00632   if(function_4P(V1,R_down,R_top,R_left,R_right) == exteriorD ||
00633      function_4P(V2,R_down,R_top,R_left,R_right) == exteriorD)
00634     return false;
00635   else return true;
00636 }
00637 
00638 // Move_domains
00639 inline double Move_domain::distance(D3vector V, dir_3D d) {
00640   return domain_A->distance(V-V_move,d);
00641 }
00642 
00643 inline bool Move_domain::edge(D3vector V1, D3vector V2) {
00644   return domain_A->edge(V1-V_move,V2-V_move);
00645 }
00646 
00647 // Scale_domains
00648 inline double Scale_domain::distance(D3vector V, dir_3D d) {
00649   if(d<Sdir) return domain_A->distance(V/V_scale,d) * V_scale.x;
00650   if(d>Ndir) return domain_A->distance(V/V_scale,d) * V_scale.z;
00651   return domain_A->distance(V/V_scale,d) * V_scale.y;
00652 }
00653 
00654 inline bool Scale_domain::edge(D3vector V1, D3vector V2) {
00655   return domain_A->edge(V1/V_scale,V2/V_scale);
00656 }
00657 
00658 // Union_domains
00659 inline bool Union_domains::edge(D3vector V1, D3vector V2) {
00660   double eps, dis;
00661   if(domain_A->edge(V1-V_move,V2-V_move)) return true;
00662   if(domain_B->edge(V1-V_move,V2-V_move)) return true;
00663   eps = H * domain_eps;
00664   // E - W
00665   dis = V1.x - V2.x;
00666   if(dis > eps) {  //  V2.x ---- V1.x
00667     if(dis < domain_A->distance(V2,Edir) + domain_B->distance(V1,Wdir))
00668       return true;
00669     if(dis < domain_B->distance(V2,Edir) + domain_A->distance(V1,Wdir))
00670       return true;
00671     return false;
00672   }
00673   dis = V2.x - V1.x;
00674   if(dis > eps) {  //  V1.x ---- V2.x
00675     if(dis < domain_A->distance(V1,Edir) + domain_B->distance(V2,Wdir))
00676       return true;
00677     if(dis < domain_B->distance(V1,Edir) + domain_A->distance(V2,Wdir))
00678       return true;
00679     return false;
00680   }
00681   // S - N
00682   dis = V1.y - V2.y;
00683   if(dis > eps) {  //  V2.y ---- V1.y
00684     if(dis < domain_A->distance(V2,Ndir) + domain_B->distance(V1,Sdir))
00685       return true;
00686     if(dis < domain_B->distance(V2,Ndir) + domain_A->distance(V1,Sdir))
00687       return true;
00688     return false;
00689   }
00690   dis = V2.y - V1.y;
00691   if(dis > eps) {  //  V1.y ---- V2.y
00692     if(dis < domain_A->distance(V1,Ndir) + domain_B->distance(V2,Sdir))
00693       return true;
00694     if(dis < domain_B->distance(V1,Ndir) + domain_A->distance(V2,Sdir))
00695       return true;
00696     return false;
00697   }
00698   // D - T
00699   dis = V1.z - V2.z;
00700   if(dis > eps) {  //  V2.z ---- V1.z
00701     if(dis < domain_A->distance(V2,Tdir) + domain_B->distance(V1,Ddir))
00702       return true;
00703     if(dis < domain_B->distance(V2,Tdir) + domain_A->distance(V1,Ddir))
00704       return true;
00705     return false;
00706   }
00707   dis = V2.z - V1.z;
00708   //  if(dis > eps) {  //  V1.z ---- V2.z
00709   if(dis < domain_A->distance(V1,Tdir) + domain_B->distance(V2,Ddir))
00710     return true;
00711   if(dis < domain_B->distance(V1,Tdir) + domain_A->distance(V2,Ddir))
00712     return true;
00713   return false;
00714   // }
00715 }
00716 
00717 inline double Union_domains::distance(D3vector V, dir_3D d) {
00718   double dA, dB, eps;
00719   eps = H * domain_eps;
00720   dA = domain_A->distance(V,d);
00721   dB = domain_B->distance(V,d);
00722   if(!(dA>0.0) && dB>0.0)
00723     return MAX(domain_A->distance(V+(dB-eps)*Unit_vector(d),d)+dB+eps,dB);
00724   if(dA>0.0 && !(dB>0.0))
00725     return MAX(dA,domain_B->distance(V+(dA-eps)*Unit_vector(d),d)+dA+eps);
00726   return MAX(domain_A->distance(V,d),
00727              domain_B->distance(V,d));
00728 }
00729 
00730 
00731 
00732 // Cut_domains
00733 inline bool Cut_domains::edge(D3vector V1, D3vector V2) {
00734   if(domain_A->edge(V1-V_move,V2-V_move) &&
00735      domain_B->edge(V1-V_move,V2-V_move)) return true;
00736   else return false;
00737 }
00738 
00739 inline double Cut_domains::distance(D3vector V, dir_3D d) {
00740   double dA, dB;
00741   dA = domain_A->distance(V,d);
00742   dB = domain_B->distance(V,d);
00743   return MIN(dA,dB);
00744 }
00745 
00746 
00747 
00748 // Remark:
00749 // the functions
00750 //        int Give_n_uniform() =0;
00751 // are not implemented in an optimal way.
00752 // sometimes they give back too small values
00753 // this is not a problem, since this function is
00754 // used only for error messages!!
00755 
00757 // 9.:  special domain fuer Andreas  
00759 
00760 
00761 class Special_domain : public Convex_domains {
00762  public:
00763   Special_domain(double (*dis_Specdom)(D3vector V, dir_3D d), PointtypeD (*Poi_Specdom)(D3vector V), 
00764                  double transverseScale);
00765 };
00766 
00767 inline Special_domain ::Special_domain (double (*dis_Specdom)(D3vector V, dir_3D d), PointtypeD (*Poi_Specdom)(D3vector V),
00768                                         double transverseScale) : 
00769   Convex_domains(Poi_Specdom,dis_Specdom,1) {
00770   A = D3vector(-transverseScale,-transverseScale,0.0);
00771   H = 2.0*transverseScale;
00772 
00773   VecH = D3vector(2.0*transverseScale,2.0*transverseScale,1.0);
00774 }
00775 
00776 
00777 #endif
00778     

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