Skip to content

Commit

Permalink
code review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
christophlohrmann committed Aug 12, 2021
1 parent a5dad74 commit 05c2812
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 134 deletions.
48 changes: 24 additions & 24 deletions src/core/grid_based_algorithms/electrokinetics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,31 +147,31 @@ int ek_print_vtk_lbforce_density(char *filename);
int ek_lb_print_vtk_density(char *filename);
int ek_lb_print_vtk_velocity(char *filename);
int ek_init();
int ek_set_agrid(float agrid);
int ek_set_lb_density(float lb_density);
int ek_set_viscosity(float viscosity);
int ek_set_lb_ext_force_density(float lb_ext_force_dens_x,
float lb_ext_force_dens_y,
float lb_ext_force_dens_z);
int ek_set_friction(float friction);
int ek_set_T(float T);
int ek_set_prefactor(float prefactor);
int ek_set_electrostatics_coupling(bool electrostatics_coupling);
void ek_set_agrid(float agrid);
void ek_set_lb_density(float lb_density);
void ek_set_viscosity(float viscosity);
void ek_set_lb_ext_force_density(float lb_ext_force_dens_x,
float lb_ext_force_dens_y,
float lb_ext_force_dens_z);
void ek_set_friction(float friction);
void ek_set_T(float T);
void ek_set_prefactor(float prefactor);
void ek_set_electrostatics_coupling(bool electrostatics_coupling);
void ek_calculate_electrostatic_coupling();
int ek_set_bulk_viscosity(float bulk_viscosity);
int ek_set_gamma_odd(float gamma_odd);
int ek_set_gamma_even(float gamma_even);
int ek_set_density(int species, float density);
int ek_set_D(int species, float D);
int ek_set_valency(int species, float valency);
int ek_set_ext_force_density(int species, float ext_force_density_x,
float ext_force_density_y,
float ext_force_density_z);
int ek_set_stencil(int stencil);
int ek_set_advection(bool advection);
int ek_set_fluidcoupling(bool ideal_contribution);
int ek_set_fluctuations(bool fluctuations);
int ek_set_fluctuation_amplitude(float fluctuation_amplitude);
void ek_set_bulk_viscosity(float bulk_viscosity);
void ek_set_gamma_odd(float gamma_odd);
void ek_set_gamma_even(float gamma_even);
void ek_set_density(int species, float density);
void ek_set_D(int species, float D);
void ek_set_valency(int species, float valency);
void ek_set_ext_force_density(int species, float ext_force_density_x,
float ext_force_density_y,
float ext_force_density_z);
void ek_set_stencil(int stencil);
void ek_set_advection(bool advection);
void ek_set_fluidcoupling(bool ideal_contribution);
void ek_set_fluctuations(bool fluctuations);
void ek_set_fluctuation_amplitude(float fluctuation_amplitude);
void ek_set_rng_state(uint64_t counter);
int ek_node_get_density(int species, int x, int y, int z, double *density);
int ek_node_get_flux(int species, int x, int y, int z, double *flux);
Expand Down
139 changes: 49 additions & 90 deletions src/core/grid_based_algorithms/electrokinetics_cuda.cu
Original file line number Diff line number Diff line change
Expand Up @@ -3641,185 +3641,144 @@ void ek_print_lbpar() {
printf("}\n");
}

