LCOV - code coverage report
Current view: top level - src/ics - CoupledValueFunctionIC.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #32971 (54bef8) with base c6cf66 Lines: 18 20 90.0 %
Date: 2026-05-29 20:38:39 Functions: 3 3 100.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 "CoupledValueFunctionIC.h"
      11             : #include "Function.h"
      12             : 
      13             : registerMooseObject("PhaseFieldApp", CoupledValueFunctionIC);
      14             : 
      15             : InputParameters
      16          69 : CoupledValueFunctionIC::validParams()
      17             : {
      18          69 :   InputParameters params = InitialCondition::validParams();
      19          69 :   params.addClassDescription("Initialize the variable from a lookup function");
      20         138 :   params.addRequiredParam<FunctionName>("function",
      21             :                                         "Coupled function to evaluate with values from v");
      22         138 :   params.addCoupledVar("v",
      23             :                        "List of up to four coupled variables that are substituted for x,y,z, and t "
      24             :                        "in the coupled function");
      25          69 :   return params;
      26           0 : }
      27             : 
      28          37 : CoupledValueFunctionIC::CoupledValueFunctionIC(const InputParameters & parameters)
      29             :   : InitialCondition(parameters),
      30          37 :     _func(getFunction("function")),
      31          37 :     _var_num(coupledComponents("v")),
      32          74 :     _vals(coupledValues("v"))
      33             : {
      34          37 :   if (_var_num > 4)
      35           0 :     paramError("v", "You can couple at most four variables.");
      36          37 : }
      37             : 
      38             : Real
      39        4000 : CoupledValueFunctionIC::value(const Point & /*p*/)
      40             : {
      41             :   Point p;
      42             :   Real t = 0.0;
      43             : 
      44       16000 :   for (unsigned int i = 0; i < 3 && i < _var_num; ++i)
      45       12000 :     p(i) = (*_vals[i])[_qp];
      46        4000 :   if (_var_num == 4)
      47        2000 :     t = (*_vals[3])[_qp];
      48             : 
      49        4000 :   return _func.value(t, p);
      50             : }

Generated by: LCOV version 1.14