LCOV - code coverage report
Current view: top level - src/userobjects - ConstantVelocityInitializer.C (source / functions) Hit Total Coverage
Test: idaholab/salamander: d3fcc7 Lines: 13 14 92.9 %
Date: 2025-08-11 14:54:34 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of SALAMANDER: Software for Advanced Large-scale Analysis of MAgnetic
       2             : //* confinement for Numerical Design, Engineering & Research,
       3             : //* A multiphysics application for modeling plasma facing components
       4             : //* https://github.com/idaholab/salamander
       5             : //* https://mooseframework.inl.gov/salamander
       6             : //*
       7             : //* SALAMANDER is powered by the MOOSE Framework
       8             : //* https://www.mooseframework.inl.gov
       9             : //*
      10             : //* Licensed under LGPL 2.1, please see LICENSE for details
      11             : //* https://www.gnu.org/licenses/lgpl-2.1.html
      12             : //*
      13             : //* Copyright 2025, Battelle Energy Alliance, LLC
      14             : //* ALL RIGHTS RESERVED
      15             : //*
      16             : #include "ConstantVelocityInitializer.h"
      17             : #include <algorithm>
      18             : 
      19             : registerMooseObject("SalamanderApp", ConstantVelocityInitializer);
      20             : 
      21             : InputParameters
      22        1318 : ConstantVelocityInitializer::validParams()
      23             : {
      24        1318 :   auto params = VelocityInitializerBase::validParams();
      25        1318 :   params.addClassDescription(
      26             :       "Provides particles with velocities sampled from a user provided list of velocities.");
      27        2636 :   params.addRequiredParam<std::vector<Point>>(
      28             :       "velocities", "The velocites which will be cycled through when initializing particles.");
      29        1318 :   return params;
      30           0 : }
      31             : 
      32         655 : ConstantVelocityInitializer::ConstantVelocityInitializer(const InputParameters & parameters)
      33        1310 :   : VelocityInitializerBase(parameters), _velocities(getParam<std::vector<Point>>("velocities"))
      34             : {
      35         655 : }
      36             : 
      37             : const std::vector<Point>
      38       33100 : ConstantVelocityInitializer::getParticleVelocities(const size_t num_samples) const
      39             : {
      40       33100 :   auto velocities = std::vector<Point>(num_samples);
      41             : 
      42       33100 :   std::generate(velocities.begin(),
      43             :                 velocities.end(),
      44      650400 :                 [this, i = size_t(0)]() mutable { return _velocities[i++ % _velocities.size()]; });
      45       33100 :   return velocities;
      46             : }

Generated by: LCOV version 1.14