2

I am trying to visualise some grid transformations in a report that I am writing. I am happy with the left-hand side grid in the figure I attached and now I need to create an annulus meshed which is shown on the right. It is important that they they have the same number of points. Since left one is 10-by-10 the right one should have 10 points along the circumference and 10 in the wall normal direction. enter image description here

Here is the code I used to generate the left one:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{calc}

\begin{document} \begin{figure}[h!] \centering \begin{tikzpicture} \coordinate (A) at (0,0); \coordinate (B) at (3,0); \coordinate (C) at (3,3); \coordinate (D) at (0,3);

    \foreach [evaluate=\i as \x using \i/10] \i in {0,...,10} 
    {
        \draw ($(A)!\x!(B)$) arc -- ($(D)!\x!(C)$);
        \draw ($(A)!\x!(D)$) -- ($(B)!\x!(C)$);
    }   
    \draw[->, >= Latex] (-0.1, -0.1) -- (1, -0.1);
    \draw[->, >= Latex] (-0.1, -0.1) -- (-0.1, 1);
    \draw[->, >= Latex] (-0.1, -0.1) -- (0.5, 0.5);
    \node[] at (1, -0.35) (y) {$\zeta$};
    \node[] at (-0.35, 1) (x) {$\eta$};
    \node[] at (-0.35, -0.10) (x) {$\xi$};
    \draw[->, >= Latex] (3.5, 1.5) -- (4.5, 1.5);
\end{tikzpicture}
\caption{Visualisation of a mapping from a computational grid to a physical space using 2D section.}

\end{figure} \end{document}

Do you have any advice?

Thanks!

  • 1
    Use polar coordinates and closed paths. – projetmbc Jan 09 '24 at 23:29
  • 1
    Have you searched "torus" in this forum? there are several TikZ solutions. My advice is an Asymptote one: just take m=10, n=10 and remove the dots from this code https://tex.stackexchange.com/a/696595/140722 – Black Mild Jan 10 '24 at 03:51
  • Missing \documentclass. – Sebastiano Jan 10 '24 at 08:45
  • Welcome to TeX.SX. When you post a question, always provide a "Minimal Working Example" (MWE) that starts with \documentclass, includes all relevant \usepackage commands, ends with \end{document} and compiles without errors, even if it does not produce your desired output. That way other users can simply copy and paste your code in order to help you. Note that the arc in your code shouldn't be there. Please edit your question. – Sandy G Jan 10 '24 at 13:24
  • Unrelated: \draw[step=3mm] (0,0)grid(3,3); is an easier way to draw your grid. – Sandy G Jan 10 '24 at 13:25

1 Answers1

3

Update: After rereading your question, I realize you want an annulus, not a torus. Replace the scope here in the original code:

\begin{scope}[shift={(7,1.5)}]
    \foreach \t in {0,...,10}{
        \draw (0,0) circle[radius=1+.1*\t];
        \draw (36*\t:1)--(36*\t:2);
    }
\end{scope}

enter image description here

I'm assuming you only want 5 longitudinal regions visible since the other 5 are on the back side.

Original solution:

A few suggestions:

  • Use grid to simplify the code for the rectangular grid.
  • Nodes can be included in the \draw commands for simpler placement.
  • A scope can make calculations easier, allowing polar coordinates for the torus.

enter image description here

\documentclass{article}

\usepackage{tikz} \usetikzlibrary{arrows.meta}

\begin{document}

\begin{figure}[h!] \centering \begin{tikzpicture} \draw[step=3mm] (0,0)grid(3,3); \draw[-Latex] (-0.1, -0.1) -- (1, -0.1) node[below]{$\zeta$}; \draw[-Latex] (-0.1, -0.1) -- (-0.1, 1) node[left]{$\eta$}; \draw[-Latex] (-0.1, -0.1) node[left]{$\xi$} -- (0.5, 0.5);

    \draw[-Latex] (3.5, 1.5) -- (4.5, 1.5);
    \begin{scope}[shift={(7,1.5)}]
        \foreach \t in {0,36,...,360}{
            \draw (0,0) circle[radius=1.5+.5*cos(\t)];
            \draw (\t:1)--(\t:2);
        }
    \end{scope} 
\end{tikzpicture}
\caption{Visualisation of a mapping from a computational grid to a physical space using 2D section.}

\end{figure}

\end{document}

Sandy G
  • 42,558