https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Component1DJunction.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
10#include "Component1DJunction.h"
11#include "Component1D.h"
12#include "THMMesh.h"
13
16{
18 params.addPrivateParam<std::string>("component_type", "junction");
19 params.addRequiredParam<std::vector<BoundaryName>>("connections", "Junction connections");
20 return params;
21}
22
24 : Component1DConnection(params)
25{
26 const std::vector<BoundaryName> & connections =
27 getParam<std::vector<BoundaryName>>("connections");
28 for (const auto & connection_string : connections)
29 addConnection(connection_string);
30}
31
32void
34{
36
37 const BoundaryID boundary_id = mesh().getNextBoundaryId();
38
39 auto & boundary_info = mesh().getMesh().get_boundary_info();
40
41 for (const auto & connection : getConnections())
42 {
43 const std::string & comp_name = connection._component_name;
44
45 if (hasComponentByName<Component1D>(comp_name))
46 {
47 const Component1D & comp = getComponentByName<Component1D>(comp_name);
48 for (auto && conn : comp.getConnections(connection._end_type))
49 // add connection's side to sideset of all sides connected to this zero-D component
50 boundary_info.add_side(conn._elem, conn._side, boundary_id);
51 }
52 }
53
54 // name the sideset corresponding to the sides of all connected component ends
55 boundary_info.sideset_name(boundary_id) = name();
56
57 const auto & node_to_elem = mesh().nodeToElemMap();
58 for (auto & nid : _nodes)
59 {
60 const auto & it = node_to_elem.find(nid);
61 if (it == node_to_elem.end())
62 mooseError(name(), ": failed to find node ", nid, "in the mesh!");
63
64 const std::vector<dof_id_type> & elems = it->second;
65 for (const auto & e : elems)
66 _connected_elems.push_back(e);
67 }
68}
69
70void
72{
74
75 for (auto & eid : _connected_elems)
76 {
77 const Elem * elem = constMesh().queryElemPtr(eid);
78 if (elem != nullptr && elem->processor_id() == processor_id())
79 _proc_ids.push_back(elem->processor_id());
80 else
81 _proc_ids.push_back(0);
82 }
84}
85
86void
88{
90
91 if (_connections.size() == 0)
92 logError("There must be at least one connection.");
93}
boundary_id_type BoundaryID
const std::string name
Definition Setup.h:21
Base class for 1D component junctions and boundaries.
virtual void setupMesh() override
Performs mesh setup such as creating mesh or naming mesh sets.
static InputParameters validParams()
virtual void check() const override
Check the component integrity.
void addConnection(const BoundaryName &boundary_name)
Adds a connection for this component.
const std::vector< Connection > & getConnections() const
Returns the vector of connections of this component.
std::vector< dof_id_type > _nodes
Boundary node IDs from connected components.
std::vector< Connection > _connections
Vector of connections of this component.
std::vector< dof_id_type > _connected_elems
Element IDs of connected 1D components.
std::vector< processor_id_type > _proc_ids
Processor IDs of connected 1D components.
virtual void initSecondary() override
Perform secondary initialization, which relies on init() being called for all components.
virtual void check() const override
Check the component integrity.
Component1DJunction(const InputParameters &params)
static InputParameters validParams()
virtual void setupMesh() override
Performs mesh setup such as creating mesh or naming mesh sets.
Base class for 1D components.
Definition Component1D.h:19
virtual const std::vector< Connection > & getConnections(Component1DConnection::EEndType end_type) const
Gets the vector of connections of an end type for this component.
const THMMesh & constMesh() const
Const reference to mesh, which can be called at any point.
Definition Component.h:63
void logError(Args &&... args) const
Logs an error.
Definition Component.h:226
virtual void initSecondary()
Perform secondary initialization, which relies on init() being called for all components.
Definition Component.h:411
THMMesh & mesh()
Non-const reference to THM mesh, which can only be called before the end of mesh setup.
Definition Component.C:60
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addPrivateParam(const std::string &name, const T &value)
void mooseError(Args &&... args) const
MeshBase & getMesh()
const std::unordered_map< dof_id_type, std::vector< dof_id_type > > & nodeToElemMap()
virtual Elem * queryElemPtr(const dof_id_type i)
virtual BoundaryID getNextBoundaryId()
Gets the next nodeset or sideset ID.
Definition THMMesh.C:209
processor_id_type processor_id() const
const Parallel::Communicator & comm() const