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 "LeapFrogStepper.h" 17 : 18 : registerMooseObject("SalamanderApp", LeapFrogStepper); 19 : 20 : InputParameters 21 127 : LeapFrogStepper::validParams() 22 : { 23 127 : auto params = ParticleStepperBase::validParams(); 24 127 : params.addClassDescription("Particle Stepper which implements a simple leap frog update where " 25 : "the velocity and position are updated with a 1/2 dt offset."); 26 254 : params.addRequiredParam<std::vector<VariableName>>( 27 : "field_components", 28 : "A list of 3 variables which represent the 3 components of the force field acting on " 29 : "particles"); 30 127 : return params; 31 0 : } 32 : 33 64 : LeapFrogStepper::LeapFrogStepper(const InputParameters & parameters) 34 : : ParticleStepperBase(parameters), 35 192 : _field_vars(getParam<std::vector<VariableName>>("field_components")) 36 : { 37 64 : if (_field_vars.size() != 3) 38 1 : paramError("field_components", "You must provide 3 components representing the force field"); 39 : 40 252 : for (int i = 0; i < 3; ++i) 41 : { 42 378 : _field_samplers.push_back(SALAMANDER::VariableSampler(_fe_problem, _field_vars[i], _tid)); 43 : } 44 63 : } 45 : 46 : void 47 6544 : LeapFrogStepper::setupStep(Ray & ray, Point & v, const Real q_m_ratio, const Real distance) const 48 : { 49 : 50 : // if it is the particles first step we need to take a half step 51 : // for the velocity other wise we take a full step 52 6544 : Point F = sampleField(_field_samplers, ray); 53 : 54 6544 : const auto dt = distance == 0 ? _dt / 2 : _dt; 55 : 56 6544 : v = linearImpulse(v, F, q_m_ratio, dt); 57 6544 : setMaxDistanceAndDirection(ray, v, _dt); 58 6544 : }