<commit_before>#include "convectionSystem.h"
#include "debugUtils.h"
#include "chemistry0d.h"
#include "tbb_tools.h"

#include <boost/foreach.hpp>
#define foreach BOOST_FOREACH

ConvectionSystemUTW::ConvectionSystemUTW()
    : gas(NULL)
    , continuityBC(ContinuityBoundaryCondition::Left)
    , jContBC(0)
    , nVars(3)
{
}

int ConvectionSystemUTW::f(const realtype t, const sdVector& y, sdVector& ydot)
{
    unroll_y(y);
    // *** Update auxiliary data ***
    rho = gas->pressure * Wmx / (Cantera::GasConstant * T);

    // *** Calculate V ***
    if (continuityBC == ContinuityBoundaryCondition::Left) {
        rV[0] = rVzero;
        for (size_t j=0; j<nPoints-1; j++) {
            rV[j+1] = rV[j] - hh[j] * (drhodt[j] + rho[j] * pow(2.0,grid.beta)* U[j] * rphalf[j]);
        }
    } else if (continuityBC == ContinuityBoundaryCondition::Zero) {
        // jContBC is the point just to the right of the stagnation point
        size_t j = jContBC;
        double dVdx0 = - drhodt[j] - rho[j] * pow(2.0,grid.beta)* U[j] * rphalf[j];
        if (jContBC != 0) {
            dVdx0 = 0.5 * dVdx0 - 0.5 * (drhodt[j-1] + rho[j-1] * pow(2.0,grid.beta)* U[j-1] * rphalf[j-1]);
        }

        rV[j] = (x[j] - xVzero) * dVdx0;
        for (j=jContBC; j<jj; j++) {
            rV[j+1] = rV[j] - hh[j] * (drhodt[j] + rho[j] * pow(2.0,grid.beta)* U[j] * rphalf[j]);
        }

        if (jContBC != 0) {
            j = jContBC-1;
//            dVdx0 = - drhodt[j] - rho[j] * U[j] * rphalf[j];
            rV[j] = (x[j] - xVzero) * dVdx0;
            for (j=jContBC-1; j>0; j--) {
                rV[j-1] = rV[j] + hh[j-1] * (drhodt[j-1] + rho[j-1] * pow(2.0,grid.beta)* U[j-1] * rphalf[j-1]);
            }
        }
    } else {
        if (continuityBC == ContinuityBoundaryCondition::Temp) {
            size_t j = jContBC;
            // Find value of rV[jContBC] such that dTdt[jContBC] == 0, per later
            // calculation of dTdt
            if (j == 0 || splitConstT[j] / (T[j+1] - T[j]) < 0) {
                rV[j] = rphalf[j] * rho[j] * splitConstT[j] * hh[j] / (T[j+1] - T[j]);
            } else {
                rV[j] = rphalf[j-1] * rho[j] * splitConstT[j] * hh[j-1] / (T[j] - T[j-1]);
            }
        }
        for (size_t j=jContBC; j<nPoints-1; j++) {
            rV[j+1] = rV[j] - hh[j] * (drhodt[j] + rho[j] * pow(2.0,grid.beta)* U[j] * rphalf[j]);
        }
        for (size_t j=jContBC; j>0; j--) {
            rV[j-1] = rV[j] + hh[j-1] * (drhodt[j] + rho[j] * pow(2.0,grid.beta)* U[j] * rphalf[j]);
        }
    }

    rV2V();

    // *** Calculate upwinded convective derivatives<commit_msg>Fix cylindrical flame transient response<commit_after>#include "convectionSystem.h"
#include "debugUtils.h"
#include "chemistry0d.h"
#include "tbb_tools.h"

#include <boost/foreach.hpp>
#define foreach BOOST_FOREACH

ConvectionSystemUTW::ConvectionSystemUTW()
    : gas(NULL)
    , continuityBC(ContinuityBoundaryCondition::Left)
    , jContBC(0)
    , nVars(3)
{
}

int ConvectionSystemUTW::f(const realtype t, const sdVector& y, sdVector& ydot)
{
    unroll_y(y);
    // *** Update auxiliary data ***
    rho = gas->pressure * Wmx / (Cantera::GasConstant * T);

    // *** Calculate V ***
    if (continuityBC == ContinuityBoundaryCondition::Left) {
        rV[0] = rVzero;
        for (size_t j=0; j<nPoints-1; j++) {
            rV[j+1] = rV[j] - hh[j] * rphalf[j] * (drhodt[j] + rho[j] * pow(2.0,grid.beta)* U[j]);
        }
    } else if (continuityBC == ContinuityBoundaryCondition::Zero) {
        // jContBC is the point just to the right of the stagnation point
        size_t j = jContBC;
        double dVdx0 = - rphalf[j] * (drhodt[j] - rho[j] * pow(2.0,grid.beta)* U[j]);
        if (jContBC != 0) {
            dVdx0 = 0.5 * dVdx0 - 0.5 * rphalf[j-1] * (drhodt[j-1] + rho[j-1] * pow(2.0,grid.beta)* U[j-1]);
        }

        rV[j] = (x[j] - xVzero) * dVdx0;
        for (j=jContBC; j<jj; j++) {
            rV[j+1] = rV[j] - hh[j] * rphalf[j] * (drhodt[j] + rho[j] * pow(2.0,grid.beta)* U[j]);
        }

        if (jContBC != 0) {
            j = jContBC-1;
//            dVdx0 = - drhodt[j] - rho[j] * U[j] * rphalf[j];
            rV[j] = (x[j] - xVzero) * dVdx0;
            for (j=jContBC-1; j>0; j--) {
                rV[j-1] = rV[j] + hh[j-1] * rphalf[j-1] * (drhodt[j-1] + rho[j-1] * pow(2.0,grid.beta)* U[j-1]);
            }
        }
    } else {
        if (continuityBC == ContinuityBoundaryCondition::Temp) {
            size_t j = jContBC;
            // Find value of rV[jContBC] such that dTdt[jContBC] == 0, per later
            // calculation of dTdt
            if (j == 0 || splitConstT[j] / (T[j+1] - T[j]) < 0) {
                rV[j] = rphalf[j] * rho[j] * splitConstT[j] * hh[j] / (T[j+1] - T[j]);
            } else {
                rV[j] = rphalf[j-1] * rho[j] * splitConstT[j] * hh[j-1] / (T[j] - T[j-1]);
            }
        }
        for (size_t j=jContBC; j<nPoints-1; j++) {
            rV[j+1] = rV[j] - hh[j] * rphalf[j] * (drhodt[j] + rho[j] * pow(2.0,grid.beta)* U[j]);
        }
        for (size_t j=jContBC; j>0; j--) {
            rV[j-1] = rV[j] + hh[j-1] * rphalf[j] * (drhodt[j] + rho[j] * pow(2.0,grid.beta)* U[j]);
        }
    }

    rV2V();

    // *** Calculate upwinded convective derivatives
{'fraction_non_alphanumeric': 0.1969439728353141, 'fraction_numerical': 0.023014525561214864, 'mean_word_length': 2.0418818129661505, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '323785', 'n_tokens_mistral': 2363, 'n_tokens_neox': 2313, 'n_words': 421}