![]() |
![]() |
![]() |
Let us present an OFELI program that solves the 2-D time dependent incompressible Navier-Stokes equations.
#include "OFELI.h" #include "Fluid.h" #include "User.h" |
IPF data("tiff2 - 1.0",argv[1]); int output_flag = data.getOutput(); int save_flag = data.getSave(); int pres_flag = data.getIntPar(1); theTimeStep = data.getTimeStep(); theFinalTime = data.getMaxTime(); |
Mesh ms(data.getMeshFile()); User ud(ms); |
SkSMatrix<double> A(ms); Vect<double> b(ms), u(ms); |
ud.setInitialData(u); Vect<double> bc(ms); ud.setDBC(bc); Vect<double> body_f(ms); ud.setBodyForce(body_f); Vect<double> bound_f(ms); ud.setSurfaceForce(bound_f); |
IOField vf(data.getMeshFile(),data.getString("v_file"),ms,IOField::OUT); IOField pf(data.getMeshFile(),data.getString("p_file"),ms,IOField::OUT); |
TimeLoop { b = 0; |
MeshElements(ms) { NSP2DQ41 eq(theElement,u,theTime); eq.LMass(1./theTimeStep); eq.Penal(1.e07); eq.Viscous(0.1); eq.RHS_Convection(); eq.BodyRHS(ud); if (theStep==1) eq.ElementAssembly(A); eq.ElementAssembly(b); } |
MeshSides(ms) { NSP2DQ41 eq(theSide); eq.BoundaryRHS(ud); eq.SideAssembly(b); } |
A.Prescribe(ms,b,bc,theStep-1); A.solve(b); u = b; |
u.setTime(theTime); if (output_flag > 0) cout << u; if (save_flag) v_file.put(u); |
if (pres_flag) { double pres = 0.; Vect |
class User : public UserData |
<?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.1"/> <max_time value="1.0"/> <verbose value="1"/> <output value="1"/> <mesh_file value="cavity.m"/> <parameter label="v_file" value="cavity.v"/> <parameter label="p_file" value="cavity.p"/> </Project> </OFELI_File> |
Note that only execution and time integration parameters are given. All other data were given through the class User.
![]() |
![]() |
![]() |