geometric_multigrid.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: 1216 $
7 //LIC//
8 //LIC// $LastChangedDate: 2016-08-06 15:23:30 +0100 (Sat, 06 Aug 2016) $
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 // Include the corresponding header file
31 #include "geometric_multigrid.h"
32 
33 namespace oomph
34 {
35  //=========================================================================
36  /// \short Given the son type of the element and the local coordinate s of
37  /// a given node in the son element, return the local coordinate s in its
38  /// father element. 2D case.
39  //=========================================================================
40  template<>
43  {
44  // If the element is unrefined between the levels the local coordinate
45  // of the node in one element is the same as that in the other element
46  // therefore we only need to perform calculations if the levels are
47  // different (i.e. son_type is not OMEGA)
48  if (son_type!=Tree::OMEGA)
49  {
50  // Scale the local coordinate from the range [-1,1]x[-1,1] to the range
51  // [0,1]x[0,1] to match the width of the local coordinate range of the
52  // fine element from the perspective of the father element. This
53  // then simply requires a shift of the coordinates to match which type
54  // of son element we're dealing with
55  s[0]=(s[0]+1.0)/2.0;
56  s[1]=(s[1]+1.0)/2.0;
57 
58  // Cases: The son_type determines how the local coordinates should be
59  // shifted to give the local coordinates in the coarse mesh element
60  switch(son_type)
61  {
62  // If we're dealing with the bottom-left element we need to shift
63  // the range [0,1]x[0,1] to [-1,0]x[-1,0]
64  case QuadTreeNames::SW:
65  s[0]-=1;
66  s[1]-=1;
67  break;
68 
69  // If we're dealing with the bottom-right element we need to shift
70  // the range [0,1]x[0,1] to [0,1]x[-1,0]
71  case QuadTreeNames::SE:
72  s[1]-=1;
73  break;
74 
75  // If we're dealing with the top-right element we need to shift the
76  // range [0,1]x[0,1] to [0,1]x[0,1], i.e. nothing needs to be done
77  case QuadTreeNames::NE:
78  break;
79 
80  // If we're dealing with the top-left element we need to shift
81  // the range [0,1]x[0,1] to [-1,0]x[0,1]
82  case QuadTreeNames::NW:
83  s[0]-=1;
84  break;
85  }
86  } // if son_type!=Tree::OMEGA
87  } // End of level_up_local_coord_of_node
88 
89  //=========================================================================
90  /// \short Given the son type of the element and the local coordinate s of
91  /// a given node in the son element, return the local coordinate s in its
92  /// father element. 3D case.
93  //=========================================================================
94  template<>
97  {
98  // If the element is unrefined between the levels the local coordinate
99  // of the node in one element is the same as that in the other element
100  // therefore we only need to perform calculations if the levels are
101  // different (i.e. son_type is not OMEGA)
102  if (son_type!=Tree::OMEGA)
103  {
104  // Scale the local coordinate from the range [-1,1]x[-1,1]x[-1,1]
105  // to the range [0,1]x[0,1]x[0,1] to match the width of the local
106  // coordinate range of the fine element from the perspective of
107  // the father element. This then simply requires a shift of the
108  // coordinates to match which type of son element we're dealing with
109  s[0]=(s[0]+1.0)/2.0;
110  s[1]=(s[1]+1.0)/2.0;
111  s[2]=(s[2]+1.0)/2.0;
112 
113  // Cases: The son_type determines how the local coordinates should be
114  // shifted to give the local coordinates in the coarse mesh element
115  switch(son_type)
116  {
117  case OcTreeNames::LDF:
118  s[0]-=1;
119  s[1]-=1;
120  break;
121 
122  case OcTreeNames::LDB:
123  s[0]-=1;
124  s[1]-=1;
125  s[2]-=1;
126  break;
127 
128  case OcTreeNames::LUF:
129  s[0]-=1;
130  break;
131 
132  case OcTreeNames::LUB:
133  s[0]-=1;
134  s[2]-=1;
135  break;
136 
137  case OcTreeNames::RDF:
138  s[1]-=1;
139  break;
140 
141  case OcTreeNames::RDB:
142  s[1]-=1;
143  s[2]-=1;
144  break;
145 
146  case OcTreeNames::RUF:
147  break;
148 
149  case OcTreeNames::RUB:
150  s[2]-=1;
151  break;
152  }
153  } // if son_type!=Tree::OMEGA
154  } // End of level_up_local_coord_of_node
155 } // End of namespace oomph
static char t char * s
Definition: cfortran.h:572
void level_up_local_coord_of_node(const int &son_type, Vector< double > &s)
Given the son_type of an element and a local node number j in that element with nnode_1d nodes per co...
static const int OMEGA
Default value for an unassigned neighbour.
Definition: tree.h:241