Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : 10 : #include "VectorPostprocessorVisualizationAux.h" 11 : 12 : registerMooseObject("MooseApp", VectorPostprocessorVisualizationAux); 13 : 14 : InputParameters 15 14443 : VectorPostprocessorVisualizationAux::validParams() 16 : { 17 14443 : InputParameters params = AuxKernel::validParams(); 18 : 19 14443 : params.addClassDescription("Read values from a VectorPostprocessor that is producing vectors " 20 : "that are 'number of processors' * in length. Puts the value for " 21 : "each processor into an elemental auxiliary field."); 22 : 23 14443 : params.addRequiredParam<VectorPostprocessorName>( 24 : "vpp", "The name of the VectorPostprocessor to pull the data from."); 25 14443 : params.addRequiredParam<std::string>( 26 : "vector_name", "The name of the vector to use from the VectorPostprocessor"); 27 : 28 43329 : params.addParam<bool>("use_broadcast", 29 28886 : false, 30 : "Causes this AuxKernel to use a broadcasted version of the vector instead " 31 : "of a scattered version of the vector (the default). This is slower - but " 32 : "is useful for debugging and testing"); 33 : 34 14443 : return params; 35 0 : } 36 : 37 94 : VectorPostprocessorVisualizationAux::VectorPostprocessorVisualizationAux( 38 94 : const InputParameters & parameters) 39 : : AuxKernel(parameters), 40 94 : _use_broadcast(getParam<bool>("use_broadcast")), 41 94 : _vpp_scatter(getScatterVectorPostprocessorValue("vpp", getParam<std::string>("vector_name"))), 42 94 : _vpp_vector( 43 94 : getVectorPostprocessorValue("vpp", getParam<std::string>("vector_name"), _use_broadcast)), 44 188 : _my_pid(processor_id()) 45 : { 46 94 : } 47 : 48 : void 49 84 : VectorPostprocessorVisualizationAux::timestepSetup() 50 : { 51 84 : if (_my_pid == 0 && _vpp_vector.size() != n_processors()) 52 0 : mooseError("Error in AuxKernel ", 53 0 : name(), 54 : ". Vector ", 55 : getParam<std::string>("vector_name"), 56 : " in VectorPostprocessor ", 57 : getParam<VectorPostprocessorName>("vpp"), 58 : " does not contain num_procs number of entries. num_procs: ", 59 0 : n_processors(), 60 : " num_entries: ", 61 0 : _vpp_vector.size()); 62 84 : } 63 : 64 : Real 65 12000 : VectorPostprocessorVisualizationAux::computeValue() 66 : { 67 12000 : if (_use_broadcast) 68 : { 69 : mooseAssert(_vpp_vector.size() > _my_pid, 70 : "Vector does not contain enough entries in VectorPostprocessorVisualization named " 71 : << name()); 72 3200 : return _vpp_vector[_my_pid]; 73 : } 74 8800 : return _vpp_scatter; 75 : }