Skip to content

Modifying field values for neighboring cells inside a postprocessor

OpenLB – Open Source Lattice Boltzmann Code Forums on OpenLB General Topics Modifying field values for neighboring cells inside a postprocessor

Viewing 8 posts - 16 through 23 (of 23 total)
  • Author
    Posts
  • #9121
    Danial.Khazaeipoul
    Participant

    I did though about storing the cell IDs, instead of storing pointers to the cell interfaces. However, I would need to create a Cell interface to be able to modify a global data which requires a blockLattice to be passed as an argument:

    Cell<T,DESCRIPTOR> cell(blockLattice, iCell);

    From the user-guide, I can see that the OperatorScope can be set to PerBlock instead of PerCell or PerCellWithParameters. However, I am not sure if this works with the freeSurfacePostProcessor or if OpenLB provides a similar method for block lattice operator such as:

    template <typename T, typename DESCRIPTOR>
    template <typename BLOCK>
    void TestPostProcessor3D<T, DESCRIPTOR>::apply(BLOCK& block)
    {}

    #9122
    Danial.Khazaeipoul
    Participant

    I could potentially simplify this by implementing the algorithm directly within the top-level example. However, I believe doing so would introduce unnecessary complexity and complicate future integration efforts. Instead, I’m working on a more general integration approach, allowing users to easily utilize it in the same way they currently use the free-surface dynamics feature when the code is ready to merge.

    #9125
    Danial.Khazaeipoul
    Participant

    In regard to this part of your question:

    “I assume you want to preserve the queue across operator applications?”

    No, I don’t need to preserve the queue, it is only used as a temporary container to store the cells or their ids to search for the connected gas or interface cells for which the global data, e.g., TEST_ID, is to be modified. Each operator call is going to build its own queue and discard it when the global data is modified.

    #9128
    Adrian
    Keymaster

    Ok, good. This means that you can build on your previous post and store e.g. copies of the cell interfaces instead of pointers or just plain cell IDs and apply them using the CELL::setCellID method.

    #9131
    Danial.Khazaeipoul
    Participant

    Thank you Adrian,

    I attempted to follow your suggestion and only stored the “CellIDs” in the queue. However, it seems that the CUDA platform does not provide the “CELL::setCellId”. I did check the core/platform directory and only the CPU platform implements the “CELL::setCellId” method to be used. The code compiles and runs on CPU platform but it fails to compile on GPUs:

    error: class “olb::gpu::cuda::Cell<T, NavierStokesDescriptor>” has no member “setCellId”

    #9133
    Adrian
    Keymaster

    You are right. Luckily this is easy to fix.

    #9144
    Danial.Khazaeipoul
    Participant

    Thank you for your assistance. FYI, the cell interface for cuda does also miss a getCellId() method which I added per your suggestion:

    CellID getCellId() const __device__ {
    return this->_iCell;
    }

    #9235
    Danial.Khazaeipoul
    Participant

    Dear Adrian,

    Is it possible to perform atomic operations within the operators?
    I am attempting to do atomicMin within the apply() operator as below but I get a compile time error that no instances of the overloaded function “atomicMin” matches the argument provided:

    reducedID = atomicMin(cell.template getFieldPointer<FreeSurface::TEST_ID>(), nbrID);

    Note that, nbrID and the TEST_ID fields are of the type CellID. Moreover, the function itself requires a memory address and a value as below:

    int atomicMin(int* address, int val);
    unsigned int atomicMin(unsigned int* address, unsigned int val);
    unsigned long long int atomicMin(unsigned long long int* address, unsigned long long int val);
    long long int atomicMin(long long int* address, long long int val);
Viewing 8 posts - 16 through 23 (of 23 total)
  • You must be logged in to reply to this topic.