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
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "SundanceGrouperBase.hpp"
00043 #include "SundanceOut.hpp"
00044 #include "PlayaTabs.hpp"
00045 #include "SundanceFuncWithBasis.hpp"
00046 #include "SundanceBasisFamily.hpp"
00047 #include "SundanceQuadratureFamily.hpp"
00048 #include "SundanceEquationSet.hpp"
00049 #include "SundanceUnknownFuncElement.hpp"
00050 #include "SundanceTestFuncElement.hpp"
00051 #include "SundanceUnknownFunction.hpp"
00052 #include "SundanceUnknownParameterElement.hpp"
00053 #include "SundanceTestFunction.hpp"
00054
00055 using namespace Sundance;
00056 using namespace Sundance;
00057 using namespace Sundance;
00058 using namespace Sundance;
00059 using namespace Sundance;
00060 using namespace Sundance;
00061 using namespace Sundance;
00062 using namespace Teuchos;
00063
00064
00065
00066 void GrouperBase::setVerb(
00067 int setupVerb,
00068 int integrationVerb,
00069 int transformVerb)
00070 {
00071 setupVerb_ = setupVerb;
00072 integrationVerb_ = integrationVerb;
00073 transformVerb_ = transformVerb;
00074 }
00075
00076
00077
00078 void GrouperBase::extractWeakForm(const EquationSet& eqn,
00079 const MultipleDeriv& functionalDeriv,
00080 BasisFamily& varBasis,
00081 BasisFamily& unkBasis,
00082 MultiIndex& miVar, MultiIndex& miUnk,
00083 int& rawVarID, int& rawUnkID,
00084 int& reducedVarID, int& reducedUnkID,
00085 int& testBlock, int& unkBlock,
00086 int& rawParamID, int& reducedParamID,
00087 bool& isOneForm, bool& hasParam) const
00088 {
00089 Tabs tab0(0);
00090
00091 MultipleDeriv::const_iterator iter;
00092
00093 isOneForm = false;
00094 hasParam = false;
00095
00096 if (functionalDeriv.size()==0) return;
00097
00098 TEUCHOS_TEST_FOR_EXCEPTION(functionalDeriv.size() > 2, std::logic_error,
00099 "GrouperBase::extractWeakForm detected a functional "
00100 "derivative of order > 2: "
00101 << functionalDeriv.toString());
00102
00103 bool foundUnk = false;
00104 bool foundVar = false;
00105
00106 SUNDANCE_MSG2(setupVerb(),
00107 tab0 << "extracting weak form for functional derivative "
00108 << functionalDeriv);
00109
00110
00111 for (iter = functionalDeriv.begin(); iter != functionalDeriv.end(); iter++)
00112 {
00113 Tabs tab;
00114 const Deriv& d = *iter;
00115
00116 TEUCHOS_TEST_FOR_EXCEPTION(!d.isFunctionalDeriv(), std::logic_error,
00117 "GrouperBase::extractWeakForm "
00118 "detected a non-functional derivative: "
00119 << functionalDeriv.toString());
00120
00121 const FunctionIdentifier& fid = d.fid();
00122
00123 const SymbolicFuncElement* s = d.symbFuncElem();
00124
00125 TEUCHOS_TEST_FOR_EXCEPTION(s==0, std::logic_error,
00126 "GrouperBase::extractWeakForm failed to cast "
00127 "function to SymbolicFuncElement");
00128
00129
00130 int dofID = fid.dofID();
00131 int myIndex = fid.componentIndex();
00132
00133 if (!foundVar && eqn.hasVarID(dofID))
00134 {
00135 TEUCHOS_TEST_FOR_EXCEPTION(d.isParameter(), std::logic_error,
00136 "Parameter not expected here");
00137 foundVar = true;
00138 reducedVarID = eqn.reducedVarID(dofID);
00139 rawVarID = dofID;
00140 testBlock = eqn.blockForVarID(dofID);
00141
00142 SUNDANCE_MSG2(setupVerb(),
00143 tab << "found varID=" << reducedVarID);
00144
00145 const UnknownFuncElement* u
00146 = dynamic_cast<const UnknownFuncElement*>(s);
00147
00148 const TestFuncElement* t
00149 = dynamic_cast<const TestFuncElement*>(s);
00150
00151 TEUCHOS_TEST_FOR_EXCEPTION(u==0 && t==0, std::logic_error,
00152 "GrouperBase::extractWeakForm could not cast "
00153 "variational function to either an "
00154 "UnknownFuncElement or a TestFuncElement");
00155
00156 if (t != 0)
00157 {
00158 varBasis = TestFunctionData::getData(t)->basis()[myIndex];
00159 }
00160 else
00161 {
00162 varBasis = UnknownFunctionData::getData(u)->basis()[myIndex];
00163 }
00164 SUNDANCE_MSG2(setupVerb(),
00165 tab << "found varBasis=" << varBasis);
00166
00167 miVar = d.opOnFunc().mi();
00168 SUNDANCE_MSG2(setupVerb(),
00169 tab << "found var multi index=" << miVar.toString());
00170 }
00171 else if (eqn.hasFixedParamID(dofID))
00172 {
00173 const UnknownParameterElement* upe
00174 = dynamic_cast<const UnknownParameterElement*>(s);
00175 TEUCHOS_TEST_FOR_EXCEPTION(upe==0, std::logic_error,
00176 "GrouperBase::extractWeakForm could not cast "
00177 "unknown parameter to UnknownParameterElement");
00178 hasParam = true;
00179 rawParamID = dofID;
00180 reducedParamID = eqn.reducedFixedParamID(dofID);
00181 }
00182 else
00183 {
00184 TEUCHOS_TEST_FOR_EXCEPTION(d.isParameter(), std::logic_error,
00185 "Parameter not expected here");
00186 const UnknownFuncElement* u
00187 = dynamic_cast<const UnknownFuncElement*>(s);
00188 TEUCHOS_TEST_FOR_EXCEPTION(u==0, std::logic_error,
00189 "GrouperBase::extractWeakForm could not cast "
00190 "unknown function to UnknownFuncElement");
00191 foundUnk = true;
00192 reducedUnkID = eqn.reducedUnkID(dofID);
00193 rawUnkID = dofID;
00194 unkBlock = eqn.blockForUnkID(dofID);
00195
00196 SUNDANCE_MSG2(setupVerb(),
00197 tab << "found reducedUnkID=" << reducedUnkID);
00198
00199 unkBasis = UnknownFunctionData::getData(u)->basis()[myIndex];
00200 SUNDANCE_MSG2(setupVerb(),
00201 tab << "found unkBasis=" << unkBasis);
00202
00203 miUnk = d.opOnFunc().mi();
00204 SUNDANCE_MSG2(setupVerb(),
00205 tab << "found unk multi index=" << miUnk.toString());
00206 }
00207 }
00208
00209 if (!foundUnk) isOneForm = true;
00210 }