LCOV - code coverage report
Current view: top level - src/constraints - NodeElemConstraintBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 34 35 97.1 %
Date: 2025-07-17 01:28:37 Functions: 5 6 83.3 %
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 "NodeElemConstraintBase.h"
      11             : 
      12             : #include "MooseVariableFE.h"
      13             : #include "SystemBase.h"
      14             : 
      15             : InputParameters
      16       43197 : NodeElemConstraintBase::validParams()
      17             : {
      18       43197 :   InputParameters params = Constraint::validParams();
      19       43197 :   params.addRequiredParam<SubdomainName>("secondary", "secondary block id");
      20       43197 :   params.addRequiredParam<SubdomainName>("primary", "primary block id");
      21       43197 :   params.addRequiredCoupledVar("primary_variable",
      22             :                                "The variable on the primary side of the domain");
      23       43197 :   return params;
      24           0 : }
      25             : 
      26         204 : NodeElemConstraintBase::NodeElemConstraintBase(const InputParameters & parameters)
      27             :   : Constraint(parameters),
      28             :     // The secondary side is at nodes (hence passing 'true').  The neighbor side is the primary side
      29             :     // and it is not at nodes (so passing false)
      30             :     NeighborCoupleableMooseVariableDependencyIntermediateInterface(this, true, false),
      31             :     NeighborMooseVariableInterface<Real>(
      32             :         this, true, Moose::VarKindType::VAR_SOLVER, Moose::VarFieldType::VAR_FIELD_STANDARD),
      33         204 :     _var(_sys.getFieldVariable<Real>(_tid, parameters.get<NonlinearVariableName>("variable"))),
      34         204 :     _primary_var(*getVar("primary_variable", 0)),
      35             : 
      36         204 :     _secondary(_mesh.getSubdomainID(getParam<SubdomainName>("secondary"))),
      37         204 :     _primary(_mesh.getSubdomainID(getParam<SubdomainName>("primary"))),
      38             : 
      39         204 :     _current_node(_var.node()),
      40         204 :     _current_elem(_var.neighbor()),
      41             : 
      42         204 :     _phi_secondary(1),
      43         204 :     _test_secondary(1), // One entry
      44             : 
      45         204 :     _phi_primary(_assembly.phiNeighbor(_primary_var)),
      46         204 :     _test_primary(_var.phiNeighbor()),
      47             : 
      48         204 :     _node_to_elem_map(_mesh.nodeToElemMap()),
      49         408 :     _overwrite_secondary_residual(false)
      50             : {
      51         204 :   addMooseVariableDependency(&_var);
      52         204 :   _mesh.errorIfDistributedMesh("NodeElemConstraintBase");
      53             :   // Put a "1" into test_secondary
      54             :   // will always only have one entry that is 1
      55         204 :   _test_secondary[0].push_back(1);
      56         204 : }
      57             : 
      58         200 : NodeElemConstraintBase::~NodeElemConstraintBase()
      59             : {
      60         200 :   _phi_secondary.release();
      61         200 :   _test_secondary.release();
      62         200 : }
      63             : 
      64             : void
      65        4970 : NodeElemConstraintBase::computeSecondaryValue(NumericVector<Number> & current_solution)
      66             : {
      67        4970 :   const dof_id_type & dof_idx = _var.nodalDofIndex();
      68        4970 :   _qp = 0;
      69        4970 :   current_solution.set(dof_idx, computeQpSecondaryValue());
      70        4970 : }
      71             : 
      72             : bool
      73       14910 : NodeElemConstraintBase::overwriteSecondaryResidual() const
      74             : {
      75       14910 :   return _overwrite_secondary_residual;
      76             : }

Generated by: LCOV version 1.14