ENH: control local boundary consistency checks from FieldBase settings

- avoids multiple definitions for various template specializations
This commit is contained in:
Mark Olesen
2025-05-19 14:53:00 +02:00
committed by Mattijs Janssens
parent 4668d0e886
commit a9b59ad27e
18 changed files with 127 additions and 636 deletions

View File

@ -250,8 +250,8 @@ OptimisationSwitches
experimentalDdtCorr 0; experimentalDdtCorr 0;
//- Enable enforced consistency of constraint bcs after 'local' operations. //- Enable enforced consistency of constraint bcs after 'local' operations.
// Default is on. Set to 0/false to revert to <v2306 behaviour // Default is on. Set to 0 (ie, false) to revert to <v2306 behaviour
//localConsistency 0; //localBoundaryConsistency 0;
//- Since v2412 wall distance is calculated on a combined patch, created //- Since v2412 wall distance is calculated on a combined patch, created
// from all the individual wall patches. Set to 0/false to revert to // from all the individual wall patches. Set to 0/false to revert to

View File

@ -35,6 +35,7 @@ License
#include "IOdictionary.H" #include "IOdictionary.H"
#include "fileOperation.H" #include "fileOperation.H"
#include "fstreamPointer.H" #include "fstreamPointer.H"
#include "Field.H" // Ugly handling of localBoundaryConsistency switches
#include <iomanip> #include <iomanip>
@ -141,6 +142,9 @@ void Foam::Time::readDict()
<< controlDict_.name() << nl; << controlDict_.name() << nl;
debug::optimisationObjects().setValues(*localDict, true); debug::optimisationObjects().setValues(*localDict, true);
// Ugly handling of localBoundaryConsistency switches
FieldBase::warnLocalBoundaryConsistencyCompat(*localDict);
} }

View File

@ -55,10 +55,7 @@ bool Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::checkConsistency
<< endl; << endl;
} }
auto& bfld = const_cast<GeometricBoundaryField<Type, PatchField, GeoMesh>&> auto& bfld = this->constCast();
(
*this
);
// Store old value // Store old value
@ -719,7 +716,7 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::evaluateLocal
{ {
// DebugInFunction << nl; // DebugInFunction << nl;
if (!localConsistency) if (!FieldBase::localBoundaryConsistency())
{ {
return; return;
} }

View File

@ -100,12 +100,6 @@ public:
//- Enable debug //- Enable debug
static int debug; static int debug;
//- User-defined tolerance (for consistency checks)
static scalar tolerance;
//- Enable local consistency
static int localConsistency;
// Constructors // Constructors

View File

@ -78,66 +78,6 @@ defineTemplateDebugSwitchWithName
0 0
); );
// Local-ops consistency enforcing
template<> int pointScalarField::Boundary::localConsistency
(
debug::optimisationSwitch("localConsistency", 1)
);
registerOptSwitch
(
"localConsistency",
int,
Foam::pointScalarField::Boundary::localConsistency
);
template<> int pointVectorField::Boundary::localConsistency
(
debug::optimisationSwitch("localConsistency", 1)
);
registerOptSwitch
(
"pointVectorField::Boundary::localConsistency",
int,
Foam::pointVectorField::Boundary::localConsistency
);
template<> int pointSphericalTensorField::Boundary::localConsistency
(
debug::optimisationSwitch("localConsistency", 1)
);
registerOptSwitch
(
"pointSphericalTensorField::Boundary::localConsistency",
int,
Foam::pointSphericalTensorField::Boundary::localConsistency
);
template<> int pointSymmTensorField::Boundary::localConsistency
(
debug::optimisationSwitch("localConsistency", 1)
);
registerOptSwitch
(
"pointSymmTensorField::Boundary::localConsistency",
int,
Foam::pointSymmTensorField::Boundary::localConsistency
);
template<> int pointTensorField::Boundary::localConsistency
(
debug::optimisationSwitch("localConsistency", 1)
);
registerOptSwitch
(
"pointTensorField::Boundary::localConsistency",
int,
Foam::pointTensorField::Boundary::localConsistency
);
} // End namespace Foam } // End namespace Foam

View File

@ -47,6 +47,7 @@ License
#include "stringListOps.H" #include "stringListOps.H"
#include "fileOperation.H" #include "fileOperation.H"
#include "fileOperationInitialise.H" #include "fileOperationInitialise.H"
#include "Field.H" // Ugly handling of localBoundaryConsistency switches
#include <cctype> #include <cctype>
@ -2231,6 +2232,12 @@ void Foam::argList::parse
Info<< " user-supplied system call operations" << nl Info<< " user-supplied system call operations" << nl
<< nl; << nl;
IOobject::writeDivider(Info); IOobject::writeDivider(Info);
// Ugly handling of localBoundaryConsistency switches
FieldBase::warnLocalBoundaryConsistencyCompat
(
debug::optimisationSwitches()
);
} }
} }
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2018-2023 OpenCFD Ltd. Copyright (C) 2018-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -79,127 +79,6 @@ defineTemplateDebugSwitchWithName
0 0
); );
template<> scalar areaScalarField::Boundary::tolerance
(
debug::floatOptimisationSwitch("areaScalarField::Boundary::tolerance", 0)
);
registerOptSwitch
(
"areaScalarField::Boundary::tolerance",
scalar,
Foam::areaScalarField::Boundary::tolerance
);
template<> scalar areaVectorField::Boundary::tolerance
(
debug::floatOptimisationSwitch("areaVectorField::Boundary::tolerance", 0)
);
registerOptSwitch
(
"areaVectorField::Boundary::tolerance",
scalar,
Foam::areaVectorField::Boundary::tolerance
);
template<> scalar areaSphericalTensorField::Boundary::tolerance
(
debug::floatOptimisationSwitch
(
"areaSphericalTensorField::Boundary::tolerance",
0
)
);
registerOptSwitch
(
"areaSphericalTensorField::Boundary::tolerance",
scalar,
Foam::areaSphericalTensorField::Boundary::tolerance
);
template<> scalar areaSymmTensorField::Boundary::tolerance
(
debug::floatOptimisationSwitch
(
"areaSymmTensorField::Boundary::tolerance",
0
)
);
registerOptSwitch
(
"areaSymmTensorField::Boundary::tolerance",
scalar,
Foam::areaSymmTensorField::Boundary::tolerance
);
template<> scalar areaTensorField::Boundary::tolerance
(
debug::floatOptimisationSwitch("areaTensorField::Boundary::tolerance", 0)
);
registerOptSwitch
(
"areaTensorField::Boundary::tolerance",
scalar,
Foam::areaTensorField::Boundary::tolerance
);
// Local-ops consistency enforcing
template<> int areaScalarField::Boundary::localConsistency
(
debug::optimisationSwitch("localConsistency", 1)
);
registerOptSwitch
(
"areaScalarField::Boundary::localConsistency",
int,
Foam::areaScalarField::Boundary::localConsistency
);
template<> int areaVectorField::Boundary::localConsistency
(
debug::optimisationSwitch("localConsistency", 1)
);
registerOptSwitch
(
"areaVectorField::Boundary::localConsistency",
int,
Foam::areaVectorField::Boundary::localConsistency
);
template<> int areaSphericalTensorField::Boundary::localConsistency
(
debug::optimisationSwitch("localConsistency", 1)
);
registerOptSwitch
(
"areaSphericalTensorField::Boundary::localConsistency",
int,
Foam::areaSphericalTensorField::Boundary::localConsistency
);
template<> int areaSymmTensorField::Boundary::localConsistency
(
debug::optimisationSwitch("localConsistency", 1)
);
registerOptSwitch
(
"areaSymmTensorField::Boundary::localConsistency",
int,
Foam::areaSymmTensorField::Boundary::localConsistency
);
template<> int areaTensorField::Boundary::localConsistency
(
debug::optimisationSwitch("localConsistency", 1)
);
registerOptSwitch
(
"areaTensorField::Boundary::localConsistency",
int,
Foam::areaTensorField::Boundary::localConsistency
);
} // End namespace Foam } // End namespace Foam
@ -230,56 +109,26 @@ void GeometricField<scalar, faPatchField, areaMesh>::replace
*this == gsf; *this == gsf;
} }
template<>
bool GeometricBoundaryField<scalar, faPatchField, areaMesh>::check() const #undef fieldChecks
{ #define fieldChecks(Type) \
return checkConsistency<coupledFaPatchField<scalar>> template<> \
( bool GeometricBoundaryField<Type, faPatchField, areaMesh>::check() const \
Foam::areaScalarField::Boundary::tolerance, { \
!(debug&4) // make into warning if debug&4 return checkConsistency<coupledFaPatchField<Type>> \
); ( \
FieldBase::localBoundaryTolerance_, \
!(debug&4) /* make into warning if debug&4 */ \
); \
} }
template<> fieldChecks(scalar);
bool GeometricBoundaryField<vector, faPatchField, areaMesh>::check() const fieldChecks(vector);
{ fieldChecks(sphericalTensor);
return checkConsistency<coupledFaPatchField<vector>> fieldChecks(symmTensor);
( fieldChecks(tensor);
Foam::areaScalarField::Boundary::tolerance,
!(debug&4) // make into warning if debug&4
);
}
template<> #undef fieldChecks
bool GeometricBoundaryField<sphericalTensor, faPatchField, areaMesh>::check
() const
{
return checkConsistency<coupledFaPatchField<sphericalTensor>>
(
Foam::areaScalarField::Boundary::tolerance,
!(debug&4) // make into warning if debug&4
);
}
template<>
bool GeometricBoundaryField<symmTensor, faPatchField, areaMesh>::check() const
{
return checkConsistency<coupledFaPatchField<symmTensor>>
(
Foam::areaScalarField::Boundary::tolerance,
!(debug&4) // make into warning if debug&4
);
}
template<>
bool GeometricBoundaryField<tensor, faPatchField, areaMesh>::check() const
{
return checkConsistency<coupledFaPatchField<tensor>>
(
Foam::areaScalarField::Boundary::tolerance,
!(debug&4) // make into warning if debug&4
);
}
} // End namespace Foam } // End namespace Foam

