https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
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
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
42bool
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)
const Real _activate_distance
define the distance of the element to the point on the path, below which the element will be activate...
virtual bool isElementActivated() override
const Function * _function_x
path of the heat source, x, y, z components
static InputParameters validParams()
ActivateElementsByPath(const InputParameters &parameters)
const Elem *const & _current_elem
The current element pointer (available during execute())
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:30
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
Real distance(const Point &p)