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

#include <ComputeInitialConditionThread.h>

Public Member Functions

 ComputeInitialConditionThread (FEProblemBase &fe_problem)
 
 ComputeInitialConditionThread (ComputeInitialConditionThread &x, Threads::split split)
 
void operator() (const libMesh::ConstElemRange &range)
 
void join (const ComputeInitialConditionThread &)
 

Protected Member Functions

void printGeneralExecutionInformation () const
 Print information about the loop, mostly order of execution of objects. More...
 

Protected Attributes

FEProblemBase_fe_problem
 
THREAD_ID _tid
 

Detailed Description

Definition at line 20 of file ComputeInitialConditionThread.h.

Constructor & Destructor Documentation

◆ ComputeInitialConditionThread() [1/2]

ComputeInitialConditionThread::ComputeInitialConditionThread ( FEProblemBase fe_problem)

Definition at line 16 of file ComputeInitialConditionThread.C.

17  : _fe_problem(fe_problem)
18 {
19 }

◆ ComputeInitialConditionThread() [2/2]

ComputeInitialConditionThread::ComputeInitialConditionThread ( ComputeInitialConditionThread x,
Threads::split  split 
)

Definition at line 21 of file ComputeInitialConditionThread.C.

Member Function Documentation

◆ join()

void ComputeInitialConditionThread::join ( const ComputeInitialConditionThread )

Definition at line 109 of file ComputeInitialConditionThread.C.

110 {
111 }

◆ operator()()

void ComputeInitialConditionThread::operator() ( const libMesh::ConstElemRange range)

Definition at line 28 of file ComputeInitialConditionThread.C.

29 {
30  ParallelUniqueId puid;
31  _tid = puid.id;
32  const auto current_ic_state = _fe_problem.getCurrentICState();
33 
36 
37  // Iterate over all the elements in the range
38  for (const auto & elem : range)
39  {
40  const unsigned int n_nodes = elem->n_nodes();
41 
42  // we need to execute objects that are for all subdomains covered by this
43  // elements' nodes.
44  std::set<SubdomainID> block_ids;
45  for (unsigned int n = 0; n < n_nodes; n++)
46  {
47  auto node = elem->node_ptr(n);
48  const auto & ids = _fe_problem.mesh().getNodeBlockIds(*node);
49  block_ids.insert(ids.begin(), ids.end());
50  }
51 
52  // we need to remember the order the variables originally are provided in
53  // since the ics dependencies are resolved to handle the inter-variable
54  // dependencies correctly.
55  std::vector<MooseVariableFEBase *> order;
56 
57  // group all initial condition objects by variable. so we can compute all
58  // its dof values at once and copy into solution vector once. This is
59  // necessary because we have to collect extra off-block ic objects from
60  // nodes shared between subdomains for cases where the off-block ic "wins"
61  // on the interface. The grouping is required because we need to have all
62  // the dof values for the element determined together so we can compute
63  // the correct qp values, etc. for the variable.
64  std::map<MooseVariableFEBase *, std::vector<std::shared_ptr<InitialConditionBase>>> groups;
65  for (auto id : block_ids)
66  if (warehouse.hasActiveBlockObjects(id, _tid))
67  for (auto ic : warehouse.getActiveBlockObjects(id, _tid))
68  {
69  if ((id != elem->subdomain_id() && !ic->variable().isNodal()) ||
70  ic->getState() != current_ic_state)
71  continue;
72  order.push_back(&(ic->variable()));
73  groups[&(ic->variable())].push_back(ic);
74  }
75 
77  _fe_problem.prepare(elem, _tid);
79 
80  for (auto var : order)
81  {
82  DenseVector<Real> Ue;
83  auto & vec = groups[var];
84 
85  // because of all the off-node shenanigans/grouping above, per-variable
86  // objects could possible have their order jumbled - so re-sort just in
87  // case.
88  try
89  {
90  DependencyResolverInterface::sort<std::shared_ptr<InitialConditionBase>>(vec);
91  }
92  catch (CyclicDependencyException<std::shared_ptr<InitialConditionBase>> & e)
93  {
94  DependencyResolverInterface::cyclicDependencyError<std::shared_ptr<InitialConditionBase>>(
95  e, "Cyclic dependency detected in object ordering");
96  }
97 
98  for (auto ic : vec)
99  ic->compute();
100  vec.clear();
101 
102  // Now that all dofs are set for this variable, solemnize the solution.
103  var->insert(var->sys().solution());
104  }
105  }
106 }
unsigned short getCurrentICState()
Retrieves the current initial condition state.
bool hasActiveBlockObjects(THREAD_ID tid=0) const
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
virtual void prepare(const Elem *elem, const THREAD_ID tid) override
Warehouse for storing initial conditions.
void printGeneralExecutionInformation() const
Print information about the loop, mostly order of execution of objects.
const std::set< SubdomainID > & getNodeBlockIds(const Node &node) const
Return list of blocks to which the given node belongs.
Definition: MooseMesh.C:1496
const InitialConditionWarehouse & getInitialConditionWarehouse() const
Return InitialCondition storage.
const dof_id_type n_nodes
virtual void reinitElem(const Elem *elem, const THREAD_ID tid) override
virtual void setCurrentSubdomainID(const Elem *elem, const THREAD_ID tid) override
virtual MooseMesh & mesh() override

◆ printGeneralExecutionInformation()

void ComputeInitialConditionThread::printGeneralExecutionInformation ( ) const
protected

Print information about the loop, mostly order of execution of objects.

Definition at line 114 of file ComputeInitialConditionThread.C.

Referenced by operator()().

115 {
116  const auto & ic_wh = _fe_problem.getInitialConditionWarehouse();
117  if (_fe_problem.shouldPrintExecution(_tid) && ic_wh.hasActiveObjects())
118  {
119  const auto & console = _fe_problem.console();
120  const auto & execute_on = _fe_problem.getCurrentExecuteOnFlag();
121  console << "[DBG] Executing initial conditions on elements on " << execute_on << std::endl;
122  console << "[DBG] Unordered list:" << std::endl;
123  console << ic_wh.activeObjectsToFormattedString() << std::endl;
124  console << "[DBG] The order of execution is defined by dependency resolution on every element"
125  << std::endl;
126  }
127 }
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
const InitialConditionWarehouse & getInitialConditionWarehouse() const
Return InitialCondition storage.
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

Member Data Documentation

◆ _fe_problem

FEProblemBase& ComputeInitialConditionThread::_fe_problem
protected

Definition at line 34 of file ComputeInitialConditionThread.h.

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

◆ _tid

THREAD_ID ComputeInitialConditionThread::_tid
protected

Definition at line 35 of file ComputeInitialConditionThread.h.

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


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