diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/createSolidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/createSolidFields.H index 2cc60f7b9b0655e26c23bef010c214687bbc5793..3f31f302b9727fdcbbb9cb323d7d849dba2a3fbf 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/createSolidFields.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/createSolidFields.H @@ -31,7 +31,12 @@ coordinates.set ( i, - coordinateSystem::New(solidRegions[i], thermos[i]) + coordinateSystem::New + ( + solidRegions[i], + thermos[i], + "coordinateSystem" + ) ); tmp<volVectorField> tkappaByCp = diff --git a/applications/test/coordinateSystem/Test-coordinateSystem.C b/applications/test/coordinateSystem/Test-coordinateSystem.C index 3f68919a520079264ae8052af3c3a9adefd9f4e4..736111c2e952bfe3df9e756cb6f1ddc4c4a4af87 100644 --- a/applications/test/coordinateSystem/Test-coordinateSystem.C +++ b/applications/test/coordinateSystem/Test-coordinateSystem.C @@ -30,12 +30,47 @@ Description \*---------------------------------------------------------------------------*/ #include "argList.H" -#include "coordinateSystem.H" +#include "Time.H" +#include "coordinateSystems.H" +#include "identityRotation.H" +#include "indirectCS.H" #include "Fstream.H" #include "IOstreams.H" using namespace Foam; +void basicTests(const coordinateSystem& cs) +{ + cs.writeEntry(cs.name(), Info); + + if (isA<indirectCS>(cs)) + { + Info<< "indirect from:" << nl; + dynamicCast<const indirectCS>(cs).cs().writeEntry(cs.name(), Info); + } + + + Info<< "rotation: " << cs.R().R() << nl; + + for + ( + const point& pt : + { + point{1,0,0}, + point{0,1,0}, + point{0,0,1}, + point{1,1,1}, + } + ) + { + Info<< " test point: " << pt + << " = local " << cs.localPosition(pt) << nl; + } + + Info<< nl; +} + + void doTest(const dictionary& dict) { Info<< dict.dictName() << dict << nl; @@ -43,18 +78,42 @@ void doTest(const dictionary& dict) // Could fail? const bool throwingIOError = FatalIOError.throwExceptions(); const bool throwingError = FatalError.throwExceptions(); + try { - coordinateSystem cs1(dict.dictName(), dict); + auto cs1ptr = coordinateSystem::New(dict, ""); + coordinateSystem& cs1 = *cs1ptr; + cs1.rename(dict.dictName()); - coordinateSystem cs2; + basicTests(cs1); + } + catch (Foam::IOerror& err) + { + Info<< "Caught FatalIOError " << err << nl << endl; + } + catch (Foam::error& err) + { + Info<< "Caught FatalError " << err << nl << endl; + } + FatalError.throwExceptions(throwingError); + FatalIOError.throwExceptions(throwingIOError); +} - // Move assign - cs2 = std::move(cs1); - // Info<<cs2 << nl; - cs2.writeDict(Info, true); - Info<< nl; +void doTest(const objectRegistry& obr, const dictionary& dict) +{ + Info<< dict.dictName() << dict << nl; + + // Could fail? + const bool throwingIOError = FatalIOError.throwExceptions(); + const bool throwingError = FatalError.throwExceptions(); + + try + { + auto cs1ptr = coordinateSystem::New(obr, dict, word::null); + coordinateSystem& cs1 = *cs1ptr; + + basicTests(cs1); } catch (Foam::IOerror& err) { @@ -78,7 +137,38 @@ int main(int argc, char *argv[]) argList::addArgument("dict .. dictN"); argList args(argc, argv, false, true); - if (args.size() <= 1) + if (args.found("case")) + { + Info<<"using case for tests" << nl; + + #include "createTime.H" + + const coordinateSystems& systems = coordinateSystems::New(runTime); + + Info<<"global systems: " << systems.size() << nl; + + for (const coordinateSystem& cs : systems) + { + basicTests(cs); + } + + for (label argi=1; argi < args.size(); ++argi) + { + const string& dictFile = args[argi]; + IFstream is(dictFile); + + dictionary inputDict(is); + + forAllConstIters(inputDict, iter) + { + if (iter().isDict()) + { + doTest(runTime, iter().dict()); + } + } + } + } + else if (args.size() <= 1) { Info<<"no coordinateSystem dictionaries to expand" << nl; } diff --git a/applications/test/coordinateSystem/testCase/constant/coordinateSystems b/applications/test/coordinateSystem/testCase/constant/coordinateSystems new file mode 100644 index 0000000000000000000000000000000000000000..ca113a73d20786a0cb5b14e892cc8e62b3d9c13e --- /dev/null +++ b/applications/test/coordinateSystem/testCase/constant/coordinateSystems @@ -0,0 +1,85 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1806 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class IOPtrList<coordinateSystem>; + object cooordinateSystems; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +( +cs1 +{ + type cartesian; + origin (1 2 3); + coordinateRotation + { + type axes; + e1 (0 0 1); + e2 (0 1 0); + } +} + +cs2 +{ + type cartesian; + origin (0 3 5); + e1 (1 2 0); + e2 (2 0 2); +} + +cs3 +{ + type cartesian; + origin (0 3 5); + coordinateRotation + { + type euler; + angles (90 0 0); + } +} + +cs3 +{ + type cylindrical; + origin (0 3 5); + coordinateRotation + { + type euler; + angles (90 0 0); + } +} + +cyl +{ + type cylindrical; + origin (0 0 0); + degrees false; + + coordinateRotation + { + type axisAngle; + axis (0 0 1); + angle 90; + } +} + +ident +{ + origin (0 0 0); + coordinateRotation + { + type none; + } +} + +) + +// ************************************************************************* // diff --git a/applications/test/coordinateSystem/testCase/system/controlDict b/applications/test/coordinateSystem/testCase/system/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..4173430aa13f8da691a84933ecb235a02740e398 --- /dev/null +++ b/applications/test/coordinateSystem/testCase/system/controlDict @@ -0,0 +1,48 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1806 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application simpleFoam; + +startFrom latestTime; + +startTime 0; + +stopAt endTime; + +endTime 4; + +deltaT 1; + +writeControl timeStep; + +writeInterval 100; + +purgeWrite 0; + +writeFormat binary; + +writePrecision 6; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable true; + + +// ************************************************************************* // diff --git a/applications/test/coordinateSystem/testDict1 b/applications/test/coordinateSystem/testCsys1 similarity index 67% rename from applications/test/coordinateSystem/testDict1 rename to applications/test/coordinateSystem/testCsys1 index 2fa9cdb21b8c7f980be4531f0e62e630d1513b50..7251a946c088a67f478f8eeb3b8d29d106ea21c2 100644 --- a/applications/test/coordinateSystem/testDict1 +++ b/applications/test/coordinateSystem/testCsys1 @@ -10,12 +10,19 @@ FoamFile version 2.0; format ascii; class dictionary; - object testDict; + object testCsys1; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Rotate 90 deg around x: y -> z, z -> -y +rot_x90 +{ + origin (0 0 0); + e1 (1 0 0); + e3 (0 -1 0); +} + rot_x90_axesRotation { origin (0 0 0); @@ -27,13 +34,24 @@ rot_x90_axesRotation } } +rot_x90_axisAngle +{ + origin (0 0 0); + coordinateRotation + { + type axisAngle; + axis (1 0 0); // non-unit also OK + angle 90; + } +} + rot_x90_euler { origin (0 0 0); coordinateRotation { - type EulerRotation; - rotation (0 90 0); // z-x'-z'' + type euler; + angles (0 90 0); // z-x'-z'' } } @@ -51,6 +69,17 @@ rot_z45_axesRotation } } +rot_z45_axisAngle +{ + origin (0 0 0); + coordinateRotation + { + type axisAngle; + axis (0 0 10); // non-unit also OK + angle 45; + } +} + rot_z45_euler { origin (0 0 0); @@ -63,6 +92,7 @@ rot_z45_euler // Rotate -45 deg around z: x -> (1 -1 0), y = (1 1 0) + rot_zm45_axesRotation { origin (0 0 0); @@ -74,6 +104,17 @@ rot_zm45_axesRotation } } +rot_zm45_axisAngle +{ + origin (0 0 0); + coordinateRotation + { + type axisAngle; + axis (0 0 10); // non-unit also OK + angle -45; + } +} + rot_zm45_euler { origin (0 0 0); @@ -98,6 +139,28 @@ null_axesRotation } } +null_axisAngle0 +{ + origin (0 0 0); + coordinateRotation + { + type axisAngle; + axis (0 0 0); // non-unit also OK + angle 0; + } +} + +null_axisAngle1 +{ + origin (0 0 0); + coordinateRotation + { + type axisAngle; + axis (1 1 1); // non-unit also OK + angle 0; + } +} + null_euler { origin (0 0 0); diff --git a/applications/test/coordinateSystem/testCsys2 b/applications/test/coordinateSystem/testCsys2 new file mode 100644 index 0000000000000000000000000000000000000000..13caeacd5ae2a5aceab2fe1b6e1fe53d1f98b5e9 --- /dev/null +++ b/applications/test/coordinateSystem/testCsys2 @@ -0,0 +1,59 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1806 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object testCsys1; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// This dictionary only works in combination with constant/coordinateSystems + +mycs1 +{ + type indirect; + name cs1; +} + +mycs2 +{ + type indirect; + name cs2; +} + +mycs3 +{ + type indirect; + name cs3; +} + +mycyl +{ + type indirect; + name cyl; +} + + +mycy2 +{ + coordinateSystem + { + type indirect; + name cyl; + } +} + +mycy3 +{ + coordinateSystem cyl; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/utilities/surface/surfaceMeshConvert/coordinateSystems b/applications/utilities/surface/surfaceMeshConvert/coordinateSystems index c527806a2141ec7b1bd3ec4b38eca5c7151fbeda..d325ab2b2c1904cacddab545904c3014c0807644 100644 --- a/applications/utilities/surface/surfaceMeshConvert/coordinateSystems +++ b/applications/utilities/surface/surfaceMeshConvert/coordinateSystems @@ -14,69 +14,69 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -7 + ( -system_9 +_9 { type cartesian; origin (1.03291515 -0.114391257 -0.0826236662); e3 (1 0 0); e1 (0 1 0); - // STARCDRotation (0 90 90); + // coordinateRotation { type starcd; angles (0 90 90); } } -system_10 +_10 { type cartesian; origin (0.623151719 -0.286472935 -0.113933262); e3 (0.99508851 0.09829095 0.01173645); e1 (0.01179356 0 -0.99993045); - // STARCDRotation (5.6403745 -0.0664172952 89.3275351); + // coordinateRotation { type starcd; angles (5.6403745 -0.0664172952 89.3275351); } } -system_15 +_15 { type cartesian; origin (0.644772231 -0.240036493 0.155972187); e3 (-0.01346388 -0.90616979 -0.42269969); e1 (0.00627978 0.42265304 -0.90626981); - // STARCDRotation (-90.8512386 0 115.005148); + // coordinateRotation { type starcd; angles (-90.8512386 0 115.005148); } } -system_16 +_16 { type cartesian; origin (0.540824938 -0.240036415 0.15928296); e3 (-0.01346388 -0.90616979 -0.42269969); e1 (0.00627978 0.42265304 -0.90626981); - // STARCDRotation (-90.8512386 0 115.005148); + // coordinateRotation { type starcd; angles (-90.8512386 0 115.005148); } } -system_17 +_17 { type cartesian; origin (0.436877646 -0.240036339 0.162593737); e3 (-0.01346388 -0.90616979 -0.42269969); e1 (0.00627978 0.42265304 -0.90626981); - // STARCDRotation (-90.8512386 0 115.005148); + // coordinateRotation { type starcd; angles (-90.8512386 0 115.005148); } } -system_18 +_18 { type cartesian; origin (0.332930354 -0.240036261 0.16590451); e3 (-0.01346388 -0.90616979 -0.42269969); e1 (0.00627978 0.42265304 -0.90626981); - // STARCDRotation (-90.8512386 0 115.005148); + // coordinateRotation { type starcd; angles (-90.8512386 0 115.005148); } } -system_21 +_21 { type cartesian; origin (0.55863733 -0.300866705 0.00317260982); e3 (0.42110287 0.02470132 -0.90667647); e1 (0.90646036 0.02342535 0.42164069); - // STARCDRotation (-178.185897 -0.71772221 -155.059695); + // coordinateRotation { type starcd; angles (-178.185897 -0.71772221 -155.059695); } } ) diff --git a/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C b/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C index 7fe05e83187f1d9447f2474dfbd7b3ef1eaa9b1d..c172488240a0835d90dd13aff764e2e5a12ac2da 100644 --- a/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C +++ b/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -150,9 +150,7 @@ int main(int argc, char *argv[]) if (args.found("from") || args.found("to")) { - autoPtr<IOobject> csDictIoPtr; - - const word dictName("coordinateSystems::typeName"); + const word dictName(coordinateSystems::typeName); // Note: cannot use setSystemRunTimeDictionaryIO.H since dictionary // is in constant @@ -163,9 +161,10 @@ int main(int argc, char *argv[]) dictPath = dictPath / dictName; } + autoPtr<IOobject> ioPtr; if (dictPath.size()) { - csDictIoPtr.reset + ioPtr.reset ( new IOobject ( @@ -179,7 +178,7 @@ int main(int argc, char *argv[]) } else { - csDictIoPtr.reset + ioPtr.reset ( new IOobject ( @@ -193,51 +192,51 @@ int main(int argc, char *argv[]) ); } - - if (!csDictIoPtr->typeHeaderOk<coordinateSystems>(false)) + if (!ioPtr->typeHeaderOk<coordinateSystems>(false)) { FatalErrorInFunction << "Cannot open coordinateSystems file\n " - << csDictIoPtr->objectPath() << nl + << ioPtr->objectPath() << nl << exit(FatalError); } - coordinateSystems csLst(csDictIoPtr()); + coordinateSystems globalCoords(*ioPtr); if (args.found("from")) { - const word csName = args["from"]; + const word csName(args["from"]); + const auto* csPtr = globalCoords.lookupPtr(csName); - const label csIndex = csLst.findIndex(csName); - if (csIndex < 0) + if (!csPtr) { FatalErrorInFunction << "Cannot find -from " << csName << nl - << "available coordinateSystems: " << csLst.toc() << nl + << "available coordinateSystems: " + << flatOutput(globalCoords.names()) << nl << exit(FatalError); } - fromCsys.reset(new coordinateSystem(csLst[csIndex])); + fromCsys = autoPtr<coordinateSystem>::New(*csPtr); } if (args.found("to")) { - const word csName = args["to"]; + const word csName(args["to"]); + const auto* csPtr = globalCoords.lookupPtr(csName); - const label csIndex = csLst.findIndex(csName); - if (csIndex < 0) + if (!csPtr) { FatalErrorInFunction << "Cannot find -to " << csName << nl - << "available coordinateSystems: " << csLst.toc() << nl + << "available coordinateSystems: " + << flatOutput(globalCoords.names()) << nl << exit(FatalError); } - toCsys.reset(new coordinateSystem(csLst[csIndex])); + toCsys = autoPtr<coordinateSystem>::New(*csPtr); } - - // maybe fix this later + // Maybe fix this later if (fromCsys.valid() && toCsys.valid()) { FatalErrorInFunction @@ -258,29 +257,30 @@ int main(int argc, char *argv[]) scalar scaleIn = 0; if (args.readIfPresent("scaleIn", scaleIn) && scaleIn > 0) { - Info<< " -scaleIn " << scaleIn << endl; + Info<< "scale input " << scaleIn << endl; surf.scalePoints(scaleIn); } - if (fromCsys.valid()) { - Info<< " -from " << fromCsys().name() << endl; - tmp<pointField> tpf = fromCsys().localPosition(surf.points()); + Info<< "move points from coordinate system: " + << fromCsys->name() << endl; + tmp<pointField> tpf = fromCsys->localPosition(surf.points()); surf.movePoints(tpf()); } if (toCsys.valid()) { - Info<< " -to " << toCsys().name() << endl; - tmp<pointField> tpf = toCsys().globalPosition(surf.points()); + Info<< "move points to coordinate system: " + << toCsys->name() << endl; + tmp<pointField> tpf = toCsys->globalPosition(surf.points()); surf.movePoints(tpf()); } scalar scaleOut = 0; if (args.readIfPresent("scaleOut", scaleOut) && scaleOut > 0) { - Info<< " -scaleOut " << scaleOut << endl; + Info<< "scale output " << scaleOut << endl; surf.scalePoints(scaleOut); } diff --git a/applications/utilities/surface/surfaceMeshExport/surfaceMeshExport.C b/applications/utilities/surface/surfaceMeshExport/surfaceMeshExport.C index 127b6e75f234a132c5251367bd9d12fd0a25ffa6..4de5bef4afe13d829cade5825cafc505e5049f50 100644 --- a/applications/utilities/surface/surfaceMeshExport/surfaceMeshExport.C +++ b/applications/utilities/surface/surfaceMeshExport/surfaceMeshExport.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -139,21 +139,22 @@ int main(int argc, char *argv[]) if (args.found("from") || args.found("to")) { - autoPtr<IOobject> ioPtr; + const word dictName(coordinateSystems::typeName); - if (args.found("dict")) + fileName dictPath; + if (args.readIfPresent("dict", dictPath) && isDir(dictPath)) { - const fileName dictPath = args["dict"]; + dictPath = dictPath / dictName; + } + autoPtr<IOobject> ioPtr; + if (dictPath.size()) + { ioPtr.reset ( new IOobject ( - ( - isDir(dictPath) - ? dictPath/coordinateSystems::typeName - : dictPath - ), + dictPath, runTime, IOobject::MUST_READ, IOobject::NO_WRITE, @@ -167,7 +168,7 @@ int main(int argc, char *argv[]) ( new IOobject ( - coordinateSystems::typeName, + dictName, runTime.constant(), runTime, IOobject::MUST_READ, @@ -177,7 +178,6 @@ int main(int argc, char *argv[]) ); } - if (!ioPtr->typeHeaderOk<coordinateSystems>(false)) { FatalErrorInFunction @@ -185,42 +185,43 @@ int main(int argc, char *argv[]) << exit(FatalError); } - coordinateSystems csLst(ioPtr()); + coordinateSystems globalCoords(*ioPtr); if (args.found("from")) { - const word csName = args["from"]; + const word csName(args["from"]); + const auto* csPtr = globalCoords.lookupPtr(csName); - const label csIndex = csLst.findIndex(csName); - if (csIndex < 0) + if (!csPtr) { FatalErrorInFunction << "Cannot find -from " << csName << nl - << "available coordinateSystems: " << csLst.toc() << nl + << "available coordinateSystems: " + << flatOutput(globalCoords.names()) << nl << exit(FatalError); } - fromCsys.reset(new coordinateSystem(csLst[csIndex])); + fromCsys = autoPtr<coordinateSystem>::New(*csPtr); } if (args.found("to")) { - const word csName = args["to"]; + const word csName(args["to"]); + const auto* csPtr = globalCoords.lookupPtr(csName); - const label csIndex = csLst.findIndex(csName); - if (csIndex < 0) + if (!csPtr) { FatalErrorInFunction << "Cannot find -to " << csName << nl - << "available coordinateSystems: " << csLst.toc() << nl + << "available coordinateSystems: " + << flatOutput(globalCoords.names()) << nl << exit(FatalError); } - toCsys.reset(new coordinateSystem(csLst[csIndex])); + toCsys = autoPtr<coordinateSystem>::New(*csPtr); } - - // maybe fix this later + // Maybe fix this later if (fromCsys.valid() && toCsys.valid()) { FatalErrorInFunction @@ -256,28 +257,30 @@ int main(int argc, char *argv[]) scalar scaleIn = 0; if (args.readIfPresent("scaleIn", scaleIn) && scaleIn > 0) { - Info<< " -scaleIn " << scaleIn << endl; + Info<< "scale input " << scaleIn << endl; surf.scalePoints(scaleIn); } if (fromCsys.valid()) { - Info<< " -from " << fromCsys().name() << endl; - tmp<pointField> tpf = fromCsys().localPosition(surf.points()); + Info<< "move points from coordinate system: " + << fromCsys->name() << endl; + tmp<pointField> tpf = fromCsys->localPosition(surf.points()); surf.movePoints(tpf()); } if (toCsys.valid()) { - Info<< " -to " << toCsys().name() << endl; - tmp<pointField> tpf = toCsys().globalPosition(surf.points()); + Info<< "move points to coordinate system: " + << toCsys->name() << endl; + tmp<pointField> tpf = toCsys->globalPosition(surf.points()); surf.movePoints(tpf()); } scalar scaleOut = 0; if (args.readIfPresent("scaleOut", scaleOut) && scaleOut > 0) { - Info<< " -scaleOut " << scaleOut << endl; + Info<< "scale output " << scaleOut << endl; surf.scalePoints(scaleOut); } diff --git a/applications/utilities/surface/surfaceMeshImport/surfaceMeshImport.C b/applications/utilities/surface/surfaceMeshImport/surfaceMeshImport.C index 69637b46e5be49ec12a8b00f41dac7a2be4d3b6b..8fe28d3c9b4b30f8bf2a5bc55a69be0ee1596c81 100644 --- a/applications/utilities/surface/surfaceMeshImport/surfaceMeshImport.C +++ b/applications/utilities/surface/surfaceMeshImport/surfaceMeshImport.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -152,21 +152,22 @@ int main(int argc, char *argv[]) if (args.found("from") || args.found("to")) { - autoPtr<IOobject> ioPtr; + const word dictName(coordinateSystems::typeName); - if (args.found("dict")) + fileName dictPath; + if (args.readIfPresent("dict", dictPath) && isDir(dictPath)) { - const fileName dictPath = args["dict"]; + dictPath = dictPath / dictName; + } + autoPtr<IOobject> ioPtr; + if (dictPath.size()) + { ioPtr.reset ( new IOobject ( - ( - isDir(dictPath) - ? dictPath/coordinateSystems::typeName - : dictPath - ), + dictPath, runTime, IOobject::MUST_READ, IOobject::NO_WRITE, @@ -180,7 +181,7 @@ int main(int argc, char *argv[]) ( new IOobject ( - coordinateSystems::typeName, + dictName, runTime.constant(), runTime, IOobject::MUST_READ, @@ -190,50 +191,51 @@ int main(int argc, char *argv[]) ); } - if (!ioPtr->typeHeaderOk<coordinateSystems>(false)) { FatalErrorInFunction + << "Cannot open coordinateSystems file\n " << ioPtr->objectPath() << nl << exit(FatalError); } - coordinateSystems csLst(ioPtr()); + coordinateSystems globalCoords(*ioPtr); if (args.found("from")) { - const word csName = args["from"]; + const word csName(args["from"]); + const auto* csPtr = globalCoords.lookupPtr(csName); - const label csIndex = csLst.findIndex(csName); - if (csIndex < 0) + if (!csPtr) { FatalErrorInFunction << "Cannot find -from " << csName << nl - << "available coordinateSystems: " << csLst.toc() << nl + << "available coordinateSystems: " + << flatOutput(globalCoords.names()) << nl << exit(FatalError); } - fromCsys.reset(new coordinateSystem(csLst[csIndex])); + fromCsys = autoPtr<coordinateSystem>::New(*csPtr); } if (args.found("to")) { - const word csName = args["to"]; + const word csName(args["to"]); + const auto* csPtr = globalCoords.lookupPtr(csName); - const label csIndex = csLst.findIndex(csName); - if (csIndex < 0) + if (!csPtr) { FatalErrorInFunction << "Cannot find -to " << csName << nl - << "available coordinateSystems: " << csLst.toc() << nl + << "available coordinateSystems: " + << flatOutput(globalCoords.names()) << nl << exit(FatalError); } - toCsys.reset(new coordinateSystem(csLst[csIndex])); + toCsys = autoPtr<coordinateSystem>::New(*csPtr); } - - // maybe fix this later + // Maybe fix this later if (fromCsys.valid() && toCsys.valid()) { FatalErrorInFunction @@ -242,7 +244,6 @@ int main(int argc, char *argv[]) } - MeshedSurface<face> surf(importName); if (args.found("clean")) @@ -254,28 +255,31 @@ int main(int argc, char *argv[]) scalar scaleIn = 0; if (args.readIfPresent("scaleIn", scaleIn) && scaleIn > 0) { - Info<< " -scaleIn " << scaleIn << endl; + Info<< "scale input " << scaleIn << endl; surf.scalePoints(scaleIn); } if (fromCsys.valid()) { - Info<< " -from " << fromCsys().name() << endl; - tmp<pointField> tpf = fromCsys().localPosition(surf.points()); + Info<< "move points from coordinate system: " + << fromCsys->name() << endl; + + tmp<pointField> tpf = fromCsys->localPosition(surf.points()); surf.movePoints(tpf()); } if (toCsys.valid()) { - Info<< " -to " << toCsys().name() << endl; - tmp<pointField> tpf = toCsys().globalPosition(surf.points()); + Info<< "move points to coordinate system: " + << toCsys->name() << endl; + tmp<pointField> tpf = toCsys->globalPosition(surf.points()); surf.movePoints(tpf()); } scalar scaleOut = 0; if (args.readIfPresent("scaleOut", scaleOut) && scaleOut > 0) { - Info<< " -scaleOut " << scaleOut << endl; + Info<< "scale output " << scaleOut << endl; surf.scalePoints(scaleOut); } diff --git a/etc/caseDicts/general/coordinateSystem/cartesianXY b/etc/caseDicts/general/coordinateSystem/cartesianXY index 2fe0d38a5e6e5abcec2e941ec6add0a1350deb9f..02731395392d1151eb4f1a46417f0ae7b974b8dd 100644 --- a/etc/caseDicts/general/coordinateSystem/cartesianXY +++ b/etc/caseDicts/general/coordinateSystem/cartesianXY @@ -18,7 +18,7 @@ type cartesian; origin (0 0 0); coordinateRotation { - type axesRotation; + type axes; e1 $x; e2 $y; } diff --git a/etc/caseDicts/general/coordinateSystem/cartesianXZ b/etc/caseDicts/general/coordinateSystem/cartesianXZ index 4915e791bd55f1674e49c581e8a9e3cdb52b87fb..f8ce01b167cdda349e148e95f154906715339fc5 100644 --- a/etc/caseDicts/general/coordinateSystem/cartesianXZ +++ b/etc/caseDicts/general/coordinateSystem/cartesianXZ @@ -18,7 +18,7 @@ type cartesian; origin (0 0 0); coordinateRotation { - type axesRotation; + type axes; e1 $x; e3 $z; } diff --git a/etc/caseDicts/general/coordinateSystem/cartesianYZ b/etc/caseDicts/general/coordinateSystem/cartesianYZ index 0452b239c1080b41968682426d10658ad64430d4..ab473dd987369ce39dd72319a1f9622b94ed2b18 100644 --- a/etc/caseDicts/general/coordinateSystem/cartesianYZ +++ b/etc/caseDicts/general/coordinateSystem/cartesianYZ @@ -18,7 +18,7 @@ type cartesian; origin (0 0 0); coordinateRotation { - type axesRotation; + type axes; e2 $y; e3 $z } diff --git a/etc/controlDict b/etc/controlDict index 918ac112ca2f0d8cab866f7afac91e8ed91216cc..950e5adc2b08b9d9242954ceff0c3224ea165166 100644 --- a/etc/controlDict +++ b/etc/controlDict @@ -208,7 +208,6 @@ DebugSwitches Ergun 0; Euler 0; EulerImplicit 0; - EulerRotation 0; extendedCellToFaceStencil 0; FDIC 0; FaceCellWave 0; @@ -239,7 +238,6 @@ DebugSwitches IFstream 0; IOMap<dictionary> 0; IOPtrList<MRFZone> 0; - IOPtrList<coordinateSystem> 0; IOPtrList<injector> 0; IOPtrList<porousZone> 0; IOobject 0; @@ -336,7 +334,6 @@ DebugSwitches SLTS 0; SRFModel 0; SRFVelocity 0; - STARCDRotation 0; Schaeffer 0; SchillerNaumann 0; SinclairJackson 0; @@ -456,9 +453,7 @@ DebugSwitches constantAbsorptionEmission 0; constantAlphaContactAngle 0; constantScatter 0; - coordinateRotation 0; coordinateSystem 0; - coordinateSystems 0; corrected 0; coupled 0; cubeRootVol 0; @@ -478,9 +473,9 @@ DebugSwitches diagonal 0; dictionary 0; dimensionSet 1; - mappedBase 0; - mappedPatch 0; - mappedVelocityFlux 0; + mappedBase 0; + mappedPatch 0; + mappedVelocityFlux 0; directionMixed 0; directional 0; disallowGenericFvPatchField 0; @@ -745,7 +740,6 @@ DebugSwitches outletInlet 0; outletStabilised 0; pair 0; - parabolicCylindrical 0; parcel 0; partialSlip 0; passiveParticle 0; @@ -1101,5 +1095,4 @@ DimensionSets } - // ************************************************************************* // diff --git a/src/atmosphericModels/derivedFvPatchFields/nutkAtmRoughWallFunction/nutkAtmRoughWallFunctionFvPatchScalarField.H b/src/atmosphericModels/derivedFvPatchFields/nutkAtmRoughWallFunction/nutkAtmRoughWallFunctionFvPatchScalarField.H index 858ab1fd914660e36b63e156455dd768f2427a96..955fa72d7ee4d4a4871fded35b38656ca7a82e76 100644 --- a/src/atmosphericModels/derivedFvPatchFields/nutkAtmRoughWallFunction/nutkAtmRoughWallFunctionFvPatchScalarField.H +++ b/src/atmosphericModels/derivedFvPatchFields/nutkAtmRoughWallFunction/nutkAtmRoughWallFunctionFvPatchScalarField.H @@ -43,7 +43,7 @@ Description U_f | frictional velocity K | Von Karman's constant z_0 | surface roughness length - z | vertical co-ordinate + z | vertical coordinate \endvartable Usage diff --git a/src/dynamicMesh/meshCut/directions/directions.C b/src/dynamicMesh/meshCut/directions/directions.C index b5258913447df7894863134abd695c164729c034..3686d429efcfe2d74af7e496079c3db06fe0b5b0 100644 --- a/src/dynamicMesh/meshCut/directions/directions.C +++ b/src/dynamicMesh/meshCut/directions/directions.C @@ -276,7 +276,7 @@ Foam::directions::directions List<vectorField>(wordList(dict.lookup("directions")).size()) { const wordList wantedDirs(dict.lookup("directions")); - const word coordSystem(dict.lookup("coordinateSystem")); + const word coordSystem(dict.get<word>("coordinateSystem")); bool wantNormal = false; bool wantTan1 = false; diff --git a/src/dynamicMesh/motionSolvers/displacement/points0/points0MotionSolver.C b/src/dynamicMesh/motionSolvers/displacement/points0/points0MotionSolver.C index 1a204d67a5ee5a4d44d5eb26c0a095813f9182f0..8af0c320c1e16e5a9d663d370277ce7ee84f36fd 100644 --- a/src/dynamicMesh/motionSolvers/displacement/points0/points0MotionSolver.C +++ b/src/dynamicMesh/motionSolvers/displacement/points0/points0MotionSolver.C @@ -230,8 +230,8 @@ void Foam::points0MotionSolver::updateMesh(const mapPolyMesh& mpm) else { FatalErrorInFunction - << "Cannot determine co-ordinates of introduced vertices." - << " New vertex " << pointi << " at co-ordinate " + << "Cannot determine coordinates of introduced vertices." + << " New vertex " << pointi << " at coordinate " << points[pointi] << exit(FatalError); } } diff --git a/src/engine/enginePiston/enginePiston.C b/src/engine/enginePiston/enginePiston.C index 68be48ec087718d67c21051c8aec3cef43c945da..ba520fffd6ed16877ca3ffb695b34671fea72799 100644 --- a/src/engine/enginePiston/enginePiston.C +++ b/src/engine/enginePiston/enginePiston.C @@ -30,7 +30,6 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct from components Foam::enginePiston::enginePiston ( const polyMesh& mesh, @@ -49,7 +48,6 @@ Foam::enginePiston::enginePiston {} -// Construct from dictionary Foam::enginePiston::enginePiston ( const polyMesh& mesh, @@ -61,20 +59,13 @@ Foam::enginePiston::enginePiston patchID_(dict.lookup("patch"), mesh.boundaryMesh()), csPtr_ ( - coordinateSystem::New - ( - mesh_, - dict.subDict("coordinateSystem") - ) + coordinateSystem::New(mesh_, dict, "coordinateSystem") ), - minLayer_(readScalar(dict.lookup("minLayer"))), - maxLayer_(readScalar(dict.lookup("maxLayer"))) + minLayer_(dict.get<scalar>("minLayer")), + maxLayer_(dict.get<scalar>("maxLayer")) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::enginePiston::writeDict(Ostream& os) const diff --git a/src/engine/enginePiston/enginePiston.H b/src/engine/enginePiston/enginePiston.H index 03c2291216ef91379ab49b75e875775d6d25674e..d1a6993d85174eab13101d8c5560fd07ced4db20 100644 --- a/src/engine/enginePiston/enginePiston.H +++ b/src/engine/enginePiston/enginePiston.H @@ -112,7 +112,8 @@ public: ); - // Destructor - default + //- Destructor + ~enginePiston() = default; // Member Functions diff --git a/src/engine/engineValve/engineValve.C b/src/engine/engineValve/engineValve.C index 0be19c39f28fdec6f6972f80354f05224c8e1b2e..27263fd9c4b10860a539d5167ae213d7d025b3dd 100644 --- a/src/engine/engineValve/engineValve.C +++ b/src/engine/engineValve/engineValve.C @@ -63,7 +63,6 @@ Foam::scalar Foam::engineValve::adjustCrankAngle(const scalar theta) const // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct from components Foam::engineValve::engineValve ( const word& name, @@ -110,7 +109,6 @@ Foam::engineValve::engineValve {} -// Construct from dictionary Foam::engineValve::engineValve ( const word& name, @@ -123,11 +121,7 @@ Foam::engineValve::engineValve engineDB_(refCast<const engineTime>(mesh_.time())), csPtr_ ( - coordinateSystem::New - ( - mesh_, - dict.subDict("coordinateSystem") - ) + coordinateSystem::New(mesh_, dict, "coordinateSystem") ), bottomPatch_(dict.lookup("bottomPatch"), mesh.boundaryMesh()), poppetPatch_(dict.lookup("poppetPatch"), mesh.boundaryMesh()), @@ -156,18 +150,15 @@ Foam::engineValve::engineValve liftProfile_("theta", "lift", name_, dict.lookup("liftProfile")), liftProfileStart_(min(liftProfile_.x())), liftProfileEnd_(max(liftProfile_.x())), - minLift_(readScalar(dict.lookup("minLift"))), - minTopLayer_(readScalar(dict.lookup("minTopLayer"))), - maxTopLayer_(readScalar(dict.lookup("maxTopLayer"))), - minBottomLayer_(readScalar(dict.lookup("minBottomLayer"))), - maxBottomLayer_(readScalar(dict.lookup("maxBottomLayer"))), - diameter_(readScalar(dict.lookup("diameter"))) + minLift_(dict.get<scalar>("minLift")), + minTopLayer_(dict.get<scalar>("minTopLayer")), + maxTopLayer_(dict.get<scalar>("maxTopLayer")), + minBottomLayer_(dict.get<scalar>("minBottomLayer")), + maxBottomLayer_(dict.get<scalar>("maxBottomLayer")), + diameter_(dict.get<scalar>("diameter")) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::scalar Foam::engineValve::lift(const scalar theta) const @@ -238,7 +229,7 @@ void Foam::engineValve::writeDict(Ostream& os) const { os << nl << name() << nl << token::BEGIN_BLOCK; - cs().writeDict(os); + cs().writeEntry("coordinateSystem", os); os << "bottomPatch " << bottomPatch_.name() << token::END_STATEMENT << nl << "poppetPatch " << poppetPatch_.name() << token::END_STATEMENT << nl diff --git a/src/engine/engineValve/engineValve.H b/src/engine/engineValve/engineValve.H index e34b88f65f8257f735892ef17ac84983af026c2d..6967f34c86016dc4adafacf03f9d66fc9dbab896 100644 --- a/src/engine/engineValve/engineValve.H +++ b/src/engine/engineValve/engineValve.H @@ -45,7 +45,7 @@ SourceFiles namespace Foam { -// Forward declaration of classes +// Forward declarations class polyMesh; class engineTime; @@ -145,9 +145,6 @@ class engineValve public: - // Static data members - - // Constructors //- Construct from components @@ -171,7 +168,6 @@ public: const scalar minBottomLayer, const scalar maxBottomLayer, const scalar diameter - ); //- Construct from dictionary @@ -183,7 +179,8 @@ public: ); - // Destructor - default + //- Destructor + ~engineValve() = default; // Member Functions @@ -308,7 +305,7 @@ public: //- Write dictionary - void writeDict(Ostream&) const; + void writeDict(Ostream& os) const; }; diff --git a/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimer.C b/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimer.C index 35a9a246d1818af6e5905fedf77705905f96043e..afb8309789cc5e627208bc826c10e3a788f06171 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimer.C +++ b/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimer.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,8 @@ License #include "DarcyForchheimer.H" #include "geometricOneField.H" #include "fvMatrices.H" +#include "cylindricalTransform.H" +#include "pointIndList.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -67,66 +69,60 @@ Foam::porosityModels::DarcyForchheimer::DarcyForchheimer } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::porosityModels::DarcyForchheimer::~DarcyForchheimer() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::porosityModels::DarcyForchheimer::calcTransformModelData() { - if (coordSys_.R().uniform()) - { - forAll(cellZoneIDs_, zoneI) - { - D_[zoneI].setSize(1); - F_[zoneI].setSize(1); + // The Darcy coefficient as a tensor + tensor darcyCoeff(Zero); + darcyCoeff.xx() = dXYZ_.value().x(); + darcyCoeff.yy() = dXYZ_.value().y(); + darcyCoeff.zz() = dXYZ_.value().z(); - D_[zoneI][0] = Zero; - D_[zoneI][0].xx() = dXYZ_.value().x(); - D_[zoneI][0].yy() = dXYZ_.value().y(); - D_[zoneI][0].zz() = dXYZ_.value().z(); + // The Forchheimer coefficient as a tensor + // - the leading 0.5 is from 1/2*rho + tensor forchCoeff(Zero); + forchCoeff.xx() = 0.5*fXYZ_.value().x(); + forchCoeff.yy() = 0.5*fXYZ_.value().y(); + forchCoeff.zz() = 0.5*fXYZ_.value().z(); - D_[zoneI][0] = coordSys_.R().transformTensor(D_[zoneI][0]); - // leading 0.5 is from 1/2*rho - F_[zoneI][0] = Zero; - F_[zoneI][0].xx() = 0.5*fXYZ_.value().x(); - F_[zoneI][0].yy() = 0.5*fXYZ_.value().y(); - F_[zoneI][0].zz() = 0.5*fXYZ_.value().z(); + if (coordSys_.R().uniform()) + { + forAll(cellZoneIDs_, zonei) + { + D_[zonei].setSize(1); + F_[zonei].setSize(1); - F_[zoneI][0] = coordSys_.R().transformTensor(F_[zoneI][0]); + D_[zonei] = coordSys_.R().transformTensor(darcyCoeff); + F_[zonei] = coordSys_.R().transformTensor(forchCoeff); } } else { - forAll(cellZoneIDs_, zoneI) - { - const labelList& cells = mesh_.cellZones()[cellZoneIDs_[zoneI]]; - - D_[zoneI].setSize(cells.size()); - F_[zoneI].setSize(cells.size()); - - forAll(cells, i) - { - D_[zoneI][i] = Zero; - D_[zoneI][i].xx() = dXYZ_.value().x(); - D_[zoneI][i].yy() = dXYZ_.value().y(); - D_[zoneI][i].zz() = dXYZ_.value().z(); - - // leading 0.5 is from 1/2*rho - F_[zoneI][i] = Zero; - F_[zoneI][i].xx() = 0.5*fXYZ_.value().x(); - F_[zoneI][i].yy() = 0.5*fXYZ_.value().y(); - F_[zoneI][i].zz() = 0.5*fXYZ_.value().z(); - } - - const coordinateRotation& R = coordSys_.R(mesh_, cells); + // This is perhaps only represents a temporary solution (JUL-2018) + // + // The only non-uniform coordinate rotation ('cylindric') corresponds + // to the cylindricalTransform. - D_[zoneI] = R.transformTensor(D_[zoneI], cells); - F_[zoneI] = R.transformTensor(F_[zoneI], cells); + forAll(cellZoneIDs_, zonei) + { + const cylindricalTransform<pointUIndList> + cylTrans + ( + coordSys_, + pointUIndList + ( + mesh_.cellCentres(), + mesh_.cellZones()[cellZoneIDs_[zonei]] + ) + ); + + D_[zonei].setSize(cylTrans.size()); + F_[zonei].setSize(cylTrans.size()); + + D_[zonei] = cylTrans.transformTensor(darcyCoeff); + F_[zonei] = cylTrans.transformTensor(forchCoeff); } } @@ -159,8 +155,22 @@ void Foam::porosityModels::DarcyForchheimer::calcTransformModelData() dimensionedTensor(fXYZ_.dimensions(), Zero) ); - UIndirectList<tensor>(Dout, mesh_.cellZones()[cellZoneIDs_[0]]) = D_[0]; - UIndirectList<tensor>(Fout, mesh_.cellZones()[cellZoneIDs_[0]]) = F_[0]; + + forAll(cellZoneIDs_, zonei) + { + const labelList& cells = mesh_.cellZones()[cellZoneIDs_[zonei]]; + + if (coordSys_.R().uniform()) + { + UIndirectList<tensor>(Dout, cells) = D_[zonei].first(); + UIndirectList<tensor>(Fout, cells) = F_[zonei].first(); + } + else + { + UIndirectList<tensor>(Dout, cells) = D_[zonei]; + UIndirectList<tensor>(Fout, cells) = F_[zonei]; + } + } Dout.write(); Fout.write(); @@ -176,7 +186,7 @@ void Foam::porosityModels::DarcyForchheimer::calcForce vectorField& force ) const { - scalarField Udiag(U.size(), 0.0); + scalarField Udiag(U.size(), Zero); vectorField Usource(U.size(), Zero); const scalarField& V = mesh_.V(); @@ -202,19 +212,17 @@ void Foam::porosityModels::DarcyForchheimer::correct if (UEqn.dimensions() == dimForce) { - const volScalarField& rho = mesh_.lookupObject<volScalarField>(rhoName); + const auto& rho = mesh_.lookupObject<volScalarField>(rhoName); if (mesh_.foundObject<volScalarField>(muName)) { - const volScalarField& mu = - mesh_.lookupObject<volScalarField>(muName); + const auto& mu = mesh_.lookupObject<volScalarField>(muName); apply(Udiag, Usource, V, rho, mu, U); } else { - const volScalarField& nu = - mesh_.lookupObject<volScalarField>(nuName); + const auto& nu = mesh_.lookupObject<volScalarField>(nuName); apply(Udiag, Usource, V, rho, rho*nu, U); } @@ -223,17 +231,14 @@ void Foam::porosityModels::DarcyForchheimer::correct { if (mesh_.foundObject<volScalarField>(nuName)) { - const volScalarField& nu = - mesh_.lookupObject<volScalarField>(nuName); + const auto& nu = mesh_.lookupObject<volScalarField>(nuName); apply(Udiag, Usource, V, geometricOneField(), nu, U); } else { - const volScalarField& rho = - mesh_.lookupObject<volScalarField>(rhoName); - const volScalarField& mu = - mesh_.lookupObject<volScalarField>(muName); + const auto& rho = mesh_.lookupObject<volScalarField>(rhoName); + const auto& mu = mesh_.lookupObject<volScalarField>(muName); apply(Udiag, Usource, V, geometricOneField(), mu/rho, U); } @@ -271,8 +276,8 @@ void Foam::porosityModels::DarcyForchheimer::correct if (UEqn.dimensions() == dimForce) { - const volScalarField& rho = mesh_.lookupObject<volScalarField>(rhoName); - const volScalarField& mu = mesh_.lookupObject<volScalarField>(muName); + const auto& rho = mesh_.lookupObject<volScalarField>(rhoName); + const auto& mu = mesh_.lookupObject<volScalarField>(muName); apply(AU, rho, mu, U); } @@ -280,17 +285,14 @@ void Foam::porosityModels::DarcyForchheimer::correct { if (mesh_.foundObject<volScalarField>(nuName)) { - const volScalarField& nu = - mesh_.lookupObject<volScalarField>(nuName); + const auto& nu = mesh_.lookupObject<volScalarField>(nuName); apply(AU, geometricOneField(), nu, U); } else { - const volScalarField& rho = - mesh_.lookupObject<volScalarField>(rhoName); - const volScalarField& mu = - mesh_.lookupObject<volScalarField>(muName); + const auto& rho = mesh_.lookupObject<volScalarField>(rhoName); + const auto& mu = mesh_.lookupObject<volScalarField>(muName); apply(AU, geometricOneField(), mu/rho, U); } diff --git a/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimer.H b/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimer.H index 96bcd160c64f660fe0640defa0b3f4a569ea50f0..038d9510986674f0a8a83d4b2e54ab3eac2ca949 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimer.H +++ b/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimer.H @@ -41,7 +41,7 @@ Description to specify a multiplier (of the max component). The orientation of the porous region is defined with the same notation as - a co-ordinate system, but only a Cartesian co-ordinate system is valid. + a coordinate system, but only a Cartesian coordinate system is valid. SourceFiles DarcyForchheimer.C @@ -141,7 +141,7 @@ public: ); //- Destructor - virtual ~DarcyForchheimer(); + virtual ~DarcyForchheimer() = default; // Member Functions diff --git a/src/finiteVolume/cfdTools/general/porosityModel/fixedCoeff/fixedCoeff.C b/src/finiteVolume/cfdTools/general/porosityModel/fixedCoeff/fixedCoeff.C index 64a81304ea850a452f099f17267db6c030f77605..5e970b693c341feaf50ec1a402cfe7dc659bd564 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/fixedCoeff/fixedCoeff.C +++ b/src/finiteVolume/cfdTools/general/porosityModel/fixedCoeff/fixedCoeff.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,6 +26,8 @@ License #include "addToRunTimeSelectionTable.H" #include "fixedCoeff.H" #include "fvMatrices.H" +#include "cylindricalTransform.H" +#include "pointIndList.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -123,62 +125,59 @@ Foam::porosityModels::fixedCoeff::fixedCoeff } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::porosityModels::fixedCoeff::~fixedCoeff() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::porosityModels::fixedCoeff::calcTransformModelData() { + // The alpha coefficient as a tensor + tensor alphaCoeff(Zero); + alphaCoeff.xx() = alphaXYZ_.value().x(); + alphaCoeff.yy() = alphaXYZ_.value().y(); + alphaCoeff.zz() = alphaXYZ_.value().z(); + + // The beta coefficient as a tensor + tensor betaCoeff(Zero); + betaCoeff.xx() = betaXYZ_.value().x(); + betaCoeff.yy() = betaXYZ_.value().y(); + betaCoeff.zz() = betaXYZ_.value().z(); + + if (coordSys_.R().uniform()) { - forAll(cellZoneIDs_, zoneI) + forAll(cellZoneIDs_, zonei) { - alpha_[zoneI].setSize(1); - beta_[zoneI].setSize(1); - - alpha_[zoneI][0] = Zero; - alpha_[zoneI][0].xx() = alphaXYZ_.value().x(); - alpha_[zoneI][0].yy() = alphaXYZ_.value().y(); - alpha_[zoneI][0].zz() = alphaXYZ_.value().z(); - alpha_[zoneI][0] = coordSys_.R().transformTensor(alpha_[zoneI][0]); - - beta_[zoneI][0] = Zero; - beta_[zoneI][0].xx() = betaXYZ_.value().x(); - beta_[zoneI][0].yy() = betaXYZ_.value().y(); - beta_[zoneI][0].zz() = betaXYZ_.value().z(); - beta_[zoneI][0] = coordSys_.R().transformTensor(beta_[zoneI][0]); + alpha_[zonei].setSize(1); + beta_[zonei].setSize(1); + + alpha_[zonei] = coordSys_.R().transformTensor(alphaCoeff); + beta_[zonei] = coordSys_.R().transformTensor(betaCoeff); } } else { - forAll(cellZoneIDs_, zoneI) - { - const labelList& cells = mesh_.cellZones()[cellZoneIDs_[zoneI]]; - - alpha_[zoneI].setSize(cells.size()); - beta_[zoneI].setSize(cells.size()); - - forAll(cells, i) - { - alpha_[zoneI][i] = Zero; - alpha_[zoneI][i].xx() = alphaXYZ_.value().x(); - alpha_[zoneI][i].yy() = alphaXYZ_.value().y(); - alpha_[zoneI][i].zz() = alphaXYZ_.value().z(); + // This is perhaps only represents a temporary solution (JUL-2018) + // + // The only non-uniform coordinate rotation ('cylindric') corresponds + // to the cylindricalTransform. - beta_[zoneI][i] = Zero; - beta_[zoneI][i].xx() = betaXYZ_.value().x(); - beta_[zoneI][i].yy() = betaXYZ_.value().y(); - beta_[zoneI][i].zz() = betaXYZ_.value().z(); - } - - const coordinateRotation& R = coordSys_.R(mesh_, cells); - - alpha_[zoneI] = R.transformTensor(alpha_[zoneI], cells); - beta_[zoneI] = R.transformTensor(beta_[zoneI], cells); + forAll(cellZoneIDs_, zonei) + { + const cylindricalTransform<pointUIndList> + cylTrans + ( + coordSys_, + pointUIndList + ( + mesh_.cellCentres(), + mesh_.cellZones()[cellZoneIDs_[zonei]] + ) + ); + + alpha_[zonei].setSize(cylTrans.size()); + beta_[zonei].setSize(cylTrans.size()); + + alpha_[zonei] = cylTrans.transformTensor(alphaCoeff); + beta_[zonei] = cylTrans.transformTensor(betaCoeff); } } } @@ -195,7 +194,7 @@ void Foam::porosityModels::fixedCoeff::calcForce scalarField Udiag(U.size(), 0.0); vectorField Usource(U.size(), Zero); const scalarField& V = mesh_.V(); - scalar rhoRef = readScalar(coeffs_.lookup("rhoRef")); + const scalar rhoRef = coeffs_.get<scalar>("rhoRef"); apply(Udiag, Usource, V, U, rhoRef); @@ -216,7 +215,7 @@ void Foam::porosityModels::fixedCoeff::correct scalar rho = 1.0; if (UEqn.dimensions() == dimForce) { - coeffs_.lookup("rhoRef") >> rho; + coeffs_.read("rhoRef", rho); } apply(Udiag, Usource, V, U, rho); @@ -238,7 +237,7 @@ void Foam::porosityModels::fixedCoeff::correct scalar rho = 1.0; if (UEqn.dimensions() == dimForce) { - coeffs_.lookup("rhoRef") >> rho; + coeffs_.read("rhoRef", rho); } apply(Udiag, Usource, V, U, rho); @@ -256,7 +255,7 @@ void Foam::porosityModels::fixedCoeff::correct scalar rho = 1.0; if (UEqn.dimensions() == dimForce) { - coeffs_.lookup("rhoRef") >> rho; + coeffs_.read("rhoRef", rho); } apply(AU, U, rho); diff --git a/src/finiteVolume/cfdTools/general/porosityModel/fixedCoeff/fixedCoeff.H b/src/finiteVolume/cfdTools/general/porosityModel/fixedCoeff/fixedCoeff.H index af67f523d4b17b7e95d7cb3a8d6195b665ca9864..1090eb5c8ef3b3175f5a1bf15e19c066543692ea 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/fixedCoeff/fixedCoeff.H +++ b/src/finiteVolume/cfdTools/general/porosityModel/fixedCoeff/fixedCoeff.H @@ -118,7 +118,7 @@ public: ); //- Destructor - virtual ~fixedCoeff(); + virtual ~fixedCoeff() = default; // Member Functions diff --git a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/IOporosityModelList.C b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/IOporosityModelList.C index 0ed573c356ea6786018a03be5606d59bcc2f3371..f6cab47ee1f11c4ecfdc7236711a906c2a387c85 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/IOporosityModelList.C +++ b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/IOporosityModelList.C @@ -48,15 +48,15 @@ Foam::IOobject Foam::IOporosityModelList::createIOobject Info<< "Creating porosity model list from " << io.name() << nl << endl; io.readOpt() = IOobject::MUST_READ_IF_MODIFIED; - return io; } else { Info<< "No porosity models present" << nl << endl; io.readOpt() = IOobject::NO_READ; - return io; } + + return io; } @@ -79,10 +79,8 @@ bool Foam::IOporosityModelList::read() porosityModelList::read(*this); return true; } - else - { - return false; - } + + return false; } diff --git a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/IOporosityModelList.H b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/IOporosityModelList.H index 62502570d1270063834a33e8190abbb52360d73d..8509897429e0326a7c47c71f622126b8487dc788 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/IOporosityModelList.H +++ b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/IOporosityModelList.H @@ -71,12 +71,11 @@ public: // Constructors //- Construct from mesh - IOporosityModelList(const fvMesh& mesh); + explicit IOporosityModelList(const fvMesh& mesh); //- Destructor - virtual ~IOporosityModelList() - {} + virtual ~IOporosityModelList() = default; // Member Functions diff --git a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.C b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.C index d2d430537637d3419697823bac593d5cbd4b5e80..b1dc2dcb0f45022cf04299fe1c5ea8db3000c659 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.C +++ b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.C @@ -63,12 +63,7 @@ void Foam::porosityModel::adjustNegativeResistance(dimensionedVector& resist) Foam::label Foam::porosityModel::fieldIndex(const label i) const { - label index = 0; - if (!coordSys_.R().uniform()) - { - index = i; - } - return index; + return (coordSys_.R().uniform() ? 0 : i); } @@ -101,12 +96,12 @@ Foam::porosityModel::porosityModel active_(true), zoneName_(cellZoneName), cellZoneIDs_(), - coordSys_(*(coordinateSystem::New(mesh, coeffs_))) + coordSys_(*(coordinateSystem::New(mesh, coeffs_, "coordinateSystem"))) { if (zoneName_ == word::null) { dict.readIfPresent("active", active_); - dict_.lookup("cellZone") >> zoneName_; + dict_.read("cellZone", zoneName_); } cellZoneIDs_ = mesh_.cellZones().findIndices(zoneName_); @@ -128,40 +123,31 @@ Foam::porosityModel::porosityModel const pointField& points = mesh_.points(); const cellList& cells = mesh_.cells(); const faceList& faces = mesh_.faces(); - forAll(cellZoneIDs_, zoneI) + + for (const label zonei : cellZoneIDs_) { - const cellZone& cZone = mesh_.cellZones()[cellZoneIDs_[zoneI]]; - point bbMin = point::max; - point bbMax = point::min; + const cellZone& cZone = mesh_.cellZones()[zonei]; + + boundBox bb; - forAll(cZone, i) + for (const label celli : cZone) { - const label cellI = cZone[i]; - const cell& c = cells[cellI]; + const cell& c = cells[celli]; const pointField cellPoints(c.points(faces, points)); - forAll(cellPoints, pointI) + for (const point& pt : cellPoints) { - const point pt = coordSys_.localPosition(cellPoints[pointI]); - bbMin = min(bbMin, pt); - bbMax = max(bbMax, pt); + bb.add(coordSys_.localPosition(pt)); } } - reduce(bbMin, minOp<point>()); - reduce(bbMax, maxOp<point>()); + bb.reduce(); - Info<< " local bounds: " << (bbMax - bbMin) << nl << endl; + Info<< " local bounds: " << bb.span() << nl << endl; } } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::porosityModel::~porosityModel() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::porosityModel::transformModelData() @@ -262,7 +248,7 @@ bool Foam::porosityModel::read(const dictionary& dict) coeffs_ = dict.optionalSubDict(type() + "Coeffs"); - dict.lookup("cellZone") >> zoneName_; + dict.read("cellZone", zoneName_); cellZoneIDs_ = mesh_.cellZones().findIndices(zoneName_); return true; diff --git a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.H b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.H index f8dd0a31fbde63e06a1b7a3e9090d95c53917296..a90bb2ef4ff92a5741e5742ad745ed32ed882c4f 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.H +++ b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.H @@ -91,7 +91,7 @@ protected: //- Cell zone IDs labelList cellZoneIDs_; - //- Local co-ordinate system + //- Local coordinate system coordinateSystem coordSys_; @@ -209,7 +209,7 @@ public: ); //- Destructor - virtual ~porosityModel(); + virtual ~porosityModel() = default; // Member Functions diff --git a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModelList.C b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModelList.C index bb39e241382eacd91baf96f3f87bb0e0602ffbd0..588624f71bc3941114cfdafe251bccbc70f68699 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModelList.C +++ b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModelList.C @@ -38,33 +38,26 @@ Foam::porosityModelList::porosityModelList mesh_(mesh) { reset(dict); - active(true); } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::porosityModelList::~porosityModelList() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // bool Foam::porosityModelList::active(const bool warn) const { - bool a = false; + bool anyOk = false; forAll(*this, i) { - a = a || this->operator[](i).active(); + anyOk = anyOk || this->operator[](i).active(); } - if (warn && this->size() && !a) + if (warn && this->size() && !anyOk) { Info<< "No porosity models active" << endl; } - return a; + return anyOk; } diff --git a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModelList.H b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModelList.H index fb48794662671af00cfbc6a5f29641f5b42117db..4674865685b30a7e24dcf9b1bf63949bba551968 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModelList.H +++ b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModelList.H @@ -45,7 +45,7 @@ SourceFiles namespace Foam { -// Forward declaration of friend functions and operators +// Forward declarations class porosityModelList; Ostream& operator<<(Ostream& os, const porosityModelList& models); @@ -82,13 +82,13 @@ public: porosityModelList(const fvMesh& mesh, const dictionary& dict); //- Destructor - ~porosityModelList(); + ~porosityModelList() = default; // Member Functions //- Return active status - bool active(const bool active = false) const; + bool active(const bool warn = false) const; //- Reset the source list void reset(const dictionary& dict); diff --git a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModelNew.C b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModelNew.C index 811023faaaee87ef90a82e4c4fb3662f58b09c5b..b1e05ae0887e015e1e6c236bc361c56b6c948625 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModelNew.C +++ b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModelNew.C @@ -35,7 +35,7 @@ Foam::autoPtr<Foam::porosityModel> Foam::porosityModel::New const word& cellZoneName ) { - const word modelType(dict.lookup("type")); + const word modelType(dict.get<word>("type")); Info<< "Porosity region " << name << ":" << nl << " selecting model: " << modelType << endl; @@ -46,7 +46,7 @@ Foam::autoPtr<Foam::porosityModel> Foam::porosityModel::New { FatalErrorInFunction << "Unknown " << typeName << " type " << modelType << nl << nl - << "Valid " << typeName << " types are:" << nl + << "Valid types are:" << nl << meshConstructorTablePtr_->sortedToc() << exit(FatalError); } diff --git a/src/finiteVolume/cfdTools/general/porosityModel/powerLaw/powerLaw.C b/src/finiteVolume/cfdTools/general/porosityModel/powerLaw/powerLaw.C index 280b0e4ba27af5ed6d0f13eb84ae3c1059cd78a0..aca0860bbccd7ece8298c57b8b0316f0082a4da9 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/powerLaw/powerLaw.C +++ b/src/finiteVolume/cfdTools/general/porosityModel/powerLaw/powerLaw.C @@ -52,18 +52,12 @@ Foam::porosityModels::powerLaw::powerLaw ) : porosityModel(name, modelType, mesh, dict, cellZoneName), - C0_(readScalar(coeffs_.lookup("C0"))), - C1_(readScalar(coeffs_.lookup("C1"))), + C0_(coeffs_.get<scalar>("C0")), + C1_(coeffs_.get<scalar>("C1")), rhoName_(coeffs_.lookupOrDefault<word>("rho", "rho")) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::porosityModels::powerLaw::~powerLaw() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::porosityModels::powerLaw::calcTransformModelData() @@ -100,7 +94,7 @@ void Foam::porosityModels::powerLaw::correct if (UEqn.dimensions() == dimForce) { - const volScalarField& rho = mesh_.lookupObject<volScalarField> + const auto& rho = mesh_.lookupObject<volScalarField> ( IOobject::groupName(rhoName_, U.group()) ); @@ -139,7 +133,7 @@ void Foam::porosityModels::powerLaw::correct if (UEqn.dimensions() == dimForce) { - const volScalarField& rho = mesh_.lookupObject<volScalarField> + const auto& rho = mesh_.lookupObject<volScalarField> ( IOobject::groupName(rhoName_, U.group()) ); diff --git a/src/finiteVolume/cfdTools/general/porosityModel/powerLaw/powerLaw.H b/src/finiteVolume/cfdTools/general/porosityModel/powerLaw/powerLaw.H index 3d97f2786fb4d4fa98d10cfc4cd5a8b2f383ba51..305e60e5e3c265ea5c9ac4f54454da1efbdc322c 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/powerLaw/powerLaw.H +++ b/src/finiteVolume/cfdTools/general/porosityModel/powerLaw/powerLaw.H @@ -119,7 +119,7 @@ public: ); //- Destructor - virtual ~powerLaw(); + virtual ~powerLaw() = default; // Member Functions diff --git a/src/finiteVolume/cfdTools/general/porosityModel/powerLaw/powerLawTemplates.C b/src/finiteVolume/cfdTools/general/porosityModel/powerLaw/powerLawTemplates.C index 7ed3d2ead772cf7eaeebb3033490046a8a933a69..30df618f66ae5c415dfaa36ade16d44ad7ebd620 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/powerLaw/powerLawTemplates.C +++ b/src/finiteVolume/cfdTools/general/porosityModel/powerLaw/powerLawTemplates.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -37,14 +37,12 @@ void Foam::porosityModels::powerLaw::apply const scalar C0 = C0_; const scalar C1m1b2 = (C1_ - 1.0)/2.0; - forAll(cellZoneIDs_, zoneI) + for (const label zonei : cellZoneIDs_) { - const labelList& cells = mesh_.cellZones()[cellZoneIDs_[zoneI]]; + const labelList& cells = mesh_.cellZones()[zonei]; - forAll(cells, i) + for (const label celli : cells) { - const label celli = cells[i]; - Udiag[celli] += V[celli]*rho[celli]*C0*pow(magSqr(U[celli]), C1m1b2); } @@ -63,14 +61,12 @@ void Foam::porosityModels::powerLaw::apply const scalar C0 = C0_; const scalar C1m1b2 = (C1_ - 1.0)/2.0; - forAll(cellZoneIDs_, zoneI) + for (const label zonei : cellZoneIDs_) { - const labelList& cells = mesh_.cellZones()[cellZoneIDs_[zoneI]]; + const labelList& cells = mesh_.cellZones()[zonei]; - forAll(cells, i) + for (const label celli : cells) { - const label celli = cells[i]; - AU[celli] = AU[celli] + I*(rho[celli]*C0*pow(magSqr(U[celli]), C1m1b2)); } diff --git a/src/finiteVolume/cfdTools/general/porosityModel/solidification/solidification.C b/src/finiteVolume/cfdTools/general/porosityModel/solidification/solidification.C index 68d3edcf774cab5822d157e55284aa0218558c06..50276c115bdeb60fe9c21b880e45b167e992e596 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/solidification/solidification.C +++ b/src/finiteVolume/cfdTools/general/porosityModel/solidification/solidification.C @@ -99,7 +99,7 @@ void Foam::porosityModels::solidification::correct if (UEqn.dimensions() == dimForce) { - const volScalarField& rho = mesh_.lookupObject<volScalarField> + const auto& rho = mesh_.lookupObject<volScalarField> ( IOobject::groupName(rhoName_, U.group()) ); @@ -138,7 +138,7 @@ void Foam::porosityModels::solidification::correct if (UEqn.dimensions() == dimForce) { - const volScalarField& rho = mesh_.lookupObject<volScalarField> + const auto& rho = mesh_.lookupObject<volScalarField> ( IOobject::groupName(rhoName_, U.group()) ); diff --git a/src/finiteVolume/cfdTools/general/porosityModel/solidification/solidification.H b/src/finiteVolume/cfdTools/general/porosityModel/solidification/solidification.H index 3922d54775448f60ee3214f473bcb34700c1452a..ee83b6ee7e00a397579e2c9e35b1ca187fb9e3e8 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/solidification/solidification.H +++ b/src/finiteVolume/cfdTools/general/porosityModel/solidification/solidification.H @@ -63,14 +63,9 @@ Description // use the global coordinate system coordinateSystem { - type cartesian; origin (0 0 0); - coordinateRotation - { - type axesRotation; - e1 (1 0 0); - e2 (0 1 0); - } + e1 (1 0 0); + e2 (0 1 0); } } \endverbatim diff --git a/src/finiteVolume/cfdTools/general/porosityModel/solidification/solidificationTemplates.C b/src/finiteVolume/cfdTools/general/porosityModel/solidification/solidificationTemplates.C index d9ea04d59eb99dcbed77a68179efad455eb17fd7..9abd56a62f4f2db0ff792ff0b6bb2905f1ac5cb2 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/solidification/solidificationTemplates.C +++ b/src/finiteVolume/cfdTools/general/porosityModel/solidification/solidificationTemplates.C @@ -38,18 +38,17 @@ void Foam::porosityModels::solidification::apply const volVectorField& U ) const { - const volScalarField& T = mesh_.lookupObject<volScalarField> + const auto& T = mesh_.lookupObject<volScalarField> ( IOobject::groupName(TName_, U.group()) ); - forAll(cellZoneIDs_, zoneI) + for (const label zonei : cellZoneIDs_) { - const labelList& cells = mesh_.cellZones()[cellZoneIDs_[zoneI]]; + const labelList& cells = mesh_.cellZones()[zonei]; - forAll(cells, i) + for (const label celli : cells) { - const label celli = cells[i]; Udiag[celli] += V[celli]*alpha[celli]*rho[celli]*D_->value(T[celli]); } @@ -66,18 +65,17 @@ void Foam::porosityModels::solidification::apply const volVectorField& U ) const { - const volScalarField& T = mesh_.lookupObject<volScalarField> + const auto& T = mesh_.lookupObject<volScalarField> ( IOobject::groupName(TName_, U.group()) ); - forAll(cellZoneIDs_, zoneI) + for (const label zonei : cellZoneIDs_) { - const labelList& cells = mesh_.cellZones()[cellZoneIDs_[zoneI]]; + const labelList& cells = mesh_.cellZones()[zonei]; - forAll(cells, i) + for (const label celli : cells) { - const label celli = cells[i]; AU[celli] += tensor::I*alpha[celli]*rho[celli]*D_->value(T[celli]); } @@ -100,7 +98,7 @@ void Foam::porosityModels::solidification::apply } else { - const volScalarField& alpha = mesh_.lookupObject<volScalarField> + const auto& alpha = mesh_.lookupObject<volScalarField> ( IOobject::groupName(alphaName_, U.group()) ); @@ -124,7 +122,7 @@ void Foam::porosityModels::solidification::apply } else { - const volScalarField& alpha = mesh_.lookupObject<volScalarField> + const auto& alpha = mesh_.lookupObject<volScalarField> ( IOobject::groupName(alphaName_, U.group()) ); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/cylindricalInletVelocity/cylindricalInletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/cylindricalInletVelocity/cylindricalInletVelocityFvPatchVectorField.H index 833714cce15350444fab4fdf34837db49e65176e..f97698335d29d63878107e49fa2fb1f6710fda7c 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/cylindricalInletVelocity/cylindricalInletVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/cylindricalInletVelocity/cylindricalInletVelocityFvPatchVectorField.H @@ -29,7 +29,7 @@ Group Description This boundary condition describes an inlet vector boundary condition in - cylindrical co-ordinates given a central axis, central point, rpm, axial + cylindrical coordinates given a central axis, central point, rpm, axial and radial velocity. Usage diff --git a/src/finiteVolume/fields/fvPatchFields/derived/phaseHydrostaticPressure/phaseHydrostaticPressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/phaseHydrostaticPressure/phaseHydrostaticPressureFvPatchScalarField.H index 94b71defce7109cac83e51561ddbd2b4f79c39a5..94ae12a9fd8faf53c8dbd3a389a499aee0911e26 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/phaseHydrostaticPressure/phaseHydrostaticPressureFvPatchScalarField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/phaseHydrostaticPressure/phaseHydrostaticPressureFvPatchScalarField.H @@ -39,7 +39,7 @@ Description \vartable p_{hyd} | hyrostatic pressure [Pa] p_{ref} | reference pressure [Pa] - x_{ref} | reference point in Cartesian co-ordinates + x_{ref} | reference point in Cartesian coordinates \rho | density (assumed uniform) g | acceleration due to gravity [m/s2] \endtable diff --git a/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.H index 485a417bda5770936b57e67acb9c072bb69691ed..19e85084858193fba3917439a88eb384acc7876e 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.H @@ -33,7 +33,7 @@ Description Usage \table Property | Description | Required | Default value - origin | origin of rotation in Cartesian co-ordinates | yes| + origin | origin of rotation in Cartesian coordinates | yes| axis | axis of rotation | yes | omega | angular velocty of the frame [rad/s] | yes | \endtable diff --git a/src/finiteVolume/fields/fvPatchFields/derived/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.H index d56fcc8f2e983d608b40003c6ad08cd151bc884b..5b22c192b44e89ad3b1290868699a5b216b110d6 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.H @@ -29,7 +29,7 @@ Group Description This boundary condition describes an inlet vector boundary condition in - swirl co-ordinates given a central axis, central point, axial, radial and + swirl coordinates given a central axis, central point, axial, radial and tangential velocity profiles. Usage diff --git a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/eddy/eddy.H b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/eddy/eddy.H index be527caa2f3813cc74a599977fef50eac7d78a19..c1c91145b7a908e525bd715997da5f4f00d47a45 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/eddy/eddy.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/eddy/eddy.H @@ -42,19 +42,18 @@ SourceFiles #include "point.H" #include "tensor.H" #include "Random.H" -#include "coordinateSystem.H" +#include "boundBox.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -// Forward declaration of classes +// Forward declarations +class eddy; class Istream; class Ostream; -// Forward declaration of friend functions and operators -class eddy; bool operator==(const eddy& a, const eddy& b); bool operator!=(const eddy& a, const eddy& b); Istream& operator>>(Istream& is, eddy& e); @@ -87,7 +86,7 @@ class eddy //- Time-averaged intensity vector alpha_; - //- Co-ordinate system transformation from local to global axes + //- Coordinate system transformation from local to global axes // X-direction aligned with max stress eigenvalue tensor Rpg_; @@ -161,7 +160,7 @@ public: //- Return the time-averaged intensity inline const vector& alpha() const; - //- Return the co-ordinate system transformation from local + //- Return the coordinate system transformation from local // principal to global axes inline const tensor& Rpg() const; diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.H index fb61f2f0143e0cf505e45192d7c8f88bc61b4103..7497873c39abdc08eab11cf70b03d3c11cf346f3 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.H @@ -39,7 +39,7 @@ Description \vartable p_{hyd} | hyrostatic pressure [Pa] p_{ref} | reference pressure [Pa] - x_{ref} | reference point in Cartesian co-ordinates + x_{ref} | reference point in Cartesian coordinates \rho | density (assumed uniform) g | acceleration due to gravity [m/s2] \endtable diff --git a/src/finiteVolume/interpolation/interpolation/interpolationCellPoint/cellPointWeight/cellPointWeight.H b/src/finiteVolume/interpolation/interpolation/interpolationCellPoint/cellPointWeight/cellPointWeight.H index ed064281c1d973370e328a93738cc45632705c64..80b2e5a835bd5759463a07ec74887741bc5d3ea3 100644 --- a/src/finiteVolume/interpolation/interpolation/interpolationCellPoint/cellPointWeight/cellPointWeight.H +++ b/src/finiteVolume/interpolation/interpolation/interpolationCellPoint/cellPointWeight/cellPointWeight.H @@ -89,7 +89,7 @@ public: //- Debug switch static int debug; - //- Tolerance used in calculating barycentric co-ordinates + //- Tolerance used in calculating barycentric coordinates // (applied to normalised values) static scalar tol; diff --git a/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/pointMVCWeight.H b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/pointMVCWeight.H index a76fc7f951eca91837c87bdc19b97bb0f9489ba0..2228f1a5b37d81ddd11e4c39351c3248abd74aa0 100644 --- a/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/pointMVCWeight.H +++ b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/pointMVCWeight.H @@ -107,7 +107,7 @@ public: //- Debug switch static int debug; - //- Tolerance used in calculating barycentric co-ordinates + //- Tolerance used in calculating barycentric coordinates // (applied to normalised values) static scalar tol; diff --git a/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C b/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C index 2c4ea97f34d8a7b837714a213d23bf69dfef30cb..4ea66e73f902da9f60016f1d46d175f84435002d 100644 --- a/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C +++ b/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -56,23 +56,19 @@ fieldCoordinateSystemTransform : fvMeshFunctionObject(name, runTime, dict), fieldSet_(mesh_), - coordSys_(mesh_, dict.subDict("coordinateSystem")) + csPtr_ + ( + coordinateSystem::New(mesh_, dict, "coordinateSystem") + ) { read(dict); Info<< type() << " " << name << ":" << nl << " Applying transformation from global Cartesian to local " - << coordSys_ << nl << endl; + << *csPtr_ << nl << endl; } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::fieldCoordinateSystemTransform:: -~fieldCoordinateSystemTransform() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::word diff --git a/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.H b/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.H index dbc0446cb7f9a4714ce2e09b07738aba109714ee..21c03b0cd9ec3917cfe58bc97d1709c4ce65bde9 100644 --- a/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.H +++ b/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -29,7 +29,7 @@ Group Description Transforms a user-specified selection of fields from global Cartesian - co-ordinates to a local co-ordinate system. The fields are run-time + coordinates to a local coordinate system. The fields are run-time modifiable. Usage @@ -52,9 +52,9 @@ Usage origin (0.001 0 0); coordinateRotation { - type axesRotation; - e1 (1 0.15 0); - e3 (0 0 -1); + type axes; + e1 (1 0.15 0); + e3 (0 0 -1); } } } @@ -65,7 +65,7 @@ Usage Property | Description | Required | Default value type | type name: fieldCoordinateSystemTransform | yes | fields | list of fields to be transformed |yes | - coordinateSystem | local co-ordinate system | yes | + coordinateSystem | local coordinate system | yes | \endtable See also @@ -107,8 +107,8 @@ protected: //- Fields to transform volFieldSelection fieldSet_; - //- Co-ordinate system to transform to - coordinateSystem coordSys_; + //- Coordinate system to transform to + autoPtr<coordinateSystem> csPtr_; // Protected Member Functions @@ -143,7 +143,7 @@ public: //- Destructor - virtual ~fieldCoordinateSystemTransform(); + virtual ~fieldCoordinateSystemTransform() = default; // Member Functions diff --git a/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformTemplates.C b/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformTemplates.C index 2e26c96343c6ca95d2c1973947b764c6fe3f3969..cd67102d1263d16c4cd121ac1f6fdd29ec71eaec 100644 --- a/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformTemplates.C +++ b/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformTemplates.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -41,7 +41,7 @@ void Foam::functionObjects::fieldCoordinateSystemTransform::transformField store ( transFieldName, - Foam::transform(dimensionedTensor(coordSys_.R().R()), field) + Foam::transform(dimensionedTensor(csPtr_->R().R()), field) ); } diff --git a/src/functionObjects/field/fieldCoordinateSystemTransform/postProcessingDict b/src/functionObjects/field/fieldCoordinateSystemTransform/postProcessingDict index c1ffcfcb73bfff4762fbae6ead7a6556e2b2ff89..d2604fe00208fcec93c932a6969354e26e3ce2f3 100644 --- a/src/functionObjects/field/fieldCoordinateSystemTransform/postProcessingDict +++ b/src/functionObjects/field/fieldCoordinateSystemTransform/postProcessingDict @@ -41,12 +41,8 @@ functions coordinateSystem { origin (0 0 0); - coordinateRotation - { - type axesRotation; - e1 (1 0.15 0); - e3 (0 0 -1); - } + e1 (1 0.15 0); + e3 (0 0 -1); } } } diff --git a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C index a75a4e1bd64834a1365b377e93ed061bd0dc5ccc..2091d670758c515845617b319a4ef8abdd36f885 100644 --- a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C +++ b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C @@ -352,10 +352,17 @@ bool Foam::functionObjects::regionSizeDistribution::read(const dictionary& dict) if (dict.found("coordinateSystem")) { - coordSysPtr_.reset(new coordinateSystem(obr_, dict)); + coordSysPtr_.reset + ( + coordinateSystem::New(obr_, dict, "coordinateSystem") + ); Info<< "Transforming all vectorFields with coordinate system " - << coordSysPtr_().name() << endl; + << coordSysPtr_->name() << endl; + } + else + { + coordSysPtr_.clear(); } if (isoPlanes_) @@ -900,10 +907,10 @@ bool Foam::functionObjects::regionSizeDistribution::write() { Log << "Transforming vector field " << fldName << " with coordinate system " - << coordSysPtr_().name() + << coordSysPtr_->name() << endl; - fld = coordSysPtr_().localVector(fld); + fld = coordSysPtr_->localVector(fld); } diff --git a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.H b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.H index 1ab6800d10efbdaa07a12817eeda2ead919112ac..b5f1168c819ae7f14989bd1783ed379e83b3ba94 100644 --- a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.H +++ b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.H @@ -113,8 +113,8 @@ Usage maxDiameter | maximum region equivalent diameter | yes | minDiameter | minimum region equivalent diameter | no | 0 setFormat | writing format | yes | - origin | origin of local co-ordinate system | yes | - coordinateRoation | orientation of local co-ordinate system | no + origin | origin of local coordinate system | yes | + coordinateRoation | orientation of local coordinate system | no log | Log to standard output | no | yes isoPlanes | switch for isoPlanes | no | false origin | origin of the plane when isoPlanes is used | no | none diff --git a/src/functionObjects/forces/forces/forces.C b/src/functionObjects/forces/forces/forces.C index 681ac2b2514c6f793849e7d18e07e8b51efd3f8a..e302d29135584ad926aa49f2fbaada270a95d59c 100644 --- a/src/functionObjects/forces/forces/forces.C +++ b/src/functionObjects/forces/forces/forces.C @@ -29,6 +29,7 @@ License #include "turbulentTransportModel.H" #include "turbulentFluidThermoModel.H" #include "addToRunTimeSelectionTable.H" +#include "cartesianCS.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -37,7 +38,6 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(forces, 0); - addToRunTimeSelectionTable(functionObject, forces, dictionary); } } @@ -882,7 +882,19 @@ bool Foam::functionObjects::forces::read(const dictionary& dict) // specified directly, from coordinate system, or implicitly (0 0 0) if (!dict.readIfPresent<point>("CofR", coordSys_.origin())) { - coordSys_ = coordinateSystem(obr_, dict); + // The 'coordinateSystem' sub-dictionary is optional, + // but enforce use of cartesianCS. + + if (dict.found("coordinateSystem")) + { + // Can use New() for access to indirect (global) CS. + coordSys_ = coordinateSystem::New(obr_, dict); + } + else + { + coordSys_ = coordinateSystem(dict); + } + localSystem_ = true; } diff --git a/src/functionObjects/forces/forces/forces.H b/src/functionObjects/forces/forces/forces.H index 4a27514c6abe370f742caab8329c7759c057539e..7ddab4a55b4a505d9502ccbc561d8ba223b664b6 100644 --- a/src/functionObjects/forces/forces/forces.H +++ b/src/functionObjects/forces/forces/forces.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -32,21 +32,21 @@ Description skin-friction forces over a given list of patches, and the resistance from porous zones. - Forces and moments are calculated, with optional co-ordinate system and + Forces and moments are calculated, with optional coordinate system and writing of binned data, where force and moment contributions are collected into a user-defined number of bins that span the input geometries for a user-defined direction vector. Data is written into multiple files in the postProcessing/\<functionObjectName\> directory: - - force.dat : forces in global Cartesian co-ordinate system - - moment.dat : moments in global Cartesian co-ordinate system - - forceBin.dat : force bins in global Cartesian co-ordinate system - - momentBin.dat : moment bins in global Cartesian co-ordinate system - - localForce.dat : forces in local co-ordinate system - - localMoment.dat : moments in local co-ordinate system - - localForceBin.dat : force bins in local co-ordinate system - - localMomentBin.dat : moment bins in local co-ordinate system + - force.dat : forces in global Cartesian coordinate system + - moment.dat : moments in global Cartesian coordinate system + - forceBin.dat : force bins in global Cartesian coordinate system + - momentBin.dat : moment bins in global Cartesian coordinate system + - localForce.dat : forces in local coordinate system + - localMoment.dat : moments in local coordinate system + - localForceBin.dat : force bins in local coordinate system + - localMomentBin.dat : moment bins in local coordinate system Usage Example of function object specification: @@ -107,13 +107,19 @@ Note CofR (0 0 0); \endverbatim or + \verbatim + origin (0 0 0); + e1 (0 1 0); + e3 (0 0 1); + \endverbatim + or \verbatim coordinateSystem { origin (0 0 0); coordinateRotation { - type axesRotation; + type axes; e3 (0 0 1); e1 (1 0 0); } @@ -136,7 +142,7 @@ SourceFiles #include "fvMeshFunctionObject.H" #include "writeFile.H" -#include "coordinateSystem.H" +#include "cartesianCS.H" #include "volFieldsFwd.H" #include "HashSet.H" #include "Tuple2.H" @@ -224,9 +230,9 @@ protected: scalar pRef_; //- Coordinate system used when evaluting forces/moments - coordinateSystem coordSys_; + cartesianCS coordSys_; - //- Flag to indicate whether we are using a local co-ordinate sys + //- Flag to indicate whether we are using a local coordinates bool localSystem_; //- Flag to include porosity effects diff --git a/src/fvOptions/sources/derived/explicitPorositySource/explicitPorositySource.H b/src/fvOptions/sources/derived/explicitPorositySource/explicitPorositySource.H index 2efe55db43e39013062adde5ff3656dcba3f9217..b52dd45e8eca698c75abfb7588d6ff1b46394152 100644 --- a/src/fvOptions/sources/derived/explicitPorositySource/explicitPorositySource.H +++ b/src/fvOptions/sources/derived/explicitPorositySource/explicitPorositySource.H @@ -44,14 +44,9 @@ Usage coordinateSystem { - type cartesian; origin (0 0 0); - coordinateRotation - { - type axesRotation; - e1 (0.70710678 0.70710678 0); - e2 (0 0 1); - } + e1 (0.70710678 0.70710678 0); + e2 (0 0 1); } } } diff --git a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C index 39cb29279d3c69f4b65c779e62b9ea13a3936089..0783ef6c55e450fe6aa9a0d999689aff5ece91e9 100644 --- a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C +++ b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C @@ -29,6 +29,7 @@ License #include "fvcGrad.H" #include "zeroGradientFvPatchField.H" #include "basicThermo.H" +#include "cylindricalTransform.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // @@ -59,7 +60,7 @@ const Foam::coordinateSystem& Foam::fv::jouleHeatingSource::coordSys() const if (!coordSysPtr_.valid()) { FatalErrorInFunction - << "Co-ordinate system invalid" + << "Coordinate system invalid" << abort(FatalError); } @@ -73,27 +74,36 @@ Foam::fv::jouleHeatingSource::transformSigma const volVectorField& sigmaLocal ) const { - tmp<volSymmTensorField> tsigma + auto tsigma = tmp<volSymmTensorField>::New ( - new volSymmTensorField + IOobject ( - IOobject - ( - sigmaName, - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - false - ), + sigmaName, + mesh_.time().timeName(), mesh_, - dimensionedSymmTensor(sigmaLocal.dimensions(), Zero), - zeroGradientFvPatchField<symmTensor>::typeName - ) + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + mesh_, + dimensionedSymmTensor(sigmaLocal.dimensions(), Zero), + zeroGradientFvPatchField<symmTensor>::typeName ); + auto& sigma = tsigma.ref(); - volSymmTensorField& sigma = tsigma.ref(); - sigma.primitiveFieldRef() = coordSys().R().transformVector(sigmaLocal); + if (coordSys().R().uniform()) + { + sigma.primitiveFieldRef() = coordSys().R().transformVector(sigmaLocal); + } + else + { + const cylindricalTransform<pointField> cylTrans + ( + coordSys(), + mesh_.cellCentres() + ); + sigma.primitiveFieldRef() = cylTrans.transformVector(sigmaLocal); + } sigma.correctBoundaryConditions(); diff --git a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.H b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.H index 4842cfa1edc8dc1526662317f1727d7f4ec6b994..4d5ae4bbd1c2c4a081ad09720d583ec058e5ec8d 100644 --- a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.H +++ b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.H @@ -91,15 +91,9 @@ Usage coordinateSystem { - type cartesian; - origin (0 0 0); - - coordinateRotation - { - type axesRotation; - e1 (1 0 0); - e3 (0 0 1); - } + origin (0 0 0); + e1 (1 0 0); + e3 (0 0 1); } // Optionally specify sigma as a function of temperature @@ -179,7 +173,7 @@ class jouleHeatingSource //- Electrical conductivity as a vector function of temperature autoPtr<Function1<vector>> vectorSigmaVsTPtr_; - //- Co-ordinate system - used for vectorial electrical conductivity + //- Coordinate system - used for vectorial electrical conductivity autoPtr<coordinateSystem> coordSysPtr_; //- Current time index (used for updating) @@ -194,8 +188,7 @@ class jouleHeatingSource //- No copy assignment void operator=(const jouleHeatingSource&) = delete; - //- Return the co-ordinate system for anisotropic electrical - // conductivity + //- The coordinate system for anisotropic electrical conductivity const coordinateSystem& coordSys() const; //- Transform the anisotropic electrical conductivity into global system diff --git a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceIO.C b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceIO.C index ce4dde6f95ee0c2b9fd5cc807e0ce638b5639f38..3f5ccdad1e97d9396d87cd6da68aac76b4943f78 100644 --- a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceIO.C +++ b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -32,20 +32,26 @@ bool Foam::fv::jouleHeatingSource::read(const dictionary& dict) if (option::read(dict)) { coeffs_.readIfPresent("T", TName_); - coeffs_.lookup("anisotropicElectricalConductivity") - >> anisotropicElectricalConductivity_; + coeffs_.read + ( + "anisotropicElectricalConductivity", + anisotropicElectricalConductivity_ + ); if (anisotropicElectricalConductivity_) { Info<< " Using vector electrical conductivity" << endl; + coordSysPtr_ = + coordinateSystem::New(mesh_, coeffs_, "coordinateSystem"); + initialiseSigma(coeffs_, vectorSigmaVsTPtr_); - coordSysPtr_ = coordinateSystem::New(mesh_, coeffs_); } else { Info<< " Using scalar electrical conductivity" << endl; + coordSysPtr_.clear(); initialiseSigma(coeffs_, scalarSigmaVsTPtr_); } diff --git a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C index ba2b264d5200a96c412294fbdb1396ce8f3e8ada..d2f826463f3c4cde9a28489a349ecbd373253f37 100644 --- a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C +++ b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -84,15 +84,12 @@ void Foam::fv::rotorDiskSource::checkData() { case ifFixed: { - coeffs_.lookup("inletVelocity") >> inletVelocity_; + coeffs_.read("inletVelocity", inletVelocity_); break; } case ifSurfaceNormal: { - scalar UIn - ( - readScalar(coeffs_.lookup("inletNormalVelocity")) - ); + scalar UIn(coeffs_.get<scalar>("inletNormalVelocity")); inletVelocity_ = -coordSys_.R().e3()*UIn; break; } @@ -263,7 +260,7 @@ void Foam::fv::rotorDiskSource::setFaceArea(vector& axis, const bool correct) void Foam::fv::rotorDiskSource::createCoordinateSystem() { - // Construct the local rotor co-ordinate system + // Construct the local rotor coordinate system vector origin(Zero); vector axis(Zero); vector refDir(Zero); @@ -324,7 +321,7 @@ void Foam::fv::rotorDiskSource::createCoordinateSystem() // Correct the axis direction using a point above the rotor { - vector pointAbove(coeffs_.lookup("pointAbove")); + vector pointAbove(coeffs_.get<vector>("pointAbove")); vector dir = pointAbove - origin; dir /= mag(dir); if ((dir & axis) < 0) @@ -333,18 +330,7 @@ void Foam::fv::rotorDiskSource::createCoordinateSystem() } } - coeffs_.lookup("refDirection") >> refDir; - - cylindrical_.reset - ( - new cylindrical - ( - mesh_, - axis, - origin, - cells_ - ) - ); + coeffs_.read("refDirection", refDir); // Set the face areas and apply correction to calculated axis // e.g. if cellZone is more than a single layer in thickness @@ -354,20 +340,9 @@ void Foam::fv::rotorDiskSource::createCoordinateSystem() } case gmSpecified: { - coeffs_.lookup("origin") >> origin; - coeffs_.lookup("axis") >> axis; - coeffs_.lookup("refDirection") >> refDir; - - cylindrical_.reset - ( - new cylindrical - ( - mesh_, - axis, - origin, - cells_ - ) - ); + coeffs_.read("origin", origin); + coeffs_.read("axis", axis); + coeffs_.read("refDirection", refDir); setFaceArea(axis, false); @@ -383,7 +358,7 @@ void Foam::fv::rotorDiskSource::createCoordinateSystem() } } - coordSys_ = cylindricalCS("rotorCoordSys", origin, axis, refDir, false); + coordSys_ = cylindricalCS(origin, axis, refDir, false); const scalar sumArea = gSum(area_); const scalar diameter = Foam::sqrt(4.0*sumArea/mathematical::pi); @@ -407,7 +382,7 @@ void Foam::fv::rotorDiskSource::constructGeometry() { const label celli = cells_[i]; - // Position in (planar) rotor co-ordinate system + // Position in (planar) rotor coordinate system x_[i] = coordSys_.localPosition(C[celli]); // Cache max radius @@ -486,7 +461,6 @@ Foam::fv::rotorDiskSource::rotorDiskSource invR_(cells_.size(), I), area_(cells_.size(), 0.0), coordSys_(false), - cylindrical_(), rMax_(0.0), trim_(trimModel::New(*this, coeffs_)), blade_(coeffs_.subDict("blade")), @@ -523,7 +497,7 @@ void Foam::fv::rotorDiskSource::addSup ); // Read the reference density for incompressible flow - coeffs_.lookup("rhoRef") >> rhoRef_; + coeffs_.read("rhoRef", rhoRef_); const vectorField Uin(inflowVelocity(eqn.psi())); trim_->correct(Uin, force); @@ -576,32 +550,29 @@ bool Foam::fv::rotorDiskSource::read(const dictionary& dict) { if (cellSetOption::read(dict)) { - coeffs_.lookup("fields") >> fieldNames_; + coeffs_.read("fields", fieldNames_); applied_.setSize(fieldNames_.size(), false); - // Read co-ordinate system/geometry invariant properties - scalar rpm(readScalar(coeffs_.lookup("rpm"))); + // Read coordinate system/geometry invariant properties + scalar rpm(coeffs_.get<scalar>("rpm")); omega_ = rpm/60.0*mathematical::twoPi; - coeffs_.lookup("nBlades") >> nBlades_; + coeffs_.read("nBlades", nBlades_); inletFlow_ = inletFlowTypeNames_.lookup("inletFlowType", coeffs_); - coeffs_.lookup("tipEffect") >> tipEffect_; + coeffs_.read("tipEffect", tipEffect_); const dictionary& flapCoeffs(coeffs_.subDict("flapCoeffs")); - flapCoeffs.lookup("beta0") >> flap_.beta0; - flapCoeffs.lookup("beta1c") >> flap_.beta1c; - flapCoeffs.lookup("beta2s") >> flap_.beta2s; - flap_.beta0 = degToRad(flap_.beta0); - flap_.beta1c = degToRad(flap_.beta1c); - flap_.beta2s = degToRad(flap_.beta2s); + flap_.beta0 = degToRad(flapCoeffs.get<scalar>("beta0")); + flap_.beta1c = degToRad(flapCoeffs.get<scalar>("beta1c")); + flap_.beta2s = degToRad(flapCoeffs.get<scalar>("beta2s")); - // Create co-ordinate system + // Create coordinate system createCoordinateSystem(); - // Read co-ordinate system dependent properties + // Read coordinate system dependent properties checkData(); constructGeometry(); @@ -616,10 +587,8 @@ bool Foam::fv::rotorDiskSource::read(const dictionary& dict) return true; } - else - { - return false; - } + + return false; } diff --git a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.H b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.H index 2414d0a703dfb3b095af0ac1326504caa1e691d9..98fa7e00472554237045c617d99355c0511b661d 100644 --- a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.H +++ b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -78,8 +78,8 @@ Usage Where: Valid options for the \c geometryMode entry include: - - auto : determine rototor co-ord system from cells - - specified : specified co-ord system + - auto : determine rotor coordinate system from cells + - specified : specified coordinate system Valid options for the \c inletFlowType entry include: - fixed : specified velocity @@ -102,7 +102,6 @@ SourceFiles #include "cellSetOption.H" #include "cylindricalCS.H" -#include "cylindrical.H" #include "Enum.H" #include "bladeModel.H" #include "profileModelList.H" @@ -113,7 +112,7 @@ SourceFiles namespace Foam { -// Forward declaration of classes +// Forward declarations class trimModel; namespace fv @@ -196,12 +195,9 @@ protected: //- Area [m2] List<scalar> area_; - //- Rotor local cylindrical co-ordinate system (r, theta, z) + //- Rotor local cylindrical coordinate system (r, theta, z) cylindricalCS coordSys_; - //- Rotor transformation co-ordinate system - autoPtr<cylindrical> cylindrical_; - //- Maximum radius scalar rMax_; @@ -223,7 +219,7 @@ protected: //- Set the face areas per cell, and optionally correct the rotor axis void setFaceArea(vector& axis, const bool correct); - //- Create the co-ordinate system + //- Create the coordinate system void createCoordinateSystem(); //- Construct geometry @@ -250,7 +246,6 @@ public: // Constructors - //- Construct from components rotorDiskSource ( @@ -280,7 +275,7 @@ public: // (Cylindrical r, theta, z) inline const List<point>& x() const; - //- Return the rotor co-ordinate system (r, theta, z) + //- Return the rotor coordinate system (r, theta, z) inline const cylindricalCS& coordSys() const; diff --git a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSourceI.H b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSourceI.H index e923790514390a98f8670493d6f183a127f7df92..ad4888de39e43ea62805ced770c97445aa2d7eb9 100644 --- a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSourceI.H +++ b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSourceI.H @@ -27,25 +27,25 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -Foam::scalar Foam::fv::rotorDiskSource::rhoRef() const +inline Foam::scalar Foam::fv::rotorDiskSource::rhoRef() const { return rhoRef_; } -Foam::scalar Foam::fv::rotorDiskSource::omega() const +inline Foam::scalar Foam::fv::rotorDiskSource::omega() const { return omega_; } -const Foam::List<Foam::point>& Foam::fv::rotorDiskSource::x() const +inline const Foam::List<Foam::point>& Foam::fv::rotorDiskSource::x() const { return x_; } -const Foam::cylindricalCS& Foam::fv::rotorDiskSource::coordSys() const +inline const Foam::cylindricalCS& Foam::fv::rotorDiskSource::coordSys() const { return coordSys_; } diff --git a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSourceTemplates.C b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSourceTemplates.C index f305281d53f389500562c64917eaf72097df302e..cac59a069ba2a46da9094c586625d802dc49ba7d 100644 --- a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSourceTemplates.C +++ b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSourceTemplates.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,6 +26,8 @@ License #include "rotorDiskSource.H" #include "volFields.H" #include "unitConversion.H" +#include "cylindricalTransform.H" +#include "pointIndList.H" using namespace Foam::constant; @@ -50,6 +52,14 @@ void Foam::fv::rotorDiskSource::calculate scalar AOAmin = GREAT; scalar AOAmax = -GREAT; + // Position dependent transformation + const cylindricalTransform<pointUIndList> + cylTrans + ( + coordSys_, + pointUIndList(mesh_.cellCentres(), cells_) + ); + forAll(cells_, i) { if (area_[i] > ROOTVSMALL) @@ -59,7 +69,7 @@ void Foam::fv::rotorDiskSource::calculate const scalar radius = x_[i].x(); // Transform velocity into local cylindrical reference frame - vector Uc = cylindrical_->invTransform(U[celli], i); + vector Uc = cylTrans.invTransform(U[celli], i); // Transform velocity into local coning system Uc = R_[i] & Uc; @@ -131,8 +141,8 @@ void Foam::fv::rotorDiskSource::calculate // Transform force from local coning system into rotor cylindrical localForce = invR_[i] & localForce; - // Transform force into global Cartesian co-ordinate system - force[celli] = cylindrical_->transform(localForce, i); + // Transform force into global Cartesian coordinate system + force[celli] = cylTrans.transform(localForce, i); if (divideVolume) { @@ -169,24 +179,21 @@ void Foam::fv::rotorDiskSource::writeField if (mesh_.time().writeTime() || writeNow) { - tmp<fieldType> tfield + auto tfield = tmp<fieldType>::New ( - new fieldType + IOobject ( - IOobject - ( - name, - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + name, + mesh_.time().timeName(), mesh_, - dimensioned<Type>(dimless, Zero) - ) + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensioned<Type>(dimless, Zero) ); - Field<Type>& field = tfield.ref().primitiveFieldRef(); + auto& field = tfield.ref().primitiveFieldRef(); if (cells_.size() != values.size()) { diff --git a/src/fvOptions/sources/interRegion/interRegionExplicitPorositySource/interRegionExplicitPorositySource.H b/src/fvOptions/sources/interRegion/interRegionExplicitPorositySource/interRegionExplicitPorositySource.H index 9ffc92ddc7506f00dc297055285c0000ab4b8704..012823c253d8d69436c97320eebe530b556a4d20 100644 --- a/src/fvOptions/sources/interRegion/interRegionExplicitPorositySource/interRegionExplicitPorositySource.H +++ b/src/fvOptions/sources/interRegion/interRegionExplicitPorositySource/interRegionExplicitPorositySource.H @@ -43,13 +43,9 @@ Description coordinateSystem { - origin (0 0 0); - coordinateRotation - { - type axesRotation; - e1 (0.70710678 0.70710678 0); - e2 (0 0 1); - } + origin (0 0 0); + e1 (0.70710678 0.70710678 0); + e2 (0 0 1); } } } diff --git a/src/lagrangian/basic/injectedParticle/injectedParticleIO.C b/src/lagrangian/basic/injectedParticle/injectedParticleIO.C index 9c5842682bbff1e50a4dbb2530b4aea301e0eb68..4fa325b9e4c5902e89d7f97db5e8ff9d964348fc 100644 --- a/src/lagrangian/basic/injectedParticle/injectedParticleIO.C +++ b/src/lagrangian/basic/injectedParticle/injectedParticleIO.C @@ -63,7 +63,7 @@ Foam::injectedParticle::injectedParticle if (readFields) { // After the base particle class has read the fields from file and - // constructed the necessary barycentric co-ordinates we can update the + // constructed the necessary barycentric coordinates we can update the // particle position on this mesh position_ = particle::position(); diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleCollector/ParticleCollector.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleCollector/ParticleCollector.C index 1a8255ae7d615056a3be9057c3adac92d0b371c6..d7e73d14333bf4d7bb3fd3edbafb95de12f78ac1 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleCollector/ParticleCollector.C +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleCollector/ParticleCollector.C @@ -207,7 +207,7 @@ void Foam::ParticleCollector<CloudType>::initConcentricCircles() faces_.setSize(nFace); area_.setSize(nFace); - coordSys_ = cylindricalCS("coordSys", origin, normal_[0], refDir, false); + coordSys_ = cylindricalCS(origin, normal_[0], refDir, false); List<label> ptIDs(identity(nPointPerRadius)); @@ -355,7 +355,7 @@ void Foam::ParticleCollector<CloudType>::collectParcelConcentricCircles return; } - // Intersection point in cylindrical co-ordinate system + // Intersection point in cylindrical coordinate system const point pCyl = coordSys_.localPosition(p1 + (d1/(d1 - d2))*(p2 - p1)); scalar r = pCyl[0]; diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleCollector/ParticleCollector.H b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleCollector/ParticleCollector.H index 12a13129ecb06b9178b24ec0ed2a8ff125e04123..ba235d22ac6e2d98b1a0fcf5c6daa4972899942a 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleCollector/ParticleCollector.H +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleCollector/ParticleCollector.H @@ -160,7 +160,7 @@ private: //- List of radii List<scalar> radius_; - //- Cylindrical co-ordinate system + //- Cylindrical coordinate system cylindricalCS coordSys_; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/KinematicLookupTableInjection.H b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/KinematicLookupTableInjection.H index 343e46dc1e505080b9e66bc706338702ed28cd5a..18ae20461aa604c7f6a36ca2e8c50561cbf58f76 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/KinematicLookupTableInjection.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/KinematicLookupTableInjection.H @@ -42,7 +42,7 @@ Description where: \plaintable - x, y, z | global cartesian co-ordinates [m] + x, y, z | global cartesian coordinates [m] u, v, w | global cartesian velocity components [m/s] d | diameter [m] rho | density [kg/m3] diff --git a/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/ReactingLookupTableInjection.H b/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/ReactingLookupTableInjection.H index dfe38af74cb04d9cb4e7c23b8d3c08531148e2db..152d5fe9529d47e607e65b5cb759eb0d6c2cb42b 100644 --- a/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/ReactingLookupTableInjection.H +++ b/src/lagrangian/intermediate/submodels/Reacting/InjectionModel/ReactingLookupTableInjection/ReactingLookupTableInjection.H @@ -39,7 +39,7 @@ Description ); where: - x, y, z = global cartesian co-ordinates [m] + x, y, z = global cartesian coordinates [m] u, v, w = global cartesian velocity components [m/s] d = diameter [m] rho = density [kg/m3] diff --git a/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/ReactingMultiphaseLookupTableInjection.H b/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/ReactingMultiphaseLookupTableInjection.H index 2541f65755f9a0ec90e2e8f183cf171485817999..e02579fb8dee5a71083dada913e48f7d30d68e97 100644 --- a/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/ReactingMultiphaseLookupTableInjection.H +++ b/src/lagrangian/intermediate/submodels/ReactingMultiphase/InjectionModel/ReactingMultiphaseLookupTableInjection/ReactingMultiphaseLookupTableInjection.H @@ -39,7 +39,7 @@ Description ); where: - x, y, z = global cartesian co-ordinates [m] + x, y, z = global cartesian coordinates [m] u, v, w = global cartesian velocity components [m/s] d = diameter [m] rho = density [kg/m3] diff --git a/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/ThermoLookupTableInjection.H b/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/ThermoLookupTableInjection.H index 7ef9b9227ca380ca92a0fdcf8f38edae8f841680..8c312b8eabe54852db0650d786358ff39cc0d357 100644 --- a/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/ThermoLookupTableInjection.H +++ b/src/lagrangian/intermediate/submodels/Thermodynamic/InjectionModel/ThermoLookupTableInjection/ThermoLookupTableInjection.H @@ -39,7 +39,7 @@ Description ); where: - x, y, z = global cartesian co-ordinates [m] + x, y, z = global cartesian coordinates [m] u, v, w = global cartesian velocity components [m/s] d = diameter [m] rho = density [kg/m3] diff --git a/src/mesh/blockMesh/blockEdges/arcEdge/arcEdge.C b/src/mesh/blockMesh/blockEdges/arcEdge/arcEdge.C index 793cc27b2f58e3eda49e5245cb502aa3b685a1ca..3bde3caedea7d89686d61bd47f7862ec8c364df8 100644 --- a/src/mesh/blockMesh/blockEdges/arcEdge/arcEdge.C +++ b/src/mesh/blockMesh/blockEdges/arcEdge/arcEdge.C @@ -98,8 +98,8 @@ Foam::cylindricalCS Foam::blockEdges::arcEdge::calcAngle() radius_ = mag(r3); - // set up and return the local coordinate system - return cylindricalCS("arcEdgeCS", centre, tempAxis, r1); + // set up and return the local coordinate system (in degrees) + return cylindricalCS(centre, tempAxis, r1, true); } diff --git a/src/mesh/blockMesh/blockEdges/arcEdge/arcEdge.H b/src/mesh/blockMesh/blockEdges/arcEdge/arcEdge.H index 078b8bd548cb5705f3ab078c0e950a2656763227..a81651c9607d3daccffcef746ad826289ed0e00e 100644 --- a/src/mesh/blockMesh/blockEdges/arcEdge/arcEdge.H +++ b/src/mesh/blockMesh/blockEdges/arcEdge/arcEdge.H @@ -56,6 +56,8 @@ class arcEdge // Private data point p1_, p2_, p3_; + + //- Arc angle (degrees) scalar angle_; scalar radius_; cylindricalCS cs_; @@ -101,15 +103,14 @@ public: //- Destructor - virtual ~arcEdge() - {} + virtual ~arcEdge() = default; // Member Functions //- Return the point position corresponding to the curve parameter // 0 <= lambda <= 1 - point position(const scalar) const; + point position(const scalar lambda) const; //- Return the length of the curve scalar length() const; diff --git a/src/meshTools/Make/files b/src/meshTools/Make/files index 56dc286f3a9cb384b481beb518e59699a10a006c..63ce4d8128deec2cba2d4d67f173927b363d2044 100644 --- a/src/meshTools/Make/files +++ b/src/meshTools/Make/files @@ -56,18 +56,22 @@ cellDist/wallPoint/wallPoint.C cellFeatures/cellFeatures.C -csys = coordinateSystems +csys = coordinate/systems $(csys)/coordinateSystem.C $(csys)/coordinateSystemNew.C $(csys)/coordinateSystems.C -$(csys)/cylindricalCS.C $(csys)/cartesianCS.C -$(csys)/coordinateRotation/axesRotation.C -$(csys)/coordinateRotation/coordinateRotation.C -$(csys)/coordinateRotation/coordinateRotationNew.C -$(csys)/coordinateRotation/EulerCoordinateRotation.C -$(csys)/coordinateRotation/STARCDCoordinateRotation.C -$(csys)/coordinateRotation/cylindrical.C +$(csys)/cylindricalCS.C +$(csys)/indirectCS.C + +crot = coordinate/rotation +$(crot)/axesRotation.C +$(crot)/axisAngleRotation.C +$(crot)/coordinateRotation.C +$(crot)/cylindricalRotation.C +$(crot)/identityRotation.C +$(crot)/EulerCoordinateRotation.C +$(crot)/STARCDCoordinateRotation.C polyMeshZipUpCells/polyMeshZipUpCells.C primitiveMeshGeometry/primitiveMeshGeometry.C diff --git a/src/meshTools/coordinate/rotation/EulerCoordinateRotation.C b/src/meshTools/coordinate/rotation/EulerCoordinateRotation.C new file mode 100644 index 0000000000000000000000000000000000000000..9da4ccf379f0ae9e4e1bd9c5e708d028af717861 --- /dev/null +++ b/src/meshTools/coordinate/rotation/EulerCoordinateRotation.C @@ -0,0 +1,194 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2017-2018 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 "EulerCoordinateRotation.H" +#include "unitConversion.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + namespace coordinateRotations + { + defineTypeName(euler); + + // Standard short name + addNamedToRunTimeSelectionTable + ( + coordinateRotation, + euler, + dictionary, + euler + ); + + // Longer name - Compat 1806 + addNamedToRunTimeSelectionTable + ( + coordinateRotation, + euler, + dictionary, + EulerRotation + ); + } +} + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::coordinateRotations::euler::calcPhiThetaPsi() +{ + scalar phi = angles_.component(vector::X); + scalar theta = angles_.component(vector::Y); + scalar psi = angles_.component(vector::Z); + + if (degrees_) + { + phi *= degToRad(); + theta *= degToRad(); + psi *= degToRad(); + } + + R_ = + tensor + ( + cos(phi)*cos(psi) - sin(phi)*sin(psi)*cos(theta), + -sin(phi)*cos(psi)*cos(theta) - cos(phi)*sin(psi), + sin(phi)*sin(theta), + + cos(phi)*sin(psi)*cos(theta) + sin(phi)*cos(psi), + cos(phi)*cos(psi)*cos(theta) - sin(phi)*sin(psi), + -cos(phi)*sin(theta), + + sin(psi)*sin(theta), + cos(psi)*sin(theta), + cos(theta) + ); + + Rtr_ = R_.T(); +} + + +void Foam::coordinateRotations::euler::assign(const dictionary& dict) +{ + dict.readCompat<vector>("angles", {{"rotation", 1806}}, angles_); + degrees_ = dict.lookupOrDefault("degrees", true); + + calcPhiThetaPsi(); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::coordinateRotations::euler::euler() +: + coordinateRotation(), + angles_(Zero), + degrees_(true) +{} + + +Foam::coordinateRotations::euler::euler(const euler& crot) +: + coordinateRotation(crot), + angles_(crot.angles_), + degrees_(crot.degrees_) +{} + + +Foam::coordinateRotations::euler::euler +( + const vector& phiThetaPsi, + const bool degrees +) +: + coordinateRotation(), + angles_(phiThetaPsi), + degrees_(degrees) +{ + calcPhiThetaPsi(); +} + + +Foam::coordinateRotations::euler::euler +( + const scalar phiAngle, + const scalar thetaAngle, + const scalar psiAngle, + const bool degrees +) +: + coordinateRotation(), + angles_(phiAngle, thetaAngle, psiAngle), + degrees_(degrees) +{ + calcPhiThetaPsi(); +} + + +Foam::coordinateRotations::euler::euler(const dictionary& dict) +: + euler() +{ + assign(dict); +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void Foam::coordinateRotations::euler::clear() +{ + coordinateRotation::clear(); + angles_ = Zero; + degrees_ = true; +} + + +void Foam::coordinateRotations::euler::write(Ostream& os) const +{ + os << "euler-angles(" << (degrees_ ? "degrees" : "radians") + << "): " << angles_; +} + + +void Foam::coordinateRotations::euler::writeEntry +( + const word& keyword, + Ostream& os +) const +{ + os.beginBlock(keyword); + + os.writeEntry("type", type()); + os.writeEntry("angles", angles_); + if (!degrees_) + { + os.writeEntry("degrees", "false"); + } + + os.endBlock(); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/meshTools/coordinate/rotation/EulerCoordinateRotation.H b/src/meshTools/coordinate/rotation/EulerCoordinateRotation.H new file mode 100644 index 0000000000000000000000000000000000000000..2790edad3b670e93c9f8dd4d0614471fda83d6b1 --- /dev/null +++ b/src/meshTools/coordinate/rotation/EulerCoordinateRotation.H @@ -0,0 +1,169 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2017-2018 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::coordinateRotations::euler + +Description + A coordinateRotation defined in the z-x-z (intrinsic) Euler convention. + + The 3 rotations are defined in the Euler intrinsic convention + (around Z, around X' and around Z''). + The order of the parameter arguments matches this rotation order. + + For reference and illustration, see + http://mathworld.wolfram.com/EulerAngles.html + and + https://en.wikipedia.org/wiki/Euler_angles#Conventions + + Note, however, the reverse transformation (local->global) is defined here. + + - the rotation angles are in degrees, unless otherwise explicitly specified: + + \verbatim + coordinateRotation + { + type euler; + angles (0 0 180); + } + \endverbatim + + \heading Dictionary entries + \table + Property | Description | Required | Default + type | type name: euler (previously EulerRotation) | yes | + angles | z-x-z rotation angles | yes | + degrees | angles in degrees | no | true + \endtable + +SourceFiles + EulerCoordinateRotation.C + +\*---------------------------------------------------------------------------*/ + +#ifndef coordinateRotations_euler_H +#define coordinateRotations_euler_H + +#include "coordinateRotation.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace coordinateRotations +{ + +/*---------------------------------------------------------------------------*\ + Class coordinateRotations::euler Declaration +\*---------------------------------------------------------------------------*/ + +class euler +: + public coordinateRotation +{ + // Private Data + + //- The rotation angles + vector angles_; + + //- Angles measured in degrees + bool degrees_; + + + // Private Member Functions + + //- Calculate transformation tensor for angles interpreted as + //- phi/theta/psi (z-x-z order) + void calcPhiThetaPsi(); + + //- Assign from dictionary + void assign(const dictionary& dict); + + +public: + + //- Runtime type information + TypeNameNoDebug("euler"); + + + // Constructors + + //- Construct null - an identity transform + euler(); + + //- Copy construct + euler(const euler& crot); + + //- Construct from rotation vector + euler(const vector& phiThetaPsi, const bool degrees); + + //- Construct from components of rotation vector + euler + ( + const scalar phiAngle, + const scalar thetaAngle, + const scalar psiAngle, + const bool degrees + ); + + //- Construct from dictionary + explicit euler(const dictionary& dict); + + //- Return clone + autoPtr<coordinateRotation> clone() const + { + return + autoPtr<coordinateRotation>::NewFrom + <coordinateRotations::euler>(*this); + } + + + // Member Functions + + //- Reset to an identity rotation + virtual void clear(); + + //- Write information + virtual void write(Ostream& os) const; + + //- Write dictionary entry + virtual void writeEntry(const word& keyword, Ostream& os) const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace coordinateRotations + + +//- Compatibility typedef 1806 +typedef coordinateRotations::euler EulerCoordinateRotation; + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/coordinate/rotation/STARCDCoordinateRotation.C b/src/meshTools/coordinate/rotation/STARCDCoordinateRotation.C new file mode 100644 index 0000000000000000000000000000000000000000..3f30ee086f4621e49bc9361712afc17cf30c6a9c --- /dev/null +++ b/src/meshTools/coordinate/rotation/STARCDCoordinateRotation.C @@ -0,0 +1,213 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2017-2018 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 "STARCDCoordinateRotation.H" +#include "unitConversion.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + namespace coordinateRotations + { + defineTypeName(starcd); + + // Standard short name + addNamedToRunTimeSelectionTable + ( + coordinateRotation, + starcd, + dictionary, + starcd + ); + + // Longer name - Compat 1806 + addNamedToRunTimeSelectionTable + ( + coordinateRotation, + starcd, + dictionary, + STARCDRotation + ); + } +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::coordinateRotations::starcd::calcTransform +( + const scalar rotZ, + const scalar rotX, + const scalar rotY, + const bool degrees +) +{ + scalar x = rotX; + scalar y = rotY; + scalar z = rotZ; + + if (degrees) + { + x *= degToRad(); + y *= degToRad(); + z *= degToRad(); + } + + R_ = + tensor + ( + cos(y)*cos(z) - sin(x)*sin(y)*sin(z), + -cos(x)*sin(z), + sin(x)*cos(y)*sin(z) + sin(y)*cos(z), + + cos(y)*sin(z) + sin(x)*sin(y)*cos(z), + cos(x)*cos(z), + sin(y)*sin(z) - sin(x)*cos(y)*cos(z), + + -cos(x)*sin(y), + sin(x), + cos(x)*cos(y) + ); + + Rtr_ = R_.T(); +} + + +void Foam::coordinateRotations::starcd::assign(const dictionary& dict) +{ + dict.readCompat<vector>("angles", {{"rotation", 1806}}, angles_); + degrees_ = dict.lookupOrDefault("degrees", true); + + calcTransform + ( + angles_.component(vector::X), // rotZ + angles_.component(vector::Y), // rotX + angles_.component(vector::Z), // rotY + degrees_ + ); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::coordinateRotations::starcd::starcd() +: + coordinateRotation(), + angles_(Zero), + degrees_(true) +{} + + +Foam::coordinateRotations::starcd::starcd(const starcd& crot) +: + coordinateRotation(crot), + angles_(crot.angles_), + degrees_(crot.degrees_) +{} + + +Foam::coordinateRotations::starcd::starcd +( + const vector& rotZrotXrotY, + const bool degrees +) +: + coordinateRotation(), + angles_(rotZrotXrotY), + degrees_(degrees) +{ + calcTransform + ( + rotZrotXrotY.component(vector::X), // rotZ + rotZrotXrotY.component(vector::Y), // rotX + rotZrotXrotY.component(vector::Z), // rotY + degrees_ + ); +} + + +Foam::coordinateRotations::starcd::starcd +( + const scalar rotZ, + const scalar rotX, + const scalar rotY, + const bool degrees +) +: + coordinateRotation(), + angles_(rotZ, rotX, rotY), + degrees_(degrees) +{ + calcTransform(rotZ, rotX, rotY, degrees_); +} + + +Foam::coordinateRotations::starcd::starcd(const dictionary& dict) +: + starcd() +{ + assign(dict); +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void Foam::coordinateRotations::starcd::clear() +{ + coordinateRotation::clear(); + angles_ = Zero; + degrees_ = true; +} + + +void Foam::coordinateRotations::starcd::write(Ostream& os) const +{ + os << "starcd-angles(" << (degrees_ ? "degrees" : "radians") + << "): " << angles_; +} + + +void Foam::coordinateRotations::starcd::writeEntry +( + const word& keyword, + Ostream& os +) const +{ + os.beginBlock(keyword); + + os.writeEntry("type", type()); + os.writeEntry("angles", angles_); + if (!degrees_) + { + os.writeEntry("degrees", "false"); + } + + os.endBlock(); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/meshTools/coordinate/rotation/STARCDCoordinateRotation.H b/src/meshTools/coordinate/rotation/STARCDCoordinateRotation.H new file mode 100644 index 0000000000000000000000000000000000000000..9f236338531d9109689feadc0f47d0e960d46c1a --- /dev/null +++ b/src/meshTools/coordinate/rotation/STARCDCoordinateRotation.H @@ -0,0 +1,168 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2017-2018 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::coordinateRotations::starcd + +Description + A coordinateRotation defined by the STAR-CD convention. + + The 3 rotations are defined in the STAR-CD convention + (around Z, around X' and around Y''). + The order of the parameter arguments matches this rotation order. + + - the rotation angles are in degrees, unless otherwise explicitly specified: + + \verbatim + coordinateRotation + { + type starcd; + angles (0 0 180); + } + \endverbatim + + \heading Dictionary entries + \table + Property | Description | Required | Default + type | type name: starcd (previously STARCDRotation) | yes | + angles | z-x-y rotation angles | yes | + degrees | angles in degrees | no | true + \endtable + +SourceFiles + STARCDCoordinateRotation.C + +\*---------------------------------------------------------------------------*/ + +#ifndef coordinateRotations_starcd_H +#define coordinateRotations_starcd_H + +#include "coordinateRotation.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace coordinateRotations +{ + +/*---------------------------------------------------------------------------*\ + Class coordinateRotations::starcd Declaration +\*---------------------------------------------------------------------------*/ + +class starcd +: + public coordinateRotation +{ + // Private Data + + //- The rotation angles + vector angles_; + + //- Angles measured in degrees + bool degrees_; + + + // Private Member Functions + + //- Calculate transformation tensor for angles interpreted as + //- rotZ, rotX, rotY + void calcTransform + ( + const scalar rotZ, + const scalar rotX, + const scalar rotY, + const bool degrees + ); + + //- Assign from dictionary + void assign(const dictionary& dict); + + +public: + + //- Runtime type information + TypeNameNoDebug("starcd"); + + + // Constructors + + //- Construct null - an identity transform + starcd(); + + //- Copy construct + starcd(const starcd& crot); + + //- Construct from rotation vector + starcd(const vector& rotZrotXrotY, const bool degrees); + + //- Construct from components of rotation vector + starcd + ( + const scalar rotZ, + const scalar rotX, + const scalar rotY, + const bool degrees + ); + + //- Construct from dictionary + explicit starcd(const dictionary& dict); + + //- Return clone + autoPtr<coordinateRotation> clone() const + { + return + autoPtr<coordinateRotation>::NewFrom + <coordinateRotations::starcd>(*this); + } + + + // Member Functions + + //- Reset to an identity rotation + virtual void clear(); + + //- Write information + virtual void write(Ostream& os) const; + + //- Write dictionary entry + virtual void writeEntry(const word& keyword, Ostream& os) const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace coordinateRotations + + +//- Compatibility typedef 1806 +typedef coordinateRotations::starcd STARCDCoordinateRotation; + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/coordinate/rotation/axesRotation.C b/src/meshTools/coordinate/rotation/axesRotation.C new file mode 100644 index 0000000000000000000000000000000000000000..7c1d9fb819821daa1b92322fca94a91b660df140 --- /dev/null +++ b/src/meshTools/coordinate/rotation/axesRotation.C @@ -0,0 +1,304 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2017-2018 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 "axesRotation.H" +#include "dictionary.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + namespace coordinateRotations + { + defineTypeName(axes); + + // Standard short name + addNamedToRunTimeSelectionTable + ( + coordinateRotation, + axes, + dictionary, + axes + ); + + // Longer name - Compat 1806 + addNamedToRunTimeSelectionTable + ( + coordinateRotation, + axes, + dictionary, + axesRotation + ); + } +} + + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +void Foam::coordinateRotations::axes::assign(const dictionary& dict) +{ + vector axis1, axis2; + + if + ( + dict.readIfPresent("e1", axis1) + && dict.readIfPresent("e2", axis2) + ) + { + setTransform(axis1, axis2, E1_E2); + } + else if + ( + dict.readIfPresent("e2", axis1) + && dict.readIfPresent("e3", axis2) + ) + { + setTransform(axis1, axis2, E2_E3); + } + else if + ( + dict.readIfPresent("e3", axis1) + && dict.readIfPresent("e1", axis2) + ) + { + setTransform(axis1, axis2, E3_E1); + } + else if (dict.found("axis") || dict.found("direction")) + { + // Both "axis" and "direction" are required + // If one is missing the appropriate error message will be generated + dict.read("axis", axis1); + dict.read("direction", axis2); + + setTransform(axis1, axis2, E3_E1); + } + else + { + FatalIOErrorInFunction(dict) + << "No entries of the type (e1, e2) or (e2, e3) or (e3, e1) found" + << exit(FatalIOError); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::coordinateRotations::axes::axes() +: + coordinateRotation(), + axis1_(0,0,1), + axis2_(1,0,0), + order_(E3_E1) +{} + + +Foam::coordinateRotations::axes::axes(const axes& crot) +: + coordinateRotation(crot), + axis1_(crot.axis1_), + axis2_(crot.axis2_), + order_(crot.order_) +{} + + +Foam::coordinateRotations::axes::axes(axes&& crot) +: + coordinateRotation(std::move(crot)), + axis1_(std::move(crot.axis1_)), + axis2_(std::move(crot.axis2_)), + order_(crot.order_) +{} + + +Foam::coordinateRotations::axes::axes +( + const vector& axis, + const vector& dirn, + const axisOrder& order +) +: + coordinateRotations::axes() +{ + setTransform(axis, dirn, order); +} + + +Foam::coordinateRotations::axes::axes(const vector& axis) +: + coordinateRotations::axes(axis, findOrthogonal(axis), E3_E1) +{} + + +Foam::coordinateRotations::axes::axes(const dictionary& dict) +: + coordinateRotations::axes() +{ + assign(dict); +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void Foam::coordinateRotations::axes::clear() +{ + coordinateRotation::clear(); + axis1_ = vector(0,0,1); // e3 + axis2_ = vector(1,0,0); // e1 + order_ = E3_E1; +} + + +void Foam::coordinateRotations::axes::setTransform +( + const vector& axis1, + const vector& axis2, + const axisOrder& order +) +{ + axis1_ = axis1; + axis2_ = axis2; + order_ = order; + + const vector a(normalised(axis1)); + vector b = axis2; + + b = (b - (b & a) * a); + + if (mag(b) < SMALL) + { + FatalErrorInFunction + << "axis1, axis2 appear to be co-linear: " + << axis1 << ", " << axis2 << endl + << abort(FatalError); + } + b.normalise(); + + const vector c = a^b; + + // Global->Local transformation + switch (order) + { + case E1_E2: + { + Rtr_ = tensor(a, b, c); + break; + } + case E2_E3: + { + Rtr_ = tensor(c, a, b); + break; + } + case E3_E1: + { + Rtr_ = tensor(b, c, a); + break; + } + default: + { + FatalErrorInFunction + << "Unhandled axes specification" << endl + << abort(FatalError); + break; + } + } + + // Local->Global transformation + R_ = Rtr_.T(); +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void Foam::coordinateRotations::axes::write(Ostream& os) const +{ + switch (order_) + { + case E1_E2: + { + os << "e1: " << axis1_ << " e2: " << axis2_; + break; + } + case E2_E3: + { + os << "e2: " << axis1_ << " e3: " << axis2_; + break; + } + case E3_E1: + { + os << "e1: " << axis2_ << " e3: " << axis1_; + break; + } + } +} + + +void Foam::coordinateRotations::axes::writeEntry +( + const word& keyword, + Ostream& os +) const +{ + // We permit direct embedding of the axes specification without + // requiring a sub-dictionary. + + const bool subDict = !keyword.empty(); + + if (subDict) + { + os.beginBlock(keyword); + os.writeEntry("type", type()); + } + + switch (order_) + { + case E1_E2: + { + os.writeEntry("e1", axis1_); + os.writeEntry("e2", axis2_); + break; + } + case E2_E3: + { + os.writeEntry("e2", axis1_); + os.writeEntry("e3", axis2_); + break; + } + case E3_E1: + { + os.writeEntry("e1", axis2_); + os.writeEntry("e3", axis1_); + break; + } + } + + if (subDict) + { + os.endBlock(); + } +} + + +// ************************************************************************* // diff --git a/src/meshTools/coordinate/rotation/axesRotation.H b/src/meshTools/coordinate/rotation/axesRotation.H new file mode 100644 index 0000000000000000000000000000000000000000..dde5c9d3ba0092100535ed5a04db2f787a54df34 --- /dev/null +++ b/src/meshTools/coordinate/rotation/axesRotation.H @@ -0,0 +1,194 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2017-2018 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::coordinateRotations::axes + +Description + A coordinateRotation specified using global axes. + + The rotation is defined by a combination of vectors (e1/e2), (e2/e3) + or (e3/e1). Any nonorthogonality is absorbed into the second vector. + + \verbatim + coordinateRotation + { + type axes; + e1 (1 0 0); + e2 (0 1 0); + } + \endverbatim + + \heading Dictionary entries + \table + Property | Description | Required | Default + type | type name: axes (previously axesRotation) | yes | + e1 | local x-axis | partly | + e2 | local y-axis | partly | + e3 | local z-axis | partly | + \endtable + +Note + It is also possible to specify in terms of \c axis and \c direction. + In terms of cylindrical coordinates, the \c axis would + correspond to the \a z-axis and the \c direction to the \a r-axis. + +SourceFiles + axesRotation.C + +\*---------------------------------------------------------------------------*/ + +#ifndef coordinateRotations_axes_H +#define coordinateRotations_axes_H + +#include "coordinateRotation.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace coordinateRotations +{ + +/*---------------------------------------------------------------------------*\ + Class coordinateRotations::axes Declaration +\*---------------------------------------------------------------------------*/ + +class axes +: + public coordinateRotation +{ +public: + + //- The order/combination of local axes for the axes-rotation definition + // Note that these follow the right-hand rule. + enum axisOrder + { + E1_E2, //!< The axis is X-dominant, the direction is Y-dominant + E2_E3, //!< The axis is Y-dominant, the direction is Z-dominant + E3_E1 //!< The axis is Z-dominant, the direction is X-dominant + }; + + +protected: + + // Private Data + + //- The primary axis + vector axis1_; + + //- The secondary axis + vector axis2_; + + //- The axis order + axisOrder order_; + + + // Protected Member Functions + + //- Assign from dictionary + void assign(const dictionary& dict); + + +public: + + //- Runtime type information + TypeNameNoDebug("axes"); + + + // Constructors + + //- Construct null - an identity transform + axes(); + + //- Copy construct + axes(const axes& crot); + + //- Move construct + axes(axes&& crot); + + //- Construct from two axes (axis and direction) + axes + ( + const vector& axis, + const vector& dirn, + const axisOrder& order = E3_E1 + ); + + //- Construct from a single axis (as e3) using a best-guess for the + //- second axis. + // The largest component and its sign are used when guessing + // an appropriate orientation (direction). + explicit axes(const vector& axis); + + //- Construct from dictionary + explicit axes(const dictionary& dict); + + //- Return clone + autoPtr<coordinateRotation> clone() const + { + return + autoPtr<coordinateRotation>::NewFrom + <coordinateRotations::axes>(*this); + } + + + //- Destructor + virtual ~axes() = default; + + + // Member Functions + + //- Reset to an identity rotation + virtual void clear(); + + //- Set the transformation tensors from two axes (axis and direction) + void setTransform + ( + const vector& axis1, + const vector& axis2, + const axisOrder& order = E3_E1 + ); + + //- Write information + virtual void write(Ostream& os) const; + + //- Write dictionary entry + virtual void writeEntry(const word& keyword, Ostream& os) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace coordinateRotations + +// Compatibility typedef 1806 +typedef coordinateRotations::axes axesRotation; + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/coordinate/rotation/axisAngleRotation.C b/src/meshTools/coordinate/rotation/axisAngleRotation.C new file mode 100644 index 0000000000000000000000000000000000000000..4e6cdf1b051f2e7e8b45f37f1b5884736b71e667 --- /dev/null +++ b/src/meshTools/coordinate/rotation/axisAngleRotation.C @@ -0,0 +1,175 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 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 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 "axisAngleRotation.H" +#include "dictionary.H" +#include "quaternion.H" +#include "unitConversion.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + namespace coordinateRotations + { + defineTypeName(axisAngle); + addToRunTimeSelectionTable + ( + coordinateRotation, + axisAngle, + dictionary + ); + } +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::coordinateRotations::axisAngle::assign(const dictionary& dict) +{ + setTransform + ( + dict.get<vector>("axis"), + dict.get<scalar>("angle"), + dict.lookupOrDefault("degrees", true) + ); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::coordinateRotations::axisAngle::axisAngle() +: + coordinateRotation(), + axis_(0,0,1), + angle_(0), + degrees_(true) +{} + + +Foam::coordinateRotations::axisAngle::axisAngle(const axisAngle& crot) +: + coordinateRotation(crot), + axis_(crot.axis_), + angle_(crot.angle_), + degrees_(crot.degrees_) +{} + + +Foam::coordinateRotations::axisAngle::axisAngle(axisAngle&& crot) +: + coordinateRotation(std::move(crot)), + axis_(std::move(crot.axis_)), + angle_(std::move(crot.angle_)), + degrees_(crot.degrees_) +{} + + +Foam::coordinateRotations::axisAngle::axisAngle +( + const vector& axis, + const scalar angle, + const bool degrees +) +: + axisAngle() +{ + setTransform(axis, angle, degrees); +} + + +Foam::coordinateRotations::axisAngle::axisAngle(const dictionary& dict) +: + axisAngle() +{ + assign(dict); +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void Foam::coordinateRotations::axisAngle::clear() +{ + coordinateRotation::clear(); + axis_ = vector(0,0,1); + angle_ = 0; +} + + +void Foam::coordinateRotations::axisAngle::setTransform +( + const vector& axis, + const scalar angle, + const bool degrees +) +{ + axis_ = axis; + angle_ = angle; + degrees_ = degrees; + + if (mag(axis_) < SMALL) + { + clear(); // identity rotation + } + else + { + const quaternion quat(axis_, (degrees_ ? degToRad(angle_) : angle_)); + + R_ = quat.R(); + Rtr_ = R_.T(); + } +} + + +void Foam::coordinateRotations::axisAngle::write(Ostream& os) const +{ + os << "rotation axis: " << axis_ + << " angle(" << (degrees_ ? "degrees" : "radians") + << "): " << angle_; +} + + +void Foam::coordinateRotations::axisAngle::writeEntry +( + const word& keyword, + Ostream& os +) const +{ + os.beginBlock(keyword); + + os.writeEntry("type", type()); + os.writeEntry("axis", axis_); + os.writeEntry("angle", angle_); + if (!degrees_) + { + os.writeEntry("degrees", "false"); + } + + os.endBlock(); +} + + +// ************************************************************************* // diff --git a/src/meshTools/coordinate/rotation/axisAngleRotation.H b/src/meshTools/coordinate/rotation/axisAngleRotation.H new file mode 100644 index 0000000000000000000000000000000000000000..cf575293a22220e1f53b3f0bec3e97e75d73ad68 --- /dev/null +++ b/src/meshTools/coordinate/rotation/axisAngleRotation.H @@ -0,0 +1,162 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 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 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::coordinateRotations::axisAngle + +Description + A coordinateRotation specified by a rotation axis and a rotation angle + about that axis. + + \verbatim + coordinateRotation + { + type axisAngle; + axis (1 0 0); + angle 90; + } + \endverbatim + + \heading Dictionary entries + \table + Property | Description | Required | Default + type | type name: axisAngle | yes | + axis | axis of rotation (vector) | yes | + angle | rotation angle | yes | + degrees | angle in degrees | no | true + \endtable + +SourceFiles + axisAngle.C + +\*---------------------------------------------------------------------------*/ + +#ifndef coordinateRotations_axisAngle_H +#define coordinateRotations_axisAngle_H + +#include "coordinateRotation.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace coordinateRotations +{ + +/*---------------------------------------------------------------------------*\ + Class coordinateRotations::axisAngle Declaration +\*---------------------------------------------------------------------------*/ + +class axisAngle +: + public coordinateRotation +{ + // Private Data + + //- The rotation axis + vector axis_; + + //- The rotation angle + scalar angle_; + + //- Angle measured in degrees + bool degrees_; + + + // Private Member Functions + + //- Assign from dictionary + void assign(const dictionary& dict); + + +public: + + //- Runtime type information + TypeNameNoDebug("axisAngle"); + + // Constructors + + //- Construct null + axisAngle(); + + //- Copy construct + axisAngle(const axisAngle& crot); + + //- Move construct + axisAngle(axisAngle&& crot); + + //- Construct from axis and angle + axisAngle + ( + const vector& axis, + const scalar angle, + const bool degrees + ); + + //- Construct from dictionary + explicit axisAngle(const dictionary& dict); + + //- Return clone + autoPtr<coordinateRotation> clone() const + { + return + autoPtr<coordinateRotation>::NewFrom + <coordinateRotations::axisAngle>(*this); + } + + + //- Destructor + virtual ~axisAngle() = default; + + + // Member Functions + + //- Reset to an identity rotation + virtual void clear(); + + //- Set the transformation tensors from axis and angle + void setTransform + ( + const vector& axis, + const scalar angle, + const bool degrees + ); + + //- Write information + virtual void write(Ostream& os) const; + + //- Write dictionary entry + virtual void writeEntry(const word& keyword, Ostream& os) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace coordinateRotations +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/coordinate/rotation/coordinateRotation.C b/src/meshTools/coordinate/rotation/coordinateRotation.C new file mode 100644 index 0000000000000000000000000000000000000000..0e1ac5087c23c7299ce34bc9e0802ad9e7c796a8 --- /dev/null +++ b/src/meshTools/coordinate/rotation/coordinateRotation.C @@ -0,0 +1,250 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2017-2018 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 "coordinateRotation.H" +#include "dictionary.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeName(coordinateRotation); + defineRunTimeSelectionTable(coordinateRotation, dictionary); +} + + +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +Foam::vector Foam::coordinateRotation::findOrthogonal(const vector& axis) +{ + direction maxCmpt = 0, dirCmpt = 1; + + scalar maxVal = mag(axis[maxCmpt]); + bool negative = (axis[maxCmpt] < 0); + + for (direction cmpt=1; cmpt < vector::nComponents; ++cmpt) + { + const scalar val = mag(axis[cmpt]); + + if (maxVal < val) + { + maxVal = val; + maxCmpt = cmpt; + dirCmpt = maxCmpt+1; + negative = (axis[cmpt] < 0); + + if (dirCmpt >= vector::nComponents) + { + dirCmpt = 0; + } + } + } + + vector dirn = Zero; + dirn.component(dirCmpt) = (negative ? -1 : 1); + + return dirn; +} + + +Foam::symmTensor Foam::coordinateRotation::transformPrincipal +( + const tensor& tt, + const vector& st +) +{ + return symmTensor + ( + tt.xx()*st.x()*tt.xx() + + tt.xy()*st.y()*tt.xy() + + tt.xz()*st.z()*tt.xz(), + + tt.xx()*st.x()*tt.yx() + + tt.xy()*st.y()*tt.yy() + + tt.xz()*st.z()*tt.yz(), + + tt.xx()*st.x()*tt.zx() + + tt.xy()*st.y()*tt.zy() + + tt.xz()*st.z()*tt.zz(), + + tt.yx()*st.x()*tt.yx() + + tt.yy()*st.y()*tt.yy() + + tt.yz()*st.z()*tt.yz(), + + tt.yx()*st.x()*tt.zx() + + tt.yy()*st.y()*tt.zy() + + tt.yz()*st.z()*tt.zz(), + + tt.zx()*st.x()*tt.zx() + + tt.zy()*st.y()*tt.zy() + + tt.zz()*st.z()*tt.zz() + ); +} + + +// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // + +Foam::autoPtr<Foam::coordinateRotation> Foam::coordinateRotation::New +( + const dictionary& dict +) +{ + const word modelType(dict.get<word>("type")); + + auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + + if (!cstrIter.found()) + { + FatalIOErrorInFunction(dict) + << "Unknown coordinateRotation type " + << modelType << nl << nl + << "Valid types: " + << flatOutput(dictionaryConstructorTablePtr_->sortedToc()) + << exit(FatalIOError); + } + + return autoPtr<coordinateRotation>(cstrIter()(dict)); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::coordinateRotation::write(Ostream& os) const +{ + os << "e1: " << e1() << " e2: " << e2() << " e3: " << e3(); +} + + +void Foam::coordinateRotation::writeEntry +( + const word& keyword, + Ostream& os +) const +{ + os.beginBlock(keyword); + + os.writeEntry("type", type()); + os.writeEntry("e1", e1()); + os.writeEntry("e2", e2()); + os.writeEntry("e3", e3()); + + os.endBlock(); +} + + +Foam::vector Foam::coordinateRotation::transform +( + const vector& input +) const +{ + return (R_ & input); +} + + +Foam::tmp<Foam::vectorField> Foam::coordinateRotation::transform +( + const vectorField& input +) const +{ + return (R_ & input); +} + + +Foam::vector Foam::coordinateRotation::invTransform +( + const vector& input +) const +{ + return (Rtr_ & input); +} + + +Foam::tmp<Foam::vectorField> Foam::coordinateRotation::invTransform +( + const vectorField& input +) const +{ + return (Rtr_ & input); +} + + +Foam::symmTensor Foam::coordinateRotation::transformVector +( + const vector& input +) const +{ + return transformPrincipal(R_, input); +} + + +Foam::tmp<Foam::symmTensorField> Foam::coordinateRotation::transformVector +( + const vectorField& input +) const +{ + const label len = input.size(); + + auto tresult = tmp<symmTensorField>::New(len); + auto& result = tresult.ref(); + + for (label pos=0; pos<len; ++pos) + { + result[pos] = transformPrincipal(R_, input[pos]); + } + + return tresult; +} + + +Foam::tensor Foam::coordinateRotation::transformTensor +( + const tensor& input +) const +{ + return (R_ & input & Rtr_); +} + + +Foam::tmp<Foam::tensorField> Foam::coordinateRotation::transformTensor +( + const tensorField& input +) const +{ + const label len = input.size(); + + auto tresult = tmp<tensorField>::New(len); + auto& result = tresult.ref(); + + for (label pos=0; pos<len; ++pos) + { + result[pos] = (R_ & input[pos] & Rtr_); + } + + return tresult; +} + + +// ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.H b/src/meshTools/coordinate/rotation/coordinateRotation.H similarity index 50% rename from src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.H rename to src/meshTools/coordinate/rotation/coordinateRotation.H index 13625e34ba7569f64e64a34c9893efbd3db6e9b2..ac52a0d5c79729657cf7804f6503a40eea541331 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.H +++ b/src/meshTools/coordinate/rotation/coordinateRotation.H @@ -2,8 +2,8 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -21,36 +21,48 @@ License 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::STARCDCoordinateRotation +Namespace + Foam::coordinateRotations Description - A coordinateRotation defined by the STAR-CD convention. + Namespace for coordinate system rotations. - The 3 rotations are defined in the STAR-CD convention - (around Z, around X' and around Y''). - The order of the parameter arguments matches this rotation order. +Class + Foam::coordinateRotation - - the rotation angles are in degrees, unless otherwise explicitly specified: +Description + Base class for a coordinate rotation, which is often used as component + of a coordinateSystem. \verbatim coordinateRotation { - type STARCDRotation; - degrees false; - rotation (0 0 3.141592654); + type axes + e1 (1 0 0); + e2 (0 1 0); } \endverbatim + Types of coordinateRotations: + -# \link coordinateRotations::identity none \endlink + -# \link coordinateRotations::axes axes \endlink + -# \link coordinateRotations::axisAngle axisAngle \endlink + -# \link coordinateRotations::euler euler \endlink + -# \link coordinateRotations::starcd starcd \endlink + -# \link coordinateRotations::cylindrical cylindrical \endlink + SourceFiles - STARCDCoordinateRotation.C + coordinateRotation.C \*---------------------------------------------------------------------------*/ -#ifndef STARCDCoordinateRotation_H -#define STARCDCoordinateRotation_H +#ifndef coordinateRotation_H +#define coordinateRotation_H -#include "coordinateRotation.H" +#include "vectorField.H" +#include "tensorField.H" +#include "dictionary.H" +#include "runTimeSelectionTables.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -58,15 +70,14 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class STARCDCoordinateRotation Declaration + Class coordinateRotation Declaration \*---------------------------------------------------------------------------*/ -class STARCDCoordinateRotation -: - public coordinateRotation +class coordinateRotation { +protected: - // Private Member Data + // Protected data //- Local-to-Global transformation tensor tensor R_; @@ -75,81 +86,63 @@ class STARCDCoordinateRotation tensor Rtr_; - // Private Member Functions + // Protected Member Functions - //- Calculate transformation tensor - void calcTransform - ( - const scalar rotZ, - const scalar rotX, - const scalar rotY, - const bool inDegrees - ); + //- Determine best-guess for an orthogonal axis + static vector findOrthogonal(const vector& axis); public: //- Runtime type information - TypeName("STARCDRotation"); + TypeNameNoDebug("coordinateRotation"); + + // Declare run-time constructor selection table from dictionary + declareRunTimeSelectionTable + ( + autoPtr, + coordinateRotation, + dictionary, + ( + const dictionary& dict + ), + (dict) + ); // Constructors - //- Construct null - STARCDCoordinateRotation(); + // Uses all default constructors - //- Construct as copy - STARCDCoordinateRotation(const STARCDCoordinateRotation& r); + //- Construct and return a clone + virtual autoPtr<coordinateRotation> clone() const = 0; - //- Construct from rotation vector - STARCDCoordinateRotation - ( - const vector& rotZrotXrotY, - const bool inDegrees - ); - //- Construct from components of rotation vector - STARCDCoordinateRotation - ( - const scalar rotZ, - const scalar rotX, - const scalar rotY, - const bool inDegrees - ); + // Selectors - //- Construct from dictionary - explicit STARCDCoordinateRotation(const dictionary& dict); - - //- Construct from dictionary and a registry (typically a mesh) - STARCDCoordinateRotation - ( - const dictionary& dict, - const objectRegistry& unused - ); + //- Select constructed from dictionary + static autoPtr<coordinateRotation> New(const dictionary& dict); - //- Return clone - autoPtr<coordinateRotation> clone() const - { - return - autoPtr<coordinateRotation>::NewFrom - <STARCDCoordinateRotation>(*this); - } + //- Destructor + virtual ~coordinateRotation() = default; // Member Functions - //- Reset rotation to an identity rotation + //- True if the rotation tensor is uniform for all positions + virtual bool uniform() const + { + return true; + } + + //- Reset to an identity rotation virtual void clear() { R_ = sphericalTensor::I; Rtr_ = sphericalTensor::I; } - //- Update the rotation for a list of cells - virtual void updateCells(const polyMesh&, const labelList&) - {} - //- Return local-to-global transformation tensor virtual const tensor& R() const { @@ -160,7 +153,7 @@ public: virtual const tensor& Rtr() const { return Rtr_; - }; + } //- Return local Cartesian x-axis in global coordinates virtual const vector e1() const @@ -180,44 +173,65 @@ public: return Rtr_.z(); } - //- Return transformation tensor field - virtual const tensorField& Tr() const; - //- Transform vectorField using transformation tensor field - virtual tmp<vectorField> transform(const vectorField& st) const; + // Transformations - //- Transform vector using transformation tensor - virtual vector transform(const vector& st) const; + //- Transform principal + static symmTensor transformPrincipal + ( + const tensor& rot, + const vector& vec + ); - //- Inverse transform vectorField using transformation tensor field - virtual tmp<vectorField> invTransform(const vectorField& st) const; + + //- Transform vector using the transformation tensor + // \return vector + virtual vector transform(const vector& input) const; + + //- Transform vectorField using transformation tensor field + // \return tmp vectorField + virtual tmp<vectorField> transform(const vectorField& input) const; //- Inverse transform vector using transformation tensor - virtual vector invTransform(const vector& st) const; + // \return vector + virtual vector invTransform(const vector& input) const; - //- Transform tensor field using transformation tensorField - virtual tmp<tensorField> transformTensor(const tensorField& st) const; + //- Inverse transform vectorField using transformation tensor field + // \return tmp vectorField + virtual tmp<vectorField> invTransform(const vectorField& input) const; - //- Transform tensor using transformation tensorField - virtual tensor transformTensor(const tensor& st) const; - //- Transform tensor sub-field using transformation tensorField - virtual tmp<tensorField> transformTensor + //- Transform vector using transformation tensor + // \return symmetrical tensor + virtual symmTensor transformVector(const vector& input) const; + + //- Transform vectorField using transformation tensorField + //- \return symmetrical tensorField + virtual tmp<symmTensorField> transformVector ( - const tensorField& st, - const labelList& cellMap + const vectorField& input ) const; - //- Transform vectorField using transformation tensorField and return - // symmetrical tensorField - virtual tmp<symmTensorField> transformVector + + //- Transform tensor field using transformation tensor + // \return tensor + virtual tensor transformTensor(const tensor& input) const; + + //- Transform tensor field using transformation tensor + // \return tmp tensorField + virtual tmp<tensorField> transformTensor ( - const vectorField& st + const tensorField& input ) const; - //- Transform vector using transformation tensor and return - // symmetrical tensor - virtual symmTensor transformVector(const vector& st) const; + + // Write + + //- Write information about e1,e2,e3 vectors + virtual void write(Ostream& os) const; + + //- Write dictionary entry with e1,e2,e3 vectors + virtual void writeEntry(const word& keyword, Ostream& os) const; }; diff --git a/src/meshTools/coordinate/rotation/cylindricalRotation.C b/src/meshTools/coordinate/rotation/cylindricalRotation.C new file mode 100644 index 0000000000000000000000000000000000000000..a8bcc31e611d9a7b6ed323b518accf02ccc137e1 --- /dev/null +++ b/src/meshTools/coordinate/rotation/cylindricalRotation.C @@ -0,0 +1,89 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2018 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 "cylindricalRotation.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + namespace coordinateRotations + { + defineTypeName(cylindrical); + addToRunTimeSelectionTable + ( + coordinateRotation, + cylindrical, + dictionary + ); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::coordinateRotations::cylindrical::cylindrical(const cylindrical& crot) +: + coordinateRotations::axes(crot) +{} + + +Foam::coordinateRotations::cylindrical::cylindrical(const vector& axis) +: + coordinateRotations::axes(axis) +{} + + +Foam::coordinateRotations::cylindrical::cylindrical(const dictionary& dict) +: + cylindrical(dict.getCompat<vector>("axis", {{"e3", -1806}})) +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void Foam::coordinateRotations::cylindrical::write(Ostream& os) const +{ + os << type() << " axis: " << e3(); +} + + +void Foam::coordinateRotations::cylindrical::writeEntry +( + const word& keyword, + Ostream& os +) const +{ + os.beginBlock(keyword); + + os.writeEntry("type", type()); + os.writeEntry("axis", e3()); + + os.endBlock(); +} + + +// ************************************************************************* // diff --git a/src/meshTools/coordinate/rotation/cylindricalRotation.H b/src/meshTools/coordinate/rotation/cylindricalRotation.H new file mode 100644 index 0000000000000000000000000000000000000000..64c51ddcfd1392507e66616b864f71cbcdaf91b2 --- /dev/null +++ b/src/meshTools/coordinate/rotation/cylindricalRotation.H @@ -0,0 +1,119 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2018 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::coordinateRotations::cylindrical + +Description + A special purpose coordinateRotation description to mark that + position-dependent transformations should be used. + + \heading Dictionary entries + \table + Property | Description | Required | Default + type | type name: cylindrical | yes | + axis | z-axis | yes | + e3 | z-axis (synonym for axix) | no | + \endtable + +SourceFiles + cylindricalRotation.C + +\*---------------------------------------------------------------------------*/ + +#ifndef coordinateRotations_cylindrical_H +#define coordinateRotations_cylindrical_H + +#include "axesRotation.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace coordinateRotations +{ + +/*---------------------------------------------------------------------------*\ + Class coordinateRotations::cylindrical Declaration +\*---------------------------------------------------------------------------*/ + +class cylindrical +: + public coordinateRotations::axes +{ +public: + + //- Runtime type information + TypeNameNoDebug("cylindrical"); + + + // Constructors + + //- Copy construct + cylindrical(const cylindrical& crot); + + //- Construct from axis. + explicit cylindrical(const vector& axis); + + //- Construct from dictionary + explicit cylindrical(const dictionary& dict); + + //- Return clone + autoPtr<coordinateRotation> clone() const + { + return + autoPtr<coordinateRotation>::NewFrom + <coordinateRotations::cylindrical>(*this); + } + + + //- Destructor + virtual ~cylindrical() = default; + + + // Member Functions + + //- Do not treat the rotation tensor as uniform + virtual bool uniform() const + { + return false; + } + + //- Write information + virtual void write(Ostream& os) const; + + //- Write dictionary entry + virtual void writeEntry(const word& keyword, Ostream& os) const; + +}; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace coordinateRotations +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.C b/src/meshTools/coordinate/rotation/identityRotation.C similarity index 53% rename from src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.C rename to src/meshTools/coordinate/rotation/identityRotation.C index 57565dbc451c3dd8c8a456f3cab50c5598e64174..620f8289bf23f5966f25ed34aaf77b78ce637f31 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.C +++ b/src/meshTools/coordinate/rotation/identityRotation.C @@ -2,8 +2,8 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2018 OpenCFD Ltd. + \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -23,7 +23,7 @@ License \*---------------------------------------------------------------------------*/ -#include "coordinateRotation.H" +#include "identityRotation.H" #include "dictionary.H" #include "addToRunTimeSelectionTable.H" @@ -31,55 +31,61 @@ License namespace Foam { - defineTypeNameAndDebug(coordinateRotation, 0); - defineRunTimeSelectionTable(coordinateRotation, dictionary); - defineRunTimeSelectionTable(coordinateRotation, objectRegistry); + namespace coordinateRotations + { + defineTypeName(identity); + addToRunTimeSelectionTable + ( + coordinateRotation, + identity, + dictionary + ); + } } -// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::symmTensor Foam::coordinateRotation::transformPrincipal -( - const tensor& tt, - const vector& st -) const +Foam::coordinateRotations::identity::identity() +: + coordinateRotation() { - return symmTensor - ( - tt.xx()*st.x()*tt.xx() - + tt.xy()*st.y()*tt.xy() - + tt.xz()*st.z()*tt.xz(), + R_ = sphericalTensor::I; + Rtr_ = sphericalTensor::I; +} + - tt.xx()*st.x()*tt.yx() - + tt.xy()*st.y()*tt.yy() - + tt.xz()*st.z()*tt.yz(), +Foam::coordinateRotations::identity::identity(const identity&) +: + identity() +{} - tt.xx()*st.x()*tt.zx() - + tt.xy()*st.y()*tt.zy() - + tt.xz()*st.z()*tt.zz(), - tt.yx()*st.x()*tt.yx() - + tt.yy()*st.y()*tt.yy() - + tt.yz()*st.z()*tt.yz(), +Foam::coordinateRotations::identity::identity(const dictionary&) +: + identity() +{} - tt.yx()*st.x()*tt.zx() - + tt.yy()*st.y()*tt.zy() - + tt.yz()*st.z()*tt.zz(), - tt.zx()*st.x()*tt.zx() - + tt.zy()*st.y()*tt.zy() - + tt.zz()*st.z()*tt.zz() - ); +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // +void Foam::coordinateRotations::identity::write(Ostream& os) const +{ + os << "identity rotation"; } -void Foam::coordinateRotation::write(Ostream& os) const +void Foam::coordinateRotations::identity::writeEntry +( + const word& keyword, + Ostream& os +) const { - os.writeEntry("e1", e1()); - os.writeEntry("e2", e2()); - os.writeEntry("e3", e3()); + os.beginBlock(keyword); + + os.writeEntry("type", type()); + + os.endBlock(); } diff --git a/src/meshTools/coordinate/rotation/identityRotation.H b/src/meshTools/coordinate/rotation/identityRotation.H new file mode 100644 index 0000000000000000000000000000000000000000..bd5d92ffd238c07bbccb092426fdcb56b835d3d3 --- /dev/null +++ b/src/meshTools/coordinate/rotation/identityRotation.H @@ -0,0 +1,118 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 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 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::coordinateRotations::identity + +Description + An identity coordinateRotation. + + \verbatim + coordinateRotation + { + type none; + } + \endverbatim + + \heading Dictionary entries + \table + Property | Description | Required | Default + type | type name: none | yes | + \endtable + +SourceFiles + identityRotation.C + +\*---------------------------------------------------------------------------*/ + +#ifndef coordinateRotations_identity_H +#define coordinateRotations_identity_H + +#include "coordinateRotation.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace coordinateRotations +{ + +/*---------------------------------------------------------------------------*\ + Class coordinateRotations::identity Declaration +\*---------------------------------------------------------------------------*/ + +class identity +: + public coordinateRotation +{ +public: + + //- Runtime type information + TypeNameNoDebug("none"); + + + // Constructors + + //- Construct null + identity(); + + //- Copy construct + identity(const identity& unused); + + //- Construct from dictionary + explicit identity(const dictionary& unused); + + //- Return clone + autoPtr<coordinateRotation> clone() const + { + return + autoPtr<coordinateRotation>::NewFrom + <coordinateRotations::identity>(*this); + } + + + //- Destructor + virtual ~identity() = default; + + + // Member Functions + + //- Write information + virtual void write(Ostream& os) const; + + //- Write dictionary entry + virtual void writeEntry(const word& keyword, Ostream& os) const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace coordinateRotations +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/cartesianCS.C b/src/meshTools/coordinate/systems/cartesianCS.C similarity index 53% rename from src/meshTools/coordinateSystems/cartesianCS.C rename to src/meshTools/coordinate/systems/cartesianCS.C index f01bc18c22ac2bde9f81ff014dedcca5ceb9405c..d65f166bbb58451fa391a631e70ca9f54430d0e7 100644 --- a/src/meshTools/coordinateSystems/cartesianCS.C +++ b/src/meshTools/coordinate/systems/cartesianCS.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -24,16 +24,13 @@ License \*---------------------------------------------------------------------------*/ #include "cartesianCS.H" - -#include "one.H" -#include "mathematicalConstants.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { - defineTypeNameAndDebug(cartesianCS, 0); + defineTypeName(cartesianCS); addToRunTimeSelectionTable(coordinateSystem, cartesianCS, dictionary); } @@ -46,115 +43,49 @@ Foam::cartesianCS::cartesianCS() {} -Foam::cartesianCS::cartesianCS -( - const coordinateSystem& cs -) +Foam::cartesianCS::cartesianCS(const coordinateSystem& csys) : - coordinateSystem(cs) + coordinateSystem(csys) {} -Foam::cartesianCS::cartesianCS -( - const word& name, - const coordinateSystem& cs -) +Foam::cartesianCS::cartesianCS(coordinateSystem&& csys) : - coordinateSystem(name, cs) + coordinateSystem(std::move(csys)) {} Foam::cartesianCS::cartesianCS ( - const word& name, const point& origin, - const coordinateRotation& cr + const coordinateRotation& crot ) : - coordinateSystem(name, origin, cr) + coordinateSystem(origin, crot) {} Foam::cartesianCS::cartesianCS ( - const word& name, const point& origin, const vector& axis, const vector& dirn ) : - coordinateSystem(name, origin, axis, dirn) + coordinateSystem(origin, axis, dirn) {} -Foam::cartesianCS::cartesianCS -( - const word& name, - const dictionary& dict -) +Foam::cartesianCS::cartesianCS(const dictionary& dict) : - coordinateSystem(name, dict) + coordinateSystem(dict) {} -Foam::cartesianCS::cartesianCS -( - const objectRegistry& obr, - const dictionary& dict -) +Foam::cartesianCS::cartesianCS(const word& name, const dictionary& dict) : - coordinateSystem(obr, dict) -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::cartesianCS::~cartesianCS() + coordinateSystem(name, dict) {} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - - -Foam::vector Foam::cartesianCS::localToGlobal -( - const vector& local, - bool translate -) const -{ - return coordinateSystem::localToGlobal(local, translate); -} - - -Foam::tmp<Foam::vectorField> Foam::cartesianCS::localToGlobal -( - const vectorField& local, - bool translate -) const -{ - return coordinateSystem::localToGlobal(local, translate); -} - - -Foam::vector Foam::cartesianCS::globalToLocal -( - const vector& global, - bool translate -) const -{ - return coordinateSystem::globalToLocal(global, translate); -} - - -Foam::tmp<Foam::vectorField> Foam::cartesianCS::globalToLocal -( - const vectorField& global, - bool translate -) const -{ - return coordinateSystem::globalToLocal(global, translate); -} - - // ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/cartesianCS.H b/src/meshTools/coordinate/systems/cartesianCS.H similarity index 56% rename from src/meshTools/coordinateSystems/cartesianCS.H rename to src/meshTools/coordinate/systems/cartesianCS.H index d499f790b4700626f68421a78c60a496fed6fe83..c136b5bca6ad2558a95e9d24bf2779a0bf9b8d9a 100644 --- a/src/meshTools/coordinateSystems/cartesianCS.H +++ b/src/meshTools/coordinate/systems/cartesianCS.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,7 +25,13 @@ Class Foam::cartesianCS Description - Cartesian coordinate system + A Cartesian coordinate system + + \heading Dictionary entries + \table + Property | Description | Required | Default + type | type name: cartesian | yes | + \endtable SourceFiles cartesianCS.C @@ -36,7 +42,6 @@ SourceFiles #define cartesianCS_H #include "coordinateSystem.H" -#include "typeInfo.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -44,94 +49,66 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class cartesianCS Declaration + Class cartesianCS Declaration \*---------------------------------------------------------------------------*/ class cartesianCS : public coordinateSystem { -protected: - - // Protected Member Functions - - - //- Convert from local coordinate system to the global Cartesian system - // with optional translation for the origin - virtual vector localToGlobal(const vector&, bool translate) const; - - //- Convert from local coordinate system to the global Cartesian system - // with optional translation for the origin - virtual tmp<vectorField> localToGlobal - ( - const vectorField&, - bool translate - ) const; - - //- Convert from global Cartesian system to the local coordinate system - // with optional translation for the origin - virtual vector globalToLocal(const vector&, bool translate) const; - - //- Convert from global Cartesian system to the local coordinate system - // with optional translation for the origin - virtual tmp<vectorField> globalToLocal - ( - const vectorField&, - bool translate - ) const; - - public: //- Runtime type information - TypeName("cartesian"); + TypeNameNoDebug("cartesian"); // Constructors - //- Construct null + //- Construct null. This is an identity coordinateSystem. cartesianCS(); - //- Construct copy - cartesianCS - ( - const coordinateSystem& - ); + //- Copy construct from coordinateSystem + cartesianCS(const coordinateSystem& csys); - //- Construct copy with a different name - cartesianCS - ( - const word& name, - const coordinateSystem& - ); + //- Move construct from coordinateSystem + cartesianCS(coordinateSystem&& csys); //- Construct from origin and rotation cartesianCS ( - const word& name, const point& origin, - const coordinateRotation& + const coordinateRotation& crot ); //- Construct from origin and 2 axes cartesianCS ( - const word& name, const point& origin, const vector& axis, const vector& dirn ); - //- Construct from dictionary - cartesianCS(const word&, const dictionary&); - + //- Construct from dictionary without a name + explicit cartesianCS(const dictionary& dict); - //- Construct from dictionary and objectRegistry - cartesianCS(const objectRegistry&, const dictionary&); + //- Construct from dictionary with a given name + cartesianCS(const word& name, const dictionary& dict); //- Destructor - virtual ~cartesianCS(); + virtual ~cartesianCS() = default; + + + // Member Operators + + //- Copy assignment + cartesianCS& operator=(const cartesianCS&) = default; + + //- Move assignment + cartesianCS& operator=(cartesianCS&&) = default; + + //- Copy/move assignment from coordinateSystem, autoPtr + using coordinateSystem::operator=; }; diff --git a/src/meshTools/coordinate/systems/coordinateSystem.C b/src/meshTools/coordinate/systems/coordinateSystem.C new file mode 100644 index 0000000000000000000000000000000000000000..9815d0a71627852df04a89a38e6703286e2eee2b --- /dev/null +++ b/src/meshTools/coordinate/systems/coordinateSystem.C @@ -0,0 +1,389 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2018 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 "coordinateSystem.H" +#include "cartesianCS.H" +#include "IOstream.H" +#include "axesRotation.H" +#include "identityRotation.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(coordinateSystem, 0); + defineRunTimeSelectionTable(coordinateSystem, dictionary); + defineRunTimeSelectionTable(coordinateSystem, registry); +} + +Foam::coordinateSystem Foam::coordinateSystem::dummySystem; + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::coordinateSystem::coordinateSystem() +: + origin_(Zero), + rot_(new coordinateRotations::identity()), + name_(), + note_() +{} + + +Foam::coordinateSystem::coordinateSystem(const coordinateSystem& csys) +: + origin_(csys.origin_), + rot_(csys.rot_.clone()), + name_(csys.name_), + note_(csys.note_) +{} + + +Foam::coordinateSystem::coordinateSystem(coordinateSystem&& csys) +: + origin_(std::move(csys.origin_)), + rot_(std::move(csys.rot_)), + name_(std::move(csys.name_)), + note_(std::move(csys.note_)) +{} + + +Foam::coordinateSystem::coordinateSystem +( + const word& name, + const coordinateSystem& csys +) +: + origin_(csys.origin_), + rot_(csys.rot_.clone()), + name_(name), + note_(csys.note_) +{} + + +Foam::coordinateSystem::coordinateSystem +( + const point& origin, + const coordinateRotation& crot +) +: + coordinateSystem(word::null, origin, crot) +{} + + +Foam::coordinateSystem::coordinateSystem +( + const word& name, + const point& origin, + const coordinateRotation& crot +) +: + origin_(origin), + rot_(crot.clone()), + name_(name), + note_() +{} + + +Foam::coordinateSystem::coordinateSystem +( + const point& origin, + const vector& axis, + const vector& dirn +) +: + coordinateSystem(word::null, origin, axis, dirn) +{} + + +Foam::coordinateSystem::coordinateSystem +( + const word& name, + const point& origin, + const vector& axis, + const vector& dirn +) +: + origin_(origin), + rot_(new coordinateRotations::axes(axis, dirn)), + name_(name), + note_() +{} + + +Foam::coordinateSystem::coordinateSystem(const dictionary& dict) +: + coordinateSystem(word::null, dict) +{} + + +Foam::coordinateSystem::coordinateSystem +( + const word& name, + const dictionary& dict +) +: + origin_(Zero), + rot_(), + name_(name), + note_() +{ + assign(dict); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + + +void Foam::coordinateSystem::clear() +{ + note_.clear(); + origin_ = Zero; + rot_->clear(); +} + + +void Foam::coordinateSystem::setRotation(autoPtr<coordinateRotation>&& crot) +{ + rot_.reset(std::move(crot)); +} + + +void Foam::coordinateSystem::write(Ostream& os) const +{ + if (!valid()) + { + return; + } + + + // Is it non-cartesian? + if + ( + type() != typeName_() + && type() != cartesianCS::typeName_() + ) + { + os << type() << ' '; + } + + os << "origin: " << origin_ << ' '; + rot_->write(os); +} + + +void Foam::coordinateSystem::writeEntry(const word& keyword, Ostream& os) const +{ + if (!valid()) + { + return; + } + + const bool subDict = !keyword.empty(); + + if (subDict) + { + os.beginBlock(keyword); + + // Suppress type for base class (defaults to cartesian) + if + ( + type() != typeName_() + && type() != cartesianCS::typeName_() + ) + { + os.writeEntry<word>("type", type()); + } + + if (note_.size()) + { + // The 'note' is optional + os.writeEntry("note", note_); + } + } + + os.writeEntry("origin", origin_); + + rot_->writeEntry("coordinateRotation", os); + + if (subDict) + { + os.endBlock(); + } +} + + +// * * * * * * * * * * * * * * * Transformations * * * * * * * * * * * * * * // + +Foam::vector Foam::coordinateSystem::localToGlobal +( + const vector& local, + bool translate +) const +{ + if (translate) + { + return (rot_->transform(local)) + origin_; + } + + return rot_->transform(local); +} + + +Foam::tmp<Foam::vectorField> Foam::coordinateSystem::localToGlobal +( + const vectorField& local, + bool translate +) const +{ + if (translate) + { + return (rot_->transform(local)) + origin_; + } + + return rot_->transform(local); +} + + +Foam::vector Foam::coordinateSystem::globalToLocal +( + const vector& global, + bool translate +) const +{ + if (translate) + { + return rot_->invTransform(global - origin_); + } + + return rot_->invTransform(global); +} + + +Foam::tmp<Foam::vectorField> Foam::coordinateSystem::globalToLocal +( + const vectorField& global, + bool translate +) const +{ + if (translate) + { + return rot_->invTransform(global - origin_); + } + + return rot_->invTransform(global); +} + + +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +void Foam::coordinateSystem::operator=(const coordinateSystem& csys) +{ + name_ = csys.name_; + note_ = csys.note_; + origin_ = csys.origin_; + + // Some extra safety + if (csys.rot_.valid()) + { + rot_ = csys.rot_.clone(); + } + else + { + rot_.reset(new coordinateRotations::identity()); + } +} + + +void Foam::coordinateSystem::operator=(coordinateSystem&& csys) +{ + name_ = std::move(csys.name_); + note_ = std::move(csys.note_); + origin_ = std::move(csys.origin_); + rot_ = std::move(csys.rot_); +} + + +void Foam::coordinateSystem::operator=(const autoPtr<coordinateSystem>& csys) +{ + coordinateSystem::operator=(*csys); +} + + +void Foam::coordinateSystem::operator=(autoPtr<coordinateSystem>&& csys) +{ + coordinateSystem::operator=(std::move(*csys)); + csys.clear(); +} + + +void Foam::coordinateSystem::assign(const dictionary& dict) +{ + dict.read("origin", origin_); + + note_.clear(); + dict.readIfPresent("note", note_); + + const dictionary* rotPtr = + dict.csearch("coordinateRotation", false, false).dictPtr(); + + if (rotPtr) + { + rot_ = coordinateRotation::New(*rotPtr); + } + else + { + rot_.reset(new coordinateRotations::axes(dict)); + } +} + + +// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // + +bool Foam::operator!= +( + const coordinateSystem& a, + const coordinateSystem& b +) +{ + return + ( + a.origin() != b.origin() + || a.type() != b.type() + || a.R().R() != b.R().R() + ); +} + + +Foam::Ostream& Foam::operator<<(Ostream& os, const coordinateSystem& csys) +{ + csys.write(os); + os.check(FUNCTION_NAME); + return os; +} + + +// ************************************************************************* // diff --git a/src/meshTools/coordinate/systems/coordinateSystem.H b/src/meshTools/coordinate/systems/coordinateSystem.H new file mode 100644 index 0000000000000000000000000000000000000000..81425308e7166357973ad2165b83ed4e5d162639 --- /dev/null +++ b/src/meshTools/coordinate/systems/coordinateSystem.H @@ -0,0 +1,478 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2018 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::coordinateSystem + +Description + Base class for coordinate system specification, + the default coordinate system type is cartesian. + + All systems are defined by an origin point and a coordinate rotation + By default, the axes specification can be used directly as part of the + coordinate system specification. For example, + + \verbatim + coordinateSystem + { + origin (0 0 0); + e1 (0 1 0); + e3 (1 0 0); + } + \endverbatim + + The same, but in more verbose format: + \verbatim + coordinateSystem + { + type cartesian; + origin (0 0 0); + coordinateRotation + { + type axes; + e1 (0 1 0); + e3 (1 0 0); + } + } + \endverbatim + + Types of coordinateRotation: + -# \link identityRotation none \endlink + -# \link axesRotation axes \endlink + -# axisAngle + -# \link EulerCoordinateRotation euler \endlink + -# \link STARCDCoordinateRotation starcd \endlink + + Type of coordinateSystem: + -# \link cartesianCS cartesian \endlink + -# \link cylindricalCS cylindrical \endlink + +SourceFiles + coordinateSystem.C + coordinateSystemNew.C + +\*---------------------------------------------------------------------------*/ + +#ifndef coordinateSystem_H +#define coordinateSystem_H + +#include "vector.H" +#include "point.H" +#include "tensor.H" +#include "vectorField.H" +#include "pointField.H" +#include "coordinateRotation.H" +#include "autoPtr.H" +#include "tmp.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward Declarations +class coordinateSystem; +class objectRegistry; +class indirectCS; + +/*---------------------------------------------------------------------------*\ + Class coordinateSystem Declaration +\*---------------------------------------------------------------------------*/ + +class coordinateSystem +{ +protected: + + //- Friendship with indirectCS for dispatching to underlying CS + friend indirectCS; + + // Protected data + + //- The coordinate system origin + point origin_; + + //- The Local-to-Global transformation (and inverse). + // May be invalid after a move assignment or transfer + autoPtr<coordinateRotation> rot_; + + //- The name of the coordinate system (optional) + word name_; + + //- An optional note describing the coordinate system + string note_; + + //- Dummy coordinate system for suppressed manipulation + static coordinateSystem dummySystem; + + + // Protected Member Functions + + //- Convert from local coordinate system to the global Cartesian system + //- with optional translation for the origin + virtual vector localToGlobal + ( + const vector& local, + bool translate + ) const; + + //- Convert from local coordinate system to the global Cartesian system + //- with optional translation for the origin + virtual tmp<vectorField> localToGlobal + ( + const vectorField& local, + bool translate + ) const; + + //- Convert from global Cartesian system to the local coordinate system + //- with optional translation for the origin + virtual vector globalToLocal + ( + const vector& global, + bool translate + ) const; + + //- Convert from global Cartesian system to the local coordinate system + //- with optional translation for the origin + virtual tmp<vectorField> globalToLocal + ( + const vectorField& global, + bool translate + ) const; + + //- Assign from dictionary content + void assign(const dictionary& dict); + +public: + + //- Runtime type information + TypeName("coordinateSystem"); + + //- Helper class for construction of coordinateSystem PtrList + // The Istream contains a word followed by a dictionary + class iNew + { + public: + + iNew() = default; + + autoPtr<coordinateSystem> operator()(Istream& is) const + { + return coordinateSystem::New(is); + } + }; + + + // Constructors + + //- Construct null. This is an identity coordinateSystem. + coordinateSystem(); + + //- Copy construct + coordinateSystem(const coordinateSystem& csys); + + //- Move construct + coordinateSystem(coordinateSystem&& csys); + + //- Copy construct with a different name + coordinateSystem + ( + const word& name, + const coordinateSystem& csys + ); + + //- Construct from origin and rotation + coordinateSystem + ( + const point& origin, + const coordinateRotation& crot + ); + + //- Construct from origin and 2 axes + coordinateSystem + ( + const point& origin, + const vector& axis, + const vector& dirn + ); + + //- Construct from origin and rotation + coordinateSystem + ( + const word& name, + const point& origin, + const coordinateRotation& crot + ); + + //- Construct from origin and 2 axes + coordinateSystem + ( + const word& name, + const point& origin, + const vector& axis, + const vector& dirn + ); + + //- Construct from dictionary without a name + explicit coordinateSystem(const dictionary& dict); + + //- Construct from dictionary with a given name + coordinateSystem(const word& name, const dictionary& dict); + + + //- Return clone + autoPtr<coordinateSystem> clone() const + { + return autoPtr<coordinateSystem>::New(*this); + } + + + // Declare run-time constructor selection table + declareRunTimeSelectionTable + ( + autoPtr, + coordinateSystem, + dictionary, + ( + const dictionary& dict + ), + (dict) + ); + + // Declare run-time constructor selection table + declareRunTimeSelectionTable + ( + autoPtr, + coordinateSystem, + registry, + ( + const objectRegistry& obr, + const dictionary& dict + ), + (obr, dict) + ); + + + // Selectors + + //- Select construct from dictionary with reference to objectRegistry + //- for indirectCS entries. + // \param dictName the name of the sub-dictionary to use for the + // description of the coordinate system + // + // \note includes an implicit secondary search for a + // "coordinateSystem" sub-dictionary, for convenience and for + // compatibility with previous versions (1806 and earlier). + static autoPtr<coordinateSystem> New + ( + const objectRegistry& obr, + const dictionary& dict, + const word& dictName = "" + ); + + //- Select constructed from dictionary + // \param dictName the name of the sub-dictionary to use for the + // description of the coordinate system + // + // \note includes an implicit secondary search for a + // "coordinateSystem" sub-dictionary, for convenience and for + // compatibility with previous versions (1806 and earlier). + static autoPtr<coordinateSystem> New + ( + const dictionary& dict, + const word& dictName = "" + ); + + //- Select constructed from Istream + // Expects a name/dictionary as input + static autoPtr<coordinateSystem> New(Istream& is); + + + //- Destructor + virtual ~coordinateSystem() = default; + + + // Member Functions + + // Access + + //- The coordinate system is considered valid if its rotation is valid + virtual bool valid() const + { + return rot_.valid(); + } + + //- Return the name + virtual const word& name() const + { + return name_; + } + + //- Return the optional note + virtual const string& note() const + { + return note_; + } + + //- Return origin + virtual const point& origin() const + { + return origin_; + } + + //- Return const reference to coordinate rotation + virtual const coordinateRotation& R() const + { + return *rot_; + } + + + // Edit + + //- Rename + virtual void rename(const word& newName) + { + name_ = newName; + } + + //- Provide non-constant access to the optional note + virtual string& note() + { + return note_; + } + + //- Edit access to origin + virtual point& origin() + { + return origin_; + } + + //- Reset origin and rotation to an identity coordinateSystem + // Also resets the note + virtual void clear(); + + //- Change the rotation + virtual void setRotation(autoPtr<coordinateRotation>&& crot); + + + // Write + + //- Write + virtual void write(Ostream& os) const; + + //- Write dictionary entry + virtual void writeEntry(const word& keyword, Ostream& os) const; + + + // Transformations + + //- Convert from local coordinate position to global (cartesian) + //- position + point globalPosition(const point& local) const + { + return localToGlobal(local, true); + } + + //- Convert from local coordinate position to global (cartesian) + //- position + tmp<pointField> globalPosition(const pointField& local) const + { + return localToGlobal(local, true); + } + + //- Convert from local vector components to global (cartesian) + //- vector components + vector globalVector(const vector& local) const + { + return localToGlobal(local, false); + } + + //- Convert from local vector components to global (cartesian) + //- vector components + tmp<vectorField> globalVector(const vectorField& local) const + { + return localToGlobal(local, false); + } + + //- Convert from global (cartesian) position to local coordinate + //- position + point localPosition(const point& global) const + { + return globalToLocal(global, true); + } + + //- Convert from global (cartesian) position to local coordinate + //- position + tmp<pointField> localPosition(const pointField& global) const + { + return globalToLocal(global, true); + } + + //- Convert from global (cartesian) vector components to local + //- vector components + vector localVector(const vector& global) const + { + return globalToLocal(global, false); + } + + //- Convert from global (cartesian) vector components to local + //- vector components + tmp<vectorField> localVector(const vectorField& global) const + { + return globalToLocal(global, false); + } + + + // Member Operators + + //- Copy assignment + void operator=(const coordinateSystem& csys); + + //- Move assignment + void operator=(coordinateSystem&& csys); + + //- Copy assignment from autoPtr + void operator=(const autoPtr<coordinateSystem>& csys); + + //- Move assignment from autoPtr + void operator=(autoPtr<coordinateSystem>&& csys); + +}; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Global Operators + +//- Compare inequality +bool operator!=(const coordinateSystem& a, const coordinateSystem& b); + +//- Output operator +Ostream& operator<<(Ostream& os, const coordinateSystem& csys); + + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/coordinate/systems/coordinateSystemNew.C b/src/meshTools/coordinate/systems/coordinateSystemNew.C new file mode 100644 index 0000000000000000000000000000000000000000..9d3ab6a9f0df9c6eb955b0513601d993cae8fcbb --- /dev/null +++ b/src/meshTools/coordinate/systems/coordinateSystemNew.C @@ -0,0 +1,178 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2018 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 "objectRegistry.H" +#include "cartesianCS.H" +#include "indirectCS.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New +( + const objectRegistry& obr, + const dictionary& dict, + const word& dictName +) +{ + const dictionary* dictPtr = + ( + dictName.empty() + ? &dict + : &(dict.subDict(dictName)) + ); + + // Handle a 'coordinateSystem' sub-dictionary + // - in 1806 and earlier, this was handled (rather poorly) in the + // coordinateSystem constructor itself. + + if (coordinateSystem::typeName_() != dictName) + { + const auto compat = + dictPtr->csearch(coordinateSystem::typeName_(), false, false); + + if (compat.isDict()) + { + dictPtr = compat.dictPtr(); + } + else if (compat.found()) + { + const word csName(compat.ref().stream()); + + // Deprecated syntax + + std::cerr + << "--> FOAM IOWarning :" << nl + << " Found 'coordinateSystem' as a keyword" + " instead of as dictionary." << nl + << " Treating as indirect type with name: " << csName + << std::endl; + + error::warnAboutAge("keyword style", 1806); + + return autoPtr<coordinateSystem>(new indirectCS(obr, csName)); + } + } + + + const word modelType + ( + dictPtr->lookupOrDefault<word>("type", cartesianCS::typeName_()) + ); + + auto cstrIter1 = registryConstructorTablePtr_->cfind(modelType); + + if (cstrIter1.found()) + { + return autoPtr<coordinateSystem>(cstrIter1()(obr, *dictPtr)); + } + + auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + + if (!cstrIter.found()) + { + FatalIOErrorInFunction(*dictPtr) + << "Unknown coordinateSystem type " + << modelType << nl << nl + << "Valid types: " + << flatOutput(dictionaryConstructorTablePtr_->sortedToc()) + << " or " + << flatOutput(registryConstructorTablePtr_->sortedToc()) + << exit(FatalIOError); + } + + return autoPtr<coordinateSystem>(cstrIter()(*dictPtr)); +} + + +Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New +( + const dictionary& dict, + const word& dictName +) +{ + const dictionary* dictPtr = + ( + dictName.empty() + ? &dict + : &(dict.subDict(dictName)) + ); + + // Handle a 'coordinateSystem' sub-dictionary + // - in 1806 and earlier, this was handled (rather poorly) in the + // coordinateSystem constructor itself. + + if (coordinateSystem::typeName_() != dictName) + { + const auto compat = + dictPtr->csearch(coordinateSystem::typeName_(), false, false); + + if (compat.isDict()) + { + dictPtr = compat.dictPtr(); + } + else if (compat.found()) + { + FatalIOErrorInFunction(*dictPtr) + << "Unknown coordinateSystem entry type " + << "(should be dictionary)" + << nl << nl + << exit(FatalIOError); + } + } + + const word modelType + ( + dictPtr->lookupOrDefault<word>("type", cartesianCS::typeName_()) + ); + + auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + + if (!cstrIter.found()) + { + FatalIOErrorInFunction(*dictPtr) + << "Unknown coordinateSystem type " + << modelType << nl << nl + << "Valid types: " + << flatOutput(dictionaryConstructorTablePtr_->sortedToc()) + << exit(FatalIOError); + } + + return autoPtr<coordinateSystem>(cstrIter()(*dictPtr)); +} + + +Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New(Istream& is) +{ + const word csName(is); + const dictionary dict(is); + + auto cs = coordinateSystem::New(dict, word::null); + cs->rename(csName); + + return cs; +} + + +// ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/coordinateSystems.C b/src/meshTools/coordinate/systems/coordinateSystems.C similarity index 80% rename from src/meshTools/coordinateSystems/coordinateSystems.C rename to src/meshTools/coordinate/systems/coordinateSystems.C index 08902cdb67f7484381a1951a453ea433d4a63c60..46c4976148039863bf3cb33328ccaab6537f74d3 100644 --- a/src/meshTools/coordinateSystems/coordinateSystems.C +++ b/src/meshTools/coordinate/systems/coordinateSystems.C @@ -32,8 +32,8 @@ License namespace Foam { - defineTypeNameAndDebug(coordinateSystems, 0); - defineTemplateTypeNameAndDebug(IOPtrList<coordinateSystem>, 0); + defineTypeName(coordinateSystems); + defineTemplateTypeName(IOPtrList<coordinateSystem>); } @@ -82,7 +82,7 @@ namespace Foam Foam::coordinateSystems::coordinateSystems(const IOobject& io) : - IOPtrList<coordinateSystem>(io) + IOPtrList<coordinateSystem>(io, coordinateSystem::iNew()) {} @@ -156,7 +156,7 @@ Foam::labelList Foam::coordinateSystems::findIndices(const keyType& key) const } else { - indices.setSize(this->size()); + indices.resize(this->size()); label count = 0; forAll(*this, i) { @@ -165,7 +165,7 @@ Foam::labelList Foam::coordinateSystems::findIndices(const keyType& key) const indices[count++] = i; } } - indices.setSize(count); + indices.resize(count); } return indices; @@ -208,6 +208,51 @@ bool Foam::coordinateSystems::found(const keyType& key) const } +const Foam::coordinateSystem* +Foam::coordinateSystems::lookupPtr(const word& name) const +{ + const label index = this->findIndex(name); + + if (coordinateSystem::debug) + { + InfoInFunction + << "Global coordinate system: " + << name << "=" << index << endl; + } + + if (index < 0) + { + return nullptr; + } + + return this->operator()(index); +} + + +const Foam::coordinateSystem& +Foam::coordinateSystems::lookup(const word& name) const +{ + const label index = this->findIndex(name); + + if (index < 0) + { + FatalErrorInFunction + << "Could not find coordinate system: " << name << nl + << "available coordinate systems: " + << flatOutput(names()) << nl << nl + << exit(FatalError); + } + if (coordinateSystem::debug) + { + InfoInFunction + << "Global coordinate system: " + << name << "=" << index << endl; + } + + return this->operator[](index); +} + + Foam::wordList Foam::coordinateSystems::names() const { wordList output(size()); @@ -248,10 +293,12 @@ bool Foam::coordinateSystems::writeData(Ostream& os) const { os << nl << size() << nl << token::BEGIN_LIST; - forAll(*this, i) + const PtrList<coordinateSystem>& list = *this; + + for (const coordinateSystem& csys : list) { os << nl; - operator[](i).writeDict(os, true); + csys.writeEntry(csys.name(), os); } os << token::END_LIST << nl; diff --git a/src/meshTools/coordinateSystems/coordinateSystems.H b/src/meshTools/coordinate/systems/coordinateSystems.H similarity index 88% rename from src/meshTools/coordinateSystems/coordinateSystems.H rename to src/meshTools/coordinate/systems/coordinateSystems.H index 1e429b97c284b444322b8aba93c372eb6883eb7d..c2ef5ab8c9f5cc49f4eb20b57236755715871180 100644 --- a/src/meshTools/coordinateSystems/coordinateSystems.H +++ b/src/meshTools/coordinate/systems/coordinateSystems.H @@ -25,7 +25,7 @@ Class Foam::coordinateSystems Description - Provides a centralized coordinateSystem collection. + A centralized collection of named coordinate systems. Note Mixing normal constructors and the coordinateSystems::New constructor @@ -36,8 +36,12 @@ Note ( cat1 { - coordinateSystem system_10; - porosity 0.781; + coordinateSystem + { + type indirect; + name _10; + } + porosity 0.781; Darcy { d d [0 -2 0 0 0] (-1000 -1000 0.50753e+08); @@ -57,8 +61,8 @@ SourceFiles #ifndef coordinateSystems_H #define coordinateSystems_H -#include "coordinateSystem.H" #include "IOPtrList.H" +#include "coordinateSystem.H" #include "wordRes.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -86,7 +90,7 @@ class coordinateSystems public: //- Runtime type information - TypeName("coordinateSystems"); + TypeNameNoDebug("coordinateSystems"); // Constructors @@ -111,7 +115,7 @@ public: // Selectors //- Return previously registered or read construct from "constant" - static const coordinateSystems& New(const objectRegistry&); + static const coordinateSystems& New(const objectRegistry& obr); // Member Functions @@ -125,6 +129,12 @@ public: //- Search for given key bool found(const keyType& key) const; + //- Return reference to named coordinateSystem or FatalErrror + const coordinateSystem& lookup(const word& name) const; + + //- Return pointer to named coordinateSystem or nullptr on error + const coordinateSystem* lookupPtr(const word& name) const; + //- A list of the coordinate-system names wordList names() const; @@ -144,7 +154,7 @@ public: } //- Write data - bool writeData(Ostream&) const; + bool writeData(Ostream& os) const; }; diff --git a/src/meshTools/coordinateSystems/cylindricalCS.C b/src/meshTools/coordinate/systems/cylindricalCS.C similarity index 64% rename from src/meshTools/coordinateSystems/cylindricalCS.C rename to src/meshTools/coordinate/systems/cylindricalCS.C index fda455545ac1e325adb458d0e66e8c9a1c82b40b..26f0156facde80957647ea750d443ab1ca5f7afc 100644 --- a/src/meshTools/coordinateSystems/cylindricalCS.C +++ b/src/meshTools/coordinate/systems/cylindricalCS.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -24,96 +24,98 @@ License \*---------------------------------------------------------------------------*/ #include "cylindricalCS.H" - -#include "one.H" -#include "mathematicalConstants.H" +#include "unitConversion.H" #include "addToRunTimeSelectionTable.H" +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeName(cylindricalCS); + addToRunTimeSelectionTable(coordinateSystem, cylindricalCS, dictionary); +} + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::cylindricalCS::cylindricalCS(const bool inDegrees) +Foam::cylindricalCS::cylindricalCS() : coordinateSystem(), - inDegrees_(inDegrees) + degrees_(false) {} -Foam::cylindricalCS::cylindricalCS -( - const coordinateSystem& cs, - const bool inDegrees -) +Foam::cylindricalCS::cylindricalCS(const bool degrees) : - coordinateSystem(cs), - inDegrees_(inDegrees) + coordinateSystem(), + degrees_(degrees) {} Foam::cylindricalCS::cylindricalCS ( - const word& name, - const coordinateSystem& cs, - const bool inDegrees + const coordinateSystem& csys, + const bool degrees ) : - coordinateSystem(name, cs), - inDegrees_(inDegrees) + coordinateSystem(csys), + degrees_(degrees) {} Foam::cylindricalCS::cylindricalCS ( - const word& name, const point& origin, - const coordinateRotation& cr, - const bool inDegrees + const coordinateRotation& crot, + const bool degrees ) : - coordinateSystem(name, origin, cr), - inDegrees_(inDegrees) + coordinateSystem(origin, crot), + degrees_(degrees) {} Foam::cylindricalCS::cylindricalCS ( - const word& name, const point& origin, const vector& axis, const vector& dirn, - const bool inDegrees + const bool degrees ) : - coordinateSystem(name, origin, axis, dirn), - inDegrees_(inDegrees) + coordinateSystem(origin, axis, dirn), + degrees_(degrees) {} Foam::cylindricalCS::cylindricalCS ( const word& name, - const dictionary& dict + const point& origin, + const vector& axis, + const vector& dirn, + const bool degrees ) : - coordinateSystem(name, dict), - inDegrees_(dict.lookupOrDefault("degrees", true)) + cylindricalCS(origin, axis, dirn, degrees) +{} + + +Foam::cylindricalCS::cylindricalCS(const dictionary& dict) +: + coordinateSystem(dict), + degrees_(dict.lookupOrDefault("degrees", true)) {} Foam::cylindricalCS::cylindricalCS ( - const objectRegistry& obr, + const word& name, const dictionary& dict ) : - coordinateSystem(obr, dict), - inDegrees_(dict.lookupOrDefault("degrees", true)) -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::cylindricalCS::~cylindricalCS() + coordinateSystem(name, dict), + degrees_(dict.lookupOrDefault("degrees", true)) {} @@ -121,13 +123,51 @@ Foam::cylindricalCS::~cylindricalCS() bool Foam::cylindricalCS::inDegrees() const { - return inDegrees_; + return degrees_; } bool& Foam::cylindricalCS::inDegrees() { - return inDegrees_; + return degrees_; +} + + +void Foam::cylindricalCS::writeEntry(const word& keyword, Ostream& os) const +{ + if (!valid()) + { + return; + } + + const bool subDict = !keyword.empty(); + + if (subDict) + { + os.beginBlock(keyword); + + os.writeEntry("type", type()); + + if (note_.size()) + { + // The 'note' is optional + os.writeEntry("note", note_); + } + + if (!degrees_) + { + os.writeEntry("degrees", "false"); + } + } + + os.writeEntry("origin", origin_); + + rot_->writeEntry("coordinateRotation", os); + + if (subDict) + { + os.endBlock(); + } } @@ -137,9 +177,10 @@ Foam::vector Foam::cylindricalCS::localToGlobal bool translate ) const { - scalar theta + const scalar theta ( - local.y()*(inDegrees_ ? constant::mathematical::pi/180.0 : 1.0) + local.y() + * (degrees_ ? degToRad() : 1.0) ); return coordinateSystem::localToGlobal @@ -159,10 +200,9 @@ Foam::tmp<Foam::vectorField> Foam::cylindricalCS::localToGlobal scalarField theta ( local.component(vector::Y) - *(inDegrees_ ? constant::mathematical::pi/180.0 : 1.0) + * (degrees_ ? degToRad() : 1.0) ); - vectorField lc(local.size()); lc.replace(vector::X, local.component(vector::X)*cos(theta)); lc.replace(vector::Y, local.component(vector::X)*sin(theta)); @@ -190,7 +230,7 @@ Foam::vector Foam::cylindricalCS::globalToLocal ( lc.y(), lc.x() - )*(inDegrees_ ? 180.0/constant::mathematical::pi : 1.0), + ) * (degrees_ ? radToDeg() : 1.0), lc.z() ); } @@ -207,8 +247,8 @@ Foam::tmp<Foam::vectorField> Foam::cylindricalCS::globalToLocal coordinateSystem::globalToLocal(global, translate) ); - tmp<vectorField> tresult(new vectorField(lc.size())); - vectorField& result = tresult.ref(); + auto tresult = tmp<vectorField>::New(lc.size()); + auto& result = tresult.ref(); result.replace ( @@ -223,7 +263,7 @@ Foam::tmp<Foam::vectorField> Foam::cylindricalCS::globalToLocal ( lc.component(vector::Y), lc.component(vector::X) - )*(inDegrees_ ? 180.0/constant::mathematical::pi : 1.0) + ) * (degrees_ ? radToDeg() : 1.0) ); result.replace(vector::Z, lc.component(vector::Z)); diff --git a/src/meshTools/coordinateSystems/cylindricalCS.H b/src/meshTools/coordinate/systems/cylindricalCS.H similarity index 61% rename from src/meshTools/coordinateSystems/cylindricalCS.H rename to src/meshTools/coordinate/systems/cylindricalCS.H index 4504231caeec791f1ce012f02afbd1ce1372f667..810808d21618d997a1263af5dae34ff374a2259b 100644 --- a/src/meshTools/coordinateSystems/cylindricalCS.H +++ b/src/meshTools/coordinate/systems/cylindricalCS.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,7 +25,13 @@ Class Foam::cylindricalCS Description - Cylindrical coordinate system + A cylindrical coordinate system + + \heading Dictionary entries + \table + Property | Description | Required | Default + type | type name: cylindrical | yes | + \endtable SourceFiles cylindricalCS.C @@ -52,91 +58,106 @@ class cylindricalCS { // Private data members - //- Are angles in degrees? (default = true) - bool inDegrees_; + //- Angles in degrees (default = true) + bool degrees_; protected: // Protected Member Functions - //- Convert from local coordinate system to the global Cartesian system // with optional translation for the origin - virtual vector localToGlobal(const vector&, bool translate) const; + virtual vector localToGlobal + ( + const vector& local, + bool translate + ) const; //- Convert from local coordinate system to the global Cartesian system // with optional translation for the origin virtual tmp<vectorField> localToGlobal ( - const vectorField&, + const vectorField& local, bool translate ) const; //- Convert from global Cartesian system to the local coordinate system // with optional translation for the origin - virtual vector globalToLocal(const vector&, bool translate) const; + virtual vector globalToLocal + ( + const vector& global, + bool translate + ) const; //- Convert from global Cartesian system to the local coordinate system // with optional translation for the origin virtual tmp<vectorField> globalToLocal ( - const vectorField&, + const vectorField& global, bool translate ) const; public: + //- Runtime type information + TypeNameNoDebug("cylindrical"); + // Constructors - //- Construct null - cylindricalCS(const bool inDegrees=true); + //- Construct null (identity coordinateSystem), angles in radians + cylindricalCS(); - //- Construct copy - cylindricalCS - ( - const coordinateSystem&, - const bool inDegrees=true - ); + //- Construct null (identity coordinateSystem), + //- angles in degrees/radians + cylindricalCS(const bool degrees); + + //- Copy construct + cylindricalCS(const cylindricalCS& csys) = default; + + //- Copy construct from another coordinateSystem type + cylindricalCS(const coordinateSystem& csys, const bool degrees); - //- Construct copy with a different name + //- Construct from origin and rotation cylindricalCS ( - const word& name, - const coordinateSystem&, - const bool inDegrees=true + const point& origin, + const coordinateRotation& crot, + const bool degrees ); - //- Construct from origin and rotation + //- Construct from origin and 2 axes cylindricalCS ( - const word& name, const point& origin, - const coordinateRotation&, - const bool inDegrees=true + const vector& axis, + const vector& dirn, + const bool degrees ); //- Construct from origin and 2 axes cylindricalCS ( - const word& name, + const word& unused, const point& origin, const vector& axis, const vector& dirn, - const bool inDegrees=true + const bool degrees ); - //- Construct from dictionary and name - cylindricalCS(const word&, const dictionary&); + //- Construct from dictionary without a name + // Default angle units is degrees. + explicit cylindricalCS(const dictionary& dict); - //- Construct from dictionary and objectRegistry - cylindricalCS(const objectRegistry&, const dictionary&); + //- Construct from dictionary with a given name + // Default angle units is degrees. + cylindricalCS(const word& name, const dictionary& dict); //- Destructor - virtual ~cylindricalCS(); + virtual ~cylindricalCS() = default; // Member Functions @@ -144,8 +165,12 @@ public: //- Are angles in degrees? bool inDegrees() const; - //- Non-const access to inDegrees + //- Non-const access to degrees vs radians. bool& inDegrees(); + + //- Write dictionary entry + virtual void writeEntry(const word& keyword, Ostream& os) const; + }; diff --git a/src/meshTools/coordinate/systems/indirectCS.C b/src/meshTools/coordinate/systems/indirectCS.C new file mode 100644 index 0000000000000000000000000000000000000000..1f267c783ae8fea37ac4a62d4825e0acfa149935 --- /dev/null +++ b/src/meshTools/coordinate/systems/indirectCS.C @@ -0,0 +1,106 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 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 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 "indirectCS.H" +#include "coordinateSystems.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(indirectCS, 0); + addToRunTimeSelectionTable(coordinateSystem, indirectCS, registry); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::indirectCS::indirectCS(const indirectCS& csys) +: + coordinateSystem(), + backend_(csys.backend_) +{} + + +Foam::indirectCS::indirectCS(indirectCS&& csys) +: + coordinateSystem(), + backend_(std::move(csys.backend_)) +{} + + +// Use lookup() instead of lookupPtr() to trigger FatalError on any problems +Foam::indirectCS::indirectCS +( + const objectRegistry& obr, + const word& name +) +: + coordinateSystem(), + backend_(&(coordinateSystems::New(obr).lookup(name))) +{} + + +Foam::indirectCS::indirectCS +( + const objectRegistry& obr, + const dictionary& dict +) +: + indirectCS(obr, dict.get<word>("name")) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::indirectCS::write(Ostream& os) const +{ + writeEntry("coordinateSystem", os); +} + + +void Foam::indirectCS::writeEntry(const word& keyword, Ostream& os) const +{ + if (!valid()) + { + return; + } + + const bool subDict = !keyword.empty(); + + if (subDict) + { + os.beginBlock(keyword); + + os.writeEntry("type", type()); + os.writeEntry("name", name()); + + os.endBlock(); + } +} + + +// ************************************************************************* // diff --git a/src/meshTools/coordinate/systems/indirectCS.H b/src/meshTools/coordinate/systems/indirectCS.H new file mode 100644 index 0000000000000000000000000000000000000000..7eff2894cd060283f8698d9723859a0d6edb7be5 --- /dev/null +++ b/src/meshTools/coordinate/systems/indirectCS.H @@ -0,0 +1,245 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 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 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::indirectCS + +Description + A coordinate system forward to a global coordinate system that is + normally provided by the constant/coordinateSystems file. + + \heading Dictionary entries + \table + Property | Description | Required | Default + type | type name: indirect | yes | + name | name of the referenced system | yes | + \endtable + +SourceFiles + indirectCS.C + +\*---------------------------------------------------------------------------*/ + +#ifndef indirectCS_H +#define indirectCS_H + +#include "coordinateSystem.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class indirectCS Declaration +\*---------------------------------------------------------------------------*/ + +class indirectCS +: + public coordinateSystem +{ + // Private Data + + //- The real coordinate system + const coordinateSystem* backend_; + + + // Private Member Functions + + //- Disallow construct null + indirectCS() = delete; + + +protected: + + // Protected Member Functions + + //- Convert from local coordinate system to the global Cartesian system + //- with optional translation for the origin + virtual vector localToGlobal + ( + const vector& local, + bool translate + ) const + { + return backend_->localToGlobal(local, translate); + } + + //- Convert from local coordinate system to the global Cartesian system + //- with optional translation for the origin + virtual tmp<vectorField> localToGlobal + ( + const vectorField& local, + bool translate + ) const + { + return backend_->localToGlobal(local, translate); + } + + //- Convert from global Cartesian system to the local coordinate system + //- with optional translation for the origin + virtual vector globalToLocal + ( + const vector& global, + bool translate + ) const + { + return backend_->globalToLocal(global, translate); + } + + //- Convert from global Cartesian system to the local coordinate system + //- with optional translation for the origin + virtual tmp<vectorField> globalToLocal + ( + const vectorField& global, + bool translate + ) const + { + return backend_->globalToLocal(global, translate); + } + + +public: + + //- Runtime type information + TypeName("indirect"); + + + // Constructors + + //- Copy construct + indirectCS(const indirectCS& csys); + + //- Move construct + indirectCS(indirectCS&& csys); + + //- Construct from global lookup + indirectCS(const objectRegistry& obr, const word& name); + + //- Construct from global lookup + indirectCS(const objectRegistry& obr, const dictionary& dict); + + + //- Destructor + virtual ~indirectCS() = default; + + + // Member Functions + + // Access + + //- Reference to the underlying coordinate system + virtual const coordinateSystem& cs() const + { + return *backend_; + } + + //- Is the coordinate system valid? + virtual bool valid() const + { + return backend_ && backend_->valid(); + } + + //- Return the name + virtual const word& name() const + { + return backend_->name_; + } + + //- Return the optional note + virtual const string& note() const + { + return backend_->note(); + } + + //- Return origin + virtual const point& origin() const + { + return backend_->origin(); + } + + //- Return const reference to coordinate rotation + virtual const coordinateRotation& R() const + { + return backend_->R(); + } + + + // Edit + + //- Rename (ignored) + void rename(const word& newName) {} + + //- Provide non-constant access to the optional note + string& note() + { + NotImplemented; + return dummySystem.note(); + } + + //- Edit access to origin (disallowed) + virtual point& origin() + { + NotImplemented; + return dummySystem.origin(); + } + + //- Clear (ignored) + virtual void clear() {} + + //- Change the rotation (disallowed) + virtual void setRotation(autoPtr<coordinateRotation>&& crot) + { + NotImplemented; + } + + + // Write + + //- Write + virtual void write(Ostream& os) const; + + //- Write dictionary entry + virtual void writeEntry(const word& keyword, Ostream& os) const; + + + // Member Operators + + //- No copy assignment + void operator=(const coordinateSystem& csys) = delete; + + //- No move assignment + void operator=(coordinateSystem&& csys) = delete; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/coordinate/transform/cylindricalTransform.H b/src/meshTools/coordinate/transform/cylindricalTransform.H new file mode 100644 index 0000000000000000000000000000000000000000..a5219e83c3db80ed84a8eb87e065cbd2ac9c4389 --- /dev/null +++ b/src/meshTools/coordinate/transform/cylindricalTransform.H @@ -0,0 +1,249 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 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 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::cylindricalTransform + +Description + A cylindrical transformation with a position-dependent rotational + field. + +SourceFiles + cylindrical.C + +\*---------------------------------------------------------------------------*/ + +#ifndef cylindricalTransform_H +#define cylindricalTransform_H + +#include "point.H" +#include "pointField.H" +#include "vectorField.H" +#include "tensorField.H" +#include "symmTensorField.H" +#include "tmp.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward Declarations +class coordinateSystem; + +/*---------------------------------------------------------------------------*\ + Class cylindricalTransform Declaration +\*---------------------------------------------------------------------------*/ + +template<class PointField> +class cylindricalTransform +{ + // Private Data + + //- The coordinate system origin + const point origin_; + + //- The cylindrical z-axis + const vector axis_; + + //- The global positions + const PointField& points_; + + //- The size of the transform (number of points). + // Only managed separately to avoid possible compilation issues + const label size_; + + + // Private Member Functions + + //- Implementation detail for transform(vector) + inline vector transformImpl + ( + const vector& input, + const label pos, + const bool forward + ) const; + + + //- Implementation detail for transformVector + inline symmTensor transformVectorImpl + ( + const vector& input, + const label pos + ) const; + + //- Implementation detail for transformTensor + inline tensor transformTensorImpl + ( + const tensor& input, + const label pos + ) const; + + + // Member Operators + + //- No null construction + cylindricalTransform() = delete; + + //- No copy construct + cylindricalTransform(const cylindricalTransform&) = delete; + + //- No copy assignment + void operator=(const cylindricalTransform&) = delete; + + +public: + + // Constructors + + //- Construct from the origin, axis and a field of positions + cylindricalTransform + ( + const point& origin, + const vector& axis, + const PointField& globalPositions + ); + + //- Copy construct from origin, axis of a coordinateSystem and + //- a field of positions + cylindricalTransform + ( + const coordinateSystem& csys, + const PointField& globalPositions + ); + + + //- Destructor + ~cylindricalTransform() = default; + + + // Member Functions + + //- Return the global origin + inline const point& origin() const + { + return origin_; + } + + //- Return local Cartesian z-axis in global coordinates + inline const vector e3() const + { + return axis_; + } + + //- The global positions. + // This determines the size of the tranformation + inline const PointField& points() const + { + return points_; + } + + //- The size of the tranformation (number of points) + inline label size() const + { + return size_; + } + + + // Transformations + + //- Transform a vector at the given position within the + //- transformation dependent on the global positions + // \return vector + vector transform(const vector& input, const label pos) const; + + //- Transform a vector at all positions of the + //- transformation dependent on the global positions + // \return tmp vectorField + tmp<vectorField> transform(const vector& input) const; + + //- Transform vector field using transformation dependent + //- on the global positions + // \return tmp vectorField + tmp<vectorField> transform(const vectorField& input) const; + + + //- Inverse transform a vector at the given position within the + //- transformation dependent on the global positions + // \return tmp vectorField + vector invTransform(const vector& input, const label pos) const; + + //- Inverse transform a vector at all positions of the + //- transformation dependent on the global positions + // \return tmp vectorField + tmp<vectorField> invTransform(const vector& input) const; + + //- Inverse transform vector field using transformation dependent + //- on the global positions + // \return tmp vectorField + tmp<vectorField> invTransform(const vectorField& input) const; + + + //- Transform a vector at the given position within the + //- transformation dependent on the global positions + // \return tmp symmTensorField + symmTensor transformVector(const vector& input, const label pos) const; + + //- Transform a vector at all positions of the + //- transformation dependent on the global positions + // \return tmp symmTensorField + tmp<symmTensorField> transformVector(const vector& input) const; + + //- Transform vector field using transformation dependent + //- on the global positions + // \return tmp symmTensorField + tmp<symmTensorField> transformVector(const vectorField& input) const; + + + //- Transform a tensor at the given position within the + //- transformation dependent on the global positions. + // \return tensor + tensor transformTensor(const tensor& input, const label pos) const; + + //- Transform a tensor at all positions of the + //- transformation dependent on the global positions. + // \return tmp tensorField + tmp<tensorField> transformTensor(const tensor& input) const; + + //- Transform a tensorField using transformation dependent + //- on the global positions. + // \return tmp tensorField + tmp<tensorField> transformTensor(const tensorField& input) const; +}; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "cylindricalTransformTemplates.C" +#endif + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/coordinate/transform/cylindricalTransformTemplates.C b/src/meshTools/coordinate/transform/cylindricalTransformTemplates.C new file mode 100644 index 0000000000000000000000000000000000000000..acbcfebb8c499386a5842aa87a825837bef29a37 --- /dev/null +++ b/src/meshTools/coordinate/transform/cylindricalTransformTemplates.C @@ -0,0 +1,353 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 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 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 "cylindricalTransform.H" +#include "coordinateRotation.H" +#include "coordinateSystem.H" +#include "axesRotation.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template<class PointField> +inline Foam::vector +Foam::cylindricalTransform<PointField>::transformImpl +( + const vector& input, + const label pos, + const bool forward +) const +{ + // Do we trap for zero size, co-linearity etc here? + const vector dirn(normalised(points_[pos] - origin_)); + + const coordinateRotations::axes crot(e3(), dirn); + + if (forward) + { + return crot.R() & input; + } + else + { + return crot.Rtr() & input; + } +} + + +template<class PointField> +inline Foam::symmTensor +Foam::cylindricalTransform<PointField>::transformVectorImpl +( + const vector& input, + const label pos +) const +{ + // Do we trap for zero size, co-linearity etc here? + const vector dirn(normalised(points_[pos] - origin_)); + + const tensor rot = coordinateRotations::axes(e3(), dirn).R(); + + return coordinateRotation::transformPrincipal(rot, input); +} + + +template<class PointField> +inline Foam::tensor +Foam::cylindricalTransform<PointField>::transformTensorImpl +( + const tensor& input, + const label pos +) const +{ + // Do we trap for zero size, co-linearity etc here? + const vector dirn(normalised(points_[pos] - origin_)); + + const coordinateRotations::axes crot(e3(), dirn); + + return (crot.R() & input & crot.Rtr()); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class PointField> +Foam::cylindricalTransform<PointField>::cylindricalTransform +( + const point& origin, + const vector& axis, + const PointField& globalPositions +) +: + origin_(origin), + axis_(axis), + points_(globalPositions), + size_(globalPositions.size()) +{} + + +template<class PointField> +Foam::cylindricalTransform<PointField>::cylindricalTransform +( + const coordinateSystem& csys, + const PointField& globalPositions +) +: + origin_(csys.origin()), + axis_(csys.R().e3()), + points_(globalPositions), + size_(globalPositions.size()) +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +template<class PointField> +Foam::vector +Foam::cylindricalTransform<PointField>::transform +( + const vector& input, + const label pos +) const +{ + return this->transformImpl(input, pos, true); +} + + +template<class PointField> +Foam::tmp<Foam::vectorField> +Foam::cylindricalTransform<PointField>::transform +( + const vector& input +) const +{ + auto tresult = tmp<vectorField>::New(size_); + auto& result = tresult.ref(); + + for (label pos = 0; pos < size_; ++pos) + { + result[pos] = this->transformImpl(input, pos, true); + } + + return tresult; +} + + +template<class PointField> +Foam::tmp<Foam::vectorField> +Foam::cylindricalTransform<PointField>::transform +( + const vectorField& input +) const +{ + if (input.size() != size_) + { + FatalErrorInFunction + << "positions has different size from vectorField" + << abort(FatalError); + } + + auto tresult = tmp<vectorField>::New(size_); + auto& result = tresult.ref(); + + for (label pos = 0; pos < size_; ++pos) + { + result[pos] = transformImpl(input[pos], pos, true); + } + + return tresult; +} + + +template<class PointField> +Foam::vector +Foam::cylindricalTransform<PointField>::invTransform +( + const vector& input, + const label pos +) const +{ + return transformImpl(input, pos, false); +} + + +template<class PointField> +Foam::tmp<Foam::vectorField> +Foam::cylindricalTransform<PointField>::invTransform +( + const vector& input +) const +{ + auto tresult = tmp<vectorField>::New(size_); + auto& result = tresult.ref(); + + for (label pos = 0; pos < size_; ++pos) + { + result[pos] = transformImpl(input, pos, false); + } + + return tresult; +} + + +template<class PointField> +Foam::tmp<Foam::vectorField> +Foam::cylindricalTransform<PointField>::invTransform +( + const vectorField& input +) const +{ + if (input.size() != size_) + { + FatalErrorInFunction + << "positions has different size from vectorField" + << abort(FatalError); + } + + auto tresult = tmp<vectorField>::New(size_); + auto& result = tresult.ref(); + + for (label pos = 0; pos < size_; ++pos) + { + result[pos] = transformImpl(input[pos], pos, false); + } + + return tresult; +} + + +template<class PointField> +Foam::symmTensor +Foam::cylindricalTransform<PointField>::transformVector +( + const vector& input, + const label pos +) const +{ + return transformVectorImpl(input, pos); +} + + +template<class PointField> +Foam::tmp<Foam::symmTensorField> +Foam::cylindricalTransform<PointField>::transformVector +( + const vector& input +) const +{ + auto tresult = tmp<symmTensorField>::New(size_); + auto& result = tresult.ref(); + + for (label pos = 0; pos < size_; ++pos) + { + result[pos] = transformVectorImpl(input, pos); + } + + return tresult; +} + + +template<class PointField> +Foam::tmp<Foam::symmTensorField> +Foam::cylindricalTransform<PointField>::transformVector +( + const vectorField& input +) const +{ + if (input.size() != size_) + { + FatalErrorInFunction + << "positions has different size from vectorField" + << abort(FatalError); + } + + auto tresult = tmp<symmTensorField>::New(size_); + auto& result = tresult.ref(); + + for (label pos = 0; pos < size_; ++pos) + { + result[pos] = transformVectorImpl(input[pos], pos); + } + + return tresult; +} + + +template<class PointField> +Foam::tensor +Foam::cylindricalTransform<PointField>::transformTensor +( + const tensor& input, + const label pos +) const +{ + return transformTensorImpl(input, pos); +} + + +template<class PointField> +Foam::tmp<Foam::tensorField> +Foam::cylindricalTransform<PointField>::transformTensor +( + const tensor& input +) const +{ + auto tresult = tmp<tensorField>::New(size_); + auto& result = tresult.ref(); + + for (label pos = 0; pos < size_; ++pos) + { + result[pos] = transformTensorImpl(input, pos); + } + + return tresult; +} + + +template<class PointField> +Foam::tmp<Foam::tensorField> +Foam::cylindricalTransform<PointField>::transformTensor +( + const tensorField& input +) const +{ + if (input.size() != size_) + { + FatalErrorInFunction + << "positions has different size from vectorField" + << abort(FatalError); + } + + auto tresult = tmp<tensorField>::New(size_); + auto& result = tresult.ref(); + + for (label pos = 0; pos < size_; ++pos) + { + result[pos] = transformTensorImpl(input[pos], pos); + } + + return tresult; +} + + +// ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.C b/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.C deleted file mode 100644 index 5a7d86e8289abd916cd690334396094f69c60320..0000000000000000000000000000000000000000 --- a/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.C +++ /dev/null @@ -1,276 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2017 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 "EulerCoordinateRotation.H" - -#include "mathematicalConstants.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(EulerCoordinateRotation, 0); - addToRunTimeSelectionTable - ( - coordinateRotation, - EulerCoordinateRotation, - dictionary - ); - addToRunTimeSelectionTable - ( - coordinateRotation, - EulerCoordinateRotation, - objectRegistry - ); -} - -// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // - -Foam::vector Foam::EulerCoordinateRotation::transform(const vector& st) const -{ - return (R_ & st); -} - - -Foam::vector Foam::EulerCoordinateRotation::invTransform -( - const vector& st -) const -{ - return (Rtr_ & st); -} - - -Foam::tmp<Foam::vectorField> Foam::EulerCoordinateRotation::transform -( - const vectorField& st -) const -{ - NotImplemented; - return nullptr; -} - - -Foam::tmp<Foam::vectorField> Foam::EulerCoordinateRotation::invTransform -( - const vectorField& st -) const -{ - NotImplemented; - return nullptr; -} - - -const Foam::tensorField& Foam::EulerCoordinateRotation::Tr() const -{ - NotImplemented; - return NullObjectRef<tensorField>(); -} - - -Foam::tmp<Foam::tensorField> Foam::EulerCoordinateRotation::transformTensor -( - const tensorField& st -) const -{ - NotImplemented; - return nullptr; -} - - -Foam::tensor Foam::EulerCoordinateRotation::transformTensor -( - const tensor& st -) const -{ - return (R_ & st & Rtr_); -} - - -Foam::tmp<Foam::tensorField> Foam::EulerCoordinateRotation::transformTensor -( - const tensorField& st, - const labelList& cellMap -) const -{ - NotImplemented; - return nullptr; -} - - -Foam::tmp<Foam::symmTensorField> Foam::EulerCoordinateRotation:: -transformVector -( - const vectorField& st -) const -{ - tmp<symmTensorField> tfld(new symmTensorField(st.size())); - symmTensorField& fld = tfld.ref(); - - forAll(fld, i) - { - fld[i] = transformPrincipal(R_, st[i]); - } - return tfld; -} - - -Foam::symmTensor Foam::EulerCoordinateRotation::transformVector -( - const vector& st -) const -{ - return transformPrincipal(R_, st); -} - - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -void Foam::EulerCoordinateRotation::calcTransform -( - const scalar phiAngle, - const scalar thetaAngle, - const scalar psiAngle, - const bool inDegrees -) -{ - scalar phi = phiAngle; - scalar theta = thetaAngle; - scalar psi = psiAngle; - - if (inDegrees) - { - phi *= constant::mathematical::pi/180.0; - theta *= constant::mathematical::pi/180.0; - psi *= constant::mathematical::pi/180.0; - } - - R_ = - ( - tensor - ( - cos(phi)*cos(psi) - sin(phi)*sin(psi)*cos(theta), - -sin(phi)*cos(psi)*cos(theta) - cos(phi)*sin(psi), - sin(phi)*sin(theta), - - cos(phi)*sin(psi)*cos(theta) + sin(phi)*cos(psi), - cos(phi)*cos(psi)*cos(theta) - sin(phi)*sin(psi), - -cos(phi)*sin(theta), - - sin(psi)*sin(theta), - cos(psi)*sin(theta), - cos(theta) - ) - ); - - Rtr_ = R_.T(); -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::EulerCoordinateRotation::EulerCoordinateRotation() -: - R_(sphericalTensor::I), - Rtr_(sphericalTensor::I) -{} - - -Foam::EulerCoordinateRotation::EulerCoordinateRotation -( - const EulerCoordinateRotation& r -) -: - R_(r.R_), - Rtr_(r.Rtr_) -{} - - -Foam::EulerCoordinateRotation::EulerCoordinateRotation -( - const vector& phiThetaPsi, - const bool inDegrees -) -: - R_(sphericalTensor::I), - Rtr_(sphericalTensor::I) -{ - calcTransform - ( - phiThetaPsi.component(vector::X), - phiThetaPsi.component(vector::Y), - phiThetaPsi.component(vector::Z), - inDegrees - ); -} - - -Foam::EulerCoordinateRotation::EulerCoordinateRotation -( - const scalar phiAngle, - const scalar thetaAngle, - const scalar psiAngle, - const bool inDegrees -) -: - R_(sphericalTensor::I), - Rtr_(sphericalTensor::I) -{ - calcTransform(phiAngle, thetaAngle, psiAngle, inDegrees); -} - - -Foam::EulerCoordinateRotation::EulerCoordinateRotation -( - const dictionary& dict -) -: - R_(sphericalTensor::I), - Rtr_(sphericalTensor::I) -{ - const vector rotation(dict.lookup("rotation")); - - calcTransform - ( - rotation.component(vector::X), - rotation.component(vector::Y), - rotation.component(vector::Z), - dict.lookupOrDefault("degrees", true) - ); -} - - -Foam::EulerCoordinateRotation::EulerCoordinateRotation -( - const dictionary& dict, - const objectRegistry& -) -: - EulerCoordinateRotation(dict) -{} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.H b/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.H deleted file mode 100644 index 6b2c44f809a1d880d14881dc0ba9016a5ceb3c08..0000000000000000000000000000000000000000 --- a/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.H +++ /dev/null @@ -1,240 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2017 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::EulerCoordinateRotation - -Description - A coordinateRotation defined in the z-x-z (intrinsic) Euler convention. - - The 3 rotations are defined in the Euler intrinsic convention - (around Z, around X' and around Z''). - The order of the parameter arguments matches this rotation order. - - For reference and illustration, see - http://mathworld.wolfram.com/EulerAngles.html - and - https://en.wikipedia.org/wiki/Euler_angles#Conventions - - Note, however, that it is the reverse transformation - (local->global) that is defined here. - - - the rotation angles are in degrees, unless otherwise explicitly specified: - - \verbatim - coordinateRotation - { - type EulerRotation; - degrees false; - rotation (0 0 3.141592654); - } - \endverbatim - -SourceFiles - EulerCoordinateRotation.C - -\*---------------------------------------------------------------------------*/ - -#ifndef EulerCoordinateRotation_H -#define EulerCoordinateRotation_H - -#include "coordinateRotation.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class EulerCoordinateRotation Declaration -\*---------------------------------------------------------------------------*/ - -class EulerCoordinateRotation -: - public coordinateRotation -{ - - // Private Member Data - - //- Local-to-global transformation tensor - tensor R_; - - //- Global-to-Local transformation tensor - tensor Rtr_; - - - // Private Member Functions - - //- Calculate transformation tensor - void calcTransform - ( - const scalar phiAngle, - const scalar thetaAngle, - const scalar psiAngle, - const bool inDegrees - ); - - -public: - - //- Runtime type information - TypeName("EulerRotation"); - - - // Constructors - - //- Construct null - EulerCoordinateRotation(); - - //- Construct as copy - EulerCoordinateRotation(const EulerCoordinateRotation& r); - - //- Construct from rotation vector - EulerCoordinateRotation - ( - const vector& phiThetaPsi, - const bool inDegrees - ); - - //- Construct from components of rotation vector - EulerCoordinateRotation - ( - const scalar phiAngle, - const scalar thetaAngle, - const scalar psiAngle, - const bool inDegrees - ); - - //- Construct from dictionary - explicit EulerCoordinateRotation(const dictionary& dict); - - //- Construct from dictionary and a registry (typically a mesh) - EulerCoordinateRotation - ( - const dictionary& dict, - const objectRegistry& unused - ); - - //- Return clone - autoPtr<coordinateRotation> clone() const - { - return - autoPtr<coordinateRotation>::NewFrom - <EulerCoordinateRotation>(*this); - } - - - // Member Functions - - //- Reset rotation to an identity rotation - virtual void clear() - { - R_ = sphericalTensor::I; - Rtr_ = sphericalTensor::I; - } - - //- Update the rotation for a list of cells - virtual void updateCells(const polyMesh&, const labelList&) - {} - - //- Return local-to-global transformation tensor - virtual const tensor& R() const - { - return R_; - } - - //- Return global-to-local transformation tensor - virtual const tensor& Rtr() const - { - return Rtr_; - }; - - //- Return local Cartesian x-axis in global coordinates - virtual const vector e1() const - { - return Rtr_.x(); - } - - //- Return local Cartesian y-axis in global coordinates - virtual const vector e2() const - { - return Rtr_.y(); - } - - //- Return local Cartesian z-axis in global coordinates - virtual const vector e3() const - { - return Rtr_.z(); - } - - //- Return transformation tensor field - virtual const tensorField& Tr() const; - - //- Transform vectorField using transformation tensor field - virtual tmp<vectorField> transform(const vectorField& st) const; - - //- Transform vector using transformation tensor - virtual vector transform(const vector& st) const; - - //- Inverse transform vectorField using transformation tensor field - virtual tmp<vectorField> invTransform(const vectorField& st) const; - - //- Inverse transform vector using transformation tensor - virtual vector invTransform(const vector& st) const; - - //- Transform tensor field using transformation tensorField - virtual tmp<tensorField> transformTensor(const tensorField& st) const; - - //- Transform tensor using transformation tensorField - virtual tensor transformTensor(const tensor& st) const; - - //- Transform tensor sub-field using transformation tensorField - virtual tmp<tensorField> transformTensor - ( - const tensorField& st, - const labelList& cellMap - ) const; - - //- Transform vectorField using transformation tensorField and return - // symmetrical tensorField - virtual tmp<symmTensorField> transformVector - ( - const vectorField& st - ) const; - - //- Transform vector using transformation tensor and return - // symmetrical tensor - virtual symmTensor transformVector(const vector& st) const; - -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C b/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C deleted file mode 100644 index 2cb61d9d1df474347cee17190eb0277e930ac4d6..0000000000000000000000000000000000000000 --- a/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C +++ /dev/null @@ -1,277 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2017 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 "STARCDCoordinateRotation.H" - -#include "mathematicalConstants.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(STARCDCoordinateRotation, 0); - addToRunTimeSelectionTable - ( - coordinateRotation, - STARCDCoordinateRotation, - dictionary - ); - addToRunTimeSelectionTable - ( - coordinateRotation, - STARCDCoordinateRotation, - objectRegistry - ); -} - - -// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // - -Foam::vector Foam::STARCDCoordinateRotation::transform(const vector& st) const -{ - return (R_ & st); -} - - -Foam::vector Foam::STARCDCoordinateRotation::invTransform -( - const vector& st -) const -{ - return (Rtr_ & st); -} - - -Foam::tmp<Foam::vectorField> Foam::STARCDCoordinateRotation::transform -( - const vectorField& st -) const -{ - NotImplemented; - return nullptr; -} - - -Foam::tmp<Foam::vectorField> Foam::STARCDCoordinateRotation::invTransform -( - const vectorField& st -) const -{ - NotImplemented; - return nullptr; -} - - -const Foam::tensorField& Foam::STARCDCoordinateRotation::Tr() const -{ - NotImplemented; - return NullObjectRef<tensorField>(); -} - - -Foam::tmp<Foam::tensorField> Foam::STARCDCoordinateRotation::transformTensor -( - const tensorField& st -) const -{ - NotImplemented; - return nullptr; -} - - -Foam::tensor Foam::STARCDCoordinateRotation::transformTensor -( - const tensor& st -) const -{ - return (R_ & st & Rtr_); -} - - -Foam::tmp<Foam::tensorField> Foam::STARCDCoordinateRotation::transformTensor -( - const tensorField& st, - const labelList& cellMap -) const -{ - NotImplemented; - return nullptr; -} - - -Foam::tmp<Foam::symmTensorField> Foam::STARCDCoordinateRotation:: -transformVector -( - const vectorField& st -) const -{ - tmp<symmTensorField> tfld(new symmTensorField(st.size())); - symmTensorField& fld = tfld.ref(); - - forAll(fld, i) - { - fld[i] = transformPrincipal(R_, st[i]); - } - return tfld; -} - - -Foam::symmTensor Foam::STARCDCoordinateRotation::transformVector -( - const vector& st -) const -{ - return transformPrincipal(R_, st); -} - - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -void Foam::STARCDCoordinateRotation::calcTransform -( - const scalar rotZ, - const scalar rotX, - const scalar rotY, - const bool inDegrees -) -{ - scalar x = rotX; - scalar y = rotY; - scalar z = rotZ; - - if (inDegrees) - { - x *= constant::mathematical::pi/180.0; - y *= constant::mathematical::pi/180.0; - z *= constant::mathematical::pi/180.0; - } - - R_ = - ( - tensor - ( - cos(y)*cos(z) - sin(x)*sin(y)*sin(z), - -cos(x)*sin(z), - sin(x)*cos(y)*sin(z) + sin(y)*cos(z), - - cos(y)*sin(z) + sin(x)*sin(y)*cos(z), - cos(x)*cos(z), - sin(y)*sin(z) - sin(x)*cos(y)*cos(z), - - -cos(x)*sin(y), - sin(x), - cos(x)*cos(y) - ) - ); - - Rtr_ = R_.T(); -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::STARCDCoordinateRotation::STARCDCoordinateRotation() -: - R_(sphericalTensor::I), - Rtr_(sphericalTensor::I) -{} - - -Foam::STARCDCoordinateRotation::STARCDCoordinateRotation -( - const STARCDCoordinateRotation& r -) -: - R_(r.R_), - Rtr_(r.Rtr_) -{} - - -Foam::STARCDCoordinateRotation::STARCDCoordinateRotation -( - const vector& rotZrotXrotY, - const bool inDegrees -) -: - R_(sphericalTensor::I), - Rtr_(sphericalTensor::I) -{ - calcTransform - ( - rotZrotXrotY.component(vector::X), - rotZrotXrotY.component(vector::Y), - rotZrotXrotY.component(vector::Z), - inDegrees - ); -} - - -Foam::STARCDCoordinateRotation::STARCDCoordinateRotation -( - const scalar rotZ, - const scalar rotX, - const scalar rotY, - const bool inDegrees -) -: - R_(sphericalTensor::I), - Rtr_(sphericalTensor::I) -{ - calcTransform(rotZ, rotX, rotY, inDegrees); -} - - -Foam::STARCDCoordinateRotation::STARCDCoordinateRotation -( - const dictionary& dict -) -: - R_(sphericalTensor::I), - Rtr_(sphericalTensor::I) -{ - const vector rotation(dict.lookup("rotation")); - - calcTransform - ( - rotation.component(vector::X), - rotation.component(vector::Y), - rotation.component(vector::Z), - dict.lookupOrDefault("degrees", true) - ); -} - - -Foam::STARCDCoordinateRotation::STARCDCoordinateRotation -( - const dictionary& dict, - const objectRegistry& -) -: - STARCDCoordinateRotation(dict) -{} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.C b/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.C deleted file mode 100644 index 95ec8f0e763ab90e9366b5f36545eed68a5daea5..0000000000000000000000000000000000000000 --- a/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.C +++ /dev/null @@ -1,334 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2017 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 "axesRotation.H" -#include "dictionary.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(axesRotation, 0); - addToRunTimeSelectionTable - ( - coordinateRotation, - axesRotation, - dictionary - ); - addToRunTimeSelectionTable - ( - coordinateRotation, - axesRotation, - objectRegistry - ); -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::axesRotation::axesRotation() -: - R_(sphericalTensor::I), - Rtr_(sphericalTensor::I) -{} - - -Foam::axesRotation::axesRotation(const axesRotation& r) -: - R_(r.R_), - Rtr_(r.Rtr_) -{} - - -Foam::axesRotation::axesRotation(const tensor& R) -: - R_(R), - Rtr_(R_.T()) -{} - - -Foam::axesRotation::axesRotation -( - const vector& axis, - const vector& dir, - const axisOrder& order -) -: - R_(sphericalTensor::I), - Rtr_(sphericalTensor::I) -{ - setTransform(axis, dir, order); -} - - -Foam::axesRotation::axesRotation -( - const vector& axis -) -: - R_(sphericalTensor::I), - Rtr_(sphericalTensor::I) -{ - direction maxCmpt = 0, dirCmpt = 1; - - scalar maxVal = mag(axis[maxCmpt]); - bool negative = (axis[maxCmpt] < 0); - - for (direction cmpt = 1; cmpt < vector::nComponents; ++cmpt) - { - const scalar val = mag(axis[cmpt]); - - if (maxVal < val) - { - maxVal = val; - maxCmpt = cmpt; - dirCmpt = maxCmpt+1; - negative = (axis[cmpt] < 0); - - if (dirCmpt >= vector::nComponents) - { - dirCmpt = 0; - } - } - } - - vector dir = Zero; - dir.component(dirCmpt) = (negative ? -1 : 1); - - setTransform(axis, dir, E3_E1); -} - - -Foam::axesRotation::axesRotation -( - const dictionary& dict -) -: - R_(sphericalTensor::I), - Rtr_(sphericalTensor::I) -{ - operator=(dict); -} - - -Foam::axesRotation::axesRotation -( - const dictionary& dict, - const objectRegistry& -) -: - axesRotation(dict) -{} - - -// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // - -void Foam::axesRotation::setTransform -( - const vector& axis1, - const vector& axis2, - const axisOrder& order -) -{ - const vector a = axis1/mag(axis1); - vector b = axis2; - - b = b - (b & a)*a; - - if (mag(b) < SMALL) - { - FatalErrorInFunction - << "axis1, axis2 appear to be co-linear: " - << axis1 << ", " << axis2 << endl - << abort(FatalError); - } - - b = b/mag(b); - const vector c = a^b; - - // Global->local transformation - switch (order) - { - case E1_E2: - { - Rtr_ = tensor(a, b, c); - break; - } - case E2_E3: - { - Rtr_ = tensor(c, a, b); - break; - } - case E3_E1: - { - Rtr_ = tensor(b, c, a); - break; - } - default: - { - FatalErrorInFunction - << "Unhandled axes specification" << endl - << abort(FatalError); - - break; - } - } - - // Local->global transformation - R_ = Rtr_.T(); -} - - -const Foam::tensorField& Foam::axesRotation::Tr() const -{ - NotImplemented; - return NullObjectRef<tensorField>(); -} - - -Foam::tmp<Foam::vectorField> Foam::axesRotation::transform -( - const vectorField& st -) const -{ - return (R_ & st); -} - - -Foam::vector Foam::axesRotation::transform(const vector& st) const -{ - return (R_ & st); -} - - -Foam::tmp<Foam::vectorField> Foam::axesRotation::invTransform -( - const vectorField& st -) const -{ - return (Rtr_ & st); -} - - -Foam::vector Foam::axesRotation::invTransform(const vector& st) const -{ - return (Rtr_ & st); -} - - -Foam::tmp<Foam::tensorField> Foam::axesRotation::transformTensor -( - const tensorField& st -) const -{ - NotImplemented; - return nullptr; -} - - -Foam::tensor Foam::axesRotation::transformTensor -( - const tensor& st -) const -{ - return (R_ & st & Rtr_); -} - - -Foam::tmp<Foam::tensorField> Foam::axesRotation::transformTensor -( - const tensorField& st, - const labelList& cellMap -) const -{ - NotImplemented; - return nullptr; -} - - -Foam::tmp<Foam::symmTensorField> Foam::axesRotation::transformVector -( - const vectorField& st -) const -{ - tmp<symmTensorField> tfld(new symmTensorField(st.size())); - symmTensorField& fld = tfld.ref(); - - forAll(fld, i) - { - fld[i] = transformPrincipal(R_, st[i]); - } - return tfld; -} - - -Foam::symmTensor Foam::axesRotation::transformVector -( - const vector& st -) const -{ - return transformPrincipal(R_, st); -} - - -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // - -void Foam::axesRotation::operator=(const dictionary& dict) -{ - vector axis1, axis2; - - if (dict.readIfPresent("e1", axis1) && dict.readIfPresent("e2", axis2)) - { - setTransform(axis1, axis2, E1_E2); - } - else if (dict.readIfPresent("e2", axis1) && dict.readIfPresent("e3", axis2)) - { - setTransform(axis1, axis2, E2_E3); - } - else if (dict.readIfPresent("e3", axis1) && dict.readIfPresent("e1", axis2)) - { - setTransform(axis1, axis2, E3_E1); - } - else if (dict.found("axis") || dict.found("direction")) - { - // Both "axis" and "direction" are required - // If one is missing the appropriate error message will be generated - dict.lookup("axis") >> axis1; - dict.lookup("direction") >> axis2; - - setTransform(axis1, axis2, E3_E1); - } - else - { - FatalErrorInFunction - << "not entry of the type (e1, e2) or (e2, e3) or (e3, e1) " - << "found " - << exit(FatalError); - } -} - - -// ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.H b/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.H deleted file mode 100644 index 4ac0a04928863905126f8d314277101a064c9760..0000000000000000000000000000000000000000 --- a/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.H +++ /dev/null @@ -1,250 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2017 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::axesRotation - -Description - A coordinate rotation specified using global axes - - The rotation is defined by a combination of vectors (e1/e2), (e2/e3) - or (e3/e1). Any nonorthogonality will be absorbed into the second - vector. In terms of cylindrical coordinates, the 'axis' would - correspond to the \a z-axis and the 'direction' to the \a r-axis. - - \verbatim - axesRotation - { - type axesRotation; - e1 (1 0 0); - e2 (0 1 0); - } - \endverbatim - -SourceFiles - axesRotation.C - -\*---------------------------------------------------------------------------*/ - -#ifndef axesRotation_H -#define axesRotation_H - -#include "vector.H" -#include "coordinateRotation.H" -#include "dictionary.H" -#include "runTimeSelectionTables.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class axesRotation Declaration -\*---------------------------------------------------------------------------*/ - -class axesRotation -: - public coordinateRotation -{ -public: - - //- The order/combination of local axes for the axes-rotation definition - // Note that these follow the right-hand rule. - enum axisOrder - { - E1_E2, //!< The axis is X-dominant, the direction is Y-dominant - E2_E3, //!< The axis is Y-dominant, the direction is Z-dominant - E3_E1 //!< The axis is Z-dominant, the direction is X-dominant - }; - - -private: - - // Private data - - //- Local-to-Global transformation tensor - tensor R_; - - //- Global-to-Local transformation tensor - tensor Rtr_; - - -public: - - //- Runtime type information - TypeName("axesRotation"); - - // Constructors - - //- Construct null - axesRotation(); - - //- Construct as copy - axesRotation(const axesRotation& r); - - //- Construct from local to global rotation matrix - explicit axesRotation(const tensor& R); - - //- Construct from two axes (axis and direction) - axesRotation - ( - const vector& axis, - const vector& dir, - const axisOrder& order = E3_E1 - ); - - //- Construct from a single axis using a best-guess for the second axis - // For the best-guess, the largest component value and sign of the - // axis determines the direction orientation. - explicit axesRotation(const vector& axis); - - //- Construct from dictionary - explicit axesRotation(const dictionary& dict); - - //- Construct from dictionary and a registry (typically a mesh) - axesRotation - ( - const dictionary& dict, - const objectRegistry& unused - ); - - //- Return clone - autoPtr<coordinateRotation> clone() const - { - return autoPtr<coordinateRotation>::NewFrom<axesRotation>(*this); - } - - - //- Destructor - virtual ~axesRotation() = default; - - - // Member Functions - - //- Reset rotation to an identity rotation - virtual void clear() - { - R_ = sphericalTensor::I; - Rtr_ = sphericalTensor::I; - } - - //- Set the transformation tensors from two axes (axis and direction) - void setTransform - ( - const vector& axis1, - const vector& axis2, - const axisOrder& order = E3_E1 - ); - - //- Update the rotation for a list of cells - virtual void updateCells(const polyMesh&, const labelList&) - {} - - //- Return local-to-global transformation tensor - virtual const tensor& R() const - { - return R_; - } - - //- Return global-to-local transformation tensor - virtual const tensor& Rtr() const - { - return Rtr_; - } - - //- Return local Cartesian x-axis in global coordinates - virtual const vector e1() const - { - return Rtr_.x(); - } - - //- Return local Cartesian y-axis in global coordinates - virtual const vector e2() const - { - return Rtr_.y(); - } - - //- Return local Cartesian z-axis in global coordinates - virtual const vector e3() const - { - return Rtr_.z(); - } - - //- Return transformation tensor field - virtual const tensorField& Tr() const; - - //- Transform vectorField using transformation tensor field - virtual tmp<vectorField> transform(const vectorField& st) const; - - //- Transform vector using transformation tensor - virtual vector transform(const vector& st) const; - - //- Inverse transform vectorField using transformation tensor field - virtual tmp<vectorField> invTransform(const vectorField& st) const; - - //- Inverse transform vector using transformation tensor - virtual vector invTransform(const vector& st) const; - - //- Transform tensor field using transformation tensorField - virtual tmp<tensorField> transformTensor(const tensorField& st) const; - - //- Transform tensor using transformation tensorField - virtual tensor transformTensor(const tensor& st) const; - - //- Transform tensor sub-field using transformation tensorField - virtual tmp<tensorField> transformTensor - ( - const tensorField& st, - const labelList& cellMap - ) const; - - //- Transform vectorField using transformation tensorField and return - // symmetric tensorField - virtual tmp<symmTensorField> transformVector - ( - const vectorField& st - ) const; - - //- Transform vector using transformation tensor and return - // symmetric tensor - virtual symmTensor transformVector(const vector& st) const; - - - // Member Operators - - //- Assign from dictionary - void operator=(const dictionary& dict); - -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.H b/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.H deleted file mode 100644 index 3a8396b5095d0d2be14e505b4e48ace1100e1671..0000000000000000000000000000000000000000 --- a/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.H +++ /dev/null @@ -1,234 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -Class - Foam::coordinateRotation - -Description - Abstract base class for coordinate rotation - - \verbatim - coordinateRotation - { - type axesRotation - e1 (1 0 0); - e2 (0 1 0); - } - \endverbatim - - Types of coordinateRotation: - -# axesRotation - -# STARCDRotation - -# cylindrical - -# EulerCoordinateRotation - -SourceFiles - coordinateRotation.C - coordinateRotationNew.C - -\*---------------------------------------------------------------------------*/ - -#ifndef coordinateRotation_H -#define coordinateRotation_H - -#include "vector.H" -#include "tensor.H" -#include "tensorField.H" -#include "dictionary.H" -#include "runTimeSelectionTables.H" -#include "objectRegistry.H" -#include "polyMesh.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class coordinateRotation Declaration -\*---------------------------------------------------------------------------*/ - -class coordinateRotation -{ -protected: - - // Protected member functions - - //- Transform principal - symmTensor transformPrincipal(const tensor&, const vector&) const; - - -public: - - - //- Runtime type information - TypeName("coordinateRotation"); - - - // Declare run-time constructor selection table - // for constructors with dictionary and objectRegistry - declareRunTimeSelectionTable - ( - autoPtr, - coordinateRotation, - objectRegistry, - ( - const dictionary& dict, const objectRegistry& obr - ), - (dict, obr) - ); - - - // Declare run-time constructor selection table - // for constructors with dictionary - declareRunTimeSelectionTable - ( - autoPtr, - coordinateRotation, - dictionary, - ( - const dictionary& dict - ), - (dict) - ); - - // Constructors - - //- Construct and return a clone - virtual autoPtr<coordinateRotation> clone() const = 0; - - - // Selectors - - //- Select constructed from dictionary and objectRegistry - static autoPtr<coordinateRotation> New - ( - const dictionary& dict, - const objectRegistry& obr - ); - - //- Select constructed from dictionary - static autoPtr<coordinateRotation> New - ( - const dictionary& dict - ); - - - //- Destructor - virtual ~coordinateRotation() - {} - - - // Member Functions - - //- Reset rotation to an identity rotation - virtual void clear() = 0; - - //- Update the rotation for a list of cells - virtual void updateCells - ( - const polyMesh& mesh, - const labelList& cells - ) = 0; - - //- Return local-to-global transformation tensor - virtual const tensor& R() const = 0; - - //- Return global-to-local transformation tensor - virtual const tensor& Rtr() const = 0; - - //- Return local Cartesian x-axis - virtual const vector e1() const = 0; - - //- Return local Cartesian y-axis - virtual const vector e2() const = 0; - - //- Return local Cartesian z-axis - virtual const vector e3() const = 0; - - //- Return local-to-global transformation tensor - virtual const tensorField& Tr() const = 0; - - //- Return true if the rotation tensor is uniform - virtual bool uniform() const - { - return true; - } - - //- Transform vectorField using transformation tensor field - virtual tmp<vectorField> transform(const vectorField& st) const = 0; - - //- Transform vector using transformation tensor - virtual vector transform(const vector& st) const = 0; - - //- Inverse transform vectorField using transformation tensor field - virtual tmp<vectorField> invTransform(const vectorField& st) const = 0; - - //- Inverse transform vector using transformation tensor - virtual vector invTransform(const vector& st) const = 0; - - //- Transform tensor field using transformation tensorField - virtual tmp<tensorField> transformTensor - ( - const tensorField& st - ) const = 0; - - //- Transform tensor sub-field using transformation tensorField - virtual tmp<tensorField> transformTensor - ( - const tensorField& st, - const labelList& cellMap - ) const = 0; - - //- Transform tensor using transformation tensorField - virtual tensor transformTensor(const tensor& st) const = 0; - - //- Transform vectorField using transformation tensorField and return - // symmetrical tensorField - virtual tmp<symmTensorField> transformVector - ( - const vectorField& st - ) const = 0; - - //- Transform vector using transformation tensor and return - // symmetrical tensor - virtual symmTensor transformVector(const vector& st) const = 0; - - - // Write - - //- Write coordinateRotation as e1,e2,e3 vectors - virtual void write(Ostream& os) const; - -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotationNew.C b/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotationNew.C deleted file mode 100644 index f9ed1f1e00f051de25cb8fcf38cc90a31931794b..0000000000000000000000000000000000000000 --- a/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotationNew.C +++ /dev/null @@ -1,76 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2017-2018 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 "coordinateRotation.H" -#include "objectRegistry.H" - -// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // - -Foam::autoPtr<Foam::coordinateRotation> Foam::coordinateRotation::New -( - const dictionary& dict, - const objectRegistry& obr -) -{ - const word modelType(dict.get<word>("type")); - - auto cstrIter = objectRegistryConstructorTablePtr_->cfind(modelType); - - if (!cstrIter.found()) - { - FatalIOErrorInFunction(dict) - << "Unknown coordinateRotation type " << modelType << nl << nl - << "Valid types: " - << flatOutput(objectRegistryConstructorTablePtr_->sortedToc()) - << exit(FatalIOError); - } - - return autoPtr<coordinateRotation>(cstrIter()(dict, obr)); -} - - -Foam::autoPtr<Foam::coordinateRotation> Foam::coordinateRotation::New -( - const dictionary& dict -) -{ - const word modelType(dict.get<word>("type")); - - auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); - - if (!cstrIter.found()) - { - FatalIOErrorInFunction(dict) - << "Unknown coordinateRotation type " << modelType << nl << nl - << "Valid types: " - << flatOutput(dictionaryConstructorTablePtr_->sortedToc()) - << exit(FatalIOError); - } - - return autoPtr<coordinateRotation>(cstrIter()(dict)); -} - - -// ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/coordinateRotation/cylindrical.C b/src/meshTools/coordinateSystems/coordinateRotation/cylindrical.C deleted file mode 100644 index 17303cf7a50cd7dae89d7b03e39eaeba46309178..0000000000000000000000000000000000000000 --- a/src/meshTools/coordinateSystems/coordinateRotation/cylindrical.C +++ /dev/null @@ -1,360 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "cylindrical.H" -#include "axesRotation.H" -#include "addToRunTimeSelectionTable.H" -#include "polyMesh.H" -#include "tensorIOField.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(cylindrical, 0); - addToRunTimeSelectionTable - ( - coordinateRotation, - cylindrical, - dictionary - ); - addToRunTimeSelectionTable - ( - coordinateRotation, - cylindrical, - objectRegistry - ); -} - - -// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // - -void Foam::cylindrical::init -( - const objectRegistry& obr, - const labelUList& cells -) -{ - const polyMesh& mesh = refCast<const polyMesh>(obr); - const vectorField& cc = mesh.cellCentres(); - - if (cells.size()) - { - Rptr_.reset(new tensorField(cells.size())); - - tensorField& R = Rptr_(); - forAll(cells, i) - { - const label celli = cells[i]; - vector dir = cc[celli] - origin_; - dir /= mag(dir) + VSMALL; - - R[i] = axesRotation(e3_, dir).R(); - } - } - else - { - Rptr_.reset(new tensorField(mesh.nCells())); - - tensorField& R = Rptr_(); - forAll(cc, celli) - { - vector dir = cc[celli] - origin_; - dir /= mag(dir) + VSMALL; - - R[celli] = axesRotation(e3_, dir).R(); - } - } -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::cylindrical::cylindrical(const cylindrical& r) -: - Rptr_(r.Rptr_.clone()), - origin_(r.origin_), - e3_(r.e3_) -{} - - -Foam::cylindrical::cylindrical(const tensorField& R) -: - Rptr_(), - origin_(Zero), - e3_(Zero) -{ - Rptr_() = R; -} - - -Foam::cylindrical::cylindrical(const dictionary& dict) -: - Rptr_(), - origin_(Zero), - e3_(Zero) -{ - FatalErrorInFunction - << " cylindrical can not be constructed from dictionary " - << " use the constructor : " - "(" - " const dictionary&, const objectRegistry&" - ")" - << exit(FatalIOError); -} - - -Foam::cylindrical::cylindrical -( - const dictionary& dict, - const objectRegistry& obr -) -: - Rptr_(), - origin_(Zero), - e3_(Zero) -{ - // If origin is specified in the coordinateSystem - dict.parent().readIfPresent("origin", origin_); - - // Rotation axis - dict.lookup("e3") >> e3_; - - init(obr); -} - - -Foam::cylindrical::cylindrical -( - const objectRegistry& obr, - const vector& axis, - const point& origin -) -: - Rptr_(), - origin_(origin), - e3_(axis) -{ - init(obr); -} - - -Foam::cylindrical::cylindrical -( - const objectRegistry& obr, - const vector& axis, - const point& origin, - const List<label>& cells -) -: - Rptr_(), - origin_(origin), - e3_(axis) -{ - init(obr, cells); -} - - -// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // - -void Foam::cylindrical::clear() -{ - Rptr_.clear(); -} - - -void Foam::cylindrical::updateCells -( - const polyMesh& mesh, - const labelList& cells -) -{ - const vectorField& cc = mesh.cellCentres(); - tensorField& R = Rptr_(); - - forAll(cells, i) - { - const label celli = cells[i]; - vector dir = cc[celli] - origin_; - dir /= mag(dir) + VSMALL; - - R[celli] = axesRotation(e3_, dir).R(); - } -} - - -Foam::tmp<Foam::vectorField> Foam::cylindrical::transform -( - const vectorField& vf -) const -{ - if (Rptr_->size() != vf.size()) - { - FatalErrorInFunction - << "vectorField st has different size to tensorField " - << abort(FatalError); - } - - return (Rptr_() & vf); -} - - -Foam::vector Foam::cylindrical::transform(const vector& v) const -{ - NotImplemented; - return Zero; -} - - -Foam::vector Foam::cylindrical::transform -( - const vector& v, - const label cmptI -) const -{ - return (Rptr_()[cmptI] & v); -} - - -Foam::tmp<Foam::vectorField> Foam::cylindrical::invTransform -( - const vectorField& vf -) const -{ - return (Rptr_().T() & vf); -} - - -Foam::vector Foam::cylindrical::invTransform(const vector& v) const -{ - NotImplemented; - return Zero; -} - - -Foam::vector Foam::cylindrical::invTransform -( - const vector& v, - const label cmptI -) const -{ - return (Rptr_()[cmptI].T() & v); -} - - -Foam::tmp<Foam::tensorField> Foam::cylindrical::transformTensor -( - const tensorField& tf -) const -{ - if (Rptr_->size() != tf.size()) - { - FatalErrorInFunction - << "tensorField st has different size to tensorField Tr" - << abort(FatalError); - } - return (Rptr_() & tf & Rptr_().T()); -} - - -Foam::tensor Foam::cylindrical::transformTensor -( - const tensor& t -) const -{ - NotImplemented; - - return Zero; -} - - -Foam::tmp<Foam::tensorField> Foam::cylindrical::transformTensor -( - const tensorField& tf, - const labelList& cellMap -) const -{ - if (cellMap.size() != tf.size()) - { - FatalErrorInFunction - << "tensorField tf has different size to tensorField Tr" - << abort(FatalError); - } - - const tensorField& R = Rptr_(); - const tensorField Rtr(R.T()); - tmp<tensorField> tt(new tensorField(cellMap.size())); - tensorField& t = tt.ref(); - forAll(cellMap, i) - { - const label celli = cellMap[i]; - t[i] = R[celli] & tf[i] & Rtr[celli]; - } - - return tt; -} - - -Foam::tmp<Foam::symmTensorField> Foam::cylindrical::transformVector -( - const vectorField& vf -) const -{ - if (Rptr_->size() != vf.size()) - { - FatalErrorInFunction - << "tensorField vf has different size to tensorField Tr" - << abort(FatalError); - } - - tmp<symmTensorField> tfld(new symmTensorField(Rptr_->size())); - symmTensorField& fld = tfld.ref(); - - const tensorField& R = Rptr_(); - forAll(fld, i) - { - fld[i] = transformPrincipal(R[i], vf[i]); - } - return tfld; -} - - -Foam::symmTensor Foam::cylindrical::transformVector -( - const vector& v -) const -{ - NotImplemented; - return Zero; -} - - -void Foam::cylindrical::write(Ostream& os) const -{ - os.writeEntry("e3", e3()); -} - - -// ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/coordinateRotation/cylindrical.H b/src/meshTools/coordinateSystems/coordinateRotation/cylindrical.H deleted file mode 100644 index 9f7a2463e724211c93abee9e82a45c0c512f8825..0000000000000000000000000000000000000000 --- a/src/meshTools/coordinateSystems/coordinateRotation/cylindrical.H +++ /dev/null @@ -1,251 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -Class - Foam::cylindrical - -Description - A local coordinate rotation. - - The cell based rotational field can be created in two ways: - -# Each rotational tensor is defined with two vectors (\c dir and \c e3) - where <tt>dir = cellC - origin</tt> and \c e3 is the rotation axis. - Per each cell an axesRotation type of rotation is created - (cylindrical coordinates). For example: - \verbatim - cylindrical - { - type localAxes; - e3 (0 0 1); - } - \endverbatim - - -# The rotational tensor field is provided at construction. - -SourceFiles - cylindrical.C - -\*---------------------------------------------------------------------------*/ - -#ifndef cylindrical_H -#define cylindrical_H - -#include "point.H" -#include "vector.H" -#include "ListOps.H" -#include "coordinateRotation.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class cylindrical Declaration -\*---------------------------------------------------------------------------*/ - -class cylindrical -: - public coordinateRotation -{ - // Private data - - //- An autoPtr to the transformation tensor - autoPtr<tensorField> Rptr_; - - //- Origin of the coordinate system - point origin_; - - //- Rotation axis - vector e3_; - - - // Private members - - //- Init transformation tensor field - void init - ( - const objectRegistry& obr, - const labelUList& cells = Foam::emptyLabelList - ); - - -public: - - //- Runtime type information - TypeName("cylindrical"); - - // Constructors - - //- Construct as copy - cylindrical(const cylindrical& r); - - //- Construct from tensor Field - explicit cylindrical(const tensorField& R); - - //- Construct from dictionary - for API compatibility only - explicit cylindrical(const dictionary& dict); - - //- Construct from dictionary and objectRegistry - cylindrical(const dictionary& dict, const objectRegistry& obr); - - //- Construct from components for all cells - cylindrical - ( - const objectRegistry& obr, - const vector& axis, - const point& origin - ); - - //- Construct from components for list of cells - cylindrical - ( - const objectRegistry& obr, - const vector& axis, - const point& origin, - const List<label>& cells - ); - - //- Return clone - autoPtr<coordinateRotation> clone() const - { - return autoPtr<coordinateRotation>::NewFrom<cylindrical>(*this); - } - - - //- Destructor - virtual ~cylindrical() = default; - - - // Member Functions - - //- Reset rotation to an identity rotation - virtual void clear(); - - //- Update the rotation for a list of cells - virtual void updateCells(const polyMesh& mesh, const labelList& cells); - - //- Return local-to-global transformation tensor - virtual const tensor& R() const - { - NotImplemented; - return tensor::zero; - } - - //- Return global-to-local transformation tensor - virtual const tensor& Rtr() const - { - NotImplemented; - return tensor::zero; - } - - //- Return local Cartesian x-axis in global coordinates - virtual const vector e1() const - { - NotImplemented; - return vector::zero; - } - - //- Return local Cartesian y-axis in global coordinates - virtual const vector e2() const - { - NotImplemented; - return vector::zero; - } - - //- Return local Cartesian z-axis in global coordinates - virtual const vector e3() const - { - return e3_; - } - - virtual const tensorField& Tr() const - { - return *Rptr_; - } - - //- Transform vectorField using transformation tensor field - virtual tmp<vectorField> transform(const vectorField& tf) const; - - //- Transform vector using transformation tensor - virtual vector transform(const vector& v) const; - - //- Transform vector using transformation tensor for component - virtual vector transform(const vector& v, const label cmptI) const; - - //- Inverse transform vectorField using transformation tensor field - virtual tmp<vectorField> invTransform(const vectorField& vf) const; - - //- Inverse transform vector using transformation tensor - virtual vector invTransform(const vector& v) const; - - //- Inverse transform vector using transformation tensor for component - virtual vector invTransform(const vector& v, const label cmptI) const; - - //- Return if the rotation is uniform - virtual bool uniform() const - { - return false; - } - - //- Transform tensor field using transformation tensorField - virtual tmp<tensorField> transformTensor(const tensorField& tf) const; - - //- Transform tensor using transformation tensorField - virtual tensor transformTensor(const tensor& t) const; - - //- Transform tensor sub-field using transformation tensorField - virtual tmp<tensorField> transformTensor - ( - const tensorField& tf, - const labelList& cellMap - ) const; - - //- Transform vectorField using transformation tensorField and return - // symmetrical tensorField - virtual tmp<symmTensorField> transformVector - ( - const vectorField& vf - ) const; - - //- Transform vector using transformation tensor and return - // symmetrical tensor (R & st & R.T()) - virtual symmTensor transformVector(const vector& v) const; - - - // Write - - //- Write - virtual void write(Ostream&) const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/coordinateSystem.C b/src/meshTools/coordinateSystems/coordinateSystem.C deleted file mode 100644 index 5ec436197423e97c00e4eb3f764c12e635c59cb7..0000000000000000000000000000000000000000 --- a/src/meshTools/coordinateSystems/coordinateSystem.C +++ /dev/null @@ -1,414 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2018 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 "IOstream.H" -#include "axesRotation.H" -#include "coordinateSystem.H" -#include "coordinateSystems.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(coordinateSystem, 0); - defineRunTimeSelectionTable(coordinateSystem, dictionary); -} - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::coordinateSystem::coordinateSystem() -: - name_(), - note_(), - origin_(Zero), - R_(new axesRotation(sphericalTensor::I)) -{} - - -Foam::coordinateSystem::coordinateSystem(const coordinateSystem& cs) -: - name_(cs.name_), - note_(cs.note_), - origin_(cs.origin_), - R_(cs.R_.clone()) -{} - - -Foam::coordinateSystem::coordinateSystem(coordinateSystem&& cs) -: - name_(std::move(cs.name_)), - note_(std::move(cs.note_)), - origin_(std::move(cs.origin_)), - R_(std::move(cs.R_)) -{} - - -Foam::coordinateSystem::coordinateSystem -( - const word& name, - const coordinateSystem& cs -) -: - name_(name), - note_(cs.note_), - origin_(cs.origin_), - R_(cs.R_.clone()) -{} - - -Foam::coordinateSystem::coordinateSystem -( - const word& name, - const point& origin, - const coordinateRotation& cr -) -: - name_(name), - note_(), - origin_(origin), - R_(cr.clone()) -{} - - -Foam::coordinateSystem::coordinateSystem -( - const word& name, - const point& origin, - const vector& axis, - const vector& dirn -) -: - name_(name), - note_(), - origin_(origin), - R_(new axesRotation(axis, dirn)) -{} - - -Foam::coordinateSystem::coordinateSystem -( - const word& name, - const dictionary& dict -) -: - name_(name), - note_(), - origin_(Zero), - R_() -{ - init(dict); -} - - -Foam::coordinateSystem::coordinateSystem(const dictionary& dict) -: - name_(), - note_(), - origin_(Zero), - R_() -{ - init(dict); -} - - -Foam::coordinateSystem::coordinateSystem -( - const objectRegistry& obr, - const dictionary& dict -) -: - name_(), - note_(), - origin_(Zero), - R_() -{ - const entry* entryPtr = dict.lookupEntryPtr(typeName_(), false, false); - - if (!entryPtr) - { - // No 'coordinateSystem' entry - init(dict, obr); - } - else if (entryPtr->isDict()) - { - // 'coordinateSystem' as dictionary entry - use it - init(entryPtr->dict(), obr); - } - else - { - // 'coordinateSystem' as non-dictionary entry - // - this is a lookup into global coordinateSystems - - keyType key(entryPtr->stream()); - - const coordinateSystems& lst = coordinateSystems::New(obr); - const label index = lst.findIndex(key); - - if (debug) - { - InfoInFunction - << "Using global coordinate system: " - << key << "=" << index << endl; - } - - if (index < 0) - { - FatalErrorInFunction - << "could not find coordinate system: " << key << nl - << "available coordinate systems: " << lst.toc() << nl << nl - << exit(FatalError); - } - - // Copy from coordinateSystem, but assign the name as the typeName - // to avoid strange things in writeDict() - operator=(lst[index]); - name_ = typeName_(); - } -} - - -Foam::coordinateSystem::coordinateSystem(Istream& is) -: - name_(is), - note_(), - origin_(Zero), - R_() -{ - dictionary dict(is); - init(dict); -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -Foam::dictionary Foam::coordinateSystem::dict(bool ignoreType) const -{ - dictionary dict; - - dict.add("name", name_); - - // Only write type for derived types - if (!ignoreType && type() != typeName_()) - { - dict.add("type", type()); - } - - // The note entry is optional - if (note_.size()) - { - dict.add("note", note_); - } - - dict.add("origin", origin_); - dict.add("e1", R_->e1()); - dict.add("e3", R_->e3()); - - return dict; -} - - -Foam::vector Foam::coordinateSystem::localToGlobal -( - const vector& local, - bool translate -) const -{ - if (translate) - { - return (R_->transform(local)) + origin_; - } - - return R_->transform(local); -} - - -Foam::tmp<Foam::vectorField> Foam::coordinateSystem::localToGlobal -( - const vectorField& local, - bool translate -) const -{ - if (translate) - { - return (R_->transform(local)) + origin_; - } - - return R_->transform(local); -} - - -Foam::vector Foam::coordinateSystem::globalToLocal -( - const vector& global, - bool translate -) const -{ - if (translate) - { - return R_->invTransform(global - origin_); - } - - return R_->invTransform(global); -} - - -Foam::tmp<Foam::vectorField> Foam::coordinateSystem::globalToLocal -( - const vectorField& global, - bool translate -) const -{ - if (translate) - { - return R_->invTransform(global - origin_); - } - - return R_->invTransform(global); -} - - -void Foam::coordinateSystem::clear() -{ - note_.clear(); - origin_ = Zero; - R_->clear(); -} - - -void Foam::coordinateSystem::transfer(coordinateSystem& cs) -{ - name_ = std::move(cs.name_); - note_ = std::move(cs.note_); - origin_ = std::move(cs.origin_); - R_ = std::move(cs.R_); -} - - -void Foam::coordinateSystem::write(Ostream& os) const -{ - os << type() << " origin: " << origin() << nl; - R_->write(os); -} - - -void Foam::coordinateSystem::writeDict(Ostream& os, bool subDict) const -{ - if (subDict) - { - os.beginBlock(name_); - } - - os.writeEntry("type", type()); - - if (note_.size()) - { - // The 'note' is optional - os.writeEntry("note", note_); - } - - os.writeEntry("origin", origin_); - R_->write(os); - - if (subDict) - { - os.endBlock(); - } -} - - -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // - -void Foam::coordinateSystem::operator=(const coordinateSystem& cs) -{ - name_ = cs.name_; - note_ = cs.note_; - origin_ = cs.origin_; - - // Some extra safety - if (cs.R_.valid()) - { - R_ = cs.R_.clone(); - } - else - { - R_.reset(new axesRotation(sphericalTensor::I)); - } -} - -void Foam::coordinateSystem::operator=(coordinateSystem&& cs) -{ - transfer(cs); -} - - -void Foam::coordinateSystem::init(const dictionary& dict) -{ - dict.lookup("origin") >> origin_; - note_.clear(); - dict.readIfPresent("note", note_); - R_ = coordinateRotation::New(dict.subDict("coordinateRotation")); -} - - -void Foam::coordinateSystem::init -( - const dictionary& dict, - const objectRegistry& obr -) -{ - dict.lookup("origin") >> origin_; - - // The 'note' entry is optional - note_.clear(); - dict.readIfPresent("note", note_); - R_ = coordinateRotation::New(dict.subDict("coordinateRotation"), obr); -} - - -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // - -bool Foam::operator!=(const coordinateSystem& a, const coordinateSystem& b) -{ - return - ( - a.origin() != b.origin() - || a.type() != b.type() - || a.R().R() != b.R().R() - ); -} - - -// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // - -Foam::Ostream& Foam::operator<<(Ostream& os, const coordinateSystem& cs) -{ - cs.write(os); - os.check(FUNCTION_NAME); - return os; -} - - -// ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/coordinateSystem.H b/src/meshTools/coordinateSystems/coordinateSystem.H deleted file mode 100644 index d47608b392e3d79eb5162a34e0252e3ce9f25029..0000000000000000000000000000000000000000 --- a/src/meshTools/coordinateSystems/coordinateSystem.H +++ /dev/null @@ -1,427 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2018 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::coordinateSystem - -Description - Base class for other coordinate system specifications. - - All systems are defined by an origin point and a co-ordinate rotation. - - \verbatim - coordinateSystem - { - type cartesian; - origin (0 0 0); - coordinateRotation - { - type cylindrical; - e3 (0 0 1); - } - } - \endverbatim - - Types of coordinateRotation: - -# axesRotation - -# \link STARCDCoordinateRotation STARCDRotation \endlink - -# cylindricalCS cylindrical - -# EulerCoordinateRotation - - Type of co-ordinates: - -# \link cartesianCS cartesian \endlink - - -SourceFiles - coordinateSystem.C - coordinateSystemNew.C - -\*---------------------------------------------------------------------------*/ - -#ifndef coordinateSystem_H -#define coordinateSystem_H - -#include "vector.H" -#include "point.H" -#include "tensor.H" -#include "vectorField.H" -#include "pointField.H" -#include "tmp.H" -#include "coordinateRotation.H" -#include "objectRegistry.H" -#include "autoPtr.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// Forward declarations - -class coordinateSystem; - -bool operator!=(const coordinateSystem&, const coordinateSystem&); -Ostream& operator<<(Ostream&, const coordinateSystem&); - - -/*---------------------------------------------------------------------------*\ - Class coordinateSystem Declaration -\*---------------------------------------------------------------------------*/ - -class coordinateSystem -{ - // Private data - - //- Name of coordinate system - word name_; - - //- Optional note - string note_; - - //- Origin - point origin_; - - //- Local-to-Global transformation tensor. - // May be invalid after a move assignment or transfer - autoPtr<coordinateRotation> R_; - - -protected: - - // Protected Member Functions - - //- Convert from local coordinate system to the global Cartesian system - //- with optional translation for the origin - virtual vector localToGlobal(const vector&, bool translate) const; - - //- Convert from local coordinate system to the global Cartesian system - //- with optional translation for the origin - virtual tmp<vectorField> localToGlobal - ( - const vectorField&, - bool translate - ) const; - - //- Convert from global Cartesian system to the local coordinate system - //- with optional translation for the origin - virtual vector globalToLocal(const vector&, bool translate) const; - - //- Convert from global Cartesian system to the local coordinate system - //- with optional translation for the origin - virtual tmp<vectorField> globalToLocal - ( - const vectorField&, - bool translate - ) const; - - //- Init from dict and obr - void init(const dictionary& dict); - - //- Init from dictionary - void init(const dictionary& dict, const objectRegistry& obr); - - -public: - - //- Runtime type information - TypeName("coordinateSystem"); - - - // Constructors - - //- Construct null. This is equivalent to an identity coordinateSystem - coordinateSystem(); - - //- Copy construct - coordinateSystem(const coordinateSystem& cs); - - //- Move construct - coordinateSystem(coordinateSystem&& cs); - - //- Copy construct with a different name - coordinateSystem - ( - const word& name, - const coordinateSystem& cs - ); - - //- Construct from origin and rotation - coordinateSystem - ( - const word& name, - const point& origin, - const coordinateRotation& - ); - - //- Construct from origin and 2 axes - coordinateSystem - ( - const word& name, - const point& origin, - const vector& axis, - const vector& dirn - ); - - //- Construct from dictionary with a given name - coordinateSystem(const word& name, const dictionary& dict); - - //- Construct from dictionary with default name - explicit coordinateSystem(const dictionary& dict); - - //- Construct from dictionary (default name) - // With the ability to reference global coordinateSystems - coordinateSystem(const objectRegistry& obr, const dictionary& dict); - - //- Construct from Istream - // The Istream contains a word followed by a dictionary - coordinateSystem(Istream& is); - - - //- Return clone - autoPtr<coordinateSystem> clone() const - { - return autoPtr<coordinateSystem>::New(*this); - } - - - // Declare run-time constructor selection table - declareRunTimeSelectionTable - ( - autoPtr, - coordinateSystem, - dictionary, - ( - const objectRegistry& obr, - const dictionary& dict - ), - (obr, dict) - ); - - - // Selectors - - //- Select constructed from dictionary and objectRegistry - static autoPtr<coordinateSystem> New - ( - const objectRegistry& obr, - const dictionary& dict - ); - - //- Select constructed from dictionary - static autoPtr<coordinateSystem> New - ( - const dictionary& dict - ); - - //- Select constructed from Istream - static autoPtr<coordinateSystem> New(Istream& is); - - - //- Destructor - virtual ~coordinateSystem() = default; - - - // Member Functions - - // Access - - //- Return name - const word& name() const - { - return name_; - } - - //- Return non-constant access to the optional note - string& note() - { - return note_; - } - - //- Return the optional note - const string& note() const - { - return note_; - } - - //- Return origin - const point& origin() const - { - return origin_; - } - - //- Return const reference to co-ordinate rotation - const coordinateRotation& R() const - { - return *R_; - } - - //- Return non const reference to co-ordinate rotation - coordinateRotation& R() - { - return *R_; - } - - //- Update and return the co-ordinate rotation for a list of cells - const coordinateRotation& R - ( - const polyMesh& mesh, - const labelList& cells - ) - { - R_->updateCells(mesh, cells); - return *R_; - } - - //- Return as dictionary of entries - // \param[in] ignoreType drop type (cartesian, cylindrical, etc) - // when generating the dictionary - virtual dictionary dict(bool ignoreType=false) const; - - - // Edit - - //- Rename - void rename(const word& newName) - { - name_ = newName; - } - - //- Edit access to origin - point& origin() - { - return origin_; - } - - //- Reset origin and rotation to an identity coordinateSystem - // Also resets the note - virtual void clear(); - - //- Transfer contents from parameter - void transfer(coordinateSystem& cs); - - - // Write - - //- Write - virtual void write(Ostream& os) const; - - //- Write dictionary - void writeDict(Ostream& os, bool subDict=true) const; - - - // Transformations - - //- Convert from position in local coordinate system to global - // Cartesian position - point globalPosition(const point& local) const - { - return localToGlobal(local, true); - } - - //- Convert from position in local coordinate system to global - // Cartesian position - tmp<pointField> globalPosition(const pointField& local) const - { - return localToGlobal(local, true); - } - - //- Convert from vector components in local coordinate system to - // global Cartesian vector - vector globalVector(const vector& local) const - { - return localToGlobal(local, false); - } - - //- Convert from vector components in local coordinate system to - // global Cartesian vector - tmp<vectorField> globalVector(const vectorField& local) const - { - return localToGlobal(local, false); - } - - //- Convert from global Cartesian position to position in local - // coordinate system - point localPosition(const point& global) const - { - return globalToLocal(global, true); - } - - //- Convert from global Cartesian position to position in local - // coordinate system - tmp<pointField> localPosition(const pointField& global) const - { - return globalToLocal(global, true); - } - - //- Convert from global Cartesian vector to components in local - // coordinate system - vector localVector(const vector& global) const - { - return globalToLocal(global, false); - } - - //- Convert from global Cartesian vector to components in local - // coordinate system - tmp<vectorField> localVector(const vectorField& global) const - { - return globalToLocal(global, false); - } - - - // Member Operators - - //- Copy assignment - void operator=(const coordinateSystem& cs); - - //- Move assignment - void operator=(coordinateSystem&& cs); - - - // Friend Operators - - friend bool operator!= - ( - const coordinateSystem& a, - const coordinateSystem& b - ); - - - // IOstream Operators - - friend Ostream& operator<< - ( - Ostream& os, - const coordinateSystem& cs - ); -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/coordinateSystemNew.C b/src/meshTools/coordinateSystems/coordinateSystemNew.C deleted file mode 100644 index 9f0fd188663fdb6df7e38ec8125032c95cbaf24f..0000000000000000000000000000000000000000 --- a/src/meshTools/coordinateSystems/coordinateSystemNew.C +++ /dev/null @@ -1,81 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "coordinateSystem.H" -#include "dictionary.H" - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New -( - const objectRegistry& obr, - const dictionary& dict -) -{ - const dictionary& coordDict = dict.subDict(typeName_()); - const word modelType(coordDict.get<word>("type")); - - auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); - - if (!cstrIter.found()) - { - FatalIOErrorInFunction - ( - dict - ) << "Unknown coordinateSystem type " - << modelType << nl << nl - << "Valid types: " - << flatOutput(dictionaryConstructorTablePtr_->sortedToc()) - << exit(FatalIOError); - } - - return autoPtr<coordinateSystem>(cstrIter()(obr, coordDict)); -} - - -Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New -( - const dictionary& dict -) -{ - const dictionary& coordDict = dict.subDict(typeName_()); - - return autoPtr<coordinateSystem>::New(coordDict); -} - - -Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New -( - Istream& is -) -{ - const word name(is); - const dictionary dict(is); - - return autoPtr<coordinateSystem>::New(name, dict); -} - - -// ************************************************************************* // diff --git a/src/meshTools/searchableSurfaces/searchableRotatedBox/searchableRotatedBox.C b/src/meshTools/searchableSurfaces/searchableRotatedBox/searchableRotatedBox.C index 13e85223e34d30a0b52e60f40fb937bf36e3889b..bf66177ced96649a4e45eabda79683440be8c4b6 100644 --- a/src/meshTools/searchableSurfaces/searchableRotatedBox/searchableRotatedBox.C +++ b/src/meshTools/searchableSurfaces/searchableRotatedBox/searchableRotatedBox.C @@ -25,7 +25,6 @@ License #include "searchableRotatedBox.H" #include "addToRunTimeSelectionTable.H" -#include "axesRotation.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // diff --git a/src/meshTools/searchableSurfaces/searchableSurfaceCollection/searchableSurfaceCollection.C b/src/meshTools/searchableSurfaces/searchableSurfaceCollection/searchableSurfaceCollection.C index 79603ea10b71388714b7205012084b54b5193b70..2e6a2b0df0dc22ade436bd7327a8b56fe9605bce 100644 --- a/src/meshTools/searchableSurfaces/searchableSurfaceCollection/searchableSurfaceCollection.C +++ b/src/meshTools/searchableSurfaces/searchableSurfaceCollection/searchableSurfaceCollection.C @@ -201,7 +201,8 @@ Foam::searchableSurfaceCollection::searchableSurfaceCollection surfI, coordinateSystem::New ( - subDict.subDict("transform") + subDict, + "transform" ) ); @@ -229,7 +230,7 @@ Foam::searchableSurfaceCollection::searchableSurfaceCollection Info<< " instance : " << instance_[surfI] << endl; Info<< " surface : " << s.name() << endl; Info<< " scale : " << scale_[surfI] << endl; - Info<< " coordsys : " << transform_[surfI] << endl; + Info<< " transform: " << transform_[surfI] << endl; surfI++; } diff --git a/src/sampling/sampledSet/circle/circleSet.H b/src/sampling/sampledSet/circle/circleSet.H index 5d4cb5973497e7bbeba5836db4138e39ce1cc401..ab122f8795490c70ae6dac384c792052b0dd8f20 100644 --- a/src/sampling/sampledSet/circle/circleSet.H +++ b/src/sampling/sampledSet/circle/circleSet.H @@ -69,13 +69,13 @@ class circleSet // Circle definition - //- Origin (x, y, z) in global cartesian co-ordinates + //- Origin (x, y, z) in global cartesian coordinates point origin_; //- Axis of the circle vector circleAxis_; - //- Point on circle (x, y, z) in global cartesian co-ordinates + //- Point on circle (x, y, z) in global cartesian coordinates // Defines start point point startPoint_; diff --git a/src/sampling/sampledSurface/readers/ensight/ensightSurfaceReader.C b/src/sampling/sampledSurface/readers/ensight/ensightSurfaceReader.C index 11701aa55a7ba3e222163d5c923b49db99f55bcd..3c1759e3cf873b96d86d6acca299310c6869fac7 100644 --- a/src/sampling/sampledSurface/readers/ensight/ensightSurfaceReader.C +++ b/src/sampling/sampledSurface/readers/ensight/ensightSurfaceReader.C @@ -130,7 +130,7 @@ void Foam::ensightSurfaceReader::readGeometryHeader(ensightReadFile& is) const is.read(buffer); if (debug) Info<< "buffer: " << buffer << endl; - // Co-ordinates + // Coordinates is.read(buffer); if (debug) Info<< "buffer: " << buffer << endl; } diff --git a/src/sampling/sampledSurface/sampledPlane/sampledPlane.C b/src/sampling/sampledSurface/sampledPlane/sampledPlane.C index 1e7799d7a8cc8ecc8f426913d97e8c71fbc12d91..f4a20474e211588ff633f70ebd3e3c22dbc7c0c7 100644 --- a/src/sampling/sampledSurface/sampledPlane/sampledPlane.C +++ b/src/sampling/sampledSurface/sampledPlane/sampledPlane.C @@ -88,10 +88,11 @@ Foam::sampledPlane::sampledPlane // allow lookup from global coordinate systems if (dict.found("coordinateSystem")) { - coordinateSystem cs(mesh, dict.subDict("coordinateSystem")); + auto csysPtr = coordinateSystem::New(mesh, dict, "coordinateSystem"); + const auto& csys = *csysPtr; - const point base = cs.globalPosition(planeDesc().refPoint()); - const vector norm = cs.globalVector(planeDesc().normal()); + const point base = csys.globalPosition(planeDesc().refPoint()); + const vector norm = csys.globalVector(planeDesc().normal()); // Assign the plane description static_cast<plane&>(*this) = plane(base, norm); diff --git a/src/sampling/surfMeshSample/plane/surfMeshSamplePlane.C b/src/sampling/surfMeshSample/plane/surfMeshSamplePlane.C index bb82d2b89ba82f2b77f85b0732d6c761142d5f47..edead29a1780fcf7112f5494f21275b453360d80 100644 --- a/src/sampling/surfMeshSample/plane/surfMeshSamplePlane.C +++ b/src/sampling/surfMeshSample/plane/surfMeshSamplePlane.C @@ -89,10 +89,11 @@ Foam::surfMeshSamplePlane::surfMeshSamplePlane // allow lookup from global coordinate systems if (dict.found("coordinateSystem")) { - coordinateSystem cs(mesh, dict.subDict("coordinateSystem")); + auto csysPtr = coordinateSystem::New(mesh, dict, "coordinateSystem"); + const auto& csys = *csysPtr; - const point base = cs.globalPosition(planeDesc().refPoint()); - const vector norm = cs.globalVector(planeDesc().normal()); + const point base = csys.globalPosition(planeDesc().refPoint()); + const vector norm = csys.globalVector(planeDesc().normal()); // Assign the plane description static_cast<plane&>(*this) = plane(base, norm); diff --git a/src/topoChangerFvMesh/mixerFvMesh/mixerFvMesh.C b/src/topoChangerFvMesh/mixerFvMesh/mixerFvMesh.C index d613e33906ebe782568f17b78aadb3817db49983..810847c07ed92bbf154d3ce681df7532c36e1d44 100644 --- a/src/topoChangerFvMesh/mixerFvMesh/mixerFvMesh.C +++ b/src/topoChangerFvMesh/mixerFvMesh/mixerFvMesh.C @@ -35,7 +35,6 @@ License namespace Foam { defineTypeNameAndDebug(mixerFvMesh, 0); - addToRunTimeSelectionTable(topoChangerFvMesh, mixerFvMesh, IOobject); } @@ -207,8 +206,7 @@ void Foam::mixerFvMesh::calcMovingMasks() const const word innerSliderZoneName ( - word(motionDict_.subDict("slider").lookup("inside")) - + "Zone" + motionDict_.subDict("slider").get<word>("inside") + "Zone" ); const labelList& innerSliderAddr = faceZones()[innerSliderZoneName]; @@ -225,8 +223,7 @@ void Foam::mixerFvMesh::calcMovingMasks() const const word outerSliderZoneName ( - word(motionDict_.subDict("slider").lookup("outside")) - + "Zone" + motionDict_.subDict("slider").get<word>("outside") + "Zone" ); const labelList& outerSliderAddr = faceZones()[outerSliderZoneName]; @@ -245,7 +242,6 @@ void Foam::mixerFvMesh::calcMovingMasks() const // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct from components Foam::mixerFvMesh::mixerFvMesh ( const IOobject& io @@ -269,13 +265,9 @@ Foam::mixerFvMesh::mixerFvMesh ), csPtr_ ( - coordinateSystem::New - ( - "coordinateSystem", - motionDict_.subDict("coordinateSystem") - ) + coordinateSystem::New(*this, motionDict_, "coordinateSystem") ), - rpm_(readScalar(motionDict_.lookup("rpm"))), + rpm_(motionDict_.get<scalar>("rpm")), movingPointsMaskPtr_(nullptr) { addZonesAndModifiers(); diff --git a/src/topoChangerFvMesh/mixerFvMesh/mixerFvMesh.H b/src/topoChangerFvMesh/mixerFvMesh/mixerFvMesh.H index 5d4eb0c27097269acb53a7da031df8793385e6e4..d1c687c6f945c040d51581deb1d7f5676359ddf6 100644 --- a/src/topoChangerFvMesh/mixerFvMesh/mixerFvMesh.H +++ b/src/topoChangerFvMesh/mixerFvMesh/mixerFvMesh.H @@ -43,8 +43,6 @@ SourceFiles namespace Foam { -// Forward declaration of classes - /*---------------------------------------------------------------------------*\ Class mixerFvMesh Declaration \*---------------------------------------------------------------------------*/ @@ -61,7 +59,7 @@ class mixerFvMesh //- Coordinate system autoPtr<coordinateSystem> csPtr_; - // - Rotational speed in rotations per minute (rpm) + // - Rotational speed in revolutions per minute (rpm) scalar rpm_; //- Markup field for points. Moving points marked with 1 diff --git a/src/waveModels/waveModel/waveModel.C b/src/waveModels/waveModel/waveModel.C index ed7e3e1ba326464cc9a3440dba841d364b1a5e3d..9bf97a8a081a8eab18e1e509e2df7ae4bb9b10ee 100644 --- a/src/waveModels/waveModel/waveModel.C +++ b/src/waveModels/waveModel/waveModel.C @@ -53,7 +53,7 @@ Foam::word Foam::waveModel::modelName(const word& patchName) void Foam::waveModel::initialiseGeometry() { - // Determine local patch co-ordinate system given by: + // Determine local patch coordinate system given by: // - X: streamwise: patch normal // - Y: spanwise: Z^X // - Z: up: (negative) gravity direction @@ -403,7 +403,7 @@ void Foam::waveModel::correct(const scalar t) } } - // Transform velocity into global co-ordinate system + // Transform velocity into global coordinate system U_ = Rlg_ & U_; currTimeIndex_ = mesh_.time().timeIndex(); diff --git a/src/waveModels/waveModel/waveModel.H b/src/waveModels/waveModel/waveModel.H index 36d48ddd8f7a4f3da06ef5f412f1d997d49e38ea..0d90cc9b99fd9eaf3031980e9d2c2a1c5fa30583 100644 --- a/src/waveModels/waveModel/waveModel.H +++ b/src/waveModels/waveModel/waveModel.H @@ -85,16 +85,16 @@ protected: //- Number of paddles label nPaddle_; - //- Paddle x co-ordinates / [m] + //- Paddle x coordinates / [m] scalarField xPaddle_; - //- Paddle y co-ordinates / [m] + //- Paddle y coordinates / [m] scalarField yPaddle_; //- Addressing from patch face index to paddle index labelList faceToPaddle_; - //- Patch face centre z co-ordinates / [m] + //- Patch face centre z coordinates / [m] scalarField z_; //- Overall (point) span in z-direction / [m] diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/angledDuct/constant/fvOptions b/tutorials/compressible/rhoPimpleFoam/RAS/angledDuct/constant/fvOptions index 3d246ece8b7ac86d32e447b3aacb108d57b5ffe4..306f826cef7c73498ed38b0229640e79fc72c756 100644 --- a/tutorials/compressible/rhoPimpleFoam/RAS/angledDuct/constant/fvOptions +++ b/tutorials/compressible/rhoPimpleFoam/RAS/angledDuct/constant/fvOptions @@ -31,14 +31,9 @@ porosity1 coordinateSystem { - type cartesian; origin (0 0 0); - coordinateRotation - { - type axesRotation; - e1 (0.70710678 0.70710678 0); - e3 (0 0 1); - } + e1 (0.70710678 0.70710678 0); + e3 (0 0 1); } } } diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/angledDuctLTS/constant/fvOptions b/tutorials/compressible/rhoPimpleFoam/RAS/angledDuctLTS/constant/fvOptions index 1a139a96d42795c03219a87c6d97c5bacc392918..adaebd15cfc0b5bb8bd9999a647796cfb2c0977b 100644 --- a/tutorials/compressible/rhoPimpleFoam/RAS/angledDuctLTS/constant/fvOptions +++ b/tutorials/compressible/rhoPimpleFoam/RAS/angledDuctLTS/constant/fvOptions @@ -31,14 +31,9 @@ porosity1 coordinateSystem { - type cartesian; origin (0 0 0); - coordinateRotation - { - type axesRotation; - e1 (0.70710678 0.70710678 0); - e2 (0 0 1); - } + e1 (0.70710678 0.70710678 0); + e2 (0 0 1); } } } diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/mixerVessel2D/constant/fvOptions b/tutorials/compressible/rhoPimpleFoam/RAS/mixerVessel2D/constant/fvOptions index 1dca13888a90724ee205bd495e4745b750b7447d..1ce0804c6aef71776cc732bbb6f4e55d84ba5746 100644 --- a/tutorials/compressible/rhoPimpleFoam/RAS/mixerVessel2D/constant/fvOptions +++ b/tutorials/compressible/rhoPimpleFoam/RAS/mixerVessel2D/constant/fvOptions @@ -31,13 +31,10 @@ porosity1 coordinateSystem { - type cartesian; origin (0 0 0); coordinateRotation { - type axesRotation; - e1 (1 0 0); - e2 (0 1 0); + type none; } } } diff --git a/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/common/constant/porosityProperties b/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/common/constant/porosityProperties index 8093402fc9173a766a8c048c986ccc2338a09ecd..77c3649255caf6e6061bdc6d4837788c8141d760 100644 --- a/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/common/constant/porosityProperties +++ b/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/common/constant/porosityProperties @@ -26,14 +26,9 @@ porosity1 coordinateSystem { - type cartesian; origin (0 0 0); - coordinateRotation - { - type axesRotation; - e1 (0.70710678 0.70710678 0); - e2 (0 0 1); - } + e1 (0.70710678 0.70710678 0); + e2 (0 0 1); } } diff --git a/tutorials/compressible/rhoSimpleFoam/angledDuctExplicitFixedCoeff/constant/fvOptions b/tutorials/compressible/rhoSimpleFoam/angledDuctExplicitFixedCoeff/constant/fvOptions index 1cf991953fe20be1ad46cc054ca2170b2d5fd878..4fc67a5490e3b9ef87dee628503dc70cd7c059f0 100644 --- a/tutorials/compressible/rhoSimpleFoam/angledDuctExplicitFixedCoeff/constant/fvOptions +++ b/tutorials/compressible/rhoSimpleFoam/angledDuctExplicitFixedCoeff/constant/fvOptions @@ -35,14 +35,9 @@ porosity coordinateSystem { - type cartesian; origin (0 0 0); - coordinateRotation - { - type axesRotation; - e1 (0.70710678 0.70710678 0); - e2 (0 0 1); - } + e1 (0.70710678 0.70710678 0); + e2 (0 0 1); } } } diff --git a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/system/snappyHexMeshDict b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/system/snappyHexMeshDict index c75aa58ad7817330de576a564d9a1525ffeed24a..244b9b7177823732a9e78d1511cc3fe2a20015e1 100644 --- a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/system/snappyHexMeshDict +++ b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/system/snappyHexMeshDict @@ -54,17 +54,9 @@ geometry scale (1.0 1.0 2.1); transform { - coordinateSystem - { - type cartesian; - origin (2 2 0); - coordinateRotation - { - type axesRotation; - e1 (1 0 0); - e3 (0 0 1); - } - } + origin (2 2 0); + e1 (1 0 0); + e3 (0 0 1); } } herring @@ -73,17 +65,9 @@ geometry scale (1.0 1.0 2.1); transform { - coordinateSystem - { - type cartesian; - origin (3.5 3 0); - coordinateRotation - { - type axesRotation; - e1 (1 0 0); - e3 (0 0 1); - } - } + origin (3.5 3 0); + e1 (1 0 0); + e3 (0 0 1); } } } @@ -121,7 +105,6 @@ castellatedMeshControls nCellsBetweenLevels 1; - // Explicit feature edge refinement // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -136,7 +119,6 @@ castellatedMeshControls ); - // Surface based refinement // ~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/constant/air/fvOptions b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/constant/air/fvOptions index 870926abb9f90aa1d14bc015a4fe73f9de67b2ca..15fa8b1c2cbad1fbd42cf507cc67fd32f615b553 100644 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/constant/air/fvOptions +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/constant/air/fvOptions @@ -44,14 +44,9 @@ porosityBlockage coordinateSystem { - type cartesian; origin (0 0 0); - coordinateRotation - { - type axesRotation; - e1 (0 1 0); - e2 (0 0 1); - } + e1 (0 1 0); + e2 (0 0 1); } } } diff --git a/tutorials/incompressible/pisoFoam/laminar/porousBlockage/constant/fvOptions b/tutorials/incompressible/pisoFoam/laminar/porousBlockage/constant/fvOptions index 5240f45df467c7c5bb86a1b03ad423123eec2fb1..e2dc251030d04dfe77abe75d8540a919fca21219 100644 --- a/tutorials/incompressible/pisoFoam/laminar/porousBlockage/constant/fvOptions +++ b/tutorials/incompressible/pisoFoam/laminar/porousBlockage/constant/fvOptions @@ -36,13 +36,10 @@ porosity1 coordinateSystem { - type cartesian; origin (0 0 0); coordinateRotation { - type axesRotation; - e1 (1 0 0); - e2 (0 1 0); + type none; } } } diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuct/common/constant/porosityProperties b/tutorials/incompressible/porousSimpleFoam/angledDuct/common/constant/porosityProperties index bea521b859ae500b54af07f88a75788473c08192..77c3649255caf6e6061bdc6d4837788c8141d760 100644 --- a/tutorials/incompressible/porousSimpleFoam/angledDuct/common/constant/porosityProperties +++ b/tutorials/incompressible/porousSimpleFoam/angledDuct/common/constant/porosityProperties @@ -26,14 +26,9 @@ porosity1 coordinateSystem { - type cartesian; origin (0 0 0); - coordinateRotation - { - type axesRotation; - e1 (0.70710678 0.70710678 0); - e2 (0 0 1); - } + e1 (0.70710678 0.70710678 0); + e2 (0 0 1); } } diff --git a/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/constant/porosityProperties b/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/constant/porosityProperties index 9c81c5df7e1dee0ec104c283d060dd56acbc642c..13973aa67e953fdd662d54bc25bd938ca99a1ead 100644 --- a/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/constant/porosityProperties +++ b/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/constant/porosityProperties @@ -26,14 +26,9 @@ porosity1 coordinateSystem { - type cartesian; origin (0 0 0); - coordinateRotation - { - type axesRotation; - e1 (1 0 0); //(0.70710678 0.70710678 0); - e2 (0 0 1); - } + e1 (1 0 0); + e2 (0 1 0); } } diff --git a/tutorials/incompressible/simpleFoam/simpleCar/system/fvOptions b/tutorials/incompressible/simpleFoam/simpleCar/system/fvOptions index 8619d8254bef8fef8a4d0d881222b2a2b4bfb79e..36dd8238364f8d3c85a8fdeed4c3445bba4fa4b0 100644 --- a/tutorials/incompressible/simpleFoam/simpleCar/system/fvOptions +++ b/tutorials/incompressible/simpleFoam/simpleCar/system/fvOptions @@ -33,14 +33,9 @@ porosity1 coordinateSystem { - type cartesian; - origin (0 0 0); - coordinateRotation - { - type axesRotation; - e1 (1 0 0); - e2 (0 1 0); - } + origin (0 0 0); + e1 (1 0 0); + e2 (0 1 0); } } } diff --git a/tutorials/lagrangian/reactingParcelFoam/filter/constant/fvOptions b/tutorials/lagrangian/reactingParcelFoam/filter/constant/fvOptions index fdbdbb37dbb24a022b35a3e0820587b2aaab3800..b2fd38d6d48e450160026ea041967eff3b8a7381 100644 --- a/tutorials/lagrangian/reactingParcelFoam/filter/constant/fvOptions +++ b/tutorials/lagrangian/reactingParcelFoam/filter/constant/fvOptions @@ -31,14 +31,9 @@ filter1 coordinateSystem { - type cartesian; origin (0 0 0); - coordinateRotation - { - type axesRotation; - e1 (1 0 0); - e2 (0 1 0); - } + e1 (1 0 0); + e2 (0 1 0); } } } diff --git a/tutorials/mesh/parallel/filter/system/fvOptions b/tutorials/mesh/parallel/filter/system/fvOptions index be0c86520ff4390b37ad04eb064afc260a2a8110..89094dc787b9104e5654f72c99c1816459048a5d 100644 --- a/tutorials/mesh/parallel/filter/system/fvOptions +++ b/tutorials/mesh/parallel/filter/system/fvOptions @@ -34,14 +34,9 @@ filter1 coordinateSystem { - type cartesian; origin (0 0 0); - coordinateRotation - { - type axesRotation; - e1 (1 0 0); - e2 (0 1 0); - } + e1 (1 0 0); + e2 (0 1 0); } } } diff --git a/tutorials/multiphase/interFoam/RAS/angledDuct/constant/fvOptions b/tutorials/multiphase/interFoam/RAS/angledDuct/constant/fvOptions index 84a023855686f37df4e4d616951ef3da371bde7f..e90a10d0965f8e46222eff7f2c9d987deffb3823 100644 --- a/tutorials/multiphase/interFoam/RAS/angledDuct/constant/fvOptions +++ b/tutorials/multiphase/interFoam/RAS/angledDuct/constant/fvOptions @@ -31,14 +31,9 @@ porosity1 coordinateSystem { - type cartesian; origin (0 0 0); - coordinateRotation - { - type axesRotation; - e1 (0.70710678 0.70710678 0); - e2 (0 0 1); - } + e1 (0.70710678 0.70710678 0); + e2 (0 0 1); } } } diff --git a/tutorials/verificationAndValidation/schemes/divergenceExample/README b/tutorials/verificationAndValidation/schemes/divergenceExample/README index 6b586a8f8ea32544a3f4eff4e319efcd141301d9..6e04d3a7603fd4739d903a7ce44453fb29a35a39 100644 --- a/tutorials/verificationAndValidation/schemes/divergenceExample/README +++ b/tutorials/verificationAndValidation/schemes/divergenceExample/README @@ -2,7 +2,7 @@ Divergence scheme test ====================== Various divergence schemes are examined on a 2-D structured mesh, where a -passive scalar is convected at 45deg to the mesh co-ordinate system using a +passive scalar is convected at 45deg to the mesh coordinate system using a uniform flow velocity. Executing: ./Allrun