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

FiniteDifferences2D.h

00001 /****************************************************************************
00002  *                                                                          *
00003  *  Program: FDDlib                                                         *
00004  *  Version: 1.1                                                            *
00005  *                                                                          *
00006  *  Copyright (C) 2002 - 2004 by Eric Miller and Dana Brooks                *
00007  *  All rights reserved.                                                    *
00008  *                                                                          *
00009  *  This software is Version 1.1 of the fddlib tomography toolbox.          *
00010  *  It is not to be redistributed or used for any commercial purpose        *
00011  *  without the prior written consent of the authors and Northeastern       *
00012  *  University.                                                             *
00013  *                                                                          *
00014  *  This software is provided as is, and any express or implied warranties, *
00015  *  including but not limited to the implied warranty of merchantability    *
00016  *  and the implied warranty of fitness for a particular purpose, are dis-  *
00017  *  claimed.  In no event shall the authors or Northeastern University be   *
00018  *  liable for any direct, indirect, incidental, special, exemplary, or     *
00019  *  consequential damages (including but not limited to procurement of      * 
00020  *  substitute goods or services; loss of use, data, or profits; or busi-   *
00021  *  ness interruption) however caused and on any theory of liability,       *
00022  *  whether in contract, strict liability, or tort (including negligence or *
00023  *  otherwise) arising in any way from the use of this software, even if    *
00024  *  advised of the possibility of such damage.                              *
00025  *                                                                          *
00026  *  Portions of this code benefit from ideas from Kyle Guilbert, Greg       *
00027  *  Boverman, Derek Uluski, David Kaeli, and Jennifer Black                 *
00028  *                                                                          *
00029  ****************************************************************************/
00030 
00031 #ifndef _FINITE_DIFF2D_H_
00032 #define _FINITE_DIFF2D_H_
00033 
00034 #include "ArbitraryCartesianGrid2D.h"
00035 #include "CartesianNode2D.h"
00036 #include "grid_enums.h"
00037 #include "SparseRowMatrix.h"
00038 #include "Source2D.h"
00039 #include "Detector2D.h"
00040 #include "ComplexVector.h"
00041 #include "Preconditioner.h"
00042 #include <string>
00043 #include <vector>
00044 #include <map>
00045 #include "solver.h"
00046 #include "BoundaryCondition2D.h"
00047 
00048 namespace FDDlib {
00049 
00053 class FiniteDifferences2D
00054 {
00055 protected:
00056 
00058   struct s_neighbordata {
00060     CartesianNode2D* n_node;
00062     int n_linearIndex;
00063   };
00064 
00066   ArbitraryCartesianGrid2D *grid;
00067   
00069   static const int UNKNOWN_VALUE = -10;
00070   
00072   static const int OMITVAL = -1;
00073 
00075   SparseRowMatrix<double> Amat_;
00076 
00078   ComplexVector<double> Phi_;
00079 
00081   ComplexVector<double> AdjointPhi_;
00082 
00084   int startTime;
00085 
00087   int stopTime;
00088 
00090   double achievedTol_;
00091 
00093   int usedIterations_;
00094 
00096   int currSrcNum_;
00097 
00099   double currFreq_;
00100   
00102   int numUnknowns;
00103   
00105   std::map<int, Complex<double> > knowns;
00106   
00108   std::vector<BoundaryCondition2D*> bconds_;
00109   
00113   SparseRowMatrix<double> Adep;
00114 
00119   std::vector<int> rowMap;
00120 
00124   bool validAndActive(const s_neighbordata& ndata) const;
00125   
00132   double getOffDiagVal(const CartesianNode2D& node,
00133                        const CartesianNode2D& node_p,
00134                        const CartesianNode2D& node_m, 
00135                        direction2D dir) const;
00136   
00140   void resetDataVector(std::vector<s_neighbordata>& datavec) const;
00141 
00145   void buildAMatrix(double omega) throw(std::string);
00146   
00148   void postProcessAMatrix();
00149   
00151   void updateRightHandSide(RealVector<double>& RHS);
00152 
00158   void copySubMatrices();
00159   
00160 public:
00161 
00166   FiniteDifferences2D(ArbitraryCartesianGrid2D* acg3d, 
00167                       const std::vector<BoundaryCondition2D*>& bconds);
00168 
00184   void SingleSrcSolve(int solveIterations, double residualTol,
00185                      const Source2D &src,
00186                      const std::vector<Detector2D*> &detarr,
00187                      Preconditioner& Pre, enum_solver Solver,
00188                      void (*callback)(const FiniteDifferences2D&, bool,
00189                            const std::vector<Detector2D*>&)) throw(std::string);
00190 
00208   void MultipleSrcSolve(int solveIterations, double residualTol,
00209                          const std::vector<Source2D*> &srcarr,
00210                          const std::vector<Detector2D*> &detarr,
00211                          Preconditioner& Pre, enum_solver Solver,
00212                          void (*callback)(const FiniteDifferences2D&, bool,
00213                                const std::vector<Detector2D*>&)) throw(std::string);
00214 
00226   bool AdjointSolve(int solveIterations, double residualTol,
00227                    const Detector2D &adjDetector, double frequency,
00228                    Preconditioner& Pre, enum_solver Solver) throw(std::string);
00229 
00242   bool solve(int solveIterations, double residualTol,
00243             bool adjoint, Preconditioner& Pre,
00244             RealVector<double>& RHS, enum_solver Solver) throw(std::string);
00245 
00249   ComplexVector<double> getPhi() const;
00250 
00254   ComplexVector<double> getAdjointPhi() const;
00255 
00261   void getPhi(RealVector<double>& realvec, RealVector<double>& imagvec) const;
00262 
00267   void getAdjointPhi(RealVector<double>& realvec,
00268                      RealVector<double>& imagvec) const;
00269 
00276   void getStatistics(double& solveTime, double& achievedTol,
00277                      int& usedIterations) const;
00278 
00287   void getSourceInfo(int& srcNum, double& freq) const;
00288   
00289 };
00290 
00291 }
00292 
00293 #endif

Generated on Mon Aug 30 15:41:06 2004 for FDDLib by doxygen1.2.18