FEI Version of the Day
fei_Aztec_BlockMap.cpp
00001 /*
00002 // @HEADER
00003 // ************************************************************************
00004 //             FEI: Finite Element Interface to Linear Solvers
00005 //                  Copyright (2005) Sandia Corporation.
00006 //
00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the
00008 // U.S. Government retains certain rights in this software.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Alan Williams (william@sandia.gov) 
00038 //
00039 // ************************************************************************
00040 // @HEADER
00041 */
00042 
00043 
00044 #include <fei_trilinos_macros.hpp>
00045 #include <fei_iostream.hpp>
00046 
00047 #ifdef HAVE_FEI_AZTECOO
00048 
00049 #include <assert.h>
00050 #include <stdio.h>
00051 #include <stdlib.h>
00052 
00053 #include <fei_mpi.h>
00054 
00055 #ifndef FEI_SER
00056 
00057 #define AZTEC_MPI AZTEC_MPI
00058 #define AZ_MPI AZ_MPI
00059 #ifndef MPI
00060 #define MPI MPI
00061 #endif
00062 
00063 #endif
00064 
00065 #include <az_aztec.h>
00066 #include <fei_Aztec_Map.hpp>
00067 #include <fei_Aztec_BlockMap.hpp>
00068 
00069 namespace fei_trilinos {
00070 
00071 //==============================================================================
00072 Aztec_BlockMap::Aztec_BlockMap(int globalSz, int N_update, const int* update, int localOffs,
00073                           MPI_Comm comm,
00074                           int numGlobalBlocks, int numLocalBlocks,
00075                           const int* blkUpdate,
00076                           int localBlockOffset, int* blockSizes)
00077 
00078   : Aztec_Map(globalSz, N_update, update, localOffs, comm),
00079     numGlobalBlocks_(numGlobalBlocks),
00080     numLocalBlocks_(numLocalBlocks),
00081     localBlockOffset_(localBlockOffset)
00082 {
00083     checkInput();
00084 
00085     blockSizes_ = new int[numLocalBlocks_];
00086     blockUpdate_ = new int[numLocalBlocks_];
00087 
00088     for(int i=0; i<numLocalBlocks_; i++) {
00089         blockSizes_[i] = blockSizes[i];
00090         blockUpdate_[i] = blkUpdate[i];
00091     }
00092 }
00093  
00094 //==============================================================================
00095 Aztec_BlockMap::Aztec_BlockMap(const Aztec_BlockMap& map)
00096   : Aztec_Map(map.globalSize(), map.localSize(), &map.update[0], map.localOffset(),
00097               map.getCommunicator()),
00098     numGlobalBlocks_(map.numGlobalBlocks_),
00099     numLocalBlocks_(map.numLocalBlocks_),
00100     localBlockOffset_(map.localBlockOffset_)
00101 {
00102     blockSizes_ = new int[numLocalBlocks_];
00103     blockUpdate_ = new int[numLocalBlocks_];
00104 
00105     for(int i=0; i<numLocalBlocks_; i++) {
00106         blockSizes_[i] = map.blockSizes_[i];
00107         blockUpdate_[i] = map.blockUpdate_[i];
00108     }
00109 }
00110 
00111 //==============================================================================
00112 Aztec_BlockMap::~Aztec_BlockMap(void)  {
00113 
00114     delete [] blockSizes_;
00115     blockSizes_ = NULL;
00116 
00117     delete [] blockUpdate_;
00118     blockUpdate_ = NULL;
00119 
00120     numGlobalBlocks_ = 0;
00121     numLocalBlocks_ = 0;
00122     localBlockOffset_ = 0;
00123 }
00124 
00125 //==============================================================================
00126 void Aztec_BlockMap::checkInput() {
00127 
00128     if (numGlobalBlocks_ <= 0) {
00129        fei::console_out() << "Aztec_BlockMap: ERROR, numGlobalBlocks <= 0. Aborting."
00130             << FEI_ENDL;
00131        abort();
00132     }
00133 
00134     if (localBlockOffset_ < 0) {
00135        fei::console_out() << "Aztec_BlockMap: ERROR, negative localBlockOffset. Aborting."
00136             << FEI_ENDL;
00137        abort();
00138     }
00139 }
00140 
00141 }//namespace fei_trilinos
00142 
00143 #endif
00144 //HAVE_FEI_AZTECOO
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends