This file is indexed.

/usr/include/deal.II/lac/solver_selector.h is in libdeal.ii-dev 6.3.1-1.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
//---------------------------------------------------------------------------
//    $Id: solver_selector.h 19894 2009-10-15 22:19:51Z kanschat $
//    Version: $Name$
//
//    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009 by the deal.II authors
//
//    This file is subject to QPL and may not be  distributed
//    without copyright and license information. Please refer
//    to the file deal.II/doc/license.html for the  text  and
//    further information on this license.
//
//---------------------------------------------------------------------------
#ifndef __deal2__solver_selector_h
#define __deal2__solver_selector_h


#include <base/config.h>
#include <base/smartpointer.h>
#include <lac/solver.h>
#include <lac/vector.h>
#include <lac/vector_memory.h>
#include <lac/solver_control.h>
#include <lac/solver_cg.h>
#include <lac/solver_bicgstab.h>
#include <lac/solver_gmres.h>
#include <lac/vector_memory.h>
#include <lac/solver_richardson.h>
#include <lac/precondition.h>

DEAL_II_NAMESPACE_OPEN


/*!@addtogroup Solvers */
/*@{*/

/**
 * Selects a solver by changing a parameter.
 * 
 * By calling the @p solve function of this @p SolverSelector, it selects
 * the @p solve function of that @p Solver that was specified in the constructor
 * of this class.
 *
 * <h3>Usage</h3>
 * The simplest use of this class is the following:
 * @verbatim
 *                                  // generate a @p SolverControl and
 *                                  // a @p VectorMemory
 * SolverControl control;
 * VectorMemory<Vector<double> > memory;
 *                                  // Line 3:
 *                                  //
 *                                  // generate a @p SolverSelector that
 *                                  // calls the @p SolverCG
 * SolverSelector<Vector<double> > 
 *   solver_selector("cg", control, memory);
 *                                  // generate e.g. a @p PreconditionRelaxation
 * PreconditionRelaxation<SparseMatrix<double>, Vector<double> >
 *   preconditioning(A, &SparseMatrix<double>
 *                   ::template precondition_SSOR<double>,0.8);
 *                                  // call the @p solve function with this
 *                                  // preconditioning as last argument
 * solver_selector.solve(A,x,b,preconditioning);
 * @endverbatim
 * But the full usefulness of the @p SolverSelector class is not
 * clear until the presentation of the following example that assumes
 * the user using the @p ParameterHandler class and having declared a
 * "solver" entry, e.g. with
 * @verbatim
 * Parameter_Handler prm;
 * prm.declare_entry ("solver", "none",
 *                    Patterns::Selection(SolverSelector<>::get_solver_names()));
 * ...
 * @endverbatim
 * Assuming that in the users parameter file there exists the line
 * @verbatim
 * set solver = cg
 * @endverbatim
 * then `Line 3' of the above example reads
 * @verbatim
 * SolverSelector<SparseMatrix<double>, Vector<double> > 
 *   solver_selector(prm.get("solver"), control, memory);
 * @endverbatim
 *
 *
 * If at some time there exists a new solver "xyz" then the user does not need
 * to change his program. Only in the implementation of the @p SolverSelector
 * the calling of this solver has to be added and each user with program lines
 * quoted above only needs to 'set solver = xyz' in his parameter file to get
 * access to that new solver.  :-)
 *
 * (By the way, thanks to Wolfgang for implementing the @p ParameterHandler.)
 * 
 * @author Ralf Hartmann, 1999
 */
template <class VECTOR = Vector<double> >
class SolverSelector : public Subscriptor
{
  public:

				     /**
				      * Constructor. Use the arguments
				      * to initialize actual solver
				      * objects.
				      */
    SolverSelector (const std::string    &solvername,
		    SolverControl        &control,
		    VectorMemory<VECTOR> &vector_memory);
  
				     /**
				      * Destructor
				      */
    ~SolverSelector();

				     /**
				      * Solver procedure. Calls the @p solve
				      * function
				      * of the @p solver whose @p SolverName
				      * was specified in the constructor.
				      * 
				      */
    template<class Matrix, class Preconditioner>
    void solve(const Matrix &A,
	       VECTOR &x,
	       const VECTOR &b,
	       const Preconditioner &precond) const;
    
				     /**
				      * Set the additional data. For more
				      * info see the @p Solver class.
				      */
    void set_data(const typename SolverRichardson<VECTOR>
		  ::AdditionalData &data);

				     /**
				      * Set the additional data. For more
				      * info see the @p Solver class.
				      */
    void set_data(const typename SolverCG<VECTOR>
		  ::AdditionalData &data);

				     /**
				      * Set the additional data. For more
				      * info see the @p Solver class.
				      */
    void set_data(const typename SolverBicgstab<VECTOR>
		  ::AdditionalData &data); 

