https://mooseframework.inl.gov
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
ComputeLinearFVElementalThread Class Reference

Adds contributions from volumetric terms discretized using the finite volume method to the matrix and right hand side of a linear system. More...

#include <ComputeLinearFVElementalThread.h>

Public Types

using ElemInfoRange = StoredRange< MooseMesh::const_elem_info_iterator, const ElemInfo * >
 

Public Member Functions

 ComputeLinearFVElementalThread (FEProblemBase &fe_problem, const unsigned int linear_system_num, const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
 Class constructor. More...
 
 ComputeLinearFVElementalThread (ComputeLinearFVElementalThread &x, Threads::split split)
 Splitting constructor. More...
 
void operator() (const ElemInfoRange &range)
 Operator which is used to execute the thread over a certain iterator range. More...
 
void join (const ComputeLinearFVElementalThread &)
 Join threads at the end of the execution. More...
 

Protected Member Functions

void setupSystemContributionObjects ()
 Setup the contribution objects before we start the loop. More...
 
void fetchBlockSystemContributionObjects ()
 Fetch contribution objects that belong to a specific spatial subdomain. More...
 
void printGeneralExecutionInformation () const
 Print list of object types executed and in which order. More...
 
void printBlockExecutionInformation () const
 Print ordering of objects executed on each block. More...
 

Protected Attributes

FEProblemBase_fe_problem
 Reference to the problem. More...
 
const unsigned int _system_number
 The number of the linear system we are contributing to. More...
 
const std::set< TagID > & _vector_tags
 The vector tags this thread contributes to. More...
 
const std::set< TagID > & _matrix_tags
 The matrix tags this thread contributes to. More...
 
THREAD_ID _tid
 Thread ID. More...
 
SubdomainID _subdomain
 The subdomain for the current element. More...
 
SubdomainID _old_subdomain
 The subdomain for the last element. More...
 
std::vector< LinearFVElementalKernel * > _fv_kernels
 The set of cached elemental kernels which will be executed on a given element. More...
 

Private Attributes

bool _system_contrib_objects_ready
 Boolean that is used to check if the kernels are ready to start contributing to the system. More...
 

Detailed Description

Adds contributions from volumetric terms discretized using the finite volume method to the matrix and right hand side of a linear system.

Definition at line 27 of file ComputeLinearFVElementalThread.h.

Member Typedef Documentation

◆ ElemInfoRange

Definition at line 51 of file ComputeLinearFVElementalThread.h.

Constructor & Destructor Documentation

◆ ComputeLinearFVElementalThread() [1/2]

ComputeLinearFVElementalThread::ComputeLinearFVElementalThread ( FEProblemBase fe_problem,
const unsigned int  linear_system_num,
const std::set< TagID > &  vector_tags,
const std::set< TagID > &  matrix_tags 
)

Class constructor.

Parameters
fe_problemReference to the problem
linear_system_numThe number of the linear system which is assembled by this thread
modeComputation mode (rhs, matrix or both)
vector_tagsThe vector tags this thread should contribute to. These are used to query the warehouse for the objects that should contribute to the right hand side.
matrix_tagsThe matrix tags this thread should contribute to. These are used to query the warehouse for the objects that should contribute to the matrix.

Definition at line 16 of file ComputeLinearFVElementalThread.C.

20  : _fe_problem(fe_problem),
21  _system_number(system_num),
22  _vector_tags(vector_tags),
23  _matrix_tags(matrix_tags),
27 {
28 }
FEProblemBase & _fe_problem
Reference to the problem.
const std::set< TagID > & _matrix_tags
The matrix tags this thread contributes to.
SubdomainID _old_subdomain
The subdomain for the last element.
const unsigned int _system_number
The number of the linear system we are contributing to.
SubdomainID _subdomain
The subdomain for the current element.
const SubdomainID INVALID_BLOCK_ID
Definition: MooseTypes.C:20
const std::set< TagID > & _vector_tags
The vector tags this thread contributes to.
bool _system_contrib_objects_ready
Boolean that is used to check if the kernels are ready to start contributing to the system...

◆ ComputeLinearFVElementalThread() [2/2]

ComputeLinearFVElementalThread::ComputeLinearFVElementalThread ( ComputeLinearFVElementalThread x,
Threads::split  split 
)

Splitting constructor.

Parameters
xReference to the other thread
splitThe thread split

Definition at line 31 of file ComputeLinearFVElementalThread.C.

40 {
41 }
FEProblemBase & _fe_problem
Reference to the problem.
const std::set< TagID > & _matrix_tags
The matrix tags this thread contributes to.
SubdomainID _old_subdomain
The subdomain for the last element.
const unsigned int _system_number
The number of the linear system we are contributing to.
SubdomainID _subdomain
The subdomain for the current element.
const std::set< TagID > & _vector_tags
The vector tags this thread contributes to.
bool _system_contrib_objects_ready
Boolean that is used to check if the kernels are ready to start contributing to the system...

Member Function Documentation

◆ fetchBlockSystemContributionObjects()

void ComputeLinearFVElementalThread::fetchBlockSystemContributionObjects ( )
protected

Fetch contribution objects that belong to a specific spatial subdomain.

Definition at line 117 of file ComputeLinearFVElementalThread.C.

Referenced by operator()().

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 }
FEProblemBase & _fe_problem
Reference to the problem.
const std::set< TagID > & _matrix_tags
The matrix tags this thread contributes to.
SubdomainID _old_subdomain
The subdomain for the last element.
const unsigned int _system_number
The number of the linear system we are contributing to.
SubdomainID _subdomain
The subdomain for the current element.
const std::set< TagID > & _vector_tags
The vector tags this thread contributes to.
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
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
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse...
Definition: TheWarehouse.h:466
std::vector< LinearFVElementalKernel * > _fv_kernels
The set of cached elemental kernels which will be executed on a given element.

