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.3 $
00022 // $Date: 2003/04/02 22:02:52 $
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  DPBSV(char *UPLO,
00056                               int *N, int *KD, int *NRHS, 
00057                               double *A, int *LDA, double *B, int *LDB, 
00058                               int *INFO);
00059 
00060 extern "C" int  DPBTRS(char *UPLO,
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         opserr << "WARNING BandSPDLinLapackSolver::solve(void)- ";
00082         opserr << " 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", &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         DPBTRS("U", &n,&kd,&nrhs,Aptr,&ldA,Xptr,&ldB,&info);
00116     }
00117 #else   
00118     { if (theSOE->factored == false)          
00119         dpbsv_("U",&n,&kd,&nrhs,Aptr,&ldA,Xptr,&ldB,&info);
00120       else
00121         dpbtrs_("U",&n,&kd,&nrhs,Aptr,&ldA,Xptr,&ldB,&info);
00122     }
00123 #endif    
00124 
00125     // check if successfull
00126     if (info != 0) {
00127         opserr << "WARNING BandSPDLinLapackSolver::solve() - the LAPACK";
00128         opserr << " routines returned " << info << endln;
00129         return -info;
00130     }
00131 
00132     theSOE->factored = true;
00133     return 0;
00134 }
00135     
00136 
00137 
00138 int
00139 BandSPDLinLapackSolver::setSize()
00140 {
00141     // nothing to do    
00142     return 0;
00143 }
00144 
00145 int
00146 BandSPDLinLapackSolver::sendSelf(int cTag,
00147                                  Channel &theChannel)
00148 {
00149     // nothing to do
00150     return 0;
00151 }
00152 
00153 int
00154 BandSPDLinLapackSolver::recvSelf(int tag,
00155                                  Channel &theChannel, 
00156                                  FEM_ObjectBroker &theBroker)
00157 {
00158     // nothing to do
00159     return 0;
00160 }
00161 
00162 
00163 

Generated on Mon Oct 23 15:05:28 2006 for OpenSees by doxygen 1.5.0