| 813 | } |
| 814 | |
| 815 | void LBM::sanity_checks_initialization() { // sanity checks during initialization on used extensions based on used flags |
| 816 | uchar flags_used = 0u; |
| 817 | bool moving_boundaries_used=false, equilibrium_boundaries_used=false, surface_used=false, temperature_used=false; // identify used extensions based used flags |
| 818 | const uint threads = thread::hardware_concurrency(); |
| 819 | vector<uchar> t_flags_used(threads, 0u); |
| 820 | vector<char> t_moving_boundaries_used(threads, false); // don't use vector<bool> as it uses bit-packing which is broken for multithreading |
| 821 | vector<char> t_equilibrium_boundaries_used(threads, false); // don't use vector<bool> as it uses bit-packing which is broken for multithreading |
| 822 | parallel_for(get_N(), threads, [&](ulong n, uint t) { |
| 823 | const uchar flagsn = flags[n]; |
| 824 | const uchar flagsn_bo = flagsn&(TYPE_S|TYPE_E); |
| 825 | t_flags_used[t] = t_flags_used[t]|flagsn; |
| 826 | if(flagsn_bo&TYPE_S) t_moving_boundaries_used[t] = t_moving_boundaries_used[t] || (((flagsn_bo==TYPE_S)&&(u.x[n]!=0.0f||u.y[n]!=0.0f||u.z[n]!=0.0f))||(flagsn_bo==(TYPE_S|TYPE_E))); |
| 827 | t_equilibrium_boundaries_used[t] = t_equilibrium_boundaries_used[t] || flagsn_bo==TYPE_E; |
| 828 | }); |
| 829 | for(uint t=0u; t<threads; t++) { |
| 830 | flags_used = flags_used|t_flags_used[t]; |
| 831 | moving_boundaries_used = moving_boundaries_used || t_moving_boundaries_used[t]; |
| 832 | equilibrium_boundaries_used = equilibrium_boundaries_used || t_equilibrium_boundaries_used[t]; |
| 833 | } |
| 834 | surface_used = (bool)(flags_used&(TYPE_F|TYPE_I|TYPE_G)); |
| 835 | temperature_used = (bool)(flags_used&TYPE_T); |
| 836 | #ifndef MOVING_BOUNDARIES |
| 837 | if(moving_boundaries_used) print_warning("Some boundary cells have non-zero velocity, but MOVING_BOUNDARIES is not enabled. If you intend to use moving boundaries, uncomment \"#define MOVING_BOUNDARIES\" in defines.hpp."); |
| 838 | #else // MOVING_BOUNDARIES |
| 839 | if(!moving_boundaries_used) print_warning("The MOVING_BOUNDARIES extension is enabled but no moving boundary cells (TYPE_S flag and velocity unequal to zero) are placed in the simulation box. You may disable the extension by commenting out \"#define MOVING_BOUNDARIES\" in defines.hpp."); |
| 840 | #endif // MOVING_BOUNDARIES |
| 841 | #ifndef EQUILIBRIUM_BOUNDARIES |
| 842 | if(equilibrium_boundaries_used) print_error("Some cells are set as equilibrium boundaries with the TYPE_E flag, but EQUILIBRIUM_BOUNDARIES is not enabled. Uncomment \"#define EQUILIBRIUM_BOUNDARIES\" in defines.hpp."); |
| 843 | #else // EQUILIBRIUM_BOUNDARIES |
| 844 | if(!equilibrium_boundaries_used) print_warning("The EQUILIBRIUM_BOUNDARIES extension is enabled but no equilibrium boundary cells (TYPE_E flag) are placed in the simulation box. You may disable the extension by commenting out \"#define EQUILIBRIUM_BOUNDARIES\" in defines.hpp."); |
| 845 | #endif // EQUILIBRIUM_BOUNDARIES |
| 846 | #ifndef SURFACE |
| 847 | if(surface_used) print_error("Some cells are set as fluid/interface/gas with the TYPE_F/TYPE_I/TYPE_G flags, but SURFACE is not enabled. Uncomment \"#define SURFACE\" in defines.hpp."); |
| 848 | #else // SURFACE |
| 849 | if(!surface_used) print_error("The SURFACE extension is enabled but no fluid/interface/gas cells (TYPE_F/TYPE_I/TYPE_G flags) are placed in the simulation box. Disable the extension by commenting out \"#define SURFACE\" in defines.hpp."); |
| 850 | #endif // SURFACE |
| 851 | #ifndef TEMPERATURE |
| 852 | if(temperature_used) print_error("Some cells are set as temperature boundary with the TYPE_T flag, but TEMPERATURE is not enabled. Uncomment \"#define TEMPERATURE\" in defines.hpp."); |
| 853 | #endif // TEMPERATURE |
| 854 | } |
| 855 | |
| 856 | void LBM::initialize() { // write all data fields to device and call kernel_initialize |
| 857 | #ifndef BENCHMARK |
nothing calls this directly
no test coverage detected