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

FaceFractureCriteria_Def.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 #include <Intrepid_MiniTensor.h>
00007 #include "Teuchos_TestForException.hpp"
00008 #include "Phalanx_DataLayout.hpp"
00009 
00010 #include "Intrepid_FunctionSpaceTools.hpp"
00011 #include "Intrepid_RealSpaceTools.hpp"
00012 
00013 #include <typeinfo>
00014 
00015 namespace LCM {
00016 
00017   template<typename EvalT, typename Traits>
00018   FaceFractureCriteria<EvalT, Traits>::FaceFractureCriteria(
00019       const Teuchos::ParameterList& p) :
00020       coord(p.get<std::string>("Coordinate Vector Name"),
00021           p.get<Teuchos::RCP<PHX::DataLayout> >("Vertex Vector Data Layout")), faceAve(
00022           p.get<std::string>("Face Average Name"),
00023           p.get<Teuchos::RCP<PHX::DataLayout> >("Face Vector Data Layout")), yieldStrength(
00024           p.get<RealType>("Yield Name")), fractureLimit(
00025           p.get<RealType>("Fracture Limit Name")), criterion(
00026           p.get<std::string>("Insertion Criteria Name")), cellType(
00027           p.get<Teuchos::RCP<shards::CellTopology> >("Cell Type")), criteriaMet(
00028           p.get<std::string>("Criteria Met Name"),
00029           p.get<Teuchos::RCP<PHX::DataLayout> >("Face Scalar Data Layout")), temp(
00030           p.get<std::string>("Temp2 Name"),
00031           p.get<Teuchos::RCP<PHX::DataLayout> >("Cell Scalar Data Layout"))
00032   {
00033     this->addDependentField(coord);
00034     this->addDependentField(faceAve);
00035 
00036     this->addEvaluatedField(criteriaMet);
00037     this->addEvaluatedField(temp); // temp for testing
00038 
00039     // Get Dimensions
00040     Teuchos::RCP<PHX::DataLayout> vec_dl =
00041         p.get<Teuchos::RCP<PHX::DataLayout> >("Face Vector Data Layout");
00042     std::vector<PHX::DataLayout::size_type> dims;
00043     vec_dl->dimensions(dims);
00044 
00045     worksetSize = dims[0];
00046     numFaces = dims[1];
00047     numComp = dims[2];
00048 
00049     /* As the vector length for this problem is not equal to the number
00050      * of spatial dimensions (as in the normal mechanics problems), we
00051      * get the spatial dimension from the coordinate vector.
00052      */
00053     Teuchos::RCP<PHX::DataLayout> vertex_dl = p.get<
00054         Teuchos::RCP<PHX::DataLayout> >("Vertex Vector Data Layout");
00055     vertex_dl->dimensions(dims);
00056     numDims = dims[2];
00057 
00058     sides = cellType->getCellTopologyData()->side;
00059 
00060     this->setName("FaceFractureCriteria" + PHX::TypeString<EvalT>::value);
00061   }
00062 
00063   template<typename EvalT, typename Traits>
00064   void FaceFractureCriteria<EvalT, Traits>::postRegistrationSetup(
00065       typename Traits::SetupData d, PHX::FieldManager<Traits>& fm)
00066   {
00067     this->utils.setFieldData(coord, fm);
00068     this->utils.setFieldData(faceAve, fm);
00069     this->utils.setFieldData(criteriaMet, fm);
00070 
00071     this->utils.setFieldData(temp, fm); // temp for testing
00072 
00073   }
00074 
00075   template<typename EvalT, typename Traits>
00076   void FaceFractureCriteria<EvalT, Traits>::evaluateFields(
00077       typename Traits::EvalData workset)
00078   {
00079     std::cout << "Insertion Criterion: " << criterion << std::endl;
00080     if (criterion == "Test Fracture")
00081       testFracture();
00082     else if (criterion == "Traction")
00083       tractionCriterion();
00084     else
00085       TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
00086           "Fracture Criterion Not Recognized");
00087 
00088   }
00089 
00090   // Test fracture criterion
00091   template<typename EvalT, typename Traits>
00092   void FaceFractureCriteria<EvalT, Traits>::testFracture()
00093   {
00094     TEUCHOS_TEST_FOR_EXCEPTION(fractureLimit<=0.0, std::logic_error,
00095         "Fracture Limit Must Be > 0");
00096 
00097     for (std::size_t cell = 0; cell < worksetSize; ++cell) {
00098       for (std::size_t face = 0; face < numFaces; ++face) {
00099         ScalarT max_comp = 0.0;
00100         criteriaMet(cell, face) = 0;
00101         for (std::size_t comp = 0; comp < numComp; ++comp) {
00102           max_comp = std::max(faceAve(cell, face, comp), max_comp);
00103         }
00104         if (max_comp > fractureLimit) {
00105           criteriaMet(cell, face) = 1;
00106           // for debug
00107           std::cout << "Fracture Criteria met for (cell, face): " << cell << ","
00108                     << face << " Max Stress: " << max_comp << std::endl;
00109         }
00110       }
00111 
00112       // hack to force evaluation
00113       temp(cell) = 0.0;
00114     }
00115 
00116   }
00117 
00118   // Traction based criterion
00119   template<typename EvalT, typename Traits>
00120   void FaceFractureCriteria<EvalT, Traits>::tractionCriterion()
00121   {
00122     TEUCHOS_TEST_FOR_EXCEPTION(fractureLimit<=0.0, std::logic_error,
00123         "Fracture Limit Must Be > 0");
00124 
00125     // local variables to create the traction vector
00126     Intrepid::Vector<ScalarT> p0(3);
00127     Intrepid::Vector<ScalarT> p1(3);
00128     Intrepid::Vector<ScalarT> p2(3);
00129     Intrepid::Vector<ScalarT> normal(3); // face normal
00130     Intrepid::Vector<ScalarT> traction(3);
00131     Intrepid::Tensor<ScalarT> stress(3);
00132 
00133     for (std::size_t cell = 0; cell < worksetSize; ++cell) {
00134       //hack to force evaluation
00135       temp(cell) = 0.0;
00136 
00137       for (std::size_t face = 0; face < numFaces; ++face) {
00138         criteriaMet(cell, face) = 0;
00139 
00140         // Get the face normal
00141         // First get the (local) IDs of three independent nodes on the face
00142         int n0 = sides[face].node[0];
00143         int n1 = sides[face].node[1];
00144         int n2 = sides[face].node[2];
00145 
00146         // Then create a vector of the nodal points of each
00147         for (std::size_t i = 0; i < numDims; ++i) {
00148           p0(i) = coord(cell, n0, i);
00149           p1(i) = coord(cell, n1, i);
00150           p2(i) = coord(cell, n2, i);
00151         }
00152 
00153         normal = Intrepid::normal(p0, p1, p2);
00154 
00155         // fill the stress tensor
00156         for (std::size_t i = 0; i < numComp; ++i) {
00157           stress(i / numDims, i % numDims) = faceAve(cell, face, i);
00158         }
00159 
00160         // Get the traction
00161         traction = Intrepid::dot(stress, normal);
00162         ScalarT traction_norm = Intrepid::norm(traction);
00163 
00164         if (traction_norm > fractureLimit) {
00165           criteriaMet(cell, face) = 1;
00166           // for debug
00167           std::cout << "Fracture Criteria met for (cell, face): " << cell << ","
00168                     << face << " Max Stress: " << traction_norm << std::endl;
00169         }
00170         //else
00171         //    cout << "Fracture Criteria NOT met for (cell, face): " << cell << ","
00172         //         << face << " Max Stress: " << traction_norm << std::endl;
00173       }
00174     }
00175   }
00176 
00177 } // namespace LCM
00178 

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