cancel
Showing results for 
Search instead for 
Did you mean: 

Femap: Mirror Result

Experimenter
Experimenter

Hi,

 

Using symmetrical B.C's are very usefull since the gain in computational cost.

But not always does people agree with only seeing a part of their product.

 

So my question is:

Is there a way to mirror the result? I have searched and searched but not found anything suitable.

Mirror a mesh, solid or surface etc. no problem but these do not bring any result with them.

 

I am thinking that if there is no tool in Femap that allows to mirror the result i would try to write an API for it. 

 

3 REPLIES

Re: Femap: Mirror Result

Experimenter
Experimenter

Started with an API for reflecting the result. So far i have mirrored the solid and mesh but it seems like the feGererateReflect function does not support the result parameters in my code bellow. Any ideas what function i can use instead?

 

 

Option Explicit

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

   Dim fSet As femap.Set
   Set fSet = App.feSet

   Dim rc As zReturnCode

   rc=fSet.Select(FT_SOLID,True,"Select Surface(s) with Associated Mesh to Move Along Vector")
   If rc=FE_CANCEL Then Exit Sub

   Dim vecLength As Double
   Dim vecBase As Variant
   Dim vecDir As Variant

   rc=App.feVectorPick("Select Vector to Move Along",False,vecLength,vecBase,vecDir)
   If rc=FE_CANCEL Then Exit Sub

	App.feGenerateReflect(FT_SOLID,fSet.ID,vecBase,vecDir,0,True)

	fSet.Reset
	rc=fSet.Select(FT_ELEM,True,"FT_ELEM")
    If rc=FE_CANCEL Then Exit Sub

	App.feGenerateReflect(FT_ELEM,fSet.ID,vecBase,vecDir,0,True)

'FT_RES_ATTACH

	fSet.Reset
	rc=fSet.Select(FT_RES_ATTACH,True,"FT_RES_ATTACH")
    If rc=FE_CANCEL Then App.feAppMessage(FCM_ERROR,"FAIL FT_RES_ATTACH")
	App.feGenerateReflect(FT_RES_ATTACH,1,vecBase,vecDir,0,True)
	App.feGenerateCopy(FT_RES_ATTACH,fSet.ID,vecDir,0,True)

'FT_OUT_CASE

	fSet.Reset
	rc=fSet.Select(FT_OUT_CASE ,True,"FT_OUT_CASE")
    If rc=FE_CANCEL Then App.feAppMessage(FCM_ERROR,"FAIL FT_OUT_CASE")
	App.feGenerateReflect(FT_OUT_CASE ,fSet.ID,vecBase,vecDir,0,True)
	App.feGenerateCopy(FT_OUT_CASE,fSet.ID,vecDir,0,True)

'FT_OUT_DIR

	fSet.Reset
	rc=fSet.Select(FT_OUT_DIR,True,"FT_OUT_DIR")
    If rc=FE_CANCEL Then App.feAppMessage(FCM_ERROR,"FAIL FT_OUT_DIR")
	App.feGenerateReflect(FT_OUT_DIR ,fSet.ID,vecBase,vecDir,0,True),
	App.feGenerateCopy(FT_OUT_DIR,fSet.ID,vecDir,0,True)

'FT_OUT_DATA

	fSet.Reset
	rc=fSet.Select(FT_OUT_DATA ,True,"FT_OUT_DATA")
    If rc=FE_CANCEL Then App.feAppMessage(FCM_ERROR,"FAIL FT_OUT_DATA")
	App.feGenerateReflect(FT_OUT_DATA,fSet.ID,vecBase,vecDir,0,True)
	App.feGenerateCopy(FT_OUT_DATA,fSet.ID,vecDir,0,True)

	App.feViewRegenerate(0)
End Sub

 

Regards Henrik

 

Re: Femap: Mirror Result

Phenom
Phenom

Hi,

 

The way I see it this problem has a simple part and a more complicated one.

The simple part is that when reflecting, I'm betting FEMAP keeps the ID order of elems/nodes. What I mean is that if you have your set of initial IDs, and you use the trackdata object to get a set of created IDs, then when you parse these sets simultaneously you get "brother IDs": you get pairs of IDs which should get the same output value. The n-th element in the 2nd set will actually be the reflexion of the element whose ID is the n-th one in the 1st set.

That's the easy part: that means that for each output, you can retrieve the list of its values from the initial IDs and simply re-affect (by duplicating) that list on the reflected IDs.

 

And that's where the more annoying part comes in: you need to repeat this process for nodes, elements, perhaps 1/2/3D elements, perhaps top/bottom output, perhaps center/corner output, perhaps nodal vectorial output...etc... The problem with dealing with output is that their are many hidden operations.

 

