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
pycodegen
lbmpy_walberla
Commits
2c3ca968
Commit
2c3ca968
authored
May 15, 2019
by
Martin Bauer
Browse files
Fix: compressible models are now generated correctly
parent
913d2040
Pipeline
#16231
passed with stage
in 1 minute and 52 seconds
Changes
3
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
lbmpy_walberla/templates/LatticeModel.tmpl.h
View file @
2c3ca968
...
...
@@ -100,7 +100,7 @@ public:
static
const
real_t
w
[{{
Q
}}];
static
const
real_t
wInv
[{{
Q
}}];
static
const
bool
compressible
=
{
{
compressible
}
};
static
const
bool
compressible
=
{
%
if
compressible
%
}
true
{
%
else
%
}
false
{
%
endif
%
};
static
const
int
equilibriumAccuracyOrder
=
{{
equilibrium_order
}};
class
Sweep
...
...
@@ -211,7 +211,7 @@ public:
const
Vector3
<
real_t
>
&
u
=
Vector3
<
real_t
>
(
real_t
(
0.0
)
),
real_t
rho
=
real_t
(
1.0
)
)
{
{
%
if
compressible
==
'
false
'
%
}
{
%
if
not
compressible
%
}
rho
-=
real_t
(
1.0
);
{
%
endif
%
}
{{
equilibrium_from_direction
}}
...
...
@@ -221,7 +221,7 @@ public:
const
Vector3
<
real_t
>
&
u
=
Vector3
<
real_t
>
(
real_t
(
0.0
)),
real_t
rho
=
real_t
(
1.0
)
)
{
{
%
if
compressible
==
'
false
'
%
}
{
%
if
not
compressible
%
}
rho
-=
real_t
(
1.0
);
{
%
endif
%
}
{{
symmetric_equilibrium_from_direction
}}
...
...
@@ -231,7 +231,7 @@ public:
const
Vector3
<
real_t
>
&
u
=
Vector3
<
real_t
>
(
real_t
(
0.0
)
),
real_t
rho
=
real_t
(
1.0
)
)
{
{
%
if
compressible
==
'
false
'
%
}
{
%
if
not
compressible
%
}
rho
-=
real_t
(
1.0
);
{
%
endif
%
}
{{
asymmetric_equilibrium_from_direction
}}
...
...
@@ -240,7 +240,7 @@ public:
static
std
::
vector
<
real_t
>
get
(
const
Vector3
<
real_t
>
&
u
=
Vector3
<
real_t
>
(
real_t
(
0.0
)
),
real_t
rho
=
real_t
(
1.0
)
)
{
{
%
if
compressible
==
'
false
'
%
}
{
%
if
not
compressible
%
}
rho
-=
real_t
(
1.0
);
{
%
endif
%
}
...
...
@@ -296,7 +296,7 @@ struct Equilibrium< {{class_name}}, void >
static
void
set
(
FieldPtrOrIterator
&
it
,
const
Vector3
<
real_t
>
&
u
=
Vector3
<
real_t
>
(
real_t
(
0.0
)
),
real_t
rho
=
real_t
(
1.0
)
)
{
{
%
if
compressible
==
'
false
'
%
}
{
%
if
not
compressible
%
}
rho
-=
real_t
(
1.0
);
{
%
endif
%
}
...
...
@@ -309,7 +309,7 @@ struct Equilibrium< {{class_name}}, void >
static
void
set
(
PdfField_T
&
pdf
,
const
cell_idx_t
x
,
const
cell_idx_t
y
,
const
cell_idx_t
z
,
const
Vector3
<
real_t
>
&
u
=
Vector3
<
real_t
>
(
real_t
(
0.0
)
),
real_t
rho
=
real_t
(
1.0
)
)
{
{
%
if
compressible
==
'
false
'
%
}
{
%
if
not
compressible
%
}
rho
-=
real_t
(
1.0
);
{
%
endif
%
}
...
...
@@ -364,7 +364,7 @@ struct DensityAndVelocity<{{class_name}}>
const
real_t
u_2
(
0.0
);
{
%
endif
%
}
Equilibrium
<
{{
class_name
}}
>::
set
(
it
,
Vector3
<
real_t
>
(
u_0
,
u_1
,
u_2
),
rho
{
%
if
compressible
%
}
+
real_t
(
1
)
{
%
endif
%
});
Equilibrium
<
{{
class_name
}}
>::
set
(
it
,
Vector3
<
real_t
>
(
u_0
,
u_1
,
u_2
),
rho
{
%
if
not
compressible
%
}
+
real_t
(
1
)
{
%
endif
%
});
}
template
<
typename
PdfField_T
>
...
...
@@ -376,7 +376,7 @@ struct DensityAndVelocity<{{class_name}}>
const
real_t
u_2
(
0.0
);
{
%
endif
%
}
Equilibrium
<
{{
class_name
}}
>::
set
(
pdf
,
x
,
y
,
z
,
Vector3
<
real_t
>
(
u_0
,
u_1
,
u_2
),
rho
{
%
if
compressible
%
}
+
real_t
(
1
)
{
%
endif
%
});
Equilibrium
<
{{
class_name
}}
>::
set
(
pdf
,
x
,
y
,
z
,
Vector3
<
real_t
>
(
u_0
,
u_1
,
u_2
),
rho
{
%
if
not
compressible
%
}
+
real_t
(
1
)
{
%
endif
%
});
}
};
...
...
@@ -398,7 +398,7 @@ struct DensityAndVelocityRange<{{class_name}}, FieldIteratorXYZ>
const
real_t
u_2
(
0.0
);
{
%
endif
%
}
Equilibrium
<
{{
class_name
}}
>::
set
(
cellIt
,
Vector3
<
real_t
>
(
u_0
,
u_1
,
u_2
),
rho
{
%
if
compressible
%
}
+
real_t
(
1
)
{
%
endif
%
});
Equilibrium
<
{{
class_name
}}
>::
set
(
cellIt
,
Vector3
<
real_t
>
(
u_0
,
u_1
,
u_2
),
rho
{
%
if
not
compressible
%
}
+
real_t
(
1
)
{
%
endif
%
});
}
}
};
...
...
lbmpy_walberla/walberla_lbm_generation.py
View file @
2c3ca968
...
...
@@ -100,7 +100,7 @@ def generate_lattice_model(generation_context, class_name, lb_method, refinement
'stencil_name'
:
stencil_name
,
'D'
:
lb_method
.
dim
,
'Q'
:
len
(
lb_method
.
stencil
),
'compressible'
:
'true'
if
params
[
'compressible'
]
else
'false'
,
'compressible'
:
lb_method
.
conserved_quantity_computation
.
compressible
,
'weights'
:
","
.
join
(
str
(
w
.
evalf
())
+
constant_suffix
for
w
in
lb_method
.
weights
),
'inverse_weights'
:
","
.
join
(
str
((
1
/
w
).
evalf
())
+
constant_suffix
for
w
in
lb_method
.
weights
),
...
...
lbmpy_walberla_tests/test_walberla_codegen.py
View file @
2c3ca968
...
...
@@ -17,16 +17,18 @@ class WalberlaLbmpyCodegenTest(unittest.TestCase):
force_field
=
ps
.
fields
(
"force(3): [3D]"
,
layout
=
'fzyx'
)
omega
=
sp
.
Symbol
(
"omega"
)
lb_method
=
create_lb_method
(
stencil
=
'D3Q19'
,
method
=
'srt'
,
relaxation_rates
=
[
omega
],
lb_method
=
create_lb_method
(
stencil
=
'D3Q19'
,
method
=
'srt'
,
relaxation_rates
=
[
omega
],
compressible
=
True
,
force_model
=
'guo'
,
force
=
force_field
.
center_vector
)
scaling
=
RefinementScaling
()
scaling
.
add_standard_relaxation_rate_scaling
(
omega
)
scaling
.
add_force_scaling
(
force_field
)
generate_lattice_model
(
ctx
,
'SrtWithForceFieldModel'
,
lb_method
,
refinement_scaling
=
scaling
)
generate_lattice_model
(
ctx
,
'SrtWithForceFieldModel'
,
lb_method
,
refinement_scaling
=
scaling
,
update_rule_params
=
{
'compressible'
:
True
})
generate_boundary
(
ctx
,
'MyUBB'
,
UBB
([
0.05
,
0
,
0
]),
lb_method
)
generate_boundary
(
ctx
,
'MyNoSlip'
,
NoSlip
(),
lb_method
)
assert
'static const bool compressible = true;'
in
ctx
.
files
[
'SrtWithForceFieldModel.h'
]
@
staticmethod
def
test_sparse
():
...
...
@@ -48,3 +50,12 @@ class WalberlaLbmpyCodegenTest(unittest.TestCase):
lb_assignments
=
create_lb_update_rule
(
stencil
=
'D3Q19'
,
method
=
'srt'
).
main_assignments
generate_pack_info_from_kernel
(
ctx
,
'MyPackInfo2'
,
lb_assignments
)
@
staticmethod
def
test_incompressible
():
with
ManualCodeGenerationContext
()
as
ctx
:
omega
=
sp
.
Symbol
(
"omega"
)
lb_method
=
create_lb_method
(
stencil
=
'D3Q19'
,
method
=
'srt'
,
relaxation_rates
=
[
omega
],
compressible
=
False
)
generate_lattice_model
(
ctx
,
'Model'
,
lb_method
,
update_rule_params
=
{
'compressible'
:
False
})
assert
'static const bool compressible = false;'
in
ctx
.
files
[
'Model.h'
]
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