View File

@ -69,17 +69,39 @@ void GeometricField<scalar, faPatchField, areaMesh>::replace
const GeometricField<scalar, faPatchField, areaMesh>& sf const GeometricField<scalar, faPatchField, areaMesh>& sf
); );
// Local consistency checks
//
// template<class Type>
// bool GeometricBoundaryField<Type, faPatchField, areaMesh>::check() const
// {
// return checkConsistency<coupledFaPatchField<Type>>
// (
// FieldBase::localBoundaryTolerance_,
// !(debug&4) // make into warning if debug&4
// );
// }
template<> template<>
bool GeometricBoundaryField<scalar, faPatchField, areaMesh>::check() const; bool GeometricBoundaryField<scalar, faPatchField, areaMesh>::
check() const;
template<> template<>
bool GeometricBoundaryField<vector, faPatchField, areaMesh>::check() const; bool GeometricBoundaryField<vector, faPatchField, areaMesh>::
check() const;
template<> template<>
bool GeometricBoundaryField<sphericalTensor, faPatchField, areaMesh>::check bool GeometricBoundaryField<sphericalTensor, faPatchField, areaMesh>::
() const; check() const;
template<> template<>
bool GeometricBoundaryField<symmTensor, faPatchField, areaMesh>::check() const; bool GeometricBoundaryField<symmTensor, faPatchField, areaMesh>::
check() const;
template<> template<>
bool GeometricBoundaryField<tensor, faPatchField, areaMesh>::check() const; bool GeometricBoundaryField<tensor, faPatchField, areaMesh>::
check() const;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -77,84 +77,6 @@ defineTemplateDebugSwitchWithName
0 0
); );
template<> scalar edgeScalarField::Boundary::tolerance
(
debug::floatOptimisationSwitch("tolerance", 0)
);
template<> scalar edgeVectorField::Boundary::tolerance
(
debug::floatOptimisationSwitch("tolerance", 0)
);
template<> scalar edgeSphericalTensorField::Boundary::tolerance
(
debug::floatOptimisationSwitch("tolerance", 0)
);
template<> scalar edgeSymmTensorField::Boundary::tolerance
(
debug::floatOptimisationSwitch("tolerance", 0)
);
template<> scalar edgeTensorField::Boundary::tolerance
(
debug::floatOptimisationSwitch("tolerance", 0)
);
// Local-ops consistency enforcing
template<> int edgeScalarField::Boundary::localConsistency
(
debug::optimisationSwitch("localConsistency", 1)
);
registerOptSwitch
(
"edgeScalarField::Boundary::localConsistency",
int,
Foam::edgeScalarField::Boundary::localConsistency
);
template<> int edgeVectorField::Boundary::localConsistency
(
debug::optimisationSwitch("localConsistency", 1)
);
registerOptSwitch
(
"edgeVectorField::Boundary::localConsistency",
int,
Foam::edgeVectorField::Boundary::localConsistency
);
template<> int edgeSphericalTensorField::Boundary::localConsistency
(
debug::optimisationSwitch("localConsistency", 1)
);
registerOptSwitch
(
"edgeSphericalTensorField::Boundary::localConsistency",
int,
Foam::edgeSphericalTensorField::Boundary::localConsistency
);
template<> int edgeSymmTensorField::Boundary::localConsistency
(
debug::optimisationSwitch("localConsistency", 1)
);
registerOptSwitch
(
"edgeSymmTensorField::Boundary::localConsistency",
int,
Foam::edgeSymmTensorField::Boundary::localConsistency
);
template<> int edgeTensorField::Boundary::localConsistency
(
debug::optimisationSwitch("localConsistency", 1)
);
registerOptSwitch
(
"edgeTensorField::Boundary::localConsistency",
int,
Foam::edgeTensorField::Boundary::localConsistency
);
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -169,8 +169,7 @@ Foam::vectorField Foam::SRF::SRFModel::velocity
Foam::tmp<Foam::volVectorField> Foam::SRF::SRFModel::U() const Foam::tmp<Foam::volVectorField> Foam::SRF::SRFModel::U() const
{ {
const int oldLocal = volVectorField::Boundary::localConsistency; const auto oldConsistency = FieldBase::localBoundaryConsistency(0);
volVectorField::Boundary::localConsistency = 0;
tmp<volVectorField> relPos(mesh_.C() - origin_); tmp<volVectorField> relPos(mesh_.C() - origin_);
auto tU = volVectorField::New auto tU = volVectorField::New
@ -181,7 +180,7 @@ Foam::tmp<Foam::volVectorField> Foam::SRF::SRFModel::U() const
omega_ ^ (relPos() - axis_*(axis_ & relPos())) omega_ ^ (relPos() - axis_*(axis_ & relPos()))
) )
); );
volVectorField::Boundary::localConsistency = oldLocal; FieldBase::localBoundaryConsistency(oldConsistency);
return tU; return tU;
} }

