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 "RampIC.h" 11 : #include "FEProblem.h" 12 : #include "MooseMesh.h" 13 : 14 : registerMooseObject("PhaseFieldApp", RampIC); 15 : 16 : InputParameters 17 72 : RampIC::validParams() 18 : { 19 72 : InputParameters params = InitialCondition::validParams(); 20 72 : params.addClassDescription( 21 : "Linear ramp along the x-axis with given values at the left and right extreme points."); 22 144 : params.addRequiredParam<Real>("value_left", "The value on left (xmin) boundary."); 23 144 : params.addRequiredParam<Real>("value_right", "The value on right (xmax) boundary."); 24 72 : return params; 25 0 : } 26 : 27 38 : RampIC::RampIC(const InputParameters & parameters) 28 : : InitialCondition(parameters), 29 38 : _xlength(_fe_problem.mesh().dimensionWidth(0)), 30 38 : _xmin(_fe_problem.mesh().getMinInDimension(0)), 31 76 : _value_left(getParam<Real>("value_left")), 32 114 : _value_right(getParam<Real>("value_right")) 33 : { 34 38 : } 35 : 36 : Real 37 540 : RampIC::value(const Point & p) 38 : { 39 540 : return (_value_right - _value_left) / _xlength * (p(0) - _xmin) + _value_left; 40 : } 41 : 42 : RealGradient 43 0 : RampIC::gradient(const Point & /*p*/) 44 : { 45 0 : return (_value_right - _value_left) / _xlength; 46 : }