CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > CONVERGE

Event settings based on other parameters

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By lmy_csi
  • 1 Post By lmy_csi

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 24, 2024, 11:46
Default Event settings based on other parameters
  #1
Member
 
Amin Sheikhi
Join Date: Mar 2023
Posts: 31
Rep Power: 3
Amin_ is on a distinguished road
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
Amin_ is offline   Reply With Quote

Old   Yesterday, 11:23
Default
  #2
New Member
 
Mingyi Liang
Join Date: Sep 2022
Posts: 24
Rep Power: 4
lmy_csi is on a distinguished road
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
Amin_ likes this.
lmy_csi is online now   Reply With Quote

Old   Yesterday, 16:33
Default
  #3
Member
 
Amin Sheikhi
Join Date: Mar 2023
Posts: 31
Rep Power: 3
Amin_ is on a distinguished road
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
Amin_ is offline   Reply With Quote

Old   Yesterday, 19:10
Default
  #4
New Member
 
Mingyi Liang
Join Date: Sep 2022
Posts: 24
Rep Power: 4
lmy_csi is on a distinguished road
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
Amin_ likes this.
lmy_csi is online now   Reply With Quote

Old   Today, 05:58
Default
  #5
Member
 
Amin Sheikhi
Join Date: Mar 2023
Posts: 31
Rep Power: 3
Amin_ is on a distinguished road
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
Amin_ 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
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


All times are GMT -4. The time now is 11:32.