Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FSI - Issue with pysu2_nastran.py when Reading SET1 from Complex Nastran .f06 Files #2313

Open
safadumanli opened this issue Jun 27, 2024 · 0 comments
Labels

Comments

@safadumanli
Copy link

Description:

There is a problem in the pysu2_nastran.py script when reading the SET1 section from Nastran .f06 output files. The current implementation of the function that reads the SET1 section is insufficient for more complex, such as 3D, mesh structures.

In the tutorial, a simple airfoil case is used with a mesh consisting of 123 surface nodes, which works fine. However, for more complex mesh structures, the SET1 section in the Nastran .f06 file includes additional lines with dates, headers, and the Nastran program's name. These extra lines cause issues while reading the SET1 section, leading to errors in processing the file.

https://github.com/su2code/Tutorials/blob/master/multiphysics/unsteady_fsi_python/Ma01/modal.f06

line 376 starts with SET1. There is no additional line between the SET1 ID's. But for more complex mesh, additional lines look like this:

" 191305- SET1 1 1 2 3 4 5 6 7 +^M
191306- + 8 9 10 11 12 13 14 15 +^M
191307- + 16 17 18 19 20 21 22 23 +^M
191308- + 24 25 26 27 28 29 30 31 +^M
191309- + 32 33 34 35 36 37 38 39 +^M
191310- + 40 41 42 43 44 45 46 47 +^M
191311- + 48 49 50 51 52 53 54 55 +^M
191312- + 56 57 58 59 60 61 62 63 +^M
191313- + 64 65 66 67 68 69 70 71 +^M
191314- + 72 73 74 75 76 77 78 79 +^M
191315- + 80 81 82 83 84 85 86 87 +^M
191316- + 88 89 90 91 92 93 94 95 +^M
191317- + 96 97 98 99 100 101 102 103 +^M
191318- + 104 105 106 107 108 109 110 111 +^M
191319- + 112 113 114 115 116 117 118 119 +^M
191320- + 120 121 122 123 124 125 126 127 +^M
191321- + 128 129 130 131 132 133 134 135 +^M
191322- + 136 137 138 139 140 141 142 143 +^M
191323- + 144 145 146 147 148 149 150 151 +^M
191324- + 152 153 154 155 156 157 158 159 +^M
191325- + 160 161 162 163 164 165 166 167 +^M
191326- + 168 169 170 171 172 173 174 175 +^M
191327- + 176 177 178 179 180 181 182 183 +^M
191328- + 184 185 186 187 188 189 190 191 +^M
191329- + 192 193 194 195 196 197 198 199 +^M
191330- + 200 201 202 203 204 205 206 207 +^M
191331- + 208 209 210 211 212 213 214 215 +^M
191332- + 216 217 218 219 220 221 222 223 +^M
191333- + 224 225 226 227 228 229 230 231 +^M
191334- + 232 233 234 235 236 237 238 239 +^M
191335- + 240 241 242 243 244 245 246 247 +^M
191336- + 248 249 250 251 252 253 254 255 +^M
191337- + 256 257 258 259 260 261 262 263 +^M
191338- + 264 265 266 267 268 269 270 271 +^M
191339- + 272 273 274 275 276 277 278 279 +^M
191340- + 280 281 282 283 284 285 286 287 +^M
1 NX NASTRAN MODES ANALYSIS SET NOVEMBER 15, 2022 MSC Nastran 11/19/16 PAGE 4257^M
^M
0 ^M
S O R T E D B U L K D A T A E C H O ^M
ENTRY ^M
COUNT . 1 .. 2 .. 3 .. 4 .. 5 .. 6 .. 7 .. 8 .. 9 .. 10 . ^M
191341- + 288 289 290 291 292 293 294 295 +^M
191342- + 296 297 298 299 300 301 302 303 +^M
191343- + 304 305 306 307 308 309 310 311 +^M
191344- + 312 313 314 315 316 317 318 319 +^M
191345- + 320 321 322 323 324 325 326 327 +^M
191346- + 328 329 330 331 332 333 334 335 +^M
..."

Expected Behavior:
The function should correctly parse the SET1 section, ignoring any non-relevant lines such as dates, headers, and program names, and correctly extract the node data.

Observed Behavior:
The function fails to properly read the SET1 section due to the presence of extra lines, leading to errors in processing the .f06 file.

Proposed Solution:
I did some revision on the set1 reading part. here it is:
original part:
"
pos = line.find("SET1")
if pos == 30:
line = line.strip("\r\n")
line = line[37:]
line = line.split()
existValue = True
markerTag = line.pop(0)
self.markers[markerTag] = []
while existValue:
if line[0] == "+":
line = meshfile.readline()
line = line.strip("\r\n")
line = line[37:]
line = line.split()
ID = int(line.pop(0))
for iPoint in range(self.nPoint):
if self.node[iPoint].GetID() == ID:
break
if (iPoint == (self.nPoint - 1)) and (
self.node[iPoint].GetID() != ID
):
raise Exception(
"Point {} in the set {} was not found in the mesh".format(
ID, markerTag
)
)
self.markers[markerTag].append(iPoint)
existValue = len(line) >= 1
self.nMarker += 1
continue

    if not any(self.FSI_marker in key for key in self.markers.keys()):
        raise Exception("The FSI marker was not found in the available sets")

    self.markers[self.FSI_marker].sort()

"

Revisied Version:
"
pos = line.find("SET1")
if pos == 30:
line = line.strip("\r\n")
line = line[37:]
line = line.split()
markerTag = line.pop(0)
self.markers[markerTag] = []

                # First 7 ID which in the same line with SET1
                for _ in range(7):
                    ID = int(line.pop(0))
                    print("ID: ", ID )
                    for iPoint in range(self.nPoint):
                        if self.node[iPoint].GetID() == ID:
                            break
                    if (iPoint == (self.nPoint - 1)) and (self.node[iPoint].GetID() != ID):
                        raise Exception(
                            "Point {} in the set {} was not found in the mesh".format(ID, markerTag)
                        )
                    self.markers[markerTag].append(iPoint)

                # after SET1 line start to read a new line
                while True:
                    line = meshfile.readline().strip("\r\n")
                    if not line:
                        continue
                    line = line[30:].strip().split()
                    #  when the SET1 ends, there is a SPC card in .f06 file. this is a break condition 
                    if "SPC1" in line:
                        break
                    if "SPC" in line:
                        break
                    if not line:
                        continue
                    if line[0] == "+":
                        line.pop(0)
                        if line[-1]=="+":
                            line.pop(-1)
                        while line:
                            ID = int(line.pop(0))
                            print("ID: ", ID )
                            for iPoint in range(self.nPoint):
                                if self.node[iPoint].GetID() == ID:
                                    break
                            if (iPoint == (self.nPoint - 1)) and (self.node[iPoint].GetID() != ID):
                                raise Exception(
                                    "Point {} in the set {} was not found in the mesh".format(ID, markerTag)
                                )
                        self.markers[markerTag].append(iPoint)
                    else:
                        continue

                self.nMarker += 1
                continue
  #there is warning part for "FSI marker check" in here, i just did not write but that is not important for now
  self.markers[self.FSI_marker].sort()

"

I am trying to validate this FSI module on a 3D wing. I hope this works in other cases. I can take help for FSI code structure. I have some problem with validation, wings suction and pressure side collapses and analysis diverges. I dont know that the problem on the structural analysis or the FSI code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant