https://mooseframework.inl.gov
Loading...
Searching...
No Matches
GatherRCDataFaceThread.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 "ComputeFVFluxThread.h"
14#include "INSFVAttributes.h"
15#include "TheWarehouse.h"
16
22template <typename RangeType>
24{
25public:
27 using Parent::join;
28
30 const unsigned int nl_sys_number,
31 const std::vector<unsigned int> & vars,
32 bool on_displaced);
33
34 // Splitting Constructor
35 GatherRCDataFaceThread(GatherRCDataFaceThread & x, Threads::split split);
36
37 void onFace(const FaceInfo & fi) override final;
38 void onBoundary(const FaceInfo & fi, BoundaryID boundary) override final;
39 void subdomainChanged() override final;
40 void neighborSubdomainChanged() override final;
41
42private:
47 void finalizeContainers();
48
55 template <typename... Attribs>
56 void getVarROs(std::vector<INSFVMomentumResidualObject *> & ros,
57 TheWarehouse::QueryCache<Attribs...> & queries);
58
60 const std::vector<unsigned int> & _vars;
61
64
68
72};
73
74template <typename RangeType>
76 const unsigned int nl_sys_number,
77 const std::vector<unsigned int> & vars,
78 bool on_displaced)
79 : ThreadedFaceLoop<RangeType>(fe_problem, nl_sys_number, {}, on_displaced), _vars(vars)
80{
81}
82
83template <typename RangeType>
89
90template <typename RangeType>
91template <typename... Attribs>
92void
93GatherRCDataFaceThread<RangeType>::getVarROs(std::vector<INSFVMomentumResidualObject *> & ros,
95{
96 for (const auto var_num : _vars)
97 {
98 // We don't want to do cascading var num attributes or else the second time around we won't get
99 // any results out of the query (e.g. an object cannot have a variable that simultaneously has
100 // both var number 0 and 1)
101 auto copied_queries = queries;
102 std::vector<INSFVMomentumResidualObject *> var_ros;
103 copied_queries.template condition<AttribVar>(static_cast<int>(var_num)).queryInto(var_ros);
104 for (auto * const var_ro : var_ros)
105 ros.push_back(var_ro);
106 }
107}
108
109template <typename RangeType>
110void
112{
113 for (auto * const k : _fv_flux_kernels)
114 k->gatherRCData(fi);
115}
116
117template <typename RangeType>
118void
120{
121 {
122 std::vector<INSFVMomentumResidualObject *> bcs;
123 // cannot bind to lvalue reference otherwise the temporary is destroyed and we are left with a
124 // dangling reference
125 auto queries = this->_fe_problem.theWarehouse()
126 .query()
127 .template condition<AttribSystem>("FVFluxBC")
128 .template condition<AttribSysNum>(this->_nl_system_num)
129 .template condition<AttribDisplaced>(this->_on_displaced)
130 .template condition<AttribThread>(this->_tid)
131 .template condition<AttribBoundaries>(bnd_id);
132 getVarROs(bcs, queries);
133
134 for (auto * const bc : bcs)
135 bc->gatherRCData(fi);
136 }
137
138 {
139 std::vector<INSFVMomentumResidualObject *> iks;
140 // cannot bind to lvalue reference otherwise the temporary is destroyed and we are left with a
141 // dangling reference
142 auto queries = this->_fe_problem.theWarehouse()
143 .query()
144 .template condition<AttribSystem>("FVInterfaceKernel")
145 .template condition<AttribSysNum>(this->_nl_system_num)
146 .template condition<AttribDisplaced>(this->_on_displaced)
147 .template condition<AttribThread>(this->_tid)
148 .template condition<AttribBoundaries>(bnd_id);
149 getVarROs(iks, queries);
150
151 for (auto * const ik : iks)
152 ik->gatherRCData(fi);
153 }
154}
155
156template <typename RangeType>
157void
159{
161
162 // Clear kernels
163 _fv_flux_kernels.clear();
164 _elem_sub_fv_flux_kernels.clear();
165
166 std::vector<INSFVMomentumResidualObject *> kernels;
167 // cannot bind to lvalue reference otherwise the temporary is destroyed and we are left with a
168 // dangling reference
169 auto queries = this->_fe_problem.theWarehouse()
170 .query()
171 .template condition<AttribSysNum>(this->_nl_system_num)
172 .template condition<AttribSystem>("FVFluxKernel")
173 .template condition<AttribDisplaced>(this->_on_displaced)
174 .template condition<AttribSubdomains>(this->_subdomain)
175 .template condition<AttribThread>(this->_tid);
176 getVarROs(kernels, queries);
177
178 _elem_sub_fv_flux_kernels =
179 std::set<INSFVMomentumResidualObject *>(kernels.begin(), kernels.end());
180
181 finalizeContainers();
182}
183
184template <typename RangeType>
185void
187{
189
190 // Clear kernels
191 _fv_flux_kernels.clear();
192 _neigh_sub_fv_flux_kernels.clear();
193
194 std::vector<INSFVMomentumResidualObject *> kernels;
195 // cannot bind to lvalue reference otherwise the temporary is destroyed and we are left with a
196 // dangling reference
197 auto queries = this->_fe_problem.theWarehouse()
198 .query()
199 .template condition<AttribSysNum>(this->_nl_system_num)
200 .template condition<AttribSystem>("FVFluxKernel")
201 .template condition<AttribDisplaced>(this->_on_displaced)
202 .template condition<AttribSubdomains>(this->_neighbor_subdomain)
203 .template condition<AttribThread>(this->_tid);
204 getVarROs(kernels, queries);
205
206 _neigh_sub_fv_flux_kernels =
207 std::set<INSFVMomentumResidualObject *>(kernels.begin(), kernels.end());
208
209 finalizeContainers();
210}
211
212template <typename RangeType>
213void
215{
216 const bool same_kernels = _elem_sub_fv_flux_kernels == _neigh_sub_fv_flux_kernels;
217 if (same_kernels)
218 _fv_flux_kernels = _elem_sub_fv_flux_kernels;
219 else
220 std::set_union(_elem_sub_fv_flux_kernels.begin(),
221 _elem_sub_fv_flux_kernels.end(),
222 _neigh_sub_fv_flux_kernels.begin(),
223 _neigh_sub_fv_flux_kernels.end(),
224 std::inserter(_fv_flux_kernels, _fv_flux_kernels.begin()));
225}
boundary_id_type BoundaryID
const std::vector< double > x
A class that gathers 'a' coefficient data from flux kernels, boundary conditions, and interface kerne...
void subdomainChanged() override final
std::set< INSFVMomentumResidualObject * > _neigh_sub_fv_flux_kernels
The subset of flux kernels that contribute to the momentum equation residual from the neighbor side o...
GatherRCDataFaceThread(FEProblemBase &fe_problem, const unsigned int nl_sys_number, const std::vector< unsigned int > &vars, bool on_displaced)
void getVarROs(std::vector< INSFVMomentumResidualObject * > &ros, TheWarehouse::QueryCache< Attribs... > &queries)
This determines all the momentum residual objects for all the variables.
std::set< INSFVMomentumResidualObject * > _elem_sub_fv_flux_kernels
The subset of flux kernels that contribute to the momentum equation residual from the element side of...
void neighborSubdomainChanged() override final
const std::vector< unsigned int > & _vars
The velocity variable numbers.
void onBoundary(const FaceInfo &fi, BoundaryID boundary) override final
void onFace(const FaceInfo &fi) override final
std::set< INSFVMomentumResidualObject * > _fv_flux_kernels
The collection of flux kernels that contribute to the momentum equation residuals.
void finalizeContainers()
Called at the end of either subdomainChanged or neighborSubdomainChanged, this method computes the fi...
All objects that contribute to pressure-based (e.g.
std::vector< T * > & queryInto(std::vector< T * > &results, Args &&... args)
virtual void subdomainChanged()
void join(const ThreadedFaceLoop &y)
virtual void neighborSubdomainChanged()