LCOV - code coverage report
Current view: top level - src/postprocessors - ObtainAvgContactAngle.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #32971 (54bef8) with base c6cf66 Lines: 31 32 96.9 %
Date: 2026-05-29 20:38:39 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         312 : ObtainAvgContactAngle::validParams()
      18             : {
      19         312 :   InputParameters params = SidePostprocessor::validParams();
      20         312 :   params.addClassDescription("Obtain contact angle");
      21         624 :   params.addRequiredCoupledVar("pf", "phase field variable");
      22         312 :   return params;
      23           0 : }
      24             : 
      25         168 : ObtainAvgContactAngle::ObtainAvgContactAngle(const InputParameters & parameters)
      26         168 :   : SidePostprocessor(parameters), _pf(coupledValue("pf")), _grad_pf(coupledGradient("pf"))
      27             : {
      28         168 : }
      29             : 
      30             : void
      31         744 : ObtainAvgContactAngle::initialize()
      32             : {
      33         744 :   _cos_theta_val = 0.0;
      34         744 :   _total_weight = 0.0;
      35         744 : }
      36             : 
      37             : void
      38        2799 : ObtainAvgContactAngle::execute()
      39             : {
      40             : 
      41       11196 :   for (unsigned int qp = 0; qp < _qrule->n_points(); qp++)
      42             :   {
      43        8397 :     if (std::abs(_pf[qp]) < 0.5) // Operating only within the interface
      44             :     {
      45             :       // Real tol_val = libMesh::TOLERANCE * libMesh::TOLERANCE;
      46         405 :       const Real weight = _grad_pf[qp].norm();
      47         405 :       _cos_theta_val +=
      48         405 :           _grad_pf[qp] * _normals[qp]; // weight * (_grad_pf[qp]/_grad_pf[qp].norm()) * _normals[qp]
      49         405 :       _total_weight += weight;
      50             :     }
      51             :   }
      52        2799 : }
      53             : 
      54             : Real
      55         624 : ObtainAvgContactAngle::getValue() const
      56             : {
      57         624 :   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         624 : ObtainAvgContactAngle::finalize()
      70             : {
      71         624 :   gatherSum(_cos_theta_val);
      72         624 :   gatherSum(_total_weight);
      73         624 :   _contact_angle = std::acos(_cos_theta_val / _total_weight) * 180 / libMesh::pi;
      74         624 : }

Generated by: LCOV version 1.14