So to adress your issue I would start by simplifying it: start by dealing with one type of output at a time, nodal scalar or elemental scalar, 1 single value per entity. Once that works, add more otput in there.

 

Pseudo code will be something like:

 

 

Select elements

Select reflection plane

Select output to reflect

 

Create sets of initial nodes and elems (for later)

 

Track created mesh (nodes and elems)

Generate element reflection

Retrieve created elems and nodes as sets

 

for each output, depending on its nature (nodes or elems?)

     get outputlist at set => on the initial set

     append that output list with the new reflected IDs + values (keep in mind what I write above)

     put that "doubled" outputlist on this "doubled" set

 

 

When you see it like this, you can see that this can be generalized to any number of copies (if we imagine more than just reflecting). Also you could imagine that this works no matter the output.

But there will be problems for sure. Imagine for example displacements: with reflexion BCs, the 'reflected ghost' part of your model should have reflected displacements, i.e. somewhere in there a sign should change. Or in a general case where you're reflecting along any plane, the X Y Z values change completely! (nodal vectorial output is stored in Csys0)

 

Anyway... In simple cases where you limit this concept to scalar output, and output which is not oriented (temperature, energy... but NOT displacement, stress, force), this should work. Other than that good luck.

 

AP

Re: Femap: Mirror Result

Experimenter
Experimenter

Thank you for a great answer Smiley Happy

 

The code bellow is a start two pseudo the way u described to solve the problem.
I can now mirror the element result into a new output set. But the problem is as astrium_tls said, the hidden operations within the result. So next is to deal with the corner data.

I found an old thread by astrium_tls: bug with corner output on plates

 

/ Regards Henrik

 

Option Explicit

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

    Dim rc As zReturnCode

    Dim ElementSet As femap.Set
    Set ElementSet = App.feSet

    Dim fOut As femap.Output
    Set fOut = App.feOutput

    Dim fOutNew As femap.Output
    Set fOutNew = App.feOutput
    Dim fOutSetNew As femap.OutputSet
    Set fOutSetNew = App.feOutputSet

    Dim Value As Double
    Dim ResID As Long
    Dim sOutSet As Object
    Dim sOutVec As Object

    Dim id(8) As Long, cen(8) As Double
    Dim c1(8) As Double, c2(8) As Double, c3(8) As Double, c4(8) As Double
    Dim c5(8) As Double, c6(8) As Double, c7(8) As Double, c8(8) As Double

    'Mirror_Body_Mesh(),


If App.feSelectOutput( "Select Output Vectors",0,FOT_ANY, FOC_ANY,FT_ELEM,False,sOutSet, sOutVec ) = FE_OK  Then
    ' Create a new Output Set
    fOutSetNew.title = "Mirrored Result"
    fOutSetNew.analysis = FAT_STATIC
    fOutSetNew.Put(App.feOutputSet.NextEmptyID)

    ' Get the selected output ID
    ResID = sOutVec.Next

    ' Initialize the new output
    fOutNew.InitScalarAtElem(fOutSetNew.ID,ResID,"Mirrored Output",FOT_STRESS,True)

    fOut.Get(ResID)
    'Select Elements of interest
    If ElementSet.Select(FT_ELEM, True, "Select Node" ) = FE_OK Then
    ' Fill the new nodes with old node values, if the data is nodal.
         While ElementSet.Next
            ' Retrieve the output values. The index must be the ID of the node/element where the
            ' output value is stored.

            Value = fOut.value(ElementSet.CurrentID)
            fOutNew.value(ElementSet.CurrentID) = Value
            fOutNew.value(ElementSet.CurrentID+720) = Value

        Wend
    End If
End If

rc = fOutNew.Put(ResID)
App.feViewRegenerate(0)

End Sub



Function Mirror_Body_Mesh()

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

    Dim fSet As femap.Set
    Set fSet = App.feSet

    Dim fOut As femap.Output
    Set fOut = App.feOutput
    Dim rc As zReturnCode

    rc=fSet.Select(FT_SOLID,True,"Select Solid(s) with Associated Mesh to Move Along Vector")
    If rc=FE_CANCEL Then Exit Function

    Dim vecLength As Double
    Dim vecBase As Variant
    Dim vecDir As Variant

    rc=App.feVectorPick("Select Vector to Move Along",False,vecLength,vecBase,vecDir)
    If rc=FE_CANCEL Then Exit Function
    App.feGenerateReflect(FT_SOLID,fSet.ID,vecBase,vecDir,0,True)

    fSet.Reset
    rc=fSet.Select(FT_ELEM,True,"FT_ELEM")
    If rc=FE_CANCEL Then Exit Function
    App.feGenerateReflect(FT_ELEM,fSet.ID,vecBase,vecDir,0,True)

End Function