ENH: consistent UniformDimensionedField naming
- construct from components, or use word::null to ensure consistent avoid naming between IOobject vs dimensioned type. - support construct with parameter ordering as per DimensionedField ENH: instantiate a uniformDimensionedLabelField - eg, for registering standalone integer counters
This commit is contained in:
parent
1d39cdaa17
commit
5042d1296f
@ -108,7 +108,7 @@ forAll(fluidRegions, i)
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
dimensionedScalar("hRef", dimLength, Zero) // uses name
|
||||
dimensionedScalar(word::null, dimLength, Zero)
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -221,7 +221,7 @@ forAll(fluidRegions, i)
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
dimensionedScalar("hRef", dimLength, Zero)
|
||||
dimensionedScalar(word::null, dimLength, Zero)
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -13,11 +13,11 @@ forAll(cumulativeContErrIO, i)
|
||||
"cumulativeContErr",
|
||||
runTime.timeName(),
|
||||
"uniform",
|
||||
mesh,
|
||||
mesh.thisDb(),
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
dimensionedScalar(dimless, Zero)
|
||||
dimensionedScalar(word::null, dimless, Zero)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ forAll(fluidRegions, i)
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
dimensionedScalar("hRef", dimLength, Zero) // uses name
|
||||
dimensionedScalar(word::null, dimLength, Zero)
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -13,11 +13,11 @@ forAll(cumulativeContErrIO, i)
|
||||
"cumulativeContErr",
|
||||
runTime.timeName(),
|
||||
"uniform",
|
||||
mesh,
|
||||
mesh.thisDb(),
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
dimensionedScalar(dimless, Zero)
|
||||
dimensionedScalar(word::null, dimless, Zero)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -66,6 +66,22 @@ Foam::UniformDimensionedField<Type>::UniformDimensionedField
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::UniformDimensionedField<Type>::UniformDimensionedField
|
||||
(
|
||||
const IOobject& io,
|
||||
const Type& val,
|
||||
const dimensionSet& dims
|
||||
)
|
||||
:
|
||||
regIOobject(io),
|
||||
dimensioned<Type>(regIOobject::name(), dims, val)
|
||||
{
|
||||
// Read value
|
||||
readHeaderOk(IOstreamOption::BINARY, typeName);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::UniformDimensionedField<Type>::UniformDimensionedField
|
||||
(
|
||||
|
@ -79,6 +79,7 @@ public:
|
||||
|
||||
//- Construct from components. Either reads or uses supplied value.
|
||||
// The name of the IOobject defines the name of the field.
|
||||
// Parameter ordering as per dimensioned\<Type\>
|
||||
UniformDimensionedField
|
||||
(
|
||||
const IOobject& io,
|
||||
@ -86,6 +87,16 @@ public:
|
||||
const Type& val
|
||||
);
|
||||
|
||||
//- Construct from components. Either reads or uses supplied value.
|
||||
// The name of the IOobject defines the name of the field.
|
||||
// Parameter ordering as per DimensionedField\<Type\>
|
||||
UniformDimensionedField
|
||||
(
|
||||
const IOobject& io,
|
||||
const Type& val,
|
||||
const dimensionSet& dims
|
||||
);
|
||||
|
||||
//- Construct as copy
|
||||
UniformDimensionedField(const UniformDimensionedField<Type>&);
|
||||
|
||||
@ -99,17 +110,16 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Name function provided to resolve the ambiguity between the
|
||||
//- name functions in regIOobject and dimensioned<Type>
|
||||
//- Use name from dimensioned\<Type\>, not from regIOobject
|
||||
virtual const word& name() const
|
||||
{
|
||||
return dimensioned<Type>::name();
|
||||
}
|
||||
|
||||
//- ReadData function required for regIOobject read operation
|
||||
//- The readData method required for regIOobject read operation
|
||||
virtual bool readData(Istream&);
|
||||
|
||||
//- WriteData function required for regIOobject write operation
|
||||
//- The writeData method required for regIOobject write operation
|
||||
bool writeData(Ostream&) const;
|
||||
|
||||
//- Is object global
|
||||
@ -128,10 +138,10 @@ public:
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Assign name, dimensions and value.
|
||||
//- Assign name, dimensions and value of the dimensioned\<Type\>
|
||||
void operator=(const UniformDimensionedField<Type>& rhs);
|
||||
|
||||
//- Assign name, dimensions and value.
|
||||
//- Assign name, dimensions and value to the dimensioned\<Type\>
|
||||
void operator=(const dimensioned<Type>& rhs);
|
||||
|
||||
//- Return value
|
||||
|
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -34,6 +35,7 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTemplateTypeNameAndDebug(uniformDimensionedLabelField, 0);
|
||||
defineTemplateTypeNameAndDebug(uniformDimensionedScalarField, 0);
|
||||
defineTemplateTypeNameAndDebug(uniformDimensionedVectorField, 0);
|
||||
defineTemplateTypeNameAndDebug(uniformDimensionedSphericalTensorField, 0);
|
||||
|
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
Copyright (C) 2022-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -48,6 +48,10 @@ template<class Type> class UniformDimensionedField;
|
||||
|
||||
// Typedefs
|
||||
|
||||
typedef
|
||||
UniformDimensionedField<label>
|
||||
uniformDimensionedLabelField;
|
||||
|
||||
typedef
|
||||
UniformDimensionedField<scalar>
|
||||
uniformDimensionedScalarField;
|
||||
@ -71,6 +75,11 @@ typedef
|
||||
|
||||
// Global file status
|
||||
|
||||
template<>
|
||||
inline bool typeGlobal<uniformDimensionedLabelField>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
template<>
|
||||
inline bool typeGlobal<uniformDimensionedScalarField>()
|
||||
{
|
||||
|
@ -271,11 +271,7 @@ void Foam::hexRef8Data::sync(const IOobject& io)
|
||||
rio.readOpt(IOobject::NO_READ);
|
||||
level0EdgePtr_.reset
|
||||
(
|
||||
new uniformDimensionedScalarField
|
||||
(
|
||||
rio,
|
||||
dimensionedScalar(rio.name(), dimLength, masterLen)
|
||||
)
|
||||
new uniformDimensionedScalarField(rio, dimLength, masterLen)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -44,11 +44,11 @@ uniformDimensionedScalarField cumulativeContErrIO
|
||||
"cumulativeContErr",
|
||||
runTime.timeName(),
|
||||
"uniform",
|
||||
mesh,
|
||||
mesh.thisDb(),
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
dimensionedScalar(dimless, Zero)
|
||||
dimensionedScalar(word::null, dimless, Zero)
|
||||
);
|
||||
scalar& cumulativeContErr = cumulativeContErrIO.value();
|
||||
|
||||
|
@ -5,9 +5,9 @@
|
||||
(
|
||||
"hRef",
|
||||
runTime.constant(),
|
||||
mesh,
|
||||
mesh.thisDb(),
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
dimensionedScalar(dimLength, Zero)
|
||||
dimensionedScalar(word::null, dimLength, Zero)
|
||||
);
|
||||
|
@ -5,9 +5,9 @@
|
||||
(
|
||||
"pRef",
|
||||
runTime.constant(),
|
||||
mesh,
|
||||
mesh.thisDb(),
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
dimensionedScalar(dimPressure, Zero)
|
||||
dimensionedScalar(word::null, dimPressure, Zero)
|
||||
);
|
||||
|
@ -203,19 +203,21 @@ Foam::mappedPatchBase::updateSampleMeshTime() const
|
||||
{
|
||||
const auto& mesh = sampleMesh();
|
||||
|
||||
updateSampleMeshTimePtr_ =
|
||||
autoPtr<uniformDimensionedScalarField>::New
|
||||
updateSampleMeshTimePtr_.reset
|
||||
(
|
||||
new uniformDimensionedScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"updateSampleMeshTime",
|
||||
mesh.pointsInstance(),
|
||||
mesh,
|
||||
mesh.thisDb(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
)
|
||||
);
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return updateSampleMeshTimePtr_();
|
||||
@ -229,19 +231,21 @@ Foam::mappedPatchBase::updateMeshTime() const
|
||||
{
|
||||
const auto& mesh = patch_.boundaryMesh().mesh();
|
||||
|
||||
updateMeshTimePtr_ =
|
||||
autoPtr<uniformDimensionedScalarField>::New
|
||||
updateMeshTimePtr_.reset
|
||||
(
|
||||
new uniformDimensionedScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"updateMeshTime",
|
||||
mesh.pointsInstance(),
|
||||
mesh,
|
||||
mesh.thisDb(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
)
|
||||
);
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return updateMeshTimePtr_();
|
||||
|
Loading…
Reference in New Issue
Block a user