Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

Trying to give hydrostatic pressure on surface using API

Dear all,

 

I am trying to give pressure on surface "perpendicular to surfaces" according to depth of water surface.

 

Think a curved surface . How can i manage it by using simple API? 

9 REPLIES

Re: Trying to give hydrostatic pressure on surface using API


Sub Main
    Dim App As femap.model
    Set App = feFemap()

    Dim fs As femap.Set
    Dim fLS As femap.LoadSet
    Dim fLD As femap.LoadDefinition
    Dim flg As femap.LoadGeom

    Dim nID As Long
    Dim dPress As Double

    Set fs = App.feSet
    Set fLS = App.feLoadSet
    Set fLD = App.feLoadDefinition
    Set flg = App.feLoadGeom

    ' Get surface
    If fs.SelectID( FT_SURFACE, "Select surface to load", nID ) <> FE_OK Then Exit All
    If App.feGetReal( "Pressure", -999999999, 999999999, dPress ) <> FE_OK Then Exit All


    ' Create load set
    fLS.title = "Sample load set"
    fLS.Put( App.Info_NextID( FT_LOAD_DIR ) )

    ' Create load definition
    fLD.setID = fLS.ID
    fLD.PutAll( fLD.NextEmptyID(), FT_GEOM_LOAD, FLT_SEPRESSURE, "Pressure load" )

    ' Create geometric load
    flg.setID = fLS.ID
    flg.LoadDefinitionID = fLD.ID
    flg.type = fLD.loadType
    flg.geomID = nID
    flg.geomTYPE = FT_SURFACE
    flg.load( 0 ) = dPress
    flg.Put( flg.NextEmptyID() )

End Sub

 

You need to create a geometric load (feLoadGeom), but before  you do that, you need a Load Definition as well as a Load Set. The load type on the definition object as well as on the load geom object is what defines the load type and must match. In this case, you're using the enum FLT_SEPRESSURE. Load values for scalar quantities is stored in the load(0) field. 

Re: Trying to give hydrostatic pressure on surface using API

Yes this gives stable pressure which you put. 

 

The script must be take into consideration X,Y plane zero.

 

Then it must be ask what is the hydrostatic level (eg, z=3000 mm)

 

Then  it must give pressures according to z height for different elements.

 

Re: Trying to give hydrostatic pressure on surface using API

