1#include "FractureModule.h"
 
    3#include "ParticleSystem/Module/SummationDensity.h"
 
    4#include "ParticleSystem/Module/Kernel.h"
 
    8    IMPLEMENT_TCLASS(FractureModule, TDataType)
 
   10    template<typename TDataType>
 
   11    FractureModule<TDataType>::FractureModule()
 
   12        : ElastoplasticityModule<TDataType>()
 
   16    template <typename Real, typename Coord, typename Bond>
 
   17    __global__ void PM_ComputeInvariants(
 
   18        DArray<Real> bulk_stiffiness,
 
   21        DArrayList<Bond> bonds,
 
   28        int i = threadIdx.x + (blockIdx.x * blockDim.x);
 
   29        if (i >= Y.size()) return;
 
   31        CorrectedKernel<Real> kernSmooth;
 
   35        List<Bond>& bonds_i = bonds[i];
 
   42        //compute the first and second invariants of the deformation state, i.e., I1 and J2
 
   43        int size_i = bonds_i.size();
 
   44        Real total_weight = Real(0);
 
   45        for (int ne = 1; ne < size_i; ne++)
 
   47            Bond bond_ij = bonds_i[ne];
 
   51            Real r = (x_i - x_j).norm();
 
   55                Real weight = kernSmooth.Weight(r, horizon);
 
   56                Coord p = (Y[j] - y_i);
 
   57                Real ratio_ij = p.norm() / r;
 
   59                I1_i += weight*ratio_ij;
 
   61                total_weight += weight;
 
   65        if (total_weight > EPSILON)
 
   74        for (int ne = 0; ne < size_i; ne++)
 
   76            Bond bond_ij = bonds_i[ne];
 
   79            Real r = (x_i - x_j).norm();
 
   83                Real weight = kernSmooth.Weight(r, horizon);
 
   84                Vec3f p = (Y[j] - y_i);
 
   85                Real ratio_ij = p.norm() / r;
 
   86                J2_i = (ratio_ij - I1_i)*(ratio_ij - I1_i)*weight;
 
   89        if (total_weight > EPSILON)
 
   99        Real D1 = 1 - I1_i;     //positive for compression and negative for stretching
 
  101        Real s_J2 = J2_i*mu*bulk_stiffiness[i];
 
  102        Real s_D1 = D1*lambda*bulk_stiffiness[i];
 
  104        //Drucker-Prager yield criterion
 
  105        if (s_J2 > s_A + B*s_D1)
 
  107            bulk_stiffiness[i] = 0.0f;
 
  111    template<typename TDataType>
 
  112    void FractureModule<TDataType>::applyPlasticity()
 
  114        int num = this->inY()->size();
 
  115        uint pDims = cudaGridSize(num, BLOCK_SIZE);
 
  117        Real A = this->computeA();
 
  118        Real B = this->computeB();
 
  120        PM_ComputeInvariants<< <pDims, BLOCK_SIZE >> > (
 
  121            this->mBulkStiffness,
 
  122            this->inX()->getData(),
 
  123            this->inY()->getData(),
 
  124            this->inBonds()->getData(),
 
  125            this->inHorizon()->getData(),
 
  128            this->varMu()->getData(),
 
  129            this->varLambda()->getData());
 
  133    DEFINE_CLASS(FractureModule);