Skip to content
Snippets Groups Projects
Commit 1d29b1de authored by Markus Holzer's avatar Markus Holzer Committed by Jonas Plewinski
Browse files

Add weights to storage spec

parent 927ebe66
Branches
No related merge requests found
......@@ -32,6 +32,7 @@ def generate_lbm_storage_specification(generation_context, class_name: str,
default_dtype = config.data_type.default_factory()
is_float = True if issubclass(default_dtype.numpy_dtype.type, np.float32) else False
constant_suffix = "f" if is_float else ""
cg = PackingKernelsCodegen(stencil, streaming_pattern, class_name, config)
kernels = cg.create_uniform_kernel_families()
......@@ -39,9 +40,6 @@ def generate_lbm_storage_specification(generation_context, class_name: str,
if nonuniform:
kernels = cg.create_nonuniform_kernel_families(kernels_dict=kernels)
values_per_cell = len(stencil)
dimension = len(stencil[0])
# Pure storage specification
if not stencil_name:
raise ValueError("lb_method uses a stencil that is not supported in waLBerla")
......@@ -56,11 +54,15 @@ def generate_lbm_storage_specification(generation_context, class_name: str,
'namespace': namespace,
'stencil_name': stencil_name,
'communication_stencil_name': communication_stencil_name,
'stencil_size': stencil.Q,
'dimension': stencil.D,
'compressible': cqc.compressible,
'equilibriumAccuracyOrder': equilibrium.order,
'equilibrium_accuracy_order': equilibrium.order,
'equilibrium_deviation_only': equilibrium.deviation_only,
'inplace': is_inplace(streaming_pattern),
'zero_centered': cqc.zero_centered_pdfs,
'eq_deviation_only': equilibrium.deviation_only,
'weights': ",".join(str(w.evalf()) + constant_suffix for w in method.weights),
'inverse_weights': ",".join(str((1 / w).evalf()) + constant_suffix for w in method.weights),
'nonuniform': nonuniform,
'target': target.name.lower(),
......@@ -68,8 +70,6 @@ def generate_lbm_storage_specification(generation_context, class_name: str,
'is_gpu': target == Target.GPU,
'kernels': kernels,
'direction_sizes': cg.get_direction_sizes(),
'stencil_size': stencil.Q,
'dimension': stencil.D,
'src_field': cg.src_field,
'dst_field': cg.dst_field
......
......@@ -63,19 +63,20 @@ class {{class_name}}
using Stencil = stencil::{{stencil_name}};
// Lattice stencil used for the communication (should be used to define which block directions need to be communicated)
using CommunicationStencil = stencil::{{communication_stencil_name}};
// If false used correction: Lattice Boltzmann Model for the Incompressible Navier–Stokes Equation, He 1997
static const bool compressible = {% if compressible %}true{% else %}false{% endif %};
// Cut off for the lattice Boltzmann equilibrium
static const int equilibriumAccuracyOrder = {{equilibriumAccuracyOrder}};
static const int equilibriumAccuracyOrder = {{equilibrium_accuracy_order}};
// If true the equilibrium is computed in regard to "delta_rho" and not the actual density "rho"
static const bool equilibriumDeviationOnly = {% if equilibrium_deviation_only -%} true {%- else -%} false {%- endif -%};
// If streaming pattern is inplace (esotwist, aa, ...) or not (pull, push)
static const bool inplace = {% if inplace -%} true {%- else -%} false {%- endif -%};
// If true the background deviation (rho_0 = 1) is subtracted for the collision step.
static const bool zeroCenteredPDFs = {% if zero_centered -%} true {%- else -%} false {%- endif -%};
// If true the equilibrium is computed in regard to "delta_rho" and not the actual density "rho"
static const bool deviationOnlyEquilibrium = {% if eq_deviation_only -%} true {%- else -%} false {%- endif -%};
// Lattice weights
static constexpr {{dtype}} w[{{stencil_size}}] = { {{weights}} };
// Inverse lattice weights
static constexpr {{dtype}} wInv[{{stencil_size}}] = { {{inverse_weights}} };
// Compute kernels to pack and unpack MPI buffers
class PackKernels {
......
......@@ -57,19 +57,20 @@ class D3Q19StorageSpecification
using Stencil = stencil::D3Q19;
// Lattice stencil used for the communication (should be used to define which block directions need to be communicated)
using CommunicationStencil = stencil::D3Q19;
// If false used correction: Lattice Boltzmann Model for the Incompressible Navier–Stokes Equation, He 1997
static const bool compressible = false;
// Cut off for the lattice Boltzmann equilibrium
static const int equilibriumAccuracyOrder = 2;
// If true the equilibrium is computed in regard to "delta_rho" and not the actual density "rho"
static const bool equilibriumDeviationOnly = true;
// If streaming pattern is inplace (esotwist, aa, ...) or not (pull, push)
static const bool inplace = false;
// If true the background deviation (rho_0 = 1) is subtracted for the collision step.
static const bool zeroCenteredPDFs = true;
// If true the equilibrium is computed in regard to "delta_rho" and not the actual density "rho"
static const bool deviationOnlyEquilibrium = true;
// Lattice weights
static constexpr double w[19] = { 0.333333333333333,0.0555555555555556,0.0555555555555556,0.0555555555555556,0.0555555555555556,0.0555555555555556,0.0555555555555556,0.0277777777777778,0.0277777777777778,0.0277777777777778,0.0277777777777778,0.0277777777777778,0.0277777777777778,0.0277777777777778,0.0277777777777778,0.0277777777777778,0.0277777777777778,0.0277777777777778,0.0277777777777778 };
// Inverse lattice weights
static constexpr double wInv[19] = { 3.00000000000000,18.0000000000000,18.0000000000000,18.0000000000000,18.0000000000000,18.0000000000000,18.0000000000000,36.0000000000000,36.0000000000000,36.0000000000000,36.0000000000000,36.0000000000000,36.0000000000000,36.0000000000000,36.0000000000000,36.0000000000000,36.0000000000000,36.0000000000000,36.0000000000000 };
// Compute kernels to pack and unpack MPI buffers
class PackKernels {
......
......@@ -57,19 +57,20 @@ class D3Q27StorageSpecification
using Stencil = stencil::D3Q27;
// Lattice stencil used for the communication (should be used to define which block directions need to be communicated)
using CommunicationStencil = stencil::D3Q27;
// If false used correction: Lattice Boltzmann Model for the Incompressible Navier–Stokes Equation, He 1997
static const bool compressible = false;
// Cut off for the lattice Boltzmann equilibrium
static const int equilibriumAccuracyOrder = 2;
// If true the equilibrium is computed in regard to "delta_rho" and not the actual density "rho"
static const bool equilibriumDeviationOnly = true;
// If streaming pattern is inplace (esotwist, aa, ...) or not (pull, push)
static const bool inplace = false;
// If true the background deviation (rho_0 = 1) is subtracted for the collision step.
static const bool zeroCenteredPDFs = true;
// If true the equilibrium is computed in regard to "delta_rho" and not the actual density "rho"
static const bool deviationOnlyEquilibrium = true;
// Lattice weights
static constexpr double w[27] = { 0.296296296296296,0.0740740740740741,0.0740740740740741,0.0740740740740741,0.0740740740740741,0.0740740740740741,0.0740740740740741,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.00462962962962963,0.00462962962962963,0.00462962962962963,0.00462962962962963,0.00462962962962963,0.00462962962962963,0.00462962962962963,0.00462962962962963 };
// Inverse lattice weights
static constexpr double wInv[27] = { 3.37500000000000,13.5000000000000,13.5000000000000,13.5000000000000,13.5000000000000,13.5000000000000,13.5000000000000,54.0000000000000,54.0000000000000,54.0000000000000,54.0000000000000,54.0000000000000,54.0000000000000,54.0000000000000,54.0000000000000,54.0000000000000,54.0000000000000,54.0000000000000,54.0000000000000,216.000000000000,216.000000000000,216.000000000000,216.000000000000,216.000000000000,216.000000000000,216.000000000000,216.000000000000 };
// Compute kernels to pack and unpack MPI buffers
class PackKernels {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment