37 #include "navier_stokes.h" 40 #include "meshes/channel_spine_mesh.h" 44 using namespace oomph;
84 const double& zeta_min,
const double& zeta_max)
88 Geom_data_pt.resize(1);
91 Geom_data_pt[0] =
new Data(4);
97 for (
unsigned i=0;i<4;i++) {Geom_data_pt[0]->pin(i);}
100 Geom_data_pt[0]->set_value(0,height);
101 Geom_data_pt[0]->set_value(1,amplitude);
102 Geom_data_pt[0]->set_value(2,zeta_min);
103 Geom_data_pt[0]->set_value(3,zeta_max);
118 if(geom_data_pt.size()!=1)
120 std::ostringstream error_stream;
122 <<
"Wrong size for geom_data_pt " << geom_data_pt.size() << std::endl;
123 if (geom_data_pt[0]->nvalue()!=1)
125 error_stream <<
"Wrong geom_data_pt[0]->nvalue() " 126 << geom_data_pt[0]->nvalue() << std::endl;
129 throw OomphLibError(error_stream.str(),
130 OOMPH_CURRENT_FUNCTION,
131 OOMPH_EXCEPTION_LOCATION);
134 Geom_data_pt.resize(1);
135 Geom_data_pt[0]=geom_data_pt[0];
149 delete Geom_data_pt[0];
155 double&
height(){
return *Geom_data_pt[0]->value_pt(0);}
158 double&
amplitude(){
return *Geom_data_pt[0]->value_pt(1);}
162 void position(
const Vector<double>& zeta, Vector<double>& r)
const 167 throw OomphLibError(
"The vector r has the wrong dimension\n",
168 OOMPH_CURRENT_FUNCTION,
169 OOMPH_EXCEPTION_LOCATION);
173 double H = Geom_data_pt[0]->value(0);
174 double A = Geom_data_pt[0]->value(1);
175 double zeta_min = Geom_data_pt[0]->value(2);
176 double zeta_max = Geom_data_pt[0]->value(3);
177 double Lz = zeta_max-zeta_min;
181 r[1] = H + A*sin(MathematicalConstants::Pi*(zeta[0]-zeta_min)/Lz);
188 void position(
const unsigned& t,
const Vector<double>& zeta,
189 Vector<double>& r)
const 192 if (t>Geom_data_pt[0]->time_stepper_pt()->nprev_values())
194 std::ostringstream error_stream;
196 <<
"t > nprev_values() in SpikedLine: " << t <<
" " 197 << Geom_data_pt[0]->time_stepper_pt()->nprev_values() << std::endl;
199 throw OomphLibError(error_stream.str(),
200 OOMPH_CURRENT_FUNCTION,
201 OOMPH_EXCEPTION_LOCATION);
206 double H = Geom_data_pt[0]->value(t,0);
207 double A = Geom_data_pt[0]->value(t,1);
208 double zeta_min = Geom_data_pt[0]->value(t,2);
209 double zeta_max = Geom_data_pt[0]->value(t,3);
210 double Lz = zeta_max-zeta_min;
214 r[1] = H + A*sin(MathematicalConstants::Pi*(zeta[0]-zeta_min)/Lz);
223 DenseMatrix<double> &drdzeta)
const 226 double A = Geom_data_pt[0]->value(1);
227 double zeta_min = Geom_data_pt[0]->value(2);
228 double zeta_max = Geom_data_pt[0]->value(3);
229 double Lz = zeta_max-zeta_min;
233 drdzeta(0,1)=MathematicalConstants::Pi*A*
234 cos(MathematicalConstants::Pi*(zeta[0]-zeta_min)/Lz)/Lz;
242 RankThreeTensor<double> &ddrdzeta)
const 245 double A = Geom_data_pt[0]->value(1);
246 double zeta_min = Geom_data_pt[0]->value(2);
247 double zeta_max = Geom_data_pt[0]->value(3);
248 double Lz = zeta_max-zeta_min;
252 ddrdzeta(0,0,1)=-MathematicalConstants::Pi*MathematicalConstants::Pi*
253 A*sin(MathematicalConstants::Pi*(zeta[0]-zeta_min)/Lz)/(Lz*Lz);
262 virtual void d2position(
const Vector<double>& zeta, Vector<double>& r,
263 DenseMatrix<double> &drdzeta,
264 RankThreeTensor<double> &ddrdzeta)
const 267 double H = Geom_data_pt[0]->value(0);
268 double A = Geom_data_pt[0]->value(1);
269 double zeta_min = Geom_data_pt[0]->value(2);
270 double zeta_max = Geom_data_pt[0]->value(3);
271 double Lz = zeta_max-zeta_min;
275 r[1] = H + A*sin(MathematicalConstants::Pi*(zeta[0]-zeta_min)/Lz);
279 drdzeta(0,1)=MathematicalConstants::Pi*A*
280 cos(MathematicalConstants::Pi*(zeta[0]-zeta_min)/Lz)/Lz;
284 ddrdzeta(0,0,1)=-MathematicalConstants::Pi*MathematicalConstants::Pi*
285 A*sin(MathematicalConstants::Pi*(zeta[0]-zeta_min)/Lz)/(Lz*Lz);
316 template<
class ELEMENT>
333 mesh_pt()->node_update();
342 void doc_solution(DocInfo& doc_info);
357 template<
class ELEMENT>
387 double amplitude_upper = -0.4*Ly;
390 double zeta_max=Lx0+Lx1;
391 GeomObject* UpperWall =
396 Problem::mesh_pt() =
new ChannelSpineMesh<ELEMENT>(Nx0,Nx1,Nx2,Ny,
404 unsigned num_bound = mesh_pt()->nboundary();
405 for(
unsigned ibound=0;ibound<num_bound;ibound++)
407 unsigned num_nod= mesh_pt()->nboundary_node(ibound);
408 for (
unsigned inod=0;inod<num_nod;inod++)
413 for (
unsigned i=0;i<2;i++)
415 mesh_pt()->boundary_node_pt(ibound,inod)->pin(i);
421 mesh_pt()->boundary_node_pt(ibound,inod)->pin(1);
429 for (
unsigned ibound=0;ibound<num_bound-1;ibound++)
431 unsigned num_nod= mesh_pt()->nboundary_node(ibound);
432 for (
unsigned inod=0;inod<num_nod;inod++)
436 for (
unsigned i=0;i<2;i++)
438 mesh_pt()->boundary_node_pt(ibound,inod)->set_value(i,0.0);
443 mesh_pt()->boundary_node_pt(ibound,inod)->set_value(1,0.0);
451 unsigned num_nod= mesh_pt()->nboundary_node(ibound);
452 for (
unsigned inod=0;inod<num_nod;inod++)
454 double y=mesh_pt()->boundary_node_pt(ibound,inod)->x(1);
456 mesh_pt()->boundary_node_pt(ibound,inod)->set_value(0,y*(Ly-y));
457 mesh_pt()->boundary_node_pt(ibound,inod)->set_value(1,0.0);
461 unsigned n_element = mesh_pt()->nelement();
466 for(
unsigned e=0;e<n_element;e++)
469 ELEMENT* el_pt =
dynamic_cast<ELEMENT*
>(mesh_pt()->element_pt(e));
475 cout <<
"Number of equations: " << assign_eqn_numbers() << std::endl;
485 template<
class ELEMENT>
496 sprintf(filename,
"%s/soln%i.dat",doc_info.directory().c_str(),
498 some_file.open(filename);
499 mesh_pt()->output(some_file,npts);
514 doc_info.set_directory(
"RESLT");
525 problem.newton_solve();
543 problem.newton_solve();
567 doc_info.set_directory(
"RESLT");
591 double amplitude_upper = -0.4*Ly;
593 double zeta_max=Lx0+Lx1;
594 GeomObject* UpperWall =
598 ChannelSpineMesh<SpineElement<QTaylorHoodElement<2> > >* mesh_pt =
599 new ChannelSpineMesh<SpineElement<QTaylorHoodElement<2> > >(Nx0,Nx1,Nx2,Ny,
604 mesh_pt->node_update();
607 dynamic_cast<SinusoidalWall*
>(mesh_pt->wall_pt())->amplitude()=0.5;
617 sprintf(filename,
"%s/mesh_update%i.dat",doc_info.directory().c_str(),
622 unsigned n_node = mesh_pt->nnode();
623 for (
unsigned inode=0;inode<n_node;inode++)
625 SpineNode* node_pt=
dynamic_cast<SpineNode*
>(
626 mesh_pt->node_pt(inode));
627 if (node_pt->node_update_fct_id()==1)
629 node_pt->node_update();
631 some_file.open(filename);
632 sprintf(filename,
"%s/mesh_update%i.dat",doc_info.directory().c_str(),
635 mesh_pt->output(some_file,npts);
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.
~SinusoidalWall()
Destructor: Clean up if necessary.
void doc_solution(DocInfo &doc_info)
Doc the solution.
double height(const double &x)
Height of domain.
SinusoidalWall(const double &height, const double &litude, const double &zeta_min, const double &zeta_max)
Constructor: Pass height, amplitude, zeta min and zeta max (all are pinned by default) ...
bool Must_clean_up
Do I need to clean up?
void actions_after_newton_solve()
Update the after solve (empty)
double & height()
Access function for horizontal half axis.
Data * geom_data_pt(const unsigned &j)
Return pointer to the j-th Data item that the object's shape depends on.
SinusoidalWall(const Vector< Data *> &geom_data_pt)
Constructor: One item of geometric data, containing four values:
ChannelSpineFlowProblem()
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.
~ChannelSpineFlowProblem()
Destructor: (empty)
Vector< Data * > Geom_data_pt
Vector of pointers to Data items that affects the object's shape.
double Re
Reynolds number.
unsigned ngeom_data() const
How many items of Data does the shape of the object depend on?
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...
void doc_sparse_node_update()
Create the files to illustrate the sparse node update operation.
void position(const Vector< double > &zeta, Vector< double > &r) const
Position vector at Lagrangian coordinate zeta.
Namespace for physical parameters.
double H
Undeformed height of domain.
int main()
Driver for channel flow problem with spine mesh.
void actions_before_newton_solve()
Update the problem specs before solve. Set velocity boundary conditions just to be on the safe side...
double & amplitude()
Access function for vertical half axis.
double A
Amplitude of indentation.
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...