From 239b954ad31b661f9a934d93dc84cea52e5514fd Mon Sep 17 00:00:00 2001 From: graham Date: Thu, 16 Apr 2009 19:18:15 +0100 Subject: [PATCH] Changing FreeStream to create inflow on all patches of type patch. Implemented Bird eqn 4.22 for the number flux and eqn 12.5 for the velocity distibution. Drawing T and U for the FreeStream from the boundaryT and boundaryU fields. --- .../discreteMethods/dsmc/dsmcFoam/dsmcFoam.C | 2 +- .../clouds/Templates/DsmcCloud/DsmcCloud.C | 45 ++- .../clouds/Templates/DsmcCloud/DsmcCloud.H | 17 + .../clouds/Templates/DsmcCloud/DsmcCloudI.H | 34 ++ .../FreeStream/FreeStream.C | 370 ++++++++++++------ .../FreeStream/FreeStream.H | 27 +- 6 files changed, 335 insertions(+), 160 deletions(-) diff --git a/applications/solvers/discreteMethods/dsmc/dsmcFoam/dsmcFoam.C b/applications/solvers/discreteMethods/dsmc/dsmcFoam/dsmcFoam.C index 1ea52cc6aa..cb068960e8 100644 --- a/applications/solvers/discreteMethods/dsmc/dsmcFoam/dsmcFoam.C +++ b/applications/solvers/discreteMethods/dsmc/dsmcFoam/dsmcFoam.C @@ -91,7 +91,7 @@ int main(int argc, char *argv[]) runTime.write(); - Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + Info<< nl << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } diff --git a/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.C b/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.C index 42a1ba7ea6..53177e9afe 100644 --- a/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.C +++ b/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.C @@ -37,6 +37,7 @@ Foam::scalar Foam::DsmcCloud::kb = 1.380650277e-23; template Foam::scalar Foam::DsmcCloud::Tref = 273; + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // template @@ -625,6 +626,13 @@ Foam::DsmcCloud::DsmcCloud buildConstProps(); buildCellOccupancy(); + + // Initialise the collision selection remainder to a random value between 0 + // and 1. + forAll(collisionSelectionRemainder_, i) + { + collisionSelectionRemainder_[i] = rndGen_.scalar01(); + } } @@ -813,22 +821,27 @@ void Foam::DsmcCloud::info() const Info<< "Cloud name: " << this->name() << nl << " Number of dsmc particles = " - << nDsmcParticles << nl - << " Number of molecules = " - << nMol << nl - << " Mass in system = " - << returnReduce(massInSystem(), sumOp()) << nl - << " Average linear momentum = " - << linearMomentum/nMol << nl - << " |Average linear momentum| = " - << mag(linearMomentum)/nMol << nl - << " Average linear kinetic energy = " - << linearKineticEnergy/nMol << nl - << " Average internal energy = " - << internalEnergy/nMol << nl - << " Average total energy = " - << (internalEnergy + linearKineticEnergy)/nMol << nl + << nDsmcParticles << endl; + + if (nDsmcParticles) + { + Info<< " Number of molecules = " + << nMol << nl + << " Mass in system = " + << returnReduce(massInSystem(), sumOp()) << nl + << " Average linear momentum = " + << linearMomentum/nMol << nl + << " |Average linear momentum| = " + << mag(linearMomentum)/nMol << nl + << " Average linear kinetic energy = " + << linearKineticEnergy/nMol << nl + << " Average internal energy = " + << internalEnergy/nMol << nl + << " Average total energy = " + << (internalEnergy + linearKineticEnergy)/nMol + << endl; + } } @@ -874,7 +887,7 @@ Foam::scalar Foam::DsmcCloud::equipartitionInternalEnergy scalar energyRatio; - scalar P; + scalar P = -1; do { diff --git a/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.H b/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.H index b246b04990..20bed1ee7b 100644 --- a/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.H +++ b/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.H @@ -299,6 +299,12 @@ public: scalar mass ) const; + inline scalarField maxwellianAverageSpeed + ( + scalarField temperature, + scalar mass + ) const; + //- RMS particle speed inline scalar maxwellianRMSSpeed ( @@ -306,6 +312,12 @@ public: scalar mass ) const; + inline scalarField maxwellianRMSSpeed + ( + scalarField temperature, + scalar mass + ) const; + //- Most probable speed inline scalar maxwellianMostProbableSpeed ( @@ -313,6 +325,11 @@ public: scalar mass ) const; + inline scalarField maxwellianMostProbableSpeed + ( + scalarField temperature, + scalar mass + ) const; // Sub-models diff --git a/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloudI.H b/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloudI.H index ede1e3559b..d39de4954f 100644 --- a/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloudI.H +++ b/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloudI.H @@ -302,6 +302,17 @@ inline Foam::scalar Foam::DsmcCloud::maxwellianAverageSpeed } +template +inline Foam::scalarField Foam::DsmcCloud::maxwellianAverageSpeed +( + scalarField temperature, + scalar mass +) const +{ + return 2.0*sqrt(2.0*kb*temperature/(mathematicalConstant::pi*mass)); +} + + template inline Foam::scalar Foam::DsmcCloud::maxwellianRMSSpeed ( @@ -313,6 +324,17 @@ inline Foam::scalar Foam::DsmcCloud::maxwellianRMSSpeed } +template +inline Foam::scalarField Foam::DsmcCloud::maxwellianRMSSpeed +( + scalarField temperature, + scalar mass +) const +{ + return sqrt(3.0*kb*temperature/mass); +} + + template inline Foam::scalar Foam::DsmcCloud::maxwellianMostProbableSpeed @@ -325,6 +347,18 @@ Foam::DsmcCloud::maxwellianMostProbableSpeed } +template +inline Foam::scalarField +Foam::DsmcCloud::maxwellianMostProbableSpeed +( + scalarField temperature, + scalar mass +) const +{ + return sqrt(2.0*kb*temperature/mass); +} + + template inline const Foam::tmp Foam::DsmcCloud::rhoN() const diff --git a/src/lagrangian/dsmc/submodels/InflowBoundaryModel/FreeStream/FreeStream.C b/src/lagrangian/dsmc/submodels/InflowBoundaryModel/FreeStream/FreeStream.C index 02ed6d28b5..368597a4fd 100644 --- a/src/lagrangian/dsmc/submodels/InflowBoundaryModel/FreeStream/FreeStream.C +++ b/src/lagrangian/dsmc/submodels/InflowBoundaryModel/FreeStream/FreeStream.C @@ -36,32 +36,27 @@ Foam::FreeStream::FreeStream ) : InflowBoundaryModel(dict, cloud, typeName), - patchIndex_(), - temperature_(readScalar(this->coeffDict().lookup("temperature"))), - velocity_(this->coeffDict().lookup("velocity")), + patches_(), moleculeTypeIds_(), numberDensities_(), particleFluxAccumulators_() { - word patchName = this->coeffDict().lookup("patch"); + // Identify which patches to use - patchIndex_ = cloud.mesh().boundaryMesh().findPatchID(patchName); + DynamicList