diff --git a/src/OpenFOAM/db/functionObjects/outputFilterOutputControl/outputFilterOutputControl.C b/src/OpenFOAM/db/functionObjects/outputFilterOutputControl/outputFilterOutputControl.C index 34b9da0da1..e282ff8c21 100644 --- a/src/OpenFOAM/db/functionObjects/outputFilterOutputControl/outputFilterOutputControl.C +++ b/src/OpenFOAM/db/functionObjects/outputFilterOutputControl/outputFilterOutputControl.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -30,11 +30,8 @@ License namespace Foam { template<> - const char* Foam::NamedEnum - < - Foam::outputFilterOutputControl::outputControls, - 2 - >::names[] = + const char* NamedEnum:: + names[] = { "timeStep", "outputTime" diff --git a/src/fieldSources/derived/fixedTemperatureSource/fixedTemperatureSource.C b/src/fieldSources/derived/fixedTemperatureSource/fixedTemperatureSource.C index bef68f3c4e..34db0a7e3e 100644 --- a/src/fieldSources/derived/fixedTemperatureSource/fixedTemperatureSource.C +++ b/src/fieldSources/derived/fixedTemperatureSource/fixedTemperatureSource.C @@ -41,8 +41,18 @@ namespace Foam fixedTemperatureSource, dictionary ); + + template<> + const char* NamedEnum::names[] = + { + "constant", + "lookup" + }; } +const Foam::NamedEnum + Foam::fixedTemperatureSource::temperatureModeNames_; + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -55,8 +65,29 @@ Foam::fixedTemperatureSource::fixedTemperatureSource ) : basicSource(name, modelType, dict, mesh), - T_(readScalar(coeffs_.lookup("temperature"))) + mode_(temperatureModeNames_.read(coeffs_.lookup("mode"))), + Tconstant_(0.0), + TName_("T") { + switch (mode_) + { + case tmConstant: + { + coeffs_.lookup("temperature") >> Tconstant_; + break; + } + case tmLookup: + { + TName_ = coeffs_.lookupOrDefault("TName", "T"); + break; + } + default: + { + // error handling done by NamedEnum + } + } + + fieldNames_.setSize(1, "energy"); applied_.setSize(1, false); } @@ -81,8 +112,31 @@ void Foam::fixedTemperatureSource::setValue if (eqn.psi().name() == thermo.he().name()) { - const scalarField Tfield(cells_.size(), T_); - eqn.setValues(cells_, thermo.he(thermo.p(), Tfield, cells_)); + switch (mode_) + { + case tmConstant: + { + scalarField Tconst(cells_.size(), Tconstant_); + eqn.setValues(cells_, thermo.he(thermo.p(), Tconst, cells_)); + + break; + } + case tmLookup: + { + const volScalarField& T = + mesh().lookupObject(TName_); + + scalarField Tlookup(T, cells_); + eqn.setValues(cells_, thermo.he(thermo.p(), Tlookup, cells_)); + + break; + } + default: + { + // error handling done by NamedEnum + } + } + } } @@ -98,7 +152,8 @@ bool Foam::fixedTemperatureSource::read(const dictionary& dict) { if (basicSource::read(dict)) { - coeffs_.readIfPresent("T", T_); + coeffs_.readIfPresent("temperature", Tconstant_); + coeffs_.readIfPresent("TName", TName_); return true; } diff --git a/src/fieldSources/derived/fixedTemperatureSource/fixedTemperatureSource.H b/src/fieldSources/derived/fixedTemperatureSource/fixedTemperatureSource.H index 4281a38e2c..3aefdb5645 100644 --- a/src/fieldSources/derived/fixedTemperatureSource/fixedTemperatureSource.H +++ b/src/fieldSources/derived/fixedTemperatureSource/fixedTemperatureSource.H @@ -33,7 +33,13 @@ Description fixedTemperatureSourceCoeffs { fieldNames (h e hs); // names of fields to apply source + mode constant; // constant or lookup + + // constant option temperature 500; // fixed temperature [K] + + // loolup option + // TName T; // optional temperature field name } @@ -46,6 +52,7 @@ SourceFiles #define fixedTemperatureSource_H #include "basicSource.H" +#include "NamedEnum.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -61,12 +68,32 @@ class fixedTemperatureSource public basicSource { +public: + + //- Temperature mode + enum temperatureMode + { + tmConstant, + tmLookup + }; + + + //- String representation of temperatureMode enums + static const NamedEnum temperatureModeNames_; + + protected: // Protected data - //- Fixed temperature [K] - scalar T_; + //- Operation mode + temperatureMode mode_; + + //- Constant temperature [K] + scalar Tconstant_; + + //- Temperature field name + word TName_; private: diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.C index 9ef4be21a4..f3a7615b4a 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.C @@ -63,7 +63,19 @@ Foam::fixedJumpFvPatchField::fixedJumpFvPatchField : jumpCyclicFvPatchField(p, iF), jump_("jump", dict, p.size()) -{} +{ + if (dict.found("value")) + { + fvPatchField::operator= + ( + Field("value", dict, p.size()) + ); + } + else + { + this->evaluate(Pstream::blocking); + } +} template diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedJumpAMI/fixedJumpAMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedJumpAMI/fixedJumpAMIFvPatchField.C index 4c3290cf2d..ad6fb925ae 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedJumpAMI/fixedJumpAMIFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedJumpAMI/fixedJumpAMIFvPatchField.C @@ -63,7 +63,19 @@ Foam::fixedJumpAMIFvPatchField::fixedJumpAMIFvPatchField : jumpCyclicAMIFvPatchField(p, iF), jump_("jump", dict, p.size()) -{} +{ + if (dict.found("value")) + { + fvPatchField::operator= + ( + Field("value", dict, p.size()) + ); + } + else + { + this->evaluate(Pstream::blocking); + } +} template diff --git a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C index fbfc5eb96a..29590cc051 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C @@ -53,7 +53,7 @@ timeVaryingMappedFixedValueFvPatchField endSampleTime_(-1), endSampledValues_(0), endAverage_(pTraits::zero), - offSet_() + offset_() {} @@ -79,7 +79,7 @@ timeVaryingMappedFixedValueFvPatchField endSampleTime_(-1), endSampledValues_(0), endAverage_(pTraits::zero), - offSet_() + offset_() {} @@ -104,7 +104,7 @@ timeVaryingMappedFixedValueFvPatchField endSampleTime_(-1), endSampledValues_(0), endAverage_(pTraits::zero), - offSet_(DataEntry::New("offSet", dict)) + offset_(DataEntry::New("offset", dict)) { dict.readIfPresent("fieldTableName", fieldTableName_); @@ -138,7 +138,7 @@ timeVaryingMappedFixedValueFvPatchField endSampleTime_(ptf.endSampleTime_), endSampledValues_(ptf.endSampledValues_), endAverage_(ptf.endAverage_), - offSet_(ptf.offSet_().clone().ptr()) + offset_(ptf.offset_().clone().ptr()) {} @@ -163,7 +163,7 @@ timeVaryingMappedFixedValueFvPatchField endSampleTime_(ptf.endSampleTime_), endSampledValues_(ptf.endSampledValues_), endAverage_(ptf.endAverage_), - offSet_(ptf.offSet_().clone().ptr()) + offset_(ptf.offset_().clone().ptr()) {} @@ -487,7 +487,7 @@ void timeVaryingMappedFixedValueFvPatchField::updateCoeffs() // apply offset to mapped values const scalar t = this->db().time().timeOutputValue(); - this->operator==(*this + offSet_->value(t)); + this->operator==(*this + offset_->value(t)); if (debug) { @@ -512,7 +512,7 @@ void timeVaryingMappedFixedValueFvPatchField::write(Ostream& os) const << token::END_STATEMENT << nl; } - offSet_->writeData(os); + offset_->writeData(os); this->writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.H index 01e61301eb..aec6c322b9 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.H @@ -132,7 +132,7 @@ class timeVaryingMappedFixedValueFvPatchField Type endAverage_; //- Time varying offset values to interpolated data - autoPtr > offSet_; + autoPtr > offset_; public: diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformJumpAMI/uniformJumpAMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/uniformJumpAMI/uniformJumpAMIFvPatchField.C index 06f4e3c134..0670119ab0 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformJumpAMI/uniformJumpAMIFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformJumpAMI/uniformJumpAMIFvPatchField.C @@ -73,6 +73,10 @@ Foam::uniformJumpAMIFvPatchField::uniformJumpAMIFvPatchField { fvPatchField::operator=(Field("value", dict, p.size())); } + else + { + this->evaluate(Pstream::blocking); + } } diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C index 58217adbf5..7ec52b1ee8 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C @@ -326,7 +326,7 @@ bool Foam::KinematicParcel::move p.age() += dt; - td.cloud().functions().postMove(p, cellI, dt); + td.cloud().functions().postMove(p, cellI, dt, td.keepParticle); } return td.keepParticle; @@ -340,7 +340,7 @@ void Foam::KinematicParcel::hitFace(TrackData& td) typename TrackData::cloudType::parcelType& p = static_cast(*this); - td.cloud().functions().postFace(p, p.face()); + td.cloud().functions().postFace(p, p.face(), td.keepParticle); } @@ -364,7 +364,14 @@ bool Foam::KinematicParcel::hitPatch static_cast(*this); // Invoke post-processing model - td.cloud().functions().postPatch(p, pp, trackFraction, tetIs); + td.cloud().functions().postPatch + ( + p, + pp, + trackFraction, + tetIs, + td.keepParticle + ); // Invoke surface film model if (td.cloud().surfaceFilm().transferParcel(p, pp, td.keepParticle)) diff --git a/src/lagrangian/intermediate/parcels/include/makeParcelCloudFunctionObjects.H b/src/lagrangian/intermediate/parcels/include/makeParcelCloudFunctionObjects.H index 9e19beae34..783878f480 100644 --- a/src/lagrangian/intermediate/parcels/include/makeParcelCloudFunctionObjects.H +++ b/src/lagrangian/intermediate/parcels/include/makeParcelCloudFunctionObjects.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,6 +29,7 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #include "FacePostProcessing.H" +#include "ParticleCollector.H" #include "ParticleErosion.H" #include "ParticleTracks.H" #include "ParticleTrap.H" @@ -42,6 +43,7 @@ License makeCloudFunctionObject(CloudType); \ \ makeCloudFunctionObjectType(FacePostProcessing, CloudType); \ + makeCloudFunctionObjectType(ParticleCollector, CloudType); \ makeCloudFunctionObjectType(ParticleErosion, CloudType); \ makeCloudFunctionObjectType(ParticleTracks, CloudType); \ makeCloudFunctionObjectType(ParticleTrap, CloudType); \ diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObject/CloudFunctionObject.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObject/CloudFunctionObject.C index dbc359ae9a..5a208a4ca8 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObject/CloudFunctionObject.C +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObject/CloudFunctionObject.C @@ -96,7 +96,8 @@ void Foam::CloudFunctionObject::postMove ( const typename CloudType::parcelType&, const label, - const scalar + const scalar, + bool& ) { // do nothing @@ -109,7 +110,8 @@ void Foam::CloudFunctionObject::postPatch const typename CloudType::parcelType&, const polyPatch&, const scalar, - const tetIndices& + const tetIndices&, + bool& ) { // do nothing @@ -120,7 +122,8 @@ template void Foam::CloudFunctionObject::postFace ( const typename CloudType::parcelType&, - const label + const label, + bool& ) { // do nothing diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObject/CloudFunctionObject.H b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObject/CloudFunctionObject.H index 5baf0f7ae9..976fd3867f 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObject/CloudFunctionObject.H +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObject/CloudFunctionObject.H @@ -46,6 +46,9 @@ SourceFiles namespace Foam { +class polyPatch; +class tetIndices; + /*---------------------------------------------------------------------------*\ Class CloudFunctionObject Declaration \*---------------------------------------------------------------------------*/ @@ -134,7 +137,8 @@ public: ( const typename CloudType::parcelType& p, const label cellI, - const scalar dt + const scalar dt, + bool& keepParticle ); //- Post-patch hook @@ -143,14 +147,16 @@ public: const typename CloudType::parcelType& p, const polyPatch& pp, const scalar trackFraction, - const tetIndices& testIs + const tetIndices& testIs, + bool& keepParticle ); //- Post-face hook virtual void postFace ( const typename CloudType::parcelType& p, - const label faceI + const label faceI, + bool& keepParticle ); }; diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObjectList/CloudFunctionObjectList.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObjectList/CloudFunctionObjectList.C index 2f97468e36..e0d57b6057 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObjectList/CloudFunctionObjectList.C +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObjectList/CloudFunctionObjectList.C @@ -132,12 +132,18 @@ void Foam::CloudFunctionObjectList::postMove ( const typename CloudType::parcelType& p, const label cellI, - const scalar dt + const scalar dt, + bool& keepParticle ) { forAll(*this, i) { - this->operator[](i).postMove(p, cellI, dt); + this->operator[](i).postMove(p, cellI, dt, keepParticle); + + if (!keepParticle) + { + return; + } } } @@ -148,12 +154,25 @@ void Foam::CloudFunctionObjectList::postPatch const typename CloudType::parcelType& p, const polyPatch& pp, const scalar trackFraction, - const tetIndices& tetIs + const tetIndices& tetIs, + bool& keepParticle ) { forAll(*this, i) { - this->operator[](i).postPatch(p, pp, trackFraction, tetIs); + this->operator[](i).postPatch + ( + p, + pp, + trackFraction, + tetIs, + keepParticle + ); + + if (!keepParticle) + { + return; + } } } @@ -162,12 +181,18 @@ template void Foam::CloudFunctionObjectList::postFace ( const typename CloudType::parcelType& p, - const label faceI + const label faceI, + bool& keepParticle ) { forAll(*this, i) { - this->operator[](i).postFace(p, faceI); + this->operator[](i).postFace(p, faceI, keepParticle); + + if (!keepParticle) + { + return; + } } } diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObjectList/CloudFunctionObjectList.H b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObjectList/CloudFunctionObjectList.H index 5daeab9f29..de9c3afc02 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObjectList/CloudFunctionObjectList.H +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObjectList/CloudFunctionObjectList.H @@ -114,7 +114,8 @@ public: ( const typename CloudType::parcelType& p, const label cellI, - const scalar dt + const scalar dt, + bool& keepParticle ); //- Post-patch hook @@ -123,14 +124,16 @@ public: const typename CloudType::parcelType& p, const polyPatch& pp, const scalar trackFraction, - const tetIndices& tetIs + const tetIndices& tetIs, + bool& keepParticle ); //- Post-face hook virtual void postFace ( const typename CloudType::parcelType& p, - const label faceI + const label faceI, + bool& keepParticle ); }; diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.C index ae02927bbd..8c64e1b62f 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.C +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -133,7 +133,7 @@ void Foam::FacePostProcessing::write() { OFstream& os = outputFilePtr_[zoneI]; os << time.timeName() << token::TAB << sumMassTotal << token::TAB - << sumMassFlowRate<< endl; + << sumMassFlowRate<< endl; } } @@ -376,7 +376,8 @@ template void Foam::FacePostProcessing::postFace ( const parcelType& p, - const label faceI + const label faceI, + bool& ) { if diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.H b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.H index 06387d234b..3195b9fc57 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.H +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.H @@ -160,7 +160,8 @@ public: virtual void postFace ( const parcelType& p, - const label faceI + const label faceI, + bool& keepParticle ); }; diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleCollector/ParticleCollector.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleCollector/ParticleCollector.C new file mode 100644 index 0000000000..06f836a3d5 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleCollector/ParticleCollector.C @@ -0,0 +1,677 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "ParticleCollector.H" +#include "Pstream.H" +#include "surfaceWriter.H" +#include "unitConversion.H" +#include "Random.H" +#include "triangle.H" +#include "cloud.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template +void Foam::ParticleCollector::makeLogFile +( + const faceList& faces, + const Field& points, + const Field& area +) +{ + // Create the output file if not already created + if (log_) + { + if (debug) + { + Info<< "Creating output file" << endl; + } + + if (Pstream::master()) + { + const fileName logDir = outputDir_/this->owner().time().timeName(); + + // Create directory if does not exist + mkDir(logDir); + + // Open new file at start up + outputFilePtr_.reset + ( + new OFstream(logDir/(type() + ".dat")) + ); + + outputFilePtr_() + << "# Source : " << type() << nl + << "# Total area : " << sum(area) << nl + << "# Time"; + + forAll(faces, i) + { + word id = Foam::name(i); + + outputFilePtr_() + << tab << "area[" << id << "]" + << tab << "mass[" << id << "]" + << tab << "massFlowRate[" << id << "]" + << endl; + } + } + } +} + + +template +void Foam::ParticleCollector::initPolygons() +{ + mode_ = mtPolygon; + + List > polygons(this->coeffDict().lookup("polygons")); + label nPoints = 0; + forAll(polygons, polyI) + { + label np = polygons[polyI].size(); + if (np < 3) + { + FatalIOErrorIn + ( + "Foam::ParticleCollector::initPolygons()", + this->coeffDict() + ) + << "polygons must consist of at least 3 points" + << exit(FatalIOError); + } + + nPoints += np; + } + + label pointOffset = 0; + points_.setSize(nPoints); + faces_.setSize(polygons.size()); + faceTris_.setSize(polygons.size()); + area_.setSize(polygons.size()); + forAll(faces_, faceI) + { + const Field& polyPoints = polygons[faceI]; + face f(identity(polyPoints.size()) + pointOffset); + UIndirectList(points_, f) = polyPoints; + area_[faceI] = f.mag(points_); + + DynamicList tris; + f.triangles(points_, tris); + faceTris_[faceI].transfer(tris); + + faces_[faceI].transfer(f); + + pointOffset += polyPoints.size(); + } +} + + +template +void Foam::ParticleCollector::initConcentricCircles() +{ + mode_ = mtConcentricCircle; + + vector origin(this->coeffDict().lookup("origin")); + + radius_ = this->coeffDict().lookup("radius"); + nSector_ = readLabel(this->coeffDict().lookup("nSector")); + + label nS = nSector_; + + vector refDir; + if (nSector_ > 1) + { + refDir = this->coeffDict().lookup("refDir"); + refDir -= normal_*(normal_ & refDir); + refDir /= mag(refDir); + } + else + { + // set 4 quadrants for single sector cases + nS = 4; + + vector tangent = vector::zero; + scalar magTangent = 0.0; + + Random rnd(1234); + while (magTangent < SMALL) + { + vector v = rnd.vector01(); + + tangent = v - (v & normal_)*normal_; + magTangent = mag(tangent); + } + + refDir = tangent/magTangent; + } + + scalar dTheta = 5.0; + scalar dThetaSector = 360.0/scalar(nS); + label intervalPerSector = max(1, ceil(dThetaSector/dTheta)); + dTheta = dThetaSector/scalar(intervalPerSector); + + label nPointPerSector = intervalPerSector + 1; + + label nPointPerRadius = nS*(nPointPerSector - 1); + label nPoint = radius_.size()*nPointPerRadius; + label nFace = radius_.size()*nS; + + // add origin + nPoint++; + + points_.setSize(nPoint); + faces_.setSize(nFace); + area_.setSize(nFace); + + coordSys_ = cylindricalCS("coordSys", origin, normal_, refDir, false); + + List