https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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.
 
 ComputeLinearFVElementalThread (ComputeLinearFVElementalThread &x, Threads::split split)
 Splitting constructor.
 
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.
 

Protected Member Functions

void setupSystemContributionObjects ()
 Setup the contribution objects before we start the loop.
 
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.
 
void printBlockExecutionInformation () const
 Print ordering of objects executed on each block.
 

Protected Attributes

FEProblemBase_fe_problem
 Reference to the problem.
 
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.
 
const std::set< TagID > & _matrix_tags
 The matrix tags this thread contributes to.
 
THREAD_ID _tid
 Thread ID.
 
SubdomainID _subdomain
 The subdomain for the current element.
 
SubdomainID _old_subdomain
 The subdomain for the last element.
 
std::vector< LinearFVElementalKernel * > _fv_kernels
 The set of cached elemental kernels which will be executed on a given element.
 

Private Attributes

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

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 50 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
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}
SubdomainID _subdomain
The subdomain for the current element.
const std::set< TagID > & _vector_tags
The vector tags this thread contributes to.
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.
SubdomainID _old_subdomain
The subdomain for the last element.
const SubdomainID INVALID_BLOCK_ID
Definition MooseTypes.C:20

◆ 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.

Member Function Documentation

◆ fetchBlockSystemContributionObjects()

void ComputeLinearFVElementalThread::fetchBlockSystemContributionObjects ( )
protected

Fetch contribution objects that belong to a specific spatial subdomain.

Definition at line 119 of file ComputeLinearFVElementalThread.C.

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}
std::vector< LinearFVElementalKernel * > _fv_kernels
The set of cached elemental kernels which will be executed on a given element.
TheWarehouse & theWarehouse() const
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.

Referenced by operator()().

◆ 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{
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}
void printBlockExecutionInformation() const
Print ordering of objects executed on each block.
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.
void setupSystemContributionObjects()
Setup the contribution objects before we start the loop.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ printBlockExecutionInformation()

void ComputeLinearFVElementalThread::printBlockExecutionInformation ( ) const
protected

Print ordering of objects executed on each block.

Definition at line 170 of file ComputeLinearFVElementalThread.C.

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}
virtual MooseMesh & mesh() override
bool shouldPrintExecution(const THREAD_ID tid) const
Check whether the problem should output execution orders at this time.
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::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.

Referenced by operator()().

◆ printGeneralExecutionInformation()

void ComputeLinearFVElementalThread::printGeneralExecutionInformation ( ) const
protected

Print list of object types executed and in which order.

Definition at line 155 of file ComputeLinearFVElementalThread.C.

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}
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.

Referenced by operator()().

◆ setupSystemContributionObjects()

void ComputeLinearFVElementalThread::setupSystemContributionObjects ( )
protected

Setup the contribution objects before we start the loop.

Definition at line 83 of file ComputeLinearFVElementalThread.C.

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}

Referenced by operator()().

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 94 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 81 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 90 of file ComputeLinearFVElementalThread.h.

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

◆ _subdomain

SubdomainID ComputeLinearFVElementalThread::_subdomain
protected

The subdomain for the current element.

Definition at line 87 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 99 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 75 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 78 of file ComputeLinearFVElementalThread.h.

Referenced by fetchBlockSystemContributionObjects(), and setupSystemContributionObjects().


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