SharedComponents.h
Go to the documentation of this file.
/*****************************************************************************
*
* Copyright (c) 2003-2020 by The University of Queensland
* http://www.uq.edu.au
*
* Primary Business: Queensland, Australia
* Licensed under the Apache License, version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Development until 2012 by Earth Systems Science Computational Center (ESSCC)
* Development 2012-2013 by School of Earth Sciences
* Development from 2014-2017 by Centre for Geoscience Computing (GeoComp)
* Development from 2019 by School of Earth and Environmental Sciences
**
*****************************************************************************/
/****************************************************************************/
/* Paso: shared components */
/****************************************************************************/
/* Author: Lutz Gross, l.gross@uq.edu.au */
/****************************************************************************/
#ifndef __PASO_SHAREDCOMPONENTS_H__
#define __PASO_SHAREDCOMPONENTS_H__
#include "Paso.h"
namespace paso {
struct SharedComponents;
typedef boost::shared_ptr<SharedComponents> SharedComponents_ptr;
typedef boost::shared_ptr<const SharedComponents> const_SharedComponents_ptr;
struct PASO_DLL_API SharedComponents
{
SharedComponents(dim_t localLength, const std::vector<int>& neighbours,
const index_t* sharedArray,
const std::vector<index_t>& offset,
index_t m = 1, index_t b = 0)
: local_length(localLength*m),
neighbour(neighbours),
offsetInShared(offset)
{
if (offset.empty()) {
numSharedComponents = 0;
} else {
numSharedComponents = offset[neighbours.size()] * m;
}
shared = new index_t[numSharedComponents];
if (!neighbours.empty() && !offset.empty()) {
if (m != 1) {
for (int i = 0; i < offsetInShared.size(); i++) {
offsetInShared[i] *= m;
}
}
#pragma omp parallel for
for (dim_t i = 0; i < offset[neighbours.size()]; i++) {
const index_t itmp = m * sharedArray[i] + b;
for (dim_t j = 0; j < m; ++j)
shared[m*i+j] = itmp+j;
}
} else {
offsetInShared[neighbours.size()] = 0;
}
}
~SharedComponents()
{
delete[] shared;
}
dim_t local_length;
std::vector<int> neighbour;
std::vector<index_t> offsetInShared;
index_t* shared;
dim_t numSharedComponents;
};
} // namespace paso
#endif // __PASO_SHAREDCOMPONENTS_H__
Paso.h
escript::DataTypes::dim_t
index_t dim_t
Definition: DataTypes.h:66
escript::DataTypes::index_t
int index_t
type for array/matrix indices used both globally and on each rank
Definition: DataTypes.h:61
paso
Definition: BiCGStab.cpp:25
paso::const_SharedComponents_ptr
boost::shared_ptr< const SharedComponents > const_SharedComponents_ptr
Definition: SharedComponents.h:38
paso::SharedComponents_ptr
boost::shared_ptr< SharedComponents > SharedComponents_ptr
Definition: SharedComponents.h:36
PASO_DLL_API
#define PASO_DLL_API
Definition: paso/src/system_dep.h:29
paso::SharedComponents
Definition: SharedComponents.h:41
paso::SharedComponents::offsetInShared
std::vector< index_t > offsetInShared
Definition: SharedComponents.h:86
paso::SharedComponents::shared
index_t * shared
Definition: SharedComponents.h:90
paso::SharedComponents::SharedComponents
SharedComponents(dim_t localLength, const std::vector< int > &neighbours, const index_t *sharedArray, const std::vector< index_t > &offset, index_t m=1, index_t b=0)
Definition: SharedComponents.h:42
paso::SharedComponents::local_length
dim_t local_length
local array length shared
Definition: SharedComponents.h:79
paso::SharedComponents::~SharedComponents
~SharedComponents()
Definition: SharedComponents.h:73
paso::SharedComponents::numSharedComponents
dim_t numSharedComponents
= offsetInShared[numNeighbours]
Definition: SharedComponents.h:93
paso::SharedComponents::neighbour
std::vector< int > neighbour
list of the processors sharing values with this processor
Definition: SharedComponents.h:82