Project 2- Creating a custom IOObject in Visual Studio Code
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\title{Creating a custom IOObject using Visual Studio code}
\author{Pavan Kumar}
\date{}
\begin{document}
\maketitle
\newpage
\section{Introduction}
In this article, the total pressure field $p_total$ is the contribution of the static pressure and the dynamic pressure is computed in the pitzDaily tutorial of OpenFOAM. The report is compiled, and the results are presented as well.
\section{PitzDaily}
It is a case study to investigate steady turbulent flow over a backward-facing step. The problem description is taken from one used by Pitz and Daily in an experimental investigation against which the computed solution can be compared. This example introduces the following OpenFOAM features for the first time:
\begin{enumerate}
\item generation of a mesh using blockMesh using full mesh grading capability;
\item steady turbulent flow.
\end{enumerate}
\section{Procedure}
The pitzDaily tutorial is copied from the incompressible/simpleFoam directory,
Then inside the controlDict, the following code is added:
\begin{verbatim}
functions
{
#includeFunc streamlines
p_total
{
type coded;
libs ("libutilityFunctionObjects.so");
name p_total;
enabled true;
writeControl timeStep;
writeInterval 100;
codeWrite
#{
const volScalarField& p = mesh().lookupObject("p");
const volVectorField& U = mesh().lookupObject("U");
Info << "Creating p_total Field" << nl << endl;
volScalarField p_total
(
IOobject
(
"p_total",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
p + 0.5*mag(U)*mag(U)
);
p_total.write();
#};
}
}
\end{verbatim}
The total pressure is computed as the sum of static (p) and dynamic pressure $(0.5*U^2)$, using the formula:
\[p total= p + (0.5U^2)\]
\section{Explanation of code}
The steps used to create the ptotal field and calculate the total pressure are as follows:
\begin{enumerate}
\item Here, the ptotal filed is created from the bases of utilityFunctionObjects.so library and is written at every 100th interval time step.
\item Then, read the mesh data in U and p field files by using lookup command.
\item Then, created an IOobject scalar field called ptotal to write mesh, time instance data inside the ptotal field by using the formula $p + 0.5*mag(U)*mag(U)$
\end{enumerate}
\section{Results}
Run the solver by using the following commands
\begin{enumerate}
\item blockMesh
\item simpleFoam
\item paraFoam
\end{enumerate}
After, the end of the stimulation, the ptotal field is created as post-processing results.
Then, to visualize the fields use paraFoam command, and the results are as follows:
\begin{figure}
\centering
\includegraphics[width=0.5\linewidth]{p.png}
\caption{pressure field}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=0.5\linewidth]{U.png}
\caption{velocity field}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=0.5\linewidth]{p_total.png}
\caption{ptotal at 100 timestep }
\end{figure}
\begin{figure}
\centering
\includegraphics[width=0.5\linewidth]{p_total2.png}
\caption{ptotal at 200 time step}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=0.5\linewidth]{plot.png}
\caption{plot of p,U,ptotal over the length}
\end{figure}
\section{Conclusion}
Finally, we created a custom IOobject in Visual Studio Code to compute the total pressure flow filed for an incompressible fluid case, pitzDaily. And plotted the results in this report.
\end{document}