1

I want to put 2 containers UEXTERNALDB and UMAT within the big container Macroscale Analysis (as in figure)enter image description here.

Here is my code below:

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage[active,tightpage]{preview}
\usetikzlibrary{shapes,arrows.meta,calc,fit,backgrounds,shapes.multipart, 
 positioning}
\tikzset{box/.style={draw, rectangle, rounded corners, thick, node 
 distance=7em, 
text width=6em, text centered, minimum height=3.5em}}
%\tikzset{line/.style={draw, thick, -{Latex[length=2mm,width=1mm]}}}
\tikzset{every node/.style={font=\scriptsize}}

\PreviewEnvironment{tikzpicture}
%=======================================
% Adjust the boarder of the flowchart
%=======================================
\setlength\PreviewBorder{4pt}%

\begin{document}
%************************************************************
%************************************************************
%  Define block styles
%************************************************************
%************************************************************
\tikzset{block/.style={rectangle split, draw, rectangle split parts=2,
text width=14em, text centered, rounded corners, minimum height=4em},
grnblock/.style={rectangle, draw, fill=green!20, text width=10em, text 
centered, rounded corners, minimum height=4em}, 
whtblock/.style={rectangle, draw, fill=white!20, text width=10em, text 
centered, minimum height=3em},    
ylwblock/.style={rectangle, draw, fill=yellow, text width=10em, text 
centered, minimum height=3em}, 
line/.style={draw, -{Latex[length=2mm,width=1mm]}},
cloud/.style={draw, ellipse,fill=white!20, node distance=3cm,    minimum 
height=3em},  
container1/.style={draw, rectangle,dashed,inner sep=0.28cm, rounded
corners,fill=green!8,minimum height=2.4cm,minimum width=5.6cm},
container2/.style={draw, rectangle,dashed,inner sep=0.28cm, rounded
corners,fill=red!8,minimum height=2.4cm,minimum width=5.6cm},
container3/.style={draw, rectangle,dashed,inner sep=0.28cm, rounded
corners,fill=gray!15,minimum height=1.4cm,minimum width=5.6cm}}
%************************************************************
%************************************************************ 
\begin{tikzpicture}[node distance = 1.20cm, auto]
%************************************************************
%************************************************************
%  Draw nodes
%************************************************************
%************************************************************

% ****************************************************
% ****************************************************
%===============================================    
%  Microscale: FEM
%===============================================  
\node [whtblock,font=\fontsize{10}{0}\selectfont] (MicFEM) {Finite element 
mesh \\[0.5em]for microstructure};   
%===============================================    
%  Microscale: ROM
%===============================================     
\node [whtblock, below=of MicFEM, node distance=2.5cm,font=\fontsize{10} 
{0}\selectfont] (ROM) {Generate Reduced Order \\[0.5em]Model (ROM)\\[0.3em] 
parts and order};

%===============================================    
%  Micro-morphology
%===============================================      
\node [grnblock, left=of MicFEM,node distance=7cm,font=\fontsize{10} 
{0}\selectfont] (Morph) {\textbf{Microstructure:}\\[0.75em]Morphological 
properties,\\ e.g. fiber volume fraction, cell type};    
%===============================================    
%  Constituent elastic parameters
%===============================================  
\node [block, right=of ROM,node distance=7cm,rectangle split part fill= 
{orange!20,blue!3},font=\fontsize{10}{0}\selectfont] (ConstElasProp) 
{\textbf{Constituent Elastic Parameters}
\nodepart[text width=3cm]{two} 
$E^{(f)}_{1},E^{(f)}_{3},G^{(f)}_{13},\nu^{(f)}_{12},\nu^{(f)}_{31}$\\ 
[0.3em]$E^{(m)},\nu^{(m)}$};
%===============================================    
%  CoefTens Compute
%===============================================      
\node [whtblock, below=of ROM, node distance=2.5cm,font=\fontsize{9} 
{0}\selectfont] (CfTns) {Compute \\[0.5em]coefficient tensors\\[0.5em] 
(\textbf{CoefTensCompute})\\[0.4em] \textcolor{blue}{In-house code}};

