eighth_sphere_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// Version 1.0; svn revision $LastChangedRevision$
7 //LIC//
8 //LIC// $LastChangedDate$
9 //LIC//
10 //LIC// Copyright (C) 2006-2016 Matthias Heil and Andrew Hazel
11 //LIC//
12 //LIC// This library is free software; you can redistribute it and/or
13 //LIC// modify it under the terms of the GNU Lesser General Public
14 //LIC// License as published by the Free Software Foundation; either
15 //LIC// version 2.1 of the License, or (at your option) any later version.
16 //LIC//
17 //LIC// This library is distributed in the hope that it will be useful,
18 //LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
19 //LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 //LIC// Lesser General Public License for more details.
21 //LIC//
22 //LIC// You should have received a copy of the GNU Lesser General Public
23 //LIC// License along with this library; if not, write to the Free Software
24 //LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 //LIC// 02110-1301 USA.
26 //LIC//
27 //LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
28 //LIC//
29 //LIC//====================================================================
30 #ifndef OOMPH_EIGHTH_SPHERE_MESH_HEADER
31 #define OOMPH_EIGHTH_SPHERE_MESH_HEADER
32 
33 // Headers
34 #include "../generic/refineable_brick_mesh.h"
35 #include "../generic/macro_element.h"
36 #include "../generic/domain.h"
37 #include "../generic/algebraic_elements.h"
38 #include "../generic/brick_mesh.h"
39 
40 //Include the headers file for domain
41 #include "eighth_sphere_domain.h"
42 
43 namespace oomph
44 {
45 
46 
47 //======================================================================
48 /// Eight of a sphere brick mesh, based on the EightSphereDomain
49 /// Non-refineable version with four brick elements.
50 /// The eighth-sphere is located in the positive octant,
51 /// centred at the origin. The mesh boundaries are numbered
52 /// as follows:
53 /// - Boundary 0: Plane x=0
54 /// - Boundary 1: Plane y=0
55 /// - Boundary 2: Plane z=0
56 /// - Boundary 3: The surface of the sphere.
57 //======================================================================
58 template<class ELEMENT>
59 class EighthSphereMesh : public virtual BrickMeshBase
60 {
61 
62 public:
63 
64  /// \short Constructor: Pass radius and timestepper; defaults to
65  /// static default timestepper
66  EighthSphereMesh(const double& radius, TimeStepper* time_stepper_pt=
67  &Mesh::Default_TimeStepper);
68 
69 
70  /// Destructor
72  {
73  delete Domain_pt;
74  Domain_pt=0;
75  }
76 
77 protected :
78 
79  /// Pointer to the domain
80  Domain* Domain_pt;
81 
82  /// Radius of the sphere
83  double Radius;
84 
85 };
86 
87 
88 
89 
90 
91 //======================================================================
92 /// Refineable version of the eight of a sphere brick mesh.
93 /// The eighth-sphere is located in the positive octant,
94 /// centred at the origin. The mesh boundaries are numbered
95 /// as follows:
96 /// - Boundary 0: Plane x=0
97 /// - Boundary 1: Plane y=0
98 /// - Boundary 2: Plane z=0
99 /// - Boundary 3: The surface of the sphere.
100 //======================================================================
101 template<class ELEMENT>
103  public virtual RefineableBrickMesh<ELEMENT>
104  {
105 
106 public:
107 
108  /// \short Constructor: Pass radius and timestepper; defaults to
109  /// static default timestepper
110  RefineableEighthSphereMesh(const double& radius, TimeStepper* time_stepper_pt=
111  &Mesh::Default_TimeStepper) :
112  EighthSphereMesh<ELEMENT>(radius,time_stepper_pt)
113  {
114 
115  // Loop over all elements and set macro element pointer
116  unsigned nel=this->nelement();
117  for (unsigned ielem=0;ielem<nel;ielem++)
118  {
119  dynamic_cast<RefineableQElement<3>*>(this->element_pt(ielem))->
120  set_macro_elem_pt(this->Domain_pt->macro_element_pt(ielem));
121  }
122 
123  // Associate the elements with octrees and plant in forest
124  Vector<TreeRoot*> tree_pt;
125  OcTreeRoot::setup_static_data();
126  for (unsigned e = 0; e<nel; e++)
127  {
128  FiniteElement* el_pt=this->finite_element_pt(e);
129  ELEMENT* ref_el_pt=dynamic_cast<ELEMENT*>(el_pt);
130  OcTreeRoot* octree_root_pt=new OcTreeRoot(ref_el_pt);
131  tree_pt.push_back(octree_root_pt);
132  }
133 
134  //Plant in forest
135  this->Forest_pt=new OcTreeForest(tree_pt);
136 
137 #ifdef PARANOID
138  // Run self test on octree forest
139  dynamic_cast<OcTreeForest*>(this->Forest_pt)->self_test();
140 #endif
141 
142  }
143 
144 };
145 
146 }
147 
148 #endif
Domain * Domain_pt
Pointer to the domain.
EighthSphereMesh(const double &radius, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor: Pass radius and timestepper; defaults to static default timestepper. ...
double Radius
Radius of the sphere.
RefineableEighthSphereMesh(const double &radius, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor: Pass radius and timestepper; defaults to static default timestepper. ...