https://mooseframework.inl.gov
Loading...
Searching...
No Matches
GravityVectorInterface.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 "PhysicalConstants.h"
12#include "MooseUtils.h"
13#include "MooseObject.h"
14
17{
19 params.addParam<Real>("gravity_magnitude",
21 "Magnitude of the gravitational acceleration [m/s^2]");
22 params.addParam<RealVectorValue>(
23 "gravity_direction",
24 "Direction of gravitational acceleration. This will be normalized and multiplied by "
25 "'gravity_magnitude'. This parameter is mutually exclusive with 'gravity_vector'.");
26 params.addParam<RealVectorValue>("gravity_vector",
27 "Gravitational acceleration vector [m/s^2]. This parameter is "
28 "mutually exclusive with 'gravity_direction'.");
29 return params;
30}
31
33{
34 if (moose_object->isParamValid("gravity_direction"))
35 {
36 if (moose_object->isParamValid("gravity_vector"))
37 moose_object->paramError(
38 "gravity_direction",
39 "The parameters 'gravity_vector' and 'gravity_direction' are mutually exclusive.");
40
41 _gravity_magnitude = moose_object->getParam<Real>("gravity_magnitude");
42
43 // Direction is normalized below
44 _gravity_direction = moose_object->getParam<RealVectorValue>("gravity_direction");
45
46 // If gravity is zero, direction is the zero vector (which is initial value)
47 if (MooseUtils::absoluteFuzzyEqual(_gravity_direction.norm(), 0.0))
48 {
49 if (!MooseUtils::absoluteFuzzyEqual(_gravity_magnitude, 0.0))
50 mooseError("If 'gravity_direction' is zero, then 'gravity_magnitude' must also be zero.");
51 }
52 else
53 {
54 // If gravity is zero, direction is the zero vector
55 if (MooseUtils::absoluteFuzzyEqual(_gravity_magnitude, 0.0))
56 _gravity_direction = RealVectorValue(0, 0, 0);
57 else
59 }
60
62 }
63 else if (moose_object->isParamValid("gravity_vector"))
64 {
65 if (moose_object->isParamSetByUser("gravity_magnitude"))
66 moose_object->paramError(
67 "gravity_magnitude",
68 "The parameters 'gravity_vector' and 'gravity_magnitude' are mutually exclusive.");
69
70 _gravity_vector = moose_object->getParam<RealVectorValue>("gravity_vector");
72
73 // If gravity is zero, direction is the zero vector
74 if (MooseUtils::absoluteFuzzyEqual(_gravity_magnitude, 0.0))
75 _gravity_direction = RealVectorValue(0, 0, 0);
76 else
78 }
79 else
80 moose_object->paramError("gravity_vector",
81 "Either 'gravity_vector' or 'gravity_direction' must be specified.");
82}
InputParameters emptyInputParameters()
void mooseError(Args &&... args)
RealVectorValue _gravity_direction
Gravitational acceleration unit direction.
RealVectorValue _gravity_vector
Gravitational acceleration vector.
Real _gravity_magnitude
Gravitational acceleration magnitude.
GravityVectorInterface(const MooseObject *moose_object)
static InputParameters validParams()
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void paramError(const std::string &param, Args... args) const
bool isParamSetByUser(const std::string &name) const
const T & getParam(const std::string &name) const
bool isParamValid(const std::string &name) const
TypeVector< T > unit() const
const auto acceleration_of_gravity