Throughout Parshas Noach, the name of Hashem appears in two different forms. In the sixth Perek (of Sefer Bereishis), the name Elokim is used exclusively, while in the seventh Perek, the name Yud-Kay-Vov-Kay and Elokim both appear, and seem to be interchangeable. A closer analysis, however, reveals that the usage of these different names follows a very rational pattern and in fact reveals how Hashem operates during each faze of His interaction with Noach.
The term Elokim denotes "justice" and "strength". The term Yud-Kay-Vov-Kay denotes Hashem's very essence, which includes the attributes of mercy and kindness. It is very fitting that the sixth Perek should use the word Elokim since it describes Hashem's disappointment with man's behavior. The decision to destroy the world is motivated by the attribute of justice. Even the commandment to build the ark and the decision to spare mankind from extinction by saving Noach is an expression of justice and therefore requires the Midah denoted by the name Elokim.
In the seventh Perek, Hashem addresses Noach directly and invites him to enter the ark. This clearly indicates the Midah of kindness and mercy towards Noach. As far as Noach himself is concerned, the sparing of his life has no cosmic significance; he thus views the saving of his life as an act of mercy symbolized by the name Yud-Kay-Vov-Kay. In the same Perek, however, when Noach and his family and the various animals enter the ark, that action becomes part of the greater plan of Hashem to both destroy and spare the universe. This explains the most blatant Posuk where both of these attributes of Hashem can be seen. The Torah says "כאשר צוה אתו אלקים", "As Elokim commanded," but then says, "ויסגר י-ק-ו-ק בעדו", "And Yud-Kay-Vov-Kay closed (the ark) on his behalf (בראשית ז:ט"ז). When it comes to saving the universe, it is Elokim who determines who shall live and who shall die. When dealing with Noach on a personal level, though, it is the attribute of mercy symbolized by the Yud-Kay-Vov-Kay that prevails.
This pattern of usage of Hashem's names in Parshas Noach reflects the pattern used throughout Sefer Bereishis, and a close analysis of this can make certain stories in the Torah much more understandable.