https://mooseframework.inl.gov
ActivateElementsByPath.C
Go to the documentation of this file.
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 
14 
17 {
19 
20  params.addParam<FunctionName>(
21  "function_x", "0", "The x component of the heating spot travel path");
22  params.addParam<FunctionName>(
23  "function_y", "0", "The y component of the heating spot travel path");
24  params.addParam<FunctionName>(
25  "function_z", "0", "The z component of the heating spot travel path");
26  params.addParam<Real>("activate_distance",
27  1e-4,
28  "The maximum distance of the activated element to the point on the path.");
29  return params;
30 }
31 
33  : ActivateElementsUserObjectBase(parameters),
34  _function_x(isParamValid("function_x") ? &getFunction("function_x") : nullptr),
35  _function_y(isParamValid("function_y") ? &getFunction("function_y") : nullptr),
36  _function_z(isParamValid("function_z") ? &getFunction("function_z") : nullptr),
37  _activate_distance(
38  declareRestartableData<Real>("activate_distance", getParam<Real>("activate_distance")))
39 {
40 }
41 
42 bool
44 {
45  // activate center (assume position of the activate center is only time dependent)
46  const static Point dummy;
47  Real x_t = _function_x ? _function_x->value(_t, dummy) : 0.0;
48  Real y_t = _function_y ? _function_y->value(_t, dummy) : 0.0;
49  Real z_t = _function_z ? _function_z->value(_t, dummy) : 0.0;
50 
51  // activate element when element is close to the point
52  Real distance = (_current_elem->vertex_average() - Point(x_t, y_t, z_t)).norm();
54  return true;
55  else
56  return false;
57 }
registerMooseObject("MooseApp", ActivateElementsByPath)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const Function * _function_x
path of the heat source, x, y, z components
Real distance(const Point &p)
ActivateElementsByPath(const InputParameters &parameters)
auto norm(const T &a) -> decltype(std::abs(a))
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Elem *const & _current_elem
The current element pointer (available during execute())
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
virtual Real value(Real t, const Point &p) const
Override this to evaluate the scalar function at point (t,x,y,z), by default this returns zero...
Definition: Function.C:44
const Real _activate_distance
define the distance of the element to the point on the path, below which the element will be activate...
static InputParameters validParams()
virtual bool isElementActivated() override