This file is indexed.

/usr/include/dune/grid/onedgrid/onedgridindexsets.hh is in libdune-grid-dev 2.2.1-2.

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
#ifndef DUNE_ONEDGRID_INDEXSETS_HH
#define DUNE_ONEDGRID_INDEXSETS_HH

/** \file
    \brief The index and id sets for the OneDGrid class
*/

#include <vector>

#include <dune/grid/common/indexidset.hh>

#include <dune/grid/onedgrid/onedgridlist.hh>
#include <dune/grid/onedgrid/onedgridentity.hh>

namespace Dune {

template<class GridImp>
class OneDGridLevelIndexSet : public IndexSet<GridImp,OneDGridLevelIndexSet<GridImp> >
{
public:

    /** \brief Constructor for a given level of a given grid
    */
    OneDGridLevelIndexSet (const GridImp& grid, int level) 
        : grid_(&grid), level_(level)
    {}

  //! get index of an entity
  template<int cd>
  int index (const typename GridImp::Traits::template Codim<cd>::Entity& e) const 
  {
      return grid_->getRealImplementation(e).levelIndex(); 
  }

  //! get index of subentity of an entity
  template<int cc>
  unsigned int subIndex (const typename GridImp::Traits::template Codim<cc>::Entity& e, 
                         int i,
                         unsigned int codim) const
  {
      if( cc == 0 )
          return grid_->getRealImplementation(e).subLevelIndex(i,codim);
      else
          return grid_->getRealImplementation(e).levelIndex(); 
  }

  //! get number of entities of given type and on this level
  int size (GeometryType type) const
  {
      return grid_->size(level_,type);
  }

  //! get number of entities of given codim, type and on this level
  int size (int codim) const
  {
      return grid_->size(level_,codim);
  }

    /** \brief Deliver all geometry types used in this grid */
  const std::vector<GeometryType>& geomTypes (int codim) const
  {
	return myTypes_[codim];
  }

    /** \brief Return true if e is contained in the index set.
        
    Warning: this implementation takes O(n) time!  It also assumes that e belongs
    to the correct grid.
    */
    template <class EntityType>
    bool contains (const EntityType& e) const
    {
        // If the entity isn't on the same level as this index set it cannot be contained in the index set
        if (e.level() != level_)
            return false;

        enum { cd = EntityType::codimension };
        typedef typename GridImp::template Codim<cd>::template Partition<All_Partition>::LevelIterator IteratorType; 
        IteratorType iend = grid_->template lend<cd,All_Partition>(level_);
        for (IteratorType it = grid_->template lbegin<cd,All_Partition>(level_);
             it != iend; ++it)
            {
                if (this->template index<cd>(*it) == this->template index<cd>(e)) 
                    return true;
            }
        return false; 
    }

    /** \brief Sets the corresponding internal fields.  Used by the GridFactory */
    void setSizesAndTypes(unsigned int numVertices, unsigned int numElements) {

        numVertices_ = numVertices;
        numElements_ = numElements;

        // ///////////////////////////////////////////////
        //   Update the list of geometry types present
        // ///////////////////////////////////////////////
        if (numElements_>0) {
            myTypes_[0].resize(1);
            myTypes_[0][0] = GeometryType(1);
        } else
            myTypes_[0].resize(0);

        if (numVertices_>0) {
            myTypes_[1].resize(1);
            myTypes_[1][0] = GeometryType(0);
        } else
            myTypes_[1].resize(0);

    }

    /** \todo Should be private */
    void update() {

        // ///////////////////////////////
        //   Init the element indices
        // ///////////////////////////////
        numElements_ = 0;
        OneDGridList<OneDEntityImp<1> >::const_iterator eIt;
        for (eIt = grid_->elements(level_).begin(); eIt != grid_->elements(level_).end(); eIt = eIt->succ_)
            /** \todo Remove this const cast */
            const_cast<OneDEntityImp<1>*>(eIt)->levelIndex_ = numElements_++;

        // //////////////////////////////
        //   Init the vertex indices
        // //////////////////////////////

        numVertices_ = 0;
        OneDGridList<OneDEntityImp<0> >::const_iterator vIt;
        for (vIt = grid_->vertices(level_).begin(); vIt != grid_->vertices(level_).end(); vIt = vIt->succ_)
            /** \todo Remove this const cast */
            const_cast<OneDEntityImp<0>*>(vIt)->levelIndex_ = numVertices_++;

        // set the list of geometry types
        setSizesAndTypes(numVertices_, numElements_);
    }

private:
  const GridImp* grid_;
  int level_;

    int numElements_;
    int numVertices_;

