Plants with perfect flowers can self fertilize by autogamy, in some species this is provided by growing a few cleistogamous (non-opening) flowers. Many species rely on this as a fall back, should cross fertilization fail at least there will be some seed set.
Cleistogamy or automatic self-pollination in a small, closed flower is cheap for the plant. There is no costly corolla, fragrance, or nectar to grow so the plant has fewer metabolic biosynthetic pathways to support. The fertilization is guaranteed so this makes a great backup flower to plants that produce opening flowers as well.
If the plant is growing on good soil in environments with good light it can favor growing large expensive chasmogamous (open) flowers with nectar to ensure cross fertilization, but if the plant is growing in poor soil &/or poor light it can still set some seed with cheap flowers and ensured self fertilization at the expense of cross fertilization.
In some species a late season growth of cleistogamous flowers can rescue a reproductive season with good early growth but little pollination because of pollinator loss. Regions with variable pollinators would favor plant species with cleistogamous late season flower set.
The advantage to producing a chasmogamous open flower with a costly pollination syndrome requiring nectar and self pollination barriers is just cross fertilization to increase genetic variation.
The disadvantage of cleistogamy is the offspring have limited genetic diversity. The advantage a selfing species enjoys is a twofold gene transmission by being both seed parent and pollen parent to its own seeds. This works well in species with weak selection against inbreeding depression.
Geitonogamy is pollination by a neighboring flower from the same plant. Monoecious plants like pines, maize and caster show geitonogamy. Geitonogamy is not possible for strictly dioecious plants. However it is common in animal pollinated plants with the pollinator visiting multiple flowers before leaving so it happens in both monoecious imperfect flowered plants and any plant with hermaphroditic/perfect flowers. Geitonogamy is a type of self fertilization with a slightly better introduction of genetic diversity than cleistogamy.
The nematode Caenorhabditis elegans contains two genders, self-fertilizing hermaphrodites and males. Hermaphrodites in C. elegans usually reproduce by internal self-fertilization, as fertilization by males is inefficient.