00001 /*@HEADER 00002 // *********************************************************************** 00003 // 00004 // Ifpack: Object-Oriented Algebraic Preconditioner Package 00005 // Copyright (2009) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 //@HEADER 00028 */ 00029 00030 #ifndef MATGENFD_DH_DH 00031 #define MATGENFD_DH_DH 00032 00033 /*===================================================================== 00034 option summary: 00035 --------------- 00036 processor topology 00037 -px <int> -py <int> -pz <int> 00038 defaults: -px 1 -py 1 -pz 0 00039 00040 grid topology 00041 -m <int> 00042 if pz=0, each processor has a square grid of dimension m*m, 00043 hence there are m*m*px*py unknowns. 00044 if pz > 0, each local grid is of dimension m*m*m, hence 00045 there are m*m*m*px*py*pz unknowns. 00046 00047 00048 diffusion coefficients (default is 1.0): 00049 -dx <double> -dy <double> -dz <double> 00050 00051 convection coefficients (default is 0.0) 00052 -cx <double> -cy <double> -cz <double> 00053 00054 grid dimension; if more than one mpi process, this is 00055 the local size for each processor: 00056 -m <int> 00057 00058 boundary conditions: 00059 This is very primitive; boundary conditions can only be generated for 00060 2D grids; the condition along each side is either dirichlet (constant), 00061 if bcXX >= 0, or neuman, if bcXX < 0. 00062 00063 -bcx1 <double> 00064 -bcx2 <double> 00065 -bcy1 <double> 00066 -bcy2 <double> 00067 00068 Misc. 00069 -debug_matgen 00070 -striped (may not work?) 00071 =====================================================================*/ 00072 00073 00074 #include "euclid_common.h" 00075 00076 #ifdef __cplusplus 00077 extern "C" 00078 { 00079 #endif 00080 00081 struct _matgenfd 00082 { 00083 bool allocateMem; 00084 /* If true, memory is allocated when run() is called, in which case 00085 * the caller is responsible for calling FREE_DH for the rp, cval, 00086 * aval, and rhs arrays. If false, caller is assumed to have 00087 * allocated memory when run is called. 00088 * Default is "true" 00089 */ 00090 int px, py, pz; /* Processor graph dimensions */ 00091 bool threeD; 00092 int m; /* number of matrix rows in local matrix */ 00093 int cc; /* Dimension of each processor's subgrid */ 00094 double hh; /* Grid spacing; this is constant, equal to 1.0/(px*cc-1) */ 00095 int id; /* the processor whose submatrix is to be generated */ 00096 int np; /* number of subdomains (processors, mpi tasks) */ 00097 double stencil[8]; 00098 00099 00100 /* derivative coefficients; a,b,c are 2nd derivatives, 00101 * c,d,e are 1st derivatives; f,g,h not currently used. 00102 */ 00103 double a, b, c, d, e, f, g, h; 00104 00105 int first; /* global number of first locally owned row */ 00106 bool debug; 00107 00108 /* boundary conditions; if value is < 0, neumen; else, dirichelet */ 00109 double bcX1, bcX2; 00110 double bcY1, bcY2; 00111 double bcZ1, bcZ2; 00112 00113 /* The following return coefficients; default is konstant() */ 00114 double (*A) (double coeff, double x, double y, double z); 00115 double (*B) (double coeff, double x, double y, double z); 00116 double (*C) (double coeff, double x, double y, double z); 00117 double (*D) (double coeff, double x, double y, double z); 00118 double (*E) (double coeff, double x, double y, double z); 00119 double (*F) (double coeff, double x, double y, double z); 00120 double (*G) (double coeff, double x, double y, double z); 00121 double (*H) (double coeff, double x, double y, double z); 00122 }; 00123 00124 extern void MatGenFD_Create (MatGenFD * mg); 00125 extern void MatGenFD_Destroy (MatGenFD mg); 00126 extern void MatGenFD_Run (MatGenFD mg, int id, int np, Mat_dh * A, 00127 Vec_dh * rhs); 00128 00129 /* =========== coefficient functions ============== */ 00130 extern double konstant (double coeff, double x, double y, double z); 00131 extern double e2_xy (double coeff, double x, double y, double z); 00132 00133 00134 00135 /* 3 boxes nested inside the unit square domain. 00136 diffusivity constants are: -dd1, -dd2, -dd3. 00137 */ 00138 /* box placement */ 00139 #define BOX1_X1 0.1 00140 #define BOX1_X2 0.4 00141 #define BOX1_Y1 0.1 00142 #define BOX1_Y2 0.4 00143 00144 #define BOX2_X1 0.6 00145 #define BOX2_X2 0.9 00146 #define BOX2_Y1 0.1 00147 #define BOX2_Y2 0.4 00148 00149 #define BOX3_X1 0.2 00150 #define BOX3_X2 0.8 00151 #define BOX3_Y1 0.6 00152 #define BOX3_Y2 0.8 00153 00154 /* default diffusivity */ 00155 #define BOX1_DD 10 00156 #define BOX2_DD 100 00157 #define BOX3_DD 50 00158 00159 extern double box_1 (double coeff, double x, double y, double z); 00160 /* -bd2 is diffusion coeff outside box; 00161 -bd1 is diffusion coeff inside box. 00162 */ 00163 00164 00165 00166 extern double box_2 (double coeff, double x, double y, double z); 00167 00168 #ifdef __cplusplus 00169 } 00170 #endif 00171 #endif
1.7.6.1