www.mooseframework.org
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 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 107 of file ComputeInitialConditionThread.C.

108 {
109 }

◆ operator()()

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

Definition at line 28 of file ComputeInitialConditionThread.C.

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

Referenced by operator()().

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