https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Component1DConnection.h
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#pragma once
11
12#include "Component.h"
13
18{
19public:
21
24 {
26 OUT
27 };
29 static const std::map<std::string, EEndType> _end_type_to_enum;
30
33 {
35 const BoundaryName _boundary_name;
36
38 const std::string _component_name;
39
42
43 Connection(const BoundaryName & boundary_name,
44 const std::string & component_name,
45 const EEndType & end_type)
46 : _boundary_name(boundary_name), _component_name(component_name), _end_type(end_type)
47 {
48 }
49 };
50
56 const std::vector<Connection> & getConnections() const { return _connections; }
57
63 const std::vector<std::string> & getConnectedComponentNames() const
64 {
66 }
67
71 const std::vector<SubdomainName> & getConnectedSubdomainNames() const
72 {
74 }
75
81 virtual const std::vector<dof_id_type> & getNodeIDs() const;
82
88 const std::vector<BoundaryName> & getBoundaryNames() const;
89
90protected:
91 virtual void setupMesh() override;
92 virtual void init() override;
93 virtual void check() const override;
94
103 void addConnection(const BoundaryName & boundary_name);
104
110 void checkNumberOfConnections(const unsigned int & n_connections) const;
111
118 template <typename T>
119 void checkSizeEqualsNumberOfConnections(const std::string & param) const;
120
128 template <typename T>
129 void checkAllConnectionsHaveSame(const std::vector<T> & objects,
130 const std::string & description) const;
131
133 std::vector<Point> _positions;
135 std::vector<const Elem *> _elems;
137 std::vector<unsigned short int> _sides;
139 std::vector<dof_id_type> _nodes;
141 std::vector<unsigned int> _boundary_ids;
143 std::vector<BoundaryName> _boundary_names;
145 std::vector<Real> _normals;
147 std::vector<RealVectorValue> _directions;
148
150 std::vector<Connection> _connections;
152 std::vector<std::string> _connected_component_names;
154 std::vector<SubdomainName> _connected_subdomain_names;
155
156public:
158};
159
160template <typename T>
161void
163{
164 const auto & value = getParam<std::vector<T>>(param);
165 if (value.size() != _connections.size())
166 logError("The number of entries in '",
167 param,
168 "' (",
169 value.size(),
170 ") must equal the number of connections (",
171 _connections.size(),
172 ")");
173}
174
175template <typename T>
176void
178 const std::string & description) const
179{
180 for (const auto & obj : objects)
181 if (obj != objects[0])
182 logError("All connections must have the same ", description);
183}
184
185namespace THM
186{
187template <>
188Component1DConnection::EEndType stringToEnum(const std::string & s);
189}
Base class for 1D component junctions and boundaries.
std::vector< Real > _normals
Outward normals associated with connected components.
std::vector< RealVectorValue > _directions
Directions of connected components.
std::vector< BoundaryName > _boundary_names
Boundary names of connected components.
virtual void init() override
Initializes the component.
const std::vector< BoundaryName > & getBoundaryNames() const
Gets the boundary names for this component.
static const std::map< std::string, EEndType > _end_type_to_enum
Map of end type string to enum.
virtual void setupMesh() override
Performs mesh setup such as creating mesh or naming mesh sets.
static InputParameters validParams()
std::vector< Point > _positions
Physical positions of connected components.
virtual void check() const override
Check the component integrity.
virtual const std::vector< dof_id_type > & getNodeIDs() const
Gets the list of boundary nodes connected to this component.
void checkNumberOfConnections(const unsigned int &n_connections) const
Checks that the number of connections is equal to the supplied value.
void addConnection(const BoundaryName &boundary_name)
Adds a connection for this component.
void checkSizeEqualsNumberOfConnections(const std::string &param) const
Checks that the size of a vector parameter equals the number of connections.
std::vector< const Elem * > _elems
Boundary elements of connected components.
std::vector< unsigned int > _boundary_ids
Boundary IDs of connected components.
const std::vector< Connection > & getConnections() const
Returns the vector of connections of this component.
void checkAllConnectionsHaveSame(const std::vector< T > &objects, const std::string &description) const
Checks that all connections have the same of a certain type of object.
const std::vector< SubdomainName > & getConnectedSubdomainNames() const
Gets the vector of connected subdomain names.
std::vector< std::string > _connected_component_names
Vector of connected component names.
std::vector< dof_id_type > _nodes
Boundary node IDs from connected components.
std::vector< unsigned short int > _sides
Boundary sides of connected components.
std::vector< Connection > _connections
Vector of connections of this component.
std::vector< SubdomainName > _connected_subdomain_names
Vector of subdomain names of the connected components.
const std::vector< std::string > & getConnectedComponentNames() const
Returns a list of names of components that are connected to this component.
Base class for THM components.
Definition Component.h:32
void logError(Args &&... args) const
Logs an error.
Definition Component.h:226
Component1DConnection::EEndType stringToEnum(const std::string &s)
Structure for holding data for a connection.
const BoundaryName _boundary_name
The name of the boundary this connection is attached to.
const EEndType _end_type
End type for the connection.
Connection(const BoundaryName &boundary_name, const std::string &component_name, const EEndType &end_type)
const std::string _component_name
Name of the component in the connection.