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 "AuxKernelBase.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), _query(query)
29{
30}
31
32// Splitting Constructor
38
39void
41{
43 const auto tid = puid.id;
44
45 for (const auto & belem : range)
46 {
47 const Elem * elem = belem->_elem;
48 const auto boundary_id = belem->_bnd_id;
49 const auto side = belem->_side;
50
51 // We can distribute work just as the actual execution code will
52 if (elem->processor_id() != _fe_problem.processor_id())
53 return;
54
55 auto & mesh = _fe_problem.mesh();
56
57 const auto & bnd_name = mesh.getBoundaryName(boundary_id);
58
59 // uo check
60 std::vector<SideUserObject *> objs;
63 .condition<AttribInterfaces>(Interfaces::SideUserObject)
64 .condition<AttribBoundaries>(boundary_id, true)
65 .queryInto(objs);
66 for (const auto & uo : objs)
67 if (uo->checkVariableBoundaryIntegrity())
68 {
69 auto leftover_vars = uo->checkAllVariables(*elem);
70 if (!leftover_vars.empty())
71 {
72 const auto neighbor = elem->neighbor_ptr(side);
73 const bool upwind_elem = !neighbor || elem->id() < neighbor->id();
74 const Elem * lower_d_elem =
75 upwind_elem ? mesh.getLowerDElem(elem, side)
76 : mesh.getLowerDElem(neighbor, neighbor->which_neighbor_am_i(elem));
77 if (lower_d_elem)
78 leftover_vars = uo->checkVariables(*lower_d_elem, leftover_vars);
79 }
80 boundaryIntegrityCheckError(*uo, leftover_vars, bnd_name);
81 }
82
83 auto check = [elem, &bnd_name, &mesh, side](const auto & bnd_objects)
84 {
85 for (const auto & bnd_object : bnd_objects)
86 // Skip if this object uses geometric search because coupled variables may be defined on
87 // paired boundaries instead of the boundary this elem is on
88 if (!bnd_object->requiresGeometricSearch() && bnd_object->checkVariableBoundaryIntegrity())
89 {
90 // First check the higher-dimensional element
91 auto leftover_vars = bnd_object->checkAllVariables(*elem);
92 if (!leftover_vars.empty())
93 {
94 const auto neighbor = elem->neighbor_ptr(side);
95 const bool upwind_elem = !neighbor || elem->id() < neighbor->id();
96 const Elem * lower_d_elem =
97 upwind_elem ? mesh.getLowerDElem(elem, side)
98 : mesh.getLowerDElem(neighbor, neighbor->which_neighbor_am_i(elem));
99 if (lower_d_elem)
100 leftover_vars = bnd_object->checkVariables(*lower_d_elem, leftover_vars);
101 }
102
103 boundaryIntegrityCheckError(*bnd_object, leftover_vars, bnd_name);
104 }
105 };
106
107 // Mortar AuxKernels are excluded here: their boundaryIDs() report the primary/secondary
108 // boundaries they couple across, but their coupled variables are only required to be
109 // defined on the mortar segment mesh, not on every element of those boundaries.
110 std::vector<AuxKernelBase *> auxkernels;
112 .query()
113 .condition<AttribSystem>("AuxKernel")
114 .condition<AttribThread>(tid)
116 .condition<AttribBoundaries>(boundary_id, true)
117 .queryInto(auxkernels);
118 check(auxkernels);
119
120 for (const auto i : make_range(_fe_problem.numNonlinearSystems()))
121 {
122 const auto & warehouse = _fe_problem.getNonlinearSystemBase(i).getIntegratedBCWarehouse();
123 if (warehouse.hasBoundaryObjects(boundary_id, tid))
124 check(warehouse.getBoundaryObjects(boundary_id, tid));
125 }
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}
@ Nodal
Execution categories.
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
Tracks the AuxKernelType of an AuxKernel: its value type (Real/Vector/Array) and its execution catego...
Definition Attributes.h:336
AttribBoundaries tracks all boundary IDs associated with an object.
Definition Attributes.h:223
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)
void join(const BoundaryElemIntegrityCheckThread &)
BoundaryElemIntegrityCheckThread(FEProblemBase &fe_problem, const TheWarehouse::Query &query)
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual std::size_t numNonlinearSystems() const override
virtual MooseMesh & mesh() override
TheWarehouse & theWarehouse() const
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.
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse.
processor_id_type processor_id() const
query_obj query
MeshBase & mesh