escript  Revision_
SharedComponents.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2016 by The University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Apache License, version 2.0
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16 
17 
18 /****************************************************************************/
19 
20 /* Paso: shared components */
21 
22 /****************************************************************************/
23 
24 /* Author: Lutz Gross, l.gross@uq.edu.au */
25 
26 /****************************************************************************/
27 
28 #ifndef __PASO_SHAREDCOMPONENTS_H__
29 #define __PASO_SHAREDCOMPONENTS_H__
30 
31 #include "Paso.h"
32 
33 namespace paso {
34 
36 typedef boost::shared_ptr<SharedComponents> SharedComponents_ptr;
37 typedef boost::shared_ptr<const SharedComponents> const_SharedComponents_ptr;
38 
41 {
42  SharedComponents(dim_t localLength, dim_t nNeighbours,
43  const Esys_MPI_rank* neighbours, const index_t* sharedArray,
44  const index_t* offset, index_t m, index_t b,
45  const esysUtils::JMPI& mpiInfo)
46  : local_length(localLength*m),
47  numNeighbors(nNeighbours),
48  mpi_info(mpiInfo)
49  {
51  if (!offset) {
53  } else {
54  numSharedComponents = offset[nNeighbours] * m;
55  }
58  if (numNeighbors > 0 && offset != NULL) {
59 #pragma omp parallel
60  {
61 #pragma omp for
62  for (dim_t i=0; i < numNeighbors; i++) {
63  neighbor[i] = neighbours[i];
64  offsetInShared[i] = offset[i] * m;
65  }
66  offsetInShared[numNeighbors] = offset[nNeighbours] * m;
67 #pragma omp for
68  for (dim_t i=0; i<offset[nNeighbours]; i++) {
69  const index_t itmp=m*sharedArray[i]+b;
70  for (dim_t j=0; j < m; ++j)
71  shared[m*i+j]=itmp+j;
72  }
73  }
74  } else {
76  }
77  }
78 
80  {
81  delete[] neighbor;
82  delete[] shared;
83  delete[] offsetInShared;
84  }
85 
88 
91 
95 
98 
102 
105 
107 };
108 
109 } // namespace paso
110 
111 #endif // __PASO_SHAREDCOMPONENTS_H__
112 
#define PASO_DLL_API
Definition: Paso.h:41
dim_t numNeighbors
number of processors sharing values with this processor
Definition: SharedComponents.h:90
~SharedComponents()
Definition: SharedComponents.h:79
boost::shared_ptr< const SharedComponents > const_SharedComponents_ptr
Definition: SharedComponents.h:37
boost::shared_ptr< SharedComponents > SharedComponents_ptr
Definition: SharedComponents.h:35
const esysUtils::JMPI mpi_info
Definition: SharedComponents.h:106
dim_t local_length
local array length shared
Definition: SharedComponents.h:87
Definition: AMG.cpp:38
index_t * offsetInShared
Definition: SharedComponents.h:94
dim_t numSharedComponents
= offsetInShared[numNeighbors]
Definition: SharedComponents.h:104
SharedComponents(dim_t localLength, dim_t nNeighbours, const Esys_MPI_rank *neighbours, const index_t *sharedArray, const index_t *offset, index_t m, index_t b, const esysUtils::JMPI &mpiInfo)
Definition: SharedComponents.h:42
int index_t
Definition: types.h:24
int Esys_MPI_rank
Definition: Esys_MPI.h:59
Definition: SharedComponents.h:40
index_t dim_t
Definition: types.h:27
Esys_MPI_rank * neighbor
list of the processors sharing values with this processor
Definition: SharedComponents.h:97
boost::shared_ptr< JMPI_ > JMPI
Definition: Esys_MPI.h:79
index_t * shared
Definition: SharedComponents.h:101