LCOV - code coverage report
Current view: top level - src/userobjects - ParticleInitializerBase.C (source / functions) Hit Total Coverage
Test: idaholab/salamander: 762d38 Lines: 24 25 96.0 %
Date: 2025-07-22 20:51:44 Functions: 3 3 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 confinement for Numerical Design, Engineering & Research,
       2             : //* A multiphysics application for modeling plasma facing components
       3             : //* https://github.com/idaholab/salamander
       4             : //* https://mooseframework.inl.gov/salamander
       5             : //*
       6             : //* SALAMANDER is powered by the MOOSE Framework
       7             : //* https://www.mooseframework.inl.gov
       8             : //*
       9             : //* Licensed under LGPL 2.1, please see LICENSE for details
      10             : //* https://www.gnu.org/licenses/lgpl-2.1.html
      11             : //*
      12             : //* Copyright 2025, Battelle Energy Alliance, LLC
      13             : //* ALL RIGHTS RESERVED
      14             : //*
      15             : 
      16             : #include "ParticleInitializerBase.h"
      17             : #include "Distribution.h"
      18             : 
      19             : InputParameters
      20        1314 : ParticleInitializerBase::validParams()
      21             : {
      22        1314 :   auto params = GeneralUserObject::validParams();
      23        1314 :   params.addClassDescription("Base class for ParticleStepper. Provides the basic implementation"
      24             :                              "for dimensional dependent velocity updating."
      25             :                              "And the ability to sample vector fields for use in a particle step");
      26        2628 :   params.addParam<unsigned int>("seed", 0, "An additional seed for the random number generators");
      27        3942 :   params.addRangeCheckedParam<Real>(
      28        2628 :       "mass", 1.0, "mass > 0.0", "The mass of the particles being placed in the mesh");
      29        2628 :   params.addParam<Real>("charge", 1, "The charge of the particles being placed in the mesh");
      30        2628 :   params.addParam<std::string>("species", "", "The type of particle that is being initialized");
      31        2628 :   params.addRequiredParam<std::vector<DistributionName>>(
      32             :       "velocity_distributions",
      33             :       "The distribution names to be sampled when initializing the velocity of each particle");
      34        1314 :   return params;
      35           0 : }
      36             : 
      37         656 : ParticleInitializerBase::ParticleInitializerBase(const InputParameters & parameters)
      38             :   : GeneralUserObject(parameters),
      39         656 :     _mass(getParam<Real>("mass")),
      40        1312 :     _charge(getParam<Real>("charge")),
      41        1312 :     _species(getParam<std::string>("species")),
      42        1312 :     _seed(getParam<unsigned int>("seed")),
      43         656 :     _mesh_dimension(_fe_problem.mesh().dimension()),
      44        1968 :     _distribution_names(getParam<std::vector<DistributionName>>("velocity_distributions"))
      45             : {
      46         656 :   if (_distribution_names.size() != 3)
      47           1 :     paramError("velocity_distributions",
      48             :                "You must provide 3 distributions, one for each velocity component.");
      49         655 : }
      50             : 
      51             : void
      52         314 : ParticleInitializerBase::initialSetup()
      53             : {
      54             :   // Needed because distributions are constructed after UserObjects
      55        1256 :   for (const DistributionName & name : _distribution_names)
      56         942 :     _velocity_distributions.push_back(&getDistributionByName(name));
      57         314 : }

Generated by: LCOV version 1.14