diff --git a/applications/test/multiWorld/left/0/T b/applications/test/multiWorld/left/0/T deleted file mode 100644 index a03c149999140676a9cb969843731dda86418733..0000000000000000000000000000000000000000 --- a/applications/test/multiWorld/left/0/T +++ /dev/null @@ -1,80 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: v2106 | -| \\ / A nd | Website: www.openfoam.com | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class volScalarField; - object T; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -dimensions [0 0 0 1 0 0 0]; - -internalField uniform 1; - -boundaryField -{ - coupled - { - //type mappedField; - type mappedMixedField; - - // What to sample: - sampleMode nearestPatchFace; - - // Simulation world to sample - sampleWorld RIGHT; - - // Region to sample - sampleRegion region0; - - // If sampleMode is nearestPatchFace : patch to find faces of - samplePatch coupled; - - // Use database to get data from (one-way or loose coupling in - // combination with functionObject) - //sampleDatabase false; //true; - - // According to offsetMode (see above) supply one of - // offset, offsets or distance - offset (0 0 0); - - value uniform 0.0; - - - // For mappedMixed - //weightField DTV; - refValue $value; - refGradient uniform 0.0; - valueFraction uniform 1.0; - } - - top - { - type zeroGradient; - } - - bottom - { - type zeroGradient; - } - - left - { - type fixedValue; - value uniform 1; - } - - frontAndBack - { - type empty; - } -} - -// ************************************************************************* // diff --git a/applications/test/multiWorld/mpirun.schema b/applications/test/multiWorld/mpirun.schema deleted file mode 100644 index 49aadf442eeb5354ff0fd93de00bb438be920cbc..0000000000000000000000000000000000000000 --- a/applications/test/multiWorld/mpirun.schema +++ /dev/null @@ -1,2 +0,0 @@ --np 2 laplacianFoam -case left -world LEFT -parallel --np 2 laplacianFoam -case right -world RIGHT -parallel diff --git a/applications/test/multiWorld/mpirun_left_right.schema b/applications/test/multiWorld/mpirun_left_right.schema deleted file mode 100644 index 133e452fb6034c4b2dc67c794bad8b389eb1b787..0000000000000000000000000000000000000000 --- a/applications/test/multiWorld/mpirun_left_right.schema +++ /dev/null @@ -1,2 +0,0 @@ --np 1 xterm -font fixed -title left -geometry 200x15+0+0 -e ./run_world.sh left --np 1 xterm -font fixed -title right -geometry 200x15+0+200 -e ./run_world.sh right diff --git a/applications/test/multiWorld/right/0/T b/applications/test/multiWorld/right/0/T deleted file mode 100644 index eb9be91317e5d8d11c8425daa8ae7266ace14332..0000000000000000000000000000000000000000 --- a/applications/test/multiWorld/right/0/T +++ /dev/null @@ -1,79 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: v2106 | -| \\ / A nd | Website: www.openfoam.com | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class volScalarField; - object T; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -dimensions [0 0 0 1 0 0 0]; - -internalField uniform 0; - -boundaryField -{ - coupled - { - //type mappedField; - type mappedMixedField; - - // What to sample: - sampleMode nearestPatchFace; - - // Simulation world to sample - sampleWorld LEFT; - - // Region to sample - sampleRegion region0; - - // If sampleMode is nearestPatchFace : patch to find faces of - samplePatch coupled; - - // Use database to get data from (one-way or loose coupling in - // combination with functionObject) - //sampleDatabase false; //true; - - // According to offsetMode (see above) supply one of - // offset, offsets or distance - offset (0 0 0); - - value uniform 1.1; - - // For mappedMixed - //weightField DTV; - refValue $value; - refGradient uniform 0.0; - valueFraction uniform 1.0; - } - - top - { - type zeroGradient; - } - - bottom - { - type zeroGradient; - } - - right - { - type fixedValue; - value uniform 0; - } - - frontAndBack - { - type empty; - } -} - -// ************************************************************************* // diff --git a/applications/test/multiWorld/right/constant/transportProperties b/applications/test/multiWorld/right/constant/transportProperties deleted file mode 120000 index d0e9cc0e1caac311626efaec509ece91b57722f9..0000000000000000000000000000000000000000 --- a/applications/test/multiWorld/right/constant/transportProperties +++ /dev/null @@ -1 +0,0 @@ -../../left/constant/transportProperties \ No newline at end of file diff --git a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C index 2c0f91dae931173f44c3f69c891a0e841f9f56e3..c11783e342d60ef3839413860652dd0cae54d673 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C @@ -1126,7 +1126,7 @@ void setCouplingInfo forAll(zoneToPatch, zoneI) { - label patchi = zoneToPatch[zoneI]; + const label patchi = zoneToPatch[zoneI]; if (patchi != -1) { @@ -1139,50 +1139,38 @@ void setCouplingInfo const scalar mergeSqrDist = gMax(magSqr(offsets[zoneI]-avgOffset)); + // Create with uniform offset initially + auto mappedPtr = autoPtr<mappedWallPolyPatch>::New + ( + pp.name(), + pp.size(), + pp.start(), + patchi, + sampleRegion, // sampleRegion + mode, // sampleMode + pp.name(), // samplePatch + + avgOffset, // uniform offset + patches + ); + + Info<< "Adding on " << mesh.name() << " coupling patch " + << pp.name() << " with "; + // Verify uniformity of offset // (same check as blockMesh geom merge) if (mergeSqrDist < magSqr(10*SMALL*bb.span())) { - Info<< "Adding on " << mesh.name() - << " coupling patch " << pp.name() - << " with uniform offset " << avgOffset << endl; - - // Uniform offset - newPatches[patchi] = new mappedWallPolyPatch - ( - pp.name(), - pp.size(), - pp.start(), - patchi, - sampleRegion, // sampleRegion - mode, // sampleMode - pp.name(), // samplePatch - - avgOffset, // uniform offset - patches - ); + Info<< "uniform offset " << avgOffset << endl; } else { - Info<< "Adding on " << mesh.name() - << " coupling patch " << pp.name() - << " with non-uniform offset" << endl; + Info<< "non-uniform offset" << endl; - // Uniform offset - newPatches[patchi] = new mappedWallPolyPatch - ( - pp.name(), - pp.size(), - pp.start(), - patchi, - sampleRegion, // sampleRegion - mode, // sampleMode - pp.name(), // samplePatch - - offsets[zoneI], // non-uniform offsets - patches - ); + (*mappedPtr).setOffset(offsets[zoneI]); } + + newPatches[patchi] = mappedPtr.release(); } } } diff --git a/src/Pstream/mpi/UPstream.C b/src/Pstream/mpi/UPstream.C index 7a5332ce81076cf03d8ced93dbb752d11bcf2dec..07f3765528a62663abe921c81f7125511e4c34f7 100644 --- a/src/Pstream/mpi/UPstream.C +++ b/src/Pstream/mpi/UPstream.C @@ -1091,11 +1091,12 @@ void Foam::UPstream::allocatePstreamCommunicator &PstreamGlobals::MPIGroups_[index] ); - // Create new communicator - MPI_Comm_create + // Create new communicator for this group + MPI_Comm_create_group ( PstreamGlobals::MPICommunicators_[parentIndex], PstreamGlobals::MPIGroups_[index], + Pstream::msgType(), &PstreamGlobals::MPICommunicators_[index] ); diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C index e1506f058c2e028d6032a4990c01adf402df476f..259903f2193dcd59b64a074058b67631c0599257 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -150,17 +150,19 @@ turbulentTemperatureCoupledBaffleMixedFvPatchScalarField valueFraction() = 1.0; } - // Store patch value as initial guess when running in database mode - mappedPatchFieldBase<scalar>::initRetrieveField - ( - this->internalField().name(), - *this - ); - mappedPatchFieldBase<scalar>::initRetrieveField - ( - this->internalField().name() + "_weights", - this->patch().deltaCoeffs() - ); +// This blocks (crashes) with more than two worlds! +// +/// // Store patch value as initial guess when running in database mode +/// mappedPatchFieldBase<scalar>::initRetrieveField +/// ( +/// this->internalField().name(), +/// *this +/// ); +/// mappedPatchFieldBase<scalar>::initRetrieveField +/// ( +/// this->internalField().name() + "_weights", +/// this->patch().deltaCoeffs() +/// ); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedMixedFieldFvPatchField/mappedMixedFieldFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedMixedFieldFvPatchField/mappedMixedFieldFvPatchField.C index 52dae310de48a2d42e10709d2234f54231a11d22..884cddd15fd539b63efa602ecf455ce0acd76b1c 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedMixedFieldFvPatchField/mappedMixedFieldFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedMixedFieldFvPatchField/mappedMixedFieldFvPatchField.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -61,39 +61,7 @@ Foam::mappedMixedFieldFvPatchField<Type>::mappedMixedFieldFvPatchField mappedPatchBase(p.patch(), dict), mappedPatchFieldBase<Type>(*this, *this, dict), weightFieldName_(dict.getOrDefault<word>("weightField", word::null)) -{ - mixedFvPatchField<Type>::operator= - ( - Field<Type>("value", dict, p.size()) - ); - - if (dict.found("refValue")) - { - // Full restart - this->refValue() = Field<Type>("refValue", dict, p.size()); - this->refGrad() = Field<Type>("refGradient", dict, p.size()); - this->valueFraction() = scalarField("valueFraction", dict, p.size()); - } - else - { - // Start from user entered data. Assume fixedValue. - this->refValue() = *this; - this->refGrad() = Zero; - this->valueFraction() = 1.0; - } - - // Store patch value as initial guess when running in database mode - mappedPatchFieldBase<Type>::initRetrieveField - ( - this->internalField().name(), - *this - ); - mappedPatchFieldBase<Type>::initRetrieveField - ( - this->internalField().name() + "_weights", - this->patch().deltaCoeffs() - ); -} +{} template<class Type> diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.C b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.C index 85d098ae6be2f9bc16ef2833fd03edebe44508f3..2f05fcd713be74bb316d7d58ddb3671b4ab331cb 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.C @@ -55,29 +55,34 @@ void Foam::mappedPatchFieldBase<Type>::storeField const objectRegistry& obr, const word& region, const word& patch, + const label myComm, const labelListList& procToMap, const word& fieldName, const Field<T>& fld ) const { // Store my data onto database - //const label myRank = Pstream::myProcNo(0); // comm_ - const label nProcs = Pstream::nProcs(0); // comm_ - for (label domain = 0; domain < nProcs; domain++) + const auto& procIDs = UPstream::procID(myComm); + + forAll(procToMap, ranki) { - const labelList& map = procToMap[domain]; + const labelList& map = procToMap[ranki]; + const label proci = procIDs[ranki]; if (map.size()) { const Field<T> subFld(fld, map); - const objectRegistry& subObr = mappedPatchBase::subRegistry + auto& subObr = const_cast<objectRegistry&> ( - obr, - mapper_.sendPath(domain) - / region - / patch + mappedPatchBase::subRegistry + ( + obr, + mapper_.sendPath(proci) + / region + / patch + ) ); if (fvPatchField<Type>::debug) @@ -88,12 +93,7 @@ void Foam::mappedPatchFieldBase<Type>::storeField << " as:" << subObr.objectPath() << endl; } - mappedPatchBase::storeField - ( - const_cast<objectRegistry&>(subObr), - fieldName, - subFld - ); + mappedPatchBase::storeField(subObr, fieldName, subFld); } } } @@ -107,27 +107,32 @@ bool Foam::mappedPatchFieldBase<Type>::retrieveField const objectRegistry& obr, const word& region, const word& patch, + const label myComm, const labelListList& procToMap, const word& fieldName, Field<T>& fld ) const { - // Store my data onto database - const label nProcs = Pstream::nProcs(0); // comm_ + const auto& procIDs = UPstream::procID(myComm); bool ok = true; - for (label domain = 0; domain < nProcs; domain++) + forAll(procToMap, ranki) { - const labelList& map = procToMap[domain]; + const labelList& map = procToMap[ranki]; + const label proci = procIDs[ranki]; + if (map.size()) { - const objectRegistry& subObr = mappedPatchBase::subRegistry + auto& subObr = const_cast<objectRegistry&> ( - obr, - mapper_.receivePath(domain) - / region - / patch + mappedPatchBase::subRegistry + ( + obr, + mapper_.receivePath(proci) + / region + / patch + ) ); const IOField<T>* subFldPtr = subObr.getObjectPtr<IOField<T>> @@ -174,12 +179,7 @@ bool Foam::mappedPatchFieldBase<Type>::retrieveField // detect it if necessary. const Field<T> dummyFld(0); - mappedPatchBase::storeField - ( - const_cast<objectRegistry&>(subObr), - fieldName, - dummyFld - ); + mappedPatchBase::storeField(subObr, fieldName, dummyFld); ok = false; } @@ -207,6 +207,8 @@ void Foam::mappedPatchFieldBase<Type>::initRetrieveField const Field<T>& fld ) const { + // Old code. Likely not quite correct... + // Store my data onto database const label nProcs = Pstream::nProcs(0); // comm_ @@ -215,12 +217,15 @@ void Foam::mappedPatchFieldBase<Type>::initRetrieveField const labelList& constructMap = map[domain]; if (constructMap.size()) { - const objectRegistry& subObr = mappedPatchBase::subRegistry + auto& subObr = const_cast<objectRegistry&> ( - obr, - mapper_.receivePath(domain) - / region - / patch + mappedPatchBase::subRegistry + ( + obr, + mapper_.receivePath(domain) + / region + / patch + ) ); const Field<T> receiveFld(fld, constructMap); @@ -235,12 +240,7 @@ void Foam::mappedPatchFieldBase<Type>::initRetrieveField << " as:" << subObr.objectPath() << endl; } - mappedPatchBase::storeField - ( - const_cast<objectRegistry&>(subObr), - fieldName, - receiveFld - ); + mappedPatchBase::storeField(subObr, fieldName, receiveFld); } } } @@ -251,6 +251,7 @@ template<class T> bool Foam::mappedPatchFieldBase<Type>::storeAndRetrieveField ( const word& fieldName, + const label myComm, const labelListList& subMap, const label constructSize, const labelListList& constructMap, @@ -264,6 +265,7 @@ bool Foam::mappedPatchFieldBase<Type>::storeAndRetrieveField patchField_.internalField().time(), patchField_.patch().boundaryMesh().mesh().name(), patchField_.patch().name(), + myComm, subMap, fieldName, fld @@ -276,6 +278,7 @@ bool Foam::mappedPatchFieldBase<Type>::storeAndRetrieveField patchField_.internalField().time(), mapper_.sampleRegion(), mapper_.samplePatch(), + myComm, constructMap, fieldName, work @@ -525,6 +528,8 @@ void Foam::mappedPatchFieldBase<Type>::distribute { if (mapper_.sampleDatabase()) { + const label myComm = mapper_.getCommunicator(); // Get or create + if (mapper_.mode() != mappedPatchBase::NEARESTPATCHFACEAMI) { // Store my data on send buffers @@ -533,6 +538,7 @@ void Foam::mappedPatchFieldBase<Type>::distribute patchField_.internalField().time(), patchField_.patch().boundaryMesh().mesh().name(), patchField_.patch().name(), + myComm, mapper_.map().subMap(), fieldName, fld @@ -545,6 +551,7 @@ void Foam::mappedPatchFieldBase<Type>::distribute patchField_.internalField().time(), mapper_.sampleRegion(), mapper_.samplePatch(), + myComm, mapper_.map().constructMap(), fieldName, fld @@ -566,6 +573,7 @@ void Foam::mappedPatchFieldBase<Type>::distribute storeAndRetrieveField ( fieldName, + myComm, AMI.srcMap().subMap(), AMI.tgtMap().constructSize(), AMI.tgtMap().constructMap(), @@ -581,6 +589,7 @@ void Foam::mappedPatchFieldBase<Type>::distribute storeAndRetrieveField ( fieldName, + myComm, AMI.tgtMap().subMap(), AMI.srcMap().constructSize(), AMI.srcMap().constructMap(), diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.H b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.H index 58b08b0ac71dcb3d9b0e8c0d1960289a696f0036..9ee3d796e2bd4857c38f11cca4266336b74b2ab5 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.H @@ -67,9 +67,9 @@ namespace Foam { // Forward Declarations -class mappedPatchBase; template<class> class interpolation; class mapDistribute; +class mappedPatchBase; /*---------------------------------------------------------------------------*\ Class mappedPatchFieldBase Declaration @@ -86,7 +86,7 @@ class mappedPatchFieldBase protected: - // Protected data + // Protected Data //- Mapping engine const mappedPatchBase& mapper_; @@ -129,6 +129,7 @@ protected: bool storeAndRetrieveField ( const word& fieldName, + const label myComm, const labelListList& subMap, const label constructSize, const labelListList& constructMap, @@ -138,6 +139,44 @@ protected: ) const; + //- Initialise field to retrieve (e.g. when value read from dictionary) + template<class T> + void initRetrieveField + ( + const word& fieldName, + const Field<T>& fld + ) const; + + + //- Store elements of field onto (sub) registry + template<class T> + void storeField + ( + const objectRegistry& obr, + const word& region, + const word& patch, + const label myComm, + const labelListList& procToMap, + const word& fieldName, + const Field<T>& fld + ) const; + + //- Construct field from registered elements. + // \return true if successful + template<class T> + bool retrieveField + ( + const bool allowUnset, + const objectRegistry& obr, + const word& region, + const word& patch, + const label myComm, + const labelListList& procToMap, + const word& fieldName, + Field<T>& fld + ) const; + + public: // Constructors @@ -230,54 +269,19 @@ public: virtual void write(Ostream& os) const; - // Helpers - - //- Check that patch is of correct type - static const mappedPatchBase& mapper - ( - const fvPatch& p, - const DimensionedField<Type, volMesh>& iF - ); - - //- Initialise field to retrieve (used e.g. when value read from - // dictionary) - template<class T> - void initRetrieveField - ( - const word& fieldName, - const Field<T>& fld - ) const; - - //- Store elements of field onto (sub) registry - template<class T> - void storeField - ( - const objectRegistry& obr, - const word& region, - const word& patch, - const labelListList& procToMap, - const word& fieldName, - const Field<T>& fld - ) const; - - //- Construct field from registered elements. Return true if - // successful - template<class T> - bool retrieveField - ( - const bool allowUnset, - const objectRegistry& obr, - const word& region, - const word& patch, - const labelListList& procToMap, - const word& fieldName, - Field<T>& fld - ) const; - - //- Wrapper for mapDistribute::distribute that knows about - //- dabase mapping - template<class T> - void distribute(const word& fieldName, Field<T>& newValues) const; + // Helpers + + //- Check that patch is of correct type + static const mappedPatchBase& mapper + ( + const fvPatch& p, + const DimensionedField<Type, volMesh>& iF + ); + + //- Wrapper for mapDistribute::distribute that knows about + //- dabase mapping + template<class T> + void distribute(const word& fieldName, Field<T>& newValues) const; }; diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedMixed/mappedMixedFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/mappedMixed/mappedMixedFvPatchField.C index d05fc6f33d567eab8262bad837d61f6cec27425c..216ca035feb481e234f2fa0039d3644ba2ad2670 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/mappedMixed/mappedMixedFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedMixed/mappedMixedFvPatchField.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -90,17 +90,19 @@ Foam::mappedMixedFvPatchField<Type>::mappedMixedFvPatchField this->valueFraction() = 1.0; } - // Store patch value as initial guess when running in database mode - mappedPatchFieldBase<Type>::initRetrieveField - ( - this->internalField().name(), - *this - ); - mappedPatchFieldBase<Type>::initRetrieveField - ( - this->internalField().name() + "_weights", - this->patch().deltaCoeffs() - ); +// This blocks (crashes) with more than two worlds! +// +/// // Store patch value as initial guess when running in database mode +/// mappedPatchFieldBase<Type>::initRetrieveField +/// ( +/// this->internalField().name(), +/// *this +/// ); +/// mappedPatchFieldBase<Type>::initRetrieveField +/// ( +/// this->internalField().name() + "_weights", +/// this->patch().deltaCoeffs() +/// ); } diff --git a/src/functionObjects/utilities/syncObjects/syncObjects.C b/src/functionObjects/utilities/syncObjects/syncObjects.C index 694eecfc92843af2e457b18d3443d31480566a82..9e90dff60fb2cdd92502563775c7bf98a2fc6b40 100644 --- a/src/functionObjects/utilities/syncObjects/syncObjects.C +++ b/src/functionObjects/utilities/syncObjects/syncObjects.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -39,7 +39,6 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(syncObjects, 0); - addToRunTimeSelectionTable ( functionObject, @@ -50,9 +49,6 @@ namespace functionObjects } -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjects::syncObjects::syncObjects @@ -63,14 +59,7 @@ Foam::functionObjects::syncObjects::syncObjects ) : functionObject(name), - obr_ - ( - //runTime.lookupObject<objectRegistry> - //( - // dict.lookupOrDefault("region", polyMesh::defaultRegion) - //) - runTime - ) + obr_(runTime) { read(dict); } @@ -121,9 +110,12 @@ void Foam::functionObjects::syncObjects::sync() dictionary sendDataDict; mappedPatchBase::writeDict(sendObr, sendDataDict); - //Pout<< "** to processor " << proci - // << " sendObr:" << sendObr.objectPath() - // << " sending dictionary:" << sendDataDict << endl; + if (debug & 2) + { + Pout<< "** to processor " << proci + << " sendObr:" << sendObr.objectPath() + << " sending dictionary:" << sendDataDict << endl; + } UOPstream os(proci, pBufs); os << sendDataDict; } @@ -139,14 +131,14 @@ void Foam::functionObjects::syncObjects::sync() obr_, mappedPatchBase::receivePath(root_, proci) ); - //Pout<< "** from processor " << proci - // << " receiveObr:" << receiveObr.objectPath() - // << " receiving dictionary" << endl; UIPstream is(proci, pBufs); const dictionary fromProcDict(is); - //Pout<< "** from processor " << proci - // << " received dictionary:" << fromProcDict << endl; - + if (debug & 2) + { + Pout<< "** from processor " << proci + << " receiveObr:" << receiveObr.objectPath() + << " received dictionary:" << fromProcDict << endl; + } mappedPatchBase::readDict ( fromProcDict, diff --git a/src/meshTools/Make/files b/src/meshTools/Make/files index d92cd130ad11bd503cb2289ca69461f7b9353ea4..09b7191723513790075d096bd98171e42c3ca822 100644 --- a/src/meshTools/Make/files +++ b/src/meshTools/Make/files @@ -298,6 +298,8 @@ $(ACMICycPatches)/cyclicACMIPointPatchField/cyclicACMIPointPatchFields.C PeriodicAMICycPatches=$(AMI)/patches/cyclicPeriodicAMI $(PeriodicAMICycPatches)/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.C +multiWorld/multiWorldConnectionsObject.C + mappedPatches/mappedPolyPatch/mappedPatchBase.C mappedPatches/mappedPolyPatch/mappedPolyPatch.C mappedPatches/mappedPolyPatch/mappedWallPolyPatch.C diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C index d5b19a4b33c44ca2f4064fbc11164afb1107716b..e02312a9113438187f4fab1567d8594ca587c0f4 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015-2020 OpenCFD Ltd. + Copyright (C) 2015-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,6 +30,7 @@ License #include "addToRunTimeSelectionTable.H" #include "ListListOps.H" #include "meshSearchMeshObject.H" +#include "multiWorldConnectionsObject.H" #include "meshTools.H" #include "OFstream.H" #include "Random.H" @@ -48,7 +49,7 @@ License #include "faceAreaWeightAMI.H" #include "OTstream.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { @@ -119,53 +120,31 @@ Foam::autoPtr<Foam::fileName> Foam::mappedPatchBase::readDatabase } -Foam::label Foam::mappedPatchBase::communicator -( - const word& sampleWorld -) +bool Foam::mappedPatchBase::addWorldConnection() { - // Start off with local world - label comm = UPstream::worldComm; - - if (!sampleWorld.empty() && Pstream::parRun()) + if (sameWorld()) { - if (!UPstream::allWorlds().found(sampleWorld)) - { - FatalErrorInFunction << "Cannot find sampleWorld " << sampleWorld - << " in set of worlds " << UPstream::allWorlds() - << exit(FatalError); - } - - const labelList& worldIDs = UPstream::worldIDs(); + return true; + } - DynamicList<label> subRanks(worldIDs.size()); - forAll(worldIDs, proci) - { - const label worldi = worldIDs[proci]; - if - ( - worldi == UPstream::myWorldID() - || UPstream::allWorlds()[worldi] == sampleWorld - ) - { - subRanks.append(proci); - } - } + const Time& runTime = patch_.boundaryMesh().mesh().time(); + return const_cast<multiWorldConnections&> + ( + multiWorldConnections::New(runTime) + ).addConnectionByName(sampleWorld_); +} - // Allocate new communicator with parent 0 (= world) - comm = UPstream::allocateCommunicator(0, subRanks, true); - if (debug) - { - Pout<< "mappedPatchBase::communicator :" - << " myWorld:" << UPstream::myWorld() - << " sampleWorld:" << sampleWorld - << " using subRanks:" << subRanks - << " new comm:" << comm << endl; - } +Foam::label Foam::mappedPatchBase::getWorldCommunicator() const +{ + if (sameWorld()) + { + return UPstream::worldComm; } - return comm; + const Time& runTime = patch_.boundaryMesh().mesh().time(); + return + multiWorldConnections::New(runTime).getCommByName(sampleWorld_); } @@ -180,8 +159,8 @@ Foam::tmp<Foam::pointField> Foam::mappedPatchBase::facePoints (void)mesh.tetBasePtIs(); // Initialise to face-centre - tmp<pointField> tfacePoints(new pointField(patch_.size())); - pointField& facePoints = tfacePoints.ref(); + auto tfacePoints = tmp<pointField>::New(patch_.size()); + auto& facePoints = tfacePoints.ref(); forAll(pp, facei) { @@ -208,18 +187,30 @@ void Foam::mappedPatchBase::collectSamples pointField& patchFc // Per sample: originating centre ) const { - const label oldComm(Pstream::warnComm); - Pstream::warnComm = comm_; + DebugInFunction << nl; - const label myRank = Pstream::myProcNo(comm_); - const label nProcs = Pstream::nProcs(comm_); + const label myComm = getCommunicator(); // Get or create + const label myRank = Pstream::myProcNo(myComm); + const label nProcs = Pstream::nProcs(myComm); + + const label oldWarnComm(Pstream::warnComm); + Pstream::warnComm = myComm; + + if (debug & 2) + { + Perr<< "patch: " << patch_.name() + << "[rank=" << myRank << " procs=" << nProcs + << " comm=" << myComm << "] collect samples" << endl; + } // Collect all sample points and the faces they come from. { List<pointField> globalFc(nProcs); globalFc[myRank] = facePoints; - Pstream::gatherList(globalFc, Pstream::msgType(), comm_); - Pstream::scatterList(globalFc, Pstream::msgType(), comm_); + + Pstream::gatherList(globalFc, Pstream::msgType(), myComm); + Pstream::scatterList(globalFc, Pstream::msgType(), myComm); + // Rework into straight list patchFc = ListListOps::combine<pointField> ( @@ -231,8 +222,8 @@ void Foam::mappedPatchBase::collectSamples { List<pointField> globalSamples(nProcs); globalSamples[myRank] = samplePoints(facePoints); - Pstream::gatherList(globalSamples, Pstream::msgType(), comm_); - Pstream::scatterList(globalSamples, Pstream::msgType(), comm_); + Pstream::gatherList(globalSamples, Pstream::msgType(), myComm); + Pstream::scatterList(globalSamples, Pstream::msgType(), myComm); // Rework into straight list samples = ListListOps::combine<pointField> ( @@ -245,8 +236,8 @@ void Foam::mappedPatchBase::collectSamples labelListList globalFaces(nProcs); globalFaces[myRank] = identity(patch_.size()); // Distribute to all processors - Pstream::gatherList(globalFaces, Pstream::msgType(), comm_); - Pstream::scatterList(globalFaces, Pstream::msgType(), comm_); + Pstream::gatherList(globalFaces, Pstream::msgType(), myComm); + Pstream::scatterList(globalFaces, Pstream::msgType(), myComm); patchFaces = ListListOps::combine<labelList> ( @@ -258,13 +249,13 @@ void Foam::mappedPatchBase::collectSamples { labelList procToWorldIndex(nProcs); procToWorldIndex[myRank] = mySampleWorld; - Pstream::gatherList(procToWorldIndex, Pstream::msgType(), comm_); - Pstream::scatterList(procToWorldIndex, Pstream::msgType(), comm_); + Pstream::gatherList(procToWorldIndex, Pstream::msgType(), myComm); + Pstream::scatterList(procToWorldIndex, Pstream::msgType(), myComm); labelList nPerProc(nProcs); nPerProc[myRank] = patch_.size(); - Pstream::gatherList(nPerProc, Pstream::msgType(), comm_); - Pstream::scatterList(nPerProc, Pstream::msgType(), comm_); + Pstream::gatherList(nPerProc, Pstream::msgType(), myComm); + Pstream::scatterList(nPerProc, Pstream::msgType(), myComm); patchFaceWorlds.setSize(patchFaces.size()); patchFaceProcs.setSize(patchFaces.size()); @@ -280,7 +271,8 @@ void Foam::mappedPatchBase::collectSamples } } } - Pstream::warnComm = oldComm; + + Pstream::warnComm = oldWarnComm; } @@ -296,9 +288,12 @@ void Foam::mappedPatchBase::findLocalSamples List<nearInfoWorld>& nearest ) const { - // Find the local cell containing the samples + DebugInFunction << nl; + + const label myComm = getCommunicator(); // Get or create - const label myRank = Pstream::myProcNo(comm_); + // Find the local cell containing the samples + const label myRank = Pstream::myProcNo(myComm); // Lookup the correct region const polyMesh& mesh = lookupMesh(sampleRegion); @@ -601,32 +596,32 @@ void Foam::mappedPatchBase::findSamples pointField& sampleLocations ) const { + DebugInFunction << nl; + // Find the processor/cell containing the samples. Does not account // for samples being found in two processors. + const label myComm = getCommunicator(); // Get or create + const label myRank = Pstream::myProcNo(myComm); + const label nProcs = Pstream::nProcs(myComm); - const label myRank = Pstream::myProcNo(comm_); - const label nProcs = Pstream::nProcs(comm_); + const label oldWarnComm(Pstream::warnComm); + Pstream::warnComm = myComm; wordList samplePatches(nProcs); { - const label oldComm(Pstream::warnComm); - Pstream::warnComm = comm_; samplePatches[myRank] = samplePatch_; - Pstream::gatherList(samplePatches, Pstream::msgType(), comm_); - Pstream::scatterList(samplePatches, Pstream::msgType(), comm_); - Pstream::warnComm = oldComm; + Pstream::gatherList(samplePatches, Pstream::msgType(), myComm); + Pstream::scatterList(samplePatches, Pstream::msgType(), myComm); } wordList sampleRegions(nProcs); { - const label oldComm(Pstream::warnComm); - Pstream::warnComm = comm_; sampleRegions[myRank] = sampleRegion_; - Pstream::gatherList(sampleRegions, Pstream::msgType(), comm_); - Pstream::scatterList(sampleRegions, Pstream::msgType(), comm_); - Pstream::warnComm = oldComm; + Pstream::gatherList(sampleRegions, Pstream::msgType(), myComm); + Pstream::scatterList(sampleRegions, Pstream::msgType(), myComm); } + // Find all the info for nearest List<nearInfoWorld> nearest(samples.size()); forAll(nearest, samplei) @@ -680,8 +675,6 @@ void Foam::mappedPatchBase::findSamples } } - const label oldComm(Pstream::warnComm); - Pstream::warnComm = comm_; // Find nearest. Combine on master. Pstream::listCombineGather @@ -689,13 +682,13 @@ void Foam::mappedPatchBase::findSamples nearest, nearestWorldEqOp(), Pstream::msgType(), - comm_ + myComm ); - Pstream::listCombineScatter(nearest, Pstream::msgType(), comm_); + Pstream::listCombineScatter(nearest, Pstream::msgType(), myComm); //if (debug) //{ - // Pout<< "** AFter combining:" << endl; + // Pout<< "** After combining:" << endl; // forAll(nearest, samplei) // { // Pout<< " sample:" << samples[samplei] @@ -735,7 +728,7 @@ void Foam::mappedPatchBase::findSamples } } - Pstream::warnComm = oldComm; + Pstream::warnComm = oldWarnComm; } @@ -748,6 +741,10 @@ void Foam::mappedPatchBase::calcMapping() const << "Mapping already calculated" << exit(FatalError); } + DebugInFunction << nl; + + const label myComm = getCommunicator(); // Get or create + //// Make sure if running in database that there is a syncObjects FO //if (sampleDatabase() && !sameWorld()) //{ @@ -806,11 +803,11 @@ void Foam::mappedPatchBase::calcMapping() const << " on the same patch, on the same region" << " will find the faces themselves which does not make sense" << " for anything but testing." << endl - << "patch_:" << patch_.name() << endl - << "sampleRegion_:" << sampleRegion() << endl - << "mode_:" << sampleModeNames_[mode_] << endl - << "samplePatch_:" << samplePatch() << endl - << "offsetMode_:" << offsetModeNames_[offsetMode_] << endl; + << "patch:" << patch_.name() << endl + << "sampleRegion:" << sampleRegion() << endl + << "mode:" << sampleModeNames_[mode_] << endl + << "samplePatch:" << samplePatch() << endl + << "offsetMode:" << offsetModeNames_[offsetMode_] << endl; } } @@ -877,7 +874,7 @@ void Foam::mappedPatchBase::calcMapping() const nNotFound++; } } - reduce(nNotFound, sumOp<label>(), Pstream::msgType(), comm_); + reduce(nNotFound, sumOp<label>(), Pstream::msgType(), myComm); if (nNotFound > 0) { @@ -937,7 +934,7 @@ void Foam::mappedPatchBase::calcMapping() const // - cell/face sample is in (so source when mapping) // sampleIndices, sampleProcs. - if (Pstream::master(comm_)) + if (Pstream::master(myComm)) { forAll(samples, i) { @@ -954,7 +951,7 @@ void Foam::mappedPatchBase::calcMapping() const } - if (debug && Pstream::master(comm_)) + if (debug && Pstream::master(myComm)) { //forAll(samples, i) //{ @@ -993,7 +990,7 @@ void Foam::mappedPatchBase::calcMapping() const } // Determine schedule. - mapPtr_.reset(new mapDistribute(sampleProcs, patchFaceProcs, comm_)); + mapPtr_.reset(new mapDistribute(sampleProcs, patchFaceProcs, myComm)); // Rework the schedule from indices into samples to cell data to send, // face data to receive. @@ -1104,6 +1101,13 @@ void Foam::mappedPatchBase::calcAMI() const return; } + DebugInFunction << nl; + + const label myComm = getCommunicator(); // Get or create + + const label oldWorldComm(Pstream::worldComm); + const label oldWarnComm(Pstream::warnComm); + // Check if running locally if (sampleWorld_.empty() || sameWorld()) { @@ -1136,17 +1140,15 @@ void Foam::mappedPatchBase::calcAMI() const } // Construct/apply AMI interpolation to determine addressing and - // weights. Make sure to use optional inter-world communicator. + // weights. - const label oldWorldComm = Pstream::worldComm; - Pstream::worldComm = comm_; - - const label oldComm(Pstream::warnComm); - Pstream::warnComm = UPstream::worldComm; + // Change to use inter-world communicator + Pstream::worldComm = myComm; + Pstream::warnComm = Pstream::worldComm; AMIPtr_->calculate(patch_, nbrPatch0, surfPtr()); - Pstream::warnComm = oldComm; + Pstream::warnComm = oldWarnComm; Pstream::worldComm = oldWorldComm; } else @@ -1163,11 +1165,8 @@ void Foam::mappedPatchBase::calcAMI() const ); // Change to use inter-world communicator - const label oldWorldComm = Pstream::worldComm; - Pstream::worldComm = comm_; - - const label oldComm(Pstream::warnComm); - Pstream::warnComm = UPstream::worldComm; + Pstream::worldComm = myComm; + Pstream::warnComm = Pstream::worldComm; if (masterWorld()) { @@ -1186,7 +1185,7 @@ void Foam::mappedPatchBase::calcAMI() const // Now the AMI addressing/weights will be from src side (on masterWorld // processors) to tgt side (on other processors) - Pstream::warnComm = oldComm; + Pstream::warnComm = oldWarnComm; Pstream::worldComm = oldWorldComm; } } @@ -1216,28 +1215,26 @@ const Foam::objectRegistry& Foam::mappedPatchBase::subRegistry Foam::mappedPatchBase::mappedPatchBase(const polyPatch& pp) : patch_(pp), - sampleWorld_(word::null), + sampleWorld_(), sampleRegion_(patch_.boundaryMesh().mesh().name()), mode_(NEARESTPATCHFACE), - samplePatch_(word::null), + samplePatch_(), coupleGroup_(), sampleDatabasePtr_(), offsetMode_(UNIFORM), offset_(Zero), offsets_(pp.size(), offset_), distance_(0), - comm_(communicator(sampleWorld_)), - sameRegion_ - ( - sampleWorld_.empty() - && sampleRegion_ == patch_.boundaryMesh().mesh().name() - ), + communicator_(-1), // Demand-driven (cached value) + sameRegion_(true), mapPtr_(nullptr), AMIReverse_(false), AMIPtr_(new faceAreaWeightAMI(true, AMIReverse_)), surfPtr_(nullptr), surfDict_(fileName("surface")) -{} +{ + // NOTE: same region, no sample-world. Thus no world-world communication +} Foam::mappedPatchBase::mappedPatchBase @@ -1249,29 +1246,17 @@ Foam::mappedPatchBase::mappedPatchBase const vectorField& offsets ) : - patch_(pp), - sampleWorld_(word::null), - sampleRegion_(sampleRegion), - mode_(mode), - samplePatch_(samplePatch), - coupleGroup_(), - sampleDatabasePtr_(), - offsetMode_(NONUNIFORM), - offset_(Zero), - offsets_(offsets), - distance_(0), - comm_(communicator(sampleWorld_)), - sameRegion_ + mappedPatchBase ( - sampleWorld_.empty() - && sampleRegion_ == patch_.boundaryMesh().mesh().name() - ), - mapPtr_(nullptr), - AMIReverse_(false), - AMIPtr_(new faceAreaWeightAMI(true, AMIReverse_)), - surfPtr_(nullptr), - surfDict_(fileName("surface")) -{} + pp, + sampleRegion, + mode, + samplePatch, + scalar(0) + ) +{ + mappedPatchBase::setOffset(offsets); +} Foam::mappedPatchBase::mappedPatchBase @@ -1280,32 +1265,20 @@ Foam::mappedPatchBase::mappedPatchBase const word& sampleRegion, const sampleMode mode, const word& samplePatch, - const vector& offset + const vector& uniformOffset ) : - patch_(pp), - sampleWorld_(word::null), - sampleRegion_(sampleRegion), - mode_(mode), - samplePatch_(samplePatch), - coupleGroup_(), - sampleDatabasePtr_(), - offsetMode_(UNIFORM), - offset_(offset), - offsets_(0), - distance_(0), - comm_(communicator(sampleWorld_)), - sameRegion_ + mappedPatchBase ( - sampleWorld_.empty() - && sampleRegion_ == patch_.boundaryMesh().mesh().name() - ), - mapPtr_(nullptr), - AMIReverse_(false), - AMIPtr_(new faceAreaWeightAMI(true, AMIReverse_)), - surfPtr_(nullptr), - surfDict_(fileName("surface")) -{} + pp, + sampleRegion, + mode, + samplePatch, + scalar(0) + ) +{ + mappedPatchBase::setOffset(uniformOffset); +} Foam::mappedPatchBase::mappedPatchBase @@ -1314,11 +1287,11 @@ Foam::mappedPatchBase::mappedPatchBase const word& sampleRegion, const sampleMode mode, const word& samplePatch, - const scalar distance + const scalar normalDistance ) : patch_(pp), - sampleWorld_(word::null), + sampleWorld_(), sampleRegion_(sampleRegion), mode_(mode), samplePatch_(samplePatch), @@ -1327,8 +1300,8 @@ Foam::mappedPatchBase::mappedPatchBase offsetMode_(NORMAL), offset_(Zero), offsets_(0), - distance_(distance), - comm_(communicator(sampleWorld_)), + distance_(normalDistance), + communicator_(-1), // Demand-driven (cached value) sameRegion_ ( sampleWorld_.empty() @@ -1339,7 +1312,9 @@ Foam::mappedPatchBase::mappedPatchBase AMIPtr_(new faceAreaWeightAMI(true, AMIReverse_)), surfPtr_(nullptr), surfDict_(fileName("surface")) -{} +{ + addWorldConnection(); +} Foam::mappedPatchBase::mappedPatchBase @@ -1358,8 +1333,8 @@ Foam::mappedPatchBase::mappedPatchBase offsetMode_(UNIFORM), offset_(Zero), offsets_(0), - distance_(0.0), - comm_(communicator(sampleWorld_)), + distance_(0), + communicator_(-1), // Demand-driven (cached value) sameRegion_ ( sampleWorld_.empty() @@ -1379,6 +1354,8 @@ Foam::mappedPatchBase::mappedPatchBase surfPtr_(nullptr), surfDict_(dict.subOrEmptyDict("surface")) { + addWorldConnection(); + if (!coupleGroup_.valid()) { if (sampleWorld_.empty() && sampleRegion_.empty()) @@ -1448,8 +1425,8 @@ Foam::mappedPatchBase::mappedPatchBase offsetMode_(UNIFORM), offset_(Zero), offsets_(0), - distance_(0.0), - comm_(communicator(sampleWorld_)), + distance_(0), + communicator_(-1), // Demand-driven (cached value) sameRegion_ ( sampleWorld_.empty() @@ -1469,6 +1446,8 @@ Foam::mappedPatchBase::mappedPatchBase surfPtr_(nullptr), surfDict_(dict.subOrEmptyDict("surface")) { + addWorldConnection(); + if (mode != NEARESTPATCHFACE && mode != NEARESTPATCHFACEAMI) { FatalIOErrorInFunction(dict) @@ -1479,7 +1458,6 @@ Foam::mappedPatchBase::mappedPatchBase << exit(FatalIOError); } - if (!coupleGroup_.valid()) { if (sampleWorld_.empty() && sampleRegion_.empty()) @@ -1514,7 +1492,7 @@ Foam::mappedPatchBase::mappedPatchBase offset_(mpb.offset_), offsets_(mpb.offsets_), distance_(mpb.distance_), - comm_(mpb.comm_), + communicator_(mpb.communicator_), sameRegion_(mpb.sameRegion_), mapPtr_(nullptr), AMIReverse_(mpb.AMIReverse_), @@ -1552,7 +1530,7 @@ Foam::mappedPatchBase::mappedPatchBase : vectorField() ), distance_(mpb.distance_), - comm_(mpb.comm_), + communicator_(mpb.communicator_), sameRegion_(mpb.sameRegion_), mapPtr_(nullptr), AMIReverse_(mpb.AMIReverse_), @@ -1572,14 +1550,44 @@ Foam::mappedPatchBase::~mappedPatchBase() void Foam::mappedPatchBase::clearOut() { - mapPtr_.clear(); - surfPtr_.clear(); + mapPtr_.reset(nullptr); + surfPtr_.reset(nullptr); AMIPtr_->upToDate() = false; } // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +void Foam::mappedPatchBase::setOffset(const scalar normalDist) +{ + clearOut(); + offsetMode_ = offsetMode::NORMAL; + offset_ = Zero; + offsets_.clear(); + distance_ = normalDist; +} + + +void Foam::mappedPatchBase::setOffset(const vector& uniformOffset) +{ + clearOut(); + offsetMode_ = offsetMode::UNIFORM; + offset_ = uniformOffset; + offsets_.clear(); + distance_ = Zero; +} + + +void Foam::mappedPatchBase::setOffset(const vectorField& offsets) +{ + clearOut(); + offsetMode_ = offsetMode::NONUNIFORM; + offset_ = Zero; + offsets_ = offsets; + distance_ = Zero; +} + + const Foam::polyMesh& Foam::mappedPatchBase::lookupMesh ( const word& sampleRegion @@ -1653,8 +1661,8 @@ Foam::tmp<Foam::pointField> Foam::mappedPatchBase::samplePoints const pointField& fc ) const { - tmp<pointField> tfld(new pointField(fc)); - pointField& fld = tfld.ref(); + auto tfld = tmp<pointField>::New(fc); + auto& fld = tfld.ref(); switch (offsetMode_) { @@ -1725,7 +1733,7 @@ Foam::pointIndexHit Foam::mappedPatchBase::facePoint return pointIndexHit(true, fc, 0); } - label celli = mesh.faceOwner()[facei]; + const label celli = mesh.faceOwner()[facei]; const point& cc = mesh.cellCentres()[celli]; vector d = fc-cc; @@ -1918,7 +1926,7 @@ void Foam::mappedPatchBase::write(Ostream& os) const if (sampleDatabasePtr_) { - os.writeEntry("sampleDatabase", sampleDatabasePtr_.valid()); + os.writeEntry("sampleDatabase", Switch::name(true)); // Write database path if differing os.writeEntryIfDifferent<fileName> ( diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H index 9c23dfcdcb33d1378813dec3e361d72814a94778..09bdd1367a8aae6c05b8adfc51a076246fc67398 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -112,7 +112,6 @@ class mapDistribute; class mappedPatchBase { - public: // Type enumerations @@ -150,7 +149,6 @@ public: class nearestEqOp { - public: void operator()(nearInfo& x, const nearInfo& y) const @@ -171,7 +169,6 @@ public: class maxProcEqOp { - public: void operator()(nearInfo& x, const nearInfo& y) const @@ -197,7 +194,6 @@ public: class nearestWorldEqOp { - public: void operator()(nearInfoWorld& x, const nearInfoWorld& y) const @@ -225,7 +221,7 @@ public: protected: - // Protected data + // Protected Data //- Patch to sample const polyPatch& patch_; @@ -261,7 +257,7 @@ protected: scalar distance_; //- Communicator - label comm_; + label communicator_; //- Same region mutable bool sameRegion_; @@ -294,8 +290,11 @@ protected: // Protected Member Functions - //- Optionally allocate a world-local communicator - static label communicator(const word& sampleWorld); + //- Add a world-world connection + bool addWorldConnection(); + + //- Get the communicator for the world-world connection + label getWorldCommunicator() const; //- Lookup mesh const polyMesh& lookupMesh(const word& region) const; @@ -309,11 +308,11 @@ protected: //- Get the points from face-centre-decomposition face centres - // and project them onto the face-diagonal-decomposition triangles. + //- and project them onto the face-diagonal-decomposition triangles. tmp<pointField> facePoints(const polyPatch&) const; //- Collect single list of samples and originating processor+face + - // wanted world + //- wanted world void collectSamples ( const label mySampleWorld, // My wanted sampling world @@ -362,7 +361,7 @@ protected: void calcAMI() const; - // Database handling + // Database Handling //- Read optional database name from dictionary static autoPtr<fileName> readDatabase(const dictionary& dict); @@ -422,7 +421,7 @@ public: const word& sampleRegion, const sampleMode sampleMode, const word& samplePatch, - const vector& offset + const vector& uniformOffset ); //- Construct from offsetMode=normal and distance @@ -432,7 +431,7 @@ public: const word& sampleRegion, const sampleMode sampleMode, const word& samplePatch, - const scalar distance + const scalar normalDistance ); //- Construct from dictionary @@ -459,17 +458,29 @@ public: virtual ~mappedPatchBase(); - // Member functions + // Member Functions + + // Edit void clearOut(); + //- Change to normal offset with given distance + void setOffset(const scalar normalDist); + + //- Change to uniform offset with value + void setOffset(const vector& uniformOffset); + + //- Change to non-uniform offsets + void setOffset(const vectorField& offsets); + + // Access //- What to sample - inline const sampleMode& mode() const; + inline sampleMode mode() const noexcept; //- World to sample - inline const word& sampleWorld() const; + inline const word& sampleWorld() const noexcept; //- Region to sample inline const word& sampleRegion() const; @@ -484,12 +495,15 @@ public: inline label sampleSize() const; //- Offset vector (from patch faces to destination mesh objects) - inline const vector& offset() const; + inline const vector& offset() const noexcept; - //- Offset vector (from patch faces to destination mesh objects) - inline const vectorField& offsets() const; + //- Offset vectors (from patch faces to destination mesh objects) + inline const vectorField& offsets() const noexcept; + + //- Get the communicator (worldComm or world-to-world) + inline label getCommunicator() const; - //- Communicator + //- Identical to getCommunicator() inline label comm() const; //- Is sample world the local world? @@ -499,7 +513,7 @@ public: inline bool masterWorld() const; //- Cached sampleRegion != mesh.name() - inline bool sameRegion() const; + inline bool sameRegion() const noexcept; //- Return reference to the parallel distribution map inline const mapDistribute& map() const; @@ -547,7 +561,7 @@ public: inline bool sampleDatabase() const { - return sampleDatabasePtr_.valid(); + return bool(sampleDatabasePtr_); } //- Helper: return path to store data to be sent to processor i @@ -615,7 +629,7 @@ public: // I/O //- Write as a dictionary - virtual void write(Ostream&) const; + virtual void write(Ostream& os) const; }; diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseI.H b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseI.H index fee58471deed8017616473817179b3c25d2e3d92..2a3695d7cd8c4f968a30f6639105de6166279eaf 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseI.H +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseI.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,14 +26,14 @@ License \*---------------------------------------------------------------------------*/ -inline const Foam::mappedPatchBase::sampleMode& -Foam::mappedPatchBase::mode() const +inline Foam::mappedPatchBase::sampleMode +Foam::mappedPatchBase::mode() const noexcept { return mode_; } -inline const Foam::word& Foam::mappedPatchBase::sampleWorld() const +inline const Foam::word& Foam::mappedPatchBase::sampleWorld() const noexcept { return sampleWorld_; } @@ -132,29 +132,48 @@ inline Foam::label Foam::mappedPatchBase::sampleSize() const } -inline const Foam::vector& Foam::mappedPatchBase::offset() const +inline const Foam::vector& Foam::mappedPatchBase::offset() const noexcept { return offset_; } -inline const Foam::vectorField& Foam::mappedPatchBase::offsets() const +inline const Foam::vectorField& Foam::mappedPatchBase::offsets() const noexcept { return offsets_; } +inline Foam::label Foam::mappedPatchBase::getCommunicator() const +{ + // Cached communicator, or a get a new one + if (communicator_ == -1) + { + const_cast<label&>(communicator_) = getWorldCommunicator(); + } + return communicator_; +} + + inline Foam::label Foam::mappedPatchBase::comm() const { - return comm_; + // Cached communicator, or a get a new one + if (communicator_ == -1) + { + const_cast<label&>(communicator_) = getWorldCommunicator(); + } + return communicator_; } inline bool Foam::mappedPatchBase::sameWorld() const { return + ( UPstream::allWorlds().size() == 1 - || UPstream::myWorld() == sampleWorld_; + || sampleWorld_.empty() + || UPstream::myWorld() == sampleWorld_ + ); } @@ -164,18 +183,14 @@ inline bool Foam::mappedPatchBase::masterWorld() const { return true; } - else - { - // Use ordering in allWorlds - const label myWorld = UPstream::myWorldID(); - const label mySampleWorld = - UPstream::allWorlds().find(sampleWorld_); - return myWorld < mySampleWorld; - } + + // Use ordering in allWorlds + const label otherWorldId = UPstream::allWorlds().find(sampleWorld_); + return (otherWorldId < 0 || (UPstream::myWorldID() < otherWorldId)); } -inline bool Foam::mappedPatchBase::sameRegion() const +inline bool Foam::mappedPatchBase::sameRegion() const noexcept { return sameRegion_; } diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseTemplates.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseTemplates.C index 29c5e7a1690e5f8bb2fbe7234730d583d053067f..130f10823eaa3da56732a7f10c04c7683a3c014b 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseTemplates.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseTemplates.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2018-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,14 +29,16 @@ License template<class Type> void Foam::mappedPatchBase::distribute(List<Type>& lst) const { - const label oldComm(Pstream::warnComm); - Pstream::warnComm = comm_; + const label myComm = getCommunicator(); // Get or create + const label oldWarnComm(Pstream::warnComm); + Pstream::warnComm = myComm; + switch (mode_) { case NEARESTPATCHFACEAMI: { - const label oldWorldComm = Pstream::worldComm; - Pstream::worldComm = comm_; + const label oldWorldComm(Pstream::worldComm); + Pstream::worldComm = myComm; if (sameWorld()) { @@ -90,7 +93,8 @@ void Foam::mappedPatchBase::distribute(List<Type>& lst) const map().distribute(lst); } } - Pstream::warnComm = oldComm; + + Pstream::warnComm = oldWarnComm; } @@ -101,14 +105,16 @@ void Foam::mappedPatchBase::distribute const CombineOp& cop ) const { - const label oldComm(Pstream::warnComm); - Pstream::warnComm = comm_; + const label myComm = getCommunicator(); // Get or create + const label oldWarnComm(Pstream::warnComm); + Pstream::warnComm = myComm; + switch (mode_) { case NEARESTPATCHFACEAMI: { - const label oldWorldComm = Pstream::worldComm; - Pstream::worldComm = comm_; + const label oldWorldComm(Pstream::worldComm); + Pstream::worldComm = myComm; lst = AMI().interpolateToSource(Field<Type>(std::move(lst)), cop); Pstream::worldComm = oldWorldComm; break; @@ -129,25 +135,28 @@ void Foam::mappedPatchBase::distribute cop, flipOp(), UPstream::msgType(), - comm_ + myComm ); } } - Pstream::warnComm = oldComm; + + Pstream::warnComm = oldWarnComm; } template<class Type> void Foam::mappedPatchBase::reverseDistribute(List<Type>& lst) const { - const label oldComm(Pstream::warnComm); - Pstream::warnComm = comm_; + const label myComm = getCommunicator(); // Get or create + const label oldWarnComm(Pstream::warnComm); + Pstream::warnComm = myComm; + switch (mode_) { case NEARESTPATCHFACEAMI: { - const label oldWorldComm = Pstream::worldComm; - Pstream::worldComm = comm_; + const label oldWorldComm(Pstream::worldComm); + Pstream::worldComm = myComm; lst = AMI().interpolateToTarget(Field<Type>(std::move(lst))); Pstream::worldComm = oldWorldComm; break; @@ -158,7 +167,8 @@ void Foam::mappedPatchBase::reverseDistribute(List<Type>& lst) const break; } } - Pstream::warnComm = oldComm; + + Pstream::warnComm = oldWarnComm; } @@ -169,14 +179,16 @@ void Foam::mappedPatchBase::reverseDistribute const CombineOp& cop ) const { - const label oldComm(Pstream::warnComm); - Pstream::warnComm = comm_; + const label myComm = getCommunicator(); // Get or create + const label oldWarnComm(Pstream::warnComm); + Pstream::warnComm = myComm; + switch (mode_) { case NEARESTPATCHFACEAMI: { - const label oldWorldComm = Pstream::worldComm; - Pstream::worldComm = comm_; + const label oldWorldComm(Pstream::worldComm); + Pstream::worldComm = myComm; lst = AMI().interpolateToTarget(Field<Type>(std::move(lst)), cop); Pstream::worldComm = oldWorldComm; break; @@ -198,12 +210,13 @@ void Foam::mappedPatchBase::reverseDistribute cop, flipOp(), UPstream::msgType(), - comm_ + myComm ); break; } } - Pstream::warnComm = oldComm; + + Pstream::warnComm = oldWarnComm; } diff --git a/src/meshTools/multiWorld/multiWorldConnectionsObject.C b/src/meshTools/multiWorld/multiWorldConnectionsObject.C new file mode 100644 index 0000000000000000000000000000000000000000..f8d2c438ed99c225117d6a6e5d7a5437e1003483 --- /dev/null +++ b/src/meshTools/multiWorld/multiWorldConnectionsObject.C @@ -0,0 +1,462 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "multiWorldConnectionsObject.H" +#include "Pstream.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(multiWorldConnections, 0); +} + + +// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Combine world-to-world connections. +// Forward connection = 1, Backward connection = 2, Both = 3 +struct worldConnectBitOrEq +{ + void operator()(EdgeMap<unsigned>& a, const EdgeMap<unsigned>& b) const + { + forAllConstIters(b, iter) + { + a(iter.key()) |= iter.val(); + } + } +}; + + +static void printDOT(Ostream& os, const EdgeMap<unsigned>& connections) +{ + os << nl << "// Multiworld communication graph:" << nl; + os.beginBlock("graph"); + + // Graph Nodes == worlds + label worldi = 0; + for (const word& worldName : UPstream::allWorlds()) + { + os.indent(); + os << worldi << " [xlabel=" << worldi + << ",label=\"" << worldName << "\"]" << nl; + + ++worldi; + } + os << nl; + + // Graph Edges == connections + for (const edge& connect : connections.sortedToc()) + { + os.indent(); + os << connect.first() << " -- " << connect.second(); + + // Mismatched forward/backward connections? + if (connections.lookup(connect, 0u) != 3u) + { + os << " [style=dashed] // mismatched?"; + } + os << nl; + } + + os.endBlock(); + + os << "// end graph" << nl; +} + +} // End namespace Foam + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +Foam::edge Foam::multiWorldConnections::worldPair(const label otherWorld) +{ + if (otherWorld < 0 || !Pstream::parRun()) + { + Perr<< "ignore: no world or non-parallel" << endl; + return edge(-1, -1); + } + else if (UPstream::allWorlds().size() <= otherWorld) + { + Perr<< "ignore: invalid world: " << otherWorld << endl; + return edge(-1, -1); + } + + const label thisWorldID = UPstream::myWorldID(); + + // The worlds (sorted) + return edge(thisWorldID, otherWorld, true); +} + + +Foam::edge Foam::multiWorldConnections::worldPair(const word& otherWorld) +{ + if (otherWorld.empty() || !Pstream::parRun()) + { + Perr<< "ignore: no world or non-parallel" << endl; + return edge(-1, -1); + } + + const label thisWorldID = UPstream::myWorldID(); + const label otherWorldID = UPstream::allWorlds().find(otherWorld); + + if (otherWorldID < 0) + { + FatalErrorInFunction + << "Cannot find world " << otherWorld + << " in set of worlds " << flatOutput(UPstream::allWorlds()) + << exit(FatalError); + } + + // The worlds (sorted) + return edge(thisWorldID, otherWorldID, true); +} + + +Foam::label Foam::multiWorldConnections::createCommunicator(const edge& worlds) +{ + // Fallback: do not create, just use local world + label comm = UPstream::worldComm; + + if (!worlds.valid()) + { + return comm; + } + + const labelList& worldIDs = UPstream::worldIDs(); + + DynamicList<label> subRanks(worldIDs.size()); + forAll(worldIDs, proci) + { + if (worlds.found(worldIDs[proci])) + { + subRanks.append(proci); + } + } + + // Allocate new communicator with parent 0 (= world) + comm = UPstream::allocateCommunicator(0, subRanks, true); + + if (debug & 2) + { + Pout<< "multiWorld::communicator :" + << " between " << UPstream::allWorlds()[worlds.first()] + << " and " << UPstream::allWorlds()[worlds.second()] + << " sub-ranks: " << subRanks + << " comm:" << comm << endl; + } + + return comm; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::multiWorldConnections::multiWorldConnections(const Time& runTime) +: + MeshObjectType(runTime) +{} + + +// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // + +const Foam::multiWorldConnections& +Foam::multiWorldConnections::New(const Time& runTime) +{ + return MeshObjectType::New(runTime); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::multiWorldConnections::~multiWorldConnections() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::multiWorldConnections::empty() const noexcept +{ + return table_.empty(); +} + + +Foam::label Foam::multiWorldConnections::size() const noexcept +{ + return table_.size(); +} + + +void Foam::multiWorldConnections::createComms() +{ + // Need new communicator(s) + + const label thisWorldID = UPstream::myWorldID(); + + EdgeMap<unsigned> allConnections; + forAllConstIters(table_, iter) + { + const edge& connect = iter.key(); + + allConnections.insert + ( + connect, + (connect.first() == thisWorldID ? 1u : 2u) + ); + } + + + // Use MPI_COMM_WORLD + const label oldWorldComm(Pstream::worldComm); + const label oldWarnComm(Pstream::warnComm); + Pstream::worldComm = 0; + Pstream::warnComm = Pstream::worldComm; + + if (Pstream::parRun()) + { + Pstream::combineGather + ( + allConnections, + worldConnectBitOrEq() + ); + Pstream::scatter(allConnections); + } + + // Check for mismatched connections + label brokenConnections = 0; + + forAllConstIters(allConnections, iter) + { + // Mismatched forward/backward connections? + if (iter.val() != 3u) + { + ++brokenConnections; + } + } + + if (brokenConnections) + { + Pstream::warnComm = oldWarnComm; + Pstream::worldComm = oldWorldComm; + + FatalErrorInFunction + << "Has " << brokenConnections + << " broken world-world connections"; + + printDOT(FatalError, allConnections); + + FatalError << exit(FatalError); + } + else + { + // NOTE: process in sorted order to ensure proper + // synchronization on all worlds and all processors + + for (const edge& connect : allConnections.sortedToc()) + { + // Process known connections without communicators. + // - create a communicator and cache its value + + auto iter = table_.find(connect); + if (iter.found() && iter.val() == -1) + { + iter.val() = createCommunicator(connect); + } + } + + Pstream::warnComm = oldWarnComm; + Pstream::worldComm = oldWorldComm; + } + + if (debug) + { + printDOT(Info, allConnections); + } +} + + +bool Foam::multiWorldConnections::addConnectionById(const label otherWorld) +{ + // The worlds (sorted) + edge worlds(worldPair(otherWorld)); + + if (!worlds.valid()) + { + return false; + } + + const bool added = table_.insert(worlds, -1); + + Pout<< (added ? "Add" : "Existing") << " connection from " + << UPstream::myWorld() << " to " << otherWorld << nl; + + return added; +} + + +bool Foam::multiWorldConnections::addConnectionByName(const word& otherWorld) +{ + // The worlds (sorted) + edge worlds(worldPair(otherWorld)); + + if (!worlds.valid()) + { + return false; + } + + const bool added = table_.insert(worlds, -1); + + Pout<< (added ? "Add" : "Existing") << " connection from " + << UPstream::myWorld() << " to " << otherWorld << nl; + + return added; +} + + +Foam::label Foam::multiWorldConnections::getCommById +( + const label otherWorldID +) const +{ + // Default: use local world + label comm = UPstream::worldComm; + + // The communication worlds (sorted) + edge worlds(worldPair(otherWorldID)); + + if (!worlds.valid()) + { + return comm; + } + + const auto iter = table_.cfind(worlds); + + if (!iter.found()) + { + FatalErrorInFunction + << "No connection registered for worlds " << worlds + << exit(FatalError); + } + + // Get cached value, or allocate ALL known communicators + comm = iter.val(); + + if (comm == -1) + { + // Need new communicator(s) + const_cast<multiWorldConnections&>(*this).createComms(); + + // Retrieve from table cache + comm = table_.lookup(worlds, UPstream::worldComm); + } + + return comm; +} + + +Foam::label Foam::multiWorldConnections::getCommByName +( + const word& otherWorld +) const +{ + // Default: use local world + label comm = UPstream::worldComm; + + // The communication worlds (sorted) + edge worlds(worldPair(otherWorld)); + + if (!worlds.valid()) + { + return comm; + } + + const auto iter = table_.cfind(worlds); + + if (!iter.found()) + { + FatalErrorInFunction + << "No connection registered for worlds " << worlds + << exit(FatalError); + } + + // Get cached value, or allocate ALL known communicators + comm = iter.val(); + + if (comm == -1) + { + // Need new communicator(s) + const_cast<multiWorldConnections&>(*this).createComms(); + + // Retrieve from table cache + comm = table_.lookup(worlds, UPstream::worldComm); + } + + return comm; +} + + +Foam::labelList Foam::multiWorldConnections::comms() const +{ + labelList list(table_.size()); + + if (list.empty()) + { + // Default: use local world + list.resize(1, UPstream::worldComm); + } + else + { + forAllConstIters(table_, iter) + { + if (iter.val() == -1) + { + // Need new communicator(s) + const_cast<multiWorldConnections&>(*this).createComms(); + break; + } + } + + // Retrieve values from table cache + label i = 0; + + forAllConstIters(table_, iter) + { + list[i] = iter.val(); + ++i; + } + + Foam::sort(list); // Consistent order! + } + + return list; +} + + +// ************************************************************************* // diff --git a/src/meshTools/multiWorld/multiWorldConnectionsObject.H b/src/meshTools/multiWorld/multiWorldConnectionsObject.H new file mode 100644 index 0000000000000000000000000000000000000000..76cf3f505a9962782cc3b7539631e80a8aa89f3f --- /dev/null +++ b/src/meshTools/multiWorld/multiWorldConnectionsObject.H @@ -0,0 +1,157 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::multiWorldConnections + +Description + Centralized handling of multi-world MPI connections. + +Note + This class may move to static only or a singleton in the future. + +SourceFiles + multiWorldConnectionsObject.C + +\*---------------------------------------------------------------------------*/ + +#ifndef meshObjects_multiWorldConnections_H +#define meshObjects_multiWorldConnections_H + +#include "MeshObject.H" +#include "EdgeMap.H" +#include "Time.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class multiWorldConnections Declaration +\*---------------------------------------------------------------------------*/ + +class multiWorldConnections +: + public MeshObject + < + Time, + TopologicalMeshObject, + multiWorldConnections + > +{ + // Private Typedefs + + typedef MeshObject + < + Time, + TopologicalMeshObject, + multiWorldConnections + > MeshObjectType; + + + // Private Data + + //- Table of world/world connections to communicator label + EdgeMap<label> table_; + + + // Private Member Functions + + //- Pairing from myWorld to other world by ID + // \return invalid on any error or if non-parallel + static edge worldPair(const label otherWorld); + + //- Pairing from myWorld to other world by NAME. + // \return invalid on any error or if non-parallel + static edge worldPair(const word& otherWorld); + + //- Allocate a communicator between myWorld and other world + static label createCommunicator(const edge& worlds); + + +public: + + //- Run-time type information + TypeName("multiWorld"); + + + // Constructors + + //- Construct + explicit multiWorldConnections(const Time& runTime); + + + // Selectors + + //- Access mesh object + static const multiWorldConnections& New(const Time& runTime); + + + //- Destructor + ~multiWorldConnections(); + + + // Member Functions + + //- True if no world-to-world connections are defined + bool empty() const noexcept; + + //- Number of world-to-world connections defined. + label size() const noexcept; + + //- Create all communicators. + //- Low-level, not normally called directly + void createComms(); + + //- Define a connection from myWorld to other world by ID + bool addConnectionById(const label otherWorld); + + //- Define a connection from myWorld to other world by NAME + bool addConnectionByName(const word& otherWorld); + + //- Get communicator for myWorld to other world connection by ID. + // Uses cached value, or creates a new communicator + label getCommById(const label otherWorld) const; + + //- Get communicator for myWorld to other world connection by NAME. + // Uses cached value, or creates a new communicator + label getCommByName(const word& otherWorld) const; + + //- Get communicators used for myWorld to other worlds in sorted order. + // \return worldComm if no world-to-world communicators in use. + labelList comms() const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/tutorials/basic/laplacianFoam/multiWorld/mpirun.schema b/tutorials/basic/laplacianFoam/multiWorld/mpirun.schema deleted file mode 100644 index cc3c3af9f1c56337363e136847e987d70bcc4a7a..0000000000000000000000000000000000000000 --- a/tutorials/basic/laplacianFoam/multiWorld/mpirun.schema +++ /dev/null @@ -1,2 +0,0 @@ --np 2 laplacianFoam -case left -world LEFT -parallel --np 2 laplacianFoam -case right -world RIGHT -parallel diff --git a/tutorials/basic/laplacianFoam/multiWorld/right/constant/transportProperties b/tutorials/basic/laplacianFoam/multiWorld/right/constant/transportProperties deleted file mode 120000 index d0e9cc0e1caac311626efaec509ece91b57722f9..0000000000000000000000000000000000000000 --- a/tutorials/basic/laplacianFoam/multiWorld/right/constant/transportProperties +++ /dev/null @@ -1 +0,0 @@ -../../left/constant/transportProperties \ No newline at end of file diff --git a/applications/test/multiWorld/Allclean b/tutorials/basic/laplacianFoam/multiWorld1/Allclean similarity index 71% rename from applications/test/multiWorld/Allclean rename to tutorials/basic/laplacianFoam/multiWorld1/Allclean index 336db4138515a5a9192bca1dabf80608d59140c6..4512a2f0dccbc1477353dbf99d1bda82139549aa 100755 --- a/applications/test/multiWorld/Allclean +++ b/tutorials/basic/laplacianFoam/multiWorld1/Allclean @@ -3,12 +3,14 @@ cd "${0%/*}" || exit # Run from this directory . ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions #------------------------------------------------------------------------------ -for subcase in left right +for subcase in $(./list-worlds) do ( - cd "$subcase" && cleanCase + cd "$subcase" || exit + cleanCase0 + rm -f *_mapped.obj 2>/dev/null ) done -rm -f log.* +rm -rf log.* 2>/dev/null #------------------------------------------------------------------------------ diff --git a/tutorials/basic/laplacianFoam/multiWorld/Allrun b/tutorials/basic/laplacianFoam/multiWorld1/Allrun similarity index 60% rename from tutorials/basic/laplacianFoam/multiWorld/Allrun rename to tutorials/basic/laplacianFoam/multiWorld1/Allrun index 4ad24b00fe199b4c5bc1f74227a3bea0242d497e..73f3d91f7d7e92fb4ade8ca1ae1dedfe58d69c2d 100755 --- a/tutorials/basic/laplacianFoam/multiWorld/Allrun +++ b/tutorials/basic/laplacianFoam/multiWorld1/Allrun @@ -5,25 +5,19 @@ cd "${0%/*}" || exit # Run from this directory # Run serial ./Allrun.pre -mpirun -app ./mpirun_left_right.schema +echo "Begin run" +mpirun -app ./mpirun_worlds.schema # Run with database -mv -f log.run_left* log.run_right* - -for subcase in left right -do -( - cd "$subcase" || exit - foamListTimes -rm - restore0Dir - foamDictionary 0/T -entry boundaryField.coupled.sampleDatabase -add true -) -done - -mpirun -app ./mpirun_left_right.schema +./Allrun.addDatabase +mv -f log.run_* 2>/dev/null +echo "Begin run with database" +mpirun -app ./mpirun_worlds.schema ## Run parallel ## ./Allrun.pre-parallel ## mpirun -app ./mpirun.schema +echo "End" + #------------------------------------------------------------------------------ diff --git a/tutorials/basic/laplacianFoam/multiWorld1/Allrun.addDatabase b/tutorials/basic/laplacianFoam/multiWorld1/Allrun.addDatabase new file mode 100755 index 0000000000000000000000000000000000000000..17ba9cf53dd20b4ea3c0869d68264598e4a78855 --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld1/Allrun.addDatabase @@ -0,0 +1,30 @@ +#!/bin/sh +cd "${0%/*}" || exit # Run from this directory +. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions +#------------------------------------------------------------------------------ + +# Running with database +for subcase in $(./list-worlds) +do +( + cd "$subcase" || exit + foamListTimes -rm + restore0Dir + + dictFile="0/T" + + for patch in $(foamDictionary "$dictFile" -keywords -entry boundaryField) + do + patchType="$(foamDictionary "$dictFile" -value -entry boundaryField/"$patch"/type)" + + case "$patchType" in + (mapped*) + foamDictionary "$dictFile" -entry boundaryField/"$patch"/sampleDatabase -add true >/dev/null + echo "Use sampleDatabase: $subcase/$dictFile patch=$patch" + ;; + esac + done +) +done + +#------------------------------------------------------------------------------ diff --git a/tutorials/basic/laplacianFoam/multiWorld/Allrun.pre b/tutorials/basic/laplacianFoam/multiWorld1/Allrun.pre similarity index 68% rename from tutorials/basic/laplacianFoam/multiWorld/Allrun.pre rename to tutorials/basic/laplacianFoam/multiWorld1/Allrun.pre index 61541f6f5f6e7bcc684ee947c77322044fc39c64..05ad890d2a6d4e7967743b186d96ffe6c630ccd9 100755 --- a/tutorials/basic/laplacianFoam/multiWorld/Allrun.pre +++ b/tutorials/basic/laplacianFoam/multiWorld1/Allrun.pre @@ -4,11 +4,19 @@ cd "${0%/*}" || exit # Run from this directory #------------------------------------------------------------------------------ # Create meshes and initial fields -for subcase in left right +for subcase in $(./list-worlds) do ( cd "$subcase" || exit - runApplication blockMesh && restore0Dir + echo "case=$subcase" + if [ -x ./Allrun.pre ] + then + ./Allrun.pre + else + runApplication blockMesh + fi + restore0Dir + echo ) done diff --git a/tutorials/basic/laplacianFoam/multiWorld/Allrun.pre-parallel b/tutorials/basic/laplacianFoam/multiWorld1/Allrun.pre-parallel similarity index 93% rename from tutorials/basic/laplacianFoam/multiWorld/Allrun.pre-parallel rename to tutorials/basic/laplacianFoam/multiWorld1/Allrun.pre-parallel index d6227536a020652e3382016073612cc4e213154c..ded773acc3820fd3151a33a491cfe26b9106c4fc 100755 --- a/tutorials/basic/laplacianFoam/multiWorld/Allrun.pre-parallel +++ b/tutorials/basic/laplacianFoam/multiWorld1/Allrun.pre-parallel @@ -4,7 +4,7 @@ cd "${0%/*}" || exit # Run from this directory #------------------------------------------------------------------------------ # Create meshes and initial fields -for subcase in left right +for subcase in $(./list-worlds) do ( cd "$subcase" || exit diff --git a/tutorials/basic/laplacianFoam/multiWorld/left/constant/transportProperties b/tutorials/basic/laplacianFoam/multiWorld1/common/constant/transportProperties similarity index 100% rename from tutorials/basic/laplacianFoam/multiWorld/left/constant/transportProperties rename to tutorials/basic/laplacianFoam/multiWorld1/common/constant/transportProperties diff --git a/tutorials/basic/laplacianFoam/multiWorld/common/system/controlDict b/tutorials/basic/laplacianFoam/multiWorld1/common/system/controlDict similarity index 100% rename from tutorials/basic/laplacianFoam/multiWorld/common/system/controlDict rename to tutorials/basic/laplacianFoam/multiWorld1/common/system/controlDict diff --git a/tutorials/basic/laplacianFoam/multiWorld/common/system/decomposeParDict b/tutorials/basic/laplacianFoam/multiWorld1/common/system/decomposeParDict similarity index 100% rename from tutorials/basic/laplacianFoam/multiWorld/common/system/decomposeParDict rename to tutorials/basic/laplacianFoam/multiWorld1/common/system/decomposeParDict diff --git a/tutorials/basic/laplacianFoam/multiWorld/common/system/fvSchemes b/tutorials/basic/laplacianFoam/multiWorld1/common/system/fvSchemes similarity index 100% rename from tutorials/basic/laplacianFoam/multiWorld/common/system/fvSchemes rename to tutorials/basic/laplacianFoam/multiWorld1/common/system/fvSchemes diff --git a/tutorials/basic/laplacianFoam/multiWorld/common/system/fvSolution b/tutorials/basic/laplacianFoam/multiWorld1/common/system/fvSolution similarity index 100% rename from tutorials/basic/laplacianFoam/multiWorld/common/system/fvSolution rename to tutorials/basic/laplacianFoam/multiWorld1/common/system/fvSolution diff --git a/tutorials/basic/laplacianFoam/multiWorld/left/0.orig/T b/tutorials/basic/laplacianFoam/multiWorld1/left/0.orig/T similarity index 98% rename from tutorials/basic/laplacianFoam/multiWorld/left/0.orig/T rename to tutorials/basic/laplacianFoam/multiWorld1/left/0.orig/T index f94e100bd8d579cc3db4888d3b7dd973783bc11b..ea1ba37ff224a34ba1775102ae30361edbf6211d 100644 --- a/tutorials/basic/laplacianFoam/multiWorld/left/0.orig/T +++ b/tutorials/basic/laplacianFoam/multiWorld1/left/0.orig/T @@ -29,7 +29,7 @@ boundaryField sampleMode nearestPatchFaceAMI; // Simulation world to sample - sampleWorld RIGHT; + sampleWorld right; // Region to sample sampleRegion region0; diff --git a/tutorials/basic/laplacianFoam/multiWorld1/left/constant/transportProperties b/tutorials/basic/laplacianFoam/multiWorld1/left/constant/transportProperties new file mode 120000 index 0000000000000000000000000000000000000000..e6a4e4f7fc53f2c83e8fcde854665db55f6466d2 --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld1/left/constant/transportProperties @@ -0,0 +1 @@ +../../common/constant/transportProperties \ No newline at end of file diff --git a/tutorials/basic/laplacianFoam/multiWorld/left/system/blockMeshDict b/tutorials/basic/laplacianFoam/multiWorld1/left/system/blockMeshDict similarity index 100% rename from tutorials/basic/laplacianFoam/multiWorld/left/system/blockMeshDict rename to tutorials/basic/laplacianFoam/multiWorld1/left/system/blockMeshDict diff --git a/applications/test/multiWorld/left/system/controlDict b/tutorials/basic/laplacianFoam/multiWorld1/left/system/controlDict similarity index 100% rename from applications/test/multiWorld/left/system/controlDict rename to tutorials/basic/laplacianFoam/multiWorld1/left/system/controlDict diff --git a/applications/test/multiWorld/left/system/decomposeParDict b/tutorials/basic/laplacianFoam/multiWorld1/left/system/decomposeParDict similarity index 100% rename from applications/test/multiWorld/left/system/decomposeParDict rename to tutorials/basic/laplacianFoam/multiWorld1/left/system/decomposeParDict diff --git a/applications/test/multiWorld/left/system/fvSchemes b/tutorials/basic/laplacianFoam/multiWorld1/left/system/fvSchemes similarity index 100% rename from applications/test/multiWorld/left/system/fvSchemes rename to tutorials/basic/laplacianFoam/multiWorld1/left/system/fvSchemes diff --git a/applications/test/multiWorld/left/system/fvSolution b/tutorials/basic/laplacianFoam/multiWorld1/left/system/fvSolution similarity index 100% rename from applications/test/multiWorld/left/system/fvSolution rename to tutorials/basic/laplacianFoam/multiWorld1/left/system/fvSolution diff --git a/tutorials/basic/laplacianFoam/multiWorld1/list-worlds b/tutorials/basic/laplacianFoam/multiWorld1/list-worlds new file mode 100755 index 0000000000000000000000000000000000000000..536d4dfe2ef5903e0c48c3702bf574a04d3b92e9 --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld1/list-worlds @@ -0,0 +1,6 @@ +#!/bin/sh +#------------------------------------------------------------------------------ + +echo left right + +#------------------------------------------------------------------------------ diff --git a/tutorials/basic/laplacianFoam/multiWorld1/mpirun.schema b/tutorials/basic/laplacianFoam/multiWorld1/mpirun.schema new file mode 100644 index 0000000000000000000000000000000000000000..e0ec9b4140139a6cd798e7cb78f7442836a35552 --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld1/mpirun.schema @@ -0,0 +1,2 @@ +-np 2 laplacianFoam -case left -world left -parallel +-np 2 laplacianFoam -case right -world right -parallel diff --git a/tutorials/basic/laplacianFoam/multiWorld/mpirun_left_right.schema b/tutorials/basic/laplacianFoam/multiWorld1/mpirun_worlds.schema similarity index 100% rename from tutorials/basic/laplacianFoam/multiWorld/mpirun_left_right.schema rename to tutorials/basic/laplacianFoam/multiWorld1/mpirun_worlds.schema diff --git a/tutorials/basic/laplacianFoam/multiWorld/right/0.orig/T b/tutorials/basic/laplacianFoam/multiWorld1/right/0.orig/T similarity index 98% rename from tutorials/basic/laplacianFoam/multiWorld/right/0.orig/T rename to tutorials/basic/laplacianFoam/multiWorld1/right/0.orig/T index b98bee77b2913ac8207f12251471ae408604403a..b9521e967aad1cc689aba8b960bc7177afe940c1 100644 --- a/tutorials/basic/laplacianFoam/multiWorld/right/0.orig/T +++ b/tutorials/basic/laplacianFoam/multiWorld1/right/0.orig/T @@ -29,7 +29,7 @@ boundaryField sampleMode nearestPatchFaceAMI; // Simulation world to sample - sampleWorld LEFT; + sampleWorld left; // Region to sample sampleRegion region0; diff --git a/tutorials/basic/laplacianFoam/multiWorld1/right/constant/transportProperties b/tutorials/basic/laplacianFoam/multiWorld1/right/constant/transportProperties new file mode 120000 index 0000000000000000000000000000000000000000..e6a4e4f7fc53f2c83e8fcde854665db55f6466d2 --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld1/right/constant/transportProperties @@ -0,0 +1 @@ +../../common/constant/transportProperties \ No newline at end of file diff --git a/tutorials/basic/laplacianFoam/multiWorld/right/system/blockMeshDict b/tutorials/basic/laplacianFoam/multiWorld1/right/system/blockMeshDict similarity index 100% rename from tutorials/basic/laplacianFoam/multiWorld/right/system/blockMeshDict rename to tutorials/basic/laplacianFoam/multiWorld1/right/system/blockMeshDict diff --git a/applications/test/multiWorld/right/system/controlDict b/tutorials/basic/laplacianFoam/multiWorld1/right/system/controlDict similarity index 100% rename from applications/test/multiWorld/right/system/controlDict rename to tutorials/basic/laplacianFoam/multiWorld1/right/system/controlDict diff --git a/applications/test/multiWorld/right/system/decomposeParDict b/tutorials/basic/laplacianFoam/multiWorld1/right/system/decomposeParDict similarity index 100% rename from applications/test/multiWorld/right/system/decomposeParDict rename to tutorials/basic/laplacianFoam/multiWorld1/right/system/decomposeParDict diff --git a/applications/test/multiWorld/right/system/fvSchemes b/tutorials/basic/laplacianFoam/multiWorld1/right/system/fvSchemes similarity index 100% rename from applications/test/multiWorld/right/system/fvSchemes rename to tutorials/basic/laplacianFoam/multiWorld1/right/system/fvSchemes diff --git a/applications/test/multiWorld/right/system/fvSolution b/tutorials/basic/laplacianFoam/multiWorld1/right/system/fvSolution similarity index 100% rename from applications/test/multiWorld/right/system/fvSolution rename to tutorials/basic/laplacianFoam/multiWorld1/right/system/fvSolution diff --git a/applications/test/multiWorld/run_world.sh b/tutorials/basic/laplacianFoam/multiWorld1/run_world.sh similarity index 71% rename from applications/test/multiWorld/run_world.sh rename to tutorials/basic/laplacianFoam/multiWorld1/run_world.sh index 2f2ac9f9761e1fd7355b1407fea35a838fc214b8..5e574ef4e261b83998709944cb44e2caa0b48089 100755 --- a/applications/test/multiWorld/run_world.sh +++ b/tutorials/basic/laplacianFoam/multiWorld1/run_world.sh @@ -15,9 +15,11 @@ then fi worldCase="$(echo "$world" | tr '[:upper:]' '[:lower:]')" -worldName="$(echo "$world" | tr '[:lower:]' '[:upper:]')" +# worldName="$(echo "$world" | tr '[:lower:]' '[:upper:]')" +worldName="$worldCase" -"$application" -case "$worldCase" -world "$worldName" 2>&1 | tee log.run_"$worldCase" -read dummy +log="log.run_$worldCase" + +"$application" -case "$worldCase" -world "$worldName" > "$log" 2>&1 # ---------------------------------------------------------------------------- diff --git a/tutorials/basic/laplacianFoam/multiWorld/Allclean b/tutorials/basic/laplacianFoam/multiWorld2/Allclean similarity index 71% rename from tutorials/basic/laplacianFoam/multiWorld/Allclean rename to tutorials/basic/laplacianFoam/multiWorld2/Allclean index d9d9ef5636ac7f1d370da7542466843621e63711..4512a2f0dccbc1477353dbf99d1bda82139549aa 100755 --- a/tutorials/basic/laplacianFoam/multiWorld/Allclean +++ b/tutorials/basic/laplacianFoam/multiWorld2/Allclean @@ -3,12 +3,14 @@ cd "${0%/*}" || exit # Run from this directory . ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions #------------------------------------------------------------------------------ -for subcase in left right +for subcase in $(./list-worlds) do ( - cd "$subcase" && cleanCase0 + cd "$subcase" || exit + cleanCase0 + rm -f *_mapped.obj 2>/dev/null ) done -rm -f log.* +rm -rf log.* 2>/dev/null #------------------------------------------------------------------------------ diff --git a/applications/test/multiWorld/Allrun b/tutorials/basic/laplacianFoam/multiWorld2/Allrun similarity index 52% rename from applications/test/multiWorld/Allrun rename to tutorials/basic/laplacianFoam/multiWorld2/Allrun index a5604a34e680744d2c77cb8c1f5cf603a758ea41..cc3093f244fceee0436878d3b7fe5144ef506dab 100755 --- a/applications/test/multiWorld/Allrun +++ b/tutorials/basic/laplacianFoam/multiWorld2/Allrun @@ -5,15 +5,19 @@ cd "${0%/*}" || exit # Run from this directory # Run serial ./Allrun.pre -mpirun -app ./mpirun_left_right.schema +echo "Begin run - interworld communication" +mpirun -app ./mpirun_full.schema -## Run parallel -# ./Allrun.pre-parallel -#(cd left && runApplication blockMesh) -#(cd left && runApplication decomposePar) -#(cd right && runApplication blockMesh) -#(cd right && runApplication decomposePar) -# -#mpirun -app ./mpirun.schema +# Run with database +if false +then + ./Allrun.addDatabase + rm -f log.run* 2>/dev/null + echo "Begin run - database data exchange" + mpirun -app ./mpirun_full.schema +fi + +echo "Can load with: paraview --script=load-worlds.py &" +echo "End" #------------------------------------------------------------------------------ diff --git a/tutorials/basic/laplacianFoam/multiWorld2/Allrun.addDatabase b/tutorials/basic/laplacianFoam/multiWorld2/Allrun.addDatabase new file mode 100755 index 0000000000000000000000000000000000000000..5b5b26469e6b71c50bb8ea33c478f12b16bacf08 --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/Allrun.addDatabase @@ -0,0 +1,30 @@ +#!/bin/sh +cd "${0%/*}" || exit # Run from this directory +. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions +#------------------------------------------------------------------------------ + +# Prepare for running with database +for subcase in $(./list-worlds) +do +( + cd "$subcase" || exit + foamListTimes -rm + restore0Dir + + dictFile="0/T" + + for patch in $(foamDictionary "$dictFile" -keywords -entry boundaryField) + do + patchType="$(foamDictionary "$dictFile" -value -entry boundaryField/"$patch"/type)" + + case "$patchType" in + (mapped*) + foamDictionary "$dictFile" -entry boundaryField/"$patch"/sampleDatabase -add true >/dev/null + echo "Use sampleDatabase: $subcase/$dictFile patch=$patch" + ;; + esac + done +) +done + +#------------------------------------------------------------------------------ diff --git a/applications/test/multiWorld/Allrun.pre-parallel b/tutorials/basic/laplacianFoam/multiWorld2/Allrun.pre similarity index 58% rename from applications/test/multiWorld/Allrun.pre-parallel rename to tutorials/basic/laplacianFoam/multiWorld2/Allrun.pre index eaad67c68b6d7ea8f2840281d1c2f78c22545a45..928c9e254283c63362d90aaf99f9562b578a7b12 100755 --- a/applications/test/multiWorld/Allrun.pre-parallel +++ b/tutorials/basic/laplacianFoam/multiWorld2/Allrun.pre @@ -3,12 +3,21 @@ cd "${0%/*}" || exit # Run from this directory . ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions #------------------------------------------------------------------------------ -# Create meshes -for subcase in left right +# Create meshes and initial fields +for subcase in $(./list-worlds) do ( cd "$subcase" || exit - runApplication blockMesh + echo "case=$subcase" + if [ -x ./Allrun.pre ] + then + ./Allrun.pre + else + runApplication blockMesh + fi + restore0Dir + touch "$subcase.foam" # paraview + echo ) done diff --git a/applications/test/multiWorld/left/constant/transportProperties b/tutorials/basic/laplacianFoam/multiWorld2/common/constant/transportProperties similarity index 92% rename from applications/test/multiWorld/left/constant/transportProperties rename to tutorials/basic/laplacianFoam/multiWorld2/common/constant/transportProperties index 5bb8a0784a5314f9e91470b8a1fc154f2546ea63..fb641eeeb3a2d644d8c349d81d6eaf43516f2e73 100644 --- a/applications/test/multiWorld/left/constant/transportProperties +++ b/tutorials/basic/laplacianFoam/multiWorld2/common/constant/transportProperties @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: v2106 | +| \\ / O peration | Version: v2112 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/applications/test/multiWorld/common/system/controlDict b/tutorials/basic/laplacianFoam/multiWorld2/common/system/controlDict similarity index 94% rename from applications/test/multiWorld/common/system/controlDict rename to tutorials/basic/laplacianFoam/multiWorld2/common/system/controlDict index aff336cb41b469990066660c788dca0cb7a6fe7a..7ee2771851a04636fe1313241e73fd89bf593dab 100644 --- a/applications/test/multiWorld/common/system/controlDict +++ b/tutorials/basic/laplacianFoam/multiWorld2/common/system/controlDict @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: v2106 | +| \\ / O peration | Version: v2112 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ @@ -19,9 +19,9 @@ libs (utilityFunctionObjects); DebugSwitches { + multiWorld 1; // mappedPatchBase 1; -// syncObjects 1; - +// syncObjects 2; } diff --git a/applications/test/multiWorld/common/system/decomposeParDict b/tutorials/basic/laplacianFoam/multiWorld2/common/system/decomposeParDict similarity index 100% rename from applications/test/multiWorld/common/system/decomposeParDict rename to tutorials/basic/laplacianFoam/multiWorld2/common/system/decomposeParDict diff --git a/applications/test/multiWorld/common/system/fvSchemes b/tutorials/basic/laplacianFoam/multiWorld2/common/system/fvSchemes similarity index 95% rename from applications/test/multiWorld/common/system/fvSchemes rename to tutorials/basic/laplacianFoam/multiWorld2/common/system/fvSchemes index 6e67d123db9c73e348e3e5113f4007800cead2ee..028412c048bc60930f515133d664e80d877458a6 100644 --- a/applications/test/multiWorld/common/system/fvSchemes +++ b/tutorials/basic/laplacianFoam/multiWorld2/common/system/fvSchemes @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: v2106 | +| \\ / O peration | Version: v2112 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/applications/test/multiWorld/common/system/fvSolution b/tutorials/basic/laplacianFoam/multiWorld2/common/system/fvSolution similarity index 93% rename from applications/test/multiWorld/common/system/fvSolution rename to tutorials/basic/laplacianFoam/multiWorld2/common/system/fvSolution index 737bf06d151fea540892b46abdd3adafc68d40d7..a7c94ca0baf966142adfbe3283a2d22ad68bb866 100644 --- a/applications/test/multiWorld/common/system/fvSolution +++ b/tutorials/basic/laplacianFoam/multiWorld2/common/system/fvSolution @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: v2106 | +| \\ / O peration | Version: v2112 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/basic/laplacianFoam/multiWorld2/list-worlds b/tutorials/basic/laplacianFoam/multiWorld2/list-worlds new file mode 100755 index 0000000000000000000000000000000000000000..0ca989fc697bf3436bf060c26a909bfb7bfeb54f --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/list-worlds @@ -0,0 +1,6 @@ +#!/bin/sh +#------------------------------------------------------------------------------ + +echo top slab1 slab2 slab3 slab4 + +#------------------------------------------------------------------------------ diff --git a/tutorials/basic/laplacianFoam/multiWorld2/load-worlds.py b/tutorials/basic/laplacianFoam/multiWorld2/load-worlds.py new file mode 100644 index 0000000000000000000000000000000000000000..ff80ba41b8938e8ace95e434977e5a8b21143614 --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/load-worlds.py @@ -0,0 +1,67 @@ +#### import the simple module from the paraview +from paraview.simple import * +#### disable automatic camera reset on 'Show' +paraview.simple._DisableFirstRenderCameraReset() + +# get active view +renderView1 = GetActiveViewOrCreate('RenderView') + +useGroup = True +pieces = [] + +# Load all pieces +for worldName in ['top', 'slab1', 'slab2', 'slab3', 'slab4']: + # Could also touch world/world.foam into existence + loadedDir = './' + worldName + '/' + worldName + '.foam' + piece = OpenFOAMReader(registrationName=worldName, FileName=loadedDir) + piece.SkipZeroTime = 0 + piece.Decomposepolyhedra = 0 + piece.MeshRegions = ['internalMesh'] + piece.CellArrays = ['T'] + pieces.append(piece) + +# Set display for all pieces +for piece in pieces: + display = Show(piece, renderView1, 'UnstructuredGridRepresentation') + display.SetRepresentationType('Surface With Edges') + ColorBy(display, ('CELLS', 'T')) + # Show color bar/color legend + display.SetScalarBarVisibility(renderView1, True) + +# ---- +# Group pieces +if useGroup: + # Hide data in view + group1 = GroupDatasets(registrationName='GroupDatasets1', Input=pieces) + + # show data in view + display = Show(group1, renderView1, 'UnstructuredGridRepresentation') + + display.SetRepresentationType('Surface With Edges') + ColorBy(display, ('CELLS', 'T')) + # Show color bar/color legend + display.SetScalarBarVisibility(renderView1, True) + + for piece in pieces: + Hide(piece, renderView1) + +# ---- +# get color transfer function/color map for 'T' +tLUT = GetColorTransferFunction('T') + +# Rescale transfer function +tLUT.RescaleTransferFunction(0.0, 1.2) + +# get opacity transfer function/opacity map for 'T' +tPWF = GetOpacityTransferFunction('T') + +# Rescale transfer function +tPWF.RescaleTransferFunction(0.0, 1.2) + +# reset view to fit data +renderView1.ResetCamera(False) + +# update the view to ensure updated data information +renderView1.Update() + +#================================================================ diff --git a/tutorials/basic/laplacianFoam/multiWorld2/mpirun_full.schema b/tutorials/basic/laplacianFoam/multiWorld2/mpirun_full.schema new file mode 100644 index 0000000000000000000000000000000000000000..f2af1722c0c1a00430de480699e27624fb3e6b3a --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/mpirun_full.schema @@ -0,0 +1,5 @@ +-np 1 ./run_world.sh top +-np 1 ./run_world.sh slab1 +-np 1 ./run_world.sh slab2 +-np 1 ./run_world.sh slab3 +-np 1 ./run_world.sh slab4 diff --git a/tutorials/basic/laplacianFoam/multiWorld/run_world.sh b/tutorials/basic/laplacianFoam/multiWorld2/run_world.sh similarity index 58% rename from tutorials/basic/laplacianFoam/multiWorld/run_world.sh rename to tutorials/basic/laplacianFoam/multiWorld2/run_world.sh index 2f2ac9f9761e1fd7355b1407fea35a838fc214b8..8fe4a93df596c44affadd69a5ac67cc2be97f9a2 100755 --- a/tutorials/basic/laplacianFoam/multiWorld/run_world.sh +++ b/tutorials/basic/laplacianFoam/multiWorld2/run_world.sh @@ -2,12 +2,6 @@ world="${1:?specify world/case}" application="${2:-laplacianFoam}" -# case "$application" in -# (-test) -# application="Test-multiWorld1" -# ;; -# esac - if [ -z "$application" ] || ! command -v "$application" > /dev/null then echo "No application: $application" @@ -15,9 +9,11 @@ then fi worldCase="$(echo "$world" | tr '[:upper:]' '[:lower:]')" -worldName="$(echo "$world" | tr '[:lower:]' '[:upper:]')" +# worldName="$(echo "$world" | tr '[:lower:]' '[:upper:]')" +worldName="$worldCase" + +log="log.run_$worldCase" -"$application" -case "$worldCase" -world "$worldName" 2>&1 | tee log.run_"$worldCase" -read dummy +"$application" -case "$worldCase" -world "$worldName" > "$log" 2>&1 # ---------------------------------------------------------------------------- diff --git a/tutorials/basic/laplacianFoam/multiWorld2/slab1/0.orig/T b/tutorials/basic/laplacianFoam/multiWorld2/slab1/0.orig/T new file mode 100644 index 0000000000000000000000000000000000000000..5cf8ed43c2aa5e8207a2a7b879aa04308fd8fcfe --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/slab1/0.orig/T @@ -0,0 +1,87 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2112 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 0; + +_mappedMixedField +{ + type mappedMixedField; + + // What/how to sample: + sampleMode nearestPatchFaceAMI; + + // Simulation world to sample + // Overwrite -> sampleWorld top; + + // Region to sample + sampleRegion region0; + + // If sampleMode is nearestPatchFace : patch to find faces of + // Overwrite -> samplePatch right_to_left; + + // Use database to get data from (one-way or loose coupling in + // combination with functionObject) + //sampleDatabase false; //true; + + // According to offsetMode (see above) supply one of + // offset, offsets or distance + offset (0 0 0); + + value uniform 0.0; + + // For mappedMixed + //weightField DTV; + refValue $value; + refGradient uniform 0.0; + valueFraction uniform 1.0; +} + +boundaryField +{ + slab1_to_2 + { + $_mappedMixedField; + sampleWorld slab2; + samplePatch slab2_to_1; + } + + left + { + type fixedValue; + value uniform 1; + } + + to_top + { + $_mappedMixedField; + sampleWorld top; + samplePatch top_to_1; + } + + bottom + { + type zeroGradient; + } + + frontAndBack + { + type empty; + } +} + +// ************************************************************************* // diff --git a/tutorials/basic/laplacianFoam/multiWorld2/slab1/constant/transportProperties b/tutorials/basic/laplacianFoam/multiWorld2/slab1/constant/transportProperties new file mode 120000 index 0000000000000000000000000000000000000000..e6a4e4f7fc53f2c83e8fcde854665db55f6466d2 --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/slab1/constant/transportProperties @@ -0,0 +1 @@ +../../common/constant/transportProperties \ No newline at end of file diff --git a/tutorials/basic/laplacianFoam/multiWorld2/slab1/system/blockMeshDict b/tutorials/basic/laplacianFoam/multiWorld2/slab1/system/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..8ee7c1603ad534e32b92060f168de9baa9536ec0 --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/slab1/system/blockMeshDict @@ -0,0 +1,84 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2112 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +SLAB_OFFSET 0; + +scale 0.1; + +transform +{ + origin (#eval{0.5 * $SLAB_OFFSET} 0 0); + rotation none; +} + +xdim 0.5; +ydim 1; +zdim 0.1; + +vertices +( + (0 0 0) + ($xdim 0 0) + ($xdim $ydim 0) + (0 $ydim 0) + + (0 0 $zdim) + ($xdim 0 $zdim) + ($xdim $ydim $zdim) + (0 $ydim $zdim) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (2 2 1) grading (1 1 1) +); + + +boundary +( + left // left-side (face 0) + { + type wall; + faces ((0 0)); + } + + slab1_to_2 // right-side (face 1) + { + type wall; + faces ((0 1)); + } + + bottom // face 2 + { + type wall; + faces ((0 2)); + } + + to_top // top: face 3 + { + type wall; + faces ((0 3)); + } + + frontAndBack // face 4 5 + { + type empty; + faces ((0 4) (0 5)); + } +); + + +// ************************************************************************* // diff --git a/tutorials/basic/laplacianFoam/multiWorld/left/system/controlDict b/tutorials/basic/laplacianFoam/multiWorld2/slab1/system/controlDict similarity index 100% rename from tutorials/basic/laplacianFoam/multiWorld/left/system/controlDict rename to tutorials/basic/laplacianFoam/multiWorld2/slab1/system/controlDict diff --git a/tutorials/basic/laplacianFoam/multiWorld/left/system/decomposeParDict b/tutorials/basic/laplacianFoam/multiWorld2/slab1/system/decomposeParDict similarity index 100% rename from tutorials/basic/laplacianFoam/multiWorld/left/system/decomposeParDict rename to tutorials/basic/laplacianFoam/multiWorld2/slab1/system/decomposeParDict diff --git a/tutorials/basic/laplacianFoam/multiWorld/left/system/fvSchemes b/tutorials/basic/laplacianFoam/multiWorld2/slab1/system/fvSchemes similarity index 100% rename from tutorials/basic/laplacianFoam/multiWorld/left/system/fvSchemes rename to tutorials/basic/laplacianFoam/multiWorld2/slab1/system/fvSchemes diff --git a/tutorials/basic/laplacianFoam/multiWorld/left/system/fvSolution b/tutorials/basic/laplacianFoam/multiWorld2/slab1/system/fvSolution similarity index 100% rename from tutorials/basic/laplacianFoam/multiWorld/left/system/fvSolution rename to tutorials/basic/laplacianFoam/multiWorld2/slab1/system/fvSolution diff --git a/tutorials/basic/laplacianFoam/multiWorld2/slab2/0.orig/T b/tutorials/basic/laplacianFoam/multiWorld2/slab2/0.orig/T new file mode 100644 index 0000000000000000000000000000000000000000..c2cf629f7dba637d8509c84faf87c5c310fb83d1 --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/slab2/0.orig/T @@ -0,0 +1,94 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2112 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 0; + +_mappedMixedField +{ + type mappedMixedField; + + // What/how to sample: + sampleMode nearestPatchFaceAMI; + + // Simulation world to sample + // Overwrite -> sampleWorld top; + + // Region to sample + sampleRegion region0; + + // If sampleMode is nearestPatchFace : patch to find faces of + // Overwrite -> samplePatch right_to_left; + + // Use database to get data from (one-way or loose coupling in + // combination with functionObject) + //sampleDatabase false; //true; + + // According to offsetMode (see above) supply one of + // offset, offsets or distance + offset (0 0 0); + + value uniform 0.0; + + // For mappedMixed + //weightField DTV; + refValue $value; + refGradient uniform 0.0; + valueFraction uniform 1.0; +} + +boundaryField +{ + slab2_to_1 + { + $_mappedMixedField; + sampleWorld slab1; + samplePatch slab1_to_2; + } + + slab2_to_3 + { + $_mappedMixedField; + sampleWorld slab3; + samplePatch slab3_to_2; + } + + to_top + { + $_mappedMixedField; + sampleWorld top; + samplePatch top_to_2; + } + + bottom + { + type zeroGradient; + } + + right + { + type fixedValue; + value uniform 0; + } + + frontAndBack + { + type empty; + } +} + +// ************************************************************************* // diff --git a/tutorials/basic/laplacianFoam/multiWorld2/slab2/constant/transportProperties b/tutorials/basic/laplacianFoam/multiWorld2/slab2/constant/transportProperties new file mode 120000 index 0000000000000000000000000000000000000000..e6a4e4f7fc53f2c83e8fcde854665db55f6466d2 --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/slab2/constant/transportProperties @@ -0,0 +1 @@ +../../common/constant/transportProperties \ No newline at end of file diff --git a/applications/test/multiWorld/right/system/blockMeshDict b/tutorials/basic/laplacianFoam/multiWorld2/slab2/system/blockMeshDict similarity index 51% rename from applications/test/multiWorld/right/system/blockMeshDict rename to tutorials/basic/laplacianFoam/multiWorld2/slab2/system/blockMeshDict index e2833174626dfe1e8a10ee71c5c6742608750616..c482516dbfe58c63b31b94cccdddba2f29150a54 100644 --- a/applications/test/multiWorld/right/system/blockMeshDict +++ b/tutorials/basic/laplacianFoam/multiWorld2/slab2/system/blockMeshDict @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: v2106 | +| \\ / O peration | Version: v2112 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ @@ -14,76 +14,70 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +SLAB_OFFSET 1; + scale 0.1; +transform +{ + origin (#eval{0.5 * $SLAB_OFFSET} 0 0); + rotation none; +} + +xdim 0.5; +ydim 1; +zdim 0.1; + vertices ( - (0.5 0 0) - (1 0 0) - (1 1 0) - (0.5 1 0) - (0.5 0 0.1) - (1 0 0.1) - (1 1 0.1) - (0.5 1 0.1) -); + (0 0 0) + ($xdim 0 0) + ($xdim $ydim 0) + (0 $ydim 0) -blocks -( - hex (0 1 2 3 4 5 6 7) (2 2 1) simpleGrading (1 1 1) + (0 0 $zdim) + ($xdim 0 $zdim) + ($xdim $ydim $zdim) + (0 $ydim $zdim) ); -edges +blocks ( + hex (0 1 2 3 4 5 6 7) (2 2 1) grading (1 1 1) ); boundary ( - coupled + slab2_to_1 // left-side (face 0) { - type wall; - faces - ( - (0 4 7 3) - ); + type wall; + faces ((0 0)); } - top + + slab2_to_3 // right-side (face 1) { - type wall; - faces - ( - (3 7 6 2) - ); + type wall; + faces ((0 1)); } - bottom + + bottom // face 2 { - type wall; - faces - ( - (1 5 4 0) - ); + type wall; + faces ((0 2)); } - right + + to_top // top: face 3 { - type wall; - faces - ( - (2 6 5 1) - ); + type wall; + faces ((0 3)); } - frontAndBack + + frontAndBack // face 4 5 { - type empty; - faces - ( - (0 3 2 1) - (4 5 6 7) - ); + type empty; + faces ((0 4) (0 5)); } ); -mergePatchPairs -( -); // ************************************************************************* // diff --git a/tutorials/basic/laplacianFoam/multiWorld/right/system/controlDict b/tutorials/basic/laplacianFoam/multiWorld2/slab2/system/controlDict similarity index 100% rename from tutorials/basic/laplacianFoam/multiWorld/right/system/controlDict rename to tutorials/basic/laplacianFoam/multiWorld2/slab2/system/controlDict diff --git a/tutorials/basic/laplacianFoam/multiWorld/right/system/decomposeParDict b/tutorials/basic/laplacianFoam/multiWorld2/slab2/system/decomposeParDict similarity index 100% rename from tutorials/basic/laplacianFoam/multiWorld/right/system/decomposeParDict rename to tutorials/basic/laplacianFoam/multiWorld2/slab2/system/decomposeParDict diff --git a/tutorials/basic/laplacianFoam/multiWorld/right/system/fvSchemes b/tutorials/basic/laplacianFoam/multiWorld2/slab2/system/fvSchemes similarity index 100% rename from tutorials/basic/laplacianFoam/multiWorld/right/system/fvSchemes rename to tutorials/basic/laplacianFoam/multiWorld2/slab2/system/fvSchemes diff --git a/tutorials/basic/laplacianFoam/multiWorld/right/system/fvSolution b/tutorials/basic/laplacianFoam/multiWorld2/slab2/system/fvSolution similarity index 100% rename from tutorials/basic/laplacianFoam/multiWorld/right/system/fvSolution rename to tutorials/basic/laplacianFoam/multiWorld2/slab2/system/fvSolution diff --git a/tutorials/basic/laplacianFoam/multiWorld2/slab3/0.orig/T b/tutorials/basic/laplacianFoam/multiWorld2/slab3/0.orig/T new file mode 100644 index 0000000000000000000000000000000000000000..23bd2a6fbfa113372302884cfc34231f0c280b7c --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/slab3/0.orig/T @@ -0,0 +1,88 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2112 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 0; + +_mappedMixedField +{ + type mappedMixedField; + + // What/how to sample: + sampleMode nearestPatchFaceAMI; + + // Simulation world to sample + // Overwrite -> sampleWorld top; + + // Region to sample + sampleRegion region0; + + // If sampleMode is nearestPatchFace : patch to find faces of + // Overwrite -> samplePatch right_to_left; + + // Use database to get data from (one-way or loose coupling in + // combination with functionObject) + //sampleDatabase false; //true; + + // According to offsetMode (see above) supply one of + // offset, offsets or distance + offset (0 0 0); + + value uniform 0.0; + + // For mappedMixed + //weightField DTV; + refValue $value; + refGradient uniform 0.0; + valueFraction uniform 1.0; +} + +boundaryField +{ + slab3_to_2 + { + $_mappedMixedField; + sampleWorld slab2; + samplePatch slab2_to_3; + } + + slab3_to_4 + { + $_mappedMixedField; + sampleWorld slab4; + samplePatch slab4_to_3; + } + + to_top + { + $_mappedMixedField; + sampleWorld top; + samplePatch top_to_3; + } + + bottom + { + type zeroGradient; + } + + frontAndBack + { + type empty; + } +} + +// ************************************************************************* // diff --git a/tutorials/basic/laplacianFoam/multiWorld2/slab3/constant/transportProperties b/tutorials/basic/laplacianFoam/multiWorld2/slab3/constant/transportProperties new file mode 120000 index 0000000000000000000000000000000000000000..e6a4e4f7fc53f2c83e8fcde854665db55f6466d2 --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/slab3/constant/transportProperties @@ -0,0 +1 @@ +../../common/constant/transportProperties \ No newline at end of file diff --git a/tutorials/basic/laplacianFoam/multiWorld2/slab3/system/blockMeshDict b/tutorials/basic/laplacianFoam/multiWorld2/slab3/system/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..afb6537de04720a5654fe278b7b87adef745df7e --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/slab3/system/blockMeshDict @@ -0,0 +1,83 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2112 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +SLAB_OFFSET 2; + +scale 0.1; + +transform +{ + origin (#eval{0.5 * $SLAB_OFFSET} 0 0); + rotation none; +} + +xdim 0.5; +ydim 1; +zdim 0.1; + +vertices +( + (0 0 0) + ($xdim 0 0) + ($xdim $ydim 0) + (0 $ydim 0) + + (0 0 $zdim) + ($xdim 0 $zdim) + ($xdim $ydim $zdim) + (0 $ydim $zdim) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (2 2 1) grading (1 1 1) +); + +boundary +( + slab3_to_2 // left-side (face 0) + { + type wall; + faces ((0 0)); + } + + slab3_to_4 // right-side (face 1) + { + type wall; + faces ((0 1)); + } + + bottom // face 2 + { + type wall; + faces ((0 2)); + } + + to_top // top: face 3 + { + type wall; + faces ((0 3)); + } + + frontAndBack // face 4 5 + { + type empty; + faces ((0 4) (0 5)); + } +); + + +// ************************************************************************* // diff --git a/tutorials/basic/laplacianFoam/multiWorld2/slab3/system/controlDict b/tutorials/basic/laplacianFoam/multiWorld2/slab3/system/controlDict new file mode 120000 index 0000000000000000000000000000000000000000..e38bfb1f6b29ad74081447310151d1d7cb723d8c --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/slab3/system/controlDict @@ -0,0 +1 @@ +../../common/system/controlDict \ No newline at end of file diff --git a/tutorials/basic/laplacianFoam/multiWorld2/slab3/system/decomposeParDict b/tutorials/basic/laplacianFoam/multiWorld2/slab3/system/decomposeParDict new file mode 120000 index 0000000000000000000000000000000000000000..9276e7939a3791b19a21ab0f390795f8b35de238 --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/slab3/system/decomposeParDict @@ -0,0 +1 @@ +../../common/system/decomposeParDict \ No newline at end of file diff --git a/tutorials/basic/laplacianFoam/multiWorld2/slab3/system/fvSchemes b/tutorials/basic/laplacianFoam/multiWorld2/slab3/system/fvSchemes new file mode 120000 index 0000000000000000000000000000000000000000..274d17e172845cf7de4dddb3e6ed0a5464d437af --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/slab3/system/fvSchemes @@ -0,0 +1 @@ +../../common/system/fvSchemes \ No newline at end of file diff --git a/tutorials/basic/laplacianFoam/multiWorld2/slab3/system/fvSolution b/tutorials/basic/laplacianFoam/multiWorld2/slab3/system/fvSolution new file mode 120000 index 0000000000000000000000000000000000000000..504f0b1c9e2057fe941ed5718c4be80647f41b98 --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/slab3/system/fvSolution @@ -0,0 +1 @@ +../../common/system/fvSolution \ No newline at end of file diff --git a/tutorials/basic/laplacianFoam/multiWorld2/slab4/0.orig/T b/tutorials/basic/laplacianFoam/multiWorld2/slab4/0.orig/T new file mode 100644 index 0000000000000000000000000000000000000000..e22efdd6aab245573c39c5f2d13b3b61eb9ef417 --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/slab4/0.orig/T @@ -0,0 +1,87 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2112 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 0; + +_mappedMixedField +{ + type mappedMixedField; + + // What/how to sample: + sampleMode nearestPatchFaceAMI; + + // Simulation world to sample + // Overwrite -> sampleWorld top; + + // Region to sample + sampleRegion region0; + + // If sampleMode is nearestPatchFace : patch to find faces of + // Overwrite -> samplePatch right_to_left; + + // Use database to get data from (one-way or loose coupling in + // combination with functionObject) + //sampleDatabase false; //true; + + // According to offsetMode (see above) supply one of + // offset, offsets or distance + offset (0 0 0); + + value uniform 0.0; + + // For mappedMixed + //weightField DTV; + refValue $value; + refGradient uniform 0.0; + valueFraction uniform 1.0; +} + +boundaryField +{ + slab4_to_3 + { + $_mappedMixedField; + sampleWorld slab3; + samplePatch slab3_to_4; + } + + right + { + type fixedValue; + value uniform 0; + } + + to_top + { + $_mappedMixedField; + sampleWorld top; + samplePatch top_to_4; + } + + bottom + { + type zeroGradient; + } + + frontAndBack + { + type empty; + } +} + +// ************************************************************************* // diff --git a/tutorials/basic/laplacianFoam/multiWorld2/slab4/constant/transportProperties b/tutorials/basic/laplacianFoam/multiWorld2/slab4/constant/transportProperties new file mode 120000 index 0000000000000000000000000000000000000000..e6a4e4f7fc53f2c83e8fcde854665db55f6466d2 --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/slab4/constant/transportProperties @@ -0,0 +1 @@ +../../common/constant/transportProperties \ No newline at end of file diff --git a/tutorials/basic/laplacianFoam/multiWorld2/slab4/system/blockMeshDict b/tutorials/basic/laplacianFoam/multiWorld2/slab4/system/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..493d29f16479d3495cc47a42d4c83b7e9dfee6b0 --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/slab4/system/blockMeshDict @@ -0,0 +1,83 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2112 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +SLAB_OFFSET 3; + +scale 0.1; + +transform +{ + origin (#eval{0.5 * $SLAB_OFFSET} 0 0); + rotation none; +} + +xdim 0.5; +ydim 1; +zdim 0.1; + +vertices +( + (0 0 0) + ($xdim 0 0) + ($xdim $ydim 0) + (0 $ydim 0) + + (0 0 $zdim) + ($xdim 0 $zdim) + ($xdim $ydim $zdim) + (0 $ydim $zdim) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (2 2 1) grading (1 1 1) +); + +boundary +( + slab4_to_3 // left-side (face 0) + { + type wall; + faces ((0 0)); + } + + right // right-side (face 1) + { + type wall; + faces ((0 1)); + } + + bottom // face 2 + { + type wall; + faces ((0 2)); + } + + to_top // top: face 3 + { + type wall; + faces ((0 3)); + } + + frontAndBack // face 4 5 + { + type empty; + faces ((0 4) (0 5)); + } +); + + +// ************************************************************************* // diff --git a/tutorials/basic/laplacianFoam/multiWorld2/slab4/system/controlDict b/tutorials/basic/laplacianFoam/multiWorld2/slab4/system/controlDict new file mode 120000 index 0000000000000000000000000000000000000000..e38bfb1f6b29ad74081447310151d1d7cb723d8c --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/slab4/system/controlDict @@ -0,0 +1 @@ +../../common/system/controlDict \ No newline at end of file diff --git a/tutorials/basic/laplacianFoam/multiWorld2/slab4/system/decomposeParDict b/tutorials/basic/laplacianFoam/multiWorld2/slab4/system/decomposeParDict new file mode 120000 index 0000000000000000000000000000000000000000..9276e7939a3791b19a21ab0f390795f8b35de238 --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/slab4/system/decomposeParDict @@ -0,0 +1 @@ +../../common/system/decomposeParDict \ No newline at end of file diff --git a/tutorials/basic/laplacianFoam/multiWorld2/slab4/system/fvSchemes b/tutorials/basic/laplacianFoam/multiWorld2/slab4/system/fvSchemes new file mode 120000 index 0000000000000000000000000000000000000000..274d17e172845cf7de4dddb3e6ed0a5464d437af --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/slab4/system/fvSchemes @@ -0,0 +1 @@ +../../common/system/fvSchemes \ No newline at end of file diff --git a/tutorials/basic/laplacianFoam/multiWorld2/slab4/system/fvSolution b/tutorials/basic/laplacianFoam/multiWorld2/slab4/system/fvSolution new file mode 120000 index 0000000000000000000000000000000000000000..504f0b1c9e2057fe941ed5718c4be80647f41b98 --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/slab4/system/fvSolution @@ -0,0 +1 @@ +../../common/system/fvSolution \ No newline at end of file diff --git a/tutorials/basic/laplacianFoam/multiWorld2/top/0.orig/T b/tutorials/basic/laplacianFoam/multiWorld2/top/0.orig/T new file mode 100644 index 0000000000000000000000000000000000000000..d480b95498e6971196d301eee7549b88240b79b8 --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/top/0.orig/T @@ -0,0 +1,109 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2112 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 0; + +_mappedMixedField +{ + type mappedMixedField; + + // What/how to sample: + sampleMode nearestPatchFaceAMI; + + // Simulation world to sample + // Overwrite -> sampleWorld slabN; + + // Region to sample + sampleRegion region0; + + // If sampleMode is nearestPatchFace : patch to find faces of + samplePatch to_top; + + // Use database to get data from (one-way or loose coupling in + // combination with functionObject) + //sampleDatabase false; //true; + + // According to offsetMode (see above) supply one of + // offset, offsets or distance + offset (0 0 0); + + value uniform 0.0; + + // For mappedMixed + //weightField DTV; + refValue $value; + refGradient uniform 0.0; + valueFraction uniform 1.0; +} + + +boundaryField +{ + top_to_1 + { + $_mappedMixedField; + sampleWorld slab1; + } + + top_to_2 + { + $_mappedMixedField; + sampleWorld slab2; + } + + top_to_3 + { + $_mappedMixedField; + sampleWorld slab3; + } + + top_to_4 + { + $_mappedMixedField; + sampleWorld slab4; + } + + top + { + type zeroGradient; + } + + interface + { + type zeroGradient; + } + + left + { + type fixedValue; + value uniform 1.2; + } + + right + { + type fixedValue; + value uniform 0.2; + } + + frontAndBack + { + type empty; + } +} + +// ************************************************************************* // diff --git a/applications/test/multiWorld/Allrun.pre b/tutorials/basic/laplacianFoam/multiWorld2/top/Allrun.pre similarity index 72% rename from applications/test/multiWorld/Allrun.pre rename to tutorials/basic/laplacianFoam/multiWorld2/top/Allrun.pre index eaad67c68b6d7ea8f2840281d1c2f78c22545a45..1863e020ca34f866b1850cd44e4d0ee63fe694b0 100755 --- a/applications/test/multiWorld/Allrun.pre +++ b/tutorials/basic/laplacianFoam/multiWorld2/top/Allrun.pre @@ -4,12 +4,10 @@ cd "${0%/*}" || exit # Run from this directory #------------------------------------------------------------------------------ # Create meshes -for subcase in left right -do -( - cd "$subcase" || exit - runApplication blockMesh -) -done +runApplication blockMesh + +runApplication -s patches topoSet -dict system/topoSetDict.patches + +runApplication createPatch -overwrite #------------------------------------------------------------------------------ diff --git a/tutorials/basic/laplacianFoam/multiWorld2/top/constant/transportProperties b/tutorials/basic/laplacianFoam/multiWorld2/top/constant/transportProperties new file mode 120000 index 0000000000000000000000000000000000000000..e6a4e4f7fc53f2c83e8fcde854665db55f6466d2 --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/top/constant/transportProperties @@ -0,0 +1 @@ +../../common/constant/transportProperties \ No newline at end of file diff --git a/applications/test/multiWorld/left/system/blockMeshDict b/tutorials/basic/laplacianFoam/multiWorld2/top/system/blockMeshDict similarity index 55% rename from applications/test/multiWorld/left/system/blockMeshDict rename to tutorials/basic/laplacianFoam/multiWorld2/top/system/blockMeshDict index eb3f42e5735d5049237c7557eea9c560fb57674e..1fed71bacc98b96a6988875dc5838a61efd74023 100644 --- a/applications/test/multiWorld/left/system/blockMeshDict +++ b/tutorials/basic/laplacianFoam/multiWorld2/top/system/blockMeshDict @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: v2106 | +| \\ / O peration | Version: v2112 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ @@ -13,78 +13,75 @@ FoamFile object blockMeshDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// TOP + +NSLABS 4; scale 0.1; +transform +{ + origin (0 1 0); + rotation none; +} + +xdim #eval{0.5 * $NSLABS}; +ydim 0.2; +zdim 0.1; + +nx #eval #{ round(5 * $NSLABS) #}; + vertices ( - (0 0 0) - (0.5 0 0) - (0.5 1 0) - (0 1 0) - (0 0 0.1) - (0.5 0 0.1) - (0.5 1 0.1) - (0 1 0.1) + (0 0 0) + ($xdim 0 0) + ($xdim $ydim 0) + (0 $ydim 0) + + (0 0 $zdim) + ($xdim 0 $zdim) + ($xdim $ydim $zdim) + (0 $ydim $zdim) ); blocks ( - hex (0 1 2 3 4 5 6 7) (2 2 1) simpleGrading (1 1 1) + hex (0 1 2 3 4 5 6 7) ($nx 2 1) grading (1 1 1) ); -edges -( -); boundary ( - coupled + left { - type wall; - faces - ( - (2 6 5 1) - ); + type wall; + faces ((0 0)); } - top + right { - type wall; - faces - ( - (3 7 6 2) - ); + type wall; + faces ((0 1)); } - bottom + + interface // inter-world connections { - type wall; - faces - ( - (1 5 4 0) - ); + type wall; + faces ((0 2)); } - left + + top { - type wall; - faces - ( - (0 4 7 3) - ); + type wall; + faces ((0 3)); } + frontAndBack { - type empty; - faces - ( - (0 3 2 1) - (4 5 6 7) - ); + type empty; + faces ((0 4) (0 5)); } ); -mergePatchPairs -( -); // ************************************************************************* // diff --git a/tutorials/basic/laplacianFoam/multiWorld2/top/system/controlDict b/tutorials/basic/laplacianFoam/multiWorld2/top/system/controlDict new file mode 120000 index 0000000000000000000000000000000000000000..e38bfb1f6b29ad74081447310151d1d7cb723d8c --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/top/system/controlDict @@ -0,0 +1 @@ +../../common/system/controlDict \ No newline at end of file diff --git a/tutorials/basic/laplacianFoam/multiWorld2/top/system/createPatchDict b/tutorials/basic/laplacianFoam/multiWorld2/top/system/createPatchDict new file mode 100644 index 0000000000000000000000000000000000000000..9d333f1df2ddf31cc66e633df9318f88190f529d --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/top/system/createPatchDict @@ -0,0 +1,55 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2112 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object createPatchDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +pointSync false; + +_fromSet +{ + patchInfo { type patch; } + constructFrom set; +} + + +// Patches to create +patches +( + { + name top_to_1; + set top_to_1; + $_fromSet; + } + + { + name top_to_2; + set top_to_2; + $_fromSet; + } + + { + name top_to_3; + set top_to_3; + $_fromSet; + } + + { + name top_to_4; + set top_to_4; + $_fromSet; + } +); + + +// ************************************************************************* // diff --git a/tutorials/basic/laplacianFoam/multiWorld2/top/system/decomposeParDict b/tutorials/basic/laplacianFoam/multiWorld2/top/system/decomposeParDict new file mode 120000 index 0000000000000000000000000000000000000000..9276e7939a3791b19a21ab0f390795f8b35de238 --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/top/system/decomposeParDict @@ -0,0 +1 @@ +../../common/system/decomposeParDict \ No newline at end of file diff --git a/tutorials/basic/laplacianFoam/multiWorld2/top/system/fvSchemes b/tutorials/basic/laplacianFoam/multiWorld2/top/system/fvSchemes new file mode 120000 index 0000000000000000000000000000000000000000..274d17e172845cf7de4dddb3e6ed0a5464d437af --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/top/system/fvSchemes @@ -0,0 +1 @@ +../../common/system/fvSchemes \ No newline at end of file diff --git a/tutorials/basic/laplacianFoam/multiWorld2/top/system/fvSolution b/tutorials/basic/laplacianFoam/multiWorld2/top/system/fvSolution new file mode 120000 index 0000000000000000000000000000000000000000..504f0b1c9e2057fe941ed5718c4be80647f41b98 --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/top/system/fvSolution @@ -0,0 +1 @@ +../../common/system/fvSolution \ No newline at end of file diff --git a/tutorials/basic/laplacianFoam/multiWorld2/top/system/topoSetDict.patches b/tutorials/basic/laplacianFoam/multiWorld2/top/system/topoSetDict.patches new file mode 100644 index 0000000000000000000000000000000000000000..2249d242f8436e8aca041ee1e3bc6f3cd3672bb2 --- /dev/null +++ b/tutorials/basic/laplacianFoam/multiWorld2/top/system/topoSetDict.patches @@ -0,0 +1,71 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2112 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object topoSetDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +_newFromPatch +{ + type faceSet; + action new; + source patchToFace; + patch interface; +} + +_subsetBox +{ + type faceSet; + action subset; + source boxToFace; + min (0 0 -1); + span (0.05 2 2); +} + + +actions +( + // slab 1 (offset 0) + { name top_to_1; $_newFromPatch } + { + name top_to_1; + $_subsetBox; + min (0 0 -1); + } + + // slab 2 (offset 1) + { name top_to_2; $_newFromPatch } + { + name top_to_2; + $_subsetBox; + min (0.05 0 -1); + } + + // slab 3 (offset 2) + { name top_to_3; $_newFromPatch } + { + name top_to_3; + $_subsetBox; + min (0.10 0 -1); + } + + // slab 4 (offset 3) + { name top_to_4; $_newFromPatch } + { + name top_to_4; + $_subsetBox; + min (0.15 0 -1); + } +); + + +// ************************************************************************* //