Challenge

Creating a custom IOObject in Visual Studio Code

documentclass[12pt]{report}
usepackage{parskip}
usepackage{graphicx}
usepackage{caption}
usepackage[a4paper, total={6in, 8in}]{geometry}

title{Creating an IOobject in Visual Studio Code}

author{Satya Sasank K}
%date{November 2021}

begin{document}

maketitle

section*{AIM}
The aim of this project is to create a new input output object called Total pressure.

section*{OBJECTIVE}
The objectives of this project are as follows:-\
1. Create an IOObject called total pressure.\
2. Place this in the controlDict file.\
3. Plot this variable against time.

section*{PROCEDURE}
The Ptotal we are trying to compute is nothing but the sum of static and dynamic pressure. It is given by the following expression.\

(P_{total} = P_{static} + P_{dynamic})\

(P_{total} = P + frac{1}{2}(U^2))\
newline
Since the value of p and u varies for each time step the value of total pressure needs to be calculated for each and every time step. We calculate this by using a cpp file and we compile this file using wmake. We will also be running this program on a test case which will be the pitzDaily case from the tutorials.\
newline
The algorithm is simple which is\
1. read U\
2. read p\
3. Calculate (P_{total})\
we create a new cpp file with the name ptotal.cpp and write the program in it which will be as follows\
begin{verbatim}
#include "fvCFD.H"
//simplifying the code using the namespace command
using namespace std;

int main(int argc,char *argv[])
{
Foam::argList::noBanner();

//removing the openfoam banner in the terminal
timeSelector::addOptions();

#include "addTimeOptions.H"
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"

instantList Times = timeSelector::select0(runTime,args);

forAll(Times,i)//for all the time steps
{
runTime.setTime(Times[i],i);
Info<<"Time: "<<runTime.timeName()<<endl;

//reading u
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ
),
mesh
);

//reading p
volScalarField p
(
IOobject
(
"p",
runTime.timeName(),
mesh,
IOobject::MUST_READ
),
mesh
);

//writing p_total
volScalarField p_total
(
IOobject
(
"p_total",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
::mag(p+0.5*pow(mag(U),2))
);
p_total.write();

}
return 0;
}
end{verbatim}

Now we need to compile this. For this we create a make folder and create 2 files in it with the names\
1. files\
2. options\
The content in these will be as follows\
"files"
begin{verbatim}
ptotal.C

EXE = $(FOAM_USER_APPBIN)/ptotal
end{verbatim}
"options"
begin{verbatim}
EXE_INC =
-I$(LIB_SRC)/finiteVolume/lnInclude
-I$(LIB_SRC)/meshTools/lnInclude

EXE_LIBS =
-lfiniteVolume
end{verbatim}
in the make folder we create another folder with the name "linux64GccDPInt32Opt"
Now in the main folder where we have the ptotal.cpp and Make. We open a new terminal and execute wmake and the ptotal program will be compiled.
Now we copy the pitzdaily folder from incompressible in tutorials into the run folder. we navigate to this pitzdaily in the run and execute the following commands.\
"blockMesh"\
"checkMesh"\
"simpleFoam"\
"ptotal"\
section*{RESULTS}
The output in the terminal will be as follows
begin{verbatim}
Create time

Create mesh for time = 0

Time: 0
Time: 100
Time: 200
Time: 282
end{verbatim}
The contour of the ptotal will be as follows
begin{figure}
centering
includegraphics[scale=0.4]{ptotal.png}
caption{Ptotal contour}
end{figure}
end{document}

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.