DamagedDeviatorBehaviour.h 7.73 KB
Newer Older
1 2 3 4 5
/* 
    This file is a part of eXlibris C++ Library
    under the GNU General Public License:
    See the LICENSE.md files for terms and 
    conditions.
6
*/
7 8


9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
#ifndef _DamagedDeviatorBehaviour_h
#define _DamagedDeviatorBehaviour_h
// DamageBandDyn
#include "Eval.h"
#include "Export.h"

namespace xfem
{
class xIntegrationRule;
}

namespace damaged_deviator_behaviour
{
template <typename TENSOR2>
class EvalStress : public xfem::xEval<TENSOR2>
{
public:
  typedef TENSOR2 result_type;
  typedef boost::function<double (double)> DamageFct;
  EvalStress(const xfem::xEval<result_type>& eval_strain_,
             const xfem::xEval<double>& eval_damage_,
             const xfem::xEval<double>& eval_G_,
             const xfem::xEval<double>& eval_K_,
             DamageFct deviator_fct_,
             DamageFct positive_trace_fct_,
             DamageFct negative_trace_fct_);
  void operator()(const xfem::xGeomElem* geo_appro, const xfem::xGeomElem* geo_integ, result_type& res) const;
private:
  const xfem::xEval<result_type>& eval_strain;
  const xfem::xEval<double>& eval_damage;
  const xfem::xEval<double>& eval_G;
  const xfem::xEval<double>& eval_K;
  xfem::xDeviatoric deviatoric;
  DamageFct deviator_fct;
  DamageFct positive_trace_fct;
  DamageFct negative_trace_fct;
  mutable double tr, buf;
};

template <typename TENSOR2>
class EvalEnergyReleaseRate : public xfem::xEval<double>
{
public:
  typedef double result_type;
  typedef boost::function<double (double)> DamageFctDerivative;
  EvalEnergyReleaseRate(const xfem::xEval<TENSOR2>& eval_strain_,
                        const xfem::xEval<double>& eval_damage_,
                        const xfem::xEval<double>& eval_G_,
                        const xfem::xEval<double>& eval_K_,
                        DamageFctDerivative deviator_fct_,
                        DamageFctDerivative positive_trace_fct_,
                        DamageFctDerivative negative_trace_fct_);
  void operator()(const xfem::xGeomElem* geo_appro, const xfem::xGeomElem* geo_integ, result_type& res) const;
private:
  const xfem::xEval<TENSOR2>& eval_strain;
  const xfem::xEval<double>& eval_damage;
  const xfem::xEval<double>& eval_G;
  const xfem::xEval<double>& eval_K;
  xfem::xDeviatoric deviatoric;
  mutable xfem::xTensor2 dev;
  mutable double tr, buf;
  DamageFctDerivative deviator_fct;
  DamageFctDerivative positive_trace_fct;
  DamageFctDerivative negative_trace_fct;
};

#ifdef ESHELBY
template <typename TENSOR2>
class EvalEshelby : public xfem::xEval<TENSOR2>
{
public:
  typedef TENSOR2 result_type;
  EvalEshelby(const xfem::xEval<result_type>& eval_grad_disp_,
              const xfem::xEval<double>& eval_damage_,
              const xfem::xEval<double>& eval_G_,
              const xfem::xEval<double>& eval_K_);
private:
};
#endif
}

template <typename TLSSOLVER, typename STRESSTENSOR>
class DamagedDeviatorBehaviour
{
public:
  typedef STRESSTENSOR StressTensor;
  typedef typename TLSSOLVER::IterDomain IterDomain;
  typedef typename TLSSOLVER::IterOldDomain IterOldDomain;
  typedef boost::function<double (double)> DamageFct;
  typedef boost::function<double (double)> DamageFctDerivative;
  typedef boost::function<boost::shared_ptr<xfem::xEval<double> >
                          (const xfem::xEval<double>&)>           EvalWrapper;

