"src/lib/vscode:/vscode.git/clone" did not exist on "53adc6a0cad17a9a9b94a54585283cb61ae7eaff"
Commit 55e5a777 authored by shunbo's avatar shunbo
Browse files

initial commit

parents
/* 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) 2011-2015 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/>.
Description
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "timeSelector.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noParallel();
// timeSelector::addOptions();
timeSelector::addOptions(true, true);
#include "setRootCase.H"
#include "createTime.H"
Info<< "Times found:" << runTime.times() << endl;
instantList timeDirs = timeSelector::select0(runTime, args);
Info<< "Times selected:" << timeDirs << endl;
Info<< "\nEnd\n" << endl;
return 0;
}
// ************************************************************************* //
Test-flatOuput1.C
EXE = $(FOAM_USER_APPBIN)/Test-flatOuput1
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 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
Simple test of FlatOutput
\*---------------------------------------------------------------------------*/
#include "wordList.H"
#include "ListOps.H"
#include "FlatOutput.H"
#include "IOstreams.H"
#include "macros.H"
using namespace Foam;
// For testing various pre-defined formatting
#define printFlatOutput(Content, Format) \
STRINGIFY(Format) << ": " << flatOutput(Content, FlatOutput::Format{})
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
wordList words1
{
"ab", "cd", "ef", "gh",
"ij", "kl", "mn", "op",
"qr", "st", "uv", "wx", "yz"
};
{
Info<< nl
<< "regular" << nl
<< "#----------------" << nl;
Info<< nl << "operator<< " << words1 << nl;
Info<< nl << "writeList: ";
words1.writeList(Info) << nl;
}
Info<< nl
<< "Using c++ " << int(__cplusplus) << nl;
{
Info<< nl
<< "flatOutput" << nl
<< "#----------------" << nl;
Info<< nl << "operator<< " << flatOutput(words1) << nl;
Info<< nl << "write: ";
flatOutput(words1).write(Info) << nl;
Info<< nl << printFlatOutput(words1, BareComma) << nl;
Info<< nl << printFlatOutput(words1, BareSpace) << nl;
Info<< nl << printFlatOutput(words1, BraceComma) << nl;
Info<< nl << printFlatOutput(words1, BraceSpace) << nl;
Info<< nl << printFlatOutput(words1, ParenComma) << nl;
Info<< nl << printFlatOutput(words1, ParenSpace) << nl;
Info<< nl << printFlatOutput(words1, PointyComma) << nl;
Info<< nl << printFlatOutput(words1, PointySpace) << nl;
Info<< nl << printFlatOutput(words1, SquareComma) << nl;
Info<< nl << printFlatOutput(words1, SquareSpace) << nl;
}
Info<< "\nEnd\n" << endl;
return 0;
}
// ************************************************************************* //
foamCellZoneToVTK.C
EXE = $(FOAM_USER_APPBIN)/foamCellZoneToVTK
EXE_INC = \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lfileFormats \
-lmeshTools
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 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/>.
Application
foamCellZoneToVTK.C
Description
Write tet-decomposed OpenFOAM mesh in VTK format.
For diagnostic purposes.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "timeSelector.H"
#include "Time.H"
#include "polyMesh.H"
#include "foamVtkInternalMeshWriter.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::addNote
(
"Write OpenFOAM cellZone mesh to VTK"
);
argList::addOption
(
"cellZone",
"name",
"Convert mesh subset corresponding to specified cellZone"
);
argList::addBoolOption
(
"list",
"List names of cellZones and exit"
);
timeSelector::addOptions();
#include "setRootCase.H"
word cellZoneName;
args.readIfPresent("cellZone", cellZoneName);
const bool optList = args.found("list");
if (optList)
{
if (!cellZoneName.empty())
{
Info<< "specify -list or -cellZone, but not both!" << nl;
return 1;
}
}
else if (cellZoneName.empty())
{
Info<< "Did not specify a cellZone!!" << nl;
return 1;
}
#include "createTime.H"
instantList timeDirs = timeSelector::select0(runTime, args);
fileName exportName("zonemesh-" + cellZoneName);
#include "createPolyMesh.H"
forAll(timeDirs, timei)
{
runTime.setTime(timeDirs[timei], timei);
polyMesh::readUpdateState state = mesh.readUpdate();
if (!timei || state != polyMesh::UNCHANGED)
{
fileName meshName(exportName);
if (state != polyMesh::UNCHANGED)
{
meshName += '_' + runTime.timeName();
}
if (optList)
{
Info<< "cellZones:" << nl;
for (const word& name : mesh.cellZones().names())
{
Info<< " " << name << nl;
}
}
else
{
const cellZone* zonePtr =
mesh.cellZones().cfindZone(cellZoneName);
Info<< "cellZone " << cellZoneName;
if (!zonePtr)
{
Info<< " ... not found" << nl;
continue;
}
Info<< nl;
const cellZone& zn = *zonePtr;
// Define a subset
vtk::vtuCells vtuCells;
vtuCells.reset(mesh, zn);
vtk::internalMeshWriter writer
(
mesh,
vtuCells,
fileName
(
mesh.time().globalPath() / meshName
)
);
writer.writeGeometry();
writer.beginCellData();
writer.writeProcIDs();
Info<< "Wrote " << writer.output().name() << nl;
}
}
}
Info<< "\nEnd\n" << endl;
return 0;
}
// ************************************************************************* //
Test-foamEnv.C
EXE = $(FOAM_USER_APPBIN)/Test-foamEnv
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 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-etcFiles
Description
Test etcFiles functionality.
Similar to foamEtcFile script, but automatically prunes nonexistent
directories from the list.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "OSspecific.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noBanner();
argList::noParallel();
argList::noFunctionObjects();
argList::removeOption("case");
argList::addArgument("env...");
argList::addNote
(
"Simple test/report OpenFOAM environment"
);
argList args(argc, argv, false, true);
for (int argi = 1; argi < args.size(); ++argi)
{
const std::string envName(args[argi]);
if (hasEnv(envName))
{
Info<<"Have env " << envName.c_str() << "=" << getEnv(envName)
<< nl;
}
else
{
Info<<"No env " << envName.c_str()<< nl;
}
}
return 0;
}
// ************************************************************************* //
foamMeshToTet-vtk.C
writeVTKtetMesh.C
EXE = $(FOAM_USER_APPBIN)/foamMeshToTet-vtk
EXE_INC = \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lfileFormats \
-lmeshTools
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 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/>.
Application
foamMeshToTet-vtk
Description
Write tet-decomposed OpenFOAM mesh in VTK format.
For diagnostic purposes.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "timeSelector.H"
#include "Time.H"
#include "polyMesh.H"
namespace Foam
{
void writeVTKtetMesh(const fileName& output, const polyMesh& mesh);
}
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::addNote
(
"Write tet-decomposed OpenFOAM mesh in VTK"
);
argList::noParallel();
timeSelector::addOptions();
#include "setRootCase.H"
#include "createTime.H"
instantList timeDirs = timeSelector::select0(runTime, args);
fileName exportName = "tetmesh";
if (args.found("case"))
{
exportName += '-' + args.globalCaseName();
}
#include "createPolyMesh.H"
forAll(timeDirs, timei)
{
runTime.setTime(timeDirs[timei], timei);
polyMesh::readUpdateState state = mesh.readUpdate();
if (!timei || state != polyMesh::UNCHANGED)
{
fileName meshName(exportName);
if (state != polyMesh::UNCHANGED)
{
meshName += '_' + runTime.timeName();
}
writeVTKtetMesh(meshName, mesh);
}
}
Info<< "\nEnd\n" << endl;
return 0;
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 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/>.
\*---------------------------------------------------------------------------*/
#include "polyMesh.H"
#include "Fstream.H"
#include "tetMatcher.H"
#include "foamVtkInternalMeshWriter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
void writeVTKtetMesh(const fileName& output, const polyMesh& mesh_)
{
#if WM_LABEL_SIZE == 64
# define FOAM_VTK_LABEL_NAME "vtktypeint64"
#else
# define FOAM_VTK_LABEL_NAME "int"
#endif
const faceList& faces = mesh_.faces();
const labelList& faceOwner = mesh_.faceOwner();
label nTets = 0;
for (label facei = 0; facei < mesh_.nInternalFaces(); ++facei)
{
nTets += 2 * faces[facei].nTriangles();
}
for (label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); ++facei)
{
nTets += faces[facei].nTriangles();
}
const label nPoints = (mesh_.nPoints() + mesh_.nCells());
OFstream os(output + ".vtk");
Info<< "Write: " << os.name() << nl;
os << "# vtk DataFile Version 5.1" << nl
<< "tet-mesh" << nl
<< "ASCII" << nl
<< "DATASET UNSTRUCTURED_GRID" << nl
<< nl;
os << "POINTS " << nPoints << " float" << nl;
for (const point& p : mesh_.points())
{
os << float(p.x()) << ' '
<< float(p.y()) << ' '
<< float(p.z()) << nl;
}
for (const point& p : mesh_.cellCentres())
{
os << float(p.x()) << ' '
<< float(p.y()) << ' '
<< float(p.z()) << nl;
}
os << nl;
os << "CELLS " << (1 + nTets) << ' ' << (4 * nTets) << nl;
os << "OFFSETS " << FOAM_VTK_LABEL_NAME << nl
<< 0; // begin offset = 0
{
label offset = 0;
for (label teti = 0; teti < nTets; ++teti)
{
offset += 4;
os << ' ' << offset;
}
os << nl << nl;
}
labelList nLocalTets(mesh_.nCells(), Zero);
os << nl
<< "CONNECTIVITY " << FOAM_VTK_LABEL_NAME << nl;
for (label celli = 0; celli < mesh_.nCells(); ++celli)
{
const cell& cFaces = mesh_.cells()[celli];
if (tetMatcher::test(mesh_, celli))
{
// Tet: no cell-centre decomposition
const label facei = cFaces[0];
const face& f0 = faces[facei];
// Get the other point from f1. Tbd: check if not duplicate face
// (ACMI / ignoreBoundaryFaces_).
const face& f1 = faces[cFaces[1]];
label apexi = -1;
forAll(f1, fp)
{
apexi = f1[fp];
if (!f0.found(apexi))
{
break;
}
}
const label p0 = f0[0];
label p1 = f0[1];
label p2 = f0[2];
if (faceOwner[facei] == celli)
{
std::swap(p1, p2);
}
++nLocalTets[celli];
os << p0 << ' ' << p1 << ' ' << p2 << ' ' << apexi << nl;
}
else
{
for (const label facei : cFaces)
{
const face& f = faces[facei];
label fp0 = mesh_.tetBasePtIs()[facei];
// Fallback
if (fp0 < 0)
{
fp0 = 0;
}
const label p0 = f[fp0];
label fp = f.fcIndex(fp0);
for (label i = 2; i < f.size(); ++i)
{
label p1 = f[fp];
fp = f.fcIndex(fp);
label p2 = f[fp];
if (faceOwner[facei] == celli)
{
std::swap(p1, p2);
}
++nLocalTets[celli];
os << p0 << ' ' << p1 << ' ' << p2 << ' '
<< (mesh_.nPoints() + celli) << nl;
}
}
}
}
os << nl
<< "CELL_TYPES " << nTets << nl;
for (label teti = 0; teti < nTets; ++teti)
{
if (teti) os << ' ';
os << vtk::cellType::VTK_TETRA;
}
os << nl;
os << nl << "CELL_DATA " << nTets << nl
<< "FIELD FieldData " << 1 << nl;
os << "cellID " << 1 << ' ' << nTets << " int" << nl;
forAll(nLocalTets, celli)
{
label n = nLocalTets[celli];
while (n--)
{
os << ' ' << celli;
}
os << nl;
}
}
} // End namespace Foam
// ************************************************************************* //
foamToMetisGraph.C
EXE = $(FOAM_USER_APPBIN)/foamToMetisGraph
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 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
Create a metis graph file representation of an OpenFOAM mesh
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "polyMesh.H"
#include "OFstream.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noParallel();
argList::noFunctionObjects();
argList::addNote
(
"Create a metis graph file representation for an OpenFOAM mesh"
);
#include "setRootCase.H"
#include "createTime.H"
#include "createPolyMesh.H"
const labelListList& cellCells = mesh.cellCells();
// No. of Nodes = nCells
// No. of Edges connecting Nodes = nInternalFaces
OFstream os(args.caseName() + ".graph", IOstream::ASCII);
os << "%% metis graph file, of an OpenFOAM mesh %%" << nl
<< "%% nCells=" << mesh.nCells()
<< " nFaces=" << mesh.nFaces()
<< " nInternalFaces=" << mesh.nInternalFaces() << nl;
os << cellCells.size() << " " << mesh.nInternalFaces() << nl;
for (const auto& edges : cellCells)
{
forAll(edges, i)
{
if (i) os << " ";
os << edges[i] + 1; // index starts at 1.
}
os << nl;
}
Info<<"Wrote graph with "
<< mesh.nCells() << " nodes and "
<< mesh.nInternalFaces() << " edges to "
<< os.name() << nl;
Info<< nl << "End\n" << endl;
return 0;
}
// ************************************************************************* //
Test-foamVersion.C
EXE = $(FOAM_USER_APPBIN)/Test-foamVersion
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