volume of single element

Unknown
edited April 5 in Community Q&A

Hi experts,

 

I was wondering if I could extract the volume of single tetrahedral element in the mesh using udf in acusolve. Do you think it is possible? I have a non-uniform unstructured tetrahedral mesh.

 

Thanks and regards,

Prabin.

Best Answer

Answers

  • acupro
    acupro
    Altair Employee
    edited April 5 Answer ✓

    I'm thinking the simplest (though not necessarily simple) approach is through this function call:
    udfGetOeiData() - where one of the fields is volume:
    https://help.altair.com/hwcfdsolvers/acusolve/topics/acusolve/udfgetoeidata_acusolve_udf.htm

    This depends on having an ELEMENT_OUTPUT command in the input file like this:

    ELEMENT_OUTPUT( "sample" ) {     element_set                     = "flow"     type                            = subset     elements                        = { 32 ; }     integrated_output_frequency     = 1     integrated_output_time_interval = 60.0     num_user_output                 = 0 }

    https://help.altair.com/hwcfdsolvers/acusolve/topics/acusolve/element_output_acusolve_com_ref.htm

    The element number 32 has to exist in the element set "flow" defined elsewhere.

    You'll need to pull your desired element number from the existing element set definition - to use in that ELEMENT_OUTPUT command.

     

  • Unknown
    edited October 2023

    I'm thinking the simplest (though not necessarily simple) approach is through this function call:
    udfGetOeiData() - where one of the fields is volume:
    https://help.altair.com/hwcfdsolvers/acusolve/topics/acusolve/udfgetoeidata_acusolve_udf.htm

    This depends on having an ELEMENT_OUTPUT command in the input file like this:

    ELEMENT_OUTPUT( "sample" ) {     element_set                     = "flow"     type                            = subset     elements                        = { 32 ; }     integrated_output_frequency     = 1     integrated_output_time_interval = 60.0     num_user_output                 = 0 }

    https://help.altair.com/hwcfdsolvers/acusolve/topics/acusolve/element_output_acusolve_com_ref.htm

    The element number 32 has to exist in the element set "flow" defined elsewhere.

    You'll need to pull your desired element number from the existing element set definition - to use in that ELEMENT_OUTPUT command.

     

    Do you know how can I calculate volume of each element in the mesh using acuReport? I found the following link:

    https://help.altair.com/hwcfdsolvers/acusolve/topics/acusolve/elmvolume.htm

  • acupro
    acupro
    Altair Employee
    edited October 2023

    Do you know how can I calculate volume of each element in the mesh using acuReport? I found the following link:

    https://help.altair.com/hwcfdsolvers/acusolve/topics/acusolve/elmvolume.htm

    What are you wanting to do with the element volume?  What's the end goal with that information?

  • Unknown
    edited October 2023

    What are you wanting to do with the element volume?  What's the end goal with that information?

    I have a domain of fluid where a particular region is solid. The solid region is random in its shape. However, I have identification (based on the element) that the region is solid. I will add the volume of all the elements to calculate the volume of that solid region. 

    image

    This is simple representation of flow over cylinder. I basically want to calculate the volume of solid cylinder. It is simple for simple solid. As I move on, there will be more complex structures whose volume I need to calculate. 

    So, to help out with this, I am thinking of summing the volume of each element within this region. This will ultimately be used in the optimization of fluid flow.

  • acupro
    acupro
    Altair Employee
    edited October 2023

    I have a domain of fluid where a particular region is solid. The solid region is random in its shape. However, I have identification (based on the element) that the region is solid. I will add the volume of all the elements to calculate the volume of that solid region. 

    image

    This is simple representation of flow over cylinder. I basically want to calculate the volume of solid cylinder. It is simple for simple solid. As I move on, there will be more complex structures whose volume I need to calculate. 

    So, to help out with this, I am thinking of summing the volume of each element within this region. This will ultimately be used in the optimization of fluid flow.

    Are you doing topology optimization - as in these tutorials?

    https://help.altair.com/hwcfdsolvers/acusolve/topics/tutorials/acu/acu_7200_intro_sl_r.htm

    https://help.altair.com/hwcfdsolvers/acusolve/topics/tutorials/acu/acu_7201_intro_sl_r.htm

    So it's only during the simulation that the elements are determined to be either fluid or solid?  Are you somehow adding a marker to call it 'solid'?  If you're defining the geometry volumes as either fluid or solid and they don't change through the simulation, the ELEMENT_OUTPUT I mentioned before gives you volume as one of the output quantities.

    (I guess I'm confused when you say 'I have a domain of fluid where a particular region is solid' - I would generally think a volume is either fluid or solid, not both.)

  • Unknown
    edited October 2023

    Are you doing topology optimization - as in these tutorials?

    https://help.altair.com/hwcfdsolvers/acusolve/topics/tutorials/acu/acu_7200_intro_sl_r.htm

    https://help.altair.com/hwcfdsolvers/acusolve/topics/tutorials/acu/acu_7201_intro_sl_r.htm

    So it's only during the simulation that the elements are determined to be either fluid or solid?  Are you somehow adding a marker to call it 'solid'?  If you're defining the geometry volumes as either fluid or solid and they don't change through the simulation, the ELEMENT_OUTPUT I mentioned before gives you volume as one of the output quantities.

    (I guess I'm confused when you say 'I have a domain of fluid where a particular region is solid' - I would generally think a volume is either fluid or solid, not both.)

    I am not doing density-based TO. So, I could not use the built-in TO tools. Yes, I have a marker in each element for solid.

    I could not use the method you explained earlier because I don't have exact solid volume set. My volume changes from fluid to solid (or vice versa) throughout the optimization process.

    Do you know how I can use acuReport?

  • acupro
    acupro
    Altair Employee
    edited October 2023

    I am not doing density-based TO. So, I could not use the built-in TO tools. Yes, I have a marker in each element for solid.

    I could not use the method you explained earlier because I don't have exact solid volume set. My volume changes from fluid to solid (or vice versa) throughout the optimization process.

    Do you know how I can use acuReport?

    I am not familiar with acuReport usage.

    Have you tried using udfGetElmWDetJ in the user function?

    https://help.altair.com/hwcfdsolvers/acusolve/topics/acusolve/udfgetelmwdetj_acusolve_udf.htm

    Looks like this is accessible from Body Force, Material Model, or Component Model user functions.

  • Unknown
    edited March 14

    I am not familiar with acuReport usage.

    Have you tried using udfGetElmWDetJ in the user function?

    https://help.altair.com/hwcfdsolvers/acusolve/topics/acusolve/udfgetelmwdetj_acusolve_udf.htm

    Looks like this is accessible from Body Force, Material Model, or Component Model user functions.

    I have been able to get the volume of single element (both in serial and parallel mode with 8 cores.) I used the code as mentioned in the above link. The following code works very well both in series and parallel. I found that wDetJ is 1/8 th of volume of single element. To find the volume of an element, I needed to multiply by 8 (most probably there are 8 gauss points).

    Real* wghtDetJac ; Real wDetJ ; Integer elem ; ... wghtDetJac = udfGetElmWDetJ( udfHd ) ; for ( elem = 0 ; elem < nItems ; elem++ ) {   wDetJ = wghtDetJac[elem] ;  ... }

    I have a simple geometry as below. It is 1m x 1m x 1m with (10 x 10 x 1) elements:- 

    image

    Now, the issue I am having is that I have marker (0-fluid; 1-solid) for each element in the domain above. I want to run a code to calculate the volume of only fluid (i.e marker with 0). I wrote a code that does this. It works very well in series (only 1 core). But, I found when I try to run the same code in parallel (multi cores with 8 cores), wDetJ is correct. But, the total volume (vol) corresponding to 0 marker is not correct in parallel mode--it is correct only in series mode. Would you please help me figure out how to evaluate the volume for the 0 marker only in parallel mode? I figured out that UDF is called several times even in each timestep due to parallelization. The code I ran is:

    Integer timeStep ;
    Integer firstCall ;
    static Integer mytimestep ;
    firstCall = udfFirstCall( udfHd ) ;
    Real dens ;

    /* volume of an element */
    Real* wghtDetJac ;
    Real wDetJ ;
    wghtDetJac = udfGetElmWDetJ( udfHd ) ;

    static Real vol ;
    if (firstCall ==1)
    {
    vol = 0.0 ;
     
    for ( elem =0 ; elem < nItems ; elem++ ) {
     
    outVec[elem] =0 ;

    if (dens ==0) // fluid region
    {
    wDetJ = wghtDetJac[elem] ;
    udfPrintMessPrim( udfHd, "wDetJ=%0.12f\t nItems=%d\n", wDetJ, nItems) ;
    vol += wDetJ*8;
    }

    FILE* fpv = fopen("volume.txt", "w");
    fprintf(fpv, "%0.12f\n%0.12f\n%d\n%d\n", vol, wDetJ*8, nItems);
    fclose(fpv);
    }
    }