For study 3D instabilities problem i.e a base state (velocity field and temperature field) and an additional perturbation.
The method must be independent of the type of instabilities considered but as an example, let's take the well known Kelvin-Helmholtz instability. The dynamical equation for the system can be defined as the Boussinesq equation \begin{equation} \nabla\cdot\mathbf{u}=0 \end{equation} \begin{equation} \frac{d\mathbf{u}}{dt}=-\frac{1}{\rho}\nabla p + b \mathbf{n} + \nu_\mathbf{u} \Delta \mathbf{u} \end{equation} \begin{equation} \frac{d b}{dt}= \nu_{b} \Delta b \end{equation}
Where $\mathbf{u}=(u,v,w)$ is the velocity vector, $b$ is the buoyancy proportional to the temperature, $p$ is the pressure, $\frac{d~}{dt}$ is the lagrangian derivative, $\nu_\mathbf{u}$ is the kinematic viscosity, $\nu_{b}$ is the diffusion coefficient of buoyancy, $\Delta$ is the Laplacien operator and $\nabla$ is the gradient operator. The problem is define on $[0,Lx]\times[0,Ly]\times[0,Lz]$. The problem is $Lx$ periodic. $\mathbf{u}$ and $b$ are the computational variables. We initialize the field with \begin{equation} \mathbf{u}(\mathbf{x},t=0)=\mathbf{u}_B(\mathbf{x})+\mathbf{u}_P(\mathbf{x}) \end{equation} \begin{equation} b(\mathbf{x},t=0)=b_B(\mathbf{x})+b_P(\mathbf{x}) \end{equation} where $\mathbf{x}=(x,y,z)$ is the spacial coordonate, $t$ is the time coordinate, the sub-script $B$ is for the base state and the sub-script $P$ is for the perturbed field.
if $z>Lz/2$ then $u_B(\mathbf{x})=\alpha_1$ else $u_B(\mathbf{x})=\alpha_2$. if $z>Lz/2$ then $u_B(\mathbf{x})=\beta_1$ else $u_B(\mathbf{x})=\beta_2$. $v_B=0$ and $w_B=0$.
Numerically we add a perturbation $(\mathbf{u}_P,b_P)$ for accelerate the developmental of the instability. We expect the perturbed field to be Gaussian and negligible in front of the base state. By negligeable let's said $||(\mathbf{u}_P,b_P)||\approx 10^{-3}||(\mathbf{u}_B,b_B)||$. The flow is discretized on a regular structured grid.
How to implement properly the perturbed field $(\mathbf{u}_P,b_P)$ in the physical grid space ?