Commit 033ef4fb authored by Markus Holzer's avatar Markus Holzer
Browse files

Minor changes

parent 291cc560
......@@ -17,7 +17,6 @@
//! \\author pystencils
//======================================================================================================================
#include "core/DataTypes.h"
{% if target is equalto 'cpu' -%}
......@@ -64,7 +63,7 @@ public:
NUM_TYPES = 3
};
IndexVectors() : cpuVectors_(NUM_TYPES) {}
IndexVectors() = default;
bool operator==(IndexVectors & other) { return other.cpuVectors_ == cpuVectors_; }
{% if target == 'gpu' -%}
......@@ -72,14 +71,14 @@ public:
for( auto & gpuVec: gpuVectors_)
cudaFree( gpuVec );
}
{% endif %}
{% endif -%}
CpuIndexVector & indexVector(Type t) { return cpuVectors_[t]; }
{{StructName}} * pointerCpu(Type t) { return &(cpuVectors_[t][0]); }
{% if target == 'gpu' -%}
{{StructName}} * pointerGpu(Type t) { return gpuVectors_[t]; }
{% endif %}
{% endif -%}
void syncGPU()
{
......@@ -100,12 +99,12 @@ public:
}
private:
std::vector<CpuIndexVector> cpuVectors_;
std::vector<CpuIndexVector> cpuVectors_{NUM_TYPES};
{% if target == 'gpu' -%}
using GpuIndexVector = {{StructName}} *;
std::vector<GpuIndexVector> gpuVectors_;
{% endif %}
{%- endif %}
};
......
......@@ -41,8 +41,47 @@ typedef pystencils::ChannelFlowCodeGen_PackInfo PackInfo_T;
typedef walberla::uint8_t flag_t;
typedef FlagField< flag_t > FlagField_T;
auto pdfFieldAdder = [](IBlock* const block, StructuredBlockStorage * const storage) {
return new PdfField_T(storage->getNumberOfXCells(*block),
storage->getNumberOfYCells(*block),
storage->getNumberOfZCells(*block),
uint_t(1),
field::fzyx,
make_shared<field::AllocateAligned<real_t, 64>>());
};
int main(int argc, char** argv)
{
class Init_element
{
public:
void operator()( walberla::lbm::ChannelFlowCodeGen_Outflow::IndexInfo &element, cell_idx_t x, cell_idx_t y, cell_idx_t z, field::GhostLayerField<double, 27> *pdfs)
{
element.pdf_3 = pdfs->get(x + cell_idx_c(0), y + cell_idx_c(0), z + cell_idx_c(0), 3);
element.pdf_nd_3 = pdfs->get(x + cell_idx_c(0), y + cell_idx_c(0), z + cell_idx_c(0), 3);
element.pdf_7 = pdfs->get(x + cell_idx_c(0), y + cell_idx_c(0), z + cell_idx_c(0), 7);
element.pdf_nd_7 = pdfs->get(x + cell_idx_c(0), y + cell_idx_c(0), z + cell_idx_c(0), 7);
element.pdf_9 = pdfs->get(x + cell_idx_c(0), y + cell_idx_c(0), z + cell_idx_c(0), 9);
element.pdf_nd_9 = pdfs->get(x + cell_idx_c(0), y + cell_idx_c(0), z + cell_idx_c(0), 9);
element.pdf_13 = pdfs->get(x + cell_idx_c(0), y + cell_idx_c(0), z + cell_idx_c(0), 13);
element.pdf_nd_13 = pdfs->get(x + cell_idx_c(0), y + cell_idx_c(0), z + cell_idx_c(0), 13);
element.pdf_17 = pdfs->get(x + cell_idx_c(0), y + cell_idx_c(0), z + cell_idx_c(0), 17);
element.pdf_nd_17 = pdfs->get(x + cell_idx_c(0), y + cell_idx_c(0), z + cell_idx_c(0), 17);
element.pdf_20 = pdfs->get(x + cell_idx_c(0), y + cell_idx_c(0), z + cell_idx_c(0), 20);
element.pdf_nd_20 = pdfs->get(x + cell_idx_c(0), y + cell_idx_c(0), z + cell_idx_c(0), 20);
element.pdf_22 = pdfs->get(x + cell_idx_c(0), y + cell_idx_c(0), z + cell_idx_c(0), 22);
element.pdf_nd_22 = pdfs->get(x + cell_idx_c(0), y + cell_idx_c(0), z + cell_idx_c(0), 22);
element.pdf_24 = pdfs->get(x + cell_idx_c(0), y + cell_idx_c(0), z + cell_idx_c(0), 24);
element.pdf_nd_24 = pdfs->get(x + cell_idx_c(0), y + cell_idx_c(0), z + cell_idx_c(0), 24);
element.pdf_26 = pdfs->get(x + cell_idx_c(0), y + cell_idx_c(0), z + cell_idx_c(0), 26);
element.pdf_nd_26 = pdfs->get(x + cell_idx_c(0), y + cell_idx_c(0), z + cell_idx_c(0), 26);
}
private:
};
walberla::Environment walberlaEnv(argc, argv);
for( auto cfg = python_coupling::configBegin( argc, argv ); cfg != python_coupling::configEnd(); ++cfg )
......@@ -66,7 +105,7 @@ int main(int argc, char** argv)
parameters.getParameter< double >("remainingTimeLoggerFrequency", 3.0); // in seconds
// create fields
BlockDataID pdfFieldID = field::addToStorage< PdfField_T >(blocks, "PDFs", real_t(0), field::fzyx);
BlockDataID pdfFieldID = blocks->addStructuredBlockData<PdfField_T>(pdfFieldAdder, "PDFs");
BlockDataID velFieldID = field::addToStorage< VelocityField_T >(blocks, "velocity", real_t(0), field::fzyx);
BlockDataID densityFieldID = field::addToStorage< ScalarField_T >(blocks, "density", real_t(0), field::fzyx);
......@@ -87,9 +126,10 @@ int main(int argc, char** argv)
auto boundariesConfig = config->getOneBlock("Boundaries");
lbm::ChannelFlowCodeGen_Outflow::Init_element test;
lbm::ChannelFlowCodeGen_UBB ubb(blocks, pdfFieldID, u_max);
lbm::ChannelFlowCodeGen_NoSlip noSlip(blocks, pdfFieldID);
lbm::ChannelFlowCodeGen_Outflow outflow(blocks, pdfFieldID);
lbm::ChannelFlowCodeGen_Outflow outflow(blocks, pdfFieldID, test);
geometry::initBoundaryHandling< FlagField_T >(*blocks, flagFieldId, boundariesConfig);
geometry::setNonBoundaryCellsToDomain< FlagField_T >(*blocks, flagFieldId, fluidFlagUID);
......
......@@ -35,15 +35,17 @@ setter_assignments = macroscopic_values_setter(method, velocity=velocity_field.c
getter_assignments = macroscopic_values_getter(method, velocity=velocity_field.center_vector,
pdfs=pdfs.center_vector, density=density_field)
# opt = {'instruction_set': 'sse', 'assume_aligned': True, 'nontemporal': False, 'assume_inner_stride_one': True}
update_rule = create_lb_update_rule(lb_method=method, **options)
info_header = f"""
using namespace walberla;
#include "stencil/D{dim}Q{q}.h"
using Stencil_T = walberla::stencil::D{dim}Q{q};
using PdfField_T = GhostLayerField<real_t, {q}>;
using VelocityField_T = GhostLayerField<real_t, {dim}>;
using ScalarField_T = GhostLayerField<real_t, 1>;
using namespace walberla;
#include "stencil/D{dim}Q{q}.h"
using Stencil_T = walberla::stencil::D{dim}Q{q};
using PdfField_T = GhostLayerField<real_t, {q}>;
using VelocityField_T = GhostLayerField<real_t, {dim}>;
using ScalarField_T = GhostLayerField<real_t, 1>;
"""
with CodeGeneration() as ctx:
......
......@@ -4,11 +4,11 @@ from lbmpy.relaxationrates import relaxation_rate_from_lattice_viscosity
class Scenario:
def __init__(self):
self.timesteps = 301
self.vtkWriteFrequency = 50
self.timesteps = 601
self.vtkWriteFrequency = 150
self.cells = (75, 100, 100)
self.blocks = (4, 1, 1)
self.cells = (32, 64, 64)
self.blocks = (8, 1, 1)
self.periodic = (0, 0, 0)
self.diameter_sphere = 30
......
Markdown is supported
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