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 00011 00012 #if !defined(LCM_Topology_FractureCriterion_h) 00013 #define LCM_Topology_FractureCriterion_h 00014 00015 #include <cassert> 00016 00017 #include "Teuchos_ScalarTraits.hpp" 00018 #include "Topology_Types.h" 00019 00020 namespace LCM{ 00021 00025 class AbstractFractureCriterion { 00026 00027 public: 00028 00029 AbstractFractureCriterion() {} 00030 00031 virtual 00032 bool 00033 check(Entity const & entity) const = 0; 00034 00035 virtual 00036 ~AbstractFractureCriterion() {} 00037 00038 private: 00039 00040 AbstractFractureCriterion(const AbstractFractureCriterion &); 00041 AbstractFractureCriterion &operator=(const AbstractFractureCriterion &); 00042 00043 }; 00044 00048 class FractureCriterionRandom : public AbstractFractureCriterion { 00049 00050 public: 00051 00052 FractureCriterionRandom(size_t const element_rank, double const probability) : 00053 AbstractFractureCriterion(), 00054 element_rank_(element_rank), probability_(probability) {} 00055 00056 bool 00057 check(Entity const & entity) const 00058 { 00059 EntityRank const 00060 rank = entity.entity_rank(); 00061 00062 assert(static_cast<size_t>(rank) == element_rank_ - 1); 00063 00064 stk::mesh::PairIterRelation const 00065 relations = entity.relations(element_rank_); 00066 00067 assert(relations.size() == 2); 00068 00069 double const 00070 random = 0.5 * Teuchos::ScalarTraits<double>::random() + 0.5; 00071 00072 return random < probability_; 00073 } 00074 00075 private: 00076 00077 FractureCriterionRandom(); 00078 FractureCriterionRandom(FractureCriterionRandom const &); 00079 FractureCriterionRandom & operator=(FractureCriterionRandom const &); 00080 00081 private: 00082 00083 size_t 00084 element_rank_; 00085 00086 double 00087 probability_; 00088 }; 00089 00090 } // namespace LCM 00091 00092 #endif // LCM_Topology_FractureCriterion_h