extruded_domain.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 // oomph-lib headers
27 #include "extruded_domain.h"
28 #include "extruded_macro_element.h"
29 
30 namespace oomph
31 {
32  //=================================================================
33  /// Constructor
34  //=================================================================
36  const unsigned& n_extruded_element,
37  const double& extrusion_length)
38  : Domain(),
39  Domain_pt(domain_pt),
40  N_extruded_element(n_extruded_element),
41  T_min(0.0),
42  T_max(extrusion_length)
43  {
44  // The number of macro elements to create in the extruded domain
45  unsigned n_macro_element =
47 
48  // There are four macro elements
49  Macro_element_pt.resize(n_macro_element);
50 
51  // Build the 3D extruded macro elements
52  for (unsigned i = 0; i < n_macro_element; i++)
53  {
54  // Create the i-th macro element
56  }
57  } // End of ExtrudedDomain
58 
59 
60  //=================================================================
61  /// Constructor
62  //=================================================================
64  const unsigned& n_extruded_element,
65  const double& t_min,
66  const double& t_max)
67  : Domain(),
68  Domain_pt(domain_pt),
69  N_extruded_element(n_extruded_element),
70  T_min(t_min),
71  T_max(t_max)
72  {
73  // The number of macro elements to create in the extruded domain
74  unsigned n_macro_element =
76 
77  // There are four macro elements
78  Macro_element_pt.resize(n_macro_element);
79 
80  // Build the 3D extruded macro elements
81  for (unsigned i = 0; i < n_macro_element; i++)
82  {
83  // Create the i-th macro element
85  }
86 
87  /*
88  // DRAIG: Might be worth having this as an output function if it's not
89  // already in the base class...
90  // Loop over the number of macro elements
91  for (unsigned i=0;i<n_macro_element;i++)
92  {
93  // Create an output stream
94  std::ofstream some_file;
95 
96  // Allocate space for the filename
97  char filename[1000];
98 
99  // Number of plot points
100  unsigned n_pts=20;
101 
102  // Create the file name
103  sprintf(filename,"RESLT/extruded_element%i.dat",i);
104 
105  // Open a file with the created filename
106  some_file.open(filename);
107 
108  // Output macro element
109  macro_element_pt(i)->output(some_file,n_pts);
110 
111  // Close the file
112  some_file.close();
113  }
114  exit(0);
115  */
116  } // End of ExtrudedDomain
117 
118 
119  //=================================================================
120  /// Number of macro elements in domain
121  //=================================================================
123  {
124  // Return the size of the macro element container
125  return Macro_element_pt.size();
126  } // End of nmacro_element
127 
128 
129  //=================================================================
130  /// Access to i-th extruded macro element
131  //=================================================================
133  {
134  // Return a pointer to the i-th macro element in storage
135  return dynamic_cast<ExtrudedMacroElement*>(Macro_element_pt[i]);
136  } // End of macro_element_pt
137 
138 
139  //=================================================================
140  /// Vector representation of the i_macro-th macro element
141  /// boundary i_direct (e.g. N/S/W/E in 2D spatial = 3D space-time).
142  /// NOTE: Some extra care has to be taken here to translate the
143  /// OcTree enumeration to the QuadTree enumeration (in the
144  /// appropriate manner) so that the original Domain object can be
145  /// used to calculate the global coordinate associated with the
146  /// provided local coordinates.
147  //=================================================================
148  void ExtrudedDomain::macro_element_boundary(const unsigned& time,
149  const unsigned& i_macro,
150  const unsigned& i_direct,
151  const Vector<double>& s,
152  Vector<double>& x)
153  {
154  // Make sure that time=0 otherwise this doesn't make sense
155  if (time != 0)
156  {
157  // Create an output stream
158  std::ostringstream error_message_stream;
159 
160  // Create an error message
161  error_message_stream << "This output function outputs a space-time\n"
162  << "representation of the domain. As such, it\n"
163  << "does not make sense to output the domain\n"
164  << "at a previous time level!" << std::endl;
165 
166  // Throw an error
167  throw OomphLibError(error_message_stream.str(),
168  OOMPH_CURRENT_FUNCTION,
169  OOMPH_EXCEPTION_LOCATION);
170  }
171 
172  // The number of dimensions
173  unsigned n_dim = 3;
174 
175  // The number of macro elements in the original spatial Domain
176  unsigned n_macro = Domain_pt->nmacro_element();
177 
178  // Calculate the shifted macro element number (to correspond to the
179  // correct macro element in the original spatial Domain)
180  unsigned true_macro_id = i_macro % n_macro;
181 
182  // Which layer of the extruded domain are we in? Layer 0 corresponds to
183  // elements closest to t=T_min and the layer N_extruded_element-1
184  // corresponds to elements closest to t=T_max
185  unsigned i_layer = (i_macro - true_macro_id) / n_macro;
186 
187  // Calculate the width of an extrusion layer
188  double layer_width = (T_max - T_min) / double(N_extruded_element);
189 
190  // Storage for the global (spatial) coordinates
191  Vector<double> x_project(n_dim - 1, 0.0);
192 
193  // Calculate the time value associated with the start of the i-layer-th
194  // extrusion layer
195  double t_lower = (T_min + i_layer * layer_width);
196 
197  // Initialise the time value
198  double t = t_lower;
199 
200  // If we're on one of the edges (once projected to 2D in the t-direction)
201  if ((i_direct == OcTreeNames::L) || (i_direct == OcTreeNames::R) ||
202  (i_direct == OcTreeNames::D) || (i_direct == OcTreeNames::U))
203  {
204  // Update the time value to get the time value associated
205  // with the input surface coordinates
206  t += 0.5 * (1.0 + s[1]) * layer_width;
207 
208  // Get the local coordinate associated with the surface coordinate
209  // in the projected Domain. This is the first surface coordinate
210  // on the left, right, down and up faces of the 3D macro element.
211  Vector<double> s_project(1, s[0]);
212 
213  // If we're on the left face (or the West face once projected to 2D)
214  if (i_direct == OcTreeNames::L)
215  {
216  // Call the corresponding function through the provided Domain object
218  t, true_macro_id, QuadTreeNames::W, s_project, x_project);
219  }
220  // If we're on the right face (or the East face once projected to 2D)
221  else if (i_direct == OcTreeNames::R)
222  {
223  // Call the corresponding function through the provided Domain object
225  t, true_macro_id, QuadTreeNames::E, s_project, x_project);
226  }
227  // If we're on the down face (or the South face once projected to 2D)
228  else if (i_direct == OcTreeNames::D)
229  {
230  // Call the corresponding function through the provided Domain object
232  t, true_macro_id, QuadTreeNames::S, s_project, x_project);
233  }
234  // If we're on the up face (or the North face once projected to 2D)
235  else if (i_direct == OcTreeNames::U)
236  {
237  // Call the corresponding function through the provided Domain object
239  t, true_macro_id, QuadTreeNames::N, s_project, x_project);
240  }
241  }
242  else if ((i_direct == OcTreeNames::B) || (i_direct == OcTreeNames::F))
243  {
244  // Grab the i_macro-th macro element from the Domain object
246  Domain_pt->macro_element_pt(true_macro_id);
247 
248  // If we're on the back face (or the whole element at t=T_max)
249  if (i_direct == OcTreeNames::B)
250  {
251  // Call the macro_map function to calculate the global (spatial)
252  // coordinates associated with the given surface coordinates
253  macro_element_pt->macro_map(t, s, x_project);
254  }
255  // If we're on the front face (or the whole element at t=T_max)
256  else if (i_direct == OcTreeNames::F)
257  {
258  // Update the time value to get the time value associated
259  // with the input surface coordinates
260  t += layer_width;
261 
262  // Call the macro_map function to calculate the global (spatial)
263  // coordinates associated with the given surface coordinates
264  macro_element_pt->macro_map(t, s, x_project);
265  }
266  }
267  else
268  {
269  // Create an output stream
270  std::ostringstream error_message_stream;
271 
272  // Create an error message
273  error_message_stream << "Incorrect face enumeration input! Should either "
274  << "be L,R,D,U,B or F. You input "
275  << OcTree::Direct_string[i_direct] << "!"
276  << std::endl;
277 
278  // We should never get here so throw an error if we do
279  throw OomphLibError(error_message_stream.str(),
280  OOMPH_CURRENT_FUNCTION,
281  OOMPH_EXCEPTION_LOCATION);
282  } // if ((i_direct==OcTreeNames::L)||(i_direct==OcTreeNames::R)||...
283 
284  // Loop over the global (spatial) coordinates
285  for (unsigned i = 0; i < n_dim - 1; i++)
286  {
287  // Copy the global coordinates over
288  x[i] = x_project[i];
289  }
290 
291  // Finally, add in the final coordinate (the time value)
292  x[n_dim - 1] = t;
293  } // End of macro_element_boundary
294 } // End of namespace oomph
static char t char * s
Definition: cfortran.h:568
cstr elem_len * i
Definition: cfortran.h:603
char t
Definition: cfortran.h:568
Base class for Domains with curvilinear and/or time-dependent boundaries. Domain boundaries are typic...
Definition: domain.h:67
Vector< MacroElement * > Macro_element_pt
Vector of pointers to macro elements.
Definition: domain.h:301
unsigned nmacro_element()
Number of macro elements in domain.
Definition: domain.h:123
virtual void macro_element_boundary(const unsigned &t, const unsigned &i_macro, const unsigned &i_direct, const Vector< double > &s, Vector< double > &f)=0
Vector representation of the i_macro-th macro element boundary i_direct (e.g. N/S/W/E in 2D) at time ...
MacroElement * macro_element_pt(const unsigned &i)
Access to i-th macro element.
Definition: domain.h:116
void macro_element_boundary(const unsigned &time, const unsigned &i_macro, const unsigned &i_direct, const Vector< double > &s, Vector< double > &x)
Vector representation of the i_macro-th macro element boundary i_direct (e.g. N/S/W/E in 2D spatial =...
double T_max
The maximum t-value.
ExtrudedDomain(Domain *domain_pt, const unsigned &n_extruded_element, const double &extrusion_length)
Constructor.
unsigned nmacro_element()
Number of macro elements in domain.
ExtrudedMacroElement * macro_element_pt(const unsigned &i)
Access to i-th extruded macro element.
Domain * Domain_pt
Pointer to the Domain.
double T_min
The minimum t-value (defaults to 0.0 if not specified)
DRAIG: FILL IN COMPLETE DESCRIPTION ONCE FINISHED...
Base class for MacroElement s that are used during mesh refinement in domains with curvlinear and/or ...
Definition: macro_element.h:73
void macro_map(const Vector< double > &s, Vector< double > &r)
The mapping from local to global coordinates at the current time : r(s)
static Vector< std::string > Direct_string
Translate (enumerated) directions into strings.
Definition: octree.h:329
An OomphLibError object which should be thrown when an run-time error is encountered....
DRAIG: FILL IN COMPLETE DESCRIPTION ONCE FINISHED...
//////////////////////////////////////////////////////////////////// ////////////////////////////////...