4

I'm trying to produce the following flowchart with adding multiple dotted backgrounds. I know the basics for creating a simple flowchart using Tikz, however, I'd like to know how I can create a flowchart which is a bit complicated as shown below. I created the figure in MS PowerPoint.

MWE for the simple flow-chart I created:

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{tikz}
\usepackage{adjustbox}
\usetikzlibrary{shapes.geometric, arrows}
\usetikzlibrary{automata,positioning}
\usetikzlibrary{shapes.multipart}
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=red!30]
\tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, text width=3cm,draw=black, fill=blue!30]
\tikzstyle{process} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm, text centered, text width=3cm, draw=black, fill=orange!30]
\tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30]
\tikzstyle{arrow} = [thick,->,>=stealth]

\begin{document}

\begin{figure}[htbp]
\centering
\begin{tikzpicture}[
    node distance=2cm
  ]
\node (pro1) [process, below of=in1,yshift=-0.5cm] {Meshing\\A};
\node (pro0) [process, left of=pro1, xshift=-2.5cm] {Design\\A};
\node (pro2) [process, below of=pro1,yshift=-0.5cm] {solver setup};
\node (pro) [process, right of=pro2, xshift=2.5cm] {A\\+\\B};

\node (dec1) [decision, below of=pro2, yshift=-0.8cm] {i = N?};
\node (dec2) [decision, left of=dec1, xshift=-2.5cm] {Converged?};
\node (pro5) [process, left of=dec2, xshift=-2.5cm] {i = i+1};
\node (pro6) [process, below of=dec1, yshift=-1cm] {Post processing};
\draw [arrow] (pro0) -- (pro1);
\draw [arrow] (pro1) -- (pro2);
\draw [arrow] (pro) -- (pro2);

\draw [arrow] (pro2) -- (dec1);
\draw [arrow] (dec1) -- node[anchor=south] {No} (dec2);
\draw [arrow] (dec2) -- node[anchor=south] {No} (pro5);
\draw [arrow] (pro5) |- (pro2);
\draw [arrow] (dec1) -- node[anchor=west] {Yes} (pro6);
\draw [arrow] (dec2) |- node[anchor=north] {Yes} (pro6);
\end{tikzpicture}
\end{figure}

\end{document}

This provides a simple output:

enter image description here

However, I'm looking for a much complicated output as shown below:

enter image description here

Thanks for your time and help in advance.

4
  • 2
    You can take some ideas from this example texample.net/tikz/examples/flowchart
    – Andrey L.
    Apr 21, 2022 at 13:58
  • Your example starts by below of=in1 where no node is named in1. Please edit it to make it compilable. Now for what you're looking for, you should find the fit library useful.
    – SebGlav
    Apr 21, 2022 at 17:05
  • @AndreyL.: Thanks!
    – Rahman
    Apr 21, 2022 at 21:16
  • @SebGlav: I see that now. I forgot to edit that.
    – Rahman
    Apr 21, 2022 at 21:16

1 Answer 1

3

Here's something very generic, just to show the use of the fit library in this particular case.

Note that I repaced all your tikzstyle by tikzset, which are the modern way of designing styles in TikZ.

use of fit library

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{tikz}
\usepackage{adjustbox}
\usetikzlibrary{shapes.geometric, arrows, fit}
\usetikzlibrary{automata,positioning}
\usetikzlibrary{shapes.multipart}
\tikzset{
    startstop/.style =
        {rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=red!30},
    io/.style = 
        {trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, text width=3cm,draw=black, fill=blue!30},
    process/.style = {rectangle, rounded corners, minimum width=3cm, minimum height=1cm, text centered, text width=3cm, draw=black, fill=orange!30},
    decision/.style = {diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30},
    arrow/.style = {thick,->,>=stealth},
    myfit/.style={draw,dashed,blue, inner xsep=10pt, inner ysep=15pt, rounded corners=5pt},
    mytitle/.style={draw,densely dashed,blue, fill=orange!50, inner sep=5pt, right, xshift=10pt}
    }



\begin{document}

\begin{figure}[htbp]
\centering
\begin{tikzpicture}[
    node distance=2cm
  ]
\node (pro1) [process, yshift=-0.5cm] {Meshing\\A};
\node (pro0) [process, left of=pro1, xshift=-2.5cm] {Design\\A};
\node (pro2) [process, below of=pro1,yshift=-0.5cm] {solver setup};
\node (pro) [process, right of=pro2, xshift=2.5cm] {A\\+\\B};

\node (dec1) [decision, below of=pro2, yshift=-0.8cm] {i = N?};
\node (dec2) [decision, left of=dec1, xshift=-2.5cm] {Converged?};
\node (pro5) [process, left of=dec2, xshift=-2.5cm] {i = i+1};
\node (pro6) [process, below of=dec1, yshift=-1cm] {Post processing};
\draw [arrow] (pro0) -- (pro1);
\draw [arrow] (pro1) -- (pro2);
\draw [arrow] (pro) -- (pro2);

\draw [arrow] (pro2) -- (dec1);
\draw [arrow] (dec1) -- node[anchor=south] {No} (dec2);
\draw [arrow] (dec2) -- node[anchor=south] {No} (pro5);
\draw [arrow] (pro5) |- (pro2);
\draw [arrow] (dec1) -- node[anchor=west] {Yes} (pro6);
\draw [arrow] (dec2) |- node[anchor=north] {Yes} (pro6);

\node[fit=(pro1)(pro0),myfit] (myfit1) {};
\node[mytitle] at (myfit1.north west) {Pre-processing};
\draw[arrow,blue] (myfit1) -| (pro);

\end{tikzpicture}
\end{figure}

\end{document}
4
  • Thanks, @SebGlav. Appreciate it.
    – Rahman
    Apr 21, 2022 at 21:16
  • Can I also use \node for drawing multiple nodes inside the dotted box for 'Solver set-up' as shown in my 2nd picture attached in the post? That part was a bit complex for me.
    – Rahman
    Apr 21, 2022 at 21:35
  • 1
    Every node can be drawn with \node. In this particular case, I recommand to use matrix of nodes. You could ask for this specific part in another question.
    – SebGlav
    Apr 22, 2022 at 6:15
  • Thanks, @SebGlav!
    – Rahman
    Apr 22, 2022 at 6:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .