To get an array of groups the currently logged in user belong to, you can use the following:
$user = JFactory::getUser();
$groups = JAccess::getGroupsByUser($user->id);
var_dump($groups);
To get the names of these groups, you can run a database query (add after the code above)
$user = JFactory::getUser();
$groups = JAccess::getGroupsByUser($user->id);
$groups_list = '(' . implode(',', $groups) . ')';
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->qn('title'))
->from('#__usergroups')
->where($db->qn('id') . ' IN ' . $groups_list);
$db->setQuery($query);
$rows = $db->loadObjectList();
var_dump($rows);
To get the user's access levels, you can use the following:
$user = JFactory::getUser();
$levels = JAccess::getAuthorisedViewLevels($user->id);
var_dump($levels);