我想把2个容器UEXTERNALDB和UMAT放在大容器Macroscale Analysis里面(如图)。
下面是我的代码:
\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}
答案1
基本上,您需要引入另一个层,behind
如下例中调用 。从您提供的代码和您制作的屏幕截图中,我可以添加 UEXTERNALDB 框,但不能添加 UMAT 框,因为您的代码结果似乎没有您想要适合的三个节点。实际上,我更担心您混合使用不同的语法,有时使用定位right=of...
,有时不使用right of=...
。您node distance
在没有任何区别的位置添加等等。我没有清理你的代码(但在需要更改的位置调整了语法)。所以我想您可以通过在各处使用定位语法和删除node distance
语句来清理代码,这对自己有很大帮助。请不要将这些建议解读为批评,它们只是为了帮助您编写更好的代码,让您能够以更少的努力来控制。
\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}