From 29405937ac229fcac793c3204cca21dcb2300df1 Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Thu, 18 Jun 2026 17:48:43 -0400 Subject: [PATCH 01/33] Produce pkgconfig info for libpyorbit. Overall restructuring so we don't ship more than necessary. --- src/meson.build | 427 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 296 insertions(+), 131 deletions(-) diff --git a/src/meson.build b/src/meson.build index c7474e58..84d484f6 100644 --- a/src/meson.build +++ b/src/meson.build @@ -17,21 +17,20 @@ dependencies += dependency('fftw3', version: '>= 3.0.0', required: true) # Detecting if MPICH or OPENMPI are installed and enabling support if present mpi_use = get_option('USE_MPI') +use_mpi_flag = '0' if mpi_use == 'mpich' message('Requested to use MPICH as the MPI implementation.') dependencies += dependency('mpich', version: '>= 4.0.0', required: true) add_project_arguments('-DUSE_MPI=1', language: 'cpp') - - # Configure dependencies or settings specific to MPICH + use_mpi_flag = '1' elif mpi_use == 'ompi' message('Requested to use OpenMPI as the MPI implementation.') dependencies += dependency('ompi', version: '>= 4.0.0', required: true) add_project_arguments('-DUSE_MPI=1', language: 'cpp') - + use_mpi_flag = '1' elif mpi_use == 'none' message('Requested to not use MPI.') - else mpich_dependency = dependency('mpich', version: '>= 4.0.0', required: false) openmpi_dependency = dependency('ompi', version: '>= 4.0.0', required: false) @@ -40,10 +39,12 @@ else add_project_arguments('-DUSE_MPI=1', language: 'cpp') dependencies += mpich_dependency message('Using MPICH as the MPI implementation.') + use_mpi_flag = '1' elif openmpi_dependency.found() add_project_arguments('-DUSE_MPI=1', language: 'cpp') dependencies += openmpi_dependency message('Using OpenMPI as the MPI implementation.') + use_mpi_flag = '1' else message('MPI will not be used.') endif @@ -51,61 +52,34 @@ else endif sources = files([ - 'linac/wrap_linacmodule.cc', 'linac/tracking/linac_tracking.cc', - 'linac/tracking/wrap_linac_tracking.cc', - 'linac/rfgap/wrap_BaseRfGap.cc', 'linac/rfgap/BaseRfGap_slow.cc', - 'linac/rfgap/wrap_RfGapTTF_slow.cc', - 'linac/rfgap/wrap_RfGapThreePointTTF.cc', 'linac/rfgap/BaseRfGap.cc', 'linac/rfgap/RfGapThreePointTTF.cc', 'linac/rfgap/MatrixRfGap.cc', - 'linac/rfgap/wrap_BaseRfGap_slow.cc', - 'linac/rfgap/wrap_RfGapThreePointTTF_slow.cc', - 'linac/rfgap/wrap_SuperFishFieldSource.cc', 'linac/rfgap/RfGapTTF.cc', 'linac/rfgap/SuperFishFieldSource.cc', 'linac/rfgap/RfGapTTF_slow.cc', 'linac/rfgap/RfGapThreePointTTF_slow.cc', - 'linac/rfgap/wrap_RfGapTTF.cc', - 'linac/rfgap/wrap_MatrixRfGap.cc', 'orbit/OrbitConst.cc', - 'orbit/wrap_bunch.cc', - 'orbit/wrap_syncpart.cc', 'orbit/Bunch.cc', 'orbit/SyncPart.cc', - 'orbit/BunchDiagnostics/wrap_bunch_tune_analysis.cc', - 'orbit/BunchDiagnostics/wrap_bunch_twiss_analysis.cc', 'orbit/BunchDiagnostics/BunchTwissAnalysis.cc', 'orbit/BunchDiagnostics/BunchTuneAnalysis.cc', - 'orbit/FieldTracker/wrap_fieldtracker.cc', 'orbit/FieldTracker/FieldTracker.cc', - 'orbit/MaterialInteractions/wrap_foil.cc', 'orbit/MaterialInteractions/Foil.cc', 'orbit/MaterialInteractions/Collimator.cc', 'orbit/MaterialInteractions/numrecipes.cc', 'orbit/MaterialInteractions/cross_sections.cc', - 'orbit/MaterialInteractions/wrap_collimator.cc', 'orbit/MaterialInteractions/MaterialInteractions.cc', 'orbit/RFCavities/Dual_Harmonic_Cav.cc', 'orbit/RFCavities/Frequency_Cav.cc', 'orbit/RFCavities/Barrier_Cav.cc', - 'orbit/RFCavities/wrap_Harmonic_Cav.cc', 'orbit/RFCavities/Harmonic_Cav.cc', - 'orbit/RFCavities/wrap_Dual_Harmonic_Cav.cc', - 'orbit/RFCavities/wrap_Barrier_Cav.cc', - 'orbit/RFCavities/wrap_Frequency_Cav.cc', - 'orbit/RFCavities/wrap_rfcavities.cc', - 'orbit/Impedances/wrap_TImpedance.cc', 'orbit/Impedances/TImpedance.cc', - 'orbit/Impedances/wrap_impedances.cc', 'orbit/Impedances/LImpedance.cc', - 'orbit/Impedances/wrap_LImpedance.cc', 'orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.cc', - 'orbit/SynchPartRedefinition/wrap_synch_part_redefinition_z_de.cc', 'orbit/Errors/errorbase.cc', - 'orbit/Errors/wrap_errorbase.cc', 'orbit/ParticlesAttributes/ParticleInitialCoordinates.cc', 'orbit/ParticlesAttributes/ParticleIdNumber.cc', 'orbit/ParticlesAttributes/ParticleMacroSize.cc', @@ -122,194 +96,385 @@ sources = files([ 'orbit/Apertures/CircleApertureShape.cc', 'orbit/Apertures/PhaseAperture.cc', 'orbit/Apertures/Aperture.cc', - 'orbit/Apertures/wrap_aperture.cc', - 'orbit/Apertures/wrap_CompositeApertureShape.cc', 'orbit/Apertures/RectangularApertureShape.cc', 'orbit/Apertures/PyBaseApertureShape.cc', 'orbit/Apertures/ConvexApertureShape.cc', - 'orbit/Apertures/wrap_ConvexApertureShape.cc', - 'orbit/Apertures/wrap_PyBaseApertureShape.cc', 'orbit/Apertures/EnergyAperture.cc', 'orbit/Apertures/BaseAperture.cc', 'orbit/Apertures/EllipseApertureShape.cc', - 'orbit/Apertures/wrap_BaseAperture.cc', - 'orbit/Apertures/wrap_PrimitiveApertureShape.cc', 'orbit/Apertures/CompositeApertureShape.cc', - 'orbit/Apertures/wrap_EnergyAperture.cc', - 'orbit/Apertures/wrap_TAperture.cc', - 'orbit/Apertures/wrap_PhaseAperture.cc', 'orbit/Apertures/BaseApertureShape.cc', - 'trackerrk4/wrap_runge_kutta_tracker.cc', - 'trackerrk4/wrap_py_external_effects.cc', 'trackerrk4/ExternalEffects.cc', 'trackerrk4/ExtEffectsContainer.cc', - 'trackerrk4/wrap_trackerrk4.cc', 'trackerrk4/PyExternalEffects.cc', 'trackerrk4/RungeKuttaTracker.cc', - 'trackerrk4/wrap_ext_effects_container.cc', - 'mpi/wrap_orbit_mpi.cc', - 'mpi/wrap_mpi_comm.cc', 'mpi/orbit_mpi.cc', - 'mpi/wrap_mpi_datatype.cc', - 'mpi/wrap_mpi_request.cc', - 'mpi/wrap_mpi_op.cc', - 'mpi/wrap_mpi_status.cc', - 'mpi/wrap_mpi_group.cc', 'spacecharge/PoissonSolverFFT3D.cc', 'spacecharge/SpaceChargeCalcUnifEllipse.cc', 'spacecharge/ForceSolver2D.cc', 'spacecharge/PoissonSolverFFT2D.cc', - 'spacecharge/wrap_poissonsolverfft2d.cc', - 'spacecharge/wrap_poissonsolverfft3d.cc', 'spacecharge/PoissonSolver2D.cc', 'spacecharge/SpaceChargeForceCalc2p5D.cc', 'spacecharge/PoissonSolver3D.cc', 'spacecharge/SpaceChargeCalc3D.cc', - 'spacecharge/wrap_boundary2d.cc', - 'spacecharge/wrap_forcesolverfft2d.cc', 'spacecharge/ForceSolverFFT2D.cc', 'spacecharge/SpaceChargeCalcSliceBySlice2D.cc', 'spacecharge/Grid3D.cc', - 'spacecharge/wrap_spacecharge.cc', - 'spacecharge/wrap_spacechargecalc2p5d_rb.cc', - 'spacecharge/Grid2D.cc', 'spacecharge/SpaceChargeCalc2p5Drb.cc', + 'spacecharge/Grid2D.cc', + 'spacecharge/SpaceChargeCalc2p5D.cc', 'spacecharge/Grid1D.cc', 'spacecharge/LSpaceChargeCalc.cc', - 'spacecharge/wrap_grid1D.cc', - 'spacecharge/wrap_uniform_ellipsoid_field_calculator.cc', 'spacecharge/ShapedBoundary2D.cc', - 'spacecharge/wrap_grid3D.cc', 'spacecharge/BaseBoundary2D.cc', - 'spacecharge/wrap_grid2D.cc', - 'spacecharge/wrap_spacechargecalc_uniform_ellipse.cc', - 'spacecharge/wrap_spacechargecalc3d.cc', 'spacecharge/UniformEllipsoidFieldCalculator.cc', - 'spacecharge/wrap_spacechargeforcecalc2p5d.cc', - 'spacecharge/SpaceChargeCalc2p5D.cc', - 'spacecharge/wrap_spacechargecalc_slicebyslice_2D.cc', - 'spacecharge/wrap_spacechargecalc2p5d.cc', - 'spacecharge/wrap_lspacechargecalc.cc', - 'utils/wrap_function.cc', 'utils/FieldSourceContainer.cc', 'utils/AttributesBucket.cc', 'utils/bessel.cc', 'utils/PyBaseFieldSource.cc', - 'utils/wrap_field_source_container.cc', 'utils/OU_SplineCH.cc', 'utils/CppPyWrapper.cc', - 'utils/wrap_random.cc', - 'utils/wrap_utils.cc', 'utils/StringUtils.cc', - 'utils/wrap_py_base_field_source.cc', - 'utils/wrap_splinech.cc', 'utils/Random.cc', - 'utils/wrap_numrecipes.cc', 'utils/BaseFieldSource.cc', 'utils/OU_Function.cc', 'utils/MathPolynomial.cc', 'utils/BufferStore.cc', - 'utils/statistics/wrap_statmoments2d.cc', 'utils/statistics/StatMoments2D.cc', - 'utils/field_sources/wrap_loop_field_source.cc', 'utils/field_sources/LoopFieldSource.cc', 'utils/field_sources/QuadFieldSource.cc', 'utils/field_sources/ShiftedFieldSource.cc', - 'utils/field_sources/wrap_dipole_field_source.cc', - 'utils/field_sources/wrap_quad_field_source.cc', - 'utils/field_sources/wrap_magnetic_field_source_grid3d.cc', 'utils/field_sources/DipoleFieldSource.cc', - 'utils/field_sources/wrap_field_sources_module.cc', 'utils/field_sources/MagnetFieldSourceGrid3D.cc', 'utils/integration/gauss_legendre_points.cc', - 'utils/integration/wrap_gauss_legendre_integrator.cc', 'utils/integration/GaussLegendreIntegrator.cc', 'utils/bunch/ParticlesWithIdFunctions.cc', - 'utils/bunch/wrap_bunch_extrema_calculator.cc', 'utils/bunch/TwissFilteringFunctions.cc', 'utils/bunch/InitialCoordsAttrFunctions.cc', 'utils/bunch/BunchExtremaCalculator.cc', - 'utils/bunch/wrap_bunch_utils_functions.cc', 'utils/harmonic_analysis/HarmonicData.cc', - 'utils/harmonic_analysis/wrap_harmonic_data.cc', - 'utils/polynomial/wrap_polynomial.cc', 'utils/polynomial/OU_Polynomial.cc', - 'utils/matrix/wrap_matrix.cc', 'utils/matrix/PhaseVector.cc', 'utils/matrix/MatrixOperations.cc', - 'utils/matrix/wrap_phase_vector.cc', 'utils/matrix/Matrix.cc', - 'teapot/wrap_teapotbase.cc', - 'teapot/wrap_matrix_generator.cc', 'teapot/teapotbase.cc', 'teapot/MatrixGenerator.cc' ]) inc = include_directories([ 'main', - 'orbit/SynchPartRedefinition', - 'trackerrk4', - 'utils/ellipticalint', - 'teapot', 'mpi', - 'orbit/ParticlesAttributes', + 'orbit', + 'orbit/Apertures', + 'orbit/BunchDiagnostics', 'orbit/Errors', 'orbit/FieldTracker', - 'utils/statistics', - 'utils', - 'linac/tracking', - 'spacecharge', + 'orbit/Impedances', 'orbit/MaterialInteractions', - 'utils/field_sources', + 'orbit/ParticlesAttributes', + 'orbit/RFCavities', + 'orbit/SynchPartRedefinition', + 'spacecharge', + 'teapot', + 'trackerrk4', + 'utils', 'utils/bunch', - 'orbit/Impedances', + 'utils/ellipticalint', + 'utils/field_sources', 'utils/harmonic_analysis', - 'linac', + 'utils/integration', + 'utils/matrix', 'utils/polynomial', + 'utils/statistics', + 'linac', 'linac/rfgap', - 'orbit/RFCavities', - 'utils/matrix', - 'orbit/BunchDiagnostics', - 'orbit', - 'utils/integration', - 'orbit/Apertures' + 'linac/tracking', ]) core_lib = library( - 'core', + 'pyorbit3_core', sources: sources, include_directories: inc, - override_options: ['b_lundef=false'], dependencies: dependencies, + override_options: ['b_lundef=false'], install: true, ) -core_dep = declare_dependency(link_with : core_lib) +core_dep = declare_dependency(link_with : core_lib, dependencies: dependencies) + +api_headers = [ + 'linac/rfgap/BaseRfGap.hh', + 'linac/rfgap/BaseRfGap_slow.hh', + 'linac/rfgap/MatrixRfGap.hh', + 'linac/rfgap/RfGapThreePointTTF.hh', + 'linac/rfgap/RfGapThreePointTTF_slow.hh', + 'linac/rfgap/RfGapTTF.hh', + 'linac/rfgap/RfGapTTF_slow.hh', + 'linac/rfgap/SuperFishFieldSource.hh', + 'linac/tracking/linac_tracking.hh', + 'main/pyORBIT_Object.hh', + 'mpi/orbit_mpi.hh', + 'orbit/Apertures/Aperture.hh', + 'orbit/Apertures/BaseAperture.hh', + 'orbit/Apertures/BaseApertureShape.hh', + 'orbit/Apertures/CircleApertureShape.hh', + 'orbit/Apertures/CompositeApertureShape.hh', + 'orbit/Apertures/ConvexApertureShape.hh', + 'orbit/Apertures/EllipseApertureShape.hh', + 'orbit/Apertures/EnergyAperture.hh', + 'orbit/Apertures/PhaseAperture.hh', + 'orbit/Apertures/PyBaseApertureShape.hh', + 'orbit/Apertures/RectangularApertureShape.hh', + 'orbit/Bunch.hh', + 'orbit/BunchDiagnostics/BunchTuneAnalysis.hh', + 'orbit/BunchDiagnostics/BunchTwissAnalysis.hh', + 'orbit/Errors/errorbase.hh', + 'orbit/FieldTracker/FieldTracker.hh', + 'orbit/Impedances/LImpedance.hh', + 'orbit/Impedances/TImpedance.hh', + 'orbit/MaterialInteractions/Collimator.hh', + 'orbit/MaterialInteractions/Foil.hh', + 'orbit/MaterialInteractions/MaterialInteractions.hh', + 'orbit/MaterialInteractions/cross_sections.hh', + 'orbit/MaterialInteractions/numrecipes.hh', + 'orbit/OrbitConst.hh', + 'orbit/ParticlesAttributes/AtomPopulations.hh', + 'orbit/ParticlesAttributes/Evolution.hh', + 'orbit/ParticlesAttributes/LostParticleAttributes.hh', + 'orbit/ParticlesAttributes/ParticleAttributes.hh', + 'orbit/ParticlesAttributes/ParticleAttributesFactory.hh', + 'orbit/ParticlesAttributes/ParticleIdNumber.hh', + 'orbit/ParticlesAttributes/ParticleInitialCoordinates.hh', + 'orbit/ParticlesAttributes/ParticleMacroSize.hh', + 'orbit/ParticlesAttributes/ParticlePhaseAttributes.hh', + 'orbit/ParticlesAttributes/TurnNumberAttributes.hh', + 'orbit/ParticlesAttributes/WaveFunctionAmplitudes.hh', + 'orbit/ParticlesAttributes/part_time.hh', + 'orbit/ParticlesAttributes/pq_coordinates.hh', + 'orbit/RFCavities/Barrier_Cav.hh', + 'orbit/RFCavities/Dual_Harmonic_Cav.hh', + 'orbit/RFCavities/Frequency_Cav.hh', + 'orbit/RFCavities/Harmonic_Cav.hh', + 'orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.hh', + 'orbit/SyncPart.hh', + 'spacecharge/BaseBoundary2D.hh', + 'spacecharge/ForceSolver2D.hh', + 'spacecharge/ForceSolverFFT2D.hh', + 'spacecharge/Grid1D.hh', + 'spacecharge/Grid2D.hh', + 'spacecharge/Grid3D.hh', + 'spacecharge/LSpaceChargeCalc.hh', + 'spacecharge/PoissonSolver2D.hh', + 'spacecharge/PoissonSolver3D.hh', + 'spacecharge/PoissonSolverFFT2D.hh', + 'spacecharge/PoissonSolverFFT3D.hh', + 'spacecharge/ShapedBoundary2D.hh', + 'spacecharge/SpaceChargeCalc2p5D.hh', + 'spacecharge/SpaceChargeCalc2p5Drb.hh', + 'spacecharge/SpaceChargeCalc3D.hh', + 'spacecharge/SpaceChargeCalcSliceBySlice2D.hh', + 'spacecharge/SpaceChargeCalcUnifEllipse.hh', + 'spacecharge/SpaceChargeForceCalc2p5D.hh', + 'spacecharge/UniformEllipsoidFieldCalculator.hh', + 'teapot/MatrixGenerator.hh', + 'teapot/teapotbase.hh', + 'trackerrk4/ExtEffectsContainer.hh', + 'trackerrk4/ExternalEffects.hh', + 'trackerrk4/PyExternalEffects.hh', + 'trackerrk4/RungeKuttaTracker.hh', + 'utils/AttributesBucket.hh', + 'utils/BaseFieldSource.hh', + 'utils/BufferStore.hh', + 'utils/CppPyWrapper.hh', + 'utils/FieldSourceContainer.hh', + 'utils/MathPolynomial.hh', + 'utils/OU_Function.hh', + 'utils/OU_SplineCH.hh', + 'utils/PyBaseFieldSource.hh', + 'utils/Random.hh', + 'utils/StringUtils.hh', + 'utils/bessel.hh', + 'utils/bunch/BunchExtremaCalculator.hh', + 'utils/bunch/InitialCoordsAttrFunctions.hh', + 'utils/bunch/ParticlesWithIdFunctions.hh', + 'utils/bunch/TwissFilteringFunctions.hh', + 'utils/ellipticalint/elliptint.hh', + 'utils/field_sources/DipoleFieldSource.hh', + 'utils/field_sources/LoopFieldSource.hh', + 'utils/field_sources/MagnetFieldSourceGrid3D.hh', + 'utils/field_sources/QuadFieldSource.hh', + 'utils/field_sources/ShiftedFieldSource.hh', + 'utils/harmonic_analysis/HarmonicData.hh', + 'utils/integration/GaussLegendreIntegrator.hh', + 'utils/integration/gauss_legendre_points.hh', + 'utils/matrix/Matrix.hh', + 'utils/matrix/MatrixOperations.hh', + 'utils/matrix/PhaseVector.hh', + 'utils/polynomial/OU_Polynomial.hh', + 'utils/statistics/StatMoments2D.hh', + 'utils/tcomplex.hh', +] + +install_headers(api_headers, subdir : 'pyorbit3', preserve_path : true) + +pc_requires = ['fftw3 >= 3.0.0'] +if get_option('USE_MPI') == 'mpich' + pc_requires += ['mpich >= 4.0.0'] +elif get_option('USE_MPI') == 'ompi' + pc_requires += ['ompi >= 4.0.0'] +endif + +pkgconfig = import('pkgconfig') + +pkgconfig.generate( + name: 'pyorbit3', + description: 'PyORBIT3 core library', + filebase: 'pyorbit3', + version: meson.project_version(), + libraries: core_lib, + requires: pc_requires, + subdirs: 'pyorbit3', + extra_cflags: '-DUSE_MPI=' + use_mpi_flag, + install_dir: get_option('libdir') / 'pkgconfig', +) ext_modules = { - 'orbit_mpi': 'mpi_init.cc', - 'bunch': 'bunch_init.cc', - 'spacecharge': 'spacecharge_init.cc', - 'trackerrk4': 'trackerrk4_init.cc', - 'teapot_base': 'teapot_base_init.cc', - 'linac': 'linac_init.cc', - 'orbit_utils': 'utils_init.cc', - 'aperture': 'aperture_init.cc', - 'foil': 'foil_init.cc', - 'field_sources': 'field_sources_init.cc', - 'rfcavities': 'rfcavities_init.cc', - 'impedances': 'impedances_init.cc', - 'fieldtracker': 'fieldtracker_init.cc', - 'collimator': 'collimator_init.cc', - 'error_base': 'error_base_init.cc', + 'orbit_mpi': files( + 'core/mpi_init.cc', + 'mpi/wrap_orbit_mpi.cc', + 'mpi/wrap_mpi_comm.cc', + 'mpi/wrap_mpi_datatype.cc', + 'mpi/wrap_mpi_request.cc', + 'mpi/wrap_mpi_op.cc', + 'mpi/wrap_mpi_status.cc', + 'mpi/wrap_mpi_group.cc', + ), + 'bunch': files( + 'core/bunch_init.cc', + 'orbit/wrap_bunch.cc', + 'orbit/wrap_syncpart.cc', + 'orbit/BunchDiagnostics/wrap_bunch_tune_analysis.cc', + 'orbit/BunchDiagnostics/wrap_bunch_twiss_analysis.cc', + 'orbit/SynchPartRedefinition/wrap_synch_part_redefinition_z_de.cc', + ), + 'spacecharge': files( + 'core/spacecharge_init.cc', + 'spacecharge/wrap_spacecharge.cc', + 'spacecharge/wrap_grid1D.cc', + 'spacecharge/wrap_grid2D.cc', + 'spacecharge/wrap_grid3D.cc', + 'spacecharge/wrap_poissonsolverfft2d.cc', + 'spacecharge/wrap_poissonsolverfft3d.cc', + 'spacecharge/wrap_forcesolverfft2d.cc', + 'spacecharge/wrap_boundary2d.cc', + 'spacecharge/wrap_spacechargecalc2p5d.cc', + 'spacecharge/wrap_spacechargeforcecalc2p5d.cc', + 'spacecharge/wrap_spacechargecalc2p5d_rb.cc', + 'spacecharge/wrap_spacechargecalc_slicebyslice_2D.cc', + 'spacecharge/wrap_lspacechargecalc.cc', + 'spacecharge/wrap_spacechargecalc3d.cc', + 'spacecharge/wrap_uniform_ellipsoid_field_calculator.cc', + 'spacecharge/wrap_spacechargecalc_uniform_ellipse.cc', + ), + 'trackerrk4': files( + 'core/trackerrk4_init.cc', + 'trackerrk4/wrap_trackerrk4.cc', + 'trackerrk4/wrap_runge_kutta_tracker.cc', + 'trackerrk4/wrap_py_external_effects.cc', + 'trackerrk4/wrap_ext_effects_container.cc', + ), + 'teapot_base': files( + 'core/teapot_base_init.cc', + 'teapot/wrap_teapotbase.cc', + 'teapot/wrap_matrix_generator.cc', + ), + 'linac': files( + 'core/linac_init.cc', + 'linac/wrap_linacmodule.cc', + 'linac/tracking/wrap_linac_tracking.cc', + 'linac/rfgap/wrap_BaseRfGap.cc', + 'linac/rfgap/wrap_BaseRfGap_slow.cc', + 'linac/rfgap/wrap_MatrixRfGap.cc', + 'linac/rfgap/wrap_RfGapTTF.cc', + 'linac/rfgap/wrap_RfGapTTF_slow.cc', + 'linac/rfgap/wrap_SuperFishFieldSource.cc', + 'linac/rfgap/wrap_RfGapThreePointTTF.cc', + 'linac/rfgap/wrap_RfGapThreePointTTF_slow.cc', + ), + 'orbit_utils': files( + 'core/utils_init.cc', + 'utils/wrap_utils.cc', + 'utils/matrix/wrap_matrix.cc', + 'utils/matrix/wrap_phase_vector.cc', + 'utils/wrap_py_base_field_source.cc', + 'utils/wrap_field_source_container.cc', + 'utils/wrap_function.cc', + 'utils/wrap_splinech.cc', + 'utils/statistics/wrap_statmoments2d.cc', + 'utils/bunch/wrap_bunch_extrema_calculator.cc', + 'utils/integration/wrap_gauss_legendre_integrator.cc', + 'utils/polynomial/wrap_polynomial.cc', + 'utils/wrap_numrecipes.cc', + 'utils/bunch/wrap_bunch_utils_functions.cc', + 'utils/harmonic_analysis/wrap_harmonic_data.cc', + 'utils/wrap_random.cc', + ), + 'aperture': files( + 'core/aperture_init.cc', + 'orbit/Apertures/wrap_aperture.cc', + 'orbit/Apertures/wrap_TAperture.cc', + 'orbit/Apertures/wrap_PhaseAperture.cc', + 'orbit/Apertures/wrap_EnergyAperture.cc', + 'orbit/Apertures/wrap_BaseAperture.cc', + 'orbit/Apertures/wrap_PyBaseApertureShape.cc', + 'orbit/Apertures/wrap_PrimitiveApertureShape.cc', + 'orbit/Apertures/wrap_CompositeApertureShape.cc', + 'orbit/Apertures/wrap_ConvexApertureShape.cc', + ), + 'foil': files( + 'core/foil_init.cc', + 'orbit/MaterialInteractions/wrap_foil.cc', + ), + 'field_sources': files( + 'core/field_sources_init.cc', + 'utils/field_sources/wrap_field_sources_module.cc', + 'utils/field_sources/wrap_magnetic_field_source_grid3d.cc', + 'utils/field_sources/wrap_quad_field_source.cc', + 'utils/field_sources/wrap_dipole_field_source.cc', + 'utils/field_sources/wrap_loop_field_source.cc', + ), + 'rfcavities': files( + 'core/rfcavities_init.cc', + 'orbit/RFCavities/wrap_rfcavities.cc', + 'orbit/RFCavities/wrap_Frequency_Cav.cc', + 'orbit/RFCavities/wrap_Harmonic_Cav.cc', + 'orbit/RFCavities/wrap_Barrier_Cav.cc', + 'orbit/RFCavities/wrap_Dual_Harmonic_Cav.cc', + ), + 'impedances': files( + 'core/impedances_init.cc', + 'orbit/Impedances/wrap_impedances.cc', + 'orbit/Impedances/wrap_LImpedance.cc', + 'orbit/Impedances/wrap_TImpedance.cc', + ), + 'fieldtracker': files( + 'core/fieldtracker_init.cc', + 'orbit/FieldTracker/wrap_fieldtracker.cc', + ), + 'collimator': files( + 'core/collimator_init.cc', + 'orbit/MaterialInteractions/wrap_collimator.cc', + ), + 'error_base': files( + 'core/error_base_init.cc', + 'orbit/Errors/wrap_errorbase.cc', + ), } -base = meson.current_source_dir() + '/core' - -foreach name, src : ext_modules +foreach name, src_list : ext_modules python.extension_module( name, - sources: base / src, + sources: src_list, include_directories: inc, dependencies: [core_dep], install: true, From e1b6ad2c79c34540beae652595309fb78d35343f Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 19 Jun 2026 10:40:59 -0400 Subject: [PATCH 02/33] Fix runtime dlopen errors by decoupling PyORBIT core logic from wrapper implementation. Previously, we were compiling one, monolithic shared library. In the revised meson.build, I've separated out compilation of the core from python extension modules and removed unnecessary interdependence. Bunch and GridD were reliant on the pyORBIT_MPI_Comm wrapper over MPI_Comm, which coupled C++ core behavior and python wrapper handling thereby preventing separation. Factored out common utility functions to ascertain Python types of pyorbit objects at runtime under src/core/type_accessors.cc. Renamed all instances of "Python.h" -> . This is probably better for Python.h, because the header typically exists at system lib paths, not in the project dir. --- src/core/mpi_init.cc | 4 +- src/core/type_accessors.cc | 65 ++++++ src/linac/rfgap/wrap_BaseRfGap.hh | 2 +- src/linac/rfgap/wrap_BaseRfGap_slow.hh | 2 +- src/linac/rfgap/wrap_MatrixRfGap.hh | 2 +- src/linac/rfgap/wrap_RfGapTTF.hh | 2 +- src/linac/rfgap/wrap_RfGapTTF_slow.hh | 2 +- src/linac/rfgap/wrap_RfGapThreePointTTF.hh | 2 +- .../rfgap/wrap_RfGapThreePointTTF_slow.hh | 2 +- src/linac/rfgap/wrap_SuperFishFieldSource.hh | 2 +- src/linac/tracking/wrap_linac_tracking.cc | 2 +- src/linac/tracking/wrap_linac_tracking.hh | 2 +- src/linac/wrap_linacmodule.hh | 2 +- src/meson.build | 32 ++- src/mpi/orbit_mpi.hh | 2 +- src/mpi/wrap_mpi_comm.cc | 185 ++++++------------ src/mpi/wrap_mpi_comm.hh | 2 +- src/mpi/wrap_orbit_mpi.cc | 2 +- src/mpi/wrap_orbit_mpi.hh | 2 + src/orbit/Apertures/wrap_BaseAperture.hh | 2 +- .../Apertures/wrap_CompositeApertureShape.hh | 2 +- .../Apertures/wrap_ConvexApertureShape.hh | 2 +- src/orbit/Apertures/wrap_EnergyAperture.hh | 2 +- src/orbit/Apertures/wrap_PhaseAperture.hh | 2 +- .../Apertures/wrap_PrimitiveApertureShape.hh | 2 +- .../Apertures/wrap_PyBaseApertureShape.hh | 2 +- src/orbit/Apertures/wrap_TAperture.hh | 2 +- src/orbit/Apertures/wrap_aperture.hh | 2 +- src/orbit/Bunch.cc | 73 ++++--- src/orbit/Bunch.hh | 15 +- .../BunchDiagnostics/BunchTwissAnalysis.cc | 16 +- .../wrap_bunch_tune_analysis.hh | 2 +- .../wrap_bunch_twiss_analysis.hh | 2 +- src/orbit/Errors/wrap_errorbase.cc | 2 +- src/orbit/FieldTracker/wrap_fieldtracker.hh | 2 +- src/orbit/Impedances/wrap_LImpedance.hh | 2 +- src/orbit/Impedances/wrap_TImpedance.hh | 2 +- src/orbit/Impedances/wrap_impedances.hh | 2 +- .../MaterialInteractions/wrap_collimator.hh | 2 +- src/orbit/MaterialInteractions/wrap_foil.hh | 2 +- .../ParticleAttributesFactory.cc | 2 +- src/orbit/RFCavities/wrap_Barrier_Cav.hh | 2 +- .../RFCavities/wrap_Dual_Harmonic_Cav.hh | 2 +- src/orbit/RFCavities/wrap_Frequency_Cav.hh | 2 +- src/orbit/RFCavities/wrap_Harmonic_Cav.hh | 2 +- src/orbit/RFCavities/wrap_rfcavities.hh | 2 +- src/orbit/SyncPart.cc | 6 +- .../SynchPartRedefinitionZdE.cc | 6 +- .../wrap_synch_part_redefinition_z_de.hh | 2 +- src/orbit/wrap_bunch.cc | 67 +++---- src/orbit/wrap_bunch.hh | 4 +- src/orbit/wrap_syncpart.hh | 2 +- src/spacecharge/Grid1D.cc | 6 +- src/spacecharge/Grid1D.hh | 3 +- src/spacecharge/Grid2D.cc | 6 +- src/spacecharge/Grid2D.hh | 3 +- src/spacecharge/Grid3D.cc | 6 +- src/spacecharge/Grid3D.hh | 3 +- src/spacecharge/SpaceChargeCalcUnifEllipse.cc | 4 +- src/spacecharge/SpaceChargeCalcUnifEllipse.hh | 1 - src/spacecharge/wrap_boundary2d.hh | 2 +- src/spacecharge/wrap_forcesolverfft2d.hh | 2 +- src/spacecharge/wrap_grid1D.cc | 2 +- src/spacecharge/wrap_grid1D.hh | 2 +- src/spacecharge/wrap_grid2D.cc | 3 +- src/spacecharge/wrap_grid2D.hh | 2 +- src/spacecharge/wrap_grid3D.cc | 3 +- src/spacecharge/wrap_grid3D.hh | 2 +- src/spacecharge/wrap_lspacechargecalc.hh | 2 +- src/spacecharge/wrap_poissonsolverfft2d.hh | 2 +- src/spacecharge/wrap_poissonsolverfft3d.hh | 2 +- src/spacecharge/wrap_spacecharge.cc | 8 - src/spacecharge/wrap_spacecharge.hh | 2 +- src/spacecharge/wrap_spacechargecalc2p5d.hh | 2 +- .../wrap_spacechargecalc2p5d_rb.hh | 2 +- src/spacecharge/wrap_spacechargecalc3d.hh | 2 +- .../wrap_spacechargecalc_slicebyslice_2D.hh | 2 +- .../wrap_spacechargecalc_uniform_ellipse.hh | 2 +- .../wrap_spacechargeforcecalc2p5d.hh | 2 +- ...wrap_uniform_ellipsoid_field_calculator.hh | 2 +- src/teapot/wrap_matrix_generator.hh | 2 +- src/teapot/wrap_teapotbase.cc | 2 +- src/trackerrk4/ExtEffectsContainer.hh | 2 +- src/trackerrk4/PyExternalEffects.hh | 2 +- src/trackerrk4/wrap_ext_effects_container.hh | 2 +- src/trackerrk4/wrap_py_external_effects.hh | 2 +- src/trackerrk4/wrap_runge_kutta_tracker.hh | 2 +- src/trackerrk4/wrap_trackerrk4.cc | 8 - src/trackerrk4/wrap_trackerrk4.hh | 2 +- src/utils/CppPyWrapper.hh | 2 +- src/utils/FieldSourceContainer.hh | 2 +- src/utils/PyBaseFieldSource.hh | 2 +- src/utils/bunch/BunchExtremaCalculator.cc | 12 +- src/utils/bunch/InitialCoordsAttrFunctions.cc | 14 +- src/utils/bunch/ParticlesWithIdFunctions.cc | 18 +- .../bunch/wrap_bunch_extrema_calculator.hh | 2 +- src/utils/bunch/wrap_bunch_utils_functions.hh | 2 +- src/utils/field_sources/ShiftedFieldSource.cc | 2 +- .../field_sources/wrap_dipole_field_source.hh | 2 +- .../wrap_field_sources_module.hh | 2 +- .../field_sources/wrap_loop_field_source.hh | 2 +- .../wrap_magnetic_field_source_grid3d.hh | 2 +- .../field_sources/wrap_quad_field_source.hh | 2 +- .../harmonic_analysis/wrap_harmonic_data.hh | 2 +- .../wrap_gauss_legendre_integrator.hh | 2 +- src/utils/matrix/wrap_matrix.hh | 2 +- src/utils/matrix/wrap_phase_vector.hh | 2 +- src/utils/polynomial/wrap_polynomial.hh | 2 +- src/utils/statistics/StatMoments2D.cc | 10 +- src/utils/statistics/StatMoments2D.hh | 3 +- src/utils/statistics/wrap_statmoments2d.cc | 2 +- src/utils/statistics/wrap_statmoments2d.hh | 2 +- src/utils/wrap_field_source_container.hh | 2 +- src/utils/wrap_function.hh | 2 +- src/utils/wrap_numrecipes.hh | 2 +- src/utils/wrap_py_base_field_source.hh | 2 +- src/utils/wrap_random.hh | 2 +- src/utils/wrap_splinech.hh | 2 +- src/utils/wrap_utils.cc | 9 - src/utils/wrap_utils.hh | 2 +- 120 files changed, 381 insertions(+), 394 deletions(-) create mode 100644 src/core/type_accessors.cc diff --git a/src/core/mpi_init.cc b/src/core/mpi_init.cc index 19fcf616..bf3e796a 100644 --- a/src/core/mpi_init.cc +++ b/src/core/mpi_init.cc @@ -1,6 +1,6 @@ -#include "Python.h" +#include #include "wrap_orbit_mpi.hh" PyMODINIT_FUNC PyInit_orbit_mpi(void) { return wrap_orbit_mpi::initorbit_mpi(); -} \ No newline at end of file +} diff --git a/src/core/type_accessors.cc b/src/core/type_accessors.cc new file mode 100644 index 00000000..31b91134 --- /dev/null +++ b/src/core/type_accessors.cc @@ -0,0 +1,65 @@ +#include + +#include "wrap_bunch.hh" +#include "wrap_spacecharge.hh" +#include "wrap_mpi_comm.hh" +#include "wrap_utils.hh" +#include "wrap_trackerrk4.hh" + +extern "C" { + +namespace wrap_orbit_bunch { + +PyObject* getBunchType(const char* name){ + PyObject* mod = PyImport_ImportModule("orbit.core.bunch"); + PyObject* pyType = PyObject_GetAttrString(mod,name); + Py_DECREF(mod); + Py_DECREF(pyType); + return pyType; +} + +} + +PyObject* getSpaceChargeType(const char* name){ + PyObject* mod = PyImport_ImportModule("orbit.core.spacecharge"); + PyObject* pyType = PyObject_GetAttrString(mod,name); + Py_DECREF(mod); + Py_DECREF(pyType); + return pyType; +} + +namespace wrap_orbit_mpi_comm { + +PyObject* getMPI_CommType(const char* name){ + PyObject* mod = PyImport_ImportModule("orbit.core.orbit_mpi"); + PyObject* mpi_comm_mod = PyObject_GetAttrString(mod,"mpi_comm"); + PyObject* pyType = PyObject_GetAttrString(mpi_comm_mod,name); + Py_DECREF(mpi_comm_mod); + Py_DECREF(mod); + Py_DECREF(pyType); + return pyType; +} + +} + +namespace wrap_orbit_utils { + +PyObject* getOrbitUtilsType(const char* name){ + PyObject* mod = PyImport_ImportModule(const_cast("orbit.core.orbit_utils")); + PyObject* pyType = PyObject_GetAttrString(mod,name); + Py_DECREF(mod); + Py_DECREF(pyType); + return pyType; +} + +} + +PyObject* getTrackerRK4Type(const char* name){ + PyObject* mod = PyImport_ImportModule("orbit.core.trackerrk4"); + PyObject* pyType = PyObject_GetAttrString(mod,name); + Py_DECREF(mod); + Py_DECREF(pyType); + return pyType; +} + +} diff --git a/src/linac/rfgap/wrap_BaseRfGap.hh b/src/linac/rfgap/wrap_BaseRfGap.hh index 588ec5d5..6960adfd 100644 --- a/src/linac/rfgap/wrap_BaseRfGap.hh +++ b/src/linac/rfgap/wrap_BaseRfGap.hh @@ -1,7 +1,7 @@ #ifndef WRAP_BASE_RF_GAP_H #define WRAP_BASE_RF_GAP_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/linac/rfgap/wrap_BaseRfGap_slow.hh b/src/linac/rfgap/wrap_BaseRfGap_slow.hh index 54b11437..5b2908d6 100644 --- a/src/linac/rfgap/wrap_BaseRfGap_slow.hh +++ b/src/linac/rfgap/wrap_BaseRfGap_slow.hh @@ -1,7 +1,7 @@ #ifndef WRAP_BASE_RF_GAP_SLOW_H #define WRAP_BASE_RF_GAP_SLOW_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/linac/rfgap/wrap_MatrixRfGap.hh b/src/linac/rfgap/wrap_MatrixRfGap.hh index 745dd3f1..8086e6ff 100644 --- a/src/linac/rfgap/wrap_MatrixRfGap.hh +++ b/src/linac/rfgap/wrap_MatrixRfGap.hh @@ -1,7 +1,7 @@ #ifndef WRAP_MATRIX_RF_GAP_H #define WRAP_MATRIX_RF_GAP_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/linac/rfgap/wrap_RfGapTTF.hh b/src/linac/rfgap/wrap_RfGapTTF.hh index 190061d4..41acb227 100644 --- a/src/linac/rfgap/wrap_RfGapTTF.hh +++ b/src/linac/rfgap/wrap_RfGapTTF.hh @@ -1,7 +1,7 @@ #ifndef WRAP_RF_GAP_TTF_H #define WRAP_RF_GAP_TTF_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/linac/rfgap/wrap_RfGapTTF_slow.hh b/src/linac/rfgap/wrap_RfGapTTF_slow.hh index 2c7a6a8f..442e556d 100644 --- a/src/linac/rfgap/wrap_RfGapTTF_slow.hh +++ b/src/linac/rfgap/wrap_RfGapTTF_slow.hh @@ -1,7 +1,7 @@ #ifndef WRAP_RF_GAP_TTF_SLOW_H #define WRAP_RF_GAP_TTF_SLOW_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/linac/rfgap/wrap_RfGapThreePointTTF.hh b/src/linac/rfgap/wrap_RfGapThreePointTTF.hh index 2f9a9611..3e1d3e04 100644 --- a/src/linac/rfgap/wrap_RfGapThreePointTTF.hh +++ b/src/linac/rfgap/wrap_RfGapThreePointTTF.hh @@ -1,7 +1,7 @@ #ifndef WRAP_RF_GAP_THREE_POINT_TTF_H #define WRAP_RF_GAP_THREE_POINT_TTF_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/linac/rfgap/wrap_RfGapThreePointTTF_slow.hh b/src/linac/rfgap/wrap_RfGapThreePointTTF_slow.hh index 62f99b3c..eabae2e4 100644 --- a/src/linac/rfgap/wrap_RfGapThreePointTTF_slow.hh +++ b/src/linac/rfgap/wrap_RfGapThreePointTTF_slow.hh @@ -1,7 +1,7 @@ #ifndef WRAP_RF_GAP_THREE_POINT_TTF_SLOW_H #define WRAP_RF_GAP_THREE_POINT_TTF_SLOW_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/linac/rfgap/wrap_SuperFishFieldSource.hh b/src/linac/rfgap/wrap_SuperFishFieldSource.hh index 474817c6..23b5ba93 100644 --- a/src/linac/rfgap/wrap_SuperFishFieldSource.hh +++ b/src/linac/rfgap/wrap_SuperFishFieldSource.hh @@ -1,7 +1,7 @@ #ifndef WRAP_SUPER_FISH_RF_FIELD_SOURCE_H #define WRAP_SUPER_FISH_RF_FIELD_SOURCE_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/linac/tracking/wrap_linac_tracking.cc b/src/linac/tracking/wrap_linac_tracking.cc index 579d9477..5c54fff1 100644 --- a/src/linac/tracking/wrap_linac_tracking.cc +++ b/src/linac/tracking/wrap_linac_tracking.cc @@ -1,4 +1,4 @@ -#include "Python.h" +#include #include "orbit_mpi.hh" #include "pyORBIT_Object.hh" diff --git a/src/linac/tracking/wrap_linac_tracking.hh b/src/linac/tracking/wrap_linac_tracking.hh index db48ced3..0bbfec87 100644 --- a/src/linac/tracking/wrap_linac_tracking.hh +++ b/src/linac/tracking/wrap_linac_tracking.hh @@ -1,7 +1,7 @@ #ifndef WRAP_LINAC_TRACKING_H #define WRAP_LINAC_TRACKING_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" diff --git a/src/linac/wrap_linacmodule.hh b/src/linac/wrap_linacmodule.hh index 62fd8d56..75b83f66 100644 --- a/src/linac/wrap_linacmodule.hh +++ b/src/linac/wrap_linacmodule.hh @@ -1,7 +1,7 @@ #ifndef WRAP_LINAC_H #define WRAP_LINAC_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/meson.build b/src/meson.build index 84d484f6..e03091ac 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,10 +1,7 @@ -# Add Python installation details python = import('python').find_installation('python3', pure: false) -# Add C++ compiler details cpp = meson.get_compiler('cpp') -# Add -march=native if the compiler supports it if cpp.has_argument('-march=native') add_project_arguments('-march=native', language: 'cpp') endif @@ -14,8 +11,16 @@ dependencies = [] dependencies += python.dependency() dependencies += dependency('fftw3', version: '>= 3.0.0', required: true) -# Detecting if MPICH or OPENMPI are installed and enabling support if present +py_link_args = [] + +if host_machine.system() == 'darwin' + # The unresolved symbols will be resolved once the Python interpreter loads libpyorbit. + # The linker on MacOS is a bit more strict, so we need to explicitly tell it that + # symbols from libpython will be nont resolvable for now. + py_link_args += ['-Wl,-undefined,dynamic_lookup'] +endif +# Detecting if MPICH or OPENMPI are installed and enabling support if present mpi_use = get_option('USE_MPI') use_mpi_flag = '0' @@ -192,11 +197,11 @@ inc = include_directories([ ]) core_lib = library( - 'pyorbit3_core', + 'pyorbit3', sources: sources, include_directories: inc, dependencies: dependencies, - override_options: ['b_lundef=false'], + link_args: py_link_args, install: true, ) @@ -351,6 +356,7 @@ ext_modules = { ), 'bunch': files( 'core/bunch_init.cc', + 'core/type_accessors.cc', 'orbit/wrap_bunch.cc', 'orbit/wrap_syncpart.cc', 'orbit/BunchDiagnostics/wrap_bunch_tune_analysis.cc', @@ -359,6 +365,7 @@ ext_modules = { ), 'spacecharge': files( 'core/spacecharge_init.cc', + 'core/type_accessors.cc', 'spacecharge/wrap_spacecharge.cc', 'spacecharge/wrap_grid1D.cc', 'spacecharge/wrap_grid2D.cc', @@ -385,11 +392,13 @@ ext_modules = { ), 'teapot_base': files( 'core/teapot_base_init.cc', + 'core/type_accessors.cc', 'teapot/wrap_teapotbase.cc', 'teapot/wrap_matrix_generator.cc', ), 'linac': files( 'core/linac_init.cc', + 'core/type_accessors.cc', 'linac/wrap_linacmodule.cc', 'linac/tracking/wrap_linac_tracking.cc', 'linac/rfgap/wrap_BaseRfGap.cc', @@ -403,6 +412,7 @@ ext_modules = { ), 'orbit_utils': files( 'core/utils_init.cc', + 'core/type_accessors.cc', 'utils/wrap_utils.cc', 'utils/matrix/wrap_matrix.cc', 'utils/matrix/wrap_phase_vector.cc', @@ -421,6 +431,7 @@ ext_modules = { ), 'aperture': files( 'core/aperture_init.cc', + 'core/type_accessors.cc', 'orbit/Apertures/wrap_aperture.cc', 'orbit/Apertures/wrap_TAperture.cc', 'orbit/Apertures/wrap_PhaseAperture.cc', @@ -433,10 +444,12 @@ ext_modules = { ), 'foil': files( 'core/foil_init.cc', + 'core/type_accessors.cc', 'orbit/MaterialInteractions/wrap_foil.cc', ), 'field_sources': files( 'core/field_sources_init.cc', + 'core/type_accessors.cc', 'utils/field_sources/wrap_field_sources_module.cc', 'utils/field_sources/wrap_magnetic_field_source_grid3d.cc', 'utils/field_sources/wrap_quad_field_source.cc', @@ -445,6 +458,7 @@ ext_modules = { ), 'rfcavities': files( 'core/rfcavities_init.cc', + 'core/type_accessors.cc', 'orbit/RFCavities/wrap_rfcavities.cc', 'orbit/RFCavities/wrap_Frequency_Cav.cc', 'orbit/RFCavities/wrap_Harmonic_Cav.cc', @@ -453,16 +467,19 @@ ext_modules = { ), 'impedances': files( 'core/impedances_init.cc', + 'core/type_accessors.cc', 'orbit/Impedances/wrap_impedances.cc', 'orbit/Impedances/wrap_LImpedance.cc', 'orbit/Impedances/wrap_TImpedance.cc', ), 'fieldtracker': files( 'core/fieldtracker_init.cc', + 'core/type_accessors.cc', 'orbit/FieldTracker/wrap_fieldtracker.cc', ), 'collimator': files( 'core/collimator_init.cc', + 'core/type_accessors.cc', 'orbit/MaterialInteractions/wrap_collimator.cc', ), 'error_base': files( @@ -476,7 +493,8 @@ foreach name, src_list : ext_modules name, sources: src_list, include_directories: inc, - dependencies: [core_dep], + link_with: core_lib, + dependencies: dependencies, install: true, subdir: 'orbit/core', ) diff --git a/src/mpi/orbit_mpi.hh b/src/mpi/orbit_mpi.hh index bff6ea5d..4b158c56 100644 --- a/src/mpi/orbit_mpi.hh +++ b/src/mpi/orbit_mpi.hh @@ -1,4 +1,4 @@ -#include "Python.h" +#include #ifndef ORBIT_MPI_INCLUDE #define ORBIT_MPI_INCLUDE diff --git a/src/mpi/wrap_mpi_comm.cc b/src/mpi/wrap_mpi_comm.cc index 9e4f98a5..ca27414c 100644 --- a/src/mpi/wrap_mpi_comm.cc +++ b/src/mpi/wrap_mpi_comm.cc @@ -1,16 +1,4 @@ -/////////////////////////////////////////////////////////////////////////// -// -// INCLUDE FILES -// -/////////////////////////////////////////////////////////////////////////// #include "orbit_mpi.hh" - -//this header is from Python package -#include "structmember.h" - -//c++ header for cerr and cout -#include - #include "wrap_mpi_comm.hh" namespace wrap_orbit_mpi_comm{ @@ -20,13 +8,8 @@ namespace wrap_orbit_mpi_comm{ #ifdef __cplusplus extern "C" { #endif - //--------------------------------------------------------- - //Python MPI_Comm class definition - //--------------------------------------------------------- - //constructor for python class wrapping MPI_Comm instance - //It never will be called directly - static PyObject* mpi_comm_new(PyTypeObject *type, PyObject *args, PyObject *kwds) + static PyObject* mpi_comm_new(PyTypeObject *type, PyObject *Py_UNUSED(args), PyObject *Py_UNUSED(kwds)) { pyORBIT_MPI_Comm* self; self = (pyORBIT_MPI_Comm *) type->tp_alloc(type, 0); @@ -34,105 +17,85 @@ extern "C" { return (PyObject *) self; } - //initializator for python MPI_Comm class - //this is implementation of the __init__ method - static int mpi_comm_init(pyORBIT_MPI_Comm *self, PyObject *args, PyObject *kwds){ - if(PyTuple_Size(args) != 0){ - error("MPI_Comm constructor cannot have an input parameter."); - } - return 0; - } - - //feeing the mpi comm in the python MPI_Comm class - static PyObject* mpi_comm_free(PyObject *self, PyObject *args){ - pyORBIT_MPI_Comm* pyMPI_Comm = (pyORBIT_MPI_Comm*) self; + static int mpi_comm_init(pyORBIT_MPI_Comm *Py_UNUSED(self), PyObject *args, PyObject *Py_UNUSED(kwds)){ + if(PyTuple_Size(args) != 0){ + error("MPI_Comm constructor cannot have an input parameter."); + } + return 0; + } + + static PyObject* mpi_comm_free(PyObject *self, PyObject *Py_UNUSED(ignored)){ + pyORBIT_MPI_Comm* pyMPI_Comm = (pyORBIT_MPI_Comm*) self; if(pyMPI_Comm->comm != MPI_COMM_WORLD && pyMPI_Comm->comm != MPI_COMM_SELF){ ORBIT_MPI_Comm_free(&pyMPI_Comm->comm); } pyMPI_Comm->comm = MPI_COMM_WORLD; - Py_INCREF(Py_None); - return Py_None; - } - - //----------------------------------------------------- - //destructor for python MPI_Comm class. - //----------------------------------------------------- - //this is implementation of the __del__ method - static void mpi_comm_del(pyORBIT_MPI_Comm* self){ - //std::cerr<<"The MPI_Comm __del__ has been called!"<comm; if(comm != MPI_COMM_NULL && comm != MPI_COMM_WORLD && comm != MPI_COMM_SELF){ ORBIT_MPI_Comm_free(&comm); } self->ob_base.ob_type->tp_free((PyObject*)self); - } - - // defenition of the methods of the python MPI_Comm wrapper class - // they will be vailable from python level - static PyMethodDef MPI_CommClassMethods[] = { - //{ "test", MPI_Comm_test ,METH_VARARGS,"document string"}, - { "free", mpi_comm_free ,METH_VARARGS,"Free MPI communicator."}, - {NULL} - }; - - // defenition of the memebers of the python MPI_Comm wrapper class - // they will be vailable from python level + } + + static PyMethodDef MPI_CommClassMethods[] = { + { "free", mpi_comm_free ,METH_NOARGS,"Free MPI communicator."}, + {NULL} + }; + static PyMemberDef MPI_CommClassMembers[] = { {NULL} }; - //new python SyncPart wrapper type definition - static PyTypeObject pyORBIT_MPI_Comm_Type = { + PyTypeObject pyORBIT_MPI_Comm_Type = { PyVarObject_HEAD_INIT(NULL, 0) - "MPI_Comm", /*tp_name*/ - sizeof(pyORBIT_MPI_Comm), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor) mpi_comm_del , /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "The MPI_Comm python wrapper", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - MPI_CommClassMethods, /* tp_methods */ - MPI_CommClassMembers, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) mpi_comm_init, /* tp_init */ - 0, /* tp_alloc */ - mpi_comm_new, /* tp_new */ + "MPI_Comm", + sizeof(pyORBIT_MPI_Comm), + 0, + (destructor) mpi_comm_del, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + "The MPI_Comm python wrapper", + 0, + 0, + 0, + 0, + 0, + 0, + MPI_CommClassMethods, + MPI_CommClassMembers, + 0, + 0, + 0, + 0, + 0, + 0, + (initproc) mpi_comm_init, + 0, + mpi_comm_new, }; - //-------------------------------------------------- - //Initialization function of the MPI_Comm class - //It will be called from orbit_mpi wrapper initialization - //-------------------------------------------------- - void init_orbit_mpi_comm(PyObject* module){ + void init_orbit_mpi_comm(PyObject* module){ if (PyType_Ready(&pyORBIT_MPI_Comm_Type) < 0) return; Py_INCREF(&pyORBIT_MPI_Comm_Type); - //we put Py_INCREF(...) because PyModule_AddObject() steal the reference - PyObject * comm_module = PyModule_New("mpi_comm"); PyModule_AddObject(comm_module, "MPI_Comm", (PyObject *)&pyORBIT_MPI_Comm_Type); Py_INCREF(comm_module); @@ -149,16 +112,13 @@ extern "C" { pyMPI_Comm_NULL->comm = MPI_COMM_NULL; Py_INCREF((PyObject *) pyMPI_Comm_NULL); - PyModule_AddObject(comm_module, "MPI_COMM_WORLD", (PyObject *) pyMPI_Comm_WORLD); - PyModule_AddObject(comm_module, "MPI_COMM_SELF", (PyObject *) pyMPI_Comm_SELF); - PyModule_AddObject(comm_module, "MPI_COMM_NULL", (PyObject *) pyMPI_Comm_NULL); + PyModule_AddObject(comm_module, "MPI_COMM_WORLD", (PyObject *) pyMPI_Comm_WORLD); + PyModule_AddObject(comm_module, "MPI_COMM_SELF", (PyObject *) pyMPI_Comm_SELF); + PyModule_AddObject(comm_module, "MPI_COMM_NULL", (PyObject *) pyMPI_Comm_NULL); PyModule_AddObject(module, "mpi_comm", comm_module); } - //----------------------------------------------------------- - //The function that will be exposed as C/C++ API for MPI_Comm - //----------------------------------------------------------- pyORBIT_MPI_Comm* newMPI_Comm(){ pyORBIT_MPI_Comm* pyMPI_Comm = PyObject_New(pyORBIT_MPI_Comm,&pyORBIT_MPI_Comm_Type); pyMPI_Comm->comm = MPI_COMM_WORLD; @@ -170,25 +130,8 @@ extern "C" { Py_DECREF(pyMPI_Comm); } - PyObject* getMPI_CommType(const char* name){ - PyObject* mod = PyImport_ImportModule("orbit.core.orbit_mpi"); - PyObject* mpi_comm_mod = PyObject_GetAttrString(mod,"mpi_comm"); - PyObject* pyType = PyObject_GetAttrString(mpi_comm_mod,name); - Py_DECREF(mpi_comm_mod); - Py_DECREF(mod); - Py_DECREF(pyType); - return pyType; - } - #ifdef __cplusplus } #endif -//end of namespace wrap_orbit_mpi_comm } - -/////////////////////////////////////////////////////////////////////////// -// -// END OF FILE -// -/////////////////////////////////////////////////////////////////////////// diff --git a/src/mpi/wrap_mpi_comm.hh b/src/mpi/wrap_mpi_comm.hh index 9b06b544..7328e210 100644 --- a/src/mpi/wrap_mpi_comm.hh +++ b/src/mpi/wrap_mpi_comm.hh @@ -12,7 +12,7 @@ extern "C" { #endif - namespace wrap_orbit_mpi_comm{ + namespace wrap_orbit_mpi_comm { void init_orbit_mpi_comm(PyObject* module); //The function that will be exposed as C/C++ API for MPI_Comm diff --git a/src/mpi/wrap_orbit_mpi.cc b/src/mpi/wrap_orbit_mpi.cc index f83ff846..658232ed 100644 --- a/src/mpi/wrap_orbit_mpi.cc +++ b/src/mpi/wrap_orbit_mpi.cc @@ -1,5 +1,5 @@ #define PY_SSIZE_T_CLEAN -#include "Python.h" +#include #include "orbit_mpi.hh" #include diff --git a/src/mpi/wrap_orbit_mpi.hh b/src/mpi/wrap_orbit_mpi.hh index 2f4cc15f..16d769ed 100644 --- a/src/mpi/wrap_orbit_mpi.hh +++ b/src/mpi/wrap_orbit_mpi.hh @@ -1,3 +1,5 @@ +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/orbit/Apertures/wrap_BaseAperture.hh b/src/orbit/Apertures/wrap_BaseAperture.hh index bd6d0c13..6df9220e 100644 --- a/src/orbit/Apertures/wrap_BaseAperture.hh +++ b/src/orbit/Apertures/wrap_BaseAperture.hh @@ -1,7 +1,7 @@ #ifndef WRAP_ORBIT_BASE_APERTURE_HH_ #define WRAP_ORBIT_BASE_APERTURE_HH_ -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/orbit/Apertures/wrap_CompositeApertureShape.hh b/src/orbit/Apertures/wrap_CompositeApertureShape.hh index a2a4c165..63d46246 100644 --- a/src/orbit/Apertures/wrap_CompositeApertureShape.hh +++ b/src/orbit/Apertures/wrap_CompositeApertureShape.hh @@ -1,7 +1,7 @@ #ifndef WRAP_ORBIT_COMPOSITE_APERTURE_SHAPE_HH_ #define WRAP_ORBIT_COMPOSITE_APERTURE_SHAPE_HH_ -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/orbit/Apertures/wrap_ConvexApertureShape.hh b/src/orbit/Apertures/wrap_ConvexApertureShape.hh index 92a67841..b4e9cfa9 100644 --- a/src/orbit/Apertures/wrap_ConvexApertureShape.hh +++ b/src/orbit/Apertures/wrap_ConvexApertureShape.hh @@ -1,7 +1,7 @@ #ifndef WRAP_ORBIT_CONVEX_APERTURE_SHAPE_HH_ #define WRAP_ORBIT_CONVEX_APERTURE_SHAPE_HH_ -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/orbit/Apertures/wrap_EnergyAperture.hh b/src/orbit/Apertures/wrap_EnergyAperture.hh index b022d90e..acf0525d 100644 --- a/src/orbit/Apertures/wrap_EnergyAperture.hh +++ b/src/orbit/Apertures/wrap_EnergyAperture.hh @@ -1,7 +1,7 @@ #ifndef WRAP_ORBIT_ENERGY_APERTURE_HH_ #define WRAP_ORBIT_ENERGY_APERTURE_HH_ -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/orbit/Apertures/wrap_PhaseAperture.hh b/src/orbit/Apertures/wrap_PhaseAperture.hh index 921b1e27..e438bb4f 100644 --- a/src/orbit/Apertures/wrap_PhaseAperture.hh +++ b/src/orbit/Apertures/wrap_PhaseAperture.hh @@ -1,7 +1,7 @@ #ifndef WRAP_ORBIT_PHASE_APERTURE_HH_ #define WRAP_ORBIT_PHASE_APERTURE_HH_ -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/orbit/Apertures/wrap_PrimitiveApertureShape.hh b/src/orbit/Apertures/wrap_PrimitiveApertureShape.hh index 627dd19b..45fc9b77 100644 --- a/src/orbit/Apertures/wrap_PrimitiveApertureShape.hh +++ b/src/orbit/Apertures/wrap_PrimitiveApertureShape.hh @@ -1,7 +1,7 @@ #ifndef WRAP_ORBIT_PRIMITIVE_APERTURE_SHAPE_HH_ #define WRAP_ORBIT_PRIMITIVE_APERTURE_SHAPE_HH_ -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/orbit/Apertures/wrap_PyBaseApertureShape.hh b/src/orbit/Apertures/wrap_PyBaseApertureShape.hh index 41299cc5..46527930 100644 --- a/src/orbit/Apertures/wrap_PyBaseApertureShape.hh +++ b/src/orbit/Apertures/wrap_PyBaseApertureShape.hh @@ -1,7 +1,7 @@ #ifndef WRAP_ORBIT_PY_BASE_APERTURE_SHAPE_HH_ #define WRAP_ORBIT_PY_BASE_APERTURE_SHAPE_HH_ -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/orbit/Apertures/wrap_TAperture.hh b/src/orbit/Apertures/wrap_TAperture.hh index 4d49cf5e..b028e599 100644 --- a/src/orbit/Apertures/wrap_TAperture.hh +++ b/src/orbit/Apertures/wrap_TAperture.hh @@ -1,7 +1,7 @@ #ifndef WRAP_ORBIT_APERTURE_HH_ #define WRAP_ORBIT_APERTURE_HH_ -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/orbit/Apertures/wrap_aperture.hh b/src/orbit/Apertures/wrap_aperture.hh index 6de0fef3..81609f59 100644 --- a/src/orbit/Apertures/wrap_aperture.hh +++ b/src/orbit/Apertures/wrap_aperture.hh @@ -1,7 +1,7 @@ #ifndef WRAP_ORBIT_APERTURE_MODULE_HH_ #define WRAP_ORBIT_APERTURE_MODULE_HH_ -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/orbit/Bunch.cc b/src/orbit/Bunch.cc index 8a2a2714..08c32684 100644 --- a/src/orbit/Bunch.cc +++ b/src/orbit/Bunch.cc @@ -56,15 +56,15 @@ Bunch::Bunch(): CppPyWrapper(NULL) } //for MPI - pyComm_Local = wrap_orbit_mpi_comm::newMPI_Comm(); + comm_ = MPI_COMM_WORLD; rank_MPI = 0; size_MPI = 1; iMPIini = 0; ORBIT_MPI_Initialized(&iMPIini); if(iMPIini > 0){ - ORBIT_MPI_Comm_size(pyComm_Local->comm, &size_MPI); - ORBIT_MPI_Comm_rank(pyComm_Local->comm, &rank_MPI); + ORBIT_MPI_Comm_size(comm_, &size_MPI); + ORBIT_MPI_Comm_rank(comm_, &rank_MPI); } //data members related to the ParticleAttributes @@ -103,8 +103,7 @@ Bunch::~Bunch() //delete synchronous particle instance delete syncPart; - //delete the python instance of the mpi communicator - wrap_orbit_mpi_comm::freeMPI_Comm(this->pyComm_Local); + //MPI communicator is handled by the caller; no cleanup needed } AttributesBucket* Bunch::getBunchAttributes(){ @@ -209,7 +208,7 @@ void Bunch::initBunchAttributes(const char* fileName){ } if(size_MPI > 1){ - ORBIT_MPI_Bcast (&error_ind,1, MPI_INT, 0, pyComm_Local->comm ); + ORBIT_MPI_Bcast (&error_ind,1, MPI_INT, 0, comm_ ); } if(error_ind > 0){ @@ -249,18 +248,18 @@ void Bunch::initBunchAttributes(const char* fileName){ if(size_MPI > 1){ - ORBIT_MPI_Bcast (&stop_ind,1, MPI_INT, 0, pyComm_Local->comm ); - ORBIT_MPI_Bcast (&def_found_ind,1, MPI_INT, 0, pyComm_Local->comm ); + ORBIT_MPI_Bcast (&stop_ind,1, MPI_INT, 0, comm_ ); + ORBIT_MPI_Bcast (&def_found_ind,1, MPI_INT, 0, comm_ ); } if(stop_ind == 0 && def_found_ind == 1){ if(size_MPI > 1){ int strLength = strlen(str.c_str()); - ORBIT_MPI_Bcast ( &strLength,1, MPI_INT, 0, pyComm_Local->comm ); + ORBIT_MPI_Bcast ( &strLength,1, MPI_INT, 0, comm_ ); int buff_index = 0; char* char_tmp = BufferStore::getBufferStore()->getFreeCharArr(buff_index,strLength+1); strcpy(char_tmp, str.c_str()); - ORBIT_MPI_Bcast ( char_tmp, strLength+1, MPI_CHAR, 0, pyComm_Local->comm ); + ORBIT_MPI_Bcast ( char_tmp, strLength+1, MPI_CHAR, 0, comm_ ); std::string str_new(char_tmp); BufferStore::getBufferStore()->setUnusedCharArr(buff_index); StringUtils::Tokenize(str_new,v_str); @@ -856,7 +855,7 @@ int Bunch::getSizeGlobal() } else{ ORBIT_MPI_Allreduce(&nSize,&sizeGlobal,1, - MPI_INT,MPI_SUM,pyComm_Local->comm); + MPI_INT,MPI_SUM,comm_); return sizeGlobal; } } @@ -985,7 +984,7 @@ void Bunch::print(std::ostream& Out) if(i==rank_MPI){nSizeArr[i]=nSize;} } ORBIT_MPI_Allreduce(nSizeArr,nSizeArr_MPI,size_MPI, - MPI_INT,MPI_SUM,pyComm_Local->comm); + MPI_INT,MPI_SUM,comm_); //at this point all CPUs know about number of macro-particles on each CPU @@ -1023,11 +1022,11 @@ void Bunch::print(std::ostream& Out) j_count++; } ORBIT_MPI_Send(dump_arr, (nDimAndAttr)*nSizeChank, MPI_DOUBLE, 0, - 1111, pyComm_Local->comm); + 1111, comm_); } if(rank_MPI == 0){ ORBIT_MPI_Recv(dump_arr, (nDimAndAttr)*nSizeChank, MPI_DOUBLE, i, - 1111, pyComm_Local->comm, &statusMPI); + 1111, comm_, &statusMPI); for( int j = 0; j < (j_stop - j_start); j++){ int flg = (int) dump_arr[(nDimAndAttr)*j + 6]; if(flg > 0){ @@ -1124,7 +1123,7 @@ int Bunch::readBunchCoords(const char* fileName, int nParts) } if(size_MPI > 1){ - ORBIT_MPI_Bcast (&error_ind,1, MPI_INT, 0, pyComm_Local->comm ); + ORBIT_MPI_Bcast (&error_ind,1, MPI_INT, 0, comm_ ); } if(error_ind > 0){ @@ -1196,10 +1195,10 @@ int Bunch::readBunchCoords(const char* fileName, int nParts) } if(size_MPI > 1){ - ORBIT_MPI_Bcast ( &nT, 1, MPI_INT, 0, pyComm_Local->comm ); - ORBIT_MPI_Bcast ( &error_ind, 1, MPI_INT, 0, pyComm_Local->comm ); - ORBIT_MPI_Bcast ( &nn, 1, MPI_INT, 0, pyComm_Local->comm ); - ORBIT_MPI_Bcast ( arr_0, chunk_size*(nDimAndAttr) , MPI_DOUBLE, 0, pyComm_Local->comm ); + ORBIT_MPI_Bcast ( &nT, 1, MPI_INT, 0, comm_ ); + ORBIT_MPI_Bcast ( &error_ind, 1, MPI_INT, 0, comm_ ); + ORBIT_MPI_Bcast ( &nn, 1, MPI_INT, 0, comm_ ); + ORBIT_MPI_Bcast ( arr_0, chunk_size*(nDimAndAttr) , MPI_DOUBLE, 0, comm_ ); } if(error_ind > 0){ @@ -1229,7 +1228,7 @@ int Bunch::readBunchCoords(const char* fileName, int nParts) } if(size_MPI > 1){ - ORBIT_MPI_Bcast ( &info_stop, 1, MPI_INT, 0, pyComm_Local->comm ); + ORBIT_MPI_Bcast ( &info_stop, 1, MPI_INT, 0, comm_ ); } } @@ -1317,7 +1316,7 @@ int Bunch::readParticleAttributesNames(const char* fileName, } if(size_MPI > 1){ - ORBIT_MPI_Bcast (&error_ind,1, MPI_INT, 0, pyComm_Local->comm ); + ORBIT_MPI_Bcast (&error_ind,1, MPI_INT, 0, comm_ ); } if(error_ind > 0){ @@ -1370,8 +1369,8 @@ int Bunch::readParticleAttributesNames(const char* fileName, if(strLength < ln_str) { strLength = ln_str;} } - ORBIT_MPI_Bcast ( &nTypes, 1, MPI_INT, 0, pyComm_Local->comm ); - ORBIT_MPI_Bcast ( &strLength,1, MPI_INT, 0, pyComm_Local->comm ); + ORBIT_MPI_Bcast ( &nTypes, 1, MPI_INT, 0, comm_ ); + ORBIT_MPI_Bcast ( &strLength,1, MPI_INT, 0, comm_ ); if(nTypes == 0) return 0; @@ -1380,8 +1379,8 @@ int Bunch::readParticleAttributesNames(const char* fileName, strcpy(char_tmp, str.c_str()); int ln_str = strlen(str.c_str()); - ORBIT_MPI_Bcast ( &ln_str, 1, MPI_INT, 0, pyComm_Local->comm ); - ORBIT_MPI_Bcast ( char_tmp,ln_str +1, MPI_CHAR, 0, pyComm_Local->comm ); + ORBIT_MPI_Bcast ( &ln_str, 1, MPI_INT, 0, comm_ ); + ORBIT_MPI_Bcast ( char_tmp,ln_str +1, MPI_CHAR, 0, comm_ ); std::string str_new(char_tmp); StringUtils::Tokenize(str_new,v_str); @@ -1393,7 +1392,7 @@ int Bunch::readParticleAttributesNames(const char* fileName, //spreading all attr. dictionaries across all CPUs int nDicts = v_str_part_attr.size(); - ORBIT_MPI_Bcast ( &nDicts, 1, MPI_INT, 0, pyComm_Local->comm ); + ORBIT_MPI_Bcast ( &nDicts, 1, MPI_INT, 0, comm_ ); if(rank_MPI != 0){ v_str_part_attr.clear(); } @@ -1403,8 +1402,8 @@ int Bunch::readParticleAttributesNames(const char* fileName, ln_str = strlen(v_str_part_attr[i].c_str()); strcpy(char_tmp, v_str_part_attr[i].c_str()); } - ORBIT_MPI_Bcast ( &ln_str, 1, MPI_INT, 0, pyComm_Local->comm ); - ORBIT_MPI_Bcast ( char_tmp,ln_str +1, MPI_CHAR, 0, pyComm_Local->comm ); + ORBIT_MPI_Bcast ( &ln_str, 1, MPI_INT, 0, comm_ ); + ORBIT_MPI_Bcast ( char_tmp,ln_str +1, MPI_CHAR, 0, comm_ ); std::string str_tmp(char_tmp); if(rank_MPI != 0){ v_str_part_attr.push_back(str_tmp); @@ -1675,17 +1674,17 @@ void Bunch::restoreAllParticleAttributesFromMemory(){ attrCntrMapTemp.clear(); } -pyORBIT_MPI_Comm* Bunch::getMPI_Comm_Local(){ - return pyComm_Local; +MPI_Comm Bunch::getMPI_Comm_Local() const noexcept { + return comm_; } -void Bunch::setMPI_Comm_Local(pyORBIT_MPI_Comm* pyComm_Local){ - wrap_orbit_mpi_comm::freeMPI_Comm(this->pyComm_Local); - this->pyComm_Local = pyComm_Local; - Py_INCREF((PyObject *) this->pyComm_Local); - if(iMPIini > 0){ - ORBIT_MPI_Comm_size(pyComm_Local->comm, &size_MPI); - ORBIT_MPI_Comm_rank(pyComm_Local->comm, &rank_MPI); +void Bunch::setMPI_Comm_Local(MPI_Comm comm){ + // wrap_orbit_mpi_comm::freeMPI_Comm(comm_); + comm_ = comm; + // Py_INCREF((PyObject *) this->comm_); + if(iMPIini > 0) { + ORBIT_MPI_Comm_size(comm, &size_MPI); + ORBIT_MPI_Comm_rank(comm, &rank_MPI); } } diff --git a/src/orbit/Bunch.hh b/src/orbit/Bunch.hh index 9f525b86..f5cd0a0b 100644 --- a/src/orbit/Bunch.hh +++ b/src/orbit/Bunch.hh @@ -21,15 +21,11 @@ // /////////////////////////////////////////////////////////////////////////// #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include -#include #include -#include #include -#include #include #include @@ -40,8 +36,6 @@ #include "AttributesBucket.hh" #include "CppPyWrapper.hh" -using namespace std; - #ifndef BUNCH_H #define BUNCH_H /////////////////////////////////////////////////////////////////////////// @@ -191,8 +185,8 @@ public: void addParticlesTo(Bunch* bunch); //Parallel case - pyORBIT_MPI_Comm* getMPI_Comm_Local(); - void setMPI_Comm_Local(pyORBIT_MPI_Comm* pyComm_Local); + MPI_Comm getMPI_Comm_Local() const noexcept; + void setMPI_Comm_Local(MPI_Comm comm); int getMPI_Size(); int getMPI_Rank(); @@ -285,10 +279,7 @@ protected: int rank_MPI; int size_MPI; - pyORBIT_MPI_Comm* pyComm_Local; - - //reference to the python wrapping class instance - PyObject* py_wrapper; + MPI_Comm comm_; }; diff --git a/src/orbit/BunchDiagnostics/BunchTwissAnalysis.cc b/src/orbit/BunchDiagnostics/BunchTwissAnalysis.cc index 0a361326..8fea7169 100644 --- a/src/orbit/BunchDiagnostics/BunchTwissAnalysis.cc +++ b/src/orbit/BunchDiagnostics/BunchTwissAnalysis.cc @@ -108,15 +108,15 @@ void BunchTwissAnalysis::analyzeBunch(Bunch* bunch){ } int count_MPI = 0; - ORBIT_MPI_Allreduce(&count,&count_MPI,1,MPI_INT,MPI_SUM,bunch->getMPI_Comm_Local()->comm); + ORBIT_MPI_Allreduce(&count,&count_MPI,1,MPI_INT,MPI_SUM,bunch->getMPI_Comm_Local()); count = count_MPI; double total_macrosize_MPI = 0.; - ORBIT_MPI_Allreduce(&total_macrosize,&total_macrosize_MPI,1,MPI_DOUBLE,MPI_SUM,bunch->getMPI_Comm_Local()->comm); + ORBIT_MPI_Allreduce(&total_macrosize,&total_macrosize_MPI,1,MPI_DOUBLE,MPI_SUM,bunch->getMPI_Comm_Local()); total_macrosize = total_macrosize_MPI; - ORBIT_MPI_Allreduce(avg_arr,avg_arr_MPI,6,MPI_DOUBLE,MPI_SUM,bunch->getMPI_Comm_Local()->comm); - ORBIT_MPI_Allreduce(corr_arr,corr_arr_MPI,36,MPI_DOUBLE,MPI_SUM,bunch->getMPI_Comm_Local()->comm); + ORBIT_MPI_Allreduce(avg_arr,avg_arr_MPI,6,MPI_DOUBLE,MPI_SUM,bunch->getMPI_Comm_Local()); + ORBIT_MPI_Allreduce(corr_arr,corr_arr_MPI,36,MPI_DOUBLE,MPI_SUM,bunch->getMPI_Comm_Local()); if(fabs(total_macrosize) > 0.){ for(int i = 0; i < 6; i++){ @@ -189,11 +189,11 @@ void BunchTwissAnalysis::computeBunchMoments(Bunch* bunch, int order, int disper } - ORBIT_MPI_Allreduce(&total_macrosize,&total_macrosize_MPI,1,MPI_DOUBLE,MPI_SUM,bunch->getMPI_Comm_Local()->comm); + ORBIT_MPI_Allreduce(&total_macrosize,&total_macrosize_MPI,1,MPI_DOUBLE,MPI_SUM,bunch->getMPI_Comm_Local()); total_macrosize = total_macrosize_MPI; double xAvg_MPI = 0; - ORBIT_MPI_Allreduce(&xAvg,&xAvg_MPI,1,MPI_DOUBLE,MPI_SUM,bunch->getMPI_Comm_Local()->comm); + ORBIT_MPI_Allreduce(&xAvg,&xAvg_MPI,1,MPI_DOUBLE,MPI_SUM,bunch->getMPI_Comm_Local()); if(fabs(total_macrosize) > 0.){ xAvg = xAvg_MPI/total_macrosize; } @@ -294,7 +294,7 @@ void BunchTwissAnalysis::computeBunchMoments(Bunch* bunch, int order, int disper } - ORBIT_MPI_Allreduce(&total_macrosize,&total_macrosize_MPI,1,MPI_DOUBLE,MPI_SUM,bunch->getMPI_Comm_Local()->comm); + ORBIT_MPI_Allreduce(&total_macrosize,&total_macrosize_MPI,1,MPI_DOUBLE,MPI_SUM,bunch->getMPI_Comm_Local()); total_macrosize = total_macrosize_MPI; //if( nMPIsize_ > 1){ @@ -310,7 +310,7 @@ void BunchTwissAnalysis::computeBunchMoments(Bunch* bunch, int order, int disper //MPI_Allreduce(buff_0, buff_1, count, MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD); - ORBIT_MPI_Allreduce(buff_0, buff_1, count, MPI_DOUBLE, MPI_SUM, bunch->getMPI_Comm_Local()->comm); + ORBIT_MPI_Allreduce(buff_0, buff_1, count, MPI_DOUBLE, MPI_SUM, bunch->getMPI_Comm_Local()); count = 0; for(j=0; j<_order+1; j++){ diff --git a/src/orbit/BunchDiagnostics/wrap_bunch_tune_analysis.hh b/src/orbit/BunchDiagnostics/wrap_bunch_tune_analysis.hh index 6511745e..460c5504 100644 --- a/src/orbit/BunchDiagnostics/wrap_bunch_tune_analysis.hh +++ b/src/orbit/BunchDiagnostics/wrap_bunch_tune_analysis.hh @@ -1,7 +1,7 @@ #ifndef WRAP_BUNCH_TUNE_ANALYSIS_HH_ #define WRAP_BUNCH_TUNE_ANALYSIS_HH_ -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/orbit/BunchDiagnostics/wrap_bunch_twiss_analysis.hh b/src/orbit/BunchDiagnostics/wrap_bunch_twiss_analysis.hh index 7f01e87d..c2e94d47 100644 --- a/src/orbit/BunchDiagnostics/wrap_bunch_twiss_analysis.hh +++ b/src/orbit/BunchDiagnostics/wrap_bunch_twiss_analysis.hh @@ -1,7 +1,7 @@ #ifndef WRAP_BUNCH_TWISS_ANALYSIS_HH_ #define WRAP_BUNCH_TWISS_ANALYSIS_HH_ -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/orbit/Errors/wrap_errorbase.cc b/src/orbit/Errors/wrap_errorbase.cc index 82494511..186d5e8c 100644 --- a/src/orbit/Errors/wrap_errorbase.cc +++ b/src/orbit/Errors/wrap_errorbase.cc @@ -1,4 +1,4 @@ -#include "Python.h" +#include #include "orbit_mpi.hh" #include "pyORBIT_Object.hh" diff --git a/src/orbit/FieldTracker/wrap_fieldtracker.hh b/src/orbit/FieldTracker/wrap_fieldtracker.hh index c981ff1b..036086f4 100644 --- a/src/orbit/FieldTracker/wrap_fieldtracker.hh +++ b/src/orbit/FieldTracker/wrap_fieldtracker.hh @@ -1,7 +1,7 @@ #ifndef WRAP_ORBIT_FIELDTRACKER_HH_ #define WRAP_ORBIT_FIELDTRACKER_HH_ -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/orbit/Impedances/wrap_LImpedance.hh b/src/orbit/Impedances/wrap_LImpedance.hh index d2936333..5ffebd3d 100644 --- a/src/orbit/Impedances/wrap_LImpedance.hh +++ b/src/orbit/Impedances/wrap_LImpedance.hh @@ -1,7 +1,7 @@ #ifndef WRAP_LIMPEDANCE_H #define WRAP_LIMPEDANCE_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" diff --git a/src/orbit/Impedances/wrap_TImpedance.hh b/src/orbit/Impedances/wrap_TImpedance.hh index d001bb24..ffca3037 100644 --- a/src/orbit/Impedances/wrap_TImpedance.hh +++ b/src/orbit/Impedances/wrap_TImpedance.hh @@ -1,7 +1,7 @@ #ifndef WRAP_TIMPEDANCE_H #define WRAP_TIMPEDANCE_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" diff --git a/src/orbit/Impedances/wrap_impedances.hh b/src/orbit/Impedances/wrap_impedances.hh index c6270c41..cef05bc4 100644 --- a/src/orbit/Impedances/wrap_impedances.hh +++ b/src/orbit/Impedances/wrap_impedances.hh @@ -1,7 +1,7 @@ #ifndef WRAP_IMPEDANCES_H #define WRAP_IMPEDANCES_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" diff --git a/src/orbit/MaterialInteractions/wrap_collimator.hh b/src/orbit/MaterialInteractions/wrap_collimator.hh index 278e7b70..5f3069a0 100644 --- a/src/orbit/MaterialInteractions/wrap_collimator.hh +++ b/src/orbit/MaterialInteractions/wrap_collimator.hh @@ -1,7 +1,7 @@ #ifndef WRAP_ORBIT_COLLIMATOR_HH_ #define WRAP_ORBIT_COLLIMATOR_HH_ -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/orbit/MaterialInteractions/wrap_foil.hh b/src/orbit/MaterialInteractions/wrap_foil.hh index eafb1808..7f9b35e7 100644 --- a/src/orbit/MaterialInteractions/wrap_foil.hh +++ b/src/orbit/MaterialInteractions/wrap_foil.hh @@ -1,7 +1,7 @@ #ifndef WRAP_ORBIT_FOIL_HH_ #define WRAP_ORBIT_FOIL_HH_ -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/orbit/ParticlesAttributes/ParticleAttributesFactory.cc b/src/orbit/ParticlesAttributes/ParticleAttributesFactory.cc index 6f2c9d9d..7939b3b1 100644 --- a/src/orbit/ParticlesAttributes/ParticleAttributesFactory.cc +++ b/src/orbit/ParticlesAttributes/ParticleAttributesFactory.cc @@ -46,7 +46,7 @@ ParticleAttributes* ParticleAttributesFactory::getParticleAttributesInstance( int rank_MPI = 0; int size_MPI = 1; int iMPIini = 0; - MPI_Comm MPI_COMM_Local = bunch->getMPI_Comm_Local()->comm; + MPI_Comm MPI_COMM_Local = bunch->getMPI_Comm_Local(); ORBIT_MPI_Initialized(&iMPIini); if(iMPIini > 0){ diff --git a/src/orbit/RFCavities/wrap_Barrier_Cav.hh b/src/orbit/RFCavities/wrap_Barrier_Cav.hh index ccb7d80d..13b6760f 100644 --- a/src/orbit/RFCavities/wrap_Barrier_Cav.hh +++ b/src/orbit/RFCavities/wrap_Barrier_Cav.hh @@ -1,7 +1,7 @@ #ifndef WRAP_BARRIER_CAV_H #define WRAP_BARRIER_CAV_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" diff --git a/src/orbit/RFCavities/wrap_Dual_Harmonic_Cav.hh b/src/orbit/RFCavities/wrap_Dual_Harmonic_Cav.hh index d12449e6..5b6f969a 100644 --- a/src/orbit/RFCavities/wrap_Dual_Harmonic_Cav.hh +++ b/src/orbit/RFCavities/wrap_Dual_Harmonic_Cav.hh @@ -1,7 +1,7 @@ #ifndef WRAP_Dual_Harmonic_Cav_H #define WRAP_Dual_Harmonic_Cav_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" diff --git a/src/orbit/RFCavities/wrap_Frequency_Cav.hh b/src/orbit/RFCavities/wrap_Frequency_Cav.hh index c2e8333d..e3311012 100644 --- a/src/orbit/RFCavities/wrap_Frequency_Cav.hh +++ b/src/orbit/RFCavities/wrap_Frequency_Cav.hh @@ -1,7 +1,7 @@ #ifndef WRAP_FREQUENCY_CAV_H #define WRAP_FREQUENCY_CAV_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" diff --git a/src/orbit/RFCavities/wrap_Harmonic_Cav.hh b/src/orbit/RFCavities/wrap_Harmonic_Cav.hh index 63710662..5b686371 100644 --- a/src/orbit/RFCavities/wrap_Harmonic_Cav.hh +++ b/src/orbit/RFCavities/wrap_Harmonic_Cav.hh @@ -1,7 +1,7 @@ #ifndef WRAP_HARMONIC_CAV_H #define WRAP_HARMONIC_CAV_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" diff --git a/src/orbit/RFCavities/wrap_rfcavities.hh b/src/orbit/RFCavities/wrap_rfcavities.hh index 1a327081..cecebb20 100644 --- a/src/orbit/RFCavities/wrap_rfcavities.hh +++ b/src/orbit/RFCavities/wrap_rfcavities.hh @@ -1,7 +1,7 @@ #ifndef WRAP_RFCAVITIES_H #define WRAP_RFCAVITIES_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" diff --git a/src/orbit/SyncPart.cc b/src/orbit/SyncPart.cc index 6494ecbf..216fa23c 100644 --- a/src/orbit/SyncPart.cc +++ b/src/orbit/SyncPart.cc @@ -24,7 +24,7 @@ // INCLUDE FILES // /////////////////////////////////////////////////////////////////////////// -#include "Python.h" +#include #include "SyncPart.hh" @@ -326,7 +326,7 @@ void SyncPart::readSyncPart(const char* fileName){ int rank_MPI = 0; int size_MPI = 1; int iMPIini = 0; - MPI_Comm MPI_COMM_Local = bunch->getMPI_Comm_Local()->comm; + MPI_Comm MPI_COMM_Local = bunch->getMPI_Comm_Local(); ORBIT_MPI_Initialized(&iMPIini); if(iMPIini > 0){ @@ -469,7 +469,7 @@ void SyncPart::print(std::ostream& Out) int rank_MPI = 0; int size_MPI = 1; int iMPIini = 0; - MPI_Comm MPI_COMM_Local = bunch->getMPI_Comm_Local()->comm; + MPI_Comm MPI_COMM_Local = bunch->getMPI_Comm_Local(); ORBIT_MPI_Initialized(&iMPIini); if(iMPIini > 0){ diff --git a/src/orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.cc b/src/orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.cc index 22021ae7..2bd4c3f7 100644 --- a/src/orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.cc +++ b/src/orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.cc @@ -70,14 +70,14 @@ void SynchPartRedefinitionZdE::analyzeBunch(Bunch* bunch){ } int count_MPI = 0; - ORBIT_MPI_Allreduce(&count,&count_MPI,1,MPI_INT,MPI_SUM,bunch->getMPI_Comm_Local()->comm); + ORBIT_MPI_Allreduce(&count,&count_MPI,1,MPI_INT,MPI_SUM,bunch->getMPI_Comm_Local()); count = count_MPI; double total_macrosize_MPI = 0.; - ORBIT_MPI_Allreduce(&total_macrosize,&total_macrosize_MPI,1,MPI_DOUBLE,MPI_SUM,bunch->getMPI_Comm_Local()->comm); + ORBIT_MPI_Allreduce(&total_macrosize,&total_macrosize_MPI,1,MPI_DOUBLE,MPI_SUM,bunch->getMPI_Comm_Local()); total_macrosize = total_macrosize_MPI; - ORBIT_MPI_Allreduce(z_dE_avg_arr,z_dE_avg_arr_MPI,2,MPI_DOUBLE,MPI_SUM,bunch->getMPI_Comm_Local()->comm); + ORBIT_MPI_Allreduce(z_dE_avg_arr,z_dE_avg_arr_MPI,2,MPI_DOUBLE,MPI_SUM,bunch->getMPI_Comm_Local()); if(fabs(total_macrosize) > 0.){ for(int i = 0; i < 2; i++){ diff --git a/src/orbit/SynchPartRedefinition/wrap_synch_part_redefinition_z_de.hh b/src/orbit/SynchPartRedefinition/wrap_synch_part_redefinition_z_de.hh index ef7ace81..2df15fb3 100644 --- a/src/orbit/SynchPartRedefinition/wrap_synch_part_redefinition_z_de.hh +++ b/src/orbit/SynchPartRedefinition/wrap_synch_part_redefinition_z_de.hh @@ -1,7 +1,7 @@ #ifndef WRAP_SYNCH_PARTICLE_REDEFINITION_HH_ #define WRAP_SYNCH_PARTICLE_REDEFINITION_HH_ -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/orbit/wrap_bunch.cc b/src/orbit/wrap_bunch.cc index 8bda038d..57b6769a 100644 --- a/src/orbit/wrap_bunch.cc +++ b/src/orbit/wrap_bunch.cc @@ -9,6 +9,7 @@ // /////////////////////////////////////////////////////////////////////////// #include "wrap_bunch.hh" +#include "wrap_mpi_comm.hh" #include "wrap_syncpart.hh" #include "wrap_bunch_twiss_analysis.hh" #include "wrap_bunch_tune_analysis.hh" @@ -28,7 +29,7 @@ namespace wrap_orbit_bunch{ //constructor for python class wrapping Bunch instance //It never will be called directly - static PyObject* Bunch_new(PyTypeObject *type, PyObject *args, PyObject *kwds){ + static PyObject* Bunch_new(PyTypeObject *type, PyObject *Py_UNUSED(args), PyObject *Py_UNUSED(kwds)) { pyORBIT_Object* self; self = (pyORBIT_Object *) type->tp_alloc(type, 0); self->cpp_obj = NULL; @@ -37,7 +38,7 @@ namespace wrap_orbit_bunch{ //initializator for python Bunch class //this is implementation of the __init__ method - static int Bunch_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ + static int Bunch_init(pyORBIT_Object *self, PyObject *Py_UNUSED(args), PyObject *Py_UNUSED(kwds)){ //std::cerr<<"The Bunch __init__ has been called!"<cpp_obj = (void*) new Bunch(); @@ -62,7 +63,7 @@ namespace wrap_orbit_bunch{ //---------------------------------------------------------------- //returns the SyncPart python class wrapper instance - static PyObject* Bunch_getSyncParticle(PyObject *self, PyObject *args){ + static PyObject* Bunch_getSyncParticle(PyObject *self, PyObject *Py_UNUSED(ignored)){ Bunch* cpp_bunch = (Bunch*) ((pyORBIT_Object *) self)->cpp_obj; PyObject* pySyncPart = cpp_bunch->getSyncPart()->getPyWrapper(); Py_INCREF(pySyncPart); @@ -76,29 +77,34 @@ namespace wrap_orbit_bunch{ //---------------------------------------------------------------- //returns the local MPI Comm for this bunch - static PyObject* Bunch_getMPIComm(PyObject *self, PyObject *args){ + static PyObject* Bunch_getMPIComm(PyObject *self, PyObject *Py_UNUSED(ignored)) { Bunch* cpp_bunch = (Bunch*) ((pyORBIT_Object *) self)->cpp_obj; - PyObject* pyMPIComm = (PyObject*) cpp_bunch->getMPI_Comm_Local(); - Py_INCREF(pyMPIComm); - return pyMPIComm; + + PyObject* mpi_comm_type = wrap_orbit_mpi_comm::getMPI_CommType("MPI_Comm"); + PyObject* pyComm = PyObject_CallFunction(mpi_comm_type, NULL); + if (pyComm == NULL) { + return NULL; + } + + ((pyORBIT_MPI_Comm*)pyComm)->comm = cpp_bunch->getMPI_Comm_Local(); + + return pyComm; } - //sets a new local MPI Comm for this bunch - static PyObject* Bunch_setMPIComm(PyObject *self, PyObject *args){ - Bunch* cpp_bunch = (Bunch*) ((pyORBIT_Object *) self)->cpp_obj; - int nVars = PyTuple_Size(args); - PyObject* pyMPIComm; - if(nVars == 1){ - if(!PyArg_ParseTuple(args,"O:setMPIComm",&pyMPIComm)){ - error("The Bunch method setMPIComm(mpi_comm) - mpi_comm is needed."); - } - cpp_bunch->setMPI_Comm_Local( (pyORBIT_MPI_Comm*) pyMPIComm); - } - else{ - error("The Bunch method should be setMPIComm(mpi_comm)."); - } - Py_INCREF(Py_None); - return Py_None; + //sets a new local MPI Comm for this bunch + static PyObject* Bunch_setMPIComm(PyObject *self, PyObject *arg) { + Bunch* cpp_bunch = (Bunch*) ((pyORBIT_Object *) self)->cpp_obj; + + PyObject* mpi_comm_type = wrap_orbit_mpi_comm::getMPI_CommType("MPI_Comm"); + if (!PyObject_TypeCheck(arg, (PyTypeObject*)mpi_comm_type)) { + PyErr_SetString(PyExc_TypeError, "expected an MPI_Comm object"); + return NULL; + } + + pyORBIT_MPI_Comm *pyComm = (pyORBIT_MPI_Comm*)arg; + cpp_bunch->setMPI_Comm_Local(pyComm->comm); + + Py_RETURN_NONE; } //--------------------------------------------------------------- @@ -1188,9 +1194,9 @@ namespace wrap_orbit_bunch{ //-------------------------------------------------------- // class Bunch wrapper START //-------------------------------------------------------- - { "getMPIComm", Bunch_getMPIComm ,METH_VARARGS,"Returns MPI Comm of this bunch"}, - { "setMPIComm", Bunch_setMPIComm ,METH_VARARGS,"Sets a new MPI Comm for this bunch"}, - { "getSyncParticle", Bunch_getSyncParticle ,METH_VARARGS,"Returns syncParticle class instance"}, + { "getMPIComm", Bunch_getMPIComm ,METH_NOARGS,"Returns MPI Comm of this bunch"}, + { "setMPIComm", Bunch_setMPIComm ,METH_O,"Sets a new MPI Comm for this bunch"}, + { "getSyncParticle", Bunch_getSyncParticle ,METH_NOARGS,"Returns syncParticle class instance"}, { "addParticle", Bunch_addParticle ,METH_VARARGS,"Adds a macro-particle to the bunch"}, { "deleteParticle", Bunch_deleteParticle ,METH_VARARGS,"Removes macro-particle from the bunch and call compress inside"}, { "deleteParticleFast", Bunch_deleteParticleFast ,METH_VARARGS,"Removes macro-particle from the bunch very fast"}, @@ -1328,15 +1334,6 @@ extern "C" { return module; } - PyObject* getBunchType(const char* name){ - PyObject* mod = PyImport_ImportModule("orbit.core.bunch"); - PyObject* pyType = PyObject_GetAttrString(mod,name); - Py_DECREF(mod); - Py_DECREF(pyType); - return pyType; - } - - #ifdef __cplusplus } #endif diff --git a/src/orbit/wrap_bunch.hh b/src/orbit/wrap_bunch.hh index f096625c..1157f294 100644 --- a/src/orbit/wrap_bunch.hh +++ b/src/orbit/wrap_bunch.hh @@ -16,7 +16,7 @@ // INCLUDE FILES // /////////////////////////////////////////////////////////////////////////// -#include "Python.h" +#include #ifdef __cplusplus extern "C" { @@ -25,7 +25,7 @@ extern "C" { namespace wrap_orbit_bunch{ /* The name of the function was changed to avoid collision with PyImport magic naming */ PyMODINIT_FUNC initbunch(void); - PyObject* getBunchType(const char* name); + PyObject* getBunchType(const char* name); } #ifdef __cplusplus diff --git a/src/orbit/wrap_syncpart.hh b/src/orbit/wrap_syncpart.hh index 01770894..af1c37d6 100644 --- a/src/orbit/wrap_syncpart.hh +++ b/src/orbit/wrap_syncpart.hh @@ -11,7 +11,7 @@ // INCLUDE FILES // /////////////////////////////////////////////////////////////////////////// -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/spacecharge/Grid1D.cc b/src/spacecharge/Grid1D.cc index 36caeb54..e3259e26 100644 --- a/src/spacecharge/Grid1D.cc +++ b/src/spacecharge/Grid1D.cc @@ -759,7 +759,7 @@ void Grid1D::getBinIndAndWZSmoothed(double z, } /** synchronizeMPI */ -void Grid1D::synchronizeMPI(pyORBIT_MPI_Comm* pyComm) +void Grid1D::synchronizeMPI(MPI_Comm comm) { // ====== MPI start ======== @@ -776,7 +776,7 @@ void Grid1D::synchronizeMPI(pyORBIT_MPI_Comm* pyComm) inArr[i] = arr_[i]; } - if(pyComm == NULL) + if(comm == MPI_COMM_NULL) { ORBIT_MPI_Allreduce(inArr, outArr, size_MPI, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); @@ -784,7 +784,7 @@ void Grid1D::synchronizeMPI(pyORBIT_MPI_Comm* pyComm) else { ORBIT_MPI_Allreduce(inArr, outArr, size_MPI, - MPI_DOUBLE, MPI_SUM, pyComm->comm); + MPI_DOUBLE, MPI_SUM, comm); } for(int i = 0; i < zSize_; i++) diff --git a/src/spacecharge/Grid1D.hh b/src/spacecharge/Grid1D.hh index 18b292e5..2b096cd3 100644 --- a/src/spacecharge/Grid1D.hh +++ b/src/spacecharge/Grid1D.hh @@ -3,7 +3,6 @@ // MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include #include @@ -135,7 +134,7 @@ public: void calcGradientSmoothed(double z, double& ez); /** synchronizeMPI */ - void synchronizeMPI(pyORBIT_MPI_Comm* comm); + void synchronizeMPI(MPI_Comm comm); private: diff --git a/src/spacecharge/Grid2D.cc b/src/spacecharge/Grid2D.cc index c3c324c1..78f9c399 100644 --- a/src/spacecharge/Grid2D.cc +++ b/src/spacecharge/Grid2D.cc @@ -440,7 +440,7 @@ int Grid2D::isInside(double x,double y){ } /**synchronizeMPI */ -void Grid2D::synchronizeMPI(pyORBIT_MPI_Comm* pyComm){ +void Grid2D::synchronizeMPI(MPI_Comm comm){ // ====== MPI start ======== int size_MPI = xSize_ * ySize_; int buff_index0 = 0; @@ -456,10 +456,10 @@ void Grid2D::synchronizeMPI(pyORBIT_MPI_Comm* pyComm){ } } - if(pyComm == NULL) { + if(comm == MPI_COMM_NULL) { ORBIT_MPI_Allreduce(inArr,outArr,size_MPI,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD); } else { - ORBIT_MPI_Allreduce(inArr,outArr,size_MPI,MPI_DOUBLE,MPI_SUM,pyComm->comm); + ORBIT_MPI_Allreduce(inArr,outArr,size_MPI,MPI_DOUBLE,MPI_SUM,comm); } count = 0; diff --git a/src/spacecharge/Grid2D.hh b/src/spacecharge/Grid2D.hh index 419be46d..30b0bdfe 100644 --- a/src/spacecharge/Grid2D.hh +++ b/src/spacecharge/Grid2D.hh @@ -5,7 +5,6 @@ //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include #include @@ -93,7 +92,7 @@ public: int getSizeY(); /** synchronizeMPI */ - void synchronizeMPI(pyORBIT_MPI_Comm* comm); + void synchronizeMPI(MPI_Comm comm); /** Returns 1 if (x,y) is inside the grid region, and 0 otherwise */ int isInside(double x,double y); diff --git a/src/spacecharge/Grid3D.cc b/src/spacecharge/Grid3D.cc index 401b34e2..84a95556 100644 --- a/src/spacecharge/Grid3D.cc +++ b/src/spacecharge/Grid3D.cc @@ -809,7 +809,7 @@ double Grid3D::calcSheetGradient(int iZ,int iX,int iY, } /**synchronize MPI */ -void Grid3D::synchronizeMPI(pyORBIT_MPI_Comm* pyComm){ +void Grid3D::synchronizeMPI(MPI_Comm pyComm){ // ====== MPI start ======== int size_MPI = nX_ * nY_*nZ_; int buff_index0 = 0; @@ -827,10 +827,10 @@ void Grid3D::synchronizeMPI(pyORBIT_MPI_Comm* pyComm){ } } - if(pyComm == NULL) { + if(pyComm == MPI_COMM_NULL) { ORBIT_MPI_Allreduce(inArr,outArr,size_MPI,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD); } else { - ORBIT_MPI_Allreduce(inArr,outArr,size_MPI,MPI_DOUBLE,MPI_SUM,pyComm->comm); + ORBIT_MPI_Allreduce(inArr,outArr,size_MPI,MPI_DOUBLE,MPI_SUM,pyComm); } count = 0; diff --git a/src/spacecharge/Grid3D.hh b/src/spacecharge/Grid3D.hh index fa15ebad..57d3fb2f 100644 --- a/src/spacecharge/Grid3D.hh +++ b/src/spacecharge/Grid3D.hh @@ -18,7 +18,6 @@ //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" //ORBIT bunch #include "Bunch.hh" @@ -175,7 +174,7 @@ public: double getSliceSum(double z); /** synchronize MPI */ - void synchronizeMPI(pyORBIT_MPI_Comm* pyComm); + void synchronizeMPI(MPI_Comm pyComm); protected: //--------------------------------------- diff --git a/src/spacecharge/SpaceChargeCalcUnifEllipse.cc b/src/spacecharge/SpaceChargeCalcUnifEllipse.cc index 250ee81b..83af0bbc 100644 --- a/src/spacecharge/SpaceChargeCalcUnifEllipse.cc +++ b/src/spacecharge/SpaceChargeCalcUnifEllipse.cc @@ -143,7 +143,7 @@ void SpaceChargeCalcUnifEllipse::bunchAnalysis(Bunch* bunch){ } //calculates sum over all CPUs - ORBIT_MPI_Allreduce(coord_avg,coord_avg_out,7,MPI_DOUBLE,MPI_SUM,bunch->getMPI_Comm_Local()->comm); + ORBIT_MPI_Allreduce(coord_avg,coord_avg_out,7,MPI_DOUBLE,MPI_SUM,bunch->getMPI_Comm_Local()); total_macrosize = coord_avg_out[6]; if(total_macrosize == 0.){ @@ -233,7 +233,7 @@ void SpaceChargeCalcUnifEllipse::bunchAnalysis(Bunch* bunch){ } } //calculates sum over all CPUs - ORBIT_MPI_Allreduce(macroSizesEll_arr,macroSizesEll_MPI_arr,nEllipses,MPI_DOUBLE,MPI_SUM,bunch->getMPI_Comm_Local()->comm); + ORBIT_MPI_Allreduce(macroSizesEll_arr,macroSizesEll_MPI_arr,nEllipses,MPI_DOUBLE,MPI_SUM,bunch->getMPI_Comm_Local()); for(int ie = 0; ie < nEllipses; ie++){ macroSizesEll_arr[ie] = macroSizesEll_MPI_arr[ie]; //std::cout<<"debug 0 ie ="<< ie <<" macrosize="<< macroSizesEll_MPI_arr[ie] << std::endl; diff --git a/src/spacecharge/SpaceChargeCalcUnifEllipse.hh b/src/spacecharge/SpaceChargeCalcUnifEllipse.hh index d88f9ba3..246cb936 100644 --- a/src/spacecharge/SpaceChargeCalcUnifEllipse.hh +++ b/src/spacecharge/SpaceChargeCalcUnifEllipse.hh @@ -9,7 +9,6 @@ //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include #include diff --git a/src/spacecharge/wrap_boundary2d.hh b/src/spacecharge/wrap_boundary2d.hh index 7a5c6904..1a7eaa0f 100644 --- a/src/spacecharge/wrap_boundary2d.hh +++ b/src/spacecharge/wrap_boundary2d.hh @@ -1,7 +1,7 @@ #ifndef WRAP_BOUNDARY_2D_H #define WRAP_BOUNDARY_2D_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/spacecharge/wrap_forcesolverfft2d.hh b/src/spacecharge/wrap_forcesolverfft2d.hh index 85d52b56..787251b9 100644 --- a/src/spacecharge/wrap_forcesolverfft2d.hh +++ b/src/spacecharge/wrap_forcesolverfft2d.hh @@ -1,7 +1,7 @@ #ifndef WRAP_SPACE_CHARGE_FORCE_SOLVER_FFT_2D_H #define WRAP_SPACE_CHARGE_FORCE_SOLVER_FFT_2D_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/spacecharge/wrap_grid1D.cc b/src/spacecharge/wrap_grid1D.cc index a194ae7c..a83c5f81 100644 --- a/src/spacecharge/wrap_grid1D.cc +++ b/src/spacecharge/wrap_grid1D.cc @@ -445,7 +445,7 @@ static PyObject* Grid1D_synchronizeMPI(PyObject *self, PyObject *args) { ORBIT_MPI_Finalize("Grid1D.synchronizeMPI(MPI_Comm) - input parameter is not MPI_Comm"); } - cpp_Grid1D->synchronizeMPI((pyORBIT_MPI_Comm*) pyMPIComm); + cpp_Grid1D->synchronizeMPI(((pyORBIT_MPI_Comm*) pyMPIComm)->comm); } Py_INCREF(Py_None); return Py_None; diff --git a/src/spacecharge/wrap_grid1D.hh b/src/spacecharge/wrap_grid1D.hh index e7ed0805..4b111d1c 100644 --- a/src/spacecharge/wrap_grid1D.hh +++ b/src/spacecharge/wrap_grid1D.hh @@ -1,7 +1,7 @@ #ifndef WRAP_SPACE_CHARGE_GRID_1D_H #define WRAP_SPACE_CHARGE_GRID_1D_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" diff --git a/src/spacecharge/wrap_grid2D.cc b/src/spacecharge/wrap_grid2D.cc index e1fb5f84..b85aaa42 100644 --- a/src/spacecharge/wrap_grid2D.cc +++ b/src/spacecharge/wrap_grid2D.cc @@ -4,6 +4,7 @@ #include "wrap_grid2D.hh" #include "wrap_spacecharge.hh" #include "wrap_bunch.hh" +#include "wrap_mpi_comm.hh" #include @@ -180,7 +181,7 @@ extern "C" { if((!PyObject_IsInstance(pyMPIComm,py_mpi_comm_type))){ ORBIT_MPI_Finalize("Grid2D.synchronizeMPI(MPI_Comm) - input parameter is not MPI_Comm"); } - cpp_Grid2D->synchronizeMPI((pyORBIT_MPI_Comm*) pyMPIComm); + cpp_Grid2D->synchronizeMPI(((pyORBIT_MPI_Comm*) pyMPIComm)->comm); } Py_INCREF(Py_None); return Py_None; diff --git a/src/spacecharge/wrap_grid2D.hh b/src/spacecharge/wrap_grid2D.hh index 73501b59..1cc4f599 100644 --- a/src/spacecharge/wrap_grid2D.hh +++ b/src/spacecharge/wrap_grid2D.hh @@ -1,7 +1,7 @@ #ifndef WRAP_SPACE_CHARGE_GRID_2D_H #define WRAP_SPACE_CHARGE_GRID_2D_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/spacecharge/wrap_grid3D.cc b/src/spacecharge/wrap_grid3D.cc index 5dcc32b0..dc92eac5 100644 --- a/src/spacecharge/wrap_grid3D.cc +++ b/src/spacecharge/wrap_grid3D.cc @@ -4,6 +4,7 @@ #include "wrap_grid3D.hh" #include "wrap_spacecharge.hh" #include "wrap_bunch.hh" +#include "wrap_mpi_comm.hh" #include @@ -195,7 +196,7 @@ extern "C" { if((!PyObject_IsInstance(pyMPIComm,py_mpi_comm_type))){ ORBIT_MPI_Finalize("Grid3D.synchronizeMPI(MPI_Comm) - input parameter is not MPI_Comm"); } - cpp_Grid3D->synchronizeMPI((pyORBIT_MPI_Comm*) pyMPIComm); + cpp_Grid3D->synchronizeMPI(((pyORBIT_MPI_Comm*) pyMPIComm)->comm); } Py_INCREF(Py_None); return Py_None; diff --git a/src/spacecharge/wrap_grid3D.hh b/src/spacecharge/wrap_grid3D.hh index 4a465399..be407e32 100644 --- a/src/spacecharge/wrap_grid3D.hh +++ b/src/spacecharge/wrap_grid3D.hh @@ -1,7 +1,7 @@ #ifndef WRAP_SPACE_CHARGE_GRID_3D_H #define WRAP_SPACE_CHARGE_GRID_3D_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/spacecharge/wrap_lspacechargecalc.hh b/src/spacecharge/wrap_lspacechargecalc.hh index 17963c15..6c55a07a 100644 --- a/src/spacecharge/wrap_lspacechargecalc.hh +++ b/src/spacecharge/wrap_lspacechargecalc.hh @@ -1,7 +1,7 @@ #ifndef WRAP_SPACE_CHARGE_CALC_L_H #define WRAP_SPACE_CHARGE_CALC_L_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" diff --git a/src/spacecharge/wrap_poissonsolverfft2d.hh b/src/spacecharge/wrap_poissonsolverfft2d.hh index 383cda0f..1f31604a 100644 --- a/src/spacecharge/wrap_poissonsolverfft2d.hh +++ b/src/spacecharge/wrap_poissonsolverfft2d.hh @@ -1,7 +1,7 @@ #ifndef WRAP_SPACE_CHARGE_POISSON_SOLVER_FFT_2D_H #define WRAP_SPACE_CHARGE_POISSON_SOLVER_FFT_2D_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/spacecharge/wrap_poissonsolverfft3d.hh b/src/spacecharge/wrap_poissonsolverfft3d.hh index 6bda120c..4f78628c 100644 --- a/src/spacecharge/wrap_poissonsolverfft3d.hh +++ b/src/spacecharge/wrap_poissonsolverfft3d.hh @@ -1,7 +1,7 @@ #ifndef WRAP_SPACE_CHARGE_POISSON_SOLVER_FFT_3D_H #define WRAP_SPACE_CHARGE_POISSON_SOLVER_FFT_3D_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/spacecharge/wrap_spacecharge.cc b/src/spacecharge/wrap_spacecharge.cc index ab8d9ed5..079c6b9c 100644 --- a/src/spacecharge/wrap_spacecharge.cc +++ b/src/spacecharge/wrap_spacecharge.cc @@ -52,14 +52,6 @@ extern "C" { return module; } - PyObject* getSpaceChargeType(const char* name){ - PyObject* mod = PyImport_ImportModule("orbit.core.spacecharge"); - PyObject* pyType = PyObject_GetAttrString(mod,name); - Py_DECREF(mod); - Py_DECREF(pyType); - return pyType; - } - #ifdef __cplusplus } #endif diff --git a/src/spacecharge/wrap_spacecharge.hh b/src/spacecharge/wrap_spacecharge.hh index 12bddf42..1120c9f1 100644 --- a/src/spacecharge/wrap_spacecharge.hh +++ b/src/spacecharge/wrap_spacecharge.hh @@ -1,7 +1,7 @@ #ifndef WRAP_SPACE_CHARGE_H #define WRAP_SPACE_CHARGE_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/spacecharge/wrap_spacechargecalc2p5d.hh b/src/spacecharge/wrap_spacechargecalc2p5d.hh index 9ca19c00..bac019d2 100644 --- a/src/spacecharge/wrap_spacechargecalc2p5d.hh +++ b/src/spacecharge/wrap_spacechargecalc2p5d.hh @@ -1,7 +1,7 @@ #ifndef WRAP_SPACE_CHARGE_CALC_2P5D_H #define WRAP_SPACE_CHARGE_CALC_2P5D_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/spacecharge/wrap_spacechargecalc2p5d_rb.hh b/src/spacecharge/wrap_spacechargecalc2p5d_rb.hh index b2551e92..bbf671d5 100644 --- a/src/spacecharge/wrap_spacechargecalc2p5d_rb.hh +++ b/src/spacecharge/wrap_spacechargecalc2p5d_rb.hh @@ -1,7 +1,7 @@ #ifndef WRAP_SPACE_CHARGE_CALC_2P5D_RB_H #define WRAP_SPACE_CHARGE_CALC_2P5D_RB_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/spacecharge/wrap_spacechargecalc3d.hh b/src/spacecharge/wrap_spacechargecalc3d.hh index ec48fc43..61af06ff 100644 --- a/src/spacecharge/wrap_spacechargecalc3d.hh +++ b/src/spacecharge/wrap_spacechargecalc3d.hh @@ -1,7 +1,7 @@ #ifndef WRAP_SPACE_CHARGE_CALC_3D_H #define WRAP_SPACE_CHARGE_CALC_3D_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/spacecharge/wrap_spacechargecalc_slicebyslice_2D.hh b/src/spacecharge/wrap_spacechargecalc_slicebyslice_2D.hh index 6a8fb982..812733b5 100755 --- a/src/spacecharge/wrap_spacechargecalc_slicebyslice_2D.hh +++ b/src/spacecharge/wrap_spacechargecalc_slicebyslice_2D.hh @@ -1,7 +1,7 @@ #ifndef WRAP_SPACE_CHARGE_CALC_SLICE_BY_SLICE_2D_H #define WRAP_SPACE_CHARGE_CALC_SLICE_BY_SLICE_2D_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/spacecharge/wrap_spacechargecalc_uniform_ellipse.hh b/src/spacecharge/wrap_spacechargecalc_uniform_ellipse.hh index 85cc0fd9..fd9acf06 100644 --- a/src/spacecharge/wrap_spacechargecalc_uniform_ellipse.hh +++ b/src/spacecharge/wrap_spacechargecalc_uniform_ellipse.hh @@ -1,7 +1,7 @@ #ifndef WRAP_SPACE_CHARGE_CALC_UNIFORM_ELLIPSE_H #define WRAP_SPACE_CHARGE_CALC_UNIFORM_ELLIPSE_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/spacecharge/wrap_spacechargeforcecalc2p5d.hh b/src/spacecharge/wrap_spacechargeforcecalc2p5d.hh index eb91c908..f483312c 100644 --- a/src/spacecharge/wrap_spacechargeforcecalc2p5d.hh +++ b/src/spacecharge/wrap_spacechargeforcecalc2p5d.hh @@ -1,7 +1,7 @@ #ifndef WRAP_SPACE_CHARGE_FORCE_CALC_2P5D_H #define WRAP_SPACE_CHARGE_FORCE_CALC_2P5D_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/spacecharge/wrap_uniform_ellipsoid_field_calculator.hh b/src/spacecharge/wrap_uniform_ellipsoid_field_calculator.hh index 680a1c4f..a3e783d2 100644 --- a/src/spacecharge/wrap_uniform_ellipsoid_field_calculator.hh +++ b/src/spacecharge/wrap_uniform_ellipsoid_field_calculator.hh @@ -1,7 +1,7 @@ #ifndef WRAP_UNIFORM_ELLIPSOID_FIELD_CALC_H #define WRAP_UNIFORM_ELLIPSOID_FIELD_CALC_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/teapot/wrap_matrix_generator.hh b/src/teapot/wrap_matrix_generator.hh index 9c9eaab2..0bf9bb8a 100644 --- a/src/teapot/wrap_matrix_generator.hh +++ b/src/teapot/wrap_matrix_generator.hh @@ -1,7 +1,7 @@ #ifndef WRAP_MATRIX_GENERATOR_H #define WRAP_MATRIX_GENERATOR_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" diff --git a/src/teapot/wrap_teapotbase.cc b/src/teapot/wrap_teapotbase.cc index da405a16..68525d9a 100644 --- a/src/teapot/wrap_teapotbase.cc +++ b/src/teapot/wrap_teapotbase.cc @@ -1,4 +1,4 @@ -#include "Python.h" +#include #include "orbit_mpi.hh" #include "pyORBIT_Object.hh" diff --git a/src/trackerrk4/ExtEffectsContainer.hh b/src/trackerrk4/ExtEffectsContainer.hh index 321ba9db..73994f9b 100644 --- a/src/trackerrk4/ExtEffectsContainer.hh +++ b/src/trackerrk4/ExtEffectsContainer.hh @@ -3,7 +3,7 @@ -#include "Python.h" +#include #include "ExternalEffects.hh" #include diff --git a/src/trackerrk4/PyExternalEffects.hh b/src/trackerrk4/PyExternalEffects.hh index 9c100b95..f5ecce14 100644 --- a/src/trackerrk4/PyExternalEffects.hh +++ b/src/trackerrk4/PyExternalEffects.hh @@ -29,7 +29,7 @@ #ifndef PY_EXTERNAL_EFFECTS_H #define PY_EXTERNAL_EFFECTS_H -#include "Python.h" +#include #include "ExternalEffects.hh" diff --git a/src/trackerrk4/wrap_ext_effects_container.hh b/src/trackerrk4/wrap_ext_effects_container.hh index d0a532c6..0ab910a7 100644 --- a/src/trackerrk4/wrap_ext_effects_container.hh +++ b/src/trackerrk4/wrap_ext_effects_container.hh @@ -1,7 +1,7 @@ #ifndef WRAP_EXT_EFFECTS_CONTAINER_HH_ #define WRAP_EXT_EFFECTS_CONTAINER_HH_ -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/trackerrk4/wrap_py_external_effects.hh b/src/trackerrk4/wrap_py_external_effects.hh index ec7dc15a..88beeff6 100644 --- a/src/trackerrk4/wrap_py_external_effects.hh +++ b/src/trackerrk4/wrap_py_external_effects.hh @@ -1,7 +1,7 @@ #ifndef WRAP_PY_EXTERNAL_EFFECTS_H #define WRAP_PY_EXTERNAL_EFFECTS_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/trackerrk4/wrap_runge_kutta_tracker.hh b/src/trackerrk4/wrap_runge_kutta_tracker.hh index c8bce3f1..b25398be 100644 --- a/src/trackerrk4/wrap_runge_kutta_tracker.hh +++ b/src/trackerrk4/wrap_runge_kutta_tracker.hh @@ -1,7 +1,7 @@ #ifndef WRAP_RUNGE_KUTTA_TRACKER_H #define WRAP_RUNGE_KUTTA_TRACKER_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/trackerrk4/wrap_trackerrk4.cc b/src/trackerrk4/wrap_trackerrk4.cc index 5d23b55c..a955b7be 100644 --- a/src/trackerrk4/wrap_trackerrk4.cc +++ b/src/trackerrk4/wrap_trackerrk4.cc @@ -29,14 +29,6 @@ extern "C" { return module; } - PyObject* getTrackerRK4Type(const char* name){ - PyObject* mod = PyImport_ImportModule("orbit.core.trackerrk4"); - PyObject* pyType = PyObject_GetAttrString(mod,name); - Py_DECREF(mod); - Py_DECREF(pyType); - return pyType; - } - #ifdef __cplusplus } #endif diff --git a/src/trackerrk4/wrap_trackerrk4.hh b/src/trackerrk4/wrap_trackerrk4.hh index dcbf5693..59bf3177 100644 --- a/src/trackerrk4/wrap_trackerrk4.hh +++ b/src/trackerrk4/wrap_trackerrk4.hh @@ -1,7 +1,7 @@ #ifndef WRAP_RK4_TRACKER_H #define WRAP_RK4_TRACKER_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/utils/CppPyWrapper.hh b/src/utils/CppPyWrapper.hh index ada658e6..c43fa22e 100644 --- a/src/utils/CppPyWrapper.hh +++ b/src/utils/CppPyWrapper.hh @@ -15,7 +15,7 @@ #ifndef CPP_PY_WRAPPER_H #define CPP_PY_WRAPPER_H -#include "Python.h" +#include namespace OrbitUtils{ diff --git a/src/utils/FieldSourceContainer.hh b/src/utils/FieldSourceContainer.hh index ce8c4c01..bfd4c06d 100644 --- a/src/utils/FieldSourceContainer.hh +++ b/src/utils/FieldSourceContainer.hh @@ -18,7 +18,7 @@ #ifndef FIELDSOURCECONTAINER_HH_ #define FIELDSOURCECONTAINER_HH_ -#include "Python.h" +#include #include "BaseFieldSource.hh" #include diff --git a/src/utils/PyBaseFieldSource.hh b/src/utils/PyBaseFieldSource.hh index f00cee04..a79ce1dd 100644 --- a/src/utils/PyBaseFieldSource.hh +++ b/src/utils/PyBaseFieldSource.hh @@ -22,7 +22,7 @@ #ifndef PY_BASE_FIELD_SOURCE_H #define PY_BASE_FIELD_SOURCE_H -#include "Python.h" +#include #include "BaseFieldSource.hh" diff --git a/src/utils/bunch/BunchExtremaCalculator.cc b/src/utils/bunch/BunchExtremaCalculator.cc index 03057d2c..0571fcdb 100644 --- a/src/utils/bunch/BunchExtremaCalculator.cc +++ b/src/utils/bunch/BunchExtremaCalculator.cc @@ -65,7 +65,7 @@ void BunchExtremaCalculator::getExtremaXYZ(Bunch* bunch, gridLimArr[2] = - gridLimArr[2]; gridLimArr[4] = - gridLimArr[4]; - ORBIT_MPI_Allreduce(gridLimArr,gridLimArr_out,6,MPI_DOUBLE,MPI_MAX,bunch->getMPI_Comm_Local()->comm); + ORBIT_MPI_Allreduce(gridLimArr,gridLimArr_out,6,MPI_DOUBLE,MPI_MAX,bunch->getMPI_Comm_Local()); gridLimArr_out[0] = - gridLimArr_out[0]; gridLimArr_out[2] = - gridLimArr_out[2]; @@ -114,7 +114,7 @@ void BunchExtremaCalculator::getExtremaXpYpdE(Bunch* bunch, gridLimArr[2] = - gridLimArr[2]; gridLimArr[4] = - gridLimArr[4]; - ORBIT_MPI_Allreduce(gridLimArr,gridLimArr_out,6,MPI_DOUBLE,MPI_MAX,bunch->getMPI_Comm_Local()->comm); + ORBIT_MPI_Allreduce(gridLimArr,gridLimArr_out,6,MPI_DOUBLE,MPI_MAX,bunch->getMPI_Comm_Local()); gridLimArr_out[0] = - gridLimArr_out[0]; gridLimArr_out[2] = - gridLimArr_out[2]; @@ -152,7 +152,7 @@ void BunchExtremaCalculator::getExtremaZ(Bunch* bunch, gridLimArr[0] = - gridLimArr[0]; - ORBIT_MPI_Allreduce(gridLimArr,gridLimArr_out,2,MPI_DOUBLE,MPI_MAX,bunch->getMPI_Comm_Local()->comm); + ORBIT_MPI_Allreduce(gridLimArr,gridLimArr_out,2,MPI_DOUBLE,MPI_MAX,bunch->getMPI_Comm_Local()); gridLimArr_out[0] = - gridLimArr_out[0]; @@ -182,8 +182,8 @@ void BunchExtremaCalculator::getExtremaR(Bunch* bunch, double& rMax) double x_avg_global = 0.; double y_avg_global = 0.; - ORBIT_MPI_Allreduce(&x_avg,&x_avg_global,1,MPI_DOUBLE,MPI_SUM,bunch->getMPI_Comm_Local()->comm); - ORBIT_MPI_Allreduce(&y_avg,&y_avg_global,1,MPI_DOUBLE,MPI_SUM,bunch->getMPI_Comm_Local()->comm); + ORBIT_MPI_Allreduce(&x_avg,&x_avg_global,1,MPI_DOUBLE,MPI_SUM,bunch->getMPI_Comm_Local()); + ORBIT_MPI_Allreduce(&y_avg,&y_avg_global,1,MPI_DOUBLE,MPI_SUM,bunch->getMPI_Comm_Local()); if(nParts > 0){ x_avg = x_avg_global/nParts; @@ -203,7 +203,7 @@ void BunchExtremaCalculator::getExtremaR(Bunch* bunch, double& rMax) if(rMax > rMax_local) rMax_local = rMax; } - ORBIT_MPI_Allreduce(&rMax_local,&rMax_global,1,MPI_DOUBLE,MPI_MAX,bunch->getMPI_Comm_Local()->comm); + ORBIT_MPI_Allreduce(&rMax_local,&rMax_global,1,MPI_DOUBLE,MPI_MAX,bunch->getMPI_Comm_Local()); rMax = rMax_global; } diff --git a/src/utils/bunch/InitialCoordsAttrFunctions.cc b/src/utils/bunch/InitialCoordsAttrFunctions.cc index 2ba87291..63a7562b 100644 --- a/src/utils/bunch/InitialCoordsAttrFunctions.cc +++ b/src/utils/bunch/InitialCoordsAttrFunctions.cc @@ -113,8 +113,8 @@ namespace OrbitUtils{ int transport_mtrx_from_init_coords(Bunch* bunch, Matrix* A_mtr, int appl_twiss_x, int appl_twiss_y, int appl_twiss_z){ int size_MPI,rank_MPI; - ORBIT_MPI_Comm_size(bunch->getMPI_Comm_Local()->comm, &size_MPI); - ORBIT_MPI_Comm_rank(bunch->getMPI_Comm_Local()->comm, &rank_MPI); + ORBIT_MPI_Comm_size(bunch->getMPI_Comm_Local(), &size_MPI); + ORBIT_MPI_Comm_rank(bunch->getMPI_Comm_Local(), &rank_MPI); if(bunch->hasParticleAttributes("ParticleInitialCoordinates") == 0){ if(rank_MPI == 0){ @@ -190,9 +190,9 @@ namespace OrbitUtils{ } } - ORBIT_MPI_Allreduce(&total_macrosize,&total_macrosize_mpi,1,MPI_DOUBLE,MPI_SUM,b_tmp->getMPI_Comm_Local()->comm); - ORBIT_MPI_Allreduce(arr_avg,arr_avg_mpi,6,MPI_DOUBLE,MPI_SUM,b_tmp->getMPI_Comm_Local()->comm); - ORBIT_MPI_Allreduce(arr_init_avg,arr_init_avg_mpi,6,MPI_DOUBLE,MPI_SUM,b_tmp->getMPI_Comm_Local()->comm); + ORBIT_MPI_Allreduce(&total_macrosize,&total_macrosize_mpi,1,MPI_DOUBLE,MPI_SUM,b_tmp->getMPI_Comm_Local()); + ORBIT_MPI_Allreduce(arr_avg,arr_avg_mpi,6,MPI_DOUBLE,MPI_SUM,b_tmp->getMPI_Comm_Local()); + ORBIT_MPI_Allreduce(arr_init_avg,arr_init_avg_mpi,6,MPI_DOUBLE,MPI_SUM,b_tmp->getMPI_Comm_Local()); total_macrosize = total_macrosize_mpi; @@ -249,7 +249,7 @@ namespace OrbitUtils{ count++; } } - ORBIT_MPI_Allreduce(mtrx_arr,mtrx_arr_mpi,36,MPI_DOUBLE,MPI_SUM,b_tmp->getMPI_Comm_Local()->comm); + ORBIT_MPI_Allreduce(mtrx_arr,mtrx_arr_mpi,36,MPI_DOUBLE,MPI_SUM,b_tmp->getMPI_Comm_Local()); count = 0; for (int i = 0; i < 6; i++){ for (int j = 0; j < 6; j++){ @@ -265,7 +265,7 @@ namespace OrbitUtils{ count++; } } - ORBIT_MPI_Allreduce(mtrx_arr,mtrx_arr_mpi,36,MPI_DOUBLE,MPI_SUM,b_tmp->getMPI_Comm_Local()->comm); + ORBIT_MPI_Allreduce(mtrx_arr,mtrx_arr_mpi,36,MPI_DOUBLE,MPI_SUM,b_tmp->getMPI_Comm_Local()); count = 0; for (int i = 0; i < 6; i++){ for (int j = 0; j < 6; j++){ diff --git a/src/utils/bunch/ParticlesWithIdFunctions.cc b/src/utils/bunch/ParticlesWithIdFunctions.cc index 059f641e..35f301b6 100644 --- a/src/utils/bunch/ParticlesWithIdFunctions.cc +++ b/src/utils/bunch/ParticlesWithIdFunctions.cc @@ -51,8 +51,8 @@ namespace OrbitUtils{ int n_parts = bunch->getSize(); if(n_parts == 0) return; int size_MPI,rank_MPI; - ORBIT_MPI_Comm_size(bunch->getMPI_Comm_Local()->comm, &size_MPI); - ORBIT_MPI_Comm_rank(bunch->getMPI_Comm_Local()->comm, &rank_MPI); + ORBIT_MPI_Comm_size(bunch->getMPI_Comm_Local(), &size_MPI); + ORBIT_MPI_Comm_rank(bunch->getMPI_Comm_Local(), &rank_MPI); if(bunch->hasParticleAttributes("ParticleIdNumber") == 0){ if(rank_MPI == 0){ std::cerr << "OrbitUtils::bunch_utils_functions::bunch_sort_id(Bunch* bunch) function"<< std::endl; @@ -99,8 +99,8 @@ namespace OrbitUtils{ */ int transport_mtrx(Bunch* bunch_in, Bunch* bunch_out, Matrix* A_mtr, int appl_twiss_x, int appl_twiss_y, int appl_twiss_z){ int size_MPI,rank_MPI; - ORBIT_MPI_Comm_size(bunch_in->getMPI_Comm_Local()->comm, &size_MPI); - ORBIT_MPI_Comm_rank(bunch_in->getMPI_Comm_Local()->comm, &rank_MPI); + ORBIT_MPI_Comm_size(bunch_in->getMPI_Comm_Local(), &size_MPI); + ORBIT_MPI_Comm_rank(bunch_in->getMPI_Comm_Local(), &rank_MPI); if(bunch_in->hasParticleAttributes("ParticleIdNumber") == 0 || bunch_out->hasParticleAttributes("ParticleIdNumber") == 0){ if(rank_MPI == 0){ std::cerr << "OrbitUtils::bunch_utils_functions::transport_mtrx(...) function"<< std::endl; @@ -218,9 +218,9 @@ namespace OrbitUtils{ } } - ORBIT_MPI_Allreduce(&total_macrosize,&total_macrosize_mpi,1,MPI_DOUBLE,MPI_SUM,b_in_tmp->getMPI_Comm_Local()->comm); - ORBIT_MPI_Allreduce(arr_avg_in,arr_avg_in_mpi,6,MPI_DOUBLE,MPI_SUM,b_in_tmp->getMPI_Comm_Local()->comm); - ORBIT_MPI_Allreduce(arr_avg_out,arr_avg_out_mpi,6,MPI_DOUBLE,MPI_SUM,b_in_tmp->getMPI_Comm_Local()->comm); + ORBIT_MPI_Allreduce(&total_macrosize,&total_macrosize_mpi,1,MPI_DOUBLE,MPI_SUM,b_in_tmp->getMPI_Comm_Local()); + ORBIT_MPI_Allreduce(arr_avg_in,arr_avg_in_mpi,6,MPI_DOUBLE,MPI_SUM,b_in_tmp->getMPI_Comm_Local()); + ORBIT_MPI_Allreduce(arr_avg_out,arr_avg_out_mpi,6,MPI_DOUBLE,MPI_SUM,b_in_tmp->getMPI_Comm_Local()); total_macrosize = total_macrosize_mpi; @@ -276,7 +276,7 @@ namespace OrbitUtils{ count++; } } - ORBIT_MPI_Allreduce(mtrx_arr,mtrx_arr_mpi,36,MPI_DOUBLE,MPI_SUM,b_in_tmp->getMPI_Comm_Local()->comm); + ORBIT_MPI_Allreduce(mtrx_arr,mtrx_arr_mpi,36,MPI_DOUBLE,MPI_SUM,b_in_tmp->getMPI_Comm_Local()); count = 0; for (int i = 0; i < 6; i++){ for (int j = 0; j < 6; j++){ @@ -292,7 +292,7 @@ namespace OrbitUtils{ count++; } } - ORBIT_MPI_Allreduce(mtrx_arr,mtrx_arr_mpi,36,MPI_DOUBLE,MPI_SUM,b_in_tmp->getMPI_Comm_Local()->comm); + ORBIT_MPI_Allreduce(mtrx_arr,mtrx_arr_mpi,36,MPI_DOUBLE,MPI_SUM,b_in_tmp->getMPI_Comm_Local()); count = 0; for (int i = 0; i < 6; i++){ for (int j = 0; j < 6; j++){ diff --git a/src/utils/bunch/wrap_bunch_extrema_calculator.hh b/src/utils/bunch/wrap_bunch_extrema_calculator.hh index fcd41ae3..3358057a 100644 --- a/src/utils/bunch/wrap_bunch_extrema_calculator.hh +++ b/src/utils/bunch/wrap_bunch_extrema_calculator.hh @@ -1,7 +1,7 @@ #ifndef WRAP_UTILS_BUNCH_H #define WRAP_UTILS_BUNCH_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/utils/bunch/wrap_bunch_utils_functions.hh b/src/utils/bunch/wrap_bunch_utils_functions.hh index 2eeb0f3d..b4cf027f 100644 --- a/src/utils/bunch/wrap_bunch_utils_functions.hh +++ b/src/utils/bunch/wrap_bunch_utils_functions.hh @@ -1,7 +1,7 @@ #ifndef WRAP_UTILS_BUNCH_FUNCTIONS_H #define WRAP_UTILS_BUNCH_FUNCTIONS_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/utils/field_sources/ShiftedFieldSource.cc b/src/utils/field_sources/ShiftedFieldSource.cc index 3fe1bb80..fd357bbb 100644 --- a/src/utils/field_sources/ShiftedFieldSource.cc +++ b/src/utils/field_sources/ShiftedFieldSource.cc @@ -23,7 +23,7 @@ // the external coordinate system by coordTransformBack (3x3) matrix. // /////////////////////////////////////////////////////////////////////////// -#include "Python.h" +#include #include "orbit_mpi.hh" diff --git a/src/utils/field_sources/wrap_dipole_field_source.hh b/src/utils/field_sources/wrap_dipole_field_source.hh index b7050bb5..b39db8d6 100644 --- a/src/utils/field_sources/wrap_dipole_field_source.hh +++ b/src/utils/field_sources/wrap_dipole_field_source.hh @@ -1,7 +1,7 @@ #ifndef WRAP_DIPOLE_FIELD_SOURCE_H #define WRAP_DIPOLE_FIELD_SOURCE_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/utils/field_sources/wrap_field_sources_module.hh b/src/utils/field_sources/wrap_field_sources_module.hh index 008d89c0..e56441c3 100644 --- a/src/utils/field_sources/wrap_field_sources_module.hh +++ b/src/utils/field_sources/wrap_field_sources_module.hh @@ -1,7 +1,7 @@ #ifndef WRAP_FIELD_SOURCES_MODULE_H #define WRAP_FIELD_SOURCES_MODULE_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/utils/field_sources/wrap_loop_field_source.hh b/src/utils/field_sources/wrap_loop_field_source.hh index d09e8485..39f96d4b 100644 --- a/src/utils/field_sources/wrap_loop_field_source.hh +++ b/src/utils/field_sources/wrap_loop_field_source.hh @@ -1,7 +1,7 @@ #ifndef WRAP_LOOP_FIELD_SOURCE_H #define WRAP_LOOP_FIELD_SOURCE_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/utils/field_sources/wrap_magnetic_field_source_grid3d.hh b/src/utils/field_sources/wrap_magnetic_field_source_grid3d.hh index c29b0f54..ccf97665 100644 --- a/src/utils/field_sources/wrap_magnetic_field_source_grid3d.hh +++ b/src/utils/field_sources/wrap_magnetic_field_source_grid3d.hh @@ -1,7 +1,7 @@ #ifndef WRAP_MAGNET_FIELD_SOURCE_GRID3D_H #define WRAP_MAGNET_FIELD_SOURCE_GRID3D_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/utils/field_sources/wrap_quad_field_source.hh b/src/utils/field_sources/wrap_quad_field_source.hh index 5d91fff8..d83fc376 100644 --- a/src/utils/field_sources/wrap_quad_field_source.hh +++ b/src/utils/field_sources/wrap_quad_field_source.hh @@ -1,7 +1,7 @@ #ifndef WRAP_QUAD_FIELD_SOURCE_H #define WRAP_QUAD_FIELD_SOURCE_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/utils/harmonic_analysis/wrap_harmonic_data.hh b/src/utils/harmonic_analysis/wrap_harmonic_data.hh index 4b0e5ada..b38609d1 100644 --- a/src/utils/harmonic_analysis/wrap_harmonic_data.hh +++ b/src/utils/harmonic_analysis/wrap_harmonic_data.hh @@ -1,7 +1,7 @@ #ifndef WRAP_ORBIT_UTILS_HARMONIC_DATA_HH_ #define WRAP_ORBIT_UTILS_HARMONIC_DATA_HH_ -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/utils/integration/wrap_gauss_legendre_integrator.hh b/src/utils/integration/wrap_gauss_legendre_integrator.hh index d3452f87..258a5d7a 100644 --- a/src/utils/integration/wrap_gauss_legendre_integrator.hh +++ b/src/utils/integration/wrap_gauss_legendre_integrator.hh @@ -2,7 +2,7 @@ #define WRAP_ORBIT_UTILS_GAUSS_LEGENDRE_INTEGRATOR_HH_ -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/utils/matrix/wrap_matrix.hh b/src/utils/matrix/wrap_matrix.hh index c2aa7570..3fca2cef 100644 --- a/src/utils/matrix/wrap_matrix.hh +++ b/src/utils/matrix/wrap_matrix.hh @@ -1,7 +1,7 @@ #ifndef WRAP_UTILS_MATRIX_H #define WRAP_UTILS_MATRIX_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/utils/matrix/wrap_phase_vector.hh b/src/utils/matrix/wrap_phase_vector.hh index 33b04fdd..27f44540 100644 --- a/src/utils/matrix/wrap_phase_vector.hh +++ b/src/utils/matrix/wrap_phase_vector.hh @@ -1,7 +1,7 @@ #ifndef WRAP_UTILS_PHASE_VECTOR_H #define WRAP_UTILS_PHASE_VECTOR_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/utils/polynomial/wrap_polynomial.hh b/src/utils/polynomial/wrap_polynomial.hh index c3e4adc3..49086229 100644 --- a/src/utils/polynomial/wrap_polynomial.hh +++ b/src/utils/polynomial/wrap_polynomial.hh @@ -1,7 +1,7 @@ #ifndef WRAP_ORBIT_UTILS_POLYNOMIAL_HH_ #define WRAP_ORBIT_UTILS_POLYNOMIAL_HH_ -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/utils/statistics/StatMoments2D.cc b/src/utils/statistics/StatMoments2D.cc index 3656b76a..58292b50 100644 --- a/src/utils/statistics/StatMoments2D.cc +++ b/src/utils/statistics/StatMoments2D.cc @@ -167,7 +167,7 @@ int StatMoments2D::getCount() } /** It will synchronize the moments through the MPI communicator */ -void StatMoments2D::synchronizeMPI(pyORBIT_MPI_Comm* pyComm) +void StatMoments2D::synchronizeMPI(MPI_Comm pyComm) { int mpi_size = (max_order+1)*(max_order+1); int buff_index0 = -1; @@ -183,10 +183,10 @@ void StatMoments2D::synchronizeMPI(pyORBIT_MPI_Comm* pyComm) } } - if(pyComm == NULL) { + if(pyComm == MPI_COMM_NULL) { ORBIT_MPI_Allreduce(inArr,outArr,mpi_size,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD); } else { - ORBIT_MPI_Allreduce(inArr,outArr,mpi_size,MPI_DOUBLE,MPI_SUM,pyComm->comm); + ORBIT_MPI_Allreduce(inArr,outArr,mpi_size,MPI_DOUBLE,MPI_SUM,pyComm); } ii = 0; @@ -198,10 +198,10 @@ void StatMoments2D::synchronizeMPI(pyORBIT_MPI_Comm* pyComm) } int count_MPI = -1; - if(pyComm == NULL) { + if(pyComm == MPI_COMM_NULL) { ORBIT_MPI_Allreduce(&count,&count_MPI,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD); } else { - ORBIT_MPI_Allreduce(&count,&count_MPI,1,MPI_INT,MPI_SUM,pyComm->comm); + ORBIT_MPI_Allreduce(&count,&count_MPI,1,MPI_INT,MPI_SUM,pyComm); } count = count_MPI; diff --git a/src/utils/statistics/StatMoments2D.hh b/src/utils/statistics/StatMoments2D.hh index 79ac3161..2f312ba0 100644 --- a/src/utils/statistics/StatMoments2D.hh +++ b/src/utils/statistics/StatMoments2D.hh @@ -2,7 +2,6 @@ #define STAT_MOMENTS_2D_H #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" //pyORBIT utils #include "CppPyWrapper.hh" @@ -66,7 +65,7 @@ namespace OrbitUtils{ int getCount(); /** It will synchronize the moments through the MPI communicator */ - void synchronizeMPI(pyORBIT_MPI_Comm* pyComm); + void synchronizeMPI(MPI_Comm pyComm); /** Returns the emittance */ double getEmittance(); diff --git a/src/utils/statistics/wrap_statmoments2d.cc b/src/utils/statistics/wrap_statmoments2d.cc index d61a782d..539ac0da 100644 --- a/src/utils/statistics/wrap_statmoments2d.cc +++ b/src/utils/statistics/wrap_statmoments2d.cc @@ -172,7 +172,7 @@ extern "C" { if((!PyObject_IsInstance(pyMPIComm,py_mpi_comm_type))){ error("StatMoments2D.synchronizeMPI(MPI_Comm) - input parameter is not MPI_Comm"); } - cpp_StatMoments2D->synchronizeMPI((pyORBIT_MPI_Comm*) pyMPIComm); + cpp_StatMoments2D->synchronizeMPI(((pyORBIT_MPI_Comm*) pyMPIComm)->comm); } Py_INCREF(Py_None); return Py_None; diff --git a/src/utils/statistics/wrap_statmoments2d.hh b/src/utils/statistics/wrap_statmoments2d.hh index 3696dd37..1da57091 100644 --- a/src/utils/statistics/wrap_statmoments2d.hh +++ b/src/utils/statistics/wrap_statmoments2d.hh @@ -2,7 +2,7 @@ #define WRAP_ORBIT_UTILS_STAT_MOMENTS_2D_HH_ -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/utils/wrap_field_source_container.hh b/src/utils/wrap_field_source_container.hh index bb97c187..e7d37304 100644 --- a/src/utils/wrap_field_source_container.hh +++ b/src/utils/wrap_field_source_container.hh @@ -2,7 +2,7 @@ #define WRAP_FIELD_SOURCE_CONTAINER_HH_ -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/utils/wrap_function.hh b/src/utils/wrap_function.hh index 7d22dd4f..15c8ed5a 100644 --- a/src/utils/wrap_function.hh +++ b/src/utils/wrap_function.hh @@ -2,7 +2,7 @@ #define WRAP_ORBIT_UTILS_FUNCTION_HH_ -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/utils/wrap_numrecipes.hh b/src/utils/wrap_numrecipes.hh index f338562a..5ee49b3a 100644 --- a/src/utils/wrap_numrecipes.hh +++ b/src/utils/wrap_numrecipes.hh @@ -2,7 +2,7 @@ #define WRAP_ORBIT_UTILS_NUMRECIPES_HH_ -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/utils/wrap_py_base_field_source.hh b/src/utils/wrap_py_base_field_source.hh index b0d17767..330ac517 100644 --- a/src/utils/wrap_py_base_field_source.hh +++ b/src/utils/wrap_py_base_field_source.hh @@ -1,7 +1,7 @@ #ifndef WRAP_UTILS_PY_BASE_FILELD_SOURCE_H #define WRAP_UTILS_PY_BASE_FILELD_SOURCE_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/utils/wrap_random.hh b/src/utils/wrap_random.hh index 3e7f14f6..abee30de 100644 --- a/src/utils/wrap_random.hh +++ b/src/utils/wrap_random.hh @@ -2,7 +2,7 @@ #define WRAP_ORBIT_UTILS_RANDOM_HH_ -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/utils/wrap_splinech.hh b/src/utils/wrap_splinech.hh index e9289340..97e14cab 100644 --- a/src/utils/wrap_splinech.hh +++ b/src/utils/wrap_splinech.hh @@ -2,7 +2,7 @@ #define WRAP_ORBIT_UTILS_SPLINE_CH_HH_ -#include "Python.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/utils/wrap_utils.cc b/src/utils/wrap_utils.cc index 820976a1..434880d7 100644 --- a/src/utils/wrap_utils.cc +++ b/src/utils/wrap_utils.cc @@ -58,15 +58,6 @@ extern "C" { return module; } - PyObject* getOrbitUtilsType(const char* name){ - PyObject* mod = PyImport_ImportModule(const_cast("orbit.core.orbit_utils")); - PyObject* pyType = PyObject_GetAttrString(mod,name); - Py_DECREF(mod); - Py_DECREF(pyType); - return pyType; - } - - #ifdef __cplusplus } #endif diff --git a/src/utils/wrap_utils.hh b/src/utils/wrap_utils.hh index 291799a4..04ed7fc7 100644 --- a/src/utils/wrap_utils.hh +++ b/src/utils/wrap_utils.hh @@ -1,7 +1,7 @@ #ifndef WRAP_ORBIT_UTILS_H #define WRAP_ORBIT_UTILS_H -#include "Python.h" +#include #ifdef __cplusplus extern "C" { From b4f9a7be181cae9246b1fb3f1e5f505134a98856 Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 19 Jun 2026 11:14:55 -0400 Subject: [PATCH 03/33] Restore comments and deleted header that I thought wasn't necessary. Switch to #include <...> in parity with Python.h --- src/main/pyORBIT_Object.hh | 2 +- src/mpi/wrap_mpi_comm.cc | 117 ++++++++++++++++++++++++----------- src/mpi/wrap_mpi_datatype.cc | 2 +- src/mpi/wrap_mpi_group.cc | 2 +- src/mpi/wrap_mpi_op.cc | 2 +- src/mpi/wrap_mpi_request.cc | 2 +- src/mpi/wrap_mpi_status.cc | 2 +- 7 files changed, 86 insertions(+), 43 deletions(-) diff --git a/src/main/pyORBIT_Object.hh b/src/main/pyORBIT_Object.hh index 7a037e54..80dbc41f 100644 --- a/src/main/pyORBIT_Object.hh +++ b/src/main/pyORBIT_Object.hh @@ -17,7 +17,7 @@ #ifndef PY_ORBIT_OBJECT_H #define PY_ORBIT_OBJECT_H -#include "structmember.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/mpi/wrap_mpi_comm.cc b/src/mpi/wrap_mpi_comm.cc index ca27414c..6c5c976e 100644 --- a/src/mpi/wrap_mpi_comm.cc +++ b/src/mpi/wrap_mpi_comm.cc @@ -1,4 +1,13 @@ +/////////////////////////////////////////////////////////////////////////// +// +// INCLUDE FILES +// +/////////////////////////////////////////////////////////////////////////// #include "orbit_mpi.hh" + +//this header is from Python package +#include + #include "wrap_mpi_comm.hh" namespace wrap_orbit_mpi_comm{ @@ -9,6 +18,12 @@ namespace wrap_orbit_mpi_comm{ extern "C" { #endif + //--------------------------------------------------------- + //Python MPI_Comm class definition + //--------------------------------------------------------- + + //constructor for python class wrapping MPI_Comm instance + //It never will be called directly static PyObject* mpi_comm_new(PyTypeObject *type, PyObject *Py_UNUSED(args), PyObject *Py_UNUSED(kwds)) { pyORBIT_MPI_Comm* self; @@ -17,6 +32,8 @@ extern "C" { return (PyObject *) self; } + //initializator for python MPI_Comm class + //this is implementation of the __init__ method static int mpi_comm_init(pyORBIT_MPI_Comm *Py_UNUSED(self), PyObject *args, PyObject *Py_UNUSED(kwds)){ if(PyTuple_Size(args) != 0){ error("MPI_Comm constructor cannot have an input parameter."); @@ -24,6 +41,7 @@ extern "C" { return 0; } + //feeing the mpi comm in the python MPI_Comm class static PyObject* mpi_comm_free(PyObject *self, PyObject *Py_UNUSED(ignored)){ pyORBIT_MPI_Comm* pyMPI_Comm = (pyORBIT_MPI_Comm*) self; if(pyMPI_Comm->comm != MPI_COMM_WORLD && pyMPI_Comm->comm != MPI_COMM_SELF){ @@ -34,7 +52,12 @@ extern "C" { return Py_None; } + //----------------------------------------------------- + //destructor for python MPI_Comm class. + //----------------------------------------------------- + //this is implementation of the __del__ method static void mpi_comm_del(pyORBIT_MPI_Comm* self){ + //std::cerr<<"The MPI_Comm __del__ has been called!"<comm; if(comm != MPI_COMM_NULL && comm != MPI_COMM_WORLD && comm != MPI_COMM_SELF){ ORBIT_MPI_Comm_free(&comm); @@ -42,58 +65,68 @@ extern "C" { self->ob_base.ob_type->tp_free((PyObject*)self); } + // defenition of the methods of the python MPI_Comm wrapper class + // they will be vailable from python level static PyMethodDef MPI_CommClassMethods[] = { { "free", mpi_comm_free ,METH_NOARGS,"Free MPI communicator."}, {NULL} }; + // defenition of the memebers of the python MPI_Comm wrapper class + // they will be vailable from python level static PyMemberDef MPI_CommClassMembers[] = { {NULL} }; + //new python MPI_Comm wrapper type definition PyTypeObject pyORBIT_MPI_Comm_Type = { PyVarObject_HEAD_INIT(NULL, 0) - "MPI_Comm", - sizeof(pyORBIT_MPI_Comm), - 0, - (destructor) mpi_comm_del, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - "The MPI_Comm python wrapper", - 0, - 0, - 0, - 0, - 0, - 0, - MPI_CommClassMethods, - MPI_CommClassMembers, - 0, - 0, - 0, - 0, - 0, - 0, - (initproc) mpi_comm_init, - 0, - mpi_comm_new, + "MPI_Comm", /*tp_name*/ + sizeof(pyORBIT_MPI_Comm), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor) mpi_comm_del, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ + "The MPI_Comm python wrapper", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + MPI_CommClassMethods, /* tp_methods */ + MPI_CommClassMembers, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) mpi_comm_init, /* tp_init */ + 0, /* tp_alloc */ + mpi_comm_new, /* tp_new */ }; + //-------------------------------------------------- + //Initialization function of the MPI_Comm class + //It will be called from orbit_mpi wrapper initialization + //-------------------------------------------------- void init_orbit_mpi_comm(PyObject* module){ if (PyType_Ready(&pyORBIT_MPI_Comm_Type) < 0) return; + //we put Py_INCREF(...) because PyModule_AddObject() steal the reference Py_INCREF(&pyORBIT_MPI_Comm_Type); PyObject * comm_module = PyModule_New("mpi_comm"); @@ -119,6 +152,9 @@ extern "C" { PyModule_AddObject(module, "mpi_comm", comm_module); } + //----------------------------------------------------------- + //The function that will be exposed as C/C++ API for MPI_Comm + //----------------------------------------------------------- pyORBIT_MPI_Comm* newMPI_Comm(){ pyORBIT_MPI_Comm* pyMPI_Comm = PyObject_New(pyORBIT_MPI_Comm,&pyORBIT_MPI_Comm_Type); pyMPI_Comm->comm = MPI_COMM_WORLD; @@ -134,4 +170,11 @@ extern "C" { } #endif +//end of namespace wrap_orbit_mpi_comm } + +/////////////////////////////////////////////////////////////////////////// +// +// END OF FILE +// +/////////////////////////////////////////////////////////////////////////// diff --git a/src/mpi/wrap_mpi_datatype.cc b/src/mpi/wrap_mpi_datatype.cc index 12ab0442..868b2b7a 100644 --- a/src/mpi/wrap_mpi_datatype.cc +++ b/src/mpi/wrap_mpi_datatype.cc @@ -6,7 +6,7 @@ #include "orbit_mpi.hh" //this header is from Python package -#include "structmember.h" +#include //c++ header for cerr and cout #include diff --git a/src/mpi/wrap_mpi_group.cc b/src/mpi/wrap_mpi_group.cc index 2aad7957..c428a57a 100644 --- a/src/mpi/wrap_mpi_group.cc +++ b/src/mpi/wrap_mpi_group.cc @@ -6,7 +6,7 @@ #include "orbit_mpi.hh" //this header is from Python package -#include "structmember.h" +#include //c++ header for cerr and cout #include diff --git a/src/mpi/wrap_mpi_op.cc b/src/mpi/wrap_mpi_op.cc index 3d73c313..ae6afa8d 100644 --- a/src/mpi/wrap_mpi_op.cc +++ b/src/mpi/wrap_mpi_op.cc @@ -6,7 +6,7 @@ #include "orbit_mpi.hh" //this header is from Python package -#include "structmember.h" +#include //c++ header for cerr and cout #include diff --git a/src/mpi/wrap_mpi_request.cc b/src/mpi/wrap_mpi_request.cc index 73c6fad9..438dc9f8 100644 --- a/src/mpi/wrap_mpi_request.cc +++ b/src/mpi/wrap_mpi_request.cc @@ -6,7 +6,7 @@ #include "orbit_mpi.hh" //this header is from Python package -#include "structmember.h" +#include //c++ header for cerr and cout #include diff --git a/src/mpi/wrap_mpi_status.cc b/src/mpi/wrap_mpi_status.cc index 81ad503c..7d97d565 100644 --- a/src/mpi/wrap_mpi_status.cc +++ b/src/mpi/wrap_mpi_status.cc @@ -6,7 +6,7 @@ #include "orbit_mpi.hh" //this header is from Python package -#include "structmember.h" +#include //c++ header for cerr and cout #include From 401b3880d311c4e2595f1e976a3348b751a1e0ee Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 19 Jun 2026 11:22:34 -0400 Subject: [PATCH 04/33] attempt to fix linking on linux --- src/meson.build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/meson.build b/src/meson.build index e03091ac..46ed49be 100644 --- a/src/meson.build +++ b/src/meson.build @@ -8,7 +8,6 @@ endif dependencies = [] -dependencies += python.dependency() dependencies += dependency('fftw3', version: '>= 3.0.0', required: true) py_link_args = [] @@ -17,7 +16,10 @@ if host_machine.system() == 'darwin' # The unresolved symbols will be resolved once the Python interpreter loads libpyorbit. # The linker on MacOS is a bit more strict, so we need to explicitly tell it that # symbols from libpython will be nont resolvable for now. + dependencies += python.dependency() py_link_args += ['-Wl,-undefined,dynamic_lookup'] +else + dependencies += python.dependency(embed : true) endif # Detecting if MPICH or OPENMPI are installed and enabling support if present From da49351c1b8d9b8da7febce8631a4e3515066248 Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 11 Sep 2026 13:18:42 -0400 Subject: [PATCH 05/33] fix(bunch): retain MPI communicator ownership --- src/core/type_accessors.cc | 57 ++++++------- src/mpi/orbit_mpi.cc | 2 + src/orbit/Bunch.cc | 10 +-- src/orbit/wrap_bunch.cc | 88 ++++++++++++++++----- src/utils/bunch/ParticlesWithIdFunctions.cc | 6 +- 5 files changed, 111 insertions(+), 52 deletions(-) diff --git a/src/core/type_accessors.cc b/src/core/type_accessors.cc index 31b91134..e5e4c6d7 100644 --- a/src/core/type_accessors.cc +++ b/src/core/type_accessors.cc @@ -8,36 +8,47 @@ extern "C" { +namespace { + +PyObject* getModuleAttribute(const char* module_name, const char* name){ + PyObject* module = PyImport_ImportModule(module_name); + if(module == NULL){ + return NULL; + } + PyObject* attribute = PyDict_GetItemString(PyModule_GetDict(module), name); + Py_DECREF(module); + if(attribute == NULL){ + PyErr_Format(PyExc_AttributeError, "module '%s' has no attribute '%s'", module_name, name); + } + return attribute; +} + +} + namespace wrap_orbit_bunch { PyObject* getBunchType(const char* name){ - PyObject* mod = PyImport_ImportModule("orbit.core.bunch"); - PyObject* pyType = PyObject_GetAttrString(mod,name); - Py_DECREF(mod); - Py_DECREF(pyType); - return pyType; + return getModuleAttribute("orbit.core.bunch", name); } } PyObject* getSpaceChargeType(const char* name){ - PyObject* mod = PyImport_ImportModule("orbit.core.spacecharge"); - PyObject* pyType = PyObject_GetAttrString(mod,name); - Py_DECREF(mod); - Py_DECREF(pyType); - return pyType; + return getModuleAttribute("orbit.core.spacecharge", name); } namespace wrap_orbit_mpi_comm { PyObject* getMPI_CommType(const char* name){ - PyObject* mod = PyImport_ImportModule("orbit.core.orbit_mpi"); - PyObject* mpi_comm_mod = PyObject_GetAttrString(mod,"mpi_comm"); - PyObject* pyType = PyObject_GetAttrString(mpi_comm_mod,name); - Py_DECREF(mpi_comm_mod); - Py_DECREF(mod); - Py_DECREF(pyType); - return pyType; + PyObject* mpi_comm_module = getModuleAttribute("orbit.core.orbit_mpi", "mpi_comm"); + if(mpi_comm_module == NULL){ + return NULL; + } + PyObject* type = PyDict_GetItemString(PyModule_GetDict(mpi_comm_module), name); + if(type == NULL){ + PyErr_Format(PyExc_AttributeError, "module 'mpi_comm' has no attribute '%s'", name); + } + return type; } } @@ -45,21 +56,13 @@ PyObject* getMPI_CommType(const char* name){ namespace wrap_orbit_utils { PyObject* getOrbitUtilsType(const char* name){ - PyObject* mod = PyImport_ImportModule(const_cast("orbit.core.orbit_utils")); - PyObject* pyType = PyObject_GetAttrString(mod,name); - Py_DECREF(mod); - Py_DECREF(pyType); - return pyType; + return getModuleAttribute("orbit.core.orbit_utils", name); } } PyObject* getTrackerRK4Type(const char* name){ - PyObject* mod = PyImport_ImportModule("orbit.core.trackerrk4"); - PyObject* pyType = PyObject_GetAttrString(mod,name); - Py_DECREF(mod); - Py_DECREF(pyType); - return pyType; + return getModuleAttribute("orbit.core.trackerrk4", name); } } diff --git a/src/mpi/orbit_mpi.cc b/src/mpi/orbit_mpi.cc index 4965a9e1..59e38059 100644 --- a/src/mpi/orbit_mpi.cc +++ b/src/mpi/orbit_mpi.cc @@ -176,6 +176,7 @@ int ORBIT_MPI_Comm_dup(MPI_Comm comm, MPI_Comm *comm_out){ res = MPI_Comm_dup(comm, comm_out); #else res = MPI_SUCCESS; + *comm_out = comm; #endif return res; } @@ -233,6 +234,7 @@ int ORBIT_MPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int *result){ res = MPI_Comm_compare(comm1, comm2, result); #else res = MPI_SUCCESS; + *result = MPI_IDENT; #endif return res; } diff --git a/src/orbit/Bunch.cc b/src/orbit/Bunch.cc index 08c32684..590f13c2 100644 --- a/src/orbit/Bunch.cc +++ b/src/orbit/Bunch.cc @@ -1679,12 +1679,12 @@ MPI_Comm Bunch::getMPI_Comm_Local() const noexcept { } void Bunch::setMPI_Comm_Local(MPI_Comm comm){ - // wrap_orbit_mpi_comm::freeMPI_Comm(comm_); comm_ = comm; - // Py_INCREF((PyObject *) this->comm_); - if(iMPIini > 0) { - ORBIT_MPI_Comm_size(comm, &size_MPI); - ORBIT_MPI_Comm_rank(comm, &rank_MPI); + rank_MPI = 0; + size_MPI = 1; + if(iMPIini > 0 && comm_ != MPI_COMM_NULL) { + ORBIT_MPI_Comm_size(comm_, &size_MPI); + ORBIT_MPI_Comm_rank(comm_, &rank_MPI); } } diff --git a/src/orbit/wrap_bunch.cc b/src/orbit/wrap_bunch.cc index 57b6769a..7febe397 100644 --- a/src/orbit/wrap_bunch.cc +++ b/src/orbit/wrap_bunch.cc @@ -22,6 +22,16 @@ namespace wrap_orbit_bunch{ + typedef struct { + pyORBIT_Object base; + PyObject* mpi_comm; + } pyORBIT_Bunch; + + static void setMPICommOwner(pyORBIT_Bunch* bunch, PyObject* mpi_comm){ + Py_INCREF(mpi_comm); + Py_XSETREF(bunch->mpi_comm, mpi_comm); + } + void error(const char* msg){ ORBIT_MPI_Finalize(msg); } //--------------------------------------------------------- //Python Bunch class definition @@ -30,29 +40,48 @@ namespace wrap_orbit_bunch{ //constructor for python class wrapping Bunch instance //It never will be called directly static PyObject* Bunch_new(PyTypeObject *type, PyObject *Py_UNUSED(args), PyObject *Py_UNUSED(kwds)) { - pyORBIT_Object* self; - self = (pyORBIT_Object *) type->tp_alloc(type, 0); - self->cpp_obj = NULL; + pyORBIT_Bunch* self; + self = (pyORBIT_Bunch *) type->tp_alloc(type, 0); + if (self == NULL) { + return NULL; + } + self->base.cpp_obj = NULL; + self->mpi_comm = NULL; return (PyObject *) self; } //initializator for python Bunch class //this is implementation of the __init__ method - static int Bunch_init(pyORBIT_Object *self, PyObject *Py_UNUSED(args), PyObject *Py_UNUSED(kwds)){ + static int Bunch_init(pyORBIT_Bunch *self, PyObject *Py_UNUSED(args), PyObject *Py_UNUSED(kwds)){ //std::cerr<<"The Bunch __init__ has been called!"<cpp_obj = (void*) new Bunch(); - ((Bunch*) self->cpp_obj)->setPyWrapper((PyObject*) self); + self->base.cpp_obj = (void*) new Bunch(); + ((Bunch*) self->base.cpp_obj)->setPyWrapper((PyObject*) self); + + PyObject* mpi_comm_type = wrap_orbit_mpi_comm::getMPI_CommType("MPI_Comm"); + if (mpi_comm_type == NULL) { + return -1; + } + self->mpi_comm = PyObject_CallNoArgs(mpi_comm_type); + if (self->mpi_comm == NULL) { + return -1; + } //This is the way to create new class instance from the C-level // Template: PyObject* PyObject_CallMethod( PyObject *o, char *method, char *format, ...) //see Python/C API documentation //It will create a SyncParticle object and set the reference to it from pyBunch PyObject* mod = PyImport_ImportModule("orbit.core.bunch"); + if (mod == NULL) { + return -1; + } PyObject* pySyncPart = PyObject_CallMethod(mod,const_cast("SyncParticle"),const_cast("O"),self); + Py_DECREF(mod); + if (pySyncPart == NULL) { + return -1; + } //the references should be decreased because they were created as "new reference" Py_DECREF(pySyncPart); - Py_DECREF(mod); return 0; } @@ -78,17 +107,13 @@ namespace wrap_orbit_bunch{ //returns the local MPI Comm for this bunch static PyObject* Bunch_getMPIComm(PyObject *self, PyObject *Py_UNUSED(ignored)) { - Bunch* cpp_bunch = (Bunch*) ((pyORBIT_Object *) self)->cpp_obj; - - PyObject* mpi_comm_type = wrap_orbit_mpi_comm::getMPI_CommType("MPI_Comm"); - PyObject* pyComm = PyObject_CallFunction(mpi_comm_type, NULL); - if (pyComm == NULL) { - return NULL; - } - - ((pyORBIT_MPI_Comm*)pyComm)->comm = cpp_bunch->getMPI_Comm_Local(); - - return pyComm; + PyObject* mpi_comm = ((pyORBIT_Bunch*) self)->mpi_comm; + if (mpi_comm == NULL) { + PyErr_SetString(PyExc_RuntimeError, "Bunch has no MPI communicator"); + return NULL; + } + Py_INCREF(mpi_comm); + return mpi_comm; } //sets a new local MPI Comm for this bunch @@ -96,6 +121,9 @@ namespace wrap_orbit_bunch{ Bunch* cpp_bunch = (Bunch*) ((pyORBIT_Object *) self)->cpp_obj; PyObject* mpi_comm_type = wrap_orbit_mpi_comm::getMPI_CommType("MPI_Comm"); + if (mpi_comm_type == NULL) { + return NULL; + } if (!PyObject_TypeCheck(arg, (PyTypeObject*)mpi_comm_type)) { PyErr_SetString(PyExc_TypeError, "expected an MPI_Comm object"); return NULL; @@ -103,6 +131,7 @@ namespace wrap_orbit_bunch{ pyORBIT_MPI_Comm *pyComm = (pyORBIT_MPI_Comm*)arg; cpp_bunch->setMPI_Comm_Local(pyComm->comm); + setMPICommOwner((pyORBIT_Bunch*) self, arg); Py_RETURN_NONE; } @@ -1145,8 +1174,18 @@ namespace wrap_orbit_bunch{ if(!PyArg_ParseTuple(args,"O:copyEmptyBunchTo",&pyBunch_Target)){ error("PyBunch - copyEmptyBunchTo(pyBunch) - target pyBunch object is needed"); } + PyObject* bunch_type = getBunchType("Bunch"); + if (bunch_type == NULL) { + return NULL; + } + if (!PyObject_TypeCheck(pyBunch_Target, (PyTypeObject*) bunch_type)) { + PyErr_SetString(PyExc_TypeError, "expected a Bunch object"); + return NULL; + } Bunch* cpp_target_bunch = (Bunch*) ((pyORBIT_Object *) pyBunch_Target)->cpp_obj; cpp_bunch->copyEmptyBunchTo(cpp_target_bunch); + setMPICommOwner((pyORBIT_Bunch*) pyBunch_Target, + ((pyORBIT_Bunch*) self)->mpi_comm); Py_INCREF(Py_None); return Py_None; } @@ -1159,8 +1198,18 @@ namespace wrap_orbit_bunch{ if(!PyArg_ParseTuple(args,"O:copyBunchTo",&pyBunch_Target)){ error("PyBunch - copyBunchTo(pyBunch) - target pyBunch object is needed"); } + PyObject* bunch_type = getBunchType("Bunch"); + if (bunch_type == NULL) { + return NULL; + } + if (!PyObject_TypeCheck(pyBunch_Target, (PyTypeObject*) bunch_type)) { + PyErr_SetString(PyExc_TypeError, "expected a Bunch object"); + return NULL; + } Bunch* cpp_target_bunch = (Bunch*) ((pyORBIT_Object *) pyBunch_Target)->cpp_obj; cpp_bunch->copyBunchTo(cpp_target_bunch); + setMPICommOwner((pyORBIT_Bunch*) pyBunch_Target, + ((pyORBIT_Bunch*) self)->mpi_comm); Py_INCREF(Py_None); return Py_None; } @@ -1187,6 +1236,7 @@ namespace wrap_orbit_bunch{ static void Bunch_del(pyORBIT_Object* self){ Bunch* cpp_bunch = (Bunch*) self->cpp_obj; delete cpp_bunch; + Py_XDECREF(((pyORBIT_Bunch*) self)->mpi_comm); self->ob_base.ob_type->tp_free((PyObject*)self); } @@ -1266,7 +1316,7 @@ namespace wrap_orbit_bunch{ static PyTypeObject pyORBIT_Bunch_Type = { PyVarObject_HEAD_INIT(NULL, 0) "Bunch", /*tp_name*/ - sizeof(pyORBIT_Object), /*tp_basicsize*/ + sizeof(pyORBIT_Bunch), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor) Bunch_del , /*tp_dealloc*/ 0, /*tp_print*/ diff --git a/src/utils/bunch/ParticlesWithIdFunctions.cc b/src/utils/bunch/ParticlesWithIdFunctions.cc index 35f301b6..26a6d7f4 100644 --- a/src/utils/bunch/ParticlesWithIdFunctions.cc +++ b/src/utils/bunch/ParticlesWithIdFunctions.cc @@ -117,7 +117,11 @@ namespace OrbitUtils{ } ORBIT_MPI_Finalize(); } - if(bunch_in->getMPI_Comm_Local() != bunch_out->getMPI_Comm_Local()){ + int comm_comparison = MPI_UNEQUAL; + if(ORBIT_MPI_Comm_compare(bunch_in->getMPI_Comm_Local(), + bunch_out->getMPI_Comm_Local(), + &comm_comparison) != MPI_SUCCESS || + (comm_comparison != MPI_IDENT && comm_comparison != MPI_CONGRUENT)){ if(rank_MPI == 0){ std::cerr << "OrbitUtils::bunch_utils_functions::transport_mtrx(...) function"<< std::endl; std::cerr << "Bunches In and Out have different MPI communicators!"<< std::endl; From 9dc6c513e68a9cdb76d8986ce41cfba1ca0b3939 Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 11 Sep 2026 13:19:06 -0400 Subject: [PATCH 06/33] build(core): package standalone core library --- src/linac/rfgap/BaseRfGap.hh | 1 - src/linac/rfgap/BaseRfGap_slow.hh | 1 - src/linac/rfgap/MatrixRfGap.hh | 1 - src/linac/rfgap/RfGapTTF.hh | 1 - src/linac/rfgap/RfGapTTF_slow.hh | 1 - src/linac/rfgap/RfGapThreePointTTF.hh | 1 - src/linac/rfgap/RfGapThreePointTTF_slow.hh | 1 - src/meson.build | 48 +++++++++++++------ src/orbit/Impedances/LImpedance.hh | 1 - src/orbit/Impedances/TImpedance.hh | 1 - src/orbit/RFCavities/Barrier_Cav.hh | 1 - src/orbit/RFCavities/Dual_Harmonic_Cav.hh | 1 - src/orbit/RFCavities/Frequency_Cav.hh | 1 - src/orbit/RFCavities/Harmonic_Cav.hh | 1 - src/spacecharge/ForceSolver2D.hh | 1 - src/spacecharge/ForceSolverFFT2D.hh | 1 - src/spacecharge/LSpaceChargeCalc.hh | 1 - src/spacecharge/PoissonSolver2D.hh | 1 - src/spacecharge/PoissonSolver3D.hh | 1 - src/spacecharge/PoissonSolverFFT2D.hh | 1 - src/spacecharge/PoissonSolverFFT3D.hh | 1 - src/spacecharge/SpaceChargeCalc2p5D.hh | 1 - src/spacecharge/SpaceChargeCalc2p5Drb.hh | 1 - src/spacecharge/SpaceChargeCalc3D.hh | 1 - .../SpaceChargeCalcSliceBySlice2D.hh | 1 - src/spacecharge/SpaceChargeForceCalc2p5D.hh | 1 - 26 files changed, 34 insertions(+), 39 deletions(-) diff --git a/src/linac/rfgap/BaseRfGap.hh b/src/linac/rfgap/BaseRfGap.hh index 5deb4d68..79e709ed 100644 --- a/src/linac/rfgap/BaseRfGap.hh +++ b/src/linac/rfgap/BaseRfGap.hh @@ -6,7 +6,6 @@ //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include #include diff --git a/src/linac/rfgap/BaseRfGap_slow.hh b/src/linac/rfgap/BaseRfGap_slow.hh index de39488f..f20fac71 100644 --- a/src/linac/rfgap/BaseRfGap_slow.hh +++ b/src/linac/rfgap/BaseRfGap_slow.hh @@ -10,7 +10,6 @@ //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include #include diff --git a/src/linac/rfgap/MatrixRfGap.hh b/src/linac/rfgap/MatrixRfGap.hh index c021514c..2c82dcad 100644 --- a/src/linac/rfgap/MatrixRfGap.hh +++ b/src/linac/rfgap/MatrixRfGap.hh @@ -9,7 +9,6 @@ For this RF gap we know the E0TL, frequency, and phase only. //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include #include diff --git a/src/linac/rfgap/RfGapTTF.hh b/src/linac/rfgap/RfGapTTF.hh index 9d4f81b6..8eeef0c5 100644 --- a/src/linac/rfgap/RfGapTTF.hh +++ b/src/linac/rfgap/RfGapTTF.hh @@ -9,7 +9,6 @@ //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include diff --git a/src/linac/rfgap/RfGapTTF_slow.hh b/src/linac/rfgap/RfGapTTF_slow.hh index fe22376c..3445d498 100644 --- a/src/linac/rfgap/RfGapTTF_slow.hh +++ b/src/linac/rfgap/RfGapTTF_slow.hh @@ -11,7 +11,6 @@ //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include diff --git a/src/linac/rfgap/RfGapThreePointTTF.hh b/src/linac/rfgap/RfGapThreePointTTF.hh index ddba6822..1d990640 100644 --- a/src/linac/rfgap/RfGapThreePointTTF.hh +++ b/src/linac/rfgap/RfGapThreePointTTF.hh @@ -10,7 +10,6 @@ //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include diff --git a/src/linac/rfgap/RfGapThreePointTTF_slow.hh b/src/linac/rfgap/RfGapThreePointTTF_slow.hh index 133580b6..0b529671 100644 --- a/src/linac/rfgap/RfGapThreePointTTF_slow.hh +++ b/src/linac/rfgap/RfGapThreePointTTF_slow.hh @@ -13,7 +13,6 @@ //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include diff --git a/src/meson.build b/src/meson.build index 46ed49be..c672d9e8 100644 --- a/src/meson.build +++ b/src/meson.build @@ -10,16 +10,14 @@ dependencies = [] dependencies += dependency('fftw3', version: '>= 3.0.0', required: true) -py_link_args = [] +python_embed_dependency = python.dependency(embed: true) +core_link_args = [] if host_machine.system() == 'darwin' - # The unresolved symbols will be resolved once the Python interpreter loads libpyorbit. - # The linker on MacOS is a bit more strict, so we need to explicitly tell it that - # symbols from libpython will be nont resolvable for now. dependencies += python.dependency() - py_link_args += ['-Wl,-undefined,dynamic_lookup'] + core_link_args += ['-Wl,-undefined,dynamic_lookup'] else - dependencies += python.dependency(embed : true) + dependencies += python_embed_dependency endif # Detecting if MPICH or OPENMPI are installed and enabling support if present @@ -168,7 +166,7 @@ sources = files([ 'teapot/MatrixGenerator.cc' ]) -inc = include_directories([ +include_paths = [ 'main', 'mpi', 'orbit', @@ -196,18 +194,34 @@ inc = include_directories([ 'linac', 'linac/rfgap', 'linac/tracking', -]) +] + +inc = include_directories(include_paths) core_lib = library( 'pyorbit3', sources: sources, include_directories: inc, dependencies: dependencies, - link_args: py_link_args, + link_args: core_link_args, install: true, ) -core_dep = declare_dependency(link_with : core_lib, dependencies: dependencies) +core_install_dir = get_option('prefix') / get_option('libdir') +extension_install_dir = python.get_install_dir() / 'orbit/core' +core_relative_install_dir = run_command( + python, + '-c', + 'import os, sys; print(os.path.relpath(sys.argv[1], sys.argv[2]))', + core_install_dir, + extension_install_dir, + check: true, +).stdout().strip() +if host_machine.system() == 'darwin' + core_install_rpath = '@loader_path/' + core_relative_install_dir +else + core_install_rpath = '$ORIGIN/' + core_relative_install_dir +endif api_headers = [ 'linac/rfgap/BaseRfGap.hh', @@ -219,7 +233,6 @@ api_headers = [ 'linac/rfgap/RfGapTTF_slow.hh', 'linac/rfgap/SuperFishFieldSource.hh', 'linac/tracking/linac_tracking.hh', - 'main/pyORBIT_Object.hh', 'mpi/orbit_mpi.hh', 'orbit/Apertures/Aperture.hh', 'orbit/Apertures/BaseAperture.hh', @@ -305,7 +318,6 @@ api_headers = [ 'utils/bunch/InitialCoordsAttrFunctions.hh', 'utils/bunch/ParticlesWithIdFunctions.hh', 'utils/bunch/TwissFilteringFunctions.hh', - 'utils/ellipticalint/elliptint.hh', 'utils/field_sources/DipoleFieldSource.hh', 'utils/field_sources/LoopFieldSource.hh', 'utils/field_sources/MagnetFieldSourceGrid3D.hh', @@ -324,7 +336,14 @@ api_headers = [ install_headers(api_headers, subdir : 'pyorbit3', preserve_path : true) -pc_requires = ['fftw3 >= 3.0.0'] +pc_include_subdirs = ['pyorbit3'] +foreach path : include_paths + if path != 'main' and path != 'utils/ellipticalint' + pc_include_subdirs += 'pyorbit3' / path + endif +endforeach + +pc_requires = [python_embed_dependency, 'fftw3 >= 3.0.0'] if get_option('USE_MPI') == 'mpich' pc_requires += ['mpich >= 4.0.0'] elif get_option('USE_MPI') == 'ompi' @@ -340,7 +359,7 @@ pkgconfig.generate( version: meson.project_version(), libraries: core_lib, requires: pc_requires, - subdirs: 'pyorbit3', + subdirs: pc_include_subdirs, extra_cflags: '-DUSE_MPI=' + use_mpi_flag, install_dir: get_option('libdir') / 'pkgconfig', ) @@ -497,6 +516,7 @@ foreach name, src_list : ext_modules include_directories: inc, link_with: core_lib, dependencies: dependencies, + install_rpath: core_install_rpath, install: true, subdir: 'orbit/core', ) diff --git a/src/orbit/Impedances/LImpedance.hh b/src/orbit/Impedances/LImpedance.hh index a826af87..16f48839 100644 --- a/src/orbit/Impedances/LImpedance.hh +++ b/src/orbit/Impedances/LImpedance.hh @@ -5,7 +5,6 @@ //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include #include diff --git a/src/orbit/Impedances/TImpedance.hh b/src/orbit/Impedances/TImpedance.hh index 08e31d1f..4e87e579 100644 --- a/src/orbit/Impedances/TImpedance.hh +++ b/src/orbit/Impedances/TImpedance.hh @@ -5,7 +5,6 @@ //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include #include diff --git a/src/orbit/RFCavities/Barrier_Cav.hh b/src/orbit/RFCavities/Barrier_Cav.hh index 0c49c5fe..f3438b11 100644 --- a/src/orbit/RFCavities/Barrier_Cav.hh +++ b/src/orbit/RFCavities/Barrier_Cav.hh @@ -3,7 +3,6 @@ //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include #include diff --git a/src/orbit/RFCavities/Dual_Harmonic_Cav.hh b/src/orbit/RFCavities/Dual_Harmonic_Cav.hh index 64c396b6..82be5096 100644 --- a/src/orbit/RFCavities/Dual_Harmonic_Cav.hh +++ b/src/orbit/RFCavities/Dual_Harmonic_Cav.hh @@ -3,7 +3,6 @@ //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include #include diff --git a/src/orbit/RFCavities/Frequency_Cav.hh b/src/orbit/RFCavities/Frequency_Cav.hh index 3f424514..1b12dce1 100644 --- a/src/orbit/RFCavities/Frequency_Cav.hh +++ b/src/orbit/RFCavities/Frequency_Cav.hh @@ -3,7 +3,6 @@ //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include #include diff --git a/src/orbit/RFCavities/Harmonic_Cav.hh b/src/orbit/RFCavities/Harmonic_Cav.hh index a538e8d7..9f6e2010 100644 --- a/src/orbit/RFCavities/Harmonic_Cav.hh +++ b/src/orbit/RFCavities/Harmonic_Cav.hh @@ -3,7 +3,6 @@ //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include #include diff --git a/src/spacecharge/ForceSolver2D.hh b/src/spacecharge/ForceSolver2D.hh index 0e82629a..e97877c6 100644 --- a/src/spacecharge/ForceSolver2D.hh +++ b/src/spacecharge/ForceSolver2D.hh @@ -5,7 +5,6 @@ //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include #include diff --git a/src/spacecharge/ForceSolverFFT2D.hh b/src/spacecharge/ForceSolverFFT2D.hh index 7bd77583..d1df7a4a 100644 --- a/src/spacecharge/ForceSolverFFT2D.hh +++ b/src/spacecharge/ForceSolverFFT2D.hh @@ -5,7 +5,6 @@ //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include #include diff --git a/src/spacecharge/LSpaceChargeCalc.hh b/src/spacecharge/LSpaceChargeCalc.hh index f9b24a70..52e37afc 100644 --- a/src/spacecharge/LSpaceChargeCalc.hh +++ b/src/spacecharge/LSpaceChargeCalc.hh @@ -5,7 +5,6 @@ //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include #include diff --git a/src/spacecharge/PoissonSolver2D.hh b/src/spacecharge/PoissonSolver2D.hh index a1cb3a0a..28c699c7 100644 --- a/src/spacecharge/PoissonSolver2D.hh +++ b/src/spacecharge/PoissonSolver2D.hh @@ -5,7 +5,6 @@ //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include #include diff --git a/src/spacecharge/PoissonSolver3D.hh b/src/spacecharge/PoissonSolver3D.hh index 06844ca6..0e3a25ca 100644 --- a/src/spacecharge/PoissonSolver3D.hh +++ b/src/spacecharge/PoissonSolver3D.hh @@ -5,7 +5,6 @@ //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include #include diff --git a/src/spacecharge/PoissonSolverFFT2D.hh b/src/spacecharge/PoissonSolverFFT2D.hh index 98b489dc..33e2d9e6 100644 --- a/src/spacecharge/PoissonSolverFFT2D.hh +++ b/src/spacecharge/PoissonSolverFFT2D.hh @@ -5,7 +5,6 @@ //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include #include diff --git a/src/spacecharge/PoissonSolverFFT3D.hh b/src/spacecharge/PoissonSolverFFT3D.hh index 6134af5d..3b13e018 100644 --- a/src/spacecharge/PoissonSolverFFT3D.hh +++ b/src/spacecharge/PoissonSolverFFT3D.hh @@ -5,7 +5,6 @@ //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include #include diff --git a/src/spacecharge/SpaceChargeCalc2p5D.hh b/src/spacecharge/SpaceChargeCalc2p5D.hh index 53dfa196..f36f1fde 100644 --- a/src/spacecharge/SpaceChargeCalc2p5D.hh +++ b/src/spacecharge/SpaceChargeCalc2p5D.hh @@ -5,7 +5,6 @@ //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include #include diff --git a/src/spacecharge/SpaceChargeCalc2p5Drb.hh b/src/spacecharge/SpaceChargeCalc2p5Drb.hh index c343cade..a6ab5b87 100644 --- a/src/spacecharge/SpaceChargeCalc2p5Drb.hh +++ b/src/spacecharge/SpaceChargeCalc2p5Drb.hh @@ -9,7 +9,6 @@ //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include #include diff --git a/src/spacecharge/SpaceChargeCalc3D.hh b/src/spacecharge/SpaceChargeCalc3D.hh index f29ae565..261b49ca 100644 --- a/src/spacecharge/SpaceChargeCalc3D.hh +++ b/src/spacecharge/SpaceChargeCalc3D.hh @@ -11,7 +11,6 @@ //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include #include diff --git a/src/spacecharge/SpaceChargeCalcSliceBySlice2D.hh b/src/spacecharge/SpaceChargeCalcSliceBySlice2D.hh index 0babb55a..44fd5a6f 100755 --- a/src/spacecharge/SpaceChargeCalcSliceBySlice2D.hh +++ b/src/spacecharge/SpaceChargeCalcSliceBySlice2D.hh @@ -5,7 +5,6 @@ //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include #include diff --git a/src/spacecharge/SpaceChargeForceCalc2p5D.hh b/src/spacecharge/SpaceChargeForceCalc2p5D.hh index 35b49a52..265ba0f1 100644 --- a/src/spacecharge/SpaceChargeForceCalc2p5D.hh +++ b/src/spacecharge/SpaceChargeForceCalc2p5D.hh @@ -5,7 +5,6 @@ //MPI Function Wrappers #include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" #include #include From d4f62b1b6f92a9d1e6813d06a3f872395b31957b Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 11 Sep 2026 13:29:48 -0400 Subject: [PATCH 07/33] refactor(headers): use canonical include paths --- src/core/aperture_init.cc | 2 +- src/core/bunch_init.cc | 2 +- src/core/collimator_init.cc | 2 +- src/core/error_base_init.cc | 2 +- src/core/field_sources_init.cc | 2 +- src/core/fieldtracker_init.cc | 2 +- src/core/foil_init.cc | 2 +- src/core/impedances_init.cc | 2 +- src/core/linac_init.cc | 2 +- src/core/mpi_init.cc | 2 +- src/core/rfcavities_init.cc | 2 +- src/core/spacecharge_init.cc | 2 +- src/core/teapot_base_init.cc | 6 +-- src/core/trackerrk4_init.cc | 2 +- src/core/type_accessors.cc | 10 ++--- src/core/utils_init.cc | 2 +- src/linac/rfgap/BaseRfGap.cc | 10 ++--- src/linac/rfgap/BaseRfGap.hh | 6 +-- src/linac/rfgap/BaseRfGap_slow.cc | 10 ++--- src/linac/rfgap/BaseRfGap_slow.hh | 6 +-- src/linac/rfgap/MatrixRfGap.cc | 10 ++--- src/linac/rfgap/MatrixRfGap.hh | 6 +-- src/linac/rfgap/RfGapTTF.cc | 8 ++-- src/linac/rfgap/RfGapTTF.hh | 8 ++-- src/linac/rfgap/RfGapTTF_slow.cc | 8 ++-- src/linac/rfgap/RfGapTTF_slow.hh | 8 ++-- src/linac/rfgap/RfGapThreePointTTF.cc | 8 ++-- src/linac/rfgap/RfGapThreePointTTF.hh | 6 +-- src/linac/rfgap/RfGapThreePointTTF_slow.cc | 8 ++-- src/linac/rfgap/RfGapThreePointTTF_slow.hh | 6 +-- src/linac/rfgap/SuperFishFieldSource.cc | 4 +- src/linac/rfgap/SuperFishFieldSource.hh | 4 +- src/linac/rfgap/wrap_BaseRfGap.cc | 12 +++--- src/linac/rfgap/wrap_BaseRfGap_slow.cc | 12 +++--- src/linac/rfgap/wrap_MatrixRfGap.cc | 12 +++--- src/linac/rfgap/wrap_RfGapTTF.cc | 16 ++++---- src/linac/rfgap/wrap_RfGapTTF_slow.cc | 16 ++++---- src/linac/rfgap/wrap_RfGapThreePointTTF.cc | 16 ++++---- .../rfgap/wrap_RfGapThreePointTTF_slow.cc | 16 ++++---- src/linac/rfgap/wrap_SuperFishFieldSource.cc | 14 +++---- src/linac/tracking/linac_tracking.cc | 6 +-- src/linac/tracking/linac_tracking.hh | 2 +- src/linac/tracking/wrap_linac_tracking.cc | 8 ++-- src/linac/wrap_linacmodule.cc | 24 +++++------ src/meson.build | 41 +------------------ src/mpi/orbit_mpi.cc | 2 +- src/mpi/wrap_mpi_comm.cc | 4 +- src/mpi/wrap_mpi_comm.hh | 2 +- src/mpi/wrap_mpi_datatype.cc | 4 +- src/mpi/wrap_mpi_datatype.hh | 2 +- src/mpi/wrap_mpi_group.cc | 4 +- src/mpi/wrap_mpi_group.hh | 2 +- src/mpi/wrap_mpi_op.cc | 4 +- src/mpi/wrap_mpi_op.hh | 2 +- src/mpi/wrap_mpi_request.cc | 4 +- src/mpi/wrap_mpi_request.hh | 2 +- src/mpi/wrap_mpi_status.cc | 4 +- src/mpi/wrap_mpi_status.hh | 2 +- src/mpi/wrap_orbit_mpi.cc | 28 ++++++------- src/orbit/Apertures/Aperture.cc | 10 ++--- src/orbit/Apertures/Aperture.hh | 4 +- src/orbit/Apertures/BaseAperture.cc | 4 +- src/orbit/Apertures/BaseAperture.hh | 6 +-- src/orbit/Apertures/BaseApertureShape.cc | 2 +- src/orbit/Apertures/BaseApertureShape.hh | 6 +-- src/orbit/Apertures/CircleApertureShape.cc | 2 +- src/orbit/Apertures/CircleApertureShape.hh | 6 +-- src/orbit/Apertures/CompositeApertureShape.cc | 2 +- src/orbit/Apertures/CompositeApertureShape.hh | 6 +-- src/orbit/Apertures/ConvexApertureShape.cc | 4 +- src/orbit/Apertures/ConvexApertureShape.hh | 6 +-- src/orbit/Apertures/EllipseApertureShape.cc | 2 +- src/orbit/Apertures/EllipseApertureShape.hh | 6 +-- src/orbit/Apertures/EnergyAperture.cc | 8 ++-- src/orbit/Apertures/EnergyAperture.hh | 4 +- src/orbit/Apertures/PhaseAperture.cc | 8 ++-- src/orbit/Apertures/PhaseAperture.hh | 4 +- src/orbit/Apertures/PyBaseApertureShape.cc | 2 +- src/orbit/Apertures/PyBaseApertureShape.hh | 6 +-- .../Apertures/RectangularApertureShape.cc | 2 +- .../Apertures/RectangularApertureShape.hh | 6 +-- src/orbit/Apertures/wrap_BaseAperture.cc | 10 ++--- .../Apertures/wrap_CompositeApertureShape.cc | 8 ++-- .../Apertures/wrap_ConvexApertureShape.cc | 8 ++-- src/orbit/Apertures/wrap_EnergyAperture.cc | 10 ++--- src/orbit/Apertures/wrap_PhaseAperture.cc | 10 ++--- .../Apertures/wrap_PrimitiveApertureShape.cc | 12 +++--- .../Apertures/wrap_PyBaseApertureShape.cc | 8 ++-- src/orbit/Apertures/wrap_TAperture.cc | 10 ++--- src/orbit/Apertures/wrap_aperture.cc | 24 +++++------ src/orbit/Bunch.cc | 10 ++--- src/orbit/Bunch.hh | 10 ++--- .../BunchDiagnostics/BunchTuneAnalysis.cc | 6 +-- .../BunchDiagnostics/BunchTuneAnalysis.hh | 7 ++-- .../BunchDiagnostics/BunchTwissAnalysis.cc | 6 +-- .../BunchDiagnostics/BunchTwissAnalysis.hh | 4 +- .../wrap_bunch_tune_analysis.cc | 10 ++--- .../wrap_bunch_twiss_analysis.cc | 10 ++--- src/orbit/Errors/errorbase.cc | 10 ++--- src/orbit/Errors/errorbase.hh | 2 +- src/orbit/Errors/wrap_errorbase.cc | 8 ++-- src/orbit/FieldTracker/FieldTracker.cc | 6 +-- src/orbit/FieldTracker/FieldTracker.hh | 6 +-- src/orbit/FieldTracker/wrap_fieldtracker.cc | 12 +++--- src/orbit/Impedances/LImpedance.cc | 8 ++-- src/orbit/Impedances/LImpedance.hh | 10 ++--- src/orbit/Impedances/TImpedance.cc | 8 ++-- src/orbit/Impedances/TImpedance.hh | 10 ++--- src/orbit/Impedances/wrap_LImpedance.cc | 10 ++--- src/orbit/Impedances/wrap_TImpedance.cc | 10 ++--- src/orbit/Impedances/wrap_impedances.cc | 6 +-- src/orbit/MaterialInteractions/Collimator.cc | 16 ++++---- src/orbit/MaterialInteractions/Collimator.hh | 4 +- src/orbit/MaterialInteractions/Foil.cc | 16 ++++---- src/orbit/MaterialInteractions/Foil.hh | 4 +- .../MaterialInteractions.cc | 8 ++-- .../MaterialInteractions.hh | 2 +- .../MaterialInteractions/cross_sections.cc | 2 +- src/orbit/MaterialInteractions/numrecipes.cc | 2 +- .../MaterialInteractions/wrap_collimator.cc | 10 ++--- src/orbit/MaterialInteractions/wrap_foil.cc | 10 ++--- src/orbit/OrbitConst.cc | 2 +- .../ParticlesAttributes/AtomPopulations.cc | 4 +- .../ParticlesAttributes/AtomPopulations.hh | 2 +- src/orbit/ParticlesAttributes/Evolution.cc | 4 +- src/orbit/ParticlesAttributes/Evolution.hh | 2 +- .../LostParticleAttributes.cc | 4 +- .../LostParticleAttributes.hh | 2 +- .../ParticlesAttributes/ParticleAttributes.cc | 4 +- .../ParticlesAttributes/ParticleAttributes.hh | 2 +- .../ParticleAttributesFactory.cc | 26 ++++++------ .../ParticleAttributesFactory.hh | 4 +- .../ParticlesAttributes/ParticleIdNumber.cc | 4 +- .../ParticlesAttributes/ParticleIdNumber.hh | 2 +- .../ParticleInitialCoordinates.cc | 4 +- .../ParticleInitialCoordinates.hh | 2 +- .../ParticlesAttributes/ParticleMacroSize.cc | 4 +- .../ParticlesAttributes/ParticleMacroSize.hh | 4 +- .../ParticlePhaseAttributes.cc | 4 +- .../ParticlePhaseAttributes.hh | 2 +- .../TurnNumberAttributes.cc | 4 +- .../TurnNumberAttributes.hh | 2 +- .../WaveFunctionAmplitudes.cc | 4 +- .../WaveFunctionAmplitudes.hh | 2 +- src/orbit/ParticlesAttributes/part_time.cc | 4 +- src/orbit/ParticlesAttributes/part_time.hh | 2 +- .../ParticlesAttributes/pq_coordinates.cc | 4 +- .../ParticlesAttributes/pq_coordinates.hh | 2 +- src/orbit/RFCavities/Barrier_Cav.cc | 8 ++-- src/orbit/RFCavities/Barrier_Cav.hh | 6 +-- src/orbit/RFCavities/Dual_Harmonic_Cav.cc | 8 ++-- src/orbit/RFCavities/Dual_Harmonic_Cav.hh | 6 +-- src/orbit/RFCavities/Frequency_Cav.cc | 10 ++--- src/orbit/RFCavities/Frequency_Cav.hh | 6 +-- src/orbit/RFCavities/Harmonic_Cav.cc | 8 ++-- src/orbit/RFCavities/Harmonic_Cav.hh | 6 +-- src/orbit/RFCavities/wrap_Barrier_Cav.cc | 10 ++--- .../RFCavities/wrap_Dual_Harmonic_Cav.cc | 10 ++--- src/orbit/RFCavities/wrap_Frequency_Cav.cc | 10 ++--- src/orbit/RFCavities/wrap_Harmonic_Cav.cc | 10 ++--- src/orbit/RFCavities/wrap_rfcavities.cc | 10 ++--- src/orbit/SyncPart.cc | 10 ++--- src/orbit/SyncPart.hh | 2 +- .../SynchPartRedefinitionZdE.cc | 8 ++-- .../SynchPartRedefinitionZdE.hh | 4 +- .../wrap_synch_part_redefinition_z_de.cc | 10 ++--- src/orbit/wrap_bunch.cc | 18 ++++---- src/orbit/wrap_syncpart.cc | 8 ++-- src/spacecharge/BaseBoundary2D.cc | 4 +- src/spacecharge/BaseBoundary2D.hh | 4 +- src/spacecharge/ForceSolver2D.cc | 2 +- src/spacecharge/ForceSolver2D.hh | 6 +-- src/spacecharge/ForceSolverFFT2D.cc | 2 +- src/spacecharge/ForceSolverFFT2D.hh | 6 +-- src/spacecharge/Grid1D.cc | 10 ++--- src/spacecharge/Grid1D.hh | 6 +-- src/spacecharge/Grid2D.cc | 6 +-- src/spacecharge/Grid2D.hh | 6 +-- src/spacecharge/Grid3D.cc | 6 +-- src/spacecharge/Grid3D.hh | 8 ++-- src/spacecharge/LSpaceChargeCalc.cc | 8 ++-- src/spacecharge/LSpaceChargeCalc.hh | 10 ++--- src/spacecharge/PoissonSolver2D.cc | 2 +- src/spacecharge/PoissonSolver2D.hh | 6 +-- src/spacecharge/PoissonSolver3D.cc | 2 +- src/spacecharge/PoissonSolver3D.hh | 6 +-- src/spacecharge/PoissonSolverFFT2D.cc | 2 +- src/spacecharge/PoissonSolverFFT2D.hh | 6 +-- src/spacecharge/PoissonSolverFFT3D.cc | 2 +- src/spacecharge/PoissonSolverFFT3D.hh | 6 +-- src/spacecharge/ShapedBoundary2D.cc | 2 +- src/spacecharge/ShapedBoundary2D.hh | 4 +- src/spacecharge/SpaceChargeCalc2p5D.cc | 10 ++--- src/spacecharge/SpaceChargeCalc2p5D.hh | 16 ++++---- src/spacecharge/SpaceChargeCalc2p5Drb.cc | 10 ++--- src/spacecharge/SpaceChargeCalc2p5Drb.hh | 14 +++---- src/spacecharge/SpaceChargeCalc3D.cc | 10 ++--- src/spacecharge/SpaceChargeCalc3D.hh | 12 +++--- .../SpaceChargeCalcSliceBySlice2D.cc | 8 ++-- .../SpaceChargeCalcSliceBySlice2D.hh | 14 +++---- src/spacecharge/SpaceChargeCalcUnifEllipse.cc | 6 +-- src/spacecharge/SpaceChargeCalcUnifEllipse.hh | 8 ++-- src/spacecharge/SpaceChargeForceCalc2p5D.cc | 10 ++--- src/spacecharge/SpaceChargeForceCalc2p5D.hh | 16 ++++---- .../UniformEllipsoidFieldCalculator.cc | 8 ++-- .../UniformEllipsoidFieldCalculator.hh | 4 +- src/spacecharge/wrap_boundary2d.cc | 14 +++---- src/spacecharge/wrap_forcesolverfft2d.cc | 12 +++--- src/spacecharge/wrap_grid1D.cc | 14 +++---- src/spacecharge/wrap_grid2D.cc | 14 +++---- src/spacecharge/wrap_grid3D.cc | 14 +++---- src/spacecharge/wrap_lspacechargecalc.cc | 10 ++--- src/spacecharge/wrap_poissonsolverfft2d.cc | 12 +++--- src/spacecharge/wrap_poissonsolverfft3d.cc | 12 +++--- src/spacecharge/wrap_spacecharge.cc | 34 +++++++-------- src/spacecharge/wrap_spacechargecalc2p5d.cc | 12 +++--- .../wrap_spacechargecalc2p5d_rb.cc | 12 +++--- src/spacecharge/wrap_spacechargecalc3d.cc | 12 +++--- .../wrap_spacechargecalc_slicebyslice_2D.cc | 12 +++--- .../wrap_spacechargecalc_uniform_ellipse.cc | 12 +++--- .../wrap_spacechargeforcecalc2p5d.cc | 12 +++--- ...wrap_uniform_ellipsoid_field_calculator.cc | 10 ++--- src/teapot/MatrixGenerator.cc | 4 +- src/teapot/MatrixGenerator.hh | 4 +- src/teapot/teapotbase.cc | 8 ++-- src/teapot/teapotbase.hh | 2 +- src/teapot/wrap_matrix_generator.cc | 16 ++++---- src/teapot/wrap_teapotbase.cc | 10 ++--- src/trackerrk4/ExtEffectsContainer.cc | 4 +- src/trackerrk4/ExtEffectsContainer.hh | 2 +- src/trackerrk4/ExternalEffects.cc | 4 +- src/trackerrk4/ExternalEffects.hh | 6 +-- src/trackerrk4/PyExternalEffects.cc | 6 +-- src/trackerrk4/PyExternalEffects.hh | 2 +- src/trackerrk4/RungeKuttaTracker.cc | 4 +- src/trackerrk4/RungeKuttaTracker.hh | 8 ++-- src/trackerrk4/wrap_ext_effects_container.cc | 12 +++--- src/trackerrk4/wrap_py_external_effects.cc | 10 ++--- src/trackerrk4/wrap_runge_kutta_tracker.cc | 8 ++-- src/trackerrk4/wrap_trackerrk4.cc | 10 ++--- src/utils/AttributesBucket.cc | 2 +- src/utils/BaseFieldSource.cc | 2 +- src/utils/BaseFieldSource.hh | 2 +- src/utils/BufferStore.cc | 2 +- src/utils/CppPyWrapper.cc | 2 +- src/utils/FieldSourceContainer.cc | 4 +- src/utils/FieldSourceContainer.hh | 2 +- src/utils/MathPolynomial.cc | 4 +- src/utils/MathPolynomial.hh | 2 +- src/utils/OU_Function.cc | 4 +- src/utils/OU_Function.hh | 2 +- src/utils/OU_SplineCH.cc | 4 +- src/utils/OU_SplineCH.hh | 4 +- src/utils/PyBaseFieldSource.cc | 4 +- src/utils/PyBaseFieldSource.hh | 2 +- src/utils/Random.cc | 2 +- src/utils/StringUtils.cc | 2 +- src/utils/bessel.cc | 2 +- src/utils/bunch/BunchExtremaCalculator.cc | 6 +-- src/utils/bunch/BunchExtremaCalculator.hh | 2 +- src/utils/bunch/InitialCoordsAttrFunctions.cc | 16 ++++---- src/utils/bunch/InitialCoordsAttrFunctions.hh | 4 +- src/utils/bunch/ParticlesWithIdFunctions.cc | 16 ++++---- src/utils/bunch/ParticlesWithIdFunctions.hh | 4 +- src/utils/bunch/TwissFilteringFunctions.cc | 4 +- src/utils/bunch/TwissFilteringFunctions.hh | 2 +- .../bunch/wrap_bunch_extrema_calculator.cc | 12 +++--- src/utils/bunch/wrap_bunch_utils_functions.cc | 14 +++---- src/utils/field_sources/DipoleFieldSource.cc | 8 ++-- src/utils/field_sources/DipoleFieldSource.hh | 4 +- src/utils/field_sources/LoopFieldSource.cc | 12 +++--- src/utils/field_sources/LoopFieldSource.hh | 2 +- .../field_sources/MagnetFieldSourceGrid3D.cc | 8 ++-- .../field_sources/MagnetFieldSourceGrid3D.hh | 4 +- src/utils/field_sources/QuadFieldSource.cc | 8 ++-- src/utils/field_sources/QuadFieldSource.hh | 4 +- src/utils/field_sources/ShiftedFieldSource.cc | 6 +-- src/utils/field_sources/ShiftedFieldSource.hh | 8 ++-- .../field_sources/wrap_dipole_field_source.cc | 10 ++--- .../wrap_field_sources_module.cc | 16 ++++---- .../field_sources/wrap_loop_field_source.cc | 10 ++--- .../wrap_magnetic_field_source_grid3d.cc | 10 ++--- .../field_sources/wrap_quad_field_source.cc | 10 ++--- src/utils/harmonic_analysis/HarmonicData.cc | 6 +-- src/utils/harmonic_analysis/HarmonicData.hh | 4 +- .../harmonic_analysis/wrap_harmonic_data.cc | 10 ++--- .../integration/GaussLegendreIntegrator.cc | 12 +++--- .../integration/GaussLegendreIntegrator.hh | 6 +-- .../integration/gauss_legendre_points.cc | 2 +- .../integration/gauss_legendre_points.hh | 2 +- .../wrap_gauss_legendre_integrator.cc | 14 +++---- src/utils/matrix/Matrix.cc | 6 +-- src/utils/matrix/Matrix.hh | 2 +- src/utils/matrix/MatrixOperations.cc | 6 +-- src/utils/matrix/MatrixOperations.hh | 6 +-- src/utils/matrix/PhaseVector.cc | 4 +- src/utils/matrix/PhaseVector.hh | 2 +- src/utils/matrix/wrap_matrix.cc | 16 ++++---- src/utils/matrix/wrap_phase_vector.cc | 14 +++---- src/utils/polynomial/OU_Polynomial.cc | 4 +- src/utils/polynomial/OU_Polynomial.hh | 2 +- src/utils/polynomial/wrap_polynomial.cc | 10 ++--- src/utils/statistics/StatMoments2D.cc | 4 +- src/utils/statistics/StatMoments2D.hh | 4 +- src/utils/statistics/wrap_statmoments2d.cc | 12 +++--- src/utils/wrap_field_source_container.cc | 12 +++--- src/utils/wrap_function.cc | 10 ++--- src/utils/wrap_numrecipes.cc | 8 ++-- src/utils/wrap_py_base_field_source.cc | 10 ++--- src/utils/wrap_random.cc | 8 ++-- src/utils/wrap_splinech.cc | 10 ++--- src/utils/wrap_utils.cc | 32 +++++++-------- 312 files changed, 1100 insertions(+), 1136 deletions(-) diff --git a/src/core/aperture_init.cc b/src/core/aperture_init.cc index 08f949de..1950d6ba 100644 --- a/src/core/aperture_init.cc +++ b/src/core/aperture_init.cc @@ -1,4 +1,4 @@ -#include "wrap_aperture.hh" +#include "orbit/Apertures/wrap_aperture.hh" PyMODINIT_FUNC PyInit_aperture(void) { return wrap_aperture::initaperture(); } \ No newline at end of file diff --git a/src/core/bunch_init.cc b/src/core/bunch_init.cc index d9d6b8de..a1f2b3ba 100644 --- a/src/core/bunch_init.cc +++ b/src/core/bunch_init.cc @@ -1,4 +1,4 @@ -#include "wrap_bunch.hh" +#include "orbit/wrap_bunch.hh" PyMODINIT_FUNC PyInit_bunch(void) { return wrap_orbit_bunch::initbunch(); } \ No newline at end of file diff --git a/src/core/collimator_init.cc b/src/core/collimator_init.cc index 2f88f044..5d1e7e3c 100644 --- a/src/core/collimator_init.cc +++ b/src/core/collimator_init.cc @@ -1,4 +1,4 @@ -# include "wrap_collimator.hh" +# include "orbit/MaterialInteractions/wrap_collimator.hh" PyMODINIT_FUNC PyInit_collimator(void) { return wrap_collimator::initcollimator(); } diff --git a/src/core/error_base_init.cc b/src/core/error_base_init.cc index 1e6888aa..76b02342 100644 --- a/src/core/error_base_init.cc +++ b/src/core/error_base_init.cc @@ -1,5 +1,5 @@ #include -# include "wrap_errorbase.hh" +# include "orbit/Errors/wrap_errorbase.hh" PyMODINIT_FUNC PyInit_error_base(void) { return wrap_errorbase::initerrorbase(); } \ No newline at end of file diff --git a/src/core/field_sources_init.cc b/src/core/field_sources_init.cc index e592a9c4..aa8f9220 100644 --- a/src/core/field_sources_init.cc +++ b/src/core/field_sources_init.cc @@ -1,4 +1,4 @@ -#include "wrap_field_sources_module.hh" +#include "utils/field_sources/wrap_field_sources_module.hh" PyMODINIT_FUNC PyInit_field_sources(void) { return wrap_field_sources_module::initFieldSourcesModule(); } \ No newline at end of file diff --git a/src/core/fieldtracker_init.cc b/src/core/fieldtracker_init.cc index 15b9c9cd..16f0f3d1 100644 --- a/src/core/fieldtracker_init.cc +++ b/src/core/fieldtracker_init.cc @@ -1,4 +1,4 @@ -#include "wrap_fieldtracker.hh" +#include "orbit/FieldTracker/wrap_fieldtracker.hh" PyMODINIT_FUNC PyInit_fieldtracker(void) { return wrap_fieldtracker::initfieldtracker(); } \ No newline at end of file diff --git a/src/core/foil_init.cc b/src/core/foil_init.cc index 3c5869c2..8132a765 100644 --- a/src/core/foil_init.cc +++ b/src/core/foil_init.cc @@ -1,4 +1,4 @@ -#include "wrap_foil.hh" +#include "orbit/MaterialInteractions/wrap_foil.hh" PyMODINIT_FUNC PyInit_foil(void) { return wrap_foil::initfoil(); } diff --git a/src/core/impedances_init.cc b/src/core/impedances_init.cc index 48b9cf5a..af13db5c 100644 --- a/src/core/impedances_init.cc +++ b/src/core/impedances_init.cc @@ -1,4 +1,4 @@ -#include "wrap_impedances.hh" +#include "orbit/Impedances/wrap_impedances.hh" PyMODINIT_FUNC PyInit_impedances(void) { return wrap_impedances::initimpedances(); } \ No newline at end of file diff --git a/src/core/linac_init.cc b/src/core/linac_init.cc index 9797a77e..7003f8ee 100644 --- a/src/core/linac_init.cc +++ b/src/core/linac_init.cc @@ -1,4 +1,4 @@ -#include "wrap_linacmodule.hh" +#include "linac/wrap_linacmodule.hh" PyMODINIT_FUNC PyInit_linac(void) { return wrap_linac::initlinac(); } \ No newline at end of file diff --git a/src/core/mpi_init.cc b/src/core/mpi_init.cc index bf3e796a..821b0d20 100644 --- a/src/core/mpi_init.cc +++ b/src/core/mpi_init.cc @@ -1,5 +1,5 @@ #include -#include "wrap_orbit_mpi.hh" +#include "mpi/wrap_orbit_mpi.hh" PyMODINIT_FUNC PyInit_orbit_mpi(void) { return wrap_orbit_mpi::initorbit_mpi(); diff --git a/src/core/rfcavities_init.cc b/src/core/rfcavities_init.cc index 112c15dc..bb742bfb 100644 --- a/src/core/rfcavities_init.cc +++ b/src/core/rfcavities_init.cc @@ -1,4 +1,4 @@ -#include "wrap_rfcavities.hh" +#include "orbit/RFCavities/wrap_rfcavities.hh" PyMODINIT_FUNC PyInit_rfcavities(void) { return wrap_rfcavities::initrfcavities(); } \ No newline at end of file diff --git a/src/core/spacecharge_init.cc b/src/core/spacecharge_init.cc index 730b25b5..04b42c62 100644 --- a/src/core/spacecharge_init.cc +++ b/src/core/spacecharge_init.cc @@ -1,4 +1,4 @@ -#include "wrap_spacecharge.hh" +#include "spacecharge/wrap_spacecharge.hh" PyMODINIT_FUNC PyInit_spacecharge(void) { return initspacecharge(); } \ No newline at end of file diff --git a/src/core/teapot_base_init.cc b/src/core/teapot_base_init.cc index 9dc74c73..a682fdce 100644 --- a/src/core/teapot_base_init.cc +++ b/src/core/teapot_base_init.cc @@ -1,7 +1,7 @@ #include -#include "wrap_orbit_mpi.hh" -#include "wrap_teapotbase.hh" -#include "wrap_errorbase.hh" +#include "mpi/wrap_orbit_mpi.hh" +#include "teapot/wrap_teapotbase.hh" +#include "orbit/Errors/wrap_errorbase.hh" PyMODINIT_FUNC PyInit_teapot_base(void) { return wrap_teapotbase::initteapotbase(); diff --git a/src/core/trackerrk4_init.cc b/src/core/trackerrk4_init.cc index 87f23f7d..77c3744a 100644 --- a/src/core/trackerrk4_init.cc +++ b/src/core/trackerrk4_init.cc @@ -1,4 +1,4 @@ -#include "wrap_trackerrk4.hh" +#include "trackerrk4/wrap_trackerrk4.hh" PyMODINIT_FUNC PyInit_trackerrk4(void) { return inittrackerrk4(); } \ No newline at end of file diff --git a/src/core/type_accessors.cc b/src/core/type_accessors.cc index e5e4c6d7..ce2594e1 100644 --- a/src/core/type_accessors.cc +++ b/src/core/type_accessors.cc @@ -1,10 +1,10 @@ #include -#include "wrap_bunch.hh" -#include "wrap_spacecharge.hh" -#include "wrap_mpi_comm.hh" -#include "wrap_utils.hh" -#include "wrap_trackerrk4.hh" +#include "orbit/wrap_bunch.hh" +#include "spacecharge/wrap_spacecharge.hh" +#include "mpi/wrap_mpi_comm.hh" +#include "utils/wrap_utils.hh" +#include "trackerrk4/wrap_trackerrk4.hh" extern "C" { diff --git a/src/core/utils_init.cc b/src/core/utils_init.cc index 5f8cd02f..d3af5291 100644 --- a/src/core/utils_init.cc +++ b/src/core/utils_init.cc @@ -1,4 +1,4 @@ -#include "wrap_utils.hh" +#include "utils/wrap_utils.hh" PyMODINIT_FUNC PyInit_orbit_utils(void) { return wrap_orbit_utils::initutils(); } \ No newline at end of file diff --git a/src/linac/rfgap/BaseRfGap.cc b/src/linac/rfgap/BaseRfGap.cc index b185f539..8392725b 100644 --- a/src/linac/rfgap/BaseRfGap.cc +++ b/src/linac/rfgap/BaseRfGap.cc @@ -8,15 +8,15 @@ A. Shishlo, J. Holmes, ORNL Tech. Note ORNL/TM-2015/247, June 2015 */ -#include "BaseRfGap.hh" -#include "ParticleMacroSize.hh" +#include "linac/rfgap/BaseRfGap.hh" +#include "orbit/ParticlesAttributes/ParticleMacroSize.hh" #include #include -#include "Bunch.hh" -#include "bessel.hh" -#include "OrbitConst.hh" +#include "orbit/Bunch.hh" +#include "utils/bessel.hh" +#include "orbit/OrbitConst.hh" using namespace OrbitUtils; diff --git a/src/linac/rfgap/BaseRfGap.hh b/src/linac/rfgap/BaseRfGap.hh index 79e709ed..16b1379d 100644 --- a/src/linac/rfgap/BaseRfGap.hh +++ b/src/linac/rfgap/BaseRfGap.hh @@ -5,16 +5,16 @@ #define BASE_RF_GAP_H //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include //ORBIT bunch -#include "Bunch.hh" +#include "orbit/Bunch.hh" //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" using namespace std; diff --git a/src/linac/rfgap/BaseRfGap_slow.cc b/src/linac/rfgap/BaseRfGap_slow.cc index d43d721a..bcd84048 100644 --- a/src/linac/rfgap/BaseRfGap_slow.cc +++ b/src/linac/rfgap/BaseRfGap_slow.cc @@ -15,15 +15,15 @@ so the name of the class has the word slow in the name. */ -#include "BaseRfGap_slow.hh" -#include "ParticleMacroSize.hh" +#include "linac/rfgap/BaseRfGap_slow.hh" +#include "orbit/ParticlesAttributes/ParticleMacroSize.hh" #include #include -#include "Bunch.hh" -#include "bessel.hh" -#include "OrbitConst.hh" +#include "orbit/Bunch.hh" +#include "utils/bessel.hh" +#include "orbit/OrbitConst.hh" using namespace OrbitUtils; diff --git a/src/linac/rfgap/BaseRfGap_slow.hh b/src/linac/rfgap/BaseRfGap_slow.hh index f20fac71..c37e86ad 100644 --- a/src/linac/rfgap/BaseRfGap_slow.hh +++ b/src/linac/rfgap/BaseRfGap_slow.hh @@ -9,16 +9,16 @@ #define BASE_RF_GAP_SLOW_H //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include //ORBIT bunch -#include "Bunch.hh" +#include "orbit/Bunch.hh" //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" using namespace std; diff --git a/src/linac/rfgap/MatrixRfGap.cc b/src/linac/rfgap/MatrixRfGap.cc index 6283f8c8..b741d1f6 100644 --- a/src/linac/rfgap/MatrixRfGap.cc +++ b/src/linac/rfgap/MatrixRfGap.cc @@ -9,12 +9,12 @@ A. Shishlo, J. Holmes, ORNL Tech. Note ORNL/TM-2015/247, June 2015 */ -#include "MatrixRfGap.hh" -#include "ParticleMacroSize.hh" +#include "linac/rfgap/MatrixRfGap.hh" +#include "orbit/ParticlesAttributes/ParticleMacroSize.hh" -#include "Bunch.hh" -#include "bessel.hh" -#include "OrbitConst.hh" +#include "orbit/Bunch.hh" +#include "utils/bessel.hh" +#include "orbit/OrbitConst.hh" #include #include diff --git a/src/linac/rfgap/MatrixRfGap.hh b/src/linac/rfgap/MatrixRfGap.hh index 2c82dcad..432e45fb 100644 --- a/src/linac/rfgap/MatrixRfGap.hh +++ b/src/linac/rfgap/MatrixRfGap.hh @@ -8,16 +8,16 @@ For this RF gap we know the E0TL, frequency, and phase only. #define MATRIX_RF_GAP_H //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include //ORBIT bunch -#include "Bunch.hh" +#include "orbit/Bunch.hh" //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" using namespace std; diff --git a/src/linac/rfgap/RfGapTTF.cc b/src/linac/rfgap/RfGapTTF.cc index 5d26751a..64b424a0 100644 --- a/src/linac/rfgap/RfGapTTF.cc +++ b/src/linac/rfgap/RfGapTTF.cc @@ -10,10 +10,10 @@ ORNL Tech. Note ORNL/TM-2015/247, June 2015 */ -#include "Bunch.hh" -#include "bessel.hh" -#include "OrbitConst.hh" -#include "RfGapTTF.hh" +#include "orbit/Bunch.hh" +#include "utils/bessel.hh" +#include "orbit/OrbitConst.hh" +#include "linac/rfgap/RfGapTTF.hh" #include #include diff --git a/src/linac/rfgap/RfGapTTF.hh b/src/linac/rfgap/RfGapTTF.hh index 8eeef0c5..24823c6b 100644 --- a/src/linac/rfgap/RfGapTTF.hh +++ b/src/linac/rfgap/RfGapTTF.hh @@ -8,18 +8,18 @@ #define TTF_RF_GAP_H //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include //ORBIT bunch -#include "Bunch.hh" +#include "orbit/Bunch.hh" //pyORBIT utils -#include "CppPyWrapper.hh" -#include "OU_Polynomial.hh" +#include "utils/CppPyWrapper.hh" +#include "utils/polynomial/OU_Polynomial.hh" using namespace std; diff --git a/src/linac/rfgap/RfGapTTF_slow.cc b/src/linac/rfgap/RfGapTTF_slow.cc index 2d1b2a43..76c07979 100644 --- a/src/linac/rfgap/RfGapTTF_slow.cc +++ b/src/linac/rfgap/RfGapTTF_slow.cc @@ -17,10 +17,10 @@ */ -#include "Bunch.hh" -#include "bessel.hh" -#include "OrbitConst.hh" -#include "RfGapTTF_slow.hh" +#include "orbit/Bunch.hh" +#include "utils/bessel.hh" +#include "orbit/OrbitConst.hh" +#include "linac/rfgap/RfGapTTF_slow.hh" #include #include diff --git a/src/linac/rfgap/RfGapTTF_slow.hh b/src/linac/rfgap/RfGapTTF_slow.hh index 3445d498..7e5d0fe9 100644 --- a/src/linac/rfgap/RfGapTTF_slow.hh +++ b/src/linac/rfgap/RfGapTTF_slow.hh @@ -10,18 +10,18 @@ #define TTF_RF_GAP_SLOW_H //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include //ORBIT bunch -#include "Bunch.hh" +#include "orbit/Bunch.hh" //pyORBIT utils -#include "CppPyWrapper.hh" -#include "OU_Polynomial.hh" +#include "utils/CppPyWrapper.hh" +#include "utils/polynomial/OU_Polynomial.hh" using namespace std; diff --git a/src/linac/rfgap/RfGapThreePointTTF.cc b/src/linac/rfgap/RfGapThreePointTTF.cc index 2fab396e..174b11fd 100644 --- a/src/linac/rfgap/RfGapThreePointTTF.cc +++ b/src/linac/rfgap/RfGapThreePointTTF.cc @@ -11,10 +11,10 @@ ORNL Tech. Note ORNL/TM-2015/247, June 2015 */ -#include "Bunch.hh" -#include "bessel.hh" -#include "OrbitConst.hh" -#include "RfGapThreePointTTF.hh" +#include "orbit/Bunch.hh" +#include "utils/bessel.hh" +#include "orbit/OrbitConst.hh" +#include "linac/rfgap/RfGapThreePointTTF.hh" #include #include diff --git a/src/linac/rfgap/RfGapThreePointTTF.hh b/src/linac/rfgap/RfGapThreePointTTF.hh index 1d990640..e3a24ba2 100644 --- a/src/linac/rfgap/RfGapThreePointTTF.hh +++ b/src/linac/rfgap/RfGapThreePointTTF.hh @@ -9,17 +9,17 @@ #define THREE_POINTS_RF_GAP_H //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include //ORBIT bunch -#include "Bunch.hh" +#include "orbit/Bunch.hh" //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" using namespace std; diff --git a/src/linac/rfgap/RfGapThreePointTTF_slow.cc b/src/linac/rfgap/RfGapThreePointTTF_slow.cc index 0d09aa29..b27bb342 100644 --- a/src/linac/rfgap/RfGapThreePointTTF_slow.cc +++ b/src/linac/rfgap/RfGapThreePointTTF_slow.cc @@ -13,10 +13,10 @@ ORNL Tech. Note ORNL/TM-2015/247, June 2015 */ -#include "Bunch.hh" -#include "bessel.hh" -#include "OrbitConst.hh" -#include "RfGapThreePointTTF_slow.hh" +#include "orbit/Bunch.hh" +#include "utils/bessel.hh" +#include "orbit/OrbitConst.hh" +#include "linac/rfgap/RfGapThreePointTTF_slow.hh" #include #include diff --git a/src/linac/rfgap/RfGapThreePointTTF_slow.hh b/src/linac/rfgap/RfGapThreePointTTF_slow.hh index 0b529671..1b8a09ed 100644 --- a/src/linac/rfgap/RfGapThreePointTTF_slow.hh +++ b/src/linac/rfgap/RfGapThreePointTTF_slow.hh @@ -12,17 +12,17 @@ #define THREE_POINTS_RF_GAP_SLOW_H //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include //ORBIT bunch -#include "Bunch.hh" +#include "orbit/Bunch.hh" //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" using namespace std; diff --git a/src/linac/rfgap/SuperFishFieldSource.cc b/src/linac/rfgap/SuperFishFieldSource.cc index 5eddc2d8..cce7e1a9 100644 --- a/src/linac/rfgap/SuperFishFieldSource.cc +++ b/src/linac/rfgap/SuperFishFieldSource.cc @@ -5,8 +5,8 @@ The class can represent several RF gaps. */ -#include "OrbitConst.hh" -#include "SuperFishFieldSource.hh" +#include "orbit/OrbitConst.hh" +#include "linac/rfgap/SuperFishFieldSource.hh" #include #include diff --git a/src/linac/rfgap/SuperFishFieldSource.hh b/src/linac/rfgap/SuperFishFieldSource.hh index 45f121f0..c8052ea0 100644 --- a/src/linac/rfgap/SuperFishFieldSource.hh +++ b/src/linac/rfgap/SuperFishFieldSource.hh @@ -8,8 +8,8 @@ #ifndef SUPER_FISH_RF_FIELD_SOURCE_H #define SUPER_FISH_RF_FIELD_SOURCE_H -#include "BaseFieldSource.hh" -#include "Grid2D.hh" +#include "utils/BaseFieldSource.hh" +#include "spacecharge/Grid2D.hh" #include #include diff --git a/src/linac/rfgap/wrap_BaseRfGap.cc b/src/linac/rfgap/wrap_BaseRfGap.cc index 6140c94f..9bb5ab7e 100644 --- a/src/linac/rfgap/wrap_BaseRfGap.cc +++ b/src/linac/rfgap/wrap_BaseRfGap.cc @@ -1,13 +1,13 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_BaseRfGap.hh" -#include "wrap_linacmodule.hh" -#include "wrap_bunch.hh" +#include "linac/rfgap/wrap_BaseRfGap.hh" +#include "linac/wrap_linacmodule.hh" +#include "orbit/wrap_bunch.hh" #include -#include "BaseRfGap.hh" +#include "linac/rfgap/BaseRfGap.hh" using namespace OrbitUtils; diff --git a/src/linac/rfgap/wrap_BaseRfGap_slow.cc b/src/linac/rfgap/wrap_BaseRfGap_slow.cc index c1c64486..90af7d69 100644 --- a/src/linac/rfgap/wrap_BaseRfGap_slow.cc +++ b/src/linac/rfgap/wrap_BaseRfGap_slow.cc @@ -1,13 +1,13 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_BaseRfGap_slow.hh" -#include "wrap_linacmodule.hh" -#include "wrap_bunch.hh" +#include "linac/rfgap/wrap_BaseRfGap_slow.hh" +#include "linac/wrap_linacmodule.hh" +#include "orbit/wrap_bunch.hh" #include -#include "BaseRfGap_slow.hh" +#include "linac/rfgap/BaseRfGap_slow.hh" using namespace OrbitUtils; diff --git a/src/linac/rfgap/wrap_MatrixRfGap.cc b/src/linac/rfgap/wrap_MatrixRfGap.cc index dac308c5..035c1533 100644 --- a/src/linac/rfgap/wrap_MatrixRfGap.cc +++ b/src/linac/rfgap/wrap_MatrixRfGap.cc @@ -1,13 +1,13 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_MatrixRfGap.hh" -#include "wrap_linacmodule.hh" -#include "wrap_bunch.hh" +#include "linac/rfgap/wrap_MatrixRfGap.hh" +#include "linac/wrap_linacmodule.hh" +#include "orbit/wrap_bunch.hh" #include -#include "MatrixRfGap.hh" +#include "linac/rfgap/MatrixRfGap.hh" using namespace OrbitUtils; diff --git a/src/linac/rfgap/wrap_RfGapTTF.cc b/src/linac/rfgap/wrap_RfGapTTF.cc index 08cc1a88..be69a52b 100644 --- a/src/linac/rfgap/wrap_RfGapTTF.cc +++ b/src/linac/rfgap/wrap_RfGapTTF.cc @@ -1,15 +1,15 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_RfGapTTF.hh" -#include "wrap_linacmodule.hh" -#include "wrap_bunch.hh" +#include "linac/rfgap/wrap_RfGapTTF.hh" +#include "linac/wrap_linacmodule.hh" +#include "orbit/wrap_bunch.hh" #include -#include "wrap_utils.hh" -#include "RfGapTTF.hh" -#include "OU_Polynomial.hh" +#include "utils/wrap_utils.hh" +#include "linac/rfgap/RfGapTTF.hh" +#include "utils/polynomial/OU_Polynomial.hh" using namespace OrbitUtils; diff --git a/src/linac/rfgap/wrap_RfGapTTF_slow.cc b/src/linac/rfgap/wrap_RfGapTTF_slow.cc index 3b20342b..9231db01 100644 --- a/src/linac/rfgap/wrap_RfGapTTF_slow.cc +++ b/src/linac/rfgap/wrap_RfGapTTF_slow.cc @@ -1,15 +1,15 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_RfGapTTF_slow.hh" -#include "wrap_linacmodule.hh" -#include "wrap_bunch.hh" +#include "linac/rfgap/wrap_RfGapTTF_slow.hh" +#include "linac/wrap_linacmodule.hh" +#include "orbit/wrap_bunch.hh" #include -#include "wrap_utils.hh" -#include "RfGapTTF_slow.hh" -#include "OU_Polynomial.hh" +#include "utils/wrap_utils.hh" +#include "linac/rfgap/RfGapTTF_slow.hh" +#include "utils/polynomial/OU_Polynomial.hh" using namespace OrbitUtils; diff --git a/src/linac/rfgap/wrap_RfGapThreePointTTF.cc b/src/linac/rfgap/wrap_RfGapThreePointTTF.cc index f3b4e503..fa400b7b 100644 --- a/src/linac/rfgap/wrap_RfGapThreePointTTF.cc +++ b/src/linac/rfgap/wrap_RfGapThreePointTTF.cc @@ -1,15 +1,15 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_RfGapThreePointTTF.hh" -#include "wrap_linacmodule.hh" -#include "wrap_bunch.hh" +#include "linac/rfgap/wrap_RfGapThreePointTTF.hh" +#include "linac/wrap_linacmodule.hh" +#include "orbit/wrap_bunch.hh" #include -#include "wrap_utils.hh" -#include "RfGapThreePointTTF.hh" -#include "OU_Polynomial.hh" +#include "utils/wrap_utils.hh" +#include "linac/rfgap/RfGapThreePointTTF.hh" +#include "utils/polynomial/OU_Polynomial.hh" using namespace OrbitUtils; diff --git a/src/linac/rfgap/wrap_RfGapThreePointTTF_slow.cc b/src/linac/rfgap/wrap_RfGapThreePointTTF_slow.cc index 0b7da02b..3c661def 100644 --- a/src/linac/rfgap/wrap_RfGapThreePointTTF_slow.cc +++ b/src/linac/rfgap/wrap_RfGapThreePointTTF_slow.cc @@ -1,15 +1,15 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_RfGapThreePointTTF_slow.hh" -#include "wrap_linacmodule.hh" -#include "wrap_bunch.hh" +#include "linac/rfgap/wrap_RfGapThreePointTTF_slow.hh" +#include "linac/wrap_linacmodule.hh" +#include "orbit/wrap_bunch.hh" #include -#include "wrap_utils.hh" -#include "RfGapThreePointTTF_slow.hh" -#include "OU_Polynomial.hh" +#include "utils/wrap_utils.hh" +#include "linac/rfgap/RfGapThreePointTTF_slow.hh" +#include "utils/polynomial/OU_Polynomial.hh" using namespace OrbitUtils; diff --git a/src/linac/rfgap/wrap_SuperFishFieldSource.cc b/src/linac/rfgap/wrap_SuperFishFieldSource.cc index a42ac010..f6216131 100644 --- a/src/linac/rfgap/wrap_SuperFishFieldSource.cc +++ b/src/linac/rfgap/wrap_SuperFishFieldSource.cc @@ -1,12 +1,12 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_SuperFishFieldSource.hh" -#include "wrap_linacmodule.hh" +#include "linac/rfgap/wrap_SuperFishFieldSource.hh" +#include "linac/wrap_linacmodule.hh" -#include "wrap_utils.hh" -#include "wrap_spacecharge.hh" -#include "SuperFishFieldSource.hh" +#include "utils/wrap_utils.hh" +#include "spacecharge/wrap_spacecharge.hh" +#include "linac/rfgap/SuperFishFieldSource.hh" #include diff --git a/src/linac/tracking/linac_tracking.cc b/src/linac/tracking/linac_tracking.cc index 7302a565..268748e0 100644 --- a/src/linac/tracking/linac_tracking.cc +++ b/src/linac/tracking/linac_tracking.cc @@ -27,9 +27,9 @@ // /////////////////////////////////////////////////////////////////////////// -#include "OrbitConst.hh" -#include "Bunch.hh" -#include "SyncPart.hh" +#include "orbit/OrbitConst.hh" +#include "orbit/Bunch.hh" +#include "orbit/SyncPart.hh" #include diff --git a/src/linac/tracking/linac_tracking.hh b/src/linac/tracking/linac_tracking.hh index 129696a9..9984f925 100644 --- a/src/linac/tracking/linac_tracking.hh +++ b/src/linac/tracking/linac_tracking.hh @@ -18,7 +18,7 @@ #ifndef LINAC_TRACKING_H #define LINAC_TRACKING_H -#include "Bunch.hh" +#include "orbit/Bunch.hh" namespace linac_tracking { diff --git a/src/linac/tracking/wrap_linac_tracking.cc b/src/linac/tracking/wrap_linac_tracking.cc index 5c54fff1..85ca36d8 100644 --- a/src/linac/tracking/wrap_linac_tracking.cc +++ b/src/linac/tracking/wrap_linac_tracking.cc @@ -1,11 +1,11 @@ #include -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "main/pyORBIT_Object.hh" -#include "linac_tracking.hh" +#include "linac/tracking/linac_tracking.hh" -#include "wrap_linac_tracking.hh" +#include "linac/tracking/wrap_linac_tracking.hh" namespace wrap_linac_tracking { diff --git a/src/linac/wrap_linacmodule.cc b/src/linac/wrap_linacmodule.cc index 42a6d89a..c9bbb6cd 100644 --- a/src/linac/wrap_linacmodule.cc +++ b/src/linac/wrap_linacmodule.cc @@ -1,15 +1,15 @@ -#include "orbit_mpi.hh" - -#include "wrap_linacmodule.hh" -#include "wrap_BaseRfGap.hh" -#include "wrap_BaseRfGap_slow.hh" -#include "wrap_MatrixRfGap.hh" -#include "wrap_RfGapTTF.hh" -#include "wrap_RfGapTTF_slow.hh" -#include "wrap_SuperFishFieldSource.hh" -#include "wrap_RfGapThreePointTTF.hh" -#include "wrap_RfGapThreePointTTF_slow.hh" -#include "wrap_linac_tracking.hh" +#include "mpi/orbit_mpi.hh" + +#include "linac/wrap_linacmodule.hh" +#include "linac/rfgap/wrap_BaseRfGap.hh" +#include "linac/rfgap/wrap_BaseRfGap_slow.hh" +#include "linac/rfgap/wrap_MatrixRfGap.hh" +#include "linac/rfgap/wrap_RfGapTTF.hh" +#include "linac/rfgap/wrap_RfGapTTF_slow.hh" +#include "linac/rfgap/wrap_SuperFishFieldSource.hh" +#include "linac/rfgap/wrap_RfGapThreePointTTF.hh" +#include "linac/rfgap/wrap_RfGapThreePointTTF_slow.hh" +#include "linac/tracking/wrap_linac_tracking.hh" static PyMethodDef linacmoduleMethods[] = { {NULL,NULL} }; diff --git a/src/meson.build b/src/meson.build index c672d9e8..0bc3f7f1 100644 --- a/src/meson.build +++ b/src/meson.build @@ -166,37 +166,7 @@ sources = files([ 'teapot/MatrixGenerator.cc' ]) -include_paths = [ - 'main', - 'mpi', - 'orbit', - 'orbit/Apertures', - 'orbit/BunchDiagnostics', - 'orbit/Errors', - 'orbit/FieldTracker', - 'orbit/Impedances', - 'orbit/MaterialInteractions', - 'orbit/ParticlesAttributes', - 'orbit/RFCavities', - 'orbit/SynchPartRedefinition', - 'spacecharge', - 'teapot', - 'trackerrk4', - 'utils', - 'utils/bunch', - 'utils/ellipticalint', - 'utils/field_sources', - 'utils/harmonic_analysis', - 'utils/integration', - 'utils/matrix', - 'utils/polynomial', - 'utils/statistics', - 'linac', - 'linac/rfgap', - 'linac/tracking', -] - -inc = include_directories(include_paths) +inc = include_directories('.') core_lib = library( 'pyorbit3', @@ -336,13 +306,6 @@ api_headers = [ install_headers(api_headers, subdir : 'pyorbit3', preserve_path : true) -pc_include_subdirs = ['pyorbit3'] -foreach path : include_paths - if path != 'main' and path != 'utils/ellipticalint' - pc_include_subdirs += 'pyorbit3' / path - endif -endforeach - pc_requires = [python_embed_dependency, 'fftw3 >= 3.0.0'] if get_option('USE_MPI') == 'mpich' pc_requires += ['mpich >= 4.0.0'] @@ -359,7 +322,7 @@ pkgconfig.generate( version: meson.project_version(), libraries: core_lib, requires: pc_requires, - subdirs: pc_include_subdirs, + subdirs: 'pyorbit3', extra_cflags: '-DUSE_MPI=' + use_mpi_flag, install_dir: get_option('libdir') / 'pkgconfig', ) diff --git a/src/mpi/orbit_mpi.cc b/src/mpi/orbit_mpi.cc index 59e38059..b80941b0 100644 --- a/src/mpi/orbit_mpi.cc +++ b/src/mpi/orbit_mpi.cc @@ -1,4 +1,4 @@ -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include diff --git a/src/mpi/wrap_mpi_comm.cc b/src/mpi/wrap_mpi_comm.cc index 6c5c976e..d899fb88 100644 --- a/src/mpi/wrap_mpi_comm.cc +++ b/src/mpi/wrap_mpi_comm.cc @@ -3,12 +3,12 @@ // INCLUDE FILES // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" //this header is from Python package #include -#include "wrap_mpi_comm.hh" +#include "mpi/wrap_mpi_comm.hh" namespace wrap_orbit_mpi_comm{ diff --git a/src/mpi/wrap_mpi_comm.hh b/src/mpi/wrap_mpi_comm.hh index 7328e210..34f5e290 100644 --- a/src/mpi/wrap_mpi_comm.hh +++ b/src/mpi/wrap_mpi_comm.hh @@ -6,7 +6,7 @@ // This is a wrapper for the MPI_Comm data type from MPI // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #ifdef __cplusplus extern "C" { diff --git a/src/mpi/wrap_mpi_datatype.cc b/src/mpi/wrap_mpi_datatype.cc index 868b2b7a..08c61853 100644 --- a/src/mpi/wrap_mpi_datatype.cc +++ b/src/mpi/wrap_mpi_datatype.cc @@ -3,7 +3,7 @@ // INCLUDE FILES // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" //this header is from Python package #include @@ -11,7 +11,7 @@ //c++ header for cerr and cout #include -#include "wrap_mpi_datatype.hh" +#include "mpi/wrap_mpi_datatype.hh" namespace wrap_orbit_mpi_datatype{ diff --git a/src/mpi/wrap_mpi_datatype.hh b/src/mpi/wrap_mpi_datatype.hh index 670192ee..e16d97eb 100644 --- a/src/mpi/wrap_mpi_datatype.hh +++ b/src/mpi/wrap_mpi_datatype.hh @@ -6,7 +6,7 @@ // This is a wrapper for the MPI_Datatype data type from MPI // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #ifdef __cplusplus extern "C" { diff --git a/src/mpi/wrap_mpi_group.cc b/src/mpi/wrap_mpi_group.cc index c428a57a..6bff418b 100644 --- a/src/mpi/wrap_mpi_group.cc +++ b/src/mpi/wrap_mpi_group.cc @@ -3,7 +3,7 @@ // INCLUDE FILES // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" //this header is from Python package #include @@ -11,7 +11,7 @@ //c++ header for cerr and cout #include -#include "wrap_mpi_group.hh" +#include "mpi/wrap_mpi_group.hh" namespace wrap_orbit_mpi_group{ diff --git a/src/mpi/wrap_mpi_group.hh b/src/mpi/wrap_mpi_group.hh index fc06e37c..16bf327c 100644 --- a/src/mpi/wrap_mpi_group.hh +++ b/src/mpi/wrap_mpi_group.hh @@ -6,7 +6,7 @@ // This is a wrapper for the MPI_Group data type from MPI // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #ifdef __cplusplus extern "C" { diff --git a/src/mpi/wrap_mpi_op.cc b/src/mpi/wrap_mpi_op.cc index ae6afa8d..a59c573c 100644 --- a/src/mpi/wrap_mpi_op.cc +++ b/src/mpi/wrap_mpi_op.cc @@ -3,7 +3,7 @@ // INCLUDE FILES // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" //this header is from Python package #include @@ -11,7 +11,7 @@ //c++ header for cerr and cout #include -#include "wrap_mpi_op.hh" +#include "mpi/wrap_mpi_op.hh" namespace wrap_orbit_mpi_op{ diff --git a/src/mpi/wrap_mpi_op.hh b/src/mpi/wrap_mpi_op.hh index 76d7102c..8172c881 100644 --- a/src/mpi/wrap_mpi_op.hh +++ b/src/mpi/wrap_mpi_op.hh @@ -6,7 +6,7 @@ // This is a wrapper for the MPI_Op data type from MPI // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #ifdef __cplusplus extern "C" { diff --git a/src/mpi/wrap_mpi_request.cc b/src/mpi/wrap_mpi_request.cc index 438dc9f8..45b15ea9 100644 --- a/src/mpi/wrap_mpi_request.cc +++ b/src/mpi/wrap_mpi_request.cc @@ -3,7 +3,7 @@ // INCLUDE FILES // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" //this header is from Python package #include @@ -11,7 +11,7 @@ //c++ header for cerr and cout #include -#include "wrap_mpi_request.hh" +#include "mpi/wrap_mpi_request.hh" namespace wrap_orbit_mpi_request{ diff --git a/src/mpi/wrap_mpi_request.hh b/src/mpi/wrap_mpi_request.hh index 059da4ae..8ea00f59 100644 --- a/src/mpi/wrap_mpi_request.hh +++ b/src/mpi/wrap_mpi_request.hh @@ -6,7 +6,7 @@ // This is a wrapper for the MPI_Request data type from MPI // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #ifdef __cplusplus extern "C" { diff --git a/src/mpi/wrap_mpi_status.cc b/src/mpi/wrap_mpi_status.cc index 7d97d565..c602bf07 100644 --- a/src/mpi/wrap_mpi_status.cc +++ b/src/mpi/wrap_mpi_status.cc @@ -3,7 +3,7 @@ // INCLUDE FILES // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" //this header is from Python package #include @@ -11,7 +11,7 @@ //c++ header for cerr and cout #include -#include "wrap_mpi_status.hh" +#include "mpi/wrap_mpi_status.hh" namespace wrap_orbit_mpi_status{ diff --git a/src/mpi/wrap_mpi_status.hh b/src/mpi/wrap_mpi_status.hh index 19d021b5..8aea68eb 100644 --- a/src/mpi/wrap_mpi_status.hh +++ b/src/mpi/wrap_mpi_status.hh @@ -6,7 +6,7 @@ // This is a wrapper for the MPI_Status data type from MPI // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #ifdef __cplusplus extern "C" { diff --git a/src/mpi/wrap_orbit_mpi.cc b/src/mpi/wrap_orbit_mpi.cc index 658232ed..3bff7b96 100644 --- a/src/mpi/wrap_orbit_mpi.cc +++ b/src/mpi/wrap_orbit_mpi.cc @@ -1,22 +1,22 @@ #define PY_SSIZE_T_CLEAN #include -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include //arrays buffers for MPI exchange -#include "BufferStore.hh" +#include "utils/BufferStore.hh" -#include "wrap_orbit_mpi.hh" +#include "mpi/wrap_orbit_mpi.hh" //wrappers of mpi objects -#include "wrap_mpi_comm.hh" -#include "wrap_mpi_group.hh" -#include "wrap_mpi_status.hh" -#include "wrap_mpi_request.hh" -#include "wrap_mpi_datatype.hh" -#include "wrap_mpi_op.hh" +#include "mpi/wrap_mpi_comm.hh" +#include "mpi/wrap_mpi_group.hh" +#include "mpi/wrap_mpi_status.hh" +#include "mpi/wrap_mpi_request.hh" +#include "mpi/wrap_mpi_datatype.hh" +#include "mpi/wrap_mpi_op.hh" using namespace OrbitUtils; @@ -68,27 +68,27 @@ namespace wrap_orbit_mpi{ //------------------------------------------------------------------ // Wrappers for MPI functions related to the MPI_Comm manipulations //------------------------------------------------------------------ - #include "wrap_orbit_mpi_comm_functions.hh" + #include "mpi/wrap_orbit_mpi_comm_functions.hh" //------------------------------------------------------------------ // Wrappers for MPI functions related to the MPI_Group manipulations //------------------------------------------------------------------ - #include "wrap_orbit_mpi_group_functions.hh" + #include "mpi/wrap_orbit_mpi_group_functions.hh" //---------------------------------------------------------------------- // Wrappers for MPI functions related to the MPI_Intercomm manipulations //---------------------------------------------------------------------- - #include "wrap_orbit_mpi_intercomm_functions.hh" + #include "mpi/wrap_orbit_mpi_intercomm_functions.hh" //------------------------------------------------------------------- // Wrappers for MPI functions related to the MPI_Graph manipulations //------------------------------------------------------------------- - #include "wrap_orbit_mpi_graph_functions.hh" + #include "mpi/wrap_orbit_mpi_graph_functions.hh" //------------------------------------------------------------------ // Wrappers for MPI functions related to the Send-Receive operations //------------------------------------------------------------------ - #include "wrap_orbit_mpi_send_receive_functions.hh" + #include "mpi/wrap_orbit_mpi_send_receive_functions.hh" //Finalizes the execution of program // the action is depended on the number of arguments diff --git a/src/orbit/Apertures/Aperture.cc b/src/orbit/Apertures/Aperture.cc index dbadba45..f027f075 100644 --- a/src/orbit/Apertures/Aperture.cc +++ b/src/orbit/Apertures/Aperture.cc @@ -1,14 +1,14 @@ -#include "Aperture.hh" -#include "SyncPart.hh" -#include "OrbitConst.hh" -#include "Random.hh" +#include "orbit/Apertures/Aperture.hh" +#include "orbit/SyncPart.hh" +#include "orbit/OrbitConst.hh" +#include "utils/Random.hh" #include #include #include #include -#include "ParticleAttributes.hh" +#include "orbit/ParticlesAttributes/ParticleAttributes.hh" // Constructor /////////////////////////////////////////////////////////////////////////// // diff --git a/src/orbit/Apertures/Aperture.hh b/src/orbit/Apertures/Aperture.hh index 1f9243b4..ffc2bbae 100644 --- a/src/orbit/Apertures/Aperture.hh +++ b/src/orbit/Apertures/Aperture.hh @@ -3,8 +3,8 @@ #define APERTURE_H //pyORBIT utils -#include "CppPyWrapper.hh" -#include "Bunch.hh" +#include "utils/CppPyWrapper.hh" +#include "orbit/Bunch.hh" using namespace std; diff --git a/src/orbit/Apertures/BaseAperture.cc b/src/orbit/Apertures/BaseAperture.cc index 696e0543..ee73d5f8 100644 --- a/src/orbit/Apertures/BaseAperture.cc +++ b/src/orbit/Apertures/BaseAperture.cc @@ -1,5 +1,5 @@ -#include "BaseAperture.hh" -#include "ParticleAttributes.hh" +#include "orbit/Apertures/BaseAperture.hh" +#include "orbit/ParticlesAttributes/ParticleAttributes.hh" #include #include diff --git a/src/orbit/Apertures/BaseAperture.hh b/src/orbit/Apertures/BaseAperture.hh index 7a6c40de..f9453002 100644 --- a/src/orbit/Apertures/BaseAperture.hh +++ b/src/orbit/Apertures/BaseAperture.hh @@ -2,11 +2,11 @@ #ifndef BASE_APERTURE_H #define BASE_APERTURE_H -#include "Bunch.hh" -#include "BaseApertureShape.hh" +#include "orbit/Bunch.hh" +#include "orbit/Apertures/BaseApertureShape.hh" //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" using namespace std; diff --git a/src/orbit/Apertures/BaseApertureShape.cc b/src/orbit/Apertures/BaseApertureShape.cc index fbf2016f..1f706c57 100644 --- a/src/orbit/Apertures/BaseApertureShape.cc +++ b/src/orbit/Apertures/BaseApertureShape.cc @@ -1,4 +1,4 @@ -#include "BaseApertureShape.hh" +#include "orbit/Apertures/BaseApertureShape.hh" #include #include diff --git a/src/orbit/Apertures/BaseApertureShape.hh b/src/orbit/Apertures/BaseApertureShape.hh index b6f26e59..f9cd839d 100644 --- a/src/orbit/Apertures/BaseApertureShape.hh +++ b/src/orbit/Apertures/BaseApertureShape.hh @@ -2,11 +2,11 @@ #ifndef BASE_APERTURE_SHAPE_H #define BASE_APERTURE_SHAPE_H -#include "Bunch.hh" -#include "BaseApertureShape.hh" +#include "orbit/Bunch.hh" +#include "orbit/Apertures/BaseApertureShape.hh" //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" using namespace std; diff --git a/src/orbit/Apertures/CircleApertureShape.cc b/src/orbit/Apertures/CircleApertureShape.cc index 4bdcd123..08b81314 100644 --- a/src/orbit/Apertures/CircleApertureShape.cc +++ b/src/orbit/Apertures/CircleApertureShape.cc @@ -1,4 +1,4 @@ -#include "CircleApertureShape.hh" +#include "orbit/Apertures/CircleApertureShape.hh" #include #include diff --git a/src/orbit/Apertures/CircleApertureShape.hh b/src/orbit/Apertures/CircleApertureShape.hh index 46ca8095..dd7f23bc 100644 --- a/src/orbit/Apertures/CircleApertureShape.hh +++ b/src/orbit/Apertures/CircleApertureShape.hh @@ -2,10 +2,10 @@ #define CIRCULAR_APERTURE_SHAPE_H //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" -#include "Bunch.hh" -#include "BaseApertureShape.hh" +#include "orbit/Bunch.hh" +#include "orbit/Apertures/BaseApertureShape.hh" using namespace std; diff --git a/src/orbit/Apertures/CompositeApertureShape.cc b/src/orbit/Apertures/CompositeApertureShape.cc index 20b4ada4..a9bb87a0 100644 --- a/src/orbit/Apertures/CompositeApertureShape.cc +++ b/src/orbit/Apertures/CompositeApertureShape.cc @@ -1,4 +1,4 @@ -#include "CompositeApertureShape.hh" +#include "orbit/Apertures/CompositeApertureShape.hh" #include #include diff --git a/src/orbit/Apertures/CompositeApertureShape.hh b/src/orbit/Apertures/CompositeApertureShape.hh index 54030614..bc15f88d 100644 --- a/src/orbit/Apertures/CompositeApertureShape.hh +++ b/src/orbit/Apertures/CompositeApertureShape.hh @@ -2,10 +2,10 @@ #define COMPOSITE_APERTURE_SHAPE_H //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" -#include "Bunch.hh" -#include "BaseApertureShape.hh" +#include "orbit/Bunch.hh" +#include "orbit/Apertures/BaseApertureShape.hh" using namespace std; diff --git a/src/orbit/Apertures/ConvexApertureShape.cc b/src/orbit/Apertures/ConvexApertureShape.cc index 6e0e74a7..fb60117d 100644 --- a/src/orbit/Apertures/ConvexApertureShape.cc +++ b/src/orbit/Apertures/ConvexApertureShape.cc @@ -1,6 +1,6 @@ -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" -#include "ConvexApertureShape.hh" +#include "orbit/Apertures/ConvexApertureShape.hh" #include #include diff --git a/src/orbit/Apertures/ConvexApertureShape.hh b/src/orbit/Apertures/ConvexApertureShape.hh index 2d2a4672..6584c791 100644 --- a/src/orbit/Apertures/ConvexApertureShape.hh +++ b/src/orbit/Apertures/ConvexApertureShape.hh @@ -2,10 +2,10 @@ #define CONVEX_APERTURE_SHAPE_H //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" -#include "Bunch.hh" -#include "BaseApertureShape.hh" +#include "orbit/Bunch.hh" +#include "orbit/Apertures/BaseApertureShape.hh" using namespace std; diff --git a/src/orbit/Apertures/EllipseApertureShape.cc b/src/orbit/Apertures/EllipseApertureShape.cc index a8ad1b98..5de82490 100644 --- a/src/orbit/Apertures/EllipseApertureShape.cc +++ b/src/orbit/Apertures/EllipseApertureShape.cc @@ -1,4 +1,4 @@ -#include "EllipseApertureShape.hh" +#include "orbit/Apertures/EllipseApertureShape.hh" #include #include diff --git a/src/orbit/Apertures/EllipseApertureShape.hh b/src/orbit/Apertures/EllipseApertureShape.hh index 981d0c66..6198c6f9 100644 --- a/src/orbit/Apertures/EllipseApertureShape.hh +++ b/src/orbit/Apertures/EllipseApertureShape.hh @@ -2,10 +2,10 @@ #define ELLIPSE_APERTURE_SHAPE_H //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" -#include "Bunch.hh" -#include "BaseApertureShape.hh" +#include "orbit/Bunch.hh" +#include "orbit/Apertures/BaseApertureShape.hh" using namespace std; diff --git a/src/orbit/Apertures/EnergyAperture.cc b/src/orbit/Apertures/EnergyAperture.cc index d28281d8..8f7c1331 100644 --- a/src/orbit/Apertures/EnergyAperture.cc +++ b/src/orbit/Apertures/EnergyAperture.cc @@ -19,16 +19,16 @@ /////////////////////////////////////////////////////////////////////////// -#include "EnergyAperture.hh" -#include "SyncPart.hh" -#include "OrbitConst.hh" +#include "orbit/Apertures/EnergyAperture.hh" +#include "orbit/SyncPart.hh" +#include "orbit/OrbitConst.hh" #include #include #include #include -#include "ParticleAttributes.hh" +#include "orbit/ParticlesAttributes/ParticleAttributes.hh" /** The EnergyAperture class constructor. diff --git a/src/orbit/Apertures/EnergyAperture.hh b/src/orbit/Apertures/EnergyAperture.hh index fcc5d33e..b7a7b16f 100644 --- a/src/orbit/Apertures/EnergyAperture.hh +++ b/src/orbit/Apertures/EnergyAperture.hh @@ -21,8 +21,8 @@ /////////////////////////////////////////////////////////////////////////// //pyORBIT utils -#include "CppPyWrapper.hh" -#include "Bunch.hh" +#include "utils/CppPyWrapper.hh" +#include "orbit/Bunch.hh" using namespace std; diff --git a/src/orbit/Apertures/PhaseAperture.cc b/src/orbit/Apertures/PhaseAperture.cc index 9f87726d..a5811ee5 100644 --- a/src/orbit/Apertures/PhaseAperture.cc +++ b/src/orbit/Apertures/PhaseAperture.cc @@ -20,16 +20,16 @@ /////////////////////////////////////////////////////////////////////////// -#include "PhaseAperture.hh" -#include "SyncPart.hh" -#include "OrbitConst.hh" +#include "orbit/Apertures/PhaseAperture.hh" +#include "orbit/SyncPart.hh" +#include "orbit/OrbitConst.hh" #include #include #include #include -#include "ParticleAttributes.hh" +#include "orbit/ParticlesAttributes/ParticleAttributes.hh" /** The PhaseAperture class constructor. It needs the RF frequency in Hz to translate diff --git a/src/orbit/Apertures/PhaseAperture.hh b/src/orbit/Apertures/PhaseAperture.hh index a7471856..98570f5e 100644 --- a/src/orbit/Apertures/PhaseAperture.hh +++ b/src/orbit/Apertures/PhaseAperture.hh @@ -22,8 +22,8 @@ /////////////////////////////////////////////////////////////////////////// //pyORBIT utils -#include "CppPyWrapper.hh" -#include "Bunch.hh" +#include "utils/CppPyWrapper.hh" +#include "orbit/Bunch.hh" using namespace std; diff --git a/src/orbit/Apertures/PyBaseApertureShape.cc b/src/orbit/Apertures/PyBaseApertureShape.cc index 876424dd..6f8fcc89 100644 --- a/src/orbit/Apertures/PyBaseApertureShape.cc +++ b/src/orbit/Apertures/PyBaseApertureShape.cc @@ -1,4 +1,4 @@ -#include "PyBaseApertureShape.hh" +#include "orbit/Apertures/PyBaseApertureShape.hh" #include #include diff --git a/src/orbit/Apertures/PyBaseApertureShape.hh b/src/orbit/Apertures/PyBaseApertureShape.hh index 9fa6d06c..e8098c47 100644 --- a/src/orbit/Apertures/PyBaseApertureShape.hh +++ b/src/orbit/Apertures/PyBaseApertureShape.hh @@ -2,10 +2,10 @@ #define PY_BASE_APERTURE_SHAPE_H //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" -#include "Bunch.hh" -#include "BaseApertureShape.hh" +#include "orbit/Bunch.hh" +#include "orbit/Apertures/BaseApertureShape.hh" using namespace std; diff --git a/src/orbit/Apertures/RectangularApertureShape.cc b/src/orbit/Apertures/RectangularApertureShape.cc index 0518ee34..61253fa4 100644 --- a/src/orbit/Apertures/RectangularApertureShape.cc +++ b/src/orbit/Apertures/RectangularApertureShape.cc @@ -1,4 +1,4 @@ -#include "RectangularApertureShape.hh" +#include "orbit/Apertures/RectangularApertureShape.hh" #include #include diff --git a/src/orbit/Apertures/RectangularApertureShape.hh b/src/orbit/Apertures/RectangularApertureShape.hh index dd746658..28ce0b7c 100644 --- a/src/orbit/Apertures/RectangularApertureShape.hh +++ b/src/orbit/Apertures/RectangularApertureShape.hh @@ -2,10 +2,10 @@ #define RECTANGULAR_APERTURE_SHAPE_H //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" -#include "Bunch.hh" -#include "BaseApertureShape.hh" +#include "orbit/Bunch.hh" +#include "orbit/Apertures/BaseApertureShape.hh" using namespace std; diff --git a/src/orbit/Apertures/wrap_BaseAperture.cc b/src/orbit/Apertures/wrap_BaseAperture.cc index 64ae2387..4132af25 100644 --- a/src/orbit/Apertures/wrap_BaseAperture.cc +++ b/src/orbit/Apertures/wrap_BaseAperture.cc @@ -1,12 +1,12 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_bunch.hh" +#include "orbit/wrap_bunch.hh" #include -#include "BaseAperture.hh" -#include "BaseApertureShape.hh" +#include "orbit/Apertures/BaseAperture.hh" +#include "orbit/Apertures/BaseApertureShape.hh" namespace wrap_base_aperture{ diff --git a/src/orbit/Apertures/wrap_CompositeApertureShape.cc b/src/orbit/Apertures/wrap_CompositeApertureShape.cc index 3bff3478..7735cb48 100644 --- a/src/orbit/Apertures/wrap_CompositeApertureShape.cc +++ b/src/orbit/Apertures/wrap_CompositeApertureShape.cc @@ -1,11 +1,11 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_bunch.hh" +#include "orbit/wrap_bunch.hh" #include -#include "CompositeApertureShape.hh" +#include "orbit/Apertures/CompositeApertureShape.hh" namespace wrap_py_composite_aperture_shape{ diff --git a/src/orbit/Apertures/wrap_ConvexApertureShape.cc b/src/orbit/Apertures/wrap_ConvexApertureShape.cc index f316fb30..5c27656f 100644 --- a/src/orbit/Apertures/wrap_ConvexApertureShape.cc +++ b/src/orbit/Apertures/wrap_ConvexApertureShape.cc @@ -1,11 +1,11 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_bunch.hh" +#include "orbit/wrap_bunch.hh" #include -#include "ConvexApertureShape.hh" +#include "orbit/Apertures/ConvexApertureShape.hh" namespace wrap_convex_aperture_shape{ diff --git a/src/orbit/Apertures/wrap_EnergyAperture.cc b/src/orbit/Apertures/wrap_EnergyAperture.cc index 238e388d..d1dfc47f 100644 --- a/src/orbit/Apertures/wrap_EnergyAperture.cc +++ b/src/orbit/Apertures/wrap_EnergyAperture.cc @@ -1,12 +1,12 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_aperture.hh" -#include "wrap_bunch.hh" +#include "orbit/Apertures/wrap_aperture.hh" +#include "orbit/wrap_bunch.hh" #include -#include "EnergyAperture.hh" +#include "orbit/Apertures/EnergyAperture.hh" namespace wrap_energy_aperture{ diff --git a/src/orbit/Apertures/wrap_PhaseAperture.cc b/src/orbit/Apertures/wrap_PhaseAperture.cc index d6d03518..51172fee 100644 --- a/src/orbit/Apertures/wrap_PhaseAperture.cc +++ b/src/orbit/Apertures/wrap_PhaseAperture.cc @@ -1,12 +1,12 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_aperture.hh" -#include "wrap_bunch.hh" +#include "orbit/Apertures/wrap_aperture.hh" +#include "orbit/wrap_bunch.hh" #include -#include "PhaseAperture.hh" +#include "orbit/Apertures/PhaseAperture.hh" namespace wrap_phase_aperture{ diff --git a/src/orbit/Apertures/wrap_PrimitiveApertureShape.cc b/src/orbit/Apertures/wrap_PrimitiveApertureShape.cc index 84359118..f5c94a1e 100644 --- a/src/orbit/Apertures/wrap_PrimitiveApertureShape.cc +++ b/src/orbit/Apertures/wrap_PrimitiveApertureShape.cc @@ -1,13 +1,13 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_bunch.hh" +#include "orbit/wrap_bunch.hh" #include -#include "CircleApertureShape.hh" -#include "EllipseApertureShape.hh" -#include "RectangularApertureShape.hh" +#include "orbit/Apertures/CircleApertureShape.hh" +#include "orbit/Apertures/EllipseApertureShape.hh" +#include "orbit/Apertures/RectangularApertureShape.hh" namespace wrap_py_base_aperture_shape{ diff --git a/src/orbit/Apertures/wrap_PyBaseApertureShape.cc b/src/orbit/Apertures/wrap_PyBaseApertureShape.cc index 1c51be6c..756b0a56 100644 --- a/src/orbit/Apertures/wrap_PyBaseApertureShape.cc +++ b/src/orbit/Apertures/wrap_PyBaseApertureShape.cc @@ -1,11 +1,11 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_bunch.hh" +#include "orbit/wrap_bunch.hh" #include -#include "PyBaseApertureShape.hh" +#include "orbit/Apertures/PyBaseApertureShape.hh" namespace wrap_py_base_aperture_shape{ diff --git a/src/orbit/Apertures/wrap_TAperture.cc b/src/orbit/Apertures/wrap_TAperture.cc index 4017b25d..473aaa40 100644 --- a/src/orbit/Apertures/wrap_TAperture.cc +++ b/src/orbit/Apertures/wrap_TAperture.cc @@ -1,12 +1,12 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_aperture.hh" -#include "wrap_bunch.hh" +#include "orbit/Apertures/wrap_aperture.hh" +#include "orbit/wrap_bunch.hh" #include -#include "Aperture.hh" +#include "orbit/Apertures/Aperture.hh" namespace wrap_aperture{ diff --git a/src/orbit/Apertures/wrap_aperture.cc b/src/orbit/Apertures/wrap_aperture.cc index da663cd9..33375937 100644 --- a/src/orbit/Apertures/wrap_aperture.cc +++ b/src/orbit/Apertures/wrap_aperture.cc @@ -1,18 +1,18 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_aperture.hh" +#include "orbit/Apertures/wrap_aperture.hh" -#include "wrap_TAperture.hh" -#include "wrap_PhaseAperture.hh" -#include "wrap_EnergyAperture.hh" -#include "wrap_BaseAperture.hh" -#include "wrap_PyBaseApertureShape.hh" -#include "wrap_PrimitiveApertureShape.hh" -#include "wrap_CompositeApertureShape.hh" -#include "wrap_ConvexApertureShape.hh" +#include "orbit/Apertures/wrap_TAperture.hh" +#include "orbit/Apertures/wrap_PhaseAperture.hh" +#include "orbit/Apertures/wrap_EnergyAperture.hh" +#include "orbit/Apertures/wrap_BaseAperture.hh" +#include "orbit/Apertures/wrap_PyBaseApertureShape.hh" +#include "orbit/Apertures/wrap_PrimitiveApertureShape.hh" +#include "orbit/Apertures/wrap_CompositeApertureShape.hh" +#include "orbit/Apertures/wrap_ConvexApertureShape.hh" -#include "wrap_bunch.hh" +#include "orbit/wrap_bunch.hh" #include diff --git a/src/orbit/Bunch.cc b/src/orbit/Bunch.cc index 590f13c2..bdb64c99 100644 --- a/src/orbit/Bunch.cc +++ b/src/orbit/Bunch.cc @@ -14,12 +14,12 @@ // /////////////////////////////////////////////////////////////////////////// -#include "Bunch.hh" +#include "orbit/Bunch.hh" -#include "ParticleAttributesFactory.hh" -#include "OrbitConst.hh" -#include "StringUtils.hh" -#include "BufferStore.hh" +#include "orbit/ParticlesAttributes/ParticleAttributesFactory.hh" +#include "orbit/OrbitConst.hh" +#include "utils/StringUtils.hh" +#include "utils/BufferStore.hh" #include #include diff --git a/src/orbit/Bunch.hh b/src/orbit/Bunch.hh index f5cd0a0b..76b23c12 100644 --- a/src/orbit/Bunch.hh +++ b/src/orbit/Bunch.hh @@ -20,7 +20,7 @@ // INCLUDE FILES // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include @@ -29,12 +29,12 @@ #include #include -#include "ParticleAttributes.hh" -#include "SyncPart.hh" +#include "orbit/ParticlesAttributes/ParticleAttributes.hh" +#include "orbit/SyncPart.hh" //from utils -#include "AttributesBucket.hh" -#include "CppPyWrapper.hh" +#include "utils/AttributesBucket.hh" +#include "utils/CppPyWrapper.hh" #ifndef BUNCH_H #define BUNCH_H diff --git a/src/orbit/BunchDiagnostics/BunchTuneAnalysis.cc b/src/orbit/BunchDiagnostics/BunchTuneAnalysis.cc index 659b58a6..957c099f 100644 --- a/src/orbit/BunchDiagnostics/BunchTuneAnalysis.cc +++ b/src/orbit/BunchDiagnostics/BunchTuneAnalysis.cc @@ -1,6 +1,6 @@ -#include "BunchTuneAnalysis.hh" -#include "SyncPart.hh" -#include "OrbitConst.hh" +#include "orbit/BunchDiagnostics/BunchTuneAnalysis.hh" +#include "orbit/SyncPart.hh" +#include "orbit/OrbitConst.hh" #include #include diff --git a/src/orbit/BunchDiagnostics/BunchTuneAnalysis.hh b/src/orbit/BunchDiagnostics/BunchTuneAnalysis.hh index 84b137b0..d68d1b31 100644 --- a/src/orbit/BunchDiagnostics/BunchTuneAnalysis.hh +++ b/src/orbit/BunchDiagnostics/BunchTuneAnalysis.hh @@ -1,10 +1,11 @@ #ifndef BUNCH_TUNE_ANALYSIS_H #define BUNCH_TUNE_ANALYSIS_H -#include "CppPyWrapper.hh" +//pyORBIT utils +#include "utils/CppPyWrapper.hh" -#include "Bunch.hh" -#include "BunchTwissAnalysis.hh" +#include "orbit/Bunch.hh" +#include "orbit/BunchDiagnostics/BunchTwissAnalysis.hh" using namespace std; diff --git a/src/orbit/BunchDiagnostics/BunchTwissAnalysis.cc b/src/orbit/BunchDiagnostics/BunchTwissAnalysis.cc index 8fea7169..7deb2ada 100644 --- a/src/orbit/BunchDiagnostics/BunchTwissAnalysis.cc +++ b/src/orbit/BunchDiagnostics/BunchTwissAnalysis.cc @@ -1,12 +1,12 @@ -#include "BunchTwissAnalysis.hh" +#include "orbit/BunchDiagnostics/BunchTwissAnalysis.hh" #include #include #include #include -#include "ParticleMacroSize.hh" -#include "SyncPart.hh" +#include "orbit/ParticlesAttributes/ParticleMacroSize.hh" +#include "orbit/SyncPart.hh" /** Constructor */ BunchTwissAnalysis::BunchTwissAnalysis(): CppPyWrapper(NULL) diff --git a/src/orbit/BunchDiagnostics/BunchTwissAnalysis.hh b/src/orbit/BunchDiagnostics/BunchTwissAnalysis.hh index deaa20ee..e328ffb7 100644 --- a/src/orbit/BunchDiagnostics/BunchTwissAnalysis.hh +++ b/src/orbit/BunchDiagnostics/BunchTwissAnalysis.hh @@ -2,9 +2,9 @@ #define BUNCH_TWISS_ANALYSIS_H //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" -#include "Bunch.hh" +#include "orbit/Bunch.hh" using namespace std; diff --git a/src/orbit/BunchDiagnostics/wrap_bunch_tune_analysis.cc b/src/orbit/BunchDiagnostics/wrap_bunch_tune_analysis.cc index 3adeff0a..23499104 100644 --- a/src/orbit/BunchDiagnostics/wrap_bunch_tune_analysis.cc +++ b/src/orbit/BunchDiagnostics/wrap_bunch_tune_analysis.cc @@ -1,12 +1,12 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_bunch_tune_analysis.hh" -#include "wrap_bunch.hh" +#include "orbit/BunchDiagnostics/wrap_bunch_tune_analysis.hh" +#include "orbit/wrap_bunch.hh" #include -#include "BunchTuneAnalysis.hh" +#include "orbit/BunchDiagnostics/BunchTuneAnalysis.hh" namespace wrap_bunch_tune_analysis{ diff --git a/src/orbit/BunchDiagnostics/wrap_bunch_twiss_analysis.cc b/src/orbit/BunchDiagnostics/wrap_bunch_twiss_analysis.cc index ca3efe39..5a227741 100644 --- a/src/orbit/BunchDiagnostics/wrap_bunch_twiss_analysis.cc +++ b/src/orbit/BunchDiagnostics/wrap_bunch_twiss_analysis.cc @@ -1,12 +1,12 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_bunch_twiss_analysis.hh" -#include "wrap_bunch.hh" +#include "orbit/BunchDiagnostics/wrap_bunch_twiss_analysis.hh" +#include "orbit/wrap_bunch.hh" #include -#include "BunchTwissAnalysis.hh" +#include "orbit/BunchDiagnostics/BunchTwissAnalysis.hh" namespace wrap_bunch_twiss_analysis{ diff --git a/src/orbit/Errors/errorbase.cc b/src/orbit/Errors/errorbase.cc index 07fb506f..7a35cee4 100644 --- a/src/orbit/Errors/errorbase.cc +++ b/src/orbit/Errors/errorbase.cc @@ -22,11 +22,11 @@ // ///////////////////////////////////////////////////////////////////////////// -#include "errorbase.hh" -#include "teapotbase.hh" -#include "OrbitConst.hh" -#include "SyncPart.hh" -#include "Random.hh" +#include "orbit/Errors/errorbase.hh" +#include "teapot/teapotbase.hh" +#include "orbit/OrbitConst.hh" +#include "orbit/SyncPart.hh" +#include "utils/Random.hh" #include #include diff --git a/src/orbit/Errors/errorbase.hh b/src/orbit/Errors/errorbase.hh index 6cb82b70..a22e0865 100644 --- a/src/orbit/Errors/errorbase.hh +++ b/src/orbit/Errors/errorbase.hh @@ -18,7 +18,7 @@ #ifndef ERROR_BASE_H #define ERROR_BASE_H -#include "Bunch.hh" +#include "orbit/Bunch.hh" namespace error_base { diff --git a/src/orbit/Errors/wrap_errorbase.cc b/src/orbit/Errors/wrap_errorbase.cc index 186d5e8c..f533ed2f 100644 --- a/src/orbit/Errors/wrap_errorbase.cc +++ b/src/orbit/Errors/wrap_errorbase.cc @@ -1,11 +1,11 @@ #include -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "main/pyORBIT_Object.hh" -#include "errorbase.hh" +#include "orbit/Errors/errorbase.hh" -#include "wrap_errorbase.hh" +#include "orbit/Errors/wrap_errorbase.hh" namespace wrap_errorbase { diff --git a/src/orbit/FieldTracker/FieldTracker.cc b/src/orbit/FieldTracker/FieldTracker.cc index 02a4bd23..78ea8017 100644 --- a/src/orbit/FieldTracker/FieldTracker.cc +++ b/src/orbit/FieldTracker/FieldTracker.cc @@ -1,12 +1,12 @@ -#include "FieldTracker.hh" +#include "orbit/FieldTracker/FieldTracker.hh" #include #include #include #include #include -#include "OrbitConst.hh" -#include "SyncPart.hh" +#include "orbit/OrbitConst.hh" +#include "orbit/SyncPart.hh" ////////////////////////////////////////////////////////////////////////// //Constructor for FieldTracker diff --git a/src/orbit/FieldTracker/FieldTracker.hh b/src/orbit/FieldTracker/FieldTracker.hh index 06ac3cc2..2042d7c9 100644 --- a/src/orbit/FieldTracker/FieldTracker.hh +++ b/src/orbit/FieldTracker/FieldTracker.hh @@ -4,9 +4,9 @@ #define FIELDTRACKER_H //pyORBIT utils -#include "CppPyWrapper.hh" -#include "Bunch.hh" -#include "Grid3D.hh" +#include "utils/CppPyWrapper.hh" +#include "orbit/Bunch.hh" +#include "spacecharge/Grid3D.hh" using namespace std; diff --git a/src/orbit/FieldTracker/wrap_fieldtracker.cc b/src/orbit/FieldTracker/wrap_fieldtracker.cc index 9e6f2107..9f5efb7e 100644 --- a/src/orbit/FieldTracker/wrap_fieldtracker.cc +++ b/src/orbit/FieldTracker/wrap_fieldtracker.cc @@ -1,13 +1,13 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" -#include "wrap_fieldtracker.hh" -#include "wrap_bunch.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" +#include "orbit/FieldTracker/wrap_fieldtracker.hh" +#include "orbit/wrap_bunch.hh" #include -#include "FieldTracker.hh" +#include "orbit/FieldTracker/FieldTracker.hh" -#include "wrap_fieldtracker.hh" +#include "orbit/FieldTracker/wrap_fieldtracker.hh" namespace wrap_fieldtracker{ diff --git a/src/orbit/Impedances/LImpedance.cc b/src/orbit/Impedances/LImpedance.cc index c2f95e1d..b382f1aa 100644 --- a/src/orbit/Impedances/LImpedance.cc +++ b/src/orbit/Impedances/LImpedance.cc @@ -11,10 +11,10 @@ // ///////////////////////////////////////////////////////////////////////////// -#include "Grid1D.hh" -#include "BufferStore.hh" -#include "LImpedance.hh" -#include "OrbitConst.hh" +#include "spacecharge/Grid1D.hh" +#include "utils/BufferStore.hh" +#include "orbit/Impedances/LImpedance.hh" +#include "orbit/OrbitConst.hh" #include #include #include diff --git a/src/orbit/Impedances/LImpedance.hh b/src/orbit/Impedances/LImpedance.hh index 16f48839..0aa7ae0b 100644 --- a/src/orbit/Impedances/LImpedance.hh +++ b/src/orbit/Impedances/LImpedance.hh @@ -4,19 +4,19 @@ #define LIMPEDANCE_H //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include #include //ORBIT bunch -#include "Bunch.hh" +#include "orbit/Bunch.hh" //pyORBIT utils -#include "CppPyWrapper.hh" -#include "BunchExtremaCalculator.hh" -#include "Grid1D.hh" +#include "utils/CppPyWrapper.hh" +#include "utils/bunch/BunchExtremaCalculator.hh" +#include "spacecharge/Grid1D.hh" //FFTW library header #include "fftw3.h" diff --git a/src/orbit/Impedances/TImpedance.cc b/src/orbit/Impedances/TImpedance.cc index b6031982..c73a221f 100644 --- a/src/orbit/Impedances/TImpedance.cc +++ b/src/orbit/Impedances/TImpedance.cc @@ -10,10 +10,10 @@ // ///////////////////////////////////////////////////////////////////////////// -#include "Grid1D.hh" -#include "BufferStore.hh" -#include "TImpedance.hh" -#include "OrbitConst.hh" +#include "spacecharge/Grid1D.hh" +#include "utils/BufferStore.hh" +#include "orbit/Impedances/TImpedance.hh" +#include "orbit/OrbitConst.hh" #include #include #include diff --git a/src/orbit/Impedances/TImpedance.hh b/src/orbit/Impedances/TImpedance.hh index 4e87e579..48767723 100644 --- a/src/orbit/Impedances/TImpedance.hh +++ b/src/orbit/Impedances/TImpedance.hh @@ -4,19 +4,19 @@ #define TIMPEDANCE_H //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include #include //ORBIT bunch -#include "Bunch.hh" +#include "orbit/Bunch.hh" //pyORBIT utils -#include "CppPyWrapper.hh" -#include "BunchExtremaCalculator.hh" -#include "Grid1D.hh" +#include "utils/CppPyWrapper.hh" +#include "utils/bunch/BunchExtremaCalculator.hh" +#include "spacecharge/Grid1D.hh" //FFTW library header #include "fftw3.h" diff --git a/src/orbit/Impedances/wrap_LImpedance.cc b/src/orbit/Impedances/wrap_LImpedance.cc index fb3e00b9..f1490c15 100644 --- a/src/orbit/Impedances/wrap_LImpedance.cc +++ b/src/orbit/Impedances/wrap_LImpedance.cc @@ -1,12 +1,12 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_LImpedance.hh" -#include "wrap_bunch.hh" +#include "orbit/Impedances/wrap_LImpedance.hh" +#include "orbit/wrap_bunch.hh" #include -#include "LImpedance.hh" +#include "orbit/Impedances/LImpedance.hh" using namespace OrbitUtils; diff --git a/src/orbit/Impedances/wrap_TImpedance.cc b/src/orbit/Impedances/wrap_TImpedance.cc index 119c8965..e177d3c9 100644 --- a/src/orbit/Impedances/wrap_TImpedance.cc +++ b/src/orbit/Impedances/wrap_TImpedance.cc @@ -1,12 +1,12 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_TImpedance.hh" -#include "wrap_bunch.hh" +#include "orbit/Impedances/wrap_TImpedance.hh" +#include "orbit/wrap_bunch.hh" #include -#include "TImpedance.hh" +#include "orbit/Impedances/TImpedance.hh" using namespace OrbitUtils; diff --git a/src/orbit/Impedances/wrap_impedances.cc b/src/orbit/Impedances/wrap_impedances.cc index 16293211..95d85a93 100644 --- a/src/orbit/Impedances/wrap_impedances.cc +++ b/src/orbit/Impedances/wrap_impedances.cc @@ -1,7 +1,7 @@ -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" -#include "wrap_LImpedance.hh" -#include "wrap_TImpedance.hh" +#include "orbit/Impedances/wrap_LImpedance.hh" +#include "orbit/Impedances/wrap_TImpedance.hh" static PyMethodDef impedancesMethods[] = {{NULL,NULL}}; diff --git a/src/orbit/MaterialInteractions/Collimator.cc b/src/orbit/MaterialInteractions/Collimator.cc index a4d88b94..0c21a2e2 100644 --- a/src/orbit/MaterialInteractions/Collimator.cc +++ b/src/orbit/MaterialInteractions/Collimator.cc @@ -1,17 +1,17 @@ -#include "MaterialInteractions.hh" -#include "Collimator.hh" -#include "SyncPart.hh" -#include "cross_sections.hh" -#include "numrecipes.hh" -#include "OrbitConst.hh" -#include "Random.hh" +#include "orbit/MaterialInteractions/MaterialInteractions.hh" +#include "orbit/MaterialInteractions/Collimator.hh" +#include "orbit/SyncPart.hh" +#include "orbit/MaterialInteractions/cross_sections.hh" +#include "orbit/MaterialInteractions/numrecipes.hh" +#include "orbit/OrbitConst.hh" +#include "utils/Random.hh" #include #include #include #include -#include "ParticleInitialCoordinates.hh" +#include "orbit/ParticlesAttributes/ParticleInitialCoordinates.hh" using namespace OrbitUtils; diff --git a/src/orbit/MaterialInteractions/Collimator.hh b/src/orbit/MaterialInteractions/Collimator.hh index 6cd57395..f766e698 100644 --- a/src/orbit/MaterialInteractions/Collimator.hh +++ b/src/orbit/MaterialInteractions/Collimator.hh @@ -3,8 +3,8 @@ #define COLLIMATOR_H //pyORBIT utils -#include "CppPyWrapper.hh" -#include "Bunch.hh" +#include "utils/CppPyWrapper.hh" +#include "orbit/Bunch.hh" using namespace std; diff --git a/src/orbit/MaterialInteractions/Foil.cc b/src/orbit/MaterialInteractions/Foil.cc index a0eaa2b9..5dec4257 100644 --- a/src/orbit/MaterialInteractions/Foil.cc +++ b/src/orbit/MaterialInteractions/Foil.cc @@ -1,17 +1,17 @@ -#include "MaterialInteractions.hh" -#include "Foil.hh" -#include "SyncPart.hh" -#include "cross_sections.hh" -#include "numrecipes.hh" -#include "OrbitConst.hh" -#include "Random.hh" +#include "orbit/MaterialInteractions/MaterialInteractions.hh" +#include "orbit/MaterialInteractions/Foil.hh" +#include "orbit/SyncPart.hh" +#include "orbit/MaterialInteractions/cross_sections.hh" +#include "orbit/MaterialInteractions/numrecipes.hh" +#include "orbit/OrbitConst.hh" +#include "utils/Random.hh" #include #include #include #include -#include "ParticleInitialCoordinates.hh" +#include "orbit/ParticlesAttributes/ParticleInitialCoordinates.hh" using namespace OrbitUtils; diff --git a/src/orbit/MaterialInteractions/Foil.hh b/src/orbit/MaterialInteractions/Foil.hh index 3b2052ae..faac4f3e 100644 --- a/src/orbit/MaterialInteractions/Foil.hh +++ b/src/orbit/MaterialInteractions/Foil.hh @@ -3,8 +3,8 @@ #define FOIL_H //pyORBIT utils -#include "CppPyWrapper.hh" -#include "Bunch.hh" +#include "utils/CppPyWrapper.hh" +#include "orbit/Bunch.hh" using namespace std; diff --git a/src/orbit/MaterialInteractions/MaterialInteractions.cc b/src/orbit/MaterialInteractions/MaterialInteractions.cc index 362114c8..914418f7 100644 --- a/src/orbit/MaterialInteractions/MaterialInteractions.cc +++ b/src/orbit/MaterialInteractions/MaterialInteractions.cc @@ -13,10 +13,10 @@ // A class for storing hadron material interaction methods. // /////////////////////////////////////////////////////////////////////////// -#include "MaterialInteractions.hh" -#include "OrbitConst.hh" -#include "Random.hh" -#include "bessel.hh" +#include "orbit/MaterialInteractions/MaterialInteractions.hh" +#include "orbit/OrbitConst.hh" +#include "utils/Random.hh" +#include "utils/bessel.hh" #include #include diff --git a/src/orbit/MaterialInteractions/MaterialInteractions.hh b/src/orbit/MaterialInteractions/MaterialInteractions.hh index 14e05375..09a08ee2 100644 --- a/src/orbit/MaterialInteractions/MaterialInteractions.hh +++ b/src/orbit/MaterialInteractions/MaterialInteractions.hh @@ -2,7 +2,7 @@ #define MATERIAL_INTERACTIONS_H //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" using namespace std; diff --git a/src/orbit/MaterialInteractions/cross_sections.cc b/src/orbit/MaterialInteractions/cross_sections.cc index 8312eaa5..4cb292c3 100644 --- a/src/orbit/MaterialInteractions/cross_sections.cc +++ b/src/orbit/MaterialInteractions/cross_sections.cc @@ -2,7 +2,7 @@ #include #include #include -#include "cross_sections.hh" +#include "orbit/MaterialInteractions/cross_sections.hh" namespace OrbitUtils{ diff --git a/src/orbit/MaterialInteractions/numrecipes.cc b/src/orbit/MaterialInteractions/numrecipes.cc index a38dd327..1434f870 100644 --- a/src/orbit/MaterialInteractions/numrecipes.cc +++ b/src/orbit/MaterialInteractions/numrecipes.cc @@ -2,7 +2,7 @@ #include #include #include -#include "numrecipes.hh" +#include "orbit/MaterialInteractions/numrecipes.hh" namespace OrbitUtils{ diff --git a/src/orbit/MaterialInteractions/wrap_collimator.cc b/src/orbit/MaterialInteractions/wrap_collimator.cc index 444b8e24..91817b8c 100644 --- a/src/orbit/MaterialInteractions/wrap_collimator.cc +++ b/src/orbit/MaterialInteractions/wrap_collimator.cc @@ -1,12 +1,12 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_collimator.hh" -#include "wrap_bunch.hh" +#include "orbit/MaterialInteractions/wrap_collimator.hh" +#include "orbit/wrap_bunch.hh" #include -#include "Collimator.hh" +#include "orbit/MaterialInteractions/Collimator.hh" namespace wrap_collimator{ diff --git a/src/orbit/MaterialInteractions/wrap_foil.cc b/src/orbit/MaterialInteractions/wrap_foil.cc index 3d9398a9..160a0541 100644 --- a/src/orbit/MaterialInteractions/wrap_foil.cc +++ b/src/orbit/MaterialInteractions/wrap_foil.cc @@ -1,12 +1,12 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_foil.hh" -#include "wrap_bunch.hh" +#include "orbit/MaterialInteractions/wrap_foil.hh" +#include "orbit/wrap_bunch.hh" #include -#include "Foil.hh" +#include "orbit/MaterialInteractions/Foil.hh" namespace wrap_foil{ diff --git a/src/orbit/OrbitConst.cc b/src/orbit/OrbitConst.cc index f57a4a40..b9e9c9ca 100644 --- a/src/orbit/OrbitConst.cc +++ b/src/orbit/OrbitConst.cc @@ -21,7 +21,7 @@ ///////////////////////////////////////////////////////////////////////////// -#include "OrbitConst.hh" +#include "orbit/OrbitConst.hh" const double OrbitConst::PI = 3.14159265358979323846264; const double OrbitConst::c = 2.99792458e+8; diff --git a/src/orbit/ParticlesAttributes/AtomPopulations.cc b/src/orbit/ParticlesAttributes/AtomPopulations.cc index f4617c09..2fd4fbfe 100644 --- a/src/orbit/ParticlesAttributes/AtomPopulations.cc +++ b/src/orbit/ParticlesAttributes/AtomPopulations.cc @@ -16,8 +16,8 @@ // /////////////////////////////////////////////////////////////////////////// -#include "../Bunch.hh" -#include "AtomPopulations.hh" +#include "orbit/Bunch.hh" +#include "orbit/ParticlesAttributes/AtomPopulations.hh" AtomPopulations::AtomPopulations(Bunch* bunch, int size_in): ParticleAttributes(bunch,size_in) diff --git a/src/orbit/ParticlesAttributes/AtomPopulations.hh b/src/orbit/ParticlesAttributes/AtomPopulations.hh index f94b2489..9e219f57 100644 --- a/src/orbit/ParticlesAttributes/AtomPopulations.hh +++ b/src/orbit/ParticlesAttributes/AtomPopulations.hh @@ -21,7 +21,7 @@ #include -#include "ParticleAttributes.hh" +#include "orbit/ParticlesAttributes/ParticleAttributes.hh" class AtomPopulations : public ParticleAttributes { diff --git a/src/orbit/ParticlesAttributes/Evolution.cc b/src/orbit/ParticlesAttributes/Evolution.cc index c9d4e2cf..e5c36488 100644 --- a/src/orbit/ParticlesAttributes/Evolution.cc +++ b/src/orbit/ParticlesAttributes/Evolution.cc @@ -16,8 +16,8 @@ // /////////////////////////////////////////////////////////////////////////// -#include "../Bunch.hh" -#include "Evolution.hh" +#include "orbit/Bunch.hh" +#include "orbit/ParticlesAttributes/Evolution.hh" Evolution::Evolution(Bunch* bunch, int size_in): ParticleAttributes(bunch,size_in) diff --git a/src/orbit/ParticlesAttributes/Evolution.hh b/src/orbit/ParticlesAttributes/Evolution.hh index 5fb71833..eb9ed07e 100644 --- a/src/orbit/ParticlesAttributes/Evolution.hh +++ b/src/orbit/ParticlesAttributes/Evolution.hh @@ -33,7 +33,7 @@ // WaveFunctionAmplitudes // /////////////////////////////////////////////////////////////////////////// -#include "ParticleAttributes.hh" +#include "orbit/ParticlesAttributes/ParticleAttributes.hh" class Evolution : public ParticleAttributes { diff --git a/src/orbit/ParticlesAttributes/LostParticleAttributes.cc b/src/orbit/ParticlesAttributes/LostParticleAttributes.cc index cf26a17e..5a0c67a2 100644 --- a/src/orbit/ParticlesAttributes/LostParticleAttributes.cc +++ b/src/orbit/ParticlesAttributes/LostParticleAttributes.cc @@ -15,8 +15,8 @@ // /////////////////////////////////////////////////////////////////////////// -#include "../Bunch.hh" -#include "LostParticleAttributes.hh" +#include "orbit/Bunch.hh" +#include "orbit/ParticlesAttributes/LostParticleAttributes.hh" LostParticleAttributes::LostParticleAttributes(Bunch* bunch): ParticleAttributes(bunch,1) diff --git a/src/orbit/ParticlesAttributes/LostParticleAttributes.hh b/src/orbit/ParticlesAttributes/LostParticleAttributes.hh index 774254aa..45727600 100644 --- a/src/orbit/ParticlesAttributes/LostParticleAttributes.hh +++ b/src/orbit/ParticlesAttributes/LostParticleAttributes.hh @@ -21,7 +21,7 @@ // INCLUDE FILES // /////////////////////////////////////////////////////////////////////////// -#include "ParticleAttributes.hh" +#include "orbit/ParticlesAttributes/ParticleAttributes.hh" class LostParticleAttributes : public ParticleAttributes { diff --git a/src/orbit/ParticlesAttributes/ParticleAttributes.cc b/src/orbit/ParticlesAttributes/ParticleAttributes.cc index e1779486..51f838d5 100644 --- a/src/orbit/ParticlesAttributes/ParticleAttributes.cc +++ b/src/orbit/ParticlesAttributes/ParticleAttributes.cc @@ -17,8 +17,8 @@ // /////////////////////////////////////////////////////////////////////////// -#include "../Bunch.hh" -#include "ParticleAttributes.hh" +#include "orbit/Bunch.hh" +#include "orbit/ParticlesAttributes/ParticleAttributes.hh" ParticleAttributes::ParticleAttributes(Bunch* bunch, int size_in) { diff --git a/src/orbit/ParticlesAttributes/ParticleAttributes.hh b/src/orbit/ParticlesAttributes/ParticleAttributes.hh index bff57fc1..6547aa5a 100644 --- a/src/orbit/ParticlesAttributes/ParticleAttributes.hh +++ b/src/orbit/ParticlesAttributes/ParticleAttributes.hh @@ -19,7 +19,7 @@ #ifndef PARTICLE_ATTRIBUTES_H #define PARTICLE_ATTRIBUTES_H -#include "../../mpi/orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include diff --git a/src/orbit/ParticlesAttributes/ParticleAttributesFactory.cc b/src/orbit/ParticlesAttributes/ParticleAttributesFactory.cc index 7939b3b1..4ac56098 100644 --- a/src/orbit/ParticlesAttributes/ParticleAttributesFactory.cc +++ b/src/orbit/ParticlesAttributes/ParticleAttributesFactory.cc @@ -15,19 +15,19 @@ // /////////////////////////////////////////////////////////////////////////// -#include "ParticleAttributesFactory.hh" - -#include "ParticleMacroSize.hh" -#include "WaveFunctionAmplitudes.hh" -#include "AtomPopulations.hh" -#include "pq_coordinates.hh" -#include "part_time.hh" -#include "Evolution.hh" -#include "LostParticleAttributes.hh" -#include "ParticlePhaseAttributes.hh" -#include "ParticleIdNumber.hh" -#include "ParticleInitialCoordinates.hh" -#include "TurnNumberAttributes.hh" +#include "orbit/ParticlesAttributes/ParticleAttributesFactory.hh" + +#include "orbit/ParticlesAttributes/ParticleMacroSize.hh" +#include "orbit/ParticlesAttributes/WaveFunctionAmplitudes.hh" +#include "orbit/ParticlesAttributes/AtomPopulations.hh" +#include "orbit/ParticlesAttributes/pq_coordinates.hh" +#include "orbit/ParticlesAttributes/part_time.hh" +#include "orbit/ParticlesAttributes/Evolution.hh" +#include "orbit/ParticlesAttributes/LostParticleAttributes.hh" +#include "orbit/ParticlesAttributes/ParticlePhaseAttributes.hh" +#include "orbit/ParticlesAttributes/ParticleIdNumber.hh" +#include "orbit/ParticlesAttributes/ParticleInitialCoordinates.hh" +#include "orbit/ParticlesAttributes/TurnNumberAttributes.hh" ParticleAttributesFactory::ParticleAttributesFactory() { diff --git a/src/orbit/ParticlesAttributes/ParticleAttributesFactory.hh b/src/orbit/ParticlesAttributes/ParticleAttributesFactory.hh index 3a72aedf..6b0b6121 100644 --- a/src/orbit/ParticlesAttributes/ParticleAttributesFactory.hh +++ b/src/orbit/ParticlesAttributes/ParticleAttributesFactory.hh @@ -28,9 +28,9 @@ // INCLUDE FILES // /////////////////////////////////////////////////////////////////////////// -#include "../Bunch.hh" +#include "orbit/Bunch.hh" -#include "ParticleAttributes.hh" +#include "orbit/ParticlesAttributes/ParticleAttributes.hh" /////////////////////////////////////////////////////////////////////////// // // CLASS NAME diff --git a/src/orbit/ParticlesAttributes/ParticleIdNumber.cc b/src/orbit/ParticlesAttributes/ParticleIdNumber.cc index a9431ab4..04916994 100644 --- a/src/orbit/ParticlesAttributes/ParticleIdNumber.cc +++ b/src/orbit/ParticlesAttributes/ParticleIdNumber.cc @@ -16,8 +16,8 @@ // /////////////////////////////////////////////////////////////////////////// -#include "../Bunch.hh" -#include "ParticleIdNumber.hh" +#include "orbit/Bunch.hh" +#include "orbit/ParticlesAttributes/ParticleIdNumber.hh" ParticleIdNumber::ParticleIdNumber(Bunch* bunch): ParticleAttributes(bunch,1) diff --git a/src/orbit/ParticlesAttributes/ParticleIdNumber.hh b/src/orbit/ParticlesAttributes/ParticleIdNumber.hh index 69fd79e5..ca2f2934 100644 --- a/src/orbit/ParticlesAttributes/ParticleIdNumber.hh +++ b/src/orbit/ParticlesAttributes/ParticleIdNumber.hh @@ -36,7 +36,7 @@ // ParticleIdNumber // /////////////////////////////////////////////////////////////////////////// -#include "ParticleAttributes.hh" +#include "orbit/ParticlesAttributes/ParticleAttributes.hh" class ParticleIdNumber : public ParticleAttributes { diff --git a/src/orbit/ParticlesAttributes/ParticleInitialCoordinates.cc b/src/orbit/ParticlesAttributes/ParticleInitialCoordinates.cc index 56d63685..b5c19331 100644 --- a/src/orbit/ParticlesAttributes/ParticleInitialCoordinates.cc +++ b/src/orbit/ParticlesAttributes/ParticleInitialCoordinates.cc @@ -23,8 +23,8 @@ // /////////////////////////////////////////////////////////////////////////// -#include "../Bunch.hh" -#include "ParticleInitialCoordinates.hh" +#include "orbit/Bunch.hh" +#include "orbit/ParticlesAttributes/ParticleInitialCoordinates.hh" ParticleInitialCoordinates::ParticleInitialCoordinates(Bunch* bunch): ParticleAttributes(bunch,6) diff --git a/src/orbit/ParticlesAttributes/ParticleInitialCoordinates.hh b/src/orbit/ParticlesAttributes/ParticleInitialCoordinates.hh index bc2032b2..cfc7d2c4 100644 --- a/src/orbit/ParticlesAttributes/ParticleInitialCoordinates.hh +++ b/src/orbit/ParticlesAttributes/ParticleInitialCoordinates.hh @@ -31,7 +31,7 @@ // /////////////////////////////////////////////////////////////////////////// #include -#include "ParticleAttributes.hh" +#include "orbit/ParticlesAttributes/ParticleAttributes.hh" class ParticleInitialCoordinates : public ParticleAttributes { diff --git a/src/orbit/ParticlesAttributes/ParticleMacroSize.cc b/src/orbit/ParticlesAttributes/ParticleMacroSize.cc index e182b5fc..4708e58d 100644 --- a/src/orbit/ParticlesAttributes/ParticleMacroSize.cc +++ b/src/orbit/ParticlesAttributes/ParticleMacroSize.cc @@ -16,8 +16,8 @@ // /////////////////////////////////////////////////////////////////////////// -#include "../Bunch.hh" -#include "ParticleMacroSize.hh" +#include "orbit/Bunch.hh" +#include "orbit/ParticlesAttributes/ParticleMacroSize.hh" ParticleMacroSize::ParticleMacroSize(Bunch* bunch): ParticleAttributes(bunch,1) diff --git a/src/orbit/ParticlesAttributes/ParticleMacroSize.hh b/src/orbit/ParticlesAttributes/ParticleMacroSize.hh index 7623d10d..c0697c56 100644 --- a/src/orbit/ParticlesAttributes/ParticleMacroSize.hh +++ b/src/orbit/ParticlesAttributes/ParticleMacroSize.hh @@ -17,9 +17,9 @@ #ifndef PARTICLE_MACROSIZE_H #define PARTICLE_MACROSIZE_H -#include "../../mpi/orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" -#include "ParticleAttributes.hh" +#include "orbit/ParticlesAttributes/ParticleAttributes.hh" #include diff --git a/src/orbit/ParticlesAttributes/ParticlePhaseAttributes.cc b/src/orbit/ParticlesAttributes/ParticlePhaseAttributes.cc index 1ec7fc8e..65fd9f7e 100644 --- a/src/orbit/ParticlesAttributes/ParticlePhaseAttributes.cc +++ b/src/orbit/ParticlesAttributes/ParticlePhaseAttributes.cc @@ -15,8 +15,8 @@ // /////////////////////////////////////////////////////////////////////////// -#include "../Bunch.hh" -#include "ParticlePhaseAttributes.hh" +#include "orbit/Bunch.hh" +#include "orbit/ParticlesAttributes/ParticlePhaseAttributes.hh" ParticlePhaseAttributes::ParticlePhaseAttributes(Bunch* bunch): ParticleAttributes(bunch,6) diff --git a/src/orbit/ParticlesAttributes/ParticlePhaseAttributes.hh b/src/orbit/ParticlesAttributes/ParticlePhaseAttributes.hh index 3e676992..edf91bf7 100644 --- a/src/orbit/ParticlesAttributes/ParticlePhaseAttributes.hh +++ b/src/orbit/ParticlesAttributes/ParticlePhaseAttributes.hh @@ -21,7 +21,7 @@ // INCLUDE FILES // /////////////////////////////////////////////////////////////////////////// -#include "ParticleAttributes.hh" +#include "orbit/ParticlesAttributes/ParticleAttributes.hh" class ParticlePhaseAttributes : public ParticleAttributes { diff --git a/src/orbit/ParticlesAttributes/TurnNumberAttributes.cc b/src/orbit/ParticlesAttributes/TurnNumberAttributes.cc index 4ae1d529..e3579791 100644 --- a/src/orbit/ParticlesAttributes/TurnNumberAttributes.cc +++ b/src/orbit/ParticlesAttributes/TurnNumberAttributes.cc @@ -21,8 +21,8 @@ // /////////////////////////////////////////////////////////////////////////// -#include "../Bunch.hh" -#include "TurnNumberAttributes.hh" +#include "orbit/Bunch.hh" +#include "orbit/ParticlesAttributes/TurnNumberAttributes.hh" TurnNumberAttributes::TurnNumberAttributes(Bunch* bunch): ParticleAttributes(bunch,1) diff --git a/src/orbit/ParticlesAttributes/TurnNumberAttributes.hh b/src/orbit/ParticlesAttributes/TurnNumberAttributes.hh index 36fcbe7c..d5012c1d 100644 --- a/src/orbit/ParticlesAttributes/TurnNumberAttributes.hh +++ b/src/orbit/ParticlesAttributes/TurnNumberAttributes.hh @@ -26,7 +26,7 @@ #include -#include "ParticleAttributes.hh" +#include "orbit/ParticlesAttributes/ParticleAttributes.hh" class TurnNumberAttributes : public ParticleAttributes { diff --git a/src/orbit/ParticlesAttributes/WaveFunctionAmplitudes.cc b/src/orbit/ParticlesAttributes/WaveFunctionAmplitudes.cc index 55c065cb..75aad7d8 100644 --- a/src/orbit/ParticlesAttributes/WaveFunctionAmplitudes.cc +++ b/src/orbit/ParticlesAttributes/WaveFunctionAmplitudes.cc @@ -15,8 +15,8 @@ // /////////////////////////////////////////////////////////////////////////// -#include "../Bunch.hh" -#include "WaveFunctionAmplitudes.hh" +#include "orbit/Bunch.hh" +#include "orbit/ParticlesAttributes/WaveFunctionAmplitudes.hh" WaveFunctionAmplitudes::WaveFunctionAmplitudes(Bunch* bunch, int size_in): ParticleAttributes(bunch, size_in) diff --git a/src/orbit/ParticlesAttributes/WaveFunctionAmplitudes.hh b/src/orbit/ParticlesAttributes/WaveFunctionAmplitudes.hh index 2c77e818..020c32fb 100644 --- a/src/orbit/ParticlesAttributes/WaveFunctionAmplitudes.hh +++ b/src/orbit/ParticlesAttributes/WaveFunctionAmplitudes.hh @@ -18,7 +18,7 @@ #include -#include "ParticleAttributes.hh" +#include "orbit/ParticlesAttributes/ParticleAttributes.hh" class WaveFunctionAmplitudes : public ParticleAttributes { diff --git a/src/orbit/ParticlesAttributes/part_time.cc b/src/orbit/ParticlesAttributes/part_time.cc index f0341e48..840c7f7c 100644 --- a/src/orbit/ParticlesAttributes/part_time.cc +++ b/src/orbit/ParticlesAttributes/part_time.cc @@ -16,8 +16,8 @@ // /////////////////////////////////////////////////////////////////////////// -#include "../Bunch.hh" -#include "part_time.hh" +#include "orbit/Bunch.hh" +#include "orbit/ParticlesAttributes/part_time.hh" part_time::part_time(Bunch* bunch, int size_in): ParticleAttributes(bunch,size_in) diff --git a/src/orbit/ParticlesAttributes/part_time.hh b/src/orbit/ParticlesAttributes/part_time.hh index 71ae8ae2..662e390d 100644 --- a/src/orbit/ParticlesAttributes/part_time.hh +++ b/src/orbit/ParticlesAttributes/part_time.hh @@ -36,7 +36,7 @@ // WaveFunctionAmplitudes // /////////////////////////////////////////////////////////////////////////// -#include "ParticleAttributes.hh" +#include "orbit/ParticlesAttributes/ParticleAttributes.hh" class part_time : public ParticleAttributes { diff --git a/src/orbit/ParticlesAttributes/pq_coordinates.cc b/src/orbit/ParticlesAttributes/pq_coordinates.cc index c00ed4dc..a8d89a48 100644 --- a/src/orbit/ParticlesAttributes/pq_coordinates.cc +++ b/src/orbit/ParticlesAttributes/pq_coordinates.cc @@ -15,8 +15,8 @@ // /////////////////////////////////////////////////////////////////////////// -#include "../Bunch.hh" -#include "pq_coordinates.hh" +#include "orbit/Bunch.hh" +#include "orbit/ParticlesAttributes/pq_coordinates.hh" pq_coordinates::pq_coordinates(Bunch* bunch, int size_in): ParticleAttributes(bunch,size_in) diff --git a/src/orbit/ParticlesAttributes/pq_coordinates.hh b/src/orbit/ParticlesAttributes/pq_coordinates.hh index 45439411..1d9fdbf8 100644 --- a/src/orbit/ParticlesAttributes/pq_coordinates.hh +++ b/src/orbit/ParticlesAttributes/pq_coordinates.hh @@ -23,7 +23,7 @@ /////////////////////////////////////////////////////////////////////////// #include -#include "ParticleAttributes.hh" +#include "orbit/ParticlesAttributes/ParticleAttributes.hh" class pq_coordinates : public ParticleAttributes { diff --git a/src/orbit/RFCavities/Barrier_Cav.cc b/src/orbit/RFCavities/Barrier_Cav.cc index 0a95ce5a..c6d25dee 100644 --- a/src/orbit/RFCavities/Barrier_Cav.cc +++ b/src/orbit/RFCavities/Barrier_Cav.cc @@ -1,11 +1,11 @@ -#include "Barrier_Cav.hh" -#include "ParticleMacroSize.hh" +#include "orbit/RFCavities/Barrier_Cav.hh" +#include "orbit/ParticlesAttributes/ParticleMacroSize.hh" #include #include -#include "Bunch.hh" -#include "OrbitConst.hh" +#include "orbit/Bunch.hh" +#include "orbit/OrbitConst.hh" using namespace OrbitUtils; diff --git a/src/orbit/RFCavities/Barrier_Cav.hh b/src/orbit/RFCavities/Barrier_Cav.hh index f3438b11..58099f29 100644 --- a/src/orbit/RFCavities/Barrier_Cav.hh +++ b/src/orbit/RFCavities/Barrier_Cav.hh @@ -2,16 +2,16 @@ #define BARRIER_CAV_H //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include //ORBIT bunch -#include "Bunch.hh" +#include "orbit/Bunch.hh" //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" using namespace std; diff --git a/src/orbit/RFCavities/Dual_Harmonic_Cav.cc b/src/orbit/RFCavities/Dual_Harmonic_Cav.cc index 610cbf57..c5785907 100644 --- a/src/orbit/RFCavities/Dual_Harmonic_Cav.cc +++ b/src/orbit/RFCavities/Dual_Harmonic_Cav.cc @@ -1,11 +1,11 @@ -#include "Dual_Harmonic_Cav.hh" -#include "ParticleMacroSize.hh" +#include "orbit/RFCavities/Dual_Harmonic_Cav.hh" +#include "orbit/ParticlesAttributes/ParticleMacroSize.hh" #include #include -#include "Bunch.hh" -#include "OrbitConst.hh" +#include "orbit/Bunch.hh" +#include "orbit/OrbitConst.hh" using namespace OrbitUtils; diff --git a/src/orbit/RFCavities/Dual_Harmonic_Cav.hh b/src/orbit/RFCavities/Dual_Harmonic_Cav.hh index 82be5096..ed42c68e 100644 --- a/src/orbit/RFCavities/Dual_Harmonic_Cav.hh +++ b/src/orbit/RFCavities/Dual_Harmonic_Cav.hh @@ -2,16 +2,16 @@ #define Dual_Harmonic_Cav_H //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include //ORBIT bunch -#include "Bunch.hh" +#include "orbit/Bunch.hh" //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" using namespace std; diff --git a/src/orbit/RFCavities/Frequency_Cav.cc b/src/orbit/RFCavities/Frequency_Cav.cc index 0777f449..8220e45b 100644 --- a/src/orbit/RFCavities/Frequency_Cav.cc +++ b/src/orbit/RFCavities/Frequency_Cav.cc @@ -1,12 +1,12 @@ -#include "Frequency_Cav.hh" -#include "ParticleMacroSize.hh" +#include "orbit/RFCavities/Frequency_Cav.hh" +#include "orbit/ParticlesAttributes/ParticleMacroSize.hh" #include #include -#include "Bunch.hh" -#include "bessel.hh" -#include "OrbitConst.hh" +#include "orbit/Bunch.hh" +#include "utils/bessel.hh" +#include "orbit/OrbitConst.hh" using namespace OrbitUtils; diff --git a/src/orbit/RFCavities/Frequency_Cav.hh b/src/orbit/RFCavities/Frequency_Cav.hh index 1b12dce1..223a91b9 100644 --- a/src/orbit/RFCavities/Frequency_Cav.hh +++ b/src/orbit/RFCavities/Frequency_Cav.hh @@ -2,16 +2,16 @@ #define FREQUENCY_CAV_H //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include //ORBIT bunch -#include "Bunch.hh" +#include "orbit/Bunch.hh" //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" using namespace std; diff --git a/src/orbit/RFCavities/Harmonic_Cav.cc b/src/orbit/RFCavities/Harmonic_Cav.cc index 8b893235..60a85719 100644 --- a/src/orbit/RFCavities/Harmonic_Cav.cc +++ b/src/orbit/RFCavities/Harmonic_Cav.cc @@ -1,11 +1,11 @@ -#include "Harmonic_Cav.hh" -#include "ParticleMacroSize.hh" +#include "orbit/RFCavities/Harmonic_Cav.hh" +#include "orbit/ParticlesAttributes/ParticleMacroSize.hh" #include #include -#include "Bunch.hh" -#include "OrbitConst.hh" +#include "orbit/Bunch.hh" +#include "orbit/OrbitConst.hh" using namespace OrbitUtils; diff --git a/src/orbit/RFCavities/Harmonic_Cav.hh b/src/orbit/RFCavities/Harmonic_Cav.hh index 9f6e2010..50674ef6 100644 --- a/src/orbit/RFCavities/Harmonic_Cav.hh +++ b/src/orbit/RFCavities/Harmonic_Cav.hh @@ -2,16 +2,16 @@ #define HARMONIC_CAV_H //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include //ORBIT bunch -#include "Bunch.hh" +#include "orbit/Bunch.hh" //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" using namespace std; diff --git a/src/orbit/RFCavities/wrap_Barrier_Cav.cc b/src/orbit/RFCavities/wrap_Barrier_Cav.cc index 3f360f7b..b1d977e0 100644 --- a/src/orbit/RFCavities/wrap_Barrier_Cav.cc +++ b/src/orbit/RFCavities/wrap_Barrier_Cav.cc @@ -1,12 +1,12 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_Barrier_Cav.hh" -#include "wrap_bunch.hh" +#include "orbit/RFCavities/wrap_Barrier_Cav.hh" +#include "orbit/wrap_bunch.hh" #include -#include "Barrier_Cav.hh" +#include "orbit/RFCavities/Barrier_Cav.hh" using namespace OrbitUtils; diff --git a/src/orbit/RFCavities/wrap_Dual_Harmonic_Cav.cc b/src/orbit/RFCavities/wrap_Dual_Harmonic_Cav.cc index bf9b7b32..c31916cb 100644 --- a/src/orbit/RFCavities/wrap_Dual_Harmonic_Cav.cc +++ b/src/orbit/RFCavities/wrap_Dual_Harmonic_Cav.cc @@ -1,12 +1,12 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_Dual_Harmonic_Cav.hh" -#include "wrap_bunch.hh" +#include "orbit/RFCavities/wrap_Dual_Harmonic_Cav.hh" +#include "orbit/wrap_bunch.hh" #include -#include "Dual_Harmonic_Cav.hh" +#include "orbit/RFCavities/Dual_Harmonic_Cav.hh" using namespace OrbitUtils; diff --git a/src/orbit/RFCavities/wrap_Frequency_Cav.cc b/src/orbit/RFCavities/wrap_Frequency_Cav.cc index b245b043..4e30192b 100644 --- a/src/orbit/RFCavities/wrap_Frequency_Cav.cc +++ b/src/orbit/RFCavities/wrap_Frequency_Cav.cc @@ -1,12 +1,12 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_Frequency_Cav.hh" -#include "wrap_bunch.hh" +#include "orbit/RFCavities/wrap_Frequency_Cav.hh" +#include "orbit/wrap_bunch.hh" #include -#include "Frequency_Cav.hh" +#include "orbit/RFCavities/Frequency_Cav.hh" using namespace OrbitUtils; diff --git a/src/orbit/RFCavities/wrap_Harmonic_Cav.cc b/src/orbit/RFCavities/wrap_Harmonic_Cav.cc index 11ce38e7..c038bf2e 100644 --- a/src/orbit/RFCavities/wrap_Harmonic_Cav.cc +++ b/src/orbit/RFCavities/wrap_Harmonic_Cav.cc @@ -1,12 +1,12 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_Harmonic_Cav.hh" -#include "wrap_bunch.hh" +#include "orbit/RFCavities/wrap_Harmonic_Cav.hh" +#include "orbit/wrap_bunch.hh" #include -#include "Harmonic_Cav.hh" +#include "orbit/RFCavities/Harmonic_Cav.hh" using namespace OrbitUtils; diff --git a/src/orbit/RFCavities/wrap_rfcavities.cc b/src/orbit/RFCavities/wrap_rfcavities.cc index 4034c5dd..209ae43a 100644 --- a/src/orbit/RFCavities/wrap_rfcavities.cc +++ b/src/orbit/RFCavities/wrap_rfcavities.cc @@ -1,9 +1,9 @@ -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" -#include "wrap_Frequency_Cav.hh" -#include "wrap_Harmonic_Cav.hh" -#include "wrap_Barrier_Cav.hh" -#include "wrap_Dual_Harmonic_Cav.hh" +#include "orbit/RFCavities/wrap_Frequency_Cav.hh" +#include "orbit/RFCavities/wrap_Harmonic_Cav.hh" +#include "orbit/RFCavities/wrap_Barrier_Cav.hh" +#include "orbit/RFCavities/wrap_Dual_Harmonic_Cav.hh" static PyMethodDef rfcavitiesMethods[] = {{NULL,NULL}}; diff --git a/src/orbit/SyncPart.cc b/src/orbit/SyncPart.cc index 216fa23c..c90a9c67 100644 --- a/src/orbit/SyncPart.cc +++ b/src/orbit/SyncPart.cc @@ -26,12 +26,12 @@ /////////////////////////////////////////////////////////////////////////// #include -#include "SyncPart.hh" +#include "orbit/SyncPart.hh" -#include "Bunch.hh" -#include "OrbitConst.hh" -#include "StringUtils.hh" -#include "BufferStore.hh" +#include "orbit/Bunch.hh" +#include "orbit/OrbitConst.hh" +#include "utils/StringUtils.hh" +#include "utils/BufferStore.hh" #include #include diff --git a/src/orbit/SyncPart.hh b/src/orbit/SyncPart.hh index d14aa9ba..80ef97f3 100644 --- a/src/orbit/SyncPart.hh +++ b/src/orbit/SyncPart.hh @@ -23,7 +23,7 @@ // INCLUDE FILES // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include diff --git a/src/orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.cc b/src/orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.cc index 2bd4c3f7..7163fa3a 100644 --- a/src/orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.cc +++ b/src/orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.cc @@ -1,4 +1,4 @@ -#include "SynchPartRedefinitionZdE.hh" +#include "orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.hh" #include #include @@ -6,10 +6,10 @@ #include //#include "Bunch.hh" -#include "ParticlesAttributes/ParticleMacroSize.hh" -#include "SyncPart.hh" +#include "orbit/ParticlesAttributes/ParticleMacroSize.hh" +#include "orbit/SyncPart.hh" -#include "OrbitConst.hh" +#include "orbit/OrbitConst.hh" /** Constructor */ SynchPartRedefinitionZdE::SynchPartRedefinitionZdE(): CppPyWrapper(NULL) diff --git a/src/orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.hh b/src/orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.hh index 7c920ecb..e5aa4d66 100644 --- a/src/orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.hh +++ b/src/orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.hh @@ -2,9 +2,9 @@ #define SYNCH_PARTICLE_REDEFINITION_H //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" -#include "Bunch.hh" +#include "orbit/Bunch.hh" using namespace std; diff --git a/src/orbit/SynchPartRedefinition/wrap_synch_part_redefinition_z_de.cc b/src/orbit/SynchPartRedefinition/wrap_synch_part_redefinition_z_de.cc index c834a765..953e717f 100644 --- a/src/orbit/SynchPartRedefinition/wrap_synch_part_redefinition_z_de.cc +++ b/src/orbit/SynchPartRedefinition/wrap_synch_part_redefinition_z_de.cc @@ -1,12 +1,12 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_synch_part_redefinition_z_de.hh" -#include "wrap_bunch.hh" +#include "orbit/SynchPartRedefinition/wrap_synch_part_redefinition_z_de.hh" +#include "orbit/wrap_bunch.hh" #include -#include "SynchPartRedefinitionZdE.hh" +#include "orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.hh" namespace wrap_synch_part_redefinition{ diff --git a/src/orbit/wrap_bunch.cc b/src/orbit/wrap_bunch.cc index 7febe397..55fdfcf4 100644 --- a/src/orbit/wrap_bunch.cc +++ b/src/orbit/wrap_bunch.cc @@ -8,17 +8,17 @@ // INCLUDE FILES // /////////////////////////////////////////////////////////////////////////// -#include "wrap_bunch.hh" -#include "wrap_mpi_comm.hh" -#include "wrap_syncpart.hh" -#include "wrap_bunch_twiss_analysis.hh" -#include "wrap_bunch_tune_analysis.hh" -#include "wrap_synch_part_redefinition_z_de.hh" +#include "orbit/wrap_bunch.hh" +#include "mpi/wrap_mpi_comm.hh" +#include "orbit/wrap_syncpart.hh" +#include "orbit/BunchDiagnostics/wrap_bunch_twiss_analysis.hh" +#include "orbit/BunchDiagnostics/wrap_bunch_tune_analysis.hh" +#include "orbit/SynchPartRedefinition/wrap_synch_part_redefinition_z_de.hh" -#include "pyORBIT_Object.hh" +#include "main/pyORBIT_Object.hh" -#include "Bunch.hh" -#include "ParticleAttributesFactory.hh" +#include "orbit/Bunch.hh" +#include "orbit/ParticlesAttributes/ParticleAttributesFactory.hh" namespace wrap_orbit_bunch{ diff --git a/src/orbit/wrap_syncpart.cc b/src/orbit/wrap_syncpart.cc index 787c00a7..01d1f9bc 100644 --- a/src/orbit/wrap_syncpart.cc +++ b/src/orbit/wrap_syncpart.cc @@ -3,12 +3,12 @@ // INCLUDE FILES // /////////////////////////////////////////////////////////////////////////// -#include "wrap_syncpart.hh" +#include "orbit/wrap_syncpart.hh" -#include "pyORBIT_Object.hh" +#include "main/pyORBIT_Object.hh" -#include "Bunch.hh" -#include "SyncPart.hh" +#include "orbit/Bunch.hh" +#include "orbit/SyncPart.hh" namespace wrap_orbit_syncpart{ diff --git a/src/spacecharge/BaseBoundary2D.cc b/src/spacecharge/BaseBoundary2D.cc index b897048d..868eb772 100644 --- a/src/spacecharge/BaseBoundary2D.cc +++ b/src/spacecharge/BaseBoundary2D.cc @@ -1,5 +1,5 @@ -#include "BaseBoundary2D.hh" -#include "OrbitConst.hh" +#include "spacecharge/BaseBoundary2D.hh" +#include "orbit/OrbitConst.hh" #include #include diff --git a/src/spacecharge/BaseBoundary2D.hh b/src/spacecharge/BaseBoundary2D.hh index 4e9481bf..8340ac4a 100644 --- a/src/spacecharge/BaseBoundary2D.hh +++ b/src/spacecharge/BaseBoundary2D.hh @@ -1,11 +1,11 @@ #ifndef SC_BASE_BOUNDARY_2D_H #define SC_BASE_BOUNDARY_2D_H -#include "Grid2D.hh" +#include "spacecharge/Grid2D.hh" #include //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" using namespace std; diff --git a/src/spacecharge/ForceSolver2D.cc b/src/spacecharge/ForceSolver2D.cc index e1205425..5953ec3d 100644 --- a/src/spacecharge/ForceSolver2D.cc +++ b/src/spacecharge/ForceSolver2D.cc @@ -1,4 +1,4 @@ -#include "ForceSolver2D.hh" +#include "spacecharge/ForceSolver2D.hh" #include diff --git a/src/spacecharge/ForceSolver2D.hh b/src/spacecharge/ForceSolver2D.hh index e97877c6..69980df5 100644 --- a/src/spacecharge/ForceSolver2D.hh +++ b/src/spacecharge/ForceSolver2D.hh @@ -4,16 +4,16 @@ #define SC_Force_SOLVER_BASE_2D_H //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include #include //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" -#include "Grid2D.hh" +#include "spacecharge/Grid2D.hh" using namespace std; diff --git a/src/spacecharge/ForceSolverFFT2D.cc b/src/spacecharge/ForceSolverFFT2D.cc index abe7b890..a241d18c 100644 --- a/src/spacecharge/ForceSolverFFT2D.cc +++ b/src/spacecharge/ForceSolverFFT2D.cc @@ -1,4 +1,4 @@ -#include "ForceSolverFFT2D.hh" +#include "spacecharge/ForceSolverFFT2D.hh" #include diff --git a/src/spacecharge/ForceSolverFFT2D.hh b/src/spacecharge/ForceSolverFFT2D.hh index d1df7a4a..71bbc71c 100644 --- a/src/spacecharge/ForceSolverFFT2D.hh +++ b/src/spacecharge/ForceSolverFFT2D.hh @@ -4,7 +4,7 @@ #define SC_FORCE_SOLVER_FFT_2D_H //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include @@ -12,12 +12,12 @@ #include //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" //FFTW library header #include "fftw3.h" -#include "ForceSolver2D.hh" +#include "spacecharge/ForceSolver2D.hh" using namespace std; diff --git a/src/spacecharge/Grid1D.cc b/src/spacecharge/Grid1D.cc index e3259e26..7c5d1494 100644 --- a/src/spacecharge/Grid1D.cc +++ b/src/spacecharge/Grid1D.cc @@ -14,12 +14,12 @@ // Correction done by A. Shishlo 2023.02.10 // ///////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" -#include "Grid1D.hh" -#include "Bunch.hh" -#include "ParticleMacroSize.hh" -#include "BufferStore.hh" +#include "spacecharge/Grid1D.hh" +#include "orbit/Bunch.hh" +#include "orbit/ParticlesAttributes/ParticleMacroSize.hh" +#include "utils/BufferStore.hh" #include diff --git a/src/spacecharge/Grid1D.hh b/src/spacecharge/Grid1D.hh index 2b096cd3..9abab179 100644 --- a/src/spacecharge/Grid1D.hh +++ b/src/spacecharge/Grid1D.hh @@ -2,16 +2,16 @@ #define SC_GRID_1D_H // MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include // ORBIT bunch -#include "Bunch.hh" +#include "orbit/Bunch.hh" // pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" using namespace std; diff --git a/src/spacecharge/Grid2D.cc b/src/spacecharge/Grid2D.cc index 78f9c399..a7b2c81a 100644 --- a/src/spacecharge/Grid2D.cc +++ b/src/spacecharge/Grid2D.cc @@ -1,8 +1,8 @@ //This class repersents a 2D rectangular grid -#include "Grid2D.hh" -#include "ParticleMacroSize.hh" -#include "BufferStore.hh" +#include "spacecharge/Grid2D.hh" +#include "orbit/ParticlesAttributes/ParticleMacroSize.hh" +#include "utils/BufferStore.hh" #include diff --git a/src/spacecharge/Grid2D.hh b/src/spacecharge/Grid2D.hh index 30b0bdfe..bad12e62 100644 --- a/src/spacecharge/Grid2D.hh +++ b/src/spacecharge/Grid2D.hh @@ -4,16 +4,16 @@ #define SC_GRID_2D_H //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include //ORBIT bunch -#include "Bunch.hh" +#include "orbit/Bunch.hh" //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" using namespace std; diff --git a/src/spacecharge/Grid3D.cc b/src/spacecharge/Grid3D.cc index 84a95556..6b971cec 100644 --- a/src/spacecharge/Grid3D.cc +++ b/src/spacecharge/Grid3D.cc @@ -14,10 +14,10 @@ // /////////////////////////////////////////////////////////////////////////// -#include "ParticleMacroSize.hh" -#include "BufferStore.hh" +#include "orbit/ParticlesAttributes/ParticleMacroSize.hh" +#include "utils/BufferStore.hh" -#include "Grid3D.hh" +#include "spacecharge/Grid3D.hh" #include diff --git a/src/spacecharge/Grid3D.hh b/src/spacecharge/Grid3D.hh index 57d3fb2f..62707aca 100644 --- a/src/spacecharge/Grid3D.hh +++ b/src/spacecharge/Grid3D.hh @@ -17,15 +17,15 @@ #define SC_GRID3D_HH //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" //ORBIT bunch -#include "Bunch.hh" +#include "orbit/Bunch.hh" //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" -#include "Grid2D.hh" +#include "spacecharge/Grid2D.hh" #include #include diff --git a/src/spacecharge/LSpaceChargeCalc.cc b/src/spacecharge/LSpaceChargeCalc.cc index bd008e86..297b85a3 100644 --- a/src/spacecharge/LSpaceChargeCalc.cc +++ b/src/spacecharge/LSpaceChargeCalc.cc @@ -11,10 +11,10 @@ // ///////////////////////////////////////////////////////////////////////////// -#include "LSpaceChargeCalc.hh" -#include "BufferStore.hh" -#include "Grid1D.hh" -#include "OrbitConst.hh" +#include "spacecharge/Grid1D.hh" +#include "utils/BufferStore.hh" +#include "spacecharge/LSpaceChargeCalc.hh" +#include "orbit/OrbitConst.hh" #include #include #include diff --git a/src/spacecharge/LSpaceChargeCalc.hh b/src/spacecharge/LSpaceChargeCalc.hh index 52e37afc..9f1e0162 100644 --- a/src/spacecharge/LSpaceChargeCalc.hh +++ b/src/spacecharge/LSpaceChargeCalc.hh @@ -4,19 +4,19 @@ #define SC_SPACECHARGE_CALC_L_H //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include #include //ORBIT bunch -#include "Bunch.hh" +#include "orbit/Bunch.hh" //pyORBIT utils -#include "CppPyWrapper.hh" -#include "BunchExtremaCalculator.hh" -#include "Grid1D.hh" +#include "utils/CppPyWrapper.hh" +#include "utils/bunch/BunchExtremaCalculator.hh" +#include "spacecharge/Grid1D.hh" //FFTW library header #include "fftw3.h" diff --git a/src/spacecharge/PoissonSolver2D.cc b/src/spacecharge/PoissonSolver2D.cc index cf4426ad..e093fd95 100644 --- a/src/spacecharge/PoissonSolver2D.cc +++ b/src/spacecharge/PoissonSolver2D.cc @@ -1,4 +1,4 @@ -#include "PoissonSolver2D.hh" +#include "spacecharge/PoissonSolver2D.hh" #include diff --git a/src/spacecharge/PoissonSolver2D.hh b/src/spacecharge/PoissonSolver2D.hh index 28c699c7..a379d13a 100644 --- a/src/spacecharge/PoissonSolver2D.hh +++ b/src/spacecharge/PoissonSolver2D.hh @@ -4,16 +4,16 @@ #define SC_POISSON_SOLVER_BASE_2D_H //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include #include //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" -#include "Grid2D.hh" +#include "spacecharge/Grid2D.hh" using namespace std; diff --git a/src/spacecharge/PoissonSolver3D.cc b/src/spacecharge/PoissonSolver3D.cc index aef8bc62..02ce2121 100644 --- a/src/spacecharge/PoissonSolver3D.cc +++ b/src/spacecharge/PoissonSolver3D.cc @@ -1,4 +1,4 @@ -#include "PoissonSolver3D.hh" +#include "spacecharge/PoissonSolver3D.hh" #include diff --git a/src/spacecharge/PoissonSolver3D.hh b/src/spacecharge/PoissonSolver3D.hh index 0e3a25ca..3292a724 100644 --- a/src/spacecharge/PoissonSolver3D.hh +++ b/src/spacecharge/PoissonSolver3D.hh @@ -4,16 +4,16 @@ #define SC_POISSON_SOLVER_BASE_3D_H //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include #include //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" -#include "Grid3D.hh" +#include "spacecharge/Grid3D.hh" using namespace std; diff --git a/src/spacecharge/PoissonSolverFFT2D.cc b/src/spacecharge/PoissonSolverFFT2D.cc index a855c6de..88b2f093 100644 --- a/src/spacecharge/PoissonSolverFFT2D.cc +++ b/src/spacecharge/PoissonSolverFFT2D.cc @@ -1,4 +1,4 @@ -#include "PoissonSolverFFT2D.hh" +#include "spacecharge/PoissonSolverFFT2D.hh" #include diff --git a/src/spacecharge/PoissonSolverFFT2D.hh b/src/spacecharge/PoissonSolverFFT2D.hh index 33e2d9e6..b065d844 100644 --- a/src/spacecharge/PoissonSolverFFT2D.hh +++ b/src/spacecharge/PoissonSolverFFT2D.hh @@ -4,19 +4,19 @@ #define SC_POISSON_SOLVER_FFT_2D_H //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include #include //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" //FFTW library header #include "fftw3.h" -#include "PoissonSolver2D.hh" +#include "spacecharge/PoissonSolver2D.hh" using namespace std; diff --git a/src/spacecharge/PoissonSolverFFT3D.cc b/src/spacecharge/PoissonSolverFFT3D.cc index fec5d5c8..a1b637c4 100644 --- a/src/spacecharge/PoissonSolverFFT3D.cc +++ b/src/spacecharge/PoissonSolverFFT3D.cc @@ -1,4 +1,4 @@ -#include "PoissonSolverFFT3D.hh" +#include "spacecharge/PoissonSolverFFT3D.hh" #include diff --git a/src/spacecharge/PoissonSolverFFT3D.hh b/src/spacecharge/PoissonSolverFFT3D.hh index 3b13e018..6077813d 100644 --- a/src/spacecharge/PoissonSolverFFT3D.hh +++ b/src/spacecharge/PoissonSolverFFT3D.hh @@ -4,7 +4,7 @@ #define SC_POISSON_SOLVER_FFT_3D_H //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include @@ -12,12 +12,12 @@ #include //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" //FFTW library header #include "fftw3.h" -#include "PoissonSolver3D.hh" +#include "spacecharge/PoissonSolver3D.hh" using namespace std; diff --git a/src/spacecharge/ShapedBoundary2D.cc b/src/spacecharge/ShapedBoundary2D.cc index 1a77ee2d..e4fa6c54 100644 --- a/src/spacecharge/ShapedBoundary2D.cc +++ b/src/spacecharge/ShapedBoundary2D.cc @@ -1,4 +1,4 @@ -#include "ShapedBoundary2D.hh" +#include "spacecharge/ShapedBoundary2D.hh" #include #include diff --git a/src/spacecharge/ShapedBoundary2D.hh b/src/spacecharge/ShapedBoundary2D.hh index 4eb98f5c..e2f77db2 100644 --- a/src/spacecharge/ShapedBoundary2D.hh +++ b/src/spacecharge/ShapedBoundary2D.hh @@ -1,10 +1,10 @@ #ifndef SC_SHAPED_BOUNDARY_2D_H #define SC_SHAPED_BOUNDARY_2D_H -#include "Grid2D.hh" +#include "spacecharge/Grid2D.hh" #include -#include "BaseBoundary2D.hh" +#include "spacecharge/BaseBoundary2D.hh" using namespace std; diff --git a/src/spacecharge/SpaceChargeCalc2p5D.cc b/src/spacecharge/SpaceChargeCalc2p5D.cc index c6fded05..338d52a7 100644 --- a/src/spacecharge/SpaceChargeCalc2p5D.cc +++ b/src/spacecharge/SpaceChargeCalc2p5D.cc @@ -10,11 +10,11 @@ // ///////////////////////////////////////////////////////////////////////////// -#include "Grid1D.hh" -#include "Grid2D.hh" -#include "PoissonSolverFFT2D.hh" -#include "SpaceChargeCalc2p5D.hh" -#include "BufferStore.hh" +#include "spacecharge/Grid1D.hh" +#include "spacecharge/Grid2D.hh" +#include "spacecharge/PoissonSolverFFT2D.hh" +#include "spacecharge/SpaceChargeCalc2p5D.hh" +#include "utils/BufferStore.hh" #include #include diff --git a/src/spacecharge/SpaceChargeCalc2p5D.hh b/src/spacecharge/SpaceChargeCalc2p5D.hh index f36f1fde..1ca3627f 100644 --- a/src/spacecharge/SpaceChargeCalc2p5D.hh +++ b/src/spacecharge/SpaceChargeCalc2p5D.hh @@ -4,22 +4,22 @@ #define SC_SPACECHARGE_CALC_2P5D_H //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include //ORBIT bunch -#include "Bunch.hh" +#include "orbit/Bunch.hh" //pyORBIT utils -#include "CppPyWrapper.hh" -#include "BunchExtremaCalculator.hh" +#include "utils/CppPyWrapper.hh" +#include "utils/bunch/BunchExtremaCalculator.hh" -#include "Grid1D.hh" -#include "Grid2D.hh" -#include "PoissonSolverFFT2D.hh" -#include "BaseBoundary2D.hh" +#include "spacecharge/Grid1D.hh" +#include "spacecharge/Grid2D.hh" +#include "spacecharge/PoissonSolverFFT2D.hh" +#include "spacecharge/BaseBoundary2D.hh" using namespace std; diff --git a/src/spacecharge/SpaceChargeCalc2p5Drb.cc b/src/spacecharge/SpaceChargeCalc2p5Drb.cc index 9348ea04..74a1db8a 100644 --- a/src/spacecharge/SpaceChargeCalc2p5Drb.cc +++ b/src/spacecharge/SpaceChargeCalc2p5Drb.cc @@ -16,11 +16,11 @@ // ///////////////////////////////////////////////////////////////////////////// -#include "Grid1D.hh" -#include "Grid2D.hh" -#include "PoissonSolverFFT2D.hh" -#include "SpaceChargeCalc2p5Drb.hh" -#include "BufferStore.hh" +#include "spacecharge/Grid1D.hh" +#include "spacecharge/Grid2D.hh" +#include "spacecharge/PoissonSolverFFT2D.hh" +#include "spacecharge/SpaceChargeCalc2p5Drb.hh" +#include "utils/BufferStore.hh" #include #include diff --git a/src/spacecharge/SpaceChargeCalc2p5Drb.hh b/src/spacecharge/SpaceChargeCalc2p5Drb.hh index a6ab5b87..0626681f 100644 --- a/src/spacecharge/SpaceChargeCalc2p5Drb.hh +++ b/src/spacecharge/SpaceChargeCalc2p5Drb.hh @@ -8,21 +8,21 @@ #define SC_SPACECHARGE_CALC_2P5D_RB_H //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include //ORBIT bunch -#include "Bunch.hh" +#include "orbit/Bunch.hh" //pyORBIT utils -#include "CppPyWrapper.hh" -#include "BunchExtremaCalculator.hh" +#include "utils/CppPyWrapper.hh" +#include "utils/bunch/BunchExtremaCalculator.hh" -#include "Grid1D.hh" -#include "Grid2D.hh" -#include "PoissonSolverFFT2D.hh" +#include "spacecharge/Grid1D.hh" +#include "spacecharge/Grid2D.hh" +#include "spacecharge/PoissonSolverFFT2D.hh" using namespace std; diff --git a/src/spacecharge/SpaceChargeCalc3D.cc b/src/spacecharge/SpaceChargeCalc3D.cc index be539037..2a615896 100644 --- a/src/spacecharge/SpaceChargeCalc3D.cc +++ b/src/spacecharge/SpaceChargeCalc3D.cc @@ -18,11 +18,11 @@ // ///////////////////////////////////////////////////////////////////////////// -#include "Grid3D.hh" -#include "PoissonSolverFFT3D.hh" -#include "SpaceChargeCalc3D.hh" -#include "BufferStore.hh" -#include "OrbitConst.hh" +#include "spacecharge/Grid3D.hh" +#include "spacecharge/PoissonSolverFFT3D.hh" +#include "spacecharge/SpaceChargeCalc3D.hh" +#include "utils/BufferStore.hh" +#include "orbit/OrbitConst.hh" #include #include diff --git a/src/spacecharge/SpaceChargeCalc3D.hh b/src/spacecharge/SpaceChargeCalc3D.hh index 261b49ca..08232bcf 100644 --- a/src/spacecharge/SpaceChargeCalc3D.hh +++ b/src/spacecharge/SpaceChargeCalc3D.hh @@ -10,20 +10,20 @@ #define SC_SPACECHARGE_CALC_3D_H //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include //ORBIT bunch -#include "Bunch.hh" +#include "orbit/Bunch.hh" //pyORBIT utils -#include "CppPyWrapper.hh" -#include "BunchExtremaCalculator.hh" +#include "utils/CppPyWrapper.hh" +#include "utils/bunch/BunchExtremaCalculator.hh" -#include "Grid3D.hh" -#include "PoissonSolverFFT3D.hh" +#include "spacecharge/Grid3D.hh" +#include "spacecharge/PoissonSolverFFT3D.hh" using namespace std; diff --git a/src/spacecharge/SpaceChargeCalcSliceBySlice2D.cc b/src/spacecharge/SpaceChargeCalcSliceBySlice2D.cc index f09a2dba..996e46a3 100755 --- a/src/spacecharge/SpaceChargeCalcSliceBySlice2D.cc +++ b/src/spacecharge/SpaceChargeCalcSliceBySlice2D.cc @@ -10,10 +10,10 @@ // ///////////////////////////////////////////////////////////////////////////// -#include "Grid3D.hh" -#include "PoissonSolverFFT2D.hh" -#include "SpaceChargeCalcSliceBySlice2D.hh" -#include "BufferStore.hh" +#include "spacecharge/Grid3D.hh" +#include "spacecharge/PoissonSolverFFT2D.hh" +#include "spacecharge/SpaceChargeCalcSliceBySlice2D.hh" +#include "utils/BufferStore.hh" #include #include diff --git a/src/spacecharge/SpaceChargeCalcSliceBySlice2D.hh b/src/spacecharge/SpaceChargeCalcSliceBySlice2D.hh index 44fd5a6f..8f8681e9 100755 --- a/src/spacecharge/SpaceChargeCalcSliceBySlice2D.hh +++ b/src/spacecharge/SpaceChargeCalcSliceBySlice2D.hh @@ -4,21 +4,21 @@ #define SC_SPACECHARGE_CALC_2P5D_H //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include //ORBIT bunch -#include "Bunch.hh" +#include "orbit/Bunch.hh" //pyORBIT utils -#include "CppPyWrapper.hh" -#include "BunchExtremaCalculator.hh" +#include "utils/CppPyWrapper.hh" +#include "utils/bunch/BunchExtremaCalculator.hh" -#include "Grid3D.hh" -#include "PoissonSolverFFT2D.hh" -#include "BaseBoundary2D.hh" +#include "spacecharge/Grid3D.hh" +#include "spacecharge/PoissonSolverFFT2D.hh" +#include "spacecharge/BaseBoundary2D.hh" using namespace std; diff --git a/src/spacecharge/SpaceChargeCalcUnifEllipse.cc b/src/spacecharge/SpaceChargeCalcUnifEllipse.cc index 83af0bbc..8549e8ee 100644 --- a/src/spacecharge/SpaceChargeCalcUnifEllipse.cc +++ b/src/spacecharge/SpaceChargeCalcUnifEllipse.cc @@ -15,10 +15,10 @@ // The space charge kick is transformed later into the lab system. // ///////////////////////////////////////////////////////////////////////////// -#include "SpaceChargeCalcUnifEllipse.hh" -#include "BufferStore.hh" +#include "spacecharge/SpaceChargeCalcUnifEllipse.hh" +#include "utils/BufferStore.hh" -#include "ParticleMacroSize.hh" +#include "orbit/ParticlesAttributes/ParticleMacroSize.hh" #include #include diff --git a/src/spacecharge/SpaceChargeCalcUnifEllipse.hh b/src/spacecharge/SpaceChargeCalcUnifEllipse.hh index 246cb936..dd5c0267 100644 --- a/src/spacecharge/SpaceChargeCalcUnifEllipse.hh +++ b/src/spacecharge/SpaceChargeCalcUnifEllipse.hh @@ -8,18 +8,18 @@ #define SC_SPACECHARGE_CALC_UNIFORM_ELLIPSE_HH //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include //ORBIT bunch -#include "Bunch.hh" +#include "orbit/Bunch.hh" //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" -#include "UniformEllipsoidFieldCalculator.hh" +#include "spacecharge/UniformEllipsoidFieldCalculator.hh" using namespace std; diff --git a/src/spacecharge/SpaceChargeForceCalc2p5D.cc b/src/spacecharge/SpaceChargeForceCalc2p5D.cc index ae14eb03..6f2b73c1 100644 --- a/src/spacecharge/SpaceChargeForceCalc2p5D.cc +++ b/src/spacecharge/SpaceChargeForceCalc2p5D.cc @@ -10,11 +10,11 @@ // ///////////////////////////////////////////////////////////////////////////// -#include "Grid1D.hh" -#include "Grid2D.hh" -#include "ForceSolverFFT2D.hh" -#include "SpaceChargeForceCalc2p5D.hh" -#include "BufferStore.hh" +#include "spacecharge/Grid1D.hh" +#include "spacecharge/Grid2D.hh" +#include "spacecharge/ForceSolverFFT2D.hh" +#include "spacecharge/SpaceChargeForceCalc2p5D.hh" +#include "utils/BufferStore.hh" #include #include diff --git a/src/spacecharge/SpaceChargeForceCalc2p5D.hh b/src/spacecharge/SpaceChargeForceCalc2p5D.hh index 265ba0f1..71179d00 100644 --- a/src/spacecharge/SpaceChargeForceCalc2p5D.hh +++ b/src/spacecharge/SpaceChargeForceCalc2p5D.hh @@ -4,21 +4,21 @@ #define SC_SPACEFORCECHARGE_CALC_2P5D_H //MPI Function Wrappers -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include //ORBIT bunch -#include "Bunch.hh" +#include "orbit/Bunch.hh" //pyORBIT utils -#include "CppPyWrapper.hh" -#include "BunchExtremaCalculator.hh" +#include "utils/CppPyWrapper.hh" +#include "utils/bunch/BunchExtremaCalculator.hh" -#include "Grid1D.hh" -#include "Grid2D.hh" -#include "ForceSolverFFT2D.hh" -#include "BaseBoundary2D.hh" +#include "spacecharge/Grid1D.hh" +#include "spacecharge/Grid2D.hh" +#include "spacecharge/ForceSolverFFT2D.hh" +#include "spacecharge/BaseBoundary2D.hh" using namespace std; diff --git a/src/spacecharge/UniformEllipsoidFieldCalculator.cc b/src/spacecharge/UniformEllipsoidFieldCalculator.cc index 811eb52d..ab5bda9f 100644 --- a/src/spacecharge/UniformEllipsoidFieldCalculator.cc +++ b/src/spacecharge/UniformEllipsoidFieldCalculator.cc @@ -4,11 +4,11 @@ */ //MPI Function Wrappers -#include "orbit_mpi.hh" -#include "wrap_mpi_comm.hh" +#include "mpi/orbit_mpi.hh" +#include "mpi/wrap_mpi_comm.hh" -#include "UniformEllipsoidFieldCalculator.hh" -#include "gauss_legendre_points.hh" +#include "spacecharge/UniformEllipsoidFieldCalculator.hh" +#include "utils/integration/gauss_legendre_points.hh" #include diff --git a/src/spacecharge/UniformEllipsoidFieldCalculator.hh b/src/spacecharge/UniformEllipsoidFieldCalculator.hh index 6df271e7..e80fa34b 100644 --- a/src/spacecharge/UniformEllipsoidFieldCalculator.hh +++ b/src/spacecharge/UniformEllipsoidFieldCalculator.hh @@ -2,10 +2,10 @@ #define UNIFORM_SC_ELLIPSOID_HH //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" //Function from OrbitUtils -#include "OU_Function.hh" +#include "utils/OU_Function.hh" #include #include diff --git a/src/spacecharge/wrap_boundary2d.cc b/src/spacecharge/wrap_boundary2d.cc index f634b438..fc63b2d1 100644 --- a/src/spacecharge/wrap_boundary2d.cc +++ b/src/spacecharge/wrap_boundary2d.cc @@ -1,14 +1,14 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_boundary2d.hh" -#include "wrap_spacecharge.hh" +#include "spacecharge/wrap_boundary2d.hh" +#include "spacecharge/wrap_spacecharge.hh" #include -#include "BaseBoundary2D.hh" -#include "ShapedBoundary2D.hh" -#include "Grid2D.hh" +#include "spacecharge/BaseBoundary2D.hh" +#include "spacecharge/ShapedBoundary2D.hh" +#include "spacecharge/Grid2D.hh" using namespace OrbitUtils; diff --git a/src/spacecharge/wrap_forcesolverfft2d.cc b/src/spacecharge/wrap_forcesolverfft2d.cc index b8e03f56..a9c2522f 100644 --- a/src/spacecharge/wrap_forcesolverfft2d.cc +++ b/src/spacecharge/wrap_forcesolverfft2d.cc @@ -1,11 +1,11 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "ForceSolverFFT2D.hh" -#include "Grid2D.hh" +#include "spacecharge/ForceSolverFFT2D.hh" +#include "spacecharge/Grid2D.hh" -#include "wrap_forcesolverfft2d.hh" -#include "wrap_spacecharge.hh" +#include "spacecharge/wrap_forcesolverfft2d.hh" +#include "spacecharge/wrap_spacecharge.hh" #include diff --git a/src/spacecharge/wrap_grid1D.cc b/src/spacecharge/wrap_grid1D.cc index a83c5f81..acb858a4 100644 --- a/src/spacecharge/wrap_grid1D.cc +++ b/src/spacecharge/wrap_grid1D.cc @@ -1,14 +1,14 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_grid1D.hh" -#include "wrap_spacecharge.hh" -#include "wrap_bunch.hh" -#include "wrap_mpi_comm.hh" +#include "spacecharge/wrap_grid1D.hh" +#include "spacecharge/wrap_spacecharge.hh" +#include "orbit/wrap_bunch.hh" +#include "mpi/wrap_mpi_comm.hh" #include -#include "Grid1D.hh" +#include "spacecharge/Grid1D.hh" using namespace OrbitUtils; diff --git a/src/spacecharge/wrap_grid2D.cc b/src/spacecharge/wrap_grid2D.cc index b85aaa42..49222ead 100644 --- a/src/spacecharge/wrap_grid2D.cc +++ b/src/spacecharge/wrap_grid2D.cc @@ -1,14 +1,14 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_grid2D.hh" -#include "wrap_spacecharge.hh" -#include "wrap_bunch.hh" -#include "wrap_mpi_comm.hh" +#include "spacecharge/wrap_grid2D.hh" +#include "spacecharge/wrap_spacecharge.hh" +#include "orbit/wrap_bunch.hh" +#include "mpi/wrap_mpi_comm.hh" #include -#include "Grid2D.hh" +#include "spacecharge/Grid2D.hh" using namespace OrbitUtils; diff --git a/src/spacecharge/wrap_grid3D.cc b/src/spacecharge/wrap_grid3D.cc index dc92eac5..b02b3768 100644 --- a/src/spacecharge/wrap_grid3D.cc +++ b/src/spacecharge/wrap_grid3D.cc @@ -1,14 +1,14 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_grid3D.hh" -#include "wrap_spacecharge.hh" -#include "wrap_bunch.hh" -#include "wrap_mpi_comm.hh" +#include "spacecharge/wrap_grid3D.hh" +#include "spacecharge/wrap_spacecharge.hh" +#include "orbit/wrap_bunch.hh" +#include "mpi/wrap_mpi_comm.hh" #include -#include "Grid3D.hh" +#include "spacecharge/Grid3D.hh" using namespace OrbitUtils; diff --git a/src/spacecharge/wrap_lspacechargecalc.cc b/src/spacecharge/wrap_lspacechargecalc.cc index fd089ad5..98539127 100644 --- a/src/spacecharge/wrap_lspacechargecalc.cc +++ b/src/spacecharge/wrap_lspacechargecalc.cc @@ -1,12 +1,12 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_lspacechargecalc.hh" -#include "wrap_bunch.hh" +#include "spacecharge/wrap_lspacechargecalc.hh" +#include "orbit/wrap_bunch.hh" #include -#include "LSpaceChargeCalc.hh" +#include "spacecharge/LSpaceChargeCalc.hh" using namespace OrbitUtils; diff --git a/src/spacecharge/wrap_poissonsolverfft2d.cc b/src/spacecharge/wrap_poissonsolverfft2d.cc index 1e04e405..c87eaac9 100644 --- a/src/spacecharge/wrap_poissonsolverfft2d.cc +++ b/src/spacecharge/wrap_poissonsolverfft2d.cc @@ -1,11 +1,11 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "PoissonSolverFFT2D.hh" -#include "Grid2D.hh" +#include "spacecharge/PoissonSolverFFT2D.hh" +#include "spacecharge/Grid2D.hh" -#include "wrap_poissonsolverfft2d.hh" -#include "wrap_spacecharge.hh" +#include "spacecharge/wrap_poissonsolverfft2d.hh" +#include "spacecharge/wrap_spacecharge.hh" #include diff --git a/src/spacecharge/wrap_poissonsolverfft3d.cc b/src/spacecharge/wrap_poissonsolverfft3d.cc index 65af4b89..631509d2 100644 --- a/src/spacecharge/wrap_poissonsolverfft3d.cc +++ b/src/spacecharge/wrap_poissonsolverfft3d.cc @@ -1,11 +1,11 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "PoissonSolverFFT3D.hh" -#include "Grid3D.hh" +#include "spacecharge/PoissonSolverFFT3D.hh" +#include "spacecharge/Grid3D.hh" -#include "wrap_poissonsolverfft2d.hh" -#include "wrap_spacecharge.hh" +#include "spacecharge/wrap_poissonsolverfft2d.hh" +#include "spacecharge/wrap_spacecharge.hh" #include diff --git a/src/spacecharge/wrap_spacecharge.cc b/src/spacecharge/wrap_spacecharge.cc index 079c6b9c..be8fe364 100644 --- a/src/spacecharge/wrap_spacecharge.cc +++ b/src/spacecharge/wrap_spacecharge.cc @@ -1,21 +1,21 @@ -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" -#include "wrap_grid1D.hh" -#include "wrap_grid2D.hh" -#include "wrap_grid3D.hh" -#include "wrap_poissonsolverfft2d.hh" -#include "wrap_poissonsolverfft3d.hh" -#include "wrap_forcesolverfft2d.hh" -#include "wrap_boundary2d.hh" -#include "wrap_spacecharge.hh" -#include "wrap_spacechargecalc2p5d.hh" -#include "wrap_spacechargeforcecalc2p5d.hh" -#include "wrap_spacechargecalc2p5d_rb.hh" -#include "wrap_spacechargecalc_slicebyslice_2D.hh" -#include "wrap_lspacechargecalc.hh" -#include "wrap_spacechargecalc3d.hh" -#include "wrap_uniform_ellipsoid_field_calculator.hh" -#include "wrap_spacechargecalc_uniform_ellipse.hh" +#include "spacecharge/wrap_grid1D.hh" +#include "spacecharge/wrap_grid2D.hh" +#include "spacecharge/wrap_grid3D.hh" +#include "spacecharge/wrap_poissonsolverfft2d.hh" +#include "spacecharge/wrap_poissonsolverfft3d.hh" +#include "spacecharge/wrap_forcesolverfft2d.hh" +#include "spacecharge/wrap_boundary2d.hh" +#include "spacecharge/wrap_spacecharge.hh" +#include "spacecharge/wrap_spacechargecalc2p5d.hh" +#include "spacecharge/wrap_spacechargeforcecalc2p5d.hh" +#include "spacecharge/wrap_spacechargecalc2p5d_rb.hh" +#include "spacecharge/wrap_spacechargecalc_slicebyslice_2D.hh" +#include "spacecharge/wrap_lspacechargecalc.hh" +#include "spacecharge/wrap_spacechargecalc3d.hh" +#include "spacecharge/wrap_uniform_ellipsoid_field_calculator.hh" +#include "spacecharge/wrap_spacechargecalc_uniform_ellipse.hh" static PyMethodDef spacechargeMethods[] = { {NULL,NULL} }; diff --git a/src/spacecharge/wrap_spacechargecalc2p5d.cc b/src/spacecharge/wrap_spacechargecalc2p5d.cc index 2ba12f3c..960608e1 100644 --- a/src/spacecharge/wrap_spacechargecalc2p5d.cc +++ b/src/spacecharge/wrap_spacechargecalc2p5d.cc @@ -1,13 +1,13 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" # -#include "wrap_spacechargecalc2p5d.hh" -#include "wrap_spacecharge.hh" -#include "wrap_bunch.hh" +#include "spacecharge/wrap_spacechargecalc2p5d.hh" +#include "spacecharge/wrap_spacecharge.hh" +#include "orbit/wrap_bunch.hh" #include -#include "SpaceChargeCalc2p5D.hh" +#include "spacecharge/SpaceChargeCalc2p5D.hh" using namespace OrbitUtils; diff --git a/src/spacecharge/wrap_spacechargecalc2p5d_rb.cc b/src/spacecharge/wrap_spacechargecalc2p5d_rb.cc index 31bdbae8..ba7f5d5a 100644 --- a/src/spacecharge/wrap_spacechargecalc2p5d_rb.cc +++ b/src/spacecharge/wrap_spacechargecalc2p5d_rb.cc @@ -1,13 +1,13 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" # -#include "wrap_spacechargecalc2p5d_rb.hh" -#include "wrap_spacecharge.hh" -#include "wrap_bunch.hh" +#include "spacecharge/wrap_spacechargecalc2p5d_rb.hh" +#include "spacecharge/wrap_spacecharge.hh" +#include "orbit/wrap_bunch.hh" #include -#include "SpaceChargeCalc2p5Drb.hh" +#include "spacecharge/SpaceChargeCalc2p5Drb.hh" using namespace OrbitUtils; diff --git a/src/spacecharge/wrap_spacechargecalc3d.cc b/src/spacecharge/wrap_spacechargecalc3d.cc index 18bae349..e853ea79 100644 --- a/src/spacecharge/wrap_spacechargecalc3d.cc +++ b/src/spacecharge/wrap_spacechargecalc3d.cc @@ -1,13 +1,13 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" # -#include "wrap_spacechargecalc3d.hh" -#include "wrap_spacecharge.hh" -#include "wrap_bunch.hh" +#include "spacecharge/wrap_spacechargecalc3d.hh" +#include "spacecharge/wrap_spacecharge.hh" +#include "orbit/wrap_bunch.hh" #include -#include "SpaceChargeCalc3D.hh" +#include "spacecharge/SpaceChargeCalc3D.hh" using namespace OrbitUtils; diff --git a/src/spacecharge/wrap_spacechargecalc_slicebyslice_2D.cc b/src/spacecharge/wrap_spacechargecalc_slicebyslice_2D.cc index ba761988..5ebdf0a6 100755 --- a/src/spacecharge/wrap_spacechargecalc_slicebyslice_2D.cc +++ b/src/spacecharge/wrap_spacechargecalc_slicebyslice_2D.cc @@ -1,13 +1,13 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" # -#include "wrap_spacechargecalc_slicebyslice_2D.hh" -#include "wrap_spacecharge.hh" -#include "wrap_bunch.hh" +#include "spacecharge/wrap_spacechargecalc_slicebyslice_2D.hh" +#include "spacecharge/wrap_spacecharge.hh" +#include "orbit/wrap_bunch.hh" #include -#include "SpaceChargeCalcSliceBySlice2D.hh" +#include "spacecharge/SpaceChargeCalcSliceBySlice2D.hh" using namespace OrbitUtils; diff --git a/src/spacecharge/wrap_spacechargecalc_uniform_ellipse.cc b/src/spacecharge/wrap_spacechargecalc_uniform_ellipse.cc index 657c610f..64e0de26 100644 --- a/src/spacecharge/wrap_spacechargecalc_uniform_ellipse.cc +++ b/src/spacecharge/wrap_spacechargecalc_uniform_ellipse.cc @@ -1,13 +1,13 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_spacechargecalc_uniform_ellipse.hh" -#include "wrap_spacecharge.hh" -#include "wrap_bunch.hh" +#include "spacecharge/wrap_spacechargecalc_uniform_ellipse.hh" +#include "spacecharge/wrap_spacecharge.hh" +#include "orbit/wrap_bunch.hh" #include -#include "SpaceChargeCalcUnifEllipse.hh" +#include "spacecharge/SpaceChargeCalcUnifEllipse.hh" using namespace OrbitUtils; diff --git a/src/spacecharge/wrap_spacechargeforcecalc2p5d.cc b/src/spacecharge/wrap_spacechargeforcecalc2p5d.cc index 65e98689..fa607641 100644 --- a/src/spacecharge/wrap_spacechargeforcecalc2p5d.cc +++ b/src/spacecharge/wrap_spacechargeforcecalc2p5d.cc @@ -1,13 +1,13 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" # -#include "wrap_spacechargeforcecalc2p5d.hh" -#include "wrap_spacecharge.hh" -#include "wrap_bunch.hh" +#include "spacecharge/wrap_spacechargeforcecalc2p5d.hh" +#include "spacecharge/wrap_spacecharge.hh" +#include "orbit/wrap_bunch.hh" #include -#include "SpaceChargeForceCalc2p5D.hh" +#include "spacecharge/SpaceChargeForceCalc2p5D.hh" using namespace OrbitUtils; diff --git a/src/spacecharge/wrap_uniform_ellipsoid_field_calculator.cc b/src/spacecharge/wrap_uniform_ellipsoid_field_calculator.cc index 37e0b3d1..655b1d5d 100644 --- a/src/spacecharge/wrap_uniform_ellipsoid_field_calculator.cc +++ b/src/spacecharge/wrap_uniform_ellipsoid_field_calculator.cc @@ -1,10 +1,10 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "UniformEllipsoidFieldCalculator.hh" +#include "spacecharge/UniformEllipsoidFieldCalculator.hh" -#include "wrap_uniform_ellipsoid_field_calculator.hh" -#include "wrap_spacecharge.hh" +#include "spacecharge/wrap_uniform_ellipsoid_field_calculator.hh" +#include "spacecharge/wrap_spacecharge.hh" #include diff --git a/src/teapot/MatrixGenerator.cc b/src/teapot/MatrixGenerator.cc index 48ed1a4d..3d1af484 100644 --- a/src/teapot/MatrixGenerator.cc +++ b/src/teapot/MatrixGenerator.cc @@ -20,8 +20,8 @@ // b = ((y1-y0)*x2^2 - (y2-y0)*x1^2) / (x1*x2*(x2-x1)) // ///////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" -#include "MatrixGenerator.hh" +#include "mpi/orbit_mpi.hh" +#include "teapot/MatrixGenerator.hh" using namespace OrbitUtils; diff --git a/src/teapot/MatrixGenerator.hh b/src/teapot/MatrixGenerator.hh index 03c290d9..66d5530a 100644 --- a/src/teapot/MatrixGenerator.hh +++ b/src/teapot/MatrixGenerator.hh @@ -16,8 +16,8 @@ #ifndef TEAPOT_BASE_MATRIX_GENERATOR_H #define TEAPOT_BASE_MATRIX_GENERATOR_H -#include "Bunch.hh" -#include "Matrix.hh" +#include "orbit/Bunch.hh" +#include "utils/matrix/Matrix.hh" using namespace OrbitUtils; diff --git a/src/teapot/teapotbase.cc b/src/teapot/teapotbase.cc index 042d3922..2a618f56 100644 --- a/src/teapot/teapotbase.cc +++ b/src/teapot/teapotbase.cc @@ -31,10 +31,10 @@ // /////////////////////////////////////////////////////////////////////////// -#include "teapotbase.hh" -#include "OrbitConst.hh" -#include "Bunch.hh" -#include "SyncPart.hh" +#include "teapot/teapotbase.hh" +#include "orbit/OrbitConst.hh" +#include "orbit/Bunch.hh" +#include "orbit/SyncPart.hh" #include diff --git a/src/teapot/teapotbase.hh b/src/teapot/teapotbase.hh index 351a407a..4e83b866 100644 --- a/src/teapot/teapotbase.hh +++ b/src/teapot/teapotbase.hh @@ -23,7 +23,7 @@ #ifndef TEAPOT_BASE_H #define TEAPOT_BASE_H -#include "Bunch.hh" +#include "orbit/Bunch.hh" namespace teapot_base { diff --git a/src/teapot/wrap_matrix_generator.cc b/src/teapot/wrap_matrix_generator.cc index 793d58f7..15ce3f9a 100644 --- a/src/teapot/wrap_matrix_generator.cc +++ b/src/teapot/wrap_matrix_generator.cc @@ -1,15 +1,15 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_matrix_generator.hh" -#include "wrap_teapotbase.hh" -#include "wrap_bunch.hh" -#include "wrap_utils.hh" +#include "teapot/wrap_matrix_generator.hh" +#include "teapot/wrap_teapotbase.hh" +#include "orbit/wrap_bunch.hh" +#include "utils/wrap_utils.hh" #include -#include "MatrixGenerator.hh" -#include "MatrixOperations.hh" +#include "teapot/MatrixGenerator.hh" +#include "utils/matrix/MatrixOperations.hh" using namespace OrbitUtils; using namespace teapot_base; diff --git a/src/teapot/wrap_teapotbase.cc b/src/teapot/wrap_teapotbase.cc index 68525d9a..c6a50b53 100644 --- a/src/teapot/wrap_teapotbase.cc +++ b/src/teapot/wrap_teapotbase.cc @@ -1,12 +1,12 @@ #include -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "main/pyORBIT_Object.hh" -#include "teapotbase.hh" +#include "teapot/teapotbase.hh" -#include "wrap_teapotbase.hh" -#include "wrap_matrix_generator.hh" +#include "teapot/wrap_teapotbase.hh" +#include "teapot/wrap_matrix_generator.hh" namespace wrap_teapotbase { diff --git a/src/trackerrk4/ExtEffectsContainer.cc b/src/trackerrk4/ExtEffectsContainer.cc index 4bab44d3..c876553c 100644 --- a/src/trackerrk4/ExtEffectsContainer.cc +++ b/src/trackerrk4/ExtEffectsContainer.cc @@ -21,8 +21,8 @@ // This is an example of embedding Python in C++ Orbit level. // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" -#include "ExtEffectsContainer.hh" +#include "mpi/orbit_mpi.hh" +#include "trackerrk4/ExtEffectsContainer.hh" #include #include #include diff --git a/src/trackerrk4/ExtEffectsContainer.hh b/src/trackerrk4/ExtEffectsContainer.hh index 73994f9b..1845be6c 100644 --- a/src/trackerrk4/ExtEffectsContainer.hh +++ b/src/trackerrk4/ExtEffectsContainer.hh @@ -5,7 +5,7 @@ #include -#include "ExternalEffects.hh" +#include "trackerrk4/ExternalEffects.hh" #include diff --git a/src/trackerrk4/ExternalEffects.cc b/src/trackerrk4/ExternalEffects.cc index 0cede32f..bfc1c22a 100644 --- a/src/trackerrk4/ExternalEffects.cc +++ b/src/trackerrk4/ExternalEffects.cc @@ -11,12 +11,12 @@ // slow changing magnetic and electric fields. // /////////////////////////////////////////////////////////////////////////// -#include "RungeKuttaTracker.hh" +#include "trackerrk4/RungeKuttaTracker.hh" #include #include #include -#include "ExternalEffects.hh" +#include "trackerrk4/ExternalEffects.hh" using namespace TrackerRK4; diff --git a/src/trackerrk4/ExternalEffects.hh b/src/trackerrk4/ExternalEffects.hh index c613e82c..57b252ac 100644 --- a/src/trackerrk4/ExternalEffects.hh +++ b/src/trackerrk4/ExternalEffects.hh @@ -16,10 +16,10 @@ #include -#include "Bunch.hh" -#include "BaseFieldSource.hh" +#include "orbit/Bunch.hh" +#include "utils/BaseFieldSource.hh" -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" namespace TrackerRK4{ diff --git a/src/trackerrk4/PyExternalEffects.cc b/src/trackerrk4/PyExternalEffects.cc index cfca4c28..5a7648d5 100644 --- a/src/trackerrk4/PyExternalEffects.cc +++ b/src/trackerrk4/PyExternalEffects.cc @@ -26,11 +26,11 @@ // debugging only. // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include -#include "PyExternalEffects.hh" -#include "RungeKuttaTracker.hh" +#include "trackerrk4/PyExternalEffects.hh" +#include "trackerrk4/RungeKuttaTracker.hh" //#include using namespace TrackerRK4; diff --git a/src/trackerrk4/PyExternalEffects.hh b/src/trackerrk4/PyExternalEffects.hh index f5ecce14..219e76c7 100644 --- a/src/trackerrk4/PyExternalEffects.hh +++ b/src/trackerrk4/PyExternalEffects.hh @@ -31,7 +31,7 @@ #include -#include "ExternalEffects.hh" +#include "trackerrk4/ExternalEffects.hh" namespace TrackerRK4{ diff --git a/src/trackerrk4/RungeKuttaTracker.cc b/src/trackerrk4/RungeKuttaTracker.cc index 91d58667..09f6eae7 100644 --- a/src/trackerrk4/RungeKuttaTracker.cc +++ b/src/trackerrk4/RungeKuttaTracker.cc @@ -14,7 +14,7 @@ // // /////////////////////////////////////////////////////////////////////////// -#include "RungeKuttaTracker.hh" +#include "trackerrk4/RungeKuttaTracker.hh" #include #include @@ -23,7 +23,7 @@ using namespace TrackerRK4; using namespace OrbitUtils; -#include "OrbitConst.hh" +#include "orbit/OrbitConst.hh" RungeKuttaTracker::RungeKuttaTracker(double lengthIn){ diff --git a/src/trackerrk4/RungeKuttaTracker.hh b/src/trackerrk4/RungeKuttaTracker.hh index 40ce050d..cbb4a8df 100644 --- a/src/trackerrk4/RungeKuttaTracker.hh +++ b/src/trackerrk4/RungeKuttaTracker.hh @@ -17,11 +17,11 @@ #ifndef RUNGE_KUTTA_3D_TRACKER_H #define RUNGE_KUTTA_3D_TRACKER_H -#include "Bunch.hh" -#include "BaseFieldSource.hh" -#include "ExternalEffects.hh" +#include "orbit/Bunch.hh" +#include "utils/BaseFieldSource.hh" +#include "trackerrk4/ExternalEffects.hh" -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" namespace TrackerRK4{ diff --git a/src/trackerrk4/wrap_ext_effects_container.cc b/src/trackerrk4/wrap_ext_effects_container.cc index 407187b9..26750f1d 100644 --- a/src/trackerrk4/wrap_ext_effects_container.cc +++ b/src/trackerrk4/wrap_ext_effects_container.cc @@ -1,14 +1,14 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_utils.hh" -#include "wrap_ext_effects_container.hh" +#include "utils/wrap_utils.hh" +#include "trackerrk4/wrap_ext_effects_container.hh" #include #include -#include "ExtEffectsContainer.hh" -#include "ExternalEffects.hh" +#include "trackerrk4/ExtEffectsContainer.hh" +#include "trackerrk4/ExternalEffects.hh" using namespace OrbitUtils; diff --git a/src/trackerrk4/wrap_py_external_effects.cc b/src/trackerrk4/wrap_py_external_effects.cc index 67f80279..62f12d6c 100644 --- a/src/trackerrk4/wrap_py_external_effects.cc +++ b/src/trackerrk4/wrap_py_external_effects.cc @@ -1,13 +1,13 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_utils.hh" -#include "wrap_py_external_effects.hh" +#include "utils/wrap_utils.hh" +#include "trackerrk4/wrap_py_external_effects.hh" #include #include -#include "PyExternalEffects.hh" +#include "trackerrk4/PyExternalEffects.hh" using namespace OrbitUtils; using namespace TrackerRK4; diff --git a/src/trackerrk4/wrap_runge_kutta_tracker.cc b/src/trackerrk4/wrap_runge_kutta_tracker.cc index 4f73283d..c2dfad8b 100644 --- a/src/trackerrk4/wrap_runge_kutta_tracker.cc +++ b/src/trackerrk4/wrap_runge_kutta_tracker.cc @@ -1,11 +1,11 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_runge_kutta_tracker.hh" +#include "trackerrk4/wrap_runge_kutta_tracker.hh" #include -#include "RungeKuttaTracker.hh" +#include "trackerrk4/RungeKuttaTracker.hh" using namespace TrackerRK4; using namespace OrbitUtils; diff --git a/src/trackerrk4/wrap_trackerrk4.cc b/src/trackerrk4/wrap_trackerrk4.cc index a955b7be..8ea7aca7 100644 --- a/src/trackerrk4/wrap_trackerrk4.cc +++ b/src/trackerrk4/wrap_trackerrk4.cc @@ -1,9 +1,9 @@ -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" -#include "wrap_trackerrk4.hh" -#include "wrap_runge_kutta_tracker.hh" -#include "wrap_py_external_effects.hh" -#include "wrap_ext_effects_container.hh" +#include "trackerrk4/wrap_trackerrk4.hh" +#include "trackerrk4/wrap_runge_kutta_tracker.hh" +#include "trackerrk4/wrap_py_external_effects.hh" +#include "trackerrk4/wrap_ext_effects_container.hh" static PyMethodDef trackerrk4Methods[] = { {NULL,NULL} }; diff --git a/src/utils/AttributesBucket.cc b/src/utils/AttributesBucket.cc index 676f5521..10931988 100644 --- a/src/utils/AttributesBucket.cc +++ b/src/utils/AttributesBucket.cc @@ -13,7 +13,7 @@ // A class for collection of int and double attributes in the dictionary. /////////////////////////////////////////////////////////////////////////// -#include "AttributesBucket.hh" +#include "utils/AttributesBucket.hh" using namespace OrbitUtils; diff --git a/src/utils/BaseFieldSource.cc b/src/utils/BaseFieldSource.cc index baace095..e4252c98 100644 --- a/src/utils/BaseFieldSource.cc +++ b/src/utils/BaseFieldSource.cc @@ -14,7 +14,7 @@ /////////////////////////////////////////////////////////////////////////// -#include "BaseFieldSource.hh" +#include "utils/BaseFieldSource.hh" using namespace OrbitUtils; diff --git a/src/utils/BaseFieldSource.hh b/src/utils/BaseFieldSource.hh index f4727445..45649ab7 100644 --- a/src/utils/BaseFieldSource.hh +++ b/src/utils/BaseFieldSource.hh @@ -12,7 +12,7 @@ #ifndef BASE_FIELD_SOURCE_H #define BASE_FIELD_SOURCE_H -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" namespace OrbitUtils{ diff --git a/src/utils/BufferStore.cc b/src/utils/BufferStore.cc index 7822570e..9c5f06ef 100644 --- a/src/utils/BufferStore.cc +++ b/src/utils/BufferStore.cc @@ -19,7 +19,7 @@ #include #include -#include "BufferStore.hh" +#include "utils/BufferStore.hh" using namespace OrbitUtils; diff --git a/src/utils/CppPyWrapper.cc b/src/utils/CppPyWrapper.cc index b3178252..b9bae280 100644 --- a/src/utils/CppPyWrapper.cc +++ b/src/utils/CppPyWrapper.cc @@ -12,7 +12,7 @@ // this class. // /////////////////////////////////////////////////////////////////////////// -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" using namespace OrbitUtils; diff --git a/src/utils/FieldSourceContainer.cc b/src/utils/FieldSourceContainer.cc index 15ad959a..6c58b799 100644 --- a/src/utils/FieldSourceContainer.cc +++ b/src/utils/FieldSourceContainer.cc @@ -13,13 +13,13 @@ // The container for instances of the BaseFieldSource class. // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include #include #include -#include "FieldSourceContainer.hh" +#include "utils/FieldSourceContainer.hh" using namespace OrbitUtils; diff --git a/src/utils/FieldSourceContainer.hh b/src/utils/FieldSourceContainer.hh index bfd4c06d..a47768c1 100644 --- a/src/utils/FieldSourceContainer.hh +++ b/src/utils/FieldSourceContainer.hh @@ -20,7 +20,7 @@ #include -#include "BaseFieldSource.hh" +#include "utils/BaseFieldSource.hh" #include namespace OrbitUtils{ diff --git a/src/utils/MathPolynomial.cc b/src/utils/MathPolynomial.cc index ad623772..fffa77d9 100644 --- a/src/utils/MathPolynomial.cc +++ b/src/utils/MathPolynomial.cc @@ -14,8 +14,8 @@ // different polynomials. // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" -#include "MathPolynomial.hh" +#include "mpi/orbit_mpi.hh" +#include "utils/MathPolynomial.hh" using namespace OrbitUtils; diff --git a/src/utils/MathPolynomial.hh b/src/utils/MathPolynomial.hh index 9ce9c95b..af6fa605 100644 --- a/src/utils/MathPolynomial.hh +++ b/src/utils/MathPolynomial.hh @@ -19,7 +19,7 @@ /////////////////////////////////////////////////////////////////////////// #include #include -#include "tcomplex.hh" +#include "utils/tcomplex.hh" #include namespace OrbitUtils{ diff --git a/src/utils/OU_Function.cc b/src/utils/OU_Function.cc index 2cfa3145..1f5348d5 100644 --- a/src/utils/OU_Function.cc +++ b/src/utils/OU_Function.cc @@ -15,8 +15,8 @@ // It is using linear interpolation. // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" -#include "OU_Function.hh" +#include "mpi/orbit_mpi.hh" +#include "utils/OU_Function.hh" #include diff --git a/src/utils/OU_Function.hh b/src/utils/OU_Function.hh index 0f8fbcc2..9a1fe969 100644 --- a/src/utils/OU_Function.hh +++ b/src/utils/OU_Function.hh @@ -18,7 +18,7 @@ #ifndef ORBIT_UTILS_FUNCTION_H #define ORBIT_UTILS_FUNCTION_H -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" #include #include diff --git a/src/utils/OU_SplineCH.cc b/src/utils/OU_SplineCH.cc index 169a4509..384a48c2 100644 --- a/src/utils/OU_SplineCH.cc +++ b/src/utils/OU_SplineCH.cc @@ -23,8 +23,8 @@ // m[n-2] = (y[n-1] - y[n-2])/(x[n-1]-x[n-2]) // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" -#include "OU_SplineCH.hh" +#include "mpi/orbit_mpi.hh" +#include "utils/OU_SplineCH.hh" #include diff --git a/src/utils/OU_SplineCH.hh b/src/utils/OU_SplineCH.hh index 15767a51..eac2dd72 100644 --- a/src/utils/OU_SplineCH.hh +++ b/src/utils/OU_SplineCH.hh @@ -31,8 +31,8 @@ #include #include -#include "CppPyWrapper.hh" -#include "OU_Function.hh" +#include "utils/CppPyWrapper.hh" +#include "utils/OU_Function.hh" namespace OrbitUtils{ diff --git a/src/utils/PyBaseFieldSource.cc b/src/utils/PyBaseFieldSource.cc index f2ba47bf..13faada7 100644 --- a/src/utils/PyBaseFieldSource.cc +++ b/src/utils/PyBaseFieldSource.cc @@ -19,9 +19,9 @@ // debugging only. // /////////////////////////////////////////////////////////////////////////// -#include "PyBaseFieldSource.hh" +#include "utils/PyBaseFieldSource.hh" -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include using namespace OrbitUtils; diff --git a/src/utils/PyBaseFieldSource.hh b/src/utils/PyBaseFieldSource.hh index a79ce1dd..6b34b2ee 100644 --- a/src/utils/PyBaseFieldSource.hh +++ b/src/utils/PyBaseFieldSource.hh @@ -24,7 +24,7 @@ #include -#include "BaseFieldSource.hh" +#include "utils/BaseFieldSource.hh" namespace OrbitUtils{ diff --git a/src/utils/Random.cc b/src/utils/Random.cc index 4725232a..ef8090d5 100644 --- a/src/utils/Random.cc +++ b/src/utils/Random.cc @@ -15,7 +15,7 @@ // a random number between 0 and 1. /////////////////////////////////////////////////////////////////////////// -#include "Random.hh" +#include "utils/Random.hh" #include using namespace OrbitUtils; diff --git a/src/utils/StringUtils.cc b/src/utils/StringUtils.cc index 03671cf8..90f3dc9a 100644 --- a/src/utils/StringUtils.cc +++ b/src/utils/StringUtils.cc @@ -1,4 +1,4 @@ -#include "StringUtils.hh" +#include "utils/StringUtils.hh" #include #include diff --git a/src/utils/bessel.cc b/src/utils/bessel.cc index f7817d0d..6a0a9bdc 100644 --- a/src/utils/bessel.cc +++ b/src/utils/bessel.cc @@ -13,7 +13,7 @@ // /////////////////////////////////////////////////////////////////////////// -#include "bessel.hh" +#include "utils/bessel.hh" namespace OrbitUtils{ diff --git a/src/utils/bunch/BunchExtremaCalculator.cc b/src/utils/bunch/BunchExtremaCalculator.cc index 0571fcdb..68a37835 100644 --- a/src/utils/bunch/BunchExtremaCalculator.cc +++ b/src/utils/bunch/BunchExtremaCalculator.cc @@ -14,9 +14,9 @@ // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" -#include "BunchExtremaCalculator.hh" -#include "BufferStore.hh" +#include "mpi/orbit_mpi.hh" +#include "utils/bunch/BunchExtremaCalculator.hh" +#include "utils/BufferStore.hh" #include #include diff --git a/src/utils/bunch/BunchExtremaCalculator.hh b/src/utils/bunch/BunchExtremaCalculator.hh index 104446a7..078cebbd 100644 --- a/src/utils/bunch/BunchExtremaCalculator.hh +++ b/src/utils/bunch/BunchExtremaCalculator.hh @@ -18,7 +18,7 @@ #define BUNCH_EXTREMA_CALCULATIONS_H //ORBIT bunch -#include "Bunch.hh" +#include "orbit/Bunch.hh" namespace OrbitUtils{ diff --git a/src/utils/bunch/InitialCoordsAttrFunctions.cc b/src/utils/bunch/InitialCoordsAttrFunctions.cc index 63a7562b..9ea60ceb 100644 --- a/src/utils/bunch/InitialCoordsAttrFunctions.cc +++ b/src/utils/bunch/InitialCoordsAttrFunctions.cc @@ -39,14 +39,14 @@ // wx = exp(-(x^2+(alphax*x+betax*x')^2)/(2*(betax*emittancex)) etc. // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" -#include "InitialCoordsAttrFunctions.hh" -#include "ParticleInitialCoordinates.hh" -#include "ParticleMacroSize.hh" - -#include "BufferStore.hh" -#include "MatrixOperations.hh" -#include "BunchTwissAnalysis.hh" +#include "mpi/orbit_mpi.hh" +#include "utils/bunch/InitialCoordsAttrFunctions.hh" +#include "orbit/ParticlesAttributes/ParticleInitialCoordinates.hh" +#include "orbit/ParticlesAttributes/ParticleMacroSize.hh" + +#include "utils/BufferStore.hh" +#include "utils/matrix/MatrixOperations.hh" +#include "orbit/BunchDiagnostics/BunchTwissAnalysis.hh" #include // std::sort #include // std::vector diff --git a/src/utils/bunch/InitialCoordsAttrFunctions.hh b/src/utils/bunch/InitialCoordsAttrFunctions.hh index 53d77820..d06522b7 100644 --- a/src/utils/bunch/InitialCoordsAttrFunctions.hh +++ b/src/utils/bunch/InitialCoordsAttrFunctions.hh @@ -18,9 +18,9 @@ #define PARTICLES_INIT_COORDS_FUNCTIONS_H //ORBIT bunch -#include "Bunch.hh" +#include "orbit/Bunch.hh" -#include "Matrix.hh" +#include "utils/matrix/Matrix.hh" #include diff --git a/src/utils/bunch/ParticlesWithIdFunctions.cc b/src/utils/bunch/ParticlesWithIdFunctions.cc index 26a6d7f4..f2a93729 100644 --- a/src/utils/bunch/ParticlesWithIdFunctions.cc +++ b/src/utils/bunch/ParticlesWithIdFunctions.cc @@ -23,14 +23,14 @@ // wx = exp(-(x^2+(alphax*x+betax*x')^2)/(2*(betax*emittancex)) etc. // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" -#include "ParticlesWithIdFunctions.hh" -#include "ParticleIdNumber.hh" -#include "ParticleMacroSize.hh" - -#include "BufferStore.hh" -#include "MatrixOperations.hh" -#include "BunchTwissAnalysis.hh" +#include "mpi/orbit_mpi.hh" +#include "utils/bunch/ParticlesWithIdFunctions.hh" +#include "orbit/ParticlesAttributes/ParticleIdNumber.hh" +#include "orbit/ParticlesAttributes/ParticleMacroSize.hh" + +#include "utils/BufferStore.hh" +#include "utils/matrix/MatrixOperations.hh" +#include "orbit/BunchDiagnostics/BunchTwissAnalysis.hh" #include // std::sort #include // std::vector diff --git a/src/utils/bunch/ParticlesWithIdFunctions.hh b/src/utils/bunch/ParticlesWithIdFunctions.hh index 023e5bfe..0865a418 100644 --- a/src/utils/bunch/ParticlesWithIdFunctions.hh +++ b/src/utils/bunch/ParticlesWithIdFunctions.hh @@ -20,9 +20,9 @@ #include //ORBIT bunch -#include "Bunch.hh" +#include "orbit/Bunch.hh" -#include "Matrix.hh" +#include "utils/matrix/Matrix.hh" namespace OrbitUtils{ diff --git a/src/utils/bunch/TwissFilteringFunctions.cc b/src/utils/bunch/TwissFilteringFunctions.cc index 56902267..e9afbe8e 100644 --- a/src/utils/bunch/TwissFilteringFunctions.cc +++ b/src/utils/bunch/TwissFilteringFunctions.cc @@ -15,9 +15,9 @@ // /////////////////////////////////////////////////////////////////////////// -#include "BunchTwissAnalysis.hh" +#include "orbit/BunchDiagnostics/BunchTwissAnalysis.hh" -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" namespace OrbitUtils{ diff --git a/src/utils/bunch/TwissFilteringFunctions.hh b/src/utils/bunch/TwissFilteringFunctions.hh index 63d99bc4..a09fe2f9 100644 --- a/src/utils/bunch/TwissFilteringFunctions.hh +++ b/src/utils/bunch/TwissFilteringFunctions.hh @@ -21,7 +21,7 @@ #include //ORBIT bunch -#include "Bunch.hh" +#include "orbit/Bunch.hh" namespace OrbitUtils{ diff --git a/src/utils/bunch/wrap_bunch_extrema_calculator.cc b/src/utils/bunch/wrap_bunch_extrema_calculator.cc index c23ebaf8..b84052bd 100644 --- a/src/utils/bunch/wrap_bunch_extrema_calculator.cc +++ b/src/utils/bunch/wrap_bunch_extrema_calculator.cc @@ -1,13 +1,13 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_utils.hh" -#include "wrap_matrix.hh" -#include "wrap_bunch.hh" +#include "utils/wrap_utils.hh" +#include "utils/matrix/wrap_matrix.hh" +#include "orbit/wrap_bunch.hh" #include -#include "BunchExtremaCalculator.hh" +#include "utils/bunch/BunchExtremaCalculator.hh" using namespace OrbitUtils; using namespace wrap_orbit_utils; diff --git a/src/utils/bunch/wrap_bunch_utils_functions.cc b/src/utils/bunch/wrap_bunch_utils_functions.cc index 0e29cc67..c6666b43 100644 --- a/src/utils/bunch/wrap_bunch_utils_functions.cc +++ b/src/utils/bunch/wrap_bunch_utils_functions.cc @@ -1,14 +1,14 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" #include -#include "wrap_bunch.hh" -#include "wrap_utils.hh" +#include "orbit/wrap_bunch.hh" +#include "utils/wrap_utils.hh" -#include "ParticlesWithIdFunctions.hh" -#include "TwissFilteringFunctions.hh" -#include "InitialCoordsAttrFunctions.hh" +#include "utils/bunch/ParticlesWithIdFunctions.hh" +#include "utils/bunch/TwissFilteringFunctions.hh" +#include "utils/bunch/InitialCoordsAttrFunctions.hh" using namespace OrbitUtils; diff --git a/src/utils/field_sources/DipoleFieldSource.cc b/src/utils/field_sources/DipoleFieldSource.cc index 7cbc091e..f73f1dcb 100644 --- a/src/utils/field_sources/DipoleFieldSource.cc +++ b/src/utils/field_sources/DipoleFieldSource.cc @@ -17,16 +17,16 @@ // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" -#include "BufferStore.hh" +#include "mpi/orbit_mpi.hh" +#include "utils/BufferStore.hh" #include #include #include #include -#include "ShiftedFieldSource.hh" -#include "DipoleFieldSource.hh" +#include "utils/field_sources/ShiftedFieldSource.hh" +#include "utils/field_sources/DipoleFieldSource.hh" using namespace OrbitUtils; diff --git a/src/utils/field_sources/DipoleFieldSource.hh b/src/utils/field_sources/DipoleFieldSource.hh index c95553f1..7fc73dfb 100644 --- a/src/utils/field_sources/DipoleFieldSource.hh +++ b/src/utils/field_sources/DipoleFieldSource.hh @@ -19,8 +19,8 @@ #ifndef DIPOLE_FIELD_SOURCE_H #define DIPOLE_FIELD_SOURCE_H -#include "Grid3D.hh" -#include "ShiftedFieldSource.hh" +#include "spacecharge/Grid3D.hh" +#include "utils/field_sources/ShiftedFieldSource.hh" namespace OrbitUtils{ diff --git a/src/utils/field_sources/LoopFieldSource.cc b/src/utils/field_sources/LoopFieldSource.cc index 0263c9f9..da78cbc2 100644 --- a/src/utils/field_sources/LoopFieldSource.cc +++ b/src/utils/field_sources/LoopFieldSource.cc @@ -20,19 +20,19 @@ // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" -#include "BufferStore.hh" +#include "mpi/orbit_mpi.hh" +#include "utils/BufferStore.hh" #include #include #include #include -#include "ShiftedFieldSource.hh" -#include "LoopFieldSource.hh" -#include "elliptint.hh" +#include "utils/field_sources/ShiftedFieldSource.hh" +#include "utils/field_sources/LoopFieldSource.hh" +#include "utils/ellipticalint/elliptint.hh" -#include "OrbitConst.hh" +#include "orbit/OrbitConst.hh" using namespace OrbitUtils; diff --git a/src/utils/field_sources/LoopFieldSource.hh b/src/utils/field_sources/LoopFieldSource.hh index 194d7443..b155c476 100644 --- a/src/utils/field_sources/LoopFieldSource.hh +++ b/src/utils/field_sources/LoopFieldSource.hh @@ -23,7 +23,7 @@ #ifndef CURRENT_LOOP_FIELD_SOURCE_H #define CURRENT_LOOP_FIELD_SOURCE_H -#include "ShiftedFieldSource.hh" +#include "utils/field_sources/ShiftedFieldSource.hh" namespace OrbitUtils{ diff --git a/src/utils/field_sources/MagnetFieldSourceGrid3D.cc b/src/utils/field_sources/MagnetFieldSourceGrid3D.cc index f6199526..9e147cf9 100644 --- a/src/utils/field_sources/MagnetFieldSourceGrid3D.cc +++ b/src/utils/field_sources/MagnetFieldSourceGrid3D.cc @@ -22,16 +22,16 @@ // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" -#include "BufferStore.hh" +#include "mpi/orbit_mpi.hh" +#include "utils/BufferStore.hh" #include #include #include #include -#include "ShiftedFieldSource.hh" -#include "MagnetFieldSourceGrid3D.hh" +#include "utils/field_sources/ShiftedFieldSource.hh" +#include "utils/field_sources/MagnetFieldSourceGrid3D.hh" using namespace OrbitUtils; diff --git a/src/utils/field_sources/MagnetFieldSourceGrid3D.hh b/src/utils/field_sources/MagnetFieldSourceGrid3D.hh index b55925fc..45844a32 100644 --- a/src/utils/field_sources/MagnetFieldSourceGrid3D.hh +++ b/src/utils/field_sources/MagnetFieldSourceGrid3D.hh @@ -25,8 +25,8 @@ #ifndef MAGNET_FIELD_SOURCE_GRID3D_H #define MAGNET_FIELD_SOURCE_GRID3D_H -#include "Grid3D.hh" -#include "ShiftedFieldSource.hh" +#include "spacecharge/Grid3D.hh" +#include "utils/field_sources/ShiftedFieldSource.hh" namespace OrbitUtils{ diff --git a/src/utils/field_sources/QuadFieldSource.cc b/src/utils/field_sources/QuadFieldSource.cc index dcd2cb00..c89e9bed 100644 --- a/src/utils/field_sources/QuadFieldSource.cc +++ b/src/utils/field_sources/QuadFieldSource.cc @@ -18,16 +18,16 @@ // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" -#include "BufferStore.hh" +#include "mpi/orbit_mpi.hh" +#include "utils/BufferStore.hh" #include #include #include #include -#include "ShiftedFieldSource.hh" -#include "QuadFieldSource.hh" +#include "utils/field_sources/ShiftedFieldSource.hh" +#include "utils/field_sources/QuadFieldSource.hh" using namespace OrbitUtils; diff --git a/src/utils/field_sources/QuadFieldSource.hh b/src/utils/field_sources/QuadFieldSource.hh index 00eab099..8a8a2dd3 100644 --- a/src/utils/field_sources/QuadFieldSource.hh +++ b/src/utils/field_sources/QuadFieldSource.hh @@ -21,8 +21,8 @@ #ifndef QUAD_FIELD_SOURCE_H #define QUAD_FIELD_SOURCE_H -#include "Grid3D.hh" -#include "ShiftedFieldSource.hh" +#include "spacecharge/Grid3D.hh" +#include "utils/field_sources/ShiftedFieldSource.hh" namespace OrbitUtils{ diff --git a/src/utils/field_sources/ShiftedFieldSource.cc b/src/utils/field_sources/ShiftedFieldSource.cc index fd357bbb..7eb2e6b4 100644 --- a/src/utils/field_sources/ShiftedFieldSource.cc +++ b/src/utils/field_sources/ShiftedFieldSource.cc @@ -25,10 +25,10 @@ /////////////////////////////////////////////////////////////////////////// #include -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" -#include "ShiftedFieldSource.hh" -#include "MatrixOperations.hh" +#include "utils/field_sources/ShiftedFieldSource.hh" +#include "utils/matrix/MatrixOperations.hh" using namespace OrbitUtils; diff --git a/src/utils/field_sources/ShiftedFieldSource.hh b/src/utils/field_sources/ShiftedFieldSource.hh index 6aaed8ac..39b0ac06 100644 --- a/src/utils/field_sources/ShiftedFieldSource.hh +++ b/src/utils/field_sources/ShiftedFieldSource.hh @@ -27,16 +27,16 @@ #ifndef SHIFTED_FIELD_SOURCE_H #define SHIFTED_FIELD_SOURCE_H -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" #include #include #include #include -#include "BaseFieldSource.hh" -#include "Matrix.hh" -#include "PhaseVector.hh" +#include "utils/BaseFieldSource.hh" +#include "utils/matrix/Matrix.hh" +#include "utils/matrix/PhaseVector.hh" namespace OrbitUtils{ diff --git a/src/utils/field_sources/wrap_dipole_field_source.cc b/src/utils/field_sources/wrap_dipole_field_source.cc index 07ba696e..8c96058c 100644 --- a/src/utils/field_sources/wrap_dipole_field_source.cc +++ b/src/utils/field_sources/wrap_dipole_field_source.cc @@ -1,9 +1,9 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" -#include "wrap_spacecharge.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" +#include "spacecharge/wrap_spacecharge.hh" -#include "wrap_utils.hh" -#include "DipoleFieldSource.hh" +#include "utils/wrap_utils.hh" +#include "utils/field_sources/DipoleFieldSource.hh" #include diff --git a/src/utils/field_sources/wrap_field_sources_module.cc b/src/utils/field_sources/wrap_field_sources_module.cc index a1973289..309e3c94 100644 --- a/src/utils/field_sources/wrap_field_sources_module.cc +++ b/src/utils/field_sources/wrap_field_sources_module.cc @@ -1,15 +1,15 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" #include -#include "wrap_bunch.hh" -#include "wrap_utils.hh" +#include "orbit/wrap_bunch.hh" +#include "utils/wrap_utils.hh" -#include "wrap_magnetic_field_source_grid3d.hh" -#include "wrap_quad_field_source.hh" -#include "wrap_dipole_field_source.hh" -#include "wrap_loop_field_source.hh" +#include "utils/field_sources/wrap_magnetic_field_source_grid3d.hh" +#include "utils/field_sources/wrap_quad_field_source.hh" +#include "utils/field_sources/wrap_dipole_field_source.hh" +#include "utils/field_sources/wrap_loop_field_source.hh" namespace wrap_field_sources_module{ diff --git a/src/utils/field_sources/wrap_loop_field_source.cc b/src/utils/field_sources/wrap_loop_field_source.cc index a3c638be..a6e7d183 100644 --- a/src/utils/field_sources/wrap_loop_field_source.cc +++ b/src/utils/field_sources/wrap_loop_field_source.cc @@ -1,9 +1,9 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" -#include "wrap_spacecharge.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" +#include "spacecharge/wrap_spacecharge.hh" -#include "wrap_utils.hh" -#include "LoopFieldSource.hh" +#include "utils/wrap_utils.hh" +#include "utils/field_sources/LoopFieldSource.hh" #include diff --git a/src/utils/field_sources/wrap_magnetic_field_source_grid3d.cc b/src/utils/field_sources/wrap_magnetic_field_source_grid3d.cc index 53c6d1db..15e1fc18 100644 --- a/src/utils/field_sources/wrap_magnetic_field_source_grid3d.cc +++ b/src/utils/field_sources/wrap_magnetic_field_source_grid3d.cc @@ -1,9 +1,9 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" -#include "wrap_spacecharge.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" +#include "spacecharge/wrap_spacecharge.hh" -#include "wrap_utils.hh" -#include "MagnetFieldSourceGrid3D.hh" +#include "utils/wrap_utils.hh" +#include "utils/field_sources/MagnetFieldSourceGrid3D.hh" #include diff --git a/src/utils/field_sources/wrap_quad_field_source.cc b/src/utils/field_sources/wrap_quad_field_source.cc index ba1b29e4..3910aa06 100644 --- a/src/utils/field_sources/wrap_quad_field_source.cc +++ b/src/utils/field_sources/wrap_quad_field_source.cc @@ -1,9 +1,9 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" -#include "wrap_spacecharge.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" +#include "spacecharge/wrap_spacecharge.hh" -#include "wrap_utils.hh" -#include "QuadFieldSource.hh" +#include "utils/wrap_utils.hh" +#include "utils/field_sources/QuadFieldSource.hh" #include diff --git a/src/utils/harmonic_analysis/HarmonicData.cc b/src/utils/harmonic_analysis/HarmonicData.cc index 2f10c1ed..a600bb13 100644 --- a/src/utils/harmonic_analysis/HarmonicData.cc +++ b/src/utils/harmonic_analysis/HarmonicData.cc @@ -30,9 +30,9 @@ /////////////////////////////////////////////////////////////////////////// #include -#include "orbit_mpi.hh" -#include "HarmonicData.hh" -#include "OrbitConst.hh" +#include "mpi/orbit_mpi.hh" +#include "utils/harmonic_analysis/HarmonicData.hh" +#include "orbit/OrbitConst.hh" using namespace OrbitUtils; diff --git a/src/utils/harmonic_analysis/HarmonicData.hh b/src/utils/harmonic_analysis/HarmonicData.hh index ab8f97aa..39eb74b2 100644 --- a/src/utils/harmonic_analysis/HarmonicData.hh +++ b/src/utils/harmonic_analysis/HarmonicData.hh @@ -31,8 +31,8 @@ #ifndef ORBIT_UTILS_HARMONICDATA_H #define ORBIT_UTILS_HARMONICDATA_H -#include "CppPyWrapper.hh" -#include "OU_Function.hh" +#include "utils/CppPyWrapper.hh" +#include "utils/OU_Function.hh" using namespace std; diff --git a/src/utils/harmonic_analysis/wrap_harmonic_data.cc b/src/utils/harmonic_analysis/wrap_harmonic_data.cc index 19188a7a..187963a0 100644 --- a/src/utils/harmonic_analysis/wrap_harmonic_data.cc +++ b/src/utils/harmonic_analysis/wrap_harmonic_data.cc @@ -1,14 +1,14 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_utils.hh" -#include "wrap_harmonic_data.hh" +#include "utils/wrap_utils.hh" +#include "utils/harmonic_analysis/wrap_harmonic_data.hh" #include #include #include -#include "HarmonicData.hh" +#include "utils/harmonic_analysis/HarmonicData.hh" using namespace OrbitUtils; using namespace wrap_orbit_utils; diff --git a/src/utils/integration/GaussLegendreIntegrator.cc b/src/utils/integration/GaussLegendreIntegrator.cc index d6dcb56b..d3e2754e 100644 --- a/src/utils/integration/GaussLegendreIntegrator.cc +++ b/src/utils/integration/GaussLegendreIntegrator.cc @@ -13,12 +13,12 @@ // The integrator for the Gauss-Legendre schema. // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" -#include "orbit_mpi.hh" -#include "GaussLegendreIntegrator.hh" -#include "gauss_legendre_points.hh" -#include "OU_Function.hh" -#include "OU_SplineCH.hh" +#include "mpi/orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" +#include "utils/integration/GaussLegendreIntegrator.hh" +#include "utils/integration/gauss_legendre_points.hh" +#include "utils/OU_Function.hh" +#include "utils/OU_SplineCH.hh" #include diff --git a/src/utils/integration/GaussLegendreIntegrator.hh b/src/utils/integration/GaussLegendreIntegrator.hh index b6e7d63c..17555b66 100644 --- a/src/utils/integration/GaussLegendreIntegrator.hh +++ b/src/utils/integration/GaussLegendreIntegrator.hh @@ -21,10 +21,10 @@ #include #include -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" -#include "OU_Function.hh" -#include "OU_SplineCH.hh" +#include "utils/OU_Function.hh" +#include "utils/OU_SplineCH.hh" using namespace std; diff --git a/src/utils/integration/gauss_legendre_points.cc b/src/utils/integration/gauss_legendre_points.cc index c2311d5c..14702461 100644 --- a/src/utils/integration/gauss_legendre_points.cc +++ b/src/utils/integration/gauss_legendre_points.cc @@ -1,4 +1,4 @@ -#include "gauss_legendre_points.hh" +#include "utils/integration/gauss_legendre_points.hh" #include namespace OrbitUtils{ diff --git a/src/utils/integration/gauss_legendre_points.hh b/src/utils/integration/gauss_legendre_points.hh index 1936d604..21ceb2e7 100644 --- a/src/utils/integration/gauss_legendre_points.hh +++ b/src/utils/integration/gauss_legendre_points.hh @@ -12,7 +12,7 @@ #ifndef GAUSS_LEGENDRE_POINTS_H #define GAUSS_LEGENDRE_POINTS_H -#include "OU_Function.hh" +#include "utils/OU_Function.hh" namespace OrbitUtils{ diff --git a/src/utils/integration/wrap_gauss_legendre_integrator.cc b/src/utils/integration/wrap_gauss_legendre_integrator.cc index 3d5388d4..8942800f 100644 --- a/src/utils/integration/wrap_gauss_legendre_integrator.cc +++ b/src/utils/integration/wrap_gauss_legendre_integrator.cc @@ -1,15 +1,15 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_utils.hh" +#include "utils/wrap_utils.hh" #include #include -#include "GaussLegendreIntegrator.hh" -#include "wrap_gauss_legendre_integrator.hh" -#include "OU_SplineCH.hh" -#include "OU_Function.hh" +#include "utils/integration/GaussLegendreIntegrator.hh" +#include "utils/integration/wrap_gauss_legendre_integrator.hh" +#include "utils/OU_SplineCH.hh" +#include "utils/OU_Function.hh" using namespace OrbitUtils; using namespace wrap_orbit_utils; diff --git a/src/utils/matrix/Matrix.cc b/src/utils/matrix/Matrix.cc index cee5cbcc..d728cd81 100644 --- a/src/utils/matrix/Matrix.cc +++ b/src/utils/matrix/Matrix.cc @@ -14,9 +14,9 @@ // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" -#include "Matrix.hh" -#include "BufferStore.hh" +#include "mpi/orbit_mpi.hh" +#include "utils/matrix/Matrix.hh" +#include "utils/BufferStore.hh" #include diff --git a/src/utils/matrix/Matrix.hh b/src/utils/matrix/Matrix.hh index 2b8f353f..74127cae 100644 --- a/src/utils/matrix/Matrix.hh +++ b/src/utils/matrix/Matrix.hh @@ -17,7 +17,7 @@ #ifndef PLAIN_MATRIX_H #define PLAIN_MATRIX_H -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" namespace OrbitUtils{ diff --git a/src/utils/matrix/MatrixOperations.cc b/src/utils/matrix/MatrixOperations.cc index 8e29aa0a..c468479a 100644 --- a/src/utils/matrix/MatrixOperations.cc +++ b/src/utils/matrix/MatrixOperations.cc @@ -1,7 +1,7 @@ -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" -#include "MatrixOperations.hh" -#include "BufferStore.hh" +#include "utils/matrix/MatrixOperations.hh" +#include "utils/BufferStore.hh" #include diff --git a/src/utils/matrix/MatrixOperations.hh b/src/utils/matrix/MatrixOperations.hh index 0b6f7976..92c5295d 100644 --- a/src/utils/matrix/MatrixOperations.hh +++ b/src/utils/matrix/MatrixOperations.hh @@ -1,9 +1,9 @@ #ifndef __MATRIX_OPERATIONS_H_ #define __MATRIX_OPERATIONS_H_ -#include "Matrix.hh" -#include "PhaseVector.hh" -#include "Bunch.hh" +#include "utils/matrix/Matrix.hh" +#include "utils/matrix/PhaseVector.hh" +#include "orbit/Bunch.hh" namespace OrbitUtils{ diff --git a/src/utils/matrix/PhaseVector.cc b/src/utils/matrix/PhaseVector.cc index 87a024d4..53761977 100644 --- a/src/utils/matrix/PhaseVector.cc +++ b/src/utils/matrix/PhaseVector.cc @@ -13,9 +13,9 @@ // A class for a plain double values vector // /////////////////////////////////////////////////////////////////////////// -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" -#include "PhaseVector.hh" +#include "utils/matrix/PhaseVector.hh" #include diff --git a/src/utils/matrix/PhaseVector.hh b/src/utils/matrix/PhaseVector.hh index bbcd37f3..8eae08ed 100644 --- a/src/utils/matrix/PhaseVector.hh +++ b/src/utils/matrix/PhaseVector.hh @@ -17,7 +17,7 @@ #ifndef PHASE_VECTOR_H #define PHASE_VECTOR_H -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" namespace OrbitUtils{ diff --git a/src/utils/matrix/wrap_matrix.cc b/src/utils/matrix/wrap_matrix.cc index eb2bc14d..609ce3a2 100644 --- a/src/utils/matrix/wrap_matrix.cc +++ b/src/utils/matrix/wrap_matrix.cc @@ -1,15 +1,15 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_utils.hh" -#include "wrap_matrix.hh" -#include "wrap_bunch.hh" +#include "utils/wrap_utils.hh" +#include "utils/matrix/wrap_matrix.hh" +#include "orbit/wrap_bunch.hh" #include -#include "Matrix.hh" -#include "PhaseVector.hh" -#include "MatrixOperations.hh" +#include "utils/matrix/Matrix.hh" +#include "utils/matrix/PhaseVector.hh" +#include "utils/matrix/MatrixOperations.hh" using namespace OrbitUtils; using namespace wrap_orbit_utils; diff --git a/src/utils/matrix/wrap_phase_vector.cc b/src/utils/matrix/wrap_phase_vector.cc index bff60f33..f5099730 100644 --- a/src/utils/matrix/wrap_phase_vector.cc +++ b/src/utils/matrix/wrap_phase_vector.cc @@ -1,14 +1,14 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_utils.hh" -#include "wrap_phase_vector.hh" +#include "utils/wrap_utils.hh" +#include "utils/matrix/wrap_phase_vector.hh" #include -#include "PhaseVector.hh" -#include "Matrix.hh" -#include "MatrixOperations.hh" +#include "utils/matrix/PhaseVector.hh" +#include "utils/matrix/Matrix.hh" +#include "utils/matrix/MatrixOperations.hh" using namespace OrbitUtils; using namespace wrap_orbit_utils; diff --git a/src/utils/polynomial/OU_Polynomial.cc b/src/utils/polynomial/OU_Polynomial.cc index fec8a1a6..b4ad6998 100644 --- a/src/utils/polynomial/OU_Polynomial.cc +++ b/src/utils/polynomial/OU_Polynomial.cc @@ -19,8 +19,8 @@ /////////////////////////////////////////////////////////////////////////// #include -#include "orbit_mpi.hh" -#include "OU_Polynomial.hh" +#include "mpi/orbit_mpi.hh" +#include "utils/polynomial/OU_Polynomial.hh" using namespace OrbitUtils; diff --git a/src/utils/polynomial/OU_Polynomial.hh b/src/utils/polynomial/OU_Polynomial.hh index f1e480c9..f979ab25 100644 --- a/src/utils/polynomial/OU_Polynomial.hh +++ b/src/utils/polynomial/OU_Polynomial.hh @@ -18,7 +18,7 @@ #ifndef ORBIT_UTILS_POLYNOMIAL_H #define ORBIT_UTILS_POLYNOMIAL_H -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" using namespace std; diff --git a/src/utils/polynomial/wrap_polynomial.cc b/src/utils/polynomial/wrap_polynomial.cc index 309481d1..0a623357 100644 --- a/src/utils/polynomial/wrap_polynomial.cc +++ b/src/utils/polynomial/wrap_polynomial.cc @@ -1,14 +1,14 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_utils.hh" -#include "wrap_polynomial.hh" +#include "utils/wrap_utils.hh" +#include "utils/polynomial/wrap_polynomial.hh" #include #include #include -#include "OU_Polynomial.hh" +#include "utils/polynomial/OU_Polynomial.hh" using namespace OrbitUtils; using namespace wrap_orbit_utils; diff --git a/src/utils/statistics/StatMoments2D.cc b/src/utils/statistics/StatMoments2D.cc index 58292b50..341c28e7 100644 --- a/src/utils/statistics/StatMoments2D.cc +++ b/src/utils/statistics/StatMoments2D.cc @@ -1,10 +1,10 @@ -#include "StatMoments2D.hh" +#include "utils/statistics/StatMoments2D.hh" #include #include #include -#include "BufferStore.hh" +#include "utils/BufferStore.hh" using namespace OrbitUtils; diff --git a/src/utils/statistics/StatMoments2D.hh b/src/utils/statistics/StatMoments2D.hh index 2f312ba0..c487fd7f 100644 --- a/src/utils/statistics/StatMoments2D.hh +++ b/src/utils/statistics/StatMoments2D.hh @@ -1,10 +1,10 @@ #ifndef STAT_MOMENTS_2D_H #define STAT_MOMENTS_2D_H -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" //pyORBIT utils -#include "CppPyWrapper.hh" +#include "utils/CppPyWrapper.hh" using namespace std; diff --git a/src/utils/statistics/wrap_statmoments2d.cc b/src/utils/statistics/wrap_statmoments2d.cc index 539ac0da..b2abb428 100644 --- a/src/utils/statistics/wrap_statmoments2d.cc +++ b/src/utils/statistics/wrap_statmoments2d.cc @@ -1,14 +1,14 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_utils.hh" -#include "wrap_statmoments2d.hh" -#include "wrap_mpi_comm.hh" +#include "utils/wrap_utils.hh" +#include "utils/statistics/wrap_statmoments2d.hh" +#include "mpi/wrap_mpi_comm.hh" #include #include -#include "StatMoments2D.hh" +#include "utils/statistics/StatMoments2D.hh" using namespace OrbitUtils; using namespace wrap_orbit_utils; diff --git a/src/utils/wrap_field_source_container.cc b/src/utils/wrap_field_source_container.cc index b29a90d6..9389ece3 100644 --- a/src/utils/wrap_field_source_container.cc +++ b/src/utils/wrap_field_source_container.cc @@ -1,14 +1,14 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_utils.hh" -#include "wrap_field_source_container.hh" +#include "utils/wrap_utils.hh" +#include "utils/wrap_field_source_container.hh" #include #include -#include "FieldSourceContainer.hh" -#include "BaseFieldSource.hh" +#include "utils/FieldSourceContainer.hh" +#include "utils/BaseFieldSource.hh" using namespace OrbitUtils; diff --git a/src/utils/wrap_function.cc b/src/utils/wrap_function.cc index 4002e970..cbed1997 100644 --- a/src/utils/wrap_function.cc +++ b/src/utils/wrap_function.cc @@ -1,13 +1,13 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_utils.hh" -#include "wrap_function.hh" +#include "utils/wrap_utils.hh" +#include "utils/wrap_function.hh" #include #include -#include "OU_Function.hh" +#include "utils/OU_Function.hh" using namespace OrbitUtils; using namespace wrap_orbit_utils; diff --git a/src/utils/wrap_numrecipes.cc b/src/utils/wrap_numrecipes.cc index fe74a206..f0b0d3c0 100644 --- a/src/utils/wrap_numrecipes.cc +++ b/src/utils/wrap_numrecipes.cc @@ -1,12 +1,12 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_utils.hh" +#include "utils/wrap_utils.hh" #include #include -#include "bessel.hh" +#include "utils/bessel.hh" using namespace OrbitUtils; using namespace wrap_orbit_utils; diff --git a/src/utils/wrap_py_base_field_source.cc b/src/utils/wrap_py_base_field_source.cc index ea0c442c..9a8a2178 100644 --- a/src/utils/wrap_py_base_field_source.cc +++ b/src/utils/wrap_py_base_field_source.cc @@ -1,12 +1,12 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_utils.hh" -#include "wrap_py_base_field_source.hh" +#include "utils/wrap_utils.hh" +#include "utils/wrap_py_base_field_source.hh" #include -#include "PyBaseFieldSource.hh" +#include "utils/PyBaseFieldSource.hh" using namespace OrbitUtils; using namespace wrap_orbit_utils; diff --git a/src/utils/wrap_random.cc b/src/utils/wrap_random.cc index 94e41b0d..5c19e455 100644 --- a/src/utils/wrap_random.cc +++ b/src/utils/wrap_random.cc @@ -1,12 +1,12 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_utils.hh" +#include "utils/wrap_utils.hh" #include #include -#include "Random.hh" +#include "utils/Random.hh" using namespace OrbitUtils; using namespace wrap_orbit_utils; diff --git a/src/utils/wrap_splinech.cc b/src/utils/wrap_splinech.cc index 90742fc3..21b06439 100644 --- a/src/utils/wrap_splinech.cc +++ b/src/utils/wrap_splinech.cc @@ -1,13 +1,13 @@ -#include "orbit_mpi.hh" -#include "pyORBIT_Object.hh" +#include "mpi/orbit_mpi.hh" +#include "main/pyORBIT_Object.hh" -#include "wrap_utils.hh" -#include "wrap_function.hh" +#include "utils/wrap_utils.hh" +#include "utils/wrap_function.hh" #include #include -#include "OU_SplineCH.hh" +#include "utils/OU_SplineCH.hh" using namespace OrbitUtils; using namespace wrap_orbit_utils; diff --git a/src/utils/wrap_utils.cc b/src/utils/wrap_utils.cc index 434880d7..82b6dcb1 100644 --- a/src/utils/wrap_utils.cc +++ b/src/utils/wrap_utils.cc @@ -1,20 +1,20 @@ -#include "orbit_mpi.hh" +#include "mpi/orbit_mpi.hh" -#include "wrap_utils.hh" -#include "wrap_matrix.hh" -#include "wrap_phase_vector.hh" -#include "wrap_py_base_field_source.hh" -#include "wrap_field_source_container.hh" -#include "wrap_function.hh" -#include "wrap_splinech.hh" -#include "wrap_statmoments2d.hh" -#include "wrap_bunch_extrema_calculator.hh" -#include "wrap_gauss_legendre_integrator.hh" -#include "wrap_polynomial.hh" -#include "wrap_numrecipes.hh" -#include "wrap_bunch_utils_functions.hh" -#include "wrap_harmonic_data.hh" -#include "wrap_random.hh" +#include "utils/wrap_utils.hh" +#include "utils/matrix/wrap_matrix.hh" +#include "utils/matrix/wrap_phase_vector.hh" +#include "utils/wrap_py_base_field_source.hh" +#include "utils/wrap_field_source_container.hh" +#include "utils/wrap_function.hh" +#include "utils/wrap_splinech.hh" +#include "utils/statistics/wrap_statmoments2d.hh" +#include "utils/bunch/wrap_bunch_extrema_calculator.hh" +#include "utils/integration/wrap_gauss_legendre_integrator.hh" +#include "utils/polynomial/wrap_polynomial.hh" +#include "utils/wrap_numrecipes.hh" +#include "utils/bunch/wrap_bunch_utils_functions.hh" +#include "utils/harmonic_analysis/wrap_harmonic_data.hh" +#include "utils/wrap_random.hh" //#include "wrap_field_sources_module.hh" namespace wrap_orbit_utils{ From 6398ee02f3615e2b930228e1a98f0c02f00d9d64 Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 11 Sep 2026 14:06:39 -0400 Subject: [PATCH 08/33] refactor(core): isolate MPI and SyncPart from Python --- src/main/pyORBIT_Object.hh | 1 + src/mpi/orbit_mpi.cc | 65 +++++++--------------- src/mpi/orbit_mpi.hh | 48 +--------------- src/mpi/wrap_mpi_comm.hh | 2 +- src/mpi/wrap_mpi_datatype.hh | 2 +- src/mpi/wrap_mpi_group.hh | 2 +- src/mpi/wrap_mpi_op.hh | 2 +- src/mpi/wrap_mpi_request.hh | 2 +- src/mpi/wrap_mpi_status.hh | 2 +- src/mpi/wrap_orbit_mpi.cc | 5 ++ src/mpi/wrap_orbit_mpi_types.hh | 38 +++++++++++++ src/orbit/SyncPart.cc | 15 ----- src/orbit/SyncPart.hh | 6 +- src/orbit/wrap_bunch.cc | 13 +++-- src/orbit/wrap_bunch.hh | 1 + src/orbit/wrap_syncpart.cc | 4 +- src/spacecharge/wrap_grid1D.cc | 1 + src/spacecharge/wrap_grid2D.cc | 1 + src/spacecharge/wrap_grid3D.cc | 1 + src/utils/statistics/wrap_statmoments2d.cc | 1 + 20 files changed, 89 insertions(+), 123 deletions(-) create mode 100644 src/mpi/wrap_orbit_mpi_types.hh diff --git a/src/main/pyORBIT_Object.hh b/src/main/pyORBIT_Object.hh index 80dbc41f..c3d83a00 100644 --- a/src/main/pyORBIT_Object.hh +++ b/src/main/pyORBIT_Object.hh @@ -17,6 +17,7 @@ #ifndef PY_ORBIT_OBJECT_H #define PY_ORBIT_OBJECT_H +#include #include #ifdef __cplusplus diff --git a/src/mpi/orbit_mpi.cc b/src/mpi/orbit_mpi.cc index b80941b0..180ea3e7 100644 --- a/src/mpi/orbit_mpi.cc +++ b/src/mpi/orbit_mpi.cc @@ -33,9 +33,6 @@ int ORBIT_MPI_Init(){ #if USE_MPI > 0 // Ignoring result; if it fails, the proc is doomed anyway. MPI_Init(NULL, NULL); - - // Registering MPI finalize method at cleanup stage - Py_AtExit(ORBIT_MPI_Finalize); #endif return MPI_SUCCESS; } @@ -52,57 +49,37 @@ int ORBIT_MPI_Initialized(int *init){ return res; } -/** A C wrapper around MPI_Finalize. */ +/** Finalizes MPI without terminating the process. */ +int ORBIT_MPI_FinalizeMPI(){ +#if USE_MPI > 0 + int initialized = 0; + int finalized = 0; + MPI_Initialized(&initialized); + if(initialized == 0) return MPI_SUCCESS; + MPI_Finalized(&finalized); + if(finalized == 0) return MPI_Finalize(); +#endif + return MPI_SUCCESS; +} + +/** A C wrapper around MPI_Finalize that terminates successfully. */ void ORBIT_MPI_Finalize(){ - int res = 0; - res = ORBIT_MPI_Finalize(NULL); - if(res != MPI_SUCCESS){ - PyErr_SetString(PyExc_RuntimeError,"ORBIT_MPI_Finalize."); - PyErr_Print(); - PyRun_SimpleString("import traceback; traceback.print_stack()"); - } + ORBIT_MPI_Finalize(NULL); } /** A C wrapper around MPI_Finalize(message). */ int ORBIT_MPI_Finalize(const char* message){ - int res = 0; - int rank; - ORBIT_MPI_Comm_rank(MPI_COMM_WORLD, &rank); - int init; - ORBIT_MPI_Initialized(&init); -#if USE_MPI > 0 - if(init > 0){ - res = MPI_Finalize(); - } -#else - if(message != NULL){res = MPI_SUCCESS;} -#endif + int rank = 0; + int initialized = 0; + ORBIT_MPI_Initialized(&initialized); + if(initialized > 0) ORBIT_MPI_Comm_rank(MPI_COMM_WORLD, &rank); + int res = ORBIT_MPI_FinalizeMPI(); if(rank == 0){ - if(Py_IsInitialized()){ - PyErr_SetString(PyExc_RuntimeError,"ORBIT_MPI_Finalize."); - PyErr_Print(); - PyRun_SimpleString("import traceback; traceback.print_stack()"); - } if(message != NULL){ std::cerr< - #ifndef ORBIT_MPI_INCLUDE #define ORBIT_MPI_INCLUDE @@ -103,53 +101,9 @@ //-------------------------------------------------------------- -//-------------------------------------------------------------- -// The PyORBIT MPI classes definitions START -//-------------------------------------------------------------- -#ifdef __cplusplus -extern "C" { -#endif - - typedef struct { - PyObject_HEAD - MPI_Comm comm; - } pyORBIT_MPI_Comm; - - typedef struct { - PyObject_HEAD - MPI_Group group; - } pyORBIT_MPI_Group; - - typedef struct { - PyObject_HEAD - MPI_Status status; - } pyORBIT_MPI_Status; - - typedef struct { - PyObject_HEAD - MPI_Request request; - } pyORBIT_MPI_Request; - - typedef struct { - PyObject_HEAD - MPI_Datatype datatype; - } pyORBIT_MPI_Datatype; - - typedef struct { - PyObject_HEAD - MPI_Op op; - } pyORBIT_MPI_Op; - -#ifdef __cplusplus -} -#endif -//-------------------------------------------------------------- -// The PyORBIT MPI classes definitions STOP -//-------------------------------------------------------------- - - int ORBIT_MPI_Init(); int ORBIT_MPI_Initialized(int *init); +int ORBIT_MPI_FinalizeMPI(); void ORBIT_MPI_Finalize(); int ORBIT_MPI_Finalize(const char* message); int ORBIT_MPI_Get_processor_name(char *name, int* len); diff --git a/src/mpi/wrap_mpi_comm.hh b/src/mpi/wrap_mpi_comm.hh index 34f5e290..4e5a4e21 100644 --- a/src/mpi/wrap_mpi_comm.hh +++ b/src/mpi/wrap_mpi_comm.hh @@ -6,7 +6,7 @@ // This is a wrapper for the MPI_Comm data type from MPI // /////////////////////////////////////////////////////////////////////////// -#include "mpi/orbit_mpi.hh" +#include "mpi/wrap_orbit_mpi_types.hh" #ifdef __cplusplus extern "C" { diff --git a/src/mpi/wrap_mpi_datatype.hh b/src/mpi/wrap_mpi_datatype.hh index e16d97eb..4eaed246 100644 --- a/src/mpi/wrap_mpi_datatype.hh +++ b/src/mpi/wrap_mpi_datatype.hh @@ -6,7 +6,7 @@ // This is a wrapper for the MPI_Datatype data type from MPI // /////////////////////////////////////////////////////////////////////////// -#include "mpi/orbit_mpi.hh" +#include "mpi/wrap_orbit_mpi_types.hh" #ifdef __cplusplus extern "C" { diff --git a/src/mpi/wrap_mpi_group.hh b/src/mpi/wrap_mpi_group.hh index 16bf327c..af486d88 100644 --- a/src/mpi/wrap_mpi_group.hh +++ b/src/mpi/wrap_mpi_group.hh @@ -6,7 +6,7 @@ // This is a wrapper for the MPI_Group data type from MPI // /////////////////////////////////////////////////////////////////////////// -#include "mpi/orbit_mpi.hh" +#include "mpi/wrap_orbit_mpi_types.hh" #ifdef __cplusplus extern "C" { diff --git a/src/mpi/wrap_mpi_op.hh b/src/mpi/wrap_mpi_op.hh index 8172c881..bcae888e 100644 --- a/src/mpi/wrap_mpi_op.hh +++ b/src/mpi/wrap_mpi_op.hh @@ -6,7 +6,7 @@ // This is a wrapper for the MPI_Op data type from MPI // /////////////////////////////////////////////////////////////////////////// -#include "mpi/orbit_mpi.hh" +#include "mpi/wrap_orbit_mpi_types.hh" #ifdef __cplusplus extern "C" { diff --git a/src/mpi/wrap_mpi_request.hh b/src/mpi/wrap_mpi_request.hh index 8ea00f59..177aa6da 100644 --- a/src/mpi/wrap_mpi_request.hh +++ b/src/mpi/wrap_mpi_request.hh @@ -6,7 +6,7 @@ // This is a wrapper for the MPI_Request data type from MPI // /////////////////////////////////////////////////////////////////////////// -#include "mpi/orbit_mpi.hh" +#include "mpi/wrap_orbit_mpi_types.hh" #ifdef __cplusplus extern "C" { diff --git a/src/mpi/wrap_mpi_status.hh b/src/mpi/wrap_mpi_status.hh index 8aea68eb..99556942 100644 --- a/src/mpi/wrap_mpi_status.hh +++ b/src/mpi/wrap_mpi_status.hh @@ -6,7 +6,7 @@ // This is a wrapper for the MPI_Status data type from MPI // /////////////////////////////////////////////////////////////////////////// -#include "mpi/orbit_mpi.hh" +#include "mpi/wrap_orbit_mpi_types.hh" #ifdef __cplusplus extern "C" { diff --git a/src/mpi/wrap_orbit_mpi.cc b/src/mpi/wrap_orbit_mpi.cc index 3bff7b96..5129bb52 100644 --- a/src/mpi/wrap_orbit_mpi.cc +++ b/src/mpi/wrap_orbit_mpi.cc @@ -28,6 +28,10 @@ using namespace OrbitUtils; /** The namespace for the python wrappers around MPI functions. */ namespace wrap_orbit_mpi{ + static void finalize_mpi_at_exit(){ + ORBIT_MPI_FinalizeMPI(); + } + /** A local error(message) function. */ void error(const char* msg){ ORBIT_MPI_Finalize(msg); } @@ -181,6 +185,7 @@ namespace wrap_orbit_mpi{ PyMODINIT_FUNC initorbit_mpi(void) { // Initialize MPI ORBIT_MPI_Init(); + Py_AtExit(finalize_mpi_at_exit); PyObject *m, *d; m = PyModule_Create(&cModPyDem); diff --git a/src/mpi/wrap_orbit_mpi_types.hh b/src/mpi/wrap_orbit_mpi_types.hh new file mode 100644 index 00000000..90c99a06 --- /dev/null +++ b/src/mpi/wrap_orbit_mpi_types.hh @@ -0,0 +1,38 @@ +#ifndef WRAP_ORBIT_MPI_TYPES_H +#define WRAP_ORBIT_MPI_TYPES_H + +#include + +#include "mpi/orbit_mpi.hh" + +typedef struct { + PyObject_HEAD + MPI_Comm comm; +} pyORBIT_MPI_Comm; + +typedef struct { + PyObject_HEAD + MPI_Group group; +} pyORBIT_MPI_Group; + +typedef struct { + PyObject_HEAD + MPI_Status status; +} pyORBIT_MPI_Status; + +typedef struct { + PyObject_HEAD + MPI_Request request; +} pyORBIT_MPI_Request; + +typedef struct { + PyObject_HEAD + MPI_Datatype datatype; +} pyORBIT_MPI_Datatype; + +typedef struct { + PyObject_HEAD + MPI_Op op; +} pyORBIT_MPI_Op; + +#endif diff --git a/src/orbit/SyncPart.cc b/src/orbit/SyncPart.cc index c90a9c67..9da3b280 100644 --- a/src/orbit/SyncPart.cc +++ b/src/orbit/SyncPart.cc @@ -24,8 +24,6 @@ // INCLUDE FILES // /////////////////////////////////////////////////////////////////////////// -#include - #include "orbit/SyncPart.hh" #include "orbit/Bunch.hh" @@ -55,24 +53,11 @@ SyncPart::SyncPart(Bunch* bunchIn) SyncPart::~SyncPart() { - Py_XDECREF(py_wrapper); -} - -void SyncPart::setPyWrapper(PyObject* py_wrapper_In){ - if(py_wrapper != NULL) Py_XDECREF(py_wrapper); - Py_INCREF(py_wrapper_In); - py_wrapper = py_wrapper_In; -} - -PyObject* SyncPart::getPyWrapper(){ - return py_wrapper; } //initialization all necessary variables and attributes void SyncPart::init() { - py_wrapper = NULL; - energy = 0.; time = 0.; diff --git a/src/orbit/SyncPart.hh b/src/orbit/SyncPart.hh index 80ef97f3..bc86e925 100644 --- a/src/orbit/SyncPart.hh +++ b/src/orbit/SyncPart.hh @@ -55,9 +55,6 @@ class SyncPart //-------------------------------------- virtual ~SyncPart(); - void setPyWrapper(PyObject* py_wrapper_In); - PyObject* getPyWrapper(); - /** Kinetic energy in GeV */ @@ -134,7 +131,7 @@ private: friend class Bunch; - SyncPart(Bunch* bunch); + SyncPart(Bunch* bunch); //initilaze the sync. particle from file void readSyncPart(const char* fileName); @@ -143,7 +140,6 @@ private: void print(std::ostream& Out); Bunch* bunch; - PyObject* py_wrapper; //-------------------------------------------- //parameters diff --git a/src/orbit/wrap_bunch.cc b/src/orbit/wrap_bunch.cc index 55fdfcf4..c687679e 100644 --- a/src/orbit/wrap_bunch.cc +++ b/src/orbit/wrap_bunch.cc @@ -25,8 +25,13 @@ namespace wrap_orbit_bunch{ typedef struct { pyORBIT_Object base; PyObject* mpi_comm; + PyObject* sync_part; } pyORBIT_Bunch; + PyObject* getSyncPartWrapper(PyObject* pyBunch){ + return ((pyORBIT_Bunch*) pyBunch)->sync_part; + } + static void setMPICommOwner(pyORBIT_Bunch* bunch, PyObject* mpi_comm){ Py_INCREF(mpi_comm); Py_XSETREF(bunch->mpi_comm, mpi_comm); @@ -47,6 +52,7 @@ namespace wrap_orbit_bunch{ } self->base.cpp_obj = NULL; self->mpi_comm = NULL; + self->sync_part = NULL; return (PyObject *) self; } @@ -80,8 +86,7 @@ namespace wrap_orbit_bunch{ return -1; } - //the references should be decreased because they were created as "new reference" - Py_DECREF(pySyncPart); + self->sync_part = pySyncPart; return 0; } @@ -93,8 +98,7 @@ namespace wrap_orbit_bunch{ //returns the SyncPart python class wrapper instance static PyObject* Bunch_getSyncParticle(PyObject *self, PyObject *Py_UNUSED(ignored)){ - Bunch* cpp_bunch = (Bunch*) ((pyORBIT_Object *) self)->cpp_obj; - PyObject* pySyncPart = cpp_bunch->getSyncPart()->getPyWrapper(); + PyObject* pySyncPart = ((pyORBIT_Bunch*) self)->sync_part; Py_INCREF(pySyncPart); return pySyncPart; } @@ -1236,6 +1240,7 @@ namespace wrap_orbit_bunch{ static void Bunch_del(pyORBIT_Object* self){ Bunch* cpp_bunch = (Bunch*) self->cpp_obj; delete cpp_bunch; + Py_XDECREF(((pyORBIT_Bunch*) self)->sync_part); Py_XDECREF(((pyORBIT_Bunch*) self)->mpi_comm); self->ob_base.ob_type->tp_free((PyObject*)self); } diff --git a/src/orbit/wrap_bunch.hh b/src/orbit/wrap_bunch.hh index 1157f294..d1386f1c 100644 --- a/src/orbit/wrap_bunch.hh +++ b/src/orbit/wrap_bunch.hh @@ -26,6 +26,7 @@ extern "C" { /* The name of the function was changed to avoid collision with PyImport magic naming */ PyMODINIT_FUNC initbunch(void); PyObject* getBunchType(const char* name); + PyObject* getSyncPartWrapper(PyObject* pyBunch); } #ifdef __cplusplus diff --git a/src/orbit/wrap_syncpart.cc b/src/orbit/wrap_syncpart.cc index 01d1f9bc..73a4923e 100644 --- a/src/orbit/wrap_syncpart.cc +++ b/src/orbit/wrap_syncpart.cc @@ -4,6 +4,7 @@ // /////////////////////////////////////////////////////////////////////////// #include "orbit/wrap_syncpart.hh" +#include "orbit/wrap_bunch.hh" #include "main/pyORBIT_Object.hh" @@ -43,12 +44,11 @@ extern "C" { pyORBIT_Object* pyBunch = (pyORBIT_Object*) PyTuple_GetItem(args,0); Bunch* cpp_bunch = (Bunch*) pyBunch->cpp_obj; - if(cpp_bunch->getSyncPart()->getPyWrapper() != NULL){ + if(wrap_orbit_bunch::getSyncPartWrapper((PyObject*) pyBunch) != NULL){ error("You should not create SyncParticle class instance directly!"); } self->cpp_obj = (void*) cpp_bunch->getSyncPart(); - cpp_bunch->getSyncPart()->setPyWrapper((PyObject *) self); return 0; } diff --git a/src/spacecharge/wrap_grid1D.cc b/src/spacecharge/wrap_grid1D.cc index acb858a4..d48228a3 100644 --- a/src/spacecharge/wrap_grid1D.cc +++ b/src/spacecharge/wrap_grid1D.cc @@ -1,4 +1,5 @@ #include "mpi/orbit_mpi.hh" +#include "mpi/wrap_orbit_mpi_types.hh" #include "main/pyORBIT_Object.hh" #include "spacecharge/wrap_grid1D.hh" diff --git a/src/spacecharge/wrap_grid2D.cc b/src/spacecharge/wrap_grid2D.cc index 49222ead..d1621623 100644 --- a/src/spacecharge/wrap_grid2D.cc +++ b/src/spacecharge/wrap_grid2D.cc @@ -1,4 +1,5 @@ #include "mpi/orbit_mpi.hh" +#include "mpi/wrap_orbit_mpi_types.hh" #include "main/pyORBIT_Object.hh" #include "spacecharge/wrap_grid2D.hh" diff --git a/src/spacecharge/wrap_grid3D.cc b/src/spacecharge/wrap_grid3D.cc index b02b3768..9888f175 100644 --- a/src/spacecharge/wrap_grid3D.cc +++ b/src/spacecharge/wrap_grid3D.cc @@ -1,4 +1,5 @@ #include "mpi/orbit_mpi.hh" +#include "mpi/wrap_orbit_mpi_types.hh" #include "main/pyORBIT_Object.hh" #include "spacecharge/wrap_grid3D.hh" diff --git a/src/utils/statistics/wrap_statmoments2d.cc b/src/utils/statistics/wrap_statmoments2d.cc index b2abb428..0efe920e 100644 --- a/src/utils/statistics/wrap_statmoments2d.cc +++ b/src/utils/statistics/wrap_statmoments2d.cc @@ -1,4 +1,5 @@ #include "mpi/orbit_mpi.hh" +#include "mpi/wrap_orbit_mpi_types.hh" #include "main/pyORBIT_Object.hh" #include "utils/wrap_utils.hh" From 085ba0ca52be2ad22e284282bb71df1d6c4311c2 Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 11 Sep 2026 14:14:34 -0400 Subject: [PATCH 09/33] refactor(bunch): move wrapper identity to bindings --- src/main/pyORBIT_Object.cc | 32 ++++++++++++++++++++++ src/main/pyORBIT_Object.hh | 9 ++++++ src/meson.build | 19 ++++++++----- src/orbit/Apertures/PyBaseApertureShape.cc | 3 +- src/orbit/Bunch.cc | 2 +- src/orbit/Bunch.hh | 3 +- src/orbit/wrap_bunch.cc | 3 +- src/trackerrk4/PyExternalEffects.cc | 11 ++++---- src/utils/bunch/BunchExtremaCalculator.cc | 2 +- src/utils/bunch/BunchExtremaCalculator.hh | 2 +- 10 files changed, 67 insertions(+), 19 deletions(-) create mode 100644 src/main/pyORBIT_Object.cc diff --git a/src/main/pyORBIT_Object.cc b/src/main/pyORBIT_Object.cc new file mode 100644 index 00000000..10f29f1a --- /dev/null +++ b/src/main/pyORBIT_Object.cc @@ -0,0 +1,32 @@ +#include "main/pyORBIT_Object.hh" + +#include + +namespace { + +std::unordered_map wrappers; + +} + +namespace pyorbit { + +void registerPyWrapper(void* cpp_obj, PyObject* py_wrapper) +{ + wrappers[cpp_obj] = py_wrapper; +} + +void unregisterPyWrapper(void* cpp_obj, PyObject* py_wrapper) +{ + auto wrapper = wrappers.find(cpp_obj); + if(wrapper != wrappers.end() && wrapper->second == py_wrapper) { + wrappers.erase(wrapper); + } +} + +PyObject* getPyWrapper(void* cpp_obj) +{ + auto wrapper = wrappers.find(cpp_obj); + return wrapper == wrappers.end() ? nullptr : wrapper->second; +} + +} diff --git a/src/main/pyORBIT_Object.hh b/src/main/pyORBIT_Object.hh index c3d83a00..fa80d7f1 100644 --- a/src/main/pyORBIT_Object.hh +++ b/src/main/pyORBIT_Object.hh @@ -30,6 +30,15 @@ extern "C" { } pyORBIT_Object; #ifdef __cplusplus +} + +namespace pyorbit { + +// Registry entries are borrowed references owned by their Python wrappers. +void registerPyWrapper(void* cpp_obj, PyObject* py_wrapper); +void unregisterPyWrapper(void* cpp_obj, PyObject* py_wrapper); +PyObject* getPyWrapper(void* cpp_obj); + } #endif diff --git a/src/meson.build b/src/meson.build index 0bc3f7f1..eb7195a1 100644 --- a/src/meson.build +++ b/src/meson.build @@ -102,7 +102,6 @@ sources = files([ 'orbit/Apertures/PhaseAperture.cc', 'orbit/Apertures/Aperture.cc', 'orbit/Apertures/RectangularApertureShape.cc', - 'orbit/Apertures/PyBaseApertureShape.cc', 'orbit/Apertures/ConvexApertureShape.cc', 'orbit/Apertures/EnergyAperture.cc', 'orbit/Apertures/BaseAperture.cc', @@ -111,7 +110,6 @@ sources = files([ 'orbit/Apertures/BaseApertureShape.cc', 'trackerrk4/ExternalEffects.cc', 'trackerrk4/ExtEffectsContainer.cc', - 'trackerrk4/PyExternalEffects.cc', 'trackerrk4/RungeKuttaTracker.cc', 'mpi/orbit_mpi.cc', 'spacecharge/PoissonSolverFFT3D.cc', @@ -136,7 +134,6 @@ sources = files([ 'utils/FieldSourceContainer.cc', 'utils/AttributesBucket.cc', 'utils/bessel.cc', - 'utils/PyBaseFieldSource.cc', 'utils/OU_SplineCH.cc', 'utils/CppPyWrapper.cc', 'utils/StringUtils.cc', @@ -213,7 +210,6 @@ api_headers = [ 'orbit/Apertures/EllipseApertureShape.hh', 'orbit/Apertures/EnergyAperture.hh', 'orbit/Apertures/PhaseAperture.hh', - 'orbit/Apertures/PyBaseApertureShape.hh', 'orbit/Apertures/RectangularApertureShape.hh', 'orbit/Bunch.hh', 'orbit/BunchDiagnostics/BunchTuneAnalysis.hh', @@ -270,7 +266,6 @@ api_headers = [ 'teapot/teapotbase.hh', 'trackerrk4/ExtEffectsContainer.hh', 'trackerrk4/ExternalEffects.hh', - 'trackerrk4/PyExternalEffects.hh', 'trackerrk4/RungeKuttaTracker.hh', 'utils/AttributesBucket.hh', 'utils/BaseFieldSource.hh', @@ -280,7 +275,6 @@ api_headers = [ 'utils/MathPolynomial.hh', 'utils/OU_Function.hh', 'utils/OU_SplineCH.hh', - 'utils/PyBaseFieldSource.hh', 'utils/Random.hh', 'utils/StringUtils.hh', 'utils/bessel.hh', @@ -327,6 +321,14 @@ pkgconfig.generate( install_dir: get_option('libdir') / 'pkgconfig', ) +binding_lib = shared_library( + 'pyorbit3_python', + sources: 'main/pyORBIT_Object.cc', + dependencies: python.dependency(), + gnu_symbol_visibility: 'default', + install: true, +) + ext_modules = { 'orbit_mpi': files( 'core/mpi_init.cc', @@ -373,6 +375,7 @@ ext_modules = { 'trackerrk4/wrap_runge_kutta_tracker.cc', 'trackerrk4/wrap_py_external_effects.cc', 'trackerrk4/wrap_ext_effects_container.cc', + 'trackerrk4/PyExternalEffects.cc', ), 'teapot_base': files( 'core/teapot_base_init.cc', @@ -412,6 +415,7 @@ ext_modules = { 'utils/bunch/wrap_bunch_utils_functions.cc', 'utils/harmonic_analysis/wrap_harmonic_data.cc', 'utils/wrap_random.cc', + 'utils/PyBaseFieldSource.cc', ), 'aperture': files( 'core/aperture_init.cc', @@ -425,6 +429,7 @@ ext_modules = { 'orbit/Apertures/wrap_PrimitiveApertureShape.cc', 'orbit/Apertures/wrap_CompositeApertureShape.cc', 'orbit/Apertures/wrap_ConvexApertureShape.cc', + 'orbit/Apertures/PyBaseApertureShape.cc', ), 'foil': files( 'core/foil_init.cc', @@ -477,7 +482,7 @@ foreach name, src_list : ext_modules name, sources: src_list, include_directories: inc, - link_with: core_lib, + link_with: [core_lib, binding_lib], dependencies: dependencies, install_rpath: core_install_rpath, install: true, diff --git a/src/orbit/Apertures/PyBaseApertureShape.cc b/src/orbit/Apertures/PyBaseApertureShape.cc index 6f8fcc89..28b927c6 100644 --- a/src/orbit/Apertures/PyBaseApertureShape.cc +++ b/src/orbit/Apertures/PyBaseApertureShape.cc @@ -1,4 +1,5 @@ #include "orbit/Apertures/PyBaseApertureShape.hh" +#include "main/pyORBIT_Object.hh" #include #include @@ -39,7 +40,7 @@ int PyBaseApertureShape::inside(Bunch* bunch, int count){ double** coord = bunch->coordArr(); PyObject* py_wrp = getPyWrapper(); - PyObject* py_bunch = bunch->getPyWrapper(); + PyObject* py_bunch = pyorbit::getPyWrapper(bunch); int res_isinside = 0; diff --git a/src/orbit/Bunch.cc b/src/orbit/Bunch.cc index bdb64c99..9cde723e 100644 --- a/src/orbit/Bunch.cc +++ b/src/orbit/Bunch.cc @@ -32,7 +32,7 @@ using namespace OrbitUtils; changed, and dumped to a file. */ -Bunch::Bunch(): CppPyWrapper(NULL) +Bunch::Bunch() { //initialization all necessary variables and attributes diff --git a/src/orbit/Bunch.hh b/src/orbit/Bunch.hh index 76b23c12..609425ff 100644 --- a/src/orbit/Bunch.hh +++ b/src/orbit/Bunch.hh @@ -34,7 +34,6 @@ //from utils #include "utils/AttributesBucket.hh" -#include "utils/CppPyWrapper.hh" #ifndef BUNCH_H #define BUNCH_H @@ -45,7 +44,7 @@ // /////////////////////////////////////////////////////////////////////////// -class Bunch: public OrbitUtils::CppPyWrapper +class Bunch { public: //-------------------------------------- diff --git a/src/orbit/wrap_bunch.cc b/src/orbit/wrap_bunch.cc index c687679e..2fd74023 100644 --- a/src/orbit/wrap_bunch.cc +++ b/src/orbit/wrap_bunch.cc @@ -62,7 +62,7 @@ namespace wrap_orbit_bunch{ //std::cerr<<"The Bunch __init__ has been called!"<base.cpp_obj = (void*) new Bunch(); - ((Bunch*) self->base.cpp_obj)->setPyWrapper((PyObject*) self); + pyorbit::registerPyWrapper(self->base.cpp_obj, (PyObject*) self); PyObject* mpi_comm_type = wrap_orbit_mpi_comm::getMPI_CommType("MPI_Comm"); if (mpi_comm_type == NULL) { @@ -1239,6 +1239,7 @@ namespace wrap_orbit_bunch{ //this is implementation of the __del__ method static void Bunch_del(pyORBIT_Object* self){ Bunch* cpp_bunch = (Bunch*) self->cpp_obj; + pyorbit::unregisterPyWrapper(cpp_bunch, (PyObject*) self); delete cpp_bunch; Py_XDECREF(((pyORBIT_Bunch*) self)->sync_part); Py_XDECREF(((pyORBIT_Bunch*) self)->mpi_comm); diff --git a/src/trackerrk4/PyExternalEffects.cc b/src/trackerrk4/PyExternalEffects.cc index 5a7648d5..9351b1da 100644 --- a/src/trackerrk4/PyExternalEffects.cc +++ b/src/trackerrk4/PyExternalEffects.cc @@ -31,6 +31,7 @@ #include "trackerrk4/PyExternalEffects.hh" #include "trackerrk4/RungeKuttaTracker.hh" +#include "main/pyORBIT_Object.hh" //#include using namespace TrackerRK4; @@ -48,14 +49,14 @@ PyExternalEffects::~PyExternalEffects() void PyExternalEffects::setupEffects(Bunch* bunch){ PyObject* py_wrp = getPyWrapper(); - PyObject* py_bunch = bunch->getPyWrapper(); + PyObject* py_bunch = pyorbit::getPyWrapper(bunch); PyObject* res_tuple = PyObject_CallMethod(py_wrp,const_cast("setupEffects"),const_cast("O"),py_bunch); Py_DECREF(res_tuple); } void PyExternalEffects::prepareEffects(Bunch* bunch, double t){ PyObject* py_wrp = getPyWrapper(); - PyObject* py_bunch = bunch->getPyWrapper(); + PyObject* py_bunch = pyorbit::getPyWrapper(bunch); PyObject* res_tuple = PyObject_CallMethod(py_wrp,const_cast("prepareEffects"),const_cast("Od"),py_bunch, time); Py_DECREF(res_tuple); } @@ -63,7 +64,7 @@ void PyExternalEffects::prepareEffects(Bunch* bunch, double t){ void PyExternalEffects::finalizeEffects(Bunch* bunch){ PyObject* py_wrp = getPyWrapper(); - PyObject* py_bunch = bunch->getPyWrapper(); + PyObject* py_bunch = pyorbit::getPyWrapper(bunch); PyObject* res_tuple = PyObject_CallMethod(py_wrp,const_cast("finalizeEffects"),const_cast("O"),py_bunch); Py_DECREF(res_tuple); } @@ -74,7 +75,7 @@ void PyExternalEffects::applyEffects(Bunch* bunch, RungeKuttaTracker* tracker) { PyObject* py_wrp = getPyWrapper(); - PyObject* py_bunch = bunch->getPyWrapper(); + PyObject* py_bunch = pyorbit::getPyWrapper(bunch); PyObject* py_field = fieldSource->getPyWrapper(); PyObject* py_tracker = tracker->getPyWrapper(); PyObject* res_tuple = PyObject_CallMethod(py_wrp,const_cast("applyEffects"),const_cast("OddOO"), @@ -92,7 +93,7 @@ void PyExternalEffects::applyEffectsForEach(Bunch* bunch, int index, RungeKuttaTracker* tracker) { PyObject* py_wrp = getPyWrapper(); - PyObject* py_bunch = bunch->getPyWrapper(); + PyObject* py_bunch = pyorbit::getPyWrapper(bunch); PyObject* py_field = fieldSource->getPyWrapper(); PyObject* py_tracker = tracker->getPyWrapper(); PyObject* pyInVct = Py_BuildValue("(dddddd)",y_in_vct[0],y_in_vct[1],y_in_vct[2], diff --git a/src/utils/bunch/BunchExtremaCalculator.cc b/src/utils/bunch/BunchExtremaCalculator.cc index 68a37835..c2e6e9dc 100644 --- a/src/utils/bunch/BunchExtremaCalculator.cc +++ b/src/utils/bunch/BunchExtremaCalculator.cc @@ -25,7 +25,7 @@ using namespace OrbitUtils; -BunchExtremaCalculator::BunchExtremaCalculator(): CppPyWrapper(NULL) +BunchExtremaCalculator::BunchExtremaCalculator() { } diff --git a/src/utils/bunch/BunchExtremaCalculator.hh b/src/utils/bunch/BunchExtremaCalculator.hh index 078cebbd..486d7d16 100644 --- a/src/utils/bunch/BunchExtremaCalculator.hh +++ b/src/utils/bunch/BunchExtremaCalculator.hh @@ -24,7 +24,7 @@ namespace OrbitUtils{ /** A class calculates the extrema and averages of the particles coordinates in the bunch.*/ - class BunchExtremaCalculator : public CppPyWrapper + class BunchExtremaCalculator { public: From 80f976752dbc2af4e05a7f799043ae5bd741ae8a Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 11 Sep 2026 14:22:51 -0400 Subject: [PATCH 10/33] refactor(trackerrk4): detach tracker from Python --- src/trackerrk4/PyExternalEffects.cc | 4 ++-- src/trackerrk4/RungeKuttaTracker.hh | 4 +--- src/trackerrk4/wrap_runge_kutta_tracker.cc | 3 ++- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/trackerrk4/PyExternalEffects.cc b/src/trackerrk4/PyExternalEffects.cc index 9351b1da..5b175a8b 100644 --- a/src/trackerrk4/PyExternalEffects.cc +++ b/src/trackerrk4/PyExternalEffects.cc @@ -77,7 +77,7 @@ void PyExternalEffects::applyEffects(Bunch* bunch, PyObject* py_wrp = getPyWrapper(); PyObject* py_bunch = pyorbit::getPyWrapper(bunch); PyObject* py_field = fieldSource->getPyWrapper(); - PyObject* py_tracker = tracker->getPyWrapper(); + PyObject* py_tracker = pyorbit::getPyWrapper(tracker); PyObject* res_tuple = PyObject_CallMethod(py_wrp,const_cast("applyEffects"),const_cast("OddOO"), py_bunch, t,t_step, @@ -95,7 +95,7 @@ void PyExternalEffects::applyEffectsForEach(Bunch* bunch, int index, PyObject* py_wrp = getPyWrapper(); PyObject* py_bunch = pyorbit::getPyWrapper(bunch); PyObject* py_field = fieldSource->getPyWrapper(); - PyObject* py_tracker = tracker->getPyWrapper(); + PyObject* py_tracker = pyorbit::getPyWrapper(tracker); PyObject* pyInVct = Py_BuildValue("(dddddd)",y_in_vct[0],y_in_vct[1],y_in_vct[2], y_in_vct[3],y_in_vct[4],y_in_vct[5]); PyObject* pyOutVct = Py_BuildValue("(dddddd)",y_out_vct[0],y_out_vct[1],y_out_vct[2], diff --git a/src/trackerrk4/RungeKuttaTracker.hh b/src/trackerrk4/RungeKuttaTracker.hh index cbb4a8df..874bcf35 100644 --- a/src/trackerrk4/RungeKuttaTracker.hh +++ b/src/trackerrk4/RungeKuttaTracker.hh @@ -21,11 +21,9 @@ #include "utils/BaseFieldSource.hh" #include "trackerrk4/ExternalEffects.hh" -#include "utils/CppPyWrapper.hh" - namespace TrackerRK4{ - class RungeKuttaTracker: public OrbitUtils::CppPyWrapper + class RungeKuttaTracker { //-------------------------------------------------- // public methods of the RungeKuttaTracker class diff --git a/src/trackerrk4/wrap_runge_kutta_tracker.cc b/src/trackerrk4/wrap_runge_kutta_tracker.cc index c2dfad8b..64617f84 100644 --- a/src/trackerrk4/wrap_runge_kutta_tracker.cc +++ b/src/trackerrk4/wrap_runge_kutta_tracker.cc @@ -41,7 +41,7 @@ extern "C" { error("PyRungeKuttaTracker - RungeKuttaTracker(length[m]) - constructor needs a parameter."); } self->cpp_obj = new RungeKuttaTracker(length); - ((RungeKuttaTracker*) self->cpp_obj)->setPyWrapper((PyObject*) self); + pyorbit::registerPyWrapper(self->cpp_obj, (PyObject*) self); //std::cerr<<"The RungeKuttaTracker __init__ has been called!"<cpp_obj, (PyObject*) self); delete ((RungeKuttaTracker*)self->cpp_obj); self->ob_base.ob_type->tp_free((PyObject*)self); } From 16ec89e7f220268f0eab5da5191a8d33fd60199c Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 11 Sep 2026 14:28:14 -0400 Subject: [PATCH 11/33] refactor(utils): remove unused Python wrapper state --- src/utils/OU_Function.cc | 2 +- src/utils/OU_Function.hh | 4 +--- src/utils/OU_SplineCH.cc | 2 +- src/utils/OU_SplineCH.hh | 3 +-- src/utils/harmonic_analysis/HarmonicData.cc | 2 +- src/utils/harmonic_analysis/HarmonicData.hh | 3 +-- src/utils/harmonic_analysis/wrap_harmonic_data.cc | 1 - src/utils/integration/GaussLegendreIntegrator.cc | 6 +++--- src/utils/integration/GaussLegendreIntegrator.hh | 4 +--- src/utils/integration/wrap_gauss_legendre_integrator.cc | 1 - src/utils/matrix/PhaseVector.cc | 4 ++-- src/utils/matrix/PhaseVector.hh | 4 +--- src/utils/matrix/wrap_phase_vector.cc | 2 -- src/utils/polynomial/OU_Polynomial.cc | 2 +- src/utils/polynomial/OU_Polynomial.hh | 4 +--- src/utils/polynomial/wrap_polynomial.cc | 1 - src/utils/statistics/StatMoments2D.cc | 4 ++-- src/utils/statistics/StatMoments2D.hh | 5 +---- src/utils/statistics/wrap_statmoments2d.cc | 1 - src/utils/wrap_function.cc | 1 - src/utils/wrap_splinech.cc | 1 - 21 files changed, 18 insertions(+), 39 deletions(-) diff --git a/src/utils/OU_Function.cc b/src/utils/OU_Function.cc index 1f5348d5..e499d0e2 100644 --- a/src/utils/OU_Function.cc +++ b/src/utils/OU_Function.cc @@ -22,7 +22,7 @@ using namespace OrbitUtils; -Function::Function(): CppPyWrapper(NULL) +Function::Function() { x_arr = NULL; y_arr = NULL; diff --git a/src/utils/OU_Function.hh b/src/utils/OU_Function.hh index 9a1fe969..c8d17e5e 100644 --- a/src/utils/OU_Function.hh +++ b/src/utils/OU_Function.hh @@ -18,8 +18,6 @@ #ifndef ORBIT_UTILS_FUNCTION_H #define ORBIT_UTILS_FUNCTION_H -#include "utils/CppPyWrapper.hh" - #include #include #include @@ -29,7 +27,7 @@ using namespace std; namespace OrbitUtils{ - class Function : public CppPyWrapper + class Function { public: //----------------------------------------- diff --git a/src/utils/OU_SplineCH.cc b/src/utils/OU_SplineCH.cc index 384a48c2..b6a5f870 100644 --- a/src/utils/OU_SplineCH.cc +++ b/src/utils/OU_SplineCH.cc @@ -31,7 +31,7 @@ namespace OrbitUtils{ - SplineCH::SplineCH(): CppPyWrapper(NULL) + SplineCH::SplineCH() { x_arr = NULL; y_arr = NULL; diff --git a/src/utils/OU_SplineCH.hh b/src/utils/OU_SplineCH.hh index eac2dd72..8fca9727 100644 --- a/src/utils/OU_SplineCH.hh +++ b/src/utils/OU_SplineCH.hh @@ -31,12 +31,11 @@ #include #include -#include "utils/CppPyWrapper.hh" #include "utils/OU_Function.hh" namespace OrbitUtils{ - class SplineCH : public CppPyWrapper + class SplineCH { public: //----------------------------------------- diff --git a/src/utils/harmonic_analysis/HarmonicData.cc b/src/utils/harmonic_analysis/HarmonicData.cc index a600bb13..e77b4a8d 100644 --- a/src/utils/harmonic_analysis/HarmonicData.cc +++ b/src/utils/harmonic_analysis/HarmonicData.cc @@ -36,7 +36,7 @@ using namespace OrbitUtils; -HarmonicData::HarmonicData(int order_in, Function* inFunc): CppPyWrapper(NULL) +HarmonicData::HarmonicData(int order_in, Function* inFunc) { this->init(order_in,inFunc); } diff --git a/src/utils/harmonic_analysis/HarmonicData.hh b/src/utils/harmonic_analysis/HarmonicData.hh index 39eb74b2..1c078f14 100644 --- a/src/utils/harmonic_analysis/HarmonicData.hh +++ b/src/utils/harmonic_analysis/HarmonicData.hh @@ -31,14 +31,13 @@ #ifndef ORBIT_UTILS_HARMONICDATA_H #define ORBIT_UTILS_HARMONICDATA_H -#include "utils/CppPyWrapper.hh" #include "utils/OU_Function.hh" using namespace std; namespace OrbitUtils{ - class HarmonicData : public CppPyWrapper + class HarmonicData { public: //----------------------------------------- diff --git a/src/utils/harmonic_analysis/wrap_harmonic_data.cc b/src/utils/harmonic_analysis/wrap_harmonic_data.cc index 187963a0..c33cd260 100644 --- a/src/utils/harmonic_analysis/wrap_harmonic_data.cc +++ b/src/utils/harmonic_analysis/wrap_harmonic_data.cc @@ -62,7 +62,6 @@ extern "C" { else{ error("HarmonicData(order,pyFunction) or HarmonicData(harmonicData)- constructor parameters are needed"); } - ((HarmonicData*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } diff --git a/src/utils/integration/GaussLegendreIntegrator.cc b/src/utils/integration/GaussLegendreIntegrator.cc index d3e2754e..90697885 100644 --- a/src/utils/integration/GaussLegendreIntegrator.cc +++ b/src/utils/integration/GaussLegendreIntegrator.cc @@ -24,7 +24,7 @@ using namespace OrbitUtils; -GaussLegendreIntegrator::GaussLegendreIntegrator(): CppPyWrapper(NULL) +GaussLegendreIntegrator::GaussLegendreIntegrator() { n_int_points = 1024; x0 = 0.; @@ -34,7 +34,7 @@ GaussLegendreIntegrator::GaussLegendreIntegrator(): CppPyWrapper(NULL) n_int_points = pw_finc->getSize(); } -GaussLegendreIntegrator::GaussLegendreIntegrator(int nPoints): CppPyWrapper(NULL) +GaussLegendreIntegrator::GaussLegendreIntegrator(int nPoints) { n_int_points = nPoints; x0 = 0.; @@ -44,7 +44,7 @@ GaussLegendreIntegrator::GaussLegendreIntegrator(int nPoints): CppPyWrapper(NULL n_int_points = pw_finc->getSize(); } -GaussLegendreIntegrator::GaussLegendreIntegrator(int nPoints, double x_from, double x_to): CppPyWrapper(NULL) +GaussLegendreIntegrator::GaussLegendreIntegrator(int nPoints, double x_from, double x_to) { n_int_points = nPoints; x0 = x_from; diff --git a/src/utils/integration/GaussLegendreIntegrator.hh b/src/utils/integration/GaussLegendreIntegrator.hh index 17555b66..c9d455f6 100644 --- a/src/utils/integration/GaussLegendreIntegrator.hh +++ b/src/utils/integration/GaussLegendreIntegrator.hh @@ -21,8 +21,6 @@ #include #include -#include "utils/CppPyWrapper.hh" - #include "utils/OU_Function.hh" #include "utils/OU_SplineCH.hh" @@ -30,7 +28,7 @@ using namespace std; namespace OrbitUtils{ - class GaussLegendreIntegrator : public CppPyWrapper + class GaussLegendreIntegrator { public: //----------------------------------------- diff --git a/src/utils/integration/wrap_gauss_legendre_integrator.cc b/src/utils/integration/wrap_gauss_legendre_integrator.cc index 8942800f..2a7d8466 100644 --- a/src/utils/integration/wrap_gauss_legendre_integrator.cc +++ b/src/utils/integration/wrap_gauss_legendre_integrator.cc @@ -61,7 +61,6 @@ extern "C" { if(self->cpp_obj == NULL){ error("GaussLegendreIntegrator([nPoints[,x_min,x_max]]) - constructor signature."); } - ((GaussLegendreIntegrator*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } diff --git a/src/utils/matrix/PhaseVector.cc b/src/utils/matrix/PhaseVector.cc index 53761977..757e9816 100644 --- a/src/utils/matrix/PhaseVector.cc +++ b/src/utils/matrix/PhaseVector.cc @@ -21,14 +21,14 @@ using namespace OrbitUtils; -PhaseVector::PhaseVector(int n_in): CppPyWrapper(NULL) +PhaseVector::PhaseVector(int n_in) { n = n_in; v = (double* ) malloc (sizeof(double)*n); zero(); } -PhaseVector::PhaseVector(PhaseVector* vIn): CppPyWrapper(NULL) +PhaseVector::PhaseVector(PhaseVector* vIn) { n = vIn->size(); v = (double* ) malloc (sizeof(double)*n); diff --git a/src/utils/matrix/PhaseVector.hh b/src/utils/matrix/PhaseVector.hh index 8eae08ed..3a9d6784 100644 --- a/src/utils/matrix/PhaseVector.hh +++ b/src/utils/matrix/PhaseVector.hh @@ -17,13 +17,11 @@ #ifndef PHASE_VECTOR_H #define PHASE_VECTOR_H -#include "utils/CppPyWrapper.hh" - namespace OrbitUtils{ /** A double values vector. */ - class PhaseVector : public CppPyWrapper + class PhaseVector { public: diff --git a/src/utils/matrix/wrap_phase_vector.cc b/src/utils/matrix/wrap_phase_vector.cc index f5099730..1cde8737 100644 --- a/src/utils/matrix/wrap_phase_vector.cc +++ b/src/utils/matrix/wrap_phase_vector.cc @@ -48,7 +48,6 @@ extern "C" { error("PyPhaseVector - __init__(size) - input parameter is needed."); } self->cpp_obj = new PhaseVector(size); - ((PhaseVector*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } PyObject* pyORBIT_PhaseVector_Type = getOrbitUtilsType("PhaseVector"); @@ -58,7 +57,6 @@ extern "C" { PhaseVector* v = (PhaseVector*)(((pyORBIT_Object*) pyIn)->cpp_obj); self->cpp_obj = new PhaseVector(v->size()); v->copyTo((PhaseVector*) self->cpp_obj); - ((PhaseVector*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } diff --git a/src/utils/polynomial/OU_Polynomial.cc b/src/utils/polynomial/OU_Polynomial.cc index b4ad6998..cfc19d38 100644 --- a/src/utils/polynomial/OU_Polynomial.cc +++ b/src/utils/polynomial/OU_Polynomial.cc @@ -24,7 +24,7 @@ using namespace OrbitUtils; -Polynomial::Polynomial(int order_in): CppPyWrapper(NULL) +Polynomial::Polynomial(int order_in) { if(order_in < 0){ ORBIT_MPI_Finalize("Orbit Utilites Polynomial::Polynomial(order) - order should be >= 0. Stop."); diff --git a/src/utils/polynomial/OU_Polynomial.hh b/src/utils/polynomial/OU_Polynomial.hh index f979ab25..d988b021 100644 --- a/src/utils/polynomial/OU_Polynomial.hh +++ b/src/utils/polynomial/OU_Polynomial.hh @@ -18,13 +18,11 @@ #ifndef ORBIT_UTILS_POLYNOMIAL_H #define ORBIT_UTILS_POLYNOMIAL_H -#include "utils/CppPyWrapper.hh" - using namespace std; namespace OrbitUtils{ - class Polynomial : public CppPyWrapper + class Polynomial { public: //----------------------------------------- diff --git a/src/utils/polynomial/wrap_polynomial.cc b/src/utils/polynomial/wrap_polynomial.cc index 0a623357..3ff73cc4 100644 --- a/src/utils/polynomial/wrap_polynomial.cc +++ b/src/utils/polynomial/wrap_polynomial.cc @@ -35,7 +35,6 @@ extern "C" { /** This is implementation of the __init__ method */ static int Polynomial_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ self->cpp_obj = new Polynomial(0); - ((Polynomial*) self->cpp_obj)->setPyWrapper((PyObject*) self); int nVars = PyTuple_Size(args); int order = -1; if(nVars == 1){ diff --git a/src/utils/statistics/StatMoments2D.cc b/src/utils/statistics/StatMoments2D.cc index 341c28e7..88cf4226 100644 --- a/src/utils/statistics/StatMoments2D.cc +++ b/src/utils/statistics/StatMoments2D.cc @@ -9,7 +9,7 @@ using namespace OrbitUtils; /** Constructor with max order = 2 by default */ -StatMoments2D::StatMoments2D(): CppPyWrapper(NULL) +StatMoments2D::StatMoments2D() { max_order = 2; stat_arr = NULL; @@ -17,7 +17,7 @@ StatMoments2D::StatMoments2D(): CppPyWrapper(NULL) } /** Constructor with maximal order parameter */ -StatMoments2D::StatMoments2D(int maxOrder): CppPyWrapper(NULL) +StatMoments2D::StatMoments2D(int maxOrder) { max_order = maxOrder; if(max_order < 2) max_order = 2; diff --git a/src/utils/statistics/StatMoments2D.hh b/src/utils/statistics/StatMoments2D.hh index c487fd7f..0de0dfb1 100644 --- a/src/utils/statistics/StatMoments2D.hh +++ b/src/utils/statistics/StatMoments2D.hh @@ -3,9 +3,6 @@ #include "mpi/orbit_mpi.hh" -//pyORBIT utils -#include "utils/CppPyWrapper.hh" - using namespace std; /** @@ -15,7 +12,7 @@ It is used by other classes to calculate Twiss paraemeters etc. namespace OrbitUtils{ - class StatMoments2D: public CppPyWrapper + class StatMoments2D { public: diff --git a/src/utils/statistics/wrap_statmoments2d.cc b/src/utils/statistics/wrap_statmoments2d.cc index 0efe920e..1826066c 100644 --- a/src/utils/statistics/wrap_statmoments2d.cc +++ b/src/utils/statistics/wrap_statmoments2d.cc @@ -48,7 +48,6 @@ extern "C" { self->cpp_obj = new StatMoments2D(max_order); } } - ((StatMoments2D*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } diff --git a/src/utils/wrap_function.cc b/src/utils/wrap_function.cc index cbed1997..b93477be 100644 --- a/src/utils/wrap_function.cc +++ b/src/utils/wrap_function.cc @@ -34,7 +34,6 @@ extern "C" { /** This is implementation of the __init__ method */ static int Function_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ self->cpp_obj = new Function(); - ((Function*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } diff --git a/src/utils/wrap_splinech.cc b/src/utils/wrap_splinech.cc index 21b06439..fd61464c 100644 --- a/src/utils/wrap_splinech.cc +++ b/src/utils/wrap_splinech.cc @@ -34,7 +34,6 @@ extern "C" { /** This is implementation of the __init__ method */ static int SplineCH_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ self->cpp_obj = new SplineCH(); - ((SplineCH*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } From 30a1cabb5eb1413540ec45dfe9ff1f290e556288 Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 11 Sep 2026 14:32:54 -0400 Subject: [PATCH 12/33] refactor(linac): remove unused Python wrapper state --- src/linac/rfgap/BaseRfGap.cc | 2 +- src/linac/rfgap/BaseRfGap.hh | 3 +-- src/linac/rfgap/BaseRfGap_slow.cc | 2 +- src/linac/rfgap/BaseRfGap_slow.hh | 3 +-- src/linac/rfgap/MatrixRfGap.cc | 2 +- src/linac/rfgap/MatrixRfGap.hh | 3 +-- src/linac/rfgap/RfGapTTF.cc | 2 +- src/linac/rfgap/RfGapTTF.hh | 3 +-- src/linac/rfgap/RfGapTTF_slow.cc | 2 +- src/linac/rfgap/RfGapTTF_slow.hh | 3 +-- src/linac/rfgap/RfGapThreePointTTF.cc | 2 +- src/linac/rfgap/RfGapThreePointTTF.hh | 3 +-- src/linac/rfgap/RfGapThreePointTTF_slow.cc | 2 +- src/linac/rfgap/RfGapThreePointTTF_slow.hh | 3 +-- src/linac/rfgap/wrap_BaseRfGap.cc | 1 - src/linac/rfgap/wrap_BaseRfGap_slow.cc | 1 - src/linac/rfgap/wrap_MatrixRfGap.cc | 1 - src/linac/rfgap/wrap_RfGapTTF.cc | 1 - src/linac/rfgap/wrap_RfGapTTF_slow.cc | 1 - src/linac/rfgap/wrap_RfGapThreePointTTF.cc | 1 - src/linac/rfgap/wrap_RfGapThreePointTTF_slow.cc | 1 - 21 files changed, 14 insertions(+), 28 deletions(-) diff --git a/src/linac/rfgap/BaseRfGap.cc b/src/linac/rfgap/BaseRfGap.cc index 8392725b..4fd2ffdc 100644 --- a/src/linac/rfgap/BaseRfGap.cc +++ b/src/linac/rfgap/BaseRfGap.cc @@ -21,7 +21,7 @@ ORNL Tech. Note ORNL/TM-2015/247, June 2015 using namespace OrbitUtils; // Constructor -BaseRfGap::BaseRfGap(): CppPyWrapper(NULL) +BaseRfGap::BaseRfGap() { } diff --git a/src/linac/rfgap/BaseRfGap.hh b/src/linac/rfgap/BaseRfGap.hh index 16b1379d..466b056b 100644 --- a/src/linac/rfgap/BaseRfGap.hh +++ b/src/linac/rfgap/BaseRfGap.hh @@ -14,7 +14,6 @@ #include "orbit/Bunch.hh" //pyORBIT utils -#include "utils/CppPyWrapper.hh" using namespace std; @@ -22,7 +21,7 @@ using namespace std; This class represents a 2D rectangular grid. */ -class BaseRfGap: public OrbitUtils::CppPyWrapper +class BaseRfGap { public: diff --git a/src/linac/rfgap/BaseRfGap_slow.cc b/src/linac/rfgap/BaseRfGap_slow.cc index bcd84048..2345ad4d 100644 --- a/src/linac/rfgap/BaseRfGap_slow.cc +++ b/src/linac/rfgap/BaseRfGap_slow.cc @@ -28,7 +28,7 @@ so the name of the class has the word slow in the name. using namespace OrbitUtils; // Constructor -BaseRfGap_slow::BaseRfGap_slow(): CppPyWrapper(NULL) +BaseRfGap_slow::BaseRfGap_slow() { } diff --git a/src/linac/rfgap/BaseRfGap_slow.hh b/src/linac/rfgap/BaseRfGap_slow.hh index c37e86ad..552da660 100644 --- a/src/linac/rfgap/BaseRfGap_slow.hh +++ b/src/linac/rfgap/BaseRfGap_slow.hh @@ -18,7 +18,6 @@ #include "orbit/Bunch.hh" //pyORBIT utils -#include "utils/CppPyWrapper.hh" using namespace std; @@ -26,7 +25,7 @@ using namespace std; This class represents a 2D rectangular grid. */ -class BaseRfGap_slow: public OrbitUtils::CppPyWrapper +class BaseRfGap_slow { public: diff --git a/src/linac/rfgap/MatrixRfGap.cc b/src/linac/rfgap/MatrixRfGap.cc index b741d1f6..2a50d253 100644 --- a/src/linac/rfgap/MatrixRfGap.cc +++ b/src/linac/rfgap/MatrixRfGap.cc @@ -22,7 +22,7 @@ ORNL Tech. Note ORNL/TM-2015/247, June 2015 using namespace OrbitUtils; // Constructor -MatrixRfGap::MatrixRfGap(): CppPyWrapper(NULL) +MatrixRfGap::MatrixRfGap() { } diff --git a/src/linac/rfgap/MatrixRfGap.hh b/src/linac/rfgap/MatrixRfGap.hh index 432e45fb..24037e6c 100644 --- a/src/linac/rfgap/MatrixRfGap.hh +++ b/src/linac/rfgap/MatrixRfGap.hh @@ -17,7 +17,6 @@ For this RF gap we know the E0TL, frequency, and phase only. #include "orbit/Bunch.hh" //pyORBIT utils -#include "utils/CppPyWrapper.hh" using namespace std; @@ -25,7 +24,7 @@ using namespace std; This class represents a RF gap as transport matrix. No nonlinear effects. */ -class MatrixRfGap: public OrbitUtils::CppPyWrapper +class MatrixRfGap { public: diff --git a/src/linac/rfgap/RfGapTTF.cc b/src/linac/rfgap/RfGapTTF.cc index 64b424a0..58e419c1 100644 --- a/src/linac/rfgap/RfGapTTF.cc +++ b/src/linac/rfgap/RfGapTTF.cc @@ -22,7 +22,7 @@ using namespace OrbitUtils; // Constructor -RfGapTTF::RfGapTTF(): CppPyWrapper(NULL) +RfGapTTF::RfGapTTF() { } diff --git a/src/linac/rfgap/RfGapTTF.hh b/src/linac/rfgap/RfGapTTF.hh index 24823c6b..0e508412 100644 --- a/src/linac/rfgap/RfGapTTF.hh +++ b/src/linac/rfgap/RfGapTTF.hh @@ -18,7 +18,6 @@ #include "orbit/Bunch.hh" //pyORBIT utils -#include "utils/CppPyWrapper.hh" #include "utils/polynomial/OU_Polynomial.hh" using namespace std; @@ -27,7 +26,7 @@ using namespace std; This class represents a RF gap as a Parmila type gap. */ -class RfGapTTF: public OrbitUtils::CppPyWrapper +class RfGapTTF { public: diff --git a/src/linac/rfgap/RfGapTTF_slow.cc b/src/linac/rfgap/RfGapTTF_slow.cc index 76c07979..3bdcdd32 100644 --- a/src/linac/rfgap/RfGapTTF_slow.cc +++ b/src/linac/rfgap/RfGapTTF_slow.cc @@ -29,7 +29,7 @@ using namespace OrbitUtils; // Constructor -RfGapTTF_slow::RfGapTTF_slow(): CppPyWrapper(NULL) +RfGapTTF_slow::RfGapTTF_slow() { } diff --git a/src/linac/rfgap/RfGapTTF_slow.hh b/src/linac/rfgap/RfGapTTF_slow.hh index 7e5d0fe9..2a20752c 100644 --- a/src/linac/rfgap/RfGapTTF_slow.hh +++ b/src/linac/rfgap/RfGapTTF_slow.hh @@ -20,7 +20,6 @@ #include "orbit/Bunch.hh" //pyORBIT utils -#include "utils/CppPyWrapper.hh" #include "utils/polynomial/OU_Polynomial.hh" using namespace std; @@ -29,7 +28,7 @@ using namespace std; This class represents a RF gap as a Parmila type gap. */ -class RfGapTTF_slow: public OrbitUtils::CppPyWrapper +class RfGapTTF_slow { public: diff --git a/src/linac/rfgap/RfGapThreePointTTF.cc b/src/linac/rfgap/RfGapThreePointTTF.cc index 174b11fd..1b267d19 100644 --- a/src/linac/rfgap/RfGapThreePointTTF.cc +++ b/src/linac/rfgap/RfGapThreePointTTF.cc @@ -23,7 +23,7 @@ using namespace OrbitUtils; // Constructor -RfGapThreePointTTF::RfGapThreePointTTF(): CppPyWrapper(NULL) +RfGapThreePointTTF::RfGapThreePointTTF() { } diff --git a/src/linac/rfgap/RfGapThreePointTTF.hh b/src/linac/rfgap/RfGapThreePointTTF.hh index e3a24ba2..f8e76a30 100644 --- a/src/linac/rfgap/RfGapThreePointTTF.hh +++ b/src/linac/rfgap/RfGapThreePointTTF.hh @@ -19,7 +19,6 @@ #include "orbit/Bunch.hh" //pyORBIT utils -#include "utils/CppPyWrapper.hh" using namespace std; @@ -27,7 +26,7 @@ using namespace std; This class represents a RF gap as a Three Points type gap. */ -class RfGapThreePointTTF: public OrbitUtils::CppPyWrapper +class RfGapThreePointTTF { public: diff --git a/src/linac/rfgap/RfGapThreePointTTF_slow.cc b/src/linac/rfgap/RfGapThreePointTTF_slow.cc index b27bb342..3a5c4f98 100644 --- a/src/linac/rfgap/RfGapThreePointTTF_slow.cc +++ b/src/linac/rfgap/RfGapThreePointTTF_slow.cc @@ -25,7 +25,7 @@ using namespace OrbitUtils; // Constructor -RfGapThreePointTTF_slow::RfGapThreePointTTF_slow(): CppPyWrapper(NULL) +RfGapThreePointTTF_slow::RfGapThreePointTTF_slow() { } diff --git a/src/linac/rfgap/RfGapThreePointTTF_slow.hh b/src/linac/rfgap/RfGapThreePointTTF_slow.hh index 1b8a09ed..44ef8239 100644 --- a/src/linac/rfgap/RfGapThreePointTTF_slow.hh +++ b/src/linac/rfgap/RfGapThreePointTTF_slow.hh @@ -22,7 +22,6 @@ #include "orbit/Bunch.hh" //pyORBIT utils -#include "utils/CppPyWrapper.hh" using namespace std; @@ -30,7 +29,7 @@ using namespace std; This class represents a RF gap as a Three Points type gap. */ -class RfGapThreePointTTF_slow: public OrbitUtils::CppPyWrapper +class RfGapThreePointTTF_slow { public: diff --git a/src/linac/rfgap/wrap_BaseRfGap.cc b/src/linac/rfgap/wrap_BaseRfGap.cc index 9bb5ab7e..36d13ee8 100644 --- a/src/linac/rfgap/wrap_BaseRfGap.cc +++ b/src/linac/rfgap/wrap_BaseRfGap.cc @@ -36,7 +36,6 @@ extern "C" { //this is implementation of the __init__ method static int BaseRfGap_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ self->cpp_obj = new BaseRfGap(); - ((BaseRfGap*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } diff --git a/src/linac/rfgap/wrap_BaseRfGap_slow.cc b/src/linac/rfgap/wrap_BaseRfGap_slow.cc index 90af7d69..27fa57e7 100644 --- a/src/linac/rfgap/wrap_BaseRfGap_slow.cc +++ b/src/linac/rfgap/wrap_BaseRfGap_slow.cc @@ -36,7 +36,6 @@ extern "C" { //this is implementation of the __init__ method static int BaseRfGap_slow_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ self->cpp_obj = new BaseRfGap_slow(); - ((BaseRfGap_slow*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } diff --git a/src/linac/rfgap/wrap_MatrixRfGap.cc b/src/linac/rfgap/wrap_MatrixRfGap.cc index 035c1533..1a490d62 100644 --- a/src/linac/rfgap/wrap_MatrixRfGap.cc +++ b/src/linac/rfgap/wrap_MatrixRfGap.cc @@ -35,7 +35,6 @@ extern "C" { //this is implementation of the __init__ method static int MatrixRfGap_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ self->cpp_obj = new MatrixRfGap(); - ((MatrixRfGap*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } diff --git a/src/linac/rfgap/wrap_RfGapTTF.cc b/src/linac/rfgap/wrap_RfGapTTF.cc index be69a52b..bc279188 100644 --- a/src/linac/rfgap/wrap_RfGapTTF.cc +++ b/src/linac/rfgap/wrap_RfGapTTF.cc @@ -38,7 +38,6 @@ extern "C" { //this is implementation of the __init__ method static int RfGapTTF_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ self->cpp_obj = new RfGapTTF(); - ((RfGapTTF*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } diff --git a/src/linac/rfgap/wrap_RfGapTTF_slow.cc b/src/linac/rfgap/wrap_RfGapTTF_slow.cc index 9231db01..07272b15 100644 --- a/src/linac/rfgap/wrap_RfGapTTF_slow.cc +++ b/src/linac/rfgap/wrap_RfGapTTF_slow.cc @@ -38,7 +38,6 @@ extern "C" { //this is implementation of the __init__ method static int RfGapTTF_slow_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ self->cpp_obj = new RfGapTTF_slow(); - ((RfGapTTF_slow*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } diff --git a/src/linac/rfgap/wrap_RfGapThreePointTTF.cc b/src/linac/rfgap/wrap_RfGapThreePointTTF.cc index fa400b7b..b809deb0 100644 --- a/src/linac/rfgap/wrap_RfGapThreePointTTF.cc +++ b/src/linac/rfgap/wrap_RfGapThreePointTTF.cc @@ -38,7 +38,6 @@ extern "C" { //this is implementation of the __init__ method static int RfGapThreePointTTF_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ self->cpp_obj = new RfGapThreePointTTF(); - ((RfGapThreePointTTF*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } diff --git a/src/linac/rfgap/wrap_RfGapThreePointTTF_slow.cc b/src/linac/rfgap/wrap_RfGapThreePointTTF_slow.cc index 3c661def..5c0462a8 100644 --- a/src/linac/rfgap/wrap_RfGapThreePointTTF_slow.cc +++ b/src/linac/rfgap/wrap_RfGapThreePointTTF_slow.cc @@ -38,7 +38,6 @@ extern "C" { //this is implementation of the __init__ method static int RfGapThreePointTTF_slow_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ self->cpp_obj = new RfGapThreePointTTF_slow(); - ((RfGapThreePointTTF_slow*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } From 67b5fc403a770de478e5c9e1815af0a52b2fca94 Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 11 Sep 2026 14:34:30 -0400 Subject: [PATCH 13/33] refactor(rfcavities): remove Python wrapper state --- src/orbit/RFCavities/Barrier_Cav.cc | 2 +- src/orbit/RFCavities/Barrier_Cav.hh | 3 +-- src/orbit/RFCavities/Dual_Harmonic_Cav.cc | 2 +- src/orbit/RFCavities/Dual_Harmonic_Cav.hh | 3 +-- src/orbit/RFCavities/Frequency_Cav.cc | 2 +- src/orbit/RFCavities/Frequency_Cav.hh | 3 +-- src/orbit/RFCavities/Harmonic_Cav.cc | 2 +- src/orbit/RFCavities/Harmonic_Cav.hh | 3 +-- src/orbit/RFCavities/wrap_Barrier_Cav.cc | 1 - src/orbit/RFCavities/wrap_Dual_Harmonic_Cav.cc | 1 - src/orbit/RFCavities/wrap_Frequency_Cav.cc | 1 - src/orbit/RFCavities/wrap_Harmonic_Cav.cc | 1 - 12 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/orbit/RFCavities/Barrier_Cav.cc b/src/orbit/RFCavities/Barrier_Cav.cc index c6d25dee..23761b6c 100644 --- a/src/orbit/RFCavities/Barrier_Cav.cc +++ b/src/orbit/RFCavities/Barrier_Cav.cc @@ -15,7 +15,7 @@ Barrier_Cav::Barrier_Cav(double ZtoPhi, double RFPhasep, double RFPhasem, double dRFPhasep, - double dRFPhasem): CppPyWrapper(NULL) + double dRFPhasem) { _ZtoPhi = ZtoPhi; _RFVoltage = RFVoltage; diff --git a/src/orbit/RFCavities/Barrier_Cav.hh b/src/orbit/RFCavities/Barrier_Cav.hh index 58099f29..92d4aca9 100644 --- a/src/orbit/RFCavities/Barrier_Cav.hh +++ b/src/orbit/RFCavities/Barrier_Cav.hh @@ -11,11 +11,10 @@ #include "orbit/Bunch.hh" //pyORBIT utils -#include "utils/CppPyWrapper.hh" using namespace std; -class Barrier_Cav: public OrbitUtils::CppPyWrapper +class Barrier_Cav { public: Barrier_Cav(double ZtoPhi, double RFVoltage, diff --git a/src/orbit/RFCavities/Dual_Harmonic_Cav.cc b/src/orbit/RFCavities/Dual_Harmonic_Cav.cc index c5785907..3979efd4 100644 --- a/src/orbit/RFCavities/Dual_Harmonic_Cav.cc +++ b/src/orbit/RFCavities/Dual_Harmonic_Cav.cc @@ -16,7 +16,7 @@ Dual_Harmonic_Cav::Dual_Harmonic_Cav(double ZtoPhi , double RFVoltage, double RatioVoltage, double RFPhase, - double RFPhase2): CppPyWrapper(NULL) + double RFPhase2) { _ZtoPhi = ZtoPhi; _RFHNum = RFHNum; diff --git a/src/orbit/RFCavities/Dual_Harmonic_Cav.hh b/src/orbit/RFCavities/Dual_Harmonic_Cav.hh index ed42c68e..9383bbcc 100644 --- a/src/orbit/RFCavities/Dual_Harmonic_Cav.hh +++ b/src/orbit/RFCavities/Dual_Harmonic_Cav.hh @@ -11,11 +11,10 @@ #include "orbit/Bunch.hh" //pyORBIT utils -#include "utils/CppPyWrapper.hh" using namespace std; -class Dual_Harmonic_Cav: public OrbitUtils::CppPyWrapper +class Dual_Harmonic_Cav { public: Dual_Harmonic_Cav(double ZtoPhi, double RFHNum, diff --git a/src/orbit/RFCavities/Frequency_Cav.cc b/src/orbit/RFCavities/Frequency_Cav.cc index 8220e45b..300d12a5 100644 --- a/src/orbit/RFCavities/Frequency_Cav.cc +++ b/src/orbit/RFCavities/Frequency_Cav.cc @@ -13,7 +13,7 @@ using namespace OrbitUtils; // Constructor Frequency_Cav::Frequency_Cav(double RFFreq, double RFE0TL, - double RFPhase): CppPyWrapper(NULL) + double RFPhase) { _RFFreq = RFFreq; _RFE0TL = RFE0TL; diff --git a/src/orbit/RFCavities/Frequency_Cav.hh b/src/orbit/RFCavities/Frequency_Cav.hh index 223a91b9..9c79315f 100644 --- a/src/orbit/RFCavities/Frequency_Cav.hh +++ b/src/orbit/RFCavities/Frequency_Cav.hh @@ -11,11 +11,10 @@ #include "orbit/Bunch.hh" //pyORBIT utils -#include "utils/CppPyWrapper.hh" using namespace std; -class Frequency_Cav: public OrbitUtils::CppPyWrapper +class Frequency_Cav { public: Frequency_Cav(double RFFreq, double RFE0TL, double RFPhase); diff --git a/src/orbit/RFCavities/Harmonic_Cav.cc b/src/orbit/RFCavities/Harmonic_Cav.cc index 60a85719..7da3725e 100644 --- a/src/orbit/RFCavities/Harmonic_Cav.cc +++ b/src/orbit/RFCavities/Harmonic_Cav.cc @@ -14,7 +14,7 @@ Harmonic_Cav::Harmonic_Cav(double ZtoPhi , double dESync , double RFHNum , double RFVoltage, - double RFPhase): CppPyWrapper(NULL) + double RFPhase) { _ZtoPhi = ZtoPhi; _dESync = dESync; diff --git a/src/orbit/RFCavities/Harmonic_Cav.hh b/src/orbit/RFCavities/Harmonic_Cav.hh index 50674ef6..0060115c 100644 --- a/src/orbit/RFCavities/Harmonic_Cav.hh +++ b/src/orbit/RFCavities/Harmonic_Cav.hh @@ -11,11 +11,10 @@ #include "orbit/Bunch.hh" //pyORBIT utils -#include "utils/CppPyWrapper.hh" using namespace std; -class Harmonic_Cav: public OrbitUtils::CppPyWrapper +class Harmonic_Cav { public: Harmonic_Cav(double ZtoPhi, double dESync , diff --git a/src/orbit/RFCavities/wrap_Barrier_Cav.cc b/src/orbit/RFCavities/wrap_Barrier_Cav.cc index b1d977e0..938f6b50 100644 --- a/src/orbit/RFCavities/wrap_Barrier_Cav.cc +++ b/src/orbit/RFCavities/wrap_Barrier_Cav.cc @@ -69,7 +69,6 @@ static int Barrier_Cav_init(pyORBIT_Object *self, RFPhasem, dRFPhasep, dRFPhasem); - ((Barrier_Cav*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } diff --git a/src/orbit/RFCavities/wrap_Dual_Harmonic_Cav.cc b/src/orbit/RFCavities/wrap_Dual_Harmonic_Cav.cc index c31916cb..232400d5 100644 --- a/src/orbit/RFCavities/wrap_Dual_Harmonic_Cav.cc +++ b/src/orbit/RFCavities/wrap_Dual_Harmonic_Cav.cc @@ -72,7 +72,6 @@ static int Dual_Harmonic_Cav_init(pyORBIT_Object *self, RatioVoltage, RFPhase, RFPhase2); - ((Dual_Harmonic_Cav*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } diff --git a/src/orbit/RFCavities/wrap_Frequency_Cav.cc b/src/orbit/RFCavities/wrap_Frequency_Cav.cc index 4e30192b..fae840a3 100644 --- a/src/orbit/RFCavities/wrap_Frequency_Cav.cc +++ b/src/orbit/RFCavities/wrap_Frequency_Cav.cc @@ -54,7 +54,6 @@ static int Frequency_Cav_init(pyORBIT_Object *self, PyObject *args, PyObject *kw ORBIT_MPI_Finalize("PyFrequency_Cav - Frequency_Cav_init - cannot parse arguments! They should be (RFFreq, RFE0TL, RFPhase)"); } self->cpp_obj = new Frequency_Cav(RFFreq, RFE0TL, RFPhase); - ((Frequency_Cav*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } diff --git a/src/orbit/RFCavities/wrap_Harmonic_Cav.cc b/src/orbit/RFCavities/wrap_Harmonic_Cav.cc index c038bf2e..5d844677 100644 --- a/src/orbit/RFCavities/wrap_Harmonic_Cav.cc +++ b/src/orbit/RFCavities/wrap_Harmonic_Cav.cc @@ -66,7 +66,6 @@ static int Harmonic_Cav_init(pyORBIT_Object *self, RFHNum, RFVoltage, RFPhase); - ((Harmonic_Cav*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } From fe472fe58eae22486c1f446ca67c337d79b587e0 Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 11 Sep 2026 14:36:10 -0400 Subject: [PATCH 14/33] refactor(bunch): detach analysis helpers from Python --- src/orbit/BunchDiagnostics/BunchTuneAnalysis.cc | 4 ++-- src/orbit/BunchDiagnostics/BunchTuneAnalysis.hh | 3 +-- src/orbit/BunchDiagnostics/BunchTwissAnalysis.cc | 2 +- src/orbit/BunchDiagnostics/BunchTwissAnalysis.hh | 3 +-- src/orbit/BunchDiagnostics/wrap_bunch_tune_analysis.cc | 1 - src/orbit/BunchDiagnostics/wrap_bunch_twiss_analysis.cc | 1 - src/orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.cc | 2 +- src/orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.hh | 3 +-- .../wrap_synch_part_redefinition_z_de.cc | 1 - 9 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/orbit/BunchDiagnostics/BunchTuneAnalysis.cc b/src/orbit/BunchDiagnostics/BunchTuneAnalysis.cc index 957c099f..6469ab3a 100644 --- a/src/orbit/BunchDiagnostics/BunchTuneAnalysis.cc +++ b/src/orbit/BunchDiagnostics/BunchTuneAnalysis.cc @@ -8,7 +8,7 @@ #include -BunchTuneAnalysis::BunchTuneAnalysis(): CppPyWrapper(NULL) { +BunchTuneAnalysis::BunchTuneAnalysis() { double matrix[6][6] = { {1.0, 0.0, 0.0, 0.0, 0.0, 0.0}, {0.0, 1.0, 0.0, 0.0, 0.0, 0.0}, @@ -158,4 +158,4 @@ void BunchTuneAnalysis::analyzeBunch(Bunch* bunch){ erase = 0; } -} \ No newline at end of file +} diff --git a/src/orbit/BunchDiagnostics/BunchTuneAnalysis.hh b/src/orbit/BunchDiagnostics/BunchTuneAnalysis.hh index d68d1b31..d39b1b1b 100644 --- a/src/orbit/BunchDiagnostics/BunchTuneAnalysis.hh +++ b/src/orbit/BunchDiagnostics/BunchTuneAnalysis.hh @@ -2,7 +2,6 @@ #define BUNCH_TUNE_ANALYSIS_H //pyORBIT utils -#include "utils/CppPyWrapper.hh" #include "orbit/Bunch.hh" #include "orbit/BunchDiagnostics/BunchTwissAnalysis.hh" @@ -11,7 +10,7 @@ using namespace std; /** Estimates particle tunes using average phase advance (APA) over one turn. */ -class BunchTuneAnalysis: public OrbitUtils::CppPyWrapper +class BunchTuneAnalysis { public: /** Constructor*/ diff --git a/src/orbit/BunchDiagnostics/BunchTwissAnalysis.cc b/src/orbit/BunchDiagnostics/BunchTwissAnalysis.cc index 7deb2ada..e5afc1b2 100644 --- a/src/orbit/BunchDiagnostics/BunchTwissAnalysis.cc +++ b/src/orbit/BunchDiagnostics/BunchTwissAnalysis.cc @@ -9,7 +9,7 @@ #include "orbit/SyncPart.hh" /** Constructor */ -BunchTwissAnalysis::BunchTwissAnalysis(): CppPyWrapper(NULL) +BunchTwissAnalysis::BunchTwissAnalysis() { avg_arr = (double* ) malloc (6*sizeof(double)); diff --git a/src/orbit/BunchDiagnostics/BunchTwissAnalysis.hh b/src/orbit/BunchDiagnostics/BunchTwissAnalysis.hh index e328ffb7..2ea49251 100644 --- a/src/orbit/BunchDiagnostics/BunchTwissAnalysis.hh +++ b/src/orbit/BunchDiagnostics/BunchTwissAnalysis.hh @@ -2,7 +2,6 @@ #define BUNCH_TWISS_ANALYSIS_H //pyORBIT utils -#include "utils/CppPyWrapper.hh" #include "orbit/Bunch.hh" @@ -13,7 +12,7 @@ using namespace std; As results it returns the Twiss parameters for each plane. */ -class BunchTwissAnalysis: public OrbitUtils::CppPyWrapper +class BunchTwissAnalysis { public: diff --git a/src/orbit/BunchDiagnostics/wrap_bunch_tune_analysis.cc b/src/orbit/BunchDiagnostics/wrap_bunch_tune_analysis.cc index 23499104..6fd6abfc 100644 --- a/src/orbit/BunchDiagnostics/wrap_bunch_tune_analysis.cc +++ b/src/orbit/BunchDiagnostics/wrap_bunch_tune_analysis.cc @@ -31,7 +31,6 @@ static PyObject* BunchTuneAnalysis_new(PyTypeObject *type, PyObject *args, PyObj /** Implementation of the __init__ method */ static int BunchTuneAnalysis_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ self->cpp_obj = new BunchTuneAnalysis(); - ((BunchTuneAnalysis*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } diff --git a/src/orbit/BunchDiagnostics/wrap_bunch_twiss_analysis.cc b/src/orbit/BunchDiagnostics/wrap_bunch_twiss_analysis.cc index 5a227741..c9a980ec 100644 --- a/src/orbit/BunchDiagnostics/wrap_bunch_twiss_analysis.cc +++ b/src/orbit/BunchDiagnostics/wrap_bunch_twiss_analysis.cc @@ -30,7 +30,6 @@ extern "C" { /** This is implementation of the __init__ method */ static int BunchTwissAnalysis_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ self->cpp_obj = new BunchTwissAnalysis(); - ((BunchTwissAnalysis*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } diff --git a/src/orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.cc b/src/orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.cc index 7163fa3a..24b0721b 100644 --- a/src/orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.cc +++ b/src/orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.cc @@ -12,7 +12,7 @@ #include "orbit/OrbitConst.hh" /** Constructor */ -SynchPartRedefinitionZdE::SynchPartRedefinitionZdE(): CppPyWrapper(NULL) +SynchPartRedefinitionZdE::SynchPartRedefinitionZdE() { z_dE_avg_arr = (double* ) malloc (2*sizeof(double)); diff --git a/src/orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.hh b/src/orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.hh index e5aa4d66..cd366a0b 100644 --- a/src/orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.hh +++ b/src/orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.hh @@ -2,7 +2,6 @@ #define SYNCH_PARTICLE_REDEFINITION_H //pyORBIT utils -#include "utils/CppPyWrapper.hh" #include "orbit/Bunch.hh" @@ -14,7 +13,7 @@ using namespace std; to the center of the bunch's phase space. */ -class SynchPartRedefinitionZdE: public OrbitUtils::CppPyWrapper +class SynchPartRedefinitionZdE { public: diff --git a/src/orbit/SynchPartRedefinition/wrap_synch_part_redefinition_z_de.cc b/src/orbit/SynchPartRedefinition/wrap_synch_part_redefinition_z_de.cc index 953e717f..cec7efbd 100644 --- a/src/orbit/SynchPartRedefinition/wrap_synch_part_redefinition_z_de.cc +++ b/src/orbit/SynchPartRedefinition/wrap_synch_part_redefinition_z_de.cc @@ -30,7 +30,6 @@ extern "C" { /** This is implementation of the __init__ method */ static int SynchPartRedefinitionZdE_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ self->cpp_obj = new SynchPartRedefinitionZdE(); - ((SynchPartRedefinitionZdE*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } From 26721326987c87d3ea92b4e35216c7ab8ee5f519 Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 11 Sep 2026 14:37:52 -0400 Subject: [PATCH 15/33] refactor(tracking): remove unused Python wrapper state --- src/orbit/FieldTracker/FieldTracker.hh | 4 +--- src/orbit/FieldTracker/wrap_fieldtracker.cc | 1 - src/orbit/MaterialInteractions/Collimator.cc | 2 +- src/orbit/MaterialInteractions/Collimator.hh | 4 +--- src/orbit/MaterialInteractions/Foil.cc | 2 +- src/orbit/MaterialInteractions/Foil.hh | 4 +--- src/orbit/MaterialInteractions/wrap_collimator.cc | 1 - src/orbit/MaterialInteractions/wrap_foil.cc | 1 - 8 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/orbit/FieldTracker/FieldTracker.hh b/src/orbit/FieldTracker/FieldTracker.hh index 2042d7c9..d11fdc07 100644 --- a/src/orbit/FieldTracker/FieldTracker.hh +++ b/src/orbit/FieldTracker/FieldTracker.hh @@ -3,8 +3,6 @@ #ifndef FIELDTRACKER_H #define FIELDTRACKER_H -//pyORBIT utils -#include "utils/CppPyWrapper.hh" #include "orbit/Bunch.hh" #include "spacecharge/Grid3D.hh" @@ -15,7 +13,7 @@ using namespace std; 3-dimensional magnetic field */ -class FieldTracker: public OrbitUtils::CppPyWrapper +class FieldTracker { public: diff --git a/src/orbit/FieldTracker/wrap_fieldtracker.cc b/src/orbit/FieldTracker/wrap_fieldtracker.cc index 9f5efb7e..169216cb 100644 --- a/src/orbit/FieldTracker/wrap_fieldtracker.cc +++ b/src/orbit/FieldTracker/wrap_fieldtracker.cc @@ -68,7 +68,6 @@ namespace wrap_fieldtracker{ ax, ay, ex, epx, l, zi, zf, ds, niters, resid, xrefi, yrefi, eulerai, eulerbi, eulergi, cpp_bunch, filename_str); - ((FieldTracker*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } diff --git a/src/orbit/MaterialInteractions/Collimator.cc b/src/orbit/MaterialInteractions/Collimator.cc index 0c21a2e2..22ce198e 100644 --- a/src/orbit/MaterialInteractions/Collimator.cc +++ b/src/orbit/MaterialInteractions/Collimator.cc @@ -51,7 +51,7 @@ using namespace OrbitUtils; Collimator::Collimator(double length, int ma, double density_fac, int shape, - double a, double b, double c, double d, double angle, double pos): CppPyWrapper(NULL) + double a, double b, double c, double d, double angle, double pos) { length_ = length; ma_ = ma; diff --git a/src/orbit/MaterialInteractions/Collimator.hh b/src/orbit/MaterialInteractions/Collimator.hh index f766e698..191ca95f 100644 --- a/src/orbit/MaterialInteractions/Collimator.hh +++ b/src/orbit/MaterialInteractions/Collimator.hh @@ -2,8 +2,6 @@ #ifndef COLLIMATOR_H #define COLLIMATOR_H -//pyORBIT utils -#include "utils/CppPyWrapper.hh" #include "orbit/Bunch.hh" using namespace std; @@ -12,7 +10,7 @@ using namespace std; The collimator class is used to define how a bunch propogates through a collimator */ -class Collimator: public OrbitUtils::CppPyWrapper +class Collimator { public: diff --git a/src/orbit/MaterialInteractions/Foil.cc b/src/orbit/MaterialInteractions/Foil.cc index 5dec4257..54661fe8 100644 --- a/src/orbit/MaterialInteractions/Foil.cc +++ b/src/orbit/MaterialInteractions/Foil.cc @@ -35,7 +35,7 @@ using namespace OrbitUtils; // /////////////////////////////////////////////////////////////////////////// -Foil::Foil(double xmin, double xmax, double ymin, double ymax, double thick): CppPyWrapper(NULL) +Foil::Foil(double xmin, double xmax, double ymin, double ymax, double thick) { xmin_ = xmin; xmax_ = xmax; diff --git a/src/orbit/MaterialInteractions/Foil.hh b/src/orbit/MaterialInteractions/Foil.hh index faac4f3e..71e11c8c 100644 --- a/src/orbit/MaterialInteractions/Foil.hh +++ b/src/orbit/MaterialInteractions/Foil.hh @@ -2,8 +2,6 @@ #ifndef FOIL_H #define FOIL_H -//pyORBIT utils -#include "utils/CppPyWrapper.hh" #include "orbit/Bunch.hh" using namespace std; @@ -12,7 +10,7 @@ using namespace std; The foil class is used to define how a bunch propogates through a foil */ -class Foil: public OrbitUtils::CppPyWrapper +class Foil { public: diff --git a/src/orbit/MaterialInteractions/wrap_collimator.cc b/src/orbit/MaterialInteractions/wrap_collimator.cc index 91817b8c..b0b19ce5 100644 --- a/src/orbit/MaterialInteractions/wrap_collimator.cc +++ b/src/orbit/MaterialInteractions/wrap_collimator.cc @@ -38,7 +38,6 @@ extern "C" { error("Collimator - cannot parse arguments! It should be (length,ma,density_fac,shape,a,b,c,d,angle,pos)"); } self->cpp_obj = new Collimator(length,ma,density_fac,shape,a,b,c,d,angle,pos); - ((Collimator*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } diff --git a/src/orbit/MaterialInteractions/wrap_foil.cc b/src/orbit/MaterialInteractions/wrap_foil.cc index 160a0541..322de28d 100644 --- a/src/orbit/MaterialInteractions/wrap_foil.cc +++ b/src/orbit/MaterialInteractions/wrap_foil.cc @@ -37,7 +37,6 @@ extern "C" { error("PyBunch - addParticle - cannot parse arguments! It should be (xmin, xmax, ymin, ymax, thick)"); } self->cpp_obj = new Foil(xmin, xmax, ymin, ymax, thick); - ((Foil*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } From da0551682cb7d24d4f01cec59834c9b4358c856f Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 11 Sep 2026 14:40:59 -0400 Subject: [PATCH 16/33] refactor(spacecharge): detach solver bases from Python --- src/spacecharge/BaseBoundary2D.cc | 2 +- src/spacecharge/BaseBoundary2D.hh | 5 +---- src/spacecharge/ForceSolver2D.cc | 2 +- src/spacecharge/ForceSolver2D.hh | 5 +---- src/spacecharge/ForceSolverFFT2D.hh | 3 --- src/spacecharge/PoissonSolver2D.cc | 4 ++-- src/spacecharge/PoissonSolver2D.hh | 5 +---- src/spacecharge/PoissonSolver3D.cc | 4 ++-- src/spacecharge/PoissonSolver3D.hh | 5 +---- src/spacecharge/PoissonSolverFFT2D.hh | 3 --- src/spacecharge/PoissonSolverFFT3D.hh | 3 --- src/spacecharge/wrap_boundary2d.cc | 2 -- src/spacecharge/wrap_forcesolverfft2d.cc | 1 - src/spacecharge/wrap_poissonsolverfft2d.cc | 1 - src/spacecharge/wrap_poissonsolverfft3d.cc | 1 - 15 files changed, 10 insertions(+), 36 deletions(-) diff --git a/src/spacecharge/BaseBoundary2D.cc b/src/spacecharge/BaseBoundary2D.cc index 868eb772..9bbcafd9 100644 --- a/src/spacecharge/BaseBoundary2D.cc +++ b/src/spacecharge/BaseBoundary2D.cc @@ -19,7 +19,7 @@ surface. */ // Constructor -BaseBoundary2D::BaseBoundary2D(int nPoints, int nModes): CppPyWrapper(NULL) +BaseBoundary2D::BaseBoundary2D(int nPoints, int nModes) { initialized_ = 0; diff --git a/src/spacecharge/BaseBoundary2D.hh b/src/spacecharge/BaseBoundary2D.hh index 8340ac4a..a5e469bf 100644 --- a/src/spacecharge/BaseBoundary2D.hh +++ b/src/spacecharge/BaseBoundary2D.hh @@ -4,9 +4,6 @@ #include "spacecharge/Grid2D.hh" #include -//pyORBIT utils -#include "utils/CppPyWrapper.hh" - using namespace std; /** @@ -15,7 +12,7 @@ and calculates the potential created by charges on the boundary surface. */ -class BaseBoundary2D: public OrbitUtils::CppPyWrapper +class BaseBoundary2D { public: diff --git a/src/spacecharge/ForceSolver2D.cc b/src/spacecharge/ForceSolver2D.cc index 5953ec3d..1409b8fa 100644 --- a/src/spacecharge/ForceSolver2D.cc +++ b/src/spacecharge/ForceSolver2D.cc @@ -5,7 +5,7 @@ using namespace OrbitUtils; // Constructor -ForceSolver2D::ForceSolver2D(int xSize, int ySize): CppPyWrapper(NULL) +ForceSolver2D::ForceSolver2D(int xSize, int ySize) { xSize_ = xSize; ySize_ = ySize; diff --git a/src/spacecharge/ForceSolver2D.hh b/src/spacecharge/ForceSolver2D.hh index 69980df5..6e06d16c 100644 --- a/src/spacecharge/ForceSolver2D.hh +++ b/src/spacecharge/ForceSolver2D.hh @@ -10,9 +10,6 @@ #include #include -//pyORBIT utils -#include "utils/CppPyWrapper.hh" - #include "spacecharge/Grid2D.hh" using namespace std; @@ -22,7 +19,7 @@ using namespace std; created by a 2D charge distribution. */ -class ForceSolver2D: public OrbitUtils::CppPyWrapper +class ForceSolver2D { public: diff --git a/src/spacecharge/ForceSolverFFT2D.hh b/src/spacecharge/ForceSolverFFT2D.hh index 71bbc71c..8fd66f64 100644 --- a/src/spacecharge/ForceSolverFFT2D.hh +++ b/src/spacecharge/ForceSolverFFT2D.hh @@ -11,9 +11,6 @@ #include #include -//pyORBIT utils -#include "utils/CppPyWrapper.hh" - //FFTW library header #include "fftw3.h" diff --git a/src/spacecharge/PoissonSolver2D.cc b/src/spacecharge/PoissonSolver2D.cc index e093fd95..3b3aef10 100644 --- a/src/spacecharge/PoissonSolver2D.cc +++ b/src/spacecharge/PoissonSolver2D.cc @@ -5,7 +5,7 @@ using namespace OrbitUtils; // Constructor -PoissonSolver2D::PoissonSolver2D(int xSize, int ySize): CppPyWrapper(NULL) +PoissonSolver2D::PoissonSolver2D(int xSize, int ySize) { xSize_ = xSize; ySize_ = ySize; @@ -20,7 +20,7 @@ PoissonSolver2D::PoissonSolver2D(int xSize, int ySize): CppPyWrapper(NULL) // Constructor PoissonSolver2D::PoissonSolver2D(int xSize, int ySize, double xMin, double xMax, - double yMin, double yMax): CppPyWrapper(NULL) + double yMin, double yMax) { xSize_ = xSize; ySize_ = ySize; diff --git a/src/spacecharge/PoissonSolver2D.hh b/src/spacecharge/PoissonSolver2D.hh index a379d13a..cc2fdd21 100644 --- a/src/spacecharge/PoissonSolver2D.hh +++ b/src/spacecharge/PoissonSolver2D.hh @@ -10,9 +10,6 @@ #include #include -//pyORBIT utils -#include "utils/CppPyWrapper.hh" - #include "spacecharge/Grid2D.hh" using namespace std; @@ -22,7 +19,7 @@ using namespace std; potential of a 2D charge distribution. */ -class PoissonSolver2D: public OrbitUtils::CppPyWrapper +class PoissonSolver2D { public: diff --git a/src/spacecharge/PoissonSolver3D.cc b/src/spacecharge/PoissonSolver3D.cc index 02ce2121..9015a291 100644 --- a/src/spacecharge/PoissonSolver3D.cc +++ b/src/spacecharge/PoissonSolver3D.cc @@ -5,7 +5,7 @@ using namespace OrbitUtils; // Constructor -PoissonSolver3D::PoissonSolver3D(int xSize, int ySize, int zSize): CppPyWrapper(NULL) +PoissonSolver3D::PoissonSolver3D(int xSize, int ySize, int zSize) { xSize_ = xSize; ySize_ = ySize; @@ -32,7 +32,7 @@ PoissonSolver3D::PoissonSolver3D(int xSize, int ySize, int zSize): CppPyWrapper( PoissonSolver3D::PoissonSolver3D(int xSize, int ySize, int zSize, double xMin, double xMax, double yMin, double yMax, - double zMin, double zMax): CppPyWrapper(NULL) + double zMin, double zMax) { xSize_ = xSize; ySize_ = ySize; diff --git a/src/spacecharge/PoissonSolver3D.hh b/src/spacecharge/PoissonSolver3D.hh index 3292a724..e627adab 100644 --- a/src/spacecharge/PoissonSolver3D.hh +++ b/src/spacecharge/PoissonSolver3D.hh @@ -10,9 +10,6 @@ #include #include -//pyORBIT utils -#include "utils/CppPyWrapper.hh" - #include "spacecharge/Grid3D.hh" using namespace std; @@ -22,7 +19,7 @@ using namespace std; created by 3D charge distribution. */ -class PoissonSolver3D: public OrbitUtils::CppPyWrapper +class PoissonSolver3D { public: diff --git a/src/spacecharge/PoissonSolverFFT2D.hh b/src/spacecharge/PoissonSolverFFT2D.hh index b065d844..d81dfedf 100644 --- a/src/spacecharge/PoissonSolverFFT2D.hh +++ b/src/spacecharge/PoissonSolverFFT2D.hh @@ -10,9 +10,6 @@ #include #include -//pyORBIT utils -#include "utils/CppPyWrapper.hh" - //FFTW library header #include "fftw3.h" diff --git a/src/spacecharge/PoissonSolverFFT3D.hh b/src/spacecharge/PoissonSolverFFT3D.hh index 6077813d..c00728b6 100644 --- a/src/spacecharge/PoissonSolverFFT3D.hh +++ b/src/spacecharge/PoissonSolverFFT3D.hh @@ -11,9 +11,6 @@ #include #include -//pyORBIT utils -#include "utils/CppPyWrapper.hh" - //FFTW library header #include "fftw3.h" diff --git a/src/spacecharge/wrap_boundary2d.cc b/src/spacecharge/wrap_boundary2d.cc index fc63b2d1..231b9a80 100644 --- a/src/spacecharge/wrap_boundary2d.cc +++ b/src/spacecharge/wrap_boundary2d.cc @@ -45,7 +45,6 @@ extern "C" { ORBIT_MPI_Finalize("PyBoundary2D - Boundary2D(nPoints,nModes) - constructor needs parameters."); } self->cpp_obj = new BaseBoundary2D(nPoints, nModes); - ((BaseBoundary2D*) self->cpp_obj)->setPyWrapper((PyObject*) self); //std::cerr<<"The Boundary2D __init__ has been called!"<cpp_obj = new ShapedBoundary2D(nPoints, nModes,shape,xDim,yDim); - ((BaseBoundary2D*) self->cpp_obj)->setPyWrapper((PyObject*) self); //std::cerr<<"The Boundary2D __init__ has been called!"<cpp_obj = new ForceSolverFFT2D(xSize,ySize); - ((ForceSolverFFT2D*) self->cpp_obj)->setPyWrapper((PyObject*) self); //std::cerr<<"The ForceSolverFFT2D __init__ has been called!"<cpp_obj = new PoissonSolverFFT2D(xSize,ySize,xMin,xMax,yMin,yMax); - ((PoissonSolverFFT2D*) self->cpp_obj)->setPyWrapper((PyObject*) self); //std::cerr<<"The PoissonSolverFFT2D __init__ has been called!"<cpp_obj = new PoissonSolverFFT3D(xSize,ySize,zSize,xMin,xMax,yMin,yMax,zMin,zMax); - ((PoissonSolverFFT3D*) self->cpp_obj)->setPyWrapper((PyObject*) self); //std::cerr<<"The PoissonSolverFFT3D __init__ has been called!"< Date: Fri, 11 Sep 2026 14:45:44 -0400 Subject: [PATCH 17/33] refactor(spacecharge): remove calculator wrapper state --- src/spacecharge/LSpaceChargeCalc.cc | 2 +- src/spacecharge/LSpaceChargeCalc.hh | 3 +-- src/spacecharge/SpaceChargeCalc2p5D.cc | 4 ++-- src/spacecharge/SpaceChargeCalc2p5D.hh | 3 +-- src/spacecharge/SpaceChargeCalc2p5Drb.cc | 4 ++-- src/spacecharge/SpaceChargeCalc2p5Drb.hh | 3 +-- src/spacecharge/SpaceChargeCalc3D.cc | 2 +- src/spacecharge/SpaceChargeCalc3D.hh | 3 +-- src/spacecharge/SpaceChargeCalcSliceBySlice2D.cc | 4 ++-- src/spacecharge/SpaceChargeCalcSliceBySlice2D.hh | 3 +-- src/spacecharge/SpaceChargeCalcUnifEllipse.cc | 2 +- src/spacecharge/SpaceChargeCalcUnifEllipse.hh | 3 +-- src/spacecharge/SpaceChargeForceCalc2p5D.cc | 2 +- src/spacecharge/SpaceChargeForceCalc2p5D.hh | 3 +-- src/spacecharge/wrap_lspacechargecalc.cc | 1 - src/spacecharge/wrap_spacechargecalc2p5d.cc | 1 - src/spacecharge/wrap_spacechargecalc2p5d_rb.cc | 1 - src/spacecharge/wrap_spacechargecalc3d.cc | 1 - src/spacecharge/wrap_spacechargecalc_slicebyslice_2D.cc | 1 - src/spacecharge/wrap_spacechargeforcecalc2p5d.cc | 1 - 20 files changed, 17 insertions(+), 30 deletions(-) diff --git a/src/spacecharge/LSpaceChargeCalc.cc b/src/spacecharge/LSpaceChargeCalc.cc index 297b85a3..a8463666 100644 --- a/src/spacecharge/LSpaceChargeCalc.cc +++ b/src/spacecharge/LSpaceChargeCalc.cc @@ -25,7 +25,7 @@ using namespace OrbitUtils; -LSpaceChargeCalc::LSpaceChargeCalc(double b_a_in, double length_in, int nMacrosMin_in, int useSpaceCharge_in, int nBins_in) : CppPyWrapper(NULL) { +LSpaceChargeCalc::LSpaceChargeCalc(double b_a_in, double length_in, int nMacrosMin_in, int useSpaceCharge_in, int nBins_in) { b_a = b_a_in; length = length_in; nMacrosMin = nMacrosMin_in; diff --git a/src/spacecharge/LSpaceChargeCalc.hh b/src/spacecharge/LSpaceChargeCalc.hh index 9f1e0162..03968ef3 100644 --- a/src/spacecharge/LSpaceChargeCalc.hh +++ b/src/spacecharge/LSpaceChargeCalc.hh @@ -14,7 +14,6 @@ #include "orbit/Bunch.hh" //pyORBIT utils -#include "utils/CppPyWrapper.hh" #include "utils/bunch/BunchExtremaCalculator.hh" #include "spacecharge/Grid1D.hh" @@ -23,7 +22,7 @@ using namespace std; -class LSpaceChargeCalc: public OrbitUtils::CppPyWrapper +class LSpaceChargeCalc { public: diff --git a/src/spacecharge/SpaceChargeCalc2p5D.cc b/src/spacecharge/SpaceChargeCalc2p5D.cc index 338d52a7..e3b13090 100644 --- a/src/spacecharge/SpaceChargeCalc2p5D.cc +++ b/src/spacecharge/SpaceChargeCalc2p5D.cc @@ -22,7 +22,7 @@ using namespace OrbitUtils; -SpaceChargeCalc2p5D::SpaceChargeCalc2p5D(int xSize, int ySize, int zSize, double xy_ratio_in): CppPyWrapper(NULL) +SpaceChargeCalc2p5D::SpaceChargeCalc2p5D(int xSize, int ySize, int zSize, double xy_ratio_in) { xy_ratio = xy_ratio_in; poissonSolver = new PoissonSolverFFT2D(xSize, ySize, -xy_ratio, xy_ratio, -1.0, 1.0); @@ -32,7 +32,7 @@ SpaceChargeCalc2p5D::SpaceChargeCalc2p5D(int xSize, int ySize, int zSize, double bunchExtremaCalc = new BunchExtremaCalculator(); } -SpaceChargeCalc2p5D::SpaceChargeCalc2p5D(int xSize, int ySize, int zSize): CppPyWrapper(NULL) +SpaceChargeCalc2p5D::SpaceChargeCalc2p5D(int xSize, int ySize, int zSize) { xy_ratio = 1.0; poissonSolver = new PoissonSolverFFT2D(xSize, ySize, -xy_ratio, xy_ratio, -1.0, 1.0); diff --git a/src/spacecharge/SpaceChargeCalc2p5D.hh b/src/spacecharge/SpaceChargeCalc2p5D.hh index 1ca3627f..af071de0 100644 --- a/src/spacecharge/SpaceChargeCalc2p5D.hh +++ b/src/spacecharge/SpaceChargeCalc2p5D.hh @@ -13,7 +13,6 @@ #include "orbit/Bunch.hh" //pyORBIT utils -#include "utils/CppPyWrapper.hh" #include "utils/bunch/BunchExtremaCalculator.hh" #include "spacecharge/Grid1D.hh" @@ -23,7 +22,7 @@ using namespace std; -class SpaceChargeCalc2p5D: public OrbitUtils::CppPyWrapper +class SpaceChargeCalc2p5D { public: diff --git a/src/spacecharge/SpaceChargeCalc2p5Drb.cc b/src/spacecharge/SpaceChargeCalc2p5Drb.cc index 74a1db8a..fc9a2e45 100644 --- a/src/spacecharge/SpaceChargeCalc2p5Drb.cc +++ b/src/spacecharge/SpaceChargeCalc2p5Drb.cc @@ -28,7 +28,7 @@ using namespace OrbitUtils; -SpaceChargeCalc2p5Drb::SpaceChargeCalc2p5Drb(int xSize, int ySize, int zSize, double xy_ratio_in): CppPyWrapper(NULL) +SpaceChargeCalc2p5Drb::SpaceChargeCalc2p5Drb(int xSize, int ySize, int zSize, double xy_ratio_in) { xy_ratio = xy_ratio_in; poissonSolver = new PoissonSolverFFT2D(xSize, ySize, -xy_ratio, xy_ratio, -1.0, 1.0); @@ -45,7 +45,7 @@ SpaceChargeCalc2p5Drb::SpaceChargeCalc2p5Drb(int xSize, int ySize, int zSize, do } } -SpaceChargeCalc2p5Drb::SpaceChargeCalc2p5Drb(int xSize, int ySize, int zSize): CppPyWrapper(NULL) +SpaceChargeCalc2p5Drb::SpaceChargeCalc2p5Drb(int xSize, int ySize, int zSize) { xy_ratio = 1.0; poissonSolver = new PoissonSolverFFT2D(xSize, ySize, -xy_ratio, xy_ratio, -1.0, 1.0); diff --git a/src/spacecharge/SpaceChargeCalc2p5Drb.hh b/src/spacecharge/SpaceChargeCalc2p5Drb.hh index 0626681f..eb82b7b2 100644 --- a/src/spacecharge/SpaceChargeCalc2p5Drb.hh +++ b/src/spacecharge/SpaceChargeCalc2p5Drb.hh @@ -17,7 +17,6 @@ #include "orbit/Bunch.hh" //pyORBIT utils -#include "utils/CppPyWrapper.hh" #include "utils/bunch/BunchExtremaCalculator.hh" #include "spacecharge/Grid1D.hh" @@ -26,7 +25,7 @@ using namespace std; -class SpaceChargeCalc2p5Drb: public OrbitUtils::CppPyWrapper +class SpaceChargeCalc2p5Drb { public: diff --git a/src/spacecharge/SpaceChargeCalc3D.cc b/src/spacecharge/SpaceChargeCalc3D.cc index 2a615896..7410355a 100644 --- a/src/spacecharge/SpaceChargeCalc3D.cc +++ b/src/spacecharge/SpaceChargeCalc3D.cc @@ -30,7 +30,7 @@ using namespace OrbitUtils; -SpaceChargeCalc3D::SpaceChargeCalc3D(int xSize, int ySize, int zSize): CppPyWrapper(NULL) +SpaceChargeCalc3D::SpaceChargeCalc3D(int xSize, int ySize, int zSize) { xy_ratio = 1.0; xz_ratio = 1.0; diff --git a/src/spacecharge/SpaceChargeCalc3D.hh b/src/spacecharge/SpaceChargeCalc3D.hh index 08232bcf..729b1d1f 100644 --- a/src/spacecharge/SpaceChargeCalc3D.hh +++ b/src/spacecharge/SpaceChargeCalc3D.hh @@ -19,7 +19,6 @@ #include "orbit/Bunch.hh" //pyORBIT utils -#include "utils/CppPyWrapper.hh" #include "utils/bunch/BunchExtremaCalculator.hh" #include "spacecharge/Grid3D.hh" @@ -27,7 +26,7 @@ using namespace std; -class SpaceChargeCalc3D: public OrbitUtils::CppPyWrapper +class SpaceChargeCalc3D { public: diff --git a/src/spacecharge/SpaceChargeCalcSliceBySlice2D.cc b/src/spacecharge/SpaceChargeCalcSliceBySlice2D.cc index 996e46a3..d5c2964c 100755 --- a/src/spacecharge/SpaceChargeCalcSliceBySlice2D.cc +++ b/src/spacecharge/SpaceChargeCalcSliceBySlice2D.cc @@ -21,7 +21,7 @@ using namespace OrbitUtils; -SpaceChargeCalcSliceBySlice2D::SpaceChargeCalcSliceBySlice2D(int xSize, int ySize, int zSize, double xy_ratio_in): CppPyWrapper(NULL) +SpaceChargeCalcSliceBySlice2D::SpaceChargeCalcSliceBySlice2D(int xSize, int ySize, int zSize, double xy_ratio_in) { xy_ratio = xy_ratio_in; useLongTracking = 0; @@ -31,7 +31,7 @@ SpaceChargeCalcSliceBySlice2D::SpaceChargeCalcSliceBySlice2D(int xSize, int ySiz bunchExtremaCalc = new BunchExtremaCalculator(); } -SpaceChargeCalcSliceBySlice2D::SpaceChargeCalcSliceBySlice2D(int xSize, int ySize, int zSize): CppPyWrapper(NULL) +SpaceChargeCalcSliceBySlice2D::SpaceChargeCalcSliceBySlice2D(int xSize, int ySize, int zSize) { xy_ratio = 1.0; useLongTracking = 0; diff --git a/src/spacecharge/SpaceChargeCalcSliceBySlice2D.hh b/src/spacecharge/SpaceChargeCalcSliceBySlice2D.hh index 8f8681e9..1e76d030 100755 --- a/src/spacecharge/SpaceChargeCalcSliceBySlice2D.hh +++ b/src/spacecharge/SpaceChargeCalcSliceBySlice2D.hh @@ -13,7 +13,6 @@ #include "orbit/Bunch.hh" //pyORBIT utils -#include "utils/CppPyWrapper.hh" #include "utils/bunch/BunchExtremaCalculator.hh" #include "spacecharge/Grid3D.hh" @@ -22,7 +21,7 @@ using namespace std; -class SpaceChargeCalcSliceBySlice2D: public OrbitUtils::CppPyWrapper +class SpaceChargeCalcSliceBySlice2D { public: diff --git a/src/spacecharge/SpaceChargeCalcUnifEllipse.cc b/src/spacecharge/SpaceChargeCalcUnifEllipse.cc index 8549e8ee..0a07dd4f 100644 --- a/src/spacecharge/SpaceChargeCalcUnifEllipse.cc +++ b/src/spacecharge/SpaceChargeCalcUnifEllipse.cc @@ -26,7 +26,7 @@ using namespace OrbitUtils; -SpaceChargeCalcUnifEllipse::SpaceChargeCalcUnifEllipse(int nEllipses_in): CppPyWrapper(NULL) +SpaceChargeCalcUnifEllipse::SpaceChargeCalcUnifEllipse(int nEllipses_in) { nEllipses = nEllipses_in; ellipsoidCalc_arr = new UniformEllipsoidFieldCalculator*[nEllipses]; diff --git a/src/spacecharge/SpaceChargeCalcUnifEllipse.hh b/src/spacecharge/SpaceChargeCalcUnifEllipse.hh index dd5c0267..949c303d 100644 --- a/src/spacecharge/SpaceChargeCalcUnifEllipse.hh +++ b/src/spacecharge/SpaceChargeCalcUnifEllipse.hh @@ -17,13 +17,12 @@ #include "orbit/Bunch.hh" //pyORBIT utils -#include "utils/CppPyWrapper.hh" #include "spacecharge/UniformEllipsoidFieldCalculator.hh" using namespace std; -class SpaceChargeCalcUnifEllipse: public OrbitUtils::CppPyWrapper +class SpaceChargeCalcUnifEllipse { public: diff --git a/src/spacecharge/SpaceChargeForceCalc2p5D.cc b/src/spacecharge/SpaceChargeForceCalc2p5D.cc index 6f2b73c1..c3f167db 100644 --- a/src/spacecharge/SpaceChargeForceCalc2p5D.cc +++ b/src/spacecharge/SpaceChargeForceCalc2p5D.cc @@ -22,7 +22,7 @@ using namespace OrbitUtils; -SpaceChargeForceCalc2p5D::SpaceChargeForceCalc2p5D(int xSize, int ySize, int zSize): CppPyWrapper(NULL) +SpaceChargeForceCalc2p5D::SpaceChargeForceCalc2p5D(int xSize, int ySize, int zSize) { forceSolver = new ForceSolverFFT2D(xSize, ySize); rhoGrid = new Grid2D(xSize, ySize); diff --git a/src/spacecharge/SpaceChargeForceCalc2p5D.hh b/src/spacecharge/SpaceChargeForceCalc2p5D.hh index 71179d00..4f744e15 100644 --- a/src/spacecharge/SpaceChargeForceCalc2p5D.hh +++ b/src/spacecharge/SpaceChargeForceCalc2p5D.hh @@ -12,7 +12,6 @@ //ORBIT bunch #include "orbit/Bunch.hh" //pyORBIT utils -#include "utils/CppPyWrapper.hh" #include "utils/bunch/BunchExtremaCalculator.hh" #include "spacecharge/Grid1D.hh" @@ -22,7 +21,7 @@ using namespace std; -class SpaceChargeForceCalc2p5D: public OrbitUtils::CppPyWrapper +class SpaceChargeForceCalc2p5D { public: diff --git a/src/spacecharge/wrap_lspacechargecalc.cc b/src/spacecharge/wrap_lspacechargecalc.cc index 98539127..9c7c7712 100644 --- a/src/spacecharge/wrap_lspacechargecalc.cc +++ b/src/spacecharge/wrap_lspacechargecalc.cc @@ -55,7 +55,6 @@ extern "C" self->cpp_obj = new LSpaceChargeCalc(b_a, length, nMacrosMin, useSpaceCharge, nBins); - ((LSpaceChargeCalc*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } diff --git a/src/spacecharge/wrap_spacechargecalc2p5d.cc b/src/spacecharge/wrap_spacechargecalc2p5d.cc index 960608e1..e1e14ba8 100644 --- a/src/spacecharge/wrap_spacechargecalc2p5d.cc +++ b/src/spacecharge/wrap_spacechargecalc2p5d.cc @@ -46,7 +46,6 @@ extern "C" { } else { self->cpp_obj = new SpaceChargeCalc2p5D(xSize,ySize,zSize); } - ((SpaceChargeCalc2p5D*) self->cpp_obj)->setPyWrapper((PyObject*) self); //std::cerr<<"The SpaceChargeCalc2p5D __init__ has been called!"<cpp_obj = new SpaceChargeCalc2p5Drb(xSize,ySize,zSize); } - ((SpaceChargeCalc2p5Drb*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } diff --git a/src/spacecharge/wrap_spacechargecalc3d.cc b/src/spacecharge/wrap_spacechargecalc3d.cc index e853ea79..46b30a70 100644 --- a/src/spacecharge/wrap_spacechargecalc3d.cc +++ b/src/spacecharge/wrap_spacechargecalc3d.cc @@ -41,7 +41,6 @@ extern "C" { ORBIT_MPI_Finalize("PySpaceChargeCalc3D - SpaceChargeCalc3D(xSize,ySize,xzSize) - constructor needs parameters."); } self->cpp_obj = new SpaceChargeCalc3D(xSize,ySize,zSize); - ((SpaceChargeCalc3D*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } diff --git a/src/spacecharge/wrap_spacechargecalc_slicebyslice_2D.cc b/src/spacecharge/wrap_spacechargecalc_slicebyslice_2D.cc index 5ebdf0a6..01569c4f 100755 --- a/src/spacecharge/wrap_spacechargecalc_slicebyslice_2D.cc +++ b/src/spacecharge/wrap_spacechargecalc_slicebyslice_2D.cc @@ -46,7 +46,6 @@ extern "C" { } else { self->cpp_obj = new SpaceChargeCalcSliceBySlice2D(xSize,ySize,zSize); } - ((SpaceChargeCalcSliceBySlice2D*) self->cpp_obj)->setPyWrapper((PyObject*) self); //std::cerr<<"The SpaceChargeCalcSliceBySlice2D __init__ has been called!"<cpp_obj = new SpaceChargeForceCalc2p5D(xSize,ySize,zSize); - ((SpaceChargeForceCalc2p5D*) self->cpp_obj)->setPyWrapper((PyObject*) self); //std::cerr<<"The SpaceChargeForceCalc2p5D __init__ has been called!"< Date: Fri, 11 Sep 2026 14:47:41 -0400 Subject: [PATCH 18/33] refactor(impedances): remove wrapper state --- src/orbit/Impedances/LImpedance.cc | 2 +- src/orbit/Impedances/LImpedance.hh | 3 +-- src/orbit/Impedances/TImpedance.cc | 2 +- src/orbit/Impedances/TImpedance.hh | 3 +-- src/orbit/Impedances/wrap_LImpedance.cc | 1 - src/orbit/Impedances/wrap_TImpedance.cc | 1 - 6 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/orbit/Impedances/LImpedance.cc b/src/orbit/Impedances/LImpedance.cc index b382f1aa..abad93c8 100644 --- a/src/orbit/Impedances/LImpedance.cc +++ b/src/orbit/Impedances/LImpedance.cc @@ -29,7 +29,7 @@ using namespace OrbitUtils; LImpedance::LImpedance(double length, int nMacrosMin, - int nBins): CppPyWrapper(NULL) + int nBins) { _length = length; _nMacrosMin = nMacrosMin; diff --git a/src/orbit/Impedances/LImpedance.hh b/src/orbit/Impedances/LImpedance.hh index 0aa7ae0b..a722647a 100644 --- a/src/orbit/Impedances/LImpedance.hh +++ b/src/orbit/Impedances/LImpedance.hh @@ -14,7 +14,6 @@ #include "orbit/Bunch.hh" //pyORBIT utils -#include "utils/CppPyWrapper.hh" #include "utils/bunch/BunchExtremaCalculator.hh" #include "spacecharge/Grid1D.hh" @@ -23,7 +22,7 @@ using namespace std; -class LImpedance: public OrbitUtils::CppPyWrapper +class LImpedance { public: diff --git a/src/orbit/Impedances/TImpedance.cc b/src/orbit/Impedances/TImpedance.cc index c73a221f..b60d5946 100644 --- a/src/orbit/Impedances/TImpedance.cc +++ b/src/orbit/Impedances/TImpedance.cc @@ -30,7 +30,7 @@ TImpedance::TImpedance(double length, int nMacrosMin, int nBins, int useX, - int useY): CppPyWrapper(NULL) + int useY) { _length = length; _nMacrosMin = nMacrosMin; diff --git a/src/orbit/Impedances/TImpedance.hh b/src/orbit/Impedances/TImpedance.hh index 48767723..37f596d6 100644 --- a/src/orbit/Impedances/TImpedance.hh +++ b/src/orbit/Impedances/TImpedance.hh @@ -14,7 +14,6 @@ #include "orbit/Bunch.hh" //pyORBIT utils -#include "utils/CppPyWrapper.hh" #include "utils/bunch/BunchExtremaCalculator.hh" #include "spacecharge/Grid1D.hh" @@ -23,7 +22,7 @@ using namespace std; -class TImpedance: public OrbitUtils::CppPyWrapper +class TImpedance { public: diff --git a/src/orbit/Impedances/wrap_LImpedance.cc b/src/orbit/Impedances/wrap_LImpedance.cc index f1490c15..90a0ae1d 100644 --- a/src/orbit/Impedances/wrap_LImpedance.cc +++ b/src/orbit/Impedances/wrap_LImpedance.cc @@ -63,7 +63,6 @@ extern "C" self->cpp_obj = new LImpedance(length, nMacrosMin, nBins); - ((LImpedance*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } diff --git a/src/orbit/Impedances/wrap_TImpedance.cc b/src/orbit/Impedances/wrap_TImpedance.cc index e177d3c9..73b78f21 100644 --- a/src/orbit/Impedances/wrap_TImpedance.cc +++ b/src/orbit/Impedances/wrap_TImpedance.cc @@ -69,7 +69,6 @@ extern "C" self->cpp_obj = new TImpedance(length, nMacrosMin, nBins, useX, useY); - ((TImpedance*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } From 75358f74895cee0b3121f0b8633e9b30f92918e2 Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 11 Sep 2026 14:49:58 -0400 Subject: [PATCH 19/33] refactor(apertures): remove element wrapper state --- src/orbit/Apertures/Aperture.cc | 2 +- src/orbit/Apertures/Aperture.hh | 3 +-- src/orbit/Apertures/EnergyAperture.cc | 2 +- src/orbit/Apertures/EnergyAperture.hh | 3 +-- src/orbit/Apertures/PhaseAperture.cc | 2 +- src/orbit/Apertures/PhaseAperture.hh | 3 +-- src/orbit/Apertures/wrap_EnergyAperture.cc | 1 - src/orbit/Apertures/wrap_PhaseAperture.cc | 1 - src/orbit/Apertures/wrap_TAperture.cc | 1 - 9 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/orbit/Apertures/Aperture.cc b/src/orbit/Apertures/Aperture.cc index f027f075..da0dd09c 100644 --- a/src/orbit/Apertures/Aperture.cc +++ b/src/orbit/Apertures/Aperture.cc @@ -31,7 +31,7 @@ // /////////////////////////////////////////////////////////////////////////// -Aperture::Aperture(int shape, double a, double b, double c, double d, double pos): CppPyWrapper(NULL) +Aperture::Aperture(int shape, double a, double b, double c, double d, double pos) { shape_ = shape; a_ = a; diff --git a/src/orbit/Apertures/Aperture.hh b/src/orbit/Apertures/Aperture.hh index ffc2bbae..15066ffa 100644 --- a/src/orbit/Apertures/Aperture.hh +++ b/src/orbit/Apertures/Aperture.hh @@ -3,7 +3,6 @@ #define APERTURE_H //pyORBIT utils -#include "utils/CppPyWrapper.hh" #include "orbit/Bunch.hh" using namespace std; @@ -12,7 +11,7 @@ using namespace std; The aperture class is used to define how a bunch propogates through an aperture */ -class Aperture: public OrbitUtils::CppPyWrapper +class Aperture { public: diff --git a/src/orbit/Apertures/EnergyAperture.cc b/src/orbit/Apertures/EnergyAperture.cc index 8f7c1331..cba9f8fa 100644 --- a/src/orbit/Apertures/EnergyAperture.cc +++ b/src/orbit/Apertures/EnergyAperture.cc @@ -33,7 +33,7 @@ /** The EnergyAperture class constructor. */ -EnergyAperture::EnergyAperture(): CppPyWrapper(NULL) +EnergyAperture::EnergyAperture() { minEnergy_ = -1.0e+36; maxEnergy_ = +1.0e+36; diff --git a/src/orbit/Apertures/EnergyAperture.hh b/src/orbit/Apertures/EnergyAperture.hh index b7a7b16f..5377de42 100644 --- a/src/orbit/Apertures/EnergyAperture.hh +++ b/src/orbit/Apertures/EnergyAperture.hh @@ -21,12 +21,11 @@ /////////////////////////////////////////////////////////////////////////// //pyORBIT utils -#include "utils/CppPyWrapper.hh" #include "orbit/Bunch.hh" using namespace std; -class EnergyAperture: public OrbitUtils::CppPyWrapper +class EnergyAperture { public: diff --git a/src/orbit/Apertures/PhaseAperture.cc b/src/orbit/Apertures/PhaseAperture.cc index a5811ee5..f822eaa4 100644 --- a/src/orbit/Apertures/PhaseAperture.cc +++ b/src/orbit/Apertures/PhaseAperture.cc @@ -35,7 +35,7 @@ The PhaseAperture class constructor. It needs the RF frequency in Hz to translate from z coordinate in meters to phase in degrees. */ -PhaseAperture::PhaseAperture(double frequency): CppPyWrapper(NULL) +PhaseAperture::PhaseAperture(double frequency) { frequency_ = frequency; minPhase_ = -1.0e+36; diff --git a/src/orbit/Apertures/PhaseAperture.hh b/src/orbit/Apertures/PhaseAperture.hh index 98570f5e..bcaf96f6 100644 --- a/src/orbit/Apertures/PhaseAperture.hh +++ b/src/orbit/Apertures/PhaseAperture.hh @@ -22,12 +22,11 @@ /////////////////////////////////////////////////////////////////////////// //pyORBIT utils -#include "utils/CppPyWrapper.hh" #include "orbit/Bunch.hh" using namespace std; -class PhaseAperture: public OrbitUtils::CppPyWrapper +class PhaseAperture { public: diff --git a/src/orbit/Apertures/wrap_EnergyAperture.cc b/src/orbit/Apertures/wrap_EnergyAperture.cc index d1dfc47f..0a82f792 100644 --- a/src/orbit/Apertures/wrap_EnergyAperture.cc +++ b/src/orbit/Apertures/wrap_EnergyAperture.cc @@ -28,7 +28,6 @@ extern "C" { /** This is implementation of the __init__ method */ static int EnergyAperture_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ self->cpp_obj = new EnergyAperture(); - ((EnergyAperture*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } diff --git a/src/orbit/Apertures/wrap_PhaseAperture.cc b/src/orbit/Apertures/wrap_PhaseAperture.cc index 51172fee..12c71366 100644 --- a/src/orbit/Apertures/wrap_PhaseAperture.cc +++ b/src/orbit/Apertures/wrap_PhaseAperture.cc @@ -35,7 +35,6 @@ extern "C" { ORBIT_MPI_Finalize("PhaseAperture class constructor - cannot parse arguments! It should be (frequency)"); } self->cpp_obj = new PhaseAperture(frequency); - ((PhaseAperture*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } diff --git a/src/orbit/Apertures/wrap_TAperture.cc b/src/orbit/Apertures/wrap_TAperture.cc index 473aaa40..bd02719f 100644 --- a/src/orbit/Apertures/wrap_TAperture.cc +++ b/src/orbit/Apertures/wrap_TAperture.cc @@ -40,7 +40,6 @@ extern "C" { ORBIT_MPI_Finalize("Aperture class constructor - cannot parse arguments! It should be (shape,a,b,c,d,pos)"); } self->cpp_obj = new Aperture(shape,a,b,c,d,pos); - ((Aperture*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } From 483da48c8ab8b0f1f7af5305f09414a122120b03 Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 11 Sep 2026 15:13:16 -0400 Subject: [PATCH 20/33] refactor(spacecharge): make grid ownership explicit --- src/linac/rfgap/SuperFishFieldSource.cc | 36 +++------- src/linac/rfgap/SuperFishFieldSource.hh | 9 +-- src/linac/rfgap/wrap_SuperFishFieldSource.cc | 43 +++++++----- src/orbit/Impedances/LImpedance.cc | 10 +-- src/orbit/Impedances/LImpedance.hh | 3 +- src/orbit/Impedances/TImpedance.cc | 11 +--- src/orbit/Impedances/TImpedance.hh | 3 +- src/spacecharge/Grid1D.cc | 6 +- src/spacecharge/Grid1D.hh | 5 +- src/spacecharge/Grid2D.cc | 4 +- src/spacecharge/Grid2D.hh | 5 +- src/spacecharge/Grid3D.cc | 2 +- src/spacecharge/Grid3D.hh | 5 +- src/spacecharge/LSpaceChargeCalc.cc | 7 +- src/spacecharge/LSpaceChargeCalc.hh | 3 +- src/spacecharge/SpaceChargeCalc2p5D.cc | 37 ++++------- src/spacecharge/SpaceChargeCalc2p5D.hh | 7 +- src/spacecharge/SpaceChargeCalc2p5Drb.cc | 46 ++++--------- src/spacecharge/SpaceChargeCalc2p5Drb.hh | 9 +-- src/spacecharge/SpaceChargeCalc3D.cc | 20 ++---- src/spacecharge/SpaceChargeCalc3D.hh | 5 +- .../SpaceChargeCalcSliceBySlice2D.cc | 22 ++----- .../SpaceChargeCalcSliceBySlice2D.hh | 5 +- src/spacecharge/SpaceChargeForceCalc2p5D.cc | 38 +++-------- src/spacecharge/SpaceChargeForceCalc2p5D.hh | 11 ++-- src/spacecharge/wrap_grid.hh | 13 ++++ src/spacecharge/wrap_grid1D.cc | 39 +++++++++-- src/spacecharge/wrap_grid1D.hh | 3 + src/spacecharge/wrap_grid2D.cc | 39 +++++++++-- src/spacecharge/wrap_grid2D.hh | 3 + src/spacecharge/wrap_grid3D.cc | 39 +++++++++-- src/spacecharge/wrap_grid3D.hh | 3 + src/spacecharge/wrap_spacechargecalc2p5d.cc | 50 ++------------ .../wrap_spacechargecalc2p5d_rb.cc | 66 ++----------------- src/spacecharge/wrap_spacechargecalc3d.cc | 33 +--------- .../wrap_spacechargecalc_slicebyslice_2D.cc | 33 +--------- .../wrap_spacechargeforcecalc2p5d.cc | 66 ++----------------- .../field_sources/MagnetFieldSourceGrid3D.cc | 22 ------- .../field_sources/MagnetFieldSourceGrid3D.hh | 2 +- .../wrap_magnetic_field_source_grid3d.cc | 35 ++++++---- 40 files changed, 288 insertions(+), 510 deletions(-) create mode 100644 src/spacecharge/wrap_grid.hh diff --git a/src/linac/rfgap/SuperFishFieldSource.cc b/src/linac/rfgap/SuperFishFieldSource.cc index cce7e1a9..50c92471 100644 --- a/src/linac/rfgap/SuperFishFieldSource.cc +++ b/src/linac/rfgap/SuperFishFieldSource.cc @@ -24,9 +24,12 @@ SuperFishFieldSource::SuperFishFieldSource(): BaseFieldSource() amplitude = 0.; time_init = 0.; field_center_pos = 0.; - grid2D_Ez = new Grid2D(3,3); - grid2D_Er = new Grid2D(3,3); - grid2D_H = new Grid2D(3,3); + ownedGrid2D_Ez.reset(new Grid2D(3,3)); + ownedGrid2D_Er.reset(new Grid2D(3,3)); + ownedGrid2D_H.reset(new Grid2D(3,3)); + grid2D_Ez = ownedGrid2D_Ez.get(); + grid2D_Er = ownedGrid2D_Er.get(); + grid2D_H = ownedGrid2D_H.get(); avg_ez_field = 0.; @@ -35,36 +38,15 @@ SuperFishFieldSource::SuperFishFieldSource(): BaseFieldSource() // Destructor SuperFishFieldSource::~SuperFishFieldSource() { - deleteGrids(); -} - -/** Delete all Grid2D grids. */ -void SuperFishFieldSource::deleteGrids() -{ - if(grid2D_Ez->getPyWrapper() != NULL){ - Py_XDECREF(grid2D_Ez->getPyWrapper()); - } else { - delete grid2D_Ez; - } - - if(grid2D_Er->getPyWrapper() != NULL){ - Py_XDECREF(grid2D_Er->getPyWrapper()); - } else { - delete grid2D_Er; - } - - if(grid2D_H->getPyWrapper() != NULL){ - Py_XDECREF(grid2D_H->getPyWrapper()); - } else { - delete grid2D_H; - } } /** Sets the Ez, Er, and H fields. */ void SuperFishFieldSource::setGrid2D_Fields(Grid2D* grid2D_Ez_in,Grid2D* grid2D_Er_in,Grid2D* grid2D_H_in) { - deleteGrids(); + ownedGrid2D_Ez.reset(); + ownedGrid2D_Er.reset(); + ownedGrid2D_H.reset(); grid2D_Ez = grid2D_Ez_in; grid2D_Er = grid2D_Er_in; grid2D_H = grid2D_H_in; diff --git a/src/linac/rfgap/SuperFishFieldSource.hh b/src/linac/rfgap/SuperFishFieldSource.hh index c8052ea0..0a782cf5 100644 --- a/src/linac/rfgap/SuperFishFieldSource.hh +++ b/src/linac/rfgap/SuperFishFieldSource.hh @@ -13,6 +13,7 @@ #include #include +#include using namespace std; @@ -93,13 +94,13 @@ public: /** Returns the Grid2D instance with H field. */ Grid2D* getGrid2D_H(); - /** Sets the Ez, Er, and H fields. */ + /** Sets borrowed Ez, Er, and H fields. The caller retains ownership. */ void setGrid2D_Fields(Grid2D* grid2D_Ez_in,Grid2D* grid2D_Er_in,Grid2D* grid2D_H_in); private: - - /** Delete all Grid2D grids. */ - void deleteGrids(); + std::unique_ptr ownedGrid2D_Ez; + std::unique_ptr ownedGrid2D_Er; + std::unique_ptr ownedGrid2D_H; //grids 2D for Ez, Er, and H Grid2D* grid2D_Ez; diff --git a/src/linac/rfgap/wrap_SuperFishFieldSource.cc b/src/linac/rfgap/wrap_SuperFishFieldSource.cc index f6216131..bfa5551b 100644 --- a/src/linac/rfgap/wrap_SuperFishFieldSource.cc +++ b/src/linac/rfgap/wrap_SuperFishFieldSource.cc @@ -14,6 +14,12 @@ using namespace OrbitUtils; namespace wrap_linac{ + typedef struct { + PyObject_HEAD + void* cpp_obj; + PyObject* grids[3]; + } pyORBIT_SuperFishFieldSource; + #ifdef __cplusplus extern "C" { #endif @@ -26,16 +32,19 @@ extern "C" { //It never will be called directly static PyObject* SuperFishFieldSource_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - pyORBIT_Object* self; - self = (pyORBIT_Object *) type->tp_alloc(type, 0); + pyORBIT_SuperFishFieldSource* self; + self = (pyORBIT_SuperFishFieldSource *) type->tp_alloc(type, 0); self->cpp_obj = NULL; + self->grids[0] = NULL; + self->grids[1] = NULL; + self->grids[2] = NULL; //std::cerr<<"The SuperFishFieldSource new has been called!"<cpp_obj = new SuperFishFieldSource(); ((SuperFishFieldSource*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; @@ -55,7 +64,7 @@ extern "C" { //setGrid2D_Fields(grid2D_Ez,grid2D_Er,grid2D_H) - sets the Grid2D instances with Ez, Er, H fields. static PyObject* SuperFishFieldSource_setGrid2D_Fields(PyObject *self, PyObject *args){ - pyORBIT_Object* pySuperFishFieldSource = (pyORBIT_Object*) self; + pyORBIT_SuperFishFieldSource* pySuperFishFieldSource = (pyORBIT_SuperFishFieldSource*) self; SuperFishFieldSource* cpp_SuperFishFieldSource = (SuperFishFieldSource*) pySuperFishFieldSource->cpp_obj; PyObject* pyGrid2D_Ez; PyObject* pyGrid2D_Er; @@ -76,25 +85,24 @@ extern "C" { Py_INCREF(pyGrid2D_Ez); Py_INCREF(pyGrid2D_Er); Py_INCREF(pyGrid2D_H); + Py_XDECREF(pySuperFishFieldSource->grids[0]); + Py_XDECREF(pySuperFishFieldSource->grids[1]); + Py_XDECREF(pySuperFishFieldSource->grids[2]); + pySuperFishFieldSource->grids[0] = pyGrid2D_Ez; + pySuperFishFieldSource->grids[1] = pyGrid2D_Er; + pySuperFishFieldSource->grids[2] = pyGrid2D_H; Py_INCREF(Py_None); return Py_None; } //getGrid2D_Fields returns the Grid2D instances with Ez, Er, H fields. static PyObject* SuperFishFieldSource_getGrid2D_Fields(PyObject *self, PyObject *args){ - pyORBIT_Object* pySuperFishFieldSource = (pyORBIT_Object*) self; - SuperFishFieldSource* cpp_SuperFishFieldSource = (SuperFishFieldSource*) pySuperFishFieldSource->cpp_obj; - Grid2D* grid2d_Ez = cpp_SuperFishFieldSource->getGrid2D_Ez(); - Grid2D* grid2d_Er = cpp_SuperFishFieldSource->getGrid2D_Er(); - Grid2D* grid2d_H = cpp_SuperFishFieldSource->getGrid2D_H(); - PyObject* pyGrid2D_Ez = (PyObject*) grid2d_Ez->getPyWrapper(); - PyObject* pyGrid2D_Er = (PyObject*) grid2d_Er->getPyWrapper(); - PyObject* pyGrid2D_H = (PyObject*) grid2d_H->getPyWrapper(); - if(pyGrid2D_Ez == NULL || pyGrid2D_Er == NULL || pyGrid2D_H == NULL){ + pyORBIT_SuperFishFieldSource* source = (pyORBIT_SuperFishFieldSource*) self; + if(source->grids[0] == NULL || source->grids[1] == NULL || source->grids[2] == NULL){ Py_INCREF(Py_None); return Py_None; } - return Py_BuildValue("(OOO)",pyGrid2D_Ez,pyGrid2D_Er,pyGrid2D_H); + return Py_BuildValue("(OOO)", source->grids[0], source->grids[1], source->grids[2]); } //setFrequency(frequency) sets the RF frequency. @@ -254,10 +262,13 @@ extern "C" { //----------------------------------------------------- //destructor for python SuperFishFieldSource class (__del__ method). //----------------------------------------------------- - static void SuperFishFieldSource_del(pyORBIT_Object* self){ + static void SuperFishFieldSource_del(pyORBIT_SuperFishFieldSource* self){ //std::cerr<<"The SuperFishFieldSource __del__ has been called!"<cpp_obj; delete cpp_SuperFishFieldSource; + Py_CLEAR(self->grids[0]); + Py_CLEAR(self->grids[1]); + Py_CLEAR(self->grids[2]); self->ob_base.ob_type->tp_free((PyObject*)self); } @@ -296,7 +307,7 @@ extern "C" { static PyTypeObject pyORBIT_SuperFishFieldSource_Type = { PyVarObject_HEAD_INIT(NULL, 0) "SuperFishFieldSource", /*tp_name*/ - sizeof(pyORBIT_Object), /*tp_basicsize*/ + sizeof(pyORBIT_SuperFishFieldSource), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor) SuperFishFieldSource_del , /*tp_dealloc*/ 0, /*tp_print*/ diff --git a/src/orbit/Impedances/LImpedance.cc b/src/orbit/Impedances/LImpedance.cc index abad93c8..e4576d4f 100644 --- a/src/orbit/Impedances/LImpedance.cc +++ b/src/orbit/Impedances/LImpedance.cc @@ -34,7 +34,7 @@ LImpedance::LImpedance(double length, _length = length; _nMacrosMin = nMacrosMin; _nBins = nBins; - zGrid = new Grid1D(_nBins, _length); + zGrid.reset(new Grid1D(_nBins, _length)); _fftmagnitude = new double[_nBins / 2]; _fftphase = new double[_nBins / 2]; @@ -64,14 +64,6 @@ LImpedance::LImpedance(double length, LImpedance::~LImpedance() { - if(zGrid->getPyWrapper() != NULL) - { - Py_DECREF(zGrid->getPyWrapper()); - } - else - { - delete zGrid; - } delete[] _fftmagnitude; delete[] _fftphase; delete[] _z; diff --git a/src/orbit/Impedances/LImpedance.hh b/src/orbit/Impedances/LImpedance.hh index a722647a..d5f52faa 100644 --- a/src/orbit/Impedances/LImpedance.hh +++ b/src/orbit/Impedances/LImpedance.hh @@ -8,6 +8,7 @@ #include #include +#include #include //ORBIT bunch @@ -50,7 +51,7 @@ public: int _nBins; //protected: - Grid1D* zGrid; + std::unique_ptr zGrid; OrbitUtils::BunchExtremaCalculator* bunchExtremaCalc; //FFT arrays diff --git a/src/orbit/Impedances/TImpedance.cc b/src/orbit/Impedances/TImpedance.cc index b60d5946..e7821b40 100644 --- a/src/orbit/Impedances/TImpedance.cc +++ b/src/orbit/Impedances/TImpedance.cc @@ -37,7 +37,7 @@ TImpedance::TImpedance(double length, _nBins = nBins; _useX = useX; _useY = useY; - zGrid = new Grid1D(_nBins, _length); + zGrid.reset(new Grid1D(_nBins, _length)); _qX = 0.0; _qY = 0.0; @@ -97,15 +97,6 @@ TImpedance::TImpedance(double length, TImpedance::~TImpedance() { - if(zGrid->getPyWrapper() != NULL) - { - Py_DECREF(zGrid->getPyWrapper()); - } - else - { - delete zGrid; - } - delete[] _xCentroid; delete[] _xpCentroid; delete[] _zXImped_nplus; diff --git a/src/orbit/Impedances/TImpedance.hh b/src/orbit/Impedances/TImpedance.hh index 37f596d6..e5750d11 100644 --- a/src/orbit/Impedances/TImpedance.hh +++ b/src/orbit/Impedances/TImpedance.hh @@ -8,6 +8,7 @@ #include #include +#include #include //ORBIT bunch @@ -80,7 +81,7 @@ public: double _betaY; double _charge2TKick; int _Turns; - Grid1D* zGrid; + std::unique_ptr zGrid; OrbitUtils::BunchExtremaCalculator* bunchExtremaCalc; double* _xCentroid; diff --git a/src/spacecharge/Grid1D.cc b/src/spacecharge/Grid1D.cc index 7c5d1494..b3db4416 100644 --- a/src/spacecharge/Grid1D.cc +++ b/src/spacecharge/Grid1D.cc @@ -27,7 +27,7 @@ using namespace OrbitUtils; /** Constructor with grid size only */ -Grid1D::Grid1D(int zSize):CppPyWrapper(NULL) +Grid1D::Grid1D(int zSize) { zSize_ = zSize; zMin_ = -0.5; @@ -37,7 +37,7 @@ Grid1D::Grid1D(int zSize):CppPyWrapper(NULL) } /** Constructor with grid size and grid physical length */ -Grid1D::Grid1D(int zSize, double length):CppPyWrapper(NULL) +Grid1D::Grid1D(int zSize, double length) { zSize_ = zSize; zMin_ = 0.; @@ -47,7 +47,7 @@ Grid1D::Grid1D(int zSize, double length):CppPyWrapper(NULL) } /** Constructor with grid size and spatial limits */ -Grid1D::Grid1D(int zSize, double zMin, double zMax):CppPyWrapper(NULL) +Grid1D::Grid1D(int zSize, double zMin, double zMax) { zSize_ = zSize; zMin_ = zMin; diff --git a/src/spacecharge/Grid1D.hh b/src/spacecharge/Grid1D.hh index 9abab179..4374cc4e 100644 --- a/src/spacecharge/Grid1D.hh +++ b/src/spacecharge/Grid1D.hh @@ -10,13 +10,10 @@ // ORBIT bunch #include "orbit/Bunch.hh" -// pyORBIT utils -#include "utils/CppPyWrapper.hh" - using namespace std; -class Grid1D:public OrbitUtils::CppPyWrapper +class Grid1D { public: diff --git a/src/spacecharge/Grid2D.cc b/src/spacecharge/Grid2D.cc index a7b2c81a..fedd477a 100644 --- a/src/spacecharge/Grid2D.cc +++ b/src/spacecharge/Grid2D.cc @@ -9,7 +9,7 @@ using namespace OrbitUtils; // Constructor -Grid2D::Grid2D(int xSize, int ySize): CppPyWrapper(NULL) +Grid2D::Grid2D(int xSize, int ySize) { xSize_ = xSize; ySize_ = ySize; @@ -23,7 +23,7 @@ Grid2D::Grid2D(int xSize, int ySize): CppPyWrapper(NULL) Grid2D::Grid2D(int xSize, int ySize, double xMin, double xMax, - double yMin, double yMax): CppPyWrapper(NULL) + double yMin, double yMax) { xSize_ = xSize; ySize_ = ySize; diff --git a/src/spacecharge/Grid2D.hh b/src/spacecharge/Grid2D.hh index bad12e62..488e2f18 100644 --- a/src/spacecharge/Grid2D.hh +++ b/src/spacecharge/Grid2D.hh @@ -12,16 +12,13 @@ //ORBIT bunch #include "orbit/Bunch.hh" -//pyORBIT utils -#include "utils/CppPyWrapper.hh" - using namespace std; /** This class repersents a 2D rectangular grid. */ -class Grid2D: public OrbitUtils::CppPyWrapper +class Grid2D { public: diff --git a/src/spacecharge/Grid3D.cc b/src/spacecharge/Grid3D.cc index 6b971cec..d223e463 100644 --- a/src/spacecharge/Grid3D.cc +++ b/src/spacecharge/Grid3D.cc @@ -24,7 +24,7 @@ using namespace OrbitUtils; /** Constructor */ -Grid3D::Grid3D(int nX, int nY, int nZ): CppPyWrapper(NULL) +Grid3D::Grid3D(int nX, int nY, int nZ) { nX_ = nX; nY_ = nY; diff --git a/src/spacecharge/Grid3D.hh b/src/spacecharge/Grid3D.hh index 62707aca..41ec7966 100644 --- a/src/spacecharge/Grid3D.hh +++ b/src/spacecharge/Grid3D.hh @@ -22,15 +22,12 @@ //ORBIT bunch #include "orbit/Bunch.hh" -//pyORBIT utils -#include "utils/CppPyWrapper.hh" - #include "spacecharge/Grid2D.hh" #include #include -class Grid3D: public OrbitUtils::CppPyWrapper +class Grid3D { public: //-------------------------------------- diff --git a/src/spacecharge/LSpaceChargeCalc.cc b/src/spacecharge/LSpaceChargeCalc.cc index a8463666..d849f27a 100644 --- a/src/spacecharge/LSpaceChargeCalc.cc +++ b/src/spacecharge/LSpaceChargeCalc.cc @@ -31,7 +31,7 @@ LSpaceChargeCalc::LSpaceChargeCalc(double b_a_in, double length_in, int nMacrosM nMacrosMin = nMacrosMin_in; useSpaceCharge = useSpaceCharge_in; nBins = nBins_in; - zGrid = new Grid1D(nBins, length); + zGrid.reset(new Grid1D(nBins, length)); nModes = nBins / 2; useGrad = 0; @@ -62,11 +62,6 @@ LSpaceChargeCalc::LSpaceChargeCalc(double b_a_in, double length_in, int nMacrosM } LSpaceChargeCalc::~LSpaceChargeCalc() { - if (zGrid->getPyWrapper() != NULL) { - Py_DECREF(zGrid->getPyWrapper()); - } else { - delete zGrid; - } delete[] _fftmagnitude; delete[] _fftphase; delete[] _z; diff --git a/src/spacecharge/LSpaceChargeCalc.hh b/src/spacecharge/LSpaceChargeCalc.hh index 03968ef3..cfb07cd1 100644 --- a/src/spacecharge/LSpaceChargeCalc.hh +++ b/src/spacecharge/LSpaceChargeCalc.hh @@ -8,6 +8,7 @@ #include #include +#include #include //ORBIT bunch @@ -62,7 +63,7 @@ public: int smooth; //protected: - Grid1D* zGrid; + std::unique_ptr zGrid; OrbitUtils::BunchExtremaCalculator* bunchExtremaCalc; //FFT arrays diff --git a/src/spacecharge/SpaceChargeCalc2p5D.cc b/src/spacecharge/SpaceChargeCalc2p5D.cc index e3b13090..3f457178 100644 --- a/src/spacecharge/SpaceChargeCalc2p5D.cc +++ b/src/spacecharge/SpaceChargeCalc2p5D.cc @@ -26,9 +26,9 @@ SpaceChargeCalc2p5D::SpaceChargeCalc2p5D(int xSize, int ySize, int zSize, double { xy_ratio = xy_ratio_in; poissonSolver = new PoissonSolverFFT2D(xSize, ySize, -xy_ratio, xy_ratio, -1.0, 1.0); - rhoGrid = new Grid2D(xSize, ySize); - phiGrid = new Grid2D(xSize, ySize); - zGrid = new Grid1D(zSize); + rhoGrid.reset(new Grid2D(xSize, ySize)); + phiGrid.reset(new Grid2D(xSize, ySize)); + zGrid.reset(new Grid1D(zSize)); bunchExtremaCalc = new BunchExtremaCalculator(); } @@ -36,42 +36,27 @@ SpaceChargeCalc2p5D::SpaceChargeCalc2p5D(int xSize, int ySize, int zSize) { xy_ratio = 1.0; poissonSolver = new PoissonSolverFFT2D(xSize, ySize, -xy_ratio, xy_ratio, -1.0, 1.0); - rhoGrid = new Grid2D(xSize, ySize); - phiGrid = new Grid2D(xSize, ySize); - zGrid = new Grid1D(zSize); + rhoGrid.reset(new Grid2D(xSize, ySize)); + phiGrid.reset(new Grid2D(xSize, ySize)); + zGrid.reset(new Grid1D(zSize)); bunchExtremaCalc = new BunchExtremaCalculator(); } SpaceChargeCalc2p5D::~SpaceChargeCalc2p5D(){ delete poissonSolver; - if(rhoGrid->getPyWrapper() != NULL){ - Py_DECREF(rhoGrid->getPyWrapper()); - } else { - delete rhoGrid; - } - if(phiGrid->getPyWrapper() != NULL){ - Py_DECREF(phiGrid->getPyWrapper()); - } else { - delete phiGrid; - } - if(zGrid->getPyWrapper() != NULL){ - Py_DECREF(zGrid->getPyWrapper()); - } else { - delete zGrid; - } delete bunchExtremaCalc; } Grid2D* SpaceChargeCalc2p5D::getRhoGrid(){ - return rhoGrid; + return rhoGrid.get(); } Grid2D* SpaceChargeCalc2p5D::getPhiGrid(){ - return phiGrid; + return phiGrid.get(); } Grid1D* SpaceChargeCalc2p5D::getLongGrid(){ - return zGrid; + return zGrid.get(); } void SpaceChargeCalc2p5D::trackBunch(Bunch* bunch, double length, BaseBoundary2D* boundary){ @@ -85,11 +70,11 @@ void SpaceChargeCalc2p5D::trackBunch(Bunch* bunch, double length, BaseBoundary2D double z_step = zGrid->getStepZ(); //calculate phiGrid - poissonSolver->findPotential(rhoGrid,phiGrid); + poissonSolver->findPotential(rhoGrid.get(),phiGrid.get()); if(boundary != NULL){ //update potential with boundary condition - boundary->addBoundaryPotential(rhoGrid,phiGrid); + boundary->addBoundaryPotential(rhoGrid.get(),phiGrid.get()); //std::cerr<<"Boundary ADDED."< #include +#include //ORBIT bunch #include "orbit/Bunch.hh" @@ -53,9 +54,9 @@ private: protected: PoissonSolverFFT2D* poissonSolver; - Grid2D* rhoGrid; - Grid2D* phiGrid; - Grid1D* zGrid; + std::unique_ptr rhoGrid; + std::unique_ptr phiGrid; + std::unique_ptr zGrid; OrbitUtils::BunchExtremaCalculator* bunchExtremaCalc; double xy_ratio; diff --git a/src/spacecharge/SpaceChargeCalc2p5Drb.cc b/src/spacecharge/SpaceChargeCalc2p5Drb.cc index fc9a2e45..c8aa5a75 100644 --- a/src/spacecharge/SpaceChargeCalc2p5Drb.cc +++ b/src/spacecharge/SpaceChargeCalc2p5Drb.cc @@ -32,10 +32,10 @@ SpaceChargeCalc2p5Drb::SpaceChargeCalc2p5Drb(int xSize, int ySize, int zSize, do { xy_ratio = xy_ratio_in; poissonSolver = new PoissonSolverFFT2D(xSize, ySize, -xy_ratio, xy_ratio, -1.0, 1.0); - rhoGrid = new Grid2D(xSize, ySize); - phiGrid = new Grid2D(xSize, ySize); - zGrid = new Grid1D(zSize); - zDerivGrid = new Grid1D(zSize); + rhoGrid.reset(new Grid2D(xSize, ySize)); + phiGrid.reset(new Grid2D(xSize, ySize)); + zGrid.reset(new Grid1D(zSize)); + zDerivGrid.reset(new Grid1D(zSize)); bunchExtremaCalc = new BunchExtremaCalculator(); //we will use 3 points by default to calculate the longitudinal density derivative n_long_avg = 3; @@ -49,10 +49,10 @@ SpaceChargeCalc2p5Drb::SpaceChargeCalc2p5Drb(int xSize, int ySize, int zSize) { xy_ratio = 1.0; poissonSolver = new PoissonSolverFFT2D(xSize, ySize, -xy_ratio, xy_ratio, -1.0, 1.0); - rhoGrid = new Grid2D(xSize, ySize); - phiGrid = new Grid2D(xSize, ySize); - zGrid = new Grid1D(zSize); - zDerivGrid = new Grid1D(zSize); + rhoGrid.reset(new Grid2D(xSize, ySize)); + phiGrid.reset(new Grid2D(xSize, ySize)); + zGrid.reset(new Grid1D(zSize)); + zDerivGrid.reset(new Grid1D(zSize)); bunchExtremaCalc = new BunchExtremaCalculator(); //we will use 3 points by default to calculate the longitudinal density derivative n_long_avg = 3; @@ -64,26 +64,6 @@ SpaceChargeCalc2p5Drb::SpaceChargeCalc2p5Drb(int xSize, int ySize, int zSize) SpaceChargeCalc2p5Drb::~SpaceChargeCalc2p5Drb(){ delete poissonSolver; - if(rhoGrid->getPyWrapper() != NULL){ - Py_DECREF(rhoGrid->getPyWrapper()); - } else { - delete rhoGrid; - } - if(phiGrid->getPyWrapper() != NULL){ - Py_DECREF(phiGrid->getPyWrapper()); - } else { - delete phiGrid; - } - if(zGrid->getPyWrapper() != NULL){ - Py_DECREF(zGrid->getPyWrapper()); - } else { - delete zGrid; - } - if(zDerivGrid->getPyWrapper() != NULL){ - Py_DECREF(zDerivGrid->getPyWrapper()); - } else { - delete zDerivGrid; - } delete bunchExtremaCalc; for(int i = 0; i < 5; i++){ delete [] S_arr[i]; @@ -92,19 +72,19 @@ SpaceChargeCalc2p5Drb::~SpaceChargeCalc2p5Drb(){ } Grid2D* SpaceChargeCalc2p5Drb::getRhoGrid(){ - return rhoGrid; + return rhoGrid.get(); } Grid2D* SpaceChargeCalc2p5Drb::getPhiGrid(){ - return phiGrid; + return phiGrid.get(); } Grid1D* SpaceChargeCalc2p5Drb::getLongGrid(){ - return zGrid; + return zGrid.get(); } Grid1D* SpaceChargeCalc2p5Drb::getLongDerivativeGrid(){ - return zDerivGrid; + return zDerivGrid.get(); } void SpaceChargeCalc2p5Drb::trackBunch(Bunch* bunch, double length, double pipe_radius){ @@ -122,7 +102,7 @@ void SpaceChargeCalc2p5Drb::trackBunch(Bunch* bunch, double length, double pipe_ double z_step = zGrid->getStepZ(); //calculate phiGrid - poissonSolver->findPotential(rhoGrid,phiGrid); + poissonSolver->findPotential(rhoGrid.get(),phiGrid.get()); SyncPart* syncPart = bunch->getSyncPart(); double factor = 2*length*bunch->getClassicalRadius()/(pow(syncPart->getBeta(),2)*pow(syncPart->getGamma(),3)); diff --git a/src/spacecharge/SpaceChargeCalc2p5Drb.hh b/src/spacecharge/SpaceChargeCalc2p5Drb.hh index eb82b7b2..1867e568 100644 --- a/src/spacecharge/SpaceChargeCalc2p5Drb.hh +++ b/src/spacecharge/SpaceChargeCalc2p5Drb.hh @@ -12,6 +12,7 @@ #include #include +#include //ORBIT bunch #include "orbit/Bunch.hh" @@ -70,10 +71,10 @@ private: protected: PoissonSolverFFT2D* poissonSolver; - Grid2D* rhoGrid; - Grid2D* phiGrid; - Grid1D* zGrid; - Grid1D* zDerivGrid; + std::unique_ptr rhoGrid; + std::unique_ptr phiGrid; + std::unique_ptr zGrid; + std::unique_ptr zDerivGrid; OrbitUtils::BunchExtremaCalculator* bunchExtremaCalc; double xy_ratio; diff --git a/src/spacecharge/SpaceChargeCalc3D.cc b/src/spacecharge/SpaceChargeCalc3D.cc index 7410355a..18fac0e3 100644 --- a/src/spacecharge/SpaceChargeCalc3D.cc +++ b/src/spacecharge/SpaceChargeCalc3D.cc @@ -35,11 +35,11 @@ SpaceChargeCalc3D::SpaceChargeCalc3D(int xSize, int ySize, int zSize) xy_ratio = 1.0; xz_ratio = 1.0; poissonSolver = new PoissonSolverFFT3D(xSize, ySize, zSize, -xy_ratio, xy_ratio, -1./xy_ratio, 1./xy_ratio, -1./xz_ratio, 1./xz_ratio); - rhoGrid = new Grid3D(xSize, ySize, zSize); + rhoGrid.reset(new Grid3D(xSize, ySize, zSize)); rhoGrid->setGridX(poissonSolver->getMinX(),poissonSolver->getMaxX()); rhoGrid->setGridY(poissonSolver->getMinY(),poissonSolver->getMaxY()); rhoGrid->setGridZ(poissonSolver->getMinZ(),poissonSolver->getMaxZ()); - phiGrid = new Grid3D(xSize, ySize, zSize); + phiGrid.reset(new Grid3D(xSize, ySize, zSize)); phiGrid->setGridX(poissonSolver->getMinX(),poissonSolver->getMaxX()); phiGrid->setGridY(poissonSolver->getMinY(),poissonSolver->getMaxY()); phiGrid->setGridZ(poissonSolver->getMinZ(),poissonSolver->getMaxZ()); @@ -60,25 +60,15 @@ SpaceChargeCalc3D::SpaceChargeCalc3D(int xSize, int ySize, int zSize) SpaceChargeCalc3D::~SpaceChargeCalc3D(){ delete poissonSolver; - if(rhoGrid->getPyWrapper() != NULL){ - Py_DECREF(rhoGrid->getPyWrapper()); - } else { - delete rhoGrid; - } - if(phiGrid->getPyWrapper() != NULL){ - Py_DECREF(phiGrid->getPyWrapper()); - } else { - delete phiGrid; - } delete bunchExtremaCalc; } Grid3D* SpaceChargeCalc3D::getRhoGrid(){ - return rhoGrid; + return rhoGrid.get(); } Grid3D* SpaceChargeCalc3D::getPhiGrid(){ - return phiGrid; + return phiGrid.get(); } void SpaceChargeCalc3D::setNumberOfExternalBunches(int nBunches){ @@ -113,7 +103,7 @@ void SpaceChargeCalc3D::trackBunch(Bunch* bunch, double length){ } //calculate phiGrid with potential. The z-coordinate is in the center of mass coordinate system - poissonSolver->findPotential(rhoGrid,phiGrid); + poissonSolver->findPotential(rhoGrid.get(),phiGrid.get()); SyncPart* syncPart = bunch->getSyncPart(); double gamma = syncPart->getGamma(); diff --git a/src/spacecharge/SpaceChargeCalc3D.hh b/src/spacecharge/SpaceChargeCalc3D.hh index 729b1d1f..3f70cc21 100644 --- a/src/spacecharge/SpaceChargeCalc3D.hh +++ b/src/spacecharge/SpaceChargeCalc3D.hh @@ -14,6 +14,7 @@ #include #include +#include //ORBIT bunch #include "orbit/Bunch.hh" @@ -73,8 +74,8 @@ private: protected: PoissonSolverFFT3D* poissonSolver; - Grid3D* rhoGrid; - Grid3D* phiGrid; + std::unique_ptr rhoGrid; + std::unique_ptr phiGrid; OrbitUtils::BunchExtremaCalculator* bunchExtremaCalc; double xy_ratio; diff --git a/src/spacecharge/SpaceChargeCalcSliceBySlice2D.cc b/src/spacecharge/SpaceChargeCalcSliceBySlice2D.cc index d5c2964c..3c7b7f03 100755 --- a/src/spacecharge/SpaceChargeCalcSliceBySlice2D.cc +++ b/src/spacecharge/SpaceChargeCalcSliceBySlice2D.cc @@ -26,8 +26,8 @@ SpaceChargeCalcSliceBySlice2D::SpaceChargeCalcSliceBySlice2D(int xSize, int ySiz xy_ratio = xy_ratio_in; useLongTracking = 0; poissonSolver = new PoissonSolverFFT2D(xSize, ySize, -xy_ratio, xy_ratio, -1.0, 1.0); - rhoGrid3D = new Grid3D(xSize, ySize, zSize); - phiGrid3D = new Grid3D(xSize, ySize, zSize); + rhoGrid3D.reset(new Grid3D(xSize, ySize, zSize)); + phiGrid3D.reset(new Grid3D(xSize, ySize, zSize)); bunchExtremaCalc = new BunchExtremaCalculator(); } @@ -36,23 +36,13 @@ SpaceChargeCalcSliceBySlice2D::SpaceChargeCalcSliceBySlice2D(int xSize, int ySiz xy_ratio = 1.0; useLongTracking = 0; poissonSolver = new PoissonSolverFFT2D(xSize, ySize, -xy_ratio, xy_ratio, -1.0, 1.0); - rhoGrid3D = new Grid3D(xSize, ySize, zSize); - phiGrid3D = new Grid3D(xSize, ySize, zSize); + rhoGrid3D.reset(new Grid3D(xSize, ySize, zSize)); + phiGrid3D.reset(new Grid3D(xSize, ySize, zSize)); bunchExtremaCalc = new BunchExtremaCalculator(); } SpaceChargeCalcSliceBySlice2D::~SpaceChargeCalcSliceBySlice2D(){ delete poissonSolver; - if(rhoGrid3D->getPyWrapper() != NULL){ - Py_DECREF(rhoGrid3D->getPyWrapper()); - } else { - delete rhoGrid3D; - } - if(phiGrid3D->getPyWrapper() != NULL){ - Py_DECREF(phiGrid3D->getPyWrapper()); - } else { - delete phiGrid3D; - } delete bunchExtremaCalc; } @@ -66,11 +56,11 @@ int SpaceChargeCalcSliceBySlice2D::getLongitudinalTracking() } Grid3D* SpaceChargeCalcSliceBySlice2D::getRhoGrid(){ - return rhoGrid3D; + return rhoGrid3D.get(); } Grid3D* SpaceChargeCalcSliceBySlice2D::getPhiGrid(){ - return phiGrid3D; + return phiGrid3D.get(); } diff --git a/src/spacecharge/SpaceChargeCalcSliceBySlice2D.hh b/src/spacecharge/SpaceChargeCalcSliceBySlice2D.hh index 1e76d030..3a7c5003 100755 --- a/src/spacecharge/SpaceChargeCalcSliceBySlice2D.hh +++ b/src/spacecharge/SpaceChargeCalcSliceBySlice2D.hh @@ -8,6 +8,7 @@ #include #include +#include //ORBIT bunch #include "orbit/Bunch.hh" @@ -60,8 +61,8 @@ private: protected: PoissonSolverFFT2D* poissonSolver; - Grid3D* rhoGrid3D; - Grid3D* phiGrid3D; + std::unique_ptr rhoGrid3D; + std::unique_ptr phiGrid3D; OrbitUtils::BunchExtremaCalculator* bunchExtremaCalc; double xy_ratio; diff --git a/src/spacecharge/SpaceChargeForceCalc2p5D.cc b/src/spacecharge/SpaceChargeForceCalc2p5D.cc index c3f167db..f1100f17 100644 --- a/src/spacecharge/SpaceChargeForceCalc2p5D.cc +++ b/src/spacecharge/SpaceChargeForceCalc2p5D.cc @@ -25,52 +25,32 @@ using namespace OrbitUtils; SpaceChargeForceCalc2p5D::SpaceChargeForceCalc2p5D(int xSize, int ySize, int zSize) { forceSolver = new ForceSolverFFT2D(xSize, ySize); - rhoGrid = new Grid2D(xSize, ySize); - forceGridX = new Grid2D(xSize, ySize); - forceGridY = new Grid2D(xSize, ySize); - zGrid = new Grid1D(zSize); + rhoGrid.reset(new Grid2D(xSize, ySize)); + forceGridX.reset(new Grid2D(xSize, ySize)); + forceGridY.reset(new Grid2D(xSize, ySize)); + zGrid.reset(new Grid1D(zSize)); bunchExtremaCalc = new BunchExtremaCalculator(); } SpaceChargeForceCalc2p5D::~SpaceChargeForceCalc2p5D(){ delete forceSolver; - if(rhoGrid->getPyWrapper() != NULL){ - Py_DECREF(rhoGrid->getPyWrapper()); - } else { - delete rhoGrid; - } - if(forceGridX->getPyWrapper() != NULL){ - Py_DECREF(forceGridX->getPyWrapper()); - } else { - delete forceGridX; - } - if(forceGridY->getPyWrapper() != NULL){ - Py_DECREF(forceGridY->getPyWrapper()); - } else { - delete forceGridY; - } - if(zGrid->getPyWrapper() != NULL){ - Py_DECREF(zGrid->getPyWrapper()); - } else { - delete zGrid; - } delete bunchExtremaCalc; } Grid2D* SpaceChargeForceCalc2p5D::getRhoGrid(){ - return rhoGrid; + return rhoGrid.get(); } Grid2D* SpaceChargeForceCalc2p5D::getForceGridX(){ - return forceGridX; + return forceGridX.get(); } Grid2D* SpaceChargeForceCalc2p5D::getForceGridY(){ - return forceGridY; + return forceGridY.get(); } Grid1D* SpaceChargeForceCalc2p5D::getLongGrid(){ - return zGrid; + return zGrid.get(); } void SpaceChargeForceCalc2p5D::trackBunch(Bunch* bunch, double length){ @@ -86,7 +66,7 @@ void SpaceChargeForceCalc2p5D::trackBunch(Bunch* bunch, double length){ double z_step = zGrid->getStepZ(); //calculate phiGrid - forceSolver->findForce(rhoGrid, forceGridX, forceGridY); + forceSolver->findForce(rhoGrid.get(), forceGridX.get(), forceGridY.get()); SyncPart* syncPart = bunch->getSyncPart(); double factor = 2*length*bunch->getClassicalRadius()/(pow(syncPart->getBeta(),2)*pow(syncPart->getGamma(),3)); diff --git a/src/spacecharge/SpaceChargeForceCalc2p5D.hh b/src/spacecharge/SpaceChargeForceCalc2p5D.hh index 4f744e15..b48c87f3 100644 --- a/src/spacecharge/SpaceChargeForceCalc2p5D.hh +++ b/src/spacecharge/SpaceChargeForceCalc2p5D.hh @@ -8,6 +8,7 @@ #include #include +#include //ORBIT bunch #include "orbit/Bunch.hh" @@ -55,11 +56,11 @@ private: protected: ForceSolverFFT2D* forceSolver; - Grid2D* rhoGrid; - Grid2D* phiGrid; - Grid2D* forceGridX; - Grid2D* forceGridY; - Grid1D* zGrid; + std::unique_ptr rhoGrid; + std::unique_ptr phiGrid; + std::unique_ptr forceGridX; + std::unique_ptr forceGridY; + std::unique_ptr zGrid; OrbitUtils::BunchExtremaCalculator* bunchExtremaCalc; }; diff --git a/src/spacecharge/wrap_grid.hh b/src/spacecharge/wrap_grid.hh new file mode 100644 index 00000000..d076dcfb --- /dev/null +++ b/src/spacecharge/wrap_grid.hh @@ -0,0 +1,13 @@ +#ifndef WRAP_SPACE_CHARGE_GRID_H +#define WRAP_SPACE_CHARGE_GRID_H + +#include + +typedef struct { + PyObject_HEAD + void* cpp_obj; + int owns_cpp; + PyObject* owner; +} pyORBIT_Grid; + +#endif diff --git a/src/spacecharge/wrap_grid1D.cc b/src/spacecharge/wrap_grid1D.cc index d48228a3..dd1bfa96 100644 --- a/src/spacecharge/wrap_grid1D.cc +++ b/src/spacecharge/wrap_grid1D.cc @@ -3,6 +3,7 @@ #include "main/pyORBIT_Object.hh" #include "spacecharge/wrap_grid1D.hh" +#include "spacecharge/wrap_grid.hh" #include "spacecharge/wrap_spacecharge.hh" #include "orbit/wrap_bunch.hh" #include "mpi/wrap_mpi_comm.hh" @@ -31,9 +32,11 @@ extern "C" static PyObject* Grid1D_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - pyORBIT_Object* self; - self = (pyORBIT_Object *) type->tp_alloc(type, 0); + pyORBIT_Grid* self; + self = (pyORBIT_Grid *) type->tp_alloc(type, 0); self->cpp_obj = NULL; + self->owns_cpp = 0; + self->owner = NULL; // std::cerr << "The Grid1D new has been called!" << std::endl; return (PyObject *) self; } @@ -42,7 +45,7 @@ static PyObject* Grid1D_new(PyTypeObject *type, PyObject *args, PyObject *kwds) // Initializator for python Grid1D class // This is implementation of the __init__ method -static int Grid1D_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds) +static int Grid1D_init(pyORBIT_Grid *self, PyObject *args, PyObject *kwds) { int nVars = PyTuple_Size(args); int binZ; @@ -62,7 +65,8 @@ static int Grid1D_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds) } self->cpp_obj = new Grid1D(binZ, zMin, zMax); } - ((Grid1D*) self->cpp_obj)->setPyWrapper((PyObject*) self); + self->owns_cpp = 1; + pyorbit::registerPyWrapper(self->cpp_obj, (PyObject*) self); // std::cerr << "The Grid1D __init__ has been called!" << std::endl; return 0; } @@ -457,11 +461,14 @@ static PyObject* Grid1D_synchronizeMPI(PyObject *self, PyObject *args) // Destructor for python Grid1D class (__del__ method). //----------------------------------------------------- -static void Grid1D_del(pyORBIT_Object* self) +static void Grid1D_del(pyORBIT_Grid* self) { //std::cerr << "The Grid1D __del__ has been called!" << std::endl; Grid1D* cpp_Grid1D = (Grid1D*) self->cpp_obj; - delete cpp_Grid1D; + pyorbit::unregisterPyWrapper(cpp_Grid1D, (PyObject*) self); + if(self->owns_cpp) delete cpp_Grid1D; + self->cpp_obj = NULL; + Py_CLEAR(self->owner); self->ob_base.ob_type->tp_free((PyObject*)self); } @@ -512,7 +519,7 @@ static PyTypeObject pyORBIT_Grid1D_Type = { PyVarObject_HEAD_INIT(NULL, 0) "Grid1D", /*tp_name*/ - sizeof(pyORBIT_Object), /*tp_basicsize*/ + sizeof(pyORBIT_Grid), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor) Grid1D_del , /*tp_dealloc*/ 0, /*tp_print*/ @@ -550,6 +557,24 @@ static PyTypeObject pyORBIT_Grid1D_Type = Grid1D_new, /* tp_new */ }; +PyObject* wrapGrid1D(Grid1D* grid, PyObject* owner) +{ + PyObject* wrapper = pyorbit::getPyWrapper(grid); + if(wrapper != NULL) { + Py_INCREF(wrapper); + return wrapper; + } + + pyORBIT_Grid* self = (pyORBIT_Grid*) pyORBIT_Grid1D_Type.tp_alloc(&pyORBIT_Grid1D_Type, 0); + if(self == NULL) return NULL; + self->cpp_obj = grid; + self->owns_cpp = 0; + self->owner = owner; + Py_XINCREF(owner); + pyorbit::registerPyWrapper(grid, (PyObject*) self); + return (PyObject*) self; +} + //-------------------------------------------------- // Initialization function of the pyGrid1D class diff --git a/src/spacecharge/wrap_grid1D.hh b/src/spacecharge/wrap_grid1D.hh index 4b111d1c..bbb2b9d4 100644 --- a/src/spacecharge/wrap_grid1D.hh +++ b/src/spacecharge/wrap_grid1D.hh @@ -3,6 +3,8 @@ #include +class Grid1D; + #ifdef __cplusplus extern "C" { @@ -11,6 +13,7 @@ extern "C" namespace wrap_spacecharge { void initGrid1D(PyObject* module); + PyObject* wrapGrid1D(Grid1D* grid, PyObject* owner); } #ifdef __cplusplus diff --git a/src/spacecharge/wrap_grid2D.cc b/src/spacecharge/wrap_grid2D.cc index d1621623..952680f6 100644 --- a/src/spacecharge/wrap_grid2D.cc +++ b/src/spacecharge/wrap_grid2D.cc @@ -3,6 +3,7 @@ #include "main/pyORBIT_Object.hh" #include "spacecharge/wrap_grid2D.hh" +#include "spacecharge/wrap_grid.hh" #include "spacecharge/wrap_spacecharge.hh" #include "orbit/wrap_bunch.hh" #include "mpi/wrap_mpi_comm.hh" @@ -27,23 +28,26 @@ extern "C" { //It never will be called directly static PyObject* Grid2D_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - pyORBIT_Object* self; - self = (pyORBIT_Object *) type->tp_alloc(type, 0); + pyORBIT_Grid* self; + self = (pyORBIT_Grid *) type->tp_alloc(type, 0); self->cpp_obj = NULL; + self->owns_cpp = 0; + self->owner = NULL; //std::cerr<<"The Grid2D new has been called!"<cpp_obj = new Grid2D(binX,binY,xMin,xMax,yMin,yMax); - ((Grid2D*) self->cpp_obj)->setPyWrapper((PyObject*) self); + self->owns_cpp = 1; + pyorbit::registerPyWrapper(self->cpp_obj, (PyObject*) self); //std::cerr<<"The Grid2D __init__ has been called!"<cpp_obj; - delete cpp_Grid2D; + pyorbit::unregisterPyWrapper(cpp_Grid2D, (PyObject*) self); + if(self->owns_cpp) delete cpp_Grid2D; + self->cpp_obj = NULL; + Py_CLEAR(self->owner); self->ob_base.ob_type->tp_free((PyObject*)self); } @@ -400,7 +407,7 @@ extern "C" { static PyTypeObject pyORBIT_Grid2D_Type = { PyVarObject_HEAD_INIT(NULL, 0) "Grid2D", /*tp_name*/ - sizeof(pyORBIT_Object), /*tp_basicsize*/ + sizeof(pyORBIT_Grid), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor) Grid2D_del , /*tp_dealloc*/ 0, /*tp_print*/ @@ -438,6 +445,24 @@ extern "C" { Grid2D_new, /* tp_new */ }; + PyObject* wrapGrid2D(Grid2D* grid, PyObject* owner) + { + PyObject* wrapper = pyorbit::getPyWrapper(grid); + if(wrapper != NULL) { + Py_INCREF(wrapper); + return wrapper; + } + + pyORBIT_Grid* self = (pyORBIT_Grid*) pyORBIT_Grid2D_Type.tp_alloc(&pyORBIT_Grid2D_Type, 0); + if(self == NULL) return NULL; + self->cpp_obj = grid; + self->owns_cpp = 0; + self->owner = owner; + Py_XINCREF(owner); + pyorbit::registerPyWrapper(grid, (PyObject*) self); + return (PyObject*) self; + } + //-------------------------------------------------- //Initialization function of the pyGrid2D class //It will be called from SpaceCharge wrapper initialization diff --git a/src/spacecharge/wrap_grid2D.hh b/src/spacecharge/wrap_grid2D.hh index 1cc4f599..becee2c4 100644 --- a/src/spacecharge/wrap_grid2D.hh +++ b/src/spacecharge/wrap_grid2D.hh @@ -3,12 +3,15 @@ #include +class Grid2D; + #ifdef __cplusplus extern "C" { #endif namespace wrap_spacecharge{ void initGrid2D(PyObject* module); + PyObject* wrapGrid2D(Grid2D* grid, PyObject* owner); } #ifdef __cplusplus diff --git a/src/spacecharge/wrap_grid3D.cc b/src/spacecharge/wrap_grid3D.cc index 9888f175..c82252cb 100644 --- a/src/spacecharge/wrap_grid3D.cc +++ b/src/spacecharge/wrap_grid3D.cc @@ -3,6 +3,7 @@ #include "main/pyORBIT_Object.hh" #include "spacecharge/wrap_grid3D.hh" +#include "spacecharge/wrap_grid.hh" #include "spacecharge/wrap_spacecharge.hh" #include "orbit/wrap_bunch.hh" #include "mpi/wrap_mpi_comm.hh" @@ -27,21 +28,24 @@ extern "C" { //It never will be called directly static PyObject* Grid3D_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - pyORBIT_Object* self; - self = (pyORBIT_Object *) type->tp_alloc(type, 0); + pyORBIT_Grid* self; + self = (pyORBIT_Grid *) type->tp_alloc(type, 0); self->cpp_obj = NULL; + self->owns_cpp = 0; + self->owner = NULL; return (PyObject *) self; } //initializator for python Grid3D class //this is implementation of the __init__ method - static int Grid3D_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ + static int Grid3D_init(pyORBIT_Grid *self, PyObject *args, PyObject *kwds){ int binX, binY, binZ; if(!PyArg_ParseTuple(args,"iii:__init__",&binX,&binY,&binZ)){ ORBIT_MPI_Finalize("PyGrid3D - Grid3D(nX,nY,nZ) - constructor needs parameters."); } self->cpp_obj = new Grid3D(binX,binY,binZ); - ((Grid3D*) self->cpp_obj)->setPyWrapper((PyObject*) self); + self->owns_cpp = 1; + pyorbit::registerPyWrapper(self->cpp_obj, (PyObject*) self); return 0; } @@ -313,10 +317,13 @@ extern "C" { //----------------------------------------------------- //destructor for python Grid3D class (__del__ method). //----------------------------------------------------- - static void Grid3D_del(pyORBIT_Object* self){ + static void Grid3D_del(pyORBIT_Grid* self){ //std::cerr<<"The Grid3D __del__ has been called!"<cpp_obj; - delete cpp_Grid3D; + pyorbit::unregisterPyWrapper(cpp_Grid3D, (PyObject*) self); + if(self->owns_cpp) delete cpp_Grid3D; + self->cpp_obj = NULL; + Py_CLEAR(self->owner); self->ob_base.ob_type->tp_free((PyObject*)self); } @@ -360,7 +367,7 @@ extern "C" { static PyTypeObject pyORBIT_Grid3D_Type = { PyVarObject_HEAD_INIT(NULL, 0) "Grid3D", /*tp_name*/ - sizeof(pyORBIT_Object), /*tp_basicsize*/ + sizeof(pyORBIT_Grid), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor) Grid3D_del , /*tp_dealloc*/ 0, /*tp_print*/ @@ -398,6 +405,24 @@ extern "C" { Grid3D_new, /* tp_new */ }; + PyObject* wrapGrid3D(Grid3D* grid, PyObject* owner) + { + PyObject* wrapper = pyorbit::getPyWrapper(grid); + if(wrapper != NULL) { + Py_INCREF(wrapper); + return wrapper; + } + + pyORBIT_Grid* self = (pyORBIT_Grid*) pyORBIT_Grid3D_Type.tp_alloc(&pyORBIT_Grid3D_Type, 0); + if(self == NULL) return NULL; + self->cpp_obj = grid; + self->owns_cpp = 0; + self->owner = owner; + Py_XINCREF(owner); + pyorbit::registerPyWrapper(grid, (PyObject*) self); + return (PyObject*) self; + } + //-------------------------------------------------- //Initialization function of the pyGrid3D class //It will be called from SpaceCharge wrapper initialization diff --git a/src/spacecharge/wrap_grid3D.hh b/src/spacecharge/wrap_grid3D.hh index be407e32..4883ef1a 100644 --- a/src/spacecharge/wrap_grid3D.hh +++ b/src/spacecharge/wrap_grid3D.hh @@ -3,12 +3,15 @@ #include +class Grid3D; + #ifdef __cplusplus extern "C" { #endif namespace wrap_spacecharge{ void initGrid3D(PyObject* module); + PyObject* wrapGrid3D(Grid3D* grid, PyObject* owner); } #ifdef __cplusplus diff --git a/src/spacecharge/wrap_spacechargecalc2p5d.cc b/src/spacecharge/wrap_spacechargecalc2p5d.cc index e1e14ba8..c5ff65ec 100644 --- a/src/spacecharge/wrap_spacechargecalc2p5d.cc +++ b/src/spacecharge/wrap_spacechargecalc2p5d.cc @@ -3,6 +3,8 @@ # #include "spacecharge/wrap_spacechargecalc2p5d.hh" #include "spacecharge/wrap_spacecharge.hh" +#include "spacecharge/wrap_grid1D.hh" +#include "spacecharge/wrap_grid2D.hh" #include "orbit/wrap_bunch.hh" #include @@ -54,63 +56,21 @@ extern "C" { static PyObject* SpaceChargeCalc2p5D_getRhoGrid(PyObject *self, PyObject *args){ pyORBIT_Object* pySpaceChargeCalc2p5D = (pyORBIT_Object*) self; SpaceChargeCalc2p5D* cpp_SpaceChargeCalc2p5D = (SpaceChargeCalc2p5D*) pySpaceChargeCalc2p5D->cpp_obj; - Grid2D* cpp_grid2d = cpp_SpaceChargeCalc2p5D->getRhoGrid(); - if(cpp_grid2d->getPyWrapper() != NULL){ - Py_INCREF(cpp_grid2d->getPyWrapper()); - return cpp_grid2d->getPyWrapper(); - } - //It will create a pyGrid2D object - PyObject* mod = PyImport_ImportModule("orbit.core.spacecharge"); - PyObject* pyGrid2D = PyObject_CallMethod(mod,const_cast("Grid2D"),const_cast("ii"),cpp_grid2d->getSizeX(),cpp_grid2d->getSizeY()); - //delete the c++ reference to the internal Grid2D inside pyGrid2D and assign the new one - delete ((Grid2D*)((pyORBIT_Object*) pyGrid2D)->cpp_obj); - ((pyORBIT_Object*) pyGrid2D)->cpp_obj = cpp_grid2d; - cpp_grid2d->setPyWrapper(pyGrid2D); - Py_INCREF(cpp_grid2d->getPyWrapper()); - Py_DECREF(mod); - return pyGrid2D; + return wrapGrid2D(cpp_SpaceChargeCalc2p5D->getRhoGrid(), self); } //Grid2D* getPhiGrid() returns the 2D grid with potential static PyObject* SpaceChargeCalc2p5D_getPhiGrid(PyObject *self, PyObject *args){ pyORBIT_Object* pySpaceChargeCalc2p5D = (pyORBIT_Object*) self; SpaceChargeCalc2p5D* cpp_SpaceChargeCalc2p5D = (SpaceChargeCalc2p5D*) pySpaceChargeCalc2p5D->cpp_obj; - Grid2D* cpp_grid2d = cpp_SpaceChargeCalc2p5D->getPhiGrid(); - if(cpp_grid2d->getPyWrapper() != NULL){ - Py_INCREF(cpp_grid2d->getPyWrapper()); - return cpp_grid2d->getPyWrapper(); - } - //It will create a pyGrid2D object - PyObject* mod = PyImport_ImportModule("orbit.core.spacecharge"); - PyObject* pyGrid2D = PyObject_CallMethod(mod,const_cast("Grid2D"),const_cast("ii"),cpp_grid2d->getSizeX(),cpp_grid2d->getSizeY()); - //delete the c++ reference to the internal Grid2D inside pyGrid2D and assign the new one - delete ((Grid2D*)((pyORBIT_Object*) pyGrid2D)->cpp_obj); - ((pyORBIT_Object*) pyGrid2D)->cpp_obj = cpp_grid2d; - cpp_grid2d->setPyWrapper(pyGrid2D); - Py_INCREF(cpp_grid2d->getPyWrapper()); - Py_DECREF(mod); - return pyGrid2D; + return wrapGrid2D(cpp_SpaceChargeCalc2p5D->getPhiGrid(), self); } //Grid1D* getLongGrid() returns the 1D grid with longitudinal density static PyObject* SpaceChargeCalc2p5D_getLongGrid(PyObject *self, PyObject *args){ pyORBIT_Object* pySpaceChargeCalc2p5D = (pyORBIT_Object*) self; SpaceChargeCalc2p5D* cpp_SpaceChargeCalc2p5D = (SpaceChargeCalc2p5D*) pySpaceChargeCalc2p5D->cpp_obj; - Grid1D* cpp_grid1d = cpp_SpaceChargeCalc2p5D->getLongGrid(); - if(cpp_grid1d->getPyWrapper() != NULL){ - Py_INCREF(cpp_grid1d->getPyWrapper()); - return cpp_grid1d->getPyWrapper(); - } - //It will create a pyGrid2D object - PyObject* mod = PyImport_ImportModule("orbit.core.spacecharge"); - PyObject* pyGrid1D = PyObject_CallMethod(mod,const_cast("Grid1D"),const_cast("i"),cpp_grid1d->getSizeZ()); - //delete the c++ reference to the internal Grid1D inside pyGrid1D and assign the new one - delete ((Grid1D*)((pyORBIT_Object*) pyGrid1D)->cpp_obj); - ((pyORBIT_Object*) pyGrid1D)->cpp_obj = cpp_grid1d; - cpp_grid1d->setPyWrapper(pyGrid1D); - Py_INCREF(cpp_grid1d->getPyWrapper()); - Py_DECREF(mod); - return pyGrid1D; + return wrapGrid1D(cpp_SpaceChargeCalc2p5D->getLongGrid(), self); } //trackBunch(Bunch* bunch, double length[,BaseBoundary2D* boundary]) diff --git a/src/spacecharge/wrap_spacechargecalc2p5d_rb.cc b/src/spacecharge/wrap_spacechargecalc2p5d_rb.cc index dad6902a..12bc3d6a 100644 --- a/src/spacecharge/wrap_spacechargecalc2p5d_rb.cc +++ b/src/spacecharge/wrap_spacechargecalc2p5d_rb.cc @@ -3,6 +3,8 @@ # #include "spacecharge/wrap_spacechargecalc2p5d_rb.hh" #include "spacecharge/wrap_spacecharge.hh" +#include "spacecharge/wrap_grid1D.hh" +#include "spacecharge/wrap_grid2D.hh" #include "orbit/wrap_bunch.hh" #include @@ -53,84 +55,28 @@ extern "C" { static PyObject* SpaceChargeCalc2p5Drb_getRhoGrid(PyObject *self, PyObject *args){ pyORBIT_Object* pySpaceChargeCalc2p5Drb = (pyORBIT_Object*) self; SpaceChargeCalc2p5Drb* cpp_SpaceChargeCalc2p5Drb = (SpaceChargeCalc2p5Drb*) pySpaceChargeCalc2p5Drb->cpp_obj; - Grid2D* cpp_grid2d = cpp_SpaceChargeCalc2p5Drb->getRhoGrid(); - if(cpp_grid2d->getPyWrapper() != NULL){ - Py_INCREF(cpp_grid2d->getPyWrapper()); - return cpp_grid2d->getPyWrapper(); - } - //It will create a pyGrid2D object - PyObject* mod = PyImport_ImportModule("orbit.core.spacecharge"); - PyObject* pyGrid2D = PyObject_CallMethod(mod,const_cast("Grid2D"),const_cast("ii"),cpp_grid2d->getSizeX(),cpp_grid2d->getSizeY()); - //delete the c++ reference to the internal Grid2D inside pyGrid2D and assign the new one - delete ((Grid2D*)((pyORBIT_Object*) pyGrid2D)->cpp_obj); - ((pyORBIT_Object*) pyGrid2D)->cpp_obj = cpp_grid2d; - cpp_grid2d->setPyWrapper(pyGrid2D); - Py_INCREF(cpp_grid2d->getPyWrapper()); - Py_DECREF(mod); - return pyGrid2D; + return wrapGrid2D(cpp_SpaceChargeCalc2p5Drb->getRhoGrid(), self); } //Grid2D* getPhiGrid() returns the 2D grid with potential static PyObject* SpaceChargeCalc2p5Drb_getPhiGrid(PyObject *self, PyObject *args){ pyORBIT_Object* pySpaceChargeCalc2p5Drb = (pyORBIT_Object*) self; SpaceChargeCalc2p5Drb* cpp_SpaceChargeCalc2p5Drb = (SpaceChargeCalc2p5Drb*) pySpaceChargeCalc2p5Drb->cpp_obj; - Grid2D* cpp_grid2d = cpp_SpaceChargeCalc2p5Drb->getPhiGrid(); - if(cpp_grid2d->getPyWrapper() != NULL){ - Py_INCREF(cpp_grid2d->getPyWrapper()); - return cpp_grid2d->getPyWrapper(); - } - //It will create a pyGrid2D object - PyObject* mod = PyImport_ImportModule("orbit.core.spacecharge"); - PyObject* pyGrid2D = PyObject_CallMethod(mod,const_cast("Grid2D"),const_cast("ii"),cpp_grid2d->getSizeX(),cpp_grid2d->getSizeY()); - //delete the c++ reference to the internal Grid2D inside pyGrid2D and assign the new one - delete ((Grid2D*)((pyORBIT_Object*) pyGrid2D)->cpp_obj); - ((pyORBIT_Object*) pyGrid2D)->cpp_obj = cpp_grid2d; - cpp_grid2d->setPyWrapper(pyGrid2D); - Py_INCREF(cpp_grid2d->getPyWrapper()); - Py_DECREF(mod); - return pyGrid2D; + return wrapGrid2D(cpp_SpaceChargeCalc2p5Drb->getPhiGrid(), self); } //Grid1D* getLongGrid() returns the 1D grid with longitudinal density static PyObject* SpaceChargeCalc2p5Drb_getLongGrid(PyObject *self, PyObject *args){ pyORBIT_Object* pySpaceChargeCalc2p5Drb = (pyORBIT_Object*) self; SpaceChargeCalc2p5Drb* cpp_SpaceChargeCalc2p5Drb = (SpaceChargeCalc2p5Drb*) pySpaceChargeCalc2p5Drb->cpp_obj; - Grid1D* cpp_grid1d = cpp_SpaceChargeCalc2p5Drb->getLongGrid(); - if(cpp_grid1d->getPyWrapper() != NULL){ - Py_INCREF(cpp_grid1d->getPyWrapper()); - return cpp_grid1d->getPyWrapper(); - } - //It will create a pyGrid2D object - PyObject* mod = PyImport_ImportModule("orbit.core.spacecharge"); - PyObject* pyGrid1D = PyObject_CallMethod(mod,const_cast("Grid1D"),const_cast("i"),cpp_grid1d->getSizeZ()); - //delete the c++ reference to the internal Grid1D inside pyGrid1D and assign the new one - delete ((Grid1D*)((pyORBIT_Object*) pyGrid1D)->cpp_obj); - ((pyORBIT_Object*) pyGrid1D)->cpp_obj = cpp_grid1d; - cpp_grid1d->setPyWrapper(pyGrid1D); - Py_INCREF(cpp_grid1d->getPyWrapper()); - Py_DECREF(mod); - return pyGrid1D; + return wrapGrid1D(cpp_SpaceChargeCalc2p5Drb->getLongGrid(), self); } //Grid1D* getLongDerivativeGrid() returns the 1D grid with the derivative of the longitudinal density static PyObject* SpaceChargeCalc2p5Drb_getLongDerivativeGrid(PyObject *self, PyObject *args){ pyORBIT_Object* pySpaceChargeCalc2p5Drb = (pyORBIT_Object*) self; SpaceChargeCalc2p5Drb* cpp_SpaceChargeCalc2p5Drb = (SpaceChargeCalc2p5Drb*) pySpaceChargeCalc2p5Drb->cpp_obj; - Grid1D* cpp_grid1d = cpp_SpaceChargeCalc2p5Drb->getLongDerivativeGrid(); - if(cpp_grid1d->getPyWrapper() != NULL){ - Py_INCREF(cpp_grid1d->getPyWrapper()); - return cpp_grid1d->getPyWrapper(); - } - //It will create a pyGrid2D object - PyObject* mod = PyImport_ImportModule("orbit.core.spacecharge"); - PyObject* pyGrid1D = PyObject_CallMethod(mod,const_cast("Grid1D"),const_cast("i"),cpp_grid1d->getSizeZ()); - //delete the c++ reference to the internal Grid1D inside pyGrid1D and assign the new one - delete ((Grid1D*)((pyORBIT_Object*) pyGrid1D)->cpp_obj); - ((pyORBIT_Object*) pyGrid1D)->cpp_obj = cpp_grid1d; - cpp_grid1d->setPyWrapper(pyGrid1D); - Py_INCREF(cpp_grid1d->getPyWrapper()); - Py_DECREF(mod); - return pyGrid1D; + return wrapGrid1D(cpp_SpaceChargeCalc2p5Drb->getLongDerivativeGrid(), self); } //trackBunch(Bunch* bunch, double length, double pipe_radius) diff --git a/src/spacecharge/wrap_spacechargecalc3d.cc b/src/spacecharge/wrap_spacechargecalc3d.cc index 46b30a70..026c3e45 100644 --- a/src/spacecharge/wrap_spacechargecalc3d.cc +++ b/src/spacecharge/wrap_spacechargecalc3d.cc @@ -3,6 +3,7 @@ # #include "spacecharge/wrap_spacechargecalc3d.hh" #include "spacecharge/wrap_spacecharge.hh" +#include "spacecharge/wrap_grid3D.hh" #include "orbit/wrap_bunch.hh" #include @@ -48,42 +49,14 @@ extern "C" { static PyObject* SpaceChargeCalc3D_getRhoGrid(PyObject *self, PyObject *args){ pyORBIT_Object* pySpaceChargeCalc3D = (pyORBIT_Object*) self; SpaceChargeCalc3D* cpp_SpaceChargeCalc3D = (SpaceChargeCalc3D*) pySpaceChargeCalc3D->cpp_obj; - Grid3D* cpp_grid3d = cpp_SpaceChargeCalc3D->getRhoGrid(); - if(cpp_grid3d->getPyWrapper() != NULL){ - Py_INCREF(cpp_grid3d->getPyWrapper()); - return cpp_grid3d->getPyWrapper(); - } - //It will create a pyGrid3D object - PyObject* mod = PyImport_ImportModule("orbit.core.spacecharge"); - PyObject* pyGrid3D = PyObject_CallMethod(mod,const_cast("Grid3D"),const_cast("iii"),cpp_grid3d->getSizeX(),cpp_grid3d->getSizeY(),cpp_grid3d->getSizeZ()); - //delete the c++ reference to the internal Grid3D inside pyGrid3D and assign the new one - delete ((Grid3D*)((pyORBIT_Object*) pyGrid3D)->cpp_obj); - ((pyORBIT_Object*) pyGrid3D)->cpp_obj = cpp_grid3d; - cpp_grid3d->setPyWrapper(pyGrid3D); - Py_INCREF(cpp_grid3d->getPyWrapper()); - Py_DECREF(mod); - return pyGrid3D; + return wrapGrid3D(cpp_SpaceChargeCalc3D->getRhoGrid(), self); } //Grid3D* getPhiGrid() returns the 3D grid with potential static PyObject* SpaceChargeCalc3D_getPhiGrid(PyObject *self, PyObject *args){ pyORBIT_Object* pySpaceChargeCalc3D = (pyORBIT_Object*) self; SpaceChargeCalc3D* cpp_SpaceChargeCalc3D = (SpaceChargeCalc3D*) pySpaceChargeCalc3D->cpp_obj; - Grid3D* cpp_grid3d = cpp_SpaceChargeCalc3D->getPhiGrid(); - if(cpp_grid3d->getPyWrapper() != NULL){ - Py_INCREF(cpp_grid3d->getPyWrapper()); - return cpp_grid3d->getPyWrapper(); - } - //It will create a pyGrid3D object - PyObject* mod = PyImport_ImportModule("orbit.core.spacecharge"); - PyObject* pyGrid3D = PyObject_CallMethod(mod,const_cast("Grid3D"),const_cast("iii"),cpp_grid3d->getSizeX(),cpp_grid3d->getSizeY(),cpp_grid3d->getSizeZ()); - //delete the c++ reference to the internal Grid3D inside pyGrid3D and assign the new one - delete ((Grid3D*)((pyORBIT_Object*) pyGrid3D)->cpp_obj); - ((pyORBIT_Object*) pyGrid3D)->cpp_obj = cpp_grid3d; - cpp_grid3d->setPyWrapper(pyGrid3D); - Py_INCREF(cpp_grid3d->getPyWrapper()); - Py_DECREF(mod); - return pyGrid3D; + return wrapGrid3D(cpp_SpaceChargeCalc3D->getPhiGrid(), self); } //trackBunch(Bunch* bunch, double length) diff --git a/src/spacecharge/wrap_spacechargecalc_slicebyslice_2D.cc b/src/spacecharge/wrap_spacechargecalc_slicebyslice_2D.cc index 01569c4f..89456476 100755 --- a/src/spacecharge/wrap_spacechargecalc_slicebyslice_2D.cc +++ b/src/spacecharge/wrap_spacechargecalc_slicebyslice_2D.cc @@ -3,6 +3,7 @@ # #include "spacecharge/wrap_spacechargecalc_slicebyslice_2D.hh" #include "spacecharge/wrap_spacecharge.hh" +#include "spacecharge/wrap_grid3D.hh" #include "orbit/wrap_bunch.hh" #include @@ -54,42 +55,14 @@ extern "C" { static PyObject* SpaceChargeCalcSliceBySlice2D_getRhoGrid(PyObject *self, PyObject *args){ pyORBIT_Object* pySpaceChargeCalcSliceBySlice2D = (pyORBIT_Object*) self; SpaceChargeCalcSliceBySlice2D* cpp_SpaceChargeCalcSliceBySlice2D = (SpaceChargeCalcSliceBySlice2D*) pySpaceChargeCalcSliceBySlice2D->cpp_obj; - Grid3D* cpp_grid3d = cpp_SpaceChargeCalcSliceBySlice2D->getRhoGrid(); - if(cpp_grid3d->getPyWrapper() != NULL){ - Py_INCREF(cpp_grid3d->getPyWrapper()); - return cpp_grid3d->getPyWrapper(); - } - //It will create a pyGrid3D object - PyObject* mod = PyImport_ImportModule("orbit.core.spacecharge"); - PyObject* pyGrid3D = PyObject_CallMethod(mod,const_cast("Grid3D"),const_cast("iii"),cpp_grid3d->getSizeX(),cpp_grid3d->getSizeY(),cpp_grid3d->getSizeZ()); - //delete the c++ reference to the internal Grid3D inside pyGrid3D and assign the new one - delete ((Grid3D*)((pyORBIT_Object*) pyGrid3D)->cpp_obj); - ((pyORBIT_Object*) pyGrid3D)->cpp_obj = cpp_grid3d; - cpp_grid3d->setPyWrapper(pyGrid3D); - Py_INCREF(cpp_grid3d->getPyWrapper()); - Py_DECREF(mod); - return pyGrid3D; + return wrapGrid3D(cpp_SpaceChargeCalcSliceBySlice2D->getRhoGrid(), self); } //Grid3D* getPhiGrid() returns the 3D grid with potential static PyObject* SpaceChargeCalcSliceBySlice2D_getPhiGrid(PyObject *self, PyObject *args){ pyORBIT_Object* pySpaceChargeCalcSliceBySlice2D = (pyORBIT_Object*) self; SpaceChargeCalcSliceBySlice2D* cpp_SpaceChargeCalcSliceBySlice2D = (SpaceChargeCalcSliceBySlice2D*) pySpaceChargeCalcSliceBySlice2D->cpp_obj; - Grid3D* cpp_grid3d = cpp_SpaceChargeCalcSliceBySlice2D->getPhiGrid(); - if(cpp_grid3d->getPyWrapper() != NULL){ - Py_INCREF(cpp_grid3d->getPyWrapper()); - return cpp_grid3d->getPyWrapper(); - } - //It will create a pyGrid3D object - PyObject* mod = PyImport_ImportModule("orbit.core.spacecharge"); - PyObject* pyGrid3D = PyObject_CallMethod(mod,const_cast("Grid3D"),const_cast("iii"),cpp_grid3d->getSizeX(),cpp_grid3d->getSizeY(),cpp_grid3d->getSizeZ()); - //delete the c++ reference to the internal Grid3D inside pyGrid3D and assign the new one - delete ((Grid3D*)((pyORBIT_Object*) pyGrid3D)->cpp_obj); - ((pyORBIT_Object*) pyGrid3D)->cpp_obj = cpp_grid3d; - cpp_grid3d->setPyWrapper(pyGrid3D); - Py_INCREF(cpp_grid3d->getPyWrapper()); - Py_DECREF(mod); - return pyGrid3D; + return wrapGrid3D(cpp_SpaceChargeCalcSliceBySlice2D->getPhiGrid(), self); } //trackBunch(Bunch* bunch, double length[,BaseBoundary2D* boundary]) diff --git a/src/spacecharge/wrap_spacechargeforcecalc2p5d.cc b/src/spacecharge/wrap_spacechargeforcecalc2p5d.cc index 46bd9248..ce46fbe3 100644 --- a/src/spacecharge/wrap_spacechargeforcecalc2p5d.cc +++ b/src/spacecharge/wrap_spacechargeforcecalc2p5d.cc @@ -3,6 +3,8 @@ # #include "spacecharge/wrap_spacechargeforcecalc2p5d.hh" #include "spacecharge/wrap_spacecharge.hh" +#include "spacecharge/wrap_grid1D.hh" +#include "spacecharge/wrap_grid2D.hh" #include "orbit/wrap_bunch.hh" #include @@ -50,42 +52,14 @@ extern "C" { static PyObject* SpaceChargeForceCalc2p5D_getRhoGrid(PyObject *self, PyObject *args){ pyORBIT_Object* pySpaceChargeForceCalc2p5D = (pyORBIT_Object*) self; SpaceChargeForceCalc2p5D* cpp_SpaceChargeForceCalc2p5D = (SpaceChargeForceCalc2p5D*) pySpaceChargeForceCalc2p5D->cpp_obj; - Grid2D* cpp_grid2d = cpp_SpaceChargeForceCalc2p5D->getRhoGrid(); - if(cpp_grid2d->getPyWrapper() != NULL){ - Py_INCREF(cpp_grid2d->getPyWrapper()); - return cpp_grid2d->getPyWrapper(); - } - //It will create a pyGrid2D object - PyObject* mod = PyImport_ImportModule("orbit.core.spacecharge"); - PyObject* pyGrid2D = PyObject_CallMethod(mod,const_cast("Grid2D"),const_cast("ii"),cpp_grid2d->getSizeX(),cpp_grid2d->getSizeY()); - //delete the c++ reference to the internal Grid2D inside pyGrid2D and assign the new one - delete ((Grid2D*)((pyORBIT_Object*) pyGrid2D)->cpp_obj); - ((pyORBIT_Object*) pyGrid2D)->cpp_obj = cpp_grid2d; - cpp_grid2d->setPyWrapper(pyGrid2D); - Py_INCREF(cpp_grid2d->getPyWrapper()); - Py_DECREF(mod); - return pyGrid2D; + return wrapGrid2D(cpp_SpaceChargeForceCalc2p5D->getRhoGrid(), self); } //Grid2D* getPhiGrid() returns the 2D grid with horizontal force static PyObject* SpaceChargeForceCalc2p5D_getForceGridX(PyObject *self, PyObject *args){ pyORBIT_Object* pySpaceChargeForceCalc2p5D = (pyORBIT_Object*) self; SpaceChargeForceCalc2p5D* cpp_SpaceChargeForceCalc2p5D = (SpaceChargeForceCalc2p5D*) pySpaceChargeForceCalc2p5D->cpp_obj; - Grid2D* cpp_grid2d = cpp_SpaceChargeForceCalc2p5D->getForceGridX(); - if(cpp_grid2d->getPyWrapper() != NULL){ - Py_INCREF(cpp_grid2d->getPyWrapper()); - return cpp_grid2d->getPyWrapper(); - } - //It will create a pyGrid2D object - PyObject* mod = PyImport_ImportModule("orbit.core.spacecharge"); - PyObject* pyGrid2D = PyObject_CallMethod(mod,const_cast("Grid2D"),const_cast("ii"),cpp_grid2d->getSizeX(),cpp_grid2d->getSizeY()); - //delete the c++ reference to the internal Grid2D inside pyGrid2D and assign the new one - delete ((Grid2D*)((pyORBIT_Object*) pyGrid2D)->cpp_obj); - ((pyORBIT_Object*) pyGrid2D)->cpp_obj = cpp_grid2d; - cpp_grid2d->setPyWrapper(pyGrid2D); - Py_INCREF(cpp_grid2d->getPyWrapper()); - Py_DECREF(mod); - return pyGrid2D; + return wrapGrid2D(cpp_SpaceChargeForceCalc2p5D->getForceGridX(), self); } @@ -93,21 +67,7 @@ extern "C" { static PyObject* SpaceChargeForceCalc2p5D_getForceGridY(PyObject *self, PyObject *args){ pyORBIT_Object* pySpaceChargeForceCalc2p5D = (pyORBIT_Object*) self; SpaceChargeForceCalc2p5D* cpp_SpaceChargeForceCalc2p5D = (SpaceChargeForceCalc2p5D*) pySpaceChargeForceCalc2p5D->cpp_obj; - Grid2D* cpp_grid2d = cpp_SpaceChargeForceCalc2p5D->getForceGridY(); - if(cpp_grid2d->getPyWrapper() != NULL){ - Py_INCREF(cpp_grid2d->getPyWrapper()); - return cpp_grid2d->getPyWrapper(); - } - //It will create a pyGrid2D object - PyObject* mod = PyImport_ImportModule("orbit.core.spacecharge"); - PyObject* pyGrid2D = PyObject_CallMethod(mod,const_cast("Grid2D"),const_cast("ii"),cpp_grid2d->getSizeX(),cpp_grid2d->getSizeY()); - //delete the c++ reference to the internal Grid2D inside pyGrid2D and assign the new one - delete ((Grid2D*)((pyORBIT_Object*) pyGrid2D)->cpp_obj); - ((pyORBIT_Object*) pyGrid2D)->cpp_obj = cpp_grid2d; - cpp_grid2d->setPyWrapper(pyGrid2D); - Py_INCREF(cpp_grid2d->getPyWrapper()); - Py_DECREF(mod); - return pyGrid2D; + return wrapGrid2D(cpp_SpaceChargeForceCalc2p5D->getForceGridY(), self); } @@ -115,21 +75,7 @@ extern "C" { static PyObject* SpaceChargeForceCalc2p5D_getLongGrid(PyObject *self, PyObject *args){ pyORBIT_Object* pySpaceChargeForceCalc2p5D = (pyORBIT_Object*) self; SpaceChargeForceCalc2p5D* cpp_SpaceChargeForceCalc2p5D = (SpaceChargeForceCalc2p5D*) pySpaceChargeForceCalc2p5D->cpp_obj; - Grid1D* cpp_grid1d = cpp_SpaceChargeForceCalc2p5D->getLongGrid(); - if(cpp_grid1d->getPyWrapper() != NULL){ - Py_INCREF(cpp_grid1d->getPyWrapper()); - return cpp_grid1d->getPyWrapper(); - } - //It will create a pyGrid2D object - PyObject* mod = PyImport_ImportModule("orbit.core.spacecharge"); - PyObject* pyGrid1D = PyObject_CallMethod(mod,const_cast("Grid1D"),const_cast("i"),cpp_grid1d->getSizeZ()); - //delete the c++ reference to the internal Grid1D inside pyGrid1D and assign the new one - delete ((Grid1D*)((pyORBIT_Object*) pyGrid1D)->cpp_obj); - ((pyORBIT_Object*) pyGrid1D)->cpp_obj = cpp_grid1d; - cpp_grid1d->setPyWrapper(pyGrid1D); - Py_INCREF(cpp_grid1d->getPyWrapper()); - Py_DECREF(mod); - return pyGrid1D; + return wrapGrid1D(cpp_SpaceChargeForceCalc2p5D->getLongGrid(), self); } //trackBunch(Bunch* bunch, double length[,BaseBoundary2D* boundary]) diff --git a/src/utils/field_sources/MagnetFieldSourceGrid3D.cc b/src/utils/field_sources/MagnetFieldSourceGrid3D.cc index 9e147cf9..12c8aaf0 100644 --- a/src/utils/field_sources/MagnetFieldSourceGrid3D.cc +++ b/src/utils/field_sources/MagnetFieldSourceGrid3D.cc @@ -85,28 +85,6 @@ MagnetFieldSourceGrid3D::MagnetFieldSourceGrid3D(Grid3D* BxGrid_In, Grid3D* ByGr MagnetFieldSourceGrid3D::~MagnetFieldSourceGrid3D() { - - if(BxGrid->getPyWrapper() == NULL){ - delete BxGrid; - } - else { - Py_XDECREF(BxGrid->getPyWrapper()); - } - - if(ByGrid->getPyWrapper() == NULL){ - delete ByGrid; - } - else { - Py_XDECREF(ByGrid->getPyWrapper()); - } - - if(BzGrid->getPyWrapper() == NULL){ - delete BzGrid; - } - else { - Py_XDECREF(BzGrid->getPyWrapper()); - } - for(int i = 0; i < 8; i++){ delete [] field_sign_arr[i]; } diff --git a/src/utils/field_sources/MagnetFieldSourceGrid3D.hh b/src/utils/field_sources/MagnetFieldSourceGrid3D.hh index 45844a32..f3e239f1 100644 --- a/src/utils/field_sources/MagnetFieldSourceGrid3D.hh +++ b/src/utils/field_sources/MagnetFieldSourceGrid3D.hh @@ -36,7 +36,7 @@ namespace OrbitUtils{ { public: - /** Constructor. */ + /** Constructor. The caller retains ownership of the grids. */ MagnetFieldSourceGrid3D(Grid3D* BxGrid, Grid3D* ByGrid, Grid3D* BzGrid); /** Destructor */ diff --git a/src/utils/field_sources/wrap_magnetic_field_source_grid3d.cc b/src/utils/field_sources/wrap_magnetic_field_source_grid3d.cc index 15e1fc18..48977574 100644 --- a/src/utils/field_sources/wrap_magnetic_field_source_grid3d.cc +++ b/src/utils/field_sources/wrap_magnetic_field_source_grid3d.cc @@ -12,6 +12,12 @@ using namespace wrap_orbit_utils; namespace wrap_field_source_grid3d{ + typedef struct { + PyObject_HEAD + void* cpp_obj; + PyObject* grids[3]; + } pyORBIT_MagnetFieldSourceGrid3D; + void error(const char* msg){ ORBIT_MPI_Finalize(msg); } #ifdef __cplusplus @@ -25,15 +31,18 @@ extern "C" { //It never will be called directly static PyObject* MagnetFieldSourceGrid3D_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - pyORBIT_Object* self; - self = (pyORBIT_Object *) type->tp_alloc(type, 0); + pyORBIT_MagnetFieldSourceGrid3D* self; + self = (pyORBIT_MagnetFieldSourceGrid3D *) type->tp_alloc(type, 0); self->cpp_obj = NULL; + self->grids[0] = NULL; + self->grids[1] = NULL; + self->grids[2] = NULL; return (PyObject *) self; } //initializator for python MagnetFieldSourceGrid3D class //this is implementation of the __init__ method - static int MagnetFieldSourceGrid3D_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ + static int MagnetFieldSourceGrid3D_init(pyORBIT_MagnetFieldSourceGrid3D *self, PyObject *args, PyObject *kwds){ PyObject* pyBxGrid3D; PyObject* pyByGrid3D; PyObject* pyBzGrid3D; @@ -55,20 +64,17 @@ extern "C" { Py_INCREF(pyBxGrid3D); Py_INCREF(pyByGrid3D); Py_INCREF(pyBzGrid3D); + self->grids[0] = pyBxGrid3D; + self->grids[1] = pyByGrid3D; + self->grids[2] = pyBzGrid3D; ((MagnetFieldSourceGrid3D*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } /** Returns 3 Grid3D objects with Bx,By,Bz fields that were used in the constructor */ static PyObject* MagnetFieldSourceGrid3D_getGrid3Ds(PyObject *self, PyObject *args){ - MagnetFieldSourceGrid3D* cpp_fieldSource = (MagnetFieldSourceGrid3D*)((pyORBIT_Object*) self)->cpp_obj; - Grid3D* BxGrid3D = cpp_fieldSource->getBxGrid(); - Grid3D* ByGrid3D = cpp_fieldSource->getByGrid(); - Grid3D* BzGrid3D = cpp_fieldSource->getBzGrid(); - PyObject* pyBxGrid3D = (PyObject*) BxGrid3D->getPyWrapper(); - PyObject* pyByGrid3D = (PyObject*) ByGrid3D->getPyWrapper(); - PyObject* pyBzGrid3D = (PyObject*) BzGrid3D->getPyWrapper(); - return Py_BuildValue("(OOO)",pyBxGrid3D,pyByGrid3D,pyBzGrid3D); + pyORBIT_MagnetFieldSourceGrid3D* source = (pyORBIT_MagnetFieldSourceGrid3D*) self; + return Py_BuildValue("(OOO)", source->grids[0], source->grids[1], source->grids[2]); } /** Sets or returns X,Y,Z axis symmetries */ @@ -189,8 +195,11 @@ extern "C" { //----------------------------------------------------- //destructor for python MagnetFieldSourceGrid3D class (__del__ method). //----------------------------------------------------- - static void MagnetFieldSourceGrid3D_del(pyORBIT_Object* self){ + static void MagnetFieldSourceGrid3D_del(pyORBIT_MagnetFieldSourceGrid3D* self){ delete ((MagnetFieldSourceGrid3D*)self->cpp_obj); + Py_CLEAR(self->grids[0]); + Py_CLEAR(self->grids[1]); + Py_CLEAR(self->grids[2]); self->ob_base.ob_type->tp_free((PyObject*)self); } @@ -216,7 +225,7 @@ extern "C" { static PyTypeObject pyORBIT_MagnetFieldSourceGrid3D_Type = { PyVarObject_HEAD_INIT(NULL, 0) "MagnetFieldSourceGrid3D", /*tp_name*/ - sizeof(pyORBIT_Object), /*tp_basicsize*/ + sizeof(pyORBIT_MagnetFieldSourceGrid3D), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor) MagnetFieldSourceGrid3D_del , /*tp_dealloc*/ 0, /*tp_print*/ From e76b46a467e3545a67f2d8ac0c871ca90d3be7e6 Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 11 Sep 2026 15:25:09 -0400 Subject: [PATCH 21/33] refactor(fields): move ownership to bindings --- src/linac/rfgap/wrap_SuperFishFieldSource.cc | 3 +- src/trackerrk4/PyExternalEffects.cc | 4 +-- src/utils/BaseFieldSource.cc | 2 +- src/utils/BaseFieldSource.hh | 4 +-- src/utils/FieldSourceContainer.cc | 13 ------- src/utils/FieldSourceContainer.hh | 6 ++-- src/utils/PyBaseFieldSource.cc | 5 ++- src/utils/PyBaseFieldSource.hh | 3 ++ src/utils/field_sources/ShiftedFieldSource.cc | 32 ++++------------- src/utils/field_sources/ShiftedFieldSource.hh | 5 ++- .../field_sources/wrap_dipole_field_source.cc | 34 ++++++++++++------- .../field_sources/wrap_loop_field_source.cc | 34 ++++++++++++------- .../wrap_magnetic_field_source_grid3d.cc | 19 +++++++---- .../field_sources/wrap_quad_field_source.cc | 34 ++++++++++++------- src/utils/matrix/Matrix.cc | 4 +-- src/utils/matrix/Matrix.hh | 4 +-- src/utils/matrix/wrap_matrix.cc | 7 ++-- src/utils/wrap_field_source_container.cc | 30 ++++++++++++---- src/utils/wrap_py_base_field_source.cc | 2 ++ 19 files changed, 133 insertions(+), 112 deletions(-) diff --git a/src/linac/rfgap/wrap_SuperFishFieldSource.cc b/src/linac/rfgap/wrap_SuperFishFieldSource.cc index bfa5551b..ca2a7c90 100644 --- a/src/linac/rfgap/wrap_SuperFishFieldSource.cc +++ b/src/linac/rfgap/wrap_SuperFishFieldSource.cc @@ -46,7 +46,7 @@ extern "C" { //this is implementation of the __init__ method static int SuperFishFieldSource_init(pyORBIT_SuperFishFieldSource *self, PyObject *args, PyObject *kwds){ self->cpp_obj = new SuperFishFieldSource(); - ((SuperFishFieldSource*) self->cpp_obj)->setPyWrapper((PyObject*) self); + pyorbit::registerPyWrapper(self->cpp_obj, (PyObject*) self); return 0; } @@ -265,6 +265,7 @@ extern "C" { static void SuperFishFieldSource_del(pyORBIT_SuperFishFieldSource* self){ //std::cerr<<"The SuperFishFieldSource __del__ has been called!"<cpp_obj; + pyorbit::unregisterPyWrapper(cpp_SuperFishFieldSource, (PyObject*) self); delete cpp_SuperFishFieldSource; Py_CLEAR(self->grids[0]); Py_CLEAR(self->grids[1]); diff --git a/src/trackerrk4/PyExternalEffects.cc b/src/trackerrk4/PyExternalEffects.cc index 5b175a8b..a24e86b2 100644 --- a/src/trackerrk4/PyExternalEffects.cc +++ b/src/trackerrk4/PyExternalEffects.cc @@ -76,7 +76,7 @@ void PyExternalEffects::applyEffects(Bunch* bunch, { PyObject* py_wrp = getPyWrapper(); PyObject* py_bunch = pyorbit::getPyWrapper(bunch); - PyObject* py_field = fieldSource->getPyWrapper(); + PyObject* py_field = pyorbit::getPyWrapper(fieldSource); PyObject* py_tracker = pyorbit::getPyWrapper(tracker); PyObject* res_tuple = PyObject_CallMethod(py_wrp,const_cast("applyEffects"),const_cast("OddOO"), py_bunch, @@ -94,7 +94,7 @@ void PyExternalEffects::applyEffectsForEach(Bunch* bunch, int index, { PyObject* py_wrp = getPyWrapper(); PyObject* py_bunch = pyorbit::getPyWrapper(bunch); - PyObject* py_field = fieldSource->getPyWrapper(); + PyObject* py_field = pyorbit::getPyWrapper(fieldSource); PyObject* py_tracker = pyorbit::getPyWrapper(tracker); PyObject* pyInVct = Py_BuildValue("(dddddd)",y_in_vct[0],y_in_vct[1],y_in_vct[2], y_in_vct[3],y_in_vct[4],y_in_vct[5]); diff --git a/src/utils/BaseFieldSource.cc b/src/utils/BaseFieldSource.cc index e4252c98..b6d9bd8b 100644 --- a/src/utils/BaseFieldSource.cc +++ b/src/utils/BaseFieldSource.cc @@ -18,7 +18,7 @@ using namespace OrbitUtils; -BaseFieldSource::BaseFieldSource(): CppPyWrapper(NULL) +BaseFieldSource::BaseFieldSource() { } diff --git a/src/utils/BaseFieldSource.hh b/src/utils/BaseFieldSource.hh index 45649ab7..6f9ee257 100644 --- a/src/utils/BaseFieldSource.hh +++ b/src/utils/BaseFieldSource.hh @@ -12,8 +12,6 @@ #ifndef BASE_FIELD_SOURCE_H #define BASE_FIELD_SOURCE_H -#include "utils/CppPyWrapper.hh" - namespace OrbitUtils{ @@ -23,7 +21,7 @@ namespace OrbitUtils{ subclasses. */ - class BaseFieldSource: public CppPyWrapper + class BaseFieldSource { public: diff --git a/src/utils/FieldSourceContainer.cc b/src/utils/FieldSourceContainer.cc index 6c58b799..8ec9426b 100644 --- a/src/utils/FieldSourceContainer.cc +++ b/src/utils/FieldSourceContainer.cc @@ -29,23 +29,10 @@ FieldSourceContainer::FieldSourceContainer():BaseFieldSource() } FieldSourceContainer::~FieldSourceContainer(){ - - for (int i=0;igetPyWrapper() == NULL){ - delete ref[i]; - } else { - Py_XDECREF(ref[i]->getPyWrapper()); - } - } - } /** Adds the instance of the ExternalEffects class to the container. */ void FieldSourceContainer::AddFieldSource(BaseFieldSource* fs) { - if(fs->getPyWrapper() != NULL){ - Py_INCREF(fs->getPyWrapper()); - } - ref.push_back(fs); } diff --git a/src/utils/FieldSourceContainer.hh b/src/utils/FieldSourceContainer.hh index a47768c1..8a11d21b 100644 --- a/src/utils/FieldSourceContainer.hh +++ b/src/utils/FieldSourceContainer.hh @@ -18,8 +18,6 @@ #ifndef FIELDSOURCECONTAINER_HH_ #define FIELDSOURCECONTAINER_HH_ -#include - #include "utils/BaseFieldSource.hh" #include @@ -40,7 +38,7 @@ namespace OrbitUtils{ /** Destructor. */ ~FieldSourceContainer(); - /** Adds the instance of the ExternalEffects class to the container. */ + /** Adds a non-owning field-source reference to the container. */ void AddFieldSource(BaseFieldSource* fs); /** Adds the instance of the ExternalEffects class to the container. */ @@ -50,7 +48,7 @@ namespace OrbitUtils{ private: - std::vector ref; + std::vector ref; }; }; diff --git a/src/utils/PyBaseFieldSource.cc b/src/utils/PyBaseFieldSource.cc index 13faada7..c03809bf 100644 --- a/src/utils/PyBaseFieldSource.cc +++ b/src/utils/PyBaseFieldSource.cc @@ -28,7 +28,7 @@ using namespace OrbitUtils; PyBaseFieldSource::PyBaseFieldSource(PyObject* py_wrapperIn) { - setPyWrapper(py_wrapperIn); + py_wrapper = py_wrapperIn; } PyBaseFieldSource::~PyBaseFieldSource() @@ -40,8 +40,7 @@ void PyBaseFieldSource::getElectricMagneticField( double& fe_x, double& fe_y, double& fe_z, double& fm_x, double& fm_y, double& fm_z) { - PyObject* py_wrp = getPyWrapper(); - PyObject* ef_tuple = PyObject_CallMethod(py_wrp,const_cast("getElectricMagneticField"),const_cast("dddd"),x,y,z,t); + PyObject* ef_tuple = PyObject_CallMethod(py_wrapper,const_cast("getElectricMagneticField"),const_cast("dddd"),x,y,z,t); if(!PyArg_ParseTuple( ef_tuple,"dddddd:electric_magnetic_field",&fe_x,&fe_y,&fe_z,&fm_x,&fm_y,&fm_z)){ ORBIT_MPI_Finalize("PyBaseFieldSource - getElectricMagneticField(x,y,z,t0 method does not work!"); } diff --git a/src/utils/PyBaseFieldSource.hh b/src/utils/PyBaseFieldSource.hh index 6b34b2ee..89207f3d 100644 --- a/src/utils/PyBaseFieldSource.hh +++ b/src/utils/PyBaseFieldSource.hh @@ -55,6 +55,9 @@ namespace OrbitUtils{ double& fe_x, double& fe_y, double& fe_z, double& fm_x, double& fm_y, double& fm_z); + private: + PyObject* py_wrapper; + }; }; diff --git a/src/utils/field_sources/ShiftedFieldSource.cc b/src/utils/field_sources/ShiftedFieldSource.cc index 7eb2e6b4..4101fb8d 100644 --- a/src/utils/field_sources/ShiftedFieldSource.cc +++ b/src/utils/field_sources/ShiftedFieldSource.cc @@ -23,8 +23,6 @@ // the external coordinate system by coordTransformBack (3x3) matrix. // /////////////////////////////////////////////////////////////////////////// -#include - #include "mpi/orbit_mpi.hh" #include "utils/field_sources/ShiftedFieldSource.hh" @@ -36,8 +34,9 @@ using namespace OrbitUtils; ShiftedFieldSource::ShiftedFieldSource(): BaseFieldSource() { - coordTransformM4x4 = new Matrix(4,4); - coordTransformM3x3 = new Matrix(3,3); + ownedCoordTransformM4x4.reset(new Matrix(4,4)); + coordTransformM4x4 = ownedCoordTransformM4x4.get(); + coordTransformM3x3.reset(new Matrix(3,3)); coordTransformM4x4->unit(); coordTransformM3x3->unit(); @@ -58,15 +57,6 @@ ShiftedFieldSource::ShiftedFieldSource(): BaseFieldSource() /** Destructor */ ShiftedFieldSource::~ShiftedFieldSource() { - if(coordTransformM4x4->getPyWrapper() == NULL){ - delete coordTransformM4x4; - } - else { - Py_XDECREF(coordTransformM4x4->getPyWrapper()); - } - - delete coordTransformM3x3; - delete coordVectExt; delete coordVectInn; @@ -101,7 +91,7 @@ void ShiftedFieldSource::getElectricMagneticField( innArr[1] = E_y; innArr[2] = E_z; - MatrixOperations::mult(coordTransformM3x3,fieldVectInn,fieldVectExt); + MatrixOperations::mult(coordTransformM3x3.get(),fieldVectInn,fieldVectExt); extArr = fieldVectExt->getArray(); E_x = extArr[0]; @@ -115,7 +105,7 @@ void ShiftedFieldSource::getElectricMagneticField( innArr[1] = H_y; innArr[2] = H_z; - MatrixOperations::mult(coordTransformM3x3,fieldVectInn,fieldVectExt); + MatrixOperations::mult(coordTransformM3x3.get(),fieldVectInn,fieldVectExt); extArr = fieldVectExt->getArray(); H_x = extArr[0]; @@ -148,19 +138,9 @@ Matrix* ShiftedFieldSource::getCoordsTransformMatrix() */ void ShiftedFieldSource::setCoordsTransformMatrix(Matrix* coordTransformM4x4_In) { - if(coordTransformM4x4->getPyWrapper() == NULL){ - delete coordTransformM4x4; - } - else { - Py_XDECREF(coordTransformM4x4->getPyWrapper()); - } - + ownedCoordTransformM4x4.reset(); coordTransformM4x4 = coordTransformM4x4_In; - if(coordTransformM4x4->getPyWrapper() != NULL){ - Py_INCREF(coordTransformM4x4->getPyWrapper()); - } - for(int ind_x; ind_x < 3; ind_x++){ for(int ind_y; ind_y < 3; ind_y++){ coordTransformM3x3->getArray()[ind_x][ind_y] = coordTransformM4x4->getArray()[ind_x][ind_y]; diff --git a/src/utils/field_sources/ShiftedFieldSource.hh b/src/utils/field_sources/ShiftedFieldSource.hh index 39b0ac06..bbaa5274 100644 --- a/src/utils/field_sources/ShiftedFieldSource.hh +++ b/src/utils/field_sources/ShiftedFieldSource.hh @@ -33,6 +33,7 @@ #include #include #include +#include #include "utils/BaseFieldSource.hh" #include "utils/matrix/Matrix.hh" @@ -80,6 +81,7 @@ namespace OrbitUtils{ /** Sets coordinates transformation matrix 4x4. It includes rotation 3x3 matrix and origin shift. + The caller retains ownership of the matrix. */ void setCoordsTransformMatrix(Matrix* coordTransformM4x4); @@ -87,6 +89,7 @@ namespace OrbitUtils{ protected: //Matrix for transformation from external to shifted system + std::unique_ptr ownedCoordTransformM4x4; Matrix* coordTransformM4x4; //----------------------------------- @@ -103,7 +106,7 @@ namespace OrbitUtils{ //Matrix for transformation E and B from shifted to external system - Matrix* coordTransformM3x3; + std::unique_ptr coordTransformM3x3; }; }; diff --git a/src/utils/field_sources/wrap_dipole_field_source.cc b/src/utils/field_sources/wrap_dipole_field_source.cc index 8c96058c..0ea8dd04 100644 --- a/src/utils/field_sources/wrap_dipole_field_source.cc +++ b/src/utils/field_sources/wrap_dipole_field_source.cc @@ -12,6 +12,12 @@ using namespace wrap_orbit_utils; namespace wrap_dipole_field_source{ + typedef struct { + PyObject_HEAD + void* cpp_obj; + PyObject* transform; + } pyORBIT_DipoleFieldSource; + void error(const char* msg){ ORBIT_MPI_Finalize(msg); } #ifdef __cplusplus @@ -25,17 +31,18 @@ extern "C" { //It never will be called directly static PyObject* DipoleFieldSource_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - pyORBIT_Object* self; - self = (pyORBIT_Object *) type->tp_alloc(type, 0); + pyORBIT_DipoleFieldSource* self; + self = (pyORBIT_DipoleFieldSource *) type->tp_alloc(type, 0); self->cpp_obj = NULL; + self->transform = NULL; return (PyObject *) self; } //initializator for python DipoleFieldSource class //this is implementation of the __init__ method - static int DipoleFieldSource_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ + static int DipoleFieldSource_init(pyORBIT_DipoleFieldSource *self, PyObject *args, PyObject *kwds){ self->cpp_obj = new DipoleFieldSource(); - ((DipoleFieldSource*) self->cpp_obj)->setPyWrapper((PyObject*) self); + pyorbit::registerPyWrapper(self->cpp_obj, (PyObject*) self); return 0; } @@ -85,6 +92,7 @@ extern "C" { /** Sets / Returns the coordinates transformation matrix 4x4 from external to inner system */ static PyObject* DipoleFieldSource_transormfMatrix(PyObject *self, PyObject *args){ + pyORBIT_DipoleFieldSource* source = (pyORBIT_DipoleFieldSource*) self; DipoleFieldSource* cpp_fieldSource = (DipoleFieldSource*)((pyORBIT_Object*) self)->cpp_obj; int nArgs = PyTuple_Size(args); PyObject* pyMatrix; @@ -101,25 +109,27 @@ extern "C" { if(cpp_matrix->rows() != 4 || cpp_matrix->columns() != 4){ error("DipoleFieldSource.transormfMatrix(Matrix) - Matrix is not 4x4."); } - // the Py_INCREF(pyMatrix) call will be performed inside setCoordsTransformMatrix(...) method cpp_fieldSource->setCoordsTransformMatrix(cpp_matrix); + Py_INCREF(pyMatrix); + Py_XDECREF(source->transform); + source->transform = pyMatrix; Py_INCREF(Py_None); return Py_None; } - cpp_matrix = cpp_fieldSource->getCoordsTransformMatrix(); - pyMatrix = (PyObject*) ((pyORBIT_Object*) cpp_matrix->getPyWrapper()); - if(pyMatrix == NULL){ + if(source->transform == NULL){ error("DipoleFieldSource.transormfMatrix() - cannot return Matrix 4x4. You have to assign it first."); } - Py_INCREF(pyMatrix); - return pyMatrix; + Py_INCREF(source->transform); + return source->transform; } //----------------------------------------------------- //destructor for python DipoleFieldSource class (__del__ method). //----------------------------------------------------- - static void DipoleFieldSource_del(pyORBIT_Object* self){ + static void DipoleFieldSource_del(pyORBIT_DipoleFieldSource* self){ + pyorbit::unregisterPyWrapper(self->cpp_obj, (PyObject*) self); delete ((DipoleFieldSource*)self->cpp_obj); + Py_CLEAR(self->transform); self->ob_base.ob_type->tp_free((PyObject*)self); } @@ -143,7 +153,7 @@ extern "C" { static PyTypeObject pyORBIT_DipoleFieldSource_Type = { PyVarObject_HEAD_INIT(NULL, 0) "DipoleFieldSource", /*tp_name*/ - sizeof(pyORBIT_Object), /*tp_basicsize*/ + sizeof(pyORBIT_DipoleFieldSource), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor) DipoleFieldSource_del , /*tp_dealloc*/ 0, /*tp_print*/ diff --git a/src/utils/field_sources/wrap_loop_field_source.cc b/src/utils/field_sources/wrap_loop_field_source.cc index a6e7d183..6443014a 100644 --- a/src/utils/field_sources/wrap_loop_field_source.cc +++ b/src/utils/field_sources/wrap_loop_field_source.cc @@ -12,6 +12,12 @@ using namespace wrap_orbit_utils; namespace wrap_loop_field_source{ + typedef struct { + PyObject_HEAD + void* cpp_obj; + PyObject* transform; + } pyORBIT_LoopFieldSource; + void error(const char* msg){ ORBIT_MPI_Finalize(msg); } #ifdef __cplusplus @@ -25,17 +31,18 @@ extern "C" { //It never will be called directly static PyObject* LoopFieldSource_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - pyORBIT_Object* self; - self = (pyORBIT_Object *) type->tp_alloc(type, 0); + pyORBIT_LoopFieldSource* self; + self = (pyORBIT_LoopFieldSource *) type->tp_alloc(type, 0); self->cpp_obj = NULL; + self->transform = NULL; return (PyObject *) self; } //initializator for python LoopFieldSource class //this is implementation of the __init__ method - static int LoopFieldSource_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ + static int LoopFieldSource_init(pyORBIT_LoopFieldSource *self, PyObject *args, PyObject *kwds){ self->cpp_obj = new LoopFieldSource(); - ((LoopFieldSource*) self->cpp_obj)->setPyWrapper((PyObject*) self); + pyorbit::registerPyWrapper(self->cpp_obj, (PyObject*) self); return 0; } @@ -115,6 +122,7 @@ extern "C" { /** Sets / Returns the coordinates transformation matrix 4x4 from external to inner system */ static PyObject* LoopFieldSource_transormfMatrix(PyObject *self, PyObject *args){ + pyORBIT_LoopFieldSource* source = (pyORBIT_LoopFieldSource*) self; LoopFieldSource* cpp_fieldSource = (LoopFieldSource*)((pyORBIT_Object*) self)->cpp_obj; int nArgs = PyTuple_Size(args); PyObject* pyMatrix; @@ -131,25 +139,27 @@ extern "C" { if(cpp_matrix->rows() != 4 || cpp_matrix->columns() != 4){ error("LoopFieldSource.transormfMatrix(Matrix) - Matrix is not 4x4."); } - // the Py_INCREF(pyMatrix) call will be performed inside setCoordsTransformMatrix(...) method cpp_fieldSource->setCoordsTransformMatrix(cpp_matrix); + Py_INCREF(pyMatrix); + Py_XDECREF(source->transform); + source->transform = pyMatrix; Py_INCREF(Py_None); return Py_None; } - cpp_matrix = cpp_fieldSource->getCoordsTransformMatrix(); - pyMatrix = (PyObject*) ((pyORBIT_Object*) cpp_matrix->getPyWrapper()); - if(pyMatrix == NULL){ + if(source->transform == NULL){ error("LoopFieldSource.transormfMatrix() - cannot return Matrix 4x4. You have to assign it first."); } - Py_INCREF(pyMatrix); - return pyMatrix; + Py_INCREF(source->transform); + return source->transform; } //----------------------------------------------------- //destructor for python LoopFieldSource class (__del__ method). //----------------------------------------------------- - static void LoopFieldSource_del(pyORBIT_Object* self){ + static void LoopFieldSource_del(pyORBIT_LoopFieldSource* self){ + pyorbit::unregisterPyWrapper(self->cpp_obj, (PyObject*) self); delete ((LoopFieldSource*)self->cpp_obj); + Py_CLEAR(self->transform); self->ob_base.ob_type->tp_free((PyObject*)self); } @@ -175,7 +185,7 @@ extern "C" { static PyTypeObject pyORBIT_LoopFieldSource_Type = { PyVarObject_HEAD_INIT(NULL, 0) "LoopFieldSource", /*tp_name*/ - sizeof(pyORBIT_Object), /*tp_basicsize*/ + sizeof(pyORBIT_LoopFieldSource), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor) LoopFieldSource_del , /*tp_dealloc*/ 0, /*tp_print*/ diff --git a/src/utils/field_sources/wrap_magnetic_field_source_grid3d.cc b/src/utils/field_sources/wrap_magnetic_field_source_grid3d.cc index 48977574..26049a98 100644 --- a/src/utils/field_sources/wrap_magnetic_field_source_grid3d.cc +++ b/src/utils/field_sources/wrap_magnetic_field_source_grid3d.cc @@ -16,6 +16,7 @@ namespace wrap_field_source_grid3d{ PyObject_HEAD void* cpp_obj; PyObject* grids[3]; + PyObject* transform; } pyORBIT_MagnetFieldSourceGrid3D; void error(const char* msg){ ORBIT_MPI_Finalize(msg); } @@ -37,6 +38,7 @@ extern "C" { self->grids[0] = NULL; self->grids[1] = NULL; self->grids[2] = NULL; + self->transform = NULL; return (PyObject *) self; } @@ -67,7 +69,7 @@ extern "C" { self->grids[0] = pyBxGrid3D; self->grids[1] = pyByGrid3D; self->grids[2] = pyBzGrid3D; - ((MagnetFieldSourceGrid3D*) self->cpp_obj)->setPyWrapper((PyObject*) self); + pyorbit::registerPyWrapper(self->cpp_obj, (PyObject*) self); return 0; } @@ -162,6 +164,7 @@ extern "C" { /** Sets / Returns the coordinates transformation matrix 4x4 from external to inner system */ static PyObject* MagnetFieldSourceGrid3D_transormfMatrix(PyObject *self, PyObject *args){ + pyORBIT_MagnetFieldSourceGrid3D* source = (pyORBIT_MagnetFieldSourceGrid3D*) self; MagnetFieldSourceGrid3D* cpp_fieldSource = (MagnetFieldSourceGrid3D*)((pyORBIT_Object*) self)->cpp_obj; int nArgs = PyTuple_Size(args); PyObject* pyMatrix; @@ -178,28 +181,30 @@ extern "C" { if(cpp_matrix->rows() != 4 || cpp_matrix->columns() != 4){ error("MagnetFieldSourceGrid3D.transormfMatrix(Matrix) - Matrix is not 4x4."); } - // the Py_INCREF(pyMatrix) call will be performed inside setCoordsTransformMatrix(...) method cpp_fieldSource->setCoordsTransformMatrix(cpp_matrix); + Py_INCREF(pyMatrix); + Py_XDECREF(source->transform); + source->transform = pyMatrix; Py_INCREF(Py_None); return Py_None; } - cpp_matrix = cpp_fieldSource->getCoordsTransformMatrix(); - pyMatrix = (PyObject*) ((pyORBIT_Object*) cpp_matrix->getPyWrapper()); - if(pyMatrix == NULL){ + if(source->transform == NULL){ error("MagnetFieldSourceGrid3D.transormfMatrix() - cannot return Matrix 4x4. You have to assign it first."); } - Py_INCREF(pyMatrix); - return pyMatrix; + Py_INCREF(source->transform); + return source->transform; } //----------------------------------------------------- //destructor for python MagnetFieldSourceGrid3D class (__del__ method). //----------------------------------------------------- static void MagnetFieldSourceGrid3D_del(pyORBIT_MagnetFieldSourceGrid3D* self){ + pyorbit::unregisterPyWrapper(self->cpp_obj, (PyObject*) self); delete ((MagnetFieldSourceGrid3D*)self->cpp_obj); Py_CLEAR(self->grids[0]); Py_CLEAR(self->grids[1]); Py_CLEAR(self->grids[2]); + Py_CLEAR(self->transform); self->ob_base.ob_type->tp_free((PyObject*)self); } diff --git a/src/utils/field_sources/wrap_quad_field_source.cc b/src/utils/field_sources/wrap_quad_field_source.cc index 3910aa06..be510d00 100644 --- a/src/utils/field_sources/wrap_quad_field_source.cc +++ b/src/utils/field_sources/wrap_quad_field_source.cc @@ -12,6 +12,12 @@ using namespace wrap_orbit_utils; namespace wrap_quad_field_source{ + typedef struct { + PyObject_HEAD + void* cpp_obj; + PyObject* transform; + } pyORBIT_QuadFieldSource; + void error(const char* msg){ ORBIT_MPI_Finalize(msg); } #ifdef __cplusplus @@ -25,17 +31,18 @@ extern "C" { //It never will be called directly static PyObject* QuadFieldSource_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - pyORBIT_Object* self; - self = (pyORBIT_Object *) type->tp_alloc(type, 0); + pyORBIT_QuadFieldSource* self; + self = (pyORBIT_QuadFieldSource *) type->tp_alloc(type, 0); self->cpp_obj = NULL; + self->transform = NULL; return (PyObject *) self; } //initializator for python QuadFieldSource class //this is implementation of the __init__ method - static int QuadFieldSource_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ + static int QuadFieldSource_init(pyORBIT_QuadFieldSource *self, PyObject *args, PyObject *kwds){ self->cpp_obj = new QuadFieldSource(); - ((QuadFieldSource*) self->cpp_obj)->setPyWrapper((PyObject*) self); + pyorbit::registerPyWrapper(self->cpp_obj, (PyObject*) self); return 0; } @@ -85,6 +92,7 @@ extern "C" { /** Sets / Returns the coordinates transformation matrix 4x4 from external to inner system */ static PyObject* QuadFieldSource_transormfMatrix(PyObject *self, PyObject *args){ + pyORBIT_QuadFieldSource* source = (pyORBIT_QuadFieldSource*) self; QuadFieldSource* cpp_fieldSource = (QuadFieldSource*)((pyORBIT_Object*) self)->cpp_obj; int nArgs = PyTuple_Size(args); PyObject* pyMatrix; @@ -101,25 +109,27 @@ extern "C" { if(cpp_matrix->rows() != 4 || cpp_matrix->columns() != 4){ error("QuadFieldSource.transormfMatrix(Matrix) - Matrix is not 4x4."); } - // the Py_INCREF(pyMatrix) call will be performed inside setCoordsTransformMatrix(...) method cpp_fieldSource->setCoordsTransformMatrix(cpp_matrix); + Py_INCREF(pyMatrix); + Py_XDECREF(source->transform); + source->transform = pyMatrix; Py_INCREF(Py_None); return Py_None; } - cpp_matrix = cpp_fieldSource->getCoordsTransformMatrix(); - pyMatrix = (PyObject*) ((pyORBIT_Object*) cpp_matrix->getPyWrapper()); - if(pyMatrix == NULL){ + if(source->transform == NULL){ error("QuadFieldSource.transormfMatrix() - cannot return Matrix 4x4. You have to assign it first."); } - Py_INCREF(pyMatrix); - return pyMatrix; + Py_INCREF(source->transform); + return source->transform; } //----------------------------------------------------- //destructor for python QuadFieldSource class (__del__ method). //----------------------------------------------------- - static void QuadFieldSource_del(pyORBIT_Object* self){ + static void QuadFieldSource_del(pyORBIT_QuadFieldSource* self){ + pyorbit::unregisterPyWrapper(self->cpp_obj, (PyObject*) self); delete ((QuadFieldSource*)self->cpp_obj); + Py_CLEAR(self->transform); self->ob_base.ob_type->tp_free((PyObject*)self); } @@ -143,7 +153,7 @@ extern "C" { static PyTypeObject pyORBIT_QuadFieldSource_Type = { PyVarObject_HEAD_INIT(NULL, 0) "QuadFieldSource", /*tp_name*/ - sizeof(pyORBIT_Object), /*tp_basicsize*/ + sizeof(pyORBIT_QuadFieldSource), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor) QuadFieldSource_del , /*tp_dealloc*/ 0, /*tp_print*/ diff --git a/src/utils/matrix/Matrix.cc b/src/utils/matrix/Matrix.cc index d728cd81..be9fbf98 100644 --- a/src/utils/matrix/Matrix.cc +++ b/src/utils/matrix/Matrix.cc @@ -22,7 +22,7 @@ using namespace OrbitUtils; -Matrix::Matrix(int n_in, int m_in): CppPyWrapper(NULL) +Matrix::Matrix(int n_in, int m_in) { n = n_in; m = m_in; @@ -34,7 +34,7 @@ Matrix::Matrix(int n_in, int m_in): CppPyWrapper(NULL) zero(); } -Matrix::Matrix(Matrix* mtrx): CppPyWrapper(NULL) +Matrix::Matrix(Matrix* mtrx) { n = mtrx->rows(); m = mtrx->columns(); diff --git a/src/utils/matrix/Matrix.hh b/src/utils/matrix/Matrix.hh index 74127cae..64a9ce57 100644 --- a/src/utils/matrix/Matrix.hh +++ b/src/utils/matrix/Matrix.hh @@ -17,13 +17,11 @@ #ifndef PLAIN_MATRIX_H #define PLAIN_MATRIX_H -#include "utils/CppPyWrapper.hh" - namespace OrbitUtils{ /** A class for plain NxM matrices with double values. */ - class Matrix : public CppPyWrapper + class Matrix { public: diff --git a/src/utils/matrix/wrap_matrix.cc b/src/utils/matrix/wrap_matrix.cc index 609ce3a2..581b0c75 100644 --- a/src/utils/matrix/wrap_matrix.cc +++ b/src/utils/matrix/wrap_matrix.cc @@ -51,7 +51,7 @@ extern "C" { Matrix* mtrx = (Matrix*)(((pyORBIT_Object*) pyIn)->cpp_obj); self->cpp_obj = new Matrix(mtrx->rows(),mtrx->columns()); mtrx->copyTo((Matrix*) self->cpp_obj); - ((Matrix*) self->cpp_obj)->setPyWrapper((PyObject*) self); + pyorbit::registerPyWrapper(self->cpp_obj, (PyObject*) self); return 0; } if(nArgs == 2){ @@ -60,7 +60,7 @@ extern "C" { error("PyMatrix - Matrix(n,m) - a maririx size is needed."); } self->cpp_obj = new Matrix(n,m); - ((Matrix*) self->cpp_obj)->setPyWrapper((PyObject*) self); + pyorbit::registerPyWrapper(self->cpp_obj, (PyObject*) self); } return 0; } @@ -68,8 +68,9 @@ extern "C" { //----------------------------------------------------- //destructor for python Matrix class (__del__ method). //----------------------------------------------------- - static void Matrix_del(pyORBIT_Object* self){ + static void Matrix_del(pyORBIT_Object* self){ //std::cerr<<"The Matrix __del__ has been called!"<cpp_obj, (PyObject*) self); delete ((Matrix*)self->cpp_obj); self->ob_base.ob_type->tp_free((PyObject*)self); } diff --git a/src/utils/wrap_field_source_container.cc b/src/utils/wrap_field_source_container.cc index 9389ece3..6f3484d8 100644 --- a/src/utils/wrap_field_source_container.cc +++ b/src/utils/wrap_field_source_container.cc @@ -15,6 +15,11 @@ using namespace OrbitUtils; namespace wrap_field_source_container{ + typedef struct { + PyObject_HEAD + void* cpp_obj; + PyObject* sources; + } pyORBIT_FieldSourceContainer; void error(const char* msg){ ORBIT_MPI_Finalize(msg); } @@ -26,27 +31,36 @@ extern "C" { //constructor for python class wrapping CppFieldSource instance //It never will be called directly static PyObject* FieldSourceContainer_new(PyTypeObject *type, PyObject *args, PyObject *kwds){ - pyORBIT_Object* self; - self = (pyORBIT_Object *) type->tp_alloc(type, 0); + pyORBIT_FieldSourceContainer* self; + self = (pyORBIT_FieldSourceContainer *) type->tp_alloc(type, 0); self->cpp_obj = NULL; + self->sources = NULL; return (PyObject *) self; } //this is implementation of the __init__ method - static int FieldSourceContainer_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ + static int FieldSourceContainer_init(pyORBIT_FieldSourceContainer *self, PyObject *args, PyObject *kwds){ self->cpp_obj = new FieldSourceContainer(); - ((FieldSourceContainer*) self->cpp_obj)->setPyWrapper((PyObject*) self); + self->sources = PyList_New(0); + if(self->sources == NULL) { + delete ((FieldSourceContainer*) self->cpp_obj); + self->cpp_obj = NULL; + return -1; + } + pyorbit::registerPyWrapper(self->cpp_obj, (PyObject*) self); return 0; } static PyObject* FieldSourceContainer_AddFieldSource(PyObject *self, PyObject *args){ - FieldSourceContainer* cpp_FieldSourceContainer = (FieldSourceContainer*)((pyORBIT_Object*) self)->cpp_obj; + pyORBIT_FieldSourceContainer* container = (pyORBIT_FieldSourceContainer*) self; + FieldSourceContainer* cpp_FieldSourceContainer = (FieldSourceContainer*) container->cpp_obj; BaseFieldSource* fs; PyObject* pyfs; if(!PyArg_ParseTuple( args,"O:",&pyfs)) error(" AddFieldSource(BaseFieldSource fs) - parameter is needed"); else { fs = (BaseFieldSource*) ((pyORBIT_Object*) pyfs)->cpp_obj; + if(PyList_Append(container->sources, pyfs) < 0) return NULL; cpp_FieldSourceContainer->AddFieldSource(fs); } Py_INCREF(Py_None); @@ -68,9 +82,11 @@ extern "C" { //----------------------------------------------------- //destructor for python FieldSourceContainer class (__del__ method). //----------------------------------------------------- - static void FieldSourceContainer_del(pyORBIT_Object* self){ + static void FieldSourceContainer_del(pyORBIT_FieldSourceContainer* self){ //std::cerr<<"The FieldSourceContainer __del__ has been called!"<cpp_obj, (PyObject*) self); delete ((FieldSourceContainer*)self->cpp_obj); + Py_CLEAR(self->sources); self->ob_base.ob_type->tp_free((PyObject*)self); } @@ -93,7 +109,7 @@ extern "C" { static PyTypeObject pyORBIT_FieldSourceContainer_Type = { PyVarObject_HEAD_INIT(NULL, 0) "FieldSourceContainer", /*tp_name*/ - sizeof(pyORBIT_Object), /*tp_basicsize*/ + sizeof(pyORBIT_FieldSourceContainer), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor) FieldSourceContainer_del , /*tp_dealloc*/ 0, /*tp_print*/ diff --git a/src/utils/wrap_py_base_field_source.cc b/src/utils/wrap_py_base_field_source.cc index 9a8a2178..1f3ec90d 100644 --- a/src/utils/wrap_py_base_field_source.cc +++ b/src/utils/wrap_py_base_field_source.cc @@ -37,6 +37,7 @@ extern "C" { //this is implementation of the __init__ method static int PyBaseFieldSource_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ self->cpp_obj = new PyBaseFieldSource((PyObject*) self); + pyorbit::registerPyWrapper(self->cpp_obj, (PyObject*) self); return 0; } @@ -45,6 +46,7 @@ extern "C" { //----------------------------------------------------- static void PyBaseFieldSource_del(pyORBIT_Object* self){ //std::cerr<<"The PyBaseFieldSource __del__ has been called!"<cpp_obj, (PyObject*) self); delete ((PyBaseFieldSource*)self->cpp_obj); self->ob_base.ob_type->tp_free((PyObject*)self); } From 0174d93291e8b7012ed23d3447ec10a2fb0d95da Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 11 Sep 2026 15:26:31 -0400 Subject: [PATCH 22/33] fix(fields): initialize transform copy indices --- src/utils/field_sources/ShiftedFieldSource.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/field_sources/ShiftedFieldSource.cc b/src/utils/field_sources/ShiftedFieldSource.cc index 4101fb8d..842fad81 100644 --- a/src/utils/field_sources/ShiftedFieldSource.cc +++ b/src/utils/field_sources/ShiftedFieldSource.cc @@ -141,8 +141,8 @@ void ShiftedFieldSource::setCoordsTransformMatrix(Matrix* coordTransformM4x4_In) ownedCoordTransformM4x4.reset(); coordTransformM4x4 = coordTransformM4x4_In; - for(int ind_x; ind_x < 3; ind_x++){ - for(int ind_y; ind_y < 3; ind_y++){ + for(int ind_x = 0; ind_x < 3; ind_x++){ + for(int ind_y = 0; ind_y < 3; ind_y++){ coordTransformM3x3->getArray()[ind_x][ind_y] = coordTransformM4x4->getArray()[ind_x][ind_y]; } } From 56cbb3ee9ed7586e15ea9f5eac8a1b5a73638856 Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 11 Sep 2026 15:29:57 -0400 Subject: [PATCH 23/33] refactor(rk4): move effect ownership to bindings --- src/trackerrk4/ExtEffectsContainer.cc | 13 -------- src/trackerrk4/ExtEffectsContainer.hh | 6 +--- src/trackerrk4/ExternalEffects.hh | 4 +-- src/trackerrk4/PyExternalEffects.cc | 17 ++++------ src/trackerrk4/PyExternalEffects.hh | 3 +- src/trackerrk4/wrap_ext_effects_container.cc | 35 +++++++++++++------- src/trackerrk4/wrap_py_external_effects.cc | 2 ++ 7 files changed, 35 insertions(+), 45 deletions(-) diff --git a/src/trackerrk4/ExtEffectsContainer.cc b/src/trackerrk4/ExtEffectsContainer.cc index c876553c..b35c04d3 100644 --- a/src/trackerrk4/ExtEffectsContainer.cc +++ b/src/trackerrk4/ExtEffectsContainer.cc @@ -37,22 +37,9 @@ ExtEffectsContainer::ExtEffectsContainer(){ } ExtEffectsContainer::~ExtEffectsContainer(){ - - for (int i=0;igetPyWrapper() == NULL){ - delete ref[i]; - } else { - Py_XDECREF(ref[i]->getPyWrapper()); - } - } - } void ExtEffectsContainer::AddEffect(ExternalEffects* eff) { - if(eff->getPyWrapper() != NULL){ - Py_INCREF(eff->getPyWrapper()); - } - ref.push_back(eff); ref_setup.push_back(eff); diff --git a/src/trackerrk4/ExtEffectsContainer.hh b/src/trackerrk4/ExtEffectsContainer.hh index 1845be6c..0320f9c6 100644 --- a/src/trackerrk4/ExtEffectsContainer.hh +++ b/src/trackerrk4/ExtEffectsContainer.hh @@ -1,10 +1,6 @@ #ifndef EXTEFFECTSCONTAINER_HH_ #define EXTEFFECTSCONTAINER_HH_ - - -#include - #include "trackerrk4/ExternalEffects.hh" #include @@ -25,7 +21,7 @@ using namespace OrbitUtils; /** Destructor. */ ~ExtEffectsContainer(); - /** Adds the instance of the ExternalEffects class to the container. */ + /** Adds a non-owning external-effects reference to the container. */ void AddEffect(ExternalEffects* eff); /** It initializes effects. */ diff --git a/src/trackerrk4/ExternalEffects.hh b/src/trackerrk4/ExternalEffects.hh index 57b252ac..f1ad6daf 100644 --- a/src/trackerrk4/ExternalEffects.hh +++ b/src/trackerrk4/ExternalEffects.hh @@ -19,13 +19,11 @@ #include "orbit/Bunch.hh" #include "utils/BaseFieldSource.hh" -#include "utils/CppPyWrapper.hh" - namespace TrackerRK4{ class RungeKuttaTracker; - class ExternalEffects: public OrbitUtils::CppPyWrapper + class ExternalEffects { //-------------------------------------------------- // public methods of the ExternalEffects class diff --git a/src/trackerrk4/PyExternalEffects.cc b/src/trackerrk4/PyExternalEffects.cc index a24e86b2..25b1364b 100644 --- a/src/trackerrk4/PyExternalEffects.cc +++ b/src/trackerrk4/PyExternalEffects.cc @@ -40,7 +40,7 @@ using namespace OrbitUtils; PyExternalEffects::PyExternalEffects(PyObject* py_wrapperIn) { setName("PyExternalEffects"); - setPyWrapper(py_wrapperIn); + py_wrapper = py_wrapperIn; } PyExternalEffects::~PyExternalEffects() @@ -48,24 +48,21 @@ PyExternalEffects::~PyExternalEffects() } void PyExternalEffects::setupEffects(Bunch* bunch){ - PyObject* py_wrp = getPyWrapper(); PyObject* py_bunch = pyorbit::getPyWrapper(bunch); - PyObject* res_tuple = PyObject_CallMethod(py_wrp,const_cast("setupEffects"),const_cast("O"),py_bunch); + PyObject* res_tuple = PyObject_CallMethod(py_wrapper,const_cast("setupEffects"),const_cast("O"),py_bunch); Py_DECREF(res_tuple); } void PyExternalEffects::prepareEffects(Bunch* bunch, double t){ - PyObject* py_wrp = getPyWrapper(); PyObject* py_bunch = pyorbit::getPyWrapper(bunch); - PyObject* res_tuple = PyObject_CallMethod(py_wrp,const_cast("prepareEffects"),const_cast("Od"),py_bunch, time); + PyObject* res_tuple = PyObject_CallMethod(py_wrapper,const_cast("prepareEffects"),const_cast("Od"),py_bunch, time); Py_DECREF(res_tuple); } void PyExternalEffects::finalizeEffects(Bunch* bunch){ - PyObject* py_wrp = getPyWrapper(); PyObject* py_bunch = pyorbit::getPyWrapper(bunch); - PyObject* res_tuple = PyObject_CallMethod(py_wrp,const_cast("finalizeEffects"),const_cast("O"),py_bunch); + PyObject* res_tuple = PyObject_CallMethod(py_wrapper,const_cast("finalizeEffects"),const_cast("O"),py_bunch); Py_DECREF(res_tuple); } @@ -74,11 +71,10 @@ void PyExternalEffects::applyEffects(Bunch* bunch, BaseFieldSource* fieldSource, RungeKuttaTracker* tracker) { - PyObject* py_wrp = getPyWrapper(); PyObject* py_bunch = pyorbit::getPyWrapper(bunch); PyObject* py_field = pyorbit::getPyWrapper(fieldSource); PyObject* py_tracker = pyorbit::getPyWrapper(tracker); - PyObject* res_tuple = PyObject_CallMethod(py_wrp,const_cast("applyEffects"),const_cast("OddOO"), + PyObject* res_tuple = PyObject_CallMethod(py_wrapper,const_cast("applyEffects"),const_cast("OddOO"), py_bunch, t,t_step, py_field, @@ -92,7 +88,6 @@ void PyExternalEffects::applyEffectsForEach(Bunch* bunch, int index, BaseFieldSource* fieldSource, RungeKuttaTracker* tracker) { - PyObject* py_wrp = getPyWrapper(); PyObject* py_bunch = pyorbit::getPyWrapper(bunch); PyObject* py_field = pyorbit::getPyWrapper(fieldSource); PyObject* py_tracker = pyorbit::getPyWrapper(tracker); @@ -100,7 +95,7 @@ void PyExternalEffects::applyEffectsForEach(Bunch* bunch, int index, y_in_vct[3],y_in_vct[4],y_in_vct[5]); PyObject* pyOutVct = Py_BuildValue("(dddddd)",y_out_vct[0],y_out_vct[1],y_out_vct[2], y_out_vct[3],y_out_vct[4],y_out_vct[5]); - PyObject* res_tuple = PyObject_CallMethod(py_wrp,const_cast("applyEffectsForEach"),const_cast("OiOOddOO"), + PyObject* res_tuple = PyObject_CallMethod(py_wrapper,const_cast("applyEffectsForEach"),const_cast("OiOOddOO"), py_bunch, index, pyInVct,pyOutVct, diff --git a/src/trackerrk4/PyExternalEffects.hh b/src/trackerrk4/PyExternalEffects.hh index 219e76c7..15149e1b 100644 --- a/src/trackerrk4/PyExternalEffects.hh +++ b/src/trackerrk4/PyExternalEffects.hh @@ -67,7 +67,8 @@ namespace TrackerRK4{ OrbitUtils::BaseFieldSource* fieldSource, RungeKuttaTracker* tracker); - + private: + PyObject* py_wrapper; }; }; diff --git a/src/trackerrk4/wrap_ext_effects_container.cc b/src/trackerrk4/wrap_ext_effects_container.cc index 26750f1d..fd297bb7 100644 --- a/src/trackerrk4/wrap_ext_effects_container.cc +++ b/src/trackerrk4/wrap_ext_effects_container.cc @@ -15,6 +15,11 @@ using namespace OrbitUtils; namespace wrap_ext_effects_container{ + typedef struct { + PyObject_HEAD + void* cpp_obj; + PyObject* effects; + } pyORBIT_ExtEffectsContainer; void error(const char* msg){ ORBIT_MPI_Finalize(msg); } @@ -27,27 +32,30 @@ extern "C" { //It never will be called directly static PyObject* ExtEffectsContainer_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - pyORBIT_Object* self; - self = (pyORBIT_Object *) type->tp_alloc(type, 0); + pyORBIT_ExtEffectsContainer* self; + self = (pyORBIT_ExtEffectsContainer *) type->tp_alloc(type, 0); self->cpp_obj = NULL; + self->effects = NULL; return (PyObject *) self; } //this is implementation of the __init__ method - static int ExtEffectsContainer_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ - - + static int ExtEffectsContainer_init(pyORBIT_ExtEffectsContainer *self, PyObject *args, PyObject *kwds){ self->cpp_obj = new ExtEffectsContainer(); - ((ExtEffectsContainer*) self->cpp_obj)->setPyWrapper((PyObject*) self); - - + self->effects = PyList_New(0); + if(self->effects == NULL) { + delete ((ExtEffectsContainer*) self->cpp_obj); + self->cpp_obj = NULL; + return -1; + } + pyorbit::registerPyWrapper(self->cpp_obj, (PyObject*) self); return 0; } static PyObject* ExtEffectsContainer_AddEffect(PyObject *self, PyObject *args){ - - ExtEffectsContainer* cpp_ExtEffectsContainer = (ExtEffectsContainer*)((pyORBIT_Object*) self)->cpp_obj; + pyORBIT_ExtEffectsContainer* container = (pyORBIT_ExtEffectsContainer*) self; + ExtEffectsContainer* cpp_ExtEffectsContainer = (ExtEffectsContainer*) container->cpp_obj; ExternalEffects* extEf; PyObject* pyExtEffects; @@ -56,6 +64,7 @@ extern "C" { error(" AddEffect(ExternalEffects effect) - parameter is needed"); else { extEf = (ExternalEffects*) ((pyORBIT_Object*) pyExtEffects)->cpp_obj; + if(PyList_Append(container->effects, pyExtEffects) < 0) return NULL; cpp_ExtEffectsContainer->AddEffect(extEf); } @@ -67,8 +76,10 @@ extern "C" { //----------------------------------------------------- //destructor for python ExtEffectsContainer class (__del__ method). //----------------------------------------------------- - static void ExtEffectsContainer_del(pyORBIT_Object* self){ + static void ExtEffectsContainer_del(pyORBIT_ExtEffectsContainer* self){ + pyorbit::unregisterPyWrapper(self->cpp_obj, (PyObject*) self); delete ((ExtEffectsContainer*)self->cpp_obj); + Py_CLEAR(self->effects); self->ob_base.ob_type->tp_free((PyObject*)self); } @@ -89,7 +100,7 @@ extern "C" { static PyTypeObject pyORBIT_ExtEffectsContainer_Type = { PyVarObject_HEAD_INIT(NULL, 0) "ExtEffectsContainer", /*tp_name*/ - sizeof(pyORBIT_Object), /*tp_basicsize*/ + sizeof(pyORBIT_ExtEffectsContainer), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor) ExtEffectsContainer_del , /*tp_dealloc*/ 0, /*tp_print*/ diff --git a/src/trackerrk4/wrap_py_external_effects.cc b/src/trackerrk4/wrap_py_external_effects.cc index 62f12d6c..635ef11e 100644 --- a/src/trackerrk4/wrap_py_external_effects.cc +++ b/src/trackerrk4/wrap_py_external_effects.cc @@ -38,6 +38,7 @@ extern "C" { //this is implementation of the __init__ method static int PyExternalEffects_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ self->cpp_obj = new PyExternalEffects((PyObject*) self); + pyorbit::registerPyWrapper(self->cpp_obj, (PyObject*) self); return 0; } @@ -61,6 +62,7 @@ extern "C" { //----------------------------------------------------- static void PyExternalEffects_del(pyORBIT_Object* self){ //std::cerr<<"The PyExternalEffects __del__ has been called!"<cpp_obj, (PyObject*) self); delete ((PyExternalEffects*)self->cpp_obj); self->ob_base.ob_type->tp_free((PyObject*)self); } From 90b6d53be7c9dd0463530110177b911cf93b72e8 Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 11 Sep 2026 15:31:14 -0400 Subject: [PATCH 24/33] fix(rk4): pass preparation time to callback --- src/trackerrk4/PyExternalEffects.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/trackerrk4/PyExternalEffects.cc b/src/trackerrk4/PyExternalEffects.cc index 25b1364b..d390cff6 100644 --- a/src/trackerrk4/PyExternalEffects.cc +++ b/src/trackerrk4/PyExternalEffects.cc @@ -55,7 +55,7 @@ void PyExternalEffects::setupEffects(Bunch* bunch){ void PyExternalEffects::prepareEffects(Bunch* bunch, double t){ PyObject* py_bunch = pyorbit::getPyWrapper(bunch); - PyObject* res_tuple = PyObject_CallMethod(py_wrapper,const_cast("prepareEffects"),const_cast("Od"),py_bunch, time); + PyObject* res_tuple = PyObject_CallMethod(py_wrapper,const_cast("prepareEffects"),const_cast("Od"),py_bunch, t); Py_DECREF(res_tuple); } From 569835e5fba19414812f69d859eb868952fc321f Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 11 Sep 2026 15:38:38 -0400 Subject: [PATCH 25/33] refactor(apertures): move shape ownership to bindings --- src/orbit/Apertures/BaseAperture.cc | 16 +------ src/orbit/Apertures/BaseAperture.hh | 7 +-- src/orbit/Apertures/BaseApertureShape.cc | 2 +- src/orbit/Apertures/BaseApertureShape.hh | 5 +-- src/orbit/Apertures/CompositeApertureShape.cc | 7 --- src/orbit/Apertures/CompositeApertureShape.hh | 5 +-- src/orbit/Apertures/PyBaseApertureShape.cc | 6 +-- src/orbit/Apertures/PyBaseApertureShape.hh | 8 ++-- src/orbit/Apertures/wrap_BaseAperture.cc | 36 +++++++++------ .../Apertures/wrap_CompositeApertureShape.cc | 45 ++++++++++--------- .../Apertures/wrap_ConvexApertureShape.cc | 3 +- .../Apertures/wrap_PrimitiveApertureShape.cc | 3 +- .../Apertures/wrap_PyBaseApertureShape.cc | 5 ++- 13 files changed, 69 insertions(+), 79 deletions(-) diff --git a/src/orbit/Apertures/BaseAperture.cc b/src/orbit/Apertures/BaseAperture.cc index ee73d5f8..b316958e 100644 --- a/src/orbit/Apertures/BaseAperture.cc +++ b/src/orbit/Apertures/BaseAperture.cc @@ -24,7 +24,7 @@ /////////////////////////////////////////////////////////////////////////// /** BaseAperture constructor */ -BaseAperture::BaseAperture(): CppPyWrapper(NULL) +BaseAperture::BaseAperture() { apertureName = "no_name"; isActive = 1; @@ -36,9 +36,6 @@ BaseAperture::BaseAperture(): CppPyWrapper(NULL) /** BaseAperture decstructor */ BaseAperture::~BaseAperture() { - if(apertureShape != NULL){ - Py_XDECREF(apertureShape->getPyWrapper()); - } } /** Returns aperture shape */ @@ -55,18 +52,7 @@ void BaseAperture::setApertureShape(BaseApertureShape* apertureShapeIn){ return; } - if( ((PyObject*) apertureShapeIn->getPyWrapper()) == NULL){ - ORBIT_MPI_Finalize("BaseAperture class setApertureShape(...): BaseApertureShape Python class needed! Stop."); - } - - if(apertureShape != NULL){ - if( ((PyObject*) apertureShape->getPyWrapper()) != NULL){ - Py_XDECREF( (PyObject*) apertureShape->getPyWrapper()); - } - } - apertureShape = apertureShapeIn; - Py_INCREF((PyObject*) apertureShape->getPyWrapper()); } /** diff --git a/src/orbit/Apertures/BaseAperture.hh b/src/orbit/Apertures/BaseAperture.hh index f9453002..a4565dbc 100644 --- a/src/orbit/Apertures/BaseAperture.hh +++ b/src/orbit/Apertures/BaseAperture.hh @@ -5,9 +5,6 @@ #include "orbit/Bunch.hh" #include "orbit/Apertures/BaseApertureShape.hh" -//pyORBIT utils -#include "utils/CppPyWrapper.hh" - using namespace std; /////////////////////////////////////////////////////////////////////////// @@ -29,7 +26,7 @@ using namespace std; of particle's coordinates. */ -class BaseAperture: public OrbitUtils::CppPyWrapper +class BaseAperture { public: @@ -42,7 +39,7 @@ public: /** Returns aperture shape */ BaseApertureShape* getApertureShape(); - /** Sets aperture shape */ + /** Sets a borrowed aperture shape. The caller retains ownership. */ void setApertureShape(BaseApertureShape* apertureShape); /** Routine for transfering particles through a aperture */ diff --git a/src/orbit/Apertures/BaseApertureShape.cc b/src/orbit/Apertures/BaseApertureShape.cc index 1f706c57..3d802d42 100644 --- a/src/orbit/Apertures/BaseApertureShape.cc +++ b/src/orbit/Apertures/BaseApertureShape.cc @@ -20,7 +20,7 @@ /////////////////////////////////////////////////////////////////////////// /** BaseApertureShape constructor */ -BaseApertureShape::BaseApertureShape(): CppPyWrapper(NULL) +BaseApertureShape::BaseApertureShape() { shapeName = "no_shape"; typeName = "no_type"; diff --git a/src/orbit/Apertures/BaseApertureShape.hh b/src/orbit/Apertures/BaseApertureShape.hh index f9cd839d..9a74965e 100644 --- a/src/orbit/Apertures/BaseApertureShape.hh +++ b/src/orbit/Apertures/BaseApertureShape.hh @@ -5,9 +5,6 @@ #include "orbit/Bunch.hh" #include "orbit/Apertures/BaseApertureShape.hh" -//pyORBIT utils -#include "utils/CppPyWrapper.hh" - using namespace std; /////////////////////////////////////////////////////////////////////////// @@ -26,7 +23,7 @@ using namespace std; It defines the interface for BaseApertureShape subclasses. */ -class BaseApertureShape: public OrbitUtils::CppPyWrapper +class BaseApertureShape { public: diff --git a/src/orbit/Apertures/CompositeApertureShape.cc b/src/orbit/Apertures/CompositeApertureShape.cc index a9bb87a0..4729246a 100644 --- a/src/orbit/Apertures/CompositeApertureShape.cc +++ b/src/orbit/Apertures/CompositeApertureShape.cc @@ -32,12 +32,6 @@ CompositeApertureShape::CompositeApertureShape(): BaseApertureShape() /** CompositeApertureShape decstructor */ CompositeApertureShape::~CompositeApertureShape() { - int n_shapes = apertureShapes.size(); - for(int ind = 0; ind < n_shapes; ind++){ - if(apertureShapes[ind]->getPyWrapper() != NULL){ - Py_XDECREF((PyObject*) apertureShapes[ind]->getPyWrapper()); - } - } } /** Return 1 if the particular macro-particle is inside this shape */ @@ -59,7 +53,6 @@ int CompositeApertureShape::inside(Bunch* bunch, int count){ void CompositeApertureShape::addApertureShape(BaseApertureShape* apertureShape) { apertureShapes.push_back(apertureShape); - Py_INCREF((PyObject*) apertureShape->getPyWrapper()); } /** Returns vector of pointers to aperture shapes that are in this collection */ diff --git a/src/orbit/Apertures/CompositeApertureShape.hh b/src/orbit/Apertures/CompositeApertureShape.hh index bc15f88d..413f6002 100644 --- a/src/orbit/Apertures/CompositeApertureShape.hh +++ b/src/orbit/Apertures/CompositeApertureShape.hh @@ -1,9 +1,6 @@ #ifndef COMPOSITE_APERTURE_SHAPE_H #define COMPOSITE_APERTURE_SHAPE_H -//pyORBIT utils -#include "utils/CppPyWrapper.hh" - #include "orbit/Bunch.hh" #include "orbit/Apertures/BaseApertureShape.hh" @@ -39,7 +36,7 @@ public: /** Return 1 if the particular macro-particle is inside this shape */ int inside(Bunch* bunch, int count); - /** Adds the new aperture shape to the collection */ + /** Adds a non-owning aperture-shape reference to the collection. */ void addApertureShape(BaseApertureShape* apertureShape); diff --git a/src/orbit/Apertures/PyBaseApertureShape.cc b/src/orbit/Apertures/PyBaseApertureShape.cc index 28b927c6..f935a4d9 100644 --- a/src/orbit/Apertures/PyBaseApertureShape.cc +++ b/src/orbit/Apertures/PyBaseApertureShape.cc @@ -23,8 +23,9 @@ /////////////////////////////////////////////////////////////////////////// /** PyBaseApertureShape constructor */ -PyBaseApertureShape::PyBaseApertureShape(): BaseApertureShape() +PyBaseApertureShape::PyBaseApertureShape(PyObject* py_wrapper): BaseApertureShape() { + this->py_wrapper = py_wrapper; shapeName = "python_class_shape"; typeName = "python_class_shape"; } @@ -39,12 +40,11 @@ int PyBaseApertureShape::inside(Bunch* bunch, int count){ double** coord = bunch->coordArr(); - PyObject* py_wrp = getPyWrapper(); PyObject* py_bunch = pyorbit::getPyWrapper(bunch); int res_isinside = 0; - PyObject* py_res = PyObject_CallMethod(py_wrp,const_cast("inside"),const_cast("Oi"),py_bunch,count); + PyObject* py_res = PyObject_CallMethod(py_wrapper,const_cast("inside"),const_cast("Oi"),py_bunch,count); res_isinside = (int) PyLong_AS_LONG(py_res); diff --git a/src/orbit/Apertures/PyBaseApertureShape.hh b/src/orbit/Apertures/PyBaseApertureShape.hh index e8098c47..f113e168 100644 --- a/src/orbit/Apertures/PyBaseApertureShape.hh +++ b/src/orbit/Apertures/PyBaseApertureShape.hh @@ -1,8 +1,7 @@ #ifndef PY_BASE_APERTURE_SHAPE_H #define PY_BASE_APERTURE_SHAPE_H -//pyORBIT utils -#include "utils/CppPyWrapper.hh" +#include #include "orbit/Bunch.hh" #include "orbit/Apertures/BaseApertureShape.hh" @@ -32,7 +31,7 @@ class PyBaseApertureShape: public BaseApertureShape public: /** PyBaseApertureShape constructor */ - PyBaseApertureShape(); + PyBaseApertureShape(PyObject* py_wrapper); /** PyBaseApertureShape decstructor */ virtual ~PyBaseApertureShape(); @@ -40,6 +39,9 @@ public: /** Return 1 if the particular macro-particle is inside this shape */ int inside(Bunch* bunch, int count); +private: + PyObject* py_wrapper; + }; //end of PY_BASE_APERTURE_SHAPE_H ifdef diff --git a/src/orbit/Apertures/wrap_BaseAperture.cc b/src/orbit/Apertures/wrap_BaseAperture.cc index 4132af25..d16edd80 100644 --- a/src/orbit/Apertures/wrap_BaseAperture.cc +++ b/src/orbit/Apertures/wrap_BaseAperture.cc @@ -9,6 +9,11 @@ #include "orbit/Apertures/BaseApertureShape.hh" namespace wrap_base_aperture{ + typedef struct { + PyObject_HEAD + void* cpp_obj; + PyObject* shape; + } pyORBIT_BaseAperture; #ifdef __cplusplus extern "C" { @@ -19,26 +24,31 @@ extern "C" { It never will be called directly. */ static PyObject* BaseAperture_new(PyTypeObject *type, PyObject *args, PyObject *kwds){ - pyORBIT_Object* self; - self = (pyORBIT_Object *) type->tp_alloc(type, 0); + pyORBIT_BaseAperture* self; + self = (pyORBIT_BaseAperture *) type->tp_alloc(type, 0); self->cpp_obj = NULL; + self->shape = NULL; return (PyObject *) self; } /** This is implementation of the __init__ method */ - static int BaseAperture_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ + static int BaseAperture_init(pyORBIT_BaseAperture *self, PyObject *args, PyObject *kwds){ self->cpp_obj = new BaseAperture(); - ((BaseAperture*) self->cpp_obj)->setPyWrapper((PyObject*) self); + pyorbit::registerPyWrapper(self->cpp_obj, (PyObject*) self); return 0; } /** Sets the pyBaseApertureShape object for inside(...) method */ static PyObject* BaseAperture_setApertureShape(PyObject *self, PyObject *args){ - BaseAperture* cpp_BaseAperture = (BaseAperture*)((pyORBIT_Object*) self)->cpp_obj; + pyORBIT_BaseAperture* aperture = (pyORBIT_BaseAperture*) self; + BaseAperture* cpp_BaseAperture = (BaseAperture*) aperture->cpp_obj; PyObject* pyBaseApertureShape; if(!PyArg_ParseTuple(args,"O:setApertureShape",&pyBaseApertureShape)){ ORBIT_MPI_Finalize("BaseAperture - setApertureShape(BaseApertureShape) - parameter is needed. Stop."); } + Py_INCREF(pyBaseApertureShape); + Py_XDECREF(aperture->shape); + aperture->shape = pyBaseApertureShape; cpp_BaseAperture->setApertureShape((BaseApertureShape*) ((pyORBIT_Object*) pyBaseApertureShape)->cpp_obj); Py_INCREF(Py_None); return Py_None; @@ -46,15 +56,13 @@ extern "C" { /** Returns the pyBaseApertureShape object for inside(...) method */ static PyObject* BaseAperture_getApertureShape(PyObject *self, PyObject *args){ - BaseAperture* cpp_BaseAperture = (BaseAperture*)((pyORBIT_Object*) self)->cpp_obj; - BaseApertureShape* baseApertureShape = cpp_BaseAperture->getApertureShape(); - if(baseApertureShape == NULL){ + pyORBIT_BaseAperture* aperture = (pyORBIT_BaseAperture*) self; + if(aperture->shape == NULL){ Py_INCREF(Py_None); return Py_None; } - PyObject* pyBaseApertureShape = baseApertureShape->getPyWrapper(); - Py_INCREF(pyBaseApertureShape); - return pyBaseApertureShape; + Py_INCREF(aperture->shape); + return aperture->shape; } /** Performs the collimation tracking of the bunch */ @@ -149,9 +157,11 @@ extern "C" { //----------------------------------------------------- //destructor for python BaseAperture class (__del__ method). //----------------------------------------------------- - static void BaseAperture_del(pyORBIT_Object* self){ + static void BaseAperture_del(pyORBIT_BaseAperture* self){ //std::cerr<<"The BaseAperture __del__ has been called!"<cpp_obj, (PyObject*) self); delete ((BaseAperture*)self->cpp_obj); + Py_CLEAR(self->shape); self->ob_base.ob_type->tp_free((PyObject*)self); } @@ -177,7 +187,7 @@ extern "C" { static PyTypeObject pyORBIT_BaseAperture_Type = { PyVarObject_HEAD_INIT(NULL, 0) "BaseAperture", /*tp_name*/ - sizeof(pyORBIT_Object), /*tp_basicsize*/ + sizeof(pyORBIT_BaseAperture), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor) BaseAperture_del , /*tp_dealloc*/ 0, /*tp_print*/ diff --git a/src/orbit/Apertures/wrap_CompositeApertureShape.cc b/src/orbit/Apertures/wrap_CompositeApertureShape.cc index 7735cb48..e19f370d 100644 --- a/src/orbit/Apertures/wrap_CompositeApertureShape.cc +++ b/src/orbit/Apertures/wrap_CompositeApertureShape.cc @@ -8,6 +8,11 @@ #include "orbit/Apertures/CompositeApertureShape.hh" namespace wrap_py_composite_aperture_shape{ + typedef struct { + PyObject_HEAD + void* cpp_obj; + PyObject* shapes; + } pyORBIT_CompositeApertureShape; #ifdef __cplusplus extern "C" { @@ -17,16 +22,23 @@ extern "C" { Constructor for python class wrapping c++ Circle, Ellipse, and Rectangular ApertureShape instances. */ static PyObject* CompositeApertureShape_new(PyTypeObject *type, PyObject *args, PyObject *kwds){ - pyORBIT_Object* self; - self = (pyORBIT_Object *) type->tp_alloc(type, 0); + pyORBIT_CompositeApertureShape* self; + self = (pyORBIT_CompositeApertureShape *) type->tp_alloc(type, 0); self->cpp_obj = NULL; + self->shapes = NULL; return (PyObject *) self; } /** This is implementation of the __init__ method */ - static int CompositeApertureShape_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ + static int CompositeApertureShape_init(pyORBIT_CompositeApertureShape *self, PyObject *args, PyObject *kwds){ self->cpp_obj = (pyORBIT_Object*) new CompositeApertureShape(); - ((BaseApertureShape*) self->cpp_obj)->setPyWrapper((PyObject*) self); + self->shapes = PyList_New(0); + if(self->shapes == NULL) { + delete ((CompositeApertureShape*) self->cpp_obj); + self->cpp_obj = NULL; + return -1; + } + pyorbit::registerPyWrapper(self->cpp_obj, (PyObject*) self); return 0; } @@ -58,12 +70,13 @@ extern "C" { // addApertureShape() - adds the ApertureShape instance to composite static PyObject* CompositeApertureShape_addApertureShape(PyObject *self, PyObject *args){ - pyORBIT_Object* pyCompositeApertureShape= (pyORBIT_Object*) self; - CompositeApertureShape* cpp_CompositeApertureShape = (CompositeApertureShape*) pyCompositeApertureShape->cpp_obj; + pyORBIT_CompositeApertureShape* composite = (pyORBIT_CompositeApertureShape*) self; + CompositeApertureShape* cpp_CompositeApertureShape = (CompositeApertureShape*) composite->cpp_obj; PyObject* pyBaseApertureShape; if(!PyArg_ParseTuple(args,"O:setApertureShape",&pyBaseApertureShape)){ ORBIT_MPI_Finalize("CompositeApertureShape.addApertureShape(BaseApertureShape) - parameter is needed. Stop."); } + if(PyList_Append(composite->shapes, pyBaseApertureShape) < 0) return NULL; cpp_CompositeApertureShape->addApertureShape((BaseApertureShape*) ((pyORBIT_Object*) pyBaseApertureShape)->cpp_obj); Py_INCREF(Py_None); return Py_None; @@ -71,26 +84,18 @@ extern "C" { // getApertureShapes() - returns the ApertureShape instances inside the composite static PyObject* CompositeApertureShape_getApertureShapes(PyObject *self, PyObject *args){ - pyORBIT_Object* pyCompositeApertureShape= (pyORBIT_Object*) self; - CompositeApertureShape* cpp_CompositeApertureShape = (CompositeApertureShape*) pyCompositeApertureShape->cpp_obj; - std::vector apertureShapes = cpp_CompositeApertureShape->getApertureShape(); - //create tuple with apertureShapes - PyObject* resTuple = PyTuple_New(apertureShapes.size()); - for(int i = 0, n = apertureShapes.size(); i < n; i++){ - PyObject* py_nm = apertureShapes[i]->getPyWrapper(); - if(PyTuple_SetItem(resTuple,i,py_nm)){ - ORBIT_MPI_Finalize("CompositeApertureShape.getApertureShapes(...) - cannot add the ApertureShape instance to composite"); - } - } - return resTuple; + pyORBIT_CompositeApertureShape* composite = (pyORBIT_CompositeApertureShape*) self; + return PyList_AsTuple(composite->shapes); } //----------------------------------------------------- //destructor for python CompositeApertureShape class (__del__ method). //----------------------------------------------------- - static void CompositeApertureShape_del(pyORBIT_Object* self){ + static void CompositeApertureShape_del(pyORBIT_CompositeApertureShape* self){ //std::cerr<<"debug CompositeApertureShape __del__ has been called!"<cpp_obj, (PyObject*) self); delete ((BaseApertureShape*)self->cpp_obj); + Py_CLEAR(self->shapes); self->ob_base.ob_type->tp_free((PyObject*)self); } @@ -113,7 +118,7 @@ extern "C" { static PyTypeObject pyORBIT_CompositeApertureShape_Type = { PyVarObject_HEAD_INIT(NULL, 0) "CompositeApertureShape", /*tp_name*/ - sizeof(pyORBIT_Object), /*tp_basicsize*/ + sizeof(pyORBIT_CompositeApertureShape), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor) CompositeApertureShape_del , /*tp_dealloc*/ 0, /*tp_print*/ diff --git a/src/orbit/Apertures/wrap_ConvexApertureShape.cc b/src/orbit/Apertures/wrap_ConvexApertureShape.cc index 5c27656f..184646be 100644 --- a/src/orbit/Apertures/wrap_ConvexApertureShape.cc +++ b/src/orbit/Apertures/wrap_ConvexApertureShape.cc @@ -26,7 +26,7 @@ extern "C" { /** This is implementation of the __init__ method */ static int ConvexApertureShape_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ self->cpp_obj = new ConvexApertureShape(); - ((BaseApertureShape*) self->cpp_obj)->setPyWrapper((PyObject*) self); + pyorbit::registerPyWrapper(self->cpp_obj, (PyObject*) self); return 0; } @@ -132,6 +132,7 @@ extern "C" { //destructor for python ConvexApertureShape class (__del__ method). //----------------------------------------------------- static void ConvexApertureShape_del(pyORBIT_Object* self){ + pyorbit::unregisterPyWrapper(self->cpp_obj, (PyObject*) self); delete ((ConvexApertureShape*) self->cpp_obj); self->ob_base.ob_type->tp_free((PyObject*)self); } diff --git a/src/orbit/Apertures/wrap_PrimitiveApertureShape.cc b/src/orbit/Apertures/wrap_PrimitiveApertureShape.cc index f5c94a1e..941618c2 100644 --- a/src/orbit/Apertures/wrap_PrimitiveApertureShape.cc +++ b/src/orbit/Apertures/wrap_PrimitiveApertureShape.cc @@ -58,7 +58,7 @@ extern "C" { if(self->cpp_obj == NULL){ ORBIT_MPI_Finalize("PrimitiveApertureShape(shapeType, par1[,par2]) - shapeType should be circle,ellipse, or rectangular. Stop."); } - ((BaseApertureShape*) self->cpp_obj)->setPyWrapper((PyObject*) self); + pyorbit::registerPyWrapper(self->cpp_obj, (PyObject*) self); return 0; } @@ -198,6 +198,7 @@ extern "C" { //----------------------------------------------------- static void PrimitiveApertureShape_del(pyORBIT_Object* self){ //std::cerr<<"debug PrimitiveApertureShape __del__ has been called!"<cpp_obj, (PyObject*) self); delete ((BaseApertureShape*)self->cpp_obj); self->ob_base.ob_type->tp_free((PyObject*)self); } diff --git a/src/orbit/Apertures/wrap_PyBaseApertureShape.cc b/src/orbit/Apertures/wrap_PyBaseApertureShape.cc index 756b0a56..72246450 100644 --- a/src/orbit/Apertures/wrap_PyBaseApertureShape.cc +++ b/src/orbit/Apertures/wrap_PyBaseApertureShape.cc @@ -26,8 +26,8 @@ extern "C" { /** This is implementation of the __init__ method */ static int PyBaseApertureShape_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ - self->cpp_obj = new PyBaseApertureShape(); - ((PyBaseApertureShape*) self->cpp_obj)->setPyWrapper((PyObject*) self); + self->cpp_obj = new PyBaseApertureShape((PyObject*) self); + pyorbit::registerPyWrapper(self->cpp_obj, (PyObject*) self); return 0; } @@ -100,6 +100,7 @@ extern "C" { //----------------------------------------------------- static void PyBaseApertureShape_del(pyORBIT_Object* self){ //std::cerr<<"debug PyBaseApertureShape __del__ has been called!"<cpp_obj, (PyObject*) self); delete ((PyBaseApertureShape*)self->cpp_obj); self->ob_base.ob_type->tp_free((PyObject*)self); } From 46379cae48e2981ad167e2c9e6a61612c41b7fc4 Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 11 Sep 2026 15:48:19 -0400 Subject: [PATCH 26/33] refactor(spacecharge): move ellipsoid ownership to bindings --- src/orbit/Apertures/CircleApertureShape.hh | 3 -- src/orbit/Apertures/ConvexApertureShape.hh | 3 -- src/orbit/Apertures/EllipseApertureShape.hh | 3 -- .../Apertures/RectangularApertureShape.hh | 3 -- .../MaterialInteractions.hh | 4 -- src/spacecharge/SpaceChargeCalcUnifEllipse.cc | 6 +-- .../UniformEllipsoidFieldCalculator.cc | 3 +- .../UniformEllipsoidFieldCalculator.hh | 5 +- .../wrap_spacechargecalc_uniform_ellipse.cc | 16 +----- ...wrap_uniform_ellipsoid_field_calculator.cc | 52 +++++++++++++++---- ...wrap_uniform_ellipsoid_field_calculator.hh | 6 +++ 11 files changed, 54 insertions(+), 50 deletions(-) diff --git a/src/orbit/Apertures/CircleApertureShape.hh b/src/orbit/Apertures/CircleApertureShape.hh index dd7f23bc..ae9de27d 100644 --- a/src/orbit/Apertures/CircleApertureShape.hh +++ b/src/orbit/Apertures/CircleApertureShape.hh @@ -1,9 +1,6 @@ #ifndef CIRCULAR_APERTURE_SHAPE_H #define CIRCULAR_APERTURE_SHAPE_H -//pyORBIT utils -#include "utils/CppPyWrapper.hh" - #include "orbit/Bunch.hh" #include "orbit/Apertures/BaseApertureShape.hh" diff --git a/src/orbit/Apertures/ConvexApertureShape.hh b/src/orbit/Apertures/ConvexApertureShape.hh index 6584c791..7b69cd0b 100644 --- a/src/orbit/Apertures/ConvexApertureShape.hh +++ b/src/orbit/Apertures/ConvexApertureShape.hh @@ -1,9 +1,6 @@ #ifndef CONVEX_APERTURE_SHAPE_H #define CONVEX_APERTURE_SHAPE_H -//pyORBIT utils -#include "utils/CppPyWrapper.hh" - #include "orbit/Bunch.hh" #include "orbit/Apertures/BaseApertureShape.hh" diff --git a/src/orbit/Apertures/EllipseApertureShape.hh b/src/orbit/Apertures/EllipseApertureShape.hh index 6198c6f9..5bd1bc14 100644 --- a/src/orbit/Apertures/EllipseApertureShape.hh +++ b/src/orbit/Apertures/EllipseApertureShape.hh @@ -1,9 +1,6 @@ #ifndef ELLIPSE_APERTURE_SHAPE_H #define ELLIPSE_APERTURE_SHAPE_H -//pyORBIT utils -#include "utils/CppPyWrapper.hh" - #include "orbit/Bunch.hh" #include "orbit/Apertures/BaseApertureShape.hh" diff --git a/src/orbit/Apertures/RectangularApertureShape.hh b/src/orbit/Apertures/RectangularApertureShape.hh index 28ce0b7c..d5a461dd 100644 --- a/src/orbit/Apertures/RectangularApertureShape.hh +++ b/src/orbit/Apertures/RectangularApertureShape.hh @@ -1,9 +1,6 @@ #ifndef RECTANGULAR_APERTURE_SHAPE_H #define RECTANGULAR_APERTURE_SHAPE_H -//pyORBIT utils -#include "utils/CppPyWrapper.hh" - #include "orbit/Bunch.hh" #include "orbit/Apertures/BaseApertureShape.hh" diff --git a/src/orbit/MaterialInteractions/MaterialInteractions.hh b/src/orbit/MaterialInteractions/MaterialInteractions.hh index 09a08ee2..70cee12a 100644 --- a/src/orbit/MaterialInteractions/MaterialInteractions.hh +++ b/src/orbit/MaterialInteractions/MaterialInteractions.hh @@ -1,10 +1,6 @@ #ifndef MATERIAL_INTERACTIONS_H #define MATERIAL_INTERACTIONS_H -//pyORBIT utils -#include "utils/CppPyWrapper.hh" - - using namespace std; /** diff --git a/src/spacecharge/SpaceChargeCalcUnifEllipse.cc b/src/spacecharge/SpaceChargeCalcUnifEllipse.cc index 0a07dd4f..0a2b86a9 100644 --- a/src/spacecharge/SpaceChargeCalcUnifEllipse.cc +++ b/src/spacecharge/SpaceChargeCalcUnifEllipse.cc @@ -44,11 +44,7 @@ SpaceChargeCalcUnifEllipse::SpaceChargeCalcUnifEllipse(int nEllipses_in) SpaceChargeCalcUnifEllipse::~SpaceChargeCalcUnifEllipse(){ for(int ie = 0; ie < nEllipses; ie++){ - if(ellipsoidCalc_arr[ie]->getPyWrapper() != NULL){ - Py_DECREF(ellipsoidCalc_arr[ie]->getPyWrapper()); - } else { - delete ellipsoidCalc_arr[ie]; - } + delete ellipsoidCalc_arr[ie]; } delete [] ellipsoidCalc_arr; diff --git a/src/spacecharge/UniformEllipsoidFieldCalculator.cc b/src/spacecharge/UniformEllipsoidFieldCalculator.cc index ab5bda9f..d0a16bcc 100644 --- a/src/spacecharge/UniformEllipsoidFieldCalculator.cc +++ b/src/spacecharge/UniformEllipsoidFieldCalculator.cc @@ -5,7 +5,6 @@ //MPI Function Wrappers #include "mpi/orbit_mpi.hh" -#include "mpi/wrap_mpi_comm.hh" #include "spacecharge/UniformEllipsoidFieldCalculator.hh" #include "utils/integration/gauss_legendre_points.hh" @@ -26,7 +25,7 @@ using namespace OrbitUtils; #endif /** Constructor. There is no parameters */ -UniformEllipsoidFieldCalculator::UniformEllipsoidFieldCalculator(): CppPyWrapper(NULL) +UniformEllipsoidFieldCalculator::UniformEllipsoidFieldCalculator() { intFuncX0 = new Function(); intFuncY0 = new Function(); diff --git a/src/spacecharge/UniformEllipsoidFieldCalculator.hh b/src/spacecharge/UniformEllipsoidFieldCalculator.hh index e80fa34b..00f32865 100644 --- a/src/spacecharge/UniformEllipsoidFieldCalculator.hh +++ b/src/spacecharge/UniformEllipsoidFieldCalculator.hh @@ -1,9 +1,6 @@ #ifndef UNIFORM_SC_ELLIPSOID_HH #define UNIFORM_SC_ELLIPSOID_HH -//pyORBIT utils -#include "utils/CppPyWrapper.hh" - //Function from OrbitUtils #include "utils/OU_Function.hh" @@ -18,7 +15,7 @@ using namespace std; */ -class UniformEllipsoidFieldCalculator: public OrbitUtils::CppPyWrapper +class UniformEllipsoidFieldCalculator { public: diff --git a/src/spacecharge/wrap_spacechargecalc_uniform_ellipse.cc b/src/spacecharge/wrap_spacechargecalc_uniform_ellipse.cc index 64e0de26..a59e663f 100644 --- a/src/spacecharge/wrap_spacechargecalc_uniform_ellipse.cc +++ b/src/spacecharge/wrap_spacechargecalc_uniform_ellipse.cc @@ -3,6 +3,7 @@ #include "spacecharge/wrap_spacechargecalc_uniform_ellipse.hh" #include "spacecharge/wrap_spacecharge.hh" +#include "spacecharge/wrap_uniform_ellipsoid_field_calculator.hh" #include "orbit/wrap_bunch.hh" #include @@ -75,20 +76,7 @@ extern "C" { Py_INCREF(Py_None); return Py_None; } - if(cpp_ellipseFieldCalc->getPyWrapper() != NULL){ - Py_INCREF(cpp_ellipseFieldCalc->getPyWrapper()); - return cpp_ellipseFieldCalc->getPyWrapper(); - } - //It will create a pyUniformEllipsoidFieldCalculator object - PyObject* mod = PyImport_ImportModule("orbit.core.spacecharge"); - PyObject* pyUniformEllipsoidFieldCalculator = PyObject_CallMethod(mod,const_cast("UniformEllipsoidFieldCalculator"),const_cast("")); - //delete the c++ reference to the internal UniformEllipsoidFieldCalculator inside pyUniformEllipsoidFieldCalculator and assign the new one - delete ((UniformEllipsoidFieldCalculator*)((pyORBIT_Object*) pyUniformEllipsoidFieldCalculator)->cpp_obj); - ((pyORBIT_Object*) pyUniformEllipsoidFieldCalculator)->cpp_obj = cpp_ellipseFieldCalc; - cpp_ellipseFieldCalc->setPyWrapper(pyUniformEllipsoidFieldCalculator); - Py_INCREF(cpp_ellipseFieldCalc->getPyWrapper()); - Py_DECREF(mod); - return pyUniformEllipsoidFieldCalculator; + return wrapUniformEllipsoidFieldCalculator(cpp_ellipseFieldCalc, self); } //getNEllipses() - returns the number of ellipses inside the Space Charge calculator diff --git a/src/spacecharge/wrap_uniform_ellipsoid_field_calculator.cc b/src/spacecharge/wrap_uniform_ellipsoid_field_calculator.cc index 655b1d5d..e4c1a715 100644 --- a/src/spacecharge/wrap_uniform_ellipsoid_field_calculator.cc +++ b/src/spacecharge/wrap_uniform_ellipsoid_field_calculator.cc @@ -11,6 +11,12 @@ using namespace OrbitUtils; namespace wrap_spacecharge{ + typedef struct { + PyObject_HEAD + void* cpp_obj; + int owns_cpp; + PyObject* owner; + } pyORBIT_UniformEllipsoidFieldCalculator; #ifdef __cplusplus extern "C" { @@ -24,17 +30,20 @@ extern "C" { //It never will be called directly static PyObject* UniformEllipsoidFieldCalculator_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - pyORBIT_Object* self; - self = (pyORBIT_Object *) type->tp_alloc(type, 0); + pyORBIT_UniformEllipsoidFieldCalculator* self; + self = (pyORBIT_UniformEllipsoidFieldCalculator *) type->tp_alloc(type, 0); self->cpp_obj = NULL; + self->owns_cpp = 0; + self->owner = NULL; return (PyObject *) self; } //initializator for python UniformEllipsoidFieldCalculator class //this is implementation of the __init__ method - static int UniformEllipsoidFieldCalculator_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ + static int UniformEllipsoidFieldCalculator_init(pyORBIT_UniformEllipsoidFieldCalculator *self, PyObject *args, PyObject *kwds){ self->cpp_obj = new UniformEllipsoidFieldCalculator(); - ((UniformEllipsoidFieldCalculator*) self->cpp_obj)->setPyWrapper((PyObject*) self); + self->owns_cpp = 1; + pyorbit::registerPyWrapper(self->cpp_obj, (PyObject*) self); return 0; } @@ -69,11 +78,12 @@ extern "C" { //----------------------------------------------------- //destructor for python UniformEllipsoidFieldCalculator class (__del__ method). //----------------------------------------------------- - static void UniformEllipsoidFieldCalculator_del(pyORBIT_Object* self){ + static void UniformEllipsoidFieldCalculator_del(pyORBIT_UniformEllipsoidFieldCalculator* self){ UniformEllipsoidFieldCalculator* cpp_UniformEllipsoidFieldCalculator = (UniformEllipsoidFieldCalculator*) self->cpp_obj; - if(cpp_UniformEllipsoidFieldCalculator != NULL){ - delete cpp_UniformEllipsoidFieldCalculator; - } + pyorbit::unregisterPyWrapper(cpp_UniformEllipsoidFieldCalculator, (PyObject*) self); + if(self->owns_cpp) delete cpp_UniformEllipsoidFieldCalculator; + self->cpp_obj = NULL; + Py_CLEAR(self->owner); self->ob_base.ob_type->tp_free((PyObject*)self); } @@ -95,7 +105,7 @@ extern "C" { static PyTypeObject pyORBIT_UniformEllipsoidFieldCalculator_Type = { PyVarObject_HEAD_INIT(NULL, 0) "UniformEllipsoidFieldCalculator", /*tp_name*/ - sizeof(pyORBIT_Object), /*tp_basicsize*/ + sizeof(pyORBIT_UniformEllipsoidFieldCalculator), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor) UniformEllipsoidFieldCalculator_del , /*tp_dealloc*/ 0, /*tp_print*/ @@ -133,6 +143,30 @@ extern "C" { UniformEllipsoidFieldCalculator_new, /* tp_new */ }; + PyObject* wrapUniformEllipsoidFieldCalculator( + UniformEllipsoidFieldCalculator* calculator, + PyObject* owner + ){ + PyObject* wrapper = pyorbit::getPyWrapper(calculator); + if(wrapper != NULL){ + Py_INCREF(wrapper); + return wrapper; + } + + pyORBIT_UniformEllipsoidFieldCalculator* self = + (pyORBIT_UniformEllipsoidFieldCalculator*) + pyORBIT_UniformEllipsoidFieldCalculator_Type.tp_alloc( + &pyORBIT_UniformEllipsoidFieldCalculator_Type, 0 + ); + if(self == NULL) return NULL; + self->cpp_obj = calculator; + self->owns_cpp = 0; + self->owner = owner; + Py_XINCREF(owner); + pyorbit::registerPyWrapper(calculator, (PyObject*) self); + return (PyObject*) self; + } + //-------------------------------------------------- //Initialization function of the pyUniformEllipsoidFieldCalculator class //It will be called from SpaceCharge wrapper initialization diff --git a/src/spacecharge/wrap_uniform_ellipsoid_field_calculator.hh b/src/spacecharge/wrap_uniform_ellipsoid_field_calculator.hh index a3e783d2..2ddcbec4 100644 --- a/src/spacecharge/wrap_uniform_ellipsoid_field_calculator.hh +++ b/src/spacecharge/wrap_uniform_ellipsoid_field_calculator.hh @@ -3,12 +3,18 @@ #include +class UniformEllipsoidFieldCalculator; + #ifdef __cplusplus extern "C" { #endif namespace wrap_spacecharge{ void initUniformEllipsoidFieldCalculator(PyObject* module); + PyObject* wrapUniformEllipsoidFieldCalculator( + UniformEllipsoidFieldCalculator* calculator, + PyObject* owner + ); } #ifdef __cplusplus From 18f65fff08627d59ae4b291de627624f97e57b28 Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 11 Sep 2026 15:49:07 -0400 Subject: [PATCH 27/33] refactor(core): remove obsolete Python wrapper base --- src/meson.build | 2 -- src/utils/CppPyWrapper.cc | 39 ---------------------------- src/utils/CppPyWrapper.hh | 54 --------------------------------------- 3 files changed, 95 deletions(-) delete mode 100644 src/utils/CppPyWrapper.cc delete mode 100644 src/utils/CppPyWrapper.hh diff --git a/src/meson.build b/src/meson.build index eb7195a1..c43587dd 100644 --- a/src/meson.build +++ b/src/meson.build @@ -135,7 +135,6 @@ sources = files([ 'utils/AttributesBucket.cc', 'utils/bessel.cc', 'utils/OU_SplineCH.cc', - 'utils/CppPyWrapper.cc', 'utils/StringUtils.cc', 'utils/Random.cc', 'utils/BaseFieldSource.cc', @@ -270,7 +269,6 @@ api_headers = [ 'utils/AttributesBucket.hh', 'utils/BaseFieldSource.hh', 'utils/BufferStore.hh', - 'utils/CppPyWrapper.hh', 'utils/FieldSourceContainer.hh', 'utils/MathPolynomial.hh', 'utils/OU_Function.hh', diff --git a/src/utils/CppPyWrapper.cc b/src/utils/CppPyWrapper.cc deleted file mode 100644 index b9bae280..00000000 --- a/src/utils/CppPyWrapper.cc +++ /dev/null @@ -1,39 +0,0 @@ -//////////////////////////////// -*- C++ -*- ////////////////////////////// -// -// FILE NAME -// CppPyWrapper.cc -// -// CREATED -// 04/22/2003 -// -// DESCRIPTION -// The base class that provides capability to keep the reference to -// the Python class instance that is wrapping the c++ subclassing -// this class. -// -/////////////////////////////////////////////////////////////////////////// -#include "utils/CppPyWrapper.hh" - -using namespace OrbitUtils; - -CppPyWrapper::CppPyWrapper(PyObject* py_wrapperIn) -{ - cpp_py_wrapper = py_wrapperIn; -} - -CppPyWrapper::CppPyWrapper() -{ - cpp_py_wrapper = NULL; -} - -CppPyWrapper::~CppPyWrapper() -{ -} - -void CppPyWrapper::setPyWrapper(PyObject* py_wrapperIn){ - cpp_py_wrapper = py_wrapperIn; -} - -PyObject* CppPyWrapper::getPyWrapper(){ - return cpp_py_wrapper; -} diff --git a/src/utils/CppPyWrapper.hh b/src/utils/CppPyWrapper.hh deleted file mode 100644 index c43fa22e..00000000 --- a/src/utils/CppPyWrapper.hh +++ /dev/null @@ -1,54 +0,0 @@ -//////////////////////////////// -*- C++ -*- ////////////////////////////// -// -// FILE NAME -// CppPyWrapper.hh -// -// CREATED -// 04/22/2003 -// -// DESCRIPTION -// The base class that provides capability to keep the reference to -// the Python class instance that is wrapping the c++ subclassing -// this class. -// -/////////////////////////////////////////////////////////////////////////// -#ifndef CPP_PY_WRAPPER_H -#define CPP_PY_WRAPPER_H - -#include - -namespace OrbitUtils{ - - /** - The base class that provides capability to keep the reference to - the Python class instance that is wrapping the c++ subclassing - this class. - */ - - class CppPyWrapper - { - public: - - /** Constructor of the CppPyWrapper class with reference to Python class instance. */ - CppPyWrapper(PyObject* py_wrapperIn); - - /** Constructor of the CppPyWrapper class with NULL reference to Python class. */ - CppPyWrapper(); - - /** Destrictor. It is empty. */ - ~CppPyWrapper(); - - /** Sets the reference to Python class instance. */ - void setPyWrapper(PyObject* py_wrapperIn); - - /** Returns the reference to Python class instance. */ - PyObject* getPyWrapper(); - - private: - - PyObject* cpp_py_wrapper; - - }; -}; - -#endif From 17017138aa64ed914aba398d260f04df2cad3e09 Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Sun, 13 Sep 2026 11:10:17 -0400 Subject: [PATCH 28/33] build(core): make Python bindings optional --- meson.build | 4 ++- meson_options.txt | 1 + src/meson.build | 87 +++++++++++++++++++++-------------------------- 3 files changed, 43 insertions(+), 49 deletions(-) diff --git a/meson.build b/meson.build index d37025ea..ce4cd76f 100644 --- a/meson.build +++ b/meson.build @@ -10,4 +10,6 @@ project('PyORBIT', ) subdir('src') -subdir('py/orbit') +if get_option('BUILD_PYTHON') + subdir('py/orbit') +endif diff --git a/meson_options.txt b/meson_options.txt index 3ae5f6ab..64ce4c8f 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1 +1,2 @@ option('USE_MPI', type: 'string', value: 'auto', description: 'Choose MPI implementation (mpich, openmpi, none, auto)') +option('BUILD_PYTHON', type: 'boolean', value: true, description: 'Build and install Python bindings') diff --git a/src/meson.build b/src/meson.build index c43587dd..05307bbb 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,4 +1,8 @@ -python = import('python').find_installation('python3', pure: false) +build_python = get_option('BUILD_PYTHON') +if build_python + python = import('python').find_installation('python3', pure: false) + python_dependency = python.dependency() +endif cpp = meson.get_compiler('cpp') @@ -6,19 +10,8 @@ if cpp.has_argument('-march=native') add_project_arguments('-march=native', language: 'cpp') endif -dependencies = [] - -dependencies += dependency('fftw3', version: '>= 3.0.0', required: true) - -python_embed_dependency = python.dependency(embed: true) -core_link_args = [] - -if host_machine.system() == 'darwin' - dependencies += python.dependency() - core_link_args += ['-Wl,-undefined,dynamic_lookup'] -else - dependencies += python_embed_dependency -endif +core_dependencies = [dependency('fftw3', version: '>= 3.0.0', required: true)] +pc_requires = ['fftw3 >= 3.0.0'] # Detecting if MPICH or OPENMPI are installed and enabling support if present mpi_use = get_option('USE_MPI') @@ -26,12 +19,14 @@ use_mpi_flag = '0' if mpi_use == 'mpich' message('Requested to use MPICH as the MPI implementation.') - dependencies += dependency('mpich', version: '>= 4.0.0', required: true) + core_dependencies += dependency('mpich', version: '>= 4.0.0', required: true) + pc_requires += ['mpich >= 4.0.0'] add_project_arguments('-DUSE_MPI=1', language: 'cpp') use_mpi_flag = '1' elif mpi_use == 'ompi' message('Requested to use OpenMPI as the MPI implementation.') - dependencies += dependency('ompi', version: '>= 4.0.0', required: true) + core_dependencies += dependency('ompi', version: '>= 4.0.0', required: true) + pc_requires += ['ompi >= 4.0.0'] add_project_arguments('-DUSE_MPI=1', language: 'cpp') use_mpi_flag = '1' elif mpi_use == 'none' @@ -42,12 +37,14 @@ else if mpich_dependency.found() add_project_arguments('-DUSE_MPI=1', language: 'cpp') - dependencies += mpich_dependency + core_dependencies += mpich_dependency + pc_requires += ['mpich >= 4.0.0'] message('Using MPICH as the MPI implementation.') use_mpi_flag = '1' elif openmpi_dependency.found() add_project_arguments('-DUSE_MPI=1', language: 'cpp') - dependencies += openmpi_dependency + core_dependencies += openmpi_dependency + pc_requires += ['ompi >= 4.0.0'] message('Using OpenMPI as the MPI implementation.') use_mpi_flag = '1' else @@ -168,27 +165,10 @@ core_lib = library( 'pyorbit3', sources: sources, include_directories: inc, - dependencies: dependencies, - link_args: core_link_args, + dependencies: core_dependencies, install: true, ) -core_install_dir = get_option('prefix') / get_option('libdir') -extension_install_dir = python.get_install_dir() / 'orbit/core' -core_relative_install_dir = run_command( - python, - '-c', - 'import os, sys; print(os.path.relpath(sys.argv[1], sys.argv[2]))', - core_install_dir, - extension_install_dir, - check: true, -).stdout().strip() -if host_machine.system() == 'darwin' - core_install_rpath = '@loader_path/' + core_relative_install_dir -else - core_install_rpath = '$ORIGIN/' + core_relative_install_dir -endif - api_headers = [ 'linac/rfgap/BaseRfGap.hh', 'linac/rfgap/BaseRfGap_slow.hh', @@ -298,13 +278,6 @@ api_headers = [ install_headers(api_headers, subdir : 'pyorbit3', preserve_path : true) -pc_requires = [python_embed_dependency, 'fftw3 >= 3.0.0'] -if get_option('USE_MPI') == 'mpich' - pc_requires += ['mpich >= 4.0.0'] -elif get_option('USE_MPI') == 'ompi' - pc_requires += ['ompi >= 4.0.0'] -endif - pkgconfig = import('pkgconfig') pkgconfig.generate( @@ -319,10 +292,27 @@ pkgconfig.generate( install_dir: get_option('libdir') / 'pkgconfig', ) +if build_python +core_install_dir = get_option('prefix') / get_option('libdir') +extension_install_dir = python.get_install_dir() / 'orbit/core' +core_relative_install_dir = run_command( + python, + '-c', + 'import os, sys; print(os.path.relpath(sys.argv[1], sys.argv[2]))', + core_install_dir, + extension_install_dir, + check: true, +).stdout().strip() +if host_machine.system() == 'darwin' + core_install_rpath = '@loader_path/' + core_relative_install_dir +else + core_install_rpath = '$ORIGIN/' + core_relative_install_dir +endif + binding_lib = shared_library( 'pyorbit3_python', sources: 'main/pyORBIT_Object.cc', - dependencies: python.dependency(), + dependencies: python_dependency, gnu_symbol_visibility: 'default', install: true, ) @@ -478,12 +468,13 @@ ext_modules = { foreach name, src_list : ext_modules python.extension_module( name, - sources: src_list, - include_directories: inc, - link_with: [core_lib, binding_lib], - dependencies: dependencies, + sources: src_list, + include_directories: inc, + link_with: [core_lib, binding_lib], + dependencies: core_dependencies + [python_dependency], install_rpath: core_install_rpath, install: true, subdir: 'orbit/core', ) endforeach +endif From 82c3c9d39372b8384c02a12dc465a70ff8ad1a74 Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Sun, 13 Sep 2026 11:26:08 -0400 Subject: [PATCH 29/33] fix(style): restore consistent CRLF endings --- src/orbit/Apertures/Aperture.cc | 2 +- src/orbit/Apertures/Aperture.hh | 2 +- src/orbit/Bunch.hh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/orbit/Apertures/Aperture.cc b/src/orbit/Apertures/Aperture.cc index da0dd09c..b5dac547 100644 --- a/src/orbit/Apertures/Aperture.cc +++ b/src/orbit/Apertures/Aperture.cc @@ -31,7 +31,7 @@ // /////////////////////////////////////////////////////////////////////////// -Aperture::Aperture(int shape, double a, double b, double c, double d, double pos) +Aperture::Aperture(int shape, double a, double b, double c, double d, double pos) { shape_ = shape; a_ = a; diff --git a/src/orbit/Apertures/Aperture.hh b/src/orbit/Apertures/Aperture.hh index 15066ffa..e03b616d 100644 --- a/src/orbit/Apertures/Aperture.hh +++ b/src/orbit/Apertures/Aperture.hh @@ -11,7 +11,7 @@ using namespace std; The aperture class is used to define how a bunch propogates through an aperture */ -class Aperture +class Aperture { public: diff --git a/src/orbit/Bunch.hh b/src/orbit/Bunch.hh index 609425ff..1690daec 100644 --- a/src/orbit/Bunch.hh +++ b/src/orbit/Bunch.hh @@ -44,7 +44,7 @@ // /////////////////////////////////////////////////////////////////////////// -class Bunch +class Bunch { public: //-------------------------------------- From a70d3080dced93dcbf75ccc6c4a4bd9d1b5ef552 Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Sun, 13 Sep 2026 12:09:23 -0400 Subject: [PATCH 30/33] fix(orbit): include C string declarations --- src/orbit/Bunch.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/orbit/Bunch.cc b/src/orbit/Bunch.cc index 9cde723e..bba55917 100644 --- a/src/orbit/Bunch.cc +++ b/src/orbit/Bunch.cc @@ -21,6 +21,7 @@ #include "utils/StringUtils.hh" #include "utils/BufferStore.hh" +#include #include #include From 526cba196803fd947e8ebdb41116c014abc19db7 Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Sun, 13 Sep 2026 12:52:47 -0400 Subject: [PATCH 31/33] refactor(core): qualify standard library symbols --- src/linac/rfgap/BaseRfGap.hh | 1 - src/linac/rfgap/BaseRfGap_slow.hh | 1 - src/linac/rfgap/MatrixRfGap.hh | 1 - src/linac/rfgap/RfGapTTF.hh | 1 - src/linac/rfgap/RfGapTTF_slow.hh | 1 - src/linac/rfgap/RfGapThreePointTTF.hh | 1 - src/linac/rfgap/RfGapThreePointTTF_slow.hh | 1 - src/linac/rfgap/SuperFishFieldSource.hh | 1 - src/linac/tracking/linac_tracking.cc | 1 + src/orbit/Apertures/Aperture.hh | 1 - src/orbit/Apertures/BaseAperture.cc | 4 ++-- src/orbit/Apertures/BaseAperture.hh | 7 +++---- src/orbit/Apertures/BaseApertureShape.cc | 6 +++--- src/orbit/Apertures/BaseApertureShape.hh | 11 +++++------ src/orbit/Apertures/CircleApertureShape.hh | 1 - src/orbit/Apertures/CompositeApertureShape.hh | 1 - src/orbit/Apertures/ConvexApertureShape.hh | 1 - src/orbit/Apertures/EllipseApertureShape.hh | 1 - src/orbit/Apertures/EnergyAperture.hh | 1 - src/orbit/Apertures/PhaseAperture.hh | 1 - src/orbit/Apertures/PyBaseApertureShape.hh | 1 - src/orbit/Apertures/RectangularApertureShape.hh | 1 - src/orbit/Bunch.cc | 17 +++++++++-------- src/orbit/BunchDiagnostics/BunchTuneAnalysis.cc | 4 ++-- src/orbit/BunchDiagnostics/BunchTuneAnalysis.hh | 1 - .../BunchDiagnostics/BunchTwissAnalysis.hh | 1 - src/orbit/FieldTracker/FieldTracker.cc | 16 ++++++++-------- src/orbit/FieldTracker/FieldTracker.hh | 5 ++--- src/orbit/Impedances/LImpedance.hh | 1 - src/orbit/Impedances/TImpedance.hh | 1 - src/orbit/MaterialInteractions/Collimator.hh | 1 - src/orbit/MaterialInteractions/Foil.hh | 1 - .../MaterialInteractions.cc | 2 +- .../MaterialInteractions.hh | 1 - .../ParticleAttributesFactory.cc | 12 ++++++------ .../ParticleAttributesFactory.hh | 4 ++-- src/orbit/RFCavities/Barrier_Cav.hh | 1 - src/orbit/RFCavities/Dual_Harmonic_Cav.hh | 1 - src/orbit/RFCavities/Frequency_Cav.hh | 1 - src/orbit/RFCavities/Harmonic_Cav.hh | 1 - src/orbit/SyncPart.cc | 6 ++++-- src/orbit/SyncPart.hh | 1 - .../SynchPartRedefinitionZdE.hh | 1 - src/spacecharge/BaseBoundary2D.cc | 3 ++- src/spacecharge/BaseBoundary2D.hh | 7 +++---- src/spacecharge/ForceSolver2D.hh | 1 - src/spacecharge/ForceSolverFFT2D.cc | 17 +++++++++-------- src/spacecharge/ForceSolverFFT2D.hh | 1 - src/spacecharge/Grid1D.hh | 1 - src/spacecharge/Grid2D.hh | 1 - src/spacecharge/LSpaceChargeCalc.hh | 1 - src/spacecharge/PoissonSolver2D.hh | 1 - src/spacecharge/PoissonSolver3D.hh | 1 - src/spacecharge/PoissonSolverFFT2D.hh | 1 - src/spacecharge/PoissonSolverFFT3D.hh | 1 - src/spacecharge/ShapedBoundary2D.cc | 3 ++- src/spacecharge/ShapedBoundary2D.hh | 3 +-- src/spacecharge/SpaceChargeCalc2p5D.hh | 1 - src/spacecharge/SpaceChargeCalc2p5Drb.hh | 1 - src/spacecharge/SpaceChargeCalc3D.hh | 1 - .../SpaceChargeCalcSliceBySlice2D.hh | 1 - src/spacecharge/SpaceChargeCalcUnifEllipse.cc | 1 + src/spacecharge/SpaceChargeCalcUnifEllipse.hh | 1 - src/spacecharge/SpaceChargeForceCalc2p5D.hh | 1 - .../UniformEllipsoidFieldCalculator.hh | 1 - src/spacecharge/wrap_boundary2d.cc | 2 +- src/teapot/teapotbase.cc | 1 + src/trackerrk4/ExtEffectsContainer.hh | 10 +++++----- src/trackerrk4/RungeKuttaTracker.cc | 1 + src/utils/OU_Function.cc | 6 +++--- src/utils/OU_Function.hh | 1 - src/utils/OU_SplineCH.cc | 6 +++--- src/utils/StringUtils.cc | 8 ++++---- src/utils/StringUtils.hh | 3 +-- src/utils/harmonic_analysis/HarmonicData.cc | 1 + src/utils/harmonic_analysis/HarmonicData.hh | 1 - .../integration/GaussLegendreIntegrator.hh | 1 - src/utils/polynomial/OU_Polynomial.hh | 1 - src/utils/statistics/StatMoments2D.hh | 1 - 79 files changed, 86 insertions(+), 132 deletions(-) diff --git a/src/linac/rfgap/BaseRfGap.hh b/src/linac/rfgap/BaseRfGap.hh index 466b056b..284a02c4 100644 --- a/src/linac/rfgap/BaseRfGap.hh +++ b/src/linac/rfgap/BaseRfGap.hh @@ -15,7 +15,6 @@ //pyORBIT utils -using namespace std; /** This class represents a 2D rectangular grid. diff --git a/src/linac/rfgap/BaseRfGap_slow.hh b/src/linac/rfgap/BaseRfGap_slow.hh index 552da660..49211096 100644 --- a/src/linac/rfgap/BaseRfGap_slow.hh +++ b/src/linac/rfgap/BaseRfGap_slow.hh @@ -19,7 +19,6 @@ //pyORBIT utils -using namespace std; /** This class represents a 2D rectangular grid. diff --git a/src/linac/rfgap/MatrixRfGap.hh b/src/linac/rfgap/MatrixRfGap.hh index 24037e6c..d3ef91b2 100644 --- a/src/linac/rfgap/MatrixRfGap.hh +++ b/src/linac/rfgap/MatrixRfGap.hh @@ -18,7 +18,6 @@ For this RF gap we know the E0TL, frequency, and phase only. //pyORBIT utils -using namespace std; /** This class represents a RF gap as transport matrix. No nonlinear effects. diff --git a/src/linac/rfgap/RfGapTTF.hh b/src/linac/rfgap/RfGapTTF.hh index 0e508412..a83438db 100644 --- a/src/linac/rfgap/RfGapTTF.hh +++ b/src/linac/rfgap/RfGapTTF.hh @@ -20,7 +20,6 @@ //pyORBIT utils #include "utils/polynomial/OU_Polynomial.hh" -using namespace std; /** This class represents a RF gap as a Parmila type gap. diff --git a/src/linac/rfgap/RfGapTTF_slow.hh b/src/linac/rfgap/RfGapTTF_slow.hh index 2a20752c..22ba0645 100644 --- a/src/linac/rfgap/RfGapTTF_slow.hh +++ b/src/linac/rfgap/RfGapTTF_slow.hh @@ -22,7 +22,6 @@ //pyORBIT utils #include "utils/polynomial/OU_Polynomial.hh" -using namespace std; /** This class represents a RF gap as a Parmila type gap. diff --git a/src/linac/rfgap/RfGapThreePointTTF.hh b/src/linac/rfgap/RfGapThreePointTTF.hh index f8e76a30..e845794a 100644 --- a/src/linac/rfgap/RfGapThreePointTTF.hh +++ b/src/linac/rfgap/RfGapThreePointTTF.hh @@ -20,7 +20,6 @@ //pyORBIT utils -using namespace std; /** This class represents a RF gap as a Three Points type gap. diff --git a/src/linac/rfgap/RfGapThreePointTTF_slow.hh b/src/linac/rfgap/RfGapThreePointTTF_slow.hh index 44ef8239..d06fe1a1 100644 --- a/src/linac/rfgap/RfGapThreePointTTF_slow.hh +++ b/src/linac/rfgap/RfGapThreePointTTF_slow.hh @@ -23,7 +23,6 @@ //pyORBIT utils -using namespace std; /** This class represents a RF gap as a Three Points type gap. diff --git a/src/linac/rfgap/SuperFishFieldSource.hh b/src/linac/rfgap/SuperFishFieldSource.hh index 0a782cf5..206f2565 100644 --- a/src/linac/rfgap/SuperFishFieldSource.hh +++ b/src/linac/rfgap/SuperFishFieldSource.hh @@ -15,7 +15,6 @@ #include #include -using namespace std; class SuperFishFieldSource: public OrbitUtils::BaseFieldSource { diff --git a/src/linac/tracking/linac_tracking.cc b/src/linac/tracking/linac_tracking.cc index 268748e0..fa3360a8 100644 --- a/src/linac/tracking/linac_tracking.cc +++ b/src/linac/tracking/linac_tracking.cc @@ -31,6 +31,7 @@ #include "orbit/Bunch.hh" #include "orbit/SyncPart.hh" +#include #include namespace linac_tracking diff --git a/src/orbit/Apertures/Aperture.hh b/src/orbit/Apertures/Aperture.hh index e03b616d..de727b2e 100644 --- a/src/orbit/Apertures/Aperture.hh +++ b/src/orbit/Apertures/Aperture.hh @@ -5,7 +5,6 @@ //pyORBIT utils #include "orbit/Bunch.hh" -using namespace std; /** The aperture class is used to define how a bunch propogates through an aperture diff --git a/src/orbit/Apertures/BaseAperture.cc b/src/orbit/Apertures/BaseAperture.cc index b316958e..eae142d4 100644 --- a/src/orbit/Apertures/BaseAperture.cc +++ b/src/orbit/Apertures/BaseAperture.cc @@ -182,12 +182,12 @@ int BaseAperture::getNumberOfLost(){ } /** Returns the aperture name */ -string BaseAperture::getName(){ +std::string BaseAperture::getName(){ return apertureName; } /** Sets the aperture name */ -void BaseAperture::setName(string apertureNameIn){ +void BaseAperture::setName(std::string apertureNameIn){ apertureName = apertureNameIn; } diff --git a/src/orbit/Apertures/BaseAperture.hh b/src/orbit/Apertures/BaseAperture.hh index a4565dbc..178bab22 100644 --- a/src/orbit/Apertures/BaseAperture.hh +++ b/src/orbit/Apertures/BaseAperture.hh @@ -5,7 +5,6 @@ #include "orbit/Bunch.hh" #include "orbit/Apertures/BaseApertureShape.hh" -using namespace std; /////////////////////////////////////////////////////////////////////////// // @@ -49,10 +48,10 @@ public: int getNumberOfLost(); /** Returns the aperture name */ - string getName(); + std::string getName(); /** Sets the aperture name */ - void setName(string apertureNameIn); + void setName(std::string apertureNameIn); /** Sets the position of the node in the lattice */ double getPosition(); @@ -73,7 +72,7 @@ public: protected: //name of the aperture - string apertureName; + std::string apertureName; //Counters int nLost_; diff --git a/src/orbit/Apertures/BaseApertureShape.cc b/src/orbit/Apertures/BaseApertureShape.cc index 3d802d42..980dd210 100644 --- a/src/orbit/Apertures/BaseApertureShape.cc +++ b/src/orbit/Apertures/BaseApertureShape.cc @@ -65,19 +65,19 @@ double BaseApertureShape::getCenterY() /** Returns the shape name */ -string BaseApertureShape::getName() +std::string BaseApertureShape::getName() { return shapeName; } /** Sets the shape name */ -void BaseApertureShape::setName(string shapeNameIn) +void BaseApertureShape::setName(std::string shapeNameIn) { shapeName = shapeNameIn; } /** Returns the shape type name */ -string BaseApertureShape::getTypeName() +std::string BaseApertureShape::getTypeName() { return typeName; } diff --git a/src/orbit/Apertures/BaseApertureShape.hh b/src/orbit/Apertures/BaseApertureShape.hh index 9a74965e..10684f1a 100644 --- a/src/orbit/Apertures/BaseApertureShape.hh +++ b/src/orbit/Apertures/BaseApertureShape.hh @@ -5,7 +5,6 @@ #include "orbit/Bunch.hh" #include "orbit/Apertures/BaseApertureShape.hh" -using namespace std; /////////////////////////////////////////////////////////////////////////// // @@ -49,19 +48,19 @@ public: double getCenterY(); /** Returns the shape name */ - string getName(); + std::string getName(); /** Sets the shape name */ - void setName(string shapeName); + void setName(std::string shapeName); /** Returns the shape type name */ - string getTypeName(); + std::string getTypeName(); protected: - string shapeName; + std::string shapeName; - string typeName; + std::string typeName; double x_center, y_center; diff --git a/src/orbit/Apertures/CircleApertureShape.hh b/src/orbit/Apertures/CircleApertureShape.hh index ae9de27d..491115cf 100644 --- a/src/orbit/Apertures/CircleApertureShape.hh +++ b/src/orbit/Apertures/CircleApertureShape.hh @@ -4,7 +4,6 @@ #include "orbit/Bunch.hh" #include "orbit/Apertures/BaseApertureShape.hh" -using namespace std; /////////////////////////////////////////////////////////////////////////// // diff --git a/src/orbit/Apertures/CompositeApertureShape.hh b/src/orbit/Apertures/CompositeApertureShape.hh index 413f6002..efd2b8c1 100644 --- a/src/orbit/Apertures/CompositeApertureShape.hh +++ b/src/orbit/Apertures/CompositeApertureShape.hh @@ -4,7 +4,6 @@ #include "orbit/Bunch.hh" #include "orbit/Apertures/BaseApertureShape.hh" -using namespace std; /////////////////////////////////////////////////////////////////////////// // diff --git a/src/orbit/Apertures/ConvexApertureShape.hh b/src/orbit/Apertures/ConvexApertureShape.hh index 7b69cd0b..f153a38f 100644 --- a/src/orbit/Apertures/ConvexApertureShape.hh +++ b/src/orbit/Apertures/ConvexApertureShape.hh @@ -4,7 +4,6 @@ #include "orbit/Bunch.hh" #include "orbit/Apertures/BaseApertureShape.hh" -using namespace std; /////////////////////////////////////////////////////////////////////////// // diff --git a/src/orbit/Apertures/EllipseApertureShape.hh b/src/orbit/Apertures/EllipseApertureShape.hh index 5bd1bc14..a9709072 100644 --- a/src/orbit/Apertures/EllipseApertureShape.hh +++ b/src/orbit/Apertures/EllipseApertureShape.hh @@ -4,7 +4,6 @@ #include "orbit/Bunch.hh" #include "orbit/Apertures/BaseApertureShape.hh" -using namespace std; /////////////////////////////////////////////////////////////////////////// // diff --git a/src/orbit/Apertures/EnergyAperture.hh b/src/orbit/Apertures/EnergyAperture.hh index 5377de42..1430843d 100644 --- a/src/orbit/Apertures/EnergyAperture.hh +++ b/src/orbit/Apertures/EnergyAperture.hh @@ -23,7 +23,6 @@ //pyORBIT utils #include "orbit/Bunch.hh" -using namespace std; class EnergyAperture { diff --git a/src/orbit/Apertures/PhaseAperture.hh b/src/orbit/Apertures/PhaseAperture.hh index bcaf96f6..c02e8494 100644 --- a/src/orbit/Apertures/PhaseAperture.hh +++ b/src/orbit/Apertures/PhaseAperture.hh @@ -24,7 +24,6 @@ //pyORBIT utils #include "orbit/Bunch.hh" -using namespace std; class PhaseAperture { diff --git a/src/orbit/Apertures/PyBaseApertureShape.hh b/src/orbit/Apertures/PyBaseApertureShape.hh index f113e168..559f3ab2 100644 --- a/src/orbit/Apertures/PyBaseApertureShape.hh +++ b/src/orbit/Apertures/PyBaseApertureShape.hh @@ -6,7 +6,6 @@ #include "orbit/Bunch.hh" #include "orbit/Apertures/BaseApertureShape.hh" -using namespace std; /////////////////////////////////////////////////////////////////////////// // diff --git a/src/orbit/Apertures/RectangularApertureShape.hh b/src/orbit/Apertures/RectangularApertureShape.hh index d5a461dd..43f57b75 100644 --- a/src/orbit/Apertures/RectangularApertureShape.hh +++ b/src/orbit/Apertures/RectangularApertureShape.hh @@ -4,7 +4,6 @@ #include "orbit/Bunch.hh" #include "orbit/Apertures/BaseApertureShape.hh" -using namespace std; /////////////////////////////////////////////////////////////////////////// // diff --git a/src/orbit/Bunch.cc b/src/orbit/Bunch.cc index bba55917..5ba616f0 100644 --- a/src/orbit/Bunch.cc +++ b/src/orbit/Bunch.cc @@ -21,6 +21,7 @@ #include "utils/StringUtils.hh" #include "utils/BufferStore.hh" +#include #include #include #include @@ -196,7 +197,7 @@ void Bunch::initBunchAttributes(const char* fileName){ std::vector attr_names; attr_names.clear(); - ifstream is; + std::ifstream is; int error_ind = 0; if(rank_MPI == 0){ @@ -560,7 +561,7 @@ void Bunch::resize() std::map::iterator pos; for (pos = attrCntrMap.begin(); pos != attrCntrMap.end(); ++pos) { - string name = pos->first; + std::string name = pos->first; ParticleAttributes* attrCntrl = pos->second; for(int i = nOldTotalSize; i < nTotalSize; i++){ attrCntrl->init(i); @@ -1075,10 +1076,10 @@ void Bunch::print(std::ostream& Out) void Bunch::print(const char* fileName) { - ofstream F_dump; + std::ofstream F_dump; if(rank_MPI == 0){ - F_dump.open (fileName, ios::out); + F_dump.open (fileName, std::ios::out); } print(F_dump); @@ -1110,7 +1111,7 @@ int Bunch::readBunchCoords(const char* fileName, int nParts) { double x,y,z, px,py,pz; - ifstream is; + std::ifstream is; int error_ind = 0; @@ -1303,7 +1304,7 @@ int Bunch::readParticleAttributesNames(const char* fileName, attr_names.clear(); - ifstream is; + std::ifstream is; int error_ind = 0; @@ -1416,7 +1417,7 @@ int Bunch::readParticleAttributesNames(const char* fileName, for(int i = 0; i < nDicts; i++){ int nT = StringUtils::Tokenize(v_str_part_attr[i],v_str_dict); int dict_size = (v_str_dict.size() - 3)/2; - map attr_dict; + std::map attr_dict; for(int k = 0; k < dict_size; k++){ int val = 0; sscanf(v_str_dict[2*k+3+1].c_str(),"%df",&val); @@ -1604,7 +1605,7 @@ ParticleAttributes* Bunch::removeParticleAttributesWithoutDelete(const std::stri std::map::iterator pos; for (pos = attrCntrLowIndMap.begin(); pos != attrCntrLowIndMap.end(); ++pos) { - string name = pos->first; + std::string name = pos->first; int ind = pos->second; if(ind >= lowInd) { attrCntrLowIndMap[name] = attrCntrLowIndMap[name] - attr_length; diff --git a/src/orbit/BunchDiagnostics/BunchTuneAnalysis.cc b/src/orbit/BunchDiagnostics/BunchTuneAnalysis.cc index 6469ab3a..592a41d9 100644 --- a/src/orbit/BunchDiagnostics/BunchTuneAnalysis.cc +++ b/src/orbit/BunchDiagnostics/BunchTuneAnalysis.cc @@ -77,7 +77,7 @@ void BunchTuneAnalysis::analyzeBunch(Bunch* bunch){ double** part_coord_arr = bunch->coordArr(); if(!bunch->hasParticleAttributes("ParticlePhaseAttributes")){ - cerr<<"BunchTuneAnalysis: Adding particle phase information attribute.\n"; + std::cerr<<"BunchTuneAnalysis: Adding particle phase information attribute.\n"; std::map tunemap; tunemap.insert(std::make_pair("phase_1", 0)); tunemap.insert(std::make_pair("phase_2", 0)); @@ -89,7 +89,7 @@ void BunchTuneAnalysis::analyzeBunch(Bunch* bunch){ } if (bunch->hasParticleAttributes("ParticlePhaseAttributes") && erase == 1) { - cerr<<"BunchTuneAnalysis: Normalization matrix has been updated. Setting particle phases to zero. Tunes will be accurate after the next `analyzeBunch` call.\n"; + std::cerr<<"BunchTuneAnalysis: Normalization matrix has been updated. Setting particle phases to zero. Tunes will be accurate after the next `analyzeBunch` call.\n"; for (int i=0; i < bunch->getSize(); i++) { bunch->getParticleAttributes("ParticlePhaseAttributes")->attValue(i, 0) = 0.0; bunch->getParticleAttributes("ParticlePhaseAttributes")->attValue(i, 1) = 0.0; diff --git a/src/orbit/BunchDiagnostics/BunchTuneAnalysis.hh b/src/orbit/BunchDiagnostics/BunchTuneAnalysis.hh index d39b1b1b..923fe9fa 100644 --- a/src/orbit/BunchDiagnostics/BunchTuneAnalysis.hh +++ b/src/orbit/BunchDiagnostics/BunchTuneAnalysis.hh @@ -6,7 +6,6 @@ #include "orbit/Bunch.hh" #include "orbit/BunchDiagnostics/BunchTwissAnalysis.hh" -using namespace std; /** Estimates particle tunes using average phase advance (APA) over one turn. */ diff --git a/src/orbit/BunchDiagnostics/BunchTwissAnalysis.hh b/src/orbit/BunchDiagnostics/BunchTwissAnalysis.hh index 2ea49251..de741e78 100644 --- a/src/orbit/BunchDiagnostics/BunchTwissAnalysis.hh +++ b/src/orbit/BunchDiagnostics/BunchTwissAnalysis.hh @@ -5,7 +5,6 @@ #include "orbit/Bunch.hh" -using namespace std; /** The BunchTwissAnalysis class calculates the average of 6D coordinates and they correlations. diff --git a/src/orbit/FieldTracker/FieldTracker.cc b/src/orbit/FieldTracker/FieldTracker.cc index 78ea8017..960c98b7 100644 --- a/src/orbit/FieldTracker/FieldTracker.cc +++ b/src/orbit/FieldTracker/FieldTracker.cc @@ -46,9 +46,9 @@ FieldTracker::FieldTracker(const double &bx, const double &by, const double &resid, const double &xrefi, const double &yrefi, const double &eulerai, const double &eulerbi, - const double &eulergi, Bunch* b, string &filename) { + const double &eulergi, Bunch* b, std::string &filename) { - cerr << "Instantiating the 3D field track class \n" ; + std::cerr << "Instantiating the 3D field track class \n" ; double ZPARSEMIN = 100.0 * zi - 1.0; double ZPARSEMAX = 100.0 * zf + 1.0; @@ -151,7 +151,7 @@ void FieldTracker::trackBunch(Bunch* b) { double xj, yj, zj, pxj, pyj, pzj, sj; int lost = 0; - ofstream fio("Path", std::ios::out); + std::ofstream fio("Path", std::ios::out); if(getPath == 1) { @@ -359,7 +359,7 @@ void FieldTracker::trackBunch(Bunch* b) { // //////////////////////////////////////////////////////////////////////////////// -void FieldTracker::ParseGrid3D(const string &fileName, const double &xmin, +void FieldTracker::ParseGrid3D(const std::string &fileName, const double &xmin, const double &xmax, const double &ymin, const double &ymax, const double &zmin, const double &zmax, const int &skipX, const int &skipY, const int &skipZ) { @@ -368,13 +368,13 @@ void FieldTracker::ParseGrid3D(const string &fileName, const double &xmin, int nZTab = 0; int iDummy, i, j, k; int xindex, yindex, zindex; - string Dummy; + std::string Dummy; double x, y, z, Bx, By, Bz; std::cerr << "Filename: " << fileName << "\n"; - ifstream fio(fileName.c_str(), ios::in); + std::ifstream fio(fileName.c_str(), std::ios::in); if (!fio) { std::cerr << "Filename " << fileName << " not found\n"; } @@ -424,7 +424,7 @@ void FieldTracker::ParseGrid3D(const string &fileName, const double &xmin, BZGrid = new Grid3D(nXTab, nYTab, nZTab); BMagGrid = new Grid3D(nXTab, nYTab, nZTab); - ifstream fio2(fileName.c_str(), ios::in); + std::ifstream fio2(fileName.c_str(), std::ios::in); if (!fio2) { std::cerr << "Filename " << fileName << " not found\n"; } @@ -671,7 +671,7 @@ void FieldTracker::nodeCalculator(Bunch* b) int iquit = 0; double xwidth = FieldTracker::xFoilMax - FieldTracker::xFoilMin; - ofstream fio("RefPath", ios::out); + std::ofstream fio("RefPath", std::ios::out); xField3D = xref; yField3D = yref; diff --git a/src/orbit/FieldTracker/FieldTracker.hh b/src/orbit/FieldTracker/FieldTracker.hh index d11fdc07..f2ad7b6b 100644 --- a/src/orbit/FieldTracker/FieldTracker.hh +++ b/src/orbit/FieldTracker/FieldTracker.hh @@ -6,7 +6,6 @@ #include "orbit/Bunch.hh" #include "spacecharge/Grid3D.hh" -using namespace std; /** The FieldTracker class is used to define how a particle/bunch propogates through an @@ -27,14 +26,14 @@ public: const double &resid, const double &xrefi, const double &yrefi, const double &eulerai, const double &eulerbi, - const double &eulergi, Bunch* b, string &filename); + const double &eulergi, Bunch* b, std::string &filename); /** Routine for transfering particles through a aperture */ void trackBunch(Bunch* b); void BGrid3D(); - void ParseGrid3D(const string &fileName, + void ParseGrid3D(const std::string &fileName, const double &xmin, const double &xmax, const double &ymin, const double &ymax, const double &zmin, const double &zmax, diff --git a/src/orbit/Impedances/LImpedance.hh b/src/orbit/Impedances/LImpedance.hh index d5f52faa..d0b84643 100644 --- a/src/orbit/Impedances/LImpedance.hh +++ b/src/orbit/Impedances/LImpedance.hh @@ -21,7 +21,6 @@ //FFTW library header #include "fftw3.h" -using namespace std; class LImpedance { diff --git a/src/orbit/Impedances/TImpedance.hh b/src/orbit/Impedances/TImpedance.hh index e5750d11..7873a5ec 100644 --- a/src/orbit/Impedances/TImpedance.hh +++ b/src/orbit/Impedances/TImpedance.hh @@ -21,7 +21,6 @@ //FFTW library header #include "fftw3.h" -using namespace std; class TImpedance { diff --git a/src/orbit/MaterialInteractions/Collimator.hh b/src/orbit/MaterialInteractions/Collimator.hh index 191ca95f..ea64f623 100644 --- a/src/orbit/MaterialInteractions/Collimator.hh +++ b/src/orbit/MaterialInteractions/Collimator.hh @@ -4,7 +4,6 @@ #include "orbit/Bunch.hh" -using namespace std; /** The collimator class is used to define how a bunch propogates through a collimator diff --git a/src/orbit/MaterialInteractions/Foil.hh b/src/orbit/MaterialInteractions/Foil.hh index 71e11c8c..70cb95d0 100644 --- a/src/orbit/MaterialInteractions/Foil.hh +++ b/src/orbit/MaterialInteractions/Foil.hh @@ -4,7 +4,6 @@ #include "orbit/Bunch.hh" -using namespace std; /** The foil class is used to define how a bunch propogates through a foil diff --git a/src/orbit/MaterialInteractions/MaterialInteractions.cc b/src/orbit/MaterialInteractions/MaterialInteractions.cc index 914418f7..1e1dc94c 100644 --- a/src/orbit/MaterialInteractions/MaterialInteractions.cc +++ b/src/orbit/MaterialInteractions/MaterialInteractions.cc @@ -338,7 +338,7 @@ double MaterialInteractions::elastic_t(double p, double a) theta+=1.768e-3; } - if(found==0) cout<<"Warning, never found elastic t.\n"; + if(found==0) std::cout<<"Warning, never found elastic t.\n"; t=2.*p_cm*p_cm*(1. - cos(angle_cm)); return t; } diff --git a/src/orbit/MaterialInteractions/MaterialInteractions.hh b/src/orbit/MaterialInteractions/MaterialInteractions.hh index 70cee12a..e8769aa3 100644 --- a/src/orbit/MaterialInteractions/MaterialInteractions.hh +++ b/src/orbit/MaterialInteractions/MaterialInteractions.hh @@ -1,7 +1,6 @@ #ifndef MATERIAL_INTERACTIONS_H #define MATERIAL_INTERACTIONS_H -using namespace std; /** The MaterialInteractions class contains a set of routines for calculating common interactions of a particle with a diff --git a/src/orbit/ParticlesAttributes/ParticleAttributesFactory.cc b/src/orbit/ParticlesAttributes/ParticleAttributesFactory.cc index 4ac56098..7884541a 100644 --- a/src/orbit/ParticlesAttributes/ParticleAttributesFactory.cc +++ b/src/orbit/ParticlesAttributes/ParticleAttributesFactory.cc @@ -78,7 +78,7 @@ ParticleAttributes* ParticleAttributesFactory::getParticleAttributesInstance( if(name == "Amplitudes"){ if(params_dict.size() == 0){ - cout<<"dictionary Amplitudes(dict) should be defined "<<"\n"; + std::cout<<"dictionary Amplitudes(dict) should be defined "<<"\n"; } else { if(params_dict.count("size") == 1){ part_atrs = new WaveFunctionAmplitudes(bunch,(int) params_dict["size"]); @@ -99,7 +99,7 @@ ParticleAttributes* ParticleAttributesFactory::getParticleAttributesInstance( if(name == "Populations"){ if(params_dict.size() == 0){ - cout<<"dictionary AtomPopulations(dict) should be defined "<<"\n"; + std::cout<<"dictionary AtomPopulations(dict) should be defined "<<"\n"; } else { if(params_dict.count("size") == 1){ part_atrs = new AtomPopulations(bunch,(int) params_dict["size"]); @@ -119,7 +119,7 @@ ParticleAttributes* ParticleAttributesFactory::getParticleAttributesInstance( if(name == "pq_coords"){ if(params_dict.size() == 0){ - cout<<"dictionary pq_coords(dict) should be defined "<<"\n"; + std::cout<<"dictionary pq_coords(dict) should be defined "<<"\n"; } else { if(params_dict.count("size") == 1){ part_atrs = new pq_coordinates(bunch,(int) params_dict["size"]); @@ -139,7 +139,7 @@ ParticleAttributes* ParticleAttributesFactory::getParticleAttributesInstance( if(name == "part_time"){ if(params_dict.size() == 0){ - cout<<"dictionary prf_time(dict) should be defined "<<"\n"; + std::cout<<"dictionary prf_time(dict) should be defined "<<"\n"; } else { if(params_dict.count("size") == 1){ part_atrs = new part_time(bunch, (int)params_dict["size"]); @@ -159,7 +159,7 @@ ParticleAttributes* ParticleAttributesFactory::getParticleAttributesInstance( if(name == "Evolution"){ if(params_dict.size() == 0){ - cout<<"dictionary Evolution(dict) should be defined "<<"\n"; + std::cout<<"dictionary Evolution(dict) should be defined "<<"\n"; } else { if(params_dict.count("size") == 1){ part_atrs = new Evolution(bunch, (int) params_dict["size"]); @@ -205,7 +205,7 @@ ParticleAttributes* ParticleAttributesFactory::getParticleAttributesInstance( return part_atrs; } -void ParticleAttributesFactory::getParticleAttributesNames(std::vector& names){ +void ParticleAttributesFactory::getParticleAttributesNames(std::vector& names){ names.clear(); names.push_back("macrosize"); names.push_back("ParticleIdNumber"); diff --git a/src/orbit/ParticlesAttributes/ParticleAttributesFactory.hh b/src/orbit/ParticlesAttributes/ParticleAttributesFactory.hh index 6b0b6121..b7361872 100644 --- a/src/orbit/ParticlesAttributes/ParticleAttributesFactory.hh +++ b/src/orbit/ParticlesAttributes/ParticleAttributesFactory.hh @@ -47,12 +47,12 @@ class ParticleAttributesFactory //returns the name of the particle attributes bucket static ParticleAttributes* getParticleAttributesInstance( - const string name, + const std::string name, std::map part_attr_dict, Bunch* bunch); //returns the vector of possible particle attributes names - static void getParticleAttributesNames(std::vector& names); + static void getParticleAttributesNames(std::vector& names); private: ParticleAttributesFactory(); diff --git a/src/orbit/RFCavities/Barrier_Cav.hh b/src/orbit/RFCavities/Barrier_Cav.hh index 92d4aca9..7fbf72c4 100644 --- a/src/orbit/RFCavities/Barrier_Cav.hh +++ b/src/orbit/RFCavities/Barrier_Cav.hh @@ -12,7 +12,6 @@ //pyORBIT utils -using namespace std; class Barrier_Cav { diff --git a/src/orbit/RFCavities/Dual_Harmonic_Cav.hh b/src/orbit/RFCavities/Dual_Harmonic_Cav.hh index 9383bbcc..66ef4455 100644 --- a/src/orbit/RFCavities/Dual_Harmonic_Cav.hh +++ b/src/orbit/RFCavities/Dual_Harmonic_Cav.hh @@ -12,7 +12,6 @@ //pyORBIT utils -using namespace std; class Dual_Harmonic_Cav { diff --git a/src/orbit/RFCavities/Frequency_Cav.hh b/src/orbit/RFCavities/Frequency_Cav.hh index 9c79315f..bcc564be 100644 --- a/src/orbit/RFCavities/Frequency_Cav.hh +++ b/src/orbit/RFCavities/Frequency_Cav.hh @@ -12,7 +12,6 @@ //pyORBIT utils -using namespace std; class Frequency_Cav { diff --git a/src/orbit/RFCavities/Harmonic_Cav.hh b/src/orbit/RFCavities/Harmonic_Cav.hh index 0060115c..a83eebc2 100644 --- a/src/orbit/RFCavities/Harmonic_Cav.hh +++ b/src/orbit/RFCavities/Harmonic_Cav.hh @@ -12,7 +12,6 @@ //pyORBIT utils -using namespace std; class Harmonic_Cav { diff --git a/src/orbit/SyncPart.cc b/src/orbit/SyncPart.cc index 9da3b280..2ba19eb7 100644 --- a/src/orbit/SyncPart.cc +++ b/src/orbit/SyncPart.cc @@ -31,6 +31,8 @@ #include "utils/StringUtils.hh" #include "utils/BufferStore.hh" +#include +#include #include #include @@ -322,7 +324,7 @@ void SyncPart::readSyncPart(const char* fileName){ std::vector attr_names; attr_names.clear(); - ifstream is; + std::ifstream is; int error_ind = 0; if(rank_MPI == 0){ @@ -343,7 +345,7 @@ void SyncPart::readSyncPart(const char* fileName){ } std::string str; - std::vector v_str; + std::vector v_str; int stop_ind = 0; int def_found_ind = 0; diff --git a/src/orbit/SyncPart.hh b/src/orbit/SyncPart.hh index bc86e925..48f408aa 100644 --- a/src/orbit/SyncPart.hh +++ b/src/orbit/SyncPart.hh @@ -35,7 +35,6 @@ #include #include -using namespace std; #ifndef SYNC_PARTICLE_H #define SYNC_PARTICLE_H diff --git a/src/orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.hh b/src/orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.hh index cd366a0b..d31b65b7 100644 --- a/src/orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.hh +++ b/src/orbit/SynchPartRedefinition/SynchPartRedefinitionZdE.hh @@ -5,7 +5,6 @@ #include "orbit/Bunch.hh" -using namespace std; /** The SynchPartRedefinitionZdE class calculates the average of z and dE coordinates diff --git a/src/spacecharge/BaseBoundary2D.cc b/src/spacecharge/BaseBoundary2D.cc index 9bbcafd9..bd2876dd 100644 --- a/src/spacecharge/BaseBoundary2D.cc +++ b/src/spacecharge/BaseBoundary2D.cc @@ -1,6 +1,7 @@ #include "spacecharge/BaseBoundary2D.hh" #include "orbit/OrbitConst.hh" +#include #include #include @@ -234,7 +235,7 @@ void BaseBoundary2D::initializeBPs(){ } /** Returns the name of the shape */ -string BaseBoundary2D::getShapeName(){ +std::string BaseBoundary2D::getShapeName(){ return shape_; } diff --git a/src/spacecharge/BaseBoundary2D.hh b/src/spacecharge/BaseBoundary2D.hh index a5e469bf..36eb0704 100644 --- a/src/spacecharge/BaseBoundary2D.hh +++ b/src/spacecharge/BaseBoundary2D.hh @@ -4,7 +4,6 @@ #include "spacecharge/Grid2D.hh" #include -using namespace std; /** The BaseBoundary2D class defines a boundary geometry @@ -59,7 +58,7 @@ class BaseBoundary2D void initializeBPs(); /** Returns the name of the shape */ - string getShapeName(); + std::string getShapeName(); /** Returns the shape index */ int getShapeType(); @@ -71,7 +70,7 @@ class BaseBoundary2D public: /** NOSHAPE String constant */ - string NO_SHAPE; + std::string NO_SHAPE; const static int IS_INSIDE; const static int IS_OUTSIDE; @@ -89,7 +88,7 @@ class BaseBoundary2D protected: - string shape_; + std::string shape_; int shape_type_; //should be set to 1 in the base constructor diff --git a/src/spacecharge/ForceSolver2D.hh b/src/spacecharge/ForceSolver2D.hh index 6e06d16c..d4ba52c7 100644 --- a/src/spacecharge/ForceSolver2D.hh +++ b/src/spacecharge/ForceSolver2D.hh @@ -12,7 +12,6 @@ #include "spacecharge/Grid2D.hh" -using namespace std; /** The ForceSolver2D class calculates 2D forces along X and Y axes diff --git a/src/spacecharge/ForceSolverFFT2D.cc b/src/spacecharge/ForceSolverFFT2D.cc index a241d18c..18d7c409 100644 --- a/src/spacecharge/ForceSolverFFT2D.cc +++ b/src/spacecharge/ForceSolverFFT2D.cc @@ -1,5 +1,6 @@ #include "spacecharge/ForceSolverFFT2D.hh" +#include #include using namespace OrbitUtils; @@ -114,22 +115,22 @@ void ForceSolverFFT2D::_defineGreenF() { rTransX = iX * dx_; rTot2 = rTransX*rTransX + rTransY*rTransY; - greensF_[iX][iY] = complex(rTransX/rTot2, rTransY/rTot2); + greensF_[iX][iY] = std::complex(rTransX/rTot2, rTransY/rTot2); } - greensF_[xSize2_/2][iY] = complex(0,0); //end point + greensF_[xSize2_/2][iY] = std::complex(0,0); //end point for (iX = xSize2_/2+1; iX < xSize2_; iX++) { rTransX = (iX - xSize2_) * dx_; rTot2 = rTransX*rTransX + rTransY*rTransY; - greensF_[iX][iY] = complex(rTransX/rTot2, rTransY/rTot2); + greensF_[iX][iY] = std::complex(rTransX/rTot2, rTransY/rTot2); } } for(iX=0; iX < xSize_/2; iX++) // Null the top row: { - greensF_[iX][ySize2_/2] = complex(0,0); + greensF_[iX][ySize2_/2] = std::complex(0,0); } for (iY = ySize2_/2+1; iY < ySize2_; iY++) // Bottom rows: @@ -140,20 +141,20 @@ void ForceSolverFFT2D::_defineGreenF() { rTransX = iX * dx_; rTot2 = rTransX*rTransX + rTransY*rTransY; - greensF_[iX][iY] = complex(rTransX/rTot2, rTransY/rTot2); + greensF_[iX][iY] = std::complex(rTransX/rTot2, rTransY/rTot2); } - greensF_[xSize2_/2][iY] = complex(0,0); //end point + greensF_[xSize2_/2][iY] = std::complex(0,0); //end point for (iX = xSize2_/2+1; iX < xSize2_; iX++) { rTransX = (iX - xSize2_) * dx_; //rTransX = (iX - 1 - xSize2_) * dx_; rTot2 = rTransX*rTransX + rTransY*rTransY; - greensF_[iX][iY] = complex(rTransX/rTot2, rTransY/rTot2); + greensF_[iX][iY] = std::complex(rTransX/rTot2, rTransY/rTot2); } } - greensF_[0][0] = complex(0,0); //end point + greensF_[0][0] = std::complex(0,0); //end point // Calculate the FFT of the Greens Function: diff --git a/src/spacecharge/ForceSolverFFT2D.hh b/src/spacecharge/ForceSolverFFT2D.hh index 8fd66f64..58a1ab98 100644 --- a/src/spacecharge/ForceSolverFFT2D.hh +++ b/src/spacecharge/ForceSolverFFT2D.hh @@ -16,7 +16,6 @@ #include "spacecharge/ForceSolver2D.hh" -using namespace std; /** The ForceSolverFFT2D class is used to calculate the force diff --git a/src/spacecharge/Grid1D.hh b/src/spacecharge/Grid1D.hh index 4374cc4e..ab1ec525 100644 --- a/src/spacecharge/Grid1D.hh +++ b/src/spacecharge/Grid1D.hh @@ -10,7 +10,6 @@ // ORBIT bunch #include "orbit/Bunch.hh" -using namespace std; class Grid1D diff --git a/src/spacecharge/Grid2D.hh b/src/spacecharge/Grid2D.hh index 488e2f18..a22be2df 100644 --- a/src/spacecharge/Grid2D.hh +++ b/src/spacecharge/Grid2D.hh @@ -12,7 +12,6 @@ //ORBIT bunch #include "orbit/Bunch.hh" -using namespace std; /** This class repersents a 2D rectangular grid. diff --git a/src/spacecharge/LSpaceChargeCalc.hh b/src/spacecharge/LSpaceChargeCalc.hh index cfb07cd1..66f93f6f 100644 --- a/src/spacecharge/LSpaceChargeCalc.hh +++ b/src/spacecharge/LSpaceChargeCalc.hh @@ -21,7 +21,6 @@ //FFTW library header #include "fftw3.h" -using namespace std; class LSpaceChargeCalc { diff --git a/src/spacecharge/PoissonSolver2D.hh b/src/spacecharge/PoissonSolver2D.hh index cc2fdd21..0d7d53cb 100644 --- a/src/spacecharge/PoissonSolver2D.hh +++ b/src/spacecharge/PoissonSolver2D.hh @@ -12,7 +12,6 @@ #include "spacecharge/Grid2D.hh" -using namespace std; /** The PoissonSolver2D class calculates electrostatic diff --git a/src/spacecharge/PoissonSolver3D.hh b/src/spacecharge/PoissonSolver3D.hh index e627adab..7dac49f4 100644 --- a/src/spacecharge/PoissonSolver3D.hh +++ b/src/spacecharge/PoissonSolver3D.hh @@ -12,7 +12,6 @@ #include "spacecharge/Grid3D.hh" -using namespace std; /** The PoissonSolver3D class calculates 3D voltage distribution diff --git a/src/spacecharge/PoissonSolverFFT2D.hh b/src/spacecharge/PoissonSolverFFT2D.hh index d81dfedf..ae6f372a 100644 --- a/src/spacecharge/PoissonSolverFFT2D.hh +++ b/src/spacecharge/PoissonSolverFFT2D.hh @@ -15,7 +15,6 @@ #include "spacecharge/PoissonSolver2D.hh" -using namespace std; /** The PoissonSolverFFT2D class calculates electrostatic diff --git a/src/spacecharge/PoissonSolverFFT3D.hh b/src/spacecharge/PoissonSolverFFT3D.hh index c00728b6..11c3f6f4 100644 --- a/src/spacecharge/PoissonSolverFFT3D.hh +++ b/src/spacecharge/PoissonSolverFFT3D.hh @@ -16,7 +16,6 @@ #include "spacecharge/PoissonSolver3D.hh" -using namespace std; /** The PoissonSolverFFT3D class calculates electrostatic diff --git a/src/spacecharge/ShapedBoundary2D.cc b/src/spacecharge/ShapedBoundary2D.cc index e4fa6c54..cd7468e7 100644 --- a/src/spacecharge/ShapedBoundary2D.cc +++ b/src/spacecharge/ShapedBoundary2D.cc @@ -1,12 +1,13 @@ #include "spacecharge/ShapedBoundary2D.hh" +#include #include #include using namespace OrbitUtils; /** Constructor */ -ShapedBoundary2D::ShapedBoundary2D(int nPoints, int nModes, string shape, double xDim, double yDim): +ShapedBoundary2D::ShapedBoundary2D(int nPoints, int nModes, std::string shape, double xDim, double yDim): BaseBoundary2D(4*((int)(nPoints/4)),nModes) { nPoints = getNumberOfPoints(); diff --git a/src/spacecharge/ShapedBoundary2D.hh b/src/spacecharge/ShapedBoundary2D.hh index e2f77db2..f275066b 100644 --- a/src/spacecharge/ShapedBoundary2D.hh +++ b/src/spacecharge/ShapedBoundary2D.hh @@ -6,7 +6,6 @@ #include "spacecharge/BaseBoundary2D.hh" -using namespace std; /** The ShapedBoundary2D class defines a boundary geometry for three cases: @@ -20,7 +19,7 @@ class ShapedBoundary2D: public BaseBoundary2D public: /** Constructor */ - ShapedBoundary2D(int nPoints, int nModes, string shape, double xDim, double yDim); + ShapedBoundary2D(int nPoints, int nModes, std::string shape, double xDim, double yDim); /** Destructor */ virtual ~ShapedBoundary2D(); diff --git a/src/spacecharge/SpaceChargeCalc2p5D.hh b/src/spacecharge/SpaceChargeCalc2p5D.hh index 6dd20625..d8c61337 100644 --- a/src/spacecharge/SpaceChargeCalc2p5D.hh +++ b/src/spacecharge/SpaceChargeCalc2p5D.hh @@ -21,7 +21,6 @@ #include "spacecharge/PoissonSolverFFT2D.hh" #include "spacecharge/BaseBoundary2D.hh" -using namespace std; class SpaceChargeCalc2p5D { diff --git a/src/spacecharge/SpaceChargeCalc2p5Drb.hh b/src/spacecharge/SpaceChargeCalc2p5Drb.hh index 1867e568..99ed3531 100644 --- a/src/spacecharge/SpaceChargeCalc2p5Drb.hh +++ b/src/spacecharge/SpaceChargeCalc2p5Drb.hh @@ -24,7 +24,6 @@ #include "spacecharge/Grid2D.hh" #include "spacecharge/PoissonSolverFFT2D.hh" -using namespace std; class SpaceChargeCalc2p5Drb { diff --git a/src/spacecharge/SpaceChargeCalc3D.hh b/src/spacecharge/SpaceChargeCalc3D.hh index 3f70cc21..778c9508 100644 --- a/src/spacecharge/SpaceChargeCalc3D.hh +++ b/src/spacecharge/SpaceChargeCalc3D.hh @@ -25,7 +25,6 @@ #include "spacecharge/Grid3D.hh" #include "spacecharge/PoissonSolverFFT3D.hh" -using namespace std; class SpaceChargeCalc3D { diff --git a/src/spacecharge/SpaceChargeCalcSliceBySlice2D.hh b/src/spacecharge/SpaceChargeCalcSliceBySlice2D.hh index 3a7c5003..dc327edf 100755 --- a/src/spacecharge/SpaceChargeCalcSliceBySlice2D.hh +++ b/src/spacecharge/SpaceChargeCalcSliceBySlice2D.hh @@ -20,7 +20,6 @@ #include "spacecharge/PoissonSolverFFT2D.hh" #include "spacecharge/BaseBoundary2D.hh" -using namespace std; class SpaceChargeCalcSliceBySlice2D { diff --git a/src/spacecharge/SpaceChargeCalcUnifEllipse.cc b/src/spacecharge/SpaceChargeCalcUnifEllipse.cc index 0a2b86a9..e6ea6179 100644 --- a/src/spacecharge/SpaceChargeCalcUnifEllipse.cc +++ b/src/spacecharge/SpaceChargeCalcUnifEllipse.cc @@ -20,6 +20,7 @@ #include "orbit/ParticlesAttributes/ParticleMacroSize.hh" +#include #include #include #include diff --git a/src/spacecharge/SpaceChargeCalcUnifEllipse.hh b/src/spacecharge/SpaceChargeCalcUnifEllipse.hh index 949c303d..8b847e64 100644 --- a/src/spacecharge/SpaceChargeCalcUnifEllipse.hh +++ b/src/spacecharge/SpaceChargeCalcUnifEllipse.hh @@ -20,7 +20,6 @@ #include "spacecharge/UniformEllipsoidFieldCalculator.hh" -using namespace std; class SpaceChargeCalcUnifEllipse { diff --git a/src/spacecharge/SpaceChargeForceCalc2p5D.hh b/src/spacecharge/SpaceChargeForceCalc2p5D.hh index b48c87f3..7325f7a6 100644 --- a/src/spacecharge/SpaceChargeForceCalc2p5D.hh +++ b/src/spacecharge/SpaceChargeForceCalc2p5D.hh @@ -20,7 +20,6 @@ #include "spacecharge/ForceSolverFFT2D.hh" #include "spacecharge/BaseBoundary2D.hh" -using namespace std; class SpaceChargeForceCalc2p5D { diff --git a/src/spacecharge/UniformEllipsoidFieldCalculator.hh b/src/spacecharge/UniformEllipsoidFieldCalculator.hh index 00f32865..5f4ecefb 100644 --- a/src/spacecharge/UniformEllipsoidFieldCalculator.hh +++ b/src/spacecharge/UniformEllipsoidFieldCalculator.hh @@ -7,7 +7,6 @@ #include #include -using namespace std; /** This class calculates the field of uniformly charged ellipsoid by using diff --git a/src/spacecharge/wrap_boundary2d.cc b/src/spacecharge/wrap_boundary2d.cc index 231b9a80..9cf41bea 100644 --- a/src/spacecharge/wrap_boundary2d.cc +++ b/src/spacecharge/wrap_boundary2d.cc @@ -54,7 +54,7 @@ extern "C" { if(!PyArg_ParseTuple(args,"iisd|d:__init__",&nPoints,&nModes,&shape_name,&xDim,&yDim)){ ORBIT_MPI_Finalize("PyBoundary2D - Boundary2D(nPoints,nModes,shape,xDim,yDim) - constructor needs parameters."); } - string shape(shape_name); + std::string shape(shape_name); if(nVars == 4){ yDim = xDim;} self->cpp_obj = new ShapedBoundary2D(nPoints, nModes,shape,xDim,yDim); //std::cerr<<"The Boundary2D __init__ has been called!"< #include namespace teapot_base diff --git a/src/trackerrk4/ExtEffectsContainer.hh b/src/trackerrk4/ExtEffectsContainer.hh index 0320f9c6..12bdf8cd 100644 --- a/src/trackerrk4/ExtEffectsContainer.hh +++ b/src/trackerrk4/ExtEffectsContainer.hh @@ -48,11 +48,11 @@ using namespace OrbitUtils; private: - vector ref; - vector ref_setup; - vector ref_prepare; - vector ref_apply; - vector ref_finalize; + std::vector ref; + std::vector ref_setup; + std::vector ref_prepare; + std::vector ref_apply; + std::vector ref_finalize; }; diff --git a/src/trackerrk4/RungeKuttaTracker.cc b/src/trackerrk4/RungeKuttaTracker.cc index 09f6eae7..e224f7a0 100644 --- a/src/trackerrk4/RungeKuttaTracker.cc +++ b/src/trackerrk4/RungeKuttaTracker.cc @@ -16,6 +16,7 @@ /////////////////////////////////////////////////////////////////////////// #include "trackerrk4/RungeKuttaTracker.hh" +#include #include #include #include diff --git a/src/utils/OU_Function.cc b/src/utils/OU_Function.cc index e499d0e2..e6c14e39 100644 --- a/src/utils/OU_Function.cc +++ b/src/utils/OU_Function.cc @@ -641,7 +641,7 @@ void Function::findMinMaxXY(){ } -void Function::print(ostream& Out) +void Function::print(std::ostream& Out) { if(rank_MPI == 0){ Out< #include -using namespace std; namespace OrbitUtils{ diff --git a/src/utils/OU_SplineCH.cc b/src/utils/OU_SplineCH.cc index b6a5f870..232694d3 100644 --- a/src/utils/OU_SplineCH.cc +++ b/src/utils/OU_SplineCH.cc @@ -207,7 +207,7 @@ namespace OrbitUtils{ return yyp; } - void SplineCH::print(ostream& Out) + void SplineCH::print(std::ostream& Out) { if(rank_MPI == 0){ Out<& tokens, const string& delimiters) +int StringUtils::Tokenize(const std::string& str,std::vector& tokens, const std::string& delimiters) { tokens.clear(); // Skip delimiters at beginning. - string::size_type lastPos = str.find_first_not_of(delimiters, 0); + std::string::size_type lastPos = str.find_first_not_of(delimiters, 0); // Find first "non-delimiter". - string::size_type pos = str.find_first_of(delimiters, lastPos); + std::string::size_type pos = str.find_first_of(delimiters, lastPos); - while (string::npos != pos || string::npos != lastPos) + while (std::string::npos != pos || std::string::npos != lastPos) { // Found a token, add it to the vector. tokens.push_back(str.substr(lastPos, pos - lastPos)); diff --git a/src/utils/StringUtils.hh b/src/utils/StringUtils.hh index bbb10191..ad4f97e0 100644 --- a/src/utils/StringUtils.hh +++ b/src/utils/StringUtils.hh @@ -4,7 +4,6 @@ #include #include -using namespace std; //======================================= //Usage @@ -22,7 +21,7 @@ namespace OrbitUtils{ The Tokenizer. It returns the vector with tokens. The delimiter is optional, and by default it is a space. */ - int Tokenize(const string& str,vector& tokens, const string& delimiters = " "); + int Tokenize(const std::string& str,std::vector& tokens, const std::string& delimiters = " "); }; }; #endif diff --git a/src/utils/harmonic_analysis/HarmonicData.cc b/src/utils/harmonic_analysis/HarmonicData.cc index e77b4a8d..95000bb6 100644 --- a/src/utils/harmonic_analysis/HarmonicData.cc +++ b/src/utils/harmonic_analysis/HarmonicData.cc @@ -29,6 +29,7 @@ // /////////////////////////////////////////////////////////////////////////// #include +#include #include "mpi/orbit_mpi.hh" #include "utils/harmonic_analysis/HarmonicData.hh" diff --git a/src/utils/harmonic_analysis/HarmonicData.hh b/src/utils/harmonic_analysis/HarmonicData.hh index 1c078f14..45464052 100644 --- a/src/utils/harmonic_analysis/HarmonicData.hh +++ b/src/utils/harmonic_analysis/HarmonicData.hh @@ -33,7 +33,6 @@ #include "utils/OU_Function.hh" -using namespace std; namespace OrbitUtils{ diff --git a/src/utils/integration/GaussLegendreIntegrator.hh b/src/utils/integration/GaussLegendreIntegrator.hh index c9d455f6..7ae3a992 100644 --- a/src/utils/integration/GaussLegendreIntegrator.hh +++ b/src/utils/integration/GaussLegendreIntegrator.hh @@ -24,7 +24,6 @@ #include "utils/OU_Function.hh" #include "utils/OU_SplineCH.hh" -using namespace std; namespace OrbitUtils{ diff --git a/src/utils/polynomial/OU_Polynomial.hh b/src/utils/polynomial/OU_Polynomial.hh index d988b021..0882fa5e 100644 --- a/src/utils/polynomial/OU_Polynomial.hh +++ b/src/utils/polynomial/OU_Polynomial.hh @@ -18,7 +18,6 @@ #ifndef ORBIT_UTILS_POLYNOMIAL_H #define ORBIT_UTILS_POLYNOMIAL_H -using namespace std; namespace OrbitUtils{ diff --git a/src/utils/statistics/StatMoments2D.hh b/src/utils/statistics/StatMoments2D.hh index 0de0dfb1..70dfeacf 100644 --- a/src/utils/statistics/StatMoments2D.hh +++ b/src/utils/statistics/StatMoments2D.hh @@ -3,7 +3,6 @@ #include "mpi/orbit_mpi.hh" -using namespace std; /** The Moments1D class calculates the arbitrary moments of the (u,up) distribution. From 86f95f4ecafda6c593fa7389d54d44c7c2e21db5 Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Sun, 13 Sep 2026 12:54:39 -0400 Subject: [PATCH 32/33] fix(utils): qualify elliptic integral math --- src/utils/ellipticalint/elliptint.hh | 82 ++++++++++++++-------------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/src/utils/ellipticalint/elliptint.hh b/src/utils/ellipticalint/elliptint.hh index 9d767714..46f72e73 100644 --- a/src/utils/ellipticalint/elliptint.hh +++ b/src/utils/ellipticalint/elliptint.hh @@ -22,6 +22,8 @@ Chapter 6. Special Functions elliptint.hh **/ +#include +#include #include #include @@ -36,10 +38,10 @@ namespace EllipticalIntegrals{ static const double ERRTOL=0.0012, THIRD=1.0/3.0, C1=0.3, C2=1.0/7.0, C3=0.375, C4=9.0/22.0; static const double TINY=5.0*std::numeric_limits::min(), - BIG=0.2*std::numeric_limits::max(), COMP1=2.236/sqrt(TINY), + BIG=0.2*std::numeric_limits::max(), COMP1=2.236/std::sqrt(TINY), COMP2=(TINY*BIG)*(TINY*BIG)/25.0; double alamb,ave,s,w,xt,yt; - if (x < 0.0 || y == 0.0 || (x+fabs(y)) < TINY || (x+fabs(y)) > BIG || + if (x < 0.0 || y == 0.0 || (x+std::fabs(y)) < TINY || (x+std::fabs(y)) > BIG || (y<-COMP1 && x > 0.0 && x < COMP2)) throw("invalid arguments in rc"); if (y > 0.0) { xt=x; @@ -48,16 +50,16 @@ namespace EllipticalIntegrals{ } else { xt=x-y; yt= -y; - w=sqrt(x)/sqrt(xt); + w=std::sqrt(x)/std::sqrt(xt); } do { - alamb=2.0*sqrt(xt)*sqrt(yt)+yt; + alamb=2.0*std::sqrt(xt)*std::sqrt(yt)+yt; xt=0.25*(xt+alamb); yt=0.25*(yt+alamb); ave=THIRD*(xt+yt+yt); s=(yt-ave)/ave; - } while (fabs(s) > ERRTOL); - return w*(1.0+s*s*(C1+s*(C2+s*(C3+s*C4))))/sqrt(ave); + } while (std::fabs(s) > ERRTOL); + return w*(1.0+s*s*(C1+s*(C2+s*(C3+s*C4))))/std::sqrt(ave); } /* @@ -75,9 +77,9 @@ namespace EllipticalIntegrals{ yt=y; zt=z; do { - sqrtx=sqrt(xt); - sqrty=sqrt(yt); - sqrtz=sqrt(zt); + sqrtx=std::sqrt(xt); + sqrty=std::sqrt(yt); + sqrtz=std::sqrt(zt); alamb=sqrtx*(sqrty+sqrtz)+sqrty*sqrtz; xt=0.25*(xt+alamb); yt=0.25*(yt+alamb); @@ -86,10 +88,10 @@ namespace EllipticalIntegrals{ delx=(ave-xt)/ave; dely=(ave-yt)/ave; delz=(ave-zt)/ave; - } while (std::max(std::max(fabs(delx),fabs(dely)),fabs(delz)) > ERRTOL); + } while (std::max(std::max(std::fabs(delx),std::fabs(dely)),std::fabs(delz)) > ERRTOL); e2=delx*dely-delz*delz; e3=delx*dely*delz; - return (1.0+(C1*e2-C2-C3*e3)*e2+C4*e3)/sqrt(ave); + return (1.0+(C1*e2-C2-C3*e3)*e2+C4*e3)/std::sqrt(ave); } /* @@ -100,8 +102,8 @@ namespace EllipticalIntegrals{ double rd(const double x, const double y, const double z) { static const double ERRTOL=0.0015, C1=3.0/14.0, C2=1.0/6.0, C3=9.0/22.0, C4=3.0/26.0, C5=0.25*C3, C6=1.5*C4; - static const double TINY=2.0*pow(std::numeric_limits::max(),-2./3.), - BIG=0.1*ERRTOL*pow(std::numeric_limits::min(),-2./3.); + static const double TINY=2.0*std::pow(std::numeric_limits::max(),-2./3.), + BIG=0.1*ERRTOL*std::pow(std::numeric_limits::min(),-2./3.); double alamb,ave,delx,dely,delz,ea,eb,ec,ed,ee,fac,sqrtx,sqrty, sqrtz,sum,xt,yt,zt; if (std::min(x,y) < 0.0 || std::min(x+y,z) < TINY || std::max(std::max(x,y),z) > BIG) @@ -112,9 +114,9 @@ namespace EllipticalIntegrals{ sum=0.0; fac=1.0; do { - sqrtx=sqrt(xt); - sqrty=sqrt(yt); - sqrtz=sqrt(zt); + sqrtx=std::sqrt(xt); + sqrty=std::sqrt(yt); + sqrtz=std::sqrt(zt); alamb=sqrtx*(sqrty+sqrtz)+sqrty*sqrtz; sum += fac/(sqrtz*(zt+alamb)); fac=0.25*fac; @@ -125,14 +127,14 @@ namespace EllipticalIntegrals{ delx=(ave-xt)/ave; dely=(ave-yt)/ave; delz=(ave-zt)/ave; - } while (std::max(std::max(abs(delx),abs(dely)),abs(delz)) > ERRTOL); + } while (std::max(std::max(std::abs(delx),std::abs(dely)),std::abs(delz)) > ERRTOL); ea=delx*dely; eb=delz*delz; ec=ea-eb; ed=ea-6.0*eb; ee=ed+ec+ec; return 3.0*sum+fac*(1.0+ed*(-C1+C5*ed-C6*delz*ee) - +delz*(C2*ee+delz*(-C3*ec+delz*C4*ea)))/(ave*sqrt(ave)); + +delz*(C2*ee+delz*(-C3*ec+delz*C4*ea)))/(ave*std::sqrt(ave)); } /* @@ -143,12 +145,12 @@ namespace EllipticalIntegrals{ double rj(const double x, const double y, const double z, const double p) { static const double ERRTOL=0.0015, C1=3.0/14.0, C2=1.0/3.0, C3=3.0/22.0, C4=3.0/26.0, C5=0.75*C3, C6=1.5*C4, C7=0.5*C2, C8=C3+C3; - static const double TINY=pow(5.0*std::numeric_limits::min(),1./3.), - BIG=0.3*pow(0.2*std::numeric_limits::max(),1./3.); + static const double TINY=std::pow(5.0*std::numeric_limits::min(),1./3.), + BIG=0.3*std::pow(0.2*std::numeric_limits::max(),1./3.); double a,alamb,alpha,ans,ave,b,beta,delp,delx,dely,delz,ea,eb,ec,ed,ee, fac,pt,rcx,rho,sqrtx,sqrty,sqrtz,sum,tau,xt,yt,zt; - if (std::min(std::min(x,y),z) < 0.0 || std::min(std::min(x+y,x+z),std::min(y+z,fabs(p))) < TINY - || std::max(std::max(x,y),std::max(z,fabs(p))) > BIG) throw("invalid arguments in rj"); + if (std::min(std::min(x,y),z) < 0.0 || std::min(std::min(x+y,x+z),std::min(y+z,std::fabs(p))) < TINY + || std::max(std::max(x,y),std::max(z,std::fabs(p))) > BIG) throw("invalid arguments in rj"); sum=0.0; fac=1.0; if (p > 0.0) { @@ -168,12 +170,12 @@ namespace EllipticalIntegrals{ rcx=rc(rho,tau); } do { - sqrtx=sqrt(xt); - sqrty=sqrt(yt); - sqrtz=sqrt(zt); + sqrtx=std::sqrt(xt); + sqrty=std::sqrt(yt); + sqrtz=std::sqrt(zt); alamb=sqrtx*(sqrty+sqrtz)+sqrty*sqrtz; - alpha=pow((pt*(sqrtx+sqrty+sqrtz)+sqrtx*sqrty*sqrtz),2); - beta=pt*pow((pt+alamb),2); + alpha=std::pow((pt*(sqrtx+sqrty+sqrtz)+sqrtx*sqrty*sqrtz),2); + beta=pt*std::pow((pt+alamb),2); sum += fac*rc(alpha,beta); fac=0.25*fac; xt=0.25*(xt+alamb); @@ -185,15 +187,15 @@ namespace EllipticalIntegrals{ dely=(ave-yt)/ave; delz=(ave-zt)/ave; delp=(ave-pt)/ave; - } while (std::max(std::max(fabs(delx),fabs(dely)), - std::max(fabs(delz),fabs(delp))) > ERRTOL); + } while (std::max(std::max(std::fabs(delx),std::fabs(dely)), + std::max(std::fabs(delz),std::fabs(delp))) > ERRTOL); ea=delx*(dely+delz)+dely*delz; eb=delx*dely*delz; ec=delp*delp; ed=ea-3.0*ec; ee=eb+2.0*delp*(ea-ec); ans=3.0*sum+fac*(1.0+ed*(-C1+C5*ed-C6*ee)+eb*(C7+delp*(-C8+delp*C4)) - +delp*ea*(C2-delp*C3)-C2*delp*ec)/(ave*sqrt(ave)); + +delp*ea*(C2-delp*C3)-C2*delp*ec)/(ave*std::sqrt(ave)); if (p <= 0.0) ans=a*(b*ans+3.0*(rcx-rf(xt,yt,zt))); return ans; } @@ -201,37 +203,37 @@ namespace EllipticalIntegrals{ /* Legendre elliptic integral of the first kind F(phi,ak), evaluated using Carlson’s function RF . - The argument ranges are 0<= phi <= pi/2, 0 <= k*sin(phi) <= 1. + The argument ranges are 0<= phi <= pi/2, 0 <= k*std::sin(phi) <= 1. **/ double ellf(const double phi, const double ak) { - double s=sin(phi); - return s*rf(pow(cos(phi),2),(1.0-s*ak)*(1.0+s*ak),1.0); + double s=std::sin(phi); + return s*rf(std::pow(cos(phi),2),(1.0-s*ak)*(1.0+s*ak),1.0); } /* Legendre elliptic integral of the second kind E(phi,ak), evaluated using Carlson’s function RF and RD. - The argument ranges are 0<= phi <= pi/2, 0 <= k*sin(phi) <= 1. + The argument ranges are 0<= phi <= pi/2, 0 <= k*std::sin(phi) <= 1. **/ double elle(const double phi, const double ak) { double cc,q,s; - s=sin(phi); - cc=pow(cos(phi),2); + s=std::sin(phi); + cc=std::pow(cos(phi),2); q=(1.0-s*ak)*(1.0+s*ak); - return s*(rf(cc,q,1.0)-(pow(s*ak,2))*rd(cc,q,1.0)/3.0); + return s*(rf(cc,q,1.0)-(std::pow(s*ak,2))*rd(cc,q,1.0)/3.0); } /* Legendre elliptic integral of the third kind P(phi,ak), evaluated using Carlson’s function RJ and RD. (Note that the sign convention on n is opposite that of Abramowitz and Stegun.) - The argument ranges are 0<= phi <= pi/2, 0 <= k*sin(phi) <= 1. + The argument ranges are 0<= phi <= pi/2, 0 <= k*std::sin(phi) <= 1. **/ double ellpi(const double phi, const double en, const double ak) { double cc,enss,q,s; - s=sin(phi); + s=std::sin(phi); enss=en*s*s; - cc=pow(cos(phi),2); + cc=std::pow(cos(phi),2); q=(1.0-s*ak)*(1.0+s*ak); return s*(rf(cc,q,1.0)-enss*rj(cc,q,1.0,1.0+enss)/3.0); } From e68cd461b3b0354a8b54f915a6fed05139b063ea Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Sun, 13 Sep 2026 13:14:40 -0400 Subject: [PATCH 33/33] bump python version --- environment.yml | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/environment.yml b/environment.yml index 556ecff3..beb9679b 100644 --- a/environment.yml +++ b/environment.yml @@ -2,7 +2,7 @@ name: pyorbit channels: - conda-forge dependencies: - - python=3.10 + - python>=3.11 - fftw - numpy - scipy diff --git a/pyproject.toml b/pyproject.toml index d601642b..268f1bc1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ requires = ['meson-python', "setuptools>=45", "wheel", "setuptools_scm"] name = 'PyORBIT' dynamic = ["version"] description = 'Use meson-python to build c++ anf python modules.' -requires-python = '>=3.9' +requires-python = '>=3.11' #dependencies = [ #'setuptools', #'setuptools-scm'