  Scalar field cosmologies with a generalized harmonic potential and matter
with energy density $\rho_m$, pressure $p_m$, and barotropic equation of state
(EoS) $p_m=(\gamma-1)\rho_m, \; \gamma\in[0,2]$ in Kantowski-Sachs (KS) and
closed Friedmann--Lema\^itre--Robertson--Walker (FLRW) metrics are
investigated. We use methods from non--linear dynamical systems theory and
averaging theory considering a time--dependent perturbation function $D$. We
define a regular dynamical system over a compact phase space, obtaining global
results. That is, for KS metric the global late--time attractors of full and
time--averaged systems are two anisotropic contracting solutions, which are
non--flat locally rotationally symmetric (LRS) Kasner and Taub (flat LRS
Kasner) for $0\leq \gamma \leq 2$, and flat FLRW matter--dominated universe if
$0\leq \gamma \leq \frac{2}{3}$. For closed FLRW metric late--time attractors
of full and averaged systems are a flat matter--dominated FLRW universe for
$0\leq \gamma \leq \frac{2}{3}$ as in KS and Einstein-de Sitter solution for
$0\leq\gamma<1$. Therefore, time--averaged system determines future asymptotics
of full system. Also, oscillations entering the system through Klein-Gordon
(KG) equation can be controlled and smoothed out when $D$ goes monotonically to
zero, and incidentally for the whole $D$-range for KS and for closed FLRW (if
$0\leq \gamma< 1$) too. However, for $\gamma\geq 1$ closed FLRW solutions of
the full system depart from the solutions of the averaged system as $D$ is
large. Our results are supported by numerical simulations.
