https://mooseframework.inl.gov
Loading...
Searching...
No Matches
BoundaryElemIntegrityCheckThread.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// MOOSE includes
12#include "AuxiliarySystem.h"
13#include "NonlinearSystemBase.h"
14#include "FEProblemBase.h"
15#include "SideUserObject.h"
16#include "MooseMesh.h"
17#include "IntegratedBCBase.h"
19
20#include "libmesh/threads.h"
21#include "libmesh/elem.h"
22#include "libmesh/mesh_base.h"
23
24#include <vector>
25
27 FEProblemBase & fe_problem, const TheWarehouse::Query & query)
28 : _fe_problem(fe_problem),
29 _aux_sys(fe_problem.getAuxiliarySystem()),
30 _elem_aux(_aux_sys.elemAuxWarehouse()),
31 _elem_vec_aux(_aux_sys.elemVectorAuxWarehouse()),
32 _elem_array_aux(_aux_sys.elemArrayAuxWarehouse()),
33 _query(query)
34{
35}
36
37// Splitting Constructor
40 : _fe_problem(x._fe_problem),
41 _aux_sys(x._aux_sys),
42 _elem_aux(x._elem_aux),
43 _elem_vec_aux(x._elem_vec_aux),
44 _elem_array_aux(x._elem_array_aux),
45 _query(x._query)
46{
47}
48
49void
51{
53 const auto tid = puid.id;
54
55 for (const auto & belem : range)
56 {
57 const Elem * elem = belem->_elem;
58 const auto boundary_id = belem->_bnd_id;
59 const auto side = belem->_side;
60
61 // We can distribute work just as the actual execution code will
62 if (elem->processor_id() != _fe_problem.processor_id())
63 return;
64
65 auto & mesh = _fe_problem.mesh();
66
67 const auto & bnd_name = mesh.getBoundaryName(boundary_id);
68
69 // uo check
70 std::vector<SideUserObject *> objs;
73 .condition<AttribInterfaces>(Interfaces::SideUserObject)
74 .condition<AttribBoundaries>(boundary_id, true)
75 .queryInto(objs);
76 for (const auto & uo : objs)
77 if (uo->checkVariableBoundaryIntegrity())
78 {
79 auto leftover_vars = uo->checkAllVariables(*elem);
80 if (!leftover_vars.empty())
81 {
82 const auto neighbor = elem->neighbor_ptr(side);
83 const bool upwind_elem = !neighbor || elem->id() < neighbor->id();
84 const Elem * lower_d_elem =
85 upwind_elem ? mesh.getLowerDElem(elem, side)
86 : mesh.getLowerDElem(neighbor, neighbor->which_neighbor_am_i(elem));
87 if (lower_d_elem)
88 leftover_vars = uo->checkVariables(*lower_d_elem, leftover_vars);
89 }
90 boundaryIntegrityCheckError(*uo, leftover_vars, bnd_name);
91 }
92
93 auto check = [elem, boundary_id, &bnd_name, tid, &mesh, side](const auto & warehouse)
94 {
95 if (!warehouse.hasBoundaryObjects(boundary_id, tid))
96 return;
97
98 const auto & bnd_objects = warehouse.getBoundaryObjects(boundary_id, tid);
99 for (const auto & bnd_object : bnd_objects)
100 // Skip if this object uses geometric search because coupled variables may be defined on
101 // paired boundaries instead of the boundary this elem is on
102 if (!bnd_object->requiresGeometricSearch() && bnd_object->checkVariableBoundaryIntegrity())
103 {
104 // First check the higher-dimensional element
105 auto leftover_vars = bnd_object->checkAllVariables(*elem);
106 if (!leftover_vars.empty())
107 {
108 const auto neighbor = elem->neighbor_ptr(side);
109 const bool upwind_elem = !neighbor || elem->id() < neighbor->id();
110 const Elem * lower_d_elem =
111 upwind_elem ? mesh.getLowerDElem(elem, side)
112 : mesh.getLowerDElem(neighbor, neighbor->which_neighbor_am_i(elem));
113 if (lower_d_elem)
114 leftover_vars = bnd_object->checkVariables(*lower_d_elem, leftover_vars);
115 }
116
117 boundaryIntegrityCheckError(*bnd_object, leftover_vars, bnd_name);
118 }
119 };
120
121 check(_elem_aux);
122 check(_elem_vec_aux);
123 check(_elem_array_aux);
124 for (const auto i : make_range(_fe_problem.numNonlinearSystems()))
126 }
127}
128
129void
133
134void
136 const std::set<MooseVariableFieldBase *> & variables,
137 const BoundaryName & boundary_name)
138{
139 if (variables.empty())
140 return;
141
142 std::vector<std::string> names;
143 names.reserve(variables.size());
144 for (const auto * const var : variables)
145 names.push_back(var->name());
146
147 mooseError("'",
148 object.name(),
149 "' of type '",
150 object.type(),
151 "' depends on variable(s) '",
152 MooseUtils::join(names, ","),
153 "'. However, that variable does not appear to be defined on (all of) boundary '",
154 boundary_name,
155 "'.");
156}
void boundaryIntegrityCheckError(const MooseObject &object, const std::set< MooseVariableFieldBase * > &variables, const BoundaryName &boundary_name)
Compose boundary restricted error message for the provided object, variables, and boundary_name if th...
void boundaryIntegrityCheckError(const MooseObject &object, const std::set< MooseVariableFieldBase * > &variables, const BoundaryName &boundary_name)
Compose boundary restricted error message for the provided object, variables, and boundary_name if th...
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
AttribBoundaries tracks all boundary IDs associated with an object.
Definition Attributes.h:190
const TheWarehouse::Query & _query
A warehouse query that we will use to obtain user objects for boundary variable dependency integrity ...
FEProblemBase & _fe_problem
the finite element (or volume) problem
void operator()(const ConstBndElemRange &range)
const ExecuteMooseObjectWarehouse< AuxKernel > & _elem_aux
Elemental auxiliary kernels acting on standard field variables.
const ExecuteMooseObjectWarehouse< ArrayAuxKernel > & _elem_array_aux
Elemental auxiliary kernels acting on array field variables.
void join(const BoundaryElemIntegrityCheckThread &)
BoundaryElemIntegrityCheckThread(FEProblemBase &fe_problem, const TheWarehouse::Query &query)
const ExecuteMooseObjectWarehouse< VectorAuxKernel > & _elem_vec_aux
Elemental auxiliary kernels acting on vector field variables.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual std::size_t numNonlinearSystems() const override
virtual MooseMesh & mesh() override
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
Every object that can be built by the factory should be derived from this class.
Definition MooseObject.h:31
MooseObjectTagWarehouse< IntegratedBCBase > & getIntegratedBCWarehouse()
QueryCache is a convenient way to construct and pass around (possible partially constructed) warehous...
QueryCache & condition(Args &&... args)
Adds a new condition to the query.
QueryCache clone() const
clone creates and returns an independent copy of the query in its current state.
processor_id_type processor_id() const
query_obj query
MeshBase & mesh