common_young_laplace_stuff.h
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_COMMON_YOUNG_LAPLACE_STUFF_DOC
31 #define OOMPH_COMMON_YOUNG_LAPLACE_STUFF_DOC
32 #include <assert.h>
33 
34 //===== start_of_namespace========================================
35 /// Namespace for "global" problem parameters
36 //================================================================
37 namespace GlobalParameters
38 {
39 
40  // Independent problem parameters:
41  //--------------------------------
42 
43  /// Use spines (true) or not (false)
44  bool Use_spines = true;
45 
46  /// Use height control (true) or not (false)?
47  bool Use_height_control = true;
48 
49  /// Enumeration for the possible cases
54  };
55 
56  /// What case are we considering: Choose one from the enumeration Cases
58 
59 
60  // "Physical parameters"
61  //----------------------
62 
63  /// Contact angle and its cos (dependent parameter -- is reassigned)
64  double Gamma = MathematicalConstants::Pi/4.0;
65  double Cos_gamma=cos(Gamma);
66 
67  /// Pointer to Data object that stores the prescribed curvature
68  Data* Kappa_pt = 0;
69 
70  /// Initial value for kappa
71  double Kappa_initial = 0.0;
72 
73  /// Height control value
74  double Controlled_height = 0.0;
75 
76  // Resolution parameters
77  //----------------------
78 
79  /// Increase or decrease the value of the control parameters?
80  int Step_sign = 1;
81 
82  /// Number of steps
83  unsigned Nsteps = 5;
84 
85  /// Increment for prescribed curvature
86  double Kappa_increment = -0.05;
87 
88  /// Increment for height control
90 
91  /// Number of element in bulk mesh at which height control is applied.
92  /// Initialise to 0 -- will be overwritte in
93  /// setup_dependent_parameters_and_sanity_check()
94  unsigned Control_element = 0;
95 
96  // Mesh data
97  // ---------
98 
99  /// Length and width of the domain
100  double L_x = 1.0;
101  double L_y = 1.0;
102 
103  /// Number of elements in the mesh
104  unsigned N_x = 8;
105  unsigned N_y = 8;
106 
107  // Spines data
108  // -----------
109 
110  /// Min. first spine angle against horizontal plane
111  double Alpha_min = MathematicalConstants::Pi/2.0;
112 
113  /// Max. first spine angle against horizontal plane
114  double Alpha_max = MathematicalConstants::Pi/2.0;
115 
116  /// Min. second spine angle against horizontal plane
117  double Beta_min = MathematicalConstants::Pi/2.0;
118 
119  /// Max. second pine angle against horizontal plane
120  double Beta_max = MathematicalConstants::Pi/2.0;
121 
122  /// Should the spines rotate in the x and y directions (true)?
124 
125  // end of parameters
126 
127  //-------------------------------------------------------
128  /// Setup dependent parameters and perform sanity check
129  //-------------------------------------------------------
131  {
132 
133  // Reset initial value for kappa
134  Kappa_initial=0.0;
135 
136  // Check that we've got an even number of elements for control element
137  if ((N_x%2!=0)||(N_y%2!=0))
138  {
139  cout << "n_x n_y should even" << endl;
140  abort();
141  }
142 
143  // Find control element
144  Control_element=N_y*N_x/2+N_x/2;
145 
146  // Set up mesh and spines parameters
148  {
149  // Reset parameters (not realLy used for mesh in this
150  // case but for normalisation of spine rotation)
151  L_x=1.0;
152  L_y=1.0;
153 
154  // Rotate outwards
155  Alpha_min=MathematicalConstants::Pi/2.0;
156  Alpha_max=MathematicalConstants::Pi/2.0*0.5;
157  Rotate_spines_in_both_directions=true;
158  }
159  else if (Case==All_pinned)
160  {
161  // Spines angles for all pinned boundary conditions
162  Alpha_min=MathematicalConstants::Pi/2.0*1.5;
163  Alpha_max=MathematicalConstants::Pi/2.0*0.5;
164  Rotate_spines_in_both_directions=true;
165  }
166  else if (Case==Barrel_shape)
167  {
168  // Spines angles for barrel shaped validation
169  Alpha_min=MathematicalConstants::Pi/2.0*1.5;
170  Alpha_max=MathematicalConstants::Pi/2.0*0.5;
171  Rotate_spines_in_both_directions=false;
172  }
174  {
175  // Spines angles for T-junction with non nil contact angle
176  Alpha_min=MathematicalConstants::Pi/2.0*1.5;
177  Alpha_max=MathematicalConstants::Pi/2.0*0.5;
178  Rotate_spines_in_both_directions=false;
179  }
180  else
181  {
182  std::cout << "Never get here: Case = " << Case << std::endl;
183  assert(false);
184  }
185 
186  // Convert angle to cos
187  Cos_gamma = cos(Gamma);
188 
189  } // end of set up
190 
191  // Spine functions
192  //----------------
193 
194  /// \short Spine basis: The position vector to the basis of the spine
195  /// as a function of the two coordinates x_1 and x_2, and its
196  /// derivatives w.r.t. to these coordinates.
197  /// dspine_B[i][j] = d spine_B[j] / dx_i
198  /// Spines start in the (x_1,x_2) plane at (x_1,x_2).
199  void spine_base_function(const Vector<double>& x,
200  Vector<double>& spine_B,
201  Vector< Vector<double> >& dspine_B)
202  {
203 
204  // Bspines and derivatives
205  spine_B[0] = x[0];
206  spine_B[1] = x[1];
207  spine_B[2] = 0.0 ;
208  dspine_B[0][0] = 1.0 ;
209  dspine_B[1][0] = 0.0 ;
210  dspine_B[0][1] = 0.0 ;
211  dspine_B[1][1] = 1.0 ;
212  dspine_B[0][2] = 0.0 ;
213  dspine_B[1][2] = 0.0 ;
214 
215  } // End of bspine functions
216 
217 
218  /// \short Spine: The spine vector field as a function of the two
219  /// coordinates x_1 and x_2, and its derivatives w.r.t. to these coordinates:
220  /// dspine[i][j] = d spine[j] / dx_i
221  void spine_function(const Vector<double>& xx,
222  Vector<double>& spine,
223  Vector< Vector<double> >& dspine)
224  {
225 
226  // Scale lengths
227  Vector<double> x(2,0.0);
228  x[0]=xx[0]/L_x;
229  x[1]=xx[1]/L_y;
230 
231  // Which spine orientation do we have?
232  if (!Rotate_spines_in_both_directions)
233  {
234  /// Spines (and derivatives) are independent of x[0] and rotate
235  /// in the x[1]-direction
236  spine[0]=0.0; // Sx
237  dspine[0][0]=0.0; // dSx/dx[0]
238  dspine[1][0]=0.0; // dSx/dx[1]
239 
240  spine[1]=cos(Alpha_min+(Alpha_max-Alpha_min)*x[1]); // Sy
241  dspine[0][1]=0.0; // dSy/dx[0]
242  dspine[1][1]=-sin(Alpha_min+(Alpha_max-Alpha_min)*x[1])
243  *(Alpha_max-Alpha_min)/L_y; // dSy/dx[1]
244 
245  spine[2]=sin(Alpha_min+(Alpha_max-Alpha_min)*x[1]); // Sz
246  dspine[0][2]=0.0; // dSz/dx[0]
247  dspine[1][2]=cos(Alpha_min+(Alpha_max-Alpha_min)*x[1])
248  *(Alpha_max-Alpha_min)/L_y; // dSz/dx[1]
249  }
250  else
251  {
252  /// Spines are dependent of x[0] AND x[1] and rotate in both directions
253  spine[0]=cos(Alpha_min+(Alpha_max-Alpha_min)*x[0]); // Sx
254  dspine[0][0]=-sin(Alpha_min+(Alpha_max-Alpha_min)*x[0])*
255  (Alpha_max-Alpha_min)/L_x; // dSx/dx[0]
256  dspine[1][0]=0.0; // dSx/dx[1]
257 
258  spine[1]=cos(Alpha_min+(Alpha_max-Alpha_min)*x[1]); // Sy
259  dspine[0][1]=0.0; // dSy/dx[0]
260  dspine[1][1]=-sin(Alpha_min+(Alpha_max-Alpha_min)*x[1])*
261  (Alpha_max-Alpha_min)/L_y; // dSy/dx[1]
262 
263  spine[2]=1.0; // Sz
264  dspine[0][2]=0.0; // dSz/dx[0]
265  dspine[1][2]=0.0; // dSz/dx[1]
266  }
267 
268 
269  } // End spine function
270 
271  // Exact kappa value
272  //------------------
273  double get_exact_kappa()
274  {
275  if (Use_height_control)
276  {
277 
279  {
280  // Mean (!) curvature of spherical cap pinned in the
281  // quarter circular mesh (cylindrical tube)
282  return 4.0*Controlled_height/
283  (Controlled_height*Controlled_height+1.0);
284  }
285  else if (Case==Barrel_shape)
286  {
287  // Mean (!) curvature of barrel that goes through
288  // the corners of the rectangular domain
289  return 2.0*Controlled_height/
290  (Controlled_height*Controlled_height+L_y*L_y/4.0);
291  }
292  else
293  {
294  std::cout << "No exact solution for this case..." << std::endl;
295  return 0.0;
296  }
297  }
298  else
299  {
300  // Return prescribed kappa no height control
301  return 999; //Kappa_pt->value(0);
302  }
303  }
304 
305 
306 } // end of namespace
307 
308 #endif
double L_x
Length and width of the domain.
double Controlled_height
Height control value.
Definition: barrel.cc:55
bool Rotate_spines_in_both_directions
Should the spines rotate in the x and y directions (true)?
double Alpha_min
Min. spine angle against horizontal plane.
Definition: barrel.cc:100
unsigned Nsteps
Number of steps.
void spine_function(const Vector< double > &x, Vector< double > &spine, Vector< Vector< double > > &dspine)
Spine: The spine vector field as a function of the two coordinates x_1 and x_2, and its derivatives w...
Definition: barrel.cc:108
Namespace for "global" problem parameters.
Definition: barrel.cc:48
Data * Kappa_pt
Pointer to Data object that stores the prescribed curvature.
unsigned N_x
Number of elements in the mesh.
double Gamma
Contact angle and its cos (dependent parameter – is reassigned)
void spine_base_function(const Vector< double > &x, Vector< double > &spine_B, Vector< Vector< double > > &dspine_B)
Spine basis: The position vector to the basis of the spine as a function of the two coordinates x_1 a...
Definition: barrel.cc:76
bool Use_spines
Use spines (true) or not (false)
void setup_dependent_parameters_and_sanity_check()
Setup dependent parameters and perform sanity check.
double Cos_gamma
Cos of contact angle.
double Alpha_max
Max. spine angle against horizontal plane.
Definition: barrel.cc:103
double L_y
Width of domain.
int Case
What case are we considering: Choose one from the enumeration Cases.
int Step_sign
Increase or decrease the value of the control parameters?
double Kappa_increment
Increment for prescribed curvature.
double Beta_min
Min. second spine angle against horizontal plane.
double Beta_max
Max. second pine angle against horizontal plane.
Cases
Enumeration for the possible cases.
double get_exact_kappa()
Exact kappa.
Definition: barrel.cc:58
bool Use_height_control
Use height control (true) or not (false)?
double Kappa_initial
Initial value for kappa.
double Controlled_height_increment
Increment for height control.