CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Trouble updating fields at regular time intervals

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 20, 2024, 06:53
Default Trouble updating fields at regular time intervals
  #1
New Member
 
YF
Join Date: Sep 2016
Posts: 5
Rep Power: 10
foolfishzju is on a distinguished road
I’ve been facing an issue for several weeks related to updating fields at regular time intervals, and I’m hoping for some help.

I am trying to create a droplet or bubble in a specific location at each time interval during a simulation. After researching different approaches, I found two possible solutions:
1. Using the coded function object in system/controlDict.
2. Using the systemCall function object to run a script that executes the setFields command.
However, both methods have their challenges, and I have been unable to get either to work.

For the coded function object approach, the issue is that while I can access field data (like alpha.water) using the lookupObject function, I’m unable to modify the field values. It seems that these fields are read-only within the coded function.

For the systemCall approach, there are conflicts between the ongoing computation and the execution of setFields. Since the job is actively running when the systemCall function is triggered, modifying fields during the computation can lead to conflicts and cause the job to crash.

Please could anyone help me?
Many thanks in advance!
__________________
Yuan Fang
foolfishzju is offline   Reply With Quote

Old   October 15, 2024, 05:52
Default
  #2
New Member
 
YF
Join Date: Sep 2016
Posts: 5
Rep Power: 10
foolfishzju is on a distinguished road
Problem resolved. By combing a bash script with 'timeActivatedFileUpdate' function, we are able to update fields at regular time intervals. Below is the script.
Code:
while (( (echo "$time_start < $time_end" | bc -l) ))
do

    # Step 1: Run setFields in parallel mode
    mpirun -np $TOTAL_TASKS setFields -parallel > log.setFields_$time_start 2>&1

    # Step 2: Run the case from time_start to time_start + time_step
    # ControlDict will be updated using timeActivatedFileUpdate function
    mpirun -np $TOTAL_TASKS icoFoam -parallel > log.icoFoam_$time_start 2>&1

    # Increment time_start for the next interval
    time_start=$(echo "$time_start + $time_step" | bc)

done
__________________
Yuan Fang
foolfishzju is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[solidMechanics] Support thread for "Solid Mechanics Solvers added to OpenFOAM Extend" bigphil OpenFOAM CC Toolkits for Fluid-Structure Interaction 686 December 22, 2022 10:10
AMI speed performance danny123 OpenFOAM 21 October 24, 2020 05:13
Setting up Lid driven Cavity Benchmark with 1M cells for multiple cores puneet336 OpenFOAM Running, Solving & CFD 11 April 7, 2019 01:58
Floating point exception error lpz_michele OpenFOAM Running, Solving & CFD 53 October 19, 2015 03:50
same geometry,structured and unstructured mesh,different behaviour. sharonyue OpenFOAM Running, Solving & CFD 13 January 2, 2013 23:40


All times are GMT -4. The time now is 09:19.