CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   WARNING: Automatically switched to run in parallel -t1 mode. (https://www.cfd-online.com/Forums/fluent/214612-warning-automatically-switched-run-parallel-t1-mode.html)

ERA February 7, 2019 01:41

WARNING: Automatically switched to run in parallel -t1 mode.
 
Hello,
I am getting this warning when I start Fluent to run a serial model
** WARNING: Automatically switched to run in parallel -t1 mode. **
** Detected non-parallelized UDF usage, enabling parallel usage. **
** If you encounter any issues, please re-run with -t0 flag. **

Then when I initialize the solution, I get the following error
Node 0: Process xxxx: Received signal SIGSEGV
MPI rank 0 exited before MPI_Finalize with status 2
The fl process could not be started

Then automatically Fluent closes

Any suggestions for how to fix this issue? and how to force Fluent to run in serial?

Thanks

LuckyTran February 7, 2019 11:23

How to run in serial

Quote:

Originally Posted by ERA (Post 724025)
** If you encounter any issues, please re-run with -t0 flag. **


The problem is you have a (probably old) udf which is not parallelized and needs to be.

ERA February 7, 2019 12:08

Thanks, LuckyTran for your reply. I do not want to run in parallel. I defined the model initially as a serial one. I want to stop Fluent from automatically running parallel. I only have this issue after my license expired and had to install a new license for the same version (18.2)

LuckyTran February 7, 2019 12:20

It's not a licensing problem. Newer versions of Fluent now only run in parallel (since version 18.something). A result of that is now all UDF's must be parallel. If you want the original serial mode, you have to launch Fluent from a command line and pass the -t0 flag. If you launch from the GUI and click the serial box, it's actually still running in parallel but with 1 process. The short term solution is to use the -t0 flag. The long term solution is to fix your udf.


Did you suddenly switch to a newer version of Fluent? Going back to the old version might also be a workaround.

ERA February 7, 2019 12:39

Thanks, LuckyTran. I did not change the version. I was running with 18.2 with no issue. Then The license expired and installed a new license for the same version and start having this issue.

LuckyTran February 7, 2019 12:54

I just learned that from the GUI you can start Fluent in parallel mode with 0 nodes (put 0 and not 1) and that will also launch serial Fluent. Do not select serial because that now launches parallel 1 and not parallel 0.


I also found this really useful guide on parallelization of UDFs.

ERA February 7, 2019 13:22

I ran Fluent from "VS2015 x86 x64 Cross Tools Command Prompt" using the following command
"C:\Program Files\ANSYS Student\v182\fluent\ntbin\win64\fluent.exe" -t0
Then Fluent open, and I read the .cas file. However, when I initialize the solution, it is still giving the same issue "automatically running in parallel"

Any suggestion?

LuckyTran February 7, 2019 13:29

Probably you're still not launching in serial.


That shouldn't have worked anyway because you still need to pass the 2d/3d/2ddp/3ddp flag. The fact that Fluent opened means something is happening implicitly under the hood. Unfortunately I don't know enough about your setup to help you any here.

ERA February 7, 2019 13:49

Both ways work. However, after initialization, I got a new error
chip-exec: anisotropic_diffusivity: wrong return type: float udf function expected
Error: received a fatal signal (Segmentation fault).

#include "udf.h"

/* case-dependent constants */
#define fluid_thread_ID 2 /* thread ID of the fluid cell zone */
#define inlet_thread_ID 5 /* thread ID of the inlet boundary condition */
#define outlet_thread_ID 7 /* thread ID of the outlet boundary condition */
#define i_acid 0 /* species index of the acid */

/* acid/solid property-dependent constants in SI units*/
#define beta 1. /* slope of the curve in the permeability porosity relation */
#define Sh_infinity 3.0 /* asymptotic Sherwood number for the pore */
#define D_m 3.6e-9 /* molecular diffusivity of the acid m2/s */
#define r_p0 10.e-6 /* initial pore radius */
#define v_acid 2.0 /* stoichiometric coefficient of the chemical reaction */
#define k_s 2.1e-3 /* surface reaction rate constant */
#define a_0 5000.0 /* initial interfacial area available for reaction per unit volume of the medium */
#define rho_s 2.71e+3 /* density of the solid phase */
#define m 1. /* pore length to diameter ratio */
#define alpha_os 0.5 /* numerical constant that depends upon the structure of the carbonate under consideration */
#define lambda_X 0.5 /* numerical constant that depends upon the structure of the carbonate under consideration */
#define lambda_T 0.1 /* numerical constant that depends upon the structure of the carbonate under consideration */
#define E_a 62760. /* activation energy for the reaction */
#define R 8.3144598 /* universal gas constant */
#define k_0 20.2e-15 /* initial permeability*/

int test_x = 0;

DEFINE_ON_DEMAND(export_volumes)
{
Domain *d = Get_Domain(1);
Thread *t = Lookup_Thread(d, 2);
cell_t c;
FILE *fp;

fp = fopen("volume.txt", "w");
begin_c_loop(c, t)
{
fprintf(fp, "%f %f\n", C_VOLUME(c, t), C_UDMI(c, t, 0));
}
end_c_loop(c, t)
fclose(fp);
}

DEFINE_INIT(initialize_UDM, d)
{
Thread *t = Lookup_Thread(d, fluid_thread_ID);
cell_t c;
FILE *fp;
int cell_ID;
float phi, k; /* these must be type "float" to be properly read from the data file, not type "real" */

fp = fopen("data.txt", "r");
begin_c_loop(c, t)
{
fscanf(fp, "%d %f %f", &cell_ID, &phi, &k);
C_UDMI(c, t, 0) = C_UDMI(c, t, 1) = C_UDMI(c, t, 2) = phi;
C_UDMI(c, t, 4) = k;
/* (phi / 0.2 * pow((phi * (1 - 0.2)) / (0.2 * (1 - phi)), 2 * beta); /* permeability */
C_UDMI(c, t, 3) = k_0;
C_UDMI(c, t, 6) = r_p0;
C_UDMI(c, t, 7) = a_0;
C_UDMI(c, t, 8) = C_UDSI(c, t, 0);
C_UDMI(c, t, 9) = C_T(c, t);
}
end_c_loop(c, t)
fclose(fp);
}

DEFINE_ANISOTROPIC_DIFFUSIVITY (anisotropic_diffusivity, c, t, i, dmatrix)
{
real r_p = C_UDMI(c, t, 6);
real phi = C_UDMI(c, t, 2);
real rho_f = C_R(c, t);

real u = sqrt(pow(C_U(c, t), 2) + pow(C_V(c, t), 2) + pow(C_W(c, t), 2));

real D_eX = alpha_os * D_m + ((2 * lambda_X * u * r_p) / phi);
real D_eT = alpha_os * D_m + ((2 * lambda_T * u * r_p) / phi);
dmatrix[0][0] = rho_f * D_eT;
dmatrix[1][1] = rho_f * D_eX;
dmatrix[2][2] = rho_f * D_eT;
}

/* legacy */
DEFINE_DIFFUSIVITY(diffusivity, c, t, i)
{
real D = D_m * C_R(c, t);
return D;
}

DEFINE_PROFILE(porosity_profile, t, i)
{
cell_t c;

begin_c_loop(c, t)
{
C_PROFILE(c, t, i) = C_UDMI(c, t, 2);
}
end_c_loop(c, t)
}

DEFINE_PROFILE(viscous_resistance_profile, t, i)
{
cell_t c;

begin_c_loop(c, t)
{
C_PROFILE(c, t, i) = 1 / C_UDMI(c, t, 4); /* viscous resistance = inverse of permeability */
}
end_c_loop(c, t)
}

DEFINE_SOURCE(acid_sink, c, t, dS, eqn)
{
dS[eqn] = 0.;
return C_UDMI(c, t, 5);
}

/* called in DEFINE_ADJUST and EXECUTE_AT_END */
void reaction_model(Domain *d)
{
Thread *t = Lookup_Thread(d, fluid_thread_ID);
cell_t c;
real dt = CURRENT_TIMESTEP;

begin_c_loop(c, t)
{
real phi_0 = C_UDMI(c, t, 0);
real phi_prev = C_UDMI(c, t, 1);
/*real k_0 = C_UDMI(c, t, 3);*/
real k = C_UDMI(c, t, 4);
real r_p = C_UDMI(c, t, 6);
real a_v = C_UDMI(c, t, 7);
real T_0 = C_UDMI(c, t, 9);

real mu = C_MU_L(c, t); /* dynamic viscosity */
real rho_f = C_R(c, t); /* density of the fluid phase */
real Y_acid = C_UDSI(c, t, 0); /* mass fraction of acid */
real u_velocity = C_U(c, t);
real v_velocity = C_V(c, t);
real w_velocity = C_W(c, t);
real T = C_T(c, t);

real v = mu / rho_f; /* kinematic viscosity */
real u = sqrt(pow(u_velocity, 2) + pow(v_velocity, 2) + pow(w_velocity, 2)); /* magnitude of Darcy velocity */
real Re_p = (2 * u * r_p) / v; /* pore Reynolds number */
real Sc = v / D_m; /* Schimdt number */
real k_ratio = exp(-E_a / (R * T)) / exp(-E_a / (R * T_0)); /* Arrhenius reaction rate constant ratio */
real k_s_adjusted = k_s * k_ratio; /* k_s adjusted for current temperature */
real k_c = (Sh_infinity + (0.7 / sqrt(m)) * sqrt(Re_p) * pow(Sc, 1 / 3)) * (D_m / (2 * r_p)); /* local mass-transfer coefficient */
real k_eff = ((k_c * k_s_adjusted) / (k_c + k_s_adjusted)) * a_v; /* effective dissolution rate constant */
real C = Y_acid * rho_f; /* mass concentration of the acid */
real source = -k_eff * C; /* acid sink term, models the reaction of acid */
real phi = ((v_acid * k_eff * C) / rho_s) * dt + phi_prev; /* porosity */
real phi_change=phi/phi_0; /*ratio of current over initial porosity*/

k = k_0 * (phi / phi_0) * pow((phi * (1 - phi_0)) / (phi_0 * (1 - phi)), 2 * beta); /* permeability */
r_p = r_p0 * sqrt((k * phi_0) / (k_0 * phi)); /* pore radius */
a_v = a_0 * ((phi * r_p0) / (phi_0 * r_p)); /* interfacial area available for reaction per unit volume of the medium */

C_UDMI(c, t, 2) = phi;
C_UDMI(c, t, 4) = k;
C_UDMI(c, t, 5) = source;
C_UDMI(c, t, 6) = r_p;
C_UDMI(c, t, 7) = a_v;
C_UDMI(c, t, 8) = Y_acid;
C_UDMI(c, t, 10) = phi_change;
}
end_c_loop(c, t)
}

DEFINE_ADJUST(run_reaction, d)
{
reaction_model(d);
}

DEFINE_EXECUTE_AT_END(update_porosity)
{
Domain *d = Get_Domain(1);
Thread *t = Lookup_Thread(d, fluid_thread_ID);
cell_t c;

reaction_model(d);

begin_c_loop(c, t)
{
C_UDMI(c, t, 1) = C_UDMI(c, t, 2); /* updates previous time step porosity */
C_UDMI(c, t, 9) = C_T(c, t);
}
end_c_loop(c, t)
}

DEFINE_EXECUTE_AT_END(interrupt)
{
/*Domain *d = Get_Domain(1);
Thread *t_inlet = Lookup_Thread(d, inlet_thread_ID);
Thread *t_outlet = Lookup_Thread(d, outlet_thread_ID);
cell_t c;
real inlet_pressure, outlet_pressure; */

test_x = test_x + 1;
if (test_x > 1) RP_Set_Integer("interrupt/flag", 1);

/* begin_c_loop(c, t_outlet)
{
if (C_P(c, t_outlet) / C_P(c, t_inlet) >= 1/100)
{
RP_Set_Integer("interrupt/flag", 1);
}
}
end_c_loop(c, t_outlet) */
}

LuckyTran February 7, 2019 14:25

You are using a lot of C_UDMI calls which requires you to allocate this user-defined memory beforehand. It looks like you need 10 of them. Did you forget to do this?


Also I think you udf can be parallized quite easily by just fixing the fopen fscanf and fprintf statements. For example: follow this guide for writing files in parallel. Reading files is kinda the same.

ERA February 7, 2019 16:17

I defined the number of UDM to 10. but I still get this error
chip-exec: anisotropic_diffusivity: wrong return type: double udf function expected
Error: received a fatal signal (Segmentation fault).

any suggestions?

LuckyTran February 7, 2019 17:06

Need more info... What are you hooking these profiles to?

This UDF worked before and now suddenly doesn't? I feel like you are purposely misleading be down a rabbit hole with debugging your UDF and it does not make me happy.

ERA February 8, 2019 13:08

Quote:

Originally Posted by LuckyTran (Post 724108)
Need more info... What are you hooking these profiles to?

This UDF worked before and now suddenly doesn't? I feel like you are purposely misleading be down a rabbit hole with debugging your UDF and it does not make me happy.

Thanks, LuckyTran for your help. Sorry if I bothered you.

Quick update:
The UDF that includes UDS was working before I reinstall the new license. The same version of 18.2
Meanwhile, I have a UDF that does not include any UDS and it works fine. I can initialize the solution and calculations with no issues. Regarding automatically switching to parallel, there are no issues even if start Fluent as serial.

My conclusion is the new update of 18.2 needs tweaking of the UDF with UDS. I had the same issue when I upgraded before from 16.2 to 18.2.


All times are GMT -4. The time now is 16:54.