LCOV - code coverage report
Current view: top level - src/postprocessors - ExternalWork.C (source / functions) Hit Total Coverage
Test: coverage.info Lines: 31 37 83.8 %
Date: 2025-02-21 01:06:12 Functions: 7 8 87.5 %

          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 "ExternalWork.h"
       6             : 
       7             : registerMooseObject("raccoonApp", ExternalWork);
       8             : 
       9             : InputParameters
      10         140 : ExternalWork::validParams()
      11             : {
      12         140 :   InputParameters params = NodalPostprocessor::validParams();
      13         140 :   params.addClassDescription("This class computes the total external work. The power expenditure "
      14             :                              "(rate of external work) is defined as $\\mathcal{P}^\\text{ext} = "
      15             :                              "\\int_\\bodyboundary \\bft \\cdot \\dot{\\bs{\\phi}} \\diff{A}$. The "
      16             :                              "power expenditure is integrated in time to get the total work.");
      17         280 :   params.addRequiredCoupledVar("forces",
      18             :                                "The reaction forces associated with each of the displacement");
      19         280 :   params.addRequiredCoupledVar(
      20             :       "displacements",
      21             :       "The displacements appropriate for the simulation geometry and coordinate system");
      22         140 :   return params;
      23           0 : }
      24             : 
      25           1 : ExternalWork::ExternalWork(const InputParameters & parameters)
      26             :   : NodalPostprocessor(parameters),
      27           1 :     _sum(0),
      28           1 :     _ndisp(coupledComponents("displacements")),
      29           1 :     _u_dots(coupledDots("displacements")),
      30           1 :     _nforce(coupledComponents("forces")),
      31           1 :     _forces(coupledValues("forces")),
      32           2 :     _sum_old(getPostprocessorValueOldByName(name()))
      33             : {
      34           1 :   for (unsigned int i = _ndisp; i < 3; ++i)
      35           0 :     _u_dots.push_back(&_zero);
      36             : 
      37           1 :   for (unsigned int i = _nforce; i < 3; ++i)
      38           0 :     _forces.push_back(&_zero);
      39           1 : }
      40             : 
      41             : void
      42         200 : ExternalWork::initialize()
      43             : {
      44         200 :   _sum = 0;
      45         200 : }
      46             : 
      47             : void
      48         800 : ExternalWork::execute()
      49             : {
      50         800 :   _sum += computeQpValue();
      51         800 : }
      52             : 
      53             : Real
      54         800 : ExternalWork::computeQpValue()
      55             : {
      56         800 :   RealVectorValue u_dot((*_u_dots[0])[_qp], (*_u_dots[1])[_qp], (*_u_dots[2])[_qp]);
      57         800 :   RealVectorValue force((*_forces[0])[_qp], (*_forces[1])[_qp], (*_forces[2])[_qp]);
      58             : 
      59         800 :   return force * u_dot;
      60             : }
      61             : 
      62             : Real
      63         200 : ExternalWork::getValue() const
      64             : {
      65         200 :   return _sum * _dt + _sum_old;
      66             : }
      67             : 
      68             : void
      69         200 : ExternalWork::finalize()
      70             : {
      71         200 :   gatherSum(_sum);
      72         200 : }
      73             : 
      74             : void
      75           0 : ExternalWork::threadJoin(const UserObject & y)
      76             : {
      77             :   const ExternalWork & pps = static_cast<const ExternalWork &>(y);
      78           0 :   _sum += pps._sum;
      79           0 : }

Generated by: LCOV version 1.16