diff --git a/CHANGELOG.md b/CHANGELOG.md index e18c2e4e98..19f6661cf1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,133 @@ Change Log / Release Log for PIConGPU ================================================================ +0.1.0 +----- +**Date:** 2015-05-21 + +This is version `0.1.0` of PIConGPU, a *pre-beta* version. + +Initial field ionization support was added, including the first model for BSI. +The code-base was substantially hardened, fixing several minor and major +issues. Especially, several restart related issues, an issue with 2D3V zigzack +current calculation and a memory issue with Jetson TK1 boards were fixed. +A work-around for a critical CUDA 6.5 compiler bug was applied to all affected +parts of the code. + +### Changes to "Open Beta RC6" + +**.param file changes:** + See full syntax for each file at + https://github.com/ComputationalRadiationPhysics/picongpu/tree/0.1.0/src/picongpu/include/simulation_defines/param + - `componentsConfig.param` & `gasConfig.param` fix typo `gasHomogeneous` #577 + - `physicalConstants.param`: new variable `GAMMA_THRESH` #669 + - `speciesAttributes.param`: new identifier `boundElectrons` and + new aliases `ionizer`, `atomicNumbers` + - `ionizationEnergies.param`, `ionizerConfig.param`: added + +**.unitless file changes:** + See full syntax for each file at + https://github.com/ComputationalRadiationPhysics/picongpu/tree/0.1.0/src/picongpu/include/simulation_defines/unitless + - `gasConfig.unitless`: typo in `gasHomogeneous` #577 + - `speciesAttributes.unitless`: new unit for `boundElectrons` identifier + - `speciesDefinition.unitless`: new traits `GetCharge`, `GetMass`, + `GetChargeState` and added `ionizers` + - `ionizerConfig.unitless`: added + +**New Features:** + - initial support for field ionization: + - basic framework and BSI #595 + - attribute (constant flag) for proton and neutron number #687 #731 + - attribute `boundElectrons` #706 + - tools: + - python scripts: + - new reader for `SliceFieldPrinter` plugin #578 + - new analyzer tool for numerical heating #672 #692 + - `cuda_memtest`: + - 32bit host system support (Jetson TK1) #583 + - works without `nvidia-smi`, `grep` or `gawk` - optional with NVML for + GPU serial number detection (Jetson TK1) #626 + - `splash2txt`: + - removed build option `S2T_RELEASE` and uses `CMAKE_BUILD_TYPE` #591 + - `tbg`: + - allows for defaults for `-s`, `-t`, `-c` via env vars #613 #622 + - 3D live visualization: `server` tool that collects `clients` and + simulations was published #641 + - new/updated particle traits and attributes: + - `getCharge`, `getMass` #596 + - attributes are now automatically initialized to their generic + defaults #607 #615 + - libPMacc: + - machine-dependent `UInt` vector class is now split in explicit + `UInt32` and `UInt64` classes #665 + - nvidia random number generators (RNG) refactored #711 + - plugins: + - background fields do now affect plugins/outputs #600 + - `Radiation` uses/requires HDF5 output #419 #610 #628 #646 #716 + - `SliceFieldPrinter` supports `FieldJ`, output in one file, + updated command-line syntax #548 + - `CountParticles`, `EnergyFields`, `EnergyParticles` support restarts + without overwriting their previous output #636 #703 + +**Bug Fixes:** + - CUDA 6.5: `int(bool)` casts were broken (affects plugins + `BinEnergyParticles`, `PhaseSpace` and might had an effect on methods of the + basic PIC cycle) #570 #651 #656 #657 #678 #680 + - the ZigZag current solver was broken for 2D3V if non-zero + momentum-components in z direction were used (e.g. warm plasmas or + purely transversal KHI) #823 + - host-device-shared memory (SoC) support was broken (Jetson TK1) #633 + - boost 1.56.0+ support via `Resolve` trait #588 #593 #594 + - potential race condition in field update and pusher #604 + - using `--gridDist` could cause a segfault when adding additional arguments, + e.g., in 2D3V setups #638 + - `MessageHeader` (used in `png` and 2D live visualization) leaked memory #683 + - restarts with HDF5: + - static load-balancing via `--gridDist` in y-direction was broken #639 + - parallel setups with particle-empty GPUs hung with HDF5 #609 #611 #642 + - 2D3V field reads were broken (each field's z-component was not initialized + with the checkpointed values again, e.g., `B_z`) #688 #689 + - loading more than 4 billion global particles was potentially broken #721 + - plugins: + - `Visualization` (png & 2D live sim) memory bug in double precision runs #621 + - `ADIOS` + - storing more than 4 billion particles was broken #666 + - default of `adios.aggregators` was broken (now = MPI_Size) #662 + - parallel setups with particle-empty GPUs did hang #661 + - `HDF5`/`ADIOS` output of grid-mapped particle energy for non-relativistic + particles was zero #669 + - libPMacc: + - CMake: path detection could fail #796 #808 + - `DeviceBuffer<*,DIM3>::getPointer()` was broken (does not affect + PIConGPU) #647 + - empty super-cell memory foot print reduced #648 + - `float2int` return type should be int #623 + - CUDA 7: + - cuSTL prefixed templates with `_` are not allowed; usage of static dim + member #630 + - explicit call to `template`-ed `operator()` to avoid waring #750 + - `EnvironmentController` caused a warning about `extendend friend syntax` #644 + - multi-GPU nodes might fail to start up when not using `default` compute + mode with CUDA 7 drivers #643 + +**Misc:** + - HDF5 support requires libSplash 1.2.4+ #642 #715 + - various code clean-up for MSVC #563 #564 #566 #624 #625 + - plugins: + - removed `LineSliceFields` #590 + - `png` plugin write speedup ~2.3x by increasing file size about 12% #698 + - updated contribution guidelines, install, cfg examples #601 #598 #617 #620 + #673 #700 #714 + - updated module examples and cfg files for: + - lawrencium (LBL) #612 + - titan (ORNL) #618 + - hypnos (HZDR) #670 + - an `Empty` example was added, which defaults to the setup given by + all `.param` files in default mode (a standard PIC cycle without lasers nor + particles), see `src/picongpu/include/simulation_defines/` #634 + - some source files had wrong file permissions #668 + + Open Beta RC6 ------------- **Date:** 2014-11-25 diff --git a/README.md b/README.md index 24771abe2a..2db7ece16d 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,9 @@ codes. See the [user guide](https://github.com/ComputationalRadiationPhysics/pic our [getting started video](http://www.youtube.com/watch?v=7ybsD8G4Rsk) and [contact](http://www.hzdr.de/db/Cms?pNid=132&pOid=30354) us! +Please sign up on our **PIConGPU-Users** mailing list: +[Subscribe (Feed)](https://cg.hzdr.de/Lists/picongpu-users/List.html) + **Upgrades:** Every time we update the *master* branch, we publish a new release of PIConGPU. Before you pull the changes in, please read our [ChangeLog](CHANGELOG.md)! You may have to update some of your simulation `.param` files by hand @@ -141,10 +144,9 @@ Active Team - Axel Huebl* - Maximilian Knespel - Richard Pausch* -- Felix Schmitt* -- Conrad Schumann +- Stefan Tietze - Rene Widera* -- Benjamin Worpitz +- Benjamin Worpitz* ### Participants, Former Members and Thanks @@ -156,8 +158,10 @@ The PIConGPU Team expresses its thanks to: - Anton Helm - Wolfgang Hoehnig - Dr. Remi Lehe +- Felix Schmitt(*) - Benjamin Schneider - Joseph Schuchart +- Conrad Schumann - Klaus Steiniger Kudos to everyone who helped! diff --git a/doc/TBG_macros.cfg b/doc/TBG_macros.cfg index 2025824b92..2f55ef1a0e 100644 --- a/doc/TBG_macros.cfg +++ b/doc/TBG_macros.cfg @@ -23,8 +23,8 @@ ## To see all flags available for your PIConGPU binary, run ## picongpu --help. The avalable flags depend on your configuration flags. ## -## Flags that target a specific species e.g. electrons (--png_e) or ions -## (--png_i) must only be used if the respective species is activated (configure flags). +## Flags that target a specific species e.g. electrons (--e_png) or ions +## (--i_png) must only be used if the respective species is activated (configure flags). ## ## If not stated otherwise, variables/flags must not be used more than once! ################################################################################ @@ -83,88 +83,73 @@ TBG_periodic="--periodic 1 0 1" # Enables moving window (sliding) in your simulation TBG_movingWindow="-m" +################################################################################ +## Placeholder for multi data plugins: +## +## placeholders must be substituted with the real data name +## +## = species name e.g. e (electrons), i (ions) +## = field names e.g. FieldE, FieldB, FieldJ +################################################################################ # The following flags are available for the radiation plugin. # For a full description, see the plugins section in the online wiki. -#--radiation_e.period Radiation is calculated every .period steps. Currently 0 or 1 -#--radiation_e.dump Period, after which the calculated radiation data should be dumped to the file system -#--radiation_e.lastRadiation If set to 1, the spectra summed between the last and the current dump-time-step are stored -#--radiation_e.folderLastRad Folder in which the summed spectra are stored -#--radiation_e.totalRadiation Set to 1 to store spectra summed from simulation start till current time step -#--radiation_e.folderTotalRad Folder in which total radiation spectra are stored -#--radiation_e.start Time step to start calculating the radition -#--radiation_e.end Time step to stop calculating the radiation -#--radiation_e.omegaList If spectrum frequencies are taken from a file, this gives the path to this list -#--radiation_e.radPerGPU If set to 1, each GPU stores its own spectra without summing the entire simulation area -#--radiation_e.folderRadPerGPU Folder where the GPU specific spectras are stored -TBG_radiation="--radiation_e.period 1 --radiation_e.dump 2 --radiation_e.totalRadiation 1 \ - --radiation_e.lastRadiation 0 --radiation_e.start 2800 --radiation_e.end 3000" +#--_radiation.period Radiation is calculated every .period steps. Currently 0 or 1 +#--_radiation.dump Period, after which the calculated radiation data should be dumped to the file system +#--_radiation.lastRadiation If flag is set, the spectra summed between the last and the current dump-time-step are stored +#--_radiation.folderLastRad Folder in which the summed spectra are stored +#--_radiation.totalRadiation If flag is set, store spectra summed from simulation start till current time step +#--_radiation.folderTotalRad Folder in which total radiation spectra are stored +#--_radiation.start Time step to start calculating the radition +#--_radiation.end Time step to stop calculating the radiation +#--_radiation.omegaList If spectrum frequencies are taken from a file, this gives the path to this list +#--_radiation.radPerGPU If flag is set, each GPU stores its own spectra without summing the entire simulation area +#--_radiation.folderRadPerGPU Folder where the GPU specific spectras are stored +#--e__radiation.compression If flag is set, the hdf5 output will be compressed. +TBG_radiation="--_radiation.period 1 --_radiation.dump 2 --_radiation.totalRadiation \ + --_radiation.lastRadiation --_radiation.start 2800 --_radiation.end 3000" # Create 2D images in PNG format every .period steps. -# Images can be created for the following particle species: -# - Electrons (--png_e) -# - Ions (--png_i) # The slice plane is defined using .axis [yx,yz] and .slicePoint (offset from origin # as a float within [0.0,1.0]. # The output folder can be set with .folder. # Can be used more than once to print different images, e.g. for YZ and YX planes. -TBG_E_pngYZ="--png_e.period 10 --png_e.axis yz --png_e.slicePoint 0.5 --png_e.folder pngElectronsYZ" -TBG_E_pngYX="--png_e.period 10 --png_e.axis yx --png_e.slicePoint 0.5 --png_e.folder pngElectronsYX" -TBG_I_pngYZ="--png_i.period 10 --png_i.axis yz --png_i.slicePoint 0.5 --png_i.folder pngIonsYZ" -TBG_I_pngYX="--png_i.period 10 --png_i.axis yx --png_i.slicePoint 0.5 --png_i.folder pngIonsYX" +TBG__pngYZ="--_png.period 10 --_png.axis yz --_png.slicePoint 0.5 --_png.folder pngElectronsYZ" +TBG__pngYX="--_png.period 10 --_png.axis yx --_png.slicePoint 0.5 --_png.folder pngElectronsYX" # Notification period of position plugin (single-particle debugging) -TBG_E_pos_dbg="--pos_e.period 1" +TBG__pos_dbg="--_position.period 1" -# Create a particle-energy histogram [in keV] every .period steps for: -# - Electrons (--bin_e) -# - Ions (--bin_i) -TBG_eBin="--bin_e.period 500 --bin_e.binCount 1024 --bin_e.minEnergy 0 --bin_e.maxEnergy 500000" -TBG_iBin="--bin_i.period 500 --bin_i.binCount 1024 --bin_i.minEnergy 0 --bin_i.maxEnergy 500000" +# Create a particle-energy histogram [in keV] per species for every .period steps +TBG__Histogram="--_energyHistogram.period 500 --_energyHistogram.binCount 1024 \ + --_energyHistogram.minEnergy 0 --_energyHistogram.maxEnergy 500000" # Calculate a 2D phase space # - requires parallel libSplash for HDF5 output # - momentum range in m_e c -TBG_ePSxpx="--ps_e.period 10 --ps_e.space x --ps_e.momentum px --ps_e.min -1.0 --ps_e.max 1.0" -TBG_ePSxpz="--ps_e.period 10 --ps_e.space x --ps_e.momentum pz --ps_e.min -1.0 --ps_e.max 1.0" -TBG_ePSypx="--ps_e.period 10 --ps_e.space y --ps_e.momentum px --ps_e.min -1.0 --ps_e.max 1.0" -TBG_ePSypy="--ps_e.period 10 --ps_e.space y --ps_e.momentum py --ps_e.min -1.0 --ps_e.max 1.0" -TBG_ePSypz="--ps_e.period 10 --ps_e.space y --ps_e.momentum pz --ps_e.min -1.0 --ps_e.max 1.0" - - -# Binary density output for slides every .period steps over axis .axis [yx,yz] -# at offset .slicePoint [0.0,1.0] from origin to folder .folder. -# Possible for: -# - Electrons (--binDensity_e) -# - Ions (--binDensity_i) -TBG_E_binaryDensity="--binDensity_e.period 100 --binDensity_e.axis yx \ - --binDensity_e.slicePoint 0.5 --binDensity_e.folder densityElectrons" -TBG_I_binaryDensity="--binDensity_i.period 100 --binDensity_i.axis yx \ - --binDensity_i.slicePoint 0.5 --binDensity_i.folder densityIons" +TBG__PSxpx="--_phaseSpace.period 10 --_phaseSpace.space x --_phaseSpace.momentum px --_phaseSpace.min -1.0 --_phaseSpace.max 1.0" +TBG__PSxpz="--_phaseSpace.period 10 --_phaseSpace.space x --_phaseSpace.momentum pz --_phaseSpace.min -1.0 --_phaseSpace.max 1.0" +TBG__ePSypx="--_phaseSpace.period 10 --_phaseSpace.space y --_phaseSpace.momentum px --_phaseSpace.min -1.0 --_phaseSpace.max 1.0" +TBG__PSypy="--_phaseSpace.period 10 --_phaseSpace.space y --_phaseSpace.momentum py --_phaseSpace.min -1.0 --_phaseSpace.max 1.0" +TBG__PSypz="--_phaseSpace.period 10 --_phaseSpace.space y --_phaseSpace.momentum pz --_phaseSpace.min -1.0 --_phaseSpace.max 1.0" # Sum up total energy every .period steps for -# - Electrons (--energy_e) -# - Ions (--energy_i) -# - Fields (--energy_fields) -TBG_sumEnergy="--energy_fields.period 10 --energy_e.period 10 --energy_i.period 10" +# - species (--_energy) +# - fields (--fields_energy) +TBG_sumEnergy="--fields_energy.period 10 --_energy.period 10" -# Count the number of macro particles every .period steps for -# - Electrons (--elec_cnt) -# - Ions (--ions_cnt) -TBG_macroCount="--elec_cnt.period 100 --ions_cnt.period 100" +# Count the number of macro particles per species for every .period steps +TBG_macroCount="--_macroParticlesCount.period 100" -# Count makro particles per super cell -# (creates HDF5 output via libSplash) -# - Electrons (--countPerSuperCell_e) -# - Ions (--countPerSuperCell_i) -TBG_countPerSuper="--countPerSuperCell_e.period 100 --countPerSuperCell_i.period 100" +# Count makro particles of a species per super cell +TBG_countPerSuper="--_macroParticlesPerSuperCell.period 100 --_macroParticlesPerSuperCell.period 100" # Dump simulation data (fields and particles) to HDF5 files using libSplash. # Data is dumped every .period steps to the fileset .file. @@ -191,10 +176,10 @@ TBG_restart="--restart" # --restart-directory /path/to/simOutput/checkpoints # Connect to a live-view server (start the server in advance) -TBG_liveViewYX="--live_e.period 1 --live_e.slicePoint 0.5 --live_e.ip 10.0.2.254 \ - --live_e.port 2020 --live_e.axis yx" -TBG_liveViewYZ="--live_e.period 1 --live_e.slicePoint 0.5 --live_e.ip 10.0.2.254 \ - --live_e.port 2021 --live_e.axis yz" +TBG_liveViewYX="--_liveView.period 1 --_liveView.slicePoint 0.5 --_liveView.ip 10.0.2.254 \ + --_liveView.port 2020 --_liveView.axis yx" +TBG_liveViewYZ="--_liveView.period 1 --_liveView.slicePoint 0.5 --_liveView.ip 10.0.2.254 \ + --_liveView.port 2021 --_liveView.axis yz" ################################################################################ diff --git a/examples/Bunch/cmakeFlags b/examples/Bunch/cmakeFlags index 6dcbcace42..51dfe6833b 100755 --- a/examples/Bunch/cmakeFlags +++ b/examples/Bunch/cmakeFlags @@ -30,7 +30,8 @@ # - increase by 1, no gaps flags[0]="-DCUDA_ARCH=sm_35" - +flags[1]="-DCUDA_ARCH=sm_35 -DPARAM_OVERWRITES:LIST=-DPARAM_INCLUDE_FIELDBACKGROUND=true" +flags[2]="-DCUDA_ARCH=sm_35 -DPARAM_OVERWRITES:LIST=-DPARAM_INCLUDE_FIELDBACKGROUND=true;-DPARAM_DIMENSION=DIM2" ################################################################################ # execution diff --git a/examples/Bunch/include/simulation_defines/param/componentsConfig.param b/examples/Bunch/include/simulation_defines/param/componentsConfig.param index c4b683428d..34f5525f4e 100644 --- a/examples/Bunch/include/simulation_defines/param/componentsConfig.param +++ b/examples/Bunch/include/simulation_defines/param/componentsConfig.param @@ -1,5 +1,5 @@ /** - * Copyright 2013-2014 Axel Huebl, Anton Helm, Richard Pausch + * Copyright 2013-2015 Axel Huebl, Anton Helm, Richard Pausch * * This file is part of PIConGPU. * @@ -36,6 +36,7 @@ namespace simulation_starter = defaultPIConGPU; * in 'x' direction * - laserWavepacket : wavepacket (Gaussian in time and space, not focusing) * - laserPlaneWave : a plane wave + * - laserPolynom : a polynomial laser envelope */ namespace laserProfile = laserPlaneWave; diff --git a/examples/Bunch/include/simulation_defines/param/fieldBackground.param b/examples/Bunch/include/simulation_defines/param/fieldBackground.param new file mode 100644 index 0000000000..3edc5882c5 --- /dev/null +++ b/examples/Bunch/include/simulation_defines/param/fieldBackground.param @@ -0,0 +1,243 @@ +/** + * Copyright 2014-2015 Axel Huebl, Alexander Debus + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + +#pragma once + +/** Load pre-defined templates */ +#include "fields/background/templates/TWTS/TWTS.hpp" + +#ifndef PARAM_INCLUDE_FIELDBACKGROUND +#define PARAM_INCLUDE_FIELDBACKGROUND false +#endif + +/** Load external background fields + * + */ +namespace picongpu +{ + class FieldBackgroundE + { + public: + + /* Add this additional field for pushing particles */ + static const bool InfluenceParticlePusher = PARAM_INCLUDE_FIELDBACKGROUND; + + /* We use this to calculate your SI input back to our unit system */ + PMACC_ALIGN(unitField, const float3_64); + + /* TWTS E-fields need to be initialized on host, + * so they can look up global grid dimensions. + * + * Note: No PMACC_ALIGN(...) used, since this *additional* memory alignment would require + * roughly double the number of registers in the corresponding kernel on the device. + */ + const templates::twts::EField twtsFieldE; + + /* Constructor is host-only, because of subGrid and halfSimSize initialization */ + HINLINE FieldBackgroundE( const float3_64 unitField ) : + + unitField(unitField), + + twtsFieldE( + /* focus_y [m], the distance to the laser focus in y-direction */ + 30.0e-6, + /* wavelength [m] */ + 0.8e-6, + /* pulselength [s], sigma of std. gauss for intensity (E^2) */ + 10.0e-15 / 2.3548200450309493820231386529194, + /* w_x [m], cylindrically focused spot size */ + 5.0e-6, + /* w_y [m] */ + 0.01, + /* interaction angle between TWTS laser propagation vector and the y-axis [rad] */ + 60. * (PI/180.), + /* propagation speed of overlap [speed of light]. */ + 1.0, + /* manual time delay [s] if auto_tdelay is false */ + 39.3e-6 / SI::SPEED_OF_LIGHT_SI, + /* Should PIConGPU automatically choose a suitable time delay? [true/false] */ + false ) + {} + + /** Specify your background field E(r,t) here + * + * \param cellIdx The total cell id counted from the start at t=0 + * \param currentStep The current time step */ + HDINLINE float3_X + operator()( const DataSpace& cellIdx, + const uint32_t currentStep ) const + { + /* unit: meter */ + const double WAVE_LENGTH_SI = 0.8e-6; + + /** UNITCONV */ + /* const double UNITCONV_Intens_to_A0 = SI::ELECTRON_CHARGE_SI + * SI::ELECTRON_CHARGE_SI * 2.0 * WAVE_LENGTH_SI * WAVE_LENGTH_SI / (4.0 * PI * PI + * SI::ELECTRON_MASS_SI * SI::ELECTRON_MASS_SI * SI::SPEED_OF_LIGHT_SI + * SI::SPEED_OF_LIGHT_SI * SI::SPEED_OF_LIGHT_SI * SI::SPEED_OF_LIGHT_SI + * SI::SPEED_OF_LIGHT_SI * SI::EPS0_SI); */ + const double UNITCONV_A0_to_Amplitude_SI = -2.0 * PI / WAVE_LENGTH_SI + * SI::ELECTRON_MASS_SI * SI::SPEED_OF_LIGHT_SI + * SI::SPEED_OF_LIGHT_SI / SI::ELECTRON_CHARGE_SI; + + /* unit: W / m^2 + * const double _PEAK_INTENSITY_SI = 3.4e19 * 1.0e4; + * unit: none + * const double _A0 = _PEAK_INTENSITY_SI * UNITCONV_Intens_to_A0; + */ + + /* unit: none */ + const double _A0 = 1.0; + + /* unit: Volt /meter + *\todo #738 implement math::vector, native type operations + */ + const float3_64 invUnitField = float3_64(1.0 / unitField[0], + 1.0 / unitField[1], + 1.0 / unitField[2] ); + + /* laser amplitude in picongpu units [ unit: (Volt /meter) / unitField-factor ] + * Note: the laser amplitude is included in all field components + * polarization and other properties are established by the peak amplitude + * normalized twtsFieldE(...) + */ + const float3_X amplitude = precisionCast( + float_64(_A0 * UNITCONV_A0_to_Amplitude_SI) * invUnitField ); + + /* Note: twtsFieldE(...) is normalized, such that peak amplitude equals unity. */ + return amplitude * twtsFieldE( cellIdx, currentStep ); + } + }; + + class FieldBackgroundB + { + public: + /* Add this additional field for pushing particles */ + static const bool InfluenceParticlePusher = PARAM_INCLUDE_FIELDBACKGROUND; + + /* TWTS B-fields need to be initialized on host, + * so they can look up global grid dimensions. + * + * Note: No PMACC_ALIGN(...) used, since this *additional* memory alignment would require + * roughly double the number of registers in the corresponding kernel on the device. + */ + const templates::twts::BField twtsFieldB; + + /* We use this to calculate your SI input back to our unit system */ + PMACC_ALIGN(unitField, const float3_64); + + HINLINE FieldBackgroundB( const float3_64 unitField ) : + + unitField(unitField), + + twtsFieldB( + /* focus_y [m], the distance to the laser focus in y-direction */ + 30.0e-6, + /* wavelength [m] */ + 0.8e-6, + /* pulselength [s], sigma of std. gauss for intensity (E^2) */ + 10.0e-15 / 2.3548200450309493820231386529194, + /* w_x [m], cylindrically focused spot size */ + 5.0e-6, + /* w_y [m] */ + 0.01, + /* interaction angle between TWTS laser propagation vector and the y-axis [rad] */ + 60. * (PI / 180.), + /* propagation speed of overlap [speed of light]. */ + 1.0, + /* manual time delay [s] if auto_tdelay is false */ + 39.3e-6 / SI::SPEED_OF_LIGHT_SI, + /* Should PIConGPU automatically choose a suitable time delay? [true / false] */ + false ) + {} + + /** Specify your background field B(r,t) here + * + * \param cellIdx The total cell id counted from the start at t=0 + * \param currentStep The current time step */ + HDINLINE float3_X + operator()( const DataSpace& cellIdx, + const uint32_t currentStep ) const + { + /* unit: meter */ + const double WAVE_LENGTH_SI = 0.8e-6; + + /** UNITCONV */ + /* const double UNITCONV_Intens_to_A0 = SI::ELECTRON_CHARGE_SI + * SI::ELECTRON_CHARGE_SI * 2.0 * WAVE_LENGTH_SI * WAVE_LENGTH_SI / (4.0 * PI * PI + * SI::ELECTRON_MASS_SI * SI::ELECTRON_MASS_SI * SI::SPEED_OF_LIGHT_SI + * SI::SPEED_OF_LIGHT_SI * SI::SPEED_OF_LIGHT_SI * SI::SPEED_OF_LIGHT_SI + * SI::SPEED_OF_LIGHT_SI * SI::EPS0_SI); */ + const double UNITCONV_A0_to_Amplitude_SI = -2.0 * PI / WAVE_LENGTH_SI + * SI::ELECTRON_MASS_SI * SI::SPEED_OF_LIGHT_SI + * SI::SPEED_OF_LIGHT_SI / SI::ELECTRON_CHARGE_SI; + + /* unit: W / m^2 + * const double _PEAK_INTENSITY_SI = 3.4e19 * 1.0e4; + * unit: none + * const double _A0 = _PEAK_INTENSITY_SI * UNITCONV_Intens_to_A0; + */ + + /** unit: none */ + const double _A0 = 1.0; + + /** unit: Volt /meter */ + const float3_64 invUnitField = float3_64( 1.0 / unitField[0], + 1.0 / unitField[1], + 1.0 / unitField[2] ); + + /* laser amplitude in picongpu units [ unit: (Volt/meter) / unitField-factor ] + * Note: the laser amplitude is included in all field components + * polarization and other properties are established by the peak amplitude + * normalized twtsFieldB(...) + */ + const float3_X amplitude = precisionCast( + float_64(_A0 * UNITCONV_A0_to_Amplitude_SI) * invUnitField ); + + /* Note: twtsFieldB(...) is normalized, such that peak amplitude equals unity. */ + return amplitude * twtsFieldB( cellIdx, currentStep ); + } + }; + + class FieldBackgroundJ + { + public: + /* Add this additional field? */ + static const bool activated = false; + + /* We use this to calculate your SI input back to our unit system */ + PMACC_ALIGN(unitField, const float3_64); + + HDINLINE FieldBackgroundJ( const float3_64 unitField ) : unitField(unitField) + {} + + /** Specify your background field J(r,t) here + * + * \param cellIdx The total cell id counted from the start at t=0 + * \param currentStep The current time step */ + HDINLINE float3_X + operator()( const DataSpace& cellIdx, + const uint32_t currentStep ) const + { + return float3_X(0.0, 0.0, 0.0); + } + }; + +} /* namespace picongpu */ diff --git a/examples/Bunch/include/simulation_defines/param/gridConfig.param b/examples/Bunch/include/simulation_defines/param/gridConfig.param index d87b6fef7a..e43bdadc3e 100644 --- a/examples/Bunch/include/simulation_defines/param/gridConfig.param +++ b/examples/Bunch/include/simulation_defines/param/gridConfig.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Rene Widera, Richard Pausch * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ @@ -53,7 +53,7 @@ namespace picongpu {1.0e-3, 1.0e-3}, /*x direction [negative,positive]*/ {1.0e-3, 1.0e-3}, /*y direction [negative,positive]*/ {1.0e-3, 1.0e-3} /*z direction [negative,positive]*/ - }; //unit: none + }; //unit: none const uint32_t ABSORBER_FADE_IN_STEPS = 16; @@ -62,7 +62,7 @@ namespace picongpu * is fired at the begin of the simulation. * When it reaches slide_point % of the absolute(*) simulation area, * the co-moving window starts to move with the speed of light. - * + * * (*) Note: beware, that there is one "hidden" row of gpus at the y-front, * when you use the co-moving window * 0.75 means only 75% of simulation area is used for real simulation diff --git a/examples/Bunch/include/simulation_defines/param/laserConfig.param b/examples/Bunch/include/simulation_defines/param/laserConfig.param index 669c2dbf0b..3d308f78b7 100644 --- a/examples/Bunch/include/simulation_defines/param/laserConfig.param +++ b/examples/Bunch/include/simulation_defines/param/laserConfig.param @@ -1,22 +1,22 @@ /** - * Copyright 2013-2014 Anton Helm, Richard Pausch + * Copyright 2013-2015 Anton Helm, Richard Pausch * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ @@ -72,6 +72,9 @@ const double FOCUS_POS_SI = 4.62e-5; * unit: none */ const double PULSE_INIT = 20.0; +/* laser phase shift (no shift: 0.0) */ +const float_X LASER_PHASE = 0.0; /* unit: rad, periodic in 2*pi */ + enum PolarisationType { LINEAR_X = 1u, @@ -123,6 +126,9 @@ const double TILT_X_SI = 0; * unit: none */ const double PULSE_INIT = 20.0; +/* laser phase shift (no shift: 0.0) */ +const float_X LASER_PHASE = 0.0; /* unit: rad, periodic in 2*pi */ + enum PolarisationType { LINEAR_X = 1u, @@ -177,6 +183,9 @@ const double PULSE_LENGTH_SI = 10.615e-15 / 4.0; //5.0e-15; //25.0e-15 / 1.17741 * unit: none */ const double RAMP_INIT = 20.6146; //25.6415;//SI::aux_calulation::PULSE_TIME_SI/SI::PULSE_LENGTH_SI; +/* we use a sin(omega*time + laser_phase) function to set up the laser - define phase: */ +const float_X LASER_PHASE = 0.0; /* unit: rad, periodic in 2*pi */ + enum PolarisationType { LINEAR_X = 1u, @@ -239,6 +248,9 @@ and half at the end of the plateau * unit: none */ const double RAMP_INIT = 20.0; +/* we use a sin(omega*time + laser_phase) function to set up the laser - define phase: */ +const float_X LASER_PHASE = 0.0; /* unit: rad, periodic in 2*pi */ + enum PolarisationType { LINEAR_X = 1u, @@ -276,11 +288,11 @@ const double UNITCONV_A0_to_Amplitude_SI = -2.0 * PI / WAVE_LENGTH_SI * ::picong const double AMPLITUDE_SI = 1.738e13; -/** Pulse length: +/** Pulse length: * PULSE_LENGTH_SI = total length of polynamial laser pulse * Rise time = 0.5 * PULSE_LENGTH_SI * Fall time = 0.5 * PULSE_LENGTH_SI - * in order to compare to a gaussian pulse: rise time = sqrt{2} * T_{FWHM} + * in order to compare to a gaussian pulse: rise time = sqrt{2} * T_{FWHM} * unit: seconds */ const double PULSE_LENGTH_SI = 4.0e-15; @@ -288,9 +300,12 @@ const double PULSE_LENGTH_SI = 4.0e-15; * decreases to its 1/e^2-th part, * at the focus position of the laser * unit: meter */ -const double W0x_SI = 4.246e-6; // waist in x-direction +const double W0x_SI = 4.246e-6; // waist in x-direction const double W0z_SI = W0x_SI; // waist in z-direction } + +/* we use a sin(omega*(time-riseTime) + laser_phase) function to set up the laser - define phase: */ +const float_X LASER_PHASE = 0.0; /* unit: rad, periodic in 2*pi */ } namespace laserNone diff --git a/examples/Bunch/include/simulation_defines/param/precision.param b/examples/Bunch/include/simulation_defines/param/precision.param index d2cb49ab7a..7102705b02 100644 --- a/examples/Bunch/include/simulation_defines/param/precision.param +++ b/examples/Bunch/include/simulation_defines/param/precision.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Richard Pausch * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ diff --git a/examples/Bunch/include/simulation_defines/param/radiationConfig.param b/examples/Bunch/include/simulation_defines/param/radiationConfig.param index 3a93cdf4ed..c4b8e68592 100644 --- a/examples/Bunch/include/simulation_defines/param/radiationConfig.param +++ b/examples/Bunch/include/simulation_defines/param/radiationConfig.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Rene Widera, Richard Pausch * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ @@ -24,7 +24,7 @@ /* radiation verbose level: - 0=nothing, 1=physics, 2=simulation_state, 4=memory, 8=critical + 0=nothing, 1=physics, 2=simulation_state, 4=memory, 8=critical */ #define PIC_VERBOSE_RADIATION 3 @@ -79,22 +79,22 @@ namespace radiationNyquist -/////////////////////////////////////////////////// +/////////////////////////////////////////////////// namespace picongpu { - // corect treatment of coherent and incoherent radiation from macroparticles - // 1 = on (slower and more memory, but correct quantitativ treatment) - // 0 = off (faster but macroparticles are treated as highly charged, point-like particle) + // corect treatment of coherent and incoherent radiation from macroparticles + // 1 = on (slower and more memory, but correct quantitativ treatment) + // 0 = off (faster but macroparticles are treated as highly charged, point-like particle) #define __COHERENTINCOHERENTWEIGHTING__ 1 /* Choose different form factors in order to consider different particle shapes for radiation - * radFormFactor_CIC_3D + * radFormFactor_CIC_3D * radFormFactor_CIC_1Dy */ namespace radFormFactor_CIC_3D { } @@ -104,11 +104,11 @@ namespace picongpu namespace radFormFactor = radFormFactor_CIC_3D; -}//namespace picongpu +}//namespace picongpu -/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// @@ -118,19 +118,19 @@ namespace parameters /*!enable radiation calculation*/ #define ENABLE_RADIATION 1 -// Nyquist low pass allows only amplitudes for frequencies below Nyquist frequency -// 1 = on (slower and more memory, no fourier reflections) -// 0 = off (faster but with fourier reflections) +// Nyquist low pass allows only amplitudes for frequencies below Nyquist frequency +// 1 = on (slower and more memory, no fourier reflections) +// 0 = off (faster but with fourier reflections) #define __NYQUISTCHECK__ 1 -//marked every N particle for calculate radiation -//mark no particle at beginning +//marked every N particle for calculate radiation +//mark no particle at beginning #define RAD_MARK_PARTICLE 1 -//disable or enable gamme filter -//diable (0) / enable (1) +//disable or enable gamme filter +//diable (0) / enable (1) #define RAD_ACTIVATE_GAMMA_FILTER 0 const float RadiationGamma = 5.; @@ -150,26 +150,22 @@ namespace picongpu // add a window function weighting to the radiation in order // to avoid ringing effects from sharpe boundaries -// 1 = on (slower but with noise/ringing reduction) -// 0 = off (faster but might contain ringing) -#define PIC_RADWINDOWFUNCTION 0 - - +// default: no window function via `radWindowFunctionNone` /* Choose different window function in order to get better ringing reduction - * radWindowFunctionRectangle * radWindowFunctionTriangle * radWindowFunctionHamming * radWindowFunctionTriplett * radWindowFunctionGauss + * radWindowFunctionNone */ -namespace radWindowFunctionRectangle { } namespace radWindowFunctionTriangle { } namespace radWindowFunctionHamming { } namespace radWindowFunctionTriplett { } namespace radWindowFunctionGauss { } +namespace radWindowFunctionNone { } -namespace radWindowFunction = radWindowFunctionTriangle; +namespace radWindowFunction = radWindowFunctionNone; }//namespace picongpu diff --git a/examples/Bunch/include/simulation_defines/param/radiationObserver.param b/examples/Bunch/include/simulation_defines/param/radiationObserver.param index 5b45916240..fa60660bdb 100644 --- a/examples/Bunch/include/simulation_defines/param/radiationObserver.param +++ b/examples/Bunch/include/simulation_defines/param/radiationObserver.param @@ -1,22 +1,22 @@ /** - * Copyright 2013-2014 Heiko Burau, Richard Pausch + * Copyright 2013-2015 Heiko Burau, Richard Pausch * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ #pragma once @@ -25,9 +25,9 @@ namespace picongpu { namespace radiation_observer { - /** Compute observation angles + /** Compute observation angles * - * This function is used in the Radiation plug-in kernel to compute + * This function is used in the Radiation plug-in kernel to compute * the observation directions given as a unit vector pointing * towards a 'virtual' detector * @@ -36,14 +36,14 @@ namespace picongpu * to compute the observation direction * * @return unit vector pointing in observation direction - * type: vec2 - * + * type: vector_64 + * */ - DINLINE vec2 observation_direction(const int observation_id_extern) + DINLINE vector_64 observation_direction(const int observation_id_extern) { /** Computes observation angles along the x-y plane. * Assuming electron(s) fly in -x direction and the laser - * propages in +x direction, the observation angles are centered + * propages in +x direction, the observation angles are centered * around the -y-axis (0,-1,0) . * By setting gamma, the angle range can be adjusted to the * energy of the electrons. @@ -53,19 +53,19 @@ namespace picongpu const int my_theta_id = observation_id_extern; /* set up: */ - const numtype2 gamma_times_thetaMax = 1.5; /* max normalized angle */ - const numtype2 gamma = 5.0; /* relativistic gamma */ - const numtype2 thetaMax = gamma_times_thetaMax / gamma; /* max angle */ + const picongpu::float_64 gamma_times_thetaMax = 1.5; /* max normalized angle */ + const picongpu::float_64 gamma = 5.0; /* relativistic gamma */ + const picongpu::float_64 thetaMax = gamma_times_thetaMax / gamma; /* max angle */ /* stepwith of theta for from [-thetaMax : +thetaMax] */ - const numtype2 delta_theta = 2.0 * thetaMax / (parameters::N_observer); + const picongpu::float_64 delta_theta = 2.0 * thetaMax / (parameters::N_observer); /* compute angle theta for index */ - const numtype2 theta(my_theta_id * delta_theta - thetaMax + picongpu::PI); + const picongpu::float_64 theta(my_theta_id * delta_theta - thetaMax + picongpu::PI); /* + picongpu::PI -> turn observation direction 180 degrees towards -y */ /* compute observation unit vector */ - return vec2(sinf(theta), cosf(theta), 0.0); + return vector_64(sinf(theta), cosf(theta), 0.0); } diff --git a/examples/Bunch/include/simulation_defines/param/species.param b/examples/Bunch/include/simulation_defines/param/species.param index a3cda48c2b..d4dd8ea893 100644 --- a/examples/Bunch/include/simulation_defines/param/species.param +++ b/examples/Bunch/include/simulation_defines/param/species.param @@ -1,5 +1,5 @@ /** - * Copyright 2014 Rene Widera + * Copyright 2014-2015 Rene Widera * * This file is part of PIConGPU. * @@ -45,6 +45,7 @@ namespace picongpu * - particles::shapes::CIC : 1st order * - particles::shapes::TSC : 2nd order (requires CUDA_ARCH>=sm_20) * - particles::shapes::PCS : 3rd order (requires CUDA_ARCH>=sm_20) + * - particles::shapes::P4S : 4th order (requires CUDA_ARCH>=sm_20) * * example: typedef particles::shapes::CIC CICShape; */ @@ -54,9 +55,9 @@ typedef particles::shapes::CIC UsedParticleShape; typedef FieldToParticleInterpolation UsedField2Particle; /*! select current solver method ----------------------------------------------- - * - currentSolver::Esirkepov : particle shapes - CIC, TSC, PCS (1st to 3rd order) + * - currentSolver::Esirkepov : particle shapes - CIC, TSC, PCS, P4S (1st to 4th order) * - currentSolver::VillaBune<> : particle shapes - CIC (1st order) only - * - currentSolver::ZigZag : particle shapes - CIC, TSC, PCS (1st to 3rd order) + * - currentSolver::ZigZag : particle shapes - CIC, TSC, PCS , P4S (1st to 4th order) * * For development purposes: --------------------------------------------------- * - currentSolver::EsirkepovNative : generic version of currentSolverEsirkepov diff --git a/examples/Bunch/include/simulation_defines/param/speciesInitialization.param b/examples/Bunch/include/simulation_defines/param/speciesInitialization.param index 4ad51907d5..7b073366c2 100644 --- a/examples/Bunch/include/simulation_defines/param/speciesInitialization.param +++ b/examples/Bunch/include/simulation_defines/param/speciesInitialization.param @@ -32,7 +32,8 @@ namespace picongpu * the functors are called in order (from first to last functor) */ typedef mpl::vector< - particles::CreateGas + particles::CreateGas, + particles::Manipulate > InitPipeline; } //namespace picongpu diff --git a/examples/Bunch/include/simulation_defines/param/starter.param b/examples/Bunch/include/simulation_defines/param/starter.param index 1be850a561..f241c5ad6e 100644 --- a/examples/Bunch/include/simulation_defines/param/starter.param +++ b/examples/Bunch/include/simulation_defines/param/starter.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Richard Pausch * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ diff --git a/examples/Bunch/include/simulation_defines/param/visColorScales.param b/examples/Bunch/include/simulation_defines/param/visColorScales.param index 66a3497bc1..754f1b68ff 100644 --- a/examples/Bunch/include/simulation_defines/param/visColorScales.param +++ b/examples/Bunch/include/simulation_defines/param/visColorScales.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Heiko Burau, Richard Pausch * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ diff --git a/examples/Bunch/include/simulation_defines/param/visualization.param b/examples/Bunch/include/simulation_defines/param/visualization.param index 67e88aeb83..6358881ee0 100644 --- a/examples/Bunch/include/simulation_defines/param/visualization.param +++ b/examples/Bunch/include/simulation_defines/param/visualization.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Heiko Burau, Richard Pausch * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ #pragma once diff --git a/examples/Bunch/submit/bunch_0032.cfg b/examples/Bunch/submit/bunch_0032.cfg index 7991ef7189..a4b460a1f6 100644 --- a/examples/Bunch/submit/bunch_0032.cfg +++ b/examples/Bunch/submit/bunch_0032.cfg @@ -47,18 +47,18 @@ TBG_periodic="--periodic 1 0 1" ## Section: Optional Variables ## #################################s -TBG_radiation="--radiation_e.period 1 --radiation_e.dump 2 --radiation_e.totalRadiation 1 \ - --radiation_e.lastRadiation 0 --radiation_e.start 2800 --radiation_e.end 3000" +TBG_radiation="--e_radiation.period 1 --e_radiation.dump 2 --e_radiation.totalRadiation \ + --e_radiation.start 2800 --e_radiation.end 3000" -TBG_pngYX="--png_e.period 100 --png_e.axis yx --png_e.slicePoint 0.5 --png_e.folder pngElectronsYX" +TBG_pngYX="--e_png.period 100 --e_png.axis yx --e_png.slicePoint 0.5 --e_png.folder pngElectronsYX" # [in keV] -TBG_eBin="--bin_e.period 500 --bin_e.binCount 1024 --bin_e.minEnergy 0 --bin_e.maxEnergy 500000" +TBG_eBin="--e_energyHistogram.period 500 --e_energyHistogram.binCount 1024 --e_energyHistogram.minEnergy 0 --e_energyHistogram.maxEnergy 500000" TBG_plugins="!TBG_eBin \ !TBG_pngYX \ !TBG_radiation \ - --elec_cnt.period 100" + --e_macroParticlesCount.period 100" ################################# diff --git a/examples/KelvinHelmholtz/cmakeFlags b/examples/KelvinHelmholtz/cmakeFlags index e04c4b5fae..8a534c8dd2 100755 --- a/examples/KelvinHelmholtz/cmakeFlags +++ b/examples/KelvinHelmholtz/cmakeFlags @@ -36,6 +36,7 @@ flags[3]="-DCUDA_ARCH=sm_35 -DPARAM_OVERWRITES:LIST=-DPARAM_CURRENTSOLVER=ZigZag flags[4]="-DCUDA_ARCH=sm_35 -DPARAM_OVERWRITES:LIST=-DPARAM_CURRENTSOLVER=ZigZag;-DPARAM_PARTICLESHAPE=PCS" flags[5]="-DCUDA_ARCH=sm_35 -DPARAM_OVERWRITES:LIST=-DPARAM_CURRENTSOLVER=ZigZag;-DPARAM_PARTICLESHAPE=TSC" flags[6]="-DCUDA_ARCH=sm_35 -DPARAM_OVERWRITES:LIST=-DPARAM_CURRENTSOLVER=ZigZag;-DPARAM_PARTICLESHAPE=TSC;-DPARAM_DIMENSION=DIM2" +flags[7]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_FIELDSOLVER=fieldSolverDirSplitting" ################################################################################ diff --git a/examples/KelvinHelmholtz/include/simulation_defines/extensionParam.loader b/examples/KelvinHelmholtz/include/simulation_defines/extensionParam.loader index 7892e097ae..b7e0f79088 100644 --- a/examples/KelvinHelmholtz/include/simulation_defines/extensionParam.loader +++ b/examples/KelvinHelmholtz/include/simulation_defines/extensionParam.loader @@ -1,22 +1,22 @@ /** * Copyright 2013 Axel Huebl, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ #pragma once diff --git a/examples/KelvinHelmholtz/include/simulation_defines/extensionUnitless.loader b/examples/KelvinHelmholtz/include/simulation_defines/extensionUnitless.loader index a01dfbd880..b07b017c53 100644 --- a/examples/KelvinHelmholtz/include/simulation_defines/extensionUnitless.loader +++ b/examples/KelvinHelmholtz/include/simulation_defines/extensionUnitless.loader @@ -1,22 +1,22 @@ /** * Copyright 2013 Axel Huebl, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ #pragma once diff --git a/examples/KelvinHelmholtz/include/simulation_defines/param/componentsConfig.param b/examples/KelvinHelmholtz/include/simulation_defines/param/componentsConfig.param index d66119f134..5a697e3c81 100644 --- a/examples/KelvinHelmholtz/include/simulation_defines/param/componentsConfig.param +++ b/examples/KelvinHelmholtz/include/simulation_defines/param/componentsConfig.param @@ -1,5 +1,5 @@ /** - * Copyright 2013-2014 Axel Huebl, Anton Helm, Rene Widera, Richard Pausch + * Copyright 2013-2015 Axel Huebl, Anton Helm, Rene Widera, Richard Pausch * * This file is part of PIConGPU. * @@ -36,6 +36,7 @@ namespace picongpu * in 'x' direction * - laserWavepacket : wavepacket (Gaussian in time and space, not focusing) * - laserPlaneWave : a plane wave + * - laserPolynom : a polynomial laser envelope */ namespace laserProfile = laserNone; @@ -49,7 +50,13 @@ namespace picongpu * - fieldSolverYeeNative : generic version of fieldSolverYee * (need more shared memory per GPU and is slow) */ - namespace fieldSolver = fieldSolverYee; +#ifndef PARAM_FIELDSOLVER +/* WARNING: if you change field solver by hand please update your CELL_WIDTH_SI + * in `gridConfig.param` to fulfill the convergence condition (CFL) + */ +#define PARAM_FIELDSOLVER fieldSolverYee +#endif +namespace fieldSolver = PARAM_FIELDSOLVER; /*enable (1) or disable (0) current calculation*/ #define ENABLE_CURRENT 1 diff --git a/examples/KelvinHelmholtz/include/simulation_defines/param/gridConfig.param b/examples/KelvinHelmholtz/include/simulation_defines/param/gridConfig.param index e439956e04..e9ff63f520 100644 --- a/examples/KelvinHelmholtz/include/simulation_defines/param/gridConfig.param +++ b/examples/KelvinHelmholtz/include/simulation_defines/param/gridConfig.param @@ -1,23 +1,23 @@ /** - * Copyright 2013-2014 Axel Huebl, Rene Widera, Richard Pausch + * Copyright 2013-2015 Axel Huebl, Rene Widera, Richard Pausch * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ - + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + #pragma once @@ -29,16 +29,36 @@ namespace picongpu { /** Duration of one timestep * unit: seconds */ - const double DELTA_T_SI = 1.5e-16; + const double DELTA_T_SI = 1.79e-16; /** equals X * unit: meter */ +#define fieldSolverDirSplitting 1 +#if (PARAM_FIELDSOLVER == 1) + /* THIS CODE PATH IS ONLY USED IF `PARAM_FIELDSOLVER` IS CHANGED IN + * `cmakeFlags` and the field solver there is set to fieldSolverDirSplitting + * + * Directional Splitting requires a fixed ratio between dt and dx + * and in addition cubic cells. + * conditions: dX == dt * c + * dX == dY + * dX == dZ + */ + const double CELL_WIDTH_SI = DELTA_T_SI*SPEED_OF_LIGHT_SI; +#else + /* cell size for Yee solver (must fulfill CFL) + * WARNING: if you change the field solver in `componentsConfig` you + * have to change the CELL_SIZE in this code path + */ const double CELL_WIDTH_SI = 9.34635e-8; +#endif +#undef fieldSolverDirSplitting + /** equals Y - the propagation direction * unit: meter */ - const double CELL_HEIGHT_SI = 9.34635e-8; + const double CELL_HEIGHT_SI = CELL_WIDTH_SI; /** equals Z * unit: meter */ - const double CELL_DEPTH_SI = 9.34635e-8; + const double CELL_DEPTH_SI = CELL_WIDTH_SI; } //namespace SI //! Defines the size of the absorbing zone (in cells) @@ -47,22 +67,22 @@ namespace picongpu {32, 32}, /*y direction [negative,positive]*/ {32, 32} /*z direction [negative,positive]*/ }; //unit: number of cells - + //! Define the strange of the absober for any direction const float_X ABSORBER_STRENGTH[3][2] = { {1.0e-3, 1.0e-3}, /*x direction [negative,positive]*/ {1.0e-3, 1.0e-3}, /*y direction [negative,positive]*/ {1.0e-3, 1.0e-3} /*z direction [negative,positive]*/ - }; //unit: none + }; //unit: none const uint32_t ABSORBER_FADE_IN_STEPS = 16; - + /** When to move the co-moving window. * An initial pseudo particle, flying with the speed of light, * is fired at the begin of the simulation. * When it reaches slide_point % of the absolute(*) simulation area, * the co-moving window starts to move with the speed of light. - * + * * (*) Note: beware, that there is one "hidden" row of gpus at the y-front, * when you use the co-moving window * 0.75 means only 75% of simulation area is used for real simulation diff --git a/examples/KelvinHelmholtz/include/simulation_defines/param/radiationConfig.param b/examples/KelvinHelmholtz/include/simulation_defines/param/radiationConfig.param index 3ad7825102..7c265eb86e 100644 --- a/examples/KelvinHelmholtz/include/simulation_defines/param/radiationConfig.param +++ b/examples/KelvinHelmholtz/include/simulation_defines/param/radiationConfig.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Rene Widera, Richard Pausch * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ @@ -52,7 +52,7 @@ namespace SI //const double omega_min = 1.0e14; //const double omega_max = 1.0e17; // plasma omega = sqrt( (Teilchendichte * (1.6e-19)^2) / (8.854e-12 * 9.11e-31) ) - // = 2.52e14 Hz + // = 2.52e14 Hz const double omega_min = 0.1*2.52e14; const double omega_max = 200*2.52e14; } @@ -83,22 +83,22 @@ namespace radiationNyquist -/////////////////////////////////////////////////// +/////////////////////////////////////////////////// namespace picongpu { - // corect treatment of coherent and incoherent radiation from macroparticles - // 1 = on (slower and more memory, but correct quantitativ treatment) - // 0 = off (faster but macroparticles are treated as highly charged, point-like particle) + // corect treatment of coherent and incoherent radiation from macroparticles + // 1 = on (slower and more memory, but correct quantitativ treatment) + // 0 = off (faster but macroparticles are treated as highly charged, point-like particle) #define __COHERENTINCOHERENTWEIGHTING__ 0 /* Choose different form factors in order to consider different particle shapes for radiation - * radFormFactor_CIC_3D + * radFormFactor_CIC_3D * radFormFactor_CIC_1Dy */ namespace radFormFactor_CIC_3D { } @@ -108,11 +108,11 @@ namespace picongpu namespace radFormFactor = radFormFactor_CIC_3D; -}//namespace picongpu +}//namespace picongpu -/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// @@ -156,24 +156,20 @@ namespace picongpu // add a window function weighting to the radiation in order // to avoid ringing effects from sharpe boundaries -// 1 = on (slower but with noise/ringing reduction) -// 0 = off (faster but might contain ringing) -#define PIC_RADWINDOWFUNCTION 1 - - +// default: no window function via `radWindowFunctionNone` /* Choose different window function in order to get better ringing reduction - * radWindowFunctionRectangle * radWindowFunctionTriangle * radWindowFunctionHamming * radWindowFunctionTriplett * radWindowFunctionGauss + * radWindowFunctionNone */ -namespace radWindowFunctionRectangle { } namespace radWindowFunctionTriangle { } namespace radWindowFunctionHamming { } namespace radWindowFunctionTriplett { } namespace radWindowFunctionGauss { } +namespace radWindowFunctionNone { } namespace radWindowFunction = radWindowFunctionTriangle; diff --git a/examples/KelvinHelmholtz/include/simulation_defines/param/radiationObserver.param b/examples/KelvinHelmholtz/include/simulation_defines/param/radiationObserver.param index 7cfd3e80f5..5f6a23a1a3 100644 --- a/examples/KelvinHelmholtz/include/simulation_defines/param/radiationObserver.param +++ b/examples/KelvinHelmholtz/include/simulation_defines/param/radiationObserver.param @@ -1,22 +1,22 @@ /** - * Copyright 2013-2014 Heiko Burau, Rene Widera, Richard Pausch + * Copyright 2013-2015 Heiko Burau, Rene Widera, Richard Pausch * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ #pragma once @@ -25,9 +25,9 @@ namespace picongpu { namespace radiation_observer { - /** Compute observation angles + /** Compute observation angles * - * This function is used in the Radiation plug-in kernel to compute + * This function is used in the Radiation plug-in kernel to compute * the observation directions given as a unit vector pointing * towards a 'virtual' detector * @@ -36,12 +36,12 @@ namespace picongpu * to compute the observation direction * * @return unit vector pointing in observation direction - * type: vec2 - * + * type: vector_64 + * */ - DINLINE vec2 observation_direction(const int observation_id_extern) + DINLINE vector_64 observation_direction(const int observation_id_extern) { - /** This computes observation directions for one octant + /** This computes observation directions for one octant * of a sphere around the simulation area. * The axises of the octant point towards: * (+1,0,0) ; (0,+1,0) ; (0,0,-1) @@ -55,17 +55,17 @@ namespace picongpu const int my_index_phi = observation_id_extern % N_angle_split; /* range for BOTH angles */ - const numtype2 angle_range= picongpu::PI/2.0; + const picongpu::float_64 angle_range= picongpu::PI/2.0; /* angle stepwidth for BOTH angles */ - const numtype2 delta_angle = 1.0 * angle_range / (N_angle_split-1); + const picongpu::float_64 delta_angle = 1.0 * angle_range / (N_angle_split-1); /* compute both angles */ - const numtype2 theta( my_index_theta * delta_angle + 0.5*picongpu::PI ); - const numtype2 phi( my_index_phi * delta_angle ); + const picongpu::float_64 theta( my_index_theta * delta_angle + 0.5*picongpu::PI ); + const picongpu::float_64 phi( my_index_phi * delta_angle ); /* compute unit vector */ - return vec2( sinf(theta)*cosf(phi) , sinf(theta)*sinf(phi) , cosf(theta) ) ; + return vector_64( sinf(theta)*cosf(phi) , sinf(theta)*sinf(phi) , cosf(theta) ) ; } diff --git a/examples/KelvinHelmholtz/include/simulation_defines/param/species.param b/examples/KelvinHelmholtz/include/simulation_defines/param/species.param index 8bf55f72ac..d6f00eab27 100644 --- a/examples/KelvinHelmholtz/include/simulation_defines/param/species.param +++ b/examples/KelvinHelmholtz/include/simulation_defines/param/species.param @@ -1,5 +1,5 @@ /** - * Copyright 2014 Rene Widera + * Copyright 2014-2015 Rene Widera * * This file is part of PIConGPU. * @@ -44,6 +44,7 @@ namespace picongpu * - particles::shapes::CIC : 1st order * - particles::shapes::TSC : 2nd order (requires CUDA_ARCH>=sm_20) * - particles::shapes::PCS : 3rd order (requires CUDA_ARCH>=sm_20) + * - particles::shapes::P4S : 4th order (requires CUDA_ARCH>=sm_20) * * example: typedef particles::shapes::CIC CICShape; */ @@ -56,9 +57,9 @@ typedef particles::shapes::PARAM_PARTICLESHAPE UsedParticleShape; typedef FieldToParticleInterpolation UsedField2Particle; /*! select current solver method ----------------------------------------------- - * - currentSolver::Esirkepov : particle shapes - CIC, TSC, PCS (1st to 3rd order) + * - currentSolver::Esirkepov : particle shapes - CIC, TSC, PCS, P4S (1st to 4th order) * - currentSolver::VillaBune<> : particle shapes - CIC (1st order) only - * - currentSolver::ZigZag : particle shapes - CIC, TSC, PCS (1st to 3rd order) + * - currentSolver::ZigZag : particle shapes - CIC, TSC, PCS, P4S (1st to 4th order) * * For development purposes: --------------------------------------------------- * - currentSolver::EsirkepovNative : generic version of currentSolverEsirkepov diff --git a/examples/KelvinHelmholtz/include/simulation_defines/param/visColorScales.param b/examples/KelvinHelmholtz/include/simulation_defines/param/visColorScales.param index d542691c33..f97580df7c 100644 --- a/examples/KelvinHelmholtz/include/simulation_defines/param/visColorScales.param +++ b/examples/KelvinHelmholtz/include/simulation_defines/param/visColorScales.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Axel Huebl, Heiko Burau, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ diff --git a/examples/KelvinHelmholtz/submit/0004gpus.cfg b/examples/KelvinHelmholtz/submit/0004gpus.cfg index bcf9fdc14e..45fb016a6f 100644 --- a/examples/KelvinHelmholtz/submit/0004gpus.cfg +++ b/examples/KelvinHelmholtz/submit/0004gpus.cfg @@ -44,24 +44,24 @@ TBG_periodic="--periodic 1 1 1" ## Section: Optional Variables ## ################################# -TBG_pngYZ="--png_e.period 10 --png_e.axis yz --png_e.slicePoint 0.5 --png_e.folder pngElectronsYZ" -TBG_pngYX="--png_e.period 10 --png_e.axis yx --png_e.slicePoint 0.5 --png_e.folder pngElectronsYX" +TBG_pngYZ="--e_png.period 10 --e_png.axis yz --e_png.slicePoint 0.5 --e_png.folder pngElectronsYZ" +TBG_pngYX="--e_png.period 10 --e_png.axis yx --e_png.slicePoint 0.5 --e_png.folder pngElectronsYX" -TBG_ipngYX="--png_i.period 10 --png_i.axis yx --png_i.slicePoint 0.5 --png_i.folder pngIonsYX" +TBG_ipngYX="--i_png.period 10 --i_png.axis yx --i_png.slicePoint 0.5 --i_png.folder pngIonsYX" -TBG_eBin="--bin_e.period 100 --bin_e.binCount 1024 --bin_e.minEnergy 0 --bin_e.maxEnergy 5000" -TBG_iBin="--bin_i.period 100 --bin_i.binCount 1024 --bin_i.minEnergy 0 --bin_i.maxEnergy 2000000" +TBG_eBin="--e_energyHistogram.period 100 --e_energyHistogram.binCount 1024 --e_energyHistogram.minEnergy 0 --e_energyHistogram.maxEnergy 5000" +TBG_iBin="--i_energyHistogram.period 100 --i_energyHistogram.binCount 1024 --i_energyHistogram.minEnergy 0 --i_energyHistogram.maxEnergy 2000000" TBG_plugins="!TBG_ipngYX \ !TBG_eBin \ !TBG_iBin \ !TBG_pngYX \ !TBG_pngYZ \ - --ions_cnt.period 100 \ - --elec_cnt.period 100 \ - --energy_fields.period 10 \ - --energy_e.period 10 \ - --energy_i.period 10" + --i_macroParticlesCount.period 100 \ + --e_macroParticlesCount.period 100 \ + --fields_energy.period 10 \ + --e_energy.period 10 \ + --i_energy.period 10" ################################# diff --git a/examples/KelvinHelmholtz/submit/0016gpus.cfg b/examples/KelvinHelmholtz/submit/0016gpus.cfg index 0cb3466031..397c5dcf98 100644 --- a/examples/KelvinHelmholtz/submit/0016gpus.cfg +++ b/examples/KelvinHelmholtz/submit/0016gpus.cfg @@ -48,15 +48,15 @@ TBG_periodic="--periodic 1 1 1" TBG_hdf5="--hdf5.period 250" -TBG_pngYZ="--png_e.period 10 --png_e.axis yz --png_e.slicePoint 0.5 --png_e.folder pngElectronsYZ" -TBG_pngYX="--png_e.period 10 --png_e.axis yx --png_e.slicePoint 0.5 --png_e.folder pngElectronsYX" +TBG_pngYZ="--e_png.period 10 --e_png.axis yz --e_png.slicePoint 0.5 --e_png.folder pngElectronsYZ" +TBG_pngYX="--e_png.period 10 --e_png.axis yx --e_png.slicePoint 0.5 --e_png.folder pngElectronsYX" -TBG_ipngYZ="--png_i.period 10 --png_i.axis yz --png_i.slicePoint 0.5 --png_i.folder pngIonsYZ" -TBG_ipngYX="--png_i.period 10 --png_i.axis yx --png_i.slicePoint 0.5 --png_i.folder pngIonsYX" +TBG_ipngYZ="--i_png.period 10 --i_png.axis yz --i_png.slicePoint 0.5 --i_png.folder pngIonsYZ" +TBG_ipngYX="--i_png.period 10 --i_png.axis yx --i_png.slicePoint 0.5 --i_png.folder pngIonsYX" # [in keV] -TBG_eBin="--bin_e.period 100 --bin_e.binCount 1024 --bin_e.minEnergy 0 --bin_e.maxEnergy 5000" -TBG_iBin="--bin_i.period 100 --bin_i.binCount 1024 --bin_i.minEnergy 0 --bin_i.maxEnergy 2000000" +TBG_eBin="--e_energyHistogram.period 100 --e_energyHistogram.binCount 1024 --e_energyHistogram.minEnergy 0 --e_energyHistogram.maxEnergy 5000" +TBG_iBin="--i_energyHistogram.period 100 --i_energyHistogram.binCount 1024 --i_energyHistogram.minEnergy 0 --i_energyHistogram.maxEnergy 2000000" TBG_plugins="!TBG_ipngYZ \ !TBG_ipngYX \ @@ -65,11 +65,11 @@ TBG_plugins="!TBG_ipngYZ \ !TBG_pngYX \ !TBG_pngYZ \ !TBG_hdf5 \ - --ions_cnt.period 100 \ - --elec_cnt.period 100 \ - --energy_fields.period 10 \ - --energy_e.period 10 \ - --energy_i.period 10" + --i_macroParticlesCount.period 100 \ + --e_macroParticlesCount.period 100 \ + --fields_energy.period 10 \ + --e_energy.period 10 \ + --i_energy.period 10" ################################# diff --git a/examples/LaserWakefield/cmakeFlags b/examples/LaserWakefield/cmakeFlags index e3e4fc1753..c2432855ec 100755 --- a/examples/LaserWakefield/cmakeFlags +++ b/examples/LaserWakefield/cmakeFlags @@ -31,17 +31,15 @@ flags[0]="-DCUDA_ARCH=sm_20" flags[1]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_FIELDSOLVER=fieldSolverLehe;-DPARAM_PARTICLEPUSHER=Vay" -flags[2]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_FIELDSOLVER=fieldSolverDirSplitting" -flags[3]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_CURRENTSOLVER=Esirkepov;-DPARAM_PARTICLESHAPE=CIC" -flags[4]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_CURRENTSOLVER=VillaBune;-DPARAM_PARTICLESHAPE=CIC" -flags[5]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_PRECISION=precision64Bit" -flags[6]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_FIELDSOLVER=fieldSolverDirSplitting;-DPARAM_PRECISION=precision64Bit" -flags[7]="-DCUDA_ARCH=sm_35 -DPARAM_OVERWRITES:LIST=-DENABLE_CURRENT=0" -flags[8]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_DIMENSION=DIM2" -flags[9]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_CURRENTSOLVER=Esirkepov;-DPARAM_PARTICLESHAPE=CIC;-DPARAM_DIMENSION=DIM2" -flags[10]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_PRECISION=precision64Bit;-DPARAM_DIMENSION=DIM2" -flags[11]="-DCUDA_ARCH=sm_35 -DPARAM_OVERWRITES:LIST=-DENABLE_CURRENT=0;-DPARAM_DIMENSION=DIM2" -flags[12]="-DCUDA_ARCH=sm_35 -DPARAM_OVERWRITES:LIST=-DPARAM_GASPROFILE=gasSphereFlanks;-DPARAM_IONS=1;-DPARAM_IONIZATION=1" +flags[2]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_CURRENTSOLVER=Esirkepov;-DPARAM_PARTICLESHAPE=CIC" +flags[3]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_CURRENTSOLVER=VillaBune;-DPARAM_PARTICLESHAPE=CIC" +flags[4]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_PRECISION=precision64Bit" +flags[5]="-DCUDA_ARCH=sm_35 -DPARAM_OVERWRITES:LIST=-DENABLE_CURRENT=0" +flags[6]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_DIMENSION=DIM2" +flags[7]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_CURRENTSOLVER=Esirkepov;-DPARAM_PARTICLESHAPE=CIC;-DPARAM_DIMENSION=DIM2" +flags[8]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_PRECISION=precision64Bit;-DPARAM_DIMENSION=DIM2" +flags[9]="-DCUDA_ARCH=sm_35 -DPARAM_OVERWRITES:LIST=-DENABLE_CURRENT=0;-DPARAM_DIMENSION=DIM2" +flags[10]="-DCUDA_ARCH=sm_35 -DPARAM_OVERWRITES:LIST=-DPARAM_IONS=1;-DPARAM_IONIZATION=1" ################################################################################ # execution diff --git a/examples/LaserWakefield/include/simulation_defines/param/componentsConfig.param b/examples/LaserWakefield/include/simulation_defines/param/componentsConfig.param index db3cf4a0d3..a27470df03 100644 --- a/examples/LaserWakefield/include/simulation_defines/param/componentsConfig.param +++ b/examples/LaserWakefield/include/simulation_defines/param/componentsConfig.param @@ -1,5 +1,5 @@ /** - * Copyright 2013-2014 Axel Huebl, Anton Helm, Rene Widera, Felix Schmitt, + * Copyright 2013-2015 Axel Huebl, Anton Helm, Rene Widera, Felix Schmitt, * Richard Pausch * * This file is part of PIConGPU. @@ -37,6 +37,7 @@ namespace simulation_starter = defaultPIConGPU; * in 'x' direction * - laserWavepacket : wavepacket (Gaussian in time and space, not focusing) * - laserPlaneWave : a plane wave + * - laserPolynom : a polynomial laser envelope */ namespace laserProfile = laserGaussianBeam; diff --git a/examples/LaserWakefield/include/simulation_defines/param/gasConfig.param b/examples/LaserWakefield/include/simulation_defines/param/gasConfig.param index 1c0fa7bb2c..c18dac60b5 100644 --- a/examples/LaserWakefield/include/simulation_defines/param/gasConfig.param +++ b/examples/LaserWakefield/include/simulation_defines/param/gasConfig.param @@ -43,39 +43,46 @@ const double GAS_DENSITY_SI = 1.e25; //########################################################################## namespace gasProfiles { -struct GaussianParameter -{ - /** Gas Formular: - const float_X exponent = fabs((y - GAS_CENTER) / GAS_SIGMA); - const float_X density = __expf(GAS_FACTOR*__powf(exponent, GAS_POWER)); - takes GAS_CENTER_LEFT for y < GAS_CENTER_LEFT, - GAS_CENTER_RIGHT for y > GAS_CENTER_RIGHT, - and exponent = float_X(0.0) for GAS_CENTER_LEFT < y < GAS_CENTER_RIGHT */ - static const float_X GAS_FACTOR = -1.0; - static const float_X GAS_POWER = 4.0; +/** Middle of the constant sphere + * unit: meter */ +CONST_VECTOR(float_64, simDim, SphereFlanksParam_center, 8.0e3, 8.0e3, 8.0e3); +struct SphereFlanksParam +{ /** height of vacuum area on top border * this vacuum is really important because of the laser initialization, * which is done in the first cell of the simulation * unit: cells */ - static const uint32_t VACUUM_CELLS_Y = 50; + static const uint32_t vacuum_y_cells = 50; struct SI { - /** The central position of the gas distribution + /** Radius of the constant sphere * unit: meter */ - static const float_64 GAS_CENTER_LEFT = 8.0e-5; - static const float_64 GAS_CENTER_RIGHT = 10.0e-5; - /** the distance from GAS_CENTER until the gas density decreases to its 1/e-th part + static const float_64 r = 1.0e3; + + /** Inner radius if you want to build a shell/ring * unit: meter */ - static const float_64 GAS_SIGMA_LEFT = 8.0e-5; - static const float_64 GAS_SIGMA_RIGHT = 8.0e-5; + static const float_64 ri = 0.0; + + /** Middle of the constant sphere + * unit: meter */ + const SphereFlanksParam_center_t center; + + /** Parameters for the exponential slope + * For radius > GAS_R_SI: + * let radius' = radius - r + * \rho = exp[ - radius' * exponent ] + * unit: 1/m + */ + static const float_64 exponent = 1.0e-3; + }; }; -/* definition of GasGaussian*/ -typedef GaussianImpl Gaussian; +/* definition of gas sphere with flanks*/ +typedef SphereFlanksImpl SphereFlanks; }//namespace gasProfiles diff --git a/examples/LaserWakefield/include/simulation_defines/param/gridConfig.param b/examples/LaserWakefield/include/simulation_defines/param/gridConfig.param index 29d28c6c19..43258f6d34 100644 --- a/examples/LaserWakefield/include/simulation_defines/param/gridConfig.param +++ b/examples/LaserWakefield/include/simulation_defines/param/gridConfig.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Axel Huebl, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ @@ -53,7 +53,7 @@ namespace picongpu {1.0e-3, 1.0e-3}, /*x direction [negative,positive]*/ {1.0e-3, 1.0e-3}, /*y direction [negative,positive]*/ {1.0e-3, 1.0e-3} /*z direction [negative,positive]*/ - }; //unit: none + }; //unit: none const uint32_t ABSORBER_FADE_IN_STEPS = 16; @@ -62,7 +62,7 @@ namespace picongpu * is fired at the begin of the simulation. * When it reaches slide_point % of the absolute(*) simulation area, * the co-moving window starts to move with the speed of light. - * + * * (*) Note: beware, that there is one "hidden" row of gpus at the y-front, * when you use the co-moving window * 0.75 means only 75% of simulation area is used for real simulation diff --git a/examples/LaserWakefield/include/simulation_defines/param/laserConfig.param b/examples/LaserWakefield/include/simulation_defines/param/laserConfig.param index dbf33a3f5a..68bf6275dd 100644 --- a/examples/LaserWakefield/include/simulation_defines/param/laserConfig.param +++ b/examples/LaserWakefield/include/simulation_defines/param/laserConfig.param @@ -1,22 +1,22 @@ /** - * Copyright 2013-2014 Axel Huebl, Anton Helm, Rene Widera, Richard Pausch + * Copyright 2013-2015 Axel Huebl, Anton Helm, Rene Widera, Richard Pausch * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ @@ -71,7 +71,10 @@ namespace picongpu /** The laser pulse will be initialized PULSE_INIT times of the PULSE_LENGTH * unit: none */ const double PULSE_INIT = 15.0; - + + /* laser phase shift (no shift: 0.0) */ + const float_X LASER_PHASE = 0.0; /* unit: rad, periodic in 2*pi */ + enum PolarisationType { LINEAR_X = 1u, @@ -123,6 +126,9 @@ namespace picongpu * unit: none */ const double PULSE_INIT = 20.0; + /* laser phase shift (no shift: 0.0) */ + const float_X LASER_PHASE = 0.0; /* unit: rad, periodic in 2*pi */ + enum PolarisationType { LINEAR_X = 1u, @@ -177,6 +183,9 @@ namespace picongpu * unit: none */ const double RAMP_INIT = 20.6146; //25.6415;//SI::aux_calulation::PULSE_TIME_SI/SI::PULSE_LENGTH_SI; + /* we use a sin(omega*time + laser_phase) function to set up the laser - define phase: */ + const float_X LASER_PHASE = 0.0; /* unit: rad, periodic in 2*pi */ + enum PolarisationType { LINEAR_X = 1u, @@ -240,6 +249,9 @@ namespace picongpu * unit: none */ const double RAMP_INIT = 20.0; + /* we use a sin(omega*time + laser_phase) function to set up the laser - define phase: */ + const float_X LASER_PHASE = 0.0; /* unit: rad, periodic in 2*pi */ + enum PolarisationType { LINEAR_X = 1u, @@ -277,21 +289,24 @@ namespace picongpu const double AMPLITUDE_SI = 1.738e13; - /** Pulse length: + /** Pulse length: * PULSE_LENGTH_SI = total length of polynamial laser pulse * Rise time = 0.5 * PULSE_LENGTH_SI * Fall time = 0.5 * PULSE_LENGTH_SI - * in order to compare to a gaussian pulse: rise time = sqrt{2} * T_{FWHM} + * in order to compare to a gaussian pulse: rise time = sqrt{2} * T_{FWHM} * unit: seconds */ - const double PULSE_LENGTH_SI = 4.0e-15; + const double PULSE_LENGTH_SI = 4.0e-15; /** beam waist: distance from the axis where the pulse intensity (E^2) * decreases to its 1/e^2-th part, * at the focus position of the laser * unit: meter */ - const double W0x_SI = 4.246e-6; // waist in x-direction + const double W0x_SI = 4.246e-6; // waist in x-direction const double W0z_SI = W0x_SI; // waist in z-direction } + + /* we use a sin(omega*(time-riseTime) + laser_phase) function to set up the laser - define phase: */ + const float_X LASER_PHASE = 0.0; /* unit: rad, periodic in 2*pi */ } namespace laserNone diff --git a/examples/LaserWakefield/include/simulation_defines/param/particleConfig.param b/examples/LaserWakefield/include/simulation_defines/param/particleConfig.param index 92bdec79de..252730e7ec 100644 --- a/examples/LaserWakefield/include/simulation_defines/param/particleConfig.param +++ b/examples/LaserWakefield/include/simulation_defines/param/particleConfig.param @@ -1,5 +1,5 @@ /** - * Copyright 2013 Axel Huebl, Rene Widera + * Copyright 2013-2015 Axel Huebl, Rene Widera, Marco Garten * * This file is part of PIConGPU. * @@ -23,6 +23,8 @@ #pragma once #include "particles/startPosition/functors.def" +#include "particles/manipulators/manipulators.def" +#include "nvidia/functors/Assign.hpp" namespace picongpu { @@ -39,7 +41,24 @@ namespace particles * unit: none */ const float_X MIN_WEIGHTING = 10.0; -const uint32_t TYPICAL_PARTICLES_PER_CELL = 2; +const uint32_t TYPICAL_PARTICLES_PER_CELL = 10; + +namespace manipulators +{ + struct SixTimesWeightingFunctor + { + template + DINLINE void operator()(T_Particle& particle) + { + particle[weighting_]*=float_X(6.0); + } + }; + + /* definition of SetDrift start*/ + typedef FreeImpl SixTimesWeighting; + + +} //namespace manipulators namespace startPosition { @@ -53,18 +72,18 @@ struct RandomParameter /* definition of random particle start*/ typedef RandomImpl Random; -struct QuietParameter -{ - /** Count of particles per cell per direction at initial state - * unit: none */ - typedef typename mCT::shrinkTo, simDim>::type numParticlesPerDimension; -}; - -/* definition of random particle start*/ -typedef QuietImpl Quiet; +} //namespace startPosition +namespace manipulators +{ + + struct BoundElectronsWhenNeutral + { + /* space for attribute initial parameters */ + }; + typedef SetAttributeImpl SetBoundElectrons; +} //namespace manipulators -} //namespace startPosition } //namespace particles } //namespac picongpu diff --git a/examples/LaserWakefield/include/simulation_defines/param/physicalConstants.param b/examples/LaserWakefield/include/simulation_defines/param/physicalConstants.param new file mode 100644 index 0000000000..e92f6b3862 --- /dev/null +++ b/examples/LaserWakefield/include/simulation_defines/param/physicalConstants.param @@ -0,0 +1,85 @@ +/** + * Copyright 2013 Axel Huebl, Heiko Burau, Rene Widera + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + + + +#pragma once + +namespace picongpu +{ + const float_64 PI = 3.141592653589793238462643383279502884197169399; + + /** Threshold used for calculations that want to separate between + * high-precision formulas for relativistic and non-relativistic + * use-cases, e.g. energy-binning algorithms. */ + const float_X GAMMA_THRESH = float_X(1.005); + + namespace SI + { + /** unit: m / s */ + const float_64 SPEED_OF_LIGHT_SI = 2.99792458e8; + + /** unit: N / A^2 */ + const float_64 MUE0_SI = PI * 4.e-7; + /** unit: C / (V m) */ + const float_64 EPS0_SI = 1.0 / MUE0_SI / SPEED_OF_LIGHT_SI + / SPEED_OF_LIGHT_SI; + + // Electron properties + /** unit: kg */ + const float_64 ELECTRON_MASS_SI = 9.109382e-31; + /** unit: C */ + const float_64 ELECTRON_CHARGE_SI = -1.602176e-19; + + // Ion / Proton / Positron properties + /** unit: kg */ + const float_64 ION_MASS_SI = 1.6726217e-27; + + const float_64 ION_MASS_C_SI = 1.660538921-27; + } + + // converts + // + // UNIT_A to UNIT_B + // + // CONVENTION: WE DO NOT CONVERT FROM ANY STRANGE UNIT TO UNITLESS UNITS DIRECTLY! + // convert steps: INPUT -> float_64_convert to SI -> float_64_convert to unitless + // -> cast to float + // WE DO NOT define "UNIT_ENERGY_keV" or something similar! Never! + // Stay SI, stay free ;-) + // + // example: + // // some particle physicist beloved input: + // const float_64 An_Arbitrary_Energy_Input_keV = 30.0; // unit: keV + // + // // first convert to SI (because SI stays our standard Unit System!) + // const float_64 An_Arbitrary_Energy_Input_SI = An_Arbitrary_Energy_Input_keV * UNITCONV_keV_to_Joule // unit: Joule + // + // // now the "real" convert to our internal unitless system + // const float_X An_Arbitrary_Energy_Input = float_X(An_Arbitrary_Energy_Input_SI / UNIT_ENERGY) // unit: none + // + // As a convention, we DO NOT use the short track: + // const float_64 An_Arbitrary_Energy_Input_keV = 30.0; // unit: keV + // const float_X An_Arbitrary_Energy_Input = float_X(An_Arbitrary_Energy_Input_SI * UNITCONV_keV_to_Joule / UNIT_ENERGY) // unit: none + // + const float_64 UNITCONV_keV_to_Joule = 1.60217646e-16; + const float_64 UNITCONV_Joule_to_keV = (1.0 / UNITCONV_keV_to_Joule); + +} diff --git a/examples/LaserWakefield/include/simulation_defines/param/precision.param b/examples/LaserWakefield/include/simulation_defines/param/precision.param index e02ec8e470..b4981f7229 100644 --- a/examples/LaserWakefield/include/simulation_defines/param/precision.param +++ b/examples/LaserWakefield/include/simulation_defines/param/precision.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ diff --git a/examples/LaserWakefield/include/simulation_defines/param/species.param b/examples/LaserWakefield/include/simulation_defines/param/species.param index 819090461b..425f332a1b 100644 --- a/examples/LaserWakefield/include/simulation_defines/param/species.param +++ b/examples/LaserWakefield/include/simulation_defines/param/species.param @@ -1,5 +1,5 @@ /** - * Copyright 2014 Rene Widera + * Copyright 2014-2015 Rene Widera * * This file is part of PIConGPU. * @@ -34,17 +34,7 @@ /*enable (1) or disable (0) electrons*/ #define ENABLE_ELECTRONS 1 /*enable (1) or disable (0) ions*/ -#ifndef PARAM_IONS -#define PARAM_IONS 0 -#endif - -#define ENABLE_IONS PARAM_IONS - -/*enable (1) or disable (0) ionization*/ -#ifndef PARAM_IONIZATION -#define PARAM_IONIZATION 0 -#endif - +#define ENABLE_IONS 1 namespace picongpu { @@ -54,6 +44,7 @@ namespace picongpu * - particles::shapes::CIC : 1st order * - particles::shapes::TSC : 2nd order (requires CUDA_ARCH>=sm_20) * - particles::shapes::PCS : 3rd order (requires CUDA_ARCH>=sm_20) + * - particles::shapes::P4S : 4th order (requires CUDA_ARCH>=sm_20) * * example: typedef particles::shapes::CIC CICShape; */ @@ -66,16 +57,16 @@ typedef particles::shapes::PARAM_PARTICLESHAPE UsedParticleShape; typedef FieldToParticleInterpolation UsedField2Particle; /*! select current solver method ----------------------------------------------- - * - currentSolver::Esirkepov : particle shapes - CIC, TSC, PCS (1st to 3rd order) + * - currentSolver::Esirkepov : particle shapes - CIC, TSC, PCS, P4S (1st to 4th order) * - currentSolver::VillaBune<> : particle shapes - CIC (1st order) only - * - currentSolver::ZigZag : particle shapes - CIC, TSC, PCS (1st to 3rd order) + * - currentSolver::ZigZag : particle shapes - CIC, TSC, PCS, P4S (1st to 4th order) * * For development purposes: --------------------------------------------------- * - currentSolver::EsirkepovNative : generic version of currentSolverEsirkepov * without optimization (~4x slower and needs more shared memory) */ #ifndef PARAM_CURRENTSOLVER -#define PARAM_CURRENTSOLVER Esirkepov +#define PARAM_CURRENTSOLVER ZigZag #endif typedef currentSolver::PARAM_CURRENTSOLVER UsedParticleCurrentSolver; diff --git a/examples/LaserWakefield/include/simulation_defines/param/speciesDefinition.param b/examples/LaserWakefield/include/simulation_defines/param/speciesDefinition.param index e1fc0b186f..5154cb71f2 100644 --- a/examples/LaserWakefield/include/simulation_defines/param/speciesDefinition.param +++ b/examples/LaserWakefield/include/simulation_defines/param/speciesDefinition.param @@ -1,5 +1,5 @@ /** - * Copyright 2013-2014 Rene Widera, Marco Garten + * Copyright 2013-2015 Rene Widera, Marco Garten, Richard Pausch * * This file is part of PIConGPU. * @@ -73,8 +73,9 @@ AttributRadiationFlag /* attribute sequence for species: ions */ typedef typename MakeSeq< -DefaultParticleAttributes, -boundElectrons +DefaultParticleAttributes +AttributMomentum_mt1, +AttributRadiationFlag, >::type AttributeSeqIons; /*########################### end particle attributes ########################*/ @@ -93,13 +94,22 @@ typedef bmpl::vector< /* define species: electrons */ typedef Particles, + bmpl::string<'e','H'>, SuperCellSize, AttributeSeqElectrons, ParticleFlagsElectrons, typename MakeSeq >::type > > PIC_Electrons; +/* define species: electrons */ +typedef Particles, + SuperCellSize, + AttributeSeqElectrons, + ParticleFlagsElectrons, + typename MakeSeq >::type > +> PIC_ElectronsC; + /*--------------------------- ions -------------------------------------------*/ /*! Specify (chemical) element @@ -118,41 +128,51 @@ typedef Particles > - */ - -typedef particles::shapes::CIC IonShape; typedef bmpl::vector< particlePusher, shape, interpolation, current, - #if(PARAM_IONIZATION == 1) - ionizer >, - #endif atomicNumbers > ParticleFlagsIons; /* define species: ions */ typedef Particles, + bmpl::string<'i','H'>, SuperCellSize, AttributeSeqIons, ParticleFlagsIons, typename MakeSeq >::type > > PIC_Ions; +//##### carbon + +struct Carbon +{ + static const float_X numberOfProtons = 6.0; + static const float_X numberOfNeutrons = 6.0; +}; +typedef bmpl::vector< + particlePusher, + shape, + interpolation, + current, + atomicNumbers +> ParticleFlagsIonsC; + +/* define species: ions */ +typedef Particles, + SuperCellSize, + AttributeSeqIons, + ParticleFlagsIonsC, + typename MakeSeq >::type > +> PIC_IonsC; + + /*########################### end species ####################################*/ @@ -173,7 +193,9 @@ PIC_Ions typedef typename MakeSeq< Species1, -Species2 +Species2, +PIC_IonsC, +PIC_ElectronsC >::type VectorAllSpecies; diff --git a/examples/LaserWakefield/include/simulation_defines/param/speciesInitialization.param b/examples/LaserWakefield/include/simulation_defines/param/speciesInitialization.param index cfb5b46ecf..6b27ded2e8 100644 --- a/examples/LaserWakefield/include/simulation_defines/param/speciesInitialization.param +++ b/examples/LaserWakefield/include/simulation_defines/param/speciesInitialization.param @@ -29,12 +29,21 @@ namespace picongpu /** InitPipeline define in which order species are initialized * - * the functors are called in order (from first to last functor) + * the functors called in order (from first to last functor) */ typedef mpl::vector< +#if (PARAM_IONIZATION == 0) + particles::CreateGas -#if (ENABLE_IONS == 1) - ,particles::CloneSpecies + #if (ENABLE_IONS == 1) + ,particles::CloneSpecies + #endif + +#else + + particles::CreateGas, + particles::Manipulate + #endif > InitPipeline; diff --git a/examples/LaserWakefield/include/simulation_defines/param/starter.param b/examples/LaserWakefield/include/simulation_defines/param/starter.param index a320c949e7..b2f0b5f38a 100644 --- a/examples/LaserWakefield/include/simulation_defines/param/starter.param +++ b/examples/LaserWakefield/include/simulation_defines/param/starter.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ diff --git a/examples/LaserWakefield/include/simulation_defines/param/visColorScales.param b/examples/LaserWakefield/include/simulation_defines/param/visColorScales.param index d542691c33..f97580df7c 100644 --- a/examples/LaserWakefield/include/simulation_defines/param/visColorScales.param +++ b/examples/LaserWakefield/include/simulation_defines/param/visColorScales.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Axel Huebl, Heiko Burau, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ diff --git a/examples/LaserWakefield/include/simulation_defines/param/visualization.param b/examples/LaserWakefield/include/simulation_defines/param/visualization.param index 7b13402155..7772fc7f95 100644 --- a/examples/LaserWakefield/include/simulation_defines/param/visualization.param +++ b/examples/LaserWakefield/include/simulation_defines/param/visualization.param @@ -1,22 +1,22 @@ /** * Copyright 2013-2014 Axel Huebl, Heiko Burau, Rene Widera, Richard Pausch * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ #pragma once diff --git a/examples/LaserWakefield/include/simulation_defines/unitless/physicalConstants.unitless b/examples/LaserWakefield/include/simulation_defines/unitless/physicalConstants.unitless new file mode 100644 index 0000000000..2ae2c2baa6 --- /dev/null +++ b/examples/LaserWakefield/include/simulation_defines/unitless/physicalConstants.unitless @@ -0,0 +1,104 @@ +/** + * Copyright 2013-2014 Axel Huebl, Rene Widera + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + + +#pragma once + +namespace picongpu +{ + /** Unit of Speed */ + const float_64 UNIT_SPEED = SI::SPEED_OF_LIGHT_SI; + /** Unit of time */ + const float_64 UNIT_TIME = SI::DELTA_T_SI; + /** Unit of length */ + const float_64 UNIT_LENGTH = UNIT_TIME*UNIT_SPEED; + +#if(SIMDIM==DIM3) + namespace SI + { + /** density normed to dimension of the simulation*/ + const float_64 GAS_DENSITY_NORMED= SI::GAS_DENSITY_SI; + } //namespace SI + + namespace particles + { + /** Number of particles per makro particle (= macro particle weighting) + * unit: none */ + const float_X TYPICAL_NUM_PARTICLE_PER_MAKROPARTICLE = float_64(SI::GAS_DENSITY_NORMED*SI::CELL_WIDTH_SI*SI::CELL_HEIGHT_SI *SI::CELL_DEPTH_SI ) + / float_64(particles::TYPICAL_PARTICLES_PER_CELL); + } + +#elif(SIMDIM==DIM2) + namespace SI + { + /** density normed to dimension of the simulation + * + * http://www.tf.uni-kiel.de/matwis/amat/mw1_ge/kap_6/basics/m6_2_1.html + */ + const float_64 GAS_DENSITY_NORMED= SI::GAS_DENSITY_SI*UNIT_LENGTH; + } //namespace SI + namespace particles + { + /** Number of particles per makro particle (= macro particle weighting) + * unit: none */ + const float_X TYPICAL_NUM_PARTICLE_PER_MAKROPARTICLE = float_64(SI::GAS_DENSITY_NORMED*SI::CELL_WIDTH_SI*SI::CELL_HEIGHT_SI ) + / float_64(particles::TYPICAL_PARTICLES_PER_CELL); + } +#endif + + + /** Unit of mass */ + const double UNIT_MASS = SI::ELECTRON_MASS_SI * double(particles::TYPICAL_NUM_PARTICLE_PER_MAKROPARTICLE); + /** Unit of charge */ + const double UNIT_CHARGE = -1.0 * SI::ELECTRON_CHARGE_SI * double(particles::TYPICAL_NUM_PARTICLE_PER_MAKROPARTICLE); + /** Unit of energy */ + const double UNIT_ENERGY = (UNIT_MASS * UNIT_LENGTH * UNIT_LENGTH / (UNIT_TIME * UNIT_TIME)); + /** Unit of EField: V/m */ + const double UNIT_EFIELD = 1.0 / (UNIT_TIME * UNIT_TIME / UNIT_MASS / UNIT_LENGTH * UNIT_CHARGE); + //** Unit of BField: Tesla [T] = Vs/m^2 */ + const double UNIT_BFIELD = (UNIT_MASS / (UNIT_TIME * UNIT_CHARGE)); + + + + + const float_X SPEED_OF_LIGHT = float_X(SI::SPEED_OF_LIGHT_SI / UNIT_SPEED); + + //! Charge of electron + const float_X Q_EL = (float) (SI::ELECTRON_CHARGE_SI / UNIT_CHARGE); + //! Mass of electron + const float_X M_EL = (float) (SI::ELECTRON_MASS_SI / UNIT_MASS); + + //! Mass of ion + const float_X M_ION = (float) (SI::ION_MASS_SI / UNIT_MASS); + + //! Mass of ion carbon + const float_X M_IONC = (float) (SI::ION_MASS_C_SI / UNIT_MASS); + + + //! magnetic constant must be double 3.92907e-39 + const float_X MUE0 = (float) (SI::MUE0_SI / UNIT_LENGTH / UNIT_MASS * UNIT_CHARGE * UNIT_CHARGE); + + //! electric constant must be double 2.54513e+38 + const float_X EPS0 = (float) (1. / MUE0 / SPEED_OF_LIGHT / SPEED_OF_LIGHT); + + // = 1/c^2 + const float_X MUE0_EPS0 = float_X(1. / SPEED_OF_LIGHT / SPEED_OF_LIGHT); + +} //namespace picongpu diff --git a/examples/LaserWakefield/include/simulation_defines/unitless/speciesDefinition.unitless b/examples/LaserWakefield/include/simulation_defines/unitless/speciesDefinition.unitless new file mode 100644 index 0000000000..2e06f37c54 --- /dev/null +++ b/examples/LaserWakefield/include/simulation_defines/unitless/speciesDefinition.unitless @@ -0,0 +1,91 @@ +/** + * Copyright 2014 Rene Widera + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + + +#pragma once + +#include "traits/frame/GetCharge.hpp" +#include "traits/frame/GetMass.hpp" +#include "traits/attribute/GetCharge.hpp" +#include "traits/attribute/GetChargeState.hpp" +#include "traits/attribute/GetMass.hpp" +#include "fields/currentDeposition/Solver.hpp" +#include "particles/Particles.tpp" +#include "particles/ionization/byField/ionizers.hpp" + +namespace picongpu +{ +namespace traits +{ +namespace frame +{ + +template<> +HDINLINE float_X getMass() +{ + return M_ION; + /** \todo take account for mass loss of ions when electrons leave them during ionization */ +}; + +template<> +HDINLINE float_X getCharge() +{ + return Q_EL; +}; + +template<> +HDINLINE float_X getMass() +{ + return M_EL; +}; + +template<> +HDINLINE float_X getCharge() +{ + return Q_EL*float_X(-1.0); +}; + +template<> +HDINLINE float_X getCharge() +{ + return Q_EL*float_X(-6.0); +}; + +template<> +HDINLINE float_X getMass() +{ + return M_IONC; +}; + +template<> +HDINLINE float_X getCharge() +{ + return Q_EL; +}; + +template<> +HDINLINE float_X getMass() +{ + return M_EL; +}; + +} //namespace frame +} //namespace traits +} //namespace picongpu diff --git a/examples/LaserWakefield/submit/0001gpus.cfg b/examples/LaserWakefield/submit/0001gpus.cfg index 494c6dee9f..c48b8b2a71 100644 --- a/examples/LaserWakefield/submit/0001gpus.cfg +++ b/examples/LaserWakefield/submit/0001gpus.cfg @@ -45,14 +45,10 @@ TBG_steps="-s 1024" ################################# # png image output (electron density) -TBG_pngYX="--png_e.period 64 --png_e.axis yx --png_e.slicePoint 0.5 --png_e.folder pngElectronsYX" - -# binary density output for slides -TBG_binaryDensity="--binDensity_e.period 100 --binDensity_e.axis yx --binDensity_e.slicePoint 0.5 --binDensity_e.folder densityElectrons" +TBG_pngYX="--e_png.period 64 --e_png.axis yx --e_png.slicePoint 0.5 --e_png.folder pngElectronsYX" TBG_plugins="!TBG_pngYX \ - !TBG_binaryDensity \ - --elec_cnt.period 100" + --e_macroParticlesCount.period 100" ################################# diff --git a/examples/LaserWakefield/submit/0008gpus.cfg b/examples/LaserWakefield/submit/0008gpus.cfg index 51bcb32a11..923a8a2032 100644 --- a/examples/LaserWakefield/submit/0008gpus.cfg +++ b/examples/LaserWakefield/submit/0008gpus.cfg @@ -47,16 +47,12 @@ TBG_movingWindow="-m" ## Section: Optional Variables ## ################################# -TBG_pngYZ="--png_e.period 32 --png_e.axis yz --png_e.slicePoint 0.5 --png_e.folder pngElectronsYZ" -TBG_pngYX="--png_e.period 32 --png_e.axis yx --png_e.slicePoint 0.5 --png_e.folder pngElectronsYX" - -# binary density output for slides -TBG_binaryDensity="--binDensity_e.period 100 --binDensity_e.axis yx --binDensity_e.slicePoint 0.5 --binDensity_e.folder densityElectrons" +TBG_pngYZ="--e_png.period 32 --e_png.axis yz --e_png.slicePoint 0.5 --e_png.folder pngElectronsYZ" +TBG_pngYX="--e_png.period 32 --e_png.axis yx --e_png.slicePoint 0.5 --e_png.folder pngElectronsYX" TBG_plugins="!TBG_pngYX \ !TBG_pngYZ \ - !TBG_binaryDensity \ - --elec_cnt.period 100" + --e_macroParticlesCount.period 100" ################################# diff --git a/examples/LaserWakefield/submit/0016gpus.cfg b/examples/LaserWakefield/submit/0016gpus.cfg index c6ee108238..5b3ba2f3e8 100644 --- a/examples/LaserWakefield/submit/0016gpus.cfg +++ b/examples/LaserWakefield/submit/0016gpus.cfg @@ -49,12 +49,12 @@ TBG_movingWindow="-m" ################################# # create preview images (png) -TBG_pngYZ="--png_e.period 10 --png_e.axis yz --png_e.slicePoint 0.5 --png_e.folder pngElectronsYZ" -TBG_pngYX="--png_e.period 10 --png_e.axis yx --png_e.slicePoint 0.5 --png_e.folder pngElectronsYX" +TBG_pngYZ="--e_png.period 10 --e_png.axis yz --e_png.slicePoint 0.5 --e_png.folder pngElectronsYZ" +TBG_pngYX="--e_png.period 10 --e_png.axis yx --e_png.slicePoint 0.5 --e_png.folder pngElectronsYX" TBG_plugins="!TBG_pngYX \ !TBG_pngYZ \ - --elec_cnt.period 100" + --e_macroParticlesCount.period 100" ################################# diff --git a/examples/LaserWakefield/submit/0032gpus.cfg b/examples/LaserWakefield/submit/0032gpus.cfg index fc77b86c62..08471fda9c 100644 --- a/examples/LaserWakefield/submit/0032gpus.cfg +++ b/examples/LaserWakefield/submit/0032gpus.cfg @@ -48,12 +48,12 @@ TBG_movingWindow="-m" ################################# # create preview images (png) -TBG_pngYZ="--png_e.period 10 --png_e.axis yz --png_e.slicePoint 0.5 --png_e.folder pngElectronsYZ" -TBG_pngYX="--png_e.period 10 --png_e.axis yx --png_e.slicePoint 0.5 --png_e.folder pngElectronsYX" +TBG_pngYZ="--e_png.period 10 --e_png.axis yz --e_png.slicePoint 0.5 --e_png.folder pngElectronsYZ" +TBG_pngYX="--e_png.period 10 --e_png.axis yx --e_png.slicePoint 0.5 --e_png.folder pngElectronsYX" TBG_plugins="!TBG_pngYX \ !TBG_pngYZ \ - --elec_cnt.period 100" + --e_macroParticlesCount.period 100" ################################# ## Section: Program Parameters ## diff --git a/examples/SingleParticleCurrent/include/CheckCurrent.hpp b/examples/SingleParticleCurrent/include/CheckCurrent.hpp index 08b172c4d7..8f506ac60a 100644 --- a/examples/SingleParticleCurrent/include/CheckCurrent.hpp +++ b/examples/SingleParticleCurrent/include/CheckCurrent.hpp @@ -1,23 +1,23 @@ /** * Copyright 2013 Heiko Burau, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ - + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + #pragma once #include "fields/FieldJ.hpp" @@ -29,22 +29,22 @@ namespace picongpu { - + struct CheckCurrent { struct PrintNonZeroComponents { typedef void type; float3_X totalJ; - - PrintNonZeroComponents() : totalJ(0.0) {} + + PrintNonZeroComponents() : totalJ(float3_X::create(0.0)) {} ~PrintNonZeroComponents() { const float_X unit_current = UNIT_CHARGE / (UNIT_LENGTH * UNIT_LENGTH * UNIT_TIME); totalJ *= unit_current; printf("totalJ: (%g, %g, %g) A/m²\n", totalJ.x(), totalJ.y(), totalJ.z()); } - + HDINLINE void operator()(float3_X data, PMacc::math::Int<3> cellIdx) { @@ -55,7 +55,7 @@ struct CheckCurrent printf("j_y = %g at %d, %d, %d\n", data.y() * unit_current, cellIdx.x(), cellIdx.y(), cellIdx.z()); if(data.z() != 0.0f) printf("j_z = %g at %d, %d, %d\n", data.z() * unit_current, cellIdx.x(), cellIdx.y(), cellIdx.z()); - + this->totalJ += data; } }; @@ -63,28 +63,28 @@ struct CheckCurrent { typedef SuperCellSize GuardDim; - + // Get fieldJ without guards - BOOST_AUTO(fieldJ_device, + BOOST_AUTO(fieldJ_device, _fieldJ_device.getGridBuffer().getDeviceBuffer().cartBuffer()); container::HostBuffer fieldJ_with_guards(fieldJ_device.size()); fieldJ_with_guards = fieldJ_device; container::View > fieldJ(fieldJ_with_guards.view(GuardDim::toRT(), -GuardDim::toRT())); - + float3_X beta(BETA0_X, BETA0_Y, BETA0_Z); - + std::cout << "\nsingle P A R T I C L E facts:\n\n"; std::cout << "position: (" << float3_X(LOCAL_POS_X, LOCAL_POS_Y, LOCAL_POS_Z) << ") at cell " << fieldJ.size()/size_t(2) << std::endl; std::cout << "velocity: (" << beta << ") * c\n"; std::cout << "delta_pos: (" << beta * SPEED_OF_LIGHT / float3_X(CELL_WIDTH, CELL_HEIGHT, CELL_DEPTH) << ") * cellSize\n"; - + const double j = Q_EL / CELL_VOLUME * abs(beta) * SPEED_OF_LIGHT; const double unit_current = UNIT_CHARGE / (UNIT_LENGTH * UNIT_LENGTH * UNIT_TIME); std::cout << "j = rho * abs(velocity) = " << std::setprecision(6) << j * unit_current << " A/m²" << std::endl; std::cout << "------------------------------------------\n\n"; - + std::cout << "fieldJ facts:\n\n"; // std::cout << "zone: " << fieldJ.zone().size << ", " << fieldJ.zone().offset << std::endl; // std::cout << "index: " << *cursor::make_MultiIndexCursor<3>()(math::Int<3>(1,2,3)) << std::endl; @@ -98,6 +98,6 @@ struct CheckCurrent std::cout << "------------------------------------------\n\n"; } }; - - + + } diff --git a/examples/SingleParticleCurrent/include/simulation_defines/extensionParam.loader b/examples/SingleParticleCurrent/include/simulation_defines/extensionParam.loader index 544322513e..c84d213dbb 100644 --- a/examples/SingleParticleCurrent/include/simulation_defines/extensionParam.loader +++ b/examples/SingleParticleCurrent/include/simulation_defines/extensionParam.loader @@ -1,22 +1,22 @@ /** * Copyright 2013 Axel Huebl, Heiko Burau, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ #pragma once diff --git a/examples/SingleParticleCurrent/include/simulation_defines/extensionUnitless.loader b/examples/SingleParticleCurrent/include/simulation_defines/extensionUnitless.loader index 03f10c5108..8d8c47c7ec 100644 --- a/examples/SingleParticleCurrent/include/simulation_defines/extensionUnitless.loader +++ b/examples/SingleParticleCurrent/include/simulation_defines/extensionUnitless.loader @@ -1,22 +1,22 @@ /** * Copyright 2013 Axel Huebl, Heiko Burau, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ #pragma once diff --git a/examples/SingleParticleCurrent/include/simulation_defines/param/backgroundFields.param b/examples/SingleParticleCurrent/include/simulation_defines/param/backgroundFields.param index 1ccba5a16f..ec7703e594 100644 --- a/examples/SingleParticleCurrent/include/simulation_defines/param/backgroundFields.param +++ b/examples/SingleParticleCurrent/include/simulation_defines/param/backgroundFields.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Axel Huebl, Heiko Burau, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ diff --git a/examples/SingleParticleCurrent/include/simulation_defines/param/componentsConfig.param b/examples/SingleParticleCurrent/include/simulation_defines/param/componentsConfig.param index f399cb70a3..3ca7693612 100644 --- a/examples/SingleParticleCurrent/include/simulation_defines/param/componentsConfig.param +++ b/examples/SingleParticleCurrent/include/simulation_defines/param/componentsConfig.param @@ -1,5 +1,5 @@ /** - * Copyright 2013-2014 Axel Huebl, Heiko Burau, Anton Helm, Rene Widera, + * Copyright 2013-2015 Axel Huebl, Heiko Burau, Anton Helm, Rene Widera, * Richard Pausch * * This file is part of PIConGPU. @@ -37,6 +37,7 @@ namespace simulation_starter = singleParticleTest; * in 'x' direction * - laserWavepacket : wavepacket (Gaussian in time and space, not focusing) * - laserPlaneWave : a plane wave + * - laserPolynom : a polynomial laser envelope */ namespace laserProfile = laserNone; diff --git a/examples/SingleParticleCurrent/include/simulation_defines/param/gridConfig.param b/examples/SingleParticleCurrent/include/simulation_defines/param/gridConfig.param index 984ad3ccce..efe2d539ff 100644 --- a/examples/SingleParticleCurrent/include/simulation_defines/param/gridConfig.param +++ b/examples/SingleParticleCurrent/include/simulation_defines/param/gridConfig.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Heiko Burau * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ @@ -53,7 +53,7 @@ namespace picongpu {1.0e-3, 1.0e-3}, /*x direction [negative,positive]*/ {1.0e-3, 1.0e-3}, /*y direction [negative,positive]*/ {1.0e-3, 1.0e-3} /*z direction [negative,positive]*/ - }; //unit: none + }; //unit: none const uint32_t ABSORBER_FADE_IN_STEPS = 16; @@ -62,7 +62,7 @@ namespace picongpu * is fired at the begin of the simulation. * When it reaches slide_point % of the absolute(*) simulation area, * the co-moving window starts to move with the speed of light. - * + * * (*) Note: beware, that there is one "hidden" row of gpus at the y-front, * when you use the co-moving window * 0.75 means only 75% of simulation area is used for real simulation diff --git a/examples/SingleParticleCurrent/include/simulation_defines/param/species.param b/examples/SingleParticleCurrent/include/simulation_defines/param/species.param index a3cda48c2b..e9812174b0 100644 --- a/examples/SingleParticleCurrent/include/simulation_defines/param/species.param +++ b/examples/SingleParticleCurrent/include/simulation_defines/param/species.param @@ -1,5 +1,5 @@ /** - * Copyright 2014 Rene Widera + * Copyright 2014-2015 Rene Widera * * This file is part of PIConGPU. * @@ -45,6 +45,7 @@ namespace picongpu * - particles::shapes::CIC : 1st order * - particles::shapes::TSC : 2nd order (requires CUDA_ARCH>=sm_20) * - particles::shapes::PCS : 3rd order (requires CUDA_ARCH>=sm_20) + * - particles::shapes::P4S : 4th order (requires CUDA_ARCH>=sm_20) * * example: typedef particles::shapes::CIC CICShape; */ @@ -54,9 +55,9 @@ typedef particles::shapes::CIC UsedParticleShape; typedef FieldToParticleInterpolation UsedField2Particle; /*! select current solver method ----------------------------------------------- - * - currentSolver::Esirkepov : particle shapes - CIC, TSC, PCS (1st to 3rd order) + * - currentSolver::Esirkepov : particle shapes - CIC, TSC, PCS, P4S (1st to 4th order) * - currentSolver::VillaBune<> : particle shapes - CIC (1st order) only - * - currentSolver::ZigZag : particle shapes - CIC, TSC, PCS (1st to 3rd order) + * - currentSolver::ZigZag : particle shapes - CIC, TSC, PCS, P4S (1st to 4th order) * * For development purposes: --------------------------------------------------- * - currentSolver::EsirkepovNative : generic version of currentSolverEsirkepov diff --git a/examples/SingleParticleCurrent/include/simulation_defines/param/starter.param b/examples/SingleParticleCurrent/include/simulation_defines/param/starter.param index c0b213169d..28b4e0bba8 100644 --- a/examples/SingleParticleCurrent/include/simulation_defines/param/starter.param +++ b/examples/SingleParticleCurrent/include/simulation_defines/param/starter.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Axel Huebl, Heiko Burau, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ diff --git a/examples/SingleParticleCurrent/include/simulation_defines/param/visColorScales.param b/examples/SingleParticleCurrent/include/simulation_defines/param/visColorScales.param index d542691c33..f97580df7c 100644 --- a/examples/SingleParticleCurrent/include/simulation_defines/param/visColorScales.param +++ b/examples/SingleParticleCurrent/include/simulation_defines/param/visColorScales.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Axel Huebl, Heiko Burau, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ diff --git a/examples/SingleParticleCurrent/include/simulation_defines/param/visualization.param b/examples/SingleParticleCurrent/include/simulation_defines/param/visualization.param index 1a7c8e80be..c759411af5 100644 --- a/examples/SingleParticleCurrent/include/simulation_defines/param/visualization.param +++ b/examples/SingleParticleCurrent/include/simulation_defines/param/visualization.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Axel Huebl, Heiko Burau, Rene Widera, Richard Pausch * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ #pragma once diff --git a/examples/SingleParticleCurrent/include/simulation_defines/unitless/backgroundFields.unitless b/examples/SingleParticleCurrent/include/simulation_defines/unitless/backgroundFields.unitless index fb9c882874..ce5f068c01 100644 --- a/examples/SingleParticleCurrent/include/simulation_defines/unitless/backgroundFields.unitless +++ b/examples/SingleParticleCurrent/include/simulation_defines/unitless/backgroundFields.unitless @@ -1,22 +1,22 @@ /** * Copyright 2013 Axel Huebl, Heiko Burau, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ diff --git a/examples/SingleParticleCurrent/include/simulation_defines/unitless/starter.unitless b/examples/SingleParticleCurrent/include/simulation_defines/unitless/starter.unitless index 3f23d16a78..4f21a66586 100644 --- a/examples/SingleParticleCurrent/include/simulation_defines/unitless/starter.unitless +++ b/examples/SingleParticleCurrent/include/simulation_defines/unitless/starter.unitless @@ -1,22 +1,22 @@ /** * Copyright 2013 Axel Huebl, Heiko Burau, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ diff --git a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/extensionParam.loader b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/extensionParam.loader index 873975a79a..66f125a7a4 100644 --- a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/extensionParam.loader +++ b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/extensionParam.loader @@ -1,22 +1,22 @@ /** * Copyright 2013 Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ #pragma once diff --git a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/extensionUnitless.loader b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/extensionUnitless.loader index ee2f9ad8a5..f8aa780326 100644 --- a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/extensionUnitless.loader +++ b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/extensionUnitless.loader @@ -1,22 +1,22 @@ /** * Copyright 2013 Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ #pragma once diff --git a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/componentsConfig.param b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/componentsConfig.param index 2aa459c844..27639c9450 100644 --- a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/componentsConfig.param +++ b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/componentsConfig.param @@ -1,5 +1,5 @@ /** - * Copyright 2013-2014 Axel Huebl, Anton Helm, Rene Widera, Richard Pausch + * Copyright 2013-2015 Axel Huebl, Anton Helm, Rene Widera, Richard Pausch * * This file is part of PIConGPU. * @@ -36,6 +36,7 @@ namespace simulation_starter = radiationTest; * in 'x' direction * - laserWavepacket : wavepacket (Gaussian in time and space, not focusing) * - laserPlaneWave : a plane wave + * - laserPolynom : a polynomial laser envelope */ namespace laserProfile = laserPlaneWave; diff --git a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/gridConfig.param b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/gridConfig.param index 91087797b6..ce20b5594c 100644 --- a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/gridConfig.param +++ b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/gridConfig.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Rene Widera, Richard Pausch * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ @@ -53,7 +53,7 @@ namespace picongpu {1.0e-3, 1.0e-3}, /*x direction [negative,positive]*/ {1.0e-3, 1.0e-3}, /*y direction [negative,positive]*/ {1.0e-3, 1.0e-3} /*z direction [negative,positive]*/ - }; //unit: none + }; //unit: none const uint32_t ABSORBER_FADE_IN_STEPS = 16; @@ -62,7 +62,7 @@ namespace picongpu * is fired at the begin of the simulation. * When it reaches slide_point % of the absolute(*) simulation area, * the co-moving window starts to move with the speed of light. - * + * * (*) Note: beware, that there is one "hidden" row of gpus at the y-front, * when you use the co-moving window * 0.75 means only 75% of simulation area is used for real simulation diff --git a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/laserConfig.param b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/laserConfig.param index 770aee37b9..bbafb15679 100644 --- a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/laserConfig.param +++ b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/laserConfig.param @@ -1,22 +1,22 @@ /** - * Copyright 2013-2014 Axel Huebl, Anton Helm, Rene Widera, Richard Pausch + * Copyright 2013-2015 Axel Huebl, Anton Helm, Rene Widera, Richard Pausch * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ @@ -72,6 +72,9 @@ const double FOCUS_POS_SI = 4.62e-5; * unit: none */ const double PULSE_INIT = 20.0; +/* laser phase shift (no shift: 0.0) */ +const float_X LASER_PHASE = 0.0; /* unit: rad, periodic in 2*pi */ + enum PolarisationType { LINEAR_X = 1u, @@ -134,6 +137,9 @@ const double TILT_X_SI = 0; * unit: none */ const double PULSE_INIT = 20.0; +/* laser phase shift (no shift: 0.0) */ +const float_X LASER_PHASE = 0.0; /* unit: rad, periodic in 2*pi */ + enum PolarisationType { LINEAR_X = 1u, @@ -188,6 +194,9 @@ const double PULSE_LENGTH_SI = 10.615e-15 / 4.0; //5.0e-15; //25.0e-15 / 1.17741 * unit: none */ const double RAMP_INIT = 20.6146; //25.6415;//SI::aux_calulation::PULSE_TIME_SI/SI::PULSE_LENGTH_SI; +/* we use a sin(omega*time + laser_phase) function to set up the laser - define phase: */ +const float_X LASER_PHASE = 0.0; /* unit: rad, periodic in 2*pi */ + enum PolarisationType { LINEAR_X = 1u, @@ -250,6 +259,9 @@ const double W0_Z_SI = W0_X_SI; * unit: none */ const double RAMP_INIT = 20.0; +/* we use a sin(omega*time + laser_phase) function to set up the laser - define phase: */ +const float_X LASER_PHASE = 0.0; /* unit: rad, periodic in 2*pi */ + enum PolarisationType { LINEAR_X = 1u, @@ -287,11 +299,11 @@ const double UNITCONV_A0_to_Amplitude_SI = -2.0 * PI / WAVE_LENGTH_SI * ::picong const double AMPLITUDE_SI = 1.738e13; -/** Pulse length: +/** Pulse length: * PULSE_LENGTH_SI = total length of polynamial laser pulse * Rise time = 0.5 * PULSE_LENGTH_SI * Fall time = 0.5 * PULSE_LENGTH_SI - * in order to compare to a gaussian pulse: rise time = sqrt{2} * T_{FWHM} + * in order to compare to a gaussian pulse: rise time = sqrt{2} * T_{FWHM} * unit: seconds */ const double PULSE_LENGTH_SI = 4.0e-15; @@ -299,9 +311,12 @@ const double PULSE_LENGTH_SI = 4.0e-15; * decreases to its 1/e^2-th part, * at the focus position of the laser * unit: meter */ -const double W0x_SI = 4.246e-6; // waist in x-direction +const double W0x_SI = 4.246e-6; // waist in x-direction const double W0z_SI = W0x_SI; // waist in z-direction } + +/* we use a sin(omega*(time-riseTime) + laser_phase) function to set up the laser - define phase: */ +const float_X LASER_PHASE = 0.0; /* unit: rad, periodic in 2*pi */ } namespace laserNone diff --git a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/radiationConfig.param b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/radiationConfig.param index ba13729c4b..1c87f8c610 100644 --- a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/radiationConfig.param +++ b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/radiationConfig.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Rene Widera, Richard Pausch * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ @@ -24,7 +24,7 @@ /* radiation verbose level: - 0=nothing, 1=physics, 2=simulation_state, 4=memory, 8=critical + 0=nothing, 1=physics, 2=simulation_state, 4=memory, 8=critical */ #define PIC_VERBOSE_RADIATION 3 @@ -79,22 +79,22 @@ namespace radiationNyquist -/////////////////////////////////////////////////// +/////////////////////////////////////////////////// namespace picongpu { - // corect treatment of coherent and incoherent radiation from macroparticles - // 1 = on (slower and more memory, but correct quantitativ treatment) - // 0 = off (faster but macroparticles are treated as highly charged, point-like particle) + // corect treatment of coherent and incoherent radiation from macroparticles + // 1 = on (slower and more memory, but correct quantitativ treatment) + // 0 = off (faster but macroparticles are treated as highly charged, point-like particle) #define __COHERENTINCOHERENTWEIGHTING__ 1 /* Choose different form factors in order to consider different particle shapes for radiation - * radFormFactor_CIC_3D + * radFormFactor_CIC_3D * radFormFactor_CIC_1Dy */ namespace radFormFactor_CIC_3D { } @@ -104,11 +104,11 @@ namespace picongpu namespace radFormFactor = radFormFactor_CIC_3D; -}//namespace picongpu +}//namespace picongpu -/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// @@ -150,26 +150,22 @@ namespace picongpu // add a window function weighting to the radiation in order // to avoid ringing effects from sharpe boundaries -// 1 = on (slower but with noise/ringing reduction) -// 0 = off (faster but might contain ringing) -#define PIC_RADWINDOWFUNCTION 0 - - +// default: no window function via `radWindowFunctionNone` /* Choose different window function in order to get better ringing reduction - * radWindowFunctionRectangle * radWindowFunctionTriangle * radWindowFunctionHamming * radWindowFunctionTriplett * radWindowFunctionGauss + * radWindowFunctionNone */ -namespace radWindowFunctionRectangle { } namespace radWindowFunctionTriangle { } namespace radWindowFunctionHamming { } namespace radWindowFunctionTriplett { } namespace radWindowFunctionGauss { } +namespace radWindowFunctionNone { } -namespace radWindowFunction = radWindowFunctionTriangle; +namespace radWindowFunction = radWindowFunctionNone; }//namespace picongpu diff --git a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/radiationObserver.param b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/radiationObserver.param index c67d21d39a..ea8bbb441b 100644 --- a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/radiationObserver.param +++ b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/radiationObserver.param @@ -1,22 +1,22 @@ /** - * Copyright 2013-2014 Heiko Burau, Richard Pausch + * Copyright 2013-2015 Heiko Burau, Richard Pausch * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ #pragma once @@ -25,9 +25,9 @@ namespace picongpu { namespace radiation_observer { - /** Compute observation angles + /** Compute observation angles * - * This function is used in the Radiation plug-in kernel to compute + * This function is used in the Radiation plug-in kernel to compute * the observation directions given as a unit vector pointing * towards a 'virtual' detector * @@ -36,14 +36,14 @@ namespace picongpu * to compute the observation direction * * @return unit vector pointing in observation direction - * type: vec2 - * + * type: vector_64 + * */ - DINLINE vec2 observation_direction(const int observation_id_extern) + DINLINE vector_64 observation_direction(const int observation_id_extern) { /** Computes observation angles along the x-y plane. * Assuming electron(s) fly in -x direction and the laser - * propages in +x direction, the observation angles are centered + * propages in +x direction, the observation angles are centered * around the -y-axis (0,-1,0) . * By setting gamma, the angle range can be adjusted to the * energy of the electrons. @@ -54,19 +54,19 @@ namespace picongpu const int my_theta_id = observation_id_extern; /* set up: */ - const numtype2 gamma_times_thetaMax = 1.5; /* max normalized angle */ - const numtype2 gamma = 5.0; /* relativistic gamma */ - const numtype2 thetaMax = gamma_times_thetaMax / gamma; /* max angle */ + const picongpu::float_64 gamma_times_thetaMax = 1.5; /* max normalized angle */ + const picongpu::float_64 gamma = 5.0; /* relativistic gamma */ + const picongpu::float_64 thetaMax = gamma_times_thetaMax / gamma; /* max angle */ /* stepwith of theta for from [-thetaMax : +thetaMax] */ - const numtype2 delta_theta = 2.0 * thetaMax / (parameters::N_observer); + const picongpu::float_64 delta_theta = 2.0 * thetaMax / (parameters::N_observer); /* compute angle theta for index */ - const numtype2 theta(my_theta_id * delta_theta - thetaMax + picongpu::PI); + const picongpu::float_64 theta(my_theta_id * delta_theta - thetaMax + picongpu::PI); /* + picongpu::PI -> turn observation direction 180 degrees towards -y */ /* compute observation unit vector */ - return vec2(sinf(theta), cosf(theta), 0.0); + return vector_64(sinf(theta), cosf(theta), 0.0); } diff --git a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/species.param b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/species.param index a3cda48c2b..e9812174b0 100644 --- a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/species.param +++ b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/species.param @@ -1,5 +1,5 @@ /** - * Copyright 2014 Rene Widera + * Copyright 2014-2015 Rene Widera * * This file is part of PIConGPU. * @@ -45,6 +45,7 @@ namespace picongpu * - particles::shapes::CIC : 1st order * - particles::shapes::TSC : 2nd order (requires CUDA_ARCH>=sm_20) * - particles::shapes::PCS : 3rd order (requires CUDA_ARCH>=sm_20) + * - particles::shapes::P4S : 4th order (requires CUDA_ARCH>=sm_20) * * example: typedef particles::shapes::CIC CICShape; */ @@ -54,9 +55,9 @@ typedef particles::shapes::CIC UsedParticleShape; typedef FieldToParticleInterpolation UsedField2Particle; /*! select current solver method ----------------------------------------------- - * - currentSolver::Esirkepov : particle shapes - CIC, TSC, PCS (1st to 3rd order) + * - currentSolver::Esirkepov : particle shapes - CIC, TSC, PCS, P4S (1st to 4th order) * - currentSolver::VillaBune<> : particle shapes - CIC (1st order) only - * - currentSolver::ZigZag : particle shapes - CIC, TSC, PCS (1st to 3rd order) + * - currentSolver::ZigZag : particle shapes - CIC, TSC, PCS, P4S (1st to 4th order) * * For development purposes: --------------------------------------------------- * - currentSolver::EsirkepovNative : generic version of currentSolverEsirkepov diff --git a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/starter.param b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/starter.param index 90b8b4c28c..d74b7a0f61 100644 --- a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/starter.param +++ b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/starter.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ diff --git a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/testExtension.param b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/testExtension.param index cf77324271..476f6782f0 100644 --- a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/testExtension.param +++ b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/testExtension.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Rene Widera, Richard Pausch * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ @@ -26,7 +26,7 @@ namespace picongpu { // Init Beta = v/c for the Electron const double BETA0_X = 0.0; //unit: none - const double BETA0_Y = -0.9797958971; /* gamma=5 */ //unit: none + const double BETA0_Y = -0.9797958971; /* gamma=5 */ //unit: none const double BETA0_Z = 0.0; //unit: none // Constant Background Fields @@ -38,7 +38,7 @@ namespace picongpu const double B_Y_SI = 0.0; //unit: Tesla = Vs/m^2 const double B_Z_SI = 0.0; //unit: Tesla = Vs/m^2 - // Offset of particle in cells + // Offset of particle in cells const unsigned int OneParticleOffset = 1000; } diff --git a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/visColorScales.param b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/visColorScales.param index d542691c33..f97580df7c 100644 --- a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/visColorScales.param +++ b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/visColorScales.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Axel Huebl, Heiko Burau, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ diff --git a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/visualization.param b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/visualization.param index 503da02283..a3bc0a9ba0 100644 --- a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/visualization.param +++ b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/param/visualization.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Axel Huebl, Heiko Burau, Rene Widera, Richard Pausch * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ #pragma once diff --git a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/unitless/starter.unitless b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/unitless/starter.unitless index 8371883f8f..7d7c212bab 100644 --- a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/unitless/starter.unitless +++ b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/unitless/starter.unitless @@ -1,22 +1,22 @@ /** * Copyright 2013 Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ diff --git a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/unitless/testExtension.unitless b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/unitless/testExtension.unitless index a714bb6666..61ec4d481a 100644 --- a/examples/SingleParticleRadiationWithLaser/include/simulation_defines/unitless/testExtension.unitless +++ b/examples/SingleParticleRadiationWithLaser/include/simulation_defines/unitless/testExtension.unitless @@ -1,22 +1,22 @@ /** * Copyright 2013 Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ diff --git a/examples/SingleParticleRadiationWithLaser/submit/0008gpus.cfg b/examples/SingleParticleRadiationWithLaser/submit/0008gpus.cfg index 08daa38d56..270a0f960c 100644 --- a/examples/SingleParticleRadiationWithLaser/submit/0008gpus.cfg +++ b/examples/SingleParticleRadiationWithLaser/submit/0008gpus.cfg @@ -46,16 +46,16 @@ TBG_periodic="--periodic 1 0 1" ## Section: Optional Variables ## ################################# -TBG_pngYZ="--png_e.period 10 --png_e.axis yz --png_e.slicePoint 0.5 --png_e.folder pngElectronsYZ" -TBG_pngYX="--png_e.period 10 --png_e.axis yx --png_e.slicePoint 0.5 --png_e.folder pngElectronsYX" +TBG_pngYZ="--e_png.period 10 --e_png.axis yz --e_png.slicePoint 0.5 --e_png.folder pngElectronsYZ" +TBG_pngYX="--e_png.period 10 --e_png.axis yx --e_png.slicePoint 0.5 --e_png.folder pngElectronsYX" -TBG_radiation="--radiation_e.period 1 --radiation_e.dump 40 --radiation_e.totalRadiation 1 --radiation_e.lastRadiation 0" +TBG_radiation="--e_radiation.period 1 --e_radiation.dump 40 --e_radiation.totalRadiation" TBG_plugins="!TBG_pngYX \ !TBG_pngYZ \ - --elec_cnt.period 100 \ + --e_macroParticlesCount.period 100 \ !TBG_radiation \ - --pos_e.period 1" + --e_position.period 1" ################################# ## Section: Program Parameters ## diff --git a/examples/SingleParticleTest/include/simulation_defines/extensionParam.loader b/examples/SingleParticleTest/include/simulation_defines/extensionParam.loader index 15de399de5..53f13bd6a4 100644 --- a/examples/SingleParticleTest/include/simulation_defines/extensionParam.loader +++ b/examples/SingleParticleTest/include/simulation_defines/extensionParam.loader @@ -1,22 +1,22 @@ /** * Copyright 2013 Axel Huebl, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ #pragma once diff --git a/examples/SingleParticleTest/include/simulation_defines/extensionUnitless.loader b/examples/SingleParticleTest/include/simulation_defines/extensionUnitless.loader index 945d734d44..b06cafde71 100644 --- a/examples/SingleParticleTest/include/simulation_defines/extensionUnitless.loader +++ b/examples/SingleParticleTest/include/simulation_defines/extensionUnitless.loader @@ -1,22 +1,22 @@ /** * Copyright 2013 Axel Huebl, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ #pragma once diff --git a/examples/SingleParticleTest/include/simulation_defines/param/backgroundFields.param b/examples/SingleParticleTest/include/simulation_defines/param/backgroundFields.param index 7033667f7f..729cc09ece 100644 --- a/examples/SingleParticleTest/include/simulation_defines/param/backgroundFields.param +++ b/examples/SingleParticleTest/include/simulation_defines/param/backgroundFields.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Axel Huebl, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ diff --git a/examples/SingleParticleTest/include/simulation_defines/param/componentsConfig.param b/examples/SingleParticleTest/include/simulation_defines/param/componentsConfig.param index 31032f47f6..c88fead12f 100644 --- a/examples/SingleParticleTest/include/simulation_defines/param/componentsConfig.param +++ b/examples/SingleParticleTest/include/simulation_defines/param/componentsConfig.param @@ -1,5 +1,5 @@ /** - * Copyright 2013-2014 Axel Huebl, Anton Helm, Rene Widera, Richard Pausch + * Copyright 2013-2015 Axel Huebl, Anton Helm, Rene Widera, Richard Pausch * * This file is part of PIConGPU. * @@ -36,6 +36,7 @@ namespace simulation_starter = singleParticleTest; * in 'x' direction * - laserWavepacket : wavepacket (Gaussian in time and space, not focusing) * - laserPlaneWave : a plane wave + * - laserPolynom : a polynomial laser envelope */ namespace laserProfile = laserNone; diff --git a/examples/SingleParticleTest/include/simulation_defines/param/species.param b/examples/SingleParticleTest/include/simulation_defines/param/species.param index a3cda48c2b..e9812174b0 100644 --- a/examples/SingleParticleTest/include/simulation_defines/param/species.param +++ b/examples/SingleParticleTest/include/simulation_defines/param/species.param @@ -1,5 +1,5 @@ /** - * Copyright 2014 Rene Widera + * Copyright 2014-2015 Rene Widera * * This file is part of PIConGPU. * @@ -45,6 +45,7 @@ namespace picongpu * - particles::shapes::CIC : 1st order * - particles::shapes::TSC : 2nd order (requires CUDA_ARCH>=sm_20) * - particles::shapes::PCS : 3rd order (requires CUDA_ARCH>=sm_20) + * - particles::shapes::P4S : 4th order (requires CUDA_ARCH>=sm_20) * * example: typedef particles::shapes::CIC CICShape; */ @@ -54,9 +55,9 @@ typedef particles::shapes::CIC UsedParticleShape; typedef FieldToParticleInterpolation UsedField2Particle; /*! select current solver method ----------------------------------------------- - * - currentSolver::Esirkepov : particle shapes - CIC, TSC, PCS (1st to 3rd order) + * - currentSolver::Esirkepov : particle shapes - CIC, TSC, PCS, P4S (1st to 4th order) * - currentSolver::VillaBune<> : particle shapes - CIC (1st order) only - * - currentSolver::ZigZag : particle shapes - CIC, TSC, PCS (1st to 3rd order) + * - currentSolver::ZigZag : particle shapes - CIC, TSC, PCS, P4S (1st to 4th order) * * For development purposes: --------------------------------------------------- * - currentSolver::EsirkepovNative : generic version of currentSolverEsirkepov diff --git a/examples/SingleParticleTest/include/simulation_defines/param/starter.param b/examples/SingleParticleTest/include/simulation_defines/param/starter.param index 330f03717f..60e9ff8a67 100644 --- a/examples/SingleParticleTest/include/simulation_defines/param/starter.param +++ b/examples/SingleParticleTest/include/simulation_defines/param/starter.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Axel Huebl, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ diff --git a/examples/SingleParticleTest/include/simulation_defines/param/visColorScales.param b/examples/SingleParticleTest/include/simulation_defines/param/visColorScales.param index d542691c33..f97580df7c 100644 --- a/examples/SingleParticleTest/include/simulation_defines/param/visColorScales.param +++ b/examples/SingleParticleTest/include/simulation_defines/param/visColorScales.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Axel Huebl, Heiko Burau, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ diff --git a/examples/SingleParticleTest/include/simulation_defines/param/visualization.param b/examples/SingleParticleTest/include/simulation_defines/param/visualization.param index eceb1cbe53..16b803972d 100644 --- a/examples/SingleParticleTest/include/simulation_defines/param/visualization.param +++ b/examples/SingleParticleTest/include/simulation_defines/param/visualization.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Axel Huebl, Heiko Burau, Rene Widera, Richard Pausch * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ #pragma once diff --git a/examples/SingleParticleTest/include/simulation_defines/unitless/backgroundFields.unitless b/examples/SingleParticleTest/include/simulation_defines/unitless/backgroundFields.unitless index d5e01ff39f..17c7782a78 100644 --- a/examples/SingleParticleTest/include/simulation_defines/unitless/backgroundFields.unitless +++ b/examples/SingleParticleTest/include/simulation_defines/unitless/backgroundFields.unitless @@ -1,22 +1,22 @@ /** * Copyright 2013 Axel Huebl, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ diff --git a/examples/SingleParticleTest/include/simulation_defines/unitless/starter.unitless b/examples/SingleParticleTest/include/simulation_defines/unitless/starter.unitless index 18ad2cb0dc..8fe93e3acf 100644 --- a/examples/SingleParticleTest/include/simulation_defines/unitless/starter.unitless +++ b/examples/SingleParticleTest/include/simulation_defines/unitless/starter.unitless @@ -1,22 +1,22 @@ /** * Copyright 2013 Axel Huebl, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ diff --git a/examples/SingleParticleTest/submit/0008gpus.cfg b/examples/SingleParticleTest/submit/0008gpus.cfg index c5a9018e7a..d12c00ceee 100644 --- a/examples/SingleParticleTest/submit/0008gpus.cfg +++ b/examples/SingleParticleTest/submit/0008gpus.cfg @@ -46,13 +46,13 @@ TBG_periodic="--periodic 1 0 1" ## Section: Optional Variables ## ################################# -TBG_pngYZ="--png_e.period 10 --png_e.axis yz --png_e.slicePoint 0.5 --png_e.folder pngElectronsYZ" -TBG_pngYX="--png_e.period 10 --png_e.axis yx --png_e.slicePoint 0.5 --png_e.folder pngElectronsYX" +TBG_pngYZ="--e_png.period 10 --e_png.axis yz --e_png.slicePoint 0.5 --e_png.folder pngElectronsYZ" +TBG_pngYX="--e_png.period 10 --e_png.axis yx --e_png.slicePoint 0.5 --e_png.folder pngElectronsYX" -TBG_plugins="--pos_e.period 1 \ +TBG_plugins="--e_position.period 1 \ !TBG_pngYX \ !TBG_pngYZ \ - --elec_cnt.period 100" + --e_macroParticlesCount.period 100" ################################# diff --git a/examples/ThermalTest/include/simulation_defines/param/componentsConfig.param b/examples/ThermalTest/include/simulation_defines/param/componentsConfig.param index c9ae7e2e7f..2061384920 100644 --- a/examples/ThermalTest/include/simulation_defines/param/componentsConfig.param +++ b/examples/ThermalTest/include/simulation_defines/param/componentsConfig.param @@ -1,5 +1,5 @@ /** - * Copyright 2013-2014 Axel Huebl, Heiko Burau, Anton Helm, Rene Widera, + * Copyright 2013-2015 Axel Huebl, Heiko Burau, Anton Helm, Rene Widera, * Richard Pausch * * This file is part of PIConGPU. @@ -37,6 +37,7 @@ namespace simulation_starter = thermalTestStarter; * in 'x' direction * - laserWavepacket : wavepacket (Gaussian in time and space, not focusing) * - laserPlaneWave : a plane wave + * - laserPolynom : a polynomial laser envelope */ namespace laserProfile = laserNone; diff --git a/examples/ThermalTest/include/simulation_defines/param/gridConfig.param b/examples/ThermalTest/include/simulation_defines/param/gridConfig.param index 84c0509a56..e5d54b092b 100644 --- a/examples/ThermalTest/include/simulation_defines/param/gridConfig.param +++ b/examples/ThermalTest/include/simulation_defines/param/gridConfig.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Heiko Burau, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ @@ -53,7 +53,7 @@ namespace picongpu {1.0e-3, 1.0e-3}, /*x direction [negative,positive]*/ {1.0e-3, 1.0e-3}, /*y direction [negative,positive]*/ {1.0e-3, 1.0e-3} /*z direction [negative,positive]*/ - }; //unit: none + }; //unit: none const uint32_t ABSORBER_FADE_IN_STEPS = 16; @@ -62,7 +62,7 @@ namespace picongpu * is fired at the begin of the simulation. * When it reaches slide_point % of the absolute(*) simulation area, * the co-moving window starts to move with the speed of light. - * + * * (*) Note: beware, that there is one "hidden" row of gpus at the y-front, * when you use the co-moving window * 0.75 means only 75% of simulation area is used for real simulation diff --git a/examples/ThermalTest/include/simulation_defines/param/starter.param b/examples/ThermalTest/include/simulation_defines/param/starter.param index e6f68ecd2e..caa58241c8 100644 --- a/examples/ThermalTest/include/simulation_defines/param/starter.param +++ b/examples/ThermalTest/include/simulation_defines/param/starter.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Heiko Burau, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ diff --git a/examples/ThermalTest/include/simulation_defines/unitless/starter.unitless b/examples/ThermalTest/include/simulation_defines/unitless/starter.unitless index 14842b5e99..23ef896bd3 100644 --- a/examples/ThermalTest/include/simulation_defines/unitless/starter.unitless +++ b/examples/ThermalTest/include/simulation_defines/unitless/starter.unitless @@ -1,22 +1,22 @@ /** * Copyright 2013 Heiko Burau, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ diff --git a/examples/ThermalTest/submit/0001gpu.cfg b/examples/ThermalTest/submit/0001gpu.cfg index 5d55e24ee7..93df6ca1a9 100644 --- a/examples/ThermalTest/submit/0001gpu.cfg +++ b/examples/ThermalTest/submit/0001gpu.cfg @@ -47,12 +47,12 @@ TBG_periodic="--periodic 1 1 1" ################################# # create preview images (png) -TBG_pngYZ="--png_e.period 10 --png_e.axis yz --png_e.slicePoint 0.5 --png_e.folder pngElectronsYZ" -TBG_pngYX="--png_e.period 10 --png_e.axis yx --png_e.slicePoint 0.5 --png_e.folder pngElectronsYX" +TBG_pngYZ="--e_png.period 10 --e_png.axis yz --e_png.slicePoint 0.5 --e_png.folder pngElectronsYZ" +TBG_pngYX="--e_png.period 10 --e_png.axis yx --e_png.slicePoint 0.5 --e_png.folder pngElectronsYX" TBG_plugins="!TBG_pngYX \ !TBG_pngYZ \ - --elec_cnt.period 250" + --e_macroParticlesCount.period 250" ################################# diff --git a/examples/ThermalTest/submit/0004gpus.cfg b/examples/ThermalTest/submit/0004gpus.cfg index 0307d3e7c4..1feceb7115 100644 --- a/examples/ThermalTest/submit/0004gpus.cfg +++ b/examples/ThermalTest/submit/0004gpus.cfg @@ -47,12 +47,12 @@ TBG_periodic="--periodic 1 1 1" ################################# # create preview images (png) -TBG_pngYZ="--png_e.period 10 --png_e.axis yz --png_e.slicePoint 0.5 --png_e.folder pngElectronsYZ" -TBG_pngYX="--png_e.period 10 --png_e.axis yx --png_e.slicePoint 0.5 --png_e.folder pngElectronsYX" +TBG_pngYZ="--e_png.period 10 --e_png.axis yz --e_png.slicePoint 0.5 --e_png.folder pngElectronsYZ" +TBG_pngYX="--e_png.period 10 --e_png.axis yx --e_png.slicePoint 0.5 --e_png.folder pngElectronsYX" TBG_plugins="!TBG_pngYX \ !TBG_pngYZ \ - --elec_cnt.period 100" + --e_macroParticlesCount.period 100" ################################# diff --git a/examples/ThermalTest/submit/0008gpus.cfg b/examples/ThermalTest/submit/0008gpus.cfg index 3bc93b5330..cc8ad11a9a 100644 --- a/examples/ThermalTest/submit/0008gpus.cfg +++ b/examples/ThermalTest/submit/0008gpus.cfg @@ -47,12 +47,12 @@ TBG_periodic="--periodic 1 1 1" ################################# # create preview images (png) -TBG_pngYZ="--png_e.period 10 --png_e.axis yz --png_e.slicePoint 0.5 --png_e.folder pngElectronsYZ" -TBG_pngYX="--png_e.period 10 --png_e.axis yx --png_e.slicePoint 0.5 --png_e.folder pngElectronsYX" +TBG_pngYZ="--e_png.period 10 --e_png.axis yz --e_png.slicePoint 0.5 --e_png.folder pngElectronsYZ" +TBG_pngYX="--e_png.period 10 --e_png.axis yx --e_png.slicePoint 0.5 --e_png.folder pngElectronsYX" TBG_plugins="!TBG_pngYX \ !TBG_pngYZ \ - --elec_cnt.period 100" + --e_macroParticlesCount.period 100" ################################# diff --git a/examples/ThermalTest/submit/0032gpus.cfg b/examples/ThermalTest/submit/0032gpus.cfg index a52a22c6e9..93b9a43fcb 100644 --- a/examples/ThermalTest/submit/0032gpus.cfg +++ b/examples/ThermalTest/submit/0032gpus.cfg @@ -47,12 +47,12 @@ TBG_periodic="--periodic 1 1 1" ################################# # create preview images (png) -TBG_pngYZ="--png_e.period 10 --png_e.axis yz --png_e.slicePoint 0.5 --png_e.folder pngElectronsYZ" -TBG_pngYX="--png_e.period 10 --png_e.axis yx --png_e.slicePoint 0.5 --png_e.folder pngElectronsYX" +TBG_pngYZ="--e_png.period 10 --e_png.axis yz --e_png.slicePoint 0.5 --e_png.folder pngElectronsYZ" +TBG_pngYX="--e_png.period 10 --e_png.axis yx --e_png.slicePoint 0.5 --e_png.folder pngElectronsYX" TBG_plugins="!TBG_pngYX \ !TBG_pngYZ \ - --elec_cnt.period 250" + --e_macroParticlesCount.period 250" ################################# diff --git a/examples/ThermalTest/submit/0064gpus.cfg b/examples/ThermalTest/submit/0064gpus.cfg index d72bffbb84..f9d3cf4149 100644 --- a/examples/ThermalTest/submit/0064gpus.cfg +++ b/examples/ThermalTest/submit/0064gpus.cfg @@ -47,12 +47,12 @@ TBG_periodic="--periodic 1 1 1" ################################# # create preview images (png) -TBG_pngYZ="--png_e.period 10 --png_e.axis yz --png_e.slicePoint 0.5 --png_e.folder pngElectronsYZ" -TBG_pngYX="--png_e.period 10 --png_e.axis yx --png_e.slicePoint 0.5 --png_e.folder pngElectronsYX" +TBG_pngYZ="--e_png.period 10 --e_png.axis yz --e_png.slicePoint 0.5 --e_png.folder pngElectronsYZ" +TBG_pngYX="--e_png.period 10 --e_png.axis yx --e_png.slicePoint 0.5 --e_png.folder pngElectronsYX" TBG_plugins="!TBG_pngYX \ !TBG_pngYZ \ - --elec_cnt.period 250" + --e_macroParticlesCount.period 250" ################################# diff --git a/examples/WeibelTransverse/include/simulation_defines/extensionParam.loader b/examples/WeibelTransverse/include/simulation_defines/extensionParam.loader index 7892e097ae..b7e0f79088 100644 --- a/examples/WeibelTransverse/include/simulation_defines/extensionParam.loader +++ b/examples/WeibelTransverse/include/simulation_defines/extensionParam.loader @@ -1,22 +1,22 @@ /** * Copyright 2013 Axel Huebl, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ #pragma once diff --git a/examples/WeibelTransverse/include/simulation_defines/extensionUnitless.loader b/examples/WeibelTransverse/include/simulation_defines/extensionUnitless.loader index a01dfbd880..b07b017c53 100644 --- a/examples/WeibelTransverse/include/simulation_defines/extensionUnitless.loader +++ b/examples/WeibelTransverse/include/simulation_defines/extensionUnitless.loader @@ -1,22 +1,22 @@ /** * Copyright 2013 Axel Huebl, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ #pragma once diff --git a/examples/WeibelTransverse/include/simulation_defines/param/componentsConfig.param b/examples/WeibelTransverse/include/simulation_defines/param/componentsConfig.param index d66119f134..8077230d4f 100644 --- a/examples/WeibelTransverse/include/simulation_defines/param/componentsConfig.param +++ b/examples/WeibelTransverse/include/simulation_defines/param/componentsConfig.param @@ -1,5 +1,5 @@ /** - * Copyright 2013-2014 Axel Huebl, Anton Helm, Rene Widera, Richard Pausch + * Copyright 2013-2015 Axel Huebl, Anton Helm, Rene Widera, Richard Pausch * * This file is part of PIConGPU. * @@ -36,6 +36,7 @@ namespace picongpu * in 'x' direction * - laserWavepacket : wavepacket (Gaussian in time and space, not focusing) * - laserPlaneWave : a plane wave + * - laserPolynom : a polynomial laser envelope */ namespace laserProfile = laserNone; diff --git a/examples/WeibelTransverse/include/simulation_defines/param/gridConfig.param b/examples/WeibelTransverse/include/simulation_defines/param/gridConfig.param index 76f661258b..fc04b7e989 100644 --- a/examples/WeibelTransverse/include/simulation_defines/param/gridConfig.param +++ b/examples/WeibelTransverse/include/simulation_defines/param/gridConfig.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Axel Huebl, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ @@ -53,7 +53,7 @@ namespace picongpu {1.0e-3, 1.0e-3}, /*x direction [negative,positive]*/ {1.0e-3, 1.0e-3}, /*y direction [negative,positive]*/ {1.0e-3, 1.0e-3} /*z direction [negative,positive]*/ - }; //unit: none + }; //unit: none const uint32_t ABSORBER_FADE_IN_STEPS = 16; @@ -62,7 +62,7 @@ namespace picongpu * is fired at the begin of the simulation. * When it reaches slide_point % of the absolute(*) simulation area, * the co-moving window starts to move with the speed of light. - * + * * (*) Note: beware, that there is one "hidden" row of gpus at the y-front, * when you use the co-moving window * 0.75 means only 75% of simulation area is used for real simulation diff --git a/examples/WeibelTransverse/include/simulation_defines/param/physicalConstants.param b/examples/WeibelTransverse/include/simulation_defines/param/physicalConstants.param index 396f63124e..0ee8b5ad56 100644 --- a/examples/WeibelTransverse/include/simulation_defines/param/physicalConstants.param +++ b/examples/WeibelTransverse/include/simulation_defines/param/physicalConstants.param @@ -1,22 +1,22 @@ /** * Copyright 2013, 2015 Axel Huebl, Rene Widera, Richard Pausch * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ @@ -31,7 +31,7 @@ namespace picongpu * use-cases, e.g. energy-binning algorithms. */ const float_X GAMMA_THRESH = float_X(1.005); - /** This limit is used to decide between a pure 1-sqrt(1-x) calculation + /** This limit is used to decide between a pure 1-sqrt(1-x) calculation * and a 5th order Taylor approximation of 1-sqrt(1-x) to avoid halving * of significant digits due to the sqrt() evaluation at x = 1/gamma^2 near 0.0. * With 0.18 the relative error between Taylor approximation and real value @@ -71,7 +71,7 @@ namespace picongpu // -> cast to float // WE DO NOT define "UNIT_ENERGY_keV" or something similar! Never! // Stay SI, stay free ;-) - // + // // example: // // some particle physicist beloved input: // const float_64 An_Arbitrary_Energy_Input_keV = 30.0; // unit: keV diff --git a/examples/WeibelTransverse/include/simulation_defines/param/visColorScales.param b/examples/WeibelTransverse/include/simulation_defines/param/visColorScales.param index d542691c33..f97580df7c 100644 --- a/examples/WeibelTransverse/include/simulation_defines/param/visColorScales.param +++ b/examples/WeibelTransverse/include/simulation_defines/param/visColorScales.param @@ -1,22 +1,22 @@ /** * Copyright 2013 Axel Huebl, Heiko Burau, Rene Widera * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ diff --git a/examples/WeibelTransverse/submit/0004gpus.cfg b/examples/WeibelTransverse/submit/0004gpus.cfg index fd87976d12..b4413817e6 100644 --- a/examples/WeibelTransverse/submit/0004gpus.cfg +++ b/examples/WeibelTransverse/submit/0004gpus.cfg @@ -46,15 +46,15 @@ TBG_periodic="--periodic 1 1 1" ## Section: Optional Variables ## ################################# -TBG_pngYZ="--png_e.period 10 --png_e.axis yz --png_e.slicePoint 0.5 --png_e.folder pngElectronsYZ" -TBG_pngYX="--png_e.period 10 --png_e.axis yx --png_e.slicePoint 0.5 --png_e.folder pngElectronsYX" +TBG_pngYZ="--e_png.period 10 --e_png.axis yz --e_png.slicePoint 0.5 --e_png.folder pngElectronsYZ" +TBG_pngYX="--e_png.period 10 --e_png.axis yx --e_png.slicePoint 0.5 --e_png.folder pngElectronsYX" -TBG_ipngYZ="--png_i.period 10 --png_i.axis yz --png_i.slicePoint 0.5 --png_i.folder pngIonsYZ" -TBG_ipngYX="--png_i.period 10 --png_i.axis yx --png_i.slicePoint 0.5 --png_i.folder pngIonsYX" +TBG_ipngYZ="--i_png.period 10 --i_png.axis yz --i_png.slicePoint 0.5 --i_png.folder pngIonsYZ" +TBG_ipngYX="--i_png.period 10 --i_png.axis yx --i_png.slicePoint 0.5 --i_png.folder pngIonsYX" # [in keV] -TBG_eBin="--bin_e.period 100 --bin_e.binCount 1024 --bin_e.minEnergy 0 --bin_e.maxEnergy 5000" -TBG_iBin="--bin_i.period 100 --bin_i.binCount 1024 --bin_i.minEnergy 0 --bin_i.maxEnergy 2000000" +TBG_eBin="--e_energyHistogram.period 100 --e_energyHistogram.binCount 1024 --e_energyHistogram.minEnergy 0 --e_energyHistogram.maxEnergy 5000" +TBG_iBin="--i_energyHistogram.period 100 --i_energyHistogram.binCount 1024 --i_energyHistogram.minEnergy 0 --i_energyHistogram.maxEnergy 2000000" TBG_plugins="!TBG_ipngYX \ !TBG_ipngYZ \ @@ -62,11 +62,11 @@ TBG_plugins="!TBG_ipngYX \ !TBG_iBin \ !TBG_pngYX \ !TBG_pngYZ \ - --ions_cnt.period 100 \ - --elec_cnt.period 100 \ - --energy_fields.period 10 \ - --energy_e.period 10 \ - --energy_i.period 10" + --i_macroParticlesCount.period 100 \ + --e_macroParticlesCount.period 100 \ + --fields_energy.period 10 \ + --e_energy.period 10 \ + --i_energy.period 10" ################################# diff --git a/src/libPMacc/examples/gameOfLife2D/CMakeLists.txt b/src/libPMacc/examples/gameOfLife2D/CMakeLists.txt index 0163497949..86d7190f9c 100644 --- a/src/libPMacc/examples/gameOfLife2D/CMakeLists.txt +++ b/src/libPMacc/examples/gameOfLife2D/CMakeLists.txt @@ -4,7 +4,7 @@ # This file is part of libPMacc. # # libPMacc is free software: you can redistribute it and/or modify -# it under the terms of of either the GNU General Public License or +# it under the terms of either the GNU General Public License or # the GNU Lesser General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. diff --git a/src/libPMacc/examples/gameOfLife2D/include/Evolution.hpp b/src/libPMacc/examples/gameOfLife2D/include/Evolution.hpp index 6927352e4d..dc1c495b74 100644 --- a/src/libPMacc/examples/gameOfLife2D/include/Evolution.hpp +++ b/src/libPMacc/examples/gameOfLife2D/include/Evolution.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/examples/gameOfLife2D/include/GatherSlice.hpp b/src/libPMacc/examples/gameOfLife2D/include/GatherSlice.hpp index 4c6665ef5f..0bd4c2a340 100644 --- a/src/libPMacc/examples/gameOfLife2D/include/GatherSlice.hpp +++ b/src/libPMacc/examples/gameOfLife2D/include/GatherSlice.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013-2014 Axel Huebl, Heiko Burau, Rene Widera, Maximilian Knespel + * Copyright 2013-2015 Axel Huebl, Heiko Burau, Rene Widera, + * Maximilian Knespel, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -19,19 +20,14 @@ * If not, see . */ +#pragma once -#ifndef GATHERSLICE_HPP -#define GATHERSLICE_HPP - -#include "types.h" - - -#include #include "mappings/simulation/GridController.hpp" - -//c includes #include "memory/boxes/PitchedBox.hpp" #include "dimensions/DataSpace.hpp" +#include "types.h" // DIM* + +#include namespace gol { @@ -227,5 +223,4 @@ struct GatherSlice }//namespace -#endif /* GATHERSLICE_HPP */ diff --git a/src/libPMacc/examples/gameOfLife2D/include/PngCreator.hpp b/src/libPMacc/examples/gameOfLife2D/include/PngCreator.hpp index 5dce868260..5843144f34 100644 --- a/src/libPMacc/examples/gameOfLife2D/include/PngCreator.hpp +++ b/src/libPMacc/examples/gameOfLife2D/include/PngCreator.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/examples/gameOfLife2D/include/Simulation.hpp b/src/libPMacc/examples/gameOfLife2D/include/Simulation.hpp index 6b6cc225c5..05fe67d649 100644 --- a/src/libPMacc/examples/gameOfLife2D/include/Simulation.hpp +++ b/src/libPMacc/examples/gameOfLife2D/include/Simulation.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/examples/gameOfLife2D/include/types.hpp b/src/libPMacc/examples/gameOfLife2D/include/types.hpp index 9c3f1bb31b..1426089abf 100644 --- a/src/libPMacc/examples/gameOfLife2D/include/types.hpp +++ b/src/libPMacc/examples/gameOfLife2D/include/types.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/examples/gameOfLife2D/main.cu b/src/libPMacc/examples/gameOfLife2D/main.cu index a3bf94d9ab..62c97651c0 100644 --- a/src/libPMacc/examples/gameOfLife2D/main.cu +++ b/src/libPMacc/examples/gameOfLife2D/main.cu @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/examples/gameOfLife2D/submit/1gpu.cfg b/src/libPMacc/examples/gameOfLife2D/submit/1gpu.cfg index c24802669d..2a96c5cf66 100644 --- a/src/libPMacc/examples/gameOfLife2D/submit/1gpu.cfg +++ b/src/libPMacc/examples/gameOfLife2D/submit/1gpu.cfg @@ -5,7 +5,7 @@ # This file is part of libPMacc. # # libPMacc is free software: you can redistribute it and/or modify -# it under the terms of of either the GNU General Public License or +# it under the terms of either the GNU General Public License or # the GNU Lesser General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. diff --git a/src/libPMacc/examples/gameOfLife2D/submit/2gpus.cfg b/src/libPMacc/examples/gameOfLife2D/submit/2gpus.cfg index f4b4115a10..5409b0c93a 100644 --- a/src/libPMacc/examples/gameOfLife2D/submit/2gpus.cfg +++ b/src/libPMacc/examples/gameOfLife2D/submit/2gpus.cfg @@ -5,7 +5,7 @@ # This file is part of libPMacc. # # libPMacc is free software: you can redistribute it and/or modify -# it under the terms of of either the GNU General Public License or +# it under the terms of either the GNU General Public License or # the GNU Lesser General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. diff --git a/src/libPMacc/examples/gameOfLife2D/submit/4gpus.cfg b/src/libPMacc/examples/gameOfLife2D/submit/4gpus.cfg index d7471d6842..a0ce87cb92 100644 --- a/src/libPMacc/examples/gameOfLife2D/submit/4gpus.cfg +++ b/src/libPMacc/examples/gameOfLife2D/submit/4gpus.cfg @@ -5,7 +5,7 @@ # This file is part of libPMacc. # # libPMacc is free software: you can redistribute it and/or modify -# it under the terms of of either the GNU General Public License or +# it under the terms of either the GNU General Public License or # the GNU Lesser General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. diff --git a/src/libPMacc/examples/gameOfLife2D/submit/bash/bash_mpiexec.tpl b/src/libPMacc/examples/gameOfLife2D/submit/bash/bash_mpiexec.tpl index d30933253e..d4731aa538 100644 --- a/src/libPMacc/examples/gameOfLife2D/submit/bash/bash_mpiexec.tpl +++ b/src/libPMacc/examples/gameOfLife2D/submit/bash/bash_mpiexec.tpl @@ -5,7 +5,7 @@ # This file is part of libPMacc. # # libPMacc is free software: you can redistribute it and/or modify -# it under the terms of of either the GNU General Public License or +# it under the terms of either the GNU General Public License or # the GNU Lesser General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. diff --git a/src/libPMacc/examples/gameOfLife2D/submit/bash/bash_mpirun.tpl b/src/libPMacc/examples/gameOfLife2D/submit/bash/bash_mpirun.tpl index b6cfad20a2..6fe4269aa0 100644 --- a/src/libPMacc/examples/gameOfLife2D/submit/bash/bash_mpirun.tpl +++ b/src/libPMacc/examples/gameOfLife2D/submit/bash/bash_mpirun.tpl @@ -5,7 +5,7 @@ # This file is part of libPMacc. # # libPMacc is free software: you can redistribute it and/or modify -# it under the terms of of either the GNU General Public License or +# it under the terms of either the GNU General Public License or # the GNU Lesser General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. diff --git a/src/libPMacc/include/Environment.hpp b/src/libPMacc/include/Environment.hpp index 13ab4a1c74..063acd9df1 100644 --- a/src/libPMacc/include/Environment.hpp +++ b/src/libPMacc/include/Environment.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -185,16 +185,42 @@ class Environment { const int tryDeviceId = (deviceOffset + deviceNumber) % num_gpus; rc = cudaSetDevice(tryDeviceId); + + if(rc == cudaSuccess) + { + cudaStream_t stream; + /* \todo: Check if this workaround is needed + * + * - since NVIDIA change something in driver cudaSetDevice never + * return an error if another process already use the selected + * device if gpu compute mode is set "process exclusive" + * - create a dummy stream to check if the device is already used by + * an other process. + * - cudaStreamCreate fail if gpu is already in use + */ + rc = cudaStreamCreate(&stream); + } + if (rc == cudaSuccess) { cudaDeviceProp dprop; - cudaGetDeviceProperties(&dprop, deviceNumber); + CUDA_CHECK(cudaGetDeviceProperties(&dprop, deviceNumber)); log ("Set device to %1%: %2%") % tryDeviceId % dprop.name; - CUDA_CHECK(cudaSetDeviceFlags(cudaDeviceScheduleSpin)); + if(cudaErrorSetOnActiveProcess == cudaSetDeviceFlags(cudaDeviceScheduleSpin)) + { + cudaGetLastError(); //reset all errors + /* - because of cudaStreamCreate was called cudaSetDeviceFlags crashed + * - to set the flags reset the device and set flags again + */ + CUDA_CHECK(cudaDeviceReset()); + CUDA_CHECK(cudaSetDeviceFlags(cudaDeviceScheduleSpin)); + } + CUDA_CHECK(cudaGetLastError()); break; } - else if (rc == cudaErrorDeviceAlreadyInUse) + else if (rc == cudaErrorDeviceAlreadyInUse || rc==cudaErrorDevicesUnavailable) { + cudaGetLastError(); //reset all errors log ("Device %1% already in use, try next.") % tryDeviceId; continue; } diff --git a/src/libPMacc/include/RefWrapper.hpp b/src/libPMacc/include/RefWrapper.hpp index 95389da76a..6e11fcfeac 100644 --- a/src/libPMacc/include/RefWrapper.hpp +++ b/src/libPMacc/include/RefWrapper.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/algorithms/ForEach.hpp b/src/libPMacc/include/algorithms/ForEach.hpp index 2ae10c73b1..63047a3a7c 100644 --- a/src/libPMacc/include/algorithms/ForEach.hpp +++ b/src/libPMacc/include/algorithms/ForEach.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013-2014 Axel Huebl, Heiko Burau, Rene Widera + * Copyright 2013-2015 Axel Huebl, Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -24,14 +24,7 @@ #pragma once #include "compileTime/accessors/Identity.hpp" - -#include -#include -#include -#include -#include - -#include +#include "forward.hpp" #include #include @@ -46,7 +39,12 @@ #include #include #include -#include "forward.hpp" +#include +#include +#include +#include +#include +#include /* Help to read this file: diff --git a/src/libPMacc/include/algorithms/GlobalReduce.hpp b/src/libPMacc/include/algorithms/GlobalReduce.hpp index 0298de9021..84f7242285 100644 --- a/src/libPMacc/include/algorithms/GlobalReduce.hpp +++ b/src/libPMacc/include/algorithms/GlobalReduce.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/algorithms/PromoteType.hpp b/src/libPMacc/include/algorithms/PromoteType.hpp index 25402ba004..b0918190c0 100644 --- a/src/libPMacc/include/algorithms/PromoteType.hpp +++ b/src/libPMacc/include/algorithms/PromoteType.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/algorithms/TypeCast.hpp b/src/libPMacc/include/algorithms/TypeCast.hpp index 7be6e28999..d7dbde25d9 100644 --- a/src/libPMacc/include/algorithms/TypeCast.hpp +++ b/src/libPMacc/include/algorithms/TypeCast.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/algorithms/math.hpp b/src/libPMacc/include/algorithms/math.hpp index bfe93c1f1b..a2eac81012 100644 --- a/src/libPMacc/include/algorithms/math.hpp +++ b/src/libPMacc/include/algorithms/math.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/algorithms/math/defines/abs.hpp b/src/libPMacc/include/algorithms/math/defines/abs.hpp index e6d7353d3f..b98672dab2 100644 --- a/src/libPMacc/include/algorithms/math/defines/abs.hpp +++ b/src/libPMacc/include/algorithms/math/defines/abs.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/algorithms/math/defines/comparison.hpp b/src/libPMacc/include/algorithms/math/defines/comparison.hpp index 2e37e78dd4..e65547f3eb 100644 --- a/src/libPMacc/include/algorithms/math/defines/comparison.hpp +++ b/src/libPMacc/include/algorithms/math/defines/comparison.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/algorithms/math/defines/cross.hpp b/src/libPMacc/include/algorithms/math/defines/cross.hpp index 7326691ed7..cdbe9b5ab1 100644 --- a/src/libPMacc/include/algorithms/math/defines/cross.hpp +++ b/src/libPMacc/include/algorithms/math/defines/cross.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/algorithms/math/defines/dot.hpp b/src/libPMacc/include/algorithms/math/defines/dot.hpp index 50eca8a325..dec325b746 100644 --- a/src/libPMacc/include/algorithms/math/defines/dot.hpp +++ b/src/libPMacc/include/algorithms/math/defines/dot.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/algorithms/math/defines/erf.hpp b/src/libPMacc/include/algorithms/math/defines/erf.hpp index e1edc2e08e..8b4d6737ca 100644 --- a/src/libPMacc/include/algorithms/math/defines/erf.hpp +++ b/src/libPMacc/include/algorithms/math/defines/erf.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/algorithms/math/defines/exp.hpp b/src/libPMacc/include/algorithms/math/defines/exp.hpp index b6f4f0a9ce..6c7d73d76c 100644 --- a/src/libPMacc/include/algorithms/math/defines/exp.hpp +++ b/src/libPMacc/include/algorithms/math/defines/exp.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/algorithms/math/defines/floatingPoint.hpp b/src/libPMacc/include/algorithms/math/defines/floatingPoint.hpp index 1a7813ad85..c314a92df1 100644 --- a/src/libPMacc/include/algorithms/math/defines/floatingPoint.hpp +++ b/src/libPMacc/include/algorithms/math/defines/floatingPoint.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/algorithms/math/defines/pow.hpp b/src/libPMacc/include/algorithms/math/defines/pow.hpp index 830cb0d343..b85b98e0c2 100644 --- a/src/libPMacc/include/algorithms/math/defines/pow.hpp +++ b/src/libPMacc/include/algorithms/math/defines/pow.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/algorithms/math/defines/sqrt.hpp b/src/libPMacc/include/algorithms/math/defines/sqrt.hpp index dc213f1763..469ad343ff 100644 --- a/src/libPMacc/include/algorithms/math/defines/sqrt.hpp +++ b/src/libPMacc/include/algorithms/math/defines/sqrt.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/algorithms/math/defines/trigo.hpp b/src/libPMacc/include/algorithms/math/defines/trigo.hpp index 3489b17760..bc1630ee9a 100644 --- a/src/libPMacc/include/algorithms/math/defines/trigo.hpp +++ b/src/libPMacc/include/algorithms/math/defines/trigo.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/algorithms/math/doubleMath/abs.tpp b/src/libPMacc/include/algorithms/math/doubleMath/abs.tpp index 9a5fa347f8..73506ff198 100644 --- a/src/libPMacc/include/algorithms/math/doubleMath/abs.tpp +++ b/src/libPMacc/include/algorithms/math/doubleMath/abs.tpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/algorithms/math/doubleMath/erf.tpp b/src/libPMacc/include/algorithms/math/doubleMath/erf.tpp index 7f112b305e..2fe6e7b3d9 100644 --- a/src/libPMacc/include/algorithms/math/doubleMath/erf.tpp +++ b/src/libPMacc/include/algorithms/math/doubleMath/erf.tpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/algorithms/math/doubleMath/exp.tpp b/src/libPMacc/include/algorithms/math/doubleMath/exp.tpp index 2c4ea6524f..f1204f60ce 100644 --- a/src/libPMacc/include/algorithms/math/doubleMath/exp.tpp +++ b/src/libPMacc/include/algorithms/math/doubleMath/exp.tpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/algorithms/math/doubleMath/floatingPoint.tpp b/src/libPMacc/include/algorithms/math/doubleMath/floatingPoint.tpp index 666c19e325..ccbe33e524 100644 --- a/src/libPMacc/include/algorithms/math/doubleMath/floatingPoint.tpp +++ b/src/libPMacc/include/algorithms/math/doubleMath/floatingPoint.tpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/algorithms/math/doubleMath/pow.tpp b/src/libPMacc/include/algorithms/math/doubleMath/pow.tpp index 27d22a2fad..7d966f23ab 100644 --- a/src/libPMacc/include/algorithms/math/doubleMath/pow.tpp +++ b/src/libPMacc/include/algorithms/math/doubleMath/pow.tpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/algorithms/math/doubleMath/sqrt.tpp b/src/libPMacc/include/algorithms/math/doubleMath/sqrt.tpp index ac399506e6..d99172ff41 100644 --- a/src/libPMacc/include/algorithms/math/doubleMath/sqrt.tpp +++ b/src/libPMacc/include/algorithms/math/doubleMath/sqrt.tpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -25,7 +25,6 @@ #include "types.h" - namespace PMacc { namespace algorithms @@ -51,7 +50,11 @@ struct RSqrt HDINLINE double operator( )(const double& value ) { - return ::rsqrt( value ); +#if defined(_MSC_VER) && !defined(__CUDA_ARCH__) + return 1.0/::sqrt(value); +#else + return ::rsqrt(value); +#endif } }; diff --git a/src/libPMacc/include/algorithms/math/doubleMath/trigo.tpp b/src/libPMacc/include/algorithms/math/doubleMath/trigo.tpp index 1f6931a8b8..e8db37bf86 100644 --- a/src/libPMacc/include/algorithms/math/doubleMath/trigo.tpp +++ b/src/libPMacc/include/algorithms/math/doubleMath/trigo.tpp @@ -5,7 +5,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -72,7 +72,12 @@ struct SinCos HDINLINE void operator( )(double arg, double& sinValue, double& cosValue ) { - ::sincos( arg, &sinValue, &cosValue ); +#if defined(_MSC_VER) && !defined(__CUDA_ARCH__) + sinValue = ::sin(arg); + cosValue = ::cos(arg); +#else + ::sincos(arg, &sinValue, &cosValue); +#endif } }; diff --git a/src/libPMacc/include/algorithms/math/floatMath/abs.tpp b/src/libPMacc/include/algorithms/math/floatMath/abs.tpp index 5d211ac336..b9720224e2 100644 --- a/src/libPMacc/include/algorithms/math/floatMath/abs.tpp +++ b/src/libPMacc/include/algorithms/math/floatMath/abs.tpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/algorithms/math/floatMath/erf.tpp b/src/libPMacc/include/algorithms/math/floatMath/erf.tpp index 924c372c27..d4071a1976 100644 --- a/src/libPMacc/include/algorithms/math/floatMath/erf.tpp +++ b/src/libPMacc/include/algorithms/math/floatMath/erf.tpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/algorithms/math/floatMath/exp.tpp b/src/libPMacc/include/algorithms/math/floatMath/exp.tpp index 4bc119cf18..54bdae6740 100644 --- a/src/libPMacc/include/algorithms/math/floatMath/exp.tpp +++ b/src/libPMacc/include/algorithms/math/floatMath/exp.tpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/algorithms/math/floatMath/floatingPoint.tpp b/src/libPMacc/include/algorithms/math/floatMath/floatingPoint.tpp index 9247a23b8b..0510477d9a 100644 --- a/src/libPMacc/include/algorithms/math/floatMath/floatingPoint.tpp +++ b/src/libPMacc/include/algorithms/math/floatMath/floatingPoint.tpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/algorithms/math/floatMath/pow.tpp b/src/libPMacc/include/algorithms/math/floatMath/pow.tpp index 0ac7a56875..b1fae65f46 100644 --- a/src/libPMacc/include/algorithms/math/floatMath/pow.tpp +++ b/src/libPMacc/include/algorithms/math/floatMath/pow.tpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/algorithms/math/floatMath/sqrt.tpp b/src/libPMacc/include/algorithms/math/floatMath/sqrt.tpp index 6be7480c5a..33629590da 100644 --- a/src/libPMacc/include/algorithms/math/floatMath/sqrt.tpp +++ b/src/libPMacc/include/algorithms/math/floatMath/sqrt.tpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -25,7 +25,6 @@ #include "types.h" - namespace PMacc { namespace algorithms @@ -51,7 +50,11 @@ struct RSqrt HDINLINE float operator( )(const float& value ) { - return ::rsqrtf( value ); +#if defined(_MSC_VER) && !defined(__CUDA_ARCH__) + return 1.0f/::sqrtf(value); +#else + return ::rsqrtf(value); +#endif } }; diff --git a/src/libPMacc/include/algorithms/math/floatMath/trigo.tpp b/src/libPMacc/include/algorithms/math/floatMath/trigo.tpp index bf147a502a..84347e64e6 100644 --- a/src/libPMacc/include/algorithms/math/floatMath/trigo.tpp +++ b/src/libPMacc/include/algorithms/math/floatMath/trigo.tpp @@ -5,7 +5,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -73,7 +73,12 @@ struct SinCos HDINLINE void operator( )(float arg, float& sinValue, float& cosValue ) { +#if defined(_MSC_VER) && !defined(__CUDA_ARCH__) + sinValue = ::sinf(arg); + cosValue = ::cosf(arg); +#else ::sincosf( arg, &sinValue, &cosValue ); +#endif } }; diff --git a/src/libPMacc/include/basicOperations.hpp b/src/libPMacc/include/basicOperations.hpp index 6f8c183f99..be0d78339e 100644 --- a/src/libPMacc/include/basicOperations.hpp +++ b/src/libPMacc/include/basicOperations.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -36,14 +36,7 @@ namespace DINLINE void atomicAddWrapper(float* address, float value) { -#if __CUDA_ARCH__ >= 200 // for Fermi, atomicAdd supports floats atomicAdd(address, value); -#else - // float-atomic-add from - // [url="http://forums.nvidia.com/index.php?showtopic=158039&view=findpost&p=991561"]http://forums.nvidia.com/index.php?showtop...st&p=991561[/url] - float old = value; - while ((old = atomicExch(address, atomicExch(address, 0.0f) + old)) != 0.0f); -#endif } DINLINE void atomicAddWrapper(double* inAddress, double value) diff --git a/src/libPMacc/include/communication/CommunicatorMPI.hpp b/src/libPMacc/include/communication/CommunicatorMPI.hpp index f7e5aac06a..521ef99e20 100644 --- a/src/libPMacc/include/communication/CommunicatorMPI.hpp +++ b/src/libPMacc/include/communication/CommunicatorMPI.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013 Axel Huebl, Felix Schmitt, Heiko Burau, Rene Widera, Wolfgang Hoenig + * Copyright 2013-2015 Axel Huebl, Felix Schmitt, Heiko Burau, Rene Widera, + * Wolfgang Hoenig, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,21 +21,20 @@ * If not, see . */ -#ifndef _COMMUNICATORMPI_HPP -#define _COMMUNICATORMPI_HPP +#pragma once + +#include "communication/ICommunicator.hpp" +#include "communication/manager_common.h" +#include "dimensions/DataSpace.hpp" +#include "memory/dataTypes/Mask.hpp" +#include "types.h" #include + #include #include #include -#include "types.h" -#include "memory/dataTypes/Mask.hpp" -#include "dimensions/DataSpace.hpp" - -#include "communication/ICommunicator.hpp" -#include "communication/manager_common.h" - namespace PMacc { @@ -57,9 +57,7 @@ class CommunicatorMPI : public ICommunicator * calls MPI_Finalize */ virtual ~CommunicatorMPI() - { - exit(); - } + {} virtual int getRank() { @@ -71,7 +69,6 @@ class CommunicatorMPI : public ICommunicator return mpiSize; } - MPI_Comm getMPIComm() const { return topology; @@ -89,7 +86,7 @@ class CommunicatorMPI : public ICommunicator * * \warning throws invalid argument if cx*cy*cz != totalnodes */ - void init(DataSpace numberProcesses, DataSpace periodic) throw (std::invalid_argument) + void init(DataSpace numberProcesses, DataSpace periodic) { this->periodic = periodic; @@ -121,12 +118,10 @@ class CommunicatorMPI : public ICommunicator MPI_CHECK(MPI_Cart_create(computing_comm, DIM, dims, periods, 0, &topology)); // 3. update Host rank - hostRank = UpdateHostRank(); + updateHostRank(); //4. update Coordinates updateCoordinates(); - - } /*! returns a rank number (0-n) for each host @@ -164,7 +159,7 @@ class CommunicatorMPI : public ICommunicator MPI_CHECK(MPI_Isend( (void*) send_data, - send_data_count, + static_cast(send_data_count), MPI_CHAR, ExchangeTypeToRank(ex), gridExchangeTag + tag, @@ -183,7 +178,7 @@ class CommunicatorMPI : public ICommunicator MPI_CHECK(MPI_Irecv( recv_data, - recv_data_max, + static_cast(recv_data_max), MPI_CHAR, ExchangeTypeToRank(ex), gridExchangeTag + tag, @@ -225,19 +220,9 @@ class CommunicatorMPI : public ICommunicator protected: - - /*! calls MPI_Finalize - * - */ - void exit() - { - // MPI_CHECK(MPI_Barrier(MPI_COMM_WORLD)); - // MPI_Finalize(); - } - /* Set the first found non charactor or number to 0 (NULL) * name like p1223(Pid=1233) is than p1223 - * in some MPI implementation /mpich) the hostname is uniqu + * in some MPI implementation /mpich) the hostname is unique */ void cleanHostname(char* name) { @@ -263,11 +248,10 @@ class CommunicatorMPI : public ICommunicator * from the master. * */ - int UpdateHostRank() + void updateHostRank() { char hostname[MPI_MAX_PROCESSOR_NAME]; int length; - int hostRank; MPI_CHECK(MPI_Get_processor_name(hostname, &length)); cleanHostname(hostname); @@ -304,8 +288,6 @@ class CommunicatorMPI : public ICommunicator // if(hostRank!=0) hostRank--; //!\todo fix mpi hostrank start with 1 } - return hostRank; - } /*! update coordinates \see getCoordinates @@ -393,8 +375,6 @@ class CommunicatorMPI : public ICommunicator return ranks[type]; } - - private: //! coordinates in GPU-Grid [0:cx-1,0:cy-1,0:cz-1] DataSpace coordinates; @@ -417,8 +397,4 @@ class CommunicatorMPI : public ICommunicator int mpiSize; }; - } //namespace PMacc - -#endif /* _COMMUNICATORMPI_HPP */ - diff --git a/src/libPMacc/include/communication/ICommunicator.hpp b/src/libPMacc/include/communication/ICommunicator.hpp index 347035c834..6820d7c31e 100644 --- a/src/libPMacc/include/communication/ICommunicator.hpp +++ b/src/libPMacc/include/communication/ICommunicator.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Rene Widera, Wolfgang Hoenig + * Copyright 2013, 2015 Rene Widera, Wolfgang Hoenig, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,14 +20,12 @@ * If not, see . */ +#pragma once -#ifndef _ICOMMUNICATOR_HPP -#define _ICOMMUNICATOR_HPP +#include "types.h" #include -#include "types.h" - namespace PMacc { @@ -82,7 +80,3 @@ class ICommunicator }; } //namespace PMacc - - -#endif /* _ICOMMUNICATOR_HPP */ - diff --git a/src/libPMacc/include/communication/manager_common.h b/src/libPMacc/include/communication/manager_common.h index 703c71cf4f..dad3a23e23 100755 --- a/src/libPMacc/include/communication/manager_common.h +++ b/src/libPMacc/include/communication/manager_common.h @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/compileTime/AllCombinations.hpp b/src/libPMacc/include/compileTime/AllCombinations.hpp index 9a68530f17..93b4909a61 100644 --- a/src/libPMacc/include/compileTime/AllCombinations.hpp +++ b/src/libPMacc/include/compileTime/AllCombinations.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2014 Rene Widera + * Copyright 2014-2015 Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -22,22 +22,19 @@ #pragma once -#include "types.h" #include "compileTime/conversion/SeqToMap.hpp" #include "compileTime/conversion/TypeToAliasPair.hpp" #include "compileTime/conversion/TypeToPair.hpp" #include "compileTime/conversion/MakeSeqFromNestedSeq.hpp" #include "compileTime/conversion/MakeSeq.hpp" +#include "math/Vector.hpp" +#include "types.h" + #include #include - -#include #include -#include #include -#include "math/Vector.hpp" - namespace PMacc { namespace bmpl = boost::mpl; diff --git a/src/libPMacc/include/compileTime/GetKeyFromAlias.hpp b/src/libPMacc/include/compileTime/GetKeyFromAlias.hpp index 7a6aca07ab..24edb03be1 100644 --- a/src/libPMacc/include/compileTime/GetKeyFromAlias.hpp +++ b/src/libPMacc/include/compileTime/GetKeyFromAlias.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Rene Widera + * Copyright 2013, 2015 Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -22,22 +22,19 @@ #pragma once -#include "types.h" #include "compileTime/conversion/SeqToMap.hpp" #include "compileTime/conversion/TypeToAliasPair.hpp" #include "compileTime/conversion/TypeToPair.hpp" +#include "static_assert.hpp" +#include "types.h" + #include #include - -#include -#include #include namespace PMacc { - - template diff --git a/src/libPMacc/include/compileTime/accessors/First.hpp b/src/libPMacc/include/compileTime/accessors/First.hpp index 405bf4b68e..2351399f1c 100644 --- a/src/libPMacc/include/compileTime/accessors/First.hpp +++ b/src/libPMacc/include/compileTime/accessors/First.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/compileTime/accessors/Identity.hpp b/src/libPMacc/include/compileTime/accessors/Identity.hpp index 1fa92cbe25..9e72a8d78f 100644 --- a/src/libPMacc/include/compileTime/accessors/Identity.hpp +++ b/src/libPMacc/include/compileTime/accessors/Identity.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/compileTime/accessors/Second.hpp b/src/libPMacc/include/compileTime/accessors/Second.hpp index 540daf99eb..aad5614f69 100644 --- a/src/libPMacc/include/compileTime/accessors/Second.hpp +++ b/src/libPMacc/include/compileTime/accessors/Second.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/compileTime/conversion/JoinToSeq.hpp b/src/libPMacc/include/compileTime/conversion/JoinToSeq.hpp index 0b4983429f..f54220db03 100644 --- a/src/libPMacc/include/compileTime/conversion/JoinToSeq.hpp +++ b/src/libPMacc/include/compileTime/conversion/JoinToSeq.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/compileTime/conversion/MakeSeq.hpp b/src/libPMacc/include/compileTime/conversion/MakeSeq.hpp index 5034cdffe5..da633ade1e 100644 --- a/src/libPMacc/include/compileTime/conversion/MakeSeq.hpp +++ b/src/libPMacc/include/compileTime/conversion/MakeSeq.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/compileTime/conversion/MakeSeqFromNestedSeq.hpp b/src/libPMacc/include/compileTime/conversion/MakeSeqFromNestedSeq.hpp index b4c122545d..c782810d21 100644 --- a/src/libPMacc/include/compileTime/conversion/MakeSeqFromNestedSeq.hpp +++ b/src/libPMacc/include/compileTime/conversion/MakeSeqFromNestedSeq.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/compileTime/conversion/RemoveFromSeq.hpp b/src/libPMacc/include/compileTime/conversion/RemoveFromSeq.hpp index 5d61bcd118..bcff3fd717 100644 --- a/src/libPMacc/include/compileTime/conversion/RemoveFromSeq.hpp +++ b/src/libPMacc/include/compileTime/conversion/RemoveFromSeq.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/compileTime/conversion/ResolveAliases.hpp b/src/libPMacc/include/compileTime/conversion/ResolveAliases.hpp index 5100ffdf32..8b165f153b 100644 --- a/src/libPMacc/include/compileTime/conversion/ResolveAliases.hpp +++ b/src/libPMacc/include/compileTime/conversion/ResolveAliases.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/compileTime/conversion/ResolveAndRemoveFromSeq.hpp b/src/libPMacc/include/compileTime/conversion/ResolveAndRemoveFromSeq.hpp index e5a30ff0a6..4c3097a26d 100644 --- a/src/libPMacc/include/compileTime/conversion/ResolveAndRemoveFromSeq.hpp +++ b/src/libPMacc/include/compileTime/conversion/ResolveAndRemoveFromSeq.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/compileTime/conversion/SeqToMap.hpp b/src/libPMacc/include/compileTime/conversion/SeqToMap.hpp index 48dc243f0b..783a45edca 100644 --- a/src/libPMacc/include/compileTime/conversion/SeqToMap.hpp +++ b/src/libPMacc/include/compileTime/conversion/SeqToMap.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/compileTime/conversion/ToSeq.hpp b/src/libPMacc/include/compileTime/conversion/ToSeq.hpp index 2fb64761c1..54742a94b4 100644 --- a/src/libPMacc/include/compileTime/conversion/ToSeq.hpp +++ b/src/libPMacc/include/compileTime/conversion/ToSeq.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/compileTime/conversion/TypeToAliasPair.hpp b/src/libPMacc/include/compileTime/conversion/TypeToAliasPair.hpp index dd122b00a5..353caa976e 100644 --- a/src/libPMacc/include/compileTime/conversion/TypeToAliasPair.hpp +++ b/src/libPMacc/include/compileTime/conversion/TypeToAliasPair.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/compileTime/conversion/TypeToPair.hpp b/src/libPMacc/include/compileTime/conversion/TypeToPair.hpp index 45db41c720..e184bcea69 100644 --- a/src/libPMacc/include/compileTime/conversion/TypeToPair.hpp +++ b/src/libPMacc/include/compileTime/conversion/TypeToPair.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/algorithm/cudaBlock/Foreach.hpp b/src/libPMacc/include/cuSTL/algorithm/cudaBlock/Foreach.hpp index 5c24ebd7eb..c369153916 100644 --- a/src/libPMacc/include/cuSTL/algorithm/cudaBlock/Foreach.hpp +++ b/src/libPMacc/include/cuSTL/algorithm/cudaBlock/Foreach.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/algorithm/host/Foreach.hpp b/src/libPMacc/include/cuSTL/algorithm/host/Foreach.hpp index 148e88c8dc..7d85de8963 100644 --- a/src/libPMacc/include/cuSTL/algorithm/host/Foreach.hpp +++ b/src/libPMacc/include/cuSTL/algorithm/host/Foreach.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/algorithm/kernel/FFT.hpp b/src/libPMacc/include/cuSTL/algorithm/kernel/FFT.hpp index 319b572c3a..b64112c0c3 100644 --- a/src/libPMacc/include/cuSTL/algorithm/kernel/FFT.hpp +++ b/src/libPMacc/include/cuSTL/algorithm/kernel/FFT.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/algorithm/kernel/FFT.tpp b/src/libPMacc/include/cuSTL/algorithm/kernel/FFT.tpp index 79fb4f1fce..e7265cf4eb 100644 --- a/src/libPMacc/include/cuSTL/algorithm/kernel/FFT.tpp +++ b/src/libPMacc/include/cuSTL/algorithm/kernel/FFT.tpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/algorithm/kernel/Foreach.hpp b/src/libPMacc/include/cuSTL/algorithm/kernel/Foreach.hpp index 1d41615bc2..ac282aafa4 100644 --- a/src/libPMacc/include/cuSTL/algorithm/kernel/Foreach.hpp +++ b/src/libPMacc/include/cuSTL/algorithm/kernel/Foreach.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/algorithm/kernel/ForeachBlock.hpp b/src/libPMacc/include/cuSTL/algorithm/kernel/ForeachBlock.hpp index c6ce7c752e..1b5bbdcfbf 100644 --- a/src/libPMacc/include/cuSTL/algorithm/kernel/ForeachBlock.hpp +++ b/src/libPMacc/include/cuSTL/algorithm/kernel/ForeachBlock.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/algorithm/kernel/Reduce.hpp b/src/libPMacc/include/cuSTL/algorithm/kernel/Reduce.hpp index 4665dd4759..d2ee36af5b 100644 --- a/src/libPMacc/include/cuSTL/algorithm/kernel/Reduce.hpp +++ b/src/libPMacc/include/cuSTL/algorithm/kernel/Reduce.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/algorithm/kernel/Reduce.tpp b/src/libPMacc/include/cuSTL/algorithm/kernel/Reduce.tpp index 78409a3aaa..9542e0bc60 100644 --- a/src/libPMacc/include/cuSTL/algorithm/kernel/Reduce.tpp +++ b/src/libPMacc/include/cuSTL/algorithm/kernel/Reduce.tpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -135,7 +135,7 @@ void Reduce::operator()(const DestCursor& destCursor, const Zone& p_zo while(partialSumSize > 1) { int numBlocks = ceil((float)partialSumSize / 512.0f); - zone::SphericZone<1> p_zone1D = zone::SphericZone<1>(math::Size_t<1>(numBlocks*512)); + zone::SphericZone<1> p_zone1D = zone::SphericZone<1>(math::Size_t<1>((size_t)(numBlocks*512))); curDestBuffer ^= 1; if(numBlocks == 1) { diff --git a/src/libPMacc/include/cuSTL/algorithm/kernel/detail/ForeachKernel.hpp b/src/libPMacc/include/cuSTL/algorithm/kernel/detail/ForeachKernel.hpp index 24413461b6..deea10bd50 100644 --- a/src/libPMacc/include/cuSTL/algorithm/kernel/detail/ForeachKernel.hpp +++ b/src/libPMacc/include/cuSTL/algorithm/kernel/detail/ForeachKernel.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/algorithm/kernel/detail/SphericMapper.hpp b/src/libPMacc/include/cuSTL/algorithm/kernel/detail/SphericMapper.hpp index 02d9f5b5d7..4e0ad900bb 100644 --- a/src/libPMacc/include/cuSTL/algorithm/kernel/detail/SphericMapper.hpp +++ b/src/libPMacc/include/cuSTL/algorithm/kernel/detail/SphericMapper.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013-2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,11 +20,11 @@ * If not, see . */ -#ifndef ALGORITHM_KERNEL_DETAIL_SPHERICMAPPER_HPP -#define ALGORITHM_KERNEL_DETAIL_SPHERICMAPPER_HPP +#pragma once -#include "types.h" #include "math/vector/Size_t.hpp" +#include "types.h" + #include namespace PMacc @@ -70,8 +70,8 @@ struct SphericMapper<1, BlockSize> HDINLINE math::Int<1> operator()(const dim3& _blockIdx, const dim3& _threadIdx = dim3(0,0,0)) const { - return operator()(math::Int<1>(_blockIdx.x), - math::Int<1>(_threadIdx.x)); + return operator()(math::Int<1>((int)_blockIdx.x), + math::Int<1>((int)_threadIdx.x)); } }; @@ -151,8 +151,8 @@ struct SphericMapper<1, mpl::void_> DINLINE math::Int<1> operator()(const dim3& _blockIdx, const dim3& _threadIdx = dim3(0,0,0)) const { - return operator()(math::Int<1>(_blockIdx.x), - math::Int<1>(_threadIdx.x)); + return operator()(math::Int<1>((int)_blockIdx.x), + math::Int<1>((int)_threadIdx.x)); } }; @@ -216,5 +216,3 @@ struct SphericMapper<3, mpl::void_> } // kernel } // algorithm } // PMacc - -#endif // ALGORITHM_KERNEL_DETAIL_SPHERICMAPPER_HPP diff --git a/src/libPMacc/include/cuSTL/algorithm/kernel/run-time/Foreach.hpp b/src/libPMacc/include/cuSTL/algorithm/kernel/run-time/Foreach.hpp index 624bc7814a..8b95715c30 100644 --- a/src/libPMacc/include/cuSTL/algorithm/kernel/run-time/Foreach.hpp +++ b/src/libPMacc/include/cuSTL/algorithm/kernel/run-time/Foreach.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/algorithm/mpi/Gather.hpp b/src/libPMacc/include/cuSTL/algorithm/mpi/Gather.hpp index 8ee1825517..677ca9bca9 100644 --- a/src/libPMacc/include/cuSTL/algorithm/mpi/Gather.hpp +++ b/src/libPMacc/include/cuSTL/algorithm/mpi/Gather.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau + * Copyright 2013, 2015 Heiko Burau * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,8 +20,7 @@ * If not, see . */ -#ifndef ALGORITHM_MPI_GATHER_HPP -#define ALGORITHM_MPI_GATHER_HPP +#pragma once #include "mpi.h" #include "math/vector/Int.hpp" @@ -46,19 +45,16 @@ class Gather std::vector > positions; bool m_participate; - template - struct CopyToDest; - - template - struct CopyToDest + template + struct CopyToDest { void operator()(const Gather& gather, - container::HostBuffer& dest, + container::HostBuffer& dest, std::vector& tmpDest, - container::HostBuffer& source, int dir) const; + container::HostBuffer& source, int dir) const; }; - template + template friend class CopyToDest; public: Gather(const zone::SphericZone& p_zone); @@ -79,5 +75,3 @@ class Gather } // PMacc #include "Gather.tpp" - -#endif // ALGORITHM_MPI_GATHER_HPP diff --git a/src/libPMacc/include/cuSTL/algorithm/mpi/Gather.tpp b/src/libPMacc/include/cuSTL/algorithm/mpi/Gather.tpp index 9c014df0c9..cef35600b3 100644 --- a/src/libPMacc/include/cuSTL/algorithm/mpi/Gather.tpp +++ b/src/libPMacc/include/cuSTL/algorithm/mpi/Gather.tpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau + * Copyright 2013, 2015 Heiko Burau, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -21,10 +21,11 @@ */ #include "mappings/simulation/GridController.hpp" -#include #include "cuSTL/container/copier/Memcopy.hpp" #include "communication/manager_common.h" +#include + namespace PMacc { namespace algorithm @@ -32,6 +33,47 @@ namespace algorithm namespace mpi { +namespace GatherHelper +{ + +/** @tparam dim dimension of mpi cluster + * @tparam memDim dimension of memory to be gathered + * + * if memDim == dim - 1 then ``dir`` indicates the direction (orientation) + * of the (meta)plane. + */ +template +struct posInMem; + +template +struct posInMem +{ + math::Int operator()(const math::Int& pos, int) const + { + return pos; + } +}; + +template<> +struct posInMem +{ + math::Int operator()(const math::Int& pos, int dir) const + { + return math::Int(pos[(dir+1)%3], pos[(dir+2)%3]); + } +}; + +template<> +struct posInMem +{ + math::Int operator()(const math::Int& pos, int dir) const + { + return math::Int(pos[(dir+1)%2]); + } +}; + +} + template Gather::Gather(const zone::SphericZone& p_zone) : comm(MPI_COMM_NULL) { @@ -102,29 +144,29 @@ int Gather::rank() const } template -template -void Gather::CopyToDest::operator()( +template +void Gather::CopyToDest::operator()( const Gather& gather, - container::HostBuffer& dest, + container::HostBuffer& dest, std::vector& tmpDest, - container::HostBuffer& source, int dir) const + container::HostBuffer& source, int dir) const { using namespace math; for(int i = 0; i < (int)gather.positions.size(); i++) { - Int<3> pos = gather.positions[i]; - Int<2> pos2D(pos[(dir+1)%3], pos[(dir+2)%3]); + Int pos = gather.positions[i]; + Int posInMem = GatherHelper::posInMem()(pos, dir); - cudaWrapper::Memcopy<2>()(&(*dest.origin()(pos2D * (Int<2>)source.size())), dest.getPitch(), + cudaWrapper::Memcopy()(&(*dest.origin()(posInMem * (Int)source.size())), dest.getPitch(), tmpDest.data() + i * source.size().productOfComponents(), source.getPitch(), source.size(), cudaWrapper::flags::Memcopy::hostToHost); } } -template<> +template template -void Gather<3>::operator()(container::HostBuffer& dest, +void Gather::operator()(container::HostBuffer& dest, container::HostBuffer& source, int dir) const { if(!this->m_participate) return; @@ -137,7 +179,7 @@ void Gather<3>::operator()(container::HostBuffer& dest, 0, this->comm)); if(!root()) return; - CopyToDest()(*this, dest, tmpDest, source, dir); + CopyToDest()(*this, dest, tmpDest, source, dir); } } // mpi diff --git a/src/libPMacc/include/cuSTL/algorithm/mpi/Reduce.hpp b/src/libPMacc/include/cuSTL/algorithm/mpi/Reduce.hpp index 43e1f3dbcb..df3d64e39d 100644 --- a/src/libPMacc/include/cuSTL/algorithm/mpi/Reduce.hpp +++ b/src/libPMacc/include/cuSTL/algorithm/mpi/Reduce.hpp @@ -6,7 +6,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/algorithm/mpi/Reduce.tpp b/src/libPMacc/include/cuSTL/algorithm/mpi/Reduce.tpp index a7fb32913b..7ac95a19f9 100644 --- a/src/libPMacc/include/cuSTL/algorithm/mpi/Reduce.tpp +++ b/src/libPMacc/include/cuSTL/algorithm/mpi/Reduce.tpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/container/CartBuffer.hpp b/src/libPMacc/include/cuSTL/container/CartBuffer.hpp index 3c5a426441..5e96105bc3 100644 --- a/src/libPMacc/include/cuSTL/container/CartBuffer.hpp +++ b/src/libPMacc/include/cuSTL/container/CartBuffer.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013-2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,22 +20,23 @@ * If not, see . */ -#ifndef CONTAINER_CARTBUFFER_HPP -#define CONTAINER_CARTBUFFER_HPP +#pragma once -#include -#include "types.h" -#include "math/vector/Size_t.hpp" -#include "math/vector/UInt32.hpp" +#include "allocator/EmptyAllocator.hpp" #include "cuSTL/cursor/BufferCursor.hpp" #include "cuSTL/cursor/navigator/CartNavigator.hpp" #include "cuSTL/cursor/accessor/PointerAccessor.hpp" #include "cuSTL/cursor/SafeCursor.hpp" #include "cuSTL/zone/SphericZone.hpp" -#include "allocator/EmptyAllocator.hpp" +#include "cuSTL/container/view/View.hpp" +#include "math/vector/Size_t.hpp" +#include "math/vector/UInt32.hpp" +#include "types.h" + #include #include -#include "cuSTL/container/view/View.hpp" + +#include namespace PMacc { @@ -71,7 +72,7 @@ class CartBuffer math::Size_t pitch; HDINLINE void init(); HDINLINE void exit(); - HDINLINE CartBuffer() {} + HDINLINE CartBuffer() : refCount(NULL) {} private: /* makes this class able to emulate a r-value reference */ BOOST_COPYABLE_AND_MOVABLE(This) @@ -129,5 +130,3 @@ class CartBuffer } // PMacc #include "CartBuffer.tpp" - -#endif // CONTAINER_CARTBUFFER_HPP diff --git a/src/libPMacc/include/cuSTL/container/CartBuffer.tpp b/src/libPMacc/include/cuSTL/container/CartBuffer.tpp index 2a07cf9011..5bbf82bb28 100644 --- a/src/libPMacc/include/cuSTL/container/CartBuffer.tpp +++ b/src/libPMacc/include/cuSTL/container/CartBuffer.tpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013-2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -21,8 +21,9 @@ */ #include "cuSTL/container/allocator/tag.h" +#include "eventSystem/EventSystem.hpp" + #include -#include namespace PMacc { @@ -31,7 +32,9 @@ namespace container namespace detail { - template struct PitchHelper; + template + struct PitchHelper; + template<> struct PitchHelper<1> { @@ -44,7 +47,7 @@ namespace detail template HDINLINE math::Size_t<1> operator()(const TCursor& cursor) { - return math::Size_t<1>((char*)cursor(0, 1).getMarker() - (char*)cursor.getMarker()); + return math::Size_t<1>(size_t((char*)cursor(0, 1).getMarker() - (char*)cursor.getMarker())); } }; template<> @@ -53,8 +56,8 @@ namespace detail template HDINLINE math::Size_t<2> operator()(const TCursor& cursor) { - return math::Size_t<2>((char*)cursor(0, 1, 0).getMarker() - (char*)cursor.getMarker(), - (char*)cursor(0, 0, 1).getMarker() - (char*)cursor.getMarker()); + return math::Size_t<2>((size_t)((char*)cursor(0, 1, 0).getMarker() - (char*)cursor.getMarker()), + (size_t)((char*)cursor(0, 0, 1).getMarker() - (char*)cursor.getMarker())); } }; @@ -82,7 +85,7 @@ namespace detail template CartBuffer::CartBuffer -(const math::Size_t& _size) +(const math::Size_t& _size) : refCount(NULL) { this->_size = _size; init(); @@ -90,28 +93,28 @@ CartBuffer::CartBuffer template CartBuffer::CartBuffer -(size_t x) +(size_t x) : refCount(NULL) { this->_size = math::Size_t<1>(x); init(); } template CartBuffer::CartBuffer -(size_t x, size_t y) +(size_t x, size_t y) : refCount(NULL) { this->_size = math::Size_t<2>(x, y); init(); } template CartBuffer::CartBuffer -(size_t x, size_t y, size_t z) +(size_t x, size_t y, size_t z) : refCount(NULL) { this->_size = math::Size_t<3>(x, y, z); init(); } template CartBuffer::CartBuffer -(const CartBuffer& other) +(const CartBuffer& other) : refCount(NULL) { this->dataPointer = other.dataPointer; this->refCount = other.refCount; @@ -124,7 +127,7 @@ CartBuffer::CartBuffer template CartBuffer::CartBuffer -(BOOST_RV_REF(CartBuffer) other) +(BOOST_RV_REF(CartBuffer) other) : refCount(NULL) { this->dataPointer = 0; this->refCount = 0; @@ -199,7 +202,7 @@ CartBuffer::view { a = (a + (math::Int)this->size()) % (math::Int)this->size(); b = (b + (math::Int)this->size()) - % ((math::Int)this->size() + math::Int(1)); + % ((math::Int)this->size() + math::Int::create(1)); View > result; @@ -228,7 +231,7 @@ cursor::SafeCursor > CartBuffer::originSafe() const { return cursor::make_SafeCursor(this->origin(), - math::Int(0), + math::Int::create(0), math::Int(size())); } @@ -257,7 +260,7 @@ zone::SphericZone CartBuffer::zone() const { zone::SphericZone myZone; - myZone.offset = math::Int(0); + myZone.offset = math::Int::create(0); myZone.size = this->_size; return myZone; } diff --git a/src/libPMacc/include/cuSTL/container/DeviceBuffer.hpp b/src/libPMacc/include/cuSTL/container/DeviceBuffer.hpp index 64ea97cec5..2138130da3 100644 --- a/src/libPMacc/include/cuSTL/container/DeviceBuffer.hpp +++ b/src/libPMacc/include/cuSTL/container/DeviceBuffer.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013-2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,8 +20,7 @@ * If not, see . */ -#ifndef CONTAINER_DEVICEBUFFER_HPP -#define CONTAINER_DEVICEBUFFER_HPP +#pragma once #include #include @@ -93,5 +92,3 @@ class DeviceBuffer } // container } // PMacc - -#endif // CONTAINER_DEVICEBUFFER_HPP diff --git a/src/libPMacc/include/cuSTL/container/HostBuffer.hpp b/src/libPMacc/include/cuSTL/container/HostBuffer.hpp index b544030ede..a236fcd376 100644 --- a/src/libPMacc/include/cuSTL/container/HostBuffer.hpp +++ b/src/libPMacc/include/cuSTL/container/HostBuffer.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/container/IndexBuffer.hpp b/src/libPMacc/include/cuSTL/container/IndexBuffer.hpp index b3038edad8..6d9a5de5f7 100644 --- a/src/libPMacc/include/cuSTL/container/IndexBuffer.hpp +++ b/src/libPMacc/include/cuSTL/container/IndexBuffer.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/container/PNGBuffer.hpp b/src/libPMacc/include/cuSTL/container/PNGBuffer.hpp index 268e211f6b..1e6e32f735 100644 --- a/src/libPMacc/include/cuSTL/container/PNGBuffer.hpp +++ b/src/libPMacc/include/cuSTL/container/PNGBuffer.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/container/PseudoBuffer.hpp b/src/libPMacc/include/cuSTL/container/PseudoBuffer.hpp index 502c5ea68c..6717160963 100644 --- a/src/libPMacc/include/cuSTL/container/PseudoBuffer.hpp +++ b/src/libPMacc/include/cuSTL/container/PseudoBuffer.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/container/PseudoBuffer.tpp b/src/libPMacc/include/cuSTL/container/PseudoBuffer.tpp index 16b605126d..a9f57dd89a 100644 --- a/src/libPMacc/include/cuSTL/container/PseudoBuffer.tpp +++ b/src/libPMacc/include/cuSTL/container/PseudoBuffer.tpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/container/allocator/DeviceMemAllocator.hpp b/src/libPMacc/include/cuSTL/container/allocator/DeviceMemAllocator.hpp index b877c9101a..e8ca6524b8 100644 --- a/src/libPMacc/include/cuSTL/container/allocator/DeviceMemAllocator.hpp +++ b/src/libPMacc/include/cuSTL/container/allocator/DeviceMemAllocator.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/container/allocator/DeviceMemAllocator.tpp b/src/libPMacc/include/cuSTL/container/allocator/DeviceMemAllocator.tpp index f25dba8a5a..a25d16a570 100644 --- a/src/libPMacc/include/cuSTL/container/allocator/DeviceMemAllocator.tpp +++ b/src/libPMacc/include/cuSTL/container/allocator/DeviceMemAllocator.tpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/container/allocator/DeviceMemEvenPitchAllocator.hpp b/src/libPMacc/include/cuSTL/container/allocator/DeviceMemEvenPitchAllocator.hpp index 6367725ef5..d31ed820f6 100644 --- a/src/libPMacc/include/cuSTL/container/allocator/DeviceMemEvenPitchAllocator.hpp +++ b/src/libPMacc/include/cuSTL/container/allocator/DeviceMemEvenPitchAllocator.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/container/allocator/DeviceMemEvenPitchAllocator.tpp b/src/libPMacc/include/cuSTL/container/allocator/DeviceMemEvenPitchAllocator.tpp index d4dced75fa..c0c0212b64 100644 --- a/src/libPMacc/include/cuSTL/container/allocator/DeviceMemEvenPitchAllocator.tpp +++ b/src/libPMacc/include/cuSTL/container/allocator/DeviceMemEvenPitchAllocator.tpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/container/allocator/EmptyAllocator.hpp b/src/libPMacc/include/cuSTL/container/allocator/EmptyAllocator.hpp index 147b795c9a..e14df6601d 100644 --- a/src/libPMacc/include/cuSTL/container/allocator/EmptyAllocator.hpp +++ b/src/libPMacc/include/cuSTL/container/allocator/EmptyAllocator.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/container/allocator/HostMemAllocator.hpp b/src/libPMacc/include/cuSTL/container/allocator/HostMemAllocator.hpp index 654053bcfd..e7c7db8dab 100644 --- a/src/libPMacc/include/cuSTL/container/allocator/HostMemAllocator.hpp +++ b/src/libPMacc/include/cuSTL/container/allocator/HostMemAllocator.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/container/allocator/HostMemAllocator.tpp b/src/libPMacc/include/cuSTL/container/allocator/HostMemAllocator.tpp index 7eb17c7d4f..9d7e696cf2 100644 --- a/src/libPMacc/include/cuSTL/container/allocator/HostMemAllocator.tpp +++ b/src/libPMacc/include/cuSTL/container/allocator/HostMemAllocator.tpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/container/allocator/compile-time/SharedMemAllocator.hpp b/src/libPMacc/include/cuSTL/container/allocator/compile-time/SharedMemAllocator.hpp index 1ced1ac7f0..2e1648a3f7 100644 --- a/src/libPMacc/include/cuSTL/container/allocator/compile-time/SharedMemAllocator.hpp +++ b/src/libPMacc/include/cuSTL/container/allocator/compile-time/SharedMemAllocator.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/container/allocator/tag.h b/src/libPMacc/include/cuSTL/container/allocator/tag.h index 0197a4b367..6c3dfb69c3 100644 --- a/src/libPMacc/include/cuSTL/container/allocator/tag.h +++ b/src/libPMacc/include/cuSTL/container/allocator/tag.h @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/container/assigner/DeviceMemAssigner.hpp b/src/libPMacc/include/cuSTL/container/assigner/DeviceMemAssigner.hpp index 09053e8dae..7ee22067cd 100644 --- a/src/libPMacc/include/cuSTL/container/assigner/DeviceMemAssigner.hpp +++ b/src/libPMacc/include/cuSTL/container/assigner/DeviceMemAssigner.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013-2014 Heiko Burau, Rene Widera + * Copyright 2013-2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,61 +20,57 @@ * If not, see . */ -#ifndef ASSIGNER_DEVICEMEMASSIGNER_HPP -#define ASSIGNER_DEVICEMEMASSIGNER_HPP +#pragma once -#include #include "cuSTL/cursor/BufferCursor.hpp" #include "cuSTL/zone/SphericZone.hpp" -#include "math/vector/Size_t.hpp" #include "cuSTL/algorithm/kernel/run-time/Foreach.hpp" #include "lambda/Expression.hpp" -#include "math/Vector.hpp" -#include -#include +#include "math/vector/Size_t.hpp" #include "types.h" + #include + #include +#include namespace PMacc { namespace assigner { -namespace mpl = boost::mpl; - template struct DeviceMemAssigner { static const int dim = T_dim; + template - static void assign(Type* data, const math::Size_t& pitch, const Type& value, - const math::Size_t& size) + static void assign( + Type* data, + const math::Size_t& pitch, + const Type& value, + const math::Size_t& size) { - - using namespace math; - cursor::BufferCursor cursor(data, pitch); zone::SphericZone myZone(size); + cursor::BufferCursor cursor(data, pitch); /* The greatest common divisor of each component of the volume size - * and a certain power of two value gives the best suitable block size - */ + * and a certain power of two value gives the best suitable block size */ boost::math::gcd_evaluator gcd; // greatest common divisor - math::Size_t<3> blockDim(1); + math::Size_t<3> blockDim(math::Size_t<3>::create(1)); int maxValues[] = {16, 16, 4}; // maximum values for each dimension for(int i = 0; i < dim; i++) + { blockDim[i] = gcd(size[i], maxValues[dim-1]); + } /* the maximum number of threads per block for devices with * compute capability > 2.0 is 1024 */ - assert(blockDim.productOfComponents()<=1024); + assert(blockDim.productOfComponents() <= 1024); - using namespace lambda; algorithm::kernel::RT::Foreach foreach(blockDim); - foreach(myZone, cursor, _1 = value); + foreach(myZone, cursor, lambda::_1 = value); } }; } // assigner } // PMacc - -#endif // ASSIGNER_DEVICEMEMASSIGNER_HPP diff --git a/src/libPMacc/include/cuSTL/container/assigner/HostMemAssigner.hpp b/src/libPMacc/include/cuSTL/container/assigner/HostMemAssigner.hpp index 5edb852b9f..24c50e4b30 100644 --- a/src/libPMacc/include/cuSTL/container/assigner/HostMemAssigner.hpp +++ b/src/libPMacc/include/cuSTL/container/assigner/HostMemAssigner.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/container/compile-time/CartBuffer.hpp b/src/libPMacc/include/cuSTL/container/compile-time/CartBuffer.hpp index abaff0d5d2..b9217cd310 100644 --- a/src/libPMacc/include/cuSTL/container/compile-time/CartBuffer.hpp +++ b/src/libPMacc/include/cuSTL/container/compile-time/CartBuffer.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/container/compile-time/CartBuffer.tpp b/src/libPMacc/include/cuSTL/container/compile-time/CartBuffer.tpp index 6e4a884aa6..64bab83efc 100644 --- a/src/libPMacc/include/cuSTL/container/compile-time/CartBuffer.tpp +++ b/src/libPMacc/include/cuSTL/container/compile-time/CartBuffer.tpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/container/compile-time/SharedBuffer.hpp b/src/libPMacc/include/cuSTL/container/compile-time/SharedBuffer.hpp index 9193430bdf..dffa164729 100644 --- a/src/libPMacc/include/cuSTL/container/compile-time/SharedBuffer.hpp +++ b/src/libPMacc/include/cuSTL/container/compile-time/SharedBuffer.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013, 2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,8 +20,7 @@ * If not, see . */ -#ifndef CONTAINER_CT_SHAREDBUFFER_HPP -#define CONTAINER_CT_SHAREDBUFFER_HPP +#pragma once #include "CartBuffer.hpp" #include "../allocator/compile-time/SharedMemAllocator.hpp" @@ -46,5 +45,3 @@ struct SharedBuffer } // CT } // container } // PMacc - -#endif // CONTAINER_CT_SHAREDBUFFER_HPP diff --git a/src/libPMacc/include/cuSTL/container/copier/D2DCopier.hpp b/src/libPMacc/include/cuSTL/container/copier/D2DCopier.hpp index 023ba05932..7b62b00c65 100644 --- a/src/libPMacc/include/cuSTL/container/copier/D2DCopier.hpp +++ b/src/libPMacc/include/cuSTL/container/copier/D2DCopier.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013, 2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,8 +20,7 @@ * If not, see . */ -#ifndef COPIER_D2DCOPIER_HPP -#define COPIER_D2DCOPIER_HPP +#pragma once #include "Memcopy.hpp" #include @@ -47,5 +46,3 @@ struct D2DCopier } // copier } // PMacc - -#endif // COPIER_D2DCOPIER_HPP diff --git a/src/libPMacc/include/cuSTL/container/copier/H2HCopier.hpp b/src/libPMacc/include/cuSTL/container/copier/H2HCopier.hpp index 75eca70cda..6a93942ba7 100644 --- a/src/libPMacc/include/cuSTL/container/copier/H2HCopier.hpp +++ b/src/libPMacc/include/cuSTL/container/copier/H2HCopier.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013, 2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,8 +20,7 @@ * If not, see . */ -#ifndef COPIER_H2HCOPIER_HPP -#define COPIER_H2HCOPIER_HPP +#pragma once #include "Memcopy.hpp" #include @@ -47,5 +46,3 @@ struct H2HCopier } // copier } // PMacc - -#endif // COPIER_H2HCOPIER_HPP diff --git a/src/libPMacc/include/cuSTL/container/copier/Memcopy.hpp b/src/libPMacc/include/cuSTL/container/copier/Memcopy.hpp index 67ca199315..fad788d043 100644 --- a/src/libPMacc/include/cuSTL/container/copier/Memcopy.hpp +++ b/src/libPMacc/include/cuSTL/container/copier/Memcopy.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013, 2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,8 +20,7 @@ * If not, see . */ -#ifndef CUDAWRAPPERMEMCOPY_HPP -#define CUDAWRAPPERMEMCOPY_HPP +#pragma once #include "math/vector/Size_t.hpp" #include @@ -105,5 +104,3 @@ struct Memcopy<3> } // cudaWrapper } // PMacc - -#endif //CUDAWRAPPERMEMCOPY_HPP diff --git a/src/libPMacc/include/cuSTL/container/tag.h b/src/libPMacc/include/cuSTL/container/tag.h index e10f69da9a..ea3de0be68 100644 --- a/src/libPMacc/include/cuSTL/container/tag.h +++ b/src/libPMacc/include/cuSTL/container/tag.h @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/container/view/View.hpp b/src/libPMacc/include/cuSTL/container/view/View.hpp index 20f02be14e..7087279e98 100644 --- a/src/libPMacc/include/cuSTL/container/view/View.hpp +++ b/src/libPMacc/include/cuSTL/container/view/View.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/cursor/BufferCursor.hpp b/src/libPMacc/include/cuSTL/cursor/BufferCursor.hpp index 51ed9a6f93..87260b2913 100644 --- a/src/libPMacc/include/cuSTL/cursor/BufferCursor.hpp +++ b/src/libPMacc/include/cuSTL/cursor/BufferCursor.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/cursor/Cursor.hpp b/src/libPMacc/include/cuSTL/cursor/Cursor.hpp index 429c4061be..71560ec598 100644 --- a/src/libPMacc/include/cuSTL/cursor/Cursor.hpp +++ b/src/libPMacc/include/cuSTL/cursor/Cursor.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/cursor/FunctorCursor.hpp b/src/libPMacc/include/cuSTL/cursor/FunctorCursor.hpp index 22d93af087..db1ed353a0 100644 --- a/src/libPMacc/include/cuSTL/cursor/FunctorCursor.hpp +++ b/src/libPMacc/include/cuSTL/cursor/FunctorCursor.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/cursor/MultiIndexCursor.hpp b/src/libPMacc/include/cuSTL/cursor/MultiIndexCursor.hpp index eabca08a03..00707c6619 100644 --- a/src/libPMacc/include/cuSTL/cursor/MultiIndexCursor.hpp +++ b/src/libPMacc/include/cuSTL/cursor/MultiIndexCursor.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -43,7 +43,7 @@ template HDINLINE cursor::Cursor >, MultiIndexNavigator, math::Int > - make_MultiIndexCursor(const math::Int& idx = math::Int(0)) + make_MultiIndexCursor(const math::Int& idx = math::Int::create(0)) { return make_Cursor(cursor::MarkerAccessor >(), MultiIndexNavigator(), diff --git a/src/libPMacc/include/cuSTL/cursor/NestedCursor.hpp b/src/libPMacc/include/cuSTL/cursor/NestedCursor.hpp index 290caca6e2..d3e50d6b26 100644 --- a/src/libPMacc/include/cuSTL/cursor/NestedCursor.hpp +++ b/src/libPMacc/include/cuSTL/cursor/NestedCursor.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/cursor/SafeCursor.hpp b/src/libPMacc/include/cuSTL/cursor/SafeCursor.hpp index 4edba2c2aa..f11fe607d4 100644 --- a/src/libPMacc/include/cuSTL/cursor/SafeCursor.hpp +++ b/src/libPMacc/include/cuSTL/cursor/SafeCursor.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/cursor/accessor/CursorAccessor.hpp b/src/libPMacc/include/cuSTL/cursor/accessor/CursorAccessor.hpp index 6542fcb788..b9efecb658 100644 --- a/src/libPMacc/include/cuSTL/cursor/accessor/CursorAccessor.hpp +++ b/src/libPMacc/include/cuSTL/cursor/accessor/CursorAccessor.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/cursor/accessor/FunctorAccessor.hpp b/src/libPMacc/include/cuSTL/cursor/accessor/FunctorAccessor.hpp index 4f4969703c..77b2bddffe 100644 --- a/src/libPMacc/include/cuSTL/cursor/accessor/FunctorAccessor.hpp +++ b/src/libPMacc/include/cuSTL/cursor/accessor/FunctorAccessor.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/cursor/accessor/MarkerAccessor.hpp b/src/libPMacc/include/cuSTL/cursor/accessor/MarkerAccessor.hpp index 7934d23903..7a24c76f87 100644 --- a/src/libPMacc/include/cuSTL/cursor/accessor/MarkerAccessor.hpp +++ b/src/libPMacc/include/cuSTL/cursor/accessor/MarkerAccessor.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/cursor/accessor/PointerAccessor.hpp b/src/libPMacc/include/cuSTL/cursor/accessor/PointerAccessor.hpp index f7a6595b85..eec5470356 100644 --- a/src/libPMacc/include/cuSTL/cursor/accessor/PointerAccessor.hpp +++ b/src/libPMacc/include/cuSTL/cursor/accessor/PointerAccessor.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/cursor/accessor/TwistAxesAccessor.hpp b/src/libPMacc/include/cuSTL/cursor/accessor/TwistAxesAccessor.hpp index 7b18bd100c..ee659a2a22 100644 --- a/src/libPMacc/include/cuSTL/cursor/accessor/TwistAxesAccessor.hpp +++ b/src/libPMacc/include/cuSTL/cursor/accessor/TwistAxesAccessor.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/cursor/compile-time/BufferCursor.hpp b/src/libPMacc/include/cuSTL/cursor/compile-time/BufferCursor.hpp index 950e9c03e7..deda85d8e0 100644 --- a/src/libPMacc/include/cuSTL/cursor/compile-time/BufferCursor.hpp +++ b/src/libPMacc/include/cuSTL/cursor/compile-time/BufferCursor.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/cursor/compile-time/SafeCursor.hpp b/src/libPMacc/include/cuSTL/cursor/compile-time/SafeCursor.hpp index 89a621ab25..647542e3e5 100644 --- a/src/libPMacc/include/cuSTL/cursor/compile-time/SafeCursor.hpp +++ b/src/libPMacc/include/cuSTL/cursor/compile-time/SafeCursor.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/cursor/navigator/BufferNavigator.hpp b/src/libPMacc/include/cuSTL/cursor/navigator/BufferNavigator.hpp index a8782baa47..be8a24e82d 100644 --- a/src/libPMacc/include/cuSTL/cursor/navigator/BufferNavigator.hpp +++ b/src/libPMacc/include/cuSTL/cursor/navigator/BufferNavigator.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/cursor/navigator/CartNavigator.hpp b/src/libPMacc/include/cuSTL/cursor/navigator/CartNavigator.hpp index fc7aca11ad..634a9ba14a 100644 --- a/src/libPMacc/include/cuSTL/cursor/navigator/CartNavigator.hpp +++ b/src/libPMacc/include/cuSTL/cursor/navigator/CartNavigator.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/cursor/navigator/CursorNavigator.hpp b/src/libPMacc/include/cuSTL/cursor/navigator/CursorNavigator.hpp index e8d7493663..60c09e76f6 100644 --- a/src/libPMacc/include/cuSTL/cursor/navigator/CursorNavigator.hpp +++ b/src/libPMacc/include/cuSTL/cursor/navigator/CursorNavigator.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/cursor/navigator/EmptyNavigator.hpp b/src/libPMacc/include/cuSTL/cursor/navigator/EmptyNavigator.hpp index 0dc7fd35ce..80d2436d00 100644 --- a/src/libPMacc/include/cuSTL/cursor/navigator/EmptyNavigator.hpp +++ b/src/libPMacc/include/cuSTL/cursor/navigator/EmptyNavigator.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/cursor/navigator/MultiIndexNavigator.hpp b/src/libPMacc/include/cuSTL/cursor/navigator/MultiIndexNavigator.hpp index 53f573f329..d9484e6476 100644 --- a/src/libPMacc/include/cuSTL/cursor/navigator/MultiIndexNavigator.hpp +++ b/src/libPMacc/include/cuSTL/cursor/navigator/MultiIndexNavigator.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/cursor/navigator/compile-time/BufferNavigator.hpp b/src/libPMacc/include/cuSTL/cursor/navigator/compile-time/BufferNavigator.hpp index 3a1cebe9d9..4e0d1ae6f8 100644 --- a/src/libPMacc/include/cuSTL/cursor/navigator/compile-time/BufferNavigator.hpp +++ b/src/libPMacc/include/cuSTL/cursor/navigator/compile-time/BufferNavigator.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/cursor/navigator/compile-time/TwistAxesNavigator.hpp b/src/libPMacc/include/cuSTL/cursor/navigator/compile-time/TwistAxesNavigator.hpp index 5903252267..98e193a7c0 100644 --- a/src/libPMacc/include/cuSTL/cursor/navigator/compile-time/TwistAxesNavigator.hpp +++ b/src/libPMacc/include/cuSTL/cursor/navigator/compile-time/TwistAxesNavigator.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/cursor/navigator/compile-time/TwistedAxesNavigator.hpp b/src/libPMacc/include/cuSTL/cursor/navigator/compile-time/TwistedAxesNavigator.hpp index 59cdc56c85..2e8f7ba18d 100644 --- a/src/libPMacc/include/cuSTL/cursor/navigator/compile-time/TwistedAxesNavigator.hpp +++ b/src/libPMacc/include/cuSTL/cursor/navigator/compile-time/TwistedAxesNavigator.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/cursor/navigator/tag.h b/src/libPMacc/include/cuSTL/cursor/navigator/tag.h index f3737a16d5..c545a45de7 100644 --- a/src/libPMacc/include/cuSTL/cursor/navigator/tag.h +++ b/src/libPMacc/include/cuSTL/cursor/navigator/tag.h @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/cursor/tools/slice.hpp b/src/libPMacc/include/cuSTL/cursor/tools/slice.hpp index b109766251..1679bcab58 100644 --- a/src/libPMacc/include/cuSTL/cursor/tools/slice.hpp +++ b/src/libPMacc/include/cuSTL/cursor/tools/slice.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/cursor/tools/twistAxes.hpp b/src/libPMacc/include/cuSTL/cursor/tools/twistAxes.hpp index e300b344b7..1bd3996678 100644 --- a/src/libPMacc/include/cuSTL/cursor/tools/twistAxes.hpp +++ b/src/libPMacc/include/cuSTL/cursor/tools/twistAxes.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/cursor/tools/twistVectorFieldAxes.hpp b/src/libPMacc/include/cuSTL/cursor/tools/twistVectorFieldAxes.hpp index 2967b3d535..b8a832c1b4 100644 --- a/src/libPMacc/include/cuSTL/cursor/tools/twistVectorFieldAxes.hpp +++ b/src/libPMacc/include/cuSTL/cursor/tools/twistVectorFieldAxes.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/cursor/traits.hpp b/src/libPMacc/include/cuSTL/cursor/traits.hpp index 55e100b2f0..629b941e08 100644 --- a/src/libPMacc/include/cuSTL/cursor/traits.hpp +++ b/src/libPMacc/include/cuSTL/cursor/traits.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/zone/SphericZone.hpp b/src/libPMacc/include/cuSTL/zone/SphericZone.hpp index 33d5d9b183..6a74e96c78 100644 --- a/src/libPMacc/include/cuSTL/zone/SphericZone.hpp +++ b/src/libPMacc/include/cuSTL/zone/SphericZone.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -53,7 +53,7 @@ struct SphericZone math::Int offset; HDINLINE SphericZone() {} - HDINLINE SphericZone(const math::Size_t& size) : size(size), offset(math::Int(0)) {} + HDINLINE SphericZone(const math::Size_t& size) : size(size), offset(math::Int::create(0)) {} HDINLINE SphericZone(const math::Size_t& size, const math::Int& offset) : size(size), offset(offset) {} diff --git a/src/libPMacc/include/cuSTL/zone/StaggeredZone.hpp b/src/libPMacc/include/cuSTL/zone/StaggeredZone.hpp index 111bce990f..e775332e2e 100644 --- a/src/libPMacc/include/cuSTL/zone/StaggeredZone.hpp +++ b/src/libPMacc/include/cuSTL/zone/StaggeredZone.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/zone/ToricZone.hpp b/src/libPMacc/include/cuSTL/zone/ToricZone.hpp index 0b44dce757..9900f22658 100644 --- a/src/libPMacc/include/cuSTL/zone/ToricZone.hpp +++ b/src/libPMacc/include/cuSTL/zone/ToricZone.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/cuSTL/zone/compile-time/SphericZone.hpp b/src/libPMacc/include/cuSTL/zone/compile-time/SphericZone.hpp index ce57122a90..a01113125c 100644 --- a/src/libPMacc/include/cuSTL/zone/compile-time/SphericZone.hpp +++ b/src/libPMacc/include/cuSTL/zone/compile-time/SphericZone.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/dataManagement/AbstractInitialiser.hpp b/src/libPMacc/include/dataManagement/AbstractInitialiser.hpp index 6548fa51c0..6fef2a1e60 100644 --- a/src/libPMacc/include/dataManagement/AbstractInitialiser.hpp +++ b/src/libPMacc/include/dataManagement/AbstractInitialiser.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013-2014 Rene Widera, Felix Schmitt + * Copyright 2013-2015 Rene Widera, Felix Schmitt, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,13 +20,11 @@ * If not, see . */ -#ifndef ABSTRACTINITIALISER_HPP -#define ABSTRACTINITIALISER_HPP +#pragma once #include "dataManagement/ISimulationData.hpp" #include "dataManagement/IDataSorter.hpp" - namespace PMacc { @@ -60,6 +58,3 @@ namespace PMacc }; } - -#endif /* ABSTRACTINITIALISER_HPP */ - diff --git a/src/libPMacc/include/dataManagement/DataConnector.hpp b/src/libPMacc/include/dataManagement/DataConnector.hpp index c924cb8689..f36dc2121e 100644 --- a/src/libPMacc/include/dataManagement/DataConnector.hpp +++ b/src/libPMacc/include/dataManagement/DataConnector.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/dataManagement/Dataset.hpp b/src/libPMacc/include/dataManagement/Dataset.hpp index a9c9c1bdee..fc22c80b77 100644 --- a/src/libPMacc/include/dataManagement/Dataset.hpp +++ b/src/libPMacc/include/dataManagement/Dataset.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Rene Widera, Felix Schmitt + * Copyright 2013, 2015 Rene Widera, Felix Schmitt, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,14 +20,11 @@ * If not, see . */ - -#ifndef DATASET_HPP -#define DATASET_HPP - -#include +#pragma once #include "dataManagement/ISimulationData.hpp" +#include namespace PMacc { @@ -107,6 +104,3 @@ namespace PMacc DatasetStatus status; }; } - -#endif /* DATASET_HPP */ - diff --git a/src/libPMacc/include/dataManagement/IDataSorter.hpp b/src/libPMacc/include/dataManagement/IDataSorter.hpp index e16fee00ff..cdfbf44070 100644 --- a/src/libPMacc/include/dataManagement/IDataSorter.hpp +++ b/src/libPMacc/include/dataManagement/IDataSorter.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Rene Widera, Felix Schmitt + * Copyright 2013, 2015 Rene Widera, Felix Schmitt, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,9 +20,7 @@ * If not, see . */ - -#ifndef IDATASORTER_HPP -#define IDATASORTER_HPP +#pragma once namespace PMacc { @@ -76,6 +74,3 @@ namespace PMacc virtual ID_TYPE getNext() = 0; }; } - -#endif /* IDATASORTER_HPP */ - diff --git a/src/libPMacc/include/dataManagement/ISimulationData.hpp b/src/libPMacc/include/dataManagement/ISimulationData.hpp index d1552acab2..aacaf5cc94 100644 --- a/src/libPMacc/include/dataManagement/ISimulationData.hpp +++ b/src/libPMacc/include/dataManagement/ISimulationData.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013-2014 Rene Widera, Felix Schmitt + * Copyright 2013-2015 Rene Widera, Felix Schmitt, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,15 +20,14 @@ * If not, see . */ -#ifndef ISIMULATIONDATA_HPP -#define ISIMULATIONDATA_HPP +#pragma once #include namespace PMacc { typedef std::string SimulationDataId; - + /** * Interface for simulation data which should be registered at DataConnector * for file output, visualization, etc. @@ -41,16 +40,13 @@ namespace PMacc * will return up-to-date values. */ virtual void synchronize() = 0; - + /** * Return the globally unique identifier for this simulation data. * * @return globally unique identifier */ virtual SimulationDataId getUniqueId() = 0; - + }; } - -#endif /* ISIMULATIONDATA_HPP */ - diff --git a/src/libPMacc/include/dataManagement/ListSorter.hpp b/src/libPMacc/include/dataManagement/ListSorter.hpp index d45b8d710a..04e117ed66 100644 --- a/src/libPMacc/include/dataManagement/ListSorter.hpp +++ b/src/libPMacc/include/dataManagement/ListSorter.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013-2014 Rene Widera, Felix Schmitt + * Copyright 2013-2015 Rene Widera, Felix Schmitt, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,8 +20,7 @@ * If not, see . */ -#ifndef LISTSORTER_HPP -#define LISTSORTER_HPP +#pragma once #include "dataManagement/IDataSorter.hpp" @@ -81,6 +80,3 @@ namespace PMacc typename std::list::iterator iter; }; } - -#endif /* LISTSORTER_HPP */ - diff --git a/src/libPMacc/include/debug/DebugBuffers.hpp b/src/libPMacc/include/debug/DebugBuffers.hpp index 372448b32e..961c1d6a55 100644 --- a/src/libPMacc/include/debug/DebugBuffers.hpp +++ b/src/libPMacc/include/debug/DebugBuffers.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Felix Schmitt, Heiko Burau, Rene Widera + * Copyright 2013-2015 Felix Schmitt, Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,16 +20,14 @@ * If not, see . */ +#pragma once -#ifndef DEBUGBUFFERS_HPP -#define DEBUGBUFFERS_HPP +#include "memory/buffers/IHostBuffer.hpp" +#include "types.h" #include #include -#include "types.h" -#include "memory/buffers/HostBuffer.hpp" - namespace PMacc { @@ -107,6 +105,3 @@ namespace PMacc } }; } - -#endif /* DEBUGBUFFERS_HPP */ - diff --git a/src/libPMacc/include/debug/DebugDataSpace.hpp b/src/libPMacc/include/debug/DebugDataSpace.hpp index e477c24342..18f7289acb 100644 --- a/src/libPMacc/include/debug/DebugDataSpace.hpp +++ b/src/libPMacc/include/debug/DebugDataSpace.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013 Felix Schmitt, Heiko Burau, Rene Widera + * Copyright 2013, 2015 Felix Schmitt, Heiko Burau, Rene Widera, + * Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,15 +21,13 @@ * If not, see . */ +#pragma once -#ifndef DEBUGDATASPACE_HPP -#define DEBUGDATASPACE_HPP +#include "dimensions/DataSpace.hpp" #include #include -#include "dimensions/DataSpace.hpp" - namespace PMacc { @@ -73,6 +72,3 @@ namespace PMacc }; } - -#endif /* DEBUGDATASPACE_HPP */ - diff --git a/src/libPMacc/include/debug/DebugExchangeTypes.hpp b/src/libPMacc/include/debug/DebugExchangeTypes.hpp index bafb166201..53b1b10e97 100644 --- a/src/libPMacc/include/debug/DebugExchangeTypes.hpp +++ b/src/libPMacc/include/debug/DebugExchangeTypes.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera + * Copyright 2013, 2015 Felix Schmitt, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,15 +20,14 @@ * If not, see . */ -#ifndef DEBUGEXCHANGETYPES_HPP -#define DEBUGEXCHANGETYPES_HPP +#pragma once + +#include "memory/dataTypes/Mask.hpp" +#include "types.h" #include #include -#include "types.h" -#include "memory/dataTypes/Mask.hpp" - namespace PMacc { @@ -78,6 +77,3 @@ namespace PMacc }; } - -#endif /* DEBUGEXCHANGETYPES_HPP */ - diff --git a/src/libPMacc/include/debug/PMaccVerbose.hpp b/src/libPMacc/include/debug/PMaccVerbose.hpp index 8fa125d9bd..b51989dd25 100644 --- a/src/libPMacc/include/debug/PMaccVerbose.hpp +++ b/src/libPMacc/include/debug/PMaccVerbose.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -22,9 +22,10 @@ #pragma once -#include #include "debug/VerboseLog.hpp" +#include + #ifndef PMACC_VERBOSE_LVL #define PMACC_VERBOSE_LVL 0 #endif diff --git a/src/libPMacc/include/debug/VerboseLog.hpp b/src/libPMacc/include/debug/VerboseLog.hpp index a21d250b63..c114f38a70 100644 --- a/src/libPMacc/include/debug/VerboseLog.hpp +++ b/src/libPMacc/include/debug/VerboseLog.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Rene Widera + * Copyright 2013-2015 Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -22,15 +22,14 @@ #pragma once -#include -#include -#include - +#include "debug/VerboseLogMakros.hpp" #include "types.h" -#include -#include "debug/VerboseLogMakros.hpp" +#include +#include +#include +#include namespace PMacc { diff --git a/src/libPMacc/include/debug/VerboseLogMakros.hpp b/src/libPMacc/include/debug/VerboseLogMakros.hpp index 05d9b20779..a51382c23f 100644 --- a/src/libPMacc/include/debug/VerboseLogMakros.hpp +++ b/src/libPMacc/include/debug/VerboseLogMakros.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,18 +20,13 @@ * If not, see . */ - #pragma once #include #include #include - -#include "static_assert.hpp" #include - - /** create a log lvl * @param code integer which represent a bit in a 64bit bitmask * @param name name of the log lvl, name is needet later to call log(...) @@ -70,6 +65,3 @@ typedef structName thisClass; \ public: \ __DEFINE_VERBOSE_CLASS_LVLS - - - diff --git a/src/libPMacc/include/dimensions/DataSpace.hpp b/src/libPMacc/include/dimensions/DataSpace.hpp index 05cd317504..e2169befb0 100644 --- a/src/libPMacc/include/dimensions/DataSpace.hpp +++ b/src/libPMacc/include/dimensions/DataSpace.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013 Felix Schmitt, Heiko Burau, Rene Widera, Wolfgang Hoenig + * Copyright 2013-2015 Felix Schmitt, Heiko Burau, Rene Widera, + * Wolfgang Hoenig, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -22,15 +23,8 @@ #pragma once -#include -#include -#include -#include -#include - -#include "types.h" #include "math/Vector.hpp" - +#include "types.h" namespace PMacc { @@ -122,7 +116,7 @@ namespace PMacc } /** - * Give DataSpace were all dimensions set to init value + * Give DataSpace where all dimensions set to init value * * @param value value which is setfor all dimensions * @return the new DataSpace @@ -163,8 +157,6 @@ namespace PMacc return false; } - - HDINLINE operator math::Size_t() const { math::Size_t result; diff --git a/src/libPMacc/include/dimensions/DataSpace.tpp b/src/libPMacc/include/dimensions/DataSpace.tpp index db8453780c..649c1ecebd 100644 --- a/src/libPMacc/include/dimensions/DataSpace.tpp +++ b/src/libPMacc/include/dimensions/DataSpace.tpp @@ -1,10 +1,10 @@ /** - * Copyright 2013-2014 Rene Widera + * Copyright 2013-2015 Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -23,13 +23,13 @@ #pragma once -#include "types.h" #include "dimensions/DataSpace.hpp" + #include "traits/GetComponentsType.hpp" #include "traits/GetNComponents.hpp" - #include "algorithms/math.hpp" #include "algorithms/TypeCast.hpp" +#include "types.h" namespace PMacc { diff --git a/src/libPMacc/include/dimensions/DataSpaceOperations.hpp b/src/libPMacc/include/dimensions/DataSpaceOperations.hpp index 0ebee8c251..faed700d8c 100644 --- a/src/libPMacc/include/dimensions/DataSpaceOperations.hpp +++ b/src/libPMacc/include/dimensions/DataSpaceOperations.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013 Felix Schmitt, Heiko Burau, Rene Widera + * Copyright 2013, 2015 Felix Schmitt, Heiko Burau, Rene Widera, + * Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,9 +21,7 @@ * If not, see . */ - -#ifndef DATASPACEOPERATIONS_HPP -#define DATASPACEOPERATIONS_HPP +#pragma once #include "types.h" #include "dimensions/DataSpace.hpp" @@ -294,5 +293,3 @@ namespace PMacc } }; } - -#endif /* DATASPACEOPERATIONS_HPP */ \ No newline at end of file diff --git a/src/libPMacc/include/dimensions/GridLayout.hpp b/src/libPMacc/include/dimensions/GridLayout.hpp index f3ba30cd61..843afb050a 100644 --- a/src/libPMacc/include/dimensions/GridLayout.hpp +++ b/src/libPMacc/include/dimensions/GridLayout.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013 Felix Schmitt, Heiko Burau, Rene Widera, Wolfgang Hoenig + * Copyright 2013, 2015 Felix Schmitt, Heiko Burau, Rene Widera, Wolfgang Hoenig, + * Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,8 +21,7 @@ * If not, see . */ -#ifndef _GRIDLAYOUT_HPP -#define _GRIDLAYOUT_HPP +#pragma once #include "dimensions/DataSpace.hpp" @@ -87,6 +87,3 @@ namespace PMacc }; } //namespace PMacc - -#endif /* _GRIDLAYOUT_HPP */ - diff --git a/src/libPMacc/include/dimensions/SuperCellDescription.hpp b/src/libPMacc/include/dimensions/SuperCellDescription.hpp index 8752206a12..652a85ac89 100644 --- a/src/libPMacc/include/dimensions/SuperCellDescription.hpp +++ b/src/libPMacc/include/dimensions/SuperCellDescription.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/eventSystem/EventSystem.hpp b/src/libPMacc/include/eventSystem/EventSystem.hpp index 107277f237..8bb7a8c46e 100644 --- a/src/libPMacc/include/eventSystem/EventSystem.hpp +++ b/src/libPMacc/include/eventSystem/EventSystem.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/eventSystem/Manager.hpp b/src/libPMacc/include/eventSystem/Manager.hpp index dc056799dc..395fe5d017 100644 --- a/src/libPMacc/include/eventSystem/Manager.hpp +++ b/src/libPMacc/include/eventSystem/Manager.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013-2014 Felix Schmitt, Rene Widera, Wolfgang Hoenig + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Wolfgang Hoenig, + * Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -22,12 +23,11 @@ #pragma once -#include -#include - #include "eventSystem/tasks/ITask.hpp" #include "eventSystem/events/EventPool.hpp" +#include +#include namespace PMacc { @@ -74,9 +74,7 @@ namespace PMacc EventPool& getEventPool(); - int getCount(); - - + std::size_t getCount(); private: diff --git a/src/libPMacc/include/eventSystem/Manager.tpp b/src/libPMacc/include/eventSystem/Manager.tpp index df2916a327..0a1982592f 100644 --- a/src/libPMacc/include/eventSystem/Manager.tpp +++ b/src/libPMacc/include/eventSystem/Manager.tpp @@ -1,10 +1,10 @@ /** - * Copyright 2013-2014 Felix Schmitt, Rene Widera + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,14 +20,15 @@ * If not, see . */ +#include "eventSystem/streams/StreamController.hpp" +#include "eventSystem/EventSystem.hpp" +#include "eventSystem/Manager.hpp" + +#include +#include #include #include -#include "eventSystem/EventSystem.hpp" -#include "eventSystem/streams/StreamController.hpp" -#include "eventSystem/Manager.hpp" -#include -#include //#define DEBUG_EVENTS namespace PMacc @@ -203,7 +204,7 @@ inline EventPool& Manager::getEventPool( ) return *eventPool; } -inline int Manager::getCount( ) +inline std::size_t Manager::getCount( ) { for ( TaskMap::iterator iter = tasks.begin( ); iter != tasks.end( ); ++iter ) { diff --git a/src/libPMacc/include/eventSystem/events/CudaEvent.hpp b/src/libPMacc/include/eventSystem/events/CudaEvent.hpp index 8f66537e19..11e9fe07c3 100644 --- a/src/libPMacc/include/eventSystem/events/CudaEvent.hpp +++ b/src/libPMacc/include/eventSystem/events/CudaEvent.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/eventSystem/events/EventDataReceive.hpp b/src/libPMacc/include/eventSystem/events/EventDataReceive.hpp index 9179a5314c..06377245d5 100644 --- a/src/libPMacc/include/eventSystem/events/EventDataReceive.hpp +++ b/src/libPMacc/include/eventSystem/events/EventDataReceive.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera, Wolfgang Hoenig + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Wolfgang Hoenig, + * Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,9 +21,7 @@ * If not, see . */ - -#ifndef _EVENTDATARECEIVE_HPP -#define _EVENTDATARECEIVE_HPP +#pragma once #include "eventSystem/events/IEventData.hpp" @@ -32,13 +31,10 @@ namespace PMacc class EventDataReceive : public IEventData { public: - EventDataReceive(EventNotify *task, size_t recv_count) : IEventData(task), recv_count(recv_count) - { - - } + {} size_t getReceivedCount() const { @@ -51,6 +47,3 @@ namespace PMacc }; } //namespace PMacc - -#endif /* _EVENTDATARECEIVE_HPP */ - diff --git a/src/libPMacc/include/eventSystem/events/EventNotify.hpp b/src/libPMacc/include/eventSystem/events/EventNotify.hpp index 8b6f79121c..191d26277b 100644 --- a/src/libPMacc/include/eventSystem/events/EventNotify.hpp +++ b/src/libPMacc/include/eventSystem/events/EventNotify.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera, Wolfgang Hoenig + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Wolfgang Hoenig, + * Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,20 +21,18 @@ * If not, see . */ - -#ifndef _EVENTNOTIFY_HPP -#define _EVENTNOTIFY_HPP +#pragma once #include -#include "types.h" -#include "eventSystem/events/IEvent.hpp" - +#include "types.h" namespace PMacc { class IEventData; + class IEvent; + /** * Implements an observable. */ @@ -78,6 +77,3 @@ namespace PMacc } //namespace PMacc - -#endif /* _EVENTNOTIFY_HPP */ - diff --git a/src/libPMacc/include/eventSystem/events/EventNotify.tpp b/src/libPMacc/include/eventSystem/events/EventNotify.tpp index c2f770881c..fa668d5690 100644 --- a/src/libPMacc/include/eventSystem/events/EventNotify.tpp +++ b/src/libPMacc/include/eventSystem/events/EventNotify.tpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Rene Widera + * Copyright 2013-2015 Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,12 +20,12 @@ * If not, see . */ -#include - -#include "types.h" #include "eventSystem/events/EventNotify.hpp" #include "eventSystem/events/IEventData.hpp" +#include "eventSystem/events/IEvent.hpp" +#include "types.h" +#include namespace PMacc { @@ -53,6 +53,3 @@ namespace PMacc } } //namespace PMacc - - - diff --git a/src/libPMacc/include/eventSystem/events/EventPool.hpp b/src/libPMacc/include/eventSystem/events/EventPool.hpp index 0920b04503..ffbdfb207a 100644 --- a/src/libPMacc/include/eventSystem/events/EventPool.hpp +++ b/src/libPMacc/include/eventSystem/events/EventPool.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -23,10 +23,11 @@ #pragma once -#include "types.h" #include "eventSystem/events/CudaEvent.hpp" +#include "debug/VerboseLog.hpp" +#include "types.h" + #include -#include namespace PMacc { diff --git a/src/libPMacc/include/eventSystem/events/EventTask.hpp b/src/libPMacc/include/eventSystem/events/EventTask.hpp index 77244f257f..a051730402 100644 --- a/src/libPMacc/include/eventSystem/events/EventTask.hpp +++ b/src/libPMacc/include/eventSystem/events/EventTask.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Rene Widera + * Copyright 2013-2015 Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,15 +20,11 @@ * If not, see . */ +#pragma once -#ifndef _EVENTTASK_HPP -#define _EVENTTASK_HPP - - -#include -#include "eventSystem/tasks/ITask.hpp" - +#include "types.h" +#include namespace PMacc { @@ -110,5 +106,3 @@ namespace PMacc } //namespace PMacc - -#endif /* _EVENTTASK_HPP */ diff --git a/src/libPMacc/include/eventSystem/events/EventTask.tpp b/src/libPMacc/include/eventSystem/events/EventTask.tpp index 055658d8b7..a17cea1eda 100644 --- a/src/libPMacc/include/eventSystem/events/EventTask.tpp +++ b/src/libPMacc/include/eventSystem/events/EventTask.tpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Rene Widera + * Copyright 2013-2015 Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -30,15 +30,12 @@ namespace PMacc { inline EventTask::EventTask(id_t taskId) : - taskId(taskId) - { - } + taskId(taskId) + {} inline EventTask::EventTask() : - taskId(0) - { - - } + taskId(0) + {} inline std::string EventTask::toString() { @@ -107,8 +104,5 @@ namespace PMacc return *this; } - - } - diff --git a/src/libPMacc/include/eventSystem/events/IEvent.hpp b/src/libPMacc/include/eventSystem/events/IEvent.hpp index 35c4997728..0140f44207 100644 --- a/src/libPMacc/include/eventSystem/events/IEvent.hpp +++ b/src/libPMacc/include/eventSystem/events/IEvent.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera, Wolfgang Hoenig + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Wolfgang Hoenig, + * Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,9 +21,7 @@ * If not, see . */ - -#ifndef _IEVENT_HPP -#define _IEVENT_HPP +#pragma once #include "types.h" @@ -56,6 +55,3 @@ namespace PMacc }; } //namespace PMacc - -#endif /* _IEVENT_HPP */ - diff --git a/src/libPMacc/include/eventSystem/events/IEventData.hpp b/src/libPMacc/include/eventSystem/events/IEventData.hpp index 36b21b2a7e..1e756b23f3 100644 --- a/src/libPMacc/include/eventSystem/events/IEventData.hpp +++ b/src/libPMacc/include/eventSystem/events/IEventData.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera, Wolfgang Hoenig + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Wolfgang Hoenig, + * Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,8 +21,7 @@ * If not, see . */ -#ifndef _IEVENTDATA_HPP -#define _IEVENTDATA_HPP +#pragma once #include "eventSystem/events/EventNotify.hpp" @@ -39,13 +39,10 @@ namespace PMacc IEventData(EventNotify *task) : task(task) - { - - } + {} virtual ~IEventData() - { - } + {} EventNotify* getEventNotify() { @@ -58,6 +55,3 @@ namespace PMacc }; } //namespace PMacc - -#endif /* _IEVENTDATA_HPP */ - diff --git a/src/libPMacc/include/eventSystem/events/kernelEvents.hpp b/src/libPMacc/include/eventSystem/events/kernelEvents.hpp index 7db6cea719..70c66760d5 100644 --- a/src/libPMacc/include/eventSystem/events/kernelEvents.hpp +++ b/src/libPMacc/include/eventSystem/events/kernelEvents.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,14 +20,14 @@ * If not, see . */ -#ifndef KERNELEVENTS_H -#define KERNELEVENTS_H +#pragma once -#include "types.h" -#include "ppFunctions.hpp" -#include #include "dimensions/DataSpace.hpp" #include "eventSystem/EventSystem.hpp" +#include "ppFunctions.hpp" +#include "types.h" + +#include namespace PMacc { @@ -43,14 +43,14 @@ namespace PMacc #endif /** Call activate kernel from taskKernel. - * If PMACC_SYNC_KERNEL is 1 cudaThreadSynchronize() is called before + * If PMACC_SYNC_KERNEL is 1 cudaDeviceSynchronize() is called before * and after activation. */ #define PMACC_ACTIVATE_KERNEL \ CUDA_CHECK_KERNEL_MSG(cudaGetLastError( ),"Last error after kernel launch"); \ - CUDA_CHECK_KERNEL_MSG(cudaThreadSynchronize(),"Crash after kernel launch"); \ + CUDA_CHECK_KERNEL_MSG(cudaDeviceSynchronize(),"Crash after kernel launch"); \ taskKernel->activateChecks(); \ - CUDA_CHECK_KERNEL_MSG(cudaThreadSynchronize(),"Crash after kernel activation"); + CUDA_CHECK_KERNEL_MSG(cudaDeviceSynchronize(),"Crash after kernel activation"); /** * Appends kernel arguments to generated code and activates kernel task. @@ -79,12 +79,8 @@ namespace PMacc * @param kernelname name of the CUDA kernel (can also used with templates etc. myKernel<1>) */ #define __cudaKernel(kernelname) { \ - CUDA_CHECK_KERNEL_MSG(cudaThreadSynchronize(),"Crash before kernel call"); \ + CUDA_CHECK_KERNEL_MSG(cudaDeviceSynchronize(),"Crash before kernel call"); \ TaskKernel *taskKernel = Environment<>::get().Factory().createTaskKernel(#kernelname); \ kernelname PMACC_CUDAKERNELCONFIG } - - -#endif //KERNELEVENTS_H - diff --git a/src/libPMacc/include/eventSystem/streams/EventStream.hpp b/src/libPMacc/include/eventSystem/streams/EventStream.hpp index da26e50a20..5d77d673eb 100644 --- a/src/libPMacc/include/eventSystem/streams/EventStream.hpp +++ b/src/libPMacc/include/eventSystem/streams/EventStream.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,11 +20,12 @@ * If not, see . */ - #pragma once -#include #include "eventSystem/events/CudaEvent.hpp" +#include "types.h" + +#include namespace PMacc { diff --git a/src/libPMacc/include/eventSystem/streams/StreamController.hpp b/src/libPMacc/include/eventSystem/streams/StreamController.hpp index d5f161ed29..b08c1df291 100644 --- a/src/libPMacc/include/eventSystem/streams/StreamController.hpp +++ b/src/libPMacc/include/eventSystem/streams/StreamController.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera, Wolfgang Hoenig + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Wolfgang Hoenig, + * Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -21,15 +22,16 @@ */ -#ifndef _STREAMCONTROLLER_HPP -#define _STREAMCONTROLLER_HPP - -#include -#include +#pragma once +#include "eventSystem/streams/EventStream.hpp" #include "types.h" -#include "eventSystem/streams/EventStream.hpp" +#include + +#include +#include +#include namespace PMacc { @@ -138,7 +140,3 @@ namespace PMacc }; } //namespace PMacc - - -#endif /* _ENVIRONMENTCONTROLLER_HPP */ - diff --git a/src/libPMacc/include/eventSystem/tasks/Factory.hpp b/src/libPMacc/include/eventSystem/tasks/Factory.hpp index e79b617063..d5f05fc2a8 100644 --- a/src/libPMacc/include/eventSystem/tasks/Factory.hpp +++ b/src/libPMacc/include/eventSystem/tasks/Factory.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera, Wolfgang Hoenig + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Wolfgang Hoenig, + * Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,13 +21,13 @@ * If not, see . */ +#pragma once -#ifndef _FACTORY_HPP -#define _FACTORY_HPP - -#include #include "eventSystem/tasks/ITask.hpp" #include "eventSystem/streams/EventStream.hpp" +#include "types.h" + +#include namespace PMacc { @@ -43,7 +44,7 @@ namespace PMacc /** * Singleton Factory-pattern class for creation of several types of EventTasks. - * Tasks are not actually 'returned' but immediately initialised and + * Tasks are not actually 'returned' but immediately initialized and * added to the Manager's queue. An exception is TaskKernel. */ class Factory @@ -184,6 +185,3 @@ namespace PMacc } //namespace PMacc - -#endif /* _FACTORY_HPP */ - diff --git a/src/libPMacc/include/eventSystem/tasks/Factory.tpp b/src/libPMacc/include/eventSystem/tasks/Factory.tpp index ed6de2f418..74a2413a98 100644 --- a/src/libPMacc/include/eventSystem/tasks/Factory.tpp +++ b/src/libPMacc/include/eventSystem/tasks/Factory.tpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Rene Widera + * Copyright 2013-2015 Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -37,9 +37,9 @@ #include "eventSystem/tasks/TaskSetCurrentSizeOnDevice.hpp" #include "eventSystem/tasks/TaskSendMPI.hpp" #include "eventSystem/tasks/TaskReceiveMPI.hpp" +#include "eventSystem/tasks/TaskGetCurrentSizeFromDevice.hpp" #include "eventSystem/streams/EventStream.hpp" #include "eventSystem/streams/StreamController.hpp" -#include "eventSystem/tasks/TaskGetCurrentSizeFromDevice.hpp" namespace PMacc { diff --git a/src/libPMacc/include/eventSystem/tasks/ITask.hpp b/src/libPMacc/include/eventSystem/tasks/ITask.hpp index a5d9e2e9fb..2e0b615b82 100644 --- a/src/libPMacc/include/eventSystem/tasks/ITask.hpp +++ b/src/libPMacc/include/eventSystem/tasks/ITask.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera, Wolfgang Hoenig + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Wolfgang Hoenig, + * Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,19 +21,16 @@ * If not, see . */ - -#ifndef _ITASK_HPP -#define _ITASK_HPP - -#include -#include -#include -#include +#pragma once #include "eventSystem/events/EventNotify.hpp" #include "eventSystem/events/IEvent.hpp" #include "types.h" +#include +#include +#include + namespace PMacc { /** @@ -76,7 +74,7 @@ namespace PMacc } /** - * Initialises the task. + * Initializes the task. * Must be called before adding the task to the Manager's queue. */ virtual void init()=0; @@ -126,6 +124,3 @@ namespace PMacc }; } //namespace PMacc - -#endif /* _ITASK_HPP */ - diff --git a/src/libPMacc/include/eventSystem/tasks/MPITask.hpp b/src/libPMacc/include/eventSystem/tasks/MPITask.hpp index 2571b25393..b9404887ac 100644 --- a/src/libPMacc/include/eventSystem/tasks/MPITask.hpp +++ b/src/libPMacc/include/eventSystem/tasks/MPITask.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,13 +20,11 @@ * If not, see . */ -#ifndef MPITASK_HPP -#define MPITASK_HPP - -#include +#pragma once #include "eventSystem/tasks/ITask.hpp" -#include "eventSystem/transactions/TransactionManager.hpp" + +#include namespace PMacc { @@ -79,6 +77,3 @@ namespace PMacc bool finished; }; } - -#endif /* MPITASK_HPP */ - diff --git a/src/libPMacc/include/eventSystem/tasks/StreamTask.hpp b/src/libPMacc/include/eventSystem/tasks/StreamTask.hpp index 132806124f..3916baf1d2 100644 --- a/src/libPMacc/include/eventSystem/tasks/StreamTask.hpp +++ b/src/libPMacc/include/eventSystem/tasks/StreamTask.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -22,12 +22,9 @@ #pragma once -#include - #include "eventSystem/tasks/ITask.hpp" #include "eventSystem/events/CudaEvent.hpp" - namespace PMacc { class EventStream; diff --git a/src/libPMacc/include/eventSystem/tasks/StreamTask.tpp b/src/libPMacc/include/eventSystem/tasks/StreamTask.tpp index 020d724102..928515aef6 100644 --- a/src/libPMacc/include/eventSystem/tasks/StreamTask.tpp +++ b/src/libPMacc/include/eventSystem/tasks/StreamTask.tpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Rene Widera + * Copyright 2013-2015 Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,15 +20,12 @@ * If not, see . */ -#include #include "Environment.hpp" //#include "eventSystem/EventSystem.hpp" #include "eventSystem/tasks/StreamTask.hpp" #include "eventSystem/streams/EventStream.hpp" - - namespace PMacc { diff --git a/src/libPMacc/include/eventSystem/tasks/TaskCopyDeviceToDevice.hpp b/src/libPMacc/include/eventSystem/tasks/TaskCopyDeviceToDevice.hpp index 2e1aa1495a..281d345189 100644 --- a/src/libPMacc/include/eventSystem/tasks/TaskCopyDeviceToDevice.hpp +++ b/src/libPMacc/include/eventSystem/tasks/TaskCopyDeviceToDevice.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera, Wolfgang Hoenig + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Wolfgang Hoenig, + * Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,16 +21,14 @@ * If not, see . */ -#ifndef _TASKCOPYDEVICETODEVICE_HPP -#define _TASKCOPYDEVICETODEVICE_HPP - -#include - -#include "types.h" +#pragma once #include "eventSystem/EventSystem.hpp" #include "eventSystem/streams/EventStream.hpp" #include "eventSystem/tasks/StreamTask.hpp" +#include "types.h" + +#include namespace PMacc { @@ -54,7 +53,7 @@ namespace PMacc notify(this->myId, COPYDEVICE2DEVICE, NULL); } - bool executeIntern() throw (std::runtime_error) + bool executeIntern() { return isFinished(); } @@ -199,7 +198,3 @@ namespace PMacc }; } //namespace PMacc - - -#endif /* _TASKCOPYDEVICETODEVICE_HPP */ - diff --git a/src/libPMacc/include/eventSystem/tasks/TaskCopyDeviceToHost.hpp b/src/libPMacc/include/eventSystem/tasks/TaskCopyDeviceToHost.hpp index ba6190cada..c1ab5757a7 100644 --- a/src/libPMacc/include/eventSystem/tasks/TaskCopyDeviceToHost.hpp +++ b/src/libPMacc/include/eventSystem/tasks/TaskCopyDeviceToHost.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera, Wolfgang Hoenig + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Wolfgang Hoenig, + * Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,17 +21,15 @@ * If not, see . */ -#ifndef _TASKCOPYDEVICETOHOST_HPP -#define _TASKCOPYDEVICETOHOST_HPP - - -#include -#include +#pragma once #include "eventSystem/EventSystem.hpp" #include "eventSystem/streams/EventStream.hpp" #include "eventSystem/tasks/StreamTask.hpp" +#include + +#include namespace PMacc { @@ -205,7 +204,3 @@ namespace PMacc }; } //namespace PMacc - - -#endif /* _TASKCOPYDEVICETOHOST_HPP */ - diff --git a/src/libPMacc/include/eventSystem/tasks/TaskCopyHostToDevice.hpp b/src/libPMacc/include/eventSystem/tasks/TaskCopyHostToDevice.hpp index d5f76cbe7c..7373585f89 100644 --- a/src/libPMacc/include/eventSystem/tasks/TaskCopyHostToDevice.hpp +++ b/src/libPMacc/include/eventSystem/tasks/TaskCopyHostToDevice.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera, Wolfgang Hoenig + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Wolfgang Hoenig, + * Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,15 +21,14 @@ * If not, see . */ -#ifndef _TASKCOPYHOSTTODEVICE_HPP -#define _TASKCOPYHOSTTODEVICE_HPP - -#include +#pragma once #include "eventSystem/EventSystem.hpp" #include "eventSystem/streams/EventStream.hpp" #include "eventSystem/tasks/StreamTask.hpp" +#include + namespace PMacc { @@ -193,7 +193,3 @@ namespace PMacc } //namespace PMacc - - -#endif /* _TASKCOPYHOSTTODEVICE_HPP */ - diff --git a/src/libPMacc/include/eventSystem/tasks/TaskGetCurrentSizeFromDevice.hpp b/src/libPMacc/include/eventSystem/tasks/TaskGetCurrentSizeFromDevice.hpp index 02469e52af..3ed5c3533b 100644 --- a/src/libPMacc/include/eventSystem/tasks/TaskGetCurrentSizeFromDevice.hpp +++ b/src/libPMacc/include/eventSystem/tasks/TaskGetCurrentSizeFromDevice.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,19 +20,16 @@ * If not, see . */ -#ifndef _TASKGETCURRENTSIZEFROMDEVICE_HPP -#define _TASKGETCURRENTSIZEFROMDEVICE_HPP - -#include -#include - - -#include "dimensions/DataSpace.hpp" -#include "types.h" +#pragma once #include "eventSystem/EventSystem.hpp" #include "eventSystem/streams/EventStream.hpp" #include "eventSystem/tasks/StreamTask.hpp" +#include "dimensions/DataSpace.hpp" +#include "types.h" + +#include +#include namespace PMacc { @@ -87,7 +84,3 @@ class TaskGetCurrentSizeFromDevice : public StreamTask }; } //namespace PMacc - - -#endif /* _TASKGETCURRENTSIZEFROMDEVICE_HPP */ - diff --git a/src/libPMacc/include/eventSystem/tasks/TaskKernel.hpp b/src/libPMacc/include/eventSystem/tasks/TaskKernel.hpp index 0967fa0f2a..92cb506e02 100644 --- a/src/libPMacc/include/eventSystem/tasks/TaskKernel.hpp +++ b/src/libPMacc/include/eventSystem/tasks/TaskKernel.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -21,11 +21,7 @@ */ -#ifndef _TASKKERNEL_HPP -#define _TASKKERNEL_HPP - -#include -#include +#pragma once #include "eventSystem/tasks/StreamTask.hpp" #include "eventSystem/streams/EventStream.hpp" @@ -88,6 +84,3 @@ namespace PMacc } //namespace PMacc - -#endif /* _TASKKERNEL_HPP */ - diff --git a/src/libPMacc/include/eventSystem/tasks/TaskLogicalAnd.hpp b/src/libPMacc/include/eventSystem/tasks/TaskLogicalAnd.hpp index 9b4d2f3698..09c4ad3e1c 100644 --- a/src/libPMacc/include/eventSystem/tasks/TaskLogicalAnd.hpp +++ b/src/libPMacc/include/eventSystem/tasks/TaskLogicalAnd.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera, Wolfgang Hoenig + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Wolfgang Hoenig, + * Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -21,15 +22,11 @@ */ -#ifndef _TASKLOGICALAND_HPP -#define _TASKLOGICALAND_HPP +#pragma once #include "eventSystem/tasks/ITask.hpp" #include "eventSystem/tasks/StreamTask.hpp" #include "eventSystem/EventSystem.hpp" -#include - -#include namespace PMacc { @@ -153,5 +150,3 @@ namespace PMacc } //namespace PMacc -#endif /* _TASKLOGICALAND_HPP */ - diff --git a/src/libPMacc/include/eventSystem/tasks/TaskReceive.hpp b/src/libPMacc/include/eventSystem/tasks/TaskReceive.hpp index b8c404aa27..baf4019b3f 100644 --- a/src/libPMacc/include/eventSystem/tasks/TaskReceive.hpp +++ b/src/libPMacc/include/eventSystem/tasks/TaskReceive.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera, Wolfgang Hoenig + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Wolfgang Hoenig, + * Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,17 +21,15 @@ * If not, see . */ -#ifndef _TASKRECEIVE_HPP -#define _TASKRECEIVE_HPP +#pragma once -#include "memory/buffers/Exchange.hpp" - -#include "mappings/simulation/EnvironmentController.hpp" #include "eventSystem/tasks/ITask.hpp" #include "eventSystem/tasks/MPITask.hpp" #include "eventSystem/tasks/TaskCopyHostToDevice.hpp" #include "eventSystem/events/EventDataReceive.hpp" #include "eventSystem/tasks/Factory.hpp" +#include "mappings/simulation/EnvironmentController.hpp" +#include "memory/buffers/Exchange.hpp" namespace PMacc { @@ -147,6 +146,3 @@ namespace PMacc } //namespace PMacc - -#endif /* _TASKRECEIVE_HPP */ - diff --git a/src/libPMacc/include/eventSystem/tasks/TaskReceiveMPI.hpp b/src/libPMacc/include/eventSystem/tasks/TaskReceiveMPI.hpp index 47a51df661..1088379a1f 100644 --- a/src/libPMacc/include/eventSystem/tasks/TaskReceiveMPI.hpp +++ b/src/libPMacc/include/eventSystem/tasks/TaskReceiveMPI.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera, Wolfgang Hoenig + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Wolfgang Hoenig, + * Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,18 +21,14 @@ * If not, see . */ -#ifndef TASKRECEIVEMPI_HPP -#define TASKRECEIVEMPI_HPP - -#include - -#include "memory/buffers/Exchange.hpp" - -#include "eventSystem/tasks/MPITask.hpp" +#pragma once #include "communication/manager_common.h" #include "communication/ICommunicator.hpp" +#include "eventSystem/tasks/MPITask.hpp" +#include "memory/buffers/Exchange.hpp" +#include namespace PMacc { @@ -114,5 +111,3 @@ class TaskReceiveMPI : public MPITask } //namespace PMacc -#endif /* TASKRECEIVEMPI_HPP */ - diff --git a/src/libPMacc/include/eventSystem/tasks/TaskSend.hpp b/src/libPMacc/include/eventSystem/tasks/TaskSend.hpp index 3f33e3e51e..d56600fdbc 100644 --- a/src/libPMacc/include/eventSystem/tasks/TaskSend.hpp +++ b/src/libPMacc/include/eventSystem/tasks/TaskSend.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera, Wolfgang Hoenig + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Wolfgang Hoenig, + * Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,20 +21,17 @@ * If not, see . */ +#pragma once -#ifndef _TASKSEND_HPP -#define _TASKSEND_HPP - -#include - -#include "memory/buffers/Exchange.hpp" -#include "eventSystem/EventSystem.hpp" - +#include "eventSystem/tasks/Factory.hpp" #include "eventSystem/tasks/ITask.hpp" #include "eventSystem/tasks/TaskReceive.hpp" #include "eventSystem/tasks/TaskCopyDeviceToHost.hpp" +#include "eventSystem/EventSystem.hpp" #include "mappings/simulation/EnvironmentController.hpp" -#include "eventSystem/tasks/Factory.hpp" +#include "memory/buffers/Exchange.hpp" + +#include namespace PMacc { @@ -132,10 +130,8 @@ namespace PMacc DeviceToHostFinished, SendDone, Finish - }; - Exchange *exchange; EventTask& copyEvent; state_t state; @@ -143,5 +139,3 @@ namespace PMacc } //namespace PMacc -#endif /* _TASKSEND_HPP */ - diff --git a/src/libPMacc/include/eventSystem/tasks/TaskSendMPI.hpp b/src/libPMacc/include/eventSystem/tasks/TaskSendMPI.hpp index f15ff8da61..8765d61252 100644 --- a/src/libPMacc/include/eventSystem/tasks/TaskSendMPI.hpp +++ b/src/libPMacc/include/eventSystem/tasks/TaskSendMPI.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera, Wolfgang Hoenig + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Wolfgang Hoenig, + * Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,17 +21,14 @@ * If not, see . */ -#ifndef TASKSENDMPI_HPP -#define TASKSENDMPI_HPP - -#include - -#include "memory/buffers/Exchange.hpp" - -#include "eventSystem/tasks/MPITask.hpp" +#pragma once #include "communication/manager_common.h" #include "communication/ICommunicator.hpp" +#include "eventSystem/tasks/MPITask.hpp" +#include "memory/buffers/Exchange.hpp" + +#include namespace PMacc { @@ -103,5 +101,3 @@ class TaskSendMPI : public MPITask } //namespace PMacc -#endif /* TASKSENDMPI_HPP */ - diff --git a/src/libPMacc/include/eventSystem/tasks/TaskSetCurrentSizeOnDevice.hpp b/src/libPMacc/include/eventSystem/tasks/TaskSetCurrentSizeOnDevice.hpp index 657518d209..c09232cacd 100644 --- a/src/libPMacc/include/eventSystem/tasks/TaskSetCurrentSizeOnDevice.hpp +++ b/src/libPMacc/include/eventSystem/tasks/TaskSetCurrentSizeOnDevice.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,19 +20,16 @@ * If not, see . */ - -#ifndef _TASKSETCURRENTSIZEONDEVICE_HPP -#define _TASKSETCURRENTSIZEONDEVICE_HPP - -#include -#include - -#include "dimensions/DataSpace.hpp" +#pragma once #include "eventSystem/EventSystem.hpp" #include "eventSystem/streams/EventStream.hpp" #include "eventSystem/tasks/StreamTask.hpp" #include "eventSystem/events/kernelEvents.hpp" +#include "dimensions/DataSpace.hpp" + +#include +#include __global__ void kernelSetValueOnDeviceMemory(size_t* pointer, const size_t size) { @@ -98,6 +95,3 @@ class TaskSetCurrentSizeOnDevice : public StreamTask } //namespace PMacc - -#endif /* _TASKSETCURRENTSIZEONDEVICE_HPP */ - diff --git a/src/libPMacc/include/eventSystem/tasks/TaskSetValue.hpp b/src/libPMacc/include/eventSystem/tasks/TaskSetValue.hpp index a086e73db9..5a1a2aa013 100644 --- a/src/libPMacc/include/eventSystem/tasks/TaskSetValue.hpp +++ b/src/libPMacc/include/eventSystem/tasks/TaskSetValue.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013-2014 Felix Schmitt, Heiko Burau, Rene Widera + * Copyright 2013-2015 Felix Schmitt, Heiko Burau, Rene Widera, + * Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -22,21 +23,19 @@ #pragma once -#include -#include - -#include "memory/buffers/DeviceBuffer.hpp" #include "dimensions/DataSpace.hpp" +#include "mappings/simulation/EnvironmentController.hpp" +#include "memory/buffers/DeviceBuffer.hpp" #include "memory/boxes/DataBox.hpp" - #include "eventSystem/EventSystem.hpp" -#include "memory/buffers/DeviceBuffer.hpp" #include "eventSystem/tasks/StreamTask.hpp" -#include "mappings/simulation/EnvironmentController.hpp" #include #include +#include +#include + namespace PMacc { namespace taskSetValueHelper diff --git a/src/libPMacc/include/eventSystem/transactions/Transaction.hpp b/src/libPMacc/include/eventSystem/transactions/Transaction.hpp index 4de286d654..d4f6edcd4f 100644 --- a/src/libPMacc/include/eventSystem/transactions/Transaction.hpp +++ b/src/libPMacc/include/eventSystem/transactions/Transaction.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,14 +20,10 @@ * If not, see . */ - -#ifndef TRANSACTION_HPP -#define TRANSACTION_HPP +#pragma once #include "eventSystem/EventSystem.hpp" - - namespace PMacc { @@ -84,6 +80,3 @@ class Transaction } - -#endif /* TRANSACTION_HPP */ - diff --git a/src/libPMacc/include/eventSystem/transactions/Transaction.tpp b/src/libPMacc/include/eventSystem/transactions/Transaction.tpp index 1cc79540e5..b29d6dd38a 100644 --- a/src/libPMacc/include/eventSystem/transactions/Transaction.tpp +++ b/src/libPMacc/include/eventSystem/transactions/Transaction.tpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Rene Widera + * Copyright 2013-2015 Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -19,12 +19,12 @@ * and the GNU Lesser General Public License along with libPMacc. * If not, see . */ + +#include "eventSystem/transactions/Transaction.hpp" #include "eventSystem/streams/StreamController.hpp" #include "eventSystem/events/EventTask.hpp" #include "eventSystem/tasks/StreamTask.hpp" -#include "Transaction.hpp" - namespace PMacc { diff --git a/src/libPMacc/include/eventSystem/transactions/TransactionManager.hpp b/src/libPMacc/include/eventSystem/transactions/TransactionManager.hpp index 1d8049882d..3b2aef0c33 100644 --- a/src/libPMacc/include/eventSystem/transactions/TransactionManager.hpp +++ b/src/libPMacc/include/eventSystem/transactions/TransactionManager.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -22,10 +22,11 @@ #pragma once -#include #include "eventSystem/EventSystem.hpp" #include "eventSystem/transactions/Transaction.hpp" +#include + namespace PMacc { // forward declaration diff --git a/src/libPMacc/include/eventSystem/transactions/TransactionManager.tpp b/src/libPMacc/include/eventSystem/transactions/TransactionManager.tpp index 4e151a4015..3b9fd9e346 100644 --- a/src/libPMacc/include/eventSystem/transactions/TransactionManager.tpp +++ b/src/libPMacc/include/eventSystem/transactions/TransactionManager.tpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -19,9 +19,10 @@ * and the GNU Lesser General Public License along with libPMacc. * If not, see . */ + +#include "eventSystem/EventSystem.hpp" #include -#include "eventSystem/EventSystem.hpp" namespace PMacc { diff --git a/src/libPMacc/include/fields/SimulationFieldHelper.hpp b/src/libPMacc/include/fields/SimulationFieldHelper.hpp index 575a059f06..68b1b28baa 100644 --- a/src/libPMacc/include/fields/SimulationFieldHelper.hpp +++ b/src/libPMacc/include/fields/SimulationFieldHelper.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera + * Copyright 2013, 2015 Felix Schmitt, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,8 +20,7 @@ * If not, see . */ -#ifndef SIMULATIONFIELDHELPER_HPP -#define SIMULATIONFIELDHELPER_HPP +#pragma once #include "dimensions/GridLayout.hpp" #include "eventSystem/EventSystem.hpp" @@ -63,6 +62,3 @@ class SimulationFieldHelper }; } //namespace PMacc - -#endif /* SIMULATIONFIELDHELPER_HPP */ - diff --git a/src/libPMacc/include/forward.hpp b/src/libPMacc/include/forward.hpp index 42e8cf5a7b..aa299a88c3 100644 --- a/src/libPMacc/include/forward.hpp +++ b/src/libPMacc/include/forward.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/identifier/alias.hpp b/src/libPMacc/include/identifier/alias.hpp index 1d3a2bbbe6..4121759099 100644 --- a/src/libPMacc/include/identifier/alias.hpp +++ b/src/libPMacc/include/identifier/alias.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/identifier/identifier.hpp b/src/libPMacc/include/identifier/identifier.hpp index 3790321e89..adbe4f147d 100644 --- a/src/libPMacc/include/identifier/identifier.hpp +++ b/src/libPMacc/include/identifier/identifier.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -22,7 +22,6 @@ #pragma once - #include "types.h" /* No namespace is needed because we only have defines*/ @@ -33,7 +32,7 @@ #define PMACC_PLACEHOLDER(id) using namespace PMACC_JOIN(host_placeholder,id) #endif -/*define special makros for creating classes which are ony used as identifer*/ +/*define special macros for creating classes which are only used as identifier*/ #define PMACC_identifier(name,id,...) \ namespace PMACC_JOIN(placeholder_definition,id) { \ struct name{ \ @@ -51,7 +50,7 @@ /** create an identifier (identifier with arbitrary code as second parameter - * !! second parameter is optinal and can be any C++ code one can add inside a class + * !! second parameter is optional and can be any C++ code one can add inside a class * * example: identifier(varname); //create type varname * example: identifier(varname,typedef int type;); //create type varname, diff --git a/src/libPMacc/include/identifier/named_type.hpp b/src/libPMacc/include/identifier/named_type.hpp index 7a7fb00a55..e2e7d120c1 100644 --- a/src/libPMacc/include/identifier/named_type.hpp +++ b/src/libPMacc/include/identifier/named_type.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/identifier/value_identifier.hpp b/src/libPMacc/include/identifier/value_identifier.hpp index 02d13e8184..0ee52f46ec 100644 --- a/src/libPMacc/include/identifier/value_identifier.hpp +++ b/src/libPMacc/include/identifier/value_identifier.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/lambda/CT/Eval.hpp b/src/libPMacc/include/lambda/CT/Eval.hpp index 26b099c0aa..3195ebf16e 100644 --- a/src/libPMacc/include/lambda/CT/Eval.hpp +++ b/src/libPMacc/include/lambda/CT/Eval.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/lambda/CT/Expression.hpp b/src/libPMacc/include/lambda/CT/Expression.hpp index 4ab3f30e1d..6a716c6949 100644 --- a/src/libPMacc/include/lambda/CT/Expression.hpp +++ b/src/libPMacc/include/lambda/CT/Expression.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/lambda/CT/FillTerminalList.hpp b/src/libPMacc/include/lambda/CT/FillTerminalList.hpp index f97ca95cd2..2822681655 100644 --- a/src/libPMacc/include/lambda/CT/FillTerminalList.hpp +++ b/src/libPMacc/include/lambda/CT/FillTerminalList.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/lambda/CT/TerminalTL.hpp b/src/libPMacc/include/lambda/CT/TerminalTL.hpp index dfe731f73b..78b0023668 100644 --- a/src/libPMacc/include/lambda/CT/TerminalTL.hpp +++ b/src/libPMacc/include/lambda/CT/TerminalTL.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/lambda/ExprTypes.h b/src/libPMacc/include/lambda/ExprTypes.h index 4af04f33b9..3ce95ee3e9 100644 --- a/src/libPMacc/include/lambda/ExprTypes.h +++ b/src/libPMacc/include/lambda/ExprTypes.h @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/lambda/Expression.hpp b/src/libPMacc/include/lambda/Expression.hpp index 579c327c2c..d2e63bff85 100644 --- a/src/libPMacc/include/lambda/Expression.hpp +++ b/src/libPMacc/include/lambda/Expression.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/lambda/ProxyClass.hpp b/src/libPMacc/include/lambda/ProxyClass.hpp index afd6ad5848..382ed38c08 100644 --- a/src/libPMacc/include/lambda/ProxyClass.hpp +++ b/src/libPMacc/include/lambda/ProxyClass.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/lambda/is_Expression.hpp b/src/libPMacc/include/lambda/is_Expression.hpp index 6429fd828e..c5821140b1 100644 --- a/src/libPMacc/include/lambda/is_Expression.hpp +++ b/src/libPMacc/include/lambda/is_Expression.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/lambda/make_Expr.hpp b/src/libPMacc/include/lambda/make_Expr.hpp index 3c95fa92bb..4a9c4b3bfb 100644 --- a/src/libPMacc/include/lambda/make_Expr.hpp +++ b/src/libPMacc/include/lambda/make_Expr.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/lambda/make_Functor.hpp b/src/libPMacc/include/lambda/make_Functor.hpp index 4e0d043dea..144314f8f9 100644 --- a/src/libPMacc/include/lambda/make_Functor.hpp +++ b/src/libPMacc/include/lambda/make_Functor.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/lambda/placeholder.h b/src/libPMacc/include/lambda/placeholder.h index d1e706b8e6..4778f3a99d 100644 --- a/src/libPMacc/include/lambda/placeholder.h +++ b/src/libPMacc/include/lambda/placeholder.h @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/mappings/kernel/AreaMapping.hpp b/src/libPMacc/include/mappings/kernel/AreaMapping.hpp index 121629c965..5ce356d952 100644 --- a/src/libPMacc/include/mappings/kernel/AreaMapping.hpp +++ b/src/libPMacc/include/mappings/kernel/AreaMapping.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Felix Schmitt, Heiko Burau, Rene Widera + * Copyright 2013-2015 Felix Schmitt, Heiko Burau, Rene Widera * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,8 +20,8 @@ * If not, see . */ -#ifndef AREAMAPPING_H -#define AREAMAPPING_H + +#pragma once #include "types.h" #include "dimensions/DataSpace.hpp" @@ -57,35 +57,29 @@ namespace PMacc } /** - * Generates cuda gridDim information for kernel call. + * Generate grid dimension information for kernel calls * - * @return dim3 with gridDim information + * @return size of the grid */ - HINLINE DataSpace getGridDim() + HINLINE DataSpace getGridDim() const { - return this->reduce(AreaMappingMethods::getGridDim(*this, - this->getGridSuperCells())); + return AreaMappingMethods::getGridDim(*this, + this->getGridSuperCells()); } /** - * Returns index of current logical block, depending on current cuda block id. + * Returns index of current logical block * - * @param _blockIdx current cuda block id (blockIdx) - * @return current logical block index + * @param realSuperCellIdx current SuperCell index (block index) + * @return mapped SuperCell index */ - DINLINE DataSpace getSuperCellIndex(const DataSpace& realSuperCellIdx) + HDINLINE DataSpace getSuperCellIndex(const DataSpace& realSuperCellIdx) const { return AreaMappingMethods::getBlockIndex(*this, this->getGridSuperCells(), - extend(realSuperCellIdx)); + realSuperCellIdx); } }; - } // namespace PMacc - - - -#endif /* AREAMAPPING_H */ - diff --git a/src/libPMacc/include/mappings/kernel/AreaMappingMethods.hpp b/src/libPMacc/include/mappings/kernel/AreaMappingMethods.hpp index af8e1a3e27..8bcde3cf12 100644 --- a/src/libPMacc/include/mappings/kernel/AreaMappingMethods.hpp +++ b/src/libPMacc/include/mappings/kernel/AreaMappingMethods.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,8 +20,7 @@ * If not, see . */ -#ifndef AREAMAPPINGMETHODS_H -#define AREAMAPPINGMETHODS_H +#pragma once #include "types.h" #include "dimensions/DataSpace.hpp" @@ -313,8 +312,4 @@ namespace PMacc } }; -} - - -#endif /* AREAMAPPINGMETHODS_H */ - +} //namespace PMacc diff --git a/src/libPMacc/include/mappings/kernel/CudaGridDimRestrictions.hpp b/src/libPMacc/include/mappings/kernel/CudaGridDimRestrictions.hpp deleted file mode 100644 index caa4fa7332..0000000000 --- a/src/libPMacc/include/mappings/kernel/CudaGridDimRestrictions.hpp +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Copyright 2013 Felix Schmitt, Heiko Burau, Rene Widera - * - * This file is part of libPMacc. - * - * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or - * the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * libPMacc is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with libPMacc. - * If not, see . - */ - -#ifndef CUDAGRIDDIMRESTRICTIONS_HPP -#define CUDAGRIDDIMRESTRICTIONS_HPP - -#include "types.h" -#include -#include "dimensions/DataSpace.hpp" - -namespace PMacc -{ - -/*! Handles cuda restriction that gridDim.z() != 1 is not allowed - */ -template -class CudaGridDimRestrictions -{ -protected: - /*! Create a mapping of any gridDim to a allowed gridDim where gridDim.z() =1 - * @param value a gridDim - * @return a valid cuda gridDim as DataSpace - */ - HDINLINE DataSpace reduce(const DataSpace &value); - - /*! Is the toward operation of reduce - * - call this with cuda blockIdx than the real 3D block index is returned - * - call this with cuda gridDim than the real 3D grid dimension is returnd - * @param value a gridDim - * @return gridDim whith size before reduce was called. - */ - HDINLINE DataSpace extend(const DataSpace &value); -}; - -template<> -class CudaGridDimRestrictions -{ -protected: - - HDINLINE DataSpace reduce(const DataSpace &value) - { - return value; - } - - HDINLINE DataSpace extend(const DataSpace &value) - { - return value; - } -}; - -template<> -class CudaGridDimRestrictions -{ -protected: - - CudaGridDimRestrictions() - : z(1) - { - } - - HDINLINE DataSpace reduce(const DataSpace &value) - { - z = value.z(); - return DataSpace (value.x() * z, value.y(), 1); - } - - HDINLINE DataSpace extend(const DataSpace &value) - { - return DataSpace (value.x() / z, value.y(), value.x() % z); - } -private: - - PMACC_ALIGN(z, int); - - -}; - -} // namespace PMacc - - - -#endif /* CUDAGRIDDIMRESTRICTIONS_HPP */ - diff --git a/src/libPMacc/include/mappings/kernel/ExchangeMapping.hpp b/src/libPMacc/include/mappings/kernel/ExchangeMapping.hpp index 9adb63b93b..b4c67412f9 100644 --- a/src/libPMacc/include/mappings/kernel/ExchangeMapping.hpp +++ b/src/libPMacc/include/mappings/kernel/ExchangeMapping.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Felix Schmitt, Heiko Burau, Rene Widera + * Copyright 2013-2015 Felix Schmitt, Heiko Burau, Rene Widera * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,8 +20,8 @@ * If not, see . */ -#ifndef EXCHANGEMAPPING_H -#define EXCHANGEMAPPING_H + +#pragma once #include "types.h" #include "dimensions/DataSpace.hpp" @@ -34,7 +34,7 @@ namespace PMacc class ExchangeMapping; /** - * Allows mapping CUDA thread/block indizes to a specific region in a DataSpace + * Allows mapping thread/block indices to a specific region in a DataSpace * defined by a valid ExchangeType combination. * * @tparam areaType are to map to @@ -82,35 +82,29 @@ namespace PMacc } /** - * Generates cuda gridDim information for kernel call. + * Generate grid dimension information for kernel calls * - * @return DataSpace with gridDim information + * @return size of the grid */ - HINLINE DataSpace getGridDim() + HINLINE DataSpace getGridDim() const { - return this->reduce(ExchangeMappingMethods::getGridDim(*this, exchangeType)); + return ExchangeMappingMethods::getGridDim(*this, exchangeType); } /** - * Returns index of current logical block, depending on current cuda block id. + * Returns index of current logical block * - * @param _blockIdx current cuda block id (blockIdx) - * @return current logical block index + * @param realSuperCellIdx current SuperCell index (block index) + * @return mapped SuperCell index */ - DINLINE DataSpace getSuperCellIndex(const DataSpace& realSuperCellIdx) + HDINLINE DataSpace getSuperCellIndex(const DataSpace& realSuperCellIdx) const { return ExchangeMappingMethods::getBlockIndex( *this, - extend(realSuperCellIdx), + realSuperCellIdx, exchangeType); } }; - } // namespace PMacc - - - -#endif /* EXCHANGEMAPPING_H */ - diff --git a/src/libPMacc/include/mappings/kernel/ExchangeMappingMethods.hpp b/src/libPMacc/include/mappings/kernel/ExchangeMappingMethods.hpp index 3dc43e1daa..9a79d6b212 100644 --- a/src/libPMacc/include/mappings/kernel/ExchangeMappingMethods.hpp +++ b/src/libPMacc/include/mappings/kernel/ExchangeMappingMethods.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,8 +20,8 @@ * If not, see . */ -#ifndef EXCHANGEMAPPINGMETHODS_H -#define EXCHANGEMAPPINGMETHODS_H + +#pragma once #include "types.h" #include "dimensions/DataSpace.hpp" @@ -315,8 +315,5 @@ namespace PMacc return result; } }; -} - - -#endif /* EXCHANGEMAPPINGMETHODS_H */ +}//namespace PMacc diff --git a/src/libPMacc/include/mappings/kernel/MappingDescription.hpp b/src/libPMacc/include/mappings/kernel/MappingDescription.hpp index 407c59b8b3..27888bbf29 100644 --- a/src/libPMacc/include/mappings/kernel/MappingDescription.hpp +++ b/src/libPMacc/include/mappings/kernel/MappingDescription.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -22,28 +22,25 @@ #pragma once -#include #include #include "dimensions/DataSpace.hpp" #include "dimensions/DataSpaceOperations.hpp" #include "mappings/simulation/GridController.hpp" #include "dimensions/GridLayout.hpp" -#include "mappings/kernel/CudaGridDimRestrictions.hpp" #include "math/Vector.hpp" namespace PMacc { /** - * Abstracts logical block information from cuda block variables. + * Abstracts logical block information from block variables. * * @tparam DIM dimension for grid/blocks * @tparam SuperCellSize mapper class for logical grid information */ template -class MappingDescription : -public CudaGridDimRestrictions +class MappingDescription { public: @@ -97,7 +94,7 @@ public CudaGridDimRestrictions * @param globaOffset cells * @return global index of the root supercell */ - HINLINE DataSpace getRootSuperCellCoordinate(const DataSpace globalOffset) + HINLINE DataSpace getRootSuperCellCoordinate(const DataSpace globalOffset) const { return globalOffset/SuperCellSize::toRT(); } diff --git a/src/libPMacc/include/mappings/kernel/StrideMapping.hpp b/src/libPMacc/include/mappings/kernel/StrideMapping.hpp index 4cfe9e41d0..32a190455e 100644 --- a/src/libPMacc/include/mappings/kernel/StrideMapping.hpp +++ b/src/libPMacc/include/mappings/kernel/StrideMapping.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Felix Schmitt, Heiko Burau, Rene Widera + * Copyright 2013-2015 Felix Schmitt, Heiko Burau, Rene Widera * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,11 +20,10 @@ * If not, see . */ -#ifndef STRIDEMAPPING_H -#define STRIDEMAPPING_H + +#pragma once #include "types.h" -#include #include "dimensions/DataSpace.hpp" #include "mappings/kernel/StrideMappingMethods.hpp" #include "dimensions/DataSpaceOperations.hpp" @@ -60,28 +59,28 @@ class StrideMapping > : public } /** - * Generates cuda gridDim information for kernel call. + * Generate grid dimension information for kernel calls * - * @return dim3 with gridDim information + * @return size of the grid */ - HINLINE DataSpace getGridDim() + HINLINE DataSpace getGridDim() const { - return this->reduce((StrideMappingMethods::getGridDim(*this) - offset + (int)Stride - 1) / (int)Stride); + return (StrideMappingMethods::getGridDim(*this) - offset + (int)Stride - 1) / (int)Stride; } /** - * Returns index of current logical block, depending on current cuda block id. + * Returns index of current logical block * - * @param _blockIdx current cuda block id (blockIdx) - * @return current logical block index + * @param realSuperCellIdx current SuperCell index (block index) + * @return mapped SuperCell index */ - DINLINE DataSpace getSuperCellIndex(const DataSpace& realSuperCellIdx) + HDINLINE DataSpace getSuperCellIndex(const DataSpace& realSuperCellIdx) const { - const DataSpace blockId((extend(realSuperCellIdx) * (int)Stride) + offset); + const DataSpace blockId((realSuperCellIdx * (int)Stride) + offset); return StrideMappingMethods::shift(*this, blockId); } - HDINLINE DataSpace getOffset() + HDINLINE DataSpace getOffset() const { return offset; } @@ -91,6 +90,10 @@ class StrideMapping > : public this->offset = offset; } + /** set mapper to next domain + * + * @return true if domain is valid, else false + */ HINLINE bool next() { int linearOffset = DataSpaceOperations::map(DataSpace::create(stride), offset); @@ -105,10 +108,4 @@ class StrideMapping > : public }; - } // namespace PMacc - - - -#endif /* STRIDEMAPPING_H */ - diff --git a/src/libPMacc/include/mappings/kernel/StrideMappingMethods.hpp b/src/libPMacc/include/mappings/kernel/StrideMappingMethods.hpp index 943a5f5a57..c027d2112f 100644 --- a/src/libPMacc/include/mappings/kernel/StrideMappingMethods.hpp +++ b/src/libPMacc/include/mappings/kernel/StrideMappingMethods.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -21,8 +21,7 @@ */ -#ifndef STRIDEMAPPINGMETHODS_H -#define STRIDEMAPPINGMETHODS_H +#pragma once #include "types.h" #include "dimensions/DataSpace.hpp" @@ -101,11 +100,4 @@ namespace PMacc } }; - - - -} - - -#endif /* AREAMAPPINGMETHODS_H */ - +} //namespace PMacc diff --git a/src/libPMacc/include/mappings/simulation/EnvironmentController.hpp b/src/libPMacc/include/mappings/simulation/EnvironmentController.hpp index b8cdd4bd9d..3e6169e97c 100644 --- a/src/libPMacc/include/mappings/simulation/EnvironmentController.hpp +++ b/src/libPMacc/include/mappings/simulation/EnvironmentController.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Rene Widera, Wolfgang Hoenig + * Copyright 2013, 2015 Rene Widera, Wolfgang Hoenig, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,9 +20,7 @@ * If not, see . */ - -#ifndef _ENVIRONMENTCONTROLLER_HPP -#define _ENVIRONMENTCONTROLLER_HPP +#pragma once #include "memory/dataTypes/Mask.hpp" @@ -90,7 +88,3 @@ class EnvironmentController }; } //namespace PMacc - - -#endif /* _ENVIRONMENTCONTROLLER_HPP */ - diff --git a/src/libPMacc/include/mappings/simulation/Filesystem.hpp b/src/libPMacc/include/mappings/simulation/Filesystem.hpp index 0722146c20..2636037395 100644 --- a/src/libPMacc/include/mappings/simulation/Filesystem.hpp +++ b/src/libPMacc/include/mappings/simulation/Filesystem.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/mappings/simulation/GridController.hpp b/src/libPMacc/include/mappings/simulation/GridController.hpp index 884991902e..7b2df135b6 100644 --- a/src/libPMacc/include/mappings/simulation/GridController.hpp +++ b/src/libPMacc/include/mappings/simulation/GridController.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013 Axel Huebl, Felix Schmitt, Rene Widera, Wolfgang Hoenig + * Copyright 2013, 2015 Axel Huebl, Felix Schmitt, Rene Widera, + * Wolfgang Hoenig, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,10 +21,7 @@ * If not, see . */ - -#ifndef _GRIDCONTROLLER_HPP -#define _GRIDCONTROLLER_HPP - +#pragma once #include "dimensions/DataSpace.hpp" #include "dimensions/DataSpaceOperations.hpp" @@ -291,8 +289,3 @@ namespace PMacc CommunicatorMPI GridController::comm; } //namespace PMacc - - - -#endif /* _GRIDCONTROLLER_HPP */ - diff --git a/src/libPMacc/include/mappings/simulation/Selection.hpp b/src/libPMacc/include/mappings/simulation/Selection.hpp index 017783fc2e..15a0b6e258 100644 --- a/src/libPMacc/include/mappings/simulation/Selection.hpp +++ b/src/libPMacc/include/mappings/simulation/Selection.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/mappings/simulation/SubGrid.hpp b/src/libPMacc/include/mappings/simulation/SubGrid.hpp index 65e2e7e8a7..e336cf3426 100644 --- a/src/libPMacc/include/mappings/simulation/SubGrid.hpp +++ b/src/libPMacc/include/mappings/simulation/SubGrid.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/mappings/threads/ThreadCollective.hpp b/src/libPMacc/include/mappings/threads/ThreadCollective.hpp index 1badef1ac8..4f832c6850 100644 --- a/src/libPMacc/include/mappings/threads/ThreadCollective.hpp +++ b/src/libPMacc/include/mappings/threads/ThreadCollective.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013-2014 Heiko Burau, Rene Widera + * Copyright 2013-2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -23,10 +23,10 @@ #pragma once -#include "types.h" -#include "dimensions/DataSpace.hpp" -#include "dimensions/DataSpaceOperations.hpp" #include "dimensions/SuperCellDescription.hpp" +#include "dimensions/DataSpaceOperations.hpp" +#include "dimensions/DataSpace.hpp" +#include "types.h" namespace PMacc { diff --git a/src/libPMacc/include/math/Complex.hpp b/src/libPMacc/include/math/Complex.hpp index 858df7d4ba..21d64c0c5b 100644 --- a/src/libPMacc/include/math/Complex.hpp +++ b/src/libPMacc/include/math/Complex.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/math/ConstVector.hpp b/src/libPMacc/include/math/ConstVector.hpp index cc7a0b7876..0df8edfdf0 100644 --- a/src/libPMacc/include/math/ConstVector.hpp +++ b/src/libPMacc/include/math/ConstVector.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2014 Rene Widera + * Copyright 2014, 2015 Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -22,9 +22,9 @@ #pragma once -#include "types.h" -#include "math/vector/Vector.tpp" +#include "math/vector/Vector.hpp" #include "ppFunctions.hpp" +#include "types.h" /* select namespace depending on __CUDA_ARCH__ compiler flag*/ #ifdef __CUDA_ARCH__ //we are on gpu @@ -33,11 +33,14 @@ #define PMACC_USING_STATIC_CONST_VECTOR_NAMESPACE(id) using namespace PMACC_JOIN(pmacc_static_const_vector_host,id) #endif -/** @see PMACC_CONST_VECTOR documentation, only unique "id" is added +/** define a const vector + * + * create type definition `Name_t` + * @see PMACC_CONST_VECTOR documentation, only unique "id" is added * * @param id unique precompiler id to create unique namespaces */ -#define PMACC_STATIC_CONST_VECTOR_DIM(id,Name,Type,Dim,count,...) \ +#define PMACC_STATIC_CONST_VECTOR_DIM_DEF(id,Name,Type,Dim,count,...) \ namespace PMACC_JOIN(pmacc_static_const_storage,id) \ { \ namespace PMACC_JOIN(pmacc_static_const_vector_device,id) \ @@ -55,6 +58,7 @@ namespace PMACC_JOIN(pmacc_static_const_storage,id) \ template \ struct ConstArrayStorage \ { \ + static const bool isConst = true; \ typedef T_Type type; \ static const int dim=T_Dim; \ HDINLINE type& operator[](const int idx) \ @@ -64,7 +68,7 @@ namespace PMACC_JOIN(pmacc_static_const_storage,id) \ } \ HDINLINE const type& operator[](const int idx) const \ { \ - /*access const C array with the name of array*/ \ + /*access const C array with the name of array*/ \ return PMACC_JOIN(Name,_data)[idx]; \ } \ }; \ @@ -75,6 +79,14 @@ namespace PMACC_JOIN(pmacc_static_const_storage,id) \ PMacc::math::StandartAccessor, \ PMacc::math::StandartNavigator, \ ConstArrayStorage > PMACC_JOIN(Name,_t); \ +} /* namespace pmacc_static_const_storage + id */ \ +using namespace PMACC_JOIN(pmacc_static_const_storage,id) + +/** create a instance of type `Name_t` with the name `Name` + */ +#define PMACC_STATIC_CONST_VECTOR_DIM_INSTANCE(id,Name,Type,Dim,count,...) \ +namespace PMACC_JOIN(pmacc_static_const_storage,id) \ +{ \ namespace PMACC_JOIN(pmacc_static_const_vector_device,id) \ { \ /* create const instance on device */ \ @@ -85,10 +97,26 @@ namespace PMACC_JOIN(pmacc_static_const_storage,id) \ /* create const instance on host*/ \ const PMACC_JOIN(Name,_t) Name; \ } /* namespace pmacc_static_const_vector_host + id */ \ -} /* namespace pmacc_static_const_storage + id */ \ -using namespace PMACC_JOIN(pmacc_static_const_storage,id) +} /* namespace pmacc_static_const_storage + id */ + +/** @see PMACC_CONST_VECTOR documentation, only unique "id" is added + * + * @param id unique precompiler id to create unique namespaces + */ +#define PMACC_STATIC_CONST_VECTOR_DIM(id,Name,Type,Dim,count,...) \ + PMACC_STATIC_CONST_VECTOR_DIM_DEF(id,Name,Type,Dim,count,__VA_ARGS__); \ + PMACC_STATIC_CONST_VECTOR_DIM_INSTANCE(id,Name,Type,Dim,count,__VA_ARGS__) +/** define a const vector + * + * for description @see PMACC_CONST_VECTOR + * + * create type definition `name_t` + */ +#define PMACC_CONST_VECTOR_DEF(type,dim,name,...) \ + PMACC_STATIC_CONST_VECTOR_DIM_DEF(__COUNTER__,name,type,dim,PMACC_COUNT_ARGS(__VA_ARGS__),__VA_ARGS__) + /** Create global constant math::Vector with compile time values which can be * used on device and host * @@ -107,4 +135,3 @@ using namespace PMACC_JOIN(pmacc_static_const_storage,id) */ #define PMACC_CONST_VECTOR(type,dim,name,...) \ PMACC_STATIC_CONST_VECTOR_DIM(__COUNTER__,name,type,dim,PMACC_COUNT_ARGS(__VA_ARGS__),__VA_ARGS__) - diff --git a/src/libPMacc/include/math/MapTuple.hpp b/src/libPMacc/include/math/MapTuple.hpp index 12ee15307a..b96357f4b5 100644 --- a/src/libPMacc/include/math/MapTuple.hpp +++ b/src/libPMacc/include/math/MapTuple.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -130,11 +130,11 @@ Map_, typename mpl::deref::type>::type::first>::type, typedef typename mpl::at::type& type; // typedef typename mpl::at::type& type2; }; - + template struct result { - + typedef const typename mpl::at::type& type; }; /* diff --git a/src/libPMacc/include/math/Tuple.hpp b/src/libPMacc/include/math/Tuple.hpp index 8abbfd07c9..abd2b79c5e 100644 --- a/src/libPMacc/include/math/Tuple.hpp +++ b/src/libPMacc/include/math/Tuple.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/math/Vector.hpp b/src/libPMacc/include/math/Vector.hpp index fa99025efa..88b67733a1 100644 --- a/src/libPMacc/include/math/Vector.hpp +++ b/src/libPMacc/include/math/Vector.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/math/VectorOperations.hpp b/src/libPMacc/include/math/VectorOperations.hpp index f9daf461c8..f1b70417a7 100644 --- a/src/libPMacc/include/math/VectorOperations.hpp +++ b/src/libPMacc/include/math/VectorOperations.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/math/complex/Complex.hpp b/src/libPMacc/include/math/complex/Complex.hpp index 44104453ff..9020b2fe77 100644 --- a/src/libPMacc/include/math/complex/Complex.hpp +++ b/src/libPMacc/include/math/complex/Complex.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -36,10 +36,10 @@ struct Complex // constructor (real, imaginary) HDINLINE Complex(T_Type real, T_Type imaginary = type(0.0) ) : real(real), imaginary(imaginary) { } - + // constructor (Complex) template - HDINLINE explicit Complex(const Complex& other) : + HDINLINE explicit Complex(const Complex& other) : real( static_cast (other.get_real()) ), imaginary( static_cast (other.get_imag()) ) { } @@ -96,17 +96,17 @@ struct Complex { return imaginary; } - + // complex zero HDINLINE static Complex zero(void) { return Complex( type(0.0) , type(0.0) ); } - + private: PMACC_ALIGN(real,T_Type); // real part PMACC_ALIGN(imaginary,T_Type); // imaginary part - + }; /** Addition operators */ diff --git a/src/libPMacc/include/math/complex/Complex.tpp b/src/libPMacc/include/math/complex/Complex.tpp index d4f5ddc09b..2922f6a08c 100644 --- a/src/libPMacc/include/math/complex/Complex.tpp +++ b/src/libPMacc/include/math/complex/Complex.tpp @@ -1,10 +1,11 @@ /** - * Copyright 2013-2015 Heiko Burau, Rene Widera, Richard Pausch, Alexander Debus + * Copyright 2013-2015 Heiko Burau, Rene Widera, Richard Pausch, + * Alexander Debus, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -22,10 +23,11 @@ #pragma once -#include -#include "math/Complex.hpp" #include "algorithms/math.hpp" #include "algorithms/TypeCast.hpp" +#include "math/Complex.hpp" + +#include namespace PMacc { @@ -59,12 +61,12 @@ template struct Euler { typedef typename ::PMacc::math::Complex result; - + HDINLINE result operator( )(const T_Type &magnitude, const T_Type &phase) { return result(magnitude * pmMath::cos(phase),magnitude * pmMath::sin(phase)); } - + HDINLINE result operator( )(const T_Type &magnitude, const T_Type &sinValue, const T_Type &cosValue) { @@ -78,7 +80,7 @@ template struct Sqrt< ::PMacc::math::Complex > { typedef typename ::PMacc::math::Complex result; - typedef T_Type type; + typedef T_Type type; HDINLINE result operator( )(const ::PMacc::math::Complex& other) { @@ -99,7 +101,7 @@ struct Exp< ::PMacc::math::Complex > { typedef typename ::PMacc::math::Complex result; typedef T_Type type; - + HDINLINE result operator( )(const ::PMacc::math::Complex& other) { return pmMath::euler(type(1.0),other.get_imag())*pmMath::exp(other.get_real()); @@ -123,7 +125,7 @@ struct Arg< ::PMacc::math::Complex > { typedef typename ::PMacc::math::Complex::type result; typedef T_Type type; - + HDINLINE result operator( )(const ::PMacc::math::Complex& other) { if ( other.get_real()==type(0.0) && other.get_imag()==type(0.0) ) @@ -145,7 +147,7 @@ struct Pow< ::PMacc::math::Complex, T_Type > { typedef typename ::PMacc::math::Complex result; typedef T_Type type; - + HDINLINE result operator( )(const ::PMacc::math::Complex& other, const T_Type& exponent) { @@ -172,7 +174,7 @@ template struct Abs2< ::PMacc::math::Complex > { typedef typename ::PMacc::math::Complex::type result; - + HDINLINE result operator( )(const ::PMacc::math::Complex& other) { return pmMath::abs2(other.get_real()) + pmMath::abs2(other.get_imag()); diff --git a/src/libPMacc/include/math/vector/Float.hpp b/src/libPMacc/include/math/vector/Float.hpp index c881896c55..eac1ed1b8c 100644 --- a/src/libPMacc/include/math/vector/Float.hpp +++ b/src/libPMacc/include/math/vector/Float.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/math/vector/Int.hpp b/src/libPMacc/include/math/vector/Int.hpp index 7cd3428456..114d8ba265 100644 --- a/src/libPMacc/include/math/vector/Int.hpp +++ b/src/libPMacc/include/math/vector/Int.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/math/vector/Size_t.hpp b/src/libPMacc/include/math/vector/Size_t.hpp index 554616360e..64d019df49 100644 --- a/src/libPMacc/include/math/vector/Size_t.hpp +++ b/src/libPMacc/include/math/vector/Size_t.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/math/vector/UInt32.hpp b/src/libPMacc/include/math/vector/UInt32.hpp index 184c194352..0ea529dfe3 100644 --- a/src/libPMacc/include/math/vector/UInt32.hpp +++ b/src/libPMacc/include/math/vector/UInt32.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/math/vector/UInt64.hpp b/src/libPMacc/include/math/vector/UInt64.hpp index c2ae29f543..30a6bdaa3e 100644 --- a/src/libPMacc/include/math/vector/UInt64.hpp +++ b/src/libPMacc/include/math/vector/UInt64.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/math/vector/Vector.hpp b/src/libPMacc/include/math/vector/Vector.hpp index 6abe87117d..b0fc5359bf 100644 --- a/src/libPMacc/include/math/vector/Vector.hpp +++ b/src/libPMacc/include/math/vector/Vector.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013-2014 Heiko Burau, Rene Widera + * Copyright 2013-2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -22,16 +22,16 @@ #pragma once +#include +#include +#include #include "result_of_Functor.hpp" -#include -#include -#include +#include "static_assert.hpp" +#include "types.h" + #include -#include + #include -#include -#include -#include namespace PMacc { @@ -43,6 +43,7 @@ namespace detail template struct Vector_components { + static const bool isConst = false; static const int dim = T_Dim; typedef T_Type type; @@ -62,11 +63,47 @@ struct Vector_components } }; + +/** functor to copy a object element wise + * + * @tparam isDestConst define if destination is const (not copyable) object + */ +template +struct CopyElementWise +{ + /** copy object element wise + * + * @tparam T_Dest destination object type + * @tparam T_Src source object type + */ + template + HDINLINE void operator()(T_Dest& dest,const T_Src& src) const + { + PMACC_CASSERT_MSG(CopyElementWise_destination_and_source_had_different_dimension, + T_Dest::dim == T_Src::dim); + for (int d = 0; d < T_Dest::dim; d++) + dest[d] = src[d]; + } +}; + +/** specialization for constant destination + * + * the constant storage is already available and set in the destination + */ +template<> +struct CopyElementWise +{ + template + HDINLINE void operator()(T_Dest& dest,const T_Src& src) const + { + } +}; + } //namespace detail namespace tag { -struct Vector; + struct Vector; } template, protected T_Accessor, protecte }; HDINLINE Vector() + {} + + HDINLINE + Vector(const type x) { + PMACC_CASSERT_MSG(math_Vector__constructor_is_only_allowed_for_DIM1,dim == 1); + (*this)[0] = x; } HDINLINE @@ -121,17 +164,9 @@ struct Vector : private T_Storage, protected T_Accessor, protecte (*this)[2] = z; } - HDINLINE - Vector(const T_Type& value) - { - for (int i = 0; i < dim; i++) - (*this)[i] = value; - } - HDINLINE Vector(const This& other) { - for (int i = 0; i < dim; i++) - (*this)[i] = other[i]; + detail::CopyElementWise()(*this,other); } template< @@ -152,6 +187,22 @@ struct Vector : private T_Storage, protected T_Accessor, protecte (*this)[i] = static_cast (other[i]); } + /** + * Creates a Vector where all dimensions are set to the same value + * + * @param value Value which is set for all dimensions + * @return new Vector<...> + */ + HDINLINE + static This create(const type& value) + { + This result; + for (int i = 0; i < dim; i++) + result[i] = value; + + return result; + } + HDINLINE const This& toRT() const { return *this; @@ -162,6 +213,15 @@ struct Vector : private T_Storage, protected T_Accessor, protecte return *this; } + HDINLINE This revert() + { + This invertedVector; + for (int i = 0; i < dim; i++) + invertedVector[dim-1-i] = (*this)[i]; + + return invertedVector; + } + template< typename T_OtherAccessor, typename T_OtherNavigator, diff --git a/src/libPMacc/include/math/vector/Vector.tpp b/src/libPMacc/include/math/vector/Vector.tpp index d745d92e59..0b74b7df8a 100644 --- a/src/libPMacc/include/math/vector/Vector.tpp +++ b/src/libPMacc/include/math/vector/Vector.tpp @@ -1,10 +1,10 @@ /** - * Copyright 2013-2014 Axel Huebl, Heiko Burau, Rene Widera + * Copyright 2013-2015 Axel Huebl, Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -27,10 +27,10 @@ #include "math/Vector.hpp" #include "algorithms/math.hpp" #include "algorithms/TypeCast.hpp" +#include "algorithms/PromoteType.hpp" #include "mpi/GetMPI_StructAsArray.hpp" #include "traits/GetComponentsType.hpp" #include "traits/GetNComponents.hpp" -#include "algorithms/PromoteType.hpp" namespace PMacc { diff --git a/src/libPMacc/include/math/vector/accessor/StandartAccessor.hpp b/src/libPMacc/include/math/vector/accessor/StandartAccessor.hpp index 3efa6b08c1..f46415d177 100644 --- a/src/libPMacc/include/math/vector/accessor/StandartAccessor.hpp +++ b/src/libPMacc/include/math/vector/accessor/StandartAccessor.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013, 2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -22,6 +22,8 @@ #pragma once +#include "types.h" + namespace PMacc { namespace math diff --git a/src/libPMacc/include/math/vector/compile-time/Float.hpp b/src/libPMacc/include/math/vector/compile-time/Float.hpp index b9f558168c..06aa090da5 100644 --- a/src/libPMacc/include/math/vector/compile-time/Float.hpp +++ b/src/libPMacc/include/math/vector/compile-time/Float.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/math/vector/compile-time/Int.hpp b/src/libPMacc/include/math/vector/compile-time/Int.hpp index a9cefd6d68..9657018947 100644 --- a/src/libPMacc/include/math/vector/compile-time/Int.hpp +++ b/src/libPMacc/include/math/vector/compile-time/Int.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/math/vector/compile-time/Size_t.hpp b/src/libPMacc/include/math/vector/compile-time/Size_t.hpp index fb75018a99..934f6f584f 100644 --- a/src/libPMacc/include/math/vector/compile-time/Size_t.hpp +++ b/src/libPMacc/include/math/vector/compile-time/Size_t.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/math/vector/compile-time/UInt32.hpp b/src/libPMacc/include/math/vector/compile-time/UInt32.hpp index f23dde1112..56c51d19a2 100644 --- a/src/libPMacc/include/math/vector/compile-time/UInt32.hpp +++ b/src/libPMacc/include/math/vector/compile-time/UInt32.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/math/vector/compile-time/UInt64.hpp b/src/libPMacc/include/math/vector/compile-time/UInt64.hpp index 7b124eaaad..909721ed7d 100644 --- a/src/libPMacc/include/math/vector/compile-time/UInt64.hpp +++ b/src/libPMacc/include/math/vector/compile-time/UInt64.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/math/vector/compile-time/Vector.hpp b/src/libPMacc/include/math/vector/compile-time/Vector.hpp index 3faab7a7a3..9dbc0b9bbe 100644 --- a/src/libPMacc/include/math/vector/compile-time/Vector.hpp +++ b/src/libPMacc/include/math/vector/compile-time/Vector.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013-2014 Heiko Burau, Rene Widera + * Copyright 2013-2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -22,8 +22,6 @@ #pragma once -#include "types.h" -#include #include #include #include @@ -37,6 +35,9 @@ #include #include #include "math/Vector.hpp" +#include "types.h" + +#include namespace PMacc { @@ -97,7 +98,14 @@ struct VectorFromCT<3> template struct TypeSelector { - typedef typename Arg0::value_type type; + typedef Arg0 type; +}; + +/** get integral type*/ +template +struct TypeSelector > +{ + typedef T type; }; template<> @@ -145,8 +153,7 @@ struct Vector /** Create a runtime Vector * - * Creates the corresponding runtime vector - * object + * Creates the corresponding runtime vector object. * * \return RT_type runtime vector with same value type */ diff --git a/src/libPMacc/include/math/vector/math_functor/abs.hpp b/src/libPMacc/include/math/vector/math_functor/abs.hpp new file mode 100644 index 0000000000..cff977ec02 --- /dev/null +++ b/src/libPMacc/include/math/vector/math_functor/abs.hpp @@ -0,0 +1,62 @@ +/** + * Copyright 2013, 2015 Heiko Burau, Rene Widera, Richard Pausch + * + * This file is part of libPMacc. + * + * libPMacc is free software: you can redistribute it and/or modify + * it under the terms of of either the GNU General Public License or + * the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * libPMacc is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with libPMacc. + * If not, see . + */ + +#pragma once + +#include "types.h" +#include "lambda/Expression.hpp" +#include "algorithms/math/defines/abs.hpp" + +namespace PMacc +{ +namespace math +{ +namespace math_functor +{ + +struct Abs +{ + template + HDINLINE + Type operator()(const Type& x) const + { + return algorithms::math::abs(x); + } +}; + +lambda::Expression > _abs; + +} // math_vector +} // math + +namespace result_of +{ + +template +struct Functor +{ + typedef Type type; +}; + +} // result_of + +} // PMacc diff --git a/src/libPMacc/include/math/vector/math_functor/cosf.hpp b/src/libPMacc/include/math/vector/math_functor/cosf.hpp index c3511887e6..3a1e618880 100644 --- a/src/libPMacc/include/math/vector/math_functor/cosf.hpp +++ b/src/libPMacc/include/math/vector/math_functor/cosf.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013, 2015 Heiko Burau, Rene Widera, Richard Pausch * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,11 +20,11 @@ * If not, see . */ -#ifndef MATH_FUNCTOR_COSF_HPP -#define MATH_FUNCTOR_COSF_HPP +#pragma once #include "types.h" #include "lambda/Expression.hpp" +#include "algorithms/math/defines/trigo.hpp" namespace PMacc { @@ -37,9 +37,9 @@ struct Cosf { typedef float result_type; - DINLINE float operator()(const float& value) const + DINLINE result_type operator()(const result_type& value) const { - return __cosf(value); + return algorithms::math::cos(value); } }; @@ -49,4 +49,3 @@ lambda::Expression > _cosf; } // math } // PMacc -#endif // MATH_FUNCTOR_COSF_HPP diff --git a/src/libPMacc/include/math/vector/math_functor/max.hpp b/src/libPMacc/include/math/vector/math_functor/max.hpp index a27f397740..71391a232d 100644 --- a/src/libPMacc/include/math/vector/math_functor/max.hpp +++ b/src/libPMacc/include/math/vector/math_functor/max.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013, 2015 Heiko Burau, Rene Widera * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,12 +20,11 @@ * If not, see . */ -#ifndef MATH_FUNCTOR_MAX_HPP -#define MATH_FUNCTOR_MAX_HPP - +#pragma once #include "types.h" #include "lambda/Expression.hpp" +#include "algorithms/math/defines/comparison.hpp" namespace PMacc { @@ -40,7 +39,7 @@ struct Max HDINLINE Type operator()(const Type& a, const Type& b) const { - return max(a,b); + return algorithms::math::max(a,b); } }; @@ -61,5 +60,3 @@ struct Functor } // result_of } // PMacc - -#endif // MATH_FUNCTOR_MAX_HPP diff --git a/src/libPMacc/include/math/vector/math_functor/min.hpp b/src/libPMacc/include/math/vector/math_functor/min.hpp index 3713d8e33f..72db83e1cb 100644 --- a/src/libPMacc/include/math/vector/math_functor/min.hpp +++ b/src/libPMacc/include/math/vector/math_functor/min.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013, 2015 Heiko Burau, Rene Widera, Richard Pausch * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,12 +20,12 @@ * If not, see . */ -#ifndef MATH_FUNCTOR_MIN_HPP -#define MATH_FUNCTOR_MIN_HPP +#pragma once #include "types.h" #include "lambda/Expression.hpp" +#include "algorithms/math/defines/comparison.hpp" namespace PMacc { @@ -40,7 +40,7 @@ struct Min HDINLINE Type operator()(const Type& a, const Type& b) const { - return min(a,b); + return algorithms::math::min(a,b); } }; @@ -62,4 +62,3 @@ struct Functor } // PMacc -#endif // MATH_FUNCTOR_MIN_HPP diff --git a/src/libPMacc/include/math/vector/math_functor/sin.hpp b/src/libPMacc/include/math/vector/math_functor/sin.hpp new file mode 100644 index 0000000000..6298113b2f --- /dev/null +++ b/src/libPMacc/include/math/vector/math_functor/sin.hpp @@ -0,0 +1,53 @@ +/** + * Copyright 2013, 2015 Heiko Burau, Rene Widera, Richard Pausch + * + * This file is part of libPMacc. + * + * libPMacc is free software: you can redistribute it and/or modify + * it under the terms of either the GNU General Public License or + * the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * libPMacc is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with libPMacc. + * If not, see . + */ + +#pragma once + +#include "types.h" +#include "lambda/Expression.hpp" +#include "algorithms/math/defines/trigo.hpp" + +namespace PMacc +{ +namespace math +{ +namespace math_functor +{ + +template +struct Sin +{ + typedef T_Type result_type; + + DINLINE result_type operator()(const result_type& value) const + { + return algorithms::math::sin(value); + } +}; + +lambda::Expression> > _sinf; +lambda::Expression> > _sind; + +} // math_functor +} // math +} // PMacc + diff --git a/src/libPMacc/include/math/vector/math_functor/sqrtf.hpp b/src/libPMacc/include/math/vector/math_functor/sqrtf.hpp index 194b4a7564..edfedc6791 100644 --- a/src/libPMacc/include/math/vector/math_functor/sqrtf.hpp +++ b/src/libPMacc/include/math/vector/math_functor/sqrtf.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013, 2015 Heiko Burau, Rene Widera, Richard Pausch * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,11 +20,11 @@ * If not, see . */ -#ifndef MATH_FUNCTOR_SQRTF_HPP -#define MATH_FUNCTOR_SQRTF_HPP +#pragma once #include "types.h" #include "lambda/Expression.hpp" +#include "algorithms/math/defines/sqrt.hpp" namespace PMacc { @@ -37,9 +37,9 @@ struct Sqrtf { typedef float result_type; - HDINLINE float operator()(const float& value) const + HDINLINE result_type operator()(const result_type& value) const { - return __sqrtf(value); + return algorithms::math::sqrt(value); } }; @@ -49,4 +49,3 @@ lambda::Expression > _sqrtf; } // math } // PMacc -#endif // MATH_FUNCTOR_SQRTF_HPP diff --git a/src/libPMacc/include/math/vector/navigator/PermutedNavigator.hpp b/src/libPMacc/include/math/vector/navigator/PermutedNavigator.hpp index 72cba7f47e..40d08209d3 100644 --- a/src/libPMacc/include/math/vector/navigator/PermutedNavigator.hpp +++ b/src/libPMacc/include/math/vector/navigator/PermutedNavigator.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013, 2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -22,6 +22,8 @@ #pragma once +#include "types.h" + namespace PMacc { namespace math diff --git a/src/libPMacc/include/math/vector/navigator/StackedNavigator.hpp b/src/libPMacc/include/math/vector/navigator/StackedNavigator.hpp index a355e95dc3..5cc72207a2 100644 --- a/src/libPMacc/include/math/vector/navigator/StackedNavigator.hpp +++ b/src/libPMacc/include/math/vector/navigator/StackedNavigator.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2014 Heiko Burau, Rene Widera + * Copyright 2014, 2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -22,6 +22,8 @@ #pragma once +#include "types.h" + namespace PMacc { namespace math diff --git a/src/libPMacc/include/math/vector/navigator/StandartNavigator.hpp b/src/libPMacc/include/math/vector/navigator/StandartNavigator.hpp index 0ed7f7dcb3..73ab7bc456 100644 --- a/src/libPMacc/include/math/vector/navigator/StandartNavigator.hpp +++ b/src/libPMacc/include/math/vector/navigator/StandartNavigator.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013, 2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -22,6 +22,8 @@ #pragma once +#include "types.h" + namespace PMacc { namespace math diff --git a/src/libPMacc/include/math/vector/tools/twistVectorAxes.hpp b/src/libPMacc/include/math/vector/tools/twistVectorAxes.hpp index 68352345b5..904b2bbd3d 100644 --- a/src/libPMacc/include/math/vector/tools/twistVectorAxes.hpp +++ b/src/libPMacc/include/math/vector/tools/twistVectorAxes.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/memory/boxes/CachedBox.hpp b/src/libPMacc/include/memory/boxes/CachedBox.hpp index 0e4aea0dca..2d6125a3b1 100644 --- a/src/libPMacc/include/memory/boxes/CachedBox.hpp +++ b/src/libPMacc/include/memory/boxes/CachedBox.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/memory/boxes/DataBox.hpp b/src/libPMacc/include/memory/boxes/DataBox.hpp index e804abb367..75d48aeca9 100644 --- a/src/libPMacc/include/memory/boxes/DataBox.hpp +++ b/src/libPMacc/include/memory/boxes/DataBox.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013 Felix Schmitt, Heiko Burau, Rene Widera, Wolfgang Hoenig + * Copyright 2013, 2015 Felix Schmitt, Heiko Burau, Rene Widera, + * Wolfgang Hoenig, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,9 +21,7 @@ * If not, see . */ - -#ifndef _DATABOX_HPP -#define _DATABOX_HPP +#pragma once #include "types.h" #include "dimensions/DataSpace.hpp" @@ -164,5 +163,3 @@ namespace PMacc }; } - -#endif /* _DATABOX_HPP */ diff --git a/src/libPMacc/include/memory/boxes/DataBoxDim1Access.hpp b/src/libPMacc/include/memory/boxes/DataBoxDim1Access.hpp index 3dfb9eb279..1ee2b6be25 100644 --- a/src/libPMacc/include/memory/boxes/DataBoxDim1Access.hpp +++ b/src/libPMacc/include/memory/boxes/DataBoxDim1Access.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/memory/boxes/DataBoxUnaryTransform.hpp b/src/libPMacc/include/memory/boxes/DataBoxUnaryTransform.hpp index 7b8f0b5ec0..a324c16cab 100644 --- a/src/libPMacc/include/memory/boxes/DataBoxUnaryTransform.hpp +++ b/src/libPMacc/include/memory/boxes/DataBoxUnaryTransform.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/memory/boxes/MultiBox.hpp b/src/libPMacc/include/memory/boxes/MultiBox.hpp index 601047cb13..92fc07861e 100644 --- a/src/libPMacc/include/memory/boxes/MultiBox.hpp +++ b/src/libPMacc/include/memory/boxes/MultiBox.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -57,8 +57,8 @@ class MutiBoxAccess } private: - const PMACC_ALIGN(ptr, char*); const PMACC_ALIGN(offset, size_t); + const PMACC_ALIGN(ptr, char*); }; }//namespace MutiBoxAccass @@ -127,8 +127,8 @@ class MultiBox protected: - PMACC_ALIGN(fixedPointer, Type*); PMACC_ALIGN(attributePitch, size_t); + PMACC_ALIGN(fixedPointer, Type*); }; template @@ -195,9 +195,9 @@ class MultiBox protected: - PMACC_ALIGN(fixedPointer, Type*); PMACC_ALIGN(pitch, size_t); PMACC_ALIGN(attributePitch, size_t); + PMACC_ALIGN(fixedPointer, Type*); }; template @@ -255,10 +255,10 @@ class MultiBox } - PMACC_ALIGN(fixedPointer, Type*); PMACC_ALIGN(pitch, size_t); PMACC_ALIGN(pitch2D, size_t); PMACC_ALIGN(attributePitch, size_t); + PMACC_ALIGN(fixedPointer, Type*); }; diff --git a/src/libPMacc/include/memory/boxes/PitchedBox.hpp b/src/libPMacc/include/memory/boxes/PitchedBox.hpp index 639f96870c..cfab6818b2 100644 --- a/src/libPMacc/include/memory/boxes/PitchedBox.hpp +++ b/src/libPMacc/include/memory/boxes/PitchedBox.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -156,8 +156,8 @@ class PitchedBox protected: - PMACC_ALIGN(fixedPointer, TYPE*); PMACC_ALIGN(pitch, size_t); + PMACC_ALIGN(fixedPointer, TYPE*); }; @@ -213,7 +213,7 @@ class PitchedBox { return fixedPointer; } - + HDINLINE PMacc::cursor::BufferCursor toCursor() const { @@ -232,9 +232,9 @@ class PitchedBox } - PMACC_ALIGN(fixedPointer, TYPE*); PMACC_ALIGN(pitch, size_t); PMACC_ALIGN(pitch2D, size_t); + PMACC_ALIGN(fixedPointer, TYPE*); }; diff --git a/src/libPMacc/include/memory/boxes/SharedBox.hpp b/src/libPMacc/include/memory/boxes/SharedBox.hpp index f8d507d3cf..583d103365 100644 --- a/src/libPMacc/include/memory/boxes/SharedBox.hpp +++ b/src/libPMacc/include/memory/boxes/SharedBox.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013-2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -22,13 +22,10 @@ #pragma once -#include "types.h" -#include "math/Vector.hpp" - - #include #include - +#include +#include "types.h" namespace PMacc { @@ -56,8 +53,8 @@ class SharedBox typedef T_TYPE ValueType; typedef ValueType& RefValueType; typedef T_Vector Size; - typedef SharedBox, T_id > ReducedType; - typedef SharedBox This; + typedef SharedBox, T_id> ReducedType; + typedef SharedBox This; HDINLINE RefValueType operator[](const int idx) { diff --git a/src/libPMacc/include/memory/buffers/Buffer.hpp b/src/libPMacc/include/memory/buffers/Buffer.hpp index fdd7dd2424..68d31eb78f 100644 --- a/src/libPMacc/include/memory/buffers/Buffer.hpp +++ b/src/libPMacc/include/memory/buffers/Buffer.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013-2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,18 +20,16 @@ * If not, see . */ +#pragma once -#ifndef _BUFFER_HPP -#define _BUFFER_HPP - -#include -#include - -#include "types.h" #include "dimensions/DataSpace.hpp" #include "memory/boxes/DataBox.hpp" #include "memory/boxes/PitchedBox.hpp" #include "Environment.hpp" +#include "types.h" + +#include +#include namespace PMacc { @@ -193,6 +191,3 @@ namespace PMacc }; } //namespace PMacc - -#endif /* _BUFFER_HPP */ - diff --git a/src/libPMacc/include/memory/buffers/DeviceBuffer.hpp b/src/libPMacc/include/memory/buffers/DeviceBuffer.hpp index 03128b7003..51e442b640 100644 --- a/src/libPMacc/include/memory/buffers/DeviceBuffer.hpp +++ b/src/libPMacc/include/memory/buffers/DeviceBuffer.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013-2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,24 +20,19 @@ * If not, see . */ +#pragma once -#ifndef _DEVICEBUFFER_HPP -#define _DEVICEBUFFER_HPP - -#include -#include -#include - - -#include "memory/buffers/Buffer.hpp" - - +#include #include -#include #include #include -#include "cuSTL/container/view/View.hpp" +#include +#include + +#include +#include +#include namespace PMacc { @@ -170,6 +165,3 @@ namespace PMacc }; } //namespace PMacc - - -#endif /* _DEVICEBUFFER_HPP */ diff --git a/src/libPMacc/include/memory/buffers/DeviceBufferIntern.hpp b/src/libPMacc/include/memory/buffers/DeviceBufferIntern.hpp index a29847296f..feb32d420d 100644 --- a/src/libPMacc/include/memory/buffers/DeviceBufferIntern.hpp +++ b/src/libPMacc/include/memory/buffers/DeviceBufferIntern.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Axel Huebl, Heiko Burau, Rene Widera + * Copyright 2013-2015 Axel Huebl, Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,17 +20,14 @@ * If not, see . */ - -#ifndef _DEVICEBUFFERINTERN_HPP -#define _DEVICEBUFFERINTERN_HPP - -#include +#pragma once #include "dimensions/DataSpace.hpp" +#include "eventSystem/tasks/Factory.hpp" #include "memory/buffers/DeviceBuffer.hpp" #include "memory/boxes/DataBox.hpp" -#include "eventSystem/tasks/Factory.hpp" +#include namespace PMacc { @@ -327,5 +324,3 @@ class DeviceBufferIntern : public DeviceBuffer }; } //namespace PMacc - -#endif /* _DEVICEBUFFERINTERN_HPP */ diff --git a/src/libPMacc/include/memory/buffers/Exchange.hpp b/src/libPMacc/include/memory/buffers/Exchange.hpp index 5af7e969b9..9f12abfb83 100644 --- a/src/libPMacc/include/memory/buffers/Exchange.hpp +++ b/src/libPMacc/include/memory/buffers/Exchange.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Rene Widera + * Copyright 2013-2015 Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,9 +20,7 @@ * If not, see . */ - -#ifndef _EXCHANGE_HPP -#define _EXCHANGE_HPP +#pragma once #include "memory/buffers/DeviceBuffer.hpp" #include "memory/buffers/HostBuffer.hpp" @@ -98,6 +96,3 @@ namespace PMacc }; } - -#endif /* _EXCHANGE_HPP */ - diff --git a/src/libPMacc/include/memory/buffers/ExchangeIntern.hpp b/src/libPMacc/include/memory/buffers/ExchangeIntern.hpp index 740d07beb5..e61721a4c4 100644 --- a/src/libPMacc/include/memory/buffers/ExchangeIntern.hpp +++ b/src/libPMacc/include/memory/buffers/ExchangeIntern.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Rene Widera + * Copyright 2013-2015 Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,24 +20,21 @@ * If not, see . */ +#pragma once - -#ifndef _EXCHANGEINTERN_HPP -#define _EXCHANGEINTERN_HPP - -#include - -#include "types.h" -#include "memory/buffers/Exchange.hpp" -#include "memory/dataTypes/Mask.hpp" #include "dimensions/GridLayout.hpp" #include "mappings/simulation/GridController.hpp" +#include "memory/buffers/Exchange.hpp" +#include "memory/dataTypes/Mask.hpp" +#include "memory/buffers/DeviceBufferIntern.hpp" +#include "memory/buffers/HostBufferIntern.hpp" #include "eventSystem/tasks/Factory.hpp" #include "eventSystem/tasks/TaskReceive.hpp" -#include "memory/buffers/DeviceBufferIntern.hpp" -#include "memory/buffers/HostBufferIntern.hpp" +#include "types.h" + +#include namespace PMacc { @@ -241,6 +238,3 @@ namespace PMacc }; } - -#endif /* _EXCHANGEINTERN_HPP */ - diff --git a/src/libPMacc/include/memory/buffers/GridBuffer.hpp b/src/libPMacc/include/memory/buffers/GridBuffer.hpp index 913e9ab09f..5955553afe 100644 --- a/src/libPMacc/include/memory/buffers/GridBuffer.hpp +++ b/src/libPMacc/include/memory/buffers/GridBuffer.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Rene Widera + * Copyright 2013-2015 Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,24 +20,19 @@ * If not, see . */ +#pragma once -#ifndef _GRIDBUFFER_HPP -#define _GRIDBUFFER_HPP - -#include - -#include "eventSystem/EventSystem.hpp" #include "dimensions/GridLayout.hpp" -#include "memory/dataTypes/Mask.hpp" - +#include "eventSystem/EventSystem.hpp" #include "mappings/simulation/EnvironmentController.hpp" +#include "memory/dataTypes/Mask.hpp" #include "memory/buffers/ExchangeIntern.hpp" #include "memory/buffers/HostBufferIntern.hpp" #include "memory/buffers/DeviceBufferIntern.hpp" #include #include - +#include #include namespace PMacc @@ -557,6 +552,3 @@ class GridBuffer }; } - -#endif /* _GRIDBUFFER_HPP */ - diff --git a/src/libPMacc/include/memory/buffers/HostBuffer.hpp b/src/libPMacc/include/memory/buffers/HostBuffer.hpp index da666b3a27..7cfb39c2f2 100644 --- a/src/libPMacc/include/memory/buffers/HostBuffer.hpp +++ b/src/libPMacc/include/memory/buffers/HostBuffer.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Rene Widera + * Copyright 2013-2015 Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,14 +20,11 @@ * If not, see . */ +#pragma once #include "memory/buffers/Buffer.hpp" #include "dimensions/DataSpace.hpp" - -#ifndef _HOSTBUFFER_HPP -#define _HOSTBUFFER_HPP - namespace PMacc { @@ -86,6 +83,3 @@ namespace PMacc }; } //namespace PMacc - - -#endif /* _HOSTBUFFER_HPP */ diff --git a/src/libPMacc/include/memory/buffers/HostBufferIntern.hpp b/src/libPMacc/include/memory/buffers/HostBufferIntern.hpp index 509446f97e..ee1935c9ca 100644 --- a/src/libPMacc/include/memory/buffers/HostBufferIntern.hpp +++ b/src/libPMacc/include/memory/buffers/HostBufferIntern.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Rene Widera + * Copyright 2013-2015 Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,16 +20,13 @@ * If not, see . */ - -#ifndef _HOSTBUFFERINTERN_HPP -#define _HOSTBUFFERINTERN_HPP - -#include +#pragma once #include "memory/buffers/Buffer.hpp" +#include "eventSystem/tasks/Factory.hpp" #include "eventSystem/EventSystem.hpp" -#include "eventSystem/tasks/Factory.hpp" +#include namespace PMacc { @@ -129,6 +126,3 @@ class HostBufferIntern : public HostBuffer }; } - -#endif /* _HOSTBUFFERINTERN_HPP */ - diff --git a/src/libPMacc/include/memory/buffers/MappedBufferIntern.hpp b/src/libPMacc/include/memory/buffers/MappedBufferIntern.hpp index 4d8ca44cb1..b9ab453ddd 100644 --- a/src/libPMacc/include/memory/buffers/MappedBufferIntern.hpp +++ b/src/libPMacc/include/memory/buffers/MappedBufferIntern.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2014 Rene Widera, Axel Huebl + * Copyright 2014-2015 Rene Widera, Axel Huebl, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,16 +20,14 @@ * If not, see . */ - #pragma once -#include - +#include "eventSystem/EventSystem.hpp" +#include "eventSystem/tasks/Factory.hpp" #include "memory/buffers/Buffer.hpp" #include "memory/buffers/DeviceBuffer.hpp" -#include "eventSystem/EventSystem.hpp" -#include "eventSystem/tasks/Factory.hpp" +#include namespace PMacc { diff --git a/src/libPMacc/include/memory/buffers/MultiGridBuffer.hpp b/src/libPMacc/include/memory/buffers/MultiGridBuffer.hpp index c54941d5cb..29562c357d 100644 --- a/src/libPMacc/include/memory/buffers/MultiGridBuffer.hpp +++ b/src/libPMacc/include/memory/buffers/MultiGridBuffer.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013-2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,23 +20,21 @@ * If not, see . */ - #pragma once -#include - #include "dimensions/DataSpace.hpp" -#include "eventSystem/EventSystem.hpp" #include "dimensions/GridLayout.hpp" -#include "memory/dataTypes/Mask.hpp" - +#include "eventSystem/EventSystem.hpp" #include "mappings/simulation/EnvironmentController.hpp" +#include "memory/dataTypes/Mask.hpp" #include "memory/buffers/ExchangeIntern.hpp" #include "memory/buffers/HostBufferIntern.hpp" #include "memory/buffers/DeviceBufferIntern.hpp" #include "memory/buffers/GridBuffer.hpp" #include "memory/boxes/MultiBox.hpp" +#include + namespace PMacc { diff --git a/src/libPMacc/include/memory/dataTypes/BitData.hpp b/src/libPMacc/include/memory/dataTypes/BitData.hpp index a518f5e4e6..b5a4c63e95 100644 --- a/src/libPMacc/include/memory/dataTypes/BitData.hpp +++ b/src/libPMacc/include/memory/dataTypes/BitData.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013, 2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,11 +20,7 @@ * If not, see . */ - - -#ifndef BITDATA_HPP -#define BITDATA_HPP - +#pragma once #include "types.h" @@ -205,6 +201,3 @@ namespace PMacc } - -#endif /* BITDATA_HPP */ - diff --git a/src/libPMacc/include/memory/dataTypes/Mask.hpp b/src/libPMacc/include/memory/dataTypes/Mask.hpp index f9b19ae8b7..b679453dad 100644 --- a/src/libPMacc/include/memory/dataTypes/Mask.hpp +++ b/src/libPMacc/include/memory/dataTypes/Mask.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -224,8 +224,31 @@ namespace PMacc return (ExchangeType) tmp; } + /** translate direction to relative offset + * + * direction (combination of `ExchangeType`'s) e.g. TOP, TOP+LEFT, ... @see types.h + * are translated to a relative offsets were any dimension is + * set to -1,0,1 + * - `-1` if contains LEFT, BOTTOM or FRONT + * - `+1` if contains RIGHT, TOP or BACK + * - `0` else + * + * @param direction combination which describe a direction (only one direction) + * @return DataSpace with relative offsets + */ template - static HDINLINE DataSpace getRelativeDirections(const uint32_t ex) ; + static HDINLINE DataSpace getRelativeDirections( uint32_t direction) + { + DataSpace tmp; + + for( uint32_t d = 0; d < DIM; ++d ) + { + const int dim_direction(direction % 3); + tmp[d] = (dim_direction == 2 ? -1 : dim_direction); + direction /= 3; + } + return tmp; + } protected: @@ -236,83 +259,14 @@ namespace PMacc }; + /** special implementation for `DIM1` + * + * optimization: no modulo is used + */ template<> - HDINLINE DataSpace Mask::getRelativeDirections(const uint32_t ex) - { - switch (ex) - { - case RIGHT: - return DataSpace (1); - case LEFT: - return DataSpace (-1); - default: - return DataSpace (0); - } - } - - template<> - HDINLINE DataSpace Mask::getRelativeDirections(const uint32_t ex) - { - DataSpace tmp; - - switch (ex % 3) - { - case RIGHT: - tmp.x() = 1; - break; - case LEFT: - tmp.x() = -1; - break; - } - - switch (ex / 3) - { - case 1: /*BOTTOM*/ - tmp.y() = 1; - break; - case 2: /*TOP*/ - tmp.y() = -1; - break; - } - return tmp; - } - - template<> - HDINLINE DataSpace Mask::getRelativeDirections(const uint32_t ex) + HDINLINE DataSpace Mask::getRelativeDirections( uint32_t direction) { - DataSpace tmp; - - switch (ex % 3) - { - case RIGHT: - tmp.x() = 1; - break; - case LEFT: - tmp.x() = -1; - break; - } - - switch (ex / 3 % 3) - { - case 1: /*BOTTOM*/ - tmp.y() = 1; - break; - case 2: /*TOP*/ - tmp.y() = -1; - break; - } - - switch (ex / 3 / 3) - { - case 1: /*BACK*/ - tmp.z() = 1; - break; - case 2: /*FRONT*/ - tmp.z() = -1; - break; - } - - return tmp; + return (direction == 2 ? DataSpace (-1) : DataSpace (direction)); } } diff --git a/src/libPMacc/include/mpi/GetMPI_Op.hpp b/src/libPMacc/include/mpi/GetMPI_Op.hpp index 7bfb4d8a0e..c01eaf4672 100644 --- a/src/libPMacc/include/mpi/GetMPI_Op.hpp +++ b/src/libPMacc/include/mpi/GetMPI_Op.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Rene Widera + * Copyright 2013, 2015 Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,8 +20,7 @@ * If not, see . */ -#ifndef GETMPI_OP_HPP -#define GETMPI_OP_HPP +#pragma once #include "types.h" #include @@ -35,6 +34,3 @@ namespace PMacc MPI_Op getMPI_Op(); } } - -#endif /* GETMPI_OP_HPP */ - diff --git a/src/libPMacc/include/mpi/GetMPI_StructAsArray.hpp b/src/libPMacc/include/mpi/GetMPI_StructAsArray.hpp index 527d9567af..582db57a27 100644 --- a/src/libPMacc/include/mpi/GetMPI_StructAsArray.hpp +++ b/src/libPMacc/include/mpi/GetMPI_StructAsArray.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/mpi/GetMPI_StructAsArray.tpp b/src/libPMacc/include/mpi/GetMPI_StructAsArray.tpp index 86b1198c8a..43e726e706 100644 --- a/src/libPMacc/include/mpi/GetMPI_StructAsArray.tpp +++ b/src/libPMacc/include/mpi/GetMPI_StructAsArray.tpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/mpi/MPIReduce.hpp b/src/libPMacc/include/mpi/MPIReduce.hpp index e1477ccdd6..dd1586b48c 100644 --- a/src/libPMacc/include/mpi/MPIReduce.hpp +++ b/src/libPMacc/include/mpi/MPIReduce.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/mpi/MPI_StructAsArray.hpp b/src/libPMacc/include/mpi/MPI_StructAsArray.hpp index 029924515f..74df3f7402 100644 --- a/src/libPMacc/include/mpi/MPI_StructAsArray.hpp +++ b/src/libPMacc/include/mpi/MPI_StructAsArray.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Rene Widera + * Copyright 2013, 2015 Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,10 +20,10 @@ * If not, see . */ -#ifndef MPI_STRUCTASARRAY_HPP -#define MPI_STRUCTASARRAY_HPP +#pragma once #include "types.h" + #include namespace PMacc @@ -41,6 +41,3 @@ namespace PMacc }; } } - -#endif /* MPI_STRUCTASARRAY_HPP */ - diff --git a/src/libPMacc/include/mpi/reduceMethods/AllReduce.hpp b/src/libPMacc/include/mpi/reduceMethods/AllReduce.hpp index 24d334717d..0fffd80877 100644 --- a/src/libPMacc/include/mpi/reduceMethods/AllReduce.hpp +++ b/src/libPMacc/include/mpi/reduceMethods/AllReduce.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/mpi/reduceMethods/Reduce.hpp b/src/libPMacc/include/mpi/reduceMethods/Reduce.hpp index b1007e4480..3e99d1c65f 100644 --- a/src/libPMacc/include/mpi/reduceMethods/Reduce.hpp +++ b/src/libPMacc/include/mpi/reduceMethods/Reduce.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/nvidia/functors/Add.hpp b/src/libPMacc/include/nvidia/functors/Add.hpp index ea6ca8b9a2..26fcc4e088 100644 --- a/src/libPMacc/include/nvidia/functors/Add.hpp +++ b/src/libPMacc/include/nvidia/functors/Add.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013, 2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,12 +20,10 @@ * If not, see . */ +#pragma once -#ifndef ADD_HPP -#define ADD_HPP - -#include "types.h" #include "mpi/GetMPI_Op.hpp" +#include "types.h" namespace PMacc { @@ -59,6 +57,3 @@ namespace PMacc } } } - -#endif /* ADD_HPP */ - diff --git a/src/libPMacc/include/nvidia/functors/Assign.hpp b/src/libPMacc/include/nvidia/functors/Assign.hpp index 45d1c25db1..70e46df5e1 100644 --- a/src/libPMacc/include/nvidia/functors/Assign.hpp +++ b/src/libPMacc/include/nvidia/functors/Assign.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013-2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,8 +20,7 @@ * If not, see . */ -#ifndef ASSIGN_HPP -#define ASSIGN_HPP +#pragma once #include "types.h" @@ -44,6 +43,3 @@ namespace PMacc } } } - -#endif /* ASSIGN_HPP */ - diff --git a/src/libPMacc/include/nvidia/functors/Max.hpp b/src/libPMacc/include/nvidia/functors/Max.hpp index f09edc3ecc..2943671745 100644 --- a/src/libPMacc/include/nvidia/functors/Max.hpp +++ b/src/libPMacc/include/nvidia/functors/Max.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013, 2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,15 +20,13 @@ * If not, see . */ - -#ifndef MAX_HPP -#define MAX_HPP - -#include "types.h" +#pragma once #include "mpi/GetMPI_Op.hpp" #include "algorithms/math.hpp" +#include "types.h" + namespace PMacc { namespace nvidia @@ -61,6 +59,3 @@ namespace PMacc } } } - -#endif /* MAX_HPP */ - diff --git a/src/libPMacc/include/nvidia/functors/Min.hpp b/src/libPMacc/include/nvidia/functors/Min.hpp index 8b5e60bac7..6f9827985a 100644 --- a/src/libPMacc/include/nvidia/functors/Min.hpp +++ b/src/libPMacc/include/nvidia/functors/Min.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013, 2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -21,14 +21,13 @@ */ -#ifndef MIN_HPP -#define MIN_HPP - -#include "types.h" +#pragma once #include "mpi/GetMPI_Op.hpp" #include "algorithms/math.hpp" +#include "types.h" + namespace PMacc { namespace nvidia @@ -61,6 +60,3 @@ namespace PMacc } } } - -#endif /* MIN_HPP */ - diff --git a/src/libPMacc/include/nvidia/functors/Mul.hpp b/src/libPMacc/include/nvidia/functors/Mul.hpp index f3d063834e..9af4fbe242 100644 --- a/src/libPMacc/include/nvidia/functors/Mul.hpp +++ b/src/libPMacc/include/nvidia/functors/Mul.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/nvidia/functors/Sub.hpp b/src/libPMacc/include/nvidia/functors/Sub.hpp index 5617d125ae..eb3edd8692 100644 --- a/src/libPMacc/include/nvidia/functors/Sub.hpp +++ b/src/libPMacc/include/nvidia/functors/Sub.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/nvidia/memory/MemoryInfo.hpp b/src/libPMacc/include/nvidia/memory/MemoryInfo.hpp index beace7e290..34f9602dcb 100644 --- a/src/libPMacc/include/nvidia/memory/MemoryInfo.hpp +++ b/src/libPMacc/include/nvidia/memory/MemoryInfo.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/nvidia/reduce/Reduce.hpp b/src/libPMacc/include/nvidia/reduce/Reduce.hpp index f4a88b9d7c..48fbef127c 100644 --- a/src/libPMacc/include/nvidia/reduce/Reduce.hpp +++ b/src/libPMacc/include/nvidia/reduce/Reduce.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Axel Huebl, Heiko Burau, Rene Widera + * Copyright 2013-2015 Axel Huebl, Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,14 +20,13 @@ * If not, see . */ +#pragma once -#ifndef REDUCE_HPP -#define REDUCE_HPP - -#include "types.h" #include "nvidia/functors/Assign.hpp" #include "traits/GetValueType.hpp" +#include "types.h" + #include namespace PMacc @@ -222,7 +221,7 @@ namespace PMacc */ HINLINE uint32_t optimalThreadsPerBlock(uint32_t n, uint32_t sizePerElement) { - uint32_t sharedBorder = sharedMemByte / sizePerElement; + uint32_t const sharedBorder = sharedMemByte / sizePerElement; return getThreadsPerBlock(std::min(sharedBorder, n)); } @@ -237,6 +236,3 @@ namespace PMacc } } } - -#endif /* REDUCE_HPP */ - diff --git a/src/libPMacc/include/nvidia/rng/RNG.hpp b/src/libPMacc/include/nvidia/rng/RNG.hpp index 42c70fc469..fb0301561a 100644 --- a/src/libPMacc/include/nvidia/rng/RNG.hpp +++ b/src/libPMacc/include/nvidia/rng/RNG.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/nvidia/rng/distributions/Normal_float.hpp b/src/libPMacc/include/nvidia/rng/distributions/Normal_float.hpp index 65fec3a908..d5dd3231ca 100644 --- a/src/libPMacc/include/nvidia/rng/distributions/Normal_float.hpp +++ b/src/libPMacc/include/nvidia/rng/distributions/Normal_float.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/nvidia/rng/distributions/Uniform_float.hpp b/src/libPMacc/include/nvidia/rng/distributions/Uniform_float.hpp index 5713a85fb5..cbe8bc4862 100644 --- a/src/libPMacc/include/nvidia/rng/distributions/Uniform_float.hpp +++ b/src/libPMacc/include/nvidia/rng/distributions/Uniform_float.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/nvidia/rng/distributions/Uniform_int32.hpp b/src/libPMacc/include/nvidia/rng/distributions/Uniform_int32.hpp index b41bded861..d6e835bf39 100644 --- a/src/libPMacc/include/nvidia/rng/distributions/Uniform_int32.hpp +++ b/src/libPMacc/include/nvidia/rng/distributions/Uniform_int32.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/nvidia/rng/methods/Xor.hpp b/src/libPMacc/include/nvidia/rng/methods/Xor.hpp index 839b3d6551..15d6493b31 100644 --- a/src/libPMacc/include/nvidia/rng/methods/Xor.hpp +++ b/src/libPMacc/include/nvidia/rng/methods/Xor.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/nvidia/traits/GetType.hpp b/src/libPMacc/include/nvidia/traits/GetType.hpp index faead80444..b09c9c5211 100644 --- a/src/libPMacc/include/nvidia/traits/GetType.hpp +++ b/src/libPMacc/include/nvidia/traits/GetType.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/particles/Identifier.hpp b/src/libPMacc/include/particles/Identifier.hpp index f7d1b0b18e..a977a1fa7d 100644 --- a/src/libPMacc/include/particles/Identifier.hpp +++ b/src/libPMacc/include/particles/Identifier.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/particles/ParticleDescription.hpp b/src/libPMacc/include/particles/ParticleDescription.hpp index 0d53c8773c..31cc2c35bb 100644 --- a/src/libPMacc/include/particles/ParticleDescription.hpp +++ b/src/libPMacc/include/particles/ParticleDescription.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/particles/ParticlesBase.hpp b/src/libPMacc/include/particles/ParticlesBase.hpp index fdbd03e737..444234b185 100644 --- a/src/libPMacc/include/particles/ParticlesBase.hpp +++ b/src/libPMacc/include/particles/ParticlesBase.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/particles/ParticlesBase.kernel b/src/libPMacc/include/particles/ParticlesBase.kernel index b82e5c8c39..a242b9ae01 100644 --- a/src/libPMacc/include/particles/ParticlesBase.kernel +++ b/src/libPMacc/include/particles/ParticlesBase.kernel @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/particles/ParticlesBase.tpp b/src/libPMacc/include/particles/ParticlesBase.tpp index a5fe0f0895..a38589f4ec 100644 --- a/src/libPMacc/include/particles/ParticlesBase.tpp +++ b/src/libPMacc/include/particles/ParticlesBase.tpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/particles/boostExtension/InheritGenerators.hpp b/src/libPMacc/include/particles/boostExtension/InheritGenerators.hpp index 6032232e6d..9522fc0c25 100644 --- a/src/libPMacc/include/particles/boostExtension/InheritGenerators.hpp +++ b/src/libPMacc/include/particles/boostExtension/InheritGenerators.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Rene Widera + * Copyright 2013, 2015 Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,7 +20,6 @@ * If not, see . */ - #pragma once #include "particles/memory/frames/NullFrame.hpp" @@ -39,7 +38,6 @@ namespace PMacc { - template struct LinearInherit; @@ -51,7 +49,7 @@ class LinearInheritFork : public Base1, public Base2 /** Rule if head is a class without Base template parameter * - * Create a fork an inharid from head and combined classes from Vec + * Create a fork and inherit from head and combined classes from Vec */ template ::value> struct TypelistLinearInherit; @@ -64,7 +62,7 @@ struct TypelistLinearInherit -/** Rule if head is a clase which can inharit from other class +/** Rule if head is a class which can inherit from other class */ template < template class Head, class Vec> struct TypelistLinearInherit, Vec ,false> @@ -75,7 +73,7 @@ struct TypelistLinearInherit, Vec ,false> /** Rule if Vec is empty but Head is valid * - * This is the recursiv end rule + * This is the recursive end rule */ template struct TypelistLinearInherit @@ -85,7 +83,7 @@ struct TypelistLinearInherit -/** Create a data strcture which inharid lineary +/** Create a data structure which inherit linearly * \tparam vec_ boost mpl vector with classes * * class A; diff --git a/src/libPMacc/include/particles/boostExtension/InheritLinearly.hpp b/src/libPMacc/include/particles/boostExtension/InheritLinearly.hpp index fd6ada88d6..abd06064ec 100644 --- a/src/libPMacc/include/particles/boostExtension/InheritLinearly.hpp +++ b/src/libPMacc/include/particles/boostExtension/InheritLinearly.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/particles/frame_types.hpp b/src/libPMacc/include/particles/frame_types.hpp index 350c2bc274..c27bba5816 100644 --- a/src/libPMacc/include/particles/frame_types.hpp +++ b/src/libPMacc/include/particles/frame_types.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,9 +20,7 @@ * If not, see . */ - -#ifndef FRAME_TYPES_HPP -#define FRAME_TYPES_HPP +#pragma once #include "types.h" @@ -34,16 +32,11 @@ namespace PMacc { - - - /** * Is used for indirect pointer layer. * This type is limited by atomicSub on device (in CUDA 3.2 we can use 32 Bit int only). */ - typedef unsigned int vint_t; - - + typedef unsigned int vint_t; /** * Defines the local cell id type in a supercell @@ -55,7 +48,3 @@ namespace PMacc */ enum FrameType { CORE_FRAME = 0u, BORDER_FRAME =1u , BIG_FRAME=2u}; } - - -#endif /* FRAME_TYPES_HPP */ - diff --git a/src/libPMacc/include/particles/memory/boxes/ExchangePopDataBox.hpp b/src/libPMacc/include/particles/memory/boxes/ExchangePopDataBox.hpp index d6e958782d..0f1c66e9a9 100644 --- a/src/libPMacc/include/particles/memory/boxes/ExchangePopDataBox.hpp +++ b/src/libPMacc/include/particles/memory/boxes/ExchangePopDataBox.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013, 2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,9 +20,7 @@ * If not, see . */ - -#ifndef EXCHANGEPOPDATABOX_HPP -#define EXCHANGEPOPDATABOX_HPP +#pragma once #include "particles/memory/dataTypes/ExchangeMemoryIndex.hpp" #include "particles/memory/boxes/TileDataBox.hpp" @@ -70,6 +68,3 @@ class ExchangePopDataBox : public DataBox > }; } - -#endif /* EXCHANGEPOPDATABOX_HPP */ - diff --git a/src/libPMacc/include/particles/memory/boxes/ExchangePushDataBox.hpp b/src/libPMacc/include/particles/memory/boxes/ExchangePushDataBox.hpp index efeeebfd02..2227b0147b 100644 --- a/src/libPMacc/include/particles/memory/boxes/ExchangePushDataBox.hpp +++ b/src/libPMacc/include/particles/memory/boxes/ExchangePushDataBox.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013, 2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,8 +20,7 @@ * If not, see . */ -#ifndef EXCHANGEPUSHDATABOX_HPP -#define EXCHANGEPUSHDATABOX_HPP +#pragma once #include "particles/memory/dataTypes/ExchangeMemoryIndex.hpp" #include "memory/boxes/DataBox.hpp" @@ -86,11 +85,8 @@ class ExchangePushDataBox : public DataBox > protected: PMACC_ALIGN8(virtualMemory, PushDataBox); - PMACC_ALIGN(currentSizePointer, TYPE*); PMACC_ALIGN(maxSize, TYPE); + PMACC_ALIGN(currentSizePointer, TYPE*); }; } - -#endif /* EXCHANGEPUSHDATABOX_HPP */ - diff --git a/src/libPMacc/include/particles/memory/boxes/ParticlesBox.hpp b/src/libPMacc/include/particles/memory/boxes/ParticlesBox.hpp index da5b4da2e9..ca7ca2291b 100644 --- a/src/libPMacc/include/particles/memory/boxes/ParticlesBox.hpp +++ b/src/libPMacc/include/particles/memory/boxes/ParticlesBox.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -73,15 +73,27 @@ class ParticlesBox : protected DataBox, DIM> > */ DINLINE FRAME &getEmptyFrame() { - FrameType* tmp = (FrameType*) mallocMC::malloc(sizeof (FrameType)); - - if (tmp != NULL) + FrameType* tmp = NULL; + const int maxTries = 13; //magic number is not performance critical + for (int numTries = 0; numTries < maxTries; ++numTries) { - /* disable all particles since we can not assume that newly allocated memory contains zeros */ - for (int i = 0; i < (int) math::CT::volume::type::value; ++i) - (*tmp)[i][multiMask_] = 0; - /* takes care that changed values are visible to all threads inside this block*/ - __threadfence_block(); + tmp = (FrameType*) mallocMC::malloc(sizeof (FrameType)); + if (tmp != NULL) + { + /* disable all particles since we can not assume that newly allocated memory contains zeros */ + for (int i = 0; i < (int) math::CT::volume::type::value; ++i) + (*tmp)[i][multiMask_] = 0; + /* takes care that changed values are visible to all threads inside this block*/ + __threadfence_block(); + break; + } + else + { + printf("%s: mallocMC out of memory (try %i of %i)\n", + (numTries+1)==maxTries?"WARNING":"ERROR", + numTries+1, + maxTries); + } } return *(FramePtr(tmp)); @@ -94,7 +106,7 @@ class ParticlesBox : protected DataBox, DIM> > */ DINLINE void removeFrame(FRAME &frame) { - mallocMC::free((void*)&frame); + mallocMC::free((void*) &frame); } /** diff --git a/src/libPMacc/include/particles/memory/boxes/PopDataBox.hpp b/src/libPMacc/include/particles/memory/boxes/PopDataBox.hpp index 2b9027b47e..71f86021e3 100644 --- a/src/libPMacc/include/particles/memory/boxes/PopDataBox.hpp +++ b/src/libPMacc/include/particles/memory/boxes/PopDataBox.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013 Felix Schmitt, Heiko Burau, Rene Widera + * Copyright 2013-2015 Felix Schmitt, Heiko Burau, Rene Widera, + * Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,9 +21,7 @@ * If not, see . */ - -#ifndef POPDATABOX_HPP -#define POPDATABOX_HPP +#pragma once #include @@ -111,11 +110,10 @@ class PopDataBox : public DataBox > protected: + + PMACC_ALIGN(maxSize, TYPE); // ptr must be in device-memory PMACC_ALIGN(currentSize, TYPE*); - PMACC_ALIGN(maxSize, TYPE); }; } - -#endif /* POPDATABOX_HPP */ diff --git a/src/libPMacc/include/particles/memory/boxes/PushDataBox.hpp b/src/libPMacc/include/particles/memory/boxes/PushDataBox.hpp index 1e9fe37863..a4b5d050bc 100644 --- a/src/libPMacc/include/particles/memory/boxes/PushDataBox.hpp +++ b/src/libPMacc/include/particles/memory/boxes/PushDataBox.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013 Felix Schmitt, Heiko Burau, Rene Widera + * Copyright 2013-2015 Felix Schmitt, Heiko Burau, Rene Widera, + * Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -21,9 +22,8 @@ */ -#ifndef PUSHDATABOX_HPP -#define PUSHDATABOX_HPP +#pragma once #include #include "particles/memory/boxes/TileDataBox.hpp" @@ -95,9 +95,7 @@ namespace PMacc } protected: - PMACC_ALIGN(currentSize,TYPE*); PMACC_ALIGN(maxSize,TYPE); + PMACC_ALIGN(currentSize,TYPE*); }; } - -#endif /* PUSHDATABOX_HPP */ diff --git a/src/libPMacc/include/particles/memory/boxes/TileDataBox.hpp b/src/libPMacc/include/particles/memory/boxes/TileDataBox.hpp index ade4108f91..df308142d2 100644 --- a/src/libPMacc/include/particles/memory/boxes/TileDataBox.hpp +++ b/src/libPMacc/include/particles/memory/boxes/TileDataBox.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/particles/memory/buffers/ParticlesBuffer.hpp b/src/libPMacc/include/particles/memory/buffers/ParticlesBuffer.hpp index 6b7ff6fab9..b977d7ed3d 100644 --- a/src/libPMacc/include/particles/memory/buffers/ParticlesBuffer.hpp +++ b/src/libPMacc/include/particles/memory/buffers/ParticlesBuffer.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Axel Huebl, Felix Schmitt, Rene Widera + * Copyright 2013-2015 Axel Huebl, Felix Schmitt, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,8 +20,7 @@ * If not, see . */ -#ifndef PARTICLESBUFFER_HPP -#define PARTICLESBUFFER_HPP +#pragma once #include "particles/frame_types.hpp" #include "memory/buffers/GridBuffer.hpp" @@ -317,5 +316,3 @@ class ParticlesBuffer }; } - -#endif /* PARTICLESBUFFER_HPP */ \ No newline at end of file diff --git a/src/libPMacc/include/particles/memory/buffers/StackExchangeBuffer.hpp b/src/libPMacc/include/particles/memory/buffers/StackExchangeBuffer.hpp index 67a81dce5d..6ced461d7e 100644 --- a/src/libPMacc/include/particles/memory/buffers/StackExchangeBuffer.hpp +++ b/src/libPMacc/include/particles/memory/buffers/StackExchangeBuffer.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Felix Schmitt, Rene Widera + * Copyright 2013-2015 Felix Schmitt, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,8 +20,7 @@ * If not, see . */ -#ifndef STACKEXCHANGEBUFFER_HPP -#define STACKEXCHANGEBUFFER_HPP +#pragma once #include "particles/memory/boxes/ExchangePopDataBox.hpp" #include "particles/memory/boxes/ExchangePushDataBox.hpp" @@ -175,6 +174,3 @@ namespace PMacc Exchange& stackIndexer; }; } - -#endif /* STACKEXCHANGEBUFFER_HPP */ - diff --git a/src/libPMacc/include/particles/memory/dataTypes/ExchangeMemoryIndex.hpp b/src/libPMacc/include/particles/memory/dataTypes/ExchangeMemoryIndex.hpp index 674291d5e6..8ef3bbdba2 100644 --- a/src/libPMacc/include/particles/memory/dataTypes/ExchangeMemoryIndex.hpp +++ b/src/libPMacc/include/particles/memory/dataTypes/ExchangeMemoryIndex.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013, 2015 Heiko Burau, Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,16 +20,14 @@ * If not, see . */ -#ifndef EXCHANGEMEMORYINDEX_HPP -#define EXCHANGEMEMORYINDEX_HPP +#pragma once -#include "types.h" #include "dimensions/DataSpace.hpp" +#include "types.h" namespace PMacc { - template class ExchangeMemoryIndex { @@ -75,6 +73,3 @@ class ExchangeMemoryIndex PMACC_ALIGN(count, TYPE); }; } - -#endif /* EXCHANGEMEMORYINDEX_HPP */ - diff --git a/src/libPMacc/include/particles/memory/dataTypes/Particle.hpp b/src/libPMacc/include/particles/memory/dataTypes/Particle.hpp index 78d5d932a7..a3f518d570 100644 --- a/src/libPMacc/include/particles/memory/dataTypes/Particle.hpp +++ b/src/libPMacc/include/particles/memory/dataTypes/Particle.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -53,7 +53,8 @@ namespace pmacc = PMacc; /** A single particle of a @see Frame * - * A instance of this Particle is only a reference to a dataset of @see Frame + * A instance of this Particle is a representaion ("pointer") to the memory + * where the frame is stored. * * @tparam T_FrameType type of the parent frame * @tparam T_ValueTypeSeq sequence with all attribute identifiers @@ -76,16 +77,17 @@ struct Particle : public InheritLinearly * in this case sizeof(uint32_t)>sizeof(reference) */ /** index of particle inside the Frame*/ - const uint32_t idx; - /** reference to parent frame where this particle is from*/ - FrameType& frame; + PMACC_ALIGN(idx, const uint32_t); + + /** pointer to parent frame where this particle is from*/ + PMACC_ALIGN(frame, FrameType* const); /** create particle * * @param frame reference to parent frame * @param idx index of particle inside the frame */ - HDINLINE Particle(FrameType& frame, uint32_t idx) : frame(frame), idx(idx) + HDINLINE Particle(FrameType& frame, uint32_t idx) : frame(&frame), idx(idx) { } @@ -109,7 +111,7 @@ struct Particle : public InheritLinearly >::type operator[](const T_Key key) { - return frame.getIdentifier(key)[idx]; + return frame->getIdentifier(key)[idx]; } /** const version of method operator(const T_Key) */ @@ -123,7 +125,7 @@ struct Particle : public InheritLinearly operator[](const T_Key key) const { - return frame.getIdentifier(key)[idx]; + return frame->getIdentifier(key)[idx]; } private: /* we disallow to assign this class*/ diff --git a/src/libPMacc/include/particles/memory/dataTypes/Pointer.hpp b/src/libPMacc/include/particles/memory/dataTypes/Pointer.hpp index 6b5a90e6a9..29c8a64ce1 100644 --- a/src/libPMacc/include/particles/memory/dataTypes/Pointer.hpp +++ b/src/libPMacc/include/particles/memory/dataTypes/Pointer.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/particles/memory/dataTypes/StaticArray.hpp b/src/libPMacc/include/particles/memory/dataTypes/StaticArray.hpp index 0d66bb5bb0..dfcd8cc734 100644 --- a/src/libPMacc/include/particles/memory/dataTypes/StaticArray.hpp +++ b/src/libPMacc/include/particles/memory/dataTypes/StaticArray.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/particles/memory/dataTypes/SuperCell.hpp b/src/libPMacc/include/particles/memory/dataTypes/SuperCell.hpp index 7a45284e26..c630f2ed7b 100644 --- a/src/libPMacc/include/particles/memory/dataTypes/SuperCell.hpp +++ b/src/libPMacc/include/particles/memory/dataTypes/SuperCell.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -82,11 +82,13 @@ class SuperCell sizeLastFrame = size; } - PMACC_ALIGN(firstFramePtr, TYPE*); - PMACC_ALIGN(lastFramePtr, TYPE*); + private: PMACC_ALIGN(mustShiftVal, bool); PMACC_ALIGN(sizeLastFrame, lcellId_t); +public: + PMACC_ALIGN(firstFramePtr, TYPE*); + PMACC_ALIGN(lastFramePtr, TYPE*); }; } //end namespace diff --git a/src/libPMacc/include/particles/memory/frames/Frame.hpp b/src/libPMacc/include/particles/memory/frames/Frame.hpp index d25e1fa51e..624edc7b55 100644 --- a/src/libPMacc/include/particles/memory/frames/Frame.hpp +++ b/src/libPMacc/include/particles/memory/frames/Frame.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/particles/memory/frames/NullFrame.hpp b/src/libPMacc/include/particles/memory/frames/NullFrame.hpp index 958ff1f565..4c4478af68 100644 --- a/src/libPMacc/include/particles/memory/frames/NullFrame.hpp +++ b/src/libPMacc/include/particles/memory/frames/NullFrame.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Rene Widera + * Copyright 2013, 2015 Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,14 +20,10 @@ * If not, see . */ +#pragma once -#ifndef NULLFRAME_HPP -#define NULLFRAME_HPP - - -#include "types.h" #include "particles/memory/frames/NullFrame.hpp" - +#include "types.h" namespace PMacc { @@ -44,7 +40,3 @@ namespace PMacc }; }//namespace - - -#endif /* NULLFRAME_HPP */ - diff --git a/src/libPMacc/include/particles/operations/Assign.hpp b/src/libPMacc/include/particles/operations/Assign.hpp index f455c2f06e..22204695ac 100644 --- a/src/libPMacc/include/particles/operations/Assign.hpp +++ b/src/libPMacc/include/particles/operations/Assign.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/particles/operations/CopyIdentifier.hpp b/src/libPMacc/include/particles/operations/CopyIdentifier.hpp index d726f7a03b..35130f22bf 100644 --- a/src/libPMacc/include/particles/operations/CopyIdentifier.hpp +++ b/src/libPMacc/include/particles/operations/CopyIdentifier.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/particles/operations/CountParticles.hpp b/src/libPMacc/include/particles/operations/CountParticles.hpp index d2b47908b1..d08bb44e6d 100644 --- a/src/libPMacc/include/particles/operations/CountParticles.hpp +++ b/src/libPMacc/include/particles/operations/CountParticles.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/particles/operations/Deselect.hpp b/src/libPMacc/include/particles/operations/Deselect.hpp index 06fd06d5c4..1563014355 100644 --- a/src/libPMacc/include/particles/operations/Deselect.hpp +++ b/src/libPMacc/include/particles/operations/Deselect.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/particles/operations/SetAttributeToDefault.hpp b/src/libPMacc/include/particles/operations/SetAttributeToDefault.hpp index 92f840d584..b16f7665e7 100644 --- a/src/libPMacc/include/particles/operations/SetAttributeToDefault.hpp +++ b/src/libPMacc/include/particles/operations/SetAttributeToDefault.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/particles/particleFilter/FilterFactory.hpp b/src/libPMacc/include/particles/particleFilter/FilterFactory.hpp index e1ddcab68d..4dbed923f9 100644 --- a/src/libPMacc/include/particles/particleFilter/FilterFactory.hpp +++ b/src/libPMacc/include/particles/particleFilter/FilterFactory.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/particles/particleFilter/PositionFilter.hpp b/src/libPMacc/include/particles/particleFilter/PositionFilter.hpp index 74a7765ddd..6a780e2eae 100644 --- a/src/libPMacc/include/particles/particleFilter/PositionFilter.hpp +++ b/src/libPMacc/include/particles/particleFilter/PositionFilter.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/particles/particleFilter/system/DefaultFilter.hpp b/src/libPMacc/include/particles/particleFilter/system/DefaultFilter.hpp index f6f8f461b2..0776dab656 100644 --- a/src/libPMacc/include/particles/particleFilter/system/DefaultFilter.hpp +++ b/src/libPMacc/include/particles/particleFilter/system/DefaultFilter.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Rene Widera + * Copyright 2013, 2015 Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,13 +20,11 @@ * If not, see . */ +#pragma once -#ifndef DEFAULTFILTER_HPP -#define DEFAULTFILTER_HPP - -#include "types.h" -#include "particles/frame_types.hpp" #include "particles/memory/frames/NullFrame.hpp" +#include "particles/frame_types.hpp" +#include "types.h" namespace PMacc { @@ -98,6 +96,3 @@ class DefaultFilter } //namespace Frame - -#endif /* DEFAULTFILTER_HPP */ - diff --git a/src/libPMacc/include/particles/particleFilter/system/FalseFilter.hpp b/src/libPMacc/include/particles/particleFilter/system/FalseFilter.hpp index 76f6f42702..8ac4677b5e 100644 --- a/src/libPMacc/include/particles/particleFilter/system/FalseFilter.hpp +++ b/src/libPMacc/include/particles/particleFilter/system/FalseFilter.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Rene Widera + * Copyright 2013, 2015 Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,18 +20,15 @@ * If not, see . */ +#pragma once -#ifndef FALSEFILTER_HPP -#define FALSEFILTER_HPP - -#include "types.h" -#include "particles/frame_types.hpp" #include "particles/memory/frames/NullFrame.hpp" +#include "particles/frame_types.hpp" +#include "types.h" namespace PMacc { - class FalseFilter { @@ -53,6 +50,3 @@ namespace PMacc }; } //namespace Frame - -#endif /* FALSEFILTER_HPP */ - diff --git a/src/libPMacc/include/particles/particleFilter/system/TrueFilter.hpp b/src/libPMacc/include/particles/particleFilter/system/TrueFilter.hpp index b632da7bb0..4d8ecc1dc3 100644 --- a/src/libPMacc/include/particles/particleFilter/system/TrueFilter.hpp +++ b/src/libPMacc/include/particles/particleFilter/system/TrueFilter.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Rene Widera + * Copyright 2013, 2015 Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,18 +20,15 @@ * If not, see . */ +#pragma once -#ifndef TRUEFILTER_HPP -#define TRUEFILTER_HPP - -#include "types.h" -#include "particles/frame_types.hpp" #include "particles/memory/frames/NullFrame.hpp" +#include "particles/frame_types.hpp" +#include "types.h" namespace PMacc { - class TrueFilter { @@ -53,6 +50,3 @@ namespace PMacc }; } //namespace Frame - -#endif /* TRUEFILTER_HPP */ - diff --git a/src/libPMacc/include/particles/tasks/ParticleFactory.hpp b/src/libPMacc/include/particles/tasks/ParticleFactory.hpp index 401a127226..2e80a435c1 100644 --- a/src/libPMacc/include/particles/tasks/ParticleFactory.hpp +++ b/src/libPMacc/include/particles/tasks/ParticleFactory.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/particles/tasks/ParticleFactory.tpp b/src/libPMacc/include/particles/tasks/ParticleFactory.tpp index 07acfb2d7b..4fbae5030d 100644 --- a/src/libPMacc/include/particles/tasks/ParticleFactory.tpp +++ b/src/libPMacc/include/particles/tasks/ParticleFactory.tpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/particles/tasks/TaskParticlesReceive.hpp b/src/libPMacc/include/particles/tasks/TaskParticlesReceive.hpp index 14bf6b16cd..943f1c60ce 100644 --- a/src/libPMacc/include/particles/tasks/TaskParticlesReceive.hpp +++ b/src/libPMacc/include/particles/tasks/TaskParticlesReceive.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/particles/tasks/TaskParticlesSend.hpp b/src/libPMacc/include/particles/tasks/TaskParticlesSend.hpp index d3f82e4a31..6d4723bd6e 100644 --- a/src/libPMacc/include/particles/tasks/TaskParticlesSend.hpp +++ b/src/libPMacc/include/particles/tasks/TaskParticlesSend.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/particles/tasks/TaskReceiveParticlesExchange.hpp b/src/libPMacc/include/particles/tasks/TaskReceiveParticlesExchange.hpp index 9012ce5e25..b3128bb3ae 100644 --- a/src/libPMacc/include/particles/tasks/TaskReceiveParticlesExchange.hpp +++ b/src/libPMacc/include/particles/tasks/TaskReceiveParticlesExchange.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/particles/tasks/TaskSendParticlesExchange.hpp b/src/libPMacc/include/particles/tasks/TaskSendParticlesExchange.hpp index 070b14b4f2..3df1388eca 100644 --- a/src/libPMacc/include/particles/tasks/TaskSendParticlesExchange.hpp +++ b/src/libPMacc/include/particles/tasks/TaskSendParticlesExchange.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/pluginSystem/INotify.hpp b/src/libPMacc/include/pluginSystem/INotify.hpp index ee23945461..402de45810 100644 --- a/src/libPMacc/include/pluginSystem/INotify.hpp +++ b/src/libPMacc/include/pluginSystem/INotify.hpp @@ -5,7 +5,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/pluginSystem/IPlugin.hpp b/src/libPMacc/include/pluginSystem/IPlugin.hpp index ce3c11553c..28c6bc6bcf 100644 --- a/src/libPMacc/include/pluginSystem/IPlugin.hpp +++ b/src/libPMacc/include/pluginSystem/IPlugin.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/pluginSystem/PluginConnector.hpp b/src/libPMacc/include/pluginSystem/PluginConnector.hpp index 0e7fa19e10..7d3cdb05d9 100644 --- a/src/libPMacc/include/pluginSystem/PluginConnector.hpp +++ b/src/libPMacc/include/pluginSystem/PluginConnector.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013-2014 Rene Widera, Felix Schmitt, Axel Huebl + * Copyright 2013-2015 Rene Widera, Felix Schmitt, Axel Huebl, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -22,11 +22,11 @@ #pragma once -#include - #include "pluginSystem/INotify.hpp" #include "pluginSystem/IPlugin.hpp" +#include + namespace PMacc { namespace po = boost::program_options; @@ -49,7 +49,6 @@ namespace PMacc * @param plugin plugin to register */ void registerPlugin(IPlugin *plugin) - throw (PluginException) { if (plugin != NULL) { @@ -63,7 +62,6 @@ namespace PMacc * Calls load on all registered, not loaded plugins */ void loadPlugins() - throw (PluginException) { // load all plugins for (std::list::reverse_iterator iter = plugins.rbegin(); @@ -80,7 +78,6 @@ namespace PMacc * Unloads all registered, loaded plugins */ void unloadPlugins() - throw (PluginException) { // unload all plugins for (std::list::reverse_iterator iter = plugins.rbegin(); diff --git a/src/libPMacc/include/ppFunctions.hpp b/src/libPMacc/include/ppFunctions.hpp index 143e1bc83c..8d3c6d115b 100644 --- a/src/libPMacc/include/ppFunctions.hpp +++ b/src/libPMacc/include/ppFunctions.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/result_of_Functor.hpp b/src/libPMacc/include/result_of_Functor.hpp index f6c8d129b6..75dd13d67a 100644 --- a/src/libPMacc/include/result_of_Functor.hpp +++ b/src/libPMacc/include/result_of_Functor.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/simulationControl/SimulationHelper.hpp b/src/libPMacc/include/simulationControl/SimulationHelper.hpp index e5389440af..75502fb60a 100644 --- a/src/libPMacc/include/simulationControl/SimulationHelper.hpp +++ b/src/libPMacc/include/simulationControl/SimulationHelper.hpp @@ -1,10 +1,11 @@ /** - * Copyright 2013-2015 Axel Huebl, Felix Schmitt, Rene Widera, Alexander Debus + * Copyright 2013-2015 Axel Huebl, Felix Schmitt, Rene Widera, Alexander Debus, + * Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -23,7 +24,6 @@ #pragma once -#include #include #include @@ -36,7 +36,6 @@ #include "dataManagement/DataConnector.hpp" -#include "eventSystem/EventSystem.hpp" #include "pluginSystem/IPlugin.hpp" @@ -84,7 +83,6 @@ class SimulationHelper : public IPlugin tSimulation.printInterval() << " = " << (uint64_t) (tSimulation.getInterval() / 1000.) << " sec" << std::endl; } - //CUDA_CHECK(cudaGetLastError()); } /** @@ -128,6 +126,16 @@ class SimulationHelper : public IPlugin /* trigger checkpoint notification */ if (checkpointPeriod && (currentStep % checkpointPeriod == 0)) { + /* first synchronize: if something failed, we can spare the time + * for the checkpoint writing */ + CUDA_CHECK(cudaDeviceSynchronize()); + CUDA_CHECK(cudaGetLastError()); + + GridController &gc = Environment::get().GridController(); + /* can be spared for better scalings, but allows to spare the + * time for checkpointing if some ranks died */ + MPI_CHECK(MPI_Barrier(gc.getCommunicator().getMPIComm())); + /* create directory containing checkpoints */ if (numCheckpoints == 0) { @@ -137,7 +145,14 @@ class SimulationHelper : public IPlugin Environment::get().PluginConnector().checkpointPlugins(currentStep, checkpointDirectory); - GridController &gc = Environment::get().GridController(); + /* important synchronize: only if no errors occured until this + * point guarantees that a checkpoint is usable */ + CUDA_CHECK(cudaDeviceSynchronize()); + CUDA_CHECK(cudaGetLastError()); + + /* \todo in an ideal world with MPI-3, this would be an + * MPI_Ibarrier call and this function would return a MPI_Request + * that could be checked */ MPI_CHECK(MPI_Barrier(gc.getCommunicator().getMPIComm())); if (gc.getGlobalRank() == 0) @@ -190,20 +205,20 @@ class SimulationHelper : public IPlugin TimeIntervall tRound; double roundAvg = 0.0; - /* dump initial step if simulation starts without restart */ - if (currentStep == 0) - { - /* Since in the main loop movingWindow is called always before the dump, we also call it here for consistency. - This becomes only important, if movingWindowCheck does more than merely checking for a slide. - TO DO in a new feature: Turn this into a general hook for pre-checks (window slides are just one possible action). */ - movingWindowCheck(currentStep); - dumpOneStep(currentStep); - } - else - { - currentStep--; //We dump before calculation, thus we must go one step back when doing a restart. - movingWindowCheck(currentStep); //If we restart at any step check if we must slide. - } + /* dump initial step if simulation starts without restart */ + if (currentStep == 0) + { + /* Since in the main loop movingWindow is called always before the dump, we also call it here for consistency. + This becomes only important, if movingWindowCheck does more than merely checking for a slide. + TO DO in a new feature: Turn this into a general hook for pre-checks (window slides are just one possible action). */ + movingWindowCheck(currentStep); + dumpOneStep(currentStep); + } + else + { + currentStep--; //We dump before calculation, thus we must go one step back when doing a restart. + movingWindowCheck(currentStep); //If we restart at any step check if we must slide. + } /* dump 0% output */ dumpTimes(tSimCalculation, tRound, roundAvg, currentStep); diff --git a/src/libPMacc/include/simulationControl/TimeInterval.hpp b/src/libPMacc/include/simulationControl/TimeInterval.hpp index d7c3c48059..19d28265da 100644 --- a/src/libPMacc/include/simulationControl/TimeInterval.hpp +++ b/src/libPMacc/include/simulationControl/TimeInterval.hpp @@ -1,10 +1,10 @@ /** - * Copyright 2013 Rene Widera + * Copyright 2013, 2015 Rene Widera, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,17 +20,16 @@ * If not, see . */ -#ifndef TIMEINTERVAL_HPP -#define TIMEINTERVAL_HPP +#pragma once + +#include "types.h" #include -#include -#include "types.h" +#include #include #include - namespace PMacc { @@ -124,7 +123,3 @@ namespace PMacc double end; }; } //namespace PMacc - - -#endif /* TIMEINTERVAL_HPP */ - diff --git a/src/libPMacc/include/static_assert.hpp b/src/libPMacc/include/static_assert.hpp index 857b65358f..8f11687cb7 100644 --- a/src/libPMacc/include/static_assert.hpp +++ b/src/libPMacc/include/static_assert.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/traits/GetComponentsType.hpp b/src/libPMacc/include/traits/GetComponentsType.hpp index 71427e6556..89ca0f8014 100644 --- a/src/libPMacc/include/traits/GetComponentsType.hpp +++ b/src/libPMacc/include/traits/GetComponentsType.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -39,7 +39,7 @@ namespace traits */ template::value > struct GetComponentsType; - + template struct GetComponentsType { diff --git a/src/libPMacc/include/traits/GetFlagType.hpp b/src/libPMacc/include/traits/GetFlagType.hpp index 9d53afc755..a5243a8cfb 100644 --- a/src/libPMacc/include/traits/GetFlagType.hpp +++ b/src/libPMacc/include/traits/GetFlagType.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/traits/GetNComponents.hpp b/src/libPMacc/include/traits/GetNComponents.hpp index b4a2e7d018..2262ebf112 100644 --- a/src/libPMacc/include/traits/GetNComponents.hpp +++ b/src/libPMacc/include/traits/GetNComponents.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/traits/GetValueType.hpp b/src/libPMacc/include/traits/GetValueType.hpp index d8fb769cd0..6ecc40d872 100644 --- a/src/libPMacc/include/traits/GetValueType.hpp +++ b/src/libPMacc/include/traits/GetValueType.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -20,7 +20,6 @@ * If not, see . */ - #pragma once namespace PMacc @@ -36,6 +35,3 @@ namespace PMacc } #include "GetValueType.tpp" - - - diff --git a/src/libPMacc/include/traits/GetValueType.tpp b/src/libPMacc/include/traits/GetValueType.tpp index 6f401e468c..5872e13806 100644 --- a/src/libPMacc/include/traits/GetValueType.tpp +++ b/src/libPMacc/include/traits/GetValueType.tpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/traits/HasFlag.hpp b/src/libPMacc/include/traits/HasFlag.hpp index 9f08661e5a..26747a90b7 100644 --- a/src/libPMacc/include/traits/HasFlag.hpp +++ b/src/libPMacc/include/traits/HasFlag.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/traits/HasIdentifier.hpp b/src/libPMacc/include/traits/HasIdentifier.hpp index 243c95a2c6..97d78b5bc7 100644 --- a/src/libPMacc/include/traits/HasIdentifier.hpp +++ b/src/libPMacc/include/traits/HasIdentifier.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/traits/IsSameType.hpp b/src/libPMacc/include/traits/IsSameType.hpp index af1355f32c..944d0b0369 100644 --- a/src/libPMacc/include/traits/IsSameType.hpp +++ b/src/libPMacc/include/traits/IsSameType.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/traits/Limits.hpp b/src/libPMacc/include/traits/Limits.hpp index 7e1792c490..bfd3e2de03 100644 --- a/src/libPMacc/include/traits/Limits.hpp +++ b/src/libPMacc/include/traits/Limits.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/traits/Limits.tpp b/src/libPMacc/include/traits/Limits.tpp index 14a64e8337..0ace27fb78 100644 --- a/src/libPMacc/include/traits/Limits.tpp +++ b/src/libPMacc/include/traits/Limits.tpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -24,6 +24,7 @@ #pragma once #include "traits/Limits.hpp" + #include namespace PMacc diff --git a/src/libPMacc/include/traits/NumberOfExchanges.hpp b/src/libPMacc/include/traits/NumberOfExchanges.hpp index e1b5b73519..51cbbef810 100644 --- a/src/libPMacc/include/traits/NumberOfExchanges.hpp +++ b/src/libPMacc/include/traits/NumberOfExchanges.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/traits/Resolve.hpp b/src/libPMacc/include/traits/Resolve.hpp index 8f5b930712..50524e3ad7 100644 --- a/src/libPMacc/include/traits/Resolve.hpp +++ b/src/libPMacc/include/traits/Resolve.hpp @@ -4,7 +4,7 @@ * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/libPMacc/include/types.h b/src/libPMacc/include/types.h index a3887bfe35..01b01a575c 100644 --- a/src/libPMacc/include/types.h +++ b/src/libPMacc/include/types.h @@ -1,10 +1,11 @@ /** - * Copyright 2013 Felix Schmitt, Heiko Burau, Rene Widera, Wolfgang Hoenig + * Copyright 2013-2015 Felix Schmitt, Heiko Burau, Rene Widera, + * Wolfgang Hoenig, Benjamin Worpitz * * This file is part of libPMacc. * * libPMacc is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -22,21 +23,20 @@ #pragma once -#include -#include -#include -#include -#include - -#include #include "debug/PMaccVerbose.hpp" -#include -#include #define BOOST_MPL_LIMIT_VECTOR_SIZE 20 #define BOOST_MPL_LIMIT_MAP_SIZE 20 +#include +#include +#include +#include +#include +#include +#include +#include #define PMACC_AUTO_TPL(var,...) BOOST_AUTO_TPL(var,(__VA_ARGS__)) #define PMACC_AUTO(var,...) BOOST_AUTO(var,(__VA_ARGS__)) diff --git a/src/mpiInfo/main.cpp b/src/mpiInfo/main.cpp index 201ea223c8..2eef4af2ce 100644 --- a/src/mpiInfo/main.cpp +++ b/src/mpiInfo/main.cpp @@ -20,6 +20,7 @@ #include #include +#include // std::cerr #include #include diff --git a/src/picongpu/ArgsParser.cpp b/src/picongpu/ArgsParser.cpp index 768ac7747f..c7d5223166 100644 --- a/src/picongpu/ArgsParser.cpp +++ b/src/picongpu/ArgsParser.cpp @@ -1,5 +1,5 @@ /** - * Copyright 2013 Axel Huebl, Felix Schmitt, Rene Widera + * Copyright 2013, 2015 Axel Huebl, Felix Schmitt, Rene Widera * * This file is part of PIConGPU. * @@ -61,7 +61,7 @@ namespace picongpu return instance; } - bool ArgsParser::parse( int argc, char** argv ) + ArgsParser::ArgsErrorCode ArgsParser::parse( int argc, char** argv ) throw (std::runtime_error ) { try @@ -76,7 +76,8 @@ namespace picongpu // add possible options desc.add_options() - ( "help,h", "print help message" ) + ( "help,h", "print help message and exit" ) + ( "validate", "validate command line parameters and exit" ) ( "config,c", po::value > ( &config_files )->multitoken( ), "Config file(s)" ) ; @@ -109,16 +110,23 @@ namespace picongpu if ( vm.count( "help" ) ) { std::cerr << desc << "\n"; - return false; + return SUCCESS_EXIT; + } + if ( vm.count( "validate" ) ) + { + /* if we reach this part of code the parameters are valid + * and the option `validate` is set. + */ + return SUCCESS_EXIT; } } catch ( boost::program_options::error& e ) { std::cerr << e.what() << std::endl; - return false; + return ERROR; } - return true; + return SUCCESS; } } \ No newline at end of file diff --git a/src/picongpu/CMakeLists.txt b/src/picongpu/CMakeLists.txt index df17a7125e..fe08288565 100644 --- a/src/picongpu/CMakeLists.txt +++ b/src/picongpu/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2014 Axel Huebl, Benjamin Schneider, Felix Schmitt, Heiko Burau, Rene Widera +# Copyright 2013-2015 Axel Huebl, Benjamin Schneider, Felix Schmitt, Heiko Burau, Rene Widera # # This file is part of PIConGPU. # @@ -85,20 +85,6 @@ if(CUDA_KEEP_FILES) endif(CUDA_KEEP_FILES) -################################################################################ -# Find mallocMC -################################################################################ - -find_package(mallocMC 2.1.0) - -if(mallocMC_FOUND) - include_directories(SYSTEM ${mallocMC_INCLUDE_DIRS}) -else(mallocMC_FOUND) - message(STATUS "Using mallocMC from thirdParty/ directory") - include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdParty/mallocMC/src/include) -endif(mallocMC_FOUND) - - ################################################################################ # VampirTrace ################################################################################ @@ -268,6 +254,32 @@ if( (Boost_VERSION EQUAL 105500) AND "${CUDA_NVCC_FLAGS} \"-DBOOST_NOINLINE=__attribute__((noinline))\" ") endif() +################################################################################ +# OPENMP +############################################################################## + +FIND_PACKAGE(OpenMP) +IF(NOT OPENMP_FOUND) + MESSAGE(STATUS "Disable OpenMP: Can't find library") + +ELSE() + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") +ENDIF() + + +################################################################################ +# Find mallocMC +################################################################################ + +find_package(mallocMC 2.1.0) + +if(mallocMC_FOUND) + include_directories(SYSTEM ${mallocMC_INCLUDE_DIRS}) +else(mallocMC_FOUND) + message(STATUS "Using mallocMC from thirdParty/ directory") + include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdParty/mallocMC/src/include) +endif(mallocMC_FOUND) + ################################################################################ # PMacc options @@ -392,11 +404,7 @@ endif() # libPMacc -find_path(PMACC_ROOT_DIR - NAMES include/types.h - PATHS "${CMAKE_CURRENT_SOURCE_DIR}/../libPMacc" - DOC "libPMacc root location" - ) +set(PMACC_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../libPMacc") include_directories(${PMACC_ROOT_DIR}/include) diff --git a/src/picongpu/include/ArgsParser.hpp b/src/picongpu/include/ArgsParser.hpp index 035402de0d..3551036558 100644 --- a/src/picongpu/include/ArgsParser.hpp +++ b/src/picongpu/include/ArgsParser.hpp @@ -1,5 +1,5 @@ /** - * Copyright 2013 Axel Huebl, Felix Schmitt, Rene Widera + * Copyright 2013, 2015 Axel Huebl, Felix Schmitt, Rene Widera * * This file is part of PIConGPU. * @@ -19,9 +19,7 @@ */ - -#ifndef ARGSPARSER_HPP -#define ARGSPARSER_HPP +#pragma once #include @@ -44,6 +42,7 @@ namespace picongpu { public: + enum ArgsErrorCode {SUCCESS=0,SUCCESS_EXIT=1,ERROR=42}; /** * Returns an instance of ArgsParser * @@ -63,7 +62,7 @@ namespace picongpu * @param argv command line arguments * @return true if the simulation should proceed, false otherwise */ - bool parse(int argc, char **argv) throw (std::runtime_error); + ArgsErrorCode parse(int argc, char **argv) throw (std::runtime_error); @@ -79,6 +78,3 @@ namespace picongpu }; } - -#endif /* ARGSPARSER_HPP */ - diff --git a/src/picongpu/include/algorithms/DifferenceToLower.hpp b/src/picongpu/include/algorithms/DifferenceToLower.hpp index e1280b1c87..4c233e05fa 100644 --- a/src/picongpu/include/algorithms/DifferenceToLower.hpp +++ b/src/picongpu/include/algorithms/DifferenceToLower.hpp @@ -28,59 +28,64 @@ namespace picongpu { using namespace PMacc; -template -struct DifferenceToLower; -template<> -struct DifferenceToLower +/** calculate difference to lower value + * + * @tparam T_Dim for how many dimensions this operator access memory + * + * If `GetDifference` is called for a direction greater equal T_Dim always + * a zeroed value is returned + */ +template +struct DifferenceToLower { - typedef PMacc::math::CT::Int<0,0,0> OffsetEnd; - typedef PMacc::math::CT::Int<1,1,1> OffsetOrigin; + static const uint32_t dim = T_Dim; + - template - HDINLINE typename Memory::ValueType operator()(const Memory& mem, const uint32_t direction) const + typedef typename PMacc::math::CT::make_Int::type OffsetOrigin; + typedef typename PMacc::math::CT::make_Int::type OffsetEnd; + + /** calculate the difference for a given direction + * + * @tparam T_direction direction for the difference operation + * @tparam T_isLesserThanDim not needed/ this is calculated by the compiler + */ + template + struct GetDifference { - const float_X reciWidth = float_X(1.0) / CELL_WIDTH; - const float_X reciHeight = float_X(1.0) / CELL_HEIGHT; - const float_X reciDepth = float_X(1.0) / CELL_DEPTH; - switch (direction) - { - case 0: - return (mem[0][0][0] - mem[0][0][-1]) * reciWidth; - case 1: - return (mem[0][0][0] - mem[0][-1][0]) * reciHeight; - case 2: - return (mem[0][0][0] - mem[-1][0][0]) * reciDepth; - } - return float3_X(NAN, NAN, NAN); - } -}; + static const uint32_t direction = T_direction; + /** get difference to lower value + * @return difference divided by cell size of the given direction + */ + template + HDINLINE typename Memory::ValueType operator()(const Memory& mem) const + { + const DataSpace indexIdentity; /* defaults to (0, 0, 0) in 3D */ + DataSpace indexLower; /* e.g., (0, -1, 0) for d/dy in 3D */ + indexLower[direction] = -1; -template<> -struct DifferenceToLower -{ - typedef PMacc::math::CT::Int<0, 0> OffsetEnd; - typedef PMacc::math::CT::Int<1, 1> OffsetOrigin; + return (mem(indexIdentity) - mem(indexLower)) / cellSize[direction]; + } + }; - template - HDINLINE typename Memory::ValueType operator()(const Memory& mem, const uint32_t direction) const + /** special case for `direction >= simulation dimensions` + * + * difference = d/dx = 0 + */ + template + struct GetDifference { - const float_X reciWidth = float_X(1.0) / CELL_WIDTH; - const float_X reciHeight = float_X(1.0) / CELL_HEIGHT; - switch (direction) + /** @return always a zeroed value + */ + template + HDINLINE typename Memory::ValueType operator()(const Memory& mem) const { - case 0: - return (mem[0][0] - mem[0][-1]) * reciWidth; - case 1: - return (mem[0][0] - mem[-1][0]) * reciHeight; - case 2: - return float3_X(0., 0., 0.); - + return Memory::ValueType::create(0.0);; } - return float3_X(NAN, NAN, NAN); - } + }; + }; } //namespace picongpu diff --git a/src/picongpu/include/algorithms/DifferenceToUpper.hpp b/src/picongpu/include/algorithms/DifferenceToUpper.hpp index 99cb755f49..d3d0ae0bf6 100644 --- a/src/picongpu/include/algorithms/DifferenceToUpper.hpp +++ b/src/picongpu/include/algorithms/DifferenceToUpper.hpp @@ -27,59 +27,63 @@ namespace picongpu { -template -struct DifferenceToUpper; -template<> -struct DifferenceToUpper +/** calculate difference to upper value + * + * @tparam T_Dim for how many dimensions this operator access memory + * + * If `GetDifference` is called for a direction greater equal T_Dim always + * a zeroed value is returned + */ +template +struct DifferenceToUpper { - typedef PMacc::math::CT::Int< 1, 1, 1 > OffsetEnd; - typedef PMacc::math::CT::Int< 0, 0, 0 > OffsetOrigin; + static const uint32_t dim = T_Dim; - template - HDINLINE typename Memory::ValueType operator()(const Memory& mem, const uint32_t direction) const + typedef typename PMacc::math::CT::make_Int::type OffsetOrigin; + typedef typename PMacc::math::CT::make_Int::type OffsetEnd; + + /** calculate the difference for a given direction + * + * @tparam T_direction direction for the difference operation + * @tparam T_isLesserThanDim not needed/ this is calculated by the compiler + */ + template + struct GetDifference { - const float_X reciWidth = float_X(1.0) / CELL_WIDTH; - const float_X reciHeight = float_X(1.0) / CELL_HEIGHT; - const float_X reciDepth = float_X(1.0) / CELL_DEPTH; - switch (direction) + static const uint32_t direction = T_direction; + + /** get difference to lower value + * @return difference divided by cell size of the given direction + */ + template + HDINLINE typename Memory::ValueType operator()(const Memory& mem) const { - case 0: - return (mem[0][0][1] - mem[0][0][0]) * reciWidth; - case 1: - return (mem[0][1][0] - mem[0][0][0]) * reciHeight; - case 2: - return (mem[1][0][0] - mem[0][0][0]) * reciDepth; - } - return float3_X(NAN, NAN, NAN); - } -}; + const DataSpace indexIdentity; /* defaults to (0, 0, 0) in 3D */ + DataSpace indexUpper; /* e.g., (0, 1, 0) for d/dy in 3D */ + indexUpper[direction] = 1; -template<> -struct DifferenceToUpper -{ - typedef PMacc::math::CT::Int< 1, 1 > OffsetEnd; - typedef PMacc::math::CT::Int< 0, 0 > OffsetOrigin; + return ( mem(indexUpper) - mem(indexIdentity)) / cellSize[direction]; + } + }; - template - HDINLINE typename Memory::ValueType operator()(const Memory& mem, const uint32_t direction) const + /** special case for `direction >= simulation dimensions` + * + * difference = d/dx = 0 + */ + template + struct GetDifference { - const float_X reciWidth = float_X(1.0) / CELL_WIDTH; - const float_X reciHeight = float_X(1.0) / CELL_HEIGHT; - switch (direction) + /** @return always a zeroed value + */ + template + HDINLINE typename Memory::ValueType operator()(const Memory& mem) const { - case 0: - return (mem[0][1] - mem[0][0]) * reciWidth; - case 1: - return (mem[1][0] - mem[0][0]) * reciHeight; - - case 2: - return float3_X(0., 0., 0.); - + return Memory::ValueType::create(0.0); } - return float3_X(NAN, NAN, NAN); - } + }; + }; } //namespace picongpu diff --git a/src/picongpu/include/fields/FieldE.tpp b/src/picongpu/include/fields/FieldE.tpp index ffe60ef5ec..0e8070bb81 100644 --- a/src/picongpu/include/fields/FieldE.tpp +++ b/src/picongpu/include/fields/FieldE.tpp @@ -185,7 +185,7 @@ void FieldE::reset( uint32_t ) } -HDINLINE +HDINLINE typename FieldE::UnitValueType FieldE::getUnit( ) { diff --git a/src/picongpu/include/fields/FieldJ.hpp b/src/picongpu/include/fields/FieldJ.hpp index b2137333c4..5b8f7163db 100644 --- a/src/picongpu/include/fields/FieldJ.hpp +++ b/src/picongpu/include/fields/FieldJ.hpp @@ -1,5 +1,5 @@ /** - * Copyright 2013-2014 Axel Huebl, Heiko Burau, Rene Widera, Richard Pausch + * Copyright 2013-2015 Axel Huebl, Heiko Burau, Rene Widera, Richard Pausch * * This file is part of PIConGPU. * @@ -70,7 +70,7 @@ class FieldJ : public SimulationFieldHelper, public ISimulationData virtual EventTask asyncCommunication(EventTask serialEvent); - void init(FieldE &fieldE); + void init(FieldE &fieldE, FieldB &fieldB); GridLayout getGridLayout(); @@ -87,8 +87,8 @@ class FieldJ : public SimulationFieldHelper, public ISimulationData template void computeCurrent(ParticlesClass &parClass, uint32_t currentStep) throw (std::invalid_argument); - template - void addCurrentToE(); + template + void addCurrentToEMF( T_CurrentInterpolation& myCurrentInterpolation ); SimulationDataId getUniqueId(); @@ -124,8 +124,10 @@ class FieldJ : public SimulationFieldHelper, public ISimulationData private: GridBuffer fieldJ; + GridBuffer* fieldJrecv; FieldE *fieldE; + FieldB *fieldB; }; template diff --git a/src/picongpu/include/fields/FieldJ.kernel b/src/picongpu/include/fields/FieldJ.kernel index 747d859360..183c02b706 100644 --- a/src/picongpu/include/fields/FieldJ.kernel +++ b/src/picongpu/include/fields/FieldJ.kernel @@ -1,5 +1,5 @@ /** - * Copyright 2013-2014 Axel Huebl, Heiko Burau, Rene Widera + * Copyright 2013-2015 Axel Huebl, Heiko Burau, Rene Widera * * This file is part of PIConGPU. * @@ -87,7 +87,7 @@ __global__ void kernelComputeCurrent(JBox fieldJ, __syncthreads(); - Set set(float3_X(0.0, 0.0, 0.0)); + Set set(float3_X::create(0.0)); ThreadCollective collectivSet(linearThreadIdx); collectivSet(set, cachedJ); @@ -160,24 +160,45 @@ private: const PMACC_ALIGN(deltaTime, float); }; -template -__global__ void kernelAddCurrentToE(typename FieldE::DataBoxType fieldE, - J_DataBox fieldJ, - Mapping mapper) +template +__global__ void kernelAddCurrentToEMF(typename FieldE::DataBoxType fieldE, + typename FieldB::DataBoxType fieldB, + J_DataBox fieldJ, + T_CurrentInterpolation currentInterpolation, + T_Mapping mapper) { + /* Caching of fieldJ */ + typedef SuperCellDescription< + SuperCellSize, + typename T_CurrentInterpolation::LowerMargin, + typename T_CurrentInterpolation::UpperMargin + > BlockArea; - const DataSpace blockCell( - mapper.getSuperCellIndex(DataSpace (blockIdx)) - * Mapping::SuperCellSize::toRT() - ); - const DataSpace cell(blockCell + DataSpace (threadIdx)); + PMACC_AUTO(cachedJ, CachedBox::create < 0, typename J_DataBox::ValueType > (BlockArea())); + + nvidia::functors::Assign assign; + const DataSpace block(mapper.getSuperCellIndex(DataSpace (blockIdx))); + const DataSpace blockCell = block * MappingDesc::SuperCellSize::toRT(); + + const DataSpace threadIndex(threadIdx); + PMACC_AUTO(fieldJBlock, fieldJ.shift(blockCell)); + + ThreadCollective collectiv(threadIndex); + collectiv( + assign, + cachedJ, + fieldJBlock + ); + + __syncthreads(); + + const DataSpace cell(blockCell + threadIndex); // Amperes Law: // Change of the dE = - j / EPS0 * dt // j = current density (= current per area) // = fieldJ - const float_X deltaT = DELTA_T; - fieldE(cell) -= fieldJ(cell) * (float_X(1.0) / EPS0) * deltaT; + currentInterpolation( fieldE.shift(cell), fieldB.shift(cell), cachedJ.shift(threadIndex) ); } template diff --git a/src/picongpu/include/fields/FieldJ.tpp b/src/picongpu/include/fields/FieldJ.tpp index 1c039550e1..c0f0b09b3f 100644 --- a/src/picongpu/include/fields/FieldJ.tpp +++ b/src/picongpu/include/fields/FieldJ.tpp @@ -1,5 +1,5 @@ /** - * Copyright 2013-2014 Axel Huebl, Heiko Burau, Rene Widera, Felix Schmitt, + * Copyright 2013-2015 Axel Huebl, Heiko Burau, Rene Widera, Felix Schmitt, * Richard Pausch * * This file is part of PIConGPU. @@ -53,21 +53,35 @@ using namespace PMacc; FieldJ::FieldJ( MappingDesc cellDescription ) : SimulationFieldHelper( cellDescription ), -fieldJ( cellDescription.getGridLayout( ) ), fieldE( NULL ) +fieldJ( cellDescription.getGridLayout( ) ), fieldE( NULL ), fieldB( NULL ), fieldJrecv( NULL ) { const DataSpace coreBorderSize = cellDescription.getGridLayout( ).getDataSpaceWithoutGuarding( ); - + /* cell margins the current might spread to due to particle shapes */ typedef typename bmpl::accumulate< VectorAllSpecies, typename PMacc::math::CT::make_Int::type, PMacc::math::CT::max > > - >::type LowerMargin; + >::type LowerMarginShapes; typedef typename bmpl::accumulate< VectorAllSpecies, typename PMacc::math::CT::make_Int::type, PMacc::math::CT::max > > + >::type UpperMarginShapes; + + /* margins are always positive, also for lower margins + * additional current interpolations and current filters on FieldJ might + * spread the dependencies on neighboring cells + * -> use max(shape,filter) */ + typedef typename PMacc::math::CT::max< + LowerMarginShapes, + GetMargin::LowerMargin + >::type LowerMargin; + + typedef typename PMacc::math::CT::max< + UpperMarginShapes, + GetMargin::UpperMargin >::type UpperMargin; const DataSpace originGuard( LowerMargin( ).toRT( ) ); @@ -101,10 +115,34 @@ fieldJ( cellDescription.getGridLayout( ) ), fieldE( NULL ) // std::cout << "ex " << i << " x=" << guardingCells[0] << " y=" << guardingCells[1] << " z=" << guardingCells[2] << std::endl; fieldJ.addExchangeBuffer( i, guardingCells, FIELD_J ); } + + /* Receive border values in own guard for "receive" communication pattern - necessary for current interpolation/filter */ + const DataSpace originRecvGuard( GetMargin::LowerMargin( ).toRT( ) ); + const DataSpace endRecvGuard( GetMargin::UpperMargin( ).toRT( ) ); + if( originRecvGuard != DataSpace::create(0) || + endRecvGuard != DataSpace::create(0) ) + { + fieldJrecv = new GridBuffer ( fieldJ.getDeviceBuffer(), cellDescription.getGridLayout( ) ); + + /*go over all directions*/ + for ( uint32_t i = 1; i < NumberOfExchanges::value; ++i ) + { + DataSpace relativMask = Mask::getRelativeDirections ( i ); + /* guarding cells depend on direction + * for negative direction use originGuard else endGuard (relative direction ZERO is ignored) + * don't switch end and origin because this is a read buffer and no send buffer + */ + DataSpace guardingCells; + for ( uint32_t d = 0; d < simDim; ++d ) + guardingCells[d] = ( relativMask[d] == -1 ? originRecvGuard[d] : endRecvGuard[d] ); + fieldJrecv->addExchange( GUARD, i, guardingCells, FIELD_JRECV ); + } + } } FieldJ::~FieldJ( ) { + __delete(fieldJrecv); } SimulationDataId FieldJ::getUniqueId( ) @@ -132,7 +170,14 @@ EventTask FieldJ::asyncCommunication( EventTask serialEvent ) __startTransaction( serialEvent ); FieldFactory::getInstance( ).createTaskFieldSend( *this ); ret += __endTransaction( ); - return ret; + + if( fieldJrecv != NULL ) + { + EventTask eJ = fieldJrecv->asyncCommunication( ret ); + return eJ; + } + else + return ret; } void FieldJ::bashField( uint32_t exchangeType ) @@ -166,9 +211,10 @@ void FieldJ::insertField( uint32_t exchangeType ) direction, mapper ); } -void FieldJ::init( FieldE &fieldE ) +void FieldJ::init( FieldE &fieldE, FieldB &fieldB ) { this->fieldE = &fieldE; + this->fieldB = &fieldB; Environment<>::get( ).DataConnector( ).registerData( *this ); } @@ -184,7 +230,7 @@ void FieldJ::reset( uint32_t ) void FieldJ::clear( ) { - ValueType tmp = float3_X( 0. ); + ValueType tmp(ValueType::create(0.)); fieldJ.getDeviceBuffer( ).setValue( tmp ); //fieldJ.reset(false); } @@ -250,15 +296,17 @@ void FieldJ::computeCurrent( ParticlesClass &parClass, uint32_t ) throw (std::in __setTransactionEvent( __endTransaction( ) ); } -template -void FieldJ::addCurrentToE( ) +template +void FieldJ::addCurrentToEMF( T_CurrentInterpolation& myCurrentInterpolation ) { - __picKernelArea( ( kernelAddCurrentToE ), + __picKernelArea( ( kernelAddCurrentToEMF ), cellDescription, AREA ) ( MappingDesc::SuperCellSize::toRT( ).toDim3( ) ) ( this->fieldE->getDeviceDataBox( ), - this->fieldJ.getDeviceBuffer( ).getDataBox( ) ); + this->fieldB->getDeviceDataBox( ), + this->fieldJ.getDeviceBuffer( ).getDataBox( ), + myCurrentInterpolation ); } } diff --git a/src/picongpu/include/fields/MaxwellSolver/DirSplitting/DirSplitting.hpp b/src/picongpu/include/fields/MaxwellSolver/DirSplitting/DirSplitting.hpp index 67b1a6cb0e..7c878229de 100644 --- a/src/picongpu/include/fields/MaxwellSolver/DirSplitting/DirSplitting.hpp +++ b/src/picongpu/include/fields/MaxwellSolver/DirSplitting/DirSplitting.hpp @@ -40,19 +40,56 @@ namespace dirSplitting { using namespace PMacc; -class DirSplitting +/** Check Directional Splitting grid and time conditions + * + * This is a workaround that the condition check is only + * triggered if the current used solver is `DirSplitting` + */ +template +struct ConditionCheck +{ +}; + +template +struct ConditionCheck +{ + /* Directional Splitting conditions: + * + * using SI units to avoid round off errors + */ + PMACC_CASSERT_MSG(DirectionSplitting_Set_dX_equal_dt_times_c____check_your_gridConfig_param_file, + (SI::SPEED_OF_LIGHT_SI * SI::DELTA_T_SI) == SI::CELL_WIDTH_SI); + PMACC_CASSERT_MSG(DirectionSplitting_use_cubic_cells____check_your_gridConfig_param_file, + SI::CELL_HEIGHT_SI == SI::CELL_WIDTH_SI); +#if (SIMDIM == DIM3) + PMACC_CASSERT_MSG(DirectionSplitting_use_cubic_cells____check_your_gridConfig_param_file, + SI::CELL_DEPTH_SI == SI::CELL_WIDTH_SI); +#endif +}; + +class DirSplitting : private ConditionCheck { private: - template + template void propagate(CursorE cursorE, CursorB cursorB, GridSize gridSize) const { - typedef SuperCellSize BlockDim; + using namespace cursor::tools; + using namespace PMacc::math::tools; + + PMACC_AUTO(gridSizeTwisted,twistVectorAxes(gridSize)); + + /* twist components of the supercell */ + typedef PMacc::math::CT::Int< + PMacc::math::CT::At::type::value, + PMacc::math::CT::At::type::value, + PMacc::math::CT::At::type::value + > BlockDim; algorithm::kernel::ForeachBlock foreach; - foreach(zone::SphericZone<3>(PMacc::math::Size_t<3>(BlockDim::x::value, gridSize.y(), gridSize.z())), - cursor::make_NestedCursor(cursorE), - cursor::make_NestedCursor(cursorB), - DirSplittingKernel((int)gridSize.x())); + foreach(zone::SphericZone<3>(PMacc::math::Size_t<3>(BlockDim::x::value, gridSizeTwisted.y(), gridSizeTwisted.z())), + cursor::make_NestedCursor(twistVectorFieldAxes(cursorE)), + cursor::make_NestedCursor(twistVectorFieldAxes(cursorB)), + DirSplittingKernel((int)gridSizeTwisted.x())); } public: DirSplitting(MappingDesc) {} @@ -80,25 +117,30 @@ class DirSplitting PMacc::math::Size_t<3> gridSize = fieldE_coreBorder.size(); - propagate(fieldE_coreBorder.origin(), + + typedef PMacc::math::CT::Int<0,1,2> Orientation_X; + propagate( + fieldE_coreBorder.origin(), fieldB_coreBorder.origin(), - fieldE_coreBorder.size()); + gridSize); __setTransactionEvent(fieldE.asyncCommunication(__getTransactionEvent())); __setTransactionEvent(fieldB.asyncCommunication(__getTransactionEvent())); typedef PMacc::math::CT::Int<1,2,0> Orientation_Y; - propagate(twistVectorFieldAxes(fieldE_coreBorder.origin()), - twistVectorFieldAxes(fieldB_coreBorder.origin()), - twistVectorAxes(gridSize)); + propagate( + fieldE_coreBorder.origin(), + fieldB_coreBorder.origin(), + gridSize); __setTransactionEvent(fieldE.asyncCommunication(__getTransactionEvent())); __setTransactionEvent(fieldB.asyncCommunication(__getTransactionEvent())); typedef PMacc::math::CT::Int<2,0,1> Orientation_Z; - propagate(twistVectorFieldAxes(fieldE_coreBorder.origin()), - twistVectorFieldAxes(fieldB_coreBorder.origin()), - twistVectorAxes(gridSize)); + propagate( + fieldE_coreBorder.origin(), + fieldB_coreBorder.origin(), + gridSize); if (laserProfile::INIT_TIME > float_X(0.0)) dc.getData (FieldE::getName(), true).laserManipulation(currentStep); diff --git a/src/picongpu/include/fields/MaxwellSolver/DirSplitting/DirSplitting.kernel b/src/picongpu/include/fields/MaxwellSolver/DirSplitting/DirSplitting.kernel index fcbdc0b825..550693d1e3 100644 --- a/src/picongpu/include/fields/MaxwellSolver/DirSplitting/DirSplitting.kernel +++ b/src/picongpu/include/fields/MaxwellSolver/DirSplitting/DirSplitting.kernel @@ -36,23 +36,23 @@ struct DirSplittingKernel { typedef void result_type; - int totalLength; + PMACC_ALIGN(totalLength,int); DirSplittingKernel(int totalLength) : totalLength(totalLength) {} template DINLINE void propagate(CursorE cursorE, CursorB cursorB) const { - float a_plus = (*cursorB(-1, 0, 0)).z() + (*cursorE(-1, 0, 0)).y(); - float a_minus = (*cursorB(1, 0, 0)).z() - (*cursorE(1, 0, 0)).y(); - float a_prime_plus = (*cursorB(-1, 0, 0)).y() - (*cursorE(-1, 0, 0)).z(); - float a_prime_minus = (*cursorB(1, 0, 0)).y() + (*cursorE(1, 0, 0)).z(); + float_X a_plus = (*cursorB(-1, 0, 0)).z() + (*cursorE(-1, 0, 0)).y(); + float_X a_minus = (*cursorB(1, 0, 0)).z() - (*cursorE(1, 0, 0)).y(); + float_X a_prime_plus = (*cursorB(-1, 0, 0)).y() - (*cursorE(-1, 0, 0)).z(); + float_X a_prime_minus = (*cursorB(1, 0, 0)).y() + (*cursorE(1, 0, 0)).z(); __syncthreads(); - (*cursorB).z() = 0.5f * (a_plus + a_minus); - (*cursorE).y() = 0.5f * (a_plus - a_minus); - (*cursorB).y() = 0.5f * (a_prime_plus + a_prime_minus); - (*cursorE).z() = 0.5f * (a_prime_minus - a_prime_plus); + (*cursorB).z() = float_X(0.5) * (a_plus + a_minus); + (*cursorE).y() = float_X(0.5) * (a_plus - a_minus); + (*cursorB).y() = float_X(0.5) * (a_prime_plus + a_prime_minus); + (*cursorE).z() = float_X(0.5) * (a_prime_minus - a_prime_plus); __syncthreads(); } diff --git a/src/picongpu/include/fields/MaxwellSolver/None/NoSolver.hpp b/src/picongpu/include/fields/MaxwellSolver/None/NoSolver.hpp index 6952b82a17..cda8b3e96b 100644 --- a/src/picongpu/include/fields/MaxwellSolver/None/NoSolver.hpp +++ b/src/picongpu/include/fields/MaxwellSolver/None/NoSolver.hpp @@ -34,26 +34,31 @@ namespace picongpu { using namespace PMacc; + /** Check Yee grid and time conditions + * + * This is a workaround that the condition check is only + * triggered if the current used solver is `NoSolver` + */ + template + struct ConditionCheck + { + }; + + template + struct ConditionCheck + { + /* Courant-Friedrichs-Levy-Condition for Yee Field Solver: */ + PMACC_CASSERT_MSG(Courant_Friedrichs_Levy_condition_failure____check_your_gridConfig_param_file, + (SPEED_OF_LIGHT*SPEED_OF_LIGHT*DELTA_T*DELTA_T*INV_CELL2_SUM)<=1.0); + }; - class NoSolver + class NoSolver : private ConditionCheck { private: typedef MappingDesc::SuperCellSize SuperCellSize; MappingDesc cellDescription; - template - void updateE() - { - return; - } - - template - void updateBHalf() - { - return; - } - public: NoSolver(MappingDesc cellDescription) : cellDescription(cellDescription) diff --git a/src/picongpu/include/fields/MaxwellSolver/Yee/Curl.hpp b/src/picongpu/include/fields/MaxwellSolver/Yee/Curl.hpp index b2a34e7e72..c5811382cc 100644 --- a/src/picongpu/include/fields/MaxwellSolver/Yee/Curl.hpp +++ b/src/picongpu/include/fields/MaxwellSolver/Yee/Curl.hpp @@ -19,9 +19,7 @@ */ - -#ifndef YEE_CURL_HPP -#define YEE_CURL_HPP +#pragma once #include "types.h" @@ -29,25 +27,25 @@ namespace picongpu { namespace yeeSolver { - using namespace PMacc; +using namespace PMacc; - template - struct Curl - { - typedef typename Difference::OffsetOrigin LowerMargin; - typedef typename Difference::OffsetEnd UpperMargin; +template +struct Curl +{ + typedef typename Difference::OffsetOrigin LowerMargin; + typedef typename Difference::OffsetEnd UpperMargin; - template - HDINLINE typename Memory::ValueType operator()(const Memory & mem) const - { - Difference diff; - return float3_X(diff(mem, 1).z() - diff(mem, 2).y(), - diff(mem, 2).x() - diff(mem, 0).z(), - diff(mem, 0).y() - diff(mem, 1).x()); - } - }; + template + HDINLINE typename Memory::ValueType operator()(const Memory & mem) const + { + const typename Difference::template GetDifference<0> Dx; + const typename Difference::template GetDifference<1> Dy; + const typename Difference::template GetDifference<2> Dz; + + return float3_X(Dy(mem).z() - Dz(mem).y(), + Dz(mem).x() - Dx(mem).z(), + Dx(mem).y() - Dy(mem).x()); + } +}; } // namespace yeeSolver } // namespace picongpu - -#endif /* YEE_CURL_HPP */ - diff --git a/src/picongpu/include/fields/MaxwellSolver/Yee/YeeSolver.hpp b/src/picongpu/include/fields/MaxwellSolver/Yee/YeeSolver.hpp index 193de5a916..f018c881ea 100644 --- a/src/picongpu/include/fields/MaxwellSolver/Yee/YeeSolver.hpp +++ b/src/picongpu/include/fields/MaxwellSolver/Yee/YeeSolver.hpp @@ -57,6 +57,7 @@ class YeeSolver private: typedef MappingDesc::SuperCellSize SuperCellSize; + FieldE* fieldE; FieldB* fieldB; MappingDesc cellDescription; @@ -64,6 +65,10 @@ class YeeSolver template void updateE() { + /* Courant-Friedrichs-Levy-Condition for Yee Field Solver: */ + PMACC_CASSERT_MSG(Courant_Friedrichs_Levy_condition_failure____check_your_gridConfig_param_file, + (SPEED_OF_LIGHT*SPEED_OF_LIGHT*DELTA_T*DELTA_T*INV_CELL2_SUM)<=1.0); + typedef SuperCellDescription< SuperCellSize, typename CurlB::LowerMargin, diff --git a/src/picongpu/include/fields/background/templates/TWTS/BField.hpp b/src/picongpu/include/fields/background/templates/TWTS/BField.hpp new file mode 100644 index 0000000000..191d15598b --- /dev/null +++ b/src/picongpu/include/fields/background/templates/TWTS/BField.hpp @@ -0,0 +1,194 @@ +/** + * Copyright 2014-2015 Alexander Debus, Axel Huebl + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + + +#pragma once + +#include "types.h" + +#include "math/Vector.hpp" +#include "dimensions/DataSpace.hpp" +#include "fields/background/templates/TWTS/numComponents.hpp" + +namespace picongpu +{ +/* Load pre-defined background field */ +namespace templates +{ +/* Traveling-wave Thomson scattering laser pulse */ +namespace twts +{ + +class BField +{ +public: + typedef float_X float_T; + + enum PolarizationType + { + /* The linear polarization of the TWTS laser is defined + * relative to the plane of the pulse front tilt (reference plane). + * + * Polarisation is normal to the reference plane. + * Use Ex-fields (and corresponding B-fields) in TWTS laser internal coordinate system. + */ + LINEAR_X = 1u, + /* Polarization lies within the reference plane. + * Use Ey-fields (and corresponding B-fields) in TWTS laser internal coordinate system. + */ + LINEAR_YZ = 2u, + }; + + /* Center of simulation volume in number of cells */ + PMACC_ALIGN(halfSimSize,DataSpace); + /* y-position of TWTS coordinate origin inside the simulation coordinates [meter] + * The other origin coordinates (x and z) default to globally centered values + * with respect to the simulation volume. + */ + const PMACC_ALIGN(focus_y_SI,float_64); + /* Laser wavelength [meter] */ + const PMACC_ALIGN(wavelength_SI,float_64); + /* TWTS laser pulse duration [second] */ + const PMACC_ALIGN(pulselength_SI,float_64); + /* line focus height of TWTS pulse [meter] */ + const PMACC_ALIGN(w_x_SI,float_64); + /* line focus width of TWTS pulse [meter] */ + const PMACC_ALIGN(w_y_SI,float_64); + /* interaction angle between TWTS laser propagation vector and the y-axis [rad] */ + const PMACC_ALIGN(phi,float_X); + /* propagation speed of TWTS laser overlap + normalized to the speed of light. [Default: beta0 = 1.0] */ + const PMACC_ALIGN(beta_0,float_X); + /* If auto_tdelay=FALSE, then a user defined delay is used. [second] */ + const PMACC_ALIGN(tdelay_user_SI,float_64); + /* Make time step constant accessible to device. */ + const PMACC_ALIGN(dt,float_64); + /* Make length normalization constant accessible to device. */ + const PMACC_ALIGN(unit_length,float_64); + /* TWTS laser time delay */ + PMACC_ALIGN(tdelay,float_64); + /* Should the TWTS laser time delay be chosen automatically, such that + * the laser gradually enters the simulation volume? [Default: TRUE] + */ + const PMACC_ALIGN(auto_tdelay,bool); + /* Polarization of TWTS laser */ + const PMACC_ALIGN(pol,PolarizationType); + + /** Magnetic field of the TWTS laser + * + * \param focus_y_SI the distance to the laser focus in y-direction [m] + * \param wavelength_SI central wavelength [m] + * \param pulselength_SI sigma of std. gauss for intensity (E^2), + * pulselength_SI = FWHM_of_Intensity / 2.35482 [seconds (sigma)] + * \param w_x beam waist: distance from the axis where the pulse electric field + * decreases to its 1/e^2-th part at the focus position of the laser [m] + * \param w_y \see w_x + * \param phi interaction angle between TWTS laser propagation vector and + * the y-axis [rad, default = 90.*(PI/180.)] + * \param beta_0 propagation speed of overlap normalized to + * the speed of light [c, default = 1.0] + * \param tdelay_user manual time delay if auto_tdelay is false + * \param auto_tdelay calculate the time delay such that the TWTS pulse is not + * inside the simulation volume at simulation start timestep = 0 [default = true] + * \param pol determines the TWTS laser polarization, which is either normal or parallel + * to the laser pulse front tilt plane [ default= LINEAR_X , LINEAR_YZ ] + */ + HINLINE + BField( const float_64 focus_y_SI, + const float_64 wavelength_SI, + const float_64 pulselength_SI, + const float_64 w_x_SI, + const float_64 w_y_SI, + const float_X phi = 90.*(PI / 180.), + const float_X beta_0 = 1.0, + const float_64 tdelay_user_SI = 0.0, + const bool auto_tdelay = true, + const PolarizationType pol = LINEAR_X ); + + + /** Specify your background field B(r,t) here + * + * \param cellIdx The total cell id counted from the start at t=0 + * \param currentStep The current time step */ + HDINLINE float3_X + operator()( const DataSpace& cellIdx, + const uint32_t currentStep ) const; + + /** Calculate the By(r,t) field, when electric field vector (Ex,0,0) + * is normal to the pulse-front-tilt plane (y,z) + * + * \param pos Spatial position of the target field. + * \param time Absolute time (SI, including all offsets and transformations) + * for calculating the field */ + HDINLINE float_T + calcTWTSBy( const float3_64& pos, const float_64 time ) const; + + /** Calculate the Bz(r,t) field, when electric field vector (Ex,0,0) + * is normal to the pulse-front-tilt plane (y,z) + * + * \param pos Spatial position of the target field. + * \param time Absolute time (SI, including all offsets and transformations) + * for calculating the field */ + HDINLINE float_T + calcTWTSBz_Ex( const float3_64& pos, const float_64 time ) const; + + /** Calculate the By(r,t) field, when electric field vector (0,Ey,0) + * lies within the pulse-front-tilt plane (y,z) + * + * \param pos Spatial position of the target field. + * \param time Absolute time (SI, including all offsets and transformations) + * for calculating the field */ + HDINLINE float_T + calcTWTSBx( const float3_64& pos, const float_64 time ) const; + + /** Calculate the Bz(r,t) field here (electric field vector (0,Ey,0) + * lies within the pulse-front-tilt plane (y,z) + * + * \param pos Spatial position of the target field. + * \param time Absolute time (SI, including all offsets and transformations) + * for calculating the field */ + HDINLINE float_T + calcTWTSBz_Ey( const float3_64& pos, const float_64 time ) const; + + /** Calculate the B-field vector of the TWTS laser in SI units. + * \tparam T_dim Specializes for the simulation dimension + * \param cellIdx The total cell id counted from the start at timestep 0 + * \return B-field vector of the rotated TWTS field in SI units */ + template + HDINLINE float3_X + getTWTSBfield_Normalized( + const PMacc::math::Vector& eFieldPositions_SI, + const float_64 time) const; + + /** Calculate the B-field vector of the "in-plane" polarized TWTS laser in SI units. + * \tparam T_dim Specializes for the simulation dimension + * \param cellIdx The total cell id counted from the start at timestep 0 + * \return B-field vector of the rotated TWTS field in SI units */ + template + HDINLINE float3_X + getTWTSBfield_Normalized_Ey( + const PMacc::math::Vector& eFieldPositions_SI, + const float_64 time) const; + +}; + +} /* namespace twts */ +} /* namespace templates */ +} /* namespace picongpu */ diff --git a/src/picongpu/include/fields/background/templates/TWTS/BField.tpp b/src/picongpu/include/fields/background/templates/TWTS/BField.tpp new file mode 100644 index 0000000000..45522816d4 --- /dev/null +++ b/src/picongpu/include/fields/background/templates/TWTS/BField.tpp @@ -0,0 +1,706 @@ +/** + * Copyright 2014 Alexander Debus, Axel Huebl + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + + +#pragma once + +#include "types.h" +#include "simulation_defines.hpp" +#include "simulation_classTypes.hpp" + +#include "math/Vector.hpp" +#include "dimensions/DataSpace.hpp" +#include "mappings/simulation/SubGrid.hpp" +#include "math/Complex.hpp" + +#include "fields/background/templates/TWTS/RotateField.tpp" +#include "fields/background/templates/TWTS/GetInitialTimeDelay_SI.tpp" +#include "fields/background/templates/TWTS/getFieldPositions_SI.tpp" +#include "fields/background/templates/TWTS/BField.hpp" + +namespace picongpu +{ +/** Load pre-defined background field */ +namespace templates +{ +/** Traveling-wave Thomson scattering laser pulse */ +namespace twts +{ + namespace pmMath = PMacc::algorithms::math; + + HINLINE + BField::BField( const float_64 focus_y_SI, + const float_64 wavelength_SI, + const float_64 pulselength_SI, + const float_64 w_x_SI, + const float_64 w_y_SI, + const float_X phi, + const float_X beta_0, + const float_64 tdelay_user_SI, + const bool auto_tdelay, + const PolarizationType pol ) : + focus_y_SI(focus_y_SI), wavelength_SI(wavelength_SI), + pulselength_SI(pulselength_SI), w_x_SI(w_x_SI), + w_y_SI(w_y_SI), phi(phi), beta_0(beta_0), + tdelay_user_SI(tdelay_user_SI), dt(SI::DELTA_T_SI), + unit_length(UNIT_LENGTH), auto_tdelay(auto_tdelay), pol(pol) + { + /* Note: Enviroment-objects cannot be instantiated on CUDA GPU device. Since this is done + * on host (see fieldBackground.param), this is no problem. + */ + const SubGrid& subGrid = Environment::get().SubGrid(); + halfSimSize = subGrid.getGlobalDomain().size / 2; + tdelay = detail::getInitialTimeDelay_SI(auto_tdelay, tdelay_user_SI, + halfSimSize, pulselength_SI, + focus_y_SI, phi, beta_0); + } + + template<> + HDINLINE float3_X + BField::getTWTSBfield_Normalized( + const PMacc::math::Vector& bFieldPositions_SI, + const float_64 time) const + { + typedef PMacc::math::Vector PosVecVec; + PosVecVec pos(PosVecVec::create( + float3_64::create(0.0) + )); + + for (uint32_t k = 0; k + HDINLINE float3_X + BField::getTWTSBfield_Normalized_Ey( + const PMacc::math::Vector& bFieldPositions_SI, + const float_64 time) const + { + typedef PMacc::math::Vector PosVecVec; + PosVecVec pos(PosVecVec::create( + float3_64::create(0.0) + )); + + for (uint32_t k = 0; k + HDINLINE float3_X + BField::getTWTSBfield_Normalized( + const PMacc::math::Vector& bFieldPositions_SI, + const float_64 time) const + { + typedef PMacc::math::Vector PosVecVec; + PosVecVec pos(PosVecVec::create( + float3_64::create(0.0) + )); + + for (uint32_t k = 0; k z (Meaning: In 2D-sim, insert cell-coordinate x + * into TWTS field function coordinate z.) + * y --> y + * z --> -x (Since z=0 for 2D, we use the existing + * 3D TWTS-field-function and set x = -0) + * The transformed 3D coordinates are used to calculate the field components. + * Ex --> Ez (Meaning: Calculate Ex-component of existing 3D TWTS-field (calcTWTSEx) using + * transformed position vectors to obtain the corresponding Ez-component in 2D. + * Note: Swapping field component coordinates also alters the + * intra-cell position offset.) + * By --> By + * Bz --> -Bx (Yes, the sign is necessary.) + * + * An example of intra-cell position offsets is the staggered Yee-grid. + * + * This procedure is analogous to 3D case, but replace By --> By and Bz --> -Bx. Hence the + * grid cell offset for Bx has to be used instead of Bz. Mind the "-"-sign. + */ + + /* Calculate By-component with the intra-cell offset of a By-field */ + const float_64 By_By = calcTWTSBy(pos[1], time); + /* Calculate Bx-component with the intra-cell offset of a By-field */ + const float_64 Bx_By = -calcTWTSBz_Ex(pos[1], time); + /* Calculate By-component with the intra-cell offset of a Bx-field */ + const float_64 By_Bx = calcTWTSBy(pos[0], time); + /* Calculate Bx-component with the intra-cell offset of a Bx-field */ + const float_64 Bx_Bx = -calcTWTSBz_Ex(pos[0], time); + /* Since we rotated all position vectors before calling calcTWTSBy and calcTWTSBz_Ex, we + * need to back-rotate the resulting B-field vector. Now the rotation is done + * analogously in the (y,x)-plane. (Reverse of the position vector transformation.) + * + * RotationMatrix[-(PI / 2+phi)].(By,Bx) for rotating back the field vectors. + */ + const float_64 By_rot = -pmMath::sin(phi)*By_By+pmMath::cos(phi)*Bx_By; + const float_64 Bx_rot = -pmMath::cos(phi)*By_Bx-pmMath::sin(phi)*Bx_Bx; + + /* Finally, the B-field normalized to the peak amplitude. */ + return float3_X( float_X(Bx_rot), + float_X(By_rot), + float_X(0.0) ); + } + + template<> + HDINLINE float3_X + BField::getTWTSBfield_Normalized_Ey( + const PMacc::math::Vector& bFieldPositions_SI, + const float_64 time) const + { + typedef PMacc::math::Vector PosVecVec; + PosVecVec pos(PosVecVec::create( + float3_64::create(0.0) + )); + + for (uint32_t k = 0; k z (Meaning: In 2D-sim, insert cell-coordinate x + * into TWTS field function coordinate z.) + * y --> y + * z --> -x (Since z=0 for 2D, we use the existing + * 3D TWTS-field-function and set x = -0) + * Ex --> Ez (Meaning: Calculate Ex-component of existing 3D TWTS-field to obtain + * corresponding Ez-component in 2D. + * Note: the intra-cell position offset due to the staggered grid for Ez.) + * By --> By + * Bz --> -Bx (Yes, the sign is necessary.) + * + * This procedure is analogous to 3D case, but replace By --> By and Bz --> -Bx. Hence the + * grid cell offset for Bx has to be used instead of Bz. Mind the -sign. + */ + + /* Calculate Bx-component with the intra-cell offset of a By-field */ + const float_64 Bx_By = -calcTWTSBz_Ex(pos[1], time); + /* Calculate Bx-component with the intra-cell offset of a Bx-field */ + const float_64 Bx_Bx = -calcTWTSBz_Ex(pos[0], time); + + /* Since we rotated all position vectors before calling calcTWTSBz_Ex, we + * need to back-rotate the resulting B-field vector. Now the rotation is done + * analogously in the (y,x)-plane. (Reverse of the position vector transformation.) + * + * RotationMatrix[-(PI / 2+phi)].(By,Bx) + * for rotating back the field-vectors. + */ + const float_64 By_rot = +pmMath::cos(phi)*Bx_By; + const float_64 Bx_rot = -pmMath::sin(phi)*Bx_Bx; + + /* Finally, the B-field normalized to the peak amplitude. */ + return float3_X( float_X( Bx_rot ), + float_X( By_rot ), + float_X( calcTWTSBx(pos[2], time) ) ); + } + + HDINLINE float3_X + BField::operator()( const DataSpace& cellIdx, + const uint32_t currentStep ) const + { + const float_64 time_SI = float_64(currentStep) * dt - tdelay; + + const PMacc::math::Vector bFieldPositions_SI = + detail::getFieldPositions_SI(cellIdx,halfSimSize, + fieldSolver::NumericalCellType::getBFieldPosition(),unit_length,focus_y_SI,phi); + /* Single TWTS-Pulse */ + switch (pol) + { + case LINEAR_X : + return getTWTSBfield_Normalized(bFieldPositions_SI, time_SI); + + case LINEAR_YZ : + return getTWTSBfield_Normalized_Ey(bFieldPositions_SI, time_SI); + } + return getTWTSBfield_Normalized(bFieldPositions_SI, time_SI); // defensive default + } + + /** Calculate the By(r,t) field here + * + * \param pos Spatial position of the target field. + * \param time Absolute time (SI, including all offsets and transformations) + * for calculating the field */ + HDINLINE BField::float_T + BField::calcTWTSBy( const float3_64& pos, const float_64 time ) const + { + typedef PMacc::math::Complex complex_T; + typedef PMacc::math::Complex complex_64; + /* Unit of speed */ + const double UNIT_SPEED = SI::SPEED_OF_LIGHT_SI; + /* Unit of time */ + const double UNIT_TIME = SI::DELTA_T_SI; + /* Unit of length */ + const double UNIT_LENGTH = UNIT_TIME*UNIT_SPEED; + + /* Propagation speed of overlap normalized to the speed of light [Default: beta0=1.0] */ + const float_T beta0 = float_T(beta_0); + const float_T phiReal = float_T(phi); + const float_T alphaTilt = pmMath::atan2(float_T(1.0)-beta0*pmMath::cos(phiReal), + beta0*pmMath::sin(phiReal)); + /* Definition of the laser pulse front tilt angle for the laser field below. + * + * For beta0=1.0, this is equivalent to our standard definition. Question: Why is the + * local "phi_T" not equal in value to the object member "phiReal" or "phi"? + * Because the standard TWTS pulse is defined for beta0 = 1.0 and in the coordinate-system + * of the TWTS model phi is responsible for pulse front tilt and dispersion only. Hence + * the dispersion will (although physically correct) be slightly off the ideal TWTS + * pulse for beta0 != 1.0. This only shows that this TWTS pulse is primarily designed for + * scenarios close to beta0 = 1. + */ + const float_T phiT = float_T(2.0)*alphaTilt; + + /* Angle between the laser pulse front and the y-axis. Not used, but remains in code for + * documentation purposes. + * const float_T eta = float_T(PI/2) - (phiReal - alphaTilt); + */ + + const float_T cspeed = float_T( SI::SPEED_OF_LIGHT_SI / UNIT_SPEED ); + const float_T lambda0 = float_T(wavelength_SI / UNIT_LENGTH); + const float_T om0 = float_T(2.0*PI*cspeed / lambda0); + /* factor 2 in tauG arises from definition convention in laser formula */ + const float_T tauG = float_T(pulselength_SI*2.0 / UNIT_TIME); + /* w0 is wx here --> w0 could be replaced by wx */ + const float_T w0 = float_T(w_x_SI / UNIT_LENGTH); + const float_T rho0 = float_T(PI*w0*w0 / lambda0); + /* wy is width of TWTS pulse */ + const float_T wy = float_T(w_y_SI / UNIT_LENGTH); + const float_T k = float_T(2.0*PI / lambda0); + const float_T x = float_T(pos.x() / UNIT_LENGTH); + const float_T y = float_T(pos.y() / UNIT_LENGTH); + const float_T z = float_T(pos.z() / UNIT_LENGTH); + const float_T t = float_T(time / UNIT_TIME); + + /* Shortcuts for speeding up the field calculation. */ + const float_T sinPhi = pmMath::sin(phiT); + const float_T cosPhi = pmMath::cos(phiT); + const float_T cosPhi2 = pmMath::cos(phiT / 2.0); + const float_T tanPhi2 = pmMath::tan(phiT / 2.0); + + /* The "helpVar" variables decrease the nesting level of the evaluated expressions and + * thus help with formal code verification through manual code inspection. + */ + const complex_T helpVar1 = rho0 + complex_T(0,1)*y*cosPhi + complex_T(0,1)*z*sinPhi; + const complex_T helpVar2 = cspeed*om0*tauG*tauG + complex_T(0,2) + *(-z - y*pmMath::tan(float_T(PI / 2)-phiT))*tanPhi2*tanPhi2; + const complex_T helpVar3 = complex_T(0,1)*rho0 - y*cosPhi - z*sinPhi; + + const complex_T helpVar4 = float_T(-1.0)*( + cspeed*cspeed*k*om0*tauG*tauG*wy*wy*x*x + + float_T(2.0)*cspeed*cspeed*om0*t*t*wy*wy*rho0 + - complex_T(0,2)*cspeed*cspeed*om0*om0*t*tauG*tauG*wy*wy*rho0 + + float_T(2.0)*cspeed*cspeed*om0*tauG*tauG*y*y*rho0 + - float_T(4.0)*cspeed*om0*t*wy*wy*z*rho0 + + complex_T(0,2)*cspeed*om0*om0*tauG*tauG*wy*wy*z*rho0 + + float_T(2.0)*om0*wy*wy*z*z*rho0 + + float_T(4.0)*cspeed*om0*t*wy*wy*y*rho0*tanPhi2 + - float_T(4.0)*om0*wy*wy*y*z*rho0*tanPhi2 + - complex_T(0,2)*cspeed*k*wy*wy*x*x*z*tanPhi2*tanPhi2 + + float_T(2.0)*om0*wy*wy*y*y*rho0*tanPhi2*tanPhi2 + - float_T(4.0)*cspeed*om0*t*wy*wy*z*rho0*tanPhi2*tanPhi2 + - complex_T(0,4)*cspeed*y*y*z*rho0*tanPhi2*tanPhi2 + + float_T(4.0)*om0*wy*wy*z*z*rho0*tanPhi2*tanPhi2 + - complex_T(0,2)*cspeed*k*wy*wy*x*x*y*pmMath::tan(float_T(PI / 2)-phiT)*tanPhi2*tanPhi2 + - float_T(4.0)*cspeed*om0*t*wy*wy*y*rho0*pmMath::tan(float_T(PI / 2)-phiT) + *tanPhi2*tanPhi2 + - complex_T(0,4)*cspeed*y*y*y*rho0*pmMath::tan(float_T(PI / 2)-phiT)*tanPhi2*tanPhi2 + + float_T(4.0)*om0*wy*wy*y*z*rho0*pmMath::tan(float_T(PI / 2)-phiT)*tanPhi2*tanPhi2 + + float_T(2.0)*z*sinPhi*( + + om0*( + + cspeed*cspeed*( + complex_T(0,1)*t*t*wy*wy + + om0*t*tauG*tauG*wy*wy + + complex_T(0,1)*tauG*tauG*y*y + ) + - cspeed*(complex_T(0,2)*t + om0*tauG*tauG)*wy*wy*z + + complex_T(0,1)*wy*wy*z*z + ) + + complex_T(0,2)*om0*wy*wy*y*(cspeed*t - z)*tanPhi2 + + complex_T(0,1)*tanPhi2*tanPhi2*( + complex_T(0,-2)*cspeed*y*y*z + + om0*wy*wy*( y*y - float_T(2.0)*(cspeed*t - z)*z ) + ) + ) + + float_T(2.0)*y*cosPhi*( + + om0*( + + cspeed*cspeed*( + complex_T(0,1)*t*t*wy*wy + + om0*t*tauG*tauG*wy*wy + + complex_T(0,1)*tauG*tauG*y*y + ) + - cspeed*(complex_T(0,2)*t + om0*tauG*tauG)*wy*wy*z + + complex_T(0,1)*wy*wy*z*z + ) + + complex_T(0,2)*om0*wy*wy*y*(cspeed*t - z)*tanPhi2 + + complex_T(0,1)*( + complex_T(0,-4)*cspeed*y*y*z + + om0*wy*wy*(y*y - float_T(4.0)*(cspeed*t - z)*z) + - float_T(2.0)*y*( + + cspeed*om0*t*wy*wy + + complex_T(0,1)*cspeed*y*y + - om0*wy*wy*z + )*pmMath::tan(float_T(PI / 2)-phiT) + )*tanPhi2*tanPhi2 + ) + /* The "round-trip" conversion in the line below fixes a gross accuracy bug + * in floating-point arithmetics, when float_T is set to float_X. + */ + ) * complex_T( float_64(1.0) / complex_64(float_T(2.0)*cspeed*wy*wy*helpVar1*helpVar2) ); + + const complex_T helpVar5 = complex_T(0,-1)*cspeed*om0*tauG*tauG + + (-z - y*pmMath::tan(float_T(PI / 2)-phiT)) + *tanPhi2*tanPhi2*float_T(2.0); + const complex_T helpVar6 = (cspeed*(cspeed*om0*tauG*tauG + complex_T(0,2) + *(-z - y*pmMath::tan(float_T(PI / 2)-phiT))*tanPhi2*tanPhi2)) + / (om0*rho0); + const complex_T result = (pmMath::exp(helpVar4)*tauG / cosPhi2 / cosPhi2 + *(rho0 + complex_T(0,1)*y*cosPhi + complex_T(0,1)*z*sinPhi) + *( + complex_T(0,2)*cspeed*t + cspeed*om0*tauG*tauG - complex_T(0,4)*z + + cspeed*(complex_T(0,2)*t + om0*tauG*tauG)*cosPhi + + complex_T(0,2)*y*tanPhi2 + )*pmMath::pow(helpVar3,float_T(-1.5)) + ) / (float_T(2.0)*helpVar5*pmMath::sqrt(helpVar6)); + + return result.get_real() / UNIT_SPEED; + } + + /** Calculate the Bz(r,t) field + * + * \param pos Spatial position of the target field. + * \param time Absolute time (SI, including all offsets and transformations) + * for calculating the field */ + HDINLINE BField::float_T + BField::calcTWTSBz_Ex( const float3_64& pos, const float_64 time ) const + { + typedef PMacc::math::Complex complex_T; + /** Unit of Speed */ + const double UNIT_SPEED = SI::SPEED_OF_LIGHT_SI; + /** Unit of time */ + const double UNIT_TIME = SI::DELTA_T_SI; + /** Unit of length */ + const double UNIT_LENGTH = UNIT_TIME*UNIT_SPEED; + + /* propagation speed of overlap normalized to the speed of light [Default: beta0=1.0] */ + const float_T beta0 = float_T(beta_0); + const float_T phiReal = float_T(phi); + const float_T alphaTilt = pmMath::atan2(float_T(1.0)-beta0*pmMath::cos(phiReal), + beta0*pmMath::sin(phiReal)); + + /* Definition of the laser pulse front tilt angle for the laser field below. + * + * For beta0=1.0, this is equivalent to our standard definition. Question: Why is the + * local "phi_T" not equal in value to the object member "phiReal" or "phi"? + * Because the standard TWTS pulse is defined for beta0 = 1.0 and in the coordinate-system + * of the TWTS model phi is responsible for pulse front tilt and dispersion only. Hence + * the dispersion will (although physically correct) be slightly off the ideal TWTS + * pulse for beta0 != 1.0. This only shows that this TWTS pulse is primarily designed for + * scenarios close to beta0 = 1. + */ + const float_T phiT = float_T(2.0)*alphaTilt; + + /* Angle between the laser pulse front and the y-axis. + * Not used, but remains in code for documentation purposes. + * const float_T eta = float_T(float_T(PI / 2)) - (phiReal - alphaTilt); + */ + + const float_T cspeed = float_T( SI::SPEED_OF_LIGHT_SI / UNIT_SPEED ); + const float_T lambda0 = float_T(wavelength_SI / UNIT_LENGTH); + const float_T om0 = float_T(2.0*PI*cspeed / lambda0); + /* factor 2 in tauG arises from definition convention in laser formula */ + const float_T tauG = float_T(pulselength_SI*2.0 / UNIT_TIME); + /* w0 is wx here --> w0 could be replaced by wx */ + const float_T w0 = float_T(w_x_SI / UNIT_LENGTH); + const float_T rho0 = float_T(PI*w0*w0 / lambda0); + /* wy is width of TWTS pulse */ + const float_T wy = float_T(w_y_SI / UNIT_LENGTH); + const float_T k = float_T(2.0*PI / lambda0); + const float_T x = float_T(pos.x() / UNIT_LENGTH); + const float_T y = float_T(pos.y() / UNIT_LENGTH); + const float_T z = float_T(pos.z() / UNIT_LENGTH); + const float_T t = float_T(time / UNIT_TIME); + + /* Shortcuts for speeding up the field calculation. */ + const float_T sinPhi = pmMath::sin(phiT); + const float_T cosPhi = pmMath::cos(phiT); + const float_T sinPhi2 = pmMath::sin(phiT / float_T(2.0)); + const float_T cosPhi2 = pmMath::cos(phiT / float_T(2.0)); + const float_T tanPhi2 = pmMath::tan(phiT / float_T(2.0)); + + /* The "helpVar" variables decrease the nesting level of the evaluated expressions and + * thus help with formal code verification through manual code inspection. + */ + const complex_T helpVar1 = -(cspeed*z) - cspeed*y*pmMath::tan(float_T(PI / 2)-phiT) + + complex_T(0,1)*cspeed*rho0 / sinPhi; + const complex_T helpVar2 = complex_T(0,1)*rho0 - y*cosPhi - z*sinPhi; + const complex_T helpVar3 = helpVar2*cspeed; + const complex_T helpVar4 = cspeed*om0*tauG*tauG + - complex_T(0,1)*y*cosPhi / cosPhi2 / cosPhi2*tanPhi2 + - complex_T(0,2)*z*tanPhi2*tanPhi2; + const complex_T helpVar5 = float_T(2.0)*cspeed*t - complex_T(0,1)*cspeed*om0*tauG*tauG + - float_T(2.0)*z + float_T(8.0)*y / sinPhi / sinPhi / sinPhi + *sinPhi2*sinPhi2*sinPhi2*sinPhi2 + - float_T(2.0)*z*tanPhi2*tanPhi2; + + const complex_T helpVar6 = ( + (om0*y*rho0 / cosPhi2 / cosPhi2 / cosPhi2 / cosPhi2) / helpVar1 + - (complex_T(0,2)*k*x*x) / helpVar2 + - (complex_T(0,1)*om0*om0*tauG*tauG*rho0) / helpVar2 + - (complex_T(0,4)*y*y*rho0) / (wy*wy*helpVar2) + + (om0*om0*tauG*tauG*y*cosPhi) / helpVar2 + + (float_T(4.0)*y*y*y*cosPhi) / (wy*wy*helpVar2) + + (om0*om0*tauG*tauG*z*sinPhi) / helpVar2 + + (float_T(4.0)*y*y*z*sinPhi) / (wy*wy*helpVar2) + + (complex_T(0,2)*om0*y*y*cosPhi / cosPhi2 / cosPhi2*tanPhi2) / helpVar3 + + (om0*y*rho0*cosPhi / cosPhi2 / cosPhi2*tanPhi2) / helpVar3 + + (complex_T(0,1)*om0*y*y*cosPhi*cosPhi/cosPhi2/cosPhi2*tanPhi2)/helpVar3 + + (complex_T(0,4)*om0*y*z*tanPhi2*tanPhi2) / helpVar3 + - (float_T(2.0)*om0*z*rho0*tanPhi2*tanPhi2) / helpVar3 + - (complex_T(0,2)*om0*z*z*sinPhi*tanPhi2*tanPhi2) / helpVar3 + - (om0*helpVar5*helpVar5) / (cspeed*helpVar4) + ) / float_T(4.0); + + const complex_T helpVar7 = cspeed*om0*tauG*tauG + - complex_T(0,1)*y*cosPhi / cosPhi2 / cosPhi2*tanPhi2 + - complex_T(0,2)*z*tanPhi2*tanPhi2; + const complex_T result = ( complex_T(0,2)*pmMath::exp(helpVar6)*tauG*tanPhi2 + *(cspeed*t - z + y*tanPhi2) + *pmMath::sqrt( (om0*rho0) / helpVar3 ) + ) / pmMath::pow(helpVar7,float_T(1.5)); + + return result.get_real() / UNIT_SPEED; + } + + /** Calculate the Bx(r,t) field + * + * \param pos Spatial position of the target field. + * \param time Absolute time (SI, including all offsets and transformations) + * for calculating the field */ + HDINLINE BField::float_T + BField::calcTWTSBx( const float3_64& pos, const float_64 time ) const + { + /* The Bx-field for the Ey-field is the same as + * for the By-field for the Ex-field except for the sign. + */ + return -calcTWTSBy( pos, time ); + } + + /** Calculate the Bz(r,t) field + * + * \param pos Spatial position of the target field. + * \param time Absolute time (SI, including all offsets and transformations) + * for calculating the field */ + HDINLINE BField::float_T + BField::calcTWTSBz_Ey( const float3_64& pos, const float_64 time ) const + { + typedef PMacc::math::Complex complex_T; + typedef PMacc::math::Complex complex_64; + /** Unit of speed */ + const double UNIT_SPEED = SI::SPEED_OF_LIGHT_SI; + /** Unit of time */ + const double UNIT_TIME = SI::DELTA_T_SI; + /** Unit of length */ + const double UNIT_LENGTH = UNIT_TIME*UNIT_SPEED; + + /* Propagation speed of overlap normalized to the speed of light [Default: beta0=1.0] */ + const float_T beta0 = float_T(beta_0); + const float_T phiReal = float_T(phi); + const float_T alphaTilt = pmMath::atan2(float_T(1.0)-beta0*pmMath::cos(phiReal), + beta0*pmMath::sin(phiReal)); + /* Definition of the laser pulse front tilt angle for the laser field below. + * + * For beta0=1.0, this is equivalent to our standard definition. Question: Why is the + * local "phi_T" not equal in value to the object member "phiReal" or "phi"? + * Because the standard TWTS pulse is defined for beta0 = 1.0 and in the coordinate-system + * of the TWTS model phi is responsible for pulse front tilt and dispersion only. Hence + * the dispersion will (although physically correct) be slightly off the ideal TWTS + * pulse for beta0 != 1.0. This only shows that this TWTS pulse is primarily designed for + * scenarios close to beta0 = 1. + */ + const float_T phiT = float_T(2.0)*alphaTilt; + + /* Angle between the laser pulse front and the y-axis. + * Not used, but remains in code for documentation purposes. + * const float_T eta = float_T(float_T(PI / 2)) - (phiReal - alphaTilt); + */ + + const float_T cspeed = float_T( SI::SPEED_OF_LIGHT_SI / UNIT_SPEED ); + const float_T lambda0 = float_T(wavelength_SI / UNIT_LENGTH); + const float_T om0 = float_T(2.0*PI*cspeed / lambda0); + /* factor 2 in tauG arises from definition convention in laser formula */ + const float_T tauG = float_T(pulselength_SI*2.0 / UNIT_TIME); + /* w0 is wx here --> w0 could be replaced by wx */ + const float_T w0 = float_T(w_x_SI / UNIT_LENGTH); + const float_T rho0 = float_T(PI*w0*w0 / lambda0); + /* wy is width of TWTS pulse */ + const float_T wy = float_T(w_y_SI / UNIT_LENGTH); + const float_T k = float_T(2.0*PI / lambda0); + const float_T x = float_T(pos.x() / UNIT_LENGTH); + const float_T y = float_T(pos.y() / UNIT_LENGTH); + const float_T z = float_T(pos.z() / UNIT_LENGTH); + const float_T t = float_T(time / UNIT_TIME); + + /* Shortcuts for speeding up the field calculation. */ + const float_T sinPhi = pmMath::sin(phiT); + const float_T cosPhi = pmMath::cos(phiT); + const float_T sinPhi2 = pmMath::sin(phiT / float_T(2.0)); + const float_T cosPhi2 = pmMath::cos(phiT / float_T(2.0)); + const float_T tanPhi2 = pmMath::tan(phiT / float_T(2.0)); + + /* The "helpVar" variables decrease the nesting level of the evaluated expressions and + * thus help with formal code verification through manual code inspection. + */ + const complex_T helpVar1 = + complex_T(0,-1)*cspeed*om0*tauG*tauG + - y*cosPhi / cosPhi2 / cosPhi2 * tanPhi2 + - float_T(2.0)*z*tanPhi2*tanPhi2; + const complex_T helpVar2 = complex_T(0,1)*rho0 - y*cosPhi - z*sinPhi; + + const complex_T helpVar3 = ( + - cspeed*cspeed*k*om0*tauG*tauG*wy*wy*x*x + - float_T(2.0)*cspeed*cspeed*om0*t*t*wy*wy*rho0 + + complex_T(0,2)*cspeed*cspeed*om0*om0*t*tauG*tauG*wy*wy*rho0 + - float_T(2.0)*cspeed*cspeed*om0*tauG*tauG*y*y*rho0 + + float_T(4.0)*cspeed*om0*t*wy*wy*z*rho0 + - complex_T(0,2)*cspeed*om0*om0*tauG*tauG*wy*wy*z*rho0 + - float_T(2.0)*om0*wy*wy*z*z*rho0 + - complex_T(0,8)*om0*wy*wy*y*(cspeed*t - z)*z*sinPhi2*sinPhi2 + + complex_T(0,8) / sinPhi *( + float_T(2.0)*z*z*(cspeed*om0*t*wy*wy + complex_T(0,1)*cspeed*y*y - om0*wy*wy*z) + + y*( + cspeed*k*wy*wy*x*x + - complex_T(0,2)*cspeed*om0*t*wy*wy*rho0 + + float_T(2.0)*cspeed*y*y*rho0 + + complex_T(0,2)*om0*wy*wy*z*rho0 + )*tan(float_T(PI) / float_T(2.0)-phiT) / sinPhi + )*sinPhi2*sinPhi2*sinPhi2*sinPhi2 + - complex_T(0,2)*cspeed*cspeed*om0*t*t*wy*wy*z*sinPhi + - float_T(2.0)*cspeed*cspeed*om0*om0*t*tauG*tauG*wy*wy*z*sinPhi + - complex_T(0,2)*cspeed*cspeed*om0*tauG*tauG*y*y*z*sinPhi + + complex_T(0,4)*cspeed*om0*t*wy*wy*z*z*sinPhi + + float_T(2.0)*cspeed*om0*om0*tauG*tauG*wy*wy*z*z*sinPhi + - complex_T(0,2)*om0*wy*wy*z*z*z*sinPhi + - float_T(4.0)*cspeed*om0*t*wy*wy*y*rho0*tanPhi2 + + float_T(4.0)*om0*wy*wy*y*z*rho0*tanPhi2 + + complex_T(0,2)*y*y*( + cspeed*om0*t*wy*wy + + complex_T(0,1)*cspeed*y*y + - om0*wy*wy*z + )*cosPhi*cosPhi / cosPhi2 / cosPhi2 * tanPhi2 + + complex_T(0,2)*cspeed*k*wy*wy*x*x*z*tanPhi2*tanPhi2 + - float_T(2.0)*om0*wy*wy*y*y*rho0*tanPhi2*tanPhi2 + + float_T(4.0)*cspeed*om0*t*wy*wy*z*rho0*tanPhi2*tanPhi2 + + complex_T(0,4)*cspeed*y*y*z*rho0*tanPhi2*tanPhi2 + - float_T(4.0)*om0*wy*wy*z*z*rho0*tanPhi2*tanPhi2 + - complex_T(0,2)*om0*wy*wy*y*y*z*sinPhi*tanPhi2*tanPhi2 + - float_T(2.0)*y*cosPhi*( + om0*( + cspeed*cspeed*(complex_T(0,1)*t*t*wy*wy + + om0*t*tauG*tauG*wy*wy + + complex_T(0,1)*tauG*tauG*y*y) + - cspeed*(complex_T(0,2)*t + om0*tauG*tauG)*wy*wy*z + + complex_T(0,1)*wy*wy*z*z + ) + + complex_T(0,2)*om0*wy*wy*y*(cspeed*t - z)*tanPhi2 + + complex_T(0,1)*( + complex_T(0,-4)*cspeed*y*y*z + + om0*wy*wy*(y*y - float_T(4.0)*(cspeed*t - z)*z) + )*tanPhi2*tanPhi2 + ) + /* The "round-trip" conversion in the line below fixes a gross accuracy bug + * in floating-point arithmetics, when float_T is set to float_X. + */ + ) * complex_T( float_64(1.0) / complex_64(float_T(2.0)*cspeed*wy*wy*helpVar2*helpVar1) ); + + const complex_T helpVar4 = ( + cspeed*om0*( + cspeed*om0*tauG*tauG + - complex_T(0,8)*y*pmMath::tan( float_T(PI) / float_T(2.0) - phiT ) + / sinPhi / sinPhi * sinPhi2*sinPhi2*sinPhi2*sinPhi2 + - complex_T(0,2)*z*tanPhi2*tanPhi2 + ) + ) / rho0; + + const complex_T result = float_T(-1.0)*( + cspeed*pmMath::exp(helpVar3)*k*tauG*x*pmMath::pow( helpVar2, float_T(-1.5) ) + / pmMath::sqrt(helpVar4) + ); + + return result.get_real() / UNIT_SPEED; + } + +} /* namespace twts */ +} /* namespace templates */ +} /* namespace picongpu */ diff --git a/src/picongpu/include/fields/background/templates/TWTS/EField.hpp b/src/picongpu/include/fields/background/templates/TWTS/EField.hpp new file mode 100644 index 0000000000..af2fc61f05 --- /dev/null +++ b/src/picongpu/include/fields/background/templates/TWTS/EField.hpp @@ -0,0 +1,176 @@ +/** + * Copyright 2014-2015 Alexander Debus, Axel Huebl + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + + +#pragma once + +#include "types.h" + +#include "math/Vector.hpp" +#include "dimensions/DataSpace.hpp" +#include "fields/background/templates/TWTS/numComponents.hpp" + +namespace picongpu +{ +/* Load pre-defined background field */ +namespace templates +{ +/* Traveling-wave Thomson scattering laser pulse */ +namespace twts +{ + +class EField +{ +public: + typedef float_X float_T; + + enum PolarizationType + { + /* The linear polarization of the TWTS laser is defined + * relative to the plane of the pulse front tilt. + * + * Polarisation is normal to the reference plane. + * Use Ex-fields (and corresponding B-fields) in TWTS laser internal coordinate system. + */ + LINEAR_X = 1u, + /* Polarization lies within the reference plane. + * Use Ey-fields (and corresponding B-fields) in TWTS laser internal coordinate system. + */ + LINEAR_YZ = 2u, + }; + + /* Center of simulation volume in number of cells */ + PMACC_ALIGN(halfSimSize,DataSpace); + /* y-position of TWTS coordinate origin inside the simulation coordinates [meter] + The other origin coordinates (x and z) default to globally centered values + with respect to the simulation volume. */ + const PMACC_ALIGN(focus_y_SI,float_64); + /* Laser wavelength [meter] */ + const PMACC_ALIGN(wavelength_SI,float_64); + /* TWTS laser pulse duration [second] */ + const PMACC_ALIGN(pulselength_SI,float_64); + /* line focus height of TWTS pulse [meter] */ + const PMACC_ALIGN(w_x_SI,float_64); + /* line focus width of TWTS pulse [meter] */ + const PMACC_ALIGN(w_y_SI,float_64); + /* interaction angle between TWTS laser propagation vector and the y-axis [rad] */ + const PMACC_ALIGN(phi,float_X); + /* propagation speed of TWTS laser overlap + normalized to the speed of light. [Default: beta0=1.0] */ + const PMACC_ALIGN(beta_0,float_X); + /* If auto_tdelay=FALSE, then a user defined delay is used. [second] */ + const PMACC_ALIGN(tdelay_user_SI,float_64); + /* Make time step constant accessible to device. */ + const PMACC_ALIGN(dt,float_64); + /* Make length normalization constant accessible to device. */ + const PMACC_ALIGN(unit_length,float_64); + /* TWTS laser time delay */ + PMACC_ALIGN(tdelay,float_64); + /* Should the TWTS laser delay be chosen automatically, such that + * the laser gradually enters the simulation volume? [Default: TRUE] + */ + const PMACC_ALIGN(auto_tdelay,bool); + /* Polarization of TWTS laser */ + const PMACC_ALIGN(pol,PolarizationType); + + /** Electric field of the TWTS laser + * + * \param focus_y_SI the distance to the laser focus in y-direction [m] + * \param wavelength_SI central wavelength [m] + * \param pulselength_SI sigma of std. gauss for intensity (E^2), + * pulselength_SI = FWHM_of_Intensity / 2.35482 [seconds (sigma)] + * \param w_x beam waist: distance from the axis where the pulse electric field + * decreases to its 1/e^2-th part at the focus position of the laser [m] + * \param w_y \see w_x + * \param phi interaction angle between TWTS laser propagation vector and + * the y-axis [rad, default = 90.*(PI/180.)] + * \param beta_0 propagation speed of overlap normalized to + * the speed of light [c, default = 1.0] + * \param tdelay_user manual time delay if auto_tdelay is false + * \param auto_tdelay calculate the time delay such that the TWTS pulse is not + * inside the simulation volume at simulation start timestep = 0 [default = true] + * \param pol dtermines the TWTS laser polarization, which is either normal or parallel + * to the laser pulse front tilt plane [ default= LINEAR_X , LINEAR_YZ ] + */ + HINLINE + EField( const float_64 focus_y_SI, + const float_64 wavelength_SI, + const float_64 pulselength_SI, + const float_64 w_x_SI, + const float_64 w_y_SI, + const float_X phi = 90.*(PI / 180.), + const float_X beta_0 = 1.0, + const float_64 tdelay_user_SI = 0.0, + const bool auto_tdelay = true, + const PolarizationType pol = LINEAR_X ); + + /** Specify your background field E(r,t) here + * + * \param cellIdx The total cell id counted from the start at timestep 0. + * \param currentStep The current time step + * \return float3_X with field normalized to amplitude in range [-1.:1.] + */ + HDINLINE float3_X + operator()( const DataSpace& cellIdx, + const uint32_t currentStep ) const; + + /** Calculate the Ex(r,t) field here (electric field vector normal to pulse-front-tilt plane) + * + * \param pos Spatial position of the target field + * \param time Absolute time (SI, including all offsets and transformations) + * for calculating the field + * \return Ex-field component of the non-rotated TWTS field in SI units */ + HDINLINE float_T + calcTWTSEx( const float3_64& pos, const float_64 time ) const; + + /** Calculate the Ey(r,t) field here (electric field vector in pulse-front-tilt plane) + * + * \param pos Spatial position of the target field + * \param time Absolute time (SI, including all offsets and transformations) + * for calculating the field + * \return Ex-field component of the non-rotated TWTS field in SI units */ + HDINLINE float_T + calcTWTSEy( const float3_64& pos, const float_64 time ) const; + + /** Calculate the E-field vector of the TWTS laser in SI units. + * \tparam T_dim Specializes for the simulation dimension + * \param cellIdx The total cell id counted from the start at timestep 0 + * \return Efield vector of the rotated TWTS field in SI units */ + template + HDINLINE float3_X + getTWTSEfield_Normalized( + const PMacc::math::Vector& eFieldPositions_SI, + const float_64 time) const; + + /** Calculate the E-field vector of the "in-plane polarized" TWTS laser in SI units. + * \tparam T_dim Specializes for the simulation dimension + * \param cellIdx The total cell id counted from the start at timestep 0 + * \return Efield vector of the rotated TWTS field in SI units */ + template + HDINLINE float3_X + getTWTSEfield_Normalized_Ey( + const PMacc::math::Vector& eFieldPositions_SI, + const float_64 time) const; + +}; + +} /* namespace twts */ +} /* namespace templates */ +} /* namespace picongpu */ diff --git a/src/picongpu/include/fields/background/templates/TWTS/EField.tpp b/src/picongpu/include/fields/background/templates/TWTS/EField.tpp new file mode 100644 index 0000000000..9ecfd51dcb --- /dev/null +++ b/src/picongpu/include/fields/background/templates/TWTS/EField.tpp @@ -0,0 +1,350 @@ +/** + * Copyright 2014 Alexander Debus, Axel Huebl + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + + +#pragma once + +#include "types.h" +#include "simulation_defines.hpp" +#include "simulation_classTypes.hpp" + +#include "math/Vector.hpp" +#include "dimensions/DataSpace.hpp" +#include "mappings/simulation/SubGrid.hpp" +#include "math/Complex.hpp" + +#include "fields/background/templates/TWTS/RotateField.tpp" +#include "fields/background/templates/TWTS/GetInitialTimeDelay_SI.tpp" +#include "fields/background/templates/TWTS/getFieldPositions_SI.tpp" +#include "fields/background/templates/TWTS/EField.hpp" + +namespace picongpu +{ +/* Load pre-defined background field */ +namespace templates +{ +/* Traveling-wave Thomson scattering laser pulse */ +namespace twts +{ + namespace pmMath = PMacc::algorithms::math; + + HINLINE + EField::EField( const float_64 focus_y_SI, + const float_64 wavelength_SI, + const float_64 pulselength_SI, + const float_64 w_x_SI, + const float_64 w_y_SI, + const float_X phi, + const float_X beta_0, + const float_64 tdelay_user_SI, + const bool auto_tdelay, + const PolarizationType pol ) : + focus_y_SI(focus_y_SI), wavelength_SI(wavelength_SI), + pulselength_SI(pulselength_SI), w_x_SI(w_x_SI), + w_y_SI(w_y_SI), phi(phi), beta_0(beta_0), + tdelay_user_SI(tdelay_user_SI), dt(SI::DELTA_T_SI), + unit_length(UNIT_LENGTH), auto_tdelay(auto_tdelay), pol(pol) + { + /* Note: Enviroment-objects cannot be instantiated on CUDA GPU device. Since this is done + on host (see fieldBackground.param), this is no problem. + */ + const SubGrid& subGrid = Environment::get().SubGrid(); + halfSimSize = subGrid.getGlobalDomain().size / 2; + tdelay = detail::getInitialTimeDelay_SI(auto_tdelay, tdelay_user_SI, + halfSimSize, pulselength_SI, + focus_y_SI, phi, beta_0); + } + + template<> + HDINLINE float3_X + EField::getTWTSEfield_Normalized( + const PMacc::math::Vector& eFieldPositions_SI, + const float_64 time) const + { + float3_64 pos(float3_64::create(0.0)); + for (uint32_t i = 0; i + HDINLINE float3_X + EField::getTWTSEfield_Normalized_Ey( + const PMacc::math::Vector& eFieldPositions_SI, + const float_64 time) const + { + typedef PMacc::math::Vector PosVecVec; + PosVecVec pos(PosVecVec::create( + float3_64::create(0.0) + )); + + for (uint32_t k = 0; k + HDINLINE float3_X + EField::getTWTSEfield_Normalized( + const PMacc::math::Vector& eFieldPositions_SI, + const float_64 time) const + { + /* Ex->Ez, so also the grid cell offset for Ez has to be used. */ + float3_64 pos(float3_64::create(0.0)); + /* 2D (y,z) vectors are mapped on 3D (x,y,z) vectors. */ + for (uint32_t i = 0; i + HDINLINE float3_X + EField::getTWTSEfield_Normalized_Ey( + const PMacc::math::Vector& eFieldPositions_SI, + const float_64 time) const + { + typedef PMacc::math::Vector PosVecVec; + PosVecVec pos(PosVecVec::create( + float3_64::create(0.0) + )); + + /* The 2D output of getFieldPositions_SI only returns + * the y- and z-component of a 3D vector. + */ + for (uint32_t k = 0; kEy, but grid cell offsets for Ex and Ey have to be used. + * + * Calculate Ey-component with the intra-cell offset of a Ey-field + */ + const float_64 Ey_Ey = calcTWTSEy(pos[1], time); + /* Calculate Ey-component with the intra-cell offset of a Ex-field */ + const float_64 Ey_Ex = calcTWTSEy(pos[0], time); + + /* Since we rotated all position vectors before calling calcTWTSEy, + * we need to back-rotate the resulting E-field vector. + * + * RotationMatrix[-(PI / 2+phi)].(Ey,Ex) for rotating back the field-vectors. + */ + const float_64 Ey_rot = -pmMath::sin(+phi)*Ey_Ey; + const float_64 Ex_rot = -pmMath::cos(+phi)*Ey_Ex; + + /* Finally, the E-field normalized to the peak amplitude. */ + return float3_X( float_X(Ex_rot), + float_X(Ey_rot), + float_X(0.0) ); + } + + HDINLINE float3_X + EField::operator()( const DataSpace& cellIdx, + const uint32_t currentStep ) const + { + const float_64 time_SI = float_64(currentStep) * dt - tdelay; + + const PMacc::math::Vector eFieldPositions_SI = + detail::getFieldPositions_SI(cellIdx,halfSimSize, + fieldSolver::NumericalCellType::getEFieldPosition(),unit_length,focus_y_SI,phi); + + /* Single TWTS-Pulse */ + switch (pol) + { + case LINEAR_X : + return getTWTSEfield_Normalized(eFieldPositions_SI, time_SI); + + case LINEAR_YZ : + return getTWTSEfield_Normalized_Ey(eFieldPositions_SI, time_SI); + } + return getTWTSEfield_Normalized(eFieldPositions_SI, time_SI); // defensive default + } + + /** Calculate the Ex(r,t) field here + * + * \param pos Spatial position of the target field. + * \param time Absolute time (SI, including all offsets and transformations) for calculating + * the field */ + HDINLINE EField::float_T + EField::calcTWTSEx( const float3_64& pos, const float_64 time) const + { + typedef PMacc::math::Complex complex_T; + typedef PMacc::math::Complex complex_64; + /* Unit of speed */ + const double UNIT_SPEED = SI::SPEED_OF_LIGHT_SI; + /* Unit of time */ + const double UNIT_TIME = SI::DELTA_T_SI; + /* Unit of length */ + const double UNIT_LENGTH = UNIT_TIME*UNIT_SPEED; + + /* Propagation speed of overlap normalized to the speed of light [Default: beta0=1.0] */ + const float_T beta0 = float_T(beta_0); + const float_T phiReal = float_T(phi); + const float_T alphaTilt = pmMath::atan2(float_T(1.0)-beta0*pmMath::cos(phiReal), + beta0*pmMath::sin(phiReal)); + /* Definition of the laser pulse front tilt angle for the laser field below. + * + * For beta0 = 1.0, this is equivalent to our standard definition. Question: Why is the + * local "phi_T" not equal in value to the object member "phiReal" or "phi"? + * Because the standard TWTS pulse is defined for beta0 = 1.0 and in the coordinate-system + * of the TWTS model phi is responsible for pulse front tilt and dispersion only. Hence + * the dispersion will (although physically correct) be slightly off the ideal TWTS + * pulse for beta0 != 1.0. This only shows that this TWTS pulse is primarily designed for + * scenarios close to beta0 = 1. + */ + const float_T phiT = float_T(2.0)*alphaTilt; + + /* Angle between the laser pulse front and the y-axis. Not used, but remains in code for + * documentation purposes. + * const float_T eta = (PI / 2) - (phiReal - alphaTilt); + */ + + const float_T cspeed = float_T( SI::SPEED_OF_LIGHT_SI / UNIT_SPEED ); + const float_T lambda0 = float_T(wavelength_SI / UNIT_LENGTH); + const float_T om0 = float_T(2.0*PI*cspeed / lambda0); + /* factor 2 in tauG arises from definition convention in laser formula */ + const float_T tauG = float_T(pulselength_SI*2.0 / UNIT_TIME); + /* w0 is wx here --> w0 could be replaced by wx */ + const float_T w0 = float_T(w_x_SI / UNIT_LENGTH); + const float_T rho0 = float_T(PI*w0*w0/lambda0); + /* wy is width of TWTS pulse */ + const float_T wy = float_T(w_y_SI / UNIT_LENGTH); + const float_T k = float_T(2.0*PI / lambda0); + const float_T x = float_T(pos.x() / UNIT_LENGTH); + const float_T y = float_T(pos.y() / UNIT_LENGTH); + const float_T z = float_T(pos.z() / UNIT_LENGTH); + const float_T t = float_T(time / UNIT_TIME); + + /* Calculating shortcuts for speeding up field calculation */ + const float_T sinPhi = pmMath::sin(phiT); + const float_T cosPhi = pmMath::cos(phiT); + const float_T sinPhi2 = pmMath::sin(phiT / float_T(2.0)); + const float_T cosPhi2 = pmMath::cos(phiT / float_T(2.0)); + const float_T tanPhi2 = pmMath::tan(phiT / float_T(2.0)); + + /* The "helpVar" variables decrease the nesting level of the evaluated expressions and + * thus help with formal code verification through manual code inspection. + */ + const complex_T helpVar1 = complex_T(0,1)*rho0 - y*cosPhi - z*sinPhi; + const complex_T helpVar2 = complex_T(0,-1)*cspeed*om0*tauG*tauG + - y*cosPhi / cosPhi2 / cosPhi2*tanPhi2 + - float_T(2.0)*z*tanPhi2*tanPhi2; + const complex_T helpVar3 = complex_T(0,1)*rho0 - y*cosPhi - z*sinPhi; + + const complex_T helpVar4 = ( + -(cspeed*cspeed*k*om0*tauG*tauG*wy*wy*x*x) + - float_T(2.0)*cspeed*cspeed*om0*t*t*wy*wy*rho0 + + complex_T(0,2)*cspeed*cspeed*om0*om0*t*tauG*tauG*wy*wy*rho0 + - float_T(2.0)*cspeed*cspeed*om0*tauG*tauG*y*y*rho0 + + float_T(4.0)*cspeed*om0*t*wy*wy*z*rho0 + - complex_T(0,2)*cspeed*om0*om0*tauG*tauG*wy*wy*z*rho0 + - float_T(2.0)*om0*wy*wy*z*z*rho0 + - complex_T(0,8)*om0*wy*wy*y*(cspeed*t - z)*z*sinPhi2*sinPhi2 + + complex_T(0,8) / sinPhi*( + +float_T(2.0)*z*z*(cspeed*om0*t*wy*wy+complex_T(0,1)*cspeed*y*y-om0*wy*wy*z) + + y*( + + cspeed*k*wy*wy*x*x + - complex_T(0,2)*cspeed*om0*t*wy*wy*rho0 + + float_T(2.0)*cspeed*y*y*rho0 + + complex_T(0,2)*om0*wy*wy*z*rho0 + )*pmMath::tan(float_T(PI / 2.0)-phiT)/sinPhi + )*sinPhi2*sinPhi2*sinPhi2*sinPhi2 + - complex_T(0,2)*cspeed*cspeed*om0*t*t*wy*wy*z*sinPhi + - float_T(2.0)*cspeed*cspeed*om0*om0*t*tauG*tauG*wy*wy*z*sinPhi + - complex_T(0,2)*cspeed*cspeed*om0*tauG*tauG*y*y*z*sinPhi + + complex_T(0,4)*cspeed*om0*t*wy*wy*z*z*sinPhi + + float_T(2.0)*cspeed*om0*om0*tauG*tauG*wy*wy*z*z*sinPhi + - complex_T(0,2)*om0*wy*wy*z*z*z*sinPhi + - float_T(4.0)*cspeed*om0*t*wy*wy*y*rho0*tanPhi2 + + float_T(4.0)*om0*wy*wy*y*z*rho0*tanPhi2 + + complex_T(0,2)*y*y*( + + cspeed*om0*t*wy*wy + complex_T(0,1)*cspeed*y*y - om0*wy*wy*z + )*cosPhi*cosPhi / cosPhi2 / cosPhi2*tanPhi2 + + complex_T(0,2)*cspeed*k*wy*wy*x*x*z*tanPhi2*tanPhi2 + - float_T(2.0)*om0*wy*wy*y*y*rho0*tanPhi2*tanPhi2 + + float_T(4.0)*cspeed*om0*t*wy*wy*z*rho0*tanPhi2*tanPhi2 + + complex_T(0,4)*cspeed*y*y*z*rho0*tanPhi2*tanPhi2 + - float_T(4.0)*om0*wy*wy*z*z*rho0*tanPhi2*tanPhi2 + - complex_T(0,2)*om0*wy*wy*y*y*z*sinPhi*tanPhi2*tanPhi2 + - float_T(2.0)*y*cosPhi*( + + om0*( + + cspeed*cspeed*( + complex_T(0,1)*t*t*wy*wy + + om0*t*tauG*tauG*wy*wy + + complex_T(0,1)*tauG*tauG*y*y + ) + - cspeed*(complex_T(0,2)*t + + om0*tauG*tauG)*wy*wy*z + + complex_T(0,1)*wy*wy*z*z + ) + + complex_T(0,2)*om0*wy*wy*y*(cspeed*t - z)*tanPhi2 + + complex_T(0,1)*tanPhi2*tanPhi2*( + complex_T(0,-4)*cspeed*y*y*z + + om0*wy*wy*(y*y - float_T(4.0)*(cspeed*t - z)*z) + ) + ) + /* The "round-trip" conversion in the line below fixes a gross accuracy bug + * in floating-point arithmetics, when float_T is set to float_X. + */ + ) * complex_T( float_64(1.0) / complex_64(float_T(2.0)*cspeed*wy*wy*helpVar1*helpVar2) ); + + const complex_T helpVar5 = cspeed*om0*tauG*tauG + - complex_T(0,8)*y*pmMath::tan( float_T(PI / 2)-phiT ) + / sinPhi / sinPhi*sinPhi2*sinPhi2*sinPhi2*sinPhi2 + - complex_T(0,2)*z*tanPhi2*tanPhi2; + const complex_T result = (pmMath::exp(helpVar4)*tauG + *pmMath::sqrt((cspeed*om0*rho0) / helpVar3)) / pmMath::sqrt(helpVar5); + return result.get_real(); + } + + /** Calculate the Ey(r,t) field here + * + * \param pos Spatial position of the target field. + * \param time Absolute time (SI, including all offsets and transformations) for calculating + * the field */ + HDINLINE EField::float_T + EField::calcTWTSEy( const float3_64& pos, const float_64 time) const + { + /* The field function of Ey (polarization in pulse-front-tilt plane) + * is by definition identical to Ex (polarization normal to pulse-front-tilt plane) + */ + return calcTWTSEx( pos, time ); + } + +} /* namespace twts */ +} /* namespace templates */ +} /* namespace picongpu */ diff --git a/src/picongpu/include/fields/background/templates/TWTS/GetInitialTimeDelay_SI.tpp b/src/picongpu/include/fields/background/templates/TWTS/GetInitialTimeDelay_SI.tpp new file mode 100644 index 0000000000..5a717b33cd --- /dev/null +++ b/src/picongpu/include/fields/background/templates/TWTS/GetInitialTimeDelay_SI.tpp @@ -0,0 +1,161 @@ +/** + * Copyright 2014-2015 Alexander Debus + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + + +#pragma once + +#include "types.h" +#include "math/Vector.hpp" +#include "dimensions/DataSpace.hpp" + +namespace picongpu +{ +namespace templates +{ +namespace twts +{ +/* Auxiliary functions for calculating the TWTS field */ +namespace detail +{ + namespace pmMath = PMacc::algorithms::math; + + template + class GetInitialTimeDelay + { + public: + /** Obtain the SI time delay that later enters the Ex(r, t), By(r, t) and Bz(r, t) + * calculations as t. + * \tparam T_dim Specializes for the simulation dimension + * \param auto_tdelay calculate the time delay such that the TWTS pulse is not + * inside the simulation volume at simulation start + * timestep = 0 [default = true] + * \param tdelay_user_SI manual time delay if auto_tdelay is false + * \param halfSimSize center of simulation volume in number of cells + * \param pulselength_SI sigma of std. gauss for intensity (E^2) + * \param focus_y_SI the distance to the laser focus in y-direction [m] + * \param phi interaction angle between TWTS laser propagation vector and + * the y-axis [rad, default = 90.*(PI / 180.)] + * \param beta_0 propagation speed of overlap normalized + * to the speed of light [c, default = 1.0] + * \return time delay in SI units */ + HDINLINE float_64 operator()( const bool auto_tdelay, + const float_64 tdelay_user_SI, + const DataSpace& halfSimSize, + const float_64 pulselength_SI, + const float_64 focus_y_SI, + const float_X phi, + const float_X beta_0 ) const; + }; + + template<> + HDINLINE float_64 + GetInitialTimeDelay::operator()( const bool auto_tdelay, + const float_64 tdelay_user_SI, + const DataSpace& halfSimSize, + const float_64 pulselength_SI, + const float_64 focus_y_SI, + const float_X phi, + const float_X beta_0 ) const + { + if ( auto_tdelay ) { + + /* angle between the laser pulse front and the y-axis. Good approximation for + * beta0\simeq 1. For exact relation look in TWTS core routines for Ex, By or Bz. */ + const float_64 eta = (PI / 2) - (phi / 2); + /* halfSimSize[2] --> Half-depth of simulation volume (in z); By geometric + * projection we calculate the y-distance walkoff of the TWTS-pulse. + * The abs()-function is for correct offset for -phi<-90Deg and +phi>+90Deg. */ + const float_64 y1 = float_64(halfSimSize[2] + *picongpu::SI::CELL_DEPTH_SI)*pmMath::abs(pmMath::cos(eta)); + /* Fudge parameter to make sure, that TWTS pulse starts to impact simulation volume + * at low intensity values. */ + const float_64 m = 3.; + /* Approximate cross section of laser pulse through y-axis, + * scaled with "fudge factor" m. */ + const float_64 y2 = m*(pulselength_SI*picongpu::SI::SPEED_OF_LIGHT_SI) + / pmMath::cos(eta); + /* y-position of laser coordinate system origin within simulation. */ + const float_64 y3 = focus_y_SI; + /* Programmatically obtained time-delay */ + const float_64 tdelay = (y1+y2+y3) / (picongpu::SI::SPEED_OF_LIGHT_SI*beta_0); + + return tdelay; + } + else + return tdelay_user_SI; + } + + template <> + HDINLINE float_64 + GetInitialTimeDelay::operator()( const bool auto_tdelay, + const float_64 tdelay_user_SI, + const DataSpace& halfSimSize, + const float_64 pulselength_SI, + const float_64 focus_y_SI, + const float_X phi, + const float_X beta_0 ) const + { + if ( auto_tdelay ) { + + /* angle between the laser pulse front and the y-axis. Good approximation for + * beta0\simeq 1. For exact relation look in TWTS core routines for Ex, By or Bz. */ + const float_64 eta = (PI / 2) - (phi / 2); + /* halfSimSize[0] --> Half-depth of simulation volume (in x); By geometric + * projection we calculate the y-distance walkoff of the TWTS-pulse. + * The abs()-function is for correct offset for -phi<-90Deg and +phi>+90Deg. */ + const float_64 y1 = float_64(halfSimSize[0] + *picongpu::SI::CELL_WIDTH_SI)*pmMath::abs(pmMath::cos(eta)); + /* Fudge parameter to make sure, that TWTS pulse starts to impact simulation volume + * at low intensity values. */ + const float_64 m = 3.; + /* Approximate cross section of laser pulse through y-axis, + * scaled with "fudge factor" m. */ + const float_64 y2 = m*(pulselength_SI*picongpu::SI::SPEED_OF_LIGHT_SI) + / pmMath::cos(eta); + /* y-position of laser coordinate system origin within simulation. */ + const float_64 y3 = focus_y_SI; + /* Programmatically obtained time-delay */ + const float_64 tdelay = (y1+y2+y3) / (picongpu::SI::SPEED_OF_LIGHT_SI*beta_0); + + return tdelay; + } + else + return tdelay_user_SI; + } + + template + HDINLINE float_64 + getInitialTimeDelay_SI( const bool auto_tdelay, + const float_64 tdelay_user_SI, + const DataSpace& halfSimSize, + const float_64 pulselength_SI, + const float_64 focus_y_SI, + const float_X phi, + const float_X beta_0 ) + { + return GetInitialTimeDelay()(auto_tdelay, tdelay_user_SI, + halfSimSize, pulselength_SI, + focus_y_SI, phi, beta_0); + } + +} /* namespace detail */ +} /* namespace twts */ +} /* namespace templates */ +} /* namespace picongpu */ diff --git a/src/picongpu/include/fields/background/templates/TWTS/RotateField.tpp b/src/picongpu/include/fields/background/templates/TWTS/RotateField.tpp new file mode 100644 index 0000000000..6ccc870cc3 --- /dev/null +++ b/src/picongpu/include/fields/background/templates/TWTS/RotateField.tpp @@ -0,0 +1,123 @@ +/** + * Copyright 2014-2015 Alexander Debus, Rene Widera + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + + +#pragma once + +#include "types.h" +#include "math/Vector.hpp" +#include "dimensions/DataSpace.hpp" + +namespace picongpu +{ +namespace templates +{ +namespace twts +{ +/** Auxiliary functions for calculating the TWTS field */ +namespace detail +{ + namespace pmMath = PMacc::algorithms::math; + + template + struct RotateField; + + template + struct RotateField, T_AngleType > + { + typedef PMacc::math::Vector result; + typedef T_AngleType AngleType; + HDINLINE result + operator()( const result& fieldPosVector, + const AngleType phi ) const + { + /* Since, the laser propagation direction encloses an angle of phi with the + * simulation y-axis (i.e. direction of sliding window), the positions vectors are + * rotated around the simulation x-axis before calling the TWTS field functions. + * Note: The TWTS field functions are in non-rotated frame and only use the angle + * phi to determine the required amount of pulse front tilt. + * RotationMatrix[PI/2+phi].(y,z) (180Deg-flip at phi=90Deg since coordinate + * system in paper is oriented the other way round.) */ + return result( + fieldPosVector.x(), + -pmMath::sin(AngleType(phi))*fieldPosVector.y() + -pmMath::cos(AngleType(phi))*fieldPosVector.z() , + +pmMath::cos(AngleType(phi))*fieldPosVector.y() + -pmMath::sin(AngleType(phi))*fieldPosVector.z() ); + } + + }; + + template + struct RotateField, T_AngleType > + { + typedef PMacc::math::Vector result; + typedef T_AngleType AngleType; + HDINLINE result + operator()( const result& fieldPosVector, + const AngleType phi ) const + { + /* Since, the laser propagation direction encloses an angle of phi with the + * simulation y-axis (i.e. direction of sliding window), the positions vectors are + * rotated around the simulation x-axis before calling the TWTS field functions. + * Note: The TWTS field functions are in non-rotated frame and only use the angle + * phi to determine the required amount of pulse front tilt. + * RotationMatrix[PI/2+phi].(y,z) (180Deg-flip at phi=90Deg since coordinate + * system in paper is oriented the other way round.) */ + + /* Rotate 90 degree around y-axis, so that TWTS laser propagates within + * the 2D (x,y)-plane. Corresponding position vector for the Ez-components + * in 2D simulations. + * 3D 3D vectors in 2D space (x,y) + * x --> z + * y --> y + * z --> -x (Since z=0 for 2D, we use the existing + * TWTS-field-function and set -x=0) + * + * Explicit implementation in 3D coordinates: + * fieldPosVector = float3_64( -fieldPosVector.z(), //(Here: ==0) + * fieldPosVector.y(), + * fieldPosVector.x() ); + * fieldPosVector = float3_64( fieldPosVector.x(), + * -sin(phi)*fieldPosVector.y()-cos(phi)*fieldPosVector.z(), + * +cos(phi)*fieldPosVector.y()-sin(phi)*fieldPosVector.z() ); + * The 2D implementation here only calculates the last two components. + * Note: The x-axis of rotation is fine in 2D, because that component now contains + * the (non-existing) simulation z-coordinate. */ + return result( + -pmMath::sin(AngleType(phi))*fieldPosVector.y() + -pmMath::cos(AngleType(phi))*fieldPosVector.x() , + +pmMath::cos(AngleType(phi))*fieldPosVector.y() + -pmMath::sin(AngleType(phi))*fieldPosVector.x() ); + } + }; + + template + HDINLINE typename RotateField::result + rotateField( const T_Type& fieldPosVector, + const T_AngleType phi ) + { + return RotateField()(fieldPosVector,phi); + } + +} /* namespace detail */ +} /* namespace twts */ +} /* namespace templates */ +} /* namespace picongpu */ diff --git a/src/picongpu/include/fields/background/templates/TWTS/TWTS.hpp b/src/picongpu/include/fields/background/templates/TWTS/TWTS.hpp new file mode 100644 index 0000000000..eeeff12a90 --- /dev/null +++ b/src/picongpu/include/fields/background/templates/TWTS/TWTS.hpp @@ -0,0 +1,25 @@ +/** + * Copyright 2014-2015 Alexander Debus + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + + +#pragma once + +#include "fields/background/templates/TWTS/EField.hpp" +#include "fields/background/templates/TWTS/BField.hpp" diff --git a/src/picongpu/include/fields/background/templates/TWTS/TWTS.tpp b/src/picongpu/include/fields/background/templates/TWTS/TWTS.tpp new file mode 100644 index 0000000000..73e16fb404 --- /dev/null +++ b/src/picongpu/include/fields/background/templates/TWTS/TWTS.tpp @@ -0,0 +1,25 @@ +/** + * Copyright 2014-2015 Alexander Debus + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + + +#pragma once + +#include "fields/background/templates/TWTS/EField.tpp" +#include "fields/background/templates/TWTS/BField.tpp" diff --git a/src/picongpu/include/fields/background/templates/TWTS/getFieldPositions_SI.tpp b/src/picongpu/include/fields/background/templates/TWTS/getFieldPositions_SI.tpp new file mode 100644 index 0000000000..8303e08e8f --- /dev/null +++ b/src/picongpu/include/fields/background/templates/TWTS/getFieldPositions_SI.tpp @@ -0,0 +1,82 @@ +/** + * Copyright 2014-2015 Alexander Debus + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + + +#pragma once + +#include "types.h" +#include "math/Vector.hpp" +#include "dimensions/DataSpace.hpp" +#include "fields/background/templates/TWTS/numComponents.hpp" + +namespace picongpu +{ +namespace templates +{ +namespace twts +{ +/** Auxiliary functions for calculating the TWTS field */ +namespace detail +{ + /** Calculate the SI position vectors that later enter the Ex(r, t), By(r, t) + * and Bz(r ,t) calculations as r. + * \param cellIdx The total cell id counted from the start at timestep 0. */ + HDINLINE PMacc::math::Vector + getFieldPositions_SI(const DataSpace& cellIdx, + const DataSpace& halfSimSize, + const PMacc::math::Vector& fieldOnGridPositions, + const float_64 unit_length, + const float_64 focus_y_SI, + const float_X phi ) + { + /* Note: Neither direct precisionCast on picongpu::cellSize + or casting on floatD_ does work. */ + const floatD_64 cellDim(picongpu::cellSize); + const floatD_64 cellDimensions = cellDim * unit_length; + + /* TWTS laser coordinate origin is centered transversally and defined longitudinally by + the laser center in y (usually maximum of intensity). */ + floatD_X laserOrigin = precisionCast(halfSimSize); + laserOrigin.y() = float_X( focus_y_SI/cellDimensions.y() ); + + /* For staggered fields (e.g. Yee-grid), obtain the fractional cell index components and add + * that to the total cell indices. The physical field coordinate origin is transversally + * centered with respect to the global simulation volume. + * PMacc::math::Vector fieldPositions = + * fieldSolver::NumericalCellType::getEFieldPosition(); */ + PMacc::math::Vector fieldPositions = fieldOnGridPositions; + + PMacc::math::Vector fieldPositions_SI; + + for( uint32_t i = 0; i < numComponents; ++i ) /* cellIdx Ex, Ey and Ez */ + { + fieldPositions[i] += ( precisionCast(cellIdx) - laserOrigin ); + fieldPositions_SI[i] = precisionCast(fieldPositions[i]) * cellDimensions; + + fieldPositions_SI[i] = rotateField(fieldPositions_SI[i],phi); + } + + return fieldPositions_SI; + } + +} /* namespace detail */ +} /* namespace twts */ +} /* namespace templates */ +} /* namespace picongpu */ diff --git a/src/picongpu/include/fields/background/templates/TWTS/numComponents.hpp b/src/picongpu/include/fields/background/templates/TWTS/numComponents.hpp new file mode 100644 index 0000000000..b359a3bd8d --- /dev/null +++ b/src/picongpu/include/fields/background/templates/TWTS/numComponents.hpp @@ -0,0 +1,37 @@ +/** + * Copyright 2014-2015 Alexander Debus, Axel Huebl + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + + +#pragma once + +namespace picongpu +{ +namespace templates +{ +namespace twts +{ +namespace detail +{ + /* Number of field components used in the simulation. [Default: 3 for both 2D and 3D] */ + const uint32_t numComponents = 3; +} /* namespace detail */ +} /* namespace twts */ +} /* namespace templates */ +} /* namespace picongpu */ diff --git a/src/picongpu/include/fields/currentDeposition/Esirkepov/Esirkepov.hpp b/src/picongpu/include/fields/currentDeposition/Esirkepov/Esirkepov.hpp index 63fa2e980e..26bb4957e7 100644 --- a/src/picongpu/include/fields/currentDeposition/Esirkepov/Esirkepov.hpp +++ b/src/picongpu/include/fields/currentDeposition/Esirkepov/Esirkepov.hpp @@ -162,6 +162,8 @@ struct Esirkepov for (int k = begin + offset_k; k < end + offset_k; ++k) { float_X W = DS(line, k, 2) * tmp; + /* We multiply with `cellEdgeLength` due to the fact that the attribute for the + * in-cell particle `position` (and it's change in DELTA_T) is normalize to [0,1) */ accumulated_J += -this->charge * (float_X(1.0) / float_X(CELL_VOLUME * DELTA_T)) * W * cellEdgeLength; /* the branch divergence here still over-compensates for the fewer collisions in the (expensive) atomic adds */ if (accumulated_J != float_X(0.0)) diff --git a/src/picongpu/include/fields/currentDeposition/Esirkepov/Esirkepov2D.hpp b/src/picongpu/include/fields/currentDeposition/Esirkepov/Esirkepov2D.hpp index 314618b666..1070dce7f8 100644 --- a/src/picongpu/include/fields/currentDeposition/Esirkepov/Esirkepov2D.hpp +++ b/src/picongpu/include/fields/currentDeposition/Esirkepov/Esirkepov2D.hpp @@ -158,6 +158,8 @@ struct Esirkepov for (int i = begin + offset_i; i < end + offset_i; ++i) { float_X W = DS(line, i, 0) * tmp; + /* We multiply with `cellEdgeLength` due to the fact that the attribute for the + * in-cell particle `position` (and it's change in DELTA_T) is normalize to [0,1) */ accumulated_J += -this->charge * (float_X(1.0) / float_X(CELL_VOLUME * DELTA_T)) * W * cellEdgeLength; /* the branch divergence here still over-compensates for the fewer collisions in the (expensive) atomic adds */ if (accumulated_J != float_X(0.0)) diff --git a/src/picongpu/include/fields/currentDeposition/Esirkepov/EsirkepovNative.hpp b/src/picongpu/include/fields/currentDeposition/Esirkepov/EsirkepovNative.hpp index 7d042bbbb8..a2feb0f2a0 100644 --- a/src/picongpu/include/fields/currentDeposition/Esirkepov/EsirkepovNative.hpp +++ b/src/picongpu/include/fields/currentDeposition/Esirkepov/EsirkepovNative.hpp @@ -122,6 +122,8 @@ struct EsirkepovNative for (int k = begin; k < end; ++k) { float_X W = DS(line, k, 3) * tmp; + /* We multiply with `cellEdgeLength` due to the fact that the attribute for the + * in-cell particle `position` (and it's change in DELTA_T) is normalize to [0,1) */ accumulated_J += -this->charge * (float_X(1.0) / float_X(CELL_VOLUME * DELTA_T)) * W * cellEdgeLength; atomicAddWrapper(&((*cursorJ(i, j, k)).z()), accumulated_J); } diff --git a/src/picongpu/include/fields/currentDeposition/ZigZag/EvalAssignmentFunction.hpp b/src/picongpu/include/fields/currentDeposition/ZigZag/EvalAssignmentFunction.hpp index a064b38624..e88349f61a 100644 --- a/src/picongpu/include/fields/currentDeposition/ZigZag/EvalAssignmentFunction.hpp +++ b/src/picongpu/include/fields/currentDeposition/ZigZag/EvalAssignmentFunction.hpp @@ -1,5 +1,5 @@ /** - * Copyright 2013 Axel Huebl, Heiko Burau, Rene Widera + * Copyright 2013-2015 Axel Huebl, Heiko Burau, Rene Widera * * This file is part of PIConGPU. * @@ -69,6 +69,66 @@ struct EvalAssignmentFunction * - Even Support: parPos [0.0;1.0) * - Odd Support: parPos [-0.5;0.5) */ +template<> +struct EvalAssignmentFunction > +{ + typedef typename picongpu::particles::shapes::P4S ParticleAssign; + + HDINLINE float_X + operator()(const float_X parPos) + { + + return ParticleAssign::ff_1st_radius(parPos); + } +}; + +template<> +struct EvalAssignmentFunction > +{ + typedef typename picongpu::particles::shapes::P4S ParticleAssign; + + HDINLINE float_X + operator()(const float_X parPos) + { + return ParticleAssign::ff_2nd_radius(float_X(1.0)-parPos); + } +}; + +template<> +struct EvalAssignmentFunction > +{ + typedef typename picongpu::particles::shapes::P4S ParticleAssign; + + HDINLINE float_X + operator()(const float_X parPos) + { + return ParticleAssign::ff_2nd_radius(algorithms::math::abs(float_X(-1.0)-parPos)); + } +}; + +template<> +struct EvalAssignmentFunction > +{ + typedef typename picongpu::particles::shapes::P4S ParticleAssign; + + HDINLINE float_X + operator()(const float_X parPos) + { + return ParticleAssign::ff_3rd_radius(float_X(2.0)-parPos); + } +}; + +template<> +struct EvalAssignmentFunction > +{ + typedef typename picongpu::particles::shapes::P4S ParticleAssign; + + HDINLINE float_X + operator()(const float_X parPos) + { + return ParticleAssign::ff_3rd_radius(algorithms::math::abs(float_X(-2.0)-parPos)); + } +}; template<> struct EvalAssignmentFunction > diff --git a/src/picongpu/include/fields/currentDeposition/ZigZag/ZigZag.hpp b/src/picongpu/include/fields/currentDeposition/ZigZag/ZigZag.hpp index c87fd1de7d..abca216b0c 100644 --- a/src/picongpu/include/fields/currentDeposition/ZigZag/ZigZag.hpp +++ b/src/picongpu/include/fields/currentDeposition/ZigZag/ZigZag.hpp @@ -279,13 +279,15 @@ struct ZigZag const float_X pos_tmp = pos[parId][d]; const float_X tmpRelayPoint = relayPoint[d]; inCellPos[d] = calc_InCellPos(pos_tmp, tmpRelayPoint, I[parId][d]); + /* We multiply with `cellSize[d]` due to the fact that the attribute for the + * in-cell particle `position` (and it's change in DELTA_T) is normalize to [0,1) */ flux[d] = sign * calc_chargeFlux(pos_tmp, tmpRelayPoint, deltaTime, charge) * volume_reci * cellSize[d]; } - + /* this loop is only needed for 2D, we need a flux in z direction */ for (uint32_t d = simDim; d < 3; ++d) { - flux[d] = charge * velocity[d] * volume_reci; + flux[d] = float_X(0.5) * charge * velocity[d] * volume_reci; } PMACC_AUTO(cursorJ, dataBoxJ.shift(precisionCast(I[parId])).toCursor()); diff --git a/src/picongpu/include/plugins/TotalDivJ.hpp b/src/picongpu/include/fields/currentInterpolation/Binomial/Binomial.def similarity index 51% rename from src/picongpu/include/plugins/TotalDivJ.hpp rename to src/picongpu/include/fields/currentInterpolation/Binomial/Binomial.def index 7c2bacf541..66176344f4 100644 --- a/src/picongpu/include/plugins/TotalDivJ.hpp +++ b/src/picongpu/include/fields/currentInterpolation/Binomial/Binomial.def @@ -1,5 +1,5 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2015 Axel Huebl * * This file is part of PIConGPU. * @@ -18,37 +18,37 @@ * If not, see . */ -#ifndef ANALYSIS_TOTALDIVJ_HPP -#define ANALYSIS_TOTALDIVJ_HPP - -#include "plugins/ILightweightPlugin.hpp" +#pragma once namespace picongpu { -using namespace PMacc; +namespace currentInterpolation +{ + +/* 2nd order Binomial filter */ +template +struct Binomial; -namespace po = boost::program_options; +} /* namespace currentInterpolation */ -class TotalDivJ : public ILightweightPlugin +namespace traits +{ + +/* Get margin of the current interpolation + * + * This class defines a LowerMargin and an UpperMargin. + */ +template +struct GetMargin > { private: - std::string name; - std::string prefix; - uint32_t notifyFrequency; + typedef picongpu::currentInterpolation::Binomial MyInterpolation; - void pluginLoad(); public: - TotalDivJ(std::string name, std::string prefix); - virtual ~TotalDivJ() {} - - void notify(uint32_t currentStep); - void setMappingDescription(MappingDesc*) {} - void pluginRegisterHelp(po::options_description& desc); - std::string pluginGetName() const; + typedef typename MyInterpolation::LowerMargin LowerMargin; + typedef typename MyInterpolation::UpperMargin UpperMargin; }; -} - -#include "TotalDivJ.tpp" +} /* namespace traits */ -#endif // ANALYSIS_TOTALDIVJ_HPP +} /* namespace picongpu */ diff --git a/src/picongpu/include/fields/currentInterpolation/Binomial/Binomial.hpp b/src/picongpu/include/fields/currentInterpolation/Binomial/Binomial.hpp new file mode 100644 index 0000000000..e59f169e5e --- /dev/null +++ b/src/picongpu/include/fields/currentInterpolation/Binomial/Binomial.hpp @@ -0,0 +1,79 @@ +/** + * Copyright 2015 Axel Huebl + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + +#pragma once + +#include "simulation_defines.hpp" +#include "types.h" +#include "basicOperations.hpp" + +#include "fields/currentInterpolation/None/None.def" + +namespace picongpu +{ +namespace currentInterpolation +{ +using namespace PMacc; + +template +struct Binomial +{ + static const uint32_t dim = T_dim; + + typedef typename PMacc::math::CT::make_Int::type LowerMargin; + typedef typename PMacc::math::CT::make_Int::type UpperMargin; + + template + HDINLINE void operator()(DataBoxE fieldE, + DataBoxB, + DataBoxJ fieldJ ) + { + const DataSpace self; + typedef typename DataBoxJ::ValueType TypeJ; + + /* 1 2 1 weighting for "left"(1x) "center"(2x) "right"(1x), + * see Pascal's triangle level N=2 */ + TypeJ dirSum( TypeJ::create(0.0) ); + for( uint32_t d = 0; d < dim; ++d ) + { + DataSpace dw; + dw[d] = -1; + DataSpace up; + up[d] = 1; + const TypeJ dirDw = fieldJ(dw) + fieldJ(self); + const TypeJ dirUp = fieldJ(up) + fieldJ(self); + + /* each fieldJ component is added individually */ + dirSum += dirDw + dirUp; + } + + /* component-wise division by sum of all weightings, + * in the second order binomial filter these are 4 values per direction + * (1D: 4 values; 2D: 8 values; 3D: 12 values) */ + const TypeJ filteredJ = dirSum / TypeJ::create(4.0 * dim); + + const float_X deltaT = DELTA_T; + fieldE(self) -= filteredJ * (float_X(1.0) / EPS0) * deltaT; + } +}; + +} /* namespace currentInterpolation */ + +} /* namespace picongpu */ diff --git a/src/picongpu/include/fields/currentInterpolation/CurrentInterpolation.def b/src/picongpu/include/fields/currentInterpolation/CurrentInterpolation.def new file mode 100644 index 0000000000..20ba9d56c1 --- /dev/null +++ b/src/picongpu/include/fields/currentInterpolation/CurrentInterpolation.def @@ -0,0 +1,23 @@ +/** + * Copyright 2015 Axel Huebl + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + + +#include "fields/currentInterpolation/None/None.def" +#include "fields/currentInterpolation/Binomial/Binomial.def" diff --git a/src/picongpu/include/fields/currentInterpolation/CurrentInterpolation.hpp b/src/picongpu/include/fields/currentInterpolation/CurrentInterpolation.hpp new file mode 100644 index 0000000000..08e8e7e90b --- /dev/null +++ b/src/picongpu/include/fields/currentInterpolation/CurrentInterpolation.hpp @@ -0,0 +1,23 @@ +/** + * Copyright 2015 Axel Huebl + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + + +#include "fields/currentInterpolation/None/None.hpp" +#include "fields/currentInterpolation/Binomial/Binomial.hpp" diff --git a/src/picongpu/include/plugins/FieldEnergy.hpp b/src/picongpu/include/fields/currentInterpolation/None/None.def similarity index 51% rename from src/picongpu/include/plugins/FieldEnergy.hpp rename to src/picongpu/include/fields/currentInterpolation/None/None.def index 637d0464c3..5561baea0a 100644 --- a/src/picongpu/include/plugins/FieldEnergy.hpp +++ b/src/picongpu/include/fields/currentInterpolation/None/None.def @@ -1,5 +1,5 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2015 Axel Huebl * * This file is part of PIConGPU. * @@ -18,37 +18,36 @@ * If not, see . */ -#ifndef ANALYSIS_FIELDENERGY_HPP -#define ANALYSIS_FIELDENERGY_HPP - -#include "plugins/ILightweightPlugin.hpp" +#pragma once namespace picongpu { -using namespace PMacc; +namespace currentInterpolation +{ + +template +struct None; -namespace po = boost::program_options; +} /* namespace currentInterpolation */ -class FieldEnergy : public ILightweightPlugin +namespace traits +{ + +/* Get margin of the current interpolation + * + * This class defines a LowerMargin and an UpperMargin. + */ +template +struct GetMargin > { private: - std::string name; - std::string prefix; - uint32_t notifyFrequency; + typedef picongpu::currentInterpolation::None MyInterpolation; - void pluginLoad(); public: - FieldEnergy(std::string name, std::string prefix); - virtual ~FieldEnergy() {} - - void notify(uint32_t currentStep); - void setMappingDescription(MappingDesc*) {} - void pluginRegisterHelp(po::options_description& desc); - std::string pluginGetName() const; + typedef typename MyInterpolation::LowerMargin LowerMargin; + typedef typename MyInterpolation::UpperMargin UpperMargin; }; -} - -#include "FieldEnergy.tpp" +} /* namespace traits */ -#endif // ANALYSIS_FIELDENERGY_HPP +} /* namespace picongpu */ diff --git a/src/picongpu/include/fields/currentInterpolation/None/None.hpp b/src/picongpu/include/fields/currentInterpolation/None/None.hpp new file mode 100644 index 0000000000..bbc93be93f --- /dev/null +++ b/src/picongpu/include/fields/currentInterpolation/None/None.hpp @@ -0,0 +1,58 @@ +/** + * Copyright 2015 Axel Huebl + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + +#pragma once + +#include "simulation_defines.hpp" +#include "types.h" +#include "basicOperations.hpp" + +#include "fields/currentInterpolation/None/None.def" + +namespace picongpu +{ +namespace currentInterpolation +{ +using namespace PMacc; + +template +struct None +{ + static const uint32_t dim = T_dim; + + typedef typename PMacc::math::CT::make_Int::type LowerMargin; + typedef typename PMacc::math::CT::make_Int::type UpperMargin; + + template + HDINLINE void operator()(DataBoxE fieldE, + DataBoxB, + DataBoxJ fieldJ ) + { + const DataSpace self; + + const float_X deltaT = DELTA_T; + fieldE(self) -= fieldJ(self) * (float_X(1.0) / EPS0) * deltaT; + } + +}; + +} /* namespace currentInterpolation */ + +} /* namespace picongpu */ diff --git a/src/picongpu/include/fields/laserProfiles/laserGaussianBeam.hpp b/src/picongpu/include/fields/laserProfiles/laserGaussianBeam.hpp index cfc5b51496..fff0c8a723 100644 --- a/src/picongpu/include/fields/laserProfiles/laserGaussianBeam.hpp +++ b/src/picongpu/include/fields/laserProfiles/laserGaussianBeam.hpp @@ -1,5 +1,5 @@ /** - * Copyright 2013 Axel Huebl, Heiko Burau, Anton Helm, Rene Widera, Richard Pausch + * Copyright 2013, 2015 Axel Huebl, Heiko Burau, Anton Helm, Rene Widera, Richard Pausch * * This file is part of PIConGPU. * @@ -43,7 +43,7 @@ namespace picongpu const double runTime = DELTA_T*currentStep; const double f = SPEED_OF_LIGHT / WAVE_LENGTH; - float3_X elong = float3_X(float_X(0.0), float_X(0.0), float_X(0.0)); + float3_X elong(float3_X::create(0.0)); // a symmetric pulse will be initialized at position z=0 for // a time of PULSE_INIT * PULSE_LENGTH = INIT_TIME. @@ -74,7 +74,7 @@ namespace picongpu elong.z() = float_X( envelope / sqrt(2.0) ); } - phase = 2.0f * float_X(PI ) * float_X(f ) * ( runTime - float_X(mue ) - FOCUS_POS / SPEED_OF_LIGHT ); + phase = 2.0f * float_X(PI ) * float_X(f ) * ( runTime - float_X(mue ) - FOCUS_POS / SPEED_OF_LIGHT) + LASER_PHASE; return elong; } diff --git a/src/picongpu/include/fields/laserProfiles/laserNone.hpp b/src/picongpu/include/fields/laserProfiles/laserNone.hpp index ecf7a84c7a..09ec8cb8e7 100644 --- a/src/picongpu/include/fields/laserProfiles/laserNone.hpp +++ b/src/picongpu/include/fields/laserProfiles/laserNone.hpp @@ -39,7 +39,7 @@ namespace picongpu */ HINLINE float3_X laserLongitudinal( uint32_t, float_X& phase ) { - float3_X elong = float3_X(float_X(0.0), float_X(0.0), float_X(0.0)); + const float3_X elong(float3_X::create(0.0)); phase = float_X(0.0); diff --git a/src/picongpu/include/fields/laserProfiles/laserPlaneWave.hpp b/src/picongpu/include/fields/laserProfiles/laserPlaneWave.hpp index 7b93da3017..75bdafba4f 100644 --- a/src/picongpu/include/fields/laserProfiles/laserPlaneWave.hpp +++ b/src/picongpu/include/fields/laserProfiles/laserPlaneWave.hpp @@ -1,5 +1,5 @@ /** - * Copyright 2013-2014 Axel Huebl, Heiko Burau, Rene Widera, Richard Pausch + * Copyright 2013-2015 Axel Huebl, Heiko Burau, Rene Widera, Richard Pausch * * This file is part of PIConGPU. * @@ -19,9 +19,7 @@ */ - -#ifndef LASERPLANEWAVE_HPP -#define LASERPLANEWAVE_HPP +#pragma once #include "types.h" #include "simulation_defines.hpp" @@ -30,13 +28,38 @@ namespace picongpu { /** plane wave (use periodic boundaries!) * - * no phase shifts, no spacial envelope + * no transverse spacial envelope + * based on the electric potential + * Phi = Phi_0 * exp(0.5 * (x-x_0)^2 / sigma^2) * cos(k*(x - x_0) - phi) + * by applying -grad Phi = -d/dx Phi = E(x) + * we get: + * E = -Phi_0 * exp(0.5 * (x-x_0)^2 / sigma^2) * [k*sin(k*(x - x_0) - phi) + x/sigma^2 * cos(k*(x - x_0) - phi)] + * + * This approach ensures that int_{-infinity}^{+infinity} E(x) = 0 for any phase + * if we have no transverse profile as we have with this plane wave train + * + * Since PIConGPU requires a temporally defined electric field, we use: + * t = x/c and (x-x_0)/sigma = (t-t_0)/tau and k*(x-x_0) = omega*(t-t_0) with omega/k = c and tau * c = sigma + * and get: + * E = -Phi_0*omega/c * exp(0.5 * (t-t_0)^2 / tau^2) * [sin(omega*(t - t_0) - phi) + t/(omega*tau^2) * cos(omega*(t - t_0) - phi)] + * and define: + * E_0 = -Phi_0*omega/c + * integrationCorrectionFactor = t/(omega*tau^2) + * + * Please consider: + * 1) The above formulae does only apply to a Gaussian envelope. If the plateau length is + * not zero, the integral over the volume will only vanish if the plateau length is + * a multiple of the wavelength. + * 2) Since we define our envelope by a sigma of the laser intensity, + * tau = PULSE_LENGTH * sqrt(2) */ namespace laserPlaneWave { - - /** Compute the + /** calculates longitudinal field distribution * + * @param currentStep + * @param phase + * @return */ HINLINE float3_X laserLongitudinal( uint32_t currentStep, float_X& phase ) { @@ -44,49 +67,52 @@ namespace picongpu const double f = SPEED_OF_LIGHT / WAVE_LENGTH; double envelope = double(AMPLITUDE ); - float3_X elong = float3_X(float_X(0.0), float_X(0.0), float_X(0.0)); + float3_X elong(float3_X::create(0.0)); - // a NON-symmetric (starting with phase=0) pulse will be initialized at position z=0 for - // a time of RAMP_INIT * PULSE_LENGTH + LASER_NOFOCUS_CONSTANT = INIT_TIME. - // we shift the complete pulse for the half of this time to start with - // the front of the laser pulse. const double mue = 0.5 * RAMP_INIT * PULSE_LENGTH; const double w = 2.0 * PI * f; + const double tau = PULSE_LENGTH * sqrt( 2.0 ); const double endUpramp = mue; const double startDownramp = mue + LASER_NOFOCUS_CONSTANT; + double integrationCorrectionFactor = 0.0; - if( runTime > startDownramp ) { // downramp = end - const double exponent = - ( ( runTime - startDownramp ) - / PULSE_LENGTH / sqrt( 2.0 ) ); + const double exponent = (runTime - startDownramp) / tau; envelope *= exp( -0.5 * exponent * exponent ); + integrationCorrectionFactor = ( runTime - startDownramp )/ (w*tau*tau); } else if ( runTime < endUpramp ) { // upramp = start - const double exponent = ( ( runTime - endUpramp ) / PULSE_LENGTH / sqrt( 2.0 ) ); + const double exponent = (runTime - endUpramp) / tau; envelope *= exp( -0.5 * exponent * exponent ); - + integrationCorrectionFactor = ( runTime - endUpramp )/ (w*tau*tau); } + const double timeOszi = runTime - endUpramp; + const double t_and_phase = w * timeOszi + LASER_PHASE; + // to understand both components [sin(...) + t/tau^2 * cos(...)] see description above if( Polarisation == LINEAR_X ) { - elong.x() = float_X( envelope * math::sin( w * runTime )); + elong.x() = float_X( envelope * (math::sin(t_and_phase) + + math::cos(t_and_phase) * integrationCorrectionFactor)); } else if( Polarisation == LINEAR_Z) { - elong.z() = float_X( envelope * math::sin( w * runTime )); + elong.z() = float_X( envelope * (math::sin(t_and_phase) + + math::cos(t_and_phase) * integrationCorrectionFactor)); } else if( Polarisation == CIRCULAR ) { - elong.x() = float_X( envelope / sqrt(2.0) * math::sin( w * runTime )); - elong.z() = float_X( envelope / sqrt(2.0) * math::cos( w * runTime )); + elong.x() = float_X( envelope / sqrt(2.0) * (math::sin(t_and_phase) + + math::cos(t_and_phase) * integrationCorrectionFactor)); + elong.z() = float_X( envelope / sqrt(2.0) * (math::cos(t_and_phase) + - math::sin(t_and_phase) * integrationCorrectionFactor)); } @@ -95,7 +121,7 @@ namespace picongpu return elong; } - /** + /** calculates transverse field distribution * * @param elong * @param phase @@ -111,7 +137,3 @@ namespace picongpu } } -#endif /* LASERPLANEWAVE_HPP */ - - - diff --git a/src/picongpu/include/fields/laserProfiles/laserPolynom.hpp b/src/picongpu/include/fields/laserProfiles/laserPolynom.hpp index 80bfed7180..c7013c92e8 100644 --- a/src/picongpu/include/fields/laserProfiles/laserPolynom.hpp +++ b/src/picongpu/include/fields/laserProfiles/laserPolynom.hpp @@ -1,5 +1,5 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera, Richard Pausch + * Copyright 2013, 2015 Heiko Burau, Rene Widera, Richard Pausch * * This file is part of PIConGPU. * @@ -34,33 +34,30 @@ namespace picongpu namespace laserPolynom { -HDINLINE float_64 Tpolynomial(const float_64 tau); +HDINLINE float_X Tpolynomial(const float_X tau); /** Compute the longitudinal enevelope of the laser * */ HINLINE float3_X laserLongitudinal(uint32_t currentStep, float_X& phase) { - const float_64 runTime = DELTA_T*currentStep; - const float_64 f = SPEED_OF_LIGHT / WAVE_LENGTH; + const float_X runTime = DELTA_T*currentStep; + const float_X f = SPEED_OF_LIGHT / WAVE_LENGTH; - float3_X elong(0.0f, 0.0f, 0.0f); + float3_X elong(float3_X::create(0.0)); // a symmetric pulse will be initialized at position z=0 // the laser amplitude rises for T_rise // and falls for T_rise // making the laser pulse 2*T_rise long - const float_64 T_rise = 0.5 * PULSE_LENGTH; - const float_64 tau = runTime / T_rise; + const float_X T_rise = 0.5 * PULSE_LENGTH; + const float_X tau = runTime / T_rise; - const float_64 omegaLaser = 2.0 * PI * f; + const float_X omegaLaser = 2.0 * PI * f; - elong.x() = float_X( - float_64(AMPLITUDE) * - Tpolynomial(tau) - * math::sin(omegaLaser * (runTime - T_rise)) - ); + elong.x() = AMPLITUDE * Tpolynomial(tau) + * math::sin(omegaLaser * (runTime - T_rise) + LASER_PHASE); phase = 0.0f; @@ -77,13 +74,13 @@ HINLINE float3_X laserLongitudinal(uint32_t currentStep, float_X& phase) */ HDINLINE float3_X laserTransversal(float3_X elong, const float_X, const float_X posX, const float_X posZ) { - const float_64 exponent = (posX / W0x)*(posX / W0x) + (posZ / W0z)*(posZ / W0z); + const float_X exponent = (posX / W0x)*(posX / W0x) + (posZ / W0z)*(posZ / W0z); - return elong * precisionCast (math::exp(-exponent)); + return elong * math::exp(-exponent); } -HDINLINE float_64 Tpolynomial(const float_64 tau) +HDINLINE float_X Tpolynomial(const float_X tau) { if (tau >= 0.0 && tau <= 1.0) return tau * tau * tau * (10.0 - 15.0 * tau + 6.0 * tau * tau); diff --git a/src/picongpu/include/fields/laserProfiles/laserPulseFrontTilt.hpp b/src/picongpu/include/fields/laserProfiles/laserPulseFrontTilt.hpp index 93d32c135a..23e6933cbd 100644 --- a/src/picongpu/include/fields/laserProfiles/laserPulseFrontTilt.hpp +++ b/src/picongpu/include/fields/laserProfiles/laserPulseFrontTilt.hpp @@ -1,5 +1,5 @@ /** - * Copyright 2013 Heiko Burau, Anton Helm, Rene Widera + * Copyright 2013, 2015 Heiko Burau, Anton Helm, Rene Widera, Richard Pausch * * This file is part of PIConGPU. * @@ -43,7 +43,7 @@ namespace picongpu const double runTime = DELTA_T*currentStep; const double f = SPEED_OF_LIGHT / WAVE_LENGTH; - float3_X elong = float3_X(float_X(0.0), float_X(0.0), float_X(0.0)); + float3_X elong(float3_X::create(0.0)); // a symmetric pulse will be initialized at position z=0 for // a time of PULSE_INIT * PULSE_LENGTH = INIT_TIME. @@ -74,7 +74,7 @@ namespace picongpu elong.z() = float_X( envelope / sqrt(2.0) ); } - phase = 2.0f * float_X(PI ) * float_X(f ) * ( runTime - float_X(mue ) - FOCUS_POS / SPEED_OF_LIGHT ); + phase = 2.0f * float_X(PI ) * float_X(f ) * ( runTime - float_X(mue ) - FOCUS_POS / SPEED_OF_LIGHT ) + LASER_PHASE; return elong; } diff --git a/src/picongpu/include/fields/laserProfiles/laserWavepacket.hpp b/src/picongpu/include/fields/laserProfiles/laserWavepacket.hpp index aed166a77d..6192956ece 100644 --- a/src/picongpu/include/fields/laserProfiles/laserWavepacket.hpp +++ b/src/picongpu/include/fields/laserProfiles/laserWavepacket.hpp @@ -1,5 +1,5 @@ /** - * Copyright 2013-2014 Axel Huebl, Heiko Burau, Rene Widera, Richard Pausch + * Copyright 2013-2015 Axel Huebl, Heiko Burau, Rene Widera, Richard Pausch, Stefan Tietze * * This file is part of PIConGPU. * @@ -30,6 +30,9 @@ namespace picongpu /** not focusing wavepaket with spacial gaussian envelope * * no phase shifts, just spacial envelope + * including correction to laser formular derived from vector potential, so the integration + * along propagation direction gives 0 + * this is important for few-cycle laser pulses */ namespace laserWavepacket { @@ -40,7 +43,7 @@ namespace laserWavepacket HINLINE float3_X laserLongitudinal(uint32_t currentStep, float_X& phase) { float_X envelope = float_X(AMPLITUDE); - float3_X elong = float3_X(float_X(0.0), float_X(0.0), float_X(0.0)); + float3_X elong(float3_X::create(0.0)); // a symmetric pulse will be initialized at position z=0 for // a time of RAMP_INIT * PULSE_LENGTH + LASER_NOFOCUS_CONSTANT = INIT_TIME. @@ -56,6 +59,9 @@ HINLINE float3_X laserLongitudinal(uint32_t currentStep, float_X& phase) const double endUpramp = -0.5 * LASER_NOFOCUS_CONSTANT; const double startDownramp = 0.5 * LASER_NOFOCUS_CONSTANT; + const double tau = PULSE_LENGTH * sqrt(2.0); + + double correctionFactor = 0.0; if (runTime > startDownramp) { @@ -64,31 +70,32 @@ HINLINE float3_X laserLongitudinal(uint32_t currentStep, float_X& phase) ((runTime - startDownramp) / PULSE_LENGTH / sqrt(2.0)); envelope *= math::exp(-0.5 * exponent * exponent); + correctionFactor = (runTime - startDownramp)/(tau*tau*w); } else if(runTime < endUpramp) { // upramp = start const double exponent = ((runTime - endUpramp) / PULSE_LENGTH / sqrt(2.0)); envelope *= math::exp(-0.5 * exponent * exponent); + correctionFactor = (runTime - endUpramp)/(tau*tau*w); } + phase += float_X(w * runTime) + LASER_PHASE; + if( Polarisation == LINEAR_X ) { - elong.x() = envelope * math::sin(w * runTime); + elong.x() = float_X(envelope * (math::sin(phase) + correctionFactor * math::cos(phase))); } else if( Polarisation == LINEAR_Z ) { - elong.z() = envelope * math::sin(w * runTime); + elong.z() = float_X(envelope * (math::sin(phase) + correctionFactor * math::cos(phase))); } else if( Polarisation == CIRCULAR ) { - elong.x() = envelope / sqrt(2.0) * math::sin(w * runTime); - elong.z() = envelope / sqrt(2.0) * math::cos(w * runTime); + elong.x() = float_X(envelope / sqrt(2.0) * (math::sin(phase) + correctionFactor * math::cos(phase))); + elong.z() = float_X(envelope / sqrt(2.0) * (math::cos(phase) + correctionFactor * math::sin(phase))); } - - phase = float_X(0.0); - return elong; } diff --git a/src/picongpu/include/initialization/InitialiserController.hpp b/src/picongpu/include/initialization/InitialiserController.hpp index f115f996be..c1b13d3b30 100644 --- a/src/picongpu/include/initialization/InitialiserController.hpp +++ b/src/picongpu/include/initialization/InitialiserController.hpp @@ -84,6 +84,14 @@ class InitialiserController : public IInitPlugin Environment<>::get().PluginConnector().restartPlugins(restartStep, restartDirectory); __getTransactionEvent().waitForFinished(); + CUDA_CHECK(cudaDeviceSynchronize()); + CUDA_CHECK(cudaGetLastError()); + + GridController &gc = Environment::get().GridController(); + /* can be spared for better scalings, but guarantees the user + * that the restart was successful */ + MPI_CHECK(MPI_Barrier(gc.getCommunicator().getMPIComm())); + log ("Loading from persistent data finished"); } diff --git a/src/picongpu/include/particles/gasProfiles/GaussianCloudImpl.hpp b/src/picongpu/include/particles/gasProfiles/GaussianCloudImpl.hpp index 3981d37d83..2339ba0f6f 100644 --- a/src/picongpu/include/particles/gasProfiles/GaussianCloudImpl.hpp +++ b/src/picongpu/include/particles/gasProfiles/GaussianCloudImpl.hpp @@ -64,13 +64,13 @@ struct GaussianCloudImpl : public T_ParamClass if (globalCellPos.y() < vacuum_y) return float_X(0.0); - floatD_X exponent = float_X(math::abs((globalCellPos - center) / sigma)); - - - float_X density = 1; + float_X density(1.0); const float_X power = ParamClass::power; for (uint32_t d = 0; d < simDim; ++d) - density *= math::exp(ParamClass::factor * math::pow(exponent[d], power)); + { + const float_X exponent(math::abs((globalCellPos[d] - center[d]) / sigma[d])); + density *= math::exp(ParamClass::factor * math::pow(exponent, power)); + } return density; } diff --git a/src/picongpu/include/particles/ionization/None/AlgorithmNone.hpp b/src/picongpu/include/particles/ionization/None/AlgorithmNone.hpp index b8bde4f0b8..9559eff15f 100644 --- a/src/picongpu/include/particles/ionization/None/AlgorithmNone.hpp +++ b/src/picongpu/include/particles/ionization/None/AlgorithmNone.hpp @@ -22,7 +22,7 @@ #include "types.h" -/** IONIZATION ALGORITHM +/** IONIZATION ALGORITHM * - implements the calculation of ionization probability and changes charge states * - is called with the IONIZATION MODEL, specifically by setting the flag in @see speciesDefinition.param */ @@ -42,14 +42,14 @@ namespace ionization * \tparam EType type of electric field * \tparam BType type of magnetic field * \tparam ParticleType type of particle to be ionized - * + * * \param bField magnetic field value at t=0 * \param eField electric field value at t=0 * \param parentIon particle instance to be ionized with position at t=0 and momentum at t=-1/2 */ template - HDINLINE void - operator()( const BType bField, const EType eField, ParticleType& parentIon ) + HDINLINE void + operator()( const BType bField, const EType eField, ParticleType& parentIon ) { } diff --git a/src/picongpu/include/particles/ionization/byField/BSI/AlgorithmBSI.hpp b/src/picongpu/include/particles/ionization/byField/BSI/AlgorithmBSI.hpp index b229830884..68b3e5e46a 100644 --- a/src/picongpu/include/particles/ionization/byField/BSI/AlgorithmBSI.hpp +++ b/src/picongpu/include/particles/ionization/byField/BSI/AlgorithmBSI.hpp @@ -21,11 +21,12 @@ #pragma once #include "types.h" -#include "particles/ionization/ionizationEnergies.param" +#include "simulation_defines.hpp" #include "particles/traits/GetAtomicNumbers.hpp" #include "traits/attribute/GetChargeState.hpp" +#include "algorithms/math/floatMath/floatingPoint.tpp" -/** IONIZATION ALGORITHM +/** IONIZATION ALGORITHM * - implements the calculation of ionization probability and changes charge states * by decreasing the number of bound electrons * - is called with the IONIZATION MODEL, specifically by setting the flag in @see speciesDefinition.param */ @@ -46,21 +47,23 @@ namespace ionization * \tparam EType type of electric field * \tparam BType type of magnetic field * \tparam ParticleType type of particle to be ionized - * + * * \param bField magnetic field value at t=0 * \param eField electric field value at t=0 * \param parentIon particle instance to be ionized with position at t=0 and momentum at t=-1/2 */ template - HDINLINE void + HDINLINE void operator()( const BType bField, const EType eField, ParticleType& parentIon ) { const float_X protonNumber = GetAtomicNumbers::type::numberOfProtons; float_X chargeState = attribute::getChargeState(parentIon); + uint32_t cs = math::float2int_rd(chargeState); + /* ionization condition */ - if (math::abs(eField)*UNIT_EFIELD >= SI::IONIZATION_EFIELD && chargeState < protonNumber) + if (math::abs(eField)*UNIT_EFIELD >= SI::IONIZATION_EFIELD[cs] && chargeState < protonNumber) { /* set new particle charge state */ parentIon[boundElectrons_] -= float_X(1.0); diff --git a/src/picongpu/include/particles/ionization/byField/BSI/BSI.def b/src/picongpu/include/particles/ionization/byField/BSI/BSI.def index 4514260d78..134658ad27 100644 --- a/src/picongpu/include/particles/ionization/byField/BSI/BSI.def +++ b/src/picongpu/include/particles/ionization/byField/BSI/BSI.def @@ -29,12 +29,12 @@ namespace ionization /** \struct BSI * \brief Barrier Suppression Ionization - * + * * - takes the ionization energies of the various charge states of ions * - calculates the corresponding field strengths necessary to overcome the binding energy of the electron to the core * - if the field strength is locally exceeded: increase the charge state * - see for example: Delone, N. B.; Krainov, V. P. (1998). "Tunneling and barrier-suppression ionization of atoms and ions in a laser radiation field" - * + * * \tparam T_DestSpecies electron species to be created */ template struct BSI; diff --git a/src/picongpu/include/particles/ionization/byField/BSI/BSI.hpp b/src/picongpu/include/particles/ionization/byField/BSI/BSI.hpp index 129d6771b2..c16f65832b 100644 --- a/src/picongpu/include/particles/ionization/byField/BSI/BSI.hpp +++ b/src/picongpu/include/particles/ionization/byField/BSI/BSI.hpp @@ -45,7 +45,7 @@ namespace ionization /** Functor implementation * \tparam T_SrcSpecies particle species to be ionized * \tparam T_ParticleStorage \see picongpu/src/libPMacc/include/math/MapTuple.hpp - * + * * \param currentStep current time step */ template void operator()(T_SrcSpecies& src, T_ParticleStorage& pst, const uint32_t currentStep) diff --git a/src/picongpu/include/particles/ionization/byField/ionizers.hpp b/src/picongpu/include/particles/ionization/byField/ionizers.hpp index 6d2207b984..a94e613535 100644 --- a/src/picongpu/include/particles/ionization/byField/ionizers.hpp +++ b/src/picongpu/include/particles/ionization/byField/ionizers.hpp @@ -20,7 +20,7 @@ #pragma once -/* Includes containing definition of < Ionization Models > +/* Includes containing definition of < Ionization Models > * which itself each include their own < Ionization Algorithm > * that implements what the model actually DOES */ diff --git a/src/picongpu/include/particles/ionization/ionization.hpp b/src/picongpu/include/particles/ionization/ionization.hpp index f6b47c10e5..4f21439956 100644 --- a/src/picongpu/include/particles/ionization/ionization.hpp +++ b/src/picongpu/include/particles/ionization/ionization.hpp @@ -1,5 +1,5 @@ /** - * Copyright 2014 Marco Garten, Axel Huebl, Heiko Burau, Rene Widera, + * Copyright 2014 Marco Garten, Axel Huebl, Heiko Burau, Rene Widera, * Richard Pausch, Felix Schmitt * * This file is part of PIConGPU. @@ -25,7 +25,7 @@ #include #include "simulation_defines.hpp" -#include "particles/Particles.hpp" +#include "particles/Particles.hpp" #include "mappings/kernel/AreaMapping.hpp" #include "particles/ParticlesInit.kernel" #include "mappings/simulation/GridController.hpp" @@ -43,29 +43,29 @@ using namespace PMacc; /** \struct IonizeParticlesPerFrame * \brief gathers fields for particle interpolation and gives them to the ionization model - * + * * \tparam IonizeAlgo ionization algorithm - * \tparam TVec dimensions of the target: + * \tparam TVec dimensions of the target: * e.g. size of the super cell * \tparam T_Field2ParticleInterpolation type of field to particle interpolation - * \tparam NumericalCellType type of cell with respect to field discretization: - e.g. Yee cell + * \tparam NumericalCellType type of cell with respect to field discretization: + e.g. Yee cell */ template struct IonizeParticlesPerFrame { /** Functor implementation - * + * * \tparam FrameType frame type of particles that get ionized * \tparam T_BBox type of B-field box * \tparam T_EBox type of E-field box - * + * * \param ionFrame (here address of: ) frame of the to-be-ionized particles * \param localIdx local (linear) index in super cell / frame * \param bBox B-field box instance * \param ebox E-field box instance * \param newMacroElectrons (here address of: ) variable for each thread that stores the number - * of macro electrons to be created during the current time step + * of macro electrons to be created during the current time step */ template DINLINE void operator()(FrameType& ionFrame, int localIdx, T_BBox& bBox, T_EBox& eBox, unsigned int& newMacroElectrons) @@ -79,7 +79,6 @@ struct IonizeParticlesPerFrame typedef typename T_EBox::ValueType EType; PMACC_AUTO(particle,ionFrame[localIdx]); - const float_X weighting = particle[weighting_]; floatD_X pos = particle[position_]; const int particleCellIdx = particle[localCellIdx_]; @@ -92,9 +91,6 @@ struct IonizeParticlesPerFrame BType bField =Field2ParticleInterpolation() (bBox.shift(localCell).toCursor(), pos, NumericalCellType::getBFieldPosition()); - - float3_X mom = particle[momentum_]; - const float_X mass = attribute::getMass(weighting,particle); /* define number of bound macro electrons before ionization */ float_X prevBoundElectrons = particle[boundElectrons_]; @@ -106,31 +102,29 @@ struct IonizeParticlesPerFrame particle ); - particle[momentum_] = mom; - particle[position_] = pos; /* determine number of new macro electrons to be created */ newMacroElectrons = prevBoundElectrons - particle[boundElectrons_]; /*calculate one dimensional cell index*/ - particle[localCellIdx_] = DataSpaceOperations::template map (localCell); + } }; // struct IonizeParticlesPerFrame /** kernelIonizeParticles * \brief main kernel for ionization - * + * * - maps the frame dimensions and gathers the particle boxes * - caches the E- and B-fields * - contains / calls the ionization algorithm * - calls the electron creation functors - * + * * \tparam BlockDescription_ container for information about block / super cell dimensions * \tparam ParBoxIons container of the ions * \tparam ParBoxElectrons container of the electrons * \tparam BBox b-field box class * \tparam EBox e-field box class * \tparam Mapping class containing methods for acquiring info from the block - * \tparam FrameIonizer \see IonizeParticlesPerFrame + * \tparam FrameIonizer \see IonizeParticlesPerFrame */ template __global__ void kernelIonizeParticles(ParBoxIons ionBox, @@ -141,7 +135,7 @@ __global__ void kernelIonizeParticles(ParBoxIons ionBox, Mapping mapper) { - /* "particle box" : container/iterator where the particles live in + /* "particle box" : container/iterator where the particles live in * and where one can get the frame in a super cell from */ typedef typename ParBoxElectrons::FrameType ELECTRONFRAME; typedef typename ParBoxIons::FrameType IONFRAME; @@ -172,7 +166,7 @@ __global__ void kernelIonizeParticles(ParBoxIons ionBox, __syncthreads(); /*wait that all shared memory is initialized*/ - /* find last frame in super cell + /* find last frame in super cell * define maxParticlesInFrame as the maximum frame size */ if (linearThreadIdx == 0) { @@ -207,7 +201,7 @@ __global__ void kernelIonizeParticles(ParBoxIons ionBox, fieldEBlock ); - /* Declare counter in shared memory that will later tell the current fill level or + /* Declare counter in shared memory that will later tell the current fill level or * occupation of the newly created target electron frames. */ __shared__ int newFrameFillLvl; @@ -216,7 +210,7 @@ __global__ void kernelIonizeParticles(ParBoxIons ionBox, /* Declare local variable oldFrameFillLvl for each thread */ int oldFrameFillLvl; - /* Initialize local (register) counter for each thread + /* Initialize local (register) counter for each thread * - describes how many new macro electrons should be created */ unsigned int newMacroElectrons = 0; @@ -227,15 +221,15 @@ __global__ void kernelIonizeParticles(ParBoxIons ionBox, /* Master initializes the frame fill level with 0 */ if (linearThreadIdx == 0) { - newFrameFillLvl = 0; + newFrameFillLvl = 0; electronFrame = NULL; } __syncthreads(); - /* move over source species frames and call frameIonizer + /* move over source species frames and call frameIonizer * frames are worked on in backwards order to avoid asking if there is another frame - * --> performance - * Because all frames are completely filled except the last and apart from that last frame + * --> performance + * Because all frames are completely filled except the last and apart from that last frame * one wants to make sure that all threads are working and every frame is worked on. */ while (isValid) { @@ -243,8 +237,8 @@ __global__ void kernelIonizeParticles(ParBoxIons ionBox, const bool isParticle = (*ionFrame)[linearThreadIdx][multiMask_]; __syncthreads(); - /* < IONIZATION and change of charge states > - * if the threads contain particles, the frameIonizer can ionize them + /* < IONIZATION and change of charge states > + * if the threads contain particles, the frameIonizer can ionize them * if they are non-particles their inner ionization counter remains at 0 */ if (isParticle) /* ionization based on ionization model - this actually increases charge states*/ @@ -252,40 +246,40 @@ __global__ void kernelIonizeParticles(ParBoxIons ionBox, __syncthreads(); /* always true while-loop over all particles inside source frame until each thread breaks out individually - * + * * **Attention**: Speaking of 1st and 2nd frame only may seem odd. * The question might arise what happens if more electrons are created than would fit into two frames. * Well, multi-ionization during a time step is accounted for. The number of new electrons is - * determined inside the outer loop over the valid frames while in the inner loop each thread can create only ONE + * determined inside the outer loop over the valid frames while in the inner loop each thread can create only ONE * new macro electron. But the loop repeats until each thread has created all the electrons needed in the time step. */ while (true) { /* < INIT > * - electronId is initialized as -1 (meaning: invalid) - * - (local) oldFrameFillLvl set equal to (shared) newFrameFillLvl for each thread + * - (local) oldFrameFillLvl set equal to (shared) newFrameFillLvl for each thread * --> each thread remembers the old "counter" * - then sync */ electronId = -1; oldFrameFillLvl = newFrameFillLvl; __syncthreads(); /* < CHECK & ADD > - * - if a thread wants to create electrons in each cycle it can do that only once + * - if a thread wants to create electrons in each cycle it can do that only once * and before that it atomically adds to the shared counter and uses the current - * value as electronId in the new frame + * value as electronId in the new frame * - then sync */ - if (newMacroElectrons > 0) + if (newMacroElectrons > 0) electronId = atomicAdd(&newFrameFillLvl, 1); __syncthreads(); - /* < EXIT? > + /* < EXIT? > * - if the counter hasn't changed all threads break out of the loop */ - if (oldFrameFillLvl == newFrameFillLvl) + if (oldFrameFillLvl == newFrameFillLvl) break; __syncthreads(); /* < FIRST NEW FRAME > * - if there is no frame, yet, the master will create a new target electron frame - * and attach it to the back of the frame list + * and attach it to the back of the frame list * - sync all threads again for them to know which frame to use */ if (linearThreadIdx == 0) { @@ -297,8 +291,8 @@ __global__ void kernelIonizeParticles(ParBoxIons ionBox, } __syncthreads(); /* < CREATE 1 > - * - all electrons fitting into the current frame are created there - * - internal ionization counter is decremented by 1 + * - all electrons fitting into the current frame are created there + * - internal ionization counter is decremented by 1 * - sync */ if ((0 <= electronId) && (electronId < maxParticlesInFrame)) { @@ -315,7 +309,7 @@ __global__ void kernelIonizeParticles(ParBoxIons ionBox, newMacroElectrons -= 1; } __syncthreads(); - /* < SECOND NEW FRAME > + /* < SECOND NEW FRAME > * - if the shared counter is larger than the frame size a new electron frame is reserved * and attached to the back of the frame list * - then the shared counter is set back by one frame size @@ -331,7 +325,7 @@ __global__ void kernelIonizeParticles(ParBoxIons ionBox, } __syncthreads(); /* < CREATE 2 > - * - if the EID is larger than the frame size + * - if the EID is larger than the frame size * - the EID is set back by one frame size * - the thread writes an electron to the new frame * - the internal counter is decremented by 1 */ @@ -366,7 +360,7 @@ __global__ void kernelIonizeParticles(ParBoxIons ionBox, /** ionize * \brief ionization function currently being a member function of the source species - * + * * \tparam T_ParticleDescription container of particle source species information * \tparam T_Elec type of species to be created during ionization */ @@ -402,8 +396,8 @@ void Particles::ionize( T_Elec electrons, uint32_t ) /* 3-dim vector : number of threads to be started in every dimension */ dim3 block( MappingDesc::SuperCellSize::toRT().toDim3() ); - /* kernel call : instead of name<<>> (args, ...) - "blocks" will be calculated from "this->cellDescription" and "CORE + BORDER" + /* kernel call : instead of name<<>> (args, ...) + "blocks" will be calculated from "this->cellDescription" and "CORE + BORDER" "threads" is calculated from the previously defined vector "block" */ __picKernelArea( kernelIonizeParticles, this->cellDescription, CORE + BORDER ) (block) @@ -414,7 +408,7 @@ void Particles::ionize( T_Elec electrons, uint32_t ) FrameIonizer( ) ); - /* fill the gaps in the created species' particle frames to ensure that only + /* fill the gaps in the created species' particle frames to ensure that only * the last frame is not completely filled but every other before is full */ electrons->fillAllGaps(); diff --git a/src/picongpu/include/particles/ionization/ionizationMethods.hpp b/src/picongpu/include/particles/ionization/ionizationMethods.hpp index 8c0f5fc0a3..70bab0cf14 100644 --- a/src/picongpu/include/particles/ionization/ionizationMethods.hpp +++ b/src/picongpu/include/particles/ionization/ionizationMethods.hpp @@ -18,7 +18,7 @@ * If not, see . */ -/** \file +/** \file * This file contains methods needed for ionization like: particle creation functors */ #pragma once @@ -40,13 +40,13 @@ namespace ionization namespace partOp = PMacc::particles::operations; /** \struct WriteElectronIntoFrame - * + * * \brief functor that fills an electron frame entry with details about the created particle */ struct WriteElectronIntoFrame { /** Functor implementation - * + * * \tparam T_parentIon type of the particle which is ionized * \tparam T_childElectron type of the electron that will be created */ @@ -61,7 +61,7 @@ namespace ionization /* each thread initializes a clone of the parent ion but leaving out * some attributes: * - multiMask: reading from global memory takes longer than just setting it again explicitly - * - momentum: because the electron would get a higher energy because of the ion mass + * - momentum: because the electron would get a higher energy because of the ion mass * - boundElectrons: because species other than ions or atoms do not have them * (gets AUTOMATICALLY deselected because electrons do not have this attribute) */ PMACC_AUTO(targetElectronClone, partOp::deselect >(childElectron)); diff --git a/src/picongpu/include/particles/manipulators/RandomPosImpl.def b/src/picongpu/include/particles/manipulators/RandomPosImpl.def new file mode 100644 index 0000000000..fb149b1fa3 --- /dev/null +++ b/src/picongpu/include/particles/manipulators/RandomPosImpl.def @@ -0,0 +1,36 @@ +/** + * Copyright 2014 Rene Widera + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + + +#pragma once + +namespace picongpu +{ +namespace particles +{ +namespace manipulators +{ + +template< typename T_SpeciesType = bmpl::_1> +struct RandomPosImpl; + +} //namespace manipulators +} //namespace particles +} //namespace picongpu diff --git a/src/picongpu/include/particles/manipulators/RandomPosImpl.hpp b/src/picongpu/include/particles/manipulators/RandomPosImpl.hpp new file mode 100644 index 0000000000..3c311e21d5 --- /dev/null +++ b/src/picongpu/include/particles/manipulators/RandomPosImpl.hpp @@ -0,0 +1,94 @@ +/** + * Copyright 2013-2014 Axel Huebl, Heiko Burau, Rene Widera + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + + +#pragma once + +#include "simulation_defines.hpp" +#include "nvidia/rng/RNG.hpp" +#include "nvidia/rng/methods/Xor.hpp" +#include "nvidia/rng/distributions/Uniform_float.hpp" +#include "mpi/SeedPerRank.hpp" + +namespace picongpu +{ +namespace particles +{ +namespace manipulators +{ + +namespace nvrng = nvidia::rng; +namespace rngMethods = nvidia::rng::methods; +namespace rngDistributions = nvidia::rng::distributions; + +template< typename T_SpeciesType> +struct RandomPosImpl +{ + typedef T_SpeciesType SpeciesType; + typedef typename MakeIdentifier::type SpeciesName; + + HINLINE RandomPosImpl(uint32_t currentStep) : isInitialized(false) + { + typedef typename SpeciesType::FrameType FrameType; + + GlobalSeed globalSeed; + mpi::SeedPerRank seedPerRank; + seed = seedPerRank(globalSeed(), FrameType::CommunicationTag); + seed ^= POSITION_SEED; + + const SubGrid& subGrid = Environment::get().SubGrid(); + localCells = subGrid.getLocalDomain().size; + } + + template + DINLINE void operator()(const DataSpace& localCellIdx, T_Particle& particle, const bool isParticle) + { + typedef typename T_Particle::FrameType FrameType; + + if (!isInitialized) + { + const uint32_t cellIdx = DataSpaceOperations::map( + localCells, + localCellIdx); + rng = nvrng::create(rngMethods::Xor(seed, cellIdx), rngDistributions::Uniform_float()); + isInitialized = true; + } + if (isParticle) + { + floatD_X tmpPos; + + for (uint32_t d = 0; d < simDim; ++d) + tmpPos[d] = rng(); + + particle[position_] = tmpPos; + } + } + +private: + typedef PMacc::nvidia::rng::RNG RngType; + RngType rng; + bool isInitialized; + uint32_t seed; + DataSpace localCells; +}; + +} //namespace manipulators +} //namespace particles +} //namespace picongpu diff --git a/src/picongpu/include/particles/manipulators/SetAttributeImpl.def b/src/picongpu/include/particles/manipulators/SetAttributeImpl.def new file mode 100644 index 0000000000..06fb2632b0 --- /dev/null +++ b/src/picongpu/include/particles/manipulators/SetAttributeImpl.def @@ -0,0 +1,35 @@ +/** + * Copyright 2015 Marco Garten + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + +#pragma once + +namespace picongpu +{ +namespace particles +{ +namespace manipulators +{ + +template +struct SetAttributeImpl; + +} //namespace manipulators +} //namespace particles +} //namespace picongpu diff --git a/src/picongpu/include/particles/manipulators/SetAttributeImpl.hpp b/src/picongpu/include/particles/manipulators/SetAttributeImpl.hpp new file mode 100644 index 0000000000..971e0431f6 --- /dev/null +++ b/src/picongpu/include/particles/manipulators/SetAttributeImpl.hpp @@ -0,0 +1,67 @@ +/** + * Copyright 2015 Marco Garten + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + +#pragma once + +#include "simulation_defines.hpp" + + +namespace picongpu +{ +namespace particles +{ +namespace manipulators +{ + +template +struct SetAttributeImpl : private T_ValueFunctor +{ + typedef T_ParamClass ParamClass; + typedef T_SpeciesType SpeciesType; + typedef typename MakeIdentifier::type SpeciesName; + + typedef T_ValueFunctor ValueFunctor; + + HINLINE SetAttributeImpl(uint32_t currentStep) + { + + } + + template + DINLINE void operator()(const DataSpace& localCellIdx, T_Particle& particle, const bool isParticle) + { + typedef typename SpeciesType::FrameType FrameType; + + if (isParticle) + { + /** Number of bound electrons at initial state of the neutral atom */ + const float_X protonNumber = GetAtomicNumbers::type::numberOfProtons; + + /* in this case: 'assign' the number of protons to the number of bound electrons + * \see particleConfig.param for the ValueFunctor */ + ValueFunctor::operator()(particle[boundElectrons_], protonNumber); + } + } + +}; + +} //namespace manipulators +} //namespace particles +} //namespace picongpu diff --git a/src/picongpu/include/particles/manipulators/manipulators.def b/src/picongpu/include/particles/manipulators/manipulators.def index 66cda78199..2d5fdd3e97 100644 --- a/src/picongpu/include/particles/manipulators/manipulators.def +++ b/src/picongpu/include/particles/manipulators/manipulators.def @@ -28,3 +28,5 @@ #include "particles/manipulators/IfRelativeGlobalPositionImpl.def" #include "particles/manipulators/CreateParticlesFromParticleImpl.def" #include "particles/manipulators/FreeImpl.def" +#include "particles/manipulators/SetAttributeImpl.def" +#include "particles/manipulators/RandomPosImpl.def" diff --git a/src/picongpu/include/particles/manipulators/manipulators.hpp b/src/picongpu/include/particles/manipulators/manipulators.hpp index 5dcfa20f12..ae7e7093b7 100644 --- a/src/picongpu/include/particles/manipulators/manipulators.hpp +++ b/src/picongpu/include/particles/manipulators/manipulators.hpp @@ -27,3 +27,5 @@ #include "particles/manipulators/IfRelativeGlobalPositionImpl.hpp" #include "particles/manipulators/CreateParticlesFromParticleImpl.hpp" #include "particles/manipulators/FreeImpl.hpp" +#include "particles/manipulators/RandomPosImpl.hpp" +#include "particles/manipulators/SetAttributeImpl.hpp" diff --git a/src/picongpu/include/particles/pusher/particlePusherAxl.hpp b/src/picongpu/include/particles/pusher/particlePusherAxl.hpp index 04f463f323..9864e1d17d 100644 --- a/src/picongpu/include/particles/pusher/particlePusherAxl.hpp +++ b/src/picongpu/include/particles/pusher/particlePusherAxl.hpp @@ -115,7 +115,7 @@ namespace picongpu mom += eField * charge * deltaT; } - float3_X dr = float3_X( float_X(0.0), float_X(0.0), float_X(0.0) ); + float3_X dr(float3_X::create(0.0)); // old spacial change calculation: linear step if( TrajectoryInterpolation == LINEAR ) diff --git a/src/picongpu/include/particles/shapes.hpp b/src/picongpu/include/particles/shapes.hpp index 9bd41b6ddf..6fb939d9e2 100644 --- a/src/picongpu/include/particles/shapes.hpp +++ b/src/picongpu/include/particles/shapes.hpp @@ -1,5 +1,5 @@ /** - * Copyright 2013 Axel Huebl, Rene Widera + * Copyright 2013-2015 Axel Huebl, Rene Widera * * This file is part of PIConGPU. * @@ -29,3 +29,4 @@ #include "particles/shapes/CIC.hpp" #include "particles/shapes/TSC.hpp" #include "particles/shapes/PCS.hpp" +#include "particles/shapes/P4S.hpp" diff --git a/src/picongpu/include/particles/shapes/P4S.hpp b/src/picongpu/include/particles/shapes/P4S.hpp new file mode 100644 index 0000000000..860f76fd1f --- /dev/null +++ b/src/picongpu/include/particles/shapes/P4S.hpp @@ -0,0 +1,152 @@ +/** + * Copyright 2015 Rene Widera + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + +#pragma once + +#include "simulation_defines.hpp" + +namespace picongpu +{ +namespace particles +{ +namespace shapes +{ + +namespace shared_P4S +{ + +struct P4S +{ + static const int support = 5; + + HDINLINE static float_X ff_1st_radius(const float_X x) + { + /* + * W(x)= 115/192 - 5/8 * x^2 + 1/4 * x^4 + * = 115/192 + x^2 * (-5/8 + 1/4 * x^2) + */ + const float_X square_x = x * x; + return float_X(115. / 192.) + + square_x + * ( + float_X(-5. / 8.) + + float_X(1.0 / 4.0) * square_x + ); + } + + HDINLINE static float_X ff_2nd_radius(const float_X x) + { + /* + * W(x)= 1/96 * (55 + 20 * x - 120 * x^2 + 80 * x^3 - 16 * x^4) + * = 1/96 * (55 + 4 * x * (5 - 2 * x * (15 + 2 * x * (-5 + x)))) + */ + return float_X(1. / 96.)* + ( + float_X(55.) + float_X(4.) * x + * (float_X(5.) - float_X(2.) * x + * (float_X(15.) + float_X(2.) * x + * (float_X(-5.) + x) + ) + ) + ); + } + + HDINLINE static float_X ff_3rd_radius(const float_X x) + { + /* + * W(x)=1/384 * (5 - 2*x)^4 + */ + const float_X tmp = (float_X(5.) - float_X(2.) * x); + const float_X square_tmp = tmp * tmp; + const float_X biquadratic_tmp = square_tmp*square_tmp; + + return float_X(1. / 384.) * biquadratic_tmp; + } +}; + +} //namespace shared_P4S + +/** particle assignment shape `piecewise biquadratic spline` + */ +struct P4S : public shared_P4S::P4S +{ + typedef picongpu::particles::shapes::PCS CloudShape; + + struct ChargeAssignmentOnSupport : public shared_P4S::P4S + { + + HDINLINE float_X operator()(const float_X x) + { + /* - + * | 115/192 + x^2 * (-5/8 + 1/4 * x^2) if -1/2 < x < 1/2 + * W(x)=<| + * | 1/96 * (55 + 4 * x * (5 - 2 * x * (15 + 2 * x * (-5 + x)))) if 1/2 <= |x| < 3/2 + * | + * | 1/384 * (5 - 2 * x)^4 if 3/2 <= |x| < 5/2 + * - + */ + float_X abs_x = algorithms::math::abs(x); + + const bool below_3rd_radius = (abs_x < float_X(1.5)); + if (below_3rd_radius) + { + const bool below_2rd_radius = (abs_x < float_X(0.5)); + if (below_2rd_radius) + return ff_1st_radius(abs_x); + else + return ff_2nd_radius(abs_x); + } + else + return ff_3rd_radius(abs_x); + } + + }; + + struct ChargeAssignment : public shared_P4S::P4S + { + + HDINLINE float_X operator()(const float_X x) + { + + /* - + * | 115/192 + x^2 * (-5/8 + 1/4 * x^2) if -1/2 < x < 1/2 + * W(x)=<| + * | 1/96 * (55 + 4 * x * (5 - 2 * x * (15 + 2 * x * (-5 + x)))) if 1/2 <= |x| < 3/2 + * | + * | 1/384 * (5 - 2*x)^4 if 3/2 <= |x| < 5/2 + * | + * | 0 otherwise + * - + */ + float_X abs_x = algorithms::math::abs(x); + + const bool below_max = (abs_x < float_X(2.5)); + + if (below_max) + return ChargeAssignmentOnSupport()(abs_x); + else + return float_X(0.); + } + }; +}; + +} // namespace shapes +} //namespace particles +} //namespace picongpu diff --git a/src/picongpu/include/plugins/BinEnergyParticles.hpp b/src/picongpu/include/plugins/BinEnergyParticles.hpp index 4c5d4e7cce..14f580e2c9 100644 --- a/src/picongpu/include/plugins/BinEnergyParticles.hpp +++ b/src/picongpu/include/plugins/BinEnergyParticles.hpp @@ -158,7 +158,7 @@ __global__ void kernelBinEnergyParticles(ParticlesBox pb, (maxEnergy - minEnergy) * (float) numBins) + 1; const int maxBin = numBins + 1; - + /* all entries larger than maxEnergy go into bin maxBin */ binNumber = binNumber < maxBin ? binNumber : maxBin; @@ -232,10 +232,10 @@ class BinEnergyParticles : public ISimulationPlugin public: - BinEnergyParticles(std::string name, std::string prefix) : - analyzerName(name), - analyzerPrefix(prefix), - filename(name + ".dat"), + BinEnergyParticles() : + analyzerName("BinEnergyParticles: calculate a energy histogram of a species"), + analyzerPrefix(ParticlesType::FrameType::getName() + std::string("_energyHistogram")), + filename(analyzerPrefix + ".dat"), particles(NULL), gBins(NULL), cellDescription(NULL), diff --git a/src/picongpu/include/plugins/CountParticles.hpp b/src/picongpu/include/plugins/CountParticles.hpp index fcb48c8c62..87894663fa 100644 --- a/src/picongpu/include/plugins/CountParticles.hpp +++ b/src/picongpu/include/plugins/CountParticles.hpp @@ -71,10 +71,10 @@ class CountParticles : public ISimulationPlugin mpi::MPIReduce reduce; public: - CountParticles(std::string name, std::string prefix) : - analyzerName(name), - analyzerPrefix(prefix), - filename(name + ".dat"), + CountParticles() : + analyzerName("CountParticles: count macro particles of a species"), + analyzerPrefix(ParticlesType::FrameType::getName() + std::string("_macroParticlesCount")), + filename(analyzerPrefix + ".dat"), particles(NULL), cellDescription(NULL), notifyPeriod(0), diff --git a/src/picongpu/include/plugins/EnergyFields.hpp b/src/picongpu/include/plugins/EnergyFields.hpp index e4b30b0844..320cab085a 100644 --- a/src/picongpu/include/plugins/EnergyFields.hpp +++ b/src/picongpu/include/plugins/EnergyFields.hpp @@ -103,13 +103,13 @@ class EnergyFields : public ISimulationPlugin public: - EnergyFields(std::string name, std::string prefix) : + EnergyFields() : fieldE(NULL), fieldB(NULL), cellDescription(NULL), - analyzerName(name), - analyzerPrefix(prefix), - filename(name + ".dat"), + analyzerName("EnergyFields: calculate the energy of the fields"), + analyzerPrefix(std::string("fields_energy")), + filename(analyzerPrefix + ".dat"), notifyFrequency(0), writeToFile(false), localReduce(NULL) @@ -216,8 +216,8 @@ class EnergyFields : public ISimulationPlugin * idx == 1 -> fieldE */ EneVectorType globalFieldEnergy[2]; - globalFieldEnergy[0]=EneVectorType(0.0); - globalFieldEnergy[1]=EneVectorType(0.0); + globalFieldEnergy[0]=EneVectorType::create(0.0); + globalFieldEnergy[1]=EneVectorType::create(0.0); EneVectorType localReducedFieldEnergy[2]; localReducedFieldEnergy[0] = reduceField(fieldB); diff --git a/src/picongpu/include/plugins/EnergyParticles.hpp b/src/picongpu/include/plugins/EnergyParticles.hpp index aace5c911d..5b38b35b12 100644 --- a/src/picongpu/include/plugins/EnergyParticles.hpp +++ b/src/picongpu/include/plugins/EnergyParticles.hpp @@ -178,10 +178,10 @@ class EnergyParticles : public ISimulationPlugin public: - EnergyParticles(std::string name, std::string prefix) : - analyzerName(name), - analyzerPrefix(prefix), - filename(name + ".dat"), + EnergyParticles() : + analyzerName("EnergyParticles: calculate the energy of a species"), + analyzerPrefix(ParticlesType::FrameType::getName() + std::string("_energy")), + filename(analyzerPrefix + ".dat"), particles(NULL), gEnergy(NULL), cellDescription(NULL), diff --git a/src/picongpu/include/plugins/FieldEnergy.tpp b/src/picongpu/include/plugins/FieldEnergy.tpp deleted file mode 100644 index 2bd2774ee8..0000000000 --- a/src/picongpu/include/plugins/FieldEnergy.tpp +++ /dev/null @@ -1,116 +0,0 @@ -/** - * Copyright 2013 Axel Huebl, Heiko Burau, Rene Widera - * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ - -#include "math/vector/Int.hpp" -#include "math/vector/Float.hpp" -#include "math/vector/Size_t.hpp" -#include "cuSTL/container/PseudoBuffer.hpp" -#include "dataManagement/DataConnector.hpp" -#include "fields/FieldB.hpp" -#include "fields/FieldE.hpp" -#include "math/Vector.hpp" -#include "cuSTL/algorithm/mpi/Gather.hpp" -#include "cuSTL/container/DeviceBuffer.hpp" -#include "cuSTL/container/HostBuffer.hpp" -#include "cuSTL/cursor/tools/slice.hpp" -#include "cuSTL/algorithm/kernel/Foreach.hpp" -#include "cuSTL/algorithm/host/Foreach.hpp" -#include "lambda/Expression.hpp" -#include - -#include "cuSTL/algorithm/kernel/Reduce.hpp" - -namespace picongpu -{ - -FieldEnergy::FieldEnergy(std::string name, std::string prefix) - : name(name), prefix(prefix) -{ - Environment<>::get().PluginConnector().registerPlugin(this); -} - -void FieldEnergy::pluginRegisterHelp(po::options_description& desc) -{ - desc.add_options() - ((this->prefix + "_frequency").c_str(), - po::value (&this->notifyFrequency)->default_value(0), "notifyFrequency"); -} - -std::string FieldEnergy::pluginGetName() const {return this->name;} - -void FieldEnergy::pluginLoad() -{ - Environment<>::get().PluginConnector().setNotificationPeriod(this, this->notifyFrequency); -} - -void FieldEnergy::notify(uint32_t currentStep) -{ - - namespace math = PMacc::math; - using namespace math; - typedef SuperCellSize BlockDim; - - DataConnector &dc = Environment<>::get().DataConnector(); - FieldE& fieldE = dc.getData (FieldE::getName(), true); - FieldB& fieldB = dc.getData (FieldB::getName(), true); - - BOOST_AUTO(fieldE_coreBorder, - fieldE.getGridBuffer().getDeviceBuffer().cartBuffer().view(BlockDim().toRT(), -BlockDim().toRT())); - BOOST_AUTO(fieldB_coreBorder, - fieldB.getGridBuffer().getDeviceBuffer().cartBuffer().view(BlockDim().toRT(), -BlockDim().toRT())); - - PMacc::GridController<3>& con = PMacc::Environment<3>::get().GridController(); - PMacc::math::Size_t<3> gpuDim = (math::Size_t<3>)con.getGpuNodes(); - PMacc::math::Size_t<3> globalGridSize = gpuDim * fieldE_coreBorder.size(); - int globalCellZPos = globalGridSize.z() / 2; - int localCellZPos = globalCellZPos % fieldE_coreBorder.size().z(); - int gpuZPos = globalCellZPos / fieldE_coreBorder.size().z(); - - zone::SphericZone<3> gpuGatheringZone(math::Size_t<3>(gpuDim.x(), gpuDim.y(), 1), - PMacc::math::Int<3>(0,0,gpuZPos)); - algorithm::mpi::Gather<3> gather(gpuGatheringZone); - if(!gather.participate()) return; - container::DeviceBuffer energyDBuffer(fieldE_coreBorder.size().shrink<2>()); - - using namespace lambda; - BOOST_AUTO(_abs2, expr(math::Abs2())); - - algorithm::kernel::Foreach >()( - energyDBuffer.zone(), energyDBuffer.origin(), - cursor::tools::slice(fieldE_coreBorder.origin()(0,0,localCellZPos)), - cursor::tools::slice(fieldB_coreBorder.origin()(0,0,localCellZPos)), - _1 = (_abs2(_2) + _abs2(_3) * MUE0_EPS0) * - (float_X(0.5) * EPS0 * UNIT_ENERGY * UNITCONV_Joule_to_keV / (UNIT_LENGTH*UNIT_LENGTH*UNIT_LENGTH))); - - - container::HostBuffer energyHBuffer(energyDBuffer.size()); - energyHBuffer = energyDBuffer; - - /*\todo: domain size is now different for any gpu [fixme] */ - container::HostBuffer globalEnergyBuffer(energyHBuffer.size() * gpuDim.shrink<2>()); - gather(globalEnergyBuffer, energyHBuffer, 2); - if(!gather.root()) return; - std::ostringstream filename; - filename << "FieldEnergy_" << currentStep << ".dat"; - std::ofstream file(filename.str().c_str()); - file << globalEnergyBuffer; -} - -} diff --git a/src/picongpu/include/plugins/IntensityPlugin.hpp b/src/picongpu/include/plugins/IntensityPlugin.hpp index a08553a373..b551648a37 100644 --- a/src/picongpu/include/plugins/IntensityPlugin.hpp +++ b/src/picongpu/include/plugins/IntensityPlugin.hpp @@ -137,9 +137,9 @@ class IntensityPlugin : public ILightweightPlugin * max is only the SI value of the amplitude (V/m) * integrated is the integral of amplidude of X and Z on Y position (is V/m in cell volume) */ - IntensityPlugin(std::string name, std::string prefix) : - analyzerName(name), - analyzerPrefix(prefix), + IntensityPlugin() : + analyzerName("IntensityPlugin: calculate the maximum and integrated E-Field energy\nover laser propagation direction"), + analyzerPrefix(FieldE::getName() + std::string("_intensity")), localMaxIntensity(NULL), localIntegratedIntensity(NULL), cellDescription(NULL), @@ -191,8 +191,8 @@ class IntensityPlugin : public ILightweightPlugin if (writeToFile) { - createFile(analyzerName + "_max.dat", outFileMax); - createFile(analyzerName + "_integrated.dat", outFileIntegrated); + createFile(analyzerPrefix + "_max.dat", outFileMax); + createFile(analyzerPrefix + "_integrated.dat", outFileIntegrated); } Environment<>::get().PluginConnector().setNotificationPeriod(this, notifyFrequency); diff --git a/src/picongpu/include/plugins/LiveViewPlugin.hpp b/src/picongpu/include/plugins/LiveViewPlugin.hpp index 478c9b9479..2a2e6401c5 100644 --- a/src/picongpu/include/plugins/LiveViewPlugin.hpp +++ b/src/picongpu/include/plugins/LiveViewPlugin.hpp @@ -53,9 +53,9 @@ namespace picongpu typedef Visualisation VisType; typedef std::list VisPointerList; - LiveViewPlugin(std::string name, std::string prefix) : - analyzerName(name), - analyzerPrefix(prefix), + LiveViewPlugin() : + analyzerName("LiveViewPlugin: 2D (plane) insitu live visualisation of a species"), + analyzerPrefix(ParticlesType::FrameType::getName() + std::string("_liveView")), cellDescription(NULL) { Environment<>::get().PluginConnector().registerPlugin(this); diff --git a/src/picongpu/include/plugins/ParticleDensity.hpp b/src/picongpu/include/plugins/ParticleDensity.hpp deleted file mode 100644 index 0833345b11..0000000000 --- a/src/picongpu/include/plugins/ParticleDensity.hpp +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright 2013-2014 Heiko Burau, Rene Widera, Felix Schmitt - * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ - -#pragma once - - -#include "plugins/ILightweightPlugin.hpp" - -namespace picongpu -{ -namespace heiko -{ -using namespace PMacc; - -namespace po = boost::program_options; - -template -class ParticleDensity : public ILightweightPlugin -{ -private: - std::string name; - std::string prefix; - uint32_t notifyFrequency; - float_X factor; - int plane; - float_X slicePoint; - ParticlesType *particles; - -public: - ParticleDensity(std::string name, std::string prefix); - ~ParticleDensity() {} - - void notify(uint32_t currentStep); - void setMappingDescription(MappingDesc*) {} - void pluginRegisterHelp(po::options_description& desc); - std::string pluginGetName() const; - -private: - void pluginLoad(); -}; - -} -} - -#include "ParticleDensity.tpp" diff --git a/src/picongpu/include/plugins/ParticleDensity.tpp b/src/picongpu/include/plugins/ParticleDensity.tpp deleted file mode 100644 index eae45e033e..0000000000 --- a/src/picongpu/include/plugins/ParticleDensity.tpp +++ /dev/null @@ -1,171 +0,0 @@ -/** - * Copyright 2013 Axel Huebl, Heiko Burau, Rene Widera - * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ - -#include "math/vector/Int.hpp" -#include "math/vector/Float.hpp" -#include "math/vector/Size_t.hpp" -#include "cuSTL/container/PseudoBuffer.hpp" -#include "dataManagement/DataConnector.hpp" -#include "fields/FieldB.hpp" -#include "fields/FieldE.hpp" -#include "math/Vector.hpp" -#include "cuSTL/algorithm/mpi/Gather.hpp" -#include "cuSTL/algorithm/kernel/Reduce.hpp" -#include "cuSTL/algorithm/kernel/ForeachBlock.hpp" -#include "cuSTL/algorithm/host/Foreach.hpp" -#include "cuSTL/container/DeviceBuffer.hpp" -#include "cuSTL/container/HostBuffer.hpp" -#include "cuSTL/cursor/tools/slice.hpp" -#include "lambda/Expression.hpp" -#include "cuSTL/container/PNGBuffer.hpp" -#include -#include "particles/access/Cell2Particle.hpp" -#include "cuSTL/cursor/MultiIndexCursor.hpp" -#include - -namespace picongpu -{ -namespace heiko -{ - -template -struct ParticleDensityKernel -{ - typedef void result_type; - - int planeDir; - int localPlane; - ParticleDensityKernel() {} - ParticleDensityKernel(int planeDir, int localPlane) - : planeDir(planeDir), localPlane(localPlane) {} - - template - DINLINE void operator()(FramePtr frame, uint16_t particleID, Field field, const ::PMacc::math::Int<3>& blockCellIdx) - { - lcellId_t linearCellIdx = (*frame)[particleID][localCellIdx_]; - ::PMacc::math::Int<3> cellIdx(linearCellIdx % BlockDim::x::value, - (linearCellIdx / BlockDim::x::value) % BlockDim::x::value, - linearCellIdx / (BlockDim::x::value * BlockDim::y::value)); - if(cellIdx[planeDir] != localPlane) return; - - ::PMacc::math::Int<3> globalCellIdx = blockCellIdx - (PMacc::math::Int<3>)BlockDim().toRT() + cellIdx; - /// \warn reduce a normalized float_X with particleAccess::Weight() / particles::TYPICAL_NUM_PARTICLES_PER_MACROPARTICLE - /// to avoid overflows for heavy weightings - /// - atomicAdd(&(*field(globalCellIdx.shrink<2>((planeDir+1)%3))), (int)(*frame)[particleID][weighting_]); - } -}; - -template -ParticleDensity::ParticleDensity(std::string name, std::string prefix) - : name(name), prefix(prefix) -{ - Environment<>::get().PluginConnector().registerPlugin(this); -} - -template -void ParticleDensity::pluginRegisterHelp(po::options_description& desc) -{ - desc.add_options() - ((this->prefix + "_frequency").c_str(), - po::value (&this->notifyFrequency)->default_value(0), "notify frequency"); - desc.add_options() - ((this->prefix + "_factor").c_str(), - po::value (&this->factor)->default_value(float_X(1.0)), "factor"); - desc.add_options() - ((this->prefix + "_plane").c_str(), - po::value (&this->plane)->default_value(2), "specifies the axis which stands on the cutting plane (0,1,2)"); - desc.add_options() - ((this->prefix + "_slicePoint").c_str(), - po::value (&this->slicePoint)->default_value(float_X(0.5)), "slice point 0.0 <= x <= 1.0"); -} - -template -std::string ParticleDensity::pluginGetName() const {return this->name;} - -template -void ParticleDensity::pluginLoad() -{ - Environment<>::get().PluginConnector().setNotificationPeriod(this, this->notifyFrequency); -} - -template -void ParticleDensity::notify(uint32_t currentStep) -{ - DataConnector &dc = Environment<>::get().DataConnector(); - this->particles = &(dc.getData (ParticlesType::FrameType::getName(), true)); - - - namespace vec = ::PMacc::math; - typedef SuperCellSize BlockDim; - container::PseudoBuffer fieldE - (dc.getData (FieldE::getName(), true).getGridBuffer().getDeviceBuffer()); - zone::SphericZone<3> coreBorderZone(fieldE.zone().size - precisionCast(2*BlockDim::toRT()), - fieldE.zone().offset + BlockDim::toRT()); - - container::DeviceBuffer density(coreBorderZone.size.shrink<2>((plane+1)%3)); - density.assign(0); - - PMacc::GridController<3>& con = PMacc::Environment<3>::get().GridController(); - vec::Size_t<3> gpuDim = (vec::Size_t<3>)con.getGpuNodes(); - vec::Size_t<3> globalGridSize = gpuDim * coreBorderZone.size; - - int globalPlanePos = globalGridSize[plane] * this->slicePoint; - int localPlanePos = globalPlanePos % coreBorderZone.size[plane]; - int gpuPos = globalPlanePos / coreBorderZone.size[plane]; - int superCell = localPlanePos / BlockDim().toRT()[plane]; - int cellWithinSuperCell = localPlanePos % BlockDim().toRT()[plane]; - vec::Size_t<3> planeVec(0); planeVec[plane] = 1; - vec::Size_t<3> orthoPlaneVec(1); orthoPlaneVec[plane] = 0; - - zone::SphericZone<3> gpuGatheringZone(orthoPlaneVec * gpuDim + planeVec * vec::Size_t<3>(1,1,1), - (vec::Int<3>)planeVec * gpuPos); - algorithm::mpi::Gather<3> gather(gpuGatheringZone); - if(!gather.participate()) return; - - zone::SphericZone<3> superCellSliceZone(orthoPlaneVec * coreBorderZone.size + planeVec * (vec::Size_t<3>)BlockDim().toRT(), - coreBorderZone.offset + (vec::Int<3>)planeVec * superCell * (int)BlockDim().toRT()[plane]); - - using namespace lambda; - algorithm::kernel::ForeachBlock() - (superCellSliceZone, cursor::make_MultiIndexCursor<3>(), - expr(particleAccess::Cell2Particle()) - (this->particles->getDeviceParticlesBox(), - _1, ParticleDensityKernel(plane, cellWithinSuperCell), density.origin(), _1)); - - container::HostBuffer density_host(density.size()); - density_host = density; - container::HostBuffer globalDensity(density.size() * gpuDim.shrink<2>((plane+1)%3)); - gather(globalDensity, density_host, plane); - if(!gather.root()) return; - - std::stringstream filename; - filename << "density_" << currentStep << ".dat"; - std::ofstream file(filename.str().c_str()); - /// \warn reduce a normalized float_X with particleAccess::Weight() / particles::TYPICAL_NUM_PARTICLES_PER_MACROPARTICLE - /// to avoid overflows for heavy weightings - /// - /// \warn multiply normalized float_X "count" with particles::TYPICAL_NUM_PARTICLES_PER_MACROPARTICLE here (as double!) - /// - file << globalDensity; -} - -} -} diff --git a/src/picongpu/include/plugins/ParticleSpectrum.hpp b/src/picongpu/include/plugins/ParticleSpectrum.hpp deleted file mode 100644 index b80583419e..0000000000 --- a/src/picongpu/include/plugins/ParticleSpectrum.hpp +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright 2013 Heiko Burau, Rene Widera - * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ - -#ifndef ANALYSIS_PARTICLESPECTRUM_HPP -#define ANALYSIS_PARTICLESPECTRUM_HPP - - -#include "plugins/ILightweightPlugin.hpp" - -namespace picongpu -{ -using namespace PMacc; - -namespace po = boost::program_options; - -template -class ParticleSpectrum : public ILightweightPlugin -{ -private: - std::string name; - std::string prefix; - uint32_t notifyFrequency; - float_X minEnergy, maxEnergy; - static const int numBins = 64; - static const int numBinsEx = numBins+2; - ParticlesType *particles; - - void pluginLoad(); - void pluginUnload(); -public: - ParticleSpectrum(std::string name, std::string prefix); - ~ParticleSpectrum() {} - - void notify(uint32_t currentStep); - void setMappingDescription(MappingDesc*) {} - void pluginRegisterHelp(po::options_description& desc); - std::string pluginGetName() const; -}; - -namespace detail -{ -template -struct Histrogram -{ - static const int numBins = _numBins; - static const int numBinsEx = numBins + 2; - float_X bin[numBinsEx]; -}; -} - -} - -#include "ParticleSpectrum.tpp" - -#endif // ANALYSIS_PARTICLESPECTRUM_HPP diff --git a/src/picongpu/include/plugins/ParticleSpectrum.tpp b/src/picongpu/include/plugins/ParticleSpectrum.tpp deleted file mode 100644 index 0c8aa319a7..0000000000 --- a/src/picongpu/include/plugins/ParticleSpectrum.tpp +++ /dev/null @@ -1,212 +0,0 @@ -/** - * Copyright 2013 Axel Huebl, Heiko Burau, Rene Widera - * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ - -#include "math/vector/Int.hpp" -#include "math/vector/Float.hpp" -#include "math/vector/Size_t.hpp" -#include "cuSTL/container/PseudoBuffer.hpp" -#include "dataManagement/DataConnector.hpp" -#include "fields/FieldB.hpp" -#include "fields/FieldE.hpp" -#include "math/Vector.hpp" -#include "cuSTL/algorithm/mpi/Gather.hpp" -#include "cuSTL/algorithm/mpi/Reduce.hpp" -#include "cuSTL/algorithm/kernel/Reduce.hpp" -#include "cuSTL/algorithm/kernel/ForeachBlock.hpp" -#include "cuSTL/algorithm/host/Foreach.hpp" -#include "cuSTL/container/DeviceBuffer.hpp" -#include "cuSTL/container/HostBuffer.hpp" -#include "cuSTL/cursor/FunctorCursor.hpp" -#include "lambda/Expression.hpp" -#include -#include "particles/access/Cell2Particle.hpp" -#include "cuSTL/cursor/MultiIndexCursor.hpp" -#include -#include "simulation_defines.hpp" - -namespace picongpu -{ - -struct Particle2Histrogram -{ - typedef void result_type; - float_X minEnergy, maxEnergy; - DINLINE Particle2Histrogram(float_X minEnergy, float_X maxEnergy) - : minEnergy(minEnergy), maxEnergy(maxEnergy) {} - - template - DINLINE void operator()(FramePtr particle, uint16_t particleID, Histogram histogram) const - { - float3_X mom = particle->getMomentum()[particleID]; - float_X weighting = particle->getWeighting()[particleID]; - const float_X c2 = SPEED_OF_LIGHT * SPEED_OF_LIGHT; - const float_X mass = M_EL; - const float_X mass_reci = float_X(1.0) / mass; - const float_X mass2 = mass * mass; - - mom /= weighting; - float_X mom2 = abs2(mom); - float_X energy; - if(mom2 < 1.0e-3f * (4.0f * mass2 * c2)) // relative error of the taylor approx. smaller than 10^-3 - energy = mom2 * float_X(0.5) * mass_reci; - else - energy = sqrtf(mom2 * c2 + mass2 * c2*c2) - mass * c2; - int bin = math::float2int_rd(Histogram::type::numBins * (energy - minEnergy) / (maxEnergy - minEnergy)) + 1; - bin = max(0, bin); bin = min(Histogram::type::numBinsEx-1, bin); - atomicAddWrapper(&(histogram.get().bin[bin]), weighting); - } -}; - -template -struct ParticleSpectrumKernel -{ - typedef void result_type; - float_X minEnergy, maxEnergy; - ParticleSpectrumKernel() {} - ParticleSpectrumKernel(float_X minEnergy, float_X maxEnergy) - : minEnergy(minEnergy), maxEnergy(maxEnergy) {} - - template - DINLINE void operator()(ParticlesBox pb, - const ::PMacc::math::Int<3>& blockCellIdx, - Result result) const - { - uint16_t linearThreadIdx = threadIdx.z * BlockDim::x::value * BlockDim::y::value + - threadIdx.y * BlockDim::x::value + threadIdx.x; - - __shared__ detail::Histrogram shHistogram; - __syncthreads(); /*wait that all shared memory is initialised*/ - if(linearThreadIdx < numBins+2) shHistogram.bin[linearThreadIdx] = 0; //\todo: durch assign bzw. foreach ersetzen - __syncthreads(); - - particleAccess::Cell2Particle() - (pb, blockCellIdx, Particle2Histrogram(minEnergy, maxEnergy), forward(shHistogram)); - - ::PMacc::math::Int<3> _blockIdx = blockCellIdx / (PMacc::math::Int<3>)(BlockDim().toRT()); - __syncthreads(); - result[_blockIdx] = shHistogram; - } -}; - -template -ParticleSpectrum::ParticleSpectrum(std::string name, std::string prefix) - : name(name), prefix(prefix) -{ - Environment<>::get().PluginConnector().registerPlugin(this); -} - -template -void ParticleSpectrum::pluginRegisterHelp(po::options_description& desc) -{ - desc.add_options() - ((this->prefix + "_frequency").c_str(), - po::value (&this->notifyFrequency)->default_value(0), "notify frequency"); - desc.add_options() - ((this->prefix + "_minEnergy").c_str(), - po::value (&this->minEnergy)->default_value(0.0), "min energy [keV]"); - desc.add_options() - ((this->prefix + "_maxEnergy").c_str(), - po::value (&this->maxEnergy)->default_value(1000.0), "max energy [keV]"); - /*desc.add_options() - ((this->prefix + "_numBins").c_str(), - po::value (&this->numBins)->default_value(10), "number of bins");*/ -} - -template -std::string ParticleSpectrum::pluginGetName() const {return this->name;} - -template -void ParticleSpectrum::pluginLoad() -{ - Environment<>::get().PluginConnector().setNotificationPeriod(this, this->notifyFrequency); - - this->minEnergy = this->minEnergy * UNITCONV_keV_to_Joule / UNIT_ENERGY; - this->maxEnergy = this->maxEnergy * UNITCONV_keV_to_Joule / UNIT_ENERGY; -} - -template -void ParticleSpectrum::pluginUnload(){} - -struct GetBin -{ - typedef float& result_type; - int idx; - HDINLINE GetBin() {} //\todo: due to lambda lib - HDINLINE GetBin(int idx) : idx(idx) {} - - template - DINLINE float& operator()(Histogram& histogram) - { - return histogram.bin[this->idx]; - } -}; - -template -void ParticleSpectrum::notify(uint32_t) -{/* - DataConnector &dc = Environment<>::get().DataConnector(); - this->particles = &(dc.getData (ParticlesType::FrameType::getName(), true)); - - namespace vec = ::vector; - using namespace vec; - typedef vec::CT::Size_t<8,8,4> BlockDim; - container::PseudoBuffer fieldE - (dc.getData (FieldE::getName(), true).getGridBuffer().getDeviceBuffer()); - zone::SphericZone<3> coreBorderZone(fieldE.zone().size - (size_t)2*BlockDim().toRT(), - fieldE.zone().offset + (vec::Int<3>)BlockDim().toRT()); - - container::DeviceBuffer, 3> spectrumBlocks(coreBorderZone.size / BlockDim().toRT()); - - using namespace lambda; - algorithm::kernel::ForeachBlock() - (coreBorderZone, cursor::make_MultiIndexCursor<3>(), - expr(ParticleSpectrumKernel(minEnergy, maxEnergy)) - (this->particles->getDeviceParticlesBox(), - _1, spectrumBlocks.origin()(-coreBorderZone.offset / (vec::Int<3>)BlockDim().toRT()))); - - container::DeviceBuffer, 1> spectrum(1); - for(int i = 0; i < numBinsEx; i++) - { - algorithm::kernel::Reduce >() - (cursor::make_FunctorCursor(spectrum.origin(), GetBin(i)), - spectrumBlocks.zone(), - cursor::make_FunctorCursor(spectrumBlocks.origin(), GetBin(i)), - _1 + _2); - } - - container::HostBuffer, 1> spectrumHost(1); - spectrumHost = spectrum; - container::HostBuffer spectrumMPI(numBinsEx), globalSpectrum(numBinsEx); - for(size_t i = 0; i < numBinsEx; i++) spectrumMPI.origin()[(int)i] = (*spectrumHost.origin()).bin[i]; - - PMacc::GridController<3>& con = PMacc::Environment<3>::get().GridController(); - vec::Size_t<3> gpuDim = (vec::Size_t<3>)con.getGpuNodes(); - zone::SphericZone<3> gpuReducingZone(gpuDim); - algorithm::mpi::Reduce<3> reduce(gpuReducingZone); - reduce(globalSpectrum, spectrumMPI, MPI_FLOAT, MPI_SUM); - if(!reduce.root()) return; - - std::stringstream filename; - filename << "spectrum_" << currentStep << ".dat"; - std::ofstream file(filename.str().c_str()); - file << globalSpectrum;*/ -} - -} diff --git a/src/picongpu/include/plugins/PhaseSpace/PhaseSpace.tpp b/src/picongpu/include/plugins/PhaseSpace/PhaseSpace.tpp index 903a58b583..80d169aca4 100644 --- a/src/picongpu/include/plugins/PhaseSpace/PhaseSpace.tpp +++ b/src/picongpu/include/plugins/PhaseSpace/PhaseSpace.tpp @@ -90,7 +90,7 @@ namespace picongpu /* my plane means: the offset for the transversal plane to my r_element * should be zero */ - PMacc::math::Int longOffset(0); + PMacc::math::Int longOffset(PMacc::math::Int::create(0)); longOffset[this->axis_element.space] = planePos; zone::SphericZone zoneTransversalPlane( sizeTransversalPlane, longOffset ); @@ -102,7 +102,7 @@ namespace picongpu { PMacc::math::Int inPlaneGPU(gpuPos); inPlaneGPU[this->axis_element.space] = 0; - if( inPlaneGPU == PMacc::math::Int(0) ) + if( inPlaneGPU == PMacc::math::Int::create(0) ) isGroupRoot = true; } @@ -220,7 +220,7 @@ namespace picongpu container::HostBuffer hReducedBuffer( hBuffer.size() ); hReducedBuffer.assign( float_PS(0.0) ); - (*this->planeReduce)( /* parameters: dest, source */ + planeReduce->template operator()( /* parameters: dest, source */ hReducedBuffer, hBuffer, /* the functors return value will be written to dst */ diff --git a/src/picongpu/include/plugins/PhaseSpace/PhaseSpaceMulti.hpp b/src/picongpu/include/plugins/PhaseSpace/PhaseSpaceMulti.hpp index 393f975328..a7bf398ffd 100644 --- a/src/picongpu/include/plugins/PhaseSpace/PhaseSpaceMulti.hpp +++ b/src/picongpu/include/plugins/PhaseSpace/PhaseSpaceMulti.hpp @@ -70,7 +70,7 @@ namespace picongpu void pluginUnload(); public: - PhaseSpaceMulti( const std::string _name, const std::string _prefix ); + PhaseSpaceMulti( ); virtual ~PhaseSpaceMulti() {} void notify( uint32_t ) {} diff --git a/src/picongpu/include/plugins/PhaseSpace/PhaseSpaceMulti.tpp b/src/picongpu/include/plugins/PhaseSpace/PhaseSpaceMulti.tpp index 4d646df6c7..09e713bbf3 100644 --- a/src/picongpu/include/plugins/PhaseSpace/PhaseSpaceMulti.tpp +++ b/src/picongpu/include/plugins/PhaseSpace/PhaseSpaceMulti.tpp @@ -29,9 +29,11 @@ namespace picongpu namespace po = boost::program_options; template - PhaseSpaceMulti::PhaseSpaceMulti( const std::string _name, - const std::string _prefix ) : - name(_name), prefix(_prefix), numChildren(0u), cellDescription(NULL) + PhaseSpaceMulti::PhaseSpaceMulti( ) : + name("PhaseSpaceMulti: create phase space of a species"), + prefix(Species::FrameType::getName() + std::string("_phaseSpace")), + numChildren(0u), + cellDescription(NULL) { /* register our plugin during creation */ Environment<>::get().PluginConnector().registerPlugin(this); @@ -87,7 +89,7 @@ namespace picongpu else if( this->element_space.at(i) == "z" ) el_space = AxisDescription::z; else - throw PluginException("[Plugin] [" + this->name + "] space must be x, y or z" ); + throw PluginException("[Plugin] [" + this->prefix + "] space must be x, y or z" ); uint32_t el_momentum = AxisDescription::px; if( this->element_momentum.at(i) == "px" ) @@ -97,14 +99,14 @@ namespace picongpu else if( this->element_momentum.at(i) == "pz" ) el_momentum = AxisDescription::pz; else - throw PluginException("[Plugin] [" + this->name + "] momentum must be px, py or pz" ); + throw PluginException("[Plugin] [" + this->prefix + "] momentum must be px, py or pz" ); AxisDescription new_elements; new_elements.momentum = el_momentum; new_elements.space = el_space; if( simDim == DIM2 && el_space == AxisDescription::z ) - std::cerr << "[Plugin] [" + this->name + "] Skip requested output for " + std::cerr << "[Plugin] [" + this->prefix + "] Skip requested output for " << this->element_space.at(i) << this->element_momentum.at(i) << std::endl; diff --git a/src/picongpu/include/plugins/PluginController.hpp b/src/picongpu/include/plugins/PluginController.hpp index 5da6ce000d..2d45eccb1c 100644 --- a/src/picongpu/include/plugins/PluginController.hpp +++ b/src/picongpu/include/plugins/PluginController.hpp @@ -1,5 +1,5 @@ /** - * Copyright 2013-2014 Axel Huebl, Benjamin Schneider, Felix Schmitt, + * Copyright 2013-2015 Axel Huebl, Benjamin Schneider, Felix Schmitt, * Heiko Burau, Rene Widera, Richard Pausch * * This file is part of PIConGPU. @@ -65,21 +65,11 @@ #if(SIMDIM==DIM3) #include "plugins/IntensityPlugin.hpp" - -#include "plugins/FieldEnergy.hpp" -#if(PIC_ENABLE_PNG==1) -#include "plugins/ParticleDensity.hpp" #endif -#include "plugins/ParticleSpectrum.hpp" -#include "plugins/TotalDivJ.hpp" #include "plugins/SliceFieldPrinterMulti.hpp" -#endif #include "plugins/output/images/Visualisation.hpp" -#include "plugins/output/images/DensityToBinary.hpp" -#include "plugins/output/images/ParticleDensity.hpp" - #include #include "plugins/ISimulationPlugin.hpp" @@ -89,11 +79,9 @@ #include "plugins/makroParticleCounter/PerSuperCell.hpp" #endif -#if(SIMDIM==DIM3) #if (ENABLE_ADIOS == 1) #include "plugins/adios/ADIOSWriter.hpp" #endif -#endif namespace picongpu { @@ -109,151 +97,109 @@ class PluginController : public ILightweightPlugin std::list plugins; -#if (ENABLE_ELECTRONS == 1) -#if(PIC_ENABLE_PNG==1) - typedef Visualisation ElectronsPngBuilder; - typedef PngPlugin PngImageElectrons; -#endif - typedef ParticleDensity ElectronsBinaryDensityBuilder; - -#if(ENABLE_HDF5 == 1) - /* speciesParticleShape::ParticleShape::ChargeAssignment */ - typedef PhaseSpaceMulti PhaseSpaceElectrons; -#endif -#if(SIMDIM==DIM3) -#if(PIC_ENABLE_PNG==1) - typedef heiko::ParticleDensity HeikoParticleDensity; -#endif + template + struct PushBack + { - typedef ParticleSpectrum ElectronSpectrum; - typedef SliceFieldPrinterMulti SliceFieldEPrinter; - typedef SliceFieldPrinterMulti SliceFieldBPrinter; - typedef SliceFieldPrinterMulti SliceFieldJPrinter; -#endif + template + void operator()(T& list) + { + list.push_back(new T_Type()); + } + }; - typedef LiveViewPlugin LiveImageElectrons; - typedef PngPlugin BinDensityElectrons; - typedef CountParticles ElectronCounter; - typedef EnergyParticles EnergyElectrons; - typedef PositionsParticles PositionElectrons; - typedef BinEnergyParticles BinEnergyElectrons; -#if(ENABLE_RADIATION == 1) - typedef Radiation RadiationElectrons; -#endif -#endif + /** apply the 1st vector component to the 2nd + * + * @tparam T_TupleVector vector of type PMacc::math::CT::vector + * with two components + */ + template + struct ApplyDataToPlugin : + bmpl::apply1 >::type, + typename PMacc::math::CT::At >::type > + { + }; -#if (ENABLE_IONS == 1) -#if(PIC_ENABLE_PNG==1) - typedef Visualisation IonsPngBuilder; - typedef PngPlugin PngImageIons; + /* define stand alone plugins*/ + typedef bmpl::vector< + EnergyFields, + SumCurrents +#if(SIMDIM==DIM3) + , IntensityPlugin #endif -#if(ENABLE_HDF5 == 1) - /* speciesParticleShape::ParticleShape::ChargeAssignment */ - typedef PhaseSpaceMulti PhaseSpaceIons; +#if (ENABLE_INSITU_VOLVIS == 1) + , InSituVolumeRenderer #endif - typedef ParticleDensity IonsBinaryDensityBuilder; - typedef PngPlugin BinDensityIons; - typedef LiveViewPlugin LiveImageIons; - typedef CountParticles IonCounter; - typedef EnergyParticles EnergyIons; - typedef BinEnergyParticles BinEnergyIons; +#if (ENABLE_ADIOS == 1) + , adios::ADIOSWriter #endif - #if (ENABLE_HDF5 == 1) -#if (ENABLE_ELECTRONS == 1) - typedef PerSuperCell ElectronMakroParticleCounterPerSuperCell; -#endif -#if (ENABLE_IONS == 1) - typedef PerSuperCell IonMakroParticleCounterPerSuperCell; -#endif + , hdf5::HDF5Writer #endif + > StandAllownPlugins; - /** - * Initialises the controller by adding all user plugins to its internal list. - */ - virtual void init() - { -#if (ENABLE_HDF5 == 1) - plugins.push_back(new hdf5::HDF5Writer()); -#endif -#if(SIMDIM==DIM3) -#if (ENABLE_ADIOS == 1) - plugins.push_back(new adios::ADIOSWriter()); -#endif -#endif + /* define field plugins */ + typedef bmpl::vector< + SliceFieldPrinterMulti + > UnspecializedFieldPlugins; - plugins.push_back(new EnergyFields("EnergyFields", "energy_fields")); - plugins.push_back(new SumCurrents()); + typedef bmpl::vector< FieldB, FieldE, FieldJ> AllFields; -#if(SIMDIM==DIM3) - plugins.push_back(new FieldEnergy("FieldEnergy [keV/m^3]", "field_energy")); -#if(PIC_ENABLE_PNG==1) - plugins.push_back(new HeikoParticleDensity("HeikoParticleDensity", "heiko_pd")); -#endif - plugins.push_back(new ElectronSpectrum("Electron Spectrum", "spectrum")); - plugins.push_back(new TotalDivJ("change of total charge per timestep (single gpu)", "totalDivJ")); - plugins.push_back(new SliceFieldEPrinter("FieldE: prints a slice of the E-field", "FieldE")); - plugins.push_back(new SliceFieldBPrinter("FieldB: prints a slice of the B-field", "FieldB")); - plugins.push_back(new SliceFieldJPrinter("FieldJ: prints a slice of the current-field", "FieldJ")); + typedef typename AllCombinations< + bmpl::vector + >::type CombinedUnspecializedFieldPlugins; - plugins.push_back(new IntensityPlugin("Intensity", "intensity")); -#endif + typedef typename bmpl::transform< + CombinedUnspecializedFieldPlugins, + ApplyDataToPlugin + >::type FieldPlugins; -#if (ENABLE_ELECTRONS == 1) -#if(ENABLE_HDF5 == 1) - plugins.push_back(new PhaseSpaceElectrons("PhaseSpace Electrons", "ps_e")); -#endif - plugins.push_back(new LiveImageElectrons("LiveImageElectrons", "live_e")); -#if(PIC_ENABLE_PNG==1) - plugins.push_back(new PngImageElectrons("PngImageElectrons", "png_e")); -#endif - plugins.push_back(new BinDensityElectrons("BinDensityElectrons", "binDensity_e")); - plugins.push_back(new BinEnergyElectrons("BinEnergyElectrons", "bin_e")); - plugins.push_back(new ElectronCounter("ElectronsCount", "elec_cnt")); - plugins.push_back(new EnergyElectrons("EnergyElectrons", "energy_e")); - plugins.push_back(new PositionElectrons("PositionsElectrons", "pos_e")); -#endif -#if (ENABLE_IONS == 1) -#if(ENABLE_HDF5 == 1) - plugins.push_back(new PhaseSpaceIons("PhaseSpace Ions", "ps_i")); + /* define species plugins */ + typedef bmpl::vector < + CountParticles, + EnergyParticles, + BinEnergyParticles, + LiveViewPlugin, + PositionsParticles +#if(ENABLE_RADIATION == 1) + , Radiation #endif - plugins.push_back(new LiveImageIons("LiveImageIons", "live_i")); #if(PIC_ENABLE_PNG==1) - plugins.push_back(new PngImageIons("PngImageIons", "png_i")); + , PngPlugin< Visualisation > #endif - plugins.push_back(new BinDensityIons("BinDensityIons", "binDensity_i")); - plugins.push_back(new BinEnergyIons("BinEnergyIons", "bin_i")); - plugins.push_back(new IonCounter("IonsCount", "ions_cnt")); - plugins.push_back(new EnergyIons("EnergyIons", "energy_i")); +#if(ENABLE_HDF5 == 1) + , PerSuperCell + , PhaseSpaceMulti #endif + > UnspecializedSpeciesPlugins; -#if(ENABLE_RADIATION == 1) - plugins.push_back(new RadiationElectrons("RadiationElectrons", "radiation_e")); -#endif + typedef typename AllCombinations< + bmpl::vector + >::type CombinedUnspecializedSpeciesPlugins; -#if (ENABLE_INSITU_VOLVIS == 1) - plugins.push_back(new InSituVolumeRenderer("InSituVolumeRenderer", "insituvolvis")); -#endif -#if (ENABLE_HDF5 == 1) -#if (ENABLE_ELECTRONS == 1) - plugins.push_back(new ElectronMakroParticleCounterPerSuperCell("ElectronsMakroParticleCounterPerSuperCell","countPerSuperCell_e")); -#endif -#if (ENABLE_IONS == 1) - plugins.push_back(new IonMakroParticleCounterPerSuperCell("IonsMakroParticleCounterPerSuperCell","countPerSuperCell_i")); -#endif -#endif + typedef typename bmpl::transform< + CombinedUnspecializedSpeciesPlugins, + ApplyDataToPlugin + >::type SpeciesPlugins; - /** - * Add your plugin here, guard with pragmas if it depends on compile-time switches. - * Plugins must be heap-allocated (use 'new'). - * Plugins are free'd automatically. - * Plugins should use a short but descriptive prefix for all command line parameters, e.g. - * 'my_plugin.period', or 'my_plugin.parameter'. - */ - } + /* create sequence with all plugins*/ + typedef typename MakeSeq< + StandAllownPlugins, + FieldPlugins, + SpeciesPlugins + >::type AllPlugins; + + /** + * Initialises the controller by adding all user plugins to its internal list. + */ + virtual void init() + { + ForEach > pushBack; + pushBack(forward(plugins)); + } public: diff --git a/src/picongpu/include/plugins/PngPlugin.hpp b/src/picongpu/include/plugins/PngPlugin.hpp index d823e8f094..e4ba345a92 100644 --- a/src/picongpu/include/plugins/PngPlugin.hpp +++ b/src/picongpu/include/plugins/PngPlugin.hpp @@ -54,9 +54,9 @@ namespace picongpu typedef VisClass VisType; typedef std::list VisPointerList; - PngPlugin(std::string name, std::string prefix) : - analyzerName(name), - analyzerPrefix(prefix), + PngPlugin() : + analyzerName("PngPlugin: create png's of a species and fields"), + analyzerPrefix(VisType::FrameType::getName() + "_" + VisClass::CreatorType::getName()), cellDescription(NULL) { Environment<>::get().PluginConnector().registerPlugin(this); @@ -112,7 +112,7 @@ namespace picongpu { folders.push_back(std::string(".")); } - std::string filename(analyzerName + "_" + getValue(axis, i) + "_" + o_slicePoint.str()); + std::string filename(analyzerPrefix + "_" + getValue(axis, i) + "_" + o_slicePoint.str()); typename VisType::CreatorType pngCreator(filename, getValue(folders, i)); /** \todo rename me: transpose is the wrong name `swivel` is better * diff --git a/src/picongpu/include/plugins/PositionsParticles.hpp b/src/picongpu/include/plugins/PositionsParticles.hpp index 803146d0b5..bf0022d9f7 100644 --- a/src/picongpu/include/plugins/PositionsParticles.hpp +++ b/src/picongpu/include/plugins/PositionsParticles.hpp @@ -50,7 +50,7 @@ struct SglParticle float_X charge; float_X gamma; - SglParticle() : position(0.0), momentum(0.0), mass(0.0), + SglParticle() : position(FloatPos::create(0.0)), momentum(float3_X::create(0.0)), mass(0.0), weighting(0.0), charge(0.0), gamma(0.0) { } @@ -178,9 +178,9 @@ class PositionsParticles : public ILightweightPlugin public: - PositionsParticles(std::string name, std::string prefix) : - analyzerName(name), - analyzerPrefix(prefix), + PositionsParticles() : + analyzerName("PositionsParticles: write position of one particle of a species to std::cout"), + analyzerPrefix(ParticlesType::FrameType::getName() + std::string("_position")), particles(NULL), gParticle(NULL), cellDescription(NULL), @@ -206,7 +206,7 @@ class PositionsParticles : public ILightweightPlugin /*FORMAT OUTPUT*/ if (positionParticle.mass != float_X(0.0)) - std::cout << "[ANALYSIS] [" << rank << "] [COUNTER] [" << analyzerName << "] [" << currentStep << "] " + std::cout << "[ANALYSIS] [" << rank << "] [COUNTER] [" << analyzerPrefix << "] [" << currentStep << "] " << std::setprecision(16) << double(currentStep) * SI::DELTA_T_SI << " " << positionParticle << "\n"; // no flush } diff --git a/src/picongpu/include/plugins/SliceFieldPrinter.hpp b/src/picongpu/include/plugins/SliceFieldPrinter.hpp index bd3bd3c606..5934149590 100644 --- a/src/picongpu/include/plugins/SliceFieldPrinter.hpp +++ b/src/picongpu/include/plugins/SliceFieldPrinter.hpp @@ -1,5 +1,5 @@ /** - * Copyright 2013-2014 Heiko Burau, Rene Widera, Felix Schmitt, + * Copyright 2013-2015 Heiko Burau, Rene Widera, Felix Schmitt, * Richard Pausch * * This file is part of PIConGPU. @@ -47,7 +47,7 @@ class SliceFieldPrinter : public ILightweightPlugin int plane; float_X slicePoint; MappingDesc *cellDescription; - container::DeviceBuffer* dBuffer_SI; + container::DeviceBuffer* dBuffer_SI; void pluginLoad(); void pluginUnload(); diff --git a/src/picongpu/include/plugins/SliceFieldPrinter.tpp b/src/picongpu/include/plugins/SliceFieldPrinter.tpp index 8a7738fe4c..e616778b2f 100644 --- a/src/picongpu/include/plugins/SliceFieldPrinter.tpp +++ b/src/picongpu/include/plugins/SliceFieldPrinter.tpp @@ -1,5 +1,5 @@ /** - * Copyright 2013-2014 Heiko Burau, Rene Widera, Felix Schmitt, + * Copyright 2013-2015 Heiko Burau, Rene Widera, Felix Schmitt, * Richard Pausch * * This file is part of PIConGPU. @@ -66,10 +66,10 @@ void SliceFieldPrinter::pluginLoad() namespace vec = ::PMacc::math; typedef SuperCellSize BlockDim; - vec::Size_t<3> size = vec::Size_t<3>(this->cellDescription->getGridSuperCells()) * precisionCast(BlockDim::toRT()) + vec::Size_t size = vec::Size_t(this->cellDescription->getGridSuperCells()) * precisionCast(BlockDim::toRT()) - precisionCast(2 * BlockDim::toRT()); - this->dBuffer_SI = new container::DeviceBuffer( - size.shrink<2>((this->plane+1)%3)); + this->dBuffer_SI = new container::DeviceBuffer( + size.shrink((this->plane+1)%simDim)); } else { @@ -126,39 +126,50 @@ void SliceFieldPrinter::printSlice(const TField& field, int nAxis, float namespace vec = PMacc::math; using namespace vec::tools; - PMacc::GridController<3>& con = PMacc::Environment<3>::get().GridController(); - vec::Size_t<3> gpuDim = (vec::Size_t<3>)con.getGpuNodes(); - vec::Size_t<3> globalGridSize = gpuDim * field.size(); + PMacc::GridController& con = PMacc::Environment::get().GridController(); + vec::Size_t gpuDim = (vec::Size_t)con.getGpuNodes(); + vec::Size_t globalGridSize = gpuDim * field.size(); int globalPlane = globalGridSize[nAxis] * slicePoint; int localPlane = globalPlane % field.size()[nAxis]; int gpuPlane = globalPlane / field.size()[nAxis]; - vec::Int<3> nVector(0); + vec::Int nVector(vec::Int::create(0)); nVector[nAxis] = 1; - zone::SphericZone<3> gpuGatheringZone(vec::Size_t<3>(gpuDim.x(), gpuDim.y(), gpuDim.z()), - nVector * gpuPlane); + zone::SphericZone gpuGatheringZone(gpuDim, nVector * gpuPlane); gpuGatheringZone.size[nAxis] = 1; - algorithm::mpi::Gather<3> gather(gpuGatheringZone); + algorithm::mpi::Gather gather(gpuGatheringZone); if(!gather.participate()) return; using namespace lambda; - vec::UInt32<3> twistedVector((nAxis+1)%3, (nAxis+2)%3, nAxis); +#if(SIMDIM==DIM3) + vec::UInt32<3> twistedAxesVec((nAxis+1)%3, (nAxis+2)%3, nAxis); /* convert data to higher precision and to SI units */ SliceFieldPrinterHelper::ConversionFunctor cf; algorithm::kernel::Foreach >()( dBuffer_SI->zone(), dBuffer_SI->origin(), - cursor::tools::slice(field.originCustomAxes(twistedVector)(0,0,localPlane)), + cursor::tools::slice(field.originCustomAxes(twistedAxesVec)(0,0,localPlane)), cf ); +#endif +#if(SIMDIM==DIM2) + vec::UInt32<2> twistedAxesVec((nAxis+1)%2, nAxis); + + /* convert data to higher precision and to SI units */ + SliceFieldPrinterHelper::ConversionFunctor cf; + algorithm::kernel::Foreach >()( + dBuffer_SI->zone(), dBuffer_SI->origin(), + cursor::tools::slice(field.originCustomAxes(twistedAxesVec)(0,localPlane)), + cf ); +#endif /* copy selected plane from device to host */ - container::HostBuffer hBuffer(dBuffer_SI->size()); + container::HostBuffer hBuffer(dBuffer_SI->size()); hBuffer = *dBuffer_SI; /* collect data from all nodes/GPUs */ - container::HostBuffer globalBuffer(hBuffer.size() * gpuDim.shrink<2>((nAxis+1)%3)); + container::HostBuffer globalBuffer(hBuffer.size() * gpuDim.shrink((nAxis+1)%simDim)); gather(globalBuffer, hBuffer, nAxis); if(!gather.root()) return; std::ofstream file(filename.c_str()); diff --git a/src/picongpu/include/plugins/SliceFieldPrinterMulti.hpp b/src/picongpu/include/plugins/SliceFieldPrinterMulti.hpp index bb0cd8f365..3de7ff7823 100644 --- a/src/picongpu/include/plugins/SliceFieldPrinterMulti.hpp +++ b/src/picongpu/include/plugins/SliceFieldPrinterMulti.hpp @@ -53,7 +53,7 @@ class SliceFieldPrinterMulti : public ILightweightPlugin void pluginUnload(); public: - SliceFieldPrinterMulti(std::string name, std::string prefix); + SliceFieldPrinterMulti(); virtual ~SliceFieldPrinterMulti() {} void notify(uint32_t) {} diff --git a/src/picongpu/include/plugins/SliceFieldPrinterMulti.tpp b/src/picongpu/include/plugins/SliceFieldPrinterMulti.tpp index 05d44a0135..0c57926b51 100644 --- a/src/picongpu/include/plugins/SliceFieldPrinterMulti.tpp +++ b/src/picongpu/include/plugins/SliceFieldPrinterMulti.tpp @@ -1,5 +1,5 @@ /** - * Copyright 2013-2014 Heiko Burau, Rene Widera, Felix Schmitt, + * Copyright 2013-2015 Heiko Burau, Rene Widera, Felix Schmitt, * Richard Pausch * * This file is part of PIConGPU. @@ -43,8 +43,9 @@ namespace picongpu { template -SliceFieldPrinterMulti::SliceFieldPrinterMulti(std::string name, std::string prefix) - : name(name), prefix(prefix) +SliceFieldPrinterMulti::SliceFieldPrinterMulti() + : name("SliceFieldPrinter: prints a slice of a field"), + prefix(Field::getName() + std::string("_slice")) { Environment<>::get().PluginConnector().registerPlugin(this); } diff --git a/src/picongpu/include/plugins/SumCurrents.hpp b/src/picongpu/include/plugins/SumCurrents.hpp index fe3d4d6016..53f88ba5d3 100644 --- a/src/picongpu/include/plugins/SumCurrents.hpp +++ b/src/picongpu/include/plugins/SumCurrents.hpp @@ -58,7 +58,7 @@ __global__ void kernelSumCurrents(J_DataBox fieldJ, float3_X* gCurrent, Mapping if (linearThreadIdx == 0) { - sh_sumJ = float3_X(float_X(0.0), float_X(0.0), float_X(0.0)); + sh_sumJ = float3_X::create(0.0); } __syncthreads(); @@ -185,7 +185,7 @@ class SumCurrents : public ILightweightPlugin float3_X getSumCurrents() { - sumcurrents->getDeviceBuffer().setValue(float3_X(float_X(0.0), float_X(0.0), float_X(0.0))); + sumcurrents->getDeviceBuffer().setValue(float3_X::create(0.0)); dim3 block(MappingDesc::SuperCellSize::toRT().toDim3()); __picKernelArea(kernelSumCurrents, *cellDescription, CORE + BORDER) diff --git a/src/picongpu/include/plugins/TotalDivJ.tpp b/src/picongpu/include/plugins/TotalDivJ.tpp deleted file mode 100644 index 42107cec31..0000000000 --- a/src/picongpu/include/plugins/TotalDivJ.tpp +++ /dev/null @@ -1,107 +0,0 @@ -/** - * Copyright 2013-2014 Axel Huebl, Heiko Burau, Rene Widera, Felix Schmitt - * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ - -#include "math/vector/Int.hpp" -#include "math/vector/Float.hpp" -#include "math/vector/Size_t.hpp" -#include "cuSTL/container/PseudoBuffer.hpp" -#include "dataManagement/DataConnector.hpp" -#include "fields/FieldJ.hpp" -#include "math/Vector.hpp" -#include "cuSTL/algorithm/mpi/Gather.hpp" -#include "cuSTL/container/DeviceBuffer.hpp" -#include "cuSTL/container/HostBuffer.hpp" -#include "cuSTL/algorithm/kernel/Foreach.hpp" -#include "cuSTL/algorithm/host/Foreach.hpp" -#include "lambda/Expression.hpp" -#include - -#include "cuSTL/algorithm/kernel/Reduce.hpp" - -namespace picongpu -{ - -TotalDivJ::TotalDivJ(std::string name, std::string prefix) - : name(name), prefix(prefix) -{ - Environment<>::get().PluginConnector().registerPlugin(this); -} - -void TotalDivJ::pluginRegisterHelp(po::options_description& desc) -{ - desc.add_options() - ((this->prefix + "_frequency").c_str(), - po::value (&this->notifyFrequency)->default_value(0), "notifyFrequency"); -} - -std::string TotalDivJ::pluginGetName() const {return this->name;} - -void TotalDivJ::pluginLoad() -{ - Environment<>::get().PluginConnector().setNotificationPeriod(this, this->notifyFrequency); -} - -struct Div -{ - typedef float_X result_type; - - template - HDINLINE float_X operator()(Field field) const - { - return ((*field(1,0,0)).x() - (*field).x()) * (float_X(1.0) / CELL_WIDTH) + - ((*field(0,1,0)).y() - (*field).y()) * (float_X(1.0) / CELL_HEIGHT) + - ((*field(0,0,1)).z() - (*field).z()) * (float_X(1.0) / CELL_DEPTH); - } -}; - -void TotalDivJ::notify(uint32_t currentStep) -{ - namespace vec = PMacc::math; - using namespace vec; - typedef SuperCellSize BlockDim; - - DataConnector &dc = Environment<>::get().DataConnector(); - - container::PseudoBuffer fieldJ - (dc.getData (FieldJ::getName(), true).getGridBuffer().getDeviceBuffer()); - - container::DeviceBuffer fieldDivJ(fieldJ.size()); - zone::SphericZone<3> coreBorderZone(fieldJ.zone().size - precisionCast(2*BlockDim::toRT()), - fieldJ.zone().offset + BlockDim::toRT()); - //std::cout << coreBorderZone.size << ", " << coreBorderZone.offset << std::endl; - using namespace lambda; - algorithm::kernel::Foreach() - (coreBorderZone, fieldDivJ.origin(), cursor::make_NestedCursor(fieldJ.origin()), - _1 = expr(Div())(_2)); - - container::DeviceBuffer totalDivJ(1); - algorithm::kernel::Reduce() - (totalDivJ.origin(), coreBorderZone, fieldDivJ.origin(), _1 + _2); - container::HostBuffer totalDivJ_host(1); - totalDivJ_host = totalDivJ; - - static std::ofstream file("totalDivJ.dat"); - - file << "step: " << currentStep << ", totalDivJ: " - << *totalDivJ_host.origin() * CELL_VOLUME * UNIT_CHARGE - << " Coulomb" << std::endl; -} - -} diff --git a/src/picongpu/include/plugins/adios/ADIOSWriter.def b/src/picongpu/include/plugins/adios/ADIOSWriter.def index de2e9bbab8..925ec0d7be 100644 --- a/src/picongpu/include/plugins/adios/ADIOSWriter.def +++ b/src/picongpu/include/plugins/adios/ADIOSWriter.def @@ -21,13 +21,20 @@ #pragma once #include +#include + #include +#include +#include +#include +#include // std::cerr #include "types.h" #include "math/Vector.hpp" #include "simulation_types.hpp" #include "particles/frame_types.hpp" #include "simulationControl/MovingWindow.hpp" +#include "traits/PICToAdios.hpp" namespace picongpu { @@ -55,16 +62,18 @@ namespace po = boost::program_options; { \ int _err_code = _cmd; \ if (_err_code != ADIOS_SUCCESS) \ - log ("ADIOS: error at cmd '%1%': '%2%'") % \ - #_cmd % _err_code; \ + std::cerr << "ADIOS: error at cmd '" << #_cmd \ + << "' (" << _err_code << ") in " \ + << __FILE__ << ":" << __LINE__ << adios_errmsg(); \ } #define ADIOS_CMD_EXPECT_NONZERO(_cmd) \ { \ int _err_code = _cmd; \ if (_err_code == 0) \ - log ("ADIOS: error at cmd '%1%': '%2%'") % \ - #_cmd % _err_code; \ + std::cerr << "ADIOS: error at cmd '" << #_cmd \ + << "' (" << _err_code << ") in " \ + << __FILE__ << ":" << __LINE__ << adios_errmsg(); \ } struct ThreadParams @@ -72,6 +81,10 @@ struct ThreadParams uint32_t currentStep; /** current simulation step */ std::string fullFilename; + /** current dump is a checkpoint */ + bool isCheckpoint; + ADIOS_FILE* fp; /* file pointer for checkpoint file */ + MPI_Comm adiosComm; /* MPI communicator for adios lib */ bool adiosBufferInitialized; /* set if ADIOS buffer has been allocated */ int64_t adiosFileHandle; /* ADIOS file handle */ @@ -89,7 +102,6 @@ struct ThreadParams std::list adiosFieldVarIds; /* var IDs for fields in order of appearance */ std::list adiosParticleAttrVarIds; /* var IDs for particle attributes in order of appearance */ std::list adiosSpeciesIndexVarIds; /* var IDs for species index tables in order of appearance */ - std::list adiosMetaAttrVarIds; /* var IDs for scalar meta attributes */ GridLayout gridLayout; MappingDesc *cellDescription; @@ -108,6 +120,31 @@ struct ThreadParams class ADIOSWriter; +/** Default ADIOS types we will use */ +typedef PICToAdios AdiosUInt32Type; +typedef PICToAdios AdiosFloatXType; +typedef PICToAdios AdiosDoubleType; + +/** Attribute conversation: values to c-strings in ADIOS C-API <= 1.8.0 */ +template +static std::string flt2str( T val ) +{ + typedef std::numeric_limits< T > fltLimit; + + std::stringstream s; + s.precision(fltLimit::digits10); + s << std::scientific << val; + return s.str(); +} + +template +static std::string int2str( T val ) +{ + std::stringstream s; + s << val; + return s.str(); +} + /** * Wrapper for adios_define_var that sets data transform method * diff --git a/src/picongpu/include/plugins/adios/ADIOSWriter.hpp b/src/picongpu/include/plugins/adios/ADIOSWriter.hpp index c65d1b70bc..c5e8b4d4d9 100644 --- a/src/picongpu/include/plugins/adios/ADIOSWriter.hpp +++ b/src/picongpu/include/plugins/adios/ADIOSWriter.hpp @@ -33,13 +33,13 @@ #include "particles/frame_types.hpp" #include +#include +#include #include "fields/FieldB.hpp" #include "fields/FieldE.hpp" #include "fields/FieldJ.hpp" #include "fields/FieldTmp.hpp" -#include "particles/particleFilter/FilterFactory.hpp" -#include "particles/particleFilter/PositionFilter.hpp" #include "particles/operations/CountParticles.hpp" #include "dataManagement/DataConnector.hpp" @@ -58,11 +58,17 @@ #include #include #include +#include #include +#if !defined(_WIN32) +#include +#endif #include "plugins/adios/WriteSpecies.hpp" #include "plugins/adios/ADIOSCountParticles.hpp" +#include "plugins/adios/restart/LoadSpecies.hpp" +#include "plugins/adios/restart/RestartFieldLoader.hpp" namespace picongpu @@ -106,9 +112,9 @@ int64_t defineAdiosVar(int64_t group_id, } else { var_id = adios_define_var( group_id, name, path, type, - dimensions.toString(",", "").c_str(), - globalDimensions.toString(",", "").c_str(), - offset.toString(",", "").c_str()); + dimensions.revert().toString(",", "").c_str(), + globalDimensions.revert().toString(",", "").c_str(), + offset.revert().toString(",", "").c_str()); } if (compression && canCompress) @@ -119,6 +125,8 @@ int64_t defineAdiosVar(int64_t group_id, #endif } + log ("ADIOS: Defined varID=%1% for '%2%' at %3% for %4%/%5% elements") % + var_id % std::string(name) % offset.toString() % dimensions.toString() % globalDimensions.toString(); return var_id; } @@ -128,17 +136,8 @@ int64_t defineAdiosVar(int64_t group_id, */ class ADIOSWriter : public ILightweightPlugin { -public: - - /* filter particles by global position*/ - typedef bmpl::vector< typename GetPositionFilter::type > usedFilters; - typedef typename FilterFactory::FilterType MyParticleFilter; - private: - /* filter is a rule which describes which particles should be copied to host*/ - MyParticleFilter filter; - template static std::vector createUnit(UnitType unit, uint32_t numComponents) { @@ -158,13 +157,6 @@ class ADIOSWriter : public ILightweightPlugin typedef typename T::ValueType ValueType; typedef typename GetComponentsType::type ComponentType; - static std::vector getUnit() - { - typedef typename T::UnitValueType UnitType; - UnitType unit = T::getUnit(); - return createUnit(unit, T::numComponents); - } - public: HDINLINE void operator()(ThreadParams* params) @@ -181,7 +173,6 @@ class ADIOSWriter : public ILightweightPlugin adiosType.type, GetNComponents::value, T::getName(), - getUnit(), field->getHostDataBox().getPointer()); dc.releaseData(T::getName()); @@ -228,15 +219,6 @@ class ADIOSWriter : public ILightweightPlugin return str.str(); } - /** Get the unit for the result from the solver*/ - static std::vector getUnit() - { - typedef typename FieldTmp::UnitValueType UnitType; - UnitType unit = FieldTmp::getUnit(); - const uint32_t components = GetNComponents::value; - return createUnit(unit, components); - } - HINLINE void operator_impl(ThreadParams* params) { DataConnector &dc = Environment<>::get().DataConnector(); @@ -248,7 +230,7 @@ class ADIOSWriter : public ILightweightPlugin /*load particle without copy particle data to host*/ Species* speciesTmp = &(dc.getData(Species::FrameType::getName(), true)); - fieldTmp->getGridBuffer().getDeviceBuffer().setValue(FieldTmp::ValueType(0.0)); + fieldTmp->getGridBuffer().getDeviceBuffer().setValue(ValueType::create(0.0)); /*run algorithm*/ fieldTmp->computeValue < CORE + BORDER, Solver > (*speciesTmp, params->currentStep); @@ -269,7 +251,6 @@ class ADIOSWriter : public ILightweightPlugin adiosType.type, components, getName(), - getUnit(), fieldTmp->getHostDataBox().getPointer()); dc.releaseData(FieldTmp::getName()); @@ -279,7 +260,8 @@ class ADIOSWriter : public ILightweightPlugin }; static void defineFieldVar(ThreadParams* params, - uint32_t nComponents, ADIOS_DATATYPES adiosType, const std::string name) + uint32_t nComponents, ADIOS_DATATYPES adiosType, const std::string name, + std::vector unit) { const std::string name_lookup_tpl[] = {"x", "y", "z", "w"}; @@ -304,6 +286,14 @@ class ADIOSWriter : public ILightweightPlugin params->adiosCompression); params->adiosFieldVarIds.push_back(adiosFieldVarId); + + /* already add the sim_unit attribute so `adios_group_size` calculates + * the reservation for the buffer correctly */ + AdiosDoubleType adiosDoubleType; + + ADIOS_CMD(adios_define_attribute(params->adiosGroupHandle, + "sim_unit", datasetName.str().c_str(), adiosDoubleType.type, + flt2str(unit.at(c)).c_str(), "")); } } @@ -315,8 +305,15 @@ class ADIOSWriter : public ILightweightPlugin { public: typedef typename T::ValueType ValueType; + typedef typename T::UnitValueType UnitType; typedef typename GetComponentsType::type ComponentType; + static std::vector getUnit() + { + UnitType unit = T::getUnit(); + return createUnit(unit, T::numComponents); + } + HDINLINE void operator()(ThreadParams* params) { #ifndef __CUDA_ARCH__ @@ -331,7 +328,7 @@ class ADIOSWriter : public ILightweightPlugin params->adiosGroupSize += localGroupSize; PICToAdios adiosType; - defineFieldVar(params, components, adiosType.type, T::getName()); + defineFieldVar(params, components, adiosType.type, T::getName(), getUnit()); #endif } }; @@ -353,6 +350,7 @@ class ADIOSWriter : public ILightweightPlugin private: typedef typename FieldTmp::ValueType ValueType; + typedef typename FieldTmp::UnitValueType UnitType; typedef typename GetComponentsType::type ComponentType; /** Create a name for the adios identifier. @@ -366,6 +364,14 @@ class ADIOSWriter : public ILightweightPlugin return str.str(); } + /** Get the unit for the result from the solver*/ + static std::vector getUnit() + { + UnitType unit = FieldTmp::getUnit(); + const uint32_t components = GetNComponents::value; + return createUnit(unit, components); + } + HINLINE void operator_impl(ThreadParams* params) { const uint32_t components = GetNComponents::value; @@ -379,7 +385,7 @@ class ADIOSWriter : public ILightweightPlugin params->adiosGroupSize += localGroupSize; PICToAdios adiosType; - defineFieldVar(params, components, adiosType.type, getName()); + defineFieldVar(params, components, adiosType.type, getName(), getUnit()); } }; @@ -388,6 +394,10 @@ class ADIOSWriter : public ILightweightPlugin ADIOSWriter() : filename("simDataAdios"), + checkpointFilename("adios_checkpoint"), + restartFilename(""), /* set to checkpointFilename by default */ + /* select MPI method, #OSTs and #aggregators */ + mpiTransportParams(""), notifyPeriod(0) { Environment<>::get().PluginConnector().registerPlugin(this); @@ -413,7 +423,18 @@ class ADIOSWriter : public ILightweightPlugin "ADIOS compression method (see 'adios_config -m' for help)") #endif ("adios.file", po::value (&filename)->default_value(filename), - "ADIOS output file"); + "ADIOS output file") + ("adios.checkpoint-file", po::value (&checkpointFilename), + "Optional ADIOS checkpoint filename (prefix)") + ("adios.restart-file", po::value (&restartFilename), + "adios restart filename (prefix)") + /* 1,000,000 particles are around 3900 frames at 256 particles per frame + * and match ~30MiB with typical picongpu particles. + * The only reason why we use 1M particles per chunk is that we can get a + * frame overflow in our memory manager if we process all particles in one kernel. + **/ + ("adios.restart-chunkSize", po::value (&restartChunkSize)->default_value(1000000), + "Number of particles processed in one kernel call during restart to prevent frame count blowup"); } std::string pluginGetName() const @@ -428,41 +449,145 @@ class ADIOSWriter : public ILightweightPlugin __host__ void notify(uint32_t currentStep) { - const SubGrid& subGrid = Environment::get().SubGrid(); - mThreadParams.currentStep = (int32_t) currentStep; - mThreadParams.cellDescription = this->cellDescription; - this->filter.setStatus(false); + notificationReceived(currentStep, false); + } + + void checkpoint(uint32_t currentStep, const std::string checkpointDirectory) + { + this->checkpointDirectory = checkpointDirectory; - mThreadParams.window = MovingWindow::getInstance().getWindow(currentStep); + notificationReceived(currentStep, true); + } - if (MovingWindow::getInstance().isSlidingWindowActive()) - { - //enable filters for sliding window and configurate position filter - this->filter.setStatus(true); + void restart(uint32_t restartStep, const std::string restartDirectory) + { + std::stringstream adiosPathBase; + adiosPathBase << ADIOS_PATH_ROOT << restartStep << "/"; + mThreadParams.adiosBasePath = adiosPathBase.str(); + //mThreadParams.isCheckpoint = isCheckpoint; + mThreadParams.currentStep = restartStep; + mThreadParams.cellDescription = this->cellDescription; - this->filter.setWindowPosition( - mThreadParams.window.localDimensions.offset, - mThreadParams.window.localDimensions.size); - } + /** one could try ADIOS_READ_METHOD_BP_AGGREGATE too which might + * be beneficial for re-distribution on a different number of GPUs + * would need: - export chunk_size= in MB + * - mpiTransportParams.c_str() in adios_read_init_method + */ + ADIOS_CMD(adios_read_init_method(ADIOS_READ_METHOD_BP, + mThreadParams.adiosComm, + "verbose=3;")); //mpiTransportParams.c_str())); // rly ? - for (uint32_t i = 0; i < simDim; ++i) + /* if restartFilename is relative, prepend with restartDirectory */ + if (!boost::filesystem::path(restartFilename).has_root_path()) { - mThreadParams.localWindowToDomainOffset[i] = 0; - if (mThreadParams.window.globalDimensions.offset[i] > subGrid.getLocalDomain().offset[i]) - { - mThreadParams.localWindowToDomainOffset[i] = - mThreadParams.window.globalDimensions.offset[i] - - subGrid.getLocalDomain().offset[i]; - } + restartFilename = restartDirectory + std::string("/") + restartFilename; } - __getTransactionEvent().waitForFinished(); + std::stringstream strFname; + strFname << restartFilename << "_" << mThreadParams.currentStep << ".bp"; - beginAdios(); + // adios_read_open( fname, method, comm, lock_mode, timeout_sec ) + log ("ADIOS: open file: %1%") % strFname.str(); - writeAdios((void*) &mThreadParams); + // when reading in BG_AGGREGATE mode, adios can not distinguish between + // "file does not exist" and "stream is not (yet) available, so we + // test it our selves + if (!boost::filesystem::exists(strFname.str())) + throw std::runtime_error("ADIOS: File does not exist."); - endAdios(); + /* <0 sec: wait forever + * >=0 sec: return immediately if stream is not available */ + float timeout = 0.0f; + mThreadParams.fp = adios_read_open(strFname.str().c_str(), + ADIOS_READ_METHOD_BP, mThreadParams.adiosComm, + ADIOS_LOCKMODE_CURRENT, timeout); + + /* stream reading is tricky, see ADIOS manual section 8.11.1 */ + while (adios_errno == err_file_not_found) + { + /** \todo add c++11 platform independent sleep */ +#if !defined(_WIN32) + /* give the file system 1s of peace and quiet */ + usleep(1e6); +#endif + mThreadParams.fp = adios_read_open(strFname.str().c_str(), + ADIOS_READ_METHOD_BP, mThreadParams.adiosComm, + ADIOS_LOCKMODE_CURRENT, timeout); + } + if (adios_errno == err_end_of_stream ) + /* could not read full stream */ + throw std::runtime_error("ADIOS: Stream terminated too early: " + + std::string(adios_errmsg()) ); + if (mThreadParams.fp == NULL) + throw std::runtime_error("ADIOS: Error opening stream: " + + std::string(adios_errmsg()) ); + + /* ADIOS types */ + AdiosUInt32Type adiosUInt32Type; + + /* load number of slides to initialize MovingWindow */ + log ("ADIOS: (begin) read attr (%1% available)") % + mThreadParams.fp->nattrs; + void* slidesPtr = NULL; + int slideSize; + enum ADIOS_DATATYPES slidesType; + ADIOS_CMD(adios_get_attr( mThreadParams.fp, + (mThreadParams.adiosBasePath + std::string("sim_slides")).c_str(), + &slidesType, + &slideSize, + &slidesPtr )); + + uint32_t slides = *( (uint32_t*)slidesPtr ); + log ("ADIOS: value of sim_slides = %1%") % + slides; + + assert(slidesType == adiosUInt32Type.type); + assert(slideSize == sizeof(uint32_t)); // uint32_t in bytes + + void* lastStepPtr = NULL; + int lastStepSize; + enum ADIOS_DATATYPES lastStepType; + ADIOS_CMD(adios_get_attr( mThreadParams.fp, + (mThreadParams.adiosBasePath + std::string("iteration")).c_str(), + &lastStepType, + &lastStepSize, + &lastStepPtr )); + uint32_t lastStep = *( (uint32_t*)lastStepPtr ); + log ("ADIOS: value of iteration = %1%") % + lastStep; + + assert(lastStepType == adiosUInt32Type.type); + assert(lastStep == restartStep); + + /* apply slides to set gpus to last/written configuration */ + log ("ADIOS: Setting slide count for moving window to %1%") % slides; + MovingWindow::getInstance().setSlideCounter(slides, restartStep); + + /* re-distribute the local offsets in y-direction */ + GridController &gc = Environment::get().GridController(); + if( MovingWindow::getInstance().isSlidingWindowActive() ) + gc.setStateAfterSlides(slides); + + /* set window for restart, complete global domain */ + mThreadParams.window = MovingWindow::getInstance().getDomainAsWindow(restartStep); + mThreadParams.localWindowToDomainOffset = DataSpace::create(0); + + /* load all fields */ + ForEach > forEachLoadFields; + forEachLoadFields(&mThreadParams); + + /* load all particles */ + ForEach > forEachLoadSpecies; + forEachLoadSpecies(&mThreadParams, restartChunkSize); + + /* free memory allocated in ADIOS calls */ + free(slidesPtr); + free(lastStepPtr); + + /* clean shut down: close file and finalize */ + adios_release_step( mThreadParams.fp ); + ADIOS_CMD(adios_read_close( mThreadParams.fp )); + ADIOS_CMD(adios_read_finalize_method(ADIOS_READ_METHOD_BP)); } private: @@ -476,10 +601,10 @@ class ADIOSWriter : public ILightweightPlugin __deleteArray(mThreadParams.fieldBfr); } - void beginAdios() + void beginAdios(const std::string adiosFilename) { std::stringstream full_filename; - full_filename << filename << "_" << mThreadParams.currentStep << ".bp"; + full_filename << adiosFilename << "_" << mThreadParams.currentStep << ".bp"; mThreadParams.fullFilename = full_filename.str(); mThreadParams.adiosFileHandle = ADIOS_INVALID_HANDLE; @@ -494,29 +619,89 @@ class ADIOSWriter : public ILightweightPlugin ADIOS_CMD(adios_init_noxml(mThreadParams.adiosComm)); } + /** + * Notification for dump or checkpoint received + * + * @param currentStep current simulation step + * @param isCheckpoint checkpoint notification + */ + void notificationReceived(uint32_t currentStep, bool isCheckpoint) + { + const PMacc::Selection& localDomain = Environment::get().SubGrid().getLocalDomain(); + mThreadParams.isCheckpoint = isCheckpoint; + mThreadParams.currentStep = currentStep; + mThreadParams.cellDescription = this->cellDescription; + + __getTransactionEvent().waitForFinished(); + + std::string fname = filename; + if (isCheckpoint) + { + /* if checkpointFilename is relative, prepend with checkpointDirectory */ + if (!boost::filesystem::path(checkpointFilename).has_root_path()) + fname = checkpointDirectory + std::string("/") + checkpointFilename; + else + fname = checkpointFilename; + + mThreadParams.window = MovingWindow::getInstance().getDomainAsWindow(currentStep); + } + else + { + mThreadParams.window = MovingWindow::getInstance().getWindow(currentStep); + } + + for (uint32_t i = 0; i < simDim; ++i) + { + mThreadParams.localWindowToDomainOffset[i] = 0; + if (mThreadParams.window.globalDimensions.offset[i] > localDomain.offset[i]) + { + mThreadParams.localWindowToDomainOffset[i] = + mThreadParams.window.globalDimensions.offset[i] - + localDomain.offset[i]; + } + } + + beginAdios(fname); + + writeAdios((void*) &mThreadParams, mpiTransportParams); + + endAdios(); + } + void pluginLoad() { + GridController &gc = Environment::get().GridController(); + /* It is important that we never change the mpi_pos after this point + * because we get problems with the restart. + * Otherwise we do not know which gpu must load the ghost parts around + * the sliding window. + */ + mpi_pos = gc.getPosition(); + mpi_size = gc.getGpuNodes(); + + /* if number of aggregators is not set we use all mpi process as aggregator*/ + if( mThreadParams.adiosAggregators == 0 ) + mThreadParams.adiosAggregators=mpi_size.productOfComponents(); + if (notifyPeriod > 0) { - GridController &gc = Environment::get().GridController(); - /* It is important that we never change the mpi_pos after this point - * because we get problems with the restart. - * Otherwise we do not know which gpu must load the ghost parts around - * the sliding window. - */ - mpi_pos = gc.getPosition(); - mpi_size = gc.getGpuNodes(); + Environment<>::get().PluginConnector().setNotificationPeriod(this, notifyPeriod); + } - /* if number of aggregators is not set we use all mpi process as aggregator*/ - if( mThreadParams.adiosAggregators == 0 ) - mThreadParams.adiosAggregators=mpi_size.productOfComponents(); + /* Initialize adios library */ + mThreadParams.adiosComm = MPI_COMM_NULL; + MPI_CHECK(MPI_Comm_dup(gc.getCommunicator().getMPIComm(), &(mThreadParams.adiosComm))); + mThreadParams.adiosBufferInitialized = false; - Environment<>::get().PluginConnector().setNotificationPeriod(this, notifyPeriod); + /* select MPI method, #OSTs and #aggregators */ + std::stringstream strMPITransportParams; + strMPITransportParams << "num_aggregators=" << mThreadParams.adiosAggregators + << ";num_ost=" << mThreadParams.adiosOST; + mpiTransportParams = strMPITransportParams.str(); - /* Initialize adios library */ - mThreadParams.adiosComm = MPI_COMM_NULL; - MPI_CHECK(MPI_Comm_dup(gc.getCommunicator().getMPIComm(), &(mThreadParams.adiosComm))); - mThreadParams.adiosBufferInitialized = false; + if (restartFilename == "") + { + restartFilename = checkpointFilename; } loaded = true; @@ -536,7 +721,7 @@ class ADIOSWriter : public ILightweightPlugin static void writeField(ThreadParams *params, const uint32_t sizePtrType, ADIOS_DATATYPES adiosType, const uint32_t nComponents, const std::string name, - std::vector unit, void *ptr) + void *ptr) { log ("ADIOS: write field: %1% %2% %3%") % name % nComponents % ptr; @@ -553,13 +738,18 @@ class ADIOSWriter : public ILightweightPlugin const size_t plane_full_size = field_full[1] * field_full[0] * nComponents; const size_t plane_no_guard_size = field_no_guard[1] * field_no_guard[0]; - /* copy strided data from source to temporary buffer */ - for (int z = 0; z < field_no_guard[2]; ++z) + /* copy strided data from source to temporary buffer + * + * \todo use d1Access as in `include/plugins/hdf5/writer/Field.hpp` + */ + const int maxZ = simDim == DIM3 ? field_no_guard[2] : 1; + const int guardZ = simDim == DIM3 ? field_guard[2] : 0; + for (int z = 0; z < maxZ; ++z) { for (int y = 0; y < field_no_guard[1]; ++y) { const size_t base_index_src = - (z + field_guard[2]) * plane_full_size + + (z + guardZ) * plane_full_size + (y + field_guard[1]) * field_full[0] * nComponents; const size_t base_index_dst = @@ -586,131 +776,100 @@ class ADIOSWriter : public ILightweightPlugin } } - typedef PICToAdios AdiosUInt32Type; - typedef PICToAdios AdiosFloatXType; - typedef PICToAdios AdiosDoubleType; - /** - * Define a single scalar meta attribute + * Write meta attributes + * + * @param threadParams parameters */ - static void defineMetaAttr(ThreadParams *threadParams, const char *name, - enum ADIOS_DATATYPES adiosType) + static void writeMetaAttributes(ThreadParams *threadParams) { - threadParams->adiosMetaAttrVarIds.push_back( - adios_define_var(threadParams->adiosGroupHandle, - (threadParams->adiosBasePath + std::string(name)).c_str(), "", - adiosType, 0, 0, 0)); - } + log ("ADIOS: (begin) write meta attributes."); - /** - * Define meta attributes - */ - static void defineMetaAttributes(ThreadParams *threadParams) - { AdiosUInt32Type adiosUInt32Type; AdiosFloatXType adiosFloatXType; AdiosDoubleType adiosDoubleType; - /* iteration, sim_slides */ - defineMetaAttr(threadParams, "iteration", adiosUInt32Type.type); - defineMetaAttr(threadParams, "sim_slides", adiosUInt32Type.type); - threadParams->adiosGroupSize += 2 * sizeof(uint32_t); - - /* normed grid parameters */ - defineMetaAttr(threadParams, "delta_t", adiosFloatXType.type); - defineMetaAttr(threadParams, "cell_width", adiosFloatXType.type); - defineMetaAttr(threadParams, "cell_height", adiosFloatXType.type); - if (simDim == DIM3) - defineMetaAttr(threadParams, "cell_depth", adiosFloatXType.type); - threadParams->adiosGroupSize += (1 + simDim) * sizeof(float_X); - - /* base units*/ - defineMetaAttr(threadParams, "unit_energy", adiosDoubleType.type); - defineMetaAttr(threadParams, "unit_length", adiosDoubleType.type); - defineMetaAttr(threadParams, "unit_speed", adiosDoubleType.type); - defineMetaAttr(threadParams, "unit_time", adiosDoubleType.type); - defineMetaAttr(threadParams, "unit_mass", adiosDoubleType.type); - defineMetaAttr(threadParams, "unit_charge", adiosDoubleType.type); - defineMetaAttr(threadParams, "unit_efield", adiosDoubleType.type); - defineMetaAttr(threadParams, "unit_bfield", adiosDoubleType.type); - threadParams->adiosGroupSize += 8 * sizeof(double); - - /* physical constants */ - defineMetaAttr(threadParams, "mue0", adiosFloatXType.type); - defineMetaAttr(threadParams, "eps0", adiosFloatXType.type); - threadParams->adiosGroupSize += 2 * sizeof(float_X); - } - - /** - * Write a single scalar meta attribute - */ - static void writeMetaAttr(ThreadParams *threadParams, void *var) - { - int64_t var_id = threadParams->adiosMetaAttrVarIds.back(); - threadParams->adiosMetaAttrVarIds.pop_back(); - - ADIOS_CMD(adios_write_byid(threadParams->adiosFileHandle, var_id, var)); - } - - /** - * Write meta attributes - * Attributes must be written in same order as defined using \see defineMetaAttributes - * - * @param threadParams parameters - */ - static void writeMetaAttributes(ThreadParams *threadParams) - { /* write number of slides to timestep in adios file */ uint32_t slides = MovingWindow::getInstance().getSlideCounter(threadParams->currentStep); - float_X varFloatX; - double varDouble; - /* write current iteration */ - writeMetaAttr(threadParams, &(threadParams->currentStep)); + log ("ADIOS: meta: iteration"); + // In upcoming (>1.8.0) ADIOS version, better use: + // ADIOS_CMD(adios_common_define_attribute_byvalue(threadParams->adiosGroupHandle, + // "iteration", + // threadParams->adiosBasePath.c_str(), + // adiosUInt32Type.type, + // (void*)&threadParams->currentStep )); + + ADIOS_CMD(adios_define_attribute(threadParams->adiosGroupHandle, + "iteration", threadParams->adiosBasePath.c_str(), adiosUInt32Type.type, + int2str(threadParams->currentStep).c_str(), "")); /* write number of slides */ - writeMetaAttr(threadParams, &slides); + log ("ADIOS: meta: sim_slides"); + ADIOS_CMD(adios_define_attribute(threadParams->adiosGroupHandle, + "sim_slides", threadParams->adiosBasePath.c_str(), adiosUInt32Type.type, + int2str(slides).c_str(), "")); /* write normed grid parameters */ - varFloatX = DELTA_T; - writeMetaAttr(threadParams, &varFloatX); - varFloatX = CELL_WIDTH; - writeMetaAttr(threadParams, &varFloatX); - varFloatX = CELL_HEIGHT; - writeMetaAttr(threadParams, &varFloatX); - if (simDim == DIM3) + log ("ADIOS: meta: grid"); + ADIOS_CMD(adios_define_attribute(threadParams->adiosGroupHandle, + "delta_t", threadParams->adiosBasePath.c_str(), adiosFloatXType.type, + flt2str(DELTA_T).c_str(), "")); + ADIOS_CMD(adios_define_attribute(threadParams->adiosGroupHandle, + "cell_width", threadParams->adiosBasePath.c_str(), adiosFloatXType.type, + flt2str(CELL_WIDTH).c_str(), "")); + ADIOS_CMD(adios_define_attribute(threadParams->adiosGroupHandle, + "cell_height", threadParams->adiosBasePath.c_str(), adiosFloatXType.type, + flt2str(CELL_HEIGHT).c_str(), "")); + if( simDim == DIM3 ) { - varFloatX = CELL_DEPTH; - writeMetaAttr(threadParams, &varFloatX); + ADIOS_CMD(adios_define_attribute(threadParams->adiosGroupHandle, + "cell_depth", threadParams->adiosBasePath.c_str(), adiosFloatXType.type, + flt2str(CELL_DEPTH).c_str(), "")); } /* write base units */ - varDouble = UNIT_ENERGY; - writeMetaAttr(threadParams, &varDouble); - varDouble = UNIT_LENGTH; - writeMetaAttr(threadParams, &varDouble); - varDouble = UNIT_SPEED; - writeMetaAttr(threadParams, &varDouble); - varDouble = UNIT_TIME; - writeMetaAttr(threadParams, &varDouble); - varDouble = UNIT_MASS; - writeMetaAttr(threadParams, &varDouble); - varDouble = UNIT_CHARGE; - writeMetaAttr(threadParams, &varDouble); - varDouble = UNIT_EFIELD; - writeMetaAttr(threadParams, &varDouble); - varDouble = UNIT_BFIELD; - writeMetaAttr(threadParams, &varDouble); + log ("ADIOS: meta: units"); + ADIOS_CMD(adios_define_attribute(threadParams->adiosGroupHandle, + "unit_energy", threadParams->adiosBasePath.c_str(), adiosDoubleType.type, + flt2str(UNIT_ENERGY).c_str(), "")); + ADIOS_CMD(adios_define_attribute(threadParams->adiosGroupHandle, + "unit_length", threadParams->adiosBasePath.c_str(), adiosDoubleType.type, + flt2str(UNIT_LENGTH).c_str(), "")); + ADIOS_CMD(adios_define_attribute(threadParams->adiosGroupHandle, + "unit_speed", threadParams->adiosBasePath.c_str(), adiosDoubleType.type, + flt2str(UNIT_SPEED).c_str(), "")); + ADIOS_CMD(adios_define_attribute(threadParams->adiosGroupHandle, + "unit_time", threadParams->adiosBasePath.c_str(), adiosDoubleType.type, + flt2str(UNIT_TIME).c_str(), "")); + ADIOS_CMD(adios_define_attribute(threadParams->adiosGroupHandle, + "unit_mass", threadParams->adiosBasePath.c_str(), adiosDoubleType.type, + flt2str(UNIT_MASS).c_str(), "")); + ADIOS_CMD(adios_define_attribute(threadParams->adiosGroupHandle, + "unit_charge", threadParams->adiosBasePath.c_str(), adiosDoubleType.type, + flt2str(UNIT_CHARGE).c_str(), "")); + ADIOS_CMD(adios_define_attribute(threadParams->adiosGroupHandle, + "unit_efield", threadParams->adiosBasePath.c_str(), adiosDoubleType.type, + flt2str(UNIT_EFIELD).c_str(), "")); + ADIOS_CMD(adios_define_attribute(threadParams->adiosGroupHandle, + "unit_bfield", threadParams->adiosBasePath.c_str(), adiosDoubleType.type, + flt2str(UNIT_BFIELD).c_str(), "")); /* write physical constants */ - varFloatX = MUE0; - writeMetaAttr(threadParams, &varFloatX); - varFloatX = EPS0; - writeMetaAttr(threadParams, &varFloatX); + log ("ADIOS: meta: mue0/eps0"); + + ADIOS_CMD(adios_define_attribute(threadParams->adiosGroupHandle, + "mue0", threadParams->adiosBasePath.c_str(), adiosFloatXType.type, + flt2str(MUE0).c_str(), "")); + ADIOS_CMD(adios_define_attribute(threadParams->adiosGroupHandle, + "eps0", threadParams->adiosBasePath.c_str(), adiosFloatXType.type, + flt2str(EPS0).c_str(), "")); + + log ("ADIOS: ( end ) wite meta attributes."); } - static void *writeAdios(void *p_args) + static void *writeAdios(void *p_args, std::string mpiTransportParams) { // synchronize, because following operations will be blocking anyway @@ -718,7 +877,8 @@ class ADIOSWriter : public ILightweightPlugin threadParams->adiosGroupSize = 0; /* y direction can be negative for first gpu */ - DataSpace particleOffset(Environment::get().SubGrid().getLocalDomain().offset); + const PMacc::Selection& localDomain = Environment::get().SubGrid().getLocalDomain(); + DataSpace particleOffset(localDomain.offset); particleOffset.y() -= threadParams->window.globalDimensions.offset.y(); /* create adios group for fields without statistics */ @@ -728,44 +888,60 @@ class ADIOSWriter : public ILightweightPlugin adios_flag_no)); /* select MPI method, #OSTs and #aggregators */ - std::stringstream mpiTransportParams; - mpiTransportParams << "num_aggregators=" << threadParams->adiosAggregators - << ";num_ost=" << threadParams->adiosOST; - ADIOS_CMD(adios_select_method(threadParams->adiosGroupHandle, "MPI_AGGREGATE", - mpiTransportParams.str().c_str(), "")); + ADIOS_CMD(adios_select_method(threadParams->adiosGroupHandle, + "MPI_AGGREGATE", mpiTransportParams.c_str(), "")); - /* define (sizes for) meta attributes */ - defineMetaAttributes(threadParams); + threadParams->fieldsOffsetDims = precisionCast(localDomain.offset); /* write created variable values */ for (uint32_t d = 0; d < simDim; ++d) { - uint64_t offset = threadParams->window.localDimensions.offset[d]; - /* dimension 1 is y and is the direction of the moving window (if any) */ if (1 == d) - offset = std::max(0, threadParams->window.localDimensions.offset[1] - - threadParams->window.globalDimensions.offset[1]); + { + uint64_t offset = std::max(0, localDomain.offset.y() - + threadParams->window.globalDimensions.offset.y()); + threadParams->fieldsOffsetDims[d] = offset; + } threadParams->fieldsSizeDims[d] = threadParams->window.localDimensions.size[d]; threadParams->fieldsGlobalSizeDims[d] = threadParams->window.globalDimensions.size[d]; - threadParams->fieldsOffsetDims[d] = offset; } /* collect size information for each field to be written and define * field variables */ + log ("ADIOS: (begin) collecting fields."); threadParams->adiosFieldVarIds.clear(); - ForEach > forEachCollectFieldsSizes; - forEachCollectFieldsSizes(threadParams); + if (threadParams->isCheckpoint) + { + ForEach > forEachCollectFieldsSizes; + forEachCollectFieldsSizes(threadParams); + } + else + { + ForEach > forEachCollectFieldsSizes; + forEachCollectFieldsSizes(threadParams); + } + log ("ADIOS: ( end ) collecting fields."); /* collect size information for all attributes of all species and define * particle variables */ threadParams->adiosParticleAttrVarIds.clear(); threadParams->adiosSpeciesIndexVarIds.clear(); - ForEach > adiosCountParticles; - adiosCountParticles(threadParams, std::string()); + log ("ADIOS: (begin) counting particles."); + if (threadParams->isCheckpoint) + { + ForEach > adiosCountParticles; + adiosCountParticles(threadParams, std::string()); + } + else + { + ForEach > adiosCountParticles; + adiosCountParticles(threadParams, std::string()); + } + log ("ADIOS: ( end ) counting particles."); /* allocate buffer in MB according to our current group size */ /* `1 + mem` minimum 1 MiB that we can write attributes on empty GPUs */ @@ -781,25 +957,45 @@ class ADIOSWriter : public ILightweightPlugin threadParams->fullFilename.c_str(), "w", threadParams->adiosComm)); if (threadParams->adiosFileHandle == ADIOS_INVALID_HANDLE) - throw std::runtime_error("Failed to open ADIOS file"); + throw std::runtime_error("ADIOS: Failed to open file."); - /* set adios group size (total size of all data to be written) */ + /* attributes written here are pure meta data */ + writeMetaAttributes(threadParams); + + /* set adios group size (total size of all data to be written) + * besides the number of bytes for variables, this call also + * calculates the overhead of meta data + */ uint64_t adiosTotalSize; ADIOS_CMD(adios_group_size(threadParams->adiosFileHandle, threadParams->adiosGroupSize, &adiosTotalSize)); - writeMetaAttributes(threadParams); - - - /* write fields */ - ForEach > forEachGetFields; - forEachGetFields(threadParams); + log ("ADIOS: (begin) writing fields."); + if (threadParams->isCheckpoint) + { + ForEach > forEachGetFields; + forEachGetFields(threadParams); + } + else + { + ForEach > forEachGetFields; + forEachGetFields(threadParams); + } + log ("ADIOS: ( end ) writing fields."); /* print all particle species */ log ("ADIOS: (begin) writing particle species."); - ForEach > writeSpecies; - writeSpecies(threadParams, particleOffset); + if (threadParams->isCheckpoint) + { + ForEach > writeSpecies; + writeSpecies(threadParams, particleOffset); + } + else + { + ForEach > writeSpecies; + writeSpecies(threadParams, particleOffset); + } log ("ADIOS: ( end ) writing particle species."); /* close adios file, most liekly the actual write point */ @@ -818,6 +1014,14 @@ class ADIOSWriter : public ILightweightPlugin uint32_t notifyPeriod; std::string filename; + std::string checkpointFilename; + std::string restartFilename; + std::string checkpointDirectory; + + /* select MPI method, #OSTs and #aggregators */ + std::string mpiTransportParams; + + uint32_t restartChunkSize; DataSpace mpi_pos; DataSpace mpi_size; diff --git a/src/picongpu/include/plugins/adios/WriteSpecies.hpp b/src/picongpu/include/plugins/adios/WriteSpecies.hpp index 8558e349e4..ef5b6945fd 100644 --- a/src/picongpu/include/plugins/adios/WriteSpecies.hpp +++ b/src/picongpu/include/plugins/adios/WriteSpecies.hpp @@ -1,5 +1,5 @@ /** - * Copyright 2014 Rene Widera, Felix Schmitt + * Copyright 2014-2015 Rene Widera, Felix Schmitt, Axel Huebl * * This file is part of PIConGPU. * @@ -44,6 +44,9 @@ #include "compileTime/conversion/RemoveFromSeq.hpp" #include "particles/ParticleDescription.hpp" +#include "particles/particleFilter/FilterFactory.hpp" +#include "particles/particleFilter/PositionFilter.hpp" + namespace picongpu { @@ -94,38 +97,37 @@ struct WriteSpecies ThisSpecies* speciesTmp = &(dc.getData(ThisSpecies::FrameType::getName(), true)); /* count total number of particles on the device */ - log ("ADIOS: (begin) count particles: %1%") % AdiosFrameType::getName(); + log ("ADIOS: (begin) count particles: %1%") % AdiosFrameType::getName(); uint64_cu totalNumParticles = 0; totalNumParticles = PMacc::CountParticles::countOnDevice < CORE + BORDER > ( *speciesTmp, *(params->cellDescription), params->localWindowToDomainOffset, params->window.localDimensions.size); - log ("ADIOS: ( end ) count particles: %1% = %2%") % AdiosFrameType::getName() % totalNumParticles; - + log ("ADIOS: ( end ) count particles: %1% = %2%") % AdiosFrameType::getName() % totalNumParticles; AdiosFrameType hostFrame; - log ("ADIOS: (begin) malloc mapped memory: %1%") % AdiosFrameType::getName(); + log ("ADIOS: (begin) malloc mapped memory: %1%") % AdiosFrameType::getName(); /* malloc mapped memory */ ForEach > mallocMem; mallocMem(forward(hostFrame), totalNumParticles); - log ("ADIOS: ( end ) malloc mapped memory: %1%") % AdiosFrameType::getName(); + log ("ADIOS: ( end ) malloc mapped memory: %1%") % AdiosFrameType::getName(); if (totalNumParticles > 0) { - log ("ADIOS: (begin) get mapped memory device pointer: %1%") % AdiosFrameType::getName(); + log ("ADIOS: (begin) get mapped memory device pointer: %1%") % AdiosFrameType::getName(); /* load device pointer of mapped memory */ AdiosFrameType deviceFrame; ForEach > getDevicePtr; getDevicePtr(forward(deviceFrame), forward(hostFrame)); - log ("ADIOS: ( end ) get mapped memory device pointer: %1%") % AdiosFrameType::getName(); + log ("ADIOS: ( end ) get mapped memory device pointer: %1%") % AdiosFrameType::getName(); - log ("ADIOS: (begin) copy particle to host: %1%") % AdiosFrameType::getName(); + log ("ADIOS: (begin) copy particle to host: %1%") % AdiosFrameType::getName(); typedef bmpl::vector< typename GetPositionFilter::type > usedFilters; typedef typename FilterFactory::FilterType MyParticleFilter; MyParticleFilter filter; - /* activeate filter pipeline if moving window is activated */ + /* activate filter pipeline if moving window is activated */ filter.setStatus(MovingWindow::getInstance().isSlidingWindowActive()); filter.setWindowPosition(params->localWindowToDomainOffset, params->window.localDimensions.size); @@ -144,9 +146,9 @@ struct WriteSpecies mapper ); counterBuffer.deviceToHost(); - log ("ADIOS: ( end ) copy particle to host: %1%") % AdiosFrameType::getName(); + log ("ADIOS: ( end ) copy particle to host: %1%") % AdiosFrameType::getName(); __getTransactionEvent().waitForFinished(); - log ("ADIOS: all events are finished: %1%") % AdiosFrameType::getName(); + log ("ADIOS: all events are finished: %1%") % AdiosFrameType::getName(); /* this costs a little bit of time but adios writing is slower */ assert((uint64_cu) counterBuffer.getHostBuffer().getDataBox()[0] == totalNumParticles); } @@ -160,7 +162,7 @@ struct WriteSpecies log ("ADIOS: ( end ) writing species: %1%") % AdiosFrameType::getName(); /* write species counter table to adios file */ - log ("ADIOS: (begin) writing particle index table for %1%") % AdiosFrameType::getName(); + log ("ADIOS: (begin) writing particle index table for %1%") % AdiosFrameType::getName(); { GridController& gc = Environment::get().GridController(); @@ -182,7 +184,7 @@ struct WriteSpecies params->adiosSpeciesIndexVarIds.pop_front(); ADIOS_CMD(adios_write_byid(params->adiosFileHandle, adiosIndexVarId, particlesMetaInfo)); } - log ("ADIOS: ( end ) writing particle index table for %1%") % AdiosFrameType::getName(); + log ("ADIOS: ( end ) writing particle index table for %1%") % AdiosFrameType::getName(); } }; diff --git a/src/picongpu/include/plugins/adios/restart/LoadParticleAttributesFromADIOS.hpp b/src/picongpu/include/plugins/adios/restart/LoadParticleAttributesFromADIOS.hpp new file mode 100644 index 0000000000..22a418c179 --- /dev/null +++ b/src/picongpu/include/plugins/adios/restart/LoadParticleAttributesFromADIOS.hpp @@ -0,0 +1,138 @@ +/** + * Copyright 2013-2015 Axel Huebl, Felix Schmitt, Rene Widera + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + + + +#pragma once + + +#include "types.h" +#include "simulation_types.hpp" +#include "plugins/adios/ADIOSWriter.def" +#include "traits/GetComponentsType.hpp" +#include "traits/GetNComponents.hpp" +#include "traits/Resolve.hpp" + + +namespace picongpu +{ + +namespace adios +{ +using namespace PMacc; + +/** Load attribute of a species from ADIOS checkpoint file + * + * @tparam T_Identifier identifier of species attribute + */ +template< typename T_Identifier> +struct LoadParticleAttributesFromADIOS +{ + + /** read attributes from ADIOS file + * + * @param params thread params with ADIOS_FILE, ... + * @param frame frame with all particles + * @param particlePath path to the group in the ADIOS file + * @param particlesOffset read offset in the attribute array + * @param elements number of elements which should be read the attribute array + */ + template + HINLINE void operator()( + ThreadParams* params, + FrameType& frame, + const std::string particlePath, + const uint64_t particlesOffset, + const uint64_t elements) + { + + typedef T_Identifier Identifier; + typedef typename PMacc::traits::Resolve::type::type ValueType; + const uint32_t components = GetNComponents::value; + typedef typename GetComponentsType::type ComponentType; + + log ("ADIOS: ( begin ) load species attribute: %1%") % Identifier::getName(); + + const std::string name_lookup[] = {"x", "y", "z"}; + + ComponentType* tmpArray = NULL; + if( elements > 0 ) + tmpArray = new ComponentType[elements]; + + // dev assert! + if( elements > 0 ) + assert(tmpArray); + + for (uint32_t n = 0; n < components; ++n) + { + std::stringstream datasetName; + datasetName << particlePath << T_Identifier::getName(); + if (components > 1) + datasetName << "/" << name_lookup[n]; + + ValueType* dataPtr = frame.getIdentifier(Identifier()).getPointer(); + + ADIOS_VARINFO* varInfo = adios_inq_var( params->fp, datasetName.str().c_str() ); + // it's possible to aquire the local block with that call again and + // the local elements to-be-read, but the block-ID must be known (MPI rank?) + //ADIOS_CMD(adios_inq_var_blockinfo( params->fp, varInfo )); + + ADIOS_SELECTION* sel = adios_selection_boundingbox( 1, &particlesOffset, &elements ); + + /** work-around for ADIOS 1.8.0 bug: zero-reads fail for compressed (zlib) data sets, + * so we skip the schedule read for this rank. + * Note: adios_schedule_read is not a collective call */ + if( elements > 0 ) + { + ADIOS_CMD(adios_schedule_read( params->fp, + sel, + datasetName.str().c_str(), + 0, /* from_step (not used in streams) */ + 1, /* nsteps to read (must be 1 for stream) */ + (void*)tmpArray )); + } + + /* start a blocking read of all scheduled variables */ + ADIOS_CMD(adios_perform_reads( params->fp, 1 )); + + log ("ADIOS: Did read %1% local of %2% global elements for %3%") % + elements % varInfo->dims[0] % datasetName.str(); + + /* copy component from temporary array to array of structs */ + for (size_t i = 0; i < elements; ++i) + { + ComponentType& ref = ((ComponentType*) dataPtr)[i * components + n]; + ref = tmpArray[i]; + } + + adios_selection_delete( sel ); + adios_free_varinfo( varInfo ); + } + __deleteArray(tmpArray); + + log ("ADIOS: ( end ) load species attribute: %1%") % + Identifier::getName(); + } + +}; + +} /* namespace adios */ + +} /* namespace picongpu */ diff --git a/src/picongpu/include/plugins/adios/restart/LoadSpecies.hpp b/src/picongpu/include/plugins/adios/restart/LoadSpecies.hpp new file mode 100644 index 0000000000..79ebf96af6 --- /dev/null +++ b/src/picongpu/include/plugins/adios/restart/LoadSpecies.hpp @@ -0,0 +1,225 @@ +/** + * Copyright 2013-2015 Rene Widera, Felix Schmitt, Axel Huebl + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + +#pragma once + +#include "simulation_types.hpp" + +#include "plugins/adios/ADIOSWriter.def" +#include "plugins/ISimulationPlugin.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "compileTime/conversion/MakeSeq.hpp" +#include "compileTime/conversion/RemoveFromSeq.hpp" +#include "mappings/kernel/AreaMapping.hpp" +#include "particles/ParticleDescription.hpp" + +#include "plugins/output/WriteSpeciesCommon.hpp" +#include "plugins/kernel/CopySpeciesGlobal2Local.kernel" +#include "plugins/adios/restart/LoadParticleAttributesFromADIOS.hpp" + +namespace picongpu +{ + +namespace adios +{ +using namespace PMacc; + +/** Load species from ADIOS checkpoint file + * + * @tparam T_Species type of species + * + */ +template< typename T_Species > +struct LoadSpecies +{ +public: + + typedef T_Species ThisSpecies; + typedef typename ThisSpecies::FrameType FrameType; + typedef typename FrameType::ParticleDescription ParticleDescription; + typedef typename FrameType::ValueTypeSeq ParticleAttributeList; + + + /* delete multiMask and localCellIdx in adios particle*/ + typedef bmpl::vector2 TypesToDelete; + typedef typename RemoveFromSeq::type ParticleCleanedAttributeList; + + /* add globalCellIdx for adios particle*/ + typedef typename MakeSeq< + ParticleCleanedAttributeList, + globalCellIdx + >::type ParticleNewAttributeList; + + typedef + typename ReplaceValueTypeSeq::type + NewParticleDescription; + + typedef Frame AdiosFrameType; + + /** Load species from ADIOS checkpoint file + * + * @param params thread params with ADIOS_FILE, ... + * @param restartChunkSize number of particles processed in one kernel call + */ + HINLINE void operator()(ThreadParams* params, const uint32_t restartChunkSize) + { + + log ("ADIOS: (begin) load species: %1%") % AdiosFrameType::getName(); + DataConnector &dc = Environment<>::get().DataConnector(); + GridController &gc = Environment::get().GridController(); + + std::string particlePath = params->adiosBasePath + std::string(ADIOS_PATH_PARTICLES) + + FrameType::getName() + std::string("/"); + const PMacc::Selection& localDomain = Environment::get().SubGrid().getLocalDomain(); + + /* load particle without copying particle data to host */ + ThisSpecies* speciesTmp = &(dc.getData(ThisSpecies::FrameType::getName(), true)); + + /* count total number of particles on the device */ + uint64_cu totalNumParticles = 0; + + /* load particles info table entry for this process + particlesInfo is (part-count, scalar pos, x, y, z) */ + typedef uint64_t uint64Quint[5]; + uint64Quint particlesInfo[gc.getGlobalSize()]; + + /* read full data set: putting NULL (== full data set) for `piSel` crashed ADIOS 1.8.0 + * with transforms enabled -> reported and confirmed as a bug in ADIOS 1.8.0 */ + uint64_t start = 0; + uint64_t count = 5 * gc.getGlobalSize(); // ADIOSCountParticles: uint64_t + ADIOS_SELECTION* piSel = adios_selection_boundingbox( 1, &start, &count ); + + ADIOS_CMD(adios_schedule_read( params->fp, + piSel, + (particlePath + std::string("particles_info")).c_str(), + 0, + 1, + (void*)particlesInfo )); + + /* start a blocking read of all scheduled variables */ + ADIOS_CMD(adios_perform_reads( params->fp, 1 )); + adios_selection_delete(piSel); + + /* search my entry (using my scalar position) in particlesInfo */ + uint64_t particleOffset = 0; + uint64_t myScalarPos = gc.getScalarPosition(); + + for (size_t i = 0; i < gc.getGlobalSize(); ++i) + { + if (particlesInfo[i][1] == myScalarPos) + { + totalNumParticles = particlesInfo[i][0]; + break; + } + + particleOffset += particlesInfo[i][0]; + } + + log ("ADIOS: Loading %1% particles from offset %2%") % + (long long unsigned) totalNumParticles % (long long unsigned) particleOffset; + + AdiosFrameType hostFrame; + log ("ADIOS: malloc mapped memory: %1%") % AdiosFrameType::getName(); + /*malloc mapped memory*/ + ForEach > mallocMem; + mallocMem(forward(hostFrame), totalNumParticles); + + log ("ADIOS: get mapped memory device pointer: %1%") % AdiosFrameType::getName(); + /*load device pointer of mapped memory*/ + AdiosFrameType deviceFrame; + ForEach > getDevicePtr; + getDevicePtr(forward(deviceFrame), forward(hostFrame)); + + ForEach > loadAttributes; + loadAttributes(forward(params), forward(hostFrame), particlePath, particleOffset, totalNumParticles); + + if (totalNumParticles != 0) + { + dim3 block(PMacc::math::CT::volume::type::value); + + /* counter is used to apply for work, count used frames and count loaded particles + * [0] -> offset for loading particles + * [1] -> number of loaded particles + * [2] -> number of used frames + * + * all values are zero after initialization + */ + GridBuffer counterBuffer(DataSpace(3)); + + const uint32_t cellsInSuperCell = PMacc::math::CT::volume::type::value; + + const uint32_t iterationsForLoad = ceil(double(totalNumParticles) / double(restartChunkSize)); + uint32_t leftOverParticles = totalNumParticles; + + __startAtomicTransaction(__getTransactionEvent()); + + for (uint32_t i = 0; i < iterationsForLoad; ++i) + { + /* only load a chunk of particles per iteration to avoid blow up of frame usage + */ + uint32_t currentChunkSize = std::min(leftOverParticles, restartChunkSize); + log ("ADIOS: load particles on device chunk offset=%1%; chunk size=%2%; left particles %3%") % + (i * restartChunkSize) % currentChunkSize % leftOverParticles; + __cudaKernel(copySpeciesGlobal2Local) + (ceil(double(currentChunkSize) / double(cellsInSuperCell)), cellsInSuperCell) + (counterBuffer.getDeviceBuffer().getDataBox(), + speciesTmp->getDeviceParticlesBox(), deviceFrame, + (int) totalNumParticles, + localDomain.offset, /*relative to data domain (not to physical domain)*/ + *(params->cellDescription) + ); + speciesTmp->fillAllGaps(); + leftOverParticles -= currentChunkSize; + } + __setTransactionEvent(__endTransaction()); + counterBuffer.deviceToHost(); + log ("ADIOS: wait for last processed chunk: %1%") % AdiosFrameType::getName(); + __getTransactionEvent().waitForFinished(); + + log ("ADIOS: used frames to load particles: %1%") % counterBuffer.getHostBuffer().getDataBox()[2]; + + if ((uint64_cu) counterBuffer.getHostBuffer().getDataBox()[1] != totalNumParticles) + { + log("ADIOS: error load species | counter is %1% but should %2%") % counterBuffer.getHostBuffer().getDataBox()[1] % totalNumParticles; + throw std::runtime_error("ADIOS: Failed to load expected number of particles to GPU."); + } + assert((uint64_cu) counterBuffer.getHostBuffer().getDataBox()[1] == totalNumParticles); + + /*free host memory*/ + ForEach > freeMem; + freeMem(forward(hostFrame)); + log ("ADIOS: ( end ) load species: %1%") % AdiosFrameType::getName(); + } + } +}; + + +} /* namespace adios */ + +} /* namespace picongpu */ diff --git a/src/picongpu/include/plugins/adios/restart/RestartFieldLoader.hpp b/src/picongpu/include/plugins/adios/restart/RestartFieldLoader.hpp new file mode 100644 index 0000000000..cd6d3f86c8 --- /dev/null +++ b/src/picongpu/include/plugins/adios/restart/RestartFieldLoader.hpp @@ -0,0 +1,172 @@ +/** + * Copyright 2014-2015 Axel Huebl, Felix Schmitt, Heiko Burau, Rene Widera + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + +#pragma once + +#include +#include +#include + +#include +#include + +#include "types.h" +#include "simulation_defines.hpp" +#include "plugins/adios/ADIOSWriter.def" + +#include "particles/frame_types.hpp" +#include "dataManagement/DataConnector.hpp" +#include "dimensions/DataSpace.hpp" +#include "dimensions/GridLayout.hpp" +#include "simulationControl/MovingWindow.hpp" + +namespace picongpu +{ + +namespace adios +{ + +/** + * Helper class for ADIOS plugin to load fields from parallel ADIOS BP files. + */ +class RestartFieldLoader +{ +public: + template + static void loadField(Data& field, const uint32_t numComponents, std::string objectName, ThreadParams *params) + { + log ("Begin loading field '%1%'") % objectName; + + const std::string name_lookup_tpl[] = {"x", "y", "z", "w"}; + const DataSpace field_guard = field.getGridLayout().getGuard(); + + const PMacc::Selection& localDomain = Environment::get().SubGrid().getLocalDomain(); + + field.getHostBuffer().setValue(float3_X::create(0.0)); + + DataSpace domain_offset = localDomain.offset; + + DataSpace local_domain_size = params->window.localDimensions.size; + + PMACC_AUTO(destBox, field.getHostBuffer().getDataBox()); + for (uint32_t n = 0; n < numComponents; ++n) + { + // Read the subdomain which belongs to our mpi position. + // The total grid size must match the grid size of the stored data. + log ("ADIOS: Read from domain: offset=%1% size=%2%") % + domain_offset % local_domain_size; + + std::stringstream datasetName; + datasetName << params->adiosBasePath << ADIOS_PATH_FIELDS << objectName; + if (numComponents > 1) + datasetName << "/" << name_lookup_tpl[n]; + + log ("ADIOS: Read from field '%1%'") % + datasetName.str(); + + ADIOS_VARINFO* varInfo = adios_inq_var( params->fp, datasetName.str().c_str() ); + uint64_t start[varInfo->ndim]; + uint64_t count[varInfo->ndim]; + for(int d = 0; d < varInfo->ndim; ++d) + { + /* \see adios_define_var: z,y,x in C-order */ + start[d] = domain_offset.revert()[d]; + count[d] = local_domain_size.revert()[d]; + } + + ADIOS_SELECTION* fSel = adios_selection_boundingbox( varInfo->ndim, start, count ); + + /* specify what we want to read, but start reading at below at + * `adios_perform_reads` */ + log ("ADIOS: Allocate %1% elements") % + local_domain_size.productOfComponents(); + + /// \todo float_X should be some kind of gridBuffer's GetComponentsType::type + float_X* field_container = new float_X[local_domain_size.productOfComponents()]; + /* magic parameters (0, 1): `from_step` (not used in streams), `nsteps` to read (must be 1 for stream) */ + ADIOS_CMD(adios_schedule_read( params->fp, fSel, datasetName.str().c_str(), 0, 1, (void*)field_container )); + + /* start a blocking read of all scheduled variables */ + ADIOS_CMD(adios_perform_reads( params->fp, 1 )); + + int elementCount = params->window.localDimensions.size.productOfComponents(); + + for (int linearId = 0; linearId < elementCount; ++linearId) + { + /* calculate index inside the moving window domain which is located on the local grid*/ + DataSpace destIdx = DataSpaceOperations::map(params->window.localDimensions.size, linearId); + /* jump over guard and local sliding window offset*/ + destIdx += field_guard + params->localWindowToDomainOffset; + + destBox(destIdx)[n] = field_container[linearId]; + } + + __deleteArray(field_container); + adios_selection_delete(fSel); + adios_free_varinfo(varInfo); + } + + field.hostToDevice(); + + __getTransactionEvent().waitForFinished(); + + log ("ADIOS: Read from domain: offset=%1% size=%2%") % + domain_offset % local_domain_size; + log ("ADIOS: Finished loading field '%1%'") % objectName; + } + +}; + +/** + * Hepler class for ADIOSWriter (forEach operator) to load a field from ADIOS + * + * @tparam FieldType field class to load + */ +template< typename FieldType > +struct LoadFields +{ +public: + + HDINLINE void operator()(ThreadParams* params) + { +#ifndef __CUDA_ARCH__ + DataConnector &dc = Environment<>::get().DataConnector(); + ThreadParams *tp = params; + + /* load field without copying data to host */ + FieldType* field = &(dc.getData (FieldType::getName(), true)); + + /* load from ADIOS */ + RestartFieldLoader::loadField( + field->getGridBuffer(), + (uint32_t)FieldType::numComponents, + FieldType::getName(), + tp); + + dc.releaseData(FieldType::getName()); +#endif + } + +}; + +using namespace PMacc; + +} /* namespace adios */ +} /* namespace picongpu */ diff --git a/src/picongpu/include/plugins/adios/writer/ParticleAttribute.hpp b/src/picongpu/include/plugins/adios/writer/ParticleAttribute.hpp index 4dc6ef6c55..bd6d38fd17 100644 --- a/src/picongpu/include/plugins/adios/writer/ParticleAttribute.hpp +++ b/src/picongpu/include/plugins/adios/writer/ParticleAttribute.hpp @@ -23,7 +23,6 @@ #include "types.h" #include "simulation_types.hpp" #include "plugins/adios/ADIOSWriter.def" -#include "traits/PICToAdios.hpp" #include "traits/GetComponentsType.hpp" #include "traits/GetNComponents.hpp" #include "traits/Resolve.hpp" @@ -79,7 +78,12 @@ struct ParticleAttribute int64_t adiosAttributeVarId = *(params->adiosParticleAttrVarIds.begin()); params->adiosParticleAttrVarIds.pop_front(); - ADIOS_CMD(adios_write_byid(params->adiosFileHandle, adiosAttributeVarId, tmpBfr)); + + /** We skip this part due to a bug in ADIOS 1.8.0 where + * read with *compressed* data sets fail on zero-size data sets. + * Note: adios_write commands are not collective (for most methods, except the PHDF5 transport) */ + if (elements > 0) + ADIOS_CMD(adios_write_byid(params->adiosFileHandle, adiosAttributeVarId, tmpBfr)); } __deleteArray(tmpBfr); diff --git a/src/picongpu/include/plugins/adios/writer/ParticleAttributeSize.hpp b/src/picongpu/include/plugins/adios/writer/ParticleAttributeSize.hpp index e73c902944..f2e10dc606 100644 --- a/src/picongpu/include/plugins/adios/writer/ParticleAttributeSize.hpp +++ b/src/picongpu/include/plugins/adios/writer/ParticleAttributeSize.hpp @@ -70,6 +70,8 @@ struct ParticleAttributeSize AdiosType adiosType; const std::string name_lookup[] = {"x", "y", "z"}; + std::vector unit = Unit::get(); + for (uint32_t d = 0; d < components; d++) { std::stringstream datasetName; @@ -91,6 +93,16 @@ struct ParticleAttributeSize params->adiosCompression); params->adiosParticleAttrVarIds.push_back(adiosParticleAttrId); + + /* already add the sim_unit attribute so `adios_group_size` calculates + * the reservation for the buffer correctly */ + AdiosDoubleType adiosDoubleType; + + /* check if this attribute actually has a unit (unit.size() == 0 is no unit) */ + if (unit.size() >= (d + 1)) + ADIOS_CMD(adios_define_attribute(params->adiosGroupHandle, + "sim_unit", datasetName.str().c_str(), adiosDoubleType.type, + flt2str(unit.at(d)).c_str(), "")); } diff --git a/src/picongpu/include/plugins/hdf5/HDF5Writer.hpp b/src/picongpu/include/plugins/hdf5/HDF5Writer.hpp index f3c8e4a4bb..3231606f9e 100644 --- a/src/picongpu/include/plugins/hdf5/HDF5Writer.hpp +++ b/src/picongpu/include/plugins/hdf5/HDF5Writer.hpp @@ -1,5 +1,5 @@ /** - * Copyright 2013-2014 Axel Huebl, Felix Schmitt, Heiko Burau, Rene Widera + * Copyright 2013-2015 Axel Huebl, Felix Schmitt, Heiko Burau, Rene Widera * * This file is part of PIConGPU. * @@ -143,13 +143,20 @@ class HDF5Writer : public ISimulationPlugin void checkpoint(uint32_t currentStep, const std::string checkpointDirectory) { +#if(ENABLE_ADIOS == 1) + log ("HDF5: Checkpoint skipped since ADIOS is enabled."); +#else this->checkpointDirectory = checkpointDirectory; notificationReceived(currentStep, true); +#endif } void restart(uint32_t restartStep, const std::string restartDirectory) { +#if(ENABLE_ADIOS == 1) + log ("HDF5: Restart skipped since ADIOS is enabled."); +#else const uint32_t maxOpenFilesPerNode = 4; GridController &gc = Environment::get().GridController(); mThreadParams.dataCollector = new ParallelDomainCollector( @@ -221,6 +228,7 @@ class HDF5Writer : public ISimulationPlugin mThreadParams.dataCollector->finalize(); __delete(mThreadParams.dataCollector); +#endif } private: diff --git a/src/picongpu/include/plugins/hdf5/WriteFields.hpp b/src/picongpu/include/plugins/hdf5/WriteFields.hpp index b53f425cc9..209fa47ed2 100644 --- a/src/picongpu/include/plugins/hdf5/WriteFields.hpp +++ b/src/picongpu/include/plugins/hdf5/WriteFields.hpp @@ -152,7 +152,7 @@ class WriteFields > /*load particle without copy particle data to host*/ Species* speciesTmp = &(dc.getData(Species::FrameType::getName(), true)); - fieldTmp->getGridBuffer().getDeviceBuffer().setValue(ValueType(0.0)); + fieldTmp->getGridBuffer().getDeviceBuffer().setValue(ValueType::create(0.0)); /*run algorithm*/ fieldTmp->computeValue < CORE + BORDER, Solver > (*speciesTmp, params->currentStep); diff --git a/src/picongpu/include/plugins/hdf5/restart/RestartFieldLoader.hpp b/src/picongpu/include/plugins/hdf5/restart/RestartFieldLoader.hpp index 0f4afa6759..51ee6b49a1 100644 --- a/src/picongpu/include/plugins/hdf5/restart/RestartFieldLoader.hpp +++ b/src/picongpu/include/plugins/hdf5/restart/RestartFieldLoader.hpp @@ -55,7 +55,7 @@ class RestartFieldLoader const uint32_t numSlides = MovingWindow::getInstance().getSlideCounter(params->currentStep); const PMacc::Selection& localDomain = Environment::get().SubGrid().getLocalDomain(); - field.getHostBuffer().setValue(float3_X(0.)); + field.getHostBuffer().setValue(float3_X::create(0.0)); const std::string name_lookup[] = {"x", "y", "z"}; diff --git a/src/picongpu/include/plugins/makroParticleCounter/PerSuperCell.hpp b/src/picongpu/include/plugins/makroParticleCounter/PerSuperCell.hpp index ae4a5b2ca5..f45d5fc1cd 100644 --- a/src/picongpu/include/plugins/makroParticleCounter/PerSuperCell.hpp +++ b/src/picongpu/include/plugins/makroParticleCounter/PerSuperCell.hpp @@ -133,10 +133,10 @@ class PerSuperCell : public ILightweightPlugin public: - PerSuperCell(std::string name, std::string prefix) : - analyzerName(name), - analyzerPrefix(prefix), - foldername(name), + PerSuperCell() : + analyzerName("PerSuperCell: create hdf5 with macro particle count per superCell"), + analyzerPrefix(ParticlesType::FrameType::getName() + std::string("_macroParticlesPerSuperCell")), + foldername(analyzerPrefix), particles(NULL), cellDescription(NULL), notifyFrequency(0), diff --git a/src/picongpu/include/plugins/output/images/DensityToBinary.hpp b/src/picongpu/include/plugins/output/images/DensityToBinary.hpp deleted file mode 100644 index e6f3e2d06d..0000000000 --- a/src/picongpu/include/plugins/output/images/DensityToBinary.hpp +++ /dev/null @@ -1,137 +0,0 @@ -/** - * Copyright 2013 Axel Huebl, Heiko Burau, Rene Widera - * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ - - - -#ifndef DENSITYTOBINARY_HPP -#define DENSITYTOBINARY_HPP - -#include "types.h" -#include "simulation_defines.hpp" -#include "simulation_types.hpp" - -#include -#include -#include "mappings/simulation/GridController.hpp" - -#include -#include -#include - -//c includes -#include "sys/stat.h" - -namespace picongpu -{ -using namespace PMacc; - -struct DensityToBinary -{ - typedef float_64 ValueType; - - DensityToBinary(std::string name, std::string folder) : name(folder + "/" + name), folder(folder), createFolder(true) - { - } - - ~DensityToBinary() - { - } - - template - void operator()( - const Box data, - const ValueType unit, - const Size2D size, - const MessageHeader & header) - { - - if (createFolder) - { - Environment::get().Filesystem().createDirectoryWithPermissions(folder); - createFolder = false; - } - - std::stringstream step; - step << std::setw(6) << std::setfill('0') << header.sim.step; - //std::string filename(name + "_" + step.str() + ".bin"); - std::string filename(name + "_" + step.str() + ".dat"); - - double x_cell = header.sim.cellSizeArr[0]; - double y_cell = header.sim.cellSizeArr[1]; - - double x_simOff = header.sim.simOffsetToNull[0]; - double y_simOff = header.sim.simOffsetToNull[1]; - - DataSpace gOffset = header.window.offset; - - std::ofstream file(filename.c_str(), std::ofstream::out); //| std::ofstream::binary); - - typedef std::numeric_limits< ValueType > dbl; - file.precision(dbl::digits10); - file << std::scientific; - - ValueType sizex = (int) size.x(); - //file.write((char*) (&sizex), sizeof (ValueType)); - file << sizex << " "; - - //first line with y header information - for (int x = 0; x < size.x(); ++x) - { - ValueType cellPos = (ValueType) ((x + x_simOff + gOffset.x()) * x_cell * UNIT_LENGTH); - //file.write((char*) &(cellPos), sizeof (ValueType)); - file << cellPos << " "; - } - file << std::endl; - - //the first column is for x header information - for (int y = 0; y < size.y(); ++y) - { - const ValueType cellPos = (ValueType) ((y + y_simOff + gOffset.y()) * y_cell * UNIT_LENGTH); - file << cellPos; - for (int x = 0; x < size.x(); ++x) - { - const ValueType value = precisionCast(data[y][x]) * unit; - - /** \info take care, that gnuplots binary matrix does - * not support float64 (IEEE float32 only) - * \see http://stackoverflow.com/questions/8751154/looking-at-binary-output-from-fortran-on-gnuplot - * http://gnuplot.sourceforge.net/docs_4.2/node101.html - */ - //file.write((char*) &(value), sizeof (ValueType)); - file << " " << value; - } - file << std::endl; - } - - file.close(); - } - -private: - - std::string name; - std::string folder; - bool createFolder; - -}; - -}//namespace - -#endif /* DENSITYTOBINARY_HPP */ - diff --git a/src/picongpu/include/plugins/output/images/ParticleDensity.hpp b/src/picongpu/include/plugins/output/images/ParticleDensity.hpp deleted file mode 100644 index 891d2e2b54..0000000000 --- a/src/picongpu/include/plugins/output/images/ParticleDensity.hpp +++ /dev/null @@ -1,356 +0,0 @@ -/** - * Copyright 2013-2014 Axel Huebl, Heiko Burau, Rene Widera, Felix Schmitt - * - * This file is part of PIConGPU. - * - * PIConGPU is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PIConGPU is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PIConGPU. - * If not, see . - */ - - - -#pragma once - -#include "simulation_defines.hpp" -#include "types.h" - -#include "dimensions/DataSpace.hpp" -#include "dimensions/DataSpaceOperations.hpp" - -#include "memory/buffers/GridBuffer.hpp" - -#include "particles/memory/boxes/ParticlesBox.hpp" - -#include "dataManagement/DataConnector.hpp" -#include "math/Vector.hpp" - -#include "memory/boxes/DataBox.hpp" -#include "memory/boxes/SharedBox.hpp" -#include "memory/boxes/PitchedBox.hpp" -#include "memory/buffers/GridBuffer.hpp" - -#include "simulationControl/MovingWindow.hpp" - -#include "mappings/kernel/MappingDescription.hpp" -//c includes -#include "sys/stat.h" -#include "mappings/simulation/GridController.hpp" - -#include -#include "memory/boxes/PitchedBox.hpp" -#include "plugins/output/header/MessageHeader.hpp" -#include "plugins/output/GatherSlice.hpp" -#include "plugins/ILightweightPlugin.hpp" - -namespace picongpu -{ -using namespace PMacc; - -template -__global__ void -kernelParticleDensity(ParBox pb, - DataBox > image, - DataSpace transpose, - int slice, - uint32_t globalOffset, - uint32_t sliceDim, - Mapping mapper) -{ - typedef typename ParBox::FrameType FRAME; - typedef typename MappingDesc::SuperCellSize Block; - __shared__ FRAME *frame; - __shared__ bool isValid; - __syncthreads(); /*wait that all shared memory is initialised*/ - - bool isImageThread = false; - - const DataSpace threadId(threadIdx); - const DataSpace localCell(threadId[transpose.x()], threadId[transpose.y()]); - const DataSpace block = mapper.getSuperCellIndex(DataSpace (blockIdx)); - const DataSpace blockOffset((block - 1) * Block::toRT()); - - - int localId = threadIdx.z * Block::x::value * Block::y::value + threadIdx.y * Block::x::value + threadIdx.x; - - - if (localId == 0) - isValid = false; - __syncthreads(); - - //\todo: guard size should not be set to (fixed) 1 here - const DataSpace realCell(blockOffset + threadId); //delete guard from cell idx - -#if(SIMDIM==DIM3) - uint32_t globalCell = realCell[sliceDim] + globalOffset; - - if (globalCell == slice) -#endif - { - isValid = true; - isImageThread = true; - } - __syncthreads(); - - if (!isValid) - return; - - /*index in image*/ - DataSpace imageCell( - realCell[transpose.x()], - realCell[transpose.y()]); - - - // counter is always DIM2 - typedef DataBox < PitchedBox< float_X, DIM2 > > SharedMem; - extern __shared__ float_X shBlock[]; - __syncthreads(); /*wait that all shared memory is initialised*/ - - const DataSpace blockSize(blockDim); - SharedMem counter(PitchedBox ((float_X*) shBlock, - DataSpace (), - blockSize[transpose.x()] * sizeof (float_X))); - - if (isImageThread) - { - counter(localCell) = float_X(0.0); - } - - - if (localId == 0) - { - frame = &(pb.getFirstFrame(block, isValid)); - } - __syncthreads(); - - while (isValid) //move over all Frames - { - PMACC_AUTO(particle, (*frame)[localId]); - if (particle[multiMask_] == 1) - { - int cellIdx = particle[localCellIdx_]; - // we only draw the first slice of cells in the super cell (z == 0) - const DataSpace particleCellId(DataSpaceOperations::template map (cellIdx)); -#if(SIMDIM==DIM3) - uint32_t globalParticleCell = particleCellId[sliceDim] + globalOffset + blockOffset[sliceDim]; - if (globalParticleCell == slice) -#endif - { - const DataSpace reducedCell(particleCellId[transpose.x()], particleCellId[transpose.y()]); - atomicAddWrapper(&(counter(reducedCell)), particle[weighting_] / particles::TYPICAL_NUM_PARTICLES_PER_MACROPARTICLE); - } - } - __syncthreads(); - - if (localId == 0) - { - frame = &(pb.getNextFrame(*frame, isValid)); - } - __syncthreads(); - } - - - if (isImageThread) - { - image(imageCell) = (Type_) counter(localCell); - } -} - -/** - * Visualizes simulation data by writing png files. - * Visulization is performed in an additional thread. - */ -template -class ParticleDensity : public ILightweightPlugin -{ -private: - typedef MappingDesc::SuperCellSize SuperCellSize; - -public: - - typedef Output CreatorType; - - ParticleDensity(std::string name, Output output, uint32_t notifyFrequency, DataSpace transpose, float_X slicePoint) : - output(output), - analyzerName(name), - cellDescription(NULL), - particleTag(ParticlesType::FrameType::getName()), - notifyFrequency(notifyFrequency), - transpose(transpose), - slicePoint(slicePoint), - header(NULL), - isMaster(false) - { - sliceDim = 0; - if (transpose.x() == 0 || transpose.y() == 0) - sliceDim = 1; - if ((transpose.x() == 1 || transpose.y() == 1) && sliceDim == 1) - sliceDim = 2; - - Environment<>::get().PluginConnector().registerPlugin(this); - Environment<>::get().PluginConnector().setNotificationPeriod(this, notifyFrequency); - } - - virtual ~ParticleDensity() - { - if (notifyFrequency > 0) - { - __delete(img); - MessageHeader::destroy(header); - } - } - - void notify(uint32_t currentStep) - { - const DataSpace localSize(cellDescription->getGridLayout().getDataSpaceWithoutGuarding()); - Window window(MovingWindow::getInstance().getWindow(currentStep)); - - /*sliceOffset is only used in 3D*/ - sliceOffset = (int) ((float) (window.globalDimensions.size[sliceDim]) * slicePoint) + - window.globalDimensions.offset[sliceDim]; - - if (!doDrawing()) - { - return; - } - createImage(currentStep, window); - } - - void pluginRegisterHelp(po::options_description&) - { - // nothing to do here - } - - std::string pluginGetName() const - { - return "ParticleDensity"; - } - - void setMappingDescription(MappingDesc *cellDescription) - { - this->cellDescription = cellDescription; - } - - void createImage(uint32_t currentStep, Window window) - { - DataConnector &dc = Environment<>::get().DataConnector(); - ParticlesType* particles = &(dc.getData (particleTag, true)); - - typedef MappingDesc::SuperCellSize SuperCellSize; - - DataSpace blockSize(MappingDesc::SuperCellSize::toRT()); - DataSpace blockSize2D(blockSize[transpose.x()], blockSize[transpose.y()]); - - uint32_t globalOffset = 0; -#if(SIMDIM==DIM3) - globalOffset = Environment::get().SubGrid().getLocalDomain().offset[sliceDim]; -#endif - - - //create density image of particles - __picKernelArea((kernelParticleDensity), *cellDescription, CORE + BORDER) - (SuperCellSize::toRT().toDim3(), blockSize2D.productOfComponents() * sizeof (float_X)) - (particles->getDeviceParticlesBox(), - img->getDeviceBuffer().getDataBox(), - transpose, - sliceOffset, - globalOffset, sliceDim - ); - - - img->deviceToHost(); - - header->update(*cellDescription, window, transpose, currentStep); - - __getTransactionEvent().waitForFinished(); //wait for copy picture - - PMACC_AUTO(hostBox, img->getHostBuffer().getDataBox()); - - PMACC_AUTO(resultBox, gather(hostBox, *header)); - - // units - const float_64 cellVolume = CELL_VOLUME; - float_64 unitVolume = 1.; - for (uint32_t i = 0; i < simDim; i++) - unitVolume *= UNIT_LENGTH; - // that's a hack, but works for all species - //const float_64 charge = precisionCast( - // ParticlesType::FrameType().getCharge(particles::TYPICAL_NUM_PARTICLES_PER_MACROPARTICLE)) / - // precisionCast(particles::TYPICAL_NUM_PARTICLES_PER_MACROPARTICLE) * UNIT_CHARGE; - - // Note: multiply particles::TYPICAL_NUM_PARTICLES_PER_MACROPARTICLE again - // because of normalization during atomicAdd above - // to avoid float overflow for weightings - const float_64 unit = precisionCast(particles::TYPICAL_NUM_PARTICLES_PER_MACROPARTICLE) - / (cellVolume * unitVolume); - if (isMaster) - output(resultBox.shift(header->window.offset), unit, header->window.size, *header); - } - - void init() - { - if (notifyFrequency > 0) - { - const DataSpace localSize(cellDescription->getGridLayout().getDataSpaceWithoutGuarding()); - - Window window(MovingWindow::getInstance().getWindow(0)); - sliceOffset = (int) ((float) (window.globalDimensions.size[sliceDim]) * slicePoint) + - window.globalDimensions.offset[sliceDim]; - const DataSpace gpus = Environment::get().GridController().getGpuNodes(); - - float_32 cellSizeArr[3] = {0, 0, 0}; - for (uint32_t i = 0; i < simDim; ++i) - cellSizeArr[i] = cellSize[i]; - this->header = MessageHeader::create(); - header->update(*cellDescription, window, transpose, 0, cellSizeArr, gpus); - - img = new GridBuffer (header->node.maxSize); - - isMaster = gather.init(doDrawing()); - } - } - -private: - - bool doDrawing() - { - const SubGrid& subGrid = Environment::get().SubGrid(); - const DataSpace globalRootCellPos(subGrid.getLocalDomain().offset); - const DataSpace localSize(subGrid.getLocalDomain().size); -#if(SIMDIM==DIM3) - const bool tmp = globalRootCellPos[sliceDim] + localSize[sliceDim] > sliceOffset && - globalRootCellPos[sliceDim] <= sliceOffset; - return tmp; -#else - return true; -#endif - } - - MappingDesc *cellDescription; - SimulationDataId particleTag; - - GridBuffer *img; - - int sliceOffset; - uint32_t notifyFrequency; - float_X slicePoint; - std::string analyzerName; - DataSpace transpose; - uint32_t sliceDim; - MessageHeader *header; - Output output; - GatherSlice gather; - bool isMaster; -}; - -} //namespace picongpu diff --git a/src/picongpu/include/plugins/output/images/PngCreator.hpp b/src/picongpu/include/plugins/output/images/PngCreator.hpp index 3861cec051..2066139726 100644 --- a/src/picongpu/include/plugins/output/images/PngCreator.hpp +++ b/src/picongpu/include/plugins/output/images/PngCreator.hpp @@ -39,6 +39,7 @@ #include "memory/boxes/PitchedBox.hpp" #include "memory/boxes/DataBox.hpp" +#include "plugins/output/header/MessageHeader.hpp" //c includes #include "sys/stat.h" @@ -55,6 +56,11 @@ namespace picongpu { } + static std::string getName() + { + return std::string("png"); + } + ~PngCreator() { } diff --git a/src/picongpu/include/plugins/output/images/Visualisation.hpp b/src/picongpu/include/plugins/output/images/Visualisation.hpp index 6f4bb34547..e4d62cce89 100644 --- a/src/picongpu/include/plugins/output/images/Visualisation.hpp +++ b/src/picongpu/include/plugins/output/images/Visualisation.hpp @@ -410,7 +410,7 @@ __global__ void channelsToRGB(Mem mem, uint32_t n) uint32_t tid = blockIdx.x * blockDim.x + threadIdx.x; if (tid >= n) return; - float3_X rgb = float3_X(float_X(0.0), float_X(0.0), float_X(0.0)); + float3_X rgb(float3_X::create(0.0)); visPreview::preChannel1Col::addRGB(rgb, mem[tid].x(), @@ -438,6 +438,7 @@ class Visualisation : public ILightweightPlugin public: + typedef typename ParticlesType::FrameType FrameType; typedef Output CreatorType; Visualisation(std::string name, Output output, uint32_t notifyFrequency, DataSpace transpose, float_X slicePoint) : diff --git a/src/picongpu/include/plugins/radiation/Radiation.hpp b/src/picongpu/include/plugins/radiation/Radiation.hpp index ac83e56b96..71a4f43fcd 100644 --- a/src/picongpu/include/plugins/radiation/Radiation.hpp +++ b/src/picongpu/include/plugins/radiation/Radiation.hpp @@ -127,13 +127,14 @@ class Radiation : public ISimulationPlugin std::string pathRestart; mpi::MPIReduce reduce; + bool compressionOn; public: - Radiation(std::string name, std::string prefix) : - analyzerName(name), - analyzerPrefix(prefix), - filename_prefix(name), + Radiation() : + analyzerName("Radiation: calculate the radiation of a species"), + analyzerPrefix(ParticlesType::FrameType::getName() + std::string("_radiation")), + filename_prefix(analyzerPrefix), particles(NULL), radiation(NULL), cellDescription(NULL), @@ -146,7 +147,8 @@ class Radiation : public ISimulationPlugin isMaster(false), currentStep(0), radPerGPU(false), - lastStep(0) + lastStep(0), + compressionOn(false) { Environment<>::get().PluginConnector().registerPlugin(this); } @@ -193,15 +195,16 @@ class Radiation : public ISimulationPlugin desc.add_options() ((analyzerPrefix + ".period").c_str(), po::value (¬ifyFrequency), "enable analyser [for each n-th step]") ((analyzerPrefix + ".dump").c_str(), po::value (&dumpPeriod)->default_value(0), "dump integrated radiation from last dumped step [for each n-th step] (0 = only print data at end of simulation)") - ((analyzerPrefix + ".lastRadiation").c_str(), po::value (&lastRad)->default_value(false), "enable(1)/disable(0) calculation integrated radiation from last dumped step") + ((analyzerPrefix + ".lastRadiation").c_str(), po::bool_switch(&lastRad), "enable calculation of integrated radiation from last dumped step") ((analyzerPrefix + ".folderLastRad").c_str(), po::value (&folderLastRad)->default_value("lastRad"), "folder in which the integrated radiation from last dumped step is written") - ((analyzerPrefix + ".totalRadiation").c_str(), po::value (&totalRad)->default_value(false), "enable(1)/disable(0) calculation integrated radiation from start of simulation") + ((analyzerPrefix + ".totalRadiation").c_str(), po::bool_switch(&totalRad), "enable calculation of integrated radiation from start of simulation") ((analyzerPrefix + ".folderTotalRad").c_str(), po::value (&folderTotalRad)->default_value("totalRad"), "folder in which the integrated radiation from start of simulation is written") ((analyzerPrefix + ".start").c_str(), po::value (&radStart)->default_value(2), "time index when radiation should start with calculation") ((analyzerPrefix + ".end").c_str(), po::value (&radEnd)->default_value(0), "time index when radiation should end with calculation") ((analyzerPrefix + ".omegaList").c_str(), po::value (&pathOmegaList)->default_value("_noPath_"), "path to file containing all frequencies to calculate") - ((analyzerPrefix + ".radPerGPU").c_str(), po::value (&radPerGPU)->default_value(false), "enable(1)/disable(0) radiation output from each GPU individually") - ((analyzerPrefix + ".folderRadPerGPU").c_str(), po::value (&folderRadPerGPU)->default_value("radPerGPU"), "folder in which the radiation of each GPU is written"); + ((analyzerPrefix + ".radPerGPU").c_str(), po::bool_switch(&radPerGPU), "enable radiation output from each GPU individually") + ((analyzerPrefix + ".folderRadPerGPU").c_str(), po::value (&folderRadPerGPU)->default_value("radPerGPU"), "folder in which the radiation of each GPU is written") + ((analyzerPrefix + ".compression").c_str(), po::bool_switch(&compressionOn), "enable compression of hdf5 output"); } @@ -532,6 +535,7 @@ class Radiation : public ISimulationPlugin splash::DataCollector::FileCreationAttr fAttr; splash::DataCollector::initFileCreationAttr(fAttr); + fAttr.enableCompression = compressionOn; std::ostringstream filename; filename << name << currentStep; @@ -551,6 +555,10 @@ class Radiation : public ISimulationPlugin splash::Dimensions stride(Amplitude::numComponents,1,1); + /* get the radiation amplitude unit */ + Amplitude UnityAmplitude(1., 0., 0., 0., 0., 0.); + const picongpu::float_64 factor = UnityAmplitude.calc_radiation() * UNIT_ENERGY * UNIT_TIME ; + for(uint ampIndex=0; ampIndex < Amplitude::numComponents; ++ampIndex) { splash::Dimensions offset(ampIndex,0,0); @@ -559,20 +567,30 @@ class Radiation : public ISimulationPlugin offset, stride); + /* save data for each x/y/z * Re/Im amplitude */ HDF5dataFile.write(currentStep, radSplashType, 3, dataSelection, dataLabels(ampIndex).c_str(), values); + + /* save SI unit as attribute together with data set */ + HDF5dataFile.writeAttribute(currentStep, + radSplashType, + dataLabels(ampIndex).c_str(), + "unitSI", + &factor); } - HDF5dataFile.close(); + /* save SI unit as attribute in the Amplitude group (for convenience) */ + HDF5dataFile.writeAttribute(currentStep, + radSplashType, + "Amplitude", + "unitSI", + &factor); - /* TODO: will become atribute in HDF5 file later */ - Amplitude UnityAmplitude(1., 0., 0., 0., 0., 0.); - const numtype2 factor = UnityAmplitude.calc_radiation() * UNIT_ENERGY * UNIT_TIME ; - std::cout << "Factor to radiation intensities: " << factor << std::endl; + HDF5dataFile.close(); } @@ -613,7 +631,7 @@ class Radiation : public ISimulationPlugin parameters::N_observer); const int N_tmpBuffer = radiation_frequencies::N_omega * parameters::N_observer; - numtype2* tmpBuffer = new numtype2[N_tmpBuffer]; + picongpu::float_64* tmpBuffer = new picongpu::float_64[N_tmpBuffer]; for(uint ampIndex=0; ampIndex < Amplitude::numComponents; ++ampIndex) { @@ -625,7 +643,7 @@ class Radiation : public ISimulationPlugin for(int copyIndex = 0; copyIndex < N_tmpBuffer; ++copyIndex) { /* convert data directly because Amplutude is just 6 double */ - ((numtype2*)values)[ampIndex + Amplitude::numComponents*copyIndex] = tmpBuffer[copyIndex]; + ((picongpu::float_64*)values)[ampIndex + Amplitude::numComponents*copyIndex] = tmpBuffer[copyIndex]; } } diff --git a/src/picongpu/include/plugins/radiation/Radiation.kernel b/src/picongpu/include/plugins/radiation/Radiation.kernel index 2e6d668644..3091733002 100644 --- a/src/picongpu/include/plugins/radiation/Radiation.kernel +++ b/src/picongpu/include/plugins/radiation/Radiation.kernel @@ -1,5 +1,5 @@ /** - * Copyright 2013-2014 Axel Huebl, Heiko Burau, Rene Widera, Richard Pausch, Klaus Steiniger, + * Copyright 2013-2015 Axel Huebl, Heiko Burau, Rene Widera, Richard Pausch, Klaus Steiniger, * Felix Schmitt * * This file is part of PIConGPU. @@ -128,10 +128,10 @@ void kernelRadiationParticles(ParBox pb, const int blockSize=PMacc::math::CT::volume::type::value; // vectorial part of the integrand in the Jackson formula - __shared__ vec2 real_amplitude_s[blockSize]; + __shared__ vector_64 real_amplitude_s[blockSize]; // retarded time - __shared__ numtype2 t_ret_s[blockSize]; + __shared__ picongpu::float_64 t_ret_s[blockSize]; // storage for macro particle weighting needed if // the coherent and incoherent radiation of a single @@ -159,10 +159,10 @@ void kernelRadiationParticles(ParBox pb, // simulation time (needed for retarded time) - const numtype2 t((numtype2) currentStep * (numtype2) DELTA_T); + const picongpu::float_64 t((picongpu::float_64) currentStep * (picongpu::float_64) DELTA_T); // looking direction (needed for observer) used in the thread - const vec2 look = radiation_observer::observation_direction(theta_idx); + const vector_64 look = radiation_observer::observation_direction(theta_idx); // get extent of guarding super cells (needed to ignore them) const int guardingSuperCells = mapper.getGuardingSuperCells(); @@ -267,7 +267,7 @@ void kernelRadiationParticles(ParBox pb, (cellIdx)); // add global position of cell with local position of particle in cell - vec1 particle_locationNow; + vector_32 particle_locationNow; // set z component to zero in case of simDim==DIM2 particle_locationNow[2] = 0.0; // run over all components and compute gobal position @@ -276,8 +276,8 @@ void kernelRadiationParticles(ParBox pb, // get old and new particle momenta - const vec1 particle_momentumNow = vec1(par[momentum_]); - const vec1 particle_momentumOld = vec1(par[momentumPrev1_]); + const vector_32 particle_momentumNow = vector_32(par[momentum_]); + const vector_32 particle_momentumOld = vector_32(par[momentumPrev1_]); /* get macro-particle weighting @@ -330,7 +330,7 @@ void kernelRadiationParticles(ParBox pb, // a single electron real_amplitude_s[saveParticleAt] = amplitude3.get_vector(look) * particle_charge * - (numtype2) DELTA_T; + (picongpu::float_64) DELTA_T; #else // if coherent and incoherent of single macro-particle is NOT considered @@ -340,7 +340,7 @@ void kernelRadiationParticles(ParBox pb, // compute real amplitude of macro-particle real_amplitude_s[saveParticleAt] = amplitude3.get_vector(look) * particle_charge * - (numtype2) DELTA_T; + (picongpu::float_64) DELTA_T; #endif // retarded time stored in shared memory @@ -355,36 +355,19 @@ void kernelRadiationParticles(ParBox pb, /* the particle amplitude is used to include the weighting * of the window function filter without needing more memory */ -#if (PIC_RADWINDOWFUNCTION==1) - const radWindowFunction::radWindowFunction winFkt; /* start with a factor of one */ float_X windowFactor = 1.0; - /* TODO: How to do this for 2D automatically? */ - /* window in each dimension */ - /* not supported yet */ - /*for (uint32_t d = 0; d < simDim; ++d) - { - windowFactor *= winFkt(particle_locationNow[d], - simBoxSize[d] * cellSize[d]); - } - */ - - /* window in x dimension */ - windowFactor *= winFkt(particle_locationNow.x(), - simBoxSize.x() * CELL_WIDTH); - /* window in y dimension */ - windowFactor *= winFkt(particle_locationNow.y(), - simBoxSize.y() * CELL_HEIGHT); - /* window in z dimension */ - windowFactor *= winFkt(particle_locationNow.z(), - simBoxSize.z() * CELL_DEPTH); + for (uint32_t d = 0; d < simDim; ++d) + { + windowFactor *= winFkt(particle_locationNow[d], + simBoxSize[d] * cellSize[d]); + } /* apply window function factor to amplitude */ real_amplitude_s[saveParticleAt] *= windowFactor; -#endif @@ -406,7 +389,7 @@ void kernelRadiationParticles(ParBox pb, Amplitude amplitude = Amplitude::zero(); // compute frequency "omega" using for-loop-index "o" - const numtype2 omega = freqFkt(o); + const picongpu::float_64 omega = freqFkt(o); // if coherent and incoherent radiation of a single macro-particle @@ -440,13 +423,13 @@ void kernelRadiationParticles(ParBox pb, // is considered // the form factor influences the real amplitude #if (__COHERENTINCOHERENTWEIGHTING__==1) - const vec2 weighted_real_amp = real_amplitude_s[j] * precisionCast + const vector_64 weighted_real_amp = real_amplitude_s[j] * precisionCast (myRadFormFactor(radWeighting_s[j], omega, look)); #else // if coherent/incoherent radiation of single macro-particle // is NOT considered // no change on real amplitude is performed - const vec2 weighted_real_amp = real_amplitude_s[j]; + const vector_64 weighted_real_amp = real_amplitude_s[j]; #endif // complex amplitude for j-th particle diff --git a/src/picongpu/include/plugins/radiation/amplitude.hpp b/src/picongpu/include/plugins/radiation/amplitude.hpp index f115c845b5..856f1ac7ca 100644 --- a/src/picongpu/include/plugins/radiation/amplitude.hpp +++ b/src/picongpu/include/plugins/radiation/amplitude.hpp @@ -24,34 +24,34 @@ #include "parameters.hpp" #include "mpi/GetMPI_StructAsArray.hpp" -typedef PMacc::math::Complex complex_64; +typedef PMacc::math::Complex complex_64; /** class to store 3 complex numbers for the radiated amplitude */ class Amplitude { public: - // number of scalars of type numtype2 in Amplitude = 3 (3D) * 2 (complex) = 6 - static const uint numComponents = 3 * sizeof(complex_64) / sizeof(numtype2); + // number of scalars of type picongpu::float_64 in Amplitude = 3 (3D) * 2 (complex) = 6 + static const uint numComponents = 3 * sizeof(complex_64) / sizeof(picongpu::float_64); - /** constructor - * + /** constructor + * * Arguments: - * - vec2: real 3D vector + * - vector_64: real 3D vector * - float: complex phase */ - DINLINE Amplitude(vec2 vec, picongpu::float_X phase) + DINLINE Amplitude(vector_64 vec, picongpu::float_X phase) { picongpu::float_X cosValue; picongpu::float_X sinValue; picongpu::math::sincos(phase, sinValue, cosValue); - amp_x=PMacc::algorithms::math::euler(vec.x(), picongpu::precisionCast(sinValue), picongpu::precisionCast(cosValue) ); - amp_y=PMacc::algorithms::math::euler(vec.y(), picongpu::precisionCast(sinValue), picongpu::precisionCast(cosValue) ); - amp_z=PMacc::algorithms::math::euler(vec.z(), picongpu::precisionCast(sinValue), picongpu::precisionCast(cosValue) ); + amp_x=PMacc::algorithms::math::euler(vec.x(), picongpu::precisionCast(sinValue), picongpu::precisionCast(cosValue) ); + amp_y=PMacc::algorithms::math::euler(vec.y(), picongpu::precisionCast(sinValue), picongpu::precisionCast(cosValue) ); + amp_z=PMacc::algorithms::math::euler(vec.z(), picongpu::precisionCast(sinValue), picongpu::precisionCast(cosValue) ); } - /** default constructor - * + /** default constructor + * * \warning does not initialize values! */ HDINLINE Amplitude(void) { @@ -59,13 +59,13 @@ class Amplitude } - /** constructor - * + /** constructor + * * Arguments: * - 6x float: Re(x), Im(x), Re(y), Im(y), Re(z), Im(z) */ - HDINLINE Amplitude(const numtype2 x_re, const numtype2 x_im, - const numtype2 y_re, const numtype2 y_im, - const numtype2 z_re, const numtype2 z_im) + HDINLINE Amplitude(const picongpu::float_64 x_re, const picongpu::float_64 x_im, + const picongpu::float_64 y_re, const picongpu::float_64 y_im, + const picongpu::float_64 z_re, const picongpu::float_64 z_im) : amp_x(x_re, x_im), amp_y(y_re, y_im), amp_z(z_re, z_im) { @@ -107,20 +107,20 @@ class Amplitude /** calculate radiation from *this amplitude * * Returns: \frac{d^2 I}{d \Omega d \omega} = const*Amplitude^2 */ - HDINLINE numtype2 calc_radiation(void) + HDINLINE picongpu::float_64 calc_radiation(void) { // const SI factor radiation - const numtype2 factor = 1.0 / - (16. * util::cube(M_PI) * picongpu::EPS0 * picongpu::SPEED_OF_LIGHT); + const picongpu::float_64 factor = 1.0 / + (16. * util::cube(M_PI) * picongpu::EPS0 * picongpu::SPEED_OF_LIGHT); return factor * (PMacc::algorithms::math::abs2(amp_x) + PMacc::algorithms::math::abs2(amp_y) + PMacc::algorithms::math::abs2(amp_z)); } /** debugging method - * + * * Returns: real-x-value */ - HDINLINE numtype2 debug(void) + HDINLINE picongpu::float_64 debug(void) { return amp_x.get_real(); } diff --git a/src/picongpu/include/plugins/radiation/calc_amplitude.hpp b/src/picongpu/include/plugins/radiation/calc_amplitude.hpp index 9426d6c147..434adf6239 100644 --- a/src/picongpu/include/plugins/radiation/calc_amplitude.hpp +++ b/src/picongpu/include/plugins/radiation/calc_amplitude.hpp @@ -48,28 +48,28 @@ struct One_minus_beta_times_n // Taylor just includes a method, When includes just enum - HDINLINE numtype1 operator()(const vec2& n, const Particle & particle) const + HDINLINE picongpu::float_32 operator()(const vector_64& n, const Particle & particle) const { // 1/gamma^2: - const numtype2 gamma_inv_square(particle.get_gamma_inv_square ()); + const picongpu::float_64 gamma_inv_square(particle.get_gamma_inv_square ()); - //numtype2 value; // storage for 1-\beta \times \vec n + //picongpu::float_64 value; // storage for 1-\beta \times \vec n // if energy is high enough to cause numerical errors ( equals if 1/gamma^2 is closs enought to zero) // chose a Taylor approximation to to better calculate 1-\beta \times \vec n (which is close to 1-1) // is energy is low, then the Appriximation will acuse a larger error, therfor calculate // 1-\beta \times \vec n directly // with 0.18 the relativ error will be below 0.001% for a Taylor series of 1-sqrt(1-x) of 5th order - if (gamma_inv_square < picongpu::GAMMA_INV_SQUARE_RAD_THRESH) + if (gamma_inv_square < picongpu::GAMMA_INV_SQUARE_RAD_THRESH) { - const numtype2 cos_theta(particle.get_cos_theta (n)); // cosinus between looking vector and momentum of particle - const numtype2 taylor_approx(cos_theta * Taylor()(gamma_inv_square) + (1.0 - cos_theta)); + const picongpu::float_64 cos_theta(particle.get_cos_theta (n)); // cosinus between looking vector and momentum of particle + const picongpu::float_64 taylor_approx(cos_theta * Taylor()(gamma_inv_square) + (1.0 - cos_theta)); return (taylor_approx); } else { - const vec2 beta(particle.get_beta ()); // calc v/c=beta + const vector_64 beta(particle.get_beta ()); // calc v/c=beta return (1.0 - beta * n); } @@ -82,11 +82,11 @@ struct Retarded_time_1 // contains more parameters than needed to have the // same interface as 'Retarded_time_2' - HDINLINE numtype2 operator()(const numtype2 t, - const vec2& n, const Particle & particle) const + HDINLINE picongpu::float_64 operator()(const picongpu::float_64 t, + const vector_64& n, const Particle & particle) const { - const vec2 r(particle.get_location ()); // location - return (numtype2) (t - (n * r) / (picongpu::SPEED_OF_LIGHT)); + const vector_64 r(particle.get_location ()); // location + return (picongpu::float_64) (t - (n * r) / (picongpu::SPEED_OF_LIGHT)); } }; @@ -99,21 +99,21 @@ struct Old_Method /// with Exponent=Cube the integration over t_ret will be assumed (old FFT) /// with Exponent=Square the integration over t_sim will be assumed (old DFT) - HDINLINE vec2 operator()(const vec2& n, const Particle& particle, const numtype2 delta_t) const + HDINLINE vector_64 operator()(const vector_64& n, const Particle& particle, const picongpu::float_64 delta_t) const { - const vec2 beta(particle.get_beta ()); // beta = v/c - const vec2 beta_dot((beta - particle.get_beta < When::now + 1 > ()) / delta_t); // numeric differentiation (backward difference) + const vector_64 beta(particle.get_beta ()); // beta = v/c + const vector_64 beta_dot((beta - particle.get_beta < When::now + 1 > ()) / delta_t); // numeric differentiation (backward difference) const Exponent exponent; // instance of the Exponent class // ???is a static class and no instance possible??? //const One_minus_beta_times_n one_minus_beta_times_n; - const numtype2 factor(exponent(1.0 / (One_minus_beta_times_n()(n, particle)))); + const picongpu::float_64 factor(exponent(1.0 / (One_minus_beta_times_n()(n, particle)))); // factor=1/(1-beta*n)^g g=2 for DFT and g=3 for FFT return (n % ((n - beta) % beta_dot)) * factor; } }; // typedef of all possible forms of Old_Method -//typedef Old_Method > Old_FFT; -typedef Old_Method > Old_DFT; +//typedef Old_Method > Old_FFT; +typedef Old_Method > Old_DFT; @@ -135,37 +135,37 @@ class Calc_Amplitude // of base classes HDINLINE Calc_Amplitude(const Particle& particle, - const numtype2 delta_t, - const numtype2 t_sim) + const picongpu::float_64 delta_t, + const picongpu::float_64 t_sim) : particle(particle), delta_t(delta_t), t_sim(t_sim) { } // get real vector part of amplitude - HDINLINE vec2 get_vector(const vec2& n) const + HDINLINE vector_64 get_vector(const vector_64& n) const { - const vec2 look_direction(n.unit_vec()); // make sure look_direction is a unit vector + const vector_64 look_direction(n.unit_vec()); // make sure look_direction is a unit vector VecCalc vecC; return vecC(look_direction, particle, delta_t); } // get retarded time - HDINLINE numtype2 get_t_ret(const vec2 look_direction) const + HDINLINE picongpu::float_64 get_t_ret(const vector_64 look_direction) const { TimeCalc timeC; return timeC(t_sim, look_direction, particle); - // const vec2 r = particle.get_location (); // location - // return (numtype2) (t - (n * r) / (picongpu::SPEED_OF_LIGHT)); + // const vector_64 r = particle.get_location (); // location + // return (picongpu::float_64) (t - (n * r) / (picongpu::SPEED_OF_LIGHT)); } private: // data: const Particle& particle; // one particle - const numtype2 delta_t; // length of one timestep in simulation - const numtype2 t_sim; // simulation time (for methods not using index*delta_t ) + const picongpu::float_64 delta_t; // length of one timestep in simulation + const picongpu::float_64 t_sim; // simulation time (for methods not using index*delta_t ) }; diff --git a/src/picongpu/include/plugins/radiation/nyquist_low_pass.hpp b/src/picongpu/include/plugins/radiation/nyquist_low_pass.hpp index ffe98b3cc5..f257119402 100644 --- a/src/picongpu/include/plugins/radiation/nyquist_low_pass.hpp +++ b/src/picongpu/include/plugins/radiation/nyquist_low_pass.hpp @@ -1,5 +1,5 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera, Richard Pausch + * Copyright 2013, 2015 Heiko Burau, Rene Widera, Richard Pausch * * This file is part of PIConGPU. * @@ -34,7 +34,7 @@ class NyquistLowPass : public One_minus_beta_times_n * omega_{Nyquist} = (\pi - \epsilon )/(\delta t * (1 - \vec(\beta) * \vec(n))) * so that all Amplitudes for higher frequencies can be ignored **/ - __device__ __host__ __forceinline__ NyquistLowPass(const vec2& n, const Particle& particle) + __device__ __host__ __forceinline__ NyquistLowPass(const vector_64& n, const Particle& particle) : omegaNyquist((picongpu::PI - 0.01)/ (picongpu::DELTA_T * One_minus_beta_times_n()(n, particle))) @@ -50,12 +50,12 @@ class NyquistLowPass : public One_minus_beta_times_n /** * checks if frequency omega is below Nyquist frequency **/ - __device__ __host__ __forceinline__ bool check(const numtype1 omega) + __device__ __host__ __forceinline__ bool check(const picongpu::float_32 omega) { return omega < omegaNyquist * picongpu::radiationNyquist::NyquistFactor; } private: - numtype1 omegaNyquist; // Nyquist frequency for a particle (at a certain timestep) for one direction + picongpu::float_32 omegaNyquist; // Nyquist frequency for a particle (at a certain timestep) for one direction }; diff --git a/src/picongpu/include/plugins/radiation/parameters.hpp b/src/picongpu/include/plugins/radiation/parameters.hpp index 1f7f909680..eb9afe503f 100644 --- a/src/picongpu/include/plugins/radiation/parameters.hpp +++ b/src/picongpu/include/plugins/radiation/parameters.hpp @@ -1,5 +1,5 @@ /** - * Copyright 2013 Axel Huebl, Rene Widera, Richard Pausch + * Copyright 2013, 2015 Axel Huebl, Rene Widera, Richard Pausch * * This file is part of PIConGPU. * @@ -25,10 +25,7 @@ #include "simulation_defines.hpp" -typedef picongpu::float_32 numtype1; -typedef __align__(8) picongpu::float_64 numtype2; - -typedef /*__align__(16)*/ cuda_vec vec1; -typedef /*__align__(32)*/ cuda_vec vec2; +typedef /*__align__(16)*/ cuda_vec vector_32; +typedef /*__align__(32)*/ cuda_vec vector_64; diff --git a/src/picongpu/include/plugins/radiation/particle.hpp b/src/picongpu/include/plugins/radiation/particle.hpp index 17265ad6b2..f3260e8369 100644 --- a/src/picongpu/include/plugins/radiation/particle.hpp +++ b/src/picongpu/include/plugins/radiation/particle.hpp @@ -1,5 +1,5 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera, Richard Pausch + * Copyright 2013, 2015 Heiko Burau, Rene Widera, Richard Pausch * * This file is part of PIConGPU. * @@ -54,16 +54,16 @@ class Particle : protected Taylor // Taylor includes just some methodes (no real { location_begin = When::now, momentum_begin = When::now, beta_begin = When::first }; - const vec1 momentum_now; - const vec1 momentum_old; - const vec1 location_now; + const vector_32 momentum_now; + const vector_32 momentum_old; + const vector_32 location_now; const picongpu::float_X mass; public: ////////////////////////////////////////////////////////////////// // constructors: - HDINLINE Particle(const vec1& locationNow_set, const vec1& momentumOld_set, const vec1& momentumNow_set, const picongpu::float_X mass_set) + HDINLINE Particle(const vector_32& locationNow_set, const vector_32& momentumOld_set, const vector_32& momentumNow_set, const picongpu::float_X mass_set) : location_now(locationNow_set), momentum_old(momentumOld_set), momentum_now(momentumNow_set), mass(mass_set) { @@ -74,37 +74,37 @@ class Particle : protected Taylor // Taylor includes just some methodes (no real // getters: template - HDINLINE vec2 get_location(void) const; + HDINLINE vector_64 get_location(void) const; // get location at time when template - HDINLINE vec2 get_momentum(void) const; + HDINLINE vector_64 get_momentum(void) const; // get momentum at time when template - HDINLINE vec2 get_beta(void) const + HDINLINE vector_64 get_beta(void) const { return calc_beta(get_momentum ()); } // get beta at time when except: // first --> is specialized below template - HDINLINE numtype2 get_gamma(void) const + HDINLINE picongpu::float_64 get_gamma(void) const { return calc_gamma(get_momentum ()); } // get gamma at time when template - HDINLINE numtype2 get_gamma_inv_square(void) const + HDINLINE picongpu::float_64 get_gamma_inv_square(void) const { return calc_gamma_inv_square(get_momentum ()); } // get 1/gamma^2 template< unsigned int when> - HDINLINE numtype2 get_cos_theta(const vec2& n) const + HDINLINE picongpu::float_64 get_cos_theta(const vector_64& n) const { // get cos(theta) at time when - const vec2 beta = get_beta (); + const vector_64 beta = get_beta (); return calc_cos_theta(n, beta); } @@ -113,29 +113,29 @@ class Particle : protected Taylor // Taylor includes just some methodes (no real ////////////////////////////////////////////////////////////////// // private methods: - HDINLINE vec2 calc_beta(const vec1& momentum) const + HDINLINE vector_64 calc_beta(const vector_32& momentum) const { // returns beta=v/c - const numtype1 gamma1 = calc_gamma(momentum); + const picongpu::float_32 gamma1 = calc_gamma(momentum); return momentum * (1.0 / (mass * picongpu::SPEED_OF_LIGHT * gamma1)); } - HDINLINE numtype2 calc_gamma(const vec1& momentum) const + HDINLINE picongpu::float_64 calc_gamma(const vector_32& momentum) const { // return gamma = E/(mc^2) - const numtype1 x = util::square (momentum * (1.0 / (mass * picongpu::SPEED_OF_LIGHT))); + const picongpu::float_32 x = util::square (momentum * (1.0 / (mass * picongpu::SPEED_OF_LIGHT))); return picongpu::math::sqrt(1.0 + x); } - HDINLINE numtype2 calc_gamma_inv_square(const vec1& momentum) const + HDINLINE picongpu::float_64 calc_gamma_inv_square(const vector_32& momentum) const { // returns 1/gamma^2 = m^2*c^2/(m^2*c^2 + p^2) - const numtype1 Emass = mass * picongpu::SPEED_OF_LIGHT; - return Emass / (Emass + (util::square (momentum)) / Emass); + const picongpu::float_32 Emass = mass * picongpu::SPEED_OF_LIGHT; + return Emass / (Emass + (util::square (momentum)) / Emass); } - HDINLINE numtype2 calc_cos_theta(const vec2& n, const vec2& beta) const + HDINLINE picongpu::float_64 calc_cos_theta(const vector_64& n, const vector_64& beta) const { // return cos of angle between looking and flight direction return (n * beta) / (std::sqrt(beta * beta)); @@ -144,10 +144,10 @@ class Particle : protected Taylor // Taylor includes just some methodes (no real // setters: - HDINLINE numtype2 summand(void) const + HDINLINE picongpu::float_64 summand(void) const { // return \vec n independend summand (next value to add to \vec n independend sum) - const numtype2 x = get_gamma_inv_square (); + const picongpu::float_64 x = get_gamma_inv_square (); return Taylor()(x); } @@ -156,19 +156,19 @@ class Particle : protected Taylor // Taylor includes just some methodes (no real template<> -HDINLINE vec2 Particle::get_location(void) const +HDINLINE vector_64 Particle::get_location(void) const { return location_now; } // get location at time when template<> -HDINLINE vec2 Particle::get_momentum(void) const +HDINLINE vector_64 Particle::get_momentum(void) const { return momentum_now; } // get momentum at time when template<> -HDINLINE vec2 Particle::get_momentum(void) const +HDINLINE vector_64 Particle::get_momentum(void) const { return momentum_old; } // get momentum at time when diff --git a/src/picongpu/include/plugins/radiation/radFormFactor.hpp b/src/picongpu/include/plugins/radiation/radFormFactor.hpp index b0b8a77ce2..e1a0bbea49 100644 --- a/src/picongpu/include/plugins/radiation/radFormFactor.hpp +++ b/src/picongpu/include/plugins/radiation/radFormFactor.hpp @@ -1,5 +1,5 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera, Richard Pausch + * Copyright 2013, 2015 Heiko Burau, Rene Widera, Richard Pausch * * This file is part of PIConGPU. * @@ -32,7 +32,7 @@ namespace picongpu HDINLINE radFormFactor(void) { } - HDINLINE float_X operator()(const float_X N, const float_X omega, const vec1 observer_unit_vec) const + HDINLINE float_X operator()(const float_X N, const float_X omega, const vector_32 observer_unit_vec) const { /* Form Factor for CIC charge distribution of N discrete electrons: @@ -67,7 +67,7 @@ namespace picongpu HDINLINE radFormFactor(void) { } - HDINLINE float_X operator()(const float_X N, const float_X omega, const vec1 observer_unit_vec) const + HDINLINE float_X operator()(const float_X N, const float_X omega, const vector_32 observer_unit_vec) const { /* Form Factor for 1D CIC charge distribution of N discrete electrons: @@ -91,7 +91,7 @@ namespace picongpu HDINLINE radFormFactor(void) { } - HDINLINE float_X operator()(const float_X N, const float_X omega, const vec1 observer_unit_vec) const + HDINLINE float_X operator()(const float_X N, const float_X omega, const vector_32 observer_unit_vec) const { /* Form Factor for 1D CIC charge distribution of N discrete electrons: diff --git a/src/picongpu/include/plugins/radiation/taylor.hpp b/src/picongpu/include/plugins/radiation/taylor.hpp index aafc24911c..777f347167 100644 --- a/src/picongpu/include/plugins/radiation/taylor.hpp +++ b/src/picongpu/include/plugins/radiation/taylor.hpp @@ -1,5 +1,5 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera, Richard Pausch + * Copyright 2013, 2015 Heiko Burau, Rene Widera, Richard Pausch * * This file is part of PIConGPU. * @@ -27,11 +27,11 @@ struct Taylor { // a Taylor development for 1-sqrt(1-x) - HDINLINE numtype2 operator()(numtype2 x) const + HDINLINE picongpu::float_64 operator()(picongpu::float_64 x) const { // Taylor series of 1-sqrt(1-x) till 5th order //same like 0.5*x + 0.125*x*x + 0.0625 * x*x*x + 0.0390625 * x*x*x*x + 0.02734375 *x*x*x*x*x; - const numtype2 x2 = (x * x); + const picongpu::float_64 x2 = (x * x); return x * ((0.5 + 0.125 * x) + x2 * (0.0625 + (0.0390625 * x + 0.02734375 * x2))); } diff --git a/src/picongpu/include/plugins/radiation/windowFunctions.hpp b/src/picongpu/include/plugins/radiation/windowFunctions.hpp index 431a483848..efdde92055 100644 --- a/src/picongpu/include/plugins/radiation/windowFunctions.hpp +++ b/src/picongpu/include/plugins/radiation/windowFunctions.hpp @@ -28,41 +28,6 @@ namespace picongpu /* several window functions behind namespaces: */ - namespace radWindowFunctionRectangle - { - struct radWindowFunction - { - /** 1D Window function according to the rectangle window: - * - * f(position_x) = {1.0 : (0 <= position_x <= L_x ) - * {0.0 : in any other case - * - * @param position_x = 1D position - * @param L_x = length of the simulated area - * assuming that the simulation ranges - * from 0 to L_x in the choosen dimension - * @returns weighting factor to reduce ringing effects due to - * sharp spacial boundaries - **/ - HDINLINE float_X operator()(const float_X position_x, const float_X L_x) const - { - /* an optimized formula is implemented - * - * transform position to make box symetric: - * x_prime = position_x - 1/2 * L_x - * - * then: f(x_position) = f(x_prime) - * f(x_prime) = { 1.0 : -L_x/2 <= x_prime <= +L_x/2 - * { 0.0 : in any other case - */ - const float_X x_prime = position_x - L_x*float_X(0.5); - return float_X(math::abs(x_prime) <= float_X(0.5) * L_x); - } - }; - } /* namespace radWindowFunctionRectangle */ - - - namespace radWindowFunctionTriangle { struct radWindowFunction @@ -184,5 +149,27 @@ namespace picongpu } /* namespace radWindowFunctionGauss */ + namespace radWindowFunctionNone + { + struct radWindowFunction + { + /** 1D Window function according to the no window: + * + * f(position_x) = always 1.0 + * + * @param position_x = 1D position + * @param L_x = length of the simulated area + * assuming that the simulation ranges + * from 0 to L_x in the choosen dimension + * @returns 1.0 + **/ + HDINLINE float_X operator()(const float_X position_x, const float_X L_x) const + { + return float_X(1.0); + } + }; + } /* namespace radWindowFunctionRectangle */ + + } /* namespace picongpu */ diff --git a/src/picongpu/include/simulationControl/ISimulationStarter.hpp b/src/picongpu/include/simulationControl/ISimulationStarter.hpp index d3efd8a1eb..09224b7339 100644 --- a/src/picongpu/include/simulationControl/ISimulationStarter.hpp +++ b/src/picongpu/include/simulationControl/ISimulationStarter.hpp @@ -1,5 +1,5 @@ /** - * Copyright 2013 Rene Widera + * Copyright 2013, 2015 Rene Widera * * This file is part of PIConGPU. * @@ -19,15 +19,12 @@ */ - -#ifndef ISIMULATIONSTARTER_HPP -#define ISIMULATIONSTARTER_HPP - -#include "types.h" -#include "simulation_defines.hpp" - +#pragma once #include "pluginSystem/IPlugin.hpp" +#include "ArgsParser.hpp" +#include "simulation_defines.hpp" +#include "types.h" namespace picongpu { @@ -48,7 +45,7 @@ namespace picongpu * * @return true if no error else false */ - virtual bool parseConfigs(int argc, char **argv) = 0; + virtual ArgsParser::ArgsErrorCode parseConfigs(int argc, char **argv) = 0; /*start simulation * is called after parsConfig and pluginLoad @@ -66,6 +63,3 @@ namespace picongpu } }; } - -#endif /* ISIMULATIONSTARTER_HPP */ - diff --git a/src/picongpu/include/simulationControl/MySimulation.hpp b/src/picongpu/include/simulationControl/MySimulation.hpp index 1a594cdf8b..676d4315e5 100644 --- a/src/picongpu/include/simulationControl/MySimulation.hpp +++ b/src/picongpu/include/simulationControl/MySimulation.hpp @@ -44,6 +44,7 @@ #include "fields/FieldJ.hpp" #include "fields/FieldTmp.hpp" #include "fields/MaxwellSolver/Solvers.hpp" +#include "fields/currentInterpolation/CurrentInterpolation.hpp" #include "fields/background/cellwiseOperation.hpp" #include "initialization/IInitPlugin.hpp" #include "initialization/ParserGridDistribution.hpp" @@ -86,6 +87,10 @@ class MySimulation : public SimulationHelper fieldE(NULL), fieldJ(NULL), fieldTmp(NULL), + myFieldSolver(NULL), + myCurrentInterpolation(NULL), + pushBGField(NULL), + currentBGField(NULL), cellDescription(NULL), initialiserController(NULL), slidingWindow(false) @@ -238,6 +243,8 @@ class MySimulation : public SimulationHelper __delete(myFieldSolver); + __delete(myCurrentInterpolation); + ForEach, MakeIdentifier > deleteParticleMemory; deleteParticleMemory(forward(particleStorage)); @@ -291,12 +298,15 @@ class MySimulation : public SimulationHelper fieldB->init(*fieldE, *laser); fieldE->init(*fieldB, *laser); - fieldJ->init(*fieldE); + fieldJ->init(*fieldE, *fieldB); fieldTmp->init(); // create field solver this->myFieldSolver = new fieldSolver::FieldSolver(*cellDescription); + // create current interpolation + this->myCurrentInterpolation = new fieldSolver::CurrentInterpolation; + ForEach, MakeIdentifier > particleInit; particleInit(forward(particleStorage), fieldE, fieldB, fieldJ, fieldTmp); @@ -330,12 +340,11 @@ class MySimulation : public SimulationHelper else { initialiserController->init(); + ForEach > initSpecies; + initSpecies(forward(particleStorage), step); } } - ForEach > initSpecies; - initSpecies(forward(particleStorage), step); - Environment<>::get().EnvMemoryInfo().getMemoryInfo(&freeGpuMem); log ("free mem after all particles are initialized %1% MiB") % (freeGpuMem / 1024 / 1024); @@ -346,10 +355,10 @@ class MySimulation : public SimulationHelper if( step != 0 ) { namespace nvfct = PMacc::nvidia::functors; - (*pushBGField)( fieldE, nvfct::Sub(), fieldBackgroundE(fieldE->getUnit()), - step, fieldBackgroundE::InfluenceParticlePusher); - (*pushBGField)( fieldB, nvfct::Sub(), fieldBackgroundB(fieldB->getUnit()), - step, fieldBackgroundB::InfluenceParticlePusher); + (*pushBGField)( fieldE, nvfct::Sub(), FieldBackgroundE(fieldE->getUnit()), + step, FieldBackgroundE::InfluenceParticlePusher); + (*pushBGField)( fieldB, nvfct::Sub(), FieldBackgroundB(fieldB->getUnit()), + step, FieldBackgroundB::InfluenceParticlePusher); } // communicate all fields @@ -388,31 +397,51 @@ class MySimulation : public SimulationHelper __setTransactionEvent(updateEvent); /** remove background field for particle pusher */ - (*pushBGField)(fieldE, nvfct::Sub(), fieldBackgroundE(fieldE->getUnit()), - currentStep, fieldBackgroundE::InfluenceParticlePusher); - (*pushBGField)(fieldB, nvfct::Sub(), fieldBackgroundB(fieldB->getUnit()), - currentStep, fieldBackgroundB::InfluenceParticlePusher); + (*pushBGField)(fieldE, nvfct::Sub(), FieldBackgroundE(fieldE->getUnit()), + currentStep, FieldBackgroundE::InfluenceParticlePusher); + (*pushBGField)(fieldB, nvfct::Sub(), FieldBackgroundB(fieldB->getUnit()), + currentStep, FieldBackgroundB::InfluenceParticlePusher); this->myFieldSolver->update_beforeCurrent(currentStep); fieldJ->clear(); __setTransactionEvent(commEvent); - (*currentBGField)(fieldJ, nvfct::Add(), fieldBackgroundJ(fieldJ->getUnit()), - currentStep, fieldBackgroundJ::activated); + (*currentBGField)(fieldJ, nvfct::Add(), FieldBackgroundJ(fieldJ->getUnit()), + currentStep, FieldBackgroundJ::activated); #if (ENABLE_CURRENT == 1) ForEach >, MakeIdentifier > computeCurrent; computeCurrent(forward(fieldJ),forward(particleStorage), currentStep); #endif #if (ENABLE_CURRENT == 1) - if(bmpl::size::type::value>0) + if(bmpl::size::type::value > 0) { EventTask eRecvCurrent = fieldJ->asyncCommunication(__getTransactionEvent()); - fieldJ->addCurrentToE (); - __setTransactionEvent(eRecvCurrent); - fieldJ->addCurrentToE (); + const DataSpace currentRecvLower( GetMargin::LowerMargin( ).toRT( ) ); + const DataSpace currentRecvUpper( GetMargin::UpperMargin( ).toRT( ) ); + + /* without interpolation, we do not need to access the FieldJ GUARD + * and can therefor overlap communication of GUARD->(ADD)BORDER & computation of CORE */ + if( currentRecvLower == DataSpace::create(0) && + currentRecvUpper == DataSpace::create(0) ) + { + fieldJ->addCurrentToEMF(*myCurrentInterpolation); + __setTransactionEvent(eRecvCurrent); + fieldJ->addCurrentToEMF(*myCurrentInterpolation); + } else + { + /* in case we perform a current interpolation/filter, we need + * to access the BORDER area from the CORE (and the GUARD area + * from the BORDER) + * `fieldJ->asyncCommunication` first adds the neighbors' values + * to BORDER (send) and then updates the GUARD (receive) + * \todo split the last `receive` part in a separate method to + * allow already a computation of CORE */ + __setTransactionEvent(eRecvCurrent); + fieldJ->addCurrentToEMF(*myCurrentInterpolation); + } } #endif @@ -434,10 +463,10 @@ class MySimulation : public SimulationHelper */ namespace nvfct = PMacc::nvidia::functors; - (*pushBGField)( fieldE, nvfct::Add(), fieldBackgroundE(fieldE->getUnit()), - currentStep, fieldBackgroundE::InfluenceParticlePusher ); - (*pushBGField)( fieldB, nvfct::Add(), fieldBackgroundB(fieldB->getUnit()), - currentStep, fieldBackgroundB::InfluenceParticlePusher ); + (*pushBGField)( fieldE, nvfct::Add(), FieldBackgroundE(fieldE->getUnit()), + currentStep, FieldBackgroundE::InfluenceParticlePusher ); + (*pushBGField)( fieldB, nvfct::Add(), FieldBackgroundB(fieldB->getUnit()), + currentStep, FieldBackgroundB::InfluenceParticlePusher ); } void resetAll(uint32_t currentStep) @@ -549,6 +578,8 @@ class MySimulation : public SimulationHelper // field solver fieldSolver::FieldSolver* myFieldSolver; + fieldSolver::CurrentInterpolation* myCurrentInterpolation; + cellwiseOperation::CellwiseOperation< CORE + BORDER + GUARD >* pushBGField; cellwiseOperation::CellwiseOperation< CORE + BORDER + GUARD >* currentBGField; diff --git a/src/picongpu/include/simulationControl/SimulationStarter.hpp b/src/picongpu/include/simulationControl/SimulationStarter.hpp index 1f12722843..4441ea5e78 100644 --- a/src/picongpu/include/simulationControl/SimulationStarter.hpp +++ b/src/picongpu/include/simulationControl/SimulationStarter.hpp @@ -1,5 +1,5 @@ /** - * Copyright 2013 Axel Huebl, Rene Widera + * Copyright 2013, 2015 Axel Huebl, Rene Widera * * This file is part of PIConGPU. * @@ -94,7 +94,7 @@ namespace picongpu { } - bool parseConfigs(int argc, char **argv) + ArgsParser::ArgsErrorCode parseConfigs(int argc, char **argv) { ArgsParser& ap = ArgsParser::getInstance(); PluginConnector& pluginConnector = Environment<>::get().PluginConnector(); diff --git a/src/picongpu/include/simulation_classTypes.hpp b/src/picongpu/include/simulation_classTypes.hpp index 7c2e152ae3..bfbc7bea19 100644 --- a/src/picongpu/include/simulation_classTypes.hpp +++ b/src/picongpu/include/simulation_classTypes.hpp @@ -70,7 +70,7 @@ namespace picongpu * @param area area type for which the kernel is called */ #define __picKernelArea(kernelname,description,area) { \ - CUDA_CHECK_KERNEL_MSG(cudaThreadSynchronize(),"picKernelArea crash before kernel call"); \ + CUDA_CHECK_KERNEL_MSG(cudaDeviceSynchronize(),"picKernelArea crash before kernel call"); \ AreaMapping mapper(description); \ TaskKernel *taskKernel = Environment<>::get().Factory().createTaskKernel(#kernelname); \ kernelname PIC_PMACC_CUDAKERNELCONFIG diff --git a/src/picongpu/include/simulation_defines/_defaultParam.loader b/src/picongpu/include/simulation_defines/_defaultParam.loader index c5d680160c..f430b9a6e0 100644 --- a/src/picongpu/include/simulation_defines/_defaultParam.loader +++ b/src/picongpu/include/simulation_defines/_defaultParam.loader @@ -33,6 +33,7 @@ #include "simulation_defines/param/radiationConfig.param" #include "simulation_defines/param/pusherConfig.param" #include "simulation_defines/param/ionizerConfig.param" +#include "simulation_defines/param/ionizationEnergies.param" #include "simulation_defines/param/speciesAttributes.param" #include "simulation_defines/param/gasConfig.param" #include "simulation_defines/param/particleConfig.param" diff --git a/src/picongpu/include/simulation_defines/_defaultUnitless.loader b/src/picongpu/include/simulation_defines/_defaultUnitless.loader index a81b48947f..001ffb82bc 100644 --- a/src/picongpu/include/simulation_defines/_defaultUnitless.loader +++ b/src/picongpu/include/simulation_defines/_defaultUnitless.loader @@ -39,5 +39,6 @@ #include "simulation_defines/unitless/speciesAttributes.unitless" #include "simulation_defines/unitless/speciesDefinition.unitless" #include "simulation_defines/unitless/speciesInitialization.unitless" +#include "simulation_defines/unitless/fieldBackground.unitless" #include "simulation_defines/unitless/fileOutput.unitless" #include "simulation_defines/unitless/checkpoints.unitless" diff --git a/src/picongpu/include/simulation_defines/param/componentsConfig.param b/src/picongpu/include/simulation_defines/param/componentsConfig.param index cbd4722520..d6d7c8b9a4 100644 --- a/src/picongpu/include/simulation_defines/param/componentsConfig.param +++ b/src/picongpu/include/simulation_defines/param/componentsConfig.param @@ -1,5 +1,5 @@ /** - * Copyright 2013-2014 Axel Huebl, Heiko Burau, Anton Helm, + * Copyright 2013-2015 Axel Huebl, Heiko Burau, Anton Helm, * Rene Widera, Richard Pausch * * This file is part of PIConGPU. @@ -37,6 +37,7 @@ namespace simulation_starter = defaultPIConGPU; * in 'x' direction * - laserWavepacket : wavepacket (Gaussian in time and space, not focusing) * - laserPlaneWave : a plane wave + * - laserPolynom : a polynomial laser envelope */ namespace laserProfile = laserNone; diff --git a/src/picongpu/include/simulation_defines/param/fieldBackground.param b/src/picongpu/include/simulation_defines/param/fieldBackground.param index 5bd59c8088..db9cf06c1a 100644 --- a/src/picongpu/include/simulation_defines/param/fieldBackground.param +++ b/src/picongpu/include/simulation_defines/param/fieldBackground.param @@ -1,5 +1,5 @@ /** - * Copyright 2014 Axel Huebl + * Copyright 2014-2015 Axel Huebl, Alexander Debus * * This file is part of PIConGPU. * @@ -25,7 +25,7 @@ */ namespace picongpu { - class fieldBackgroundE + class FieldBackgroundE { public: /* Add this additional field for pushing particles */ @@ -33,18 +33,18 @@ namespace picongpu /* We use this to calculate your SI input back to our unit system */ const float3_64 unitField; - HDINLINE fieldBackgroundE( const float3_64 unitField ) : unitField(unitField) + HDINLINE FieldBackgroundE( const float3_64 unitField ) : unitField(unitField) {} /** Specify your background field E(r,t) here * - * \param cellIdx The total cell id counted from the start at t=0 + * \param cellIdx The total cell id counted from the start at t = 0 * \param currentStep The current time step */ HDINLINE float3_X operator()( const DataSpace& cellIdx, const uint32_t currentStep ) const { - /* example: periodicity of 20 microns (=2.0e-5 m) */ + /* example: periodicity of 20 microns ( = 2.0e-5 m) */ const float_64 period_SI(20.0e-6); /* calculate cells -> SI -> m to microns*/ const float_64 y_SI = cellIdx.y() * SI::CELL_HEIGHT_SI * 1.0e6; @@ -57,7 +57,7 @@ namespace picongpu } }; - class fieldBackgroundB + class FieldBackgroundB { public: /* Add this additional field for pushing particles */ @@ -65,7 +65,7 @@ namespace picongpu /* We use this to calculate your SI input back to our unit system */ const float3_64 unitField; - HDINLINE fieldBackgroundB( const float3_64 unitField ) : unitField(unitField) + HDINLINE FieldBackgroundB( const float3_64 unitField ) : unitField(unitField) {} /** Specify your background field B(r,t) here @@ -76,7 +76,7 @@ namespace picongpu operator()( const DataSpace& cellIdx, const uint32_t currentStep ) const { - /* example: periodicity of 20 microns (=2.0e-5 m) */ + /* example: periodicity of 20 microns ( = 2.0e-5 m) */ const float_64 period_SI(20.0e-6); /* calculate cells -> SI -> m to microns*/ const float_64 y_SI = cellIdx.y() * SI::CELL_HEIGHT_SI * 1.0e6; @@ -89,7 +89,7 @@ namespace picongpu } }; - class fieldBackgroundJ + class FieldBackgroundJ { public: /* Add this additional field? */ @@ -97,7 +97,7 @@ namespace picongpu /* We use this to calculate your SI input back to our unit system */ const float3_64 unitField; - HDINLINE fieldBackgroundJ( const float3_64 unitField ) : unitField(unitField) + HDINLINE FieldBackgroundJ( const float3_64 unitField ) : unitField(unitField) {} /** Specify your background field J(r,t) here @@ -108,7 +108,7 @@ namespace picongpu operator()( const DataSpace& cellIdx, const uint32_t currentStep ) const { - /* example: periodicity of 20 microns (=2.0e-5 m) */ + /* example: periodicity of 20 microns ( = 2.0e-5 m) */ const float_64 period_SI(20.0e-6); /* calculate cells -> SI -> m to microns*/ const float_64 y_SI = cellIdx.y() * SI::CELL_HEIGHT_SI * 1.0e6; diff --git a/src/picongpu/include/simulation_defines/param/fieldSolver.param b/src/picongpu/include/simulation_defines/param/fieldSolver.param index eecb65c25d..a1cb1b44f7 100644 --- a/src/picongpu/include/simulation_defines/param/fieldSolver.param +++ b/src/picongpu/include/simulation_defines/param/fieldSolver.param @@ -1,5 +1,5 @@ /** - * Copyright 2013 Axel Huebl, Heiko Burau, Rene Widera + * Copyright 2013-2015 Axel Huebl, Heiko Burau, Rene Widera * * This file is part of PIConGPU. * @@ -18,9 +18,10 @@ * If not, see . */ - #pragma once +#include "fields/currentInterpolation/CurrentInterpolation.def" + /**! Configure the selected field solver method * * You can set/modify Maxwell solver specific options in the @@ -30,24 +31,24 @@ namespace picongpu { namespace fieldSolverNone { - + typedef currentInterpolation::None CurrentInterpolation; } - + namespace fieldSolverYee { - + typedef currentInterpolation::None CurrentInterpolation; } - + namespace fieldSolverYeeNative { - + typedef currentInterpolation::None CurrentInterpolation; } namespace fieldSolverDirSplitting { - + typedef currentInterpolation::None CurrentInterpolation; } - + /**! Lehe Solver * The solver proposed by R. Lehe et al * in Phys. Rev. ST Accel. Beams 16, 021301 (2013) @@ -57,11 +58,13 @@ namespace picongpu class CherenkovFreeDirection_X {}; class CherenkovFreeDirection_Y {}; class CherenkovFreeDirection_Z {}; - + /*! Distinguish the direction where numerical Cherenkov Radiation * by moving particles shall be suppressed. */ typedef CherenkovFreeDirection_Y CherenkovFreeDir; + + typedef currentInterpolation::None CurrentInterpolation; } } // namespace picongpu diff --git a/src/picongpu/include/particles/ionization/ionizationEnergies.param b/src/picongpu/include/simulation_defines/param/ionizationEnergies.param similarity index 72% rename from src/picongpu/include/particles/ionization/ionizationEnergies.param rename to src/picongpu/include/simulation_defines/param/ionizationEnergies.param index f224ace9f5..847bd97262 100644 --- a/src/picongpu/include/particles/ionization/ionizationEnergies.param +++ b/src/picongpu/include/simulation_defines/param/ionizationEnergies.param @@ -19,7 +19,7 @@ */ /** \file - * This file contains the ionization energies and conversion to corresponding + * This file contains the ionization energies and conversion to corresponding * electric field strengths for different species. */ #pragma once @@ -36,9 +36,23 @@ namespace SI /* ionization energy for ground state hydrogen: 13.6 eV --> converted to Joule */ /* Joule = kg * m^2 / s^2 */ - const double IONIZATION_ENERGY = 2.179e-18; - /* ionization field strength (E-field) for -""-: in Volt / meter */ - const double IONIZATION_EFIELD = 5.14e11; + PMACC_CONST_VECTOR(float_X,1,IONIZATION_ENERGY, + 2.179e-18 + ); + /* ionization field strength (E-field) for hydrogen: in Volt / meter + * + * usage: + * PMACC_CONST_VECTOR(float_X,,IONIZATION_EFIELD, + * , + * ... + * + * ); + * + * Do not forget to change the weight of the ion and the atomic numbers in + * their respective `.param` file */ + PMACC_CONST_VECTOR(float_X,1,IONIZATION_EFIELD, + 5.14e11 + ); } // namespace SI } // namespace picongpu diff --git a/src/picongpu/include/simulation_defines/param/ionizerConfig.param b/src/picongpu/include/simulation_defines/param/ionizerConfig.param index 71727266f6..230345136a 100644 --- a/src/picongpu/include/simulation_defines/param/ionizerConfig.param +++ b/src/picongpu/include/simulation_defines/param/ionizerConfig.param @@ -21,7 +21,7 @@ #pragma once /** forward declarations for ionization algorithms - * + * * ionization model has a < Name > * so the algorithm is called "Algorithm< Name >" */ diff --git a/src/picongpu/include/simulation_defines/param/laserConfig.param b/src/picongpu/include/simulation_defines/param/laserConfig.param index 436f79218b..cb2b151ef8 100644 --- a/src/picongpu/include/simulation_defines/param/laserConfig.param +++ b/src/picongpu/include/simulation_defines/param/laserConfig.param @@ -1,5 +1,5 @@ /** - * Copyright 2013-2014 Axel Huebl, Anton Helm, Rene Widera, Richard Pausch + * Copyright 2013-2015 Axel Huebl, Anton Helm, Rene Widera, Richard Pausch * * This file is part of PIConGPU. * @@ -68,10 +68,13 @@ namespace picongpu * unit: meter */ const double FOCUS_POS_SI = 4.62e-5; } - /** The laser pulse will be initialized PULSE_INIT times of the PULSE_LENGTH - * unit: none */ + /** The laser pulse will be initialized PULSE_INIT times of the PULSE_LENGTH + * unit: none */ const double PULSE_INIT = 20.0; + /* laser phase shift (no shift: 0.0) */ + const float_X LASER_PHASE = 0.0; /* unit: rad, periodic in 2*pi */ + enum PolarisationType { LINEAR_X = 1u, @@ -123,6 +126,9 @@ namespace picongpu * unit: none */ const double PULSE_INIT = 20.0; + /* laser phase shift (no shift: 0.0) */ + const float_X LASER_PHASE = 0.0; /* unit: rad, periodic in 2*pi */ + enum PolarisationType { LINEAR_X = 1u, @@ -177,6 +183,9 @@ namespace picongpu * unit: none */ const double RAMP_INIT = 20.6146; //25.6415;//SI::aux_calulation::PULSE_TIME_SI/SI::PULSE_LENGTH_SI; + /* we use a sin(omega*time + laser_phase) function to set up the laser - define phase: */ + const float_X LASER_PHASE = 0.0; /* unit: rad, periodic in 2*pi */ + enum PolarisationType { LINEAR_X = 1u, @@ -240,6 +249,9 @@ namespace picongpu * unit: none */ const double RAMP_INIT = 20.0; + /* we use a sin(omega*time + laser_phase) function to set up the laser - define phase: */ + const float_X LASER_PHASE = 0.0; /* unit: rad, periodic in 2*pi */ + enum PolarisationType { LINEAR_X = 1u, @@ -292,6 +304,9 @@ namespace picongpu const double W0x_SI = 4.246e-6; // waist in x-direction const double W0z_SI = W0x_SI; // waist in z-direction } + + /* we use a sin(omega*(time-riseTime) + laser_phase) function to set up the laser - define phase: */ + const float_X LASER_PHASE = 0.0; /* unit: rad, periodic in 2*pi */ } namespace laserNone diff --git a/src/picongpu/include/simulation_defines/param/physicalConstants.param b/src/picongpu/include/simulation_defines/param/physicalConstants.param index cb404659ff..6c6134750e 100644 --- a/src/picongpu/include/simulation_defines/param/physicalConstants.param +++ b/src/picongpu/include/simulation_defines/param/physicalConstants.param @@ -31,7 +31,7 @@ namespace picongpu * use-cases, e.g. energy-binning algorithms. */ const float_X GAMMA_THRESH = float_X(1.005); - /** This limit is used to decide between a pure 1-sqrt(1-x) calculation + /** This limit is used to decide between a pure 1-sqrt(1-x) calculation * and a 5th order Taylor approximation of 1-sqrt(1-x) to avoid halving * of significant digits due to the sqrt() evaluation at x = 1/gamma^2 near 0.0. * With 0.18 the relative error between Taylor approximation and real value diff --git a/src/picongpu/include/simulation_defines/param/radiationConfig.param b/src/picongpu/include/simulation_defines/param/radiationConfig.param index 2965edb3d6..268c2dcf33 100644 --- a/src/picongpu/include/simulation_defines/param/radiationConfig.param +++ b/src/picongpu/include/simulation_defines/param/radiationConfig.param @@ -150,26 +150,22 @@ namespace picongpu // add a window function weighting to the radiation in order // to avoid ringing effects from sharpe boundaries -// 1 = on (slower but with noise/ringing reduction) -// 0 = off (faster but might contain ringing) -#define PIC_RADWINDOWFUNCTION 0 - - +// default: no window function via `radWindowFunctionNone` /* Choose different window function in order to get better ringing reduction - * radWindowFunctionRectangle * radWindowFunctionTriangle * radWindowFunctionHamming * radWindowFunctionTriplett * radWindowFunctionGauss + * radWindowFunctionNone */ -namespace radWindowFunctionRectangle { } namespace radWindowFunctionTriangle { } namespace radWindowFunctionHamming { } namespace radWindowFunctionTriplett { } namespace radWindowFunctionGauss { } +namespace radWindowFunctionNone { } -namespace radWindowFunction = radWindowFunctionTriangle; +namespace radWindowFunction = radWindowFunctionNone; }//namespace picongpu diff --git a/src/picongpu/include/simulation_defines/param/radiationObserver.param b/src/picongpu/include/simulation_defines/param/radiationObserver.param index c9241e062a..6a786875c0 100644 --- a/src/picongpu/include/simulation_defines/param/radiationObserver.param +++ b/src/picongpu/include/simulation_defines/param/radiationObserver.param @@ -1,5 +1,5 @@ /** - * Copyright 2013-2014 Heiko Burau, Rene Widera, Richard Pausch + * Copyright 2013-2015 Heiko Burau, Rene Widera, Richard Pausch * * This file is part of PIConGPU. * @@ -36,10 +36,10 @@ namespace picongpu * to compute the observation direction * * @return unit vector pointing in observation direction - * type: vec2 + * type: vector_64 * */ - DINLINE vec2 observation_direction(const int observation_id_extern) + DINLINE vector_64 observation_direction(const int observation_id_extern) { /** compute observation directions for 2D virtual detector field * pointing toward the +x direction @@ -75,28 +75,28 @@ namespace picongpu /* set up observation angle range */ /* angles range for theta */ - const numtype2 angle_theta_start = - picongpu::PI/8.0 + const picongpu::float_64 angle_theta_start = - picongpu::PI/8.0 + 0.5*picongpu::PI; /* [rad] */ - const numtype2 angle_theta_end = + picongpu::PI/8.0 + const picongpu::float_64 angle_theta_end = + picongpu::PI/8.0 + 0.5*picongpu::PI; /* [rad] */ /* angles range for phi */ - const numtype2 angle_phi_start = - picongpu::PI/8.0; /* [rad] */ - const numtype2 angle_phi_end = + picongpu::PI/8.0; /* [rad] */ + const picongpu::float_64 angle_phi_start = - picongpu::PI/8.0; /* [rad] */ + const picongpu::float_64 angle_phi_end = + picongpu::PI/8.0; /* [rad] */ /* compute step with between two angles for range [angle_??_start : angle_??_end] */ const int N_theta = parameters::N_observer / N_angle_split; - const numtype2 delta_angle_theta = (angle_theta_start - + const picongpu::float_64 delta_angle_theta = (angle_theta_start - angle_theta_end) / (N_theta-1.0); - const numtype2 delta_angle_phi = (angle_phi_start - + const picongpu::float_64 delta_angle_phi = (angle_phi_start - angle_phi_end) / (N_angle_split-1.0); /* compute observation angles */ - const numtype2 theta( my_index_theta * delta_angle_theta + angle_theta_start ); - const numtype2 phi( my_index_phi * delta_angle_phi - angle_phi_start ); + const picongpu::float_64 theta( my_index_theta * delta_angle_theta + angle_theta_start ); + const picongpu::float_64 phi( my_index_phi * delta_angle_phi - angle_phi_start ); /* compute observation unit vector */ - return vec2( sinf(theta)*cosf(phi) , sinf(theta)*sinf(phi) , cosf(theta) ) ; + return vector_64( sinf(theta)*cosf(phi) , sinf(theta)*sinf(phi) , cosf(theta) ) ; } diff --git a/src/picongpu/include/simulation_defines/param/species.param b/src/picongpu/include/simulation_defines/param/species.param index 979af8fd42..7982646f27 100644 --- a/src/picongpu/include/simulation_defines/param/species.param +++ b/src/picongpu/include/simulation_defines/param/species.param @@ -1,5 +1,5 @@ /** - * Copyright 2014 Rene Widera + * Copyright 2014-2015 Rene Widera * * This file is part of PIConGPU. * @@ -47,6 +47,7 @@ namespace picongpu * - particles::shapes::CIC : 1st order * - particles::shapes::TSC : 2nd order (requires CUDA_ARCH>=sm_20) * - particles::shapes::PCS : 3rd order (requires CUDA_ARCH>=sm_20) + * - particles::shapes::P4S : 4th order (requires CUDA_ARCH>=sm_20) * * example: typedef particles::shapes::CIC CICShape; */ @@ -56,9 +57,9 @@ typedef particles::shapes::TSC UsedParticleShape; typedef FieldToParticleInterpolation UsedField2Particle; /*! select current solver method ----------------------------------------------- - * - currentSolver::Esirkepov : particle shapes - CIC, TSC, PCS (1st to 3rd order) + * - currentSolver::Esirkepov : particle shapes - CIC, TSC, PCS, P4S (1st to 4th order) * - currentSolver::VillaBune<> : particle shapes - CIC (1st order) only - * - currentSolver::ZigZag : particle shapes - CIC, TSC, PCS (1st to 3rd order) + * - currentSolver::ZigZag : particle shapes - CIC, TSC, PCS, P4S (1st to 4th order) * * For development purposes: --------------------------------------------------- * - currentSolver::currentSolver::EsirkepovNative : generic version of currentSolverEsirkepov diff --git a/src/picongpu/include/simulation_defines/param/speciesAttributes.param b/src/picongpu/include/simulation_defines/param/speciesAttributes.param index 03e076a69e..d65da11c18 100644 --- a/src/picongpu/include/simulation_defines/param/speciesAttributes.param +++ b/src/picongpu/include/simulation_defines/param/speciesAttributes.param @@ -45,11 +45,11 @@ alias(position); alias(globalCellIdx); /** specialization for the relative in-cell position */ -value_identifier(floatD_X,position_pic,floatD_X(0.)); +value_identifier(floatD_X,position_pic,floatD_X::create(0.)); /** momentum at timestep t */ -value_identifier(float3_X,momentum,float3_X(0.)); +value_identifier(float3_X,momentum,float3_X::create(0.)); /** momentum at (previous) timestep t-1 */ -value_identifier(float3_X,momentumPrev1,float3_X(0.)); +value_identifier(float3_X,momentumPrev1,float3_X::create(0.)); /** weighting of the macro particle */ value_identifier(float_X, weighting, 0.0); /** use this particle for radiation diagnostics */ @@ -60,7 +60,7 @@ value_identifier(bool, radiationFlag, false); * value type is float_X to avoid casts during the runtime * - float is also reasonable because effective charge numbers are possible * - only reasonable for ion species if ionization is enabled - * + * * \todo connect default to proton number */ value_identifier(float_X,boundElectrons,float_X(0.0)); diff --git a/src/picongpu/include/simulation_defines/unitless/fieldBackground.unitless b/src/picongpu/include/simulation_defines/unitless/fieldBackground.unitless new file mode 100755 index 0000000000..7da2eb7ed0 --- /dev/null +++ b/src/picongpu/include/simulation_defines/unitless/fieldBackground.unitless @@ -0,0 +1,25 @@ +/** + * Copyright 2014 Axel Huebl + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + + +#pragma once + +/** Load pre-defined templates (implementation) */ +#include "fields/background/templates/TWTS/TWTS.tpp" diff --git a/src/picongpu/include/simulation_defines/unitless/gridConfig.unitless b/src/picongpu/include/simulation_defines/unitless/gridConfig.unitless index 114fd14d3d..39cc14d7bb 100644 --- a/src/picongpu/include/simulation_defines/unitless/gridConfig.unitless +++ b/src/picongpu/include/simulation_defines/unitless/gridConfig.unitless @@ -47,8 +47,4 @@ namespace picongpu const float_X INV_CELL2_SUM = 1.0 / ( CELL_WIDTH * CELL_WIDTH ); #endif - /* Courant-Friedrichs-Levy-Condition for Yee Field Solver: */ - PMACC_CASSERT_MSG(Courant_Friedrichs_Levy_condition_failure____check_your_gridConfig_param_file, - (SPEED_OF_LIGHT*SPEED_OF_LIGHT*DELTA_T*DELTA_T*INV_CELL2_SUM)<=1.0); - } diff --git a/src/picongpu/include/simulation_defines/unitless/radiationConfig.unitless b/src/picongpu/include/simulation_defines/unitless/radiationConfig.unitless index 669bac0ffb..6ca5be6304 100644 --- a/src/picongpu/include/simulation_defines/unitless/radiationConfig.unitless +++ b/src/picongpu/include/simulation_defines/unitless/radiationConfig.unitless @@ -1,5 +1,5 @@ /** - * Copyright 2013 Rene Widera, Richard Pausch + * Copyright 2013, 2015 Rene Widera, Richard Pausch * * This file is part of PIConGPU. * @@ -51,7 +51,6 @@ namespace picongpu { const float_X omega_min = (SI::omega_min*UNIT_TIME); const float_X omega_max = (SI::omega_max*UNIT_TIME); - //const numtype2 delta_omega_log = (numtype2) ((omega_log_max - omega_log_min) / (double) (N_omega - 1)); // difference beween two omega const unsigned int blocksize_omega = PMacc::math::CT::volume::type::value; const unsigned int gridsize_omega = N_omega / blocksize_omega; // size of grid (dim: x); radiation diff --git a/src/picongpu/include/simulation_types.hpp b/src/picongpu/include/simulation_types.hpp index ef818548f9..d23ba6c3a7 100644 --- a/src/picongpu/include/simulation_types.hpp +++ b/src/picongpu/include/simulation_types.hpp @@ -1,5 +1,5 @@ /** - * Copyright 2013 Axel Huebl, Felix Schmitt, Heiko Burau, Rene Widera + * Copyright 2013-2015 Axel Huebl, Felix Schmitt, Heiko Burau, Rene Widera * * This file is part of PIConGPU. * @@ -19,9 +19,9 @@ */ - #pragma once +#include "version.hpp" #include "algorithms/TypeCast.hpp" #include "algorithms/PromoteType.hpp" #include "algorithms/ForEach.hpp" @@ -47,8 +47,8 @@ enum ParticleType enum CommunicationTag { - FIELD_B = 0u, FIELD_E = 1u, FIELD_J = 2u, FIELD_TMP = 3u, - PAR_IONS = 4u, PAR_ELECTRONS = 5u, + FIELD_B = 0u, FIELD_E = 1u, FIELD_J = 2u, FIELD_JRECV = 3u, FIELD_TMP = 4u, + PAR_IONS = 5u, PAR_ELECTRONS = 6u, NO_COMMUNICATION = 16u }; diff --git a/src/picongpu/include/traits/Unit.hpp b/src/picongpu/include/traits/Unit.hpp index 10e58fb26e..25c7a380f3 100644 --- a/src/picongpu/include/traits/Unit.hpp +++ b/src/picongpu/include/traits/Unit.hpp @@ -31,7 +31,7 @@ namespace traits * * \tparam T_Identifier any picongpu identifier * \return \p std::vector ::get() as static public method - * + * * a zero-size vector with no specified unit is valid for unitless items * \see simulation_defines/unitless/speciesAttributes.unitless */ diff --git a/src/picongpu/include/traits/attribute/GetCharge.hpp b/src/picongpu/include/traits/attribute/GetCharge.hpp index c458f75b71..72803b5ae0 100644 --- a/src/picongpu/include/traits/attribute/GetCharge.hpp +++ b/src/picongpu/include/traits/attribute/GetCharge.hpp @@ -36,19 +36,19 @@ namespace detail /** Calculate the real charge of a particle * - * use attribute `boundElectrons` and the proton number from + * use attribute `boundElectrons` and the proton number from * flag `atomicNumbers` to calculate the charge - * + * * \tparam T_HasBoundElectrons boolean that describes if species allows multiple charge states * due to bound electrons */ template struct LoadBoundElectrons { - /** Functor implementation - * + /** Functor implementation + * * \tparam T_Particle particle type - * \param singlyChargedResult charge resulting from multiplying a single + * \param singlyChargedResult charge resulting from multiplying a single * electron charge (positive OR negative) by the macro particle weighting * \param particle particle reference */ @@ -64,17 +64,17 @@ struct LoadBoundElectrons /** Calculate the real charge of a particle * * This is the fallback implementation if no `boundElectrons` are available for a particle - * + * * \tparam T_HasBoundElectrons boolean that describes if species allows multiple charge states * due to bound electrons */ template<> struct LoadBoundElectrons { - /** Functor implementation - * + /** Functor implementation + * * \tparam T_Particle particle type - * \param singlyChargedResult charge resulting from multiplying a single + * \param singlyChargedResult charge resulting from multiplying a single * electron charge (positive OR negative) by the macro particle weighting * \param particle particle reference */ diff --git a/src/picongpu/include/traits/attribute/GetChargeState.hpp b/src/picongpu/include/traits/attribute/GetChargeState.hpp index 35aa9acffb..78035e5d91 100644 --- a/src/picongpu/include/traits/attribute/GetChargeState.hpp +++ b/src/picongpu/include/traits/attribute/GetChargeState.hpp @@ -42,7 +42,7 @@ template struct LoadChargeState { /** Functor implementation - * + * * \return chargeState = number of electrons in neutral atom - number of currently bound electrons */ template @@ -55,7 +55,7 @@ struct LoadChargeState /** Calculate charge state of an atom / ion * - * This is the fallback implementation to throw an error if no `boundElectrons` + * This is the fallback implementation to throw an error if no `boundElectrons` * are available for a species. */ template<> @@ -72,8 +72,8 @@ struct LoadChargeState /** get the charge state of a macro particle * - * This function trait considers the `boundElectrons` attribute if it is set. - * Charge states do not add up and also the various particles in a macro particle + * This function trait considers the `boundElectrons` attribute if it is set. + * Charge states do not add up and also the various particles in a macro particle * do NOT have different charge states where one would average over them. * * @param particle a reference to a particle diff --git a/src/picongpu/include/version.hpp b/src/picongpu/include/version.hpp new file mode 100644 index 0000000000..8bcc7b5384 --- /dev/null +++ b/src/picongpu/include/version.hpp @@ -0,0 +1,25 @@ +/** + * Copyright 2015 Axel Huebl + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + +#pragma once + +#define PICONGPU_VERSION_MAJOR 0 +#define PICONGPU_VERSION_MINOR 1 +#define PICONGPU_VERSION_PATCH 0 diff --git a/src/picongpu/main.cu b/src/picongpu/main.cu index 3ad7fe21f6..2b604df206 100644 --- a/src/picongpu/main.cu +++ b/src/picongpu/main.cu @@ -1,5 +1,5 @@ /** - * Copyright 2013 Axel Huebl, Felix Schmitt, Heiko Burau, Rene Widera + * Copyright 2013-2015 Axel Huebl, Felix Schmitt, Heiko Burau, Rene Widera * * This file is part of PIConGPU. * @@ -71,9 +71,13 @@ mallocMC::AlignmentPolicies::Shrink<> //use ScatterAllocator to replace malloc/free MALLOCMC_SET_ALLOCATOR_TYPE( ScatterAllocator ); +#include "ArgsParser.hpp" +#include "communication/manager_common.h" +#include "ArgsParser.hpp" + #include #include -#include "communication/manager_common.h" + using namespace PMacc; using namespace picongpu; @@ -88,17 +92,24 @@ int main(int argc, char **argv) MPI_CHECK(MPI_Init(&argc, &argv)); picongpu::simulation_starter::SimStarter sim; - if (!sim.parseConfigs(argc, argv)) - { - MPI_CHECK(MPI_Finalize()); - return 1; - } + ArgsParser::ArgsErrorCode parserCode = sim.parseConfigs(argc, argv); + int errorCode = 1; - sim.load(); - sim.start(); - sim.unload(); + switch(parserCode) + { + case ArgsParser::ERROR: + errorCode = 1; + break; + case ArgsParser::SUCCESS: + sim.load(); + sim.start(); + sim.unload(); + /*set error code to valid (1) after the simulation terminates*/ + case ArgsParser::SUCCESS_EXIT: + errorCode = 0; + break; + }; MPI_CHECK(MPI_Finalize()); - - return 0; + return errorCode; } diff --git a/src/picongpu/submit/hypnos/fermi_profile.tpl b/src/picongpu/submit/hypnos/fermi_profile.tpl index 1696a0061f..03c796b0e6 100644 --- a/src/picongpu/submit/hypnos/fermi_profile.tpl +++ b/src/picongpu/submit/hypnos/fermi_profile.tpl @@ -45,6 +45,7 @@ TBG_nodes="$(( ( TBG_tasks + TBG_gpusPerNode -1 ) / TBG_gpusPerNode))" # send me a mail on (b)egin, (e)nd, (a)bortion #PBS -m !TBG_mailSettings -M !TBG_mailAddress #PBS -d !TBG_dstPath +#PBS -n #PBS -o stdout #PBS -e stderr diff --git a/src/picongpu/submit/hypnos/k20_autoWait_profile.tpl b/src/picongpu/submit/hypnos/k20_autoWait_profile.tpl index 13d07ca460..edbe388641 100644 --- a/src/picongpu/submit/hypnos/k20_autoWait_profile.tpl +++ b/src/picongpu/submit/hypnos/k20_autoWait_profile.tpl @@ -1,22 +1,22 @@ #!/bin/bash # Copyright 2013-2014 Axel Huebl, Rene Widera, Richard Pausch -# -# This file is part of PIConGPU. -# -# PIConGPU is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# PIConGPU is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with PIConGPU. -# If not, see . -# +# +# This file is part of PIConGPU. +# +# PIConGPU is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# PIConGPU is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with PIConGPU. +# If not, see . +# ## calculation are done by tbg ## @@ -47,6 +47,7 @@ TBG_nodes="$(( ( TBG_tasks + TBG_gpusPerNode -1 ) / TBG_gpusPerNode))" # send me a mail on (b)egin, (e)nd, (a)bortion #PBS -m !TBG_mailSettings -M !TBG_mailAddress #PBS -d !TBG_dstPath +#PBS -n #PBS -W depend=afterany:!TBG_waitJob diff --git a/src/picongpu/submit/hypnos/k20_profile.tpl b/src/picongpu/submit/hypnos/k20_profile.tpl index d41ee76573..007101af4b 100644 --- a/src/picongpu/submit/hypnos/k20_profile.tpl +++ b/src/picongpu/submit/hypnos/k20_profile.tpl @@ -1,22 +1,22 @@ #!/bin/bash # Copyright 2013-2014 Axel Huebl, Anton Helm, Rene Widera -# -# This file is part of PIConGPU. -# -# PIConGPU is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# PIConGPU is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with PIConGPU. -# If not, see . -# +# +# This file is part of PIConGPU. +# +# PIConGPU is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# PIConGPU is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with PIConGPU. +# If not, see . +# ## calculation are done by tbg ## @@ -44,6 +44,7 @@ TBG_nodes="$(( ( TBG_tasks + TBG_gpusPerNode -1 ) / TBG_gpusPerNode))" # send me a mail on (b)egin, (e)nd, (a)bortion #PBS -m !TBG_mailSettings -M !TBG_mailAddress #PBS -d !TBG_dstPath +#PBS -n #PBS -o stdout #PBS -e stderr diff --git a/src/picongpu/submit/hypnos/k20_vampir_profile.tpl b/src/picongpu/submit/hypnos/k20_vampir_profile.tpl index 285cd8c3db..3988a574e3 100644 --- a/src/picongpu/submit/hypnos/k20_vampir_profile.tpl +++ b/src/picongpu/submit/hypnos/k20_vampir_profile.tpl @@ -1,22 +1,22 @@ #!/bin/bash # Copyright 2013-2014 Axel Huebl, Anton Helm, Rene Widera -# -# This file is part of PIConGPU. -# -# PIConGPU is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# PIConGPU is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with PIConGPU. -# If not, see . -# +# +# This file is part of PIConGPU. +# +# PIConGPU is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# PIConGPU is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with PIConGPU. +# If not, see . +# ## calculation are done by tbg ## @@ -44,6 +44,7 @@ TBG_nodes="$(( ( TBG_tasks + TBG_gpusPerNode -1 ) / TBG_gpusPerNode))" # send me a mail on (b)egin, (e)nd, (a)bortion #PBS -m !TBG_mailSettings -M !TBG_mailAddress #PBS -d !TBG_dstPath +#PBS -n #PBS -o stdout #PBS -e stderr diff --git a/src/picongpu/submit/hypnos/k20_wait_profile.tpl b/src/picongpu/submit/hypnos/k20_wait_profile.tpl index a4f2d95b40..47de3e90a6 100644 --- a/src/picongpu/submit/hypnos/k20_wait_profile.tpl +++ b/src/picongpu/submit/hypnos/k20_wait_profile.tpl @@ -1,22 +1,22 @@ #!/bin/bash # Copyright 2013-2014 Axel Huebl, Rene Widera, Richard Pausch -# -# This file is part of PIConGPU. -# -# PIConGPU is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# PIConGPU is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with PIConGPU. -# If not, see . -# +# +# This file is part of PIConGPU. +# +# PIConGPU is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# PIConGPU is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with PIConGPU. +# If not, see . +# ## calculation are done by tbg ## @@ -44,6 +44,7 @@ TBG_nodes="$(( ( TBG_tasks + TBG_gpusPerNode -1 ) / TBG_gpusPerNode))" # send me a mail on (b)egin, (e)nd, (a)bortion #PBS -m !TBG_mailSettings -M !TBG_mailAddress #PBS -d !TBG_dstPath +#PBS -n #PBS -W depend=afterany:!TBG_waitJob diff --git a/src/picongpu/submit/hypnos/k80_profile.tpl b/src/picongpu/submit/hypnos/k80_profile.tpl new file mode 100644 index 0000000000..2b2ec394db --- /dev/null +++ b/src/picongpu/submit/hypnos/k80_profile.tpl @@ -0,0 +1,79 @@ +#!/bin/bash +# Copyright 2013-2015 Axel Huebl, Anton Helm, Rene Widera +# +# This file is part of PIConGPU. +# +# PIConGPU is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# PIConGPU is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with PIConGPU. +# If not, see . +# + + +## calculation are done by tbg ## +TBG_queue="k80" +TBG_mailAddress=${MY_MAIL:-"someone@example.com"} +TBG_mailSettings=${MY_MAILNOTIFY:-"n"} + +# 8 gpus per node if we need more than 8 gpus else same count as TBG_tasks +TBG_gpusPerNode=`if [ $TBG_tasks -gt 8 ] ; then echo 8; else echo $TBG_tasks; fi` + +#number of cores per parallel node / default is 2 cores per gpu on k20 queue +TBG_coresPerNode="$(( TBG_gpusPerNode * 2 ))" + +# use ceil to caculate nodes +TBG_nodes="$(( ( TBG_tasks + TBG_gpusPerNode -1 ) / TBG_gpusPerNode))" +## end calculations ## + +# PIConGPU batch script for hypnos PBS batch system + +#PBS -q !TBG_queue +#PBS -l walltime=!TBG_wallTime +# Sets batch job's name +#PBS -N !TBG_jobName +#PBS -l nodes=!TBG_nodes:ppn=!TBG_coresPerNode +# send me a mail on (b)egin, (e)nd, (a)bortion +#PBS -m !TBG_mailSettings -M !TBG_mailAddress +#PBS -d !TBG_dstPath +#PBS -n + +#PBS -o stdout +#PBS -e stderr + +echo 'Running program...' + +cd !TBG_dstPath + +export MODULES_NO_OUTPUT=1 +source ~/picongpu.profile +if [ $? -ne 0 ] ; then + echo "Error: ~/picongpu.profile not found!" + exit 1 +fi +unset MODULES_NO_OUTPUT + +#set user rights to u=rwx;g=r-x;o=--- +umask 0027 + +mkdir simOutput 2> /dev/null +cd simOutput + +#wait that all nodes see ouput folder +sleep 1 + +mpiexec --prefix $MPIHOME -tag-output --display-map -x LIBRARY_PATH -x LD_LIBRARY_PATH -am !TBG_dstPath/tbg/openib.conf --mca mpi_leave_pinned 0 -npernode !TBG_gpusPerNode -n !TBG_tasks !TBG_dstPath/picongpu/bin/cuda_memtest.sh + +if [ $? -eq 0 ] ; then + mpiexec --prefix $MPIHOME -x LIBRARY_PATH -x LD_LIBRARY_PATH -tag-output --display-map -am !TBG_dstPath/tbg/openib.conf --mca mpi_leave_pinned 0 -npernode !TBG_gpusPerNode -n !TBG_tasks !TBG_dstPath/picongpu/bin/picongpu !TBG_programParams +fi + +mpiexec --prefix $MPIHOME -x LIBRARY_PATH -x LD_LIBRARY_PATH -npernode !TBG_gpusPerNode -n !TBG_tasks killall -9 picongpu diff --git a/src/picongpu/submit/hypnos/picongpu.profile.example b/src/picongpu/submit/hypnos/picongpu.profile.example index ff087a40c8..c14781cbed 100755 --- a/src/picongpu/submit/hypnos/picongpu.profile.example +++ b/src/picongpu/submit/hypnos/picongpu.profile.example @@ -10,17 +10,16 @@ then # Core Dependencies module load gcc/4.6.2 module load cmake/3.0.1 - module load openmpi/1.6.3 module load boost/1.54.0 module load cuda/6.5 - module load mallocmc/2.0.1 + module load openmpi/1.8.4.kepler # Plugins (optional) module load pngwriter/0.5.4 - module load hdf5-parallel/1.8.14 libsplash/1.2.3 + module load hdf5-parallel/1.8.14 libsplash/1.2.4 # either use libSplash or ADIOS for file I/O - #module load libmxml/2.8 filelib/adios/1.7.0 + #module load libmxml/2.8 adios/1.8.0 # Debug Tools #module load valgrind/3.8.1 diff --git a/src/tools/bin/LineSliceFields.sh b/src/tools/bin/LineSliceFields.sh deleted file mode 100755 index f155a2e08a..0000000000 --- a/src/tools/bin/LineSliceFields.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/bash -# -# Copyright 2013 Axel Huebl -# -# This file is part of PIConGPU. -# -# PIConGPU is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# PIConGPU is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with PIConGPU. -# If not, see . -# - -if test ! -d "$1"; then - echo "$1 is not a directory" - echo "Usage:" - echo " $0 pathTolineSliceFieldFiles TIMESTEP [noPlot]" - exit 1 -fi - -initCall="$0 $*" -bindir=`dirname $0`/ - -script=`cat $bindir/../share/gnuplot/LineSliceFields.gnuplot` - -tmp1=`echo $1 | sed 's/\//\\\\\//g'` -tmp2=`echo $2 | sed 's/\//\\\\\//g'` - -script=`echo "$script" | sed -e "s/PATH/"$tmp1"/g" | sed -e "s/TIMESTEP/"$tmp2"/g"` - -rm -f $1/LSF_unsorted.dat $1/LSF.dat -export LC_NUMERIC=. - -for i in $1lineSliceFields_*.txt -do -# cat $i | grep "^$2 " | grep -v "^.* .* .* 0 0 0" - cat $i | grep "^$2 " >> $1/LSF_unsorted.dat -# cat $i | grep "^$2 " >> $1/LSF.dat -done - -sort -gsk3 $1/LSF_unsorted.dat > $1/LSF.dat - -############################ -# FWHM Analyser -intenssum=`cat $1/LSF.dat | awk 'BEGIN{t=0.0} { t+=($4*$4) } END{printf("%.8e\n", t)}'` -intensmax=`cat $1/LSF.dat | awk 'BEGIN{t=0.0} { if(($4*$4)>t) t=($4*$4) } END{printf("%.8e\n", t)}'` -# with percentage (model perfect gaussian) -leftsigma=`cat $1/LSF.dat | awk -v max=$intenssum 'BEGIN{t=0.0; x=0.0} { t+=($4*$4); if(t/max>=0.15865 && x==0.0) x=$3 } END{printf("%.8e\n", x)}'` -rightsigma=`cat $1/LSF.dat | awk -v max=$intenssum 'BEGIN{t=0.0; x=0.0} { t+=($4*$4); if(t/max>=0.84135 && x==0.0) x=$3 } END{printf("%.8e\n", x)}'` - -# in meters -twosigma=`echo "$rightsigma $leftsigma" | awk '{printf("%.8e\n", ($1-$2) )}'` -fwhm=`echo "$twosigma" | awk '{printf("%.8e\n", ($1*1.177410023) )}'` -# in seconds -sigmas=`echo "$twosigma" | awk '{printf("%.8e\n", ($1/2.0/299792458.0) )}'` -fwhms=`echo "$fwhm" | awk '{printf("%.8e\n", ($1/299792458.0) )}'` -err=`echo "$lambda" | awk '{printf("%.8e\n", ($1/299792458.0/2.0) )}'` - -echo "intensmax: $intensmax [V^2/m^2]" -echo "sigma: $sigmas [s]" -echo "fwhm: $fwhms [s]" -echo "+/- O($err [s] ) error: (integrate over lamda/2)" - -#g++ LineSliceFieldsAnalyser.cpp -I../../libgpugrid/include -o LineSliceFieldsAnalyser.o -#./LineSliceFieldsAnalyser.o $1/LSF.dat -#echo "+/- O( 2% ) (some kind of low pass)" - -python LineSliceFieldsAnalyserFFT.py $1/LSF.dat - -############################ -# GnuPlot -if test -z "$3"; then - echo -e "$script" | gnuplot -persist -fi \ No newline at end of file diff --git a/src/tools/bin/LineSliceFieldsAnalyserFFT.py b/src/tools/bin/LineSliceFieldsAnalyserFFT.py deleted file mode 100644 index 2009165659..0000000000 --- a/src/tools/bin/LineSliceFieldsAnalyserFFT.py +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2013 Richard Pausch -# -# This file is part of PIConGPU. -# -# PIConGPU is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# PIConGPU is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with PIConGPU. -# If not, see . -# - -"""Fourier Transformation of data""" - - -from numpy import * -#from matplotlib import pyplot as plt -from scipy.fftpack import fft, ifft -from scipy import optimize - -import sys - -lambda_central = 800.0e-9 / 2.0 -pulse_len_should = 20.0e-15 / 2.35482 - -delta_omega_rel = 5.0 -c = 299792458.0 - -f_central = c / lambda_central -omega_central = 2.0 * pi * f_central - -# load data -tempdata = loadtxt(sys.argv[1], usecols=(2,3)) - -x_data=tempdata[:,0] -data=tempdata[:,1] -data *= data - -delta_x = x_data[2] - x_data[1] -delta_t = ( delta_x ) / c -#print "dx = ", delta_x -#print "dt = ", delta_t - -N = len(data) -#print("Number of data points: %d" % N) - -#plt.figure(0, figsize=(18,8)) # definiert Grafikfenster - -#plt.subplot(111, autoscale_on=True) # mittiger Plot -#plt.title("Fourier Coefficients") -#plt.xlabel(r"$\omega = 2\cdot\pi\cdot f$") -#plt.ylabel(r"$c_n$") - -# interesting window in frequency -omega_min = omega_central / delta_omega_rel -omega_max = omega_central * delta_omega_rel -delta_omega = 2.0*pi/(N*delta_t) -n_min = floor(omega_min / delta_omega) -n_max = ceil(omega_max / delta_omega) - -omega = arange(N)*delta_omega -fft_data = abs(fft(data)) - -#plt.plot(omega[n_min:n_max], fft_data[n_min:n_max] -# , marker='o', linestyle='None', color='r', label="FFT") - # zeichnet FFT-Koeffizienten fuer Funktion 1 - -#plt.show() - - -# fit data -class Parameter: - def __init__(self, value): - self.value = value - - def set(self, value): - self.value = value - - def __call__(self): - return self.value - -def fit(function, parameters, y, x = None): - def f(params): - i = 0 - for p in parameters: - p.set(params[i]) - i += 1 - return y - function(x) - - if x is None: x = arange(y.shape[0]) - p = [param() for param in parameters] - return optimize.leastsq(f, p) - - -# giving initial parameters -mu = Parameter(omega_central) -sigma = Parameter(1.0 / sqrt(2.0) / pulse_len_should * 2.0) -height = Parameter(fft_data[n_min:n_max].max()) -#print "sigma_start =", sigma() - -# define your function: -def f(x): return height() * exp(-((x-mu())/sigma())**2) -def f2(x,m,s,h): return h * exp(-((x-m)/s)**2) - -# fit! (given that data is an array with the data to fit) -fitted = fit(f, [mu, sigma, height], fft_data[n_min:n_max], omega[n_min:n_max]) - -fitted2 = optimize.curve_fit(f2, omega[n_min:n_max], fft_data[n_min:n_max], [mu(), sigma(), height()]) - -sigma_omega = fitted[0][1] -#print "sigma_omega =", fitted[0][1] -sigma_freq = fitted[0][1]/2.0/pi -#print "sigma_freq =", sigma_freq, "[Hz]" - -sigma_t = 1.0 / sqrt(2.0) / sigma_omega * 2.0 -print "sigma_fft: ", sigma_t, "[s]" -print "fwhm_fft: ", sigma_t * 2.354820045, "[s]" diff --git a/src/tools/bin/addLicense b/src/tools/bin/addLicense index 1d219efcf5..4bd51a808a 100755 --- a/src/tools/bin/addLicense +++ b/src/tools/bin/addLicense @@ -64,7 +64,7 @@ text=' *\ * This file is part of '"$projectName"'.\ *\ * '"$projectName"' is free software: you can redistribute it and/or modify\ - * it under the terms of of either the GNU General Public License or\ + * it under the terms of either the GNU General Public License or\ * the GNU Lesser General Public License as published by\ * the Free Software Foundation, either version 3 of the License, or\ * (at your option) any later version.\ diff --git a/src/tools/bin/egetopt b/src/tools/bin/egetopt index dc3ff1f77a..e9f7d62c22 100755 --- a/src/tools/bin/egetopt +++ b/src/tools/bin/egetopt @@ -45,17 +45,31 @@ help() echo "NOT SUPPORTED:" echo ' - begin an option with `+`' echo ' - abbreviations of getopt `longoptions`' + echo ' - `--longoption="something with spaces"`' + echo ' use `--longoption "something with spaces"` instead' + echo ' - `-shortoption"something with spaces"`' + echo ' use `-shortoption "something with spaces"` instead' echo "" echo "" echo 'output of `getopt` help:' getopt -h 2>&1 } +# wrap all non option arguments with single quotes +for i in "$@" +do + if [[ "$i" == "++" ]] || [[ "$i" =~ ^- ]] ; then + egetoptOpts+="$i " + else + egetoptOpts+="'$i' " + fi +done + # arguments for getopt -egetOptArgs=`echo $* | sed 's/++.*$//g'` +egetOptArgs=`echo $egetoptOpts | sed 's/++.*$//g'` # user arguments -userArgs=`echo $* | sed 's/^.*++//g'` - +userArgs=`echo $egetoptOpts | sed 's/^.*++//g'` + # evaluate options for getopt OPTS=`getopt -o o:l:n:qhV -l help,options:,longoptions:version -- $egetOptArgs` eval set -- "$OPTS" @@ -123,7 +137,7 @@ while true ; do theShortOpt=`echo $1 | tr -d "-"` if [ $# -ge $nonOptionCheck ] && [[ $shortDef =~ $theShortOpt: ]] ; then # append argument to option - transformedArgs+="$2" + transformedArgs+="'$2'" shift fi # transform long option if no argument with `=` is set @@ -131,7 +145,7 @@ while true ; do theLongOpt=`echo $1 | sed 's/--//g'` if [ $# -ge $nonOptionCheck ] && [[ $longDef =~ $theLongOpt: ]] ; then # append argument to option - transformedArgs+="=$2" + transformedArgs+="='$2'" shift fi elif [[ ! $1 =~ ^-- ]] && [[ ! $1 =~ ^-.*$ ]] ; then @@ -149,4 +163,4 @@ while true ; do shift done -getopt $getOptArgs -- $transformedArgs +echo "getopt $getOptArgs -- $transformedArgs" | bash diff --git a/src/tools/bin/plotDensity b/src/tools/bin/plotDensity deleted file mode 100755 index 16bc396086..0000000000 --- a/src/tools/bin/plotDensity +++ /dev/null @@ -1,127 +0,0 @@ -#!/bin/bash -# -# Copyright 2013 Axel Huebl, Rene Widera -# -# This file is part of PIConGPU. -# -# PIConGPU is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# PIConGPU is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with PIConGPU. -# If not, see . -# - -help() -{ - echo "plotDensity plot density of particles from binary picongpu density data" - echo "" - echo "usage: plotDensity [OPTION] dataFile" - echo "" - echo "-i - start interactiv gnuplot session" - echo "-x - set description for x axis" - echo "-y - set description for x axis" - echo "-o filename - name of the png picture (etc. test.png)" - echo "" - echo "--png resolution - create png with resolution (etc. 1920x1080)" - echo "--max value - maximum value in color bar, if not set auto scaling is used" -} - - -initCall="$0 $*" - -bindir=`dirname $0`/ - -png=0 -interactive=0 -max_color=0 -X_AXIS="x" -Y_AXIS="y" - -if [ $# -eq 0 ] ; then - echo "No parameters are set" >&2 - echo -e "$(help)" - exit 1; -fi - -# options may be followed by one colon to indicate they have a required argument -OPTS=`getopt -o ix:y:o:h -l png:,max:,help -- "$@"` -if [ $? != 0 ] ; then - # something went wrong, getopt will put out an error message for us - exit 1 -fi - -eval set -- "$OPTS" - -while true ; do - case "$1" in - -i) - interactive=1 - ;; - -x) - X_AXIS="$2" - shift - ;; - -y) - Y_AXIS="$2" - shift - ;; - --png) - tmp="$2" ; - X_RESOLUTION=`echo $tmp | cut -d"x" -f1` ; - Y_RESOLUTION=`echo $tmp | cut -d"x" -f2` ; - png=1; - shift ; - ;; - --max) - max_color="$2" - if [ -z "$max_color" ] ; then - echo "No maximal value for color bar is given" >&2 - exit 1; - fi - shift - ;; - -o) - OUTFILE="$2" - if [ -z "$OUTFILE" ] ; then - echo "No output file is set" >&2 - exit 1; - fi - shift - ;; - -h|--help) - echo -e "$(help)" - exit 1 - ;; - --) shift; break;; - - esac - shift -done - -INFILE="$*" - -if [ -z "$INFILE" ] ; then - echo "No input file is given" >&2 - exit 1; -fi - -if [ $png -eq 1 ] && [ -z "$OUTFILE" ] ; then - echo "PNG output is selected but no output file is set." >&2 - exit 1; -fi - -if [ $png -eq 1 ] ; then - Y_RESOLUTION=$Y_RESOLUTION X_RESOLUTION=$X_RESOLUTION X_AXIS=$X_AXIS Y_AXIS=$Y_AXIS INFILE=$INFILE OUTFILE=$OUTFILE COLORMAX=$max_color gnuplot $bindir/../share/gnuplot/density.png.gnuplot -fi - -if [ $interactive -eq 1 ] ; then - COLORMAX=$max_color X_AXIS=$X_AXIS Y_AXIS=$Y_AXIS INFILE=$INFILE gnuplot $bindir/../share/gnuplot/density.interactive.gnuplot -fi diff --git a/src/tools/bin/plotNumericalHeating b/src/tools/bin/plotNumericalHeating index 7740043c54..03a022bc7a 100755 --- a/src/tools/bin/plotNumericalHeating +++ b/src/tools/bin/plotNumericalHeating @@ -114,7 +114,7 @@ for sim in directories: mydir = sim+simDir # get relevant files with energy files = [f for f in os.listdir(mydir) - if os.path.isfile(os.path.join(mydir, f)) and re.search('^Energy.*.dat', f)] + if os.path.isfile(os.path.join(mydir, f)) and re.search('^.*_energy.dat', f)] # check if file list is empty if len(files) == 0: sys.exit("There were no energy files in \"{}\".".format(mydir)) @@ -159,9 +159,9 @@ if numDir == 2: time_limit = i+1 else: break - if time_limit == 0: - # if no time step is equal stop program - sys.exit("Time steps between sim1 and sim2 differ from start.") + if time_limit == 0: + # if no time step is equal stop program + sys.exit("Time steps between sim1 and sim2 differ from start.") elif numDir == 1: time_limit = len(Times[0]) else: @@ -169,26 +169,44 @@ else: ## get values ## -startEnergy = Energies[0][0] - +startEnergy = Energies[:][0] ## plot numerical heating ## # choose normalization if args.boolRelative: - norm = 100. / startEnergy # relative to startEnergy in percent + norm = 100. / startEnergy[0] # relative to startEnergy in percent else: norm = 1.0 # absolute values if not args.boolDiff: - # plot energy evolution side by side + # plot energy evolution plt.plot(Times[0][:time_limit], - (Energies[0][:time_limit]-startEnergy)*norm, + (Energies[0][:time_limit]-startEnergy[0])*norm, color="green", lw=3, label=args.label1) if numDir == 2: + # True is deviation of branch to init energy is less than of dev + branch_better = (np.abs(Energies[0][:time_limit]-startEnergy[0]) + > np.abs(Energies[1][:time_limit]-startEnergy[1])) + + # branch is closer to initial energy than dev + plt.fill_between(Times[1][:time_limit], + (Energies[0][:time_limit]-startEnergy[0])*norm, + (Energies[1][:time_limit]-startEnergy[0])*norm, + where=branch_better, + color="orange", alpha=0.8) + + # dev is closer to initial energy than branch + plt.fill_between(Times[1][:time_limit], + (Energies[0][:time_limit]-startEnergy[0])*norm, + (Energies[1][:time_limit]-startEnergy[0])*norm, + where=np.logical_not(branch_better), + color="red", alpha=0.7) + + # plot second energy evolution plt.plot(Times[1][:time_limit], - (Energies[1][:time_limit]-startEnergy)*norm, - "--", color="blue", lw=5, label=args.label2) + (Energies[1][:time_limit]-startEnergy[0])*norm, + color="blue", lw=2, label=args.label2) if args.boolRelative: plt.ylabel(r"$\frac{E}{E_0}-1\,[\%]$", fontsize=24) else: diff --git a/src/tools/bin/tbg b/src/tools/bin/tbg index f5d29c915a..bb9388a9a8 100755 --- a/src/tools/bin/tbg +++ b/src/tools/bin/tbg @@ -297,6 +297,10 @@ job_relative_dir=`dirname "$outDir"` #create relative dir that we can jump in and check absolute dir mkdir -p "$job_relative_dir" +if [ $? -ne 0 ] ; then + echo "Could not create directory in: $job_relative_dir" >&2 + exit 1 +fi job_outDir=`cd "$job_relative_dir"; pwd`"/$job_name" if [ -z "$tooltpl_file" ] ; then @@ -326,6 +330,10 @@ export TBG_projectPath="$projectPath" export TBG_dstPath="$job_outDir" mkdir -p "$job_outDir" +if [ $? -ne 0 ] ; then + echo "Could not create directory in: $job_outDir" >&2 + exit 1 +fi mkdir -p "$job_outDir/tbg" cd "$job_outDir" diff --git a/src/tools/bin/uncrustifyMyCode b/src/tools/bin/uncrustifyMyCode new file mode 100755 index 0000000000..3b023f014c --- /dev/null +++ b/src/tools/bin/uncrustifyMyCode @@ -0,0 +1,57 @@ +#!/bin/bash +# Copyright 2015 Rene Widera +# +# This file is part of PIConGPU. +# +# PIConGPU is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# PIConGPU is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with PIConGPU. +# If not, see . +# + + +# This tool runs uncrustify with the style file `picongpu_uncrustify.cfg` from +# the `doc` folder on one file + +#example: for i in `echo "*.def *.h *.cpp *.cu *.hpp *.tpp *.kernel *.loader *.param *.unitless"` ; do findAndDo src/picongpu "$i" uncrustifyMyCode ; done + +function usage() +{ + echo "Usage:" + echo " uncrustifyMyCode [-h] filename" + echo + echo " -h - show usage" + echo " filename - file to uncrustify" +} + + +fileName=$1 + +if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then + usage 1>&2 + exit 1 +fi + +# check whether the first argument is a file +if test ! -f "$fileName" ; then + echo "\"$fileName\" is not a file" >&2 + echo " " >&2 + usage 1>&2 + exit 1 +fi + +toolsDir=`dirname $0` +docDir="$toolsDir/../../../doc/" + +uncrustify -c "$docDir/picongpu_uncrustify.cfg" --replace --no-backup -q $fileName + +exit 0 diff --git a/src/tools/livevis/client/.gitignore b/src/tools/livevis/client/.gitignore new file mode 100644 index 0000000000..66c5c3afef --- /dev/null +++ b/src/tools/livevis/client/.gitignore @@ -0,0 +1,17 @@ +# tmp files +*~ +moc_* +ui_*.h +qrc_*.cpp +*.o + +# netbeans project files +/nbproject/ + +# Code::Blocks project files +/*.cbp +/*.layout + +# python byte code +*.pyc + diff --git a/src/tools/livevis/client/README.md b/src/tools/livevis/client/README.md new file mode 100644 index 0000000000..037a725261 --- /dev/null +++ b/src/tools/livevis/client/README.md @@ -0,0 +1,49 @@ +InSitu Client (Keyboard Edition) +================================ + +The keyboard/mouse controlled edition of the live visualization client. + +### Prepare Environment + +- install rivlib (and vislib/thelib) +- set environment vars + +```bash +export RIVLIB_ROOT= +export VISLIB_ROOT=$RIVLIB_ROOT +export THELIB_ROOT=$RIVLIB_ROOT +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$RIVLIB_ROOT/lib +``` + +### Configure and Build + +Use Qt4! + +```bash +# sudo apt-get install qt4-default qt4-qmake +qmake-qt4 SimpleUIVisClient.pro +make +``` + +On *Hypnos*: +```bash +module load qt/4.8.2 +which qmake # version 4 ok? path ok? +qmake SimpleUIVisClient.pro +make +``` + + +### Run + +```bash +./SimpleUIVisClient +``` + + +### LICENSE + +This tool is part of PIConGPU and licensed accordingly under GPLv3+. + +It contains parts of the `PictureFlow` Qt widget from Ariya Hadayat under the +MIT license, see http://pictureflow.googlecode.com diff --git a/src/tools/livevis/client/SimpleUIVisClient.pro b/src/tools/livevis/client/SimpleUIVisClient.pro new file mode 100644 index 0000000000..db77539805 --- /dev/null +++ b/src/tools/livevis/client/SimpleUIVisClient.pro @@ -0,0 +1,92 @@ +# Copyright 2013-2015 Benjamin Schneider, Axel Huebl, Rene Widera +# +# This file is part of PIConGPU. +# +# PIConGPU is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# PIConGPU is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with PIConGPU. +# If not, see . +# + +#------------------------------------------------- +# +# Project created by QtCreator 2013-08-27T16:21:56 +# +#------------------------------------------------- + +QT += core gui opengl + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = SimpleUIVisClient +TEMPLATE = app +ONFIG += c++11 +QMAKE_CXXFLAGS += -std=c++0x -DUSE_MJPEG=1 + + +SOURCES += main.cpp\ + mainwindow.cpp \ + glwidget.cpp \ + simulationgallery.cpp \ + pictureflow.cpp \ + clickablelabel.cpp \ + udpquery.cpp \ + transferfunctions.cpp \ + verboselabel.cpp \ + camera.cpp + +HEADERS += mainwindow.h \ + glwidget.h \ + message_ids.hpp \ + simulationgallery.h \ + pictureflow.h \ + clickablelabel.h \ + udpquery.h \ + transferfunctions.h \ + verboselabel.h \ + camera.h \ + math_helper.h + +FORMS += mainwindow.ui \ + simulationgallery.ui + + +unix:!macx: LIBS += -L$$(RIVLIB_ROOT)/lib -lrivlib + +INCLUDEPATH += $$(RIVLIB_ROOT)/include +DEPENDPATH += $$(RIVLIB_ROOT)/include + +unix:!macx: LIBS += -L$$(VISLIB_ROOT)/lib/ -lvislibbase64 + +INCLUDEPATH += $$(VISLIB_ROOT)/base/include/vislib +DEPENDPATH += $$(VISLIB_ROOT)/base/include/vislib + +unix:!macx: PRE_TARGETDEPS += $$(VISLIB_ROOT)/lib/libvislibbase64.a + +unix:!macx: LIBS += -L$$(VISLIB_ROOT)/lib/ -lvislibsys64 + +INCLUDEPATH += $$(VISLIB_ROOT)/sys/include +DEPENDPATH += $$(VISLIB_ROOT)/sys/include + +unix:!macx: PRE_TARGETDEPS += $$(VISLIB_ROOT)/lib/libvislibsys64.a + +unix:!macx: LIBS += -L$$(THELIB_ROOT)/lib -lthelib + +INCLUDEPATH += $$(THELIB_ROOT)/include +DEPENDPATH += $$(THELIB_ROOT)/include + +LIBS += -lGLU + +OTHER_FILES += + +RESOURCES += \ + icons.qrc diff --git a/src/tools/livevis/client/camera.cpp b/src/tools/livevis/client/camera.cpp new file mode 100644 index 0000000000..fdb76410b6 --- /dev/null +++ b/src/tools/livevis/client/camera.cpp @@ -0,0 +1,22 @@ +/** + * Copyright 2013 Benjamin Schneider + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + +#include "camera.h" + diff --git a/src/tools/livevis/client/camera.h b/src/tools/livevis/client/camera.h new file mode 100644 index 0000000000..a8d9c27cc8 --- /dev/null +++ b/src/tools/livevis/client/camera.h @@ -0,0 +1,145 @@ +/** + * Copyright 2013 Benjamin Schneider + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + +#ifndef CAMERA_H +#define CAMERA_H + +#include "math_helper.h" + +/** + * Simple 3D Camera class. Stores the camera position and look at point + * as well as the field of view and aspect ratio. + */ +class Camera +{ +public: + + Camera(float3 pos, float3 target) + : m_position(pos), + m_focalPoint(target), + m_up(float3(0,1,0)) + { } + + float3 getPosition() { return m_position; } + float3 getFocalPoint() { return m_focalPoint; } + float3 getUp() { return m_up; } + + void setPosition(float3 pos) { m_position = pos; } + void setFocalPoint(float3 focus) { m_focalPoint = focus; } + void setUp(float3 up) { m_up = up; } + + /** + * Moves the camera and the focal point by the same vector along the local camera axes. + * Useful for following the sliding simulation window. + */ + void slide(float3 offset) + { + float4x4 invView = this->getInvViewMatrix(); + + float3 move = float3(invView * float4(offset.x, offset.y, offset.z, 0.0f)); + + m_position += move; + m_focalPoint += move; + } + + /** + * Moves the camera and the focal point by the same vector along the world axes. + * Useful for following the sliding simulation window. + */ + void follow(float3 offset) + { + m_position += offset; + m_focalPoint += offset; + } + + /** + * Moves the camera towards or away from the focal point. + * + * @param amount A value in the range [0;1] will move the camera towards the focal point. + * A value greater one will move the camera away from the focal point. + */ + void dolly(float amount) + { + if (amount < 0.000001f) return; + + float3 dir = m_focalPoint - m_position; + float dolly = sqrt(dir.x * dir.x + dir.y * dir.y + dir.z * dir.z) / amount; + + m_position = m_focalPoint - (normalize(dir) * dolly); + } + + /** + * Rotates the camera around its focal point on all three axes. + * + * @param yaw The rotation around the Y axis in degree. + * @param pitch The rotation around the X axis in degree. + * @param roll The rotation around the Z axis in degree. + */ + void orbitYawPitchRoll(float yaw, float pitch, float roll) + { + float3 fp_to_cam = m_position - m_focalPoint; + float3 dir = normalize(fp_to_cam); + float3 right = normalize(cross(m_up, dir)); + float3 up = normalize(cross(dir, right)); + + float4x4 rot_yaw = float4x4::make_rotation_around_axis(up, yaw); + float4x4 rot_pitch = float4x4::make_rotation_around_axis(right, pitch); + float4x4 rot_roll = float4x4::make_rotation_around_axis(dir, roll); + + float3 newpos = float3( (rot_yaw * rot_pitch * rot_roll) * float4(fp_to_cam.x, fp_to_cam.y, fp_to_cam.z, 1.0f) ); + + m_position = m_focalPoint + newpos; + } + + /** + * Orbit the focal point around the camera position to pan the camera. + * + * @param yaw The rotation around the Y axis. + * @param pitch The rotation around the X axis. + */ + void panYawPitch(float yaw, float pitch) + { + float3 zaxis = normalize(m_position - m_focalPoint); + float3 xaxis = normalize(cross(m_up, zaxis)); + float3 yaxis = normalize(cross(zaxis, xaxis)); + + float4x4 rot_yaw = float4x4::make_rotation_around_axis(yaxis, yaw); + float4x4 rot_pitch = float4x4::make_rotation_around_axis(xaxis, pitch); + + m_focalPoint = float3( (rot_yaw * rot_pitch) * float4(m_focalPoint.x, m_focalPoint.y, m_focalPoint.z, 1.0f) ); + } + + /** + * Returns the inverse view matrix. This is useful to construct rays. + */ + float4x4 getInvViewMatrix() + { + return float4x4::make_inv_view(m_position, m_focalPoint, m_up); + } + +private: + + /// TODO: add aspect ratio and field of view to construct rays correctly for non square images. + float3 m_position; + float3 m_focalPoint; + float3 m_up; +}; + +#endif // CAMERA_H diff --git a/src/tools/livevis/client/clickablelabel.cpp b/src/tools/livevis/client/clickablelabel.cpp new file mode 100644 index 0000000000..99a730c2b0 --- /dev/null +++ b/src/tools/livevis/client/clickablelabel.cpp @@ -0,0 +1,31 @@ +/** + * Copyright 2013 Benjamin Schneider + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + +#include "clickablelabel.h" + +ClickableLabel::ClickableLabel(QWidget * parent) : + QLabel(parent) +{ +} + +void ClickableLabel::mouseReleaseEvent(QMouseEvent * ev) +{ + emit clicked(); +} diff --git a/src/tools/livevis/client/clickablelabel.h b/src/tools/livevis/client/clickablelabel.h new file mode 100644 index 0000000000..e55d7f4015 --- /dev/null +++ b/src/tools/livevis/client/clickablelabel.h @@ -0,0 +1,45 @@ +/** + * Copyright 2013 Benjamin Schneider + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + +#ifndef CLICKABLELABEL_H +#define CLICKABLELABEL_H + +#include + +class ClickableLabel : public QLabel +{ + Q_OBJECT + +public: + explicit ClickableLabel(QWidget * parent = 0); + +signals: + + void clicked(); + +public slots: + +protected: + + void mouseReleaseEvent(QMouseEvent * ev); + +}; + +#endif // CLICKABLELABEL_H diff --git a/src/tools/livevis/client/datasourcesidebar.cpp b/src/tools/livevis/client/datasourcesidebar.cpp new file mode 100644 index 0000000000..8fc4e0eade --- /dev/null +++ b/src/tools/livevis/client/datasourcesidebar.cpp @@ -0,0 +1,46 @@ +/** + * Copyright 2013 Benjamin Schneider + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + +#include "datasourcesidebar.h" +#include "ui_datasourcesidebar.h" + +#include +#include +#include + +DataSourceSidebar::DataSourceSidebar(QWidget *parent) : + QWidget(parent), + ui(new Ui::DataSourceSidebar) +{ + ui->setupUi(this); +} + +DataSourceSidebar::~DataSourceSidebar() +{ + delete ui; +} + +void DataSourceSidebar::moveEvent(QMoveEvent * me) +{ + this->parentWidget()->update(); + this->update(); + + std::cout << "Moved Event raised!" << std::endl; +} diff --git a/src/tools/livevis/client/datasourcesidebar.h b/src/tools/livevis/client/datasourcesidebar.h new file mode 100644 index 0000000000..b342439fd7 --- /dev/null +++ b/src/tools/livevis/client/datasourcesidebar.h @@ -0,0 +1,45 @@ +/** + * Copyright 2013 Benjamin Schneider + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + +#ifndef DATASOURCESIDEBAR_H +#define DATASOURCESIDEBAR_H + +#include + +namespace Ui { +class DataSourceSidebar; +} + +class DataSourceSidebar : public QWidget +{ + Q_OBJECT + + public: + explicit DataSourceSidebar(QWidget *parent = 0); + ~DataSourceSidebar(); + + protected: + void moveEvent(QMoveEvent * me); + + private: + Ui::DataSourceSidebar *ui; +}; + +#endif // DATASOURCESIDEBAR_H diff --git a/src/tools/livevis/client/datasourcesidebar.ui b/src/tools/livevis/client/datasourcesidebar.ui new file mode 100644 index 0000000000..fa2629eb6a --- /dev/null +++ b/src/tools/livevis/client/datasourcesidebar.ui @@ -0,0 +1,83 @@ + + + DataSourceSidebar + + + + 0 + 0 + 325 + 235 + + + + Form + + + + + + + + + + Datasource A + + + + + + + false + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Datasource B + + + + + + + false + + + + + + + + + 100 + + + 100 + + + Qt::Vertical + + + + + + + + + + diff --git a/src/tools/livevis/client/glwidget.cpp b/src/tools/livevis/client/glwidget.cpp new file mode 100644 index 0000000000..1749cf39f0 --- /dev/null +++ b/src/tools/livevis/client/glwidget.cpp @@ -0,0 +1,553 @@ +/** + * Copyright 2013 Benjamin Schneider, Rene Widera + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + +#include +#include + +#include "message_ids.hpp" +#include "glwidget.h" + +GLWidget::GLWidget(QWidget *parent) + : QGLWidget(parent), + m_texture(0), + m_texWidth(0), + m_texHeight(0), + m_imgBuffer(nullptr), + m_inImgWidth(0), + m_inImgHeight(0) +{ + m_camera = new Camera(float3(1000,1000,1000), float3(0,0,0)); + m_camera->setUp(float3(1,0,0)); +} + +GLWidget::~GLWidget() +{ + ::glDeleteTextures(1, &m_texture); + + if (m_imgBuffer) + { + delete [] m_imgBuffer; + m_imgBuffer = nullptr; + } +} + +void GLWidget::update_image(uint width, uint height, const void * pixel_data) +{ + if ((width <= 0) || (height <= 0)) + return; + + m_imgLock.lock(); + + if (m_imgBuffer == nullptr) + { + m_imgBuffer = new unsigned char[width * height * 3]; + } + + m_inImgWidth = width; + m_inImgHeight = height; + + ::memcpy(m_imgBuffer, pixel_data, width * height * 3); + + m_imgLock.unlock(); + + std::cout << "[GLWidget] Image updated!" << std::endl; +} + +void GLWidget::set_background_color(float r, float g, float b) +{ + m_background_color[0] = r; + m_background_color[1] = g; + m_background_color[2] = b; + + ::glClearColor(r, g, b, 1.0f); +} + +void GLWidget::set_simulation_area(float xmin, float ymin, float zmin, float xmax, float ymax, float zmax) +{ + m_simulationArea[0] = xmin; + m_simulationArea[1] = ymin; + m_simulationArea[2] = zmin; + m_simulationArea[3] = xmax; + m_simulationArea[4] = ymax; + m_simulationArea[5] = zmax; +} + +float3 GLWidget::get_simulation_center() +{ + float3 center; + center.x = m_simulationArea[0] + 0.5f * (m_simulationArea[3] - m_simulationArea[0]); + center.y = m_simulationArea[1] + 0.5f * (m_simulationArea[4] - m_simulationArea[1]); + center.z = m_simulationArea[2] + 0.5f * (m_simulationArea[5] - m_simulationArea[2]); + + return center; +} + +void GLWidget::initializeGL() +{ + ::glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + ::glGenTextures(1, &m_texture); + + ::glEnable(GL_TEXTURE_2D); + ::glBindTexture(GL_TEXTURE_2D, m_texture); + unsigned char demoTex[] = { + 0, 0, 0, + 255, 0, 0, + 0, 255, 0, + 255, 255, 255 }; + ::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 2, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, (void*)demoTex); + ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + ::glBindTexture(GL_TEXTURE_2D, 0); + ::glDisable(GL_TEXTURE_2D); + + m_texWidth = 2; + m_texHeight = 2; +} + +void GLWidget::resizeGL(int w, int h) +{ + ::glViewport(0, 0, w, h); +} + +void GLWidget::paintGL() +{ + /// draw received simulation image + ::glEnable(GL_TEXTURE_2D); + + // read in new pixel data - lock pixel buffer + m_imgLock.lock(); + if ((m_inImgWidth > 0) && (m_inImgHeight > 0)) + { + ::glBindTexture(GL_TEXTURE_2D, m_texture); + ::glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + ::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, m_inImgWidth, m_inImgHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, (void*)m_imgBuffer); + m_texWidth = m_inImgWidth; + m_texHeight = m_inImgHeight; + ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + ::glBindTexture(GL_TEXTURE_2D, 0); + + m_inImgWidth = 0; + m_inImgHeight = 0; + } + m_imgLock.unlock(); + + ::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + ::glMatrixMode(GL_PROJECTION); + ::glLoadIdentity(); + + double ww, wh; + if (this->width() < this->height()) + { + double s = static_cast(this->width()) / static_cast(this->height()); + ww = 1.0; + wh = 1.0 / s; + ::glScaled(1.0 / s, 1, 1.0); + } + else + { + double s = static_cast(this->height()) / static_cast(this->width()); + ww = 1.0 / s; + wh = 1.0; + ::glScaled(1, 1.0/s, 1.0); + } + + ::glMatrixMode(GL_MODELVIEW); + ::glLoadIdentity(); + //::glScaled(0.95, 0.95, 1.0); + + ::glBindTexture(GL_TEXTURE_2D, m_texture); + + double txmin, txmax, tymin, tymax; + double iw, ih; + + iw = 1.0; + ih = static_cast(this->m_texHeight) / static_cast(this->m_texWidth); + + if ((iw / ih) > (ww / wh)) + { + ::glScaled(ww / iw, ww / iw, 1.0); + } + else + { + ::glScaled(wh / ih, wh / ih, 1.0); + } + + txmin = 0.5 / static_cast(this->m_texWidth); + txmax = 1.0 - txmin; + tymin = 0.5 / static_cast(this->m_texHeight); + tymax = 1.0 - tymin; + + ::glColor4ub(255, 255, 255, 255); + ::glBegin(GL_QUADS); + ::glTexCoord2d(txmin, tymax); ::glVertex2d(-iw, -ih); + ::glTexCoord2d(txmin, tymin); ::glVertex2d(-iw, ih); + ::glTexCoord2d(txmax, tymin); ::glVertex2d( iw, ih); + ::glTexCoord2d(txmax, tymax); ::glVertex2d( iw, -ih); + ::glEnd(); + + ::glBindTexture(GL_TEXTURE_2D, 0); + ::glDisable(GL_TEXTURE_2D); + + /// draw bounding box + /*::glMatrixMode(GL_MODELVIEW); + ::glLoadIdentity(); + + float3 eye = m_camera->getPosition(); + float3 target = m_camera->getFocalPoint(); + float3 up = m_camera->getUp(); + + ::gluLookAt(eye.x, eye.y, eye.z, target.x, target.y, target.z, up.x, up.y, up.z); + + ::glMatrixMode(GL_PROJECTION); + ::glLoadIdentity(); + ::gluPerspective(45.0, 1.0, 1.0, 5000.0); // TODO adapt to camera fovy and aspect ratio + + ::glColor4f(1.0f - m_background_color[0], 1.0f - m_background_color[1], 1.0f - m_background_color[2], 1.0f); + ::glBegin(GL_LINES); + ::glVertex3f(m_simulationArea[0], m_simulationArea[1], m_simulationArea[2]); + ::glVertex3f(m_simulationArea[3], m_simulationArea[1], m_simulationArea[2]); + + ::glVertex3f(m_simulationArea[0], m_simulationArea[1], m_simulationArea[2]); + ::glVertex3f(m_simulationArea[0], m_simulationArea[4], m_simulationArea[2]); + + ::glVertex3f(m_simulationArea[0], m_simulationArea[1], m_simulationArea[2]); + ::glVertex3f(m_simulationArea[0], m_simulationArea[1], m_simulationArea[5]); + + ::glVertex3f(m_simulationArea[3], m_simulationArea[4], m_simulationArea[5]); + ::glVertex3f(m_simulationArea[0], m_simulationArea[4], m_simulationArea[5]); + + ::glVertex3f(m_simulationArea[3], m_simulationArea[4], m_simulationArea[5]); + ::glVertex3f(m_simulationArea[3], m_simulationArea[1], m_simulationArea[5]); + + ::glVertex3f(m_simulationArea[3], m_simulationArea[4], m_simulationArea[5]); + ::glVertex3f(m_simulationArea[3], m_simulationArea[4], m_simulationArea[2]); + + ::glVertex3f(m_simulationArea[0], m_simulationArea[4], m_simulationArea[2]); + ::glVertex3f(m_simulationArea[0], m_simulationArea[4], m_simulationArea[5]); + + ::glVertex3f(m_simulationArea[0], m_simulationArea[1], m_simulationArea[5]); + ::glVertex3f(m_simulationArea[0], m_simulationArea[4], m_simulationArea[5]); + + ::glVertex3f(m_simulationArea[0], m_simulationArea[4], m_simulationArea[2]); + ::glVertex3f(m_simulationArea[3], m_simulationArea[4], m_simulationArea[2]); + + ::glVertex3f(m_simulationArea[3], m_simulationArea[4], m_simulationArea[2]); + ::glVertex3f(m_simulationArea[3], m_simulationArea[1], m_simulationArea[2]); + + ::glVertex3f(m_simulationArea[3], m_simulationArea[1], m_simulationArea[2]); + ::glVertex3f(m_simulationArea[3], m_simulationArea[1], m_simulationArea[5]); + + ::glVertex3f(m_simulationArea[3], m_simulationArea[1], m_simulationArea[5]); + ::glVertex3f(m_simulationArea[0], m_simulationArea[1], m_simulationArea[5]); + + ::glEnd();*/ + + /// draw axes tripod in lower right corner + +} + +void GLWidget::wheelEvent(QWheelEvent * we) +{ + + int delta = we->delta(); + + float dolly; + + if (delta > 0) + { + dolly = 1.05f; + } + else if (delta < 0) + { + dolly = 0.95f; + } + else + { + dolly = 1.0f; + } + + m_camera->dolly(dolly); + + float pos[3]; + // pos[0] = m_camera->getPosition().x; + // pos[1] = m_camera->getPosition().y; + // pos[2] = m_camera->getPosition().z; + + pos[0] = 0.0f; //m_camera->getPosition().x; + pos[1] = 0.0f;// m_camera->getPosition().y; + pos[2] = dolly; //m_camera->getPosition().z; + //emit send_message(CameraPosition, 3 * sizeof(float), pos); + emit send_message(CameraOrbit, 3 * sizeof(float), pos); +} + +void GLWidget::mousePressEvent(QMouseEvent * me) +{ + prev_mx = me->x(); + prev_my = me->y(); +} + +void GLWidget::mouseMoveEvent(QMouseEvent * me) +{ + + int dx = me->x() - prev_mx; + int dy = me->y() - prev_my; + + prev_mx = me->x(); + prev_my = me->y(); + + static float factor = -0.25f; + + if (me->buttons() & Qt::LeftButton) + { + float yaw = static_cast(dx) * factor; + float pitch = static_cast(dy) * factor; + float roll = 0.0f; + + // m_camera->orbitYawPitchRoll(yaw, pitch, roll); + float pos[3]; + pos[0] = yaw; //m_camera->getPosition().x; + pos[1] = pitch; // m_camera->getPosition().y; + pos[2] = roll; //m_camera->getPosition().z; + + //emit send_message(CameraPosition, 3 * sizeof(float), pos); + emit send_message(CameraOrbit, 3 * sizeof(float), pos); + } + + if (me->buttons() & Qt::MidButton) + { + float yaw = static_cast(dx) * factor; // * 0.25f; + float pitch = static_cast(dy) * factor; // * 0.25f; + + // m_camera->panYawPitch(yaw, pitch); + + float foc[2]; + foc[0] = yaw; //m_camera->getFocalPoint().x; + foc[1] = pitch; //m_camera->getFocalPoint().y; + //foc[2] = 0.0f; //m_camera->getFocalPoint().z; + + emit send_message(CameraPan, 2* sizeof(float), foc); + //emit send_message(CameraFocalPoint, 3* sizeof(float), foc); + } + + if (me->buttons() & Qt::RightButton) + { + float mx = -static_cast(dx); + float my = static_cast(dy); + + m_camera->slide(float3(mx,my, 0.0f)); + + float sli[3]; + sli[0] = mx; + sli[1] = my; + sli[2] = 0.0f; + + emit send_message(CameraSlide,3 * sizeof(float), sli); + } + +} + +void GLWidget::keyPressEvent(QKeyEvent * ke) +{ + + switch (ke->key()) + { + + case Qt::Key_W: { + m_camera->slide(float3(0.0f, 0.0f, 0.5f)); + + float sli[3]; + sli[0] = 0.f; + sli[1] = 0.f; + sli[2] = 0.5f; + + emit send_message(CameraSlide,3 * sizeof(float), sli); + + } break; + + case Qt::Key_S: { + m_camera->slide(float3(0.0f, 0.0f, -0.5f)); + + float sli[3]; + sli[0] = 0.f; + sli[1] = 0.f; + sli[2] = -0.5f; + + emit send_message(CameraSlide,3 * sizeof(float), sli); + + } break; + + case Qt::Key_A: { + m_camera->slide(float3(-0.5f, 0.0f, 0.0f)); + + float sli[3]; + sli[0] = -0.5f; + sli[1] = 0.f; + sli[2] = 0.f; + + emit send_message(CameraSlide,3 * sizeof(float), sli); + + } break; + + case Qt::Key_D: { + m_camera->slide(float3(0.5f, 0.0f, 0.0f)); + + float sli[3]; + sli[0] = 0.5f; + sli[1] = 0.f; + sli[2] = 0.f; + + emit send_message(CameraSlide,3 * sizeof(float), sli); + + } break; +/* + case Qt::Key_Y:{ + emit send_message(CameraDefault, 0, nullptr); + usleep(20000); + + float wei[1]; + wei[0] = 0.5f; + emit send_message(Weighting, sizeof(float), wei); + usleep(20000); + + float pos[3]; + pos[0] = m_camera->getPosition().x; + pos[1] = m_camera->getPosition().y; + pos[2] = m_camera->getPosition().z; + + emit send_message(CameraPosition, 3 * sizeof(float), pos); + usleep(20000); + + emit send_message(SimPlay, 0 , nullptr); + usleep(20000); + + float sli[3]; + for (int i = 0; i < 50; i++){ + m_camera->slide(float3(0.5f,0.f,0.f)); + + sli[0] = 0.5f; + sli[1] = 0.f; + sli[2] = 0.f; + + emit send_message(CameraSlide,3 * sizeof(float), sli); + usleep(20000); + } + for (int i = 0; i < 50; i++){ + m_camera->slide(float3(0.f,0.5f,0.f)); + + sli[0] = 0.f; + sli[1] = 0.5f; + sli[2] = 0.f; + + emit send_message(CameraSlide,3 * sizeof(float), sli); + usleep(20000); + } + + for (int i = 0; i < 50; i++){ + m_camera->slide(float3(0.f,0.f,0.5f)); + + sli[0] = 0.f; + sli[1] = 0.f; + sli[2] = 0.5f; + + emit send_message(CameraSlide,3 * sizeof(float), sli); + usleep(20000); + } + + for (int i = 0; i < 50; i++){ + m_camera->slide(float3(-0.5f,-0.5f,-0.5f)); + + sli[0] = -0.5f; + sli[1] = -0.5f; + sli[2] = -0.5f; + + emit send_message(CameraSlide,3 * sizeof(float), sli); + usleep(20000); + } + + emit send_message(SimPause, 0, nullptr); + usleep(20000); + + emit send_message(CloseConnection, 0, nullptr); + + + } break; +*/ + case Qt::Key_F1: { + + emit trigger_dataSidebar(); + } break; + + case Qt::Key_F2: { + emit trigger_transferfuncSidebar(); + } break; + + case Qt::Key_F3: { + emit trigger_settingsSidebar(); + } break; + + case Qt::Key_F4: { + emit trigger_infoBar(); + } break; + + case Qt::Key_F5: { + emit trigger_clipBar(); + } break; + + case Qt::Key_F11: { + emit trigger_ui(); + } break; + + case Qt::Key_F12: { + emit show_simulationGallery(); + } break; + + case Qt::Key_Space: { + emit play_pause_sim(); + } break; + } + + // this->send_camera_position_focus(); +} + +void GLWidget::send_camera_position_focus() +{ + float pos[3]; + float focus[3]; + + pos[0] = m_camera->getPosition().x; + pos[1] = m_camera->getPosition().y; + pos[2] = m_camera->getPosition().z; + + focus[0] = m_camera->getFocalPoint().x; + focus[1] = m_camera->getFocalPoint().y; + focus[2] = m_camera->getFocalPoint().z; + + std::cout << "CameraPosition: " << pos[0] << " " << pos[1] << " " << pos[2] << std::endl; + std::cout << "CameraFocalPoint: " << focus[0] << " " << focus[1] << " " << focus[2] << std::endl; + + emit send_message(CameraPosition, 3 * sizeof(float), pos); + emit send_message(CameraFocalPoint, 3 * sizeof(float), focus); +} diff --git a/src/tools/livevis/client/glwidget.h b/src/tools/livevis/client/glwidget.h new file mode 100644 index 0000000000..6ad8f2ca64 --- /dev/null +++ b/src/tools/livevis/client/glwidget.h @@ -0,0 +1,138 @@ +/** + * Copyright 2013 Benjamin Schneider + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + +#ifndef GLWIDGET_H +#define GLWIDGET_H + +#include + +#include +#include +#include +#include "datasourcesidebar.h" +#include "transferfuncsidebar.h" +#include "camera.h" + + +class GLWidget : public QGLWidget +{ + Q_OBJECT + +public: + + explicit GLWidget(QWidget *parent = 0); + ~GLWidget(); + + void update_image(uint width, uint height, const void * pixel_data); + + void set_background_color(float r, float g, float b); + + void set_simulation_area(float xmin, float ymin, float zmin, float xmax, float ymax, float zmax); + + float3 get_simulation_center(); + + Camera * getCamera() { return m_camera; } + +signals: + + /** + * @brief send_message Signals that a message should be send to the server. + * @param msg The message as a string. + */ + void send_message(unsigned int id, unsigned int size, const void * data); + + void trigger_dataSidebar(); + void trigger_transferfuncSidebar(); + void trigger_settingsSidebar(); + void trigger_infoBar(); + void trigger_clipBar(); + + void trigger_ui(); + + void play_pause_sim(); + + void show_simulationGallery(); + +protected: + + /** + * @brief initializeGL Initialize OpenGL for rendering. + */ + void initializeGL(); + + /** + * @brief paintGL Paint the received image. + */ + void paintGL(); + + /** + * @brief resizeGL Handle resizing of the widget. + * @param w New width. + * @param h New height. + */ + void resizeGL(int w, int h); + + /** + * Handle mouse (wheel) events to control camera position. + */ + void mousePressEvent(QMouseEvent * me); + + //void mouseReleaseEvent(QMouseEvent * me); + + void mouseMoveEvent(QMouseEvent * me); + + /** + * @brief wheelEvent Use mouse wheel to move camera towards or away from focal point. + * @param we The event indicating the rotation of the mouse wheel. + */ + void wheelEvent(QWheelEvent * we); + + void keyPressEvent(QKeyEvent * ke); + +private: + + Camera * m_camera; + + float m_background_color[3]; + + /** OpenGL rendering stuff */ + GLuint m_texture; + int m_texWidth; + int m_texHeight; + + /** storage for received image */ + unsigned char * m_imgBuffer; + int m_inImgWidth; + int m_inImgHeight; + + /** lock for synchronizing reads and writes to the image buffer */ + std::mutex m_imgLock; + + /** stores last mouse position to compute movement delta */ + int prev_mx, prev_my; + + /** The bounds of the visible simulation area. */ + float m_simulationArea[6]; + + /** Helper method to send Camera Position and Focal Point */ + void send_camera_position_focus(); +}; + +#endif // GLWIDGET_H diff --git a/src/tools/livevis/client/home_button.png b/src/tools/livevis/client/home_button.png new file mode 100644 index 0000000000..3e35816810 Binary files /dev/null and b/src/tools/livevis/client/home_button.png differ diff --git a/src/tools/livevis/client/icons.qrc b/src/tools/livevis/client/icons.qrc new file mode 100644 index 0000000000..d0315ff973 --- /dev/null +++ b/src/tools/livevis/client/icons.qrc @@ -0,0 +1,7 @@ + + + play_button.png + pause_button.png + home_button.png + + diff --git a/src/tools/livevis/client/main.cpp b/src/tools/livevis/client/main.cpp new file mode 100644 index 0000000000..dbdb1a3dfe --- /dev/null +++ b/src/tools/livevis/client/main.cpp @@ -0,0 +1,63 @@ +/** + * Copyright 2013-2015 Benjamin Schneider, Axel Huebl, Richard Pausch + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + +#include "mainwindow.h" +#include + +const std::string DEFAULT_SERVER_IP = "127.0.0.1";//"149.220.4.37"; +const int DEFAULT_SERVER_INFOPORT = 8200; + +int main(int argc, char *argv[]) +{ + std::string serverip = DEFAULT_SERVER_IP; + int server_info_port = DEFAULT_SERVER_INFOPORT; + + /// get server IP and Info Portnumber from command line arguments + for (int i = 0; i < argc; ++i) + { + if (strcmp("--serverip", argv[i]) == 0 && i < argc-1) + { + serverip = argv[i+1]; + } + if (strcmp("--serverinfoport", argv[i]) == 0 && i < argc-1) + { + server_info_port = atoi(argv[i+1]); + } + if ((strcmp("--help", argv[i]) == 0) or (strcmp("-h", argv[i]) == 0)) + { + printf("This is the client for the live visualization tool of PIConGPU.\n\n"); + printf("--serverip : Sets the IP address of the visualization server. [Default: %s]\n", serverip.c_str()); + printf("--serverinfoport : Sets the port on which to connect to the visualization server. [Default: %d]\n", server_info_port); + printf("--help , -h : Show usage information.\n"); + return 0; + } + } + + + QApplication a(argc, argv); + MainWindow w; + + w.initInfoQuery(serverip, server_info_port); + + w.show(); + //w.showMaximized(); + + return a.exec(); +} diff --git a/src/tools/livevis/client/mainwindow.cpp b/src/tools/livevis/client/mainwindow.cpp new file mode 100644 index 0000000000..d558e0e5e0 --- /dev/null +++ b/src/tools/livevis/client/mainwindow.cpp @@ -0,0 +1,1112 @@ +/** + * Copyright 2013-2015 Benjamin Schneider, Rene Widera, Axel Huebl + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + +#include "mainwindow.h" +#include "ui_mainwindow.h" +#include +#include + +#include +#include + +#include "message_ids.hpp" + +// helper +QString formatNumberReadable( double x ) +{ + if( x > 1.e12 ) + return QString::number(x/1e12,'f',0) + " Trillion"; + if( x > 1.e9 ) + return QString::number(x/1e9,'f',0) + " Billion"; + if( x > 1.e6 ) + return QString::number(x/1e6,'f',0) + " Million"; + if( x > 1.e3 ) + return QString::number(x/1e3,'f',0) + " Thousand"; + + return QString::number(x,'f',0); +} + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow), + rivlib::image_stream_connection::listener(), + rivlib::control_connection::listener(), + m_imgStream(nullptr), + m_controlConn(nullptr), + m_currentTFA(nullptr), + m_currentTFB(nullptr), + m_weighting(1.f), + m_isSimRunning(false), + m_write_png_images(false) +{ + ui->setupUi(this); + + m_uiVisible = true; + + connect(ui->centralWidget, SIGNAL(trigger_ui()), this, SLOT(triggerUi())); + + m_dataSidebarOnScreen = true; + m_transferfuncSidebarOnScreen = true; + m_settingsSidebarOnScreen = true; + m_infoBarOnScreen = true; + m_clipBarOnScreen = true; + + LEFT_X_SHOWN = 0; + LEFT_X_HIDDEN = -ui->dataSidebar->width() + 40; + + RIGHT_X_SHOWN = this->width() - ui->clipSidebar->width(); + RIGHT_X_HIDDEN = this->width() - 40; + + m_aniDataSidebar = new QPropertyAnimation(ui->dataSidebar, "pos"); + m_aniTransferfuncSidebar = new QPropertyAnimation(ui->transferfuncSidebar, "pos"); + m_aniSettingsSidebar = new QPropertyAnimation(ui->settingsSidebar, "pos"); + m_aniInfoBar = new QPropertyAnimation(ui->infoBar, "pos"); + m_aniClipBar = new QPropertyAnimation(ui->clipSidebar, "pos"); + + /// connect trigger signals from GLWidget with animation + connect(ui->centralWidget, SIGNAL(trigger_dataSidebar()), this, SLOT(triggerDataSidebar())); + connect(ui->centralWidget, SIGNAL(trigger_transferfuncSidebar()), this, SLOT(triggerTransferfuncSidebar())); + connect(ui->centralWidget, SIGNAL(trigger_settingsSidebar()), this, SLOT(triggerSettingsSidebar())); + connect(ui->centralWidget, SIGNAL(trigger_infoBar()), this, SLOT(triggerInfoBar())); + connect(ui->centralWidget, SIGNAL(trigger_clipBar()), this, SLOT(triggerClipBar())); + + /// init RIVLib connection and stream + this->m_controlConn = rivlib::control_connection::create(); + this->m_controlConn->add_listener(this); + + this->m_imgStream = rivlib::image_stream_connection::create(); + this->m_imgStream->add_listener(this); + + /// init simulation gallery + m_simulationGallery = new SimulationGallery(this); + m_simulationGallery->setGeometry(0, 0, this->width(), this->height()); + m_simulationGalleryOnScreen = true; + m_simulationGallery->show(); + m_simulationGallery->setReflectionEffect(PictureFlow::BlurredReflection); + m_simulationGallery->setFocus(); + + connect(ui->centralWidget, SIGNAL(show_simulationGallery()), this, SLOT(triggerSimulationGallery())); + connect(m_simulationGallery, SIGNAL(on_hide_me()), this, SLOT(triggerSimulationGallery())); + + /// enable changing background color + connect(ui->lblBGColor, SIGNAL(clicked()), this, SLOT(changeBackgroundcolor())); + + /// enable connecting to a visualization via its RIV URI + connect(m_simulationGallery, SIGNAL(connect_to(QString)), this, SLOT(connectToURI(QString))); + + /// enable steering of simulation by interaction with mouse and keyboard + connect(ui->centralWidget, SIGNAL(send_message(uint,uint,const void*)), this, SLOT(sendMessage(uint,uint,const void*))); + + /// add received data sources to the list of available ones + connect(this, SIGNAL(on_received_datasource(QString)), this, SLOT(received_datasource(QString))); + + /// reset to initial values + this->reset_connection(); + + /// initialize Transferfunctions + m_currentTFA = new RedGreenTransferFunction(); + m_currentTFB = new TemperatureTransferFunction(); + + connect(this, SIGNAL(on_transferFunctionA_changed()), this, SLOT(transferFunctionA_changed())); + connect(this, SIGNAL(on_transferFunctionB_changed()), this, SLOT(transferFunctionB_changed())); + + emit on_transferFunctionA_changed(); + emit on_transferFunctionB_changed(); + + /// enable display of current timestep + connect(this, SIGNAL(on_received_timestep(int)), this, SLOT(received_timestep(int))); + + /// fps display + connect(this, SIGNAL(on_received_fps(float)), this, SLOT(received_fps(float))); + connect(this, SIGNAL(on_received_rfps(float)), this, SLOT(received_rfps(float))); + + /// num GPU/cells/particles display + connect(this, SIGNAL(on_received_numGPUs(int)), this, SLOT(received_numGPUs(int))); + connect(this, SIGNAL(on_received_numCells(double)), this, SLOT(received_numCells(double))); + connect(this, SIGNAL(on_received_numParticles(double)), this, SLOT(received_numParticles(double))); + + /// enable play/pause of simulation + connect(ui->centralWidget, SIGNAL(play_pause_sim()), this, SLOT(playPauseSim())); + connect(ui->btnPlayPause, SIGNAL(clicked()), this, SLOT(playPauseSim())); + + /// enable volume clipping + m_clip[0] = 0.0f; // min x + m_clip[1] = 0.0f; // min y + m_clip[2] = 0.0f; // min z + m_clip[3] = 1.0f; // max x + m_clip[4] = 1.0f; // max y + m_clip[5] = 1.0f; // max z + + connect(ui->sldXMin, SIGNAL(valueChanged(int)), this, SLOT(clippingChanged())); + connect(ui->sldYMin, SIGNAL(valueChanged(int)), this, SLOT(clippingChanged())); + connect(ui->sldZMin, SIGNAL(valueChanged(int)), this, SLOT(clippingChanged())); + connect(ui->sldXMax, SIGNAL(valueChanged(int)), this, SLOT(clippingChanged())); + connect(ui->sldYMax, SIGNAL(valueChanged(int)), this, SLOT(clippingChanged())); + connect(ui->sldZMax, SIGNAL(valueChanged(int)), this, SLOT(clippingChanged())); + + connect(m_aniClipBar, SIGNAL(finished()), this, SLOT(refresh_glWidget())); + connect(m_aniDataSidebar, SIGNAL(finished()), this, SLOT(refresh_glWidget())); + connect(m_aniInfoBar, SIGNAL(finished()), this, SLOT(refresh_glWidget())); + connect(m_aniSettingsSidebar, SIGNAL(finished()), this, SLOT(refresh_glWidget())); + connect(m_aniTransferfuncSidebar, SIGNAL(finished()), this, SLOT(refresh_glWidget())); +} + +void MainWindow::refresh_glWidget() + { + QApplication::sendEvent(ui->centralWidget, new QWheelEvent(QPoint(0,0), 0, Qt::MouseButton::NoButton, Qt::KeyboardModifier::NoModifier)); + } + +MainWindow::~MainWindow() +{ + delete ui; + + this->m_imgStream->remove_listener(this); + if (this->m_imgStream->get_status() != rivlib::control_connection::status::not_connected) + { + this->m_imgStream->disconnect(); + } + this->m_imgStream.reset(); + + this->m_controlConn->remove_listener(this); + if (this->m_controlConn->get_status() != rivlib::control_connection::status::not_connected) + { + this->m_controlConn->disconnect(); + } + this->m_controlConn.reset(); + + if (m_aniDataSidebar) delete m_aniDataSidebar; + if (m_aniInfoBar) delete m_aniInfoBar; + if (m_aniSettingsSidebar) delete m_aniSettingsSidebar; + if (m_aniTransferfuncSidebar) delete m_aniTransferfuncSidebar; + if (m_aniClipBar) delete m_aniClipBar; +} + +void MainWindow::on_image_data(rivlib::image_stream_connection::ptr comm, uint32_t width, uint32_t height, const void * rgbpix) throw() +{ +#if (MEASURE_TIME_CPUCLOCK == 1) + clock_gettime(CLOCK_REALTIME, &m_stop); + std::cout << "CPU PROFILER (Latency): " << (m_stop.tv_sec - m_start.tv_sec) << " s and " << (m_stop.tv_nsec - m_start.tv_nsec) << " ns." << std::endl; +#endif + + ui->centralWidget->update_image(width, height, rgbpix); + ui->centralWidget->update(); +} + +void MainWindow::on_error(rivlib::image_stream_connection::ptr comm, const char * msg) throw() +{ + std::cout << "Image Stream Error: " << msg << std::endl; +} + +void MainWindow::on_connected(rivlib::image_stream_connection::ptr comm) throw() +{ + std::cout << "Image Stream connected!" << std::endl; +} + +void MainWindow::on_disconnected(rivlib::image_stream_connection::ptr comm) throw() +{ + std::cout << "Image Stream disconnected!" << std::endl; +} + +void MainWindow::on_msg(rivlib::control_connection::ptr comm, unsigned int id, unsigned int size, const void * data) throw() +{ + try { + switch (id) + { + case static_cast(rivlib::message_id::data_channels): + { + size_t pos = 0; + if (size < pos + sizeof(uint32_t)) throw the::exception(__FILE__, __LINE__); + uint32_t cnt = *the::as_at(data, pos); + pos += sizeof(uint32_t); + + printf("Provider publishes %u data channels:\n", static_cast(cnt)); + + std::string sel_chan_name; + uint8_t sel_chan_qual = 0; + uint16_t sel_chan_type = 0; + uint16_t sel_chan_subtype = 0; + + for (uint32_t i = 0; i < cnt; ++i) + { + if (size < pos + sizeof(uint16_t)) throw the::exception(__FILE__, __LINE__); + uint16_t namelen = *the::as_at(data, pos); + pos += sizeof(uint16_t); + if (size < pos + namelen + sizeof(uint16_t) + sizeof(uint16_t) + sizeof(uint8_t)) throw the::exception(__FILE__, __LINE__); + std::string name(the::as_at(data, pos), namelen); + pos += namelen; + uint16_t chan_type = *the::as_at(data, pos); + pos += sizeof(uint16_t); + uint16_t chan_subtype = *the::as_at(data, pos); + pos += sizeof(uint16_t); + uint8_t chan_quality = *the::as_at(data, pos); + pos += sizeof(uint8_t); + + printf("\t%s (%u,%u;%u)\n", + name.c_str(), + static_cast(chan_type), + static_cast(chan_subtype), + static_cast(chan_quality)); + + // select best image_stream channel + if (static_cast(chan_type) == rivlib::data_channel_type::image_stream) { + rivlib::data_channel_image_stream_subtype subtype = static_cast(chan_subtype); + + // skip unsupported streams + if (!this->m_imgStream->is_supported(subtype)) continue; + + if (subtype == rivlib::data_channel_image_stream_subtype::rgb_mjpeg) { + // subtype is supported by this client o_O + if (sel_chan_qual < chan_quality) { + sel_chan_name = name; + sel_chan_type = chan_type; + sel_chan_subtype = chan_subtype; + sel_chan_qual = chan_quality; + } + } + } + } + + if (sel_chan_name.empty()) { + printf("No suitable image_stream data channel available\n"); + + } else { + printf("Selected \"%s\" image_stream data channel of type %u\n", sel_chan_name.c_str(), sel_chan_subtype); + this->m_imgStream->disconnect(true); + + size_t uri_len = this->m_controlConn->make_data_channel_uri(sel_chan_name.c_str(), sel_chan_type, sel_chan_subtype, nullptr, 0); + char *buf = new char[uri_len]; + uri_len = this->m_controlConn->make_data_channel_uri(sel_chan_name.c_str(), sel_chan_type, sel_chan_subtype, buf, uri_len); + std::string uri(buf, uri_len); + delete[] buf; + + this->m_imgStream->connect(uri.c_str()); + } + + } break; + + case RIVLIB_USERMSG + TimeStep: { + unsigned int timestep = reinterpret_cast(data)[0]; + emit on_received_timestep(timestep); + } break; + case RIVLIB_USERMSG + FPS: { + float fps = reinterpret_cast(data)[0]; + emit on_received_fps(fps); + } break; + case RIVLIB_USERMSG + RenderFPS: { + float fps = reinterpret_cast(data)[0]; + emit on_received_rfps(fps); + } break; + + case RIVLIB_USERMSG + NumGPUs: { + int numGPUs = reinterpret_cast(data)[0]; + emit on_received_numGPUs(numGPUs); + } break; + case RIVLIB_USERMSG + NumCells: { + double numCells = reinterpret_cast(data)[0]; + emit on_received_numCells(numCells); + } break; + case RIVLIB_USERMSG + NumParticles: { + double numParticles = reinterpret_cast(data)[0]; + emit on_received_numParticles(numParticles); + } break; + + case RIVLIB_USERMSG + AvailableDataSource: { + char * c = new char[size + 1]; + memcpy(c, data, size); + c[size] = 0; + + emit on_received_datasource(QString(c)); + + delete [] c; + } break; + + case RIVLIB_USERMSG + VisibleSimulationArea: { + ui->centralWidget->set_simulation_area(reinterpret_cast(data)[0], + reinterpret_cast(data)[1], + reinterpret_cast(data)[2], + reinterpret_cast(data)[3], + reinterpret_cast(data)[4], + reinterpret_cast(data)[5]); + } break; + + default: + printf("Ctrl Msg received: %u (%u bytes)\n", id, static_cast(size)); + break; + } + + } catch(the::exception ex) { + fprintf(stderr, "Ctrl-Message error: %s (%s, %d)\n", ex.get_msg_astr(), ex.get_file(), ex.get_line()); + //this->on_disconnect_clicked(); + } catch(...) { + fprintf(stderr, "Ctrl-Message error: unexpected exception\n"); + //this->on_disconnect_clicked(); + } +} + +void MainWindow::on_error(rivlib::control_connection::ptr comm, const char * msg) throw() +{ + std::cout << "Control Connection: " << msg << std::endl; +} + +void MainWindow::on_connected(rivlib::control_connection::ptr comm) throw() +{ + std::cout << "Control Connection connected!" << std::endl; + + this->sendMessage(RequestDataSources, 0, nullptr); + this->on_pushButton_clicked(); + + this->m_controlConn->send(static_cast(rivlib::message_id::query_data_channels), 0, nullptr); +} + +void MainWindow::on_disconnected(rivlib::control_connection::ptr comm) throw() +{ + std::cout << "Control Connection disconnected!" << std::endl; + + try { + this->m_imgStream->disconnect(true); + } catch(...) { + } +} + +void MainWindow::resizeEvent(QResizeEvent * re) +{ + this->layout()->setEnabled(true); + ui->centralWidget->layout()->setEnabled(true); + ui->dockWidget->layout()->setEnabled(true); + + m_simulationGallery->setGeometry(0, 0, this->width(), this->height()); + + RIGHT_X_SHOWN = this->width() - ui->clipSidebar->width(); + RIGHT_X_HIDDEN = this->width() - 40; + + this->correct_sidebar_positions(); + + if (m_simulationGalleryOnScreen) m_simulationGallery->setFocus(); +} + +void MainWindow::reset_connection() +{ + /// clean up potential previous connections + this->m_controlConn->disconnect(false); + + /// clean up data source sidebar + ui->cmbDatasourceA->clear(); + ui->cmbDatasourceB->clear(); + + ui->cmbDatasourceA->addItem("None"); + ui->cmbDatasourceB->addItem("None"); + + /// reset transferfunction sidebar + ui->rdo2HueA->setChecked(false); + ui->rdoRedGreenA->setChecked(true); + ui->rdoTempA->setChecked(false); + + ui->rdo2HueB->setChecked(false); + ui->rdoRedGreenB->setChecked(false); + ui->rdoTempB->setChecked(true); + + /// reset Rendering/Compositing Settings + ui->rdoAlphaBlending->setChecked(true); + ui->rdoMIP->setChecked(false); + ui->rdoIsoSurface->setChecked(false); + + m_backgroundColor[0] = m_backgroundColor[1] = m_backgroundColor[2] = 1.0f; + + QImage image(1, 1, QImage::Format_RGB32); + image.setPixel(0, 0, std::numeric_limits::max()); + + ui->lblBGColor->setPixmap(QPixmap::fromImage(image)); +} + +void MainWindow::sendMessage(unsigned int id, unsigned int size, const void * data) +{ +#if (MEASURE_TIME_CPUCLOCK == 1) + clock_gettime(CLOCK_REALTIME, &m_start); +#endif + + /// send message to server via control connection + this->m_controlConn->send(RIVLIB_USERMSG + id, size, data); + + //std::cout << "Sending Message via RIV " << id << " " << size << std::endl; +} + +void MainWindow::connectToURI(QString uri) +{ + std::cout << "Connecting..." << std::endl; + + try { + reset_connection(); + this->m_controlConn->connect(uri.toStdString().c_str()); + this->m_imgStream->disconnect(false); + } catch(the::exception ex) { + fprintf(stderr, "Connect-Message error: %s (%s, %d)\n", ex.get_msg_astr(), ex.get_file(), ex.get_line()); + //this->m_imgStream->disconnect(true); + } catch(...) { + fprintf(stderr, "Connect-Message error: unexpected exception\n"); + //this->m_imgStream->disconnect(true); + } +} + +void MainWindow::received_datasource(QString source) +{ + ui->cmbDatasourceA->addItem(source); + ui->cmbDatasourceB->addItem(source); + + //std::cout << "Datasource " << source.toStdString() << " added." << std::endl; +} + +void MainWindow::received_timestep(int step) +{ + this->layout()->setEnabled(false); + ui->centralWidget->layout()->setEnabled(false); + ui->dockWidget->layout()->setEnabled(false); + + ui->lblTimestep->setText(QString::number(step)); +} + +void MainWindow::received_fps(float fps) +{ + this->layout()->setEnabled(false); + ui->centralWidget->layout()->setEnabled(false); + ui->dockWidget->layout()->setEnabled(false); + + ui->lblFPS->setText(QString::number(fps,'f',1)); +} + +void MainWindow::received_rfps(float fps) +{ + this->layout()->setEnabled(false); + ui->centralWidget->layout()->setEnabled(false); + ui->dockWidget->layout()->setEnabled(false); + + ui->lblRFPS->setText(QString::number(fps,'f',1)); +} + +void MainWindow::received_numGPUs(int numGPUs) +{ + this->layout()->setEnabled(false); + ui->centralWidget->layout()->setEnabled(false); + ui->dockWidget->layout()->setEnabled(false); + + ui->lblStatusGPUs->setText(QString("%1 GPUs").arg(numGPUs)); +} + +void MainWindow::received_numCells(double numCells) +{ + this->layout()->setEnabled(false); + ui->centralWidget->layout()->setEnabled(false); + ui->dockWidget->layout()->setEnabled(false); + + ui->lblStatusCells->setText(formatNumberReadable(numCells) + " Cells"); +} + +void MainWindow::received_numParticles(double numParticles) +{ + this->layout()->setEnabled(false); + ui->centralWidget->layout()->setEnabled(false); + ui->dockWidget->layout()->setEnabled(false); + + ui->lblStatusParticles->setText(formatNumberReadable(numParticles) + " Particles"); +} + +void MainWindow::changeBackgroundcolor() +{ + QColor color = QColorDialog::getColor( QColor(m_backgroundColor[0] * 255.0f, + m_backgroundColor[1] * 255.0f, + m_backgroundColor[2] * 255.0f), + this, QString("Pick a Background Color") ); + + m_backgroundColor[0] = static_cast(color.red()) / 255.0f; + m_backgroundColor[1] = static_cast(color.green()) / 255.0f; + m_backgroundColor[2] = static_cast(color.blue()) / 255.0f; + + unsigned int colorUint = color.red() << 16 | color.green() << 8 | color.blue(); + + QImage image(1, 1, QImage::Format_RGB32); + image.setPixel(0, 0, colorUint); + + this->layout()->setEnabled(false); + ui->centralWidget->layout()->setEnabled(false); + + ui->lblBGColor->setPixmap(QPixmap::fromImage(image)); + ui->centralWidget->set_background_color(m_backgroundColor[0], m_backgroundColor[1], m_backgroundColor[2]); + + QWidget* titleWidget = new QWidget(this); /* where this a QMainWindow object */ + ui->dockWidget->setTitleBarWidget( titleWidget ); + ui->dockWidgetContents->setStyleSheet("background-color: rgb(" + QString::number(m_backgroundColor[0]*255) + + "," + QString::number(m_backgroundColor[1]*255) + + "," + QString::number(m_backgroundColor[2]*255) + + "," + ");"); + + + // status bar labels + QPalette lblTxtPalGPUs = QPalette(ui->lblStatusGPUs->palette()); + lblTxtPalGPUs.setColor(ui->lblStatusGPUs->foregroundRole(), QColor(255-m_backgroundColor[0]* 255.0f, 255-m_backgroundColor[1]* 255.0f, 255-m_backgroundColor[2]* 255.0f)); + ui->lblStatusGPUs->setPalette(lblTxtPalGPUs); + + QPalette lblTxtPalCells = QPalette(ui->lblStatusCells->palette()); + lblTxtPalCells.setColor(ui->lblStatusCells->foregroundRole(), QColor(255-m_backgroundColor[0]* 255.0f, 255-m_backgroundColor[1]* 255.0f, 255-m_backgroundColor[2]* 255.0f)); + ui->lblStatusCells->setPalette(lblTxtPalCells); + + QPalette lblTxtPalParticles = QPalette(ui->lblStatusParticles->palette()); + lblTxtPalParticles.setColor(ui->lblStatusParticles->foregroundRole(), QColor(255-m_backgroundColor[0]* 255.0f, 255-m_backgroundColor[1]* 255.0f, 255-m_backgroundColor[2]* 255.0f)); + ui->lblStatusParticles->setPalette(lblTxtPalParticles); + + //emit backgroundColor_updated(colorUint); + this->sendMessage(BackgroundColor, 3 * sizeof(float), m_backgroundColor); +} + +void MainWindow::triggerSimulationGallery() +{ + if (m_simulationGalleryOnScreen) + { + m_simulationGallery->hide(); + m_simulationGalleryOnScreen = false; + ui->centralWidget->setFocus(); + } + else + { + m_simulationGallery->show(); + m_simulationGalleryOnScreen = true; + m_simulationGallery->setFocus(); + } +} + +void MainWindow::hideAllSidebars() +{ + m_dataSidebarOnScreen = m_transferfuncSidebarOnScreen = m_settingsSidebarOnScreen = m_infoBarOnScreen = true; + + triggerDataSidebar(); + triggerTransferfuncSidebar(); + triggerSettingsSidebar(); + triggerInfoBar(); + triggerClipBar(); +} + +void MainWindow::triggerDataSidebar() +{ + /*if (m_dataSidebarOnScreen) + { + ui->dataSidebar->hide(); + m_dataSidebarOnScreen = false; + } + else + { + ui->dataSidebar->show(); + m_dataSidebarOnScreen = true; + }*/ + m_aniDataSidebar->setDuration(500); + + if (m_dataSidebarOnScreen) + { + m_aniDataSidebar->setEndValue(QPoint(LEFT_X_HIDDEN, ui->dataSidebar->pos().y())); + m_aniDataSidebar->setEasingCurve(QEasingCurve::InSine); + m_dataSidebarOnScreen = false; + } + else + { + m_aniDataSidebar->setEndValue(QPoint(LEFT_X_SHOWN, ui->dataSidebar->pos().y())); + m_aniDataSidebar->setEasingCurve(QEasingCurve::OutSine); + m_dataSidebarOnScreen = true; + } + + m_aniDataSidebar->start(); +} + +void MainWindow::triggerTransferfuncSidebar() +{ + m_aniTransferfuncSidebar->setDuration(500); + + if (m_transferfuncSidebarOnScreen) + { + m_aniTransferfuncSidebar->setEndValue(QPoint(LEFT_X_HIDDEN, ui->transferfuncSidebar->pos().y())); + m_aniTransferfuncSidebar->setEasingCurve(QEasingCurve::InSine); + m_transferfuncSidebarOnScreen = false; + } + else + { + m_aniTransferfuncSidebar->setEndValue(QPoint(LEFT_X_SHOWN, ui->transferfuncSidebar->pos().y())); + m_aniTransferfuncSidebar->setEasingCurve(QEasingCurve::OutSine); + m_transferfuncSidebarOnScreen = true; + } + + m_aniTransferfuncSidebar->start(); +} + +void MainWindow::triggerSettingsSidebar() +{ + m_aniSettingsSidebar->setDuration(500); + + if (m_settingsSidebarOnScreen) + { + m_aniSettingsSidebar->setEndValue(QPoint(LEFT_X_HIDDEN, ui->settingsSidebar->pos().y())); + m_aniSettingsSidebar->setEasingCurve(QEasingCurve::InSine); + m_settingsSidebarOnScreen = false; + } + else + { + m_aniSettingsSidebar->setEndValue(QPoint(LEFT_X_SHOWN, ui->settingsSidebar->pos().y())); + m_aniSettingsSidebar->setEasingCurve(QEasingCurve::OutSine); + m_settingsSidebarOnScreen = true; + } + + m_aniSettingsSidebar->start(); +} + +void MainWindow::triggerInfoBar() +{ + m_aniInfoBar->setDuration(500); + + if (m_infoBarOnScreen) + { + m_aniInfoBar->setEndValue(QPoint(RIGHT_X_HIDDEN, ui->infoBar->pos().y())); + m_aniInfoBar->setEasingCurve(QEasingCurve::InSine); + m_infoBarOnScreen = false; + } + else + { + m_aniInfoBar->setEndValue(QPoint(RIGHT_X_SHOWN, ui->infoBar->pos().y())); + m_aniInfoBar->setEasingCurve(QEasingCurve::OutSine); + m_infoBarOnScreen = true; + } + + m_aniInfoBar->start(); +} + +void MainWindow::triggerClipBar() +{ + m_aniClipBar->setDuration(500); + + if (m_clipBarOnScreen) + { + m_aniClipBar->setEndValue(QPoint(RIGHT_X_HIDDEN, ui->clipSidebar->pos().y())); + m_aniClipBar->setEasingCurve(QEasingCurve::InSine); + m_clipBarOnScreen = false; + } + else + { + m_aniClipBar->setEndValue(QPoint(RIGHT_X_SHOWN, ui->clipSidebar->pos().y())); + m_aniClipBar->setEasingCurve(QEasingCurve::OutSine); + m_clipBarOnScreen = true; + } + + m_aniClipBar->start(); +} + +void MainWindow::triggerUi() +{ + if (m_uiVisible) + { + ui->dataSidebar->hide(); + ui->transferfuncSidebar->hide(); + ui->settingsSidebar->hide(); + ui->infoBar->hide(); + ui->clipSidebar->hide(); + + m_uiVisible = false; + } + else + { + ui->dataSidebar->show(); + ui->transferfuncSidebar->show(); + ui->settingsSidebar->show(); + ui->infoBar->show(); + ui->clipSidebar->show(); + + this->correct_sidebar_positions(); + + m_uiVisible = true; + } + + this->refresh_glWidget(); +} + +void MainWindow::playPauseSim() +{ + if (m_isSimRunning) + { + m_isSimRunning = false; + this->sendMessage(SimPause, 0, nullptr); + ui->btnPlayPause->setIcon(QIcon(":/icons/play_button.png")); + } + else + { + m_isSimRunning = true; + this->sendMessage(SimPlay, 0, nullptr); + ui->btnPlayPause->setIcon(QIcon(":/icons/pause_button.png")); + } +} + +void MainWindow::clippingChanged() +{ + m_clip[1] = static_cast(ui->sldXMin->value()) * 0.01f; + m_clip[0] = static_cast(ui->sldYMin->value()) * 0.01f; + m_clip[2] = static_cast(ui->sldZMin->value()) * 0.01f; + + m_clip[4] = static_cast(ui->sldXMax->value()) * 0.01f; + m_clip[3] = static_cast(ui->sldYMax->value()) * 0.01f; + m_clip[5] = static_cast(ui->sldZMax->value()) * 0.01f; + + this->sendMessage(Clipping, 6 * sizeof(float), m_clip); +} + +void MainWindow::on_cmbDatasourceA_currentIndexChanged(const QString &arg1) +{ + ui->grpColorscaleA->setTitle(arg1); + this->sendMessage(DataSourceA, arg1.toStdString().size(), arg1.toStdString().c_str()); +} + +void MainWindow::on_cmbDatasourceB_currentIndexChanged(const QString &arg1) +{ + ui->grpColorscaleB->setTitle(arg1); + this->sendMessage(DataSourceB, arg1.toStdString().size(), arg1.toStdString().c_str()); +} + +void MainWindow::on_rdoRedGreenA_toggled(bool checked) +{ + if (checked) + { + if (m_currentTFA) delete m_currentTFA; + m_currentTFA = new RedGreenTransferFunction(); + + /// update the slider to reflect the current state of the chosen TF + ui->sldOffsetXTFA->setValue(m_currentTFA->getOffsetX() * 100.0f); + ui->sldOffsetYTFA->setValue(m_currentTFA->getOffsetY() * 100.0f); + ui->sldSlopeTFA->setValue(m_currentTFA->getSlope() * 10.0f); + + emit on_transferFunctionA_changed(); + } +} + +void MainWindow::on_rdoTempA_toggled(bool checked) +{ + if (checked) + { + if (m_currentTFA) delete m_currentTFA; + m_currentTFA = new TemperatureTransferFunction(); + + /// update the slider to reflect the current state of the chosen TF + ui->sldOffsetXTFA->setValue(m_currentTFA->getOffsetX() * 100.0f); + ui->sldOffsetYTFA->setValue(m_currentTFA->getOffsetY() * 100.0f); + ui->sldSlopeTFA->setValue(m_currentTFA->getSlope() * 10.0f); + + emit on_transferFunctionA_changed(); + } +} + +void MainWindow::on_rdo2HueA_toggled(bool checked) +{ + if (checked) + { + if (m_currentTFA) delete m_currentTFA; + m_currentTFA = new TwoHueTransferFunction(); + + /// update the slider to reflect the current state of the chosen TF + ui->sldOffsetXTFA->setValue(m_currentTFA->getOffsetX() * 100.0f); + ui->sldOffsetYTFA->setValue(m_currentTFA->getOffsetY() * 100.0f); + ui->sldSlopeTFA->setValue(m_currentTFA->getSlope() * 10.0f); + + emit on_transferFunctionA_changed(); + } +} + +void MainWindow::on_rdoRedGreenB_toggled(bool checked) +{ + if (checked) + { + if (m_currentTFB) delete m_currentTFB; + m_currentTFB = new RedGreenTransferFunction(); + + /// update the slider to reflect the current state of the chosen TF + ui->sldOffsetXTFB->setValue(m_currentTFB->getOffsetX() * 100.0f); + ui->sldOffsetYTFB->setValue(m_currentTFB->getOffsetY() * 100.0f); + ui->sldSlopeTFB->setValue(m_currentTFB->getSlope() * 10.0f); + + emit on_transferFunctionB_changed(); + } +} + +void MainWindow::on_rdoTempB_toggled(bool checked) +{ + if (checked) + { + if (m_currentTFB) delete m_currentTFB; + m_currentTFB = new TemperatureTransferFunction(); + + /// update the slider to reflect the current state of the chosen TF + ui->sldOffsetXTFB->setValue(m_currentTFB->getOffsetX() * 100.0f); + ui->sldOffsetYTFB->setValue(m_currentTFB->getOffsetY() * 100.0f); + ui->sldSlopeTFB->setValue(m_currentTFB->getSlope() * 10.0f); + + emit on_transferFunctionB_changed(); + } +} + +void MainWindow::on_rdo2HueB_toggled(bool checked) +{ + if (checked) + { + if (m_currentTFB) delete m_currentTFB; + m_currentTFB = new TwoHueTransferFunction(); + + /// update the slider to reflect the current state of the chosen TF + ui->sldOffsetXTFB->setValue(m_currentTFB->getOffsetX() * 100.0f); + ui->sldOffsetYTFB->setValue(m_currentTFB->getOffsetY() * 100.0f); + ui->sldSlopeTFB->setValue(m_currentTFB->getSlope() * 10.0f); + + emit on_transferFunctionB_changed(); + } +} + +void MainWindow::transferFunctionA_changed() +{ + /// sample the TF + float4 * sampled = new float4[TF_RESOLUTION]; + + for (int i = 0; i < TF_RESOLUTION; ++i) + { + sampled[i] = m_currentTFA->sample( static_cast(i) / static_cast(TF_RESOLUTION - 1) ); + } + + /// update color scale label + QImage image(1, TF_RESOLUTION, QImage::Format_RGB32); + + for (int y = 0; y < TF_RESOLUTION; ++y) + { + QColor color(sampled[y].r * 255.0f, sampled[y].g * 255.0f, sampled[y].b * 255.0f); + unsigned int colorUint = color.red() << 16 | color.green() << 8 | color.blue(); + image.setPixel(0, TF_RESOLUTION - y - 1, colorUint); + } + + QPixmap pm(QPixmap::fromImage(image)); + + static bool first = true; + if (first) + first = false; + else + { + this->layout()->setEnabled(false); + ui->centralWidget->layout()->setEnabled(false); + } + + ui->lblTFA->setPixmap(pm); + + /// send new TF via RIV + this->sendMessage(TransferFunctionA, sizeof(float4) * TF_RESOLUTION, sampled); + + delete [] sampled; + + /*std::cout << "DSBar X: " << ui->dataSidebar->pos().x() << std::endl; + std::cout << "TFBar X: " << ui->transferfuncSidebar->pos().x() << std::endl; + std::cout << "RSBar X: " << ui->settingsSidebar->pos().x() << std::endl; + + std::cout << "TF changed Thread: " << QThread::currentThreadId() << std::endl;*/ + + emit on_correct_sidebar_positions(); +} + +void MainWindow::transferFunctionB_changed() +{ + /// sample the TF + float4 * sampled = new float4[TF_RESOLUTION]; + + for (int i = 0; i < TF_RESOLUTION; ++i) + { + sampled[i] = m_currentTFB->sample( static_cast(i) / static_cast(TF_RESOLUTION - 1) ); + } + + /// update color scale label + QImage image(1, TF_RESOLUTION, QImage::Format_RGB32); + + for (int y = 0; y < TF_RESOLUTION; ++y) + { + QColor color(sampled[y].r * 255.0f, sampled[y].g * 255.0f, sampled[y].b * 255.0f); + unsigned int colorUint = color.red() << 16 | color.green() << 8 | color.blue(); + image.setPixel(0, TF_RESOLUTION - y - 1, colorUint); + } + + QPixmap pm(QPixmap::fromImage(image)); + + static bool first = true; + if (first) + first = false; + else + { + this->layout()->setEnabled(false); + ui->centralWidget->layout()->setEnabled(false); + } + + ui->lblTFB->setPixmap(pm); + + /// send new TF via RIV + this->sendMessage(TransferFunctionB, sizeof(float4) * TF_RESOLUTION, sampled); + + delete [] sampled; +} + +void MainWindow::on_sldOffsetXTFA_valueChanged(int value) +{ + m_currentTFA->setOffsetX( static_cast(value) * 0.01f ); + + emit on_transferFunctionA_changed(); +} + +void MainWindow::on_sldSlopeTFA_valueChanged(int value) +{ + m_currentTFA->setSlope( static_cast(value) * 0.1f ); + + emit on_transferFunctionA_changed(); +} + +void MainWindow::on_sldOffsetYTFA_valueChanged(int value) +{ + m_currentTFA->setOffsetY( static_cast(value) * 0.01f ); + + emit on_transferFunctionA_changed(); +} + +void MainWindow::on_sldOffsetXTFB_valueChanged(int value) +{ + m_currentTFB->setOffsetX( static_cast(value) * 0.01f ); + + emit on_transferFunctionB_changed(); +} + +void MainWindow::on_sldSlopeTFB_valueChanged(int value) +{ + m_currentTFB->setSlope( static_cast(value) * 0.1f ); + + emit on_transferFunctionB_changed(); +} + +void MainWindow::on_sldOffsetYTFB_valueChanged(int value) +{ + m_currentTFB->setOffsetY( static_cast(value) * 0.01f ); + + emit on_transferFunctionB_changed(); +} + +void MainWindow::on_sldSourceWeighting_valueChanged(int value) +{ + m_weighting = static_cast(value) * 0.01f; + this->sendMessage(Weighting, sizeof(float), &m_weighting); +} + +void MainWindow::correct_sidebar_positions() +{ + //std::cout << "Correction Thread: " << QThread::currentThreadId() << std::endl; + + if (m_dataSidebarOnScreen) ui->dataSidebar->move(LEFT_X_SHOWN, ui->dataSidebar->pos().y()); + else ui->dataSidebar->move(LEFT_X_HIDDEN, ui->dataSidebar->pos().y()); + + if (m_settingsSidebarOnScreen) ui->settingsSidebar->move(LEFT_X_SHOWN, ui->settingsSidebar->pos().y()); + else ui->settingsSidebar->move(LEFT_X_HIDDEN, ui->settingsSidebar->pos().y()); + + if (m_transferfuncSidebarOnScreen) ui->transferfuncSidebar->move(LEFT_X_SHOWN, ui->transferfuncSidebar->pos().y()); + else ui->transferfuncSidebar->move(LEFT_X_HIDDEN, ui->transferfuncSidebar->pos().y()); + + if (m_infoBarOnScreen) ui->infoBar->move(RIGHT_X_SHOWN, ui->infoBar->pos().y()); + else ui->infoBar->move(RIGHT_X_HIDDEN, ui->infoBar->pos().y()); + + if (m_infoBarOnScreen) ui->clipSidebar->move(RIGHT_X_SHOWN, ui->clipSidebar->pos().y()); + else ui->clipSidebar->move(RIGHT_X_HIDDEN, ui->clipSidebar->pos().y()); + + //std::cout << "DataSources is " << (m_dataSidebarOnScreen ? "ON" : "OFF") << std::endl; +} + +/// DEAD CODE, darn +void MainWindow::on_sldOffsetXTFA_sliderReleased() +{ } +/// DEAD END + +void MainWindow::on_pushButton_clicked() +{ + //this->sendMessage(CameraDefault, 0, nullptr); + + /// default camera position and focal point + float3 center = ui->centralWidget->get_simulation_center(); + Camera * cam = ui->centralWidget->getCamera(); + + cam->setPosition(center * 2.0f); + cam->setFocalPoint(center); + + float pos[3], focal[3]; + pos[0] = cam->getPosition().x; + pos[1] = cam->getPosition().y; + pos[2] = cam->getPosition().z; + focal[0] = cam->getFocalPoint().x; + focal[1] = cam->getFocalPoint().y; + focal[2] = cam->getFocalPoint().z; + + //std::cout << "CameraPosition: " << pos[0] << " " << pos[1] << " " << pos[2] << std::endl; + //std::cout << "CameraFocalPoint: " << focal[0] << " " << focal[1] << " " << focal[2] << std::endl; + + this->sendMessage(CameraDefault, 3 * sizeof(float), pos); + // this->sendMessage(CameraPosition, 3 * sizeof(float), pos); + // this->sendMessage(CameraFocalPoint, 3 * sizeof(float), focal); +} + +void MainWindow::on_rdoAlphaBlending_clicked() +{ + if (ui->rdoAlphaBlending->isChecked()) + { + this->sendMessage(CompositingModeAlphaBlend, 0, nullptr); + } +} + +void MainWindow::on_rdoMIP_clicked() +{ + if (ui->rdoMIP->isChecked()) + { + this->sendMessage(CompositingModeMIP, 0, nullptr); + } +} + +void MainWindow::on_rdoIsoSurface_clicked() +{ + if (ui->rdoIsoSurface->isChecked()) + { + this->sendMessage(CompositingModeIsoSurface, 0, nullptr); + } +} + +void MainWindow::on_sldIsoValue_valueChanged(int value) +{ + float iso_value = static_cast(value) * 0.01f; + this->sendMessage(IsoSurfaceValue, sizeof(float), &iso_value); + + std::cout << "ISO: " << iso_value << std::endl; +} + +void MainWindow::on_btnWritePng_clicked() +{ + m_write_png_images = !m_write_png_images; + + if (m_write_png_images) + { + this->sendMessage(PngWriterOn, 0, nullptr); + ui->btnWritePng->setText("On"); + } + else + { + this->sendMessage(PngWriterOff, 0, nullptr); + ui->btnWritePng->setText("Off"); + } +} diff --git a/src/tools/livevis/client/mainwindow.h b/src/tools/livevis/client/mainwindow.h new file mode 100644 index 0000000000..41ff092331 --- /dev/null +++ b/src/tools/livevis/client/mainwindow.h @@ -0,0 +1,237 @@ +/** + * Copyright 2013-2015 Benjamin Schneider, Axel Huebl, Rene Widera + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +#include "rivlib/rivlib.h" + +#include +#include +#include "glwidget.h" +#include "simulationgallery.h" +#include "transferfunctions.h" + +#define MEASURE_TIME_CPUCLOCK 1 + +namespace Ui { +class MainWindow; +} + +using namespace eu_vicci; + +class MainWindow : public QMainWindow, + public rivlib::image_stream_connection::listener, + public rivlib::control_connection::listener +{ + Q_OBJECT + +public: + + explicit MainWindow(QWidget * parent = 0); + ~MainWindow(); + + void initInfoQuery(std::string ip, int m_infoport) { m_simulationGallery->startQuery(ip, m_infoport); } + + /** Implementation of image_stream_connection::listener */ + virtual void on_image_data(rivlib::image_stream_connection::ptr comm, uint32_t width, uint32_t height, const void * rgbpix) throw(); + + virtual void on_error(rivlib::image_stream_connection::ptr comm, const char * msg) throw(); + + virtual void on_connected(rivlib::image_stream_connection::ptr comm) throw(); + + virtual void on_disconnected(rivlib::image_stream_connection::ptr comm) throw(); + + /** Implementation of control_connection::listener */ + virtual void on_connected(rivlib::control_connection::ptr comm) throw(); + + virtual void on_disconnected(rivlib::control_connection::ptr comm) throw(); + + virtual void on_error(rivlib::control_connection::ptr comm, const char *msg) throw(); + + virtual void on_msg(rivlib::control_connection::ptr comm, unsigned int id, unsigned int size, const void *data) throw(); + +public slots: + + void triggerDataSidebar(); + void triggerTransferfuncSidebar(); + void triggerSettingsSidebar(); + void triggerInfoBar(); + void triggerClipBar(); + + void triggerUi(); + + void hideAllSidebars(); + + void triggerSimulationGallery(); + + void changeBackgroundcolor(); + + void connectToURI(QString uri); + + void received_datasource(QString source); + void received_timestep(int step); + void received_fps(float fps); + void received_rfps(float fps); + + void received_numGPUs(int numGPUs); + void received_numCells(double numCells); + void received_numParticles(double numParticles); + + void sendMessage(unsigned int id, unsigned int size, const void * data); + + void transferFunctionA_changed(); + void transferFunctionB_changed(); + + void playPauseSim(); + + void clippingChanged(); + + void refresh_glWidget(); + +signals: + + void on_received_timestep(int step); + void on_received_fps(float fps); + void on_received_rfps(float fps); + void on_received_datasource(QString source); + + void on_received_numGPUs(int numGPUs); + void on_received_numCells(double numCells); + void on_received_numParticles(double numParticles); + + void on_transferFunctionA_changed(); + void on_transferFunctionB_changed(); + + void on_correct_sidebar_positions(); + +protected: + + void resizeEvent(QResizeEvent * re); + + void reset_connection(); + +private slots: + void on_cmbDatasourceA_currentIndexChanged(const QString &arg1); + + void on_cmbDatasourceB_currentIndexChanged(const QString &arg1); + + void on_rdoRedGreenA_toggled(bool checked); + + void on_rdoTempA_toggled(bool checked); + + void on_rdo2HueA_toggled(bool checked); + + void on_rdoRedGreenB_toggled(bool checked); + + void on_rdoTempB_toggled(bool checked); + + void on_rdo2HueB_toggled(bool checked); + + void on_sldOffsetXTFA_valueChanged(int value); + + void on_sldSlopeTFA_valueChanged(int value); + + void on_sldOffsetYTFA_valueChanged(int value); + + void on_sldOffsetXTFB_valueChanged(int value); + + void on_sldSlopeTFB_valueChanged(int value); + + void on_sldOffsetYTFB_valueChanged(int value); + + void on_sldSourceWeighting_valueChanged(int value); + + void on_sldOffsetXTFA_sliderReleased(); + + void correct_sidebar_positions(); + + void on_pushButton_clicked(); + + void on_rdoAlphaBlending_clicked(); + + void on_rdoMIP_clicked(); + + void on_rdoIsoSurface_clicked(); + + void on_sldIsoValue_valueChanged(int value); + + void on_btnWritePng_clicked(); + +private: + + Ui::MainWindow * ui; + + bool m_uiVisible; + + /** Simulation gallery to choose to which simualtion the user wants to connect */ + SimulationGallery * m_simulationGallery; + bool m_simulationGalleryOnScreen; + + /** RIVLib */ + rivlib::image_stream_connection::ptr m_imgStream; + rivlib::control_connection::ptr m_controlConn; + + /** Animation control properties */ + bool m_dataSidebarOnScreen; + bool m_transferfuncSidebarOnScreen; + bool m_settingsSidebarOnScreen; + bool m_infoBarOnScreen; + bool m_clipBarOnScreen; + + QPropertyAnimation * m_aniDataSidebar; + QPropertyAnimation * m_aniTransferfuncSidebar; + QPropertyAnimation * m_aniSettingsSidebar; + QPropertyAnimation * m_aniInfoBar; + QPropertyAnimation * m_aniClipBar; + + int LEFT_X_SHOWN; + int LEFT_X_HIDDEN; + + int RIGHT_X_SHOWN; + int RIGHT_X_HIDDEN; + + /** Backgroundcolor */ + float m_backgroundColor[3]; + + /** Current Transferfunctions */ + ITransferFunction * m_currentTFA; + ITransferFunction * m_currentTFB; + + /** Opacity Weighting of Datasource A and B. */ + float m_weighting; + + /** simulation control */ + bool m_isSimRunning; + + /** The Clipping box defined by six floats min x,y,z and max x,y,z. */ + float m_clip[6]; + + /** Write Png images to simulation output folder. */ + bool m_write_png_images; + +#if (MEASURE_TIME_CPUCLOCK == 1) + struct timespec m_start, m_stop; +#endif +}; + +#endif // MAINWINDOW_H diff --git a/src/tools/livevis/client/mainwindow.ui b/src/tools/livevis/client/mainwindow.ui new file mode 100644 index 0000000000..9f5dfa6bad --- /dev/null +++ b/src/tools/livevis/client/mainwindow.ui @@ -0,0 +1,1220 @@ + + + MainWindow + + + + 0 + 0 + 1920 + 1080 + + + + PIConGPU - In Situ Visualization + + + /* QSlider Style Sheet */ + +QSlider::handle:vertical { + border: 1px solid grey; + border-radius: 2px; + background-color: #666666; + margin: 0 -4px; + height: 10px; +} + +QSlider::groove:vertical { + width: 4px; + border: 1px solid black; +} + +QSlider::handle:horizontal { + border: 1px solid grey; + border-radius: 2px; + background-color: #666666; + margin: -4px 0; + width: 10px; +} + +QSlider::groove:horizontal { + height: 4px; + border: 1px solid black; +} + +QSlider::sub-page { + background: #444444; +} + +QSlider::add-page { + background: #336699; +} + +/* QRadioButton Style Sheet */ + +QRadioButton::indicator { + width: 16px; + height: 16px; + border: 2px outset grey; + border-radius: 4px; +} + +QRadioButton::indicator::unchecked { + background: #666666; +} + +QRadioButton::indicator::checked { + background: #336699; +} + + + + + 0 + + + 0 + + + + + 4 + + + 4 + + + 4 + + + + + + 0 + 0 + + + + + 300 + 0 + + + + QWidget { + background-color: #333333; + color: #FFFFFF; +} + +#dataSidebar { + border: 1px solid gray; + border-left: 0px; +} + + + + 6 + + + + + + + + + Datasource A + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Datasource B + + + + + + + + + + + + + + + 100 + + + 100 + + + Qt::Vertical + + + + + + + + + + + + + 0 + 0 + + + + + 300 + 0 + + + + QWidget { + background-color: #333333; + color: #FFFFFF; +} + +#transferfuncSidebar { + border: 1px solid gray; + border-left: 0px; +} + + + + 2 + + + 1 + + + 1 + + + 1 + + + + + 0 + + + + + + + No Datasource + + + + + + Red-Green + + + + + + + Temperature + + + + + + + 2-Hue + + + + + + + + + + + + 0 + + + QLayout::SetDefaultConstraint + + + 4 + + + 4 + + + + + 0 + + + 100 + + + 50 + + + Qt::Vertical + + + + + + + 100 + + + 50 + + + Qt::Vertical + + + + + + + 0 + + + 100 + + + 50 + + + Qt::Vertical + + + + + + + + + + 0 + 0 + + + + + 40 + 0 + + + + + + + true + + + + + + + + + 0 + + + + + + + No Datasource + + + + + + Red-Green + + + + + + + Temperature + + + + + + + 2-Hue + + + + + + + + + + + + 0 + + + 4 + + + 4 + + + + + 0 + + + 100 + + + 50 + + + Qt::Vertical + + + + + + + 100 + + + 50 + + + Qt::Vertical + + + + + + + 0 + + + 100 + + + 50 + + + Qt::Vertical + + + + + + + + + + 0 + 0 + + + + + 40 + 0 + + + + + + + true + + + + + + + + + + + + + 0 + 0 + + + + + 300 + 0 + + + + QWidget { + background-color: #333333; + color: #FFFFFF; +} + +#settingsSidebar { + border: 1px solid gray; + border-left: 0px; +} + + + + 1 + + + + + Compositing Mode + + + + + + Qt::RightToLeft + + + Alpha Blending + + + + + + + Qt::RightToLeft + + + Maximum Intensity Projection + + + + + + + Qt::RightToLeft + + + Iso Surface + + + + + + + Iso Value + + + + + + + 100 + + + 50 + + + Qt::Horizontal + + + + + + + + + + Backgroundcolor + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + + QLabel { + background-color: black; +} + + + Qt::AutoText + + + true + + + Qt::AlignCenter + + + + + + + + + + + + Qt::Horizontal + + + + 639 + 20 + + + + + + + + 4 + + + 4 + + + 0 + + + + + + 0 + 0 + + + + + 0 + 40 + + + + + 16777215 + 160 + + + + QWidget { + background-color: #333333; + color: #FFFFFF; +} + +QWidget#infoBar { + border: 1px solid gray; + border-right: 0px; +} + + + + 4 + + + 4 + + + + + 6 + + + 6 + + + + + + 30 + 30 + + + + + 30 + 30 + + + + + + + + :/icons/play_button.png + + + + false + + + + + + + + 30 + 30 + + + + + 30 + 30 + + + + + + + + :/icons/home_button.png:/icons/home_button.png + + + + + + + + 30 + 30 + + + + + 30 + 30 + + + + Off + + + + + + + + + + + + DejaVu Sans + 14 + 75 + true + + + + Timestep: + + + + + + + + DejaVu Sans + 14 + 75 + true + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 8 + + + + + + + + + + + + DejaVu Sans + 14 + 75 + true + + + + Simulation FPS: + + + + + + + + DejaVu Sans + 14 + 75 + true + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 8 + + + + + + + + + + + + DejaVu Sans + 14 + 75 + true + + + + Render FPS: + + + + + + + + DejaVu Sans + 14 + 75 + true + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 8 + + + + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + QWidget { + background-color: #333333; + color: #FFFFFF; +} + +#clipSidebar { + border: 1px solid gray; + border-right: 0px; +} + + + + + + Z + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + 100 + + + 100 + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + 100 + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + 100 + + + Qt::Vertical + + + + + + + Y + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + X + + + Qt::AlignHCenter|Qt::AlignTop + + + + + + + + 0 + 0 + + + + 100 + + + 100 + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + 100 + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + 100 + + + 100 + + + Qt::Horizontal + + + + + + + Clipping + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + true + + + + 669 + 63 + + + + + 0 + 0 + + + + + true + + + + Qt::PreventContextMenu + + + false + + + Qt::ImhNone + + + QDockWidget::DockWidgetVerticalTitleBar + + + 8 + + + + true + + + + 0 + 0 + + + + Qt::PreventContextMenu + + + true + + + + + + 0 + + + QLayout::SetMaximumSize + + + + + + 0 + 0 + + + + + DejaVu Sans + 28 + 75 + true + + + + 0 GPUs + + + true + + + Qt::AlignCenter + + + Qt::NoTextInteraction + + + + + + + + 0 + 0 + + + + + DejaVu Sans + 28 + 75 + true + + + + 100 Cells + + + true + + + Qt::AlignCenter + + + Qt::NoTextInteraction + + + + + + + + 0 + 0 + + + + + DejaVu Sans + 28 + 75 + true + + + + 123 Particles + + + true + + + Qt::AlignCenter + + + Qt::NoTextInteraction + + + + + + + + + + + + + GLWidget + QWidget +
glwidget.h
+ 1 + + clicked() + +
+ + ClickableLabel + QLabel +
clickablelabel.h
+
+ + VerboseLabel + QLabel +
verboselabel.h
+
+
+ + + + +
diff --git a/src/tools/livevis/client/math_helper.h b/src/tools/livevis/client/math_helper.h new file mode 100644 index 0000000000..1d21119483 --- /dev/null +++ b/src/tools/livevis/client/math_helper.h @@ -0,0 +1,547 @@ +/** + * Copyright 2013 Benjamin Schneider + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + +#ifndef INSITUVOLUME_MATHHELPER_HPP +#define INSITUVOLUME_MATHHELPER_HPP + +#include +#include "transferfunctions.h" + +struct float3 +{ + float3() : x(0.0f), y(0.0f), z(0.0f) { } + float3(float _x, float _y, float _z) : x(_x), y(_y), z(_z) { } + float3(float4 f4) : x(f4.x), y(f4.y), z(f4.z) { } + + float x, y, z; +}; + +/** + * A collection of math classes and functions needed for the Volume Renderer. + */ +class float4x4; + +/// Negation +inline float3 operator-(const float3& a) +{ + return float3(-a.x, -a.y, -a.z); +} + +/// Addition +inline float3 operator+(float3 a, float3 b) +{ + return float3(a.x + b.x, a.y + b.y, a.z + b.z); +} + +inline void operator+=(float3 &a, float3 b) +{ + a.x += b.x; + a.y += b.y; + a.z += b.z; +} + +inline float4 operator+(float4 a, float4 b) +{ + return float4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w); +} + +inline float4 operator+(float4 a, float b) +{ + return float4(a.x + b, a.y + b, a.z + b, a.w + b); +} + +inline void operator+=(float4& a, float4 b) +{ + a.x += b.x; + a.y += b.y; + a.z += b.z; + a.w += b.w; +} + +inline void operator+=(volatile float4& a, float4 b) +{ + a.x += b.x; + a.y += b.y; + a.z += b.z; + a.w += b.w; +} + +/// Subtract +inline float3 operator-(float3 a, float b) +{ + return float3(a.x - b, a.y - b, a.z - b); +} + +inline float3 operator-(float3 a, float3 b) +{ + return float3(a.x - b.x, a.y - b.y, a.z - b.z); +} + +/// Multiply +inline float3 operator*(float3 a, float b) +{ + return float3(a.x * b, a.y * b, a.z * b); +} + +inline float3 operator*(float3 a, float3 b) +{ + return float3(a.x * b.x, a.y * b.y, a.z * b.z); +} + +inline float4 operator*(float4 a, float b) +{ + return float4(a.x * b, a.y * b, a.z * b, a.w * b); +} + +/// Divide +inline float3 operator/(float3 a, float3 b) +{ + return float3(a.x / b.x, a.y / b.y, a.z / b.z); +} + +/// Min and Max +inline float fminf(float a, float b) +{ + return a < b ? a : b; +} + +inline float fmaxf(float a, float b) +{ + return a > b ? a : b; +} + +inline float3 fminf(float3 a, float3 b) +{ + return float3(fminf(a.x,b.x), fminf(a.y,b.y), fminf(a.z,b.z)); +} + +inline float3 fmaxf(float3 a, float3 b) +{ + return float3(fmaxf(a.x,b.x), fmaxf(a.y,b.y), fmaxf(a.z,b.z)); +} + +/// Dot Product +inline float dot(float3 a, float3 b) +{ + return a.x * b.x + a.y * b.y + a.z * b.z; +} + +inline float dot(float4 a, float4 b) +{ + return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w; +} + +/// Cross Product +inline float3 cross(float3 a, float3 b) +{ + return float3(a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x); +} + +/// Normalization +inline float3 normalize(float3 v) +{ + float invLen = 1.0f / sqrt(dot(v, v)); + return v * invLen; +} + +/// clamping functions +inline float clamp(float v, float min, float max) +{ + if (v <= min) return min; + if (v >= max) return max; + return v; +} + +inline float saturate(float v) +{ + return clamp(v, 0.0f, 1.0f); +} + +inline float4 saturate(float4 val) +{ + float4 out; + + out.x = clamp(val.x, 0.0f, 1.0f); + out.y = clamp(val.y, 0.0f, 1.0f); + out.z = clamp(val.z, 0.0f, 1.0f); + out.w = clamp(val.w, 0.0f, 1.0f); + + return out; +} + +/** + * Helper class for matrices. Uses column-major memory layout (like OpenGL). + */ +class float4x4 +{ +private: + + float m[16]; + +public: + +#ifndef __CUDACC__ + + /// constructors + float4x4() { } + + float4x4(float4x4 const& rhs) + { + for (int i = 0; i < 16; i++) m[i] = rhs[i]; + } + + float4x4(const float* rhs) + { + for (int i = 0; i < 16; i++) m[i] = rhs[i]; + } + + explicit float4x4(const float v) + { + for (int i = 0; i < 16; i++) m[i] = v; + } + +#endif + + float& operator[](int i) + { + return m[i]; + } + + const float& operator[](int i) const + { + return m[i]; + } + + float& get(int row, int col) + { + return m[row + (col * 4)]; + } + + const float& get(int row, int col) const + { + return m[row + (col * 4)]; + } + + float4 getRow(int row) const + { + float4 v; + v.x = get(row, 0); + v.y = get(row, 1); + v.z = get(row, 2); + v.w = get(row, 3); + return v; + } + + float4 getCol(int col) const + { + float4 v; + v.x = get(0, col); + v.y = get(1, col); + v.z = get(2, col); + v.w = get(3, col); + return v; + } + + operator float*() + { + return m; + } + + operator const float*() const + { + return m; + } + + float4x4& operator=(float4x4 const& rhs) + { + for (int i = 0; i < 16; i++) m[i] = rhs[i]; + return (*this); + } + + float4x4& operator+=(float4x4 const& rhs) + { + for(int i = 0; i < 16; i++) m[i] += rhs[i]; + return (*this); + } + + float4x4& operator-=(float4x4 const& rhs) + { + for(int i = 0; i < 16; i++) m[i] -= rhs[i]; + return (*this); + } + + float4x4 operator*(float4x4 const & rhs) + { + float4x4 v; + + v[0] = m[0] * rhs[0] + m[4] * rhs[1] + m[8] * rhs[2] + m[12] * rhs[3]; + v[1] = m[1] * rhs[0] + m[5] * rhs[1] + m[9] * rhs[2] + m[13] * rhs[3]; + v[2] = m[2] * rhs[0] + m[6] * rhs[1] + m[10] * rhs[2] + m[14] * rhs[3]; + v[3] = m[3] * rhs[0] + m[7] * rhs[1] + m[11] * rhs[2] + m[15] * rhs[3]; + + v[4] = m[0] * rhs[4] + m[4] * rhs[5] + m[8] * rhs[6] + m[12] * rhs[7]; + v[5] = m[1] * rhs[4] + m[5] * rhs[5] + m[9] * rhs[6] + m[13] * rhs[7]; + v[6] = m[2] * rhs[4] + m[6] * rhs[5] + m[10] * rhs[6] + m[14] * rhs[7]; + v[7] = m[3] * rhs[4] + m[7] * rhs[5] + m[11] * rhs[6] + m[15] * rhs[7]; + + v[8] = m[0] * rhs[8] + m[4] * rhs[9] + m[8] * rhs[10] + m[12] * rhs[11]; + v[9] = m[1] * rhs[8] + m[5] * rhs[9] + m[9] * rhs[10] + m[13] * rhs[11]; + v[10] = m[2] * rhs[8] + m[6] * rhs[9] + m[10] * rhs[10] + m[14] * rhs[11]; + v[11] = m[3] * rhs[8] + m[7] * rhs[9] + m[11] * rhs[10] + m[15] * rhs[11]; + + v[12] = m[0] * rhs[12] + m[4] * rhs[13] + m[8] * rhs[14] + m[12] * rhs[15]; + v[13] = m[1] * rhs[12] + m[5] * rhs[13] + m[9] * rhs[14] + m[13] * rhs[15]; + v[14] = m[2] * rhs[12] + m[6] * rhs[13] + m[10] * rhs[14] + m[14] * rhs[15]; + v[15] = m[3] * rhs[12] + m[7] * rhs[13] + m[11] * rhs[14] + m[15] * rhs[15]; + + return v; + } + + const float4 operator*(float4 const & rhs) const + { + return float4( + m[0] * rhs.x + m[4] * rhs.y + m[8] * rhs.z + m[12] * rhs.w, + m[1] * rhs.x + m[5] * rhs.y + m[9] * rhs.z + m[13] * rhs.w, + m[2] * rhs.x + m[6] * rhs.y + m[10] * rhs.z + m[14] * rhs.w, + m[3] * rhs.x + m[7] * rhs.y + m[11] * rhs.z + m[15] * rhs.w); + } + + /// helper methods + static void make_identity(float4x4& v) + { + v[0] = v[5] = v[10] = v[15] = 1.0f; + v[1] = v[2] = v[3] = v[4] = v[6] = v[7] = v[8] = v[9] = v[11] = v[12] = v[13] = v[14] = 0.0f; + } + + static float4x4 make_view(float3 eye, float3 target, float3 up) + { + float3 zaxis = normalize(eye - target); + + /// if up and zaxis are nearly parallel choose an alternative up axis + if (fabs(dot(up, zaxis)) > 0.9999f) + { + /// turn up by 90 degree + up = normalize(float3(-up.y, up.x, up.z)); + } + + float3 xaxis = normalize(cross(up, zaxis)); + float3 yaxis = normalize(cross(zaxis, xaxis)); + + float4x4 rotation; + + rotation[0] = xaxis.x; + rotation[1] = yaxis.x; + rotation[2] = zaxis.x; + rotation[3] = 0.0f; + + rotation[4] = xaxis.y; + rotation[5] = yaxis.y; + rotation[6] = zaxis.y; + rotation[7] = 0.0f; + + rotation[8] = xaxis.z; + rotation[9] = yaxis.z; + rotation[10] = zaxis.z; + rotation[11] = 0.0f; + + rotation[12] = 0.0f; + rotation[13] = 0.0f; + rotation[14] = 0.0f; + rotation[15] = 1.0f; + + float4x4 translation; + + translation[0] = 1.0f; + translation[1] = 0.0f; + translation[2] = 0.0f; + translation[3] = 0.0f; + + translation[4] = 0.0f; + translation[5] = 1.0f; + translation[6] = 0.0f; + translation[7] = 0.0f; + + translation[8] = 0.0f; + translation[9] = 0.0f; + translation[10] = 1.0f; + translation[11] = 0.0f; + + translation[12] = -eye.x; + translation[13] = -eye.y; + translation[14] = -eye.z; + translation[15] = 1.0f; + + return (rotation * translation); + } + + static float4x4 make_inv_view(float3 eye, float3 target, float3 up) + { + float3 zaxis = normalize(eye - target); + + /// if up and zaxis are nearly parallel choose an alternative up axis + if (fabs(dot(up, zaxis)) > 0.9999f) + { + /// turn up by 90 degree + up = normalize(float3(-up.y, up.x, up.z)); + } + + float3 xaxis = normalize(cross(up, zaxis)); + float3 yaxis = normalize(cross(zaxis, xaxis)); + + float4x4 rotation; + + rotation[0] = xaxis.x; + rotation[1] = xaxis.y; + rotation[2] = xaxis.z; + rotation[3] = 0.0f; + + rotation[4] = yaxis.x; + rotation[5] = yaxis.y; + rotation[6] = yaxis.z; + rotation[7] = 0.0f; + + rotation[8] = zaxis.x; + rotation[9] = zaxis.y; + rotation[10] = zaxis.z; + rotation[11] = 0.0f; + + rotation[12] = 0.0f; + rotation[13] = 0.0f; + rotation[14] = 0.0f; + rotation[15] = 1.0f; + + float4x4 translation; + + translation[0] = 1.0f; + translation[1] = 0.0f; + translation[2] = 0.0f; + translation[3] = 0.0f; + + translation[4] = 0.0f; + translation[5] = 1.0f; + translation[6] = 0.0f; + translation[7] = 0.0f; + + translation[8] = 0.0f; + translation[9] = 0.0f; + translation[10] = 1.0f; + translation[11] = 0.0f; + + translation[12] = eye.x; + translation[13] = eye.y; + translation[14] = eye.z; + translation[15] = 1.0f; + + return (translation * rotation); + } + + static float4x4 make_rotation_x(float degree) + { + static const float PI = 3.14159265f; + + float4x4 rotation; + + float s = sin(PI * degree / 180.0f); + float c = cos(PI * degree / 180.0f); + + rotation[0] = 1.0f; + rotation[1] = 0.0f; + rotation[2] = 0.0f; + rotation[3] = 0.0f; + + rotation[4] = 0.0f; + rotation[5] = c; + rotation[6] = s; + rotation[7] = 0.0f; + + rotation[8] = 0.0f; + rotation[9] = -s; + rotation[10] = c; + rotation[11] = 0.0f; + + rotation[0] = 0.0f; + rotation[0] = 0.0f; + rotation[0] = 0.0f; + rotation[0] = 1.0f; + + return rotation; + } + + static float4x4 make_rotation_around_axis(float3 axis, float degree) + { + static const float PI = 3.14159265f; + + float4x4 rotation; + + float cos = cosf(PI * degree / 180.0f); + float sin = sinf(PI * degree / 180.0f); + + rotation[0] = cos + axis.x * axis.x * (1.0f - cos); + rotation[1] = axis.y * axis.x * (1.0f - cos) + axis.z * sin; + rotation[2] = axis.z * axis.x * (1.0f - cos) - axis.y * sin; + rotation[3] = 0.0f; + + rotation[4] = axis.x * axis.y * (1.0f - cos) - axis.z * sin; + rotation[5] = cos + axis.y * axis.y * (1.0f - cos); + rotation[6] = axis.z * axis.y * (1.0f - cos) + axis.x * sin; + rotation[7] = 0.0f; + + rotation[8] = axis.x * axis.z * (1.0f - cos) + axis.y * sin; + rotation[9] = axis.y * axis.z * (1.0f - cos) - axis.x * sin; + rotation[10] = cos + axis.z * axis.z * (1.0f - cos); + rotation[11] = 0.0f; + + rotation[12] = 0.0f; + rotation[13] = 0.0f; + rotation[14] = 0.0f; + rotation[15] = 1.0f; + + return rotation; + } + + static float4x4 make_translation(float3 t) + { + float4x4 translation; + + translation[0] = 0.0f; + translation[1] = 0.0f; + translation[2] = 0.0f; + translation[3] = 0.0f; + + translation[4] = 0.0f; + translation[5] = 0.0f; + translation[6] = 0.0f; + translation[7] = 0.0f; + + translation[8] = 0.0f; + translation[9] = 0.0f; + translation[10] = 0.0f; + translation[11] = 0.0f; + + translation[12] = t.x; + translation[13] = t.y; + translation[14] = t.z; + translation[15] = 1.0f; + + return translation; + } +}; + +#endif /* INSITUVOLUME_MATHHELPER_HPP */ diff --git a/src/tools/livevis/client/message_ids.hpp b/src/tools/livevis/client/message_ids.hpp new file mode 120000 index 0000000000..25004d1af9 --- /dev/null +++ b/src/tools/livevis/client/message_ids.hpp @@ -0,0 +1 @@ +../server/include/net/message_ids.hpp \ No newline at end of file diff --git a/src/tools/livevis/client/pause_button.png b/src/tools/livevis/client/pause_button.png new file mode 100644 index 0000000000..f3ae0771a9 Binary files /dev/null and b/src/tools/livevis/client/pause_button.png differ diff --git a/src/tools/livevis/client/pictureflow.cpp b/src/tools/livevis/client/pictureflow.cpp new file mode 100644 index 0000000000..e5a8facf26 --- /dev/null +++ b/src/tools/livevis/client/pictureflow.cpp @@ -0,0 +1,1047 @@ +/* + PictureFlow - animated image show widget + http://pictureflow.googlecode.com + + Copyright (C) 2009 Ariya Hidayat (ariya@kde.org) + Copyright (C) 2008 Ariya Hidayat (ariya@kde.org) + Copyright (C) 2007 Ariya Hidayat (ariya@kde.org) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +#include "pictureflow.h" + +// detect Qt version +#if QT_VERSION < 0x040300 +#error PictureFlow widgets need Qt 4.3 or later +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// for fixed-point arithmetic, we need minimum 32-bit long +// long long (64-bit) might be useful for multiplication and division +typedef long PFreal; +#define PFREAL_SHIFT 10 +#define PFREAL_ONE (1 << PFREAL_SHIFT) + +#define IANGLE_MAX 1024 +#define IANGLE_MASK 1023 + +inline PFreal fmul(PFreal a, PFreal b) +{ + return ((long long)(a))*((long long)(b)) >> PFREAL_SHIFT; +} + +inline PFreal fdiv(PFreal num, PFreal den) +{ + long long p = (long long)(num) << (PFREAL_SHIFT * 2); + long long q = p / (long long)den; + long long r = q >> PFREAL_SHIFT; + + return r; +} + +inline PFreal fsin(int iangle) +{ + // warning: regenerate the table if IANGLE_MAX and PFREAL_SHIFT are changed! + static const PFreal tab[] = { + 3, 103, 202, 300, 394, 485, 571, 652, + 726, 793, 853, 904, 947, 980, 1004, 1019, + 1023, 1018, 1003, 978, 944, 901, 849, 789, + 721, 647, 566, 479, 388, 294, 196, 97, + -4, -104, -203, -301, -395, -486, -572, -653, + -727, -794, -854, -905, -948, -981, -1005, -1020, + -1024, -1019, -1004, -979, -945, -902, -850, -790, + -722, -648, -567, -480, -389, -295, -197, -98, + 3 + }; + + while (iangle < 0) + iangle += IANGLE_MAX; + iangle &= IANGLE_MASK; + + int i = (iangle >> 4); + PFreal p = tab[i]; + PFreal q = tab[(i+1)]; + PFreal g = (q - p); + return p + g *(iangle - i*16) / 16; +} + +inline PFreal fcos(int iangle) +{ + return fsin(iangle + (IANGLE_MAX >> 2)); +} + +/* ---------------------------------------------------------- + +PictureFlowState stores the state of all slides, i.e. all the necessary +information to be able to render them. + +PictureFlowAnimator is responsible to move the slides during the +transition between slides, to achieve the effect similar to Cover Flow, +by changing the state. + +PictureFlowSoftwareRenderer (or PictureFlowOpenGLRenderer) is +the actual 3-d renderer. It should render all slides given the state +(an instance of PictureFlowState). + +Instances of all the above three classes are stored in +PictureFlowPrivate. + +------------------------------------------------------- */ + +struct SlideInfo { + int slideIndex; + int angle; + PFreal cx; + PFreal cy; + int blend; +}; + +class PictureFlowState +{ +public: + PictureFlowState(); + ~PictureFlowState(); + + void reposition(); + void reset(); + + QRgb backgroundColor; + int slideWidth; + int slideHeight; + PictureFlow::ReflectionEffect reflectionEffect; + QVector slideImages; + + int angle; + int spacing; + PFreal offsetX; + PFreal offsetY; + + SlideInfo centerSlide; + QVector leftSlides; + QVector rightSlides; + int centerIndex; +}; + +class PictureFlowAnimator +{ +public: + PictureFlowAnimator(); + PictureFlowState* state; + + void start(int slide); + void stop(int slide); + void update(); + + int target; + int step; + int frame; + QTimer animateTimer; +}; + +class PictureFlowAbstractRenderer +{ +public: + PictureFlowAbstractRenderer(): state(0), dirty(false), widget(0) {} + virtual ~PictureFlowAbstractRenderer() {} + + PictureFlowState* state; + bool dirty; + QWidget* widget; + + virtual void init() = 0; + virtual void paint() = 0; +}; + +class PictureFlowSoftwareRenderer: public PictureFlowAbstractRenderer +{ +public: + PictureFlowSoftwareRenderer(); + ~PictureFlowSoftwareRenderer(); + + virtual void init(); + virtual void paint(); + +private: + QSize size; + QRgb bgcolor; + int effect; + QImage buffer; + QVector rays; + QImage* blankSurface; + QCache surfaceCache; + QHash imageHash; + + void render(); + void renderSlides(); + QRect renderSlide(const SlideInfo &slide, int col1 = -1, int col2 = -1); + QImage* surface(int slideIndex); +}; + +// ------------- PictureFlowState --------------------------------------- + +PictureFlowState::PictureFlowState(): + backgroundColor(0), slideWidth(150), slideHeight(200), + reflectionEffect(PictureFlow::BlurredReflection), centerIndex(0) +{ +} + +PictureFlowState::~PictureFlowState() +{ + for (int i = 0; i < (int)slideImages.count(); i++) + delete slideImages[i]; +} + +// readjust the settings, call this when slide dimension is changed +void PictureFlowState::reposition() +{ + angle = 70 * IANGLE_MAX / 360; // approx. 70 degrees tilted + + offsetX = slideWidth / 2 * (PFREAL_ONE - fcos(angle)); + offsetY = slideWidth / 2 * fsin(angle); + offsetX += slideWidth * PFREAL_ONE; + offsetY += slideWidth * PFREAL_ONE / 4; + spacing = 40; +} + +// adjust slides so that they are in "steady state" position +void PictureFlowState::reset() +{ + centerSlide.angle = 0; + centerSlide.cx = 0; + centerSlide.cy = 0; + centerSlide.slideIndex = centerIndex; + centerSlide.blend = 256; + + leftSlides.resize(6); + for (int i = 0; i < (int)leftSlides.count(); i++) { + SlideInfo& si = leftSlides[i]; + si.angle = angle; + si.cx = -(offsetX + spacing * i * PFREAL_ONE); + si.cy = offsetY; + si.slideIndex = centerIndex - 1 - i; + si.blend = 256; + if (i == (int)leftSlides.count() - 2) + si.blend = 128; + if (i == (int)leftSlides.count() - 1) + si.blend = 0; + } + + rightSlides.resize(6); + for (int i = 0; i < (int)rightSlides.count(); i++) { + SlideInfo& si = rightSlides[i]; + si.angle = -angle; + si.cx = offsetX + spacing * i * PFREAL_ONE; + si.cy = offsetY; + si.slideIndex = centerIndex + 1 + i; + si.blend = 256; + if (i == (int)rightSlides.count() - 2) + si.blend = 128; + if (i == (int)rightSlides.count() - 1) + si.blend = 0; + } +} + +// ------------- PictureFlowAnimator --------------------------------------- + +PictureFlowAnimator::PictureFlowAnimator(): + state(0), target(0), step(0), frame(0) +{ +} + +void PictureFlowAnimator::start(int slide) +{ + target = slide; + if (!animateTimer.isActive() && state) { + step = (target < state->centerSlide.slideIndex) ? -1 : 1; + animateTimer.start(30); + } +} + +void PictureFlowAnimator::stop(int slide) +{ + step = 0; + target = slide; + frame = slide << 16; + animateTimer.stop(); +} + +void PictureFlowAnimator::update() +{ + if (!animateTimer.isActive()) + return; + if (step == 0) + return; + if (!state) + return; + + int speed = 16384 / 4; + +#if 1 + // deaccelerate when approaching the target + const int max = 2 * 65536; + + int fi = frame; + fi -= (target << 16); + if (fi < 0) + fi = -fi; + fi = qMin(fi, max); + + int ia = IANGLE_MAX * (fi - max / 2) / (max * 2); + speed = 512 + 16384 * (PFREAL_ONE + fsin(ia)) / PFREAL_ONE; +#endif + + frame += speed * step; + + int index = frame >> 16; + int pos = frame & 0xffff; + int neg = 65536 - pos; + int tick = (step < 0) ? neg : pos; + PFreal ftick = (tick * PFREAL_ONE) >> 16; + + if (step < 0) + index++; + + if (state->centerIndex != index) { + state->centerIndex = index; + frame = index << 16; + state->centerSlide.slideIndex = state->centerIndex; + for (int i = 0; i < (int)state->leftSlides.count(); i++) + state->leftSlides[i].slideIndex = state->centerIndex - 1 - i; + for (int i = 0; i < (int)state->rightSlides.count(); i++) + state->rightSlides[i].slideIndex = state->centerIndex + 1 + i; + } + + state->centerSlide.angle = (step * tick * state->angle) >> 16; + state->centerSlide.cx = -step * fmul(state->offsetX, ftick); + state->centerSlide.cy = fmul(state->offsetY, ftick); + + if (state->centerIndex == target) { + stop(target); + state->reset(); + return; + } + + for (int i = 0; i < (int)state->leftSlides.count(); i++) { + SlideInfo& si = state->leftSlides[i]; + si.angle = state->angle; + si.cx = -(state->offsetX + state->spacing * i * PFREAL_ONE + step * state->spacing * ftick); + si.cy = state->offsetY; + } + + for (int i = 0; i < (int)state->rightSlides.count(); i++) { + SlideInfo& si = state->rightSlides[i]; + si.angle = -state->angle; + si.cx = state->offsetX + state->spacing * i * PFREAL_ONE - step * state->spacing * ftick; + si.cy = state->offsetY; + } + + if (step > 0) { + PFreal ftick = (neg * PFREAL_ONE) >> 16; + state->rightSlides[0].angle = -(neg * state->angle) >> 16; + state->rightSlides[0].cx = fmul(state->offsetX, ftick); + state->rightSlides[0].cy = fmul(state->offsetY, ftick); + } else { + PFreal ftick = (pos * PFREAL_ONE) >> 16; + state->leftSlides[0].angle = (pos * state->angle) >> 16; + state->leftSlides[0].cx = -fmul(state->offsetX, ftick); + state->leftSlides[0].cy = fmul(state->offsetY, ftick); + } + + // must change direction ? + if (target < index) if (step > 0) + step = -1; + if (target > index) if (step < 0) + step = 1; + + // the first and last slide must fade in/fade out + int nleft = state->leftSlides.count(); + int nright = state->rightSlides.count(); + int fade = pos / 256; + + for (int index = 0; index < nleft; index++) { + int blend = 256; + if (index == nleft - 1) + blend = (step > 0) ? 0 : 128 - fade / 2; + if (index == nleft - 2) + blend = (step > 0) ? 128 - fade / 2 : 256 - fade / 2; + if (index == nleft - 3) + blend = (step > 0) ? 256 - fade / 2 : 256; + state->leftSlides[index].blend = blend; + } + for (int index = 0; index < nright; index++) { + int blend = (index < nright - 2) ? 256 : 128; + if (index == nright - 1) + blend = (step > 0) ? fade / 2 : 0; + if (index == nright - 2) + blend = (step > 0) ? 128 + fade / 2 : fade / 2; + if (index == nright - 3) + blend = (step > 0) ? 256 : 128 + fade / 2; + state->rightSlides[index].blend = blend; + } + +} + +// ------------- PictureFlowSoftwareRenderer --------------------------------------- + +PictureFlowSoftwareRenderer::PictureFlowSoftwareRenderer(): + PictureFlowAbstractRenderer(), size(0, 0), bgcolor(0), effect(-1), blankSurface(0) +{ +} + +PictureFlowSoftwareRenderer::~PictureFlowSoftwareRenderer() +{ + surfaceCache.clear(); + buffer = QImage(); + delete blankSurface; +} + +void PictureFlowSoftwareRenderer::paint() +{ + if (!widget) + return; + + if (widget->size() != size) + init(); + + if (state->backgroundColor != bgcolor) { + bgcolor = state->backgroundColor; + surfaceCache.clear(); + } + + if ((int)(state->reflectionEffect) != effect) { + effect = (int)state->reflectionEffect; + surfaceCache.clear(); + } + + if (dirty) + render(); + + QPainter painter(widget); + painter.drawImage(QPoint(0, 0), buffer); +} + +void PictureFlowSoftwareRenderer::init() +{ + if (!widget) + return; + + surfaceCache.clear(); + blankSurface = 0; + + size = widget->size(); + int ww = size.width(); + int wh = size.height(); + int w = (ww + 1) / 2; + int h = (wh + 1) / 2; + + buffer = QImage(ww, wh, QImage::Format_RGB32); + buffer.fill(bgcolor); + + rays.resize(w*2); + for (int i = 0; i < w; i++) { + PFreal gg = ((PFREAL_ONE >> 1) + i * PFREAL_ONE) / (2 * h); + rays[w-i-1] = -gg; + rays[w+i] = gg; + } + + dirty = true; +} + +// TODO: optimize this with lookup tables +static QRgb blendColor(QRgb c1, QRgb c2, int blend) +{ + int r = qRed(c1) * blend / 256 + qRed(c2) * (256 - blend) / 256; + int g = qGreen(c1) * blend / 256 + qGreen(c2) * (256 - blend) / 256; + int b = qBlue(c1) * blend / 256 + qBlue(c2) * (256 - blend) / 256; + return qRgb(r, g, b); +} + + +static QImage* prepareSurface(const QImage* slideImage, int w, int h, QRgb bgcolor, + PictureFlow::ReflectionEffect reflectionEffect) +{ + Qt::TransformationMode mode = Qt::SmoothTransformation; + QImage img = slideImage->scaled(w, h, Qt::IgnoreAspectRatio, mode); + + // slightly larger, to accomodate for the reflection + int hs = h * 2; + int hofs = h / 3; + + // offscreen buffer: black is sweet + QImage* result = new QImage(hs, w, QImage::Format_RGB32); + result->fill(bgcolor); + + // transpose the image, this is to speed-up the rendering + // because we process one column at a time + // (and much better and faster to work row-wise, i.e in one scanline) + for (int x = 0; x < w; x++) + for (int y = 0; y < h; y++) + result->setPixel(hofs + y, x, img.pixel(x, y)); + + if (reflectionEffect != PictureFlow::NoReflection) { + // create the reflection + int ht = hs - h - hofs; + int hte = ht; + for (int x = 0; x < w; x++) + for (int y = 0; y < ht; y++) { + QRgb color = img.pixel(x, img.height() - y - 1); + result->setPixel(h + hofs + y, x, blendColor(color, bgcolor, 128*(hte - y) / hte)); + } + + if (reflectionEffect == PictureFlow::BlurredReflection) { + // blur the reflection everything first + // Based on exponential blur algorithm by Jani Huhtanen + QRect rect(hs / 2, 0, hs / 2, w); + rect &= result->rect(); + + int r1 = rect.top(); + int r2 = rect.bottom(); + int c1 = rect.left(); + int c2 = rect.right(); + + int bpl = result->bytesPerLine(); + int rgba[4]; + unsigned char* p; + + // how many times blur is applied? + // for low-end system, limit this to only 1 loop + for (int loop = 0; loop < 2; loop++) { + for (int col = c1; col <= c2; col++) { + p = result->scanLine(r1) + col * 4; + for (int i = 0; i < 3; i++) + rgba[i] = p[i] << 4; + + p += bpl; + for (int j = r1; j < r2; j++, p += bpl) + for (int i = 0; i < 3; i++) + p[i] = (rgba[i] += (((p[i] << 4) - rgba[i])) >> 1) >> 4; + } + + for (int row = r1; row <= r2; row++) { + p = result->scanLine(row) + c1 * 4; + for (int i = 0; i < 3; i++) + rgba[i] = p[i] << 4; + + p += 4; + for (int j = c1; j < c2; j++, p += 4) + for (int i = 0; i < 3; i++) + p[i] = (rgba[i] += (((p[i] << 4) - rgba[i])) >> 1) >> 4; + } + + for (int col = c1; col <= c2; col++) { + p = result->scanLine(r2) + col * 4; + for (int i = 0; i < 3; i++) + rgba[i] = p[i] << 4; + + p -= bpl; + for (int j = r1; j < r2; j++, p -= bpl) + for (int i = 0; i < 3; i++) + p[i] = (rgba[i] += (((p[i] << 4) - rgba[i])) >> 1) >> 4; + } + + for (int row = r1; row <= r2; row++) { + p = result->scanLine(row) + c2 * 4; + for (int i = 0; i < 3; i++) + rgba[i] = p[i] << 4; + + p -= 4; + for (int j = c1; j < c2; j++, p -= 4) + for (int i = 0; i < 3; i++) + p[i] = (rgba[i] += (((p[i] << 4) - rgba[i])) >> 1) >> 4; + } + } + + // overdraw to leave only the reflection blurred (but not the actual image) + for (int x = 0; x < w; x++) + for (int y = 0; y < h; y++) + result->setPixel(hofs + y, x, img.pixel(x, y)); + } + } + + return result; +} + +QImage* PictureFlowSoftwareRenderer::surface(int slideIndex) +{ + if (!state) + return 0; + if (slideIndex < 0) + return 0; + if (slideIndex >= (int)state->slideImages.count()) + return 0; + + int key = slideIndex; + + QImage* img = state->slideImages.at(slideIndex); + bool empty = img ? img->isNull() : true; + if (empty) { + surfaceCache.remove(key); + imageHash.remove(slideIndex); + if (!blankSurface) { + int sw = state->slideWidth; + int sh = state->slideHeight; + + QImage img = QImage(sw, sh, QImage::Format_RGB32); + + QPainter painter(&img); + QPoint p1(sw*4 / 10, 0); + QPoint p2(sw*6 / 10, sh); + QLinearGradient linearGrad(p1, p2); + linearGrad.setColorAt(0, Qt::black); + linearGrad.setColorAt(1, Qt::white); + painter.setBrush(linearGrad); + painter.fillRect(0, 0, sw, sh, QBrush(linearGrad)); + + painter.setPen(QPen(QColor(64, 64, 64), 4)); + painter.setBrush(QBrush()); + painter.drawRect(2, 2, sw - 3, sh - 3); + painter.end(); + + blankSurface = prepareSurface(&img, sw, sh, bgcolor, state->reflectionEffect); + } + return blankSurface; + } + + bool exist = imageHash.contains(slideIndex); + if (exist) + if (img == imageHash.find(slideIndex).value()) + if (surfaceCache.contains(key)) + return surfaceCache[key]; + + QImage* sr = prepareSurface(img, state->slideWidth, state->slideHeight, bgcolor, state->reflectionEffect); + surfaceCache.insert(key, sr); + imageHash.insert(slideIndex, img); + + return sr; +} + +// Renders a slide to offscreen buffer. Returns a rect of the rendered area. +// col1 and col2 limit the column for rendering. +QRect PictureFlowSoftwareRenderer::renderSlide(const SlideInfo &slide, int col1, int col2) +{ + int blend = slide.blend; + if (!blend) + return QRect(); + + QImage* src = surface(slide.slideIndex); + if (!src) + return QRect(); + + QRect rect(0, 0, 0, 0); + + int sw = src->height(); + int sh = src->width(); + int h = buffer.height(); + int w = buffer.width(); + + if (col1 > col2) { + int c = col2; + col2 = col1; + col1 = c; + } + + col1 = (col1 >= 0) ? col1 : 0; + col2 = (col2 >= 0) ? col2 : w - 1; + col1 = qMin(col1, w - 1); + col2 = qMin(col2, w - 1); + + int zoom = 100; + int distance = h * 100 / zoom; + PFreal sdx = fcos(slide.angle); + PFreal sdy = fsin(slide.angle); + PFreal xs = slide.cx - state->slideWidth * sdx / 2; + PFreal ys = slide.cy - state->slideWidth * sdy / 2; + PFreal dist = distance * PFREAL_ONE; + + int xi = qMax((PFreal)0, (w * PFREAL_ONE / 2) + fdiv(xs * h, dist + ys) >> PFREAL_SHIFT); + if (xi >= w) + return rect; + + bool flag = false; + rect.setLeft(xi); + for (int x = qMax(xi, col1); x <= col2; x++) { + PFreal hity = 0; + PFreal fk = rays[x]; + if (sdy) { + fk = fk - fdiv(sdx, sdy); + hity = -fdiv((rays[x] * distance - slide.cx + slide.cy * sdx / sdy), fk); + } + + dist = distance * PFREAL_ONE + hity; + if (dist < 0) + continue; + + PFreal hitx = fmul(dist, rays[x]); + PFreal hitdist = fdiv(hitx - slide.cx, sdx); + + int column = sw / 2 + (hitdist >> PFREAL_SHIFT); + if (column >= sw) + break; + if (column < 0) + continue; + + rect.setRight(x); + if (!flag) + rect.setLeft(x); + flag = true; + + int y1 = h / 2; + int y2 = y1 + 1; + QRgb* pixel1 = (QRgb*)(buffer.scanLine(y1)) + x; + QRgb* pixel2 = (QRgb*)(buffer.scanLine(y2)) + x; + QRgb pixelstep = pixel2 - pixel1; + + int center = (sh / 2); + int dy = dist / h; + int p1 = center * PFREAL_ONE - dy / 2; + int p2 = center * PFREAL_ONE + dy / 2; + + const QRgb *ptr = (const QRgb*)(src->scanLine(column)); + if (blend == 256) + while ((y1 >= 0) && (y2 < h) && (p1 >= 0)) { + *pixel1 = ptr[p1 >> PFREAL_SHIFT]; + *pixel2 = ptr[p2 >> PFREAL_SHIFT]; + p1 -= dy; + p2 += dy; + y1--; + y2++; + pixel1 -= pixelstep; + pixel2 += pixelstep; + } + else + while ((y1 >= 0) && (y2 < h) && (p1 >= 0)) { + QRgb c1 = ptr[p1 >> PFREAL_SHIFT]; + QRgb c2 = ptr[p2 >> PFREAL_SHIFT]; + *pixel1 = blendColor(c1, bgcolor, blend); + *pixel2 = blendColor(c2, bgcolor, blend); + p1 -= dy; + p2 += dy; + y1--; + y2++; + pixel1 -= pixelstep; + pixel2 += pixelstep; + } + } + + rect.setTop(0); + rect.setBottom(h - 1); + return rect; +} + +void PictureFlowSoftwareRenderer::renderSlides() +{ + int nleft = state->leftSlides.count(); + int nright = state->rightSlides.count(); + + QRect r = renderSlide(state->centerSlide); + int c1 = r.left(); + int c2 = r.right(); + + for (int index = 0; index < nleft; index++) { + QRect rs = renderSlide(state->leftSlides[index], 0, c1 - 1); + if (!rs.isEmpty()) + c1 = rs.left(); + } + for (int index = 0; index < nright; index++) { + QRect rs = renderSlide(state->rightSlides[index], c2 + 1, buffer.width()); + if (!rs.isEmpty()) + c2 = rs.right(); + } +} + +// Render the slides. Updates only the offscreen buffer. +void PictureFlowSoftwareRenderer::render() +{ + buffer.fill(state->backgroundColor); + renderSlides(); + dirty = false; +} + +// ----------------------------------------- + +class PictureFlowPrivate +{ +public: + PictureFlowState* state; + PictureFlowAnimator* animator; + PictureFlowAbstractRenderer* renderer; + QTimer triggerTimer; +}; + + +PictureFlow::PictureFlow(QWidget* parent): QWidget(parent) +{ + d = new PictureFlowPrivate; + + d->state = new PictureFlowState; + d->state->reset(); + d->state->reposition(); + + d->renderer = new PictureFlowSoftwareRenderer; + d->renderer->state = d->state; + d->renderer->widget = this; + d->renderer->init(); + + d->animator = new PictureFlowAnimator; + d->animator->state = d->state; + QObject::connect(&d->animator->animateTimer, SIGNAL(timeout()), this, SLOT(updateAnimation())); + + QObject::connect(&d->triggerTimer, SIGNAL(timeout()), this, SLOT(render())); + + setAttribute(Qt::WA_StaticContents, true); + setAttribute(Qt::WA_OpaquePaintEvent, true); + setAttribute(Qt::WA_NoSystemBackground, true); +} + +PictureFlow::~PictureFlow() +{ + delete d->renderer; + delete d->animator; + delete d->state; + delete d; +} + +int PictureFlow::slideCount() const +{ + return d->state->slideImages.count(); +} + +QColor PictureFlow::backgroundColor() const +{ + return QColor(d->state->backgroundColor); +} + +void PictureFlow::setBackgroundColor(const QColor& c) +{ + d->state->backgroundColor = c.rgb(); + triggerRender(); +} + +QSize PictureFlow::slideSize() const +{ + return QSize(d->state->slideWidth, d->state->slideHeight); +} + +void PictureFlow::setSlideSize(QSize size) +{ + d->state->slideWidth = size.width(); + d->state->slideHeight = size.height(); + d->state->reposition(); + triggerRender(); +} + +PictureFlow::ReflectionEffect PictureFlow::reflectionEffect() const +{ + return d->state->reflectionEffect; +} + +void PictureFlow::setReflectionEffect(ReflectionEffect effect) +{ + d->state->reflectionEffect = effect; + triggerRender(); +} + +QImage PictureFlow::slide(int index) const +{ + QImage* i = 0; + if ((index >= 0) && (index < slideCount())) + i = d->state->slideImages[index]; + return i ? QImage(*i) : QImage(); +} + +void PictureFlow::addSlide(const QImage& image) +{ + int c = d->state->slideImages.count(); + d->state->slideImages.resize(c + 1); + d->state->slideImages[c] = new QImage(image); + triggerRender(); +} + +void PictureFlow::addSlide(const QPixmap& pixmap) +{ + addSlide(pixmap.toImage()); +} + +void PictureFlow::removeSlide(int index) +{ + int c = d->state->slideImages.count(); + if (index >= 0 && index < c) { + d->state->slideImages.remove(index); + triggerRender(); + } +} + +void PictureFlow::setSlide(int index, const QImage& image) +{ + if ((index >= 0) && (index < slideCount())) { + QImage* i = image.isNull() ? 0 : new QImage(image); + delete d->state->slideImages[index]; + d->state->slideImages[index] = i; + triggerRender(); + } +} + +void PictureFlow::setSlide(int index, const QPixmap& pixmap) +{ + setSlide(index, pixmap.toImage()); +} + +int PictureFlow::centerIndex() const +{ + return d->state->centerIndex; +} + +void PictureFlow::setCenterIndex(int index) +{ + index = qMin(index, slideCount() - 1); + index = qMax(index, 0); + d->state->centerIndex = index; + d->state->reset(); + d->animator->stop(index); + triggerRender(); +} + +void PictureFlow::clear() +{ + int c = d->state->slideImages.count(); + for (int i = 0; i < c; i++) + delete d->state->slideImages[i]; + d->state->slideImages.resize(0); + + d->state->reset(); + triggerRender(); +} + +void PictureFlow::render() +{ + d->renderer->dirty = true; + update(); +} + +void PictureFlow::triggerRender() +{ + d->triggerTimer.setSingleShot(true); + d->triggerTimer.start(0); +} + +void PictureFlow::showPrevious() +{ + int step = d->animator->step; + int center = d->state->centerIndex; + + if (step > 0) + d->animator->start(center); + + if (step == 0) + if (center > 0) + d->animator->start(center - 1); + + if (step < 0) + d->animator->target = qMax(0, center - 2); +} + +void PictureFlow::showNext() +{ + int step = d->animator->step; + int center = d->state->centerIndex; + + if (step < 0) + d->animator->start(center); + + if (step == 0) + if (center < slideCount() - 1) + d->animator->start(center + 1); + + if (step > 0) + d->animator->target = qMin(center + 2, slideCount() - 1); +} + +void PictureFlow::showSlide(int index) +{ + index = qMax(index, 0); + index = qMin(slideCount() - 1, index); + if (index == d->state->centerSlide.slideIndex) + return; + + d->animator->start(index); +} + +void PictureFlow::keyPressEvent(QKeyEvent* event) +{ + if (event->key() == Qt::Key_Left) { + if (event->modifiers() == Qt::ControlModifier) + showSlide(centerIndex() - 10); + else + showPrevious(); + event->accept(); + return; + } + + if (event->key() == Qt::Key_Right) { + if (event->modifiers() == Qt::ControlModifier) + showSlide(centerIndex() + 10); + else + showNext(); + event->accept(); + return; + } + + event->ignore(); +} + +void PictureFlow::mousePressEvent(QMouseEvent* event) +{ + if (event->x() > width() / 2) + showNext(); + else + showPrevious(); +} + +void PictureFlow::paintEvent(QPaintEvent* event) +{ + Q_UNUSED(event); + d->renderer->paint(); +} + +void PictureFlow::resizeEvent(QResizeEvent* event) +{ + triggerRender(); + QWidget::resizeEvent(event); +} + +void PictureFlow::updateAnimation() +{ + int old_center = d->state->centerIndex; + d->animator->update(); + triggerRender(); + if (d->state->centerIndex != old_center) + emit centerIndexChanged(d->state->centerIndex); +} + diff --git a/src/tools/livevis/client/pictureflow.h b/src/tools/livevis/client/pictureflow.h new file mode 100644 index 0000000000..7c6f47b28f --- /dev/null +++ b/src/tools/livevis/client/pictureflow.h @@ -0,0 +1,202 @@ +/* + PictureFlow - animated image show widget + http://pictureflow.googlecode.com + + Copyright (C) 2009 Ariya Hidayat (ariya@kde.org) + Copyright (C) 2008 Ariya Hidayat (ariya@kde.org) + Copyright (C) 2007 Ariya Hidayat (ariya@kde.org) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +#ifndef PICTUREFLOW_H +#define PICTUREFLOW_H + +#include + +class PictureFlowPrivate; + +/*! + Class PictureFlow implements an image show widget with animation effect + like Apple's CoverFlow (in iTunes and iPod). Images are arranged in form + of slides, one main slide is shown at the center with few slides on + the left and right sides of the center slide. When the next or previous + slide is brought to the front, the whole slides flow to the right or + the right with smooth animation effect; until the new slide is finally + placed at the center. + + */ +class PictureFlow : public QWidget +{ + Q_OBJECT + + Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor) + Q_PROPERTY(QSize slideSize READ slideSize WRITE setSlideSize) + Q_PROPERTY(int slideCount READ slideCount) + Q_PROPERTY(int centerIndex READ centerIndex WRITE setCenterIndex) + +public: + + enum ReflectionEffect { + NoReflection, + PlainReflection, + BlurredReflection + }; + + /*! + Creates a new PictureFlow widget. + */ + PictureFlow(QWidget* parent = 0); + + /*! + Destroys the widget. + */ + ~PictureFlow(); + + /*! + Returns the background color. + */ + QColor backgroundColor() const; + + /*! + Sets the background color. By default it is black. + */ + void setBackgroundColor(const QColor& c); + + /*! + Returns the dimension of each slide (in pixels). + */ + QSize slideSize() const; + + /*! + Sets the dimension of each slide (in pixels). + */ + void setSlideSize(QSize size); + + /*! + Returns the total number of slides. + */ + int slideCount() const; + + /*! + Returns QImage of specified slide. + */ + QImage slide(int index) const; + + /*! + Returns the index of slide currently shown in the middle of the viewport. + */ + int centerIndex() const; + + /*! + Returns the effect applied to the reflection. + */ + ReflectionEffect reflectionEffect() const; + + /*! + Sets the effect applied to the reflection. The default is PlainReflection. + */ + void setReflectionEffect(ReflectionEffect effect); + + +public slots: + + /*! + Adds a new slide. + */ + void addSlide(const QImage& image); + + /*! + Adds a new slide. + */ + void addSlide(const QPixmap& pixmap); + + /*! + Removes an existing slide. + */ + void removeSlide(int index); + + /*! + Sets an image for specified slide. If the slide already exists, + it will be replaced. + */ + void setSlide(int index, const QImage& image); + + /*! + Sets a pixmap for specified slide. If the slide already exists, + it will be replaced. + */ + void setSlide(int index, const QPixmap& pixmap); + + /*! + Sets slide to be shown in the middle of the viewport. No animation + effect will be produced, unlike using showSlide. + */ + void setCenterIndex(int index); + + /*! + Clears all slides. + */ + void clear(); + + /*! + Shows previous slide using animation effect. + */ + void showPrevious(); + + /*! + Shows next slide using animation effect. + */ + void showNext(); + + /*! + Go to specified slide using animation effect. + */ + void showSlide(int index); + + /*! + Rerender the widget. Normally this function will be automatically invoked + whenever necessary, e.g. during the transition animation. + */ + void render(); + + /*! + Schedules a rendering update. Unlike render(), this function does not cause + immediate rendering. + */ + void triggerRender(); + +signals: + void centerIndexChanged(int index); + +protected: + void paintEvent(QPaintEvent *event); + void keyPressEvent(QKeyEvent* event); + void mousePressEvent(QMouseEvent* event); + void resizeEvent(QResizeEvent* event); + +private slots: + void updateAnimation(); + +private: + PictureFlowPrivate* d; +}; + +#endif // PICTUREFLOW_H + diff --git a/src/tools/livevis/client/play_button.png b/src/tools/livevis/client/play_button.png new file mode 100644 index 0000000000..35a7b39e9b Binary files /dev/null and b/src/tools/livevis/client/play_button.png differ diff --git a/src/tools/livevis/client/simulationgallery.cpp b/src/tools/livevis/client/simulationgallery.cpp new file mode 100644 index 0000000000..3e0cca3ea6 --- /dev/null +++ b/src/tools/livevis/client/simulationgallery.cpp @@ -0,0 +1,111 @@ +#include "simulationgallery.h" +#include "ui_simulationgallery.h" + +#include +#include +#include + +#include "udpquery.h" + + +SimulationGallery::SimulationGallery(QWidget *parent) : + PictureFlow(parent), + ui(new Ui::SimulationGallery), + m_num_slides(0) +{ + ui->setupUi(this); +} + +SimulationGallery::~SimulationGallery() +{ + delete m_receiver_thread; + delete ui; +} + +void SimulationGallery::startQuery(std::string ip, int port) +{ + m_visserver_ip = ip; + m_visserver_infoport = port; + + /// create thread not to block GUI + m_receiver_thread = new QThread(); + + /// create query object + UDPQuery * query = new UDPQuery(ip, port); + query->moveToThread(m_receiver_thread); + + /// take care that objects are deleted + connect(m_receiver_thread, SIGNAL(started()), query, SLOT(start())); + connect(m_receiver_thread, SIGNAL(finished()), query, SLOT(deleteLater())); + connect(m_receiver_thread, SIGNAL(finished()), m_receiver_thread, SLOT(deleteLater())); + connect(query, SIGNAL(received_visualization(QString,QString)), this, SLOT(add_vis_name_uri_thumb(QString,QString))); + connect(query, SIGNAL(refreshing_list()), this, SLOT(on_refreshing_list())); + + m_receiver_thread->start(); +} + +void SimulationGallery::on_refreshing_list() +{ + this->clear(); + this->m_vis_index_uri.clear(); + m_num_slides = 0; +} + +void SimulationGallery::add_vis_name_uri_thumb(QString name, QString uri/*, QImage thumb*/) +{ + qDebug() << "Called add vis name uri thumb."; + qDebug() << "Adding Name/URI " << name << " / " << uri; + + QImage image(400, 200, QImage::Format_RGB32); + QPainter painter(&image); + + for (int x = 0; x < 400; x++) + { + for (int y = 0; y < 200; y++) + { + if ((x < 10 || x > 389) || (y < 4 || y > 195)) + image.setPixel(x, y, std::numeric_limits::max() - 1); + else + image.setPixel(x, y, 1); + } + } + + QFont font("Sans Serif", 17); + QPen pen(QColor::fromRgb(255,255,255)); + + painter.setFont(font); + painter.setPen(pen); + + painter.drawText(30, 120, 380, 30, 0, name); + painter.drawText(30, 160, 380, 30, 0, uri); + + this->addSlide(image); + + m_vis_index_uri[m_num_slides] = uri; + m_num_slides++; +} + +void SimulationGallery::keyPressEvent(QKeyEvent * event) +{ + if (event->key() == Qt::Key_F12 || event->key() == Qt::Key_Escape) + { + event->accept(); + emit on_hide_me(); + } + + /// connect to the choosen visualization + if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) + { + QString uri = m_vis_index_uri[this->centerIndex()]; + + qDebug() << "Enter pressed, connecting to " << uri; + + emit connect_to(uri); + emit on_hide_me(); + } + + //if (event->key() == Qt::Key_A) + // this->add_vis_name_uri_thumb("PIConGPU 2", "riv://149.220.4.50:52000/PIConGPU"); + + PictureFlow::keyPressEvent(event); +} diff --git a/src/tools/livevis/client/simulationgallery.h b/src/tools/livevis/client/simulationgallery.h new file mode 100644 index 0000000000..8f5d28dbaf --- /dev/null +++ b/src/tools/livevis/client/simulationgallery.h @@ -0,0 +1,54 @@ +#ifndef SIMULATIONGALLERY_H +#define SIMULATIONGALLERY_H + +#include +#include +#include +#include "pictureflow.h" + + +namespace Ui { +class SimulationGallery; +} + +class SimulationGallery : public PictureFlow +{ + Q_OBJECT + +public: + + explicit SimulationGallery(QWidget * parent = 0); + ~SimulationGallery(); + + void startQuery(std::string ip, int port); + +public slots: + + void add_vis_name_uri_thumb(QString name, QString uri/*, QImage thumb*/); + void on_refreshing_list(); + +signals: + + void on_hide_me(); + void connect_to(QString uri); + +protected: + + void keyPressEvent(QKeyEvent * event); + +private: + + Ui::SimulationGallery * ui; + + QThread * m_receiver_thread; + + /** save a list of available visualizations */ + std::map m_vis_index_uri; + int m_num_slides; + + /** Address and info portnumber of visualization server */ + std::string m_visserver_ip; + int m_visserver_infoport; +}; + +#endif // SIMULATIONGALLERY_H diff --git a/src/tools/livevis/client/simulationgallery.ui b/src/tools/livevis/client/simulationgallery.ui new file mode 100644 index 0000000000..8d92468c18 --- /dev/null +++ b/src/tools/livevis/client/simulationgallery.ui @@ -0,0 +1,19 @@ + + + SimulationGallery + + + + 0 + 0 + 767 + 492 + + + + Form + + + + + diff --git a/src/tools/livevis/client/transferfuncsidebar.cpp b/src/tools/livevis/client/transferfuncsidebar.cpp new file mode 100644 index 0000000000..d5eb0f6608 --- /dev/null +++ b/src/tools/livevis/client/transferfuncsidebar.cpp @@ -0,0 +1,14 @@ +#include "transferfuncsidebar.h" +#include "ui_transferfuncsidebar.h" + +TransferfuncSidebar::TransferfuncSidebar(QWidget *parent) : + QWidget(parent), + ui(new Ui::TransferfuncSidebar) +{ + ui->setupUi(this); +} + +TransferfuncSidebar::~TransferfuncSidebar() +{ + delete ui; +} diff --git a/src/tools/livevis/client/transferfuncsidebar.h b/src/tools/livevis/client/transferfuncsidebar.h new file mode 100644 index 0000000000..8a514f4ebd --- /dev/null +++ b/src/tools/livevis/client/transferfuncsidebar.h @@ -0,0 +1,22 @@ +#ifndef TRANSFERFUNCSIDEBAR_H +#define TRANSFERFUNCSIDEBAR_H + +#include + +namespace Ui { +class TransferfuncSidebar; +} + +class TransferfuncSidebar : public QWidget +{ + Q_OBJECT + +public: + explicit TransferfuncSidebar(QWidget *parent = 0); + ~TransferfuncSidebar(); + +private: + Ui::TransferfuncSidebar *ui; +}; + +#endif // TRANSFERFUNCSIDEBAR_H diff --git a/src/tools/livevis/client/transferfuncsidebar.ui b/src/tools/livevis/client/transferfuncsidebar.ui new file mode 100644 index 0000000000..c93d4e43be --- /dev/null +++ b/src/tools/livevis/client/transferfuncsidebar.ui @@ -0,0 +1,153 @@ + + + TransferfuncSidebar + + + + 0 + 0 + 411 + 405 + + + + Form + + + + + + + + + + + + Rainbow + + + + + + + Temperature + + + + + + + RadioButton + + + + + + + + + Qt::Vertical + + + + + + + Qt::Vertical + + + + + + + + + + 0 + 0 + + + + + 20 + 0 + + + + TF1 + + + + + + + + + + + + + + + Rainbow + + + + + + + Temperature + + + + + + + RadioButton + + + + + + + + + Qt::Vertical + + + + + + + Qt::Vertical + + + + + + + + + + 0 + 0 + + + + + 20 + 0 + + + + TF2 + + + + + + + + + + diff --git a/src/tools/livevis/client/transferfunctions.cpp b/src/tools/livevis/client/transferfunctions.cpp new file mode 100644 index 0000000000..ecb1d78513 --- /dev/null +++ b/src/tools/livevis/client/transferfunctions.cpp @@ -0,0 +1,61 @@ +#include "transferfunctions.h" +#include + +float4 RedGreenTransferFunction::sample(float samplingPoint) +{ + if (samplingPoint < 0.0f) samplingPoint = 0.0f; + if (samplingPoint > 1.0f) samplingPoint = 1.0f; + + float4 result; + + result.r = 1.0f - samplingPoint; + result.g = samplingPoint; + result.b = 0.0f; + + result.a = m_offsetY * std::erff( m_slope * (samplingPoint - m_offsetX) ) + m_offsetY; + + return result; +} + +float4 TemperatureTransferFunction::sample(float samplingPoint) +{ + if (samplingPoint < 0.0f) samplingPoint = 0.0f; + if (samplingPoint > 1.0f) samplingPoint = 1.0f; + + float4 result; + + if (samplingPoint < 0.4f) result.r = 2.5f * samplingPoint; + else result.r = 1.0f; + + if (samplingPoint < 0.4f) result.g = -1.95f * samplingPoint + 0.78f; + else if (samplingPoint >= 0.4f && samplingPoint < 0.75f) result.g = 2.857f * samplingPoint - 1.143f; + else result.g = 1.0f; + + if (samplingPoint < 0.4f) result.b = -2.35f * samplingPoint + 0.94f; + else if (samplingPoint >= 0.4f && samplingPoint < 0.75f) result.b = 0.0f; + else result.b = 4.0f * samplingPoint - 3.0f; + + result.a = m_offsetY * std::erff( m_slope * (samplingPoint - m_offsetX) ) + m_offsetY; + + return result; +} + +float4 TwoHueTransferFunction::sample(float samplingPoint) +{ + if (samplingPoint < 0.0f) samplingPoint = 0.0f; + if (samplingPoint > 1.0f) samplingPoint = 1.0f; + + float4 result; + + if (samplingPoint < 0.5f) result.r = 2.0f * samplingPoint; + else result.r = -0.76f * samplingPoint + 1.38f; + + if (samplingPoint < 0.5f) result.g = 2.0f * samplingPoint; + else result.g = -2.0f * samplingPoint + 2.0f; + + result.b = 1.0f - samplingPoint; + + result.a = m_offsetY * std::erff( m_slope * (samplingPoint - m_offsetX) ) + m_offsetY; + + return result; +} diff --git a/src/tools/livevis/client/transferfunctions.h b/src/tools/livevis/client/transferfunctions.h new file mode 100644 index 0000000000..882b3b78f5 --- /dev/null +++ b/src/tools/livevis/client/transferfunctions.h @@ -0,0 +1,121 @@ +#ifndef TRANSFERFUNCTIONS_H +#define TRANSFERFUNCTIONS_H + +const int TF_RESOLUTION = 64; // number of samples taken from the gradients (widgets) used to adjust the TF + +struct float4 +{ + union + { + struct { float r, g, b, a; }; + struct { float x, y, z, w; }; + float c[4]; + }; + + float4() : x(0.0f), y(0.0f), z(0.0f), w(0.0f) { } + float4(float _x, float _y, float _z, float _w) : x(_x), y(_y), z(_z), w(_w) { } +}; + +/** + * @brief The ITransferFunction class + * + * Interface for Transferfunction classes. + */ +class ITransferFunction +{ +public: + + ITransferFunction() + : m_offsetX(0.20f), + m_offsetY(0.005f), + m_slope(9.5f) + { } + + virtual ~ITransferFunction() + { } + + /** + * @brief setOffsetX Offsets the opacity curve along the X-Axis, e.g. f(x) -> f(x - offsetX) + * @param offsetX + */ + void setOffsetX(float offsetX) { m_offsetX = offsetX; } + + /** + * @brief setOffsetY Offsets and scales the opacity curve along the Y-Axis, e.g. f(x) -> offsetY * f(x) + offsetY + * @param offsetY + */ + void setOffsetY(float offsetY) { m_offsetY = offsetY; } + + /** + * @brief setSlope Determines the slope of the opacity curve, e.g. f(x) -> f(slope * x) + * @param slope + */ + void setSlope(float slope) { m_slope = slope; } + + float getOffsetX() { return m_offsetX; } + float getOffsetY() { return m_offsetY; } + float getSlope() { return m_slope; } + + /** + * @brief sample Get the RGBA value of the Transferfunction at a given sampling point in range (0; 1). + * @param samplingPoint A sampling point between 0 and 1. + * @return An RGBA tuple. + */ + virtual float4 sample(float samplingPoint) = 0; + +protected: + + float m_offsetX; + float m_offsetY; + float m_slope; +}; + +/** + * @brief The RedGreenTransferFunction class + * + * A simple color scale ranging from red for low values to green for high values. + */ +class RedGreenTransferFunction : public ITransferFunction +{ +public: + + RedGreenTransferFunction() + : ITransferFunction() + { } + + virtual float4 sample(float samplingPoint); +}; + +/** + * @brief The TemperatureTransferFunction class + * + * A temperature color scale ranging from blue (cold) over red and yellow to white (darn hot!). + */ +class TemperatureTransferFunction : public ITransferFunction +{ +public: + + TemperatureTransferFunction() + : ITransferFunction() + { } + + virtual float4 sample(float samplingPoint); +}; + +/** + * @brief The TwoHueTransferFunction class + * + * A color scale ranging from dark blue to dark red. + */ +class TwoHueTransferFunction : public ITransferFunction +{ +public: + + TwoHueTransferFunction() + : ITransferFunction() + { } + + virtual float4 sample(float samplingPoint); +}; + +#endif // TRANSFERFUNCTIONS_H diff --git a/src/tools/livevis/client/tunnel2cluster.sh b/src/tools/livevis/client/tunnel2cluster.sh new file mode 100755 index 0000000000..d4fc5b68ad --- /dev/null +++ b/src/tools/livevis/client/tunnel2cluster.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# + +# set in /etc/hosts for the n_head +# 127.0.0.1 hypnos +# +# set DEFAULT_SERVER_IP to "127.0.0.1" in main.cpp + +# config +n_login=huebl@uts.fz-rossendorf.de +n_head=149.220.4.37 + +# functions +function getNewSSH { + tmpSSH2=$( pidof ssh | sed 's/ /\n/g' | sort ) + echo "$tmpSSH1" > tmpFile1 + echo "$tmpSSH2" > tmpFile2 + grep -Fxv -f tmpFile1 tmpFile2 | tee -a .tmpSSHtunnels + rm -rf tmpFile1 tmpFile2 +} +function finish { + tmpPIDs=$(cat .tmpSSHtunnels) + kill $tmpPIDs + rm -rf .tmpSSHtunnels + echo "done" +} +trap finish EXIT + +# start udp tunnel +tmpSSH1=$( pidof ssh | sed 's/ /\n/g' | sort ) +ssh -f -L 8203:$n_head:8203 $n_login -N +getNewSSH + +ssh $n_login "ssh $n_head 'rm -rf testfifo && mkfifo testfifo'" + +tmpSSH1=$( pidof ssh | sed 's/ /\n/g' | sort ) +ssh $n_login "ssh $n_head 'netcat -v -l -p 8203 < testfifo | nc -u 127.0.0.1 8200 > testfifo'" & +getNewSSH + +rm -rf testfifo && mkfifo testfifo +netcat -v -l -u -p 8200 < testfifo | nc localhost 8203 > testfifo & + +# start tcp (rivlib data) tunnel +ssh -L 52000:$n_head:52000 $n_login -N diff --git a/src/tools/livevis/client/udpquery.cpp b/src/tools/livevis/client/udpquery.cpp new file mode 100644 index 0000000000..ba44b03549 --- /dev/null +++ b/src/tools/livevis/client/udpquery.cpp @@ -0,0 +1,91 @@ +#include "udpquery.h" + +#include +#include +#include +#include +#include + +#include "message_ids.hpp" + +UDPQuery::UDPQuery(std::string ip, int port) + : QObject(), + m_ip(ip), + m_port(port), + m_timer(nullptr), + m_waiting(false) +{ +} + +void UDPQuery::start() +{ + m_timer = new QTimer(); + m_timer->setInterval(5000); + m_timer->setSingleShot(false); + connect(m_timer, SIGNAL(timeout()), this, SLOT(refresh())); + m_timer->start(); +} + +void UDPQuery::refresh() +{ + if (m_waiting) return; + m_waiting = true; + + emit refreshing_list(); + + /// query the visualization server connection less via UDP + int socket_fd = ::socket(AF_INET, SOCK_DGRAM, 0); + + struct sockaddr_in servaddr; + + ::bzero(&servaddr, sizeof(servaddr)); + + servaddr.sin_family = AF_INET; + servaddr.sin_addr.s_addr = inet_addr(m_ip.c_str()); + servaddr.sin_port = htons(m_port); + + uint32_t buffer = ListVisualizations; + + /// send List request + if ( ::sendto(socket_fd, (void*)&buffer, sizeof(uint32_t), 0, (struct sockaddr*)&servaddr, sizeof(servaddr)) == -1) + { + qDebug() << "Request could not be sent. Server unreachable."; + ::close(socket_fd); + return; + } + + /// receive answer - count first (length of visualization list) + uint32_t count; + + ::recvfrom(socket_fd, (void*)&count, sizeof(uint32_t), 0, NULL, NULL); + + qDebug() << "Received Count " << count; + + /// receive name and uri of all visualizations in the list + for (int i = 0; i < count; ++i) + { + //char name[128]; + char name_uri[1024]; + + /// receive name + //::recvfrom(socket_fd, (void*)name, 128, 0, NULL, NULL); + + /// receive uri + ::recvfrom(socket_fd, (void*)name_uri, 1024, 0, NULL, NULL); + + char name[128]; + char uri[1024 - 128]; + + memcpy(name, name_uri, 128); + memcpy(uri, name_uri + 128, 1024 - 128); + + memset(name + 127, 0, 1); + memset(uri + 1024 - 128 - 1, 0, 1); + + emit received_visualization(QString(name), QString(uri)); + } + + ::close(socket_fd); + + m_waiting = false; +} diff --git a/src/tools/livevis/client/udpquery.h b/src/tools/livevis/client/udpquery.h new file mode 100644 index 0000000000..ec8c1f7152 --- /dev/null +++ b/src/tools/livevis/client/udpquery.h @@ -0,0 +1,37 @@ +#ifndef UDPQUERY_H +#define UDPQUERY_H + +#include +#include + +class UDPQuery : public QObject +{ + Q_OBJECT + +public: + + explicit UDPQuery(std::string ip, int port); + +public slots: + + void start(); + +private slots: + + void refresh(); + +signals: + + void received_visualization(QString name, QString uri); + void refreshing_list(); + +private: + + QTimer * m_timer; + bool m_waiting; + + std::string m_ip; + int m_port; +}; + +#endif // UDPQUERY_H diff --git a/src/tools/livevis/client/verboselabel.cpp b/src/tools/livevis/client/verboselabel.cpp new file mode 100644 index 0000000000..1871f2569a --- /dev/null +++ b/src/tools/livevis/client/verboselabel.cpp @@ -0,0 +1,6 @@ +#include "verboselabel.h" + +VerboseLabel::VerboseLabel(QWidget * parent) : + QLabel(parent) +{ +} diff --git a/src/tools/livevis/client/verboselabel.h b/src/tools/livevis/client/verboselabel.h new file mode 100644 index 0000000000..88e42e031d --- /dev/null +++ b/src/tools/livevis/client/verboselabel.h @@ -0,0 +1,27 @@ +#ifndef VERBOSELABEL_H +#define VERBOSELABEL_H + +#include + +class VerboseLabel : public QLabel +{ + Q_OBJECT + +public: + explicit VerboseLabel(QWidget * parent = 0); + + virtual void setPixmap(const QPixmap& pm) + { + emit on_set_pixmap(); + QLabel::setPixmap(pm); + } + +signals: + + void on_set_pixmap(); + +public slots: + +}; + +#endif // VERBOSELABEL_H diff --git a/src/tools/share/gnuplot/LineSliceFields.gnuplot b/src/tools/share/gnuplot/LineSliceFields.gnuplot deleted file mode 100755 index 060a645bcf..0000000000 --- a/src/tools/share/gnuplot/LineSliceFields.gnuplot +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/gnuplot -persist -# -# Copyright 2013 Axel Huebl -# -# This file is part of PIConGPU. -# -# PIConGPU is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# PIConGPU is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with PIConGPU. -# If not, see . -# - -set xlabel "y in meters" -set ylabel "E_x^2 in V^2 * m^-2" - -#MyYRange=3.0e-3 - -set format x "%11.1e" -#set yrange [-MyYRange:MyYRange] -#set xrange [0.0:1.0e-5] -set format y "%11.1e" - -#set ytics MyYRange/5.0 - -# to do: kind of "sort by y-position" for lineplots -plot 'PATHLSF.dat' using ($3):(($4)*($4)) title "E_x^2" with p \ No newline at end of file diff --git a/src/tools/share/gnuplot/density.interactive.gnuplot b/src/tools/share/gnuplot/density.interactive.gnuplot deleted file mode 100644 index 72f7cee113..0000000000 --- a/src/tools/share/gnuplot/density.interactive.gnuplot +++ /dev/null @@ -1,55 +0,0 @@ -# -# Copyright 2013 Axel Huebl, Rene Widera -# -# This file is part of PIConGPU. -# -# PIConGPU is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# PIConGPU is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with PIConGPU. -# If not, see . -# - -reset -infile=system("echo $INFILE") - -set palette defined ( 0 "white" , 0.1 '#000fff',0.2 '#0090ff',0.3 '#0fffee',0.4 '#90ff70',0.5 '#ffee00',0.6 '#ff7000',0.7 '#ee0000', 1 '#7f0000') -#set palette defined ( 0 '#000090', 1 '#000fff', 2 '#0090ff', 3 '#0fffee', 4 '#90ff70', 5 '#ffee00', 6 '#ff7000', 7 '#ee0000', 8 '#7f0000') - -x_axis=system("echo $X_AXIS") -y_axis=system("echo $Y_AXIS") -colormax=system("echo $COLORMAX") - -set cblabel "Number of particles per cubic meter" offset 0.5,0,0 -set ylabel y_axis -set xlabel x_axis - -set terminal dumb -plot infile nonuniform matrix using 1:2:3 with image title "" - -set terminal wxt size 800,600 enhanced font 'Verdana,14' persist - -set border linewidth 2 -set pointsize 5 - - -set format x "%.1te%S" -set format y "%.1te%S" -set format cb "%.1te%S" - -if (colormax==0) colormax=GPVAL_DATA_CB_MAX ; else colormax=colormax - -set xrange [GPVAL_DATA_X_MIN:GPVAL_DATA_X_MAX] -set yrange [GPVAL_DATA_Y_MIN:GPVAL_DATA_Y_MAX] -set cbrange [0:colormax] - - -replot diff --git a/src/tools/share/gnuplot/density.png.gnuplot b/src/tools/share/gnuplot/density.png.gnuplot deleted file mode 100644 index 3d01753832..0000000000 --- a/src/tools/share/gnuplot/density.png.gnuplot +++ /dev/null @@ -1,61 +0,0 @@ -# -# Copyright 2013 Axel Huebl, Rene Widera -# -# This file is part of PIConGPU. -# -# PIConGPU is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# PIConGPU is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with PIConGPU. -# If not, see . -# - -reset -infile=system("echo $INFILE") -outfile=system("echo $OUTFILE") - -colormax=system("echo $COLORMAX") - -x_axis=system("echo $X_AXIS") -y_axis=system("echo $Y_AXIS") -resolution_x=system("echo $X_RESOLUTION") -resolution_y=system("echo $Y_RESOLUTION") - -set palette defined ( 0 "white" , 0.1 '#000fff',0.2 '#0090ff',0.3 '#0fffee',0.4 '#90ff70',0.5 '#ffee00',0.6 '#ff7000',0.7 '#ee0000', 1 '#7f0000') -#set palette defined ( 0 "white" , 0.005 "blue", 0.01 '#000fff',0.1 '#0090ff',0.2 '#0fffee',0.3 '#90ff70',0.4 '#ffee00',0.5 '#ff7000',0.7 '#ee0000', 1 '#7f0000') - -set cblabel "Number of particles per cubic meter" offset 0.5,0,0 -set ylabel y_axis -set xlabel x_axis - -set terminal dumb -plot infile nonuniform matrix using 1:2:3 with image title "" - -set terminal pngcairo size resolution_x,resolution_y enhanced font 'Verdana,14' -set output outfile - - -set border linewidth 2 -set pointsize 5 - - -set format x "%.1te%S" -set format y "%.1te%S" -set format cb "%.1te%S" - -if (colormax==0) colormax=GPVAL_DATA_CB_MAX ; else colormax=colormax - -set xrange [GPVAL_DATA_X_MIN:GPVAL_DATA_X_MAX] -set yrange [GPVAL_DATA_Y_MIN:GPVAL_DATA_Y_MAX] -set cbrange [0:colormax] - - -replot diff --git a/src/tools/splash2txt/CMakeLists.txt b/src/tools/splash2txt/CMakeLists.txt index c2febdc74b..b047079ab4 100644 --- a/src/tools/splash2txt/CMakeLists.txt +++ b/src/tools/splash2txt/CMakeLists.txt @@ -4,7 +4,7 @@ # This file is part of splash2txt. # # splash2txt is free software: you can redistribute it and/or modify -# it under the terms of of either the GNU General Public License or +# it under the terms of either the GNU General Public License or # the GNU Lesser General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. diff --git a/src/tools/splash2txt/include/ITools.hpp b/src/tools/splash2txt/include/ITools.hpp index c696c7d2c5..4625d1f4bd 100644 --- a/src/tools/splash2txt/include/ITools.hpp +++ b/src/tools/splash2txt/include/ITools.hpp @@ -4,7 +4,7 @@ * This file is part of splash2txt. * * splash2txt is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/tools/splash2txt/include/splash2txt.hpp b/src/tools/splash2txt/include/splash2txt.hpp index b2c894b87d..8a2406fa9d 100644 --- a/src/tools/splash2txt/include/splash2txt.hpp +++ b/src/tools/splash2txt/include/splash2txt.hpp @@ -4,7 +4,7 @@ * This file is part of splash2txt. * * splash2txt is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/tools/splash2txt/include/tools_adios_parallel.hpp b/src/tools/splash2txt/include/tools_adios_parallel.hpp index 839abff492..c900e67872 100644 --- a/src/tools/splash2txt/include/tools_adios_parallel.hpp +++ b/src/tools/splash2txt/include/tools_adios_parallel.hpp @@ -4,7 +4,7 @@ * This file is part of splash2txt. * * splash2txt is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/tools/splash2txt/include/tools_splash_parallel.hpp b/src/tools/splash2txt/include/tools_splash_parallel.hpp index 848b475650..45023fcbca 100644 --- a/src/tools/splash2txt/include/tools_splash_parallel.hpp +++ b/src/tools/splash2txt/include/tools_splash_parallel.hpp @@ -4,7 +4,7 @@ * This file is part of splash2txt. * * splash2txt is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/tools/splash2txt/splash2txt.cpp b/src/tools/splash2txt/splash2txt.cpp index c09f95ea00..a5698e02c0 100644 --- a/src/tools/splash2txt/splash2txt.cpp +++ b/src/tools/splash2txt/splash2txt.cpp @@ -4,7 +4,7 @@ * This file is part of splash2txt. * * splash2txt is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/tools/splash2txt/tools_adios_parallel.cpp b/src/tools/splash2txt/tools_adios_parallel.cpp index 46ef3a63eb..1c72f74897 100644 --- a/src/tools/splash2txt/tools_adios_parallel.cpp +++ b/src/tools/splash2txt/tools_adios_parallel.cpp @@ -4,7 +4,7 @@ * This file is part of splash2txt. * * splash2txt is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/tools/splash2txt/tools_splash_parallel.cpp b/src/tools/splash2txt/tools_splash_parallel.cpp index 39593a5227..fe476fad85 100644 --- a/src/tools/splash2txt/tools_splash_parallel.cpp +++ b/src/tools/splash2txt/tools_splash_parallel.cpp @@ -4,7 +4,7 @@ * This file is part of splash2txt. * * splash2txt is free software: you can redistribute it and/or modify - * it under the terms of of either the GNU General Public License or + * it under the terms of either the GNU General Public License or * the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/thirdParty/cuda_memtest/cuda_memtest.cu b/thirdParty/cuda_memtest/cuda_memtest.cu index 84aa07a136..3c6ab3452c 100644 --- a/thirdParty/cuda_memtest/cuda_memtest.cu +++ b/thirdParty/cuda_memtest/cuda_memtest.cu @@ -143,7 +143,7 @@ thread_func(void* _arg) cudaSetDevice(device); - cudaThreadSynchronize(); + cudaDeviceSynchronize(); CUERR; PRINTF("Attached to device %d successfully.\n", device); diff --git a/thirdParty/cuda_memtest/cuda_memtest.h b/thirdParty/cuda_memtest/cuda_memtest.h index 51c594783f..e185ba1d95 100644 --- a/thirdParty/cuda_memtest/cuda_memtest.h +++ b/thirdParty/cuda_memtest/cuda_memtest.h @@ -113,7 +113,7 @@ extern void get_driver_info(char* info, unsigned int len); #define SHOW_PROGRESS(msg, i, tot_num_blocks) \ - cudaThreadSynchronize(); \ + cudaDeviceSynchronize(); \ unsigned int num_checked_blocks = i+GRIDSIZE <= tot_num_blocks? i+GRIDSIZE: tot_num_blocks; \ if (verbose >=2){ \ if(interactive){ \ @@ -132,7 +132,7 @@ extern void get_driver_info(char* info, unsigned int len); exit(cuda_err);}}while(0) #define SYNC_CUERR do{ cudaError_t cuda_err; \ - cudaThreadSynchronize(); \ + cudaDeviceSynchronize(); \ if ((cuda_err = cudaGetLastError()) != cudaSuccess) { \ FPRINTF("ERROR: CUDA error: %s, line %d, file %s\n", cudaGetErrorString(cuda_err), __LINE__, __FILE__); \ PRINTF("ERROR: CUDA error: %s, line %d, file %s\n", cudaGetErrorString(cuda_err), __LINE__, __FILE__); \ diff --git a/thirdParty/cuda_memtest/tests.cu b/thirdParty/cuda_memtest/tests.cu index 76e9d80ad2..fc5a88ae48 100644 --- a/thirdParty/cuda_memtest/tests.cu +++ b/thirdParty/cuda_memtest/tests.cu @@ -191,7 +191,7 @@ error_checking(const char* msg, unsigned int blockidx) cudaMemset((void*)&err_expect[0], 0, sizeof(unsigned long)*MAX_ERR_RECORD_COUNT);CUERR; cudaMemset((void*)&err_current[0], 0, sizeof(unsigned long)*MAX_ERR_RECORD_COUNT);CUERR; if (exit_on_error){ - cudaThreadExit(); + cudaDeviceReset(); exit(ERR_BAD_STATE); } }