/**
 * Count value offsets for each member domain in a CompositeDomain.
 */
void
MultiDomainFunction::countValueOffsets(const CompositeDomain &domain) const {
  m_valueOffsets.clear();
  m_valueOffsets.push_back(0);
  for (size_t i = 0; i < domain.getNParts(); ++i) {
    const FunctionDomain &d = domain.getDomain(i);
    m_valueOffsets.push_back(m_valueOffsets.back() + d.size());
  }
}
 /**
  * Populates a vector with domain indices assigned to function i.
  */
 void MultiDomainFunction::getFunctionDomains(size_t i, const CompositeDomain& cd, std::vector<size_t>& domains)const
 {
     auto it = m_domains.find(i);
     if (it == m_domains.end())
     {// apply to all domains
       domains.resize(cd.getNParts());
       for(size_t i = 0; i < domains.size(); ++i)
       {
         domains[i] = i;
       }
     }
     else
     {// apply to selected domains
       domains.assign(it->second.begin(),it->second.end());
     }
 }