A B-coloring of a graph $G$ is a proper edge-coloring in which every $4$-cycle is rainbow. Let $q_B(G)$ be the minimum number of colors in such a coloring. Gy\'arf\'as and S\'ark\"ozy (2023) determine $q_B(G)$ when $G=P_m\square P_n$ is a rectangular grid. In this paper, we completely determine $q_B(G)$ for cylindrical and torus grid graphs $G$. For a torus grid $G=C_m\square C_n$, where $m,n\ge3$ are integers, we prove that $q_B(G)=4=\Delta(G)$ if both $m$ and $n$ are even and $G\not\cong C_4\square C_{4k+2}$ for any integer $k\ge1$, and that $q_B(G)=5=\Delta(G)+1$ if at least one of $m,n$ is odd or $G\cong C_4\square C_{4k+2}$ for some integer $k\ge1$. For a cylindrical grid $G=C_s\square P_m$, $q_B(G)$ also depends on the parity of $s$ and the length of $P_m$. For integers $m\ge2$ and $n\ge2$, we have $q_B(C_{2n}\square P_m)=4$. For integers $m\ge2$ and $n\ge1$, we have $q_B(C_{2n+1}\square P_m)=4$ if $2\le m\le n$, whereas $q_B(C_{2n+1}\square P_m)=5$ if $m\ge n+1$. In higher dimensions, we discuss the B-coloring of discrete torus and $\ell$-cylindrical grid, obtaining some exact results and certain bounds.
In 2016, Reiher's clique density theorem determined the minimum number of copies of $K_t$ in a graph with a prescribed edge density. In this paper, we investigate its local version and prove a local clique density theorem in $H$-free graphs as follows. For integers $r$ and $t$ with $2\leq t\leq r-1$, any $r$-chromatic graph $H$, any real numbers $\gamma$ and $\alpha$ with $\frac{t-2}{2(t-1)}\leq\gamma\leq \frac{r-2}{2(r-1)}$ and $0\leq\alpha\leq 1$, we determine the maximum value $\beta:=\beta(r,t,\alpha,\gamma)$ such that for every $n$-vertex $H$-free graph $G$ with at least $\gamma n^2$ edges, every $\lceil\alpha n\rceil$-vertex subset in $G$ contains at least $(\beta-o(1))n^{t}$ copies of $K_t$. In particular, when $H=K_r$, every $\lceil\alpha n\rceil$-vertex subset contains at least $\lfloor\beta n^t\rfloor$ copies of $K_t$, which is an exact bound. For suitable choices of $\alpha$ and $\gamma$, namely, those for which all part ratios in the corresponding extremal construction are rational, this bound is attained for infinitely many values of $n$.