https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ComputeLinearFVFaceThread.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
11#include "LinearSystem.h"
12#include "LinearFVKernel.h"
13#include "LinearFVFluxKernel.h"
14#include "FEProblemBase.h"
15
17 const unsigned int system_num,
19 const std::set<TagID> & vector_tags,
20 const std::set<TagID> & matrix_tags)
21 : _fe_problem(fe_problem),
22 _system_number(system_num),
23 _mode(mode),
24 _vector_tags(vector_tags),
25 _matrix_tags(matrix_tags),
26 _system_contrib_objects_ready(false)
27{
28}
29
30// Splitting Constructor
32 Threads::split /*split*/)
33 : _fe_problem(x._fe_problem),
34 _system_number(x._system_number),
35 _mode(x._mode),
36 _vector_tags(x._vector_tags),
37 _matrix_tags(x._matrix_tags),
38 _system_contrib_objects_ready(x._system_contrib_objects_ready)
39{
40}
41
42void
44{
46 _tid = puid.id;
47
50
53
54 // Iterate over all the elements in the range
55 for (const auto & face_info : range)
56 {
57 _subdomain = face_info->elem().subdomain_id();
59 face_info->neighborPtr() ? face_info->neighbor().subdomain_id() : _subdomain;
61 {
64 }
65
66 const Real face_area = face_info->faceArea() * face_info->faceCoord();
67
68 // Time to execute the kernels that contribute to the matrix and
69 // right hand side
70 for (auto & kernel : _fv_flux_kernels)
71 {
72 kernel->setupFaceData(face_info);
73 kernel->setCurrentFaceArea(face_area);
74 kernel->addMatrixContribution();
75 kernel->addRightHandSideContribution();
76 }
77 }
78}
79
80void
84
85void
87{
88 // The reason why we need to grab vectors and matrices separately is that
89 // we want to grab a union instead of an intersection.
90 std::vector<LinearFVFluxKernel *> kernels_after_vectors;
92 .query()
93 .template condition<AttribSysNum>(_system_number)
94 .template condition<AttribSystem>("LinearFVFluxKernel")
95 .template condition<AttribKokkos>(false)
96 .template condition<AttribThread>(_tid)
97 .template condition<AttribVectorTags>(_vector_tags)
98 .queryInto(kernels_after_vectors);
99
100 std::vector<LinearFVFluxKernel *> kernels_after_matrices;
102 .query()
103 .template condition<AttribSysNum>(_system_number)
104 .template condition<AttribSystem>("LinearFVFluxKernel")
105 .template condition<AttribKokkos>(false)
106 .template condition<AttribThread>(_tid)
107 .template condition<AttribMatrixTags>(_matrix_tags)
108 .queryInto(kernels_after_matrices);
109
110 // We fetch the union of the available objects
111 std::vector<LinearFVFluxKernel *> kernels;
112 MooseUtils::getUnion(kernels_after_vectors, kernels_after_matrices, kernels);
113
114 // As a last step, we make sure the kernels know which vectors/matrices they need to contribute to
115 for (auto & kernel : kernels)
116 kernel->linkTaggedVectorsAndMatrices(_vector_tags, _matrix_tags);
117
119}
120
121void
123{
125 "The system contribution objects need to be set up before we fetch the "
126 "block-restricted objects!");
127
128 _fv_flux_kernels.clear();
129
131 {
132 // We just filter based on subdomain ID on top of everything else
133 std::vector<LinearFVFluxKernel *> kernels_after_vector;
135 .query()
136 .template condition<AttribSysNum>(_system_number)
137 .template condition<AttribSystem>("LinearFVFluxKernel")
138 .template condition<AttribKokkos>(false)
139 .template condition<AttribThread>(_tid)
140 .template condition<AttribVectorTags>(_vector_tags)
141 .template condition<AttribSubdomains>(_subdomain)
142 .queryInto(kernels_after_vector);
143 std::vector<LinearFVFluxKernel *> kernels_after_matrix;
145 .query()
146 .template condition<AttribSysNum>(_system_number)
147 .template condition<AttribSystem>("LinearFVFluxKernel")
148 .template condition<AttribKokkos>(false)
149 .template condition<AttribThread>(_tid)
150 .template condition<AttribMatrixTags>(_matrix_tags)
151 .template condition<AttribSubdomains>(_subdomain)
152 .queryInto(kernels_after_matrix);
153
154 // We populate the list of kernels with the union of the two vectors
155 MooseUtils::getUnion(kernels_after_vector, kernels_after_matrix, _fv_flux_kernels_elem);
157 }
159
161 {
162 // Here we just filter based on subdomain ID on top of everything else
163 std::vector<LinearFVFluxKernel *> kernels_after_vector;
165 .query()
166 .template condition<AttribSysNum>(_system_number)
167 .template condition<AttribSystem>("LinearFVFluxKernel")
168 .template condition<AttribKokkos>(false)
169 .template condition<AttribThread>(_tid)
170 .template condition<AttribVectorTags>(_vector_tags)
171 .template condition<AttribSubdomains>(_neighbor_subdomain)
172 .queryInto(kernels_after_vector);
173 std::vector<LinearFVFluxKernel *> kernels_after_matrix;
175 .query()
176 .template condition<AttribSysNum>(_system_number)
177 .template condition<AttribSystem>("LinearFVFluxKernel")
178 .template condition<AttribKokkos>(false)
179 .template condition<AttribThread>(_tid)
180 .template condition<AttribMatrixTags>(_matrix_tags)
181 .template condition<AttribSubdomains>(_neighbor_subdomain)
182 .queryInto(kernels_after_matrix);
183
184 // We populate the list of kernels with the union of the two vectors
185 MooseUtils::getUnion(kernels_after_vector, kernels_after_matrix, _fv_flux_kernels_neighbor);
187 }
189}
190
191void
193{
195 return;
196 auto & console = _fe_problem.console();
197 auto execute_on = _fe_problem.getCurrentExecuteOnFlag();
198 console << "[DBG] Beginning linear finite volume flux objects loop on " << execute_on
199 << std::endl;
200 mooseDoOnce(console << "[DBG] Loop on faces (FaceInfo), objects ordered on each face: "
201 << std::endl;
202 console << "[DBG] - linear finite volume flux kernels" << std::endl);
203}
204
205void
207{
209 return;
210
211 // Print the location of the execution
212 auto & console = _fe_problem.console();
213 console << "[DBG] Linear flux kernels on block "
216 console << " and neighbor " << _fe_problem.mesh().getSubdomainName(_neighbor_subdomain)
217 << std::endl;
218 else
219 console << " with no neighbor block" << std::endl;
220
221 // Print the list of objects
222 std::vector<MooseObject *> kernels_to_print;
223 for (const auto & kernel : _fv_flux_kernels)
224 kernels_to_print.push_back(dynamic_cast<MooseObject *>(kernel));
226 "[DBG]")
227 << std::endl;
228}
Adds contributions from face terms discretized using the finite volume method to the matrix and right...
const std::set< TagID > & _vector_tags
The vector tags this thread contributes to.
void join(const ComputeLinearFVFaceThread &)
Join threads at the end of the execution.
SubdomainID _neighbor_subdomain
The subdomain for the current neighbor.
SubdomainID _old_neighbor_subdomain
The subdomain for the last neighbor.
void operator()(const FaceInfoRange &range)
Operator which is used to execute the thread over a certain iterator range.
std::set< LinearFVFluxKernel * > _fv_flux_kernels
Combined LinearFVFluxKernels which will be used to contribute to a system.
const std::set< TagID > & _matrix_tags
The matrix tags this thread contributes to.
FEProblemBase & _fe_problem
Reference to the problem.
void printBlockExecutionInformation() const
Print ordering of objects executed on each block.
StoredRange< MooseMesh::const_face_info_iterator, const FaceInfo * > FaceInfoRange
std::vector< LinearFVFluxKernel * > _fv_flux_kernels_elem
Kernels which will only contribute to a matrix from the element-side of the face.
SubdomainID _subdomain
The subdomain for the current element.
std::vector< LinearFVFluxKernel * > _fv_flux_kernels_neighbor
Kernels which will only contribute to a matrix from the neighbor-side of the face.
void fetchBlockSystemContributionObjects()
Fetch LinearFVFluxKernels for a given block.
void setupSystemContributionObjects()
Setup the contribution objects before we start the loop.
SubdomainID _old_subdomain
The subdomain for the last element.
const unsigned int _system_number
The number of the linear system we are contributing to.
ComputeLinearFVFaceThread(FEProblemBase &fe_problem, const unsigned int linear_system_num, const Moose::FV::LinearFVComputationMode mode, const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
Class constructor.
bool _system_contrib_objects_ready
Boolean that is used to check if the kernels are ready to start contributing to the system.
void printGeneralExecutionInformation() const
Print list of executed object types together with the execution order.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
virtual MooseMesh & mesh() override
bool shouldPrintExecution(const THREAD_ID tid) const
Check whether the problem should output execution orders at this time.
TheWarehouse & theWarehouse() const
const std::string & getSubdomainName(SubdomainID subdomain_id) const
Return the name of a block given an id.
Definition MooseMesh.C:1751
Every object that can be built by the factory should be derived from this class.
Definition MooseObject.h:31
const ConsoleStream & console() const
Return console handle.
Definition Problem.h:48
std::vector< T * > & queryInto(std::vector< T * > &results, Args &&... args)
queryInto executes the query and stores the results in the given vector.
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse.
std::string formatString(std::string message, const std::string &prefix)
Add new lines and prefixes to a string for pretty display in output NOTE: This makes a copy of the st...
std::string mooseObjectVectorToString(const std::vector< MooseObject * > &objs, const std::string &sep=" ")
Routine to output the name of MooseObjects in a string.
LinearFVComputationMode
Definition MathFVUtils.h:58
const SubdomainID INVALID_BLOCK_ID
Definition MooseTypes.C:20