quarter_tube_mesh.template.h
Go to the documentation of this file.
1 // LIC// ====================================================================
2 // LIC// This file forms part of oomph-lib, the object-oriented,
3 // LIC// multi-physics finite-element library, available
4 // LIC// at http://www.oomph-lib.org.
5 // LIC//
6 // LIC// Copyright (C) 2006-2022 Matthias Heil and Andrew Hazel
7 // LIC//
8 // LIC// This library is free software; you can redistribute it and/or
9 // LIC// modify it under the terms of the GNU Lesser General Public
10 // LIC// License as published by the Free Software Foundation; either
11 // LIC// version 2.1 of the License, or (at your option) any later version.
12 // LIC//
13 // LIC// This library is distributed in the hope that it will be useful,
14 // LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // LIC// Lesser General Public License for more details.
17 // LIC//
18 // LIC// You should have received a copy of the GNU Lesser General Public
19 // LIC// License along with this library; if not, write to the Free Software
20 // LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 // LIC// 02110-1301 USA.
22 // LIC//
23 // LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
24 // LIC//
25 // LIC//====================================================================
26 #ifndef OOMPH_QUARTER_TUBE_MESH_HEADER
27 #define OOMPH_QUARTER_TUBE_MESH_HEADER
28 
29 // Headers
30 #include "../generic/refineable_brick_mesh.h"
31 #include "../generic/macro_element.h"
32 #include "../generic/domain.h"
33 #include "../generic/algebraic_elements.h"
34 #include "../generic/brick_mesh.h"
35 #include "../generic/macro_element_node_update_element.h"
36 
37 
38 // Include the headers file for domain
39 #include "quarter_tube_domain.h"
40 
41 namespace oomph
42 {
43  //====================================================================
62  //====================================================================
63  template<class ELEMENT>
64  class QuarterTubeMesh : public virtual BrickMeshBase
65  {
66  public:
73  const Vector<double>& xi_lo,
74  const double& fract_mid,
75  const Vector<double>& xi_hi,
76  const unsigned& nlayer,
77  TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper);
78 
80  virtual ~QuarterTubeMesh()
81  {
82  delete Domain_pt;
83  }
84 
87  {
88  return Wall_pt;
89  }
90 
93  {
94  return Domain_pt;
95  }
96 
102  {
103  return Domain_pt->bl_squash_fct_pt();
104  }
105 
106 
109  {
111  }
112 
115  {
116  return Domain_pt;
117  }
118 
119  protected:
122 
125 
128 
130  double Fract_mid;
131 
134  };
135 
136 
140 
141 
142  //=============================================================
157  //=============================================================
158  template<class ELEMENT>
159  class RefineableQuarterTubeMesh : public virtual QuarterTubeMesh<ELEMENT>,
160  public RefineableBrickMesh<ELEMENT>
161 
162  {
163  public:
173  const Vector<double>& xi_lo,
174  const double& fract_mid,
175  const Vector<double>& xi_hi,
176  const unsigned& nlayer,
177  TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
178  : QuarterTubeMesh<ELEMENT>(
179  wall_pt, xi_lo, fract_mid, xi_hi, nlayer, time_stepper_pt)
180  {
181  // Loop over all elements and set macro element pointer
182  for (unsigned ielem = 0; ielem < QuarterTubeMesh<ELEMENT>::nelement();
183  ielem++)
184  {
185  dynamic_cast<RefineableQElement<3>*>(
187  ->set_macro_elem_pt(this->Domain_pt->macro_element_pt(ielem));
188  }
189 
190 
191  // Setup Octree forest: Turn elements into individual octrees
192  // and plant in forest
193  Vector<TreeRoot*> trees_pt;
194  for (unsigned iel = 0; iel < QuarterTubeMesh<ELEMENT>::nelement(); iel++)
195  {
197  ELEMENT* ref_el_pt = dynamic_cast<ELEMENT*>(el_pt);
198  OcTreeRoot* octree_root_pt = new OcTreeRoot(ref_el_pt);
199  trees_pt.push_back(octree_root_pt);
200  }
201  this->Forest_pt = new OcTreeForest(trees_pt);
202 
203 #ifdef PARANOID
204  // Run self test
205  unsigned success_flag =
206  dynamic_cast<OcTreeForest*>(this->Forest_pt)->self_test();
207  if (success_flag == 0)
208  {
209  oomph_info << "Successfully built octree forest " << std::endl;
210  }
211  else
212  {
213  throw OomphLibError("Trouble in building octree forest ",
216  }
217 #endif
218  }
219 
222  };
223 
224 
227  // MacroElementNodeUpdate-version of RefineableQuarterTubeMesh
230 
231  class MacroElementNodeUpdateNode;
232 
233  //========================================================================
235  //========================================================================
236  template<class ELEMENT>
238  : public virtual MacroElementNodeUpdateMesh,
239  public virtual RefineableQuarterTubeMesh<ELEMENT>
240  {
241  public:
251  const Vector<double>& xi_lo,
252  const double& fract_mid,
253  const Vector<double>& xi_hi,
254  const unsigned& nlayer,
255  TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
257  RefineableQuarterTubeMesh<ELEMENT>(
258  wall_pt, xi_lo, fract_mid, xi_hi, nlayer, time_stepper_pt),
259  QuarterTubeMesh<ELEMENT>(
260  wall_pt, xi_lo, fract_mid, xi_hi, nlayer, time_stepper_pt)
261  {
262 #ifdef PARANOID
263  ELEMENT* el_pt = new ELEMENT;
264  if (dynamic_cast<MacroElementNodeUpdateElementBase*>(el_pt) == 0)
265  {
266  std::ostringstream error_message;
267  error_message << "Base class for ELEMENT in "
268  << "MacroElementNodeUpdateRefineableQuarterTubeMesh needs"
269  << "to be of type MacroElementNodeUpdateElement!\n";
270  error_message << "Whereas it is: typeid(el_pt).name()"
271  << typeid(el_pt).name() << std::endl;
272 
273  std::string function_name =
274  "MacroElementNodeUpdateRefineableQuaterCircleSectorMesh::\n";
275  function_name +=
276  "MacroElementNodeUpdateRefineableQuaterCircleSectorMesh()";
277 
278  throw OomphLibError(error_message.str(),
281  }
282  delete el_pt;
283 #endif
284 
285  // Setup all the information that's required for MacroElement-based
286  // node update: Tell the elements that their geometry depends on the
287  // fishback geometric object
289  }
290 
293 
299  void node_update(const bool& update_all_solid_nodes = false)
300  {
301 #ifdef PARANOID
302  if (update_all_solid_nodes)
303  {
304  std::string error_message =
305  "Doesn't make sense to use an MacroElementNodeUpdateMesh with\n";
306  error_message +=
307  "SolidElements so specifying update_all_solid_nodes=true\n";
308  error_message += "doesn't make sense either\n";
309 
310  std::string function_name =
311  "MacroElementNodeUpdateRefineableQuaterCircleSectorMesh::\n";
312  function_name += "node_update()";
313 
314  throw OomphLibError(
316  }
317 #endif
319  }
320 
321  private:
326  {
327  unsigned n_element = this->nelement();
328  for (unsigned i = 0; i < n_element; i++)
329  {
330  // Upcast from FiniteElement to the present element
331  ELEMENT* el_pt = dynamic_cast<ELEMENT*>(this->element_pt(i));
332 
333 #ifdef PARANOID
334  // Check if cast is successful
336  dynamic_cast<MacroElementNodeUpdateElementBase*>(el_pt);
337  if (m_el_pt == 0)
338  {
339  std::ostringstream error_message;
340  error_message
341  << "Failed to upcast to MacroElementNodeUpdateElementBase\n";
342  error_message << "Element must be derived from "
343  "MacroElementNodeUpdateElementBase\n";
344  error_message << "but it is of type " << typeid(el_pt).name();
345 
346  std::string function_name =
347  "MacroElementNodeUpdateRefineableQuaterCircleSectorMesh::\n";
348  function_name += "setup_macro_element_node_update()";
349 
350  throw OomphLibError(error_message.str(),
353  }
354 #endif
355  // There's just one GeomObject
356  Vector<GeomObject*> geom_object_pt(1);
357  geom_object_pt[0] = this->Wall_pt;
358 
359  // Tell the element which geom objects its macro-element-based
360  // node update depends on
361  el_pt->set_node_update_info(geom_object_pt);
362  }
363 
364  // Add the geometric object(s) for the wall to the mesh's storage
365  Vector<GeomObject*> geom_object_pt(1);
366  geom_object_pt[0] = this->Wall_pt;
368 
369  // Fill in the domain pointer to the mesh's storage in the base class
371  }
372  };
373 
374 
375  //======================================================================
377  //=====================================================================
378 
379 
380  //====================================================================
394  //====================================================================
395 
396 
397  //========================================================================
434  //========================================================================
435  template<class ELEMENT>
437  : public virtual AlgebraicMesh,
438  public RefineableQuarterTubeMesh<ELEMENT>
439  {
440  public:
450  const Vector<double>& xi_lo,
451  const double& fract_mid,
452  const Vector<double>& xi_hi,
453  const unsigned& nlayer,
454  const double centre_box_size = 1.0,
455  TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
456  : QuarterTubeMesh<ELEMENT>(
457  wall_pt, xi_lo, fract_mid, xi_hi, nlayer, time_stepper_pt),
458  RefineableQuarterTubeMesh<ELEMENT>(
459  wall_pt, xi_lo, fract_mid, xi_hi, nlayer, time_stepper_pt),
460  Centre_box_size(centre_box_size)
461  {
462 #ifdef PARANOID
463  ELEMENT* el_pt = new ELEMENT;
464  if (dynamic_cast<AlgebraicElementBase*>(el_pt) == 0)
465  {
466  std::ostringstream error_message;
467 
468  error_message << "Base class for ELEMENT in "
469  << "AlgebraicRefineableQuarterTubeMesh needs"
470  << "to be of type AlgebraicElement!\n";
471  error_message << "Whereas it is: typeid(el_pt).name()"
472  << typeid(el_pt).name() << std::endl;
473 
474  std::string function_name = " AlgebraicRefineableQuarterTubeMesh::\n";
475  function_name += "AlgebraicRefineableQuarterTubeMesh()";
476 
477  throw OomphLibError(error_message.str(),
480  }
481  delete el_pt;
482 #endif
483 
484  // Add the geometric object to the list associated with this AlgebraicMesh
486 
487  // Setup algebraic node update operations
489 
490  // Ensure nodes are in their default position
491  node_update();
492  }
493 
495  unsigned self_test()
496  {
497  return AlgebraicMesh::self_test();
498  }
499 
506  {
507  std::ostringstream error_message;
508  error_message << "AxialSpacingFctPt has not been implemented "
509  << "for the AlgebraicRefineableQuarterTubeMesh\n";
510 
511  std::string function_name =
512  " AlgebraicRefineableQuarterTubeMesh::AxialSpacingFctPt()";
513 
514  throw OomphLibError(
515  error_message.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
516 
517  return this->Domain_pt->axial_spacing_fct_pt();
518  }
519 
525  void node_update(const bool& update_all_solid_nodes = false)
526  {
527 #ifdef PARANOID
528  if (update_all_solid_nodes)
529  {
530  std::string error_message =
531  "Doesn't make sense to use an AlgebraicMesh with\n";
532  error_message +=
533  "SolidElements so specifying update_all_solid_nodes=true\n";
534  error_message += "doesn't make sense either\n";
535 
536  std::string function_name = " AlgebraicRefineableQuarterTubeMesh::";
537  function_name += "node_update()";
538 
539  throw OomphLibError(
541  }
542 #endif
543 
545  }
546 
547 
551  void algebraic_node_update(const unsigned& t, AlgebraicNode*& node_pt)
552  {
553  // Update with the update function for the node's first (default)
554  // node update fct
555  unsigned id = node_pt->node_update_fct_id();
556 
557  switch (id)
558  {
559  case Central_region:
560 
561  // Central region
563  break;
564 
565  case Lower_right_region:
566 
567  // Lower right region
569  break;
570 
571  case Upper_left_region:
572 
573  // Upper left region
575  break;
576 
577  default:
578 
579  std::ostringstream error_message;
580  error_message << "The node update fct id is " << id
581  << ", but it should only be one of " << Central_region
582  << ", " << Lower_right_region << " or "
583  << Upper_left_region << std::endl;
584  std::string function_name = " AlgebraicRefineableQuarterTubeMesh::";
585  function_name += "algebraic_node_update()";
586 
587  throw OomphLibError(error_message.str(),
590  }
591  }
592 
596  {
597  // Get all node update fct for this node (resizes internally)
598  Vector<int> id;
600 
601  // Loop over all update fcts
602  unsigned n_update = id.size();
603  for (unsigned i = 0; i < n_update; i++)
604  {
606  }
607  }
608 
609  private:
612 
614  enum
615  {
619  };
620 
622  double Lambda_x;
623 
625  double Lambda_y;
626 
629  void node_update_central_region(const unsigned& t, AlgebraicNode*& node_pt);
630 
633  void node_update_lower_right_region(const unsigned& t,
635 
638  void node_update_upper_left_region(const unsigned& t,
640 
643 
646  void update_node_update_in_region(AlgebraicNode*& node_pt, int& region_id);
647  };
648 
649 
650 } // namespace oomph
651 #endif
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Definition: algebraic_elements.h:506
Definition: algebraic_elements.h:599
void node_update(const bool &update_all_solid_nodes=false)
Definition: algebraic_elements.h:653
unsigned self_test()
Self test: check consistentency of multiple node updates.
Definition: algebraic_elements.h:786
void add_geom_object_list_pt(GeomObject *geom_object_pt)
Definition: algebraic_elements.h:823
AlgebraicNode * node_pt(const unsigned long &n)
Return a pointer to the n-th global AlgebraicNode.
Definition: algebraic_elements.h:620
Definition: algebraic_elements.h:55
int node_update_fct_id()
Default (usually first if there are multiple ones) node update fct id.
Definition: algebraic_elements.h:146
AlgebraicMesh version of RefineableQuarterTubeMesh.
Definition: quarter_tube_mesh.template.h:439
void node_update_central_region(const unsigned &t, AlgebraicNode *&node_pt)
Definition: quarter_tube_mesh.template.cc:961
unsigned self_test()
Run self-test for algebraic mesh – return 0/1 for OK/failure.
Definition: quarter_tube_mesh.template.h:495
void setup_algebraic_node_update()
Setup algebraic update operation for all nodes.
Definition: quarter_tube_mesh.template.cc:660
void node_update_lower_right_region(const unsigned &t, AlgebraicNode *&node_pt)
Definition: quarter_tube_mesh.template.cc:1051
double Lambda_x
Fractional width of central region.
Definition: quarter_tube_mesh.template.h:622
double Centre_box_size
Size of centre box.
Definition: quarter_tube_mesh.template.h:611
void update_node_update(AlgebraicNode *&node_pt)
Definition: quarter_tube_mesh.template.h:595
double Lambda_y
Fractional height of central region.
Definition: quarter_tube_mesh.template.h:625
QuarterTubeDomain::AxialSpacingFctPt & axial_spacing_fct_pt()
Definition: quarter_tube_mesh.template.h:505
void node_update_upper_left_region(const unsigned &t, AlgebraicNode *&node_pt)
Definition: quarter_tube_mesh.template.cc:1168
@ Lower_right_region
Definition: quarter_tube_mesh.template.h:617
@ Upper_left_region
Definition: quarter_tube_mesh.template.h:618
@ Central_region
Definition: quarter_tube_mesh.template.h:616
AlgebraicRefineableQuarterTubeMesh(GeomObject *wall_pt, const Vector< double > &xi_lo, const double &fract_mid, const Vector< double > &xi_hi, const unsigned &nlayer, const double centre_box_size=1.0, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Definition: quarter_tube_mesh.template.h:448
void update_node_update_in_region(AlgebraicNode *&node_pt, int &region_id)
Definition: quarter_tube_mesh.template.cc:1288
void node_update(const bool &update_all_solid_nodes=false)
Definition: quarter_tube_mesh.template.h:525
void algebraic_node_update(const unsigned &t, AlgebraicNode *&node_pt)
Definition: quarter_tube_mesh.template.h:551
Base class for brick meshes (meshes made of 3D brick elements).
Definition: brick_mesh.h:178
MacroElement * macro_element_pt(const unsigned &i)
Access to i-th macro element.
Definition: domain.h:116
Definition: elements.h:1313
Definition: geom_objects.h:101
Base class for elements that allow MacroElement-based node update.
Definition: macro_element_node_update_element.h:197
Definition: macro_element_node_update_element.h:360
void set_geom_object_vector_pt(Vector< GeomObject * > geom_object_vector_pt)
Definition: macro_element_node_update_element.h:510
void node_update(const bool &update_all_solid_nodes=false)
Definition: macro_element_node_update_element.h:387
Domain *& macro_domain_pt()
Broken assignment operator.
Definition: macro_element_node_update_element.h:376
MacroElementNodeUpdate version of RefineableQuarterTubeMesh.
Definition: quarter_tube_mesh.template.h:240
MacroElementNodeUpdateRefineableQuarterTubeMesh(GeomObject *wall_pt, const Vector< double > &xi_lo, const double &fract_mid, const Vector< double > &xi_hi, const unsigned &nlayer, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Definition: quarter_tube_mesh.template.h:249
void node_update(const bool &update_all_solid_nodes=false)
Definition: quarter_tube_mesh.template.h:299
virtual ~MacroElementNodeUpdateRefineableQuarterTubeMesh()
Destructor: empty.
Definition: quarter_tube_mesh.template.h:292
void setup_macro_element_node_update()
Definition: quarter_tube_mesh.template.h:325
static Steady< 0 > Default_TimeStepper
The Steady Timestepper.
Definition: mesh.h:75
FiniteElement * finite_element_pt(const unsigned &e) const
Definition: mesh.h:473
const Vector< GeneralisedElement * > & element_pt() const
Return reference to the Vector of elements.
Definition: mesh.h:460
unsigned self_test()
Self-test: Check elements and nodes. Return 0 for OK.
Definition: mesh.cc:778
unsigned long nelement() const
Return number of elements in the mesh.
Definition: mesh.h:590
Definition: octree.h:928
Definition: octree.h:611
Definition: oomph_definitions.h:222
Definition: quarter_tube_domain.h:43
AxialSpacingFctPt & axial_spacing_fct_pt()
Definition: quarter_tube_domain.h:116
BLSquashFctPt & bl_squash_fct_pt()
Definition: quarter_tube_domain.h:94
double(* BLSquashFctPt)(const double &s)
Definition: quarter_tube_domain.h:87
double(* AxialSpacingFctPt)(const double &xi)
Definition: quarter_tube_domain.h:111
Definition: quarter_tube_mesh.template.h:65
QuarterTubeDomain * Domain_pt
Pointer to domain.
Definition: quarter_tube_mesh.template.h:121
Vector< double > Xi_lo
Lower limits for the coordinates along the wall.
Definition: quarter_tube_mesh.template.h:127
QuarterTubeDomain * domain_pt() const
Access function to underlying domain.
Definition: quarter_tube_mesh.template.h:114
QuarterTubeMesh(GeomObject *wall_pt, const Vector< double > &xi_lo, const double &fract_mid, const Vector< double > &xi_hi, const unsigned &nlayer, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Definition: quarter_tube_mesh.template.cc:44
QuarterTubeDomain * domain_pt()
Access function to domain.
Definition: quarter_tube_mesh.template.h:92
virtual QuarterTubeDomain::AxialSpacingFctPt & axial_spacing_fct_pt()
Function pointer for function for axial spacing.
Definition: quarter_tube_mesh.template.h:108
GeomObject * Wall_pt
Pointer to the geometric object that represents the curved wall.
Definition: quarter_tube_mesh.template.h:124
Vector< double > Xi_hi
Upper limits for the coordinates along the wall.
Definition: quarter_tube_mesh.template.h:133
double Fract_mid
Fraction along wall where outer ring is to be divided.
Definition: quarter_tube_mesh.template.h:130
virtual ~QuarterTubeMesh()
Destructor: empty.
Definition: quarter_tube_mesh.template.h:80
GeomObject *& wall_pt()
Access function to GeomObject representing wall.
Definition: quarter_tube_mesh.template.h:86
QuarterTubeDomain::BLSquashFctPt & bl_squash_fct_pt()
Definition: quarter_tube_mesh.template.h:101
Definition: refineable_brick_mesh.h:61
Definition: refineable_brick_element.h:68
Definition: quarter_tube_mesh.template.h:162
virtual ~RefineableQuarterTubeMesh()
Destructor: empty.
Definition: quarter_tube_mesh.template.h:221
RefineableQuarterTubeMesh(GeomObject *wall_pt, const Vector< double > &xi_lo, const double &fract_mid, const Vector< double > &xi_hi, const unsigned &nlayer, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Definition: quarter_tube_mesh.template.h:171
Definition: timesteppers.h:231
TreeForest * Forest_pt
Forest representation of the mesh.
Definition: refineable_mesh.h:768
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
OomphInfo oomph_info
Definition: oomph_definitions.cc:319
string name
Definition: plotDoE.py:33
t
Definition: plotPSD.py:36
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86