This file is indexed.

/usr/include/deal.II/lac/schur_matrix.h is in libdeal.ii-dev 8.1.0-6ubuntu1.

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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
// ---------------------------------------------------------------------
// $Id: schur_matrix.h 30748 2013-09-16 21:34:46Z bangerth $
//
// Copyright (C) 2001 - 2013 by the deal.II authors
//
// This file is part of the deal.II library.
//
// The deal.II library is free software; you can use it, redistribute
// it, and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// The full text of the license can be found in the file LICENSE at
// the top level of the deal.II distribution.
//
// ---------------------------------------------------------------------

#ifndef __deal2__schur_matrix_h
#define __deal2__schur_matrix_h

#include <deal.II/base/config.h>
#include <deal.II/base/subscriptor.h>
#include <deal.II/base/smartpointer.h>
#include <deal.II/base/logstream.h>
#include <deal.II/lac/vector_memory.h>
#include <deal.II/lac/block_vector.h>
#include <vector>

DEAL_II_NAMESPACE_OPEN


/*! @addtogroup Matrix2
 *@{
 */

/**
 * Schur complement of a block matrix.
 *
 * Given a non-singular matrix @p A (often positive definite) and a
 * positive semi-definite matrix @p C as well as matrices @p B and
 * @p Dt of full rank, this class implements a new matrix, the Schur
 * complement a the system of equations of the structure
 *
 * @verbatim
 * /        \  /   \     /   \
 * |  A  Dt |  | u |  -  | f |
 * | -B  C  |  | p |  -  | g |
 * \        /  \   /     \   /
 * @endverbatim
 *
 * Multiplication with the Schur matrix @p S is the operation
 * @verbatim
 * S p = C p + B A-inverse Dt-transpose p,
 * @endverbatim
 * which is an operation within the space for @p p.
 *
 * The data handed to the Schur matrix are as follows:
 *
 * @p A: the inverse of @p A is stored, instead of @p A. This
 * allows the application to use the most efficient form of inversion,
 * iterative or direct.
 *
 * @p B, @p C: these matrices are stored "as is".
 *
 * @p Dt: the computation of the Schur complement involves the
 * function @p Tvmult of the matrix @p Dt, not @p vmult! This way,
 * it is sufficient to build only one matrix @p B for the symmetric
 * Schur complement and use it twice.
 *
 * All matrices involved are of arbitrary type and vectors are
 * BlockVectors. This way, @p SchurMatrix can be coupled with
 * any matrix classes providing @p vmult and @p Tvmult and can be
 * even nested. Since SmartPointers of matrices are stored, the
 * matrix blocks should be derived from Subscriptor.
 *
 * Since the Schur complement of a matrix corresponds to a Gaussian
 * block elimination, the right hand side of the condensed system must
 * be preprocessed. Furthermore, the eliminated variable must be
 * reconstructed after solving.
 *
 * @verbatim
 *   g = g + B A-inverse f
 *   u = A-inverse (f - D-transpose p)
 * @endverbatim
 *
 * Applying these transformations, the solution of the system above by a
 * @p SchurMatrix @p schur is coded as follows:
 *
 * @code
 *   schur.prepare_rhs (g, f);
 *   solver.solve (schur, p, g, precondition);
 *   schur.postprocess (u, p);
 * @endcode
 *
 * @see @ref GlossBlockLA "Block (linear algebra)"
 * @author Guido Kanschat, 2000, 2001, 2002
 */
template <class MA_inverse, class MB, class MDt, class MC>
class SchurMatrix : public Subscriptor
{
public:

  /**
   * Constructor. This constructor
   * receives all the matrices
   * needed. Furthermore, it gets a
   * reference to a memory structure
   * for obtaining block vectors.
   *
   * Optionally, the length of the
   * @p u-vector can be provided.
   *
   * For the meaning of the matrices
   * see the class documentation.
   */
  SchurMatrix(const MA_inverse &Ainv,
              const MB &B,
              const MDt &Dt,
              const MC &C,
              VectorMemory<BlockVector<double> > &mem,
              const std::vector<unsigned int> &signature = std::vector<unsigned int>(0));

