30 #ifndef OOMPH_GEOM_OBJECTS_HEADER 31 #define OOMPH_GEOM_OBJECTS_HEADER 36 #include <oomph-lib-config.h> 129 std::ostringstream error_message;
130 error_message <<
"# of Lagrangian coordinates " << nlagrangian
131 <<
" cannot be bigger than # of Eulerian ones " 132 << ndim << std::endl;
135 OOMPH_CURRENT_FUNCTION,
136 OOMPH_EXCEPTION_LOCATION);
154 std::ostringstream error_message;
155 error_message <<
"# of Lagrangian coordinates " << nlagrangian
156 <<
" cannot be bigger than # of Eulerian ones " 157 << ndim << std::endl;
160 OOMPH_CURRENT_FUNCTION,
161 OOMPH_EXCEPTION_LOCATION);
189 const unsigned& n_dim)
210 std::ostringstream error_message;
212 <<
"GeomObject::ngeom_data() is a broken virtual function.\n" 213 <<
"Please implement it (and its companion GeomObject::geom_data_pt())\n" 214 <<
"for any GeomObject whose shape depends on Data whose values may \n" 215 <<
"be unknowns in the global Problem. \n" 216 <<
"If you have arrived here in a parallel job then it may be the case \n" 217 <<
"that you have not set the keep_all_elements_as_halos() flag to true \n" 218 <<
"for the MeshAsGeomObject representing the lower-dimensional mesh \n" 219 <<
"in a problem with multiple meshes. \n";
221 OOMPH_CURRENT_FUNCTION,
222 OOMPH_EXCEPTION_LOCATION);
232 std::ostringstream error_message;
234 <<
"GeomObject::geom_data_pt() is a broken virtual function.\n" 235 <<
"Please implement it (and its companion GeomObject::ngeom_data())\n" 236 <<
"for any GeomObject whose shape depends on Data whose values may \n" 237 <<
"be unknowns in the global Problem. \n" 238 <<
"If you have arrived here in a parallel job then it may be the case \n" 239 <<
"that you have not set the keep_all_elements_as_halos() flag to true \n" 240 <<
"for the MeshAsGeomObject representing the lower-dimensional mesh \n" 241 <<
"in a problem with multiple meshes. \n";
243 OOMPH_CURRENT_FUNCTION,
244 OOMPH_EXCEPTION_LOCATION);
261 "Calling steady position() from discrete unsteady position()",
262 OOMPH_CURRENT_FUNCTION,
263 OOMPH_EXCEPTION_LOCATION);
280 std::ostringstream warning_stream;
282 <<
"Using default (static) assignment " << j
283 <<
"-th time derivative in GeomObject::dposition_dt(...) is zero\n" 284 <<
"Overload for your specific geometric object if this is not \n" 285 <<
"appropriate. \n";
287 "GeomObject::dposition_dt()",
288 OOMPH_EXCEPTION_LOCATION);
290 unsigned n=drdt.size();
291 for (
unsigned i=0;
i<n;
i++) {drdt[
i]=0.0;}
303 "You must specify dposition() for your own object! \n",
304 OOMPH_CURRENT_FUNCTION,
305 OOMPH_EXCEPTION_LOCATION);
317 "You must specify d2position() for your own object! \n",
318 OOMPH_CURRENT_FUNCTION,
319 OOMPH_EXCEPTION_LOCATION);
334 "You must specify d2position() for your own object! \n",
335 OOMPH_CURRENT_FUNCTION,
336 OOMPH_EXCEPTION_LOCATION);
355 const bool &use_coordinate_as_initial_guess=
false)
360 sub_geom_object_pt =
this;
378 if (zeta.size()!=s.size())
380 std::ostringstream error_message;
382 <<
"You've called the default implementation of " 383 <<
"GeomObject::interpolated_zeta() \n" 384 <<
"but zeta.size()=" << zeta.size()
385 <<
"and s.size()=" << s.size() << std::endl
386 <<
"This doesn't make sense! You probably have to \n" 387 <<
"overload this function in your specific GeomObject\n";
389 OOMPH_CURRENT_FUNCTION,
390 OOMPH_EXCEPTION_LOCATION);
441 if (geom_data_pt.size()!=1)
443 std::ostringstream error_message;
444 error_message <<
"geom_data_pt should have size 1, not " 445 << geom_data_pt.size() << std::endl;
447 if (geom_data_pt[0]->nvalue()!=1)
449 error_message <<
"geom_data_pt[0] should have 1 value, not " 450 << geom_data_pt[0]->nvalue() << std::endl;
454 OOMPH_CURRENT_FUNCTION,
455 OOMPH_EXCEPTION_LOCATION);
458 Geom_data_pt.resize(1);
459 Geom_data_pt[0]=geom_data_pt[0];
470 Geom_data_pt.resize(1);
473 Geom_data_pt[0] =
new Data(1);
479 Geom_data_pt[0]->pin(0);
482 Geom_data_pt[0]->set_value(0,height);
505 delete Geom_data_pt[0];
516 r[1] = Geom_data_pt[0]->value(0);
529 std::ostringstream error_message;
530 error_message <<
"t > nprev_values() " << t <<
" " 531 << Geom_data_pt[0]->time_stepper_pt()->nprev_values()
535 OOMPH_CURRENT_FUNCTION,
536 OOMPH_EXCEPTION_LOCATION);
542 r[1] = Geom_data_pt[0]->value(t,0);
582 r[1] = Geom_data_pt[0]->value(0);
644 if (geom_data_pt.size()!=1)
646 std::ostringstream error_message;
647 error_message <<
"geom_data_pt should have size 1, not " 648 << geom_data_pt.size() << std::endl;
650 if (geom_data_pt[0]->nvalue()!=2)
652 error_message <<
"geom_data_pt[0] should have 2 values, not " 653 << geom_data_pt[0]->nvalue() << std::endl;
657 OOMPH_CURRENT_FUNCTION,
658 OOMPH_EXCEPTION_LOCATION);
661 Geom_data_pt.resize(1);
662 Geom_data_pt[0]=geom_data_pt[0];
674 Geom_data_pt.resize(1);
677 Geom_data_pt[0] =
new Data(2);
683 Geom_data_pt[0]->pin(0);
684 Geom_data_pt[0]->pin(1);
687 Geom_data_pt[0]->set_value(0,A);
688 Geom_data_pt[0]->set_value(1,B);
710 delete Geom_data_pt[0];
722 double a_ellips(){
return Geom_data_pt[0]->value(0);}
725 double b_ellips(){
return Geom_data_pt[0]->value(1);}
732 r[0] = Geom_data_pt[0]->value(0)*cos(zeta[0]);
733 r[1] = Geom_data_pt[0]->value(1)*sin(zeta[0]);
747 if(Must_clean_up) {
position(zeta,r);
return;}
753 std::ostringstream error_message;
754 error_message <<
"t > nprev_values() " << t <<
" " 755 << Geom_data_pt[0]->time_stepper_pt()->nprev_values()
759 OOMPH_CURRENT_FUNCTION,
760 OOMPH_EXCEPTION_LOCATION);
765 r[0] = Geom_data_pt[0]->value(t,0)*cos(zeta[0]);
766 r[1] = Geom_data_pt[0]->value(t,1)*sin(zeta[0]);
778 drdzeta(0,0) = - Geom_data_pt[0]->value(0)*sin(zeta[0]);
779 drdzeta(0,1) = Geom_data_pt[0]->value(1)*cos(zeta[0]);
791 ddrdzeta(0,0,0) = - Geom_data_pt[0]->value(0)*cos(zeta[0]);
792 ddrdzeta(0,0,1) = - Geom_data_pt[0]->value(1)*sin(zeta[0]);
804 double a = Geom_data_pt[0]->value(0);
805 double b = Geom_data_pt[0]->value(1);
807 r[0] = a*cos(zeta[0]);
808 r[1] = b*sin(zeta[0]);
811 drdzeta(0,0) = - a*sin(zeta[0]);
812 drdzeta(0,1) = b*cos(zeta[0]);
815 ddrdzeta(0,0,0) = - a*cos(zeta[0]);
816 ddrdzeta(0,0,1) = - b*sin(zeta[0]);
860 Circle(
const double& x_c,
const double& y_c,
864 Geom_data_pt.resize(1);
865 Geom_data_pt[0] =
new Data(3);
868 Is_time_dependent=
false;
873 Geom_data_pt[0]->pin(0);
875 Geom_data_pt[0]->set_value(0,x_c);
880 Geom_data_pt[0]->pin(1);
882 Geom_data_pt[0]->set_value(1,y_c);
887 Geom_data_pt[0]->pin(2);
889 Geom_data_pt[0]->set_value(2,r);
899 Circle(
const double& x_c,
const double& y_c,
904 Geom_data_pt.resize(1);
905 Geom_data_pt[0] =
new Data(time_stepper_pt,3);
908 Is_time_dependent=
true;
913 Geom_data_pt[0]->pin(0);
915 Geom_data_pt[0]->set_value(0,x_c);
920 Geom_data_pt[0]->pin(1);
922 Geom_data_pt[0]->set_value(1,y_c);
927 Geom_data_pt[0]->pin(2);
929 Geom_data_pt[0]->set_value(2,r);
949 if (geom_data_pt.size()!=1)
951 std::ostringstream error_message;
952 error_message <<
"geom_data_pt should have size 1, not " 953 << geom_data_pt.size() << std::endl;
955 if (geom_data_pt[0]->nvalue()!=3)
957 error_message <<
"geom_data_pt[0] should have 3 values, not " 958 << geom_data_pt[0]->nvalue() << std::endl;
962 OOMPH_CURRENT_FUNCTION,
963 OOMPH_EXCEPTION_LOCATION);
970 Is_time_dependent=
true;
974 Is_time_dependent=
false;
977 Geom_data_pt.resize(1);
978 Geom_data_pt[0]=geom_data_pt[0];
1005 delete Geom_data_pt[
i];
1015 double X_c= Geom_data_pt[0]->value(0);
1016 double Y_c= Geom_data_pt[0]->value(1);
1017 double R= Geom_data_pt[0]->value(2);
1020 r[0] = X_c + R*cos(zeta[0]);
1021 r[1] = Y_c + R*sin(zeta[0]);
1032 if (!Is_time_dependent)
1041 std::ostringstream error_message;
1042 error_message <<
"t > nprev_values() " << t <<
" " 1043 << Geom_data_pt[0]->time_stepper_pt()->nprev_values()
1047 OOMPH_CURRENT_FUNCTION,
1048 OOMPH_EXCEPTION_LOCATION);
1053 double X_c = Geom_data_pt[0]->value(t,0);
1054 double Y_c = Geom_data_pt[0]->value(t,1);
1055 double R = Geom_data_pt[0]->value(t,2);
1058 r[0] = X_c + R*cos(zeta[0]);
1059 r[1] = Y_c + R*sin(zeta[0]);
1064 double&
x_c(){
return *Geom_data_pt[0]->value_pt(0);}
1067 double&
y_c(){
return *Geom_data_pt[0]->value_pt(1);}
1070 double&
R(){
return *Geom_data_pt[0]->value_pt(2);}
1125 double&
a() {
return A;}
1133 r[0]=A*cos(zeta[1]);
1134 r[1]=
B*sin(zeta[1]);
1157 ddrdzeta(0,0,0) = 0.0;
1158 ddrdzeta(0,0,1) = 0.0;
1159 ddrdzeta(0,0,2) = 0.0;
1161 ddrdzeta(1,1,0) = -A*cos(zeta[1]);
1162 ddrdzeta(1,1,1) = -
B*sin(zeta[1]);
1163 ddrdzeta(1,1,2) = 0.0;
1165 ddrdzeta(0,1,0) = ddrdzeta(1,0,0) = 0.0;
1166 ddrdzeta(0,1,1) = ddrdzeta(1,0,1) = 0.0;
1167 ddrdzeta(0,1,2) = ddrdzeta(1,0,2) = 0.0;
1176 r[0] = A*cos(zeta[1]);
1177 r[1] =
B*sin(zeta[1]);
1186 drdzeta(1,0) = -A*sin(zeta[1]);
1187 drdzeta(1,1) =
B*cos(zeta[1]);
1191 ddrdzeta(0,0,0) = 0.0;
1192 ddrdzeta(0,0,1) = 0.0;
1193 ddrdzeta(0,0,2) = 0.0;
1195 ddrdzeta(1,1,0) = -A*cos(zeta[1]);
1196 ddrdzeta(1,1,1) = -
B*sin(zeta[1]);
1197 ddrdzeta(1,1,2) = 0.0;
1200 ddrdzeta(0,1,0) = ddrdzeta(1,0,0) = 0.0;
1201 ddrdzeta(0,1,1) = ddrdzeta(1,0,1) = 0.0;
1202 ddrdzeta(0,1,2) = ddrdzeta(1,0,2) = 0.0;
Data * geom_data_pt(const unsigned &j)
Return pointer to the j-th Data item that the object's shape depends on.
virtual unsigned ngeom_data() const
How many items of Data does the shape of the object depend on? This is implemented as a broken virtua...
virtual ~Circle()
Destructor: Clean up if necessary.
~StraightLine()
Destructor: Clean up if necessary.
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
void operator=(const Ellipse &)
Broken assignment operator.
Ellipse(const double &A, const double &B)
Constructor: 1 Lagrangian coordinate, 2 Eulerian coords. Pass half axes A and B; both pinned...
StraightLine(const double &height)
Constructor: Pass height (pinned by default)
Ellipse(const Vector< Data *> &geom_data_pt)
Constructor: 1 Lagrangian coordinate, 2 Eulerian coords. Pass half axes as Data:
double & y_c()
Access function to y-coordinate of centre of circle.
double & b()
Access function to y-half axis.
EllipticalTube(const double &a, const double &b)
Constructor: Specify radius.
StraightLine(const Vector< Data *> &geom_data_pt)
Constructor: One item of geometric data:
virtual void interpolated_zeta(const Vector< double > &s, Vector< double > &zeta) const
A geometric object may be composed of many sub-objects each with their own local coordinate. This function returns the "global" intrinsic coordinate zeta (within the compound object), at a given local coordinate s (i.e. the intrinsic coordinate of the sub-GeomObject. In simple (non-compound) GeomObjects, the local intrinsic coordinate is the global intrinsic coordinate and so the function merely returns s. To make it less likely that the default implementation is called in error (because it is not overloaded in a derived GeomObject where the default is not appropriate, we do at least check that s and zeta have the same size if called in PARANOID mode.
bool Must_clean_up
Do I need to clean up?
GeomObject(const unsigned &ndim)
Constructor: Pass dimension of geometric object (# of Eulerian coords = # of Lagrangian coords; no ti...
TimeStepper * time_stepper_pt() const
Access function for pointer to time stepper: Null if object is not time-dependent. Const version.
void position(const Vector< double > &zeta, Vector< double > &r) const
Position Vector at Lagrangian coordinate zeta.
Elliptical tube with half axes a and b.
unsigned ngeom_data() const
How many items of Data does the shape of the object depend on?
void operator=(const StraightLine &)
Broken assignment operator.
void position(const unsigned &t, const Vector< double > &zeta, Vector< double > &r) const
Parametrised position on object: r(zeta). Evaluated at previous timestep. t=0: current time; t>0: pre...
EllipticalTube(const EllipticalTube &node)
Broken copy constructor.
void d2position(const Vector< double > &zeta, RankThreeTensor< double > &ddrdzeta) const
Position Vector and 1st and 2nd derivs w.r.t. zeta.
double & x_c()
Access function to x-coordinate of centre of circle.
virtual void position(const Vector< double > &zeta, Vector< double > &r) const =0
Parametrised position on object at current time: r(zeta).
Circle(const Circle &dummy)
Broken copy constructor.
virtual void d2position(const Vector< double > &zeta, RankThreeTensor< double > &ddrdzeta) const
2nd derivative of position Vector w.r.t. to coordinates: = ddrdzeta(alpha,beta,i). Evaluated at current time.
void operator=(const EllipticalTube &)
Broken assignment operator.
GeomObject(const unsigned &nlagrangian, const unsigned &ndim)
Constructor: pass # of Eulerian and Lagrangian coordinates. No time history available/needed.
double a_ellips()
Access function for horizontal half axis.
double b_ellips()
Access function for vertical half axis.
TimeStepper * Geom_object_time_stepper_pt
Timestepper (used to handle access to geometry at previous timesteps)
Circle(const double &x_c, const double &y_c, const double &r)
Constructor: Pass x and y-coords of centre and radius (all pinned)
virtual void position(const unsigned &t, const Vector< double > &zeta, Vector< double > &r) const
Parametrised position on object: r(zeta). Evaluated at previous timestep. t=0: current time; t>0: pre...
virtual ~GeomObject()
(Empty) destructor
~Ellipse()
Destructor: Clean up if necessary.
Data * geom_data_pt(const unsigned &j)
Return pointer to the j-th Data item that the object's shape depends on.
double & R()
Access function to radius of circle.
Steady ellipse with half axes A and B as geometric object: .
Vector< Data * > Geom_data_pt
Vector of pointers to Data items that affects the object's shape.
unsigned NLagrangian
Number of Lagrangian (intrinsic) coordinates.
TimeStepper *& time_stepper_pt()
Access function for pointer to time stepper: Null if object is not time-dependent.
Data * geom_data_pt(const unsigned &j)
Return pointer to the j-th Data item that the object's shape depends on.
void position(const Vector< double > &zeta, Vector< double > &r) const
Position Vector at Lagrangian coordinate zeta.
unsigned nlagrangian() const
Access function to # of Lagrangian coordinates.
void operator=(const Circle &)
Broken assignment operator.
void position(const unsigned &t, const Vector< double > &zeta, Vector< double > &r) const
Parametrised position on object: r(zeta). Evaluated at previous timestep. t=0: current time; t>0: pre...
virtual void d2position(const Vector< double > &zeta, RankThreeTensor< double > &ddrdzeta) const
2nd derivative of position Vector w.r.t. to coordinates: = ddrdzeta(alpha,beta,i). Evaluated at current time.
bool Must_clean_up
Do I need to clean up?
void position(const unsigned &t, const Vector< double > &zeta, Vector< double > &r) const
Position vector (dummy unsteady version returns steady version)
unsigned ngeom_data() const
How many items of Data does the shape of the object depend on?
virtual void dposition(const Vector< double > &zeta, DenseMatrix< double > &drdzeta) const
Derivative of position Vector w.r.t. to coordinates: = drdzeta(alpha,i). Evaluated at current time...
virtual void assign_initial_values_impulsive(Data *const &data_pt)=0
Initialise the time-history for the Data values corresponding to an impulsive start.
A class that represents a collection of data; each Data object may contain many different individual ...
Circle(const double &x_c, const double &y_c, const double &r, TimeStepper *time_stepper_pt)
Constructor: Pass x and y-coords of centre and radius (all pinned) Circle is static but can be used i...
void position(const Vector< double > &zeta, Vector< double > &r) const
Position vector.
virtual void d2position(const Vector< double > &zeta, Vector< double > &r, DenseMatrix< double > &drdzeta, RankThreeTensor< double > &ddrdzeta) const
Posn Vector and its 1st & 2nd derivatives w.r.t. to coordinates: = drdzeta(alpha,i). = ddrdzeta(alpha,beta,i). Evaluated at current time.
virtual unsigned ngeom_data() const
How many items of Data does the shape of the object depend on?
Ellipse(const Ellipse &dummy)
Broken copy constructor.
double & a()
Access function to x-half axis.
virtual void dposition(const Vector< double > &zeta, DenseMatrix< double > &drdzeta) const
Derivative of position Vector w.r.t. to coordinates: = drdzeta(alpha,i). Evaluated at current time...
StraightLine(const StraightLine &dummy)
Broken copy constructor.
bool Is_time_dependent
Genuine time-dependence?
void position(const unsigned &t, const Vector< double > &zeta, Vector< double > &r) const
Parametrised position on object: r(zeta). Evaluated at previous timestep. t=0: current time; t>0: pre...
unsigned ndim() const
Access function to # of Eulerian coordinates.
unsigned ngeom_data() const
How many items of Data does the shape of the object depend on?
Vector< Data * > Geom_data_pt
Vector of pointers to Data items that affects the object's shape.
void position(const Vector< double > &zeta, Vector< double > &r) const
Position Vector at Lagrangian coordinate zeta.
void broken_assign(const std::string &class_name)
Issue error message and terminate execution.
Vector< Data * > Geom_data_pt
Vector of pointers to Data items that affects the object's shape.
void set_nlagrangian_and_ndim(const unsigned &n_lagrangian, const unsigned &n_dim)
Set # of Lagrangian and Eulerian coordinates.
void set_B_ellips(const double &b)
Set vertical half axis.
void dposition(const Vector< double > &zeta, DenseMatrix< double > &drdzeta) const
Derivative of position Vector w.r.t. to coordinates: = drdzeta(alpha,i).
GeomObject(const unsigned &nlagrangian, const unsigned &ndim, TimeStepper *time_stepper_pt)
Constructor: pass # of Eulerian and Lagrangian coordinates and pointer to time-stepper which is used ...
virtual void dposition_dt(const Vector< double > &zeta, const unsigned &j, Vector< double > &drdt)
j-th time-derivative on object at current time: .
bool Must_clean_up
Do I need to clean up?
virtual void d2position(const Vector< double > &zeta, Vector< double > &r, DenseMatrix< double > &drdzeta, RankThreeTensor< double > &ddrdzeta) const
Posn Vector and its 1st & 2nd derivatives w.r.t. to coordinates: = drdzeta(alpha,i). = ddrdzeta(alpha,beta,i). Evaluated at current time.
void d2position(const Vector< double > &zeta, Vector< double > &r, DenseMatrix< double > &drdzeta, RankThreeTensor< double > &ddrdzeta) const
Position Vector and 1st and 2nd derivs w.r.t. zeta.
virtual void locate_zeta(const Vector< double > &zeta, GeomObject *&sub_geom_object_pt, Vector< double > &s, const bool &use_coordinate_as_initial_guess=false)
A geometric object may be composed of may sub-objects (e.g. a finite-element representation of a boun...
GeomObject()
Default constructor.
void operator=(const GeomObject &)
Broken assignment operator.
virtual unsigned nprev_values() const =0
Number of previous values available: 0 for static, 1 for BDF<1>,...
Circle(const Vector< Data *> &geom_data_pt)
Constructor: Pass x and y-coords of centre and radius (all as Data)
Base class for time-stepping schemes. Timestepper provides an approximation of the temporal derivativ...
virtual Data * geom_data_pt(const unsigned &j)
Return pointer to the j-th Data item that the object's shape depends on. This is implemented as a bro...
unsigned Ndim
Number of Eulerian coordinates.
void d2position(const Vector< double > &zeta, Vector< double > &r, DenseMatrix< double > &drdzeta, RankThreeTensor< double > &ddrdzeta) const
Position Vector and 1st and 2nd derivs to coordinates: = drdzeta(alpha,i). = ddrdzeta(alpha,beta,i). Evaluated at current time.
GeomObject(const GeomObject &dummy)
Broken copy constructor.
void set_A_ellips(const double &a)
Set horizontal half axis.
void d2position(const Vector< double > &zeta, RankThreeTensor< double > &ddrdzeta) const
2nd derivative of position Vector w.r.t. to coordinates: = ddrdzeta(alpha,beta,i). Evaluated at current time.