This file is indexed.

/usr/include/deal.II/meshworker/functional.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
// ---------------------------------------------------------------------
//
// 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__mesh_worker_functional_h
#define dealii__mesh_worker_functional_h

#include <deal.II/algorithms/any_data.h>
#include <deal.II/base/smartpointer.h>
#include <deal.II/base/mg_level_object.h>
#include <deal.II/lac/block_vector.h>
#include <deal.II/meshworker/dof_info.h>
#include <deal.II/multigrid/mg_constrained_dofs.h>


DEAL_II_NAMESPACE_OPEN

namespace MeshWorker
{
  namespace Assembler
  {
    /**
     * The class assembling local contributions to a functional into global
     * functionals.
     *
     *
     *
     * @ingroup MeshWorker
     * @author Guido Kanschat, 2009
     */
    template <typename number = double>
    class Functional
    {
    public:
      /**
       * Initialize local data to store functionals. The number <tt>n</tt> is
       * the number of functionals to be computed.
       */
      void initialize(const unsigned int n);
      /**
       * Initialize the local data in the DoFInfo object used later for
       * assembling.
       *
       * The info object refers to a cell if <code>!face</code>, or else to an
       * interior or boundary face.
       */
      template <class DOFINFO>
      void initialize_info(DOFINFO &info, bool face);

      /**
       * Assemble the local values into the global vectors.
       */
      template<class DOFINFO>
      void assemble(const DOFINFO &info);

      /**
       * Assemble both local values into the global vectors.
       */
      template<class DOFINFO>
      void assemble(const DOFINFO &info1,
                    const DOFINFO &info2);

      /**
       * The value of the ith entry in #results.
       */
      number operator() (const unsigned int i) const;
    private:
      /**
       * The values into which the results are added.
       */
      std::vector<double> results;
    };

    /**
     * Compute cell and face contributions of one or several functionals,
     * typically for error estimates.
     *
     * @ingroup MeshWorker
     * @author Guido Kanschat, 2009
     */
    template <typename number = double>
    class CellsAndFaces
    {
    public:
      /**
       * The initialization function, specifying the @p results vectors and
       * whether face data should be collected separately.
       *
       * @p results should contain two block vectors named "cells" and "faces"
       * (the latter only if @p separate_faces is true). In each of the two,
       * each block should have equal size and be large enough to accommodate
       * all user indices set in the cells and faces covered by the loop it is
       * used in. Typically, for estimators, this is
       * Triangulation::n_active_cells() and Triangulation::n_faces(),
       * respectively.
       *
       * The use of BlockVector may seem cumbersome, but it allows us to
       * assemble several functionals at the same time, one in each block. The
       * typical situation for error estimate is just having a single block in
       * each vector.
       */
      void initialize(AnyData &results, bool separate_faces = true);

      /**
       * Initialize the local data in the DoFInfo object used later for
       * assembling.
       *
       * The info object refers to a cell if <code>!face</code>, or else to an
       * interior or boundary face.
       */
      template <class DOFINFO>
      void initialize_info(DOFINFO &info, bool face) const;

      /**
       * Assemble the local values into the global vectors.
       */
      template<class DOFINFO>
      void assemble(const DOFINFO &info);

      /**
       * Assemble both local values into the global vectors.
       */
      template<class DOFINFO>
      void assemble(const DOFINFO &info1,
                    const DOFINFO &info2);

      /**
       * The value of the ith entry in @p results.
       */
      number operator() (const unsigned int i) const;
    private:
      AnyData results;
      bool separate_faces;
    };
//----------------------------------------------------------------------//

    template <typename number>
    inline void
    Functional<number>::initialize(const unsigned int n)
    {
      results.resize(n);
      std::fill(results.begin(), results.end(), 0.);
    }


    template <typename number>
    template <class DOFINFO>
    inline void
    Functional<number>::initialize_info(DOFINFO &info, bool)
    {
      info.initialize_numbers(results.size());
    }


    template <typename number>
    template <class DOFINFO>
    inline void
    Functional<number>::assemble(const DOFINFO &info)
    {
      for (unsigned int i=0; i<results.size(); ++i)
        results[i] += info.value(i);
    }


    template <typename number>
    template <class DOFINFO>
    inline void
    Functional<number>::assemble(const DOFINFO &info1,
                                 const DOFINFO &info2)
    {
      for (unsigned int i=0; i<results.size(); ++i)
        {
          results[i] += info1.value(i);
          results[i] += info2.value(i);
        }
    }


    template <typename number>
    inline number
    Functional<number>::operator() (const unsigned int i) const
    {
      AssertIndexRange(i, results.size());
      return results[i];
    }

//----------------------------------------------------------------------//

    template <typename number>
    inline void
    CellsAndFaces<number>::initialize(AnyData &r, bool sep)
    {
      Assert(r.name(0) == "cells", AnyData::ExcNameMismatch(0, "cells"));
      if (sep)
        {
          Assert(r.name(1) == "faces", AnyData::ExcNameMismatch(1, "faces"));
          AssertDimension(r.entry<BlockVector<double>*>(0)->n_blocks(),
                          r.entry<BlockVector<double>*>(1)->n_blocks());
        }

      results = r;
      separate_faces = sep;
    }

    template <typename number>
    template <class DOFINFO>
    inline void
    CellsAndFaces<number>::initialize_info(DOFINFO &info, bool) const
    {
      info.initialize_numbers(results.entry<BlockVector<double>*>(0)->n_blocks());
    }


    template <typename number>
    template <class DOFINFO>
    inline void
    CellsAndFaces<number>::assemble(const DOFINFO &info)
    {
      BlockVector<double> *v;
      if (separate_faces &&
          info.face_number != numbers::invalid_unsigned_int)
        v = results.entry<BlockVector<double>*>(1);
      else
        v = results.entry<BlockVector<double>*>(0);

      for (unsigned int i=0; i<info.n_values(); ++i)
        v->block(i)(info.cell->user_index()) += info.value(i);
    }


    template <typename number>
    template <class DOFINFO>
    inline void
    CellsAndFaces<number>::assemble(const DOFINFO &info1,
                                    const DOFINFO &info2)
    {
      for (unsigned int i=0; i<info1.n_values(); ++i)
        {
          if (separate_faces)
            {
              BlockVector<double> *v1 = results.entry<BlockVector<double>*>(1);
              const double J = info1.value(i) + info2.value(i);
              v1->block(i)(info1.face->user_index()) += J;
              if (info2.face != info1.face)
                v1->block(i)(info2.face->user_index()) += J;
            }
          else
            {
              BlockVector<double> *v0 = results.entry<BlockVector<double>*>(0);
              v0->block(i)(info1.cell->user_index()) += .5*info1.value(i);
              v0->block(i)(info2.cell->user_index()) += .5*info2.value(i);
            }
        }
    }
  }
}

DEAL_II_NAMESPACE_CLOSE

#endif