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

AMRSolver.H

Go to the documentation of this file.
00001 /*   _______              __
00002     / ___/ /  ___  __ _  / /  ___
00003    / /__/ _ \/ _ \/  V \/ _ \/ _ \
00004    \___/_//_/\___/_/_/_/_.__/\___/
00005 */
00006 // CHOMBO Copyright (c) 2000-2004, The Regents of the University of
00007 // California, through Lawrence Berkeley National Laboratory (subject to
00008 // receipt of any required approvals from U.S. Dept. of Energy).  All
00009 // rights reserved.
00010 //
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are met:
00013 //
00014 // (1) Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 // (2) Redistributions in binary form must reproduce the above copyright
00017 // notice, this list of conditions and the following disclaimer in the
00018 // documentation and/or other materials provided with the distribution.
00019 // (3) Neither the name of Lawrence Berkeley National Laboratory, U.S.
00020 // Dept. of Energy nor the names of its contributors may be used to endorse
00021 // or promote products derived from this software without specific prior
00022 // written permission.
00023 //
00024 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00025 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
00026 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
00027 // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
00028 // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00029 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00030 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00031 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00032 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00033 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00034 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00035 //
00036 // You are under no obligation whatsoever to provide any bug fixes,
00037 // patches, or upgrades to the features, functionality or performance of
00038 // the source code ("Enhancements") to anyone; however, if you choose to
00039 // make your Enhancements available either publicly, or directly to
00040 // Lawrence Berkeley National Laboratory, without imposing a separate
00041 // written license agreement for such Enhancements, then you hereby grant
00042 // the following license: a non-exclusive, royalty-free perpetual license
00043 // to install, use, modify, prepare derivative works, incorporate into
00044 // other computer software, distribute, and sublicense such Enhancements or
00045 // derivative works thereof, in binary and source code form.
00046 //
00047 // TRADEMARKS. Product and company names mentioned herein may be the
00048 // trademarks of their respective owners.  Any rights not expressly granted
00049 // herein are reserved.
00050 //
00051 
00052 // DTGraves, Tues, July 6, 1999
00053 
00054 #ifndef _AMRSOLVER_H_
00055 #define _AMRSOLVER_H_
00056 
00057 #include <cstdlib>
00058 #include <cmath>
00059 #include <iostream>
00060 #include <cassert>
00061 
00062 #include "REAL.H"
00063 #include "IntVect.H"
00064 #include "Box.H"
00065 #include "FArrayBox.H"
00066 #include "Vector.H"
00067 #include "IntVectSet.H"
00068 #include "DisjointBoxLayout.H"
00069 #include "LevelData.H"
00070 #include "AMRLevelMG.H"
00071 #include "LevelSolver.H"
00072 #include "ProblemDomain.H"
00073 
00075 
00082 class AMRSolver
00083 {
00084 public:
00085   friend class AMRLevelMG;
00086 
00088 
00092   AMRSolver();
00093 
00095 
00098   AMRSolver(const Vector<DisjointBoxLayout>& a_gridsLevel,
00099             const Vector<Box>&               a_domainLevel,
00100             const Vector<Real>&              a_dxLevel,
00101             const Vector<int>&               a_refRatio,
00102             int                              a_numLevels,
00103             int                              a_lBase,
00104             const LevelOp* const             a_opin,
00105             int                              a_ncomp = 1,
00106             bool                             a_limitCoarsening = false);
00107 
00109 
00112   AMRSolver(const Vector<DisjointBoxLayout>& a_gridsLevel,
00113             const Vector<ProblemDomain>&     a_domainLevel,
00114             const Vector<Real>&              a_dxLevel,
00115             const Vector<int>&               a_refRatio,
00116             int                              a_numLevels,
00117             int                              a_lBase,
00118             const LevelOp* const             a_opin,
00119             int                              a_ncomp = 1,
00120             bool                             a_limitCoarsening = false);
00121 
00123 
00151   virtual void define(const Vector<DisjointBoxLayout>& a_gridsLevel,
00152                       const Vector<Box>&                    a_domainLevel,
00153                       const Vector<Real>&                   a_dxLevel,
00154                       const Vector<int>&                    a_refRatio,
00155                       int                                   a_numLevels,
00156                       int                                   a_lBase,
00157                       const LevelOp* const                  a_opin,
00158                       int                                   a_ncomp=1,
00159                       bool                                  a_limitCoarsening = false);
00160 
00162 
00190   virtual void
00191   define(const Vector<DisjointBoxLayout>& a_gridsLevel,
00192          const Vector<ProblemDomain>&     a_domainLevel,
00193          const Vector<Real>&              a_dxLevel,
00194          const Vector<int>&               a_refRatio,
00195          int                              a_numLevels,
00196          int                              a_lBase,
00197          const LevelOp* const             a_opin,
00198          int                              a_ncomp=1,
00199          bool                             a_limitCoarsening = false);
00200 
00202   virtual ~AMRSolver();
00203 
00205   bool isDefined() const;
00206 
00208   void setNumSmoothUp(int a_numSmoothUp);
00209 
00211   void setNumSmoothDown(int a_numSmoothDown);
00212 
00214   void setTolerance(Real a_tolerance);
00215 
00217 
00221   void setOperatorTolerance(Real a_operatorTolerance);
00222 
00224   void setMaxIter(int a_maxIter);
00225 
00227 
00232   // added by Dan M, 3/24/2000
00233   void setMinIter(int a_minIter);
00234 
00236 
00241   void setNumVCyclesBottom(int a_numVCycleBottom);
00242 
00244 
00249   void setConvergenceMetric(Real a_metric, int a_comp);
00250 
00252   void setNormType(int a_normType);
00253 
00255 
00274   void solveAMR(Vector<LevelData<FArrayBox> *>&       a_phiLevel,
00275                 const Vector<LevelData<FArrayBox> *>& a_rhsLevel,
00276                 bool a_initializePhiToZero = true);
00277 
00279 
00294   virtual void AMRVCycleMG(Vector<LevelData<FArrayBox> *>&       a_corrLevel,
00295                            const Vector<LevelData<FArrayBox> *>& a_residLevel);
00296 
00298 
00301   Vector<Real> computeResidualNorm(Vector<LevelData<FArrayBox> *>&       a_phiLevel,
00302                                    const Vector<LevelData<FArrayBox> *>& a_rhsLevel,
00303                                    int                                   a_normType);
00304 
00306 
00310   Vector<Real> computeResidualNorm(Vector<LevelData<FArrayBox> *>&       a_residLevel,
00311                                    Vector<LevelData<FArrayBox> *>&       a_phiLevel,
00312                                    const Vector<LevelData<FArrayBox> *>& a_rhsLevel,
00313                                    int                                   a_normType);
00314 
00316   void computeAMRResidual(Vector<LevelData<FArrayBox> *>&       a_phiLevel,
00317                           const Vector<LevelData<FArrayBox> *>& a_rhsLevel,
00318                           LevelData<FArrayBox>&                 a_res,
00319                           int                                   a_ilev);
00320 
00322 
00326   void applyAMROperator(Vector<LevelData<FArrayBox> *>& a_phiLevel,
00327                         LevelData<FArrayBox>&           a_LofPhi,
00328                         int                             a_ilev);
00329 
00331 
00336   void applyAMROperatorHphys(Vector<LevelData<FArrayBox> *>& a_phiLevel,
00337                              LevelData<FArrayBox>&           a_LofPhi,
00338                              int                             a_ilev);
00339 
00341   void setVerbose(bool a_verbose);
00342 
00343 protected:
00347   virtual void setDefaultValues();
00348 
00352   virtual void clear();
00353 
00359   Vector<Real> computeNorm(const Vector<LevelData<FArrayBox>* >& a_phiVect,
00360                            int a_normType);
00361 
00362   // accessor for  the residual in AMRMGLevel
00363   LevelData<FArrayBox>& getResid(int a_level);
00364 
00365   // accessor for correction in AmrMGLevel
00366   LevelData<FArrayBox>& getCorr(int a_level);
00367 
00371   Real m_errorTolerance;
00372 
00376   Real m_tolerance;
00377 
00381   Vector<Real> m_convergenceMetrics;
00382 
00386   Real m_operatorTolerance;
00387 
00391   int m_numLevels;
00392 
00396   int m_finestLevel;
00397 
00401   Vector<int> m_refRatio;
00402 
00406   Vector<Real> m_dxLevel;
00407 
00411   Vector<DisjointBoxLayout> m_gridsLevel;
00412 
00416   Vector<ProblemDomain> m_domainLevel;
00417 
00421   int m_maxIter;
00422 
00427   int m_minIter;
00428 
00432   int m_numSmoothUp;
00433 
00437   int m_numVCyclesBottom;
00438 
00442   int m_numSmoothDown;
00443 
00447   int m_normType;
00448 
00452   Vector<AMRLevelMG*> m_amrmgLevel;
00453 
00457   bool m_isDefined;
00458 
00461   LevelSolver m_levelSolver;
00462 
00465   int m_lBase;
00466 
00469   int m_ncomp;
00470 
00474   bool m_verbose;
00475 
00476 private:
00477   AMRSolver(const AMRSolver&);
00478   AMRSolver& operator=(const AMRSolver&);
00479 };
00480 
00481 #endif

Generated on Wed Jan 19 17:51:22 2005 for Chombo&INSwithParticles by doxygen1.2.16