LCOV - code coverage report
Current view: top level - src/ics - DamageICBase.C (source / functions) Hit Total Coverage
Test: coverage.info Lines: 11 38 28.9 %
Date: 2025-02-21 01:06:12 Functions: 1 3 33.3 %

          Line data    Source code
       1             : //* This file is part of the RACCOON application
       2             : //* being developed at Dolbow lab at Duke University
       3             : //* http://dolbow.pratt.duke.edu
       4             : 
       5             : #include "DamageICBase.h"
       6             : 
       7             : InputParameters
       8         276 : DamageICBase::validParams()
       9             : {
      10         276 :   InputParameters params = InitialCondition::validParams();
      11         552 :   params.addRequiredParam<Real>("l", "The phase-field regularization length");
      12         552 :   params.addRequiredParam<std::vector<Real>>("x1", "The abscissa values of crack starting points");
      13         552 :   params.addRequiredParam<std::vector<Real>>("y1", "The ordinate values of crack starting points");
      14         552 :   params.addRequiredParam<std::vector<Real>>("z1", "The applicate values of crack starting points");
      15         552 :   params.addRequiredParam<std::vector<Real>>("x2", "The abscissa values of crack ending points");
      16         552 :   params.addRequiredParam<std::vector<Real>>("y2", "The ordinate values of crack ending points");
      17         552 :   params.addRequiredParam<std::vector<Real>>("z2", "The applicate values of crack ending points");
      18         552 :   params.addRequiredParam<Real>("d0", "Initial damage");
      19         276 :   return params;
      20           0 : }
      21             : 
      22           0 : DamageICBase::DamageICBase(const InputParameters & parameters)
      23             :   : InitialCondition(parameters),
      24           0 :     _x1(getParam<std::vector<Real>>("x1")),
      25           0 :     _y1(getParam<std::vector<Real>>("y1")),
      26           0 :     _z1(getParam<std::vector<Real>>("z1")),
      27           0 :     _x2(getParam<std::vector<Real>>("x2")),
      28           0 :     _y2(getParam<std::vector<Real>>("y2")),
      29           0 :     _z2(getParam<std::vector<Real>>("z2")),
      30           0 :     _d0(getParam<Real>("d0")),
      31           0 :     _l(getParam<Real>("l"))
      32             : {
      33             :   mooseAssert(_x1.size() == _y1.size(), "number of cracks mismatch");
      34             :   mooseAssert(_x1.size() == _z1.size(), "number of cracks mismatch");
      35             :   mooseAssert(_x1.size() == _x2.size(), "number of cracks mismatch");
      36             :   mooseAssert(_x1.size() == _y2.size(), "number of cracks mismatch");
      37             :   mooseAssert(_x1.size() == _z2.size(), "number of cracks mismatch");
      38           0 : }
      39             : 
      40             : Real
      41           0 : DamageICBase::dist(const Point & p)
      42             : {
      43             :   // number of cracks
      44           0 :   unsigned int n = _x1.size();
      45             : 
      46             :   Real dist = -1.0;
      47             :   Real dist_new = 0.0;
      48             : 
      49           0 :   for (unsigned i = 0; i < n; ++i)
      50             :   {
      51             : 
      52             :     // point x1 and point x2 define a line segment
      53             :     // point x0 is the current point
      54           0 :     Point x1(_x1[i], _y1[i], _z1[i]);
      55           0 :     Point x2(_x2[i], _y2[i], _z2[i]);
      56           0 :     Point x0 = p;
      57             : 
      58             :     Point dx0x1 = x1 - x0;
      59             :     Point dx0x2 = x2 - x0;
      60             :     Point dx1x2 = x2 - x1;
      61             : 
      62             :     // in range indicator, if ind >= 0, in range
      63           0 :     Real ind1 = -dx0x1 * dx1x2 / dx0x1.norm() / dx1x2.norm();
      64           0 :     Real ind2 = dx0x2 * dx1x2 / dx0x2.norm() / dx1x2.norm();
      65           0 :     if (ind1 * ind2 >= 0)
      66             :     {
      67           0 :       Point num = dx0x1.cross(dx0x2);
      68           0 :       dist_new = num.norm() / dx1x2.norm();
      69             :     }
      70             :     else
      71             :     {
      72           0 :       Real dist1 = dx0x1.norm();
      73           0 :       Real dist2 = dx0x2.norm();
      74           0 :       if (dist1 < dist2)
      75             :         dist_new = dist1;
      76             :       else
      77             :         dist_new = dist2;
      78             :     }
      79           0 :     if (dist == -1.0 || dist_new < dist)
      80             :       dist = dist_new;
      81             :   }
      82             : 
      83           0 :   return dist;
      84             : }

Generated by: LCOV version 1.16