https://mooseframework.inl.gov
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 
43 void
45 {
46  ParallelUniqueId puid;
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 
77 void
79 {
80 }
81 
82 void
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<AttribThread>(_tid)
93  .template condition<AttribVectorTags>(_vector_tags)
94  .queryInto(kernels_after_vectors);
95 
96  std::vector<LinearFVElementalKernel *> kernels_after_matrices;
98  .query()
99  .template condition<AttribSysNum>(_system_number)
100  .template condition<AttribSystem>("LinearFVElementalKernel")
101  .template condition<AttribThread>(_tid)
102  .template condition<AttribMatrixTags>(_matrix_tags)
103  .queryInto(kernels_after_matrices);
104 
105  // We fetch the union of the available objects
106  std::vector<LinearFVElementalKernel *> kernels;
107  MooseUtils::getUnion(kernels_after_vectors, kernels_after_matrices, kernels);
108 
109  // As a last step, we make sure the kernels know which vectors/matrices they need to contribute to
110  for (auto & kernel : kernels)
111  kernel->linkTaggedVectorsAndMatrices(_vector_tags, _matrix_tags);
112 
114 }
115 
116 void
118 {
119  mooseAssert(_system_contrib_objects_ready,
120  "The system contribution objects need to be set up before we fetch the "
121  "block-restricted objects!");
122 
123  // Here we just filter based on subdomain ID on top of everything else
124  std::vector<LinearFVElementalKernel *> kernels_after_vector;
126  .query()
127  .template condition<AttribSysNum>(_system_number)
128  .template condition<AttribSystem>("LinearFVElementalKernel")
129  .template condition<AttribThread>(_tid)
130  .template condition<AttribVectorTags>(_vector_tags)
131  .template condition<AttribSubdomains>(_subdomain)
132  .queryInto(kernels_after_vector);
133 
134  std::vector<LinearFVElementalKernel *> kernels_after_matrix;
136  .query()
137  .template condition<AttribSysNum>(_system_number)
138  .template condition<AttribSystem>("LinearFVElementalKernel")
139  .template condition<AttribThread>(_tid)
140  .template condition<AttribMatrixTags>(_matrix_tags)
141  .template condition<AttribSubdomains>(_subdomain)
142  .queryInto(kernels_after_matrix);
143 
144  // We populate the list of kernels with the union of the two vectors
145  MooseUtils::getUnion(kernels_after_vector, kernels_after_matrix, _fv_kernels);
146 
148 }
149 
150 void
152 {
154  return;
155  auto & console = _fe_problem.console();
156  auto execute_on = _fe_problem.getCurrentExecuteOnFlag();
157  console << "[DBG] Beginning linear finite volume elemental objects loop on " << execute_on
158  << std::endl;
159 
160  mooseDoOnce(console << "[DBG] Loop on elements (ElemInfo), objects ordered on each face: "
161  << std::endl;
162  console << "[DBG] - linear finite volume kernels" << std::endl;);
163 }
164 
165 void
167 {
169  return;
170 
171  auto & console = _fe_problem.console();
172  console << "[DBG] Linear FV elemental kernels on block "
174 
175  // Print the list of objects
176  std::vector<MooseObject *> kernels_to_print;
177  for (const auto & kernel : _fv_kernels)
178  kernels_to_print.push_back(dynamic_cast<MooseObject *>(kernel));
179 
181  "[DBG]")
182  << std::endl;
183 }
std::string mooseObjectVectorToString(const std::vector< MooseObject *> &objs, const std::string &sep=" ")
Routine to output the name of MooseObjects in a string.
Definition: ConsoleUtils.C:598
FEProblemBase & _fe_problem
Reference to the problem.
const std::set< TagID > & _matrix_tags
The matrix tags this thread contributes to.
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
SubdomainID _old_subdomain
The subdomain for the last element.
std::vector< T * > & queryInto(std::vector< T *> &results, Args &&... args)
queryInto executes the query and stores the results in the given vector.
Definition: TheWarehouse.h:311
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.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
const unsigned int _system_number
The number of the linear system we are contributing to.
const std::string & getSubdomainName(SubdomainID subdomain_id) const
Return the name of a block given an id.
Definition: MooseMesh.C:1758
StoredRange< MooseMesh::const_elem_info_iterator, const ElemInfo * > ElemInfoRange
SubdomainID _subdomain
The subdomain for the current element.
Adds contributions from volumetric terms discretized using the finite volume method to the matrix and...
const SubdomainID INVALID_BLOCK_ID
Definition: MooseTypes.C:20
void setupSystemContributionObjects()
Setup the contribution objects before we start the loop.
const std::set< TagID > & _vector_tags
The vector tags this thread contributes to.
bool shouldPrintExecution(const THREAD_ID tid) const
Check whether the problem should output execution orders at this time.
bool _system_contrib_objects_ready
Boolean that is used to check if the kernels are ready to start contributing to the system...
TheWarehouse & theWarehouse() const
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...
Definition: ConsoleUtils.C:582
const ConsoleStream & console() const
Return console handle.
Definition: Problem.h:48
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void getUnion(const std::vector< T > &vector1, const std::vector< T > &vector2, std::vector< T > &common)
Function which takes the union of vector1 and vector2 and copies them to common . ...
Definition: MooseUtils.h:645
void fetchBlockSystemContributionObjects()
Fetch contribution objects that belong to a specific spatial subdomain.
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse...
Definition: TheWarehouse.h:466
ComputeLinearFVElementalThread(FEProblemBase &fe_problem, const unsigned int linear_system_num, const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
Class constructor.
virtual MooseMesh & mesh() override
void printGeneralExecutionInformation() const
Print list of object types executed and in which order.
std::vector< LinearFVElementalKernel * > _fv_kernels
The set of cached elemental kernels which will be executed on a given element.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...