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
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "SundanceBasisFamily.hpp"
00043 #include "SundanceUnknownFunction.hpp"
00044 #include "SundanceTestFunction.hpp"
00045 #include "SundanceDiscreteFunction.hpp"
00046 #include "SundanceUnknownFunctionData.hpp"
00047 #include "SundanceTestFunctionData.hpp"
00048 #include "SundanceDiscreteFunctionData.hpp"
00049 #include "SundanceLagrange.hpp"
00050 #include "SundanceEdgeLocalizedBasis.hpp"
00051
00052
00053 using namespace Sundance;
00054 using namespace Teuchos;
00055 using Playa::Handle;
00056 using Playa::Handleable;
00057
00058
00059
00060
00061
00062 int BasisFamily::order() const
00063 {
00064 return ptr()->order();
00065 }
00066
00067 int BasisFamily::dim() const
00068 {
00069 return ptr()->dim();
00070 }
00071
00072 bool BasisFamily::operator==(const BasisFamily& other) const
00073 {
00074 return !(*this < other || other < *this);
00075 }
00076
00077 int BasisFamily::size(const Array<BasisFamily>& b)
00078 {
00079 int rtn = 0;
00080 for (int i=0; i<b.size(); i++) rtn += b[i].dim();
00081 return rtn;
00082 }
00083
00084 int BasisFamily::nReferenceDOFsWithFacets(const CellType& maximalCellType,
00085 const CellType& cellType) const
00086 {
00087 return ptr()->nReferenceDOFsWithFacets(maximalCellType, cellType);
00088 }
00089
00090 int BasisFamily::nReferenceDOFsWithoutFacets(const CellType& maximalCellType,
00091 const CellType& cellType) const
00092 {
00093 return ptr()->nReferenceDOFsWithoutFacets(maximalCellType, cellType);
00094 }
00095
00096 BasisFamily BasisFamily::getBasis(const RCP<const CommonFuncDataStub>& funcData)
00097 {
00098
00099 const UnknownFunctionData* u
00100 = dynamic_cast<const UnknownFunctionData*>(funcData.get());
00101 if (u != 0)
00102 {
00103 return u->basis()[0];
00104 }
00105
00106
00107 const TestFunctionData* t
00108 = dynamic_cast<const TestFunctionData*>(funcData.get());
00109 if (t != 0)
00110 {
00111 return t->basis()[0];
00112 }
00113
00114
00115
00116 const DiscreteFunctionData* d
00117 = dynamic_cast<const DiscreteFunctionData*>(funcData.get());
00118 if (d != 0)
00119 {
00120 return d->discreteSpace().basis()[0];
00121 }
00122
00123 TEUCHOS_TEST_FOR_EXCEPTION(u==0 && t==0 && d==0, std::runtime_error,
00124 "BasisFamily::getBasis() argument is not a recognized "
00125 "type of function data");
00126 return BasisFamily();
00127
00128 }
00129
00130
00131
00132 RCP<BasisDOFTopologyBase> BasisFamily::getBasisTopology(const RCP<const CommonFuncDataStub>& funcData)
00133 {
00134 BasisFamily b = getBasis(funcData);
00135 TEUCHOS_TEST_FOR_EXCEPT(b.ptr().get()==0);
00136
00137 return rcp_dynamic_cast<BasisDOFTopologyBase>(b.ptr());
00138 }
00139
00140
00141 void BasisFamily::getConstrainsForHNDoF( const int indexInParent,
00142 const int maxCellDim,
00143 const int maxNrChild,
00144 const int facetDim,
00145 const int facetIndex,
00146 const int nodeIndex,
00147 Array<int>& localDoFs,
00148 Array<int>& parentFacetDim,
00149 Array<int>& parentFacetIndex,
00150 Array<int>& parentFacetNode,
00151 Array<double>& coefs
00152 ) const
00153 {
00154 Tabs tab;
00155 int verb = 4;
00156 SUNDANCE_MSG3( verb ,tab << "BasisFamily::getConstrainsForHNDoF IN: indexInParent:" << indexInParent
00157 << " maxCellDim:" << maxCellDim << " maxNrChild:" << maxNrChild
00158 << " facetDim:" << facetDim << " facetIndex:" << facetIndex << " nodeIndex:" << nodeIndex);
00159 ptr()->getConstrainsForHNDoF( indexInParent, maxCellDim ,
00160 maxNrChild , facetDim, facetIndex, nodeIndex, localDoFs, parentFacetDim ,
00161 parentFacetIndex , parentFacetNode , coefs );
00162 SUNDANCE_MSG3( verb , tab << "BasisFamily::getConstrainsForHNDoF OUT: localDoFs:" << localDoFs
00163 << " coefs:" << coefs);
00164 SUNDANCE_MSG3( verb , tab << "BasisFamily::getConstrainsForHNDoF OUT: parentFacetDim:" << parentFacetDim );
00165 SUNDANCE_MSG3( verb , tab << "BasisFamily::getConstrainsForHNDoF OUT: parentFacetIndex:" << parentFacetIndex );
00166 SUNDANCE_MSG3( verb , tab << "BasisFamily::getConstrainsForHNDoF OUT: parentFacetNode:" << parentFacetNode );
00167 }
00168
00169
00170 void BasisFamily::refEval(
00171 const CellType& cellType,
00172 const Array<Point>& pts,
00173 const SpatialDerivSpecifier& deriv,
00174 Array<Array<Array<double> > >& result,
00175 int verbosity) const
00176 {
00177 using std::setw;
00178 Tabs tab;
00179 SUNDANCE_MSG3(verbosity, tab << "evaluating basis " << *this
00180 << " with spatial derivative " << deriv);
00181 ptr()->refEval(cellType, pts, deriv, result, verbosity);
00182 std::string f = deriv.toString()+ "[phi_n]";
00183
00184 if (verbosity >= 4)
00185 {
00186 Tabs tab1;
00187 for (int q=0; q<pts.size(); q++)
00188 {
00189 Tabs tab2;
00190 Out::os() << tab1 << "evaluation point = " << pts[q] << std::endl;
00191 Out::os() << tab2 << setw(5) << "n";
00192 int nComps = result.size();
00193 if (nComps == 1)
00194 {
00195 Out::os() << setw(20) << f << std::endl;
00196 }
00197 else
00198 {
00199 for (int d=0; d<nComps; d++)
00200 {
00201 std::string fd = f + "[" + Teuchos::toString(d) + "]";
00202 Out::os() << setw(20) << fd;
00203 }
00204 Out::os() << std::endl;
00205 }
00206 for (int n=0; n<result[0][q].size(); n++)
00207 {
00208 Out::os() << tab2 << setw(5) << n;
00209 for (int d=0; d<nComps; d++)
00210 {
00211 Out::os() << setw(20) << result[d][q][n];
00212 }
00213 Out::os() << std::endl;
00214 }
00215 }
00216 }
00217 }
00218
00219
00220 namespace Sundance
00221 {
00222
00223 Array<std::pair<int, int> >
00224 vectorDimStructure(const Array<BasisFamily>& basis)
00225 {
00226 Array<std::pair<int, int> > rtn;
00227 for (int i=0; i<basis.size(); i++)
00228 {
00229 rtn.append(std::pair<int, int>(basis[i].tensorOrder(), basis[i].dim()));
00230 }
00231 return rtn;
00232 }
00233
00234
00235 Array<std::pair<int, int> > vectorDimStructure(const BasisFamily& basis)
00236 {
00237 return vectorDimStructure(tuple(basis));
00238 }
00239
00240 bool basisRestrictableToBoundary(const BasisFamily& b)
00241 {
00242 const Lagrange* lag = dynamic_cast<const Lagrange*>(b.ptr().get());
00243 const EdgeLocalizedBasis* elb = dynamic_cast<const EdgeLocalizedBasis*>(b.ptr().get());
00244 return lag != 0 || elb != 0;
00245 }
00246
00247 }