From a4466eee33ebf3a4ecac3ebe3a7cfecd9520c5ca Mon Sep 17 00:00:00 2001 From: graham Date: Wed, 25 Feb 2009 18:53:29 +0000 Subject: [PATCH] Removed readFields from initialisation constructor in dsmcCloud - fields did not exist on disk but the cloud had non-zero size so readFields in DsmcParcel attempted to read them. Finished initialisation of postions, still to do velocities. --- .../clouds/Templates/DsmcCloud/DsmcCloud.C | 68 ++++++++++++++++++- .../dsmc/clouds/derived/dsmcCloud/dsmcCloud.C | 4 +- 2 files changed, 67 insertions(+), 5 deletions(-) diff --git a/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.C b/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.C index 54ea00f72a..7d487b79c8 100644 --- a/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.C +++ b/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.C @@ -33,8 +33,6 @@ License template void Foam::DsmcCloud::buildConstProps() { - Info<< nl << "Building Constant Properties - PLACEHOLDER." << endl; - Info<< nl << "typeIds found " << typeIdList_ << endl; constProps_.setSize(typeIdList_.size()); @@ -103,7 +101,73 @@ void Foam::DsmcCloud::initialise numberDensities /= nParticle_; + scalar x0 = mesh_.bounds().min().x(); + scalar xR = mesh_.bounds().max().x() - x0; + scalar y0 = mesh_.bounds().min().y(); + scalar yR = mesh_.bounds().max().y() - y0; + + scalar z0 = mesh_.bounds().min().z(); + scalar zR = mesh_.bounds().max().z() - z0; + + forAll(molecules, i) + { + const word& moleculeName(molecules[i]); + + label typeId(findIndex(typeIdList_, moleculeName)); + + if(typeId == -1) + { + FatalErrorIn("Foam::DsmcCloud::initialise") + << "typeId " << moleculeName << "not defined." << nl + << abort(FatalError); + } + + scalar numberDensity = numberDensities[i]; + + scalar spacing = pow(numberDensity,-(1.0/3.0)); + + int ni = label(xR/spacing) + 1; + int nj = label(yR/spacing) + 1; + int nk = label(zR/spacing) + 1; + + vector delta(xR/ni, yR/nj, zR/nk); + + scalar pert = spacing; + + for (int i = 0; i < ni; i++) + { + for (int j = 0; j < nj; j++) + { + for (int k = 0; k < nk; k++) + { + point p + ( + x0 + (i + 0.5)*delta.x(), + y0 + (j + 0.5)*delta.y(), + z0 + (k + 0.5)*delta.z() + ); + + p.x() += pert*(rndGen_.scalar01() - 0.5); + p.y() += pert*(rndGen_.scalar01() - 0.5); + p.z() += pert*(rndGen_.scalar01() - 0.5); + + label cell = mesh_.findCell(p); + + if (cell >= 0) + { + addNewParcel + ( + p, + velocity, + cell, + typeId + ); + } + } + } + } + } } diff --git a/src/lagrangian/dsmc/clouds/derived/dsmcCloud/dsmcCloud.C b/src/lagrangian/dsmc/clouds/derived/dsmcCloud/dsmcCloud.C index aaf0a71367..38a7c827f4 100644 --- a/src/lagrangian/dsmc/clouds/derived/dsmcCloud/dsmcCloud.C +++ b/src/lagrangian/dsmc/clouds/derived/dsmcCloud/dsmcCloud.C @@ -56,9 +56,7 @@ Foam::dsmcCloud::dsmcCloud ) : DsmcCloud(cloudType, mesh, dsmcInitialiseDict) -{ - dsmcParcel::readFields(*this); -} +{} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //