< Summary

Information
Class: Morpho25.IO.Simx
Assembly: Morpho25
File(s): D:\a\Morpho\Morpho\project\Morpho\Morpho25\IO\Simx.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 165
Coverable lines: 165
Total lines: 287
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 50
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
get_MainSettings()100%10%
get_SimpleForcing()100%10%
get_TThread()100%10%
get_TimeSteps()100%10%
get_ModelTiming()100%10%
get_SoilSettings()100%10%
get_Sources()100%10%
get_Turbulence()100%10%
get_OutputSettings()100%10%
get_Cloud()100%10%
get_Background()100%10%
get_SolarAdjust()100%10%
get_BuildingSettings()100%10%
get_RadScheme()100%10%
get_ParallelCPU()100%10%
get_SOR()100%10%
get_InflowAvg()100%10%
get_Facades()100%10%
get_PlantSetting()100%10%
get_LBC()100%10%
get_FullForcing()100%10%
.ctor(...)100%10%
WriteSimx()0%500%

File(s)

D:\a\Morpho\Morpho\project\Morpho\Morpho25\IO\Simx.cs

#LineLine coverage
 1using Morpho25.Settings;
 2using Morpho25.Utility;
 3using System;
 4using System.IO;
 5using System.Text;
 6using System.Xml;
 7
 8
 9namespace Morpho25.IO
 10{
 11    /// <summary>
 12    /// Simulation definition class.
 13    /// </summary>
 14    public class Simx
 15    {
 16        /// <summary>
 17        /// New line.
 18        /// </summary>
 19        public const string NEWLINE = "\n";
 20        /// <summary>
 21        /// Main settings.
 22        /// </summary>
 023        public MainSettings MainSettings { get; }
 24        /// <summary>
 25        /// Simple forcing settings.
 26        /// </summary>
 027        public SimpleForcing SimpleForcing { get; set; }
 28        /// <summary>
 29        /// Thread settings.
 30        /// </summary>
 031        public TThread TThread { get; set; }
 32        /// <summary>
 33        /// Time step definition.
 34        /// </summary>
 035        public TimeSteps TimeSteps { get; set; }
 36        /// <summary>
 37        /// Timing settings.
 38        /// </summary>
 039        public ModelTiming ModelTiming { get; set; }
 40        /// <summary>
 41        /// Soil settings.
 42        /// </summary>
 043        public SoilSettings SoilSettings { get; set; }
 44        /// <summary>
 45        /// Source settings.
 46        /// </summary>
 047        public Sources Sources { get; set; }
 48        /// <summary>
 49        /// Turbolence settings.
 50        /// </summary>
 051        public Turbulence Turbulence { get; set; }
 52        /// <summary>
 53        /// Output settings.
 54        /// </summary>
 055        public OutputSettings OutputSettings { get; set; }
 56        /// <summary>
 57        /// Cloudiness settings.
 58        /// </summary>
 059        public Cloud Cloud { get; set; }
 60        /// <summary>
 61        /// Background settings.
 62        /// </summary>
 063        public Background Background { get; set; }
 64        /// <summary>
 65        /// Sun settings.
 66        /// </summary>
 067        public SolarAdjust SolarAdjust { get; set; }
 68        /// <summary>
 69        /// Building settings.
 70        /// </summary>
 071        public BuildingSettings BuildingSettings { get; set; }
 72        /// <summary>
 73        /// Radiation settings.
 74        /// </summary>
 075        public RadScheme RadScheme { get; set; }
 76        /// <summary>
 77        /// Parallel CPU settings.
 78        /// </summary>
 079        public ParallelCPU ParallelCPU { get; set; }
 80        /// <summary>
 81        /// SOR settings.
 82        /// </summary>
 083        public SOR SOR { get; set; }
 84        /// <summary>
 85        /// Flow settings.
 86        /// </summary>
 087        public InflowAvg InflowAvg { get; set; }
 88        /// <summary>
 89        /// Facades.
 90        /// </summary>
 091        public Facades Facades { get; set; }
 92        /// <summary>
 93        /// Plant settings.
 94        /// </summary>
 095        public PlantSetting PlantSetting { get; set; }
 96        /// <summary>
 97        /// Lateral boundary condition.
 98        /// </summary>
 099        public LBC LBC { get; set; }
 100        /// <summary>
 101        /// Full forcing settings.
 102        /// </summary>
 0103        public FullForcing FullForcing { get; set; }
 104        /// <summary>
 105        /// Create a simulation definition.
 106        /// </summary>
 107        /// <param name="mainSettings">Main settings.</param>
 0108        public Simx(MainSettings mainSettings)
 0109        {
 0110            MainSettings = mainSettings;
 0111            SimpleForcing = null;
 0112            TThread = null;
 0113            TimeSteps = null;
 0114            ModelTiming = null;
 0115            SoilSettings = null;
 0116            Sources = null;
 0117            Turbulence = null;
 0118            OutputSettings = null;
 0119            Cloud = null;
 0120            Background = null;
 0121            SolarAdjust = null;
 0122            BuildingSettings = null;
 0123            RadScheme = null;
 0124            SOR = null;
 0125            InflowAvg = null;
 0126            Facades = null;
 0127            PlantSetting = null;
 0128            LBC = null;
 0129            FullForcing = null;
 0130        }
 131        /// <summary>
 132        /// Write simulation file.
 133        /// </summary>
 134        public void WriteSimx()
 0135        {
 0136            var now = DateTime.Now;
 0137            string revisionDate = now.ToString("yyyy-MM-dd HH:mm:ss");
 0138            string filePath = Path.Combine(MainSettings
 0139                .Inx.Workspace.ProjectFolder, MainSettings.Name + ".simx");
 0140            string[] empty = { };
 141
 0142            XmlTextWriter xWriter = new XmlTextWriter(filePath, Encoding.UTF8);
 0143            xWriter.WriteStartElement("ENVI-MET_Datafile");
 0144            xWriter.WriteString(NEWLINE);
 145
 146            // Header section
 0147            string headerTitle = "Header";
 0148            string[] headerTag = new string[] { "filetype", "version",
 0149                "revisiondate", "remark", "encryptionlevel" };
 0150            string[] headerValue = new string[] { "SIMX", "2",
 0151                revisionDate, "Created with lb_envimet", "0" };
 152
 0153            Util.CreateXmlSection(xWriter, headerTitle,
 0154                headerTag, headerValue, 0, empty);
 155
 156            // Main section
 0157            Util.CreateXmlSection(xWriter, MainSettings.Title,
 0158                MainSettings.Tags, MainSettings.Values, 0, empty);
 159
 160            // First Meteorology
 0161            if (SimpleForcing != null && FullForcing == null)
 0162            {
 0163                Util.CreateXmlSection(xWriter, SimpleForcing.Title,
 0164                    SimpleForcing.Tags, SimpleForcing.Values, 0, empty);
 0165            }
 166
 0167            if (TThread != null)
 0168            {
 0169                Util.CreateXmlSection(xWriter, TThread.Title,
 0170                    TThread.Tags, TThread.Values, 0, empty);
 0171            }
 172
 0173            if (ModelTiming != null)
 0174            {
 0175                Util.CreateXmlSection(xWriter, ModelTiming.Title,
 0176                    ModelTiming.Tags, ModelTiming.Values, 0, empty);
 0177            }
 178
 0179            if (SoilSettings != null)
 0180            {
 0181                Util.CreateXmlSection(xWriter, SoilSettings.Title,
 0182                    SoilSettings.Tags, SoilSettings.Values, 0, empty);
 0183            }
 184
 0185            if (Sources != null)
 0186            {
 0187                Util.CreateXmlSection(xWriter, Sources.Title,
 0188                    Sources.Tags, Sources.Values, 0, empty);
 0189            }
 190
 0191            if (Turbulence != null)
 0192            {
 0193                Util.CreateXmlSection(xWriter, Turbulence.Title,
 0194                    Turbulence.Tags, Turbulence.Values, 0, empty);
 0195            }
 196
 0197            if (TimeSteps != null)
 0198            {
 0199                Util.CreateXmlSection(xWriter, TimeSteps.Title,
 0200                    TimeSteps.Tags, TimeSteps.Values, 0, empty);
 0201            }
 202
 0203            if (OutputSettings != null)
 0204            {
 0205                Util.CreateXmlSection(xWriter, OutputSettings.Title,
 0206                    OutputSettings.Tags, OutputSettings.Values, 0, empty);
 0207            }
 208
 0209            if (Cloud != null && FullForcing == null)
 0210            {
 0211                Util.CreateXmlSection(xWriter, Cloud.Title,
 0212                    Cloud.Tags, Cloud.Values, 0, empty);
 0213            }
 214
 0215            if (Background != null)
 0216            {
 0217                Util.CreateXmlSection(xWriter, Background.Title,
 0218                    Background.Tags, Background.Values, 0, empty);
 0219            }
 220
 0221            if (SolarAdjust != null && FullForcing == null)
 0222            {
 0223                Util.CreateXmlSection(xWriter, SolarAdjust.Title,
 0224                    SolarAdjust.Tags, SolarAdjust.Values, 0, empty);
 0225            }
 226
 0227            if (BuildingSettings != null)
 0228            {
 0229                Util.CreateXmlSection(xWriter, BuildingSettings.Title,
 0230                    BuildingSettings.Tags, BuildingSettings.Values, 0, empty);
 0231            }
 232
 0233            if (RadScheme != null)
 0234            {
 0235                Util.CreateXmlSection(xWriter, RadScheme.Title,
 0236                    RadScheme.Tags, RadScheme.Values, 0, empty);
 0237            }
 238
 0239            if (ParallelCPU != null)
 0240            {
 0241                Util.CreateXmlSection(xWriter, ParallelCPU.Title,
 0242                    ParallelCPU.Tags, ParallelCPU.Values, 0, empty);
 0243            }
 244
 0245            if (SOR != null)
 0246            {
 0247                Util.CreateXmlSection(xWriter, SOR.Title,
 0248                    SOR.Tags, SOR.Values, 0, empty);
 0249            }
 250
 0251            if (InflowAvg != null)
 0252            {
 0253                Util.CreateXmlSection(xWriter, InflowAvg.Title,
 0254                    InflowAvg.Tags, InflowAvg.Values, 0, empty);
 0255            }
 256
 0257            if (PlantSetting != null)
 0258            {
 0259                Util.CreateXmlSection(xWriter, PlantSetting.Title,
 0260                    PlantSetting.Tags, PlantSetting.Values, 0, empty);
 0261            }
 262
 0263            if (Facades != null)
 0264            {
 0265                Util.CreateXmlSection(xWriter, Facades.Title,
 0266                    Facades.Tags, Facades.Values, 0, empty);
 0267            }
 268
 269            // Third Meteorology
 0270            if (LBC != null && (SimpleForcing == null || FullForcing == null))
 0271            {
 0272                Util.CreateXmlSection(xWriter, LBC.Title,
 0273                    LBC.Tags, LBC.Values, 0, empty);
 0274            }
 275
 276            // Second Meteorology
 0277            if (FullForcing != null)
 0278            {
 0279                Util.CreateXmlSection(xWriter, FullForcing.Title,
 0280                    FullForcing.Tags, FullForcing.Values, 0, empty);
 0281            }
 282
 0283            xWriter.WriteEndElement();
 0284            xWriter.Close();
 0285        }
 286    }
 287}