From fd6f81bbf3b914aedeb211bb2d3f03120f8315d0 Mon Sep 17 00:00:00 2001 From: sergio Date: Tue, 7 Aug 2012 14:23:55 +0100 Subject: [PATCH 1/2] ENH: Adding surfaceFields sampling to sampledPatch --- .../sampledPatch/sampledPatch.C | 44 ++++ .../sampledPatch/sampledPatch.H | 36 +++ .../sampledPatch/sampledPatchTemplates.C | 21 ++ .../sampledSurface/sampledSurface.C | 49 ++++ .../sampledSurface/sampledSurface.H | 31 +++ .../sampledSurfaces/sampledSurfaces.C | 32 ++- .../sampledSurfaces/sampledSurfaces.H | 48 ++-- .../sampledSurfaces/sampledSurfacesGrouping.C | 78 +----- .../sampledSurfacesTemplates.C | 227 ++++++++++-------- 9 files changed, 343 insertions(+), 223 deletions(-) diff --git a/src/sampling/sampledSurface/sampledPatch/sampledPatch.C b/src/sampling/sampledSurface/sampledPatch/sampledPatch.C index 1f8eaf9e1b..da2d90c9fa 100644 --- a/src/sampling/sampledSurface/sampledPatch/sampledPatch.C +++ b/src/sampling/sampledSurface/sampledPatch/sampledPatch.C @@ -28,6 +28,7 @@ License #include "polyMesh.H" #include "polyPatch.H" #include "volFields.H" +#include "surfaceFields.H" #include "addToRunTimeSelectionTable.H" @@ -274,6 +275,49 @@ Foam::tmp Foam::sampledPatch::sample } +Foam::tmp Foam::sampledPatch::sample +( + const surfaceScalarField& sField +) const +{ + return sampleField(sField); +} + + +Foam::tmp Foam::sampledPatch::sample +( + const surfaceVectorField& sField +) const +{ + return sampleField(sField); +} + +Foam::tmp Foam::sampledPatch::sample +( + const surfaceSphericalTensorField& sField +) const +{ + return sampleField(sField); +} + + +Foam::tmp Foam::sampledPatch::sample +( + const surfaceSymmTensorField& sField +) const +{ + return sampleField(sField); +} + + +Foam::tmp Foam::sampledPatch::sample +( + const surfaceTensorField& sField +) const +{ + return sampleField(sField); +} + Foam::tmp Foam::sampledPatch::interpolate ( const interpolation& interpolator diff --git a/src/sampling/sampledSurface/sampledPatch/sampledPatch.H b/src/sampling/sampledSurface/sampledPatch/sampledPatch.H index 36590a747a..0ec8dbd89f 100644 --- a/src/sampling/sampledSurface/sampledPatch/sampledPatch.H +++ b/src/sampling/sampledSurface/sampledPatch/sampledPatch.H @@ -87,6 +87,13 @@ class sampledPatch const GeometricField& vField ) const; + //- sample surface field on faces + template + tmp > sampleField + ( + const GeometricField& sField + ) const; + template tmp > interpolateField(const interpolation&) const; @@ -203,6 +210,35 @@ public: const volTensorField& ) const; + //- Surface sample field on surface + virtual tmp sample + ( + const surfaceScalarField& + ) const; + + //- Surface Sample field on surface + virtual tmp sample + ( + const surfaceVectorField& + ) const; + + //- Surface sample field on surface + virtual tmp sample + ( + const surfaceSphericalTensorField& + ) const; + + //- Surface sample field on surface + virtual tmp sample + ( + const surfaceSymmTensorField& + ) const; + + //- Surface sample field on surface + virtual tmp sample + ( + const surfaceTensorField& + ) const; //- interpolate field on surface virtual tmp interpolate diff --git a/src/sampling/sampledSurface/sampledPatch/sampledPatchTemplates.C b/src/sampling/sampledSurface/sampledPatch/sampledPatchTemplates.C index 47b31e97c2..8725f412be 100644 --- a/src/sampling/sampledSurface/sampledPatch/sampledPatchTemplates.C +++ b/src/sampling/sampledSurface/sampledPatch/sampledPatchTemplates.C @@ -48,6 +48,27 @@ Foam::sampledPatch::sampleField } +template +Foam::tmp > +Foam::sampledPatch::sampleField +( + const GeometricField& sField +) const +{ + // One value per face + tmp > tvalues(new Field(patchFaceLabels_.size())); + Field& values = tvalues(); + + forAll(patchFaceLabels_, i) + { + label patchI = patchIDs_[patchIndex_[i]]; + values[i] = sField.boundaryField()[patchI][patchFaceLabels_[i]]; + } + + return tvalues; +} + + template Foam::tmp > Foam::sampledPatch::interpolateField diff --git a/src/sampling/sampledSurface/sampledSurface/sampledSurface.C b/src/sampling/sampledSurface/sampledSurface/sampledSurface.C index 5c7c5abb90..aaca4f087c 100644 --- a/src/sampling/sampledSurface/sampledSurface/sampledSurface.C +++ b/src/sampling/sampledSurface/sampledSurface/sampledSurface.C @@ -240,6 +240,55 @@ Foam::scalar Foam::sampledSurface::area() const } +Foam::tmp Foam::sampledSurface::sample +( + const surfaceScalarField& sField +) const +{ + notImplemented("tmp sampledSurface::sample"); + return tmp(NULL); +} + + +Foam::tmp Foam::sampledSurface::sample +( + const surfaceVectorField& sField +) const +{ + notImplemented("tmp sampledSurface::sample"); + return tmp(NULL); +} + +Foam::tmp Foam::sampledSurface::sample +( + const surfaceSphericalTensorField& sField +) const +{ + notImplemented("tmp sampledSurface::sample"); + return tmp(NULL); +} + + +Foam::tmp Foam::sampledSurface::sample +( + const surfaceSymmTensorField& sField +) const +{ + notImplemented("tmp sampledSurface::sample"); + return tmp(NULL); +} + + +Foam::tmp Foam::sampledSurface::sample +( + const surfaceTensorField& sField +) const +{ + notImplemented("tmp sampledSurface::sample"); + return tmp(NULL); +} + + Foam::tmp > Foam::sampledSurface::project(const Field& field) const { diff --git a/src/sampling/sampledSurface/sampledSurface/sampledSurface.H b/src/sampling/sampledSurface/sampledSurface/sampledSurface.H index 9843143107..7ef9654ebd 100644 --- a/src/sampling/sampledSurface/sampledSurface/sampledSurface.H +++ b/src/sampling/sampledSurface/sampledSurface/sampledSurface.H @@ -57,6 +57,8 @@ SourceFiles #include "runTimeSelectionTables.H" #include "autoPtr.H" #include "volFieldsFwd.H" +#include "surfaceFieldsFwd.H" +#include "surfaceMesh.H" #include "polyMesh.H" #include "coordinateSystems.H" #include "interpolation.H" @@ -352,6 +354,35 @@ public: const volTensorField& ) const = 0; + //- Surface sample field on surface + virtual tmp sample + ( + const surfaceScalarField& + ) const; + + //- Surface Sample field on surface + virtual tmp sample + ( + const surfaceVectorField& + ) const; + + //- Surface sample field on surface + virtual tmp sample + ( + const surfaceSphericalTensorField& + ) const; + + //- Surface sample field on surface + virtual tmp sample + ( + const surfaceSymmTensorField& + ) const; + + //- Surface sample field on surface + virtual tmp sample + ( + const surfaceTensorField& + ) const; //- Interpolate field on surface virtual tmp interpolate diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C index a8dfaebdfc..5fedecbd56 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C @@ -95,12 +95,7 @@ Foam::sampledSurfaces::sampledSurfaces fieldSelection_(), interpolationScheme_(word::null), mergeList_(), - formatter_(NULL), - scalarFields_(), - vectorFields_(), - sphericalTensorFields_(), - symmTensorFields_(), - tensorFields_() + formatter_(NULL) { if (Pstream::parRun()) { @@ -154,13 +149,6 @@ void Foam::sampledSurfaces::write() { if (debug) { - Pout<< "timeName = " << mesh_.time().timeName() << nl - << "scalarFields " << scalarFields_ << nl - << "vectorFields " << vectorFields_ << nl - << "sphTensorFields " << sphericalTensorFields_ << nl - << "symTensorFields " << symmTensorFields_ <(objects); + sampleAndWrite(objects); + sampleAndWrite(objects); + sampleAndWrite(objects); + sampleAndWrite(objects); + + sampleAndWrite(objects); + sampleAndWrite(objects); + sampleAndWrite(objects); + sampleAndWrite(objects); + sampleAndWrite(objects); } } diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H index 0904c92ef0..ff676d1f99 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H @@ -40,7 +40,9 @@ SourceFiles #include "sampledSurface.H" #include "surfaceWriter.H" #include "volFieldsFwd.H" +#include "surfaceFieldsFwd.H" #include "wordReList.H" +#include "IOobjectList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -60,21 +62,6 @@ class sampledSurfaces { // Private classes - //- Class used for grouping field types - template - class fieldGroup - : - public DynamicList - { - public: - - //- Construct null - fieldGroup() - : - DynamicList(0) - {} - }; - //- Class used for surface merging information class mergeInfo @@ -137,13 +124,6 @@ class sampledSurfaces //- Surface formatter autoPtr formatter_; - //- Categorized scalar/vector/tensor fields - fieldGroup scalarFields_; - fieldGroup vectorFields_; - fieldGroup sphericalTensorFields_; - fieldGroup symmTensorFields_; - fieldGroup tensorFields_; - // Private Member Functions @@ -159,13 +139,33 @@ class sampledSurfaces //- Write geometry only void writeGeometry() const; + //- Write sampled fieldName on surface and on outputDir path + template + void writeSurface + ( + const Field& values, + const label surfI, + const word& fieldName, + const fileName& outputDir + ); + //- Sample and write a particular volume field template - void sampleAndWrite(const GeometricField&); + void sampleAndWrite + ( + const GeometricField& + ); + + //- Sample and write a particular surface field + template + void sampleAndWrite + ( + const GeometricField& + ); //- Sample and write all the fields of the given type template - void sampleAndWrite(fieldGroup&); + void sampleAndWrite(const IOobjectList& allObjects); //- Disallow default bitwise copy construct and assignment sampledSurfaces(const sampledSurfaces&); diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesGrouping.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesGrouping.C index 0dda16b180..6e67008de3 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesGrouping.C +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesGrouping.C @@ -30,94 +30,22 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -void Foam::sampledSurfaces::clearFieldGroups() -{ - scalarFields_.clear(); - vectorFields_.clear(); - sphericalTensorFields_.clear(); - symmTensorFields_.clear(); - tensorFields_.clear(); -} - - -Foam::label Foam::sampledSurfaces::appendFieldGroup -( - const word& fieldName, - const word& fieldType -) -{ - if (fieldType == volScalarField::typeName) - { - scalarFields_.append(fieldName); - return 1; - } - else if (fieldType == volVectorField::typeName) - { - vectorFields_.append(fieldName); - return 1; - } - else if (fieldType == volSphericalTensorField::typeName) - { - sphericalTensorFields_.append(fieldName); - return 1; - } - else if (fieldType == volSymmTensorField::typeName) - { - symmTensorFields_.append(fieldName); - return 1; - } - else if (fieldType == volTensorField::typeName) - { - tensorFields_.append(fieldName); - return 1; - } - - return 0; -} - - Foam::label Foam::sampledSurfaces::classifyFields() { - label nFields = 0; - clearFieldGroups(); - - // check files for a particular time + // check files for a particular time if (loadFromFiles_) { IOobjectList objects(mesh_, mesh_.time().timeName()); wordList allFields = objects.sortedNames(); - labelList indices = findStrings(fieldSelection_, allFields); - - forAll(indices, fieldI) - { - const word& fieldName = allFields[indices[fieldI]]; - - nFields += appendFieldGroup - ( - fieldName, - objects.find(fieldName)()->headerClassName() - ); - } + return indices.size(); } else { wordList allFields = mesh_.sortedNames(); labelList indices = findStrings(fieldSelection_, allFields); - - forAll(indices, fieldI) - { - const word& fieldName = allFields[indices[fieldI]]; - - nFields += appendFieldGroup - ( - fieldName, - mesh_.find(fieldName)()->type() - ); - } + return indices.size(); } - - return nFields; } diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C index 78d7808d7a..a56fcadf79 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C @@ -25,10 +25,86 @@ License #include "sampledSurfaces.H" #include "volFields.H" +#include "surfaceFields.H" #include "ListListOps.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +template +void Foam::sampledSurfaces::writeSurface +( + const Field& values, + const label surfI, + const word& fieldName, + const fileName& outputDir +) +{ + const sampledSurface& s = operator[](surfI); + + if (Pstream::parRun()) + { + // Collect values from all processors + List > gatheredValues(Pstream::nProcs()); + gatheredValues[Pstream::myProcNo()] = values; + Pstream::gatherList(gatheredValues); + + if (Pstream::master()) + { + // Combine values into single field + Field allValues + ( + ListListOps::combine > + ( + gatheredValues, + accessOp >() + ) + ); + + // Renumber (point data) to correspond to merged points + if (mergeList_[surfI].pointsMap.size() == allValues.size()) + { + inplaceReorder(mergeList_[surfI].pointsMap, allValues); + allValues.setSize(mergeList_[surfI].points.size()); + } + + // Write to time directory under outputPath_ + // skip surface without faces (eg, a failed cut-plane) + if (mergeList_[surfI].faces.size()) + { + formatter_->write + ( + outputDir, + s.name(), + mergeList_[surfI].points, + mergeList_[surfI].faces, + fieldName, + allValues, + s.interpolate() + ); + } + } + } + else + { + // Write to time directory under outputPath_ + // skip surface without faces (eg, a failed cut-plane) + if (s.faces().size()) + { + formatter_->write + ( + outputDir, + s.name(), + s.points(), + s.faces(), + fieldName, + values, + s.interpolate() + ); + } + } +} + + template void Foam::sampledSurfaces::sampleAndWrite ( @@ -65,125 +141,64 @@ void Foam::sampledSurfaces::sampleAndWrite values = s.sample(vField); } - if (Pstream::parRun()) - { - // Collect values from all processors - List > gatheredValues(Pstream::nProcs()); - gatheredValues[Pstream::myProcNo()] = values; - Pstream::gatherList(gatheredValues); - - if (Pstream::master()) - { - // Combine values into single field - Field allValues - ( - ListListOps::combine > - ( - gatheredValues, - accessOp >() - ) - ); - - // Renumber (point data) to correspond to merged points - if (mergeList_[surfI].pointsMap.size() == allValues.size()) - { - inplaceReorder(mergeList_[surfI].pointsMap, allValues); - allValues.setSize(mergeList_[surfI].points.size()); - } - - // Write to time directory under outputPath_ - // skip surface without faces (eg, a failed cut-plane) - if (mergeList_[surfI].faces.size()) - { - formatter_->write - ( - outputDir, - s.name(), - mergeList_[surfI].points, - mergeList_[surfI].faces, - fieldName, - allValues, - s.interpolate() - ); - } - } - } - else - { - // Write to time directory under outputPath_ - // skip surface without faces (eg, a failed cut-plane) - if (s.faces().size()) - { - formatter_->write - ( - outputDir, - s.name(), - s.points(), - s.faces(), - fieldName, - values, - s.interpolate() - ); - } - } + writeSurface(values, surfI, fieldName, outputDir); } } + template void Foam::sampledSurfaces::sampleAndWrite ( - fieldGroup& fields + const GeometricField& sField ) { - if (fields.size()) + const word& fieldName = sField.name(); + const fileName outputDir = outputPath_/sField.time().timeName(); + + forAll(*this, surfI) { - forAll(fields, fieldI) + const sampledSurface& s = operator[](surfI); + Field values = s.sample(sField); + writeSurface(values, surfI, fieldName, outputDir); + } +} + + +template +void Foam::sampledSurfaces::sampleAndWrite(const IOobjectList& allObjects) +{ + IOobjectList fields = allObjects.lookupClass(GeoField::typeName); + forAllConstIter(IOobjectList, fields, fieldIter) + { + forAll (fieldSelection_, fieldI) { - if (Pstream::master() && verbose_) + const wordRe field = fieldSelection_[fieldI]; + if (field.match(fieldIter()->name())) { - Pout<< "sampleAndWrite: " << fields[fieldI] << endl; - } - - if (loadFromFiles_) - { - sampleAndWrite - ( - GeometricField - ( - IOobject - ( - fields[fieldI], - mesh_.time().timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ), - mesh_ - ) - ); - } - else - { - objectRegistry::const_iterator iter = - mesh_.find(fields[fieldI]); - - if - ( - iter != objectRegistry::end() - && iter()->type() - == GeometricField::typeName - ) + if (Pstream::master() && verbose_) { - sampleAndWrite - ( - mesh_.lookupObject - > - ( - fields[fieldI] - ) - ); + Pout<< "sampleAndWrite: " << field << endl; + } + + if (loadFromFiles_) + { + fieldIter()->readOpt() = IOobject::MUST_READ; + sampleAndWrite + ( + GeoField + ( + *fieldIter(), + mesh_ + ) + ); + } + else + { + sampleAndWrite + ( + mesh_.lookupObject(fieldIter()->name()) + ); } } } From 4604b692f83f94847b6ddf3efef05d73e2a1de0a Mon Sep 17 00:00:00 2001 From: sergio Date: Tue, 7 Aug 2012 16:33:33 +0100 Subject: [PATCH 2/2] ENH: Add local rho into reactingOneDim.C --- .../reactingOneDim/reactingOneDim.C | 71 +++++++++++++------ .../reactingOneDim/reactingOneDim.H | 12 +--- .../regionModel/regionModel1D/regionModel1D.C | 18 ++--- 3 files changed, 64 insertions(+), 37 deletions(-) diff --git a/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C b/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C index 65143f5d27..84ba7e84cd 100644 --- a/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C +++ b/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C @@ -232,12 +232,22 @@ void reactingOneDim::solveContinuity() Info<< "reactingOneDim::solveContinuity()" << endl; } - solve - ( - fvm::ddt(rho_) - == - - solidChemistry_->RRg() - ); + if (moveMesh_) + { + const scalarField mass0 = rho_*regionMesh().V(); + + fvScalarMatrix rhoEqn + ( + fvm::ddt(rho_) + == + - solidChemistry_->RRg() + ); + + rhoEqn.solve(); + + updateMesh(mass0); + + } } @@ -261,14 +271,15 @@ void reactingOneDim::solveSpeciesMass() solidChemistry_->RRs(i) ); - if (moveMesh_) + if (regionMesh().moving()) { - surfaceScalarField phiRhoMesh + surfaceScalarField phiYiRhoMesh ( fvc::interpolate(Yi*rho_)*regionMesh().phi() ); - YiEqn -= fvc::div(phiRhoMesh); + YiEqn += fvc::div(phiYiRhoMesh); + } YiEqn.solve(regionMesh().solver("Yi")); @@ -303,14 +314,14 @@ void reactingOneDim::solveEnergy() + fvc::div(phiGas) ); - if (moveMesh_) + if (regionMesh().moving()) { - surfaceScalarField phiMesh + surfaceScalarField phihMesh ( fvc::interpolate(rho_*h_)*regionMesh().phi() ); - hEqn -= fvc::div(phiMesh); + hEqn += fvc::div(phihMesh); } hEqn.relax(); @@ -349,7 +360,18 @@ reactingOneDim::reactingOneDim(const word& modelType, const fvMesh& mesh) pyrolysisModel(modelType, mesh), solidChemistry_(solidChemistryModel::New(regionMesh())), solidThermo_(solidChemistry_->solid()), - rho_(solidThermo_.rho()), + rho_ + ( + IOobject + ( + "rho", + regionMesh().time().timeName(), + regionMesh(), + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + solidThermo_.rho() + ), Ys_(solidThermo_.composition().Y()), h_(solidThermo_.he()), primaryRadFluxName_(coeffs().lookupOrDefault("radFluxName", "Qr")), @@ -449,7 +471,18 @@ reactingOneDim::reactingOneDim pyrolysisModel(modelType, mesh, dict), solidChemistry_(solidChemistryModel::New(regionMesh())), solidThermo_(solidChemistry_->solid()), - rho_(solidThermo_.rho()), + rho_ + ( + IOobject + ( + "rho", + regionMesh().time().timeName(), + regionMesh(), + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + solidThermo_.rho() + ), Ys_(solidThermo_.composition().Y()), h_(solidThermo_.he()), primaryRadFluxName_(dict.lookupOrDefault("radFluxName", "Qr")), @@ -681,17 +714,15 @@ void reactingOneDim::evolveRegion() { Info<< "\nEvolving pyrolysis in region: " << regionMesh().name() << endl; - const scalarField mass0 = rho_*regionMesh().V(); - solidChemistry_->solve ( time().value() - time().deltaTValue(), time().deltaTValue() ); - solveContinuity(); + calculateMassTransfer(); - updateMesh(mass0); + solveContinuity(); chemistrySh_ = solidChemistry_->Sh()(); @@ -704,9 +735,9 @@ void reactingOneDim::evolveRegion() solveEnergy(); } - calculateMassTransfer(); - solidThermo_.correct(); + + rho_ = solidThermo_.rho(); } diff --git a/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.H b/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.H index aa3d7baa9b..619c9c0e9a 100644 --- a/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.H +++ b/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.H @@ -84,14 +84,8 @@ protected: // Reference to solid thermo properties -// //- Absorption coefficient [1/m] -// const volScalarField& kappaRad_; -// -// //- Thermal conductivity [W/m/K] -// const volScalarField& kappa_; - //- Density [kg/m3] - volScalarField& rho_; + volScalarField rho_; //- List of solid components PtrList& Ys_; @@ -221,8 +215,8 @@ public: //- Fields - //- Return density [kg/m3] - virtual const volScalarField& rho() const; + //- Return const density [Kg/m3] + const volScalarField& rho() const; //- Return const temperature [K] virtual const volScalarField& T() const; diff --git a/src/regionModels/regionModel/regionModel1D/regionModel1D.C b/src/regionModels/regionModel/regionModel1D/regionModel1D.C index 372e19a3f3..60243b55cd 100644 --- a/src/regionModels/regionModel/regionModel1D/regionModel1D.C +++ b/src/regionModels/regionModel/regionModel1D/regionModel1D.C @@ -117,6 +117,8 @@ void Foam::regionModels::regionModel1D::initialise() } boundaryFaceOppositeFace_.setSize(localPyrolysisFaceI); + boundaryFaceFaces_.setSize(localPyrolysisFaceI); + boundaryFaceCells_.setSize(localPyrolysisFaceI); surfaceScalarField& nMagSf = nMagSfPtr_(); @@ -192,6 +194,7 @@ Foam::tmp Foam::regionModels::regionModel1D::moveMesh const polyBoundaryMesh& bm = regionMesh().boundaryMesh(); + label totalFaceId = 0; forAll(intCoupledPatchIDs_, localPatchI) { label patchI = intCoupledPatchIDs_[localPatchI]; @@ -200,8 +203,9 @@ Foam::tmp Foam::regionModels::regionModel1D::moveMesh forAll(pp, patchFaceI) { - const labelList& faces = boundaryFaceFaces_[patchFaceI]; - const labelList& cells = boundaryFaceCells_[patchFaceI]; + const labelList& faces = boundaryFaceFaces_[totalFaceId]; + const labelList& cells = boundaryFaceCells_[totalFaceId]; + const vector n = pp.faceNormals()[patchFaceI]; const vector sf = pp.faceAreas()[patchFaceI]; @@ -231,7 +235,7 @@ Foam::tmp Foam::regionModels::regionModel1D::moveMesh if ( - ((nbrCf - (oldPoints[pointI] + newDelta)) & n) + mag((nbrCf - (oldPoints[pointI] + newDelta)) & n) > minDelta ) { @@ -242,19 +246,17 @@ Foam::tmp Foam::regionModels::regionModel1D::moveMesh } nbrCf = oldCf[i + 1] + localDelta; } - // Modify boundary - const label bFaceI = boundaryFaceOppositeFace_[patchFaceI]; + const label bFaceI = boundaryFaceOppositeFace_[totalFaceId]; const face f = regionMesh().faces()[bFaceI]; const label cellI = cells[cells.size() - 1]; newDelta += (deltaV[cellI]/mag(sf))*n; forAll(f, pti) { const label pointI = f[pti]; - if ( - ((nbrCf - (oldPoints[pointI] + newDelta)) & n) + mag((nbrCf - (oldPoints[pointI] + newDelta)) & n) > minDelta ) { @@ -262,9 +264,9 @@ Foam::tmp Foam::regionModels::regionModel1D::moveMesh cellMoveMap[cellI] = 1; } } + totalFaceId ++; } } - // Move points regionMesh().movePoints(newPoints);