Comments (4)
-
To get the number of internal or ghost cells you can use the functions getInternalCount() and getGhostCount() respectively;
-
Cells are stored in a container called PeircedStorage. Internally, this containers stores the cells in a vector but there is no guarantee that the cells will be stored contiguously inside the vector. For examples, if you patch contains the cells 0, 1, 4, 31, 55 (note: the ids of the cells are not necessarily consecutive), those cells may be stored internally in a different order and with some holes between them:
-------------------------------
| 0 | 1 | x | x | 4 | 55 | 31 |
-------------------------------
You can ask for the raw index of a cell in the internal storage of the PiercedVector with the function getRawIndex(long id) of the cell's container (mypatch.getCells().getRawIndex(id)), but if you want to attach some data to your patch, please use the PiercedStorage container. This container will mimic the internal layout of the cell's storage, so you don't have to worry about the internal structure of the container.
int nComponents = 2;
PiercedStorage<double> field(nComponents, &mypatch.getCells());
VolOctree::CellIterator cellBegin = mypatch.cellBegin();
VolOctree::CellIterator cellEnd = mypatch.cellEnd();
for (auto itr = cellBegin; itr != cellEnd; ++itr) {
long cellId = itr.getId();
std::size_t cellRawId = itr.getRawIndex();
field.rawAt(cellRawId) = ...; // Access to the first component
field.rawAt(cellRawId, 0) = ...; // Access to the 1st component
field.rawAt(cellRawId, 1) = ...; // Access to the 2nd component
}
- To get face neighbours you can use one of the findCellFaceNeighs overloads (those functions are defined in the base classe PatchKernel).
If you are asking face neighbours in a performance-critical portion of your code you can also ask this information directly to the cells, but beware that on border faces there will be a dummy cell id set to Cell::NULL_ID (you can recognize this special id because it's negative, while all regular cell ids are equal or greater than zero):
for (Cell &cell : mypatch.getCells() ){
const long *neighs = cell.getAdjacencies();
int nNeighs = cell.getAdjacencyCount();
for (int n=0; n < nNeighs; ++n){
long neigh = neighs[n];
if (neigh < 0) {
continue;
}
<your_code>
}
}
from bitpit.
Thank you. I have a question traversing the octants in this way.
Following your suggestions I just printed the local index for 2 processors (uniform mesh 2048 internalCount for processor)
VolOctree::CellIterator cellBegin = mytree.cellBegin();
VolOctree::CellIterator cellEnd = mytree.cellEnd();
for (auto itr = cellBegin; itr != cellEnd; ++itr) {
long cellId = itr.getId();
PetscSynchronizedPrintf(MPI_COMM_WORLD, "\n %d \t-\t %d",cellId,mytree.getRank());
PetscSynchronizedFlush(MPI_COMM_WORLD,PETSC_STDOUT);
}
The count for each processor seems correct but the loop does not stop in the "internal" octants that I would handle.
The last "correct" print that I get is:
2047 - 0
4095 - 1
Then
4096 - 0
4096 - 1
and go on until
4158 - 0
4158 - 1
Instead of the Partition seems to be correct
PABLO :: Initial Serial distribution :
PABLO :: Octants for proc 0 : 4096
PABLO :: Octants for proc 1 : 4096
PABLO ::
PABLO ::
PABLO :: Final Parallel partition :
PABLO :: Octants for proc 0 : 2048
PABLO :: Final Parallel partition :
PABLO :: Octants for proc 1 : 2048
The exceeding values what represent? Why they are in both processors with the same index? I also tried to extract their information to better understand their presence and also if the global index is the same the x,y coordinates don't mach. As example
cellId x y rank
4156 _ 0.945312 _ 0.507812 - 0
4156 _ 0.945312 _ 0.492188 - 1
4157 _ 0.960938 _ 0.507812 - 0
4157 _ 0.960938 _ 0.492188 - 1
4158 _ 0.976562 _ 0.507812 - 0
4158 _ 0.976562 _ 0.492188 - 1
4159 _ 0.992188 _ 0.507812 - 0
4159 _ 0.992188 _ 0.492188 - 1
(PS. for the coordinates I just used a call to evalCellCentroid(cellId);)
Can you please detail me these points to avoid possible memory problems or overwriting in my code?
from bitpit.
Ciao Alice,
cellBegin and cellEnd methods in Voloctree are for begin and end of all the cells stored in the process portion of the patch(i.e. local cells). In Voloctree internals and ghosts are stored together in the same container. So, if you want to loop over internals only, you have to use internalBegin and internalEnd methods (ghostBegin and ghostEnd for ghosts looping).
from bitpit.
This issue has not seen any recent activity. I'm closing the issue, but feel free to re-open a closed issue if needed.
from bitpit.
Related Issues (20)
- patchkernel: enrich documentation of VolumeMapper
- Fix Cmake min version for pointcloud and lineunstructured modules
- voloctree: DDT Memory Failure when running with guard pages HOT 2
- Bitpit Debug MPI : assertion fails in PatchKernel::getOwner method
- PABLO: *UBSAN runtime_error* Morton left shift by 16 places cannot be represented in type uint64_t HOT 2
- cmake: activate address sanitizer for MSVC compiler
- Outputting RBF objects to text file HOT 5
- patchKernel: Fix documentation in patch_skd_tree.cpp
- Compilation errors with llvm's libc++ : `binary_stream.tpp:72:18: error: reinterpret_cast <...> is not allowed` HOT 6
- CMake error : `check_compiler_flag: C: needs to be enabled before use.`
- Problem with bitpit::CGElem::distancePointPolygon when compiling bitpit in Debug Mode HOT 6
- CMake : errors concerning GetGitRevisionDescription.cmake during configure step
- does bitpit support defining a domain with different lengths in different directions HOT 4
- IO: STLReader::detectFormat returning FormatUnknown for STL case HOT 1
- Example for volOctree with refinement and MPI HOT 9
- Warnings in RBF module
- Parallel RBF for large set of nodes
- Parallel RBF for large set of nodes HOT 2
- After building, headers aren't available HOT 1
- Undefined Reference to `bitpit::ParaTree::ParaTree` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bitpit.