Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADSECGH-101: Update serviceability result component #137

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
edd5aec
feat(SlsResulFunction.cs): add function class for SLS result component
SandeepArup Mar 10, 2025
75217d7
feat(ResultsSLS.cs): component migrated to use new approach
SandeepArup Mar 11, 2025
72ac17d
feat(SlsResultFunctionTest): test for SLS results
SandeepArup Mar 11, 2025
6b04a35
Merge branch 'main' into task/ADSECGH-101
SandeepArup Mar 11, 2025
4e0e1b5
test(ResultsSLS.cs): code refactored and test added
SandeepArup Mar 11, 2025
e6af288
Merge branch 'main' into task/ADSECGH-101
SandeepArup Mar 11, 2025
256185a
fix(SlsResultFunction): file name corrected
SandeepArup Mar 12, 2025
2cfceab
Merge branch 'task/ADSECGH-101' of github.com:arup-group/AdSec-Grassh…
SandeepArup Mar 12, 2025
92cef00
fix(SlsResultFunctionTests.cs): make file name singular
SandeepArup Mar 12, 2025
9bec26a
refactor(IFunction): remove abbreviation related function
SandeepArup Mar 12, 2025
0527283
fix(SlsResultFunction): update function to use correct unit
SandeepArup Mar 12, 2025
edf3463
refactor(ComponentAdapter): Refactor code to refresh component
SandeepArup Mar 12, 2025
ba26520
test(SlsResultTests): test that units refresh correctly
SandeepArup Mar 12, 2025
1bf429e
refactor(ComponentAdapter): include case when nick name has been changed
SandeepArup Mar 12, 2025
e02cc9b
refactor(ResultsSLS.cs): refactor to update parameter on pre-solve in…
SandeepArup Mar 13, 2025
1a7658f
refactor(SlsResultTests): test modified and code refactored to update…
SandeepArup Mar 13, 2025
65a7d1f
refactor(IFunction): remove unused code
SandeepArup Mar 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions AdSecCore/Functions/IFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public interface IFunction {

public abstract class Function : IFunction {
public List<string> WarningMessages { get; set; } = new List<string>();
public List<string> RemarkMessages { get; set; } = new List<string>();
public List<string> ErrorMessages { get; set; } = new List<string>();
public abstract FuncAttribute Metadata { get; set; }
public abstract Organisation Organisation { get; set; }
public virtual Attribute[] GetAllInputAttributes() { return Array.Empty<Attribute>(); }
Expand Down
9 changes: 8 additions & 1 deletion AdSecCore/Functions/ParametersGeneric.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Oasys.AdSec;
using System;

using Oasys.AdSec;
using Oasys.AdSec.DesignCode;
using Oasys.AdSec.Mesh;
using Oasys.Profiles;
Expand Down Expand Up @@ -53,6 +55,11 @@ public class LoadSurfaceParameter : ParameterAttribute<ILoadSurface> { }
public class IntegerParameter : ParameterAttribute<int> { }
public class LoadParameter : ParameterAttribute<ILoad> { }
public class CrackParameter : ParameterAttribute<ICrack> { }
public class DeformationParameter : ParameterAttribute<IDeformation> { }
public class LoadGenericParameter : ParameterAttribute<object> { }
public class CrackArrayParameter : BaseArrayParameter<ICrack> { }
public class SecantStiffnessParameter : ParameterAttribute<IStiffness> { }
public class IntervalArrayParameter : BaseArrayParameter<Tuple<double, double>> { }


}
188 changes: 188 additions & 0 deletions AdSecCore/Functions/SlsResulFunction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@

using System;
using System.Collections.Generic;
using System.Linq;

using AdSecGHCore.Constants;

using Oasys.AdSec;

using OasysUnits;
using OasysUnits.Units;

namespace AdSecCore.Functions {
public class SlsResultFunction : Function {

public SectionSolutionParameter SolutionInput { get; set; } = new SectionSolutionParameter {
Name = "Results",
NickName = "Res",
Description = "AdSec Results to perform serviceability check",
Access = Access.Item,
Optional = false,
};

Check warning on line 22 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L16-L22

Added lines #L16 - L22 were not covered by tests

public LoadGenericParameter LoadInput { get; set; } = new LoadGenericParameter {
Name = "Load",
NickName = "Ld",
Description = "AdSec Load (Load or Deformation) for which the strength results are to be calculated.",
Access = Access.Item,
Optional = false,
};

Check warning on line 30 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L24-L30

Added lines #L24 - L30 were not covered by tests

public LoadParameter LoadOutput { get; set; } = new LoadParameter {
Name = "Load",
NickName = "Ld",
Description = $"The section load under the applied action.{Environment.NewLine}If the applied deformation is outside the capacity range of the section, the returned load will be zero.",
Access = Access.Item,
Optional = false,
};

Check warning on line 38 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L32-L38

Added lines #L32 - L38 were not covered by tests

public CrackArrayParameter CrackOutput { get; set; } = new CrackArrayParameter {
Name = "Cracks",
NickName = "Crk",
Description = $"Crack results are calculated at bar positions or section surfaces depending on the Design Code specifications.{Environment.NewLine}If the applied action is outside the capacity range of the section, the returned list will be empty. See MaximumCrack output for the crack result corresponding to the maximum crack width.",
Access = Access.Item,
};

Check warning on line 45 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L40-L45

Added lines #L40 - L45 were not covered by tests

public CrackParameter MaximumCrackOutput { get; set; } = new CrackParameter {
Name = "MaximumCrack",
NickName = "Crk",
Description = $"Crack results are calculated at bar positions or section surfaces depending on the Design Code specifications.{Environment.NewLine}If the applied action is outside the capacity range of the section, the returned list will be empty. See MaximumCrack output for the crack result corresponding to the maximum crack width.",
Access = Access.Item,
};

Check warning on line 52 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L47-L52

Added lines #L47 - L52 were not covered by tests

public DoubleParameter CrackUtilOutput { get; set; } = new DoubleParameter {
Name = "CrackUtil",
NickName = "Uc",
Description = $"The ratio of the applied load (moment and axial) to the load (moment and axial) in the same direction that would cause the section to crack. Ratio > 1 means section is cracked.{Environment.NewLine}The section is cracked when the cracking utilisation ratio is greater than 1. If the applied load is outside the capacity range of the section, the cracking utilisation will be maximum double value.",
Access = Access.Item,
};

Check warning on line 59 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L54-L59

Added lines #L54 - L59 were not covered by tests

public DeformationParameter DeformationOutput { get; set; } = new DeformationParameter {
Name = "Deformation",
NickName = "Def",
Description = "The section deformation under the applied action",
Access = Access.Item,
};

Check warning on line 66 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L61-L66

Added lines #L61 - L66 were not covered by tests

public SecantStiffnessParameter SecantStiffnessOutput { get; set; } = new SecantStiffnessParameter {
Name = "SecantStiffness",
NickName = "Es",
Description = "The secant stiffness under the applied action",
Access = Access.Item,
};

Check warning on line 73 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L68-L73

Added lines #L68 - L73 were not covered by tests

public IntervalArrayParameter UncrackedMomentRangesOutput { get; set; } = new IntervalArrayParameter {
Name = "Uncracked Moment Ranges",
NickName = "Mrs",
Description = "The range of moments",
Access = Access.Item,
};

Check warning on line 80 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L75-L80

Added lines #L75 - L80 were not covered by tests

public override FuncAttribute Metadata { get; set; } = new FuncAttribute {
Name = "Find Crack Load",
NickName = "CrackLd",
Description = "Increases the load until set crack width is reached",
};

Check warning on line 86 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L82-L86

Added lines #L82 - L86 were not covered by tests

public override Organisation Organisation { get; set; } = new Organisation {
Category = CategoryName.Name(),
SubCategory = SubCategoryName.Cat7(),
};

Check warning on line 91 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L88-L91

Added lines #L88 - L91 were not covered by tests


public override Attribute[] GetAllInputAttributes() {
return new Attribute[] {
SolutionInput,
LoadInput,
};

Check warning on line 98 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L95-L98

Added lines #L95 - L98 were not covered by tests

}

public override Attribute[] GetAllOutputAttributes() {
return new Attribute[] {
LoadOutput,
CrackOutput,
MaximumCrackOutput,
CrackUtilOutput,
DeformationOutput,
SecantStiffnessOutput,
UncrackedMomentRangesOutput
};

Check warning on line 111 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L103-L111

Added lines #L103 - L111 were not covered by tests
}

private static string StrainUnitAbbreviation(StrainUnit unit) {
return Strain.GetAbbreviation(unit);

Check warning on line 115 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L115

Added line #L115 was not covered by tests
}

private static string CurvatureUnitAbbreviation(CurvatureUnit unit) {
var curvature = new Curvature(0, unit);
return string.Concat(curvature.ToString().Where(char.IsLetter));

Check warning on line 120 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L119-L120

Added lines #L119 - L120 were not covered by tests
}

private static string AxialUnitAbbreviation(AxialStiffnessUnit unit) {
var axial = new AxialStiffness(0, unit);
return string.Concat(axial.ToString().Where(char.IsLetter));

Check warning on line 125 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L124-L125

Added lines #L124 - L125 were not covered by tests

}

private static string BendingUnitAbbreviation(BendingStiffnessUnit unit) {
var bending = new BendingStiffness(0, unit);
return string.Concat(bending.ToString().Where(char.IsLetter));

Check warning on line 131 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L130-L131

Added lines #L130 - L131 were not covered by tests
}

public void RefreshDeformation(StrainUnit strainUnit, CurvatureUnit curvatureUnit) {
DeformationOutput.Description = $"The section deformation under the applied action. The output is a vector representing:{Environment.NewLine}X: Strain [{StrainUnitAbbreviation(strainUnit)}]{Environment.NewLine}Y: Curvature around zz (so in local y-direction) [{CurvatureUnitAbbreviation(curvatureUnit)}]{Environment.NewLine}Z: Curvature around yy (so in local z-direction) [{CurvatureUnitAbbreviation(curvatureUnit)}]";
}

Check warning on line 136 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L135-L136

Added lines #L135 - L136 were not covered by tests

public void RefreshSecantStiffness(AxialStiffnessUnit axialUnit, BendingStiffnessUnit bendingUnit) {
SecantStiffnessOutput.Description = $"The secant stiffness under the applied action. The output is a vector representing:{Environment.NewLine}X: Axial stiffness [{AxialUnitAbbreviation(axialUnit)}],{Environment.NewLine}Y: The bending stiffness about the y-axis in the local coordinate system [{BendingUnitAbbreviation(bendingUnit)}],{Environment.NewLine}Z: The bending stiffness about the z-axis in the local coordinate system [{BendingUnitAbbreviation(bendingUnit)}]";
}

Check warning on line 140 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L139-L140

Added lines #L139 - L140 were not covered by tests

public override void Compute() {
var momentUnit = ContextUnits.Instance.MomentUnit;

Check warning on line 143 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L143

Added line #L143 was not covered by tests
// get solution input
var solution = SolutionInput.Value;
IServiceabilityResult sls = null;

Check warning on line 146 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L145-L146

Added lines #L145 - L146 were not covered by tests
switch (LoadInput.Value) {
case ILoad load:
sls = solution.Serviceability.Check(load);
break;

Check warning on line 150 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L149-L150

Added lines #L149 - L150 were not covered by tests
case IDeformation deformation:
sls = solution.Serviceability.Check(deformation);
break;

Check warning on line 153 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L152-L153

Added lines #L152 - L153 were not covered by tests
default:
throw new ArgumentException("Invalid Load Input");

Check warning on line 155 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L155

Added line #L155 was not covered by tests
}

LoadOutput.Value = sls.Load;
DeformationOutput.Value = sls.Deformation;

Check warning on line 159 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L158-L159

Added lines #L158 - L159 were not covered by tests


var cracks = new List<ICrack>();

Check warning on line 162 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L162

Added line #L162 was not covered by tests
foreach (var crack in sls.Cracks) {
cracks.Add(crack);

Check warning on line 164 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L164

Added line #L164 was not covered by tests
}
CrackOutput.Value = cracks.ToArray();

Check warning on line 166 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L166

Added line #L166 was not covered by tests

MaximumCrackOutput.Value = sls.MaximumWidthCrack;
CrackUtilOutput.Value = sls.CrackingUtilisation.As(RatioUnit.DecimalFraction);

Check warning on line 169 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L168-L169

Added lines #L168 - L169 were not covered by tests
if (CrackUtilOutput.Value > 1) {
if (CrackOutput.Value.Length == 0) {
WarningMessages.Add("The section is failing and the cracks are so large we can't even compute them!");

Check warning on line 172 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L172

Added line #L172 was not covered by tests
} else {
RemarkMessages.Add("The section is cracked");

Check warning on line 174 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L174

Added line #L174 was not covered by tests
}
}
DeformationOutput.Value = sls.Deformation;
SecantStiffnessOutput.Value = sls.SecantStiffness;

Check warning on line 178 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L177-L178

Added lines #L177 - L178 were not covered by tests

var momentRanges = new List<Tuple<double, double>>();

Check warning on line 180 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L180

Added line #L180 was not covered by tests
foreach (var mrng in sls.UncrackedMomentRanges) {
var interval = new Tuple<double, double>(mrng.Min.As(momentUnit), mrng.Max.As(momentUnit));
momentRanges.Add(interval);

Check warning on line 183 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L182-L183

Added lines #L182 - L183 were not covered by tests
}
}

Check warning on line 185 in AdSecCore/Functions/SlsResulFunction.cs

View check run for this annotation

Codecov / codecov/patch

AdSecCore/Functions/SlsResulFunction.cs#L185

Added line #L185 was not covered by tests
}

}
Loading