oomph::Rotateable< ELEMENT > Class Template Reference
+ Inheritance diagram for oomph::Rotateable< ELEMENT >:

Public Member Functions

 Rotateable ()
 Constructor, initialise rotation to zero (default) More...
 
void further_build ()
 
void rotate (const unsigned &angle)
 Rotate the element. More...
 
void rotate_local_coordinates (Vector< double > &s)
 

Private Attributes

unsigned Rotated
 Integer to store the rotation angle. More...
 

Detailed Description

template<class ELEMENT>
class oomph::Rotateable< ELEMENT >

Class to overload an refineable QElement<3,...> so that it can be rotated about its centre.

Constructor & Destructor Documentation

◆ Rotateable()

template<class ELEMENT >
oomph::Rotateable< ELEMENT >::Rotateable ( )
inline

Constructor, initialise rotation to zero (default)

144 : RefineableElement(), ELEMENT(), Rotated(0) { }
Definition: refineable_elements.h:97
unsigned Rotated
Integer to store the rotation angle.
Definition: octree_test.cc:139

Member Function Documentation

◆ further_build()

template<class ELEMENT >
void oomph::Rotateable< ELEMENT >::further_build ( )
inline

Overload the further build function to pass the rotate information to the sons

150  {
151  ELEMENT::further_build();
152  this->Rotated = dynamic_cast<Rotateable<ELEMENT>*>
153  (this->father_element_pt())->Rotated;
154  }
Definition: octree_test.cc:135

◆ rotate()

template<class ELEMENT >
void oomph::Rotateable< ELEMENT >::rotate ( const unsigned angle)
inline

Rotate the element.

