Skip to content

Passing a custom field to coupling

OpenLB – Open Source Lattice Boltzmann Code Forums on OpenLB General Topics Passing a custom field to coupling

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #8436
    avrachan1
    Participant

    Dear Community,

    I would like to store the densities computed at a timestep and pass this to coupling object in the next time step.

    Essentially the densities at a given timestep is a scalar field at each lattice node.

    I tried to store it as

    `
    struct PREV_PHI: public FIELD_BASE<1,0,0> { };
    using T = FLOATING_POINT_TYPE;
    using DESCRIPTOR = D3Q19<PREV_PHI>;
    `

    Then using a post processor I store it after each time-step

    `
    class StorePrevPhi {
    public:
    static constexpr OperatorScope scope = OperatorScope::PerCell;

    int getPriority() const {
    // Ensure that the post processor is executed after any boundary processing
    // Alternatively it may be nicer to add it to a custom stage and call it only when necessary in the main loop
    return std::numeric_limits<int>::max();
    }

    template <typename CELL>
    void apply(CELL& cell) any_platform {
    using V = typename CELL::value_t;
    using DESCRIPTOR = typename CELL::descriptor_t;
    V rho { };
    rho=cell.computeRho();

    cell.template setField<PREV_PHI>(rho);
    }

    };

    I add the post-processor

    `
    sLattice.addPostProcessor(bulkIndicatorHE, meta::id<StorePrevPhi>{});
    `

    However in the coupling, when I try to access the FIELD PREV_PHI using

    `

    auto prevphi = cellPFE.template getFieldPointer <DESCRIPTOR::PREV_PHI>();
    `

    I get the error,

    olb-1.6r0/src/dynamics/navierStokesAdvectionDiffusionCoupling.h:179:66: error: no member named ‘PREV_PHI’ in ‘olb::descriptors::D3Q19<>’

    How do I set a field associated with a cell and access it elsewhere ?

    #8437
    Adrian
    Keymaster

    The problem is that your custom field PREV_PHI is not a member of DESCRIPTOR but a separate type. Simply amend your field get/set functions to use it without the DESCRIPTOR:: prefix.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.