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-2025 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"
29
30namespace 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
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 /// Constructor
61 //=================================================================
63 const unsigned& n_extruded_element,
64 const double& t_min,
65 const double& t_max)
66 : Domain(),
67 Domain_pt(domain_pt),
68 N_extruded_element(n_extruded_element),
69 T_min(t_min),
70 T_max(t_max)
71 {
72 // The number of macro elements to create in the extruded domain
73 unsigned n_macro_element =
75
76 // There are four macro elements
78
79 // Build the 3D extruded macro elements
80 for (unsigned i = 0; i < n_macro_element; i++)
81 {
82 // Create the i-th macro element
84 }
85
86 /*
87 // DRAIG: Might be worth having this as an output function if it's not
88 // already in the base class...
89 // Loop over the number of macro elements
90 for (unsigned i=0;i<n_macro_element;i++)
91 {
92 // Create an output stream
93 std::ofstream some_file;
94
95 // Allocate space for the filename
96 char filename[1000];
97
98 // Number of plot points
99 unsigned n_pts=20;
100
101 // Create the file name
102 snprintf(filename, sizeof(filename), "RESLT/extruded_element%i.dat",i);
103
104 // Open a file with the created filename
105 some_file.open(filename);
106
107 // Output macro element
108 macro_element_pt(i)->output(some_file,n_pts);
109
110 // Close the file
111 some_file.close();
112 }
113 exit(0);
114 */
115 } // End of ExtrudedDomain
116
117 //=================================================================
118 /// Number of macro elements in domain
119 //=================================================================
121 {
122 // Return the size of the macro element container
123 return Macro_element_pt.size();
124 } // End of nmacro_element
125
126 //=================================================================
127 /// Access to i-th extruded macro element
128 //=================================================================
130 {
131 // Return a pointer to the i-th macro element in storage
132 return dynamic_cast<ExtrudedMacroElement*>(Macro_element_pt[i]);
133 } // End of macro_element_pt
134
135 //=================================================================
136 /// Vector representation of the i_macro-th macro element
137 /// boundary i_direct (e.g. N/S/W/E in 2D spatial = 3D space-time).
138 /// NOTE: Some extra care has to be taken here to translate the
139 /// OcTree enumeration to the QuadTree enumeration (in the
140 /// appropriate manner) so that the original Domain object can be
141 /// used to calculate the global coordinate associated with the
142 /// provided local coordinates.
143 //=================================================================
144 void ExtrudedDomain::macro_element_boundary(const unsigned& time,
145 const unsigned& i_macro,
146 const unsigned& i_direct,
147 const Vector<double>& s,
149 {
150 // Make sure that time=0 otherwise this doesn't make sense
151 if (time != 0)
152 {
153 // Create an output stream
154 std::ostringstream error_message_stream;
155
156 // Create an error message
157 error_message_stream << "This output function outputs a space-time\n"
158 << "representation of the domain. As such, it\n"
159 << "does not make sense to output the domain\n"
160 << "at a previous time level!" << std::endl;
161
162 // Throw an error
166 }
167
168 // The number of dimensions
169 unsigned n_dim = 3;
170
171 // The number of macro elements in the original spatial Domain
172 unsigned n_macro = Domain_pt->nmacro_element();
173
174 // Calculate the shifted macro element number (to correspond to the
175 // correct macro element in the original spatial Domain)
176 unsigned true_macro_id = i_macro % n_macro;
177
178 // Which layer of the extruded domain are we in? Layer 0 corresponds to
179 // elements closest to t=T_min and the layer N_extruded_element-1
180 // corresponds to elements closest to t=T_max
181 unsigned i_layer = (i_macro - true_macro_id) / n_macro;
182
183 // Calculate the width of an extrusion layer
184 double layer_width = (T_max - T_min) / double(N_extruded_element);
185
186 // Storage for the global (spatial) coordinates
188
189 // Calculate the time value associated with the start of the i-layer-th
190 // extrusion layer
191 double t_lower = (T_min + i_layer * layer_width);
192
193 // Initialise the time value
194 double t = t_lower;
195
196 // If we're on one of the edges (once projected to 2D in the t-direction)
199 {
200 // Update the time value to get the time value associated
201 // with the input surface coordinates
202 t += 0.5 * (1.0 + s[1]) * layer_width;
203
204 // Get the local coordinate associated with the surface coordinate
205 // in the projected Domain. This is the first surface coordinate
206 // on the left, right, down and up faces of the 3D macro element.
208
209 // If we're on the left face (or the West face once projected to 2D)
211 {
212 // Call the corresponding function through the provided Domain object
215 }
216 // If we're on the right face (or the East face once projected to 2D)
217 else if (i_direct == OcTreeNames::R)
218 {
219 // Call the corresponding function through the provided Domain object
222 }
223 // If we're on the down face (or the South face once projected to 2D)
224 else if (i_direct == OcTreeNames::D)
225 {
226 // Call the corresponding function through the provided Domain object
229 }
230 // If we're on the up face (or the North face once projected to 2D)
231 else if (i_direct == OcTreeNames::U)
232 {
233 // Call the corresponding function through the provided Domain object
236 }
237 }
238 else if ((i_direct == OcTreeNames::B) || (i_direct == OcTreeNames::F))
239 {
240 // Grab the i_macro-th macro element from the Domain object
243
244 // If we're on the back face (or the whole element at t=T_max)
246 {
247 // Call the macro_map function to calculate the global (spatial)
248 // coordinates associated with the given surface coordinates
250 }
251 // If we're on the front face (or the whole element at t=T_max)
252 else if (i_direct == OcTreeNames::F)
253 {
254 // Update the time value to get the time value associated
255 // with the input surface coordinates
256 t += layer_width;
257
258 // Call the macro_map function to calculate the global (spatial)
259 // coordinates associated with the given surface coordinates
261 }
262 }
263 else
264 {
265 // Create an output stream
266 std::ostringstream error_message_stream;
267
268 // Create an error message
269 error_message_stream << "Incorrect face enumeration input! Should either "
270 << "be L,R,D,U,B or F. You input "
272 << std::endl;
273
274 // We should never get here so throw an error if we do
278 } // if ((i_direct==OcTreeNames::L)||(i_direct==OcTreeNames::R)||...
279
280 // Loop over the global (spatial) coordinates
281 for (unsigned i = 0; i < n_dim - 1; i++)
282 {
283 // Copy the global coordinates over
284 x[i] = x_project[i];
285 }
286
287 // Finally, add in the final coordinate (the time value)
288 x[n_dim - 1] = t;
289 } // End of macro_element_boundary
290} // 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...
double size() const
Calculate the size of the element (length, area, volume,...) in Eulerian computational coordinates....
Definition elements.cc:4320
Base class for MacroElement s that are used during mesh refinement in domains with curvlinear and/or ...
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....
TAdvectionDiffusionReactionElement<NREAGENT,DIM,NNODE_1D> elements are isoparametric triangular DIM-d...
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).