36 #include "young_laplace.h" 39 #include "meshes/simple_rectangular_quadmesh.h" 43 using namespace oomph;
56 template<
class ELEMENT>
69 void actions_before_newton_solve();
76 void doc_solution(DocInfo& doc_info, ofstream& trace_file);
82 void create_contact_angle_elements(
const unsigned& b);
96 Node* Control_node_pt;
104 template<
class ELEMENT>
127 cout <<
"Lx = " << l_x <<
" and Ly = " << l_y << endl;
130 Problem::mesh_pt()=
new SimpleRectangularQuadMesh<ELEMENT>(n_x,n_y,l_x,l_y);
134 ELEMENT* prescribed_height_element_pt=
dynamic_cast<ELEMENT*
>(
140 Control_node_pt=
static_cast<Node*
>(
141 prescribed_height_element_pt->node_pt(0));
145 HeightControlElement* height_control_element_pt=0;
148 cout <<
"Controlling height at (x,y) : (" << Control_node_pt->x(0)
149 <<
"," << Control_node_pt->x(1) <<
")" <<
"\n" << endl;
151 height_control_element_pt=
new HeightControlElement(
157 height_control_element_pt->kappa_pt()
170 N_bulk_elements = mesh_pt()->nelement();
177 create_contact_angle_elements(1);
178 Last_element_on_boundary1=mesh_pt()->nelement();
180 create_contact_angle_elements(3);
181 Last_element_on_boundary3=mesh_pt()->nelement();
185 Last_element_on_boundary1=0;
186 Last_element_on_boundary3=0;
195 unsigned n_bound = mesh_pt()->nboundary();
196 for(
unsigned b=0;b<n_bound;b++)
204 unsigned n_node = mesh_pt()->nboundary_node(b);
205 for (
unsigned n=0;n<n_node;n++)
207 mesh_pt()->boundary_node_pt(b,n)->pin(0);
216 for(
unsigned i=0;i<N_bulk_elements;i++)
219 ELEMENT *el_pt =
dynamic_cast<ELEMENT*
>(mesh_pt()->element_pt(i));
239 for (
unsigned e=N_bulk_elements;e<Last_element_on_boundary1;e++)
242 YoungLaplaceContactAngleElement<ELEMENT>* el_pt =
243 dynamic_cast<YoungLaplaceContactAngleElement<ELEMENT>*
>(
244 mesh_pt()->element_pt(e));
249 for (
unsigned e=Last_element_on_boundary1;e<Last_element_on_boundary3;e++)
252 YoungLaplaceContactAngleElement<ELEMENT> *el_pt =
253 dynamic_cast<YoungLaplaceContactAngleElement<ELEMENT>*
>(
254 mesh_pt()->element_pt(e));
267 mesh_pt()->add_element_pt(height_control_element_pt);
272 cout <<
"\nNumber of equations: " << assign_eqn_numbers() << endl;
273 cout <<
"\n********************************************\n" << endl;
282 template<
class ELEMENT>
287 unsigned n_element = mesh_pt()->nboundary_element(b);
290 for(
unsigned e=0;e<n_element;e++)
293 ELEMENT* bulk_elem_pt =
dynamic_cast<ELEMENT*
>(
294 mesh_pt()->boundary_element_pt(b,e));
297 int face_index = mesh_pt()->face_index_at_boundary(b,e);
300 YoungLaplaceContactAngleElement<ELEMENT>* contact_angle_element_pt =
new 301 YoungLaplaceContactAngleElement<ELEMENT>(bulk_elem_pt,face_index);
304 mesh_pt()->add_element_pt(contact_angle_element_pt);
317 template<
class ELEMENT>
328 cout <<
"Solving for Prescribed KAPPA Value = " ;
336 cout <<
"Solving for Prescribed HEIGHT Value = " ;
348 template<
class ELEMENT>
350 ofstream& trace_file)
357 trace_file << Control_node_pt->value(0) ;
367 sprintf(filename,
"%s/soln%i.dat",doc_info.directory().c_str(),
369 some_file.open(filename);
370 for(
unsigned i=0;i<N_bulk_elements;i++)
372 ELEMENT *el_pt =
dynamic_cast<ELEMENT*
>(mesh_pt()->element_pt(i));
373 el_pt->output(some_file,npts);
385 ofstream tangent_file;
386 sprintf(filename,
"%s/tangent_to_contact_line%i.dat",
387 doc_info.directory().c_str(),
389 tangent_file.open(filename);
391 ofstream normal_file;
392 sprintf(filename,
"%s/normal_to_contact_line%i.dat",
393 doc_info.directory().c_str(),
395 normal_file.open(filename);
398 ofstream contact_angle_file;
399 sprintf(filename,
"%s/contact_angle%i.dat",
400 doc_info.directory().c_str(),
402 contact_angle_file.open(filename);
405 Vector<double> tangent(3);
406 Vector<double> normal(3);
407 Vector<double> r_contact(3);
411 for (
unsigned bnd=0;bnd<2;bnd++)
413 unsigned el_lo=N_bulk_elements;
414 unsigned el_hi=Last_element_on_boundary1;
417 el_lo=Last_element_on_boundary1;
418 el_hi=Last_element_on_boundary3;
423 for (
unsigned e=el_lo;e<el_hi;e++)
426 tangent_file <<
"ZONE" << std::endl;
427 normal_file <<
"ZONE" << std::endl;
428 contact_angle_file <<
"ZONE" << std::endl;
431 YoungLaplaceContactAngleElement<ELEMENT>* el_pt =
432 dynamic_cast<YoungLaplaceContactAngleElement<ELEMENT>*
>(
433 mesh_pt()->element_pt(e));
437 for (
unsigned i=0;i<npts;i++)
439 s[0]=-1.0+2.0*double(i)/double(npts-1);
441 dynamic_cast<ELEMENT*
>(el_pt->bulk_element_pt())->
442 position(el_pt->local_coordinate_in_bulk(s),r_contact);
444 el_pt->contact_line_vectors(s,tangent,normal);
445 tangent_file << r_contact[0] <<
" " 446 << r_contact[1] <<
" " 447 << r_contact[2] <<
" " 450 << tangent[2] <<
" " << std::endl;
452 normal_file << r_contact[0] <<
" " 453 << r_contact[1] <<
" " 454 << r_contact[2] <<
" " 457 << normal[2] <<
" " << std::endl;
460 contact_angle_file << r_contact[1] <<
" " 461 << el_pt->actual_cos_contact_angle(s)
468 tangent_file.close();
470 contact_angle_file.close();
474 cout <<
"\n********************************************" << endl << endl;
482 void run_it(
const string& output_directory)
496 doc_info.set_directory(output_directory);
500 sprintf(filename,
"%s/trace.dat",doc_info.directory().c_str());
501 trace_file.open(filename);
505 <<
"VARIABLES=\"<GREEK>k</GREEK>\",\"<GREEK>k</GREEK>_{ex}\",\"h\"" 507 trace_file <<
"ZONE" << std::endl;
531 problem.newton_solve();
553 int main(
int argc,
char* argv[])
557 CommandLineArgs::setup(argc,argv);
565 if (CommandLineArgs::Argc==1)
568 <<
"Running every case with limited number of steps for validation" 577 case_lo=atoi(argv[1]);
578 case_hi=atoi(argv[1]);
587 for (
unsigned my_case=case_lo;my_case<=case_hi;my_case++)
597 <<
"//////////////////////////////////////////////////////////\n" 598 <<
"All pinned solution \n" 599 <<
"//////////////////////////////////////////////////////////\n\n";
605 run_it(
"RESLT_all_pinned");
612 <<
"//////////////////////////////////////////////////////////\n" 613 <<
"Barrel-shaped solution \n" 614 <<
"/////////////////////////////////////////////////////////\n\n";
620 run_it(
"RESLT_barrel_shape");
627 <<
"//////////////////////////////////////////////////////////\n" 628 <<
"T-junction solution \n" 629 <<
"//////////////////////////////////////////////////////////\n\n";
640 run_it(
"RESLT_T_junction");
646 std::cout <<
"Wrong case! Options are:\n" void doc_solution(DocInfo &doc_info, ofstream &trace_file)
Doc the solution. DocInfo object stores flags/labels for where the output gets written to and the tra...
double L_x
Length and width of the domain.
~YoungLaplaceProblem()
Destructor (empty)
double Controlled_height
Height control value.
YoungLaplaceProblem()
Constructor:
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...
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...
unsigned Last_element_on_boundary3
Number of last FaceElement on boundary 3.
bool Use_spines
Use spines (true) or not (false)
unsigned Last_element_on_boundary1
Number of last FaceElement on boundary 1.
unsigned N_bulk_elements
Number of YoungLaplace "bulk" elements (We're attaching the contact angle elements to the bulk mesh â€...
void setup_dependent_parameters_and_sanity_check()
Setup dependent parameters and perform sanity check.
void run_it(const string &output_directory)
double Cos_gamma
Cos of contact angle.
double L_y
Width of domain.
void actions_after_newton_solve()
Update the problem after solve: Empty.
int Case
What case are we considering: Choose one from the enumeration Cases.
void actions_before_newton_solve()
Update the problem before solve.
double Kappa_increment
Increment for prescribed curvature.
double get_exact_kappa()
Exact kappa.
int main(int argc, char *argv[])
bool Use_height_control
Use height control (true) or not (false)?
void create_contact_angle_elements(const unsigned &b)
Create YoungLaplace contact angle elements on the b-th boundary of the problem's mesh and add them to...
double Kappa_initial
Initial value for kappa.
double Controlled_height_increment
Increment for height control.