SundanceStdFwkEvalMediator.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 "SundanceStdFwkEvalMediator.hpp"
00032 #include "SundanceCoordExpr.hpp"
00033 #include "SundanceOut.hpp"
00034 #include "PlayaTabs.hpp"
00035 #include "PlayaExceptions.hpp"
00036 
00037 
00038 using namespace Sundance;
00039 using namespace Sundance;
00040 using namespace Sundance;
00041 using namespace Sundance;
00042 using namespace Sundance;
00043 using namespace Sundance;
00044 using namespace Sundance;
00045 using namespace Teuchos;
00046 
00047 
00048 
00049 
00050 
00051 StdFwkEvalMediator::StdFwkEvalMediator(const Mesh& mesh, int cellDim)
00052   : AbstractEvalMediator(),
00053     mesh_(mesh),
00054     cellDim_(cellDim),
00055     cellType_(NullCell),
00056     maxCellType_(NullCell),
00057     isInternalBdry_(false),
00058     forbidCofacetIntegrations_(false),
00059     cellLID_(),
00060     JVol_(rcp(new CellJacobianBatch())),
00061     JTrans_(rcp(new CellJacobianBatch())),
00062     facetIndices_(rcp(new Array<int>())),
00063     maxCellLIDs_(rcp(new Array<int>())),
00064     cofacetCellsAreReady_(false),
00065     cacheIsValid_(false),
00066     jCacheIsValid_(false),
00067     fCache_(),
00068     dfCache_(),
00069     localValueCache_(),
00070     mapStructCache_(),
00071     fCacheIsValid_(),
00072     dfCacheIsValid_(),
00073     localValueCacheIsValid_()
00074 {;}
00075 
00076 void StdFwkEvalMediator::setCellType(const CellType& cellType,
00077   const CellType& maxCellType,
00078   bool isInternalBdry) 
00079 {
00080   cellType_=cellType; 
00081   cellDim_ = dimension(cellType);
00082   maxCellType_ = maxCellType;
00083   isInternalBdry_ = isInternalBdry;
00084   cacheIsValid() = false; 
00085   jCacheIsValid_=false;
00086   cofacetCellsAreReady_ = false;
00087   forbidCofacetIntegrations_ = isInternalBdry_ ;
00088 //    && !ElementIntegral::alwaysUseCofacets();
00089 }
00090 
00091 
00092 void StdFwkEvalMediator::setIntegrationSpec(
00093   IntegrationCellSpecifier intCellSpec)
00094 {
00095   intCellSpec_ = intCellSpec;
00096 }
00097 
00098 void StdFwkEvalMediator::setCellBatch(
00099   const RCP<const Array<int> >& cellLID) 
00100 {
00101   Tabs tab(0);
00102   SUNDANCE_MSG1(verb(), tab << "eval med setting cell batch");
00103   Tabs tab1;
00104 
00105   cellLID_ = cellLID; 
00106   cacheIsValid() = false; 
00107   jCacheIsValid_=false;
00108   cofacetCellsAreReady_ = false;
00109 
00110   SUNDANCE_MSG2(verb(), tab1 << "getting volume Jacobians");
00111   mesh_.getJacobians(cellDim(), *cellLID, *JVol_);
00112   if (intCellSpec_!=NoTermsNeedCofacets) setupFacetTransformations();
00113 
00114   /* mark the function caches as invalid */
00115   SUNDANCE_MSG2(verb(), tab1 << "flushing old function caches");
00116   Map<const DiscreteFunctionData*, bool>::iterator iter;
00117   for (iter = fCacheIsValid_.begin(); iter != fCacheIsValid_.end(); iter++)
00118     {
00119       iter->second = false;
00120     }
00121   for (iter = dfCacheIsValid_.begin(); iter != dfCacheIsValid_.end(); iter++)
00122     {
00123       iter->second = false;
00124     }
00125   for (iter = localValueCacheIsValid_.begin(); iter != localValueCacheIsValid_.end(); iter++)
00126     {
00127       iter->second = false;
00128     }
00129 }
00130 
00131 void StdFwkEvalMediator::setupFacetTransformations() const 
00132 {
00133   Tabs tab(0);
00134   SUNDANCE_MSG1(verb(), tab << "setting up facet transformations");
00135   Tabs tab1;
00136 
00137   const Array<int>& cells = *cellLID_;
00138 
00139   SUNDANCE_MSG2(verb(), tab1 << "num cells in batch = " << cells.size());
00140   SUNDANCE_MSG2(verb(), tab1 << "cell dim = " << cellDim());
00141   SUNDANCE_MSG2(verb(), tab1 << "num d-cells in mesh = " << mesh_.numCells(cellDim()));
00142   
00143 
00144   facetIndices_->resize(cells.size());
00145   maxCellLIDs_->resize(cells.size());
00146   cofacetCellsAreReady_ = true;
00147 
00148   for (int c=0; c<cells.size(); c++)
00149     {
00150       Tabs tab2;
00151       SUNDANCE_MSG2(verb(), tab2 << "c = " << c);
00152       SUNDANCE_MSG2(verb(), tab2 << "cells[c] = " << cells[c]);
00153       (*maxCellLIDs_)[c] 
00154         = mesh_.maxCofacetLID(cellDim(), cells[c], 0, (*facetIndices_)[c]);
00155     }
00156 
00157   SUNDANCE_MSG2(verb(), tab1 << "getting facet Jacobians");
00158   mesh_.getJacobians(mesh_.spatialDim(), *maxCellLIDs_, *JTrans_);
00159   SUNDANCE_MSG2(verb(), tab << "setting up facet transformations");
00160 }
00161 
00162 
00163 
00164 const CellJacobianBatch& StdFwkEvalMediator::JTrans() const
00165 {
00166   /* If we're integrating a derivative on a boundary, JVol and JTrans will be
00167    * different. Otherwise, they'll be the same, and we use JVol for both
00168    * volume computations and vector transformations */
00169   if (intCellSpec_ != NoTermsNeedCofacets) 
00170   {
00171     return *JTrans_;
00172   }
00173   else
00174   {
00175     return *JVol_;
00176   }
00177 }

Site Contact