Ifpack Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MatGenFD.h
Go to the documentation of this file.
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 /*=====================================================================
47 option summary:
48 ---------------
49 processor topology
50  -px <int> -py <int> -pz <int>
51  defaults: -px 1 -py 1 -pz 0
52 
53 grid topology
54  -m <int>
55  if pz=0, each processor has a square grid of dimension m*m,
56  hence there are m*m*px*py unknowns.
57  if pz > 0, each local grid is of dimension m*m*m, hence
58  there are m*m*m*px*py*pz unknowns.
59 
60 
61 diffusion coefficients (default is 1.0):
62  -dx <double> -dy <double> -dz <double>
63 
64 convection coefficients (default is 0.0)
65  -cx <double> -cy <double> -cz <double>
66 
67 grid dimension; if more than one mpi process, this is
68 the local size for each processor:
69  -m <int>
70 
71 boundary conditions:
72  This is very primitive; boundary conditions can only be generated for
73  2D grids; the condition along each side is either dirichlet (constant),
74  if bcXX >= 0, or neuman, if bcXX < 0.
75 
76  -bcx1 <double>
77  -bcx2 <double>
78  -bcy1 <double>
79  -bcy2 <double>
80 
81 Misc.
82  -debug_matgen
83  -striped (may not work?)
84 =====================================================================*/
85 
86 
87 #include "euclid_common.h"
88 
89 #ifdef __cplusplus
90 extern "C"
91 {
92 #endif
93 
94  struct _matgenfd
95  {
97  /* If true, memory is allocated when run() is called, in which case
98  * the caller is responsible for calling FREE_DH for the rp, cval,
99  * aval, and rhs arrays. If false, caller is assumed to have
100  * allocated memory when run is called.
101  * Default is "true"
102  */
103  int px, py, pz; /* Processor graph dimensions */
104  bool threeD;
105  int m; /* number of matrix rows in local matrix */
106  int cc; /* Dimension of each processor's subgrid */
107  double hh; /* Grid spacing; this is constant, equal to 1.0/(px*cc-1) */
108  int id; /* the processor whose submatrix is to be generated */
109  int np; /* number of subdomains (processors, mpi tasks) */
110  double stencil[8];
111 
112 
113  /* derivative coefficients; a,b,c are 2nd derivatives,
114  * c,d,e are 1st derivatives; f,g,h not currently used.
115  */
116  double a, b, c, d, e, f, g, h;
117 
118  int first; /* global number of first locally owned row */
119  bool debug;
120 
121  /* boundary conditions; if value is < 0, neumen; else, dirichelet */
122  double bcX1, bcX2;
123  double bcY1, bcY2;
124  double bcZ1, bcZ2;
125 
126  /* The following return coefficients; default is konstant() */
127  double (*A) (double coeff, double x, double y, double z);
128  double (*B) (double coeff, double x, double y, double z);
129  double (*C) (double coeff, double x, double y, double z);
130  double (*D) (double coeff, double x, double y, double z);
131  double (*E) (double coeff, double x, double y, double z);
132  double (*F) (double coeff, double x, double y, double z);
133  double (*G) (double coeff, double x, double y, double z);
134  double (*H) (double coeff, double x, double y, double z);
135  };
136 
137  extern void MatGenFD_Create (MatGenFD * mg);
138  extern void MatGenFD_Destroy (MatGenFD mg);
139  extern void MatGenFD_Run (MatGenFD mg, int id, int np, Mat_dh * A,
140  Vec_dh * rhs);
141 
142  /* =========== coefficient functions ============== */
143  extern double konstant (double coeff, double x, double y, double z);
144  extern double e2_xy (double coeff, double x, double y, double z);
145 
146 
147 
148 /* 3 boxes nested inside the unit square domain.
149  diffusivity constants are: -dd1, -dd2, -dd3.
150 */
151 /* box placement */
152 #define BOX1_X1 0.1
153 #define BOX1_X2 0.4
154 #define BOX1_Y1 0.1
155 #define BOX1_Y2 0.4
156 
157 #define BOX2_X1 0.6
158 #define BOX2_X2 0.9
159 #define BOX2_Y1 0.1
160 #define BOX2_Y2 0.4
161 
162 #define BOX3_X1 0.2
163 #define BOX3_X2 0.8
164 #define BOX3_Y1 0.6
165 #define BOX3_Y2 0.8
166 
167 /* default diffusivity */
168 #define BOX1_DD 10
169 #define BOX2_DD 100
170 #define BOX3_DD 50
171 
172  extern double box_1 (double coeff, double x, double y, double z);
173  /* -bd2 is diffusion coeff outside box;
174  -bd1 is diffusion coeff inside box.
175  */
176 
177 
178 
179  extern double box_2 (double coeff, double x, double y, double z);
180 
181 #ifdef __cplusplus
182 }
183 #endif
184 #endif
185 
186 #if defined(Ifpack_SHOW_DEPRECATED_WARNINGS)
187 #ifdef __GNUC__
188 #warning "The Ifpack package is deprecated"
189 #endif
190 #endif
191 
Definition: Mat_dh.h:62
double konstant(double coeff, double x, double y, double z)
Definition: MatGenFD.c:606
double(* G)(double coeff, double x, double y, double z)
Definition: MatGenFD.h:133
int np
Definition: MatGenFD.h:109
double d
Definition: MatGenFD.h:116
double bcX2
Definition: MatGenFD.h:122
int pz
Definition: MatGenFD.h:103
int px
Definition: MatGenFD.h:103
double f
Definition: MatGenFD.h:116
int first
Definition: MatGenFD.h:118
double box_1(double coeff, double x, double y, double z)
Definition: MatGenFD.c:625
double e
Definition: MatGenFD.h:116
int cc
Definition: MatGenFD.h:106
bool debug
Definition: MatGenFD.h:119
double(* H)(double coeff, double x, double y, double z)
Definition: MatGenFD.h:134
void MatGenFD_Run(MatGenFD mg, int id, int np, Mat_dh *AOut, Vec_dh *rhsOut)
Definition: MatGenFD.c:159
bool allocateMem
Definition: MatGenFD.h:96
double b
Definition: MatGenFD.h:116
double bcZ2
Definition: MatGenFD.h:124
int id
Definition: MatGenFD.h:108
double h
Definition: MatGenFD.h:116
bool threeD
Definition: MatGenFD.h:104
double stencil[8]
Definition: MatGenFD.h:110
double g
Definition: MatGenFD.h:116
void MatGenFD_Create(MatGenFD *mg)
Definition: MatGenFD.c:80
double(* F)(double coeff, double x, double y, double z)
Definition: MatGenFD.h:132
double c
Definition: MatGenFD.h:116
int py
Definition: MatGenFD.h:103
double e2_xy(double coeff, double x, double y, double z)
Definition: MatGenFD.c:612
Definition: Vec_dh.h:52
double bcY2
Definition: MatGenFD.h:123
void MatGenFD_Destroy(MatGenFD mg)
Definition: MatGenFD.c:149
double box_2(double coeff, double x, double y, double z)
Definition: MatGenFD.c:759
double a
Definition: MatGenFD.h:116
double bcZ1
Definition: MatGenFD.h:124
double bcY1
Definition: MatGenFD.h:123
double bcX1
Definition: MatGenFD.h:122
double hh
Definition: MatGenFD.h:107