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 "ActivateElementsByPath.h" 11 : #include "libmesh/point.h" 12 : 13 : registerMooseObject("MooseApp", ActivateElementsByPath); 14 : 15 : InputParameters 16 14265 : ActivateElementsByPath::validParams() 17 : { 18 14265 : InputParameters params = ActivateElementsUserObjectBase::validParams(); 19 : 20 14265 : params.addParam<FunctionName>( 21 : "function_x", "0", "The x component of the heating spot travel path"); 22 14265 : params.addParam<FunctionName>( 23 : "function_y", "0", "The y component of the heating spot travel path"); 24 14265 : params.addParam<FunctionName>( 25 : "function_z", "0", "The z component of the heating spot travel path"); 26 42795 : params.addParam<Real>("activate_distance", 27 28530 : 1e-4, 28 : "The maximum distance of the activated element to the point on the path."); 29 14265 : return params; 30 0 : } 31 : 32 0 : ActivateElementsByPath::ActivateElementsByPath(const InputParameters & parameters) 33 : : ActivateElementsUserObjectBase(parameters), 34 0 : _function_x(isParamValid("function_x") ? &getFunction("function_x") : nullptr), 35 0 : _function_y(isParamValid("function_y") ? &getFunction("function_y") : nullptr), 36 0 : _function_z(isParamValid("function_z") ? &getFunction("function_z") : nullptr), 37 0 : _activate_distance( 38 0 : declareRestartableData<Real>("activate_distance", getParam<Real>("activate_distance"))) 39 : { 40 0 : } 41 : 42 : bool 43 0 : ActivateElementsByPath::isElementActivated() 44 : { 45 : // activate center (assume position of the activate center is only time dependent) 46 0 : const static Point dummy; 47 0 : Real x_t = _function_x ? _function_x->value(_t, dummy) : 0.0; 48 0 : Real y_t = _function_y ? _function_y->value(_t, dummy) : 0.0; 49 0 : Real z_t = _function_z ? _function_z->value(_t, dummy) : 0.0; 50 : 51 : // activate element when element is close to the point 52 0 : Real distance = (_current_elem->vertex_average() - Point(x_t, y_t, z_t)).norm(); 53 0 : if (distance < _activate_distance) 54 0 : return true; 55 : else 56 0 : return false; 57 : }