Merge branch 'master' of github.com-OpenFOAM:OpenFOAM/OpenFOAM-dev

This commit is contained in:
Henry Weller
2023-12-21 16:31:57 +00:00
7 changed files with 115 additions and 35 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -90,7 +90,7 @@ void Foam::vtkWriteOps::write
os.write os.write
( (
reinterpret_cast<char*>(fField.begin()), reinterpret_cast<char*>(fField.begin()),
fField.size()*sizeof(float) fField.size()*sizeof(floatScalar)
); );
os << std::endl; os << std::endl;
@ -228,7 +228,7 @@ void Foam::vtkWriteOps::writePointDataHeader
void Foam::vtkWriteOps::insert(const scalar src, DynamicList<floatScalar>& dest) void Foam::vtkWriteOps::insert(const scalar src, DynamicList<floatScalar>& dest)
{ {
dest.append(float(src)); dest.append(cast(src));
} }
@ -240,7 +240,7 @@ void Foam::vtkWriteOps::insert
{ {
for (direction cmpt = 0; cmpt < vector::nComponents; ++cmpt) for (direction cmpt = 0; cmpt < vector::nComponents; ++cmpt)
{ {
dest.append(float(src[cmpt])); dest.append(cast(src[cmpt]));
} }
} }
@ -253,7 +253,7 @@ void Foam::vtkWriteOps::insert
{ {
for (direction cmpt = 0; cmpt < sphericalTensor::nComponents; ++cmpt) for (direction cmpt = 0; cmpt < sphericalTensor::nComponents; ++cmpt)
{ {
dest.append(float(src[cmpt])); dest.append(cast(src[cmpt]));
} }
} }
@ -264,12 +264,12 @@ void Foam::vtkWriteOps::insert
DynamicList<floatScalar>& dest DynamicList<floatScalar>& dest
) )
{ {
dest.append(float(src.xx())); dest.append(cast(src.xx()));
dest.append(float(src.yy())); dest.append(cast(src.yy()));
dest.append(float(src.zz())); dest.append(cast(src.zz()));
dest.append(float(src.xy())); dest.append(cast(src.xy()));
dest.append(float(src.yz())); dest.append(cast(src.yz()));
dest.append(float(src.xz())); dest.append(cast(src.xz()));
} }
@ -281,7 +281,7 @@ void Foam::vtkWriteOps::insert
{ {
for (direction cmpt = 0; cmpt < tensor::nComponents; ++cmpt) for (direction cmpt = 0; cmpt < tensor::nComponents; ++cmpt)
{ {
dest.append(float(src[cmpt])); dest.append(cast(src[cmpt]));
} }
} }
@ -301,7 +301,7 @@ void Foam::vtkWriteOps::insert
{ {
forAll(map, i) forAll(map, i)
{ {
dest.append(float(source[map[i]])); dest.append(cast(source[map[i]]));
} }
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -58,6 +58,17 @@ namespace vtkWriteOps
//- Swap halves of word //- Swap halves of word
void swapWords(const label nWords, label* words32); void swapWords(const label nWords, label* words32);
//- Cast an integer to the corresponding VTK write type. Does nothing.
inline label cast(const label& x);
//- Cast a float to the corresponding VTK write type. Does nothing.
inline floatScalar cast(const floatScalar& x);
//- Cast a scalar to the corresponding VTK write type. Clips to
// pTraits<floatScalar>::max.
template<class Scalar>
inline floatScalar cast(const Scalar& x);
//- Write header //- Write header
void writeHeader void writeHeader
( (
@ -66,6 +77,7 @@ namespace vtkWriteOps
const std::string& title const std::string& title
); );
//- Write cell data header
void writeCellDataHeader void writeCellDataHeader
( (
std::ostream&, std::ostream&,
@ -73,6 +85,7 @@ namespace vtkWriteOps
const label nFields const label nFields
); );
//- Write point data header
void writePointDataHeader void writePointDataHeader
( (
std::ostream&, std::ostream&,
@ -80,7 +93,6 @@ namespace vtkWriteOps
const label nFields const label nFields
); );
//- Write floats ascii or binary. //- Write floats ascii or binary.
// If binary optionally in-place swaps argument // If binary optionally in-place swaps argument
void write(std::ostream& os, const bool binary, List<floatScalar>& fField); void write(std::ostream& os, const bool binary, List<floatScalar>& fField);
@ -97,7 +109,6 @@ namespace vtkWriteOps
// If binary optionally in-place swaps argument // If binary optionally in-place swaps argument
void write(std::ostream&, const bool, DynamicList<label>&); void write(std::ostream&, const bool, DynamicList<label>&);
//- Append scalar to given DynamicList //- Append scalar to given DynamicList
void insert(const scalar, DynamicList<floatScalar>&); void insert(const scalar, DynamicList<floatScalar>&);
@ -148,6 +159,8 @@ namespace vtkWriteOps
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "vtkWriteOpsI.H"
#ifdef NoRepository #ifdef NoRepository
#include "vtkWriteOpsTemplates.C" #include "vtkWriteOpsTemplates.C"
#endif #endif

View File

@ -0,0 +1,49 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
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/>.
\*---------------------------------------------------------------------------*/
#include "vtkWriteOps.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
inline Foam::label Foam::vtkWriteOps::cast(const label& x)
{
return x;
}
inline Foam::floatScalar Foam::vtkWriteOps::cast(const floatScalar& x)
{
return x;
}
template<class Scalar>
inline Foam::floatScalar Foam::vtkWriteOps::cast(const Scalar& x)
{
return sign(x)*floatScalar(min(mag(x), floatScalarVGreat));
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2021-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -60,10 +60,13 @@ void Foam::vtkWritePolyData::writeFieldTypeValues
for (direction cmpt = 0; cmpt < nCmpt; ++ cmpt) for (direction cmpt = 0; cmpt < nCmpt; ++ cmpt)
{ {
data[i ++] = data[i ++] =
vtkWriteOps::cast
(
component component
( (
fieldTypeValues[fieldi][fieldValuei], fieldTypeValues[fieldi][fieldValuei],
cmpt cmpt
)
); );
} }
} }
@ -109,7 +112,7 @@ void Foam::vtkWritePolyData::write
const point& p = points[pointi]; const point& p = points[pointi];
forAll(p, i) forAll(p, i)
{ {
coordinates[3*pointi + i] = float(p[i]); coordinates[3*pointi + i] = vtkWriteOps::cast(p[i]);
} }
} }
vtkWriteOps::write(os, binary, coordinates); vtkWriteOps::write(os, binary, coordinates);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -158,15 +158,11 @@ void Foam::surfaceInterpolation::makeWeights() const
surfaceScalarField& weights = *weights_; surfaceScalarField& weights = *weights_;
// Set local references to mesh data // Set local references to mesh data
// (note that we should not use fvMesh sliced fields at this point yet
// since this causes a loop when generating weighting factors in
// coupledFvPatchField evaluation phase)
const labelUList& owner = mesh_.owner(); const labelUList& owner = mesh_.owner();
const labelUList& neighbour = mesh_.neighbour(); const labelUList& neighbour = mesh_.neighbour();
const surfaceVectorField& Sf = mesh_.Sf();
const vectorField& Cf = mesh_.faceCentres(); const surfaceVectorField& Cf = mesh_.Cf();
const vectorField& C = mesh_.cellCentres(); const volVectorField& C = mesh_.C();
const vectorField& Sf = mesh_.faceAreas();
// ... and reference to the internal field of the weighting factors // ... and reference to the internal field of the weighting factors
scalarField& w = weights.primitiveFieldRef(); scalarField& w = weights.primitiveFieldRef();

