diff --git a/applications/solvers/dsmc/dsmcFoam/Make/files b/applications/solvers/dsmc/dsmcFoam/Make/files new file mode 100755 index 0000000000000000000000000000000000000000..a6860410e7104015170f0ad307ede4e93004b57a --- /dev/null +++ b/applications/solvers/dsmc/dsmcFoam/Make/files @@ -0,0 +1,3 @@ +dsmcFoam.C + +EXE = $(FOAM_APPBIN)/dsmcFoam diff --git a/applications/solvers/dsmc/dsmcFoam/Make/options b/applications/solvers/dsmc/dsmcFoam/Make/options new file mode 100755 index 0000000000000000000000000000000000000000..bc99834af6ea732c365d0b07940f997e1c6cedfe --- /dev/null +++ b/applications/solvers/dsmc/dsmcFoam/Make/options @@ -0,0 +1,12 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/lagrangian/basic/lnInclude \ + -I$(LIB_SRC)/lagrangian/dsmc/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude + +EXE_LIBS = \ + -lmeshTools \ + -lfiniteVolume \ + -llagrangian \ + -ldsmc + diff --git a/applications/solvers/dsmc/dsmcFoam/createFields.H b/applications/solvers/dsmc/dsmcFoam/createFields.H new file mode 100644 index 0000000000000000000000000000000000000000..d024bd2017ae346c53e9adbc86a775a9ba496ba5 --- /dev/null +++ b/applications/solvers/dsmc/dsmcFoam/createFields.H @@ -0,0 +1,162 @@ + + Info<< nl << "Reading field boundaryT" << endl; + volScalarField boundaryT + ( + IOobject + ( + "boundaryT", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + Info<< nl << "Reading field boundaryU" << endl; + volVectorField boundaryU + ( + IOobject + ( + "boundaryU", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + Info<< nl << "Reading field rhoN (number density)" << endl; + volScalarField rhoN + ( + IOobject + ( + "rhoN", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + Info<< nl << "Reading field rhoM (mass density)" << endl; + volScalarField rhoM + ( + IOobject + ( + "rhoM", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + Info<< nl << "Reading field rhoNdsmc (dsmc particle density)" << endl; + volScalarField dsmcRhoN + ( + IOobject + ( + "dsmcRhoN", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + Info<< nl << "Reading field momentum (momentum density)" << endl; + volVectorField momentum + ( + IOobject + ( + "momentum", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + Info<< nl << "Reading field linearKE (linear kinetic energy density)" + << endl; + + volScalarField linearKE + ( + IOobject + ( + "linearKE", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + Info<< nl << "Reading field internalE (internal energy density)" << endl; + volScalarField internalE + ( + IOobject + ( + "internalE", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + Info<< nl << "Reading field iDof (internal degree of freedom density)" + << endl; + + volScalarField iDof + ( + IOobject + ( + "iDof", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + Info<< nl << "Reading field q (surface heat transfer)" << endl; + volScalarField q + ( + IOobject + ( + "q", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + Info<< nl << "Reading field fD (surface force density)" << endl; + volVectorField fD + ( + IOobject + ( + "fD", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + Info<< nl << "Constructing dsmcCloud " << endl; + + dsmcCloud dsmc("dsmc", boundaryT, boundaryU); diff --git a/applications/solvers/dsmc/dsmcFoam/dsmcFoam.C b/applications/solvers/dsmc/dsmcFoam/dsmcFoam.C new file mode 100644 index 0000000000000000000000000000000000000000..1ea52cc6aae883bd4f5fa85e93b0294ca799d638 --- /dev/null +++ b/applications/solvers/dsmc/dsmcFoam/dsmcFoam.C @@ -0,0 +1,105 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + dsmcFoam + +Description + Direct Simulation Monte Carlo Solver for 3D, transient, multi-species flows + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "dsmcCloud.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + #include "createFields.H" + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.run()) + { + runTime++; + + Info<< "Time = " << runTime.timeName() << nl << endl; + + // Carry out dsmcCloud timestep + + dsmc.evolve(); + + // Retrieve flow field data from dsmcCloud + + rhoN = dsmc.rhoN(); + rhoN.correctBoundaryConditions(); + + rhoM = dsmc.rhoM(); + rhoM.correctBoundaryConditions(); + + dsmcRhoN = dsmc.dsmcRhoN(); + dsmcRhoN.correctBoundaryConditions(); + + momentum = dsmc.momentum(); + momentum.correctBoundaryConditions(); + + linearKE = dsmc.linearKE(); + linearKE.correctBoundaryConditions(); + + internalE = dsmc.internalE(); + internalE.correctBoundaryConditions(); + + iDof = dsmc.iDof(); + iDof.correctBoundaryConditions(); + + // Retrieve surface field data from dsmcCloud + + q = dsmc.q(); + + fD = dsmc.fD(); + + // Print status of dsmcCloud + + dsmc.info(); + + runTime.write(); + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "End\n" << endl; + + return(0); +} + + +// ************************************************************************* // diff --git a/applications/test/List/ListTest.C b/applications/test/List/ListTest.C index 3f6fcc734c824d21346c4dcf1ec7a022a8c2188c..bc8901b03beacc65c399053ab5c5d49532009edf 100644 --- a/applications/test/List/ListTest.C +++ b/applications/test/List/ListTest.C @@ -46,7 +46,7 @@ int main(int argc, char *argv[]) List<vector> list(IStringStream("1 ((0 1 2))")()); Info<< list << endl; - List<vector> list2(IStringStream("((0 1 2) (3 4 5) (3 4 5))")()); + List<vector> list2(IStringStream("((0 1 2) (3 4 5) (6 7 8))")()); Info<< list2 << endl; Info<< findIndex(list2, vector(3, 4, 5)) << endl; @@ -59,6 +59,13 @@ int main(int argc, char *argv[]) Info<< list2 << nl << list3 << endl; + + // Subset + const labelList map(IStringStream("2 (0 2)")()); + List<vector> subList3(list3, map); + Info<< "Elements " << map << " out of " << list3 + << " : " << subList3 << endl; + return 0; } diff --git a/applications/test/UIndirectListTest/Make/files b/applications/test/UIndirectListTest/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..8b43119aef9a4c4a13ceb37367ebdcf8202f907f --- /dev/null +++ b/applications/test/UIndirectListTest/Make/files @@ -0,0 +1,3 @@ +UIndirectListTest.C + +EXE = $(FOAM_USER_APPBIN)/UIndirectListTest diff --git a/applications/test/UIndirectListTest/Make/options b/applications/test/UIndirectListTest/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/applications/test/UIndirectListTest/UIndirectListTest.C b/applications/test/UIndirectListTest/UIndirectListTest.C new file mode 100644 index 0000000000000000000000000000000000000000..575173c51e095e2488e7ad118f1699683c6e318b --- /dev/null +++ b/applications/test/UIndirectListTest/UIndirectListTest.C @@ -0,0 +1,94 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Description + +\*---------------------------------------------------------------------------*/ + +#include "UIndirectList.H" +#include "IOstreams.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + List<double> completeList(10); + + forAll(completeList, i) + { + completeList[i] = 0.1*i; + } + + List<label> addresses(5); + addresses[0] = 1; + addresses[1] = 0; + addresses[2] = 7; + addresses[3] = 8; + addresses[4] = 5; + + UIndirectList<double> idl(completeList, addresses); + + forAll(idl, i) + { + Info<< idl[i] << token::SPACE; + } + + Info<< endl; + + idl[1] = -666; + + Info<< "idl[1] changed:" << idl() << endl; + + idl = -999; + + Info<< "idl changed:" << idl() << endl; + + UIndirectList<double> idl2(idl); + + Info<< "idl2:" << idl2() << endl; + + idl = idl2(); + + Info<< "idl assigned from UList:" << idl() << endl; + + + List<double> realList = UIndirectList<double>(completeList, addresses); + + Info<< "realList:" << realList << endl; + + List<double> realList2(UIndirectList<double>(completeList, addresses)); + + Info<< "realList2:" << realList2 << endl; + + + Info << "\nEnd\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C b/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C index 17092d5a6ec8ddfd460d68b5a8f12e0211782ea9..fa244430f6b474da5c561052f81b6e7ff0aaac93 100644 --- a/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C +++ b/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C @@ -177,7 +177,7 @@ label mergePatchFaces List<faceList> allFaceSetsFaces(allFaceSets.size()); forAll(allFaceSets, setI) { - allFaceSetsFaces[setI] = IndirectList<face> + allFaceSetsFaces[setI] = UIndirectList<face> ( mesh.faces(), allFaceSets[setI] diff --git a/applications/utilities/mesh/conversion/polyDualMesh/meshDualiser.C b/applications/utilities/mesh/conversion/polyDualMesh/meshDualiser.C index 08b7d7c9b8c6ffbd7bdca03022c819f290e4b952..121becd89559e5404537a34b18dc9874fc06cc50 100644 --- a/applications/utilities/mesh/conversion/polyDualMesh/meshDualiser.C +++ b/applications/utilities/mesh/conversion/polyDualMesh/meshDualiser.C @@ -76,7 +76,7 @@ void Foam::meshDualiser::checkPolyTopoChange(const polyTopoChange& meshMod) "meshDualiser::checkPolyTopoChange(const polyTopoChange&)" ) << "duplicate verts:" << newToOld[newI] << " coords:" - << IndirectList<point>(points, newToOld[newI])() + << UIndirectList<point>(points, newToOld[newI])() << abort(FatalError); } } @@ -226,10 +226,7 @@ Foam::label Foam::meshDualiser::addInternalFace if (debug) { - pointField facePoints - ( - IndirectList<point>(meshMod.points(), newFace)() - ); + pointField facePoints(meshMod.points(), newFace); labelList oldToNew; pointField newPoints; @@ -289,7 +286,7 @@ Foam::label Foam::meshDualiser::addInternalFace //n /= mag(n); //Pout<< "Generated internal dualFace:" << dualFaceI // << " verts:" << newFace - // << " points:" << IndirectList<point>(meshMod.points(), newFace)() + // << " points:" << UIndirectList<point>(meshMod.points(), newFace)() // << " n:" << n // << " between dualowner:" << dualCell0 // << " dualneigbour:" << dualCell1 @@ -316,7 +313,7 @@ Foam::label Foam::meshDualiser::addInternalFace //n /= mag(n); //Pout<< "Generated internal dualFace:" << dualFaceI // << " verts:" << newFace - // << " points:" << IndirectList<point>(meshMod.points(), newFace)() + // << " points:" << UIndirectList<point>(meshMod.points(), newFace)() // << " n:" << n // << " between dualowner:" << dualCell1 // << " dualneigbour:" << dualCell0 @@ -373,7 +370,7 @@ Foam::label Foam::meshDualiser::addBoundaryFace //n /= mag(n); //Pout<< "Generated boundary dualFace:" << dualFaceI // << " verts:" << newFace - // << " points:" << IndirectList<point>(meshMod.points(), newFace)() + // << " points:" << UIndirectList<point>(meshMod.points(), newFace)() // << " n:" << n // << " on dualowner:" << dualCellI // << endl; @@ -568,7 +565,7 @@ void Foam::meshDualiser::createFaceFromInternalFace //Pout<< "createFaceFromInternalFace : At face:" << faceI // << " verts:" << f - // << " points:" << IndirectList<point>(mesh_.points(), f)() + // << " points:" << UIndirectList<point>(mesh_.points(), f)() // << " started walking at edge:" << fEdges[fp] // << " verts:" << mesh_.edges()[fEdges[fp]] // << endl; @@ -617,7 +614,7 @@ void Foam::meshDualiser::createFaceFromInternalFace { FatalErrorIn("createFacesFromInternalFace(..)") << "face:" << faceI << " verts:" << f - << " points:" << IndirectList<point>(mesh_.points(), f)() + << " points:" << UIndirectList<point>(mesh_.points(), f)() << " no feature edge between " << f[fp] << " and " << f[nextFp] << " although have different" << " dual cells." << endl diff --git a/applications/utilities/mesh/manipulation/setSet/writePointSet.C b/applications/utilities/mesh/manipulation/setSet/writePointSet.C index 41e051ab13ed4656c3830fdf6af9116387a2ab54..e55efca4005428bcd72f2e9204b59bb781cd573d 100644 --- a/applications/utilities/mesh/manipulation/setSet/writePointSet.C +++ b/applications/utilities/mesh/manipulation/setSet/writePointSet.C @@ -70,7 +70,7 @@ void writePointSet labelList pointLabels(set.toc()); - pointField setPoints(IndirectList<point>(mesh.points(), pointLabels)()); + pointField setPoints(mesh.points(), pointLabels); // Write points diff --git a/applications/utilities/mesh/manipulation/splitMesh/regionSide.C b/applications/utilities/mesh/manipulation/splitMesh/regionSide.C index dd893bd2df901034cb37fec44e2e40a272cdaa63..604b39cc6c7703a743b0485e7cb6f76319bd8daf 100644 --- a/applications/utilities/mesh/manipulation/splitMesh/regionSide.C +++ b/applications/utilities/mesh/manipulation/splitMesh/regionSide.C @@ -22,14 +22,11 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - \*---------------------------------------------------------------------------*/ #include "regionSide.H" #include "meshTools.H" #include "primitiveMesh.H" -#include "IndirectList.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -113,7 +110,7 @@ Foam::label Foam::regionSide::otherEdge ) << "Cannot find other edge on face " << faceI << " that uses point " << pointI << " but not point " << freePointI << endl << "Edges on face:" << fEdges - << " verts:" << IndirectList<edge>(mesh.edges(), fEdges)() + << " verts:" << UIndirectList<edge>(mesh.edges(), fEdges)() << " Vertices on face:" << mesh.faces()[faceI] << " Vertices on original edge:" << e << abort(FatalError); diff --git a/applications/utilities/mesh/manipulation/splitMesh/splitMesh.C b/applications/utilities/mesh/manipulation/splitMesh/splitMesh.C index 4fb1c875bbde30574f3020a4283db5612b72fed1..b865472dadf7c92bfc2a6d340d256914913c6494 100644 --- a/applications/utilities/mesh/manipulation/splitMesh/splitMesh.C +++ b/applications/utilities/mesh/manipulation/splitMesh/splitMesh.C @@ -50,15 +50,12 @@ Description #include "attachDetach.H" #include "attachPolyTopoChanger.H" #include "regionSide.H" +#include "primitiveFacePatch.H" using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Calculation engine for set of faces in a mesh -typedef PrimitivePatch<face, List, const pointField&> facePatch; - - // Find edge between points v0 and v1. label findEdge(const primitiveMesh& mesh, const label v0, const label v1) { @@ -163,10 +160,16 @@ int main(int argc, char *argv[]) // set of edges on side of this region. Use PrimitivePatch to find these. // - IndirectList<face> zoneFaces(mesh.faces(), faces); - // Addressing on faces only in mesh vertices. - facePatch fPatch(zoneFaces(), mesh.points()); + primitiveFacePatch fPatch + ( + UIndirectList<face> + ( + mesh.faces(), + faces + ), + mesh.points() + ); const labelList& meshPoints = fPatch.meshPoints(); diff --git a/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C b/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C index 1131c591c7db91ece9158a1a312e193eede19b83..2a9784980ac2ab9b4d4f193b3e27f99f06519827 100644 --- a/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C +++ b/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C @@ -60,7 +60,6 @@ Description #include "polyTopoChanger.H" #include "mapPolyMesh.H" #include "ListOps.H" -#include "IndirectList.H" #include "slidingInterface.H" #include "perfectInterface.H" #include "IOobjectList.H" diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writePointSet.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/writePointSet.C index 68bd0216051d273c3bb3ae445c93db8b751f82ee..b8444b15c353b6bd3f78876c9a039591610b9d0f 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writePointSet.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writePointSet.C @@ -22,8 +22,6 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - \*---------------------------------------------------------------------------*/ #include "writePointSet.H" @@ -76,7 +74,7 @@ void writePointSet writeFuns::insert ( - IndirectList<point>(vMesh.mesh().points(), set.toc())(), + UIndirectList<point>(vMesh.mesh().points(), set.toc())(), ptField ); diff --git a/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/Make/files b/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/Make/files new file mode 100755 index 0000000000000000000000000000000000000000..5cba9c270defeec056f43baa38061d3d77c2e936 --- /dev/null +++ b/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/Make/files @@ -0,0 +1,3 @@ +dsmcFieldsCalc.C + +EXE = $(FOAM_APPBIN)/dsmcFieldsCalc diff --git a/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/Make/options b/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/Make/options new file mode 100755 index 0000000000000000000000000000000000000000..4e81bb55de46a818bf4bb13651892d9a208c2163 --- /dev/null +++ b/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/Make/options @@ -0,0 +1,16 @@ +EXE_INC = \ + -I$(LIB_SRC)/postProcessing/postCalc \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/lagrangian/basic/lnInclude \ + -I$(LIB_SRC)/postProcessing/functionObjects/utilities/lnInclude \ + -I$(LIB_SRC)/lagrangian/dsmc/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude + +EXE_LIBS = \ + $(FOAM_LIBBIN)/postCalc.o \ + -lmeshTools \ + -lfiniteVolume \ + -lutilityFunctionObjects \ + -llagrangian \ + -ldsmc + diff --git a/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/dsmcFieldsCalc.C b/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/dsmcFieldsCalc.C new file mode 100644 index 0000000000000000000000000000000000000000..ee4fd2c50f28c66a602156710dfe90575174e5e3 --- /dev/null +++ b/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/dsmcFieldsCalc.C @@ -0,0 +1,147 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + dsmcFields + +Description + Calculate intensive fields (U and T) from averaged extensive fields from a + DSMC calculation. + +\*---------------------------------------------------------------------------*/ + +#include "calc.H" +#include "fvc.H" +#include "dsmcCloud.H" +#include "dsmcFields.H" +#include "IOobjectList.H" + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + template<class Type> + bool addFieldsToList + ( + const fvMesh& mesh, + PtrList<GeometricField<Type, fvPatchField, volMesh> >& list, + const wordList& fieldNames + ) + { + typedef GeometricField<Type, fvPatchField, volMesh> fieldType; + + label index = 0; + forAll(fieldNames, i) + { + IOobject obj + ( + fieldNames[i], + mesh.time().timeName(), + mesh, + IOobject::MUST_READ + ); + + if (obj.headerOk() && obj.headerClassName() == fieldType::typeName) + { + list.set(index++, new fieldType(obj, mesh)); + } + else + { + Info<< "Could not find " << fieldNames[i] << endl; + + return false; + } + } + + return true; + } +} + + +void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh) +{ + bool writeResults = !args.options().found("noWrite"); + + wordList extensiveVSFNames + ( + IStringStream + ( + "( \ + rhoNMean \ + rhoMMean \ + linearKEMean \ + internalEMean \ + iDofMean \ + )" + )() + ); + + PtrList<volScalarField> extensiveVSFs(extensiveVSFNames.size()); + + if + ( + !addFieldsToList + ( + mesh, + extensiveVSFs, + extensiveVSFNames + ) + ) + { + return; + } + + wordList extensiveVVFNames(IStringStream ("(momentumMean)")()); + + PtrList<volVectorField> extensiveVVFs(extensiveVVFNames.size()); + + if + ( + !addFieldsToList + ( + mesh, + extensiveVVFs, + extensiveVVFNames + ) + ) + { + return; + } + + dsmcFields dF + ( + "dsmcFieldsUtility", + mesh, + dictionary::null, + false + ); + + if (writeResults) + { + dF.write(); + } +} + +// ************************************************************************* // diff --git a/applications/utilities/preProcessing/dsmcInitialise/Make/files b/applications/utilities/preProcessing/dsmcInitialise/Make/files new file mode 100755 index 0000000000000000000000000000000000000000..7853cb2bd63f813e349545b4ff15525f6026f0ba --- /dev/null +++ b/applications/utilities/preProcessing/dsmcInitialise/Make/files @@ -0,0 +1,3 @@ +dsmcInitialise.C + +EXE = $(FOAM_APPBIN)/dsmcInitialise diff --git a/applications/utilities/preProcessing/dsmcInitialise/Make/options b/applications/utilities/preProcessing/dsmcInitialise/Make/options new file mode 100755 index 0000000000000000000000000000000000000000..bc99834af6ea732c365d0b07940f997e1c6cedfe --- /dev/null +++ b/applications/utilities/preProcessing/dsmcInitialise/Make/options @@ -0,0 +1,12 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/lagrangian/basic/lnInclude \ + -I$(LIB_SRC)/lagrangian/dsmc/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude + +EXE_LIBS = \ + -lmeshTools \ + -lfiniteVolume \ + -llagrangian \ + -ldsmc + diff --git a/applications/utilities/preProcessing/dsmcInitialise/dsmcInitialise.C b/applications/utilities/preProcessing/dsmcInitialise/dsmcInitialise.C new file mode 100644 index 0000000000000000000000000000000000000000..c2f797c17e0d027bcdfc6ccd86770f03c6a4ae4d --- /dev/null +++ b/applications/utilities/preProcessing/dsmcInitialise/dsmcInitialise.C @@ -0,0 +1,79 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + dsmcFoam + +Description + Initialise a case for dsmcFoam by reading the initialisation dictionary + system/dsmcInitialise + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "dsmcCloud.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "Initialising dsmc for Time = " << runTime.timeName() << nl << endl; + + dsmcCloud dsmc("dsmc", mesh); + + label totalMolecules = dsmc.size(); + + if (Pstream::parRun()) + { + reduce(totalMolecules, sumOp<label>()); + } + + Info<< nl << "Total number of molecules added: " << totalMolecules + << nl << endl; + + IOstream::defaultPrecision(15); + + if (!mesh.write()) + { + FatalErrorIn(args.executable()) + << "Failed writing dsmcCloud." + << nl << exit(FatalError); + } + + Info<< nl << "ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + + Info<< "End\n" << endl; + + return(0); +} + + +// ************************************************************************* // diff --git a/applications/utilities/surface/surfaceSplitNonManifolds/surfaceSplitNonManifolds.C b/applications/utilities/surface/surfaceSplitNonManifolds/surfaceSplitNonManifolds.C index f7131d87db8483e4763ebb03ddac4fb6ffbcb7ed..b56c8e2cf0c8f0be83f9bbf079d967e5d07f7cf2 100644 --- a/applications/utilities/surface/surfaceSplitNonManifolds/surfaceSplitNonManifolds.C +++ b/applications/utilities/surface/surfaceSplitNonManifolds/surfaceSplitNonManifolds.C @@ -306,7 +306,7 @@ label findEdge FatalErrorIn("findEdge") << "Cannot find edge with labels " << v0 << ' ' << v1 << " in candidates " << edgeLabels - << " with vertices:" << IndirectList<edge>(surf.edges(), edgeLabels)() + << " with vertices:" << UIndirectList<edge>(surf.edges(), edgeLabels)() << abort(FatalError); return -1; @@ -346,7 +346,7 @@ label otherEdge FatalErrorIn("otherEdge") << "Cannot find other edge on face " << faceI << " verts:" << surf.localPoints()[faceI] << " connected to point " << pointI - << " faceEdges:" << IndirectList<edge>(surf.edges(), fEdges)() + << " faceEdges:" << UIndirectList<edge>(surf.edges(), fEdges)() << abort(FatalError); return -1; diff --git a/src/OpenFOAM/containers/Lists/List/List.C b/src/OpenFOAM/containers/Lists/List/List.C index 542f9451847e253fef802f07d6213fec7d08b789..a3c17a48900dd57ec15e880260820258b32b18c3 100644 --- a/src/OpenFOAM/containers/Lists/List/List.C +++ b/src/OpenFOAM/containers/Lists/List/List.C @@ -31,6 +31,7 @@ License #include "PtrList.H" #include "SLList.H" #include "IndirectList.H" +#include "UIndirectList.H" #include "BiIndirectList.H" #include "contiguous.H" @@ -171,6 +172,29 @@ Foam::List<T>::List(List<T>& a, bool reUse) } +// Construct as subset +template<class T> +Foam::List<T>::List(const UList<T>& a, const unallocLabelList& map) +: + UList<T>(NULL, map.size()) +{ + if (this->size_) + { + this->v_ = new T[this->size_]; + + List_ACCESS(T, (*this), vp); + List_CONST_ACCESS(T, a, ap); + List_FOR_ALL(map, i) + List_ELEM((*this), vp, i) = List_ELEM(a, ap, (map[i])); + List_END_FOR_ALL + } + else + { + this->v_ = 0; + } +} + + // Construct given start and end iterators. template<class T> template<class InputIterator> @@ -298,6 +322,28 @@ Foam::List<T>::List(const IndirectList<T>& lst) } +// Construct as copy of UIndirectList<T> +template<class T> +Foam::List<T>::List(const UIndirectList<T>& lst) +: + UList<T>(NULL, lst.size()) +{ + if (this->size_) + { + this->v_ = new T[this->size_]; + + forAll(*this, i) + { + this->operator[](i) = lst[i]; + } + } + else + { + this->v_ = 0; + } +} + + // Construct as copy of BiIndirectList<T> template<class T> Foam::List<T>::List(const BiIndirectList<T>& lst) @@ -567,6 +613,28 @@ void Foam::List<T>::operator=(const IndirectList<T>& lst) } +// Assignment operator. Takes linear time. +template<class T> +void Foam::List<T>::operator=(const UIndirectList<T>& lst) +{ + if (lst.size() != this->size_) + { + if (this->v_) delete[] this->v_; + this->v_ = 0; + this->size_ = lst.size(); + if (this->size_) this->v_ = new T[this->size_]; + } + + if (this->size_) + { + forAll(*this, i) + { + this->operator[](i) = lst[i]; + } + } +} + + // Assignment operator. Takes linear time. template<class T> void Foam::List<T>::operator=(const BiIndirectList<T>& lst) diff --git a/src/OpenFOAM/containers/Lists/List/List.H b/src/OpenFOAM/containers/Lists/List/List.H index 0c08eed8fef74db4fbaaefd2bec9abb41d88b874..86876cff713e4bbba54302df8a51bb127370a9d0 100644 --- a/src/OpenFOAM/containers/Lists/List/List.H +++ b/src/OpenFOAM/containers/Lists/List/List.H @@ -66,8 +66,10 @@ template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> class DynamicList; template<class T> class SortableList; template<class T> class IndirectList; +template<class T> class UIndirectList; template<class T> class BiIndirectList; +typedef UList<label> unallocLabelList; /*---------------------------------------------------------------------------*\ Class List Declaration @@ -112,6 +114,9 @@ public: //- Construct as copy or re-use as specified. List(List<T>&, bool reUse); + //- Construct as subset. + List(const UList<T>&, const unallocLabelList& mapAddressing); + //- Construct given start and end iterators. template<class InputIterator> List(InputIterator first, InputIterator last); @@ -129,6 +134,9 @@ public: //- Construct as copy of IndirectList<T> List(const IndirectList<T>&); + //- Construct as copy of UIndirectList<T> + List(const UIndirectList<T>&); + //- Construct as copy of BiIndirectList<T> List(const BiIndirectList<T>&); @@ -206,6 +214,9 @@ public: //- Assignment from IndirectList operator. Takes linear time. void operator=(const IndirectList<T>&); + //- Assignment from UIndirectList operator. Takes linear time. + void operator=(const UIndirectList<T>&); + //- Assignment from BiIndirectList operator. Takes linear time. void operator=(const BiIndirectList<T>&); diff --git a/applications/test/IndirectList/IndirectList.H b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H similarity index 70% rename from applications/test/IndirectList/IndirectList.H rename to src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H index b2f3bfa2b8c462976c6b191dc20457e585aea8ad..c762bdba7d57da1ca12e5b0d8dff12e94a6f5bf7 100644 --- a/applications/test/IndirectList/IndirectList.H +++ b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H @@ -23,17 +23,19 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - Foam::IndirectList + Foam::UIndirectList Description + A List with indirect addressing. Like IndirectList but does not store + addressing. SourceFiles - IndirectListI.H + UIndirectListI.H \*---------------------------------------------------------------------------*/ -#ifndef IndirectList_H -#define IndirectList_H +#ifndef UIndirectList_H +#define UIndirectList_H #include "List.H" @@ -43,22 +45,16 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class IndirectList Declaration + Class UIndirectList Declaration \*---------------------------------------------------------------------------*/ template<class T> -class IndirectList +class UIndirectList { // Private data - const UList<T>& completeList_; - List<label> addresses_; - - - // Private Member Functions - - //- Disallow default bitwise assignment - void operator=(const IndirectList<T>&); + UList<T>& completeList_; + const UList<label>& addressing_; public: @@ -66,7 +62,7 @@ public: // Constructors //- Construct given the complete list and the addressing array - inline IndirectList(const UList<T>&, const List<label>&); + inline UIndirectList(const UList<T>&, const UList<label>&); // Member Functions @@ -74,14 +70,28 @@ public: // Access inline label size() const; + inline bool empty() const; + inline const UList<T>& completeList() const; - inline const List<label>& addresses() const; + inline const List<label>& addressing() const; // Member Operators + //- Return the addressed elements as a List + inline List<T> operator()() const; + + //- Return non-const access to an element + inline T& operator[](const label); + //- Return const access to an element inline const T& operator[](const label) const; + + //- Assignment from UList of addressed elements + inline void operator=(const UList<T>&); + + //- Assignment of all entries to the given value + inline void operator=(const T&); }; @@ -91,7 +101,7 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#include "IndirectListI.H" +#include "UIndirectListI.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListI.H b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListI.H new file mode 100644 index 0000000000000000000000000000000000000000..ff8b3ebbd6d0ff9146cc259baf09bb0004218bb9 --- /dev/null +++ b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListI.H @@ -0,0 +1,130 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class T> +inline Foam::UIndirectList<T>::UIndirectList +( + const UList<T>& completeList, + const UList<label>& addr +) +: + completeList_(const_cast<UList<T>&>(completeList)), + addressing_(addr) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class T> +inline Foam::label Foam::UIndirectList<T>::size() const +{ + return addressing_.size(); +} + + +template<class T> +inline bool Foam::UIndirectList<T>::empty() const +{ + return addressing_.empty(); +} + + +template<class T> +inline const Foam::UList<T>& Foam::UIndirectList<T>::completeList() const +{ + return completeList_; +} + + +template<class T> +inline const Foam::List<Foam::label>& Foam::UIndirectList<T>::addressing() const +{ + return addressing_; +} + + +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +template<class T> +inline Foam::List<T> Foam::UIndirectList<T>::operator()() const +{ + List<T> result(size()); + + forAll(*this, i) + { + result[i] = operator[](i); + } + + return result; +} + + +template<class T> +inline T& Foam::UIndirectList<T>::operator[](const label i) +{ + return completeList_[addressing_[i]]; +} + + +template<class T> +inline const T& Foam::UIndirectList<T>::operator[](const label i) const +{ + return completeList_[addressing_[i]]; +} + + +template<class T> +inline void Foam::UIndirectList<T>::operator=(const UList<T>& ae) +{ + if (addressing_.size() != ae.size()) + { + FatalErrorIn("UIndirectList<T>::operator=(const UList<T>&)") + << "Addressing and list of addressed elements " + "have different sizes: " + << addressing_.size() << " " << ae.size() + << abort(FatalError); + } + + forAll(addressing_, i) + { + completeList_[addressing_[i]] = ae[i]; + } +} + + +template<class T> +inline void Foam::UIndirectList<T>::operator=(const T& t) +{ + forAll(addressing_, i) + { + completeList_[addressing_[i]] = t; + } +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/objectRegistry/objectRegistry.C b/src/OpenFOAM/db/objectRegistry/objectRegistry.C index 55cf75fb0f02cc0ce7aa61d90989b38fed333ebc..cbd841f8aeefc1288ce69ec7fc29d06124c9b575 100644 --- a/src/OpenFOAM/db/objectRegistry/objectRegistry.C +++ b/src/OpenFOAM/db/objectRegistry/objectRegistry.C @@ -50,7 +50,8 @@ Foam::objectRegistry::objectRegistry IOobject::NO_READ, IOobject::AUTO_WRITE, false - ) + ), + true // to flag that this is the top-level regIOobject ), HashTable<regIOobject*>(nIoObjects), time_(t), diff --git a/src/OpenFOAM/db/regIOobject/regIOobject.C b/src/OpenFOAM/db/regIOobject/regIOobject.C index fde596e89f2fbd45cc6c21861b3152042c2566f7..a5a5e8e1e3dfbe847b6d4b5667e8faaf8af5149a 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobject.C +++ b/src/OpenFOAM/db/regIOobject/regIOobject.C @@ -41,13 +41,18 @@ int Foam::regIOobject::fileModificationSkew // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // Construct from IOobject -Foam::regIOobject::regIOobject(const IOobject& io) +Foam::regIOobject::regIOobject(const IOobject& io, const bool isTime) : IOobject(io), registered_(false), ownedByRegistry_(false), lastModified_(0), - eventNo_(db().getEvent()), + eventNo_ // Do not get event for top level Time database + ( + isTime + ? 0 + : db().getEvent() + ), isPtr_(NULL) { // Register with objectRegistry if requested @@ -156,7 +161,7 @@ bool Foam::regIOobject::checkOut() } -bool Foam::regIOobject::uptodate(const word& a) const +bool Foam::regIOobject::upToDate(const word& a) const { if (db().lookupObject<regIOobject>(a).eventNo() >= eventNo_) { @@ -169,7 +174,7 @@ bool Foam::regIOobject::uptodate(const word& a) const } -bool Foam::regIOobject::uptodate(const word& a, const word& b) const +bool Foam::regIOobject::upToDate(const word& a, const word& b) const { if ( @@ -186,7 +191,7 @@ bool Foam::regIOobject::uptodate(const word& a, const word& b) const } -bool Foam::regIOobject::uptodate +bool Foam::regIOobject::upToDate ( const word& a, const word& b, @@ -209,7 +214,7 @@ bool Foam::regIOobject::uptodate } -bool Foam::regIOobject::uptodate +bool Foam::regIOobject::upToDate ( const word& a, const word& b, @@ -234,8 +239,8 @@ bool Foam::regIOobject::uptodate } -//- Flag me as uptodate -void Foam::regIOobject::setUptodate() +//- Flag me as up to date +void Foam::regIOobject::setUpToDate() { eventNo_ = db().getEvent(); } diff --git a/src/OpenFOAM/db/regIOobject/regIOobject.H b/src/OpenFOAM/db/regIOobject/regIOobject.H index 9c6ae890652555c4a2de1e5f953999b70609091b..d2c9a3dcbe6e0788e909092b04bcc87860e3cd55 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobject.H +++ b/src/OpenFOAM/db/regIOobject/regIOobject.H @@ -99,8 +99,9 @@ public: // Constructors - //- Construct from IOobject - regIOobject(const IOobject&); + //- Construct from IOobject. Optional flag for if IOobject is the + // top level regIOobject. + regIOobject(const IOobject&, const bool isTime = false); //- Construct as copy regIOobject(const regIOobject&); @@ -154,14 +155,20 @@ public: inline label& eventNo(); //- Am I uptodate with respect to other regIOobjects - bool uptodate(const word&) const; - bool uptodate(const word&, const word&) const; - bool uptodate(const word&, const word&, const word&) const; - bool uptodate(const word&, const word&, const word&, const word&) - const; - - //- Flag me as uptodate - void setUptodate(); + bool upToDate(const word&) const; + bool upToDate(const word&, const word&) const; + bool upToDate(const word&, const word&, const word&) const; + bool upToDate + ( + const word&, + const word&, + const word&, + const word& + ) const; + + //- Flag me as up to date + void setUpToDate(); + // Edit diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C index 794143d76b9d8c8b64c7961ec23eaafe44d8dea5..705ee5e2b4e7f27207a9e53f7e2e31b9aebce160 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C @@ -649,6 +649,7 @@ typename Foam::GeometricField<Type, PatchField, GeoMesh>::DimensionedInternalField& Foam::GeometricField<Type, PatchField, GeoMesh>::dimensionedInternalField() { + this->setUpToDate(); storeOldTimes(); return *this; } @@ -659,6 +660,7 @@ typename Foam::GeometricField<Type, PatchField, GeoMesh>::InternalField& Foam::GeometricField<Type, PatchField, GeoMesh>::internalField() { + this->setUpToDate(); storeOldTimes(); return *this; } @@ -670,6 +672,7 @@ typename Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricBoundaryField& Foam::GeometricField<Type, PatchField, GeoMesh>::boundaryField() { + this->setUpToDate(); storeOldTimes(); return boundaryField_; } @@ -822,6 +825,7 @@ template<class Type, template<class> class PatchField, class GeoMesh> void Foam::GeometricField<Type, PatchField, GeoMesh>:: correctBoundaryConditions() { + this->setUpToDate(); storeOldTimes(); boundaryField_.evaluate(); } diff --git a/src/OpenFOAM/matrices/solution/solution.C b/src/OpenFOAM/matrices/solution/solution.C index 054e227a757cb3ef9d97c52af3deea70284f8e63..8672f32753db3db085a25cffa0bc1ae9d9df7ba9 100644 --- a/src/OpenFOAM/matrices/solution/solution.C +++ b/src/OpenFOAM/matrices/solution/solution.C @@ -27,7 +27,7 @@ License #include "solution.H" #include "Time.H" -// these are for old syntax compatibility: +// These are for old syntax compatibility: #include "BICCG.H" #include "ICCG.H" #include "IStringStream.H" @@ -36,7 +36,7 @@ License int Foam::solution::debug(::Foam::debug::debugSwitch("solution", 0)); -// list of sub-dictionaries to rewrite +// List of sub-dictionaries to rewrite //! @cond localScope static const Foam::List<Foam::word> subDictNames ( @@ -59,7 +59,12 @@ Foam::solution::solution(const objectRegistry& obr, const fileName& dictName) IOobject::NO_WRITE ) ), - relaxationFactors_(ITstream("relaxationFactors", tokenList())()), + relaxationFactors_ + ( + ITstream("relaxationFactors", + tokenList())() + ), + defaultRelaxationFactor_(0), solvers_(ITstream("solvers", tokenList())()) { read(); @@ -157,6 +162,11 @@ bool Foam::solution::read() relaxationFactors_ = dict.subDict("relaxationFactors"); } + if (relaxationFactors_.found("default")) + { + relaxationFactors_.lookup("default") >> defaultRelaxationFactor_; + } + if (dict.found("solvers")) { solvers_ = dict.subDict("solvers"); @@ -192,7 +202,9 @@ bool Foam::solution::relax(const word& name) const Info<< "Find relax for " << name << endl; } - return relaxationFactors_.found(name); + return + relaxationFactors_.found(name) + || relaxationFactors_.found("default"); } @@ -203,7 +215,26 @@ Foam::scalar Foam::solution::relaxationFactor(const word& name) const Info<< "Lookup relaxationFactor for " << name << endl; } - return readScalar(relaxationFactors_.lookup(name)); + if (relaxationFactors_.found(name)) + { + return readScalar(relaxationFactors_.lookup(name)); + } + else if (defaultRelaxationFactor_ > SMALL) + { + return defaultRelaxationFactor_; + } + else + { + FatalIOErrorIn + ( + "Foam::solution::relaxationFactor(const word& name)", + relaxationFactors_ + ) << "Cannot find relaxationFactor for '" << name + << "' or a suitable default value." + << exit(FatalIOError); + + return 0; + } } diff --git a/src/OpenFOAM/matrices/solution/solution.H b/src/OpenFOAM/matrices/solution/solution.H index 6b361d9ff201200deaeae292dc436937be05f782..d3bf0084750740d76e3922d962f9ff2b45d40ba7 100644 --- a/src/OpenFOAM/matrices/solution/solution.H +++ b/src/OpenFOAM/matrices/solution/solution.H @@ -56,6 +56,9 @@ class solution //- Dictionary of relaxation factors for all the fields dictionary relaxationFactors_; + //- Optional default relaxation factor for all the fields + scalar defaultRelaxationFactor_; + //- Dictionary of solver parameters for all the fields dictionary solvers_; diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C index e53330b6a49b83477472a435406d84207d82bd30..0436132b58db34a2aad4d6d6b55d9483161b50df 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C @@ -629,7 +629,7 @@ Foam::pointField Foam::globalMeshData::sharedPoints() const toMaster << sharedPointAddr_ - << IndirectList<point>(mesh_.points(), sharedPointLabels_)(); + << UIndirectList<point>(mesh_.points(), sharedPointLabels_)(); } // Receive sharedPoints diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalPoints.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalPoints.C index 34e9968472c5d25d1e09b6c90359bf3dc91e7cd6..bd94a3014200615cd558dfd26b946050872bb429 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalPoints.C +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalPoints.C @@ -653,8 +653,8 @@ void Foam::globalPoints::sendSharedPoints(const labelList& changedIndices) const } toNeighbour - << IndirectList<label>(sharedPointAddr_, changedIndices)() - << IndirectList<label>(sharedPointLabels_, changedIndices)(); + << UIndirectList<label>(sharedPointAddr_, changedIndices)() + << UIndirectList<label>(sharedPointLabels_, changedIndices)(); } } } diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C index 5dac2ebe9c83f54f79a12c6349d4f13477acc90f..f4cbe6e2f3a60e247b7ca2a384b3845c3dc58eec 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C @@ -124,7 +124,7 @@ Foam::List<Foam::labelPair> Foam::mapDistribute::schedule ); // Processors involved in my schedule - return IndirectList<labelPair>(allComms, mySchedule); + return UIndirectList<labelPair>(allComms, mySchedule); //if (debug) diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C index 19c08e5504fc895005d3d9047711721cb0d3b27e..23220a6777eee911ed372a6110ca5b4e6621d76e 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C @@ -188,11 +188,11 @@ void Foam::cyclicPolyPatch::calcTransforms() << endl << "Mesh face:" << start()+facei << " vertices:" - << IndirectList<point>(points, operator[](facei))() + << UIndirectList<point>(points, operator[](facei))() << endl << "Neighbour face:" << start()+nbrFacei << " vertices:" - << IndirectList<point>(points, operator[](nbrFacei))() + << UIndirectList<point>(points, operator[](nbrFacei))() << endl << "Rerun with cyclic debug flag set" << " for more information." << exit(FatalError); @@ -403,12 +403,12 @@ bool Foam::cyclicPolyPatch::getGeometricHalves fileName nm0(casePath/name()+"_half0_faces.obj"); Pout<< "cyclicPolyPatch::getGeometricHalves : Writing half0" << " faces to OBJ file " << nm0 << endl; - writeOBJ(nm0, IndirectList<face>(pp, half0ToPatch)(), pp.points()); + writeOBJ(nm0, UIndirectList<face>(pp, half0ToPatch)(), pp.points()); fileName nm1(casePath/name()+"_half1_faces.obj"); Pout<< "cyclicPolyPatch::getGeometricHalves : Writing half1" << " faces to OBJ file " << nm1 << endl; - writeOBJ(nm1, IndirectList<face>(pp, half1ToPatch)(), pp.points()); + writeOBJ(nm1, UIndirectList<face>(pp, half1ToPatch)(), pp.points()); } // Dump face centres @@ -672,7 +672,7 @@ bool Foam::cyclicPolyPatch::matchAnchors ) << "Patch:" << name() << " : " << "Cannot find point on face " << f << " with vertices:" - << IndirectList<point>(pp.points(), f)() + << UIndirectList<point>(pp.points(), f)() << " that matches point " << wantedAnchor << " when matching the halves of cyclic patch " << name() << endl @@ -1133,8 +1133,8 @@ bool Foam::cyclicPolyPatch::order half1ToPatch = half0ToPatch + halfSize; // Get faces - faceList half0Faces(IndirectList<face>(pp, half0ToPatch)); - faceList half1Faces(IndirectList<face>(pp, half1ToPatch)); + faceList half0Faces(UIndirectList<face>(pp, half0ToPatch)); + faceList half1Faces(UIndirectList<face>(pp, half1ToPatch)); // Get geometric quantities pointField half0Ctrs, half1Ctrs, anchors0, ppPoints; @@ -1221,8 +1221,8 @@ bool Foam::cyclicPolyPatch::order } // And redo all matching - half0Faces = IndirectList<face>(pp, half0ToPatch); - half1Faces = IndirectList<face>(pp, half1ToPatch); + half0Faces = UIndirectList<face>(pp, half0ToPatch); + half1Faces = UIndirectList<face>(pp, half1ToPatch); getCentresAndAnchors ( @@ -1334,8 +1334,8 @@ bool Foam::cyclicPolyPatch::order if (baffleI == halfSize) { // And redo all matching - half0Faces = IndirectList<face>(pp, half0ToPatch); - half1Faces = IndirectList<face>(pp, half1ToPatch); + half0Faces = UIndirectList<face>(pp, half0ToPatch); + half1Faces = UIndirectList<face>(pp, half1ToPatch); getCentresAndAnchors ( @@ -1420,8 +1420,8 @@ bool Foam::cyclicPolyPatch::order } // And redo all matching - half0Faces = IndirectList<face>(pp, half0ToPatch); - half1Faces = IndirectList<face>(pp, half1ToPatch); + half0Faces = UIndirectList<face>(pp, half0ToPatch); + half1Faces = UIndirectList<face>(pp, half1ToPatch); getCentresAndAnchors ( diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C index 1e045e6d774bef9704cd65861836dd394535823d..00091293fa7cdb23283b3951acd5cff96af38d8f 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C @@ -207,7 +207,7 @@ void Foam::processorPolyPatch::calcGeometry() << endl << "Mesh face:" << start()+facei << " vertices:" - << IndirectList<point>(points(), operator[](facei))() + << UIndirectList<point>(points(), operator[](facei))() << endl << "Rerun with processor debug flag set for" << " more information." << exit(FatalError); @@ -731,7 +731,7 @@ bool Foam::processorPolyPatch::order << " : " << "Cannot find point on face " << pp[oldFaceI] << " with vertices " - << IndirectList<point>(pp.points(), pp[oldFaceI])() + << UIndirectList<point>(pp.points(), pp[oldFaceI])() << " that matches point " << wantedAnchor << " when matching the halves of processor patch " << name() << "Continuing with incorrect face ordering from now on!" diff --git a/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C b/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C index 4cf3d54ebbd6fc214c3d5e24f9283af54d6df4a6..f1ffe42d74775463842b240b476510f58c3c75c0 100644 --- a/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C +++ b/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C @@ -87,8 +87,7 @@ Foam::PackedBoolList Foam::syncTools::getMasterPoints(const polyMesh& mesh) labelList minProc(mesh.globalData().nGlobalPoints(), labelMax); - IndirectList<label>(minProc, sharedPointAddr) = - Pstream::myProcNo(); + UIndirectList<label>(minProc, sharedPointAddr) = Pstream::myProcNo(); Pstream::listCombineGather(minProc, minEqOp<label>()); Pstream::listCombineScatter(minProc); @@ -207,8 +206,7 @@ Foam::PackedBoolList Foam::syncTools::getMasterEdges(const polyMesh& mesh) labelList minProc(mesh.globalData().nGlobalEdges(), labelMax); - IndirectList<label>(minProc, sharedEdgeAddr) = - Pstream::myProcNo(); + UIndirectList<label>(minProc, sharedEdgeAddr) = Pstream::myProcNo(); Pstream::listCombineGather(minProc, minEqOp<label>()); Pstream::listCombineScatter(minProc); diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H index 8eff78be3e5dedc24d205f37c4099c2de682801d..6fb1332dc430a4622daa21bb82e609a4cb682b02 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H @@ -37,7 +37,6 @@ SourceFiles #define ZoneMesh_H #include "List.H" -#include "IndirectList.H" #include "regIOobject.H" #include "HashSet.H" #include "pointFieldsFwd.H" diff --git a/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsEdgeOwner.C b/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsEdgeOwner.C index 2c1cac1be77752d826af2e25620fed5b26d2301b..3771a12537bf854f2384bd6b9cf4667bd0f64f6d 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsEdgeOwner.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsEdgeOwner.C @@ -81,7 +81,7 @@ Foam::PatchTools::edgeOwner << "Edge " << edgeI << " vertices:" << edges[edgeI] << " is used by faces " << nbrFaces << " vertices:" - << IndirectList<Face>(localFaces, nbrFaces)() + << UIndirectList<Face>(localFaces, nbrFaces)() << " none of which use the edge vertices in the same order" << nl << "I give up" << abort(FatalError); } diff --git a/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsSortEdges.C b/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsSortEdges.C index 8e985bcfa8dd86377d0fdf257489e8d7b390d3f3..1fe3be63f7153db66a69bf781a10d94fc1001f3f 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsSortEdges.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsSortEdges.C @@ -108,7 +108,7 @@ Foam::PatchTools::sortedEdgeFaces faceAngles.sort(); - sortedEdgeFaces[edgeI] = IndirectList<label> + sortedEdgeFaces[edgeI] = UIndirectList<label> ( faceNbs, faceAngles.indices() diff --git a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C index 30c5839cc46587435da0fbc71ee413b2152388cf..aa7ecddf8b8660aef0699fbdeea5e0ac0992f715 100644 --- a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C +++ b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C @@ -1238,10 +1238,7 @@ void Foam::autoSnapDriver::smoothDisplacement magDisp().write(); Pout<< "Writing actual patch displacement ..." << endl; - vectorField actualPatchDisp - ( - IndirectList<point>(disp, pp.meshPoints())() - ); + vectorField actualPatchDisp(disp, pp.meshPoints()); dumpMove ( mesh.time().path()/"actualPatchDisplacement.obj", diff --git a/src/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C b/src/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C index 6bbb1c8d3987ebf35cc723c407340a3ad86f2962..030f6adec75966c4f2d52195c49fa80605ff3796 100644 --- a/src/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C +++ b/src/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C @@ -922,7 +922,7 @@ void Foam::refinementSurfaces::findNearest List<pointIndexHit>& hitInfo ) const { - labelList geometries(IndirectList<label>(surfaces_, surfacesToTest)); + labelList geometries(UIndirectList<label>(surfaces_, surfacesToTest)); // Do the tests. Note that findNearest returns index in geometries. searchableSurfacesQueries::findNearest @@ -955,7 +955,7 @@ void Foam::refinementSurfaces::findNearestRegion labelList& hitRegion ) const { - labelList geometries(IndirectList<label>(surfaces_, surfacesToTest)); + labelList geometries(UIndirectList<label>(surfaces_, surfacesToTest)); // Do the tests. Note that findNearest returns index in geometries. List<pointIndexHit> hitInfo; @@ -991,7 +991,7 @@ void Foam::refinementSurfaces::findNearestRegion List<pointIndexHit> localHits ( - IndirectList<pointIndexHit> + UIndirectList<pointIndexHit> ( hitInfo, localIndices diff --git a/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C b/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C index 5273914def0fc5a62974dddf4515e7a122ca7942..74993262d4eb971ba390425264caadd830352f2c 100644 --- a/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C +++ b/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C @@ -718,7 +718,7 @@ void Foam::fvMeshDistribute::getNeighbourData // Which processor they will end up on const labelList newProc ( - IndirectList<label>(distribution, pp.faceCells()) + UIndirectList<label>(distribution, pp.faceCells()) ); OPstream toNeighbour(Pstream::blocking, procPatch.neighbProcNo()); @@ -1192,7 +1192,7 @@ void Foam::fvMeshDistribute::sendMesh // // forAll(cellZones, zoneI) // { - // IndirectList<label>(cellZoneID, cellZones[zoneI]) = zoneI; + // UIndirectList<label>(cellZoneID, cellZones[zoneI]) = zoneI; // } //} diff --git a/src/dynamicMesh/meshCut/cellLooper/hexCellLooper.C b/src/dynamicMesh/meshCut/cellLooper/hexCellLooper.C index 73f7bca59e4920f6e6b3a1867036187cc95f83cc..e31ad4c2a13d12bf46ee972702e6ae4b78f72e13 100644 --- a/src/dynamicMesh/meshCut/cellLooper/hexCellLooper.C +++ b/src/dynamicMesh/meshCut/cellLooper/hexCellLooper.C @@ -269,7 +269,7 @@ bool Foam::hexCellLooper::cut { FatalErrorIn("hexCellLooper::walkHex") << "Face:" << faceVerts << " on points:" << facePoints << endl - << IndirectList<point>(facePoints, faceVerts)() + << UIndirectList<point>(facePoints, faceVerts)() << abort(FatalError); } } diff --git a/src/dynamicMesh/motionSmoother/polyMeshGeometry/polyMeshGeometry.C b/src/dynamicMesh/motionSmoother/polyMeshGeometry/polyMeshGeometry.C index f2f7ec17bee2590ad940f864d3823d1307174323..37882a2cc0821ba68a7ed3181d630bb2412287a7 100644 --- a/src/dynamicMesh/motionSmoother/polyMeshGeometry/polyMeshGeometry.C +++ b/src/dynamicMesh/motionSmoother/polyMeshGeometry/polyMeshGeometry.C @@ -103,8 +103,8 @@ void Foam::polyMeshGeometry::updateCellCentresAndVols ) { // Clear the fields for accumulation - IndirectList<vector>(cellCentres_, changedCells) = vector::zero; - IndirectList<scalar>(cellVolumes_, changedCells) = 0.0; + UIndirectList<vector>(cellCentres_, changedCells) = vector::zero; + UIndirectList<scalar>(cellVolumes_, changedCells) = 0.0; const labelList& own = mesh_.faceOwner(); const labelList& nei = mesh_.faceNeighbour(); @@ -112,9 +112,9 @@ void Foam::polyMeshGeometry::updateCellCentresAndVols // first estimate the approximate cell centre as the average of face centres vectorField cEst(mesh_.nCells()); - IndirectList<vector>(cEst, changedCells) = vector::zero; + UIndirectList<vector>(cEst, changedCells) = vector::zero; scalarField nCellFaces(mesh_.nCells()); - IndirectList<scalar>(nCellFaces, changedCells) = 0.0; + UIndirectList<scalar>(nCellFaces, changedCells) = 0.0; forAll(changedFaces, i) { diff --git a/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C b/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C index 237a2f3cb7dc27052faba2c1e5607a75a9380f1f..7820bcd70bf34719c207cf575cae9b1e4b7c1682 100644 --- a/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C +++ b/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C @@ -32,7 +32,6 @@ License #include "treeDataFace.H" #include "indexedOctree.H" #include "OFstream.H" -#include "IndirectList.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -153,11 +152,7 @@ void Foam::faceCoupleInfo::writePointsFaces() const ( "cutToMasterPoints.obj", m.localPoints(), - pointField - ( - IndirectList<point>(c.localPoints(), masterToCutPoints_)() - ) - ); + pointField(c.localPoints(), masterToCutPoints_)); } { Pout<< "Writing cutToSlavePoints to cutToSlavePoints.obj" << endl; @@ -166,10 +161,7 @@ void Foam::faceCoupleInfo::writePointsFaces() const ( "cutToSlavePoints.obj", s.localPoints(), - pointField - ( - IndirectList<point>(c.localPoints(), slaveToCutPoints_)() - ) + pointField(c.localPoints(), slaveToCutPoints_) ); } @@ -405,7 +397,7 @@ Foam::label Foam::faceCoupleInfo::mostAlignedCutEdge if (report) { Pout<< "mostAlignedEdge : finding nearest edge among " - << IndirectList<edge>(cutFaces().edges(), pEdges)() + << UIndirectList<edge>(cutFaces().edges(), pEdges)() << " connected to point " << pointI << " coord:" << localPoints[pointI] << " running between " << edgeStart << " coord:" @@ -623,7 +615,7 @@ void Foam::faceCoupleInfo::setCutEdgeToPoints(const labelList& cutToMasterEdges) "(const labelList&)" ) << " unsplitEdge:" << unsplitEdge << " does not correspond to split edges " - << IndirectList<edge>(cutEdges, stringedEdges)() + << UIndirectList<edge>(cutEdges, stringedEdges)() << abort(FatalError); } } @@ -631,7 +623,7 @@ void Foam::faceCoupleInfo::setCutEdgeToPoints(const labelList& cutToMasterEdges) //Pout<< "For master edge:" // << unsplitEdge // << " Found stringed points " - // << IndirectList<point> + // << UIndirectList<point> // ( // cutFaces().localPoints(), // splitPoints.shrink() @@ -664,9 +656,9 @@ Foam::label Foam::faceCoupleInfo::matchFaces "(const scalar, const face&, const pointField&" ", const face&, const pointField&)" ) << "Different sizes for supposedly matching faces." << nl - << "f0:" << f0 << " coords:" << IndirectList<point>(points0, f0)() + << "f0:" << f0 << " coords:" << UIndirectList<point>(points0, f0)() << nl - << "f1:" << f1 << " coords:" << IndirectList<point>(points1, f1)() + << "f1:" << f1 << " coords:" << UIndirectList<point>(points1, f1)() << abort(FatalError); } @@ -721,10 +713,9 @@ Foam::label Foam::faceCoupleInfo::matchFaces ", const face&, const pointField&)" ) << "No unique match between two faces" << nl << "Face " << f0 << " coords " - << IndirectList<point>(points0, f0)() - << nl + << UIndirectList<point>(points0, f0)() << nl << "Face " << f1 << " coords " - << IndirectList<point>(points1, f1)() + << UIndirectList<point>(points1, f1)() << "when using tolerance " << absTol << " and forwardMatching:" << sameOrientation << abort(FatalError); @@ -1575,7 +1566,7 @@ void Foam::faceCoupleInfo::perfectPointMatch // Use compaction lists to renumber cutPoints. - cutPoints_ = IndirectList<point>(cutPoints_, compactToCut)(); + cutPoints_ = UIndirectList<point>(cutPoints_, compactToCut)(); { const faceList& cutLocalFaces = cutFaces().localFaces(); @@ -1770,11 +1761,11 @@ void Foam::faceCoupleInfo::subDivisionMatch writeOBJ ( "errorEdges.obj", - IndirectList<edge> + UIndirectList<edge> ( cutFaces().edges(), cutFaces().pointEdges()[cutPointI] - )(), + ), cutFaces().localPoints(), false ); @@ -1894,7 +1885,7 @@ void Foam::faceCoupleInfo::subDivisionMatch "(const polyMesh&, const bool, const scalar)" ) << "Did not match all of cutFaces to a master face" << nl << "First unmatched cut face:" << cutFaceI << " with points:" - << IndirectList<point>(cutFaces().points(), cutF)() + << UIndirectList<point>(cutFaces().points(), cutF)() << nl << "This usually means that the slave patch is not a" << " subdivision of the master patch" diff --git a/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C b/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C index e8366ec3cb57d576edcc9251a637fd52fc18cb6c..ba95f419d3d9dd24dbd0a62b5f315cd13f9b79c1 100644 --- a/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C +++ b/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C @@ -1929,11 +1929,8 @@ Foam::Map<Foam::label> Foam::polyMeshAdder::findSharedPoints //( // pointField // ( - // IndirectList<point> - // ( - // mesh.points(), - // sharedPointLabels - // )() + // mesh.points(), + // sharedPointLabels // ), // mergeDist, // false, diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C index b3902762ef62c25821eb2d90081b672ea4443427..2f842e6d66127b62fb226d79899f1b2fd7876b3a 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C @@ -110,7 +110,7 @@ Foam::labelListList Foam::addPatchCellLayer::calcGlobalEdgeFaces ); // Extract pp part - return IndirectList<labelList>(globalEdgeFaces, meshEdges)(); + return UIndirectList<labelList>(globalEdgeFaces, meshEdges); } @@ -629,7 +629,7 @@ void Foam::addPatchCellLayer::setRefinement { labelList n(mesh_.nPoints(), 0); - IndirectList<label>(n, meshPoints) = nPointLayers; + UIndirectList<label>(n, meshPoints) = nPointLayers; syncTools::syncPointList(mesh_, n, maxEqOp<label>(), 0, false); // Non-synced @@ -706,7 +706,7 @@ void Foam::addPatchCellLayer::setRefinement { pointField d(mesh_.nPoints(), wallPoint::greatPoint); - IndirectList<point>(d, meshPoints) = firstLayerDisp; + UIndirectList<point>(d, meshPoints) = firstLayerDisp; syncTools::syncPointList ( mesh_, diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C index e0fae6f9712208aec54fee1a9014d160a518276a..51c92b035cecb17744c91f7d59f24cc5fabdffda 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C @@ -565,7 +565,7 @@ void Foam::combineFaces::setRefinement const labelList& setFaces = faceSets[setI]; masterFace_[setI] = setFaces[0]; - faceSetsVertices_[setI] = IndirectList<face> + faceSetsVertices_[setI] = UIndirectList<face> ( mesh_.faces(), setFaces diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/edgeCollapser.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/edgeCollapser.C index 53357139ac679b176bb77eee6cea0b31ef2bac96..7727e04c87fbf8f39e15600802388cbf1bdda76e 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/edgeCollapser.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/edgeCollapser.C @@ -28,7 +28,6 @@ License #include "polyMesh.H" #include "polyTopoChange.H" #include "ListOps.H" -#include "IndirectList.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C index f7dd0161cb1c50bafaded81da9ff74cc6a6820f8..af4a37beadfcb089d9f91678cb345f5e9539feec 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C @@ -746,7 +746,7 @@ Foam::label Foam::hexRef8::findLevel FatalErrorIn("hexRef8::findLevel(..)") << "face:" << f - << " level:" << IndirectList<label>(pointLevel_, f)() + << " level:" << UIndirectList<label>(pointLevel_, f)() << " startFp:" << startFp << " wantedLevel:" << wantedLevel << abort(FatalError); @@ -774,7 +774,7 @@ Foam::label Foam::hexRef8::findLevel FatalErrorIn("hexRef8::findLevel(..)") << "face:" << f - << " level:" << IndirectList<label>(pointLevel_, f)() + << " level:" << UIndirectList<label>(pointLevel_, f)() << " startFp:" << startFp << " wantedLevel:" << wantedLevel << abort(FatalError); @@ -823,7 +823,7 @@ void Foam::hexRef8::checkInternalOrientation ) { face compactFace(identity(newFace.size())); - pointField compactPoints(IndirectList<point>(meshMod.points(), newFace)()); + pointField compactPoints(meshMod.points(), newFace); vector n(compactFace.normal(compactPoints)); @@ -869,7 +869,7 @@ void Foam::hexRef8::checkBoundaryOrientation ) { face compactFace(identity(newFace.size())); - pointField compactPoints(IndirectList<point>(meshMod.points(), newFace)()); + pointField compactPoints(meshMod.points(), newFace); vector n(compactFace.normal(compactPoints)); @@ -1308,11 +1308,11 @@ void Foam::hexRef8::createInternalFaces << "cell:" << cellI << " cLevel:" << cLevel << " cell points:" << cPoints << " pointLevel:" - << IndirectList<label>(pointLevel_, cPoints)() + << UIndirectList<label>(pointLevel_, cPoints)() << " face:" << faceI << " f:" << f << " pointLevel:" - << IndirectList<label>(pointLevel_, f)() + << UIndirectList<label>(pointLevel_, f)() << " faceAnchorLevel:" << faceAnchorLevel[faceI] << " faceMidPoint:" << faceMidPoint[faceI] << " faceMidPointI:" << faceMidPointI @@ -1381,11 +1381,11 @@ void Foam::hexRef8::createInternalFaces << "cell:" << cellI << " cLevel:" << cLevel << " cell points:" << cPoints << " pointLevel:" - << IndirectList<label>(pointLevel_, cPoints)() + << UIndirectList<label>(pointLevel_, cPoints)() << " face:" << faceI << " f:" << f << " pointLevel:" - << IndirectList<label>(pointLevel_, f)() + << UIndirectList<label>(pointLevel_, f)() << " faceAnchorLevel:" << faceAnchorLevel[faceI] << " faceMidPoint:" << faceMidPoint[faceI] << " faceMidPointI:" << faceMidPointI @@ -3511,7 +3511,7 @@ Foam::labelListList Foam::hexRef8::setRefinement << " lower level" << endl << "cellPoints:" << cPoints << endl << "pointLevels:" - << IndirectList<label>(pointLevel_, cPoints)() << endl + << UIndirectList<label>(pointLevel_, cPoints)() << endl << abort(FatalError); } } @@ -4473,7 +4473,7 @@ void Foam::hexRef8::checkMesh() const << "Coupled face " << faceI << " on patch " << patchI << " " << mesh_.boundaryMesh()[patchI].name() - << " coords:" << IndirectList<point>(mesh_.points(), f)() + << " coords:" << UIndirectList<point>(mesh_.points(), f)() << " has face area:" << magArea << " (coupled) neighbour face area differs:" << neiFaceAreas[i] @@ -4515,7 +4515,7 @@ void Foam::hexRef8::checkMesh() const << "Coupled face " << faceI << " on patch " << patchI << " " << mesh_.boundaryMesh()[patchI].name() - << " coords:" << IndirectList<point>(mesh_.points(), f)() + << " coords:" << UIndirectList<point>(mesh_.points(), f)() << " has size:" << f.size() << " (coupled) neighbour face has size:" << nVerts[i] @@ -4565,7 +4565,7 @@ void Foam::hexRef8::checkMesh() const << "Coupled face " << faceI << " on patch " << patchI << " " << mesh_.boundaryMesh()[patchI].name() - << " coords:" << IndirectList<point>(mesh_.points(), f)() + << " coords:" << UIndirectList<point>(mesh_.points(), f)() << " has anchor vector:" << anchorVec << " (coupled) neighbour face anchor vector differs:" << anchorPoints[i] diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.C index 8a5005e2fda1012b3f9427e85354360673cbc089..5e4e3f55094112ea408514a215cce03e3f4004cb 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.C @@ -375,7 +375,7 @@ void Foam::removeFaces::mergeFaces //{ // Pout<< "Modifying masterface " << faceI // << " from faces:" << faceLabels - // << " old verts:" << IndirectList<face>(mesh_.faces(), faceLabels) + // << " old verts:" << UIndirectList<face>(mesh_.faces(), faceLabels) // << " for new verts:" // << mergedFace // << " possibly new owner " << own diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/removePoints.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/removePoints.C index 48532375ab9b79175d9966efd7acf87201b8686f..d03b302436ab5c88342b8b226f84e0e2932caffd 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/removePoints.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/removePoints.C @@ -353,7 +353,7 @@ void Foam::removePoints::setRefinement // Points from the mesh List<point> meshPoints ( - IndirectList<point> + UIndirectList<point> ( mesh_.points(), mesh_.faces()[savedFaceLabels_[saveI]] // mesh face diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchCutFaces.C b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchCutFaces.C index d15a6ddea53fa4c55a507725e5802826e420ab84..c84ab45d70135ae7c7534efd6698f3620e3a43e8 100644 --- a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchCutFaces.C +++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchCutFaces.C @@ -202,7 +202,7 @@ void Foam::enrichedPatch::calcCutFaces() const // Grab the next point options // Pout << "curPointLabel: " << mp[curPointLabel] << endl; const labelList& nextPoints = pp[curPointLabel]; -// Pout << "nextPoints: " << IndirectList<label>(mp, nextPoints) << endl; +// Pout << "nextPoints: " << UIndirectList<label>(mp, nextPoints) << endl; // Get the vector along the edge and the right vector vector ahead = curPoint - lp[prevPointLabel]; ahead -= normal*(normal & ahead); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/directMappedFixedValue/directMappedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/directMappedFixedValue/directMappedFixedValueFvPatchField.C index f226eef8d6cc2195abcc50bc877ffcf099993941..5322cbf47b20cd663696118452b6bdc382dd49a6 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/directMappedFixedValue/directMappedFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/directMappedFixedValue/directMappedFixedValueFvPatchField.C @@ -165,7 +165,7 @@ void directMappedFixedValueFvPatchField<Type>::getNewValues if (Pstream::myProcNo() == sendProc) { OPstream toProc(Pstream::scheduled, recvProc); - toProc<< IndirectList<Type>(sendValues, sendLabels[recvProc])(); + toProc<< UIndirectList<Type>(sendValues, sendLabels[recvProc])(); } else { @@ -188,7 +188,11 @@ void directMappedFixedValueFvPatchField<Type>::getNewValues // Do data from myself { - IndirectList<Type> fromFld(sendValues, sendLabels[Pstream::myProcNo()]); + UIndirectList<Type> fromFld + ( + sendValues, + sendLabels[Pstream::myProcNo()] + ); // Destination faces const labelList& faceLabels = receiveFaceLabels[Pstream::myProcNo()]; diff --git a/src/finiteVolume/fields/fvPatchFields/derived/directMappedVelocityFluxFixedValue/directMappedVelocityFluxFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/directMappedVelocityFluxFixedValue/directMappedVelocityFluxFixedValueFvPatchField.C index 106d478eddd147a8ef4bfad437cf74b6c6f58fe8..92bf63e8c64c96a9722f3ebea511785b4e60dbb3 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/directMappedVelocityFluxFixedValue/directMappedVelocityFluxFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/directMappedVelocityFluxFixedValue/directMappedVelocityFluxFixedValueFvPatchField.C @@ -162,8 +162,8 @@ void directMappedVelocityFluxFixedValueFvPatchField::getNewValues if (Pstream::myProcNo() == sendProc) { OPstream toProc(Pstream::scheduled, recvProc); - toProc<< IndirectList<vector>(sendUValues, sendLabels[recvProc])(); - toProc<< IndirectList<scalar> + toProc<< UIndirectList<vector>(sendUValues, sendLabels[recvProc])(); + toProc<< UIndirectList<scalar> ( sendPhiValues, sendLabels[recvProc] @@ -192,13 +192,13 @@ void directMappedVelocityFluxFixedValueFvPatchField::getNewValues // Do data from myself { - IndirectList<vector> fromUFld + UIndirectList<vector> fromUFld ( sendUValues, sendLabels[Pstream::myProcNo()] ); - IndirectList<scalar> fromPhiFld + UIndirectList<scalar> fromPhiFld ( sendPhiValues, sendLabels[Pstream::myProcNo()] diff --git a/src/finiteVolume/finiteVolume/fvSchemes/fvSchemes.C b/src/finiteVolume/finiteVolume/fvSchemes/fvSchemes.C index 979d85e0d10ab2df814fb9dc2e2860e5aef895f9..b66d628cae1e98209cdeb1ce8784811e6cfb8e51 100644 --- a/src/finiteVolume/finiteVolume/fvSchemes/fvSchemes.C +++ b/src/finiteVolume/finiteVolume/fvSchemes/fvSchemes.C @@ -29,14 +29,11 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -namespace Foam -{ - -int fvSchemes::debug(Foam::debug::debugSwitch("fvSchemes", false)); +int Foam::fvSchemes::debug(Foam::debug::debugSwitch("fvSchemes", false)); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -fvSchemes::fvSchemes(const objectRegistry& obr) +Foam::fvSchemes::fvSchemes(const objectRegistry& obr) : IOdictionary ( @@ -124,7 +121,12 @@ fvSchemes::fvSchemes(const objectRegistry& obr) ITstream(objectPath() + "::fluxRequired", tokenList())() ), - defaultFluxRequired_(false) + defaultFluxRequired_(false), + cacheFields_ + ( + ITstream(objectPath() + "::cacheFields", + tokenList())() + ) { read(); } @@ -132,7 +134,7 @@ fvSchemes::fvSchemes(const objectRegistry& obr) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -bool fvSchemes::read() +bool Foam::fvSchemes::read() { if (regIOobject::read()) { @@ -329,6 +331,11 @@ bool fvSchemes::read() } } + if (dict.found("cacheFields")) + { + cacheFields_ = dict.subDict("cacheFields"); + } + return true; } else @@ -338,7 +345,7 @@ bool fvSchemes::read() } -const dictionary& fvSchemes::schemesDict() const +const Foam::dictionary& Foam::fvSchemes::schemesDict() const { if (found("select")) { @@ -351,7 +358,7 @@ const dictionary& fvSchemes::schemesDict() const } -ITstream& fvSchemes::ddtScheme(const word& name) const +Foam::ITstream& Foam::fvSchemes::ddtScheme(const word& name) const { if (debug) { @@ -370,7 +377,7 @@ ITstream& fvSchemes::ddtScheme(const word& name) const } -ITstream& fvSchemes::d2dt2Scheme(const word& name) const +Foam::ITstream& Foam::fvSchemes::d2dt2Scheme(const word& name) const { if (debug) { @@ -389,7 +396,7 @@ ITstream& fvSchemes::d2dt2Scheme(const word& name) const } -ITstream& fvSchemes::interpolationScheme(const word& name) const +Foam::ITstream& Foam::fvSchemes::interpolationScheme(const word& name) const { if (debug) { @@ -412,7 +419,7 @@ ITstream& fvSchemes::interpolationScheme(const word& name) const } -ITstream& fvSchemes::divScheme(const word& name) const +Foam::ITstream& Foam::fvSchemes::divScheme(const word& name) const { if (debug) { @@ -431,7 +438,7 @@ ITstream& fvSchemes::divScheme(const word& name) const } -ITstream& fvSchemes::gradScheme(const word& name) const +Foam::ITstream& Foam::fvSchemes::gradScheme(const word& name) const { if (debug) { @@ -450,7 +457,7 @@ ITstream& fvSchemes::gradScheme(const word& name) const } -ITstream& fvSchemes::snGradScheme(const word& name) const +Foam::ITstream& Foam::fvSchemes::snGradScheme(const word& name) const { if (debug) { @@ -469,7 +476,7 @@ ITstream& fvSchemes::snGradScheme(const word& name) const } -ITstream& fvSchemes::laplacianScheme(const word& name) const +Foam::ITstream& Foam::fvSchemes::laplacianScheme(const word& name) const { if (debug) { @@ -488,7 +495,7 @@ ITstream& fvSchemes::laplacianScheme(const word& name) const } -bool fvSchemes::fluxRequired(const word& name) const +bool Foam::fvSchemes::fluxRequired(const word& name) const { if (debug) { @@ -506,8 +513,22 @@ bool fvSchemes::fluxRequired(const word& name) const } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +bool Foam::fvSchemes::cache(const word& name) const +{ + if (debug) + { + Info<< "Lookup cache for " << name << endl; + } + + if (cacheFields_.found(name)) + { + return true; + } + else + { + return false; + } +} -} // End namespace Foam // ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/fvSchemes/fvSchemes.H b/src/finiteVolume/finiteVolume/fvSchemes/fvSchemes.H index 87e9f536e4e5f56643e217644bfb038959361f4a..3186085846d81d3f53d7d198e9e8e426904ddb8e 100644 --- a/src/finiteVolume/finiteVolume/fvSchemes/fvSchemes.H +++ b/src/finiteVolume/finiteVolume/fvSchemes/fvSchemes.H @@ -79,6 +79,8 @@ class fvSchemes dictionary fluxRequired_; bool defaultFluxRequired_; + dictionary cacheFields_; + // Private Member Functions @@ -121,6 +123,8 @@ public: bool fluxRequired(const word& name) const; + bool cache(const word& name) const; + // Read diff --git a/src/lagrangian/Allwmake b/src/lagrangian/Allwmake index 41b2fd9bf937dbc606e668af253144335f512433..fea6fce12eba69648412f36c4a6130a52037f001 100755 --- a/src/lagrangian/Allwmake +++ b/src/lagrangian/Allwmake @@ -6,6 +6,7 @@ wmake libso basic wmake libso solidParticle wmake libso intermediate wmake libso dieselSpray +wmake libso dsmc molecularDynamics/Allwmake diff --git a/src/lagrangian/dsmc/Make/files b/src/lagrangian/dsmc/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..9f6d33d209edf23f3a65deb06139746c0bb873ae --- /dev/null +++ b/src/lagrangian/dsmc/Make/files @@ -0,0 +1,16 @@ +/* Parcels */ +parcels/derived/dsmcParcel/dsmcParcel.C + +/* Cloud base classes */ +clouds/baseClasses/DsmcBaseCloud/DsmcBaseCloud.C + +/* Clouds */ +clouds/derived/dsmcCloud/dsmcCloud.C + +/* submodels */ +parcels/derived/dsmcParcel/defineDsmcParcel.C +parcels/derived/dsmcParcel/makeDsmcParcelBinaryCollisionModels.C +parcels/derived/dsmcParcel/makeDsmcParcelWallInteractionModels.C +parcels/derived/dsmcParcel/makeDsmcParcelInflowBoundaryModels.C + +LIB = $(FOAM_LIBBIN)/libdsmc diff --git a/src/lagrangian/dsmc/Make/options b/src/lagrangian/dsmc/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..15874b7b55afc2cfae55d9550fd48451604ee3d4 --- /dev/null +++ b/src/lagrangian/dsmc/Make/options @@ -0,0 +1,7 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/lagrangian/basic/lnInclude + +LIB_LIBS = \ + -llagrangian \ + -lfiniteVolume diff --git a/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.C b/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.C new file mode 100644 index 0000000000000000000000000000000000000000..4c4bcd0a43dc965a3bd1daae9b06801b0d359c77 --- /dev/null +++ b/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.C @@ -0,0 +1,840 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "DsmcCloud.H" +#include "BinaryCollisionModel.H" +#include "WallInteractionModel.H" +#include "InflowBoundaryModel.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +template<class ParcelType> +Foam::scalar Foam::DsmcCloud<ParcelType>::kb = 1.380650277e-23; + +template<class ParcelType> +Foam::scalar Foam::DsmcCloud<ParcelType>::Tref = 273; + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template<class ParcelType> +void Foam::DsmcCloud<ParcelType>::buildConstProps() +{ + Info<< nl << "Constructing constant properties for" << endl; + constProps_.setSize(typeIdList_.size()); + + dictionary moleculeProperties + ( + particleProperties_.subDict("moleculeProperties") + ); + + forAll(typeIdList_, i) + { + const word& id(typeIdList_[i]); + + Info<< " " << id << endl; + + const dictionary& molDict(moleculeProperties.subDict(id)); + + constProps_[i] = + typename ParcelType::constantProperties::constantProperties(molDict); + } +} + + +template<class ParcelType> +void Foam::DsmcCloud<ParcelType>::buildCellOccupancy() +{ + forAll(cellOccupancy_, cO) + { + cellOccupancy_[cO].clear(); + } + + forAllIter(typename DsmcCloud<ParcelType>, *this, iter) + { + cellOccupancy_[iter().cell()].append(&iter()); + } +} + + +template<class ParcelType> +void Foam::DsmcCloud<ParcelType>::initialise +( + const IOdictionary& dsmcInitialiseDict +) +{ + Info<< nl << "Initialising particles" << endl; + + const scalar temperature + ( + readScalar(dsmcInitialiseDict.lookup("temperature")) + ); + + const vector velocity(dsmcInitialiseDict.lookup("velocity")); + + const dictionary& numberDensitiesDict + ( + dsmcInitialiseDict.subDict("numberDensities") + ); + + List<word> molecules(numberDensitiesDict.toc()); + + Field<scalar> numberDensities(molecules.size()); + + forAll(molecules, i) + { + numberDensities[i] = readScalar + ( + numberDensitiesDict.lookup(molecules[i]) + ); + } + + 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<ParcelType>::initialise") + << "typeId " << moleculeName << "not defined." << nl + << abort(FatalError); + } + + const typename ParcelType::constantProperties& cP = constProps(typeId); + + 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); + + vector U = equipartitionLinearVelocity + ( + temperature, + cP.mass() + ); + + scalar Ei = equipartitionInternalEnergy + ( + temperature, + cP.internalDegreesOfFreedom() + ); + + U += velocity; + + if (cell >= 0) + { + addNewParcel + ( + p, + U, + Ei, + cell, + typeId + ); + } + } + } + } + } + + // Initialise the sigmaTcRMax_ field to the product of the cross section of + // the most abundant species and the most probable thermal speed (Bird, + // p222-223) + + label mostAbundantType(findMax(numberDensities)); + + const typename ParcelType::constantProperties& cP = constProps + ( + mostAbundantType + ); + + sigmaTcRMax_.internalField() = cP.sigmaT()*maxwellianMostProbableSpeed + ( + temperature, + cP.mass() + ); + + sigmaTcRMax_.correctBoundaryConditions(); +} + + +template<class ParcelType> +void Foam::DsmcCloud<ParcelType>::collisions() +{ + buildCellOccupancy(); + + // Temporary storage for subCells + List<DynamicList<label> > subCells(8); + + scalar deltaT = mesh_.time().deltaT().value(); + + label collisionCandidates = 0; + + label collisions = 0; + + forAll(cellOccupancy_, celli) + { + const DynamicList<ParcelType*>& cellParcels(cellOccupancy_[celli]); + + label nC(cellParcels.size()); + + if (nC > 1) + { + + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // Assign particles to one of 8 Cartesian subCells + + // Clear temporary lists + forAll(subCells, i) + { + subCells[i].clear(); + } + + // Inverse addressing specifying which subCell a parcel is in + List<label> whichSubCell(cellParcels.size()); + + const point& cC = mesh_.cellCentres()[celli]; + + forAll(cellParcels, i) + { + ParcelType* p = cellParcels[i]; + + vector relPos = p->position() - cC; + + label subCell = + pos(relPos.x()) + 2*pos(relPos.y()) + 4*pos(relPos.z()); + + subCells[subCell].append(i); + + whichSubCell[i] = subCell; + } + + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + scalar sigmaTcRMax = sigmaTcRMax_[celli]; + + scalar selectedPairs = + collisionSelectionRemainder_[celli] + + 0.5*nC*(nC-1)*nParticle_*sigmaTcRMax*deltaT + /mesh_.cellVolumes()[celli]; + + label nCandidates(selectedPairs); + + collisionSelectionRemainder_[celli] = selectedPairs - nCandidates; + + collisionCandidates += nCandidates; + + for (label c = 0; c < nCandidates; c++) + { + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // subCell candidate selection procedure + + // Select the first collision candidate + label candidateP = rndGen_.integer(0, nC - 1); + + // Declare the second collision candidate + label candidateQ = -1; + + List<label> subCellPs = subCells[whichSubCell[candidateP]]; + + label nSC = subCellPs.size(); + + if (nSC > 1) + { + // If there are two or more particle in a subCell, choose + // another from the same cell. If the same candidate is + // chosen, choose again. + + do + { + candidateQ = subCellPs[rndGen_.integer(0, nSC - 1)]; + + } while(candidateP == candidateQ); + } + else + { + // Select a possible second collision candidate from the + // whole cell. If the same candidate is chosen, choose + // again. + + do + { + candidateQ = rndGen_.integer(0, nC - 1); + + } while(candidateP == candidateQ); + } + + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // uniform candidate selection procedure + + // // Select the first collision candidate + // label candidateP = rndGen_.integer(0, nC-1); + + // // Select a possible second collision candidate + // label candidateQ = rndGen_.integer(0, nC-1); + + // // If the same candidate is chosen, choose again + // while(candidateP == candidateQ) + // { + // candidateQ = rndGen_.integer(0, nC-1); + // } + + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + ParcelType* parcelP = cellParcels[candidateP]; + ParcelType* parcelQ = cellParcels[candidateQ]; + + label typeIdP = parcelP->typeId(); + label typeIdQ = parcelQ->typeId(); + + scalar sigmaTcR = binaryCollision().sigmaTcR + ( + typeIdP, + typeIdQ, + parcelP->U(), + parcelQ->U() + ); + + // Update the maximum value of sigmaTcR stored, but use the + // initial value in the acceptance-rejection criteria because + // the number of collision candidates selected was based on this + + if (sigmaTcR > sigmaTcRMax_[celli]) + { + sigmaTcRMax_[celli] = sigmaTcR; + } + + if ((sigmaTcR/sigmaTcRMax) > rndGen_.scalar01()) + { + binaryCollision().collide + ( + typeIdP, + typeIdQ, + parcelP->U(), + parcelQ->U(), + parcelP->Ei(), + parcelQ->Ei() + ); + + collisions++; + } + } + } + } + + reduce(collisions, sumOp<label>()); + + reduce(collisionCandidates, sumOp<label>()); + + if (collisionCandidates) + { + Info<< " Collisions = " + << collisions << nl + << " Acceptance rate = " + << scalar(collisions)/scalar(collisionCandidates) << nl + << endl; + } + else + { + Info<< " No collisions" << endl; + } +} + + +template<class ParcelType> +void Foam::DsmcCloud<ParcelType>::resetSurfaceDataFields() +{ + volScalarField::GeometricBoundaryField& qBF(q_.boundaryField()); + + forAll(qBF, p) + { + qBF[p] = 0.0; + } + + volVectorField::GeometricBoundaryField& fDBF(fD_.boundaryField()); + + forAll(fDBF, p) + { + fDBF[p] = vector::zero; + } +} + + +// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * // + +template<class ParcelType> +void Foam::DsmcCloud<ParcelType>::addNewParcel +( + const vector& position, + const vector& U, + const scalar Ei, + const label cellId, + const label typeId +) +{ + ParcelType* pPtr = new ParcelType + ( + *this, + position, + U, + Ei, + cellId, + typeId + ); + + addParticle(pPtr); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class ParcelType> +Foam::DsmcCloud<ParcelType>::DsmcCloud +( + const word& cloudType, + const volScalarField& T, + const volVectorField& U +) +: + Cloud<ParcelType>(T.mesh(), cloudType, false), + DsmcBaseCloud(), + cloudType_(cloudType), + mesh_(T.mesh()), + particleProperties_ + ( + IOobject + ( + cloudType + "Properties", + mesh_.time().constant(), + mesh_, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ), + typeIdList_(particleProperties_.lookup("typeIdList")), + nParticle_(readScalar(particleProperties_.lookup("nEquivalentParticles"))), + cellOccupancy_(mesh_.nCells()), + sigmaTcRMax_ + ( + IOobject + ( + this->name() + "SigmaTcRMax", + mesh_.time().timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ), + collisionSelectionRemainder_(mesh_.nCells(), 0), + q_ + ( + IOobject + ( + this->name() + "q_", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("zero", dimensionSet(1, 0, -3, 0, 0), 0.0) + ), + fD_ + ( + IOobject + ( + this->name() + "fD_", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedVector + ( + "zero", + dimensionSet(1, -1, -2, 0, 0), + vector::zero + ) + ), + constProps_(), + rndGen_(label(149382906) + 7183*Pstream::myProcNo()), + T_(T), + U_(U), + binaryCollisionModel_ + ( + BinaryCollisionModel<DsmcCloud<ParcelType> >::New + ( + particleProperties_, + *this + ) + ), + wallInteractionModel_ + ( + WallInteractionModel<DsmcCloud<ParcelType> >::New + ( + particleProperties_, + *this + ) + ), + inflowBoundaryModel_ + ( + InflowBoundaryModel<DsmcCloud<ParcelType> >::New + ( + particleProperties_, + *this + ) + ) +{ + buildConstProps(); + + buildCellOccupancy(); +} + + +template<class ParcelType> +Foam::DsmcCloud<ParcelType>::DsmcCloud +( + const word& cloudType, + const fvMesh& mesh +) + : + Cloud<ParcelType>(mesh, cloudType, false), + DsmcBaseCloud(), + cloudType_(cloudType), + mesh_(mesh), + particleProperties_ + ( + IOobject + ( + cloudType + "Properties", + mesh_.time().constant(), + mesh_, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ), + typeIdList_(particleProperties_.lookup("typeIdList")), + nParticle_(readScalar(particleProperties_.lookup("nEquivalentParticles"))), + cellOccupancy_(), + sigmaTcRMax_ + ( + IOobject + ( + this->name() + "SigmaTcRMax", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh_, + dimensionedScalar("zero", dimensionSet(0, 3, -1, 0, 0), 0.0) + ), + collisionSelectionRemainder_(), + q_ + ( + IOobject + ( + this->name() + "q_", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("zero", dimensionSet(1, 0, -3, 0, 0), 0.0) + ), + fD_ + ( + IOobject + ( + this->name() + "fD_", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedVector + ( + "zero", + dimensionSet(1, -1, -2, 0, 0), + vector::zero + ) + ), + constProps_(), + rndGen_(label(971501) + 1526*Pstream::myProcNo()), + T_ + ( + volScalarField + ( + IOobject + ( + "T", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("zero", dimensionSet(0, 0, 0, 1, 0), 0.0) + ) + ), + U_ + ( + volVectorField + ( + IOobject + ( + "U", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedVector + ( + "zero", + dimensionSet(0, 1, -1, 0, 0), + vector::zero + ) + ) + ), + binaryCollisionModel_(), + wallInteractionModel_(), + inflowBoundaryModel_() +{ + clear(); + + buildConstProps(); + + IOdictionary dsmcInitialiseDict + ( + IOobject + ( + "dsmcInitialiseDict", + mesh_.time().system(), + mesh_, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); + + initialise(dsmcInitialiseDict); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template<class ParcelType> +Foam::DsmcCloud<ParcelType>::~DsmcCloud() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class ParcelType> +void Foam::DsmcCloud<ParcelType>::evolve() +{ + typename ParcelType::trackData td(*this); + + // Reset the surface data collection fields + resetSurfaceDataFields(); + + if (debug) + { + this->dumpParticlePositions(); + } + + // Insert new particles from the inflow boundary + this->inflowBoundary().inflow(); + + // Move the particles ballistically with their current velocities + Cloud<ParcelType>::move(td); + + // Calculate new velocities via stochastic collisions + collisions(); +} + + +template<class ParcelType> +void Foam::DsmcCloud<ParcelType>::info() const +{ + label nDsmcParticles = this->size(); + reduce(nDsmcParticles, sumOp<label>()); + + scalar nMol = nDsmcParticles*nParticle_; + + vector linearMomentum = linearMomentumOfSystem(); + reduce(linearMomentum, sumOp<vector>()); + + scalar linearKineticEnergy = linearKineticEnergyOfSystem(); + reduce(linearKineticEnergy, sumOp<scalar>()); + + scalar internalEnergy = internalEnergyOfSystem(); + reduce(internalEnergy, sumOp<scalar>()); + + Info<< "Cloud name: " << this->name() << nl + << " Number of dsmc particles = " + << nDsmcParticles << nl + << " Number of molecules = " + << nMol << nl + << " Mass in system = " + << returnReduce(massInSystem(), sumOp<scalar>()) << 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 + << endl; +} + + +template<class ParcelType> +Foam::vector Foam::DsmcCloud<ParcelType>::equipartitionLinearVelocity +( + scalar temperature, + scalar mass +) +{ + return + sqrt(kb*temperature/mass) + *vector + ( + rndGen_.GaussNormal(), + rndGen_.GaussNormal(), + rndGen_.GaussNormal() + ); +} + + +template<class ParcelType> +Foam::scalar Foam::DsmcCloud<ParcelType>::equipartitionInternalEnergy +( + scalar temperature, + scalar iDof +) +{ + scalar Ei = 0.0; + + if (iDof < 2.0 + SMALL && iDof > 2.0 - SMALL) + { + // Special case for iDof = 2, i.e. diatomics; + Ei = -log(rndGen_.scalar01())*kb*temperature; + } + else + { + scalar a = 0.5*iDof - 1; + + scalar energyRatio; + + scalar P; + + do + { + energyRatio = 10*rndGen_.scalar01(); + + P = pow((energyRatio/a), a)*exp(a - energyRatio); + + } while (P < rndGen_.scalar01()); + + Ei = energyRatio*kb*temperature; + } + + return Ei; +} + + +template<class ParcelType> +void Foam::DsmcCloud<ParcelType>::dumpParticlePositions() const +{ + OFstream pObj + ( + this->db().time().path()/"parcelPositions_" + + this->name() + "_" + + this->db().time().timeName() + ".obj" + ); + + forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter) + { + const ParcelType& p = iter(); + + pObj<< "v " << p.position().x() + << " " << p.position().y() + << " " << p.position().z() + << nl; + } + + pObj.flush(); +} + + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.H b/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.H new file mode 100644 index 0000000000000000000000000000000000000000..b246b0499040fa15a68ab38ceb2543b8249e43f1 --- /dev/null +++ b/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.H @@ -0,0 +1,434 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::DsmcCloud + +Description + Templated base class for dsmc cloud + +SourceFiles + DsmcCloudI.H + DsmcCloud.C + +\*---------------------------------------------------------------------------*/ + +#ifndef DsmcCloud_H +#define DsmcCloud_H + +#include "Cloud.H" +#include "DsmcBaseCloud.H" +#include "IOdictionary.H" +#include "autoPtr.H" +#include "Random.H" +#include "fvMesh.H" +#include "volFields.H" +#include "scalarIOField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes + +template<class CloudType> +class BinaryCollisionModel; + +template<class CloudType> +class WallInteractionModel; + +template<class CloudType> +class InflowBoundaryModel; + +/*---------------------------------------------------------------------------*\ + Class DsmcCloud Declaration +\*---------------------------------------------------------------------------*/ + +template<class ParcelType> +class DsmcCloud +: + public Cloud<ParcelType>, + public DsmcBaseCloud +{ + // Private data + + //- Cloud type - used to set the name of the parcel properties + // dictionary by appending "Properties" + const word cloudType_; + + //- References to the mesh and time databases + const fvMesh& mesh_; + + //- Dictionary of particle properties + IOdictionary particleProperties_; + + //- A list of unique instances of molecule types in the simulation. + // The position of an entry in the list maps to the label identifying + // the typeId, i.e. where typeIdList_ = (N2 O2 CO2) + // N2 has typeId label = 0, O2 = 1, CO2 = 2. + List<word> typeIdList_; + + //- Number of real atoms/molecules represented by a parcel + scalar nParticle_; + + //- A data structure holding which particles are in which cell + List<DynamicList<ParcelType*> > cellOccupancy_; + + //- An IOField holding the value of (sigmaT * cR)max for each cell (see + // Bird p220). Initialised with the parcels, updated as required, and + // read in on start/restart. + volScalarField sigmaTcRMax_; + + //- A field holding the remainder from the previous collision selections + scalarField collisionSelectionRemainder_; + + //- Heat flux at surface field + volScalarField q_; + + //- Force density at surface field + volVectorField fD_; + + //- Parcel constant properties - one for each type + List<typename ParcelType::constantProperties> constProps_; + + //- Random number generator + Random rndGen_; + + + // References to the macroscopic fields + + //- Temperature + const volScalarField& T_; + + //- Velocity + const volVectorField& U_; + + + // References to the cloud sub-models + + //- Binary collision model + autoPtr<BinaryCollisionModel<DsmcCloud<ParcelType> > > + binaryCollisionModel_; + + //- Wall interaction model + autoPtr<WallInteractionModel<DsmcCloud<ParcelType> > > + wallInteractionModel_; + + //- Inflow boundary model + autoPtr<InflowBoundaryModel<DsmcCloud<ParcelType> > > + inflowBoundaryModel_; + + + // Private Member Functions + + //- Build the constant properties for all of the species + void buildConstProps(); + + //- Record which particles are in which cell + void buildCellOccupancy(); + + //- Initialise the system + void initialise(const IOdictionary& dsmcInitialiseDict); + + //- Calculate collisions between molecules + void collisions(); + + //- Reset the surface data accumulation field values + void resetSurfaceDataFields(); + + //- Disallow default bitwise copy construct + DsmcCloud(const DsmcCloud&); + + //- Disallow default bitwise assignment + void operator=(const DsmcCloud&); + + +public: + + // Static data members + + //- Boltzmann constant + static scalar kb; + + //- Reference temperature for all models + static scalar Tref; + + + // Constructors + + //- Construct given name and mesh, will read Parcels from file + DsmcCloud + ( + const word& cloudType, + const volScalarField& T, + const volVectorField& U + ); + + //- Construct given name and mesh. Used to initialise. + DsmcCloud + ( + const word& cloudType, + const fvMesh& mesh + ); + + + //- Destructor + virtual ~DsmcCloud(); + + + // Member Functions + + // Access + + // References to the mesh and databases + + //- Return the cloud type + inline const word& cloudType() const; + + //- Return refernce to the mesh + inline const fvMesh& mesh() const; + + + // References to the dsmc specific data + + //- Return particle properties dictionary + inline const IOdictionary& particleProperties() const; + + //- Return the idList + inline const List<word>& typeIdList() const; + + //- Return the number of real particles represented by one + // parcel + inline scalar nParticle() const; + + //- Return the cell occupancy addressing + inline const List<DynamicList<ParcelType*> >& + cellOccupancy() const; + + //- Return the sigmaTcRMax field. non-const access to allow + // updating. + inline volScalarField& sigmaTcRMax(); + + //- Return the collision selection remainder field. non-const + // access to allow updating. + inline scalarField& collisionSelectionRemainder(); + + //- Return all of the constant properties + inline const List<typename ParcelType::constantProperties>& + constProps() const; + + //- Return the constant properties of the given typeId + inline const typename ParcelType::constantProperties& + constProps(label typeId) const; + + //- Return refernce to the random object + inline Random& rndGen(); + + + // References to the surface data collection fields + + //- Return heat flux at surface field + inline const volScalarField& q() const; + + //- Return non-const heat flux at surface field + inline volScalarField& q(); + + //- Return force density at surface field + inline const volVectorField& fD() const; + + //- Return non-const force density at surface field + inline volVectorField& fD(); + + + // References to the macroscopic fields + + //- Return macroscopic temperature + inline const volScalarField& T() const; + + //- Return macroscopic velocity + inline const volVectorField& U() const; + + + // Kinetic theory helper functions + + //- Generate a random velocity sampled from the Maxwellian speed + // distribution + vector equipartitionLinearVelocity + ( + scalar temperature, + scalar mass + ); + + //- Generate a random internal energy, sampled from the + // equilibrium distribution (Bird eqn 11.22 and 11.23 and + // adapting code from DSMC3.FOR) + scalar equipartitionInternalEnergy + ( + scalar temperature, + scalar internalDegreesOfFreedom + ); + + + // From the Maxwellian distribution: + //- Average particle speed + inline scalar maxwellianAverageSpeed + ( + scalar temperature, + scalar mass + ) const; + + //- RMS particle speed + inline scalar maxwellianRMSSpeed + ( + scalar temperature, + scalar mass + ) const; + + //- Most probable speed + inline scalar maxwellianMostProbableSpeed + ( + scalar temperature, + scalar mass + ) const; + + + // Sub-models + + //- Return reference to binary elastic collision model + inline const BinaryCollisionModel<DsmcCloud<ParcelType> >& + binaryCollision() const; + + //- Return non-const reference to binary elastic collision model + inline BinaryCollisionModel<DsmcCloud<ParcelType> >& + binaryCollision(); + + //- Return reference to wall interaction model + inline const WallInteractionModel<DsmcCloud<ParcelType> >& + wallInteraction() const; + + //- Return non-const reference to wall interaction model + inline WallInteractionModel<DsmcCloud<ParcelType> >& + wallInteraction(); + + //- Return reference to wall interaction model + inline const InflowBoundaryModel<DsmcCloud<ParcelType> >& + inflowBoundary() const; + + //- Return non-const reference to wall interaction model + inline InflowBoundaryModel<DsmcCloud<ParcelType> >& + inflowBoundary(); + + + // Check + + //- Total mass injected + inline scalar massInjected() const; + + //- Total mass in system + inline scalar massInSystem() const; + + //- Total linear momentum of the system + inline vector linearMomentumOfSystem() const; + + //- Total linear kinetic energy in the system + inline scalar linearKineticEnergyOfSystem() const; + + //- Total internal energy in the system + inline scalar internalEnergyOfSystem() const; + + //- Print cloud information + void info() const; + + //- Dump particle positions to .obj file + void dumpParticlePositions() const; + + + // Fields + + //- Return the real particle number density field + inline const tmp<volScalarField> rhoN() const; + + //- Return the particle mass density field + inline const tmp<volScalarField> rhoM() const; + + //- Return the field of number of DSMC particles + inline const tmp<volScalarField> dsmcRhoN() const; + + //- Return the momentum density field + inline const tmp<volVectorField> momentum() const; + + //- Return the total linear kinetic energy (translational and + // thermal density field + inline const tmp<volScalarField> linearKE() const; + + //- Return the internal energy density field + inline const tmp<volScalarField> internalE() const; + + //- Return the average internal degrees of freedom field + inline const tmp<volScalarField> iDof() const; + + + // Cloud evolution functions + + //- Add new parcel + void addNewParcel + ( + const vector& position, + const vector& U, + const scalar Ei, + const label cellId, + const label typeId + ); + + //- Evolve the cloud (move, collide) + void evolve(); + + + //- Clear the Cloud + inline void clear(); + + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "DsmcCloudI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "DsmcCloud.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloudI.H b/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloudI.H new file mode 100644 index 0000000000000000000000000000000000000000..73899636e8f6cf2a7e47754a15c8cf8aeb711712 --- /dev/null +++ b/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloudI.H @@ -0,0 +1,598 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class ParcelType> +inline const Foam::word& Foam::DsmcCloud<ParcelType>::cloudType() const +{ + return cloudType_; +} + + +template<class ParcelType> +inline const Foam::fvMesh& Foam::DsmcCloud<ParcelType>::mesh() const +{ + return mesh_; +} + + +template<class ParcelType> +inline const Foam::IOdictionary& +Foam::DsmcCloud<ParcelType>::particleProperties() const +{ + return particleProperties_; +} + + +template<class ParcelType> +inline const Foam::List<Foam::word>& +Foam::DsmcCloud<ParcelType>::typeIdList() const +{ + return typeIdList_; +} + + +template<class ParcelType> +inline Foam::scalar Foam::DsmcCloud<ParcelType>::nParticle() const +{ + return nParticle_; +} + + +template<class ParcelType> +inline const Foam::List<Foam::DynamicList<ParcelType*> >& +Foam::DsmcCloud<ParcelType>::cellOccupancy() const +{ + return cellOccupancy_; +} + + +template<class ParcelType> +inline Foam::volScalarField& Foam::DsmcCloud<ParcelType>::sigmaTcRMax() +{ + return sigmaTcRMax_; +} + + +template<class ParcelType> +inline Foam::scalarField& +Foam::DsmcCloud<ParcelType>::collisionSelectionRemainder() +{ + return collisionSelectionRemainder_; +} + + +template<class ParcelType> +inline const Foam::List<typename ParcelType::constantProperties>& +Foam::DsmcCloud<ParcelType>::constProps() const +{ + return constProps_; +} + + +template<class ParcelType> +inline const typename ParcelType::constantProperties& +Foam::DsmcCloud<ParcelType>::constProps +( + label typeId +) const +{ + if (typeId < 0 || typeId >= constProps_.size()) + { + FatalErrorIn("Foam::DsmcCloud<ParcelType>::constProps(label typeId)") + << "constantProperties for requested typeId index " + << typeId << " do not exist" << nl + << abort(FatalError); + } + + return constProps_[typeId]; +} + + +template<class ParcelType> +inline Foam::Random& Foam::DsmcCloud<ParcelType>::rndGen() +{ + return rndGen_; +} + + +template<class ParcelType> +inline const Foam::volScalarField& Foam::DsmcCloud<ParcelType>::q() const +{ + return q_; +} + + +template<class ParcelType> +inline Foam::volScalarField& Foam::DsmcCloud<ParcelType>::q() +{ + return q_; +} + + +template<class ParcelType> +inline const Foam::volVectorField& Foam::DsmcCloud<ParcelType>::fD() const +{ + return fD_; +} + + +template<class ParcelType> +inline Foam::volVectorField& Foam::DsmcCloud<ParcelType>::fD() +{ + return fD_; +} + + +template<class ParcelType> +inline const Foam::volScalarField& Foam::DsmcCloud<ParcelType>::T() const +{ + return T_; +} + + +template<class ParcelType> +inline const Foam::volVectorField& Foam::DsmcCloud<ParcelType>::U() const +{ + return U_; +} + + +template<class ParcelType> +inline const Foam::BinaryCollisionModel<Foam::DsmcCloud<ParcelType> >& +Foam::DsmcCloud<ParcelType>::binaryCollision() const +{ + return binaryCollisionModel_; +} + + +template<class ParcelType> +inline Foam::BinaryCollisionModel<Foam::DsmcCloud<ParcelType> >& +Foam::DsmcCloud<ParcelType>::binaryCollision() +{ + return binaryCollisionModel_(); +} + + +template<class ParcelType> +inline const Foam::WallInteractionModel<Foam::DsmcCloud<ParcelType> >& +Foam::DsmcCloud<ParcelType>::wallInteraction() const +{ + return wallInteractionModel_; +} + + +template<class ParcelType> +inline Foam::WallInteractionModel<Foam::DsmcCloud<ParcelType> >& +Foam::DsmcCloud<ParcelType>::wallInteraction() +{ + return wallInteractionModel_(); +} + + +template<class ParcelType> +inline const Foam::InflowBoundaryModel<Foam::DsmcCloud<ParcelType> >& +Foam::DsmcCloud<ParcelType>::inflowBoundary() const +{ + return inflowBoundaryModel_; +} + + +template<class ParcelType> +inline Foam::InflowBoundaryModel<Foam::DsmcCloud<ParcelType> >& +Foam::DsmcCloud<ParcelType>::inflowBoundary() +{ + return inflowBoundaryModel_(); +} + + +template<class ParcelType> +inline Foam::scalar Foam::DsmcCloud<ParcelType>::massInSystem() const +{ + scalar sysMass = 0.0; + + forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter) + { + const ParcelType& p = iter(); + + const typename ParcelType::constantProperties& cP = constProps + ( + p.typeId() + ); + + sysMass += cP.mass(); + } + + return nParticle_*sysMass; +} + + +template<class ParcelType> +inline Foam::vector Foam::DsmcCloud<ParcelType>::linearMomentumOfSystem() const +{ + vector linearMomentum(vector::zero); + + forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter) + { + const ParcelType& p = iter(); + + const typename ParcelType::constantProperties& cP = constProps + ( + p.typeId() + ); + + linearMomentum += cP.mass()*p.U(); + } + + return nParticle_*linearMomentum; +} + + +template<class ParcelType> +inline Foam::scalar +Foam::DsmcCloud<ParcelType>::linearKineticEnergyOfSystem() const +{ + scalar linearKineticEnergy = 0.0; + + forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter) + { + const ParcelType& p = iter(); + + const typename ParcelType::constantProperties& cP = constProps + ( + p.typeId() + ); + + linearKineticEnergy += 0.5*cP.mass()*(p.U() & p.U()); + } + + return nParticle_*linearKineticEnergy; +} + + +template<class ParcelType> +inline Foam::scalar +Foam::DsmcCloud<ParcelType>::internalEnergyOfSystem() const +{ + scalar internalEnergy = 0.0; + + forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter) + { + const ParcelType& p = iter(); + + internalEnergy += p.Ei(); + } + + return nParticle_*internalEnergy; +} + + +template<class ParcelType> +inline Foam::scalar Foam::DsmcCloud<ParcelType>::maxwellianAverageSpeed +( + scalar temperature, + scalar mass +) const +{ + return 2.0*sqrt(2.0*kb*temperature/(mathematicalConstant::pi*mass)); +} + + +template<class ParcelType> +inline Foam::scalar Foam::DsmcCloud<ParcelType>::maxwellianRMSSpeed +( + scalar temperature, + scalar mass +) const +{ + return sqrt(3.0*kb*temperature/mass); +} + + +template<class ParcelType> +inline Foam::scalar +Foam::DsmcCloud<ParcelType>::maxwellianMostProbableSpeed +( + scalar temperature, + scalar mass +) const +{ + return sqrt(2.0*kb*temperature/mass); +} + + +template<class ParcelType> +inline const Foam::tmp<Foam::volScalarField> +Foam::DsmcCloud<ParcelType>::rhoN() const +{ + tmp<volScalarField> trhoN + ( + new volScalarField + ( + IOobject + ( + this->name() + "rhoN", + this->db().time().timeName(), + this->db(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + mesh_, + dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), 0.0) + ) + ); + + scalarField& rhoN = trhoN().internalField(); + forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter) + { + const ParcelType& p = iter(); + const label cellI = p.cell(); + + rhoN[cellI]++; + } + + rhoN *= nParticle_/mesh().cellVolumes(); + + return trhoN; +} + + +template<class ParcelType> +inline const Foam::tmp<Foam::volScalarField> +Foam::DsmcCloud<ParcelType>::rhoM() const +{ + tmp<volScalarField> trhoM + ( + new volScalarField + ( + IOobject + ( + this->name() + "rhoM", + this->db().time().timeName(), + this->db(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + mesh_, + dimensionedScalar("zero", dimensionSet(1, -3, 0, 0, 0), 0.0) + ) + ); + + scalarField& rhoM = trhoM().internalField(); + forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter) + { + const ParcelType& p = iter(); + const label cellI = p.cell(); + + rhoM[cellI] += constProps(p.typeId()).mass(); + } + + rhoM *= nParticle_/mesh().cellVolumes(); + + return trhoM; +} + + +template<class ParcelType> +inline const Foam::tmp<Foam::volScalarField> +Foam::DsmcCloud<ParcelType>::dsmcRhoN() const +{ + tmp<volScalarField> tdsmcRhoN + ( + new volScalarField + ( + IOobject + ( + this->name() + "dsmcRhoN", + this->db().time().timeName(), + this->db(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + mesh_, + dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), 0.0) + ) + ); + + scalarField& dsmcRhoN = tdsmcRhoN().internalField(); + forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter) + { + const ParcelType& p = iter(); + const label cellI = p.cell(); + + dsmcRhoN[cellI]++; + } + + return tdsmcRhoN; +} + + +template<class ParcelType> +inline const Foam::tmp<Foam::volVectorField> +Foam::DsmcCloud<ParcelType>::momentum() const +{ + tmp<volVectorField> tmomentum + ( + new volVectorField + ( + IOobject + ( + this->name() + "momentum", + this->db().time().timeName(), + this->db(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + mesh_, + dimensionedVector + ( + "zero", + dimensionSet(1, -2, -1, 0, 0), + vector::zero + ) + ) + ); + + vectorField& momentum = tmomentum().internalField(); + forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter) + { + const ParcelType& p = iter(); + const label cellI = p.cell(); + + momentum[cellI] += constProps(p.typeId()).mass()*p.U(); + } + + momentum *= nParticle_/mesh().cellVolumes(); + + return tmomentum; +} + + +template<class ParcelType> +inline const Foam::tmp<Foam::volScalarField> +Foam::DsmcCloud<ParcelType>::linearKE() const +{ + tmp<volScalarField> tlinearKE + ( + new volScalarField + ( + IOobject + ( + this->name() + "linearKE", + this->db().time().timeName(), + this->db(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + mesh_, + dimensionedScalar("zero", dimensionSet(1, -1, -2, 0, 0), 0.0) + ) + ); + + scalarField& linearKE = tlinearKE().internalField(); + forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter) + { + const ParcelType& p = iter(); + const label cellI = p.cell(); + + linearKE[cellI] += 0.5*constProps(p.typeId()).mass()*(p.U() & p.U()); + } + + linearKE *= nParticle_/mesh().cellVolumes(); + + return tlinearKE; +} + + +template<class ParcelType> +inline const Foam::tmp<Foam::volScalarField> +Foam::DsmcCloud<ParcelType>::internalE() const +{ + tmp<volScalarField> tinternalE + ( + new volScalarField + ( + IOobject + ( + this->name() + "internalE", + this->db().time().timeName(), + this->db(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + mesh_, + dimensionedScalar("zero", dimensionSet(1, -1, -2, 0, 0), 0.0) + ) + ); + + scalarField& internalE = tinternalE().internalField(); + forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter) + { + const ParcelType& p = iter(); + const label cellI = p.cell(); + + internalE[cellI] += p.Ei(); + } + + internalE *= nParticle_/mesh().cellVolumes(); + + return tinternalE; +} + + +template<class ParcelType> +inline const Foam::tmp<Foam::volScalarField> +Foam::DsmcCloud<ParcelType>::iDof() const +{ + tmp<volScalarField> tiDof + ( + new volScalarField + ( + IOobject + ( + this->name() + "iDof", + this->db().time().timeName(), + this->db(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + mesh_, + dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), 0.0) + ) + ); + + scalarField& iDof = tiDof().internalField(); + + forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter) + { + const ParcelType& p = iter(); + const label cellI = p.cell(); + + iDof[cellI] += constProps(p.typeId()).internalDegreesOfFreedom(); + } + + iDof *= nParticle_/mesh().cellVolumes(); + + return tiDof; +} + + +template<class ParcelType> +inline void Foam::DsmcCloud<ParcelType>::clear() +{ + return IDLList<ParcelType>::clear(); +} + + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/clouds/baseClasses/DsmcBaseCloud/DsmcBaseCloud.C b/src/lagrangian/dsmc/clouds/baseClasses/DsmcBaseCloud/DsmcBaseCloud.C new file mode 100644 index 0000000000000000000000000000000000000000..1e0c395ca19f24709a1c3c43b4c0c802969dc846 --- /dev/null +++ b/src/lagrangian/dsmc/clouds/baseClasses/DsmcBaseCloud/DsmcBaseCloud.C @@ -0,0 +1,49 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "DsmcBaseCloud.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(DsmcBaseCloud, 0); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::DsmcBaseCloud::DsmcBaseCloud() +{} + + +// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * // + +Foam::DsmcBaseCloud::~DsmcBaseCloud() +{} + + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/clouds/baseClasses/DsmcBaseCloud/DsmcBaseCloud.H b/src/lagrangian/dsmc/clouds/baseClasses/DsmcBaseCloud/DsmcBaseCloud.H new file mode 100644 index 0000000000000000000000000000000000000000..df49f8e148bc2dfaa47924eff697821b59dbb8cf --- /dev/null +++ b/src/lagrangian/dsmc/clouds/baseClasses/DsmcBaseCloud/DsmcBaseCloud.H @@ -0,0 +1,84 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::DsmcBaseCloud + +Description + Virtual abstract base class for templated DsmcCloud + +SourceFiles + DsmcBaseCloud.C + +\*---------------------------------------------------------------------------*/ + +#ifndef DsmcBaseCloud_H +#define DsmcBaseCloud_H + +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class DsmcBaseCloud Declaration +\*---------------------------------------------------------------------------*/ + +class DsmcBaseCloud +{ + // Private Member Functions + + //- Disallow default bitwise copy construct + DsmcBaseCloud(const DsmcBaseCloud&); + + //- Disallow default bitwise assignment + void operator=(const DsmcBaseCloud&); + + +public: + + //- Runtime type information + TypeName("DsmcBaseCloud"); + + // Constructors + + //- Null constructor + DsmcBaseCloud(); + + //- Destructor + virtual ~DsmcBaseCloud(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/test/IndirectList/IndirectListI.H b/src/lagrangian/dsmc/clouds/derived/dsmcCloud/dsmcCloud.C similarity index 65% rename from applications/test/IndirectList/IndirectListI.H rename to src/lagrangian/dsmc/clouds/derived/dsmcCloud/dsmcCloud.C index 827bd0d95f1a7bf5d5e0d6022aa135ab92541bec..000ffcd53efb82dc4454009b3a28dc9c715cf124 100644 --- a/applications/test/IndirectList/IndirectListI.H +++ b/src/lagrangian/dsmc/clouds/derived/dsmcCloud/dsmcCloud.C @@ -22,56 +22,54 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - \*---------------------------------------------------------------------------*/ +#include "dsmcCloud.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(dsmcCloud, 0); +}; + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -//- Construct given size -template<class T> -inline Foam::IndirectList<T>::IndirectList +Foam::dsmcCloud::dsmcCloud ( - const Foam::UList<T>& completeList, - const Foam::List<label>& addresses + const word& cloudType, + const volScalarField& T, + const volVectorField& U ) : - completeList_(completeList), - addresses_(addresses) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template<class T> -inline Foam::label Foam::IndirectList<T>::size() const + DsmcCloud<dsmcParcel>(cloudType, T, U) { - return addresses_.size(); + dsmcParcel::readFields(*this); } -template<class T> -inline const Foam::UList<T>& Foam::IndirectList<T>:: -completeList() const -{ - return completeList_; -} +Foam::dsmcCloud::dsmcCloud +( + const word& cloudType, + const fvMesh& mesh +) +: + DsmcCloud<dsmcParcel>(cloudType, mesh) +{} -template<class T> -inline const Foam::List<Foam::label>& Foam::IndirectList<T>::addresses() const -{ - return addresses_; -} +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // +Foam::dsmcCloud::~dsmcCloud() +{} -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // -template<class T> -inline const T& Foam::IndirectList<T>::operator[](const Foam::label i) const +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::dsmcCloud::writeFields() const { - return completeList_[addresses_[i]]; + dsmcParcel::writeFields(*this); } - // ************************************************************************* // diff --git a/src/lagrangian/dsmc/clouds/derived/dsmcCloud/dsmcCloud.H b/src/lagrangian/dsmc/clouds/derived/dsmcCloud/dsmcCloud.H new file mode 100644 index 0000000000000000000000000000000000000000..2f88bbaad563dbb99fef716f22256416ae98bc15 --- /dev/null +++ b/src/lagrangian/dsmc/clouds/derived/dsmcCloud/dsmcCloud.H @@ -0,0 +1,105 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::dsmcCloud + +Description + Cloud class to simulate dsmc parcels + +SourceFiles + dsmcCloud.C + +\*---------------------------------------------------------------------------*/ + +#ifndef dsmcCloud_H +#define dsmcCloud_H + +#include "DsmcCloud.H" +#include "dsmcParcel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class dsmcCloud Declaration +\*---------------------------------------------------------------------------*/ + +class dsmcCloud +: + public DsmcCloud<dsmcParcel> +{ + // Private member functions + + //- Disallow default bitwise copy construct + dsmcCloud(const dsmcCloud&); + + //- Disallow default bitwise assignment + void operator=(const dsmcCloud&); + + +public: + + //- Runtime type information + TypeName("dsmcCloud"); + + + // Constructors + + //- Construct from components + dsmcCloud + ( + const word& cloudType, + const volScalarField& T, + const volVectorField& U + ); + + //- Construct from name and mesh, used to initialise. + dsmcCloud + ( + const word& cloudType, + const fvMesh& mesh + ); + + //- Destructor + ~dsmcCloud(); + + + // Member functions + + //- Write fields + void writeFields() const; +}; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcel.C b/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcel.C new file mode 100644 index 0000000000000000000000000000000000000000..f9c135718947fab6e8637c6ca0b24221864f2630 --- /dev/null +++ b/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcel.C @@ -0,0 +1,209 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "DsmcParcel.H" +#include "dimensionedConstants.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class ParcelType> +template<class TrackData> +bool Foam::DsmcParcel<ParcelType>::move +( + TrackData& td +) +{ + ParcelType& p = static_cast<ParcelType&>(*this); + + td.switchProcessor = false; + td.keepParticle = true; + + const polyMesh& mesh = td.cloud().pMesh(); + const polyBoundaryMesh& pbMesh = mesh.boundaryMesh(); + + const scalar deltaT = mesh.time().deltaT().value(); + scalar tEnd = (1.0 - p.stepFraction())*deltaT; + const scalar dtMax = tEnd; + + while (td.keepParticle && !td.switchProcessor && tEnd > ROOTVSMALL) + { + // Set the Lagrangian time-step + scalar dt = min(dtMax, tEnd); + + dt *= p.trackToFace(p.position() + dt*U_, td); + + tEnd -= dt; + + p.stepFraction() = 1.0 - tEnd/deltaT; + + if (p.onBoundary() && td.keepParticle) + { + if (p.face() > -1) + { + if + ( + isType<processorPolyPatch>(pbMesh[p.patch(p.face())]) + ) + { + td.switchProcessor = true; + } + } + } + } + + return td.keepParticle; +} + + +template<class ParcelType> +template<class TrackData> +void Foam::DsmcParcel<ParcelType>::hitProcessorPatch +( + const processorPolyPatch&, + TrackData& td +) +{ + td.switchProcessor = true; +} + + +template<class ParcelType> +void Foam::DsmcParcel<ParcelType>::hitProcessorPatch +( + const processorPolyPatch&, + int& +) +{} + + +template<class ParcelType> +template<class TrackData> +void Foam::DsmcParcel<ParcelType>::hitWallPatch +( + const wallPolyPatch& wpp, + TrackData& td +) +{ + const constantProperties& constProps(td.cloud().constProps(typeId_)); + + scalar m = constProps.mass(); + + // pre-interaction energy + scalar preIE = 0.5*m*(U_ & U_) + Ei_; + + // pre-interaction momentum + vector preIMom = m*U_; + + td.cloud().wallInteraction().correct + ( + wpp, + this->face(), + U_, + Ei_, + typeId_ + ); + + // post-interaction energy + scalar postIE = 0.5*m*(U_ & U_) + Ei_; + + // post-interaction momentum + vector postIMom = m*U_; + + label wppIndex = wpp.index(); + + label wppLocalFace = wpp.whichFace(this->face()); + + const scalar fA = mag(wpp.faceAreas()[wppLocalFace]); + + const scalar deltaT = td.cloud().mesh().time().deltaT().value(); + + scalar deltaQ = td.cloud().nParticle()*(preIE - postIE)/(deltaT*fA); + + vector deltaFD = td.cloud().nParticle()*(preIMom - postIMom)/(deltaT*fA); + + td.cloud().q().boundaryField()[wppIndex][wppLocalFace] += deltaQ; + + td.cloud().fD().boundaryField()[wppIndex][wppLocalFace] += deltaFD; +} + + +template<class ParcelType> +void Foam::DsmcParcel<ParcelType>::hitWallPatch +( + const wallPolyPatch&, + int& +) +{} + + +template<class ParcelType> +template<class TrackData> +void Foam::DsmcParcel<ParcelType>::hitPatch +( + const polyPatch&, + TrackData& td +) +{ + td.keepParticle = false; +} + + +template<class ParcelType> +void Foam::DsmcParcel<ParcelType>::hitPatch +( + const polyPatch&, + int& +) +{} + + +template<class ParcelType> +void Foam::DsmcParcel<ParcelType>::transformProperties +( + const tensor& T +) +{ + Particle<ParcelType>::transformProperties(T); + U_ = transform(T, U_); +} + + +template<class ParcelType> +void Foam::DsmcParcel<ParcelType>::transformProperties +( + const vector& separation +) +{ + Particle<ParcelType>::transformProperties(separation); +} + + +// * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * // + +#include "DsmcParcelIO.C" + +// ************************************************************************* // + diff --git a/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcel.H b/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcel.H new file mode 100644 index 0000000000000000000000000000000000000000..bbc2fd1539b2fa4f5a267c2b942fe3373ebe635b --- /dev/null +++ b/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcel.H @@ -0,0 +1,347 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::DsmcParcel + +Description + DSMC parcel class + +SourceFiles + DsmcParcelI.H + DsmcParcel.C + DsmcParcelIO.C + +\*---------------------------------------------------------------------------*/ + +#ifndef DsmcParcel_H +#define DsmcParcel_H + +#include "Particle.H" +#include "IOstream.H" +#include "autoPtr.H" +#include "contiguous.H" +#include "mathematicalConstants.H" + +#include "DsmcCloud.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +template<class ParcelType> +class DsmcParcel; + +// Forward declaration of friend functions + +template<class ParcelType> +Ostream& operator<< +( + Ostream&, + const DsmcParcel<ParcelType>& +); + +/*---------------------------------------------------------------------------*\ + Class DsmcParcel Declaration +\*---------------------------------------------------------------------------*/ + +template<class ParcelType> +class DsmcParcel +: + public Particle<ParcelType> +{ +public: + + //- Class to hold DSMC particle constant properties + class constantProperties + { + // Private data + + //- Particle mass [kg] (constant) + scalar mass_; + + //- Particle hard sphere diameter [m] (constant) + scalar d_; + + //- Internal degrees of freedom + scalar internalDegreesOfFreedom_; + + //- Viscosity index + scalar omega_; + + + public: + + // Constrcutors + + //- Null constructor, allows List of constantProperties to be + // created before the contents is initialised + inline constantProperties(); + + //- Constructor from dictionary + inline constantProperties(const dictionary& dict); + + + // Member functions + + //- Return const access to the particle density + inline scalar mass() const; + + //- Return const access to the minimum particle mass + inline scalar d() const; + + //- Return the reference total collision cross section + inline scalar sigmaT() const; + + //- Return the internalDegreesOfFreedom + inline scalar internalDegreesOfFreedom() const; + + //- Return the viscosity index + inline scalar omega() const; + + }; + + + //- Class used to pass kinematic tracking data to the trackToFace function + class trackData + : + public Particle<ParcelType>::trackData + { + // Private data + + //- Reference to the cloud containing this particle + DsmcCloud<ParcelType>& cloud_; + + + public: + + // Constructors + + //- Construct from components + inline trackData + ( + DsmcCloud<ParcelType>& cloud + ); + + + // Member functions + + //- Return access to the owner cloud + inline DsmcCloud<ParcelType>& cloud(); + }; + + +protected: + + // Protected member data + + // Parcel properties + + //- Velocity of Parcel [m/s] + vector U_; + + //- Internal energy of the Parcel, covering all non-translational + // degrees of freedom [J] + scalar Ei_; + + //- Parcel type id + label typeId_; + + +public: + + //- Runtime type information + TypeName("DsmcParcel"); + + friend class Cloud<ParcelType>; + + + // Constructors + + //- Construct from components + inline DsmcParcel + ( + DsmcCloud<ParcelType>& owner, + const vector& position, + const vector& U, + const scalar Ei, + const label celli, + const label typeId + ); + + //- Construct from Istream + DsmcParcel + ( + const Cloud<ParcelType>& c, + Istream& is, + bool readFields = true + ); + + //- Construct and return a clone + autoPtr<ParcelType> clone() const + { + return autoPtr<ParcelType>(new DsmcParcel<ParcelType>(*this)); + } + + + // Member Functions + + // Access + + //- Return type id + inline label typeId() const; + + //- Return const access to velocity + inline const vector& U() const; + + //- Return const access to internal energy + inline scalar Ei() const; + + // Edit + + //- Return access to velocity + inline vector& U(); + + //- Return access to internal energy + inline scalar& Ei(); + + + // Main calculation loop + + // Tracking + + //- Move the parcel + template<class TrackData> + bool move(TrackData& td); + + + // Patch interactions + + //- Overridable function to handle the particle hitting a + // processorPatch + template<class TrackData> + void hitProcessorPatch + ( + const processorPolyPatch&, + TrackData& td + ); + + //- Overridable function to handle the particle hitting a + // processorPatch without trackData + void hitProcessorPatch + ( + const processorPolyPatch&, + int& + ); + + //- Overridable function to handle the particle hitting a wallPatch + template<class TrackData> + void hitWallPatch + ( + const wallPolyPatch&, + TrackData& td + ); + + //- Overridable function to handle the particle hitting a wallPatch + // without trackData + void hitWallPatch + ( + const wallPolyPatch&, + int& + ); + + //- Overridable function to handle the particle hitting a polyPatch + template<class TrackData> + void hitPatch + ( + const polyPatch&, + TrackData& td + ); + + //- Overridable function to handle the particle hitting a polyPatch + //- without trackData + void hitPatch + ( + const polyPatch&, + int& + ); + + //- Transform the physical properties of the particle + // according to the given transformation tensor + void transformProperties(const tensor& T); + + //- Transform the physical properties of the particle + // according to the given separation vector + void transformProperties(const vector& separation); + + + // I-O + + static void readFields(DsmcCloud<ParcelType>& c); + + static void writeFields(const DsmcCloud<ParcelType>& c); + + + // Ostream Operator + + friend Ostream& operator<< <ParcelType> + ( + Ostream&, + const DsmcParcel<ParcelType>& + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "DsmcParcelI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#define defineParcelTypeNameAndDebug(Type, DebugSwitch) \ + template<> \ + const Foam::word DsmcParcel<Type>::typeName(#Type); \ + template<> \ + int DsmcParcel<Type>::debug \ + ( \ + Foam::debug::debugSwitch(#Type, DebugSwitch) \ + ); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "DsmcParcel.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // + diff --git a/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcelI.H b/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcelI.H new file mode 100644 index 0000000000000000000000000000000000000000..ff86419186fee680205fe2b70e0d0d2a6c705e61 --- /dev/null +++ b/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcelI.H @@ -0,0 +1,172 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template <class ParcelType> +inline Foam::DsmcParcel<ParcelType>::constantProperties::constantProperties() +: + mass_(0), + d_(0) +{} + + +template <class ParcelType> +inline Foam::DsmcParcel<ParcelType>::constantProperties::constantProperties +( + const dictionary& dict +) +: + mass_(readScalar(dict.lookup("mass"))), + d_(readScalar(dict.lookup("diameter"))), + internalDegreesOfFreedom_ + ( + readScalar(dict.lookup("internalDegreesOfFreedom")) + ), + omega_(readScalar(dict.lookup("omega"))) +{} + + +template <class ParcelType> +inline Foam::DsmcParcel<ParcelType>::trackData::trackData +( + DsmcCloud<ParcelType>& cloud +) +: + Particle<ParcelType>::trackData(cloud), + cloud_(cloud) +{} + + +template <class ParcelType> +inline Foam::DsmcParcel<ParcelType>::DsmcParcel +( + DsmcCloud<ParcelType>& owner, + const vector& position, + const vector& U, + const scalar Ei, + const label celli, + const label typeId +) +: + Particle<ParcelType>(owner, position, celli), + U_(U), + Ei_(Ei), + typeId_(typeId) +{} + + +// * * * * * * * * * constantProperties Member Functions * * * * * * * * * * // + +template <class ParcelType> +inline Foam::scalar +Foam::DsmcParcel<ParcelType>::constantProperties::mass() const +{ + return mass_; +} + + +template <class ParcelType> +inline Foam::scalar +Foam::DsmcParcel<ParcelType>::constantProperties::d() const +{ + return d_; +} + + +template <class ParcelType> +inline Foam::scalar +Foam::DsmcParcel<ParcelType>::constantProperties::sigmaT() const +{ + return mathematicalConstant::pi*d_*d_; +} + + +template <class ParcelType> +inline Foam::scalar +Foam::DsmcParcel<ParcelType>::constantProperties::internalDegreesOfFreedom() +const +{ + return internalDegreesOfFreedom_; +} + + +template <class ParcelType> +inline Foam::scalar +Foam::DsmcParcel<ParcelType>::constantProperties::omega() const +{ + return omega_; +} + + +// * * * * * * * * * * * trackData Member Functions * * * * * * * * * * * * // + +template <class ParcelType> +inline Foam::DsmcCloud<ParcelType>& +Foam::DsmcParcel<ParcelType>::trackData::cloud() +{ + return cloud_; +} + + +// * * * * * * * * * * DsmcParcel Member Functions * * * * * * * * * * // + +template <class ParcelType> +inline Foam::label Foam::DsmcParcel<ParcelType>::typeId() const +{ + return typeId_; +} + + +template <class ParcelType> +inline const Foam::vector& Foam::DsmcParcel<ParcelType>::U() const +{ + return U_; +} + + +template <class ParcelType> +inline Foam::scalar Foam::DsmcParcel<ParcelType>::Ei() const +{ + return Ei_; +} + + +template <class ParcelType> +inline Foam::vector& Foam::DsmcParcel<ParcelType>::U() +{ + return U_; +} + + +template <class ParcelType> +inline Foam::scalar& Foam::DsmcParcel<ParcelType>::Ei() +{ + return Ei_; +} + + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcelIO.C b/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcelIO.C new file mode 100644 index 0000000000000000000000000000000000000000..b8bc688c09640bfd462f754fc87175a46334c9ff --- /dev/null +++ b/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcelIO.C @@ -0,0 +1,178 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "DsmcParcel.H" +#include "IOstreams.H" +#include "IOField.H" +#include "Cloud.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template <class ParcelType> +Foam::DsmcParcel<ParcelType>::DsmcParcel +( + const Cloud<ParcelType>& cloud, + Istream& is, + bool readFields +) +: + Particle<ParcelType>(cloud, is, readFields), + U_(vector::zero), + Ei_(0.0), + typeId_(-1) +{ + if (readFields) + { + if (is.format() == IOstream::ASCII) + { + is >> U_; + Ei_ = readScalar(is); + typeId_ = readLabel(is); + } + else + { + is.read + ( + reinterpret_cast<char*>(&U_), + sizeof(U_) + + sizeof(Ei_) + + sizeof(typeId_) + ); + } + } + + // Check state of Istream + is.check + ( + "DsmcParcel<ParcelType>::DsmcParcel" + "(const Cloud<ParcelType>&, Istream&, bool)" + ); +} + + +template<class ParcelType> +void Foam::DsmcParcel<ParcelType>::readFields +( + DsmcCloud<ParcelType>& c +) +{ + if (!c.size()) + { + return; + } + + IOField<vector> U(c.fieldIOobject("U", IOobject::MUST_READ)); + c.checkFieldIOobject(c, U); + + IOField<scalar> Ei(c.fieldIOobject("Ei", IOobject::MUST_READ)); + c.checkFieldIOobject(c, Ei); + + IOField<label> typeId(c.fieldIOobject("typeId", IOobject::MUST_READ)); + c.checkFieldIOobject(c, typeId); + + label i = 0; + forAllIter(typename Cloud<ParcelType>, c, iter) + { + ParcelType& p = iter(); + + p.U_ = U[i]; + p.Ei_ = Ei[i]; + p.typeId_ = typeId[i]; + i++; + } +} + + +template<class ParcelType> +void Foam::DsmcParcel<ParcelType>::writeFields +( + const DsmcCloud<ParcelType>& c +) +{ + Particle<ParcelType>::writeFields(c); + + label np = c.size(); + + IOField<vector> U(c.fieldIOobject("U", IOobject::NO_READ), np); + IOField<scalar> Ei(c.fieldIOobject("Ei", IOobject::NO_READ), np); + IOField<label> typeId(c.fieldIOobject("typeId", IOobject::NO_READ), np); + + label i = 0; + forAllConstIter(typename Cloud<ParcelType>, c, iter) + { + const DsmcParcel<ParcelType>& p = iter(); + + U[i] = p.U(); + Ei[i] = p.Ei(); + typeId[i] = p.typeId(); + i++; + } + + U.write(); + Ei.write(); + typeId.write(); +} + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +template<class ParcelType> +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const DsmcParcel<ParcelType>& p +) +{ + if (os.format() == IOstream::ASCII) + { + os << static_cast<const Particle<ParcelType>& >(p) + << token::SPACE << p.U() + << token::SPACE << p.Ei() + << token::SPACE << p.typeId(); + } + else + { + os << static_cast<const Particle<ParcelType>& >(p); + os.write + ( + reinterpret_cast<const char*>(&p.U_), + sizeof(p.U()) + + sizeof(p.Ei()) + + sizeof(p.typeId()) + ); + } + + // Check state of Ostream + os.check + ( + "Ostream& operator<<(Ostream&, const DsmcParcel<ParcelType>&)" + ); + + return os; +} + + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/parcels/derived/dsmcParcel/defineDsmcParcel.C b/src/lagrangian/dsmc/parcels/derived/dsmcParcel/defineDsmcParcel.C new file mode 100644 index 0000000000000000000000000000000000000000..d3b71359da80c68830d37927e499e44441758ae7 --- /dev/null +++ b/src/lagrangian/dsmc/parcels/derived/dsmcParcel/defineDsmcParcel.C @@ -0,0 +1,38 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "dsmcParcel.H" +#include "DsmcCloud.H" + +namespace Foam +{ + defineTemplateTypeNameAndDebug(Cloud<dsmcParcel>, 0); + + defineParcelTypeNameAndDebug(DsmcCloud<dsmcParcel>, 0); +}; + + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/parcels/derived/dsmcParcel/dsmcParcel.C b/src/lagrangian/dsmc/parcels/derived/dsmcParcel/dsmcParcel.C new file mode 100644 index 0000000000000000000000000000000000000000..8f52fcdabf62a8dbd9e7cba06295a3ea41cbbfba --- /dev/null +++ b/src/lagrangian/dsmc/parcels/derived/dsmcParcel/dsmcParcel.C @@ -0,0 +1,80 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "dsmcParcel.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(dsmcParcel, 0); + defineParticleTypeNameAndDebug(dsmcParcel, 0); + defineParcelTypeNameAndDebug(dsmcParcel, 0); +}; + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::dsmcParcel::dsmcParcel +( + DsmcCloud<dsmcParcel>& owner, + const vector& position, + const vector& U, + const scalar Ei, + const label celli, + const label typeId +) +: + DsmcParcel<dsmcParcel> + ( + owner, + position, + U, + Ei, + celli, + typeId + ) +{} + + +Foam::dsmcParcel::dsmcParcel +( + const Cloud<dsmcParcel>& cloud, + Istream& is, + bool readFields +) +: + DsmcParcel<dsmcParcel>(cloud, is, readFields) +{} + + +// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * // + +Foam::dsmcParcel::~dsmcParcel() +{} + + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/parcels/derived/dsmcParcel/dsmcParcel.H b/src/lagrangian/dsmc/parcels/derived/dsmcParcel/dsmcParcel.H new file mode 100644 index 0000000000000000000000000000000000000000..24d9c9ada4f4654f8911c151e78b806d782807eb --- /dev/null +++ b/src/lagrangian/dsmc/parcels/derived/dsmcParcel/dsmcParcel.H @@ -0,0 +1,109 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::dsmcParcel + +Description + + +SourceFiles + dsmcParcel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef dsmcParcel_H +#define dsmcParcel_H + +#include "DsmcParcel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class dsmcParcel Declaration +\*---------------------------------------------------------------------------*/ + +class dsmcParcel +: + public DsmcParcel<dsmcParcel> +{ + +public: + + //- Run-time type information + TypeName("dsmcParcel"); + + + // Constructors + + //- Construct from components + dsmcParcel + ( + DsmcCloud<dsmcParcel>& owner, + const vector& position, + const vector& U, + const scalar Ei, + const label celli, + const label typeId + ); + + //- Construct from Istream + dsmcParcel + ( + const Cloud<dsmcParcel>& c, + Istream& is, + bool readFields = true + ); + + //- Construct and return a clone + autoPtr<dsmcParcel> clone() const + { + return autoPtr<dsmcParcel>(new dsmcParcel(*this)); + } + + + //- Destructor + virtual ~dsmcParcel(); +}; + + +template<> +inline bool contiguous<dsmcParcel>() +{ + return true; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/parcels/derived/dsmcParcel/makeDsmcParcelBinaryCollisionModels.C b/src/lagrangian/dsmc/parcels/derived/dsmcParcel/makeDsmcParcelBinaryCollisionModels.C new file mode 100644 index 0000000000000000000000000000000000000000..de2444687b785586345a50d8eaf922bd63073b10 --- /dev/null +++ b/src/lagrangian/dsmc/parcels/derived/dsmcParcel/makeDsmcParcelBinaryCollisionModels.C @@ -0,0 +1,52 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "dsmcParcel.H" +#include "DsmcCloud.H" +#include "VariableHardSphere.H" +#include "LarsenBorgnakkeVariableHardSphere.H" + +namespace Foam +{ + makeBinaryCollisionModel(DsmcCloud<dsmcParcel>); + + // Add instances of collision model to the table + makeBinaryCollisionModelType + ( + VariableHardSphere, + DsmcCloud, + dsmcParcel + ); + makeBinaryCollisionModelType + ( + LarsenBorgnakkeVariableHardSphere, + DsmcCloud, + dsmcParcel + ); +}; + + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/parcels/derived/dsmcParcel/makeDsmcParcelInflowBoundaryModels.C b/src/lagrangian/dsmc/parcels/derived/dsmcParcel/makeDsmcParcelInflowBoundaryModels.C new file mode 100644 index 0000000000000000000000000000000000000000..c3ee121ff02fedac07f42ff28e5169fe4a7b9f33 --- /dev/null +++ b/src/lagrangian/dsmc/parcels/derived/dsmcParcel/makeDsmcParcelInflowBoundaryModels.C @@ -0,0 +1,52 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "dsmcParcel.H" +#include "DsmcCloud.H" +#include "FreeStream.H" +#include "NoInflow.H" + +namespace Foam +{ + makeInflowBoundaryModel(DsmcCloud<dsmcParcel>); + + // Add instances of inflow boundary model to the table + makeInflowBoundaryModelType + ( + FreeStream, + DsmcCloud, + dsmcParcel + ); + makeInflowBoundaryModelType + ( + NoInflow, + DsmcCloud, + dsmcParcel + ); +}; + + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/parcels/derived/dsmcParcel/makeDsmcParcelWallInteractionModels.C b/src/lagrangian/dsmc/parcels/derived/dsmcParcel/makeDsmcParcelWallInteractionModels.C new file mode 100644 index 0000000000000000000000000000000000000000..874c787d6a75c4be73c84b26c0032938d7f4b802 --- /dev/null +++ b/src/lagrangian/dsmc/parcels/derived/dsmcParcel/makeDsmcParcelWallInteractionModels.C @@ -0,0 +1,52 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "dsmcParcel.H" +#include "DsmcCloud.H" +#include "MaxwellianThermal.H" +#include "SpecularReflection.H" + +namespace Foam +{ + makeWallInteractionModel(DsmcCloud<dsmcParcel>); + + // Add instances of wall interaction model to the table + makeWallInteractionModelType + ( + MaxwellianThermal, + DsmcCloud, + dsmcParcel + ); + makeWallInteractionModelType + ( + SpecularReflection, + DsmcCloud, + dsmcParcel + ); +}; + + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/submodels/BinaryCollisionModel/BinaryCollisionModel/BinaryCollisionModel.C b/src/lagrangian/dsmc/submodels/BinaryCollisionModel/BinaryCollisionModel/BinaryCollisionModel.C new file mode 100644 index 0000000000000000000000000000000000000000..0118014f9c62b6ecec5a2d93bef0b9425db04cc9 --- /dev/null +++ b/src/lagrangian/dsmc/submodels/BinaryCollisionModel/BinaryCollisionModel/BinaryCollisionModel.C @@ -0,0 +1,91 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "BinaryCollisionModel.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class CloudType> +Foam::BinaryCollisionModel<CloudType>::BinaryCollisionModel +( + const dictionary& dict, + CloudType& owner, + const word& type +) +: + dict_(dict), + owner_(owner), + coeffDict_(dict.subDict(type + "Coeffs")) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template<class CloudType> +Foam::BinaryCollisionModel<CloudType>::~BinaryCollisionModel() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class CloudType> +const CloudType& +Foam::BinaryCollisionModel<CloudType>::owner() const +{ + return owner_; +} + + +template<class CloudType> +CloudType& +Foam::BinaryCollisionModel<CloudType>::owner() +{ + return owner_; +} + + +template<class CloudType> +const Foam::dictionary& +Foam::BinaryCollisionModel<CloudType>::dict() const +{ + return dict_; +} + + +template<class CloudType> +const Foam::dictionary& +Foam::BinaryCollisionModel<CloudType>::coeffDict() const +{ + return coeffDict_; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "NewBinaryCollisionModel.C" + +// ************************************************************************* // + diff --git a/src/lagrangian/dsmc/submodels/BinaryCollisionModel/BinaryCollisionModel/BinaryCollisionModel.H b/src/lagrangian/dsmc/submodels/BinaryCollisionModel/BinaryCollisionModel/BinaryCollisionModel.H new file mode 100644 index 0000000000000000000000000000000000000000..771115c98428b86253f8d4920b9ad577067b7bd5 --- /dev/null +++ b/src/lagrangian/dsmc/submodels/BinaryCollisionModel/BinaryCollisionModel/BinaryCollisionModel.H @@ -0,0 +1,189 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::BinaryCollisionModel + +Description + Templated DSMC particle collision class + +SourceFiles + BinaryCollisionModel.C + NewBinaryCollisionModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef BinaryCollisionModel_H +#define BinaryCollisionModel_H + +#include "IOdictionary.H" +#include "autoPtr.H" +#include "runTimeSelectionTables.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class BinaryCollisionModel Declaration +\*---------------------------------------------------------------------------*/ + +template<class CloudType> +class BinaryCollisionModel +{ + // Private data + + //- The cloud dictionary + const dictionary& dict_; + + // reference to the owner cloud class + CloudType& owner_; + + //- The coefficients dictionary + const dictionary coeffDict_; + + +public: + + //- Runtime type information + TypeName("BinaryCollisionModel"); + + //- Declare runtime constructor selection table + declareRunTimeSelectionTable + ( + autoPtr, + BinaryCollisionModel, + dictionary, + ( + const dictionary& dict, + CloudType& owner + ), + (dict, owner) + ); + + + // Constructors + + //- Construct from components + BinaryCollisionModel + ( + const dictionary& dict, + CloudType& owner, + const word& type + ); + + + // Destructor + virtual ~BinaryCollisionModel(); + + + //- Selector + static autoPtr<BinaryCollisionModel<CloudType> > New + ( + const dictionary& dict, + CloudType& owner + ); + + + // Access + + //- Return the owner cloud object + const CloudType& owner() const; + + //- Return non-const access to the owner cloud object + CloudType& owner(); + + //- Return the dictionary + const dictionary& dict() const; + + //- Return the coefficients dictionary + const dictionary& coeffDict() const; + + + // Member Functions + + //- Return the collision cross section * relative velocity product + virtual scalar sigmaTcR + ( + label typeIdP, + label typeIdQ, + const vector& UP, + const vector& UQ + ) const = 0; + + //- Apply collision + virtual void collide + ( + label typeIdP, + label typeIdQ, + vector& UP, + vector& UQ, + scalar& EiP, + scalar& EiQ + ) = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#define makeBinaryCollisionModel(CloudType) \ + \ + defineNamedTemplateTypeNameAndDebug \ + ( \ + BinaryCollisionModel<CloudType>, \ + 0 \ + ); \ + \ + defineTemplateRunTimeSelectionTable \ + ( \ + BinaryCollisionModel<CloudType>, \ + dictionary \ + ); + + +#define makeBinaryCollisionModelType(SS, CloudType, ParcelType) \ + \ + defineNamedTemplateTypeNameAndDebug(SS<CloudType<ParcelType> >, 0); \ + \ + BinaryCollisionModel<CloudType<ParcelType> >:: \ + adddictionaryConstructorToTable<SS<CloudType<ParcelType> > > \ + add##SS##CloudType##ParcelType##ConstructorToTable_; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "BinaryCollisionModel.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/submodels/BinaryCollisionModel/BinaryCollisionModel/NewBinaryCollisionModel.C b/src/lagrangian/dsmc/submodels/BinaryCollisionModel/BinaryCollisionModel/NewBinaryCollisionModel.C new file mode 100644 index 0000000000000000000000000000000000000000..8878164cdbf1425fcf9838a369ca9b855fcb60d4 --- /dev/null +++ b/src/lagrangian/dsmc/submodels/BinaryCollisionModel/BinaryCollisionModel/NewBinaryCollisionModel.C @@ -0,0 +1,69 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "BinaryCollisionModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class CloudType> +Foam::autoPtr<Foam::BinaryCollisionModel<CloudType> > +Foam::BinaryCollisionModel<CloudType>::New +( + const dictionary& dict, + CloudType& owner +) +{ + word BinaryCollisionModelType(dict.lookup("BinaryCollisionModel")); + + Info<< "Selecting BinaryCollisionModel " + << BinaryCollisionModelType + << endl; + + typename dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(BinaryCollisionModelType); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + FatalErrorIn + ( + "BinaryCollisionModel<CloudType>::New" + "(const dictionary&, CloudType&)" + ) + << "Unknown BinaryCollisionModelType type " + << BinaryCollisionModelType + << ", constructor not in hash table" << nl << nl + << " Valid BinaryCollisionModel types are:" << nl + << dictionaryConstructorTablePtr_->toc() << exit(FatalError); + } + + return autoPtr<BinaryCollisionModel<CloudType> > + ( + cstrIter()(dict, owner) + ); +} + + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/submodels/BinaryCollisionModel/LarsenBorgnakkeVariableHardSphere/LarsenBorgnakkeVariableHardSphere.C b/src/lagrangian/dsmc/submodels/BinaryCollisionModel/LarsenBorgnakkeVariableHardSphere/LarsenBorgnakkeVariableHardSphere.C new file mode 100644 index 0000000000000000000000000000000000000000..b6deaf1f0064cb65ed6c3e3b7d93cee12587b624 --- /dev/null +++ b/src/lagrangian/dsmc/submodels/BinaryCollisionModel/LarsenBorgnakkeVariableHardSphere/LarsenBorgnakkeVariableHardSphere.C @@ -0,0 +1,271 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "LarsenBorgnakkeVariableHardSphere.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template <class CloudType> +Foam::scalar Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::energyRatio +( + scalar ChiA, + scalar ChiB +) +{ + CloudType& cloud(this->owner()); + + Random& rndGen(cloud.rndGen()); + + scalar ChiAMinusOne = ChiA - 1; + + scalar ChiBMinusOne = ChiB - 1; + + if (ChiAMinusOne < SMALL && ChiBMinusOne < SMALL) + { + return rndGen.scalar01(); + } + + scalar energyRatio; + + scalar P; + + do + { + P = 0; + + energyRatio = rndGen.scalar01(); + + if (ChiAMinusOne < SMALL) + { + P = 1.0 - pow(energyRatio, ChiB); + } + else if (ChiBMinusOne < SMALL) + { + P = 1.0 - pow(energyRatio, ChiA); + } + else + { + P = + pow + ( + (ChiAMinusOne + ChiBMinusOne)*energyRatio/ChiAMinusOne, + ChiAMinusOne + ) + *pow + ( + (ChiAMinusOne + ChiBMinusOne)*(1 - energyRatio) + /ChiBMinusOne, + ChiBMinusOne + ); + } + } while (P < rndGen.scalar01()); + + return energyRatio; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template <class CloudType> +Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::LarsenBorgnakkeVariableHardSphere +( + const dictionary& dict, + CloudType& cloud +) +: + BinaryCollisionModel<CloudType>(dict, cloud, typeName), + relaxationCollisionNumber_ + ( + readScalar(this->coeffDict().lookup("relaxationCollisionNumber")) + ) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template <class CloudType> +Foam::LarsenBorgnakkeVariableHardSphere<CloudType>:: +~LarsenBorgnakkeVariableHardSphere() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + + +template <class CloudType> +Foam::scalar Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::sigmaTcR +( + label typeIdP, + label typeIdQ, + const vector& UP, + const vector& UQ +) const +{ + const CloudType& cloud(this->owner()); + + scalar dPQ = + 0.5 + *( + cloud.constProps(typeIdP).d() + + cloud.constProps(typeIdQ).d() + ); + + scalar omegaPQ = + 0.5 + *( + cloud.constProps(typeIdP).omega() + + cloud.constProps(typeIdQ).omega() + ); + + scalar cR = mag(UP - UQ); + + if (cR < VSMALL) + { + return 0; + } + + scalar mP = cloud.constProps(typeIdP).mass(); + + scalar mQ = cloud.constProps(typeIdQ).mass(); + + scalar mR = mP*mQ/(mP + mQ); + + // calculating cross section = pi*dPQ^2, where dPQ is from Bird, eq. 4.79 + scalar sigmaTPQ = + mathematicalConstant::pi*dPQ*dPQ + *pow(2.0*CloudType::kb*CloudType::Tref/(mR*cR*cR), omegaPQ - 0.5) + /exp(Foam::lgamma(2.5 - omegaPQ)); + + return sigmaTPQ*cR; +} + + +template <class CloudType> +void Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::collide +( + label typeIdP, + label typeIdQ, + vector& UP, + vector& UQ, + scalar& EiP, + scalar& EiQ +) +{ + CloudType& cloud(this->owner()); + + Random& rndGen(cloud.rndGen()); + + scalar inverseCollisionNumber = 1/relaxationCollisionNumber_; + + // Larsen Borgnakke internal energy redistribution part. Using the serial + // application of the LB method, as per the INELRS subroutine in Bird's + // DSMC0R.FOR + + scalar preCollisionEiP = EiP; + + scalar preCollisionEiQ = EiQ; + + scalar iDofP = cloud.constProps(typeIdP).internalDegreesOfFreedom(); + + scalar iDofQ = cloud.constProps(typeIdQ).internalDegreesOfFreedom(); + + scalar omegaPQ = + 0.5 + *( + cloud.constProps(typeIdP).omega() + + cloud.constProps(typeIdQ).omega() + ); + + scalar mP = cloud.constProps(typeIdP).mass(); + + scalar mQ = cloud.constProps(typeIdQ).mass(); + + scalar mR = mP*mQ/(mP + mQ); + + vector Ucm = (mP*UP + mQ*UQ)/(mP + mQ); + + scalar cRsqr = magSqr(UP - UQ); + + scalar availableEnergy = 0.5*mR*cRsqr; + + scalar ChiB = 2.5 - omegaPQ; + + if (iDofP > 0) + { + if (inverseCollisionNumber > rndGen.scalar01()) + { + availableEnergy += preCollisionEiP; + + scalar ChiA = 0.5*iDofP; + + EiP = energyRatio(ChiA, ChiB)*availableEnergy; + + availableEnergy -= EiP; + } + } + + if (iDofQ > 0) + { + if (inverseCollisionNumber > rndGen.scalar01()) + { + availableEnergy += preCollisionEiQ; + + // Change to general LB ratio calculation + scalar energyRatio = 1.0 - pow(rndGen.scalar01(),(1.0/ChiB)); + + EiQ = energyRatio*availableEnergy; + + availableEnergy -= EiQ; + } + } + + // Rescale the translational energy + scalar cR = sqrt(2.0*availableEnergy/mR); + + // Variable Hard Sphere collision part + + scalar cosTheta = 2.0*rndGen.scalar01() - 1.0; + + scalar sinTheta = sqrt(1.0 - cosTheta*cosTheta); + + scalar phi = 2.0*mathematicalConstant::pi*rndGen.scalar01(); + + vector postCollisionRelU = + cR + *vector + ( + cosTheta, + sinTheta*cos(phi), + sinTheta*sin(phi) + ); + + UP = Ucm + postCollisionRelU*mQ/(mP + mQ); + + UQ = Ucm - postCollisionRelU*mP/(mP + mQ); +} + + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/submodels/BinaryCollisionModel/LarsenBorgnakkeVariableHardSphere/LarsenBorgnakkeVariableHardSphere.H b/src/lagrangian/dsmc/submodels/BinaryCollisionModel/LarsenBorgnakkeVariableHardSphere/LarsenBorgnakkeVariableHardSphere.H new file mode 100644 index 0000000000000000000000000000000000000000..c95d70f24c1f4ad0cfa394728258594664c3f89a --- /dev/null +++ b/src/lagrangian/dsmc/submodels/BinaryCollisionModel/LarsenBorgnakkeVariableHardSphere/LarsenBorgnakkeVariableHardSphere.H @@ -0,0 +1,126 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +Class + Foam::LarsenBorgnakkeVariableHardSphere + +Description + Variable Hard Sphere BinaryCollision Model with Larsen Borgnakke internal + energy redistribution. Based on the INELRS subroutine in Bird's DSMC0R.FOR + +\*---------------------------------------------------------------------------*/ + +#ifndef LarsenBorgnakkeVariableHardSphere_H +#define LarsenBorgnakkeVariableHardSphere_H + +#include "BinaryCollisionModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +/*---------------------------------------------------------------------------*\ + Class LarsenBorgnakkeVariableHardSphere Declaration +\*---------------------------------------------------------------------------*/ + +template<class CloudType> +class LarsenBorgnakkeVariableHardSphere +: + public BinaryCollisionModel<CloudType> +{ + // Private data + + //- Relaxation collision number + const scalar relaxationCollisionNumber_; + + + // Private Member Functions + + //- Calculate the energy ratio for distribution to internal degrees of + // freedom + scalar energyRatio + ( + scalar ChiA, + scalar ChiB + ); + + +public: + + //- Runtime type information + TypeName("LarsenBorgnakkeVariableHardSphere"); + + + // Constructors + + //- Construct from dictionary + LarsenBorgnakkeVariableHardSphere + ( + const dictionary& dict, + CloudType& cloud + ); + + + // Destructor + virtual ~LarsenBorgnakkeVariableHardSphere(); + + + // Member Functions + + //- Return the collision cross section * relative velocity product + virtual scalar sigmaTcR + ( + label typeIdP, + label typeIdQ, + const vector& UP, + const vector& UQ + ) const; + + //- Apply collision + virtual void collide + ( + label typeIdP, + label typeIdQ, + vector& UP, + vector& UQ, + scalar& EiP, + scalar& EiQ + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "LarsenBorgnakkeVariableHardSphere.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/submodels/BinaryCollisionModel/VariableHardSphere/VariableHardSphere.C b/src/lagrangian/dsmc/submodels/BinaryCollisionModel/VariableHardSphere/VariableHardSphere.C new file mode 100644 index 0000000000000000000000000000000000000000..de47f1550dc9c66018d5fc3a4e3d60da8f64c0c2 --- /dev/null +++ b/src/lagrangian/dsmc/submodels/BinaryCollisionModel/VariableHardSphere/VariableHardSphere.C @@ -0,0 +1,144 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "VariableHardSphere.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template <class CloudType> +Foam::VariableHardSphere<CloudType>::VariableHardSphere +( + const dictionary& dict, + CloudType& cloud +) +: + BinaryCollisionModel<CloudType>(dict, cloud, typeName) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template <class CloudType> +Foam::VariableHardSphere<CloudType>::~VariableHardSphere() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + + +template <class CloudType> +Foam::scalar Foam::VariableHardSphere<CloudType>::sigmaTcR +( + label typeIdP, + label typeIdQ, + const vector& UP, + const vector& UQ +) const +{ + const CloudType& cloud(this->owner()); + + scalar dPQ = + 0.5 + *( + cloud.constProps(typeIdP).d() + + cloud.constProps(typeIdQ).d() + ); + + scalar omegaPQ = + 0.5 + *( + cloud.constProps(typeIdP).omega() + + cloud.constProps(typeIdQ).omega() + ); + + scalar cR = mag(UP - UQ); + + if (cR < VSMALL) + { + return 0; + } + + scalar mP = cloud.constProps(typeIdP).mass(); + + scalar mQ = cloud.constProps(typeIdQ).mass(); + + scalar mR = mP*mQ/(mP + mQ); + + // calculating cross section = pi*dPQ^2, where dPQ is from Bird, eq. 4.79 + scalar sigmaTPQ = + mathematicalConstant::pi*dPQ*dPQ + *pow(2.0*CloudType::kb*CloudType::Tref/(mR*cR*cR), omegaPQ - 0.5) + /exp(Foam::lgamma(2.5 - omegaPQ)); + + return sigmaTPQ*cR; +} + + +template <class CloudType> +void Foam::VariableHardSphere<CloudType>::collide +( + label typeIdP, + label typeIdQ, + vector& UP, + vector& UQ, + scalar& EiP, + scalar& EiQ +) +{ + CloudType& cloud(this->owner()); + + Random& rndGen(cloud.rndGen()); + + scalar mP = cloud.constProps(typeIdP).mass(); + + scalar mQ = cloud.constProps(typeIdQ).mass(); + + vector Ucm = (mP*UP + mQ*UQ)/(mP + mQ); + + scalar cR = mag(UP - UQ); + + scalar cosTheta = 2.0*rndGen.scalar01() - 1.0; + + scalar sinTheta = sqrt(1.0 - cosTheta*cosTheta); + + scalar phi = 2.0*mathematicalConstant::pi*rndGen.scalar01(); + + vector postCollisionRelU = + cR + *vector + ( + cosTheta, + sinTheta*cos(phi), + sinTheta*sin(phi) + ); + + UP = Ucm + postCollisionRelU*mQ/(mP + mQ); + + UQ = Ucm - postCollisionRelU*mP/(mP + mQ); +} + + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/submodels/BinaryCollisionModel/VariableHardSphere/VariableHardSphere.H b/src/lagrangian/dsmc/submodels/BinaryCollisionModel/VariableHardSphere/VariableHardSphere.H new file mode 100644 index 0000000000000000000000000000000000000000..a1dbdb9a270c0e7c8dcb3021601fc88355e035c2 --- /dev/null +++ b/src/lagrangian/dsmc/submodels/BinaryCollisionModel/VariableHardSphere/VariableHardSphere.H @@ -0,0 +1,108 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +Class + Foam::VariableHardSphere + +Description + Variable Hard Sphere BinaryCollision Model + +\*---------------------------------------------------------------------------*/ + +#ifndef VariableHardSphere_H +#define VariableHardSphere_H + +#include "BinaryCollisionModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +/*---------------------------------------------------------------------------*\ + Class VariableHardSphere Declaration +\*---------------------------------------------------------------------------*/ + +template<class CloudType> +class VariableHardSphere +: + public BinaryCollisionModel<CloudType> +{ +public: + + //- Runtime type information + TypeName("VariableHardSphere"); + + + // Constructors + + //- Construct from dictionary + VariableHardSphere + ( + const dictionary& dict, + CloudType& cloud + ); + + + // Destructor + virtual ~VariableHardSphere(); + + + // Member Functions + + //- Return the collision cross section * relative velocity product + virtual scalar sigmaTcR + ( + label typeIdP, + label typeIdQ, + const vector& UP, + const vector& UQ + ) const; + + //- Apply collision + virtual void collide + ( + label typeIdP, + label typeIdQ, + vector& UP, + vector& UQ, + scalar& EiP, + scalar& EiQ + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "VariableHardSphere.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/submodels/InflowBoundaryModel/FreeStream/FreeStream.C b/src/lagrangian/dsmc/submodels/InflowBoundaryModel/FreeStream/FreeStream.C new file mode 100644 index 0000000000000000000000000000000000000000..f4203f4d66f7e85eaf335eee7c5c3b80521dd4e0 --- /dev/null +++ b/src/lagrangian/dsmc/submodels/InflowBoundaryModel/FreeStream/FreeStream.C @@ -0,0 +1,280 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "FreeStream.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template <class CloudType> +Foam::FreeStream<CloudType>::FreeStream +( + const dictionary& dict, + CloudType& cloud +) +: + InflowBoundaryModel<CloudType>(dict, cloud, typeName), + patchIndex_(), + temperature_(readScalar(this->coeffDict().lookup("temperature"))), + velocity_(this->coeffDict().lookup("velocity")), + moleculeTypeIds_(), + numberDensities_(), + particleFluxAccumulators_() +{ + word patchName = this->coeffDict().lookup("patch"); + + patchIndex_ = cloud.mesh().boundaryMesh().findPatchID(patchName); + + const polyPatch& patch = cloud.mesh().boundaryMesh()[patchIndex_]; + + if (patchIndex_ == -1) + { + FatalErrorIn + ( + "Foam::FreeStream<CloudType>::FreeStream" + "(" + "const dictionary&, " + "CloudType&" + ")" + ) << "patch " << patchName << " not found." << nl + << abort(FatalError); + } + + const dictionary& numberDensitiesDict + ( + this->coeffDict().subDict("numberDensities") + ); + + List<word> molecules(numberDensitiesDict.toc()); + + numberDensities_.setSize(molecules.size()); + + moleculeTypeIds_.setSize(molecules.size()); + + forAll(molecules, i) + { + numberDensities_[i] = readScalar + ( + numberDensitiesDict.lookup(molecules[i]) + ); + + moleculeTypeIds_[i] = findIndex(cloud.typeIdList(), molecules[i]); + + if (moleculeTypeIds_[i] == -1) + { + FatalErrorIn + ( + "Foam::FreeStream<CloudType>::FreeStream" + "(" + "const dictionary&, " + "CloudType&" + ")" + ) << "typeId " << molecules[i] << "not defined in cloud." << nl + << abort(FatalError); + } + } + + numberDensities_ /= cloud.nParticle(); + + particleFluxAccumulators_.setSize + ( + molecules.size(), + Field<scalar>(patch.size(), 0) + ); +} + + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template <class CloudType> +Foam::FreeStream<CloudType>::~FreeStream() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template <class CloudType> +void Foam::FreeStream<CloudType>::inflow() +{ + CloudType& cloud(this->owner()); + + const polyMesh& mesh(cloud.mesh()); + + const scalar deltaT = mesh.time().deltaT().value(); + + Random& rndGen(cloud.rndGen()); + + const polyPatch& patch = mesh.boundaryMesh()[patchIndex_]; + + label particlesInserted = 0; + + // Add mass to the accumulators. negative face area dotted with the + // velocity to point flux into the domain. + + forAll(particleFluxAccumulators_, i) + { + particleFluxAccumulators_[i] += + -patch.faceAreas() & (velocity_*numberDensities_[i]*deltaT); + } + + forAll(patch, f) + { + // Loop over all faces as the outer loop to avoid calculating + // geometrical properties multiple times. + + labelList faceVertices = patch[f]; + + label nVertices = faceVertices.size(); + + label globalFaceIndex = f + patch.start(); + + label cell = mesh.faceOwner()[globalFaceIndex]; + + const vector& fC = patch.faceCentres()[f]; + + scalar fA = mag(patch.faceAreas()[f]); + + // Cummulative triangle area fractions + List<scalar> cTriAFracs(nVertices); + + for (label v = 0; v < nVertices - 1; v++) + { + const point& vA = mesh.points()[faceVertices[v]]; + + const point& vB = mesh.points()[faceVertices[(v + 1)]]; + + cTriAFracs[v] = + 0.5*mag((vA - fC)^(vB - fC))/fA + + cTriAFracs[max((v - 1), 0)]; + } + + // Force the last area fraction value to 1.0 to avoid any + // rounding/non-flat face errors giving a value < 1.0 + cTriAFracs[nVertices - 1] = 1.0; + + // Normal unit vector *negative* so normal is pointing into the + // domain + vector nw = patch.faceAreas()[f]; + nw /= -mag(nw); + + // Wall tangential unit vector. Use the direction between the + // face centre and the first vertex in the list + vector tw1 = fC - (mesh.points()[faceVertices[0]]); + tw1 /= mag(tw1); + + // Other tangential unit vector. Rescaling in case face is not + // flat and nw and tw1 aren't perfectly orthogonal + vector tw2 = nw^tw1; + tw2 /= mag(tw2); + + forAll(particleFluxAccumulators_, i) + { + scalar& faceAccumulator = particleFluxAccumulators_[i][f]; + + // Number of particles to insert + label nI = max(label(faceAccumulator), 0); + + faceAccumulator -= nI; + + label typeId = moleculeTypeIds_[i]; + + scalar mass = cloud.constProps(typeId).mass(); + + for (label n = 0; n < nI; n++) + { + // Choose a triangle to insert on, based on their relative area + + scalar triSelection = rndGen.scalar01(); + + // Selected triangle + label sTri = -1; + + forAll(cTriAFracs, tri) + { + sTri = tri; + + if (cTriAFracs[tri] >= triSelection) + { + break; + } + } + + // Randomly distribute the points on the triangle, using the + // method from: + // Generating Random Points in Triangles + // by Greg Turk + // from "Graphics Gems", Academic Press, 1990 + // http://tog.acm.org/GraphicsGems/gems/TriPoints.c + + const point& A = fC; + const point& B = mesh.points()[faceVertices[sTri]]; + const point& C = + mesh.points()[faceVertices[(sTri + 1) % nVertices]]; + + scalar s = rndGen.scalar01(); + scalar t = sqrt(rndGen.scalar01()); + + point p = (1 - t)*A + (1 - s)*t*B + s*t*C; + + vector U = + sqrt(CloudType::kb*temperature_/mass) + *( + rndGen.GaussNormal()*tw1 + + rndGen.GaussNormal()*tw2 + - sqrt(-2.0*log(max(1 - rndGen.scalar01(), VSMALL)))*nw + ); + + U += velocity_; + + scalar Ei = cloud.equipartitionInternalEnergy + ( + temperature_, + cloud.constProps(typeId).internalDegreesOfFreedom() + ); + + cloud.addNewParcel + ( + p, + U, + Ei, + cell, + typeId + ); + + particlesInserted++; + } + } + } + + reduce(particlesInserted, sumOp<label>()); + + Info<< " Particles inserted = " + << particlesInserted << endl; + +} + + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/submodels/InflowBoundaryModel/FreeStream/FreeStream.H b/src/lagrangian/dsmc/submodels/InflowBoundaryModel/FreeStream/FreeStream.H new file mode 100644 index 0000000000000000000000000000000000000000..f1bd4cc32133490ea027136a6de2f36798898574 --- /dev/null +++ b/src/lagrangian/dsmc/submodels/InflowBoundaryModel/FreeStream/FreeStream.H @@ -0,0 +1,117 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::FreeStream + +Description + Inserting new particles across the faces of a specified patch for a free + stream. Uniform values of temperature, velocity and number densities + +\*---------------------------------------------------------------------------*/ + +#ifndef FreeStream_H +#define FreeStream_H + +#include "InflowBoundaryModel.H" +#include "polyMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +/*---------------------------------------------------------------------------*\ + Class FreeStream Declaration +\*---------------------------------------------------------------------------*/ + +template<class CloudType> +class FreeStream +: + public InflowBoundaryModel<CloudType> +{ + // Private data + + //- Index of patch to introduce particles across + label patchIndex_; + + //- Temperature of the free stream + scalar temperature_; + + //- Velocity of the free stream + vector velocity_; + + //- The molecule types to be introduced + List<label> moleculeTypeIds_; + + //- The number density of the species in the inflow + Field<scalar> numberDensities_; + + //- A List of Fields, one Field for every species to be introduced, each + // field entry corresponding to a face on the patch to be injected + // across. + List<Field<scalar> > particleFluxAccumulators_; + + +public: + + //- Runtime type information + TypeName("FreeStream"); + + + // Constructors + + //- Construct from dictionary + FreeStream + ( + const dictionary& dict, + CloudType& cloud + ); + + + // Destructor + virtual ~FreeStream(); + + + // Member Functions + + //- Introduce particles + virtual void inflow(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "FreeStream.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/submodels/InflowBoundaryModel/InflowBoundaryModel/InflowBoundaryModel.C b/src/lagrangian/dsmc/submodels/InflowBoundaryModel/InflowBoundaryModel/InflowBoundaryModel.C new file mode 100644 index 0000000000000000000000000000000000000000..8e99e3f43f8191a69c57f9855d702d607dcf50d5 --- /dev/null +++ b/src/lagrangian/dsmc/submodels/InflowBoundaryModel/InflowBoundaryModel/InflowBoundaryModel.C @@ -0,0 +1,87 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "InflowBoundaryModel.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class CloudType> +Foam::InflowBoundaryModel<CloudType>::InflowBoundaryModel +( + const dictionary& dict, + CloudType& owner, + const word& type +) +: + dict_(dict), + owner_(owner), + coeffDict_(dict.subDict(type + "Coeffs")) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template<class CloudType> +Foam::InflowBoundaryModel<CloudType>::~InflowBoundaryModel() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class CloudType> +const CloudType& Foam::InflowBoundaryModel<CloudType>::owner() const +{ + return owner_; +} + + +template<class CloudType> +CloudType& Foam::InflowBoundaryModel<CloudType>::owner() +{ + return owner_; +} + + +template<class CloudType> +const Foam::dictionary& Foam::InflowBoundaryModel<CloudType>::dict() const +{ + return dict_; +} + + +template<class CloudType> +const Foam::dictionary& Foam::InflowBoundaryModel<CloudType>::coeffDict() const +{ + return coeffDict_; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "NewInflowBoundaryModel.C" + +// ************************************************************************* // + diff --git a/src/lagrangian/dsmc/submodels/InflowBoundaryModel/InflowBoundaryModel/InflowBoundaryModel.H b/src/lagrangian/dsmc/submodels/InflowBoundaryModel/InflowBoundaryModel/InflowBoundaryModel.H new file mode 100644 index 0000000000000000000000000000000000000000..6b01a82f40f1233dadbf1ad27434e0659c540a84 --- /dev/null +++ b/src/lagrangian/dsmc/submodels/InflowBoundaryModel/InflowBoundaryModel/InflowBoundaryModel.H @@ -0,0 +1,166 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::InflowBoundaryModel + + +Description + Templated inflow boundary model class + +SourceFiles + InflowBoundaryModel.C + NewInflowBoundaryModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef InflowBoundaryModel_H +#define InflowBoundaryModel_H + +#include "IOdictionary.H" +#include "autoPtr.H" +#include "runTimeSelectionTables.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class InflowBoundaryModel Declaration +\*---------------------------------------------------------------------------*/ + +template<class CloudType> +class InflowBoundaryModel +{ + // Private data + + //- The cloud dictionary + const dictionary& dict_; + + // Reference to the owner cloud class + CloudType& owner_; + + //- The coefficients dictionary + const dictionary coeffDict_; + + +public: + + //- Runtime type information + TypeName("InflowBoundaryModel"); + + //- Declare runtime constructor selection table + declareRunTimeSelectionTable + ( + autoPtr, + InflowBoundaryModel, + dictionary, + ( + const dictionary& dict, + CloudType& owner + ), + (dict, owner) + ); + + + // Constructors + + //- Construct from dictionary + InflowBoundaryModel + ( + const dictionary& dict, + CloudType& owner, + const word& type + ); + + + //- Destructor + virtual ~InflowBoundaryModel(); + + + //- Selector + static autoPtr<InflowBoundaryModel<CloudType> > New + ( + const dictionary& dict, + CloudType& owner + ); + + + // Access + + //- Return const access the owner cloud object + inline const CloudType& owner() const; + + //- Return non-const access the owner cloud object for manipulation + inline CloudType& owner(); + + //- Return the owner cloud dictionary + inline const dictionary& dict() const; + + //- Return the coefficients dictionary + inline const dictionary& coeffDict() const; + + //- Introduce particles + virtual void inflow() = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#define makeInflowBoundaryModel(CloudType) \ + \ + defineNamedTemplateTypeNameAndDebug(InflowBoundaryModel<CloudType>, 0); \ + \ + defineTemplateRunTimeSelectionTable \ + ( \ + InflowBoundaryModel<CloudType>, \ + dictionary \ + ); + + +#define makeInflowBoundaryModelType(SS, CloudType, ParcelType) \ + \ + defineNamedTemplateTypeNameAndDebug(SS<CloudType<ParcelType> >, 0); \ + \ + InflowBoundaryModel<CloudType<ParcelType> >:: \ + adddictionaryConstructorToTable<SS<CloudType<ParcelType> > > \ + add##SS##CloudType##ParcelType##ConstructorToTable_; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "InflowBoundaryModel.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/submodels/InflowBoundaryModel/InflowBoundaryModel/NewInflowBoundaryModel.C b/src/lagrangian/dsmc/submodels/InflowBoundaryModel/InflowBoundaryModel/NewInflowBoundaryModel.C new file mode 100644 index 0000000000000000000000000000000000000000..3abc5b29368d1af2c13fb65f30775d57ecfc461c --- /dev/null +++ b/src/lagrangian/dsmc/submodels/InflowBoundaryModel/InflowBoundaryModel/NewInflowBoundaryModel.C @@ -0,0 +1,63 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "InflowBoundaryModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class CloudType> +Foam::autoPtr<Foam::InflowBoundaryModel<CloudType> > +Foam::InflowBoundaryModel<CloudType>::New +( + const dictionary& dict, + CloudType& owner +) +{ + word InflowBoundaryModelType(dict.lookup("InflowBoundaryModel")); + + Info<< "Selecting InflowBoundaryModel " << InflowBoundaryModelType << endl; + + typename dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(InflowBoundaryModelType); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + FatalErrorIn + ( + "InflowBoundaryModel<CloudType>::New" + "(const dictionary&, CloudType&)" + ) << "Unknown InflowBoundaryModelType type " + << InflowBoundaryModelType + << ", constructor not in hash table" << nl << nl + << " Valid InflowBoundaryModel types are:" << nl + << dictionaryConstructorTablePtr_->toc() << exit(FatalError); + } + + return autoPtr<InflowBoundaryModel<CloudType> >(cstrIter()(dict, owner)); +} + + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/submodels/InflowBoundaryModel/NoInflow/NoInflow.C b/src/lagrangian/dsmc/submodels/InflowBoundaryModel/NoInflow/NoInflow.C new file mode 100644 index 0000000000000000000000000000000000000000..d04db500daa1fa762ada76543d72bb045a606da0 --- /dev/null +++ b/src/lagrangian/dsmc/submodels/InflowBoundaryModel/NoInflow/NoInflow.C @@ -0,0 +1,56 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "NoInflow.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template <class CloudType> +Foam::NoInflow<CloudType>::NoInflow +( + const dictionary& dict, + CloudType& cloud +) +: + InflowBoundaryModel<CloudType>(dict, cloud, typeName) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template <class CloudType> +Foam::NoInflow<CloudType>::~NoInflow() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template <class CloudType> +void Foam::NoInflow<CloudType>::inflow() +{} + + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/submodels/InflowBoundaryModel/NoInflow/NoInflow.H b/src/lagrangian/dsmc/submodels/InflowBoundaryModel/NoInflow/NoInflow.H new file mode 100644 index 0000000000000000000000000000000000000000..e3f46622e93c87519220169803ba5cdbd6c509ac --- /dev/null +++ b/src/lagrangian/dsmc/submodels/InflowBoundaryModel/NoInflow/NoInflow.H @@ -0,0 +1,92 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::NoInflow + +Description + Not inserting any particles + +\*---------------------------------------------------------------------------*/ + +#ifndef NoInflow_H +#define NoInflow_H + +#include "InflowBoundaryModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +/*---------------------------------------------------------------------------*\ + Class NoInflow Declaration +\*---------------------------------------------------------------------------*/ + +template<class CloudType> +class NoInflow +: + public InflowBoundaryModel<CloudType> +{ +public: + + //- Runtime type information + TypeName("NoInflow"); + + + // Constructors + + //- Construct from dictionary + NoInflow + ( + const dictionary& dict, + CloudType& cloud + ); + + + // Destructor + virtual ~NoInflow(); + + + // Member Functions + + //- Introduce particles (none in this case) + virtual void inflow(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "NoInflow.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/submodels/WallInteractionModel/MaxwellianThermal/MaxwellianThermal.C b/src/lagrangian/dsmc/submodels/WallInteractionModel/MaxwellianThermal/MaxwellianThermal.C new file mode 100644 index 0000000000000000000000000000000000000000..c2c12ce5ca7d835941c812b6920a09ddc694355f --- /dev/null +++ b/src/lagrangian/dsmc/submodels/WallInteractionModel/MaxwellianThermal/MaxwellianThermal.C @@ -0,0 +1,124 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "MaxwellianThermal.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template <class CloudType> +Foam::MaxwellianThermal<CloudType>::MaxwellianThermal +( + const dictionary& dict, + CloudType& cloud +) +: + WallInteractionModel<CloudType>(dict, cloud, typeName) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template <class CloudType> +Foam::MaxwellianThermal<CloudType>::~MaxwellianThermal() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template <class CloudType> +void Foam::MaxwellianThermal<CloudType>::correct +( + const wallPolyPatch& wpp, + const label faceId, + vector& U, + scalar& Ei, + label typeId +) +{ + label wppIndex = wpp.index(); + + label wppLocalFace = wpp.whichFace(faceId); + + vector nw = wpp.faceAreas()[wppLocalFace]; + + // Normal unit vector + nw /= mag(nw); + + // Normal velocity magnitude + scalar magUn = U & nw; + + // Wall tangential velocity (flow direction) + vector Ut = U - magUn*nw; + + CloudType& cloud(this->owner()); + + Random& rndGen(cloud.rndGen()); + + while (mag(Ut) < SMALL) + { + // If the incident velocity is parallel to the face normal, no + // tangential direction can be chosen. Add a perturbation to the + // incoming velocity and recalculate. + + U = vector + ( + U.x()*(0.8 + 0.2*rndGen.scalar01()), + U.y()*(0.8 + 0.2*rndGen.scalar01()), + U.z()*(0.8 + 0.2*rndGen.scalar01()) + ); + + magUn = U & nw; + + Ut = U - magUn*nw; + } + + // Wall tangential unit vector + vector tw1 = Ut/mag(Ut); + + // Other tangential unit vector + vector tw2 = nw^tw1; + + scalar T = cloud.T().boundaryField()[wppIndex][wppLocalFace]; + + scalar mass = cloud.constProps(typeId).mass(); + + scalar iDof = cloud.constProps(typeId).internalDegreesOfFreedom(); + + U = + sqrt(CloudType::kb*T/mass) + *( + rndGen.GaussNormal()*tw1 + + rndGen.GaussNormal()*tw2 + - sqrt(-2.0*log(max(1 - rndGen.scalar01(), VSMALL)))*nw + ); + + U += cloud.U().boundaryField()[wppIndex][wppLocalFace]; + + Ei = cloud.equipartitionInternalEnergy(T, iDof); +} + + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/submodels/WallInteractionModel/MaxwellianThermal/MaxwellianThermal.H b/src/lagrangian/dsmc/submodels/WallInteractionModel/MaxwellianThermal/MaxwellianThermal.H new file mode 100644 index 0000000000000000000000000000000000000000..2b71beaba006c224e5c41dea13a6a79aa6b68dcc --- /dev/null +++ b/src/lagrangian/dsmc/submodels/WallInteractionModel/MaxwellianThermal/MaxwellianThermal.H @@ -0,0 +1,100 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::MaxwellianThermal + +Description + Wall interaction setting microscopic velocity to a random one drawn from a + Maxwellian distribution corresponding to a specified temperature + +\*---------------------------------------------------------------------------*/ + +#ifndef MaxwellianThermal_H +#define MaxwellianThermal_H + +#include "WallInteractionModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +/*---------------------------------------------------------------------------*\ + Class MaxwellianThermal Declaration +\*---------------------------------------------------------------------------*/ + +template<class CloudType> +class MaxwellianThermal +: + public WallInteractionModel<CloudType> +{ +public: + + //- Runtime type information + TypeName("MaxwellianThermal"); + + + // Constructors + + //- Construct from dictionary + MaxwellianThermal + ( + const dictionary& dict, + CloudType& cloud + ); + + + // Destructor + virtual ~MaxwellianThermal(); + + + // Member Functions + + //- Apply wall correction + virtual void correct + ( + const wallPolyPatch& wpp, + const label faceId, + vector& U, + scalar& Ei, + label typeId + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "MaxwellianThermal.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/submodels/WallInteractionModel/SpecularReflection/SpecularReflection.C b/src/lagrangian/dsmc/submodels/WallInteractionModel/SpecularReflection/SpecularReflection.C new file mode 100644 index 0000000000000000000000000000000000000000..4de5507bf00f07b9df5d646cefb4f889e029d265 --- /dev/null +++ b/src/lagrangian/dsmc/submodels/WallInteractionModel/SpecularReflection/SpecularReflection.C @@ -0,0 +1,75 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "error.H" + +#include "SpecularReflection.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template <class CloudType> +Foam::SpecularReflection<CloudType>::SpecularReflection +( + const dictionary& dict, + CloudType& cloud +) +: + WallInteractionModel<CloudType>(dict, cloud, typeName) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template <class CloudType> +Foam::SpecularReflection<CloudType>::~SpecularReflection() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template <class CloudType> +void Foam::SpecularReflection<CloudType>::correct +( + const wallPolyPatch& wpp, + const label faceId, + vector& U, + scalar& Ei, + label typeId +) +{ + vector nw = wpp.faceAreas()[wpp.whichFace(faceId)]; + nw /= mag(nw); + + scalar magUn = U & nw; + + if (magUn > 0.0) + { + U -= 2.0*magUn*nw; + } +} + + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/submodels/WallInteractionModel/SpecularReflection/SpecularReflection.H b/src/lagrangian/dsmc/submodels/WallInteractionModel/SpecularReflection/SpecularReflection.H new file mode 100644 index 0000000000000000000000000000000000000000..d2208bd3503d29b6ca40a4805718a9f655882134 --- /dev/null +++ b/src/lagrangian/dsmc/submodels/WallInteractionModel/SpecularReflection/SpecularReflection.H @@ -0,0 +1,99 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::SpecularReflection + +Description + Reversing the wall-normal component of the particle velocity + +\*---------------------------------------------------------------------------*/ + +#ifndef SpecularReflection_H +#define SpecularReflection_H + +#include "WallInteractionModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +/*---------------------------------------------------------------------------*\ + Class SpecularReflection Declaration +\*---------------------------------------------------------------------------*/ + +template<class CloudType> +class SpecularReflection +: + public WallInteractionModel<CloudType> +{ +public: + + //- Runtime type information + TypeName("SpecularReflection"); + + + // Constructors + + //- Construct from dictionary + SpecularReflection + ( + const dictionary& dict, + CloudType& cloud + ); + + + // Destructor + virtual ~SpecularReflection(); + + + // Member Functions + + //- Apply wall correction + virtual void correct + ( + const wallPolyPatch& wpp, + const label faceId, + vector& U, + scalar& Ei, + label typeId + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "SpecularReflection.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/submodels/WallInteractionModel/WallInteractionModel/NewWallInteractionModel.C b/src/lagrangian/dsmc/submodels/WallInteractionModel/WallInteractionModel/NewWallInteractionModel.C new file mode 100644 index 0000000000000000000000000000000000000000..85652f2379327af4db6aa9c9a6e8e3bcff873dfc --- /dev/null +++ b/src/lagrangian/dsmc/submodels/WallInteractionModel/WallInteractionModel/NewWallInteractionModel.C @@ -0,0 +1,65 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "WallInteractionModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class CloudType> +Foam::autoPtr<Foam::WallInteractionModel<CloudType> > +Foam::WallInteractionModel<CloudType>::New +( + const dictionary& dict, + CloudType& owner +) +{ + word WallInteractionModelType(dict.lookup("WallInteractionModel")); + + Info<< "Selecting WallInteractionModel " << WallInteractionModelType + << endl; + + typename dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(WallInteractionModelType); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + FatalErrorIn + ( + "WallInteractionModel<CloudType>::New" + "(const dictionary&, CloudType&)" + ) + << "Unknown WallInteractionModelType type " + << WallInteractionModelType + << ", constructor not in hash table" << nl << nl + << " Valid WallInteractionModel types are:" << nl + << dictionaryConstructorTablePtr_->toc() << exit(FatalError); + } + + return autoPtr<WallInteractionModel<CloudType> >(cstrIter()(dict, owner)); +} + + +// ************************************************************************* // diff --git a/src/lagrangian/dsmc/submodels/WallInteractionModel/WallInteractionModel/WallInteractionModel.C b/src/lagrangian/dsmc/submodels/WallInteractionModel/WallInteractionModel/WallInteractionModel.C new file mode 100644 index 0000000000000000000000000000000000000000..060d5dd76d9c59f1a2c4e896550c0fb1ee88f1df --- /dev/null +++ b/src/lagrangian/dsmc/submodels/WallInteractionModel/WallInteractionModel/WallInteractionModel.C @@ -0,0 +1,88 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "WallInteractionModel.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class CloudType> +Foam::WallInteractionModel<CloudType>::WallInteractionModel +( + const dictionary& dict, + CloudType& owner, + const word& type +) +: + dict_(dict), + owner_(owner), + coeffDict_(dict.subDict(type + "Coeffs")) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template<class CloudType> +Foam::WallInteractionModel<CloudType>::~WallInteractionModel() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class CloudType> +const CloudType& Foam::WallInteractionModel<CloudType>::owner() const +{ + return owner_; +} + + +template<class CloudType> +CloudType& Foam::WallInteractionModel<CloudType>::owner() +{ + return owner_; +} + + +template<class CloudType> +const Foam::dictionary& Foam::WallInteractionModel<CloudType>::dict() const +{ + return dict_; +} + + +template<class CloudType> +const Foam::dictionary& +Foam::WallInteractionModel<CloudType>::coeffDict() const +{ + return coeffDict_; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "NewWallInteractionModel.C" + +// ************************************************************************* // + diff --git a/src/lagrangian/dsmc/submodels/WallInteractionModel/WallInteractionModel/WallInteractionModel.H b/src/lagrangian/dsmc/submodels/WallInteractionModel/WallInteractionModel/WallInteractionModel.H new file mode 100644 index 0000000000000000000000000000000000000000..582bf2b1065ce26ec0113398357fed1a75d92a69 --- /dev/null +++ b/src/lagrangian/dsmc/submodels/WallInteractionModel/WallInteractionModel/WallInteractionModel.H @@ -0,0 +1,175 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::WallInteractionModel + +Description + Templated wall interaction model class + +SourceFiles + WallInteractionModel.C + NewWallInteractionModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef WallInteractionModel_H +#define WallInteractionModel_H + +#include "IOdictionary.H" +#include "autoPtr.H" +#include "runTimeSelectionTables.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class WallInteractionModel Declaration +\*---------------------------------------------------------------------------*/ + +template<class CloudType> +class WallInteractionModel +{ + // Private data + + //- The cloud dictionary + const dictionary& dict_; + + // reference to the owner cloud class + CloudType& owner_; + + //- The coefficients dictionary + const dictionary coeffDict_; + + +public: + + //- Runtime type information + TypeName("WallInteractionModel"); + + //- Declare runtime constructor selection table + declareRunTimeSelectionTable + ( + autoPtr, + WallInteractionModel, + dictionary, + ( + const dictionary& dict, + CloudType& owner + ), + (dict, owner) + ); + + + // Constructors + + //- Construct from components + WallInteractionModel + ( + const dictionary& dict, + CloudType& owner, + const word& type + ); + + + // Destructor + virtual ~WallInteractionModel(); + + + //- Selector + static autoPtr<WallInteractionModel<CloudType> > New + ( + const dictionary& dict, + CloudType& owner + ); + + + // Access + + //- Return the owner cloud object + const CloudType& owner() const; + + //- Return non-const access to the owner cloud object + CloudType& owner(); + + //- Return the dictionary + const dictionary& dict() const; + + //- Return the coefficients dictionary + const dictionary& coeffDict() const; + + + // Member Functions + + //- Apply wall correction + virtual void correct + ( + const wallPolyPatch& wpp, + const label faceId, + vector& U, + scalar& Ei, + label typeId + ) = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#define makeWallInteractionModel(CloudType) \ + \ + defineNamedTemplateTypeNameAndDebug(WallInteractionModel<CloudType>, 0); \ + \ + defineTemplateRunTimeSelectionTable \ + ( \ + WallInteractionModel<CloudType>, \ + dictionary \ + ); + + +#define makeWallInteractionModelType(SS, CloudType, ParcelType) \ + \ + defineNamedTemplateTypeNameAndDebug(SS<CloudType<ParcelType> >, 0); \ + \ + WallInteractionModel<CloudType<ParcelType> >:: \ + adddictionaryConstructorToTable<SS<CloudType<ParcelType> > > \ + add##SS##CloudType##ParcelType##ConstructorToTable_; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "WallInteractionModel.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/directMapped/directMappedPolyPatch/directMappedPolyPatch.C b/src/meshTools/directMapped/directMappedPolyPatch/directMappedPolyPatch.C index e97377294c03a4f0b8df6c7868cac0f30c3289b2..9dbe7e8c1331ef7a68bdb0d4ade891b8aa002aef 100644 --- a/src/meshTools/directMapped/directMappedPolyPatch/directMappedPolyPatch.C +++ b/src/meshTools/directMapped/directMappedPolyPatch/directMappedPolyPatch.C @@ -474,7 +474,7 @@ void Foam::directMappedPolyPatch::calcMapping() const forAll(subMap, procI) { - sendLabels[procI] = IndirectList<label> + sendLabels[procI] = UIndirectList<label> ( sampleIndices, subMap[procI] @@ -493,7 +493,7 @@ void Foam::directMappedPolyPatch::calcMapping() const forAll(constructMap, procI) { receiveFaceLabels[procI] = - IndirectList<label>(patchFaces, constructMap[procI]); + UIndirectList<label>(patchFaces, constructMap[procI]); if (debug) { diff --git a/src/meshTools/meshTools/meshTools.C b/src/meshTools/meshTools/meshTools.C index f826675b30a0fd9ed2985c1459cf3d88035cead9..4568b32e38ad8179c9d280678be0a88cd416a116 100644 --- a/src/meshTools/meshTools/meshTools.C +++ b/src/meshTools/meshTools/meshTools.C @@ -545,7 +545,7 @@ Foam::label Foam::meshTools::otherEdge "meshTools::otherEdge(const primitiveMesh&, const labelList&" ", const label, const label)" ) << "Can not find edge in " - << IndirectList<edge>(mesh.edges(), edgeLabels)() + << UIndirectList<edge>(mesh.edges(), edgeLabels)() << " connected to edge " << thisEdgeI << " with vertices " << mesh.edges()[thisEdgeI] << " on side " << thisVertI << abort(FatalError); diff --git a/src/meshTools/primitiveMeshGeometry/primitiveMeshGeometry.C b/src/meshTools/primitiveMeshGeometry/primitiveMeshGeometry.C index 0b226e3e0241d100ad05e63f60eb5176831dd039..37f3c21fd0b26d5fb7fa1afc0af77ebf62465c72 100644 --- a/src/meshTools/primitiveMeshGeometry/primitiveMeshGeometry.C +++ b/src/meshTools/primitiveMeshGeometry/primitiveMeshGeometry.C @@ -102,8 +102,8 @@ void Foam::primitiveMeshGeometry::updateCellCentresAndVols ) { // Clear the fields for accumulation - IndirectList<vector>(cellCentres_, changedCells) = vector::zero; - IndirectList<scalar>(cellVolumes_, changedCells) = 0.0; + UIndirectList<vector>(cellCentres_, changedCells) = vector::zero; + UIndirectList<scalar>(cellVolumes_, changedCells) = 0.0; const labelList& own = mesh_.faceOwner(); const labelList& nei = mesh_.faceNeighbour(); @@ -111,9 +111,9 @@ void Foam::primitiveMeshGeometry::updateCellCentresAndVols // first estimate the approximate cell centre as the average of face centres vectorField cEst(mesh_.nCells()); - IndirectList<vector>(cEst, changedCells) = vector::zero; + UIndirectList<vector>(cEst, changedCells) = vector::zero; scalarField nCellFaces(mesh_.nCells()); - IndirectList<scalar>(nCellFaces, changedCells) = 0.0; + UIndirectList<scalar>(nCellFaces, changedCells) = 0.0; forAll(changedFaces, i) { diff --git a/src/meshTools/searchableSurface/searchableSurfaceCollection.C b/src/meshTools/searchableSurface/searchableSurfaceCollection.C index ce6ddd643122703e9214fc6041a5a76265b098f4..7c79c2779e7eb53f027308382d8e941f1272dbf2 100644 --- a/src/meshTools/searchableSurface/searchableSurfaceCollection.C +++ b/src/meshTools/searchableSurface/searchableSurfaceCollection.C @@ -432,7 +432,7 @@ void Foam::searchableSurfaceCollection::getRegion labelList surfRegion; subGeom_[surfI].getRegion ( - IndirectList<pointIndexHit>(info, indices), + UIndirectList<pointIndexHit>(info, indices), surfRegion ); forAll(indices, i) @@ -495,7 +495,7 @@ void Foam::searchableSurfaceCollection::getNormal vectorField surfNormal; subGeom_[surfI].getNormal ( - IndirectList<pointIndexHit>(info, indices), + UIndirectList<pointIndexHit>(info, indices), surfNormal ); forAll(indices, i) diff --git a/src/meshTools/sets/topoSets/topoSet.C b/src/meshTools/sets/topoSets/topoSet.C index d80b92185d561d13824f46187b5336893e17b2ee..152193313ec3e5315bf897744643f9e67ac7792a 100644 --- a/src/meshTools/sets/topoSets/topoSet.C +++ b/src/meshTools/sets/topoSets/topoSet.C @@ -255,10 +255,7 @@ void topoSet::writeDebug ) const { // Bounding box of contents. - boundBox bb - ( - pointField(IndirectList<point>(coords, toc())()) - ); + boundBox bb(pointField(coords, toc())); Pout<< "Set bounding box: min = " << bb.min() << " max = " << bb.max() << " meters. " << endl << endl; diff --git a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.C b/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.C index 16d3a328a0843b07be1b05c83db3e46fdc3b62a4..8eb7ca65feca6864afb71f9086d62a80b19a4e31 100644 --- a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.C +++ b/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.C @@ -308,6 +308,7 @@ Foam::fieldAverage::fieldAverage active_(true), prevTimeIndex_(-1), cleanRestart_(false), + resetOnOutput_(false), faItems_(), meanScalarFields_(), meanVectorFields_(), @@ -355,6 +356,7 @@ void Foam::fieldAverage::read(const dictionary& dict) if (active_) { dict.readIfPresent("cleanRestart", cleanRestart_); + dict.readIfPresent("resetOnOutput", resetOnOutput_); dict.lookup("fields") >> faItems_; initialize(); @@ -387,6 +389,17 @@ void Foam::fieldAverage::write() calcAverages(); writeAverages(); writeAveragingProperties(); + + if (resetOnOutput_) + { + Info<< "fieldAverage: restarting averaging at time " + << obr_.time().timeName() << nl << endl; + + initialize(); + + // ensure first averaging works unconditionally + prevTimeIndex_ = -1; + } } } diff --git a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.H b/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.H index bffb23b2e0b0f34ae52ca292f3bd672442692bda..29ac4c2a3b06820004cedd1675bb1f4d2cef3eb3 100644 --- a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.H +++ b/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.H @@ -41,6 +41,11 @@ Description // averaging info if available cleanRestart true; + // Whether to reset the averaged fields after they have been written. + // Used to average over only the preceding write interval for transient + // cases. + resetOnOutput true; + // Fields to be averaged. runTime modifiable! fields ( @@ -132,6 +137,9 @@ protected: //- Clean restart flag Switch cleanRestart_; + //- resetOnOutput flag + Switch resetOnOutput_; + //- List of field average items, describing what averages to be // calculated and output List<fieldAverageItem> faItems_; diff --git a/src/postProcessing/functionObjects/forces/forces/forces.C b/src/postProcessing/functionObjects/forces/forces/forces.C index 3fb9cc135a3d571cd7a218aa5c5a497ebcb8a99c..1ffc36cab022b8dd2b35c7770bbe71a688022518 100644 --- a/src/postProcessing/functionObjects/forces/forces/forces.C +++ b/src/postProcessing/functionObjects/forces/forces/forces.C @@ -151,6 +151,8 @@ Foam::forces::forces patchSet_(), pName_(""), UName_(""), + directForceDensity_(false), + fDName_(""), rhoRef_(0), CofR_(vector::zero), forcesFilePtr_(NULL) @@ -161,7 +163,13 @@ Foam::forces::forces active_ = false; WarningIn ( - "forces::forces(const objectRegistry& obr, const dictionary& dict)" + "Foam::forces::forces" + "(" + "const word&, " + "const objectRegistry&, " + "const dictionary&, " + "const bool" + ")" ) << "No fvMesh available, deactivating." << endl; } @@ -189,27 +197,50 @@ void Foam::forces::read(const dictionary& dict) patchSet_ = mesh.boundaryMesh().patchSet(wordList(dict.lookup("patches"))); - // Optional entries U and p - pName_ = dict.lookupOrDefault<word>("pName", "p"); - UName_ = dict.lookupOrDefault<word>("UName", "U"); + dict.readIfPresent("directForceDensity", directForceDensity_); - // Check whether UName and pName exists, if not deactivate forces - if - ( - !obr_.foundObject<volVectorField>(UName_) - || !obr_.foundObject<volScalarField>(pName_) - ) + if (directForceDensity_) { - active_ = false; - WarningIn("void forces::read(const dictionary& dict)") - << "Could not find " << UName_ << " or " - << pName_ << " in database." << nl - << " De-activating forces." - << endl; + // Optional entry for fDName + fDName_ = dict.lookupOrDefault<word>("fDName", "fD"); + + // Check whether fDName exists, if not deactivate forces + if + ( + !obr_.foundObject<volVectorField>(fDName_) + ) + { + active_ = false; + WarningIn("void forces::read(const dictionary& dict)") + << "Could not find " << fDName_ << " in database." << nl + << " De-activating forces." + << endl; + } } + else + { + // Optional entries U and p + pName_ = dict.lookupOrDefault<word>("pName", "p"); + UName_ = dict.lookupOrDefault<word>("UName", "U"); + + // Check whether UName and pName exists, if not deactivate forces + if + ( + !obr_.foundObject<volVectorField>(UName_) + || !obr_.foundObject<volScalarField>(pName_) + ) + { + active_ = false; + WarningIn("void forces::read(const dictionary& dict)") + << "Could not find " << UName_ << " or " + << pName_ << " in database." << nl + << " De-activating forces." + << endl; + } - // Reference density needed for incompressible calculations - rhoRef_ = readScalar(dict.lookup("rhoInf")); + // Reference density needed for incompressible calculations + rhoRef_ = readScalar(dict.lookup("rhoInf")); + } // Centre of rotation for moment calculations CofR_ = dict.lookup("CofR"); @@ -307,40 +338,76 @@ void Foam::forces::write() Foam::forces::forcesMoments Foam::forces::calcForcesMoment() const { - const volVectorField& U = obr_.lookupObject<volVectorField>(UName_); - const volScalarField& p = obr_.lookupObject<volScalarField>(pName_); - - const fvMesh& mesh = U.mesh(); - forcesMoments fm ( pressureViscous(vector::zero, vector::zero), pressureViscous(vector::zero, vector::zero) ); - const surfaceVectorField::GeometricBoundaryField& Sfb = - mesh.Sf().boundaryField(); + if (directForceDensity_) + { + const volVectorField& fD = obr_.lookupObject<volVectorField>(fDName_); + + const fvMesh& mesh = fD.mesh(); + + const surfaceVectorField::GeometricBoundaryField& Sfb = + mesh.Sf().boundaryField(); - tmp<volSymmTensorField> tdevRhoReff = devRhoReff(); - const volSymmTensorField::GeometricBoundaryField& devRhoReffb - = tdevRhoReff().boundaryField(); + forAllConstIter(labelHashSet, patchSet_, iter) + { + label patchi = iter.key(); + + vectorField Md = mesh.C().boundaryField()[patchi] - CofR_; + + scalarField sA = mag(Sfb[patchi]); + + // Normal force = surfaceUnitNormal * (surfaceNormal & forceDensity) + vectorField fN = + Sfb[patchi]/sA + *( + Sfb[patchi] & fD.boundaryField()[patchi] + ); - forAllConstIter(labelHashSet, patchSet_, iter) + fm.first().first() += sum(fN); + fm.second().first() += sum(Md ^ fN); + + // Tangential force (total force minus normal fN) + vectorField fT = sA*fD.boundaryField()[patchi] - fN; + + fm.first().second() += sum(fT); + fm.second().second() += sum(Md ^ fT); + } + } + else { - label patchi = iter.key(); + const volVectorField& U = obr_.lookupObject<volVectorField>(UName_); + const volScalarField& p = obr_.lookupObject<volScalarField>(pName_); + + const fvMesh& mesh = U.mesh(); + + const surfaceVectorField::GeometricBoundaryField& Sfb = + mesh.Sf().boundaryField(); - vectorField Md = mesh.C().boundaryField()[patchi] - CofR_; + tmp<volSymmTensorField> tdevRhoReff = devRhoReff(); + const volSymmTensorField::GeometricBoundaryField& devRhoReffb + = tdevRhoReff().boundaryField(); - vectorField pf = - mesh.Sf().boundaryField()[patchi]*p.boundaryField()[patchi]; + forAllConstIter(labelHashSet, patchSet_, iter) + { + label patchi = iter.key(); + + vectorField Md = mesh.C().boundaryField()[patchi] - CofR_; - fm.first().first() += rho(p)*sum(pf); - fm.second().first() += rho(p)*sum(Md ^ pf); + vectorField pf = Sfb[patchi]*p.boundaryField()[patchi]; - vectorField vf = Sfb[patchi] & devRhoReffb[patchi]; + fm.first().first() += rho(p)*sum(pf); + fm.second().first() += rho(p)*sum(Md ^ pf); - fm.first().second() += sum(vf); - fm.second().second() += sum(Md ^ vf); + vectorField vf = Sfb[patchi] & devRhoReffb[patchi]; + + fm.first().second() += sum(vf); + fm.second().second() += sum(Md ^ vf); + } } reduce(fm, sumOp()); diff --git a/src/postProcessing/functionObjects/forces/forces/forces.H b/src/postProcessing/functionObjects/forces/forces/forces.H index 73edae9da13c1aa12ba87c34fd03bbd8bccdc208..96651af97e0d8c0da030c59b7fbb7486e539257a 100644 --- a/src/postProcessing/functionObjects/forces/forces/forces.H +++ b/src/postProcessing/functionObjects/forces/forces/forces.H @@ -121,7 +121,7 @@ protected: //- Switch to send output to Info as well as to file Switch log_; - // Read from dictonary + // Read from dictionary //- Patches to integrate forces over labelHashSet patchSet_; @@ -132,6 +132,12 @@ protected: //- Name of velocity field word UName_; + //- Is the force density being supplied directly? + Switch directForceDensity_; + + //- The name of the force density (fD) field + word fDName_; + //- Reference density needed for incompressible calculations scalar rhoRef_; diff --git a/src/postProcessing/functionObjects/utilities/Make/files b/src/postProcessing/functionObjects/utilities/Make/files index 2930260e2f13b88e1fdb24f1872aa5e310333ae7..40a33c238ddd3983b7817bd096632f1920e2ba60 100644 --- a/src/postProcessing/functionObjects/utilities/Make/files +++ b/src/postProcessing/functionObjects/utilities/Make/files @@ -1,4 +1,7 @@ staticPressure/staticPressure.C staticPressure/staticPressureFunctionObject.C +dsmcFields/dsmcFields.C +dsmcFields/dsmcFieldsFunctionObject.C + LIB = $(FOAM_LIBBIN)/libutilityFunctionObjects diff --git a/src/postProcessing/functionObjects/utilities/Make/options b/src/postProcessing/functionObjects/utilities/Make/options index 5166bcc9e32f547f48a5f87c9c60d7210409967f..623013bc21e695c7fbe125c2c8c1022853db647e 100644 --- a/src/postProcessing/functionObjects/utilities/Make/options +++ b/src/postProcessing/functionObjects/utilities/Make/options @@ -1,9 +1,13 @@ EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/lagrangian/basic/lnInclude \ + -I$(LIB_SRC)/lagrangian/dsmc/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude LIB_LIBS = \ -lfiniteVolume \ -lmeshTools \ - -lsampling + -lsampling \ + -llagrangian \ + -ldsmc diff --git a/src/postProcessing/functionObjects/utilities/dsmcFields/IOdsmcFields.C b/src/postProcessing/functionObjects/utilities/dsmcFields/IOdsmcFields.C new file mode 100644 index 0000000000000000000000000000000000000000..32627acb3c5ceb3e2873fe858317d3e8af80114d --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/dsmcFields/IOdsmcFields.C @@ -0,0 +1,50 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Typedef + Foam::IOdsmcFields + +Description + Instance of the generic IOOutputFilter for dsmcFields. + +\*---------------------------------------------------------------------------*/ + +#ifndef IOdsmcFields_H +#define IOdsmcFields_H + +#include "dsmcFields.H" +#include "IOOutputFilter.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef IOOutputFilter<dsmcFields> IOdsmcFields; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFields.C b/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFields.C new file mode 100644 index 0000000000000000000000000000000000000000..3aaa9c514a462f7d2850d0035ab34478d70e7817 --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFields.C @@ -0,0 +1,236 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "dsmcFields.H" +#include "volFields.H" +#include "dictionary.H" +#include "dsmcCloud.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(dsmcFields, 0); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::dsmcFields::dsmcFields +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles +) +: + name_(name), + obr_(obr), + active_(true) +{ + // Check if the available mesh is an fvMesh, otherwise deactivate + if (!isA<fvMesh>(obr_)) + { + active_ = false; + WarningIn + ( + "dsmcFields::dsmcFields" + "(const objectRegistry&, const dictionary&)" + ) << "No fvMesh available, deactivating." << nl + << endl; + } + + read(dict); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::dsmcFields::~dsmcFields() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::dsmcFields::read(const dictionary& dict) +{ + if (active_) + { + + } +} + + +void Foam::dsmcFields::execute() +{ + // Do nothing - only valid on write +} + + +void Foam::dsmcFields::end() +{ + // Do nothing - only valid on write +} + + +void Foam::dsmcFields::write() +{ + if (active_) + { + word rhoNMeanName = "rhoNMean"; + word rhoMMeanName = "rhoMMean"; + word momentumMeanName = "momentumMean"; + word linearKEMeanName = "linearKEMean"; + word internalEMeanName = "internalEMean"; + word iDofMeanName = "iDofMean"; + + const volScalarField& rhoNMean = obr_.lookupObject<volScalarField> + ( + rhoNMeanName + ); + + const volScalarField& rhoMMean = obr_.lookupObject<volScalarField> + ( + rhoMMeanName + ); + + const volVectorField& momentumMean = obr_.lookupObject<volVectorField> + ( + momentumMeanName + ); + + const volScalarField& linearKEMean = obr_.lookupObject<volScalarField> + ( + linearKEMeanName + ); + + const volScalarField& internalEMean = obr_.lookupObject<volScalarField> + ( + internalEMeanName + ); + + const volScalarField& iDofMean = obr_.lookupObject<volScalarField> + ( + iDofMeanName + ); + + if (min(rhoNMean).value() > VSMALL) + { + Info<< "Calculating dsmcFields." << endl; + + Info<< " Calculating UMean field." << endl; + volVectorField UMean + ( + IOobject + ( + "UMean", + obr_.time().timeName(), + obr_, + IOobject::NO_READ + ), + momentumMean/rhoMMean + ); + + Info<< " Calculating translationalT field." << endl; + volScalarField translationalT + ( + IOobject + ( + "translationalT", + obr_.time().timeName(), + obr_, + IOobject::NO_READ + ), + 2.0/(3.0*dsmcCloud::kb*rhoNMean) + *(linearKEMean - 0.5*rhoMMean*(UMean & UMean)) + ); + + Info<< " Calculating internalT field." << endl; + volScalarField internalT + ( + IOobject + ( + "internalT", + obr_.time().timeName(), + obr_, + IOobject::NO_READ + ), + 2.0/(dsmcCloud::kb*iDofMean)*internalEMean + ); + + Info<< " Calculating overallT field." << endl; + volScalarField overallT + ( + IOobject + ( + "overallT", + obr_.time().timeName(), + obr_, + IOobject::NO_READ + ), + 2.0/(dsmcCloud::kb*(3.0*rhoNMean + iDofMean)) + *(linearKEMean - 0.5*rhoMMean*(UMean & UMean) + internalEMean) + ); + + Info<< " mag(UMean) max/min : " + << max(mag(UMean)).value() << " " + << min(mag(UMean)).value() << endl; + + Info<< " translationalT max/min : " + << max(translationalT).value() << " " + << min(translationalT).value() << endl; + + Info<< " internalT max/min : " + << max(internalT).value() << " " + << min(internalT).value() << endl; + + Info<< " overallT max/min : " + << max(overallT).value() << " " + << min(overallT).value() << endl; + + UMean.write(); + + translationalT.write(); + + internalT.write(); + + overallT.write(); + + Info<< "dsmcFields written." << nl << endl; + } + else + { + Info<< "Small or negative value (" << min(rhoNMean) + << ") found in rhoNMean field. " + << "Not calculating dsmcFields to avoid division by zero " + << "or invalid results." + << endl; + } + } +} + + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFields.H b/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFields.H new file mode 100644 index 0000000000000000000000000000000000000000..b53dda6700040633582cdc054b92eb4aee4ee5ab --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFields.H @@ -0,0 +1,144 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::dsmcFields + +Description + Calculate intensive fields: + - UMean + - translationalT + - internalT + - overallT + from averaged extensive fields from a DSMC calculation. + +SourceFiles + dsmcFields.C + IOdsmcFields.H + +\*---------------------------------------------------------------------------*/ + +#ifndef dsmcFields_H +#define dsmcFields_H + +#include "pointFieldFwd.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class objectRegistry; +class dictionary; +class mapPolyMesh; + +/*---------------------------------------------------------------------------*\ + Class dsmcFields Declaration +\*---------------------------------------------------------------------------*/ + +class dsmcFields +{ + // Private data + + //- Name of this set of dsmcFields objects + word name_; + + const objectRegistry& obr_; + + //- on/off switch + bool active_; + + // Private Member Functions + + //- Disallow default bitwise copy construct + dsmcFields(const dsmcFields&); + + //- Disallow default bitwise assignment + void operator=(const dsmcFields&); + + +public: + + //- Runtime type information + TypeName("dsmcFields"); + + + // Constructors + + //- Construct for given objectRegistry and dictionary. + // Allow the possibility to load fields from files + dsmcFields + ( + const word& name, + const objectRegistry&, + const dictionary&, + const bool loadFromFiles = false + ); + + + // Destructor + + virtual ~dsmcFields(); + + + // Member Functions + + //- Return name of the set of dsmcFields + virtual const word& name() const + { + return name_; + } + + //- Read the dsmcFields data + virtual void read(const dictionary&); + + //- Execute, currently does nothing + virtual void execute(); + + //- Execute at the final time-loop, currently does nothing + virtual void end(); + + //- Calculate the dsmcFields and write + virtual void write(); + + //- Update for changes of mesh + virtual void updateMesh(const mapPolyMesh&) + {} + + //- Update for changes of mesh + virtual void movePoints(const pointField&) + {} +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFieldsFunctionObject.C b/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFieldsFunctionObject.C new file mode 100644 index 0000000000000000000000000000000000000000..cd5324f25b103be5086875e4863677e053ce95ee --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFieldsFunctionObject.C @@ -0,0 +1,43 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "dsmcFieldsFunctionObject.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineNamedTemplateTypeNameAndDebug(dsmcFieldsFunctionObject, 0); + + addToRunTimeSelectionTable + ( + functionObject, + dsmcFieldsFunctionObject, + dictionary + ); +} + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFieldsFunctionObject.H b/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFieldsFunctionObject.H new file mode 100644 index 0000000000000000000000000000000000000000..cf34cdaa2e4d9a2ef03fa1fbee6644c4bf63ea1a --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFieldsFunctionObject.H @@ -0,0 +1,55 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Typedef + Foam::dsmcFieldsFunctionObject + +Description + FunctionObject wrapper around dsmcFields to allow it to be created via + the functions list within controlDict. + +SourceFiles + dsmcFieldsFunctionObject.C + +\*---------------------------------------------------------------------------*/ + +#ifndef dsmcFieldsFunctionObject_H +#define dsmcFieldsFunctionObject_H + +#include "dsmcFields.H" +#include "OutputFilterFunctionObject.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef OutputFilterFunctionObject<dsmcFields> + dsmcFieldsFunctionObject; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/sampling/sampledSet/sampledSets/sampledSets.C b/src/sampling/sampledSet/sampledSets/sampledSets.C index 621efba7a51244df2150d9105e97dac5168ab1bf..3f7b7a3323ede9cbc888a87d1929da1ba887e405 100644 --- a/src/sampling/sampledSet/sampledSets/sampledSets.C +++ b/src/sampling/sampledSet/sampledSets/sampledSets.C @@ -212,7 +212,7 @@ void Foam::sampledSets::combineSampledSets ( samplePts.name(), samplePts.axis(), - IndirectList<point>(allPts, indexSets[seti]), + UIndirectList<point>(allPts, indexSets[seti]), refPt ) ); diff --git a/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C b/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C index 3ec4fad1bd11b1a08d436f9dfb15762b63e79d93..c5cfecb8a8fb6c850e638676ca6f6fd255a81cb7 100644 --- a/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C +++ b/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C @@ -198,8 +198,11 @@ void Foam::sampledSets::combineSampledValues ) ); - masterValues[seti] = - IndirectList<T>(allData, indexSets[seti])(); + masterValues[seti] = UIndirectList<T> + ( + allData, + indexSets[seti] + )(); } } diff --git a/src/thermophysicalModels/specie/thermo/janaf/janafThermoI.H b/src/thermophysicalModels/specie/thermo/janaf/janafThermoI.H index 4af0fb4b0711df1d98e7023a46c0eaaced21ca13..ac91a3eef9bed458f26f3e6ef21f9842c1fd3d3d 100644 --- a/src/thermophysicalModels/specie/thermo/janaf/janafThermoI.H +++ b/src/thermophysicalModels/specie/thermo/janaf/janafThermoI.H @@ -145,12 +145,7 @@ inline Foam::scalar Foam::janafThermo<equationOfState>::hs const scalar T ) const { - const coeffArray& a = coeffs(T); - scalar Tr = T - specie::Tstd; - return this->RR* - ( - ((((a[4]/5.0*Tr + a[3]/4.0)*Tr + a[2]/3.0)*Tr + a[1]/2.0)*Tr + a[0])*Tr - ); + return h(T) - hc(); } diff --git a/src/triSurface/faceTriangulation/faceTriangulation.C b/src/triSurface/faceTriangulation/faceTriangulation.C index a2f1ed2aa087cebabca1028a1a3e6c05d9270566..f0df3371077d31883cb5fbd1a2bb6a7d6ff2d14c 100644 --- a/src/triSurface/faceTriangulation/faceTriangulation.C +++ b/src/triSurface/faceTriangulation/faceTriangulation.C @@ -422,7 +422,7 @@ bool Foam::faceTriangulation::split "split(const bool, const pointField&, const face&" ", const vector&, label&)" ) << "Illegal face:" << f - << " with points " << IndirectList<point>(points, f)() + << " with points " << UIndirectList<point>(points, f)() << endl; return false; @@ -501,7 +501,8 @@ bool Foam::faceTriangulation::split "split(const bool, const pointField&, const face&" ", const vector&, label&)" ) << "Cannot find valid diagonal on face " << f - << " with points " << IndirectList<point>(points, f)() << nl + << " with points " << UIndirectList<point>(points, f)() + << nl << "Returning naive triangulation starting from " << f[maxIndex] << " which might not be correct for a" << " concave or warped face" << endl; @@ -530,7 +531,8 @@ bool Foam::faceTriangulation::split "split(const bool, const pointField&, const face&" ", const vector&, label&)" ) << "Cannot find valid diagonal on face " << f - << " with points " << IndirectList<point>(points, f)() << nl + << " with points " << UIndirectList<point>(points, f)() + << nl << "Returning empty triFaceList" << endl; return false; @@ -564,7 +566,7 @@ bool Foam::faceTriangulation::split "split(const bool, const pointField&, const face&" ", const vector&, label&)" ) << "Illegal split of face:" << f - << " with points " << IndirectList<point>(points, f)() + << " with points " << UIndirectList<point>(points, f)() << " at indices " << index1 << " and " << index2 << abort(FatalError); } diff --git a/src/triSurface/triSurface/triSurfaceAddressing.C b/src/triSurface/triSurface/triSurfaceAddressing.C index cd67740ca66f64e45319387a7413a48b69cafbdb..ce2e5608f47e413b4af1d82968af72769767b839 100644 --- a/src/triSurface/triSurface/triSurfaceAddressing.C +++ b/src/triSurface/triSurface/triSurfaceAddressing.C @@ -112,7 +112,7 @@ void triSurface::calcSortedEdgeFaces() const faceAngles.sort(); - sortedEdgeFaces[edgeI] = IndirectList<label> + sortedEdgeFaces[edgeI] = UIndirectList<label> ( myFaceNbs, faceAngles.indices() @@ -179,7 +179,7 @@ void triSurface::calcEdgeOwner() const << "Edge " << edgeI << " vertices:" << e << " is used by faces " << myFaces << " vertices:" - << IndirectList<labelledTri>(localFaces(), myFaces)() + << UIndirectList<labelledTri>(localFaces(), myFaces)() << " none of which use the edge vertices in the same order" << nl << "I give up" << abort(FatalError); } diff --git a/tutorials/incompressible/simpleFoam/airFoil2D/0/nut b/tutorials/incompressible/simpleFoam/airFoil2D/0/nut index 739392ea8e3d6e5262e353aadc18677674b338f8..41d98b51f8bee489fa8253d80368ce6875c6421a 100644 --- a/tutorials/incompressible/simpleFoam/airFoil2D/0/nut +++ b/tutorials/incompressible/simpleFoam/airFoil2D/0/nut @@ -34,7 +34,7 @@ boundaryField wall { - type nutWallFunction; + type nutSpalartAllmarasWallFunction; value uniform 0; } diff --git a/tutorials/incompressible/simpleFoam/airFoil2D/system/fvSolution b/tutorials/incompressible/simpleFoam/airFoil2D/system/fvSolution index 6f7dffd99bd59c324d9f1e673cce74169fc25975..8a27a35a6334c21dcc9d9c3079c51d158beb64f3 100644 --- a/tutorials/incompressible/simpleFoam/airFoil2D/system/fvSolution +++ b/tutorials/incompressible/simpleFoam/airFoil2D/system/fvSolution @@ -59,6 +59,7 @@ SIMPLE relaxationFactors { + default 0; p 0.3; U 0.7; nuTilda 0.7;