Skip to content

Commit

Permalink
Add Burgers' equation solver
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsawko committed Jul 1, 2016
0 parents commit 0c90a43
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
polyMesh
linux64Gcc*
3 changes: 3 additions & 0 deletions burgersFoam/Make/files
@@ -0,0 +1,3 @@
burgersFoam.C

EXE = $(FOAM_APPBIN)/burgersFoam
11 changes: 11 additions & 0 deletions burgersFoam/Make/options
@@ -0,0 +1,11 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/fvOptions/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude

EXE_LIBS = \
-lfiniteVolume \
-lfvOptions \
-lmeshTools \
-lsampling
77 changes: 77 additions & 0 deletions burgersFoam/burgersFoam.C
@@ -0,0 +1,77 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
burgersFoam
Description
Solves a transport equation for a passive scalar
\*---------------------------------------------------------------------------*/

#include "fvCFD.H"
#include "fvIOoptionList.H"
#include "simpleControl.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"

simpleControl simple(mesh);

#include "createFields.H"
#include "createFvOptions.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

Info<< "\nCalculating scalar transport\n" << endl;

#include "CourantNo.H"

while (simple.loop())
{
Info<< "Time = " << runTime.timeName() << nl << endl;

while (simple.correctNonOrthogonal())
{
solve
(
fvm::ddt(U)
+ fvm::div(phi, U)
- fvm::laplacian(nu, U)
);
}
phi = linearInterpolate(U) & mesh.Sf();
runTime.write();
}

Info<< "End\n" << endl;
return 0;
}


// ************************************************************************* //
39 changes: 39 additions & 0 deletions burgersFoam/createFields.H
@@ -0,0 +1,39 @@
Info<< "Reading field U\n" << endl;

volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);


Info<< "Reading transportProperties\n" << endl;

IOdictionary transportProperties
(
IOobject
(
"transportProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
);


Info<< "Reading viscosity nu\n" << endl;

dimensionedScalar nu
(
transportProperties.lookup("nu")
);

#include "createPhi.H"

0 comments on commit 0c90a43

Please sign in to comment.