Use of variational methods in constructing models of continuous media with irreversible processes in the special theory of relativity