% ****************************************************
% ****************************************************
%===============================================    
%  Macroscale: FEM
%===============================================    
\node [whtblock, below=of CfTns, node distance=3.5cm,font=\fontsize{10} 
{0}\selectfont] (MacFEM) {Coefficient tensors\\[0.5em] for undamaged and\\ 
[0.5em] failed microstructure};
%===============================================    
%  ABAQUS
%===============================================      
\node [ylwblock, below=of MacFEM,font=\fontsize{10}{0}\selectfont] (ABAQ) 
{\textbf{FE analysis}\\[0.2em]\textcolor{blue}{\textbf{Abaqus software}}};  
%===============================================    
%  Macroscale: Geometry, BCs and other details
%===============================================     
\node [grnblock, left=of ABAQ, node distance=7cm,font=\fontsize{10} 
{0}\selectfont] (MacInpFile) {\textbf{Structure:}\\[0.5em] Component layup 
\\geometry, \\boundary conditions,\\ discretization}; 
%===============================================    
%  UMAT code
%===============================================      
\node [whtblock, right of=ABAQ, node distance=7cm,font=\fontsize{10} 
{0}\selectfont] (UMAT) {User-defined \\[0.3em]material subroutine\\[0.3em] 
(\textbf{UMAT})\\[0.3em] \textcolor{blue}{In-house code}};
%===============================================    
%  Constituent damage parameters
%===============================================  
\node [block, above=of UMAT,node distance=10cm,rectangle split part fill= 
{orange!20,blue!3},font=\fontsize{10}{0}\selectfont] (MatParm) 
{\textbf{Constituent Damage Parameters}
\nodepart[text width=5cm] 
{two}$\alpha^{(f)},\beta^{(f)},c^{(f)},\alpha^{\textrm{\scriptsize{N}} 
(m)},\alpha^{\textrm{\scriptsize{S}}(m)}$\\ 
[0.4em]$\beta^{\textrm{\scriptsize{N}}(m)},\beta^{\textrm{\scriptsize{S}} 
(m)},c^{(m)},\epsilon^{(f)}_{0},\epsilon^{(m)}_{0}$\\ 
 [0.4em]$\epsilon^{(f)}_\textrm{\scriptsize f}, 
 \epsilon^{\textrm{\scriptsize{N}}(m)}_\textrm{\scriptsize 
f},\epsilon^{\textrm{\scriptsize{S}}(m)}_\textrm{\scriptsize f}$};%\\[0.3em] 
\textcolor{blue}{In-house code}}; 

 % ****************************************************
 % ****************************************************    
%===============================================    
%  Output
%===============================================
\node [block, below=of ABAQ, node distance=3cm,rectangle split part fill= 
{blue!20,white},font=\fontsize{10}{0}\selectfont] (Output) {\textbf{Output}
\nodepart[text width=3cm]{two}Ultimate strength,\\[0.3em]damage contours};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   CONTAINERS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{scope}[on background layer]
 \coordinate (aux1) at ([yshift=3mm]MicFEM.north);
 \node [container1,fit=(aux1)(Morph) (ROM)(CfTns)(ConstElasProp)] (MICRO) 
 {};
   \node at (MICRO.north) [fill=white,draw,font=\fontsize{12}{0}\selectfont] 
 {\textbf{Microscale Analysis}};
%-----------------------------------------------------------
 \coordinate (aux2) at ([yshift=3mm]MacFEM.north);
 \node[container2, fit=(aux2) (MacInpFile) (MacFEM) (ABAQ) (UMAT)] (MACRO) 
 {};
 \node at (MACRO.north) [fill=white,draw,font=\fontsize{12}{0}\selectfont] 
 (MACRO-label) {\textbf{Macroscale Analysis}};
 %-----------------------------------------------------------
 \coordinate (aux3) at (5,-5);
 \node[container3, fit=(aux3) (CfTns)(ConstElasProp)] (UEXT) {};
 \node at (MACRO.north) [fill=white,draw,font=\fontsize{12}{0}\selectfont] 
 (UEXT-label) {\textbf{UEXTERNALDB}};
 \end{scope}
 %************************************************************
 %************************************************************
 %  Draw edges
 %************************************************************
 %************************************************************
 \path [line] (MicFEM) -- (ROM);
 \path [line] (ROM) -- (CfTns);
 \path [line] (MacFEM) -- (ABAQ);
\path [line] (MacInpFile) -- (ABAQ);
\path [line] (CfTns) -- (MacFEM);
\path [line] (Morph) -- (MicFEM);
\path [line] (MatParm) -- (UMAT);
\path [line] (ConstElasProp) -- (ROM);
\path [line] (UMAT) -- (ABAQ);
\path [line] (ABAQ) -- (Output);
\end{tikzpicture}
\end{document} 
3

Basically you need to introduce another layer, called behind in the example below. From the code you provide and the screenshot you made, I could add the UEXTERNALDB box, but not the UMAT box because the result of your code does not seem to have the three nodes you want to fit. I am actually much more concerned about the fact that you mix different syntax, sometimes you use positioning like right=of..., and sometimes you don't right of=.... You add node distance at positions where it does not make any difference and so on and so forth. I did not clean up your code (but adjusted the syntax at positions where I needed to change things). So I guess you could help yourself a lot by cleaning up your code by using positioning syntax everywhere and drop node distance statements. And please do not interpret these recommendations as criticisms, they are only meant to help you to write a better code that you can control with less effort.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{shapes,arrows.meta,calc,fit,shapes.multipart, 
 positioning}
