diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/solid/createSolidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/solid/createSolidFields.H index 3361a89add..8f109a3f82 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/solid/createSolidFields.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/solid/createSolidFields.H @@ -1,7 +1,6 @@ // Initialise solid field pointer lists PtrList rhos(solidRegions.size()); PtrList cps(solidRegions.size()); - PtrList rhosCps(solidRegions.size()); PtrList Ks(solidRegions.size()); PtrList Ts(solidRegions.size()); @@ -47,12 +46,6 @@ ) ); - rhosCps.set - ( - i, - new volScalarField("rhosCps", rhos[i]*cps[i]) - ); - Info<< " Adding to Ks\n" << endl; Ks.set ( diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/createSolidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/createSolidFields.H index 3361a89add..8f109a3f82 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/createSolidFields.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/createSolidFields.H @@ -1,7 +1,6 @@ // Initialise solid field pointer lists PtrList rhos(solidRegions.size()); PtrList cps(solidRegions.size()); - PtrList rhosCps(solidRegions.size()); PtrList Ks(solidRegions.size()); PtrList Ts(solidRegions.size()); @@ -47,12 +46,6 @@ ) ); - rhosCps.set - ( - i, - new volScalarField("rhosCps", rhos[i]*cps[i]) - ); - Info<< " Adding to Ks\n" << endl; Ks.set ( diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffusionNo.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffusionNo.H index c2e5668a68..4b09671de2 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffusionNo.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffusionNo.H @@ -8,7 +8,7 @@ ( solidRegions[regionI], runTime, - rhosCps[regionI], + rhos[regionI]*cps[regionI], Ks[regionI] ), DiNum diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict index 957010dc10..788b154a6e 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict @@ -143,11 +143,19 @@ castellatedMeshControls } } - // Optional angle to detect small-large cell situation perpendicular - // to the surface. Is the angle of face w.r.t the local surface - // normal. Use on flat(ish) surfaces only. Otherwise - // leave out or set to negative number. + //- Optional angle to detect small-large cell situation + // perpendicular to the surface. Is the angle of face w.r.t. + // the local surface normal. Use on flat(ish) surfaces only. + // Otherwise leave out or set to negative number. //perpendicularAngle 10; + + + //- Optional faceZone and (for closed surface) cellZone with + // how to select the cells that are in the cellZone + // (inside / outside / specified insidePoint) + //faceZone sphere; + //cellZone sphere; + //cellZoneInside inside; //outside/insidePoint } } diff --git a/applications/utilities/mesh/manipulation/setSet/setSet.C b/applications/utilities/mesh/manipulation/setSet/setSet.C index 54ff169f16..308319f2e6 100644 --- a/applications/utilities/mesh/manipulation/setSet/setSet.C +++ b/applications/utilities/mesh/manipulation/setSet/setSet.C @@ -439,6 +439,7 @@ bool doCommand const word& actionName, const bool writeVTKFile, const bool writeCurrentTime, + const bool noSync, Istream& is ) { @@ -581,7 +582,7 @@ bool doCommand // Set will have been modified. // Synchronize for coupled patches. - currentSet.sync(mesh); + if (!noSync) currentSet.sync(mesh); // Write if (writeVTKFile) @@ -834,6 +835,11 @@ int main(int argc, char *argv[]) "file", "process in batch mode, using input from specified file" ); + argList::addBoolOption + ( + "noSync", + "do not synchronise selection across coupled patches" + ); # include "setRootCase.H" # include "createTime.H" @@ -842,6 +848,7 @@ int main(int argc, char *argv[]) const bool writeVTK = !args.optionFound("noVTK"); const bool loop = args.optionFound("loop"); const bool batch = args.optionFound("batch"); + const bool noSync = args.optionFound("noSync"); if (loop && !batch) { @@ -1008,7 +1015,8 @@ int main(int argc, char *argv[]) setName, actionName, writeVTK, - loop, // if in looping mode dump sets to time directory + loop, // if in looping mode dump sets to time directory + noSync, is ); diff --git a/applications/utilities/mesh/manipulation/topoSet/topoSet.C b/applications/utilities/mesh/manipulation/topoSet/topoSet.C index d794ae342d..6f1c9957e4 100644 --- a/applications/utilities/mesh/manipulation/topoSet/topoSet.C +++ b/applications/utilities/mesh/manipulation/topoSet/topoSet.C @@ -49,11 +49,18 @@ int main(int argc, char *argv[]) "specify an alternative dictionary for the topoSet dictionary" ); # include "addRegionOption.H" + argList::addBoolOption + ( + "noSync", + "do not synchronise selection across coupled patches" + ); # include "setRootCase.H" # include "createTime.H" # include "createNamedPolyMesh.H" + const bool noSync = args.optionFound("noSync"); + const word dictName("topoSetDict"); fileName dictPath = dictName; @@ -140,6 +147,23 @@ int main(int argc, char *argv[]) case topoSetSource::NEW: case topoSetSource::ADD: case topoSetSource::DELETE: + { + Info<< " Applying source " << word(dict.lookup("source")) + << endl; + autoPtr source = topoSetSource::New + ( + dict.lookup("source"), + mesh, + dict.subDict("sourceInfo") + ); + + source().applyToSet(action, currentSet()); + // Synchronize for coupled patches. + if (!noSync) currentSet().sync(mesh); + currentSet().write(); + } + break; + case topoSetSource::SUBSET: { Info<< " Applying source " << word(dict.lookup("source")) @@ -148,12 +172,28 @@ int main(int argc, char *argv[]) ( dict.lookup("source"), mesh, - dict.subDict("sourceDict") + dict.subDict("sourceInfo") ); - source().applyToSet(action, currentSet()); + // Backup current set. + autoPtr oldSet + ( + topoSet::New + ( + setType, + mesh, + currentSet().name() + "_old2", + currentSet() + ) + ); + + currentSet().clear(); + source().applyToSet(topoSetSource::NEW, currentSet()); + + // Combine new value of currentSet with old one. + currentSet().subset(oldSet()); // Synchronize for coupled patches. - currentSet().sync(mesh); + if (!noSync) currentSet().sync(mesh); currentSet().write(); } break; diff --git a/applications/utilities/mesh/manipulation/topoSet/topoSetDict b/applications/utilities/mesh/manipulation/topoSet/topoSetDict index ff487c6e64..40afc5ecb9 100644 --- a/applications/utilities/mesh/manipulation/topoSet/topoSetDict +++ b/applications/utilities/mesh/manipulation/topoSet/topoSetDict @@ -301,31 +301,61 @@ FoamFile actions ( + // Example:pick up internal faces on outside of cellSet + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + // Load initial cellSet { name c0; type cellSet; action new; source labelToCell; - sourceDict + sourceInfo { value (12 13 56); } } + // Get all faces in cellSet { - name c0; + name f0; + type faceSet; + action new; + source cellToFace; + sourceInfo + { + set c0; + option all; + } + } + + // Determine inverse cellSet + { + name c1; + type cellSet; + action new; + source cellToCell; + sourceInfo + { + set c0; + } + } + { + name c1; type cellSet; action invert; } + // Keep in f0 all faces in c1 { - name c0; - type cellSet; - action delete; - source labelToCell; - sourceDict + name f0; + type faceSet; + action subset; + source cellToFace; + sourceInfo { - value (1 2 3); + set c1; + option all; } } ); diff --git a/applications/utilities/surface/surfaceInertia/surfaceInertia.C b/applications/utilities/surface/surfaceInertia/surfaceInertia.C index 0819c4bbb6..c68608feda 100644 --- a/applications/utilities/surface/surfaceInertia/surfaceInertia.C +++ b/applications/utilities/surface/surfaceInertia/surfaceInertia.C @@ -591,18 +591,27 @@ int main(int argc, char *argv[]) if (showTransform) { - Info<< "Transform tensor from reference state (Q). " << nl + Info<< "Transform tensor from reference state (orientation):" << nl + << eVec.T() << nl << "Rotation tensor required to transform " "from the body reference frame to the global " "reference frame, i.e.:" << nl - << "globalVector = Q & bodyLocalVector" - << nl << eVec.T() + << "globalVector = orientation & bodyLocalVector" + << endl; + + Info<< nl + << "Entries for sixDoFRigidBodyDisplacement boundary condition:" + << nl + << " mass " << m << token::END_STATEMENT << nl + << " centreOfMass " << cM << token::END_STATEMENT << nl + << " momentOfInertia " << eVal << token::END_STATEMENT << nl + << " orientation " << eVec.T() << token::END_STATEMENT << endl; } if (calcAroundRefPt) { - Info << "Inertia tensor relative to " << refPt << ": " + Info<< nl << "Inertia tensor relative to " << refPt << ": " << nl << applyParallelAxisTheorem(m, cM, J, refPt) << endl; } diff --git a/src/OpenFOAM/interpolations/interpolateSplineXY/interpolateSplineXY.C b/src/OpenFOAM/interpolations/interpolateSplineXY/interpolateSplineXY.C new file mode 100644 index 0000000000..2fa74142cd --- /dev/null +++ b/src/OpenFOAM/interpolations/interpolateSplineXY/interpolateSplineXY.C @@ -0,0 +1,126 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "interpolateSplineXY.H" +#include "primitiveFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template +Foam::Field Foam::interpolateSplineXY +( + const scalarField& xNew, + const scalarField& xOld, + const Field& yOld +) +{ + Field yNew(xNew.size()); + + forAll(xNew, i) + { + yNew[i] = interpolateSmoothXY(xNew[i], xOld, yOld); + } + + return yNew; +} + + +template +Type Foam::interpolateSplineXY +( + const scalar x, + const scalarField& xOld, + const Field& yOld +) +{ + label n = xOld.size(); + + // early exit if out of bounds or only one value + if (n == 1 || x < xOld[0]) + { + return yOld[0]; + } + if (x > xOld[n - 1]) + { + return yOld[n - 1]; + } + + // linear interpolation if only two values + if (n == 2) + { + return (x - xOld[0])/(xOld[1] - xOld[0])*(yOld[1] - yOld[0]) + yOld[0]; + } + + // find bounding knots + label hi = 0; + while (hi < n && xOld[hi] < x) + { + hi++; + } + + label lo = hi - 1; + + const Type& y1 = yOld[lo]; + const Type& y2 = yOld[hi]; + + Type y0; + if (lo == 0) + { + y0 = 2*y1 - y2; + } + else + { + y0 = yOld[lo - 1]; + } + + Type y3; + if (hi + 1 == n) + { + y3 = 2*y2 - y1; + } + else + { + y3 = yOld[hi + 1]; + } + + // weighting + scalar mu = (x - xOld[lo])/(xOld[hi] - xOld[lo]); + + // interpolate + return + 0.5 + *( + 2*y1 + + mu + *( + -y0 + y2 + + mu*((2*y0 - 5*y1 + 4*y2 - y3) + mu*(-y0 + 3*y1 - 3*y2 + y3)) + ) + ); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/interpolations/interpolateSplineXY/interpolateSplineXY.H b/src/OpenFOAM/interpolations/interpolateSplineXY/interpolateSplineXY.H new file mode 100644 index 0000000000..7d06169ea8 --- /dev/null +++ b/src/OpenFOAM/interpolations/interpolateSplineXY/interpolateSplineXY.H @@ -0,0 +1,84 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +InNamespace + Foam + +Description + Interpolates y values from one curve to another with a different x + distribution. + + Uses Catmull-Rom spline interpolation between points. + +SourceFiles + interpolateSplineXY.C + +\*---------------------------------------------------------------------------*/ + +#ifndef interpolateSplineXY_H +#define interpolateSplineXY_H + +#include "scalar.H" +#include "primitiveFieldsFwd.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template +Field interpolateSplineXY +( + const scalarField& xNew, + const scalarField& xOld, + const Field& yOld +); + + +template +Type interpolateSplineXY +( + const scalar x, + const scalarField& xOld, + const Field& yOld +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "interpolateSplineXY.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/interpolations/interpolateXY/interpolateXY.C b/src/OpenFOAM/interpolations/interpolateXY/interpolateXY.C index 5c45e33bd3..45cff57a7a 100644 --- a/src/OpenFOAM/interpolations/interpolateXY/interpolateXY.C +++ b/src/OpenFOAM/interpolations/interpolateXY/interpolateXY.C @@ -41,7 +41,7 @@ Field interpolateXY const Field& yOld ) { - scalarField yNew(xNew.size()); + Field yNew(xNew.size()); forAll(xNew, i) { diff --git a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/tabulated6DoFMotion/tabulated6DoFMotion.C b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/tabulated6DoFMotion/tabulated6DoFMotion.C index b4d6bf06d2..38ef552948 100644 --- a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/tabulated6DoFMotion/tabulated6DoFMotion.C +++ b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/tabulated6DoFMotion/tabulated6DoFMotion.C @@ -27,7 +27,7 @@ License #include "addToRunTimeSelectionTable.H" #include "Tuple2.H" #include "IFstream.H" -#include "interpolateXY.H" +#include "interpolateSplineXY.H" #include "mathematicalConstants.H" using namespace Foam::constant::mathematical; @@ -98,7 +98,7 @@ Foam::solidBodyMotionFunctions::tabulated6DoFMotion::transformation() const << exit(FatalError); } - translationRotationVectors TRV = interpolateXY + translationRotationVectors TRV = interpolateSplineXY ( t, times_, diff --git a/src/dynamicMesh/motionSmoother/motionSmoother.C b/src/dynamicMesh/motionSmoother/motionSmoother.C index 1f94c7582a..5c3d79a978 100644 --- a/src/dynamicMesh/motionSmoother/motionSmoother.C +++ b/src/dynamicMesh/motionSmoother/motionSmoother.C @@ -774,7 +774,8 @@ Foam::tmp Foam::motionSmoother::movePoints newPoints, minEqOp(), // combine op vector(GREAT,GREAT,GREAT), // null - true // separation + true, // separation + 1E-6*mesh_.bounds().mag() ); } @@ -925,7 +926,8 @@ bool Foam::motionSmoother::scaleMesh totalDisplacement, maxMagEqOp(), vector::zero, // null value - false // separation + false, // separation + 1E-6*mesh_.bounds().mag() ); } diff --git a/src/dynamicMesh/motionSmoother/motionSmoother.H b/src/dynamicMesh/motionSmoother/motionSmoother.H index f5df37e677..ee306dd3c9 100644 --- a/src/dynamicMesh/motionSmoother/motionSmoother.H +++ b/src/dynamicMesh/motionSmoother/motionSmoother.H @@ -208,7 +208,8 @@ class motionSmoother const Field&, const CombineOp& cop, const Type& zero, - const bool separation + const bool separation, + const scalar maxMag ) const; //- Assemble tensors for multi-patch constraints diff --git a/src/dynamicMesh/motionSmoother/motionSmootherTemplates.C b/src/dynamicMesh/motionSmoother/motionSmootherTemplates.C index aec66f951f..1660a29e18 100644 --- a/src/dynamicMesh/motionSmoother/motionSmootherTemplates.C +++ b/src/dynamicMesh/motionSmoother/motionSmootherTemplates.C @@ -292,7 +292,8 @@ void Foam::motionSmoother::testSyncField const Field& fld, const CombineOp& cop, const Type& zero, - const bool separation + const bool separation, + const scalar maxMag ) const { if (debug) @@ -315,6 +316,7 @@ void Foam::motionSmoother::testSyncField forAll(syncedFld, i) { if (syncedFld[i] != fld[i]) + if (mag(syncedFld[i] - fld[i]) > maxMag) { FatalErrorIn ( diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 0fc8dbf70c..2d1b6effb0 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -150,6 +150,7 @@ $(derivedFvPatchFields)/turbulentIntensityKineticEnergyInlet/turbulentIntensityK $(derivedFvPatchFields)/uniformFixedValue/uniformFixedValueFvPatchFields.C $(derivedFvPatchFields)/waveTransmissive/waveTransmissiveFvPatchFields.C $(derivedFvPatchFields)/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.C +$(derivedFvPatchFields)/swirlMassFlowRateInletVelocity/swirlMassFlowRateInletVelocityFvPatchVectorField.C fvsPatchFields = fields/fvsPatchFields $(fvsPatchFields)/fvsPatchField/fvsPatchFields.C diff --git a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/TimeActivatedExplicitSource.C b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/TimeActivatedExplicitSource.C index b8fbe54a89..f5a768c4a8 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/TimeActivatedExplicitSource.C +++ b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/TimeActivatedExplicitSource.C @@ -33,7 +33,7 @@ template const Foam::wordList Foam::TimeActivatedExplicitSource:: selectionModeTypeNames_ ( - IStringStream("(points cellSet)")() + IStringStream("(points cellSet cellZone all)")() ); @@ -156,6 +156,15 @@ void Foam::TimeActivatedExplicitSource::setSelection dict.lookup("cellSet") >> cellSetName_; break; } + case smCellZone: + { + dict.lookup("cellZone") >> cellSetName_; + break; + } + case smAll: + { + break; + } default: { FatalErrorIn @@ -221,13 +230,14 @@ void Foam::TimeActivatedExplicitSource::setCellSet() { Info<< indent << "- selecting cells using points" << endl; - labelHashSet cellOwners; + labelHashSet selectedCells; + forAll(points_, i) { label cellI = mesh_.findCell(points_[i]); if (cellI >= 0) { - cellOwners.insert(cellI); + selectedCells.insert(cellI); } label globalCellI = returnReduce(cellI, maxOp