https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ComputeLinearFVElementalThread.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"
14#include "FEProblemBase.h"
15
17 const unsigned int system_num,
18 const std::set<TagID> & vector_tags,
19 const std::set<TagID> & matrix_tags)
20 : _fe_problem(fe_problem),
21 _system_number(system_num),
22 _vector_tags(vector_tags),
23 _matrix_tags(matrix_tags),
24 _subdomain(Moose::INVALID_BLOCK_ID),
25 _old_subdomain(Moose::INVALID_BLOCK_ID),
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 _vector_tags(x._vector_tags),
36 _matrix_tags(x._matrix_tags),
37 _subdomain(x._subdomain),
38 _old_subdomain(x._old_subdomain),
39 _system_contrib_objects_ready(x._system_contrib_objects_ready)
40{
41}
42
43void
45{
47 _tid = puid.id;
48
50
53
54 // Iterate over all the elements in the range
55 for (const auto & elem_info : range)
56 {
57 _subdomain = elem_info->subdomain_id();
59 {
62 }
63
64 const Real elem_volume = elem_info->volume() * elem_info->coordFactor();
65
66 // Time to add the contributions from the kernels
67 for (auto kernel : _fv_kernels)
68 {
69 kernel->setCurrentElemInfo(elem_info);
70 kernel->setCurrentElemVolume(elem_volume);
71 kernel->addMatrixContribution();
72 kernel->addRightHandSideContribution();
73 }
74 }
75}
76
77void
81
82void
84{
85 // The reason why we need to grab vectors and matrices separately is that
86 // we want to grab a union instead of an intersection.
87 std::vector<LinearFVElementalKernel *> kernels_after_vectors;
89 .query()
90 .template condition<AttribSysNum>(_system_number)
91 .template condition<AttribSystem>("LinearFVElementalKernel")
92 .template condition<AttribKokkos>(false)
93 .template condition<AttribThread>(_tid)
94 .template condition<AttribVectorTags>(_vector_tags)
95 .queryInto(kernels_after_vectors);
96
97 std::vector<LinearFVElementalKernel *> kernels_after_matrices;
99 .query()
100 .template condition<AttribSysNum>(_system_number)
101 .template condition<AttribSystem>("LinearFVElementalKernel")
102 .template condition<AttribKokkos>(false)
103 .template condition<AttribThread>(_tid)
104 .template condition<AttribMatrixTags>(_matrix_tags)
105 .queryInto(kernels_after_matrices);
106
107 // We fetch the union of the available objects
108 std::vector<LinearFVElementalKernel *> kernels;
109 MooseUtils::getUnion(kernels_after_vectors, kernels_after_matrices, kernels);
110
111 // As a last step, we make sure the kernels know which vectors/matrices they need to contribute to
112 for (auto & kernel : kernels)
113 kernel->linkTaggedVectorsAndMatrices(_vector_tags, _matrix_tags);
114
116}
117
118void
120{
122 "The system contribution objects need to be set up before we fetch the "
123 "block-restricted objects!");
124
125 // Here we just filter based on subdomain ID on top of everything else
126 std::vector<LinearFVElementalKernel *> kernels_after_vector;
128 .query()
129 .template condition<AttribSysNum>(_system_number)
130 .template condition<AttribSystem>("LinearFVElementalKernel")
131 .template condition<AttribKokkos>(false)
132 .template condition<AttribThread>(_tid)
133 .template condition<AttribVectorTags>(_vector_tags)
134 .template condition<AttribSubdomains>(_subdomain)
135 .queryInto(kernels_after_vector);
136
137 std::vector<LinearFVElementalKernel *> kernels_after_matrix;
139 .query()
140 .template condition<AttribSysNum>(_system_number)
141 .template condition<AttribSystem>("LinearFVElementalKernel")
142 .template condition<AttribKokkos>(false)
143 .template condition<AttribThread>(_tid)
144 .template condition<AttribMatrixTags>(_matrix_tags)
145 .template condition<AttribSubdomains>(_subdomain)
146 .queryInto(kernels_after_matrix);
147
148 // We populate the list of kernels with the union of the two vectors
149 MooseUtils::getUnion(kernels_after_vector, kernels_after_matrix, _fv_kernels);
150
152}
153
154void
156{
158 return;
159 auto & console = _fe_problem.console();
160 auto execute_on = _fe_problem.getCurrentExecuteOnFlag();
161 console << "[DBG] Beginning linear finite volume elemental objects loop on " << execute_on
162 << std::endl;
163
164 mooseDoOnce(console << "[DBG] Loop on elements (ElemInfo), objects ordered on each face: "
165 << std::endl;
166 console << "[DBG] - linear finite volume kernels" << std::endl;);
167}
168
169void
171{
173 return;
174
175 auto & console = _fe_problem.console();
176 console << "[DBG] Linear FV elemental kernels on block "
178
179 // Print the list of objects
180 std::vector<MooseObject *> kernels_to_print;
181 for (const auto & kernel : _fv_kernels)
182 kernels_to_print.push_back(dynamic_cast<MooseObject *>(kernel));
183
185 "[DBG]")
186 << std::endl;
187}
Adds contributions from volumetric terms discretized using the finite volume method to the matrix and...
ComputeLinearFVElementalThread(FEProblemBase &fe_problem, const unsigned int linear_system_num, const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
Class constructor.
StoredRange< MooseMesh::const_elem_info_iterator, const ElemInfo * > ElemInfoRange
void printBlockExecutionInformation() const
Print ordering of objects executed on each block.
void operator()(const ElemInfoRange &range)
Operator which is used to execute the thread over a certain iterator range.
void join(const ComputeLinearFVElementalThread &)
Join threads at the end of the execution.
void printGeneralExecutionInformation() const
Print list of object types executed and in which order.
void fetchBlockSystemContributionObjects()
Fetch contribution objects that belong to a specific spatial subdomain.
SubdomainID _subdomain
The subdomain for the current element.
const std::set< TagID > & _vector_tags
The vector tags this thread contributes to.
std::vector< LinearFVElementalKernel * > _fv_kernels
The set of cached elemental kernels which will be executed on a given element.
const unsigned int _system_number
The number of the linear system we are contributing to.
FEProblemBase & _fe_problem
Reference to the problem.
bool _system_contrib_objects_ready
Boolean that is used to check if the kernels are ready to start contributing to the system.
const std::set< TagID > & _matrix_tags
The matrix tags this thread contributes to.
void setupSystemContributionObjects()
Setup the contribution objects before we start the loop.
SubdomainID _old_subdomain
The subdomain for the last element.
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.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
const SubdomainID INVALID_BLOCK_ID
Definition MooseTypes.C:20