It is well known in psychology that repression is maladaptive psychologically.
Psychological repression, or simply repression, is the psychological attempt by an individual to repel one’s own desires and impulses towards pleasurable instincts by excluding the desire from one’s consciousness and holding or subduing it in the unconscious. Repression plays a major role in many mental illnesses, and in the psyche of average people
When one is flooded by sexual thoughts or arousal, one needs to combat them without repression. This means accepting sexual thoughts into consciousness. From a psychological framework, one also needs to remember and think about past sexual activity, and work through them. From a religious framework, we remember and think about the sinfulness of past illicit sexual activity and repent of them. Without bringing the repressed sexual memories into consciousness and confessing them, true repentance is not possible.
The enigma is that there are those in the Catholic Church who would say that sexual thoughts and memories are in themselves sinful.
Is it sinful to dwell on sexual thoughts and memories if for therapeutic purposes?