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

AAdapt_RandomCriterion.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 <cassert>
00008 
00009 #include <Teuchos_ScalarTraits.hpp>
00010 
00011 #include "AAdapt_RandomCriterion.hpp"
00012 
00013 namespace AAdapt {
00014 
00015 //----------------------------------------------------------------------------
00016 //
00017 // Default constructor
00018 //
00019 RandomCriterion::RandomCriterion(int num_dim,
00020                                  stk::mesh::EntityRank& element_rank,
00021                                  Albany::STKDiscretization& stk) :
00022   AbstractFractureCriterion(num_dim, element_rank),
00023   stk_(stk) {
00024 }
00025 
00026 //----------------------------------------------------------------------------
00027 //
00028 // Random fracture criterion function.
00029 //
00030 bool
00031 RandomCriterion::computeFractureCriterion(stk::mesh::Entity& entity, double p) {
00032 
00033   // Fracture only defined on the boundary of the elements
00034   stk::mesh::EntityRank rank = entity.entity_rank();
00035   assert(rank == num_dim_ - 1);
00036 
00037   stk::mesh::PairIterRelation neighbor_elems =
00038     entity.relations(element_rank_);
00039 
00040   // Need an element on each side
00041   if(neighbor_elems.size() != 2)
00042     return false;
00043 
00044   bool is_open = false;
00045 
00046   // All we need to do is generate a number between 0 and 1
00047   double random = 0.5 + 0.5 * Teuchos::ScalarTraits<double>::random();
00048 
00049   if(random < p) {
00050     is_open = true;
00051   }
00052 
00053   return is_open;
00054 }
00055 //----------------------------------------------------------------------------
00056 } // namespace AAdapt
00057 

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