Challenge

Project 2- Creating a custom IOObject in Visual Studio Code

Code used in Latex:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}

\title{Creating a custom IOObject using Visual studio code}
\author{Aditya Bantwal}
\date{August 2022}

\begin{document}

\maketitle
\newpage
\section{Introduction}
In this study, the total pressure field is computed in the pitzDaily tutorial of OpenFOAM. The report is compiled using LATEX and the results are presented as well.

\section{Methodology}
The pitzDaily tutorial is copied from the incompressible/simpleFoam directory,
In the controlDict, the following changes are made: 
\begin{verbatim}
functions
{

    totalPressurefo
    {
        libs        ("libutilityFunctionObjects.so");
        type coded;
        // Name of on-the-fly generated functionObject
        name pTotal;
        writeControl   timeStep;
        writeInterval 100;
        codeWrite
        #{
            const volVectorField& U = mesh().lookupObject<volVectorField>("U");
            const volScalarField& p = mesh().lookupObject<volScalarField>("p");
                volScalarField pTotal
                (
                    IOobject
                    (
                        "pTotal",
                        mesh().time().timeName(),
                        mesh(),
                        IOobject::NO_READ,
                        IOobject::AUTO_WRITE
                    ),
                    p+0.5*magSqr(U)
                );
                pTotal.write();
        #};
    }

    #includeFunc streamlines
}
\end{verbatim}

The total pressure is computed as the sum of static and dynamic pressure, using the formula:
\[ptotal= pstatic + (0.5U^2)\]

The steps used to create the ptotal field and calculate the total pressure are as follows:
\begin{enumerate}
\item Create a Scalar and vector to read the pressure and velocity fields
  \item Create an IOObject
   \item Compute the total pressure
  \item Write the total pressure
\end{enumerate}

\section{Results}
\begin{figure}[htp]
    \centering
    \includegraphics[width=15cm]{ptotal}
    \caption{Total pressure}
    \label{fig:ptotal}
\end{figure}

As observed from Figure 1., the total pressure is shown and the flow occurs from high total pressure to low.

\section{Conclusion}
In this study, a codedFunctionObject was used to compute the total pressure using OpenFOAM for the pitzDaily tutorial case. The report was created in Latex.

\end{document}

To view the report created by Latex, the following link can be referred to:

https://drive.google.com/file/d/1XNRCshUbakdqQpPVdJwjEhdn4yoRhP9Z/view?usp=sharing

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.