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 ()
 
virtual void printGeneralExecutionInformation () const
 Print information about the loop, mostly order of execution of objects. More...
 

Protected Attributes

DisplacedProblem_displaced_problem
 
MooseMesh_ref_mesh
 
const std::vector< const NumericVector< Number > * > & _nl_soln
 
const NumericVector< Number > & _aux_soln
 
std::map< unsigned int, std::pair< const NumericVector< Number > *, std::shared_ptr< NumericVector< Number > > > > _sys_to_nonghost_and_ghost_soln
 
FEProblemBase_fe_problem
 
THREAD_ID _tid
 

Private Attributes

std::map< unsigned int, std::pair< std::vector< unsigned int >, std::vector< unsigned int > > > _sys_to_var_num_and_direction
 

Detailed Description

Definition at line 27 of file UpdateDisplacedMeshThread.h.

Constructor & Destructor Documentation

◆ UpdateDisplacedMeshThread() [1/2]

UpdateDisplacedMeshThread::UpdateDisplacedMeshThread ( FEProblemBase fe_problem,
DisplacedProblem displaced_problem 
)

Definition at line 21 of file UpdateDisplacedMeshThread.C.

24  _displaced_problem(displaced_problem),
28 {
29  this->init();
30 }
const std::vector< const NumericVector< Number > * > & _nl_soln
const NumericVector< Number > & _aux_soln
std::vector< const NumericVector< Number > * > _nl_solution
The nonlinear system solutions.
const NumericVector< Number > * _aux_solution
The auxiliary system solution.
MooseMesh & refMesh()

◆ UpdateDisplacedMeshThread() [2/2]

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

Definition at line 32 of file UpdateDisplacedMeshThread.C.

35  _displaced_problem(x._displaced_problem),
36  _ref_mesh(x._ref_mesh),
37  _nl_soln(x._nl_soln),
38  _aux_soln(x._aux_soln),
39  _sys_to_nonghost_and_ghost_soln(x._sys_to_nonghost_and_ghost_soln),
40  _sys_to_var_num_and_direction(x._sys_to_var_num_and_direction)
41 {
42 }
std::map< unsigned int, std::pair< std::vector< unsigned int >, std::vector< unsigned int > > > _sys_to_var_num_and_direction
const std::vector< const NumericVector< Number > * > & _nl_soln
const NumericVector< Number > & _aux_soln
tbb::split split
std::map< unsigned int, std::pair< const NumericVector< Number > *, std::shared_ptr< NumericVector< Number > > > > _sys_to_nonghost_and_ghost_soln

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 56 of file ThreadedNodeLoop.h.

57  {
58  Threads::spin_mutex::scoped_lock lock(threaded_node_mutex);
59 
60  std::string what(e.what());
62  };
virtual const char * what() const
Get out the error message.
virtual void setException(const std::string &message)
Set an exception, which is stored at this point by toggling a member variable in this class...
static Threads::spin_mutex threaded_node_mutex

◆ init()

void UpdateDisplacedMeshThread::init ( )
protected

Definition at line 45 of file UpdateDisplacedMeshThread.C.

Referenced by UpdateDisplacedMeshThread().

46 {
47  std::vector<std::string> & displacement_variables = _displaced_problem._displacements;
48  unsigned int num_displacements = displacement_variables.size();
49  auto & es = _displaced_problem.es();
50 
53 
54  for (unsigned int i = 0; i < num_displacements; i++)
55  {
56  std::string displacement_name = displacement_variables[i];
57 
58  for (const auto sys_num : make_range(es.n_systems()))
59  {
60  auto & sys = es.get_system(sys_num);
61  if (sys.has_variable(displacement_name))
62  {
63  auto & val = _sys_to_var_num_and_direction[sys.number()];
64  val.first.push_back(sys.variable_number(displacement_name));
65  val.second.push_back(i);
66  break;
67  }
68  }
69  }
70 
71  for (const auto & pr : _sys_to_var_num_and_direction)
72  {
73  auto & sys = es.get_system(pr.first);
74  mooseAssert(sys.number() <= _nl_soln.size(),
75  "The system number should always be less than or equal to the number of nonlinear "
76  "systems. If it is equal, then this system is the auxiliary system");
77  const NumericVector<Number> * const nonghost_soln =
78  sys.number() < _nl_soln.size() ? _nl_soln[sys.number()] : &_aux_soln;
80  sys.number(),
81  std::make_pair(nonghost_soln,
82  NumericVector<Number>::build(nonghost_soln->comm()).release()));
83  }
84 
85  ConstNodeRange node_range(_ref_mesh.getMesh().nodes_begin(), _ref_mesh.getMesh().nodes_end());
86 
87  for (auto & [sys_num, var_num_and_direction] : _sys_to_var_num_and_direction)
88  {
89  auto & sys = es.get_system(sys_num);
90  AllNodesSendListThread send_list(
91  this->_fe_problem, _ref_mesh, var_num_and_direction.first, sys);
92  Threads::parallel_reduce(node_range, send_list);
93  send_list.unique();
94  auto & [soln, ghost_soln] = libmesh_map_find(_sys_to_nonghost_and_ghost_soln, sys_num);
95  ghost_soln->init(soln->size(), soln->local_size(), send_list.send_list(), true, GHOSTED);
96  soln->localize(*ghost_soln, send_list.send_list());
97  }
98 }
std::map< unsigned int, std::pair< std::vector< unsigned int >, std::vector< unsigned int > > > _sys_to_var_num_and_direction
const std::vector< const NumericVector< Number > * > & _nl_soln
virtual EquationSystems & es() override
const NumericVector< Number > & _aux_soln
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:3199
GHOSTED
StoredRange< MeshBase::const_node_iterator, const Node *> ConstNodeRange
std::vector< std::string > _displacements
static std::unique_ptr< NumericVector< Number > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
IntRange< T > make_range(T beg, T end)
std::map< unsigned int, std::pair< const NumericVector< Number > *, std::shared_ptr< NumericVector< Number > > > > _sys_to_nonghost_and_ghost_soln

