https://mooseframework.inl.gov
Loading...
Searching...
No Matches
GeneratedMeshComponent.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 "THMMesh.h"
12
15{
18
19 params.addParam<std::vector<std::string>>(
20 "axial_region_names", {}, "Names to assign to axial regions");
21
22 return params;
23}
24
26 : GeometricalComponent(parameters),
28
29 _axial_region_names(getParam<std::vector<std::string>>("axial_region_names"))
30{
31 checkSizeGreaterThan<Real>("length", 0);
32 checkEqualSize<Real, unsigned int>("length", "n_elems");
33 if (_axial_region_names.size() > 0)
34 checkEqualSize<Real, std::string>("length", "axial_region_names");
35}
36
37void
39{
41
42 buildMesh();
43
44 // displace nodes
45 for (auto && node_id : _node_ids)
46 {
47 Node & curr_node = mesh().nodeRef(node_id);
48 RealVectorValue p(curr_node(0), curr_node(1), curr_node(2));
50 }
51}
52
53void
55{
57
58 // Do not use TRAP q-rule with 2nd order FEs
60 {
61 auto actions = _app.actionWarehouse().getActionListByName("setup_quadrature");
62 const MooseEnum & quadrature_type = (*actions.begin())->getParam<MooseEnum>("type");
63
64 if (quadrature_type == "TRAP")
65 logError("Cannot use TRAP quadrature rule with 2nd order elements. Use SIMPSON or GAUSS "
66 "instead.");
67 }
68}
69
70unsigned int
72{
73 return usingSecondOrderMesh() ? (2 * n_elems) + 1 : n_elems + 1;
74}
75
76void
78{
79 unsigned int n_nodes = computeNumberOfNodes(_n_elem);
80 unsigned int start_node = 0;
81 Real start_length = 0.0;
82 _node_locations = std::vector<Real>(n_nodes);
83 _node_locations[0] = start_length;
84
85 for (unsigned int i = 0; i < _n_sections; ++i)
86 {
87 Real section_length = _lengths[i];
88 Real section_n_elems = _n_elems[i];
89 Real section_n_nodes = computeNumberOfNodes(section_n_elems);
90
91 std::vector<Real> section_node_array = getUniformNodeLocations(section_length, section_n_nodes);
92 placeLocalNodeLocations(start_length, start_node, section_node_array);
93
94 start_length += section_length;
95 start_node += (section_n_nodes - 1);
96 }
97}
98
99std::vector<Real>
100GeneratedMeshComponent::getUniformNodeLocations(Real length, unsigned int n_nodes)
101{
102 std::vector<Real> node_locations(n_nodes);
103 Real dx = length / (n_nodes - 1);
104
105 node_locations[0] = 0.0;
106
107 for (unsigned int i = 1; i < (n_nodes - 1); ++i)
108 node_locations[i] = node_locations[i - 1] + dx;
109
110 node_locations[n_nodes - 1] = length;
111 return node_locations;
112}
113
114void
116 unsigned int start_node,
117 std::vector<Real> & local_node_locations)
118{
119 unsigned int n_nodes = local_node_locations.size();
120 for (unsigned int i = 1; i < n_nodes; ++i)
121 {
122 unsigned int global_i = i + start_node;
123 Real local_node_location = local_node_locations[i];
124 _node_locations[global_i] = start_length + local_node_location;
125 }
126}
const Real p
const std::list< Action * > & getActionListByName(const std::string &task) const
void logError(Args &&... args) const
Logs an error.
Definition Component.h:226
virtual void check() const
Check the component integrity.
Definition Component.h:416
std::vector< dof_id_type > _node_ids
Node IDs of this component.
Definition Component.h:506
THMMesh & mesh()
Non-const reference to THM mesh, which can only be called before the end of mesh setup.
Definition Component.C:60
Defines a discretized line segment in 3D space.
unsigned int _n_elem
Total number of axial elements.
const unsigned int _n_sections
Number of axial sections.
std::vector< unsigned int > _n_elems
Number of elements in each axial section.
Point computeRealPointFromReferencePoint(const Point &p) const
Computes point in 3-D space from a point in reference space.
std::vector< Real > _lengths
Length of each axial section.
void placeLocalNodeLocations(Real start_length, unsigned int start_node, std::vector< Real > &local_node_locations)
Puts local positions of axial nodes for an axial section into _node_locations.
std::vector< Real > _node_locations
Node locations along the main axis.
virtual void check() const override
Check the component integrity.
static InputParameters validParams()
virtual bool usingSecondOrderMesh() const =0
Check if second order mesh is being used by this geometrical component.
unsigned int computeNumberOfNodes(unsigned int n_elems)
Computes the number of axial nodes from the number of elements.
virtual void setupMesh() override
Performs mesh setup such as creating mesh or naming mesh sets.
const std::vector< std::string > & _axial_region_names
Axial region names.
std::vector< Real > getUniformNodeLocations(Real length, unsigned int n_nodes)
Computes the local positions of axial nodes for an axial section.
virtual void buildMesh()=0
void generateNodeLocations()
Generates axial node locations and stores in _node_locations.
GeneratedMeshComponent(const InputParameters &parameters)
Intermediate class for components that have mesh.
static InputParameters validParams()
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
ActionWarehouse & actionWarehouse()
virtual const Node & nodeRef(const dof_id_type i) const
MooseApp & _app
const dof_id_type n_nodes