  /**
   * Do block elimination of the
   * right hand side. Given right
   * hand sides for both components
   * of the block system, this
   * function provides the right hand
   * side for the Schur complement.
   *
   * The result is stored in the
   * first argument, which is also
   * part of the input data. If it is
   * necessary to conserve the data,
   * @p dst must be copied before
   * calling this function. This is
   * reasonable, since in many cases,
   * only the pre-processed right
   * hand side is needed.
   */
  void prepare_rhs (BlockVector<double> &dst,
                    const BlockVector<double> &src) const;

  /**
   * Multiplication with the Schur
   * complement.
   */
  void vmult (BlockVector<double> &dst,
              const BlockVector<double> &src) const;

//  void Tmult(BlockVector<double>& dst, const BlockVector<double>& src) const;

  /**
   * Computation of the residual of
   * the Schur complement.
   */
  double residual (BlockVector<double> &dst,
                   const BlockVector<double> &src,
                   const BlockVector<double> &rhs) const;

  /**
   * Compute the eliminated variable
   * from the solution of the Schur
   * complement problem.
   */
  void postprocess (BlockVector<double> &dst,
                    const BlockVector<double> &src,
                    const BlockVector<double> &rhs) const;

  /**
   * Select debugging information for
   * log-file.  Debug level 1 is
   * defined and writes the norm of
   * every vector before and after
   * each operation. Debug level 0
   * turns off debugging information.
   */
  void debug_level(unsigned int l);
private:
  /**
   * No copy constructor.
   */
  SchurMatrix (const SchurMatrix<MA_inverse, MB, MDt, MC> &);
  /**
   * No assignment.
   */
  SchurMatrix &operator = (const SchurMatrix<MA_inverse, MB, MDt, MC> &);

  /**
   * Pointer to inverse of upper left block.
   */
  const SmartPointer<const MA_inverse,SchurMatrix<MA_inverse,MB,MDt,MC> > Ainv;
  /**
   * Pointer to lower left block.
   */
  const SmartPointer<const MB,SchurMatrix<MA_inverse,MB,MDt,MC> > B;
  /**
   * Pointer to transpose of upper right block.
   */
  const SmartPointer<const MDt,SchurMatrix<MA_inverse,MB,MDt,MC> > Dt;
  /**
   * Pointer to lower right block.
   */
  const SmartPointer<const MC,SchurMatrix<MA_inverse,MB,MDt,MC> > C;
  /**
   * Auxiliary memory for vectors.
   */
  VectorMemory<BlockVector<double> > &mem;

  /**
   * Optional signature of the @p u-vector.
   */
  std::vector<types::global_dof_index> signature;

  /**
   * Switch for debugging information.
   */
  unsigned int debug;
};

/*@}*/
//---------------------------------------------------------------------------

template <class MA_inverse, class MB, class MDt, class MC>
SchurMatrix<MA_inverse, MB, MDt, MC>
::SchurMatrix(const MA_inverse &Ainv,
              const MB &B,
              const MDt &Dt,
              const MC &C,
              VectorMemory<BlockVector<double> > &mem,
              const std::vector<unsigned int> &signature)
  : Ainv(&Ainv), B(&B), Dt(&Dt), C(&C),
    mem(mem),
    signature(signature),
    debug(0)
{
}


template <class MA_inverse, class MB, class MDt, class MC>
void
SchurMatrix<MA_inverse, MB, MDt, MC>
::debug_level(unsigned int l)
{
  debug = l;
}


