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 19 of file RigidBodyModes3D.h.

Constructor & Destructor Documentation

RigidBodyModes3D::RigidBodyModes3D ( const InputParameters &  parameters)

Definition at line 50 of file RigidBodyModes3D.C.

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

void RigidBodyModes3D::execute ( )
virtual

This function will get called on each node.

Definition at line 115 of file RigidBodyModes3D.C.

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

Definition at line 206 of file RigidBodyModes3D.C.

Referenced by threadJoin().

207 {
208  // Close the basis vectors
209  NonlinearSystemBase & nl = _fe_problem.getNonlinearSystemBase();
210  for (unsigned int i = 0; i < _subspace_indices.size(); ++i)
211  {
212  std::stringstream postfix;
213  postfix << "_" << _subspace_indices[i];
214  NumericVector<Number> & mode = nl.getVector(_subspace_name + postfix.str());
215  mode.close();
216  }
217 }
std::string _subspace_name
std::vector< unsigned int > _subspace_indices
virtual void RigidBodyModes3D::initialize ( )
inlinevirtual

Definition at line 29 of file RigidBodyModes3D.h.

29 {};
virtual void RigidBodyModes3D::threadJoin ( const UserObject &  )
inlinevirtual

Definition at line 30 of file RigidBodyModes3D.h.

30 {};

Member Data Documentation

unsigned int RigidBodyModes3D::_disp_x_i
protected

Definition at line 37 of file RigidBodyModes3D.h.

Referenced by execute().

unsigned int RigidBodyModes3D::_disp_y_i
protected

Definition at line 38 of file RigidBodyModes3D.h.

Referenced by execute().

unsigned int RigidBodyModes3D::_disp_z_i
protected

Definition at line 39 of file RigidBodyModes3D.h.

Referenced by execute().

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

Definition at line 36 of file RigidBodyModes3D.h.

Referenced by execute(), and RigidBodyModes3D().

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

Definition at line 35 of file RigidBodyModes3D.h.

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

std::string RigidBodyModes3D::_subspace_name
protected

Definition at line 34 of file RigidBodyModes3D.h.

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


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