Jump to content

Mr. Wilson Wang

Members
  • Content Count

    13
  • Joined

  • Last visited

Posts posted by Mr. Wilson Wang


  1. I tried to extract openfoam force average data from several columns.  First time is fine and second time it becomes not a number even using the same method with first time. How can I fix it? And is there any instruction for the extractwakefield function in visualization part?  

    post-546-0-39265800-1456732305_thumb.png


  2. Thank you so much, Karsten.

     

    I've tried this code. But some problems occured and iges file equals to null. I've considered some that can be the problems as followed:

     

    1. It shows warning "*** INFO IGES Import : entity type warning [detected type 406 is unsupported]" when I import the original IGES file. The iges file comes from Rhino. 

     

    2. The console also shows *** INFO IGES Export : processing [exporting 1 object(s)] when file is exported and the exporter.iges is null. However when I've tried to export the original surfacegroup as Iges, it shows *** INFO IGES Export : processing [exporting 3354 object(s)] and exported that successfully.

     

    3. I've also tried to convert the imagesurfacegroup to another surfaceGroup and export it , unfortunately, the program crashed when exporting(or running).

     

    Best wishes

    Hey Wilson.

     

    For the iges export it depends a bit but this would export all surfaces which are in the list surfaces.

    igesExport exporter()
    imagesurface img()
    
    objectlist surfaces()
    
    surfaces.add(img)
    
    exporter.add(surfaces)
    
    string filepath(resolveenv("$PROJECTDIR")+"/export.iges") // iges file will be saved in the project directory.
    
    exporter.export(filepath)

    for an imagesurfacegoup:

    igesExport exporter()
    
    surfacegroup group()
    imageSurfaceGroup imggroup(group)
    
    exporter.add(imggroup)
    
    string filepath(resolveenv("$PROJECTDIR")+"/export.iges")
    
    exporter.export(filepath)
    

    I am pretty sure you can change the feature code to your needs.

     

    Cheers,

     

    Karsten


  3. Hi, Arne

     

    It's working well. Thanks a lot for your help.

    Hi,

     

    The Sobol supports parallel evaluation of multiple designs. This means, that it creates a variant, starts the external program(s) and continues to the next design. Once an external program finishes, the results are evaluated for that design. This allows to save time by running multiple evaluations at once.

    If you want to run only one external program at a time, you can disable the "asynchronous update" option of the computation. If you want to limit the number of running external processes (e.g. for license or CPU reasons), you can set that number at the Local Application that is used by the computation.

     

    Best regards,

    Arne


  4. I would like to make a series of  optimization for CFD simulaiton. I've tried to use sobol and Tsearch.  

     

    The evaluation values are needed to be calculate in external software and it would take 45 mins one case.

     

    My point is that I'd like to use sobol to do the variation case by case and finish CFD simulation at the end of each case.

     

    Problem is the sobol variation won't stop for evaluation. And Tsearch changes the design variable in a much random way which I do not prefer.

     

    Is there any other way to make that happen?

     

    One more question is that there is a topic about NAPA DXF to CAESES for variation without further information. 

     

    Is there anyone who have sample case? 


  5. Hi, Karsten

     

    It is working!! Thanks a lot. 

     

    One more question: how can I export an imagesurfacegroup as Iges? Does foreach can take the job?

     

    Best wishes

     

    Hey Wilson,

     

    The iges import supports surfaces , curves and points.

    The surfaces are imported as NURBS surfaces. You are casting it to FBSPLINE surfaces.

    Try the following code:

    if(!In.exists())
      echo("Invalid input file, file does not exist.")
      break()
    endif
    
    igesDeprecatedImport importer()
    importer.import(In.getFileName())
    objectlist imported(importer.getLastImportedObjects())
    surfacegroup ShipSurf()
    
    foreach(FSURFACE surf in imported)
       ShipSurf.add(surf)
    endfor
    
    

    Information about foreach can be found in the FDefineFeatureDlg documentation in CAESES or in the document in this post.

     

    Cheers,

     

    Karsten


  6. Simple question.  

     

    What type does it support?  surface? line? 

     

    When I tried to import iges file, I found it takes huge memory. How can I make it better? I did not do any transformation and I think the computer would crash.

    if(!In.exists())
      echo("Invalid input file, file does not exist.")
      break()
    endif
    
    igesDeprecatedImport importer()
    importer.import(In.getFileName())
    objectlist imported(importer.getLastImportedObjects())
    surfacegroup ShipSurf()
    unsigned i(0)
    
    while(i<imported.getCount()-1)
       ShipSurf.addEntities([imported.at(i).castTo(FBSplineSurface)])
       i+=1
    endwhile
    
    

  7.  

    Hi Wilson,

     

    There are some parts that can be optimized within the feature. Since we do not have an optimizing compiler, each statement has to be executed like it is. So it is a good practice to use temporary variables to simplify the code.

     

    To give you an example:

     

    if (OR(profileExport.at(i):y.toInt() == profileExport.at(i):y, (profileExport.at(i):y.toInt() + 1 - profileExport.at(i):y) > 0.0001))

      |tempCheck.setVector(#(profileExport.at(i)))

    else

      |tempCheck.setVector([#(profileExport.at(i):x), #(profileExport.at(i):y.toInt() + 1), #(profileExport.at(i):z)])

    endif

     

     

    the statement "profileExport.at(i)" has to be executed several times. Putting it in a temporary is a good idea:

     

    FVector3 vec(profileExport.at(i))

     

    if (OR(vec:y.toInt() == vec:y, (vec:y.toInt() + 1 - vec:y) > 0.0001))

      |tempCheck.setVector(vec)

    else

      |tempCheck.setVector([vec:x, vec:y.toInt() + 1, vec:z])

    endif

     

    You could even write:

     

    FVector3 vec(profileExport.at(i))

    double y(vec:y)

     

    if (OR(y.toInt() == y, (y.toInt() + 1 - y) > 0.0001))

      |tempCheck.setVector(vec)

    else

      |tempCheck.setVector([vec:x, y.toInt() + 1, vec:z])

    endif

     

     
    I am confident that you can really speed up the feature by only modifying it in the mentioned way.
     
    If you are interested, check out the blog entry of my college Arne who is diving deeply into the subject of effective feature programming:
     
    Cheers,
    Stefan

     

    hi Stefan

     

    Thank you very much for your help.

     

    It is really instructive. 


  8. Dear Scott,

     

    can you attach a sample project_

    What are the arguments of the feature. 

     

    The time comsuming is not the line by line writing.You can use the debugger and the profiling function which helps you to find out how much time each line nedds to be executed.

    Which Version do you use?

     

     

    Change

    point temp()
    point tempCheck()
    

    to

    vector temp()
    vector tempCheck()
    

    And your If statements with the and and or's are super expensive.

    And you are exporting every single point of each offset which might be 100 or even more.

     

    I don't like goto statements at all because they are very complicated to understand at least for me but if you like them okay.

     

    Cheers,

     

    Karsten

    Thank you very much, Karsten.

    sectionExport is a FOffsetGroup.

    profileExport is a FOffset.

    export=false.

    The version is 4.03.

    I don't like goto either. It is not my code and I'm freshman. 

    is there any syntax like return and any instruction for the basic syntax?


  9. I have a source to export offset file, but it is too time-consuming.

     

    what I would like to do is to make a string array to store all the string and put it all together to one file instead of writing it line by line. 

    // --- This feature creator has been automatically modified to suit the new syntax of if-commands. ---
    
    if (export)
      goto(exportfile)
    else
      goto(end)
    endif
    
    exportFile:
    
    string workingDir(designdir+"/")
    
    // create a new path for the working directory
    
    mkpath(workingDir)
    
    // open a file for writing
    
    FFile out(workingDir+shipName+".off")
    out.openWrite()
    
    out.writeLine("1")
    
    out.writeLine("****** Hull Form Data for SRI CFD Program ******")
    out.writeLine("* Ship Form Export from the FRIENDSHIP-Framework")
    out.writeLine("* Ship Name = "+shipName)
    out.writeLine("************************************************")
    
    out.writeLine("* [1] General Information **********************")
    
    out.writeLine("* alpp       xmid")
    out.writeLine("  1.0000     0.0000")
    
    out.writeLine("* [2] Profile Points ***************************")
    
    out.writeLine("* Sec.ID  x          z         0/1   Corner")
    
    unsigned sizeProfile(profileExport.getSize())
    integer i(0)
    point temp()
    point tempCheck()
    unsigned c(0)
    unsigned flag(0)
    double tempVal(0)
    
    loop1:
    
    if (OR(profileExport.at(i):y.toInt() == profileExport.at(i):y, (profileExport.at(i):y.toInt() + 1 - profileExport.at(i):y) > 0.0001))
      |tempCheck.setVector(#(profileExport.at(i)))
    else
      |tempCheck.setVector([#(profileExport.at(i):x), #(profileExport.at(i):y.toInt() + 1), #(profileExport.at(i):z)])
    endif
    
    temp.setX(#profileExport.at(i).getX())
    temp.setY(#tempCheck.getY().toInt())
    temp.setZ(if(abs(profileExport.at(i).getZ())<0.00005,0,#profileExport.at(i).getZ()))
    
    flag.setValue((#abs(tempCheck.getY()*10)-#abs(temp.getY()*10)).toInt())
    tempVal.setValue(#abs(tempCheck.getY()*1000)-#abs(temp.getY()*1000))
    c.setValue(#tempVal-#abs(flag*100))
    
    out.writeLine("  "+temp.getY()+"       "+temp.getX()+"   "+temp.getZ()+"   "+flag+"    "+c)
    
    i+=1
    if (i < sizeProfile)
      goto(loop1)
    endif
    
    out.writeLine("  -999    0.000000   0.000000   1    0")
    out.writeLine("* [3] Flat Planes ******************************")
    
    out.writeLine("* y_sflat; half breadth of side flat plane")
    out.writeLine(""+halfbeam/lpp)
    out.writeLine("* z_bflat; z-coordinate of bottom flat plane. Assumed to be 0")
    
    out.writeLine("* [4] sectionsExport *********************************")
    
    unsigned sizeSections(sectionsExport.getSize())
    unsigned sizeSection(0)
    i=0
    integer j(0)
    
    sectionsLoop:
    
    sectionsExport.at(i).removeDuplicates()
    
    out.writeLine("*** Station No. "+(i+1))
    out.writeLine(""+(i+1)+"    "+sectionsExport.at(i).getFirst().getX()+"    0.000000")
    out.writeLine("*  dz        y")
    
    sizeSection=sectionsExport.at(i).getSize()
    j=0
    
    pointLoop:
    
    if (j == 0)
      goto(next1)
    endif
    
    if (AND(IF(abs(sectionsExport.at(i).at(j - 1):y) < 3e-05, 0, sectionsExport.at(i).at(j - 1):y) == IF(abs(sectionsExport.at(i).at(j):y) < 3e-05, 0, sectionsExport.at(i).at(j):y), IF(abs(sectionsExport.at(i).at(j - 1):z) < 5e-05, 0, sectionsExport.at(i).at(j - 1):z) == IF(abs(sectionsExport.at(i).at(j):z) < 5e-05, 0, sectionsExport.at(i).at(j):z)))
      goto(next2)
    endif
    
    next1:
    
    out.writeLine(""+if(abs(sectionsExport.at(i).at(j).getZ())<0.00005,0,sectionsExport.at(i).at(j).getZ())+"  "+if(abs(sectionsExport.at(i).at(j).getY())<0.00003,0,sectionsExport.at(i).at(j).getY()))
    
    next2:
    
    j+=1
    if (j < sizeSection)
      goto(pointloop)
    endif
    
    out.writeLine("                                 0   -999  ; delimiter")
    
    i+=1
    if (i < sizeSections)
      goto(sectionsloop)
    endif
    
    out.writeLine("* Sec.ID    x     z0 ----------------------")
    out.writeLine("  -999      0     0          ; delimiter")
    
    out.writeLine("* [5] Trim *************************************")
    
    out.writeLine("*    FP     AP")
    out.writeLine(""+draftAP/lpp+"      "+draftFP/lpp)
    
    out.close()
    //export.setValue(false)
    
    end:
    
    double finish(1)
    
    
×
×
  • Create New...