LCOV - code coverage report
Current view: top level - src/postprocessors - FeatureVolumeFraction.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 0 34 0.0 %
Date: 2025-09-04 07:55:36 Functions: 0 6 0.0 %
Legend: Lines: hit not hit

          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 "FeatureVolumeFraction.h"
      11             : #include <cmath>
      12             : 
      13             : registerMooseObject("PhaseFieldApp", FeatureVolumeFraction);
      14             : 
      15             : InputParameters
      16           0 : FeatureVolumeFraction::validParams()
      17             : {
      18           0 :   InputParameters params = GeneralPostprocessor::validParams();
      19           0 :   params.addClassDescription("Computes the total feature volume fraction from a "
      20             :                              "vectorpostprocessor computing the feature volume");
      21           0 :   MooseEnum value_type("VOLUME_FRACTION AVRAMI", "VOLUME_FRACTION");
      22           0 :   params.addParam<MooseEnum>(
      23             :       "value_type", value_type, "The value to output (VOLUME_FRACTION or AVRAMI value)");
      24           0 :   params.addRequiredParam<PostprocessorName>("mesh_volume",
      25             :                                              "Postprocessor from which to get mesh volume");
      26           0 :   params.addRequiredParam<VectorPostprocessorName>("feature_volumes",
      27             :                                                    "The feature volume VectorPostprocessorValue.");
      28           0 :   params.addParam<Real>(
      29           0 :       "equil_fraction", -1.0, "Equilibrium volume fraction of 2nd phase for Avrami analysis");
      30           0 :   return params;
      31           0 : }
      32             : 
      33           0 : FeatureVolumeFraction::FeatureVolumeFraction(const InputParameters & parameters)
      34             :   : GeneralPostprocessor(parameters),
      35           0 :     _value_type(getParam<MooseEnum>("value_type").getEnum<ValueType>()),
      36           0 :     _mesh_volume(getPostprocessorValue("mesh_volume")),
      37           0 :     _feature_volumes(getVectorPostprocessorValue("feature_volumes", "feature_volumes")),
      38           0 :     _equil_fraction(getParam<Real>("equil_fraction")),
      39           0 :     _avrami_value(0)
      40             : {
      41           0 : }
      42             : 
      43             : void
      44           0 : FeatureVolumeFraction::initialize()
      45             : {
      46           0 : }
      47             : 
      48             : void
      49           0 : FeatureVolumeFraction::execute()
      50             : {
      51             :   Real volume = 0.0;
      52             : 
      53             :   // sum the values in the vector to get total volume
      54           0 :   for (const auto & feature_volume : _feature_volumes)
      55           0 :     volume += feature_volume;
      56             : 
      57             :   mooseAssert(!MooseUtils::absoluteFuzzyEqual(_mesh_volume, 0.0), "Mesh volume is zero");
      58           0 :   _volume_fraction = volume / _mesh_volume;
      59             : 
      60           0 :   _avrami_value = calculateAvramiValue();
      61           0 : }
      62             : 
      63             : Real
      64           0 : FeatureVolumeFraction::getValue() const
      65             : {
      66           0 :   switch (_value_type)
      67             :   {
      68           0 :     case ValueType::VOLUME_FRACTION:
      69           0 :       return _volume_fraction;
      70           0 :     case ValueType::AVRAMI:
      71           0 :       return _avrami_value;
      72             :     default:
      73             :       return 0;
      74             :   }
      75             : }
      76             : 
      77             : Real
      78           0 : FeatureVolumeFraction::calculateAvramiValue()
      79             : {
      80           0 :   return std::log(std::log(1.0 / (1.0 - (_volume_fraction / _equil_fraction))));
      81             : }

Generated by: LCOV version 1.14