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 "SinDirichletBC.h" 11 : 12 : registerMooseObject("MooseApp", SinDirichletBC); 13 : 14 : InputParameters 15 14361 : SinDirichletBC::validParams() 16 : { 17 14361 : InputParameters params = NodalBC::validParams(); 18 14361 : params.set<Real>("initial") = 0.0; 19 14361 : params.set<Real>("final") = 0.0; 20 14361 : params.set<Real>("duration") = 0.0; 21 14361 : params.addClassDescription( 22 : "Imposes a time-varying essential boundary condition $u=g(t)$, where $g(t)$ " 23 : "varies from an given initial value at time $t=0$ to a given final value over a specified " 24 : "duration."); 25 14361 : return params; 26 0 : } 27 : 28 48 : SinDirichletBC::SinDirichletBC(const InputParameters & parameters) 29 : : NodalBC(parameters), 30 48 : _initial(getParam<Real>("initial")), 31 48 : _final(getParam<Real>("final")), 32 96 : _duration(getParam<Real>("duration")) 33 : { 34 48 : } 35 : 36 : Real 37 88880 : SinDirichletBC::computeQpResidual() 38 : { 39 : Real value; 40 : 41 88880 : if (_t < _duration) 42 79992 : value = _initial + (_final - _initial) * std::sin((0.5 / _duration) * libMesh::pi * _t); 43 : else 44 8888 : value = _final; 45 : 46 88880 : return _u[_qp] - value; 47 : }