[fix] adjusted the validation and update functions in 'FinSet' to better meet user's expectations
This commit is contained in:
parent
ac96222964
commit
f481bb3707
@ -71,7 +71,7 @@ public class EllipticalFinSet extends FinSet {
|
|||||||
if (MathUtil.equals(this.length, length))
|
if (MathUtil.equals(this.length, length))
|
||||||
return;
|
return;
|
||||||
this.length = length;
|
this.length = length;
|
||||||
validateFinTab();
|
validateFinTabLength();
|
||||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
|||||||
}
|
}
|
||||||
|
|
||||||
tabHeight = newTabHeight;
|
tabHeight = newTabHeight;
|
||||||
|
validateFinTabHeight();
|
||||||
fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
|
fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,9 +293,15 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
|||||||
|
|
||||||
tabLength = lengthRequest;
|
tabLength = lengthRequest;
|
||||||
|
|
||||||
|
setTabPosition();
|
||||||
|
|
||||||
fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
|
fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setTabPosition(){
|
||||||
|
this.tabPosition = this.tabOffsetMethod.getAsPosition(tabOffset, tabLength, length);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* internally, set the internal offset and optionally validate tab
|
* internally, set the internal offset and optionally validate tab
|
||||||
*
|
*
|
||||||
@ -303,7 +309,7 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
|||||||
*/
|
*/
|
||||||
public void setTabOffset( final double offsetRequest) {
|
public void setTabOffset( final double offsetRequest) {
|
||||||
tabOffset = offsetRequest;
|
tabOffset = offsetRequest;
|
||||||
tabPosition = tabOffsetMethod.getAsPosition( tabOffset, tabLength, length);
|
setTabPosition();
|
||||||
|
|
||||||
fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
|
fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
|
||||||
}
|
}
|
||||||
@ -318,7 +324,8 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
|||||||
*/
|
*/
|
||||||
public void setTabOffsetMethod(final AxialMethod newPositionMethod) {
|
public void setTabOffsetMethod(final AxialMethod newPositionMethod) {
|
||||||
this.tabOffsetMethod = newPositionMethod;
|
this.tabOffsetMethod = newPositionMethod;
|
||||||
this.tabOffset = tabOffsetMethod.getAsOffset( tabPosition, tabLength, length);
|
this.tabOffset = this.tabOffsetMethod.getAsOffset(tabPosition, tabLength, length);
|
||||||
|
|
||||||
fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
|
fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,25 +347,32 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
|||||||
return tabPosition + tabLength;
|
return tabPosition + tabLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void validateFinTab(){
|
public void validateFinTabPosition() {
|
||||||
this.tabPosition = this.tabOffsetMethod.getAsPosition(tabOffset, tabLength, length);
|
|
||||||
|
|
||||||
//check front bounds:
|
//check front bounds:
|
||||||
if( tabPosition < 0){
|
if (tabPosition < 0) {
|
||||||
this.tabPosition = 0;
|
this.tabPosition = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//check tail bounds:
|
//check tail bounds:
|
||||||
if (this.length < tabPosition ) {
|
if (this.length < tabPosition) {
|
||||||
this.tabPosition = length;
|
this.tabPosition = length;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validateFinTabLength() {
|
||||||
|
//System.err.println(String.format(" >> Fin Tab Length: %.6f @ %.6f", tabLength, tabOffset));
|
||||||
|
|
||||||
final double xTabBack = getTabTrailingEdge();
|
final double xTabBack = getTabTrailingEdge();
|
||||||
if( this.length < xTabBack ){
|
if (this.length < xTabBack) {
|
||||||
this.tabLength -= (xTabBack - this.length);
|
this.tabLength -= (xTabBack - this.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
tabLength = Math.max(0, tabLength);
|
tabLength = Math.max(0, tabLength);
|
||||||
|
|
||||||
|
//System.err.println(String.format(" << Fin Tab Length: %.6f @ %.6f", tabLength, tabOffset));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validateFinTabHeight(){
|
||||||
// check tab height
|
// check tab height
|
||||||
if( null != getParent() ){
|
if( null != getParent() ){
|
||||||
// pulls the parent-body radius at the fin-tab reference point.
|
// pulls the parent-body radius at the fin-tab reference point.
|
||||||
@ -792,7 +806,6 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
|||||||
this.centerOfMass = Coordinate.NaN;
|
this.centerOfMass = Coordinate.NaN;
|
||||||
this.totalVolume = Double.NaN;
|
this.totalVolume = Double.NaN;
|
||||||
this.cantRotation = null;
|
this.cantRotation = null;
|
||||||
validateFinTab();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
super.componentChanged(e);
|
super.componentChanged(e);
|
||||||
|
@ -319,7 +319,7 @@ public class FreeformFinSet extends FinSet {
|
|||||||
clampLastPoint();
|
clampLastPoint();
|
||||||
|
|
||||||
if (oldLength != this.length)
|
if (oldLength != this.length)
|
||||||
validateFinTab();
|
validateFinTabLength();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,8 +77,9 @@ public class TrapezoidFinSet extends FinSet {
|
|||||||
if (length == r)
|
if (length == r)
|
||||||
return;
|
return;
|
||||||
length = Math.max(r, 0);
|
length = Math.max(r, 0);
|
||||||
validateFinTab();
|
setTabPosition();
|
||||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
|
||||||
|
fireComponentChangeEvent(ComponentChangeEvent.AEROMASS_CHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getTipChord() {
|
public double getTipChord() {
|
||||||
|
@ -93,7 +93,7 @@ public class FinSetTest extends BaseTestCase {
|
|||||||
fins.setTabOffsetMethod( methods[caseIndex]);
|
fins.setTabOffsetMethod( methods[caseIndex]);
|
||||||
|
|
||||||
//query
|
//query
|
||||||
double actShift = fins.getTabOffset();
|
final double actShift = fins.getTabOffset();
|
||||||
assertEquals(String.format("Offset doesn't match for: %s \n", methods[caseIndex].name()), expShift[caseIndex], actShift, EPSILON);
|
assertEquals(String.format("Offset doesn't match for: %s \n", methods[caseIndex].name()), expShift[caseIndex], actShift, EPSILON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -148,7 +148,11 @@ public class FinSetTest extends BaseTestCase {
|
|||||||
{ // MIDDLE -> native
|
{ // MIDDLE -> native
|
||||||
fins.setTabOffsetMethod(AxialMethod.MIDDLE);
|
fins.setTabOffsetMethod(AxialMethod.MIDDLE);
|
||||||
fins.setTabOffset(0.0);
|
fins.setTabOffset(0.0);
|
||||||
fins.setTabHeight(0.02);
|
|
||||||
|
assertEquals("Setting by MIDDLE method failed!", 0.015, fins.getTabFrontEdge(), EPSILON);
|
||||||
|
assertEquals("Setting by MIDDLE method failed!", 0.0, fins.getTabOffset(), EPSILON);
|
||||||
|
assertEquals("Setting by MIDDLE method failed!", 0.02, fins.getTabLength(), EPSILON);
|
||||||
|
|
||||||
fins.setTabLength(0.04);
|
fins.setTabLength(0.04);
|
||||||
|
|
||||||
assertEquals("Setting by MIDDLE method failed!", 0.005, fins.getTabFrontEdge(), EPSILON);
|
assertEquals("Setting by MIDDLE method failed!", 0.005, fins.getTabFrontEdge(), EPSILON);
|
||||||
@ -171,9 +175,9 @@ public class FinSetTest extends BaseTestCase {
|
|||||||
assertEquals("Setting by TOP method failed!", 0.02, fins.getTabFrontEdge(), EPSILON);
|
assertEquals("Setting by TOP method failed!", 0.02, fins.getTabFrontEdge(), EPSILON);
|
||||||
|
|
||||||
((TrapezoidFinSet)fins).setRootChord(0.08);
|
((TrapezoidFinSet)fins).setRootChord(0.08);
|
||||||
|
|
||||||
assertEquals("Front edge doesn't match after adjusting root chord...", 0.03, fins.getTabFrontEdge(), EPSILON);
|
|
||||||
assertEquals("Offset doesn't match after adjusting root chord....", 0.0, fins.getTabOffset(), EPSILON);
|
assertEquals("Offset doesn't match after adjusting root chord....", 0.0, fins.getTabOffset(), EPSILON);
|
||||||
|
assertEquals("Front edge doesn't match after adjusting root chord...", 0.03, fins.getTabFrontEdge(), EPSILON);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user