Skip to content

Commit

Permalink
Add PorosityAux (idaholab#367)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Schunert committed Feb 11, 2019
1 parent d45bb58 commit 4f97f56
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 0 deletions.
39 changes: 39 additions & 0 deletions include/auxkernels/MDGranularPorosityAux.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**********************************************************************/
/* DO NOT MODIFY THIS HEADER */
/* MAGPIE - Mesoscale Atomistic Glue Program for Integrated Execution */
/* */
/* Copyright 2017 Battelle Energy Alliance, LLC */
/* ALL RIGHTS RESERVED */
/**********************************************************************/

#ifndef MDGRANULARPOROSITYAUX_H
#define MDGRANULARPOROSITYAUX_H

#include "AuxKernel.h"

// forward declarations
class MDRunBase;
class MDGranularPorosityAux;

template <>
InputParameters validParams<MDGranularPorosityAux>();

class MDGranularPorosityAux : public AuxKernel
{
public:
MDGranularPorosityAux(const InputParameters & params);
virtual ~MDGranularPorosityAux() {}

virtual Real computeValue();

protected:
/// referene to the MDRunBase user object
const MDRunBase & _md_uo;

const bool _compute_packing;

/// property value that is computed only on qp = 0
Real _packing_fraction;
};

#endif // MDGRANULARPOROSITYAUXx_H
61 changes: 61 additions & 0 deletions src/auxkernels/MDGranularPorosityAux.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**********************************************************************/
/* DO NOT MODIFY THIS HEADER */
/* MAGPIE - Mesoscale Atomistic Glue Program for Integrated Execution */
/* */
/* Copyright 2017 Battelle Energy Alliance, LLC */
/* ALL RIGHTS RESERVED */
/**********************************************************************/

#include "MDGranularPorosityAux.h"
#include "MDRunBase.h"

registerMooseObject("MagpieApp", MDGranularPorosityAux);

template <>
InputParameters
validParams<MDGranularPorosityAux>()
{
InputParameters params = validParams<AuxKernel>();
params.addRequiredParam<UserObjectName>("user_object", "Name of MD runner UserObject");
params.addParam<bool>("compute_packing_fraction", false, "Whether to compute porosity or packing fraction.");
params.addClassDescription(
"Computes porosity or packing fraction (1 - porosity) and injects it into and aux variable.");
return params;
}

MDGranularPorosityAux::MDGranularPorosityAux(const InputParameters & parameters)
: AuxKernel(parameters),
_md_uo(getUserObject<MDRunBase>("user_object")),
_compute_packing(getParam<bool>("compute_packing_fraction"))
{
// ensure MD particles are granular
if (!_md_uo.isGranular())
mooseError("user_object stores non-granular particles.");

// ensure variable is elemental
if (isNodal())
mooseError("MDGranularPorosityAux only permits elemental variables.");
}

Real
MDGranularPorosityAux::computeValue()
{
if (_qp == 0)
{
_packing_fraction = 0.0;

// get the overlapping MD particles
std::vector<std::pair<unsigned int, Real>> gran_vol;
_md_uo.granularElementVolumes(_current_elem->unique_id(), gran_vol);

// add the overlapping volumes
for (auto & p : gran_vol)
_packing_fraction += p.second;

// divide by element volume
_packing_fraction /= _current_elem->volume();
}
if (_compute_packing)
return _packing_fraction;
return 1 - _packing_fraction;
}
Binary file modified tests/userobjects/lammps_file/gold/granular_out.e
Binary file not shown.

0 comments on commit 4f97f56

Please sign in to comment.