diff --git a/applications/test/dimField/Make/files b/applications/test/dimField/Make/files
new file mode 100644
index 0000000000..8289e2ec00
--- /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 0000000000..d27c95d033
--- /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 0000000000..bc0c261782
--- /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 .
+
+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 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 tensorfld
+ (
+ IOobject
+ (
+ "tensor",
+ runTime.timeName(),
+ mesh,
+ IOobject::NO_READ,
+ IOobject::NO_WRITE
+ ),
+ mesh,
+ dimensioned(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 statefld
+ (
+ IOobject
+ (
+ "state",
+ runTime.timeName(),
+ mesh,
+ IOobject::NO_READ,
+ IOobject::NO_WRITE
+ ),
+ mesh,
+ dimensioned(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 0e58235704..95307ceed4 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 volUint8Field;
+
+ defineTemplate2TypeNameAndDebug(volUint8Field, 0);
+
+} // End namespace Foam
+#endif
+
template
void setDims(UPtrList& list, const dimensionSet& ds)
@@ -159,7 +173,7 @@ int main(int argc, char *argv[])
#include "createPhi.H"
- GeometricField st
+ volSymmTensorField st
(
IOobject
(
@@ -170,11 +184,11 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE
),
mesh,
- dimensioned("st", dimless, symmTensor::one),
+ dimensioned(dimless, symmTensor::one),
zeroGradientFvPatchSymmTensorField::typeName
);
- GeometricField tensf
+ volTensorField tensf
(
IOobject
(
@@ -185,7 +199,7 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE
),
mesh,
- dimensioned("tf", dimless, tensor(1,2,3,4,5,6,7,8,9)),
+ dimensioned(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 statefld
+ (
+ IOobject
+ (
+ "state",
+ runTime.timeName(),
+ mesh,
+ IOobject::NO_READ,
+ IOobject::NO_WRITE
+ ),
+ mesh,
+ dimensioned(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 17b50d374b..e7e9f06f83 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::T() const
dimensions_
);
- Foam::T(tresult(), *this);
+ Foam::T(tresult.ref(), *this);
return tresult;
}