Thermodynamics of Deformable Dielectrics with a non-Euclidean Structure as Internal Variable