Vlasiator ebf0dd394 on dev (v5.4.0 + 1054 commits)
Loading...
Searching...
No Matches
cpu_acc_semilag.cpp
Go to the documentation of this file.
1/*
2 * This file is part of Vlasiator.
3 * Copyright 2010-2016 Finnish Meteorological Institute
4 *
5 * For details of usage, see the COPYING file and read the "Rules of the Road"
6 * at http://www.physics.helsinki.fi/vlasiator/
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
23#include <dccrg.hpp>
24#include <dccrg_cartesian_geometry.hpp>
25#include <phiprof.hpp>
26#include "../definitions.h"
27
28#include "cpu_acc_semilag.hpp"
30#include "cpu_acc_map.hpp"
31
32#ifdef _OPENMP
33#include <omp.h>
34#endif
35
44
45void cpu_accelerate_cells(dccrg::Dccrg<SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid,
46 const std::vector<CellID>& acceleratedCells,
47 const uint popID,
48 const uint map_order
49 ) {
50 int timerId {phiprof::initializeTimer("cell-semilag-acc")};
51 int intersections_id {phiprof::initializeTimer("cell-compute-intersections")};
52
53 #pragma omp parallel // Launch workshare region
54 {
55 // Calculate intersections (should be constant cost per cell)
56 #pragma omp for schedule(static,1)
57 for (size_t c=0; c<acceleratedCells.size(); ++c) {
58 const CellID cellID = acceleratedCells[c];
59 SpatialCell* SC = mpiGrid[cellID];
60 Population& pop = SC->get_population(popID);
61 compute_cell_intersections(SC, popID, map_order, pop.subcycleDt, intersections_id);
62 }
63 #pragma omp barrier
64 // Semi-Lagrangian acceleration for all cells active in this subcycle,
65 // dimension-by-dimension. Dynamic cost due to varying block counts.
66 #pragma omp for schedule(dynamic,1)
67 for (size_t c=0; c<acceleratedCells.size(); ++c) {
68 const CellID cellID = acceleratedCells[c];
69 SpatialCell* SC = mpiGrid[cellID];
70
71 phiprof::Timer semilagAccTimer {timerId};
72 cpu_accelerate_cell(SC,popID,map_order);
73 semilagAccTimer.stop();
74 }
75 }
76}
77
91
93 const uint popID,
94 const uint map_order
95 ) {
96
97 Population& pop = spatial_cell->get_population(popID);
98 switch(map_order){
99 case 0: {
100 //Map order XYZ
102 pop.intersection_x_di,pop.intersection_x_dj,pop.intersection_x_dk,0); // map along x
104 pop.intersection_y_di,pop.intersection_y_dj,pop.intersection_y_dk,1); // map along y
106 pop.intersection_z_di,pop.intersection_z_dj,pop.intersection_z_dk,2); // map along z
107 break;
108 }
109 case 1: {
110 //Map order YZX
112 pop.intersection_y_di,pop.intersection_y_dj,pop.intersection_y_dk,1); // map along y
114 pop.intersection_z_di,pop.intersection_z_dj,pop.intersection_z_dk,2); // map along z
116 pop.intersection_x_di,pop.intersection_x_dj,pop.intersection_x_dk,0); // map along x
117 break;
118 }
119 case 2: {
120 //Map order Z X Y
122 pop.intersection_z_di,pop.intersection_z_dj,pop.intersection_z_dk,2); // map along z
124 pop.intersection_x_di,pop.intersection_x_dj,pop.intersection_x_dk,0); // map along x
126 pop.intersection_y_di,pop.intersection_y_dj,pop.intersection_y_dk,1); // map along y
127 break;
128 }
129 }
130}
Constants c
Definition Dispersion.m:45
Population & get_population(const uint popID)
void compute_cell_intersections(spatial_cell::SpatialCell *spatial_cell, const uint popID, const uint map_order, const Real &dt, int intersections_id)
bool map_1d(SpatialCell *spatial_cell, const uint popID, Real in_intersection, Real in_intersection_di, Real in_intersection_dj, Real in_intersection_dk, const uint dimension)
void cpu_accelerate_cells(dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, const std::vector< CellID > &acceleratedCells, const uint popID, const uint map_order)
void cpu_accelerate_cell(SpatialCell *spatial_cell, const uint popID, const uint map_order)
uint64_t CellID
Definition definitions.h:54