Skip to content
Permalink
Browse files

Formatting.

  • Loading branch information...
KaiSzuttor committed Mar 15, 2019
1 parent da2e157 commit 920248f68b02681748dd16a965ff0c70f8de69b1
@@ -673,8 +673,7 @@ void dd_topology_init(CellPList *old, const Vector3i &grid) {

/* Min num cells can not be smaller than calc_processor_min_num_cells,
but may be set to a larger value by the user for performance reasons. */
min_num_cells =
std::max(min_num_cells, calc_processor_min_num_cells(grid));
min_num_cells = std::max(min_num_cells, calc_processor_min_num_cells(grid));

cell_structure.type = CELL_STRUCTURE_DOMDEC;
cell_structure.position_to_node = map_position_node_array;
@@ -686,17 +685,14 @@ void dd_topology_init(CellPList *old, const Vector3i &grid) {
dd_mark_cells();

/* create communicators */
dd_prepare_comm(&cell_structure.ghost_cells_comm, GHOSTTRANS_PARTNUM,
grid);
dd_prepare_comm(&cell_structure.ghost_cells_comm, GHOSTTRANS_PARTNUM, grid);

exchange_data =
(GHOSTTRANS_PROPRTS | GHOSTTRANS_POSITION | GHOSTTRANS_POSSHFTD);
update_data = (GHOSTTRANS_POSITION | GHOSTTRANS_POSSHFTD);

dd_prepare_comm(&cell_structure.exchange_ghosts_comm, exchange_data,
grid);
dd_prepare_comm(&cell_structure.update_ghost_pos_comm, update_data,
grid);
dd_prepare_comm(&cell_structure.exchange_ghosts_comm, exchange_data, grid);
dd_prepare_comm(&cell_structure.update_ghost_pos_comm, update_data, grid);
dd_prepare_comm(&cell_structure.collect_ghost_force_comm, GHOSTTRANS_FORCE,
grid);

@@ -56,8 +56,9 @@ static void fft_forw_grid_comm(fft_forw_plan plan, double *in, double *out,
static void fft_back_grid_comm(fft_forw_plan plan_f, fft_back_plan plan_b,
double *in, double *out, fft_data_struct &fft);

int fft_init(double **data, int *ca_mesh_dim, int *ca_mesh_margin, int *global_mesh_dim, double *global_mesh_off,
int *ks_pnum, fft_data_struct &fft, const Vector3i &grid) {
int fft_init(double **data, int *ca_mesh_dim, int *ca_mesh_margin,
int *global_mesh_dim, double *global_mesh_off, int *ks_pnum,
fft_data_struct &fft, const Vector3i &grid) {
int i, j;
/* helpers */
int mult[3];
@@ -61,8 +61,9 @@
* \param global_mesh_off Pointer to global CA mesh offset.
* \param ks_pnum Pointer to number of permutations in k-space.
*/
int fft_init(double **data, int *ca_mesh_dim, int *ca_mesh_margin, int *global_mesh_dim, double *global_mesh_off,
int *ks_pnum, fft_data_struct &fft, const Vector3i &grid);
int fft_init(double **data, int *ca_mesh_dim, int *ca_mesh_margin,
int *global_mesh_dim, double *global_mesh_off, int *ks_pnum,
fft_data_struct &fft, const Vector3i &grid);

/** perform the forward 3D FFT.
The assigned charges are in \a data. The result is also stored in \a data.
@@ -402,9 +402,10 @@ void dp3m_init() {
P3M_TRACE(fprintf(stderr, "%d: dp3m.rs_mesh ADR=%p\n", this_node,
(void *)dp3m.rs_mesh));

int ca_mesh_size = fft_init(&dp3m.rs_mesh, dp3m.local_mesh.dim,
dp3m.local_mesh.margin, dp3m.params.mesh,
dp3m.params.mesh_off, &dp3m.ks_pnum, dp3m.fft, node_grid);
int ca_mesh_size =
fft_init(&dp3m.rs_mesh, dp3m.local_mesh.dim, dp3m.local_mesh.margin,
dp3m.params.mesh, dp3m.params.mesh_off, &dp3m.ks_pnum,
dp3m.fft, node_grid);
dp3m.ks_mesh = Utils::realloc(dp3m.ks_mesh, ca_mesh_size * sizeof(double));

for (n = 0; n < 3; n++)
@@ -366,9 +366,9 @@ void p3m_init() {
P3M_TRACE(fprintf(stderr, "%d: p3m.rs_mesh ADR=%p\n", this_node,
(void *)p3m.rs_mesh));

int ca_mesh_size =
fft_init(&p3m.rs_mesh, p3m.local_mesh.dim, p3m.local_mesh.margin,
p3m.params.mesh, p3m.params.mesh_off, &p3m.ks_pnum, p3m.fft, node_grid);
int ca_mesh_size = fft_init(
&p3m.rs_mesh, p3m.local_mesh.dim, p3m.local_mesh.margin,
p3m.params.mesh, p3m.params.mesh_off, &p3m.ks_pnum, p3m.fft, node_grid);
p3m.ks_mesh = Utils::realloc(p3m.ks_mesh, ca_mesh_size * sizeof(double));

P3M_TRACE(fprintf(stderr, "%d: p3m.rs_mesh ADR=%p\n", this_node,
@@ -69,7 +69,8 @@ typedef struct {

const std::unordered_map<int, Datafield> fields{
{FIELD_BOXL,
{box_l.data(), Datafield::Type::DOUBLE, 3, "box_l"}}, /* 0 from grid.cpp */
{box_l.data(), Datafield::Type::DOUBLE, 3,
"box_l"}}, /* 0 from grid.cpp */
{FIELD_CELLGRID,
{dd.cell_grid, Datafield::Type::INT, 3,
"cell_grid"}}, /* 1 from cells.cpp */
@@ -234,7 +234,8 @@ void halo_dtcopy(char *r_buffer, char *s_buffer, int count, Fieldtype type) {
* @param fieldtype field layout of the lattice data (Input)
* @param datatype MPI datatype for the lattice data (Input)
*/
void prepare_halo_communication(HaloCommunicator *hc, Lattice *lattice, Fieldtype fieldtype, MPI_Datatype datatype,
void prepare_halo_communication(HaloCommunicator *hc, Lattice *lattice,
Fieldtype fieldtype, MPI_Datatype datatype,
const Vector3i &local_node_grid) {
int k, n, dir, lr, cnt, num = 0;
const auto grid = lattice->grid;
@@ -147,7 +147,8 @@ void halo_free_fieldtype(Fieldtype *ftype);
* @param fieldtype field layout of the lattice data (Input)
* @param datatype MPI datatype for the lattice data (Input)
*/
void prepare_halo_communication(HaloCommunicator *hc, Lattice *lattice, Fieldtype fieldtype, MPI_Datatype datatype,
void prepare_halo_communication(HaloCommunicator *hc, Lattice *lattice,
Fieldtype fieldtype, MPI_Datatype datatype,
const Vector3i &local_node_grid);

/** Frees datastructures associated with a halo communicator
@@ -29,8 +29,9 @@
#include "debug.hpp"
#include "grid.hpp"

int Lattice::init(double *agrid, double *offset, int halo_size, size_t dim, const Vector3d &local_box,
const Vector3d &myright, const Vector3d &box_length) {
int Lattice::init(double *agrid, double *offset, int halo_size, size_t dim,
const Vector3d &local_box, const Vector3d &myright,
const Vector3d &box_length) {
/* determine the number of local lattice nodes */
auto const epsilon = std::numeric_limits<double>::epsilon();
for (int d = 0; d < 3; d++) {
@@ -61,10 +62,10 @@ int Lattice::init(double *agrid, double *offset, int halo_size, size_t dim, cons
LATTICE_TRACE(fprintf(stderr,
"%d: box_l (%.3f,%.3f,%.3f) grid (%d,%d,%d) "
"node_neighbors (%d,%d,%d,%d,%d,%d)\n",
this_node, local_box[0], local_box[1],
local_box[2], this->grid[0], this->grid[1],
this->grid[2], node_neighbors[0], node_neighbors[1],
node_neighbors[2], node_neighbors[3], node_neighbors[4],
this_node, local_box[0], local_box[1], local_box[2],
this->grid[0], this->grid[1], this->grid[2],
node_neighbors[0], node_neighbors[1], node_neighbors[2],
node_neighbors[3], node_neighbors[4],
node_neighbors[5]));

this->halo_size = halo_size;
@@ -81,8 +82,10 @@ int Lattice::init(double *agrid, double *offset, int halo_size, size_t dim, cons
return ES_OK;
}

void Lattice::map_position_to_lattice(const Vector3d &pos, Vector<std::size_t, 8> &node_index, Vector6d &delta,
const Vector3d &myLeft, const Vector3d &local_box) const {
void Lattice::map_position_to_lattice(const Vector3d &pos,
Vector<std::size_t, 8> &node_index,
Vector6d &delta, const Vector3d &myLeft,
const Vector3d &local_box) const {
Vector3i ind{};
auto const epsilon = std::numeric_limits<double>::epsilon();

@@ -149,12 +152,16 @@ void Lattice::map_position_to_lattice_global(const Vector3d &pos, Vector3i &ind,
}
}

int Lattice::map_lattice_to_node(Vector3i &ind, const Vector3i &local_node_grid) const {
int Lattice::map_lattice_to_node(Vector3i &ind,
const Vector3i &local_node_grid) const {
/* determine coordinates in node_grid */
Vector3i grid;
grid[0] = (int)floor(ind[0] * this->agrid[0] * box_l_i[0] * local_node_grid[0]);
grid[1] = (int)floor(ind[1] * this->agrid[1] * box_l_i[1] * local_node_grid[1]);
grid[2] = (int)floor(ind[2] * this->agrid[2] * box_l_i[2] * local_node_grid[2]);
grid[0] =
(int)floor(ind[0] * this->agrid[0] * box_l_i[0] * local_node_grid[0]);
grid[1] =
(int)floor(ind[1] * this->agrid[1] * box_l_i[1] * local_node_grid[1]);
grid[2] =
(int)floor(ind[2] * this->agrid[2] * box_l_i[2] * local_node_grid[2]);

/* change from global to local lattice coordinates */
ind[0] = ind[0] - grid[0] * this->grid[0] + this->halo_size;
@@ -63,8 +63,9 @@ class Lattice {
* \param halo_size halo size
* \param dim lattice dimensions
*/
int init(double *agrid, double *offset, int halo_size, size_t dim, const Vector3d &local_box,
const Vector3d &myright, const Vector3d &box_length);
int init(double *agrid, double *offset, int halo_size, size_t dim,
const Vector3d &local_box, const Vector3d &myright,
const Vector3d &box_length);

/** Map a spatial position to the surrounding lattice sites.
*
@@ -82,8 +83,10 @@ class Lattice {
* \param delta distance fraction of pos from the surrounding
* elementary cell, 6 directions (Output)
*/
void map_position_to_lattice(const Vector3d &pos, Vector<std::size_t, 8> &node_index, Vector6d &delta,
const Vector3d &myLeft, const Vector3d &local_box) const;
void map_position_to_lattice(const Vector3d &pos,
Vector<std::size_t, 8> &node_index,
Vector6d &delta, const Vector3d &myLeft,
const Vector3d &local_box) const;
/********************** Inline Functions **********************/

/** Map a global lattice site to the node grid.
@@ -160,7 +160,8 @@ void lb_init() {
}

/* initialize the local lattice domain */
int init_status = lblattice.init(temp_agrid.data(), temp_offset.data(), 1, 0, local_box_l, my_right, box_l);
int init_status = lblattice.init(temp_agrid.data(), temp_offset.data(), 1, 0,
local_box_l, my_right, box_l);

if (check_runtime_errors() || init_status != ES_OK)
return;
@@ -263,7 +264,8 @@ void lb_reinit_parameters() {
}

/* Halo communication for push scheme */
static void halo_push_communication(LB_Fluid &lbfluid, const Vector3i &local_node_grid) {
static void halo_push_communication(LB_Fluid &lbfluid,
const Vector3i &local_node_grid) {
Lattice::index_t index;
int x, y, z, count;
int rnode, snode;
@@ -632,7 +634,8 @@ void lb_prepare_communication() {
* datatypes */

/* prepare the communication for a single velocity */
prepare_halo_communication(&comm, &lblattice, FIELDTYPE_DOUBLE, MPI_DOUBLE, node_grid);
prepare_halo_communication(&comm, &lblattice, FIELDTYPE_DOUBLE, MPI_DOUBLE,
node_grid);

update_halo_comm.num = comm.num;
update_halo_comm.halo_info =
@@ -27,7 +27,6 @@
#include "cells.hpp"
#include "global.hpp"


#include <algorithm>
#include <fstream>
#include <iostream>
@@ -178,7 +178,8 @@ void CoupleIBMParticleToFluid(Particle *p) {
// Get indices and weights of affected nodes using discrete delta function
Vector<std::size_t, 8> node_index{};
Vector6d delta{};
lblattice.map_position_to_lattice(p->r.p, node_index, delta, my_left, local_box_l);
lblattice.map_position_to_lattice(p->r.p, node_index, delta, my_left,
local_box_l);

// Loop over all affected nodes
for (int z = 0; z < 2; z++) {
@@ -233,7 +234,8 @@ void GetIBMInterpolatedVelocity(double *p, double *const v,
and the relative position of the particle in this cell */
Vector<std::size_t, 8> node_index{};
Vector6d delta{};
lblattice.map_position_to_lattice(pos, node_index, delta, my_left, local_box_l);
lblattice.map_position_to_lattice(pos, node_index, delta, my_left,
local_box_l);

/* calculate fluid velocity at particle's position
this is done by linear interpolation

0 comments on commit 920248f

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.