SundanceStdFwkEvalMediator.cpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 // ************************************************************************
00003 // 
00004 //                             Sundance
00005 //                 Copyright 2011 Sandia Corporation
00006 // 
00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00008 // the U.S. Government retains certain rights in this software.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Kevin Long (kevin.long@ttu.edu)
00038 // 
00039 
00040 /* @HEADER@ */
00041 
00042 #include "SundanceStdFwkEvalMediator.hpp"
00043 #include "SundanceCoordExpr.hpp"
00044 #include "SundanceOut.hpp"
00045 #include "PlayaTabs.hpp"
00046 #include "PlayaExceptions.hpp"
00047 
00048 
00049 using namespace Sundance;
00050 using namespace Sundance;
00051 using namespace Sundance;
00052 using namespace Sundance;
00053 using namespace Sundance;
00054 using namespace Sundance;
00055 using namespace Sundance;
00056 using namespace Teuchos;
00057 
00058 
00059 
00060 
00061 
00062 StdFwkEvalMediator::StdFwkEvalMediator(const Mesh& mesh, int cellDim)
00063   : AbstractEvalMediator(),
00064     mesh_(mesh),
00065     cellDim_(cellDim),
00066     cellType_(NullCell),
00067     maxCellType_(NullCell),
00068     isInternalBdry_(false),
00069     forbidCofacetIntegrations_(false),
00070     cellLID_(),
00071     JVol_(rcp(new CellJacobianBatch())),
00072     JTrans_(rcp(new CellJacobianBatch())),
00073     facetIndices_(rcp(new Array<int>())),
00074     maxCellLIDs_(rcp(new Array<int>())),
00075     cofacetCellsAreReady_(false),
00076     cacheIsValid_(false),
00077     jCacheIsValid_(false),
00078     fCache_(),
00079     dfCache_(),
00080     localValueCache_(),
00081     mapStructCache_(),
00082     fCacheIsValid_(),
00083     dfCacheIsValid_(),
00084     localValueCacheIsValid_()
00085 {;}
00086 
00087 void StdFwkEvalMediator::setCellType(const CellType& cellType,
00088   const CellType& maxCellType,
00089   bool isInternalBdry) 
00090 {
00091   cellType_=cellType; 
00092   cellDim_ = dimension(cellType);
00093   maxCellType_ = maxCellType;
00094   isInternalBdry_ = isInternalBdry;
00095   cacheIsValid() = false; 
00096   jCacheIsValid_=false;
00097   cofacetCellsAreReady_ = false;
00098   forbidCofacetIntegrations_ = isInternalBdry_ ;
00099 //    && !ElementIntegral::alwaysUseCofacets();
00100 }
00101 
00102 
00103 void StdFwkEvalMediator::setIntegrationSpec(
00104   IntegrationCellSpecifier intCellSpec)
00105 {
00106   intCellSpec_ = intCellSpec;
00107 }
00108 
00109 void StdFwkEvalMediator::setCellBatch(
00110   const RCP<const Array<int> >& cellLID) 
00111 {
00112   Tabs tab(0);
00113   SUNDANCE_MSG1(verb(), tab << "eval med setting cell batch");
00114   Tabs tab1;
00115 
00116   cellLID_ = cellLID; 
00117   cacheIsValid() = false; 
00118   jCacheIsValid_=false;
00119   cofacetCellsAreReady_ = false;
00120 
00121   SUNDANCE_MSG2(verb(), tab1 << "getting volume Jacobians");
00122   mesh_.getJacobians(cellDim(), *cellLID, *JVol_);
00123   if (intCellSpec_!=NoTermsNeedCofacets) setupFacetTransformations();
00124 
00125   /* mark the function caches as invalid */
00126   SUNDANCE_MSG2(verb(), tab1 << "flushing old function caches");
00127   Map<const DiscreteFunctionData*, bool>::iterator iter;
00128   for (iter = fCacheIsValid_.begin(); iter != fCacheIsValid_.end(); iter++)
00129     {
00130       iter->second = false;
00131     }
00132   for (iter = dfCacheIsValid_.begin(); iter != dfCacheIsValid_.end(); iter++)
00133     {
00134       iter->second = false;
00135     }
00136   for (iter = localValueCacheIsValid_.begin(); iter != localValueCacheIsValid_.end(); iter++)
00137     {
00138       iter->second = false;
00139     }
00140 }
00141 
00142 void StdFwkEvalMediator::setupFacetTransformations() const 
00143 {
00144   Tabs tab(0);
00145   SUNDANCE_MSG1(verb(), tab << "setting up facet transformations");
00146   Tabs tab1;
00147 
00148   const Array<int>& cells = *cellLID_;
00149 
00150   SUNDANCE_MSG2(verb(), tab1 << "num cells in batch = " << cells.size());
00151   SUNDANCE_MSG2(verb(), tab1 << "cell dim = " << cellDim());
00152   SUNDANCE_MSG2(verb(), tab1 << "num d-cells in mesh = " << mesh_.numCells(cellDim()));
00153   
00154 
00155   facetIndices_->resize(cells.size());
00156   maxCellLIDs_->resize(cells.size());
00157   cofacetCellsAreReady_ = true;
00158 
00159   for (int c=0; c<cells.size(); c++)
00160     {
00161       Tabs tab2;
00162       SUNDANCE_MSG2(verb(), tab2 << "c = " << c);
00163       SUNDANCE_MSG2(verb(), tab2 << "cells[c] = " << cells[c]);
00164       (*maxCellLIDs_)[c] 
00165         = mesh_.maxCofacetLID(cellDim(), cells[c], 0, (*facetIndices_)[c]);
00166     }
00167 
00168   SUNDANCE_MSG2(verb(), tab1 << "getting facet Jacobians");
00169   mesh_.getJacobians(mesh_.spatialDim(), *maxCellLIDs_, *JTrans_);
00170   SUNDANCE_MSG2(verb(), tab << "setting up facet transformations");
00171 }
00172 
00173 
00174 
00175 const CellJacobianBatch& StdFwkEvalMediator::JTrans() const
00176 {
00177   /* If we're integrating a derivative on a boundary, JVol and JTrans will be
00178    * different. Otherwise, they'll be the same, and we use JVol for both
00179    * volume computations and vector transformations */
00180   if (intCellSpec_ != NoTermsNeedCofacets) 
00181   {
00182     return *JTrans_;
00183   }
00184   else
00185   {
00186     return *JVol_;
00187   }
00188 }

Site Contact