This file is indexed.

/usr/include/deal.II/integrators/maxwell.h is in libdeal.ii-dev 8.4.2-2+b1.

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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
// ---------------------------------------------------------------------
//
// Copyright (C) 2010 - 2015 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 dealii__integrators_maxwell_h
#define dealii__integrators_maxwell_h


#include <deal.II/base/config.h>
#include <deal.II/base/exceptions.h>
#include <deal.II/base/quadrature.h>
#include <deal.II/lac/full_matrix.h>
#include <deal.II/fe/mapping.h>
#include <deal.II/fe/fe_values.h>
#include <deal.II/meshworker/dof_info.h>

DEAL_II_NAMESPACE_OPEN

namespace LocalIntegrators
{
  /**
   * @brief Local integrators related to curl operators and their traces.
   *
   * We use the following conventions for curl operators. First, in three
   * space dimensions
   *
   * @f[
   * \nabla\times \mathbf u = \begin{pmatrix}
   *   \partial_3 u_2 - \partial_2 u_3 \\
   *   \partial_1 u_3 - \partial_3 u_1 \\
   *   \partial_2 u_1 - \partial_1 u_2
   * \end{pmatrix}.
   * @f]
   *
   * In two space dimensions, the curl is obtained by extending a vector
   * <b>u</b> to $(u_1, u_2, 0)^T$ and a scalar <i>p</i> to $(0,0,p)^T$.
   * Computing the nonzero components, we obtain the scalar curl of a vector
   * function and the vector curl of a scalar function. The current
   * implementation exchanges the sign and we have:
   * @f[
   *  \nabla \times \mathbf u = \partial_1 u_2 - \partial 2 u_1,
   *  \qquad
   *  \nabla \times p = \begin{pmatrix}
   *    \partial_2 p \\ -\partial_1 p
   *  \end{pmatrix}
   * @f]
   *
   * @ingroup Integrators
   * @author Guido Kanschat
   * @date 2010
   */
  namespace Maxwell
  {
    /**
     * Auxiliary function. Given the tensors of <tt>dim</tt> second
     * derivatives, compute the curl of the curl of a vector function. The
     * result in two and three dimensions is:
     * @f[
     * \nabla\times\nabla\times \mathbf u = \begin{pmatrix}
     * \partial_1\partial_2 u_2 - \partial_2^2 u_1 \\
     * \partial_1\partial_2 u_1 - \partial_1^2 u_2
     * \end{pmatrix}
     *
     * \nabla\times\nabla\times \mathbf u = \begin{pmatrix}
     * \partial_1\partial_2 u_2 + \partial_1\partial_3 u_3
     * - (\partial_2^2+\partial_3^2) u_1 \\
     * \partial_2\partial_3 u_3 + \partial_2\partial_1 u_1
     * - (\partial_3^2+\partial_1^2) u_2 \\
     * \partial_3\partial_1 u_1 + \partial_3\partial_2 u_2
     * - (\partial_1^2+\partial_2^2) u_3
     * \end{pmatrix}
     * @f]
     *
     * @note The third tensor argument is not used in two dimensions and can
     * for instance duplicate one of the previous.
     *
     * @author Guido Kanschat
     * @date 2011
     */
    template <int dim>
    Tensor<1,dim>
    curl_curl (
      const Tensor<2,dim> &h0,
      const Tensor<2,dim> &h1,
      const Tensor<2,dim> &h2)
    {
      Tensor<1,dim> result;
      switch (dim)
        {
        case 2:
          result[0] = h1[0][1]-h0[1][1];
          result[1] = h0[0][1]-h1[0][0];
          break;
        case 3:
          result[0] = h1[0][1]+h2[0][2]-h0[1][1]-h0[2][2];
          result[1] = h2[1][2]+h0[1][0]-h1[2][2]-h1[0][0];
          result[2] = h0[2][0]+h1[2][1]-h2[0][0]-h2[1][1];
          break;
        default:
          Assert(false, ExcNotImplemented());
        }
      return result;
    }

