0

How to find a grid index

Hi,

 

I am having trouble finding a grid index.

I used FOFT to show temperature changes over time.

However, I could not find the specific grid index I wanted to show the results for.

My mesh is neither rectangular nor regular, making it harder to find a specific grid.

Is there a way to find the specific grid index (such as AAA 1, AAA 2 in attached picture)? 

 

5 replies

null
    • kenny
    • 8 mths ago
    • Reported - view

    I am not sure what your problem is. For output of FOFT, you do not need grid index. You need to specify the gridblock name under the keyword "FOFT " for writing out its time series.  By the way, the grid index of the mesh is sequence number of the grid.  In your example, the index of AAA1 and AAA 2 is 1 and 2 respectively.  

      • rim
      • 8 mths ago
      • Reported - view

       Yes, I want to get the time series of specific grid index using FOFT. I already have experience using FOFT, but this time I want to obtain the time series of the grid at the point I want among numerous grids. In other words, how can I find out the name of the grid when the x and y coordinates are (9, 10). It is difficult to find because there are many grid and they are not regular.

      • kenny
      • 7 mths ago
      • Reported - view

       I do not think you can get it directly from current TOUGH output. If you have the TOUGH3 source code, you may insert several lines of code to get the element name. You may aoit after reading the mesh file. For example, you can do it in Input_Output.f90, subroutine ReadeMesh after line "1502 continue". At this point, you have coordinates (gcoord) and element name (Elem) for all elements. You can let the code calculate distance of an element to the point you want to search. If the distance is less than a small value, write out the corresponding element name.

      • Keurfon_Luu
      • 7 mths ago
      • Reported - view

       If you are familiar with Python, you can use toughio for that. For instance, if you want the name of the element nearest to [10.0, 10.0, 0.0]:

      import toughio
      from scipy.spatial import KDTree
      
      parameters = toughio.read_input("MESH")  # Read your MESH file
      labels = list(parameters["elements"])  # Extract list of element names
      centers = [v["center"] for v in parameters["elements"].values()]  # Extract list of element centers
      tree = KDTree(centers)
      dist, idx = tree.query([10.0, 10.0, 0.0], k=1)
      print(f"Element nearest to [10.0, 10.0, 0.0] is: {labels[idx]}")
      
      • rim
      • 7 mths ago
      • Reported - view

       Thanks for your answer! I didn't know there was a method like this. Thanks for letting me know~

Content aside

  • 7 mths agoLast active
  • 5Replies
  • 41Views
  • 3 Following