// Parallel EDEM CFD Coupling for ANSYS FLUENT - Version 1.0
// Copyright 2013 ANSYS, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Portions of this software were developed in a collaboration between
// Adam Anderson of ANSYS, Inc. and Andrew Hobbs of Astec Inc. A user
// community forum for sharing experiences and code improvements is
// maintained at
//
// http://www.dem-solutions.com/forum
#include "edemUdf.h"
#include "forceCalculations.h"
#include "heatCalculations.h"
#include "prf.h"
static int DEM_ID = 3;
/* EDEM external global variables */
/* Global vars for Particle details */
const int MAX_PARTICLE_TYPES; /* The maximum number of particle types that can be allocated for */
int g_numParticles = 0; /* Number of particles. */
int g_numParticleTypes = 0; /* Number of particle types */
int g_NumDiscreteElements = 0;
int g_NumParticleSamplePoints = 20; /* Number of samples taken from each particle*/
cxboolean g_DEMCoupled = FALSE; /* TRUE if EDEM is started and we have a valid license */
cxboolean g_heatRegistered = FALSE; /* Indicates if heat properties are registered */
cxboolean g_FCMInitialised = FALSE; /* Perform checks on the first iteration */
int g_temperatureIndex = -1; /* Property index for temperature */
int g_heatFluxIndex = -1; /* Property index for heat flux */
FILE *g_debugFile = 0;
/* Model Settings */
int g_linkType; /* selected coupling method */
int g_dragModel; /* Selected drag model */
cxboolean g_saffLift; /* Saffman lift model */
cxboolean g_magLift; /* Magnus lift model */
double g_VolumeURF; /* Volume under-relaxation factor */
double g_MomentumURF; /* Momentum under-relaxation factor */
double g_heatURF; /* Heat under-relaxation factor */
cxboolean g_torque; /* Option for fluid-induced torque */
cxboolean g_convectiveHeatOption; /* Option for convective heat transfer */
int g_convectiveHeatModel; /* Convective heat transfer model */
double g_heatLiExp; /* Exponential constant for Li & Mason model that require user's input */
cxboolean g_radiativeHeatOption; /* Option for radiative heat transfer */
double g_emissivity; /* User input for the particle surface emissivity */
int g_FluidCells; /* the current number of Fluent cells */
int g_Threads; /* the current number of Fluent threads */
#if !RP_NODE
cxboolean registerHeatProperties(int *temperatureIndex, int *heatFluxIndex)
{
/* Properties to register for the heat transfer: temperature and heat flux */
int tempNumElements = 1; /* Define number of elements to the custom property */
int tempDataType = 0; /* Define the data type as a double using EDEMs index system */
int tempUnitType = 20; /* Define the unit type as temperature using EDEMs index system */
double initialTemp = 0.0; /* Define the starting temperature */
/*
* Heat flux is a special custom property. It has 2 elements:
* The first element is used by EDEM particle contacts for heat flux.
* The second element is used by the CFD package for fluid to particle
* heat flux. Even though the first entry will not be used here we are
* declaring the property here and therefore must declare both entries for
* EDEM to work correctly
*/
int heatFluxNumElements = 2; /* Define number of elements to the custom property */
int heatFluxDataType = 0; /* Define the data type as a double using EDEMs index system */
int heatFluxUnitType = 21; /* Define the unit type as heat flux using EDEMs index system */
double initialHeatFlux = 0.0; /* Define the starting heat flux */
/* Register temperature AND heat flux */
if (ADAPTOR_registerCustomProperty("Temperature", tempNumElements, tempDataType, tempUnitType, initialTemp, temperatureIndex) &&
ADAPTOR_registerCustomProperty("Heat Flux", heatFluxNumElements, heatFluxDataType, heatFluxUnitType, initialHeatFlux, heatFluxIndex))
return TRUE;
return FALSE;
}
#endif /* !RP_NODE */
/* When this udf library is first loaded we need to initialise EDEM */
void InitialiseEdem()
{
#if !RP_NODE
cxboolean success;
Message("Initialising EDEM-CFD Coupling Module for FLUENT. Please wait...\n");
/* Start EDEM and check we have a valid license */
/* ADAPTOR_initialiseEDEMCoupling(&success); */
ADAPTOR_init_connectEDEMCoupling(&success);
if(success)
{
Message("EDEM initialised - coupled solution available.\n");
g_DEMCoupled = TRUE;
}
else
{
Message("EDEM License Error: Cannot connect EDEM.\n");
Message("Coupled solution unavailable\n\n");
g_DEMCoupled = FALSE;
}
#endif /* !RP_NODE */
host_to_node_boolean_1(g_DEMCoupled);
/* Ensure we perform any necessary checks on the first iteration */
g_FCMInitialised = FALSE;
}
/* Clear particle data deletes held data and ensures the the correct
* custom properties are registered */
void clearParticleData()
{
#if !RP_NODE
ADAPTOR_clearParticleData();
/* If using heat transfer, register new properties */
/*
adam.anderson@ansys.com : Why does it need to register on clearing particles?
TEST by assuming heat properties already registered via EDEM
if(g_convectiveHeatOption || g_radiativeHeatOption)
{
if(!registerHeatProperties(&g_temperatureIndex, &g_heatFluxIndex))
{
Message("\n\nWARNING: Cannot register heat properties in clearParticleData .\n\n");
}
}
*/
#endif /* !RP_NODE */
g_heatRegistered = FALSE;
g_numParticles = 0;
}
/* The solution controls cover the optional relaxation factors and
* drag model options on the panel */
DEFINE_ON_DEMAND(update_solution_controls)
{
if(!g_DEMCoupled)
{
Message0("\n\nWARNING: EDEM hasn't been initialised and coupled solution is unavailable.\n");
return;
}
#if !RP_NODE
/* update the particle sample points */
g_NumParticleSamplePoints = RP_Get_Integer("edem/sample-points");
if(g_NumParticleSamplePoints <= 0) /* need minimum of 1 sample */
{
g_NumParticleSamplePoints = 1;
}
/* update the momentum, volume and heat transfer under relaxation factors */
g_MomentumURF = RP_Get_Float("edem/mtm-urf");
g_VolumeURF = RP_Get_Float("edem/volume-urf");
g_heatURF = RP_Get_Float("edem/heat-urf");
/* Get the selected drag model
Freestream = 0
Ergun + Wen Yu = 1
Di Felice = 2*/
g_dragModel = RP_Get_Integer("edem/drag-model");
/* Get the Saffman lift model */
g_saffLift = RP_Get_Boolean("edem/saffman-lift");
/* Get the Magnus lift model */
g_magLift = RP_Get_Boolean("edem/magnus-lift");
/* Include fluid-induced torque? */
g_torque = RP_Get_Boolean("edem/torque");
/* Use convective heat transfer ? */
g_convectiveHeatOption = RP_Get_Boolean("edem/heat-convective");
/* Get the selected convective heat transfer model
Ranz & Marshall = 0
Gunn = 1
Li & Mason = 2*/
g_convectiveHeatModel = RP_Get_Integer("edem/convectiveheat-model");
/* Exponential constant for Li & Mason */
g_heatLiExp = RP_Get_Float("edem/heatlimason-exp");
/* Use radiative heat transfer ? */
g_radiativeHeatOption = RP_Get_Boolean("
- 1
- 2
前往页