View File

@ -5,10 +5,10 @@
? g & (cmptMag(g.value())/mag(g.value()))*hRef ? g & (cmptMag(g.value())/mag(g.value()))*hRef
: dimensionedScalar("ghRef", g.dimensions()*dimLength, 0) : dimensionedScalar("ghRef", g.dimensions()*dimLength, 0)
); );
const int oldLocal = volVectorField::Boundary::localConsistency;
volVectorField::Boundary::localConsistency = 0; const auto oldConsistency = FieldBase::localBoundaryConsistency(0);
volScalarField gh("gh", (g & mesh.C()) - ghRef); volScalarField gh("gh", (g & mesh.C()) - ghRef);
surfaceScalarField ghf("ghf", (g & mesh.Cf()) - ghRef); surfaceScalarField ghf("ghf", (g & mesh.Cf()) - ghRef);
volVectorField::Boundary::localConsistency = oldLocal; FieldBase::localBoundaryConsistency(oldConsistency);

View File

@ -114,16 +114,11 @@ Foam::cyclicACMIFvPatchField<Type>::cyclicACMIFvPatchField
// old logic (ultimately calls the fully self contained // old logic (ultimately calls the fully self contained
// patchNeighbourField) // patchNeighbourField)
int& consistency = const auto oldConsistency = FieldBase::localBoundaryConsistency(0);
GeometricField<Type, fvPatchField, volMesh>::
Boundary::localConsistency;
const int oldConsistency = consistency;
consistency = 0;
this->evaluate(Pstream::commsTypes::buffered); this->evaluate(Pstream::commsTypes::buffered);
consistency = oldConsistency; FieldBase::localBoundaryConsistency(oldConsistency);
} }
} }
@ -331,11 +326,7 @@ template<class Type>
bool Foam::cyclicACMIFvPatchField<Type>::cacheNeighbourField() bool Foam::cyclicACMIFvPatchField<Type>::cacheNeighbourField()
{ {
/* /*
return return (FieldBase::localBoundaryConsistency() != 0);
(
GeometricField<Type, fvPatchField, volMesh>::Boundary::localConsistency
!= 0
);
*/ */
return false; return false;
} }

