From 30cedd921507a3ea83c04be4573e2210aaa4c4e4 Mon Sep 17 00:00:00 2001 From: JoePfeiffer Date: Tue, 27 Dec 2022 17:59:07 -0700 Subject: [PATCH 1/4] Instead of just checking continuity, we're doing a few more sanity checks on SymmetricComponent geometry. --- .../sf/openrocket/aerodynamics/AerodynamicCalculator.java | 4 ++-- .../sf/openrocket/aerodynamics/BarrowmanCalculator.java | 6 +++--- .../openrocket/aerodynamics/BarrowmanCalculatorTest.java | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/core/src/net/sf/openrocket/aerodynamics/AerodynamicCalculator.java b/core/src/net/sf/openrocket/aerodynamics/AerodynamicCalculator.java index 9889a4987..76429c276 100644 --- a/core/src/net/sf/openrocket/aerodynamics/AerodynamicCalculator.java +++ b/core/src/net/sf/openrocket/aerodynamics/AerodynamicCalculator.java @@ -69,7 +69,7 @@ public interface AerodynamicCalculator extends Monitorable { public AerodynamicCalculator newInstance(); /** - * Test component assembly for continuity (esp. diameter), and post any needed warnings + * Check component assembly for geometric problems and post any needed warnings */ - public void testIsContinuous(FlightConfiguration configuration, final RocketComponent component, WarningSet warnings); + public void checkGeometry(FlightConfiguration configuration, final RocketComponent component, WarningSet warnings); } diff --git a/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java b/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java index ac75e95a4..4f22f93bb 100644 --- a/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java +++ b/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java @@ -252,7 +252,7 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator { if (calcMap == null) buildCalcMap(configuration); - testIsContinuous(configuration, configuration.getRocket(), warnings); + checkGeometry(configuration, configuration.getRocket(), warnings); final InstanceMap imap = configuration.getActiveInstances(); @@ -276,7 +276,7 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator { } @Override - public void testIsContinuous(FlightConfiguration configuration, final RocketComponent treeRoot, WarningSet warnings ){ + public void checkGeometry(FlightConfiguration configuration, final RocketComponent treeRoot, WarningSet warnings ){ Queue queue = new LinkedList<>(); for (RocketComponent child : treeRoot.getChildren()) { // Ignore inactive stages @@ -320,7 +320,7 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator { prevComp = sym; }else if( comp instanceof ComponentAssembly ){ - testIsContinuous(configuration, comp, warnings); + checkGeometry(configuration, comp, warnings); } } diff --git a/core/test/net/sf/openrocket/aerodynamics/BarrowmanCalculatorTest.java b/core/test/net/sf/openrocket/aerodynamics/BarrowmanCalculatorTest.java index d113cf003..2acd0f49c 100644 --- a/core/test/net/sf/openrocket/aerodynamics/BarrowmanCalculatorTest.java +++ b/core/test/net/sf/openrocket/aerodynamics/BarrowmanCalculatorTest.java @@ -290,7 +290,7 @@ public class BarrowmanCalculatorTest { FlightConfiguration configuration = rocket.getSelectedConfiguration(); WarningSet warnings = new WarningSet(); - calc.testIsContinuous(configuration, rocket, warnings); + calc.checkGeometry(configuration, rocket, warnings); assertTrue("Estes Alpha III should be continuous: ", warnings.isEmpty()); } @@ -301,7 +301,7 @@ public class BarrowmanCalculatorTest { FlightConfiguration configuration = rocket.getSelectedConfiguration(); WarningSet warnings = new WarningSet(); - calc.testIsContinuous(configuration, rocket, warnings); + calc.checkGeometry(configuration, rocket, warnings); assertTrue("F9H should be continuous: ", warnings.isEmpty()); } @@ -319,7 +319,7 @@ public class BarrowmanCalculatorTest { body.setOuterRadius( 0.012 ); body.setName( body.getName()+" << discontinuous"); - calc.testIsContinuous(configuration, rocket, warnings); + calc.checkGeometry(configuration, rocket, warnings); assertFalse(" Estes Alpha III has an undetected discontinuity:", warnings.isEmpty()); } @@ -340,7 +340,7 @@ public class BarrowmanCalculatorTest { body.setOuterRadius( 0.012 ); body.setName( body.getName()+" << discontinuous"); - calc.testIsContinuous(configuration, rocket, warnings); + calc.checkGeometry(configuration, rocket, warnings); assertFalse(" Missed discontinuity in Falcon 9 Heavy:" , warnings.isEmpty()); } From d0c19efd3d96cc142f4e660e4b6e2eb3568a0be3 Mon Sep 17 00:00:00 2001 From: JoePfeiffer Date: Wed, 28 Dec 2022 11:01:54 -0700 Subject: [PATCH 2/4] Add check for open airframe forward end Also, it turned out the discontinuity check didn't correctly check across stages (so it wouldn't notice if the aft end of one state wasn't the same as the forward end of the next). Fixed. --- core/resources/l10n/messages.properties | 1 + .../aerodynamics/BarrowmanCalculator.java | 18 +++++++++--------- .../sf/openrocket/aerodynamics/Warning.java | 3 +++ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index 87a2d18d9..4a9a4e1e2 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -1849,6 +1849,7 @@ PlotConfiguration.Groundtrack = Ground track Warning.LargeAOA.str1 = Large angle of attack encountered. Warning.LargeAOA.str2 = Large angle of attack encountered ( Warning.DISCONTINUITY = Discontinuity in rocket body diameter +Warning.OPEN_AIRFRAME_FORWARD = Forward end of airframe is open (radius is > 0) Warning.THICK_FIN = Thick fins may not simulate accurately. Warning.JAGGED_EDGED_FIN = Jagged-edged fin predictions may be inaccurate. Warning.LISTENERS_AFFECTED = Listeners modified the flight simulation diff --git a/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java b/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java index 4f22f93bb..96ae2c947 100644 --- a/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java +++ b/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java @@ -44,7 +44,6 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator { private double cacheDiameter = -1; private double cacheLength = -1; - public BarrowmanCalculator() { } @@ -299,14 +298,16 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator { } SymmetricComponent sym = (SymmetricComponent) comp; + prevComp = sym.getPreviousSymmetricComponent(); if( null == prevComp){ - prevComp = sym; - continue; - } - - // Check for radius discontinuity - if ( !MathUtil.equals(sym.getForeRadius(), prevComp.getAftRadius())) { - warnings.add( Warning.DIAMETER_DISCONTINUITY, sym + ", " + prevComp); + if (sym.getForeRadius() - sym.getThickness() > MathUtil.EPSILON) { + warnings.add(Warning.OPEN_AIRFRAME_FORWARD, sym.toString()); + } + } else { + // Check for radius discontinuity + if ( !MathUtil.equals(sym.getForeRadius(), prevComp.getAftRadius())) { + warnings.add( Warning.DIAMETER_DISCONTINUITY, sym + ", " + prevComp); + } } // double x = component.toAbsolute(Coordinate.NUL)[0].x; @@ -318,7 +319,6 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator { //} //componentX = component.toAbsolute(new Coordinate(component.getLengthAerodynamic()))[0].x; - prevComp = sym; }else if( comp instanceof ComponentAssembly ){ checkGeometry(configuration, comp, warnings); } diff --git a/core/src/net/sf/openrocket/aerodynamics/Warning.java b/core/src/net/sf/openrocket/aerodynamics/Warning.java index c746650ea..b3c31fecc 100644 --- a/core/src/net/sf/openrocket/aerodynamics/Warning.java +++ b/core/src/net/sf/openrocket/aerodynamics/Warning.java @@ -358,6 +358,9 @@ public abstract class Warning { /** A Warning that the body diameter is discontinuous. */ ////Discontinuity in rocket body diameter. public static final Warning DIAMETER_DISCONTINUITY = new Other(trans.get("Warning.DISCONTINUITY")); + + /** A Warning that a ComponentAssembly has an open forward end */ + public static final Warning OPEN_AIRFRAME_FORWARD = new Other(trans.get("Warning.OPEN_AIRFRAME_FORWARD")); /** A Warning that the fins are thick compared to the rocket body. */ ////Thick fins may not be modeled accurately. From 7ff06980b22e8c35bbe0ce67b3ceefcc3b2ab3cc Mon Sep 17 00:00:00 2001 From: JoePfeiffer Date: Wed, 28 Dec 2022 11:36:10 -0700 Subject: [PATCH 3/4] Use string displaying diameters instead of mathematical comparison of diameters to set discontinuity warning --- .../sf/openrocket/aerodynamics/BarrowmanCalculator.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java b/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java index 96ae2c947..264c1298b 100644 --- a/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java +++ b/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java @@ -21,6 +21,7 @@ import net.sf.openrocket.rocketcomponent.InstanceMap; import net.sf.openrocket.rocketcomponent.Rocket; import net.sf.openrocket.rocketcomponent.RocketComponent; import net.sf.openrocket.rocketcomponent.SymmetricComponent; +import net.sf.openrocket.unit.UnitGroup; import net.sf.openrocket.util.Coordinate; import net.sf.openrocket.util.MathUtil; import net.sf.openrocket.util.PolyInterpolator; @@ -305,7 +306,11 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator { } } else { // Check for radius discontinuity - if ( !MathUtil.equals(sym.getForeRadius(), prevComp.getAftRadius())) { + // We're going to say it's discontinuous if it is presented to the user as having two different + // string representations. Hopefully there are enough digits in the string that it will + // present as different if the discontinuity is big enough to matter. + if (!UnitGroup.UNITS_LENGTH.getDefaultUnit().toStringUnit(2.0*sym.getForeRadius()).equals(UnitGroup.UNITS_LENGTH.getDefaultUnit().toStringUnit(2.0*prevComp.getAftRadius()))) { + // if ( !MathUtil.equals(sym.getForeRadius(), prevComp.getAftRadius())) { warnings.add( Warning.DIAMETER_DISCONTINUITY, sym + ", " + prevComp); } } From da1130fd97635a5d40cf6ca90ad6e0f701aaeb32 Mon Sep 17 00:00:00 2001 From: JoePfeiffer Date: Tue, 3 Jan 2023 18:46:53 -0700 Subject: [PATCH 4/4] Require next and previous symmetric components be in line. Avoids having "next" and "previous" go off between pods --- .../rocketcomponent/SymmetricComponent.java | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/core/src/net/sf/openrocket/rocketcomponent/SymmetricComponent.java b/core/src/net/sf/openrocket/rocketcomponent/SymmetricComponent.java index bb76e77ce..f3152ef96 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/SymmetricComponent.java +++ b/core/src/net/sf/openrocket/rocketcomponent/SymmetricComponent.java @@ -10,7 +10,7 @@ import net.sf.openrocket.preset.ComponentPreset; import net.sf.openrocket.util.BoundingBox; import net.sf.openrocket.util.Coordinate; import net.sf.openrocket.util.MathUtil; - +import net.sf.openrocket.rocketcomponent.position.RadiusMethod; /** * Class for an axially symmetric rocket component generated by rotating @@ -621,7 +621,11 @@ public abstract class SymmetricComponent extends BodyComponent implements BoxBou while (0 <= searchSiblingIndex) { final RocketComponent searchSibling = searchParent.getChild(searchSiblingIndex); if (searchSibling instanceof SymmetricComponent) { - return (SymmetricComponent) searchSibling; + SymmetricComponent candidate = (SymmetricComponent) searchSibling; + if (inline(candidate)) { + return candidate; + } + return null; } --searchSiblingIndex; } @@ -658,9 +662,12 @@ public abstract class SymmetricComponent extends BodyComponent implements BoxBou if(searchParent instanceof ComponentAssembly){ while (searchSiblingIndex < searchParent.getChildCount()) { final RocketComponent searchSibling = searchParent.getChild(searchSiblingIndex); - if (searchSibling instanceof SymmetricComponent) { - return (SymmetricComponent) searchSibling; + SymmetricComponent candidate = (SymmetricComponent) searchSibling; + if (inline(candidate)) { + return candidate; + } + return null; } ++searchSiblingIndex; } @@ -671,6 +678,29 @@ public abstract class SymmetricComponent extends BodyComponent implements BoxBou return null; } + /*** + * Determine whether a candidate symmetric component is in line with us + * + */ + private boolean inline(final SymmetricComponent candidate) { + // if we share a parent, we are in line + if (this.parent == candidate.parent) + return true; + + // if both of our parents are either not ring instanceable, or + // have a radial offset of 0 from their centerline, we are in line. + + if ((this.parent instanceof RingInstanceable) && + (!MathUtil.equals(this.parent.getRadiusMethod().getRadius(this.parent.parent, this, this.parent.getRadiusOffset()), 0))) + return false; + + if ((candidate.parent instanceof RingInstanceable) && + (!MathUtil.equals(candidate.parent.getRadiusMethod().getRadius(candidate.parent.parent, candidate, candidate.parent.getRadiusOffset()), 0))) + return false; + + return true; + } + /** * Checks whether the component uses the previous symmetric component for its auto diameter. */