\hypertarget{namespaceppm__functions}{}\section{ppm\+\_\+functions Module Reference}
\label{namespaceppm__functions}\index{ppm\_functions@{ppm\_functions}}


\subsection{Detailed Description}
Provides functions used with the Piecewise-\/\+Parabolic-\/\+Method in the vertical A\+LE algorithm. \subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespaceppm__functions_a5c4e47be75ad413904902582b3d0d4a4}{ppm\+\_\+reconstruction}} (N, h, u, edge\+\_\+values, ppoly\+\_\+coef, h\+\_\+neglect, answers\+\_\+2018)
\begin{DoxyCompactList}\small\item\em Builds quadratic polynomials coefficients from cell mean and edge values. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespaceppm__functions_a3d365f4992a6d3b5cbcaca630c502b95}{ppm\+\_\+limiter\+\_\+standard}} (N, h, u, edge\+\_\+values, h\+\_\+neglect, answers\+\_\+2018)
\begin{DoxyCompactList}\small\item\em Adjusts edge values using the standard P\+PM limiter (Colella \& Woodward, J\+CP 1984) after first checking that the edge values are bounded by neighbors cell averages and that the edge values are monotonic between cell averages. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceppm__functions_ac8f382eb9d1f0df80aab9e07eb2ceebe}{ppm\+\_\+boundary\+\_\+extrapolation}} (N, h, u, edge\+\_\+values, ppoly\+\_\+coef, h\+\_\+neglect)
\begin{DoxyCompactList}\small\item\em Reconstruction by parabolas within boundary cells. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
real, parameter \mbox{\hyperlink{namespaceppm__functions_a86e3d1a796b4934167d563eda5310a0e}{hneglect\+\_\+dflt}} = 1.E-\/30
\begin{DoxyCompactList}\small\item\em A tiny width that is so small that adding it to cell widths does not change the value due to a computational representation. It is used to avoid division by zero. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespaceppm__functions_ac8f382eb9d1f0df80aab9e07eb2ceebe}\label{namespaceppm__functions_ac8f382eb9d1f0df80aab9e07eb2ceebe}} 
\index{ppm\_functions@{ppm\_functions}!ppm\_boundary\_extrapolation@{ppm\_boundary\_extrapolation}}
\index{ppm\_boundary\_extrapolation@{ppm\_boundary\_extrapolation}!ppm\_functions@{ppm\_functions}}
\subsubsection{\texorpdfstring{ppm\_boundary\_extrapolation()}{ppm\_boundary\_extrapolation()}}
{\footnotesize\ttfamily subroutine, public ppm\+\_\+functions\+::ppm\+\_\+boundary\+\_\+extrapolation (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{N,  }\item[{real, dimension(\+:), intent(in)}]{h,  }\item[{real, dimension(\+:), intent(in)}]{u,  }\item[{real, dimension(\+:,\+:), intent(inout)}]{edge\+\_\+values,  }\item[{real, dimension(\+:,\+:), intent(inout)}]{ppoly\+\_\+coef,  }\item[{real, intent(in), optional}]{h\+\_\+neglect }\end{DoxyParamCaption})}