View File

@ -97,16 +97,11 @@ Foam::cyclicAMIFvPatchField<Type>::cyclicAMIFvPatchField
// old logic (ultimately calls the fully self contained // old logic (ultimately calls the fully self contained
// patchNeighbourField) // patchNeighbourField)
int& consistency = const auto oldConsistency = FieldBase::localBoundaryConsistency(0);
GeometricField<Type, fvPatchField, volMesh>::
Boundary::localConsistency;
const int oldConsistency = consistency;
consistency = 0;
this->evaluate(UPstream::commsTypes::nonBlocking); this->evaluate(UPstream::commsTypes::nonBlocking);
consistency = oldConsistency; FieldBase::localBoundaryConsistency(oldConsistency);
} }
else else
{ {
@ -326,11 +321,7 @@ Foam::cyclicAMIFvPatchField<Type>::patchNeighbourField
template<class Type> template<class Type>
bool Foam::cyclicAMIFvPatchField<Type>::cacheNeighbourField() bool Foam::cyclicAMIFvPatchField<Type>::cacheNeighbourField()
{ {
return return (FieldBase::localBoundaryConsistency() != 0);
(
GeometricField<Type, fvPatchField, volMesh>::Boundary::localConsistency
!= 0
);
} }

View File

@ -77,94 +77,6 @@ defineTemplateDebugSwitchWithName
0 0
); );
template<> scalar surfaceScalarField::Boundary::tolerance
(
debug::floatOptimisationSwitch("surfaceScalarField::Boundary::tolerance", 0)
);
template<> scalar surfaceVectorField::Boundary::tolerance
(
debug::floatOptimisationSwitch("surfaceVectorField::Boundary::tolerance", 0)
);
template<> scalar surfaceSphericalTensorField::Boundary::tolerance
(
debug::floatOptimisationSwitch
(
"surfaceSphericalTensorField::Boundary::tolerance",
0
)
);
template<> scalar surfaceSymmTensorField::Boundary::tolerance
(
debug::floatOptimisationSwitch
(
"surfaceSymmTensorField::Boundary::tolerance",
0
)
);
template<> scalar surfaceTensorField::Boundary::tolerance
(
debug::floatOptimisationSwitch("surfaceTensorField::Boundary::tolerance", 0)
);
// Local-ops consistency enforcing
template<> int surfaceScalarField::Boundary::localConsistency
(
debug::optimisationSwitch("localConsistency", 1)
);
registerOptSwitch
(
"surfaceScalarField::Boundary::localConsistency",
int,
Foam::surfaceScalarField::Boundary::localConsistency
);
template<> int surfaceVectorField::Boundary::localConsistency
(
debug::optimisationSwitch("localConsistency", 1)
);
registerOptSwitch
(
"surfaceVectorField::Boundary::localConsistency",
int,
Foam::surfaceVectorField::Boundary::localConsistency
);
template<> int surfaceSphericalTensorField::Boundary::localConsistency
(
debug::optimisationSwitch("localConsistency", 1)
);
registerOptSwitch
(
"surfaceSphericalTensorField::Boundary::localConsistency",
int,
Foam::surfaceSphericalTensorField::Boundary::localConsistency
);
template<> int surfaceSymmTensorField::Boundary::localConsistency
(
debug::optimisationSwitch("localConsistency", 1)
);
registerOptSwitch
(
"surfaceSymmTensorField::Boundary::localConsistency",
int,
Foam::surfaceSymmTensorField::Boundary::localConsistency
);
template<> int surfaceTensorField::Boundary::localConsistency
(
debug::optimisationSwitch("localConsistency", 1)
);
registerOptSwitch
(
"surfaceTensorField::Boundary::localConsistency",
int,
Foam::surfaceTensorField::Boundary::localConsistency
);
} // End namespace Foam } // End namespace Foam

