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

#include <RigidBodyModes3D.h>

Inheritance diagram for RigidBodyModes3D:
[legend]

Public Member Functions

 RigidBodyModes3D (const InputParameters &parameters)
 
virtual void execute ()
 This function will get called on each node. More...
 
virtual void initialize ()
 
virtual void threadJoin (const UserObject &)
 
virtual void finalize ()
 

Protected Attributes

std::string _subspace_name
 
std::vector< unsigned int > _subspace_indices
 
std::set< std::string > _modes
 
unsigned int _disp_x_i
 
unsigned int _disp_y_i
 
unsigned int _disp_z_i
 

Detailed Description

Definition at line 21 of file RigidBodyModes3D.h.

Constructor & Destructor Documentation

◆ RigidBodyModes3D()

RigidBodyModes3D::RigidBodyModes3D ( const InputParameters &  parameters)

Definition at line 54 of file RigidBodyModes3D.C.

55  : NodalUserObject(parameters),
56  _subspace_name(parameters.get<std::string>("subspace_name")),
57  _subspace_indices(parameters.get<std::vector<unsigned int>>("subspace_indices")),
58  _modes(parameters.get<std::vector<std::string>>("modes").begin(),
59  parameters.get<std::vector<std::string>>("modes").end()),
60  _disp_x_i(coupled("disp_x")),
61  _disp_y_i(coupled("disp_y")),
62  _disp_z_i(coupled("disp_z"))
63 {
64  const char * all_modes_array[6] = {"trans_x", "trans_y", "trans_z", "rot_x", "rot_y", "rot_z"};
65  std::set<std::string> all_modes(all_modes_array, all_modes_array + 6);
66  if (_modes.size() == 0)
67  _modes = all_modes;
68  if (_modes.size() > 6)
69  {
70  std::stringstream err;
71  err << "Expected between 0 and 6 rigid body modes, got " << _modes.size() << " instead\n";
72  mooseError(err.str());
73  }
74  for (std::set<std::string>::const_iterator it = _modes.begin(); it != _modes.end(); ++it)
75  {
76  if (all_modes.find(*it) == all_modes.end())
77  {
78  std::stringstream err;
79  err << "Invalid 3D rigid body mode " << *it << "; must be one of: ";
80  for (std::set<std::string>::iterator it = all_modes.begin(); it != all_modes.end(); ++it)
81  {
82  if (it != all_modes.begin())
83  err << ", ";
84  err << *it;
85  }
86  err << "\n";
87  mooseError(err.str());
88  }
89  }
90 
91  if (!_subspace_indices.size())
92  {
93  _subspace_indices = std::vector<unsigned int>(_fe_problem.subspaceDim(_subspace_name));
94  for (unsigned int i = 0; i < _fe_problem.subspaceDim(_subspace_name); ++i)
95  _subspace_indices[i] = i;
96  }
97  if (_subspace_indices.size() != _modes.size())
98  {
99  std::stringstream err;
100  err << "Number of subspace indices " << _subspace_indices.size()
101  << " must match the number or rigid body modes " << _modes.size() << "\n";
102  mooseError(err.str());
103  }
104 
105  for (unsigned int i = 0; i < _subspace_indices.size(); ++i)
106  {
107  unsigned int subspace_dim = _fe_problem.subspaceDim(_subspace_name);
108  if (_subspace_indices[i] >= subspace_dim)
109  {
110  std::stringstream err;
111  err << "Invalid " << i << "-th " << _subspace_name << " index " << _subspace_indices[i]
112  << "; must be < " << _fe_problem.subspaceDim(_subspace_name) << "\n";
113  mooseError(err.str());
114  }
115  }
116 }
std::set< std::string > _modes
unsigned int _disp_z_i
std::string _subspace_name
std::vector< unsigned int > _subspace_indices
unsigned int _disp_x_i
unsigned int _disp_y_i

Member Function Documentation

◆ execute()

void RigidBodyModes3D::execute ( )
virtual

This function will get called on each node.

Definition at line 119 of file RigidBodyModes3D.C.

