LCOV - code coverage report
Current view: top level - src/userobjects - ParticleStepperBase.C (source / functions) Hit Total Coverage
Test: idaholab/salamander: 762d38 Lines: 25 26 96.2 %
Date: 2025-07-22 20:51:44 Functions: 5 5 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 "ParticleStepperBase.h"
      17             : 
      18             : InputParameters
      19        1311 : ParticleStepperBase::validParams()
      20             : {
      21        1311 :   auto params = GeneralUserObject::validParams();
      22        1311 :   params.addClassDescription("Base class for ParticleStepper. Provides the basic implementation"
      23             :                              "for dimensional dependent velocity updating."
      24             :                              "And the ability to sample vector fields for use in a particle step");
      25        1311 :   return params;
      26           0 : }
      27             : 
      28         655 : ParticleStepperBase::ParticleStepperBase(const InputParameters & parameters)
      29         655 :   : GeneralUserObject(parameters), _mesh_dimension(_fe_problem.mesh().dimension())
      30             : {
      31         655 : }
      32             : 
      33             : void
      34       71254 : ParticleStepperBase::setMaxDistanceAndDirection(Ray & ray, const Point & v, const Real dt) const
      35             : {
      36             : 
      37             :   // if the particle velocity is the zero vector the ray needs to be explicitly
      38             :   // made stationary otherwise a zero velocity will create a divide by zero
      39             :   // when trying to compute the unit direction vector
      40       71254 :   if (v.absolute_fuzzy_equals(Point(0, 0, 0)))
      41             :   {
      42       63942 :     ray.setStationary();
      43       63942 :     return;
      44             :   }
      45             :   // temporary point to store the new velocity as we work on it
      46             :   Point velocity = Point(0, 0, 0);
      47             : 
      48        7312 :   if (_mesh_dimension >= 1)
      49        7312 :     velocity(0) = v(0);
      50             : 
      51        7312 :   if (_mesh_dimension >= 2)
      52         912 :     velocity(1) = v(1);
      53             : 
      54        7312 :   if (_mesh_dimension == 3)
      55         384 :     velocity(2) = v(2);
      56             : 
      57             :   // max distance is v^2 dt
      58        7312 :   const auto max_distance = std::sqrt(velocity * velocity) * dt;
      59             : 
      60        7312 :   ray.setStartingMaxDistance(max_distance);
      61        7312 :   ray.setStartingDirection(velocity);
      62             : }
      63             : 
      64             : Point
      65        7184 : ParticleStepperBase::sampleField(const std::vector<SALAMANDER::VariableSampler> & field_samplers,
      66             :                                  const Ray & ray) const
      67             : {
      68        7184 :   const auto p = ray.currentPoint();
      69             :   const auto e = ray.currentElem();
      70             :   return Point(field_samplers[0].sampleVariable(p, e),
      71             :                field_samplers[1].sampleVariable(p, e),
      72        7184 :                field_samplers[2].sampleVariable(p, e));
      73             : }
      74             : 
      75             : Point
      76        7184 : ParticleStepperBase::linearImpulse(const Point & v,
      77             :                                    const Point & F,
      78             :                                    const Real q_m_ratio,
      79             :                                    const Real dt) const
      80             : {
      81        7184 :   return v + q_m_ratio * F * dt;
      82             : }

Generated by: LCOV version 1.14