public void AddADUserOutput(Mike1DData mike1DData, IDiagnostics diagnostics) { ResultSpecification adUserResSpec = mike1DData.GetDefaultResultSpecification(ResultSpecificationTypes.AD); adUserResSpec.ID = "ADUserOutput"; // How often to store adUserResSpec.StoringFrequencyType = StoringFrequencyUnitTypes.Minutes; adUserResSpec.StoringFrequency = 15; // Where to store the file adUserResSpec.Connection.FilePath = new FilePath(mike1DData.Id + mike1DData.ScenarioId + "UserAD.res1d"); // What to store ADComponent adComp = mike1DData.ADComponentData.Components.Find(comp => comp.Id == "Spill"); if (adComp == null) { diagnostics.Error(new DiagnosticItem("Could not find AD component with Id: Spill")); return; } // Mass transport of "Spill" AD component // IQuantity massTransport = ADComponentQuantities.FaceTransport(adComp.Quantity); // For Release 2019 (17.0), this works IQuantity massTransport = ADComponentQuantities.Create(adComp, PredefinedQuantityAD.Transport); // For later releases (>17.0), this is recommended adUserResSpec.What.Add(massTransport); // Which data in the network to store var spatialFilter = new Res1DNetworkFilter(); // Links, output at all grid points spatialFilter.AddGlobalReachValue("Link_1", true); spatialFilter.AddGlobalReachValue("Link_2", true); // Links, output at inflow to link only spatialFilter.AddGlobalReachValue("Link_3", Res1DSpatialFilterTypeEnum.First); spatialFilter.AddGlobalReachValue("Link_4", Res1DSpatialFilterTypeEnum.First); // Weirs spatialFilter.AddGlobalReachValue("Weir:Weir_1", true); spatialFilter.AddGlobalReachValue("Weir:Weir_2", true); // Set filter for specific quantity or for all quantities //adUserResSpec.SetFilter(massTransport, spatialFilter); adUserResSpec.DefaultFilter = spatialFilter; // Add to list of result files mike1DData.ResultSpecifications.Add(adUserResSpec); }
/// <summary> /// Read file header /// </summary> public void ReadHeader(IDiagnostics diagnostics) { _diagnostics = diagnostics; OpenFile(); string line; // SWMM5 Interface File line = ReadLine(); if (!line.Equals("SWMM5 Interface File", StringComparison.OrdinalIgnoreCase)) { _diagnostics.Error(new DiagnosticItem(string.Format("Could no read SWMM5 Interface File: {0}: This files seems not to be a SWMM5 Interface File (missing initial header line)", Connection.FilePath.Path))); } // This is from the 1st line of the SWMM5 Model in the Title/Notes Section of the Data line = ReadLine(); // reporting time step in sec line = ReadLine(); double timeStepSec = ParseDouble(line.Split('-')[0].Trim()); // Quantities/constituents header line // number of constituents as listed below: line = ReadLine(); int numConstituents = ParseInt(line.Split('-')[0].Trim()); // The first one will always be flow, the following ones will be pollutants. List <Quantity> quantities = new List <Quantity>(numConstituents); for (int i = 0; i < numConstituents; i++) { line = ReadLine(); // In case there is a space in the pollutant name, we cannot use the line.split(' ') directly string[] parts = new string[2]; int splitIndex = line.LastIndexOf(' '); parts[0] = line.Substring(0, splitIndex).Trim(); parts[1] = line.Substring(splitIndex).Trim(); Quantity quantity; if (parts[0].Equals("FLOW", StringComparison.OrdinalIgnoreCase)) { if (_asRR) { // This is actually the outlet node flow - but we are using it as runoff here quantity = new Quantity("TotalRunOff", "Total Runoff", eumItem.eumIDischarge); } else { quantity = Quantity.Create(PredefinedQuantity.DischargeOutflow); } } else { quantity = new Quantity(parts[0], parts[0], eumItem.eumIConcentration); } if (parts[1] == "MGD") { quantity.EumQuantity.Unit = eumUnit.eumUMgalPerDay; } if (parts[1] == "CFS") { quantity.EumQuantity.Unit = eumUnit.eumUft3PerSec; } if (parts[1] == "GPM") { quantity.EumQuantity.Unit = eumUnit.eumUGalPerMin; } if (parts[1] == "MGD") { quantity.EumQuantity.Unit = eumUnit.eumUMgalPerDay; } if (parts[1] == "CMS") { quantity.EumQuantity.Unit = eumUnit.eumUm3PerSec; } if (parts[1] == "LPS") { quantity.EumQuantity.Unit = eumUnit.eumUliterPerSec; } if (parts[1] == "LPD") { quantity.EumQuantity.Unit = eumUnit.eumUliterPerDay; } if (parts[1] == "MG/L") { quantity.EumQuantity.Unit = eumUnit.eumUmilliGramPerL; } if (parts[1] == "UG/L") { quantity.EumQuantity.Unit = eumUnit.eumUmicroGramPerL; } if (parts[1] == "#/L") { quantity.EumQuantity.Unit = eumUnit.eumUperLiter; quantity.EumQuantity.Item = eumItem.eumIBacteriaConc; } // could also be eumItem.eumICountsPerLiter quantities.Add(quantity); } // Catchments header line // number of nodes as listed below: line = ReadLine(); int numNodes = ParseInt(line.Split('-')[0].Trim()); for (int i = 0; i < numNodes; i++) { line = ReadLine(); string nodeId = line.Trim(); IRes1DDataSet dataSet; ItemTypeGroup itemTypeGroup; if (_asRR) { Res1DCatchment catchment = new Res1DCatchment { Id = nodeId, Shape = ElementSetDefinition.CreateIdElementSet(nodeId), }; _resultData.Catchments.Add(catchment); dataSet = catchment; itemTypeGroup = ItemTypeGroup.CatchmentItem; } else { Res1DNode node = new Res1DOutlet() { Id = nodeId, }; _resultData.Nodes.Add(node); dataSet = node; itemTypeGroup = ItemTypeGroup.NodeItem; } for (int j = 0; j < quantities.Count; j++) { DataItem dataItem = new DataItem(false) { ItemTypeGroup = itemTypeGroup, NumberWithinGroup = i, Quantity = quantities[j] }; dataSet.DataItems.Add(dataItem); } } }
public void Error(string message) { diag.Error(token.Line, token.Column, message); }