33 #include "navier_stokes.h"
36 #include "meshes/channel_spine_mesh.h"
40 using namespace oomph;
76 class SpikedLine :
public GeomObject
88 SpikedLine(
const Vector<Data*>& geom_data_pt) : GeomObject(1,2)
91 if (geom_data_pt.size()!=1)
93 std::ostringstream error_stream;
95 <<
"Wrong size for geom_data_pt " << geom_data_pt.size() << std::endl;
96 if (geom_data_pt[0]->nvalue()!=1)
98 error_stream <<
"Wrong geom_data_pt[0]->nvalue() "
99 << geom_data_pt[0]->nvalue() << std::endl;
102 throw OomphLibError(error_stream.str(),
103 OOMPH_CURRENT_FUNCTION,
104 OOMPH_EXCEPTION_LOCATION);
107 Geom_data_pt.resize(1);
108 Geom_data_pt[0]=geom_data_pt[0];
117 SpikedLine(
const double&
height,
const double& amplitude,
118 const double& zeta_min,
const double& zeta_max)
122 Geom_data_pt.resize(1);
125 Geom_data_pt[0] =
new Data(4);
131 for (
unsigned i=0;i<4;i++) {Geom_data_pt[0]->pin(i);}
134 Geom_data_pt[0]->set_value(0,
height);
135 Geom_data_pt[0]->set_value(1,amplitude);
136 Geom_data_pt[0]->set_value(2,zeta_min);
137 Geom_data_pt[0]->set_value(3,zeta_max);
147 delete Geom_data_pt[0];
154 void position(
const Vector<double>& zeta, Vector<double>& r)
const
159 throw OomphLibError(
"The vector r has the wrong dimension\n",
160 OOMPH_CURRENT_FUNCTION,
161 OOMPH_EXCEPTION_LOCATION);
165 double H = Geom_data_pt[0]->value(0);
166 double A = Geom_data_pt[0]->value(1);
167 double zeta_min = Geom_data_pt[0]->value(2);
168 double zeta_max = Geom_data_pt[0]->value(3);
169 double halfLz = (zeta_max-zeta_min)/2.0;
173 if (zeta[0]-zeta_min<=halfLz)
175 r[1] =
H +
A*(zeta[0]-zeta_min)/halfLz;
179 r[1] =
H -
A*(zeta[0]-zeta_max)/halfLz;
187 void position(
const unsigned& t,
const Vector<double>& zeta,
188 Vector<double>& r)
const
191 if (t>Geom_data_pt[0]->time_stepper_pt()->nprev_values())
193 std::ostringstream error_stream;
195 <<
"t > nprev_values() in SpikedLine: " << t <<
" "
196 << Geom_data_pt[0]->time_stepper_pt()->nprev_values() << std::endl;
198 throw OomphLibError(error_stream.str(),
199 OOMPH_CURRENT_FUNCTION,
200 OOMPH_EXCEPTION_LOCATION);
205 double H = Geom_data_pt[0]->value(t,0);
206 double A = Geom_data_pt[0]->value(t,1);
207 double zeta_min = Geom_data_pt[0]->value(t,2);
208 double zeta_max = Geom_data_pt[0]->value(t,3);
209 double halfLz = (zeta_max-zeta_min)/2.0;
213 if (zeta[0]-zeta_min<=halfLz)
215 r[1] =
H +
A*(zeta[0]-zeta_min)/halfLz;
219 r[1] =
H -
A*(zeta[0]-zeta_max)/halfLz;
227 virtual void dposition(
const Vector<double>& zeta,
228 DenseMatrix<double> &drdzeta)
const
231 double A = Geom_data_pt[0]->value(1);
232 double zeta_min = Geom_data_pt[0]->value(2);
233 double zeta_max = Geom_data_pt[0]->value(3);
234 double halfLz = (zeta_max-zeta_min)/2.0;
238 if (zeta[0]-zeta_min<=halfLz)
240 drdzeta(0,1)=
A/halfLz;
244 drdzeta(0,1)=-
A/halfLz;
252 virtual void d2position(
const Vector<double>& zeta,
253 RankThreeTensor<double> &ddrdzeta)
const
266 virtual void d2position(
const Vector<double>& zeta, Vector<double>& r,
267 DenseMatrix<double> &drdzeta,
268 RankThreeTensor<double> &ddrdzeta)
const
271 double H = Geom_data_pt[0]->value(0);
272 double A = Geom_data_pt[0]->value(1);
273 double zeta_min = Geom_data_pt[0]->value(2);
274 double zeta_max = Geom_data_pt[0]->value(3);
275 double halfLz = (zeta_max-zeta_min)/2.0;
279 if (zeta[0]-zeta_min<=halfLz)
281 r[1] =
H +
A*(zeta[0]-zeta_min)/halfLz;
285 r[1] =
H -
A*(zeta[0]-zeta_max)/halfLz;
290 if (zeta[0]-zeta_min<=halfLz)
292 drdzeta(0,1)=
A/halfLz;
296 drdzeta(0,1)=-
A/halfLz;
305 unsigned ngeom_data()
const {
return Geom_data_pt.size();}
309 Data* geom_data_pt(
const unsigned& j) {
return Geom_data_pt[j];}
315 Vector<Data*> Geom_data_pt;
331 template<
class ELEMENT>
352 mesh_pt()->node_update();
356 unsigned num_nod= mesh_pt()->nboundary_node(ibound);
357 for (
unsigned inod=0;inod<num_nod;inod++)
359 double y=mesh_pt()->boundary_node_pt(ibound,inod)->x(1);
362 mesh_pt()->boundary_node_pt(ibound,inod)->set_value(i,y*(Ly-y));
365 mesh_pt()->boundary_node_pt(ibound,inod)->set_value(i,0);
370 unsigned num_bound = mesh_pt()->nboundary();
371 for(
unsigned ibound=0;ibound<num_bound-1;ibound++)
373 unsigned num_nod= mesh_pt()->nboundary_node(ibound);
374 for (
unsigned inod=0;inod<num_nod;inod++)
376 for (
unsigned i=0;i<2;i++)
380 mesh_pt()->boundary_node_pt(ibound,inod)->set_value(i,0.0);
384 mesh_pt()->boundary_node_pt(ibound,inod)->set_value(1,0.0);
395 return dynamic_cast<ChannelSpineMesh<ELEMENT>*
>(Problem::mesh_pt());
402 void doc_solution(DocInfo& doc_info);
412 template<
class ELEMENT>
438 double amplitude_upper = -0.4*Ly;
440 double zeta_max=Lx0+Lx1;
441 GeomObject* UpperWall =
442 new SpikedLine(Ly,amplitude_upper,zeta_min,zeta_max);
445 Problem::mesh_pt() =
new ChannelSpineMesh<ELEMENT>(Nx0,Nx1,Nx2,Ny,
452 unsigned num_bound = mesh_pt()->nboundary();
453 for(
unsigned ibound=0;ibound<num_bound;ibound++)
455 unsigned num_nod= mesh_pt()->nboundary_node(ibound);
456 for (
unsigned inod=0;inod<num_nod;inod++)
461 for (
unsigned i=0;i<2;i++)
463 mesh_pt()->boundary_node_pt(ibound,inod)->pin(i);
469 mesh_pt()->boundary_node_pt(ibound,inod)->pin(1);
475 unsigned n_element = mesh_pt()->nelement();
480 for(
unsigned e=0;e<n_element;e++)
483 ELEMENT* el_pt =
dynamic_cast<ELEMENT*
>(mesh_pt()->element_pt(e));
489 cout <<
"Number of equations: " << assign_eqn_numbers() << std::endl;
498 template<
class ELEMENT>
509 sprintf(filename,
"%s/soln%i.dat",doc_info.directory().c_str(),
511 some_file.open(filename);
512 mesh_pt()->output(some_file,npts);
525 doc_info.set_directory(
"RESLT");
536 problem.newton_solve();
554 problem.newton_solve();
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
ChannelSpineMesh< ELEMENT > * mesh_pt()
Upcasted access function for the mesh.
SpikedChannelSpineFlowProblem()
Constructor.
~SpikedChannelSpineFlowProblem()
Destructor: Empty.
void actions_after_newton_solve()
Update the after solve (empty)
void actions_before_newton_solve()
Update the problem specs before solve. set velocity boundary conditions just to be on the safe side....
void doc_solution(DocInfo &doc_info)
Doc the solution.
double Ly
Width of channel.
Namespace for physical parameters.
double Re
Reynolds number.
double A
Amplitude of indentation.
double height(const double &x)
Height of domain.
double H
Undeformed height of domain.
int main()
Driver for SpikedChannelSpineFlow test problem.