    /** \brief The GeometryTypes present for each codim */
  std::vector<GeometryType> myTypes_[2];
};

template<class GridImp>
class OneDGridLeafIndexSet : 
  public IndexSet<GridImp,OneDGridLeafIndexSet<GridImp> >
{
public:
  //! constructor stores reference to a grid and level
  OneDGridLeafIndexSet (const GridImp& g) : grid_(g)
  {
  }

  //! get index of an entity
  /*
    We use the remove_const to extract the Type from the mutable class,
    because the const class is not instantiated yet.
  */
  template<int cd>
  int index (const typename remove_const<GridImp>::type::Traits::template Codim<cd>::Entity& e) const 
  {
      return grid_.getRealImplementation(e).leafIndex(); 
  }

  //! get index of subentity of an entity
  template<int cc>
  int subIndex (const typename remove_const<GridImp>::type::Traits::template Codim<cc>::Entity& e, 
                int i,
                unsigned int codim) const
  {
      if( cc == 0 )
          return grid_.getRealImplementation(e).subLeafIndex(i,codim);
      else
          return grid_.getRealImplementation(e).leafIndex(); 
  }

  //! get number of entities of given codim, type on the leaf level
  int size (GeometryType type) const
  {
      if (type.isVertex()) {

          return numVertices_;

      } else if (type.isLine()) {

          return numElements_;

      } 

      return 0;
  }

  //! get number of entities of given codim, type on the leaf level
  int size(int codim) const 
  {
      if (codim==1) {

          return numVertices_;
          
      } else if (codim==0) {
          
          return numElements_;

      } 

      return 0;
  } 

  /** deliver all geometry types used in this grid */
  const std::vector<GeometryType>& geomTypes (int codim) const
  {
	return myTypes_[codim];
  }

        /** \brief Return true if e is contained in the index set.
        
    Warning: this implementation takes O(n) time!  It also assumes that e belongs
    to the correct grid.
    */
    template <class EntityType>
    bool contains (const EntityType& e) const
    {
        enum { cd = EntityType::codimension };
        typedef typename GridImp::template Codim<cd>::template Partition<All_Partition>::LeafIterator IteratorType; 
        IteratorType iend = grid_.template leafend<cd,All_Partition>();
        for (IteratorType it = grid_.template leafbegin<cd,All_Partition>();
             it != iend; ++it)
            {
                if (it->level() == e.level() && this->template index<cd>(*it) == this->template index<cd>(e)) 
                    return true;
            }
        return false; 
    }

    /** \brief Sets the corresponding internal fields.  Used by the GridFactory */
    void setSizesAndTypes(unsigned int numVertices, unsigned int numElements) {

        numVertices_ = numVertices;
        numElements_ = numElements;

        // ///////////////////////////////////////////////
        //   Update the list of geometry types present
        // ///////////////////////////////////////////////
        if (numElements_>0) {
            myTypes_[0].resize(1);
            myTypes_[0][0] = GeometryType(1);
        } else
            myTypes_[0].resize(0);

        if (numVertices_>0) {
            myTypes_[1].resize(1);
            myTypes_[1][0] = GeometryType(0);
        } else
            myTypes_[1].resize(0);

    }

    /** \todo Should be private */
    void update() {

        // ///////////////////////////////
        //   Init the element indices
        // ///////////////////////////////
        numElements_ = 0;
        typename GridImp::Traits::template Codim<0>::LeafIterator eIt    = grid_.template leafbegin<0>();
        typename GridImp::Traits::template Codim<0>::LeafIterator eEndIt = grid_.template leafend<0>();
        
        for (; eIt!=eEndIt; ++eIt) {
         
            grid_.getRealImplementation(*eIt).target_->leafIndex_ = numElements_++;

        }

        // //////////////////////////////
        //   Init the vertex indices
        // //////////////////////////////

        numVertices_ = 0;

        for (int i=grid_.maxLevel(); i>=0; i--) {

            const OneDEntityImp<0>* vIt;
            for (vIt = grid_.vertices(i).begin(); vIt != grid_.vertices(i).end(); vIt = vIt->succ_) {
                
                /** \todo Remove the const casts */
                if (vIt->isLeaf())
                    const_cast<OneDEntityImp<0>*>(vIt)->leafIndex_ = numVertices_++;
                else
                    const_cast<OneDEntityImp<0>*>(vIt)->leafIndex_ = vIt->son_->leafIndex_;

            }

        }

        // set the list of geometry types
        setSizesAndTypes(numVertices_, numElements_);

    }

private:

    const GridImp& grid_;

    int numElements_;
    int numVertices_;

    /** \brief The GeometryTypes present for each codim */
    std::vector<GeometryType> myTypes_[2];
};


template<class GridImp>
class OneDGridIdSet : public IdSet<GridImp,OneDGridIdSet<GridImp>,unsigned int>
{
public:
  //! define the type used for persistent indices
  typedef unsigned int IdType;

  //! constructor stores reference to a grid
  OneDGridIdSet (const GridImp& g) : grid_(g) {}

  //! get id of an entity
  /*
    We use the remove_const to extract the Type from the mutable class,
    because the const class is not instantiated yet.
  */
  template<int cd>
  IdType id (const typename remove_const<GridImp>::type::Traits::template Codim<cd>::Entity& e) const 
  {
      return grid_.getRealImplementation(e).globalId();
  }

  //! get id of subentity
  IdType subId (const typename remove_const<GridImp>::type::Traits::template Codim<0>::Entity& e, 
                int i,
                unsigned int codim) const
  {
      return grid_.getRealImplementation(e).subId(i,codim);
  }

private:

  const GridImp& grid_;
};

}  // namespace Dune


#endif