LCOV - code coverage report
Current view: top level - src/postprocessors - ObtainAvgContactAngle.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31730 (e8b711) with base e0c998 Lines: 31 32 96.9 %
Date: 2025-10-29 16:53:21 Functions: 7 7 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://www.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 "ObtainAvgContactAngle.h"
      11             : 
      12             : #include "libmesh/quadrature.h"
      13             : 
      14             : registerMooseObject("PhaseFieldApp", ObtainAvgContactAngle);
      15             : 
      16             : InputParameters
      17         408 : ObtainAvgContactAngle::validParams()
      18             : {
      19         408 :   InputParameters params = SidePostprocessor::validParams();
      20         408 :   params.addClassDescription("Obtain contact angle");
      21         816 :   params.addRequiredCoupledVar("pf", "phase field variable");
      22         408 :   return params;
      23           0 : }
      24             : 
      25         216 : ObtainAvgContactAngle::ObtainAvgContactAngle(const InputParameters & parameters)
      26         216 :   : SidePostprocessor(parameters), _pf(coupledValue("pf")), _grad_pf(coupledGradient("pf"))
      27             : {
      28         216 : }
      29             : 
      30             : void
      31         864 : ObtainAvgContactAngle::initialize()
      32             : {
      33         864 :   _cos_theta_val = 0.0;
      34         864 :   _total_weight = 0.0;
      35         864 : }
      36             : 
      37             : void
      38        3337 : ObtainAvgContactAngle::execute()
      39             : {
      40             : 
      41       13348 :   for (unsigned int qp = 0; qp < _qrule->n_points(); qp++)
      42             :   {
      43       10011 :     if (std::abs(_pf[qp]) < 0.5) // Operating only within the interface
      44             :     {
      45             :       // Real tol_val = libMesh::TOLERANCE * libMesh::TOLERANCE;
      46         483 :       const Real weight = _grad_pf[qp].norm();
      47         483 :       _cos_theta_val +=
      48         483 :           _grad_pf[qp] * _normals[qp]; // weight * (_grad_pf[qp]/_grad_pf[qp].norm()) * _normals[qp]
      49         483 :       _total_weight += weight;
      50             :     }
      51             :   }
      52        3337 : }
      53             : 
      54             : Real
      55         744 : ObtainAvgContactAngle::getValue() const
      56             : {
      57         744 :   return _contact_angle;
      58             : }
      59             : 
      60             : void
      61         120 : ObtainAvgContactAngle::threadJoin(const UserObject & y)
      62             : {
      63             :   const ObtainAvgContactAngle & pps = static_cast<const ObtainAvgContactAngle &>(y);
      64         120 :   _cos_theta_val += pps._cos_theta_val;
      65         120 :   _total_weight += pps._total_weight;
      66         120 : }
      67             : 
      68             : void
      69         744 : ObtainAvgContactAngle::finalize()
      70             : {
      71         744 :   gatherSum(_cos_theta_val);
      72         744 :   gatherSum(_total_weight);
      73         744 :   _contact_angle = std::acos(_cos_theta_val / _total_weight) * 180 / libMesh::pi;
      74         744 : }

Generated by: LCOV version 1.14