    /**
     * Auxiliary function. Given <tt>dim</tt> tensors of first derivatives and
     * a normal vector, compute the tangential curl
     * @f[
     * \mathbf n \times \nabla \times u.
     * @f]
     *
     * @note The third tensor argument is not used in two dimensions and can
     * for instance duplicate one of the previous.
     *
     * @author Guido Kanschat
     * @date 2011
     */
    template <int dim>
    Tensor<1,dim>
    tangential_curl (
      const Tensor<1,dim> &g0,
      const Tensor<1,dim> &g1,
      const Tensor<1,dim> &g2,
      const Tensor<1,dim> &normal)
    {
      Tensor<1,dim> result;

      switch (dim)
        {
        case 2:
          result[0] = normal[1] * (g1[0]-g0[1]);
          result[1] =-normal[0] * (g1[0]-g0[1]);
          break;
        case 3:
          result[0] = normal[2]*(g2[1]-g0[2])+normal[1]*(g1[0]-g0[1]);
          result[1] = normal[0]*(g0[2]-g1[0])+normal[2]*(g2[1]-g1[2]);
          result[2] = normal[1]*(g1[0]-g2[1])+normal[0]*(g0[2]-g2[0]);
          break;
        default:
          Assert(false, ExcNotImplemented());
        }
      return result;
    }

    /**
     * The curl-curl operator
     * @f[
     * \int_Z \nabla\!\times\! u \cdot
     * \nabla\!\times\! v \,dx
     * @f]
     * in weak form.
     *
     * @author Guido Kanschat
     * @date 2011
     */
    template <int dim>
    void curl_curl_matrix (
      FullMatrix<double> &M,
      const FEValuesBase<dim> &fe,
      const double factor = 1.)
    {
      const unsigned int n_dofs = fe.dofs_per_cell;

      AssertDimension(fe.get_fe().n_components(), dim);
      AssertDimension(M.m(), n_dofs);
      AssertDimension(M.n(), n_dofs);

      // Depending on the dimension,
      // the cross product is either
      // a scalar (2d) or a vector
      // (3d). Accordingly, in the
      // latter case we have to sum
      // up three bilinear forms, but
      // in 2d, we don't. Thus, we
      // need to adapt the loop over
      // all dimensions
      const unsigned int d_max = (dim==2) ? 1 : dim;

      for (unsigned int k=0; k<fe.n_quadrature_points; ++k)
        {
          const double dx = factor * fe.JxW(k);
          for (unsigned int i=0; i<n_dofs; ++i)
            for (unsigned int j=0; j<n_dofs; ++j)
              for (unsigned int d=0; d<d_max; ++d)
                {
                  const unsigned int d1 = (d+1)%dim;
                  const unsigned int d2 = (d+2)%dim;

                  const double cv = fe.shape_grad_component(i,k,d1)[d2] - fe.shape_grad_component(i,k,d2)[d1];
                  const double cu = fe.shape_grad_component(j,k,d1)[d2] - fe.shape_grad_component(j,k,d2)[d1];

                  M(i,j) += dx * cu * cv;
                }
        }
    }

    /**
     * The matrix for the curl operator
     * @f[
     * \int_Z \nabla\!\times\! u \cdot v \,dx.
     * @f]
     *
     * This is the standard curl operator in 3D and the scalar curl in 2D. The
     * vector curl operator can be obtained by exchanging test and trial
     * functions.
     *
     * @author Guido Kanschat
     * @date 2011
     */
    template <int dim>
    void curl_matrix (
      FullMatrix<double> &M,
      const FEValuesBase<dim> &fe,
      const FEValuesBase<dim> &fetest,
      double factor = 1.)
    {
      unsigned int t_comp = (dim==3) ? dim : 1;
      const unsigned int n_dofs = fe.dofs_per_cell;
      const unsigned int t_dofs = fetest.dofs_per_cell;
      AssertDimension(fe.get_fe().n_components(), dim);
      AssertDimension(fetest.get_fe().n_components(), t_comp);
      AssertDimension(M.m(), t_dofs);
      AssertDimension(M.n(), n_dofs);

      const unsigned int d_max = (dim==2) ? 1 : dim;

      for (unsigned int k=0; k<fe.n_quadrature_points; ++k)
        {
          const double dx = fe.JxW(k) * factor;
          for (unsigned int i=0; i<t_dofs; ++i)
            for (unsigned int j=0; j<n_dofs; ++j)
              for (unsigned int d=0; d<d_max; ++d)
                {
                  const unsigned int d1 = (d+1)%dim;
                  const unsigned int d2 = (d+2)%dim;

                  const double vv = fetest.shape_value_component(i,k,d);
                  const double cu = fe.shape_grad_component(j,k,d1)[d2] - fe.shape_grad_component(j,k,d2)[d1];
                  M(i,j) += dx * cu * vv;
                }
        }
    }

