FEI Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fei_Aztec_BlockMap.cpp
Go to the documentation of this file.
1 /*
2 // @HEADER
3 // ************************************************************************
4 // FEI: Finite Element Interface to Linear Solvers
5 // Copyright (2005) Sandia Corporation.
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the
8 // U.S. Government retains certain rights in this software.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Alan Williams (william@sandia.gov)
38 //
39 // ************************************************************************
40 // @HEADER
41 */
42 
43 
44 #include <fei_trilinos_macros.hpp>
45 #include <fei_iostream.hpp>
46 
47 #ifdef HAVE_FEI_AZTECOO
48 
49 #include <assert.h>
50 #include <stdio.h>
51 #include <stdlib.h>
52 
53 #include <fei_mpi.h>
54 
55 #ifndef FEI_SER
56 
57 #define AZTEC_MPI AZTEC_MPI
58 #define AZ_MPI AZ_MPI
59 #ifndef MPI
60 #define MPI MPI
61 #endif
62 
63 #endif
64 
65 #include <az_aztec.h>
66 #include <fei_Aztec_Map.hpp>
67 #include <fei_Aztec_BlockMap.hpp>
68 
69 namespace fei_trilinos {
70 
71 //==============================================================================
72 Aztec_BlockMap::Aztec_BlockMap(int globalSz, int N_update, const int* update, int localOffs,
73  MPI_Comm comm,
74  int numGlobalBlocks, int numLocalBlocks,
75  const int* blkUpdate,
76  int localBlockOffset, int* blockSizes)
77 
78  : Aztec_Map(globalSz, N_update, update, localOffs, comm),
79  numGlobalBlocks_(numGlobalBlocks),
80  numLocalBlocks_(numLocalBlocks),
81  localBlockOffset_(localBlockOffset)
82 {
83  checkInput();
84 
85  blockSizes_ = new int[numLocalBlocks_];
86  blockUpdate_ = new int[numLocalBlocks_];
87 
88  for(int i=0; i<numLocalBlocks_; i++) {
89  blockSizes_[i] = blockSizes[i];
90  blockUpdate_[i] = blkUpdate[i];
91  }
92 }
93 
94 //==============================================================================
95 Aztec_BlockMap::Aztec_BlockMap(const Aztec_BlockMap& map)
96  : Aztec_Map(map.globalSize(), map.localSize(), &map.update[0], map.localOffset(),
97  map.getCommunicator()),
98  numGlobalBlocks_(map.numGlobalBlocks_),
99  numLocalBlocks_(map.numLocalBlocks_),
100  localBlockOffset_(map.localBlockOffset_)
101 {
102  blockSizes_ = new int[numLocalBlocks_];
103  blockUpdate_ = new int[numLocalBlocks_];
104 
105  for(int i=0; i<numLocalBlocks_; i++) {
106  blockSizes_[i] = map.blockSizes_[i];
107  blockUpdate_[i] = map.blockUpdate_[i];
108  }
109 }
110 
111 //==============================================================================
112 Aztec_BlockMap::~Aztec_BlockMap(void) {
113 
114  delete [] blockSizes_;
115  blockSizes_ = NULL;
116 
117  delete [] blockUpdate_;
118  blockUpdate_ = NULL;
119 
120  numGlobalBlocks_ = 0;
121  numLocalBlocks_ = 0;
122  localBlockOffset_ = 0;
123 }
124 
125 //==============================================================================
126 void Aztec_BlockMap::checkInput() {
127 
128  if (numGlobalBlocks_ <= 0) {
129  fei::console_out() << "Aztec_BlockMap: ERROR, numGlobalBlocks <= 0. Aborting."
130  << FEI_ENDL;
131  abort();
132  }
133 
134  if (localBlockOffset_ < 0) {
135  fei::console_out() << "Aztec_BlockMap: ERROR, negative localBlockOffset. Aborting."
136  << FEI_ENDL;
137  abort();
138  }
139 }
140 
141 }//namespace fei_trilinos
142 
143 #endif
144 //HAVE_FEI_AZTECOO
#define MPI_Comm
Definition: fei_mpi.h:56
Aztec_BlockMap(int globalSize, int N_update, const int *update, int localOffset, MPI_Comm comm, int numGlobalBlocks, int numLocalBlocks, const int *blkUpdate, int localBlockOffset, int *blockSizes)
#define FEI_ENDL
std::ostream & console_out()