ESPResSo 3.2.0-11-g9950804-git
Extensible Simulation Package for Soft Matter Research
initialize.c
Go to the documentation of this file.
00001 /*
00002   Copyright (C) 2010,2011,2012,2013 The ESPResSo project
00003   Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010 
00004     Max-Planck-Institute for Polymer Research, Theory Group
00005   
00006   This file is part of ESPResSo.
00007   
00008   ESPResSo is free software: you can redistribute it and/or modify
00009   it under the terms of the GNU General Public License as published by
00010   the Free Software Foundation, either version 3 of the License, or
00011   (at your option) any later version.
00012   
00013   ESPResSo is distributed in the hope that it will be useful,
00014   but WITHOUT ANY WARRANTY; without even the implied warranty of
00015   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016   GNU General Public License for more details.
00017   
00018   You should have received a copy of the GNU General Public License
00019   along with this program.  If not, see <http://www.gnu.org/licenses/>. 
00020 */
00021 /** \file initialize.c
00022     Implementation of \ref initialize.h "initialize.h"
00023 */
00024 #include "utils.h"
00025 #include "initialize.h"
00026 #include "global.h"
00027 #include "particle_data.h"
00028 #include "interaction_data.h"
00029 #include "reaction.h"
00030 #include "statistics.h"
00031 #include "energy.h"
00032 #include "pressure.h"
00033 #include "polymer.h"
00034 #include "imd.h"
00035 #include "random.h"
00036 #include "communication.h"
00037 #include "cells.h"
00038 #include "grid.h"
00039 #include "thermostat.h"
00040 #include "rotation.h"
00041 #include "p3m.h"
00042 #include "p3m-dipolar.h"
00043 #include "mmm1d.h"
00044 #include "mmm2d.h"
00045 #include "maggs.h"
00046 #include "elc.h"
00047 #include "lb.h"
00048 #include "ghosts.h"
00049 #include "debye_hueckel.h"
00050 #include "reaction_field.h"
00051 #include "forces.h"
00052 #include "nsquare.h"
00053 #include "nemd.h"
00054 #include "domain_decomposition.h"
00055 #include "errorhandling.h"
00056 #include "rattle.h"
00057 #include "lattice.h"
00058 #include "iccp3m.h" /* -iccp3m- */
00059 #include "adresso.h"
00060 #include "metadynamics.h"
00061 #include "statistics_observable.h"
00062 #include "statistics_correlation.h"
00063 #include "lb-boundaries.h"
00064 #include "ghmc.h"
00065 #include "domain_decomposition.h"
00066 
00067 /** whether the thermostat has to be reinitialized before integration */
00068 static int reinit_thermo = 1;
00069 static int reinit_electrostatics = 0;
00070 static int reinit_magnetostatics = 0;
00071 #ifdef LB_GPU
00072 static int lb_reinit_particles_gpu = 1;
00073 #endif
00074 
00075 void on_program_start()
00076 {
00077   EVENT_TRACE(fprintf(stderr, "%d: on_program_start\n", this_node));
00078 
00079   /* tell Electric fence that we do realloc(0) on purpose. */
00080 #ifdef EFENCE
00081   extern int EF_ALLOW_MALLOC_0;
00082   EF_ALLOW_MALLOC_0 = 1;
00083 #endif
00084 
00085   register_sigint_handler();
00086 
00087   if (this_node == 0) {
00088     /* master node */
00089 #ifdef FORCE_CORE
00090     /* core should be the last exit handler (process dies) */
00091     atexit(core);
00092 #endif
00093     atexit(mpi_stop);
00094   }
00095 
00096   /*
00097     call the initialization of the modules here
00098   */
00099   init_random();
00100   init_bit_random();
00101 
00102   init_node_grid();
00103   /* calculate initial minimimal number of cells (see tclcallback_min_num_cells) */
00104   min_num_cells = calc_processor_min_num_cells();
00105 
00106   /* initially go for domain decomposition */
00107   dd_topology_init(&local_cells);
00108 
00109   ghost_init();
00110   /* Initialise force and energy tables */
00111   force_and_energy_tables_init();
00112 #ifdef ADRESS
00113 #ifdef INTERFACE_CORRECTION
00114   adress_force_and_energy_tables_init();
00115 #endif
00116   /* #ifdef THERMODYNAMIC_FORCE */
00117   tf_tables_init();
00118   /* #endif */
00119 #endif
00120 #ifdef P3M
00121   p3m_pre_init();
00122 #endif
00123 #ifdef DP3M
00124   dp3m_pre_init();
00125 #endif
00126 
00127 #ifdef LB_GPU
00128   if(this_node == 0){
00129     //lb_pre_init_gpu();
00130   }
00131 #endif
00132 #ifdef LB
00133   lb_pre_init();
00134 #endif
00135 
00136 #ifdef CATALYTIC_REACTIONS
00137   reaction.eq_rate=0.0;
00138   reaction.sing_mult=0;
00139 #endif
00140 
00141   /*
00142     call all initializations to do only on the master node here.
00143   */
00144   if (this_node == 0) {
00145     /* interaction_data.c: make sure 0<->0 ia always exists */
00146     make_particle_type_exist(0);
00147   }
00148 }
00149 
00150 
00151 void on_integration_start()
00152 {
00153   char *errtext;
00154 
00155   EVENT_TRACE(fprintf(stderr, "%d: on_integration_start\n", this_node));
00156   INTEG_TRACE(fprintf(stderr,"%d: on_integration_start: reinit_thermo = %d, resort_particles=%d\n",
00157                       this_node,reinit_thermo,resort_particles));
00158 
00159   /********************************************/
00160   /* sanity checks                            */
00161   /********************************************/
00162 
00163   if ( time_step < 0.0 ) {
00164     errtext = runtime_error(128);
00165     ERROR_SPRINTF(errtext, "{010 time_step not set} ");
00166   }
00167   if ( skin < 0.0 ) {
00168     errtext = runtime_error(128);
00169     ERROR_SPRINTF(errtext,"{011 skin not set} ");
00170   }
00171   if ( temperature < 0.0 ) {
00172     errtext = runtime_error(128);
00173     ERROR_SPRINTF(errtext,"{012 thermostat not initialized} ");
00174   }
00175   
00176 #ifdef NPT
00177   if (integ_switch == INTEG_METHOD_NPT_ISO) {
00178     if (nptiso.piston <= 0.0) {
00179       char *errtext = runtime_error(128);
00180       ERROR_SPRINTF(errtext,"{014 npt on, but piston mass not set} ");
00181     }
00182   
00183 #ifdef ELECTROSTATICS
00184 
00185     switch(coulomb.method) {
00186     case COULOMB_NONE:  break;
00187 #ifdef P3M
00188     case COULOMB_P3M:   break;
00189 #endif /*P3M*/
00190     default: {
00191       char *errtext = runtime_error(128);
00192       ERROR_SPRINTF(errtext,"{014 npt only works with P3M} ");
00193     }
00194     }
00195 #endif /*ELECTROSTATICS*/
00196 
00197 #ifdef DIPOLES
00198 
00199     switch (coulomb.Dmethod) {
00200     case DIPOLAR_NONE: break;
00201 #ifdef DP3M
00202     case DIPOLAR_P3M: break;
00203 #endif
00204     default: {
00205       char *errtext = runtime_error(128);
00206       ERROR_SPRINTF(errtext,"NpT does not work with your dipolar method, please use P3M.");
00207     }
00208     }
00209 #endif  /* ifdef DIPOLES */
00210   }
00211 #endif /*NPT*/
00212 
00213   if (!check_obs_calc_initialized()) return;
00214 
00215 #ifdef LB
00216   if(lattice_switch & LATTICE_LB) {
00217     if (lbpar.agrid <= 0.0) {
00218       errtext = runtime_error(128);
00219       ERROR_SPRINTF(errtext,"{098 Lattice Boltzmann agrid not set} ");
00220     }
00221     if (lbpar.tau <= 0.0) {
00222       errtext = runtime_error(128);
00223       ERROR_SPRINTF(errtext,"{099 Lattice Boltzmann time step not set} ");
00224     }
00225     if (lbpar.rho <= 0.0) {
00226       errtext = runtime_error(128);
00227       ERROR_SPRINTF(errtext,"{100 Lattice Boltzmann fluid density not set} ");
00228     }
00229     if (lbpar.viscosity <= 0.0) {
00230       errtext = runtime_error(128);
00231       ERROR_SPRINTF(errtext,"{101 Lattice Boltzmann fluid viscosity not set} ");
00232     }
00233     if (dd.use_vList && skin>=lbpar.agrid/2.0) {
00234       errtext = runtime_error(128);
00235       ERROR_SPRINTF(errtext, "{104 LB requires either no Verlet lists or that the skin of the verlet list to be less than half of lattice-Boltzmann grid spacing.} ");
00236     }
00237   }
00238 #endif
00239 #ifdef LB_GPU
00240 if(this_node == 0){
00241   if(lattice_switch & LATTICE_LB_GPU) {
00242     if (lbpar_gpu.agrid < 0.0) {
00243       errtext = runtime_error(128);
00244       ERROR_SPRINTF(errtext,"{098 Lattice Boltzmann agrid not set} ");
00245     }
00246     if (lbpar_gpu.tau < 0.0) {
00247       errtext = runtime_error(128);
00248       ERROR_SPRINTF(errtext,"{099 Lattice Boltzmann time step not set} ");
00249     }
00250     if (lbpar_gpu.rho < 0.0) {
00251       errtext = runtime_error(128);
00252       ERROR_SPRINTF(errtext,"{100 Lattice Boltzmann fluid density not set} ");
00253     }
00254     if (lbpar_gpu.viscosity < 0.0) {
00255       errtext = runtime_error(128);
00256       ERROR_SPRINTF(errtext,"{101 Lattice Boltzmann fluid viscosity not set} ");
00257     }
00258     if (lb_reinit_particles_gpu) {
00259         lb_realloc_particles_gpu();
00260         lb_reinit_particles_gpu = 0;
00261     }
00262   }
00263 }
00264 
00265 #endif
00266 
00267 #ifdef METADYNAMICS
00268   meta_init();
00269 #endif
00270 
00271 #ifdef CATALYTIC_REACTIONS
00272 if(reaction.ct_rate != 0.0) {
00273 
00274    if( dd.use_vList == 0 || cell_structure.type != CELL_STRUCTURE_DOMDEC) {
00275       errtext = runtime_error(128);
00276       ERROR_SPRINTF(errtext,"{105 The CATALYTIC_REACTIONS feature requires verlet lists and domain decomposition} ");
00277       check_runtime_errors();
00278     }
00279 
00280   if(max_cut < reaction.range) {
00281     errtext = runtime_error(128);
00282     ERROR_SPRINTF(errtext,"{106 Reaction range of %f exceeds maximum cutoff of %f} ", reaction.range, max_cut);
00283   }
00284 }
00285 #endif
00286 
00287   /********************************************/
00288   /* end sanity checks                        */
00289   /********************************************/
00290 
00291 
00292   /* Prepare the thermostat */
00293   if (reinit_thermo) {
00294     thermo_init();
00295     reinit_thermo = 0;
00296     recalc_forces = 1;
00297   }
00298 
00299   /* Ensemble preparation: NVT or NPT */
00300   integrate_ensemble_init();
00301 
00302   /* Update particle and observable information for routines in statistics.c */
00303   invalidate_obs();
00304   freePartCfg();
00305 
00306   on_observable_calc();
00307 }
00308 
00309 void on_observable_calc()
00310 {
00311   EVENT_TRACE(fprintf(stderr, "%d: on_observable_calc\n", this_node));
00312   /* Prepare particle structure: Communication step: number of ghosts and ghost information */
00313 
00314   if(resort_particles)
00315     cells_resort_particles(CELL_GLOBAL_EXCHANGE);
00316 
00317 #ifdef ELECTROSTATICS  
00318   if(reinit_electrostatics) {
00319     EVENT_TRACE(fprintf(stderr, "%d: reinit_electrostatics\n", this_node));
00320     switch (coulomb.method) {
00321 #ifdef P3M
00322     case COULOMB_ELC_P3M:
00323     case COULOMB_P3M:
00324       p3m_count_charged_particles();
00325       break;
00326 #endif
00327     case COULOMB_MAGGS: 
00328       maggs_init(); 
00329       break;
00330     default: break;
00331     }
00332     reinit_electrostatics = 0;
00333   }
00334 #endif /*ifdef ELECTROSTATICS */
00335 
00336 #ifdef DIPOLES
00337   if(reinit_magnetostatics) {
00338     EVENT_TRACE(fprintf(stderr, "%d: reinit_magnetostatics\n", this_node));
00339     switch (coulomb.Dmethod) {
00340 #ifdef DP3M
00341     case DIPOLAR_MDLC_P3M:
00342       // fall through
00343     case DIPOLAR_P3M:
00344       dp3m_count_magnetic_particles();
00345       break;
00346 #endif
00347     default: break;
00348     }
00349     reinit_magnetostatics = 0;
00350   }
00351 #endif /*ifdef ELECTROSTATICS */
00352 }
00353 
00354 void on_particle_change()
00355 {
00356   EVENT_TRACE(fprintf(stderr, "%d: on_particle_change\n", this_node));
00357   resort_particles = 1;
00358   reinit_electrostatics = 1;
00359   reinit_magnetostatics = 1;
00360 
00361 #ifdef LB_GPU
00362   lb_reinit_particles_gpu = 1;
00363 #endif
00364 
00365   invalidate_obs();
00366 
00367   /* the particle information is no longer valid */
00368   freePartCfg();
00369 }
00370 
00371 void on_coulomb_change()
00372 {
00373   EVENT_TRACE(fprintf(stderr, "%d: on_coulomb_change\n", this_node));
00374   invalidate_obs();
00375 
00376   recalc_coulomb_prefactor();
00377 
00378 #ifdef ELECTROSTATICS
00379   switch (coulomb.method) {
00380   case COULOMB_DH:
00381     break;    
00382 #ifdef P3M
00383   case COULOMB_ELC_P3M:
00384     ELC_init();
00385     // fall through
00386   case COULOMB_P3M:
00387     p3m_init();
00388     break;
00389 #endif
00390   case COULOMB_MMM1D:
00391     MMM1D_init();
00392     break;
00393   case COULOMB_MMM2D:
00394     MMM2D_init();
00395     break;
00396   case COULOMB_MAGGS: 
00397     maggs_init();
00398     /* Maggs electrostatics needs ghost velocities */
00399     on_ghost_flags_change();
00400     break;
00401   default: break;
00402   }
00403 #endif  /* ifdef ELECTROSTATICS */
00404 
00405 #ifdef DIPOLES
00406   switch (coulomb.Dmethod) {
00407 #ifdef DP3M
00408   case DIPOLAR_MDLC_P3M:
00409     // fall through
00410   case DIPOLAR_P3M:
00411     dp3m_init();
00412     break;
00413 #endif
00414   default: break;
00415   }
00416 #endif  /* ifdef DIPOLES */
00417 
00418   /* all Coulomb methods have a short range part, aka near field
00419      correction. Even in case of switching off, we should call this,
00420      since the required cutoff might have reduced. */
00421   on_short_range_ia_change();
00422 
00423   recalc_forces = 1;
00424 }
00425 
00426 void on_short_range_ia_change()
00427 {
00428   EVENT_TRACE(fprintf(stderr, "%d: on_short_range_ia_changes\n", this_node));
00429   invalidate_obs();
00430 
00431   recalc_maximal_cutoff();
00432   cells_on_geometry_change(0);
00433 
00434   recalc_forces = 1;
00435 }
00436 
00437 void on_constraint_change()
00438 {
00439   EVENT_TRACE(fprintf(stderr, "%d: on_constraint_change\n", this_node));
00440   invalidate_obs();
00441   recalc_forces = 1;
00442 }
00443 
00444 void on_lbboundary_change()
00445 {
00446   EVENT_TRACE(fprintf(stderr, "%d: on_lbboundary_change\n", this_node));
00447   invalidate_obs();
00448 
00449 #ifdef LB_BOUNDARIES
00450   if(lattice_switch & LATTICE_LB) {
00451     lb_init_boundaries();
00452   }
00453 #endif
00454 
00455 #ifdef LB_BOUNDARIES_GPU
00456   if(this_node == 0){
00457     if(lattice_switch & LATTICE_LB_GPU) {
00458       lb_init_boundaries();
00459     }
00460   }
00461 #endif
00462 
00463   recalc_forces = 1;
00464 }
00465 
00466 void on_resort_particles()
00467 {
00468   EVENT_TRACE(fprintf(stderr, "%d: on_resort_particles\n", this_node));
00469 #ifdef ELECTROSTATICS
00470   switch (coulomb.method) {
00471 #ifdef P3M
00472   case COULOMB_ELC_P3M:
00473     ELC_on_resort_particles();
00474     break;
00475 #endif
00476   case COULOMB_MMM2D:
00477     MMM2D_on_resort_particles();
00478     break;
00479   default: break;
00480   }
00481 #endif /* ifdef ELECTROSTATICS */
00482   
00483   /* DIPOLAR interactions so far don't need this */
00484 
00485   recalc_forces = 1;
00486 }
00487 
00488 void on_boxl_change() {
00489   EVENT_TRACE(fprintf(stderr, "%d: on_boxl_change\n", this_node));
00490 
00491   /* Now give methods a chance to react to the change in box length */
00492 #ifdef ELECTROSTATICS
00493   switch(coulomb.method) {
00494 #ifdef P3M
00495   case COULOMB_ELC_P3M:
00496     ELC_init();
00497     // fall through
00498   case COULOMB_P3M:
00499     p3m_scaleby_box_l();
00500     break;
00501 #endif
00502   case COULOMB_MMM1D:
00503     MMM1D_init();
00504     break;
00505   case COULOMB_MMM2D:
00506     MMM2D_init();
00507     break;
00508   case COULOMB_MAGGS: 
00509     maggs_init();
00510     break;
00511   }
00512 #endif
00513 
00514 #ifdef DIPOLES
00515   switch(coulomb.Dmethod) {
00516 #ifdef DP3M
00517   case DIPOLAR_MDLC_P3M:
00518     // fall through
00519   case DIPOLAR_P3M:
00520     dp3m_scaleby_box_l();
00521     break;
00522 #endif
00523   }
00524 #endif
00525 
00526 #ifdef LB
00527   if(lattice_switch & LATTICE_LB) {
00528     lb_init();
00529 #ifdef LB_BOUNDARIES
00530     lb_init_boundaries();
00531 #endif
00532   }
00533 #endif
00534 }
00535 
00536 void on_cell_structure_change()
00537 {
00538   EVENT_TRACE(fprintf(stderr, "%d: on_cell_structure_change\n", this_node));
00539 
00540   /* Now give methods a chance to react to the change in cell
00541      structure.  Most ES methods need to reinitialize, as they depend
00542      on skin, node grid and so on. Only for a change in box length we
00543      have separate, faster methods, as this might happend frequently
00544      in a NpT simulation. */
00545 #ifdef ELECTROSTATICS
00546   switch (coulomb.method) {
00547   case COULOMB_DH:
00548     break;    
00549 #ifdef P3M
00550   case COULOMB_ELC_P3M:
00551     ELC_init();
00552     // fall through
00553   case COULOMB_P3M:
00554     p3m_init();
00555     break;
00556 #endif
00557   case COULOMB_MMM1D:
00558     MMM1D_init();
00559     break;
00560   case COULOMB_MMM2D:
00561     MMM2D_init();
00562     break;
00563   case COULOMB_MAGGS: 
00564     maggs_init();
00565     /* Maggs electrostatics needs ghost velocities */
00566     on_ghost_flags_change();
00567     break;
00568   default: break;
00569   }
00570 #endif  /* ifdef ELECTROSTATICS */
00571 
00572 #ifdef DIPOLES
00573   switch (coulomb.Dmethod) {
00574 #ifdef DP3M
00575   case DIPOLAR_MDLC_P3M:
00576     // fall through
00577   case DIPOLAR_P3M:
00578     dp3m_init();
00579     break;
00580 #endif
00581   default: break;
00582   }
00583 #endif  /* ifdef DIPOLES */
00584 
00585 #ifdef LB
00586   if(lattice_switch & LATTICE_LB) {
00587     lb_init();
00588   }
00589 #endif
00590 }
00591 
00592 void on_temperature_change()
00593 {
00594   EVENT_TRACE(fprintf(stderr, "%d: on_temperature_change\n", this_node));
00595 
00596 #ifdef ELECTROSTATICS
00597 
00598 #endif
00599 #ifdef LB
00600   if (lattice_switch & LATTICE_LB) {
00601     lb_reinit_parameters();
00602   }
00603 #endif
00604 #ifdef LB_GPU
00605   if(this_node == 0) {
00606     if (lattice_switch & LATTICE_LB_GPU) {
00607       lb_reinit_parameters_gpu();
00608     }
00609   }
00610 #endif
00611 }
00612 
00613 void on_parameter_change(int field)
00614 {
00615   EVENT_TRACE(fprintf(stderr, "%d: on_parameter_change %s\n", this_node, fields[field].name));
00616 
00617   switch (field) {
00618   case FIELD_BOXL:
00619     grid_changed_box_l();
00620     /* Electrostatics cutoffs mostly depend on the system size,
00621        therefore recalculate them. */
00622     recalc_maximal_cutoff();
00623     cells_on_geometry_change(0);
00624     break;
00625   case FIELD_MIN_GLOBAL_CUT:
00626     recalc_maximal_cutoff();
00627     cells_on_geometry_change(0);
00628     break;
00629   case FIELD_SKIN:
00630     cells_on_geometry_change(0);
00631   case FIELD_PERIODIC:
00632     cells_on_geometry_change(CELL_FLAG_GRIDCHANGED);
00633     break;
00634   case FIELD_NODEGRID:
00635     grid_changed_n_nodes();
00636     cells_on_geometry_change(CELL_FLAG_GRIDCHANGED);
00637     break;
00638   case FIELD_MINNUMCELLS:
00639   case FIELD_MAXNUMCELLS:
00640     cells_re_init(CELL_STRUCTURE_CURRENT);
00641   case FIELD_TEMPERATURE:
00642     on_temperature_change();
00643     reinit_thermo = 1;
00644     break;
00645   case FIELD_TIMESTEP:
00646 #ifdef LB_GPU
00647     if(this_node == 0) {
00648       if (lattice_switch & LATTICE_LB_GPU) {
00649         lb_reinit_parameters_gpu();
00650       }
00651     }  
00652 #endif    
00653 #ifdef LB
00654     if (lattice_switch & LATTICE_LB) {
00655       lb_reinit_parameters();
00656     }
00657 #endif
00658   case FIELD_LANGEVIN_GAMMA:
00659   case FIELD_DPD_GAMMA:
00660   case FIELD_DPD_TGAMMA:
00661     reinit_thermo = 1;
00662     break;
00663   case FIELD_DPD_RCUT:
00664   case FIELD_DPD_TRCUT:
00665     recalc_maximal_cutoff();
00666     cells_on_geometry_change(0);
00667     reinit_thermo = 1;
00668     break;
00669   case FIELD_NPTISO_G0:
00670   case FIELD_NPTISO_GV:
00671   case FIELD_NPTISO_PISTON:
00672     reinit_thermo = 1;
00673     break;
00674 #ifdef NPT
00675   case FIELD_INTEG_SWITCH:
00676     if (integ_switch != INTEG_METHOD_NPT_ISO)
00677       nptiso.invalidate_p_vel = 1;
00678     break;
00679 #endif
00680   case FIELD_THERMO_SWITCH:
00681     /* DPD needs ghost velocities, other thermostats not */
00682     on_ghost_flags_change();
00683     break;
00684 #ifdef LB
00685   case FIELD_LATTICE_SWITCH:
00686     /* LB needs ghost velocities */
00687     on_ghost_flags_change();
00688     break;
00689 #endif
00690   }
00691 }
00692 
00693 #ifdef LB
00694 void on_lb_params_change(int field) {
00695   EVENT_TRACE(fprintf(stderr, "%d: on_lb_params_change\n", this_node));
00696 
00697   if (field == LBPAR_AGRID) {
00698     lb_init();
00699   }
00700   if (field == LBPAR_DENSITY) {
00701     lb_reinit_fluid();
00702   }
00703 
00704   lb_reinit_parameters();
00705 
00706 }
00707 #endif
00708 
00709 #if defined (LB) || defined (LB_GPU)
00710 void on_lb_params_change_gpu(int field) {
00711   EVENT_TRACE(fprintf(stderr, "%d: on_lb_params_change_gpu\n", this_node));
00712 
00713 #ifdef LB_GPU
00714   if (field == LBPAR_AGRID) {
00715     lb_init_gpu();
00716 #ifdef LB_BOUNDARIES_GPU
00717     lb_init_boundaries();
00718 #endif
00719   }
00720   if (field == LBPAR_DENSITY) {
00721     lb_reinit_fluid_gpu();
00722   }
00723 
00724   lb_reinit_parameters_gpu();
00725 #endif
00726 }
00727 #endif
00728 
00729 void on_ghost_flags_change()
00730 {
00731   EVENT_TRACE(fprintf(stderr, "%d: on_ghost_flags_change\n", this_node));
00732   /* that's all we change here */
00733   extern int ghosts_have_v;
00734 
00735   int old_have_v = ghosts_have_v;
00736 
00737   ghosts_have_v = 0;
00738   
00739   /* DPD and LB need also ghost velocities */
00740   if (thermo_switch & THERMO_DPD)
00741     ghosts_have_v = 1;
00742 #ifdef LB
00743   if (lattice_switch & LATTICE_LB)
00744     ghosts_have_v = 1;
00745 #endif
00746 #ifdef BOND_CONSTRAINT
00747   else if (n_rigidbonds)
00748     ghosts_have_v = 1;
00749 #endif
00750 #ifdef ELECTROSTATICS
00751   /* Maggs electrostatics needs ghost velocities too */
00752   else if(coulomb.method == COULOMB_MAGGS)
00753       ghosts_have_v = 1;
00754 #endif
00755 #ifdef INTER_DPD
00756   //maybe we have to add a new global to differ between compile in and acctual use.
00757   ghosts_have_v = 1;
00758 #endif
00759 #ifdef VIRTUAL_SITES 
00760   //VIRUTAL_SITES need v to update v of virtual sites
00761   ghosts_have_v = 1;
00762 #endif
00763 
00764   if (old_have_v != ghosts_have_v)
00765     cells_re_init(CELL_STRUCTURE_CURRENT);    
00766 }
00767