    /**
     * The matrix for weak boundary condition of Nitsche type for the
     * tangential component in Maxwell systems.
     *
     * @f[
     * \int_F \biggl( 2\gamma
     * (u\times n) (v\times n) -
     * (u\times n)(\nu \nabla\times
     * v) - (v\times
     * n)(\nu \nabla\times u)
     * \biggr)
     * @f]
     *
     * @author Guido Kanschat
     * @date 2011
     */
    template <int dim>
    void nitsche_curl_matrix (
      FullMatrix<double> &M,
      const FEValuesBase<dim> &fe,
      double penalty,
      double factor = 1.)
    {
      const unsigned int n_dofs = fe.dofs_per_cell;

      AssertDimension(fe.get_fe().n_components(), dim);
      AssertDimension(M.m(), n_dofs);
      AssertDimension(M.n(), n_dofs);

      // Depending on the
      // dimension, the cross
      // product is either a scalar
      // (2d) or a vector
      // (3d). Accordingly, in the
      // latter case we have to sum
      // up three bilinear forms,
      // but in 2d, we don't. Thus,
      // we need to adapt the loop
      // over all dimensions
      const unsigned int d_max = (dim==2) ? 1 : dim;

      for (unsigned int k=0; k<fe.n_quadrature_points; ++k)
        {
          const double dx = factor * fe.JxW(k);
          const Tensor<1,dim> n = fe.normal_vector(k);
          for (unsigned int i=0; i<n_dofs; ++i)
            for (unsigned int j=0; j<n_dofs; ++j)
              for (unsigned int d=0; d<d_max; ++d)
                {
                  const unsigned int d1 = (d+1)%dim;
                  const unsigned int d2 = (d+2)%dim;

                  const double cv = fe.shape_grad_component(i,k,d1)[d2] - fe.shape_grad_component(i,k,d2)[d1];
                  const double cu = fe.shape_grad_component(j,k,d1)[d2] - fe.shape_grad_component(j,k,d2)[d1];
                  const double v= fe.shape_value_component(i,k,d1)*n(d2) - fe.shape_value_component(i,k,d2)*n(d1);
                  const double u= fe.shape_value_component(j,k,d1)*n(d2) - fe.shape_value_component(j,k,d2)*n(d1);

                  M(i,j) += dx*(2.*penalty*u*v - cv*u - cu*v);
                }
        }
    }
    /**
     * The product of two tangential traces,
     * @f[
     * \int_F (u\times n)(v\times n)
     * \, ds.
     * @f]
     *
     * @author Guido Kanschat
     * @date 2011
     */
    template <int dim>
    void tangential_trace_matrix (
      FullMatrix<double> &M,
      const FEValuesBase<dim> &fe,
      double factor = 1.)
    {
      const unsigned int n_dofs = fe.dofs_per_cell;

      AssertDimension(fe.get_fe().n_components(), dim);
      AssertDimension(M.m(), n_dofs);
      AssertDimension(M.n(), n_dofs);

      // Depending on the
      // dimension, the cross
      // product is either a scalar
      // (2d) or a vector
      // (3d). Accordingly, in the
      // latter case we have to sum
      // up three bilinear forms,
      // but in 2d, we don't. Thus,
      // we need to adapt the loop
      // over all dimensions
      const unsigned int d_max = (dim==2) ? 1 : dim;

      for (unsigned int k=0; k<fe.n_quadrature_points; ++k)
        {
          const double dx = factor * fe.JxW(k);
          const Tensor<1,dim> n = fe.normal_vector(k);
          for (unsigned int i=0; i<n_dofs; ++i)
            for (unsigned int j=0; j<n_dofs; ++j)
              for (unsigned int d=0; d<d_max; ++d)
                {
                  const unsigned int d1 = (d+1)%dim;
                  const unsigned int d2 = (d+2)%dim;

                  const double v= fe.shape_value_component(i,k,d1)*n(d2) - fe.shape_value_component(i,k,d2)*n(d1);
                  const double u= fe.shape_value_component(j,k,d1)*n(d2) - fe.shape_value_component(j,k,d2)*n(d1);

                  M(i,j) += dx*u*v;
                }
        }
    }

