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