				     /**
				      * Set the additional data. For more
				      * info see the @p Solver class.
				      */
    void set_data(const typename SolverGMRES<VECTOR>
		  ::AdditionalData &data);

				     /**
				      * Set the additional data. For more
				      * info see the @p Solver class.
				      */
    void set_data(const typename SolverFGMRES<VECTOR>
		  ::AdditionalData &data);

				     /**
				      * Get the names of all implemented
				      * solvers.
				      */
    static std::string get_solver_names ();

				     /**
				      * Exception.
				      */
    DeclException1 (ExcSolverDoesNotExist,
		    std::string, << "Solver " << arg1 << " does not exist. Use one of "
		    << std::endl << get_solver_names());

  protected:
				     /**
				      * Stores the Name of the solver.
				      */
    std::string solver_name;
    
				     /**
				      * Stores the @p SolverControl that
				      * is needed in the constructor of
				      * each @p Solver class.
				      */
    SmartPointer<SolverControl,SolverSelector<VECTOR> > control;

				     /**
				      * Stores the @p VectorMemory that
				      * is needed in the constructor of
				      * each @p Solver class.
				      */
    SmartPointer<VectorMemory<VECTOR>,SolverSelector<VECTOR> > vector_memory;

  private:
				     /**
				      * Stores the additional data.
				      */
    typename SolverRichardson<VECTOR>::AdditionalData richardson_data;

				     /**
				      * Stores the additional data.
				      */
    typename SolverCG<VECTOR>::AdditionalData cg_data;

				     /**
				      * Stores the additional data.
				      */
    typename SolverBicgstab<VECTOR>::AdditionalData bicgstab_data;

				     /**
				      * Stores the additional data.
				      */
    typename SolverGMRES<VECTOR>::AdditionalData gmres_data;

				     /**
				      * Stores the additional data.
				      */
    typename SolverFGMRES<VECTOR>::AdditionalData fgmres_data;
};

/*@}*/
/* --------------------- Inline and template functions ------------------- */


template <class VECTOR>
SolverSelector<VECTOR>::SolverSelector(const std::string    &solver_name,
				       SolverControl        &control,
				       VectorMemory<VECTOR> &vector_memory) :
		solver_name(solver_name),
		control(&control),
		vector_memory(&vector_memory)
{}


template <class VECTOR>
SolverSelector<VECTOR>::~SolverSelector()
{}


template <class VECTOR>
template<class Matrix, class Preconditioner>
void
SolverSelector<VECTOR>::solve(const Matrix &A,
			      VECTOR &x,
			      const VECTOR &b,
			      const Preconditioner &precond) const
{
  if (solver_name=="richardson")
    {
      SolverRichardson<VECTOR> solver(*control,*vector_memory,
				      richardson_data);
      solver.solve(A,x,b,precond);
    }       
  else if (solver_name=="cg")
    {
      SolverCG<VECTOR> solver(*control,*vector_memory,
			      cg_data);
      solver.solve(A,x,b,precond);
    }
  else if (solver_name=="bicgstab")
    {
      SolverBicgstab<VECTOR> solver(*control,*vector_memory,
				    bicgstab_data);
      solver.solve(A,x,b,precond);
    }
  else if (solver_name=="gmres")
    {
      SolverGMRES<VECTOR> solver(*control,*vector_memory,
				 gmres_data);
      solver.solve(A,x,b,precond);
    }
  else if (solver_name=="fgmres")
    {
      SolverFGMRES<VECTOR> solver(*control,*vector_memory,
				  fgmres_data);
      solver.solve(A,x,b,precond);
    }
  else
    Assert(false,ExcSolverDoesNotExist(solver_name));
}


template <class VECTOR>
std::string SolverSelector<VECTOR>::get_solver_names()
{
  return "richardson|cg|bicgstab|gmres|fgmres";
}


template <class VECTOR>
void SolverSelector<VECTOR>::set_data(
  const typename SolverGMRES<VECTOR>::AdditionalData &data)
{ 
  gmres_data=data; 
}


template <class VECTOR>
void SolverSelector<VECTOR>::set_data(
  const typename SolverFGMRES<VECTOR>::AdditionalData &data)
{ 
  fgmres_data=data; 
}


template <class VECTOR>
void SolverSelector<VECTOR>::set_data(
  const typename SolverRichardson<VECTOR>::AdditionalData &data)
{ 
  richardson_data=data; 
}


template <class VECTOR>
void SolverSelector<VECTOR>::set_data(
  const typename SolverCG<VECTOR>::AdditionalData &data) 
{ 
  cg_data=data; 
}


template <class VECTOR>
void SolverSelector<VECTOR>::set_data(
  const typename SolverBicgstab<VECTOR>::AdditionalData &data) 
{ 
  bicgstab_data=data; 
}


DEAL_II_NAMESPACE_CLOSE

#endif