Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Houman Mirzaalian Dastjerdi
waLBerla
Commits
8ec34a6e
Commit
8ec34a6e
authored
Apr 11, 2018
by
Michael Kuron
Browse files
Add Velocity class and getValue function to ParserUBB for API compatibility with UBB
parent
ec6d666a
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lbm/boundary/ParserUBB.h
View file @
8ec34a6e
...
...
@@ -73,6 +73,29 @@ public:
bool
timeDependent_
;
};
// class Parser
// constant velocity class is for API compatibility with UBB
class
Velocity
:
public
BoundaryConfiguration
{
public:
Velocity
(
const
Vector3
<
real_t
>
&
_velocity
)
:
velocity_
(
_velocity
)
{}
Velocity
(
const
real_t
_x
,
const
real_t
_y
,
const
real_t
_z
)
:
velocity_
(
_x
,
_y
,
_z
)
{}
inline
Velocity
(
const
Config
::
BlockHandle
&
config
);
const
Vector3
<
real_t
>
&
velocity
()
const
{
return
velocity_
;
}
const
real_t
&
x
()
const
{
return
velocity_
[
0
];
}
const
real_t
&
y
()
const
{
return
velocity_
[
1
];
}
const
real_t
&
z
()
const
{
return
velocity_
[
2
];
}
Vector3
<
real_t
>
&
velocity
()
{
return
velocity_
;
}
real_t
&
x
()
{
return
velocity_
[
0
];
}
real_t
&
y
()
{
return
velocity_
[
1
];
}
real_t
&
z
()
{
return
velocity_
[
2
];
}
private:
Vector3
<
real_t
>
velocity_
;
};
// class Velocity
typedef
GhostLayerField
<
shared_ptr
<
Parser
>
,
1
>
ParserField
;
typedef
GhostLayerField
<
Vector3
<
real_t
>
,
1
>
VelocityField
;
...
...
@@ -119,6 +142,9 @@ public:
const
cell_idx_t
nx
,
const
cell_idx_t
ny
,
const
cell_idx_t
nz
,
const
flag_t
/*mask*/
);
#endif
inline
Vector3
<
real_t
>
getValue
(
const
cell_idx_t
x
,
cell_idx_t
y
,
cell_idx_t
z
)
const
;
inline
Vector3
<
real_t
>
getValue
(
const
cell_idx_t
x
,
cell_idx_t
y
,
cell_idx_t
z
,
real_t
t
)
const
;
private:
const
FlagUID
uid_
;
...
...
@@ -192,6 +218,14 @@ inline ParserUBB<LatticeModel_T, flag_t, AdaptVelocityToExternalForce>::Parser::
}
}
template
<
typename
LatticeModel_T
,
typename
flag_t
,
bool
AdaptVelocityToExternalForce
>
inline
ParserUBB
<
LatticeModel_T
,
flag_t
,
AdaptVelocityToExternalForce
>::
Velocity
::
Velocity
(
const
Config
::
BlockHandle
&
config
)
{
velocity_
[
0
]
=
(
config
&&
config
.
isDefined
(
"x"
)
)
?
config
.
getParameter
<
real_t
>
(
"x"
)
:
real_c
(
0.0
);
velocity_
[
1
]
=
(
config
&&
config
.
isDefined
(
"y"
)
)
?
config
.
getParameter
<
real_t
>
(
"y"
)
:
real_c
(
0.0
);
velocity_
[
2
]
=
(
config
&&
config
.
isDefined
(
"z"
)
)
?
config
.
getParameter
<
real_t
>
(
"z"
)
:
real_c
(
0.0
);
}
template
<
typename
LatticeModel_T
,
typename
flag_t
,
bool
AdaptVelocityToExternalForce
>
Vector3
<
real_t
>
ParserUBB
<
LatticeModel_T
,
flag_t
,
AdaptVelocityToExternalForce
>::
Parser
::
operator
()(
const
Vector3
<
real_t
>
&
x
,
const
real_t
t
)
const
{
...
...
@@ -310,6 +344,13 @@ inline void ParserUBB< LatticeModel_T, flag_t, AdaptVelocityToExternalForce >::r
WALBERLA_ASSERT_EQUAL
(
dynamic_cast
<
const
Parser
*
>
(
&
parser
),
&
parser
);
WALBERLA_ASSERT_NOT_NULLPTR
(
parserField_
);
if
(
auto
v
=
dynamic_cast
<
const
Velocity
*
>
(
&
parser
)
)
{
velocityField_
->
get
(
x
,
y
,
z
)
=
v
->
velocity
();
parserField_
->
get
(
x
,
y
,
z
)
=
nullptr
;
return
;
}
auto
&
p
=
dynamic_cast
<
const
Parser
&
>
(
parser
);
if
(
p
.
isTimeDependent
()
)
...
...
@@ -334,6 +375,16 @@ inline void ParserUBB< LatticeModel_T, flag_t, AdaptVelocityToExternalForce >::r
WALBERLA_ASSERT_EQUAL
(
dynamic_cast
<
const
Parser
*
>
(
&
parser
),
&
parser
);
WALBERLA_ASSERT_NOT_NULLPTR
(
parserField_
);
if
(
auto
v
=
dynamic_cast
<
const
Velocity
*
>
(
&
parser
)
)
{
for
(
auto
cell
=
parserField_
->
beginSliceXYZ
(
cells
);
cell
!=
parserField_
->
end
();
++
cell
)
{
velocityField_
->
get
(
cell
.
x
(),
cell
.
y
(),
cell
.
z
()
)
=
v
->
velocity
();
*
cell
=
nullptr
;
}
return
;
}
auto
&
p
=
dynamic_cast
<
const
Parser
&
>
(
parser
);
if
(
p
.
isTimeDependent
()
)
...
...
@@ -365,6 +416,16 @@ inline void ParserUBB< LatticeModel_T, flag_t, AdaptVelocityToExternalForce >::r
WALBERLA_ASSERT_EQUAL
(
dynamic_cast
<
const
Parser
*
>
(
&
parser
),
&
parser
);
WALBERLA_ASSERT_NOT_NULLPTR
(
parserField_
);
if
(
auto
v
=
dynamic_cast
<
const
Velocity
*
>
(
&
parser
)
)
{
for
(
auto
cell
=
begin
;
cell
!=
end
;
++
cell
)
{
velocityField_
->
get
(
cell
.
x
(),
cell
.
y
(),
cell
.
z
()
)
=
v
->
velocity
();
parserField_
->
get
(
cell
->
x
(),
cell
->
y
(),
cell
->
z
()
)
=
nullptr
;
}
return
;
}
auto
&
p
=
dynamic_cast
<
const
Parser
&
>
(
parser
);
if
(
p
.
isTimeDependent
()
)
...
...
@@ -400,11 +461,11 @@ inline void ParserUBB< LatticeModel_T, flag_t, AdaptVelocityToExternalForce >::u
template
<
typename
LatticeModel_T
,
typename
flag_t
,
bool
AdaptVelocityToExternalForce
>
#ifndef NDEBUG
inline
void
ParserUBB
<
LatticeModel_T
,
flag_t
,
AdaptVelocityToExternalForce
>::
ParserUBB
::
treatDirection
(
const
cell_idx_t
x
,
const
cell_idx_t
y
,
const
cell_idx_t
z
,
const
stencil
::
Direction
dir
,
const
cell_idx_t
nx
,
const
cell_idx_t
ny
,
const
cell_idx_t
nz
,
const
flag_t
mask
)
inline
void
ParserUBB
<
LatticeModel_T
,
flag_t
,
AdaptVelocityToExternalForce
>::
ParserUBB
::
treatDirection
(
const
cell_idx_t
x
,
const
cell_idx_t
y
,
const
cell_idx_t
z
,
const
stencil
::
Direction
dir
,
const
cell_idx_t
nx
,
const
cell_idx_t
ny
,
const
cell_idx_t
nz
,
const
flag_t
mask
)
#else
inline
void
ParserUBB
<
LatticeModel_T
,
flag_t
,
AdaptVelocityToExternalForce
>::
ParserUBB
::
treatDirection
(
const
cell_idx_t
x
,
const
cell_idx_t
y
,
const
cell_idx_t
z
,
const
stencil
::
Direction
dir
,
const
cell_idx_t
nx
,
const
cell_idx_t
ny
,
const
cell_idx_t
nz
,
const
flag_t
/*mask*/
)
inline
void
ParserUBB
<
LatticeModel_T
,
flag_t
,
AdaptVelocityToExternalForce
>::
ParserUBB
::
treatDirection
(
const
cell_idx_t
x
,
const
cell_idx_t
y
,
const
cell_idx_t
z
,
const
stencil
::
Direction
dir
,
const
cell_idx_t
nx
,
const
cell_idx_t
ny
,
const
cell_idx_t
nz
,
const
flag_t
/*mask*/
)
#endif
{
WALBERLA_ASSERT_EQUAL
(
nx
,
x
+
cell_idx_c
(
stencil
::
cx
[
dir
]
)
);
...
...
@@ -414,14 +475,13 @@ template< typename LatticeModel_T, typename flag_t, bool AdaptVelocityToExternal
WALBERLA_ASSERT_EQUAL
(
mask
&
this
->
mask_
,
this
->
mask_
);
// only true if "this->mask_" only contains one single flag, which is the case for the
// current implementation of this boundary condition (ParserUBB)
const
Vector3
<
real_t
>
pos
(
origin_
[
0
]
+
real_c
(
nx
)
*
dx_
[
0
],
origin_
[
1
]
+
real_c
(
ny
)
*
dx_
[
1
],
origin_
[
2
]
+
real_c
(
nz
)
*
dx_
[
2
]
);
Vector3
<
real_t
>
velocity
;
if
(
parserField_
->
get
(
nx
,
ny
,
nz
)
)
{
WALBERLA_ASSERT_NOT_NULLPTR
(
getTimeTracker
(),
"A TimeTracker is needed for time-dependent equations"
);
const
Vector3
<
real_t
>
pos
(
origin_
[
0
]
+
real_c
(
nx
)
*
dx_
[
0
],
origin_
[
1
]
+
real_c
(
ny
)
*
dx_
[
1
],
origin_
[
2
]
+
real_c
(
nz
)
*
dx_
[
2
]
);
velocity
=
(
*
parserField_
->
get
(
nx
,
ny
,
nz
))(
pos
,
time_
);
}
else
...
...
@@ -455,5 +515,32 @@ template< typename LatticeModel_T, typename flag_t, bool AdaptVelocityToExternal
}
template
<
typename
LatticeModel_T
,
typename
flag_t
,
bool
AdaptVelocityToExternalForce
>
inline
Vector3
<
real_t
>
ParserUBB
<
LatticeModel_T
,
flag_t
,
AdaptVelocityToExternalForce
>::
getValue
(
const
cell_idx_t
x
,
cell_idx_t
y
,
cell_idx_t
z
)
const
{
return
getValue
(
x
,
y
,
z
,
time_
);
}
template
<
typename
LatticeModel_T
,
typename
flag_t
,
bool
AdaptVelocityToExternalForce
>
inline
Vector3
<
real_t
>
ParserUBB
<
LatticeModel_T
,
flag_t
,
AdaptVelocityToExternalForce
>::
getValue
(
const
cell_idx_t
x
,
cell_idx_t
y
,
cell_idx_t
z
,
real_t
t
)
const
{
Vector3
<
real_t
>
velocity
;
if
(
parserField_
->
get
(
x
,
y
,
z
)
)
{
WALBERLA_ASSERT_NOT_NULLPTR
(
getTimeTracker
(),
"A TimeTracker is needed for time-dependent equations"
);
const
Vector3
<
real_t
>
pos
(
origin_
[
0
]
+
real_c
(
x
)
*
dx_
[
0
],
origin_
[
1
]
+
real_c
(
y
)
*
dx_
[
1
],
origin_
[
2
]
+
real_c
(
z
)
*
dx_
[
2
]
);
velocity
=
(
*
parserField_
->
get
(
x
,
y
,
z
))(
pos
,
t
);
}
else
{
velocity
=
velocityField_
->
get
(
x
,
y
,
z
);
}
return
velocity
;
}
}
// namespace lbm
}
// namespace walberla
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment