www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
UpdateDisplacedMeshThread Class Reference

#include <UpdateDisplacedMeshThread.h>

Inheritance diagram for UpdateDisplacedMeshThread:
[legend]

Public Member Functions

 UpdateDisplacedMeshThread (FEProblemBase &fe_problem, DisplacedProblem &displaced_problem)
 
 UpdateDisplacedMeshThread (UpdateDisplacedMeshThread &x, Threads::split split)
 
virtual void onNode (NodeRange::const_iterator &nd) override
 Called for each node. More...
 
void join (const UpdateDisplacedMeshThread &)
 
void operator() (const NodeRange &range)
 
virtual void pre ()
 Called before the node range loop. More...
 
virtual void post ()
 Called after the node range loop. More...
 
virtual void postNode (NodeRange::const_iterator &node_it)
 Called after the node assembly is done (including surface assembling) More...
 
virtual void caughtMooseException (MooseException &e)
 Called if a MooseException is caught anywhere during the computation. More...
 
virtual bool keepGoing ()
 Whether or not the loop should continue. More...
 

Protected Member Functions

void init ()
 

Protected Attributes

DisplacedProblem_displaced_problem
 
MooseMesh_ref_mesh
 
const NumericVector< Number > & _nl_soln
 
const NumericVector< Number > & _aux_soln
 
std::shared_ptr< NumericVector< Number > > _nl_ghosted_soln
 
std::shared_ptr< NumericVector< Number > > _aux_ghosted_soln
 
FEProblemBase_fe_problem
 
THREAD_ID _tid
 

Private Attributes

std::vector< unsigned int > _var_nums
 
std::vector< unsigned int > _var_nums_directions
 
std::vector< unsigned int > _aux_var_nums
 
std::vector< unsigned int > _aux_var_nums_directions
 
unsigned int _num_var_nums
 
unsigned int _num_aux_var_nums
 
unsigned int _nonlinear_system_number
 
unsigned int _aux_system_number
 

Detailed Description

Definition at line 28 of file UpdateDisplacedMeshThread.h.

Constructor & Destructor Documentation

◆ UpdateDisplacedMeshThread() [1/2]

UpdateDisplacedMeshThread::UpdateDisplacedMeshThread ( FEProblemBase fe_problem,
DisplacedProblem displaced_problem 
)

Definition at line 18 of file UpdateDisplacedMeshThread.C.

21  _displaced_problem(displaced_problem),
25  _nl_ghosted_soln(NumericVector<Number>::build(_nl_soln.comm()).release()),
26  _aux_ghosted_soln(NumericVector<Number>::build(_aux_soln.comm()).release()),
27  _var_nums(0),
29  _aux_var_nums(0),
31  _num_var_nums(0),
35 {
36  this->init();
37 }
std::vector< unsigned int > _aux_var_nums_directions
virtual TransientExplicitSystem & sys()
DisplacedSystem _displaced_aux
DisplacedSystem _displaced_nl
const NumericVector< Number > & _nl_soln
std::vector< unsigned int > _var_nums
const NumericVector< Number > & _aux_soln
std::shared_ptr< NumericVector< Number > > _nl_ghosted_soln
const NumericVector< Number > * _aux_solution
std::shared_ptr< NumericVector< Number > > _aux_ghosted_soln
std::vector< unsigned int > _var_nums_directions
std::vector< unsigned int > _aux_var_nums
const NumericVector< Number > * _nl_solution
MooseMesh & refMesh()

◆ UpdateDisplacedMeshThread() [2/2]

UpdateDisplacedMeshThread::UpdateDisplacedMeshThread ( UpdateDisplacedMeshThread x,
Threads::split  split 
)

Definition at line 39 of file UpdateDisplacedMeshThread.C.