159  {
160  Rotated = angle;
161  //Get the nodes and make a copy
162  unsigned n_node = this->nnode();
163  Vector<Node*> elemental_nodes_pt(n_node);
164  for(unsigned n=0;n<n_node;n++)
165  {
166  elemental_nodes_pt[n] = this->node_pt(n);
167  }
168 
169  //Face rotation four possibilities
170  unsigned face_rot = angle%4;
171 
172  //We now merely permute the nodes
173  unsigned n_p = this->nnode_1d();
174  //The permutation depends on the angle
175  switch(face_rot)
176  {
177  //FIRST WE JUST ROTATE ABOUT THE Z-AXIS
178  //No permutation
179  case 0:
180  break;
181 
182  //Rotation by 90 degrees (i and j are swapped and i is reversed)
183  case 1:
184  for(unsigned i=0;i<n_p;i++)
185  {
186  for(unsigned j=0;j<n_p;j++)
187  {
188  for(unsigned k=0;k<n_p;k++)
189  {
190  this->node_pt(i + j*n_p + k*n_p*n_p)
191  = elemental_nodes_pt[j + n_p*(n_p-1-i) + k*n_p*n_p];
192  }
193  }
194  }
195  break;
196 
197  //Rotation by 180 degrees (i and j are reversed)
198  case 2:
199  for(unsigned i=0;i<n_p;i++)
200  {
201  for(unsigned j=0;j<n_p;j++)
202  {
203  for(unsigned k=0;k<n_p;k++)
204  {
205  this->node_pt(i + j*n_p + k*n_p*n_p)
206  = elemental_nodes_pt[(n_p-1-i) + n_p*(n_p-1-j) + k*n_p*n_p];
207  }
208  }
209  }
210  break;
211 
212  //Rotation by 270 degrees (i and j are swapped and j is reversed)
213  case 3:
214  for(unsigned i=0;i<n_p;i++)
215  {
216  for(unsigned j=0;j<n_p;j++)
217  {
218  for(unsigned k=0;k<n_p;k++)
219  {
220  this->node_pt(i + j*n_p + k*n_p*n_p)
221  = elemental_nodes_pt[(n_p-1-j) + n_p*i + k*n_p*n_p];
222  }
223  }
224  }
225  break;
226  }
227 
228  //Now get the nodes again, after the first rotation
229  for(unsigned n=0;n<n_node;n++)
230  {
231  elemental_nodes_pt[n] = this->node_pt(n);
232  }
233 
234  //We now perform the second rotation to move the face into position
235  unsigned body_rot = angle/4;
236  switch(body_rot)
237  {
238  //No permutation
239  case 0:
240  break;
241 
242  //ROTATE ABOUT X-AXIS
243  //Rotation by 90 degrees (k and j are swapped and k is reversed)
244  case 1:
245  for(unsigned i=0;i<n_p;i++)
246  {
247  for(unsigned j=0;j<n_p;j++)
248  {
249  for(unsigned k=0;k<n_p;k++)
250  {
251  this->node_pt(i + j*n_p + k*n_p*n_p)
252  = elemental_nodes_pt[i + n_p*(n_p-1-k) + j*n_p*n_p];
253  }
254  }
255  }
256  break;
257 
258  //Rotation by 180 degrees (k and j are reversed)
259  case 2:
260  for(unsigned i=0;i<n_p;i++)
261  {
262  for(unsigned j=0;j<n_p;j++)
263  {
264  for(unsigned k=0;k<n_p;k++)
265  {
266  this->node_pt(i + j*n_p + k*n_p*n_p)
267  = elemental_nodes_pt[i + n_p*(n_p-1-j) + (n_p-1-k)*n_p*n_p];
268  }
269  }
270  }
271  break;
272 
273  //Rotation by 270 degrees (k and j are swapped and j is reversed)
274  case 3:
275  for(unsigned i=0;i<n_p;i++)
276  {
277  for(unsigned j=0;j<n_p;j++)
278  {
279  for(unsigned k=0;k<n_p;k++)
280  {
281  this->node_pt(i + j*n_p + k*n_p*n_p)
282  = elemental_nodes_pt[i + n_p*k + (n_p-1-j)*n_p*n_p];
283  }
284  }
285  }
286  break;
287 
288  //ROTATE ABOUT Y-AXIS
289  //Rotation by 90 degrees (i and k are swapped and i is reversed)
290  case 4:
291  for(unsigned i=0;i<n_p;i++)
292  {
293  for(unsigned j=0;j<n_p;j++)
294  {
295  for(unsigned k=0;k<n_p;k++)
296  {
297  this->node_pt(i + j*n_p + k*n_p*n_p)
298  = elemental_nodes_pt[k + n_p*j + (n_p-1-i)*n_p*n_p];
299  }
300  }
301  }
302  break;
303 
304  //Rotation by 270 degrees (i and k are swapped and k is reversed)
305  case 5:
306  for(unsigned i=0;i<n_p;i++)
307  {
308  for(unsigned j=0;j<n_p;j++)
309  {
310  for(unsigned k=0;k<n_p;k++)
311  {
312  this->node_pt(i + j*n_p + k*n_p*n_p)
313  = elemental_nodes_pt[(n_p-1-k) + n_p*j + i*n_p*n_p];
314  }
315  }
316  }
317  break;
318  }
319  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
char char char int int * k
Definition: level2_impl.h:374
double angle(const double &t)
Angular position as a function of time t.
Definition: jeffery_orbit.cc:98
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References Jeffery_Solution::angle(), i, j, k, and n.

◆ rotate_local_coordinates()

template<class ELEMENT >
void oomph::Rotateable< ELEMENT >::rotate_local_coordinates ( Vector< double > &  s)
inline

Rotate the local coordinates so that that output is will be consistent, irrespective of the rotation of the element

324  {
325  //Now rotate about the face
326  Vector<double> s_rot(3);
327  unsigned face_rot = Rotated%4;
328  switch(face_rot)
329  {
330  case 0:
331  s_rot[0] = s[0]; s_rot[1] = s[1]; s_rot[2] = s[2];
332  break;
333 
334  case 1:
335  s_rot[0] = -s[1]; s_rot[1] = s[0]; s_rot[2] = s[2];
336  break;
337 
338  case 2:
339  s_rot[0] = -s[0]; s_rot[1] = -s[1]; s_rot[2] = s[2];
340  break;
341 
342  case 3:
343  s_rot[0] = s[1]; s_rot[1] = -s[0]; s_rot[2] = s[2];
344  break;
345  }
346 
347  //Rotate the face into position
348  unsigned body_rot = Rotated/4;
349  Vector<double> s_rot2(3);
350  switch(body_rot)
351  {
352  case 0:
353  s_rot2[0] = s_rot[0]; s_rot2[1] = s_rot[1]; s_rot2[2] = s_rot[2];
354  break;
355 
356  case 1:
357  s_rot2[0] = s_rot[0]; s_rot2[1] = s_rot[2]; s_rot2[2] = -s_rot[1];
358  break;
359 
360  case 2:
361  s_rot2[0] = s_rot[0]; s_rot2[1] = -s_rot[1]; s_rot2[2] = -s_rot[2];
362  break;
363 
364  case 3:
365  s_rot2[0] = s_rot[0]; s_rot2[1] = -s_rot[2]; s_rot2[2] = s_rot[1];
366  break;
367 
368  case 4:
369  s_rot2[0] = -s_rot[2]; s_rot2[1] = s_rot[1]; s_rot2[2] = s_rot[0];
370  break;
371 
372  case 5:
373  s_rot2[0] = s_rot[2]; s_rot2[1] = s_rot[1]; s_rot2[2] = -s_rot[0];
374  break;
375  }
376 
377  //Set the input to the rotated coordinate
378  s[0] = s_rot2[0]; s[1] = s_rot2[1]; s[2] = s_rot2[2];
379  }
RealScalar s
Definition: level1_cplx_impl.h:130

References s.

Member Data Documentation

◆ Rotated

template<class ELEMENT >
unsigned Rotateable< ELEMENT >::Rotated
private

Integer to store the rotation angle.


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