Commit 2ef82912 authored by Martin Bauer's avatar Martin Bauer
Browse files

PEP8 name refactoring

- test run again
- notebooks not yet
parent 6b574d36
from .walberla_lbm_generation import generateLatticeModelFiles, generateLatticeModel, RefinementScaling, createLatticeBoltzmannMethod
from .walberla_lbm_generation import generate_lattice_model_files, generate_lattice_model, RefinementScaling, create_lb_method
from pystencils import Field
\ No newline at end of file
......@@ -3,80 +3,80 @@ from jinja2 import Environment, PackageLoader
from pystencils import Field, FieldType
from pystencils.data_types import create_type, TypedSymbol
from pystencils_walberla.jinja_filters import addPystencilsFiltersToJinjaEnv
from pystencils_walberla.jinja_filters import add_pystencils_filters_to_jinja_env
from lbmpy.boundaries.boundaryhandling import createLatticeBoltzmannBoundaryKernel
from lbmpy.boundaries.boundaryhandling import create_lattice_boltzmann_boundary_kernel
from pystencils.boundaries.createindexlist import numpyDataTypeForBoundaryObject, \
boundaryIndexArrayCoordinateNames, directionMemberName
from lbmpy_walberla.walberla_lbm_generation import KernelInfo
def structFromNumpyDataType(structName, numpyDtype):
result = "struct %s { \n" % (structName,)
def struct_from_numpy_dtype(struct_name, numpy_dtype):
result = "struct %s { \n" % (struct_name,)
equalityCompare = []
constructorParams = []
constructorInitializerList = []
for name, (subType, offset) in numpyDtype.fields.items():
pystencilsType = create_type(subType)
result += " %s %s;\n" % (pystencilsType, name)
equality_compare = []
constructor_params = []
constructor_initializer_list = []
for name, (subType, offset) in numpy_dtype.fields.items():
pystencils_type = create_type(subType)
result += " %s %s;\n" % (pystencils_type, name)
if name in boundaryIndexArrayCoordinateNames or name == directionMemberName:
constructorParams.append("%s %s_" % (pystencilsType, name))
constructorInitializerList.append("%s(%s_)" % (name, name))
constructor_params.append("%s %s_" % (pystencils_type, name))
constructor_initializer_list.append("%s(%s_)" % (name, name))
else:
constructorInitializerList.append("%s()" % name)
if pystencilsType.is_float():
equalityCompare.append("floatIsEqual(%s, o.%s)" % (name, name))
constructor_initializer_list.append("%s()" % name)
if pystencils_type.is_float():
equality_compare.append("floatIsEqual(%s, o.%s)" % (name, name))
else:
equalityCompare.append("%s == o.%s" % (name, name))
equality_compare.append("%s == o.%s" % (name, name))
result += " %s(%s) : %s {}\n" % (structName, ", ".join(constructorParams), ", ".join(constructorInitializerList))
result += " %s(%s) : %s {}\n" % (struct_name, ", ".join(constructor_params), ", ".join(constructor_initializer_list))
result += " bool operator==(const %s & o) const {\n return %s;\n }\n" % \
(structName, " && ".join(equalityCompare))
(struct_name, " && ".join(equality_compare))
result += "};\n"
return result
def createBoundaryClass(boundaryObject, lbMethod, doublePrecision=True, target='cpu'):
structName = "IndexInfo"
indexStructDtype = numpyDataTypeForBoundaryObject(boundaryObject, lbMethod.dim)
def create_boundary_class(boundary_object, lb_method, double_precision=True, target='cpu'):
struct_name = "IndexInfo"
index_struct_dtype = numpyDataTypeForBoundaryObject(boundary_object, lb_method.dim)
pdfField = Field.createGeneric('pdfs', lbMethod.dim, np.float64 if doublePrecision else np.float32,
indexDimensions=1, layout='fzyx', indexShape=[len(lbMethod.stencil)])
pdf_field = Field.create_generic('pdfs', lb_method.dim, np.float64 if double_precision else np.float32,
index_dimensions=1, layout='fzyx', index_shape=[len(lb_method.stencil)])
indexField = Field('indexVector', FieldType.INDEXED, indexStructDtype, layout=[0],
shape=(TypedSymbol("indexVectorSize", create_type(np.int64)), 1), strides=(1, 1))
index_field = Field('indexVector', FieldType.INDEXED, index_struct_dtype, layout=[0],
shape=(TypedSymbol("indexVectorSize", create_type(np.int64)), 1), strides=(1, 1))
kernel = createLatticeBoltzmannBoundaryKernel(pdfField, indexField, lbMethod, boundaryObject, target=target)
kernel = create_lattice_boltzmann_boundary_kernel(pdf_field, index_field, lb_method, boundary_object, target=target)
stencilInfo = [(i, ", ".join([str(e) for e in d])) for i, d in enumerate(lbMethod.stencil)]
stencil_info = [(i, ", ".join([str(e) for e in d])) for i, d in enumerate(lb_method.stencil)]
context = {
'className': boundaryObject.name,
'StructName': structName,
'StructDeclaration': structFromNumpyDataType(structName, indexStructDtype),
'className': boundary_object.name,
'StructName': struct_name,
'StructDeclaration': struct_from_numpy_dtype(struct_name, index_struct_dtype),
'kernel': KernelInfo(kernel, [], []),
'stencilInfo': stencilInfo,
'dim': lbMethod.dim,
'stencil_info': stencil_info,
'dim': lb_method.dim,
'target': target,
'namespace': 'lbm',
}
env = Environment(loader=PackageLoader('lbmpy_walberla'))
addPystencilsFiltersToJinjaEnv(env)
add_pystencils_filters_to_jinja_env(env)
headerFile = env.get_template('Boundary.tmpl.h').render(**context)
cppFile = env.get_template('Boundary.tmpl.cpp').render(**context)
return headerFile, cppFile
header_file = env.get_template('Boundary.tmpl.h').render(**context)
cpp_file = env.get_template('Boundary.tmpl.cpp').render(**context)
return header_file, cpp_file
if __name__ == '__main__':
from lbmpy.boundaries import NoSlip, UBB
from lbmpy.creationfunctions import createLatticeBoltzmannMethod
from lbmpy.boundaries import UBB
from lbmpy.creationfunctions import create_lb_method
boundary = UBB(lambda: 0, dim=2)
method = createLatticeBoltzmannMethod(stencil='D2Q9', method='srt')
header, source = createBoundaryClass(boundary, method)
method = create_lb_method(stencil='D2Q9', method='srt')
header, source = create_boundary_class(boundary, method)
print(source)
......@@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along
// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \\file {{className}}.cpp
//! \\file {{class_name}}.cpp
//! \\ingroup lbm
//! \\author lbmpy
//======================================================================================================================
......@@ -22,7 +22,7 @@
#include "core/DataTypes.h"
#include "core/Macros.h"
#include "{{className}}.h"
#include "{{class_name}}.h"
{% if target is equalto 'cpu' -%}
......@@ -41,21 +41,21 @@ namespace {{namespace}} {
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif
{{kernel|generateDefinition}}
{{kernel|generate_definition}}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
void {{className}}::operator() ( IBlock * block )
void {{class_name}}::operator() ( IBlock * block )
{
auto * indexVector = block->getData<IndexVector>(indexVectorID);
int64_t indexVectorSize = int64_c( indexVector->size() );
uint8_t * fd_indexVector = reinterpret_cast<uint8_t*>(&(*indexVector)[0]);
{{kernel|generateBlockDataToFieldExtraction(['indexVector', 'indexVectorSize'])|indent(4)}}
{{kernel|generateCall|indent(4)}}
{{kernel|generate_block_data_to_field_extraction(['indexVector', 'indexVectorSize'])|indent(4)}}
{{kernel|generate_call|indent(4)}}
}
......
......@@ -53,8 +53,8 @@ public:
typedef std::vector<{{StructName}}> IndexVector;
{{className}}( const shared_ptr<StructuredBlockForest> & blocks,
{{kernel|generateConstructorParameters(['indexVector', 'indexVectorSize'])}} )
: {{ kernel|generateConstructorInitializerList(['indexVector', 'indexVectorSize']) }}
{{kernel|generate_constructor_parameters(['indexVector', 'indexVectorSize'])}} )
: {{ kernel|generate_constructor_initializer_list(['indexVector', 'indexVectorSize']) }}
{
auto createIdxVector = []( IBlock * const , StructuredBlockStorage * const ) { return new IndexVector(); };
indexVectorID = blocks->addStructuredBlockData< IndexVector >( createIdxVector, "IndexField_{{className}}");
......@@ -88,7 +88,7 @@ public:
if( ! isFlagSet(it, domainFlag) )
continue;
{%- for dirIdx, offset in stencilInfo %}
{%- for dirIdx, offset in stencil_info %}
{% if dim == 2 -%}
if ( isFlagSet( it.neighbor({{offset}}, 0), boundaryFlag ) )
indexVector->push_back({{StructName}}(it.x(), it.y(), {{dirIdx}} ) );
......@@ -102,7 +102,7 @@ public:
private:
BlockDataID indexVectorID;
{{kernel|generateMembers(['indexVector', 'indexVectorSize'])|indent(4)}}
{{kernel|generate_members(['indexVector', 'indexVectorSize'])|indent(4)}}
};
......
......@@ -39,45 +39,45 @@ using namespace std;
namespace walberla {
namespace {{namespace}} {
{{streamCollideKernel|generateDefinition}}
{{collideKernel|generateDefinition}}
{{streamKernel|generateDefinition}}
{{stream_collide_kernel|generate_definition}}
{{collide_kernel|generate_definition}}
{{stream_kernel|generate_definition}}
const real_t {{className}}::w[{{Q}}] = { {{weights}} };
const real_t {{className}}::wInv[{{Q}}] = { {{inverseWeights}} };
const real_t {{className}}::wInv[{{Q}}] = { {{inverse_weights}} };
void {{className}}::Sweep::streamCollide( IBlock * block, const uint_t numberOfGhostLayersToInclude )
{
{{streamCollideKernel|generateBlockDataToFieldExtraction(parameters=['pdfs', 'pdfs_tmp'])|indent(4)}}
{{stream_collide_kernel|generate_block_data_to_field_extraction(parameters=['pdfs', 'pdfs_tmp'])|indent(4)}}
auto & lm = dynamic_cast< lbm::PdfField<{{className}}> * > (pdfs)->latticeModel();
lm.configureBlock(block);
{{streamCollideKernel|generateRefsForKernelParameters(prefix='lm.', parametersToIgnore=['pdfs', 'pdfs_tmp'])|indent(4) }}
{{streamCollideKernel|generateCall('cell_idx_c(numberOfGhostLayersToInclude)')|indent(4)}}
{{streamCollideKernel|generateSwaps|indent(4)}}
{{stream_collide_kernel|generate_refs_for_kernel_parameters(prefix='lm.', parameters_to_ignore=['pdfs', 'pdfs_tmp'])|indent(4) }}
{{stream_collide_kernel|generate_call('cell_idx_c(numberOfGhostLayersToInclude)')|indent(4)}}
{{stream_collide_kernel|generate_swaps|indent(4)}}
}
void {{className}}::Sweep::collide( IBlock * block, const uint_t numberOfGhostLayersToInclude )
{
{{collideKernel|generateBlockDataToFieldExtraction(parameters=['pdfs'])|indent(4)}}
{{collide_kernel|generate_block_data_to_field_extraction(parameters=['pdfs'])|indent(4)}}
auto & lm = dynamic_cast< lbm::PdfField<{{className}}> * > (pdfs)->latticeModel();
lm.configureBlock(block);
{{collideKernel|generateRefsForKernelParameters(prefix='lm.', parametersToIgnore=['pdfs', 'pdfs_tmp'])|indent(4) }}
{{collideKernel|generateCall('cell_idx_c(numberOfGhostLayersToInclude)')|indent(4)}}
{{collide_kernel|generate_refs_for_kernel_parameters(prefix='lm.', parameters_to_ignore=['pdfs', 'pdfs_tmp'])|indent(4) }}
{{collide_kernel|generate_call('cell_idx_c(numberOfGhostLayersToInclude)')|indent(4)}}
}
void {{className}}::Sweep::stream( IBlock * block, const uint_t numberOfGhostLayersToInclude )
{
{{streamKernel|generateBlockDataToFieldExtraction(parameters=['pdfs', 'pdfs_tmp'])|indent(4)}}
{{stream_kernel|generate_block_data_to_field_extraction(parameters=['pdfs', 'pdfs_tmp'])|indent(4)}}
{{streamKernel|generateCall('cell_idx_c(numberOfGhostLayersToInclude)')|indent(4)}}
{{stream_kernel|generate_call('cell_idx_c(numberOfGhostLayersToInclude)')|indent(4)}}
{{streamKernel|generateSwaps|indent(4)}}
{{stream_kernel|generate_swaps|indent(4)}}
}
......
......@@ -25,7 +25,7 @@
#include "field/SwapableCompare.h"
#include "domain_decomposition/BlockDataID.h"
#include "domain_decomposition/IBlock.h"
#include "stencil/{{stencilName}}.h"
#include "stencil/{{stencil_name}}.h"
#include "lbm/lattice_model/EquilibriumDistribution.h"
#include "lbm/field/Density.h"
......@@ -57,12 +57,12 @@
// Forward declarations
namespace walberla{
namespace {{namespace}} {
class {{className}};
class {{class_name}};
}}
namespace walberla {
namespace mpi {
mpi::SendBuffer & operator<< (mpi::SendBuffer & buf, const ::walberla::{{namespace}}::{{className}} & lm);
mpi::RecvBuffer & operator>> (mpi::RecvBuffer & buf, ::walberla::{{namespace}}::{{className}} & lm);
mpi::SendBuffer & operator<< (mpi::SendBuffer & buf, const ::walberla::{{namespace}}::{{class_name}} & lm);
mpi::RecvBuffer & operator>> (mpi::RecvBuffer & buf, ::walberla::{{namespace}}::{{class_name}} & lm);
}}
......@@ -73,7 +73,7 @@ namespace {{namespace}} {
/**
{{className}} was generated with lbmpy. Do not edit this file directly. Instead modify {{className}}.py.
{{class_name}} was generated with lbmpy. Do not edit this file directly. Instead modify {{class_name}}.py.
For details see documentation of lbmpy.
Usage:
......@@ -82,16 +82,16 @@ Usage:
a force field. All constructor parameters are ordered alphabetically.
- Create a PDFField with the lattice model as template argument to store the particle distribution functions.
Use the PDFField to get and modify macroscopic values.
- The internal class {{className}}::Sweep is a functor to execute one LB time step.
- The internal class {{class_name}}::Sweep is a functor to execute one LB time step.
Stream, collide steps can be executed separately, or together in an optimized stream-pull-collide scheme
*/
class {{className}}
class {{class_name}}
{
public:
typedef stencil::{{stencilName}} Stencil;
typedef stencil::{{stencilName}} CommunicationStencil;
typedef stencil::{{stencil_name}} Stencil;
typedef stencil::{{stencil_name}} CommunicationStencil;
static const real_t w[{{Q}}];
static const real_t wInv[{{Q}}];
......@@ -117,8 +117,8 @@ public:
BlockDataID pdfsID;
};
{{className}}( {{streamCollideKernel|generateConstructorParameters(lmIgnores) }} )
: {{ streamCollideKernel|generateConstructorInitializerList(lmIgnores) }}, currentLevel(0)
{{class_name}}( {{stream_collide_kernel|generate_constructor_parameters(lmIgnores) }} )
: {{ stream_collide_kernel|generate_constructor_initializer_list(lmIgnores) }}, currentLevel(0)
{};
void configure( IBlock & block, StructuredBlockStorage &) { configureBlock( &block ); }
......@@ -126,9 +126,9 @@ public:
private:
void configureBlock(IBlock * block)
{
{{streamCollideKernel|generateBlockDataToFieldExtraction(lmIgnores, noDeclarations=True)|indent(8)}}
{{stream_collide_kernel|generate_block_data_to_field_extraction(lmIgnores, no_declarations=True)|indent(8)}}
{% if refinementLevelScaling -%}
{% if refinement_scaling -%}
const uint_t targetLevel = block->getBlockStorage().getLevel(*block);
if( targetLevel != currentLevel )
......@@ -139,17 +139,17 @@ private:
else // currentLevel > targetLevel
levelScaleFactor = real_t(1) / real_c( uint_t(1) << ( currentLevel - targetLevel ) );
{% for scalingType, name, expression in refinementLevelScaling.scalings -%}
{% for scalingType, name, expression in refinement_scaling.scaling_info -%}
{% if scalingType == 'normal' %}
{{name}} = {{expression}};
{% elif scalingType in ('fieldWithF', 'fieldXYZ') %}
auto it = {{name}}->{% if scalingType == 'fieldWithF'%} beginWithGhostLayer(){% else %}beginWithGhostLayerXYZ(){% endif %};
{% elif scalingType in ('field_with_f', 'field_xyz') %}
auto it = {{name}}->{% if scalingType == 'field_with_f'%} beginWithGhostLayer(){% else %}beginWithGhostLayerXYZ(){% endif %};
for( ; it != {{name}}->end(); ++it )
{
auto x = it.x();
auto y = it.y();
auto z = it.z();
{% if scalingType == 'fieldWithF' -%}
{% if scalingType == 'field_with_f' -%}
auto f = it.f();
{% endif -%}
*it = {{expression}};
......@@ -163,14 +163,14 @@ private:
}
// Parameters:
{{streamCollideKernel|generateMembers(lmIgnores)|indent(4)}}
{{stream_collide_kernel|generate_members(lmIgnores)|indent(4)}}
// Updated by configureBlock:
{{streamCollideKernel|generateBlockDataToFieldExtraction(lmIgnores, declarationsOnly=True)|indent(4)}}
{{stream_collide_kernel|generate_block_data_to_field_extraction(lmIgnores, declarations_only=True)|indent(4)}}
uint_t currentLevel;
// Backend classes can access private members:
friend class {{className}}::Sweep;
friend class {{class_name}}::Sweep;
template<class LM, class Enable> friend class EquilibriumDistribution;
template<class LM, class Enable> friend struct Equilibrium;
template<class LM, class Enable> friend struct internal::AdaptVelocityToForce;
......@@ -180,8 +180,8 @@ private:
template<class LM, class Enable> friend struct MomentumDensity;
template<class LM, class It, class Enable> friend struct DensityAndVelocityRange;
friend mpi::SendBuffer & ::walberla::mpi::operator<< (mpi::SendBuffer & , const {{className}} & );
friend mpi::RecvBuffer & ::walberla::mpi::operator>> (mpi::RecvBuffer & , {{className}} & );
friend mpi::SendBuffer & ::walberla::mpi::operator<< (mpi::SendBuffer & , const {{class_name}} & );
friend mpi::RecvBuffer & ::walberla::mpi::operator>> (mpi::RecvBuffer & , {{class_name}} & );
};
......@@ -197,10 +197,10 @@ private:
template<>
class EquilibriumDistribution< {{className}}, void>
class EquilibriumDistribution< {{class_name}}, void>
{
public:
typedef typename {{className}}::Stencil Stencil;
typedef typename {{class_name}}::Stencil Stencil;
static real_t get( const stencil::Direction direction,
const Vector3< real_t > & u = Vector3< real_t >( real_t(0.0) ),
......@@ -209,7 +209,7 @@ public:
{% if compressible == 'false' %}
rho -= real_t(1.0);
{% endif %}
{{equilibriumFromDirection}}
{{equilibrium_from_direction}}
}
static real_t getSymmetricPart( const stencil::Direction direction,
......@@ -229,7 +229,7 @@ public:
{% if compressible == 'false' %}
rho -= real_t(1.0);
{% endif %}
{{asymmetricEquilibriumFromDirection}}
{{asymmetric_equilibrium_from_direction}}
}
static std::vector< real_t > get( const Vector3< real_t > & u = Vector3<real_t>( real_t(0.0) ),
......@@ -252,28 +252,28 @@ public:
namespace internal {
template<>
struct AdaptVelocityToForce<{{className}}, void>
struct AdaptVelocityToForce<{{class_name}}, void>
{
template< typename FieldPtrOrIterator >
static Vector3<real_t> get( FieldPtrOrIterator & it, const {{className}} & lm,
static Vector3<real_t> get( FieldPtrOrIterator & it, const {{class_name}} & lm,
const Vector3< real_t > & velocity, const real_t rho )
{
auto x = it.x();
auto y = it.y();
auto z = it.z();
{% if macroscopicVelocityShift %}
return velocity - Vector3<real_t>({{macroscopicVelocityShift | join(",") }} {% if D == 2 %}, 0.0 {%endif %} );
{% if macroscopic_velocity_shift %}
return velocity - Vector3<real_t>({{macroscopic_velocity_shift | join(",") }} {% if D == 2 %}, 0.0 {%endif %} );
{% else %}
return velocity;
{% endif %}
}
static Vector3<real_t> get( const cell_idx_t x, const cell_idx_t y, const cell_idx_t z, const {{className}} & lm,
static Vector3<real_t> get( const cell_idx_t x, const cell_idx_t y, const cell_idx_t z, const {{class_name}} & lm,
const Vector3< real_t > & velocity, const real_t rho )
{
{% if macroscopicVelocityShift %}
{% if macroscopic_velocity_shift %}
return velocity - Vector3<real_t>({{macroscopicVelocityShift | join(",") }} {% if D == 2 %}, 0.0 {%endif %} );
return velocity - Vector3<real_t>({{macroscopic_velocity_shift | join(",") }} {% if D == 2 %}, 0.0 {%endif %} );
{% else %}
return velocity;
{% endif %}
......@@ -284,7 +284,7 @@ struct AdaptVelocityToForce<{{className}}, void>
template<>
struct Equilibrium< {{className}}, void >
struct Equilibrium< {{class_name}}, void >
{
template< typename FieldPtrOrIterator >
......@@ -311,71 +311,71 @@ struct Equilibrium< {{className}}, void >
template<>
struct Density<{{className}}, void>
struct Density<{{class_name}}, void>
{
template< typename FieldPtrOrIterator >
static inline real_t get( const {{className}} & , const FieldPtrOrIterator & it )
static inline real_t get( const {{class_name}} & , const FieldPtrOrIterator & it )
{
{% for i in range(Q) -%}
const real_t f_{{i}} = it[{{i}}];
{% endfor -%}
{{densityGetters | indent(8)}}
{{density_getters | indent(8)}}
return rho;
}
template< typename PdfField_T >
static inline real_t get( const {{className}} & ,
static inline real_t get( const {{class_name}} & ,
const PdfField_T & pdf, const cell_idx_t x, const cell_idx_t y, const cell_idx_t z )
{
const real_t & xyz0 = pdf(x,y,z,0);
{% for i in range(Q) -%}
const real_t f_{{i}} = pdf.getF( &xyz0, {{i}});
{% endfor -%}
{{densityGetters | indent(8)}}
{{density_getters | indent(8)}}
return rho;
}
};
template<>
struct DensityAndVelocity<{{className}}>
struct DensityAndVelocity<{{class_name}}>
{
template< typename FieldPtrOrIterator >
static void set( FieldPtrOrIterator & it, const {{className}} & lm,
static void set( FieldPtrOrIterator & it, const {{class_name}} & lm,
const Vector3< real_t > & u = Vector3< real_t >( real_t(0.0) ), const real_t rhoIn = real_t(1.0) )
{
auto x = it.x();
auto y = it.y();
auto z = it.z();
{{densityVelocitySetterMacroscopicValues | indent(8)}}
{{density_velocity_setter_macroscopic_values | indent(8)}}
{% if D == 2 -%}
const real_t u_2(0.0);
{% endif %}
Equilibrium<{{className}}>::set(it, Vector3<real_t>(u_0, u_1, u_2), rho);
Equilibrium<{{class_name}}>::set(it, Vector3<real_t>(u_0, u_1, u_2), rho);
}
template< typename PdfField_T >
static void set( PdfField_T & pdf, const cell_idx_t x, const cell_idx_t y, const cell_idx_t z, const {{className}} & lm,
static void set( PdfField_T & pdf, const cell_idx_t x, const cell_idx_t y, const cell_idx_t z, const {{class_name}} & lm,
const Vector3< real_t > & u = Vector3< real_t >( real_t(0.0) ), const real_t rhoIn = real_t(1.0) )
{
{{densityVelocitySetterMacroscopicValues | indent(8)}}
{{density_velocity_setter_macroscopic_values | indent(8)}}
{% if D == 2 -%}
const real_t u_2(0.0);
{% endif %}
Equilibrium<{{className}}>::set(pdf, x, y, z, Vector3<real_t>(u_0, u_1, u_2), rho);
Equilibrium<{{class_name}}>::set(pdf, x, y, z, Vector3<real_t>(u_0, u_1, u_2), rho);
}
};
template<typename FieldIteratorXYZ >
struct DensityAndVelocityRange<{{className}}, FieldIteratorXYZ>
struct DensityAndVelocityRange<{{class_name}}, FieldIteratorXYZ>
{
static void set( FieldIteratorXYZ & begin, const FieldIteratorXYZ & end, const {{className}} & lm,
static void set( FieldIteratorXYZ & begin, const FieldIteratorXYZ & end, const {{class_name}} & lm,
const Vector3< real_t > & u = Vector3< real_t >( real_t(0.0) ), const real_t rhoIn = real_t(1.0) )
{
for( auto cellIt = begin; cellIt != end; ++cellIt )
......@@ -383,12 +383,12 @@ struct DensityAndVelocityRange<{{className}}, FieldIteratorXYZ>
const auto x = cellIt.x();
const auto y = cellIt.y();
const auto z = cellIt.z();
{{densityVelocitySetterMacroscopicValues | indent(12)}}
{{density_velocity_setter_macroscopic_values | indent(12)}}
{% if D == 2 -%}
const real_t u_2(0.0);
{% endif %}
Equilibrium<{{className}}>::set(cellIt, Vector3<real_t>(u_0, u_1, u_2), rho);
Equilibrium<{{class_name}}>::set(cellIt, Vector3<real_t>(u_0, u_1, u_2), rho);
}
}
};
......@@ -396,10 +396,10 @@ struct DensityAndVelocityRange<{{className}}, FieldIteratorXYZ>
template<>
struct DensityAndMomentumDensity<{{className}}>
struct DensityAndMomentumDensity<{{class_name}}>
{
template< typename FieldPtrOrIterator >
static real_t get( Vector3< real_t > & momentumDensity, const {{className}} & lm,
static real_t get( Vector3< real_t > & momentumDensity, const {{class_name}} & lm,
const FieldPtrOrIterator & it )
{
const auto x = it.x();
......@@ -410,7 +410,7 @@ struct DensityAndMomentumDensity<{{className}}>
const real_t f_{{i}} = it[{{i}}];
{% endfor -%}
{{momentumDensityGetter | indent(8) }}
{{momentum_density_getter | indent(8) }}
{% for i in range(D) -%}
momentumDensity[{{i}}] = md_{{i}};
{% endfor %}
......@@ -418,7 +418,7 @@ struct DensityAndMomentumDensity<{{className}}>
}
template< typename PdfField_T >