\documentclass[tikz, preview]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}



\usepackage{adjustbox}
\usepackage{makecell}
\usepackage{array}
\usepackage{longtable}
\usepackage{float}

\newcommand{\code}[1]{\texttt{#1}}

\begin{document}

\begin{figure}[H]
	\centering
	\begin{tikzpicture}
		% Set grid size
		\def\ymax{4}
		\def\xmax{12}
		\pgfmathsetmacro{\ymaxOblique}{\ymax+0.5}
		% Draw horizontal gray lines
%		\foreach \y in {1,...,\ymax}{
%			\draw[step=1cm, gray!50!white, very thick] (1,\y-1) grid (\xmax-1,\y-1);
%			\draw[step=1cm, gray!50!white, very thin] (1,\y-1) grid (0,\y-1);
%			\draw[step=1cm, gray!50!white, very thin] (\xmax-1,\y-1) grid (\xmax-0.5,\y-1);
%		}
		% Draw walls
		\draw[step=1cm, black, very thick] (1,-0.5) grid (1,\ymax+0.5);
		\draw[step=1cm, black, very thick] (\xmax-1,-0.5) grid (\xmax-1,\ymax+0.5);
		% Draw solid oblique lines
		\foreach \y in {0,0.3,...,\ymaxOblique} {
			\draw[gray!30!black, thick] (1,\y) -- ++(-0.3,-0.3);
			\draw[gray!30!black, thick] (\xmax-1,\y-0.3) -- ++(+0.3,+0.3);
		}
		% Draw BC normals
		\draw[->, thick, orange, line width=1pt] (1,\ymax) -- ++(1,0);
		\draw[->, thick, orange, line width=1pt] (\xmax-1,\ymax) -- ++(-1,0);
		
		% Draw velocity collaction points	
		\foreach \y in {1,...,\ymax} {
		\foreach \x in {1,...,\xmax} {
			% u
			\ifnum\x=1
				\draw[->, thick, red!90!black, line width=1pt] (\x-0.4,\y-1) -- ++(0.001,0);
			\else
			\ifnum\x=\xmax
				\draw[->, thick, red!90!black, line width=1pt] (\x-0.4,\y-1) -- ++(0.001,0);
			\else
				\draw[->, thick, green!70!black, line width=1pt] (\x-0.4,\y-1) -- ++(0.001,0);
			\fi
			\fi
			% v
			\ifnum\x=1
				\draw[->, thick, black, line width=1pt] (\x-1,\y-0.4) -- ++(0,0.001);
			\else
			\ifnum\x=2
			\draw[->, thick, red!90!black, line width=1pt] (\x-1,\y-0.4) -- ++(0,0.001);
			\else
			\ifnum\x=\xmax
				\draw[->, thick, red!90!black, line width=1pt] (\x-1,\y-0.4) -- ++(0,0.001);
			\else
				\draw[->, thick, green!70!black, line width=1pt] (\x-1,\y-0.4) -- ++(0,0.001);
			\fi
			\fi
			\fi
		}
		}
		% Draw pressure points
		\foreach \y in {1,...,\ymax}{
		\foreach \x in {1,...,\xmax}{
			\ifnum\x=1
		\fill[black] (\x-1,\y-1) circle (2pt);
		\else
		\fill[blue] (\x-1,\y-1) circle (2pt);
		\fi
	}}
		% Draw pointed points
		\foreach \y in {0,...,\ymax}{
		\draw[dotted, thick, cyan] (1-0.25,\y-0.25) -- (1+0.75,\y-0.25);
		\draw[dotted, thick, magenta] (\xmax-1-0.25,\y-0.25) -- (\xmax-1+0.75,\y-0.25);
		}
		
		\draw [dotted,thick,cyan] (0.75,-0.25)-- (0.75, \ymax-0.25);
		\draw [dotted,thick,cyan] (1.75,-0.25)-- (1.75, \ymax-0.25);
		\draw [dotted,thick,magenta] (\xmax-1-0.25,-0.25)-- (\xmax-1-0.25, \ymax-0.25);
		\draw [dotted,thick,magenta] (\xmax-0.25,-0.25)-- (\xmax-0.25, \ymax-0.25);	
		
		
		
		% Text
		\node at (1.5,-0.5) {\(x_{\min}\)};
		\node at (\xmax-0.5,-0.5) {\(x_{\max}\)};
		% global grid idx
		\node at (0,-1) {0};
		\node at (1,-1) {1};
		\node at (2,-1) {2};
		\node at (3,-1) {3};
		\node at (4,-1) {4};
		\node at (5,-1.1) {\dots};
		\node at (7,-1.1) {\dots};
		\node at (8,-1) {\small \code{Nx-2}};
		\node at (9,-1) {\small \code{Nx-1}};
		\node at (10,-1) {\small \code{Nx}};
		\node at (11,-1) {\small \code{Nx+1}};
		%lower BC grid idx
		\node[cyan] at (0,-1.5) {-1};
		\node[cyan] at (1,-1.5) {0};
		\node[cyan] at (2,-1.5) {1};
		\node[cyan] at (3,-1.5) {2};
		% upper BC grid idx
		\node[magenta] at (9,-1.5) {-2};
		\node[magenta] at (10,-1.5) {-1};
		\node[magenta] at (11,-1.5) {0};
		
\end{tikzpicture}
\end{figure}

\end{document}
