From cf2b84ef3223a922fe721c74efb349c7e6d71de3 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 15 Nov 2019 13:32:27 +0100 Subject: [PATCH] ENH: add zip/unzip for FieldField --- .../test/tensorFieldFields1/Make/files | 3 + .../test/tensorFieldFields1/Make/options | 2 + .../Test-tensorFieldFields1.C | 275 ++++++++++++++++++ .../FieldFields/FieldField/FieldFields.H | 2 + .../scalarFieldField/scalarFieldField.H | 2 +- .../sphericalTensorFieldField.C | 33 ++- .../sphericalTensorFieldField.H | 20 ++ .../symmTensorFieldField.C | 67 +++++ .../symmTensorFieldField.H | 38 +++ .../tensorFieldField/tensorFieldField.C | 171 ++++++++++- .../tensorFieldField/tensorFieldField.H | 105 +++++++ .../vectorFieldField/vectorFieldField.C | 64 ++++ .../vectorFieldField/vectorFieldField.H | 85 ++++++ 13 files changed, 863 insertions(+), 4 deletions(-) create mode 100644 applications/test/tensorFieldFields1/Make/files create mode 100644 applications/test/tensorFieldFields1/Make/options create mode 100644 applications/test/tensorFieldFields1/Test-tensorFieldFields1.C create mode 100644 src/OpenFOAM/fields/FieldFields/vectorFieldField/vectorFieldField.C create mode 100644 src/OpenFOAM/fields/FieldFields/vectorFieldField/vectorFieldField.H diff --git a/applications/test/tensorFieldFields1/Make/files b/applications/test/tensorFieldFields1/Make/files new file mode 100644 index 0000000000..0bc78a8cea --- /dev/null +++ b/applications/test/tensorFieldFields1/Make/files @@ -0,0 +1,3 @@ +Test-tensorFieldFields1.C + +EXE = $(FOAM_USER_APPBIN)/Test-tensorFieldFields1 diff --git a/applications/test/tensorFieldFields1/Make/options b/applications/test/tensorFieldFields1/Make/options new file mode 100644 index 0000000000..18e6fe47af --- /dev/null +++ b/applications/test/tensorFieldFields1/Make/options @@ -0,0 +1,2 @@ +/* EXE_INC = */ +/* EXE_LIBS = */ diff --git a/applications/test/tensorFieldFields1/Test-tensorFieldFields1.C b/applications/test/tensorFieldFields1/Test-tensorFieldFields1.C new file mode 100644 index 0000000000..3c93f17753 --- /dev/null +++ b/applications/test/tensorFieldFields1/Test-tensorFieldFields1.C @@ -0,0 +1,275 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 . + +Application + Test-tensorFieldFields1 + +\*---------------------------------------------------------------------------*/ + +#include "tensorField.H" +#include "FieldFields.H" +#include "Random.H" + +using namespace Foam; + + +template +void printFieldField(const FieldField& ff) +{ + forAll(ff, i) + { + Info<< ' ' << flatOutput(ff[i]); + } + Info<< nl; +} + + +template +void printComponents(const FixedList, N>& cmpts) +{ + forAll(cmpts, cmpti) + { + Info<< cmpti << ':'; + printFieldField(cmpts[cmpti]); + } +} + + +template +void allocComponents +( + FixedList, N>& cmpts, + label dim = 1 +) +{ + forAll(cmpts, i) + { + cmpts[i] = FieldField(1); + cmpts[i].set(0, new Field(dim, Zero)); + } +} + + +vectorField randomVectorField(label size) +{ + Random rnd; + + vectorField vf(size); + + forAll(vf, i) + { + for (direction cmpt=0; cmpt < vector::nComponents; ++cmpt) + { + vf[i][cmpt] = rnd.position