View File

@ -78,131 +78,6 @@ defineTemplateDebugSwitchWithName
0 0
); );
// Tolerance optimisation switch
template<> scalar volScalarField::Boundary::tolerance
(
debug::floatOptimisationSwitch("volScalarField::Boundary::tolerance", 0)
);
registerOptSwitch
(
"volScalarField::Boundary::tolerance",
scalar,
Foam::volScalarField::Boundary::tolerance
);
template<> scalar volVectorField::Boundary::tolerance
(
debug::floatOptimisationSwitch("volScalarField::Boundary::tolerance", 0)
);
registerOptSwitch
(
"volVectorField::Boundary::tolerance",
scalar,
Foam::volVectorField::Boundary::tolerance
);
template<> scalar volSphericalTensorField::Boundary::tolerance
(
debug::floatOptimisationSwitch
(
"volSphericalTensorField::Boundary::tolerance",
0
)
);
registerOptSwitch
(
"volSphericalTensorField::Boundary::tolerance",
scalar,
Foam::volSphericalTensorField::Boundary::tolerance
);
template<> scalar volSymmTensorField::Boundary::tolerance
(
debug::floatOptimisationSwitch
(
"volSymmTensorField::Boundary::tolerance",
0
)
);
registerOptSwitch
(
"volSymmTensorField::Boundary::tolerance",
scalar,
Foam::volSymmTensorField::Boundary::tolerance
);
template<> scalar volTensorField::Boundary::tolerance
(
debug::floatOptimisationSwitch("volTensorField::Boundary::tolerance", 0)
);
registerOptSwitch
(
"volTensorField::Boundary::tolerance",
scalar,
Foam::volTensorField::Boundary::tolerance
);
// Local-ops consistency enforcing
template<> int volScalarField::Boundary::localConsistency
(
debug::optimisationSwitch("localConsistency", 1)
);
registerOptSwitch
(
"volScalarField::Boundary::localConsistency",
int,
Foam::volScalarField::Boundary::localConsistency
);
template<> int volVectorField::Boundary::localConsistency
(
debug::optimisationSwitch("localConsistency", 1)
);
registerOptSwitch
(
"volVectorField::Boundary::localConsistency",
int,
Foam::volVectorField::Boundary::localConsistency
);
template<> int volSphericalTensorField::Boundary::localConsistency
(
debug::optimisationSwitch("localConsistency", 1)
);
registerOptSwitch
(
"volSphericalTensorField::Boundary::localConsistency",
int,
Foam::volSphericalTensorField::Boundary::localConsistency
);
template<> int volSymmTensorField::Boundary::localConsistency
(
debug::optimisationSwitch("localConsistency", 1)
);
registerOptSwitch
(
"volSymmTensorField::Boundary::localConsistency",
int,
Foam::volSymmTensorField::Boundary::localConsistency
);
template<> int volTensorField::Boundary::localConsistency
(
debug::optimisationSwitch("localConsistency", 1)
);
registerOptSwitch
(
"volTensorField::Boundary::localConsistency",
int,
Foam::volTensorField::Boundary::localConsistency
);
} // End namespace Foam } // End namespace Foam
@ -235,58 +110,25 @@ void GeometricField<scalar, fvPatchField, volMesh>::replace
} }
template<> #undef fieldChecks
bool GeometricBoundaryField<scalar, fvPatchField, volMesh>::check() const #define fieldChecks(Type) \
{ template<> \
return checkConsistency<coupledFvPatchField<scalar>> bool GeometricBoundaryField<Type, fvPatchField, volMesh>::check() const \
( { \
Foam::volScalarField::Boundary::tolerance, return checkConsistency<coupledFvPatchField<Type>> \
!(debug&4) // make into warning if debug&4 ( \
); FieldBase::localBoundaryTolerance_, \
!(debug&4) /* make into warning if debug&4 */ \
); \
} }
template<> fieldChecks(scalar);
bool GeometricBoundaryField<vector, fvPatchField, volMesh>::check() const fieldChecks(vector);
{ fieldChecks(sphericalTensor);
return checkConsistency<coupledFvPatchField<vector>> fieldChecks(symmTensor);
( fieldChecks(tensor);
Foam::volScalarField::Boundary::tolerance,
!(debug&4) // make into warning if debug&4
);
}
template<> #undef fieldChecks
bool GeometricBoundaryField<sphericalTensor, fvPatchField, volMesh>::check
() const
{
return checkConsistency<coupledFvPatchField<sphericalTensor>>
(
Foam::volScalarField::Boundary::tolerance,
!(debug&4) // make into warning if debug&4
);
}
template<>
bool GeometricBoundaryField<symmTensor, fvPatchField, volMesh>::check
() const
{
return checkConsistency<coupledFvPatchField<symmTensor>>
(
Foam::volScalarField::Boundary::tolerance,
!(debug&4) // make into warning if debug&4
);
}
template<>
bool GeometricBoundaryField<tensor, fvPatchField, volMesh>::check
() const
{
return checkConsistency<coupledFvPatchField<tensor>>
(
Foam::volScalarField::Boundary::tolerance,
!(debug&4) // make into warning if debug&4
);
}
} // End namespace Foam } // End namespace Foam

