void Network::getNetForces() { for (int i = 0; i <= iMax; i++) { for (int j = 0; j <= jMax; j++) { isiMax = i == iMax; isjMin = j == 0; isjMax = j == jMax; int j1 = isjMax ? 0 : j + 1; int i1 = isiMax ? 0 : i + 1; int j2 = isjMin ? jMax : j - 1; double tempPos[8] = { pos[(i * netSize + j) * 2], pos[(i * netSize + j) * 2 + 1], pos[(i * netSize + j1) * 2], pos[(i * netSize + j1) * 2 + 1] , pos[(i1 * netSize + j) * 2], pos[(i1 * netSize + j) * 2 + 1], pos[(i1 * netSize + j2) * 2], pos[(i1 * netSize + j2) * 2 + 1] }; // Calculate the net x and y force on each node. Similar to gradient function. for (int k = 1; k < 4; k++) { double x_displacement = tempPos[2 * k] + xshift(k) - tempPos[0]; double y_displacement = tempPos[2 * k + 1] + yshift(k) - tempPos[1]; forces[i][j][2 * k - 2] = spr[i][j][k - 1] * deltaL(tempPos, k) / euclDist(tempPos, k) * (x_displacement); forces[i][j][2 * k - 1] = spr[i][j][k - 1] * deltaL(tempPos, k) / euclDist(tempPos, k) * (y_displacement); } } } }
// Network Function Definitions. double Network::operator() () { double funcvalue = 0; for(int i = 0; i <= iMax; i++) { for (int j = 0; j <= jMax; j++) { // Make the array double pos[]. This shall point to the // positions of the following nodes: // // 1. node i, j // 2. node i, j + 1 (j1) // 3. node i + 1 (i1), j // 4. node i + 1, j - 1 (j2) // // Make sure to impose the periodic boundary condition here. // This is done by making a temporary node copy of the // corresponding mode (using modulo arithemetic). // // Strain is obtained by shifting the bonds at the top of the // network over by an integer number of points in the // x-direction. When measuring the energy, it only affects the // topmost row (i = iMax). isiMax = i == iMax; isjMax = j == jMax; isjMin = j == 0; int j1 = isjMax ? 0 : j + 1; int i1 = isiMax ? 0 : i + 1; int j2 = isjMin ? jMax : j - 1; double tempPos[8] = { pos[(i * netSize + j) * 2], pos[(i * netSize + j) * 2 + 1], pos[(i * netSize + j1) * 2], pos[(i * netSize + j1) * 2 + 1], pos[(i1 * netSize + j) * 2], pos[(i1 * netSize + j) * 2 + 1], pos[(i1 * netSize + j2) * 2], pos[(i1 * netSize + j2) * 2 + 1] }; for (int k = 1; k < 4; k++) { double delta = deltaL(tempPos, k); funcvalue = 0.5 * spr[i][j][k - 1] / RESTLEN * delta * delta; } } // Cycling all columns in a row } // Cycling all rows return funcvalue; }
// * * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * * // void Foam::coherentFlameModel2b::update() { Info<<"Updating Sigma Source terms"<<endl; volVectorField M(fvc::grad(b_)); volScalarField mgb_ = mag(M); dimensionedScalar dSigma = 1.0e-3* (b_* (scalar(1.0) - b_) * mgb_)().weightedAverage(rho_.mesh().V()) /((b_ * (scalar(1.0) - b_))().weightedAverage(rho_.mesh().V()) + SMALL) + dimensionedScalar("dSig", Sigma_.dimensions(), SMALL); M /= (max(Sigma_, mgb_) + dSigma); // volScalarField magM = mag(M); // M /= Sigma_ + dimensionedScalar("tol", dimless/dimLength, SMALL); // M /= (magM + dimensionedScalar("tol", dimless/dimLength, SMALL)); volScalarField orientationFactor = scalar(1.0) - (M & M); orientationFactor.max(0.0); orientationFactor.min(1.0); volTensorField A_ = I * (1.0 - orientationFactor / 3.0) - (M * M); volTensorField gradU(fvc::grad(U_)); volScalarField up(sqrt((2.0/3.0)*turbulence_.k())); //Efficiency function from the ITNFS model volScalarField GammaK("GammaK", rho_/rho_); scalar T1 = min(thermo_.Tu()).value(); scalar T2 = max(thermo_.Tb()).value(); volScalarField deltaL(2.0 * thermo_.alpha() / thermo_.rhou() / Su_ * pow(T2/T1, 0.7)); volScalarField lt(Clt_ * pow(up, 3) / (turbulence_.epsilon() + dimensionedScalar("tol", pow(dimVelocity,2)/dimTime, SMALL))); volScalarField lRatio(lt / deltaL); volScalarField uRatio(up / Su_); volScalarField s = max ( log10 (lRatio), scalar(-0.4+SMALL) ); if(fittedGammaK_){ GammaK = 0.75 * exp(-1.2 / pow(uRatio, 0.3)) * pow(lRatio, 2.0/3.0); } else { volScalarField sigma1 = 2.0 / 3.0 * (1.0 - 0.5 * exp(-pow(uRatio, 1.0/3.0))); volScalarField r = -exp(-(s+0.4)) / (s+0.4) + (1.0 - exp(-(s+0.4))) * (sigma1 * s - 0.11); GammaK = pow(10.0, r); } if(quenchingCoeff_ != 0.0){ volScalarField g = (0.7 + 1.0 / s) * exp(-s) + (1.0 - exp(-s)) * (1.0 + 0.36 * s); volScalarField x = (log10 (uRatio) - g) / s / 0.04; volScalarField Pq = 0.5 * (1.0 + tanh (sign(x) * x * x)); GammaK -= quenchingCoeff_ * 1.5 * lRatio / uRatio * log (1.0 / (1.0 - Pq)); } volScalarField P1 = rho_ * alphaSigma_ * GammaK * turbulence_.epsilon() / (turbulence_.k() + dimensionedScalar("tol", pow(dimVelocity,2), SMALL)); volScalarField P2 = rho_ * (A_ && gradU); ProdRateForSigma_ = P1 + P2; DestrRateForSigma_ = rho_ * betaSigma_ * (Su_ + CSigma_ * sqrt(3.0/2.0) * up) * Sigma_/(b_ * (1.0 - b_) + SMALL); }