Compare commits
3 Commits
wip-update
...
develop.sw
| Author | SHA1 | Date | |
|---|---|---|---|
| e65dc2d578 | |||
| 37db8ccd20 | |||
| a5d6c8ced0 |
@ -1,2 +1,2 @@
|
||||
api=2208
|
||||
api=2206
|
||||
patch=220907
|
||||
|
||||
@ -3,7 +3,6 @@ EXE_INC = \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
|
||||
-I$(LIB_SRC)/overset/lnInclude \
|
||||
-I$(LIB_SRC)/overset/include/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
|
||||
@ -31,25 +31,3 @@
|
||||
Info<< "Reading diffusivity DT\n" << endl;
|
||||
|
||||
dimensionedScalar DT("DT", dimViscosity, transportProperties);
|
||||
|
||||
bool oversetPatchErrOutput =
|
||||
simple.dict().getOrDefault("oversetPatchErrOutput", false);
|
||||
|
||||
// Dummy phi for oversetPatchErrOutput
|
||||
tmp<surfaceScalarField> tdummyPhi;
|
||||
if (oversetPatchErrOutput)
|
||||
{
|
||||
tdummyPhi = tmp<surfaceScalarField>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"dummyPhi",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar(dimless, Zero)
|
||||
);
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -58,7 +58,6 @@ Description
|
||||
#include "fvOptions.H"
|
||||
#include "simpleControl.H"
|
||||
#include "dynamicFvMesh.H"
|
||||
#include "oversetPatchPhiErr.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -100,11 +99,6 @@ int main(int argc, char *argv[])
|
||||
fvOptions.constrain(TEqn);
|
||||
TEqn.solve();
|
||||
fvOptions.correct(T);
|
||||
|
||||
if (oversetPatchErrOutput)
|
||||
{
|
||||
oversetPatchPhiErr(TEqn, tdummyPhi.ref());
|
||||
}
|
||||
}
|
||||
|
||||
#include "write.H"
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd
|
||||
Copyright (C) 2017 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -149,6 +149,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
mesh.update();
|
||||
|
||||
surfaceScalarField faceMask(localMin<scalar>(mesh).interpolate(cellMask));
|
||||
|
||||
// Since solver contains no time loop it would never execute
|
||||
// function objects so do it ourselves
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
bool ddtCorr
|
||||
(
|
||||
pimple.dict().getOrDefault("ddtCorr", true)
|
||||
);
|
||||
@ -69,8 +69,6 @@ mesh.setFluxRequired(p.name());
|
||||
|
||||
// Mask field for zeroing out contributions on hole cells
|
||||
#include "createCellMask.H"
|
||||
// Create bool field with interpolated cells
|
||||
#include "createInterpolatedCells.H"
|
||||
|
||||
Info<< "Creating turbulence model\n" << endl;
|
||||
autoPtr<compressible::turbulenceModel> turbulence
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -43,6 +43,7 @@ Description
|
||||
#include "dynamicFvMesh.H"
|
||||
#include "fluidThermo.H"
|
||||
#include "turbulentFluidThermoModel.H"
|
||||
#include "bound.H"
|
||||
#include "pimpleControl.H"
|
||||
#include "pressureControl.H"
|
||||
#include "CorrectPhi.H"
|
||||
@ -88,8 +89,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
while (runTime.run())
|
||||
{
|
||||
#include "readControls.H"
|
||||
#include "readDyMControls.H"
|
||||
|
||||
|
||||
// Store divrhoU from the previous mesh so that it can be mapped
|
||||
// and used in correctPhi to ensure the corrected phi has the
|
||||
// same divergence
|
||||
@ -125,6 +128,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if (pimple.firstIter() || moveMeshOuterCorrectors)
|
||||
{
|
||||
|
||||
// Do any mesh changes
|
||||
mesh.update();
|
||||
|
||||
@ -133,22 +137,52 @@ int main(int argc, char *argv[])
|
||||
MRF.update();
|
||||
|
||||
#include "setCellMask.H"
|
||||
#include "setInterpolatedCells.H"
|
||||
#include "correctRhoPhiFaceMask.H"
|
||||
|
||||
const surfaceScalarField faceMaskOld
|
||||
(
|
||||
localMin<scalar>(mesh).interpolate(cellMask.oldTime())
|
||||
);
|
||||
|
||||
// Zero Uf on old faceMask (H-I)
|
||||
rhoUf() *= faceMaskOld;
|
||||
|
||||
surfaceVectorField rhoUfint(fvc::interpolate(rho*U));
|
||||
|
||||
// Update Uf and phi on new C-I faces
|
||||
rhoUf() += (1-faceMaskOld)*rhoUfint;
|
||||
|
||||
// Update Uf boundary
|
||||
forAll(rhoUf().boundaryField(), patchI)
|
||||
{
|
||||
rhoUf().boundaryFieldRef()[patchI] =
|
||||
rhoUfint.boundaryField()[patchI];
|
||||
}
|
||||
|
||||
// Calculate absolute flux from the mapped surface velocity
|
||||
phi = mesh.Sf() & rhoUf();
|
||||
|
||||
if (correctPhi)
|
||||
{
|
||||
// Corrects flux on separated regions
|
||||
#include "correctPhi.H"
|
||||
}
|
||||
|
||||
// Zero phi on current H-I
|
||||
const surfaceScalarField faceMask
|
||||
(
|
||||
localMin<scalar>(mesh).interpolate(cellMask)
|
||||
);
|
||||
|
||||
phi *= faceMask;
|
||||
U *= cellMask;
|
||||
|
||||
// Make the fluxes relative to the mesh-motion
|
||||
fvc::makeRelative(phi, rho, U);
|
||||
|
||||
if (checkMeshCourantNo)
|
||||
{
|
||||
#include "meshCourantNo.H"
|
||||
}
|
||||
}
|
||||
|
||||
if (checkMeshCourantNo)
|
||||
{
|
||||
#include "meshCourantNo.H"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -25,6 +25,17 @@ surfaceScalarField phiHbyA
|
||||
fvc::interpolate(rho)*fvc::flux(HbyA)
|
||||
);
|
||||
|
||||
if (ddtCorr)
|
||||
{
|
||||
surfaceScalarField faceMaskOld
|
||||
(
|
||||
localMin<scalar>(mesh).interpolate(cellMask.oldTime())
|
||||
);
|
||||
|
||||
phiHbyA +=
|
||||
faceMaskOld*MRF.zeroFilter(rhorAUf*fvc::ddtCorr(rho, U, phi, rhoUf));
|
||||
}
|
||||
|
||||
fvc::makeRelative(phiHbyA, rho, U);
|
||||
MRF.makeRelative(fvc::interpolate(rho), phiHbyA);
|
||||
|
||||
@ -123,4 +134,8 @@ if (thermo.dpdt())
|
||||
}
|
||||
}
|
||||
|
||||
surfaceScalarField faceMask
|
||||
(
|
||||
localMin<scalar>(mesh).interpolate(cellMask)
|
||||
);
|
||||
phi *= faceMask;
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
#include "readTimeControls.H"
|
||||
|
||||
correctPhi = pimple.dict().getOrDefault("correctPhi", false);
|
||||
|
||||
checkMeshCourantNo =
|
||||
pimple.dict().getOrDefault("checkMeshCourantNo", false);
|
||||
|
||||
|
||||
ddtCorr = pimple.dict().getOrDefault("ddtCorr", true);
|
||||
@ -124,6 +124,3 @@ dimensionedScalar initialMass("initialMass", fvc::domainIntegrate(rho));
|
||||
|
||||
// Mask field for zeroing out contributions on hole cells
|
||||
#include "createCellMask.H"
|
||||
|
||||
// Create bool field with interpolated cells
|
||||
#include "createInterpolatedCells.H"
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -50,7 +50,6 @@ Description
|
||||
#include "CorrectPhi.H"
|
||||
#include "cellCellStencilObject.H"
|
||||
#include "localMin.H"
|
||||
#include "oversetAdjustPhi.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -87,6 +86,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
while (runTime.run())
|
||||
{
|
||||
#include "readTimeControls.H"
|
||||
|
||||
#include "readControls.H"
|
||||
#include "readDyMControls.H"
|
||||
|
||||
#include "compressibleCourantNo.H"
|
||||
@ -126,14 +128,45 @@ int main(int argc, char *argv[])
|
||||
MRF.update();
|
||||
|
||||
#include "setCellMask.H"
|
||||
#include "setInterpolatedCells.H"
|
||||
#include "correctRhoPhiFaceMask.H"
|
||||
|
||||
const surfaceScalarField faceMaskOld
|
||||
(
|
||||
localMin<scalar>(mesh).interpolate(cellMask.oldTime())
|
||||
);
|
||||
|
||||
// Zero Uf on old faceMask (H-I)
|
||||
rhoUf() *= faceMaskOld;
|
||||
|
||||
//fvc::correctRhoUf(rhoUfint, rho, U, phi);
|
||||
surfaceVectorField rhoUfint(fvc::interpolate(rho*U));
|
||||
|
||||
// Update Uf and phi on new C-I faces
|
||||
rhoUf() += (1-faceMaskOld)*rhoUfint;
|
||||
|
||||
// Update Uf boundary
|
||||
forAll(rhoUf().boundaryField(), patchI)
|
||||
{
|
||||
rhoUf().boundaryFieldRef()[patchI] =
|
||||
rhoUfint.boundaryField()[patchI];
|
||||
}
|
||||
|
||||
// Calculate absolute flux from the mapped surface velocity
|
||||
phi = mesh.Sf() & rhoUf();
|
||||
|
||||
if (correctPhi)
|
||||
{
|
||||
#include "correctPhi.H"
|
||||
}
|
||||
|
||||
// Zero phi on current H-I
|
||||
const surfaceScalarField faceMask
|
||||
(
|
||||
localMin<scalar>(mesh).interpolate(cellMask)
|
||||
);
|
||||
|
||||
phi *= faceMask;
|
||||
U *= cellMask;
|
||||
|
||||
// Make the fluxes relative to the mesh-motion
|
||||
fvc::makeRelative(phi, rho, U);
|
||||
}
|
||||
|
||||
@ -21,13 +21,16 @@ surfaceScalarField phiHbyA
|
||||
fvc::flux(rho*HbyA) + phig
|
||||
);
|
||||
|
||||
if (adjustFringe)
|
||||
if (ddtCorr)
|
||||
{
|
||||
fvc::makeRelative(phiHbyA,rho, U);
|
||||
oversetAdjustPhi(phiHbyA, U);
|
||||
fvc::makeAbsolute(phiHbyA,rho, U);
|
||||
}
|
||||
surfaceScalarField faceMaskOld
|
||||
(
|
||||
localMin<scalar>(mesh).interpolate(cellMask.oldTime())
|
||||
);
|
||||
|
||||
phiHbyA +=
|
||||
faceMaskOld*MRF.zeroFilter(rhorAUf*fvc::ddtCorr(rho, U, phi));
|
||||
}
|
||||
|
||||
MRF.makeRelative(fvc::interpolate(rho), phiHbyA);
|
||||
|
||||
@ -119,4 +122,8 @@ if (thermo.dpdt())
|
||||
}
|
||||
}
|
||||
|
||||
surfaceScalarField faceMask
|
||||
(
|
||||
localMin<scalar>(mesh).interpolate(cellMask)
|
||||
);
|
||||
phi *= faceMask;
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
#include "readTimeControls.H"
|
||||
|
||||
correctPhi = pimple.dict().getOrDefault("correctPhi", false);
|
||||
|
||||
checkMeshCourantNo =
|
||||
pimple.dict().getOrDefault("checkMeshCourantNo", false);
|
||||
|
||||
|
||||
ddtCorr = pimple.dict().getOrDefault("ddtCorr", true);
|
||||
@ -35,7 +35,7 @@
|
||||
(
|
||||
solidRegions[i],
|
||||
thermos[i],
|
||||
coordinateSystem::typeName
|
||||
coordinateSystem::typeName_()
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ if (!thermo.isotropic())
|
||||
(
|
||||
mesh,
|
||||
thermo,
|
||||
coordinateSystem::typeName
|
||||
coordinateSystem::typeName_()
|
||||
);
|
||||
|
||||
tmp<volVectorField> tkappaByCp = thermo.Kappa()/thermo.Cp();
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -37,10 +37,7 @@ scalar meanCoNum = 0.0;
|
||||
|
||||
if (mesh.nInternalFaces())
|
||||
{
|
||||
surfaceScalarField phiMask
|
||||
(
|
||||
localMin<scalar>(mesh).interpolate(cellMask + interpolatedCells)
|
||||
);
|
||||
surfaceScalarField phiMask(localMin<scalar>(mesh).interpolate(cellMask));
|
||||
|
||||
scalarField sumPhi(fvc::surfaceSum(mag(phiMask*phi))().internalField());
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
// Solve the Momentum equation
|
||||
|
||||
MRF.correctBoundaryVelocity(U);
|
||||
|
||||
tmp<fvVectorMatrix> tUEqn
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
#include "createTimeControls.H"
|
||||
|
||||
bool correctPhi
|
||||
(
|
||||
pimple.dict().getOrDefault("correctPhi", false)
|
||||
);
|
||||
|
||||
bool checkMeshCourantNo
|
||||
(
|
||||
pimple.dict().getOrDefault("checkMeshCourantNo", false)
|
||||
);
|
||||
|
||||
bool massFluxInterpolation
|
||||
(
|
||||
pimple.dict().getOrDefault("massFluxInterpolation", false)
|
||||
);
|
||||
|
||||
bool adjustFringe
|
||||
(
|
||||
pimple.dict().getOrDefault("oversetAdjustPhi", false)
|
||||
);
|
||||
|
||||
bool ddtCorr
|
||||
(
|
||||
pimple.dict().getOrDefault("ddtCorr", true)
|
||||
);
|
||||
@ -0,0 +1,273 @@
|
||||
// Interpolation used
|
||||
interpolationCellPoint<vector> UInterpolator(HbyA);
|
||||
|
||||
// Determine faces on outside of interpolated cells
|
||||
bitSet isOwnerInterpolatedFace(mesh.nInternalFaces());
|
||||
bitSet isNeiInterpolatedFace(mesh.nInternalFaces());
|
||||
|
||||
// Determine donor cells
|
||||
labelListList donorCell(mesh.nInternalFaces());
|
||||
|
||||
scalarListList weightCellCells(mesh.nInternalFaces());
|
||||
|
||||
// Interpolated HbyA faces
|
||||
vectorField UIntFaces(mesh.nInternalFaces(), Zero);
|
||||
|
||||
// Determine receptor neighbour cells
|
||||
labelList receptorNeigCell(mesh.nInternalFaces(), -1);
|
||||
|
||||
{
|
||||
const cellCellStencilObject& overlap = Stencil::New(mesh);
|
||||
const labelList& cellTypes = overlap.cellTypes();
|
||||
const labelIOList& zoneID = overlap.zoneID();
|
||||
|
||||
label nZones = gMax(zoneID)+1;
|
||||
PtrList<fvMeshSubset> meshParts(nZones);
|
||||
labelList nCellsPerZone(nZones, Zero);
|
||||
|
||||
// A mesh subset for each zone
|
||||
forAll(meshParts, zonei)
|
||||
{
|
||||
meshParts.set
|
||||
(
|
||||
zonei,
|
||||
// Select cells where the zoneID == zonei
|
||||
new fvMeshSubset(mesh, zonei, zoneID)
|
||||
);
|
||||
}
|
||||
|
||||
for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
|
||||
{
|
||||
label ownType = cellTypes[mesh.faceOwner()[faceI]];
|
||||
label neiType = cellTypes[mesh.faceNeighbour()[faceI]];
|
||||
if
|
||||
(
|
||||
ownType == cellCellStencil::INTERPOLATED
|
||||
&& neiType == cellCellStencil::CALCULATED
|
||||
)
|
||||
{
|
||||
isOwnerInterpolatedFace.set(faceI);
|
||||
|
||||
const vector& fc = mesh.faceCentres()[faceI];
|
||||
|
||||
for (label zoneI = 0; zoneI < nZones; zoneI++)
|
||||
{
|
||||
if (zoneI != zoneID[mesh.faceOwner()[faceI]])
|
||||
{
|
||||
const fvMesh& partMesh = meshParts[zoneI].subMesh();
|
||||
const labelList& cellMap = meshParts[zoneI].cellMap();
|
||||
label cellI = partMesh.findCell(fc);
|
||||
|
||||
if (cellI != -1)
|
||||
{
|
||||
// Determine weights
|
||||
labelList stencil(partMesh.cellCells()[cellI]);
|
||||
|
||||
stencil.append(cellI);
|
||||
|
||||
label st = stencil.size();
|
||||
|
||||
donorCell[faceI].setSize(st);
|
||||
|
||||
weightCellCells[faceI].setSize(st);
|
||||
|
||||
scalarField weights(st);
|
||||
|
||||
forAll(stencil, i)
|
||||
{
|
||||
scalar d = mag
|
||||
(
|
||||
partMesh.cellCentres()[stencil[i]]
|
||||
- fc
|
||||
);
|
||||
weights[i] = 1.0/d;
|
||||
donorCell[faceI][i] = cellMap[stencil[i]];
|
||||
}
|
||||
weights /= sum(weights);
|
||||
|
||||
weightCellCells[faceI] = weights;
|
||||
|
||||
forAll(stencil, i)
|
||||
{
|
||||
UIntFaces[faceI] +=
|
||||
weightCellCells[faceI][i]
|
||||
*UInterpolator.interpolate
|
||||
(
|
||||
fc,
|
||||
donorCell[faceI][i]
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
receptorNeigCell[faceI] = mesh.faceNeighbour()[faceI];
|
||||
}
|
||||
else if
|
||||
(
|
||||
ownType == cellCellStencil::CALCULATED
|
||||
&& neiType == cellCellStencil::INTERPOLATED
|
||||
)
|
||||
{
|
||||
isNeiInterpolatedFace.set(faceI);
|
||||
|
||||
const vector& fc = mesh.faceCentres()[faceI];
|
||||
for (label zoneI = 0; zoneI < nZones; zoneI++)
|
||||
{
|
||||
if (zoneI != zoneID[mesh.faceNeighbour()[faceI]])
|
||||
{
|
||||
const fvMesh& partMesh = meshParts[zoneI].subMesh();
|
||||
const labelList& cellMap = meshParts[zoneI].cellMap();
|
||||
label cellI = partMesh.findCell(fc);
|
||||
|
||||
if (cellI != -1)
|
||||
{
|
||||
// Determine weights
|
||||
labelList stencil(partMesh.cellCells()[cellI]);
|
||||
|
||||
stencil.append(cellI);
|
||||
|
||||
label st = stencil.size();
|
||||
|
||||
donorCell[faceI].setSize(st);
|
||||
|
||||
weightCellCells[faceI].setSize(st);
|
||||
|
||||
scalarField weights(st);
|
||||
|
||||
forAll(stencil, i)
|
||||
{
|
||||
scalar d = mag
|
||||
(
|
||||
partMesh.cellCentres()[stencil[i]]
|
||||
- fc
|
||||
);
|
||||
weights[i] = 1.0/d;
|
||||
donorCell[faceI][i] = cellMap[stencil[i]];
|
||||
}
|
||||
weights /= sum(weights);
|
||||
|
||||
weightCellCells[faceI] = weights;
|
||||
|
||||
forAll(stencil, i)
|
||||
{
|
||||
UIntFaces[faceI] +=
|
||||
weightCellCells[faceI][i]
|
||||
*UInterpolator.interpolate
|
||||
(
|
||||
fc,
|
||||
donorCell[faceI][i]
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
receptorNeigCell[faceI] = mesh.faceOwner()[faceI];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// contravariant U
|
||||
vectorField U1Contrav(mesh.nInternalFaces(), Zero);
|
||||
|
||||
surfaceVectorField faceNormals(mesh.Sf()/mesh.magSf());
|
||||
|
||||
forAll(isNeiInterpolatedFace, faceI)
|
||||
{
|
||||
label cellId = -1;
|
||||
if (isNeiInterpolatedFace.test(faceI))
|
||||
{
|
||||
cellId = mesh.faceNeighbour()[faceI];
|
||||
}
|
||||
else if (isOwnerInterpolatedFace.test(faceI))
|
||||
{
|
||||
cellId = mesh.faceOwner()[faceI];
|
||||
}
|
||||
|
||||
if (cellId != -1)
|
||||
{
|
||||
const vector& n = faceNormals[faceI];
|
||||
vector n1(Zero);
|
||||
|
||||
// 2-D cases
|
||||
if (mesh.nSolutionD() == 2)
|
||||
{
|
||||
for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
|
||||
{
|
||||
if (mesh.geometricD()[cmpt] == -1)
|
||||
{
|
||||
switch (cmpt)
|
||||
{
|
||||
case vector::X:
|
||||
{
|
||||
n1 = vector(0, n.z(), -n.y());
|
||||
break;
|
||||
}
|
||||
|
||||
case vector::Y:
|
||||
{
|
||||
n1 = vector(n.z(), 0, -n.x());
|
||||
break;
|
||||
}
|
||||
|
||||
case vector::Z:
|
||||
{
|
||||
n1 = vector(n.y(), -n.x(), 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (mesh.nSolutionD() == 3)
|
||||
{
|
||||
//Determine which is the primary direction
|
||||
if (mag(n.x()) > mag(n.y()) && mag(n.x()) > mag(n.z()))
|
||||
{
|
||||
n1 = vector(n.y(), -n.x(), 0);
|
||||
}
|
||||
else if (mag(n.y()) > mag(n.z()))
|
||||
{
|
||||
n1 = vector(0, n.z(), -n.y());
|
||||
}
|
||||
else
|
||||
{
|
||||
n1 = vector(-n.z(), 0, n.x());
|
||||
}
|
||||
}
|
||||
n1.normalise();
|
||||
|
||||
const vector n2 = normalised(n ^ n1);
|
||||
|
||||
tensor rot =
|
||||
tensor
|
||||
(
|
||||
n.x() ,n.y(), n.z(),
|
||||
n1.x() ,n1.y(), n1.z(),
|
||||
n2.x() ,n2.y(), n2.z()
|
||||
);
|
||||
|
||||
// tensor rot =
|
||||
// tensor
|
||||
// (
|
||||
// n & x ,n & y, n & z,
|
||||
// n1 & x ,n1 & y, n1 & z,
|
||||
// n2 & x ,n2 & y, n2 & z
|
||||
// );
|
||||
|
||||
U1Contrav[faceI].x() =
|
||||
2*transform(rot, UIntFaces[faceI]).x()
|
||||
- transform(rot, HbyA[receptorNeigCell[faceI]]).x();
|
||||
|
||||
U1Contrav[faceI].y() = transform(rot, HbyA[cellId]).y();
|
||||
|
||||
U1Contrav[faceI].z() = transform(rot, HbyA[cellId]).z();
|
||||
|
||||
HbyA[cellId] = transform(inv(rot), U1Contrav[faceI]);
|
||||
}
|
||||
}
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -46,9 +46,12 @@ Description
|
||||
#include "fvOptions.H"
|
||||
|
||||
#include "cellCellStencilObject.H"
|
||||
#include "zeroGradientFvPatchFields.H"
|
||||
#include "localMin.H"
|
||||
#include "interpolationCellPoint.H"
|
||||
#include "transform.H"
|
||||
#include "fvMeshSubset.H"
|
||||
#include "oversetAdjustPhi.H"
|
||||
#include "oversetPatchPhiErr.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -65,9 +68,10 @@ int main(int argc, char *argv[])
|
||||
#include "setRootCaseLists.H"
|
||||
#include "createTime.H"
|
||||
#include "createDynamicFvMesh.H"
|
||||
#include "createDyMControls.H"
|
||||
#include "initContinuityErrs.H"
|
||||
|
||||
pimpleControl pimple(mesh);
|
||||
|
||||
#include "createFields.H"
|
||||
#include "createUf.H"
|
||||
#include "createMRF.H"
|
||||
@ -84,9 +88,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
while (runTime.run())
|
||||
{
|
||||
#include "readDyMControls.H"
|
||||
#include "readOversetDyMControls.H"
|
||||
|
||||
#include "readControls.H"
|
||||
#include "CourantNo.H"
|
||||
|
||||
#include "setDeltaT.H"
|
||||
@ -95,20 +97,45 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
mesh.update();
|
||||
bool changed = mesh.update();
|
||||
|
||||
if (mesh.changing())
|
||||
if (changed)
|
||||
{
|
||||
#include "setCellMask.H"
|
||||
#include "setInterpolatedCells.H"
|
||||
#include "correctPhiFaceMask.H"
|
||||
|
||||
fvc::makeRelative(phi, U);
|
||||
surfaceScalarField faceMaskOld
|
||||
(
|
||||
localMin<scalar>(mesh).interpolate(cellMask.oldTime())
|
||||
);
|
||||
|
||||
if (checkMeshCourantNo)
|
||||
{
|
||||
#include "meshCourantNo.H"
|
||||
}
|
||||
// Zero Uf on old faceMask (H-I)
|
||||
Uf *= faceMaskOld;
|
||||
// Update Uf and phi on new C-I faces
|
||||
Uf += (1-faceMaskOld)*fvc::interpolate(U);
|
||||
phi = mesh.Sf() & Uf;
|
||||
|
||||
// Zero phi on current H-I
|
||||
surfaceScalarField faceMask
|
||||
(
|
||||
localMin<scalar>(mesh).interpolate(cellMask)
|
||||
);
|
||||
phi *= faceMask;
|
||||
}
|
||||
|
||||
|
||||
if (mesh.changing() && correctPhi)
|
||||
{
|
||||
// Calculate absolute flux from the mapped surface velocity
|
||||
#include "correctPhi.H"
|
||||
}
|
||||
|
||||
// Make the flux relative to the mesh motion
|
||||
fvc::makeRelative(phi, U);
|
||||
|
||||
if (mesh.changing() && checkMeshCourantNo)
|
||||
{
|
||||
#include "meshCourantNo.H"
|
||||
}
|
||||
|
||||
// --- Pressure-velocity PIMPLE corrector loop
|
||||
|
||||
@ -1,11 +1,36 @@
|
||||
// Option 1: interpolate rAU, do not block out rAU on blocked cells
|
||||
volScalarField rAU("rAU", 1.0/UEqn.A());
|
||||
mesh.interpolate(rAU);
|
||||
|
||||
// Option 2: do not interpolate rAU but block out rAU
|
||||
//surfaceScalarField rAUf("rAUf", fvc::interpolate(blockedCells*rAU));
|
||||
|
||||
|
||||
// Option 3: do not interpolate rAU but zero out rAUf on faces on holes
|
||||
// But what about:
|
||||
//
|
||||
// H
|
||||
// H I C C C C
|
||||
// H
|
||||
//
|
||||
surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU));
|
||||
volVectorField H("H", UEqn.H());
|
||||
|
||||
volVectorField HbyA("HbyA", U);
|
||||
HbyA = constrainHbyA(rAU*H, U, p);
|
||||
|
||||
if (massFluxInterpolation)
|
||||
{
|
||||
#include "interpolatedFaces.H"
|
||||
}
|
||||
|
||||
if (runTime.outputTime())
|
||||
{
|
||||
H.write();
|
||||
rAU.write();
|
||||
HbyA.write();
|
||||
}
|
||||
|
||||
if (pimple.nCorrPISO() <= 1)
|
||||
{
|
||||
tUEqn.clear();
|
||||
@ -13,16 +38,33 @@ if (pimple.nCorrPISO() <= 1)
|
||||
|
||||
phiHbyA = fvc::flux(HbyA);
|
||||
|
||||
if (ddtCorr)
|
||||
{
|
||||
surfaceScalarField faceMaskOld
|
||||
(
|
||||
localMin<scalar>(mesh).interpolate(cellMask.oldTime())
|
||||
);
|
||||
phiHbyA += rAUf*faceMaskOld*fvc::ddtCorr(U, Uf);
|
||||
}
|
||||
|
||||
MRF.makeRelative(phiHbyA);
|
||||
|
||||
// WIP
|
||||
if (p.needReference())
|
||||
{
|
||||
fvc::makeRelative(phiHbyA, U);
|
||||
adjustPhi(phiHbyA, U, p);
|
||||
fvc::makeAbsolute(phiHbyA, U);
|
||||
}
|
||||
|
||||
|
||||
if (adjustFringe)
|
||||
{
|
||||
fvc::makeRelative(phiHbyA, U);
|
||||
oversetAdjustPhi(phiHbyA, U, zoneIdMass);
|
||||
oversetAdjustPhi(phiHbyA, U);
|
||||
fvc::makeAbsolute(phiHbyA, U);
|
||||
}
|
||||
|
||||
|
||||
while (pimple.correctNonOrthogonal())
|
||||
{
|
||||
fvScalarMatrix pEqn
|
||||
@ -37,26 +79,27 @@ while (pimple.correctNonOrthogonal())
|
||||
if (pimple.finalNonOrthogonalIter())
|
||||
{
|
||||
phi = phiHbyA - pEqn.flux();
|
||||
pEqn.relax();
|
||||
U =
|
||||
cellMask*
|
||||
(
|
||||
HbyA
|
||||
- rAU*fvc::reconstruct((pEqn.flux())/rAUf)
|
||||
);
|
||||
U.correctBoundaryConditions();
|
||||
fvOptions.correct(U);
|
||||
}
|
||||
|
||||
if (oversetPatchErrOutput)
|
||||
{
|
||||
oversetPatchPhiErr(pEqn, phiHbyA);
|
||||
// option 2:
|
||||
// rAUf*fvc::snGrad(p)*mesh.magSf();
|
||||
}
|
||||
}
|
||||
|
||||
// Excludes error in interpolated/hole cells
|
||||
|
||||
#include "continuityErrs.H"
|
||||
|
||||
// Explicitly relax pressure for momentum corrector
|
||||
p.relax();
|
||||
volVectorField gradP(fvc::grad(p));
|
||||
|
||||
// Option 2: zero out velocity on blocked out cells
|
||||
//U = HbyA - rAU*cellMask*gradP;
|
||||
// Option 3: zero out velocity on blocked out cells
|
||||
// This is needed for the scalar Eq (k,epsilon, etc)
|
||||
// which can use U as source term
|
||||
U = cellMask*(HbyA - rAU*gradP);
|
||||
U.correctBoundaryConditions();
|
||||
|
||||
fvOptions.correct(U);
|
||||
|
||||
{
|
||||
Uf = fvc::interpolate(U);
|
||||
@ -66,4 +109,9 @@ while (pimple.correctNonOrthogonal())
|
||||
|
||||
// Make the fluxes relative to the mesh motion
|
||||
fvc::makeRelative(phi, U);
|
||||
|
||||
surfaceScalarField faceMask
|
||||
(
|
||||
localMin<scalar>(mesh).interpolate(cellMask)
|
||||
);
|
||||
phi *= faceMask;
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
#include "readTimeControls.H"
|
||||
|
||||
correctPhi = pimple.dict().getOrDefault("correctPhi", false);
|
||||
|
||||
checkMeshCourantNo = pimple.dict().getOrDefault("checkMeshCourantNo", false);
|
||||
|
||||
massFluxInterpolation =
|
||||
pimple.dict().getOrDefault("massFluxInterpolation", false);
|
||||
|
||||
ddtCorr = pimple.dict().getOrDefault("ddtCorr", true);
|
||||
@ -24,3 +24,7 @@ bool adjustFringe
|
||||
(
|
||||
simple.dict().getOrDefault("oversetAdjustPhi", false)
|
||||
);
|
||||
bool massFluxInterpolation
|
||||
(
|
||||
simple.dict().getOrDefault("massFluxInterpolation", false)
|
||||
);
|
||||
|
||||
@ -1,10 +1,18 @@
|
||||
{
|
||||
surfaceScalarField faceMask(localMin<scalar>(mesh).interpolate(cellMask));
|
||||
|
||||
volScalarField rAU(1.0/UEqn.A());
|
||||
surfaceScalarField rAUf("rAUf", faceMask*fvc::interpolate(rAU));
|
||||
|
||||
volVectorField HbyA("HbyA", U);
|
||||
HbyA = constrainHbyA(cellMask*rAU*UEqn.H(), U, p);
|
||||
|
||||
//mesh.interpolate(HbyA);
|
||||
if (massFluxInterpolation)
|
||||
{
|
||||
#include "interpolatedFaces.H"
|
||||
}
|
||||
|
||||
tUEqn.clear();
|
||||
|
||||
surfaceScalarField phiHbyA("phiHbyA", fvc::flux(HbyA));
|
||||
|
||||
@ -129,5 +129,10 @@ compressibleInterPhaseTransportModel turbulence
|
||||
// Mask field for zeroing out contributions on hole cells
|
||||
#include "createCellMask.H"
|
||||
|
||||
surfaceScalarField faceMask
|
||||
(
|
||||
localMin<scalar>(mesh).interpolate(cellMask)
|
||||
);
|
||||
|
||||
// Create bool field with interpolated cells
|
||||
#include "createInterpolatedCells.H"
|
||||
|
||||
@ -80,6 +80,9 @@ int main(int argc, char *argv[])
|
||||
#include "setRootCaseLists.H"
|
||||
#include "createTime.H"
|
||||
#include "createDynamicFvMesh.H"
|
||||
pimpleControl pimple(mesh);
|
||||
|
||||
#include "createTimeControls.H"
|
||||
#include "createDyMControls.H"
|
||||
#include "createFields.H"
|
||||
|
||||
@ -106,7 +109,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
while (runTime.run())
|
||||
{
|
||||
#include "readDyMControls.H"
|
||||
#include "readControls.H"
|
||||
|
||||
if (LTS)
|
||||
{
|
||||
@ -151,10 +154,40 @@ int main(int argc, char *argv[])
|
||||
// Update cellMask field for blocking out hole cells
|
||||
#include "setCellMask.H"
|
||||
#include "setInterpolatedCells.H"
|
||||
#include "correctPhiFaceMask.H"
|
||||
|
||||
faceMask =
|
||||
localMin<scalar>(mesh).interpolate(cellMask.oldTime());
|
||||
|
||||
// Zero Uf on old faceMask (H-I)
|
||||
Uf *= faceMask;
|
||||
|
||||
const surfaceVectorField Uint(fvc::interpolate(U));
|
||||
// Update Uf and phi on new C-I faces
|
||||
Uf += (1-faceMask)*Uint;
|
||||
|
||||
// Update Uf boundary
|
||||
forAll(Uf.boundaryField(), patchI)
|
||||
{
|
||||
Uf.boundaryFieldRef()[patchI] =
|
||||
Uint.boundaryField()[patchI];
|
||||
}
|
||||
|
||||
phi = mesh.Sf() & Uf;
|
||||
|
||||
// Correct phi on individual regions
|
||||
if (correctPhi)
|
||||
{
|
||||
#include "correctPhi.H"
|
||||
}
|
||||
|
||||
mixture.correct();
|
||||
|
||||
// Zero phi on current H-I
|
||||
faceMask = localMin<scalar>(mesh).interpolate(cellMask);
|
||||
|
||||
phi *= faceMask;
|
||||
U *= cellMask;
|
||||
|
||||
// Make the flux relative to the mesh motion
|
||||
fvc::makeRelative(phi, U);
|
||||
|
||||
@ -169,6 +202,10 @@ int main(int argc, char *argv[])
|
||||
#include "alphaControls.H"
|
||||
#include "compressibleAlphaEqnSubCycle.H"
|
||||
|
||||
const surfaceScalarField faceMask
|
||||
(
|
||||
localMin<scalar>(mesh).interpolate(cellMask)
|
||||
);
|
||||
rhoPhi *= faceMask;
|
||||
|
||||
turbulence.correctPhasePhi();
|
||||
|
||||
@ -10,6 +10,19 @@
|
||||
fvc::flux(HbyA)
|
||||
);
|
||||
|
||||
if (ddtCorr)
|
||||
{
|
||||
surfaceScalarField faceMaskOld
|
||||
(
|
||||
localMin<scalar>(mesh).interpolate(cellMask.oldTime())
|
||||
);
|
||||
phiHbyA +=
|
||||
MRF.zeroFilter
|
||||
(
|
||||
fvc::interpolate(rho*rAU)*faceMaskOld*fvc::ddtCorr(U, Uf)
|
||||
);
|
||||
}
|
||||
|
||||
MRF.makeRelative(phiHbyA);
|
||||
|
||||
surfaceScalarField phig
|
||||
|
||||
@ -157,7 +157,12 @@ void Foam::radiation::laserDTRM::initialiseReflection()
|
||||
);
|
||||
}
|
||||
|
||||
reflectionSwitch_ = returnReduceOr(reflections_.size());
|
||||
if (reflections_.size())
|
||||
{
|
||||
reflectionSwitch_ = true;
|
||||
}
|
||||
|
||||
reflectionSwitch_ = returnReduce(reflectionSwitch_, orOp<bool>());
|
||||
}
|
||||
}
|
||||
|
||||
@ -294,12 +299,14 @@ void Foam::radiation::laserDTRM::initialise()
|
||||
DTRMCloud_.addParticle(pPtr);
|
||||
}
|
||||
|
||||
if (nMissed < 10 && returnReduceAnd(cellI < 0))
|
||||
if (returnReduce(cellI, maxOp<label>()) == -1)
|
||||
{
|
||||
++nMissed;
|
||||
WarningInFunction
|
||||
<< "Cannot find owner cell for focalPoint at "
|
||||
<< p0 << endl;
|
||||
if (++nMissed <= 10)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Cannot find owner cell for focalPoint at "
|
||||
<< p0 << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -36,10 +36,7 @@ scalar meanCoNum = 0.0;
|
||||
|
||||
if (mesh.nInternalFaces())
|
||||
{
|
||||
surfaceScalarField phiMask
|
||||
(
|
||||
localMin<scalar>(mesh).interpolate(cellMask + interpolatedCells)
|
||||
);
|
||||
surfaceScalarField phiMask(localMin<scalar>(mesh).interpolate(cellMask));
|
||||
|
||||
scalarField sumPhi
|
||||
(
|
||||
|
||||
@ -7,5 +7,3 @@ volScalarField::Internal divU
|
||||
? fvc::div(phiCN() + mesh.phi())
|
||||
: fvc::div(phiCN())
|
||||
);
|
||||
|
||||
divU *= interpolatedCells*cellMask;
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
bool correctPhi
|
||||
(
|
||||
pimple.dict().getOrDefault("correctPhi", true)
|
||||
);
|
||||
|
||||
bool checkMeshCourantNo
|
||||
(
|
||||
pimple.dict().getOrDefault("checkMeshCourantNo", false)
|
||||
);
|
||||
|
||||
bool moveMeshOuterCorrectors
|
||||
(
|
||||
pimple.dict().getOrDefault("moveMeshOuterCorrectors", false)
|
||||
);
|
||||
|
||||
|
||||
bool massFluxInterpolation
|
||||
(
|
||||
pimple.dict().getOrDefault("massFluxInterpolation", false)
|
||||
);
|
||||
|
||||
bool adjustFringe
|
||||
(
|
||||
pimple.dict().getOrDefault("oversetAdjustPhi", false)
|
||||
);
|
||||
|
||||
bool ddtCorr
|
||||
(
|
||||
pimple.dict().getOrDefault("ddtCorr", true)
|
||||
);
|
||||
@ -40,12 +40,8 @@ volVectorField U
|
||||
nonInt.insert("HbyA");
|
||||
nonInt.insert("grad(p_rgh)");
|
||||
nonInt.insert("nHat");
|
||||
nonInt.insert("surfaceIntegrate(nHatf)");
|
||||
nonInt.insert("surfaceIntegrate(phi+meshPhi)");
|
||||
nonInt.insert("surfaceIntegrate(phi)");
|
||||
nonInt.insert("surfaceIntegrate(phiHbyA)");
|
||||
nonInt.insert("surfaceSum(((S|magSf)*S)");
|
||||
nonInt.insert("surfaceIntegrate(((rAUf*magSf)*snGradCorr(p_rgh)))");
|
||||
nonInt.insert("cellMask");
|
||||
nonInt.insert("cellDisplacement");
|
||||
nonInt.insert("interpolatedCells");
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -49,11 +49,14 @@ Description
|
||||
#include "turbulentTransportModel.H"
|
||||
#include "pimpleControl.H"
|
||||
#include "fvOptions.H"
|
||||
#include "CorrectPhi.H"
|
||||
#include "fvcSmooth.H"
|
||||
#include "cellCellStencilObject.H"
|
||||
#include "localMin.H"
|
||||
#include "interpolationCellPoint.H"
|
||||
#include "transform.H"
|
||||
#include "fvMeshSubset.H"
|
||||
#include "oversetAdjustPhi.H"
|
||||
#include "oversetPatchPhiErr.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -73,7 +76,8 @@ int main(int argc, char *argv[])
|
||||
#include "createTime.H"
|
||||
#include "createDynamicFvMesh.H"
|
||||
#include "initContinuityErrs.H"
|
||||
|
||||
pimpleControl pimple(mesh);
|
||||
#include "createTimeControls.H"
|
||||
#include "createDyMControls.H"
|
||||
#include "createFields.H"
|
||||
#include "createAlphaFluxes.H"
|
||||
@ -93,8 +97,11 @@ int main(int argc, char *argv[])
|
||||
dimensionedScalar("rAUf", dimTime/rho.dimensions(), 1.0)
|
||||
);
|
||||
|
||||
if (correctPhi)
|
||||
{
|
||||
#include "correctPhi.H"
|
||||
}
|
||||
#include "createUf.H"
|
||||
#include "createControls.H"
|
||||
|
||||
#include "setCellMask.H"
|
||||
#include "setInterpolatedCells.H"
|
||||
@ -112,8 +119,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
while (runTime.run())
|
||||
{
|
||||
#include "readDyMControls.H"
|
||||
#include "readOversetDyMControls.H"
|
||||
#include "readControls.H"
|
||||
|
||||
if (LTS)
|
||||
{
|
||||
@ -152,17 +158,50 @@ int main(int argc, char *argv[])
|
||||
talphaPhi1Corr0.clear();
|
||||
}
|
||||
|
||||
// Update cellMask field for blocking out hole cells
|
||||
#include "setCellMask.H"
|
||||
#include "setInterpolatedCells.H"
|
||||
#include "correctPhiFaceMask.H"
|
||||
|
||||
gh = (g & mesh.C()) - ghRef;
|
||||
ghf = (g & mesh.Cf()) - ghRef;
|
||||
|
||||
// Update cellMask field for blocking out hole cells
|
||||
#include "setCellMask.H"
|
||||
#include "setInterpolatedCells.H"
|
||||
|
||||
const surfaceScalarField faceMaskOld
|
||||
(
|
||||
localMin<scalar>(mesh).interpolate(cellMask.oldTime())
|
||||
);
|
||||
|
||||
// Zero Uf on old faceMask (H-I)
|
||||
Uf *= faceMaskOld;
|
||||
|
||||
const surfaceVectorField Uint(fvc::interpolate(U));
|
||||
// Update Uf and phi on new C-I faces
|
||||
Uf += (1-faceMaskOld)*Uint;
|
||||
|
||||
// Update Uf boundary
|
||||
forAll(Uf.boundaryField(), patchI)
|
||||
{
|
||||
Uf.boundaryFieldRef()[patchI] =
|
||||
Uint.boundaryField()[patchI];
|
||||
}
|
||||
|
||||
phi = mesh.Sf() & Uf;
|
||||
|
||||
// Correct phi on individual regions
|
||||
if (correctPhi)
|
||||
{
|
||||
#include "correctPhi.H"
|
||||
}
|
||||
|
||||
mixture.correct();
|
||||
|
||||
// Zero phi on current H-I
|
||||
const surfaceScalarField faceMask
|
||||
(
|
||||
localMin<scalar>(mesh).interpolate(cellMask)
|
||||
);
|
||||
phi *= faceMask;
|
||||
U *= cellMask;
|
||||
|
||||
// Make the flux relative to the mesh motion
|
||||
fvc::makeRelative(phi, U);
|
||||
|
||||
@ -174,14 +213,14 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (adjustFringe)
|
||||
{
|
||||
oversetAdjustPhi(phi, U, zoneIdMass);
|
||||
}
|
||||
|
||||
#include "alphaControls.H"
|
||||
#include "alphaEqnSubCycle.H"
|
||||
|
||||
const surfaceScalarField faceMask
|
||||
(
|
||||
localMin<scalar>(mesh).interpolate(cellMask)
|
||||
);
|
||||
rhoPhi *= faceMask;
|
||||
|
||||
mixture.correct();
|
||||
|
||||
@ -1,31 +1,64 @@
|
||||
{
|
||||
rAU = 1.0/UEqn.A();
|
||||
//mesh.interpolate(rAU);
|
||||
|
||||
surfaceScalarField faceMask(localMin<scalar>(mesh).interpolate(cellMask));
|
||||
|
||||
surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU));
|
||||
|
||||
volVectorField H("H", UEqn.H());
|
||||
|
||||
volVectorField HbyA("HbyA", U);
|
||||
|
||||
//HbyA = rAU*UEqn.H();
|
||||
HbyA = constrainHbyA(rAU*H, U, p_rgh);
|
||||
|
||||
if (massFluxInterpolation)
|
||||
{
|
||||
#include "interpolatedFaces.H"
|
||||
}
|
||||
|
||||
surfaceScalarField phiHbyA("phiHbyA", fvc::flux(HbyA));
|
||||
|
||||
if (ddtCorr)
|
||||
{
|
||||
surfaceScalarField faceMaskOld
|
||||
(
|
||||
localMin<scalar>(mesh).interpolate(cellMask.oldTime())
|
||||
);
|
||||
phiHbyA +=
|
||||
fvc::interpolate(rho*rAU)*faceMaskOld*fvc::ddtCorr(U, Uf);
|
||||
}
|
||||
MRF.makeRelative(phiHbyA);
|
||||
|
||||
if (p_rgh.needReference())
|
||||
{
|
||||
fvc::makeRelative(phiHbyA, U);
|
||||
adjustPhi(phiHbyA, U, p_rgh);
|
||||
fvc::makeAbsolute(phiHbyA, U);
|
||||
}
|
||||
|
||||
if (adjustFringe)
|
||||
{
|
||||
fvc::makeRelative(phiHbyA, U);
|
||||
oversetAdjustPhi(phiHbyA, U);
|
||||
fvc::makeAbsolute(phiHbyA, U);
|
||||
}
|
||||
|
||||
surfaceScalarField phig
|
||||
(
|
||||
(
|
||||
mixture.surfaceTensionForce()
|
||||
- ghf*fvc::snGrad(cellMask*rho)
|
||||
)*rAUf*faceMask*mesh.magSf()
|
||||
- ghf*fvc::snGrad(rho)
|
||||
)*faceMask*rAUf*mesh.magSf()
|
||||
);
|
||||
|
||||
phiHbyA += phig;
|
||||
|
||||
if (adjustFringe)
|
||||
{
|
||||
oversetAdjustPhi(phiHbyA, U, zoneIdMass);
|
||||
fvc::makeRelative(phiHbyA, U);
|
||||
oversetAdjustPhi(phiHbyA, U);
|
||||
fvc::makeAbsolute(phiHbyA, U);
|
||||
}
|
||||
|
||||
// Update the pressure BCs to ensure flux consistency
|
||||
@ -57,10 +90,6 @@
|
||||
U.correctBoundaryConditions();
|
||||
fvOptions.correct(U);
|
||||
}
|
||||
if (oversetPatchErrOutput)
|
||||
{
|
||||
oversetPatchPhiErr(p_rghEqn, phiHbyA);
|
||||
}
|
||||
}
|
||||
|
||||
#include "continuityErrs.H"
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
#include "readTimeControls.H"
|
||||
|
||||
correctPhi = pimple.dict().getOrDefault("correctPhi", false);
|
||||
|
||||
checkMeshCourantNo =
|
||||
pimple.dict().getOrDefault("checkMeshCourantNo", false);
|
||||
|
||||
moveMeshOuterCorrectors =
|
||||
pimple.dict().getOrDefault("moveMeshOuterCorrectors", false);
|
||||
|
||||
massFluxInterpolation =
|
||||
pimple.dict().getOrDefault("massFluxInterpolation", false);
|
||||
|
||||
ddtCorr = pimple.dict().getOrDefault("ddtCorr", true);
|
||||
|
||||
adjustFringe = pimple.dict().getOrDefault("oversetAdjustPhi", false);
|
||||
@ -0,0 +1,11 @@
|
||||
CorrectPhi
|
||||
(
|
||||
U,
|
||||
phi,
|
||||
p_rgh,
|
||||
surfaceScalarField("rAUf", fvc::interpolate(rAU)),
|
||||
divU,
|
||||
pimple
|
||||
);
|
||||
|
||||
#include "continuityErrs.H"
|
||||
@ -149,5 +149,10 @@ surfaceScalarField alphaPhi10
|
||||
// Mask field for zeroing out contributions on hole cells
|
||||
#include "createCellMask.H"
|
||||
|
||||
surfaceScalarField faceMask
|
||||
(
|
||||
localMin<scalar>(mesh).interpolate(cellMask)
|
||||
);
|
||||
|
||||
// Create bool field with interpolated cells
|
||||
#include "createInterpolatedCells.H"
|
||||
|
||||
@ -82,7 +82,9 @@ int main(int argc, char *argv[])
|
||||
#include "setRootCaseLists.H"
|
||||
#include "createTime.H"
|
||||
#include "createDynamicFvMesh.H"
|
||||
pimpleControl pimple(mesh);
|
||||
|
||||
#include "createTimeControls.H"
|
||||
#include "createDyMControls.H"
|
||||
#include "initContinuityErrs.H"
|
||||
#include "createFields.H"
|
||||
@ -116,7 +118,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
while (runTime.run())
|
||||
{
|
||||
#include "readDyMControls.H"
|
||||
#include "readControls.H"
|
||||
|
||||
// Store divU from the previous mesh so that it can be mapped
|
||||
// and used in correctPhi to ensure the corrected phi has the
|
||||
@ -151,10 +153,40 @@ int main(int argc, char *argv[])
|
||||
// Update cellMask field for blocking out hole cells
|
||||
#include "setCellMask.H"
|
||||
#include "setInterpolatedCells.H"
|
||||
#include "correctPhiFaceMask.H"
|
||||
|
||||
faceMask =
|
||||
localMin<scalar>(mesh).interpolate(cellMask.oldTime());
|
||||
|
||||
|
||||
// Zero Uf on old faceMask (H-I)
|
||||
Uf *= faceMask;
|
||||
|
||||
const surfaceVectorField Uint(fvc::interpolate(U));
|
||||
// Update Uf and phi on new C-I faces
|
||||
Uf += (1-faceMask)*Uint;
|
||||
|
||||
// Update Uf boundary
|
||||
forAll(Uf.boundaryField(), patchI)
|
||||
{
|
||||
Uf.boundaryFieldRef()[patchI] =
|
||||
Uint.boundaryField()[patchI];
|
||||
}
|
||||
|
||||
phi = mesh.Sf() & Uf;
|
||||
|
||||
if (correctPhi)
|
||||
{
|
||||
#include "correctPhi.H"
|
||||
}
|
||||
|
||||
mixture->correct();
|
||||
|
||||
// Zero phi on current H-I
|
||||
faceMask = localMin<scalar>(mesh).interpolate(cellMask);
|
||||
|
||||
phi *= faceMask;
|
||||
U *= cellMask;
|
||||
|
||||
// Make the flux relative to the mesh motion
|
||||
fvc::makeRelative(phi, U);
|
||||
}
|
||||
@ -182,6 +214,10 @@ int main(int argc, char *argv[])
|
||||
mixture->correct();
|
||||
|
||||
#include "alphaEqnSubCycle.H"
|
||||
const surfaceScalarField faceMask
|
||||
(
|
||||
localMin<scalar>(mesh).interpolate(cellMask)
|
||||
);
|
||||
rhoPhi *= faceMask;
|
||||
|
||||
interface.correct();
|
||||
|
||||
@ -8,6 +8,16 @@
|
||||
fvc::flux(HbyA)
|
||||
);
|
||||
|
||||
|
||||
if (ddtCorr)
|
||||
{
|
||||
surfaceScalarField faceMaskOld
|
||||
(
|
||||
localMin<scalar>(mesh).interpolate(cellMask.oldTime())
|
||||
);
|
||||
phiHbyA += faceMaskOld*fvc::ddtCorr(U, Uf);
|
||||
}
|
||||
|
||||
if (p_rgh.needReference())
|
||||
{
|
||||
fvc::makeRelative(phiHbyA, U);
|
||||
|
||||
@ -7,7 +7,6 @@ cd "${0%/*}" || exit # Run from this directory
|
||||
|
||||
library/Allwmake
|
||||
|
||||
# Does not use libOpenFOAM or libPstream...
|
||||
wmake -no-openfoam
|
||||
wmake
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/* Install into FOAM_APPBIN to support 'fake' builds (to test packaging) */
|
||||
Test-dummyLib.cpp
|
||||
Test-dummyLib.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/Test-dummyLib
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/* Install into central FOAM_LIBBIN for 'fake' builds (test packaging) */
|
||||
dummyLib.cpp
|
||||
dummyLib.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libTestDummy-OpenFOAM
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/* Install into central FOAM_LIBBIN/dummy for 'fake' builds (test packaging) */
|
||||
dummyMpiLib.cpp
|
||||
dummyMpiLib.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/dummy/libTestDummyMpi
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/* Install into central FOAM_MPI_LIBBIN for 'fake' builds (test packaging) */
|
||||
dummyMpiLib.cpp
|
||||
dummyMpiLib.C
|
||||
|
||||
LIB = $(FOAM_MPI_LIBBIN)/libTestDummyMpi
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -59,8 +59,7 @@ void print(const char* name, bool showLimits = true)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
std::cout<< "c++ = " << __cplusplus << '\n';
|
||||
std::cout<< "machine sizes\n---\n\n";
|
||||
std::cout<<"machine sizes\n---\n\n";
|
||||
|
||||
print<short>("short");
|
||||
print<int>("int");
|
||||
|
||||
@ -1,8 +0,0 @@
|
||||
#!/bin/sh
|
||||
cd "${0%/*}" || exit # Run from this directory
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Does not use libOpenFOAM or libPstream...
|
||||
wmake -no-openfoam
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -88,7 +88,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
while (buf1.size() > 2)
|
||||
{
|
||||
buf1.pop_front();
|
||||
(void) buf1.pop_front();
|
||||
}
|
||||
report(buf1);
|
||||
|
||||
@ -123,8 +123,6 @@ int main(int argc, char *argv[])
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
Info<< nl << "list: " << flatOutput(buf2.list()) << nl;
|
||||
|
||||
Info<< "normal: " << flatOutput(buf2) << nl;
|
||||
buf2.reverse();
|
||||
Info<< "reverse: " << flatOutput(buf2) << nl;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -152,15 +152,15 @@ int main(int argc, char *argv[])
|
||||
Info<< " => " << flatOutput(myList) << nl;
|
||||
|
||||
{
|
||||
myList.swapUp(myList.DLListBase::front());
|
||||
myList.swapUp(myList.DLListBase::back());
|
||||
myList.swapUp(myList.DLListBase::first());
|
||||
myList.swapUp(myList.DLListBase::last());
|
||||
|
||||
Info<< nl << "swapUp => " << flatOutput(myList) << nl;
|
||||
}
|
||||
|
||||
{
|
||||
myList.swapDown(myList.DLListBase::front());
|
||||
myList.swapDown(myList.DLListBase::back());
|
||||
myList.swapDown(myList.DLListBase::first());
|
||||
myList.swapDown(myList.DLListBase::last());
|
||||
|
||||
Info<< nl << "swapDown => " << flatOutput(myList) << nl;
|
||||
}
|
||||
|
||||
@ -28,6 +28,11 @@ License
|
||||
#include "DirLister.H"
|
||||
#include <dirent.h>
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
static const Foam::word extgz("gz");
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::DirLister::const_iterator::open(const fileName& dir)
|
||||
@ -105,9 +110,9 @@ Foam::word Foam::DirLister::next(DIR* dirPtr) const
|
||||
|
||||
if (ok)
|
||||
{
|
||||
if (fType == fileName::FILE && stripgz_ && name.has_ext("gz"))
|
||||
if (fType == fileName::FILE && stripgz_ && name.hasExt(extgz))
|
||||
{
|
||||
name.remove_ext();
|
||||
name = name.lessExt();
|
||||
}
|
||||
|
||||
if (!name.empty() && accept(name))
|
||||
|
||||
@ -189,12 +189,6 @@ int main(int argc, char *argv[])
|
||||
<< " hash:" << FixedList<label, 4>::hasher()(list1) << nl
|
||||
<< " hash:" << Hash<FixedList<label, 4>>()(list1) << nl;
|
||||
|
||||
Info<< "get<0>: " << list1.get<0>() << nl;
|
||||
Info<< "get<1>: " << list1.get<1>() << nl;
|
||||
Info<< "get<2>: " << list1.get<2>() << nl;
|
||||
Info<< "get<3>: " << list1.get<3>() << nl;
|
||||
// Will not compile: Info<< "get<4>: " << list1.get<4>() << nl;
|
||||
|
||||
label a[4] = {0, 1, 2, 3};
|
||||
FixedList<label, 4> list2(a);
|
||||
|
||||
|
||||
@ -113,6 +113,7 @@ int main(int argc, char *argv[])
|
||||
label coarseSize = max(addr)+1;
|
||||
|
||||
Info<< "Level : " << level << endl
|
||||
<< returnReduce(addr.size(), sumOp<label>()) << endl
|
||||
<< " current size : "
|
||||
<< returnReduce(addr.size(), sumOp<label>()) << endl
|
||||
<< " agglomerated size : "
|
||||
|
||||
@ -90,7 +90,7 @@ void writeAndRead
|
||||
const IOobject& io,
|
||||
const label sz,
|
||||
const word& writeType,
|
||||
IOobjectOption::readOption rOpt,
|
||||
const IOobject::readOption rOpt,
|
||||
const word& readType
|
||||
)
|
||||
{
|
||||
@ -208,8 +208,7 @@ int main(int argc, char *argv[])
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
|
||||
{
|
||||
@ -244,7 +243,9 @@ int main(int argc, char *argv[])
|
||||
args.executable(),
|
||||
"constant",
|
||||
runTime,
|
||||
IOobject::NO_REGISTER // implicit convert to IOobjectOption
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
);
|
||||
|
||||
labelList ints(identity(200));
|
||||
|
||||
@ -240,8 +240,13 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"merge",
|
||||
"test merging lists (requires -filter)"
|
||||
"copy-append",
|
||||
"test move append lists (requires -filter)"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"move-append",
|
||||
"test move append lists (requires -filter)"
|
||||
);
|
||||
|
||||
// timeSelector::addOptions();
|
||||
@ -256,10 +261,16 @@ int main(int argc, char *argv[])
|
||||
Info<<"limit names: " << matcher << nl;
|
||||
}
|
||||
|
||||
if (args.found("merge") && matcher.empty())
|
||||
if (args.found("copy-append") && matcher.empty())
|
||||
{
|
||||
FatalError
|
||||
<< nl << "The -merge test also requires -filter" << nl
|
||||
<< nl << "The -copy-append test also requires -filter" << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
if (args.found("move-append") && matcher.empty())
|
||||
{
|
||||
FatalError
|
||||
<< nl << "The -move-append test also requires -filter" << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
@ -316,9 +327,13 @@ int main(int argc, char *argv[])
|
||||
// On last time
|
||||
if (timeI == timeDirs.size()-1)
|
||||
{
|
||||
if (args.found("merge"))
|
||||
if (args.found("copy-append"))
|
||||
{
|
||||
Info<< nl << "Test merge" << nl;
|
||||
Info<< nl << "Test move append" << nl;
|
||||
}
|
||||
else if (args.found("move-append"))
|
||||
{
|
||||
Info<< nl << "Test move append" << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -334,8 +349,18 @@ int main(int argc, char *argv[])
|
||||
Info<< "==target==" << nl; reportDetail(objects);
|
||||
Info<< "==source==" << nl; reportDetail(other);
|
||||
|
||||
objects.merge(std::move(other));
|
||||
Info<< nl << "After merge" << nl;
|
||||
if (args.found("copy-append"))
|
||||
{
|
||||
objects.append(other);
|
||||
|
||||
Info<< nl << "After copy-append" << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
objects.append(std::move(other));
|
||||
|
||||
Info<< nl << "After move-append" << nl;
|
||||
}
|
||||
|
||||
Info<< "==target==" << nl; reportDetail(objects);
|
||||
Info<< "==source==" << nl; reportDetail(other);
|
||||
|
||||
@ -101,9 +101,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
printInfo(idl1);
|
||||
|
||||
Info<< "list() = ";
|
||||
idl1.list().writeList(Info, 0) << endl;
|
||||
|
||||
for (const label val : { 10, 30, 40, 50, 90, 80, 120 } )
|
||||
{
|
||||
testFind(val, idl1);
|
||||
@ -185,7 +182,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// MPI barrier
|
||||
bool barrier = true;
|
||||
Pstream::broadcast(barrier);
|
||||
Pstream::scatter(barrier);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -83,9 +83,9 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
IOstreamOption streamOpt;
|
||||
|
||||
if (outputName.has_ext("gz"))
|
||||
if (outputName.hasExt("gz"))
|
||||
{
|
||||
outputName.remove_ext();
|
||||
outputName.removeExt();
|
||||
streamOpt.compression(IOstreamOption::COMPRESSED);
|
||||
}
|
||||
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
Test-OFstream.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-OFstream
|
||||
@ -1,2 +0,0 @@
|
||||
/* EXE_INC = */
|
||||
/* EXE_LIBS = */
|
||||
@ -1,228 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2022 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/>.
|
||||
|
||||
Description
|
||||
Test OFstream. Primarily atomic operations
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "Fstream.H"
|
||||
#include "IOstreams.H"
|
||||
#include "OSspecific.H"
|
||||
#include "argList.H"
|
||||
#include "ListOps.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
void listFiles(const fileName& dir)
|
||||
{
|
||||
wordList files = ListOps::create<word>
|
||||
(
|
||||
readDir(dir, fileName::FILE),
|
||||
nameOp<fileName>()
|
||||
);
|
||||
|
||||
Info
|
||||
<< nl
|
||||
<< "files:" << nl
|
||||
<< files << nl
|
||||
<< "ls" << nl
|
||||
<< "============" << endl;
|
||||
Foam::system("ls -al " + dir);
|
||||
Info<< "============" << endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::addBoolOption("gz", "Use compression");
|
||||
argList::addBoolOption("append", "Use append mode");
|
||||
argList::addBoolOption("atomic", "Use atomic");
|
||||
argList::addBoolOption("keep", "Do not remove test directory");
|
||||
argList::addOption("write", "file", "test writing to file");
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
const fileName baseDir("Test-OFstream-directory");
|
||||
|
||||
Foam::mkDir(baseDir);
|
||||
|
||||
InfoErr<< "mkdir: " << baseDir << endl;
|
||||
|
||||
IOstreamOption streamOpt;
|
||||
|
||||
if (args.found("gz"))
|
||||
{
|
||||
streamOpt.compression(IOstreamOption::COMPRESSED);
|
||||
}
|
||||
|
||||
IOstreamOption::appendType append =
|
||||
(
|
||||
args.found("append")
|
||||
? IOstreamOption::APPEND
|
||||
: IOstreamOption::NON_APPEND
|
||||
);
|
||||
IOstreamOption::atomicType atomic =
|
||||
(
|
||||
args.found("atomic")
|
||||
? IOstreamOption::ATOMIC
|
||||
: IOstreamOption::NON_ATOMIC
|
||||
);
|
||||
|
||||
{
|
||||
OFstream(baseDir/"dummy")() << "Some file content" << endl;
|
||||
|
||||
Foam::ln("dummy", baseDir/"Test2.txt");
|
||||
Foam::ln("dummy", baseDir/"Test3.txt");
|
||||
Foam::ln("dummy", baseDir/"Test4.txt");
|
||||
Foam::ln("dummy", baseDir/"Test4.txt.gz");
|
||||
Foam::ln("dummy", baseDir/"Test5.txt");
|
||||
Foam::ln("dummy", baseDir/"Test5.txt.gz");
|
||||
}
|
||||
|
||||
{
|
||||
OFstream os
|
||||
(
|
||||
atomic,
|
||||
baseDir/"Test1.txt",
|
||||
streamOpt,
|
||||
append
|
||||
);
|
||||
|
||||
os << "=========================" << endl;
|
||||
|
||||
InfoErr<< "open: " << os.name() << endl;
|
||||
InfoErr<< "... sleep" << endl;
|
||||
|
||||
listFiles(baseDir);
|
||||
|
||||
sleep(2);
|
||||
|
||||
os << "+++++++++++++++++++++++++++++++++++" << endl;
|
||||
}
|
||||
|
||||
{
|
||||
OFstream os
|
||||
(
|
||||
atomic,
|
||||
baseDir/"Test2.txt",
|
||||
streamOpt
|
||||
// NON_APPEND
|
||||
);
|
||||
|
||||
os << "=========================" << endl;
|
||||
|
||||
InfoErr<< "open: " << os.name() << endl;
|
||||
InfoErr<< "... sleep" << endl;
|
||||
|
||||
listFiles(baseDir);
|
||||
|
||||
sleep(2);
|
||||
|
||||
os << "+++++++++++++++++++++++++++++++++++" << endl;
|
||||
}
|
||||
{
|
||||
OFstream os
|
||||
(
|
||||
atomic,
|
||||
baseDir/"Test3.txt",
|
||||
streamOpt,
|
||||
IOstreamOption::APPEND
|
||||
);
|
||||
|
||||
os << "=========================" << endl;
|
||||
|
||||
InfoErr<< "open: " << os.name() << endl;
|
||||
InfoErr<< "... sleep" << endl;
|
||||
|
||||
listFiles(baseDir);
|
||||
|
||||
sleep(2);
|
||||
|
||||
os << "+++++++++++++++++++++++++++++++++++" << endl;
|
||||
}
|
||||
{
|
||||
OFstream os
|
||||
(
|
||||
baseDir/"Test4.txt",
|
||||
IOstreamOption::ASCII,
|
||||
IOstreamOption::COMPRESSED
|
||||
);
|
||||
|
||||
os << "=========================" << endl;
|
||||
|
||||
InfoErr<< "open: " << os.name() << endl;
|
||||
InfoErr<< "... sleep" << endl;
|
||||
|
||||
listFiles(baseDir);
|
||||
|
||||
sleep(2);
|
||||
|
||||
os << "+++++++++++++++++++++++++++++++++++" << endl;
|
||||
}
|
||||
{
|
||||
OFstream os
|
||||
(
|
||||
IOstreamOption::ATOMIC,
|
||||
baseDir/"Test5.txt"
|
||||
// ASCII UNCOMPRESSED NON_APPEND
|
||||
);
|
||||
|
||||
os << "=========================" << endl;
|
||||
|
||||
InfoErr<< "open: " << os.name() << endl;
|
||||
InfoErr<< "... sleep" << endl;
|
||||
|
||||
listFiles(baseDir);
|
||||
|
||||
sleep(2);
|
||||
|
||||
os << "+++++++++++++++++++++++++++++++++++" << endl;
|
||||
}
|
||||
|
||||
Info<< nl << "done:" << endl;
|
||||
|
||||
listFiles(baseDir);
|
||||
|
||||
if (args.found("keep"))
|
||||
{
|
||||
InfoErr<< "keep: " << baseDir << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
InfoErr<< "rmdir: " << baseDir << endl;
|
||||
Foam::rmDir(baseDir);
|
||||
}
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -108,7 +108,7 @@ Ostream& printAddr
|
||||
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
os << "addr=" << Foam::name(list.get(i)) << nl;
|
||||
os << "addr=" << name(list(i)) << nl;
|
||||
}
|
||||
|
||||
// End delimiter
|
||||
@ -140,7 +140,7 @@ Ostream& print
|
||||
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
const T* ptr = list.get(i);
|
||||
const T* ptr = list(i);
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
@ -174,7 +174,7 @@ Ostream& print
|
||||
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
const T* ptr = list.get(i);
|
||||
const T* ptr = list(i);
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
@ -192,7 +192,7 @@ Ostream& print
|
||||
|
||||
for (label i=len; i < cap; ++i)
|
||||
{
|
||||
const T* ptr = list.get(i);
|
||||
const T* ptr = list(i);
|
||||
|
||||
os << "unused " << name(ptr) << nl;
|
||||
}
|
||||
@ -274,9 +274,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
{
|
||||
DLPtrList<Scalar> llist1;
|
||||
llist1.push_front(new Scalar(100));
|
||||
llist1.push_front(new Scalar(200));
|
||||
llist1.push_front(new Scalar(300));
|
||||
llist1.prepend(new Scalar(100));
|
||||
llist1.prepend(new Scalar(200));
|
||||
llist1.prepend(new Scalar(300));
|
||||
|
||||
auto citer = llist1.begin();
|
||||
|
||||
@ -305,9 +305,9 @@ int main(int argc, char *argv[])
|
||||
// Same but as SLPtrList
|
||||
{
|
||||
SLPtrList<Scalar> llist1;
|
||||
llist1.push_front(new Scalar(100));
|
||||
llist1.push_front(new Scalar(200));
|
||||
llist1.push_front(new Scalar(300));
|
||||
llist1.prepend(new Scalar(100));
|
||||
llist1.prepend(new Scalar(200));
|
||||
llist1.prepend(new Scalar(300));
|
||||
|
||||
for (const auto& it : llist1)
|
||||
{
|
||||
@ -334,7 +334,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
listApp.append(new Scalar(1.3*i));
|
||||
}
|
||||
listApp.emplace_back(100);
|
||||
listApp.emplace_append(100);
|
||||
|
||||
|
||||
Info<< nl
|
||||
@ -580,8 +580,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
PtrList<plane> planes;
|
||||
planes.emplace_back(vector::one, vector::one);
|
||||
planes.emplace_back(vector(1,2,3), vector::one);
|
||||
planes.emplace_append(vector::one, vector::one);
|
||||
planes.emplace_append(vector(1,2,3), vector::one);
|
||||
|
||||
Info<< nl << "appended values" << nl;
|
||||
for (const plane& p : planes)
|
||||
@ -594,15 +594,15 @@ int main(int argc, char *argv[])
|
||||
PtrDynList<plane> dynPlanes;
|
||||
|
||||
{
|
||||
dynPlanes.emplace_back(vector::one, vector::one);
|
||||
dynPlanes.emplace_back(vector(1,2,3), vector::one);
|
||||
dynPlanes.emplace_append(vector::one, vector::one);
|
||||
dynPlanes.emplace_append(vector(1,2,3), vector::one);
|
||||
dynPlanes.append(nullptr);
|
||||
|
||||
dynPlanes.set(6, new plane(vector(2,2,1), vector::one));
|
||||
dynPlanes.set(10, new plane(vector(4,5,6), vector::one));
|
||||
|
||||
dynPlanes.emplace(12, vector(3,2,1), vector::one);
|
||||
dynPlanes.emplace_back(Zero, vector::one);
|
||||
dynPlanes.emplace_append(Zero, vector::one);
|
||||
}
|
||||
|
||||
Info<< nl << "PtrDynList: ";
|
||||
@ -633,7 +633,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
forAll(dynPlanes, i)
|
||||
{
|
||||
const plane* pln = dynPlanes.get(i);
|
||||
const plane* pln = dynPlanes.set(i);
|
||||
if (pln)
|
||||
{
|
||||
stdPlanes.set(i, new plane(*pln));
|
||||
|
||||
@ -138,8 +138,8 @@ int main()
|
||||
maxFirstEqOp<label>()(maxIndexed, item);
|
||||
}
|
||||
|
||||
Pstream::combineReduce(minIndexed, minFirstEqOp<label>());
|
||||
Pstream::combineReduce(maxIndexed, maxFirstEqOp<label>());
|
||||
Pstream::combineAllGather(minIndexed, minFirstEqOp<label>());
|
||||
Pstream::combineAllGather(maxIndexed, maxFirstEqOp<label>());
|
||||
|
||||
Info<< "Min indexed: " << minIndexed << nl
|
||||
<< "Max indexed: " << maxIndexed << nl;
|
||||
@ -156,8 +156,8 @@ int main()
|
||||
maxIndexed = maxFirstOp<label>()(maxIndexed, item);
|
||||
}
|
||||
|
||||
Pstream::combineReduce(minIndexed, minFirstEqOp<label>());
|
||||
Pstream::combineReduce(maxIndexed, maxFirstEqOp<label>());
|
||||
Pstream::combineAllGather(minIndexed, minFirstEqOp<label>());
|
||||
Pstream::combineAllGather(maxIndexed, maxFirstEqOp<label>());
|
||||
|
||||
Info<< "Min indexed: " << minIndexed << nl
|
||||
<< "Max indexed: " << maxIndexed << nl;
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -43,7 +43,7 @@ void print(const boolVector& v)
|
||||
<< " any:" << Switch::name(v.any())
|
||||
<< " all:" << Switch::name(v.all())
|
||||
<< " none:" << Switch::name(v.none())
|
||||
<< " on:" << v.count() << " off:" << v.count(false) << nl;
|
||||
<< " count:" << v.count() << nl;
|
||||
}
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@ int main(int argc, char *argv[])
|
||||
Info<< nl;
|
||||
|
||||
{
|
||||
boolVector vec(1, 0, 1);
|
||||
boolVector vec{1, 0, 1};
|
||||
print(vec);
|
||||
|
||||
vec.flip();
|
||||
|
||||
@ -1,2 +1,7 @@
|
||||
/* EXE_INC = */
|
||||
/* EXE_LIBS = */
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lmeshTools
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -31,9 +31,9 @@ Description
|
||||
#include "argList.H"
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
#include "line.H"
|
||||
#include "Random.H"
|
||||
#include "boundBox.H"
|
||||
#include "treeBoundBox.H"
|
||||
#include "cellModel.H"
|
||||
#include "bitSet.H"
|
||||
#include "HashSet.H"
|
||||
#include "ListOps.H"
|
||||
@ -58,7 +58,8 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
#include "setRootCase.H"
|
||||
|
||||
Info<<"boundBox faces: " << boundBox::hexFaces() << nl
|
||||
Info<<"boundBox faces: " << boundBox::faces << nl
|
||||
<<"hex faces: " << cellModel::ref(cellModel::HEX).modelFaces() << nl
|
||||
<<"tree-bb faces: " << treeBoundBox::faces << nl
|
||||
<<"tree-bb edges: " << treeBoundBox::edges << endl;
|
||||
|
||||
@ -83,20 +84,7 @@ int main(int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
bb = cube(0, 1);
|
||||
Info<< "starting box: " << bb << endl;
|
||||
|
||||
Info<< "corner: " << bb.hexCorner<0>() << nl
|
||||
<< "corner: " << bb.hexCorner<7>() << nl
|
||||
<< "corner: " << bb.hexCorner<6>() << endl;
|
||||
|
||||
linePoints ln1(bb.max(), bb.centre());
|
||||
Info<< "line: " << ln1 << " box: " << ln1.box() << endl;
|
||||
|
||||
Info<< "box: " << boundBox(ln1.box()) << endl;
|
||||
|
||||
Info<< "corner: " << bb.hexCorner<0>() << nl
|
||||
<< "corner: " << bb.hexCorner<7>() << nl
|
||||
<< "corner: " << bb.hexCorner<6>() << endl;
|
||||
Info<<"starting box: " << bb << endl;
|
||||
|
||||
point pt(Zero);
|
||||
bb.add(pt);
|
||||
@ -111,8 +99,10 @@ int main(int argc, char *argv[])
|
||||
Info<<"enclose point " << pt << " -> " << bb << endl;
|
||||
|
||||
// restart with same points
|
||||
bb.reset(point::zero);
|
||||
bb.add(point(1,1,1), point(0,1.5,0.5));
|
||||
bb = boundBox::invertedBox;
|
||||
bb.add(point(1,1,1));
|
||||
bb.add(point::zero);
|
||||
bb.add(point(0,1.5,0.5));
|
||||
bb.add(point(5,2,-2));
|
||||
|
||||
Info<<"repeated " << bb << endl;
|
||||
@ -157,25 +147,6 @@ int main(int argc, char *argv[])
|
||||
Info<< "box is now => " << box1 << endl;
|
||||
}
|
||||
|
||||
List<boundBox> boxes(12);
|
||||
{
|
||||
Random rndGen(12345);
|
||||
for (auto& bb : boxes)
|
||||
{
|
||||
bb = cube
|
||||
(
|
||||
rndGen.position<scalar>(-10, 10),
|
||||
rndGen.position<scalar>(0, 5)
|
||||
);
|
||||
}
|
||||
|
||||
Info<< "boxes: " << boxes << endl;
|
||||
|
||||
Foam::sort(boxes);
|
||||
|
||||
Info<< "sorted: " << boxes << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
Test-boundBox2.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-boundBox2
|
||||
@ -1,2 +0,0 @@
|
||||
/* EXE_INC = */
|
||||
/* EXE_LIBS = */
|
||||
@ -1,235 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2022 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/>.
|
||||
|
||||
Description
|
||||
Test bounding box behaviour
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
#include "line.H"
|
||||
#include "Random.H"
|
||||
#include "treeBoundBox.H"
|
||||
#include "bitSet.H"
|
||||
#include "HashSet.H"
|
||||
#include "ListOps.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
//- simple helper to create a cube, given lower corner and width
|
||||
boundBox cube(scalar start, scalar width)
|
||||
{
|
||||
return boundBox
|
||||
(
|
||||
point::uniform(start),
|
||||
point::uniform(start + width)
|
||||
);
|
||||
}
|
||||
|
||||
//- simple helper to create a cube, given mid-point and width
|
||||
boundBox cubeAt(const point& mid, scalar width)
|
||||
{
|
||||
boundBox bb(mid);
|
||||
bb.grow(0.5*width);
|
||||
|
||||
return bb;
|
||||
}
|
||||
|
||||
|
||||
word faceName(direction whichFace)
|
||||
{
|
||||
switch (whichFace)
|
||||
{
|
||||
case treeBoundBox::LEFT : return "-x";
|
||||
case treeBoundBox::RIGHT : return "+x";
|
||||
|
||||
case treeBoundBox::BOTTOM : return "-y";
|
||||
case treeBoundBox::TOP : return "+y";
|
||||
|
||||
case treeBoundBox::BACK : return "-z";
|
||||
case treeBoundBox::FRONT : return "+z";
|
||||
}
|
||||
|
||||
return "??";
|
||||
}
|
||||
|
||||
|
||||
word octantName(direction octant)
|
||||
{
|
||||
word str("-x-y-z");
|
||||
|
||||
if (octant & treeBoundBox::RIGHTHALF)
|
||||
{
|
||||
str[0] = '+';
|
||||
}
|
||||
if (octant & treeBoundBox::TOPHALF)
|
||||
{
|
||||
str[2] = '+';
|
||||
}
|
||||
if (octant & treeBoundBox::FRONTHALF)
|
||||
{
|
||||
str[4] = '+';
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
void testOverlaps(const treeBoundBox& bb, const treeBoundBox& searchBox)
|
||||
{
|
||||
FixedList<bool, 8> overlaps;
|
||||
|
||||
for (direction octant = 0; octant < 8; ++octant)
|
||||
{
|
||||
overlaps[octant] = bb.subOverlaps(octant, searchBox);
|
||||
}
|
||||
|
||||
Info<< "box " << bb << " and " << searchBox << nl;
|
||||
|
||||
Info<< "overlaps any:" << bb.overlaps(searchBox)
|
||||
<< " octants: " << overlaps << nl;
|
||||
}
|
||||
|
||||
|
||||
void testOverlaps
|
||||
(
|
||||
const treeBoundBox& bb,
|
||||
const point& sample,
|
||||
const scalar nearestDistSqr
|
||||
)
|
||||
{
|
||||
FixedList<bool, 8> overlaps;
|
||||
|
||||
for (direction octant = 0; octant < 8; ++octant)
|
||||
{
|
||||
overlaps[octant] = bb.subOverlaps(octant, sample, nearestDistSqr);
|
||||
}
|
||||
|
||||
Info<< "box " << bb << " and "
|
||||
<< sample << " distSqr:" << nearestDistSqr << nl;
|
||||
|
||||
Info<< "overlaps any:" << bb.overlaps(sample, nearestDistSqr)
|
||||
<< " octants: " << overlaps << nl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#include "setRootCase.H"
|
||||
|
||||
treeBoundBox bb(cube(0, 1));
|
||||
treeBoundBox sub(cube(0.1, 0.8));
|
||||
|
||||
Info<< nl
|
||||
<< "box: " << bb << nl;
|
||||
|
||||
Info<< nl;
|
||||
for (direction octant = 0; octant < 8; ++octant)
|
||||
{
|
||||
Info<< "octant:" << octant
|
||||
<< " (" << octantName(octant) << ") = "
|
||||
<< bb.subBbox(octant) << nl;
|
||||
}
|
||||
|
||||
Info<< nl;
|
||||
for (direction facei = 0; facei < 6; ++facei)
|
||||
{
|
||||
Info<< "sub-half:" << facei
|
||||
<< " (" << faceName(facei) << ") = "
|
||||
<< bb.subHalf(facei) << nl;
|
||||
}
|
||||
|
||||
Info<< nl;
|
||||
for (direction octant = 0; octant < 8; ++octant)
|
||||
{
|
||||
const point pt = sub.corner(octant);
|
||||
const direction subOctant = bb.subOctant(pt);
|
||||
|
||||
Info<< "point:" << pt
|
||||
<< " in octant " << subOctant
|
||||
<< " sub-box: " << bb.subBbox(subOctant) << nl;
|
||||
}
|
||||
|
||||
for (const scalar dist : {0.1})
|
||||
{
|
||||
Info<< nl;
|
||||
for (direction octant = 0; octant < 8; ++octant)
|
||||
{
|
||||
treeBoundBox searchBox(cubeAt(bb.corner(octant), dist));
|
||||
testOverlaps(bb, searchBox);
|
||||
}
|
||||
|
||||
Info<< nl;
|
||||
for (direction facei = 0; facei < 6; ++facei)
|
||||
{
|
||||
treeBoundBox searchBox(cubeAt(bb.faceCentre(facei), dist));
|
||||
testOverlaps(bb, searchBox);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
treeBoundBox largerBox(bb);
|
||||
largerBox.grow(0.2);
|
||||
|
||||
// Checking at corners,
|
||||
// larger by 0.2 in three directions: radius = 0.3464
|
||||
|
||||
for (const scalar dist : {0.1, 0.35})
|
||||
{
|
||||
const scalar distSqr = sqr(dist);
|
||||
|
||||
Info<< nl;
|
||||
for (direction octant = 0; octant < 8; ++octant)
|
||||
{
|
||||
testOverlaps(bb, largerBox.corner(octant), distSqr);
|
||||
}
|
||||
}
|
||||
|
||||
// Checking at face centres,
|
||||
// larger by 0.2 in a single direction
|
||||
|
||||
for (const scalar dist : {0.1, 0.25})
|
||||
{
|
||||
const scalar distSqr = sqr(dist);
|
||||
|
||||
Info<< nl;
|
||||
for (direction facei = 0; facei < 6; ++facei)
|
||||
{
|
||||
testOverlaps(bb, largerBox.faceCentre(facei), distSqr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Info<< nl << "End" << nl << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -59,11 +59,11 @@ void basicTests(const coordinateSystem& cs)
|
||||
{
|
||||
cs.writeEntry(cs.name(), Info);
|
||||
|
||||
if ((const auto* cartptr = isA<coordSystem::cartesian>(cs)) != nullptr)
|
||||
if (const auto* cartptr = isA<coordSystem::cartesian>(cs))
|
||||
{
|
||||
if (!cartptr->valid())
|
||||
if (!cartptr->active())
|
||||
{
|
||||
Info<< "invalid cartesian = " << (*cartptr)
|
||||
Info<< "inactive cartesian = " << (*cartptr)
|
||||
<< " with: " << (*cartptr).R() << nl;
|
||||
}
|
||||
}
|
||||
@ -106,7 +106,7 @@ void doTest(const dictionary& dict)
|
||||
|
||||
try
|
||||
{
|
||||
auto cs1ptr = coordinateSystem::New(dict, word::null);
|
||||
auto cs1ptr = coordinateSystem::New(dict, "");
|
||||
coordinateSystem& cs1 = *cs1ptr;
|
||||
cs1.rename(dict.dictName());
|
||||
|
||||
|
||||
@ -51,8 +51,11 @@ cs4
|
||||
{
|
||||
type cylindrical;
|
||||
origin (0 3 5);
|
||||
rotation euler;
|
||||
angles (90 0 0);
|
||||
rotation
|
||||
{
|
||||
type euler;
|
||||
angles (90 0 0);
|
||||
}
|
||||
}
|
||||
|
||||
cyl
|
||||
@ -72,7 +75,10 @@ cyl
|
||||
ident
|
||||
{
|
||||
origin (0 0 0);
|
||||
rotation none;
|
||||
rotation
|
||||
{
|
||||
type none;
|
||||
}
|
||||
}
|
||||
|
||||
)
|
||||
|
||||
@ -26,7 +26,7 @@ rot_x90
|
||||
rot_x90_axesRotation
|
||||
{
|
||||
origin (0 0 0);
|
||||
rotation
|
||||
coordinateRotation
|
||||
{
|
||||
type axesRotation;
|
||||
e1 (1 0 0);
|
||||
@ -37,7 +37,7 @@ rot_x90_axesRotation
|
||||
rot_x90_axisAngle
|
||||
{
|
||||
origin (0 0 0);
|
||||
rotation
|
||||
coordinateRotation
|
||||
{
|
||||
type axisAngle;
|
||||
axis (1 0 0); // non-unit also OK
|
||||
@ -48,7 +48,7 @@ rot_x90_axisAngle
|
||||
rot_x90_euler
|
||||
{
|
||||
origin (0 0 0);
|
||||
rotation
|
||||
coordinateRotation
|
||||
{
|
||||
type euler;
|
||||
angles (0 90 0); // z-x'-z''
|
||||
@ -61,7 +61,7 @@ rot_x90_euler
|
||||
rot_z45_axesRotation
|
||||
{
|
||||
origin (0 0 0);
|
||||
rotation
|
||||
coordinateRotation
|
||||
{
|
||||
type axesRotation;
|
||||
e1 (1 1 0);
|
||||
@ -72,7 +72,7 @@ rot_z45_axesRotation
|
||||
rot_z45_axisAngle
|
||||
{
|
||||
origin (0 0 0);
|
||||
rotation
|
||||
coordinateRotation
|
||||
{
|
||||
type axisAngle;
|
||||
axis (0 0 10); // non-unit also OK
|
||||
@ -83,7 +83,7 @@ rot_z45_axisAngle
|
||||
rot_z45_euler
|
||||
{
|
||||
origin (0 0 0);
|
||||
rotation
|
||||
coordinateRotation
|
||||
{
|
||||
type euler;
|
||||
angles (45 0 0); // z-x'-z''
|
||||
@ -93,7 +93,7 @@ rot_z45_euler
|
||||
rot_z45_starcd
|
||||
{
|
||||
origin (0 0 0);
|
||||
rotation
|
||||
coordinateRotation
|
||||
{
|
||||
type starcd;
|
||||
angles (45 0 0); // z-x'-y''
|
||||
@ -106,7 +106,7 @@ rot_z45_starcd
|
||||
rot_zm45_axesRotation
|
||||
{
|
||||
origin (0 0 0);
|
||||
rotation
|
||||
coordinateRotation
|
||||
{
|
||||
type axesRotation;
|
||||
e1 (1 -1 0);
|
||||
@ -117,7 +117,7 @@ rot_zm45_axesRotation
|
||||
rot_zm45_axisAngle
|
||||
{
|
||||
origin (0 0 0);
|
||||
rotation
|
||||
coordinateRotation
|
||||
{
|
||||
type axisAngle;
|
||||
axis (0 0 10); // non-unit also OK
|
||||
@ -128,7 +128,7 @@ rot_zm45_axisAngle
|
||||
rot_zm45_euler
|
||||
{
|
||||
origin (0 0 0);
|
||||
rotation
|
||||
coordinateRotation
|
||||
{
|
||||
type euler;
|
||||
angles (-45 0 0); // z-x'-z''
|
||||
@ -141,7 +141,7 @@ rot_zm45_euler
|
||||
null_axesRotation
|
||||
{
|
||||
origin (0 0 0);
|
||||
rotation
|
||||
coordinateRotation
|
||||
{
|
||||
type axesRotation;
|
||||
e1 (1 0 0);
|
||||
@ -152,7 +152,7 @@ null_axesRotation
|
||||
null_axisAngle0
|
||||
{
|
||||
origin (0 0 0);
|
||||
rotation
|
||||
coordinateRotation
|
||||
{
|
||||
type axisAngle;
|
||||
axis (0 0 0); // non-unit also OK
|
||||
@ -163,7 +163,7 @@ null_axisAngle0
|
||||
null_axisAngle1
|
||||
{
|
||||
origin (0 0 0);
|
||||
rotation
|
||||
coordinateRotation
|
||||
{
|
||||
type axisAngle;
|
||||
axis (1 1 1); // non-unit also OK
|
||||
@ -174,7 +174,7 @@ null_axisAngle1
|
||||
null_euler
|
||||
{
|
||||
origin (0 0 0);
|
||||
rotation
|
||||
coordinateRotation
|
||||
{
|
||||
type euler;
|
||||
angles (0 0 0); // z-x'-z''
|
||||
|
||||
@ -60,7 +60,7 @@ int main(int argc, char *argv[])
|
||||
Info<< "Reading " << file << nl << endl;
|
||||
decomposedBlockData data
|
||||
(
|
||||
UPstream::worldComm,
|
||||
Pstream::worldComm,
|
||||
IOobject
|
||||
(
|
||||
file,
|
||||
@ -79,6 +79,7 @@ int main(int argc, char *argv[])
|
||||
(
|
||||
objPath,
|
||||
IOstreamOption::BINARY,
|
||||
IOstreamOption::currentVersion,
|
||||
runTime.writeCompression()
|
||||
);
|
||||
if (!os.good())
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -65,7 +65,8 @@ int main(int argc, char *argv[])
|
||||
"tensor",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
{ IOobject::READ_IF_PRESENT, IOobject::NO_REGISTER }
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensioned<tensor>(dimless, tensor(1,2,3,4,5,6,7,8,9))
|
||||
@ -74,47 +75,6 @@ int main(int argc, char *argv[])
|
||||
Info().beginBlock("transformed")
|
||||
<< tensorfld.T() << nl;
|
||||
Info().endBlock();
|
||||
|
||||
{
|
||||
auto tfld =
|
||||
DimensionedField<scalar, volMesh>::New
|
||||
(
|
||||
tensorfld,
|
||||
"scalar",
|
||||
dimensioned<scalar>(14)
|
||||
);
|
||||
|
||||
Info().beginBlock(tfld().type())
|
||||
<< tfld << nl;
|
||||
Info().endBlock();
|
||||
}
|
||||
|
||||
{
|
||||
auto tfld =
|
||||
volScalarField::New
|
||||
(
|
||||
"scalar",
|
||||
tensorfld.mesh(),
|
||||
dimensioned<scalar>(5)
|
||||
);
|
||||
|
||||
Info().beginBlock(tfld().type())
|
||||
<< tfld() << nl;
|
||||
Info().endBlock();
|
||||
|
||||
// From dissimilar types
|
||||
auto tfld2 =
|
||||
volVectorField::New
|
||||
(
|
||||
tfld(),
|
||||
"vector",
|
||||
dimensioned<vector>(Zero)
|
||||
);
|
||||
|
||||
Info().beginBlock(tfld2().type())
|
||||
<< tfld2() << nl;
|
||||
Info().endBlock();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TEST_UINT8_FIELD
|
||||
|
||||
@ -67,7 +67,7 @@ int main(int argc, char *argv[])
|
||||
Info<<"collapse? -> " << e4.collapse() << endl;
|
||||
printInfo(e4);
|
||||
|
||||
Info<< e3 << " connects " << e2 << " => " << e2.connected(e3) << endl;
|
||||
Info<< e3 << " connects " << e2 << " => " << e2.connects(e3) << endl;
|
||||
|
||||
labelPair labels(e3);
|
||||
|
||||
|
||||
@ -120,8 +120,7 @@ int main(int argc, char *argv[])
|
||||
try
|
||||
{
|
||||
// Should not trigger any errors
|
||||
auto expr = expressions::exprString::toExpr(str, dict);
|
||||
|
||||
expressions::exprString expr(str, dict, false);
|
||||
Info<< "expr: " << expr << nl;
|
||||
}
|
||||
catch (const Foam::error& err)
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -33,7 +33,6 @@ Description
|
||||
|
||||
#include "argList.H"
|
||||
#include "labelledTri.H"
|
||||
#include "edge.H"
|
||||
#include "faceList.H"
|
||||
#include "triFaceList.H"
|
||||
#include "pointList.H"
|
||||
@ -132,25 +131,10 @@ int main(int argc, char *argv[])
|
||||
testSign(f1, points2, testPoints);
|
||||
Info<< nl;
|
||||
|
||||
// Initializer list
|
||||
// triFace t1({1, 2, 3});
|
||||
|
||||
// Component-wise
|
||||
{
|
||||
edge e1(3, 2, 1); // Inadvertent sort!!!
|
||||
Info<< "edge:" << e1 << nl;
|
||||
}
|
||||
|
||||
// Component-wise
|
||||
triFace t1(1, 2, 3);
|
||||
triFace t1({1, 2, 3});
|
||||
Info<< "triFace:"; faceInfo(t1, points1); Info << nl;
|
||||
testSign(t1, points1, testPoints);
|
||||
|
||||
{
|
||||
scalarField fld({0, 20, 20, 30});
|
||||
Info<< "avg:" << t1.average(pointField::null(), fld) << nl;
|
||||
}
|
||||
|
||||
Info<< "triFace:"; faceInfo(t1, points2); Info << nl;
|
||||
testSign(t1, points2, testPoints);
|
||||
Info<< nl;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -48,14 +48,6 @@ Description
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// Create named file with some dummy content
|
||||
void touchFileContent(const fileName& file)
|
||||
{
|
||||
std::ofstream os(file);
|
||||
os << "file=<" << file << ">" << nl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
unsigned testClean(std::initializer_list<Pair<std::string>> tests)
|
||||
@ -268,7 +260,7 @@ int main(int argc, char *argv[])
|
||||
"hello1",
|
||||
"hello2",
|
||||
"hello3",
|
||||
"hello4.ext"
|
||||
"hello4.hmm"
|
||||
};
|
||||
|
||||
Info<< file1 << nl;
|
||||
@ -278,7 +270,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
file1,
|
||||
"some",
|
||||
"more/things.ext"
|
||||
"more/things.hmm"
|
||||
};
|
||||
|
||||
Info<< file2 << nl;
|
||||
@ -289,7 +281,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
std::string("ffO"),
|
||||
"some",
|
||||
"more/things.ext"
|
||||
"more/things.hmm"
|
||||
};
|
||||
Info<< file3 << nl;
|
||||
|
||||
@ -303,7 +295,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
"some",
|
||||
file3,
|
||||
"more/things.ext",
|
||||
"more/things.hmm",
|
||||
file1
|
||||
};
|
||||
Info<< "All ==> " << file4 << nl;
|
||||
@ -336,26 +328,26 @@ int main(int argc, char *argv[])
|
||||
fileName input1("path.to/media/image.png");
|
||||
|
||||
Info<<"File : " << input0 << " ext: "
|
||||
<< Switch(input0.has_ext())
|
||||
<< Switch(input0.hasExt())
|
||||
<< " = " << input0.ext() << nl;
|
||||
Info<<"File : " << input1 << " ext: "
|
||||
<< Switch(input1.has_ext())
|
||||
<< Switch(input1.hasExt())
|
||||
<< " = " << input1.ext() << nl;
|
||||
Info<<"File : " << endWithDot << " ext: "
|
||||
<< Switch(endWithDot.has_ext())
|
||||
<< Switch(endWithDot.hasExt())
|
||||
<< " = " << endWithDot.ext() << " <-- perhaps return false?" << nl;
|
||||
Info<<"File : " << endWithSlash << " ext: "
|
||||
<< Switch(endWithSlash.has_ext())
|
||||
<< Switch(endWithSlash.hasExt())
|
||||
<< " = " << endWithSlash.ext() << nl;
|
||||
|
||||
|
||||
Info<<"Remove extension " << (input0.remove_ext());
|
||||
Info<<"Remove extension " << (input0.removeExt());
|
||||
Info<< " now: " << input0 << nl;
|
||||
|
||||
Info<<"Remove extension " << (input1.removeExt());
|
||||
Info<< " now: " << input1 << nl;
|
||||
|
||||
Info<<"Remove extension " << (endWithSlash.remove_ext());
|
||||
Info<<"Remove extension " << (endWithSlash.removeExt());
|
||||
Info<< " now: " << endWithSlash << nl;
|
||||
|
||||
wordList exts{ "jpg", "png", "txt", word::null };
|
||||
@ -367,14 +359,14 @@ int main(int argc, char *argv[])
|
||||
Info<< nl;
|
||||
|
||||
|
||||
Info<<"Test has_ext(word)" << nl
|
||||
Info<<"Test hasExt(word)" << nl
|
||||
<<"~~~~~~~~~~~~~~~~~" << nl;
|
||||
Info<<"Has extension(s):" << nl
|
||||
<< "input: " << input1 << nl;
|
||||
for (const word& e : exts)
|
||||
{
|
||||
Info<<" '" << e << "' -> "
|
||||
<< Switch(input1.has_ext(e)) << nl;
|
||||
<< Switch(input1.hasExt(e)) << nl;
|
||||
}
|
||||
Info<< nl;
|
||||
|
||||
@ -383,12 +375,12 @@ int main(int argc, char *argv[])
|
||||
for (const word& e : exts)
|
||||
{
|
||||
Info<<" '" << e << "' -> "
|
||||
<< Switch(endWithDot.has_ext(e)) << nl;
|
||||
<< Switch(endWithDot.hasExt(e)) << nl;
|
||||
}
|
||||
Info<< nl;
|
||||
|
||||
|
||||
Info<<"Test has_ext(wordRe)" << nl
|
||||
Info<<"Test hasExt(wordRe)" << nl
|
||||
<<"~~~~~~~~~~~~~~~~~~~" << nl;
|
||||
|
||||
// A regex with a zero length matcher doesn't work at all:
|
||||
@ -401,25 +393,25 @@ int main(int argc, char *argv[])
|
||||
Info<<"Has extension(s):" << nl
|
||||
<< "input: " << endWithDot << nl;
|
||||
Info<<" " << matcher0 << " -> "
|
||||
<< Switch(endWithDot.has_ext(matcher0)) << nl;
|
||||
<< Switch(endWithDot.hasExt(matcher0)) << nl;
|
||||
Info<<" " << matcher1 << " -> "
|
||||
<< Switch(endWithDot.has_ext(matcher1)) << nl;
|
||||
<< Switch(endWithDot.hasExt(matcher1)) << nl;
|
||||
Info<<" " << matcher2 << " -> "
|
||||
<< Switch(endWithDot.has_ext(matcher2)) << nl;
|
||||
<< Switch(endWithDot.hasExt(matcher2)) << nl;
|
||||
|
||||
Info<< "input: " << input1 << nl;
|
||||
Info<<" " << matcher0 << " -> "
|
||||
<< Switch(input1.has_ext(matcher0)) << nl;
|
||||
<< Switch(input1.hasExt(matcher0)) << nl;
|
||||
Info<<" " << matcher1 << " -> "
|
||||
<< Switch(input1.has_ext(matcher1)) << nl;
|
||||
<< Switch(input1.hasExt(matcher1)) << nl;
|
||||
Info<<" " << matcher2 << " -> "
|
||||
<< Switch(input1.has_ext(matcher2)) << nl;
|
||||
<< Switch(input1.hasExt(matcher2)) << nl;
|
||||
Info<< nl;
|
||||
|
||||
Info<<"Remove extension(s):" << nl << "input: " << input1 << nl;
|
||||
while (!input1.empty())
|
||||
{
|
||||
if (input1.remove_ext())
|
||||
if (input1.removeExt())
|
||||
{
|
||||
Info<< " -> " << input1 << nl;
|
||||
}
|
||||
@ -595,54 +587,14 @@ int main(int argc, char *argv[])
|
||||
if (args.found("system"))
|
||||
{
|
||||
const fileName dirA("dirA");
|
||||
const fileName dirB("dirB");
|
||||
const fileName dirC("dirC");
|
||||
const fileName dirD("dirD");
|
||||
const fileName lnA("lnA");
|
||||
const fileName lnB("lnB");
|
||||
const fileName dirB("dirB");
|
||||
|
||||
// Purge anything existing
|
||||
Foam::rmDir(dirA, true);
|
||||
Foam::rmDir(dirB, true);
|
||||
Foam::rmDir(dirC, true);
|
||||
Foam::rmDir(dirD, true);
|
||||
Foam::rmDir(dirA);
|
||||
Foam::rm(lnA);
|
||||
Foam::rm(lnB);
|
||||
|
||||
{
|
||||
fileName name(dirA/dirB/dirC/"abc");
|
||||
Foam::mkDir(name.path());
|
||||
touchFileContent(name); // Create real file
|
||||
|
||||
Foam::mkDir(dirB/dirB/dirB/dirB);
|
||||
Foam::ln("test", dirB/"linkB"); // Create dead link
|
||||
|
||||
Foam::mkDir(dirC);
|
||||
Foam::ln("../dirD", dirC/"linkC"); // Create real link
|
||||
|
||||
Foam::mkDir(dirD);
|
||||
|
||||
for (const fileName& d : { dirA, dirB, dirC, dirD })
|
||||
{
|
||||
Info<< "Directory: " << d << " = "
|
||||
<< readDir(d, fileName::UNDEFINED, false, false) << nl;
|
||||
|
||||
if (Foam::rmDir(d, false, true))
|
||||
{
|
||||
Info<< " Removed empty dir" << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " Could not remove empty dir" << nl;
|
||||
}
|
||||
}
|
||||
|
||||
// Force removal before continuing
|
||||
Foam::rmDir(dirA, true);
|
||||
Foam::rmDir(dirB, true);
|
||||
Foam::rmDir(dirC, true);
|
||||
Foam::rmDir(dirD, true);
|
||||
}
|
||||
Foam::rmDir(dirB);
|
||||
|
||||
Info<< nl << "=========================" << nl
|
||||
<< "Test some copying and deletion" << endl;
|
||||
@ -666,7 +618,9 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
|
||||
Info<<" create: " << file << endl;
|
||||
touchFileContent(file);
|
||||
|
||||
std::ofstream os(file);
|
||||
os << "file=<" << file << ">" << nl;
|
||||
}
|
||||
|
||||
const int oldDebug = POSIX::debug;
|
||||
@ -754,7 +708,7 @@ int main(int argc, char *argv[])
|
||||
"hello1",
|
||||
"hello2",
|
||||
"hello3",
|
||||
"hello4.ext"
|
||||
"hello4.hmm"
|
||||
};
|
||||
|
||||
fileName pathName(wrdList);
|
||||
@ -764,28 +718,14 @@ int main(int argc, char *argv[])
|
||||
<< "pathName.name() = >" << pathName.name() << "<\n"
|
||||
<< "pathName.path() = " << pathName.path() << nl
|
||||
<< "pathName.ext() = >" << pathName.ext() << "<\n"
|
||||
<< "pathName.stem = >" << pathName.stem() << "<\n";
|
||||
<< "pathName.nameLessExt= >" << pathName.nameLessExt() << "<\n";
|
||||
|
||||
Info<< "pathName.components() = " << pathName.components() << nl
|
||||
<< "pathName.component(2) = " << pathName.component(2) << nl
|
||||
<< endl;
|
||||
|
||||
pathName.replace_name("newName.ext");
|
||||
Info<< "new name = " << pathName << nl;
|
||||
Info<< "has ext = " << Switch::name(pathName.has_ext()) << nl;
|
||||
Info<< "has ext('') = " << Switch::name(pathName.has_ext("")) << nl;
|
||||
Info<< "has ext(foo) = " << Switch::name(pathName.has_ext("foo")) << nl;
|
||||
Info<< "has ext(ext) = " << Switch::name(pathName.has_ext("ext")) << nl;
|
||||
|
||||
pathName.replace_ext("png");
|
||||
Info<< "new ext = " << pathName << nl;
|
||||
|
||||
pathName.replace_ext(""); // Same as remove_ext
|
||||
Info<< "new ext = " << pathName << nl;
|
||||
|
||||
Info<< "has path = " << Switch::name(pathName.has_path()) << nl;
|
||||
pathName.remove_path();
|
||||
pathName.removePath(); // second type should be a no-op
|
||||
Info<< "hasPath = " << Switch(pathName.hasPath()) << nl;
|
||||
pathName.removePath();
|
||||
Info<< "removed path = " << pathName << nl;
|
||||
|
||||
Info<< nl << nl;
|
||||
|
||||
@ -53,17 +53,20 @@ int main(int argc, char *argv[])
|
||||
const polyMesh::cellDecomposition decompMode = polyMesh::CELL_TETS;
|
||||
|
||||
treeBoundBox meshBb(mesh.bounds());
|
||||
treeBoundBox shiftedBb(meshBb);
|
||||
|
||||
// Calculate typical cell related size to shift bb by.
|
||||
scalar typDim = meshBb.avgDim()/(2.0*Foam::cbrt(scalar(mesh.nCells())));
|
||||
|
||||
shiftedBb.max() += vector::uniform(typDim);
|
||||
treeBoundBox shiftedBb
|
||||
(
|
||||
meshBb.min(),
|
||||
meshBb.max() + vector(typDim, typDim, typDim)
|
||||
);
|
||||
|
||||
Info<< "Mesh" << endl;
|
||||
Info<< " bounding box : " << meshBb << endl;
|
||||
Info<< " bounding box (shifted) : " << shiftedBb << endl;
|
||||
Info<< " typical dimension : " << shiftedBb.avgDim() << endl;
|
||||
Info<< " typical dimension : " << shiftedBb.typDim() << endl;
|
||||
|
||||
Info<< "Initialised mesh in "
|
||||
<< runTime.cpuTimeIncrement() << " s" << endl;
|
||||
|
||||
@ -64,13 +64,25 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Slightly extended bb. Slightly off-centred just so on symmetric
|
||||
// geometry there are less face/edge aligned items.
|
||||
treeBoundBox bb(efem.points());
|
||||
bb.grow(ROOTVSMALL);
|
||||
treeBoundBox bb
|
||||
(
|
||||
efem.points()
|
||||
);
|
||||
|
||||
bb.min() -= point::uniform(ROOTVSMALL);
|
||||
bb.max() += point::uniform(ROOTVSMALL);
|
||||
|
||||
labelList allEdges(identity(efem.edges().size()));
|
||||
|
||||
indexedOctree<treeDataEdge> edgeTree
|
||||
(
|
||||
treeDataEdge(efem.edges(), efem.points()), // All edges
|
||||
|
||||
treeDataEdge
|
||||
(
|
||||
false, // cachebb
|
||||
efem.edges(), // edges
|
||||
efem.points(), // points
|
||||
allEdges // selected edges
|
||||
),
|
||||
bb, // bb
|
||||
8, // maxLevel
|
||||
10, // leafsize
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
foamToEnsight-check.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/foamToEnsight-check
|
||||
@ -1,16 +0,0 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/finiteArea/lnInclude \
|
||||
-I$(LIB_SRC)/fileFormats/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/conversion/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/intermediate/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lfiniteArea \
|
||||
-lfileFormats \
|
||||
-lmeshTools \
|
||||
-lconversion \
|
||||
-llagrangianIntermediate \
|
||||
-lgenericPatchFields
|
||||
@ -1,357 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2022 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
|
||||
foamToEnsight-check
|
||||
|
||||
Description
|
||||
Check data sizes for conversion to ensight format.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "timeSelector.H"
|
||||
#include "IOobjectList.H"
|
||||
#include "IOmanip.H"
|
||||
#include "OFstream.H"
|
||||
#include "Pstream.H"
|
||||
#include "HashOps.H"
|
||||
#include "regionProperties.H"
|
||||
|
||||
#include "fvc.H"
|
||||
#include "faMesh.H"
|
||||
#include "fvMesh.H"
|
||||
|
||||
// file-format/conversion
|
||||
#include "ensightFaMesh.H"
|
||||
#include "ensightMesh.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
|
||||
void printStats(const FixedList<label, 3>& stats, const char *what = "")
|
||||
{
|
||||
Info<< what << "max-comm: "<< stats[0] << nl
|
||||
<< what << "max-size: "<< stats[1] << nl
|
||||
<< what << "off-proc: "<< stats[2] << nl;
|
||||
}
|
||||
|
||||
|
||||
template<class EnsightPartType>
|
||||
FixedList<label, 3> printPartInfo
|
||||
(
|
||||
const EnsightPartType& part,
|
||||
int verbose = 0
|
||||
)
|
||||
{
|
||||
Info<< "part: " << part.name().c_str() << nl
|
||||
<< " size: "
|
||||
<< (Pstream::parRun() ? part.total() : part.size())
|
||||
<< " (";
|
||||
|
||||
FixedList<label, 3> stats(Zero);
|
||||
|
||||
label& maxComm = stats[0];
|
||||
label& maxSize = stats[1];
|
||||
label& totNonLocalSize = stats[2];
|
||||
|
||||
for (int typei=0; typei < EnsightPartType::nTypes; ++typei)
|
||||
{
|
||||
const auto etype = typename EnsightPartType::elemType(typei);
|
||||
|
||||
if (typei) Info<< ' ';
|
||||
Info<< EnsightPartType::elemNames[etype] << ": "
|
||||
<< (Pstream::parRun() ? part.total(etype) : part.size(etype));
|
||||
|
||||
label elemCount = part.size(etype);
|
||||
label commCount = (Pstream::master() ? label(0) : elemCount);
|
||||
label nonLocalCount = commCount;
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
reduce(elemCount, maxOp<label>());
|
||||
reduce(commCount, maxOp<label>());
|
||||
|
||||
reduce(nonLocalCount, sumOp<label>());
|
||||
}
|
||||
|
||||
maxComm = max(maxComm, commCount);
|
||||
maxSize = max(maxSize, elemCount);
|
||||
totNonLocalSize = max(totNonLocalSize, nonLocalCount);
|
||||
}
|
||||
Info<< ")" << endl;
|
||||
|
||||
if (verbose && Pstream::parRun() && part.total())
|
||||
{
|
||||
for (int typei=0; typei < EnsightPartType::nTypes; ++typei)
|
||||
{
|
||||
const auto etype = typename EnsightPartType::elemType(typei);
|
||||
|
||||
label elemCount = part.size(etype);
|
||||
label totCount = part.total(etype);
|
||||
|
||||
Info<< " "
|
||||
<< EnsightPartType::elemNames[etype] << ": "
|
||||
<< totCount;
|
||||
|
||||
if (totCount)
|
||||
{
|
||||
labelList sizes(UPstream::listGatherValues(elemCount));
|
||||
|
||||
Info<< " ";
|
||||
sizes.writeList(Info);
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
printStats(stats, " ");
|
||||
|
||||
return stats;
|
||||
}
|
||||
|
||||
|
||||
void printInfo(const ensightMesh& mesh, int verbose = 0)
|
||||
{
|
||||
FixedList<label, 3> cellStats(Zero);
|
||||
FixedList<label, 3> faceStats(Zero);
|
||||
|
||||
for (const auto& iter : mesh.cellZoneParts().sorted())
|
||||
{
|
||||
FixedList<label, 3> stats = printPartInfo(iter.val(), verbose);
|
||||
|
||||
for (label i=0; i < 3; ++i)
|
||||
{
|
||||
cellStats[i] = max(cellStats[i], stats[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& iter : mesh.faceZoneParts().sorted())
|
||||
{
|
||||
FixedList<label, 3> stats = printPartInfo(iter.val(), verbose);
|
||||
|
||||
for (label i=0; i < 3; ++i)
|
||||
{
|
||||
faceStats[i] = max(faceStats[i], stats[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& iter : mesh.boundaryParts().sorted())
|
||||
{
|
||||
FixedList<label, 3> stats = printPartInfo(iter.val(), verbose);
|
||||
|
||||
for (label i=0; i < 3; ++i)
|
||||
{
|
||||
faceStats[i] = max(faceStats[i], stats[i]);
|
||||
}
|
||||
}
|
||||
|
||||
Info<< nl
|
||||
<< "===============" << nl;
|
||||
printStats(cellStats, "cell ");
|
||||
|
||||
Info<< nl;
|
||||
printStats(faceStats, "face ");
|
||||
|
||||
Info<< "===============" << endl;
|
||||
}
|
||||
|
||||
|
||||
void printInfo(const ensightFaMesh& mesh, int verbose = 0)
|
||||
{
|
||||
printPartInfo(mesh.areaPart());
|
||||
}
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::addNote
|
||||
(
|
||||
"Check data sizes for conversion of OpenFOAM to Ensight format"
|
||||
);
|
||||
// timeSelector::addOptions();
|
||||
|
||||
// Less frequently used - reduce some clutter
|
||||
argList::setAdvanced("decomposeParDict");
|
||||
|
||||
argList::addVerboseOption("Additional verbosity");
|
||||
|
||||
#include "addAllRegionOptions.H"
|
||||
|
||||
argList::addBoolOption
|
||||
(
|
||||
"no-boundary", // noPatches
|
||||
"Suppress writing any patches"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"no-internal",
|
||||
"Suppress writing the internal mesh"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"no-cellZones",
|
||||
"Suppress writing any cellZones"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"no-finite-area",
|
||||
"Suppress output of finite-area mesh/fields",
|
||||
true // mark as an advanced option
|
||||
);
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Configuration
|
||||
|
||||
const int optVerbose = args.verbose();
|
||||
const bool doBoundary = !args.found("no-boundary");
|
||||
const bool doInternal = !args.found("no-internal");
|
||||
const bool doCellZones = !args.found("no-cellZones");
|
||||
const bool doFiniteArea = !args.found("no-finite-area");
|
||||
|
||||
ensightMesh::options writeOpts;
|
||||
writeOpts.useBoundaryMesh(doBoundary);
|
||||
writeOpts.useInternalMesh(doInternal);
|
||||
writeOpts.useCellZones(doCellZones);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
#include "createTime.H"
|
||||
|
||||
instantList timeDirs = timeSelector::select0(runTime, args);
|
||||
|
||||
// Handle -allRegions, -regions, -region
|
||||
#include "getAllRegionOptions.H"
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
#include "createNamedMeshes.H"
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/// #include "createMeshAccounting.H"
|
||||
|
||||
PtrList<ensightMesh> ensightMeshes(regionNames.size());
|
||||
PtrList<faMesh> meshesFa(regionNames.size());
|
||||
PtrList<ensightFaMesh> ensightMeshesFa(regionNames.size());
|
||||
|
||||
forAll(regionNames, regioni)
|
||||
{
|
||||
const fvMesh& mesh = meshes[regioni];
|
||||
|
||||
ensightMeshes.set
|
||||
(
|
||||
regioni,
|
||||
new ensightMesh(mesh, writeOpts)
|
||||
);
|
||||
ensightMeshes[regioni].verbose(optVerbose);
|
||||
|
||||
|
||||
if (doFiniteArea)
|
||||
{
|
||||
autoPtr<faMesh> faMeshPtr(faMesh::TryNew(mesh));
|
||||
|
||||
if (faMeshPtr)
|
||||
{
|
||||
meshesFa.set(regioni, std::move(faMeshPtr));
|
||||
|
||||
ensightMeshesFa.set
|
||||
(
|
||||
regioni,
|
||||
new ensightFaMesh(meshesFa[regioni])
|
||||
);
|
||||
ensightMeshesFa[regioni].verbose(optVerbose);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
Info<< "Checking " << timeDirs.size() << " time steps" << nl;
|
||||
}
|
||||
|
||||
forAll(timeDirs, timei)
|
||||
{
|
||||
runTime.setTime(timeDirs[timei], timei);
|
||||
|
||||
forAll(regionNames, regioni)
|
||||
{
|
||||
const word& regionName = regionNames[regioni];
|
||||
// const word& regionDir = polyMesh::regionName(regionName);
|
||||
|
||||
auto& mesh = meshes[regioni];
|
||||
|
||||
polyMesh::readUpdateState meshState = mesh.readUpdate();
|
||||
const bool moving = (meshState != polyMesh::UNCHANGED);
|
||||
|
||||
auto& ensMesh = ensightMeshes[regioni];
|
||||
|
||||
// Finite-area (can be missing)
|
||||
auto* ensFaMeshPtr = ensightMeshesFa.get(regioni);
|
||||
|
||||
if (moving)
|
||||
{
|
||||
ensMesh.expire();
|
||||
ensMesh.correct();
|
||||
|
||||
if (ensFaMeshPtr)
|
||||
{
|
||||
ensFaMeshPtr->expire();
|
||||
ensFaMeshPtr->correct();
|
||||
}
|
||||
}
|
||||
|
||||
if (moving || timei == 0) // report
|
||||
{
|
||||
if (regionNames.size() > 1)
|
||||
{
|
||||
Info<< "region=" << regionName << nl;
|
||||
}
|
||||
|
||||
printInfo(ensMesh, optVerbose);
|
||||
|
||||
if (ensFaMeshPtr)
|
||||
{
|
||||
printInfo(*ensFaMeshPtr, optVerbose);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Info<< "\nEnd"<< nl << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -61,10 +61,10 @@ int main(int argc, char *argv[])
|
||||
InfoErr<< "output: " << outputName;
|
||||
|
||||
IOstreamOption::compressionType comp(IOstreamOption::UNCOMPRESSED);
|
||||
if (outputName.has_ext("gz"))
|
||||
if (outputName.hasExt("gz"))
|
||||
{
|
||||
comp = IOstreamOption::COMPRESSED;
|
||||
outputName.remove_ext();
|
||||
outputName.removeExt();
|
||||
|
||||
InfoErr<< " [compress]";
|
||||
}
|
||||
|
||||
@ -204,7 +204,7 @@ int main(int argc, char *argv[])
|
||||
labelPair inOut;
|
||||
pointField allCcs(globalNumbering.gather(mesh.cellCentres()));
|
||||
inOut[0] = allCcs.size();
|
||||
Pstream::broadcast(allCcs);
|
||||
Pstream::scatter(allCcs);
|
||||
inOut[1] = allCcs.size();
|
||||
Pout<< " " << inOut << endl;
|
||||
|
||||
|
||||
@ -41,8 +41,8 @@ void printInfo(const labelRange& range)
|
||||
<< "last " << range.last() << nl
|
||||
<< "min " << range.min() << nl
|
||||
<< "max " << range.max() << nl
|
||||
<< "end " << range.end_value() << nl
|
||||
<< "begin/end " << *range.cbegin() << ' ' << *range.cend() << nl;
|
||||
<< "after " << range.after() << nl
|
||||
<< "begin end " << *range.cbegin() << ' ' << *range.cend() << nl;
|
||||
|
||||
// Info<< "rbegin rend " << *range.rbegin() << ' ' << *range.rend() << nl;
|
||||
}
|
||||
@ -56,7 +56,7 @@ int main(int argc, char *argv[])
|
||||
argList::noParallel();
|
||||
argList::noFunctionObjects();
|
||||
argList::addArgument("start size .. startN sizeN");
|
||||
argList::addVerboseOption("enable labelRange::debug");
|
||||
argList::addVerbose("enable labelRange::debug");
|
||||
argList::addNote
|
||||
(
|
||||
"The default is to add ranges, use 'add' and 'del' to toggle\n\n"
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is derivative work of OpenFOAM.
|
||||
@ -49,6 +49,20 @@ using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Return the absolute tolerance value for bitwise comparisons of floatScalars
|
||||
floatScalar getTol(floatScalar)
|
||||
{
|
||||
return 1e-2;
|
||||
}
|
||||
|
||||
|
||||
// Return the absolute tolerance value for bitwise comparisons of doubleScalars
|
||||
doubleScalar getTol(doubleScalar)
|
||||
{
|
||||
return 1e-10;
|
||||
}
|
||||
|
||||
|
||||
// Create each constructor of EigenMatrix<Type>, and print output
|
||||
template<class Type>
|
||||
void test_constructors(Type)
|
||||
|
||||
@ -44,7 +44,7 @@ using namespace Foam;
|
||||
template<class T>
|
||||
Ostream& printInfo(const MinMax<T>& range)
|
||||
{
|
||||
Info<< range << " good=" << range.good() << " span=" << range.span();
|
||||
Info<< range << " valid=" << range.valid() << " span=" << range.span();
|
||||
|
||||
return Info;
|
||||
}
|
||||
@ -234,7 +234,11 @@ int main(int argc, char *argv[])
|
||||
|
||||
Pout<< "hashed: " << hashed << nl;
|
||||
|
||||
Pstream::mapCombineReduce(hashed, plusEqOp<scalarMinMax>());
|
||||
Pstream::mapCombineGather
|
||||
(
|
||||
hashed,
|
||||
plusEqOp<scalarMinMax>()
|
||||
);
|
||||
|
||||
Info<< "reduced: " << hashed << nl;
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ using namespace Foam;
|
||||
template<class T>
|
||||
Ostream& printInfo(const MinMax<T>& range)
|
||||
{
|
||||
Info<< range << " good=" << range.good();
|
||||
Info<< range << " valid=" << range.valid();
|
||||
|
||||
return Info;
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-openmp.cpp
|
||||
Test-openmp.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-openmp
|
||||
@ -1,4 +1,4 @@
|
||||
EXE_INC = $(COMP_OPENMP)
|
||||
EXE_INC = $(COMP_OPENMP) /* -UUSE_OMP */
|
||||
|
||||
/* Mostly do not need to explicitly link openmp libraries */
|
||||
/* EXE_LIBS = $(LINK_OPENMP) */
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -41,13 +41,14 @@ Description
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
std::cout
|
||||
<< "c++ = " << __cplusplus << '\n';
|
||||
#if USE_OMP
|
||||
std::cout << "USE_OMP defined (" << USE_OMP << ")\n";
|
||||
#else
|
||||
std::cout << "USE_OMP undefined\n";
|
||||
#endif
|
||||
|
||||
#if _OPENMP
|
||||
std::cout
|
||||
<< "openmp = " << _OPENMP << '\n'
|
||||
<< "Initial threads = " << omp_get_num_threads() << "\n\n";
|
||||
std::cout << "_OPENMP = " << _OPENMP << "\n\n";
|
||||
|
||||
// Fork threads with their own copies of variables
|
||||
int nThreads, threadId;
|
||||
@ -57,15 +58,15 @@ int main(int argc, char *argv[])
|
||||
threadId = omp_get_thread_num();
|
||||
nThreads = omp_get_num_threads();
|
||||
|
||||
// Printf rather than cout to ensure that it emits in one go
|
||||
printf("Called from thread = %d\n", threadId);
|
||||
|
||||
// Master thread
|
||||
if (threadId == 0)
|
||||
{
|
||||
// Printf rather than cout to ensure that it emits in one go
|
||||
printf("Number of threads = %d\n", nThreads);
|
||||
}
|
||||
|
||||
// Printf rather than cout to ensure that it emits in one go
|
||||
printf("Called from thread = %d\n", threadId);
|
||||
}
|
||||
#else
|
||||
std::cout << "Compiled without openmp!\n";
|
||||
@ -167,7 +167,7 @@ int main(int argc, char *argv[])
|
||||
(
|
||||
localValue,
|
||||
sumOp<scalar>(),
|
||||
UPstream::msgType(),
|
||||
Pstream::msgType(),
|
||||
comm
|
||||
);
|
||||
Pout<< "sum :" << sum << endl;
|
||||
|
||||
@ -125,13 +125,13 @@ int main(int argc, char *argv[])
|
||||
scalar data1 = 1.0;
|
||||
label request1 = -1;
|
||||
{
|
||||
Foam::reduce(data1, sumOp<scalar>(), UPstream::msgType(), request1);
|
||||
Foam::reduce(data1, sumOp<scalar>(), Pstream::msgType(), request1);
|
||||
}
|
||||
|
||||
scalar data2 = 0.1;
|
||||
label request2 = -1;
|
||||
{
|
||||
Foam::reduce(data2, sumOp<scalar>(), UPstream::msgType(), request2);
|
||||
Foam::reduce(data2, sumOp<scalar>(), Pstream::msgType(), request2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -232,7 +232,6 @@ int main(int argc, char *argv[])
|
||||
const labelListList& edgeFaces = pp.edgeFaces();
|
||||
const labelListList& faceEdges = pp.faceEdges();
|
||||
|
||||
Pout<< "box: " << pp.box() << endl;
|
||||
|
||||
checkFaceEdges(localFaces, edges, faceEdges);
|
||||
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
Test-rawIOField.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-rawIOField
|
||||
@ -1,9 +0,0 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/fileFormats/lnInclude \
|
||||
-I$(LIB_SRC)/surfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfileFormats \
|
||||
-lsurfMesh \
|
||||
-lmeshTools
|
||||
@ -1,168 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2022 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-rawIOField
|
||||
|
||||
Description
|
||||
Reading rawIOField from disk
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "Time.H"
|
||||
#include "Switch.H"
|
||||
#include "primitiveFields.H"
|
||||
#include "pointField.H"
|
||||
#include "rawIOField.H"
|
||||
#include "exprTraits.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
#undef USE_ROOT_CASE
|
||||
//#define USE_ROOT_CASE
|
||||
|
||||
|
||||
template<class Type>
|
||||
tmp<Field<Type>> readRawField
|
||||
(
|
||||
const IOobject& io,
|
||||
IOobjectOption::readOption withAverage
|
||||
)
|
||||
{
|
||||
rawIOField<Type> raw(io, withAverage);
|
||||
|
||||
Info<< "File: " << io.objectPath() << nl
|
||||
<< "Read: " << raw.size()
|
||||
<< ' ' << pTraits<Type>::typeName << " entries" << nl
|
||||
<< "Average: " << Switch::name(raw.hasAverage())
|
||||
<< " = " << raw.average() << endl;
|
||||
|
||||
return tmp<Field<Type>>::New(std::move(static_cast<Field<Type>&>(raw)));
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::addNote
|
||||
(
|
||||
"Test behaviour of rawIOField reading (writing?)"
|
||||
);
|
||||
|
||||
argList::noCheckProcessorDirectories();
|
||||
|
||||
argList::addBoolOption("scalar", "Read scalar field");
|
||||
argList::addBoolOption("vector", "Read vector field");
|
||||
argList::addBoolOption("point", "Read point field");
|
||||
argList::addBoolOption("average", "Require averaged value entry");
|
||||
argList::addBoolOption("try-average", "Optional averaged value entry");
|
||||
|
||||
argList::addArgument("fileName");
|
||||
|
||||
#ifdef USE_ROOT_CASE
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
#else
|
||||
// Without root case, or time
|
||||
argList args(argc, argv);
|
||||
#endif
|
||||
|
||||
fileName inputName = args.get<fileName>(1);
|
||||
|
||||
IOobjectOption::readOption withAverage = IOobjectOption::NO_READ;
|
||||
|
||||
if (args.found("average"))
|
||||
{
|
||||
withAverage = IOobjectOption::MUST_READ;
|
||||
}
|
||||
else if (args.found("try-average"))
|
||||
{
|
||||
withAverage = IOobjectOption::READ_IF_PRESENT;
|
||||
}
|
||||
|
||||
Info<< "Using case: " << argList::envGlobalPath() << nl
|
||||
<< "Read file: " << inputName << nl
|
||||
<< "with average: " << int(withAverage) << nl
|
||||
<< endl;
|
||||
|
||||
|
||||
refPtr<Time> timePtr;
|
||||
|
||||
#ifdef USE_ROOT_CASE
|
||||
timePtr.cref(runTime);
|
||||
#endif
|
||||
|
||||
// Fallback (eg, no runTime)
|
||||
if (!timePtr.good())
|
||||
{
|
||||
timePtr.reset(Time::New(argList::envGlobalPath()));
|
||||
}
|
||||
|
||||
|
||||
const auto& tm = timePtr();
|
||||
|
||||
fileName resolvedName(inputName);
|
||||
resolvedName.toAbsolute();
|
||||
|
||||
IOobject io
|
||||
(
|
||||
resolvedName, // absolute path
|
||||
tm,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER,
|
||||
true // is global object (currently not used)
|
||||
);
|
||||
|
||||
|
||||
if (args.found("scalar"))
|
||||
{
|
||||
auto tfield = readRawField<scalar>(io, withAverage);
|
||||
}
|
||||
else if (args.found("point"))
|
||||
{
|
||||
auto tfield = readRawField<point>(io, withAverage);
|
||||
}
|
||||
else if (args.found("vector"))
|
||||
{
|
||||
auto tfield = readRawField<vector>(io, withAverage);
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "no data type specified!\n";
|
||||
}
|
||||
|
||||
Info<< nl << "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user