mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: compilation error for DimensionedField::T() fixes #1868
- incorrectly used const access for the tmp instead of ref()
This commit is contained in:
3
applications/test/dimField/Make/files
Normal file
3
applications/test/dimField/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-dimField.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-dimField
|
||||
7
applications/test/dimField/Make/options
Normal file
7
applications/test/dimField/Make/options
Normal file
@ -0,0 +1,7 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lmeshTools
|
||||
110
applications/test/dimField/Test-dimField.C
Normal file
110
applications/test/dimField/Test-dimField.C
Normal file
@ -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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user