    /**
     * The interior penalty fluxes for Maxwell systems.
     *
     * @f[
     * \int_F \biggl( \gamma
     * \{u\times n\}\{v\times n\} -
     * \{u\times n\}\{\nu \nabla\times
     * v\}- \{v\times
     * n\}\{\nu \nabla\times u\}
     * \biggr)\;dx
     * @f]
     *
     * @author Guido Kanschat
     * @date 2011
     */
    template <int dim>
    inline void ip_curl_matrix (
      FullMatrix<double> &M11,
      FullMatrix<double> &M12,
      FullMatrix<double> &M21,
      FullMatrix<double> &M22,
      const FEValuesBase<dim> &fe1,
      const FEValuesBase<dim> &fe2,
      const double pen,
      const double factor1 = 1.,
      const double factor2 = -1.)
    {
      const unsigned int n_dofs = fe1.dofs_per_cell;

      AssertDimension(fe1.get_fe().n_components(), dim);
      AssertDimension(fe2.get_fe().n_components(), dim);
      AssertDimension(M11.m(), n_dofs);
      AssertDimension(M11.n(), n_dofs);
      AssertDimension(M12.m(), n_dofs);
      AssertDimension(M12.n(), n_dofs);
      AssertDimension(M21.m(), n_dofs);
      AssertDimension(M21.n(), n_dofs);
      AssertDimension(M22.m(), n_dofs);
      AssertDimension(M22.n(), n_dofs);

      const double nu1 = factor1;
      const double nu2 = (factor2 < 0) ? factor1 : factor2;
      const double penalty = .5 * pen * (nu1 + nu2);

      // Depending on the
      // dimension, the cross
      // product is either a scalar
      // (2d) or a vector
      // (3d). Accordingly, in the
      // latter case we have to sum
      // up three bilinear forms,
      // but in 2d, we don't. Thus,
      // we need to adapt the loop
      // over all dimensions
      const unsigned int d_max = (dim==2) ? 1 : dim;

      for (unsigned int k=0; k<fe1.n_quadrature_points; ++k)
        {
          const double dx = fe1.JxW(k);
          const Tensor<1,dim> n = fe1.normal_vector(k);
          for (unsigned int i=0; i<n_dofs; ++i)
            for (unsigned int j=0; j<n_dofs; ++j)
              for (unsigned int d=0; d<d_max; ++d)
                {
                  const unsigned int d1 = (d+1)%dim;
                  const unsigned int d2 = (d+2)%dim;
                  // curl u, curl v
                  const double cv1 = nu1*fe1.shape_grad_component(i,k,d1)[d2] - fe1.shape_grad_component(i,k,d2)[d1];
                  const double cv2 = nu2*fe2.shape_grad_component(i,k,d1)[d2] - fe2.shape_grad_component(i,k,d2)[d1];
                  const double cu1 = nu1*fe1.shape_grad_component(j,k,d1)[d2] - fe1.shape_grad_component(j,k,d2)[d1];
                  const double cu2 = nu2*fe2.shape_grad_component(j,k,d1)[d2] - fe2.shape_grad_component(j,k,d2)[d1];

                  // u x n, v x n
                  const double u1= fe1.shape_value_component(j,k,d1)*n(d2) - fe1.shape_value_component(j,k,d2)*n(d1);
                  const double u2=-fe2.shape_value_component(j,k,d1)*n(d2) + fe2.shape_value_component(j,k,d2)*n(d1);
                  const double v1= fe1.shape_value_component(i,k,d1)*n(d2) - fe1.shape_value_component(i,k,d2)*n(d1);
                  const double v2=-fe2.shape_value_component(i,k,d1)*n(d2) + fe2.shape_value_component(i,k,d2)*n(d1);

                  M11(i,j) += .5*dx*(2.*penalty*u1*v1 - cv1*u1 - cu1*v1);
                  M12(i,j) += .5*dx*(2.*penalty*v1*u2 - cv1*u2 - cu2*v1);
                  M21(i,j) += .5*dx*(2.*penalty*u1*v2 - cv2*u1 - cu1*v2);
                  M22(i,j) += .5*dx*(2.*penalty*u2*v2 - cv2*u2 - cu2*v2);
                }
        }
    }


  }
}


DEAL_II_NAMESPACE_CLOSE

#endif