⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 multiblocklattice2d.hh

📁 open lattice boltzmann project www.openlb.org
💻 HH
📖 第 1 页 / 共 3 页
字号:
    for (int rBlock=0; rBlock < getNumRelevantBlocks(); ++rBlock) {        int iBlock = relevantBlocks[rBlock];        BlockParameters2D const& params = getParameters(iBlock);        if ( util::intersect(domain, params.getBulk(), inters) ) {            inters = params.toLocal(inters);            blockLattices[iBlock] -> postProcess(inters.x0, inters.x1, inters.y0, inters.y1);        }    }}template<typename T, template<typename U> class Lattice>void MultiBlockLattice2D<T,Lattice>::postProcess() {    std::vector<int> const& relevantBlocks = getRelevantBlocks();    for (int rBlock=0; rBlock < getNumRelevantBlocks(); ++rBlock) {        int iBlock = relevantBlocks[rBlock];        blockLattices[iBlock] -> postProcess();    }    postProcessMultiBlock();}template<typename T, template<typename U> class Lattice>void MultiBlockLattice2D<T,Lattice>::executeCoupling(int x0_, int x1_, int y0_, int y1_) {    BlockCoordinates2D domain(x0_, x1_, y0_, y1_), inters;    std::vector<int> const& relevantBlocks = getRelevantBlocks();    for (int rBlock=0; rBlock < getNumRelevantBlocks(); ++rBlock) {        int iBlock = relevantBlocks[rBlock];        BlockParameters2D const& params = getParameters(iBlock);        if ( util::intersect(domain, params.getBulk(), inters) ) {            inters = params.toLocal(inters);            blockLattices[iBlock] -> executeCoupling(inters.x0, inters.x1, inters.y0, inters.y1);        }    }}template<typename T, template<typename U> class Lattice>void MultiBlockLattice2D<T,Lattice>::executeCoupling() {    std::vector<int> const& relevantBlocks = getRelevantBlocks();    for (int rBlock=0; rBlock < getNumRelevantBlocks(); ++rBlock) {        int iBlock = relevantBlocks[rBlock];        blockLattices[iBlock] -> executeCoupling();    }    multiBlockHandler -> connectBoundaries(blockLattices, periodicCommunicationOn);}template<typename T, template<typename U> class Lattice>void MultiBlockLattice2D<T,Lattice>::subscribeReductions(Reductor<T>& reductor){    //TODO: this should be generalized to any statistics object    reductor.subscribeAverage(statistics->getNumCells(), statistics->getAverageRho());    reductor.subscribeAverage(statistics->getNumCells(), statistics->getAverageEnergy());    reductor.subscribeMax(statistics->getMaxU());}template<typename T, template<typename U> class Lattice>void MultiBlockLattice2D<T,Lattice>::allocateBlocks() {    for (int iBlock=0; iBlock<getMultiData().getNumBlocks(); ++iBlock) {        int lx=0, ly=0;        if (multiBlockHandler->getLocalEnvelope(iBlock, lx, ly)) {            blockLattices.push_back(new BlockLattice2D<T,Lattice>(lx,ly));        }        else {            blockLattices.push_back( 0 );        }    }}template<typename T, template<typename U> class Lattice>void MultiBlockLattice2D<T,Lattice>::postProcessMultiBlock() {    if (statisticsOn) {        reduceStatistics();    }    multiBlockHandler -> connectBoundaries(blockLattices, periodicCommunicationOn);}template<typename T, template<typename U> class Lattice>void MultiBlockLattice2D<T,Lattice>::reduceStatistics() {    std::vector<T> averageElements, averageWeights, sumElements, minElements, maxElements;    reductor.getAverages(averageElements, averageWeights);    for (unsigned iEl=0; iEl<averageElements.size(); ++iEl) {        averageElements[iEl] =            multiBlockHandler -> reduceAverage(averageElements[iEl], averageWeights[iEl]);    }    reductor.getSums(sumElements);    for (unsigned iEl=0; iEl<sumElements.size(); ++iEl) {        sumElements[iEl] = multiBlockHandler -> reduceSum(sumElements[iEl]);    }    reductor.getMins(minElements);    for (unsigned iEl=0; iEl<minElements.size(); ++iEl) {        minElements[iEl] = multiBlockHandler -> reduceMin(minElements[iEl]);    }    reductor.getMaxs(maxElements);    for (unsigned iEl=0; iEl<maxElements.size(); ++iEl) {        maxElements[iEl] = multiBlockHandler -> reduceMax(maxElements[iEl]);    }    reductor.saveGlobalReductions(averageElements, sumElements, minElements, maxElements);    MultiBlockReductor<T> myReductor;     myReductor.startNewSubscription(); this -> subscribeReductions(myReductor);    myReductor.saveGlobalReductions(averageElements, sumElements, minElements, maxElements);}template<typename T, template<typename U> class Lattice>void MultiBlockLattice2D<T,Lattice>::eliminateStatisticsInEnvelope() {    std::vector<int> const& relevantBlocks = getRelevantBlocks();    for (int rBlock=0; rBlock<getNumRelevantBlocks(); ++rBlock) {        int iBlock = relevantBlocks[rBlock];        int envelopeWidth = getParameters(iBlock).getEnvelopeWidth();        BlockLattice2D<T,Lattice>& block = *blockLattices[iBlock];        int maxX = block.getNx()-1;        int maxY = block.getNy()-1;        block.specifyStatisticsStatus(0, maxX, 0, envelopeWidth-1, false);        block.specifyStatisticsStatus(0, maxX, maxY-envelopeWidth+1, maxY, false);        block.specifyStatisticsStatus(0, envelopeWidth-1,         0, maxY, false);        block.specifyStatisticsStatus(maxX-envelopeWidth+1, maxX, 0, maxY, false);    }}template<typename T, template<typename U> class Lattice>void MultiBlockLattice2D<T,Lattice>::toggleInternalStatistics(bool statisticsOn_) {    statisticsOn = statisticsOn_;}template<typename T, template<typename U> class Lattice>void MultiBlockLattice2D<T,Lattice>::togglePeriodicCommunication(bool periodicCommunicationOn_) {    periodicCommunicationOn = periodicCommunicationOn_;}template<typename T, template<typename U> class Lattice>bool MultiBlockLattice2D<T,Lattice>::isInternalStatisticsOn() const {    return statisticsOn;}template<typename T, template<typename U> class Lattice>bool MultiBlockLattice2D<T,Lattice>::isPeriodicCommunicationOn() const {    return periodicCommunicationOn;}template<typename T, template<typename U> class Lattice>std::vector<BlockLattice2D<T,Lattice>*> MultiBlockLattice2D<T,Lattice>::getBlockLattices() {    return blockLattices;}template<typename T, template<typename U> class Lattice>const std::vector<BlockLattice2D<T,Lattice>*> MultiBlockLattice2D<T,Lattice>::getBlockLattices() const {    return blockLattices;}template<typename T, template<typename U> class Lattice>MultiDataDistribution2D const& MultiBlockLattice2D<T,Lattice>::getMultiData() const {    return multiBlockHandler -> getMultiDataDistribution();}template<typename T, template<typename U> class Lattice>BlockParameters2D const& MultiBlockLattice2D<T,Lattice>::getParameters(int iParam) const {    return getMultiData().getBlockParameters(iParam);}template<typename T, template<typename U> class Lattice>Overlap2D const& MultiBlockLattice2D<T,Lattice>::getNormalOverlap(int iOverlap) const {    return getMultiData().getNormalOverlap(iOverlap);}template<typename T, template<typename U> class Lattice>Overlap2D const& MultiBlockLattice2D<T,Lattice>::getPeriodicOverlap(int iOverlap) const {    return getMultiData().getPeriodicOverlap(iOverlap);}template<typename T, template<typename U> class Lattice>int MultiBlockLattice2D<T,Lattice>::getNumRelevantBlocks() const {    return getRelevantBlocks().size();}template<typename T, template<typename U> class Lattice>MultiDataDistribution2D MultiBlockLattice2D<T,Lattice>::getDataDistribution() const {    return getMultiData();}template<typename T, template<typename U> class Lattice>std::vector<int> const& MultiBlockLattice2D<T,Lattice>::getRelevantBlocks() const {    return multiBlockHandler->getRelevantIndexes().getBlocks();}template<typename T, template<typename U> class Lattice>SpatiallyExtendedObject2D* MultiBlockLattice2D<T,Lattice>::getComponent(int iBlock) {    OLB_PRECONDITION( iBlock<getBlockLattices().size() );    return getBlockLattices()[iBlock];}template<typename T, template<typename U> class Lattice>SpatiallyExtendedObject2D const* MultiBlockLattice2D<T,Lattice>::getComponent(int iBlock) const {    OLB_PRECONDITION( iBlock<getBlockLattices().size() );    return getBlockLattices()[iBlock];}template<typename T, template<typename U> class Lattice>multiPhysics::MultiPhysicsId MultiBlockLattice2D<T,Lattice>::getMultiPhysicsId() const {    return multiPhysics::getMultiPhysicsBlockId<T,Lattice>();}////////// class MultiBlockSerializerPolicy2D ////////////////////////////template<typename T, template<typename U> class Lattice>MultiBlockSerializerPolicy2D<T,Lattice>::MultiBlockSerializerPolicy2D (        MultiBlockLattice2D<T,Lattice> const& lattice_ )    : lattice(lattice_){ }template<typename T, template<typename U> class Lattice>int MultiBlockSerializerPolicy2D<T,Lattice>::getElementSize() const {    return Lattice<T>::q + Lattice<T>::ExternalField::numScalars;}template<typename T, template<typename U> class Lattice>void MultiBlockSerializerPolicy2D<T,Lattice>::serializeElement (        int block, int localX, int localY, T* buffer) const{    lattice.getBlockLattices()[block] -> get(localX, localY).serialize(buffer);}template<typename T, template<typename U> class Lattice>MultiDataDistribution2D const& MultiBlockSerializerPolicy2D<T,Lattice>::getMultiData() const{    return lattice.getMultiData();}template<typename T, template<typename U> class Lattice>bool MultiBlockSerializerPolicy2D<T,Lattice>::isAllocated(int block) const{    return lattice.getBlockLattices()[block];}////////// class MultiBlockUnSerializerPolicy2D ////////////////////////////template<typename T, template<typename U> class Lattice>MultiBlockUnSerializerPolicy2D<T,Lattice>::MultiBlockUnSerializerPolicy2D (        MultiBlockLattice2D<T,Lattice>& lattice_ )    : lattice(lattice_){ }template<typename T, template<typename U> class Lattice>int MultiBlockUnSerializerPolicy2D<T,Lattice>::getElementSize() const {    return Lattice<T>::q + Lattice<T>::ExternalField::numScalars;}template<typename T, template<typename U> class Lattice>void MultiBlockUnSerializerPolicy2D<T,Lattice>::unSerializeElement (        int block, int localX, int localY, T const* buffer){    lattice.getBlockLattices()[block] -> get(localX, localY).unSerialize(buffer);}template<typename T, template<typename U> class Lattice>MultiDataDistribution2D const& MultiBlockUnSerializerPolicy2D<T,Lattice>::getMultiData() const{    return lattice.getMultiData();}template<typename T, template<typename U> class Lattice>bool MultiBlockUnSerializerPolicy2D<T,Lattice>::isAllocated(int block) const{    return lattice.getBlockLattices()[block];}}  // namespace olb#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -