Chombo + EB + MF  3.2
ChomboSundialsAdaptor.H
Go to the documentation of this file.
1 #ifdef CH_LANG_CC
2 /*
3  * _______ __
4  * / ___/ / ___ __ _ / / ___
5  * / /__/ _ \/ _ \/ V \/ _ \/ _ \
6  * \___/_//_/\___/_/_/_/_.__/\___/
7  * Please refer to Copyright.txt, in Chombo's root directory.
8  */
9 #endif
10 
11 #ifndef _CHOMBOSUNDIALSADAPTOR_H
12 #define _CHOMBOSUNDIALSADAPTOR_H
13 
14 #include <stdio.h>
15 #include "REAL.H"
16 
17 /// Virtual base class contract to interact with SUNDIALS
18 /**
19  Declares virtual functions needed to satisfy the SUNDIALS NVector
20  functions. Derived classes need to implement these, with care taken
21  to "linearize" Chombo data, e.g. avoid counting duplicate values,
22  include all components, or ghost cells, etc. in NVector operations.
23  Note that many operations can also take "this" object as an argument;
24  in that case they should do an in-place update of the object's data.
25  */
27 {
28 public:
29  ///
30  /**
31  Constructor.
32  */
34 
35  ///
36  /**
37  Destructor.
38  */
39  virtual ~ChomboSundialsAdaptor() {};
40 
41  ///
42  /**
43  SUNDIALS operation - calculates a*x+b*y and puts in this instance's data
44  */
46  Real a, Real b) = 0;
47  ///
48  /**
49  SUNDIALS operation - sets this instance's data to c
50  */
51  virtual void setConst(Real c) = 0;
52  ///
53  /**
54  SUNDIALS operation - sets this instance's data to x*y
55  */
56  virtual void prod(ChomboSundialsAdaptor& ax, ChomboSundialsAdaptor& ay) = 0;
57  ///
58  /**
59  SUNDIALS operation - sets this instance's data to x/y
60  */
61  virtual void div(ChomboSundialsAdaptor& ax, ChomboSundialsAdaptor& ay) = 0;
62  ///
63  /**
64  SUNDIALS operation - sets this instance's data to c*x
65  */
66  virtual void scale(ChomboSundialsAdaptor& ax, Real c) = 0;
67  ///
68  /**
69  SUNDIALS operation - sets this instance's data to abs(x)
70  */
71  virtual void abs(ChomboSundialsAdaptor& ax) = 0;
72  ///
73  /**
74  SUNDIALS operation - sets this instance's data to 1/x
75  */
76  virtual void inv(ChomboSundialsAdaptor& ax) = 0;
77  ///
78  /**
79  SUNDIALS operation - sets this instance's data to x+b
80  */
81  virtual void addConst(ChomboSundialsAdaptor& ax, Real b) = 0;
82  ///
83  /**
84  SUNDIALS operation - returns dot product sum(data^T * x)
85  */
86  virtual Real dotProd(ChomboSundialsAdaptor& ax) = 0;
87  ///
88  /**
89  SUNDIALS operation - returns all data max norm
90  */
91  virtual Real maxNorm() = 0;
92  ///
93  /**
94  SUNDIALS operation - returns all data weighted RMS (root mean square) norm
95  */
96  virtual Real wRMSNorm(ChomboSundialsAdaptor& aw) = 0;
97  ///
98  /**
99  SUNDIALS - does not have to be implemented, but here for completeness
100  */
102  ///
103  /**
104  SUNDIALS operation - returns all data min
105  */
106  virtual Real min() = 0;
107  ///
108  /**
109  SUNDIALS operation - returns all data L1 norm
110  (sum abs values)
111  */
112  virtual Real l1Norm() = 0;
113  ///
114  /**
115  SUNDIALS - does not have to be implemented, but here for completeness
116  */
117  virtual Real wL2Norm(ChomboSundialsAdaptor& aw) = 0;
118  ///
119  /**
120  SUNDIALS - does not have to be implemented, but here for completeness
121  */
122  virtual void compare(ChomboSundialsAdaptor& ax, Real b) = 0;
123  ///
124  /**
125  SUNDIALS - does not have to be implemented, but here for completeness
126  */
127  virtual bool invTest(ChomboSundialsAdaptor& ax) = 0;
128  ///
129  /**
130  SUNDIALS - does not have to be implemented, but here for completeness
131  */
132  virtual bool constrMask(ChomboSundialsAdaptor& ac, ChomboSundialsAdaptor& am) = 0;
133  ///
134  /**
135  SUNDIALS - does not have to be implemented, but here for completeness
136  */
137  virtual Real minQuotient(ChomboSundialsAdaptor& adenom) = 0;
138 
139  ///
140  /**
141  SUNDIALS operation - returns the total number of cells in the nvector
142  NOTE: careful for covered %AMR cells, ghost cells, etc. And should
143  probably be multiplied by the number of components
144  */
145  virtual unsigned long getLength() = 0;
146  ///
147  /**
148  Placeholder for MPI. Does not have to be implemented, here for futures
149  */
150  virtual void exchange() = 0;
151  ///
152  /**
153  Placeholder for MPI. Does not have to be implemented, but here for futures
154  */
155  virtual bool copyTo(ChomboSundialsAdaptor& a) = 0;
156  ///
157  /**
158  SUNDIALS - does not have to be implemented, but here for futures
159  */
160  virtual void print() = 0;
161  ///
162  /**
163  SUNDIALS - does not have to be implemented, but here for futures
164  */
165  virtual void printFile(FILE* outfile) = 0;
166  ///
167  /**
168  Factory
169  */
170  virtual ChomboSundialsAdaptor* newAdaptor() = 0;
171 
172 private:
173 };
174 
175 #endif
virtual void prod(ChomboSundialsAdaptor &ax, ChomboSundialsAdaptor &ay)=0
virtual Real min()=0
virtual void abs(ChomboSundialsAdaptor &ax)=0
virtual void compare(ChomboSundialsAdaptor &ax, Real b)=0
virtual void exchange()=0
virtual Real maxNorm()=0
virtual void inv(ChomboSundialsAdaptor &ax)=0
virtual Real wRMSNormMask(ChomboSundialsAdaptor &aw, ChomboSundialsAdaptor &aid)=0
virtual void printFile(FILE *outfile)=0
virtual Real wRMSNorm(ChomboSundialsAdaptor &aw)=0
virtual void div(ChomboSundialsAdaptor &ax, ChomboSundialsAdaptor &ay)=0
Virtual base class contract to interact with SUNDIALS.
Definition: ChomboSundialsAdaptor.H:26
virtual Real l1Norm()=0
virtual void setConst(Real c)=0
virtual ~ChomboSundialsAdaptor()
Definition: ChomboSundialsAdaptor.H:39
virtual Real dotProd(ChomboSundialsAdaptor &ax)=0
ChomboSundialsAdaptor()
Definition: ChomboSundialsAdaptor.H:33
virtual void linearSum(ChomboSundialsAdaptor &x, ChomboSundialsAdaptor &y, Real a, Real b)=0
virtual bool invTest(ChomboSundialsAdaptor &ax)=0
double Real
Definition: REAL.H:33
virtual void scale(ChomboSundialsAdaptor &ax, Real c)=0
virtual unsigned long getLength()=0
virtual Real minQuotient(ChomboSundialsAdaptor &adenom)=0
virtual bool copyTo(ChomboSundialsAdaptor &a)=0
virtual ChomboSundialsAdaptor * newAdaptor()=0
virtual void addConst(ChomboSundialsAdaptor &ax, Real b)=0
virtual void print()=0
virtual Real wL2Norm(ChomboSundialsAdaptor &aw)=0
virtual bool constrMask(ChomboSundialsAdaptor &ac, ChomboSundialsAdaptor &am)=0