int test_string_cast_vector() { int Error = 0; glm::vec2 A1(1, 2); std::string A2 = glm::to_string(A1); Error += A2 != std::string("fvec2(1.000000, 2.000000)") ? 1 : 0; glm::vec3 B1(1, 2, 3); std::string B2 = glm::to_string(B1); Error += B2 != std::string("fvec3(1.000000, 2.000000, 3.000000)") ? 1 : 0; glm::vec4 C1(1, 2, 3, 4); std::string C2 = glm::to_string(C1); Error += C2 != std::string("fvec4(1.000000, 2.000000, 3.000000, 4.000000)") ? 1 : 0; glm::ivec2 D1(1, 2); std::string D2 = glm::to_string(D1); Error += D2 != std::string("ivec2(1, 2)") ? 1 : 0; glm::ivec3 E1(1, 2, 3); std::string E2 = glm::to_string(E1); Error += E2 != std::string("ivec3(1, 2, 3)") ? 1 : 0; glm::ivec4 F1(1, 2, 3, 4); std::string F2 = glm::to_string(F1); Error += F2 != std::string("ivec4(1, 2, 3, 4)") ? 1 : 0; glm::dvec2 J1(1, 2); std::string J2 = glm::to_string(J1); Error += J2 != std::string("dvec2(1.000000, 2.000000)") ? 1 : 0; glm::dvec3 K1(1, 2, 3); std::string K2 = glm::to_string(K1); Error += K2 != std::string("dvec3(1.000000, 2.000000, 3.000000)") ? 1 : 0; glm::dvec4 L1(1, 2, 3, 4); std::string L2 = glm::to_string(L1); Error += L2 != std::string("dvec4(1.000000, 2.000000, 3.000000, 4.000000)") ? 1 : 0; return Error; }
double rspfBesselOrderOneFilter::filter(double x, double /* support */)const { double p, q; if (x == 0.0) return(0.0); p=x; if (x < 0.0) x=(-x); if (x < 8.0) return(p*J1(x)); q=sqrt(2.0/(M_PI*x))*(P1(x)*(1.0/sqrt(2.0)*(sin(x)-cos(x)))-8.0/x*Q1(x)* (-1.0/sqrt(2.0)*(sin(x)+cos(x)))); if (p < 0.0) q=(-q); return(q); }
/*** contributions from the mirror image H0 ***/ static double strikexH0 (MagComp component, const fault_params *fault, const magnetic_params *mag, double xi, double et, double qq, double y, double z) { double val; double h = mag->dcurier; double qd = y * sd + (fault->fdepth - h) * cd; double K1_val = K1 (component, 1.0, xi, et, qq); double atan_xe_qr_val = atan_xe_qr (component, 1.0, xi, et, qq); double J1_val = J1 (component, 1.0, xi, et, qq); double M1_val = M1 (component, 1.0, xi, et, qq); double L1_val = L1 (component, 1.0, xi, et, qq); double M1y_val = M1y (component, 1.0, xi, et, qq); double M1z_val = M1z (component, 1.0, xi, et, qq); val = - (2.0 - alpha4) * K1_val - alpha1 * atan_xe_qr_val - alpha3 * J1_val - alpha3 * (qd * M1_val + (z - h) * L1_val * sd) - 2.0 * alpha4 * h * (M1_val * cd - L1_val * sd) - 4.0 * alpha1 * h * L1_val * sd + 2.0 * alpha2 * h * ((qd + h * cd) * M1z_val - (z - 2.0 * h) * M1y_val * sd); return val; }
int test_string_cast_vector() { int Error = 0; { glm::vec2 A1(1, 2); std::string A2 = glm::to_string(A1); Error += A2 != std::string("vec2(1.000000, 2.000000)") ? 1 : 0; glm::vec3 B1(1, 2, 3); std::string B2 = glm::to_string(B1); Error += B2 != std::string("vec3(1.000000, 2.000000, 3.000000)") ? 1 : 0; glm::vec4 C1(1, 2, 3, 4); std::string C2 = glm::to_string(C1); Error += C2 != std::string("vec4(1.000000, 2.000000, 3.000000, 4.000000)") ? 1 : 0; glm::dvec2 J1(1, 2); std::string J2 = glm::to_string(J1); Error += J2 != std::string("dvec2(1.000000, 2.000000)") ? 1 : 0; glm::dvec3 K1(1, 2, 3); std::string K2 = glm::to_string(K1); Error += K2 != std::string("dvec3(1.000000, 2.000000, 3.000000)") ? 1 : 0; glm::dvec4 L1(1, 2, 3, 4); std::string L2 = glm::to_string(L1); Error += L2 != std::string("dvec4(1.000000, 2.000000, 3.000000, 4.000000)") ? 1 : 0; } { glm::bvec2 M1(false, true); std::string M2 = glm::to_string(M1); Error += M2 != std::string("bvec2(false, true)") ? 1 : 0; glm::bvec3 O1(false, true, false); std::string O2 = glm::to_string(O1); Error += O2 != std::string("bvec3(false, true, false)") ? 1 : 0; glm::bvec4 P1(false, true, false, true); std::string P2 = glm::to_string(P1); Error += P2 != std::string("bvec4(false, true, false, true)") ? 1 : 0; } { glm::ivec2 D1(1, 2); std::string D2 = glm::to_string(D1); Error += D2 != std::string("ivec2(1, 2)") ? 1 : 0; glm::ivec3 E1(1, 2, 3); std::string E2 = glm::to_string(E1); Error += E2 != std::string("ivec3(1, 2, 3)") ? 1 : 0; glm::ivec4 F1(1, 2, 3, 4); std::string F2 = glm::to_string(F1); Error += F2 != std::string("ivec4(1, 2, 3, 4)") ? 1 : 0; } { glm::i8vec2 D1(1, 2); std::string D2 = glm::to_string(D1); Error += D2 != std::string("i8vec2(1, 2)") ? 1 : 0; glm::i8vec3 E1(1, 2, 3); std::string E2 = glm::to_string(E1); Error += E2 != std::string("i8vec3(1, 2, 3)") ? 1 : 0; glm::i8vec4 F1(1, 2, 3, 4); std::string F2 = glm::to_string(F1); Error += F2 != std::string("i8vec4(1, 2, 3, 4)") ? 1 : 0; } { glm::i16vec2 D1(1, 2); std::string D2 = glm::to_string(D1); Error += D2 != std::string("i16vec2(1, 2)") ? 1 : 0; glm::i16vec3 E1(1, 2, 3); std::string E2 = glm::to_string(E1); Error += E2 != std::string("i16vec3(1, 2, 3)") ? 1 : 0; glm::i16vec4 F1(1, 2, 3, 4); std::string F2 = glm::to_string(F1); Error += F2 != std::string("i16vec4(1, 2, 3, 4)") ? 1 : 0; } { glm::i64vec2 D1(1, 2); std::string D2 = glm::to_string(D1); Error += D2 != std::string("i64vec2(1, 2)") ? 1 : 0; glm::i64vec3 E1(1, 2, 3); std::string E2 = glm::to_string(E1); Error += E2 != std::string("i64vec3(1, 2, 3)") ? 1 : 0; glm::i64vec4 F1(1, 2, 3, 4); std::string F2 = glm::to_string(F1); Error += F2 != std::string("i64vec4(1, 2, 3, 4)") ? 1 : 0; } return Error; }
void Foam::kineticTheoryModel::solve(const volTensorField& gradUat) { if (!kineticTheory_) { return; } const scalar sqrtPi = sqrt(constant::mathematical::pi); surfaceScalarField phi(1.5*rhoa_*phia_*fvc::interpolate(alpha_)); volTensorField dU(gradUat.T()); //fvc::grad(Ua_); volSymmTensorField D(symm(dU)); // NB, drag = K*alpha*beta, // (the alpha and beta has been extracted from the drag function for // numerical reasons) volScalarField Ur(mag(Ua_ - Ub_)); volScalarField betaPrim(alpha_*(1.0 - alpha_)*draga_.K(Ur)); // Calculating the radial distribution function (solid volume fraction is // limited close to the packing limit, but this needs improvements) // The solution is higly unstable close to the packing limit. gs0_ = radialModel_->g0 ( min(max(alpha_, scalar(1e-6)), alphaMax_ - 0.01), alphaMax_ ); // particle pressure - coefficient in front of Theta (Eq. 3.22, p. 45) volScalarField PsCoeff ( granularPressureModel_->granularPressureCoeff ( alpha_, gs0_, rhoa_, e_ ) ); // 'thermal' conductivity (Table 3.3, p. 49) kappa_ = conductivityModel_->kappa(alpha_, Theta_, gs0_, rhoa_, da_, e_); // particle viscosity (Table 3.2, p.47) mua_ = viscosityModel_->mua(alpha_, Theta_, gs0_, rhoa_, da_, e_); dimensionedScalar Tsmall ( "small", dimensionSet(0 , 2 ,-2 ,0 , 0, 0, 0), 1.0e-6 ); dimensionedScalar TsmallSqrt = sqrt(Tsmall); volScalarField ThetaSqrt(sqrt(Theta_)); // dissipation (Eq. 3.24, p.50) volScalarField gammaCoeff ( 12.0*(1.0 - sqr(e_))*sqr(alpha_)*rhoa_*gs0_*(1.0/da_)*ThetaSqrt/sqrtPi ); // Eq. 3.25, p. 50 Js = J1 - J2 volScalarField J1(3.0*betaPrim); volScalarField J2 ( 0.25*sqr(betaPrim)*da_*sqr(Ur) /(max(alpha_, scalar(1e-6))*rhoa_*sqrtPi*(ThetaSqrt + TsmallSqrt)) ); // bulk viscosity p. 45 (Lun et al. 1984). lambda_ = (4.0/3.0)*sqr(alpha_)*rhoa_*da_*gs0_*(1.0+e_)*ThetaSqrt/sqrtPi; // stress tensor, Definitions, Table 3.1, p. 43 volSymmTensorField tau(2.0*mua_*D + (lambda_ - (2.0/3.0)*mua_)*tr(D)*I); if (!equilibrium_) { // construct the granular temperature equation (Eq. 3.20, p. 44) // NB. note that there are two typos in Eq. 3.20 // no grad infront of Ps // wrong sign infront of laplacian fvScalarMatrix ThetaEqn ( fvm::ddt(1.5*alpha_*rhoa_, Theta_) + fvm::div(phi, Theta_, "div(phi,Theta)") == fvm::SuSp(-((PsCoeff*I) && dU), Theta_) + (tau && dU) + fvm::laplacian(kappa_, Theta_, "laplacian(kappa,Theta)") + fvm::Sp(-gammaCoeff, Theta_) + fvm::Sp(-J1, Theta_) + fvm::Sp(J2/(Theta_ + Tsmall), Theta_) ); ThetaEqn.relax(); ThetaEqn.solve(); } else { // equilibrium => dissipation == production // Eq. 4.14, p.82 volScalarField K1(2.0*(1.0 + e_)*rhoa_*gs0_); volScalarField K3 ( 0.5*da_*rhoa_* ( (sqrtPi/(3.0*(3.0-e_))) *(1.0 + 0.4*(1.0 + e_)*(3.0*e_ - 1.0)*alpha_*gs0_) +1.6*alpha_*gs0_*(1.0 + e_)/sqrtPi ) ); volScalarField K2 ( 4.0*da_*rhoa_*(1.0 + e_)*alpha_*gs0_/(3.0*sqrtPi) - 2.0*K3/3.0 ); volScalarField K4(12.0*(1.0 - sqr(e_))*rhoa_*gs0_/(da_*sqrtPi)); volScalarField trD(tr(D)); volScalarField tr2D(sqr(trD)); volScalarField trD2(tr(D & D)); volScalarField t1(K1*alpha_ + rhoa_); volScalarField l1(-t1*trD); volScalarField l2(sqr(t1)*tr2D); volScalarField l3 ( 4.0 *K4 *max(alpha_, scalar(1e-6)) *(2.0*K3*trD2 + K2*tr2D) ); Theta_ = sqr((l1 + sqrt(l2 + l3))/(2.0*(alpha_ + 1.0e-4)*K4)); } Theta_.max(1.0e-15); Theta_.min(1.0e+3); volScalarField pf ( frictionalStressModel_->frictionalPressure ( alpha_, alphaMinFriction_, alphaMax_, Fr_, eta_, p_ ) ); PsCoeff += pf/(Theta_+Tsmall); PsCoeff.min(1.0e+10); PsCoeff.max(-1.0e+10); // update particle pressure pa_ = PsCoeff*Theta_; // frictional shear stress, Eq. 3.30, p. 52 volScalarField muf ( frictionalStressModel_->muf ( alpha_, alphaMax_, pf, D, phi_ ) ); // add frictional stress mua_ += muf; mua_.min(1.0e+2); mua_.max(0.0); Info<< "kinTheory: max(Theta) = " << max(Theta_).value() << endl; volScalarField ktn(mua_/rhoa_); Info<< "kinTheory: min(nua) = " << min(ktn).value() << ", max(nua) = " << max(ktn).value() << endl; Info<< "kinTheory: min(pa) = " << min(pa_).value() << ", max(pa) = " << max(pa_).value() << endl; }