Skip to content

Commit a1bae2b

Browse files
committed
fork all non-python functionality from foamio
0 parents  commit a1bae2b

File tree

29 files changed

+2963
-0
lines changed

29 files changed

+2963
-0
lines changed

.gitignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# C extensions
2+
*.dylib
3+
*.so
4+
5+
# OpenFOAM stuff:
6+
darwin*Clang*/
7+
linux*Clang*/
8+
linux*Gcc*/
9+
linux*Icc*/
10+
lnInclude/
11+

LICENSE

+674
Large diffs are not rendered by default.

README.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# froth
2+
`froth` is OpenFOAM addons (including libraries) and `$WM_PROJECT_SITE` case templates.
3+
4+
## addons
5+
Add custom #includeEtc dictionaries by setting `WM_PROJECT_SITE`
6+
```sh
7+
export WM_PROJECT_SITE=$HOME/Documents/froth
8+
```
9+
10+
## ParaView
11+
Animate ParaView state using `pvbatch`:
12+
```sh
13+
field=U
14+
pvbatch $WM_PROJECT_SITE/etc/visualise.py state.pvsm animate /tmp/frames/$field.png --dict $WM_PROJECT_SITE/etc/caseDicts/postProcessing/visualisation/animation.png.json &&
15+
ffmpeg -y -framerate 10 -pattern_type glob -i "$c$s$t/postProcessing/frames/$field.*.png" -qscale:v 8 -codec:a libvorbis postProcessing/U.ogv &&
16+
rm -rf postProcessing/frames/$field.*.png
17+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
wedgeMesh.C
2+
3+
EXE = $(FOAM_USER_APPBIN)/wedgeMesh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
EXE_INC = \
2+
-I$(LIB_SRC)/dynamicMesh/lnInclude \
3+
-I$(LIB_SRC)/meshTools/lnInclude
4+
5+
EXE_LIBS = \
6+
-ldynamicMesh \
7+
-lmeshTools
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
/*---------------------------------------------------------------------------*\
2+
========= |
3+
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4+
\\ / O peration | Website: https://openfoam.org
5+
\\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
6+
\\/ M anipulation |
7+
-------------------------------------------------------------------------------
8+
License
9+
This file is originating from OpenFOAM and modified by the
10+
authors described below.
11+
12+
OpenFOAM is free software: you can redistribute it and/or modify it
13+
under the terms of the GNU General Public License as published by
14+
the Free Software Foundation, either version 3 of the License, or
15+
(at your option) any later version.
16+
17+
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
18+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20+
for more details.
21+
22+
You should have received a copy of the GNU General Public License
23+
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
24+
25+
Application
26+
wedgeMesh
27+
28+
Description
29+
Create a wedge from a 2D cartesian mesh.
30+
31+
Authors
32+
Stanislau Stasheuski, Aalto University, 2023
33+
34+
35+
Kristjan Krebelj, University of Ljubljana, 2020
36+
37+
Henry Weller, CFD-Direct, 2022.
38+
39+
\*---------------------------------------------------------------------------*/
40+
41+
#include "argList.H"
42+
#include "Time.H"
43+
#include "polyMesh.H"
44+
#include "unitConversion.H"
45+
#include "emptyPolyPatch.H"
46+
47+
using namespace Foam;
48+
49+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50+
51+
label parseComponent(const word& axisName) {
52+
if (axisName == "X")
53+
{
54+
return vector::X;
55+
}
56+
else if (axisName == "Y")
57+
{
58+
return vector::Y;
59+
}
60+
else if (axisName == "Z")
61+
{
62+
return vector::Z;
63+
}
64+
65+
FatalErrorInFunction
66+
<< "Invalid axis name.\nValid names are: X, Y, Z"
67+
<< exit(FatalError);
68+
return -1; // prevent comilation warning
69+
}
70+
71+
int main(int argc, char *argv[])
72+
{
73+
#include "addRegionOption.H"
74+
75+
argList::addNote
76+
(
77+
"Creates a wedge from a 2D cartesian mesh by specifying normals to wedge plane\n"
78+
"and axis patch."
79+
);
80+
81+
argList::validArgs.append("plane");
82+
argList::validArgs.append("axis normal");
83+
argList::validArgs.append("angle[0-5]");
84+
85+
#include "setRootCase.H"
86+
#include "createTime.H"
87+
#include "createNamedPolyMesh.H"
88+
89+
const label plane = parseComponent(args.argRead<word>(1)),
90+
axis = parseComponent(args.argRead<word>(2));
91+
const scalar wedgeAngle = args.argRead<scalar>(3);
92+
93+
Foam::word meshRegionName = polyMesh::defaultRegion;
94+
args.optionReadIfPresent("region", meshRegionName);
95+
96+
const fileName meshRegionSubDir = meshRegionName != polyMesh::defaultRegion
97+
? meshRegionName/polyMesh::meshSubDir
98+
: fileName(polyMesh::meshSubDir);
99+
100+
pointIOField points
101+
(
102+
IOobject
103+
(
104+
"points",
105+
runTime.findInstance(meshRegionSubDir, "points"),
106+
meshRegionSubDir,
107+
runTime,
108+
IOobject::MUST_READ,
109+
IOobject::NO_WRITE,
110+
false
111+
)
112+
);
113+
114+
const point midPoint = gAverage(points);
115+
116+
Info<< "Wedge: " << wedgeAngle << " deg" << nl << endl;
117+
118+
const scalar halfCos = Foam::cos(degToRad(0.5*wedgeAngle)),
119+
halfSin = Foam::sin(degToRad(0.5*wedgeAngle));
120+
121+
forAll(points, pointI)
122+
{
123+
points[pointI].replace(
124+
plane,
125+
points[pointI].component(plane) < midPoint.component(plane)
126+
? - halfSin*points[pointI].component(axis)
127+
: + halfSin*points[pointI].component(axis)
128+
);
129+
points[pointI].replace(
130+
axis,
131+
halfCos*points[pointI].component(axis)
132+
);
133+
}
134+
135+
Info<< "Writing points into directory " << points.path() << nl << endl;
136+
points.write();
137+
138+
Info<< "End\n" << endl;
139+
140+
return 0;
141+
}
142+
143+
144+
// ************************************************************************* //

0 commit comments

Comments
 (0)