◆ join()

void UpdateDisplacedMeshThread::join ( const UpdateDisplacedMeshThread )

Definition at line 124 of file UpdateDisplacedMeshThread.C.

125 {
126 }

◆ 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 69 of file ThreadedNodeLoop.h.

69 { 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 101 of file UpdateDisplacedMeshThread.C.

102 {
103  Node & displaced_node = *(*nd);
104 
105  Node & reference_node = _ref_mesh.nodeRef(displaced_node.id());
106 
107  for (auto & [sys_num, var_num_and_direction] : _sys_to_var_num_and_direction)
108  {
109  auto & var_numbers = var_num_and_direction.first;
110  auto & directions = var_num_and_direction.second;
111  for (const auto i : index_range(var_numbers))
112  {
113  const auto direction = directions[i];
114  if (reference_node.n_dofs(sys_num, var_numbers[i]) > 0)
115  displaced_node(direction) =
116  reference_node(direction) +
117  (*libmesh_map_find(_sys_to_nonghost_and_ghost_soln, sys_num).second)(
118  reference_node.dof_number(sys_num, var_numbers[i], 0));
119  }
120  }
121 }
std::map< unsigned int, std::pair< std::vector< unsigned int >, std::vector< unsigned int > > > _sys_to_var_num_and_direction
virtual const Node & nodeRef(const dof_id_type i) const
Definition: MooseMesh.C:637
std::map< unsigned int, std::pair< const NumericVector< Number > *, std::shared_ptr< NumericVector< Number > > > > _sys_to_nonghost_and_ghost_soln
auto index_range(const T &sizable)

◆ operator()()

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

Definition at line 94 of file ThreadedNodeLoop.h.

95 {
96  try
97  {
98  ParallelUniqueId puid;
99  _tid = puid.id;
100 
101  pre();
103 
104  for (IteratorType nd = range.begin(); nd != range.end(); ++nd)
105  {
106  if (!keepGoing())
107  break;
108 
109  onNode(nd);
110 
111  postNode(nd);
112  }
113 
114  post();
115  }
116  catch (MooseException & e)
117  {
119  }
120 }
virtual void printGeneralExecutionInformation() const
Print information about the loop, mostly order of execution of objects.
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 130 of file ThreadedNodeLoop.h.

131 {
132 }

◆ 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 142 of file ThreadedNodeLoop.h.

143 {
144 }

◆ pre()

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

Called before the node range loop.

Definition at line 124 of file ThreadedNodeLoop.h.

125 {
126 }

◆ printGeneralExecutionInformation()

virtual void ThreadedNodeLoop< NodeRange , NodeRange::const_iterator >::printGeneralExecutionInformation ( ) const
inlineprotectedvirtualinherited

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

Definition at line 76 of file ThreadedNodeLoop.h.

76 {}

Member Data Documentation

◆ _aux_soln

const NumericVector<Number>& UpdateDisplacedMeshThread::_aux_soln
protected

Definition at line 44 of file UpdateDisplacedMeshThread.h.

Referenced by init().

◆ _displaced_problem

DisplacedProblem& UpdateDisplacedMeshThread::_displaced_problem
protected

Definition at line 41 of file UpdateDisplacedMeshThread.h.

Referenced by init().

◆ _fe_problem

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

Definition at line 72 of file ThreadedNodeLoop.h.

Referenced by init().

◆ _nl_soln

const std::vector<const NumericVector<Number> *>& UpdateDisplacedMeshThread::_nl_soln
protected

Definition at line 43 of file UpdateDisplacedMeshThread.h.

Referenced by init().

◆ _ref_mesh

MooseMesh& UpdateDisplacedMeshThread::_ref_mesh
protected

Definition at line 42 of file UpdateDisplacedMeshThread.h.

Referenced by init(), and onNode().

◆ _sys_to_nonghost_and_ghost_soln

std::map<unsigned int, std::pair<const NumericVector<Number> *, std::shared_ptr<NumericVector<Number> > > > UpdateDisplacedMeshThread::_sys_to_nonghost_and_ghost_soln
protected

Definition at line 51 of file UpdateDisplacedMeshThread.h.

Referenced by init(), and onNode().

◆ _sys_to_var_num_and_direction

std::map<unsigned int, std::pair<std::vector<unsigned int>, std::vector<unsigned int> > > UpdateDisplacedMeshThread::_sys_to_var_num_and_direction
private

Definition at line 55 of file UpdateDisplacedMeshThread.h.

Referenced by init(), and onNode().

◆ _tid

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

Definition at line 73 of file ThreadedNodeLoop.h.


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