近期的疑问:禁止套娃

    科技2026-04-25  13

    /* *************** Velocity ****************************************** */ template<typename T, template<typename U> class Descriptor> void computeVelocity( MultiGridLattice3D<T,Descriptor>& lattice, MultiGridTensorField3D<T,Descriptor<T>::d>& velocity, Box3D domain ) { applyProcessingFunctional ( new BoxVelocityFunctional3D<T,Descriptor>, domain, lattice, velocity, lattice.getReferenceLevel() ); } template<typename T, template<typename U> class Descriptor> std::auto_ptr<MultiGridTensorField3D<T,Descriptor<T>::d> > computeVelocity(MultiGridLattice3D<T,Descriptor>& lattice, Box3D domain) { MultiGridTensorField3D<T,Descriptor<T>::d>* velocity = new MultiGridTensorField3D<T,Descriptor<T>::d>(lattice, domain); computeVelocity(lattice, *velocity, domain); return std::auto_ptr<MultiGridTensorField3D<T,Descriptor<T>::d> >(velocity); } template<typename T, template<typename U> class Descriptor> std::auto_ptr<MultiGridTensorField3D<T,Descriptor<T>::d> > computeVelocity(MultiGridLattice3D<T,Descriptor>& lattice) { return computeVelocity(lattice, lattice.getBoundingBox()); }

    src/multiGrid/multiGridDataAnalysisWrapper3D.hh 上面为我找到的computeVelocity源码,大致就是通过 applyProcessingFunctional ( new BoxVelocityFunctional3D<T,Descriptor>, domain, lattice, velocity, lattice.getReferenceLevel() ); 来运行一下数据处理器(data processor)。

    而在下面的源码中,lattice.get(iX,iY,iZ).computeVelocity()是不是又套娃回来了?

    template<typename T, template<typename U> class Descriptor> void BoxVelocityFunctional3D<T,Descriptor>::process ( Box3D domain, BlockLattice3D<T,Descriptor>& lattice, TensorField3D<T,Descriptor<T>::d>& tensorField) { Dot3D offset = computeRelativeDisplacement(lattice, tensorField); for (plint iX=domain.x0; iX<=domain.x1; ++iX) { for (plint iY=domain.y0; iY<=domain.y1; ++iY) { for (plint iZ=domain.z0; iZ<=domain.z1; ++iZ) { lattice.get(iX,iY,iZ).computeVelocity ( tensorField.get(iX+offset.x,iY+offset.y,iZ+offset.z) ); } } } } template<typename T, template<typename U> class Descriptor> BoxVelocityFunctional3D<T,Descriptor>* BoxVelocityFunctional3D<T,Descriptor>::clone() const { return new BoxVelocityFunctional3D<T,Descriptor>(*this); } template<typename T, template<typename U> class Descriptor> void BoxVelocityFunctional3D<T,Descriptor>::getTypeOfModification(std::vector<modif::ModifT>& modified) const { modified[0] = modif::nothing; modified[1] = modif::staticVariables; } template<typename T, template<typename U> class Descriptor> BlockDomain::DomainT BoxVelocityFunctional3D<T,Descriptor>::appliesTo() const { return BlockDomain::bulk; }

    src/dataProcessors/dataAnalysisFunctional3D.hh

    Processed: 0.009, SQL: 9