Git Product home page Git Product logo

Comments (4)

andrea-iob avatar andrea-iob commented on July 21, 2024
  1. To get the number of internal or ghost cells you can use the functions getInternalCount() and getGhostCount() respectively;

  2. 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
}
  1. 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.

araeli avatar araeli commented on July 21, 2024

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.

marcocisternino avatar marcocisternino commented on July 21, 2024

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.

marcocisternino avatar marcocisternino commented on July 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.