From 200b4f13c720e83731c0108d011dbc7ad0edd7dd Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 10 Apr 2022 18:18:06 -0400 Subject: [PATCH] use dynamic cast instead of c-style cast when casting from base type to derived class --- src/ASPHERE/compute_erotate_asphere.cpp | 6 +- src/ASPHERE/compute_temp_asphere.cpp | 2 +- src/ASPHERE/fix_nh_asphere.cpp | 2 +- src/ASPHERE/fix_nve_asphere.cpp | 2 +- src/ASPHERE/fix_nve_asphere_noforce.cpp | 2 +- src/ASPHERE/fix_nve_line.cpp | 2 +- src/ASPHERE/fix_nve_tri.cpp | 2 +- src/ASPHERE/pair_gayberne.cpp | 2 +- src/ASPHERE/pair_line_lj.cpp | 2 +- src/ASPHERE/pair_resquared.cpp | 2 +- src/ASPHERE/pair_tri_lj.cpp | 2 +- src/AWPMD/fix_nve_awpmd.cpp | 4 +- src/BOCS/fix_bocs.cpp | 14 ++--- src/BODY/compute_body_local.cpp | 2 +- src/BODY/compute_temp_body.cpp | 2 +- src/BODY/fix_nh_body.cpp | 2 +- src/BODY/fix_nve_body.cpp | 2 +- src/BODY/fix_wall_body_polygon.cpp | 4 +- src/BODY/fix_wall_body_polyhedron.cpp | 4 +- src/BODY/pair_body_nparticle.cpp | 4 +- src/BODY/pair_body_rounded_polygon.cpp | 4 +- src/BODY/pair_body_rounded_polyhedron.cpp | 4 +- src/BROWNIAN/fix_brownian_asphere.cpp | 2 +- src/BROWNIAN/fix_propel_self.cpp | 2 +- src/CG-DNA/fix_nve_dot.cpp | 2 +- src/CG-DNA/fix_nve_dotc_langevin.cpp | 2 +- src/CG-DNA/pair_oxdna_excv.cpp | 2 +- src/CLASS2/pair_lj_class2.cpp | 6 +- src/CLASS2/pair_lj_class2_coul_long.cpp | 6 +- src/COLLOID/pair_brownian.cpp | 2 +- src/COLLOID/pair_brownian_poly.cpp | 2 +- src/COLLOID/pair_lubricate.cpp | 4 +- src/COLLOID/pair_lubricateU.cpp | 2 +- src/COLLOID/pair_lubricateU_poly.cpp | 2 +- src/COLLOID/pair_lubricate_poly.cpp | 10 ++-- src/CORESHELL/compute_temp_cs.cpp | 2 +- src/DIELECTRIC/compute_efield_atom.cpp | 18 +++--- src/DIELECTRIC/fix_polarize_bem_gmres.cpp | 22 +++---- src/DIELECTRIC/fix_polarize_bem_icc.cpp | 20 +++---- src/DIELECTRIC/fix_polarize_functional.cpp | 20 +++---- src/DIELECTRIC/msm_dielectric.cpp | 2 +- src/DIELECTRIC/pair_coul_cut_dielectric.cpp | 2 +- src/DIELECTRIC/pair_coul_long_dielectric.cpp | 2 +- .../pair_lj_cut_coul_cut_dielectric.cpp | 2 +- .../pair_lj_cut_coul_debye_dielectric.cpp | 2 +- .../pair_lj_cut_coul_long_dielectric.cpp | 2 +- .../pair_lj_cut_coul_msm_dielectric.cpp | 2 +- .../pair_lj_long_coul_long_dielectric.cpp | 2 +- src/DIELECTRIC/pppm_dielectric.cpp | 2 +- src/DIELECTRIC/pppm_disp_dielectric.cpp | 2 +- src/DIFFRACTION/fix_saed_vtk.cpp | 2 +- src/DPD-REACT/fix_dpd_energy.cpp | 4 +- src/DPD-REACT/fix_rx.cpp | 8 +-- src/DPD-REACT/fix_shardlow.cpp | 8 +-- src/DRUDE/compute_temp_drude.cpp | 2 +- src/DRUDE/fix_langevin_drude.cpp | 2 +- src/DRUDE/fix_tgnh_drude.cpp | 8 +-- src/DRUDE/pair_coul_tt.cpp | 2 +- src/DRUDE/pair_lj_cut_thole_long.cpp | 2 +- src/DRUDE/pair_thole.cpp | 2 +- src/EFF/compute_temp_deform_eff.cpp | 2 +- src/EFF/fix_nve_eff.cpp | 2 +- src/EFF/fix_nvt_sllod_eff.cpp | 2 +- src/EXTRA-COMPUTE/compute_hma.cpp | 4 +- src/EXTRA-FIX/fix_addtorque.cpp | 6 +- src/EXTRA-FIX/fix_drag.cpp | 6 +- src/EXTRA-FIX/fix_electron_stopping_fit.cpp | 4 +- src/EXTRA-FIX/fix_ffl.cpp | 8 +-- src/EXTRA-FIX/fix_filter_corotate.cpp | 6 +- src/EXTRA-FIX/fix_flow_gauss.cpp | 6 +- src/EXTRA-FIX/fix_gld.cpp | 2 +- src/EXTRA-FIX/fix_gle.cpp | 8 +-- src/EXTRA-FIX/fix_momentum_chunk.cpp | 4 +- src/EXTRA-FIX/fix_npt_cauchy.cpp | 8 +-- src/EXTRA-FIX/fix_numdiff.cpp | 6 +- src/EXTRA-FIX/fix_numdiff_virial.cpp | 6 +- src/EXTRA-FIX/fix_nvk.cpp | 2 +- src/EXTRA-FIX/fix_pafi.cpp | 8 +-- src/EXTRA-FIX/fix_rhok.cpp | 6 +- src/EXTRA-FIX/fix_smd.cpp | 12 ++-- src/EXTRA-FIX/fix_spring_rg.cpp | 6 +- src/EXTRA-FIX/fix_ti_spring.cpp | 6 +- src/EXTRA-FIX/fix_tmd.cpp | 2 +- src/EXTRA-FIX/fix_ttm.cpp | 6 +- src/EXTRA-FIX/fix_ttm_mod.cpp | 6 +- src/EXTRA-FIX/fix_viscous_sphere.cpp | 6 +- src/EXTRA-FIX/fix_wall_ees.cpp | 4 +- src/EXTRA-FIX/fix_wall_region_ees.cpp | 8 +-- src/EXTRA-PAIR/pair_lj96_cut.cpp | 6 +- src/EXTRA-PAIR/pair_lj_expand_coul_long.cpp | 6 +- src/EXTRA-PAIR/pair_mie_cut.cpp | 6 +- src/FEP/compute_fep.cpp | 2 +- src/FEP/fix_adapt_fep.cpp | 12 ++-- src/FEP/pair_lj_charmm_coul_long_soft.cpp | 6 +- src/FEP/pair_lj_cut_coul_long_soft.cpp | 6 +- src/FEP/pair_lj_cut_soft.cpp | 6 +- src/GPU/fix_gpu.cpp | 8 +-- src/GPU/fix_nve_asphere_gpu.cpp | 2 +- src/GPU/pair_gayberne_gpu.cpp | 2 +- src/GPU/pair_resquared_gpu.cpp | 2 +- src/GRANULAR/fix_damping_cundall.cpp | 6 +- src/GRANULAR/fix_freeze.cpp | 6 +- src/GRANULAR/fix_pour.cpp | 28 ++++----- src/GRANULAR/fix_wall_gran.cpp | 6 +- src/GRANULAR/pair_gran_hooke_history.cpp | 10 ++-- src/GRANULAR/pair_granular.cpp | 8 +-- src/INTEL/fix_intel.cpp | 2 +- src/INTEL/fix_nve_asphere_intel.cpp | 2 +- src/INTEL/fix_nvt_sllod_intel.cpp | 2 +- src/INTEL/verlet_lrt_intel.cpp | 2 +- src/KIM/kim_init.cpp | 2 +- src/KIM/kim_interactions.cpp | 2 +- src/KIM/kim_query.cpp | 2 +- src/KSPACE/pair_buck_long_coul_long.cpp | 6 +- src/KSPACE/pair_lj_charmm_coul_long.cpp | 6 +- src/KSPACE/pair_lj_charmmfsw_coul_long.cpp | 6 +- src/KSPACE/pair_lj_cut_coul_long.cpp | 6 +- src/KSPACE/pair_lj_long_coul_long.cpp | 6 +- src/MACHDYN/pair_smd_tlsph.cpp | 26 ++++---- src/MANIFOLD/fix_manifoldforce.cpp | 6 +- src/MANYBODY/fix_qeq_comb.cpp | 10 ++-- src/MC/fix_bond_break.cpp | 2 +- src/MC/fix_bond_create.cpp | 2 +- src/MDI/mdi_engine.cpp | 4 +- src/MDI/mdi_plugin.cpp | 2 +- src/MISC/fix_imd.cpp | 2 +- src/MISC/pair_srp.cpp | 2 +- src/MISC/pair_tracker.cpp | 8 +-- src/MOLECULE/dihedral_charmm.cpp | 2 +- src/MOLECULE/dihedral_charmmfsw.cpp | 2 +- src/MOLECULE/fix_cmap.cpp | 6 +- src/OPENMP/fix_nh_asphere_omp.cpp | 2 +- src/OPENMP/fix_nvt_sllod_omp.cpp | 2 +- src/OPENMP/fix_qeq_comb_omp.cpp | 6 +- src/OPENMP/pair_reaxff_omp.cpp | 2 +- src/OPENMP/reaxff_bond_orders_omp.cpp | 2 +- src/ORIENT/fix_orient_bcc.cpp | 6 +- src/ORIENT/fix_orient_eco.cpp | 6 +- src/ORIENT/fix_orient_fcc.cpp | 6 +- src/PERI/compute_damage_atom.cpp | 2 +- src/PERI/compute_plasticity_atom.cpp | 2 +- src/PERI/pair_peri.cpp | 2 +- src/QEQ/fix_qeq.cpp | 2 +- src/QEQ/fix_qeq_fire.cpp | 4 +- src/QTB/fix_qtb.cpp | 6 +- src/REACTION/fix_bond_react.cpp | 2 +- src/REAXFF/compute_spec_atom.cpp | 2 +- src/REAXFF/fix_qeq_reaxff.cpp | 6 +- src/REAXFF/fix_reaxff_bonds.cpp | 2 +- src/REAXFF/fix_reaxff_species.cpp | 4 +- src/REAXFF/pair_reaxff.cpp | 6 +- src/REPLICA/compute_event_displace.cpp | 2 +- src/REPLICA/hyper.cpp | 6 +- src/REPLICA/neb.cpp | 2 +- src/REPLICA/prd.cpp | 2 +- src/REPLICA/tad.cpp | 6 +- src/REPLICA/temper_grem.cpp | 2 +- src/RIGID/compute_erotate_rigid.cpp | 4 +- src/RIGID/compute_ke_rigid.cpp | 4 +- src/RIGID/compute_rigid_local.cpp | 2 +- src/RIGID/fix_ehex.cpp | 2 +- src/RIGID/fix_rigid.cpp | 8 +-- src/RIGID/fix_rigid_nh.cpp | 2 +- src/RIGID/fix_rigid_nh_small.cpp | 2 +- src/RIGID/fix_rigid_small.cpp | 8 +-- src/RIGID/fix_shake.cpp | 8 +-- src/SHOCK/fix_msst.cpp | 2 +- src/SPIN/compute_spin.cpp | 8 +-- src/SPIN/fix_langevin_spin.cpp | 4 +- src/SPIN/fix_nve_spin.cpp | 12 ++-- src/SPIN/fix_precession_spin.cpp | 6 +- src/SPIN/neb_spin.cpp | 2 +- src/SPIN/pair_spin.cpp | 2 +- src/SRD/fix_srd.cpp | 10 ++-- src/UEF/compute_pressure_uef.cpp | 6 +- src/UEF/compute_temp_uef.cpp | 2 +- src/UEF/dump_cfg_uef.cpp | 4 +- src/UEF/fix_nh_uef.cpp | 22 +++---- src/angle_deprecated.cpp | 2 +- src/atom.cpp | 6 +- src/atom_vec_sphere.cpp | 2 +- src/balance.cpp | 6 +- src/bond_deprecated.cpp | 2 +- src/compute_angle.cpp | 4 +- src/compute_angmom_chunk.cpp | 4 +- src/compute_bond.cpp | 4 +- src/compute_chunk_atom.cpp | 4 +- src/compute_chunk_spread_atom.cpp | 2 +- src/compute_com_chunk.cpp | 4 +- src/compute_coord_atom.cpp | 2 +- src/compute_dihedral.cpp | 10 ++-- src/compute_dipole_chunk.cpp | 4 +- src/compute_displace_atom.cpp | 6 +- src/compute_gyration_chunk.cpp | 4 +- src/compute_improper.cpp | 10 ++-- src/compute_inertia_chunk.cpp | 4 +- src/compute_msd.cpp | 6 +- src/compute_msd_chunk.cpp | 10 ++-- src/compute_omega_chunk.cpp | 4 +- src/compute_pressure.cpp | 2 +- src/compute_property_atom.cpp | 60 +++++++++---------- src/compute_property_chunk.cpp | 4 +- src/compute_reduce_chunk.cpp | 4 +- src/compute_temp_chunk.cpp | 4 +- src/compute_temp_deform.cpp | 2 +- src/compute_torque_chunk.cpp | 4 +- src/compute_vacf.cpp | 4 +- src/compute_vcm_chunk.cpp | 4 +- src/delete_atoms.cpp | 10 ++-- src/dihedral_deprecated.cpp | 2 +- src/displace_atoms.cpp | 9 ++- src/domain.cpp | 2 +- src/dump_custom.cpp | 2 +- src/dump_image.cpp | 6 +- src/finish.cpp | 2 +- src/fix_adapt.cpp | 16 ++--- src/fix_addforce.cpp | 6 +- src/fix_ave_chunk.cpp | 6 +- src/fix_aveforce.cpp | 6 +- src/fix_efield.cpp | 6 +- src/fix_enforce2d.cpp | 6 +- src/fix_gravity.cpp | 6 +- src/fix_group.cpp | 2 +- src/fix_indent.cpp | 6 +- src/fix_langevin.cpp | 8 +-- src/fix_lineforce.cpp | 6 +- src/fix_move.cpp | 10 ++-- src/fix_nh.cpp | 6 +- src/fix_nve.cpp | 2 +- src/fix_nve_limit.cpp | 2 +- src/fix_nve_noforce.cpp | 2 +- src/fix_nvt_sllod.cpp | 2 +- src/fix_planeforce.cpp | 6 +- src/fix_press_berendsen.cpp | 2 +- src/fix_recenter.cpp | 2 +- src/fix_restrain.cpp | 6 +- src/fix_setforce.cpp | 6 +- src/fix_spring.cpp | 6 +- src/fix_spring_chunk.cpp | 14 ++--- src/fix_spring_self.cpp | 6 +- src/fix_store_force.cpp | 6 +- src/fix_viscous.cpp | 6 +- src/fix_wall.cpp | 6 +- src/fix_wall_region.cpp | 6 +- src/force.cpp | 12 ++-- src/improper_deprecated.cpp | 2 +- src/info.cpp | 2 +- src/min.cpp | 2 +- src/molecule.cpp | 2 +- src/neighbor.cpp | 6 +- src/pair_deprecated.cpp | 2 +- src/pair_hybrid.cpp | 2 +- src/pair_hybrid_scaled.cpp | 2 +- src/pair_lj_cut.cpp | 6 +- src/read_data.cpp | 6 +- src/read_restart.cpp | 2 +- src/reset_mol_ids.cpp | 8 +-- src/respa.cpp | 4 +- src/set.cpp | 18 +++--- src/special.cpp | 4 +- src/variable.cpp | 2 +- src/write_dump.cpp | 4 +- 262 files changed, 669 insertions(+), 676 deletions(-) diff --git a/src/ASPHERE/compute_erotate_asphere.cpp b/src/ASPHERE/compute_erotate_asphere.cpp index d2118e60ca..192b5e5ed3 100644 --- a/src/ASPHERE/compute_erotate_asphere.cpp +++ b/src/ASPHERE/compute_erotate_asphere.cpp @@ -43,9 +43,9 @@ void ComputeERotateAsphere::init() { // error check - avec_ellipsoid = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); - avec_line = (AtomVecLine *) atom->style_match("line"); - avec_tri = (AtomVecTri *) atom->style_match("tri"); + avec_ellipsoid = dynamic_cast( atom->style_match("ellipsoid")); + avec_line = dynamic_cast( atom->style_match("line")); + avec_tri = dynamic_cast( atom->style_match("tri")); if (!avec_ellipsoid && !avec_line && !avec_tri) error->all(FLERR,"Compute erotate/asphere requires " "atom style ellipsoid or line or tri"); diff --git a/src/ASPHERE/compute_temp_asphere.cpp b/src/ASPHERE/compute_temp_asphere.cpp index abf0157f84..84581c63c1 100644 --- a/src/ASPHERE/compute_temp_asphere.cpp +++ b/src/ASPHERE/compute_temp_asphere.cpp @@ -94,7 +94,7 @@ void ComputeTempAsphere::init() { // error check - avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); + avec = dynamic_cast( atom->style_match("ellipsoid")); if (!avec) error->all(FLERR,"Compute temp/asphere requires atom style ellipsoid"); diff --git a/src/ASPHERE/fix_nh_asphere.cpp b/src/ASPHERE/fix_nh_asphere.cpp index 357aee9696..11e11926e4 100644 --- a/src/ASPHERE/fix_nh_asphere.cpp +++ b/src/ASPHERE/fix_nh_asphere.cpp @@ -36,7 +36,7 @@ FixNHAsphere::FixNHAsphere(LAMMPS *lmp, int narg, char **arg) : void FixNHAsphere::init() { - avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); + avec = dynamic_cast( atom->style_match("ellipsoid")); if (!avec) error->all(FLERR, "Compute nvt/nph/npt asphere requires atom style ellipsoid"); diff --git a/src/ASPHERE/fix_nve_asphere.cpp b/src/ASPHERE/fix_nve_asphere.cpp index cd70cce871..ee8c8d3b6e 100644 --- a/src/ASPHERE/fix_nve_asphere.cpp +++ b/src/ASPHERE/fix_nve_asphere.cpp @@ -37,7 +37,7 @@ FixNVEAsphere::FixNVEAsphere(LAMMPS *lmp, int narg, char **arg) : void FixNVEAsphere::init() { - avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); + avec = dynamic_cast( atom->style_match("ellipsoid")); if (!avec) error->all(FLERR,"Compute nve/asphere requires atom style ellipsoid"); diff --git a/src/ASPHERE/fix_nve_asphere_noforce.cpp b/src/ASPHERE/fix_nve_asphere_noforce.cpp index 7a489989f1..799df8115a 100644 --- a/src/ASPHERE/fix_nve_asphere_noforce.cpp +++ b/src/ASPHERE/fix_nve_asphere_noforce.cpp @@ -37,7 +37,7 @@ void FixNVEAsphereNoforce::init() { // error check - avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); + avec = dynamic_cast( atom->style_match("ellipsoid")); if (!atom->ellipsoid_flag) error->all(FLERR,"Fix nve/asphere/noforce requires atom style ellipsoid"); diff --git a/src/ASPHERE/fix_nve_line.cpp b/src/ASPHERE/fix_nve_line.cpp index da64444b4f..a46f6cf67b 100644 --- a/src/ASPHERE/fix_nve_line.cpp +++ b/src/ASPHERE/fix_nve_line.cpp @@ -56,7 +56,7 @@ void FixNVELine::init() { // error checks - avec = (AtomVecLine *) atom->style_match("line"); + avec = dynamic_cast( atom->style_match("line")); if (!avec) error->all(FLERR,"Fix nve/line requires atom style line"); if (domain->dimension != 2) diff --git a/src/ASPHERE/fix_nve_tri.cpp b/src/ASPHERE/fix_nve_tri.cpp index 72287a1807..d41d3ee0ef 100644 --- a/src/ASPHERE/fix_nve_tri.cpp +++ b/src/ASPHERE/fix_nve_tri.cpp @@ -50,7 +50,7 @@ void FixNVETri::init() { // error checks - avec = (AtomVecTri *) atom->style_match("tri"); + avec = dynamic_cast( atom->style_match("tri")); if (!avec) error->all(FLERR,"Fix nve/tri requires atom style tri"); if (domain->dimension != 3) diff --git a/src/ASPHERE/pair_gayberne.cpp b/src/ASPHERE/pair_gayberne.cpp index d1770894e2..04fa5330f9 100644 --- a/src/ASPHERE/pair_gayberne.cpp +++ b/src/ASPHERE/pair_gayberne.cpp @@ -345,7 +345,7 @@ void PairGayBerne::coeff(int narg, char **arg) void PairGayBerne::init_style() { - avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); + avec = dynamic_cast( atom->style_match("ellipsoid")); if (!avec) error->all(FLERR,"Pair gayberne requires atom style ellipsoid"); neighbor->add_request(this,NeighConst::REQ_DEFAULT); diff --git a/src/ASPHERE/pair_line_lj.cpp b/src/ASPHERE/pair_line_lj.cpp index a543bac09b..ab1b81ca73 100644 --- a/src/ASPHERE/pair_line_lj.cpp +++ b/src/ASPHERE/pair_line_lj.cpp @@ -402,7 +402,7 @@ void PairLineLJ::coeff(int narg, char **arg) void PairLineLJ::init_style() { - avec = (AtomVecLine *) atom->style_match("line"); + avec = dynamic_cast( atom->style_match("line")); if (!avec) error->all(FLERR,"Pair line/lj requires atom style line"); neighbor->add_request(this,NeighConst::REQ_DEFAULT); diff --git a/src/ASPHERE/pair_resquared.cpp b/src/ASPHERE/pair_resquared.cpp index 3dfe09d801..de0771a8e7 100644 --- a/src/ASPHERE/pair_resquared.cpp +++ b/src/ASPHERE/pair_resquared.cpp @@ -317,7 +317,7 @@ void PairRESquared::coeff(int narg, char **arg) void PairRESquared::init_style() { - avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); + avec = dynamic_cast( atom->style_match("ellipsoid")); if (!avec) error->all(FLERR, "Pair resquared requires atom style ellipsoid"); neighbor->add_request(this,NeighConst::REQ_DEFAULT); diff --git a/src/ASPHERE/pair_tri_lj.cpp b/src/ASPHERE/pair_tri_lj.cpp index 0cb08c41b3..eaec71b055 100644 --- a/src/ASPHERE/pair_tri_lj.cpp +++ b/src/ASPHERE/pair_tri_lj.cpp @@ -467,7 +467,7 @@ void PairTriLJ::coeff(int narg, char **arg) void PairTriLJ::init_style() { - avec = (AtomVecTri *) atom->style_match("tri"); + avec = dynamic_cast( atom->style_match("tri")); if (!avec) error->all(FLERR,"Pair tri/lj requires atom style tri"); neighbor->add_request(this,NeighConst::REQ_DEFAULT); diff --git a/src/AWPMD/fix_nve_awpmd.cpp b/src/AWPMD/fix_nve_awpmd.cpp index 812b573826..c37feb2ede 100644 --- a/src/AWPMD/fix_nve_awpmd.cpp +++ b/src/AWPMD/fix_nve_awpmd.cpp @@ -61,9 +61,9 @@ void FixNVEAwpmd::init() dtf = 0.5 * update->dt * force->ftm2v; if (utils::strmatch(update->integrate_style,"^respa")) - step_respa = ((Respa *) update->integrate)->step; + step_respa = (dynamic_cast( update->integrate))->step; - awpmd_pair=(PairAWPMDCut *)force->pair; + awpmd_pair=dynamic_cast(force->pair); awpmd_pair->wpmd->norm_needed=1; } diff --git a/src/BOCS/fix_bocs.cpp b/src/BOCS/fix_bocs.cpp index ff4b51e95a..3083286be8 100644 --- a/src/BOCS/fix_bocs.cpp +++ b/src/BOCS/fix_bocs.cpp @@ -489,7 +489,7 @@ void FixBocs::init() { for (int i = 0; i < modify->nfix; i++) if (strcmp(modify->fix[i]->style,"deform") == 0) { - int *dimflag = ((FixDeform *) modify->fix[i])->dimflag; + int *dimflag = (dynamic_cast( modify->fix[i]))->dimflag; if ((p_flag[0] && dimflag[0]) || (p_flag[1] && dimflag[1]) || (p_flag[2] && dimflag[2]) || (p_flag[3] && dimflag[3]) || (p_flag[4] && dimflag[4]) || (p_flag[5] && dimflag[5])) @@ -523,12 +523,12 @@ void FixBocs::init() { if (p_basis_type == BASIS_ANALYTIC) { - ((ComputePressureBocs *)pressure)->send_cg_info(p_basis_type, + (dynamic_cast(pressure))->send_cg_info(p_basis_type, N_p_match, p_match_coeffs, N_mol, vavg); } else if (p_basis_type == BASIS_LINEAR_SPLINE || p_basis_type == BASIS_CUBIC_SPLINE) { - ((ComputePressureBocs *)pressure)->send_cg_info(p_basis_type, + (dynamic_cast(pressure))->send_cg_info(p_basis_type, splines, spline_length); } } @@ -589,8 +589,8 @@ void FixBocs::init() else kspace_flag = 0; if (utils::strmatch(update->integrate_style,"^respa")) { - nlevels_respa = ((Respa *) update->integrate)->nlevels; - step_respa = ((Respa *) update->integrate)->step; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; + step_respa = (dynamic_cast( update->integrate))->step; dto = 0.5*step_respa[0]; } @@ -1551,12 +1551,12 @@ int FixBocs::modify_param(int narg, char **arg) { if (p_basis_type == BASIS_ANALYTIC) { - ((ComputePressureBocs *)pressure)->send_cg_info(p_basis_type, N_p_match, + (dynamic_cast(pressure))->send_cg_info(p_basis_type, N_p_match, p_match_coeffs, N_mol, vavg); } else if (p_basis_type == BASIS_LINEAR_SPLINE || p_basis_type == BASIS_CUBIC_SPLINE ) { - ((ComputePressureBocs *)pressure)->send_cg_info(p_basis_type, splines, spline_length ); + (dynamic_cast(pressure))->send_cg_info(p_basis_type, splines, spline_length ); } } diff --git a/src/BODY/compute_body_local.cpp b/src/BODY/compute_body_local.cpp index b66a324a21..7d48b0770f 100644 --- a/src/BODY/compute_body_local.cpp +++ b/src/BODY/compute_body_local.cpp @@ -53,7 +53,7 @@ ComputeBodyLocal::ComputeBodyLocal(LAMMPS *lmp, int narg, char **arg) : } } - avec = (AtomVecBody *) atom->style_match("body"); + avec = dynamic_cast( atom->style_match("body")); if (!avec) error->all(FLERR,"Compute body/local requires atom style body"); bptr = avec->bptr; diff --git a/src/BODY/compute_temp_body.cpp b/src/BODY/compute_temp_body.cpp index d8dfc0d279..3f97c2c82f 100644 --- a/src/BODY/compute_temp_body.cpp +++ b/src/BODY/compute_temp_body.cpp @@ -87,7 +87,7 @@ void ComputeTempBody::init() { // error check - avec = (AtomVecBody *) atom->style_match("body"); + avec = dynamic_cast( atom->style_match("body")); if (!avec) error->all(FLERR,"Compute temp/body requires atom style body"); diff --git a/src/BODY/fix_nh_body.cpp b/src/BODY/fix_nh_body.cpp index e9339400cc..ba46bce2ac 100644 --- a/src/BODY/fix_nh_body.cpp +++ b/src/BODY/fix_nh_body.cpp @@ -37,7 +37,7 @@ FixNHBody::FixNHBody(LAMMPS *lmp, int narg, char **arg) : void FixNHBody::init() { - avec = (AtomVecBody *) atom->style_match("body"); + avec = dynamic_cast( atom->style_match("body")); if (!avec) error->all(FLERR, "Compute nvt/nph/npt body requires atom style body"); diff --git a/src/BODY/fix_nve_body.cpp b/src/BODY/fix_nve_body.cpp index c00356f037..f731bed81e 100644 --- a/src/BODY/fix_nve_body.cpp +++ b/src/BODY/fix_nve_body.cpp @@ -30,7 +30,7 @@ FixNVEBody::FixNVEBody(LAMMPS *lmp, int narg, char **arg) : void FixNVEBody::init() { - avec = (AtomVecBody *) atom->style_match("body"); + avec = dynamic_cast( atom->style_match("body")); if (!avec) error->all(FLERR,"Fix nve/body requires atom style body"); // check that all particles are bodies diff --git a/src/BODY/fix_wall_body_polygon.cpp b/src/BODY/fix_wall_body_polygon.cpp index e4d25e8489..47467f9d42 100644 --- a/src/BODY/fix_wall_body_polygon.cpp +++ b/src/BODY/fix_wall_body_polygon.cpp @@ -179,13 +179,13 @@ void FixWallBodyPolygon::init() { dt = update->dt; - avec = (AtomVecBody *) atom->style_match("body"); + avec = dynamic_cast( atom->style_match("body")); if (!avec) error->all(FLERR,"Pair body/rounded/polygon requires atom style body"); if (strcmp(avec->bptr->style,"rounded/polygon") != 0) error->all(FLERR,"Pair body/rounded/polygon requires " "body style rounded/polygon"); - bptr = (BodyRoundedPolygon *) avec->bptr; + bptr = dynamic_cast( avec->bptr); // set pairstyle from body/polygonular pair style diff --git a/src/BODY/fix_wall_body_polyhedron.cpp b/src/BODY/fix_wall_body_polyhedron.cpp index 522860b469..2e503640d8 100644 --- a/src/BODY/fix_wall_body_polyhedron.cpp +++ b/src/BODY/fix_wall_body_polyhedron.cpp @@ -184,13 +184,13 @@ void FixWallBodyPolyhedron::init() { dt = update->dt; - avec = (AtomVecBody *) atom->style_match("body"); + avec = dynamic_cast( atom->style_match("body")); if (!avec) error->all(FLERR,"Pair body/rounded/polyhedron requires atom style body"); if (strcmp(avec->bptr->style,"rounded/polyhedron") != 0) error->all(FLERR,"Pair body/rounded/polyhedron requires " "body style rounded/polyhedron"); - bptr = (BodyRoundedPolyhedron *) avec->bptr; + bptr = dynamic_cast( avec->bptr); // set pairstyle from body/polyhedronular pair style diff --git a/src/BODY/pair_body_nparticle.cpp b/src/BODY/pair_body_nparticle.cpp index e893350c3e..df2c6c1d23 100644 --- a/src/BODY/pair_body_nparticle.cpp +++ b/src/BODY/pair_body_nparticle.cpp @@ -416,11 +416,11 @@ void PairBodyNparticle::coeff(int narg, char **arg) void PairBodyNparticle::init_style() { - avec = (AtomVecBody *) atom->style_match("body"); + avec = dynamic_cast( atom->style_match("body")); if (!avec) error->all(FLERR,"Pair body/nparticle requires atom style body"); if (strcmp(avec->bptr->style,"nparticle") != 0) error->all(FLERR,"Pair body/nparticle requires body style nparticle"); - bptr = (BodyNparticle *) avec->bptr; + bptr = dynamic_cast( avec->bptr); neighbor->add_request(this); } diff --git a/src/BODY/pair_body_rounded_polygon.cpp b/src/BODY/pair_body_rounded_polygon.cpp index aa3a86a821..7485cf4b9c 100644 --- a/src/BODY/pair_body_rounded_polygon.cpp +++ b/src/BODY/pair_body_rounded_polygon.cpp @@ -411,13 +411,13 @@ void PairBodyRoundedPolygon::coeff(int narg, char **arg) void PairBodyRoundedPolygon::init_style() { - avec = (AtomVecBody *) atom->style_match("body"); + avec = dynamic_cast( atom->style_match("body")); if (!avec) error->all(FLERR,"Pair body/rounded/polygon requires atom style body"); if (strcmp(avec->bptr->style,"rounded/polygon") != 0) error->all(FLERR,"Pair body/rounded/polygon requires " "body style rounded/polygon"); - bptr = (BodyRoundedPolygon *) avec->bptr; + bptr = dynamic_cast( avec->bptr); if (force->newton_pair == 0) error->all(FLERR,"Pair style body/rounded/polygon requires " diff --git a/src/BODY/pair_body_rounded_polyhedron.cpp b/src/BODY/pair_body_rounded_polyhedron.cpp index 8136e82fd8..a9593b5fa2 100644 --- a/src/BODY/pair_body_rounded_polyhedron.cpp +++ b/src/BODY/pair_body_rounded_polyhedron.cpp @@ -390,13 +390,13 @@ void PairBodyRoundedPolyhedron::coeff(int narg, char **arg) void PairBodyRoundedPolyhedron::init_style() { - avec = (AtomVecBody *) atom->style_match("body"); + avec = dynamic_cast( atom->style_match("body")); if (!avec) error->all(FLERR,"Pair body/rounded/polyhedron requires " "atom style body"); if (strcmp(avec->bptr->style,"rounded/polyhedron") != 0) error->all(FLERR,"Pair body/rounded/polyhedron requires " "body style rounded/polyhedron"); - bptr = (BodyRoundedPolyhedron *) avec->bptr; + bptr = dynamic_cast( avec->bptr); if (force->newton_pair == 0) error->all(FLERR,"Pair style body/rounded/polyhedron requires " diff --git a/src/BROWNIAN/fix_brownian_asphere.cpp b/src/BROWNIAN/fix_brownian_asphere.cpp index d0191c751e..d25123aa54 100644 --- a/src/BROWNIAN/fix_brownian_asphere.cpp +++ b/src/BROWNIAN/fix_brownian_asphere.cpp @@ -56,7 +56,7 @@ FixBrownianAsphere::FixBrownianAsphere(LAMMPS *lmp, int narg, char **arg) : void FixBrownianAsphere::init() { - avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); + avec = dynamic_cast( atom->style_match("ellipsoid")); if (!avec) error->all(FLERR, "Compute brownian/asphere requires atom style ellipsoid"); // check that all particles are finite-size ellipsoids diff --git a/src/BROWNIAN/fix_propel_self.cpp b/src/BROWNIAN/fix_propel_self.cpp index ea7a3c6834..4df10f9ef4 100644 --- a/src/BROWNIAN/fix_propel_self.cpp +++ b/src/BROWNIAN/fix_propel_self.cpp @@ -100,7 +100,7 @@ void FixPropelSelf::init() error->all(FLERR, "Fix propel/self requires atom attribute mu with option dipole"); if (mode == QUAT) { - avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); + avec = dynamic_cast( atom->style_match("ellipsoid")); if (!avec) error->all(FLERR, "Fix propel/self requires atom style ellipsoid with option quat"); // check that all particles are finite-size ellipsoids diff --git a/src/CG-DNA/fix_nve_dot.cpp b/src/CG-DNA/fix_nve_dot.cpp index 53b13cdbf1..3806e452c3 100644 --- a/src/CG-DNA/fix_nve_dot.cpp +++ b/src/CG-DNA/fix_nve_dot.cpp @@ -37,7 +37,7 @@ FixNVEDot::FixNVEDot(LAMMPS *lmp, int narg, char **arg) : void FixNVEDot::init() { - avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); + avec = dynamic_cast( atom->style_match("ellipsoid")); if (!avec) error->all(FLERR,"Compute nve/dot requires atom style ellipsoid"); diff --git a/src/CG-DNA/fix_nve_dotc_langevin.cpp b/src/CG-DNA/fix_nve_dotc_langevin.cpp index 54c1d1b545..8ca4acf510 100644 --- a/src/CG-DNA/fix_nve_dotc_langevin.cpp +++ b/src/CG-DNA/fix_nve_dotc_langevin.cpp @@ -89,7 +89,7 @@ void FixNVEDotcLangevin::init() int *mask = atom->mask; int nlocal = atom->nlocal; - avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); + avec = dynamic_cast( atom->style_match("ellipsoid")); if (!avec) error->all(FLERR,"Fix nve/dotc/langevin requires atom style ellipsoid"); diff --git a/src/CG-DNA/pair_oxdna_excv.cpp b/src/CG-DNA/pair_oxdna_excv.cpp index dfc96be13e..a201a5ccf7 100644 --- a/src/CG-DNA/pair_oxdna_excv.cpp +++ b/src/CG-DNA/pair_oxdna_excv.cpp @@ -139,7 +139,7 @@ void PairOxdnaExcv::compute(int eflag, int vflag) int newton_pair = force->newton_pair; int *alist,*blist,*numneigh,**firstneigh; - AtomVecEllipsoid *avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); + auto avec = dynamic_cast( atom->style_match("ellipsoid")); AtomVecEllipsoid::Bonus *bonus = avec->bonus; int *ellipsoid = atom->ellipsoid; diff --git a/src/CLASS2/pair_lj_class2.cpp b/src/CLASS2/pair_lj_class2.cpp index c95b34232b..0278e5c682 100644 --- a/src/CLASS2/pair_lj_class2.cpp +++ b/src/CLASS2/pair_lj_class2.cpp @@ -484,7 +484,7 @@ void PairLJClass2::init_style() int list_style = NeighConst::REQ_DEFAULT; if (update->whichflag == 1 && utils::strmatch(update->integrate_style, "^respa")) { - auto respa = (Respa *) update->integrate; + auto respa = dynamic_cast( update->integrate); if (respa->level_inner >= 0) list_style = NeighConst::REQ_RESPA_INOUT; if (respa->level_middle >= 0) list_style = NeighConst::REQ_RESPA_ALL; } @@ -493,8 +493,8 @@ void PairLJClass2::init_style() // set rRESPA cutoffs if (utils::strmatch(update->integrate_style, "^respa") && - ((Respa *) update->integrate)->level_inner >= 0) - cut_respa = ((Respa *) update->integrate)->cutoff; + (dynamic_cast( update->integrate))->level_inner >= 0) + cut_respa = (dynamic_cast( update->integrate))->cutoff; else cut_respa = nullptr; } diff --git a/src/CLASS2/pair_lj_class2_coul_long.cpp b/src/CLASS2/pair_lj_class2_coul_long.cpp index 1b1cc9c5a9..d75c7dea9c 100644 --- a/src/CLASS2/pair_lj_class2_coul_long.cpp +++ b/src/CLASS2/pair_lj_class2_coul_long.cpp @@ -672,7 +672,7 @@ void PairLJClass2CoulLong::init_style() int list_style = NeighConst::REQ_DEFAULT; if (update->whichflag == 1 && utils::strmatch(update->integrate_style, "^respa")) { - auto respa = (Respa *) update->integrate; + auto respa = dynamic_cast( update->integrate); if (respa->level_inner >= 0) list_style = NeighConst::REQ_RESPA_INOUT; if (respa->level_middle >= 0) list_style = NeighConst::REQ_RESPA_ALL; } @@ -683,8 +683,8 @@ void PairLJClass2CoulLong::init_style() // set rRESPA cutoffs if (utils::strmatch(update->integrate_style, "^respa") && - ((Respa *) update->integrate)->level_inner >= 0) - cut_respa = ((Respa *) update->integrate)->cutoff; + (dynamic_cast( update->integrate))->level_inner >= 0) + cut_respa = (dynamic_cast( update->integrate))->cutoff; else cut_respa = nullptr; diff --git a/src/COLLOID/pair_brownian.cpp b/src/COLLOID/pair_brownian.cpp index 5782586654..496d7cdee7 100644 --- a/src/COLLOID/pair_brownian.cpp +++ b/src/COLLOID/pair_brownian.cpp @@ -494,7 +494,7 @@ void PairBrownian::init_style() else if (strstr(modify->fix[i]->style, "wall") != nullptr) { if (flagwall) error->all(FLERR, "Cannot use multiple fix wall commands with pair brownian"); flagwall = 1; // Walls exist - wallfix = (FixWall *) modify->fix[i]; + wallfix = dynamic_cast( modify->fix[i]); if (wallfix->xflag) flagwall = 2; // Moving walls exist } } diff --git a/src/COLLOID/pair_brownian_poly.cpp b/src/COLLOID/pair_brownian_poly.cpp index 2edbbadc0f..d24a65a821 100644 --- a/src/COLLOID/pair_brownian_poly.cpp +++ b/src/COLLOID/pair_brownian_poly.cpp @@ -362,7 +362,7 @@ void PairBrownianPoly::init_style() error->all(FLERR, "Cannot use multiple fix wall commands with pair brownian"); flagwall = 1; // Walls exist - wallfix = (FixWall *) modify->fix[i]; + wallfix = dynamic_cast( modify->fix[i]); if (wallfix->xflag) flagwall = 2; // Moving walls exist } } diff --git a/src/COLLOID/pair_lubricate.cpp b/src/COLLOID/pair_lubricate.cpp index c2117cf1ad..1267d42f1f 100644 --- a/src/COLLOID/pair_lubricate.cpp +++ b/src/COLLOID/pair_lubricate.cpp @@ -563,7 +563,7 @@ void PairLubricate::init_style() for (int i = 0; i < modify->nfix; i++) { if (strcmp(modify->fix[i]->style,"deform") == 0) { shearing = flagdeform = 1; - if (((FixDeform *) modify->fix[i])->remapflag != Domain::V_REMAP) + if ((dynamic_cast( modify->fix[i]))->remapflag != Domain::V_REMAP) error->all(FLERR,"Using pair lubricate with inconsistent " "fix deform remap option"); } @@ -572,7 +572,7 @@ void PairLubricate::init_style() error->all(FLERR, "Cannot use multiple fix wall commands with pair lubricate"); flagwall = 1; // Walls exist - wallfix = (FixWall *) modify->fix[i]; + wallfix = dynamic_cast( modify->fix[i]); if (wallfix->xflag) flagwall = 2; // Moving walls exist } } diff --git a/src/COLLOID/pair_lubricateU.cpp b/src/COLLOID/pair_lubricateU.cpp index 3d4fbcbc7d..aa83a53ce4 100644 --- a/src/COLLOID/pair_lubricateU.cpp +++ b/src/COLLOID/pair_lubricateU.cpp @@ -1801,7 +1801,7 @@ void PairLubricateU::init_style() "Cannot use multiple fix wall commands with " "pair lubricateU"); flagwall = 1; // Walls exist - wallfix = (FixWall *) modify->fix[i]; + wallfix = dynamic_cast( modify->fix[i]); if (wallfix->xflag) flagwall = 2; // Moving walls exist } } diff --git a/src/COLLOID/pair_lubricateU_poly.cpp b/src/COLLOID/pair_lubricateU_poly.cpp index 0aed0df97f..1fad75a68c 100644 --- a/src/COLLOID/pair_lubricateU_poly.cpp +++ b/src/COLLOID/pair_lubricateU_poly.cpp @@ -1165,7 +1165,7 @@ void PairLubricateUPoly::init_style() "Cannot use multiple fix wall commands with " "pair lubricateU"); flagwall = 1; // Walls exist - wallfix = (FixWall *) modify->fix[i]; + wallfix = dynamic_cast( modify->fix[i]); if (wallfix->xflag) flagwall = 2; // Moving walls exist } } diff --git a/src/COLLOID/pair_lubricate_poly.cpp b/src/COLLOID/pair_lubricate_poly.cpp index 97aa6bf6ff..38ec073f48 100644 --- a/src/COLLOID/pair_lubricate_poly.cpp +++ b/src/COLLOID/pair_lubricate_poly.cpp @@ -463,7 +463,7 @@ void PairLubricatePoly::init_style() for (int i = 0; i < modify->nfix; i++) { if (strcmp(modify->fix[i]->style,"deform") == 0) { shearing = flagdeform = 1; - if (((FixDeform *) modify->fix[i])->remapflag != Domain::V_REMAP) + if ((dynamic_cast( modify->fix[i]))->remapflag != Domain::V_REMAP) error->all(FLERR,"Using pair lubricate with inconsistent " "fix deform remap option"); } @@ -473,15 +473,15 @@ void PairLubricatePoly::init_style() "Cannot use multiple fix wall commands with " "pair lubricate/poly"); flagwall = 1; // Walls exist - wallfix = (FixWall *) modify->fix[i]; + wallfix = dynamic_cast( modify->fix[i]); if (wallfix->xflag) flagwall = 2; // Moving walls exist } if (strstr(modify->fix[i]->style,"wall") != nullptr) { flagwall = 1; // Walls exist - if (((FixWall *) modify->fix[i])->xflag) { + if ((dynamic_cast( modify->fix[i]))->xflag) { flagwall = 2; // Moving walls exist - wallfix = (FixWall *) modify->fix[i]; + wallfix = dynamic_cast( modify->fix[i]); } } } @@ -539,7 +539,7 @@ void PairLubricatePoly::init_style() for (int i = 0; i < modify->nfix; i++) if (strcmp(modify->fix[i]->style,"deform") == 0) { shearing = 1; - if (((FixDeform *) modify->fix[i])->remapflag != Domain::V_REMAP) + if ((dynamic_cast( modify->fix[i]))->remapflag != Domain::V_REMAP) error->all(FLERR,"Using pair lubricate/poly with inconsistent " "fix deform remap option"); } diff --git a/src/CORESHELL/compute_temp_cs.cpp b/src/CORESHELL/compute_temp_cs.cpp index 9b4ca249fa..6a4a5be53f 100644 --- a/src/CORESHELL/compute_temp_cs.cpp +++ b/src/CORESHELL/compute_temp_cs.cpp @@ -74,7 +74,7 @@ ComputeTempCS::ComputeTempCS(LAMMPS *lmp, int narg, char **arg) : strcpy(id_fix,fixcmd.c_str()); fixcmd += fmt::format(" {} STORE peratom 0 1", group->names[igroup]); - fix = (FixStore *)modify->add_fix(fixcmd); + fix = dynamic_cast(modify->add_fix(fixcmd)); // set fix store values = 0 for now // fill them in via setup() once Comm::borders() has been called diff --git a/src/DIELECTRIC/compute_efield_atom.cpp b/src/DIELECTRIC/compute_efield_atom.cpp index 586d858632..38dca98cb4 100644 --- a/src/DIELECTRIC/compute_efield_atom.cpp +++ b/src/DIELECTRIC/compute_efield_atom.cpp @@ -90,26 +90,26 @@ void ComputeEfieldAtom::init() void ComputeEfieldAtom::setup() { if (strcmp(force->pair_style,"lj/cut/coul/long/dielectric") == 0) - efield_pair = ((PairLJCutCoulLongDielectric*)force->pair)->efield; + efield_pair = (dynamic_cast(force->pair))->efield; else if (strcmp(force->pair_style,"lj/cut/coul/long/dielectric/omp") == 0) - efield_pair = ((PairLJCutCoulMSMDielectric*)force->pair)->efield; + efield_pair = (dynamic_cast(force->pair))->efield; else if (strcmp(force->pair_style,"lj/cut/coul/msm/dielectric") == 0) - efield_pair = ((PairLJCutCoulMSMDielectric*)force->pair)->efield; + efield_pair = (dynamic_cast(force->pair))->efield; else if (strcmp(force->pair_style,"lj/cut/coul/cut/dielectric") == 0) - efield_pair = ((PairLJCutCoulCutDielectric*)force->pair)->efield; + efield_pair = (dynamic_cast(force->pair))->efield; else if (strcmp(force->pair_style,"lj/cut/coul/cut/dielectric/omp") == 0) - efield_pair = ((PairLJCutCoulCutDielectric*)force->pair)->efield; + efield_pair = (dynamic_cast(force->pair))->efield; else if (strcmp(force->pair_style,"coul/long/dielectric") == 0) - efield_pair = ((PairCoulLongDielectric*)force->pair)->efield; + efield_pair = (dynamic_cast(force->pair))->efield; else if (strcmp(force->pair_style,"coul/cut/dielectric") == 0) - efield_pair = ((PairCoulCutDielectric*)force->pair)->efield; + efield_pair = (dynamic_cast(force->pair))->efield; else error->all(FLERR,"Compute efield/atom not supported by pair style"); if (force->kspace) { if (strcmp(force->kspace_style,"pppm/dielectric") == 0) - efield_kspace = ((PPPMDielectric*)force->kspace)->efield; + efield_kspace = (dynamic_cast(force->kspace))->efield; else if (strcmp(force->kspace_style,"msm/dielectric") == 0) - efield_kspace = ((MSMDielectric*)force->kspace)->efield; + efield_kspace = (dynamic_cast(force->kspace))->efield; else error->all(FLERR,"Compute efield/atom not supported by kspace style"); kspaceflag = 1; } diff --git a/src/DIELECTRIC/fix_polarize_bem_gmres.cpp b/src/DIELECTRIC/fix_polarize_bem_gmres.cpp index 5d723316c0..1914693221 100644 --- a/src/DIELECTRIC/fix_polarize_bem_gmres.cpp +++ b/src/DIELECTRIC/fix_polarize_bem_gmres.cpp @@ -71,7 +71,7 @@ FixPolarizeBEMGMRES::FixPolarizeBEMGMRES(LAMMPS *lmp, int narg, char **arg) : { if (narg < 5) error->all(FLERR, "Illegal fix polarize/bem/gmres command"); - avec = (AtomVecDielectric *) atom->style_match("dielectric"); + avec = dynamic_cast( atom->style_match("dielectric")); if (!avec) error->all(FLERR, "Fix polarize requires atom style dielectric"); // parse required arguments @@ -211,7 +211,7 @@ void FixPolarizeBEMGMRES::init() if (randomized) { - RanPark *random = new RanPark(lmp, seed_charge + comm->me); + auto random = new RanPark(lmp, seed_charge + comm->me); for (i = 0; i < 100; i++) random->uniform(); double sum, tmp = 0; for (i = 0; i < nlocal; i++) { @@ -248,28 +248,28 @@ void FixPolarizeBEMGMRES::setup(int /*vflag*/) // check if the pair styles in use are compatible if (strcmp(force->pair_style, "lj/cut/coul/long/dielectric") == 0) - efield_pair = ((PairLJCutCoulLongDielectric *) force->pair)->efield; + efield_pair = (dynamic_cast( force->pair))->efield; else if (strcmp(force->pair_style, "lj/cut/coul/long/dielectric/omp") == 0) - efield_pair = ((PairLJCutCoulLongDielectric *) force->pair)->efield; + efield_pair = (dynamic_cast( force->pair))->efield; else if (strcmp(force->pair_style, "lj/cut/coul/msm/dielectric") == 0) - efield_pair = ((PairLJCutCoulMSMDielectric *) force->pair)->efield; + efield_pair = (dynamic_cast( force->pair))->efield; else if (strcmp(force->pair_style, "lj/cut/coul/cut/dielectric") == 0) - efield_pair = ((PairLJCutCoulCutDielectric *) force->pair)->efield; + efield_pair = (dynamic_cast( force->pair))->efield; else if (strcmp(force->pair_style, "lj/cut/coul/cut/dielectric/omp") == 0) - efield_pair = ((PairLJCutCoulCutDielectric *) force->pair)->efield; + efield_pair = (dynamic_cast( force->pair))->efield; else if (strcmp(force->pair_style, "coul/long/dielectric") == 0) - efield_pair = ((PairCoulLongDielectric *) force->pair)->efield; + efield_pair = (dynamic_cast( force->pair))->efield; else if (strcmp(force->pair_style, "coul/cut/dielectric") == 0) - efield_pair = ((PairCoulCutDielectric *) force->pair)->efield; + efield_pair = (dynamic_cast( force->pair))->efield; else error->all(FLERR, "Pair style not compatible with fix polarize"); if (kspaceflag) { if (force->kspace) { if (strcmp(force->kspace_style, "pppm/dielectric") == 0) - efield_kspace = ((PPPMDielectric *) force->kspace)->efield; + efield_kspace = (dynamic_cast( force->kspace))->efield; else if (strcmp(force->kspace_style, "msm/dielectric") == 0) - efield_kspace = ((MSMDielectric *) force->kspace)->efield; + efield_kspace = (dynamic_cast( force->kspace))->efield; else error->all(FLERR, "Kspace style not compatible with fix polarize/bem/gmres"); } else diff --git a/src/DIELECTRIC/fix_polarize_bem_icc.cpp b/src/DIELECTRIC/fix_polarize_bem_icc.cpp index 3a485ea361..1a36518b1c 100644 --- a/src/DIELECTRIC/fix_polarize_bem_icc.cpp +++ b/src/DIELECTRIC/fix_polarize_bem_icc.cpp @@ -58,7 +58,7 @@ FixPolarizeBEMICC::FixPolarizeBEMICC(LAMMPS *lmp, int narg, char **arg) : Fix(lm { if (narg < 5) error->all(FLERR, "Illegal fix polarize/bem/icc command"); - avec = (AtomVecDielectric *) atom->style_match("dielectric"); + avec = dynamic_cast( atom->style_match("dielectric")); if (!avec) error->all(FLERR, "Fix polarize requires atom style dielectric"); // parse required arguments @@ -146,19 +146,19 @@ void FixPolarizeBEMICC::setup(int /*vflag*/) // check if the pair styles in use are compatible if (strcmp(force->pair_style, "lj/cut/coul/long/dielectric") == 0) - efield_pair = ((PairLJCutCoulLongDielectric *) force->pair)->efield; + efield_pair = (dynamic_cast( force->pair))->efield; else if (strcmp(force->pair_style, "lj/cut/coul/long/dielectric/omp") == 0) - efield_pair = ((PairLJCutCoulLongDielectric *) force->pair)->efield; + efield_pair = (dynamic_cast( force->pair))->efield; else if (strcmp(force->pair_style, "lj/cut/coul/msm/dielectric") == 0) - efield_pair = ((PairLJCutCoulMSMDielectric *) force->pair)->efield; + efield_pair = (dynamic_cast( force->pair))->efield; else if (strcmp(force->pair_style, "lj/cut/coul/cut/dielectric") == 0) - efield_pair = ((PairLJCutCoulCutDielectric *) force->pair)->efield; + efield_pair = (dynamic_cast( force->pair))->efield; else if (strcmp(force->pair_style, "lj/cut/coul/cut/dielectric/omp") == 0) - efield_pair = ((PairLJCutCoulCutDielectric *) force->pair)->efield; + efield_pair = (dynamic_cast( force->pair))->efield; else if (strcmp(force->pair_style, "coul/long/dielectric") == 0) - efield_pair = ((PairCoulLongDielectric *) force->pair)->efield; + efield_pair = (dynamic_cast( force->pair))->efield; else if (strcmp(force->pair_style, "coul/cut/dielectric") == 0) - efield_pair = ((PairCoulCutDielectric *) force->pair)->efield; + efield_pair = (dynamic_cast( force->pair))->efield; else error->all(FLERR, "Pair style not compatible with fix polarize/bem/icc"); @@ -168,9 +168,9 @@ void FixPolarizeBEMICC::setup(int /*vflag*/) kspaceflag = 1; if (strcmp(force->kspace_style, "pppm/dielectric") == 0) - efield_kspace = ((PPPMDielectric *) force->kspace)->efield; + efield_kspace = (dynamic_cast( force->kspace))->efield; else if (strcmp(force->kspace_style, "msm/dielectric") == 0) - efield_kspace = ((MSMDielectric *) force->kspace)->efield; + efield_kspace = (dynamic_cast( force->kspace))->efield; else error->all(FLERR, "Kspace style not compatible with fix polarize/bem/icc"); diff --git a/src/DIELECTRIC/fix_polarize_functional.cpp b/src/DIELECTRIC/fix_polarize_functional.cpp index 15140e7d58..971ae3e98b 100644 --- a/src/DIELECTRIC/fix_polarize_functional.cpp +++ b/src/DIELECTRIC/fix_polarize_functional.cpp @@ -71,7 +71,7 @@ FixPolarizeFunctional::FixPolarizeFunctional(LAMMPS *lmp, int narg, char **arg) { if (narg < 4) error->all(FLERR, "Illegal fix polarize/functional command"); - avec = (AtomVecDielectric *) atom->style_match("dielectric"); + avec = dynamic_cast( atom->style_match("dielectric")); if (!avec) error->all(FLERR, "Fix polarize/functional requires atom style dielectric"); nevery = utils::inumeric(FLERR, arg[3], false, lmp); @@ -290,19 +290,19 @@ void FixPolarizeFunctional::setup(int /*vflag*/) // check if the pair styles in use are compatible if (strcmp(force->pair_style, "lj/cut/coul/long/dielectric") == 0) - efield_pair = ((PairLJCutCoulLongDielectric *) force->pair)->efield; + efield_pair = (dynamic_cast( force->pair))->efield; else if (strcmp(force->pair_style, "lj/cut/coul/long/dielectric/omp") == 0) - efield_pair = ((PairLJCutCoulLongDielectric *) force->pair)->efield; + efield_pair = (dynamic_cast( force->pair))->efield; else if (strcmp(force->pair_style, "lj/cut/coul/msm/dielectric") == 0) - efield_pair = ((PairLJCutCoulMSMDielectric *) force->pair)->efield; + efield_pair = (dynamic_cast( force->pair))->efield; else if (strcmp(force->pair_style, "lj/cut/coul/cut/dielectric") == 0) - efield_pair = ((PairLJCutCoulCutDielectric *) force->pair)->efield; + efield_pair = (dynamic_cast( force->pair))->efield; else if (strcmp(force->pair_style, "lj/cut/coul/cut/dielectric/omp") == 0) - efield_pair = ((PairLJCutCoulCutDielectric *) force->pair)->efield; + efield_pair = (dynamic_cast( force->pair))->efield; else if (strcmp(force->pair_style, "coul/long/dielectric") == 0) - efield_pair = ((PairCoulLongDielectric *) force->pair)->efield; + efield_pair = (dynamic_cast( force->pair))->efield; else if (strcmp(force->pair_style, "coul/cut/dielectric") == 0) - efield_pair = ((PairCoulCutDielectric *) force->pair)->efield; + efield_pair = (dynamic_cast( force->pair))->efield; else error->all(FLERR, "Pair style not compatible with fix polarize/functional"); @@ -310,9 +310,9 @@ void FixPolarizeFunctional::setup(int /*vflag*/) kspaceflag = 1; if (strcmp(force->kspace_style, "pppm/dielectric") == 0) - efield_kspace = ((PPPMDielectric *) force->kspace)->efield; + efield_kspace = (dynamic_cast( force->kspace))->efield; else if (strcmp(force->kspace_style, "msm/dielectric") == 0) - efield_kspace = ((MSMDielectric *) force->kspace)->efield; + efield_kspace = (dynamic_cast( force->kspace))->efield; else error->all(FLERR, "Kspace style not compatible with fix polarize/functional"); diff --git a/src/DIELECTRIC/msm_dielectric.cpp b/src/DIELECTRIC/msm_dielectric.cpp index 329218a94f..d3d3da7ed7 100644 --- a/src/DIELECTRIC/msm_dielectric.cpp +++ b/src/DIELECTRIC/msm_dielectric.cpp @@ -58,7 +58,7 @@ void MSMDielectric::init() { MSM::init(); - avec = (AtomVecDielectric *) atom->style_match("dielectric"); + avec = dynamic_cast( atom->style_match("dielectric")); if (!avec) error->all(FLERR,"msm/dielectric requires atom style dielectric"); } diff --git a/src/DIELECTRIC/pair_coul_cut_dielectric.cpp b/src/DIELECTRIC/pair_coul_cut_dielectric.cpp index 7e3602967f..dc1b2041d7 100644 --- a/src/DIELECTRIC/pair_coul_cut_dielectric.cpp +++ b/src/DIELECTRIC/pair_coul_cut_dielectric.cpp @@ -162,7 +162,7 @@ void PairCoulCutDielectric::compute(int eflag, int vflag) void PairCoulCutDielectric::init_style() { - avec = (AtomVecDielectric *) atom->style_match("dielectric"); + avec = dynamic_cast( atom->style_match("dielectric")); if (!avec) error->all(FLERR, "Pair coul/cut/dielectric requires atom style dielectric"); neighbor->add_request(this, NeighConst::REQ_FULL); diff --git a/src/DIELECTRIC/pair_coul_long_dielectric.cpp b/src/DIELECTRIC/pair_coul_long_dielectric.cpp index 66a4473bfc..c8e5424a92 100644 --- a/src/DIELECTRIC/pair_coul_long_dielectric.cpp +++ b/src/DIELECTRIC/pair_coul_long_dielectric.cpp @@ -207,7 +207,7 @@ void PairCoulLongDielectric::compute(int eflag, int vflag) void PairCoulLongDielectric::init_style() { - avec = (AtomVecDielectric *) atom->style_match("dielectric"); + avec = dynamic_cast( atom->style_match("dielectric")); if (!avec) error->all(FLERR, "Pair coul/long/dielectric requires atom style dielectric"); neighbor->add_request(this, NeighConst::REQ_FULL); diff --git a/src/DIELECTRIC/pair_lj_cut_coul_cut_dielectric.cpp b/src/DIELECTRIC/pair_lj_cut_coul_cut_dielectric.cpp index 94ecdac578..ee95c1c2f5 100644 --- a/src/DIELECTRIC/pair_lj_cut_coul_cut_dielectric.cpp +++ b/src/DIELECTRIC/pair_lj_cut_coul_cut_dielectric.cpp @@ -190,7 +190,7 @@ void PairLJCutCoulCutDielectric::compute(int eflag, int vflag) void PairLJCutCoulCutDielectric::init_style() { - avec = (AtomVecDielectric *) atom->style_match("dielectric"); + avec = dynamic_cast( atom->style_match("dielectric")); if (!avec) error->all(FLERR, "Pair lj/cut/coul/cut/dielectric requires atom style dielectric"); neighbor->add_request(this, NeighConst::REQ_FULL); diff --git a/src/DIELECTRIC/pair_lj_cut_coul_debye_dielectric.cpp b/src/DIELECTRIC/pair_lj_cut_coul_debye_dielectric.cpp index 8858a444a8..f9efd30ec1 100644 --- a/src/DIELECTRIC/pair_lj_cut_coul_debye_dielectric.cpp +++ b/src/DIELECTRIC/pair_lj_cut_coul_debye_dielectric.cpp @@ -194,7 +194,7 @@ void PairLJCutCoulDebyeDielectric::compute(int eflag, int vflag) void PairLJCutCoulDebyeDielectric::init_style() { - avec = (AtomVecDielectric *) atom->style_match("dielectric"); + avec = dynamic_cast( atom->style_match("dielectric")); if (!avec) error->all(FLERR, "Pair lj/cut/coul/debye/dielectric requires atom style dielectric"); neighbor->add_request(this, NeighConst::REQ_FULL); diff --git a/src/DIELECTRIC/pair_lj_cut_coul_long_dielectric.cpp b/src/DIELECTRIC/pair_lj_cut_coul_long_dielectric.cpp index 22a725d045..823c7de50f 100644 --- a/src/DIELECTRIC/pair_lj_cut_coul_long_dielectric.cpp +++ b/src/DIELECTRIC/pair_lj_cut_coul_long_dielectric.cpp @@ -244,7 +244,7 @@ void PairLJCutCoulLongDielectric::compute(int eflag, int vflag) void PairLJCutCoulLongDielectric::init_style() { - avec = (AtomVecDielectric *) atom->style_match("dielectric"); + avec = dynamic_cast( atom->style_match("dielectric")); if (!avec) error->all(FLERR, "Pair lj/cut/coul/long/dielectric requires atom style dielectric"); neighbor->add_request(this, NeighConst::REQ_FULL); diff --git a/src/DIELECTRIC/pair_lj_cut_coul_msm_dielectric.cpp b/src/DIELECTRIC/pair_lj_cut_coul_msm_dielectric.cpp index 751f4d509a..4dffd81aa3 100644 --- a/src/DIELECTRIC/pair_lj_cut_coul_msm_dielectric.cpp +++ b/src/DIELECTRIC/pair_lj_cut_coul_msm_dielectric.cpp @@ -352,7 +352,7 @@ double PairLJCutCoulMSMDielectric::single(int i, int j, int itype, int jtype, do void PairLJCutCoulMSMDielectric::init_style() { - avec = (AtomVecDielectric *) atom->style_match("dielectric"); + avec = dynamic_cast( atom->style_match("dielectric")); if (!avec) error->all(FLERR, "Pair lj/cut/coul/msm/dielectric requires atom style dielectric"); neighbor->add_request(this, NeighConst::REQ_FULL); diff --git a/src/DIELECTRIC/pair_lj_long_coul_long_dielectric.cpp b/src/DIELECTRIC/pair_lj_long_coul_long_dielectric.cpp index 3fd86587e9..0f72238e63 100644 --- a/src/DIELECTRIC/pair_lj_long_coul_long_dielectric.cpp +++ b/src/DIELECTRIC/pair_lj_long_coul_long_dielectric.cpp @@ -71,7 +71,7 @@ void PairLJLongCoulLongDielectric::init_style() { PairLJLongCoulLong::init_style(); - avec = (AtomVecDielectric *) atom->style_match("dielectric"); + avec = dynamic_cast( atom->style_match("dielectric")); if (!avec) error->all(FLERR, "Pair lj/long/coul/long/dielectric requires atom style dielectric"); neighbor->add_request(this, NeighConst::REQ_FULL); diff --git a/src/DIELECTRIC/pppm_dielectric.cpp b/src/DIELECTRIC/pppm_dielectric.cpp index 597f51010e..25e5936cdb 100644 --- a/src/DIELECTRIC/pppm_dielectric.cpp +++ b/src/DIELECTRIC/pppm_dielectric.cpp @@ -58,7 +58,7 @@ PPPMDielectric::PPPMDielectric(LAMMPS *lmp) : PPPM(lmp) phi = nullptr; potflag = 0; - avec = (AtomVecDielectric *) atom->style_match("dielectric"); + avec = dynamic_cast( atom->style_match("dielectric")); if (!avec) error->all(FLERR,"pppm/dielectric requires atom style dielectric"); } diff --git a/src/DIELECTRIC/pppm_disp_dielectric.cpp b/src/DIELECTRIC/pppm_disp_dielectric.cpp index 2a7febd304..36847a87ac 100644 --- a/src/DIELECTRIC/pppm_disp_dielectric.cpp +++ b/src/DIELECTRIC/pppm_disp_dielectric.cpp @@ -69,7 +69,7 @@ PPPMDispDielectric::PPPMDispDielectric(LAMMPS *lmp) : PPPMDisp(lmp) phi = nullptr; potflag = 0; - avec = (AtomVecDielectric *) atom->style_match("dielectric"); + avec = dynamic_cast( atom->style_match("dielectric")); if (!avec) error->all(FLERR,"pppm/dielectric requires atom style dielectric"); } diff --git a/src/DIFFRACTION/fix_saed_vtk.cpp b/src/DIFFRACTION/fix_saed_vtk.cpp index 89627b64ef..45b2db9743 100644 --- a/src/DIFFRACTION/fix_saed_vtk.cpp +++ b/src/DIFFRACTION/fix_saed_vtk.cpp @@ -67,7 +67,7 @@ FixSAEDVTK::FixSAEDVTK(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR,"Compute ID for fix saed/vtk does not exist"); // Check that specified compute is for SAED - compute_saed = (ComputeSAED *) modify->compute[icompute]; + compute_saed = dynamic_cast( modify->compute[icompute]); if (strcmp(compute_saed->style,"saed") != 0) error->all(FLERR,"Fix saed/vtk has invalid compute assigned"); diff --git a/src/DPD-REACT/fix_dpd_energy.cpp b/src/DPD-REACT/fix_dpd_energy.cpp index f980e41157..79ff1cc231 100644 --- a/src/DPD-REACT/fix_dpd_energy.cpp +++ b/src/DPD-REACT/fix_dpd_energy.cpp @@ -30,9 +30,9 @@ FixDPDenergy::FixDPDenergy(LAMMPS *lmp, int narg, char **arg) : if (narg != 3 ) error->all(FLERR,"Illegal fix dpd/energy command"); pairDPDE = nullptr; - pairDPDE = (PairDPDfdtEnergy *) force->pair_match("dpd/fdt/energy",1); + pairDPDE = dynamic_cast( force->pair_match("dpd/fdt/energy",1)); if (pairDPDE == nullptr) - pairDPDE = (PairDPDfdtEnergy *) force->pair_match("dpd/fdt/energy/kk",1); + pairDPDE = dynamic_cast( force->pair_match("dpd/fdt/energy/kk",1)); if (pairDPDE == nullptr) error->all(FLERR,"Must use pair_style dpd/fdt/energy with fix dpd/energy"); diff --git a/src/DPD-REACT/fix_rx.cpp b/src/DPD-REACT/fix_rx.cpp index f20dd8963f..9a32f39268 100644 --- a/src/DPD-REACT/fix_rx.cpp +++ b/src/DPD-REACT/fix_rx.cpp @@ -319,9 +319,9 @@ void FixRX::post_constructor() newcmd1 += " ghost yes"; newcmd2 += " ghost yes"; - fix_species = (FixPropertyAtom *) modify->add_fix(newcmd1); + fix_species = dynamic_cast( modify->add_fix(newcmd1)); restartFlag = fix_species->restart_reset; - fix_species_old = (FixPropertyAtom *) modify->add_fix(newcmd2); + fix_species_old = dynamic_cast( modify->add_fix(newcmd2)); if (nspecies==0) error->all(FLERR,"There are no rx species specified."); @@ -579,9 +579,9 @@ int FixRX::setmask() void FixRX::init() { - pairDPDE = (PairDPDfdtEnergy *) force->pair_match("dpd/fdt/energy",1); + pairDPDE = dynamic_cast( force->pair_match("dpd/fdt/energy",1)); if (pairDPDE == nullptr) - pairDPDE = (PairDPDfdtEnergy *) force->pair_match("dpd/fdt/energy/kk",1); + pairDPDE = dynamic_cast( force->pair_match("dpd/fdt/energy/kk",1)); if (pairDPDE == nullptr) error->all(FLERR,"Must use pair_style dpd/fdt/energy with fix rx"); diff --git a/src/DPD-REACT/fix_shardlow.cpp b/src/DPD-REACT/fix_shardlow.cpp index 02a8af888e..7ab8c6f857 100644 --- a/src/DPD-REACT/fix_shardlow.cpp +++ b/src/DPD-REACT/fix_shardlow.cpp @@ -93,10 +93,10 @@ FixShardlow::FixShardlow(LAMMPS *lmp, int narg, char **arg) : pairDPD = nullptr; pairDPDE = nullptr; - pairDPD = (PairDPDfdt *) force->pair_match("dpd/fdt",1); - pairDPDE = (PairDPDfdtEnergy *) force->pair_match("dpd/fdt/energy",1); + pairDPD = dynamic_cast( force->pair_match("dpd/fdt",1)); + pairDPDE = dynamic_cast( force->pair_match("dpd/fdt/energy",1)); if (pairDPDE == nullptr) - pairDPDE = (PairDPDfdtEnergy *) force->pair_match("dpd/fdt/energy/kk",1); + pairDPDE = dynamic_cast( force->pair_match("dpd/fdt/energy/kk",1)); maxRNG = 0; if (pairDPDE) { @@ -548,7 +548,7 @@ void FixShardlow::initial_integrate(int /*vflag*/) "Either reduce the number of processors requested, or change the cutoff/skin: " "rcut= {} bbx= {} bby= {} bbz= {}\n", rcut, bbx, bby, bbz); - NPairHalfBinNewtonSSA *np_ssa = dynamic_cast(list->np); + auto np_ssa = dynamic_cast(list->np); if (!np_ssa) error->one(FLERR, "NPair wasn't a NPairHalfBinNewtonSSA object"); int ssa_phaseCt = np_ssa->ssa_phaseCt; int *ssa_phaseLen = np_ssa->ssa_phaseLen; diff --git a/src/DRUDE/compute_temp_drude.cpp b/src/DRUDE/compute_temp_drude.cpp index 96344751a7..f5cfe35223 100644 --- a/src/DRUDE/compute_temp_drude.cpp +++ b/src/DRUDE/compute_temp_drude.cpp @@ -67,7 +67,7 @@ void ComputeTempDrude::init() for (ifix = 0; ifix < modify->nfix; ifix++) if (strcmp(modify->fix[ifix]->style,"drude") == 0) break; if (ifix == modify->nfix) error->all(FLERR, "compute temp/drude requires fix drude"); - fix_drude = (FixDrude *) modify->fix[ifix]; + fix_drude = dynamic_cast( modify->fix[ifix]); if (!comm->ghost_velocity) error->all(FLERR,"compute temp/drude requires ghost velocities. Use comm_modify vel yes"); diff --git a/src/DRUDE/fix_langevin_drude.cpp b/src/DRUDE/fix_langevin_drude.cpp index dea2f9ce62..54cc156d67 100644 --- a/src/DRUDE/fix_langevin_drude.cpp +++ b/src/DRUDE/fix_langevin_drude.cpp @@ -148,7 +148,7 @@ void FixLangevinDrude::init() for (ifix = 0; ifix < modify->nfix; ifix++) if (strcmp(modify->fix[ifix]->style,"drude") == 0) break; if (ifix == modify->nfix) error->all(FLERR, "fix langevin/drude requires fix drude"); - fix_drude = (FixDrude *) modify->fix[ifix]; + fix_drude = dynamic_cast( modify->fix[ifix]); } /* ---------------------------------------------------------------------- */ diff --git a/src/DRUDE/fix_tgnh_drude.cpp b/src/DRUDE/fix_tgnh_drude.cpp index 3130044d5b..d5de5bd67f 100644 --- a/src/DRUDE/fix_tgnh_drude.cpp +++ b/src/DRUDE/fix_tgnh_drude.cpp @@ -523,7 +523,7 @@ FixTGNHDrude::FixTGNHDrude(LAMMPS *lmp, int narg, char **arg) : for (ifix = 0; ifix < modify->nfix; ifix++) if (strcmp(modify->fix[ifix]->style,"drude") == 0) break; if (ifix == modify->nfix) error->all(FLERR, "fix tgnh/drude requires fix drude"); - fix_drude = (FixDrude *) modify->fix[ifix]; + fix_drude = dynamic_cast( modify->fix[ifix]); // make sure ghost atoms have velocity if (!comm->ghost_velocity) @@ -595,7 +595,7 @@ void FixTGNHDrude::init() if (pstat_flag) for (int i = 0; i < modify->nfix; i++) if (strcmp(modify->fix[i]->style,"deform") == 0) { - int *dimflag = ((FixDeform *) modify->fix[i])->dimflag; + int *dimflag = (dynamic_cast( modify->fix[i]))->dimflag; if ((p_flag[0] && dimflag[0]) || (p_flag[1] && dimflag[1]) || (p_flag[2] && dimflag[2]) || (p_flag[3] && dimflag[3]) || (p_flag[4] && dimflag[4]) || (p_flag[5] && dimflag[5])) @@ -664,8 +664,8 @@ void FixTGNHDrude::init() else kspace_flag = 0; if (utils::strmatch(update->integrate_style,"^respa")) { - nlevels_respa = ((Respa *) update->integrate)->nlevels; - step_respa = ((Respa *) update->integrate)->step; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; + step_respa = (dynamic_cast( update->integrate))->step; dto = 0.5*step_respa[0]; } diff --git a/src/DRUDE/pair_coul_tt.cpp b/src/DRUDE/pair_coul_tt.cpp index 1e3892c414..af8ed099c5 100644 --- a/src/DRUDE/pair_coul_tt.cpp +++ b/src/DRUDE/pair_coul_tt.cpp @@ -289,7 +289,7 @@ void PairCoulTT::init_style() for (ifix = 0; ifix < modify->nfix; ifix++) if (utils::strmatch(modify->fix[ifix]->style,"^drude")) break; if (ifix == modify->nfix) error->all(FLERR, "Pair coul/tt requires fix drude"); - fix_drude = (FixDrude *) modify->fix[ifix]; + fix_drude = dynamic_cast( modify->fix[ifix]); neighbor->add_request(this); } diff --git a/src/DRUDE/pair_lj_cut_thole_long.cpp b/src/DRUDE/pair_lj_cut_thole_long.cpp index 53e95c087e..33e1e435fa 100644 --- a/src/DRUDE/pair_lj_cut_thole_long.cpp +++ b/src/DRUDE/pair_lj_cut_thole_long.cpp @@ -364,7 +364,7 @@ void PairLJCutTholeLong::init_style() if (strcmp(modify->fix[ifix]->style,"drude") == 0) break; if (ifix == modify->nfix) error->all(FLERR, "Pair style lj/cut/thole/long requires fix drude"); - fix_drude = (FixDrude *) modify->fix[ifix]; + fix_drude = dynamic_cast( modify->fix[ifix]); neighbor->add_request(this); diff --git a/src/DRUDE/pair_thole.cpp b/src/DRUDE/pair_thole.cpp index 126e611fcf..a2f0b25e13 100644 --- a/src/DRUDE/pair_thole.cpp +++ b/src/DRUDE/pair_thole.cpp @@ -258,7 +258,7 @@ void PairThole::init_style() for (ifix = 0; ifix < modify->nfix; ifix++) if (strcmp(modify->fix[ifix]->style,"drude") == 0) break; if (ifix == modify->nfix) error->all(FLERR, "Pair thole requires fix drude"); - fix_drude = (FixDrude *) modify->fix[ifix]; + fix_drude = dynamic_cast( modify->fix[ifix]); neighbor->add_request(this); } diff --git a/src/EFF/compute_temp_deform_eff.cpp b/src/EFF/compute_temp_deform_eff.cpp index 6476c78039..292bf64d7b 100644 --- a/src/EFF/compute_temp_deform_eff.cpp +++ b/src/EFF/compute_temp_deform_eff.cpp @@ -74,7 +74,7 @@ void ComputeTempDeformEff::init() int i; for (i = 0; i < modify->nfix; i++) if (strcmp(modify->fix[i]->style,"deform") == 0) { - if (((FixDeform *) modify->fix[i])->remapflag == Domain::X_REMAP && + if ((dynamic_cast( modify->fix[i]))->remapflag == Domain::X_REMAP && comm->me == 0) error->warning(FLERR,"Using compute temp/deform/eff with inconsistent " "fix deform remap option"); diff --git a/src/EFF/fix_nve_eff.cpp b/src/EFF/fix_nve_eff.cpp index ed640990ca..6639197285 100644 --- a/src/EFF/fix_nve_eff.cpp +++ b/src/EFF/fix_nve_eff.cpp @@ -59,7 +59,7 @@ void FixNVEEff::init() dtf = 0.5 * update->dt * force->ftm2v; if (utils::strmatch(update->integrate_style,"^respa")) - step_respa = ((Respa *) update->integrate)->step; + step_respa = (dynamic_cast( update->integrate))->step; } /* ---------------------------------------------------------------------- diff --git a/src/EFF/fix_nvt_sllod_eff.cpp b/src/EFF/fix_nvt_sllod_eff.cpp index 8e3f7cd72d..c4cc2de87f 100644 --- a/src/EFF/fix_nvt_sllod_eff.cpp +++ b/src/EFF/fix_nvt_sllod_eff.cpp @@ -70,7 +70,7 @@ void FixNVTSllodEff::init() int i; for (i = 0; i < modify->nfix; i++) if (strncmp(modify->fix[i]->style,"deform",6) == 0) { - if (((FixDeform *) modify->fix[i])->remapflag != Domain::V_REMAP) + if ((dynamic_cast( modify->fix[i]))->remapflag != Domain::V_REMAP) error->all(FLERR,"Using fix nvt/sllod/eff with inconsistent fix deform " "remap option"); break; diff --git a/src/EXTRA-COMPUTE/compute_hma.cpp b/src/EXTRA-COMPUTE/compute_hma.cpp index 2f11e91ec4..bb182de7af 100644 --- a/src/EXTRA-COMPUTE/compute_hma.cpp +++ b/src/EXTRA-COMPUTE/compute_hma.cpp @@ -90,8 +90,8 @@ ComputeHMA::ComputeHMA(LAMMPS *lmp, int narg, char **arg) : // our new fix's group = same as compute group id_fix = utils::strdup(std::string(id)+"_COMPUTE_STORE"); - fix = (FixStore *)modify->add_fix(fmt::format("{} {} STORE peratom 1 3", - id_fix, group->names[igroup])); + fix = dynamic_cast(modify->add_fix(fmt::format("{} {} STORE peratom 1 3", + id_fix, group->names[igroup]))); // calculate xu,yu,zu for fix store array // skip if reset from restart file diff --git a/src/EXTRA-FIX/fix_addtorque.cpp b/src/EXTRA-FIX/fix_addtorque.cpp index 7c8e832673..eb95db52b0 100644 --- a/src/EXTRA-FIX/fix_addtorque.cpp +++ b/src/EXTRA-FIX/fix_addtorque.cpp @@ -130,7 +130,7 @@ void FixAddTorque::init() else varflag = CONSTANT; if (utils::strmatch(update->integrate_style,"^respa")) { - ilevel_respa = ((Respa *) update->integrate)->nlevels-1; + ilevel_respa = (dynamic_cast( update->integrate))->nlevels-1; if (respa_level >= 0) ilevel_respa = MIN(respa_level,ilevel_respa); } } @@ -142,9 +142,9 @@ void FixAddTorque::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(ilevel_respa); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel_respa); post_force_respa(vflag,ilevel_respa,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel_respa); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel_respa); } } diff --git a/src/EXTRA-FIX/fix_drag.cpp b/src/EXTRA-FIX/fix_drag.cpp index 69aa104d52..48977a0cd1 100644 --- a/src/EXTRA-FIX/fix_drag.cpp +++ b/src/EXTRA-FIX/fix_drag.cpp @@ -71,7 +71,7 @@ int FixDrag::setmask() void FixDrag::init() { if (utils::strmatch(update->integrate_style,"^respa")) { - ilevel_respa = ((Respa *) update->integrate)->nlevels-1; + ilevel_respa = (dynamic_cast( update->integrate))->nlevels-1; if (respa_level >= 0) ilevel_respa = MIN(respa_level,ilevel_respa); } } @@ -83,9 +83,9 @@ void FixDrag::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(ilevel_respa); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel_respa); post_force_respa(vflag,ilevel_respa,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel_respa); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel_respa); } } diff --git a/src/EXTRA-FIX/fix_electron_stopping_fit.cpp b/src/EXTRA-FIX/fix_electron_stopping_fit.cpp index 35ead3397c..0e0ccc0ebb 100644 --- a/src/EXTRA-FIX/fix_electron_stopping_fit.cpp +++ b/src/EXTRA-FIX/fix_electron_stopping_fit.cpp @@ -139,9 +139,9 @@ void FixElectronStoppingFit::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_flevel_f(nlevels_respa-1); post_force_respa(vflag,nlevels_respa-1,0); - ((Respa *) update->integrate)->copy_f_flevel(nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_f_flevel(nlevels_respa-1); }; }; diff --git a/src/EXTRA-FIX/fix_ffl.cpp b/src/EXTRA-FIX/fix_ffl.cpp index 9cc9d4e179..6e08ae6c79 100644 --- a/src/EXTRA-FIX/fix_ffl.cpp +++ b/src/EXTRA-FIX/fix_ffl.cpp @@ -158,8 +158,8 @@ void FixFFL::init() { } if (utils::strmatch(update->integrate_style,"^respa")) { - nlevels_respa = ((Respa *) update->integrate)->nlevels; - step_respa = ((Respa *) update->integrate)->step; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; + step_respa = (dynamic_cast( update->integrate))->step; } init_ffl(); @@ -182,9 +182,9 @@ void FixFFL::setup(int vflag) { if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_flevel_f(nlevels_respa-1); post_force_respa(vflag,nlevels_respa-1,0); - ((Respa *) update->integrate)->copy_f_flevel(nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_f_flevel(nlevels_respa-1); } } diff --git a/src/EXTRA-FIX/fix_filter_corotate.cpp b/src/EXTRA-FIX/fix_filter_corotate.cpp index 08485ddad3..e2bd982617 100644 --- a/src/EXTRA-FIX/fix_filter_corotate.cpp +++ b/src/EXTRA-FIX/fix_filter_corotate.cpp @@ -279,7 +279,7 @@ void FixFilterCorotate::init() // set ptrs to rRESPA variables if (utils::strmatch(update->integrate_style,"^respa")) { - nlevels_respa = ((Respa *) update->integrate)->nlevels; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; } else error->all(FLERR,"Fix filter/corotate requires rRESPA!"); @@ -656,9 +656,9 @@ void FixFilterCorotate::pre_neighbor() void FixFilterCorotate::setup(int vflag) { - ((Respa *) update->integrate)->copy_flevel_f(nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_flevel_f(nlevels_respa-1); post_force_respa(vflag,nlevels_respa-1,0); - ((Respa *) update->integrate)->copy_f_flevel(nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_f_flevel(nlevels_respa-1); } void FixFilterCorotate::setup_pre_force_respa(int vflag,int ilevel) { diff --git a/src/EXTRA-FIX/fix_flow_gauss.cpp b/src/EXTRA-FIX/fix_flow_gauss.cpp index 2f8de2e21a..a1238ea748 100644 --- a/src/EXTRA-FIX/fix_flow_gauss.cpp +++ b/src/EXTRA-FIX/fix_flow_gauss.cpp @@ -123,7 +123,7 @@ void FixFlowGauss::init() //if respa level specified by fix_modify, then override default (outermost) //if specified level too high, set to max level if (utils::strmatch(update->integrate_style,"^respa")) { - ilevel_respa = ((Respa *) update->integrate)->nlevels-1; + ilevel_respa = (dynamic_cast( update->integrate))->nlevels-1; if (respa_level >= 0) ilevel_respa = MIN(respa_level,ilevel_respa); } @@ -146,9 +146,9 @@ void FixFlowGauss::setup(int vflag) error->all(FLERR,"Invalid group mass in fix flow/gauss"); if (utils::strmatch(update->integrate_style,"^respa")) { - ((Respa *) update->integrate)->copy_flevel_f(ilevel_respa); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel_respa); post_force_respa(vflag,ilevel_respa,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel_respa); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel_respa); } else post_force(vflag); diff --git a/src/EXTRA-FIX/fix_gld.cpp b/src/EXTRA-FIX/fix_gld.cpp index 41585e4fd0..b183526d65 100644 --- a/src/EXTRA-FIX/fix_gld.cpp +++ b/src/EXTRA-FIX/fix_gld.cpp @@ -197,7 +197,7 @@ void FixGLD::init() dtf = 0.5 * update->dt * force->ftm2v; if (utils::strmatch(update->integrate_style,"^respa")) - step_respa = ((Respa *) update->integrate)->step; + step_respa = (dynamic_cast( update->integrate))->step; } /* ---------------------------------------------------------------------- diff --git a/src/EXTRA-FIX/fix_gle.cpp b/src/EXTRA-FIX/fix_gle.cpp index 065749e4d2..1d07b05d91 100644 --- a/src/EXTRA-FIX/fix_gle.cpp +++ b/src/EXTRA-FIX/fix_gle.cpp @@ -356,8 +356,8 @@ void FixGLE::init() } if (utils::strmatch(update->integrate_style,"^respa")) { - nlevels_respa = ((Respa *) update->integrate)->nlevels; - step_respa = ((Respa *) update->integrate)->step; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; + step_respa = (dynamic_cast( update->integrate))->step; } init_gle(); @@ -444,9 +444,9 @@ void FixGLE::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_flevel_f(nlevels_respa-1); post_force_respa(vflag,nlevels_respa-1,0); - ((Respa *) update->integrate)->copy_f_flevel(nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_f_flevel(nlevels_respa-1); } } diff --git a/src/EXTRA-FIX/fix_momentum_chunk.cpp b/src/EXTRA-FIX/fix_momentum_chunk.cpp index 06d2137d84..2734a4565b 100644 --- a/src/EXTRA-FIX/fix_momentum_chunk.cpp +++ b/src/EXTRA-FIX/fix_momentum_chunk.cpp @@ -110,7 +110,7 @@ void FixMomentumChunk::init() int icompute = modify->find_compute(id_chunk); if (icompute < 0) error->all(FLERR,"Chunk/atom compute does not exist for fix momentum/chunk"); - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); if (strcmp(cchunk->style,"chunk/atom") != 0) error->all(FLERR,"Fix momentum/chunk does not use chunk/atom compute"); @@ -122,7 +122,7 @@ void FixMomentumChunk::init() auto cmd = fmt::format("{} {} com/chunk {}",id_com,group->names[igroup],id_chunk); modify->add_compute(cmd); icompute = modify->find_compute(id_com); - ccom = (ComputeCOMChunk *) modify->compute[icompute]; + ccom = dynamic_cast( modify->compute[icompute]); id_vcm = id + id_chunk + "_vcm"; icompute = modify->find_compute(id_vcm); diff --git a/src/EXTRA-FIX/fix_npt_cauchy.cpp b/src/EXTRA-FIX/fix_npt_cauchy.cpp index 12a197fdd1..4a1e11d963 100644 --- a/src/EXTRA-FIX/fix_npt_cauchy.cpp +++ b/src/EXTRA-FIX/fix_npt_cauchy.cpp @@ -681,7 +681,7 @@ void FixNPTCauchy::init() if (pstat_flag) for (int i = 0; i < modify->nfix; i++) if (strcmp(modify->fix[i]->style,"deform") == 0) { - int *dimflag = ((FixDeform *) modify->fix[i])->dimflag; + int *dimflag = (dynamic_cast( modify->fix[i]))->dimflag; if ((p_flag[0] && dimflag[0]) || (p_flag[1] && dimflag[1]) || (p_flag[2] && dimflag[2]) || (p_flag[3] && dimflag[3]) || (p_flag[4] && dimflag[4]) || (p_flag[5] && dimflag[5])) @@ -754,8 +754,8 @@ void FixNPTCauchy::init() else kspace_flag = 0; if (utils::strmatch(update->integrate_style,"^respa")) { - nlevels_respa = ((Respa *) update->integrate)->nlevels; - step_respa = ((Respa *) update->integrate)->step; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; + step_respa = (dynamic_cast( update->integrate))->step; dto = 0.5*step_respa[0]; } @@ -2466,7 +2466,7 @@ void FixNPTCauchy::CauchyStat_init() modify->add_fix(std::string(id_store) + " all STORE global 1 6"); restart_stored = modify->find_fix(id_store); } - init_store = (FixStore *)modify->fix[restart_stored]; + init_store = dynamic_cast(modify->fix[restart_stored]); initRUN = 0; initPK = 1; diff --git a/src/EXTRA-FIX/fix_numdiff.cpp b/src/EXTRA-FIX/fix_numdiff.cpp index 7265ec0b79..c092bd6375 100644 --- a/src/EXTRA-FIX/fix_numdiff.cpp +++ b/src/EXTRA-FIX/fix_numdiff.cpp @@ -122,7 +122,7 @@ void FixNumDiff::init() kspace_compute_flag = 0; if (utils::strmatch(update->integrate_style, "^respa")) { - ilevel_respa = ((Respa *) update->integrate)->nlevels - 1; + ilevel_respa = (dynamic_cast( update->integrate))->nlevels - 1; if (respa_level >= 0) ilevel_respa = MIN(respa_level, ilevel_respa); } } @@ -134,9 +134,9 @@ void FixNumDiff::setup(int vflag) if (utils::strmatch(update->integrate_style, "^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(ilevel_respa); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel_respa); post_force_respa(vflag, ilevel_respa, 0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel_respa); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel_respa); } } diff --git a/src/EXTRA-FIX/fix_numdiff_virial.cpp b/src/EXTRA-FIX/fix_numdiff_virial.cpp index a87be67c89..c34b3a8b1a 100644 --- a/src/EXTRA-FIX/fix_numdiff_virial.cpp +++ b/src/EXTRA-FIX/fix_numdiff_virial.cpp @@ -132,7 +132,7 @@ void FixNumDiffVirial::init() kspace_compute_flag = 0; if (utils::strmatch(update->integrate_style, "^respa")) { - ilevel_respa = ((Respa *) update->integrate)->nlevels - 1; + ilevel_respa = (dynamic_cast( update->integrate))->nlevels - 1; if (respa_level >= 0) ilevel_respa = MIN(respa_level, ilevel_respa); } } @@ -144,9 +144,9 @@ void FixNumDiffVirial::setup(int vflag) if (utils::strmatch(update->integrate_style, "^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(ilevel_respa); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel_respa); post_force_respa(vflag, ilevel_respa, 0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel_respa); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel_respa); } } diff --git a/src/EXTRA-FIX/fix_nvk.cpp b/src/EXTRA-FIX/fix_nvk.cpp index 1f4c76febc..168af71262 100644 --- a/src/EXTRA-FIX/fix_nvk.cpp +++ b/src/EXTRA-FIX/fix_nvk.cpp @@ -62,7 +62,7 @@ void FixNVK::init() if (utils::strmatch(update->integrate_style,"^respa")) { error->all(FLERR,"Fix nvk not yet enabled for RESPA"); - step_respa = ((Respa *) update->integrate)->step; + step_respa = (dynamic_cast( update->integrate))->step; } // compute initial kinetic energy diff --git a/src/EXTRA-FIX/fix_pafi.cpp b/src/EXTRA-FIX/fix_pafi.cpp index fbb6fb2971..d6ee4627c9 100644 --- a/src/EXTRA-FIX/fix_pafi.cpp +++ b/src/EXTRA-FIX/fix_pafi.cpp @@ -178,8 +178,8 @@ void FixPAFI::init() if (utils::strmatch(update->integrate_style,"^respa")) { - step_respa = ((Respa *) update->integrate)->step; // nve - nlevels_respa = ((Respa *) update->integrate)->nlevels; + step_respa = (dynamic_cast( update->integrate))->step; // nve + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; if (respa_level >= 0) ilevel_respa = MIN(respa_level,nlevels_respa-1); else ilevel_respa = nlevels_respa-1; } @@ -192,9 +192,9 @@ void FixPAFI::setup(int vflag) post_force(vflag); else for (int ilevel = 0; ilevel < nlevels_respa; ilevel++) { - ((Respa *) update->integrate)->copy_flevel_f(ilevel); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel); post_force_respa(vflag,ilevel,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel); } } diff --git a/src/EXTRA-FIX/fix_rhok.cpp b/src/EXTRA-FIX/fix_rhok.cpp index 5c49878998..9bdf940a7b 100644 --- a/src/EXTRA-FIX/fix_rhok.cpp +++ b/src/EXTRA-FIX/fix_rhok.cpp @@ -96,7 +96,7 @@ void FixRhok::init() { // RESPA boilerplate if (utils::strmatch(update->integrate_style,"^respa")) - mNLevelsRESPA = ((Respa *) update->integrate)->nlevels; + mNLevelsRESPA = (dynamic_cast( update->integrate))->nlevels; // Count the number of affected particles int nThisLocal = 0; @@ -121,9 +121,9 @@ void FixRhok::setup( int inVFlag ) post_force( inVFlag ); else { - ((Respa *) update->integrate)->copy_flevel_f( mNLevelsRESPA - 1 ); + (dynamic_cast( update->integrate))->copy_flevel_f( mNLevelsRESPA - 1 ); post_force_respa( inVFlag, mNLevelsRESPA - 1,0 ); - ((Respa *) update->integrate)->copy_f_flevel( mNLevelsRESPA - 1 ); + (dynamic_cast( update->integrate))->copy_f_flevel( mNLevelsRESPA - 1 ); } } diff --git a/src/EXTRA-FIX/fix_smd.cpp b/src/EXTRA-FIX/fix_smd.cpp index d581744f31..4a0a9f040f 100644 --- a/src/EXTRA-FIX/fix_smd.cpp +++ b/src/EXTRA-FIX/fix_smd.cpp @@ -161,7 +161,7 @@ void FixSMD::init() } if (utils::strmatch(update->integrate_style,"^respa")) { - ilevel_respa = ((Respa *) update->integrate)->nlevels-1; + ilevel_respa = (dynamic_cast( update->integrate))->nlevels-1; if (respa_level >= 0) ilevel_respa = MIN(respa_level,ilevel_respa); } } @@ -173,9 +173,9 @@ void FixSMD::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(ilevel_respa); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel_respa); post_force_respa(vflag,ilevel_respa,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel_respa); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel_respa); } } @@ -194,7 +194,7 @@ void FixSMD::post_force(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) r_old += v_smd * update->dt; else - r_old += v_smd * ((Respa *) update->integrate)->step[ilevel_respa]; + r_old += v_smd * (dynamic_cast( update->integrate))->step[ilevel_respa]; } } @@ -207,7 +207,7 @@ void FixSMD::smd_tether() double dt = update->dt; if (utils::strmatch(update->integrate_style,"^respa")) - dt = ((Respa *) update->integrate)->step[ilevel_respa]; + dt = (dynamic_cast( update->integrate))->step[ilevel_respa]; // fx,fy,fz = components of k * (r-r0) @@ -313,7 +313,7 @@ void FixSMD::smd_couple() double dt = update->dt; if (utils::strmatch(update->integrate_style,"^respa")) - dt = ((Respa *) update->integrate)->step[ilevel_respa]; + dt = (dynamic_cast( update->integrate))->step[ilevel_respa]; // renormalize direction of spring double dx,dy,dz,r,dr; diff --git a/src/EXTRA-FIX/fix_spring_rg.cpp b/src/EXTRA-FIX/fix_spring_rg.cpp index d10c60c07f..b955716923 100644 --- a/src/EXTRA-FIX/fix_spring_rg.cpp +++ b/src/EXTRA-FIX/fix_spring_rg.cpp @@ -79,7 +79,7 @@ void FixSpringRG::init() } if (utils::strmatch(update->integrate_style,"^respa")) { - ilevel_respa = ((Respa *) update->integrate)->nlevels-1; + ilevel_respa = (dynamic_cast( update->integrate))->nlevels-1; if (respa_level >= 0) ilevel_respa = MIN(respa_level,ilevel_respa); } } @@ -91,9 +91,9 @@ void FixSpringRG::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(ilevel_respa); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel_respa); post_force_respa(vflag,ilevel_respa,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel_respa); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel_respa); } } diff --git a/src/EXTRA-FIX/fix_ti_spring.cpp b/src/EXTRA-FIX/fix_ti_spring.cpp index 231da9e8ee..b332c18148 100644 --- a/src/EXTRA-FIX/fix_ti_spring.cpp +++ b/src/EXTRA-FIX/fix_ti_spring.cpp @@ -143,7 +143,7 @@ int FixTISpring::setmask() void FixTISpring::init() { if (utils::strmatch(update->integrate_style,"^respa")) - nlevels_respa = ((Respa *) update->integrate)->nlevels; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; } /* ---------------------------------------------------------------------- */ @@ -153,9 +153,9 @@ void FixTISpring::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_flevel_f(nlevels_respa-1); post_force_respa(vflag,nlevels_respa-1,0); - ((Respa *) update->integrate)->copy_f_flevel(nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_f_flevel(nlevels_respa-1); } } diff --git a/src/EXTRA-FIX/fix_tmd.cpp b/src/EXTRA-FIX/fix_tmd.cpp index df26f01e34..1404682cda 100644 --- a/src/EXTRA-FIX/fix_tmd.cpp +++ b/src/EXTRA-FIX/fix_tmd.cpp @@ -167,7 +167,7 @@ void FixTMD::init() dtv = update->dt; dtf = update->dt * force->ftm2v; if (utils::strmatch(update->integrate_style,"^respa")) - step_respa = ((Respa *) update->integrate)->step; + step_respa = (dynamic_cast( update->integrate))->step; } /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-FIX/fix_ttm.cpp b/src/EXTRA-FIX/fix_ttm.cpp index f06a0f64c6..9184983bdb 100644 --- a/src/EXTRA-FIX/fix_ttm.cpp +++ b/src/EXTRA-FIX/fix_ttm.cpp @@ -241,7 +241,7 @@ void FixTTM::init() } if (utils::strmatch(update->integrate_style,"^respa")) - nlevels_respa = ((Respa *) update->integrate)->nlevels; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; } /* ---------------------------------------------------------------------- */ @@ -251,9 +251,9 @@ void FixTTM::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) { post_force_setup(vflag); } else { - ((Respa *) update->integrate)->copy_flevel_f(nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_flevel_f(nlevels_respa-1); post_force_respa_setup(vflag,nlevels_respa-1,0); - ((Respa *) update->integrate)->copy_f_flevel(nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_f_flevel(nlevels_respa-1); } } diff --git a/src/EXTRA-FIX/fix_ttm_mod.cpp b/src/EXTRA-FIX/fix_ttm_mod.cpp index 549e83f87c..18d163bd10 100644 --- a/src/EXTRA-FIX/fix_ttm_mod.cpp +++ b/src/EXTRA-FIX/fix_ttm_mod.cpp @@ -271,7 +271,7 @@ void FixTTMMod::init() net_energy_transfer_all[ix][iy][iz] = 0; if (utils::strmatch(update->integrate_style,"^respa")) - nlevels_respa = ((Respa *) update->integrate)->nlevels; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; } /* ---------------------------------------------------------------------- */ @@ -281,9 +281,9 @@ void FixTTMMod::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) { post_force_setup(vflag); } else { - ((Respa *) update->integrate)->copy_flevel_f(nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_flevel_f(nlevels_respa-1); post_force_respa_setup(vflag,nlevels_respa-1,0); - ((Respa *) update->integrate)->copy_f_flevel(nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_f_flevel(nlevels_respa-1); } } diff --git a/src/EXTRA-FIX/fix_viscous_sphere.cpp b/src/EXTRA-FIX/fix_viscous_sphere.cpp index e0a4f910ed..cb5344076e 100644 --- a/src/EXTRA-FIX/fix_viscous_sphere.cpp +++ b/src/EXTRA-FIX/fix_viscous_sphere.cpp @@ -114,7 +114,7 @@ void FixViscousSphere::init() int max_respa = 0; if (utils::strmatch(update->integrate_style, "^respa")) { - ilevel_respa = max_respa = ((Respa *) update->integrate)->nlevels - 1; + ilevel_respa = max_respa = (dynamic_cast( update->integrate))->nlevels - 1; if (respa_level >= 0) ilevel_respa = MIN(respa_level, max_respa); } @@ -135,9 +135,9 @@ void FixViscousSphere::setup(int vflag) if (utils::strmatch(update->integrate_style, "^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(ilevel_respa); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel_respa); post_force_respa(vflag, ilevel_respa, 0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel_respa); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel_respa); } } diff --git a/src/EXTRA-FIX/fix_wall_ees.cpp b/src/EXTRA-FIX/fix_wall_ees.cpp index 26ed4f52f1..8b30e4a0be 100644 --- a/src/EXTRA-FIX/fix_wall_ees.cpp +++ b/src/EXTRA-FIX/fix_wall_ees.cpp @@ -50,7 +50,7 @@ void FixWallEES::precompute(int m) /* ---------------------------------------------------------------------- */ void FixWallEES::init() { - avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); + avec = dynamic_cast( atom->style_match("ellipsoid")); if (!avec) error->all(FLERR,"Fix wall/ees requires atom style ellipsoid"); @@ -85,7 +85,7 @@ void FixWallEES::wall_particle(int m, int which, double coord) double **f = atom->f; double **tor = atom->torque; - avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); + avec = dynamic_cast( atom->style_match("ellipsoid")); AtomVecEllipsoid::Bonus *bonus = avec->bonus; int *ellipsoid = atom->ellipsoid; int *mask = atom->mask; diff --git a/src/EXTRA-FIX/fix_wall_region_ees.cpp b/src/EXTRA-FIX/fix_wall_region_ees.cpp index 261036333e..eb1ede5c4a 100644 --- a/src/EXTRA-FIX/fix_wall_region_ees.cpp +++ b/src/EXTRA-FIX/fix_wall_region_ees.cpp @@ -91,7 +91,7 @@ void FixWallRegionEES::init() if (iregion == -1) error->all(FLERR,"Region ID for fix wall/region/ees does not exist"); - avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); + avec = dynamic_cast( atom->style_match("ellipsoid")); if (!avec) error->all(FLERR,"Fix wall/region/ees requires atom style ellipsoid"); @@ -119,7 +119,7 @@ void FixWallRegionEES::init() if (utils::strmatch(update->integrate_style,"^respa")) - nlevels_respa = ((Respa *) update->integrate)->nlevels; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; } /* ---------------------------------------------------------------------- */ @@ -129,9 +129,9 @@ void FixWallRegionEES::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_flevel_f(nlevels_respa-1); post_force_respa(vflag,nlevels_respa-1,0); - ((Respa *) update->integrate)->copy_f_flevel(nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_f_flevel(nlevels_respa-1); } } diff --git a/src/EXTRA-PAIR/pair_lj96_cut.cpp b/src/EXTRA-PAIR/pair_lj96_cut.cpp index 28038ea396..778dfbb562 100644 --- a/src/EXTRA-PAIR/pair_lj96_cut.cpp +++ b/src/EXTRA-PAIR/pair_lj96_cut.cpp @@ -487,7 +487,7 @@ void PairLJ96Cut::init_style() int list_style = NeighConst::REQ_DEFAULT; if (update->whichflag == 1 && utils::strmatch(update->integrate_style, "^respa")) { - auto respa = (Respa *) update->integrate; + auto respa = dynamic_cast( update->integrate); if (respa->level_inner >= 0) list_style = NeighConst::REQ_RESPA_INOUT; if (respa->level_middle >= 0) list_style = NeighConst::REQ_RESPA_ALL; } @@ -496,8 +496,8 @@ void PairLJ96Cut::init_style() // set rRESPA cutoffs if (utils::strmatch(update->integrate_style,"^respa") && - ((Respa *) update->integrate)->level_inner >= 0) - cut_respa = ((Respa *) update->integrate)->cutoff; + (dynamic_cast( update->integrate))->level_inner >= 0) + cut_respa = (dynamic_cast( update->integrate))->cutoff; else cut_respa = nullptr; } diff --git a/src/EXTRA-PAIR/pair_lj_expand_coul_long.cpp b/src/EXTRA-PAIR/pair_lj_expand_coul_long.cpp index 5d5ceff1e5..a62aabf3a5 100644 --- a/src/EXTRA-PAIR/pair_lj_expand_coul_long.cpp +++ b/src/EXTRA-PAIR/pair_lj_expand_coul_long.cpp @@ -688,7 +688,7 @@ void PairLJExpandCoulLong::init_style() int list_style = NeighConst::REQ_DEFAULT; if (update->whichflag == 1 && utils::strmatch(update->integrate_style, "^respa")) { - auto respa = (Respa *) update->integrate; + auto respa = dynamic_cast( update->integrate); if (respa->level_inner >= 0) list_style = NeighConst::REQ_RESPA_INOUT; if (respa->level_middle >= 0) list_style = NeighConst::REQ_RESPA_ALL; } @@ -699,8 +699,8 @@ void PairLJExpandCoulLong::init_style() // set rRESPA cutoffs if (utils::strmatch(update->integrate_style,"^respa") && - ((Respa *) update->integrate)->level_inner >= 0) - cut_respa = ((Respa *) update->integrate)->cutoff; + (dynamic_cast( update->integrate))->level_inner >= 0) + cut_respa = (dynamic_cast( update->integrate))->cutoff; else cut_respa = nullptr; // insure use of KSpace long-range solver, set g_ewald diff --git a/src/EXTRA-PAIR/pair_mie_cut.cpp b/src/EXTRA-PAIR/pair_mie_cut.cpp index 729cac8ff8..dff41ce81b 100644 --- a/src/EXTRA-PAIR/pair_mie_cut.cpp +++ b/src/EXTRA-PAIR/pair_mie_cut.cpp @@ -499,7 +499,7 @@ void PairMIECut::init_style() int list_style = NeighConst::REQ_DEFAULT; if (update->whichflag == 1 && utils::strmatch(update->integrate_style, "^respa")) { - auto respa = (Respa *) update->integrate; + auto respa = dynamic_cast( update->integrate); if (respa->level_inner >= 0) list_style = NeighConst::REQ_RESPA_INOUT; if (respa->level_middle >= 0) list_style = NeighConst::REQ_RESPA_ALL; } @@ -508,8 +508,8 @@ void PairMIECut::init_style() // set rRESPA cutoffs if (utils::strmatch(update->integrate_style,"^respa") && - ((Respa *) update->integrate)->level_inner >= 0) - cut_respa = ((Respa *) update->integrate)->cutoff; + (dynamic_cast( update->integrate))->level_inner >= 0) + cut_respa = (dynamic_cast( update->integrate))->cutoff; else cut_respa = nullptr; } diff --git a/src/FEP/compute_fep.cpp b/src/FEP/compute_fep.cpp index 8b062d2c4a..f3ee1f3c4b 100644 --- a/src/FEP/compute_fep.cpp +++ b/src/FEP/compute_fep.cpp @@ -213,7 +213,7 @@ void ComputeFEP::init() if ((strcmp(force->pair_style, "hybrid") == 0 || strcmp(force->pair_style, "hybrid/overlay") == 0)) { - PairHybrid *pair = (PairHybrid *) force->pair; + auto pair = dynamic_cast( force->pair); for (i = pert->ilo; i <= pert->ihi; i++) for (j = MAX(pert->jlo, i); j <= pert->jhi; j++) if (!pair->check_ijtype(i, j, pert->pstyle)) diff --git a/src/FEP/fix_adapt_fep.cpp b/src/FEP/fix_adapt_fep.cpp index d43c053b9a..090931ae31 100644 --- a/src/FEP/fix_adapt_fep.cpp +++ b/src/FEP/fix_adapt_fep.cpp @@ -211,7 +211,7 @@ void FixAdaptFEP::post_constructor() if (diamflag) { auto cmd = fmt::format("{}_FIX_STORE_DIAM {} STORE peratom 1 1", group->names[igroup]); - fix_diam = (FixStore *) modify->add_fix(cmd); + fix_diam = dynamic_cast( modify->add_fix(cmd)); if (fix_diam->restart_reset) fix_diam->restart_reset = 0; else { @@ -229,7 +229,7 @@ void FixAdaptFEP::post_constructor() if (chgflag) { auto cmd = fmt::format("{}_FIX_STORE_CHG {} STORE peratom 1 1", group->names[igroup]); - fix_chg = (FixStore *) modify->add_fix(cmd); + fix_chg = dynamic_cast( modify->add_fix(cmd)); if (fix_chg->restart_reset) fix_chg->restart_reset = 0; else { @@ -294,7 +294,7 @@ void FixAdaptFEP::init() if (ad->pdim == 2 && (strcmp(force->pair_style,"hybrid") == 0 || strcmp(force->pair_style,"hybrid/overlay") == 0)) { - PairHybrid *pair = (PairHybrid *) force->pair; + auto pair = dynamic_cast( force->pair); for (i = ad->ilo; i <= ad->ihi; i++) for (j = MAX(ad->jlo,i); j <= ad->jhi; j++) if (!pair->check_ijtype(i,j,ad->pstyle)) @@ -335,16 +335,16 @@ void FixAdaptFEP::init() if (id_fix_diam) { int ifix = modify->find_fix(id_fix_diam); if (ifix < 0) error->all(FLERR,"Could not find fix adapt storage fix ID"); - fix_diam = (FixStore *) modify->fix[ifix]; + fix_diam = dynamic_cast( modify->fix[ifix]); } if (id_fix_chg) { int ifix = modify->find_fix(id_fix_chg); if (ifix < 0) error->all(FLERR,"Could not find fix adapt storage fix ID"); - fix_chg = (FixStore *) modify->fix[ifix]; + fix_chg = dynamic_cast( modify->fix[ifix]); } if (utils::strmatch(update->integrate_style,"^respa")) - nlevels_respa = ((Respa *) update->integrate)->nlevels; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; } /* ---------------------------------------------------------------------- */ diff --git a/src/FEP/pair_lj_charmm_coul_long_soft.cpp b/src/FEP/pair_lj_charmm_coul_long_soft.cpp index 86681cf51f..119c545579 100644 --- a/src/FEP/pair_lj_charmm_coul_long_soft.cpp +++ b/src/FEP/pair_lj_charmm_coul_long_soft.cpp @@ -692,7 +692,7 @@ void PairLJCharmmCoulLongSoft::init_style() int list_style = NeighConst::REQ_DEFAULT; if (update->whichflag == 1 && utils::strmatch(update->integrate_style, "^respa")) { - auto respa = (Respa *) update->integrate; + auto respa = dynamic_cast( update->integrate); if (respa->level_inner >= 0) list_style = NeighConst::REQ_RESPA_INOUT; if (respa->level_middle >= 0) list_style = NeighConst::REQ_RESPA_ALL; } @@ -714,8 +714,8 @@ void PairLJCharmmCoulLongSoft::init_style() // set & error check interior rRESPA cutoffs if (utils::strmatch(update->integrate_style,"^respa") && - ((Respa *) update->integrate)->level_inner >= 0) { - cut_respa = ((Respa *) update->integrate)->cutoff; + (dynamic_cast( update->integrate))->level_inner >= 0) { + cut_respa = (dynamic_cast( update->integrate))->cutoff; if (MIN(cut_lj,cut_coul) < cut_respa[3]) error->all(FLERR,"Pair cutoff < Respa interior cutoff"); if (cut_lj_inner < cut_respa[1]) diff --git a/src/FEP/pair_lj_cut_coul_long_soft.cpp b/src/FEP/pair_lj_cut_coul_long_soft.cpp index 7fdc431c61..d3e0ca8a88 100644 --- a/src/FEP/pair_lj_cut_coul_long_soft.cpp +++ b/src/FEP/pair_lj_cut_coul_long_soft.cpp @@ -635,7 +635,7 @@ void PairLJCutCoulLongSoft::init_style() int list_style = NeighConst::REQ_DEFAULT; if (update->whichflag == 1 && utils::strmatch(update->integrate_style, "^respa")) { - auto respa = (Respa *) update->integrate; + auto respa = dynamic_cast( update->integrate); if (respa->level_inner >= 0) list_style = NeighConst::REQ_RESPA_INOUT; if (respa->level_middle >= 0) list_style = NeighConst::REQ_RESPA_ALL; } @@ -646,8 +646,8 @@ void PairLJCutCoulLongSoft::init_style() // set rRESPA cutoffs if (utils::strmatch(update->integrate_style,"^respa") && - ((Respa *) update->integrate)->level_inner >= 0) - cut_respa = ((Respa *) update->integrate)->cutoff; + (dynamic_cast( update->integrate))->level_inner >= 0) + cut_respa = (dynamic_cast( update->integrate))->cutoff; else cut_respa = nullptr; // insure use of KSpace long-range solver, set g_ewald diff --git a/src/FEP/pair_lj_cut_soft.cpp b/src/FEP/pair_lj_cut_soft.cpp index cf0a5df644..8cf61f013c 100644 --- a/src/FEP/pair_lj_cut_soft.cpp +++ b/src/FEP/pair_lj_cut_soft.cpp @@ -513,7 +513,7 @@ void PairLJCutSoft::init_style() int list_style = NeighConst::REQ_DEFAULT; if (update->whichflag == 1 && utils::strmatch(update->integrate_style, "^respa")) { - auto respa = (Respa *) update->integrate; + auto respa = dynamic_cast( update->integrate); if (respa->level_inner >= 0) list_style = NeighConst::REQ_RESPA_INOUT; if (respa->level_middle >= 0) list_style = NeighConst::REQ_RESPA_ALL; } @@ -522,8 +522,8 @@ void PairLJCutSoft::init_style() // set rRESPA cutoffs if (utils::strmatch(update->integrate_style,"^respa") && - ((Respa *) update->integrate)->level_inner >= 0) - cut_respa = ((Respa *) update->integrate)->cutoff; + (dynamic_cast( update->integrate))->level_inner >= 0) + cut_respa = (dynamic_cast( update->integrate))->cutoff; else cut_respa = nullptr; } diff --git a/src/GPU/fix_gpu.cpp b/src/GPU/fix_gpu.cpp index 808d435016..85b4f8e0e9 100644 --- a/src/GPU/fix_gpu.cpp +++ b/src/GPU/fix_gpu.cpp @@ -275,7 +275,7 @@ void FixGPU::init() // also disallow GPU neighbor lists for hybrid styles if (force->pair_match("^hybrid",0) != nullptr) { - PairHybrid *hybrid = (PairHybrid *) force->pair; + auto hybrid = dynamic_cast( force->pair); for (int i = 0; i < hybrid->nstyles; i++) if (!utils::strmatch(hybrid->keywords[i],"/gpu$")) force->pair->no_virial_fdotr_compute = 1; @@ -286,7 +286,7 @@ void FixGPU::init() // rRESPA support if (utils::strmatch(update->integrate_style,"^respa")) - _nlevels_respa = ((Respa *) update->integrate)->nlevels; + _nlevels_respa = (dynamic_cast( update->integrate))->nlevels; } /* ---------------------------------------------------------------------- */ @@ -300,9 +300,9 @@ void FixGPU::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { // In setup only, all forces calculated on GPU are put in the outer level - ((Respa *) update->integrate)->copy_flevel_f(_nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_flevel_f(_nlevels_respa-1); post_force(vflag); - ((Respa *) update->integrate)->copy_f_flevel(_nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_f_flevel(_nlevels_respa-1); } } diff --git a/src/GPU/fix_nve_asphere_gpu.cpp b/src/GPU/fix_nve_asphere_gpu.cpp index a6c4856ea0..1139c56272 100644 --- a/src/GPU/fix_nve_asphere_gpu.cpp +++ b/src/GPU/fix_nve_asphere_gpu.cpp @@ -165,7 +165,7 @@ FixNVEAsphereGPU::FixNVEAsphereGPU(LAMMPS *lmp, int narg, char **arg) : void FixNVEAsphereGPU::init() { - avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); + avec = dynamic_cast( atom->style_match("ellipsoid")); if (!avec) error->all(FLERR,"Compute nve/asphere requires atom style ellipsoid"); diff --git a/src/GPU/pair_gayberne_gpu.cpp b/src/GPU/pair_gayberne_gpu.cpp index 967817bc36..80ea3af902 100644 --- a/src/GPU/pair_gayberne_gpu.cpp +++ b/src/GPU/pair_gayberne_gpu.cpp @@ -145,7 +145,7 @@ void PairGayBerneGPU::compute(int eflag, int vflag) void PairGayBerneGPU::init_style() { - avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); + avec = dynamic_cast( atom->style_match("ellipsoid")); if (!avec) error->all(FLERR, "Pair gayberne/gpu requires atom style ellipsoid"); if (!atom->ellipsoid_flag) error->all(FLERR, "Pair gayberne/gpu requires atom style ellipsoid"); diff --git a/src/GPU/pair_resquared_gpu.cpp b/src/GPU/pair_resquared_gpu.cpp index cfe871be2b..8992f615ee 100644 --- a/src/GPU/pair_resquared_gpu.cpp +++ b/src/GPU/pair_resquared_gpu.cpp @@ -59,7 +59,7 @@ enum { SPHERE_SPHERE, SPHERE_ELLIPSE, ELLIPSE_SPHERE, ELLIPSE_ELLIPSE }; PairRESquaredGPU::PairRESquaredGPU(LAMMPS *lmp) : PairRESquared(lmp), gpu_mode(GPU_FORCE) { reinitflag = 0; - avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); + avec = dynamic_cast( atom->style_match("ellipsoid")); if (!avec) error->all(FLERR, "Pair resquared/gpu requires atom style ellipsoid"); quat_nmax = 0; quat = nullptr; diff --git a/src/GRANULAR/fix_damping_cundall.cpp b/src/GRANULAR/fix_damping_cundall.cpp index 0a2f27061b..20b7de976a 100644 --- a/src/GRANULAR/fix_damping_cundall.cpp +++ b/src/GRANULAR/fix_damping_cundall.cpp @@ -115,7 +115,7 @@ void FixDampingCundall::init() int max_respa = 0; if (utils::strmatch(update->integrate_style, "^respa")) { - ilevel_respa = max_respa = ((Respa *) update->integrate)->nlevels - 1; + ilevel_respa = max_respa = (dynamic_cast( update->integrate))->nlevels - 1; if (respa_level >= 0) ilevel_respa = MIN(respa_level, max_respa); } @@ -143,9 +143,9 @@ void FixDampingCundall::setup(int vflag) if (utils::strmatch(update->integrate_style, "^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(ilevel_respa); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel_respa); post_force_respa(vflag, ilevel_respa, 0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel_respa); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel_respa); } } diff --git a/src/GRANULAR/fix_freeze.cpp b/src/GRANULAR/fix_freeze.cpp index 1e952ef132..d3ed4db921 100644 --- a/src/GRANULAR/fix_freeze.cpp +++ b/src/GRANULAR/fix_freeze.cpp @@ -73,11 +73,11 @@ void FixFreeze::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - int nlevels_respa = ((Respa *) update->integrate)->nlevels; + int nlevels_respa = (dynamic_cast( update->integrate))->nlevels; for (int ilevel = 0; ilevel < nlevels_respa; ilevel++) { - ((Respa *) update->integrate)->copy_flevel_f(ilevel); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel); post_force_respa(vflag,ilevel,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel); } } } diff --git a/src/GRANULAR/fix_pour.cpp b/src/GRANULAR/fix_pour.cpp index 34963430e3..ddca6269c6 100644 --- a/src/GRANULAR/fix_pour.cpp +++ b/src/GRANULAR/fix_pour.cpp @@ -90,24 +90,24 @@ FixPour::FixPour(LAMMPS *lmp, int narg, char **arg) : if (strcmp(domain->regions[iregion]->style,"block") == 0) { region_style = 1; - xlo = ((RegBlock *) domain->regions[iregion])->xlo; - xhi = ((RegBlock *) domain->regions[iregion])->xhi; - ylo = ((RegBlock *) domain->regions[iregion])->ylo; - yhi = ((RegBlock *) domain->regions[iregion])->yhi; - zlo = ((RegBlock *) domain->regions[iregion])->zlo; - zhi = ((RegBlock *) domain->regions[iregion])->zhi; + xlo = (dynamic_cast( domain->regions[iregion]))->xlo; + xhi = (dynamic_cast( domain->regions[iregion]))->xhi; + ylo = (dynamic_cast( domain->regions[iregion]))->ylo; + yhi = (dynamic_cast( domain->regions[iregion]))->yhi; + zlo = (dynamic_cast( domain->regions[iregion]))->zlo; + zhi = (dynamic_cast( domain->regions[iregion]))->zhi; if (xlo < domain->boxlo[0] || xhi > domain->boxhi[0] || ylo < domain->boxlo[1] || yhi > domain->boxhi[1] || zlo < domain->boxlo[2] || zhi > domain->boxhi[2]) error->all(FLERR,"Insertion region extends outside simulation box"); } else if (strcmp(domain->regions[iregion]->style,"cylinder") == 0) { region_style = 2; - char axis = ((RegCylinder *) domain->regions[iregion])->axis; - xc = ((RegCylinder *) domain->regions[iregion])->c1; - yc = ((RegCylinder *) domain->regions[iregion])->c2; - rc = ((RegCylinder *) domain->regions[iregion])->radius; - zlo = ((RegCylinder *) domain->regions[iregion])->lo; - zhi = ((RegCylinder *) domain->regions[iregion])->hi; + char axis = (dynamic_cast( domain->regions[iregion]))->axis; + xc = (dynamic_cast( domain->regions[iregion]))->c1; + yc = (dynamic_cast( domain->regions[iregion]))->c2; + rc = (dynamic_cast( domain->regions[iregion]))->radius; + zlo = (dynamic_cast( domain->regions[iregion]))->lo; + zhi = (dynamic_cast( domain->regions[iregion]))->hi; if (axis != 'z') error->all(FLERR,"Must use a z-axis cylinder region with fix pour"); if (xc-rc < domain->boxlo[0] || xc+rc > domain->boxhi[0] || @@ -188,7 +188,7 @@ FixPour::FixPour(LAMMPS *lmp, int narg, char **arg) : auto fixlist = modify->get_fix_by_style("^gravity"); if (fixlist.size() != 1) error->all(FLERR,"There must be exactly one fix gravity defined for fix pour"); - auto fixgrav = (FixGravity *)fixlist.front(); + auto fixgrav = dynamic_cast(fixlist.front()); grav = -fixgrav->magnitude * force->ftm2v; @@ -312,7 +312,7 @@ void FixPour::init() auto fixlist = modify->get_fix_by_style("^gravity"); if (fixlist.size() != 1) error->all(FLERR,"There must be exactly one fix gravity defined for fix pour"); - auto fixgrav = (FixGravity *)fixlist.front(); + auto fixgrav = dynamic_cast(fixlist.front()); if (fixgrav->varflag != FixGravity::CONSTANT) error->all(FLERR,"Fix gravity for fix pour must be constant"); diff --git a/src/GRANULAR/fix_wall_gran.cpp b/src/GRANULAR/fix_wall_gran.cpp index 7c65248feb..da7af48e82 100644 --- a/src/GRANULAR/fix_wall_gran.cpp +++ b/src/GRANULAR/fix_wall_gran.cpp @@ -498,7 +498,7 @@ void FixWallGran::init() dt = update->dt; if (utils::strmatch(update->integrate_style,"^respa")) - nlevels_respa = ((Respa *) update->integrate)->nlevels; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; // check for FixRigid so can extract rigid body masses @@ -550,9 +550,9 @@ void FixWallGran::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_flevel_f(nlevels_respa-1); post_force_respa(vflag,nlevels_respa-1,0); - ((Respa *) update->integrate)->copy_f_flevel(nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_f_flevel(nlevels_respa-1); } } diff --git a/src/GRANULAR/pair_gran_hooke_history.cpp b/src/GRANULAR/pair_gran_hooke_history.cpp index 918f595f87..8a1e056d04 100644 --- a/src/GRANULAR/pair_gran_hooke_history.cpp +++ b/src/GRANULAR/pair_gran_hooke_history.cpp @@ -67,8 +67,8 @@ PairGranHookeHistory::PairGranHookeHistory(LAMMPS *lmp) : Pair(lmp) // this is so final order of Modify:fix will conform to input script fix_history = nullptr; - fix_dummy = (FixDummy *) modify->add_fix("NEIGH_HISTORY_HH_DUMMY" + std::to_string(instance_me) + - " all DUMMY"); + fix_dummy = dynamic_cast( modify->add_fix("NEIGH_HISTORY_HH_DUMMY" + std::to_string(instance_me) + + " all DUMMY")); } /* ---------------------------------------------------------------------- */ @@ -444,8 +444,8 @@ void PairGranHookeHistory::init_style() if (history && (fix_history == nullptr)) { auto cmd = fmt::format("NEIGH_HISTORY_HH{} all NEIGH_HISTORY {}", instance_me, size_history); - fix_history = (FixNeighHistory *) modify->replace_fix( - "NEIGH_HISTORY_HH_DUMMY" + std::to_string(instance_me), cmd, 1); + fix_history = dynamic_cast( modify->replace_fix( + "NEIGH_HISTORY_HH_DUMMY" + std::to_string(instance_me), cmd, 1)); fix_history->pair = this; } @@ -511,7 +511,7 @@ void PairGranHookeHistory::init_style() // set fix which stores history info if (history) { - fix_history = (FixNeighHistory *) modify->get_fix_by_id("NEIGH_HISTORY_HH" + std::to_string(instance_me)); + fix_history = dynamic_cast( modify->get_fix_by_id("NEIGH_HISTORY_HH" + std::to_string(instance_me))); if (!fix_history) error->all(FLERR,"Could not find pair fix neigh history ID"); } } diff --git a/src/GRANULAR/pair_granular.cpp b/src/GRANULAR/pair_granular.cpp index 93f73cc395..05df36f894 100644 --- a/src/GRANULAR/pair_granular.cpp +++ b/src/GRANULAR/pair_granular.cpp @@ -102,7 +102,7 @@ PairGranular::PairGranular(LAMMPS *lmp) : Pair(lmp) // this is so final order of Modify:fix will conform to input script fix_history = nullptr; - fix_dummy = (FixDummy *) modify->add_fix("NEIGH_HISTORY_GRANULAR_DUMMY all DUMMY"); + fix_dummy = dynamic_cast( modify->add_fix("NEIGH_HISTORY_GRANULAR_DUMMY all DUMMY")); } /* ---------------------------------------------------------------------- */ @@ -1120,10 +1120,10 @@ void PairGranular::init_style() // this is so its order in the fix list is preserved if (use_history && fix_history == nullptr) { - fix_history = (FixNeighHistory *) modify->replace_fix("NEIGH_HISTORY_GRANULAR_DUMMY", + fix_history = dynamic_cast( modify->replace_fix("NEIGH_HISTORY_GRANULAR_DUMMY", "NEIGH_HISTORY_GRANULAR" " all NEIGH_HISTORY " - + std::to_string(size_history),1); + + std::to_string(size_history),1)); fix_history->pair = this; } @@ -1189,7 +1189,7 @@ void PairGranular::init_style() // set fix which stores history info if (size_history > 0) { - fix_history = (FixNeighHistory *) modify->get_fix_by_id("NEIGH_HISTORY_GRANULAR"); + fix_history = dynamic_cast( modify->get_fix_by_id("NEIGH_HISTORY_GRANULAR")); if (!fix_history) error->all(FLERR,"Could not find pair fix neigh history ID"); } } diff --git a/src/INTEL/fix_intel.cpp b/src/INTEL/fix_intel.cpp index d4024c77af..4f81293e1b 100644 --- a/src/INTEL/fix_intel.cpp +++ b/src/INTEL/fix_intel.cpp @@ -375,7 +375,7 @@ void FixIntel::setup_pre_reverse(int eflag, int vflag) bool FixIntel::pair_hybrid_check() { - PairHybrid *ph = (PairHybrid *)force->pair; + auto ph = dynamic_cast(force->pair); bool has_intel = false; int nstyles = ph->nstyles; diff --git a/src/INTEL/fix_nve_asphere_intel.cpp b/src/INTEL/fix_nve_asphere_intel.cpp index 8b6ab72468..fa68c9bb4a 100644 --- a/src/INTEL/fix_nve_asphere_intel.cpp +++ b/src/INTEL/fix_nve_asphere_intel.cpp @@ -49,7 +49,7 @@ FixNVEAsphereIntel::FixNVEAsphereIntel(LAMMPS *lmp, int narg, char **arg) : void FixNVEAsphereIntel::init() { - avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); + avec = dynamic_cast( atom->style_match("ellipsoid")); if (!avec) error->all(FLERR,"Compute nve/asphere requires atom style ellipsoid"); diff --git a/src/INTEL/fix_nvt_sllod_intel.cpp b/src/INTEL/fix_nvt_sllod_intel.cpp index f704512c51..bc13d1d677 100644 --- a/src/INTEL/fix_nvt_sllod_intel.cpp +++ b/src/INTEL/fix_nvt_sllod_intel.cpp @@ -70,7 +70,7 @@ void FixNVTSllodIntel::init() int i; for (i = 0; i < modify->nfix; i++) if (strncmp(modify->fix[i]->style,"deform",6) == 0) { - if (((FixDeform *) modify->fix[i])->remapflag != Domain::V_REMAP) + if ((dynamic_cast( modify->fix[i]))->remapflag != Domain::V_REMAP) error->all(FLERR,"Using fix nvt/sllod with inconsistent fix deform " "remap option"); break; diff --git a/src/INTEL/verlet_lrt_intel.cpp b/src/INTEL/verlet_lrt_intel.cpp index b5476fd523..0d8eb2e468 100644 --- a/src/INTEL/verlet_lrt_intel.cpp +++ b/src/INTEL/verlet_lrt_intel.cpp @@ -67,7 +67,7 @@ void VerletLRTIntel::init() { Verlet::init(); - _intel_kspace = (PPPMIntel*)(force->kspace_match("^pppm/intel", 0)); + _intel_kspace = dynamic_cast(force->kspace_match("^pppm/intel", 0)); #ifndef LMP_INTEL_USELRT error->all(FLERR, diff --git a/src/KIM/kim_init.cpp b/src/KIM/kim_init.cpp index 2c8a19251f..dae8812a60 100644 --- a/src/KIM/kim_init.cpp +++ b/src/KIM/kim_init.cpp @@ -316,7 +316,7 @@ void KimInit::do_init(char *model_name, char *user_units, char *model_units, KIM modify->add_fix("KIM_MODEL_STORE all STORE/KIM"); ifix = modify->find_fix("KIM_MODEL_STORE"); - FixStoreKIM *fix_store = (FixStoreKIM *) modify->fix[ifix]; + auto fix_store = dynamic_cast( modify->fix[ifix]); fix_store->setptr("model_name", (void *) model_name); fix_store->setptr("user_units", (void *) user_units); fix_store->setptr("model_units", (void *) model_units); diff --git a/src/KIM/kim_interactions.cpp b/src/KIM/kim_interactions.cpp index 74ac40198c..3427d6fb57 100644 --- a/src/KIM/kim_interactions.cpp +++ b/src/KIM/kim_interactions.cpp @@ -121,7 +121,7 @@ void KimInteractions::do_setup(int narg, char **arg) int ifix = modify->find_fix("KIM_MODEL_STORE"); if (ifix >= 0) { - FixStoreKIM *fix_store = (FixStoreKIM *) modify->fix[ifix]; + auto fix_store = dynamic_cast( modify->fix[ifix]); model_name = (char *)fix_store->getptr("model_name"); simulatorModel = (KIM_SimulatorModel *)fix_store->getptr("simulator_model"); } else error->all(FLERR, "Must use 'kim init' before 'kim interactions'"); diff --git a/src/KIM/kim_query.cpp b/src/KIM/kim_query.cpp index 3a65936cdf..e85df32755 100644 --- a/src/KIM/kim_query.cpp +++ b/src/KIM/kim_query.cpp @@ -158,7 +158,7 @@ void KimQuery::command(int narg, char **arg) // check if we had a kim init command by finding fix STORE/KIM const int ifix = modify->find_fix("KIM_MODEL_STORE"); if (ifix >= 0) { - FixStoreKIM *fix_store = (FixStoreKIM *) modify->fix[ifix]; + auto fix_store = dynamic_cast( modify->fix[ifix]); char *model_name_c = (char *) fix_store->getptr("model_name"); model_name = model_name_c; } else { diff --git a/src/KSPACE/pair_buck_long_coul_long.cpp b/src/KSPACE/pair_buck_long_coul_long.cpp index 1af0857668..b1717a891d 100644 --- a/src/KSPACE/pair_buck_long_coul_long.cpp +++ b/src/KSPACE/pair_buck_long_coul_long.cpp @@ -249,8 +249,8 @@ void PairBuckLongCoulLong::init_style() // set rRESPA cutoffs if (utils::strmatch(update->integrate_style,"^respa") && - ((Respa *) update->integrate)->level_inner >= 0) - cut_respa = ((Respa *) update->integrate)->cutoff; + (dynamic_cast( update->integrate))->level_inner >= 0) + cut_respa = (dynamic_cast( update->integrate))->cutoff; else cut_respa = nullptr; // setup force tables @@ -264,7 +264,7 @@ void PairBuckLongCoulLong::init_style() int list_style = NeighConst::REQ_DEFAULT; if (update->whichflag == 1 && utils::strmatch(update->integrate_style, "^respa")) { - auto respa = (Respa *) update->integrate; + auto respa = dynamic_cast( update->integrate); if (respa->level_inner >= 0) list_style = NeighConst::REQ_RESPA_INOUT; if (respa->level_middle >= 0) list_style = NeighConst::REQ_RESPA_ALL; } diff --git a/src/KSPACE/pair_lj_charmm_coul_long.cpp b/src/KSPACE/pair_lj_charmm_coul_long.cpp index 67e0a328e5..6e39a4f56f 100644 --- a/src/KSPACE/pair_lj_charmm_coul_long.cpp +++ b/src/KSPACE/pair_lj_charmm_coul_long.cpp @@ -690,7 +690,7 @@ void PairLJCharmmCoulLong::init_style() int list_style = NeighConst::REQ_DEFAULT; if (update->whichflag == 1 && utils::strmatch(update->integrate_style, "^respa")) { - auto respa = (Respa *) update->integrate; + auto respa = dynamic_cast( update->integrate); if (respa->level_inner >= 0) list_style = NeighConst::REQ_RESPA_INOUT; if (respa->level_middle >= 0) list_style = NeighConst::REQ_RESPA_ALL; } @@ -713,8 +713,8 @@ void PairLJCharmmCoulLong::init_style() // set & error check interior rRESPA cutoffs if (utils::strmatch(update->integrate_style,"^respa") && - ((Respa *) update->integrate)->level_inner >= 0) { - cut_respa = ((Respa *) update->integrate)->cutoff; + (dynamic_cast( update->integrate))->level_inner >= 0) { + cut_respa = (dynamic_cast( update->integrate))->cutoff; cut_in_off = cut_respa[0]; cut_in_on = cut_respa[1]; cut_out_on = cut_respa[2]; diff --git a/src/KSPACE/pair_lj_charmmfsw_coul_long.cpp b/src/KSPACE/pair_lj_charmmfsw_coul_long.cpp index 1fb72a3108..a4741a56a2 100644 --- a/src/KSPACE/pair_lj_charmmfsw_coul_long.cpp +++ b/src/KSPACE/pair_lj_charmmfsw_coul_long.cpp @@ -741,7 +741,7 @@ void PairLJCharmmfswCoulLong::init_style() int list_style = NeighConst::REQ_DEFAULT; if (update->whichflag == 1 && utils::strmatch(update->integrate_style, "^respa")) { - auto respa = (Respa *) update->integrate; + auto respa = dynamic_cast( update->integrate); if (respa->level_inner >= 0) list_style = NeighConst::REQ_RESPA_INOUT; if (respa->level_middle >= 0) list_style = NeighConst::REQ_RESPA_ALL; } @@ -775,8 +775,8 @@ void PairLJCharmmfswCoulLong::init_style() // set & error check interior rRESPA cutoffs if (utils::strmatch(update->integrate_style,"^respa") && - ((Respa *) update->integrate)->level_inner >= 0) { - cut_respa = ((Respa *) update->integrate)->cutoff; + (dynamic_cast( update->integrate))->level_inner >= 0) { + cut_respa = (dynamic_cast( update->integrate))->cutoff; if (MIN(cut_lj,cut_coul) < cut_respa[3]) error->all(FLERR,"Pair cutoff < Respa interior cutoff"); if (cut_lj_inner < cut_respa[1]) diff --git a/src/KSPACE/pair_lj_cut_coul_long.cpp b/src/KSPACE/pair_lj_cut_coul_long.cpp index 6a3597a0ae..0ffdde24de 100644 --- a/src/KSPACE/pair_lj_cut_coul_long.cpp +++ b/src/KSPACE/pair_lj_cut_coul_long.cpp @@ -658,7 +658,7 @@ void PairLJCutCoulLong::init_style() int list_style = NeighConst::REQ_DEFAULT; if (update->whichflag == 1 && utils::strmatch(update->integrate_style, "^respa")) { - auto respa = (Respa *) update->integrate; + auto respa = dynamic_cast( update->integrate); if (respa->level_inner >= 0) list_style = NeighConst::REQ_RESPA_INOUT; if (respa->level_middle >= 0) list_style = NeighConst::REQ_RESPA_ALL; } @@ -669,8 +669,8 @@ void PairLJCutCoulLong::init_style() // set rRESPA cutoffs if (utils::strmatch(update->integrate_style,"^respa") && - ((Respa *) update->integrate)->level_inner >= 0) - cut_respa = ((Respa *) update->integrate)->cutoff; + (dynamic_cast( update->integrate))->level_inner >= 0) + cut_respa = (dynamic_cast( update->integrate))->cutoff; else cut_respa = nullptr; // insure use of KSpace long-range solver, set g_ewald diff --git a/src/KSPACE/pair_lj_long_coul_long.cpp b/src/KSPACE/pair_lj_long_coul_long.cpp index a7d4464094..742f424b95 100644 --- a/src/KSPACE/pair_lj_long_coul_long.cpp +++ b/src/KSPACE/pair_lj_long_coul_long.cpp @@ -242,8 +242,8 @@ void PairLJLongCoulLong::init_style() // set rRESPA cutoffs if (utils::strmatch(update->integrate_style,"^respa") && - ((Respa *) update->integrate)->level_inner >= 0) - cut_respa = ((Respa *) update->integrate)->cutoff; + (dynamic_cast( update->integrate))->level_inner >= 0) + cut_respa = (dynamic_cast( update->integrate))->cutoff; else cut_respa = nullptr; // setup force tables @@ -257,7 +257,7 @@ void PairLJLongCoulLong::init_style() int list_style = NeighConst::REQ_DEFAULT; if (update->whichflag == 1 && utils::strmatch(update->integrate_style, "^respa")) { - auto respa = (Respa *) update->integrate; + auto respa = dynamic_cast( update->integrate); if (respa->level_inner >= 0) list_style = NeighConst::REQ_RESPA_INOUT; if (respa->level_middle >= 0) list_style = NeighConst::REQ_RESPA_ALL; } diff --git a/src/MACHDYN/pair_smd_tlsph.cpp b/src/MACHDYN/pair_smd_tlsph.cpp index 323325aa30..ac1ccd7eb2 100644 --- a/src/MACHDYN/pair_smd_tlsph.cpp +++ b/src/MACHDYN/pair_smd_tlsph.cpp @@ -143,11 +143,11 @@ void PairTlsph::PreCompute() { int nlocal = atom->nlocal; int jnum, jj, i, j, itype, idim; - tagint **partner = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->partner; - int *npartner = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->npartner; - float **wfd_list = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->wfd_list; - float **wf_list = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->wf_list; - float **degradation_ij = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->degradation_ij; + tagint **partner = (dynamic_cast( modify->fix[ifix_tlsph]))->partner; + int *npartner = (dynamic_cast( modify->fix[ifix_tlsph]))->npartner; + float **wfd_list = (dynamic_cast( modify->fix[ifix_tlsph]))->wfd_list; + float **wf_list = (dynamic_cast( modify->fix[ifix_tlsph]))->wf_list; + float **degradation_ij = (dynamic_cast( modify->fix[ifix_tlsph]))->degradation_ij; double r0, r0Sq, wf, wfd, h, irad, voli, volj, scale, shepardWeight; Vector3d dx, dx0, dv, g; Matrix3d Ktmp, Ftmp, Fdottmp, L, U, eye; @@ -421,12 +421,12 @@ void PairTlsph::ComputeForces(int eflag, int vflag) { Vector3d xi, xj, vi, vj, f_visc, sumForces, f_spring; int periodic = (domain->xperiodic || domain->yperiodic || domain->zperiodic); - tagint **partner = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->partner; - int *npartner = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->npartner; - float **wfd_list = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->wfd_list; - float **wf_list = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->wf_list; - float **degradation_ij = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->degradation_ij; - float **energy_per_bond = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->energy_per_bond; + tagint **partner = (dynamic_cast( modify->fix[ifix_tlsph]))->partner; + int *npartner = (dynamic_cast( modify->fix[ifix_tlsph]))->npartner; + float **wfd_list = (dynamic_cast( modify->fix[ifix_tlsph]))->wfd_list; + float **wf_list = (dynamic_cast( modify->fix[ifix_tlsph]))->wf_list; + float **degradation_ij = (dynamic_cast( modify->fix[ifix_tlsph]))->degradation_ij; + float **energy_per_bond = (dynamic_cast( modify->fix[ifix_tlsph]))->energy_per_bond; Matrix3d eye; eye.setIdentity(); @@ -1606,13 +1606,13 @@ void PairTlsph::init_style() { error->all(FLERR, "Pair style tlsph requires its particles to be part of a group named tlsph. This group does not exist."); if (fix_tlsph_reference_configuration == nullptr) { - char **fixarg = new char*[3]; + auto fixarg = new char*[3]; fixarg[0] = (char *) "SMD_TLSPH_NEIGHBORS"; fixarg[1] = (char *) "tlsph"; fixarg[2] = (char *) "SMD_TLSPH_NEIGHBORS"; modify->add_fix(3, fixarg); delete[] fixarg; - fix_tlsph_reference_configuration = (FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[modify->nfix - 1]; + fix_tlsph_reference_configuration = dynamic_cast( modify->fix[modify->nfix - 1]); fix_tlsph_reference_configuration->pair = this; } diff --git a/src/MANIFOLD/fix_manifoldforce.cpp b/src/MANIFOLD/fix_manifoldforce.cpp index 2968361e43..7542205f8f 100644 --- a/src/MANIFOLD/fix_manifoldforce.cpp +++ b/src/MANIFOLD/fix_manifoldforce.cpp @@ -124,11 +124,11 @@ void FixManifoldForce::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - int nlevels_respa = ((Respa *) update->integrate)->nlevels; + int nlevels_respa = (dynamic_cast( update->integrate))->nlevels; for (int ilevel = 0; ilevel < nlevels_respa; ilevel++) { - ((Respa *) update->integrate)->copy_flevel_f(ilevel); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel); post_force_respa(vflag,ilevel,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel); } } } diff --git a/src/MANYBODY/fix_qeq_comb.cpp b/src/MANYBODY/fix_qeq_comb.cpp index 16425d5d64..cf9441da1e 100644 --- a/src/MANYBODY/fix_qeq_comb.cpp +++ b/src/MANYBODY/fix_qeq_comb.cpp @@ -119,14 +119,14 @@ void FixQEQComb::init() if (!atom->q_flag) error->all(FLERR,"Fix qeq/comb requires atom attribute q"); - comb3 = (PairComb3 *) force->pair_match("^comb3",0); - if (!comb3) comb = (PairComb *) force->pair_match("^comb",0); + comb3 = dynamic_cast( force->pair_match("^comb3",0)); + if (!comb3) comb = dynamic_cast( force->pair_match("^comb",0)); if (comb == nullptr && comb3 == nullptr) error->all(FLERR,"Must use pair_style comb or comb3 with fix qeq/comb"); if (utils::strmatch(update->integrate_style,"^respa")) { - ilevel_respa = ((Respa *) update->integrate)->nlevels-1; + ilevel_respa = (dynamic_cast( update->integrate))->nlevels-1; if (respa_level >= 0) ilevel_respa = MIN(respa_level,ilevel_respa); } @@ -154,9 +154,9 @@ void FixQEQComb::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(ilevel_respa); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel_respa); post_force_respa(vflag,ilevel_respa,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel_respa); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel_respa); } firstflag = 0; } diff --git a/src/MC/fix_bond_break.cpp b/src/MC/fix_bond_break.cpp index f7199d95f6..1498cd2fd4 100644 --- a/src/MC/fix_bond_break.cpp +++ b/src/MC/fix_bond_break.cpp @@ -146,7 +146,7 @@ int FixBondBreak::setmask() void FixBondBreak::init() { if (utils::strmatch(update->integrate_style,"^respa")) - nlevels_respa = ((Respa *) update->integrate)->nlevels; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; // enable angle/dihedral/improper breaking if any defined diff --git a/src/MC/fix_bond_create.cpp b/src/MC/fix_bond_create.cpp index 4317d4c162..2550e881d6 100644 --- a/src/MC/fix_bond_create.cpp +++ b/src/MC/fix_bond_create.cpp @@ -235,7 +235,7 @@ int FixBondCreate::setmask() void FixBondCreate::init() { if (utils::strmatch(update->integrate_style,"^respa")) - nlevels_respa = ((Respa *) update->integrate)->nlevels; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; // check cutoff for iatomtype,jatomtype diff --git a/src/MDI/mdi_engine.cpp b/src/MDI/mdi_engine.cpp index 2e29ed2fd4..8408b2dd49 100644 --- a/src/MDI/mdi_engine.cpp +++ b/src/MDI/mdi_engine.cpp @@ -601,7 +601,7 @@ void MDIEngine::mdi_md() // delete the instance before this method returns modify->add_fix("MDI_ENGINE_INTERNAL all MDI/ENGINE"); - FixMDIEngine *mdi_fix = (FixMDIEngine *) modify->get_fix_by_id("MDI_ENGINE_INTERNAL"); + FixMDIEngine *mdi_fix = dynamic_cast( modify->get_fix_by_id("MDI_ENGINE_INTERNAL")); mdi_fix->mdi_engine = this; // initialize LAMMPS and setup() the simulation @@ -723,7 +723,7 @@ void MDIEngine::mdi_optg() // delete the instance before this method returns modify->add_fix("MDI_ENGINE_INTERNAL all MDI/ENGINE"); - FixMDIEngine *mdi_fix = (FixMDIEngine *) modify->get_fix_by_id("MDI_ENGINE_INTERNAL"); + FixMDIEngine *mdi_fix = dynamic_cast( modify->get_fix_by_id("MDI_ENGINE_INTERNAL")); mdi_fix->mdi_engine = this; // initialize LAMMPS and setup() the simulation diff --git a/src/MDI/mdi_plugin.cpp b/src/MDI/mdi_plugin.cpp index 5d8c3516d6..99549a621f 100644 --- a/src/MDI/mdi_plugin.cpp +++ b/src/MDI/mdi_plugin.cpp @@ -120,7 +120,7 @@ int MDIPlugin::plugin_wrapper(void * /*pmpicomm*/, MDI_Comm mdicomm, void *vptr) // set FixMDIAimd mdicomm to driver's mdicomm passed to this callback - FixMDIAimd *aimdptr = (FixMDIAimd *) (ptr->fixptr); + auto aimdptr = dynamic_cast (ptr->fixptr); aimdptr->mdicomm = mdicomm; // invoke the specified LAMMPS command diff --git a/src/MISC/fix_imd.cpp b/src/MISC/fix_imd.cpp index 18d338a69f..da2a110e4d 100644 --- a/src/MISC/fix_imd.cpp +++ b/src/MISC/fix_imd.cpp @@ -595,7 +595,7 @@ int FixIMD::setmask() void FixIMD::init() { if (utils::strmatch(update->integrate_style,"^respa")) - nlevels_respa = ((Respa *) update->integrate)->nlevels; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; return; } diff --git a/src/MISC/pair_srp.cpp b/src/MISC/pair_srp.cpp index 84f7c330a8..3667d0a2c2 100644 --- a/src/MISC/pair_srp.cpp +++ b/src/MISC/pair_srp.cpp @@ -84,7 +84,7 @@ PairSRP::PairSRP(LAMMPS *lmp) : Pair(lmp), fix_id(nullptr) // will be invoked before other fixes that migrate atoms // this is checked for in FixSRP - f_srp = (FixSRP *) modify->add_fix(fmt::format("{:02d}_FIX_SRP all SRP",srp_instance)); + f_srp = dynamic_cast( modify->add_fix(fmt::format("{:02d}_FIX_SRP all SRP",srp_instance))); ++srp_instance; } diff --git a/src/MISC/pair_tracker.cpp b/src/MISC/pair_tracker.cpp index 502b04c49d..ab045d4843 100644 --- a/src/MISC/pair_tracker.cpp +++ b/src/MISC/pair_tracker.cpp @@ -51,7 +51,7 @@ PairTracker::PairTracker(LAMMPS *lmp) : Pair(lmp) fix_history = nullptr; modify->add_fix("NEIGH_HISTORY_TRACK_DUMMY all DUMMY"); - fix_dummy = (FixDummy *) modify->fix[modify->nfix - 1]; + fix_dummy = dynamic_cast( modify->fix[modify->nfix - 1]); } /* ---------------------------------------------------------------------- */ @@ -283,11 +283,11 @@ void PairTracker::init_style() if (fix_history == nullptr) { modify->replace_fix("NEIGH_HISTORY_TRACK_DUMMY", fmt::format("NEIGH_HISTORY_TRACK all NEIGH_HISTORY {}", size_history), 1); - fix_history = (FixNeighHistory *) modify->get_fix_by_id("NEIGH_HISTORY_TRACK"); + fix_history = dynamic_cast( modify->get_fix_by_id("NEIGH_HISTORY_TRACK")); fix_history->pair = this; fix_history->use_bit_flag = 0; } else { - fix_history = (FixNeighHistory *) modify->get_fix_by_id("NEIGH_HISTORY_TRACK"); + fix_history = dynamic_cast( modify->get_fix_by_id("NEIGH_HISTORY_TRACK")); if (!fix_history) error->all(FLERR, "Could not find pair fix neigh history ID"); } @@ -342,7 +342,7 @@ void PairTracker::init_style() auto trackfixes = modify->get_fix_by_style("pair/tracker"); if (trackfixes.size() != 1) error->all(FLERR, "Must use exactly one fix pair/tracker command with pair style tracker"); - fix_pair_tracker = (FixPairTracker *) trackfixes.front(); + fix_pair_tracker = dynamic_cast( trackfixes.front()); } /* ---------------------------------------------------------------------- diff --git a/src/MOLECULE/dihedral_charmm.cpp b/src/MOLECULE/dihedral_charmm.cpp index ee053f4f12..0cfd624cbc 100644 --- a/src/MOLECULE/dihedral_charmm.cpp +++ b/src/MOLECULE/dihedral_charmm.cpp @@ -350,7 +350,7 @@ void DihedralCharmm::coeff(int narg, char **arg) void DihedralCharmm::init_style() { if (utils::strmatch(update->integrate_style, "^respa")) { - Respa *r = (Respa *) update->integrate; + auto r = dynamic_cast( update->integrate); if (r->level_pair >= 0 && (r->level_pair != r->level_dihedral)) error->all(FLERR, "Dihedral style charmm must be set to same r-RESPA level as 'pair'"); if (r->level_outer >= 0 && (r->level_outer != r->level_dihedral)) diff --git a/src/MOLECULE/dihedral_charmmfsw.cpp b/src/MOLECULE/dihedral_charmmfsw.cpp index 76ba8b8283..607fa8fa4a 100644 --- a/src/MOLECULE/dihedral_charmmfsw.cpp +++ b/src/MOLECULE/dihedral_charmmfsw.cpp @@ -369,7 +369,7 @@ void DihedralCharmmfsw::coeff(int narg, char **arg) void DihedralCharmmfsw::init_style() { if (utils::strmatch(update->integrate_style, "^respa")) { - Respa *r = (Respa *) update->integrate; + auto r = dynamic_cast( update->integrate); if (r->level_pair >= 0 && (r->level_pair != r->level_dihedral)) error->all(FLERR, "Dihedral style charmmfsw must be set to same r-RESPA level as 'pair'"); if (r->level_outer >= 0 && (r->level_outer != r->level_dihedral)) diff --git a/src/MOLECULE/fix_cmap.cpp b/src/MOLECULE/fix_cmap.cpp index 01231b4b0e..b384294a89 100644 --- a/src/MOLECULE/fix_cmap.cpp +++ b/src/MOLECULE/fix_cmap.cpp @@ -189,7 +189,7 @@ void FixCMAP::init() newton_bond = force->newton_bond; if (utils::strmatch(update->integrate_style,"^respa")) { - ilevel_respa = ((Respa *) update->integrate)->nlevels-1; + ilevel_respa = (dynamic_cast( update->integrate))->nlevels-1; if (respa_level >= 0) ilevel_respa = MIN(respa_level,ilevel_respa); } } @@ -203,9 +203,9 @@ void FixCMAP::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(ilevel_respa); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel_respa); post_force_respa(vflag,ilevel_respa,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel_respa); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel_respa); } } diff --git a/src/OPENMP/fix_nh_asphere_omp.cpp b/src/OPENMP/fix_nh_asphere_omp.cpp index 2329ef584d..554a0d52b6 100644 --- a/src/OPENMP/fix_nh_asphere_omp.cpp +++ b/src/OPENMP/fix_nh_asphere_omp.cpp @@ -43,7 +43,7 @@ FixNHAsphereOMP::FixNHAsphereOMP(LAMMPS *lmp, int narg, char **arg) : void FixNHAsphereOMP::init() { - avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); + avec = dynamic_cast( atom->style_match("ellipsoid")); if (!avec) error->all(FLERR,"Compute nvt/nph/npt asphere requires atom style ellipsoid"); diff --git a/src/OPENMP/fix_nvt_sllod_omp.cpp b/src/OPENMP/fix_nvt_sllod_omp.cpp index dae2dfb5d3..c9ee6c153f 100644 --- a/src/OPENMP/fix_nvt_sllod_omp.cpp +++ b/src/OPENMP/fix_nvt_sllod_omp.cpp @@ -78,7 +78,7 @@ void FixNVTSllodOMP::init() int i; for (i = 0; i < modify->nfix; i++) if (utils::strmatch(modify->fix[i]->style,"^deform")) { - if (((FixDeform *) modify->fix[i])->remapflag != Domain::V_REMAP) + if ((dynamic_cast( modify->fix[i]))->remapflag != Domain::V_REMAP) error->all(FLERR,"Using fix nvt/sllod/omp with inconsistent fix " "deform remap option"); break; diff --git a/src/OPENMP/fix_qeq_comb_omp.cpp b/src/OPENMP/fix_qeq_comb_omp.cpp index 18f579ad3a..84ca49b7e7 100644 --- a/src/OPENMP/fix_qeq_comb_omp.cpp +++ b/src/OPENMP/fix_qeq_comb_omp.cpp @@ -49,13 +49,13 @@ void FixQEQCombOMP::init() if (nullptr != force->pair_match("comb3", 0)) error->all(FLERR, "No support for comb3 currently available in OPENMP"); - comb = (PairComb *) force->pair_match("comb/omp", 1); - if (comb == nullptr) comb = (PairComb *) force->pair_match("comb", 1); + comb = dynamic_cast( force->pair_match("comb/omp", 1)); + if (comb == nullptr) comb = dynamic_cast( force->pair_match("comb", 1)); if (comb == nullptr) error->all(FLERR, "Must use pair_style comb or comb/omp with fix qeq/comb/omp"); if (utils::strmatch(update->integrate_style, "^respa")) { - ilevel_respa = ((Respa *) update->integrate)->nlevels - 1; + ilevel_respa = (dynamic_cast( update->integrate))->nlevels - 1; if (respa_level >= 0) ilevel_respa = MIN(respa_level, ilevel_respa); } diff --git a/src/OPENMP/pair_reaxff_omp.cpp b/src/OPENMP/pair_reaxff_omp.cpp index 6d613abf60..f10f5885bd 100644 --- a/src/OPENMP/pair_reaxff_omp.cpp +++ b/src/OPENMP/pair_reaxff_omp.cpp @@ -134,7 +134,7 @@ void PairReaxFFOMP::init_style() "increased neighbor list skin."); if (fix_reaxff == nullptr) - fix_reaxff = (FixReaxFF *) modify->add_fix(fmt::format("{} all REAXFF",fix_id)); + fix_reaxff = dynamic_cast( modify->add_fix(fmt::format("{} all REAXFF",fix_id))); api->control->nthreads = comm->nthreads; } diff --git a/src/OPENMP/reaxff_bond_orders_omp.cpp b/src/OPENMP/reaxff_bond_orders_omp.cpp index 38901807c2..258f207927 100644 --- a/src/OPENMP/reaxff_bond_orders_omp.cpp +++ b/src/OPENMP/reaxff_bond_orders_omp.cpp @@ -44,7 +44,7 @@ namespace ReaxFF { dbond_coefficients coef; int pk, k, j; - PairReaxFFOMP *pair_reax_ptr = static_cast(system->pair_ptr); + auto pair_reax_ptr = static_cast(system->pair_ptr); int tid = get_tid(); ThrData *thr = pair_reax_ptr->getFixOMP()->get_thr(tid); diff --git a/src/ORIENT/fix_orient_bcc.cpp b/src/ORIENT/fix_orient_bcc.cpp index 3989863280..919927ea07 100644 --- a/src/ORIENT/fix_orient_bcc.cpp +++ b/src/ORIENT/fix_orient_bcc.cpp @@ -201,7 +201,7 @@ int FixOrientBCC::setmask() void FixOrientBCC::init() { if (utils::strmatch(update->integrate_style,"^respa")) { - ilevel_respa = ((Respa *) update->integrate)->nlevels-1; + ilevel_respa = (dynamic_cast( update->integrate))->nlevels-1; if (respa_level >= 0) ilevel_respa = MIN(respa_level,ilevel_respa); } @@ -224,9 +224,9 @@ void FixOrientBCC::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(ilevel_respa); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel_respa); post_force_respa(vflag,ilevel_respa,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel_respa); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel_respa); } } diff --git a/src/ORIENT/fix_orient_eco.cpp b/src/ORIENT/fix_orient_eco.cpp index 6f633316cf..7c8ff1f6aa 100644 --- a/src/ORIENT/fix_orient_eco.cpp +++ b/src/ORIENT/fix_orient_eco.cpp @@ -176,7 +176,7 @@ void FixOrientECO::init() { MPI_Bcast(&inv_norm_fac, 1, MPI_DOUBLE, 0, world); if (utils::strmatch(update->integrate_style,"^respa")) { - ilevel_respa = ((Respa *) update->integrate)->nlevels - 1; + ilevel_respa = (dynamic_cast( update->integrate))->nlevels - 1; if (respa_level >= 0) ilevel_respa = MIN(respa_level, ilevel_respa); } @@ -197,9 +197,9 @@ void FixOrientECO::setup(int vflag) { if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(ilevel_respa); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel_respa); post_force_respa(vflag,ilevel_respa, 0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel_respa); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel_respa); } } diff --git a/src/ORIENT/fix_orient_fcc.cpp b/src/ORIENT/fix_orient_fcc.cpp index 4dbe763cdf..f64889d141 100644 --- a/src/ORIENT/fix_orient_fcc.cpp +++ b/src/ORIENT/fix_orient_fcc.cpp @@ -199,7 +199,7 @@ int FixOrientFCC::setmask() void FixOrientFCC::init() { if (utils::strmatch(update->integrate_style,"^respa")) { - ilevel_respa = ((Respa *) update->integrate)->nlevels-1; + ilevel_respa = (dynamic_cast( update->integrate))->nlevels-1; if (respa_level >= 0) ilevel_respa = MIN(respa_level,ilevel_respa); } @@ -222,9 +222,9 @@ void FixOrientFCC::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(ilevel_respa); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel_respa); post_force_respa(vflag,ilevel_respa,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel_respa); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel_respa); } } diff --git a/src/PERI/compute_damage_atom.cpp b/src/PERI/compute_damage_atom.cpp index 80aff909ae..1e08e534c6 100644 --- a/src/PERI/compute_damage_atom.cpp +++ b/src/PERI/compute_damage_atom.cpp @@ -60,7 +60,7 @@ void ComputeDamageAtom::init() auto fixes = modify->get_fix_by_style("PERI_NEIGH"); if (fixes.size() == 0) error->all(FLERR,"Compute damage/atom requires a peridynamic potential"); - else fix_peri_neigh = (FixPeriNeigh *)fixes.front(); + else fix_peri_neigh = dynamic_cast(fixes.front()); } /* ---------------------------------------------------------------------- */ diff --git a/src/PERI/compute_plasticity_atom.cpp b/src/PERI/compute_plasticity_atom.cpp index e22c8765b4..425f6379e0 100644 --- a/src/PERI/compute_plasticity_atom.cpp +++ b/src/PERI/compute_plasticity_atom.cpp @@ -66,7 +66,7 @@ void ComputePlasticityAtom::init() auto fixes = modify->get_fix_by_style("PERI_NEIGH"); if (fixes.size() == 0) error->all(FLERR,"Compute plasticity/atom requires a peridynamic potential"); - else fix_peri_neigh = (FixPeriNeigh *)fixes.front(); + else fix_peri_neigh = dynamic_cast(fixes.front()); } /* ---------------------------------------------------------------------- */ diff --git a/src/PERI/pair_peri.cpp b/src/PERI/pair_peri.cpp index 4ed281489b..3ce8eeb08e 100644 --- a/src/PERI/pair_peri.cpp +++ b/src/PERI/pair_peri.cpp @@ -130,7 +130,7 @@ void PairPeri::init_style() // if first init, create Fix needed for storing fixed neighbors if (!fix_peri_neigh) - fix_peri_neigh = (FixPeriNeigh *) modify->add_fix("PERI_NEIGH all PERI_NEIGH"); + fix_peri_neigh = dynamic_cast( modify->add_fix("PERI_NEIGH all PERI_NEIGH")); neighbor->add_request(this); } diff --git a/src/QEQ/fix_qeq.cpp b/src/QEQ/fix_qeq.cpp index 20b7b90eee..b586ecb9d9 100644 --- a/src/QEQ/fix_qeq.cpp +++ b/src/QEQ/fix_qeq.cpp @@ -308,7 +308,7 @@ void FixQEq::init() error->warning(FLERR,"Fix efield is ignored during charge equilibration"); if (utils::strmatch(update->integrate_style,"^respa")) - nlevels_respa = ((Respa *) update->integrate)->nlevels; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; // compute net charge and print warning if too large diff --git a/src/QEQ/fix_qeq_fire.cpp b/src/QEQ/fix_qeq_fire.cpp index 219106b702..d4dc68ace2 100644 --- a/src/QEQ/fix_qeq_fire.cpp +++ b/src/QEQ/fix_qeq_fire.cpp @@ -81,8 +81,8 @@ void FixQEqFire::init() if (comm->me == 0) error->warning(FLERR,"Fix qeq/fire tolerance may be too small for damped fires"); - comb3 = (PairComb3 *) force->pair_match("^comb3",0); - if (!comb3) comb = (PairComb *) force->pair_match("^comb",0); + comb3 = dynamic_cast( force->pair_match("^comb3",0)); + if (!comb3) comb = dynamic_cast( force->pair_match("^comb",0)); } /* ---------------------------------------------------------------------- */ diff --git a/src/QTB/fix_qtb.cpp b/src/QTB/fix_qtb.cpp index ab82759e79..f9faf2475c 100644 --- a/src/QTB/fix_qtb.cpp +++ b/src/QTB/fix_qtb.cpp @@ -218,7 +218,7 @@ void FixQTB::init() // respa if (utils::strmatch(update->integrate_style,"^respa")) - nlevels_respa = ((Respa *) update->integrate)->nlevels; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; } /* ---------------------------------------------------------------------- @@ -229,9 +229,9 @@ void FixQTB::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_flevel_f(nlevels_respa-1); post_force_respa(vflag,nlevels_respa-1,0); - ((Respa *) update->integrate)->copy_f_flevel(nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_f_flevel(nlevels_respa-1); } } diff --git a/src/REACTION/fix_bond_react.cpp b/src/REACTION/fix_bond_react.cpp index d50c46a04c..385b5788c1 100644 --- a/src/REACTION/fix_bond_react.cpp +++ b/src/REACTION/fix_bond_react.cpp @@ -792,7 +792,7 @@ void FixBondReact::init() { if (utils::strmatch(update->integrate_style,"^respa")) - nlevels_respa = ((Respa *) update->integrate)->nlevels; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; // check cutoff for iatomtype,jatomtype for (int i = 0; i < nreacts; i++) { diff --git a/src/REAXFF/compute_spec_atom.cpp b/src/REAXFF/compute_spec_atom.cpp index 66886cd1e2..1df4ae559b 100644 --- a/src/REAXFF/compute_spec_atom.cpp +++ b/src/REAXFF/compute_spec_atom.cpp @@ -40,7 +40,7 @@ ComputeSpecAtom::ComputeSpecAtom(LAMMPS *lmp, int narg, char **arg) : else size_peratom_cols = nvalues; // get reference to ReaxFF pair style - reaxff = (PairReaxFF *) force->pair_match("^reax..",0); + reaxff = dynamic_cast( force->pair_match("^reax..",0)); pack_choice = new FnPtrPack[nvalues]; diff --git a/src/REAXFF/fix_qeq_reaxff.cpp b/src/REAXFF/fix_qeq_reaxff.cpp index 83a5096412..4184607474 100644 --- a/src/REAXFF/fix_qeq_reaxff.cpp +++ b/src/REAXFF/fix_qeq_reaxff.cpp @@ -141,7 +141,7 @@ FixQEqReaxFF::FixQEqReaxFF(LAMMPS *lmp, int narg, char **arg) : // perform initial allocation of atom-based arrays // register with Atom class - reaxff = (PairReaxFF *) force->pair_match("^reax..",0); + reaxff = dynamic_cast( force->pair_match("^reax..",0)); s_hist = t_hist = nullptr; atom->add_callback(Atom::GROW); @@ -395,7 +395,7 @@ void FixQEqReaxFF::init() efield = nullptr; auto fixes = modify->get_fix_by_style("^efield"); - if (fixes.size() == 1) efield = (FixEfield *) fixes.front(); + if (fixes.size() == 1) efield = dynamic_cast( fixes.front()); else if (fixes.size() > 1) error->all(FLERR, "There may be only one fix efield instance used with fix {}", style); @@ -423,7 +423,7 @@ void FixQEqReaxFF::init() init_taper(); if (utils::strmatch(update->integrate_style,"^respa")) - nlevels_respa = ((Respa *) update->integrate)->nlevels; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; } /* ---------------------------------------------------------------------- */ diff --git a/src/REAXFF/fix_reaxff_bonds.cpp b/src/REAXFF/fix_reaxff_bonds.cpp index 4a9477f3f6..4b96cb21a1 100644 --- a/src/REAXFF/fix_reaxff_bonds.cpp +++ b/src/REAXFF/fix_reaxff_bonds.cpp @@ -101,7 +101,7 @@ void FixReaxFFBonds::setup(int /*vflag*/) void FixReaxFFBonds::init() { - reaxff = (PairReaxFF *) force->pair_match("^reax..",0); + reaxff = dynamic_cast( force->pair_match("^reax..",0)); if (reaxff == nullptr) error->all(FLERR,"Cannot use fix reaxff/bonds without " "pair_style reaxff, reaxff/kk, or reaxff/omp"); } diff --git a/src/REAXFF/fix_reaxff_species.cpp b/src/REAXFF/fix_reaxff_species.cpp index 692758052e..58376a88fc 100644 --- a/src/REAXFF/fix_reaxff_species.cpp +++ b/src/REAXFF/fix_reaxff_species.cpp @@ -275,7 +275,7 @@ void FixReaxFFSpecies::init() if (atom->tag_enable == 0) error->all(FLERR, "Cannot use fix reaxff/species unless atoms have IDs"); - reaxff = (PairReaxFF *) force->pair_match("^reax..", 0); + reaxff = dynamic_cast( force->pair_match("^reax..", 0)); if (reaxff == nullptr) error->all(FLERR, "Cannot use fix reaxff/species without " @@ -297,7 +297,7 @@ void FixReaxFFSpecies::init() // create a fix to point to fix_ave_atom for averaging stored properties auto fixcmd = fmt::format("SPECBOND_{} all ave/atom {} {} {}", id, nevery, nrepeat, nfreq); for (int i = 1; i < 32; ++i) fixcmd += fmt::format(" c_SPECATOM_{}[{}]", id, i); - f_SPECBOND = (FixAveAtom *) modify->add_fix(fixcmd); + f_SPECBOND = dynamic_cast( modify->add_fix(fixcmd)); setupflag = 1; } } diff --git a/src/REAXFF/pair_reaxff.cpp b/src/REAXFF/pair_reaxff.cpp index 94646fd8a7..e78edea9a9 100644 --- a/src/REAXFF/pair_reaxff.cpp +++ b/src/REAXFF/pair_reaxff.cpp @@ -351,7 +351,7 @@ void PairReaxFF::init_style() api->system->acks2_flag = acks2_fixes.size(); if (api->system->acks2_flag) - api->workspace->s = ((FixACKS2ReaxFF *)acks2_fixes.front())->get_s(); + api->workspace->s = (dynamic_cast(acks2_fixes.front()))->get_s(); api->system->n = atom->nlocal; // my atoms api->system->N = atom->nlocal + atom->nghost; // mine + ghosts @@ -373,7 +373,7 @@ void PairReaxFF::init_style() "increased neighbor list skin."); if (fix_reaxff == nullptr) - fix_reaxff = (FixReaxFF *) modify->add_fix(fmt::format("{} all REAXFF",fix_id)); + fix_reaxff = dynamic_cast( modify->add_fix(fmt::format("{} all REAXFF",fix_id))); } /* ---------------------------------------------------------------------- */ @@ -467,7 +467,7 @@ void PairReaxFF::compute(int eflag, int vflag) if (api->system->acks2_flag) { auto ifix = modify->get_fix_by_style("^acks2/reax").front(); - api->workspace->s = ((FixACKS2ReaxFF*) ifix)->get_s(); + api->workspace->s = (dynamic_cast( ifix))->get_s(); } // setup data structures diff --git a/src/REPLICA/compute_event_displace.cpp b/src/REPLICA/compute_event_displace.cpp index cfb6307e63..6a8791de71 100644 --- a/src/REPLICA/compute_event_displace.cpp +++ b/src/REPLICA/compute_event_displace.cpp @@ -69,7 +69,7 @@ void ComputeEventDisplace::init() int ifix = modify->find_fix(id_event); if (ifix < 0) error->all(FLERR, "Could not find compute event/displace fix ID"); - fix_event = (FixEvent*) modify->fix[ifix]; + fix_event = dynamic_cast( modify->fix[ifix]); if (strcmp(fix_event->style,"EVENT/PRD") != 0 && strcmp(fix_event->style,"EVENT/TAD") != 0 && diff --git a/src/REPLICA/hyper.cpp b/src/REPLICA/hyper.cpp index d6787f0b98..00c594e7a3 100644 --- a/src/REPLICA/hyper.cpp +++ b/src/REPLICA/hyper.cpp @@ -89,7 +89,7 @@ void Hyper::command(int narg, char **arg) } else { int ifix = modify->find_fix(id_fix); if (ifix < 0) error->all(FLERR,"Could not find fix ID for hyper"); - fix_hyper = (FixHyper *) modify->fix[ifix]; + fix_hyper = dynamic_cast( modify->fix[ifix]); int dim; int *hyperflag = (int *) fix_hyper->extract("hyperflag",dim); if (hyperflag == nullptr || *hyperflag == 0) @@ -101,7 +101,7 @@ void Hyper::command(int narg, char **arg) // create FixEventHyper class to store event and pre-quench states - fix_event = (FixEventHyper *) modify->add_fix("hyper_event all EVENT/HYPER"); + fix_event = dynamic_cast( modify->add_fix("hyper_event all EVENT/HYPER")); // create Finish for timing output @@ -112,7 +112,7 @@ void Hyper::command(int narg, char **arg) int icompute = modify->find_compute(id_compute); if (icompute < 0) error->all(FLERR,"Could not find compute ID for hyper"); - compute_event = (ComputeEventDisplace *) modify->compute[icompute]; + compute_event = dynamic_cast( modify->compute[icompute]); compute_event->reset_extra_compute_fix("hyper_event"); // reset reneighboring criteria since will perform minimizations diff --git a/src/REPLICA/neb.cpp b/src/REPLICA/neb.cpp index 88e1fddfa5..a811dabfd5 100644 --- a/src/REPLICA/neb.cpp +++ b/src/REPLICA/neb.cpp @@ -178,7 +178,7 @@ void NEB::run() if (fixes.size() != 1) error->all(FLERR,"NEB requires use of exactly one fix neb instance"); - fneb = (FixNEB *) fixes[0]; + fneb = dynamic_cast( fixes[0]); if (verbose) numall =7; else numall = 4; memory->create(all,nreplica,numall,"neb:all"); diff --git a/src/REPLICA/prd.cpp b/src/REPLICA/prd.cpp index ced3f6d0e7..671bb49b64 100644 --- a/src/REPLICA/prd.cpp +++ b/src/REPLICA/prd.cpp @@ -167,7 +167,7 @@ void PRD::command(int narg, char **arg) // create FixEventPRD class to store event and pre-quench states - fix_event = (FixEventPRD *) modify->add_fix("prd_event all EVENT/PRD"); + fix_event = dynamic_cast( modify->add_fix("prd_event all EVENT/PRD")); // create Finish for timing output diff --git a/src/REPLICA/tad.cpp b/src/REPLICA/tad.cpp index bf44c9fc50..91ea2a0a29 100644 --- a/src/REPLICA/tad.cpp +++ b/src/REPLICA/tad.cpp @@ -131,11 +131,11 @@ void TAD::command(int narg, char **arg) // create FixEventTAD object to store last event - fix_event = (FixEventTAD *) modify->add_fix("tad_event all EVENT/TAD"); + fix_event = dynamic_cast( modify->add_fix("tad_event all EVENT/TAD")); // create FixStore object to store revert state - fix_revert = (FixStore *) modify->add_fix("tad_revert all STORE peratom 0 7"); + fix_revert = dynamic_cast( modify->add_fix("tad_revert all STORE peratom 0 7")); // create Finish for timing output @@ -844,7 +844,7 @@ void TAD::add_event() int ievent = n_event_list++; fix_event_list[ievent] - = (FixEventTAD *) modify->add_fix(fmt::format("tad_event_{} all EVENT/TAD", ievent)); + = dynamic_cast( modify->add_fix(fmt::format("tad_event_{} all EVENT/TAD", ievent))); // store quenched state for new event diff --git a/src/REPLICA/temper_grem.cpp b/src/REPLICA/temper_grem.cpp index 09672980a2..72dd331491 100644 --- a/src/REPLICA/temper_grem.cpp +++ b/src/REPLICA/temper_grem.cpp @@ -82,7 +82,7 @@ void TemperGrem::command(int narg, char **arg) if (strcmp(arg[3],modify->fix[whichfix]->id) == 0) break; if (whichfix == modify->nfix) error->universe_all(FLERR,"Tempering fix ID is not defined"); - fix_grem = (FixGrem*)(modify->fix[whichfix]); + fix_grem = dynamic_cast(modify->fix[whichfix]); // Check input values lambdas should be equal, assign other gREM values if (lambda != fix_grem->lambda) diff --git a/src/RIGID/compute_erotate_rigid.cpp b/src/RIGID/compute_erotate_rigid.cpp index 4217aa8e0a..6e51e4853f 100644 --- a/src/RIGID/compute_erotate_rigid.cpp +++ b/src/RIGID/compute_erotate_rigid.cpp @@ -66,8 +66,8 @@ double ComputeERotateRigid::compute_scalar() if (strncmp(modify->fix[irfix]->style,"rigid",5) == 0) { if (strstr(modify->fix[irfix]->style,"/small")) { - scalar = ((FixRigidSmall *) modify->fix[irfix])->extract_erotational(); - } else scalar = ((FixRigid *) modify->fix[irfix])->extract_erotational(); + scalar = (dynamic_cast( modify->fix[irfix]))->extract_erotational(); + } else scalar = (dynamic_cast( modify->fix[irfix]))->extract_erotational(); } scalar *= force->mvv2e; return scalar; diff --git a/src/RIGID/compute_ke_rigid.cpp b/src/RIGID/compute_ke_rigid.cpp index 48f04e9cff..1b858dea15 100644 --- a/src/RIGID/compute_ke_rigid.cpp +++ b/src/RIGID/compute_ke_rigid.cpp @@ -65,8 +65,8 @@ double ComputeKERigid::compute_scalar() if (strncmp(modify->fix[irfix]->style,"rigid",5) == 0) { if (strstr(modify->fix[irfix]->style,"/small")) { - scalar = ((FixRigidSmall *) modify->fix[irfix])->extract_ke(); - } else scalar = ((FixRigid *) modify->fix[irfix])->extract_ke(); + scalar = (dynamic_cast( modify->fix[irfix]))->extract_ke(); + } else scalar = (dynamic_cast( modify->fix[irfix]))->extract_ke(); } scalar *= force->mvv2e; return scalar; diff --git a/src/RIGID/compute_rigid_local.cpp b/src/RIGID/compute_rigid_local.cpp index 44708c7730..21b232fdfe 100644 --- a/src/RIGID/compute_rigid_local.cpp +++ b/src/RIGID/compute_rigid_local.cpp @@ -111,7 +111,7 @@ void ComputeRigidLocal::init() int ifix = modify->find_fix(idrigid); if (ifix < 0) error->all(FLERR,"FixRigidSmall ID for compute rigid/local does not exist"); - fixrigid = (FixRigidSmall *) modify->fix[ifix]; + fixrigid = dynamic_cast( modify->fix[ifix]); int flag = 0; if (strstr(fixrigid->style,"rigid/") == nullptr) flag = 1; diff --git a/src/RIGID/fix_ehex.cpp b/src/RIGID/fix_ehex.cpp index 866d5b81b7..01fe76757b 100644 --- a/src/RIGID/fix_ehex.cpp +++ b/src/RIGID/fix_ehex.cpp @@ -196,7 +196,7 @@ void FixEHEX::init() if (cnt_shake > 1) error->all(FLERR,"Multiple instances of fix shake/rattle detected (not supported yet)"); else if (cnt_shake == 1) { - fshake = ((FixShake*) modify->fix[id_shake]); + fshake = (dynamic_cast( modify->fix[id_shake])); } else if (cnt_shake == 0) error->all(FLERR, "Fix ehex was configured with keyword constrain, but shake/rattle was not defined"); diff --git a/src/RIGID/fix_rigid.cpp b/src/RIGID/fix_rigid.cpp index b1a8b15335..f21d46d576 100644 --- a/src/RIGID/fix_rigid.cpp +++ b/src/RIGID/fix_rigid.cpp @@ -676,9 +676,9 @@ void FixRigid::init() // atom style pointers to particles that store extra info - avec_ellipsoid = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); - avec_line = (AtomVecLine *) atom->style_match("line"); - avec_tri = (AtomVecTri *) atom->style_match("tri"); + avec_ellipsoid = dynamic_cast( atom->style_match("ellipsoid")); + avec_line = dynamic_cast( atom->style_match("line")); + avec_tri = dynamic_cast( atom->style_match("tri")); // warn if more than one rigid fix // if earlyflag, warn if any post-force fixes come after a rigid fix @@ -737,7 +737,7 @@ void FixRigid::init() dtq = 0.5 * update->dt; if (utils::strmatch(update->integrate_style,"^respa")) - step_respa = ((Respa *) update->integrate)->step; + step_respa = (dynamic_cast( update->integrate))->step; // setup rigid bodies, using current atom info. if reinitflag is not set, // do the initialization only once, b/c properties may not be re-computable diff --git a/src/RIGID/fix_rigid_nh.cpp b/src/RIGID/fix_rigid_nh.cpp index 17902a05aa..9f09d18f61 100644 --- a/src/RIGID/fix_rigid_nh.cpp +++ b/src/RIGID/fix_rigid_nh.cpp @@ -270,7 +270,7 @@ void FixRigidNH::init() for (int i = 0; i < modify->nfix; i++) if (strcmp(modify->fix[i]->style,"deform") == 0) { - int *dimflag = ((FixDeform *) modify->fix[i])->dimflag; + int *dimflag = (dynamic_cast( modify->fix[i]))->dimflag; if ((p_flag[0] && dimflag[0]) || (p_flag[1] && dimflag[1]) || (p_flag[2] && dimflag[2])) error->all(FLERR,"Cannot use fix rigid npt/nph and fix deform on " diff --git a/src/RIGID/fix_rigid_nh_small.cpp b/src/RIGID/fix_rigid_nh_small.cpp index 4111266773..aa8cafb6ab 100644 --- a/src/RIGID/fix_rigid_nh_small.cpp +++ b/src/RIGID/fix_rigid_nh_small.cpp @@ -268,7 +268,7 @@ void FixRigidNHSmall::init() for (int i = 0; i < modify->nfix; i++) if (strcmp(modify->fix[i]->style,"deform") == 0) { - int *dimflag = ((FixDeform *) modify->fix[i])->dimflag; + int *dimflag = (dynamic_cast( modify->fix[i]))->dimflag; if ((p_flag[0] && dimflag[0]) || (p_flag[1] && dimflag[1]) || (p_flag[2] && dimflag[2])) error->all(FLERR,"Cannot use fix rigid npt/nph and fix deform on " diff --git a/src/RIGID/fix_rigid_small.cpp b/src/RIGID/fix_rigid_small.cpp index 2fa704ffe0..ec3e58d5f5 100644 --- a/src/RIGID/fix_rigid_small.cpp +++ b/src/RIGID/fix_rigid_small.cpp @@ -432,9 +432,9 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) : // atom style pointers to particles that store extra info - avec_ellipsoid = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); - avec_line = (AtomVecLine *) atom->style_match("line"); - avec_tri = (AtomVecTri *) atom->style_match("tri"); + avec_ellipsoid = dynamic_cast( atom->style_match("ellipsoid")); + avec_line = dynamic_cast( atom->style_match("line")); + avec_tri = dynamic_cast( atom->style_match("tri")); // compute per body forces and torques inside final_integrate() by default @@ -582,7 +582,7 @@ void FixRigidSmall::init() dtq = 0.5 * update->dt; if (utils::strmatch(update->integrate_style,"^respa")) - step_respa = ((Respa *) update->integrate)->step; + step_respa = (dynamic_cast( update->integrate))->step; } /* ---------------------------------------------------------------------- diff --git a/src/RIGID/fix_shake.cpp b/src/RIGID/fix_shake.cpp index b9fa66bec7..d74f72fb69 100644 --- a/src/RIGID/fix_shake.cpp +++ b/src/RIGID/fix_shake.cpp @@ -367,10 +367,10 @@ void FixShake::init() if (utils::strmatch(update->integrate_style,"^respa")) { if (update->whichflag > 0) { auto fixes = modify->get_fix_by_style("^RESPA"); - if (fixes.size() > 0) fix_respa = (FixRespa *) fixes.front(); + if (fixes.size() > 0) fix_respa = dynamic_cast( fixes.front()); else error->all(FLERR,"Run style respa did not create fix RESPA"); } - Respa *respa_style = (Respa *) update->integrate; + auto respa_style = dynamic_cast( update->integrate); nlevels_respa = respa_style->nlevels; loop_respa = respa_style->loop; step_respa = respa_style->step; @@ -3026,9 +3026,9 @@ void FixShake::shake_end_of_step(int vflag) { // apply correction to all rRESPA levels for (int ilevel = 0; ilevel < nlevels_respa; ilevel++) { - ((Respa *) update->integrate)->copy_flevel_f(ilevel); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel); FixShake::post_force_respa(vflag,ilevel,loop_respa[ilevel]-1); - ((Respa *) update->integrate)->copy_f_flevel(ilevel); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel); } if (!rattle) dtf_inner = step_respa[0] * force->ftm2v; } diff --git a/src/SHOCK/fix_msst.cpp b/src/SHOCK/fix_msst.cpp index 90a0c45d9a..35010fc31c 100644 --- a/src/SHOCK/fix_msst.cpp +++ b/src/SHOCK/fix_msst.cpp @@ -302,7 +302,7 @@ void FixMSST::init() if (dftb) { for (int i = 0; i < modify->nfix; i++) if (utils::strmatch(modify->fix[i]->style,"^external$")) - fix_external = (FixExternal *) modify->fix[i]; + fix_external = dynamic_cast( modify->fix[i]); if (fix_external == nullptr) error->all(FLERR,"Fix msst dftb cannot be used w/out fix external"); } diff --git a/src/SPIN/compute_spin.cpp b/src/SPIN/compute_spin.cpp index 174cec7d59..a6dfdf79d2 100644 --- a/src/SPIN/compute_spin.cpp +++ b/src/SPIN/compute_spin.cpp @@ -84,7 +84,7 @@ void ComputeSpin::init() // loop 1: obtain # of Pairs, and # of Pair/Spin styles - PairHybrid *hybrid = (PairHybrid *)force->pair_match("^hybrid",0); + PairHybrid *hybrid = dynamic_cast(force->pair_match("^hybrid",0)); if (force->pair_match("^spin",0,0)) { // only one Pair/Spin style pair = force->pair_match("^spin",0,0); if (hybrid == nullptr) npairs = 1; @@ -112,11 +112,11 @@ void ComputeSpin::init() int count = 0; if (npairspin == 1) { count = 1; - spin_pairs[0] = (PairSpin *) force->pair_match("^spin",0,0); + spin_pairs[0] = dynamic_cast( force->pair_match("^spin",0,0)); } else if (npairspin > 1) { for (int i = 0; ipair_match("^spin",0,i)) { - spin_pairs[count] = (PairSpin *) force->pair_match("^spin",0,i); + spin_pairs[count] = dynamic_cast( force->pair_match("^spin",0,i)); count++; } } @@ -141,7 +141,7 @@ void ComputeSpin::init() for (iforce = 0; iforce < modify->nfix; iforce++) { if (utils::strmatch(modify->fix[iforce]->style,"^precession/spin")) { precession_spin_flag = 1; - lockprecessionspin = (FixPrecessionSpin *) modify->fix[iforce]; + lockprecessionspin = dynamic_cast( modify->fix[iforce]); } } } diff --git a/src/SPIN/fix_langevin_spin.cpp b/src/SPIN/fix_langevin_spin.cpp index 7d9af83d12..a29ce8aa2c 100644 --- a/src/SPIN/fix_langevin_spin.cpp +++ b/src/SPIN/fix_langevin_spin.cpp @@ -119,9 +119,9 @@ void FixLangevinSpin::init() void FixLangevinSpin::setup(int vflag) { if (utils::strmatch(update->integrate_style,"^respa")) { - ((Respa *) update->integrate)->copy_flevel_f(nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_flevel_f(nlevels_respa-1); post_force_respa(vflag,nlevels_respa-1,0); - ((Respa *) update->integrate)->copy_f_flevel(nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_f_flevel(nlevels_respa-1); } else post_force(vflag); } diff --git a/src/SPIN/fix_nve_spin.cpp b/src/SPIN/fix_nve_spin.cpp index 970af9c4fb..062f3c1b00 100644 --- a/src/SPIN/fix_nve_spin.cpp +++ b/src/SPIN/fix_nve_spin.cpp @@ -178,7 +178,7 @@ void FixNVESpin::init() // loop 1: obtain # of Pairs, and # of Pair/Spin styles npairspin = 0; - PairHybrid *hybrid = (PairHybrid *)force->pair_match("^hybrid",0); + PairHybrid *hybrid = dynamic_cast(force->pair_match("^hybrid",0)); if (force->pair_match("^spin",0,0)) { // only one Pair/Spin style pair = force->pair_match("^spin",0,0); if (hybrid == nullptr) npairs = 1; @@ -206,11 +206,11 @@ void FixNVESpin::init() int count1 = 0; if (npairspin == 1) { count1 = 1; - spin_pairs[0] = (PairSpin *) force->pair_match("^spin",0,0); + spin_pairs[0] = dynamic_cast( force->pair_match("^spin",0,0)); } else if (npairspin > 1) { for (int i = 0; ipair_match("^spin",0,i)) { - spin_pairs[count1] = (PairSpin *) force->pair_match("^spin",0,i); + spin_pairs[count1] = dynamic_cast( force->pair_match("^spin",0,i)); count1++; } } @@ -254,7 +254,7 @@ void FixNVESpin::init() for (iforce = 0; iforce < modify->nfix; iforce++) { if (utils::strmatch(modify->fix[iforce]->style,"^precession/spin")) { precession_spin_flag = 1; - lockprecessionspin[count2] = (FixPrecessionSpin *) modify->fix[iforce]; + lockprecessionspin[count2] = dynamic_cast( modify->fix[iforce]); count2++; } } @@ -287,7 +287,7 @@ void FixNVESpin::init() for (iforce = 0; iforce < modify->nfix; iforce++) { if (utils::strmatch(modify->fix[iforce]->style,"^langevin/spin")) { maglangevin_flag = 1; - locklangevinspin[count2] = (FixLangevinSpin *) modify->fix[iforce]; + locklangevinspin[count2] = dynamic_cast( modify->fix[iforce]); count2++; } } @@ -301,7 +301,7 @@ void FixNVESpin::init() for (iforce = 0; iforce < modify->nfix; iforce++) { if (utils::strmatch(modify->fix[iforce]->style,"^setforce/spin")) { setforce_spin_flag = 1; - locksetforcespin = (FixSetForceSpin *) modify->fix[iforce]; + locksetforcespin = dynamic_cast( modify->fix[iforce]); } } diff --git a/src/SPIN/fix_precession_spin.cpp b/src/SPIN/fix_precession_spin.cpp index 44cb6e1071..6f4bc10b87 100644 --- a/src/SPIN/fix_precession_spin.cpp +++ b/src/SPIN/fix_precession_spin.cpp @@ -273,7 +273,7 @@ void FixPrecessionSpin::init() K6h = K6/hbar; if (utils::strmatch(update->integrate_style,"^respa")) { - ilevel_respa = ((Respa *) update->integrate)->nlevels-1; + ilevel_respa = (dynamic_cast( update->integrate))->nlevels-1; if (respa_level >= 0) ilevel_respa = MIN(respa_level,ilevel_respa); } @@ -305,9 +305,9 @@ void FixPrecessionSpin::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(ilevel_respa); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel_respa); post_force_respa(vflag,ilevel_respa,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel_respa); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel_respa); } } diff --git a/src/SPIN/neb_spin.cpp b/src/SPIN/neb_spin.cpp index 27097051e4..692883fc0a 100644 --- a/src/SPIN/neb_spin.cpp +++ b/src/SPIN/neb_spin.cpp @@ -172,7 +172,7 @@ void NEBSpin::run() if (fixes.size() != 1) error->all(FLERR,"NEBSpin requires use of exactly one fix neb/spin instance"); - fneb = (FixNEBSpin *) fixes[0]; + fneb = dynamic_cast( fixes[0]); if (verbose) numall =7; else numall = 4; memory->create(all,nreplica,numall,"neb:all"); diff --git a/src/SPIN/pair_spin.cpp b/src/SPIN/pair_spin.cpp index c2fb771def..d236e910c7 100644 --- a/src/SPIN/pair_spin.cpp +++ b/src/SPIN/pair_spin.cpp @@ -96,7 +96,7 @@ void PairSpin::init_style() auto fixes = modify->get_fix_by_style("^nve/spin"); if (fixes.size() == 1) - lattice_flag = ((FixNVESpin *) fixes.front())->lattice_flag; + lattice_flag = (dynamic_cast( fixes.front()))->lattice_flag; else if (fixes.size() > 1) error->warning(FLERR,"Using multiple instances of fix nve/spin or neb/spin"); diff --git a/src/SRD/fix_srd.cpp b/src/SRD/fix_srd.cpp index f4bcbec0b5..dd27da08ea 100644 --- a/src/SRD/fix_srd.cpp +++ b/src/SRD/fix_srd.cpp @@ -289,9 +289,9 @@ FixSRD::FixSRD(LAMMPS *lmp, int narg, char **arg) : // atom style pointers to particles that store bonus info - avec_ellipsoid = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); - avec_line = (AtomVecLine *) atom->style_match("line"); - avec_tri = (AtomVecTri *) atom->style_match("tri"); + avec_ellipsoid = dynamic_cast( atom->style_match("ellipsoid")); + avec_line = dynamic_cast( atom->style_match("line")); + avec_tri = dynamic_cast( atom->style_match("tri")); // fix parameters @@ -369,7 +369,7 @@ void FixSRD::init() if (strcmp(modify->fix[m]->style, "wall/srd") == 0) { if (wallexist) error->all(FLERR, "Cannot use fix wall/srd more than once"); wallexist = 1; - wallfix = (FixWallSRD *) modify->fix[m]; + wallfix = dynamic_cast( modify->fix[m]); nwall = wallfix->nwall; wallvarflag = wallfix->varflag; wallwhich = wallfix->wallwhich; @@ -394,7 +394,7 @@ void FixSRD::init() if (fixes[i]->box_change & BOX_CHANGE_SHAPE) change_shape = 1; if (strcmp(fixes[i]->style, "deform") == 0) { deformflag = 1; - FixDeform *deform = (FixDeform *) modify->fix[i]; + auto deform = dynamic_cast( modify->fix[i]); if ((deform->box_change & BOX_CHANGE_SHAPE) && deform->remapflag != Domain::V_REMAP) error->all(FLERR, "Using fix srd with inconsistent fix deform remap option"); } diff --git a/src/UEF/compute_pressure_uef.cpp b/src/UEF/compute_pressure_uef.cpp index 5105a58ddf..da35b7635d 100644 --- a/src/UEF/compute_pressure_uef.cpp +++ b/src/UEF/compute_pressure_uef.cpp @@ -57,7 +57,7 @@ void ComputePressureUef::init() if (i==modify->nfix) error->all(FLERR,"Can't use compute pressure/uef without defining a fix nvt/npt/uef"); ifix_uef=i; - ((FixNHUef*) modify->fix[ifix_uef])->get_ext_flags(ext_flags); + (dynamic_cast( modify->fix[ifix_uef]))->get_ext_flags(ext_flags); if (strcmp(temperature->style,"temp/uef") != 0) error->warning(FLERR,"The temperature used in compute pressure/ued is not of style temp/uef"); @@ -127,7 +127,7 @@ void ComputePressureUef::compute_vector() else { double r[3][3]; - ( (FixNHUef*) modify->fix[ifix_uef])->get_rot(r); + ( dynamic_cast( modify->fix[ifix_uef]))->get_rot(r); virial_rot(virial,r); } if (keflag) { @@ -158,7 +158,7 @@ void ComputePressureUef::compute_vector() ------------------------------------------------------------------------- */ void ComputePressureUef::update_rot() { - ( (FixNHUef*) modify->fix[ifix_uef])->get_rot(rot); + ( dynamic_cast( modify->fix[ifix_uef]))->get_rot(rot); } /* ---------------------------------------------------------------------- diff --git a/src/UEF/compute_temp_uef.cpp b/src/UEF/compute_temp_uef.cpp index 23536330c0..8d02317267 100644 --- a/src/UEF/compute_temp_uef.cpp +++ b/src/UEF/compute_temp_uef.cpp @@ -61,7 +61,7 @@ void ComputeTempUef::compute_vector() ComputeTemp::compute_vector(); if (rot_flag) { double rot[3][3]; - ( (FixNHUef*) modify->fix[ifix_uef])->get_rot(rot); + ( dynamic_cast( modify->fix[ifix_uef]))->get_rot(rot); virial_rot(vector,rot); } diff --git a/src/UEF/dump_cfg_uef.cpp b/src/UEF/dump_cfg_uef.cpp index f055ac3f7d..c87e1632ef 100644 --- a/src/UEF/dump_cfg_uef.cpp +++ b/src/UEF/dump_cfg_uef.cpp @@ -68,8 +68,8 @@ void DumpCFGUef::write_header(bigint n) // so molecules are not split across periodic box boundaries double box[3][3],rot[3][3]; - ((FixNHUef*) modify->fix[ifix_uef])->get_box(box); - ((FixNHUef*) modify->fix[ifix_uef])->get_rot(rot); + (dynamic_cast( modify->fix[ifix_uef]))->get_box(box); + (dynamic_cast( modify->fix[ifix_uef]))->get_rot(rot); // rot goes from "lab frame" to "upper triangular frame" // it's transpose takes the simulation box to the flow frame for (int i=0;i<3;i++) diff --git a/src/UEF/fix_nh_uef.cpp b/src/UEF/fix_nh_uef.cpp index a88b389611..e1342adc17 100644 --- a/src/UEF/fix_nh_uef.cpp +++ b/src/UEF/fix_nh_uef.cpp @@ -272,9 +272,9 @@ void FixNHUef::setup(int j) error->all(FLERR,"Initial box is not close enough to the expected uef box"); uefbox->get_rot(rot); - ((ComputeTempUef*) temperature)->yes_rot(); - ((ComputePressureUef*) pressure)->in_fix = true; - ((ComputePressureUef*) pressure)->update_rot(); + (dynamic_cast( temperature))->yes_rot(); + (dynamic_cast( pressure))->in_fix = true; + (dynamic_cast( pressure))->update_rot(); FixNH::setup(j); } @@ -286,12 +286,12 @@ void FixNHUef::initial_integrate(int vflag) inv_rotate_x(rot); inv_rotate_v(rot); inv_rotate_f(rot); - ((ComputeTempUef*) temperature)->no_rot(); + (dynamic_cast( temperature))->no_rot(); FixNH::initial_integrate(vflag); rotate_x(rot); rotate_v(rot); rotate_f(rot); - ((ComputeTempUef*) temperature)->yes_rot(); + (dynamic_cast( temperature))->yes_rot(); } /* ---------------------------------------------------------------------- @@ -302,12 +302,12 @@ void FixNHUef::initial_integrate_respa(int vflag, int ilevel, int iloop) inv_rotate_x(rot); inv_rotate_v(rot); inv_rotate_f(rot); - ((ComputeTempUef*) temperature)->no_rot(); + (dynamic_cast( temperature))->no_rot(); FixNH::initial_integrate_respa(vflag,ilevel,iloop); rotate_x(rot); rotate_v(rot); rotate_f(rot); - ((ComputeTempUef*) temperature)->yes_rot(); + (dynamic_cast( temperature))->yes_rot(); } /* ---------------------------------------------------------------------- @@ -316,14 +316,14 @@ void FixNHUef::initial_integrate_respa(int vflag, int ilevel, int iloop) void FixNHUef::final_integrate() { // update rot here since it must directly follow the virial calculation - ((ComputePressureUef*) pressure)->update_rot(); + (dynamic_cast( pressure))->update_rot(); inv_rotate_v(rot); inv_rotate_f(rot); - ((ComputeTempUef*) temperature)->no_rot(); + (dynamic_cast( temperature))->no_rot(); FixNH::final_integrate(); rotate_v(rot); rotate_f(rot); - ((ComputeTempUef*) temperature)->yes_rot(); + (dynamic_cast( temperature))->yes_rot(); } /* ---------------------------------------------------------------------- @@ -708,7 +708,7 @@ void FixNHUef::restart(char *buf) { int n = size_restart_global(); FixNH::restart(buf); - double *list = (double *) buf; + auto list = (double *) buf; strain[0] = list[n-2]; strain[1] = list[n-1]; uefbox->set_strain(strain[0],strain[1]); diff --git a/src/angle_deprecated.cpp b/src/angle_deprecated.cpp index 9a4ca8c877..55e1651b94 100644 --- a/src/angle_deprecated.cpp +++ b/src/angle_deprecated.cpp @@ -34,7 +34,7 @@ void AngleDeprecated::settings(int, char **) // called, our style was just added at the end of the list of substyles if (utils::strmatch(my_style,"^hybrid")) { - AngleHybrid *hybrid = (AngleHybrid *)force->angle; + auto hybrid = dynamic_cast(force->angle); my_style = hybrid->keywords[hybrid->nstyles]; } diff --git a/src/atom.cpp b/src/atom.cpp index 00b9701689..6491b3849b 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -796,7 +796,7 @@ AtomVec *Atom::style_match(const char *style) { if (strcmp(atom_style,style) == 0) return avec; else if (strcmp(atom_style,"hybrid") == 0) { - auto avec_hybrid = (AtomVecHybrid *) avec; + auto avec_hybrid = dynamic_cast( avec); for (int i = 0; i < avec_hybrid->nstyles; i++) if (strcmp(avec_hybrid->keywords[i],style) == 0) return avec_hybrid->styles[i]; @@ -1841,7 +1841,7 @@ int Atom::shape_consistency(int itype, double one[3] = {-1.0, -1.0, -1.0}; double *shape; - auto avec_ellipsoid = (AtomVecEllipsoid *) style_match("ellipsoid"); + auto avec_ellipsoid = dynamic_cast( style_match("ellipsoid")); auto bonus = avec_ellipsoid->bonus; int flag = 0; @@ -2216,7 +2216,7 @@ void Atom::setup_sort_bins() #ifdef LMP_GPU if (userbinsize == 0.0) { - FixGPU *fix = (FixGPU *)modify->get_fix_by_id("package_gpu"); + FixGPU *fix = dynamic_cast(modify->get_fix_by_id("package_gpu")); if (fix) { const double subx = domain->subhi[0] - domain->sublo[0]; const double suby = domain->subhi[1] - domain->sublo[1]; diff --git a/src/atom_vec_sphere.cpp b/src/atom_vec_sphere.cpp index 5a69944501..dead605920 100644 --- a/src/atom_vec_sphere.cpp +++ b/src/atom_vec_sphere.cpp @@ -95,7 +95,7 @@ void AtomVecSphere::init() for (int i = 0; i < modify->nfix; i++) if (strcmp(modify->fix[i]->style,"adapt") == 0) { - FixAdapt *fix = (FixAdapt *) modify->fix[i]; + auto fix = dynamic_cast( modify->fix[i]); if (fix->diamflag && radvary == 0) error->all(FLERR,"Fix adapt changes particle radii " "but atom_style sphere is not dynamic"); diff --git a/src/balance.cpp b/src/balance.cpp index f2fcda2712..c2f3ee2d5c 100644 --- a/src/balance.cpp +++ b/src/balance.cpp @@ -355,7 +355,7 @@ void Balance::command(int narg, char **arg) // set disable = 0, so weights migrate with atoms for imbfinal calculation if (domain->triclinic) domain->x2lamda(atom->nlocal); - Irregular *irregular = new Irregular(lmp); + auto irregular = new Irregular(lmp); if (wtflag) fixstore->disable = 0; if (style == BISECTION) irregular->migrate_atoms(1,1,rcb->sendproc); else irregular->migrate_atoms(1); @@ -496,8 +496,8 @@ void Balance::weight_storage(char *prefix) if (prefix) cmd = prefix; cmd += "IMBALANCE_WEIGHTS"; - fixstore = (FixStore *) modify->get_fix_by_id(cmd); - if (!fixstore) fixstore = (FixStore *) modify->add_fix(cmd + " all STORE peratom 0 1"); + fixstore = dynamic_cast( modify->get_fix_by_id(cmd)); + if (!fixstore) fixstore = dynamic_cast( modify->add_fix(cmd + " all STORE peratom 0 1")); // do not carry weights with atoms during normal atom migration diff --git a/src/bond_deprecated.cpp b/src/bond_deprecated.cpp index 4f5ec58071..98bf6ea9ae 100644 --- a/src/bond_deprecated.cpp +++ b/src/bond_deprecated.cpp @@ -35,7 +35,7 @@ void BondDeprecated::settings(int, char **) // called, our style was just added at the end of the list of substyles if (utils::strmatch(my_style,"^hybrid")) { - BondHybrid *hybrid = (BondHybrid *)force->bond; + auto hybrid = dynamic_cast(force->bond); my_style = hybrid->keywords[hybrid->nstyles]; } diff --git a/src/compute_angle.cpp b/src/compute_angle.cpp index a7980c3885..e4db464f28 100644 --- a/src/compute_angle.cpp +++ b/src/compute_angle.cpp @@ -37,7 +37,7 @@ ComputeAngle::ComputeAngle(LAMMPS *lmp, int narg, char **arg) : // check if bond style hybrid exists - angle = (AngleHybrid *) force->angle_match("hybrid"); + angle = dynamic_cast( force->angle_match("hybrid")); if (!angle) error->all(FLERR,"Angle style for compute angle command is not hybrid"); size_vector = nsub = angle->nstyles; @@ -60,7 +60,7 @@ void ComputeAngle::init() { // recheck angle style in case it has been changed - angle = (AngleHybrid *) force->angle_match("hybrid"); + angle = dynamic_cast( force->angle_match("hybrid")); if (!angle) error->all(FLERR,"Angle style for compute angle command is not hybrid"); if (angle->nstyles != nsub) diff --git a/src/compute_angmom_chunk.cpp b/src/compute_angmom_chunk.cpp index 1351d379b7..49435c49fc 100644 --- a/src/compute_angmom_chunk.cpp +++ b/src/compute_angmom_chunk.cpp @@ -69,7 +69,7 @@ ComputeAngmomChunk::~ComputeAngmomChunk() void ComputeAngmomChunk::init() { - cchunk = (ComputeChunkAtom *) modify->get_compute_by_id(idchunk); + cchunk = dynamic_cast( modify->get_compute_by_id(idchunk)); if (!cchunk) error->all(FLERR, "Chunk/atom compute does not exist for compute angmom/chunk"); if (strcmp(cchunk->style, "chunk/atom") != 0) error->all(FLERR, "Compute angmom/chunk does not use chunk/atom compute"); @@ -187,7 +187,7 @@ void ComputeAngmomChunk::lock_disable() { int icompute = modify->find_compute(idchunk); if (icompute >= 0) { - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); cchunk->lockcount--; } } diff --git a/src/compute_bond.cpp b/src/compute_bond.cpp index 90d451c9f8..38f15211e0 100644 --- a/src/compute_bond.cpp +++ b/src/compute_bond.cpp @@ -37,7 +37,7 @@ ComputeBond::ComputeBond(LAMMPS *lmp, int narg, char **arg) : // check if bond style hybrid exists - bond = (BondHybrid *) force->bond_match("hybrid"); + bond = dynamic_cast( force->bond_match("hybrid")); if (!bond) error->all(FLERR,"Bond style for compute bond command is not hybrid"); size_vector = nsub = bond->nstyles; @@ -60,7 +60,7 @@ void ComputeBond::init() { // recheck bond style in case it has been changed - bond = (BondHybrid *) force->bond_match("hybrid"); + bond = dynamic_cast( force->bond_match("hybrid")); if (!bond) error->all(FLERR,"Bond style for compute bond command is not hybrid"); if (bond->nstyles != nsub) diff --git a/src/compute_chunk_atom.cpp b/src/compute_chunk_atom.cpp index 235263684d..d9358d5f10 100644 --- a/src/compute_chunk_atom.cpp +++ b/src/compute_chunk_atom.cpp @@ -545,8 +545,8 @@ void ComputeChunkAtom::init() if ((idsflag == ONCE || lockcount) && !fixstore) { id_fix = utils::strdup(id + std::string("_COMPUTE_STORE")); - fixstore = (FixStore *) modify->add_fix(fmt::format("{} {} STORE peratom 1 1", - id_fix, group->names[igroup])); + fixstore = dynamic_cast( modify->add_fix(fmt::format("{} {} STORE peratom 1 1", + id_fix, group->names[igroup]))); } if ((idsflag != ONCE && !lockcount) && fixstore) { diff --git a/src/compute_chunk_spread_atom.cpp b/src/compute_chunk_spread_atom.cpp index 0bcfa3265c..3781e83aa7 100644 --- a/src/compute_chunk_spread_atom.cpp +++ b/src/compute_chunk_spread_atom.cpp @@ -184,7 +184,7 @@ void ComputeChunkSpreadAtom::init_chunk() int icompute = modify->find_compute(idchunk); if (icompute < 0) error->all(FLERR,"Chunk/atom compute does not exist for compute chunk/spread/atom"); - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); if (strcmp(cchunk->style,"chunk/atom") != 0) error->all(FLERR,"Compute chunk/spread/atom does not use chunk/atom compute"); } diff --git a/src/compute_com_chunk.cpp b/src/compute_com_chunk.cpp index 1fac12d9ba..8124a7dccd 100644 --- a/src/compute_com_chunk.cpp +++ b/src/compute_com_chunk.cpp @@ -75,7 +75,7 @@ void ComputeCOMChunk::init() int icompute = modify->find_compute(idchunk); if (icompute < 0) error->all(FLERR,"Chunk/atom compute does not exist for compute com/chunk"); - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); if (strcmp(cchunk->style,"chunk/atom") != 0) error->all(FLERR,"Compute com/chunk does not use chunk/atom compute"); } @@ -180,7 +180,7 @@ void ComputeCOMChunk::lock_disable() { int icompute = modify->find_compute(idchunk); if (icompute >= 0) { - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); cchunk->lockcount--; } } diff --git a/src/compute_coord_atom.cpp b/src/compute_coord_atom.cpp index 4487e82985..e7cd73df19 100644 --- a/src/compute_coord_atom.cpp +++ b/src/compute_coord_atom.cpp @@ -129,7 +129,7 @@ void ComputeCoordAtom::init() { if (cstyle == ORIENT) { int iorientorder = modify->find_compute(id_orientorder); - c_orientorder = (ComputeOrientOrderAtom *) (modify->compute[iorientorder]); + c_orientorder = dynamic_cast (modify->compute[iorientorder]); cutsq = c_orientorder->cutsq; l = c_orientorder->qlcomp; // communicate real and imaginary 2*l+1 components of the normalized vector diff --git a/src/compute_dihedral.cpp b/src/compute_dihedral.cpp index a411ce1a8b..86fd1b116e 100644 --- a/src/compute_dihedral.cpp +++ b/src/compute_dihedral.cpp @@ -37,10 +37,9 @@ ComputeDihedral::ComputeDihedral(LAMMPS *lmp, int narg, char **arg) : // check if dihedral style hybrid exists - dihedral = (DihedralHybrid *) force->dihedral_match("hybrid"); + dihedral = dynamic_cast( force->dihedral_match("hybrid")); if (!dihedral) - error->all(FLERR, - "Dihedral style for compute dihedral command is not hybrid"); + error->all(FLERR, "Dihedral style for compute dihedral command is not hybrid"); size_vector = nsub = dihedral->nstyles; emine = new double[nsub]; @@ -61,10 +60,9 @@ void ComputeDihedral::init() { // recheck dihedral style in case it has been changed - dihedral = (DihedralHybrid *) force->dihedral_match("hybrid"); + dihedral = dynamic_cast( force->dihedral_match("hybrid")); if (!dihedral) - error->all(FLERR, - "Dihedral style for compute dihedral command is not hybrid"); + error->all(FLERR, "Dihedral style for compute dihedral command is not hybrid"); if (dihedral->nstyles != nsub) error->all(FLERR,"Dihedral style for compute dihedral command has changed"); } diff --git a/src/compute_dipole_chunk.cpp b/src/compute_dipole_chunk.cpp index 161f4a5c2b..f1afcc01fd 100644 --- a/src/compute_dipole_chunk.cpp +++ b/src/compute_dipole_chunk.cpp @@ -94,7 +94,7 @@ void ComputeDipoleChunk::init() if (icompute < 0) error->all(FLERR,"Chunk/atom compute does not exist for " "compute dipole/chunk"); - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); if (strcmp(cchunk->style,"chunk/atom") != 0) error->all(FLERR,"Compute dipole/chunk does not use chunk/atom compute"); @@ -232,7 +232,7 @@ void ComputeDipoleChunk::lock_disable() { int icompute = modify->find_compute(idchunk); if (icompute >= 0) { - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); cchunk->lockcount--; } } diff --git a/src/compute_displace_atom.cpp b/src/compute_displace_atom.cpp index c72570b9c6..ba9b5c997f 100644 --- a/src/compute_displace_atom.cpp +++ b/src/compute_displace_atom.cpp @@ -74,8 +74,8 @@ ComputeDisplaceAtom::ComputeDisplaceAtom(LAMMPS *lmp, int narg, char **arg) : // id = compute-ID + COMPUTE_STORE, fix group = compute group id_fix = utils::strdup(std::string(id) + "_COMPUTE_STORE"); - fix = (FixStore *) modify->add_fix(fmt::format("{} {} STORE peratom 1 3", - id_fix, group->names[igroup])); + fix = dynamic_cast( modify->add_fix(fmt::format("{} {} STORE peratom 1 3", + id_fix, group->names[igroup]))); // calculate xu,yu,zu for fix store array // skip if reset from restart file @@ -120,7 +120,7 @@ void ComputeDisplaceAtom::init() { // set fix which stores original atom coords - fix = (FixStore *) modify->get_fix_by_id(id_fix); + fix = dynamic_cast( modify->get_fix_by_id(id_fix)); if (!fix) error->all(FLERR,"Could not find compute displace/atom fix with ID {}", id_fix); if (refreshflag) { diff --git a/src/compute_gyration_chunk.cpp b/src/compute_gyration_chunk.cpp index fe6022cd47..f79325274f 100644 --- a/src/compute_gyration_chunk.cpp +++ b/src/compute_gyration_chunk.cpp @@ -95,7 +95,7 @@ void ComputeGyrationChunk::init() if (icompute < 0) error->all(FLERR,"Chunk/atom compute does not exist for " "compute gyration/chunk"); - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); if (strcmp(cchunk->style,"chunk/atom") != 0) error->all(FLERR,"Compute gyration/chunk does not use chunk/atom compute"); } @@ -286,7 +286,7 @@ void ComputeGyrationChunk::lock_disable() { int icompute = modify->find_compute(idchunk); if (icompute >= 0) { - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); cchunk->lockcount--; } } diff --git a/src/compute_improper.cpp b/src/compute_improper.cpp index 42bb247ac0..3e0780be49 100644 --- a/src/compute_improper.cpp +++ b/src/compute_improper.cpp @@ -37,10 +37,9 @@ ComputeImproper::ComputeImproper(LAMMPS *lmp, int narg, char **arg) : // check if improper style hybrid exists - improper = (ImproperHybrid *) force->improper_match("hybrid"); + improper = dynamic_cast( force->improper_match("hybrid")); if (!improper) - error->all(FLERR, - "Improper style for compute improper command is not hybrid"); + error->all(FLERR, "Improper style for compute improper command is not hybrid"); size_vector = nsub = improper->nstyles; emine = new double[nsub]; @@ -61,10 +60,9 @@ void ComputeImproper::init() { // recheck improper style in case it has been changed - improper = (ImproperHybrid *) force->improper_match("hybrid"); + improper = dynamic_cast( force->improper_match("hybrid")); if (!improper) - error->all(FLERR, - "Improper style for compute improper command is not hybrid"); + error->all(FLERR, "Improper style for compute improper command is not hybrid"); if (improper->nstyles != nsub) error->all(FLERR,"Improper style for compute improper command has changed"); } diff --git a/src/compute_inertia_chunk.cpp b/src/compute_inertia_chunk.cpp index e60192b3ab..ceca61c1b7 100644 --- a/src/compute_inertia_chunk.cpp +++ b/src/compute_inertia_chunk.cpp @@ -74,7 +74,7 @@ void ComputeInertiaChunk::init() if (icompute < 0) error->all(FLERR,"Chunk/atom compute does not exist for " "compute inertia/chunk"); - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); if (strcmp(cchunk->style,"chunk/atom") != 0) error->all(FLERR,"Compute inertia/chunk does not use chunk/atom compute"); } @@ -189,7 +189,7 @@ void ComputeInertiaChunk::lock_disable() { int icompute = modify->find_compute(idchunk); if (icompute >= 0) { - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); cchunk->lockcount--; } } diff --git a/src/compute_msd.cpp b/src/compute_msd.cpp index bff9dffd87..7b2059a0a0 100644 --- a/src/compute_msd.cpp +++ b/src/compute_msd.cpp @@ -63,8 +63,8 @@ ComputeMSD::ComputeMSD(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, a // id = compute-ID + COMPUTE_STORE, fix group = compute group id_fix = utils::strdup(id + std::string("_COMPUTE_STORE")); - fix = (FixStore *) modify->add_fix( - fmt::format("{} {} STORE peratom 1 3", id_fix, group->names[igroup])); + fix = dynamic_cast( modify->add_fix( + fmt::format("{} {} STORE peratom 1 3", id_fix, group->names[igroup]))); // calculate xu,yu,zu for fix store array // skip if reset from restart file @@ -127,7 +127,7 @@ void ComputeMSD::init() { // set fix which stores reference atom coords - fix = (FixStore *) modify->get_fix_by_id(id_fix); + fix = dynamic_cast( modify->get_fix_by_id(id_fix)); if (!fix) error->all(FLERR, "Could not find compute msd fix with ID {}", id_fix); // nmsd = # of atoms in group diff --git a/src/compute_msd_chunk.cpp b/src/compute_msd_chunk.cpp index cea6da100d..8624520cf7 100644 --- a/src/compute_msd_chunk.cpp +++ b/src/compute_msd_chunk.cpp @@ -57,8 +57,8 @@ ComputeMSDChunk::ComputeMSDChunk(LAMMPS *lmp, int narg, char **arg) : // otherwise size reset and init will be done in setup() id_fix = utils::strdup(std::string(id) + "_COMPUTE_STORE"); - fix = (FixStore *) modify->add_fix(fmt::format("{} {} STORE global 1 1", - id_fix,group->names[igroup])); + fix = dynamic_cast( modify->add_fix(fmt::format("{} {} STORE global 1 1", + id_fix,group->names[igroup]))); } /* ---------------------------------------------------------------------- */ @@ -85,7 +85,7 @@ void ComputeMSDChunk::init() int icompute = modify->find_compute(idchunk); if (icompute < 0) error->all(FLERR,"Chunk/atom compute does not exist for compute msd/chunk"); - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); if (strcmp(cchunk->style,"chunk/atom") != 0) error->all(FLERR,"Compute msd/chunk does not use chunk/atom compute"); @@ -93,7 +93,7 @@ void ComputeMSDChunk::init() // if firstflag, will be created in setup() if (!firstflag) { - fix = (FixStore *) modify->get_fix_by_id(id_fix); + fix = dynamic_cast( modify->get_fix_by_id(id_fix)); if (!fix) error->all(FLERR,"Could not find compute msd/chunk fix with ID {}", id_fix); } } @@ -235,7 +235,7 @@ void ComputeMSDChunk::lock_disable() { int icompute = modify->find_compute(idchunk); if (icompute >= 0) { - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); cchunk->lockcount--; } } diff --git a/src/compute_omega_chunk.cpp b/src/compute_omega_chunk.cpp index 1422614ae1..bf00dda6a8 100644 --- a/src/compute_omega_chunk.cpp +++ b/src/compute_omega_chunk.cpp @@ -81,7 +81,7 @@ void ComputeOmegaChunk::init() if (icompute < 0) error->all(FLERR,"Chunk/atom compute does not exist for " "compute omega/chunk"); - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); if (strcmp(cchunk->style,"chunk/atom") != 0) error->all(FLERR,"Compute omega/chunk does not use chunk/atom compute"); } @@ -313,7 +313,7 @@ void ComputeOmegaChunk::lock_disable() { int icompute = modify->find_compute(idchunk); if (icompute >= 0) { - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); cchunk->lockcount--; } } diff --git a/src/compute_pressure.cpp b/src/compute_pressure.cpp index ef1de29309..ad14b552a4 100644 --- a/src/compute_pressure.cpp +++ b/src/compute_pressure.cpp @@ -202,7 +202,7 @@ void ComputePressure::init() vptr = new double*[nvirial]; nvirial = 0; if (pairhybridflag && force->pair) { - PairHybrid *ph = (PairHybrid *) force->pair; + auto ph = dynamic_cast( force->pair); ph->no_virial_fdotr_compute = 1; vptr[nvirial++] = pairhybrid->virial; } diff --git a/src/compute_property_atom.cpp b/src/compute_property_atom.cpp index d4cec70fe4..6cd4415f73 100644 --- a/src/compute_property_atom.cpp +++ b/src/compute_property_atom.cpp @@ -216,39 +216,39 @@ ComputePropertyAtom::ComputePropertyAtom(LAMMPS *lmp, int narg, char **arg) : pack_choice[i] = &ComputePropertyAtom::pack_angmomz; } else if (strcmp(arg[iarg],"shapex") == 0) { - avec_ellipsoid = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); + avec_ellipsoid = dynamic_cast( atom->style_match("ellipsoid")); if (!avec_ellipsoid) error->all(FLERR,"Compute property/atom for atom property that isn't allocated"); pack_choice[i] = &ComputePropertyAtom::pack_shapex; } else if (strcmp(arg[iarg],"shapey") == 0) { - avec_ellipsoid = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); + avec_ellipsoid = dynamic_cast( atom->style_match("ellipsoid")); if (!avec_ellipsoid) error->all(FLERR,"Compute property/atom for atom property that isn't allocated"); pack_choice[i] = &ComputePropertyAtom::pack_shapey; } else if (strcmp(arg[iarg],"shapez") == 0) { - avec_ellipsoid = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); + avec_ellipsoid = dynamic_cast( atom->style_match("ellipsoid")); if (!avec_ellipsoid) error->all(FLERR,"Compute property/atom for atom property that isn't allocated"); pack_choice[i] = &ComputePropertyAtom::pack_shapez; } else if (strcmp(arg[iarg],"quatw") == 0) { - avec_ellipsoid = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); - avec_body = (AtomVecBody *) atom->style_match("body"); + avec_ellipsoid = dynamic_cast( atom->style_match("ellipsoid")); + avec_body = dynamic_cast( atom->style_match("body")); if (!avec_ellipsoid && !avec_body) error->all(FLERR,"Compute property/atom for atom property that isn't allocated"); pack_choice[i] = &ComputePropertyAtom::pack_quatw; } else if (strcmp(arg[iarg],"quati") == 0) { - avec_ellipsoid = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); - avec_body = (AtomVecBody *) atom->style_match("body"); + avec_ellipsoid = dynamic_cast( atom->style_match("ellipsoid")); + avec_body = dynamic_cast( atom->style_match("body")); if (!avec_ellipsoid && !avec_body) error->all(FLERR,"Compute property/atom for atom property that isn't allocated"); pack_choice[i] = &ComputePropertyAtom::pack_quati; } else if (strcmp(arg[iarg],"quatj") == 0) { - avec_ellipsoid = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); - avec_body = (AtomVecBody *) atom->style_match("body"); + avec_ellipsoid = dynamic_cast( atom->style_match("ellipsoid")); + avec_body = dynamic_cast( atom->style_match("body")); if (!avec_ellipsoid && !avec_body) error->all(FLERR,"Compute property/atom for atom property that isn't allocated"); pack_choice[i] = &ComputePropertyAtom::pack_quatj; } else if (strcmp(arg[iarg],"quatk") == 0) { - avec_ellipsoid = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); - avec_body = (AtomVecBody *) atom->style_match("body"); + avec_ellipsoid = dynamic_cast( atom->style_match("ellipsoid")); + avec_body = dynamic_cast( atom->style_match("body")); if (!avec_ellipsoid && !avec_body) error->all(FLERR,"Compute property/atom for atom property that isn't allocated"); pack_choice[i] = &ComputePropertyAtom::pack_quatk; @@ -267,65 +267,65 @@ ComputePropertyAtom::ComputePropertyAtom(LAMMPS *lmp, int narg, char **arg) : pack_choice[i] = &ComputePropertyAtom::pack_tqz; } else if (strcmp(arg[iarg],"end1x") == 0) { - avec_line = (AtomVecLine *) atom->style_match("line"); + avec_line = dynamic_cast( atom->style_match("line")); if (!avec_line) error->all(FLERR,"Compute property/atom for atom property that isn't allocated"); pack_choice[i] = &ComputePropertyAtom::pack_end1x; } else if (strcmp(arg[iarg],"end1y") == 0) { - avec_line = (AtomVecLine *) atom->style_match("line"); + avec_line = dynamic_cast( atom->style_match("line")); if (!avec_line) error->all(FLERR,"Compute property/atom for atom property that isn't allocated"); pack_choice[i] = &ComputePropertyAtom::pack_end1y; } else if (strcmp(arg[iarg],"end1z") == 0) { - avec_line = (AtomVecLine *) atom->style_match("line"); + avec_line = dynamic_cast( atom->style_match("line")); if (!avec_line) error->all(FLERR,"Compute property/atom for atom property that isn't allocated"); pack_choice[i] = &ComputePropertyAtom::pack_end1z; } else if (strcmp(arg[iarg],"end2x") == 0) { - avec_line = (AtomVecLine *) atom->style_match("line"); + avec_line = dynamic_cast( atom->style_match("line")); if (!avec_line) error->all(FLERR,"Compute property/atom for atom property that isn't allocated"); pack_choice[i] = &ComputePropertyAtom::pack_end2x; } else if (strcmp(arg[iarg],"end2y") == 0) { - avec_line = (AtomVecLine *) atom->style_match("line"); + avec_line = dynamic_cast( atom->style_match("line")); if (!avec_line) error->all(FLERR,"Compute property/atom for atom property that isn't allocated"); pack_choice[i] = &ComputePropertyAtom::pack_end2y; } else if (strcmp(arg[iarg],"end2z") == 0) { - avec_line = (AtomVecLine *) atom->style_match("line"); + avec_line = dynamic_cast( atom->style_match("line")); if (!avec_line) error->all(FLERR,"Compute property/atom for atom property that isn't allocated"); pack_choice[i] = &ComputePropertyAtom::pack_end2z; } else if (strcmp(arg[iarg],"corner1x") == 0) { - avec_tri = (AtomVecTri *) atom->style_match("tri"); + avec_tri = dynamic_cast( atom->style_match("tri")); if (!avec_tri) error->all(FLERR,"Compute property/atom for atom property that isn't allocated"); pack_choice[i] = &ComputePropertyAtom::pack_corner1x; } else if (strcmp(arg[iarg],"corner1y") == 0) { - avec_tri = (AtomVecTri *) atom->style_match("tri"); + avec_tri = dynamic_cast( atom->style_match("tri")); if (!avec_tri) error->all(FLERR,"Compute property/atom for atom property that isn't allocated"); pack_choice[i] = &ComputePropertyAtom::pack_corner1y; } else if (strcmp(arg[iarg],"corner1z") == 0) { - avec_tri = (AtomVecTri *) atom->style_match("tri"); + avec_tri = dynamic_cast( atom->style_match("tri")); if (!avec_tri) error->all(FLERR,"Compute property/atom for atom property that isn't allocated"); pack_choice[i] = &ComputePropertyAtom::pack_corner1z; } else if (strcmp(arg[iarg],"corner2x") == 0) { - avec_tri = (AtomVecTri *) atom->style_match("tri"); + avec_tri = dynamic_cast( atom->style_match("tri")); if (!avec_tri) error->all(FLERR,"Compute property/atom for atom property that isn't allocated"); pack_choice[i] = &ComputePropertyAtom::pack_corner2x; } else if (strcmp(arg[iarg],"corner2y") == 0) { - avec_tri = (AtomVecTri *) atom->style_match("tri"); + avec_tri = dynamic_cast( atom->style_match("tri")); if (!avec_tri) error->all(FLERR,"Compute property/atom for atom property that isn't allocated"); pack_choice[i] = &ComputePropertyAtom::pack_corner2y; } else if (strcmp(arg[iarg],"corner2z") == 0) { - avec_tri = (AtomVecTri *) atom->style_match("tri"); + avec_tri = dynamic_cast( atom->style_match("tri")); if (!avec_tri) error->all(FLERR,"Compute property/atom for atom property that isn't allocated"); pack_choice[i] = &ComputePropertyAtom::pack_corner2z; } else if (strcmp(arg[iarg],"corner3x") == 0) { - avec_tri = (AtomVecTri *) atom->style_match("tri"); + avec_tri = dynamic_cast( atom->style_match("tri")); if (!avec_tri) error->all(FLERR,"Compute property/atom for atom property that isn't allocated"); pack_choice[i] = &ComputePropertyAtom::pack_corner3x; } else if (strcmp(arg[iarg],"corner3y") == 0) { - avec_tri = (AtomVecTri *) atom->style_match("tri"); + avec_tri = dynamic_cast( atom->style_match("tri")); if (!avec_tri) error->all(FLERR,"Compute property/atom for atom property that isn't allocated"); pack_choice[i] = &ComputePropertyAtom::pack_corner3y; } else if (strcmp(arg[iarg],"corner3z") == 0) { - avec_tri = (AtomVecTri *) atom->style_match("tri"); + avec_tri = dynamic_cast( atom->style_match("tri")); if (!avec_tri) error->all(FLERR,"Compute property/atom for atom property that isn't allocated"); pack_choice[i] = &ComputePropertyAtom::pack_corner3z; @@ -409,10 +409,10 @@ ComputePropertyAtom::~ComputePropertyAtom() void ComputePropertyAtom::init() { - avec_ellipsoid = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); - avec_line = (AtomVecLine *) atom->style_match("line"); - avec_tri = (AtomVecTri *) atom->style_match("tri"); - avec_body = (AtomVecBody *) atom->style_match("body"); + avec_ellipsoid = dynamic_cast( atom->style_match("ellipsoid")); + avec_line = dynamic_cast( atom->style_match("line")); + avec_tri = dynamic_cast( atom->style_match("tri")); + avec_body = dynamic_cast( atom->style_match("body")); // NOTE: could reset custom vector/array indices here, like dump custom does // in case have been deleted diff --git a/src/compute_property_chunk.cpp b/src/compute_property_chunk.cpp index 1fc430d13c..3154e01516 100644 --- a/src/compute_property_chunk.cpp +++ b/src/compute_property_chunk.cpp @@ -115,7 +115,7 @@ void ComputePropertyChunk::init() if (icompute < 0) error->all(FLERR,"Chunk/atom compute does not exist for " "compute property/chunk"); - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); if (strcmp(cchunk->style,"chunk/atom") != 0) error->all(FLERR,"Compute property/chunk does not use chunk/atom compute"); } @@ -196,7 +196,7 @@ void ComputePropertyChunk::lock_disable() { int icompute = modify->find_compute(idchunk); if (icompute >= 0) { - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); cchunk->lockcount--; } } diff --git a/src/compute_reduce_chunk.cpp b/src/compute_reduce_chunk.cpp index 84af9056aa..1749503254 100644 --- a/src/compute_reduce_chunk.cpp +++ b/src/compute_reduce_chunk.cpp @@ -229,7 +229,7 @@ void ComputeReduceChunk::init_chunk() if (icompute < 0) error->all(FLERR,"Chunk/atom compute does not exist for " "compute reduce/chunk"); - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); if (strcmp(cchunk->style,"chunk/atom") != 0) error->all(FLERR,"Compute reduce/chunk does not use chunk/atom compute"); } @@ -451,7 +451,7 @@ void ComputeReduceChunk::lock_disable() { int icompute = modify->find_compute(idchunk); if (icompute >= 0) { - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); cchunk->lockcount--; } } diff --git a/src/compute_temp_chunk.cpp b/src/compute_temp_chunk.cpp index 8798835071..bd17e3995d 100644 --- a/src/compute_temp_chunk.cpp +++ b/src/compute_temp_chunk.cpp @@ -164,7 +164,7 @@ void ComputeTempChunk::init() if (icompute < 0) error->all(FLERR,"Chunk/atom compute does not exist for " "compute temp/chunk"); - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); if (strcmp(cchunk->style,"chunk/atom") != 0) error->all(FLERR,"Compute temp/chunk does not use chunk/atom compute"); @@ -774,7 +774,7 @@ void ComputeTempChunk::lock_disable() { int icompute = modify->find_compute(idchunk); if (icompute >= 0) { - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); cchunk->lockcount--; } } diff --git a/src/compute_temp_deform.cpp b/src/compute_temp_deform.cpp index cd467c0069..3259ccd090 100644 --- a/src/compute_temp_deform.cpp +++ b/src/compute_temp_deform.cpp @@ -67,7 +67,7 @@ void ComputeTempDeform::init() auto fixes = modify->get_fix_by_style("^deform"); if (fixes.size() > 0) { - if (((FixDeform *) fixes[0])->remapflag == Domain::X_REMAP && comm->me == 0) + if ((dynamic_cast( fixes[0]))->remapflag == Domain::X_REMAP && comm->me == 0) error->warning(FLERR, "Using compute temp/deform with inconsistent fix deform remap option"); } else error->warning(FLERR, "Using compute temp/deform with no fix deform defined"); } diff --git a/src/compute_torque_chunk.cpp b/src/compute_torque_chunk.cpp index 508956bb27..79c0ce5aed 100644 --- a/src/compute_torque_chunk.cpp +++ b/src/compute_torque_chunk.cpp @@ -73,7 +73,7 @@ void ComputeTorqueChunk::init() if (icompute < 0) error->all(FLERR,"Chunk/atom compute does not exist for " "compute torque/chunk"); - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); if (strcmp(cchunk->style,"chunk/atom") != 0) error->all(FLERR,"Compute torque/chunk does not use chunk/atom compute"); } @@ -185,7 +185,7 @@ void ComputeTorqueChunk::lock_disable() { int icompute = modify->find_compute(idchunk); if (icompute >= 0) { - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); cchunk->lockcount--; } } diff --git a/src/compute_vacf.cpp b/src/compute_vacf.cpp index b6fbbedc48..ce3ba557aa 100644 --- a/src/compute_vacf.cpp +++ b/src/compute_vacf.cpp @@ -40,7 +40,7 @@ ComputeVACF::ComputeVACF(LAMMPS *lmp, int narg, char **arg) : // id = compute-ID + COMPUTE_STORE, fix group = compute group id_fix = utils::strdup(id + std::string("_COMPUTE_STORE")); - fix = (FixStore *) modify->add_fix(fmt::format("{} {} STORE peratom 1 3", id_fix, group->names[igroup])); + fix = dynamic_cast( modify->add_fix(fmt::format("{} {} STORE peratom 1 3", id_fix, group->names[igroup]))); // store current velocities in fix store array // skip if reset from restart file @@ -84,7 +84,7 @@ void ComputeVACF::init() { // set fix which stores original atom velocities - fix = (FixStore *) modify->get_fix_by_id(id_fix); + fix = dynamic_cast( modify->get_fix_by_id(id_fix)); if (!fix) error->all(FLERR,"Could not find compute vacf fix ID {}", id_fix); // nvacf = # of atoms in group diff --git a/src/compute_vcm_chunk.cpp b/src/compute_vcm_chunk.cpp index 8148ed3356..5ac73f8d1e 100644 --- a/src/compute_vcm_chunk.cpp +++ b/src/compute_vcm_chunk.cpp @@ -73,7 +73,7 @@ void ComputeVCMChunk::init() int icompute = modify->find_compute(idchunk); if (icompute < 0) error->all(FLERR,"Chunk/atom compute does not exist for compute vcm/chunk"); - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); if (strcmp(cchunk->style,"chunk/atom") != 0) error->all(FLERR,"Compute vcm/chunk does not use chunk/atom compute"); } @@ -175,7 +175,7 @@ void ComputeVCMChunk::lock_disable() { int icompute = modify->find_compute(idchunk); if (icompute >= 0) { - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); cchunk->lockcount--; } } diff --git a/src/delete_atoms.cpp b/src/delete_atoms.cpp index 405e0a7390..8524d44b07 100644 --- a/src/delete_atoms.cpp +++ b/src/delete_atoms.cpp @@ -132,11 +132,11 @@ void DeleteAtoms::command(int narg, char **arg) // reset bonus data counts - AtomVecEllipsoid *avec_ellipsoid = - (AtomVecEllipsoid *) atom->style_match("ellipsoid"); - AtomVecLine *avec_line = (AtomVecLine *) atom->style_match("line"); - AtomVecTri *avec_tri = (AtomVecTri *) atom->style_match("tri"); - AtomVecBody *avec_body = (AtomVecBody *) atom->style_match("body"); + auto avec_ellipsoid = + dynamic_cast( atom->style_match("ellipsoid")); + auto avec_line = dynamic_cast( atom->style_match("line")); + auto avec_tri = dynamic_cast( atom->style_match("tri")); + auto avec_body = dynamic_cast( atom->style_match("body")); bigint nlocal_bonus; if (atom->nellipsoids > 0) { diff --git a/src/dihedral_deprecated.cpp b/src/dihedral_deprecated.cpp index b1964d5210..57ea7f1afa 100644 --- a/src/dihedral_deprecated.cpp +++ b/src/dihedral_deprecated.cpp @@ -37,7 +37,7 @@ void DihedralDeprecated::settings(int, char **) // of the list of substyles if (utils::strmatch(my_style,"^hybrid")) { - DihedralHybrid *hybrid = (DihedralHybrid *)force->dihedral; + auto hybrid = dynamic_cast(force->dihedral); my_style = hybrid->keywords[hybrid->nstyles]; } diff --git a/src/displace_atoms.cpp b/src/displace_atoms.cpp index 0406a9a635..75298604c9 100644 --- a/src/displace_atoms.cpp +++ b/src/displace_atoms.cpp @@ -263,11 +263,10 @@ void DisplaceAtoms::command(int narg, char **arg) // AtomVec pointers to retrieve per-atom storage of extra quantities - AtomVecEllipsoid *avec_ellipsoid = - (AtomVecEllipsoid *) atom->style_match("ellipsoid"); - AtomVecLine *avec_line = (AtomVecLine *) atom->style_match("line"); - AtomVecTri *avec_tri = (AtomVecTri *) atom->style_match("tri"); - AtomVecBody *avec_body = (AtomVecBody *) atom->style_match("body"); + auto avec_ellipsoid = dynamic_cast( atom->style_match("ellipsoid")); + auto avec_line = dynamic_cast( atom->style_match("line")); + auto avec_tri = dynamic_cast( atom->style_match("tri")); + auto avec_body = dynamic_cast( atom->style_match("body")); double **x = atom->x; int *ellipsoid = atom->ellipsoid; diff --git a/src/domain.cpp b/src/domain.cpp index 9ec0bebbdd..d3804d75bd 100644 --- a/src/domain.cpp +++ b/src/domain.cpp @@ -186,7 +186,7 @@ void Domain::init() for (const auto &fix : fixes) if (utils::strmatch(fix->style,"^deform")) { deform_flag = 1; - if (((FixDeform *) fix)->remapflag == Domain::V_REMAP) { + if ((dynamic_cast( fix))->remapflag == Domain::V_REMAP) { deform_vremap = 1; deform_groupbit = fix->groupbit; } diff --git a/src/dump_custom.cpp b/src/dump_custom.cpp index 606051bc70..ef44fd8665 100644 --- a/src/dump_custom.cpp +++ b/src/dump_custom.cpp @@ -2038,7 +2038,7 @@ int DumpCustom::modify_param(int narg, char **arg) std::string threshid = fmt::format("{}{}_DUMP_STORE",id,nthreshlast); thresh_fixID[nthreshlast] = utils::strdup(threshid); threshid += fmt::format(" {} STORE peratom 1 1", group->names[igroup]); - thresh_fix[nthreshlast] = (FixStore *) modify->add_fix(threshid); + thresh_fix[nthreshlast] = dynamic_cast( modify->add_fix(threshid)); thresh_last[nthreshlast] = nthreshlast; thresh_first[nthreshlast] = 1; diff --git a/src/dump_image.cpp b/src/dump_image.cpp index 0179878111..7a7f89801a 100644 --- a/src/dump_image.cpp +++ b/src/dump_image.cpp @@ -332,17 +332,17 @@ DumpImage::DumpImage(LAMMPS *lmp, int narg, char **arg) : // error checks and setup for lineflag, triflag, bodyflag, fixflag if (lineflag) { - avec_line = (AtomVecLine *) atom->style_match("line"); + avec_line = dynamic_cast( atom->style_match("line")); if (!avec_line) error->all(FLERR,"Dump image line requires atom style line"); } if (triflag) { - avec_tri = (AtomVecTri *) atom->style_match("tri"); + avec_tri = dynamic_cast( atom->style_match("tri")); if (!avec_tri) error->all(FLERR,"Dump image tri requires atom style tri"); } if (bodyflag) { - avec_body = (AtomVecBody *) atom->style_match("body"); + avec_body = dynamic_cast( atom->style_match("body")); if (!avec_body) error->all(FLERR,"Dump image body yes requires atom style body"); } diff --git a/src/finish.cpp b/src/finish.cpp index cc0cad7f92..ea472682a2 100644 --- a/src/finish.cpp +++ b/src/finish.cpp @@ -341,7 +341,7 @@ void Finish::end(int flag) } #ifdef LMP_OPENMP - FixOMP *fixomp = (FixOMP *) modify->get_fix_by_id("package_omp"); + FixOMP *fixomp = dynamic_cast( modify->get_fix_by_id("package_omp")); // print thread breakdown only with full timer detail diff --git a/src/fix_adapt.cpp b/src/fix_adapt.cpp index 0cf8f2af75..2632ccf597 100644 --- a/src/fix_adapt.cpp +++ b/src/fix_adapt.cpp @@ -247,8 +247,8 @@ void FixAdapt::post_constructor() if (diamflag && atom->radius_flag) { id_fix_diam = utils::strdup(id + std::string("_FIX_STORE_DIAM")); - fix_diam = (FixStore *) modify->add_fix(fmt::format("{} {} STORE peratom 1 1", - id_fix_diam,group->names[igroup])); + fix_diam = dynamic_cast( modify->add_fix(fmt::format("{} {} STORE peratom 1 1", + id_fix_diam,group->names[igroup]))); if (fix_diam->restart_reset) fix_diam->restart_reset = 0; else { double *vec = fix_diam->vstore; @@ -265,8 +265,8 @@ void FixAdapt::post_constructor() if (chgflag && atom->q_flag) { id_fix_chg = utils::strdup(id + std::string("_FIX_STORE_CHG")); - fix_chg = (FixStore *) modify->add_fix(fmt::format("{} {} STORE peratom 1 1", - id_fix_chg,group->names[igroup])); + fix_chg = dynamic_cast( modify->add_fix(fmt::format("{} {} STORE peratom 1 1", + id_fix_chg,group->names[igroup]))); if (fix_chg->restart_reset) fix_chg->restart_reset = 0; else { double *vec = fix_chg->vstore; @@ -348,7 +348,7 @@ void FixAdapt::init() // if pair hybrid, test that ilo,ihi,jlo,jhi are valid for sub-style if (utils::strmatch(force->pair_style,"^hybrid")) { - PairHybrid *pair = (PairHybrid *) force->pair; + auto pair = dynamic_cast( force->pair); for (i = ad->ilo; i <= ad->ihi; i++) for (j = MAX(ad->jlo,i); j <= ad->jhi; j++) if (!pair->check_ijtype(i,j,pstyle)) @@ -431,16 +431,16 @@ void FixAdapt::init() if (id_fix_diam) { int ifix = modify->find_fix(id_fix_diam); if (ifix < 0) error->all(FLERR,"Could not find fix adapt storage fix ID"); - fix_diam = (FixStore *) modify->fix[ifix]; + fix_diam = dynamic_cast( modify->fix[ifix]); } if (id_fix_chg) { int ifix = modify->find_fix(id_fix_chg); if (ifix < 0) error->all(FLERR,"Could not find fix adapt storage fix ID"); - fix_chg = (FixStore *) modify->fix[ifix]; + fix_chg = dynamic_cast( modify->fix[ifix]); } if (utils::strmatch(update->integrate_style,"^respa")) - nlevels_respa = ((Respa *) update->integrate)->nlevels; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; } /* ---------------------------------------------------------------------- */ diff --git a/src/fix_addforce.cpp b/src/fix_addforce.cpp index 1aff86fb58..0487854ade 100644 --- a/src/fix_addforce.cpp +++ b/src/fix_addforce.cpp @@ -195,7 +195,7 @@ void FixAddForce::init() error->all(FLERR,"Must use variable energy with fix addforce"); if (utils::strmatch(update->integrate_style,"^respa")) { - ilevel_respa = ((Respa *) update->integrate)->nlevels-1; + ilevel_respa = (dynamic_cast( update->integrate))->nlevels-1; if (respa_level >= 0) ilevel_respa = MIN(respa_level,ilevel_respa); } } @@ -207,9 +207,9 @@ void FixAddForce::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(ilevel_respa); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel_respa); post_force_respa(vflag,ilevel_respa,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel_respa); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel_respa); } } diff --git a/src/fix_ave_chunk.cpp b/src/fix_ave_chunk.cpp index efe1bd9fdc..46c0abfc8f 100644 --- a/src/fix_ave_chunk.cpp +++ b/src/fix_ave_chunk.cpp @@ -309,7 +309,7 @@ FixAveChunk::FixAveChunk(LAMMPS *lmp, int narg, char **arg) : int icompute = modify->find_compute(idchunk); if (icompute < 0) error->all(FLERR,"Chunk/atom compute does not exist for fix ave/chunk"); - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); if (strcmp(cchunk->style,"chunk/atom") != 0) error->all(FLERR,"Fix ave/chunk does not use chunk/atom compute"); @@ -432,7 +432,7 @@ FixAveChunk::~FixAveChunk() if (nrepeat > 1 || ave == RUNNING || ave == WINDOW) { int icompute = modify->find_compute(idchunk); if (icompute >= 0) { - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); if (ave == RUNNING || ave == WINDOW) cchunk->unlock(this); cchunk->lockcount--; } @@ -478,7 +478,7 @@ void FixAveChunk::init() int icompute = modify->find_compute(idchunk); if (icompute < 0) error->all(FLERR,"Chunk/atom compute does not exist for fix ave/chunk"); - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); if (biasflag) { int i = modify->find_compute(id_bias); diff --git a/src/fix_aveforce.cpp b/src/fix_aveforce.cpp index cd8009c81b..2d172adb9b 100644 --- a/src/fix_aveforce.cpp +++ b/src/fix_aveforce.cpp @@ -157,7 +157,7 @@ void FixAveForce::init() else varflag = CONSTANT; if (utils::strmatch(update->integrate_style,"^respa")) { - nlevels_respa = ((Respa *) update->integrate)->nlevels; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; if (respa_level >= 0) ilevel_respa = MIN(respa_level,nlevels_respa-1); else ilevel_respa = nlevels_respa-1; } @@ -171,9 +171,9 @@ void FixAveForce::setup(int vflag) post_force(vflag); else for (int ilevel = 0; ilevel < nlevels_respa; ilevel++) { - ((Respa *) update->integrate)->copy_flevel_f(ilevel); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel); post_force_respa(vflag,ilevel,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel); } } diff --git a/src/fix_efield.cpp b/src/fix_efield.cpp index 6fa3fc5297..a17a122e9d 100644 --- a/src/fix_efield.cpp +++ b/src/fix_efield.cpp @@ -210,7 +210,7 @@ void FixEfield::init() error->all(FLERR,"Must use variable energy with fix efield"); if (utils::strmatch(update->integrate_style,"^respa")) { - ilevel_respa = ((Respa *) update->integrate)->nlevels-1; + ilevel_respa = (dynamic_cast( update->integrate))->nlevels-1; if (respa_level >= 0) ilevel_respa = MIN(respa_level,ilevel_respa); } } @@ -222,9 +222,9 @@ void FixEfield::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(ilevel_respa); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel_respa); post_force_respa(vflag,ilevel_respa,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel_respa); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel_respa); } } diff --git a/src/fix_enforce2d.cpp b/src/fix_enforce2d.cpp index abff16d21e..cc3b79c45d 100644 --- a/src/fix_enforce2d.cpp +++ b/src/fix_enforce2d.cpp @@ -93,11 +93,11 @@ void FixEnforce2D::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - int nlevels_respa = ((Respa *) update->integrate)->nlevels; + int nlevels_respa = (dynamic_cast( update->integrate))->nlevels; for (int ilevel = 0; ilevel < nlevels_respa; ilevel++) { - ((Respa *) update->integrate)->copy_flevel_f(ilevel); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel); post_force_respa(vflag,ilevel,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel); } } } diff --git a/src/fix_gravity.cpp b/src/fix_gravity.cpp index b206bae5b8..cf559043cf 100644 --- a/src/fix_gravity.cpp +++ b/src/fix_gravity.cpp @@ -181,7 +181,7 @@ int FixGravity::setmask() void FixGravity::init() { if (utils::strmatch(update->integrate_style,"^respa")) { - ilevel_respa = ((Respa *) update->integrate)->nlevels-1; + ilevel_respa = (dynamic_cast( update->integrate))->nlevels-1; if (respa_level >= 0) ilevel_respa = MIN(respa_level,ilevel_respa); } @@ -245,9 +245,9 @@ void FixGravity::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(ilevel_respa); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel_respa); post_force_respa(vflag,ilevel_respa,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel_respa); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel_respa); } } diff --git a/src/fix_group.cpp b/src/fix_group.cpp index 672a69cbc3..1291721f0a 100644 --- a/src/fix_group.cpp +++ b/src/fix_group.cpp @@ -122,7 +122,7 @@ void FixGroup::init() error->all(FLERR,"Group dynamic parent group cannot be dynamic"); if (utils::strmatch(update->integrate_style,"^respa")) - nlevels_respa = ((Respa *) update->integrate)->nlevels; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; // set current indices for region and variable and custom property diff --git a/src/fix_indent.cpp b/src/fix_indent.cpp index 838d9bdaab..3f99d14a8c 100644 --- a/src/fix_indent.cpp +++ b/src/fix_indent.cpp @@ -155,7 +155,7 @@ void FixIndent::init() } if (utils::strmatch(update->integrate_style,"^respa")) { - ilevel_respa = ((Respa *) update->integrate)->nlevels-1; + ilevel_respa = (dynamic_cast( update->integrate))->nlevels-1; if (respa_level >= 0) ilevel_respa = MIN(respa_level,ilevel_respa); } } @@ -167,9 +167,9 @@ void FixIndent::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(ilevel_respa); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel_respa); post_force_respa(vflag,ilevel_respa,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel_respa); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel_respa); } } diff --git a/src/fix_langevin.cpp b/src/fix_langevin.cpp index 6e770689dc..98b8f5274a 100644 --- a/src/fix_langevin.cpp +++ b/src/fix_langevin.cpp @@ -270,7 +270,7 @@ void FixLangevin::init() } if (ascale) { - avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); + avec = dynamic_cast( atom->style_match("ellipsoid")); if (!avec) error->all(FLERR,"Fix langevin angmom requires atom style ellipsoid"); @@ -306,7 +306,7 @@ void FixLangevin::init() else tbiasflag = NOBIAS; if (utils::strmatch(update->integrate_style,"^respa")) - nlevels_respa = ((Respa *) update->integrate)->nlevels; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; if (utils::strmatch(update->integrate_style,"^respa") && gjfflag) error->all(FLERR,"Fix langevin gjf and respa are not compatible"); @@ -365,9 +365,9 @@ void FixLangevin::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_flevel_f(nlevels_respa-1); post_force_respa(vflag,nlevels_respa-1,0); - ((Respa *) update->integrate)->copy_f_flevel(nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_f_flevel(nlevels_respa-1); } if (gjfflag) { double dtfm; diff --git a/src/fix_lineforce.cpp b/src/fix_lineforce.cpp index 90901534ad..d9408efb48 100644 --- a/src/fix_lineforce.cpp +++ b/src/fix_lineforce.cpp @@ -62,11 +62,11 @@ void FixLineForce::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - int nlevels_respa = ((Respa *) update->integrate)->nlevels; + int nlevels_respa = (dynamic_cast( update->integrate))->nlevels; for (int ilevel = 0; ilevel < nlevels_respa; ilevel++) { - ((Respa *) update->integrate)->copy_flevel_f(ilevel); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel); post_force_respa(vflag,ilevel,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel); } } } diff --git a/src/fix_move.cpp b/src/fix_move.cpp index c079c07b1c..75f2eb1796 100644 --- a/src/fix_move.cpp +++ b/src/fix_move.cpp @@ -295,10 +295,10 @@ FixMove::FixMove(LAMMPS *lmp, int narg, char **arg) : // AtomVec pointers to retrieve per-atom storage of extra quantities - avec_ellipsoid = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); - avec_line = (AtomVecLine *) atom->style_match("line"); - avec_tri = (AtomVecTri *) atom->style_match("tri"); - avec_body = (AtomVecBody *) atom->style_match("body"); + avec_ellipsoid = dynamic_cast( atom->style_match("ellipsoid")); + avec_line = dynamic_cast( atom->style_match("line")); + avec_tri = dynamic_cast( atom->style_match("tri")); + avec_body = dynamic_cast( atom->style_match("body")); // xoriginal = initial unwrapped positions of atoms // toriginal = initial theta of lines @@ -495,7 +495,7 @@ void FixMove::init() velocity = nullptr; if (utils::strmatch(update->integrate_style, "^respa")) - nlevels_respa = ((Respa *) update->integrate)->nlevels; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; } /* ---------------------------------------------------------------------- diff --git a/src/fix_nh.cpp b/src/fix_nh.cpp index 032d959a03..cb0408a50c 100644 --- a/src/fix_nh.cpp +++ b/src/fix_nh.cpp @@ -648,7 +648,7 @@ void FixNH::init() if (pstat_flag) for (int i = 0; i < modify->nfix; i++) if (strcmp(modify->fix[i]->style,"deform") == 0) { - int *dimflag = ((FixDeform *) modify->fix[i])->dimflag; + int *dimflag = (dynamic_cast( modify->fix[i]))->dimflag; if ((p_flag[0] && dimflag[0]) || (p_flag[1] && dimflag[1]) || (p_flag[2] && dimflag[2]) || (p_flag[3] && dimflag[3]) || (p_flag[4] && dimflag[4]) || (p_flag[5] && dimflag[5])) @@ -721,8 +721,8 @@ void FixNH::init() else kspace_flag = 0; if (utils::strmatch(update->integrate_style,"^respa")) { - nlevels_respa = ((Respa *) update->integrate)->nlevels; - step_respa = ((Respa *) update->integrate)->step; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; + step_respa = (dynamic_cast( update->integrate))->step; dto = 0.5*step_respa[0]; } diff --git a/src/fix_nve.cpp b/src/fix_nve.cpp index 0ac89f5e26..728036128a 100644 --- a/src/fix_nve.cpp +++ b/src/fix_nve.cpp @@ -55,7 +55,7 @@ void FixNVE::init() dtf = 0.5 * update->dt * force->ftm2v; if (utils::strmatch(update->integrate_style,"^respa")) - step_respa = ((Respa *) update->integrate)->step; + step_respa = (dynamic_cast( update->integrate))->step; } /* ---------------------------------------------------------------------- diff --git a/src/fix_nve_limit.cpp b/src/fix_nve_limit.cpp index 9aba474789..cb6d7c7302 100644 --- a/src/fix_nve_limit.cpp +++ b/src/fix_nve_limit.cpp @@ -67,7 +67,7 @@ void FixNVELimit::init() ncount = 0; if (utils::strmatch(update->integrate_style,"^respa")) - step_respa = ((Respa *) update->integrate)->step; + step_respa = (dynamic_cast( update->integrate))->step; // warn if using fix shake, which will lead to invalid constraint forces diff --git a/src/fix_nve_noforce.cpp b/src/fix_nve_noforce.cpp index de24c7fef0..d043dcbd4a 100644 --- a/src/fix_nve_noforce.cpp +++ b/src/fix_nve_noforce.cpp @@ -49,7 +49,7 @@ void FixNVENoforce::init() dtv = update->dt; if (utils::strmatch(update->integrate_style,"^respa")) - step_respa = ((Respa *) update->integrate)->step; + step_respa = (dynamic_cast( update->integrate))->step; } /* ---------------------------------------------------------------------- */ diff --git a/src/fix_nvt_sllod.cpp b/src/fix_nvt_sllod.cpp index bc5d3f7298..8c5116c070 100644 --- a/src/fix_nvt_sllod.cpp +++ b/src/fix_nvt_sllod.cpp @@ -73,7 +73,7 @@ void FixNVTSllod::init() int i; for (i = 0; i < modify->nfix; i++) if (strncmp(modify->fix[i]->style,"deform",6) == 0) { - if (((FixDeform *) modify->fix[i])->remapflag != Domain::V_REMAP) + if ((dynamic_cast( modify->fix[i]))->remapflag != Domain::V_REMAP) error->all(FLERR,"Using fix nvt/sllod with inconsistent fix deform " "remap option"); break; diff --git a/src/fix_planeforce.cpp b/src/fix_planeforce.cpp index baad522ec6..0d91f2b90e 100644 --- a/src/fix_planeforce.cpp +++ b/src/fix_planeforce.cpp @@ -62,11 +62,11 @@ void FixPlaneForce::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - int nlevels_respa = ((Respa *) update->integrate)->nlevels; + int nlevels_respa = (dynamic_cast( update->integrate))->nlevels; for (int ilevel = 0; ilevel < nlevels_respa; ilevel++) { - ((Respa *) update->integrate)->copy_flevel_f(ilevel); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel); post_force_respa(vflag,ilevel,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel); } } } diff --git a/src/fix_press_berendsen.cpp b/src/fix_press_berendsen.cpp index e03e943eb5..f80acce8c4 100644 --- a/src/fix_press_berendsen.cpp +++ b/src/fix_press_berendsen.cpp @@ -270,7 +270,7 @@ void FixPressBerendsen::init() for (int i = 0; i < modify->nfix; i++) if (strcmp(modify->fix[i]->style,"deform") == 0) { - int *dimflag = ((FixDeform *) modify->fix[i])->dimflag; + int *dimflag = (dynamic_cast( modify->fix[i]))->dimflag; if ((p_flag[0] && dimflag[0]) || (p_flag[1] && dimflag[1]) || (p_flag[2] && dimflag[2])) error->all(FLERR,"Cannot use fix press/berendsen and " diff --git a/src/fix_recenter.cpp b/src/fix_recenter.cpp index 76e59014be..1f2fedc842 100644 --- a/src/fix_recenter.cpp +++ b/src/fix_recenter.cpp @@ -146,7 +146,7 @@ void FixRecenter::init() } if (utils::strmatch(update->integrate_style,"^respa")) - nlevels_respa = ((Respa *) update->integrate)->nlevels; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; } /* ---------------------------------------------------------------------- */ diff --git a/src/fix_restrain.cpp b/src/fix_restrain.cpp index 6b190df997..8b97715ff6 100644 --- a/src/fix_restrain.cpp +++ b/src/fix_restrain.cpp @@ -185,7 +185,7 @@ int FixRestrain::setmask() void FixRestrain::init() { if (utils::strmatch(update->integrate_style,"^respa")) { - ilevel_respa = ((Respa *) update->integrate)->nlevels-1; + ilevel_respa = (dynamic_cast( update->integrate))->nlevels-1; if (respa_level >= 0) ilevel_respa = MIN(respa_level,ilevel_respa); } } @@ -197,9 +197,9 @@ void FixRestrain::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(ilevel_respa); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel_respa); post_force_respa(vflag,ilevel_respa,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel_respa); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel_respa); } } diff --git a/src/fix_setforce.cpp b/src/fix_setforce.cpp index 75b79617b6..a6e796f072 100644 --- a/src/fix_setforce.cpp +++ b/src/fix_setforce.cpp @@ -168,7 +168,7 @@ void FixSetForce::init() else varflag = CONSTANT; if (utils::strmatch(update->integrate_style,"^respa")) { - nlevels_respa = ((Respa *) update->integrate)->nlevels; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; if (respa_level >= 0) ilevel_respa = MIN(respa_level,nlevels_respa-1); else ilevel_respa = nlevels_respa-1; } @@ -197,9 +197,9 @@ void FixSetForce::setup(int vflag) post_force(vflag); else for (int ilevel = 0; ilevel < nlevels_respa; ilevel++) { - ((Respa *) update->integrate)->copy_flevel_f(ilevel); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel); post_force_respa(vflag,ilevel,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel); } } diff --git a/src/fix_spring.cpp b/src/fix_spring.cpp index dc3001c0fc..46310ef181 100644 --- a/src/fix_spring.cpp +++ b/src/fix_spring.cpp @@ -130,7 +130,7 @@ void FixSpring::init() if (styleflag == COUPLE) masstotal2 = group->mass(igroup2); if (utils::strmatch(update->integrate_style,"^respa")) { - ilevel_respa = ((Respa *) update->integrate)->nlevels-1; + ilevel_respa = (dynamic_cast( update->integrate))->nlevels-1; if (respa_level >= 0) ilevel_respa = MIN(respa_level,ilevel_respa); } } @@ -142,9 +142,9 @@ void FixSpring::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(ilevel_respa); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel_respa); post_force_respa(vflag,ilevel_respa,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel_respa); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel_respa); } } diff --git a/src/fix_spring_chunk.cpp b/src/fix_spring_chunk.cpp index fb32947fe8..411f056645 100644 --- a/src/fix_spring_chunk.cpp +++ b/src/fix_spring_chunk.cpp @@ -68,7 +68,7 @@ FixSpringChunk::~FixSpringChunk() int icompute = modify->find_compute(idchunk); if (icompute >= 0) { - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); cchunk->unlock(this); cchunk->lockcount--; } @@ -97,14 +97,14 @@ void FixSpringChunk::init() int icompute = modify->find_compute(idchunk); if (icompute < 0) error->all(FLERR,"Chunk/atom compute does not exist for fix spring/chunk"); - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); if (strcmp(cchunk->style,"chunk/atom") != 0) error->all(FLERR,"Fix spring/chunk does not use chunk/atom compute"); icompute = modify->find_compute(idcom); if (icompute < 0) error->all(FLERR,"Com/chunk compute does not exist for fix spring/chunk"); - ccom = (ComputeCOMChunk *) modify->compute[icompute]; + ccom = dynamic_cast( modify->compute[icompute]); if (strcmp(ccom->style,"com/chunk") != 0) error->all(FLERR,"Fix spring/chunk does not use com/chunk compute"); @@ -114,7 +114,7 @@ void FixSpringChunk::init() error->all(FLERR,"Fix spring chunk chunkID not same as comID chunkID"); if (utils::strmatch(update->integrate_style,"^respa")) { - ilevel_respa = ((Respa *) update->integrate)->nlevels-1; + ilevel_respa = (dynamic_cast( update->integrate))->nlevels-1; if (respa_level >= 0) ilevel_respa = MIN(respa_level,ilevel_respa); } } @@ -126,9 +126,9 @@ void FixSpringChunk::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(ilevel_respa); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel_respa); post_force_respa(vflag,ilevel_respa,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel_respa); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel_respa); } } @@ -271,7 +271,7 @@ void FixSpringChunk::restart(char *buf) int icompute = modify->find_compute(idchunk); if (icompute < 0) error->all(FLERR,"Chunk/atom compute does not exist for fix spring/chunk"); - cchunk = (ComputeChunkAtom *) modify->compute[icompute]; + cchunk = dynamic_cast( modify->compute[icompute]); if (strcmp(cchunk->style,"chunk/atom") != 0) error->all(FLERR,"Fix spring/chunk does not use chunk/atom compute"); nchunk = cchunk->setup_chunks(); diff --git a/src/fix_spring_self.cpp b/src/fix_spring_self.cpp index 5ea8bffd01..180f7427ec 100644 --- a/src/fix_spring_self.cpp +++ b/src/fix_spring_self.cpp @@ -122,7 +122,7 @@ int FixSpringSelf::setmask() void FixSpringSelf::init() { if (utils::strmatch(update->integrate_style,"^respa")) { - ilevel_respa = ((Respa *) update->integrate)->nlevels-1; + ilevel_respa = (dynamic_cast( update->integrate))->nlevels-1; if (respa_level >= 0) ilevel_respa = MIN(respa_level,ilevel_respa); } } @@ -134,9 +134,9 @@ void FixSpringSelf::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(ilevel_respa); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel_respa); post_force_respa(vflag,ilevel_respa,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel_respa); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel_respa); } } diff --git a/src/fix_store_force.cpp b/src/fix_store_force.cpp index f7832cd599..8e696c075c 100644 --- a/src/fix_store_force.cpp +++ b/src/fix_store_force.cpp @@ -70,7 +70,7 @@ int FixStoreForce::setmask() void FixStoreForce::init() { if (utils::strmatch(update->integrate_style,"^respa")) - nlevels_respa = ((Respa *) update->integrate)->nlevels; + nlevels_respa = (dynamic_cast( update->integrate))->nlevels; } /* ---------------------------------------------------------------------- */ @@ -80,9 +80,9 @@ void FixStoreForce::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_flevel_f(nlevels_respa-1); post_force_respa(vflag,nlevels_respa-1,0); - ((Respa *) update->integrate)->copy_f_flevel(nlevels_respa-1); + (dynamic_cast( update->integrate))->copy_f_flevel(nlevels_respa-1); } } diff --git a/src/fix_viscous.cpp b/src/fix_viscous.cpp index a13100ee48..f0c6faa419 100644 --- a/src/fix_viscous.cpp +++ b/src/fix_viscous.cpp @@ -82,7 +82,7 @@ void FixViscous::init() int max_respa = 0; if (utils::strmatch(update->integrate_style,"^respa")) { - ilevel_respa = max_respa = ((Respa *) update->integrate)->nlevels-1; + ilevel_respa = max_respa = (dynamic_cast( update->integrate))->nlevels-1; if (respa_level >= 0) ilevel_respa = MIN(respa_level,max_respa); } } @@ -94,9 +94,9 @@ void FixViscous::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(ilevel_respa); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel_respa); post_force_respa(vflag,ilevel_respa,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel_respa); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel_respa); } } diff --git a/src/fix_wall.cpp b/src/fix_wall.cpp index 0c3623857e..2156ac321c 100644 --- a/src/fix_wall.cpp +++ b/src/fix_wall.cpp @@ -261,7 +261,7 @@ void FixWall::init() for (int m = 0; m < nwall; m++) precompute(m); if (utils::strmatch(update->integrate_style,"^respa")) { - ilevel_respa = ((Respa *) update->integrate)->nlevels-1; + ilevel_respa = (dynamic_cast( update->integrate))->nlevels-1; if (respa_level >= 0) ilevel_respa = MIN(respa_level,ilevel_respa); } } @@ -273,9 +273,9 @@ void FixWall::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) { if (!fldflag) post_force(vflag); } else { - ((Respa *) update->integrate)->copy_flevel_f(ilevel_respa); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel_respa); post_force_respa(vflag,ilevel_respa,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel_respa); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel_respa); } } diff --git a/src/fix_wall_region.cpp b/src/fix_wall_region.cpp index 909f777dce..8f5a27e4a5 100644 --- a/src/fix_wall_region.cpp +++ b/src/fix_wall_region.cpp @@ -189,7 +189,7 @@ void FixWallRegion::init() } if (utils::strmatch(update->integrate_style,"^respa")) { - ilevel_respa = ((Respa *) update->integrate)->nlevels-1; + ilevel_respa = (dynamic_cast( update->integrate))->nlevels-1; if (respa_level >= 0) ilevel_respa = MIN(respa_level,ilevel_respa); } } @@ -201,9 +201,9 @@ void FixWallRegion::setup(int vflag) if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag); else { - ((Respa *) update->integrate)->copy_flevel_f(ilevel_respa); + (dynamic_cast( update->integrate))->copy_flevel_f(ilevel_respa); post_force_respa(vflag,ilevel_respa,0); - ((Respa *) update->integrate)->copy_f_flevel(ilevel_respa); + (dynamic_cast( update->integrate))->copy_f_flevel(ilevel_respa); } } diff --git a/src/force.cpp b/src/force.cpp index 35bd8644ee..b3721a7bf9 100644 --- a/src/force.cpp +++ b/src/force.cpp @@ -298,7 +298,7 @@ Pair *Force::pair_match(const std::string &word, int exact, int nsub) else if (!exact && utils::strmatch(pair_style, word)) return pair; else if (utils::strmatch(pair_style, "^hybrid")) { - PairHybrid *hybrid = (PairHybrid *) pair; + auto hybrid = dynamic_cast( pair); count = 0; for (int i = 0; i < hybrid->nstyles; i++) if ((exact && (word == hybrid->keywords[i])) || @@ -324,7 +324,7 @@ char *Force::pair_match_ptr(Pair *ptr) if (ptr == pair) return pair_style; if (utils::strmatch(pair_style, "^hybrid")) { - PairHybrid *hybrid = (PairHybrid *) pair; + auto hybrid = dynamic_cast( pair); for (int i = 0; i < hybrid->nstyles; i++) if (ptr == hybrid->styles[i]) return hybrid->keywords[i]; } @@ -393,7 +393,7 @@ Bond *Force::bond_match(const std::string &style) if (style == bond_style) return bond; else if (strcmp(bond_style, "hybrid") == 0) { - BondHybrid *hybrid = (BondHybrid *) bond; + auto hybrid = dynamic_cast( bond); for (int i = 0; i < hybrid->nstyles; i++) if (style == hybrid->keywords[i]) return hybrid->styles[i]; } @@ -461,7 +461,7 @@ Angle *Force::angle_match(const std::string &style) if (style == angle_style) return angle; else if (utils::strmatch(angle_style, "^hybrid")) { - AngleHybrid *hybrid = (AngleHybrid *) angle; + auto hybrid = dynamic_cast( angle); for (int i = 0; i < hybrid->nstyles; i++) if (style == hybrid->keywords[i]) return hybrid->styles[i]; } @@ -529,7 +529,7 @@ Dihedral *Force::dihedral_match(const std::string &style) if (style == dihedral_style) return dihedral; else if (utils::strmatch(dihedral_style, "^hybrid")) { - DihedralHybrid *hybrid = (DihedralHybrid *) dihedral; + auto hybrid = dynamic_cast( dihedral); for (int i = 0; i < hybrid->nstyles; i++) if (style == hybrid->keywords[i]) return hybrid->styles[i]; } @@ -597,7 +597,7 @@ Improper *Force::improper_match(const std::string &style) if (style == improper_style) return improper; else if (utils::strmatch(improper_style, "^hybrid")) { - ImproperHybrid *hybrid = (ImproperHybrid *) improper; + auto hybrid = dynamic_cast( improper); for (int i = 0; i < hybrid->nstyles; i++) if (style == hybrid->keywords[i]) return hybrid->styles[i]; } diff --git a/src/improper_deprecated.cpp b/src/improper_deprecated.cpp index 7e03825346..b1e3d3511b 100644 --- a/src/improper_deprecated.cpp +++ b/src/improper_deprecated.cpp @@ -37,7 +37,7 @@ void ImproperDeprecated::settings(int, char **) // of the list of substyles if (utils::strmatch(my_style,"^hybrid")) { - ImproperHybrid *hybrid = (ImproperHybrid *)force->improper; + auto hybrid = dynamic_cast(force->improper); my_style = hybrid->keywords[hybrid->nstyles]; } diff --git a/src/info.cpp b/src/info.cpp index fad9814a5f..fa713d9ab2 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -414,7 +414,7 @@ void Info::command(int narg, char **arg) atom->natoms, atom->ntypes, force->pair_style); if (force->pair && utils::strmatch(force->pair_style,"^hybrid")) { - PairHybrid *hybrid = (PairHybrid *)force->pair; + auto hybrid = dynamic_cast(force->pair); fmt::print(out,"Hybrid sub-styles:"); for (int i=0; i < hybrid->nstyles; ++i) fmt::print(out," {}", hybrid->keywords[i]); diff --git a/src/min.cpp b/src/min.cpp index 0c71607bd8..1adb88184a 100644 --- a/src/min.cpp +++ b/src/min.cpp @@ -121,7 +121,7 @@ void Min::init() // create fix needed for storing atom-based quantities // will delete it at end of run - fix_minimize = (FixMinimize *) modify->add_fix("MINIMIZE all MINIMIZE"); + fix_minimize = dynamic_cast( modify->add_fix("MINIMIZE all MINIMIZE")); // clear out extra global and per-atom dof // will receive requests for new per-atom dof during pair init() diff --git a/src/molecule.cpp b/src/molecule.cpp index d6c839dfc4..816b2686ab 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -477,7 +477,7 @@ void Molecule::read(int flag) itensor[5] *= scale5; } else if (values.contains("body")) { bodyflag = 1; - avec_body = (AtomVecBody *) atom->style_match("body"); + avec_body = dynamic_cast( atom->style_match("body")); if (!avec_body) error->all(FLERR,"Molecule file requires atom style body"); nibody = values.next_int(); diff --git a/src/neighbor.cpp b/src/neighbor.cpp index eab6278b3a..569bd154fa 100644 --- a/src/neighbor.cpp +++ b/src/neighbor.cpp @@ -469,12 +469,12 @@ void Neighbor::init() int respa = 0; if (update->whichflag == 1 && utils::strmatch(update->integrate_style,"^respa")) { - if (((Respa *) update->integrate)->level_inner >= 0) respa = 1; - if (((Respa *) update->integrate)->level_middle >= 0) respa = 2; + if ((dynamic_cast( update->integrate))->level_inner >= 0) respa = 1; + if ((dynamic_cast( update->integrate))->level_middle >= 0) respa = 2; } if (respa) { - double *cut_respa = ((Respa *) update->integrate)->cutoff; + double *cut_respa = (dynamic_cast( update->integrate))->cutoff; cut_inner_sq = (cut_respa[1] + skin) * (cut_respa[1] + skin); cut_middle_sq = (cut_respa[3] + skin) * (cut_respa[3] + skin); cut_middle_inside_sq = (cut_respa[0] - skin) * (cut_respa[0] - skin); diff --git a/src/pair_deprecated.cpp b/src/pair_deprecated.cpp index b691744cd4..691eff124f 100644 --- a/src/pair_deprecated.cpp +++ b/src/pair_deprecated.cpp @@ -36,7 +36,7 @@ void PairDeprecated::settings(int, char **) // called, our style was just added at the end of the list of substyles if (utils::strmatch(my_style,"^hybrid")) { - PairHybrid *hybrid = (PairHybrid *)force->pair; + auto hybrid = dynamic_cast(force->pair); my_style = hybrid->keywords[hybrid->nstyles]; } diff --git a/src/pair_hybrid.cpp b/src/pair_hybrid.cpp index 6349fb78f7..2dcf900718 100644 --- a/src/pair_hybrid.cpp +++ b/src/pair_hybrid.cpp @@ -115,7 +115,7 @@ void PairHybrid::compute(int eflag, int vflag) Respa *respa = nullptr; respaflag = 0; if (utils::strmatch(update->integrate_style,"^respa")) { - respa = (Respa *) update->integrate; + respa = dynamic_cast( update->integrate); if (respa->nhybrid_styles > 0) respaflag = 1; } diff --git a/src/pair_hybrid_scaled.cpp b/src/pair_hybrid_scaled.cpp index 6bdaeb4530..908d5c27ee 100644 --- a/src/pair_hybrid_scaled.cpp +++ b/src/pair_hybrid_scaled.cpp @@ -130,7 +130,7 @@ void PairHybridScaled::compute(int eflag, int vflag) Respa *respa = nullptr; respaflag = 0; if (utils::strmatch(update->integrate_style, "^respa")) { - respa = (Respa *) update->integrate; + respa = dynamic_cast( update->integrate); if (respa->nhybrid_styles > 0) respaflag = 1; } diff --git a/src/pair_lj_cut.cpp b/src/pair_lj_cut.cpp index c6751b3505..8c24bd2f70 100644 --- a/src/pair_lj_cut.cpp +++ b/src/pair_lj_cut.cpp @@ -478,7 +478,7 @@ void PairLJCut::init_style() int list_style = NeighConst::REQ_DEFAULT; if (update->whichflag == 1 && utils::strmatch(update->integrate_style, "^respa")) { - auto respa = (Respa *) update->integrate; + auto respa = dynamic_cast( update->integrate); if (respa->level_inner >= 0) list_style = NeighConst::REQ_RESPA_INOUT; if (respa->level_middle >= 0) list_style = NeighConst::REQ_RESPA_ALL; } @@ -487,8 +487,8 @@ void PairLJCut::init_style() // set rRESPA cutoffs if (utils::strmatch(update->integrate_style, "^respa") && - ((Respa *) update->integrate)->level_inner >= 0) - cut_respa = ((Respa *) update->integrate)->cutoff; + (dynamic_cast( update->integrate))->level_inner >= 0) + cut_respa = (dynamic_cast( update->integrate))->cutoff; else cut_respa = nullptr; } diff --git a/src/read_data.cpp b/src/read_data.cpp index 2ea37b58f8..5505b5a5a0 100644 --- a/src/read_data.cpp +++ b/src/read_data.cpp @@ -99,11 +99,11 @@ ReadData::ReadData(LAMMPS *lmp) : Command(lmp) // pointers to atom styles that store bonus info nellipsoids = 0; - avec_ellipsoid = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); + avec_ellipsoid = dynamic_cast( atom->style_match("ellipsoid")); nlines = 0; - avec_line = (AtomVecLine *) atom->style_match("line"); + avec_line = dynamic_cast( atom->style_match("line")); ntris = 0; - avec_tri = (AtomVecTri *) atom->style_match("tri"); + avec_tri = dynamic_cast( atom->style_match("tri")); nbodies = 0; avec_body = (AtomVecBody *) atom->style_match("body"); } diff --git a/src/read_restart.cpp b/src/read_restart.cpp index 3f6f2f481b..dea062ed87 100644 --- a/src/read_restart.cpp +++ b/src/read_restart.cpp @@ -445,7 +445,7 @@ void ReadRestart::command(int narg, char **arg) if (nextra) { memory->destroy(atom->extra); memory->create(atom->extra,atom->nmax,nextra,"atom:extra"); - auto fix = (FixReadRestart *) modify->get_fix_by_id("_read_restart"); + auto fix = dynamic_cast( modify->get_fix_by_id("_read_restart")); int *count = fix->count; double **extra = fix->extra; double **atom_extra = atom->extra; diff --git a/src/reset_mol_ids.cpp b/src/reset_mol_ids.cpp index 79f44bdc3c..30a817433e 100644 --- a/src/reset_mol_ids.cpp +++ b/src/reset_mol_ids.cpp @@ -152,13 +152,13 @@ void ResetMolIDs::create_computes(char *fixid, char *groupid) idfrag = fmt::format("{}_reset_mol_ids_FRAGMENT_ATOM",fixid); auto use_single = singleflag ? "yes" : "no"; - cfa = (ComputeFragmentAtom *) - modify->add_compute(fmt::format("{} {} fragment/atom single {}",idfrag,groupid,use_single)); + cfa = dynamic_cast( + modify->add_compute(fmt::format("{} {} fragment/atom single {}",idfrag,groupid,use_single))); idchunk = fmt::format("{}_reset_mol_ids_CHUNK_ATOM",fixid); if (compressflag) - cca = (ComputeChunkAtom *) - modify->add_compute(fmt::format("{} {} chunk/atom molecule compress yes",idchunk,groupid)); + cca = dynamic_cast( + modify->add_compute(fmt::format("{} {} chunk/atom molecule compress yes",idchunk,groupid))); } /* ---------------------------------------------------------------------- diff --git a/src/respa.cpp b/src/respa.cpp index 9690105d40..97356eac47 100644 --- a/src/respa.cpp +++ b/src/respa.cpp @@ -121,7 +121,7 @@ Respa::Respa(LAMMPS *lmp, int narg, char **arg) : // the hybrid keyword requires a hybrid pair style if (!utils::strmatch(force->pair_style, "^hybrid")) error->all(FLERR, "Illegal run_style respa command"); - PairHybrid *hybrid = (PairHybrid *) force->pair; + auto hybrid = dynamic_cast( force->pair); nhybrid_styles = hybrid->nstyles; // each hybrid sub-style needs to be assigned to a respa level if (iarg + nhybrid_styles > narg) error->all(FLERR, "Illegal run_style respa command"); @@ -296,7 +296,7 @@ void Respa::init() std::string cmd = fmt::format("RESPA all RESPA {}", nlevels); if (atom->torque_flag) cmd += " torque"; - fix_respa = (FixRespa *) modify->add_fix(cmd); + fix_respa = dynamic_cast( modify->add_fix(cmd)); // insure respa inner/middle/outer is using Pair class that supports it diff --git a/src/set.cpp b/src/set.cpp index 2e3cff9526..970155bda3 100644 --- a/src/set.cpp +++ b/src/set.cpp @@ -767,11 +767,10 @@ void Set::set(int keyword) // loop over selected atoms - AtomVecEllipsoid *avec_ellipsoid = - (AtomVecEllipsoid *) atom->style_match("ellipsoid"); - AtomVecLine *avec_line = (AtomVecLine *) atom->style_match("line"); - AtomVecTri *avec_tri = (AtomVecTri *) atom->style_match("tri"); - AtomVecBody *avec_body = (AtomVecBody *) atom->style_match("body"); + auto avec_ellipsoid = dynamic_cast( atom->style_match("ellipsoid")); + auto avec_line = dynamic_cast( atom->style_match("line")); + auto avec_tri = dynamic_cast( atom->style_match("tri")); + auto avec_body = dynamic_cast( atom->style_match("body")); int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { @@ -1055,11 +1054,10 @@ void Set::setrandom(int keyword) { int i; - AtomVecEllipsoid *avec_ellipsoid = - (AtomVecEllipsoid *) atom->style_match("ellipsoid"); - AtomVecLine *avec_line = (AtomVecLine *) atom->style_match("line"); - AtomVecTri *avec_tri = (AtomVecTri *) atom->style_match("tri"); - AtomVecBody *avec_body = (AtomVecBody *) atom->style_match("body"); + auto avec_ellipsoid = dynamic_cast( atom->style_match("ellipsoid")); + auto avec_line = dynamic_cast( atom->style_match("line")); + auto avec_tri = dynamic_cast( atom->style_match("tri")); + auto avec_body = dynamic_cast( atom->style_match("body")); double **x = atom->x; int seed = ivalue; diff --git a/src/special.cpp b/src/special.cpp index 7f43199e18..4aa80bc443 100644 --- a/src/special.cpp +++ b/src/special.cpp @@ -684,10 +684,10 @@ void Special::combine() utils::logmesg(lmp,"{:>6} = max # of special neighbors\n",atom->maxspecial); if (lmp->kokkos) { - AtomKokkos* atomKK = (AtomKokkos*) atom; + auto atomKK = dynamic_cast( atom); atomKK->modified(Host,SPECIAL_MASK); atomKK->sync(Device,SPECIAL_MASK); - MemoryKokkos* memoryKK = (MemoryKokkos*) memory; + auto memoryKK = dynamic_cast( memory); memoryKK->grow_kokkos(atomKK->k_special,atom->special, atom->nmax,atom->maxspecial,"atom:special"); atomKK->modified(Device,SPECIAL_MASK); diff --git a/src/variable.cpp b/src/variable.cpp index 5249ed3035..42afda5cd8 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -4856,7 +4856,7 @@ VarReader::VarReader(LAMMPS *lmp, char *name, char *file, int flag) : error->all(FLERR,"Cannot use atomfile-style variable unless an atom map exists"); id_fix = utils::strdup(std::string(name) + "_VARIABLE_STORE"); - fixstore = (FixStore *) modify->add_fix(std::string(id_fix) + " all STORE peratom 0 1"); + fixstore = dynamic_cast( modify->add_fix(std::string(id_fix) + " all STORE peratom 0 1")); buffer = new char[CHUNK*MAXLINE]; } } diff --git a/src/write_dump.cpp b/src/write_dump.cpp index 8e6a5147e7..b28fc586e2 100644 --- a/src/write_dump.cpp +++ b/src/write_dump.cpp @@ -74,10 +74,10 @@ void WriteDump::command(int narg, char **arg) // set multifile_override for DumpImage so that filename needs no "*" if (strcmp(arg[1],"image") == 0) - ((DumpImage *) dump)->multifile_override = 1; + (dynamic_cast( dump))->multifile_override = 1; if (strcmp(arg[1],"cfg") == 0) - ((DumpCFG *) dump)->multifile_override = 1; + (dynamic_cast( dump))->multifile_override = 1; if ((update->first_update == 0) && (comm->me == 0)) error->warning(FLERR,"Calling write_dump before a full system init.");