42  _displaced_problem(x._displaced_problem),
43  _ref_mesh(x._ref_mesh),
44  _nl_soln(x._nl_soln),
45  _aux_soln(x._aux_soln),
46  _nl_ghosted_soln(x._nl_ghosted_soln),
47  _aux_ghosted_soln(x._aux_ghosted_soln),
48  _var_nums(x._var_nums),
49  _var_nums_directions(x._var_nums_directions),
50  _aux_var_nums(x._aux_var_nums),
51  _aux_var_nums_directions(x._aux_var_nums_directions),
52  _num_var_nums(x._num_var_nums),
53  _num_aux_var_nums(x._num_aux_var_nums),
54  _nonlinear_system_number(x._nonlinear_system_number),
55  _aux_system_number(x._aux_system_number)
56 {
57 }
std::vector< unsigned int > _aux_var_nums_directions
const NumericVector< Number > & _nl_soln
static PetscErrorCode Vec x
std::vector< unsigned int > _var_nums
const NumericVector< Number > & _aux_soln
std::shared_ptr< NumericVector< Number > > _nl_ghosted_soln
std::shared_ptr< NumericVector< Number > > _aux_ghosted_soln
std::vector< unsigned int > _var_nums_directions
std::vector< unsigned int > _aux_var_nums

Member Function Documentation

◆ caughtMooseException()

virtual void ThreadedNodeLoop< NodeRange , NodeRange::const_iterator >::caughtMooseException ( MooseException e)
inlinevirtualinherited

Called if a MooseException is caught anywhere during the computation.

The single input parameter taken is a MooseException object.

Definition at line 55 of file ThreadedNodeLoop.h.

56  {
57  std::string what(e.what());
59  };
virtual const char * what() const
Get out the error message.
virtual void setException(const std::string &message)
Set an exception.

◆ init()

void UpdateDisplacedMeshThread::init ( )
protected

Definition at line 60 of file UpdateDisplacedMeshThread.C.

Referenced by UpdateDisplacedMeshThread().

