This file is indexed.

/usr/include/trilinos/InputData.hpp is in libtrilinos-dev 10.4.0.dfsg-1ubuntu2.

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

/*--------------------------------------------------------------------*/
/*    Copyright 2005 Sandia Corporation.                              */
/*    Under the terms of Contract DE-AC04-94AL85000, there is a       */
/*    non-exclusive license for use of this work by or on behalf      */
/*    of the U.S. Government.  Export of this program may require     */
/*    a license from the United States Government.                    */
/*--------------------------------------------------------------------*/

#include <fei_macros.hpp>

#include <vector>

class ElemContribution {
 public:
  ElemContribution(){}
  ElemContribution(const ElemContribution& src)
    {
      rhsContributions = src.rhsContributions;
    }

  ~ElemContribution(){}

  bool operator==(const ElemContribution& rhs)
    {
      if (matrixContributions != rhs.matrixContributions) {
	cout << "matrixContributions don't match." << endl;
	return(false);
      }

      if ( rhsContributions != rhs.rhsContributions ) {
	cout << "rhsContributions don't match." << endl;
	return(false);
      }

      return(true);
    }

  bool operator!=(const ElemContribution& rhs)
    {
      return( !( *this == rhs) );
    }

  std::vector<double> matrixContributions;
  std::vector<double> rhsContributions;
};

class InputData {
 public:
  InputData(){}
  ~InputData()
    {
      for(int i=0; i<elemIDs.length(); i++) delete elemIDs[i];
    }

  std::vector<int> elemBlockIDs;
  std::vector<std::vector<int>*> elemIDs;
  std::vector<std::vector<ElemContribution>*> elemContributions;

  bool operator==(const InputData& rhs)
    {
      if (elemBlockIDs != rhs.elemBlockIDs) {
	cout << "elemBlockIDs don't match." << endl;
	return(false);
      }

      for(int i=0; i<elemIDs.length(); i++) {
	std::vector<ElemContribution>& elems = *(elemContributions[i]);
	std::vector<ElemContribution>& rhsElems = *(rhs.elemContributions[i]);

	for(int j=0; j<elemIDs[i]->length(); j++) {
	  int id1 = (*(elemIDs[i]))[j];
	  int id2 = (*(rhs.elemIDs[i]))[j];

	  if ( id1 != id2 ) {
	    cout << "elemIDs don't match. element-block " << elemBlockIDs[i]
		 << ", elemID in position " << j << " is " << id1
		 << ", doesn't match " << id2 << "." << endl;
	    return(false);
	  }

	  if (elems[j] != rhsElems[j]) {
	    cout << "element-block " << elemBlockIDs[i] << ", elemID " << id1
	      << "'s element-contributions don't match." << endl;
	    return(false);
	  }
	}
      }

      return(true);
    }

  bool operator!=(const InputData& rhs)
    {
      return( !( (*this) == rhs) );
    }

  int addElemID(int elemBlockID, int elemID)
    {
      //add and elemBlockID/elemID pair to the internal arrays if not already
      //present.

      int err, insertPoint = -1;
      int blkInd = elemBlockIDs.binarySearch(elemBlockID, insertPoint);
      if (blkInd < 0) {
	err = elemBlockIDs.insert(elemBlockIDs.begin()+insertPoint, elemBlockID);
	err += elemIDs.insert(elemIDs.begin()+insertPoint, new std::vector<int>);
	err += elemContributions.insert(elemContributions.begin()+insertPoint, new std::vector<ElemContribution>);
	if (err != 0) return(err);
	blkInd = insertPoint;
      }

      std::vector<int>& IDs = *(elemIDs[blkInd]);
      std::vector<ElemContribution>& ec = *(elemContributions[blkInd]);

      err = IDs.insertSorted(elemID);      
      if (err == -2) return(err);

      ElemContribution dummy;
      if (err >= 0) err = ec.insert(ec.begin()+err, dummy);
      if (err == -2) return(err);

      return(0);
    }

  int addElemMatrix(int elemBlockID, int elemID, std::vector<double>& matrixData)
    {
      int insertPoint = -1;
      int blkInd = elemBlockIDs.binarySearch(elemBlockID, insertPoint);
      if (blkInd < 0) {
	cerr << " addElemMatrix ERROR, elemBlockID " << (int)elemBlockID
	     << " not found" << endl;
	return(-1);
      }

      int elemIdx = elemIDs[blkInd]->binarySearch(elemID);
      if (elemIdx < 0) {
	cerr << "addElemMatrix ERROR, elemID " << (int)elemID << " not found."
	     <<endl;
	return(-1);
      }

      ElemContribution& elemContr = (*(elemContributions[blkInd]))[elemIdx];

      std::vector<double>& elemContrMatrix = elemContr.matrixContributions;
      int len = matrixData.length();
      int oldLen = elemContrMatrix.length();
      if (oldLen < len) {
	elemContrMatrix.resize(len);
	for(int i=oldLen; i<len; i++) elemContrMatrix[i] = 0.0;
      }

      for(int i=0; i<matrixData.length(); i++) {
	elemContrMatrix[i] += matrixData[i];
      }

      return(0);
    }

  int addElemRHS(int elemBlockID, int elemID, std::vector<double>& rhsData)
    {
      int insertPoint = -1;
      int blkInd = elemBlockIDs.binarySearch(elemBlockID, insertPoint);
      if (blkInd < 0) {
	cerr << " addElemRHS ERROR, elemBlockID " << (int)elemBlockID
	     << " not found" << endl;
	return(-1);
      }

      int elemIdx = elemIDs[blkInd]->binarySearch(elemID);
      if (elemIdx < 0) {
	cerr << "addElemRHS ERROR, elemID " << (int)elemID << " not found."<<endl;
	return(-1);
      }

      ElemContribution& elemContr = (*(elemContributions[blkInd]))[elemIdx];

      std::vector<double>& elemContrRHS = elemContr.rhsContributions;
      int len = rhsData.length();
      int oldLen = elemContrRHS.length();
      if (oldLen < len) {
	elemContrRHS.resize(len);
	for(int i=oldLen; i<len; i++) elemContrRHS[i] = 0.0;
      }

      for(int i=0; i<rhsData.length(); i++) {
	elemContrRHS[i] += rhsData[i];
      }

      return(0);
    }
};

#endif // _InputData_h_