diff --git a/applications/test/volField/Test-volField.C b/applications/test/volField/Test-volField.C index 25388a273a..0e58235704 100644 --- a/applications/test/volField/Test-volField.C +++ b/applications/test/volField/Test-volField.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2019 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -29,12 +30,96 @@ Application \*---------------------------------------------------------------------------*/ #include "fvCFD.H" +#include "GeometricFields.H" #include "transformGeometricField.H" + +template +void setDims(UPtrList& list, const dimensionSet& ds) +{ + forAll(list, i) + { + if (list.set(i)) + { + list[i].dimensions().reset(ds); + } + } +} + + +template +void rename(UPtrList& list, const word& baseName) +{ + forAll(list, i) + { + if (list.set(i)) + { + list[i].rename(IOobject::groupName(baseName, name(i))); + } + } +} + + +template +void setDims(UPtrList& list, const GeoField2& refField) +{ + setDims(list, refField.dimensions()); +} + + +template +void write +( + UPtrList& list, + label len +) +{ + len = min(len, list.size()); + + for (label i=0; i < len; ++i) + { + if (list.set(i)) + { + list[i].write(); + } + } +} + + +template +PtrList create +( + const fvMesh& mesh, + const label len +) +{ + PtrList list(len); + + forAll(list, i) + { + list.set + ( + i, + GeoField::New + ( + word("cmpt." + name(i)), + mesh, + dimensioned(Zero) + ).ptr() + ); + } + + return list; +} + + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) { + argList::addBoolOption("zip", "run zip/unzip tests"); + #include "setRootCase.H" #include "createTime.H" @@ -89,6 +174,21 @@ int main(int argc, char *argv[]) zeroGradientFvPatchSymmTensorField::typeName ); + GeometricField tensf + ( + IOobject + ( + "tf", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensioned("tf", dimless, tensor(1,2,3,4,5,6,7,8,9)), + zeroGradientFvPatchScalarField::typeName + ); + SolverPerformance sP = ( solve @@ -118,6 +218,66 @@ int main(int argc, char *argv[]) << "solverPerformanceDict: " << mesh.solverPerformanceDict() << endl; + + if (args.found("zip")) + { + Info<< nl << "Running some zip/unzip tests" << nl; + + auto cmpts = create(mesh, 9); + auto slice = create(mesh, 3); + + // vector + { + setDims(cmpts, U); + setDims(slice, U); + rename(cmpts, U.name()); + rename(slice, U.name() + "-slice"); + + Info<< "unzip: " << U.name() << nl; + + unzip(U, cmpts[0], cmpts[1], cmpts[2]); + + zip(U, cmpts[0], cmpts[1], cmpts[2]); + + U.rename(IOobject::groupName(U.name(), "rezip")); + + write(cmpts, 3); + U.write(); + } + + // tensor + { + setDims(cmpts, tensf); + setDims(slice, tensf); + rename(cmpts, tensf.name()); + rename(slice, tensf.name() + "-slice"); + + Info<< "unzip: " << tensf.name() << nl; + + unzip + ( + tensf, + cmpts[0], cmpts[1], cmpts[2], + cmpts[3], cmpts[4], cmpts[5], + cmpts[6], cmpts[7], cmpts[8] + ); + + unzipRows(tensf, slice[0], slice[1], slice[2]); + + // reszip transposed + zipCols(tensf, slice[0], slice[1], slice[2]); + + tensf.rename(tensf.name() + "-T"); + + write(cmpts, 9); + write(slice, 3); + tensf.write(); + } + } + + + Info<< "\nEnd\n" << nl; + return 0; } diff --git a/applications/test/volField/cavity/Allclean b/applications/test/volField/cavity/Allclean new file mode 100755 index 0000000000..67037edd0a --- /dev/null +++ b/applications/test/volField/cavity/Allclean @@ -0,0 +1,10 @@ +#!/bin/sh +cd "${0%/*}" || exit # Run from this directory +. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions + +cleanCase + +# Remove anything with '.' separator (generated fields) +rm -f 0/*.* + +#------------------------------------------------------------------------------ diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFields.H b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFields.H index 2683bc5ceb..19fee2e49f 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFields.H +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFields.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation + Copyright (C) 2019 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,14 +28,17 @@ InClass Foam::GeometricFields Description + The standard GeometricField types \*---------------------------------------------------------------------------*/ #ifndef GeometricFields_H #define GeometricFields_H +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + #include "GeometricScalarField.H" -//#include "GeometricVectorField.H" +#include "GeometricVectorField.H" #include "GeometricTensorField.H" #include "GeometricSphericalTensorField.H" diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricSphericalTensorField/GeometricSphericalTensorField.C b/src/OpenFOAM/fields/GeometricFields/GeometricSphericalTensorField/GeometricSphericalTensorField.C index 53e712d4ad..6aaa3db3cc 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricSphericalTensorField/GeometricSphericalTensorField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricSphericalTensorField/GeometricSphericalTensorField.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2013 OpenFOAM Foundation + Copyright (C) 2019 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,16 +27,45 @@ License \*---------------------------------------------------------------------------*/ #include "GeometricSphericalTensorField.H" +#include "sphericalTensorFieldField.H" #define TEMPLATE template class PatchField, class GeoMesh> #include "GeometricFieldFunctionsM.C" +// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // + +template class PatchField, class GeoMesh> +void Foam::zip +( + GeometricField, PatchField, GeoMesh>& result, + const GeometricField& ii +) +{ + Foam::zip(result.primitiveFieldRef(), ii.primitiveField()); + + Foam::zip(result.boundaryFieldRef(), ii.boundaryField()); +} + + +template class PatchField, class GeoMesh> +void Foam::unzip +( + const GeometricField, PatchField, GeoMesh>& input, + GeometricField& ii +) +{ + Foam::unzip(input.primitiveField(), ii.primitiveFieldRef()); + + Foam::unzip(input.boundaryField(), ii.boundaryFieldRef()); +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -// * * * * * * * * * * * * * * * global functions * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // UNARY_FUNCTION(scalar, sphericalTensor, tr, transform) UNARY_FUNCTION(sphericalTensor, sphericalTensor, sph, transform) diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricSphericalTensorField/GeometricSphericalTensorField.H b/src/OpenFOAM/fields/GeometricFields/GeometricSphericalTensorField/GeometricSphericalTensorField.H index 0020d2be7c..a3490731c4 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricSphericalTensorField/GeometricSphericalTensorField.H +++ b/src/OpenFOAM/fields/GeometricFields/GeometricSphericalTensorField/GeometricSphericalTensorField.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2019 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -48,6 +49,24 @@ SourceFiles namespace Foam { +//- Zip together sphericalTensor field from components +template class PatchField, class GeoMesh> +void zip +( + GeometricField, PatchField, GeoMesh>& result, + const GeometricField& ii +); + + +//- Unzip sphericalTensor field into components +template class PatchField, class GeoMesh> +void unzip +( + const GeometricField, PatchField, GeoMesh>& input, + GeometricField& ii +); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // UNARY_FUNCTION(scalar, sphericalTensor, tr, transform) diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricSymmTensorField/GeometricSymmTensorField.C b/src/OpenFOAM/fields/GeometricFields/GeometricSymmTensorField/GeometricSymmTensorField.C index 10ee49ab36..e17cad56dc 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricSymmTensorField/GeometricSymmTensorField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricSymmTensorField/GeometricSymmTensorField.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation + Copyright (C) 2019 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -31,6 +32,81 @@ License #define TEMPLATE template class PatchField, class GeoMesh> #include "GeometricFieldFunctionsM.C" +// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // + +template class PatchField, class GeoMesh> +void Foam::zip +( + GeometricField, PatchField, GeoMesh>& result, + const GeometricField& xx, + const GeometricField& xy, + const GeometricField& xz, + const GeometricField& yy, + const GeometricField& yz, + const GeometricField& zz +) +{ + Foam::zip + ( + result.primitiveFieldRef(), + xx.primitiveField(), xy.primitiveField(), xz.primitiveField(), + yy.primitiveField(), yz.primitiveField(), + zz.primitiveField() + ); + + Foam::zip + ( + result.boundaryFieldRef(), + xx.boundaryField(), xy.boundaryField(), xz.boundaryField(), + yy.boundaryField(), yz.boundaryField(), + zz.boundaryField() + ); +} + + +template class PatchField, class GeoMesh> +void Foam::unzip +( + const GeometricField, PatchField, GeoMesh>& input, + GeometricField& xx, + GeometricField& xy, + GeometricField& xz, + GeometricField& yy, + GeometricField& yz, + GeometricField& zz +) +{ + Foam::unzip + ( + input.primitiveField(), + xx.primitiveFieldRef(), xy.primitiveFieldRef(), xz.primitiveFieldRef(), + yy.primitiveFieldRef(), yz.primitiveFieldRef(), + zz.primitiveFieldRef() + ); + + Foam::unzip + ( + input.boundaryField(), + xx.boundaryFieldRef(), xy.boundaryFieldRef(), xz.boundaryFieldRef(), + yy.boundaryFieldRef(), yz.boundaryFieldRef(), + zz.boundaryFieldRef() + ); +} + + +template class PatchField, class GeoMesh> +void Foam::unzipDiag +( + const GeometricField, PatchField, GeoMesh>& input, + GeometricField, PatchField, GeoMesh>& result +) +{ + Foam::unzipDiag(input.primitiveField(), result.primitiveFieldRef()); + + Foam::unzipDiag(input.boundaryField(), result.boundaryFieldRef()); +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -52,7 +128,7 @@ UNARY_FUNCTION(symmTensor, symmTensor, cof, pow2) UNARY_FUNCTION(symmTensor, symmTensor, inv, inv) -// * * * * * * * * * * * * * * * global operators * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // UNARY_OPERATOR(vector, symmTensor, *, hdual, transform) diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricSymmTensorField/GeometricSymmTensorField.H b/src/OpenFOAM/fields/GeometricFields/GeometricSymmTensorField/GeometricSymmTensorField.H index 8b92fdf189..f73aa7aed6 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricSymmTensorField/GeometricSymmTensorField.H +++ b/src/OpenFOAM/fields/GeometricFields/GeometricSymmTensorField/GeometricSymmTensorField.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2019 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -48,6 +49,43 @@ SourceFiles namespace Foam { +// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // + +//- Zip together symmTensor field from components +template class PatchField, class GeoMesh> +void zip +( + GeometricField, PatchField, GeoMesh>& result, + const GeometricField& xx, + const GeometricField& xy, + const GeometricField& xz, + const GeometricField& yy, + const GeometricField& yz, + const GeometricField& zz +); + +//- Unzip symmTensor field into components +template class PatchField, class GeoMesh> +void unzip +( + const GeometricField, PatchField, GeoMesh>& input, + GeometricField& xx, + GeometricField& xy, + GeometricField& xz, + GeometricField& yy, + GeometricField& yz, + GeometricField& zz +); + +//- Extract a symmTensor field diagonal +template class PatchField, class GeoMesh> +void unzipDiag +( + const GeometricField, PatchField, GeoMesh>& input, + GeometricField, PatchField, GeoMesh>& result +); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // UNARY_FUNCTION(symmTensor, vector, sqr, sqr) @@ -64,7 +102,7 @@ UNARY_FUNCTION(symmTensor, symmTensor, cof, cof) UNARY_FUNCTION(symmTensor, symmTensor, inv, inv) -// * * * * * * * * * * * * * * * global operators * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // UNARY_OPERATOR(vector, symmTensor, *, hdual, transform) diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricTensorField/GeometricTensorField.C b/src/OpenFOAM/fields/GeometricFields/GeometricTensorField/GeometricTensorField.C index 63e326a835..8c1e0eada8 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricTensorField/GeometricTensorField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricTensorField/GeometricTensorField.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2013 OpenFOAM Foundation + Copyright (C) 2019 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -31,6 +32,223 @@ License #define TEMPLATE template class PatchField, class GeoMesh> #include "GeometricFieldFunctionsM.C" +// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // + +template class PatchField, class GeoMesh> +void Foam::zip +( + GeometricField, PatchField, GeoMesh>& result, + const GeometricField& xx, + const GeometricField& xy, + const GeometricField& xz, + const GeometricField& yx, + const GeometricField& yy, + const GeometricField& yz, + const GeometricField& zx, + const GeometricField& zy, + const GeometricField& zz +) +{ + Foam::zip + ( + result.primitiveFieldRef(), + xx.primitiveField(), xy.primitiveField(), xz.primitiveField(), + yx.primitiveField(), yy.primitiveField(), yz.primitiveField(), + zx.primitiveField(), zy.primitiveField(), zz.primitiveField() + ); + + Foam::zip + ( + result.boundaryFieldRef(), + xx.boundaryField(), xy.boundaryField(), xz.boundaryField(), + yx.boundaryField(), yy.boundaryField(), yz.boundaryField(), + zx.boundaryField(), zy.boundaryField(), zz.boundaryField() + ); +} + + +template class PatchField, class GeoMesh> +void Foam::unzip +( + const GeometricField, PatchField, GeoMesh>& input, + GeometricField& xx, + GeometricField& xy, + GeometricField& xz, + GeometricField& yx, + GeometricField& yy, + GeometricField& yz, + GeometricField& zx, + GeometricField& zy, + GeometricField& zz +) +{ + Foam::unzip + ( + input.primitiveField(), + xx.primitiveFieldRef(), xy.primitiveFieldRef(), xz.primitiveFieldRef(), + yx.primitiveFieldRef(), yy.primitiveFieldRef(), yz.primitiveFieldRef(), + zx.primitiveFieldRef(), zy.primitiveFieldRef(), zz.primitiveFieldRef() + ); + + Foam::unzip + ( + input.boundaryField(), + xx.boundaryFieldRef(), xy.boundaryFieldRef(), xz.boundaryFieldRef(), + yx.boundaryFieldRef(), yy.boundaryFieldRef(), yz.boundaryFieldRef(), + zx.boundaryFieldRef(), zy.boundaryFieldRef(), zz.boundaryFieldRef() + ); +} + + +template class PatchField, class GeoMesh> +void Foam::zipRows +( + GeometricField, PatchField, GeoMesh>& result, + const GeometricField, PatchField, GeoMesh>& x, + const GeometricField, PatchField, GeoMesh>& y, + const GeometricField, PatchField, GeoMesh>& z +) +{ + Foam::zipRows + ( + result.primitiveFieldRef(), + x.primitiveField(), + y.primitiveField(), + z.primitiveField() + ); + + Foam::zipRows + ( + result.boundaryFieldRef(), + x.boundaryField(), + y.boundaryField(), + z.boundaryField() + ); +} + + +template class PatchField, class GeoMesh> +void Foam::zipCols +( + GeometricField, PatchField, GeoMesh>& result, + const GeometricField, PatchField, GeoMesh>& x, + const GeometricField, PatchField, GeoMesh>& y, + const GeometricField, PatchField, GeoMesh>& z +) +{ + Foam::zipCols + ( + result.primitiveFieldRef(), + x.primitiveField(), + y.primitiveField(), + z.primitiveField() + ); + + Foam::zipCols + ( + result.boundaryFieldRef(), + x.boundaryField(), + y.boundaryField(), + z.boundaryField() + ); +} + + +template class PatchField, class GeoMesh> +void Foam::unzipRows +( + const GeometricField, PatchField, GeoMesh>& input, + GeometricField, PatchField, GeoMesh>& x, + GeometricField, PatchField, GeoMesh>& y, + GeometricField, PatchField, GeoMesh>& z +) +{ + Foam::unzipRows + ( + input.primitiveField(), + x.primitiveFieldRef(), + y.primitiveFieldRef(), + z.primitiveFieldRef() + ); + + Foam::unzipRows + ( + input.boundaryField(), + x.boundaryFieldRef(), + y.boundaryFieldRef(), + z.boundaryFieldRef() + ); +} + + +template class PatchField, class GeoMesh> +void Foam::unzipCols +( + const GeometricField, PatchField, GeoMesh>& input, + GeometricField, PatchField, GeoMesh>& x, + GeometricField, PatchField, GeoMesh>& y, + GeometricField, PatchField, GeoMesh>& z +) +{ + Foam::unzipCols + ( + input.primitiveField(), + x.primitiveFieldRef(), + y.primitiveFieldRef(), + z.primitiveFieldRef() + ); + + Foam::unzipCols + ( + input.boundaryField(), + x.boundaryFieldRef(), + y.boundaryFieldRef(), + z.boundaryFieldRef() + ); +} + + +template class PatchField, class GeoMesh> +void Foam::unzipRow +( + const GeometricField, PatchField, GeoMesh>& input, + const vector::components cmpt, + GeometricField, PatchField, GeoMesh>& result +) +{ + Foam::unzipRow(input.primitiveField(), cmpt, result.primitiveFieldRef()); + + Foam::unzipRow(input.boundaryField(), cmpt, result.boundaryFieldRef()); +} + + +template class PatchField, class GeoMesh> +void Foam::unzipCol +( + const GeometricField, PatchField, GeoMesh>& input, + const vector::components cmpt, + GeometricField, PatchField, GeoMesh>& result +) +{ + Foam::unzipCol(input.primitiveField(), cmpt, result.primitiveFieldRef()); + + Foam::unzipCol(input.boundaryField(), cmpt, result.boundaryFieldRef()); +} + + +template class PatchField, class GeoMesh> +void Foam::unzipDiag +( + const GeometricField, PatchField, GeoMesh>& input, + GeometricField, PatchField, GeoMesh>& result +) +{ + Foam::unzipDiag(input.primitiveField(), result.primitiveFieldRef()); + + Foam::unzipDiag(input.boundaryField(), result.boundaryFieldRef()); +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -56,7 +274,7 @@ UNARY_FUNCTION(vector, symmTensor, eigenValues, transform) UNARY_FUNCTION(symmTensor, symmTensor, eigenVectors, sign) -// * * * * * * * * * * * * * * * global operators * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // UNARY_OPERATOR(vector, tensor, *, hdual, transform) UNARY_OPERATOR(tensor, vector, *, hdual, transform) diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricTensorField/GeometricTensorField.H b/src/OpenFOAM/fields/GeometricFields/GeometricTensorField/GeometricTensorField.H index 796a290d05..f9808b90ca 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricTensorField/GeometricTensorField.H +++ b/src/OpenFOAM/fields/GeometricFields/GeometricTensorField/GeometricTensorField.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2019 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -49,6 +50,110 @@ SourceFiles namespace Foam { +// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // + +//- Zip together tensor field from components +template class PatchField, class GeoMesh> +void zip +( + GeometricField, PatchField, GeoMesh>& result, + const GeometricField& xx, + const GeometricField& xy, + const GeometricField& xz, + const GeometricField& yx, + const GeometricField& yy, + const GeometricField& yz, + const GeometricField& zx, + const GeometricField& zy, + const GeometricField& zz +); + +//- Unzip tensor field into components +template class PatchField, class GeoMesh> +void unzip +( + const GeometricField, PatchField, GeoMesh>& input, + GeometricField& xx, + GeometricField& xy, + GeometricField& xz, + GeometricField& yx, + GeometricField& yy, + GeometricField& yz, + GeometricField& zx, + GeometricField& zy, + GeometricField& zz +); + + + +//- Zip together tensor field field from row components +template class PatchField, class GeoMesh> +void zipRows +( + GeometricField, PatchField, GeoMesh>& result, + const GeometricField, PatchField, GeoMesh>& x, + const GeometricField, PatchField, GeoMesh>& y, + const GeometricField, PatchField, GeoMesh>& z +); + +//- Zip together tensor field from column components +template class PatchField, class GeoMesh> +void zipCols +( + GeometricField, PatchField, GeoMesh>& result, + const GeometricField, PatchField, GeoMesh>& x, + const GeometricField, PatchField, GeoMesh>& y, + const GeometricField, PatchField, GeoMesh>& z +); + +//- Extract tensor field field rows +template class PatchField, class GeoMesh> +void unzipRows +( + const GeometricField, PatchField, GeoMesh>& input, + GeometricField, PatchField, GeoMesh>& x, + GeometricField, PatchField, GeoMesh>& y, + GeometricField, PatchField, GeoMesh>& z +); + +//- Extract tensor field field columns +template class PatchField, class GeoMesh> +void unzipCols +( + const GeometricField, PatchField, GeoMesh>& input, + GeometricField, PatchField, GeoMesh>& x, + GeometricField, PatchField, GeoMesh>& y, + GeometricField, PatchField, GeoMesh>& z +); + + +//- Extract a tensor field row (x,y,z) == (0,1,2) +template class PatchField, class GeoMesh> +void unzipRow +( + const GeometricField, PatchField, GeoMesh>& input, + const vector::components cmpt, + GeometricField, PatchField, GeoMesh>& result +); + +//- Extract a tensor field column (x,y,z) == (0,1,2) +template class PatchField, class GeoMesh> +void unzipCol +( + const GeometricField, PatchField, GeoMesh>& input, + const vector::components cmpt, + GeometricField, PatchField, GeoMesh>& result +); + +//- Extract a tensor field diagonal +template class PatchField, class GeoMesh> +void unzipDiag +( + const GeometricField, PatchField, GeoMesh>& input, + GeometricField, PatchField, GeoMesh>& result +); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // UNARY_FUNCTION(tensor, tensor, T, transform) @@ -69,7 +174,7 @@ UNARY_FUNCTION(vector, symmTensor, eigenValues, transform) UNARY_FUNCTION(symmTensor, symmTensor, eigenVectors, sign) -// * * * * * * * * * * * * * * * global operators * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // UNARY_OPERATOR(vector, tensor, *, hdual, transform) UNARY_OPERATOR(tensor, vector, *, hdual, transform) diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricVectorField/GeometricVectorField.C b/src/OpenFOAM/fields/GeometricFields/GeometricVectorField/GeometricVectorField.C new file mode 100644 index 0000000000..8d208fc19a --- /dev/null +++ b/src/OpenFOAM/fields/GeometricFields/GeometricVectorField/GeometricVectorField.C @@ -0,0 +1,87 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019 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 . + +\*---------------------------------------------------------------------------*/ + +#include "GeometricVectorField.H" +#include "vectorFieldField.H" + +// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // + +template class PatchField, class GeoMesh> +void Foam::zip +( + GeometricField, PatchField, GeoMesh>& result, + const GeometricField& x, + const GeometricField& y, + const GeometricField& z +) +{ + Foam::zip + ( + result.primitiveFieldRef(), + x.primitiveField(), + y.primitiveField(), + z.primitiveField() + ); + + Foam::zip + ( + result.boundaryFieldRef(), + x.boundaryField(), + y.boundaryField(), + z.boundaryField() + ); +} + + +template class PatchField, class GeoMesh> +void Foam::unzip +( + const GeometricField, PatchField, GeoMesh>& input, + GeometricField& x, + GeometricField& y, + GeometricField& z +) +{ + Foam::unzip + ( + input.primitiveField(), + x.primitiveFieldRef(), + y.primitiveFieldRef(), + z.primitiveFieldRef() + ); + + Foam::unzip + ( + input.boundaryField(), + x.boundaryFieldRef(), + y.boundaryFieldRef(), + z.boundaryFieldRef() + ); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricVectorField/GeometricVectorField.H b/src/OpenFOAM/fields/GeometricFields/GeometricVectorField/GeometricVectorField.H new file mode 100644 index 0000000000..464794704f --- /dev/null +++ b/src/OpenFOAM/fields/GeometricFields/GeometricVectorField/GeometricVectorField.H @@ -0,0 +1,82 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019 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 . + +InClass + Foam::GeometricVectorField + +Description + Vector specific part of the implementation of GeometricField. + +SourceFiles + GeometricVectorField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef GeometricVectorField_H +#define GeometricVectorField_H + +#include "GeometricScalarField.H" +#include "DimensionedScalarField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * // + +//- Compose a vector field from components +template class PatchField, class GeoMesh> +void zip +( + GeometricField, PatchField, GeoMesh>& result, + const GeometricField& x, + const GeometricField& y, + const GeometricField& z +); + +//- Unzip vector field into components +template class PatchField, class GeoMesh> +void unzip +( + const GeometricField, PatchField, GeoMesh>& input, + GeometricField& x, + GeometricField& y, + GeometricField& z +); + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "GeometricVectorField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //