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

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

#include <ComputeLinearFVFaceThread.h>

Public Types

using FaceInfoRange = StoredRange< MooseMesh::const_face_info_iterator, const FaceInfo * >
 

Public Member Functions

 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. More...
 
 ComputeLinearFVFaceThread (ComputeLinearFVFaceThread &x, Threads::split split)
 Splitting constructor. More...
 
void operator() (const FaceInfoRange &range)
 Operator which is used to execute the thread over a certain iterator range. More...
 
void join (const ComputeLinearFVFaceThread &)
 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 LinearFVFluxKernels for a given block. More...
 
void printGeneralExecutionInformation () const
 Print list of executed object types together with the execution 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 Moose::FV::LinearFVComputationMode _mode
 The mode in which this thread is operating. 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...
 
SubdomainID _subdomain
 The subdomain for the current element. More...
 
SubdomainID _old_subdomain
 The subdomain for the last element. More...
 
SubdomainID _neighbor_subdomain
 The subdomain for the current neighbor. More...
 
SubdomainID _old_neighbor_subdomain
 The subdomain for the last neighbor. More...
 
THREAD_ID _tid
 Thread ID. More...
 
std::vector< LinearFVFluxKernel * > _fv_flux_kernels_elem
 Kernels which will only contribute to a matrix from the element-side of the face. More...
 
std::vector< LinearFVFluxKernel * > _fv_flux_kernels_neighbor
 Kernels which will only contribute to a matrix from the neighbor-side of the face. More...
 
std::set< LinearFVFluxKernel * > _fv_flux_kernels
 Combined LinearFVFluxKernels which will be used to contribute to a system. 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 face terms discretized using the finite volume method to the matrix and right hand side of a linear system.

Definition at line 27 of file ComputeLinearFVFaceThread.h.

Member Typedef Documentation

◆ FaceInfoRange

Definition at line 53 of file ComputeLinearFVFaceThread.h.

Constructor & Destructor Documentation

◆ ComputeLinearFVFaceThread() [1/2]

ComputeLinearFVFaceThread::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.

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 ComputeLinearFVFaceThread.C.

21  : _fe_problem(fe_problem),
22  _system_number(system_num),
23  _mode(mode),
24  _vector_tags(vector_tags),
25  _matrix_tags(matrix_tags),
27 {
28 }
const unsigned int _system_number
The number of the linear system we are contributing to.
const Moose::FV::LinearFVComputationMode _mode
The mode in which this thread is operating.
bool _system_contrib_objects_ready
Boolean that is used to check if the kernels are ready to start contributing to the system...
FEProblemBase & _fe_problem
Reference to the problem.
const std::set< TagID > & _matrix_tags
The matrix tags this thread contributes to.
const std::set< TagID > & _vector_tags
The vector tags this thread contributes to.

◆ ComputeLinearFVFaceThread() [2/2]

ComputeLinearFVFaceThread::ComputeLinearFVFaceThread ( ComputeLinearFVFaceThread x,
Threads::split  split 
)

Splitting constructor.

Parameters
xReference to the other thread
splitThe thread split

Definition at line 31 of file ComputeLinearFVFaceThread.C.

35  _mode(x._mode),
39 {
40 }
const unsigned int _system_number
The number of the linear system we are contributing to.
const Moose::FV::LinearFVComputationMode _mode
The mode in which this thread is operating.
bool _system_contrib_objects_ready
Boolean that is used to check if the kernels are ready to start contributing to the system...
FEProblemBase & _fe_problem
Reference to the problem.
const std::set< TagID > & _matrix_tags
The matrix tags this thread contributes to.
const std::set< TagID > & _vector_tags
The vector tags this thread contributes to.

Member Function Documentation

◆ fetchBlockSystemContributionObjects()

void ComputeLinearFVFaceThread::fetchBlockSystemContributionObjects ( )
protected

Fetch LinearFVFluxKernels for a given block.

We only call this when we transition from one block to another.

Definition at line 120 of file ComputeLinearFVFaceThread.C.

Referenced by operator()().

