29 #ifndef OOMPH_hierher_HEAT_TRANSFER_AND_MELT_ELEMENTS_HEADER
30 #define OOMPH_hierher_HEAT_TRANSFER_AND_MELT_ELEMENTS_HEADER
34 #include <oomph-lib-config.h>
50 namespace IntersectionChecker
59 const double& epsilon_parallel=1.0e-15)
62 double denom = ((first_segment_vertex[1][1] - first_segment_vertex[0][1])*
63 (second_segment_vertex[1][0] - second_segment_vertex[0][0])) -
64 ((first_segment_vertex[1][0] - first_segment_vertex[0][0])*
65 (second_segment_vertex[1][1] - second_segment_vertex[0][1]));
67 double nume_a = ((first_segment_vertex[1][0] - first_segment_vertex[0][0])*
68 (second_segment_vertex[0][1] - first_segment_vertex[0][1])) -
69 ((first_segment_vertex[1][1] - first_segment_vertex[0][1])*
70 (second_segment_vertex[0][0] - first_segment_vertex[0][0]));
72 double nume_b = ((second_segment_vertex[1][0] - second_segment_vertex[0][0])*
73 (second_segment_vertex[0][1] - first_segment_vertex[0][1])) -
74 ((second_segment_vertex[1][1] - second_segment_vertex[0][1])*
75 (second_segment_vertex[0][0] - first_segment_vertex[0][0]));
79 if( (
std::fabs(nume_a) < epsilon_parallel) &&
87 double ua = nume_a / denom;
88 double ub = nume_b / denom;
90 if( (ua >= 0.0) && (ua <= 1.0) && (ub >= 0.0) && (ub <= 1.0) )
115 namespace SolarRadiationHelper
124 double& solar_flux_magnitude,
126 double& total_diffuse_radiation)
128 solar_flux_magnitude=0.0;
129 solar_flux_unit_vector[0]= 0.0;
130 solar_flux_unit_vector[1]=-1.0;
131 total_diffuse_radiation=0.0;
170 for (
unsigned i=0;
i<n_intpt;
i++)
210 double &solar_flux_magnitude,
212 solar_flux_unit_vector,
213 double& total_diffuse_radiation)
277 double& solar_flux_magnitude,
279 double& total_diffuse_radiation);
291 const double& y_prev,
292 const double& x_next,
293 const double& y_next,
294 bool& crossing_quadrants,
295 int& n_winding_increment,
314 double radiation=0.0;
316 double solar_flux_magnitude=0.0;
318 double total_diffuse_radiation=0.0;
320 solar_flux_unit_vector,
321 total_diffuse_radiation);
329 radiation+=total_diffuse_radiation*phi_exposed/
336 std::stringstream error_message;
337 error_message <<
"Exposure angle " << phi_exposed
338 <<
" greater than 180^o at ( "
339 <<
x[0] <<
" , " <<
x[1] <<
" )\n"
340 <<
"Actual difference is: "
342 <<
" which exceeds tolerance " << tol << std::endl;
358 double cos_angle=-(
n[0]*solar_flux_unit_vector[0]+
359 n[1]*solar_flux_unit_vector[1]);
366 double theta=
atan2(solar_flux_unit_vector[0],-solar_flux_unit_vector[1]);
381 radiation+=cos_angle*solar_flux_magnitude*tanh_factor;
390 radiation+=cos_angle*solar_flux_magnitude;
410 const double& y_prev,
411 const double& x_next,
412 const double& y_next,
413 bool& crossing_quadrants,
414 int& n_winding_increment,
421 std::stringstream error_message;
423 crossing_quadrants=
false;
426 double y_intersect=0.0;
427 double denom=x_next-x_prev;
434 y_intersect=y_prev-(y_next-y_prev)*x_prev/denom;
436 if ((x_prev>0.0)&&(y_prev>0.0)&&(x_next<0.0)&&(y_next<0.0))
438 crossing_quadrants=
true;
439 error_message <<
"Jumped from upper right quadrant to lower left one\n";
440 oomph_info <<
"Jumped from upper right quadrant to lower left one\n";
441 if (y_intersect==0.0)
443 error_message <<
"..and cannot be repaired!\n";
447 else if (y_intersect<0.0)
449 n_winding_increment=0;
452 else if (y_intersect>0.0)
454 n_winding_increment=1;
457 else if ((x_prev<0.0)&&(y_prev<0.0)&&(x_next>0.0)&&(y_next>0.0))
459 crossing_quadrants=
true;
460 error_message <<
"Jumped from lower left quadrant to upper right one\n";
461 oomph_info <<
"Jumped from lower left quadrant to upper right one\n";
462 if (y_intersect==0.0)
464 error_message <<
"..and cannot be repaired!\n";
468 else if (y_intersect<0.0)
470 n_winding_increment=0;
473 else if (y_intersect>0.0)
475 n_winding_increment=-1;
478 else if ((x_prev<0.0)&&(y_prev>0.0)&&(x_next>0.0)&&(y_next<0.0))
480 crossing_quadrants=
true;
481 error_message <<
"Jumped from upper left quadrant to lower right one\n";
482 oomph_info <<
"Jumped from upper left quadrant to lower right one\n";
483 if (y_intersect==0.0)
485 error_message <<
"..and cannot be repaired!\n";
489 else if (y_intersect>0.0)
491 n_winding_increment=0;
494 else if (y_intersect<0.0)
496 n_winding_increment=1;
499 else if ((x_prev>0.0)&&(y_prev<0.0)&&(x_next<0.0)&&(y_next>0.0))
501 crossing_quadrants=
true;
502 error_message <<
"Jumped from lower right quadrant to upper left one\n";
503 oomph_info <<
"Jumped from lower right quadrant to upper left one\n";
504 if (y_intersect==0.0)
506 error_message <<
"..and cannot be repaired!\n";
510 else if (y_intersect>0.0)
512 n_winding_increment=0;
515 else if (y_intersect<0.0)
517 n_winding_increment=-1;
535 unsigned nnod_el=
nnode();
541 unsigned nnod=shielding_node_pt.size();
542 for (
unsigned j=0;
j<nnod;
j++)
546 if ((shielding_node_pt[
j]==first_vertex_node_pt)||
547 (shielding_node_pt[
j]==second_vertex_node_pt))
554 unsigned j_right=j_left+1;
559 throw OomphLibError(
"Failed to find leftmost node in shielding_node_pt",
573 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
577 for (
unsigned i=0;
i<n_dim-1;
i++)
586 oomph_info <<
"Integration point: " <<
x[0] <<
" " <<
x[1] << std::endl;
593 Node* nod_pt=shielding_node_pt[0];
596 double x_prev=nod_pt->
x(0)-
x[0];
597 double y_prev=nod_pt->
x(1)-
x[1];
605 "Leftmost point in shielding nodes is not to the left of current int pt",
612 double phi_prev=
atan2(y_prev,x_prev);
615 << nod_pt->
x(0) <<
" " << nod_pt->
x(1)
616 <<
" phi_raw: " << phi_prev;
627 oomph_info <<
" phi_adj: " << phi_prev << std::endl;
631 double phi_left=phi_prev;
636 for (
unsigned j=1;
j<=j_left;
j++)
638 Node* nod_pt=shielding_node_pt[
j];
639 double x_next=nod_pt->
x(0)-
x[0];
640 double y_next=nod_pt->
x(1)-
x[1];
641 double phi_next=
atan2(y_next,x_next);
644 << nod_pt->
x(0) <<
" " << nod_pt->
x(1)
645 <<
" phi_raw: " << phi_next;
651 bool no_problem=
true;
652 bool crossing_quadrants=
false;
653 int n_winding_increment=0;
668 n_winding+=n_winding_increment;
673 std::stringstream error_message;
674 error_message << error_string;
675 error_message <<
"\n x/y_prev, x/y_next:"
679 << y_next <<
" "<< std::endl;
680 error_message <<
"for point at "
681 <<
x[0] <<
" " <<
x[1] << std::endl;
682 error_message <<
"chain of shielding nodes on left:\n";
683 for (
unsigned jj=1;jj<=j_left;jj++)
685 Node* nnod_pt=shielding_node_pt[jj];
686 error_message << nnod_pt->
x(0) <<
" "
687 << nnod_pt->
x(1) <<
"\n";
699 if (!crossing_quadrants)
701 if ((x_prev<0.0)&&(x_next<0.0))
703 if ((y_prev>=0.0)&&(y_next<0.0))
707 else if ((y_prev<0.0)&&(y_next>=0.0))
719 oomph_info <<
" phi_adj: " << phi_next << std::endl;
722 if (phi_next<phi_left)
739 nod_pt=shielding_node_pt[nnod-1];
742 x_prev=nod_pt->
x(0)-
x[0];
743 y_prev=nod_pt->
x(1)-
x[1];
751 "Rightmost point in shielding nodes is not to the right of current int pt",
758 phi_prev=
atan2(y_prev,x_prev);
761 double phi_right=phi_prev;
765 for (
unsigned j=nnod-2;
j>=j_right;
j--)
767 Node* nod_pt=shielding_node_pt[
j];
768 double x_next=nod_pt->
x(0)-
x[0];
769 double y_next=nod_pt->
x(1)-
x[1];
770 double phi_next=
atan2(y_next,x_next);
776 bool no_problem=
true;
777 bool crossing_quadrants=
false;
778 int n_winding_increment=0;
793 n_winding+=n_winding_increment;
798 std::stringstream error_message;
799 error_message << error_string;
800 error_message <<
"\n x/y_prev, x/y_next:"
804 << y_next <<
" "<< std::endl;
805 error_message <<
"for point at "
806 <<
x[0] <<
" " <<
x[1] << std::endl;
807 error_message <<
"chain of shielding nodes on right:\n";
808 for (
unsigned jj=j_right;jj<nnod;jj++)
810 Node* nnod_pt=shielding_node_pt[jj];
811 error_message << nnod_pt->
x(0) <<
" "
812 << nnod_pt->
x(1) <<
"\n";
823 if (!crossing_quadrants)
825 if ((x_prev<0.0)&&(x_next<0.0))
827 if ((y_prev>=0.0)&&(y_next<0.0))
831 else if ((y_prev<0.0)&&(y_next>=0.0))
842 if (phi_next>phi_right)
866 std::ostream &outfile,
const double&
radius)
877 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
882 for (
unsigned i=0;
i<n_dim-1;
i++)
905 outfile <<
x[0] <<
" "
921 std::ostream &outfile,
const double&
radius)
932 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
937 for (
unsigned i=0;
i<n_dim-1;
i++)
950 for (
unsigned j=0;
j<nplot;
j++)
958 outfile <<
x[0] <<
" "
970 std::ostream &outfile,
const double&
radius)
981 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
986 for (
unsigned i=0;
i<n_dim-1;
i++)
999 for (
unsigned j=0;
j<nplot;
j++)
1007 outfile <<
x[0] <<
" "
1032 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
1034 outfile <<
"ZONE\n";
1037 for (
unsigned i=0;
i<n_dim-1;
i++)
1052 outfile <<
x[0] <<
" "
1084 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
1086 outfile <<
"ZONE\n";
1089 for (
unsigned i=0;
i<n_dim-1;
i++)
1107 outfile <<
x[0] <<
" "
1182 throw OomphLibError(
"Non-dim zero-centrigrade offset not set",
1205 std::ofstream outfile;
1209 visible_intpts_in_current_element,
1222 std::ofstream& outfile);
1228 for (
unsigned ipt=0;ipt<nint;ipt++)
1248 const unsigned& ipt,
1251 const bool& add_solid_position_data=
true)
1255 for (
unsigned e=0;
e<
n;
e++)
1260 "Element has already been added!",
1268 std::make_pair(illuminating_el_pt,illuminating_integration_point_index));
1271 unsigned nnod=illuminating_el_pt->
nnode();
1272 for (
unsigned j=0;
j<nnod;
j++)
1276 for (
unsigned jj=0;jj<nnod;jj++)
1287 if (add_solid_position_data)
1290 if (solid_node_pt!=0)
1306 std::ostream &outfile,
1307 const unsigned& integration_point=UINT_MAX);
1323 for (
unsigned e=0;
e<n_contrib;
e++)
1335 (r_illuminated,n_illuminated,visible_integration_points);
1378 std::ofstream &outfile)
1381 if (outfile.is_open())
1383 outfile <<
"ZONE\n";
1384 outfile << r_illuminated[0] <<
" "
1385 << r_illuminated[1] <<
"0 0\n";
1389 double contribution=0.0;
1392 unsigned n_node =
nnode();
1399 unsigned nint=visible_intpts_in_current_element.size();
1400 for (
unsigned ii=0;ii<nint;ii++)
1403 unsigned ipt=visible_intpts_in_current_element[ii];
1414 double interpolated_u=0;
1417 for(
unsigned l=0;l<n_node;l++)
1424 for(
unsigned i=0;
i<2;
i++)
1435 ray[0]=r_illuminating[0]-r_illuminated[0];
1436 ray[1]=r_illuminating[1]-r_illuminated[1];
1440 double inv_length=1.0/
sqrt(ray[0]*ray[0]+ray[1]*ray[1]);
1446 e_phi[0]= inv_length*ray[1];
1447 e_phi[1]=-inv_length*ray[0];
1450 double cos_phi=inv_length*(n_illuminated[0]*ray[0]+
1451 n_illuminated[1]*ray[1]);
1460 0.5*cos_phi*
std::fabs(inv_length*(interpolated_dxds[0]*e_phi[0]+
1461 interpolated_dxds[1]*e_phi[1]));
1465 contribution+=integrand*
w;
1467 if (outfile.is_open())
1469 outfile << r_illuminating[0] <<
" "
1470 << r_illuminating[1] <<
" "
1477 return contribution;
1488 std::ostream &outfile,
const unsigned& integration_point)
1501 if (integration_point!=UINT_MAX)
1503 ipt_lo=integration_point;
1504 ipt_hi=integration_point;
1508 for (
unsigned ipt=ipt_lo;ipt<=ipt_hi;ipt++)
1517 outfile <<
"ZONE\n";
1518 outfile << r_illuminated[0] <<
" " << r_illuminated[1] <<
"\n";
1522 for (
unsigned i2=0;i2<n_illuminating;i2++)
1531 for (
unsigned ipt2=0;ipt2<n_pts;ipt2++)
1544 outfile << r_illuminating[0] <<
" " << r_illuminating[1] <<
"\n";
1545 outfile << r_illuminated[0] <<
" " << r_illuminated[1] <<
"\n";
1565 template <
class ELEMENT>
1603 const unsigned &
i)
const
1626 outfile <<
"ZONE\n";
1629 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
1632 for (
unsigned i=0;
i<n_dim-1;
i++)
1648 double outgoing_sb_radiation=
1653 (ipt,
x,unit_normal);
1663 if (
fabs(
flux-(incoming_sb_radiation-outgoing_sb_radiation)))
1665 std::stringstream error_message;
1667 <<
"Difference between incoming ( " << incoming_sb_radiation
1668 <<
" ) and outgoing ( " << outgoing_sb_radiation <<
" ) is "
1669 << (incoming_sb_radiation-outgoing_sb_radiation)
1670 <<
" but total flux is " <<
flux <<
" so difference is "
1671 <<
fabs(
flux-(incoming_sb_radiation-outgoing_sb_radiation));
1673 error_message.str(),
1681 for(
unsigned i=0;
i<n_dim;
i++)
1683 outfile <<
x[
i] <<
" ";
1690 outfile <<
flux <<
" ";
1693 outfile << incoming_sb_radiation <<
" ";
1696 outfile << outgoing_sb_radiation <<
" ";
1699 for(
unsigned i=0;
i<n_dim;
i++)
1701 outfile << unit_normal[
i] <<
" ";
1703 outfile << std::endl;
1742 double outgoing_sb_radiation=this->
sigma()*
pow((u+this->
theta_0()),4);
1751 flux=incoming_sb_radiation-outgoing_sb_radiation+incoming_atmospheric;
1768 template<
class ELEMENT>
1771 const int &face_index) :
1778 if(bulk_el_pt->
dim()==3)
1785 "This face element will not work correctly if nodes are hanging.\n";
1786 error_string+=
"Use the refineable version instead. ";
1801 "This element will almost certainly not work in non-2D problems, though it should be easy enough to upgrade... Volunteers?\n",
1817 namespace StefanBoltzmannHelper
1862 const bool& populate_bin,
1863 Vector<std::pair<unsigned,unsigned> >& intersected_bin,
1865 std::ofstream& outfile)
1870 if (outfile.is_open())
1876 "Not outputting while bin is being populated...\n",
1889 if (ray_vertex[1][1]<ray_vertex[0][1])
1891 lower_ray_vertex=ray_vertex[1];
1892 upper_ray_vertex=ray_vertex[0];
1899 <<
"ZONE T=\"ray\"\n"
1900 <<ray_vertex[0][0] <<
" " << ray_vertex[0][1] <<
"\n"
1901 <<ray_vertex[1][0] <<
" " << ray_vertex[1][1] <<
"\n";
1917 intersected_bin.push_back(std::make_pair(ix_start,iy_start));
1921 if (lower_ray_vertex[0]==upper_ray_vertex[0])
1927 for (
unsigned i=iy_start+1;
i<=iy_end;
i++)
1935 intersected_bin.push_back(std::make_pair(ix_start,
i));
1944 (upper_ray_vertex[1]-lower_ray_vertex[1])/
1945 (upper_ray_vertex[0]-lower_ray_vertex[0]);
1948 unsigned iy=iy_start;
1957 while (y_this_bin_min<upper_ray_vertex[1])
1962 if (lower_ray_vertex[0]>upper_ray_vertex[0])
1968 x_intersect=lower_ray_vertex[0]+
1969 (y_this_bin_max-lower_ray_vertex[1])/slope;
1982 unsigned i_lo=ix_start;
1983 unsigned i_hi=ix_intersect;
1992 i_hi=ix_start-unit_offset;
2001 if (i_hi==
Nx_bin) i_hi-=1;
2004 for (
unsigned i=i_lo;
i<=i_hi;
i++)
2011 if (x_left_end_bin>upper_ray_vertex[0])
2019 if (x_right_end_bin<upper_ray_vertex[0])
2028 if (x_left_end_bin>
std::max(upper_ray_vertex[0],lower_ray_vertex[0]))
2032 else if (x_right_end_bin<
std::min(upper_ray_vertex[0],
2033 lower_ray_vertex[0]))
2047 intersected_bin.push_back(std::make_pair(
i,iy));
2054 ix_start=ix_intersect;
2057 y_this_bin_min+=
Dx[1];
2058 y_this_bin_max+=
Dx[1];
2068 unsigned nbin=intersected_bin.size();
2069 for (
unsigned i=0;
i<nbin;
i++)
2071 unsigned ix=intersected_bin[
i].first;
2072 unsigned iy=intersected_bin[
i].second;
2075 double x_hi=x_lo+
Dx[0];
2077 double y_hi=y_lo+
Dx[1];
2080 << x_lo <<
" " << y_lo <<
"\n"
2081 << x_hi <<
" " << y_lo <<
"\n"
2082 << x_hi <<
" " << y_hi <<
"\n"
2083 << x_lo <<
" " << y_hi <<
"\n"
2084 << x_lo <<
" " << y_lo <<
"\n";
2096 for (
unsigned ix=0;ix<
Nx_bin;ix++)
2098 for (
unsigned iy=0;iy<
Ny_bin;iy++)
2104 double x_hi=x_lo+
Dx[0];
2106 double y_hi=y_lo+
Dx[1];
2108 bin_file <<
"ZONE I=2, J=2\n"
2109 << x_lo <<
" " << y_lo <<
"\n"
2110 << x_hi <<
" " << y_lo <<
"\n"
2111 << x_lo <<
" " << y_hi <<
"\n"
2112 << x_hi <<
" " << y_hi <<
"\n";
2132 unsigned nel=sb_face_element_pt.size();
2133 for (
unsigned e=0;
e<nel;
e++)
2137 sb_face_element_pt[
e]);
2141 std::stringstream error_message;
2142 error_message <<
"Failed to cast possible intersecting element "
2144 <<
" to StefanBoltzmannRadiationBase";
2146 error_message.str(),
2153 for (
unsigned j_sample=0;j_sample<
Nsample;j_sample++)
2162 outfile << sample_point[0] <<
" " << sample_point[1] <<
"\n";
2178 std::ofstream some_file;
2182 unsigned nel=sb_face_element_pt.size();
2183 for (
unsigned e_illuminated=0;e_illuminated<nel;e_illuminated++)
2187 sb_face_element_pt[e_illuminated]);
2189 if (illuminated_el_pt==0)
2191 std::stringstream error_message;
2192 error_message <<
"Failed to cast illuminated element "
2194 <<
" to StefanBoltzmannRadiationBase";
2196 error_message.str(),
2218 const bool use_bins=
true;
2242 unsigned nel=sb_face_element_pt.size();
2243 for (
unsigned e_illuminated=0;e_illuminated<nel;e_illuminated++)
2247 sb_face_element_pt[e_illuminated]);
2249 if (illuminated_el_pt==0)
2251 std::stringstream error_message;
2252 error_message <<
"Failed to cast illuminated element "
2254 <<
" to StefanBoltzmannRadiationBase";
2256 error_message.str(),
2264 for (
unsigned ipt_illuminated=0;ipt_illuminated<nint;ipt_illuminated++)
2274 for (
unsigned i=0;
i<2;
i++)
2283 double percentage_offset=5.0;
2284 for (
unsigned i=0;
i<2;
i++)
2296 const bool test_horizontal_and_vertical_rays=
false;
2297 if (test_horizontal_and_vertical_rays)
2306 bool populate_bin=
true;
2307 std::ofstream dummy_file;
2309 sample_vertex[0].resize(2);
2310 sample_vertex[1].resize(2);
2311 sample_vertex[0][0]=-0.9;
2312 sample_vertex[0][1]=0.9;
2313 sample_vertex[1][0]=0.9;
2314 sample_vertex[1][1]=0.9;
2318 sb_face_element_pt[0]);
2322 dummy_intersected_bin,
2336 bool populate_bin=
true;
2337 std::ofstream dummy_file;
2339 sample_vertex[0].resize(2);
2340 sample_vertex[1].resize(2);
2341 sample_vertex[0][0]= 0.9;
2342 sample_vertex[0][1]=-0.9;
2343 sample_vertex[1][0]=-0.9;
2344 sample_vertex[1][1]=-0.9;
2348 sb_face_element_pt[0]);
2352 dummy_intersected_bin,
2364 bool populate_bin=
true;
2365 std::ofstream dummy_file;
2367 sample_vertex[0].resize(2);
2368 sample_vertex[1].resize(2);
2369 sample_vertex[0][0]=-0.7;
2370 sample_vertex[0][1]=-0.9;
2371 sample_vertex[1][0]=-0.7;
2372 sample_vertex[1][1]= 0.9;
2376 sb_face_element_pt[0]);
2380 dummy_intersected_bin,
2392 bool populate_bin=
true;
2393 std::ofstream dummy_file;
2395 sample_vertex[0].resize(2);
2396 sample_vertex[1].resize(2);
2397 sample_vertex[0][0]= 0.7;
2398 sample_vertex[0][1]= 0.9;
2399 sample_vertex[1][0]= 0.7;
2400 sample_vertex[1][1]=-0.9;
2404 sb_face_element_pt[0]);
2408 dummy_intersected_bin,
2419 nel=sb_face_element_pt.size();
2420 for (
unsigned e=0;
e<nel;
e++)
2424 sb_face_element_pt[
e]);
2428 std::stringstream error_message;
2429 error_message <<
"Failed to cast possible intersecting element "
2431 <<
" to StefanBoltzmannRadiationBase";
2433 error_message.str(),
2441 sample_vertex[0].resize(2);
2442 sample_vertex[1].resize(2);
2447 unsigned j_sample=0;
2454 for (
unsigned j_sample=1;j_sample<
Nsample;j_sample++)
2467 bool populate_bin=
true;
2468 std::ofstream dummy_file;
2471 dummy_intersected_bin,
2476 sample_vertex[0]=sample_vertex[1];
2482 << t_end_bin-t_start_bin << std::endl;
2485 nel=sb_face_element_pt.size();
2488 unsigned nintpt_all=sb_face_element_pt[0]->integral_pt()->nweight();
2491 const bool exploit_symmetry=
true;
2498 if (exploit_symmetry)
2500 nintpt_all=sb_face_element_pt[0]->integral_pt()->nweight();
2502 for (
unsigned e=0;
e<nel;
e++)
2504 aux[
e].resize(nintpt_all);
2505 for (
unsigned ipt=0;ipt<nintpt_all;ipt++)
2507 aux[
e][ipt].resize(nel);
2513 for (
unsigned e_illuminated=0;e_illuminated<nel;e_illuminated++)
2517 sb_face_element_pt[e_illuminated]);
2520 if (illuminated_el_pt==0)
2522 std::stringstream error_message;
2523 error_message <<
"Failed to cast illuminated element "
2525 <<
" to StefanBoltzmannRadiationBase";
2527 error_message.str(),
2539 for (
unsigned ipt_illuminated=0;ipt_illuminated<nint;ipt_illuminated++)
2551 unit_normal_illuminated);
2557 if (exploit_symmetry) e_lo=e_illuminated;
2558 for (
unsigned e_illuminating=e_lo;e_illuminating<nel;e_illuminating++)
2562 sb_face_element_pt[e_illuminating]);
2565 if (illuminating_el_pt==0)
2567 std::stringstream error_message;
2568 error_message <<
"Failed to cast illuminating element "
2570 <<
" to StefanBoltzmannRadiationBase";
2572 error_message.str(),
2589 for (
unsigned ipt_illuminating=0;ipt_illuminating<nint;
2598 illuminating_el_pt->
interpolated_x(s_illuminating,r_illuminating);
2601 illuminating_face_el_pt->
2602 outer_unit_normal(s_illuminating,
2603 unit_normal_illuminating);
2607 ray[0]=r_illuminated[0]-r_illuminating[0];
2608 ray[1]=r_illuminated[1]-r_illuminating[1];
2612 ray_vertex[0].resize(2);
2613 ray_vertex[1].resize(2);
2614 ray_vertex[0][0]=r_illuminated[0];
2615 ray_vertex[0][1]=r_illuminated[1];
2616 ray_vertex[1][0]=r_illuminating[0];
2617 ray_vertex[1][1]=r_illuminating[1];
2621 double dot_illuminating=
2622 (unit_normal_illuminating[0]*ray[0]+
2623 unit_normal_illuminating[1]*ray[1]);
2624 if (dot_illuminating>0.0)
2629 double dot_illuminated=
2630 (unit_normal_illuminated[0]*ray[0]+
2631 unit_normal_illuminated[1]*ray[1]);
2632 if (dot_illuminated<0.0)
2645 sprintf(
filename,
"RESLT/latest_ray.dat");
2651 bool populate_bin=
false;
2663 pause(
"done latest ray");
2668 segment_vertex[0].resize(2);
2669 segment_vertex[1].resize(2);
2672 bool have_intersection=
false;
2673 unsigned nbin=intersected_bin.size();
2674 for (
unsigned b=0;
b<nbin;
b++)
2677 unsigned i=intersected_bin[
b].first;
2678 unsigned j=intersected_bin[
b].second;
2681 for (std::set<FiniteElement*>::iterator it=
2690 if (illuminated_el_pt==0)
2692 std::stringstream error_message;
2694 <<
"Failed to cast possibly blocking element "
2695 <<
" to StefanBoltzmannRadiationBase";
2697 error_message.str(),
2703 if ((el_pt!=illuminated_el_pt)&&
2704 (el_pt!=illuminating_el_pt))
2709 for (
unsigned j_sample=0;j_sample<
Nsample-1;j_sample++)
2728 segment_vertex,ray_vertex);
2733 have_intersection=
true;
2738 if (have_intersection)
break;
2740 if (have_intersection)
break;
2745 if (!have_intersection)
2748 illuminating_integration_point_index.
2749 push_back(ipt_illuminating);
2758 segment_vertex[0].resize(2);
2759 segment_vertex[1].resize(2);
2762 bool have_intersection=
false;
2763 for (
unsigned e_intersect=0;e_intersect<nel;
2768 if (! ( (e_intersect==e_illuminated) ||
2769 (e_intersect==e_illuminating) ) )
2778 sb_face_element_pt[e_intersect]->
2782 sb_face_element_pt[e_intersect]->
2783 interpolated_x(
s,segment_vertex[0]);
2787 sb_face_element_pt[e_intersect]->
2791 sb_face_element_pt[e_intersect]->
2792 interpolated_x(
s,segment_vertex[1]);
2796 segment_vertex,ray_vertex);
2800 have_intersection=
true;
2805 if (have_intersection)
2812 if (!have_intersection)
2815 illuminating_integration_point_index.
2816 push_back(ipt_illuminating);
2827 unsigned npt=illuminating_integration_point_index.size();
2832 ipt_illuminated,illuminating_el_pt,
2833 illuminating_integration_point_index);
2836 if (exploit_symmetry)
2838 for (
unsigned i_ing=0;i_ing<npt;i_ing++)
2841 [illuminating_integration_point_index[i_ing]]
2842 [e_illuminated].push_back(ipt_illuminated);
2853 if (exploit_symmetry)
2856 for (
unsigned e_illuminated=0;e_illuminated<nel;e_illuminated++)
2860 sb_face_element_pt[e_illuminated]);
2863 if (illuminated_el_pt==0)
2865 std::stringstream error_message;
2866 error_message <<
"Failed to cast illuminated element "
2868 <<
" to StefanBoltzmannRadiationBase";
2870 error_message.str(),
2878 for (
unsigned ipt_illuminated=0;ipt_illuminated<nint;ipt_illuminated++)
2881 for (
unsigned e_illuminating=0;
2882 e_illuminating<e_illuminated;e_illuminating++)
2886 sb_face_element_pt[e_illuminating]);
2889 if (illuminating_el_pt==0)
2891 std::stringstream error_message;
2892 error_message <<
"Failed to cast illuminating element "
2894 <<
" to StefanBoltzmannRadiationBase";
2896 error_message.str(),
2903 aux[e_illuminated][ipt_illuminated][e_illuminating];
2904 unsigned npt=illuminating_integration_point_index.size();
2909 ipt_illuminated,illuminating_el_pt,
2910 illuminating_integration_point_index);
2918 oomph_info <<
"Time for setting up mutual Stefan Boltzmann radiation: "
2919 << t_end-t_start << std::endl;
AnnoyingScalar cos(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:136
AnnoyingScalar atan2(const AnnoyingScalar &y, const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:139
AnnoyingScalar sin(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:137
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
Array< double, 1, 3 > e(1./3., 0.5, 2.)
RowVector3d w
Definition: Matrix_resize_int.cpp:3
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
Scalar * b
Definition: benchVecAdd.cpp:17
TimeStepper *& time_stepper_pt()
Return the pointer to the timestepper.
Definition: nodes.h:238
Definition: elements.h:4338
int & face_index()
Definition: elements.h:4626
void outer_unit_normal(const Vector< double > &s, Vector< double > &unit_normal) const
Compute outer unit normal at the specified local coordinate.
Definition: elements.cc:6006
double zeta_nodal(const unsigned &n, const unsigned &k, const unsigned &i) const
Definition: elements.h:4497
double interpolated_x(const Vector< double > &s, const unsigned &i) const
Definition: elements.h:4528
Definition: elements.h:4998
Definition: elements.h:1313
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
Definition: elements.h:2175
double size() const
Definition: elements.cc:4290
virtual double interpolated_x(const Vector< double > &s, const unsigned &i) const
Return FE interpolated coordinate x[i] at local coordinate s.
Definition: elements.cc:3962
virtual void dshape_local_at_knot(const unsigned &ipt, Shape &psi, DShape &dpsids) const
Definition: elements.cc:3239
unsigned dim() const
Definition: elements.h:2611
unsigned nnode() const
Return the number of nodes.
Definition: elements.h:2210
Integral *const & integral_pt() const
Return the pointer to the integration scheme (const version)
Definition: elements.h:1963
virtual void get_s_plot(const unsigned &i, const unsigned &nplot, Vector< double > &s, const bool &shifted_to_interior=false) const
Definition: elements.h:3148
double nodal_position(const unsigned &n, const unsigned &i) const
Definition: elements.h:2317
unsigned nodal_dimension() const
Return the required Eulerian dimension of the nodes in this element.
Definition: elements.h:2484
virtual void set_integration_scheme(Integral *const &integral_pt)
Set the spatial integration scheme.
Definition: elements.cc:3210
unsigned add_external_data(Data *const &data_pt, const bool &fd=true)
Definition: elements.cc:307
Definition: integral.h:49
virtual double knot(const unsigned &i, const unsigned &j) const =0
Return local coordinate s[j] of i-th integration point.
virtual unsigned nweight() const =0
Return the number of integration points of the scheme.
virtual double weight(const unsigned &i) const =0
Return weight of i-th integration point.
double & x(const unsigned &i)
Return the i-th nodal coordinate.
Definition: nodes.h:1060
double value(const unsigned &i) const
Definition: nodes.cc:2408
Definition: oomph_definitions.h:222
Definition: oomph_definitions.h:267
Definition: refineable_elements.h:97
Definition: temporary_stefan_boltzmann_elements.h:150
void output_limiting_angles(std::ostream &outfile)
Output illumination angles for all integration points.
Definition: temporary_stefan_boltzmann_elements.h:1020
bool smoothed_sun_shadow_is_enabled()
Disable smoothing of shadow.
Definition: temporary_stefan_boltzmann_elements.h:194
Vector< std::pair< double, double > > Diffuse_limit_angles
Definition: temporary_stefan_boltzmann_elements.h:270
void output_atmospheric_radiation(std::ostream &outfile)
Output diffuse and direct radiation.
Definition: temporary_stefan_boltzmann_elements.h:1068
void output_diffuse_radiation_cone_max_angle(std::ostream &outfile, const double &radius)
Definition: temporary_stefan_boltzmann_elements.h:920
void disable_smoothed_sun_shadow()
Disable smoothing of shadow.
Definition: temporary_stefan_boltzmann_elements.h:188
void(*&)(const double &time, double &solar_flux_magnitude, Vector< double > &solar_flux_unit_vector, double &total_diffuse_radiation) atmospheric_radiation_fct_pt()
Reference to the atmospheric radiation function pointer.
Definition: temporary_stefan_boltzmann_elements.h:209
void enable_smoothed_sun_shadow(const double &alpha_tanh_smooth_sun_shadow=100.0)
Definition: temporary_stefan_boltzmann_elements.h:180
SolarRadiationBase()
Constructor.
Definition: temporary_stefan_boltzmann_elements.h:155
void output_diffuse_radiation_cone(std::ostream &outfile, const double &radius)
Output cone of diffuse radiation for all integration points.
Definition: temporary_stefan_boltzmann_elements.h:865
bool Smoothed_sun_shadow
Use tanh profile to smooth solar shadows.
Definition: temporary_stefan_boltzmann_elements.h:261
void update_limiting_angles(const Vector< Node * > &shielding_node_pt)
Definition: temporary_stefan_boltzmann_elements.h:528
virtual double atmospheric_radiation(const unsigned &intpt, const double &time, const Vector< double > &x, const Vector< double > &n)
Definition: temporary_stefan_boltzmann_elements.h:309
double Alpha_tanh_smooth_sun_shadow
Factor for tanh profile to smooth solar shadows.
Definition: temporary_stefan_boltzmann_elements.h:264
double alpha_tanh_smooth_sun_shadow()
Definition: temporary_stefan_boltzmann_elements.h:202
void(* Atmospheric_radiation_fct_pt)(const double &time, double &solar_flux_magnitude, Vector< double > &solar_flux_unit_vector, double &total_diffuse_radiation)
Definition: temporary_stefan_boltzmann_elements.h:276
void check_quadrant_jump(const double &x_prev, const double &y_prev, const double &x_next, const double &y_next, bool &crossing_quadrants, int &n_winding_increment, std::string &error_string, bool &no_problem)
Definition: temporary_stefan_boltzmann_elements.h:409
void output_diffuse_radiation_cone_min_angle(std::ostream &outfile, const double &radius)
Definition: temporary_stefan_boltzmann_elements.h:969
Data *const & variable_position_pt() const
Pointer to variable_position data (const version)
Definition: nodes.h:1765
Definition: temporary_stefan_boltzmann_elements.h:1132
Vector< Vector< std::pair< StefanBoltzmannRadiationBase *, Vector< unsigned > > > > Stefan_boltzmann_illumination_info
Definition: temporary_stefan_boltzmann_elements.h:1361
void add_stefan_boltzmann_illumination_info(const unsigned &ipt, StefanBoltzmannRadiationBase *illuminating_el_pt, Vector< unsigned > &illuminating_integration_point_index, const bool &add_solid_position_data=true)
Definition: temporary_stefan_boltzmann_elements.h:1247
double sigma()
Non-dim Stefan Boltzmann constant (switched off by default)
Definition: temporary_stefan_boltzmann_elements.h:1157
void output_stefan_boltzmann_radiation_rays(std::ostream &outfile, const unsigned &integration_point=UINT_MAX)
Definition: temporary_stefan_boltzmann_elements.h:1487
double *& sigma_pt()
Pointer to non-dim Stefan Boltzmann constant.
Definition: temporary_stefan_boltzmann_elements.h:1151
double * Theta_0_pt
Pointer to non-dim zero centrigrade offset in Stefan Boltzmann law.
Definition: temporary_stefan_boltzmann_elements.h:1347
double theta_0()
Definition: temporary_stefan_boltzmann_elements.h:1172
StefanBoltzmannRadiationBase()
Constructor.
Definition: temporary_stefan_boltzmann_elements.h:1137
double contribution_to_stefan_boltzmann_radiation(const Vector< double > &r_illuminated, const Vector< double > &n_illuminated, const Vector< unsigned > &visible_intpts_in_current_element)
Definition: temporary_stefan_boltzmann_elements.h:1199
void wipe_stefan_boltzmann_illumination_info()
Wipe illumination info.
Definition: temporary_stefan_boltzmann_elements.h:1225
double *& theta_0_pt()
Pointer to non-dim zero centrigrade offset in Stefan Boltzmann law.
Definition: temporary_stefan_boltzmann_elements.h:1154
void output_stefan_boltzmann_radiation(std::ostream &outfile)
Output Stefan Boltzmann radiation: x,y,in,out,n_x,n_y.
double incoming_stefan_boltzmann_radiation(const unsigned &ipt, const Vector< double > &r_illuminated, const Vector< double > &n_illuminated)
Definition: temporary_stefan_boltzmann_elements.h:1314
double * Sigma_pt
Pointer to non-dim Stefan Boltzmann constant.
Definition: temporary_stefan_boltzmann_elements.h:1344
Definition: temporary_stefan_boltzmann_elements.h:1572
StefanBoltzmannUnsteadyHeatFluxElement(FiniteElement *const &bulk_el_pt, const int &face_index)
Definition: temporary_stefan_boltzmann_elements.h:1770
StefanBoltzmannUnsteadyHeatFluxElement(const StefanBoltzmannUnsteadyHeatFluxElement &dummy)
Broken copy constructor.
Definition: temporary_stefan_boltzmann_elements.h:1582
void output_stefan_boltzmann_radiation(std::ostream &outfile)
Definition: temporary_stefan_boltzmann_elements.h:1613
virtual void get_flux(const unsigned &ipt, const double &time, const Vector< double > &x, const Vector< double > &n, const double &u, double &flux)
Definition: temporary_stefan_boltzmann_elements.h:1721
void set_integration_scheme(Integral *const &integral_pt)
Definition: temporary_stefan_boltzmann_elements.h:1590
double zeta_nodal(const unsigned &n, const unsigned &k, const unsigned &i) const
Definition: temporary_stefan_boltzmann_elements.h:1602
Definition: heat_transfer_and_melt_elements.h:123
UnsteadyHeatPrescribedFluxFctPt Flux_fct_pt
Function pointer to the (global) prescribed-flux function.
Definition: heat_transfer_and_melt_elements.h:185
unsigned U_index_ust_heat
Index at which temperature is stored.
Definition: heat_transfer_and_melt_elements.h:179
unsigned Dim
The spatial dimension of the problem.
Definition: heat_transfer_and_melt_elements.h:182
Time *const & time_pt() const
Access function for the pointer to time (const version)
Definition: timesteppers.h:572
double & time()
Return the current value of the continuous time.
Definition: timesteppers.h:123
Definition: heat_transfer_and_melt_elements.h:1522
void interpolated_u(const Vector< double > &s, double &u)
Temperature at local coordinate s.
Definition: heat_transfer_and_melt_elements.h:1669
Definition: oomph-lib/src/generic/Vector.h:58
#define min(a, b)
Definition: datatypes.h:22
#define max(a, b)
Definition: datatypes.h:23
RealScalar s
Definition: level1_cplx_impl.h:130
char char char int int * k
Definition: level2_impl.h:374
double theta
Definition: two_d_biharmonic.cc:236
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 tanh(const bfloat16 &a)
Definition: BFloat16.h:639
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 pow(const bfloat16 &a, const bfloat16 &b)
Definition: BFloat16.h:625
void plot_it(const std::string filename)
Plot "landscape" of residuals (only for 2D problems!)
Definition: spring_contact.cc:211
string filename
Definition: MergeRestartFiles.py:39
bool found
Definition: MergeRestartFiles.py:24
void flux(const double &time, const Vector< double > &x, double &flux)
Get flux applied along boundary x=0.
Definition: pretend_melt.cc:59
void normal(const Vector< double > &x, Vector< double > &normal)
Definition: free_surface_rotation.cc:65
Real fabs(const Real &a)
Definition: boostmultiprec.cpp:117
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
Definition: oomph_utilities.cc:212
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
bool intersects(const Vector< Vector< double > > &first_segment_vertex, const Vector< Vector< double > > &second_segment_vertex, const double &epsilon_parallel=1.0e-15)
Definition: temporary_stefan_boltzmann_elements.h:57
const double Pi
50 digits from maple
Definition: oomph_utilities.h:157
void Zero_atmospheric_radiation_fct(const double &time, double &solar_flux_magnitude, Vector< double > &solar_flux_unit_vector, double &total_diffuse_radiation)
Default atmospheric radiation function in terms of time.
Definition: temporary_stefan_boltzmann_elements.h:123
void bin_helper(const Vector< Vector< double > > &ray_vertex, const bool &populate_bin, Vector< std::pair< unsigned, unsigned > > &intersected_bin, FiniteElement *el_pt, std::ofstream &outfile)
Definition: temporary_stefan_boltzmann_elements.h:1861
unsigned Nx_bin
Number of bins in x direction.
Definition: temporary_stefan_boltzmann_elements.h:1833
void doc_sample_points(std::ofstream &outfile, const Vector< FiniteElement * > &sb_face_element_pt)
Definition: temporary_stefan_boltzmann_elements.h:2124
Vector< double > Dx(2, 0.0)
Increments in bin.
unsigned Ny_bin
Number of bins in y direction.
Definition: temporary_stefan_boltzmann_elements.h:1836
Vector< double > Min_coord(2, DBL_MAX)
Min bin coords.
unsigned Nsample
Definition: temporary_stefan_boltzmann_elements.h:1840
Vector< double > Max_coord(2,-DBL_MAX)
Max bin coords.
void doc_bins(std::ofstream &bin_file)
Definition: temporary_stefan_boltzmann_elements.h:2093
void setup_stefan_boltzmann_visibility(const Vector< FiniteElement * > &sb_face_element_pt)
Definition: temporary_stefan_boltzmann_elements.h:2173
Vector< Vector< std::set< FiniteElement * > > > Element_in_bin
Bin to store pointers to finite elements in.
Definition: temporary_stefan_boltzmann_elements.h:1821
double timer()
returns the time in seconds after some point in past
Definition: oomph_utilities.cc:1295
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
void pause(std::string message)
Pause and display message.
Definition: oomph_utilities.cc:1265
OomphInfo oomph_info
Definition: oomph_definitions.cc:319
list x
Definition: plotDoE.py:28
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2