FEI Version of the Day
fei_Aztec_Map.cpp
00001 /*--------------------------------------------------------------------*/
00002 /*    Copyright 2005 Sandia Corporation.                              */
00003 /*    Under the terms of Contract DE-AC04-94AL85000, there is a       */
00004 /*    non-exclusive license for use of this work by or on behalf      */
00005 /*    of the U.S. Government.  Export of this program may require     */
00006 /*    a license from the United States Government.                    */
00007 /*--------------------------------------------------------------------*/
00008 
00009 #include <fei_trilinos_macros.hpp>
00010 #include <fei_iostream.hpp>
00011 
00012 #ifdef HAVE_FEI_AZTECOO
00013 
00014 #include <cstdlib>
00015 
00016 #include <fei_mpi.h>
00017 
00018 #ifndef FEI_SER
00019 
00020 #define AZTEC_MPI AZTEC_MPI
00021 #define AZ_MPI AZ_MPI
00022 #ifndef MPI
00023 #define MPI MPI
00024 #endif
00025 
00026 #endif
00027 
00028 #include <az_aztec.h>
00029 #include <fei_Aztec_Map.hpp>
00030 
00031 namespace fei_trilinos {
00032 
00033 //==============================================================================
00034 Aztec_Map::Aztec_Map(int globalSz, int N_update, const int* update,
00035                      int localOffs, MPI_Comm comm)
00036  :
00037     proc_config(AZ_PROC_SIZE),
00038     update(update, update+N_update),
00039     external(NULL),
00040     update_index(NULL),
00041     extern_index(NULL),
00042     data_org(NULL),
00043     orderingUpdate(),
00044     az_transformed(false),
00045     globalSize_(globalSz),
00046     localSize_(N_update),
00047     localOffset_(localOffs),
00048     N_update_(N_update),
00049     comm_(comm)
00050 {
00051     checkInput();
00052     AZ_set_proc_config(&proc_config[0], comm_);
00053 }
00054  
00055 //==============================================================================
00056 Aztec_Map::Aztec_Map(const Aztec_Map& map) :
00057     proc_config(AZ_PROC_SIZE),
00058     update(map.update),
00059     external(NULL),
00060     update_index(NULL),
00061     extern_index(NULL),
00062     data_org(NULL),
00063     orderingUpdate(map.orderingUpdate),
00064     az_transformed(map.az_transformed),
00065     globalSize_(map.globalSize_),
00066     localSize_(map.localSize_),
00067     localOffset_(map.localOffset_),
00068     N_update_(map.localSize_),
00069     comm_(map.comm_)
00070 {
00071     AZ_processor_info(&proc_config[0]);
00072     update_index = (int*)AZ_allocate(N_update_*sizeof(int));
00073     for(int i=0; i<N_update_; ++i) {
00074       update_index[i] = map.update_index[i];
00075     }
00076     external = (int*)AZ_allocate(data_org[AZ_N_external]*sizeof(int));
00077     extern_index = (int*)AZ_allocate(data_org[AZ_N_external]*sizeof(int));
00078     for(int i=0; i<data_org[AZ_N_external]; ++i) {
00079       external[i] = map.external[i];
00080       extern_index[i] = map.extern_index[i];
00081     }
00082 }
00083 
00084 //==============================================================================
00085 Aztec_Map::~Aztec_Map()
00086 {
00087   globalSize_ = 0;
00088   localSize_ = 0;
00089   localOffset_ = 0;
00090 
00091   std::free(update_index);
00092   std::free(external);
00093   std::free(extern_index);
00094   std::free(data_org);
00095 }
00096 
00097 //==============================================================================
00098 void Aztec_Map::checkInput() {
00099 
00100     if (globalSize_ <= 0) {
00101         throw std::runtime_error("Aztec_Map: ERROR, globalSize <= 0.");
00102     }
00103 
00104     if (localSize_ < 0) {
00105         throw std::runtime_error("Aztec_Map: ERROR, localSize negative.");
00106     }
00107 
00108     if (localOffset_ < 0) {
00109         throw std::runtime_error("Aztec_Map: ERROR, localOffset negative.");
00110     }
00111 }
00112 
00113 }//namespace fei_trilinos
00114 
00115 #endif
00116 //HAVE_FEI_AZTECOO
00117 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends