Skip to content

Commit 226e863

Browse files
committed
source and tutorial files are added.
1 parent f006b7b commit 226e863

190 files changed

Lines changed: 24068 additions & 589 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

20181116OpenFOAMカスタマイズ入門v2.md

Lines changed: 0 additions & 583 deletions
This file was deleted.

lecture_note.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -766,9 +766,9 @@ Foam::viscosityModels::newCrossPowerLaw::calcNu() //const//const is commented ou
766766
)
767767
```
768768
769-
参考のために,作成したコード類を圧縮して添付する
769+
参考のために,作成したコード類を共有する
770770
771-
[newCrossPowerLaw.zip](/attachments/976f92c0-cadb-4220-a070-0a8c87d42859)
771+
[newCrossPowerLaw](./src/newCrossPowerLaw/)
772772
773773
<a name="compileModifiedNewCrossPowerLaw"></a>
774774
### コンパイル
@@ -786,13 +786,13 @@ wmake
786786

787787
# サンプルファイル
788788

789-
[mySimpleFoam.zip](/attachments/e42a3a60-757a-408b-b918-543ca687e5b1)
789+
[mySimpleFoam](./solvers/mySimpleFoam/)
790790

791-
[transportModels.zip](/attachments/3d84c444-9e6e-4c57-afe6-58dba488c034)
791+
[transportModels](./src/transportModels/)
792792

793-
[newCrossPowerLaw.zip](/attachments/b69b120f-646d-49bb-8a19-201b620554b3)
793+
[newCrossPowerLaw](./src/newCrossPowerLaw/)
794794

795-
[simpleCar.zip](/attachments/422b2e0b-2e6e-4adc-9b4b-e6bc1158fb49)
795+
[simpleCar](./tutorials/simpleCar/)
796796

797797

798798

solvers/mySimpleFoam/Make/files

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
mySimpleFoam.C
2+
3+
EXE = $(FOAM_USER_APPBIN)/mySimpleFoam

solvers/mySimpleFoam/Make/options

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
EXE_INC = \
2+
-I$(LIB_SRC)/finiteVolume/lnInclude \
3+
-I$(LIB_SRC)/meshTools/lnInclude \
4+
-I$(LIB_SRC)/sampling/lnInclude \
5+
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
6+
-I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
7+
-I$(LIB_SRC)/transportModels \
8+
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel
9+
10+
EXE_LIBS = \
11+
-lfiniteVolume \
12+
-lfvOptions \
13+
-lmeshTools \
14+
-lsampling \
15+
-lturbulenceModels \
16+
-lincompressibleTurbulenceModels \
17+
-lincompressibleTransportModels \
18+
-latmosphericModels

solvers/mySimpleFoam/UEqn.H

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Momentum predictor
2+
3+
MRF.correctBoundaryVelocity(U);
4+
5+
tmp<fvVectorMatrix> tUEqn
6+
(
7+
fvm::div(phi, U)
8+
+ MRF.DDt(U)
9+
+ turbulence->divDevReff(U)
10+
==
11+
fvOptions(U)
12+
);
13+
fvVectorMatrix& UEqn = tUEqn.ref();
14+
15+
UEqn.relax();
16+
17+
fvOptions.constrain(UEqn);
18+
19+
if (simple.momentumPredictor())
20+
{
21+
solve(UEqn == -fvc::grad(p));
22+
23+
fvOptions.correct(U);
24+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Info<< "Reading field p\n" << endl;
2+
volScalarField p
3+
(
4+
IOobject
5+
(
6+
"p",
7+
runTime.timeName(),
8+
mesh,
9+
IOobject::MUST_READ,
10+
IOobject::AUTO_WRITE
11+
),
12+
mesh
13+
);
14+
15+
Info<< "Reading field U\n" << endl;
16+
volVectorField U
17+
(
18+
IOobject
19+
(
20+
"U",
21+
runTime.timeName(),
22+
mesh,
23+
IOobject::MUST_READ,
24+
IOobject::AUTO_WRITE
25+
),
26+
mesh
27+
);
28+
29+
#include "createPhi.H"
30+
31+
32+
label pRefCell = 0;
33+
scalar pRefValue = 0.0;
34+
setRefCell(p, simple.dict(), pRefCell, pRefValue);
35+
mesh.setFluxRequired(p.name());
36+
37+
38+
singlePhaseTransportModel laminarTransport(U, phi);
39+
40+
autoPtr<incompressible::turbulenceModel> turbulence
41+
(
42+
incompressible::turbulenceModel::New(U, phi, laminarTransport)
43+
);
44+
45+
#include "createMRF.H"
46+
#include "createFvOptions.H"
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
/*---------------------------------------------------------------------------*\
2+
========= |
3+
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4+
\\ / O peration |
5+
\\ / A nd | www.openfoam.com
6+
\\/ M anipulation |
7+
-------------------------------------------------------------------------------
8+
Copyright (C) 2011-2017 OpenFOAM Foundation
9+
-------------------------------------------------------------------------------
10+
License
11+
This file is part of OpenFOAM.
12+
13+
OpenFOAM is free software: you can redistribute it and/or modify it
14+
under the terms of the GNU General Public License as published by
15+
the Free Software Foundation, either version 3 of the License, or
16+
(at your option) any later version.
17+
18+
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21+
for more details.
22+
23+
You should have received a copy of the GNU General Public License
24+
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25+
26+
Application
27+
mySimpleFoam
28+
29+
Group
30+
grpIncompressibleSolvers
31+
32+
Description
33+
Steady-state solver for incompressible, turbulent flows.
34+
35+
\heading Solver details
36+
The solver uses the SIMPLE algorithm to solve the continuity equation:
37+
38+
\f[
39+
\div \vec{U} = 0
40+
\f]
41+
42+
and momentum equation:
43+
44+
\f[
45+
\div \left( \vec{U} \vec{U} \right) - \div \gvec{R}
46+
= - \grad p + \vec{S}_U
47+
\f]
48+
49+
Where:
50+
\vartable
51+
\vec{U} | Velocity
52+
p | Pressure
53+
\vec{R} | Stress tensor
54+
\vec{S}_U | Momentum source
55+
\endvartable
56+
57+
\heading Required fields
58+
\plaintable
59+
U | Velocity [m/s]
60+
p | Kinematic pressure, p/rho [m2/s2]
61+
\<turbulence fields\> | As required by user selection
62+
\endplaintable
63+
64+
\*---------------------------------------------------------------------------*/
65+
66+
#include "fvCFD.H"
67+
#include "singlePhaseTransportModel.H"
68+
#include "turbulentTransportModel.H"
69+
#include "simpleControl.H"
70+
#include "fvOptions.H"
71+
72+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
73+
74+
int main(int argc, char *argv[])
75+
{
76+
argList::addNote
77+
(
78+
"Steady-state solver for incompressible, turbulent flows."
79+
);
80+
81+
#include "postProcess.H"
82+
83+
#include "addCheckCaseOptions.H"
84+
#include "setRootCaseLists.H"
85+
#include "createTime.H"
86+
#include "createMesh.H"
87+
#include "createControl.H"
88+
#include "createFields.H"
89+
#include "initContinuityErrs.H"
90+
91+
turbulence->validate();
92+
93+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
94+
95+
Info<< "\nStarting time loop\n" << endl;
96+
97+
while (simple.loop())
98+
{
99+
Info<< "Time = " << runTime.timeName() << nl << endl;
100+
101+
// --- Pressure-velocity SIMPLE corrector
102+
{
103+
#include "UEqn.H"
104+
#include "pEqn.H"
105+
}
106+
107+
laminarTransport.correct();
108+
turbulence->correct();
109+
110+
runTime.write();
111+
112+
runTime.printExecutionTime(Info);
113+
}
114+
115+
Info<< "End\n" << endl;
116+
117+
return 0;
118+
}
119+
120+
121+
// ************************************************************************* //

solvers/mySimpleFoam/pEqn.H

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
volScalarField rAU(1.0/UEqn.A());
3+
volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p));
4+
surfaceScalarField phiHbyA("phiHbyA", fvc::flux(HbyA));
5+
MRF.makeRelative(phiHbyA);
6+
adjustPhi(phiHbyA, U, p);
7+
8+
tmp<volScalarField> rAtU(rAU);
9+
10+
if (simple.consistent())
11+
{
12+
rAtU = 1.0/(1.0/rAU - UEqn.H1());
13+
phiHbyA +=
14+
fvc::interpolate(rAtU() - rAU)*fvc::snGrad(p)*mesh.magSf();
15+
HbyA -= (rAU - rAtU())*fvc::grad(p);
16+
}
17+
18+
tUEqn.clear();
19+
20+
// Update the pressure BCs to ensure flux consistency
21+
constrainPressure(p, U, phiHbyA, rAtU(), MRF);
22+
23+
// Non-orthogonal pressure corrector loop
24+
while (simple.correctNonOrthogonal())
25+
{
26+
fvScalarMatrix pEqn
27+
(
28+
fvm::laplacian(rAtU(), p) == fvc::div(phiHbyA)
29+
);
30+
31+
pEqn.setReference(pRefCell, pRefValue);
32+
33+
pEqn.solve();
34+
35+
if (simple.finalNonOrthogonalIter())
36+
{
37+
phi = phiHbyA - pEqn.flux();
38+
}
39+
}
40+
41+
#include "continuityErrs.H"
42+
43+
// Explicitly relax pressure for momentum corrector
44+
p.relax();
45+
46+
// Momentum corrector
47+
U = HbyA - rAtU()*fvc::grad(p);
48+
U.correctBoundaryConditions();
49+
fvOptions.correct(U);
50+
}

src/newCrossPowerLaw/Make/files

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
newCrossPowerLaw.C
2+
3+
LIB = $(FOAM_USER_LIBBIN)/libnewCrossPowerLaw

src/newCrossPowerLaw/Make/options

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
EXE_INC = \
2+
-I$(LIB_SRC)/transportModels/incompressible/lnInclude \
3+
-I$(LIB_SRC)/finiteVolume/lnInclude
4+
LIB_LIBS = \
5+
-lincompressibleTransportModels \
6+
-lfiniteVolume

0 commit comments

Comments
 (0)