Go to the documentation of this file.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 "SundanceDiscreteFunctionData.hpp"
00032 #include "SundanceOut.hpp"
00033 #include "SundanceTabs.hpp"
00034 #include "SundanceMaximalCellFilter.hpp"
00035 #include "SundanceCellFilter.hpp"
00036 #include "SundanceCellSet.hpp"
00037 #include "SundanceSubtypeEvaluator.hpp"
00038
00039
00040 #ifndef HAVE_TEUCHOS_EXPLICIT_INSTANTIATION
00041 #include "TSFVectorImpl.hpp"
00042 #endif
00043
00044
00045 using namespace Sundance;
00046 using namespace Teuchos;
00047
00048
00049
00050
00051 DiscreteFunctionData::DiscreteFunctionData(const DiscreteSpace& space)
00052 : DiscreteFuncDataStub(),
00053 space_(space),
00054 vector_(space_.createVector()),
00055 ghostView_(),
00056 ghostsAreValid_(false)
00057 {}
00058
00059 DiscreteFunctionData::DiscreteFunctionData(const DiscreteSpace& space,
00060 const double& constantValue)
00061 : DiscreteFuncDataStub(),
00062 space_(space),
00063 vector_(space_.createVector()),
00064 ghostView_(),
00065 ghostsAreValid_(false)
00066 {
00067 vector_.setToConstant(constantValue);
00068 }
00069
00070 DiscreteFunctionData::DiscreteFunctionData(const DiscreteSpace& space,
00071 const Vector<double>& vector)
00072 : DiscreteFuncDataStub(),
00073 space_(space),
00074 vector_(vector),
00075 ghostView_(),
00076 ghostsAreValid_(false)
00077 {}
00078
00079 const DiscreteFunctionData* DiscreteFunctionData::getData(const DiscreteFuncElement* dfe)
00080 {
00081 TEST_FOR_EXCEPTION(dfe==0, RuntimeError, "null argument to DiscreteFunctionData::getData()");
00082 RCP<const DiscreteFunctionData> rtn
00083 = rcp_dynamic_cast<const DiscreteFunctionData>(dfe->commonData());
00084 TEST_FOR_EXCEPTION(rtn.get()==0, RuntimeError,
00085 "cast to DiscreteFunctionData* failed for "
00086 "discrete function element " << dfe->toXML());
00087 return rtn.get();
00088 }
00089
00090 void DiscreteFunctionData::setVector(const Vector<double>& vec)
00091 {
00092 ghostsAreValid_ = false;
00093 vector_ = vec;
00094 }
00095
00096 void DiscreteFunctionData::updateGhosts() const
00097 {
00098 if (!ghostsAreValid_)
00099 {
00100 space_.importGhosts(vector_, ghostView_);
00101 ghostsAreValid_ = true;
00102 }
00103 }
00104
00105
00106 RCP<const MapStructure> DiscreteFunctionData
00107 ::getLocalValues(int cellDim,
00108 const Array<int>& cellLID,
00109 Array<Array<double> >& localValues) const
00110 {
00111 Tabs tab;
00112
00113 if (Evaluator::classVerbosity() > 3)
00114 {
00115 Out::os() << tab << "getting DF local values" << std::endl;
00116 }
00117 updateGhosts();
00118
00119 const RCP<DOFMapBase>& map = space_.map();
00120 static Array<Array<int> > dofs;
00121 Array<int> nNodes;
00122
00123 RCP<const Set<int> > requestedFuncs = map->allowedFuncsOnCellBatch(cellDim,
00124 cellLID);
00125
00126 RCP<const MapStructure> s = map->getDOFsForCellBatch(cellDim, cellLID,
00127 *requestedFuncs,
00128 dofs, nNodes, Evaluator::classVerbosity());
00129 localValues.resize(s->numBasisChunks());
00130
00131
00132 if (space_.getTransformation()->validTransformation())
00133 {
00134 SUNDANCE_OUT( Evaluator::classVerbosity() > 3 , "DiscreteFunctionData::getLocalValues() VALID TRAFO FOUND ... ")
00135 for (int b=0; b<nNodes.size(); b++)
00136 {
00137 int nFuncs = s->numFuncs(b);
00138 Array<int> functionIDs = s->funcs(b);
00139 localValues[b].resize(nFuncs*nNodes[b]*cellLID.size());
00140
00141
00142 ghostView_->getElements(&(dofs[b][0]), dofs[b].size(), localValues[b]);
00143
00144
00145
00146 space_.getTransformation()->getDoFsWithTransformation(
00147 dofs[b] , functionIDs , b , nNodes[b] , nFuncs , cellDim, cellLID ,ghostView_ , localValues[b] );
00148 }
00149 }
00150 else
00151 {
00152 SUNDANCE_OUT( Evaluator::classVerbosity() > 3 , "DiscreteFunctionData::getLocalValues() NO VALID TRAFO ... ")
00153 for (int b=0; b<nNodes.size(); b++)
00154 {
00155 int nFuncs = s->numFuncs(b);
00156 localValues[b].resize(nFuncs*nNodes[b]*cellLID.size());
00157 ghostView_->getElements(&(dofs[b][0]), dofs[b].size(), localValues[b]);
00158 }
00159 }
00160
00161 return s;
00162 }
00163
00164
00165