120 {
121  // Set the appropriate dof of the selectedrigid body vectors
122  // Currently this only works for Lagrange displacement variables!
123  NonlinearSystemBase & nl = _fe_problem.getNonlinearSystemBase();
124  const Node & node = *_current_node;
125  unsigned int i = 0;
126  // x-displacement mode
127  if (_modes.count("trans_x"))
128  {
129  std::stringstream postfix;
130  postfix << "_" << _subspace_indices[i++];
131  NumericVector<Number> & mode = nl.getVector(_subspace_name + postfix.str());
132  unsigned int xdof = node.dof_number(nl.number(), _disp_x_i, 0);
133  mode.set(xdof, 1.0);
134  unsigned int ydof = node.dof_number(nl.number(), _disp_y_i, 0);
135  mode.set(ydof, 0.0);
136  unsigned int zdof = node.dof_number(nl.number(), _disp_z_i, 0);
137  mode.set(zdof, 0.0);
138  }
139  // y-displacement mode
140  if (_modes.count("trans_y"))
141  {
142  std::stringstream postfix;
143  postfix << "_" << _subspace_indices[i++];
144  NumericVector<Number> & mode = nl.getVector(_subspace_name + postfix.str());
145  unsigned int xdof = node.dof_number(nl.number(), _disp_x_i, 0);
146  mode.set(xdof, 0.0);
147  unsigned int ydof = node.dof_number(nl.number(), _disp_y_i, 0);
148  mode.set(ydof, 1.0);
149  unsigned int zdof = node.dof_number(nl.number(), _disp_z_i, 0);
150  mode.set(zdof, 0.0);
151  }
152  // z-displacement mode
153  if (_modes.count("trans_z"))
154  {
155  std::stringstream postfix;
156  postfix << "_" << _subspace_indices[i++];
157  NumericVector<Number> & mode = nl.getVector(_subspace_name + postfix.str());
158  unsigned int xdof = node.dof_number(nl.number(), _disp_x_i, 0);
159  mode.set(xdof, 0.0);
160  unsigned int ydof = node.dof_number(nl.number(), _disp_y_i, 0);
161  mode.set(ydof, 0.0);
162  unsigned int zdof = node.dof_number(nl.number(), _disp_z_i, 0);
163  mode.set(zdof, 1.0);
164  }
165  // x-axis rotation mode
166  if (_modes.count("rot_x"))
167  {
168  std::stringstream postfix;
169  postfix << "_" << _subspace_indices[i++];
170  NumericVector<Number> & mode = nl.getVector(_subspace_name + postfix.str());
171  Real y = node(1), z = node(2);
172  unsigned int xdof = node.dof_number(nl.number(), _disp_x_i, 0);
173  mode.set(xdof, 0.0);
174  unsigned int ydof = node.dof_number(nl.number(), _disp_y_i, 0);
175  mode.set(ydof, -z);
176  unsigned int zdof = node.dof_number(nl.number(), _disp_z_i, 0);
177  mode.set(zdof, y);
178  }
179  // y-axis rotation mode
180  if (_modes.count("rot_y"))
181  {
182  std::stringstream postfix;
183  postfix << "_" << _subspace_indices[i++];
184  NumericVector<Number> & mode = nl.getVector(_subspace_name + postfix.str());
185  Real x = node(0), z = node(2);
186  unsigned int xdof = node.dof_number(nl.number(), _disp_x_i, 0);
187  mode.set(xdof, z);
188  unsigned int ydof = node.dof_number(nl.number(), _disp_y_i, 0);
189  mode.set(ydof, 0);
190  unsigned int zdof = node.dof_number(nl.number(), _disp_z_i, 0);
191  mode.set(zdof, -x);
192  }
193  // z-axis rotation mode
194  if (_modes.count("rot_z"))
195  {
196  std::stringstream postfix;
197  postfix << "_" << _subspace_indices[i++];
198  NumericVector<Number> & mode = nl.getVector(_subspace_name + postfix.str());
199  Real x = node(0), y = node(1);
200  unsigned int xdof = node.dof_number(nl.number(), _disp_x_i, 0);
201  mode.set(xdof, -y);
202  unsigned int ydof = node.dof_number(nl.number(), _disp_y_i, 0);
203  mode.set(ydof, x);
204  unsigned int zdof = node.dof_number(nl.number(), _disp_z_i, 0);
205  mode.set(zdof, 0);
206  }
207 }
std::set< std::string > _modes
unsigned int _disp_z_i
std::string _subspace_name
std::vector< unsigned int > _subspace_indices
unsigned int _disp_x_i
unsigned int _disp_y_i

◆ finalize()

void RigidBodyModes3D::finalize ( )
virtual

Definition at line 210 of file RigidBodyModes3D.C.

211 {
212  // Close the basis vectors
213  NonlinearSystemBase & nl = _fe_problem.getNonlinearSystemBase();
214  for (unsigned int i = 0; i < _subspace_indices.size(); ++i)
215  {
216  std::stringstream postfix;
217  postfix << "_" << _subspace_indices[i];
218  NumericVector<Number> & mode = nl.getVector(_subspace_name + postfix.str());
219  mode.close();
220  }
221 }
std::string _subspace_name
std::vector< unsigned int > _subspace_indices

◆ initialize()

virtual void RigidBodyModes3D::initialize ( )
inlinevirtual

Definition at line 31 of file RigidBodyModes3D.h.

31 {};

◆ threadJoin()

virtual void RigidBodyModes3D::threadJoin ( const UserObject &  )
inlinevirtual

Definition at line 32 of file RigidBodyModes3D.h.

32 {};

Member Data Documentation

◆ _disp_x_i

unsigned int RigidBodyModes3D::_disp_x_i
protected

Definition at line 39 of file RigidBodyModes3D.h.

Referenced by execute().

◆ _disp_y_i

unsigned int RigidBodyModes3D::_disp_y_i
protected

Definition at line 40 of file RigidBodyModes3D.h.

Referenced by execute().

◆ _disp_z_i

unsigned int RigidBodyModes3D::_disp_z_i
protected

Definition at line 41 of file RigidBodyModes3D.h.

Referenced by execute().

◆ _modes

std::set<std::string> RigidBodyModes3D::_modes
protected

Definition at line 38 of file RigidBodyModes3D.h.

Referenced by execute(), and RigidBodyModes3D().

◆ _subspace_indices

std::vector<unsigned int> RigidBodyModes3D::_subspace_indices
protected

Definition at line 37 of file RigidBodyModes3D.h.

Referenced by execute(), finalize(), and RigidBodyModes3D().

◆ _subspace_name

std::string RigidBodyModes3D::_subspace_name
protected

Definition at line 36 of file RigidBodyModes3D.h.

Referenced by execute(), finalize(), and RigidBodyModes3D().


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