SundanceCellIterator.cpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 // ************************************************************************
00003 // 
00004 //                              Sundance
00005 //                 Copyright (2005) Sandia Corporation
00006 // 
00007 // Copyright (year first published) Sandia Corporation.  Under the terms 
00008 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government 
00009 // retains certain rights in this software.
00010 // 
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //                                                                                 
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA                                                                                
00025 // Questions? Contact Kevin Long (krlong@sandia.gov), 
00026 // Sandia National Laboratories, Livermore, California, USA
00027 // 
00028 // ************************************************************************
00029 /* @HEADER@ */
00030 
00031 #include "SundanceCellIterator.hpp"
00032 #include "SundanceCellFilter.hpp"
00033 #include "SundanceOut.hpp"
00034 
00035 using namespace Sundance;
00036 using namespace Sundance;
00037 using namespace Sundance;
00038 using namespace Teuchos;
00039 
00040 CellIterator::CellIterator()
00041   :  isImplicit_(true),
00042     currentLID_(-1),
00043     reorderer_(0),
00044      iter_(dummy().begin())
00045 {;}
00046 
00047 CellIterator::CellIterator(const CellIterator& other)
00048   :  isImplicit_(other.isImplicit_),
00049      currentLID_(other.currentLID_),
00050      reorderer_(other.reorderer_),
00051      iter_()
00052 {
00053   if (!isImplicit_) iter_ = other.iter_;
00054 }
00055 
00056 CellIterator::CellIterator(const Mesh& mesh, 
00057                            int cellDim, 
00058                            CellIteratorPos pos)
00059   : isImplicit_(true),
00060     currentLID_(-1),
00061     reorderer_(mesh.reorderer()),
00062     iter_(dummy().begin())
00063 {
00064   if (cellDim == mesh.spatialDim() && reorderer_ != 0)
00065     {
00066       switch(pos)
00067         {
00068         case Begin:
00069           currentLID_ = reorderer_->begin(); 
00070           break;
00071         case End:
00072           currentLID_ = mesh.numCells(cellDim);
00073         }
00074       SUNDANCE_OUT(mesh.verb() > 2, 
00075                    "created implicit cell iterator with LID=" << currentLID_);
00076     }
00077   else 
00078     {
00079       switch(pos)
00080         {
00081         case Begin:
00082           currentLID_ = 0;
00083           break;
00084         case End:
00085           currentLID_ = mesh.numCells(cellDim);
00086         }
00087       SUNDANCE_OUT(mesh.verb() > 2, 
00088                    "created implicit cell iterator with LID=" << currentLID_);
00089     }
00090 
00091 
00092 }
00093 
00094 
00095 
00096 CellIterator::CellIterator(const Set<int>* cells, CellIteratorPos pos)
00097   : isImplicit_(false),
00098     currentLID_(-1),
00099     reorderer_(0),
00100     iter_(dummy().begin())
00101 {
00102   switch(pos)
00103   {
00104     case Begin:
00105       iter_ = cells->begin();
00106       break;
00107     case End:
00108       iter_ = cells->end();
00109       break;
00110     default:
00111       TEUCHOS_TEST_FOR_EXCEPT(1);
00112   }
00113 }
00114 
00115 
00116 
00117 CellIterator& CellIterator::operator=(const CellIterator& other)
00118 {
00119   if (*this!=other) 
00120   {
00121     isImplicit_ = other.isImplicit_;
00122     currentLID_ = other.currentLID_;
00123     reorderer_=other.reorderer_;
00124     if (!isImplicit_) iter_ = other.iter_;
00125   }
00126   return *this;
00127 }
00128 
00129     

Site Contact