26 #ifndef HALF_RECTANGLE_WITH_MESH_HEADER
27 #define HALF_RECTANGLE_WITH_MESH_HEADER
34 using namespace QuadTreeNames;
39 class HalfEllipse :
public GeomObject
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;}
95 class HalfRectangleWithHoleDomain :
public Domain
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++)
202 for(
unsigned i=0;
i<2;
i++)
204 f[
i] = left[
i] + (right[
i] - left[
i])*0.5*(
s+1.0);
215 const unsigned &direction,
233 linear_interpolate(Up[0][
m+1],Up[1][
m+1],
s[0],
f);
237 linear_interpolate(Up[0][
m],Up[1][
m],
s[0],
f);
241 linear_interpolate(Up[0][
m],Up[0][
m+1],
s[0],
f);
245 linear_interpolate(Up[1][
m],Up[1][
m+1],
s[0],
f);
250 std::ostringstream error_stream;
251 error_stream <<
"Direction is incorrect: " << direction << std::endl;
262 unsigned m_mod =
m - Nup;
273 xi[0] = 4.0*
atan(1.0) -
atan(1.0)*0.5*(1.0+
s[0]);
278 linear_interpolate(Up[0][Nup],Up[1][Nup],
s[0],
f);
282 xi[0] = 4.0*
atan(1.0);
284 linear_interpolate(Up[0][Nup],point_on_circle,
s[0],
f);
288 xi[0] = 3.0*
atan(1.0);
290 linear_interpolate(Up[1][Nup],point_on_circle,
s[0],
f);
295 std::ostringstream error_stream;
296 error_stream <<
"Direction is incorrect: " << direction
314 linear_interpolate(point_on_circle,Down[1][0],
s[0],
f);
318 xi[0] = 3.0*
atan(1.0);
320 linear_interpolate(point_on_circle,Up[1][Nup],
s[0],
f);
324 xi[0] = 3.0*
atan(1.0) - 2.0*
atan(1.0)*0.5*(1.0+
s[0]);
329 linear_interpolate(Up[1][Nup],Down[1][0],
s[0],
f);
334 std::ostringstream error_stream;
335 error_stream <<
"Direction is incorrect: " << direction << std::endl;
350 linear_interpolate(Down[0][0],Down[1][0],
s[0],
f);
354 xi[0] =
atan(1.0)*0.5*(1.0+
s[0]);
361 linear_interpolate(point_on_circle,Down[0][0],
s[0],
f);
367 linear_interpolate(point_on_circle,Down[1][0],
s[0],
f);
373 std::ostringstream error_stream;
374 error_stream <<
"Direction is incorrect: " << direction << std::endl;
387 unsigned m_mod =
m - Nup -3;
394 linear_interpolate(Down[0][m_mod+1],Down[1][m_mod+1],
s[0],
f);
398 linear_interpolate(Down[0][m_mod],Down[1][m_mod],
s[0],
f);
402 linear_interpolate(Down[0][m_mod],Down[0][m_mod+1],
s[0],
f);
406 linear_interpolate(Down[1][m_mod],Down[1][m_mod+1],
s[0],
f);
411 std::ostringstream error_stream;
412 error_stream <<
"Direction is incorrect: " << direction << std::endl;
419 else if(
m < Nup+Ndown+3 + (Ncolumn-1)*(Nup+Ndown+1))
422 unsigned m_col =
m - (Nup+Ndown+3);
424 unsigned j_col = 1 + m_col/(Nup+Ndown+1);
426 unsigned m_mod = m_col%(Nup+Ndown+1);
434 linear_interpolate(Up[j_col][m_mod+1],Up[j_col+1][m_mod+1],
s[0],
f);
438 linear_interpolate(Up[j_col][m_mod],Up[j_col+1][m_mod],
s[0],
f);
442 linear_interpolate(Up[j_col][m_mod],Up[j_col][m_mod+1],
s[0],
f);
446 linear_interpolate(Up[j_col+1][m_mod],Up[j_col+1][m_mod+1],
s[0],
f);
451 std::ostringstream error_stream;
452 error_stream <<
"Direction is incorrect: " << direction << std::endl;
465 linear_interpolate(Down[j_col][0],Down[j_col+1][0],
s[0],
f);
469 linear_interpolate(Up[j_col][Nup],Up[j_col+1][Nup],
s[0],
f);
473 linear_interpolate(Up[j_col][Nup],Down[j_col][0],
s[0],
f);
477 linear_interpolate(Up[j_col+1][Nup],Down[j_col+1][0],
s[0],
f);
482 std::ostringstream error_stream;
483 error_stream <<
"Direction is incorrect: " << direction << std::endl;
490 else if(m_mod < Nup+Ndown+1)
492 unsigned m_mod2 = m_mod - Nup -1;
499 linear_interpolate(Down[j_col][m_mod2+1],Down[j_col+1][m_mod2+1],
s[0],
f);
503 linear_interpolate(Down[j_col][m_mod2],Down[j_col+1][m_mod2],
s[0],
f);
507 linear_interpolate(Down[j_col][m_mod2],Down[j_col][m_mod2+1],
s[0],
f);
511 linear_interpolate(Down[j_col+1][m_mod2],Down[j_col+1][m_mod2+1],
s[0],
f);
516 std::ostringstream error_stream;
517 error_stream <<
"Direction is incorrect: " << direction << std::endl;
527 std::ostringstream error_stream;
528 error_stream <<
"Wrong macro element number" <<
m << std::endl;
570 template<
class ELEMENT>
571 class HalfRectangleWithHoleMesh :
public virtual Mesh
584 const double &
radius,
const double &length,
585 const double &up_length,
const unsigned &nup,
586 const double &down_length,
const unsigned &ndown,
587 const double &width_near_cylinder,
588 const unsigned &ncolumn,
594 up_length,nup,down_length,
595 ndown,width_near_cylinder,
599 unsigned long node_count=0;
609 unsigned nmacro_element = Domain_pt->nmacro_element();
610 for(
unsigned e=0;
e<nmacro_element;
e++)
613 Element_pt.push_back(
new ELEMENT);
617 dynamic_cast<ELEMENT*
>(finite_element_pt(
e))->nnode_1d();
620 for(
unsigned l1=0;l1<np;l1++)
623 for(
unsigned l2=0;l2<np;l2++)
626 Tmp_node_pt.push_back(finite_element_pt(
e)->
627 construct_node(l1*np+l2,time_stepper_pt));
630 s[0] = -1.0 + 2.0*(
double)l2/(
double)(np-1);
631 s[1] = -1.0 + 2.0*(
double)l1/(
double)(np-1);
632 Domain_pt->macro_element_pt(
e)->macro_map(
s,
r);
635 Tmp_node_pt[node_count]->x(0) =
r[0];
636 Tmp_node_pt[node_count]->x(1) =
r[1];
649 unsigned np=
dynamic_cast<ELEMENT*
>(finite_element_pt(0))->nnode_1d();
653 for(
unsigned m=0;
m<(nup+1);
m++)
656 for(
unsigned n=0;
n<np;
n++)
659 finite_element_pt(
m+1)->node_pt(
n)
660 = finite_element_pt(
m)->node_pt(np*(np-1) +
n);
663 delete Tmp_node_pt[(
m+1)*np*np +
n];
664 Tmp_node_pt[(
m+1)*np*np +
n] = 0;
669 for(
unsigned n=0;
n<np;
n++)
672 finite_element_pt(nup+1)->node_pt(
n)
673 = finite_element_pt(nup)->node_pt((np-
n-1)*np + (np-1));
676 delete Tmp_node_pt[(nup+1)*np*np +
n];
677 Tmp_node_pt[(nup+1)*np*np +
n] = 0;
681 for(
unsigned n=0;
n<np;
n++)
684 finite_element_pt(nup+2)->node_pt(np*
n + np-1)
685 = finite_element_pt(nup+1)->node_pt(np*(np-1) +
n);
688 delete Tmp_node_pt[(nup+2)*np*np + np*
n + np-1];
689 Tmp_node_pt[(nup+2)*np*np + np*
n + np-1] = 0;
694 for(
unsigned m=nup+2;
m<(nup+2+ndown);
m++)
697 for(
unsigned n=0;
n<np;
n++)
700 finite_element_pt(
m+1)->node_pt(
n)
701 = finite_element_pt(
m)->node_pt(np*(np-1) +
n);
704 delete Tmp_node_pt[(
m+1)*np*np +
n];
705 Tmp_node_pt[(
m+1)*np*np +
n] = 0;
714 unsigned left_col_offset = 0;
715 unsigned right_col_offset = nup+ndown+3;
717 for(
unsigned j=1;
j<ncolumn;
j++)
719 for(
unsigned i=0;
i<(nup+ndown+1);
i++)
722 for(
unsigned n=0;
n<np;
n++)
724 finite_element_pt(right_col_offset)->node_pt(
n*np)
725 = finite_element_pt(left_col_offset)->node_pt(
n*np + np-1);
728 delete Tmp_node_pt[right_col_offset*np*np +
n*np];
729 Tmp_node_pt[right_col_offset*np*np +
n*np] = 0;
736 for(
unsigned n=1;
n<np;
n++)
738 finite_element_pt(right_col_offset+1)->node_pt(
n)
739 = finite_element_pt(right_col_offset)->node_pt((np-1)*np +
n);
742 delete Tmp_node_pt[(right_col_offset+1)*np*np +
n];
743 Tmp_node_pt[(right_col_offset+1)*np*np +
n] = 0;
747 ++right_col_offset; ++left_col_offset;
751 if((
i==nup-1) || (
i==nup)) {++left_col_offset;}
754 if(
j==1) {first_col=
false;}
759 for(
unsigned long n=0;
n<node_count;
n++)
761 if(Tmp_node_pt[
n]!=0) {Node_pt.push_back(Tmp_node_pt[
n]);}
768 unsigned rhs_offset=0;
769 if(ncolumn > 1) {rhs_offset = nup+ndown+3 + (ncolumn-2)*(nup+ndown+1);}
771 for(
unsigned n=0;
n<np;
n++)
774 Node* nod_pt=finite_element_pt(0)->node_pt(
n*np);
775 convert_to_boundary_node(nod_pt);
776 add_boundary_node(3,nod_pt);
779 nod_pt=finite_element_pt(nup+2)->node_pt(
n*np);
780 convert_to_boundary_node(nod_pt);
781 add_boundary_node(3,nod_pt);
784 nod_pt=finite_element_pt(rhs_offset)->node_pt(
n*np + np-1);
785 convert_to_boundary_node(nod_pt);
786 add_boundary_node(1,nod_pt);
789 nod_pt=finite_element_pt(0)->node_pt(
n);
790 convert_to_boundary_node(nod_pt);
791 add_boundary_node(0,nod_pt);
794 nod_pt=finite_element_pt(nup+ndown+2)->node_pt(np*(np-1)+
n);
795 convert_to_boundary_node(nod_pt);
796 add_boundary_node(2,nod_pt);
799 nod_pt=finite_element_pt(nup)->node_pt(np*(np-1)+
n);
800 convert_to_boundary_node(nod_pt);
801 add_boundary_node(4,nod_pt);
805 for(
unsigned n=1;
n<np;
n++)
807 for(
unsigned m=1;
m<nup;
m++)
810 Node* nod_pt=finite_element_pt(
m)->node_pt(
n*np);
811 convert_to_boundary_node(nod_pt);
812 add_boundary_node(3,nod_pt);
815 nod_pt=finite_element_pt(rhs_offset +
m)->node_pt(
n*np + np-1);
816 convert_to_boundary_node(nod_pt);
817 add_boundary_node(1,nod_pt);
821 Node* nod_pt=finite_element_pt(nup+1)->node_pt(
n*np);
822 convert_to_boundary_node(nod_pt);
823 add_boundary_node(4,nod_pt);
828 unsigned rhs_extra_offset=1;
829 if(ncolumn>1) {rhs_extra_offset=0;}
830 for(
unsigned n=1;
n<np;
n++)
833 Node* nod_pt=finite_element_pt(nup)->node_pt(
n*np);
834 convert_to_boundary_node(nod_pt);
835 add_boundary_node(3,nod_pt);
838 nod_pt=finite_element_pt(rhs_offset + rhs_extra_offset + nup)
839 ->node_pt(
n*np + np-1);
840 convert_to_boundary_node(nod_pt);
841 add_boundary_node(1,nod_pt);
844 nod_pt=finite_element_pt(nup+2)->node_pt(np-1-
n);
845 convert_to_boundary_node(nod_pt);
846 add_boundary_node(4,nod_pt);
850 for(
unsigned n=1;
n<np;
n++)
852 for(
unsigned m=nup+3;
m<(nup+ndown+3);
m++)
855 Node* nod_pt=finite_element_pt(
m)->node_pt(
n*np);
856 convert_to_boundary_node(nod_pt);
857 add_boundary_node(3,nod_pt);
862 nod_pt=finite_element_pt(
m)->node_pt(
n*np + np-1);
863 convert_to_boundary_node(nod_pt);
864 add_boundary_node(1,nod_pt);
869 for(
unsigned m=nup+1;
m<(nup+ndown+1);
m++)
871 Node* nod_pt=finite_element_pt(rhs_offset +
m)->node_pt(
n*np + np-1);
872 convert_to_boundary_node(nod_pt);
873 add_boundary_node(1,nod_pt);
879 unsigned lower_index = nup + ndown + 3;
880 for(
unsigned j=1;
j<ncolumn;
j++)
882 for(
unsigned n=1;
n<np;
n++)
884 Node* nod_pt = finite_element_pt(lower_index)->node_pt(
n);
885 convert_to_boundary_node(nod_pt);
886 add_boundary_node(0,nod_pt);
889 finite_element_pt(lower_index+nup+ndown)->node_pt(np*(np-1) +
n);
890 convert_to_boundary_node(nod_pt);
891 add_boundary_node(2,nod_pt);
893 lower_index += nup+ndown+1;
898 this->setup_boundary_element_info();
923 template<
class ELEMENT>
924 class RefineableHalfRectangleWithHoleMesh :
925 public HalfRectangleWithHoleMesh<ELEMENT>,
public RefineableQuadMesh<ELEMENT>
937 const double &length,
938 const double &up_length,
940 const double &down_length,
941 const unsigned &ndown,
942 const double &width_near_cylinder,
943 const unsigned &ncolumn,
949 ncolumn,time_stepper_pt)
956 for (
unsigned e=0;
e<(ndown+nup+3);
e++)
958 dynamic_cast<ELEMENT*
>(this->element_pt(
e))->
959 set_macro_elem_pt(this->Domain_pt->macro_element_pt(
e));
963 this->setup_quadtree_forest();
968 this->refine_uniformly();
971 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 simulation can be subdivided into Domain's used in parallel code.
Definition: Domain.h:42
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
double & b()
Access to z-half axis.
Definition: b_convection_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: b_convection_sphere/half_rectangle_with_hole_mesh.h:54
HalfEllipse(const double ¢re_z, const double &a, const double &b)
Constructor.
Definition: b_convection_sphere/half_rectangle_with_hole_mesh.h:45
~HalfEllipse()
Destructor (empty)
Definition: b_convection_sphere/half_rectangle_with_hole_mesh.h:51
double & centre_z()
Access to z-coordinate of centre.
Definition: b_convection_sphere/half_rectangle_with_hole_mesh.h:62
double & a()
Access to r-half axis.
Definition: b_convection_sphere/half_rectangle_with_hole_mesh.h:65
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: b_convection_sphere/half_rectangle_with_hole_mesh.h:213
~HalfRectangleWithHoleDomain()
Destructor: Empty; cleanup done in base class.
Definition: b_convection_sphere/half_rectangle_with_hole_mesh.h:195
void linear_interpolate(Vector< double > left, Vector< double > right, const double &s, Vector< double > &f)
Definition: b_convection_sphere/half_rectangle_with_hole_mesh.h:199
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: b_convection_sphere/half_rectangle_with_hole_mesh.h:106
Domain-based mesh for rectangular mesh with circular hole.
Definition: axisym_heat_sphere/half_rectangle_with_hole_mesh.h:573
HalfRectangleWithHoleDomain * domain_pt()
Access function to the domain.
Definition: b_convection_sphere/half_rectangle_with_hole_mesh.h:903
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: b_convection_sphere/half_rectangle_with_hole_mesh.h:583
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
virtual ~RefineableHalfRectangleWithHoleMesh()
Destructor: Empty.
Definition: b_convection_sphere/half_rectangle_with_hole_mesh.h:976
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: b_convection_sphere/half_rectangle_with_hole_mesh.h:935
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