/// <summary> /// Factory method to get a new analysis model processor instance based on a given context. /// </summary> /// <param name="context">Model context</param> /// <returns>New instance of an analysis model processor.</returns> /// <exception cref="ArgumentNullException">If context is null.</exception> /// <exception cref="AnalysisModelContextNotSupportedException">If context is not supported.</exception> public static AnalysisModelProcessor GetAnalysisModelProcessor(IMgaModel context) { if (context == null) { throw new ArgumentNullException("context"); } AnalysisModelProcessor analysisModelProcessor = null; if (context.MetaBase.Name == typeof(CyPhy.ParametricExploration).Name) { analysisModelProcessor = new ParametricExplorationProcessor(CyPhyClasses.ParametricExploration.Cast(context)); } else if (context.MetaBase.Name == typeof(CyPhy.TestBenchSuite).Name) { analysisModelProcessor = new TestBenchSuiteProcessor(CyPhyClasses.TestBenchSuite.Cast(context)); } else if (TestBenchTypeProcessor.SupportedTestBenchTypes.Contains(context.MetaBase.Name)) { if (context.Meta.Name == typeof(CyPhy.CFDTestBench).Name) { string[] openFoamKinds = new string[] { typeof(CyPhy.CalmWaterSolverSettings).Name, typeof(CyPhy.CorrelationSettings).Name, typeof(CyPhy.WaveResistanceSolverSettings).Name }; if (context.ChildFCOs.Cast<MgaFCO>().Any(fco => openFoamKinds.Contains(fco.Meta.Name))) { analysisModelProcessor = new MultiJobRunProcessor(CyPhyClasses.CFDTestBench.Cast(context)); } else { analysisModelProcessor = new TestBenchTypeProcessor(CyPhyClasses.TestBenchType.Cast(context)); } } else if (context.Meta.Name == typeof(CyPhy.BlastTestBench).Name) { var blastTestBench = CyPhyClasses.BlastTestBench.Cast(context); int tierLevel = (int)blastTestBench.Attributes.BlastTier; int tierThresholdForMuliJobRun = (int)CyPhyClasses.BlastTestBench.AttributesClass.BlastTier_enum._2; if (tierLevel > tierThresholdForMuliJobRun) { // use MultiJobRunProcessor if the current tier level is greater than the defined threshold analysisModelProcessor = new MultiJobRunProcessor(blastTestBench); } else { analysisModelProcessor = new TestBenchTypeProcessor(blastTestBench); } } else if (context.Meta.Name == typeof(CyPhy.BallisticTestBench).Name) { var ballisticTestBench = CyPhyClasses.BallisticTestBench.Cast(context); int tierLevel = (int)ballisticTestBench.Attributes.Tier; int tierThresholdForMuliJobRun = (int)CyPhyClasses.BallisticTestBench.AttributesClass.Tier_enum._2; if (tierLevel > tierThresholdForMuliJobRun) { // use MultiJobRunProcessor if the current tier level is greater than the defined threshold analysisModelProcessor = new MultiJobRunProcessor(ballisticTestBench); } else { analysisModelProcessor = new TestBenchTypeProcessor(ballisticTestBench); } } else { // test bench type analysisModelProcessor = new TestBenchTypeProcessor(CyPhyClasses.TestBenchType.Cast(context)); } } else { throw new AnalysisModelContextNotSupportedException(string.Format("{0} does not supported", context.MetaBase.Name)); } analysisModelProcessor.OriginalCurrentFCOName = context.Name; return analysisModelProcessor; }
/// <summary> /// Factory method to get a new analysis model processor instance based on a given context. /// </summary> /// <param name="context">Model context</param> /// <returns>New instance of an analysis model processor.</returns> /// <exception cref="ArgumentNullException">If context is null.</exception> /// <exception cref="AnalysisModelContextNotSupportedException">If context is not supported.</exception> public static AnalysisModelProcessor GetAnalysisModelProcessor(IMgaModel context) { if (context == null) { throw new ArgumentNullException("context"); } AnalysisModelProcessor analysisModelProcessor = null; if (context.MetaBase.Name == typeof(CyPhy.ParametricExploration).Name) { analysisModelProcessor = new ParametricExplorationProcessor(CyPhyClasses.ParametricExploration.Cast(context)); } else if (context.MetaBase.Name == typeof(CyPhy.TestBenchSuite).Name) { analysisModelProcessor = new TestBenchSuiteProcessor(CyPhyClasses.TestBenchSuite.Cast(context)); } else if (TestBenchTypeProcessor.SupportedTestBenchTypes.Contains(context.MetaBase.Name)) { if (context.Meta.Name == typeof(CyPhy.CFDTestBench).Name) { string[] openFoamKinds = new string[] { typeof(CyPhy.CalmWaterSolverSettings).Name, typeof(CyPhy.CorrelationSettings).Name, typeof(CyPhy.WaveResistanceSolverSettings).Name }; if (context.ChildFCOs.Cast <MgaFCO>().Any(fco => openFoamKinds.Contains(fco.Meta.Name))) { analysisModelProcessor = new MultiJobRunProcessor(CyPhyClasses.CFDTestBench.Cast(context)); } else { analysisModelProcessor = new TestBenchTypeProcessor(CyPhyClasses.TestBenchType.Cast(context)); } } else if (context.Meta.Name == typeof(CyPhy.BlastTestBench).Name) { var blastTestBench = CyPhyClasses.BlastTestBench.Cast(context); int tierLevel = (int)blastTestBench.Attributes.BlastTier; int tierThresholdForMuliJobRun = (int)CyPhyClasses.BlastTestBench.AttributesClass.BlastTier_enum._2; if (tierLevel > tierThresholdForMuliJobRun) { // use MultiJobRunProcessor if the current tier level is greater than the defined threshold analysisModelProcessor = new MultiJobRunProcessor(blastTestBench); } else { analysisModelProcessor = new TestBenchTypeProcessor(blastTestBench); } } else if (context.Meta.Name == typeof(CyPhy.BallisticTestBench).Name) { var ballisticTestBench = CyPhyClasses.BallisticTestBench.Cast(context); int tierLevel = (int)ballisticTestBench.Attributes.Tier; int tierThresholdForMuliJobRun = (int)CyPhyClasses.BallisticTestBench.AttributesClass.Tier_enum._2; if (tierLevel > tierThresholdForMuliJobRun) { // use MultiJobRunProcessor if the current tier level is greater than the defined threshold analysisModelProcessor = new MultiJobRunProcessor(ballisticTestBench); } else { analysisModelProcessor = new TestBenchTypeProcessor(ballisticTestBench); } } else { // test bench type analysisModelProcessor = new TestBenchTypeProcessor(CyPhyClasses.TestBenchType.Cast(context)); } } else { throw new AnalysisModelContextNotSupportedException(string.Format("{0} does not supported", context.MetaBase.Name)); } analysisModelProcessor.OriginalCurrentFCOName = context.Name; return(analysisModelProcessor); }