◆ join()

void ComputeLinearFVElementalThread::join ( const ComputeLinearFVElementalThread )

Join threads at the end of the execution.

Definition at line 78 of file ComputeLinearFVElementalThread.C.

79 {
80 }

◆ operator()()

void ComputeLinearFVElementalThread::operator() ( const ElemInfoRange range)

Operator which is used to execute the thread over a certain iterator range.

Parameters
rangeThe range of ElemInfos which should be computed.

Definition at line 44 of file ComputeLinearFVElementalThread.C.

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 }
SubdomainID _old_subdomain
The subdomain for the last element.
void printBlockExecutionInformation() const
Print ordering of objects executed on each block.
SubdomainID _subdomain
The subdomain for the current element.
const SubdomainID INVALID_BLOCK_ID
Definition: MooseTypes.C:20
void setupSystemContributionObjects()
Setup the contribution objects before we start the loop.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void fetchBlockSystemContributionObjects()
Fetch contribution objects that belong to a specific spatial subdomain.
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.

◆ printBlockExecutionInformation()

void ComputeLinearFVElementalThread::printBlockExecutionInformation ( ) const
protected

Print ordering of objects executed on each block.

Definition at line 166 of file ComputeLinearFVElementalThread.C.

Referenced by operator()().

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::string & getSubdomainName(SubdomainID subdomain_id) const
Return the name of a block given an id.
Definition: MooseMesh.C:1758
SubdomainID _subdomain
The subdomain for the current element.
bool shouldPrintExecution(const THREAD_ID tid) const
Check whether the problem should output execution orders at this time.
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
virtual MooseMesh & mesh() override
std::vector< LinearFVElementalKernel * > _fv_kernels
The set of cached elemental kernels which will be executed on a given element.

◆ printGeneralExecutionInformation()

void ComputeLinearFVElementalThread::printGeneralExecutionInformation ( ) const
protected

Print list of object types executed and in which order.

Definition at line 151 of file ComputeLinearFVElementalThread.C.

Referenced by operator()().

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 }
FEProblemBase & _fe_problem
Reference to the problem.
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
bool shouldPrintExecution(const THREAD_ID tid) const
Check whether the problem should output execution orders at this time.
const ConsoleStream & console() const
Return console handle.
Definition: Problem.h:48

◆ setupSystemContributionObjects()

void ComputeLinearFVElementalThread::setupSystemContributionObjects ( )
protected

Setup the contribution objects before we start the loop.

Definition at line 83 of file ComputeLinearFVElementalThread.C.

Referenced by operator()().

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 }
FEProblemBase & _fe_problem
Reference to the problem.
const std::set< TagID > & _matrix_tags
The matrix tags this thread contributes to.
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
const unsigned int _system_number
The number of the linear system we are contributing to.
const std::set< TagID > & _vector_tags
The vector tags this thread contributes to.
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
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
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse...
Definition: TheWarehouse.h:466

Member Data Documentation

◆ _fe_problem

FEProblemBase& ComputeLinearFVElementalThread::_fe_problem
protected

◆ _fv_kernels

std::vector<LinearFVElementalKernel *> ComputeLinearFVElementalThread::_fv_kernels
protected

The set of cached elemental kernels which will be executed on a given element.

This member variable is changed on a per-block basis.

Definition at line 95 of file ComputeLinearFVElementalThread.h.

Referenced by fetchBlockSystemContributionObjects(), operator()(), and printBlockExecutionInformation().

◆ _matrix_tags

const std::set<TagID>& ComputeLinearFVElementalThread::_matrix_tags
protected

The matrix tags this thread contributes to.

Definition at line 82 of file ComputeLinearFVElementalThread.h.

Referenced by fetchBlockSystemContributionObjects(), and setupSystemContributionObjects().

◆ _old_subdomain

SubdomainID ComputeLinearFVElementalThread::_old_subdomain
protected

The subdomain for the last element.

Definition at line 91 of file ComputeLinearFVElementalThread.h.

Referenced by fetchBlockSystemContributionObjects(), and operator()().

◆ _subdomain

SubdomainID ComputeLinearFVElementalThread::_subdomain
protected

The subdomain for the current element.

Definition at line 88 of file ComputeLinearFVElementalThread.h.

Referenced by fetchBlockSystemContributionObjects(), operator()(), and printBlockExecutionInformation().

◆ _system_contrib_objects_ready

bool ComputeLinearFVElementalThread::_system_contrib_objects_ready
private

Boolean that is used to check if the kernels are ready to start contributing to the system.

Definition at line 100 of file ComputeLinearFVElementalThread.h.

Referenced by fetchBlockSystemContributionObjects(), and setupSystemContributionObjects().

◆ _system_number

const unsigned int ComputeLinearFVElementalThread::_system_number
protected

The number of the linear system we are contributing to.

Definition at line 76 of file ComputeLinearFVElementalThread.h.

Referenced by fetchBlockSystemContributionObjects(), and setupSystemContributionObjects().

◆ _tid

THREAD_ID ComputeLinearFVElementalThread::_tid
protected

◆ _vector_tags

const std::set<TagID>& ComputeLinearFVElementalThread::_vector_tags
protected

The vector tags this thread contributes to.

Definition at line 79 of file ComputeLinearFVElementalThread.h.

Referenced by fetchBlockSystemContributionObjects(), and setupSystemContributionObjects().


The documentation for this class was generated from the following files: