|
[Sponsors] |
November 24, 2024, 11:46 |
Event settings based on other parameters
|
#1 |
Member
Amin Sheikhi
Join Date: Mar 2023
Posts: 31
Rep Power: 3 |
Hello,
Do you have any suggestions for setting CONVERGE's event settings based on other parameters such as pressure instead of simulation solution time? If UDF is possible can you guide how to write any? I would appreciate any suggestions. Sincerely, Amin |
|
Yesterday, 11:23 |
|
#2 |
New Member
Mingyi Liang
Join Date: Sep 2022
Posts: 24
Rep Power: 4 |
Yes, you can write an UDF for that purpose. We have an example event UDF in our UDF manual, please have a look and try to modify it based on your own application.
If you have v4.0, there's a pressure event in Studio already, and you can use it to set up the event. If you still wanna write a pressure event UDF, please contact support@convergecfd.com for help. ----------------------------------------------------------------------------- Mingyi Liang Senior Research Engineer - Applications Convergent Science Madison, WI |
|
Yesterday, 16:33 |
|
#3 |
Member
Amin Sheikhi
Join Date: Mar 2023
Posts: 31
Rep Power: 3 |
Dear Mr. Liang,
Thank you very much for your valuable guidance. I have already seen the Events UDF example in CONVERGE 3.2 UDF Manual, but I have no idea how to alter time to pressure. For instance, I tried to replace time with pressure like the code below. Although it is a crucial parameter in many engineering problems, it will notably benefit my entire research's progress. My manipulated Pressure Event UDF: CONVERGE_EVENT(cyclic_event_setup, IN(VALUE(CONVERGE_region_t, passed_regionA), VALUE(CONVERGE_region_t, passed_regionB))) { CyclicInfo *info = (CyclicInfo *)calloc(1, sizeof(CyclicInfo)); info->start = CONVERGE_simulation_time(); info->period = 0; info->duration = 0.01; CONVERGE_region_set_user_data(passed_regionA, "cyclic_event_info", info); CONVERGE_event_triangle_set_state(passed_regionA, passed_regionB, CONVERGE_EVENT_CLOSE); } CONVERGE_EVENT(cyclic_event, IN(VALUE(CONVERGE_region_t, passed_regionA), VALUE(CONVERGE_region_t, passed_regionB))) { CyclicInfo* info = (CyclicInfo*)CONVERGE_region_get_user_data( passed_regionA, "cyclic_event_info"); enum CONVERGE_EventState state = CONVERGE_EVENT_CLOSE; if(check_cyclic_active(info)) { state = CONVERGE_EVENT_OPEN; } CONVERGE_event_triangle_set_state(passed_regionA, passed_regionB, state); CONVERGE_precision_t *, pressure; CONVERGE_index_t num_event; CONVERGE_event_triangle_event_pressure(passed_regionA, passed_regionB, CONVERGE_EVENT_CLOSE, &pressure, &num_event); for(int i = 200; i < num_event; i++) { (void)pressure[i]; } free(pressure); } CONVERGE_bool_t check_cyclic_active(CyclicInfo* info) { CONVERGE_bool_t active = CONVERGE_FALSE; if(info->start + info->period <= CONVERGE_simulation_time()) { info->start += info->period; } if(info->start + info->duration > CONVERGE_simulation_time()) { active = CONVERGE_TRUE; } return active; } Best regards, Amin |
|
Yesterday, 19:10 |
|
#4 |
New Member
Mingyi Liang
Join Date: Sep 2022
Posts: 24
Rep Power: 4 |
Hi Amin,
Simply adding pressure into the code does not work. You need to read the pressure as a field variable first in your UDF function. Below is an example: CONVERGE_EVENT(pressure_event, IN(VALUE(CONVERGE_region_t, region1), VALUE(CONVERGE_region_t, region2), FIELD(CONVERGE_precision_t*, pressure))) { enum CONVERGE_EventState state = CONVERGE_event_triangle_get_state(region1, region2); //get the current state CONVERGE_precision_t* pressure_criterion = 101325; CONVERGE_precision_t* p_region1; CONVERGE_precision_t* p_region2; //find a way to calculate p_region1 and p_region2 based on your application. The calculation is not written here. You need to get the value of p_region1 and p_region2 for the following code if (abs(p_region1-p_region2) > pressure_criterion && state == CONVERGE_EVENT_CLOSE) { state = CONVERGE_EVENT_OPEN; converge_event_triangle_set_state(region1, region2, state); } else if (abs(p_region1-p_region2) <= pressure_criterion && state == CONVERGE_EVENT_OPEN) { state = CONVERGE_EVENT_CLOSE; converge_event_triangle_set_state(region1, region2, state); converge_event_triangle_set_state(region1, region2, state); } } In this code, I did not calculate p_region1 and p_region2, so you cannot directly use it as is. You need to find a way to calculate the volume-averaged pressure in each region by looping through all cells in each region, or calculate the averaged pressure of the cells on two sides of the interface.Please let me know if you have any questions. ----------------------------------------------------------------------------- Mingyi Liang Senior Research Engineer - Applications Convergent Science Madison, WI |
|
Today, 05:58 |
|
#5 |
Member
Amin Sheikhi
Join Date: Mar 2023
Posts: 31
Rep Power: 3 |
Dear Mr. Liang,
I truly appreciate your invaluable help with my modeling and experiments. Your guidance has been a tremendous support. Thank you so much for your kindness and generosity. Wishing you continued success in your work and good health always. Best regards, Amin |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Solver parameters to solve convergence issue | WilliamH | SU2 | 5 | February 5, 2021 07:19 |
SU2 Inviscid Hypersonic Solver Settings | jclegg | SU2 | 2 | April 10, 2019 12:35 |
How to read multiphase parameters in creatFields from Transportproperties ? | Amirhosseinesh | OpenFOAM Programming & Development | 4 | October 12, 2018 11:28 |
Domain and Material Settings For Nanofluid Based Heat Transfer | Shomaz ul Haq | CFX | 44 | January 3, 2018 18:29 |
Strange residuals of the Density Based Solver | Pat84 | FLUENT | 0 | October 22, 2012 16:59 |