int ek_set_agrid(float agrid) {
inline void ek_setter_throw_if_initialized() {
throw std::runtime_error(
"Electrokinetics parameters cannot be set after initialisation");
};

void ek_set_agrid(float agrid) {
if (ek_initialized)
throw std::runtime_error(
"Electrokinetics parameters cannot be set after initialisation");
ek_setter_throw_if_initialized();
ek_parameters.agrid = agrid;
return 0;
}

int ek_set_lb_density(float lb_density) {
void ek_set_lb_density(float lb_density) {
if (ek_initialized)
throw std::runtime_error(
"Electrokinetics parameters cannot be set after initialisation");
ek_setter_throw_if_initialized();
ek_parameters.lb_density = lb_density;
return 0;
}

int ek_set_prefactor(float prefactor) {
void ek_set_prefactor(float prefactor) {
if (ek_initialized)
throw std::runtime_error(
"Electrokinetics parameters cannot be set after initialisation");
ek_setter_throw_if_initialized();
ek_parameters.prefactor = prefactor;
return 0;
}

int ek_set_electrostatics_coupling(bool electrostatics_coupling) {
void ek_set_electrostatics_coupling(bool electrostatics_coupling) {
if (ek_initialized)
throw std::runtime_error(
"Electrokinetics parameters cannot be set after initialisation");
ek_setter_throw_if_initialized();
ek_parameters.es_coupling = electrostatics_coupling;
return 0;
}

int ek_set_viscosity(float viscosity) {
void ek_set_viscosity(float viscosity) {
if (ek_initialized)
throw std::runtime_error(
"Electrokinetics parameters cannot be set after initialisation");
ek_setter_throw_if_initialized();
ek_parameters.viscosity = viscosity;
return 0;
}

int ek_set_lb_ext_force_density(float lb_ext_force_dens_x,
float lb_ext_force_dens_y,
float lb_ext_force_dens_z) {
void ek_set_lb_ext_force_density(float lb_ext_force_dens_x,
float lb_ext_force_dens_y,
float lb_ext_force_dens_z) {
if (ek_initialized)
throw std::runtime_error(
"Electrokinetics parameters cannot be set after initialisation");
ek_setter_throw_if_initialized();
ek_parameters.lb_ext_force_density[0] = lb_ext_force_dens_x;
ek_parameters.lb_ext_force_density[1] = lb_ext_force_dens_y;
ek_parameters.lb_ext_force_density[2] = lb_ext_force_dens_z;
return 0;
}

int ek_set_friction(float friction) {
void ek_set_friction(float friction) {
if (ek_initialized)
throw std::runtime_error(
"Electrokinetics parameters cannot be set after initialisation");
ek_setter_throw_if_initialized();
ek_parameters.friction = friction;
return 0;
}

int ek_set_bulk_viscosity(float bulk_viscosity) {
void ek_set_bulk_viscosity(float bulk_viscosity) {
if (ek_initialized)
throw std::runtime_error(
"Electrokinetics parameters cannot be set after initialisation");
ek_setter_throw_if_initialized();
ek_parameters.bulk_viscosity = bulk_viscosity;
return 0;
}

int ek_set_gamma_odd(float gamma_odd) {
void ek_set_gamma_odd(float gamma_odd) {
if (ek_initialized)
throw std::runtime_error(
"Electrokinetics parameters cannot be set after initialisation");
ek_setter_throw_if_initialized();
ek_parameters.gamma_odd = gamma_odd;
return 0;
}

int ek_set_gamma_even(float gamma_even) {
void ek_set_gamma_even(float gamma_even) {
if (ek_initialized)
throw std::runtime_error(
"Electrokinetics parameters cannot be set after initialisation");
ek_setter_throw_if_initialized();
ek_parameters.gamma_even = gamma_even;
return 0;
}

int ek_set_stencil(int stencil) {
void ek_set_stencil(int stencil) {
if (ek_initialized)
throw std::runtime_error(
"Electrokinetics parameters cannot be set after initialisation");
ek_setter_throw_if_initialized();
if (!ek_parameters.fluidcoupling_ideal_contribution)
return 1; // combination not implemented
throw std::runtime_error(
"Combination of stencil and fluid coupling not implmented.");
ek_parameters.stencil = stencil;
return 0;
}

int ek_set_advection(bool advection) {
void ek_set_advection(bool advection) {
if (ek_initialized)
throw std::runtime_error(
"Electrokinetics parameters cannot be set after initialisation");
ek_setter_throw_if_initialized();
ek_parameters.advection = advection;
return 0;
}

int ek_set_fluctuations(bool fluctuations) {
void ek_set_fluctuations(bool fluctuations) {
if (ek_initialized)
throw std::runtime_error(
"Electrokinetics parameters cannot be set after initialisation");
ek_setter_throw_if_initialized();
ek_parameters.fluctuations = fluctuations;
return 0;
}

int ek_set_fluctuation_amplitude(float fluctuation_amplitude) {
void ek_set_fluctuation_amplitude(float fluctuation_amplitude) {
if (ek_initialized)
throw std::runtime_error(
"Electrokinetics parameters cannot be set after initialisation");
ek_setter_throw_if_initialized();
ek_parameters.fluctuation_amplitude = fluctuation_amplitude;
return 0;
}

int ek_set_fluidcoupling(bool ideal_contribution) {
void ek_set_fluidcoupling(bool ideal_contribution) {
if (ek_initialized)
throw std::runtime_error(
"Electrokinetics parameters cannot be set after initialisation");
ek_setter_throw_if_initialized();
if (ek_parameters.stencil != 0)
return 1; // combination not implemente
throw std::runtime_error(
"Combination of stencil and fluid coupling not implemented.");
ek_parameters.fluidcoupling_ideal_contribution = ideal_contribution;
return 0;
}

int ek_set_T(float T) {
void ek_set_T(float T) {
if (ek_initialized)
throw std::runtime_error(
"Electrokinetics parameters cannot be set after initialisation");
ek_setter_throw_if_initialized();
ek_parameters.T = T;

return 0;
}

int ek_set_density(int species, float density) {
void ek_set_density(int species, float density) {
ek_init_species(species);

ek_parameters.density[ek_parameters.species_index[species]] = density;

return 0;
}

int ek_set_D(int species, float D) {

void ek_set_D(int species, float D) {
ek_init_species(species);

ek_parameters.D[ek_parameters.species_index[species]] = D;
ek_parameters.d[ek_parameters.species_index[species]] =
D / (1.0f + 2.0f * sqrt(2.0f));

return 0;
}

int ek_set_valency(int species, float valency) {

void ek_set_valency(int species, float valency) {
ek_init_species(species);

ek_parameters.valency[ek_parameters.species_index[species]] = valency;

return 0;
}

int ek_set_ext_force_density(int species, float ext_force_density_x,
float ext_force_density_y,
float ext_force_density_z) {

void ek_set_ext_force_density(int species, float ext_force_density_x,
float ext_force_density_y,
float ext_force_density_z) {
ek_init_species(species);

ek_parameters.ext_force_density[0][ek_parameters.species_index[species]] =
ext_force_density_x;
ek_parameters.ext_force_density[1][ek_parameters.species_index[species]] =
ext_force_density_y;
ek_parameters.ext_force_density[2][ek_parameters.species_index[species]] =
ext_force_density_z;

return 0;
}

struct ek_charge_of_particle {
Expand Down
40 changes: 20 additions & 20 deletions src/python/espressomd/electrokinetics.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -136,31 +136,31 @@ IF ELECTROKINETICS and CUDA:
int ek_lb_print_vtk_density(char * filename)
int ek_lb_print_vtk_velocity(char * filename)
int ek_init()
int ek_set_agrid(float agrid) except +
int ek_set_lb_density(float lb_density) except +
int ek_set_viscosity(float viscosity) except +
int ek_set_friction(float friction) except +
int ek_set_lb_ext_force_density(float lb_ext_force_dens_x, float lb_ext_force_dens_y, float lb_ext_force_dens_z) except +
int ek_set_T(float T) except +
int ek_set_prefactor(float prefactor) except +
int ek_set_bulk_viscosity(float bulk_viscosity) except +
int ek_set_gamma_odd(float gamma_odd) except +
int ek_set_gamma_even(float gamma_even) except +
int ek_set_density(int species, float density)
int ek_set_D(int species, float D)
int ek_set_valency(int species, float valency)
int ek_set_ext_force_density(int species, float ext_force_density_x, float ext_force_density_y, float ext_force_density_z)
int ek_set_stencil(int stencil) except +
int ek_set_advection(bool advection) except +
int ek_set_fluctuations(bool fluctuations) except +
int ek_set_fluctuation_amplitude(float fluctuation_amplitude) except +
int ek_set_fluidcoupling(bool ideal_contribution) except +
void ek_set_agrid(float agrid) except +
void ek_set_lb_density(float lb_density) except +
void ek_set_viscosity(float viscosity) except +
void ek_set_friction(float friction) except +
void ek_set_lb_ext_force_density(float lb_ext_force_dens_x, float lb_ext_force_dens_y, float lb_ext_force_dens_z) except +
void ek_set_T(float T) except +
void ek_set_prefactor(float prefactor) except +
void ek_set_bulk_viscosity(float bulk_viscosity) except +
void ek_set_gamma_odd(float gamma_odd) except +
void ek_set_gamma_even(float gamma_even) except +
void ek_set_density(int species, float density)
void ek_set_D(int species, float D)
void ek_set_valency(int species, float valency)
void ek_set_ext_force_density(int species, float ext_force_density_x, float ext_force_density_y, float ext_force_density_z)
void ek_set_stencil(int stencil) except +
void ek_set_advection(bool advection) except +
void ek_set_fluctuations(bool fluctuations) except +
void ek_set_fluctuation_amplitude(float fluctuation_amplitude) except +
void ek_set_fluidcoupling(bool ideal_contribution) except +
int ek_node_get_density(int species, int x, int y, int z, double * density)
int ek_node_get_flux(int species, int x, int y, int z, double * flux)
int ek_node_get_potential(int x, int y, int z, double * potential)
int ek_node_set_density(int species, int x, int y, int z, double density)
float ek_calculate_net_charge()
int ek_neutralize_system(int species)

int ek_set_electrostatics_coupling(bool electrostatics_coupling)
void ek_set_electrostatics_coupling(bool electrostatics_coupling)
int ek_print_vtk_particle_potential(char * filename)

0 comments on commit 05c2812

Please sign in to comment.