/// <summary> /// Selects multiple species by <see cref="IEnumerable<SpeciesId>"/>. /// </summary> /// <param name="SetOfSpecies"></param> /// <returns></returns> public SubBlockSelectorBase SpeciesSelector(IEnumerable <SpeciesId> SetOfSpecies) { //for (int v = 0; v < m_map.NoOfVariables; v++) { // if (this.m_map.AggBasis[v].GetType() == typeof(XdgAggregationBasis)) // Console.WriteLine("WARNING: Variable {0} has no XdgBasis and thus may be not selected",v); //} this.m_SpeciesFilter = delegate(int iCell, int iVar, int iSpec) { List <int> SpcInt = new List <int>(); foreach (SpeciesId spi in SetOfSpecies) { int SpcIdx = ((XdgAggregationBasis)this.m_map.AggBasis[iVar]).GetSpeciesIndex(iCell, spi); if (SpcIdx < 0) { continue; } SpcInt.Add(SpcIdx); } if (SpcInt.Count <= 0) { return(GetDoNothingInstruction()(iSpec)); } else { return(GetListInstruction(SpcInt)(iSpec)); } }; return(this); }
/// <summary> /// Selects Species by <see cref="SpeciesId"/>. /// </summary> /// <param name="Species"></param> /// <returns></returns> public SubBlockSelectorBase SpeciesSelector(SpeciesId SId) { this.m_SpeciesFilter = delegate(int iCell, int iVar, int iSpec) { if (this.m_map.AggBasis[iVar].GetType() != typeof(XdgAggregationBasis)) { throw new NotSupportedException("You tried to select a species within a non-xdg field!"); } int SpcIdx = ((XdgAggregationBasis)this.m_map.AggBasis[iVar]).GetSpeciesIndex(iCell, SId); if (SpcIdx < 0) { return(GetDoNothingInstruction()(iSpec)); } else { return(GetIntInstruction(SpcIdx)(iSpec)); } }; return(this); }