Skip to content

Commit

Permalink
Formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiSzuttor committed Mar 15, 2019
1 parent da2e157 commit 920248f
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 43 deletions.
12 changes: 4 additions & 8 deletions src/core/domain_decomposition.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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, /* 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. */ but may be set to a larger value by the user for performance reasons. */
min_num_cells = min_num_cells = std::max(min_num_cells, calc_processor_min_num_cells(grid));
std::max(min_num_cells, calc_processor_min_num_cells(grid));


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


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


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


dd_prepare_comm(&cell_structure.exchange_ghosts_comm, exchange_data, dd_prepare_comm(&cell_structure.exchange_ghosts_comm, exchange_data, grid);
grid); dd_prepare_comm(&cell_structure.update_ghost_pos_comm, update_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, dd_prepare_comm(&cell_structure.collect_ghost_force_comm, GHOSTTRANS_FORCE,
grid); grid);


Expand Down
5 changes: 3 additions & 2 deletions src/core/electrostatics_magnetostatics/fft.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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, static void fft_back_grid_comm(fft_forw_plan plan_f, fft_back_plan plan_b,
double *in, double *out, fft_data_struct &fft); 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 fft_init(double **data, int *ca_mesh_dim, int *ca_mesh_margin,
int *ks_pnum, fft_data_struct &fft, const Vector3i &grid) { int *global_mesh_dim, double *global_mesh_off, int *ks_pnum,
fft_data_struct &fft, const Vector3i &grid) {
int i, j; int i, j;
/* helpers */ /* helpers */
int mult[3]; int mult[3];
Expand Down
5 changes: 3 additions & 2 deletions src/core/electrostatics_magnetostatics/fft.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@
* \param global_mesh_off Pointer to global CA mesh offset. * \param global_mesh_off Pointer to global CA mesh offset.
* \param ks_pnum Pointer to number of permutations in k-space. * \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 fft_init(double **data, int *ca_mesh_dim, int *ca_mesh_margin,
int *ks_pnum, fft_data_struct &fft, const Vector3i &grid); int *global_mesh_dim, double *global_mesh_off, int *ks_pnum,
fft_data_struct &fft, const Vector3i &grid);


/** perform the forward 3D FFT. /** perform the forward 3D FFT.
The assigned charges are in \a data. The result is also stored in \a data. The assigned charges are in \a data. The result is also stored in \a data.
Expand Down
7 changes: 4 additions & 3 deletions src/core/electrostatics_magnetostatics/p3m-dipolar.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -402,9 +402,10 @@ void dp3m_init() {
P3M_TRACE(fprintf(stderr, "%d: dp3m.rs_mesh ADR=%p\n", this_node, P3M_TRACE(fprintf(stderr, "%d: dp3m.rs_mesh ADR=%p\n", this_node,
(void *)dp3m.rs_mesh)); (void *)dp3m.rs_mesh));


int ca_mesh_size = fft_init(&dp3m.rs_mesh, dp3m.local_mesh.dim, int ca_mesh_size =
dp3m.local_mesh.margin, dp3m.params.mesh, fft_init(&dp3m.rs_mesh, dp3m.local_mesh.dim, dp3m.local_mesh.margin,
dp3m.params.mesh_off, &dp3m.ks_pnum, dp3m.fft, node_grid); 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)); dp3m.ks_mesh = Utils::realloc(dp3m.ks_mesh, ca_mesh_size * sizeof(double));


for (n = 0; n < 3; n++) for (n = 0; n < 3; n++)
Expand Down
6 changes: 3 additions & 3 deletions src/core/electrostatics_magnetostatics/p3m.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -366,9 +366,9 @@ void p3m_init() {
P3M_TRACE(fprintf(stderr, "%d: p3m.rs_mesh ADR=%p\n", this_node, P3M_TRACE(fprintf(stderr, "%d: p3m.rs_mesh ADR=%p\n", this_node,
(void *)p3m.rs_mesh)); (void *)p3m.rs_mesh));


int ca_mesh_size = int ca_mesh_size = fft_init(
fft_init(&p3m.rs_mesh, p3m.local_mesh.dim, p3m.local_mesh.margin, &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.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.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, P3M_TRACE(fprintf(stderr, "%d: p3m.rs_mesh ADR=%p\n", this_node,
Expand Down
3 changes: 2 additions & 1 deletion src/core/global.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ typedef struct {


const std::unordered_map<int, Datafield> fields{ const std::unordered_map<int, Datafield> fields{
{FIELD_BOXL, {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, {FIELD_CELLGRID,
{dd.cell_grid, Datafield::Type::INT, 3, {dd.cell_grid, Datafield::Type::INT, 3,
"cell_grid"}}, /* 1 from cells.cpp */ "cell_grid"}}, /* 1 from cells.cpp */
Expand Down
3 changes: 2 additions & 1 deletion src/core/grid_based_algorithms/halo.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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 fieldtype field layout of the lattice data (Input)
* @param datatype MPI datatype for 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) { const Vector3i &local_node_grid) {
int k, n, dir, lr, cnt, num = 0; int k, n, dir, lr, cnt, num = 0;
const auto grid = lattice->grid; const auto grid = lattice->grid;
Expand Down
3 changes: 2 additions & 1 deletion src/core/grid_based_algorithms/halo.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ void halo_free_fieldtype(Fieldtype *ftype);
* @param fieldtype field layout of the lattice data (Input) * @param fieldtype field layout of the lattice data (Input)
* @param datatype MPI datatype for 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); const Vector3i &local_node_grid);


