Debug: Database connection successful OpenFOAM (Page 4) / Science, Technology, and Astronomy / New Mars Forums

New Mars Forums

Official discussion forum of The Mars Society and MarsNews.com

You are not logged in.

Announcement

Announcement: This forum is accepting new registrations via email. Please see Recruiting Topic for additional information. Write newmarsmember[at_symbol]gmail.com.

#76 2025-06-12 19:37:44

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 21,785

Re: OpenFOAM

In today's report, I note that the program ran without generating Python errors, but no records were written to the cell memory file, so we have work to do there.  The main change in today's session was to stop trying to pass every parameter to the numerous functions.  Instead, we set up global memory structures for old OpenFOAM data and for the new data we are creating.  This fundamental change led to numerous rounds of testing and fixing, and at this point I haven't looked at the data to see if it is still coming out right. 
(th)

Offline

Like button can go here

#77 2025-06-18 18:51:36

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 21,785

Re: OpenFOAM

Today's work session was short but I am hoping it was successful. Having already created code to pull all data cleanly into memory, we are now writing each of the seven files to output so that they can be confirmed as identical to the input. We have two files already, and in this evening's work session we added three more. I'll test the new code tomorrow.

Assuming the three new files are correct, my plan for tomorrow's work session is to add the two memory files to the clean write process. These files are needed to pass data from one layer to the next.

We have already written code (multiple times) to generate new faces and to write needed data to output. I moderately confident that the procedure to create new faces can be added to this clean structure without breaking anything.

(th)

Offline

Like button can go here

#78 2025-06-19 12:42:55

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 21,785

Re: OpenFOAM

Today's work session went well... There are seven files to open, and seven files to write out after processing.

We completed work on all seven today, so at long last, we can return to processing the data to create new faces tomorrow.

I'll be watching like a hawk to see to it that nothing that will break the new structure is allowed to enter.  We now are reading all the data that is needed for processing into memory, and we are running a variety of checks to be sure the data we've read in is reasonable and that counts match. We also write the data from memory back out to file, and the difference program confirms the outputs match the inputs.  This moment has been a long time coming.  In retrospect, I can see that I should have thought of this long ago, but the learning curve for OpenFOAM is steep, not to mention the learning curve for Python. In any case, this report might be useful to someone approaching a similar project for the first time.

(th)

Offline

Like button can go here

#79 2025-06-23 20:15:24

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 21,785

Re: OpenFOAM

Several days have gone by.... today's report is about the all important "faces" function.  The new layer program had been brought to the point where we were ready for update processing to begin. The most significant of the updates is creation of new faces.  Generating new faces requires passing information from the previous layer, and then doing lookups at run time. I ** think ** the new code might be working, but all I know at this point is that the run statistics look reasonable. I'm planning to look at the output tomorrow:

python3 layer_addition_program_V75.py
✅ points: 28380 entries loaded correctly.
✅ faces: 55814 entries loaded correctly.
✅ owner: 55814 entries loaded correctly.
✅ neighbour: 27436 entries loaded correctly.
✅ boundary: 5 patch blocks loaded correctly.
✅ All OpenFOAM files loaded into base_data.
✅ All face labels valid and complete.
✅ Added 52 new points at X=-0.4
✅ Wrote points with 28432 entries.
✅ Points updated and written.
? Generating new persistent memory cells and faces...
✅ Generated 125 new faces and updated cell memory.
✅ Wrote faces with 55939 entries.
✅ Faces copied and written
✅ Wrote owner with 55814 entries.
✅ Owner copied and written.
✅ Wrote neighbour with 27436 entries.
✅ Neighbour copied and written.
✅ Wrote boundary with 5 patches.
✅ Boundary copied and written.
✅ Persistent memory cells copied and written.
✅ Master memory copied and written.

(th)

Offline

Like button can go here

#80 2025-07-02 12:45:53

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 21,785

Re: OpenFOAM

