From 8f1a350758a3b75fd1fbf96cede6c9b2aa182951 Mon Sep 17 00:00:00 2001 From: sergio Date: Mon, 6 Sep 2010 11:24:22 +0100 Subject: [PATCH 01/12] ENH: Improvements on kinetic theory models and twoPhaseEulerFoam --- .../multiphase/twoPhaseEulerFoam/UEqns.H | 10 +++ .../multiphase/twoPhaseEulerFoam/kEpsilon.H | 62 ++++++++++++++ .../JohnsonJacksonFrictionalStress.C | 2 +- .../JohnsonJacksonFrictionalStress.H | 2 +- .../Schaeffer/SchaefferFrictionalStress.C | 6 +- .../Schaeffer/SchaefferFrictionalStress.H | 2 +- .../frictionalStressModel.H | 4 +- .../kineticTheoryModel/kineticTheoryModel.C | 85 +++++++++---------- .../kineticTheoryModel/kineticTheoryModel.H | 2 +- .../multiphase/twoPhaseEulerFoam/pEqn.H | 11 ++- .../twoPhaseEulerFoam/twoPhaseEulerFoam.C | 5 -- 11 files changed, 128 insertions(+), 63 deletions(-) create mode 100644 applications/solvers/multiphase/twoPhaseEulerFoam/kEpsilon.H diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/UEqns.H b/applications/solvers/multiphase/twoPhaseEulerFoam/UEqns.H index 9f0417045b..047eeac7e2 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/UEqns.H +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/UEqns.H @@ -10,6 +10,16 @@ fvVectorMatrix UbEqn(Ub, Ub.dimensions()*dimVol/dimTime); ((2.0/3.0)*I)*(sqr(Ct)*k + nuEffa*tr(gradUaT)) - nuEffa*gradUaT ); + if (kineticTheory.on()) + { + kineticTheory.solve(gradUaT); + nuEffa = kineticTheory.mua()/rhoa; + } + else // If not using kinetic theory is using Ct model + { + nuEffa = sqr(Ct)*nutb + nua; + } + if (kineticTheory.on()) { Rca -= ((kineticTheory.lambda()/rhoa)*tr(gradUaT))*tensor(I); diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/kEpsilon.H b/applications/solvers/multiphase/twoPhaseEulerFoam/kEpsilon.H new file mode 100644 index 0000000000..dab75ee07d --- /dev/null +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/kEpsilon.H @@ -0,0 +1,62 @@ +if(turbulence) +{ + if (mesh.changing()) + { + y.correct(); + } + + tmp tgradUb = fvc::grad(Ub); + volScalarField G = 2*nutb*(tgradUb() && dev(symm(tgradUb()))); + tgradUb.clear(); + + #include "wallFunctions.H" + + // Dissipation equation + fvScalarMatrix epsEqn + ( + fvm::ddt(beta, epsilon) + + fvm::div(phib, epsilon) + - fvm::laplacian + ( + alphaEps*nuEffb, epsilon, + "laplacian(DepsilonEff,epsilon)" + ) + == + C1*beta*G*epsilon/k + - fvm::Sp(C2*beta*epsilon/k, epsilon) + ); + + #include "wallDissipation.H" + + epsEqn.relax(); + epsEqn.solve(); + + epsilon.max(dimensionedScalar("zero", epsilon.dimensions(), 1.0e-15)); + + + // Turbulent kinetic energy equation + fvScalarMatrix kEqn + ( + fvm::ddt(beta, k) + + fvm::div(phib, k) + - fvm::laplacian + ( + alphak*nuEffb, k, + "laplacian(DkEff,k)" + ) + == + beta*G + - fvm::Sp(beta*epsilon/k, k) + ); + kEqn.relax(); + kEqn.solve(); + + k.max(dimensionedScalar("zero", k.dimensions(), 1.0e-8)); + + //- Re-calculate turbulence viscosity + nutb = Cmu*sqr(k)/epsilon; + + #include "wallViscosity.H" +} + +nuEffb = nutb + nub; diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/frictionalStressModel/JohnsonJackson/JohnsonJacksonFrictionalStress.C b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/frictionalStressModel/JohnsonJackson/JohnsonJacksonFrictionalStress.C index af326ffd5b..bcd41ac268 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/frictionalStressModel/JohnsonJackson/JohnsonJacksonFrictionalStress.C +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/frictionalStressModel/JohnsonJackson/JohnsonJacksonFrictionalStress.C @@ -102,7 +102,7 @@ Foam::tmp Foam::JohnsonJacksonFrictionalStress::muf const volScalarField& alpha, const dimensionedScalar& alphaMax, const volScalarField& pf, - const volTensorField& D, + const volSymmTensorField& D, const dimensionedScalar& phi ) const { diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/frictionalStressModel/JohnsonJackson/JohnsonJacksonFrictionalStress.H b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/frictionalStressModel/JohnsonJackson/JohnsonJacksonFrictionalStress.H index 08733247c5..d758f2f85c 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/frictionalStressModel/JohnsonJackson/JohnsonJacksonFrictionalStress.H +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/frictionalStressModel/JohnsonJackson/JohnsonJacksonFrictionalStress.H @@ -93,7 +93,7 @@ public: const volScalarField& alpha, const dimensionedScalar& alphaMax, const volScalarField& pf, - const volTensorField& D, + const volSymmTensorField& D, const dimensionedScalar& phi ) const; }; diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/frictionalStressModel/Schaeffer/SchaefferFrictionalStress.C b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/frictionalStressModel/Schaeffer/SchaefferFrictionalStress.C index dbc658f1d4..0f39146345 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/frictionalStressModel/Schaeffer/SchaefferFrictionalStress.C +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/frictionalStressModel/Schaeffer/SchaefferFrictionalStress.C @@ -99,7 +99,7 @@ Foam::tmp Foam::SchaefferFrictionalStress::muf const volScalarField& alpha, const dimensionedScalar& alphaMax, const volScalarField& pf, - const volTensorField& D, + const volSymmTensorField& D, const dimensionedScalar& phi ) const { @@ -124,9 +124,9 @@ Foam::tmp Foam::SchaefferFrictionalStress::muf volScalarField& muff = tmuf(); - forAll(D, celli) + forAll (D, celli) { - if (alpha[celli] > alphaMax.value()-5e-2) + if (alpha[celli] > alphaMax.value() - 5e-2) { muff[celli] = 0.5*pf[celli]*sin(phi.value()) diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/frictionalStressModel/Schaeffer/SchaefferFrictionalStress.H b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/frictionalStressModel/Schaeffer/SchaefferFrictionalStress.H index e9b0c4efd7..89b0e25ded 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/frictionalStressModel/Schaeffer/SchaefferFrictionalStress.H +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/frictionalStressModel/Schaeffer/SchaefferFrictionalStress.H @@ -93,7 +93,7 @@ public: const volScalarField& alpha, const dimensionedScalar& alphaMax, const volScalarField& pf, - const volTensorField& D, + const volSymmTensorField& D, const dimensionedScalar& phi ) const; }; diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/frictionalStressModel/frictionalStressModel/frictionalStressModel.H b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/frictionalStressModel/frictionalStressModel/frictionalStressModel.H index 8176e6aac2..b496ee9cf6 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/frictionalStressModel/frictionalStressModel/frictionalStressModel.H +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/frictionalStressModel/frictionalStressModel/frictionalStressModel.H @@ -48,7 +48,7 @@ namespace Foam class frictionalStressModel { - // Private Member Functions + // Private member functions //- Disallow default bitwise copy construct frictionalStressModel(const frictionalStressModel&); @@ -127,7 +127,7 @@ public: const volScalarField& alpha, const dimensionedScalar& alphaMax, const volScalarField& pf, - const volTensorField& D, + const volSymmTensorField& D, const dimensionedScalar& phi ) const = 0; }; diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C index abdd6080be..6354144176 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C @@ -56,12 +56,13 @@ Foam::kineticTheoryModel::kineticTheoryModel "kineticTheoryProperties", Ua_.time().constant(), Ua_.mesh(), - IOobject::MUST_READ_IF_MODIFIED, + IOobject::MUST_READ, IOobject::NO_WRITE ) ), kineticTheory_(kineticTheoryProperties_.lookup("kineticTheory")), equilibrium_(kineticTheoryProperties_.lookup("equilibrium")), + viscosityModel_ ( kineticTheoryModels::viscosityModel::New @@ -192,24 +193,19 @@ Foam::kineticTheoryModel::~kineticTheoryModel() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::kineticTheoryModel::solve() +void Foam::kineticTheoryModel::solve(const volTensorField& gradUat) { if (!kineticTheory_) { return; } - word scheme("div(phi,Theta)"); - - volScalarField alpha = alpha_; - alpha.max(1.0e-6); - const scalar sqrtPi = sqrt(constant::mathematical::pi); + const scalar sqrtPi = sqrt(mathematicalConstant::pi); surfaceScalarField phi = 1.5*rhoa_*phia_*fvc::interpolate(alpha_); - volTensorField dU = fvc::grad(Ua_); - volTensorField dUT = dU.T(); - volTensorField D = 0.5*(dU + dUT); + 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 @@ -220,45 +216,52 @@ void Foam::kineticTheoryModel::solve() // 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(alpha, alphaMax_-1.0e-2), alphaMax_); + gs0_ = radialModel_->g0 + ( + min(max(alpha_, 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_ ); + 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), + dimensionSet(0 , 2 ,-2 ,0 , 0, 0, 0), 1.0e-6 ); dimensionedScalar TsmallSqrt = sqrt(Tsmall); volScalarField ThetaSqrt = sqrt(Theta_); - // '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_); - // dissipation (Eq. 3.24, p.50) volScalarField gammaCoeff = - 12.0*(1.0 - e_*e_)*sqr(alpha)*rhoa_*gs0_*(1.0/da_) - *ThetaSqrt/sqrtPi; + 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) - /(alpha*rhoa_*sqrtPi*(ThetaSqrt + TsmallSqrt)); + /(max(alpha_, 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 - volTensorField tau = 2.0*mua_*D + (lambda_ - (2.0/3.0)*mua_)*tr(D)*I; + volSymmTensorField tau = 2.0*mua_*D + (lambda_ - (2.0/3.0)*mua_)*tr(D)*I; if (!equilibrium_) { @@ -268,8 +271,8 @@ void Foam::kineticTheoryModel::solve() // wrong sign infront of laplacian fvScalarMatrix ThetaEqn ( - fvm::ddt(1.5*alpha*rhoa_, Theta_) - + fvm::div(phi, Theta_, scheme) + fvm::ddt(1.5*alpha_*rhoa_, Theta_) + + fvm::div(phi, Theta_, "div(phi,Theta)") == fvm::SuSp(-((PsCoeff*I) && dU), Theta_) + (tau && dU) @@ -290,33 +293,31 @@ void Foam::kineticTheoryModel::solve() 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 + *(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; + 4.0*da_*rhoa_*(1.0 + e_)*alpha_*gs0_/(3.0*sqrtPi) - 2.0*K3/3.0; - volScalarField K4 = 12.0*(1.0 - e_*e_)*rhoa_*gs0_/(da_*sqrtPi); + volScalarField K4 = 12.0*(1.0 - sqr(e_))*rhoa_*gs0_/(da_*sqrtPi); volScalarField trD = tr(D); - volTensorField D2 = D & D; - volScalarField tr2D = trD*trD; - volScalarField trD2 = tr(D2); + volScalarField tr2D = sqr(trD); + volScalarField trD2 = tr(D & D); - volScalarField t1 = K1*alpha + rhoa_; + volScalarField t1 = K1*alpha_ + rhoa_; volScalarField l1 = -t1*trD; volScalarField l2 = sqr(t1)*tr2D; - volScalarField l3 = 4.0*K4*alpha*(2.0*K3*trD2 + K2*tr2D); + volScalarField l3 = 4.0*K4*max(alpha_, 1e-6)*(2.0*K3*trD2 + K2*tr2D); - Theta_ = sqr((l1 + sqrt(l2 + l3))/(2.0*(alpha + 1.0e-4)*K4)); + 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 + volScalarField pf = frictionalStressModel_->frictionalPressure ( alpha_, alphaMinFriction_, @@ -344,13 +345,11 @@ void Foam::kineticTheoryModel::solve() phi_ ); - // add frictional stress for alpha > alphaMinFriction - mua_ = viscosityModel_->mua(alpha, Theta_, gs0_, rhoa_, da_, e_) + muf; + // add frictional stress + mua_ += muf; mua_.min(1.0e+2); mua_.max(0.0); - lambda_ = (4.0/3.0)*sqr(alpha_)*rhoa_*da_*gs0_*(1.0 + e_)*ThetaSqrt/sqrtPi; - Info<< "kinTheory: max(Theta) = " << max(Theta_).value() << endl; volScalarField ktn = mua_/rhoa_; diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.H b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.H index 2659d8c1d6..2863c2d038 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.H +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.H @@ -156,7 +156,7 @@ public: // Member Functions - void solve(); + void solve(const volTensorField& gradUat); bool on() const { diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/pEqn.H b/applications/solvers/multiphase/twoPhaseEulerFoam/pEqn.H index b2bc0d817d..09d8f506ec 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/pEqn.H +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/pEqn.H @@ -5,6 +5,9 @@ volScalarField rUaA = 1.0/UaEqn.A(); volScalarField rUbA = 1.0/UbEqn.A(); + phia == (fvc::interpolate(Ua) & mesh.Sf()); + phib == (fvc::interpolate(Ub) & mesh.Sf()); + rUaAf = fvc::interpolate(rUaA); surfaceScalarField rUbAf = fvc::interpolate(rUbA); @@ -45,13 +48,9 @@ phi = alphaf*phia + betaf*phib; - surfaceScalarField Dp - ( - "(rho*(1|A(U)))", - alphaf*rUaAf/rhoa + betaf*rUbAf/rhob - ); + surfaceScalarField Dp("(rho*(1|A(U)))", alphaf*rUaAf/rhoa + betaf*rUbAf/rhob); - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { fvScalarMatrix pEqn ( diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseEulerFoam.C b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseEulerFoam.C index b3e0eb0009..bd0310765d 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseEulerFoam.C +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseEulerFoam.C @@ -92,11 +92,6 @@ int main(int argc, char *argv[]) #include "kEpsilon.H" - if (kineticTheory.on()) - { - kineticTheory.solve(); - nuEffa += kineticTheory.mua()/rhoa; - } #include "write.H" Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" From 7343f95afb06d08b4e933f530b5125540cb0e88f Mon Sep 17 00:00:00 2001 From: sergio Date: Mon, 6 Sep 2010 11:28:26 +0100 Subject: [PATCH 02/12] STY: line exceeding 80 characthers. --- applications/solvers/multiphase/twoPhaseEulerFoam/pEqn.H | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/pEqn.H b/applications/solvers/multiphase/twoPhaseEulerFoam/pEqn.H index 09d8f506ec..39a133d39b 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/pEqn.H +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/pEqn.H @@ -48,7 +48,10 @@ phi = alphaf*phia + betaf*phib; - surfaceScalarField Dp("(rho*(1|A(U)))", alphaf*rUaAf/rhoa + betaf*rUbAf/rhob); + surfaceScalarField Dp + ( + "(rho*(1|A(U)))", alphaf*rUaAf/rhoa + betaf*rUbAf/rhob + ); for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { From 44c71d5537d9571b2b5366dc2662ca99e10612ac Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 6 Sep 2010 12:26:10 +0100 Subject: [PATCH 03/12] BUG: having patchnames with uncached mesh --- .../PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C index a73b46621e..54a1ac778a 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C @@ -620,6 +620,11 @@ double* Foam::vtkPV3Foam::findTimes(int& nTimeSteps) void Foam::vtkPV3Foam::renderPatchNames(vtkRenderer* renderer, const bool show) { + if (!meshPtr_) + { + return; + } + // always remove old actors first forAll(patchTextActorsPtrs_, patchI) From 2285298921e650dd29d42a88ca79ab73cb3f8b0d Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 6 Sep 2010 12:26:25 +0100 Subject: [PATCH 04/12] STYLE: README : misspelled date --- .../incompressible/pimpleFoam/t-junction-with-fan/README.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/incompressible/pimpleFoam/t-junction-with-fan/README.txt b/tutorials/incompressible/pimpleFoam/t-junction-with-fan/README.txt index fd3f970be5..0ef40d8110 100644 --- a/tutorials/incompressible/pimpleFoam/t-junction-with-fan/README.txt +++ b/tutorials/incompressible/pimpleFoam/t-junction-with-fan/README.txt @@ -1,3 +1,3 @@ -300-04-16 T-junction with baffles and fan. +2010-04-16 T-junction with baffles and fan. Inlet on left, one outlet at bottom, one at top. To test multiple outlets. From fee00dbef07afa80b663a59f6ba322c53fb55be8 Mon Sep 17 00:00:00 2001 From: sergio Date: Mon, 6 Sep 2010 14:29:41 +0100 Subject: [PATCH 05/12] BUG : constant::mathematical::pi --- .../kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C index 6354144176..ee2300d91e 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C @@ -200,7 +200,7 @@ void Foam::kineticTheoryModel::solve(const volTensorField& gradUat) return; } - const scalar sqrtPi = sqrt(mathematicalConstant::pi); + const scalar sqrtPi = sqrt(constant::mathematical::pi); surfaceScalarField phi = 1.5*rhoa_*phia_*fvc::interpolate(alpha_); From 97dff2650ee9598156560daf458b7a57d7205851 Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 6 Sep 2010 17:02:35 +0100 Subject: [PATCH 06/12] ENH: foamToVTK : have surface fields on faceZones --- .../dataConversion/foamToVTK/Make/files | 3 +- .../dataConversion/foamToVTK/foamToVTK.C | 65 ++++++-- .../{writePatchGeom.C => surfaceMeshWriter.C} | 61 ++++---- .../foamToVTK/surfaceMeshWriter.H | 141 ++++++++++++++++++ .../foamToVTK/surfaceMeshWriterTemplates.C | 84 +++++++++++ .../dataConversion/foamToVTK/writePatchGeom.H | 62 -------- 6 files changed, 309 insertions(+), 107 deletions(-) rename applications/utilities/postProcessing/dataConversion/foamToVTK/{writePatchGeom.C => surfaceMeshWriter.C} (59%) create mode 100644 applications/utilities/postProcessing/dataConversion/foamToVTK/surfaceMeshWriter.H create mode 100644 applications/utilities/postProcessing/dataConversion/foamToVTK/surfaceMeshWriterTemplates.C delete mode 100644 applications/utilities/postProcessing/dataConversion/foamToVTK/writePatchGeom.H diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/Make/files b/applications/utilities/postProcessing/dataConversion/foamToVTK/Make/files index 23c2c6738c..2c10cfe303 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/Make/files +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/Make/files @@ -1,9 +1,10 @@ +surfaceMeshWriter.C + foamToVTK.C internalWriter.C lagrangianWriter.C patchWriter.C writeFuns.C -writePatchGeom.C writeFaceSet.C writePointSet.C writeSurfFields.C diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C index 2b82a234ba..272307588a 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C @@ -157,7 +157,7 @@ Note #include "writeFaceSet.H" #include "writePointSet.H" -#include "writePatchGeom.H" +#include "surfaceMeshWriter.H" #include "writeSurfFields.H" @@ -963,20 +963,42 @@ int main(int argc, char *argv[]) if (doFaceZones) { + PtrList ssf; + readFields + ( + vMesh, + vMesh.baseMesh(), + objects, + selectedFields, + ssf + ); + print(" surfScalarFields :", Info, ssf); + + PtrList svf; + readFields + ( + vMesh, + vMesh.baseMesh(), + objects, + selectedFields, + svf + ); + print(" surfVectorFields :", Info, svf); + const faceZoneMesh& zones = mesh.faceZones(); forAll(zones, zoneI) { - const faceZone& pp = zones[zoneI]; + const faceZone& fz = zones[zoneI]; - mkDir(fvPath/pp.name()); + mkDir(fvPath/fz.name()); fileName patchFileName; if (vMesh.useSubMesh()) { patchFileName = - fvPath/pp.name()/cellSetName + fvPath/fz.name()/cellSetName + "_" + timeDesc + ".vtk"; @@ -984,7 +1006,7 @@ int main(int argc, char *argv[]) else { patchFileName = - fvPath/pp.name()/pp.name() + fvPath/fz.name()/fz.name() + "_" + timeDesc + ".vtk"; @@ -992,18 +1014,31 @@ int main(int argc, char *argv[]) Info<< " FaceZone : " << patchFileName << endl; - std::ofstream ostr(patchFileName.c_str()); - - writeFuns::writeHeader(ostr, binary, pp.name()); - ostr<< "DATASET POLYDATA" << std::endl; - - writePatchGeom + indirectPrimitivePatch pp ( - binary, - pp().localFaces(), - pp().localPoints(), - ostr + IndirectList(mesh.faces(), fz), + mesh.points() ); + + surfaceMeshWriter writer + ( + vMesh, + binary, + pp, + fz.name(), + patchFileName + ); + + // Number of fields + writeFuns::writeCellDataHeader + ( + writer.os(), + pp.size(), + ssf.size()+svf.size() + ); + + writer.write(ssf); + writer.write(svf); } } diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writePatchGeom.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/surfaceMeshWriter.C similarity index 59% rename from applications/utilities/postProcessing/dataConversion/foamToVTK/writePatchGeom.C rename to applications/utilities/postProcessing/dataConversion/foamToVTK/surfaceMeshWriter.C index 0dd2bd9200..d947eb3de3 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writePatchGeom.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/surfaceMeshWriter.C @@ -23,60 +23,63 @@ License \*---------------------------------------------------------------------------*/ -#include "writePatchGeom.H" -#include "OFstream.H" -#include "floatScalar.H" +#include "surfaceMeshWriter.H" #include "writeFuns.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -namespace Foam -{ - -// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // - -void writePatchGeom +Foam::surfaceMeshWriter::surfaceMeshWriter ( + const vtkMesh& vMesh, const bool binary, - const faceList& faces, - const pointField& points, - std::ofstream& ostr + const indirectPrimitivePatch& pp, + const word& name, + const fileName& fName ) +: + vMesh_(vMesh), + binary_(binary), + pp_(pp), + fName_(fName), + os_(fName.c_str()) { - ostr<< "POINTS " << points.size() << " float" << std::endl; - - DynamicList ptField(3*points.size()); - - writeFuns::insert(points, ptField); - - writeFuns::write(ostr, binary, ptField); + // Write header + writeFuns::writeHeader(os_, binary_, name); + os_ << "DATASET POLYDATA" << std::endl; + // Write topology label nFaceVerts = 0; - forAll(faces, faceI) + forAll(pp, faceI) { - nFaceVerts += faces[faceI].size() + 1; + nFaceVerts += pp[faceI].size() + 1; } - ostr<< "POLYGONS " << faces.size() << ' ' << nFaceVerts << std::endl; + os_ << "POINTS " << pp.nPoints() << " float" << std::endl; + + DynamicList ptField(3*pp.nPoints()); + writeFuns::insert(pp.localPoints(), ptField); + writeFuns::write(os_, binary, ptField); + + + os_ << "POLYGONS " << pp.size() << ' ' << nFaceVerts << std::endl; DynamicList