View File

@ -64,17 +64,39 @@ void GeometricField<scalar, fvPatchField, volMesh>::replace
const GeometricField<scalar, fvPatchField, volMesh>& sf const GeometricField<scalar, fvPatchField, volMesh>& sf
); );
// Local consistency checks
//
// template<class Type>
// bool GeometricBoundaryField<Type, fvPatchField, volMesh>::check() const
// {
// return checkConsistency<coupledFvPatchField<Type>>
// (
// FieldBase::localBoundaryTolerance_,
// !(debug&4) // make into warning if debug&4
// );
// }
template<> template<>
bool GeometricBoundaryField<scalar, fvPatchField, volMesh>::check() const; bool GeometricBoundaryField<scalar, fvPatchField, volMesh>::
check() const;
template<> template<>
bool GeometricBoundaryField<vector, fvPatchField, volMesh>::check() const; bool GeometricBoundaryField<vector, fvPatchField, volMesh>::
check() const;
template<> template<>
bool GeometricBoundaryField<sphericalTensor, fvPatchField, volMesh>::check bool GeometricBoundaryField<sphericalTensor, fvPatchField, volMesh>::
() const; check() const;
template<> template<>
bool GeometricBoundaryField<symmTensor, fvPatchField, volMesh>::check() const; bool GeometricBoundaryField<symmTensor, fvPatchField, volMesh>::
check() const;
template<> template<>
bool GeometricBoundaryField<tensor, fvPatchField, volMesh>::check() const; bool GeometricBoundaryField<tensor, fvPatchField, volMesh>::
check() const;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -197,8 +197,7 @@ void Foam::functionObjects::pressure::addHydrostaticContribution
(g_ & (cmptMag(g_.value())/mag(g_.value())))*hRef_ (g_ & (cmptMag(g_.value())/mag(g_.value())))*hRef_
); );
const int oldLocal = volScalarField::Boundary::localConsistency; const auto oldConsistency = FieldBase::localBoundaryConsistency(0);
volScalarField::Boundary::localConsistency = 0;
tmp<volScalarField> rgh = rhoScale(p, (g_ & mesh_.C()) - ghRef); tmp<volScalarField> rgh = rhoScale(p, (g_ & mesh_.C()) - ghRef);
@ -218,7 +217,7 @@ void Foam::functionObjects::pressure::addHydrostaticContribution
{} {}
} }
volScalarField::Boundary::localConsistency = oldLocal; FieldBase::localBoundaryConsistency(oldConsistency);
} }