You can set the variation method to "Equation", which allows you to use !x, !y and !z as variables representing the the X, Y, Z coordinates of either the element centroid or node (depending if it's being applied at the corner or centroid). 

 

Above code changes to:


    flg.load( 0 ) = 1.0
    flg.variation = FLV_EQUATION
    flg.vareqn = "5*!z"

 

Load value is then a multiplier to the value calculated by the equation. The above is just a simple variation of 5* the z coordinate. If you want pressures at corners, set this property


    flg.CornerPressure= True

 

Note that when applying loads to geometry like this, you won't see the variation in the UI until you expand the load. Until then, it's only displayed as the constant load factor.

Re: Trying to give hydrostatic pressure on surface using API

I can not make the script run. Smiley Frustrated

 

Sub Main
    Dim App As femap.model
    Set App = feFemap()

    Dim fs As femap.Set
    Dim fLS As femap.LoadSet
    Dim fLD As femap.LoadDefinition
    Dim flg As femap.LoadGeom

    Dim nID As Long
    Dim dPress As Double

    Set fs = App.feSet
    Set fLD = App.feLoadDefinition
    Set flg = App.feLoadGeom

    ' Get surface
    If fs.SelectID( FT_SURFACE, "Select surface to load", nID ) <> FE_OK Then Exit All

    ' Create load definition
    fLD.PutAll( fLD.NextEmptyID(), FT_GEOM_LOAD, FLT_SEPRESSURE, "Pressure load" )

    flg.variation = FLV_EQUATION
    flg.vareqn = "5*!z"


    ' Create geometric load
    flg.LoadDefinitionID = fLD.ID
    flg.type = fLD.loadType
    flg.geomID = nID
    flg.geomType = FT_SURFACE
    flg.load( 0 ) = vareqn
    flg.Put( flg.NextEmptyID() )

End Sub

Can you help me?

Solution
Solution
Accepted by topic author Xazar
‎01-12-2017 02:09 AM

Re: Trying to give hydrostatic pressure on surface using API

Your script is missing some parts

 

- It's missing the creation of the load set. The load definition and geometric load therefore have no where to go

- You have  a line that reads "flg.load(0) = vareqn"... the variable vareqn has never been defined anywhere, so it defaults to a value of 0 at runtime. When using the equation method the load value is a multiplier, so you should put in a value of 1.0 or a multiplier based on the equation you use.

 

The HTML Clipboard

Sub Main
    Dim App As femap.model
    Set App = feFemap()

    Dim fs As femap.Set
    Dim fLS As femap.LoadSet
    Dim fLD As femap.LoadDefinition
    Dim flg As femap.LoadGeom

    Dim nID As Long

    Set fs = App.feSet
    Set fLS = App.feLoadSet
    Set fLD = App.feLoadDefinition
    Set flg = App.feLoadGeom

    ' Get surface
    If fs.SelectID( FT_SURFACE, "Select surface to load", nID ) <> FE_OK Then Exit All

    ' Create load set
    fLS.title = "Sample load set"
    fLS.Put( App.Info_NextID( FT_LOAD_DIR ) )

    ' Create load definition
    fLD.setID = fLS.ID
    fLD.PutAll( fLD.NextEmptyID(), FT_GEOM_LOAD, FLT_SEPRESSURE, "Pressure load" )

    ' Create geometric load
    flg.setID = fLS.ID
    flg.LoadDefinitionID = fLD.ID
    flg.type = fLD.loadType
    flg.geomID = nID
    flg.geomTYPE = FT_SURFACE
    flg.load( 0 ) = 1.0
    flg.variation = FLV_EQUATION
    flg.vareqn = "5*!z"
    flg.Put( flg.NextEmptyID() )

End Sub

 

Don't forget, you'll need to expand the geometric loads on your mesh, otherwise you'll see just the factor.

Re: Trying to give hydrostatic pressure on surface using API

Also I want to define a variable and put it in to formula.

 

But this in not working. 

 

Dim T as Integer

T=2000

 

 

flg.vareqn = "5*!z+!T"

 

Solution
Solution
Accepted by topic author Xazar
‎01-13-2017 09:23 AM

Re: Trying to give hydrostatic pressure on surface using API

It doesn't quite work that way. The only variables that are valid for equations on geometric loads are X, Y and Z, for the coordinates of the entity that will be loaded in the coordinate system specified for the load. Additionally, user-defined variables that are declared in "Tools->Variables" can be used as well, using the same ! prefix. 

 

Variables in loads are completely independent of any variables that you declare in the API - they don't know anything about each other.

 

Let's say we want to declare a variable for pi. You can do that via "Tools->Variables" 

 

tools-variables.png

 

Or, if you wanted to do it via API, then 


    App.feVarPut( "pi", False, True, 3.14159, "" )

 

You can then reference that variable in the load:


    flg.vareqn = "!Z*!PI"

 

I somewhat suspect that's not really what you're after though. If you want to determine a variable value in the API and use that in the equation, remember that the equation is just a string that's evaluated on load expansion. Therefore, rather than referencing the variable, you'd use just concatenate it into an expression:


    Dim T As Long
    T = 2000

    ' Code omitted for brevity

    flg.vareqn = "5*!z + " + CStr(T )

 

One other thing I'll point out... be careful using the Integer (2 byte int) data type in the API Programming Window. The majority of FEMAP calls use Long (4 byte int) type instead. Usually it doesn't really matter but if you start trying to mix and match variants and arrays down the line it could cause some issues. If the variable is ever going to be used as an argument to a call, it's best to stick with the data type declared in the reference manual. 

Re: Trying to give hydrostatic pressure on surface using API

That is what i want instead of Tools>Variables.

 

It works when I put line into API.

 

App.feVarPut( "T", False, True, 1000, "" )

 

Thank you very much.

Re: Trying to give hydrostatic pressure on surface using API

Hello again, i have one question also.

 

How can i modify code in order to get multiple surface selection?