LCOV - code coverage report
Current view: top level - src/dirackernels - ReporterTimePointSource.C (source / functions) Hit Total Coverage
Test: idaholab/moose optimization: #32971 (54bef8) with base c6cf66 Lines: 29 32 90.6 %
Date: 2026-05-29 20:38:04 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         105 : ReporterTimePointSource::validParams()
      17             : {
      18         105 :   InputParameters params = ReporterPointSource::validParams();
      19         105 :   params.addClassDescription("Apply a time dependent point load defined by Reporters.");
      20         210 :   params.addParam<ReporterName>("time_name",
      21             :                                 "Name of vector-postprocessor or reporter vector containing time, "
      22             :                                 "default is assumed to be all 0s.");
      23         210 :   params.addParam<Real>("reverse_time_end", 0.0, "End time used for reversing the time values.");
      24         105 :   return params;
      25           0 : }
      26             : 
      27          54 : ReporterTimePointSource::ReporterTimePointSource(const InputParameters & parameters)
      28             :   : ReporterPointSource(parameters),
      29         108 :     _coordt(isParamValid("time_name") ? getReporterValue<std::vector<Real>>("time_name")
      30             :                                       : _zeros_vec),
      31         162 :     _reverse_time_end(getParam<Real>("reverse_time_end"))
      32             : {
      33          54 : }
      34             : 
      35             : void
      36       10964 : ReporterTimePointSource::addPoints()
      37             : {
      38       10964 :   const auto nval = _values.size();
      39       10964 :   if (nval == 0)
      40           0 :     paramError("value_name", "Value vector must not be empty.");
      41             : 
      42             :   // resize these incase the values reporters changed size
      43             :   // this will only change data constructed to reference these
      44       10964 :   _ones_vec.resize(nval, 1.0);
      45       10964 :   _zeros_vec.resize(nval, 0.0);
      46       10964 :   _zeros_pts.resize(nval, Point());
      47             : 
      48       10964 :   errorCheck("x_coord_name", _coordx.size());
      49       10964 :   errorCheck("y_coord_name", _coordy.size());
      50       10964 :   errorCheck("z_coord_name", _coordz.size());
      51       10964 :   errorCheck("weight_name", _weight.size());
      52       10964 :   errorCheck("point_name", _point.size());
      53       10964 :   errorCheck("time_name", _coordt.size());
      54             : 
      55             :   const Real at =
      56       10964 :       MooseUtils::absoluteFuzzyEqual(_reverse_time_end, 0.0) ? _t : _reverse_time_end - _t + _dt;
      57      523922 :   for (const auto & i : make_range(nval))
      58             :   {
      59      512958 :     if (_coordt.empty() || MooseUtils::absoluteFuzzyEqual(at, _coordt[i]))
      60             :     {
      61       56676 :       if (_read_in_points)
      62           0 :         addPoint(_point[i], i, _values[i] * _weight[i]);
      63             :       else
      64             :       {
      65       56676 :         const Point point = Point(_coordx[i], _coordy[i], _coordz[i]);
      66       56676 :         addPoint(point, i, _values[i] * _weight[i]);
      67             :       }
      68             :     }
      69             :   }
      70       10964 : }

Generated by: LCOV version 1.14