Outputting Custom Variables

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • ysakamoto
    Junior Member
    • Feb 2013
    • 12

    Outputting Custom Variables

    Hi FEBio users/developers.

    I am currently looking for a way to output custom variables using FEBio's logfile functionality. For example, let's say that there is a fiber bundle going in the direction V. Then, assuming that the bundle deforms affinely with the underlying material, the direction of the bundle after deformation should be v=FV, and its stretch should be lambda = sqrt(V*CV).

    The above can be easily calculated using FEBio's plugin functionality by deriving FEElasticMaterialPoint class. However, it seems that there is no way to output these custom variables v and lambda to a log file or plot file. Is there any good way to do this? The above is a simple example, but in future I would like to output more complex parameters, such as fiber stretch in a certain direction, stretch rate, spherical distribution, etc, after deformation.

    Thanks!

    Yusuke
  • maas
    Lead Code Developer
    • Nov 2007
    • 3441

    #2
    Hi Yusuke,

    If I understand what you are trying to do than this is perfectly possible with the plugin capability. I would not create a new class from FEElasticMaterialPoint to implement this (unless you need that class for other reasons) but create a new class from FEDomainData and implement the Save method. If you have the FEBio source code, you can take a look at the class FEPlotFiberVector as an example. This will store your data to the plotfile so you can access it from PostView.

    There is a way to use the plugins to write data to the logfile, but I have not tested that, to be honest. I'll see if I can find some time to test it and then report back. I'll also try to expand the online developer's documentation and include some more examples. In the mean time, if you have any further questions, please don't hesitate to contact us.

    Best,

    Steve
    Department of Bioengineering, University of Utah
    Scientific Computing and Imaging institute, University of Utah

    Comment

    • ysakamoto
      Junior Member
      • Feb 2013
      • 12

      #3
      Thanks! It works well.

      However, I am still interested in the way to output results to a logfile because I want to automate everything. I am planning to run hundreds of simulations and carry out postprocessing on my custom variable. Dumping the results to logfiles would be the easiest way, but are there any other ways? I know that PostView can export nodal or elemental variables in ASCII format, but can I do this from command line?

      Also I want to automate the visualization process too. For example, I want to output the vector plot with some camera positions, etc, into image files from the command line, so that I don't have to do it manually for hundreds of results. I don't think PostView have this capability right now. That is one of the reason that I want to just dump the results to logfile, so that I can use it from other visualization software, such as ParaView.

      Comment

      • maas
        Lead Code Developer
        • Nov 2007
        • 3441

        #4
        I'm glad to hear you got that to work.

        I'll take a look at storing data to the logfile from a plugin and I'll post an example.

        Regarding the visualization, PostView cannot do off-screen rendering right now, so there is no way to automate making visualizations. Although I think this would be an interesting feature to have, I don't think we can make that happen anytime soon. It sounds like you have an alternative path forward, though.

        Best,

        Steve
        Department of Bioengineering, University of Utah
        Scientific Computing and Imaging institute, University of Utah

        Comment

        • ysakamoto
          Junior Member
          • Feb 2013
          • 12

          #5
          There is a way to use the plugins to write data to the logfile, but I have not tested that, to be honest. I'll see if I can find some time to test it and then report back. I'll also try to expand the online developer's documentation and include some more examples. In the mean time, if you have any further questions, please don't hesitate to contact us.
          What is the status of the logfile plugin capability? If I have a control over what to output, especially node coordinates, element connectivity, and node/element data, then I can just write a routine to output the results in vtk format.

          Thanks!

          Comment

          • maas
            Lead Code Developer
            • Nov 2007
            • 3441

            #6
            Hi,

            I have not had a chance to work on this. I'll try to find some time next week to look into this and I'll get back to you.

            Cheers,

            Steve
            Department of Bioengineering, University of Utah
            Scientific Computing and Imaging institute, University of Utah

            Comment

            • ysakamoto
              Junior Member
              • Feb 2013
              • 12

              #7
              I actually ended up writing some script for converting FEBio's plot file (.xplt) to VTK's unstructured mesh file (.vtu). I only tested it on tetrahedron+triangle mesh, but it should work as long as all the elements are linear.

              Here is the script:
              Convert the FEBio output file to VTK format. Contribute to yskmt/feb-vtk-converter development by creating an account on GitHub.


              FEBio's binary database specification document needs to be upgraded... I had to read the source code.

              Comment

              • maas
                Lead Code Developer
                • Nov 2007
                • 3441

                #8
                Thanks for sharing your script!

                We have a more up-to-date description of the database specification document, so we'll try to upload that one in the next couple of days.

                Cheers,

                Steve
                Department of Bioengineering, University of Utah
                Scientific Computing and Imaging institute, University of Utah

                Comment

                • maaaaaaaaaartin
                  Junior Member
                  • Feb 2015
                  • 21

                  #9
                  Thanks indeed for sharing the script!

                  Here is a small patch allowing for conversion of scalar fields.

                  Martin

                  PS: For some reason I can't upload the patch file. Here it is:

                  Code:
                  From 81d838c5a7264a9d58b750aed1ab7b9348ad571e Mon Sep 17 00:00:00 2001
                  From: Martin Genet <genet@biomed.ee.ethz.ch>
                  Date: Fri, 20 Feb 2015 14:11:56 +0100
                  Subject: [PATCH] allow for scalar fields
                  
                  ---
                   write_vtk.py | 8 +++++---
                   1 file changed, 5 insertions(+), 3 deletions(-)
                  
                  diff --git a/write_vtk.py b/write_vtk.py
                  index 9f2df7d..5bce6ba 100644
                  --- a/write_vtk.py
                  +++ b/write_vtk.py
                  @@ -67,10 +67,10 @@ def load_data(workdir, nstate, n_subdomains):
                   
                       # load miscelleneous data
                       dom_elem_types = np.loadtxt(workdir + 'element_types_%d.dat' %
                  -                                nstate, dtype=int)
                  +                                nstate, dtype=int, ndmin=1)
                   
                       item_formats = np.loadtxt(workdir + 'item_format_%d.dat' % nstate,
                  -                              dtype=int)
                  +                              dtype=int, ndmin=1)
                   
                       item_names = np.genfromtxt(workdir + 'item_names_%d.dat' % nstate,
                                                  dtype='str', delimiter='\n')
                  @@ -147,7 +147,9 @@ def write_vtk(workdir, nodes, elems, dom_n_elems, node_data,
                       PointData_xml = etree.SubElement(Piece_xml, "PointData")
                   
                       for i in range(len(node_data)):
                  -        data_dim = len(node_data[i][0])
                  +        if   (type(node_data[i][0]) is np.ndarray):   data_dim = len(node_data[i][0])
                  +        elif (type(node_data[i][0]) is np.float64): data_dim = 1
                  +        else: assert(0), "Wrong data type"
                   
                           DataArray_xml = etree.SubElement(PointData_xml, "DataArray",
                                                            type="Float32",
                  -- 
                  2.1.0

                  Comment

                  • maaaaaaaaaartin
                    Junior Member
                    • Feb 2015
                    • 21

                    #10
                    By the way, in order to export more than one time step, I had to change the test at line 361 of read_xplt.py from

                    Code:
                    while check_block(f, TAGS, 'STATE', filesize=filesize) & (cur_state < nstate)
                    to

                    Code:
                    while (cur_state < nstate):
                    Any idea what the issue might be? Thanks anyway.

                    Martin

                    Comment

                    • ysakamoto
                      Junior Member
                      • Feb 2013
                      • 12

                      #11
                      Hi Martin,

                      Thanks for the patch, I will apply it.

                      I am not sure how you want to export more than one time step, but currently the script only read/write one time step at a time. You can call it multiple times to export multiple time steps (see convert_feb_vtk.py). The first condition in the while statement is to prevent the current state from going over the total number of states saved in the file.

                      Hope this helps,

                      Yusuke

                      Comment

                      Working...
                      X
                      😀
                      😂
                      🥰
                      😘
                      🤢
                      😎
                      😞
                      😡
                      👍
                      👎