Commit 1849d86a authored by Andrew Heather's avatar Andrew Heather
Browse files
parents c4fd345a 2c62c83b
......@@ -3,8 +3,8 @@ cd ${0%/*} || exit 1 # run from this directory
if [ "$PWD" != "$WM_PROJECT_DIR" ]
then
echo "Error: Current directory in not \$WM_PROJECT_DIR"
echo " The environment variable are not consistent with the installation."
echo "Error: Current directory is not \$WM_PROJECT_DIR"
echo " The environment variables are inconsistent with the installation."
echo " Check the OpenFOAM entries in your dot-files and source them."
exit 1
fi
......
......@@ -3,8 +3,8 @@ cd ${0%/*} || exit 1 # run from this directory
if [ "$PWD" != "$WM_PROJECT_DIR/applications" ]
then
echo "Error: Current directory in not \$WM_PROJECT_DIR/applications"
echo " The environment variable are not consistent with the installation."
echo "Error: Current directory is not \$WM_PROJECT_DIR/applications"
echo " The environment variables are inconsistent with the installation."
echo " Check the OpenFOAM entries in your dot-files and source them."
exit 1
fi
......
......@@ -82,7 +82,7 @@
(
"kappa",
wallFunctionDict,
0.4187
0.41
)
);
......@@ -92,7 +92,7 @@
(
"E",
wallFunctionDict,
9.0
9.8
)
);
......
......@@ -304,7 +304,7 @@
(
"kappa",
wallFunctionDict,
0.4187
0.41
)
);
......@@ -314,7 +314,7 @@
(
"E",
wallFunctionDict,
9.0
9.8
)
);
......
#include "Xstream.H"
#include "GLstream.H"
#include "PSstream.H"
#include "shapes2D.H"
#include "IStringStream.H"
using namespace Foam;
int main()
{
colour mauve("mauve", 1, 0, 1);
lineStyle solid("Solid", 2.0, 2.0, IStringStream("1(1.0)")());
lineStyle broken("Broken", 2.0, 10.0, IStringStream("4(1 1 4 1)")());
//Xstream wind
GLstream wind
//PSstream wind
(
"GsTest",
primary("Black"),
primary("White"),
0.5, 0.5, 0.5, 0.5, 500, 500
);
do
{
wind << rectangle2D(point2D(0.0, 0.0), point2D(100.0, 100.0));
wind.setColour(mauve);
wind.setLineStyle(solid);
wind << line2D(point2D(0.0, 0.0), point2D(0.0, 200.0));
wind << line2D(point2D(0.0, 200.0), point2D(200.0, 200.0));
//wind.setLineStyle(broken);
wind << line2D(point2D(200.0, 200.0), point2D(200.0, 0.0));
wind << line2D(point2D(200.0, 0.0), point2D(0.0, 0.0));
wind << string2D(point2D(200.0, 0.0), "Hi there");
} while (wind.waitForEvent());
return 0;
}
GsTest.C
EXE = $(FOAM_USER_APPBIN)/GsTest
EXE_INC = -I$(LIB_SRC)/Gstream/lnInclude
EXE_LIBS = -lGstream -lGL $(XLIBS)
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "IStringStream.H"
#include "myBoundBox.H"
#include "myBoundBoxList.H"
#include "octree.H"
#include "octreeData.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::validOptions.insert("x1", "X1");
argList::validOptions.insert("y1", "Y1");
argList::validOptions.insert("z1", "Z1");
argList::validOptions.insert("x2", "X2");
argList::validOptions.insert("y2", "Y2");
argList::validOptions.insert("z2", "Z2");
# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
// Calculate BB of all cells
myBoundBoxList allBb(mesh.nCells());
const pointField& allPoints = mesh.points();
vectorField bbMin(mesh.nCells());
bbMin = vector(GREAT, GREAT, GREAT);
vectorField bbMax(mesh.nCells());
bbMax = vector(-GREAT, -GREAT, -GREAT);
const labelListList& pCells = mesh.pointCells();
forAll(pCells, pointi)
{
const point& vertCoord = allPoints[pointi];
const labelList& cells = pCells[pointi];
forAll(cells, celli)
{
label cellNum = cells[celli];
bbMin[cellNum].x() = min(bbMin[cellNum].x(), vertCoord.x());
bbMin[cellNum].y() = min(bbMin[cellNum].y(), vertCoord.y());
bbMin[cellNum].z() = min(bbMin[cellNum].z(), vertCoord.z());
bbMax[cellNum].x() = max(bbMax[cellNum].x(), vertCoord.x());
bbMax[cellNum].y() = max(bbMax[cellNum].y(), vertCoord.y());
bbMax[cellNum].z() = max(bbMax[cellNum].z(), vertCoord.z());
}
}
forAll(allBb, celli)
{
allBb[celli] = myBoundBox(bbMin[celli], bbMax[celli]);
}
myBoundBox meshBb(allPoints);
scalar typDim = meshBb.minDim()/111;
myBoundBox shiftedBb
(
meshBb.min(),
point
(
meshBb.max().x() + typDim,
meshBb.max().y() + typDim,
meshBb.max().z() + typDim
)
);
Info<< "Mesh" << endl;
Info<< " bounding box :" << shiftedBb << endl;
Info<< " typical dimension:" << shiftedBb.typDim() << endl;
/*
* Now we have allBb and shiftedBb
*/
// Construct table of subset of cells
labelList cellIndices(10);
cellIndices[0] = 1433;
cellIndices[1] = 1434;
cellIndices[2] = 1435;
cellIndices[3] = 1436;
cellIndices[4] = 1437;
cellIndices[5] = 1438;
cellIndices[6] = 1439;
cellIndices[7] = 1440;
cellIndices[8] = 1441;
cellIndices[9] = 1442;
// Get the corresponding bounding boxes
forAll(cellIndices, i)
{
allBb[i] = allBb[cellIndices[i]];
}
allBb.setSize(cellIndices.size());
// Wrap indices and mesh information into helper object
octreeData shapes(mesh, cellIndices);
octree oc
(
shiftedBb, // overall bounding box
shapes, // all information needed to do checks on cells
allBb, // bounding boxes of cells
10.0 // maximum ratio of cubes v.s. cells
);
// scalar x1(readScalar(IStringStream(args.options()["x1"])()));
// scalar y1(readScalar(IStringStream(args.options()["y1"])()));
// scalar z1(readScalar(IStringStream(args.options()["z1"])()));
// scalar x2(readScalar(IStringStream(args.options()["x2"])()));
// scalar y2(readScalar(IStringStream(args.options()["y2"])()));
// scalar z2(readScalar(IStringStream(args.options()["z2"])()));
label nFound = 0;
scalar x = -5.0;
for(int i = 0; i < 100; i++)
{
scalar y = -7.0;
for(int j = 0; j < 10; j++)
{
scalar z = -12.0;
for (int k = 0; k < 10; k++)
{
point sample(x, y, z);
label index = oc.find(sample);
// Convert index into shapes back into cellindex.
label cell;
if (index != -1)
{
cell = cellIndices[index];
}
else
{
cell = -1;
}
Info<< "Point:" << sample
<< " is in cell " << cell << "(octree) "
<< mesh.findCell(sample) << "(linear)"
<< endl;
z += 1.2;
}
y += 0.9;
}
x += 0.1;
}
Info<< "nFound=" << nFound << endl;
Info<< "End\n" << endl;
Info<< "Statistics:" << endl
<< " nCells :" << allBb.size() << endl
<< " nNodes :" << oc.nNodes() << endl
<< " nLeaves :" << oc.nLeaves() << endl
<< " nEntries :" << oc.nEntries() << endl
<< " Cells per leaf :"
<< oc.nEntries()/oc.nLeaves()
<< endl
<< " Every cell in :"
<< oc.nEntries()/allBb.size() << " cubes"
<< endl;
return 0;
}
// ************************************************************************* //
fvSolutionCombine.C
EXE = $(FOAM_USER_APPBIN)/fvSolutionCombine
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \
-lfiniteVolume
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
fvSolutionCombine
Description
Simple utility for combining fvSolution solution entries.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "wordRe.H"
#include "OSspecific.H"
using namespace Foam;
// check for identical dictionary content, regardless of the order
bool checkDictionaryContent(const dictionary& dict1, const dictionary& dict2)
{
// trivial cases first
if (&dict1 == &dict2)
{
return true;
}
else if (dict1.size() != dict2.size())
{
return false;
}
forAllConstIter(dictionary, dict1, iter1)
{
const entry* entryPtr = dict2.lookupEntryPtr
(
iter1().keyword(),
false,
false
);
if (!entryPtr)
{
return false;
}
const entry& entry1 = iter1();
const entry& entry2 = *entryPtr;
bool ok = false;
if (entry1.isDict())
{
if (entry2.isDict())
{
ok = checkDictionaryContent(entry1.dict(), entry2.dict());
}
}
else
{
ok = (entry1 == entry2);
}
if (!ok)
{
return false;
}
}
return true;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noParallel();
argList::validOptions.insert("rewrite", "");
argList::validOptions.insert("show", "");
argList args(argc, argv);
Time runTime(args.rootPath(), args.caseName());
const word dictName("fvSolution");
bool optRewrite = args.optionFound("rewrite");
bool optShow = args.optionFound("show");
IOdictionary solutionDict
(
IOobject
(
dictName,
"system",
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
if (!solutionDict.found("solvers"))
{
Info<<"no solvers entry found in : " << dictName << endl;
return 2;
}
if (optRewrite && solutionDict.instance() != "system")
{
Info<<"instance is not 'system' "
"- disabling rewrite for this file" << nl;
optRewrite = false;
}
dictionary& solverDict = solutionDict.subDict("solvers");
wordList names = solverDict.toc();
wordList oldNames = names;
bool changed = false;
for (label orig = 0; orig < names.size()-1; ++orig)
{
// skip patterns or entries that have already been done
if (names[orig].empty() || wordRe::isPattern(names[orig]))
{
continue;
}
const dictionary& dict1 = solverDict.subDict(names[orig]);
for (label check = orig+1; check < names.size(); ++check)
{
// skip patterns or entries that have already been done
if (names[check].empty() || wordRe::isPattern(names[check]))
{
continue;
}
const dictionary& dict2 = solverDict.subDict(names[check]);
// check for identical content
if (checkDictionaryContent(dict1, dict2))
{
names[orig] += "|" + names[check];
names[check].clear();
changed = true;
}
}
}
if (changed)
{
forAll(names, nameI)
{
if (names[nameI].empty())
{
solverDict.remove(oldNames[nameI]);
Info<<" #remove " << oldNames[nameI];
}
else
{
Info<< " " << oldNames[nameI];
if (names[nameI] != oldNames[nameI])
{
// make "(abc|def)" pattern
keyType renamed( "(" + names[nameI] + ")", true);
solverDict.changeKeyword(oldNames[nameI], renamed);
Info<< " -> " << renamed;
}
}
Info<< endl;
}
if (optRewrite)
{
mvBak(solutionDict.objectPath(), "orig");
Info<< "Backup to .orig" << nl
<< "Writing " << solutionDict.objectPath() << nl << endl;
solutionDict.regIOobject::write();
}
else if (optShow)
{
IOobject::writeDivider(Info);
solutionDict.dictionary::write(Info, false);
}
else
{
Info<< "\nFile not rewritten" << endl;
}
}
else
{
Info<< "no changes" << endl;
}
Info<< "Done\n" << endl;
return changed ? 0 : 1;
}
// ************************************************************************* //
......@@ -7,4 +7,5 @@ EXE_INC = \
EXE_LIBS = \
-ldynamicMesh \
-lmeshTools \
-lfiniteVolume
-lfiniteVolume \
-lgenericPatchFields
......@@ -6,4 +6,5 @@ EXE_INC = \
EXE_LIBS = \
-lmeshTools \
-ldynamicMesh \
-lfiniteVolume
-lfiniteVolume \
-lgenericPatchFields