/usr/include/trilinos/Epetra_FEVector.h is in libtrilinos-epetra-dev 12.12.1-5.
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 | /*
//@HEADER
// ************************************************************************
//
// Epetra: Linear Algebra Services Package
// Copyright 2011 Sandia Corporation
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef EPETRA_FEVECTOR_H
#define EPETRA_FEVECTOR_H
#include <Epetra_ConfigDefs.h>
#include <Epetra_CombineMode.h>
#include <Epetra_Map.h>
#include <Epetra_MultiVector.h>
#include <vector>
class Epetra_IntSerialDenseVector;
#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
class Epetra_LongLongSerialDenseVector;
#endif
class Epetra_SerialDenseVector;
/** Epetra Finite-Element Vector. This class inherits Epetra_MultiVector
and thus provides all Epetra_MultiVector functionality.
The added functionality provided by Epetra_FEVector is the ability to
perform finite-element style vector assembly. It accepts sub-vector
contributions, such as those that would come from element-load vectors, etc.
These sub-vectors need not be owned by the local processor. In other
words, the user can assemble overlapping data (e.g., corresponding to shared
finite-element nodes). When the user is finished assembling their vector
data, they then call the method Epetra_FEVector::GlobalAssemble() which
gathers the overlapping data (all non-local data that was input on each
processor) into the data-distribution specified by the map with which the
Epetra_FEVector was constructed.
*/
class EPETRA_LIB_DLL_EXPORT Epetra_FEVector : public Epetra_MultiVector {
public:
/** Constructor that requires a map specifying a non-overlapping
data layout.
@param Map Map describing a non-overlapping distribution for the
underlying Epetra_MultiVector into which this Epetra_FEVector will
funnel data.
@param numVectors Optional argument, default value is 1. (See the
documentation for Epetra_MultiVector for the meaning of this
argument.
@param ignoreNonLocalEntries Optional argument, default value is
false. Under certain special circumstances it is desirable to
have non-local contributions ignored rather than saving them
for the GlobalAssemble step.
*/
Epetra_FEVector(const Epetra_BlockMap& Map,
int numVectors=1,
bool ignoreNonLocalEntries=false);
//! Set multi-vector values from two-dimensional array.
/*!
\param In
Epetra_DataAccess - Enumerated type set to Copy or View.
\param In
Map - A Epetra_LocalMap, Epetra_Map or Epetra_BlockMap.
\param In
A - Pointer to an array of double precision numbers. The first vector starts at A.
The second vector starts at A+MyLDA, the third at A+2*MyLDA, and so on.
\param In
MyLDA - The "Leading Dimension", or stride between vectors in memory.
\warning This value refers to the stride on the calling processor. Thus it is a
local quantity, not a global quantity.
\param In
NumVectors - Number of vectors in multi-vector.
\return Integer error code, set to 0 if successful.
See Detailed Description section for further discussion.
*/
Epetra_FEVector(Epetra_DataAccess CV, const Epetra_BlockMap& Map,
double *A, int MyLDA, int NumVectors,
bool ignoreNonLocalEntries=false);
//! Set multi-vector values from array of pointers.
/*!
\param In
Epetra_DataAccess - Enumerated type set to Copy or View.
\param In
Map - A Epetra_LocalMap, Epetra_Map or Epetra_BlockMap.
\param In
ArrayOfPointers - An array of pointers such that ArrayOfPointers[i] points to the memory
location containing ith vector to be copied.
\param In
NumVectors - Number of vectors in multi-vector.
\return Integer error code, set to 0 if successful.
See Detailed Description section for further discussion.
*/
Epetra_FEVector(Epetra_DataAccess CV, const Epetra_BlockMap& Map,
double **ArrayOfPointers, int NumVectors,
bool ignoreNonLocalEntries=false);
/** Copy constructor. */
Epetra_FEVector(const Epetra_FEVector& source);
/** Destructor */
virtual ~Epetra_FEVector();
/** Accumulate values into the vector, adding them to any values that
already exist for the specified indices.
*/
#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
int SumIntoGlobalValues(int numIDs,
const int* GIDs, const double* values,
int vectorIndex=0);
#endif
#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
int SumIntoGlobalValues(int numIDs,
const long long* GIDs, const double* values,
int vectorIndex=0);
#endif
/** Accumulate values into the vector, adding them to any values that
already exist for the specified GIDs.
@param GIDs List of global ids. Must be the same length as the
accompanying list of values.
@param values List of coefficient values. Must be the same length as
the accompanying list of GIDs.
*/
int SumIntoGlobalValues(const Epetra_IntSerialDenseVector& GIDs,
const Epetra_SerialDenseVector& values,
int vectorIndex=0);
#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
int SumIntoGlobalValues(const Epetra_LongLongSerialDenseVector& GIDs,
const Epetra_SerialDenseVector& values,
int vectorIndex=0);
#endif
/** Copy values into the vector overwriting any values that already exist
for the specified indices.
*/
#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
int ReplaceGlobalValues(int numIDs, const int* GIDs, const double* values,
int vectorIndex=0);
#endif
#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
int ReplaceGlobalValues(int numIDs, const long long* GIDs, const double* values,
int vectorIndex=0);
#endif
/** Copy values into the vector, replacing any values that
already exist for the specified GIDs.
@param GIDs List of global ids. Must be the same length as the
accompanying list of values.
@param values List of coefficient values. Must be the same length as
the accompanying list of GIDs.
*/
int ReplaceGlobalValues(const Epetra_IntSerialDenseVector& GIDs,
const Epetra_SerialDenseVector& values,
int vectorIndex=0);
#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
int ReplaceGlobalValues(const Epetra_LongLongSerialDenseVector& GIDs,
const Epetra_SerialDenseVector& values,
int vectorIndex=0);
#endif
#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
int SumIntoGlobalValues(int numIDs,
const int* GIDs,
const int* numValuesPerID,
const double* values,
int vectorIndex=0);
#endif
#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
int SumIntoGlobalValues(int numIDs,
const long long* GIDs,
const int* numValuesPerID,
const double* values,
int vectorIndex=0);
#endif
#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
int ReplaceGlobalValues(int numIDs, const int* GIDs,
const int* numValuesPerID,
const double* values,
int vectorIndex=0);
#endif
#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
int ReplaceGlobalValues(int numIDs, const long long* GIDs,
const int* numValuesPerID,
const double* values,
int vectorIndex=0);
#endif
/** Gather any overlapping/shared data into the non-overlapping partitioning
defined by the Map that was passed to this vector at construction time.
Data imported from other processors is stored on the owning processor
with a "sumInto" or accumulate operation.
This is a collective method -- every processor must enter it before any
will complete it.
Optimization for power-users:
The optional parameter 'reuse_map_and_exporter' defaults to false.
By default, a map that describes the non-local data is re-created at
each call to GlobalAssemble, along with an exporter used to do the
communication.
This is expensive. If you know that the layout of your nonlocal data has
not changed since your previous call to GlobalAssemble, you can set this
flag to true and it will reuse the previously created map and exporter
rather than creating new ones.
*/
int GlobalAssemble(Epetra_CombineMode mode = Add,
bool reuse_map_and_exporter = false);
/** Set whether or not non-local data values should be ignored.
*/
void setIgnoreNonLocalEntries(bool flag) {
ignoreNonLocalEntries_ = flag;
}
Epetra_FEVector& operator=(const Epetra_FEVector& source);
protected:
template<typename int_type>
int inputValues(int numIDs,
const int_type* GIDs, const double* values,
bool suminto,
int vectorIndex);
template<typename int_type>
int inputValues(int numIDs,
const int_type* GIDs, const int* numValuesPerID,
const double* values,
bool suminto,
int vectorIndex);
template<typename int_type>
int inputNonlocalValue(int_type GID, double value, bool suminto,
int vectorIndex);
template<typename int_type>
int inputNonlocalValues(int_type GID, int numValues, const double* values,
bool suminto, int vectorIndex);
//! Allocate the Map, Export object, and MultiVector for nonlocal data.
template<typename int_type>
void createNonlocalMapAndExporter();
//! Deallocate the Map, Export object, and MultiVector for nonlocal data.
void destroyNonlocalMapAndExporter();
//! Make all the nonlocal multivector entries zero.
template<typename int_type>
void zeroNonlocalData();
/// \brief Deallocate storage for nonlocal data.
///
/// This does not include whatever \c destroyNonlocalMapAndExporter()
/// deallocates.
void destroyNonlocalData();
long long myFirstID_;
int myNumIDs_;
#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
std::vector<int> nonlocalIDs_int_;
#endif
#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
std::vector<long long> nonlocalIDs_LL_;
#endif
template<typename int_type> std::vector<int_type>& nonlocalIDs();
std::vector<int> nonlocalElementSize_;
/// \brief Array of arrays (one per column) of nonlocal coefficients.
///
/// Entry j in this array is an array of nonlocal coefficients for
/// column j of the multivector. \c nonlocalCoefs_[j] in turn
/// contains the data for all the nonlocal block entries. Entries
/// within a block are stored in column-major order (Fortran style),
/// in contiguous chunks of \c Map().MaxElementSize() entries.
///
/// In summary: for k = 0 to numNonlocalIDs_ - 1,
/// nonlocalCoefs_[j][j*M + i] contains the entries of nonlocal
/// block entry k, for i = 0 to nonlocalElementSize_[k] - 1.
std::vector<std::vector<double> > nonlocalCoefs_;
//! Map describing distribution of nonlocal data.
Epetra_BlockMap* nonlocalMap_;
//! Export object that sums nonlocal data into a nonoverlapping distribution.
Epetra_Export* exporter_;
//! Multivector that holds nonlocal data; source for the Export operation.
Epetra_MultiVector* nonlocalVector_;
bool ignoreNonLocalEntries_;
private:
template<typename int_type>
int GlobalAssemble(Epetra_CombineMode mode, bool reuse_map_and_exporter);
};
#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
template<> inline std::vector<int>& Epetra_FEVector::nonlocalIDs<int>()
{
return nonlocalIDs_int_;
}
#endif
#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
template<> inline std::vector<long long>& Epetra_FEVector::nonlocalIDs<long long>()
{
return nonlocalIDs_LL_;
}
#endif
#endif
|