121 {
122  mooseAssert(_system_contrib_objects_ready,
123  "The system contribution objects need to be set up before we fetch the "
124  "block-restricted objects!");
125 
126  _fv_flux_kernels.clear();
127 
128  if (_subdomain != _old_subdomain)
129  {
130  // We just filter based on subdomain ID on top of everything else
131  std::vector<LinearFVFluxKernel *> kernels_after_vector;
133  .query()
134  .template condition<AttribSysNum>(_system_number)
135  .template condition<AttribSystem>("LinearFVFluxKernel")
136  .template condition<AttribThread>(_tid)
137  .template condition<AttribVectorTags>(_vector_tags)
138  .template condition<AttribSubdomains>(_subdomain)
139  .queryInto(kernels_after_vector);
140  std::vector<LinearFVFluxKernel *> kernels_after_matrix;
142  .query()
143  .template condition<AttribSysNum>(_system_number)
144  .template condition<AttribSystem>("LinearFVFluxKernel")
145  .template condition<AttribThread>(_tid)
146  .template condition<AttribMatrixTags>(_matrix_tags)
147  .template condition<AttribSubdomains>(_subdomain)
148  .queryInto(kernels_after_matrix);
149 
150  // We populate the list of kernels with the union of the two vectors
151  MooseUtils::getUnion(kernels_after_vector, kernels_after_matrix, _fv_flux_kernels_elem);
153  }
155 
157  {
158  // Here we just filter based on subdomain ID on top of everything else
159  std::vector<LinearFVFluxKernel *> kernels_after_vector;
161  .query()
162  .template condition<AttribSysNum>(_system_number)
163  .template condition<AttribSystem>("LinearFVFluxKernel")
164  .template condition<AttribThread>(_tid)
165  .template condition<AttribVectorTags>(_vector_tags)
166  .template condition<AttribSubdomains>(_neighbor_subdomain)
167  .queryInto(kernels_after_vector);
168  std::vector<LinearFVFluxKernel *> kernels_after_matrix;
170  .query()
171  .template condition<AttribSysNum>(_system_number)
172  .template condition<AttribSystem>("LinearFVFluxKernel")
173  .template condition<AttribThread>(_tid)
174  .template condition<AttribMatrixTags>(_matrix_tags)
175  .template condition<AttribSubdomains>(_neighbor_subdomain)
176  .queryInto(kernels_after_matrix);
177 
178  // We populate the list of kernels with the union of the two vectors
179  MooseUtils::getUnion(kernels_after_vector, kernels_after_matrix, _fv_flux_kernels_neighbor);
181  }
183 }
SubdomainID _old_neighbor_subdomain
The subdomain for the last neighbor.
const unsigned int _system_number
The number of the linear system we are contributing to.
std::vector< LinearFVFluxKernel * > _fv_flux_kernels_elem
Kernels which will only contribute to a matrix from the element-side of the face. ...
SubdomainID _old_subdomain
The subdomain for the last element.
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::vector< LinearFVFluxKernel * > _fv_flux_kernels_neighbor
Kernels which will only contribute to a matrix from the neighbor-side of the face.
SubdomainID _subdomain
The subdomain for the current element.
FEProblemBase & _fe_problem
Reference to the problem.
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
std::set< LinearFVFluxKernel * > _fv_flux_kernels
Combined LinearFVFluxKernels which will be used to contribute to a system.
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse...
Definition: TheWarehouse.h:466
SubdomainID _neighbor_subdomain
The subdomain for the current neighbor.
const std::set< TagID > & _matrix_tags
The matrix tags this thread contributes to.
const std::set< TagID > & _vector_tags
The vector tags this thread contributes to.

◆ join()

void ComputeLinearFVFaceThread::join ( const ComputeLinearFVFaceThread )

Join threads at the end of the execution.

Definition at line 81 of file ComputeLinearFVFaceThread.C.

82 {
83 }

◆ operator()()

void ComputeLinearFVFaceThread::operator() ( const FaceInfoRange range)

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

Parameters
rangeThe range of FaceInfos which should be computed.

Definition at line 43 of file ComputeLinearFVFaceThread.C.

