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

Public Member Functions

 Rotateable ()
 Constructor, initialise rotation to NULL (default) More...
 
void further_build ()
 
void rotate (const unsigned &angle)
 
void rotate_local_coordinates (Vector< double > &s)
 
void output (std::ostream &outfile, const unsigned &nplot)
 
void output_fct (std::ostream &outfile, const unsigned &nplot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
 
void compute_error (std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt, double &error, double &norm)
 
 Rotateable ()
 Constructor, initialise rotation to NULL (default) More...
 
void further_build ()
 
void rotate (const unsigned &angle)
 
void rotate_local_coordinates (Vector< double > &s)
 
void output (std::ostream &outfile, const unsigned &nplot)
 
void output_fct (std::ostream &outfile, const unsigned &nplot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
 
void compute_error (std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt, double &error, double &norm)
 

Private Attributes

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

Detailed Description

template<class ELEMENT>
class Rotateable< ELEMENT >

Class the overloaded RefineablePoissonElements so that the elements that can be rotated about their centre

Constructor & Destructor Documentation

◆ Rotateable() [1/2]

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

Constructor, initialise rotation to NULL (default)

142 : RefineableElement(), ELEMENT(), Rotated(0) { }
unsigned Rotated
Integer to store the rotation angle.
Definition: tree_2d.cc:137
Definition: refineable_elements.h:97

◆ Rotateable() [2/2]

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

Constructor, initialise rotation to NULL (default)

142 : RefineableElement(), ELEMENT(), Rotated(0) { }

Member Function Documentation

◆ compute_error() [1/2]

template<class ELEMENT >
void Rotateable< ELEMENT >::compute_error ( std::ostream &  outfile,
FiniteElement::SteadyExactSolutionFctPt  exact_soln_pt,
double error,
double norm 
)
inline

Error computation stuff Overloaded to be identical under rotation

339 {
340  // Initialise
341  error=0.0;
342  norm=0.0;
343 
344  //Vector of local coordinates
345  Vector<double> s(2);
346 
347  // Vector for coordintes
348  Vector<double> x(2);
349 
350  //Find out how many nodes there are in the element
351  unsigned n_node = this->nnode();
352 
353  Shape psi(n_node);
354 
355  //Set the value of n_intpt
356  unsigned n_intpt = this->integral_pt()->nweight();
357 
358  // Tecplot
359  outfile << "ZONE" << std::endl;
360 
361  // Exact solution Vector (here a scalar)
363 
364  //Loop over the integration points
365  for(unsigned ipt=0;ipt<n_intpt;ipt++)
366  {
367 
368  //Assign values of s
369  for(unsigned i=0;i<2;i++)
370  {
371  s[i] = this->integral_pt()->knot(ipt,i);
372  }
373 
374  //Rotate the coordinates
376 
377  //Get the integral weight
378  double w = this->integral_pt()->weight(ipt);
379 
380  // Get jacobian of mapping
381  double J = this->J_eulerian(s);
382 
383  //Premultiply the weights and the Jacobian
384  double W = w*J;
385 
386  // Get x position as Vector
387  this->interpolated_x(s,x);
388 
389  // Get FE function value
390  double u_fe = this->interpolated_u_poisson(s);
391 
392  // Get exact solution at this point
393  (*exact_soln_pt)(x,exact_soln);
394 
395  //Output x,y,...,error
396  for(unsigned i=0;i<2;i++)
397  {
398  outfile << x[i] << " ";
399  }
400  outfile << exact_soln[0] << " " << exact_soln[0]-u_fe << std::endl;
401 
402  // Add to error and norm
403  norm+=exact_soln[0]*exact_soln[0]*W;
404  error+=(exact_soln[0]-u_fe)*(exact_soln[0]-u_fe)*W;
405  }
406 
407 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
JacobiRotation< float > J
Definition: Jacobi_makeJacobi.cpp:3
RowVector3d w
Definition: Matrix_resize_int.cpp:3
void rotate_local_coordinates(Vector< double > &s)
Definition: tree_2d.cc:223
Definition: shape.h:76
RealScalar s
Definition: level1_cplx_impl.h:130
void exact_soln(const double &time, const Vector< double > &x, Vector< double > &soln)
Definition: unstructured_two_d_curved.cc:301
int error
Definition: calibrate.py:297
@ W
Definition: quadtree.h:63
list x
Definition: plotDoE.py:28

References calibrate::error, ProblemParameters::exact_soln(), i, J, s, w, oomph::QuadTreeNames::W, and plotDoE::x.

◆ compute_error() [2/2]

template<class ELEMENT >
void Rotateable< ELEMENT >::compute_error ( std::ostream &  outfile,
FiniteElement::SteadyExactSolutionFctPt  exact_soln_pt,
double error,
double norm 
)
inline

Error computation stuff Overloaded to be identical under rotation

467 {
468  // Initialise
469  error=0.0;
470  norm=0.0;
471 
472  //Vector of local coordinates
473  Vector<double> s(3);
474 
475  // Vector for coordintes
476  Vector<double> x(3);
477 
478  //Find out how many nodes there are in the element
479  unsigned n_node = this->nnode();
480 
481  Shape psi(n_node);
482 
483  //Set the value of n_intpt
484  unsigned n_intpt = this->integral_pt()->nweight();
485 
486  // Tecplot
487  outfile << "ZONE" << std::endl;
488 
489  // Exact solution Vector (here a scalar)
491 
492  //Loop over the integration points
493  for(unsigned ipt=0;ipt<n_intpt;ipt++)
494  {
495 
496  //Assign values of s
497  for(unsigned i=0;i<3;i++)
498  {
499  s[i] = this->integral_pt()->knot(ipt,i);
500  }
501 
502  //Rotate the local coordinates
504 
505  //Get the integral weight
506  double w = this->integral_pt()->weight(ipt);
507 
508  // Get jacobian of mapping
509  double J = this->J_eulerian(s);
510 
511  //Premultiply the weights and the Jacobian
512  double W = w*J;
513 
514  // Get x position as Vector
515  this->interpolated_x(s,x);
516 
517  // Get FE function value
518  double u_fe = this->interpolated_u_poisson(s);
519 
520  // Get exact solution at this point
521  (*exact_soln_pt)(x,exact_soln);
522 
523  //Output x,y,...,error
524  for(unsigned i=0;i<3;i++)
525  {
526  outfile << x[i] << " ";
527  }
528  outfile << exact_soln[0] << " " << exact_soln[0]-u_fe << std::endl;
529 
530  // Add to error and norm
531  norm+=exact_soln[0]*exact_soln[0]*W;
532  error+=(exact_soln[0]-u_fe)*(exact_soln[0]-u_fe)*W;
533  }
534 
535 }

References calibrate::error, ProblemParameters::exact_soln(), i, J, s, w, oomph::QuadTreeNames::W, and plotDoE::x.

◆ further_build() [1/2]

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

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

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

◆ further_build() [2/2]

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

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

147  {
148  ELEMENT::further_build();
149  this->Rotated = dynamic_cast<Rotateable<ELEMENT>*>
150  (this->father_element_pt())->Rotated;
151  }

◆ output() [1/2]

template<class ELEMENT >
void Rotateable< ELEMENT >::output ( std::ostream &  outfile,
const unsigned nplot 
)
inline

Output function overloaded to produce identical output under rotation

257 {
258  //Vector of local coordinates
259  Vector<double> s(2);
260 
261  // Tecplot header info
262  outfile << this->tecplot_zone_string(nplot);
263 
264  // Loop over plot points
265  unsigned num_plot_points = this->nplot_points(nplot);
266  for (unsigned iplot=0;iplot<num_plot_points;iplot++)
267  {
268 
269  // Get local coordinates of plot point
270  this->get_s_plot(iplot,nplot,s);
271  //Rotate the coordinates
273 
274  for(unsigned i=0;i<2;i++)
275  {
276  outfile << this->interpolated_x(s,i) << " ";
277  }
278  outfile << this->interpolated_u_poisson(s) << std::endl;
279 
280  }
281 
282  // Write tecplot footer (e.g. FE connectivity lists)
283  this->write_tecplot_zone_footer(outfile,nplot);
284 
285 }

References i, and s.

◆ output() [2/2]

template<class ELEMENT >
void Rotateable< ELEMENT >::output ( std::ostream &  outfile,
const unsigned nplot 
)
inline

Output function overloaded to produce identical output under rotation

385 {
386  //Vector of local coordinates
387  Vector<double> s(3);
388 
389  // Tecplot header info
390  outfile << this->tecplot_zone_string(nplot);
391 
392  // Loop over plot points
393  unsigned num_plot_points = this->nplot_points(nplot);
394  for (unsigned iplot=0;iplot<num_plot_points;iplot++)
395  {
396 
397  // Get local coordinates of plot point
398  this->get_s_plot(iplot,nplot,s);
399  //Rotate the local coordinates
401  //Print the output
402  for(unsigned i=0;i<3;i++)
403  {
404  outfile << this->interpolated_x(s,i) << " ";
405  }
406  outfile << this->interpolated_u_poisson(s) << std::endl;
407 
408  }
409 
410  // Write tecplot footer (e.g. FE connectivity lists)
411  this->write_tecplot_zone_footer(outfile,nplot);
412 
413 }

References i, and s.

◆ output_fct() [1/2]

template<class ELEMENT >
void Rotateable< ELEMENT >::output_fct ( std::ostream &  outfile,
const unsigned nplot,
FiniteElement::SteadyExactSolutionFctPt  exact_soln_pt 
)
inline

Output exact solution: Overloaded to produce identical output under rotation

292 {
293  //Vector of local coordinates
294  Vector<double> s(2);
295 
296  // Vector for coordintes
297  Vector<double> x(2);
298 
299  // Tecplot header info
300  outfile << this->tecplot_zone_string(nplot);
301 
302  // Exact solution Vector (here a scalar)
304 
305  // Loop over plot points
306  unsigned num_plot_points = this->nplot_points(nplot);
307  for (unsigned iplot=0;iplot<num_plot_points;iplot++)
308  {
309 
310  // Get local coordinates of plot point
311  this->get_s_plot(iplot,nplot,s);
312  //Rotate the coordinates
314 
315  // Get x position as Vector
316  this->interpolated_x(s,x);
317 
318  // Get exact solution at this point
319  (*exact_soln_pt)(x,exact_soln);
320 
321  //Output x,y,...,u_exact
322  for(unsigned i=0;i<2;i++)
323  {
324  outfile << x[i] << " ";
325  }
326  outfile << exact_soln[0] << std::endl;
327  }
328 
329  // Write tecplot footer (e.g. FE connectivity lists)
330  this->write_tecplot_zone_footer(outfile,nplot);
331 }

References ProblemParameters::exact_soln(), i, s, and plotDoE::x.

◆ output_fct() [2/2]

template<class ELEMENT >
void Rotateable< ELEMENT >::output_fct ( std::ostream &  outfile,
const unsigned nplot,
FiniteElement::SteadyExactSolutionFctPt  exact_soln_pt 
)
inline

Output exact solution: Overloaded to produce identical output under rotation

420 {
421  //Vector of local coordinates
422  Vector<double> s(3);
423 
424  // Vector for coordintes
425  Vector<double> x(3);
426 
427  // Tecplot header info
428  outfile << this->tecplot_zone_string(nplot);
429 
430  // Exact solution Vector (here a scalar)
432 
433  // Loop over plot points
434  unsigned num_plot_points = this->nplot_points(nplot);
435  for (unsigned iplot=0;iplot<num_plot_points;iplot++)
436  {
437 
438  // Get local coordinates of plot point
439  this->get_s_plot(iplot,nplot,s);
440  //Rotate the local coordinates
442 
443  // Get x position as Vector
444  this->interpolated_x(s,x);
445 
446  // Get exact solution at this point
447  (*exact_soln_pt)(x,exact_soln);
448 
449  //Output x,y,...,u_exact
450  for(unsigned i=0;i<3;i++)
451  {
452  outfile << x[i] << " ";
453  }
454  outfile << exact_soln[0] << std::endl;
455  }
456 
457  // Write tecplot footer (e.g. FE connectivity lists)
458  this->write_tecplot_zone_footer(outfile,nplot);
459 }

References ProblemParameters::exact_soln(), i, s, and plotDoE::x.

◆ rotate() [1/2]

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

Rotate the element by a given angle: 0 (0), 1(90 degrees), 2(180 degrees), 3 (270 degrees)

157  {
158  //Get the nodes and make a copy
159  unsigned n_node = this->nnode();
160  Vector<Node*> elemental_nodes_pt(n_node);
161  for(unsigned n=0;n<n_node;n++)
162  {
163  elemental_nodes_pt[n] = this->node_pt(n);
164  }
165 
166  //We now merely permute the nodes
167  unsigned n_p = this->nnode_1d();
168  //The permutation depends on the angle
169  switch(angle)
170  {
171  //No permutation
172  case 0:
173  Rotated = 0;
174  break;
175 
176  //Rotation by 90 degrees (i and j are swapped and i is reversed)
177  case 1:
178  Rotated = 1;
179  for(unsigned i=0;i<n_p;i++)
180  {
181  for(unsigned j=0;j<n_p;j++)
182  {
183  this->node_pt(i + j*n_p)
184  = elemental_nodes_pt[j + n_p*(n_p-1-i)];
185  }
186  }
187  break;
188 
189  //Rotation by 180 degrees (i and j are reversed)
190  case 2:
191  Rotated = 2;
192  for(unsigned i=0;i<n_p;i++)
193  {
194  for(unsigned j=0;j<n_p;j++)
195  {
196  this->node_pt(i + j*n_p)
197  = elemental_nodes_pt[(n_p-1-i) + n_p*(n_p-1-j)];
198  }
199  }
200  break;
201 
202  //Rotation by 270 degrees (i and j are swapped and new j is reversed)
203  case 3:
204  Rotated = 3;
205  for(unsigned i=0;i<n_p;i++)
206  {
207  for(unsigned j=0;j<n_p;j++)
208  {
209  this->node_pt(i + j*n_p)
210  = elemental_nodes_pt[(n_p-1-j) + n_p*i];
211  }
212  }
213  break;
214 
215  default:
216  Rotated = 0;
217  }
218  }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
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, and n.

◆ rotate() [2/2]

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

Rotate the element by a given angle: 0 (0), 1(90 degrees), 2(180 degrees), 3 (270 degrees)

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

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

◆ rotate_local_coordinates() [1/2]

template<class ELEMENT >
void 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

224  {
225  //Rotated coordinates
226  Vector<double> s_rot(2);
227  //Do the four different cases
228  switch(Rotated)
229  {
230  case 0:
231  s_rot[0] = s[0]; s_rot[1] = s[1];
232  break;
233 
234  case 1:
235  s_rot[0] = -s[1]; s_rot[1] = s[0];
236  break;
237 
238  case 2:
239  s_rot[0] = -s[0]; s_rot[1] = -s[1];
240  break;
241 
242  case 3:
243  s_rot[0] = s[1]; s_rot[1] = -s[0];
244  break;
245  }
246 
247  //Now do the rotation
248  s[0] = s_rot[0]; s[1] = s_rot[1];
249  }

References s.

◆ rotate_local_coordinates() [2/2]

template<class ELEMENT >
void 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

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

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: