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 535db91
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 2 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;
}
4 changes: 2 additions & 2 deletions src/userobjects/LAMMPSFileRunner.C
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ LAMMPSFileRunner::readLAMMPSFileHistory(std::pair<FileName, FileName> filenames,
largest_column = _prop_columns[i];

if (largest_column >= elements.size())
mooseError("Error reading ", filename, " on line ", line);
mooseError("Error reading ", filenames.first, " on line ", line_before);
#endif

Point pos_before;
Expand Down Expand Up @@ -364,7 +364,7 @@ LAMMPSFileRunner::readLAMMPSFileHistory(std::pair<FileName, FileName> filenames,

// we have determined largest_column in DEBUG so we can use it in mooseAssert
mooseAssert(largest_column < elements.size(),
"Error reading " << filename << " on line " << line);
"Error reading " << filenames.second << " on line " << line_after);

Point pos_after;
for (unsigned int i = 0; i < _dim; ++i)
Expand Down
Binary file modified tests/userobjects/lammps_file/gold/granular_out.e
Binary file not shown.

0 comments on commit 535db91

Please sign in to comment.