44 {
45  ParallelUniqueId puid;
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 }
SubdomainID _old_neighbor_subdomain
The subdomain for the last neighbor.
SubdomainID _old_subdomain
The subdomain for the last element.
void fetchBlockSystemContributionObjects()
Fetch LinearFVFluxKernels for a given block.
void setupSystemContributionObjects()
Setup the contribution objects before we start the loop.
const SubdomainID INVALID_BLOCK_ID
Definition: MooseTypes.C:20
SubdomainID _subdomain
The subdomain for the current element.
void printBlockExecutionInformation() const
Print ordering of objects executed on each block.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::set< LinearFVFluxKernel * > _fv_flux_kernels
Combined LinearFVFluxKernels which will be used to contribute to a system.
SubdomainID _neighbor_subdomain
The subdomain for the current neighbor.
void printGeneralExecutionInformation() const
Print list of executed object types together with the execution order.

◆ printBlockExecutionInformation()

void ComputeLinearFVFaceThread::printBlockExecutionInformation ( ) const
protected

Print ordering of objects executed on each block.

Definition at line 200 of file ComputeLinearFVFaceThread.C.

Referenced by operator()().

201 {
203  return;
204 
205  // Print the location of the execution
206  auto & console = _fe_problem.console();
207  console << "[DBG] Linear flux kernels on block "
210  console << " and neighbor " << _fe_problem.mesh().getSubdomainName(_neighbor_subdomain)
211  << std::endl;
212  else
213  console << " with no neighbor block" << std::endl;
214 
215  // Print the list of objects
216  std::vector<MooseObject *> kernels_to_print;
217  for (const auto & kernel : _fv_flux_kernels)
218  kernels_to_print.push_back(dynamic_cast<MooseObject *>(kernel));
220  "[DBG]")
221  << std::endl;
222 }
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
const std::string & getSubdomainName(SubdomainID subdomain_id) const
Return the name of a block given an id.
Definition: MooseMesh.C:1758
const SubdomainID INVALID_BLOCK_ID
Definition: MooseTypes.C:20
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
SubdomainID _subdomain
The subdomain for the current element.
FEProblemBase & _fe_problem
Reference to the problem.
const ConsoleStream & console() const
Return console handle.
Definition: Problem.h:48
std::set< LinearFVFluxKernel * > _fv_flux_kernels
Combined LinearFVFluxKernels which will be used to contribute to a system.
virtual MooseMesh & mesh() override
SubdomainID _neighbor_subdomain
The subdomain for the current neighbor.

◆ printGeneralExecutionInformation()

void ComputeLinearFVFaceThread::printGeneralExecutionInformation ( ) const
protected

Print list of executed object types together with the execution order.

Definition at line 186 of file ComputeLinearFVFaceThread.C.

Referenced by operator()().

187 {
189  return;
190  auto & console = _fe_problem.console();
191  auto execute_on = _fe_problem.getCurrentExecuteOnFlag();
192  console << "[DBG] Beginning linear finite volume flux objects loop on " << execute_on
193  << std::endl;
194  mooseDoOnce(console << "[DBG] Loop on faces (FaceInfo), objects ordered on each face: "
195  << std::endl;
196  console << "[DBG] - linear finite volume flux kernels" << std::endl);
197 }
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.
FEProblemBase & _fe_problem
Reference to the problem.
const ConsoleStream & console() const
Return console handle.
Definition: Problem.h:48

◆ setupSystemContributionObjects()

void ComputeLinearFVFaceThread::setupSystemContributionObjects ( )
protected

Setup the contribution objects before we start the loop.

Definition at line 86 of file ComputeLinearFVFaceThread.C.