Reconstruction by parabolas within boundary cells. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em n} & Number of cells \\
\hline
\mbox{\texttt{ in}}  & {\em h} & cell widths (size N) \mbox{[}H\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em u} & cell averages (size N) \mbox{[}A\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em edge\+\_\+values} & edge values of piecewise polynomials \mbox{[}A\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em ppoly\+\_\+coef} & coefficients of piecewise polynomials, mainly \mbox{[}A\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+neglect} & A negligibly small width for the purpose of cell reconstructions \mbox{[}H\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 134 of file P\+P\+M\+\_\+functions.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{134 \textcolor{comment}{!------------------------------------------------------------------------------}}
\DoxyCodeLine{135 \textcolor{comment}{! Reconstruction by parabolas within boundary cells.}}
\DoxyCodeLine{136 \textcolor{comment}{!}}
\DoxyCodeLine{137 \textcolor{comment}{! The following explanations apply to the left boundary cell. The same}}
\DoxyCodeLine{138 \textcolor{comment}{! reasoning holds for the right boundary cell.}}
\DoxyCodeLine{139 \textcolor{comment}{!}}
\DoxyCodeLine{140 \textcolor{comment}{! A parabola needs to be built in the cell and requires three degrees of}}
\DoxyCodeLine{141 \textcolor{comment}{! freedom, which are the right edge value and slope and the cell average.}}
\DoxyCodeLine{142 \textcolor{comment}{! The right edge values and slopes are taken to be that of the neighboring}}
\DoxyCodeLine{143 \textcolor{comment}{! cell (i.e., the left edge value and slope of the neighboring cell).}}
\DoxyCodeLine{144 \textcolor{comment}{! The resulting parabola is not necessarily monotonic and the traditional}}
\DoxyCodeLine{145 \textcolor{comment}{! PPM limiter is used to modify one of the edge values in order to yield}}
\DoxyCodeLine{146 \textcolor{comment}{! a monotonic parabola.}}
\DoxyCodeLine{147 \textcolor{comment}{!}}
\DoxyCodeLine{148 \textcolor{comment}{! N:     number of cells in grid}}
\DoxyCodeLine{149 \textcolor{comment}{! h:     thicknesses of grid cells}}
\DoxyCodeLine{150 \textcolor{comment}{! u:     cell averages to use in constructing piecewise polynomials}}
\DoxyCodeLine{151 \textcolor{comment}{! edge\_values : edge values of piecewise polynomials}}
\DoxyCodeLine{152 \textcolor{comment}{! ppoly\_coef : coefficients of piecewise polynomials}}
\DoxyCodeLine{153 \textcolor{comment}{!}}
\DoxyCodeLine{154 \textcolor{comment}{! It is assumed that the size of the array 'u' is equal to the number of cells}}
\DoxyCodeLine{155 \textcolor{comment}{! defining 'grid' and 'ppoly'. No consistency check is performed here.}}
\DoxyCodeLine{156 \textcolor{comment}{!------------------------------------------------------------------------------}}
\DoxyCodeLine{157 }
\DoxyCodeLine{158   \textcolor{comment}{! Arguments}}
\DoxyCodeLine{159   \textcolor{keywordtype}{integer},              \textcolor{keywordtype}{intent(in)}    :: N\textcolor{comment}{ !< Number of cells}}
\DoxyCodeLine{160 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)},   \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{ !< cell widths (size N) [H]}}
\DoxyCodeLine{161 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)},   \textcolor{keywordtype}{intent(in)}    :: u\textcolor{comment}{ !< cell averages (size N) [A]}}
\DoxyCodeLine{162 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{intent(inout)} :: edge\_values\textcolor{comment}{    !< edge values of piecewise polynomials [A]}}
\DoxyCodeLine{163 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{intent(inout)} :: ppoly\_coef\textcolor{comment}{ !< coefficients of piecewise polynomials, mainly [A]}}
\DoxyCodeLine{164 \textcolor{keywordtype}{  real},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: h\_neglect\textcolor{comment}{  !< A negligibly small width for}}
\DoxyCodeLine{165 \textcolor{comment}{                                           !! the purpose of cell reconstructions [H]}}
\DoxyCodeLine{166 }
\DoxyCodeLine{167   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{168   \textcolor{keywordtype}{integer} :: i0, i1}
\DoxyCodeLine{169 \textcolor{keywordtype}{  real}    :: u0, u1}
\DoxyCodeLine{170 \textcolor{keywordtype}{  real}    :: h0, h1}
\DoxyCodeLine{171 \textcolor{keywordtype}{  real}    :: a, b, c}
\DoxyCodeLine{172 \textcolor{keywordtype}{  real}    :: u0\_l, u0\_r}
\DoxyCodeLine{173 \textcolor{keywordtype}{  real}    :: u1\_l, u1\_r}
\DoxyCodeLine{174 \textcolor{keywordtype}{  real}    :: slope}
\DoxyCodeLine{175 \textcolor{keywordtype}{  real}    :: exp1, exp2}
\DoxyCodeLine{176 \textcolor{keywordtype}{  real}    :: hNeglect}
\DoxyCodeLine{177 }
\DoxyCodeLine{178   hneglect = hneglect\_dflt ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(h\_neglect)) hneglect = h\_neglect}
\DoxyCodeLine{179 }
\DoxyCodeLine{180   \textcolor{comment}{! ----- Left boundary -----}}
\DoxyCodeLine{181   i0 = 1}
\DoxyCodeLine{182   i1 = 2}
\DoxyCodeLine{183   h0 = h(i0)}
\DoxyCodeLine{184   h1 = h(i1)}
\DoxyCodeLine{185   u0 = u(i0)}
\DoxyCodeLine{186   u1 = u(i1)}
\DoxyCodeLine{187 }
\DoxyCodeLine{188   \textcolor{comment}{! Compute the left edge slope in neighboring cell and express it in}}
\DoxyCodeLine{189   \textcolor{comment}{! the global coordinate system}}
\DoxyCodeLine{190   b = ppoly\_coef(i1,2)}
\DoxyCodeLine{191   u1\_r = b *((h0+hneglect)/(h1+hneglect))     \textcolor{comment}{! derivative evaluated at xi = 0.0,}}
\DoxyCodeLine{192                         \textcolor{comment}{! expressed w.r.t. xi (local coord. system)}}
\DoxyCodeLine{193 }
\DoxyCodeLine{194   \textcolor{comment}{! Limit the right slope by the PLM limited slope}}
\DoxyCodeLine{195   slope = 2.0 * ( u1 - u0 )}
\DoxyCodeLine{196   \textcolor{keywordflow}{if} ( abs(u1\_r) > abs(slope) ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{197     u1\_r = slope}
\DoxyCodeLine{198 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{199 }
\DoxyCodeLine{200   \textcolor{comment}{! The right edge value in the boundary cell is taken to be the left}}
\DoxyCodeLine{201   \textcolor{comment}{! edge value in the neighboring cell}}
\DoxyCodeLine{202   u0\_r = edge\_values(i1,1)}
\DoxyCodeLine{203 }
\DoxyCodeLine{204   \textcolor{comment}{! Given the right edge value and slope, we determine the left}}
\DoxyCodeLine{205   \textcolor{comment}{! edge value and slope by computing the parabola as determined by}}
\DoxyCodeLine{206   \textcolor{comment}{! the right edge value and slope and the boundary cell average}}
\DoxyCodeLine{207   u0\_l = 3.0 * u0 + 0.5 * u1\_r - 2.0 * u0\_r}
\DoxyCodeLine{208 }
\DoxyCodeLine{209   \textcolor{comment}{! Apply the traditional PPM limiter}}
\DoxyCodeLine{210   exp1 = (u0\_r - u0\_l) * (u0 - 0.5*(u0\_l+u0\_r))}
\DoxyCodeLine{211   exp2 = (u0\_r - u0\_l) * (u0\_r - u0\_l) / 6.0}
\DoxyCodeLine{212 }
\DoxyCodeLine{213   \textcolor{keywordflow}{if} ( exp1 > exp2 ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{214     u0\_l = 3.0 * u0 - 2.0 * u0\_r}
\DoxyCodeLine{215 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{216 }
\DoxyCodeLine{217   \textcolor{keywordflow}{if} ( exp1 < -exp2 ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{218     u0\_r = 3.0 * u0 - 2.0 * u0\_l}
\DoxyCodeLine{219 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{220 }
\DoxyCodeLine{221   edge\_values(i0,1) = u0\_l}
\DoxyCodeLine{222   edge\_values(i0,2) = u0\_r}
\DoxyCodeLine{223 }
\DoxyCodeLine{224   a = u0\_l}
\DoxyCodeLine{225   b = 6.0 * u0 - 4.0 * u0\_l - 2.0 * u0\_r}
\DoxyCodeLine{226   c = 3.0 * ( u0\_r + u0\_l - 2.0 * u0 )}
\DoxyCodeLine{227 }
\DoxyCodeLine{228   ppoly\_coef(i0,1) = a}
\DoxyCodeLine{229   ppoly\_coef(i0,2) = b}
\DoxyCodeLine{230   ppoly\_coef(i0,3) = c}
\DoxyCodeLine{231 }
\DoxyCodeLine{232   \textcolor{comment}{! ----- Right boundary -----}}
\DoxyCodeLine{233   i0 = n-1}
\DoxyCodeLine{234   i1 = n}
\DoxyCodeLine{235   h0 = h(i0)}
\DoxyCodeLine{236   h1 = h(i1)}
\DoxyCodeLine{237   u0 = u(i0)}
\DoxyCodeLine{238   u1 = u(i1)}
\DoxyCodeLine{239 }
\DoxyCodeLine{240   \textcolor{comment}{! Compute the right edge slope in neighboring cell and express it in}}
\DoxyCodeLine{241   \textcolor{comment}{! the global coordinate system}}
\DoxyCodeLine{242   b = ppoly\_coef(i0,2)}
\DoxyCodeLine{243   c = ppoly\_coef(i0,3)}
\DoxyCodeLine{244   u1\_l = (b + 2*c)                  \textcolor{comment}{! derivative evaluated at xi = 1.0}}
\DoxyCodeLine{245   u1\_l = u1\_l * ((h1+hneglect)/(h0+hneglect))}
\DoxyCodeLine{246 }
\DoxyCodeLine{247   \textcolor{comment}{! Limit the left slope by the PLM limited slope}}
\DoxyCodeLine{248   slope = 2.0 * ( u1 - u0 )}
\DoxyCodeLine{249   \textcolor{keywordflow}{if} ( abs(u1\_l) > abs(slope) ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{250     u1\_l = slope}
\DoxyCodeLine{251 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{252 }
\DoxyCodeLine{253   \textcolor{comment}{! The left edge value in the boundary cell is taken to be the right}}
\DoxyCodeLine{254   \textcolor{comment}{! edge value in the neighboring cell}}
\DoxyCodeLine{255   u0\_l = edge\_values(i0,2)}
\DoxyCodeLine{256 }
\DoxyCodeLine{257   \textcolor{comment}{! Given the left edge value and slope, we determine the right}}
\DoxyCodeLine{258   \textcolor{comment}{! edge value and slope by computing the parabola as determined by}}
\DoxyCodeLine{259   \textcolor{comment}{! the left edge value and slope and the boundary cell average}}
\DoxyCodeLine{260   u0\_r = 3.0 * u1 - 0.5 * u1\_l - 2.0 * u0\_l}
\DoxyCodeLine{261 }
\DoxyCodeLine{262   \textcolor{comment}{! Apply the traditional PPM limiter}}
\DoxyCodeLine{263   exp1 = (u0\_r - u0\_l) * (u1 - 0.5*(u0\_l+u0\_r))}
\DoxyCodeLine{264   exp2 = (u0\_r - u0\_l) * (u0\_r - u0\_l) / 6.0}
\DoxyCodeLine{265 }
\DoxyCodeLine{266   \textcolor{keywordflow}{if} ( exp1 > exp2 ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{267     u0\_l = 3.0 * u1 - 2.0 * u0\_r}
\DoxyCodeLine{268 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{269 }
\DoxyCodeLine{270   \textcolor{keywordflow}{if} ( exp1 < -exp2 ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{271     u0\_r = 3.0 * u1 - 2.0 * u0\_l}
\DoxyCodeLine{272 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{273 }
\DoxyCodeLine{274   edge\_values(i1,1) = u0\_l}
\DoxyCodeLine{275   edge\_values(i1,2) = u0\_r}
\DoxyCodeLine{276 }
\DoxyCodeLine{277   a = u0\_l}
\DoxyCodeLine{278   b = 6.0 * u1 - 4.0 * u0\_l - 2.0 * u0\_r}
\DoxyCodeLine{279   c = 3.0 * ( u0\_r + u0\_l - 2.0 * u1 )}
\DoxyCodeLine{280 }
\DoxyCodeLine{281   ppoly\_coef(i1,1) = a}
\DoxyCodeLine{282   ppoly\_coef(i1,2) = b}
\DoxyCodeLine{283   ppoly\_coef(i1,3) = c}
\DoxyCodeLine{284 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceppm__functions_a3d365f4992a6d3b5cbcaca630c502b95}\label{namespaceppm__functions_a3d365f4992a6d3b5cbcaca630c502b95}} 
\index{ppm\_functions@{ppm\_functions}!ppm\_limiter\_standard@{ppm\_limiter\_standard}}
\index{ppm\_limiter\_standard@{ppm\_limiter\_standard}!ppm\_functions@{ppm\_functions}}
\subsubsection{\texorpdfstring{ppm\_limiter\_standard()}{ppm\_limiter\_standard()}}
{\footnotesize\ttfamily subroutine ppm\+\_\+functions\+::ppm\+\_\+limiter\+\_\+standard (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{N,  }\item[{real, dimension(\+:), intent(in)}]{h,  }\item[{real, dimension(\+:), intent(in)}]{u,  }\item[{real, dimension(\+:,\+:), intent(inout)}]{edge\+\_\+values,  }\item[{real, intent(in), optional}]{h\+\_\+neglect,  }\item[{logical, intent(in), optional}]{answers\+\_\+2018 }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Adjusts edge values using the standard P\+PM limiter (Colella \& Woodward, J\+CP 1984) after first checking that the edge values are bounded by neighbors cell averages and that the edge values are monotonic between cell averages. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em n} & Number of cells \\
\hline
\mbox{\texttt{ in}}  & {\em h} & cell widths (size N) \mbox{[}H\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em u} & cell average properties (size N) \mbox{[}A\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em edge\+\_\+values} & Potentially modified edge values \mbox{[}A\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+neglect} & A negligibly small width \mbox{[}H\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em answers\+\_\+2018} & If true use older, less acccurate expressions. \\
\hline
\end{DoxyParams}


Definition at line 63 of file P\+P\+M\+\_\+functions.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{63   \textcolor{keywordtype}{integer},              \textcolor{keywordtype}{intent(in)}    :: N\textcolor{comment}{ !< Number of cells}}
\DoxyCodeLine{64 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)},   \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{ !< cell widths (size N) [H]}}
\DoxyCodeLine{65 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)},   \textcolor{keywordtype}{intent(in)}    :: u\textcolor{comment}{ !< cell average properties (size N) [A]}}
\DoxyCodeLine{66 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{intent(inout)} :: edge\_values\textcolor{comment}{ !< Potentially modified edge values [A]}}
\DoxyCodeLine{67 \textcolor{keywordtype}{  real},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: h\_neglect\textcolor{comment}{ !< A negligibly small width [H]}}
\DoxyCodeLine{68   \textcolor{keywordtype}{logical},    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: answers\_2018\textcolor{comment}{ !< If true use older, less acccurate expressions.}}
\DoxyCodeLine{69 }
\DoxyCodeLine{70   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{71   \textcolor{keywordtype}{integer}   :: k              \textcolor{comment}{! Loop index}}
\DoxyCodeLine{72 \textcolor{keywordtype}{  real}      :: u\_l, u\_c, u\_r  \textcolor{comment}{! Cell averages (left, center and right)}}
\DoxyCodeLine{73 \textcolor{keywordtype}{  real}      :: edge\_l, edge\_r \textcolor{comment}{! Edge values (left and right)}}
\DoxyCodeLine{74 \textcolor{keywordtype}{  real}      :: expr1, expr2}
\DoxyCodeLine{75 }
\DoxyCodeLine{76   \textcolor{comment}{! Bound edge values}}
\DoxyCodeLine{77   \textcolor{keyword}{call }bound\_edge\_values( n, h, u, edge\_values, h\_neglect, answers\_2018 )}
\DoxyCodeLine{78 }
\DoxyCodeLine{79   \textcolor{comment}{! Make discontinuous edge values monotonic}}
\DoxyCodeLine{80   \textcolor{keyword}{call }check\_discontinuous\_edge\_values( n, u, edge\_values )}
\DoxyCodeLine{81 }
\DoxyCodeLine{82   \textcolor{comment}{! Loop on interior cells to apply the standard}}
\DoxyCodeLine{83   \textcolor{comment}{! PPM limiter (Colella \& Woodward, JCP 84)}}
\DoxyCodeLine{84   \textcolor{keywordflow}{do} k = 2,n-1}
\DoxyCodeLine{85 }
\DoxyCodeLine{86     \textcolor{comment}{! Get cell averages}}
\DoxyCodeLine{87     u\_l = u(k-1)}
\DoxyCodeLine{88     u\_c = u(k)}
\DoxyCodeLine{89     u\_r = u(k+1)}
\DoxyCodeLine{90 }
\DoxyCodeLine{91     edge\_l = edge\_values(k,1)}
\DoxyCodeLine{92     edge\_r = edge\_values(k,2)}
\DoxyCodeLine{93 }
\DoxyCodeLine{94     \textcolor{keywordflow}{if} ( (u\_r - u\_c)*(u\_c - u\_l) <= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{95       \textcolor{comment}{! Flatten extremum}}
\DoxyCodeLine{96       edge\_l = u\_c}
\DoxyCodeLine{97       edge\_r = u\_c}
\DoxyCodeLine{98     \textcolor{keywordflow}{else}}
\DoxyCodeLine{99       expr1 = 3.0 * (edge\_r - edge\_l) * ( (u\_c - edge\_l) + (u\_c - edge\_r))}
\DoxyCodeLine{100       expr2 = (edge\_r - edge\_l) * (edge\_r - edge\_l)}
\DoxyCodeLine{101       \textcolor{keywordflow}{if} ( expr1 > expr2 ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{102         \textcolor{comment}{! Place extremum at right edge of cell by adjusting left edge value}}
\DoxyCodeLine{103         edge\_l = u\_c + 2.0 * ( u\_c - edge\_r )}
\DoxyCodeLine{104         edge\_l = max( min( edge\_l, max(u\_l, u\_c) ), min(u\_l, u\_c) ) \textcolor{comment}{! In case of round off}}
\DoxyCodeLine{105       \textcolor{keywordflow}{elseif} ( expr1 < -expr2 ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{106         \textcolor{comment}{! Place extremum at left edge of cell by adjusting right edge value}}
\DoxyCodeLine{107         edge\_r = u\_c + 2.0 * ( u\_c - edge\_l )}
\DoxyCodeLine{108         edge\_r = max( min( edge\_r, max(u\_r, u\_c) ), min(u\_r, u\_c) ) \textcolor{comment}{! In case of round off}}
\DoxyCodeLine{109 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{110 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{111     \textcolor{comment}{! This checks that the difference in edge values is representable}}
\DoxyCodeLine{112     \textcolor{comment}{! and avoids overshoot problems due to round off.}}
\DoxyCodeLine{113     \textcolor{comment}{!\#\#\# The 1.e-60 needs to have units of [A], so this dimensionally inconsisent.}}
\DoxyCodeLine{114     \textcolor{keywordflow}{if} ( abs( edge\_r - edge\_l )<max(1.e-60,epsilon(u\_c)*abs(u\_c)) ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{115       edge\_l = u\_c}
\DoxyCodeLine{116       edge\_r = u\_c}
\DoxyCodeLine{117 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{118 }
\DoxyCodeLine{119     edge\_values(k,1) = edge\_l}
\DoxyCodeLine{120     edge\_values(k,2) = edge\_r}
\DoxyCodeLine{121 }
\DoxyCodeLine{122 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! end loop on interior cells}}
\DoxyCodeLine{123 }
\DoxyCodeLine{124   \textcolor{comment}{! PCM within boundary cells}}
\DoxyCodeLine{125   edge\_values(1,:) = u(1)}
\DoxyCodeLine{126   edge\_values(n,:) = u(n)}
\DoxyCodeLine{127 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceppm__functions_a5c4e47be75ad413904902582b3d0d4a4}\label{namespaceppm__functions_a5c4e47be75ad413904902582b3d0d4a4}} 
\index{ppm\_functions@{ppm\_functions}!ppm\_reconstruction@{ppm\_reconstruction}}
\index{ppm\_reconstruction@{ppm\_reconstruction}!ppm\_functions@{ppm\_functions}}
\subsubsection{\texorpdfstring{ppm\_reconstruction()}{ppm\_reconstruction()}}
{\footnotesize\ttfamily subroutine, public ppm\+\_\+functions\+::ppm\+\_\+reconstruction (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{N,  }\item[{real, dimension(n), intent(in)}]{h,  }\item[{real, dimension(n), intent(in)}]{u,  }\item[{real, dimension(n,2), intent(inout)}]{edge\+\_\+values,  }\item[{real, dimension(n,3), intent(inout)}]{ppoly\+\_\+coef,  }\item[{real, intent(in), optional}]{h\+\_\+neglect,  }\item[{logical, intent(in), optional}]{answers\+\_\+2018 }\end{DoxyParamCaption})}



Builds quadratic polynomials coefficients from cell mean and edge values. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em n} & Number of cells \\
\hline
\mbox{\texttt{ in}}  & {\em h} & Cell widths \mbox{[}H\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em u} & Cell averages \mbox{[}A\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em edge\+\_\+values} & Edge values \mbox{[}A\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em ppoly\+\_\+coef} & Polynomial coefficients, mainly \mbox{[}A\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+neglect} & A negligibly small width \mbox{[}H\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em answers\+\_\+2018} & If true use older, less acccurate expressions. \\
\hline
\end{DoxyParams}


Definition at line 29 of file P\+P\+M\+\_\+functions.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{29   \textcolor{keywordtype}{integer},              \textcolor{keywordtype}{intent(in)}    :: N\textcolor{comment}{ !< Number of cells}}
\DoxyCodeLine{30 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(N)},   \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{ !< Cell widths [H]}}
\DoxyCodeLine{31 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(N)},   \textcolor{keywordtype}{intent(in)}    :: u\textcolor{comment}{ !< Cell averages [A]}}
\DoxyCodeLine{32 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(N,2)}, \textcolor{keywordtype}{intent(inout)} :: edge\_values\textcolor{comment}{ !< Edge values [A]}}
\DoxyCodeLine{33 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(N,3)}, \textcolor{keywordtype}{intent(inout)} :: ppoly\_coef\textcolor{comment}{ !< Polynomial coefficients, mainly [A]}}
\DoxyCodeLine{34 \textcolor{keywordtype}{  real},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: h\_neglect\textcolor{comment}{ !< A negligibly small width [H]}}
\DoxyCodeLine{35   \textcolor{keywordtype}{logical},    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: answers\_2018\textcolor{comment}{ !< If true use older, less acccurate expressions.}}
\DoxyCodeLine{36 }
\DoxyCodeLine{37   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{38   \textcolor{keywordtype}{integer}   :: k              \textcolor{comment}{! Loop index}}
\DoxyCodeLine{39 \textcolor{keywordtype}{  real}      :: edge\_l, edge\_r \textcolor{comment}{! Edge values (left and right)}}
\DoxyCodeLine{40 }
\DoxyCodeLine{41   \textcolor{comment}{! PPM limiter}}
\DoxyCodeLine{42   \textcolor{keyword}{call }ppm\_limiter\_standard( n, h, u, edge\_values, h\_neglect, answers\_2018 )}
\DoxyCodeLine{43 }
\DoxyCodeLine{44   \textcolor{comment}{! Loop over all cells}}
\DoxyCodeLine{45   \textcolor{keywordflow}{do} k = 1,n}
\DoxyCodeLine{46 }
\DoxyCodeLine{47     edge\_l = edge\_values(k,1)}
\DoxyCodeLine{48     edge\_r = edge\_values(k,2)}
\DoxyCodeLine{49 }
\DoxyCodeLine{50     \textcolor{comment}{! Store polynomial coefficients}}
\DoxyCodeLine{51     ppoly\_coef(k,1) = edge\_l}
\DoxyCodeLine{52     ppoly\_coef(k,2) = 4.0 * ( u(k) - edge\_l ) + 2.0 * ( u(k) - edge\_r )}
\DoxyCodeLine{53     ppoly\_coef(k,3) = 3.0 * ( ( edge\_r - u(k) ) + ( edge\_l - u(k) ) )}
\DoxyCodeLine{54 }
\DoxyCodeLine{55 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{56 }

\end{DoxyCode}


\subsection{Variable Documentation}
\mbox{\Hypertarget{namespaceppm__functions_a86e3d1a796b4934167d563eda5310a0e}\label{namespaceppm__functions_a86e3d1a796b4934167d563eda5310a0e}} 
\index{ppm\_functions@{ppm\_functions}!hneglect\_dflt@{hneglect\_dflt}}
\index{hneglect\_dflt@{hneglect\_dflt}!ppm\_functions@{ppm\_functions}}
\subsubsection{\texorpdfstring{hneglect\_dflt}{hneglect\_dflt}}
{\footnotesize\ttfamily real, parameter ppm\+\_\+functions\+::hneglect\+\_\+dflt = 1.E-\/30\hspace{0.3cm}{\ttfamily [private]}}



A tiny width that is so small that adding it to cell widths does not change the value due to a computational representation. It is used to avoid division by zero. 

\begin{DoxyNote}{Note}
This is a dimensional parameter and should really include a unit conversion. 
\end{DoxyNote}


Definition at line 23 of file P\+P\+M\+\_\+functions.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{23 \textcolor{keywordtype}{real}, \textcolor{keywordtype}{parameter} :: hNeglect\_dflt = 1.e-30}

\end{DoxyCode}
