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 : 17 : #include "ParticleDataVectorPostprocessor.h" 18 : #include "PICStudyBase.h" 19 : 20 : registerMooseObject("SalamanderApp", ParticleDataVectorPostprocessor); 21 : 22 : InputParameters 23 168 : ParticleDataVectorPostprocessor::validParams() 24 : { 25 168 : InputParameters params = GeneralVectorPostprocessor::validParams(); 26 168 : params.addClassDescription( 27 : "Collects data which is stored in RayData on particles on a per timestep basis."); 28 336 : params.addRequiredParam<UserObjectName>("study", "The PICStudy that owns the Ray"); 29 336 : params.addParam<std::vector<std::string>>("additional_ray_data_outputs", 30 : {}, 31 : "The names of any Ray data in addition to the particle " 32 : "position and velocity that will be output"); 33 168 : return params; 34 0 : } 35 : 36 84 : ParticleDataVectorPostprocessor::ParticleDataVectorPostprocessor(const InputParameters & parameters) 37 : : GeneralVectorPostprocessor(parameters), 38 84 : _study(getUserObject<PICStudyBase>("study")), 39 84 : _ray_data_indices(_study.getVelocityIndicies(true)), 40 168 : _data_values({&declareVector("t_pos"), 41 168 : &declareVector("t_vel"), 42 168 : &declareVector("x"), 43 168 : &declareVector("y"), 44 168 : &declareVector("z"), 45 168 : &declareVector("v_x"), 46 168 : &declareVector("v_y"), 47 252 : &declareVector("v_z")}) 48 : { 49 : const auto & additional_ray_data = 50 168 : getParam<std::vector<std::string>>("additional_ray_data_outputs"); 51 : 52 84 : if (additional_ray_data.empty()) 53 63 : return; 54 : 55 21 : const auto & additional_data_indicies = _study.getRayDataIndices(additional_ray_data); 56 21 : _ray_data_indices.insert( 57 : _ray_data_indices.end(), additional_data_indicies.begin(), additional_data_indicies.end()); 58 : 59 84 : for (const auto & data_name : additional_ray_data) 60 63 : _data_values.push_back(&declareVector(data_name)); 61 0 : } 62 : 63 : void 64 196 : ParticleDataVectorPostprocessor::initialize() 65 : { 66 2296 : for (auto & data : _data_values) 67 2100 : data->clear(); 68 196 : } 69 : 70 : void 71 196 : ParticleDataVectorPostprocessor::execute() 72 : { 73 : 74 196 : const auto rays = _study.getBankedRays(); 75 6692 : for (const auto & ray : rays) 76 : { 77 : // storing the time at which the particle position is known 78 6496 : _data_values[0]->push_back(_t); 79 : // storing the time at which the particle velocity is known 80 6496 : _data_values[1]->push_back(_t - _dt / 2); 81 : const auto & point = ray->currentPoint(); 82 25984 : for (const auto i : make_range(2, 5)) 83 19488 : _data_values[i]->push_back(point(i - 2)); 84 : 85 45088 : for (const auto i : make_range(5, int(5 + _ray_data_indices.size()))) 86 38592 : _data_values[i]->push_back(ray->data(_ray_data_indices[i - 5])); 87 : } 88 196 : } 89 : 90 : void 91 196 : ParticleDataVectorPostprocessor::finalize() 92 : { 93 2296 : for (auto data : _data_values) 94 2100 : comm().gather(0, *data); 95 196 : }