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

HydrideProblem.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 "HydrideProblem.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::HydrideProblem::
00017 HydrideProblem( 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   numDim(numDim_),
00023   haveNoise(false),
00024   comm(comm_)
00025 {
00026 
00027   // Compute number of equations
00028   int num_eq = 0;
00029   num_eq += numDim; // one displacement equation per dimension
00030   num_eq += 1; // the equation for concentration c
00031   num_eq += 1; // the equation for chemical potential difference w
00032   this->setNumEquations(num_eq);
00033 
00034 }
00035 
00036 Albany::HydrideProblem::
00037 ~HydrideProblem()
00038 {
00039 }
00040 
00041 void
00042 Albany::HydrideProblem::
00043 buildProblem(
00044   Teuchos::ArrayRCP<Teuchos::RCP<Albany::MeshSpecsStruct> >  meshSpecs,
00045   Albany::StateManager& stateMgr)
00046 {
00047   /* Construct All Phalanx Evaluators */
00048   TEUCHOS_TEST_FOR_EXCEPTION(meshSpecs.size()!=1,std::logic_error,"Problem supports one Material Block");
00049 
00050   fm.resize(1);
00051   fm[0]  = Teuchos::rcp(new PHX::FieldManager<PHAL::AlbanyTraits>);
00052   buildEvaluators(*fm[0], *meshSpecs[0], stateMgr, BUILD_RESID_FM, 
00053       Teuchos::null);
00054 
00055   if(meshSpecs[0]->nsNames.size() > 0) // Build a nodeset evaluator if nodesets are present
00056 
00057     constructDirichletEvaluators(meshSpecs[0]->nsNames);
00058 
00059   if(meshSpecs[0]->ssNames.size() > 0) // Build a sideset evaluator if sidesets are present
00060 
00061     constructNeumannEvaluators(meshSpecs[0]);
00062 
00063 
00064 }
00065 
00066 Teuchos::Array<Teuchos::RCP<const PHX::FieldTag> >
00067 Albany::HydrideProblem::
00068 buildEvaluators(
00069   PHX::FieldManager<PHAL::AlbanyTraits>& fm0,
00070   const Albany::MeshSpecsStruct& meshSpecs,
00071   Albany::StateManager& stateMgr,
00072   Albany::FieldManagerChoice fmchoice,
00073   const Teuchos::RCP<Teuchos::ParameterList>& responseList)
00074 {
00075   // Call constructEvaluators<EvalT>(*rfm[0], *meshSpecs[0], stateMgr);
00076   // for each EvalT in PHAL::AlbanyTraits::BEvalTypes
00077   ConstructEvaluatorsOp<HydrideProblem> op(
00078     *this, fm0, meshSpecs, stateMgr, fmchoice, responseList);
00079   boost::mpl::for_each<PHAL::AlbanyTraits::BEvalTypes>(op);
00080   return *op.tags;
00081 }
00082 
00083 // Dirichlet BCs
00084 void
00085 Albany::HydrideProblem::constructDirichletEvaluators(const std::vector<std::string>& nodeSetIDs)
00086 {
00087    // Construct BC evaluators for all node sets and names
00088    std::vector<std::string> bcNames(neq);
00089    bcNames[0] = "X";
00090    if (numDim>1) bcNames[1] = "Y";
00091    if (numDim>2) bcNames[2] = "Z";
00092    bcNames[numDim] = "c";
00093    bcNames[numDim+1] = "w";
00094 
00095    Albany::BCUtils<Albany::DirichletTraits> bcUtils;
00096    dfm = bcUtils.constructBCEvaluators(nodeSetIDs, bcNames,
00097                                           this->params, this->paramLib);
00098 }
00099 
00100 // Neumann BCs
00101 void
00102 Albany::HydrideProblem::constructNeumannEvaluators(
00103         const Teuchos::RCP<Albany::MeshSpecsStruct>& meshSpecs)
00104 {
00105    // Note: we only enter this function if sidesets are defined in the mesh file
00106    // i.e. meshSpecs.ssNames.size() > 0
00107 
00108    Albany::BCUtils<Albany::NeumannTraits> neuUtils;
00109 
00110    // Check to make sure that Neumann BCs are given in the input file
00111 
00112    if(!neuUtils.haveBCSpecified(this->params))
00113 
00114       return;
00115 
00116    // Construct BC evaluators for all side sets and names
00117    // Note that the string index sets up the equation offset, so ordering is important
00118    std::vector<std::string> neumannNames(neq + 1);
00119    Teuchos::Array<Teuchos::Array<int> > offsets;
00120    offsets.resize(neq+1);
00121 
00122    neumannNames[0] = "Tx";
00123    offsets[0].resize(1);
00124    offsets[0][0] = 0;
00125    offsets[neq].resize(neq);
00126    offsets[neq][0] = 0;
00127 
00128    if (numDim>1){ 
00129       neumannNames[1] = "Ty";
00130       offsets[1].resize(1);
00131       offsets[1][0] = 1;
00132       offsets[neq][1] = 1;
00133    }
00134 
00135    if (numDim>2){
00136      neumannNames[2] = "Tz";
00137       offsets[2].resize(1);
00138       offsets[2][0] = 2;
00139       offsets[neq][2] = 2;
00140    }
00141 
00142    neumannNames[numDim] = "cFlux";
00143    offsets[numDim].resize(1);
00144    offsets[numDim][0] = numDim;
00145    offsets[neq][numDim] = numDim;
00146 
00147    neumannNames[numDim + 1] = "wFlux";
00148    offsets[numDim+1].resize(1);
00149    offsets[numDim+1][0] = numDim+1;
00150    offsets[neq][numDim+1] = numDim+1;
00151 
00152    neumannNames[neq] = "all";
00153 
00154    // Construct BC evaluators for all possible names of conditions
00155    // Should only specify flux vector components (dudx, dudy, dudz), or dudn, not both
00156    std::vector<std::string> condNames(3); //dudx, dudy, dudz, dudn, P
00157    Teuchos::ArrayRCP<std::string> dof_names(1);
00158      dof_names[0] = "Displacement";
00159 
00160    // Note that sidesets are only supported for two and 3D currently
00161    if(numDim == 2)
00162     condNames[0] = "(dudx, dudy)";
00163    else if(numDim == 3)
00164     condNames[0] = "(dudx, dudy, dudz)";
00165    else
00166     TEUCHOS_TEST_FOR_EXCEPTION(true, Teuchos::Exceptions::InvalidParameter,
00167        std::endl << "Error: Sidesets only supported in 2 and 3D." << std::endl);
00168 
00169    condNames[1] = "dudn";
00170    condNames[2] = "P";
00171 
00172    nfm.resize(1); // Elasticity problem only has one element block
00173 
00174    nfm[0] = neuUtils.constructBCEvaluators(meshSpecs, neumannNames, dof_names, true, 0,
00175                                           condNames, offsets, dl,
00176                                           this->params, this->paramLib);
00177 
00178 }
00179 
00180 Teuchos::RCP<const Teuchos::ParameterList>
00181 Albany::HydrideProblem::getValidProblemParameters() const
00182 {
00183   Teuchos::RCP<Teuchos::ParameterList> validPL =
00184     this->getGenericProblemParams("ValidHydrideProblemParams");
00185 
00186   Teuchos::Array<int> defaultPeriod;
00187 
00188   validPL->set<double>("b", 0.0, "b value in equation 1.1");
00189   validPL->set<double>("gamma", 0.0, "gamma value in equation 2.2");
00190   validPL->set<double>("e", 0.0, "e value in equation between 1.2 and 1.3");
00191   validPL->set<double>("Langevin Noise SD", 0.0, "Standard deviation of the Langevin noise to apply");
00192   validPL->set<Teuchos::Array<int> >("Langevin Noise Time Period", defaultPeriod, 
00193     "Time period to apply Langevin noise");
00194   validPL->set<bool>("Lump Mass", true, "Lump mass matrix in time derivative term");
00195 
00196  validPL->sublist("Elastic Modulus", false, "");
00197   validPL->sublist("Poissons Ratio", false, "");
00198 
00199 
00200   return validPL;
00201 }
00202 

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