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