Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

BandSPDLinLapackSolver.cpp

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 1999, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** ****************************************************************** */
00020                                                                         
00021 // $Revision: 1.1.1.1 $
00022 // $Date: 2000/09/15 08:23:29 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/system_of_eqn/linearSOE/bandSPD/BandSPDLinLapackSolver.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/system_of_eqn/linearSOE/bandSPD/BandSPDLinLapackSolver.h
00027 //
00028 // Written: fmk 
00029 // Created: 11/96
00030 // Revision: A
00031 //
00032 // Description: This file contains the implementation of BandSPDLinLapackSolver.
00033 //
00034 // What: "@(#) BandSPDLinLapackSolver.h, revA"
00035 
00036 #include <BandSPDLinLapackSolver.h>
00037 #include <BandSPDLinSOE.h>
00038 #include <f2c.h>
00039 #include <math.h>
00040 
00041 
00042 BandSPDLinLapackSolver::BandSPDLinLapackSolver()
00043 :BandSPDLinSolver(SOLVER_TAGS_BandSPDLinLapackSolver)
00044 {
00045     
00046 }
00047 
00048 BandSPDLinLapackSolver::~BandSPDLinLapackSolver()
00049 {
00050     
00051 }
00052 
00053 
00054 #ifdef _WIN32
00055 extern "C" int _stdcall DPBSV(char *UPLO, unsigned int sizeUPLO,
00056          int *N, int *KD, int *NRHS, 
00057          double *A, int *LDA, double *B, int *LDB, 
00058          int *INFO);
00059 
00060 extern "C" int _stdcall DPBTRS(char *UPLO, unsigned int sizeUPLO,
00061           int *N, int *KD, int *NRHS, 
00062           double *A, int *LDA, double *B, int *LDB, 
00063           int *INFO);
00064 #else
00065 
00066 extern "C" int dpbsv_(char *UPLO, int *N, int *KD, int *NRHS, 
00067         double *A, int *LDA, double *B, int *LDB, 
00068         int *INFO);
00069 
00070 extern "C" int dpbtrs_(char *UPLO, int *N, int *KD, int *NRHS, 
00071          double *A, int *LDA, double *B, int *LDB, 
00072          int *INFO);
00073 
00074 #endif
00075          
00076 
00077 int
00078 BandSPDLinLapackSolver::solve(void)
00079 {
00080     if (theSOE == 0) {
00081  cerr << "WARNING BandSPDLinLapackSolver::solve(void)- ";
00082  cerr << " No LinearSOE object has been set\n";
00083  return -1;
00084     }
00085 
00086     int n = theSOE->size;
00087     int kd = theSOE->half_band -1;
00088     int ldA = kd +1;
00089     int nrhs = 1;
00090     int ldB = n;
00091     int info;
00092     double *Aptr = theSOE->A;
00093     double *Xptr = theSOE->X;
00094     double *Bptr = theSOE->B;
00095 
00096     // first copy B into X
00097     for (int i=0; i<n; i++)
00098  *(Xptr++) = *(Bptr++);
00099     Xptr = theSOE->X;
00100 
00101     // now solve AX = Y
00102 
00103  
00104 
00105 #ifdef _WIN32
00106     if (theSOE->factored == false) {
00107  // factor and solve  
00108  unsigned int sizeC = 1;
00109  DPBSV("U", sizeC, &n,&kd,&nrhs,Aptr,&ldA,Xptr,&ldB,&info); 
00110     }
00111       else {
00112  // solve only using factored matrix   
00113  unsigned int sizeC = 1; 
00114  DPBTRS("U", sizeC, &n,&kd,&nrhs,Aptr,&ldA,Xptr,&ldB,&info); 
00115     }
00116 #else 
00117     { if (theSOE->factored == false)          
00118  dpbsv_("U",&n,&kd,&nrhs,Aptr,&ldA,Xptr,&ldB,&info);
00119       else
00120  dpbtrs_("U",&n,&kd,&nrhs,Aptr,&ldA,Xptr,&ldB,&info);
00121     }
00122 #endif    
00123 
00124     // check if successfull
00125     if (info != 0) {
00126  cerr << "WARNING BandSPDLinLapackSolver::solve() - the LAPACK";
00127  cerr << " routines returned " << info << endl;
00128  return -info;
00129     }
00130 
00131     theSOE->factored = true;
00132     return 0;
00133 }
00134     
00135 
00136 
00137 int
00138 BandSPDLinLapackSolver::setSize()
00139 {
00140     // nothing to do    
00141     return 0;
00142 }
00143 
00144 int
00145 BandSPDLinLapackSolver::sendSelf(int cTag,
00146      Channel &theChannel)
00147 {
00148     // nothing to do
00149     return 0;
00150 }
00151 
00152 int
00153 BandSPDLinLapackSolver::recvSelf(int tag,
00154      Channel &theChannel, 
00155      FEM_ObjectBroker &theBroker)
00156 {
00157     // nothing to do
00158     return 0;
00159 }
00160 
00161 
00162 
Copyright Contact Us