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

LameUtils.hpp

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 #ifndef LAME_UTILS_HPP
00007 #define LAME_UTILS_HPP
00008 
00009 #include "Teuchos_RCP.hpp"
00010 #include "Teuchos_ParameterList.hpp"
00011 
00012 // LAME material model base class
00013 #ifdef ALBANY_LAME
00014 #include <models/Material.h>
00015 typedef lame::MatProps LameMatProps;
00016 typedef lame::Material LameMaterial;
00017 typedef lame::matParams LameMatParams;
00018 #endif
00019 #ifdef ALBANY_LAMENT
00020 #include <models/Lament_Material.h>
00021 #include "models/Lament_ElasticNew.h"
00022 #include "models/Lament_Neohookean.h"
00023 typedef lament::MatProps LameMatProps;
00024 typedef lament::Material<double> LameMaterial;
00025 //typedef lament::Material<ADType> LameMaterial_AD;
00026 typedef lament::matParams<double> LameMatParams;
00027 #endif
00028 
00030 namespace LameUtils {
00031 
00033   inline
00034   void parameterListToMatProps(const Teuchos::ParameterList& lameMaterialParameters, LameMatProps& matProps){
00035 
00036     // load the material properties into the lame(nt)::MatProps container.
00037     // LAME material properties must be of type int, double, or string.
00038 
00039     for(Teuchos::ParameterList::ConstIterator it = lameMaterialParameters.begin() ; it != lameMaterialParameters.end() ; ++it){
00040 
00041       std::string name = lameMaterialParameters.name(it);
00042       std::transform(name.begin(), name.end(), name.begin(), (int (*)(int))std::toupper);
00043       std::replace(name.begin(), name.end(), ' ', '_');
00044 
00045       const Teuchos::ParameterEntry entry = lameMaterialParameters.entry(it);
00046       if(entry.isType<int>()){
00047   std::vector<int> propertyVector;
00048   propertyVector.push_back(Teuchos::getValue<int>(entry));
00049   matProps.insert(name, propertyVector);
00050       }
00051       else if(entry.isType<double>()){
00052   std::vector<double> propertyVector;
00053   propertyVector.push_back(Teuchos::getValue<double>(entry));
00054   matProps.insert(name, propertyVector);
00055       }
00056       else if(entry.isType<std::string>()){
00057   std::vector<std::string> propertyVector;
00058   propertyVector.push_back(Teuchos::getValue<std::string>(entry));
00059   matProps.insert(name, propertyVector);
00060       }
00061       else if(entry.isType<bool>()){
00062   // Flag for reading from xml materials database is a bool -- not sent to Lame
00063       }
00064       else{
00065   TEUCHOS_TEST_FOR_EXCEPTION(true, Teuchos::Exceptions::InvalidParameter, " parameters for LAME material models must be of type double, int, or string.\n");
00066       }
00067     }
00068   }
00069 
00071 //  Teuchos::RCP<LameMaterial> constructLameMaterialModel(const std::string& lameMaterialModelName,
00072   Teuchos::RCP<LameMaterial> constructLameMaterialModel(const std::string lameMaterialModelName,
00073               const Teuchos::ParameterList& lameMaterialParameters);
00074 
00075 #ifdef ALBANY_LAMENT
00076 
00077   template <typename ScalarT>
00078   inline
00079   Teuchos::RCP<lament::Material<ScalarT> > constructLamentMaterialModel(const std::string& lameMaterialModelName,
00080                   const Teuchos::ParameterList& lameMaterialParameters){
00081     
00082     // Strings should be all upper case with spaces replaced with underscores
00083     std::string materialModelName = lameMaterialModelName;
00084     std::transform(materialModelName.begin(), materialModelName.end(), materialModelName.begin(), 
00085       (int (*)(int))std::toupper);
00086     std::replace(materialModelName.begin(), materialModelName.end(), ' ', '_');
00087   
00088     LameMatProps props;
00089     parameterListToMatProps(lameMaterialParameters, props);
00090 
00091     Teuchos::RCP<lament::Material<ScalarT> > materialModel;
00092 
00093     if(materialModelName == "ELASTIC_NEW")
00094       materialModel = Teuchos::rcp(new lament::ElasticNew<ScalarT>(props));
00095     else if(materialModelName == "NEOHOOKEAN")
00096       materialModel = Teuchos::rcp(new lament::Neohookean<ScalarT>(props));
00097     else{
00098       if(materialModel.is_null())
00099   TEUCHOS_TEST_FOR_EXCEPTION(true, Teuchos::Exceptions::InvalidParameter, " unsupported LAMENT material model: " + lameMaterialModelName + " (" + materialModelName + ")\n");
00100     }
00101 
00102     return materialModel;
00103   }
00104 #endif // ALBANY_LAMENT
00105 
00107   std::vector<std::string> getStateVariableNames(const std::string& lameMaterialModelName,
00108                                                  const Teuchos::ParameterList& lameMaterialParameters);
00109 
00111   std::vector<double> getStateVariableInitialValues(const std::string& lameMaterialModelName,
00112                                                     const Teuchos::ParameterList& lameMaterialParameters);
00113 
00114 }
00115 
00116 #endif // LAME_UTILS_HPP

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