Referenced by operator()().

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<AttribThread>(_tid)
96  .template condition<AttribVectorTags>(_vector_tags)
97  .queryInto(kernels_after_vectors);
98 
99  std::vector<LinearFVFluxKernel *> kernels_after_matrices;
101  .query()
102  .template condition<AttribSysNum>(_system_number)
103  .template condition<AttribSystem>("LinearFVFluxKernel")
104  .template condition<AttribThread>(_tid)
105  .template condition<AttribMatrixTags>(_matrix_tags)
106  .queryInto(kernels_after_matrices);
107 
108  // We fetch the union of the available objects
109  std::vector<LinearFVFluxKernel *> kernels;
110  MooseUtils::getUnion(kernels_after_vectors, kernels_after_matrices, kernels);
111 
112  // As a last step, we make sure the kernels know which vectors/matrices they need to contribute to
113  for (auto & kernel : kernels)
114  kernel->linkTaggedVectorsAndMatrices(_vector_tags, _matrix_tags);
115 
117 }
const unsigned int _system_number
The number of the linear system we are contributing 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
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
FEProblemBase & _fe_problem
Reference to the problem.
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
const std::set< TagID > & _matrix_tags
The matrix tags this thread contributes to.
const std::set< TagID > & _vector_tags
The vector tags this thread contributes to.

Member Data Documentation

◆ _fe_problem

FEProblemBase& ComputeLinearFVFaceThread::_fe_problem
protected

◆ _fv_flux_kernels

std::set<LinearFVFluxKernel *> ComputeLinearFVFaceThread::_fv_flux_kernels
protected

Combined LinearFVFluxKernels which will be used to contribute to a system.

Definition at line 114 of file ComputeLinearFVFaceThread.h.

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

◆ _fv_flux_kernels_elem

std::vector<LinearFVFluxKernel *> ComputeLinearFVFaceThread::_fv_flux_kernels_elem
protected

Kernels which will only contribute to a matrix from the element-side of the face.

Definition at line 107 of file ComputeLinearFVFaceThread.h.

Referenced by fetchBlockSystemContributionObjects().

◆ _fv_flux_kernels_neighbor

std::vector<LinearFVFluxKernel *> ComputeLinearFVFaceThread::_fv_flux_kernels_neighbor
protected

Kernels which will only contribute to a matrix from the neighbor-side of the face.

Definition at line 111 of file ComputeLinearFVFaceThread.h.

Referenced by fetchBlockSystemContributionObjects().

◆ _matrix_tags

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

The matrix tags this thread contributes to.

Definition at line 88 of file ComputeLinearFVFaceThread.h.

Referenced by fetchBlockSystemContributionObjects(), and setupSystemContributionObjects().

◆ _mode

const Moose::FV::LinearFVComputationMode ComputeLinearFVFaceThread::_mode
protected

The mode in which this thread is operating.

Definition at line 82 of file ComputeLinearFVFaceThread.h.

◆ _neighbor_subdomain

SubdomainID ComputeLinearFVFaceThread::_neighbor_subdomain
protected

The subdomain for the current neighbor.

Definition at line 97 of file ComputeLinearFVFaceThread.h.

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

◆ _old_neighbor_subdomain

SubdomainID ComputeLinearFVFaceThread::_old_neighbor_subdomain
protected

The subdomain for the last neighbor.

Definition at line 100 of file ComputeLinearFVFaceThread.h.

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

◆ _old_subdomain

SubdomainID ComputeLinearFVFaceThread::_old_subdomain
protected

The subdomain for the last element.

Definition at line 94 of file ComputeLinearFVFaceThread.h.

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

◆ _subdomain

SubdomainID ComputeLinearFVFaceThread::_subdomain
protected

The subdomain for the current element.

Definition at line 91 of file ComputeLinearFVFaceThread.h.

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

◆ _system_contrib_objects_ready

bool ComputeLinearFVFaceThread::_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 119 of file ComputeLinearFVFaceThread.h.

Referenced by fetchBlockSystemContributionObjects(), and setupSystemContributionObjects().

◆ _system_number

const unsigned int ComputeLinearFVFaceThread::_system_number
protected

The number of the linear system we are contributing to.

Definition at line 79 of file ComputeLinearFVFaceThread.h.

Referenced by fetchBlockSystemContributionObjects(), and setupSystemContributionObjects().

◆ _tid

THREAD_ID ComputeLinearFVFaceThread::_tid
protected

◆ _vector_tags

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

The vector tags this thread contributes to.

Definition at line 85 of file ComputeLinearFVFaceThread.h.

Referenced by fetchBlockSystemContributionObjects(), and setupSystemContributionObjects().


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