00001
00002
00003
00004
00005
00006
00007 #ifndef QCAD_POISSONPROBLEM_HPP
00008 #define QCAD_POISSONPROBLEM_HPP
00009
00010 #include "Teuchos_RCP.hpp"
00011 #include "Teuchos_ParameterList.hpp"
00012
00013 #include "Albany_AbstractProblem.hpp"
00014 #include "Albany_ProblemUtils.hpp"
00015 #include "Albany_ResponseUtilities.hpp"
00016
00017 #include "Phalanx.hpp"
00018 #include "PHAL_Workset.hpp"
00019 #include "PHAL_Dimension.hpp"
00020 #include "QCAD_MaterialDatabase.hpp"
00021
00022
00024 namespace QCAD {
00025
00030 class PoissonProblem : public Albany::AbstractProblem
00031 {
00032 public:
00033
00035 PoissonProblem(const Teuchos::RCP<Teuchos::ParameterList>& params,
00036 const Teuchos::RCP<ParamLib>& paramLib,
00037 const int numDim_,
00038 const Teuchos::RCP<const Epetra_Comm>& comm_);
00039
00041 ~PoissonProblem();
00042
00044 virtual int spatialDimension() const { return numDim; }
00045
00047 virtual void buildProblem(
00048 Teuchos::ArrayRCP<Teuchos::RCP<Albany::MeshSpecsStruct> > meshSpecs,
00049 Albany::StateManager& stateMgr);
00050
00051
00052 virtual Teuchos::Array< Teuchos::RCP<const PHX::FieldTag> >
00053 buildEvaluators(
00054 PHX::FieldManager<PHAL::AlbanyTraits>& fm0,
00055 const Albany::MeshSpecsStruct& meshSpecs,
00056 Albany::StateManager& stateMgr,
00057 Albany::FieldManagerChoice fmchoice,
00058 const Teuchos::RCP<Teuchos::ParameterList>& responseList);
00059
00061 Teuchos::RCP<const Teuchos::ParameterList> getValidProblemParameters() const;
00062
00063 private:
00064
00066 PoissonProblem(const PoissonProblem&);
00067
00069 PoissonProblem& operator=(const PoissonProblem&);
00070
00071 public:
00072
00074 template <typename EvalT>
00075 Teuchos::RCP<const PHX::FieldTag>
00076 constructEvaluators(
00077 PHX::FieldManager<PHAL::AlbanyTraits>& fm0,
00078 const Albany::MeshSpecsStruct& meshSpecs,
00079 Albany::StateManager& stateMgr,
00080 Albany::FieldManagerChoice fmchoice,
00081 const Teuchos::RCP<Teuchos::ParameterList>& responseList);
00082
00083 void constructDirichletEvaluators(const Albany::MeshSpecsStruct& meshSpecs);
00084 void constructNeumannEvaluators(const Teuchos::RCP<Albany::MeshSpecsStruct>& meshSpecs);
00085
00086 protected:
00087
00089 bool periodic;
00090
00092 Teuchos::RCP<const Epetra_Comm> comm;
00093 bool haveSource;
00094 int numDim;
00095 double length_unit_in_m;
00096 double energy_unit_in_eV;
00097 double temperature;
00098 Teuchos::RCP<QCAD::MaterialDatabase> materialDB;
00099 Teuchos::RCP<Albany::Layouts> dl;
00100
00102 int nEigenvectors;
00103
00104
00105
00106
00107
00108
00109
00110
00111 };
00112
00113 }
00114
00115 #include "QCAD_MaterialDatabase.hpp"
00116 #include "Albany_ProblemUtils.hpp"
00117 #include "Albany_EvaluatorUtils.hpp"
00118
00119 #include "PHAL_GatherEigenvectors.hpp"
00120 #include "QCAD_Permittivity.hpp"
00121 #include "PHAL_SharedParameter.hpp"
00122 #include "QCAD_PoissonSource.hpp"
00123 #include "PHAL_DOFInterpolation.hpp"
00124 #include "QCAD_PoissonResid.hpp"
00125 #include "QCAD_ResponseSaddleValue.hpp"
00126
00127 #include "PHAL_SaveStateField.hpp"
00128
00129 template <typename EvalT>
00130 Teuchos::RCP<const PHX::FieldTag>
00131 QCAD::PoissonProblem::constructEvaluators(
00132 PHX::FieldManager<PHAL::AlbanyTraits>& fm0,
00133 const Albany::MeshSpecsStruct& meshSpecs,
00134 Albany::StateManager& stateMgr,
00135 Albany::FieldManagerChoice fieldManagerChoice,
00136 const Teuchos::RCP<Teuchos::ParameterList>& responseList)
00137 {
00138 using Teuchos::RCP;
00139 using Teuchos::rcp;
00140 using Teuchos::ParameterList;
00141 using PHX::DataLayout;
00142 using PHX::MDALayout;
00143 using std::vector;
00144 using std::string;
00145 using PHAL::AlbanyTraits;
00146
00147 RCP<shards::CellTopology> cellType = rcp(new shards::CellTopology (&meshSpecs.ctd));
00148 RCP<Intrepid::Basis<RealType, Intrepid::FieldContainer<RealType> > >
00149 intrepidBasis = Albany::getIntrepidBasis(meshSpecs.ctd);
00150
00151 const int numNodes = intrepidBasis->getCardinality();
00152 const int worksetSize = meshSpecs.worksetSize;
00153
00154 Intrepid::DefaultCubatureFactory<RealType> cubFactory;
00155 RCP <Intrepid::Cubature<RealType> > cubature = cubFactory.create(*cellType, meshSpecs.cubatureDegree);
00156
00157 const int numQPts = cubature->getNumPoints();
00158 const int numVertices = cellType->getNodeCount();
00159
00160 *out << "Field Dimensions: Workset=" << worksetSize
00161 << ", Vertices= " << numVertices
00162 << ", Nodes= " << numNodes
00163 << ", QuadPts= " << numQPts
00164 << ", Dim= " << numDim << std::endl;
00165
00166 dl = rcp(new Albany::Layouts(worksetSize,numVertices,numNodes,numQPts,numDim));
00167 Albany::EvaluatorUtils<EvalT, PHAL::AlbanyTraits> evalUtils(dl);
00168 bool supportsTransient=false;
00169
00170
00171 Teuchos::RCP<PHX::Evaluator<AlbanyTraits> > ev;
00172
00173
00174
00175 Teuchos::ArrayRCP<string> dof_names(neq);
00176 dof_names[0] = "Potential";
00177
00178 Teuchos::ArrayRCP<string> dof_names_dot(neq);
00179 if (supportsTransient) {
00180 for (unsigned int i=0; i<neq; i++) dof_names_dot[i] = dof_names[i]+"_dot";
00181 }
00182
00183 Teuchos::ArrayRCP<string> resid_names(neq);
00184 for (unsigned int i=0; i<neq; i++) resid_names[i] = dof_names[i]+" Residual";
00185
00186 if (supportsTransient) fm0.template registerEvaluator<EvalT>
00187 (evalUtils.constructGatherSolutionEvaluator(false, dof_names, dof_names_dot));
00188 else fm0.template registerEvaluator<EvalT>
00189 (evalUtils.constructGatherSolutionEvaluator_noTransient(false, dof_names));
00190
00191 fm0.template registerEvaluator<EvalT>
00192 (evalUtils.constructScatterResidualEvaluator(false, resid_names));
00193
00194 fm0.template registerEvaluator<EvalT>
00195 (evalUtils.constructGatherCoordinateVectorEvaluator());
00196
00197 fm0.template registerEvaluator<EvalT>
00198 (evalUtils.constructMapToPhysicalFrameEvaluator(cellType, cubature));
00199
00200 fm0.template registerEvaluator<EvalT>
00201 (evalUtils.constructComputeBasisFunctionsEvaluator(cellType, intrepidBasis, cubature));
00202
00203 for (unsigned int i=0; i<neq; i++) {
00204 fm0.template registerEvaluator<EvalT>
00205 (evalUtils.constructDOFInterpolationEvaluator(dof_names[i], i));
00206
00207 if (supportsTransient)
00208 fm0.template registerEvaluator<EvalT>
00209 (evalUtils.constructDOFInterpolationEvaluator(dof_names_dot[i], i));
00210
00211 fm0.template registerEvaluator<EvalT>
00212 (evalUtils.constructDOFGradInterpolationEvaluator(dof_names[i], i));
00213 }
00214
00215 {
00216 RCP<ParameterList> p = rcp(new ParameterList);
00217 p->set<string>("Eigenvector field name root", "Evec");
00218 p->set<int>("Number of eigenvectors", nEigenvectors);
00219
00220 ev = rcp(new PHAL::GatherEigenvectors<EvalT,AlbanyTraits>(*p,dl));
00221 fm0.template registerEvaluator<EvalT>(ev);
00222 }
00223
00224 {
00225 RCP<ParameterList> p = rcp(new ParameterList);
00226
00227 p->set<string>("QP Variable Name", "Permittivity");
00228 p->set<string>("Coordinate Vector Name", "Coord Vec");
00229
00230 p->set< RCP<ParamLib> >("Parameter Library", paramLib);
00231 Teuchos::ParameterList& paramList = params->sublist("Permittivity");
00232 p->set<Teuchos::ParameterList*>("Parameter List", ¶mList);
00233
00234 p->set< RCP<QCAD::MaterialDatabase> >("MaterialDB", materialDB);
00235
00236 ev = rcp(new QCAD::Permittivity<EvalT,AlbanyTraits>(*p,dl));
00237 fm0.template registerEvaluator<EvalT>(ev);
00238 }
00239
00240 {
00241 RCP<ParameterList> p = rcp(new ParameterList);
00242
00243 p->set<string>("Parameter Name", "Temperature");
00244 p->set<double>("Parameter Value", temperature);
00245 p->set< RCP<DataLayout> >("Data Layout", dl->shared_param);
00246 p->set< RCP<ParamLib> >("Parameter Library", paramLib);
00247
00248 ev = rcp(new PHAL::SharedParameter<EvalT,AlbanyTraits>(*p));
00249 fm0.template registerEvaluator<EvalT>(ev);
00250 }
00251
00252 if (haveSource)
00253 {
00254 RCP<ParameterList> p = rcp(new ParameterList);
00255
00256
00257 p->set< string >("Coordinate Vector Name", "Coord Vec");
00258
00259 p->set<string>("Variable Name", "Potential");
00260
00261 p->set<RCP<ParamLib> >("Parameter Library", paramLib);
00262
00263
00264 Teuchos::ParameterList& paramList = params->sublist("Poisson Source");
00265 p->set<Teuchos::ParameterList*>("Parameter List", ¶mList);
00266
00267
00268 Teuchos::ParameterList& dbcPList = params->sublist("Dirichlet BCs");
00269 p->set<Teuchos::ParameterList*>("Dirichlet BCs ParameterList", &dbcPList);
00270
00271
00272 p->set<double>("Energy unit in eV",energy_unit_in_eV);
00273
00274
00275 p->set<string>("Source Name", "Poisson Source");
00276
00277
00278 p->set<double>("Length unit in m", length_unit_in_m);
00279 p->set<string>("Temperature Name", "Temperature");
00280 p->set< RCP<QCAD::MaterialDatabase> >("MaterialDB", materialDB);
00281
00282
00283 p->set<string>("Eigenvector field name root", "Evec");
00284
00285 ev = rcp(new QCAD::PoissonSource<EvalT,AlbanyTraits>(*p,dl));
00286 fm0.template registerEvaluator<EvalT>(ev);
00287 }
00288
00289
00290 char buf[100];
00291 for( int k = 0; k < nEigenvectors; k++)
00292 {
00293
00294 RCP<ParameterList> p;
00295
00296
00297 sprintf(buf, "Poisson Eigenvector Re %d interpolate to qps", k);
00298 p = rcp(new ParameterList(buf));
00299
00300
00301 sprintf(buf, "Evec_Re%d", k);
00302 p->set<string>("Variable Name", buf);
00303 p->set<string>("BF Name", "BF");
00304 p->set<int>("Offset of First DOF", 0);
00305
00306
00307
00308 sprintf(buf, "Eigenvector Re %d interpolate to qps", k);
00309 ev = rcp(new PHAL::DOFInterpolation<EvalT,AlbanyTraits>(*p,dl));
00310 fm0.template registerEvaluator<EvalT>(ev);
00311
00312
00313
00314 sprintf(buf, "Eigenvector Im %d interpolate to qps", k);
00315 p = rcp(new ParameterList(buf));
00316
00317
00318 sprintf(buf, "Evec_Im%d", k);
00319 p->set<string>("Variable Name", buf);
00320 p->set<string>("BF Name", "BF");
00321 p->set<int>("Offset of First DOF", 0);
00322
00323
00324
00325 sprintf(buf, "Eigenvector Im %d interpolate to qps", k);
00326 ev = rcp(new PHAL::DOFInterpolation<EvalT,AlbanyTraits>(*p,dl));
00327 fm0.template registerEvaluator<EvalT>(ev);
00328 }
00329
00330 {
00331 RCP<ParameterList> p = rcp(new ParameterList("Potential Resid"));
00332
00333
00334 p->set<string>("Weighted BF Name", "wBF");
00335 p->set<string>("QP Variable Name", "Potential");
00336
00337 p->set<string>("QP Time Derivative Variable Name", "Potential_dot");
00338
00339 p->set<bool>("Have Source", haveSource);
00340 p->set<string>("Source Name", "Poisson Source");
00341
00342 p->set<string>("Permittivity Name", "Permittivity");
00343
00344 p->set<string>("Gradient QP Variable Name", "Potential Gradient");
00345 p->set<string>("Flux QP Variable Name", "Potential Flux");
00346
00347 p->set<string>("Weighted Gradient BF Name", "wGrad BF");
00348
00349
00350
00351 p->set<string>("Residual Name", "Potential Residual");
00352
00353 ev = rcp(new QCAD::PoissonResid<EvalT,AlbanyTraits>(*p,dl));
00354 fm0.template registerEvaluator<EvalT>(ev);
00355 }
00356
00357
00358 if (fieldManagerChoice == Albany::BUILD_RESID_FM) {
00359 PHX::Tag<typename EvalT::ScalarT> res_tag("Scatter", dl->dummy);
00360 fm0.requireField<EvalT>(res_tag);
00361 return res_tag.clone();
00362 }
00363
00364 else if (fieldManagerChoice == Albany::BUILD_RESPONSE_FM) {
00365
00366
00367
00368
00369 RCP<ParameterList> pFromProb = rcp(new ParameterList("Response Parameters from Problem"));
00370 pFromProb->set<double>("Length unit in m", length_unit_in_m);
00371 pFromProb->set<double>("Temperature", temperature);
00372 pFromProb->set< RCP<QCAD::MaterialDatabase> >("MaterialDB", materialDB);
00373
00374 Albany::ResponseUtilities<EvalT, PHAL::AlbanyTraits> respUtils(dl);
00375 return respUtils.constructResponses(fm0, *responseList, pFromProb, stateMgr);
00376 }
00377
00378 return Teuchos::null;
00379 }
00380 #endif