This file is indexed.

/usr/include/deal.II/lac/swappable_vector.templates.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
//---------------------------------------------------------------------------
//    $Id: swappable_vector.templates.h 18849 2009-05-15 17:59:46Z bangerth $
//    Version: $Name$
//
//    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008 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__swappable_vector_templates_h
#define __deal2__swappable_vector_templates_h


#include <base/memory_consumption.h>
#include <lac/swappable_vector.h>
#include <fstream>

DEAL_II_NAMESPACE_OPEN


template <typename number>
SwappableVector<number>::SwappableVector ()
		:
		data_is_preloaded (false)
{}



template <typename number>
SwappableVector<number>::SwappableVector (const SwappableVector<number> &v) :
		Vector<number>(v),
                filename (),
                data_is_preloaded (false)
{
  Assert (v.filename == "", ExcInvalidCopyOperation());
}



template <typename number>
SwappableVector<number>::~SwappableVector ()
{
				   // if the vector was stored in a
				   // file previously, and that has
				   // not been deleted in the
				   // meantime, then we kill that file
				   // first, before killing the vector
				   // itself

  if (filename != "")
    kill_file ();
}



template <typename number>
SwappableVector<number> &
SwappableVector<number>::operator= (const SwappableVector<number> &v)
{
				   // if necessary, first delete data
  if (filename != "")
    kill_file ();

				   // if in MT mode, block all other
				   // operations. if not in MT mode,
				   // this is a no-op
  Threads::ThreadMutex::ScopedLock lock(this->lock);
  
  Vector<number>::operator = (v);
  data_is_preloaded = false;
  
  return *this;
}



template <typename number>
void SwappableVector<number>::swap_out (const std::string &name)
{
				   // if the vector was stored in
				   // another file previously, and
				   // that has not been deleted in the
				   // meantime, then we kill that file
				   // first
  if (filename != "")
    kill_file ();
  
  filename = name;
  
  Assert (this->size() != 0, ExcSizeZero());

				   // if in MT mode, block all other
				   // operations. if not in MT mode,
				   // this is a no-op
  Threads::ThreadMutex::ScopedLock lock(this->lock);

                                   //  check that we have not called
				   //  @p alert without the respective
				   //  @p reload function
  Assert (data_is_preloaded == false, ExcInternalError());
  
  std::ofstream tmp_out(filename.c_str());
  this->block_write (tmp_out);
  tmp_out.close ();
	
  this->reinit (0);
}



template <typename number>
void SwappableVector<number>::reload () 
{
				   // if in MT mode: synchronise with
				   // possibly existing @p alert
				   // calls. if not in MT mode, this
				   // is a no-op
  lock.acquire ();
  
				   // if data was already preloaded,
				   // then there is no more need to
				   // load it
  if (data_is_preloaded == false)
				     // reload data. note that this
				     // function also releases the
				     // lock
    reload_vector (false);
  else
    {
				       // clear flag since no more
				       // needed
      data_is_preloaded = false;

				       // release lock. the lock is
				       // also released in the other
				       // branch of the if-clause
      lock.release ();
    };
}



template <typename number>
void SwappableVector<number>::alert ()
{
				   // note: this function does nothing
				   // in non-MT mode
  if (!DEAL_II_USE_MT)
    return;
  
				   // synchronise with possible other
				   // invocations of this function and
				   // other functions in this class
  lock.acquire ();
  
				   // calling this function multiple
				   // times does no harm:
  if ( (data_is_preloaded == true) ||
				   // calling this function while the
				   // vector is active does no harm
				   // either
       (this->size() != 0))
    lock.release ();
  else
				     // data has not been preloaded so
				     // far, so go on! For this, start
				     // a detached thread
    Threads::new_thread (&SwappableVector<number>::reload_vector, *this, true);
				   // note that reload_vector also
				   // releases the lock
}



template <typename number>
void SwappableVector<number>::reload_vector (const bool set_flag)
{
  Assert (filename != "", ExcInvalidFilename (filename));
  Assert (this->size() == 0, ExcSizeNonzero());
  
  std::ifstream tmp_in(filename.c_str());
  this->block_read (tmp_in);
  tmp_in.close ();

				   // release the lock that was
				   // acquired by the calling
				   // functions
  if (DEAL_II_USE_MT)
    {
                                       // set the flag if so required
      if (set_flag)
        data_is_preloaded = true;
      lock.release ();
    };
}



template <typename number>
void SwappableVector<number>::kill_file () 
{
				   // if in MT mode, wait for other
				   // operations to finish first
				   // (there should be none, but who
				   // knows). if not in MT mode,
				   // this is a no-op
  Threads::ThreadMutex::ScopedLock lock(this->lock);

				   // this is too bad: someone
				   // requested the vector in advance,
				   // but never got to fetch it. this
				   // is most probably an error, not?
  Assert (data_is_preloaded == false, ExcInternalError());
  
  if (filename != "")
    {
      int status = std::remove (filename.c_str());
      AssertThrow (status == 0, ExcInternalError());
  
      filename = "";
    };
}



template <typename number>
const std::string &
SwappableVector<number>::get_filename () const 
{
  return filename;
}



template <typename number>
unsigned int
SwappableVector<number>::memory_consumption () const
{
  return (MemoryConsumption::memory_consumption (filename) +
	  sizeof(lock) +
	  MemoryConsumption::memory_consumption (data_is_preloaded) +
	  Vector<number>::memory_consumption ());
}




DEAL_II_NAMESPACE_CLOSE

#endif // __deal2__swappable_vector_templates_h