annular_domain.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-2023 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_ANNULAR_DOMAIN_HEADER
27 #define OOMPH_ANNULAR_DOMAIN_HEADER
28 
29 // Generic oomph-lib includes
30 #include "../generic/quadtree.h"
31 #include "../generic/domain.h"
32 #include "../generic/geom_objects.h"
33 
34 namespace oomph
35 {
36  //=================================================================
37  /// Annular domain
38  //=================================================================
39  class AnnularDomain : public Domain
40  {
41  public:
42  /// Constructor: Specify azimuthal fraction (1.0 is 360 degrees)
43  /// number of macro elements in azimuthal and radial direction,
44  /// inner radius and thickness. Rotate mesh by angle phi.
45  AnnularDomain(const double& azimuthal_fraction,
46  const unsigned& ntheta,
47  const unsigned& nr,
48  const double& a,
49  const double& h,
50  const double& phi)
51  : Azimuthal_fraction(azimuthal_fraction),
52  Inner_radius(a),
53  Thickness(h),
54  Ntheta(ntheta),
55  Nr(nr),
56  Phi(phi)
57  {
58  const unsigned n_macro = ntheta * nr;
59  Macro_element_pt.resize(n_macro);
60 
61  // Create the macro elements
62  for (unsigned i = 0; i < n_macro; i++)
63  {
64  Macro_element_pt[i] = new QMacroElement<2>(this, i);
65  }
66  }
67 
68  /// Broken copy constructor
69  AnnularDomain(const AnnularDomain&) = delete;
70 
71  /// Broken assignment operator
72  void operator=(const AnnularDomain&) = delete;
73 
74  /// Destructor: Empty; cleanup done in base class
76 
77 
78  /// Vector representation of the i_macro-th macro element
79  /// boundary i_direct (N/S/W/E) at time level t
80  /// (t=0: present; t>0: previous):
81  /// f(s).
82  void macro_element_boundary(const unsigned& t,
83  const unsigned& i_macro,
84  const unsigned& i_direct,
85  const Vector<double>& s,
86  Vector<double>& f);
87 
88  private:
89  /// Azimuthal fraction
91 
92  /// Inner radius
93  double Inner_radius;
94 
95  /// Thickness
96  double Thickness;
97 
98  /// Number of macro elements in azimuthal direction
99  unsigned Ntheta;
100 
101  /// Number of macro elements in radial direction
102  unsigned Nr;
103 
104  /// Rotation angle
105  double Phi;
106  };
107 
108 
109  /// //////////////////////////////////////////////////////////////////////
110  /// //////////////////////////////////////////////////////////////////////
111  /// //////////////////////////////////////////////////////////////////////
112 
113 
114  //=================================================================
115  /// Vector representation of the imacro-th macro element
116  /// boundary idirect (N/S/W/E) at time level t
117  /// (t=0: present; t>0: previous): f(s)
118  //=================================================================
120  const unsigned& imacro,
121  const unsigned& idirect,
122  const Vector<double>& s,
123  Vector<double>& f)
124  {
125  using namespace QuadTreeNames;
126 
127  // Get coordinates of macro element
128  unsigned i_theta = imacro % Ntheta;
129  unsigned i_r = (imacro - i_theta) / Ntheta;
130 
131  // Angle and radius limits
132  double theta_lo = Azimuthal_fraction * 2.0 * MathematicalConstants::Pi *
133  double(i_theta) / double(Ntheta);
134 
135  double theta_hi = Azimuthal_fraction * 2.0 * MathematicalConstants::Pi *
136  double(i_theta + 1) / double(Ntheta);
137 
138  // Revert direction (convoluted -- don't ask. It mirrors what happens
139  // in the mesh...
140  theta_lo = -MathematicalConstants::Pi +
141  Azimuthal_fraction * 2.0 * MathematicalConstants::Pi - theta_lo;
142  theta_hi = -MathematicalConstants::Pi +
143  Azimuthal_fraction * 2.0 * MathematicalConstants::Pi - theta_hi;
144 
145  double r_lo = Inner_radius + Thickness * double(i_r) / double(Nr);
146  double r_hi = Inner_radius + Thickness * double(i_r + 1) / double(Nr);
147 
148  // Actual radius and angle
149  double r = 0.0;
150  double theta = 0.0;
151 
152  // Which direction?
153  switch (idirect)
154  {
155  case N:
156 
157  theta = theta_lo + 0.5 * (s[0] + 1.0) * (theta_hi - theta_lo);
158  r = r_hi;
159 
160  break;
161 
162  case S:
163 
164  theta = theta_lo + 0.5 * (s[0] + 1.0) * (theta_hi - theta_lo);
165  r = r_lo;
166 
167  break;
168 
169  case W:
170 
171  theta = theta_lo;
172  r = r_lo + 0.5 * (s[0] + 1.0) * (r_hi - r_lo);
173 
174  break;
175 
176  case E:
177 
178  theta = theta_hi;
179  r = r_lo + 0.5 * (s[0] + 1.0) * (r_hi - r_lo);
180 
181  break;
182 
183  default:
184  std::ostringstream error_stream;
185  error_stream << "idirect is " << idirect << " not one of N, S, W, E"
186  << std::endl;
187 
188  throw OomphLibError(
189  error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
190  }
191 
192  f[0] = r * cos(theta + Phi);
193  f[1] = r * sin(theta + Phi);
194  }
195 
196 } // namespace oomph
197 
198 #endif
Annular domain.
double Phi
Rotation angle.
unsigned Nr
Number of macro elements in radial direction.
AnnularDomain(const AnnularDomain &)=delete
Broken copy constructor.
double Thickness
Thickness.
double Inner_radius
Inner radius.
unsigned Ntheta
Number of macro elements in azimuthal direction.
~AnnularDomain()
Destructor: Empty; cleanup done in base class.
AnnularDomain(const double &azimuthal_fraction, const unsigned &ntheta, const unsigned &nr, const double &a, const double &h, const double &phi)
Constructor: Specify azimuthal fraction (1.0 is 360 degrees) number of macro elements in azimuthal an...
double Azimuthal_fraction
Azimuthal fraction.
void macro_element_boundary(const unsigned &t, const unsigned &i_macro, const unsigned &i_direct, const Vector< double > &s, Vector< double > &f)
Vector representation of the i_macro-th macro element boundary i_direct (N/S/W/E) at time level t (t=...
void operator=(const AnnularDomain &)=delete
Broken assignment operator.
////////////////////////////////////////////////////////////////////// //////////////////////////////...