public HydrostaticsSolverSettings(CyPhy.HydrostaticsSolverSettings settings, CyPhy.CFDTestBench testBench) : base(settings, testBench) { FluidMaterial = (MaterialType)(int)settings.Attributes.FluidMaterial; FluidTemperature = settings.Attributes.FluidTemperature; RollAngleStart = settings.Attributes.RollAngleStart; RollAngleEnd = settings.Attributes.RollAngleEnd; RollAngleStep = settings.Attributes.RollAngleStepSize; PitchAngleStart = settings.Attributes.PitchAngleStart; PitchAngleEnd = settings.Attributes.PitchAngleEnd; PitchAngleStep = settings.Attributes.PitchAngleStepSize; }
public override void TraverseTestBench(CyPhy.TestBenchType testBenchBase) { // META-3195 - CFD needs Inventor format now instead of STL - Stereolithography_ASCII NonSTEP_DataExchangeFormats.Add("Inventor"); CyPhy.CFDTestBench testBench = testBenchBase as CyPhy.CFDTestBench; if (testBench == null) { testBench = CyPhyClasses.CFDTestBench.Cast(testBenchBase.Impl); } base.TraverseTestBench(testBenchBase); //AnalysisID = testBench.ID; foreach (var conn in testBench.Children.CFDComputation2MetricCollection) { TBComputation tbcomputation = new TBComputation(); tbcomputation.MetricID = conn.DstEnds.Metric.ID; tbcomputation.ComputationType = TBComputation.Type.COEFFICIENTOFDRAG; tbcomputation.RequestedValueType = "SCALAR"; Computations.Add(tbcomputation); } int calmSolverCnt = testBench.Children.CalmWaterSolverSettingsCollection.Count(); int waveSolverCnt = testBench.Children.WaveResistanceSolverSettingsCollection.Count(); int correlationSolverCnt = testBench.Children.CorrelationSettingsCollection.Count(); int hydrostaticsSolverCnt = testBench.Children.HydrostaticsSolverSettingsCollection.Count(); if ((calmSolverCnt + waveSolverCnt + correlationSolverCnt + hydrostaticsSolverCnt) < 1) { Logger.Instance.AddLogMessage("No CFD solver settings in the test bench", Severity.Error); return; } if (hydrostaticsSolverCnt > 1 || (calmSolverCnt + waveSolverCnt + correlationSolverCnt) > 1) { Logger.Instance.AddLogMessage( "Multiple CFD solver settings in the test bench", Severity.Error); Logger.Instance.AddLogMessage( "A test bench can only contain one hydrostatics and one calm, wave or correlation solver setting.", Severity.Info); return; } #region ValidAttributes double MinVelocity = 0; double MaxVelocity = 343; double AbsZero = -273.15; double MaxTemp = 100; double MinAngle = 0; double MaxAngle = 360; #endregion if (hydrostaticsSolverCnt == 1) { CyPhy.HydrostaticsSolverSettings solverSettings = testBench.Children.HydrostaticsSolverSettingsCollection.First(); if (solverSettings.Attributes.FluidTemperature < AbsZero || solverSettings.Attributes.FluidTemperature > MaxTemp) { string message = string.Format( "'{0}': 'FluidTemperature' attribute must be [{1} - {2}]", solverSettings.Name, AbsZero, MaxTemp); Logger.Instance.AddLogMessage( message, Severity.Error); } if (solverSettings.Attributes.PitchAngleStart < MinAngle || solverSettings.Attributes.PitchAngleStart > MaxAngle || solverSettings.Attributes.PitchAngleEnd < MinAngle || solverSettings.Attributes.PitchAngleEnd > MaxAngle || solverSettings.Attributes.RollAngleStart < MinAngle || solverSettings.Attributes.RollAngleStart > MaxAngle || solverSettings.Attributes.RollAngleEnd < MinAngle || solverSettings.Attributes.RollAngleEnd > MaxAngle || solverSettings.Attributes.PitchAngleStepSize < MinAngle || solverSettings.Attributes.PitchAngleStepSize > MaxAngle || solverSettings.Attributes.RollAngleStepSize < MinAngle || solverSettings.Attributes.RollAngleStepSize > MaxAngle) { string message = string.Format( "'{0}': 'Angle' attributes must be [{1}-{2}]", solverSettings.Name, MinAngle, MaxAngle); Logger.Instance.AddLogMessage( message, Severity.Error); } cfdConfigs.Add(new CFDConfig.HydrostaticsSolverSettings(solverSettings, testBench)); } if (calmSolverCnt == 1) { CyPhy.CalmWaterSolverSettings solverSettings = testBench.Children.CalmWaterSolverSettingsCollection.First(); if (solverSettings.Attributes.VehicleVelocity > MaxVelocity || solverSettings.Attributes.VehicleVelocity < MinVelocity) { string message = string.Format( "'{0}': 'Velocity' attribute must be [{1}-{2}]", solverSettings.Name, MinVelocity, MaxVelocity); Logger.Instance.AddLogMessage( message, Severity.Error); } if (solverSettings.Attributes.FluidTemperature < AbsZero || solverSettings.Attributes.FluidTemperature > MaxTemp) { string message = string.Format( "'{0}': 'FluidTemperature' attribute must be [{1} - {2}]", solverSettings.Name, AbsZero, MaxTemp); Logger.Instance.AddLogMessage( message, Severity.Error); } cfdConfigs.Add(new CFDConfig.CalmWaterSolverSettings(solverSettings, testBench)); return; } if (waveSolverCnt == 1) { CyPhy.WaveResistanceSolverSettings solverSettings = testBench.Children.WaveResistanceSolverSettingsCollection.First(); if (solverSettings.Attributes.VehicleVelocity > MaxVelocity || solverSettings.Attributes.VehicleVelocity < MinVelocity) { string message = string.Format( "'{0}': 'Velocity' attribute must be [{1}-{2}]", solverSettings.Name, MinVelocity, MaxVelocity); Logger.Instance.AddLogMessage( message, Severity.Error); } if (solverSettings.Attributes.FluidTemperature < AbsZero || solverSettings.Attributes.FluidTemperature > MaxTemp) { string message = string.Format( "'{0}': 'FluidTemperature' attribute must be [{1} - {2}]", solverSettings.Name, AbsZero, MaxTemp); Logger.Instance.AddLogMessage( message, Severity.Error); } if (solverSettings.Attributes.WaveFrequency < 0) { string message = string.Format( "'{0}': 'WaveFrequency' attribute must be greater than 0", solverSettings.Name); Logger.Instance.AddLogMessage( message, Severity.Error); } if (solverSettings.Attributes.WaveDirection < MinAngle || solverSettings.Attributes.WaveDirection > MaxAngle) { string message = string.Format( "'{0}': 'Angle' attributes must be [{1}-{2}]", solverSettings.Name, MinAngle, MaxAngle); Logger.Instance.AddLogMessage( message, Severity.Error); } cfdConfigs.Add(new CFDConfig.WaveResistanceSolverSettings(solverSettings, testBench)); return; } if (correlationSolverCnt == 1) { CyPhy.CorrelationSettings solverSettings = testBench.Children.CorrelationSettingsCollection.First(); if (solverSettings.Attributes.VehicleVelocity > MaxVelocity || solverSettings.Attributes.VehicleVelocity < 0) { string message = string.Format( "'{0}': 'Velocity' attribute must be [{1}-{2}]", solverSettings.Name, MinVelocity, MaxVelocity); Logger.Instance.AddLogMessage( message, Severity.Error); } cfdConfigs.Add(new CFDConfig.CorrelationSolverSettings(solverSettings, testBench)); return; } // Post Processing Blocks foreach (var postprocess in testBench.Children.PostProcessingCollection) { PostProcessScripts.Add(postprocess.Attributes.ScriptPath); } }