Esempio n. 1
0
void *_destroy_table(void)
{
  int i;
  lookup_table(i, Ttop());
  ATtableDestroy(ST_tables[i]);
  ATtableRemove(ST_table_table, Ttop());
  return NULL;
}
Esempio n. 2
0
void *_int(void)
{ int k;
  double r; 
  if(ATmatch(Ttop(), "<int>", &k))
    {
      return NULL; 
    } 
  else if(ATmatch(Ttop(), "<real>", &r))
    {
      Tset((ATerm) ATmakeInt((int)r));
      return NULL; 
    } 
  else return fail_address; 
}
Esempio n. 3
0
void *_table_keys(void)
{
  int i;
  lookup_table(i, Ttop());
  Tset(list_to_consnil((ATerm)ATtableKeys(ST_tables[i])));
  return NULL;  
}
Esempio n. 4
0
void *_is_real(void)
{ if(ATgetType(Ttop()) == AT_REAL)
    {
      return NULL; 
    } 
  else return fail_address; 
}
Esempio n. 5
0
void *_is_int(void)
{ if(ATgetType(Ttop()) == AT_INT)
    {
      return NULL; 
    } 
  else return fail_address; 
}
Esempio n. 6
0
void *_is_string()
{ char *k;
  if(ATmatch(Ttop(), "<str>", &k))
    {
      return NULL; 
    } 
  else return fail_address; 
}
Esempio n. 7
0
void *_sin(void)
{ int k;
  double r; 
  if(ATmatch(Ttop(), "<int>", &k))
    {
      r = (double)k;
    } 
  else if(ATmatch(Ttop(), "<real>", &r))
    {
      ;
    } 
  else 
    return fail_address; 

  Tset((ATerm) ATmakeReal(sin(r)));
  return NULL;
}
Esempio n. 8
0
int number_pair(int *k, int *l, double *r1, double *r2)
{  
  if(ATmatch(Ttop(), "TCons(<int>, TCons(<int>, TNil))", k, l))
    return 1; 
  else if(ATmatch(Ttop(), "TCons(<real>, TCons(<real>, TNil))", r1, r2))
    return 2; 
  else if(ATmatch(Ttop(), "TCons(<int>, TCons(<real>, TNil))", k, r2))
    { 
      *r1 = (double)*k;	
      return 3; 
    }
  else if(ATmatch(Ttop(), "TCons(<real>, TCons(<int>, TNil))", r1, l))
    { 
      *r2 = (double)*l;	
      return 4; 
    }
  else return 0;
}
Esempio n. 9
0
void *_mod(void)
{ int k, l;
  if(ATmatch(Ttop(), "TCons(<int>, TCons(<int>, TNil))", &k, &l))
    { 
      Tset((ATerm) ATmakeInt(k % l));	
      return NULL;
    } 
  else return fail_address; 
}
Esempio n. 10
0
void *_mkterm()
{ 
  char *f;
  ATermList ts;
  MatchFunFC("TCons", 2, &&mkterm_fail);
  Arg(0);
  if(ATisString(Ttop()))
    { 
      f = t_string(Ttop());
      Tpop();
      Arg(1);
      Tdrop();
      MatchFunFC("TCons", 2, &&mkterm_fail);
      Arg(0);
      ts = (ATermList) consnil_to_list_shallow(Ttop());
      Tpop();
      Tset((ATerm) ATmakeApplList(ATmakeSymbol(f, ATgetLength(ts), ATfalse), ts));
    }
  else if(ATgetType(Ttop()) == AT_REAL)
Esempio n. 11
0
void *_table_remove(void)
{
  ATerm table, key;
  int i;
  if(MatchPair(Ttop(), &table, &key))
    {
      lookup_table(i, table);
      ATtableRemove(ST_tables[i], key);
      return NULL;
    }
  return fail_address;
}
Esempio n. 12
0
void *_table_put(void)
{
  ATerm table, key, value;
  int i;
  /* ATfprintf(stderr, "<table-put>%t\n", Ttop()); */
  if(MatchTriple(Ttop(), &table, &key, &value))
    {
      /* ATfprintf(stderr, "<table-put>(%t,%t,%t)\n", table, key, value); */
      lookup_table(i, table);
      ATtablePut(ST_tables[i], key, value);
      return NULL;
    }
  return fail_address;
}
Esempio n. 13
0
void *_create_table(void)
{
  if(ST_table_table == NULL)
    ST_table_table = ATtableCreate(100, 80);
  
  if(ST_free_table >= NR_TABLES - 1)
    {
      ATfprintf(stderr, "create-table: too many tables\n");
      exit(1);
    }
  /* ATfprintf(stderr, "<create-table>%t = %d\n", Ttop(), ST_free_table); */
  ST_tables[ST_free_table] = ATtableCreate(117,75);
  ATtablePut(ST_table_table, Ttop(), (ATerm)ATmakeInt(ST_free_table));
  ST_free_table++;
  return NULL;
}
Esempio n. 14
0
void *_table_get(void)
{
  ATerm table, key, value;
  int i;
  if(MatchPair(Ttop(), &table, &key))
    {
      /* ATfprintf(stderr, "<table-get>(%t,%t)\n", table, key); */
      lookup_table(i, table);
      value = ATtableGet(ST_tables[i], key);
      if(value == NULL)
	return fail_address;
      else
	Tset(value);
      return NULL;
    }
  return fail_address;
}
Esempio n. 15
0
int main(int argc, char *argv[])
{
#   include "setRootCase.H"
#   include "createTime.H"
#   include "createMesh.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //


// Read in the existing solution files.   
Info << "Reading field U" << endl;
volVectorField U
(
    IOobject
    (
        "U",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ,
        IOobject::NO_WRITE
    ),
    mesh
);

Info << "Reading field T" << endl;
volScalarField T
(
    IOobject
    (
        "T",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ,
        IOobject::NO_WRITE
    ),
    mesh
);

Info << "Reading field p_rgh" << endl;
volScalarField p_rgh
(
    IOobject
    (
        "p_rgh",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ,
        IOobject::NO_WRITE
    ),
    mesh
);


// Compute the velocity flux at the faces.  This is needed
// by the laminar transport model.
Info<< "Creating/Calculating face flux field, phi..." << endl;
surfaceScalarField phi
(
    IOobject
    (
        "phi",
        runTime.timeName(),
        mesh,
        IOobject::READ_IF_PRESENT,
        IOobject::AUTO_WRITE
    ),
    linearInterpolate(U) & mesh.Sf()
);


// Read the gravitational acceleration.  This is needed 
// for calculating dp/dn on boundaries.
Info << "Reading gravitational acceleration..." << endl;
uniformDimensionedVectorField g
(
    IOobject
    (
        "g",
        runTime.constant(),
        mesh,
        IOobject::MUST_READ,
        IOobject::NO_WRITE
    )
);


// Read the value of TRef in the transportProperties file.
singlePhaseTransportModel laminarTransport(U, phi);
dimensionedScalar TRef(laminarTransport.lookup("TRef"));


// Use Tref and the T field to compute rhok, which is needed
// to calculate dp/dn on boundaries.
Info<< "Creating the kinematic density field, rhok..." << endl;
volScalarField rhok
(
    IOobject
    (
        "rhok",
        runTime.timeName(),
        mesh
    ),
    1.0 - (T - TRef)/TRef
);


// Get access to the input dictionary.
IOdictionary setFieldsABLDict
(
    IOobject
    (
        "setFieldsABLDict",
        runTime.time().system(),
        runTime,
        IOobject::MUST_READ,
        IOobject::NO_WRITE
    )
);



// Read in the setFieldsABLDict entries.
word velocityInitType(setFieldsABLDict.lookup("velocityInitType"));
word temperatureInitType(setFieldsABLDict.lookup("temperatureInitType"));
word tableInterpTypeU(setFieldsABLDict.lookupOrDefault<word>("tableInterpTypeU","linear"));
word tableInterpTypeT(setFieldsABLDict.lookupOrDefault<word>("tableInterpTypeT","linear"));
scalar deltaU(setFieldsABLDict.lookupOrDefault<scalar>("deltaU",1.0));
scalar deltaV(setFieldsABLDict.lookupOrDefault<scalar>("deltaV",1.0));
scalar zPeak(setFieldsABLDict.lookupOrDefault<scalar>("zPeak",0.03));
scalar Uperiods(setFieldsABLDict.lookupOrDefault<scalar>("Uperiods",4));
scalar Vperiods(setFieldsABLDict.lookupOrDefault<scalar>("Vperiods",4));
scalar xMin(setFieldsABLDict.lookupOrDefault<scalar>("xMin",0.0));
scalar yMin(setFieldsABLDict.lookupOrDefault<scalar>("yMin",0.0));
scalar zMin(setFieldsABLDict.lookupOrDefault<scalar>("zMin",0.0));
scalar xMax(setFieldsABLDict.lookupOrDefault<scalar>("xMax",3000.0));
scalar yMax(setFieldsABLDict.lookupOrDefault<scalar>("yMax",3000.0));
scalar zMax(setFieldsABLDict.lookupOrDefault<scalar>("zMax",1000.0));
scalar zRef(setFieldsABLDict.lookupOrDefault<scalar>("zRef",600.0));
bool useWallDistZ(setFieldsABLDict.lookupOrDefault<bool>("useWallDistZ",false));
bool scaleVelocityWithHeight(setFieldsABLDict.lookupOrDefault<bool>("scaleVelocityWithHeight",false));
scalar zInversion(setFieldsABLDict.lookupOrDefault<scalar>("zInversion",600.0));
scalar Ug(setFieldsABLDict.lookupOrDefault<scalar>("Ug",15.0));
scalar UgDir(setFieldsABLDict.lookupOrDefault<scalar>("UgDir",270.0));
scalar Tbottom(setFieldsABLDict.lookupOrDefault<scalar>("Tbottom",300.0));
scalar Ttop(setFieldsABLDict.lookupOrDefault<scalar>("Ttop",304.0));
scalar dTdz(setFieldsABLDict.lookupOrDefault<scalar>("dTdz",0.003));
scalar widthInversion(setFieldsABLDict.lookupOrDefault<scalar>("widthInversion",80.0));
scalar TPrimeScale(setFieldsABLDict.lookupOrDefault<scalar>("TPrimeScale",0.0));
scalar z0(setFieldsABLDict.lookupOrDefault<scalar>("z0",0.016));
scalar kappa(setFieldsABLDict.lookupOrDefault<scalar>("kappa",0.40));
List<List<scalar> > profileTable(setFieldsABLDict.lookup("profileTable"));
bool updateInternalFields(setFieldsABLDict.lookupOrDefault<bool>("updateInternalFields",true));
bool updateBoundaryFields(setFieldsABLDict.lookupOrDefault<bool>("updateBoundaryFields",true));

// Change the table profiles from scalar lists to scalar fields
scalarField zProfile(profileTable.size(),0.0);
scalarField UProfile(profileTable.size(),0.0);
scalarField VProfile(profileTable.size(),0.0);
scalarField TProfile(profileTable.size(),0.0);
forAll(zProfile,i)
{
   zProfile[i] = profileTable[i][0];
   UProfile[i] = profileTable[i][1];
   VProfile[i] = profileTable[i][2];
   TProfile[i] = profileTable[i][3];
}