Today's update is about an return to dealing with points.  In working with faces, it turned out the program was computing new points incorrectly, so we added a memory file for points, and incorporated that into the flow.  The new points are now being generated correctly, and (equally important) the memory file for points is being updated to match, so the next layer will be built upon the layer just completed.

In the next work session, we'll return to dealing with faces.  Faces must be built of a combination of new and old points.  Points that were at the top of the existing layer of cells must be rotated to the bottom, and the new points added at the top. While this is done, the order/sequence of points must be done correctly. Correctly in this context means in clockwise order for boundary (out facing) faces, and counter-clockwise for Internal faces (ones shared between cells).

Here is what the output of the run looks like:

python3 layer_addition_program_V78.py
✅ points: 28380 entries loaded correctly.
✅ faces: 55814 entries loaded correctly.
✅ owner: 55814 entries loaded correctly.
✅ neighbour: 27436 entries loaded correctly.
✅ boundary: 5 patch blocks loaded correctly.
✅ All OpenFOAM files loaded into base_data.
✅ All face labels valid and complete.
✅ Loaded 52 points from persistent memory.
✅ Added 52 new points at X=-0.4
✅ Wrote points with 28432 entries.
✅ Points updated and written.
? Generating new persistent memory cells and faces...
✅ Generated 125 new faces and updated cell memory.
✅ Wrote faces with 55939 entries.
✅ Faces copied and written
✅ Wrote owner with 55814 entries.
✅ Owner copied and written.
✅ Wrote neighbour with 27436 entries.
✅ Neighbour copied and written.
✅ Wrote boundary with 5 patches.
✅ Boundary copied and written.
✅ Persistent memory cells copied and written.
✅ Master memory copied and written.
✅ Point memory copied and written.

(th)

Offline

Like button can go here

#81 2025-07-03 19:03:25

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 21,785

Re: OpenFOAM

Today's work session was spent in preparing for the heart of the layer program: generation of new faces.

Generation of new points appears to be working correctly, and the rest of the program appears to be loading and writing data correctly.  Until now, we've put dummy data into the faces arrays because it is a major step to handle them correctly.

ChatGPT4o surprised me by wanting to use rotation with angles from the center of the new face, to determine the needed order of storage. The rule I've learned from the documentation is that we we are dealing with a boundary face, rotation needs to be clockwise, and if an internal face (between cells) then rotation is counter-clockwise.  ChatGPT4o decided to compute the centroid of each face, and then (somehow) figure out which point goes where in the output.  The output looks like this: (1234,5678,9012,3456) if the face is boundary. The points are located at the corners of the face, and you start reading clockwise from 1234.  It will be interesting to see if ChatGPT4o's solution to this problem works.

The changes were installed in the layer program and I'll test it tomorrow.  I'd be astonished if the new code works the first try, bue we'll see.

(th)

Offline

Like button can go here

#82 2025-07-05 19:00:23

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 21,785

Re: OpenFOAM

Today's work session revealed how difficult this final phase of program development is going to be.

ChatGPT4o made a couple of tiny changes to try to improve the process for:
1) Deciding which points to use for a new face
2) Deciding what order the points must be defined to meet OpenFOAM requirements
3) Including the right number of points (four in our case)

As we tried the new code, things started to get better and then they got worse.  I decided we need a break. 

To lighten things up, I requested a utility program to look at faces.  In order to know if the new program code is working, I need to be able to tell where the points are in the 3D space we are occupying.  A face definition looks like this: 4(1234 5678 9012 3456)
The four numbers represent points in space.  1234 has X, Y and Z coordinates, which I cannot know by just looking at the ID of 1234.
In addition, face 1234 is oriented in one of six possible ways.  It will be perpendicular to -X +X -Y +Y -Z or +Z axes.

The new utility program ** may ** help with visualization of the faces.

We are standing at Version 82 of the layer program.  The only file that is 100% finished is points, and that leaves:
faces
owner
neighbour
master_memory.json
persistent_memory_cells.json
and
persistent_memory_points.json

When we get past faces, the rest should be an easy downhill slide.
(th)

Offline

Like button can go here

Board footer

Powered by FluxBB