template <class MA_inverse, class MB, class MDt, class MC>
void SchurMatrix<MA_inverse, MB, MDt, MC>
::vmult(BlockVector<double> &dst,
        const BlockVector<double> &src) const
{
  deallog.push("Schur");
  if (debug > 0)
    deallog << "src:" << src.l2_norm() << std::endl;

  C->vmult(dst, src);
  if (debug > 0)
    deallog << "C:" << dst.l2_norm() << std::endl;

  BlockVector<double> *h1 = mem.alloc();
  if (signature.size()>0)
    h1->reinit(signature);
  else
    h1->reinit(B->n_block_cols(), src.block(0).size());
  Dt->Tvmult(*h1,src);
  if (debug > 0)
    deallog << "Dt:" << h1->l2_norm() << std::endl;

  BlockVector<double> *h2 = mem.alloc();
  h2->reinit(*h1);
  Ainv->vmult(*h2, *h1);
  if (debug > 0)
    deallog << "Ainverse:" << h2->l2_norm() << std::endl;

  mem.free(h1);
  B->vmult_add(dst, *h2);
  if (debug > 0)
    deallog << "dst:" << dst.l2_norm() << std::endl;

  mem.free(h2);
  deallog.pop();
}


template <class MA_inverse, class MB, class MDt, class MC>
double SchurMatrix<MA_inverse, MB, MDt, MC>
::residual(BlockVector<double> &dst,
           const BlockVector<double> &src,
           const BlockVector<double> &rhs) const
{
  vmult(dst, src);
  dst.scale(-1.);
  dst += rhs;
  return dst.l2_norm();
}


template <class MA_inverse, class MB, class MDt, class MC>
void SchurMatrix<MA_inverse, MB, MDt, MC>
::prepare_rhs(BlockVector<double> &dst,
              const BlockVector<double> &src) const
{
  Assert (src.n_blocks() == B->n_block_cols(),
          ExcDimensionMismatch(src.n_blocks(), B->n_block_cols()));
  Assert (dst.n_blocks() == B->n_block_rows(),
          ExcDimensionMismatch(dst.n_blocks(), B->n_block_rows()));

  deallog.push("Schur-prepare");
  if (debug > 0)
    deallog << "src:" << src.l2_norm() << std::endl;
  BlockVector<double> *h1 = mem.alloc();
  if (signature.size()>0)
    h1->reinit(signature);
  else
    h1->reinit(B->n_block_cols(), src.block(0).size());
  Ainv->vmult(*h1, src);
  if (debug > 0)
    deallog << "Ainverse:" << h1->l2_norm() << std::endl;
  B->vmult_add(dst, *h1);
  if (debug > 0)
    deallog << "dst:" << dst.l2_norm() << std::endl;
  mem.free(h1);
  deallog.pop();
}


template <class MA_inverse, class MB, class MDt, class MC>
void SchurMatrix<MA_inverse, MB, MDt, MC>
::postprocess(BlockVector<double> &dst,
              const BlockVector<double> &src,
              const BlockVector<double> &rhs) const
{
  Assert (dst.n_blocks() == B->n_block_cols(),
          ExcDimensionMismatch(dst.n_blocks(), B->n_block_cols()));
  Assert (rhs.n_blocks() == B->n_block_cols(),
          ExcDimensionMismatch(rhs.n_blocks(), B->n_block_cols()));
  Assert (src.n_blocks() == B->n_block_rows(),
          ExcDimensionMismatch(src.n_blocks(), B->n_block_rows()));

  deallog.push("Schur-post");
  if (debug > 0)
    deallog << "src:" << src.l2_norm() << std::endl;
  BlockVector<double> *h1 = mem.alloc();
  if (signature.size()>0)
    h1->reinit(signature);
  else
    h1->reinit(B->n_block_cols(), src.block(0).size());
  Dt->Tvmult(*h1, src);
  if (debug > 0)
    deallog << "Dt:" << h1->l2_norm() << std::endl;
  h1->sadd(-1.,rhs);
  Ainv->vmult(dst,*h1);
  if (debug > 0)
    deallog << "dst:" << dst.l2_norm() << std::endl;
  mem.free(h1);
  deallog.pop();
}


DEAL_II_NAMESPACE_CLOSE

#endif