www.mooseframework.org
ComputeBoundaryInitialConditionThread.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
16 
17 // MOOSE includes
18 #include "Assembly.h"
19 #include "InitialCondition.h"
20 #include "MooseVariable.h"
21 #include "SystemBase.h"
22 
24  FEProblemBase & fe_problem)
25  : ThreadedNodeLoop<ConstBndNodeRange, ConstBndNodeRange::const_iterator>(fe_problem)
26 {
27 }
28 
30  ComputeBoundaryInitialConditionThread & x, Threads::split split)
31  : ThreadedNodeLoop<ConstBndNodeRange, ConstBndNodeRange::const_iterator>(x, split)
32 {
33 }
34 
35 void
36 ComputeBoundaryInitialConditionThread::onNode(ConstBndNodeRange::const_iterator & nd)
37 {
38  const BndNode * bnode = *nd;
39 
40  Node * node = bnode->_node;
41  BoundaryID boundary_id = bnode->_bnd_id;
42 
44 
46 
47  if (warehouse.hasActiveBoundaryObjects(boundary_id, _tid))
48  {
49  const std::vector<std::shared_ptr<InitialCondition>> & ics =
50  warehouse.getActiveBoundaryObjects(boundary_id, _tid);
51  for (const auto & ic : ics)
52  {
53  if (node->processor_id() == _fe_problem.processor_id())
54  {
55  MooseVariable & var = ic->variable();
56  var.reinitNode();
57  var.computeNodalValues(); // has to call this to resize the internal array
58  Real value = ic->value(*node);
59 
60  var.setNodalValue(value); // update variable data, which is referenced by others, so the
61  // value is up-to-date
62 
63  // We are done, so update the solution vector
64  {
65  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
66  var.insert(var.sys().solution());
67  }
68  }
69  }
70  }
71 }
72 
73 void
75 {
76 }
Class for stuff related to variables.
Definition: MooseVariable.h:43
Warehouse for storing initial conditions.
virtual Assembly & assembly(THREAD_ID tid) override
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
static PetscErrorCode Vec x
BoundaryID _bnd_id
boundary id for the node
Definition: BndNode.h:28
Node * _node
pointer to the node
Definition: BndNode.h:26
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
const InitialConditionWarehouse & getInitialConditionWarehouse() const
Return InitialCondition storage.
void reinit(const Elem *elem)
Reinitialize objects (JxW, q_points, ...) for an elements.
Definition: Assembly.C:650
void computeNodalValues()
Compute nodal values of this variable.
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
void setNodalValue(Number value, unsigned int idx=0)
Set the nodal value for this variable to keep everything up to date.
void onNode(ConstBndNodeRange::const_iterator &nd)
Called for each node.
virtual NumericVector< Number > & solution()=0
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > ConstBndNodeRange
Some useful StoredRange typedefs.
Definition: MooseMesh.h:1213
SystemBase & sys()
Get the system this variable is part of.
void insert(NumericVector< Number > &residual)
void join(const ComputeBoundaryInitialConditionThread &)
boundary_id_type BoundaryID
Definition: MooseTypes.h:75