Vlasiator ebf0dd394 on dev (v5.4.0 + 1054 commits)
Loading...
Searching...
No Matches
spatial_cell_cpu.cpp
Go to the documentation of this file.
1/*
2 * This file is part of Vlasiator.
3 * Copyright 2010-2024 Finnish Meteorological Institute and University of Helsinki
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 <unordered_set>
24
26#include "../object_wrapper.h"
27
28#ifdef DEBUG_VLASIATOR
29#ifndef DEBUG_SPATIAL_CELL
30 #define DEBUG_SPATIAL_CELL
31#endif
32#endif
33
34using namespace std;
35
36namespace spatial_cell {
40
42 // Block list and cache always have room for all blocks
43 this->sysBoundaryLayer=0; // Default value, layer not yet initialized
44 for (unsigned int i=0; i<WID3; ++i) {
45 null_block_data[i] = 0.0;
46 }
47
48 // reset spatial cell parameters
49 for (unsigned int i = 0; i < CellParams::N_SPATIAL_CELL_PARAMS; i++) {
50 this->parameters[i]=0.0;
51 }
52
53 // reset BVOL derivatives
54 for (unsigned int i = 0; i < bvolderivatives::N_BVOL_DERIVATIVES; i++) {
55 this->derivativesBVOL[i]=0;
56 }
57
58 for (unsigned int i = 0; i < MAX_NEIGHBORS_PER_DIM; ++i) {
60 this->neighbor_block_data[i] = NULL;
61 }
62
63 //is transferred by default
64 this->mpiTransferEnabled=true;
65
66 // Set correct number of populations
67 populations.resize(getObjectWrapper().particleSpecies.size());
68
69 // Set velocity meshes
70 for (uint popID=0; popID<populations.size(); ++popID) {
72 populations[popID].vmesh->initialize(spec.velocityMesh);
73 populations[popID].velocityBlockMinValue = spec.sparseMinValue;
74 populations[popID].N_blocks = 0;
75 }
76
77 // new pointers for vectors
78 velocity_block_with_content_list = new std::vector<vmesh::GlobalID>(1);
79 velocity_block_with_no_content_list = new std::vector<vmesh::GlobalID>(1);
82 }
83
88
90 // These should be empty when created, but let's play safe.
91 velocity_block_with_content_list = new std::vector<vmesh::GlobalID>(*(other.velocity_block_with_content_list));
92 velocity_block_with_no_content_list = new std::vector<vmesh::GlobalID>(*(other.velocity_block_with_no_content_list));
93
94 // Member variables
100 initialized = other.initialized;
102 for (unsigned int i=0; i<bvolderivatives::N_BVOL_DERIVATIVES; ++i) {
104 }
105 for (unsigned int i=0; i<CellParams::N_SPATIAL_CELL_PARAMS; ++i) {
106 parameters[i] = other.parameters[i];
107 }
108 for (unsigned int i=0; i<WID3; ++i) {
109 null_block_data[i] = 0.0;
110 }
111 for (unsigned int i=0; i<MAX_NEIGHBORS_PER_DIM; ++i) {
114 }
115
116 if (other.face_neighbor_ranks.size()>0) {
117 face_neighbor_ranks = std::map<int,std::set<int>>(other.face_neighbor_ranks);
118 }
119 if (other.populations.size()>0) {
120 populations = std::vector<spatial_cell::Population>(other.populations);
121 }
122 }
124 // Used for refining spatial cells
127
128 // These should be empty when created, but let's play safe.
129 velocity_block_with_content_list = new std::vector<vmesh::GlobalID>(*(other.velocity_block_with_content_list));
130 velocity_block_with_no_content_list = new std::vector<vmesh::GlobalID>(*(other.velocity_block_with_no_content_list));
131 // Member variables
137 initialized = other.initialized;
139 for (unsigned int i=0; i<bvolderivatives::N_BVOL_DERIVATIVES; ++i) {
141 }
142 for (unsigned int i=0; i<CellParams::N_SPATIAL_CELL_PARAMS; ++i) {
143 parameters[i] = other.parameters[i];
144 }
145 for (unsigned int i=0; i<WID3; ++i) {
146 null_block_data[i] = 0.0;
147 }
148 for (unsigned int i=0; i<MAX_NEIGHBORS_PER_DIM; ++i) {
151 }
152
153 face_neighbor_ranks.clear(); // Needs re-building after refinement
154 populations = std::vector<spatial_cell::Population>(other.populations);
155
156 return *this;
157 }
158
179 void SpatialCell::adjust_velocity_blocks(const std::vector<SpatialCell*>& spatial_neighbors,
180 const uint popID,bool doDeleteEmptyBlocks) {
182
183 // This set contains all those cellids which have neighbors in any
184 // of the 6-dimensions Actually, we would only need to add
185 // local blocks with no content here, as blocks with content
186 // do not need to be created and also will not be removed as
187 // we only check for removal for blocks with no content
188 std::unordered_set<vmesh::GlobalID> neighbors_have_content;
189
190 //add neighbor content info for velocity space neighbors to map. We loop over blocks
191 //with content and raise the neighbors_have_content for
192 //itself, and for all its neighbors
193 const size_t local_content_list_size = velocity_block_with_content_list->size();
194 for (vmesh::LocalID block_index=0; block_index<local_content_list_size; ++block_index) {
195 vmesh::GlobalID block = velocity_block_with_content_list->at(block_index);
196
198 neighbors_have_content.insert(block); //also add the cell itself
199
200 int addWidthV = getObjectWrapper().particleSpecies[popID].sparseBlockAddWidthV;
201 for (int offset_vx=-addWidthV;offset_vx<=addWidthV;offset_vx++) {
202 for (int offset_vy=-addWidthV;offset_vy<=addWidthV;offset_vy++) {
203 for (int offset_vz=-addWidthV;offset_vz<=addWidthV;offset_vz++) {
204 const vmesh::GlobalID neighbor_block
205 = get_velocity_block(popID,{{indices[0]+offset_vx,indices[1]+offset_vy,indices[2]+offset_vz}});
206 neighbors_have_content.insert(neighbor_block); //add all potential ngbrs of this block with content
207 }
208 }
209 }
210 }
211
212 //add neighbor content info for spatial space neighbors to map. We loop over
213 //neighbor cell lists with existing blocks, and raise the
214 //flag for the local block with same block id
215 for (std::vector<SpatialCell*>::const_iterator neighbor = spatial_neighbors.begin();
216 neighbor != spatial_neighbors.end(); ++neighbor) {
217 size_t n_neigh_blocks = (*neighbor)->velocity_block_with_content_list->size();
218 for (vmesh::LocalID block_index=0; block_index < n_neigh_blocks; ++block_index) {
219 vmesh::GlobalID block = (*neighbor)->velocity_block_with_content_list->at(block_index);
220 neighbors_have_content.insert(block);
221 }
222 }
223
224 // REMOVE all blocks in this cell without content + without neighbors with content
225 // better to do it in the reverse order, as then blocks at the
226 // end are removed first, and we may avoid copying extra data.
227 if (doDeleteEmptyBlocks) {
228 for (int block_index= this->velocity_block_with_no_content_list->size()-1; block_index>=0; --block_index) {
229 const vmesh::GlobalID blockGID = velocity_block_with_no_content_list->at(block_index);
230 #ifdef DEBUG_SPATIAL_CELL
231 if (blockGID == invalid_global_id()) {
232 cerr << "Got invalid block at " << __FILE__ << ' ' << __LINE__ << endl;
233 exit(1);
234 }
235 #endif
236 const vmesh::LocalID blockLID = get_velocity_block_local_id(blockGID,popID);
237 #ifdef DEBUG_SPATIAL_CELL
238 if (blockLID == invalid_local_id()) {
239 cerr << "Could not find block in " << __FILE__ << ' ' << __LINE__ << endl;
240 exit(1);
241 }
242 #endif
243
244 bool removeBlock = false;
245 std::unordered_set<vmesh::GlobalID>::iterator it = neighbors_have_content.find(blockGID);
246 if (it == neighbors_have_content.end()) {
247 removeBlock = true;
248 }
249
250 if (removeBlock == true) {
251 //No content, and also no neighbor have content -> remove
252 //and increment rho loss counters
253 const Real* block_parameters = get_block_parameters(popID)+blockLID*BlockParams::N_VELOCITY_BLOCK_PARAMS;
254 const Real DV3 = block_parameters[BlockParams::DVX]
255 * block_parameters[BlockParams::DVY]
256 * block_parameters[BlockParams::DVZ];
257 Real sum=0;
258 for (unsigned int i=0; i<WID3; ++i) {
259 sum += get_data(popID)[blockLID*SIZE_VELBLOCK+i];
260 }
261 this->populations[popID].RHOLOSSADJUST += DV3*sum;
262
263 // and finally remove block
264 this->remove_velocity_block(blockGID,popID);
265 }
266 }
267 }
268
269 // ADD all blocks with neighbors in spatial or velocity space (if it exists then the block is unchanged)
270 for (std::unordered_set<vmesh::GlobalID>::iterator it=neighbors_have_content.begin(); it != neighbors_have_content.end(); ++it) {
271 this->add_velocity_block(*it,popID);
272 }
273 }
274
275 void SpatialCell::adjustSingleCellVelocityBlocks(const uint popID, bool doDeleteEmpty) {
277
278 //neighbor_ptrs is empty, so we adjust only based on local velocity space.
279 std::vector<SpatialCell*> neighbor_ptrs;
281 adjust_velocity_blocks(neighbor_ptrs,popID,doDeleteEmpty);
282 }
283
290 bool SpatialCell::compute_block_has_content(const vmesh::LocalID& blockLID,const uint popID) const {
292 #ifdef DEBUG_SPATIAL_CELL
293 const vmesh::GlobalID blockGID = populations[popID].vmesh->getGlobalID(blockLID);
294 if (blockGID == invalid_global_id()) {
295 std::cerr << "ERROR, popID " << popID << " found invalid GID " << blockGID << " for LID "<< blockLID;
296 std::cerr << __FILE__ << ":" << __LINE__ << std::endl;
297 exit(1);
298 }
299 #endif
300
301 if (blockLID == invalid_local_id()) {
302 return false;
303 }
304
305 bool has_content = false;
306 const Real velocity_block_min_value = getVelocityBlockMinValue(popID);
307 const Realf* block_data = populations[popID].blockContainer->getData(blockLID);
308 for (unsigned int i=0; i<WID3; ++i) {
309 if (block_data[i] >= velocity_block_min_value) {
310 has_content = true;
311 break;
312 }
313 }
314
315 return has_content;
316 }
317
321 const Real& SpatialCell::get_max_r_dt(const uint popID) const {
323 return populations[popID].max_dt[species::MAXRDT];
324 }
325
329 const Real& SpatialCell::get_max_v_dt(const uint popID) const {
331 return populations[popID].max_dt[species::MAXVDT];
332 }
333
341 std::tuple<void*, int, MPI_Datatype> SpatialCell::get_mpi_datatype(
342 const CellID cellID,
343 const int sender_rank,
344 const int receiver_rank,
345 const bool receiving,
346 const int neighborhood
347 ) {
348
349 std::vector<MPI_Aint> displacements;
350 std::vector<int> block_lengths;
351
352 // create datatype for actual data if we are in the first two
353 // layers around a boundary, or if we send for the whole system
355 this->sysBoundaryLayer ==1 || this->sysBoundaryLayer ==2 )) {
356
357 //add data to send/recv to displacement and block length lists
359 //first copy values in case this is the send operation
360 populations[activePopID].N_blocks = populations[activePopID].blockContainer->size();
361
362 // send velocity block list size
363 displacements.push_back((uint8_t*) &(populations[activePopID].N_blocks) - (uint8_t*) this);
364 block_lengths.push_back(sizeof(vmesh::LocalID));
365 }
366
368 // STAGE1 should have been done, otherwise we have problems...
369 if (receiving) {
370 //mpi_number_of_blocks transferred earlier
371 populations[activePopID].vmesh->setNewSize(populations[activePopID].N_blocks);
372 } else {
373 //resize to correct size (it will avoid reallocation if it is big enough, I assume)
374 populations[activePopID].N_blocks = populations[activePopID].blockContainer->size();
375 }
376
377 // send velocity block list
378 if(populations[activePopID].vmesh->size() > 0) {
379 displacements.push_back((uint8_t*) populations[activePopID].vmesh->getGrid()->data() - (uint8_t*) this);
380 block_lengths.push_back(sizeof(vmesh::GlobalID) * populations[activePopID].vmesh->size());
381 } else {
382 displacements.push_back(0);
383 block_lengths.push_back(0);
384 }
385 }
386
388 //Communicate size of list so that buffers can be allocated on receiving side
389 if (!receiving) {
391 }
392 displacements.push_back((uint8_t*) &(this->velocity_block_with_content_list_size) - (uint8_t*) this);
393 block_lengths.push_back(sizeof(vmesh::LocalID));
394 }
396 if (receiving) {
398 }
399
400 //velocity_block_with_content_list_size should first be updated, before this can be done (STAGE1)
402 displacements.push_back((uint8_t*) this->velocity_block_with_content_list->data() - (uint8_t*) this);
403 block_lengths.push_back(sizeof(vmesh::GlobalID)*this->velocity_block_with_content_list_size);
404 } else {
405 displacements.push_back(0);
406 block_lengths.push_back(0);
407 }
408 }
409
411 displacements.push_back((uint8_t*) get_data(activePopID) - (uint8_t*) this);
412 block_lengths.push_back(sizeof(Realf) * WID3 * populations[activePopID].blockContainer->size());
413 }
414
416 /*We are actually transferring the data of a
417 * neighbor. The values of neighbor_block_data
418 * and neighbor_number_of_blocks should be set in
419 * solver.*/
420
421 // Send this data only to ranks that contain face neighbors
422 // this->neighbor_number_of_blocks has been initialized to 0, on other ranks it can stay that way.
423 const set<int>& ranks = this->face_neighbor_ranks[neighborhood];
424 if ( P::amrMaxSpatialRefLevel == 0 || receiving || ranks.find(receiver_rank) != ranks.end()) {
425
426 for ( int i = 0; i < MAX_NEIGHBORS_PER_DIM; ++i) {
427 displacements.push_back((uint8_t*) this->neighbor_block_data[i] - (uint8_t*) this);
428 block_lengths.push_back(sizeof(Realf) * WID3 * this->neighbor_number_of_blocks[i]);
429 }
430
431 }
432 }
433
434 // send spatial cell parameters
436 displacements.push_back((uint8_t*) &(this->parameters[0]) - (uint8_t*) this);
437 block_lengths.push_back(sizeof(Real) * CellParams::N_SPATIAL_CELL_PARAMS);
438 }
439
440 // send spatial cell dimensions and coordinates
442 displacements.push_back((uint8_t*) &(this->parameters[CellParams::XCRD]) - (uint8_t*) this);
443 block_lengths.push_back(sizeof(Real) * 6);
444 }
445
446 // send BGBXVOL BGBYVOL BGBZVOL PERBXVOL PERBYVOL PERBZVOL
448 displacements.push_back((uint8_t*) &(this->parameters[CellParams::BGBXVOL]) - (uint8_t*) this);
449 block_lengths.push_back(sizeof(Real) * 6);
450 }
451
452 // send RHOM, VX, VY, VZ
454 displacements.push_back((uint8_t*) &(this->parameters[CellParams::RHOM]) - (uint8_t*) this);
455 block_lengths.push_back(sizeof(Real) * 4);
456 }
457
458 // send RHOM_DT2, VX_DT2, VY_DT2, VZ_DT2
460 displacements.push_back((uint8_t*) &(this->parameters[CellParams::RHOM_DT2]) - (uint8_t*) this);
461 block_lengths.push_back(sizeof(Real) * 4);
462 }
463
464 // send RHOQ
466 displacements.push_back((uint8_t*) &(this->parameters[CellParams::RHOQ]) - (uint8_t*) this);
467 block_lengths.push_back(sizeof(Real));
468 }
469
470 // send RHOQ_DT2
472 displacements.push_back((uint8_t*) &(this->parameters[CellParams::RHOQ_DT2]) - (uint8_t*) this);
473 block_lengths.push_back(sizeof(Real));
474 }
475
476 // send spatial cell BVOL derivatives
478 displacements.push_back((uint8_t*) &(this->derivativesBVOL[0]) - (uint8_t*) this);
479 block_lengths.push_back(sizeof(Real) * bvolderivatives::N_BVOL_DERIVATIVES);
480 }
481
483 displacements.push_back((uint8_t*) &(this->ioLocalCellId) - (uint8_t*) this);
484 block_lengths.push_back(sizeof(uint64_t));
485 }
486
487 // send electron pressure gradient term components
489 displacements.push_back((uint8_t*) &(this->parameters[CellParams::EXGRADPE]) - (uint8_t*) this);
490 block_lengths.push_back(sizeof(Real) * 3);
491 }
492
493
494 // send P tensor diagonal components
496 displacements.push_back((uint8_t*) &(this->parameters[CellParams::P_11]) - (uint8_t*) this);
497 block_lengths.push_back(sizeof(Real) * 3);
498 }
499
501 displacements.push_back((uint8_t*) &(this->parameters[CellParams::P_11_DT2]) - (uint8_t*) this);
502 block_lengths.push_back(sizeof(Real) * 3);
503 }
504
505 // send sysBoundaryFlag
507 displacements.push_back((uint8_t*) &(this->sysBoundaryFlag) - (uint8_t*) this);
508 block_lengths.push_back(sizeof(uint));
509 displacements.push_back((uint8_t*) &(this->sysBoundaryLayer) - (uint8_t*) this);
510 block_lengths.push_back(sizeof(uint));
511 }
512
514 displacements.push_back((uint8_t*) get_block_parameters(activePopID) - (uint8_t*) this);
515 block_lengths.push_back(sizeof(Real) * size(activePopID) * BlockParams::N_VELOCITY_BLOCK_PARAMS);
516 }
517 // Copy particle species metadata
519 for (uint popID=0; popID<populations.size(); ++popID) {
520 displacements.push_back((uint8_t*) &(populations[popID].RHO) - (uint8_t*)this);
521 block_lengths.push_back(offsetof(spatial_cell::Population, N_blocks));
522 }
523 }
524
525 // Refinement parameters
527 displacements.push_back(reinterpret_cast<uint8_t*>(this->parameters.data() + CellParams::AMR_ALPHA1) - reinterpret_cast<uint8_t*>(this));
528 block_lengths.push_back(sizeof(Real) * (CellParams::AMR_VORTICITY - CellParams::AMR_ALPHA1 + 1)); // This is just 4, but let's be explicit.
529 }
530
531 }
532
533 void* address = this;
534 int count;
535 MPI_Datatype datatype;
536
537 if (displacements.size() > 0) {
538 count = 1;
539 MPI_Type_create_hindexed(
540 displacements.size(),
541 &block_lengths[0],
542 &displacements[0],
543 MPI_BYTE,
544 &datatype
545 );
546 } else {
547 count = 0;
548 datatype = MPI_BYTE;
549 }
550
551 const bool printMpiDatatype = false;
552 if (printMpiDatatype) {
553 int mpiSize;
554 int myRank;
555 MPI_Type_size(datatype,&mpiSize);
556 MPI_Comm_rank(MPI_COMM_WORLD,&myRank);
557 cout << myRank << " get_mpi_datatype: " << cellID << " " << sender_rank << " " << receiver_rank << " " << mpiSize << ", Nblocks = " << populations[activePopID].N_blocks << ", nbr Nblocks =";
558 for (uint i = 0; i < MAX_NEIGHBORS_PER_DIM; ++i) {
559 const set<int>& ranks = this->face_neighbor_ranks[neighborhood];
560 if ( receiving || ranks.find(receiver_rank) != ranks.end()) {
561 cout << " " << this->neighbor_number_of_blocks[i];
562 } else {
563 cout << " " << 0;
564 }
565 }
566 cout << " face_neighbor_ranks =";
567 for (const auto& rank : this->face_neighbor_ranks[neighborhood]) {
568 cout << " " << rank;
569 }
570 cout << endl;
571 }
572
573 return std::make_tuple(address,count,datatype);
574 }
575
578 //random_data* SpatialCell::get_rng_data_buffer() {
579 // return &rngDataBuffer;
580 //}
581
584 //char* SpatialCell::get_rng_state_buffer() {
585 // return rngStateBuffer;
586 //}
587
593 return populations[popID].velocityBlockMinValue;
594 }
595
602 populations[popID].vmesh->setGrid();
603 populations[popID].blockContainer->setNewSize(populations[popID].vmesh->size());
604
606
607 // Set velocity block parameters:
608 for (vmesh::LocalID blockLID=0; blockLID<size(popID); ++blockLID) {
609 const vmesh::GlobalID blockGID = get_velocity_block_global_id(blockLID,popID);
610 populations[popID].vmesh->getBlockInfo(blockGID, parameters+BlockParams::VXCRD);
612 }
613 }
614
619 bool SpatialCell::setCommunicatedSpecies(const uint popID) {
620 #ifdef DEBUG_SPATIAL_CELL
621 if (popID >= getObjectWrapper().particleSpecies.size()) {
622 std::cerr << "ERROR, popID " << popID << " exceeds species.size() " << getObjectWrapper().particleSpecies.size() << " in ";
623 std::cerr << __FILE__ << ":" << __LINE__ << std::endl;
624 exit(1);
625 }
626 #endif
627
628 activePopID = popID;
629 return true;
630 }
631
636 void SpatialCell::set_max_r_dt(const uint popID,const Real& value) {
638 populations[popID].max_dt[species::MAXRDT] = value;
639 }
640
645 void SpatialCell::set_max_v_dt(const uint popID,const Real& value) {
647 populations[popID].max_dt[species::MAXVDT] = value;
648 }
649
655 bool success = true;
656
657 for (size_t p=0; p<populations.size(); ++p) {
658 const vmesh::LocalID amount
659 = 2 + populations[p].blockContainer->size()
660 * populations[p].blockContainer->getBlockAllocationFactor();
661
662 // Allow capacity to be a bit larger than needed by number of blocks, shrink otherwise
663 if (populations[p].blockContainer->capacity() > amount ) {
664 if (populations[p].blockContainer->setNewCapacityShrink(amount) == false) {
665 success = false;
666 }
667 }
668
669 }
670 return success;
671 }
672
679
680 for (vmesh::LocalID block_index=0; block_index<populations[popID].vmesh->size(); ++block_index) {
681 const vmesh::GlobalID globalID = populations[popID].vmesh->getGlobalID(block_index);
682 if (compute_block_has_content(block_index,popID)){
683 velocity_block_with_content_list->push_back(globalID);
684 } else {
685 velocity_block_with_no_content_list->push_back(globalID);
686 }
687 }
688 }
689
691 cerr << "SC::printMeshSizes:" << endl;
692 for (size_t p=0; p<populations.size(); ++p) {
693 cerr << "\t pop " << p << " " << populations[p].vmesh->size() << ' ' << populations[p].blockContainer->size() << endl;
694 }
695 }
696
699 void SpatialCell::updateSparseMinValue(const uint popID) {
700
702
703 if ( population.sparseDynamicAlgorithm == 1 || population.sparseDynamicAlgorithm == 2 ) {
704 // Linear algorithm for the minValue: y=kx+b
705 const Real k = (population.sparseDynamicMinValue2 - population.sparseDynamicMinValue1) / (population.sparseDynamicBulkValue2 - population.sparseDynamicBulkValue1);
706 const Real b = population.sparseDynamicMinValue1 - k * population.sparseDynamicBulkValue1;
707 Real x;
708 if ( population.sparseDynamicAlgorithm == 1 ) {
709 x = this->populations[popID].RHO;
710 } else {
711 x = this->get_number_of_velocity_blocks(popID);
712 }
713 const Real newMinValue = k*x+b;
714 if( newMinValue < population.sparseDynamicMinValue1 ) { // Compare against the min minValue
715 populations[popID].velocityBlockMinValue = population.sparseDynamicMinValue1;
716 } else if( newMinValue > population.sparseDynamicMinValue2 ) { // Compare against the max minValue
717 populations[popID].velocityBlockMinValue = population.sparseDynamicMinValue2;
718 } else {
719 populations[popID].velocityBlockMinValue = newMinValue;
720 }
721 return;
722 } else {
723 populations[popID].velocityBlockMinValue = getObjectWrapper().particleSpecies[popID].sparseMinValue;
724 return;
725 }
726 return;
727 }
728
729} // namespace spatial_cell
for i
Definition Dispersion.m:24
set(gca, 'YDir', 'normal')
vmesh::LocalID get_number_of_velocity_blocks(const uint popID) const
void debug_population_check(const uint popID) const
void updateSparseMinValue(const uint popID)
Real * get_block_parameters(const uint popID)
vmesh::GlobalID get_velocity_block_global_id(const vmesh::LocalID &blockLID, const uint popID) const
size_t count(const vmesh::GlobalID &block, const uint popID) const
static vmesh::GlobalID invalid_global_id()
std::tuple< void *, int, MPI_Datatype > get_mpi_datatype(const CellID cellID, const int sender_rank, const int receiver_rank, const bool receiving, const int neighborhood)
size_t size(const uint popID) const
std::array< Realf *, MAX_NEIGHBORS_PER_DIM > neighbor_block_data
void set_max_r_dt(const uint popID, const Real &value)
void adjustSingleCellVelocityBlocks(const uint popID, bool doDeleteEmpty=false)
vmesh::LocalID get_velocity_block_local_id(const vmesh::GlobalID &blockGID, const uint popID) const
static bool setCommunicatedSpecies(const uint popID)
Real getVelocityBlockMinValue(const uint popID) const
bool compute_block_has_content(const vmesh::GlobalID &block, const uint popID) const
void prepare_to_receive_blocks(const uint popID)
std::vector< vmesh::GlobalID > * velocity_block_with_content_list
velocity_block_indices_t get_velocity_block_indices(const uint popID, const vmesh::GlobalID globalID)
std::vector< vmesh::GlobalID > * velocity_block_with_no_content_list
void remove_velocity_block(const vmesh::GlobalID &block, const uint popID)
std::array< Realf, WID3 > null_block_data
void set_max_v_dt(const uint popID, const Real &value)
const Real & get_max_r_dt(const uint popID) const
std::array< vmesh::LocalID, MAX_NEIGHBORS_PER_DIM > neighbor_number_of_blocks
std::array< Real, bvolderivatives::N_BVOL_DERIVATIVES > derivativesBVOL
void adjust_velocity_blocks(const std::vector< SpatialCell * > &spatial_neighbors, const uint popID, bool doDeleteEmptyBlocks=true)
Realf * get_data(const uint popID)
const Real & get_max_v_dt(const uint popID) const
vmesh::LocalID velocity_block_with_content_list_size
void update_velocity_block_content_lists(const uint popID)
std::array< Real, CellParams::N_SPATIAL_CELL_PARAMS > parameters
const SpatialCell & operator=(const SpatialCell &other)
std::vector< spatial_cell::Population > populations
vmesh::GlobalID get_velocity_block(const uint popID, vmesh::GlobalID blockIndices[3]) const
static vmesh::LocalID invalid_local_id()
std::map< int, std::set< int > > face_neighbor_ranks
bool add_velocity_block(const vmesh::GlobalID &block, const uint popID)
const int WID3
Definition common.h:517
const int SIZE_VELBLOCK
Definition common.h:526
float Real
Definition definitions.h:41
#define MAX_NEIGHBORS_PER_DIM
Definition definitions.h:93
uint64_t CellID
Definition definitions.h:54
float Realf
Definition definitions.h:33
int myRank
Definition gpu_base.cpp:48
const int k
ObjectWrapper & getObjectWrapper()
Definition main.cpp:33
@ N_VELOCITY_BLOCK_PARAMS
Definition common.h:115
@ N_SPATIAL_CELL_PARAMS
Definition common.h:229
@ AMR_ALPHA1
Definition common.h:220
@ AMR_VORTICITY
Definition common.h:223
static const uint64_t CELL_GRADPE_TERM
static const uint64_t VEL_BLOCK_PARAMETERS
static const uint64_t CELL_P
static const uint64_t REFINEMENT_PARAMETERS
static const uint64_t CELL_SYSBOUNDARYFLAG
static const uint64_t CELL_BVOL
static const uint64_t CELL_RHOM_V
static const uint64_t CELL_RHOMDT2_VDT2
static const uint64_t POP_METADATA
static const uint64_t VEL_BLOCK_LIST_STAGE2
static const uint64_t CELL_BVOL_DERIVATIVES
static const uint64_t VEL_BLOCK_LIST_STAGE1
static const uint64_t CELL_PDT2
static const uint64_t CELL_IOLOCALCELLID
static const uint64_t VEL_BLOCK_WITH_CONTENT_STAGE1
static const uint64_t VEL_BLOCK_DATA
static const uint64_t CELL_RHOQ
static const uint64_t NEIGHBOR_VEL_BLOCK_DATA
static const uint64_t VEL_BLOCK_WITH_CONTENT_STAGE2
static const uint64_t CELL_PARAMETERS
static const uint64_t CELL_RHOQDT2
static const uint64_t CELL_DIMENSIONS
std::array< vmesh::LocalID, 3 > velocity_block_indices_t
uint32_t LocalID
Definition definitions.h:60
uint32_t GlobalID
Definition definitions.h:59
std::vector< species::Species > particleSpecies
static int amrMaxSpatialRefLevel
Definition parameters.h:190