/** Frees datastructures associated with a halo communicator /** Frees datastructures associated with a halo communicator
Expand Down
31 changes: 19 additions & 12 deletions src/core/grid_based_algorithms/lattice.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
#include "debug.hpp" #include "debug.hpp"
#include "grid.hpp" #include "grid.hpp"


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


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


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


Expand Down Expand Up @@ -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 */ /* determine coordinates in node_grid */
Vector3i grid; Vector3i grid;
grid[0] = (int)floor(ind[0] * this->agrid[0] * box_l_i[0] * local_node_grid[0]); grid[0] =
grid[1] = (int)floor(ind[1] * this->agrid[1] * box_l_i[1] * local_node_grid[1]); (int)floor(ind[0] * this->agrid[0] * box_l_i[0] * local_node_grid[0]);
grid[2] = (int)floor(ind[2] * this->agrid[2] * box_l_i[2] * local_node_grid[2]); 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 */ /* change from global to local lattice coordinates */
ind[0] = ind[0] - grid[0] * this->grid[0] + this->halo_size; ind[0] = ind[0] - grid[0] * this->grid[0] + this->halo_size;
Expand Down
11 changes: 7 additions & 4 deletions src/core/grid_based_algorithms/lattice.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ class Lattice {
* \param halo_size halo size * \param halo_size halo size
* \param dim lattice dimensions * \param dim lattice dimensions
*/ */
int init(double *agrid, double *offset, int halo_size, size_t dim, const Vector3d &local_box, int init(double *agrid, double *offset, int halo_size, size_t dim,
const Vector3d &myright, const Vector3d &box_length); const Vector3d &local_box, const Vector3d &myright,
const Vector3d &box_length);


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


/** Map a global lattice site to the node grid. /** Map a global lattice site to the node grid.
Expand Down
9 changes: 6 additions & 3 deletions src/core/grid_based_algorithms/lb.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ void lb_init() {
} }


/* initialize the local lattice domain */ /* 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) if (check_runtime_errors() || init_status != ES_OK)
return; return;
Expand Down Expand Up @@ -263,7 +264,8 @@ void lb_reinit_parameters() {
} }


/* Halo communication for push scheme */ /* 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; Lattice::index_t index;
int x, y, z, count; int x, y, z, count;
int rnode, snode; int rnode, snode;
Expand Down Expand Up @@ -632,7 +634,8 @@ void lb_prepare_communication() {
* datatypes */ * datatypes */


/* prepare the communication for a single velocity */ /* 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.num = comm.num;
update_halo_comm.halo_info = update_halo_comm.halo_info =
Expand Down
1 change: 0 additions & 1 deletion src/core/io/writer/h5md_core.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "cells.hpp" #include "cells.hpp"
#include "global.hpp" #include "global.hpp"



#include <algorithm> #include <algorithm>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
Expand Down
6 changes: 4 additions & 2 deletions src/core/virtual_sites/lb_inertialess_tracers.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ void CoupleIBMParticleToFluid(Particle *p) {
// Get indices and weights of affected nodes using discrete delta function // Get indices and weights of affected nodes using discrete delta function
Vector<std::size_t, 8> node_index{}; Vector<std::size_t, 8> node_index{};
Vector6d delta{}; 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 // Loop over all affected nodes
for (int z = 0; z < 2; z++) { for (int z = 0; z < 2; z++) {
Expand Down Expand Up @@ -233,7 +234,8 @@ void GetIBMInterpolatedVelocity(double *p, double *const v,
and the relative position of the particle in this cell */ and the relative position of the particle in this cell */
Vector<std::size_t, 8> node_index{}; Vector<std::size_t, 8> node_index{};
Vector6d delta{}; 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 /* calculate fluid velocity at particle's position
this is done by linear interpolation this is done by linear interpolation
Expand Down

0 comments on commit 920248f

Please sign in to comment.