![]() |
![]() |
![]() |
We present an OFELI program that solves the 2-D time-dependent incompressible Navier-Stokes equations. For this demo, we solve these equations by a time integration projection method. Space discretisation is handled by a triangular finite element method.
#include "OFELI.h" #include "Fluid.h" |
IPF proj(argv[1]);
Verbosity = proj.getVerbose();
Mesh mesh(proj.getMeshFile());
theTimeStep = proj.getTimeStep();
theFinalTime = proj.getMaxTime();
int plot_flag = proj.getPlot();
double Re = proj.getDouble("Reynolds");
|
IOField vff(proj.getMeshFile(),proj.getString("v_file"),mesh,IOField::OUT);
IOField pff(proj.getMeshFile(),proj.getString("p_file"),mesh,IOField::OUT);
|
Vect<double> u(mesh,"Velocity",0), p(mesh,"Pressure",0,1); TINS2DT3S eq(mesh); eq.Reynolds(Re); eq.setTolerance(proj.getTolerance()); |
Vect<double> bc(mesh), bf(mesh); Prescription pr(mesh,proj.getDataFile()); pr.get(INITIAL_FIELD,u); eq.setInput(INITIAL_FIELD,u); |
TimeLoop {
eq.setInput(BOUNDARY_CONDITION,pr.get(BOUNDARY_CONDITION,theTime));
eq.setInput(BODY_FORCE,pr.get(BODY_FORCE,theTime));
eq.runOneTimeStep();
if (plot_flag>0 && theStep%plot_flag==0) {
p.setTime(theTime); u.setTime(theTime);
vff.put(u); pff.put(p);
}
}
|
<?xml version="1.0" encoding="ISO-8859-1" ?>
<OFELI_File>
<info>
<title></title>
<date></date>
<author></author>
</info>
<Project name="cavity">
<time_step value="0.01"/>
<max_time value="0.5"/>
<verbose value="1"/>
<plot value="10"/>
<mesh_file value="cavity-30.m"/>
<parameter label="Reynolds" value="1"/>
<parameter label="v_file" value="cavity.v"/>
<parameter label="p_file" value="cavity.p"/>
</Project>
<Prescription>
<BoundaryCondition code="2" dof="1">1</BoundaryCondition>
</Prescription>
</OFELI_File>
|
Note that we have also a section describing prescription data where a boundary condition is given: We impose the value 1.0 to the horizontal velocity dof="1" for nodes with a code equal to 2. All other data that are not given are by default set to 0.
![]() |
![]() |
![]() |