\pgfdeclarelayer{behind}
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{behind,background,main,foreground}
\tikzset{box/.style={draw, rectangle, rounded corners, thick, node 
 distance=7em, 
text width=6em, text centered, minimum height=3.5em}}
\tikzset{every node/.append style={font=\scriptsize}}
\begin{document}
%************************************************************
%************************************************************
%  Define block styles
%************************************************************
%************************************************************
\tikzset{block/.style={rectangle split, draw, rectangle split parts=2,
text width=14em, text centered, rounded corners, minimum height=4em},
grnblock/.style={rectangle, draw, fill=green!20, text width=10em, text 
centered, rounded corners, minimum height=4em}, 
whtblock/.style={rectangle, draw, fill=white!20, text width=10em, text 
centered, minimum height=3em},    
ylwblock/.style={rectangle, draw, fill=yellow, text width=10em, text 
centered, minimum height=3em}, 
line/.style={draw, -{Latex[length=2mm,width=1mm]}},
cloud/.style={draw, ellipse,fill=white!20, node distance=3cm,    minimum 
height=3em},  
container1/.style={draw, rectangle,dashed,inner sep=0.28cm, rounded
corners,fill=green!8,minimum height=2.4cm,minimum width=5.6cm},
container2/.style={draw, rectangle,dashed,inner sep=0.28cm, rounded
corners,fill=red!8,minimum height=2.4cm,minimum width=5.6cm},
container3/.style={draw, rectangle,dashed,inner sep=0.28cm, rounded
corners,fill=gray!15,minimum height=1.4cm,minimum width=5.6cm}}
%************************************************************
%************************************************************ 
\begin{tikzpicture}[node distance = 1.20cm, auto]
%************************************************************
%************************************************************
%  Draw nodes
%************************************************************
%************************************************************

% ****************************************************
% ****************************************************
%===============================================    
%  Microscale: FEM
%===============================================  
\node [whtblock,font=\fontsize{10}{0}\selectfont] (MicFEM) {Finite element 
mesh \\[0.5em]for microstructure};   
%===============================================    
%  Microscale: ROM
%===============================================     
\node [whtblock, below=of MicFEM, node distance=2.5cm,font=\fontsize{10} 
{0}\selectfont] (ROM) {Generate Reduced Order \\[0.5em]Model (ROM)\\[0.3em] 
parts and order};

%===============================================    
%  Micro-morphology
%===============================================      
\node [grnblock, left=of MicFEM,node distance=7cm,font=\fontsize{10}{0}\selectfont] (Morph) {\textbf{Microstructure:}\\[0.75em]Morphological 
properties,\\ e.g.\ fiber volume fraction, cell type};    
%===============================================    
%  Constituent elastic parameters
%===============================================  
\node [block, right=of ROM,node distance=7cm,rectangle split part fill= 
{orange!20,blue!3},font=\fontsize{10}{0}\selectfont] (ConstElasProp) 
{\textbf{Constituent Elastic Parameters}
\nodepart[text width=3cm]{two} 
$E^{(f)}_{1},E^{(f)}_{3},G^{(f)}_{13},\nu^{(f)}_{12},\nu^{(f)}_{31}$\\ 
[0.3em]$E^{(m)},\nu^{(m)}$};
%===============================================    
%  CoefTens Compute
%===============================================      
\node [whtblock, below=of ROM, node distance=2.5cm,font=\fontsize{9}{0}\selectfont] (CfTns) {Compute \\[0.5em]coefficient tensors\\[0.5em] 
(\textbf{CoefTensCompute})\\[0.4em] \textcolor{blue}{In-house code}};

