LCOV - code coverage report
Current view: top level - src/dirackernels - ReporterTimePointSource.C (source / functions) Hit Total Coverage
Test: idaholab/moose optimization: #31405 (292dce) with base fef103 Lines: 29 32 90.6 %
Date: 2025-09-04 07:54:57 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://mooseframework.inl.gov
       3             : //*
       4             : //* All rights reserved, see COPYRIGHT for full restrictions
       5             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       6             : //*
       7             : //* Licensed under LGPL 2.1, please see LICENSE for details
       8             : //* https://www.gnu.org/licenses/lgpl-2.1.html
       9             : 
      10             : #include "ReporterTimePointSource.h"
      11             : #include "MooseUtils.h"
      12             : 
      13             : registerMooseObject("OptimizationApp", ReporterTimePointSource);
      14             : 
      15             : InputParameters
      16         195 : ReporterTimePointSource::validParams()
      17             : {
      18         195 :   InputParameters params = ReporterPointSource::validParams();
      19         195 :   params.addClassDescription("Apply a time dependent point load defined by Reporters.");
      20         390 :   params.addParam<ReporterName>("time_name",
      21             :                                 "Name of vector-postprocessor or reporter vector containing time, "
      22             :                                 "default is assumed to be all 0s.");
      23         390 :   params.addParam<Real>("reverse_time_end", 0.0, "End time used for reversing the time values.");
      24         195 :   return params;
      25           0 : }
      26             : 
      27         102 : ReporterTimePointSource::ReporterTimePointSource(const InputParameters & parameters)
      28             :   : ReporterPointSource(parameters),
      29         204 :     _coordt(isParamValid("time_name") ? getReporterValue<std::vector<Real>>("time_name")
      30             :                                       : _zeros_vec),
      31         306 :     _reverse_time_end(getParam<Real>("reverse_time_end"))
      32             : {
      33         102 : }
      34             : 
      35             : void
      36       16932 : ReporterTimePointSource::addPoints()
      37             : {
      38             :   // Do some size checks
      39       16932 :   const auto nval = _values.size();
      40       16932 :   if (nval == 0)
      41           0 :     paramError("value_name", "Value vector must not be empty.");
      42             : 
      43             :   // resize these incase the values reporters changed size
      44             :   // this will only change data constructed to reference these
      45       16932 :   _ones_vec.resize(nval, 1.0);
      46       16932 :   _zeros_vec.resize(nval, 0.0);
      47       16932 :   _zeros_pts.resize(nval, Point());
      48             : 
      49       16932 :   errorCheck("x_coord_name", _coordx.size());
      50       16932 :   errorCheck("y_coord_name", _coordy.size());
      51       16932 :   errorCheck("z_coord_name", _coordz.size());
      52       16932 :   errorCheck("weight_name", _weight.size());
      53       16932 :   errorCheck("point_name", _point.size());
      54       33864 :   errorCheck("time_name", _coordt.size());
      55             : 
      56             :   _point_to_weightedValue.clear();
      57             :   const Real at =
      58       16932 :       MooseUtils::absoluteFuzzyEqual(_reverse_time_end, 0.0) ? _t : _reverse_time_end - _t + _dt;
      59      806596 :   for (const auto & i : make_range(nval))
      60             :   {
      61      789664 :     if (_coordt.empty() || MooseUtils::absoluteFuzzyEqual(at, _coordt[i]))
      62             :     {
      63       89878 :       if (_read_in_points)
      64             :       {
      65           0 :         fillPoint(_point[i], i);
      66             :       }
      67             :       else
      68             :       {
      69       89878 :         const Point point = Point(_coordx[i], _coordy[i], _coordz[i]);
      70       89878 :         fillPoint(point, i);
      71             :       }
      72             :     }
      73             :   }
      74       16932 : }

Generated by: LCOV version 1.14