61 {
62  std::vector<std::string> & displacement_variables = _displaced_problem._displacements;
63  unsigned int num_displacements = displacement_variables.size();
64 
65  _var_nums.clear();
66  _var_nums_directions.clear();
67 
68  _aux_var_nums.clear();
70 
71  for (unsigned int i = 0; i < num_displacements; i++)
72  {
73  std::string displacement_name = displacement_variables[i];
74 
75  if (_displaced_problem._displaced_nl.sys().has_variable(displacement_name))
76  {
77  _var_nums.push_back(
78  _displaced_problem._displaced_nl.sys().variable_number(displacement_name));
79  _var_nums_directions.push_back(i);
80  }
81  else if (_displaced_problem._displaced_aux.sys().has_variable(displacement_name))
82  {
83  _aux_var_nums.push_back(
84  _displaced_problem._displaced_aux.sys().variable_number(displacement_name));
85  _aux_var_nums_directions.push_back(i);
86  }
87  else
88  mooseError("Undefined variable '", displacement_name, "' used for displacements!");
89  }
90 
91  _num_var_nums = _var_nums.size();
93 
94  ConstNodeRange node_range(_ref_mesh.getMesh().nodes_begin(), _ref_mesh.getMesh().nodes_end());
95 
96  {
97  AllNodesSendListThread nl_send_list(
99  Threads::parallel_reduce(node_range, nl_send_list);
100  nl_send_list.unique();
101  _nl_ghosted_soln->init(
102  _nl_soln.size(), _nl_soln.local_size(), nl_send_list.send_list(), true, GHOSTED);
103  _nl_soln.localize(*_nl_ghosted_soln, nl_send_list.send_list());
104  }
105 
106  {
107  AllNodesSendListThread aux_send_list(
109  Threads::parallel_reduce(node_range, aux_send_list);
110  aux_send_list.unique();
111  _aux_ghosted_soln->init(
112  _aux_soln.size(), _aux_soln.local_size(), aux_send_list.send_list(), true, GHOSTED);
113  _aux_soln.localize(*_aux_ghosted_soln, aux_send_list.send_list());
114  }
115 }
std::vector< unsigned int > _aux_var_nums_directions
virtual TransientExplicitSystem & sys()
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
DisplacedSystem _displaced_aux
DisplacedSystem _displaced_nl
const NumericVector< Number > & _nl_soln
std::vector< unsigned int > _var_nums
const NumericVector< Number > & _aux_soln
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:2512
std::shared_ptr< NumericVector< Number > > _nl_ghosted_soln
std::vector< std::string > _displacements
std::shared_ptr< NumericVector< Number > > _aux_ghosted_soln
std::vector< unsigned int > _var_nums_directions
std::vector< unsigned int > _aux_var_nums

◆ join()

void UpdateDisplacedMeshThread::join ( const UpdateDisplacedMeshThread )

Definition at line 144 of file UpdateDisplacedMeshThread.C.

145 {
146 }

◆ keepGoing()

virtual bool ThreadedNodeLoop< NodeRange , NodeRange::const_iterator >::keepGoing ( )
inlinevirtualinherited

Whether or not the loop should continue.

Returns
true to keep going, false to stop.

Definition at line 66 of file ThreadedNodeLoop.h.

66 { return !_fe_problem.hasException(); }
virtual bool hasException()
Whether or not an exception has occurred.

◆ onNode()

void UpdateDisplacedMeshThread::onNode ( NodeRange::const_iterator &  node_it)
overridevirtual

Called for each node.

Reimplemented from ThreadedNodeLoop< NodeRange, NodeRange::const_iterator >.

Definition at line 118 of file UpdateDisplacedMeshThread.C.

119 {
120  Node & displaced_node = *(*nd);
121 
122  Node & reference_node = _ref_mesh.nodeRef(displaced_node.id());
123 
124  for (unsigned int i = 0; i < _num_var_nums; i++)
125  {
126  unsigned int direction = _var_nums_directions[i];
127  if (reference_node.n_dofs(_nonlinear_system_number, _var_nums[i]) > 0)
128  displaced_node(direction) =
129  reference_node(direction) +
130  (*_nl_ghosted_soln)(reference_node.dof_number(_nonlinear_system_number, _var_nums[i], 0));
131  }
132 
133  for (unsigned int i = 0; i < _num_aux_var_nums; i++)
134  {
135  unsigned int direction = _aux_var_nums_directions[i];
136  if (reference_node.n_dofs(_aux_system_number, _aux_var_nums[i]) > 0)
137  displaced_node(direction) =
138  reference_node(direction) +
139  (*_aux_ghosted_soln)(reference_node.dof_number(_aux_system_number, _aux_var_nums[i], 0));
140  }
141 }
std::vector< unsigned int > _aux_var_nums_directions
virtual const Node & nodeRef(const dof_id_type i) const
Definition: MooseMesh.C:478
std::vector< unsigned int > _var_nums
std::vector< unsigned int > _var_nums_directions
std::vector< unsigned int > _aux_var_nums

◆ operator()()

void ThreadedNodeLoop< NodeRange , NodeRange::const_iterator >::operator() ( const NodeRange &  range)
inherited

Definition at line 88 of file ThreadedNodeLoop.h.

89 {
90  try
91  {
92  ParallelUniqueId puid;
93  _tid = puid.id;
94 
95  pre();
96 
97  for (IteratorType nd = range.begin(); nd != range.end(); ++nd)
98  {
99  if (!keepGoing())
100  break;
101 
102  onNode(nd);
103 
104  postNode(nd);
105  }
106 
107  post();
108  }
109  catch (MooseException & e)
110  {
112  }
113 }
virtual void caughtMooseException(MooseException &e)
Called if a MooseException is caught anywhere during the computation.
virtual bool keepGoing()
Whether or not the loop should continue.
Provides a way for users to bail out of the current solve.
virtual void pre()
Called before the node range loop.
virtual void post()
Called after the node range loop.
virtual void postNode(NodeRange::const_iterator &node_it)
Called after the node assembly is done (including surface assembling)
virtual void onNode(NodeRange::const_iterator &node_it)
Called for each node.

◆ post()

void ThreadedNodeLoop< NodeRange , NodeRange::const_iterator >::post ( )
virtualinherited

Called after the node range loop.

Definition at line 123 of file ThreadedNodeLoop.h.

124 {
125 }

◆ postNode()

void ThreadedNodeLoop< NodeRange , NodeRange::const_iterator >::postNode ( NodeRange::const_iterator &  node_it)
virtualinherited

Called after the node assembly is done (including surface assembling)

Parameters
node- active node

Definition at line 135 of file ThreadedNodeLoop.h.

136 {
137 }

◆ pre()

void ThreadedNodeLoop< NodeRange , NodeRange::const_iterator >::pre ( )
virtualinherited

Called before the node range loop.

Definition at line 117 of file ThreadedNodeLoop.h.

118 {
119 }

Member Data Documentation

◆ _aux_ghosted_soln

std::shared_ptr<NumericVector<Number> > UpdateDisplacedMeshThread::_aux_ghosted_soln
protected

Definition at line 51 of file UpdateDisplacedMeshThread.h.

Referenced by init().

◆ _aux_soln

const NumericVector<Number>& UpdateDisplacedMeshThread::_aux_soln
protected

Definition at line 45 of file UpdateDisplacedMeshThread.h.

Referenced by init().

◆ _aux_system_number

unsigned int UpdateDisplacedMeshThread::_aux_system_number
private

Definition at line 64 of file UpdateDisplacedMeshThread.h.

Referenced by onNode().

◆ _aux_var_nums

std::vector<unsigned int> UpdateDisplacedMeshThread::_aux_var_nums
private

Definition at line 57 of file UpdateDisplacedMeshThread.h.

Referenced by init(), and onNode().

◆ _aux_var_nums_directions

std::vector<unsigned int> UpdateDisplacedMeshThread::_aux_var_nums_directions
private

Definition at line 58 of file UpdateDisplacedMeshThread.h.

Referenced by init(), and onNode().

◆ _displaced_problem

DisplacedProblem& UpdateDisplacedMeshThread::_displaced_problem
protected

Definition at line 42 of file UpdateDisplacedMeshThread.h.

Referenced by init().

◆ _fe_problem

FEProblemBase& ThreadedNodeLoop< NodeRange , NodeRange::const_iterator >::_fe_problem
protectedinherited

Definition at line 69 of file ThreadedNodeLoop.h.

Referenced by init().

◆ _nl_ghosted_soln

std::shared_ptr<NumericVector<Number> > UpdateDisplacedMeshThread::_nl_ghosted_soln
protected

Definition at line 50 of file UpdateDisplacedMeshThread.h.

Referenced by init().

◆ _nl_soln

const NumericVector<Number>& UpdateDisplacedMeshThread::_nl_soln
protected

Definition at line 44 of file UpdateDisplacedMeshThread.h.

Referenced by init().

◆ _nonlinear_system_number

unsigned int UpdateDisplacedMeshThread::_nonlinear_system_number
private

Definition at line 63 of file UpdateDisplacedMeshThread.h.

Referenced by onNode().

◆ _num_aux_var_nums

unsigned int UpdateDisplacedMeshThread::_num_aux_var_nums
private

Definition at line 61 of file UpdateDisplacedMeshThread.h.

Referenced by init(), and onNode().

◆ _num_var_nums

unsigned int UpdateDisplacedMeshThread::_num_var_nums
private

Definition at line 60 of file UpdateDisplacedMeshThread.h.

Referenced by init(), and onNode().

◆ _ref_mesh

MooseMesh& UpdateDisplacedMeshThread::_ref_mesh
protected

Definition at line 43 of file UpdateDisplacedMeshThread.h.

Referenced by init(), and onNode().

◆ _tid

THREAD_ID ThreadedNodeLoop< NodeRange , NodeRange::const_iterator >::_tid
protectedinherited

Definition at line 70 of file ThreadedNodeLoop.h.

◆ _var_nums

std::vector<unsigned int> UpdateDisplacedMeshThread::_var_nums
private

Definition at line 54 of file UpdateDisplacedMeshThread.h.

Referenced by init(), and onNode().

◆ _var_nums_directions

std::vector<unsigned int> UpdateDisplacedMeshThread::_var_nums_directions
private

Definition at line 55 of file UpdateDisplacedMeshThread.h.

Referenced by init(), and onNode().


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