% ****************************************************
% ****************************************************
%===============================================    
%  Macroscale: FEM
%===============================================    
\node [whtblock, below=3.5cm of CfTns,font=\fontsize{10} 
{0}\selectfont] (MacFEM) {Coefficient tensors\\[0.5em] for undamaged and\\ 
[0.5em] failed microstructure};
%===============================================    
%  ABAQUS
%===============================================      
\node [ylwblock, below=3cm of MacFEM,font=\fontsize{10}{0}\selectfont] (ABAQ) 
{\textbf{FE analysis}\\[0.2em]\textcolor{blue}{\textbf{Abaqus software}}};  
%===============================================    
%  Macroscale: Geometry, BCs and other details
%===============================================     
\node [grnblock, left=of ABAQ, node distance=7cm,font=\fontsize{10} 
{0}\selectfont] (MacInpFile) {\textbf{Structure:}\\[0.5em] Component layup 
\\geometry, \\boundary conditions,\\ discretization}; 
%===============================================    
%  UMAT code
%===============================================      
\node [whtblock, right=1.5cm of ABAQ, font=\fontsize{10} 
{0}\selectfont] (UMAT) {User-defined \\[0.3em]material subroutine\\[0.3em] 
(\textbf{UMAT})\\[0.3em] \textcolor{blue}{In-house code}};
%===============================================    
%  Constituent damage parameters
%===============================================  
\node at (MacFEM.center -| UMAT.center) [block,anchor=center,rectangle split part fill= 
{orange!20,blue!3},font=\fontsize{10}{0}\selectfont] (MatParm) 
{\textbf{Constituent Damage Parameters}
\nodepart[text width=5cm] 
{two}$\alpha^{(f)},\beta^{(f)},c^{(f)},\alpha^{\textrm{\scriptsize{N}} 
(m)},\alpha^{\textrm{\scriptsize{S}}(m)}$\\ 
[0.4em]$\beta^{\textrm{\scriptsize{N}}(m)},\beta^{\textrm{\scriptsize{S}} 
(m)},c^{(m)},\epsilon^{(f)}_{0},\epsilon^{(m)}_{0}$\\ 
 [0.4em]$\epsilon^{(f)}_\textrm{\scriptsize f}, 
 \epsilon^{\textrm{\scriptsize{N}}(m)}_\textrm{\scriptsize 
f},\epsilon^{\textrm{\scriptsize{S}}(m)}_\textrm{\scriptsize f}$\\[0.3em] 
\textcolor{blue}{In-house code}}; 

 % ****************************************************
 % ****************************************************    
%===============================================    
%  Output
%===============================================
\node [block, below=of ABAQ, node distance=3cm,rectangle split part fill= 
{blue!20,white},font=\fontsize{10}{0}\selectfont] (Output) {\textbf{Output}
\nodepart[text width=3cm]{two}Ultimate strength,\\[0.3em]damage contours};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   CONTAINERS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{pgfonlayer}{background}
 \coordinate (aux1) at ([yshift=3mm]MicFEM.north);
 \node [container1,fit=(aux1)(Morph) (ROM)(CfTns)(ConstElasProp)] (MICRO) 
 {};
   \node at (MICRO.north) [fill=white,draw,font=\fontsize{12}{0}\selectfont] 
 {\textbf{Microscale Analysis}};
 %-----------------------------------------------------------
 \path (MatParm.north) -- ++(0,0.6) coordinate (aux3);
 %\node[container3, fit=(aux3) (CfTns)(ConstElasProp)] (UEXT) {};
 \node[container3, fit=(MacFEM)(MatParm) (aux3)] (UEXT) {};
 \node at (UEXT.north) [fill=white,draw,font=\fontsize{12}{0}\selectfont] 
 (UEXT-label) {\textbf{UEXTERNALDB}};
 %-----------------------------------------------------------
\path [line] (CfTns) -- (MacFEM);
\end{pgfonlayer}
\begin{pgfonlayer}{behind}
 \coordinate (aux2) at ([yshift=5mm]UEXT-label.north);
 \node[container2, fit=(aux2) (MacInpFile) (MacFEM) (ABAQ) (UMAT)
 (UEXT-label) (UEXT)] (MACRO) 
 {};
\end{pgfonlayer}
 \node at (MACRO.north) [fill=white,draw,font=\fontsize{12}{0}\selectfont] 
 (MACRO-label) {\textbf{Macroscale Analysis}};
 %************************************************************
 %************************************************************
 %  Draw edges
 %************************************************************
 %************************************************************
 \path [line] (MicFEM) -- (ROM);
 \path [line] (ROM) -- (CfTns);
 \path [line] (MacFEM) -- (ABAQ);
\path [line] (MacInpFile) -- (ABAQ);
\path [line] (Morph) -- (MicFEM);
\path [line] (MatParm) -- (UMAT);
\path [line] (ConstElasProp) -- (ROM);
\path [line] (UMAT) -- (ABAQ);
\path [line] (ABAQ) -- (Output);
\end{tikzpicture}
\end{document} 

enter image description here

4
  • Thanks for your help. Is there a way I can put 2 blocks within UEXTERNALDB side by side as in the picture?
    – LarCos
    Feb 4 '19 at 22:52
  • @LarCos Yes. I guess you might want to clean up your code a bit before that since otherwise it will become too complicated.
    – user121799
    Feb 4 '19 at 22:55
  • I am a beginner. I have no idea how to do that. I'm basically trying to follow the code you posted. Could you please suggest me what you mean by 'clean up'?
    – LarCos
    Feb 4 '19 at 23:03
  • @LarCos I am only trying to encourage you to make your life easier. You leave people who spend their time trying to help you basically two options: clean up your code and address all requests, or just to ignore your post. The idea behind this site is, however, to provide you with the information how you could solve your problems yourself.
    – user121799
    Feb 4 '19 at 23:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.