Commit 55e5a777 authored by shunbo's avatar shunbo
Browse files

initial commit

parents
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
-------------------------------------------------------------------------------
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
globalMeshDataTest
Description
Test global point communication
\*---------------------------------------------------------------------------*/
#include "globalMeshData.H"
#include "argList.H"
#include "polyMesh.H"
#include "Time.H"
#include "mapDistribute.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
#include "setRootCase.H"
#include "createTime.H"
#include "createPolyMesh.H"
const globalMeshData& globalData = mesh.globalData();
const indirectPrimitivePatch& coupledPatch = globalData.coupledPatch();
const globalIndexAndTransform& transforms = globalData.globalTransforms();
// Test:print shared points
{
const mapDistribute& globalPointSlavesMap =
globalData.globalPointSlavesMap();
const labelListList& slaves =
globalData.globalPointSlaves();
const labelListList& transformedSlaves =
globalData.globalPointTransformedSlaves();
// Create field with my local data
pointField coords(globalPointSlavesMap.constructSize());
SubList<point>(coords, coupledPatch.nPoints()) =
coupledPatch.localPoints();
// Exchange data. Apply positional transforms.
globalPointSlavesMap.distribute
(
transforms,
coords,
mapDistribute::transformPosition()
);
// Print
forAll(slaves, pointi)
{
const labelList& slavePoints = slaves[pointi];
if (slavePoints.size() > 0)
{
Pout<< "Master point:" << pointi
<< " coord:" << coords[pointi]
<< " connected to untransformed slave points:" << endl;
forAll(slavePoints, i)
{
Pout<< " " << coords[slavePoints[i]] << endl;
}
}
const labelList& transformedSlavePoints = transformedSlaves[pointi];
if (transformedSlavePoints.size() > 0)
{
Pout<< "Master point:" << pointi
<< " coord:" << coords[pointi]
<< " connected to transformed slave points:" << endl;
forAll(transformedSlavePoints, i)
{
Pout<< " " << coords[transformedSlavePoints[i]]
<< endl;
}
}
}
}
// Test:print shared edges
{
const mapDistribute& globalEdgeSlavesMap =
globalData.globalEdgeSlavesMap();
const labelListList& slaves =
globalData.globalEdgeSlaves();
const labelListList& transformedSlaves =
globalData.globalEdgeTransformedSlaves();
// Test: distribute edge centres
pointField ec(globalEdgeSlavesMap.constructSize());
forAll(coupledPatch.edges(), edgeI)
{
ec[edgeI] = coupledPatch.edges()[edgeI].centre
(
coupledPatch.localPoints()
);
}
// Exchange data Apply positional transforms.
globalEdgeSlavesMap.distribute
(
transforms,
ec,
mapDistribute::transformPosition()
);
// Print
forAll(slaves, edgeI)
{
const labelList& slaveEdges = slaves[edgeI];
if (slaveEdges.size() > 0)
{
Pout<< "Master edge:" << edgeI
<< " centre:" << ec[edgeI]
<< " connected to slave edges:" << endl;
forAll(slaveEdges, i)
{
Pout<< " " << ec[slaveEdges[i]] << endl;
}
}
const labelList& transformedSlaveEdges = transformedSlaves[edgeI];
if (transformedSlaveEdges.size() > 0)
{
Pout<< "Master edge:" << edgeI
<< " centre:" << ec[edgeI]
<< " connected to transformed slave edges:" << endl;
forAll(transformedSlaveEdges, i)
{
Pout<< " " << ec[transformedSlaveEdges[i]]
<< endl;
}
}
}
}
// Test: point to faces addressing
{
const mapDistribute& globalPointBoundaryFacesMap =
globalData.globalPointBoundaryFacesMap();
const labelListList& slaves =
globalData.globalPointBoundaryFaces();
const labelListList& transformedSlaves =
globalData.globalPointTransformedBoundaryFaces();
const label nBnd = mesh.nBoundaryFaces();
pointField fc(globalPointBoundaryFacesMap.constructSize());
SubList<point>(fc, nBnd) =
primitivePatch
(
SubList<face>
(
mesh.faces(),
nBnd,
mesh.nInternalFaces()
),
mesh.points()
).faceCentres();
// Exchange data
globalPointBoundaryFacesMap.distribute
(
transforms,
fc,
mapDistribute::transformPosition()
);
// Print
forAll(slaves, pointi)
{
const labelList& slaveFaces = slaves[pointi];
if (slaveFaces.size() > 0)
{
Pout<< "Master point:" << pointi
<< " at:" << coupledPatch.localPoints()[pointi]
<< " connected to " << slaveFaces.size()
<< " untransformed faces:" << endl;
forAll(slaveFaces, i)
{
Pout<< " " << fc[slaveFaces[i]] << endl;
}
}
const labelList& transformedSlaveFaces = transformedSlaves[pointi];
if (transformedSlaveFaces.size() > 0)
{
Pout<< "Master point:" << pointi
<< " connected to " << transformedSlaveFaces.size()
<< " transformed faces:" << endl;
forAll(transformedSlaveFaces, i)
{
Pout<< " " << fc[transformedSlaveFaces[i]] << endl;
}
}
}
}
// Test: point to cells addressing
{
const labelList& boundaryCells = globalData.boundaryCells();
const mapDistribute& globalPointBoundaryCellsMap =
globalData.globalPointBoundaryCellsMap();
const labelListList& slaves = globalData.globalPointBoundaryCells();
const labelListList& transformedSlaves =
globalData.globalPointTransformedBoundaryCells();
pointField cc(globalPointBoundaryCellsMap.constructSize());
forAll(boundaryCells, i)
{
cc[i] = mesh.cellCentres()[boundaryCells[i]];
}
// Exchange data
globalPointBoundaryCellsMap.distribute
(
transforms,
cc,
mapDistribute::transformPosition()
);
// Print
forAll(slaves, pointi)
{
const labelList& pointCells = slaves[pointi];
if (pointCells.size() > 0)
{
Pout<< "Master point:" << pointi
<< " at:" << coupledPatch.localPoints()[pointi]
<< " connected to " << pointCells.size()
<< " untransformed boundaryCells:" << endl;
forAll(pointCells, i)
{
Pout<< " " << cc[pointCells[i]] << endl;
}
}
const labelList& transformPointCells = transformedSlaves[pointi];
if (transformPointCells.size() > 0)
{
Pout<< "Master point:" << pointi
<< " connected to " << transformPointCells.size()
<< " transformed boundaryCells:" << endl;
forAll(transformPointCells, i)
{
Pout<< " " << cc[transformPointCells[i]] << endl;
}
}
}
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //
Test-graph.C
EXE = $(FOAM_USER_APPBIN)/Test-graph
EXE_INC = \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lsampling \
-lmeshTools
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
-------------------------------------------------------------------------------
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
graphTest
Description
Test program for making graphs
\*---------------------------------------------------------------------------*/
#include "graph.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main()
{
scalarField alpha(200);
scalarField phie(alpha.size());
scalarField phic(alpha.size());
forAll(alpha, i)
{
alpha[i] = scalar(i)/50.0;
}
scalar R = 5.0;
phie = (R - 1)/(sqrt(R/(alpha + 1.0e-6)) + 1.0) + 1.0;
phic = (R - 1)/(sqrt(R*alpha) + 1.0) + 1.0;
graph phi("@f! (R = 5)", "@a!", "@f!", alpha);
phi.insert
(
"@f!&e!",
autoPtr<curve>::New("@f!&e!", curve::curveStyle::CONTINUOUS, phie)
);
phi.insert
(
"@f!&c!",
autoPtr<curve>::New("@f!&c!", curve::curveStyle::CONTINUOUS, phic)
);
phi.write("phi", "xmgr");
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
-------------------------------------------------------------------------------
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
graphTest
Description
Test program for making graphs
\*---------------------------------------------------------------------------*/
#include "graph.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main()
{
scalarField eta(200);
scalarField C1mR(eta.size());
forAll(eta, i)
{
eta[i] = scalar(i)/10.0;
}
scalar C1 = 1.42;
scalar eta0 = 4.38;
scalar beta = 0.012;
C1mR = C1 - ((eta*(1.0 - eta/eta0))/(1.0 + beta*pow(eta, 3.0)));
graph("C&1! - R", "C&1! - R", "@h!", eta, C1mR).write
(
"C1mR",
"xmgr"
);
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //
Test-graphXi.C
EXE = $(FOAM_USER_APPBIN)/Test-graphXi
EXE_INC = \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lsampling \
-lmeshTools
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
-------------------------------------------------------------------------------
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
graphTest
Description
Test program for making graphs
\*---------------------------------------------------------------------------*/
#include "graph.H"
#include "OFstream.H"
#include "mathematicalConstants.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main()
{
scalarField x(100);
scalarField r(x.size());
forAll(x, i)
{
x[i] = -3 + 0.06*i;
}
scalarField b(0.5*(1.0 + erf(x)));
scalarField c(1.0 - b);
scalarField gradb((1/::sqrt(constant::mathematical::pi))*exp(-sqr(x)));
scalarField lapb(-2*x*gradb);
r = lapb*b*c/(gradb*gradb);
graph("r", "x", "r", x, r).write("r", "xmgr");
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //
@title "r"
@xaxis label "x"
@yaxis label "r"
@s0 legend "r"
@target G0.S0
@type xy
-3 0.951803
-2.94 0.950065
-2.88 0.948234
-2.82 0.946302
-2.76 0.944261
-2.7 0.942103
-2.64 0.939817
-2.58 0.937392
-2.52 0.934816
-2.46 0.932074
-2.4 0.929149
-2.34 0.926023
-2.28 0.922673
-2.22 0.919075
-2.16 0.915199
-2.1 0.911012
-2.04 0.906476
-1.98 0.901547
-1.92 0.896176
-1.86 0.890307
-1.8 0.883875
-1.74 0.87681
-1.68 0.869032
-1.62 0.860453
-1.56 0.850978
-1.5 0.840503
-1.44 0.828916
-1.38 0.8161
-1.32 0.801931
-1.26 0.786282
-1.2 0.769024
-1.14 0.750029
-1.08 0.729172
-1.02 0.706337
-0.96 0.681414
-0.9 0.654311
-0.84 0.624951
-0.78 0.59328
-0.72 0.559268
-0.66 0.522911
-0.6 0.48424
-0.54 0.443314
-0.48 0.40023
-0.42 0.355116
-0.36 0.308137
-0.3 0.259489
-0.24 0.2094
-0.18 0.158121
-0.12 0.10593
-0.06 0.0531214
-1.11022e-16 9.8391e-17
0.06 -0.0531214
0.12 -0.10593
0.18 -0.158121
0.24 -0.2094
0.3 -0.259489
0.36 -0.308137
0.42 -0.355116
0.48 -0.40023
0.54 -0.443314
0.6 -0.48424
0.66 -0.522911
0.72 -0.559268
0.78 -0.59328
0.84 -0.624951
0.9 -0.654311
0.96 -0.681414
1.02 -0.706337
1.08 -0.729172
1.14 -0.750029
1.2 -0.769024
1.26 -0.786282
1.32 -0.801931
1.38 -0.8161
1.44 -0.828916
1.5 -0.840503
1.56 -0.850978
1.62 -0.860453
1.68 -0.869032
1.74 -0.87681
1.8 -0.883875
1.86 -0.890307
1.92 -0.896176
1.98 -0.901547
2.04 -0.906476
2.1 -0.911012
2.16 -0.915199
2.22 -0.919075
2.28 -0.922673
2.34 -0.926023
2.4 -0.929149
2.46 -0.932074
2.52 -0.934816
2.58 -0.937392
2.64 -0.939817
2.7 -0.942103
2.76 -0.944261
2.82 -0.946302
2.88 -0.948234
2.94 -0.950065
# JPlot file
# column 1: x
# column 2: r
-3 0.951803
-2.94 0.950065
-2.88 0.948234
-2.82 0.946302
-2.76 0.944261
-2.7 0.942103
-2.64 0.939817
-2.58 0.937392
-2.52 0.934816
-2.46 0.932074
-2.4 0.929149
-2.34 0.926023
-2.28 0.922673
-2.22 0.919075
-2.16 0.915199
-2.1 0.911012
-2.04 0.906476
-1.98 0.901547
-1.92 0.896176
-1.86 0.890307
-1.8 0.883875
-1.74 0.87681
-1.68 0.869032
-1.62 0.860453
-1.56 0.850978
-1.5 0.840503
-1.44 0.828916
-1.38 0.8161
-1.32 0.801931
-1.26 0.786282
-1.2 0.769024
-1.14 0.750029
-1.08 0.729172
-1.02 0.706337
-0.96 0.681414
-0.9 0.654311
-0.84 0.624951
-0.78 0.59328
-0.72 0.559268
-0.66 0.522911
-0.6 0.48424
-0.54 0.443314
-0.48 0.40023
-0.42 0.355116
-0.36 0.308137
-0.3 0.259489
-0.24 0.2094
-0.18 0.158121
-0.12 0.10593
-0.06 0.0531214
-1.11022e-16 9.8391e-17
0.06 -0.0531214
0.12 -0.10593
0.18 -0.158121
0.24 -0.2094
0.3 -0.259489
0.36 -0.308137
0.42 -0.355116
0.48 -0.40023
0.54 -0.443314
0.6 -0.48424
0.66 -0.522911
0.72 -0.559268
0.78 -0.59328
0.84 -0.624951
0.9 -0.654311
0.96 -0.681414
1.02 -0.706337
1.08 -0.729172
1.14 -0.750029
1.2 -0.769024
1.26 -0.786282
1.32 -0.801931
1.38 -0.8161
1.44 -0.828916
1.5 -0.840503
1.56 -0.850978
1.62 -0.860453
1.68 -0.869032
1.74 -0.87681
1.8 -0.883875
1.86 -0.890307
1.92 -0.896176
1.98 -0.901547
2.04 -0.906476
2.1 -0.911012
2.16 -0.915199
2.22 -0.919075
2.28 -0.922673
2.34 -0.926023
2.4 -0.929149
2.46 -0.932074
2.52 -0.934816
2.58 -0.937392
2.64 -0.939817
2.7 -0.942103
2.76 -0.944261
2.82 -0.946302
2.88 -0.948234
2.94 -0.950065
#set term postscript color
set output "r.ps"
set title "r" 0,0
show title
set xlabel "x" 0,0
show xlabel
set ylabel "r" 0,0
show ylabel
plot'-' title "r" with lines; pause -1
-3 0.951803
-2.94 0.950065
-2.88 0.948234
-2.82 0.946302
-2.76 0.944261
-2.7 0.942103
-2.64 0.939817
-2.58 0.937392
-2.52 0.934816
-2.46 0.932074
-2.4 0.929149
-2.34 0.926023
-2.28 0.922673
-2.22 0.919075
-2.16 0.915199
-2.1 0.911012
-2.04 0.906476
-1.98 0.901547
-1.92 0.896176
-1.86 0.890307
-1.8 0.883875
-1.74 0.87681
-1.68 0.869032
-1.62 0.860453
-1.56 0.850978
-1.5 0.840503
-1.44 0.828916
-1.38 0.8161
-1.32 0.801931
-1.26 0.786282
-1.2 0.769024
-1.14 0.750029
-1.08 0.729172
-1.02 0.706337
-0.96 0.681414
-0.9 0.654311
-0.84 0.624951
-0.78 0.59328
-0.72 0.559268
-0.66 0.522911
-0.6 0.48424
-0.54 0.443314
-0.48 0.40023
-0.42 0.355116
-0.36 0.308137
-0.3 0.259489
-0.24 0.2094
-0.18 0.158121
-0.12 0.10593
-0.06 0.0531214
-1.11022e-16 9.8391e-17
0.06 -0.0531214
0.12 -0.10593
0.18 -0.158121
0.24 -0.2094
0.3 -0.259489
0.36 -0.308137
0.42 -0.355116
0.48 -0.40023
0.54 -0.443314
0.6 -0.48424
0.66 -0.522911
0.72 -0.559268
0.78 -0.59328
0.84 -0.624951
0.9 -0.654311
0.96 -0.681414
1.02 -0.706337
1.08 -0.729172
1.14 -0.750029
1.2 -0.769024
1.26 -0.786282
1.32 -0.801931
1.38 -0.8161
1.44 -0.828916
1.5 -0.840503
1.56 -0.850978
1.62 -0.860453
1.68 -0.869032
1.74 -0.87681
1.8 -0.883875
1.86 -0.890307
1.92 -0.896176
1.98 -0.901547
2.04 -0.906476
2.1 -0.911012
2.16 -0.915199
2.22 -0.919075
2.28 -0.922673
2.34 -0.926023
2.4 -0.929149
2.46 -0.932074
2.52 -0.934816
2.58 -0.937392
2.64 -0.939817
2.7 -0.942103
2.76 -0.944261
2.82 -0.946302
2.88 -0.948234
2.94 -0.950065
-3 0.951803
-2.94 0.950065
-2.88 0.948234
-2.82 0.946302
-2.76 0.944261
-2.7 0.942103
-2.64 0.939817
-2.58 0.937392
-2.52 0.934816
-2.46 0.932074
-2.4 0.929149
-2.34 0.926023
-2.28 0.922673
-2.22 0.919075
-2.16 0.915199
-2.1 0.911012
-2.04 0.906476
-1.98 0.901547
-1.92 0.896176
-1.86 0.890307
-1.8 0.883875
-1.74 0.87681
-1.68 0.869032
-1.62 0.860453
-1.56 0.850978
-1.5 0.840503
-1.44 0.828916
-1.38 0.8161
-1.32 0.801931
-1.26 0.786282
-1.2 0.769024
-1.14 0.750029
-1.08 0.729172
-1.02 0.706337
-0.96 0.681414
-0.9 0.654311
-0.84 0.624951
-0.78 0.59328
-0.72 0.559268
-0.66 0.522911
-0.6 0.48424
-0.54 0.443314
-0.48 0.40023
-0.42 0.355116
-0.36 0.308137
-0.3 0.259489
-0.24 0.2094
-0.18 0.158121
-0.12 0.10593
-0.06 0.0531214
-1.11022e-16 9.8391e-17
0.06 -0.0531214
0.12 -0.10593
0.18 -0.158121
0.24 -0.2094
0.3 -0.259489
0.36 -0.308137
0.42 -0.355116
0.48 -0.40023
0.54 -0.443314
0.6 -0.48424
0.66 -0.522911
0.72 -0.559268
0.78 -0.59328
0.84 -0.624951
0.9 -0.654311
0.96 -0.681414
1.02 -0.706337
1.08 -0.729172
1.14 -0.750029
1.2 -0.769024
1.26 -0.786282
1.32 -0.801931
1.38 -0.8161
1.44 -0.828916
1.5 -0.840503
1.56 -0.850978
1.62 -0.860453
1.68 -0.869032
1.74 -0.87681
1.8 -0.883875
1.86 -0.890307
1.92 -0.896176
1.98 -0.901547
2.04 -0.906476
2.1 -0.911012
2.16 -0.915199
2.22 -0.919075
2.28 -0.922673
2.34 -0.926023
2.4 -0.929149
2.46 -0.932074
2.52 -0.934816
2.58 -0.937392
2.64 -0.939817
2.7 -0.942103
2.76 -0.944261
2.82 -0.946302
2.88 -0.948234
2.94 -0.950065
Test-hashedWordList.C
EXE = $(FOAM_USER_APPBIN)/Test-hashedWordList
/* EXE_INC = -I$(LIB_SRC)/finiteVolume/lnInclude */
/* EXE_LIBS = -lfiniteVolume */
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2021 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
\*---------------------------------------------------------------------------*/
#include "IOstreams.H"
#include "ITstream.H"
#include "FlatOutput.H"
#include "hashedWordList.H"
using namespace Foam;
Ostream& printInfo(const hashedWordList& list, bool withAddr=false)
{
Info<< flatOutput(list) << nl << list.lookup() << nl;
if (withAddr)
{
Info<< "addr=" << name(list.cdata()) << nl;
}
return Info;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
Info<< "Test hashedWordList" << nl;
hashedWordList list1
{
"this",
"is",
"a",
"list",
"of",
"words",
};
Info<<nl << "From initializer_list" << nl;
printInfo(list1, true);
list1.sort();
Info<<nl << "sorted" << nl;
printInfo(list1, true);
// Copy construct
hashedWordList list2(list1);
Info<<nl << "Copy construct" << nl;
Info<<"list1: ";
printInfo(list1, true);
Info<<"list2: ";
printInfo(list2, true);
// Move construct
hashedWordList list3(std::move(list1));
Info<<nl << "Move construct" << nl;
Info<<"list1: ";
printInfo(list1, true);
Info<<"list3: ";
printInfo(list3, true);
// Move assign
list1 = std::move(list3);
Info<<nl << "Move assign" << nl;
Info<<"list1: ";
printInfo(list1, true);
Info<<"list3: ";
printInfo(list3, true);
list1.swap(list3);
Info<<nl << "Swap" << nl;
Info<<"list1: ";
printInfo(list1, true);
Info<<"list3: ";
printInfo(list3, true);
wordList wlist1
{
"plain", "list", "with", "some", "with", "list", "duplicates"
};
// Copy construct unique
hashedWordList list4(wlist1, true);
Info<<nl << "Copy construct unique" << nl;
Info<<"words: " << flatOutput(wlist1) << nl;
Info<<"list4: ";
printInfo(list4, false);
// Move construct unique
hashedWordList list5(std::move(wlist1), true);
Info<<nl << "Move construct unique" << nl;
Info<<"words: " << flatOutput(wlist1) << nl;
Info<<"list5: ";
printInfo(list5, false);
// Move back. Leaves lookup() with some rubbish, but clean that later
wlist1 = std::move(list5);
Info<<nl << "Move to wordList" << nl;
Info<<"words: " << flatOutput(wlist1) << nl;
Info<<"list5: ";
printInfo(list5, false);
// Move back. Leaves lookup() with some rubbish, but clean that later
list5 = std::move(wlist1);
Info<<nl << "Moved from wordList" << nl;
Info<<"words: " << flatOutput(wlist1) << nl;
Info<<"list5: ";
printInfo(list5, false);
// Test access:
Info<<nl << "Access" << nl;
Info<<"list: " << flatOutput(list5) << nl;
for (const auto str : { "some", "list", "of", "words" })
{
Info<<"index of " << str << " = " << list5[str] << nl;
}
// Stream construct
{
ITstream input
(
"(plain list with some with list duplicates)"
);
hashedWordList list6(input);
Info<<nl << "Construct from stream" << nl;
Info<<"list: " << flatOutput(list6) << nl;
input.rewind();
input >> list4;
Info<<nl << "re-read from stream" << nl;
Info<<"list: " << flatOutput(list4) << nl;
}
Info<< "\nEnd\n";
return 0;
}
// ************************************************************************* //
Test-hexRef8.C
EXE = $(FOAM_USER_APPBIN)/Test-hexRef8
EXE_INC = \
-DFULLDEBUG -g -O0 \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-ldynamicMesh
Test application for volField and surfaceField mapping with
refinement/unrefinement
Run
block/Allrun
to compile and map a few fields. Note that hexRef8 cannot be
run in inflation mode - there is the problem of getting
a set of faces to sweep that is consistent for a cell and
all its neighbours.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment