00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
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
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
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
00167
00168
00169 if (intCellSpec_ != NoTermsNeedCofacets)
00170 {
00171 return *JTrans_;
00172 }
00173 else
00174 {
00175 return *JVol_;
00176 }
00177 }