How to find associated energy functional for a given PDE let $U\subseteq\mathbb{R}^n$ be open and bounded and here we have 
$-\sum_{i,j=1}^{n}D_i(a_{ij}D_ju)=g(x)$, for $x\in U\subseteq\mathbb{R}^n$ 
If we assume that $u$ is smooth, $a_{ij}$ and $g$ are continuous and also assume that $a_{ij}(x)=a_{ji}(x)$ for all $x\in U$ and $1\leq i,j\leq n$
How can I find the associated energy functional?  
My attempt is that multiply both side by $u$ and then using partial integration
$\int_{U}u\nabla\sum_{j=1}^na_{ij}(x)D_ju\mbox{ }dx=\int_{\partial U}\sum_{j=1}^na_{ij}(x)D_ju\cdot u\cdot\hat n\mbox{ }dx-\int_U\sum_{j=1}^na_{ij}(x)D_ju\cdot\nabla u\mbox{ }dx=\int_{U}g(x)u\mbox{ }dx$
But I really don't know how to continue.

consider $L(p,z,x)=\frac{1}{2}\cdot\sum_{i,j=1}^{n}a_{ij}(x)p_ip_j-zg(x)$ 
then we have $L_{p_i}=\sum_{j=1}^{n}a_{ij}(x)p_j$ for $i=1,\ldots,n$ and $L_z=-g(x)$. 
Hence the associated E-L equation is that
$I[w]=\int_{U}\frac{1}{2}\cdot\sum_{i,j=1}^{n}a_{ij}w_{x_i}w_{x_j}-wgdx$ 
therefore the PDE is that $-\sum_{i,j=1}^{n}(a_{ij}(x)u_{x_j})_{x_i}=g$ in $U$ 
which is also $-\sum_{i,j=1}^{n}D_i(a_{ij}(x)D_ju)=g(x)$
