Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
46dfc66c
Commit
46dfc66c
authored
Jun 14, 2018
by
Andrew Heather
Browse files
INT: Refactored waves mangrove interaction fvOptions
parent
337aca5f
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/waveModels/fvOptions/multiphaseMangrovesSource/multiphaseMangrovesSource.C
View file @
46dfc66c
...
...
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017
-2018
OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017 IH-Cantabria
-------------------------------------------------------------------------------
License
...
...
@@ -48,103 +48,158 @@ namespace fv
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam
::
fv
::
multiphaseMangrovesSource
::
multiphaseMangrovesSource
(
const
word
&
name
,
const
word
&
modelType
,
const
dictionary
&
dict
,
const
fvMesh
&
mesh
)
:
option
(
name
,
modelType
,
dict
,
mesh
),
aZone_
(),
NZone_
(),
CmZone_
(),
CdZone_
()
{
read
(
dict
);
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void
Foam
::
fv
::
multiphaseMangrovesSource
::
addSup
(
const
volScalarField
&
rho
,
fvMatrix
<
vector
>&
eqn
,
const
label
fieldi
)
Foam
::
tmp
<
Foam
::
volScalarField
>
Foam
::
fv
::
multiphaseMangrovesSource
::
dragCoeff
(
const
volVectorField
&
U
)
const
{
const
volVectorField
&
U
=
eqn
.
psi
();
volScalarField
DragForceMangroves
tmp
<
volScalarField
>
tdragCoeff
=
tmp
<
volScalarField
>::
New
(
IOobject
(
typeName
+
":
D
rag
ForceMangroves
"
,
typeName
+
":
d
rag
Coeff
"
,
mesh_
.
time
().
timeName
(),
mesh_
.
time
(),
IOobject
::
NO_READ
,
IOobject
::
NO_WRITE
),
mesh_
,
dimensionedScalar
(
"
DragForceMangroves"
,
dimDensity
/
dimTime
,
0
)
dimensionedScalar
(
"
0"
,
dimless
/
dimTime
,
0
)
);
volScalarField
InertiaForceMangroves
volScalarField
&
dragCoeff
=
tdragCoeff
.
ref
();
forAll
(
zoneIDs_
,
i
)
{
const
scalar
a
=
aZone_
[
i
];
const
scalar
N
=
NZone_
[
i
];
const
scalar
Cd
=
CdZone_
[
i
];
const
labelList
&
zones
=
zoneIDs_
[
i
];
for
(
label
zonei
:
zones
)
{
const
cellZone
&
cz
=
mesh_
.
cellZones
()[
zonei
];
for
(
label
celli
:
cz
)
{
const
vector
&
Uc
=
U
[
celli
];
dragCoeff
[
celli
]
=
0
.
5
*
Cd
*
a
*
N
*
mag
(
Uc
);
}
}
}
dragCoeff
.
correctBoundaryConditions
();
return
tdragCoeff
;
}
Foam
::
tmp
<
Foam
::
volScalarField
>
Foam
::
fv
::
multiphaseMangrovesSource
::
inertiaCoeff
()
const
{
tmp
<
volScalarField
>
tinertiaCoeff
=
tmp
<
volScalarField
>::
New
(
IOobject
(
typeName
+
":
I
nertia
ForceMangroves
"
,
typeName
+
":
i
nertia
Coeff
"
,
mesh_
.
time
().
timeName
(),
mesh_
.
time
(),
IOobject
::
NO_READ
,
IOobject
::
NO_WRITE
),
mesh_
,
dimensionedScalar
(
"
InertiaForceMangroves
"
,
dimless
,
0
)
dimensionedScalar
(
"
0
"
,
dimless
,
0
)
);
volScalarField
&
inertiaCoeff
=
tinertiaCoeff
.
ref
();
const
scalar
pi
=
constant
::
mathematical
::
pi
;
forAll
(
zoneIDs_
,
i
)
{
const
scalar
a
=
aZone_
[
i
];
const
scalar
N
=
NZone_
[
i
];
const
scalar
Cm
=
CmZone_
[
i
];
const
labelList
&
zones
=
zoneIDs_
[
i
];
for
All
(
zones
,
j
)
for
(
label
zonei
:
zones
)
{
const
label
zonei
=
zones
[
j
];
const
cellZone
&
cz
=
mesh_
.
cellZones
()[
zonei
];
for
All
(
cz
,
k
)
for
(
label
celli
:
cz
)
{
const
label
celli
=
cz
[
k
];
const
scalar
a
=
aZone_
[
i
];
const
scalar
N
=
NZone_
[
i
];
const
scalar
Cm
=
CmZone_
[
i
];
const
scalar
Cd
=
CdZone_
[
i
];
const
vector
&
Uc
=
U
[
celli
];
DragForceMangroves
[
celli
]
=
0
.
5
*
Cd
*
a
*
N
*
mag
(
Uc
);
InertiaForceMangroves
[
celli
]
=
0
.
25
*
(
Cm
+
1
)
*
pi
*
a
*
a
;
inertiaCoeff
[
celli
]
=
0
.
25
*
(
Cm
+
1
)
*
pi
*
a
*
a
*
N
;
}
}
}
DragForceMangroves
.
correctBoundaryConditions
();
InertiaForceMangroves
.
correctBoundaryConditions
();
inertiaCoeff
.
correctBoundaryConditions
();
return
tinertiaCoeff
;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam
::
fv
::
multiphaseMangrovesSource
::
multiphaseMangrovesSource
(
const
word
&
name
,
const
word
&
modelType
,
const
dictionary
&
dict
,
const
fvMesh
&
mesh
)
:
option
(
name
,
modelType
,
dict
,
mesh
),
aZone_
(),
NZone_
(),
CmZone_
(),
CdZone_
()
{
read
(
dict
);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void
Foam
::
fv
::
multiphaseMangrovesSource
::
addSup
(
fvMatrix
<
vector
>&
eqn
,
const
label
fieldi
)
{
const
volVectorField
&
U
=
eqn
.
psi
();
fvMatrix
<
vector
>
mangrovesEqn
(
-
fvm
::
Sp
(
dragCoeff
(
U
),
U
)
-
inertiaCoeff
()
*
fvm
::
ddt
(
U
)
);
// Contributions are added to RHS of momentum equation
eqn
+=
mangrovesEqn
;
}
void
Foam
::
fv
::
multiphaseMangrovesSource
::
addSup
(
const
volScalarField
&
rho
,
fvMatrix
<
vector
>&
eqn
,
const
label
fieldi
)
{
const
volVectorField
&
U
=
eqn
.
psi
();
fvMatrix
<
vector
>
M
angrovesEqn
fvMatrix
<
vector
>
m
angrovesEqn
(
-
fvm
::
Sp
(
rho
*
D
rag
ForceMangroves
,
U
)
-
rho
*
I
nertia
ForceMangroves
*
fvm
::
ddt
(
rho
,
U
)
-
fvm
::
Sp
(
rho
*
d
rag
Coeff
(
U
)
,
U
)
-
rho
*
i
nertia
Coeff
()
*
fvm
::
ddt
(
U
)
);
// Contributions are added to RHS of momentum equation
eqn
+=
M
angrovesEqn
;
eqn
+=
m
angrovesEqn
;
}
...
...
src/waveModels/fvOptions/multiphaseMangrovesSource/multiphaseMangrovesSource.H
View file @
46dfc66c
...
...
@@ -61,6 +61,15 @@ class multiphaseMangrovesSource
:
public
option
{
// Private Member Functions
//- Disallow default bitwise copy construct
multiphaseMangrovesSource
(
const
multiphaseMangrovesSource
&
);
//- Disallow default bitwise assignment
void
operator
=
(
const
multiphaseMangrovesSource
&
);
protected:
...
...
@@ -86,17 +95,14 @@ protected:
//- Zone indices
labelListList
zoneIDs_
;
// Field properties
private:
// Protected Member Functions
// Private Member Functions
//- Return the drag force coefficient
tmp
<
volScalarField
>
dragCoeff
(
const
volVectorField
&
U
)
const
;
//- Disallow default bitwise copy construct
multiphaseMangrovesSource
(
const
multiphaseMangrovesSource
&
);
//- Disallow default bitwise assignment
void
operator
=
(
const
multiphaseMangrovesSource
&
);
//- Return the inertia force coefficient
tmp
<
volScalarField
>
inertiaCoeff
()
const
;
public:
...
...
@@ -126,6 +132,13 @@ public:
// Add explicit and implicit contributions
//- Add implicit contribution to momentum equation
virtual
void
addSup
(
fvMatrix
<
vector
>&
eqn
,
const
label
fieldi
);
//- Add implicit contribution to phase momentum equation
virtual
void
addSup
(
...
...
src/waveModels/fvOptions/multiphaseMangrovesTurbulenceModel/multiphaseMangrovesTurbulenceModel.C
View file @
46dfc66c
...
...
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017
-2018
OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017 IH-Cantabria
-------------------------------------------------------------------------------
License
...
...
@@ -27,13 +27,7 @@ License
#include
"mathematicalConstants.H"
#include
"fvMesh.H"
#include
"fvMatrices.H"
#include
"fvmDdt.H"
#include
"fvcGrad.H"
#include
"fvmDiv.H"
#include
"fvmLaplacian.H"
#include
"fvmSup.H"
#include
"surfaceInterpolate.H"
#include
"surfaceFields.H"
#include
"addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
...
...
@@ -53,6 +47,100 @@ namespace fv
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam
::
tmp
<
Foam
::
volScalarField
>
Foam
::
fv
::
multiphaseMangrovesTurbulenceModel
::
kCoeff
(
const
volVectorField
&
U
)
const
{
tmp
<
volScalarField
>
tkCoeff
=
tmp
<
volScalarField
>::
New
(
IOobject
(
typeName
+
":kCoeff"
,
mesh_
.
time
().
timeName
(),
mesh_
.
time
(),
IOobject
::
NO_READ
,
IOobject
::
NO_WRITE
),
mesh_
,
dimensionedScalar
(
"0"
,
dimless
/
dimTime
,
0
)
);
volScalarField
&
kCoeff
=
tkCoeff
.
ref
();
forAll
(
zoneIDs_
,
i
)
{
const
scalar
a
=
aZone_
[
i
];
const
scalar
N
=
NZone_
[
i
];
const
scalar
Ckp
=
CkpZone_
[
i
];
const
scalar
Cd
=
CdZone_
[
i
];
for
(
label
zonei
:
zoneIDs_
[
i
])
{
const
cellZone
&
cz
=
mesh_
.
cellZones
()[
zonei
];
for
(
label
celli
:
cz
)
{
kCoeff
[
celli
]
=
Ckp
*
Cd
*
a
*
N
*
mag
(
U
[
celli
]);
}
}
}
kCoeff
.
correctBoundaryConditions
();
return
tkCoeff
;
}
Foam
::
tmp
<
Foam
::
volScalarField
>
Foam
::
fv
::
multiphaseMangrovesTurbulenceModel
::
epsilonCoeff
(
const
volVectorField
&
U
)
const
{
tmp
<
volScalarField
>
tepsilonCoeff
=
tmp
<
volScalarField
>::
New
(
IOobject
(
typeName
+
":epsilonCoeff"
,
mesh_
.
time
().
timeName
(),
mesh_
.
time
(),
IOobject
::
NO_READ
,
IOobject
::
NO_WRITE
),
mesh_
,
dimensionedScalar
(
"0"
,
dimless
/
dimTime
,
0
)
);
volScalarField
&
epsilonCoeff
=
tepsilonCoeff
.
ref
();
forAll
(
zoneIDs_
,
i
)
{
const
scalar
a
=
aZone_
[
i
];
const
scalar
N
=
NZone_
[
i
];
const
scalar
Cep
=
CepZone_
[
i
];
const
scalar
Cd
=
CdZone_
[
i
];
for
(
label
zonei
:
zoneIDs_
[
i
])
{
const
cellZone
&
cz
=
mesh_
.
cellZones
()[
zonei
];
for
(
label
celli
:
cz
)
{
epsilonCoeff
[
celli
]
=
Cep
*
Cd
*
a
*
N
*
mag
(
U
[
celli
]);
}
}
}
epsilonCoeff
.
correctBoundaryConditions
();
return
tepsilonCoeff
;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam
::
fv
::
multiphaseMangrovesTurbulenceModel
::
multiphaseMangrovesTurbulenceModel
...
...
@@ -87,82 +175,48 @@ void Foam::fv::multiphaseMangrovesTurbulenceModel::addSup
{
const
volVectorField
&
U
=
mesh_
.
lookupObject
<
volVectorField
>
(
UName_
);
// Set alpha as zero-gradient
const
volScalarField
&
epsilon
=
mesh_
.
lookupObject
<
volScalarField
>
(
epsilonName_
);
const
volScalarField
&
k
=
mesh_
.
lookupObject
<
volScalarField
>
(
kName_
);
volScalarField
epsilonMangroves
(
IOobject
(
typeName
+
":epsilonMangroves"
,
mesh_
.
time
().
timeName
(),
mesh_
.
time
(),
IOobject
::
NO_READ
,
IOobject
::
NO_WRITE
),
mesh_
,
dimensionedScalar
(
"epsilonMangroves"
,
dimMass
/
dimMass
/
dimTime
,
0
)
);
volScalarField
kMangroves
(
IOobject
(
typeName
+
":kMangroves"
,
mesh_
.
time
().
timeName
(),
mesh_
.
time
(),
IOobject
::
NO_READ
,
IOobject
::
NO_WRITE
),
mesh_
,
dimensionedScalar
(
"kMangroves"
,
dimTime
/
dimTime
/
dimTime
,
0
)
);
forAll
(
zoneIDs_
,
i
)
if
(
eqn
.
psi
().
name
()
==
epsilonName_
)
{
const
labelList
&
zones
=
zoneIDs_
[
i
];
fvMatrix
<
scalar
>
epsilonEqn
(
-
fvm
::
Sp
(
epsilonCoeff
(
U
),
eqn
.
psi
())
);
eqn
+=
epsilonEqn
;
}
else
if
(
eqn
.
psi
().
name
()
==
kName_
)
{
fvMatrix
<
scalar
>
kEqn
(
-
fvm
::
Sp
(
kCoeff
(
U
),
eqn
.
psi
())
);
eqn
+=
kEqn
;
}
}
forAll
(
zones
,
j
)
{
const
label
zonei
=
zones
[
j
];
const
cellZone
&
cz
=
mesh_
.
cellZones
()[
zonei
];
forAll
(
cz
,
kk
)
{
const
label
celli
=
cz
[
kk
];
const
scalar
a
=
aZone_
[
i
];
const
scalar
N
=
NZone_
[
i
];
const
scalar
Ckp
=
CkpZone_
[
i
];
const
scalar
Cep
=
CepZone_
[
i
];
const
scalar
Cd
=
CdZone_
[
i
];
const
vector
&
Uc
=
U
[
celli
];
const
scalar
f
=
Cd
*
a
*
N
*
mag
(
Uc
);
epsilonMangroves
[
celli
]
=
Cep
*
f
;
kMangroves
[
celli
]
=
Ckp
*
f
;
}
}
}
void
Foam
::
fv
::
multiphaseMangrovesTurbulenceModel
::
addSup
(
const
volScalarField
&
rho
,
fvMatrix
<
scalar
>&
eqn
,
const
label
fieldi
)
{
const
volVectorField
&
U
=
mesh_
.
lookupObject
<
volVectorField
>
(
UName_
);
if
(
eqn
.
psi
().
name
()
==
epsilonName_
)
{
epsilonMangroves
.
correctBoundaryConditions
();
fvMatrix
<
scalar
>
epsilonEqn
(
-
fvm
::
Sp
(
epsilon
Mangroves
,
epsilon
)
);
eqn
+=
epsilonEqn
;
-
fvm
::
Sp
(
rho
*
epsilon
Coeff
(
U
),
eqn
.
psi
()
)
);
eqn
+=
epsilonEqn
;
}
else
if
(
eqn
.
psi
().
name
()
==
kName_
)
{
kMangroves
.
correctBoundaryConditions
();
fvMatrix
<
scalar
>
kEqn
(
-
fvm
::
Sp
(
kMangroves
,
k
)
);
-
fvm
::
Sp
(
rho
*
kCoeff
(
U
),
eqn
.
psi
()
)
);
eqn
+=
kEqn
;
}
}
...
...
@@ -230,106 +284,5 @@ bool Foam::fv::multiphaseMangrovesTurbulenceModel::read(const dictionary& dict)
}
}
void
Foam
::
fv
::
multiphaseMangrovesTurbulenceModel
::
addSup
(
const
volScalarField
&
rho
,
fvMatrix
<
scalar
>&
eqn
,
const
label
fieldi
)
{
const
volVectorField
&
U
=
mesh_
.
lookupObject
<
volVectorField
>
(
UName_
);
// Set alpha as zero-gradient
const
volScalarField
&
epsilon
=
mesh_
.
lookupObject
<
volScalarField
>
(
epsilonName_
);
const
volScalarField
&
k
=
mesh_
.
lookupObject
<
volScalarField
>
(
kName_
);
volScalarField
epsilonMangroves
(
IOobject
(
typeName
+
":epsilonMangroves"
,
mesh_
.
time
().
timeName
(),
mesh_
.
time
(),
IOobject
::
NO_READ
,
IOobject
::
NO_WRITE
),
mesh_
,
dimensionedScalar
(
"epsilonMangroves"
,
dimMass
/
dimMass
/
dimTime
,
0
)
);
volScalarField
kMangroves
(
IOobject
(
typeName
+
":kMangroves"
,
mesh_
.
time
().
timeName
(),
mesh_
.
time
(),
IOobject
::
NO_READ
,
IOobject
::
NO_WRITE
),
mesh_
,
dimensionedScalar
(
"kMangroves"
,
dimTime
/
dimTime
/
dimTime
,
0
)
);
forAll
(
zoneIDs_
,
i
)
{
const
labelList
&
zones
=
zoneIDs_
[
i
];
forAll
(
zones
,
j
)
{
const
label
zonei
=
zones
[
j
];
const
cellZone
&
cz
=
mesh_
.
cellZones
()[
zonei
];
forAll
(
cz
,
kk
)
{
const
label
celli
=
cz
[
kk
];
const
scalar
a
=
aZone_
[
i
];
const
scalar
N
=
NZone_
[
i
];
const
scalar
Ckp
=
CkpZone_
[
i
];
const
scalar
Cep
=
CepZone_
[
i
];
const
scalar
Cd
=
CdZone_
[
i
];
const
vector
&
Uc
=
U
[
celli
];
epsilonMangroves
[
celli
]
=
Cep
*
Cd
*
a
*
N
*
sqrt
(
Uc
.
x
()
*
Uc
.
x
()
+
Uc
.
y
()
*
Uc
.
y
()
+
Uc
.
z
()
*
Uc
.
z
());
kMangroves
[
celli
]
=
Ckp
*
Cd
*
a
*
N
*
sqrt
(
Uc
.
x
()
*
Uc
.
x
()
+
Uc
.
y
()
*
Uc
.
y
()
+
Uc
.
z
()
*
Uc
.
z
());
}
}
}