• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

Albany_HeatProblem.cpp

Go to the documentation of this file.
00001 //*****************************************************************//
00002 //    Albany 2.0:  Copyright 2012 Sandia Corporation               //
00003 //    This Software is released under the BSD license detailed     //
00004 //    in the file "license.txt" in the top-level Albany directory  //
00005 //*****************************************************************//
00006 
00007 #include "Albany_HeatProblem.hpp"
00008 
00009 #include "Intrepid_FieldContainer.hpp"
00010 #include "Intrepid_DefaultCubatureFactory.hpp"
00011 #include "Shards_CellTopology.hpp"
00012 #include "PHAL_FactoryTraits.hpp"
00013 #include "Albany_Utils.hpp"
00014 
00015 
00016 Albany::HeatProblem::
00017 HeatProblem( const Teuchos::RCP<Teuchos::ParameterList>& params_,
00018              const Teuchos::RCP<ParamLib>& paramLib_,
00019              const int numDim_,
00020              const Teuchos::RCP<const Epetra_Comm>& comm_) :
00021   Albany::AbstractProblem(params_, paramLib_),
00022   haveSource(false),
00023   haveAbsorption(false),
00024   numDim(numDim_),
00025   comm(comm_)
00026 {
00027   this->setNumEquations(1);
00028 
00029   if (numDim==1) periodic = params->get("Periodic BC", false);
00030   else           periodic = false;
00031   if (periodic) *out <<" Periodic Boundary Conditions being used." <<std::endl;
00032 
00033   haveAbsorption =  params->isSublist("Absorption");
00034 
00035   if(params->isType<std::string>("MaterialDB Filename")){
00036 
00037     std::string mtrlDbFilename = params->get<std::string>("MaterialDB Filename");
00038  // Create Material Database
00039     materialDB = Teuchos::rcp(new QCAD::MaterialDatabase(mtrlDbFilename, comm));
00040 
00041   }
00042 
00043 
00044 }
00045 
00046 Albany::HeatProblem::
00047 ~HeatProblem()
00048 {
00049 }
00050 
00051 void
00052 Albany::HeatProblem::
00053 buildProblem(
00054   Teuchos::ArrayRCP<Teuchos::RCP<Albany::MeshSpecsStruct> >  meshSpecs,
00055   Albany::StateManager& stateMgr)
00056 {
00057   /* Construct All Phalanx Evaluators */
00058   int physSets = meshSpecs.size();
00059   std::cout << "Heat Problem Num MeshSpecs: " << physSets << std::endl;
00060   fm.resize(physSets);
00061 
00062   for (int ps=0; ps<physSets; ps++) {
00063     fm[ps]  = Teuchos::rcp(new PHX::FieldManager<PHAL::AlbanyTraits>);
00064     buildEvaluators(*fm[ps], *meshSpecs[ps], stateMgr, BUILD_RESID_FM,
00065                     Teuchos::null);
00066   }
00067 
00068   if(meshSpecs[0]->nsNames.size() > 0) // Build a nodeset evaluator if nodesets are present
00069 
00070     constructDirichletEvaluators(meshSpecs[0]->nsNames);
00071 
00072   if(meshSpecs[0]->ssNames.size() > 0) // Build a sideset evaluator if sidesets are present
00073 
00074     constructNeumannEvaluators(meshSpecs[0]);
00075 
00076 }
00077 
00078 Teuchos::Array<Teuchos::RCP<const PHX::FieldTag> >
00079 Albany::HeatProblem::
00080 buildEvaluators(
00081   PHX::FieldManager<PHAL::AlbanyTraits>& fm0,
00082   const Albany::MeshSpecsStruct& meshSpecs,
00083   Albany::StateManager& stateMgr,
00084   Albany::FieldManagerChoice fmchoice,
00085   const Teuchos::RCP<Teuchos::ParameterList>& responseList)
00086 {
00087   // Call constructEvaluators<EvalT>(*rfm[0], *meshSpecs[0], stateMgr);
00088   // for each EvalT in PHAL::AlbanyTraits::BEvalTypes
00089   ConstructEvaluatorsOp<HeatProblem> op(
00090     *this, fm0, meshSpecs, stateMgr, fmchoice, responseList);
00091   boost::mpl::for_each<PHAL::AlbanyTraits::BEvalTypes>(op);
00092   return *op.tags;
00093 }
00094 
00095 // Dirichlet BCs
00096 void
00097 Albany::HeatProblem::constructDirichletEvaluators(const std::vector<std::string>& nodeSetIDs)
00098 {
00099    // Construct BC evaluators for all node sets and names
00100    std::vector<std::string> bcNames(neq);
00101    bcNames[0] = "T";
00102    Albany::BCUtils<Albany::DirichletTraits> bcUtils;
00103    dfm = bcUtils.constructBCEvaluators(nodeSetIDs, bcNames,
00104                                           this->params, this->paramLib);
00105 }
00106 
00107 // Neumann BCs
00108 void
00109 Albany::HeatProblem::constructNeumannEvaluators(const Teuchos::RCP<Albany::MeshSpecsStruct>& meshSpecs)
00110 {
00111    // Note: we only enter this function if sidesets are defined in the mesh file
00112    // i.e. meshSpecs.ssNames.size() > 0
00113 
00114    Albany::BCUtils<Albany::NeumannTraits> bcUtils;
00115 
00116    // Check to make sure that Neumann BCs are given in the input file
00117 
00118    if(!bcUtils.haveBCSpecified(this->params))
00119 
00120       return;
00121 
00122    // Construct BC evaluators for all side sets and names
00123    // Note that the string index sets up the equation offset, so ordering is important
00124    std::vector<std::string> bcNames(neq);
00125    Teuchos::ArrayRCP<std::string> dof_names(neq);
00126    Teuchos::Array<Teuchos::Array<int> > offsets;
00127    offsets.resize(neq);
00128 
00129    bcNames[0] = "T";
00130    dof_names[0] = "Temperature";
00131    offsets[0].resize(1);
00132    offsets[0][0] = 0;
00133 
00134 
00135    // Construct BC evaluators for all possible names of conditions
00136    // Should only specify flux vector components (dudx, dudy, dudz), or dudn, not both
00137    std::vector<std::string> condNames(4); 
00138      //dudx, dudy, dudz, dudn, scaled jump (internal surface), or robin (like DBC plus scaled jump)
00139 
00140    // Note that sidesets are only supported for two and 3D currently
00141    if(numDim == 2)
00142     condNames[0] = "(dudx, dudy)";
00143    else if(numDim == 3)
00144     condNames[0] = "(dudx, dudy, dudz)";
00145    else
00146     TEUCHOS_TEST_FOR_EXCEPTION(true, Teuchos::Exceptions::InvalidParameter,
00147        std::endl << "Error: Sidesets only supported in 2 and 3D." << std::endl);
00148 
00149    condNames[1] = "dudn";
00150 
00151    condNames[2] = "scaled jump";
00152 
00153    condNames[3] = "robin";
00154 
00155    nfm.resize(1); // Heat problem only has one physics set   
00156    nfm[0] = bcUtils.constructBCEvaluators(meshSpecs, bcNames, dof_names, false, 0,
00157           condNames, offsets, dl, this->params, this->paramLib, materialDB);
00158 
00159 }
00160 
00161 Teuchos::RCP<const Teuchos::ParameterList>
00162 Albany::HeatProblem::getValidProblemParameters() const
00163 {
00164   Teuchos::RCP<Teuchos::ParameterList> validPL =
00165     this->getGenericProblemParams("ValidHeatProblemParams");
00166 
00167   if (numDim==1)
00168     validPL->set<bool>("Periodic BC", false, "Flag to indicate periodic BC for 1D problems");
00169   validPL->sublist("Thermal Conductivity", false, "");
00170   validPL->set("Convection Velocity", "{0,0,0}", "");
00171   validPL->set<bool>("Have Rho Cp", false, "Flag to indicate if rhoCp is used");
00172   validPL->set<std::string>("MaterialDB Filename","materials.xml","Filename of material database xml file");
00173 
00174   return validPL;
00175 }
00176 

Generated on Wed Mar 26 2014 18:36:36 for Albany: a Trilinos-based PDE code by  doxygen 1.7.1