View File

@ -234,8 +234,7 @@ bool Foam::functionObjects::setFlow::execute()
} }
case modeType::ROTATION: case modeType::ROTATION:
{ {
const int oldLocal = volVectorField::Boundary::localConsistency; const auto oldConsistency = FieldBase::localBoundaryConsistency(0);
volVectorField::Boundary::localConsistency = 0;
const volVectorField& C = mesh_.C(); const volVectorField& C = mesh_.C();
const volVectorField d const volVectorField d
@ -269,7 +268,8 @@ bool Foam::functionObjects::setFlow::execute()
} }
U = U & R_; U = U & R_;
volVectorField::Boundary::localConsistency = oldLocal;
FieldBase::localBoundaryConsistency(oldConsistency);
U.correctBoundaryConditions(); U.correctBoundaryConditions();
setPhi(U); setPhi(U);
@ -279,8 +279,7 @@ bool Foam::functionObjects::setFlow::execute()
{ {
const scalar pi = Foam::constant::mathematical::pi; const scalar pi = Foam::constant::mathematical::pi;
const int oldLocal = volVectorField::Boundary::localConsistency; const auto oldConsistency = FieldBase::localBoundaryConsistency(0);
volVectorField::Boundary::localConsistency = 0;
const volVectorField& C = mesh_.C(); const volVectorField& C = mesh_.C();
@ -298,7 +297,8 @@ bool Foam::functionObjects::setFlow::execute()
Uc.replace(vector::Z, sin(2*pi*x)*sqr(sin(pi*z))); Uc.replace(vector::Z, sin(2*pi*x)*sqr(sin(pi*z)));
U = U & R_; U = U & R_;
volVectorField::Boundary::localConsistency = oldLocal;
FieldBase::localBoundaryConsistency(oldConsistency);
U.correctBoundaryConditions(); U.correctBoundaryConditions();
// Calculating phi // Calculating phi
@ -343,8 +343,7 @@ bool Foam::functionObjects::setFlow::execute()
{ {
const scalar pi = Foam::constant::mathematical::pi; const scalar pi = Foam::constant::mathematical::pi;
const int oldLocal = volVectorField::Boundary::localConsistency; const auto oldConsistency = FieldBase::localBoundaryConsistency(0);
volVectorField::Boundary::localConsistency = 0;
const volVectorField& C = mesh_.C(); const volVectorField& C = mesh_.C();
@ -363,7 +362,8 @@ bool Foam::functionObjects::setFlow::execute()
Uc.replace(vector::Z, -sin(2*pi*x)*sin(2*pi*y)*sqr(sin(pi*z))); Uc.replace(vector::Z, -sin(2*pi*x)*sin(2*pi*y)*sqr(sin(pi*z)));
U = U & R_; U = U & R_;
volVectorField::Boundary::localConsistency = oldLocal;
FieldBase::localBoundaryConsistency(oldConsistency);
U.correctBoundaryConditions(); U.correctBoundaryConditions();
// Calculating phi // Calculating phi