Line data Source code
1 : /**********************************************************************/ 2 : /* DO NOT MODIFY THIS HEADER */ 3 : /* MAGPIE - Mesoscale Atomistic Glue Program for Integrated Execution */ 4 : /* */ 5 : /* Copyright 2017 Battelle Energy Alliance, LLC */ 6 : /* ALL RIGHTS RESERVED */ 7 : /**********************************************************************/ 8 : 9 : #include "MDGranularPropertyAux.h" 10 : #include "MDRunBase.h" 11 : 12 : registerMooseObject("MagpieApp", MDGranularPropertyAux); 13 : 14 : InputParameters 15 18 : MDGranularPropertyAux::validParams() 16 : { 17 18 : InputParameters params = AuxKernel::validParams(); 18 36 : params.addRequiredParam<UserObjectName>("user_object", "Name of MD runner UserObject"); 19 36 : params.addParam<MultiMooseEnum>("md_particle_property", 20 36 : MDRunBase::mdParticleProperties(), 21 : "Property that is injected into auxiliary variable."); 22 36 : params.addParam<MooseEnum>("average_type", 23 36 : MDGranularPropertyAux::mdAveragingType(), 24 : "The type of average to be taken: " 25 : "granular_sum|granular_densitygranular_interstitial_density."); 26 18 : params.addClassDescription( 27 : "Injects properties collected for MD particles from MDRunBase object user_object " 28 : "into auxiliary variable."); 29 18 : return params; 30 0 : } 31 : 32 10 : MDGranularPropertyAux::MDGranularPropertyAux(const InputParameters & parameters) 33 : : AuxKernel(parameters), 34 10 : _md_uo(getUserObject<MDRunBase>("user_object")), 35 30 : _average_type(getParam<MooseEnum>("average_type")) 36 : { 37 : // check length of MultiMooseEnum parameter, get it and check that UO has it 38 20 : MultiMooseEnum mme = getParam<MultiMooseEnum>("md_particle_property"); 39 10 : if (mme.size() != 1) 40 0 : mooseError("md_particle_property must contain a single property."); 41 10 : _property_id = mme.get(0); 42 20 : if (!_md_uo.properties().contains(mme)) 43 0 : mooseError("Property ", _property_id, " not available from user_object."); 44 : 45 : // ensure MD particles are granular 46 10 : if (!_md_uo.isGranular()) 47 0 : mooseError("user_object stores non-granular particles."); 48 : 49 : // ensure variable is elemental 50 10 : if (isNodal()) 51 0 : mooseError("MDGranularPropertyAux only permits elemental variables."); 52 10 : } 53 : 54 : Real 55 1728 : MDGranularPropertyAux::computeValue() 56 : { 57 1728 : if (_qp == 0) 58 : { 59 216 : _property_value = 0.0; 60 : 61 : // get the overlapping MD particles 62 : std::vector<std::pair<unsigned int, Real>> gran_vol; 63 216 : _md_uo.granularElementVolumes(_current_elem->unique_id(), gran_vol); 64 : 65 : // loop over the overlapping MD particles and add property value 66 : Real denominator = 0; 67 648 : for (auto & p : gran_vol) 68 : { 69 432 : _property_value += p.second * _md_uo.particleProperty(p.first, _property_id); 70 432 : denominator += p.second; 71 : } 72 : 73 : // compute property value depending on what average type is requested 74 216 : if (_average_type == 1) 75 216 : _property_value /= _current_elem->volume(); 76 0 : else if (_average_type == 2) 77 : { 78 0 : if (denominator == 0.0) 79 0 : _property_value = 0.0; 80 : else 81 0 : _property_value /= denominator; 82 : } 83 : } 84 1728 : return _property_value; 85 : } 86 : 87 : MooseEnum 88 18 : MDGranularPropertyAux::mdAveragingType() 89 : { 90 36 : return MooseEnum("granular_sum=0 granular_density=1 granular_interstitial_density=2"); 91 : }