LCOV - code coverage report
Current view: top level - src/auxkernels - MDGranularPorosityAux.C (source / functions) Hit Total Coverage
Test: idaholab/magpie: 5710af Lines: 23 26 88.5 %
Date: 2025-07-21 23:34:39 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          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 "MDGranularPorosityAux.h"
      10             : #include "MDRunBase.h"
      11             : 
      12             : registerMooseObject("MagpieApp", MDGranularPorosityAux);
      13             : 
      14             : InputParameters
      15          18 : MDGranularPorosityAux::validParams()
      16             : {
      17          18 :   InputParameters params = AuxKernel::validParams();
      18          36 :   params.addRequiredParam<UserObjectName>("user_object", "Name of MD runner UserObject");
      19          36 :   params.addParam<bool>(
      20          36 :       "compute_packing_fraction", false, "Whether to compute porosity or packing fraction.");
      21          18 :   params.addClassDescription(
      22             :       "Computes porosity or packing fraction (1 - porosity) and injects it into and aux variable.");
      23          18 :   return params;
      24           0 : }
      25             : 
      26          10 : MDGranularPorosityAux::MDGranularPorosityAux(const InputParameters & parameters)
      27             :   : AuxKernel(parameters),
      28          10 :     _md_uo(getUserObject<MDRunBase>("user_object")),
      29          30 :     _compute_packing(getParam<bool>("compute_packing_fraction"))
      30             : {
      31             :   // ensure MD particles are granular
      32          10 :   if (!_md_uo.isGranular())
      33           0 :     mooseError("user_object stores non-granular particles.");
      34             : 
      35             :   // ensure variable is elemental
      36          10 :   if (isNodal())
      37           0 :     mooseError("MDGranularPorosityAux only permits elemental variables.");
      38          10 : }
      39             : 
      40             : Real
      41        1656 : MDGranularPorosityAux::computeValue()
      42             : {
      43        1656 :   if (_qp == 0)
      44             :   {
      45         288 :     _packing_fraction = 0.0;
      46             : 
      47             :     // get the overlapping MD particles
      48             :     std::vector<std::pair<unsigned int, Real>> gran_vol;
      49         288 :     _md_uo.granularElementVolumes(_current_elem->unique_id(), gran_vol);
      50             : 
      51             :     // add the overlapping volumes
      52         648 :     for (auto & p : gran_vol)
      53         360 :       _packing_fraction += p.second;
      54             : 
      55             :     // divide by element volume
      56         288 :     _packing_fraction /= _current_elem->volume();
      57             :   }
      58        1656 :   if (_compute_packing)
      59        1080 :     return _packing_fraction;
      60         576 :   return 1 - _packing_fraction;
      61             : }

Generated by: LCOV version 1.14