  DamagedDeviatorBehaviour(TLSSOLVER& tls_solver_,
                           const xfem::xEval<StressTensor>& eval_strain_,
                           const xfem::xEval<double>& eval_G_,
                           const xfem::xEval<double>& eval_K_,
                           const xfem::xEval<double>& eval_critical_energy_release_rate_,
                           DamageFct deviator_fct_,
                           DamageFct positive_trace_fct_,
                           DamageFct negative_trace_fct_,
                           DamageFctDerivative deviator_fct_der_,
                           DamageFctDerivative positive_trace_fct_der_,
                           DamageFctDerivative negative_trace_fct_der_,
                           EvalWrapper eval_damage_rate_wrapper_,
                           PostProcessing& post_processing_) :
    tls_solver(tls_solver_),
    eval_energy_release_rate(eval_strain_, tls_solver.getEvalDamage(), eval_G_, eval_K_,
                             deviator_fct_der_, positive_trace_fct_der_, negative_trace_fct_der_),
    eval_critical_energy_release_rate(eval_critical_energy_release_rate_),
    eval_stress(eval_strain_, tls_solver.getEvalDamage(), eval_G_, eval_K_,
                deviator_fct_, positive_trace_fct_, negative_trace_fct_),
    eval_strain_energy_double(eval_strain_, eval_stress),
    half_scale(0.5),
    eval_strain_energy(half_scale, eval_strain_energy_double),
    eval_damage_rate_wrapper(eval_damage_rate_wrapper_),
    post_processing(post_processing_)
  {}
  void initialize(const IterDomain& begin_, const IterDomain& end_,
                  const xfem::xIntegrationRule& integration_rule_)
  {
    tls_solver.initialize(begin_, end_, integration_rule_);
  }
  void clear(const IterOldDomain& old_begin_, const IterOldDomain& old_end_)
  {
    tls_solver.clear(old_begin_, old_end_);
  }
  void restore(const IterDomain& begin_, const IterDomain& end_,
               const xfem::xIntegrationRule& integration_rule_)
  {
    tls_solver.restore();
  }
  void project(const IterDomain& begin_, const IterDomain& end_,
               const xfem::xIntegrationRule& integration_rule_)
  {}
  void update(double time_, int step_, double time_step_,
              const IterDomain& begin_, const IterDomain& end_,
              const xfem::xIntegrationRule& integration_rule_)
  {
    tls_solver.update(eval_energy_release_rate, eval_critical_energy_release_rate, eval_damage_rate_wrapper,
                      time_, step_, time_step_, begin_, end_, integration_rule_);
  }
  void compute(double time_, int step_, double time_step_,
               const IterDomain& begin_, const IterDomain& end_,
               const xfem::xIntegrationRule& integration_rule_)
  {
    tls_solver.compute(eval_energy_release_rate, eval_critical_energy_release_rate, eval_damage_rate_wrapper,
                       time_, step_, time_step_, begin_, end_, integration_rule_);
  }
  void move(double time_, int step_, double time_step_,
            const IterDomain& begin_, const IterDomain& end_,
            const xfem::xIntegrationRule& integration_rule_)
  {
    tls_solver.move(time_, step_, time_step_);
  }
  void compute_after(double time_, int step_, double time_step_,
                     const IterDomain& begin_, const IterDomain& end_,
                     const xfem::xIntegrationRule& integration_rule_)
  {}
  void exportGmsh(double time_, int step_, double time_step_,
                  const IterDomain& begin_, const IterDomain& end_,
                  const xfem::xIntegrationRule& integration_rule_)
  {
    post_processing.exportOnTime("stress", time_, eval_stress);
    post_processing.exportEnergyOnTime("strain_energy", step_, time_, eval_strain_energy, integration_rule_, begin_, end_);
    post_processing.exportOnSpace("stress", step_, eval_stress, integration_rule_, begin_, end_);
    tls_solver.exportGmsh(time_, step_, time_step_, begin_, end_, integration_rule_);
  }
  const xfem::xEval<StressTensor>& getStress() const { return eval_stress; }

private:
  TLSSOLVER& tls_solver;

  damaged_deviator_behaviour::EvalEnergyReleaseRate<StressTensor> eval_energy_release_rate;
  const xEval<double>& eval_critical_energy_release_rate;
  damaged_deviator_behaviour::EvalStress<StressTensor> eval_stress;	

  xfem::xEvalBinary<xfem::xContraction<StressTensor> > eval_strain_energy_double;
  xfem::xScale<double> half_scale;
  xfem::xEvalUnary<xfem::xScale<double> > eval_strain_energy;

  EvalWrapper eval_damage_rate_wrapper;

  PostProcessing& post_processing;
};

#include "DamagedDeviatorBehaviour_imp.h"
#endif