IFPACK  Development
 All Classes Namespaces Files Functions Variables Enumerations Friends Pages
MatGenFD.h
1 /*@HEADER
2 // ***********************************************************************
3 //
4 // Ifpack: Object-Oriented Algebraic Preconditioner Package
5 // Copyright (2002) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 //@HEADER
41 */
42 
43 #ifndef MATGENFD_DH_DH
44 #define MATGENFD_DH_DH
45 
46 #if defined(Ifpack_SHOW_DEPRECATED_WARNINGS)
47 #ifdef __GNUC__
48 #warning "The Ifpack package is deprecated"
49 #endif
50 #endif
51 
52 /*=====================================================================
53 option summary:
54 ---------------
55 processor topology
56  -px <int> -py <int> -pz <int>
57  defaults: -px 1 -py 1 -pz 0
58 
59 grid topology
60  -m <int>
61  if pz=0, each processor has a square grid of dimension m*m,
62  hence there are m*m*px*py unknowns.
63  if pz > 0, each local grid is of dimension m*m*m, hence
64  there are m*m*m*px*py*pz unknowns.
65 
66 
67 diffusion coefficients (default is 1.0):
68  -dx <double> -dy <double> -dz <double>
69 
70 convection coefficients (default is 0.0)
71  -cx <double> -cy <double> -cz <double>
72 
73 grid dimension; if more than one mpi process, this is
74 the local size for each processor:
75  -m <int>
76 
77 boundary conditions:
78  This is very primitive; boundary conditions can only be generated for
79  2D grids; the condition along each side is either dirichlet (constant),
80  if bcXX >= 0, or neuman, if bcXX < 0.
81 
82  -bcx1 <double>
83  -bcx2 <double>
84  -bcy1 <double>
85  -bcy2 <double>
86 
87 Misc.
88  -debug_matgen
89  -striped (may not work?)
90 =====================================================================*/
91 
92 
93 #include "euclid_common.h"
94 
95 #ifdef __cplusplus
96 extern "C"
97 {
98 #endif
99 
100  struct _matgenfd
101  {
102  bool allocateMem;
103  /* If true, memory is allocated when run() is called, in which case
104  * the caller is responsible for calling FREE_DH for the rp, cval,
105  * aval, and rhs arrays. If false, caller is assumed to have
106  * allocated memory when run is called.
107  * Default is "true"
108  */
109  int px, py, pz; /* Processor graph dimensions */
110  bool threeD;
111  int m; /* number of matrix rows in local matrix */
112  int cc; /* Dimension of each processor's subgrid */
113  double hh; /* Grid spacing; this is constant, equal to 1.0/(px*cc-1) */
114  int id; /* the processor whose submatrix is to be generated */
115  int np; /* number of subdomains (processors, mpi tasks) */
116  double stencil[8];
117 
118 
119  /* derivative coefficients; a,b,c are 2nd derivatives,
120  * c,d,e are 1st derivatives; f,g,h not currently used.
121  */
122  double a, b, c, d, e, f, g, h;
123 
124  int first; /* global number of first locally owned row */
125  bool debug;
126 
127  /* boundary conditions; if value is < 0, neumen; else, dirichelet */
128  double bcX1, bcX2;
129  double bcY1, bcY2;
130  double bcZ1, bcZ2;
131 
132  /* The following return coefficients; default is konstant() */
133  double (*A) (double coeff, double x, double y, double z);
134  double (*B) (double coeff, double x, double y, double z);
135  double (*C) (double coeff, double x, double y, double z);
136  double (*D) (double coeff, double x, double y, double z);
137  double (*E) (double coeff, double x, double y, double z);
138  double (*F) (double coeff, double x, double y, double z);
139  double (*G) (double coeff, double x, double y, double z);
140  double (*H) (double coeff, double x, double y, double z);
141  };
142 
143  extern void MatGenFD_Create (MatGenFD * mg);
144  extern void MatGenFD_Destroy (MatGenFD mg);
145  extern void MatGenFD_Run (MatGenFD mg, int id, int np, Mat_dh * A,
146  Vec_dh * rhs);
147 
148  /* =========== coefficient functions ============== */
149  extern double konstant (double coeff, double x, double y, double z);
150  extern double e2_xy (double coeff, double x, double y, double z);
151 
152 
153 
154 /* 3 boxes nested inside the unit square domain.
155  diffusivity constants are: -dd1, -dd2, -dd3.
156 */
157 /* box placement */
158 #define BOX1_X1 0.1
159 #define BOX1_X2 0.4
160 #define BOX1_Y1 0.1
161 #define BOX1_Y2 0.4
162 
163 #define BOX2_X1 0.6
164 #define BOX2_X2 0.9
165 #define BOX2_Y1 0.1
166 #define BOX2_Y2 0.4
167 
168 #define BOX3_X1 0.2
169 #define BOX3_X2 0.8
170 #define BOX3_Y1 0.6
171 #define BOX3_Y2 0.8
172 
173 /* default diffusivity */
174 #define BOX1_DD 10
175 #define BOX2_DD 100
176 #define BOX3_DD 50
177 
178  extern double box_1 (double coeff, double x, double y, double z);
179  /* -bd2 is diffusion coeff outside box;
180  -bd1 is diffusion coeff inside box.
181  */
182 
183 
184 
185  extern double box_2 (double coeff, double x, double y, double z);
186 
187 #ifdef __cplusplus
188 }
189 #endif
190 #endif
Definition: Mat_dh.h:68
Definition: Vec_dh.h:58