/// <summary> /// Uses a <see cref="DataContractSerializer"/> to serialize the given /// <paramref name="config"/> /// </summary> /// <param name="fileName">The name of the file to be created</param> /// <param name="config">The configuration to be serialized</param> public static void Serialize(string fileName, FieldStateConfiguration config) { DataContractSerializer serializer = new DataContractSerializer(typeof(FieldStateConfiguration)); using (XmlWriter writer = XmlWriter.Create(fileName)) { serializer.WriteObject(writer, config); } }
/// <summary> /// Main entry point. Uses <see cref="PlotApplication"/> to plot all fields /// referenced in the config file supplied as a command line argument /// </summary> /// <param name="args"> /// Command line arguments. Currently, only the first entry is used /// which has to contain the path to the configuration file containing /// the plot information /// </param> static void Main(string[] args) { bool mustFinalizeMPI; var t = typeof(BoSSS.Application.Rheology.RheologyTimestepInfo); mustFinalizeMPI = BoSSS.Solution.Application.InitMPI(); csMPI.Raw.Comm_Rank(csMPI.Raw._COMM.WORLD, out rank); WriteLine(" --------------------------------------------"); WriteLine("| Process BoSSS.PlotGenerator.exe started |"); WriteLine("| Time: " + DateTime.Now.ToString() + " |"); WriteLine(" --------------------------------------------"); WriteLine(""); //Debugger.Break(); // path to the plotConfig.xml WriteLine("args[0]: " + args[0]); string outputPath = Path.GetDirectoryName(args[0]); // deserialize plotConfig.xml WriteLine("Reading plotConfig.xml ..."); FieldStateConfiguration config = FieldStateConfiguration.LoadConfig(args[0]); // In the next 5 lines of code you find all necessary data to create // plot files string[] basePaths = config.BasePaths; Guid sessionGuid = config.SessionGuid; FieldStateConfiguration.ExportFormats exportFormat = config.ExportFormat; List <string> fieldNameList = config.FieldNames; List <TimestepNumber> timeStepList = config.TimeSteps; // a few debug lines WriteLine("BasePaths[0] : " + basePaths[0]); WriteLine("SessionGuid : " + sessionGuid.ToString()); WriteLine("ExportFormat : " + exportFormat.ToString()); WriteLine("Count(FieldNames) : " + fieldNameList.Count.ToString()); WriteLine("Count(TimeSteps) : " + timeStepList.Count.ToString()); WriteLine("output to : " + outputPath); WriteLine("plotting..."); PlotApplication app = new PlotApplication(config, outputPath); app.Run(); csMPI.Raw.Barrier(csMPI.Raw._COMM.WORLD); if (mustFinalizeMPI) { BoSSS.Solution.Application.FinalizeMPI(); } }
/// <summary> /// Uses a <see cref="XmlSerializer"/> to de-serialize the content of a /// file with the name <paramref name="fileName"/>. /// </summary> /// <param name="fileName"></param> public static FieldStateConfiguration LoadConfig(string fileName) { if (File.Exists(fileName)) { return(FieldStateConfiguration.Deserialize(fileName)); } else { throw new ApplicationException("Could not find \"" + fileName + "\""); } }
/// <summary> /// Saves the <paramref name="config"/> and the <paramref name="path"/> /// and determines the reconstruction type (<see cref="m_showJumps"/>) and /// ghost level (<see cref="m_GhostZone"/>) /// from the <paramref name="config"/>. /// </summary> /// <param name="config">Configuration options</param> /// <param name="path">The output path</param> public PlotApplication(FieldStateConfiguration config, string path) { m_config = config; m_path = path; m_format = config.ExportFormat; switch (config.ReconstructionType) { case FieldStateConfiguration.ReconstructionTypes.None: m_showJumps = true; break; case FieldStateConfiguration.ReconstructionTypes.Average: m_showJumps = false; break; default: throw new ApplicationException("Unknown reconstruction type"); } switch (config.GhostLevel) { case FieldStateConfiguration.GhostLevels.One: m_GhostZone = true; break; case FieldStateConfiguration.GhostLevels.Zero: m_GhostZone = false; break; default: throw new ApplicationException("Unknown ghost level"); } m_Database = GetDatabase(); //init db-info this.GridDat = null; }
/// <summary> /// Basically compares this object to <paramref name="other"/> by /// comparing all public attributes for equality /// </summary> /// <param name="other">An object to be compared to</param> /// <returns> /// True, if all public attributes are equal; false otherwise /// </returns> public bool Equals(FieldStateConfiguration other) { int i; if (this.BasePaths.GetLength(0) != other.BasePaths.GetLength(0)) { return(false); } for (i = 0; i < this.BasePaths.GetLength(0); i++) { if (this.BasePaths[i].Equals(other.BasePaths[i]) == false) { return(false); } } if (this.SessionGuid.Equals(other.SessionGuid) == false) { return(false); } if (this.FieldNames.Count != other.FieldNames.Count) { return(false); } for (i = 0; i < this.FieldNames.Count; i++) { if (this.FieldNames[i].Equals(other.FieldNames[i]) == false) { return(false); } } if (this.TimeSteps.Count != other.TimeSteps.Count) { return(false); } for (i = 0; i < this.TimeSteps.Count; i++) { if (this.TimeSteps[i].Equals(other.TimeSteps[i]) == false) { return(false); } } if (this.ExportFormat.Equals(other.ExportFormat) == false) { return(false); } if (this.SuperSampling != other.SuperSampling) { return(false); } if (this.ReconstructionType.Equals(other.ReconstructionType) == false) { return(false); } if (this.GhostLevel.Equals(other.GhostLevel) == false) { return(false); } if (this.NumberOfProcesses.Equals(other.NumberOfProcesses) == false) { return(false); } return(true); }