View File

@ -575,10 +575,7 @@ void Foam::fvMeshTopoChangers::refiner::refineUfs
{ {
const surfaceVectorField UfU const surfaceVectorField UfU
( (
fvc::interpolate fvc::interpolate(mesh().lookupObject<volVectorField>(Uname))
(
mesh().lookupObject<volVectorField>(Uname)
)
); );
// Recalculate new internal faces. // Recalculate new internal faces.

View File

@ -641,9 +641,31 @@ void generateGeometryForLocations
{ {
const point& srcP = srcPs[l.srcPointi()]; const point& srcP = srcPs[l.srcPointi()];
const vector& srcN = srcNs[l.srcPointi()]; const vector& srcN = srcNs[l.srcPointi()];
const barycentric2D tgtTs = barycentric2D tgtTs =
srcPointTgtTriIntersection(srcP, srcN, tgtPs); srcPointTgtTriIntersection(srcP, srcN, tgtPs);
// Force inside the target triangle
if (cmptMin(tgtTs) < 0)
{
const direction iMin = findMin(tgtTs);
const direction iMax = findMax(tgtTs);
const direction iMid = 3 - iMin - iMax;
if (tgtTs[iMid] < 0)
{
tgtTs[iMin] = 0;
tgtTs[iMax] = 1;
tgtTs[iMid] = 0;
}
else
{
const scalar t = tgtTs[iMax] + tgtTs[iMid];
tgtTs[iMin] = 0;
tgtTs[iMax] /= t;
tgtTs[iMid] /= t;
}
}
srcPoints[pointi] = srcP; srcPoints[pointi] = srcP;
srcPointNormals[pointi] = srcN; srcPointNormals[pointi] = srcN;
tgtPoints[pointi] = tgtTriInterpolate(tgtTs, tgtPs); tgtPoints[pointi] = tgtTriInterpolate(tgtTs, tgtPs);
@ -1251,7 +1273,7 @@ Foam::barycentric2D Foam::triIntersect::srcPointTgtTriIntersection
const scalar maxMagDetAY = mag(detAY[findMax(cmptMag(detAY))]); const scalar maxMagDetAY = mag(detAY[findMax(cmptMag(detAY))]);
const vector y = vector y =
maxMagDetAY/vGreat < mag(detA) maxMagDetAY/vGreat < mag(detA)
? detAY/detA ? detAY/detA
: detAY/maxMagDetAY*vGreat; : detAY/maxMagDetAY*vGreat;