26 #ifndef HALF_RECTANGLE_WITH_MESH_HEADER
27 #define HALF_RECTANGLE_WITH_MESH_HEADER
34 using namespace QuadTreeNames;
46 const double &
a,
const double &
b)
57 r[1] = Centre_z +
B*
cos(xi[0]);
65 double&
a(){
return A;}
68 double&
b(){
return B;}
108 const double &length,
109 const double &up_length,
111 const double &down_length,
112 const unsigned &ndown,
113 const double &width_near_cylinder,
114 const unsigned &ncolumn) :
115 Cylinder_pt(cylinder_pt), Nup(nup), Ndown(ndown), Ncolumn(ncolumn)
119 double up_spacing = up_length/(
double)nup;
120 double down_spacing = down_length/(
double)ndown;
123 Up.resize(ncolumn+1); Down.resize(ncolumn+1);
128 Up[
j].resize(nup+1); Up[
j].resize(nup+1);
130 for(
unsigned i=0;
i<(nup+1);
i++)
133 Up[
j][
i][0] = 0.0; Up[
j][
i][1] =
i*up_spacing;
137 Down[
j].resize(ndown+1); Down[
j].resize(ndown+1);
140 for(
unsigned i=0;
i<(ndown+1);
i++)
142 Down[
j][
i].resize(2); Down[
j][
i].resize(2);
144 Down[
j][
i][1] = length - (ndown -
i)*down_spacing;
149 double radial_start =
radius;
150 double radial_spacing = 0.0;
154 radial_start = width_near_cylinder;
155 radial_spacing = (
radius - width_near_cylinder)/(
double)(ncolumn-1);
159 for(
unsigned j=1;
j<(ncolumn+1);
j++)
161 Up[
j].resize(nup+1); Up[
j].resize(nup+1);
163 for(
unsigned i=0;
i<(nup+1);
i++)
166 Up[
j][
i][0] = radial_start + (
j-1)*radial_spacing;
167 Up[
j][
i][1] =
i*up_spacing;
171 Down[
j].resize(ndown+1); Down[
j].resize(ndown+1);
174 for(
unsigned i=0;
i<(ndown+1);
i++)
176 Down[
j][
i].resize(2); Down[
j][
i].resize(2);
177 Down[
j][
i][0] = radial_start + (
j-1)*radial_spacing;
178 Down[
j][
i][1] = length - (ndown -
i)*down_spacing;
184 unsigned n_macro = 3 + nup + ndown + (ncolumn-1)*(1 + nup + ndown);
185 Macro_element_pt.resize(n_macro);
188 for (
unsigned i=0;
i<n_macro;
i++)
203 for(
unsigned i=0;
i<2;
i++)
205 f[
i] = left[
i] + (right[
i] - left[
i])*0.5*(
s+1.0);
216 const unsigned &direction,
234 linear_interpolate(Up[0][
m+1],Up[1][
m+1],
s[0],
f);
238 linear_interpolate(Up[0][
m],Up[1][
m],
s[0],
f);
242 linear_interpolate(Up[0][
m],Up[0][
m+1],
s[0],
f);
246 linear_interpolate(Up[1][
m],Up[1][
m+1],
s[0],
f);
251 std::ostringstream error_stream;
252 error_stream <<
"Direction is incorrect: " << direction << std::endl;
263 unsigned m_mod =
m - Nup;
274 xi[0] = 4.0*
atan(1.0) -
atan(1.0)*0.5*(1.0+
s[0]);
279 linear_interpolate(Up[0][Nup],Up[1][Nup],
s[0],
f);
283 xi[0] = 4.0*
atan(1.0);
285 linear_interpolate(Up[0][Nup],point_on_circle,
s[0],
f);
289 xi[0] = 3.0*
atan(1.0);
291 linear_interpolate(Up[1][Nup],point_on_circle,
s[0],
f);
296 std::ostringstream error_stream;
297 error_stream <<
"Direction is incorrect: " << direction
315 linear_interpolate(point_on_circle,Down[1][0],
s[0],
f);
319 xi[0] = 3.0*
atan(1.0);
321 linear_interpolate(point_on_circle,Up[1][Nup],
s[0],
f);
325 xi[0] = 3.0*
atan(1.0) - 2.0*
atan(1.0)*0.5*(1.0+
s[0]);
330 linear_interpolate(Up[1][Nup],Down[1][0],
s[0],
f);
335 std::ostringstream error_stream;
336 error_stream <<
"Direction is incorrect: " << direction << std::endl;
351 linear_interpolate(Down[0][0],Down[1][0],
s[0],
f);
355 xi[0] =
atan(1.0)*0.5*(1.0+
s[0]);
362 linear_interpolate(point_on_circle,Down[0][0],
s[0],
f);
368 linear_interpolate(point_on_circle,Down[1][0],
s[0],
f);
374 std::ostringstream error_stream;
375 error_stream <<
"Direction is incorrect: " << direction << std::endl;
388 unsigned m_mod =
m - Nup -3;
395 linear_interpolate(Down[0][m_mod+1],Down[1][m_mod+1],
s[0],
f);
399 linear_interpolate(Down[0][m_mod],Down[1][m_mod],
s[0],
f);
403 linear_interpolate(Down[0][m_mod],Down[0][m_mod+1],
s[0],
f);
407 linear_interpolate(Down[1][m_mod],Down[1][m_mod+1],
s[0],
f);
412 std::ostringstream error_stream;
413 error_stream <<
"Direction is incorrect: " << direction << std::endl;
420 else if(
m < Nup+Ndown+3 + (Ncolumn-1)*(Nup+Ndown+1))
423 unsigned m_col =
m - (Nup+Ndown+3);
425 unsigned j_col = 1 + m_col/(Nup+Ndown+1);
427 unsigned m_mod = m_col%(Nup+Ndown+1);
435 linear_interpolate(Up[j_col][m_mod+1],Up[j_col+1][m_mod+1],
s[0],
f);
439 linear_interpolate(Up[j_col][m_mod],Up[j_col+1][m_mod],
s[0],
f);
443 linear_interpolate(Up[j_col][m_mod],Up[j_col][m_mod+1],
s[0],
f);
447 linear_interpolate(Up[j_col+1][m_mod],Up[j_col+1][m_mod+1],
s[0],
f);
452 std::ostringstream error_stream;
453 error_stream <<
"Direction is incorrect: " << direction << std::endl;
466 linear_interpolate(Down[j_col][0],Down[j_col+1][0],
s[0],
f);
470 linear_interpolate(Up[j_col][Nup],Up[j_col+1][Nup],
s[0],
f);
474 linear_interpolate(Up[j_col][Nup],Down[j_col][0],
s[0],
f);
478 linear_interpolate(Up[j_col+1][Nup],Down[j_col+1][0],
s[0],
f);
483 std::ostringstream error_stream;
484 error_stream <<
"Direction is incorrect: " << direction << std::endl;
491 else if(m_mod < Nup+Ndown+1)
493 unsigned m_mod2 = m_mod - Nup -1;
500 linear_interpolate(Down[j_col][m_mod2+1],Down[j_col+1][m_mod2+1],
s[0],
f);
504 linear_interpolate(Down[j_col][m_mod2],Down[j_col+1][m_mod2],
s[0],
f);
508 linear_interpolate(Down[j_col][m_mod2],Down[j_col][m_mod2+1],
s[0],
f);
512 linear_interpolate(Down[j_col+1][m_mod2],Down[j_col+1][m_mod2+1],
s[0],
f);
517 std::ostringstream error_stream;
518 error_stream <<
"Direction is incorrect: " << direction << std::endl;
528 std::ostringstream error_stream;
529 error_stream <<
"Wrong macro element number" <<
m << std::endl;
571 template<
class ELEMENT>
585 const double &
radius,
const double &length,
586 const double &up_length,
const unsigned &nup,
587 const double &down_length,
const unsigned &ndown,
588 const double &width_near_cylinder,
589 const unsigned &ncolumn,
595 up_length,nup,down_length,
596 ndown,width_near_cylinder,
600 unsigned long node_count=0;
610 unsigned nmacro_element = Domain_pt->nmacro_element();
611 for(
unsigned e=0;
e<nmacro_element;
e++)
614 Element_pt.push_back(
new ELEMENT);
618 dynamic_cast<ELEMENT*
>(finite_element_pt(
e))->nnode_1d();
621 for(
unsigned l1=0;l1<np;l1++)
624 for(
unsigned l2=0;l2<np;l2++)
627 Tmp_node_pt.push_back(finite_element_pt(
e)->
628 construct_node(l1*np+l2,time_stepper_pt));
631 s[0] = -1.0 + 2.0*(
double)l2/(
double)(np-1);
632 s[1] = -1.0 + 2.0*(
double)l1/(
double)(np-1);
633 Domain_pt->macro_element_pt(
e)->macro_map(
s,
r);
636 Tmp_node_pt[node_count]->x(0) =
r[0];
637 Tmp_node_pt[node_count]->x(1) =
r[1];
650 unsigned np=
dynamic_cast<ELEMENT*
>(finite_element_pt(0))->nnode_1d();
654 for(
unsigned m=0;
m<(nup+1);
m++)
657 for(
unsigned n=0;
n<np;
n++)
660 finite_element_pt(
m+1)->node_pt(
n)
661 = finite_element_pt(
m)->node_pt(np*(np-1) +
n);
664 delete Tmp_node_pt[(
m+1)*np*np +
n];
665 Tmp_node_pt[(
m+1)*np*np +
n] = 0;
670 for(
unsigned n=0;
n<np;
n++)
673 finite_element_pt(nup+1)->node_pt(
n)
674 = finite_element_pt(nup)->node_pt((np-
n-1)*np + (np-1));
677 delete Tmp_node_pt[(nup+1)*np*np +
n];
678 Tmp_node_pt[(nup+1)*np*np +
n] = 0;
682 for(
unsigned n=0;
n<np;
n++)
685 finite_element_pt(nup+2)->node_pt(np*
n + np-1)
686 = finite_element_pt(nup+1)->node_pt(np*(np-1) +
n);
689 delete Tmp_node_pt[(nup+2)*np*np + np*
n + np-1];
690 Tmp_node_pt[(nup+2)*np*np + np*
n + np-1] = 0;
695 for(
unsigned m=nup+2;
m<(nup+2+ndown);
m++)
698 for(
unsigned n=0;
n<np;
n++)
701 finite_element_pt(
m+1)->node_pt(
n)
702 = finite_element_pt(
m)->node_pt(np*(np-1) +
n);
705 delete Tmp_node_pt[(
m+1)*np*np +
n];
706 Tmp_node_pt[(
m+1)*np*np +
n] = 0;
715 unsigned left_col_offset = 0;
716 unsigned right_col_offset = nup+ndown+3;
718 for(
unsigned j=1;
j<ncolumn;
j++)
720 for(
unsigned i=0;
i<(nup+ndown+1);
i++)
723 for(
unsigned n=0;
n<np;
n++)
725 finite_element_pt(right_col_offset)->node_pt(
n*np)
726 = finite_element_pt(left_col_offset)->node_pt(
n*np + np-1);
729 delete Tmp_node_pt[right_col_offset*np*np +
n*np];
730 Tmp_node_pt[right_col_offset*np*np +
n*np] = 0;
737 for(
unsigned n=1;
n<np;
n++)
739 finite_element_pt(right_col_offset+1)->node_pt(
n)
740 = finite_element_pt(right_col_offset)->node_pt((np-1)*np +
n);
743 delete Tmp_node_pt[(right_col_offset+1)*np*np +
n];
744 Tmp_node_pt[(right_col_offset+1)*np*np +
n] = 0;
748 ++right_col_offset; ++left_col_offset;
752 if((
i==nup-1) || (
i==nup)) {++left_col_offset;}
755 if(
j==1) {first_col=
false;}
760 for(
unsigned long n=0;
n<node_count;
n++)
762 if(Tmp_node_pt[
n]!=0) {Node_pt.push_back(Tmp_node_pt[
n]);}
769 unsigned rhs_offset=0;
770 if(ncolumn > 1) {rhs_offset = nup+ndown+3 + (ncolumn-2)*(nup+ndown+1);}
772 for(
unsigned n=0;
n<np;
n++)
775 Node* nod_pt=finite_element_pt(0)->node_pt(
n*np);
776 convert_to_boundary_node(nod_pt);
777 add_boundary_node(3,nod_pt);
780 nod_pt=finite_element_pt(nup+2)->node_pt(
n*np);
781 convert_to_boundary_node(nod_pt);
782 add_boundary_node(3,nod_pt);
785 nod_pt=finite_element_pt(rhs_offset)->node_pt(
n*np + np-1);
786 convert_to_boundary_node(nod_pt);
787 add_boundary_node(1,nod_pt);
790 nod_pt=finite_element_pt(0)->node_pt(
n);
791 convert_to_boundary_node(nod_pt);
792 add_boundary_node(0,nod_pt);
795 nod_pt=finite_element_pt(nup+ndown+2)->node_pt(np*(np-1)+
n);
796 convert_to_boundary_node(nod_pt);
797 add_boundary_node(2,nod_pt);
800 nod_pt=finite_element_pt(nup)->node_pt(np*(np-1)+
n);
801 convert_to_boundary_node(nod_pt);
802 add_boundary_node(4,nod_pt);
806 for(
unsigned n=1;
n<np;
n++)
808 for(
unsigned m=1;
m<nup;
m++)
811 Node* nod_pt=finite_element_pt(
m)->node_pt(
n*np);
812 convert_to_boundary_node(nod_pt);
813 add_boundary_node(3,nod_pt);
816 nod_pt=finite_element_pt(rhs_offset +
m)->node_pt(
n*np + np-1);
817 convert_to_boundary_node(nod_pt);
818 add_boundary_node(1,nod_pt);
822 Node* nod_pt=finite_element_pt(nup+1)->node_pt(
n*np);
823 convert_to_boundary_node(nod_pt);
824 add_boundary_node(4,nod_pt);
829 unsigned rhs_extra_offset=1;
830 if(ncolumn>1) {rhs_extra_offset=0;}
831 for(
unsigned n=1;
n<np;
n++)
834 Node* nod_pt=finite_element_pt(nup)->node_pt(
n*np);
835 convert_to_boundary_node(nod_pt);
836 add_boundary_node(3,nod_pt);
839 nod_pt=finite_element_pt(rhs_offset + rhs_extra_offset + nup)
840 ->node_pt(
n*np + np-1);
841 convert_to_boundary_node(nod_pt);
842 add_boundary_node(1,nod_pt);
845 nod_pt=finite_element_pt(nup+2)->node_pt(np-1-
n);
846 convert_to_boundary_node(nod_pt);
847 add_boundary_node(4,nod_pt);
851 for(
unsigned n=1;
n<np;
n++)
853 for(
unsigned m=nup+3;
m<(nup+ndown+3);
m++)
856 Node* nod_pt=finite_element_pt(
m)->node_pt(
n*np);
857 convert_to_boundary_node(nod_pt);
858 add_boundary_node(3,nod_pt);
863 nod_pt=finite_element_pt(
m)->node_pt(
n*np + np-1);
864 convert_to_boundary_node(nod_pt);
865 add_boundary_node(1,nod_pt);
870 for(
unsigned m=nup+1;
m<(nup+ndown+1);
m++)
872 Node* nod_pt=finite_element_pt(rhs_offset +
m)->node_pt(
n*np + np-1);
873 convert_to_boundary_node(nod_pt);
874 add_boundary_node(1,nod_pt);
880 unsigned lower_index = nup + ndown + 3;
881 for(
unsigned j=1;
j<ncolumn;
j++)
883 for(
unsigned n=1;
n<np;
n++)
885 Node* nod_pt = finite_element_pt(lower_index)->node_pt(
n);
886 convert_to_boundary_node(nod_pt);
887 add_boundary_node(0,nod_pt);
890 finite_element_pt(lower_index+nup+ndown)->node_pt(np*(np-1) +
n);
891 convert_to_boundary_node(nod_pt);
892 add_boundary_node(2,nod_pt);
894 lower_index += nup+ndown+1;
899 this->setup_boundary_element_info();
924 template<
class ELEMENT>
938 const double &length,
939 const double &up_length,
941 const double &down_length,
942 const unsigned &ndown,
943 const double &width_near_cylinder,
944 const unsigned &ncolumn,
950 ncolumn,time_stepper_pt)
957 for (
unsigned e=0;
e<(ndown+nup+3);
e++)
959 dynamic_cast<ELEMENT*
>(this->element_pt(
e))->
960 set_macro_elem_pt(this->Domain_pt->macro_element_pt(
e));
964 this->setup_quadtree_forest();
969 this->refine_uniformly();
972 this->setup_boundary_element_info();
AnnoyingScalar cos(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:136
AnnoyingScalar sin(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:137
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.)
Scalar * b
Definition: benchVecAdd.cpp:17
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:47
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
Definition: bench_gemm.cpp:48
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186
void position(const Vector< double > &xi, Vector< double > &r) const
Definition: extrude_with_macro_element_representation.cc:78
Definition: geom_objects.h:101
My own Ellipse class.
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:40
double & b()
Access to z-half axis.
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:68
void position(const Vector< double > &xi, Vector< double > &r) const
Return the position of the Half Ellipse.
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:54
double Centre_z
z-coordinate of centre
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:74
HalfEllipse(const double ¢re_z, const double &a, const double &b)
Constructor.
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:45
double B
z-half axis
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:80
~HalfEllipse()
Destructor (empty)
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:51
double & centre_z()
Access to z-coordinate of centre.
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:62
double & a()
Access to r-half axis.
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:65
double A
r-half axis
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:77
Rectangular domain with Half-elliptical hole.
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:96
void macro_element_boundary(const unsigned &time, const unsigned &m, const unsigned &direction, const Vector< double > &s, Vector< double > &f)
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:214
Vector< Vector< Vector< double > > > Up
Left and right side of lines in the upstream region.
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:541
unsigned Nup
Number of upstream macro elements.
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:550
~HalfRectangleWithHoleDomain()
Destructor: Empty; cleanup done in base class.
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:195
void linear_interpolate(Vector< double > left, Vector< double > right, const double &s, Vector< double > &f)
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:200
Vector< Vector< Vector< double > > > Down
Left and right side of lines in the downstream region.
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:544
unsigned Ncolumn
Number of columns.
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:556
GeomObject * Cylinder_pt
Pointer to geometric object that represents the central cylinder.
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:547
HalfRectangleWithHoleDomain(GeomObject *cylinder_pt, const double &radius, const double &length, const double &up_length, const unsigned &nup, const double &down_length, const unsigned &ndown, const double &width_near_cylinder, const unsigned &ncolumn)
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:106
unsigned Ndown
Number of downstream macro elements.
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:553
Domain-based mesh for rectangular mesh with circular hole.
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:573
HalfRectangleWithHoleDomain * Domain_pt
Pointer to the domain.
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:909
HalfRectangleWithHoleDomain * domain_pt()
Access function to the domain.
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:904
HalfRectangleWithHoleMesh(GeomObject *cylinder_pt, const double &radius, const double &length, const double &up_length, const unsigned &nup, const double &down_length, const unsigned &ndown, const double &width_near_cylinder, const unsigned &ncolumn, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:584
Definition: matrices.h:74
static Steady< 0 > Default_TimeStepper
The Steady Timestepper.
Definition: mesh.h:75
Definition: oomph_definitions.h:222
Definition: macro_element.h:279
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:927
virtual ~RefineableHalfRectangleWithHoleMesh()
Destructor: Empty.
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:977
RefineableHalfRectangleWithHoleMesh(GeomObject *cylinder_pt, const double &radius, const double &length, const double &up_length, const unsigned &nup, const double &down_length, const unsigned &ndown, const double &width_near_cylinder, const unsigned &ncolumn, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:936
Definition: refineable_quad_mesh.h:53
Definition: timesteppers.h:231
static int f(const TensorMap< Tensor< int, 3 > > &tensor)
Definition: cxx11_tensor_map.cpp:237
RealScalar s
Definition: level1_cplx_impl.h:130
const Scalar * a
Definition: level2_cplx_impl.h:32
int * m
Definition: level2_cplx_impl.h:294
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 atan(const bfloat16 &a)
Definition: BFloat16.h:636
OscillatingCylinder * Cylinder_pt
---------------------------------—TIME-INTEGRATION PARAMETERS---—
Definition: extrude_with_macro_element_representation.cc:248
@ E
Definition: quadtree.h:61
@ S
Definition: quadtree.h:62
@ W
Definition: quadtree.h:63
@ N
Definition: quadtree.h:60
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
#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