ENH: allow datToFoam writing points dict directly

- refactors the corresponding tutorial by removing redundant files and items:
    compressible/rhoCentralFoam/biconic25-55Run35
This commit is contained in:
Kutalmis Bercin
2020-01-22 09:41:25 +00:00
parent ae40bd9f9b
commit f55da4b690
8 changed files with 56 additions and 65595 deletions

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -60,7 +61,7 @@ int main(int argc, char *argv[])
if (!args.check()) if (!args.check())
{ {
FatalError.exit(); FatalError.exit();
} }
#include "createTime.H" #include "createTime.H"
@ -87,23 +88,23 @@ int main(int argc, char *argv[])
Istring >> block; Istring >> block;
Istring >> jPoints; Istring >> jPoints;
Info<< "Number of vertices in i direction = " << iPoints << endl Info<< "Number of vertices in i direction = " << iPoints << nl
<< "Number of vertices in j direction = " << jPoints << endl; << "Number of vertices in j direction = " << jPoints << endl;
// We ignore the first layer of points in i and j the biconic meshes // We ignore the first layer of points in i and j the biconic meshes
label nPointsij = (iPoints - 1)*(jPoints - 1); const label nPointsij = (iPoints - 1)*(jPoints - 1);
pointField points(nPointsij, Zero); pointField points(nPointsij, Zero);
for (direction comp = 0; comp < 2; comp++) for (direction comp = 0; comp < 2; ++comp)
{ {
label p(0); label p = 0;
for (label j = 0; j < jPoints; j++) for (label j = 0; j < jPoints; ++j)
{ {
for (label i = 0; i < iPoints; i++) for (label i = 0; i < iPoints; ++i)
{ {
double coord; scalar coord;
plot3dFile >> coord; plot3dFile >> coord;
// if statement ignores the first layer in i and j // if statement ignores the first layer in i and j
@ -126,31 +127,37 @@ int main(int argc, char *argv[])
pointField pointsWedge(nPointsij*2, Zero); pointField pointsWedge(nPointsij*2, Zero);
fileName pointsFile(runTime.constantPath()/"points.tmp");
OFstream pFile(pointsFile);
const scalar a = degToRad(0.1); const scalar a = degToRad(0.1);
tensor rotateZ = const tensor rotateZ
tensor (
( 1.0, 0.0, 0.0,
1.0, 0.0, 0.0, 0.0, 1.0, 0.0,
0.0, 1.0, 0.0, 0.0, -::sin(a), ::cos(a)
0.0, -::sin(a), ::cos(a) );
);
forAll(points, i) forAll(points, i)
{ {
pointsWedge[i] = (rotateZ & points[i]); pointsWedge[i] = (rotateZ & points[i]);
pointsWedge[i+nPointsij] = cmptMultiply pointsWedge[i + nPointsij] =
( cmptMultiply
vector(1.0, 1.0, -1.0), (
pointsWedge[i] vector(1.0, 1.0, -1.0),
); pointsWedge[i]
);
} }
const fileName polyMeshPath(runTime.constantPath()/"polyMesh");
const fileName pointsFile(polyMeshPath/"points");
OFstream pFile(pointsFile);
if (!exists(polyMeshPath)) mkDir(polyMeshPath);
Info<< "Writing points to: " << nl Info<< "Writing points to: " << nl
<< " " << pointsFile << endl; << " " << pointsFile << endl;
runTime.writeHeader(pFile, "vectorField");
pFile << pointsWedge; pFile << pointsWedge;
runTime.writeEndDivider(pFile);
Info<< "End" << endl; Info<< "End" << endl;

View File

@ -5,5 +5,6 @@ cd "${0%/*}" || exit # Run from this directory
cleanCase cleanCase
cleanSamples cleanSamples
rm -rf 0/pointPriority
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -4,17 +4,12 @@ cd "${0%/*}" || exit # Run from this directory
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
runApplication blockMesh runApplication blockMesh
runApplication datToFoam grid256.dat runApplication datToFoam grid256.dat
CONST="constant"
cat $CONST/pointsHeader $CONST/points.tmp > $CONST/polyMesh/points
runApplication collapseEdges -overwrite runApplication collapseEdges -overwrite
echo "Changing patch type to wedge type in boundary file" echo "Overwriting 'patch' type as 'wedge' type in 'boundary' dictionary"
mv $CONST/polyMesh/boundary $CONST/polyMesh/boundary.bak sed -if '/wedge1/,/nFaces/{s/patch/wedge/};/wedge2/,/nFaces/{s/patch/wedge/}'\
sed -f $CONST/wedgeScr $CONST/polyMesh/boundary.bak > $CONST/polyMesh/boundary constant/polyMesh/boundary
rm $CONST/polyMesh/boundary.bak
runApplication $(getApplication) runApplication $(getApplication)

View File

@ -1,14 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class vectorField;
object points;
}

View File

@ -37,8 +37,26 @@ mixture
Tlow 100; Tlow 100;
Thigh 10000; Thigh 10000;
Tcommon 1000; Tcommon 1000;
highCpCoeffs ( 2.9525407 0.0013968838 -4.9262577e-07 7.8600091e-11 -4.6074978e-15 -923.93753 5.8718221 ); highCpCoeffs
lowCpCoeffs ( 3.5309628 -0.0001236595 -5.0299339e-07 2.4352768e-09 -1.4087954e-12 -1046.9637 2.9674391 ); (
2.9525407
0.0013968838
-4.9262577e-07
7.8600091e-11
-4.6074978e-15
-923.93753
5.8718221
);
lowCpCoeffs
(
3.5309628
-0.0001236595
-5.0299339e-07
2.4352768e-09
-1.4087954e-12
-1046.9637
2.9674391
);
} }
transport transport
{ {

View File

@ -1,6 +0,0 @@
/wedge1/,/nFaces/{
s/patch/wedge/
}
/wedge2/,/nFaces/{
s/patch/wedge/
}

View File

@ -31,7 +31,7 @@ writeControl adjustable;
writeInterval 5e-5; writeInterval 5e-5;
cycleWrite 0; purgeWrite 0;
writeFormat binary; writeFormat binary;