quarter_circle_sector_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_CIRCLE_SECTOR_MESH_HEADER
27 #define OOMPH_QUARTER_CIRCLE_SECTOR_MESH_HEADER
28 
29 #include "../generic/refineable_quad_mesh.h"
30 #include "../generic/macro_element.h"
31 #include "../generic/domain.h"
32 #include "../generic/algebraic_elements.h"
33 #include "../generic/quad_mesh.h"
34 #include "../generic/macro_element_node_update_element.h"
35 
36 // Include the headers file for domain
38 
39 
40 namespace oomph
41 {
45 
46 
47  class GeomObject;
48 
49 
50  //====================================================================
84  //====================================================================
85  template<class ELEMENT>
86  class QuarterCircleSectorMesh : public virtual QuadMeshBase
87  {
88  public:
96  const double& xi_lo,
97  const double& fract_mid,
98  const double& xi_hi,
99  TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper);
100 
103 
106  {
107  return Wall_pt;
108  }
109 
112  {
113  return Domain_pt;
114  }
115 
121  {
122  return Domain_pt->bl_squash_fct_pt();
123  }
124 
125 
126  protected:
129 
133 
135  double Xi_lo;
136 
138  double Fract_mid;
139 
141  double Xi_hi;
142  };
143 
144 
148 
149 
150  //====================================================================
183  //====================================================================
184  template<class ELEMENT>
186  : public QuarterCircleSectorMesh<ELEMENT>,
187  public virtual RefineableQuadMesh<ELEMENT>
188  {
189  public:
198  const double& xi_lo,
199  const double& fract_mid,
200  const double& xi_hi,
201  TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
202  : QuarterCircleSectorMesh<ELEMENT>(
203  wall_pt, xi_lo, fract_mid, xi_hi, time_stepper_pt)
204  {
205  // Basic mesh has been built -- just need to setup the
206  // adaptivity information:
207 
208  // Setup quadtree forest
209  this->setup_quadtree_forest();
210  }
211 
214  };
215 
216 
219  // MacroElementNodeUpdate-version of RefineableQuarterCircleSectorMesh
222 
223  class MacroElementNodeUpdateNode;
224 
225  //========================================================================
256  //========================================================================
257  template<class ELEMENT>
259  : public virtual MacroElementNodeUpdateMesh,
260  public virtual RefineableQuarterCircleSectorMesh<ELEMENT>
261  {
262  public:
272  const double& xi_lo,
273  const double& fract_mid,
274  const double& xi_hi,
275  TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
278  wall_pt, xi_lo, fract_mid, xi_hi, time_stepper_pt)
279  {
280 #ifdef PARANOID
281  ELEMENT* el_pt = new ELEMENT;
282  if (dynamic_cast<MacroElementNodeUpdateElementBase*>(el_pt) == 0)
283  {
284  std::ostringstream error_message;
285  error_message
286  << "Base class for ELEMENT in "
287  << "MacroElementNodeUpdateRefineableQuarterCircleSectorMesh needs"
288  << "to be of type MacroElementNodeUpdateElement!\n";
289  error_message << "Whereas it is: typeid(el_pt).name()"
290  << typeid(el_pt).name() << std::endl;
291 
292  std::string function_name =
293  "MacroElementNodeUpdateRefineableQuaterCircleSectorMesh::\n";
294  function_name +=
295  "MacroElementNodeUpdateRefineableQuaterCircleSectorMesh()";
296 
297  throw OomphLibError(error_message.str(),
300  }
301  delete el_pt;
302 #endif
303 
304  // Setup all the information that's required for MacroElement-based
305  // node update: Tell the elements that their geometry depends on the
306  // fishback geometric object
308  }
309 
312 
318  void node_update(const bool& update_all_solid_nodes = false)
319  {
320 #ifdef PARANOID
321  if (update_all_solid_nodes)
322  {
323  std::string error_message =
324  "Doesn't make sense to use an MacroElementNodeUpdateMesh with\n";
325  error_message +=
326  "SolidElements so specifying update_all_solid_nodes=true\n";
327  error_message += "doesn't make sense either\n";
328 
329  std::string function_name =
330  "MacroElementNodeUpdateRefineableQuaterCircleSectorMesh::\n";
331  function_name += "node_update()";
332 
333  throw OomphLibError(
335  }
336 #endif
338  }
339 
340  private:
345  {
346  unsigned n_element = this->nelement();
347  for (unsigned i = 0; i < n_element; i++)
348  {
349  // Upcast from FiniteElement to the present element
350  ELEMENT* el_pt = dynamic_cast<ELEMENT*>(this->element_pt(i));
351 
352 #ifdef PARANOID
353  // Check if cast is successful
355  dynamic_cast<MacroElementNodeUpdateElementBase*>(el_pt);
356  if (m_el_pt == 0)
357  {
358  std::ostringstream error_message;
359  error_message
360  << "Failed to upcast to MacroElementNodeUpdateElementBase\n";
361  error_message << "Element must be derived from "
362  "MacroElementNodeUpdateElementBase\n";
363  error_message << "but it is of type " << typeid(el_pt).name();
364 
365  std::string function_name =
366  "MacroElementNodeUpdateRefineableQuaterCircleSectorMesh::\n";
367  function_name += "setup_macro_element_node_update()";
368 
369  throw OomphLibError(error_message.str(),
372  }
373 #endif
374  // There's just one GeomObject
375  Vector<GeomObject*> geom_object_pt(1);
376  geom_object_pt[0] = this->Wall_pt;
377 
378  // Tell the element which geom objects its macro-element-based
379  // node update depends on
380  el_pt->set_node_update_info(geom_object_pt);
381  }
382 
383  // Add the geometric object(s) for the wall to the mesh's storage
384  Vector<GeomObject*> geom_object_pt(1);
385  geom_object_pt[0] = this->Wall_pt;
387 
388  // Fill in the domain pointer to the mesh's storage in the base class
390  }
391  };
392 
393 
396  // Algebraic-mesh-version of RefineableQuarterCircleSectorMesh
399 
400 
401  class AlgebraicNode;
402 
403  //========================================================================
437  //========================================================================
438  template<class ELEMENT>
440  : public virtual AlgebraicMesh,
441  public RefineableQuarterCircleSectorMesh<ELEMENT>
442  {
443  public:
453  const double& xi_lo,
454  const double& fract_mid,
455  const double& xi_hi,
456  TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
458  wall_pt, xi_lo, fract_mid, xi_hi, time_stepper_pt)
459  {
460 #ifdef PARANOID
461  ELEMENT* el_pt = new ELEMENT;
462  if (dynamic_cast<AlgebraicElementBase*>(el_pt) == 0)
463  {
464  std::ostringstream error_message;
465 
466  error_message << "Base class for ELEMENT in "
467  << "AlgebraicRefineableQuarterCircleSectorMesh needs"
468  << "to be of type AlgebraicElement!\n";
469  error_message << "Whereas it is: typeid(el_pt).name()"
470  << typeid(el_pt).name() << std::endl;
471 
472  std::string function_name =
473  " AlgebraicRefineableQuarterCircleSectorMesh::\n";
474  function_name += "AlgebraicRefineableQuarterCircleSectorMesh()";
475 
476  throw OomphLibError(error_message.str(),
479  }
480  delete el_pt;
481 #endif
482 
483  // Add the geometric object to the list associated with this AlgebraicMesh
485 
486  // Setup algebraic node update operations
488  }
489 
491  unsigned self_test()
492  {
493  return AlgebraicMesh::self_test();
494  }
495 
501  void node_update(const bool& update_all_solid_nodes = false)
502  {
503 #ifdef PARANOID
504  if (update_all_solid_nodes)
505  {
506  std::string error_message =
507  "Doesn't make sense to use an AlgebraicMesh with\n";
508  error_message +=
509  "SolidElements so specifying update_all_solid_nodes=true\n";
510  error_message += "doesn't make sense either\n";
511 
512  std::string function_name =
513  " AlgebraicRefineableQuarterCircleSectorMesh::";
514  function_name += "node_update()";
515 
516  throw OomphLibError(
518  }
519 #endif
521  }
522 
523 
527  void algebraic_node_update(const unsigned& t, AlgebraicNode*& node_pt)
528  {
529  // Update with the update function for the node's first (default)
530  // node update fct
531  unsigned id = node_pt->node_update_fct_id();
532 
533  switch (id)
534  {
535  case Central_box:
536 
537  // Central box
539  break;
540 
541 
542  case Lower_right_box:
543 
544  // Lower right box
546  break;
547 
548  case Upper_left_box:
549 
550  // Upper left box
552  break;
553 
554  default:
555 
556  std::ostringstream error_message;
557  error_message << "The node update fct id is " << id
558  << ", but it should only be one of " << Central_box
559  << ", " << Lower_right_box << " or " << Upper_left_box
560  << std::endl;
561  std::string function_name =
562  " AlgebraicRefineableQuarterCircleSectorMesh::";
563  function_name += "algebraic_node_update()";
564 
565  throw OomphLibError(error_message.str(),
568  }
569  }
570 
574  {
575  // Get all node update fct for this node (resizes internally)
576  Vector<int> id;
578 
579  // Loop over all update fcts
580  unsigned n_update = id.size();
581  for (unsigned i = 0; i < n_update; i++)
582  {
583  switch (id[i])
584  {
585  case Central_box:
586 
587  // Central box: no update
588  break;
589 
590 
591  case Lower_right_box:
592 
593  // Lower right box
595  break;
596 
597  case Upper_left_box:
598 
599  // Upper left box
601  break;
602 
603  default:
604 
605  // Never get here....
606  std::ostringstream error_message;
607  error_message << "Node update fct id is " << id[i]
608  << ", but it should only be one of" << Central_box
609  << ", " << Lower_right_box << " or " << Upper_left_box
610  << std::endl;
611 
612  std::string function_name =
613  " AlgebraicRefineableQuarterCircleSectorMesh::";
614  function_name += "update_node_update()";
615 
616  throw OomphLibError(error_message.str(),
619  }
620  }
621  }
622 
623  private:
625  enum
626  {
630  };
631 
632 
634  double Lambda_x;
635 
637  double Lambda_y;
638 
641  void node_update_in_central_box(const unsigned& t, AlgebraicNode*& node_pt);
642 
645  void node_update_in_lower_right_box(const unsigned& t,
647 
650  void node_update_in_upper_left_box(const unsigned& t,
652 
655 
656 
660 
664  };
665 
666 
667 } // namespace oomph
668 
669 #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
Definition: quarter_circle_sector_mesh.template.h:442
void update_node_update(AlgebraicNode *&node_pt)
Definition: quarter_circle_sector_mesh.template.h:573
double Lambda_y
Fractional height of central box.
Definition: quarter_circle_sector_mesh.template.h:637
void node_update(const bool &update_all_solid_nodes=false)
Definition: quarter_circle_sector_mesh.template.h:501
void setup_algebraic_node_update()
Setup algebraic update operation for all nodes.
Definition: quarter_circle_sector_mesh.template.cc:557
AlgebraicRefineableQuarterCircleSectorMesh(GeomObject *wall_pt, const double &xi_lo, const double &fract_mid, const double &xi_hi, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Definition: quarter_circle_sector_mesh.template.h:451
unsigned self_test()
Run self-test for algebraic mesh – return 0/1 for OK/failure.
Definition: quarter_circle_sector_mesh.template.h:491
@ Lower_right_box
Definition: quarter_circle_sector_mesh.template.h:628
@ Central_box
Definition: quarter_circle_sector_mesh.template.h:627
@ Upper_left_box
Definition: quarter_circle_sector_mesh.template.h:629
void update_node_update_in_lower_right_box(AlgebraicNode *&node_pt)
Update algebraic update function for nodes in lower right box.
Definition: quarter_circle_sector_mesh.template.cc:1159
void node_update_in_central_box(const unsigned &t, AlgebraicNode *&node_pt)
Definition: quarter_circle_sector_mesh.template.cc:851
void node_update_in_lower_right_box(const unsigned &t, AlgebraicNode *&node_pt)
Definition: quarter_circle_sector_mesh.template.cc:940
void update_node_update_in_upper_left_box(AlgebraicNode *&node_pt)
Update algebraic update function for nodes in upper left box.
Definition: quarter_circle_sector_mesh.template.cc:1259
void algebraic_node_update(const unsigned &t, AlgebraicNode *&node_pt)
Definition: quarter_circle_sector_mesh.template.h:527
void node_update_in_upper_left_box(const unsigned &t, AlgebraicNode *&node_pt)
Definition: quarter_circle_sector_mesh.template.cc:1048
double Lambda_x
Fractional width of central box.
Definition: quarter_circle_sector_mesh.template.h:634
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
Definition: quarter_circle_sector_mesh.template.h:261
virtual ~MacroElementNodeUpdateRefineableQuarterCircleSectorMesh()
Destructor: empty.
Definition: quarter_circle_sector_mesh.template.h:311
void setup_macro_element_node_update()
Definition: quarter_circle_sector_mesh.template.h:344
void node_update(const bool &update_all_solid_nodes=false)
Definition: quarter_circle_sector_mesh.template.h:318
MacroElementNodeUpdateRefineableQuarterCircleSectorMesh(GeomObject *wall_pt, const double &xi_lo, const double &fract_mid, const double &xi_hi, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Definition: quarter_circle_sector_mesh.template.h:270
static Steady< 0 > Default_TimeStepper
The Steady Timestepper.
Definition: mesh.h:75
const Vector< GeneralisedElement * > & element_pt() const
Return reference to the Vector of elements.
Definition: mesh.h:460
unsigned long nelement() const
Return number of elements in the mesh.
Definition: mesh.h:590
Definition: oomph_definitions.h:222
Base class for quad meshes (meshes made of 2D quad elements).
Definition: quad_mesh.h:57
Definition: quarter_circle_sector_domain.h:43
double(* BLSquashFctPt)(const double &s)
Definition: quarter_circle_sector_domain.h:84
BLSquashFctPt & bl_squash_fct_pt()
Definition: quarter_circle_sector_domain.h:91
Definition: quarter_circle_sector_mesh.template.h:87
GeomObject *& wall_pt()
Access function to GeomObject representing wall.
Definition: quarter_circle_sector_mesh.template.h:105
double Fract_mid
Fraction along wall where outer ring is to be divided.
Definition: quarter_circle_sector_mesh.template.h:138
double Xi_hi
Upper limit for the (1D) coordinates along the wall.
Definition: quarter_circle_sector_mesh.template.h:141
GeomObject * Wall_pt
Definition: quarter_circle_sector_mesh.template.h:132
QuarterCircleSectorMesh(GeomObject *wall_pt, const double &xi_lo, const double &fract_mid, const double &xi_hi, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Definition: quarter_circle_sector_mesh.template.cc:44
QuarterCircleSectorDomain * Domain_pt
Pointer to Domain.
Definition: quarter_circle_sector_mesh.template.h:128
QuarterCircleSectorDomain * domain_pt()
Access function to domain.
Definition: quarter_circle_sector_mesh.template.h:111
QuarterCircleSectorDomain::BLSquashFctPt & bl_squash_fct_pt()
Definition: quarter_circle_sector_mesh.template.h:120
double Xi_lo
Lower limit for the (1D) coordinates along the wall.
Definition: quarter_circle_sector_mesh.template.h:135
virtual ~QuarterCircleSectorMesh()
Destructor:
Definition: quarter_circle_sector_mesh.template.h:102
Definition: refineable_quad_mesh.h:53
void setup_quadtree_forest()
Definition: refineable_quad_mesh.h:88
Definition: quarter_circle_sector_mesh.template.h:188
RefineableQuarterCircleSectorMesh(GeomObject *wall_pt, const double &xi_lo, const double &fract_mid, const double &xi_hi, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Definition: quarter_circle_sector_mesh.template.h:196
virtual ~RefineableQuarterCircleSectorMesh()
Destructor: Empty.
Definition: quarter_circle_sector_mesh.template.h:213
Definition: timesteppers.h:231
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
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