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_Map.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 <cstdlib>
50 
51 #include <fei_mpi.h>
52 
53 #ifndef FEI_SER
54 
55 #define AZTEC_MPI AZTEC_MPI
56 #define AZ_MPI AZ_MPI
57 #ifndef MPI
58 #define MPI MPI
59 #endif
60 
61 #endif
62 
63 #include <az_aztec.h>
64 #include <fei_Aztec_Map.hpp>
65 
66 namespace fei_trilinos {
67 
68 //==============================================================================
69 Aztec_Map::Aztec_Map(int globalSz, int N_update, const int* update,
70  int localOffs, MPI_Comm comm)
71  :
72  proc_config(AZ_PROC_SIZE),
73  update(update, update+N_update),
74  external(NULL),
75  update_index(NULL),
76  extern_index(NULL),
77  data_org(NULL),
78  orderingUpdate(),
79  az_transformed(false),
80  globalSize_(globalSz),
81  localSize_(N_update),
82  localOffset_(localOffs),
83  N_update_(N_update),
84  comm_(comm)
85 {
86  checkInput();
87  AZ_set_proc_config(&proc_config[0], comm_);
88 }
89 
90 //==============================================================================
91 Aztec_Map::Aztec_Map(const Aztec_Map& map) :
92  proc_config(AZ_PROC_SIZE),
93  update(map.update),
94  external(NULL),
95  update_index(NULL),
96  extern_index(NULL),
97  data_org(NULL),
98  orderingUpdate(map.orderingUpdate),
99  az_transformed(map.az_transformed),
100  globalSize_(map.globalSize_),
101  localSize_(map.localSize_),
102  localOffset_(map.localOffset_),
103  N_update_(map.localSize_),
104  comm_(map.comm_)
105 {
106  AZ_processor_info(&proc_config[0]);
107  update_index = (int*)AZ_allocate(N_update_*sizeof(int));
108  for(int i=0; i<N_update_; ++i) {
109  update_index[i] = map.update_index[i];
110  }
111  external = (int*)AZ_allocate(data_org[AZ_N_external]*sizeof(int));
112  extern_index = (int*)AZ_allocate(data_org[AZ_N_external]*sizeof(int));
113  for(int i=0; i<data_org[AZ_N_external]; ++i) {
114  external[i] = map.external[i];
115  extern_index[i] = map.extern_index[i];
116  }
117 }
118 
119 //==============================================================================
121 {
122  globalSize_ = 0;
123  localSize_ = 0;
124  localOffset_ = 0;
125 
126  std::free(update_index);
127  std::free(external);
128  std::free(extern_index);
129  std::free(data_org);
130 }
131 
132 //==============================================================================
133 void Aztec_Map::checkInput() {
134 
135  if (globalSize_ <= 0) {
136  throw std::runtime_error("Aztec_Map: ERROR, globalSize <= 0.");
137  }
138 
139  if (localSize_ < 0) {
140  throw std::runtime_error("Aztec_Map: ERROR, localSize negative.");
141  }
142 
143  if (localOffset_ < 0) {
144  throw std::runtime_error("Aztec_Map: ERROR, localOffset negative.");
145  }
146 }
147 
148 }//namespace fei_trilinos
149 
150 #endif
151 //HAVE_FEI_AZTECOO
152 
#define MPI_Comm
Definition: fei_mpi.h:56
virtual ~Aztec_Map(void)
Aztec_Map(int globalSize, int N_update, const int *update, int localOffset, MPI_Comm comm)