Consider a single quadrilaterally-faced hexahedron. If given the co-ordinates of the vertices, $\mathbf{v}_i$, of a face in counter-clockwise orientation, I can compute the corresponding unit outward normal vector using a cross-product:
$\mathbf{n}=\frac{(\mathbf{v}_2-\mathbf{v}_1)\times(\mathbf{v}_4-\mathbf{v}_1)}{\parallel(\mathbf{v}_2-\mathbf{v}_1)\times(\mathbf{v}_4-\mathbf{v}_1)\parallel}$
However, consider now an arbitrarily shaped volume which is discretised into a large number of quadrilaterally-faced hexahedra. Consider in particular a face shared by two adjacent hexahedra. If now given the co-ordinates of the vertices of the face in a certain orientation, the orientation will be clockwise for one hexahedron and counter-clockwise for the other.
If I do not know the orientation beforehand, how can I ensure that the unit normal is pointing outwards (assuming you know the co-ordinates of all vertices of all faces of all hexehedra)?
you can computee the dot product between the normal and the vector:
[center of element, center of the current face].
If it's > 0, the normal is outwards to the element.
If not, it's inward and you just have to do : normal = -normal, to change that