https://mooseframework.inl.gov
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 {
19 public:
20  Component1DConnection(const InputParameters & params);
21 
23  enum EEndType
24  {
25  IN,
26  OUT
27  };
29  static const std::map<std::string, EEndType> _end_type_to_enum;
30 
32  struct Connection
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 
90 protected:
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 
156 public:
157  static InputParameters validParams();
158 };
159 
160 template <typename T>
161 void
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 
175 template <typename T>
176 void
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 
185 namespace THM
186 {
187 template <>
188 Component1DConnection::EEndType stringToEnum(const std::string & s);
189 }
virtual void init() override
Initializes the component.
const std::string _component_name
Name of the component in the connection.
static InputParameters validParams()
virtual const std::vector< dof_id_type > & getNodeIDs() const
Gets the list of boundary nodes connected to this component.
Component1DConnection::EEndType stringToEnum(const std::string &s)
std::vector< unsigned short int > _sides
Boundary sides of connected components.
Base class for 1D component junctions and boundaries.
std::vector< SubdomainName > _connected_subdomain_names
Vector of subdomain names of the connected components.
const std::vector< BoundaryName > & getBoundaryNames() const
Gets the boundary names for this component.
Structure for holding data for a connection.
std::vector< Connection > _connections
Vector of connections of this component.
const std::vector< SubdomainName > & getConnectedSubdomainNames() const
Gets the vector of connected subdomain names.
std::vector< BoundaryName > _boundary_names
Boundary names of connected components.
void addConnection(const BoundaryName &boundary_name)
Adds a connection for this component.
std::vector< dof_id_type > _nodes
Boundary node IDs from connected components.
void logError(Args &&... args) const
Logs an error.
Definition: Component.h:215
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.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
std::vector< std::string > _connected_component_names
Vector of connected component names.
std::vector< unsigned int > _boundary_ids
Boundary IDs of connected components.
std::vector< Point > _positions
Physical positions of connected components.
void checkNumberOfConnections(const unsigned int &n_connections) const
Checks that the number of connections is equal to the supplied value.
Connection(const BoundaryName &boundary_name, const std::string &component_name, const EEndType &end_type)
const std::vector< std::string > & getConnectedComponentNames() const
Returns a list of names of components that are connected to this component.
void checkSizeEqualsNumberOfConnections(const std::string &param) const
Checks that the size of a vector parameter equals the number of connections.
Base class for THM components.
Definition: Component.h:27
Component1DConnection(const InputParameters &params)
std::vector< const Elem * > _elems
Boundary elements of connected components.
const EEndType _end_type
End type for the connection.
virtual void check() const override
Check the component integrity.
const std::vector< Connection > & getConnections() const
Returns the vector of connections of this component.
virtual void setupMesh() override
Performs mesh setup such as creating mesh or naming mesh sets.
std::vector< Real > _normals
Outward normals associated with connected components.
std::vector< RealVectorValue > _directions
Directions of connected components.
static const std::map< std::string, EEndType > _end_type_to_enum
Map of end type string to enum.
const BoundaryName _boundary_name
The name of the boundary this connection is attached to.