annular_mesh.template.cc
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_ANNULAR_MESH_TEMPLATE_CC
31 #define OOMPH_ANNULAR_MESH_TEMPLATE_CC
32 
33 #include "annular_mesh.template.h"
34 
35 namespace oomph
36 {
37 
38 
39 
40 
41 //===================================================================
42  /// Helper function to Wrap mesh into annular shape
43 //==================================================================
44  template<class ELEMENT>
46  const double& a,
47  const double& h,
48  const double& azimuthal_fraction,
49  const double& phi)
50  {
51  //Create the hole
52  Ellipse ellipse(a,a);
53 
54  //Set all the initial positions of the nodes
55  Vector<double> xi(1);
56  Vector<double> base(2);
57  Vector<double> N(2);
58  const unsigned n_node = this->nnode();
59  for(unsigned n=0;n<n_node;n++)
60  {
61  // Pointer to node
62  Node* nod_pt = this->node_pt(n);
63 
64  // Get the angle of the node -- rotate such that jump in angle
65  // appears at periodic boundary. Shrink domain slightly
66  // to keep angle unique
67  xi[0] = (1.0-1.0e-10)*(-azimuthal_fraction*nod_pt->x(0))*
68  2.0*MathematicalConstants::Pi+
69  MathematicalConstants::Pi-
70  (1.0-azimuthal_fraction)*2.0*MathematicalConstants::Pi;
71 
72  // Rotate
73  xi[0]+=phi;
74 
75  //Get the node's fraction in the radial direction
76  double w = nod_pt->x(1);
77 
78  //Get the position on the ellipse base
79  ellipse.position(xi,base);
80 
81  //Get the unit normal, if it were a circle , by normalising the base
82  double norm = sqrt(base[0]*base[0] + base[1]*base[1]);
83  N[0] = base[0]/norm;
84  N[1] = base[1]/norm;
85 
86  //Set circular film from the ellipse
87  nod_pt->x(0) = base[0] + w*(h+a-norm)*N[0];
88  nod_pt->x(1) = base[1] + w*(h+a-norm)*N[1];
89 
90  // Set boundary coordinates
91  Vector<double> xi_bound(1);
92 
93  // Polar angle for boundary coordinate on boundary 0
94  if(nod_pt->is_on_boundary(0))
95  {
96  xi_bound[0]=atan2(nod_pt->x(1),nod_pt->x(0));
97  nod_pt->set_coordinates_on_boundary(0,xi_bound);
98  }
99 
100  // Radius for boundary coordinate on boundary 1
101  if(nod_pt->is_on_boundary(1))
102  {
103  xi_bound[0]=sqrt(pow(nod_pt->x(0),2)+pow(nod_pt->x(1),2));
104  nod_pt->set_coordinates_on_boundary(1,xi_bound);
105  }
106 
107  // Polar angle for boundary coordinate on boundary 2
108  if(nod_pt->is_on_boundary(2))
109  {
110  xi_bound[0]=atan2(nod_pt->x(1),nod_pt->x(0));
111  nod_pt->set_coordinates_on_boundary(2,xi_bound);
112  }
113 
114  // Radius for boundary coordinate on boundary 3
115  if(nod_pt->is_on_boundary(3))
116  {
117  xi_bound[0]=sqrt(pow(nod_pt->x(0),2)+pow(nod_pt->x(1),2));
118  nod_pt->set_coordinates_on_boundary(3,xi_bound);
119  }
120  }
121 
122  this->Boundary_coordinate_exists[0]=true;
123  this->Boundary_coordinate_exists[1]=true;
124  this->Boundary_coordinate_exists[2]=true;
125  this->Boundary_coordinate_exists[3]=true;
126  }
127 
128 
129 }
130 
131 
132 
133 #endif
void wrap_into_annular_shape(const double &a, const double &h, const double &azimuthal_fraction, const double &phi)
Wrap mesh into annular shape.