diff --git a/applications/test/dimField/Make/files b/applications/test/dimField/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..8289e2ec00d6a022bae5c79fa46f7ebd4951d48e --- /dev/null +++ b/applications/test/dimField/Make/files @@ -0,0 +1,3 @@ +Test-dimField.C + +EXE = $(FOAM_USER_APPBIN)/Test-dimField diff --git a/applications/test/dimField/Make/options b/applications/test/dimField/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..d27c95d033dd5d7b1995c8ff8dc406e35ca1f586 --- /dev/null +++ b/applications/test/dimField/Make/options @@ -0,0 +1,7 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude + +EXE_LIBS = \ + -lfiniteVolume \ + -lmeshTools diff --git a/applications/test/dimField/Test-dimField.C b/applications/test/dimField/Test-dimField.C new file mode 100644 index 0000000000000000000000000000000000000000..bc0c261782140abb0948247444dbb606389a7970 --- /dev/null +++ b/applications/test/dimField/Test-dimField.C @@ -0,0 +1,110 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 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/>. + +Application + Test-dimField + +Description + Simple tests for DimensionedField + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "GeometricFields.H" + +// #undef TEST_UINT8_FIELD + +#ifdef TEST_UINT8_FIELD +namespace Foam +{ + // Something like an internal state field. Probably only dimensionless + typedef DimensionedField<uint8_t, volMesh> dimUint8Field; + + defineTemplate2TypeNameAndDebug(dimUint8Field, 0); + +} // End namespace Foam +#endif + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + + { + Info<< "Tensor field\n" << endl; + DimensionedField<tensor, volMesh> tensorfld + ( + IOobject + ( + "tensor", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensioned<tensor>(dimless, tensor(1,2,3,4,5,6,7,8,9)) + ); + + Info().beginBlock("transformed") + << tensorfld.T() << nl; + Info().endBlock(); + } + + #ifdef TEST_UINT8_FIELD + { + Info<< "uint8 field\n" << endl; + DimensionedField<uint8_t, volMesh> statefld + ( + IOobject + ( + "state", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensioned<uint8_t>(dimless, uint8_t{100}) + ); + + Info().beginBlock("stateField") + << statefld << nl; + Info().endBlock(); + } + #endif + + + Info<< "\nEnd\n" << nl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/test/volField/Test-volField.C b/applications/test/volField/Test-volField.C index 0e5823570415cb87b962d53fad0501e1e855607c..95307ceed43937fca1ce31eea1b467b40a28bb92 100644 --- a/applications/test/volField/Test-volField.C +++ b/applications/test/volField/Test-volField.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -33,6 +33,20 @@ Application #include "GeometricFields.H" #include "transformGeometricField.H" +// #undef TEST_UINT8_FIELD + +#ifdef TEST_UINT8_FIELD +namespace Foam +{ + // Something like a state field. Probably only dimensionless + // - still needs some basic boundary conditions!! + typedef GeometricField<uint8_t, fvPatchField, volMesh> volUint8Field; + + defineTemplate2TypeNameAndDebug(volUint8Field, 0); + +} // End namespace Foam +#endif + template<class GeoField> void setDims(UPtrList<GeoField>& list, const dimensionSet& ds) @@ -159,7 +173,7 @@ int main(int argc, char *argv[]) #include "createPhi.H" - GeometricField<symmTensor, fvPatchField, volMesh> st + volSymmTensorField st ( IOobject ( @@ -170,11 +184,11 @@ int main(int argc, char *argv[]) IOobject::NO_WRITE ), mesh, - dimensioned<symmTensor>("st", dimless, symmTensor::one), + dimensioned<symmTensor>(dimless, symmTensor::one), zeroGradientFvPatchSymmTensorField::typeName ); - GeometricField<tensor, fvPatchField, volMesh> tensf + volTensorField tensf ( IOobject ( @@ -185,7 +199,7 @@ int main(int argc, char *argv[]) IOobject::NO_WRITE ), mesh, - dimensioned<tensor>("tf", dimless, tensor(1,2,3,4,5,6,7,8,9)), + dimensioned<tensor>(dimless, tensor(1,2,3,4,5,6,7,8,9)), zeroGradientFvPatchScalarField::typeName ); @@ -276,6 +290,31 @@ int main(int argc, char *argv[]) } + // Note: this is definitely not working, but added to help diagnose + // what is missing if we wish to proceed with this idea + #ifdef TEST_UINT8_FIELD + { + Info<< "uint8 field\n" << endl; + GeometricField<uint8_t, fvPatchField, volMesh> statefld + ( + IOobject + ( + "state", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensioned<uint8_t>(dimless, uint8_t{100}) + ); + + Info().beginBlock("stateField") + << statefld << nl; + Info().endBlock(); + } + #endif + Info<< "\nEnd\n" << nl; return 0; diff --git a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.C b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.C index 17b50d374bb0c349de0c92ef2fbfc7686c5792f7..e7e9f06f833dc09c0a0ed7d9e72ef88b41f37335 100644 --- a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.C +++ b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015-2019 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -437,7 +437,7 @@ Foam::DimensionedField<Type, GeoMesh>::T() const dimensions_ ); - Foam::T(tresult(), *this); + Foam::T(tresult.ref(), *this); return tresult; }