TAGGED: capillary-force, fluent
-
-
August 2, 2024 at 7:01 am
智敏 徐
SubscriberWe currently use porous media to make capillary cores, and UDFs to add capillary force to porous media so that they can be aspirated, but the code we write can be imported normally but crashes as soon as we calculate it
#include "udf.h"#define PARAMETER_P 1.0 // 替换为实际的参数值#define UDS_INDEX 0#define UDM_INDEX 0#define USR_SOURCE_INDEX 0DEFINE_ADJUST(adjust_and_store_gradient, domain){Thread *t;cell_t c;face_t f;real grad[ND_ND]; // 存储梯度的数组domain = Get_Domain(2); // 假设domain_ID为2thread_loop_c(t, domain){begin_c_loop(c, t){C_UDMI(c, t, UDM_INDEX) = 0.0; // 初始化UDMC_UDSI(c, t, UDS_INDEX) = C_VOF(c, t); // 设置UDS为当前体积分数if (C_UDSI(c, t, UDS_INDEX) > 0.0 && C_UDSI(c, t, UDS_INDEX) < 1.0){F_GRAD_CELL_THREAD(c, t, &C_UDSI(c, t, UDS_INDEX), grad);C_UDMI(c, t, UDM_INDEX) = NV_MAG(grad); // 计算梯度的模并存储到UDM}}end_c_loop(c, t)}}DEFINE_SOURCE(apply_momentum_source, c, t_cell, dS, eqn){real p = PARAMETER_P; // 给定的参数preal vol_frac = C_UDSI(c, t_cell, UDS_INDEX); // 体积分数real grad_mag = C_UDMI(c, t_cell, UDM_INDEX); // 体积分数梯度的模real F = 2.0 * p * vol_frac * grad_mag; // 根据公式 F = 2 * p * vol_frac * grad_mag 计算动量源项if (vol_frac > 0.0 && vol_frac < 1.0){dS[2] += F; // 在所有方向上添加动量源项}return 0;} -
August 2, 2024 at 10:49 am
Rob
Forum ModeratorThere may be a more useful error at the top of the list. Check all macros are valid - where did F_GRAD_CELL_THREAD come from?
-
August 2, 2024 at 12:26 pm
ALEXANDRE COSTA
SubscriberHi,
I am also interested in this type of "crash".
-
August 2, 2024 at 2:18 pm
智敏 徐
Subscriber我该如何修改它?
-
August 2, 2024 at 2:21 pm
智敏 徐
SubscriberHow can I modify this?
-
August 2, 2024 at 2:23 pm
智敏 徐
SubscriberHow do you change this UDF?
-
August 5, 2024 at 9:39 am
Rob
Forum ModeratorMaybe start by answering my previous question?
-
Viewing 6 reply threads
- You must be logged in to reply to this topic.
Ansys Innovation Space
Trending discussions
Top Contributors
-
2928
-
970
-
852
-
599
-
591
Top Rated Tags
© 2025 Copyright ANSYS, Inc. All rights reserved.
Ansys does not support the usage of unauthorized Ansys software. Please visit www.ansys.com to obtain an official distribution.