Beispiel #1
0
int main(int argc, char **argv)
{
    Py_Initialize();
    PyImport_AppendInittab("spam", &PyInit_spam);

    PyRun_SimpleString("from time import time,ctime\n"
                       "print('Today is', ctime(time()))\n");
    PyRun_SimpleString("import spam\n"
                       "xx = spam.SpamCall('abcd')\n"
                       "print(xx)\n");
    PyRun_SimpleString("with open('stackless.py') as ss: exec(ss.read())");
    Py_Finalize();

    ObjectPtrTable::Instance()->Init(10);
    
    TestObj stack_obj;
    TestObj *p_obj = new TestObj;
    ObjectHandler<TestObj> hda(stack_obj);
    ObjectHandler<TestObj> hdb(*p_obj);
    TestObj *stack_obj_ptr = hda.ToObject();
    TestObj *heap_obj_ptr = hdb.ToObject();
    delete p_obj;
    p_obj = new TestObj;
    ObjectHandler<TestObj> hdc(*p_obj);
    heap_obj_ptr = hdb.ToObject();
    if (hdc == hdb) {
        return false;
    }
    else {
        TestObj *heap_obj_ptr_c = hdc.ToObject();
    }
    return 0;
}
Beispiel #2
0
void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
{
    bool writeResults = !args.optionFound("noWrite");

    IOobject Theader
    (
        "T",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ
    );

    IOobject qheader
    (
        "q",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ
    );

    IOdictionary transportProperties
    (
        IOobject
        (
            "transportProperties",
            runTime.constant(),
            mesh,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        )
    );

    dimensionedScalar Cpa
    (
         transportProperties.lookup("Cpa")
    );

    dimensionedScalar Cpv
    (
         transportProperties.lookup("Cpv")
    );

    dimensionedScalar lambda
    (
         transportProperties.lookup("lambda")
    );

    // Fluid density
    dimensionedScalar rho
    (
        transportProperties.lookup("rho")
    );


    dimensionedScalar TRef
    (
         transportProperties.lookup("TRef")
    );

    dimensionedScalar qRef
    (
         transportProperties.lookup("qRef")
    );

    if (qheader.headerOk() && Theader.headerOk())
    {
        Info<< "    Reading q" << endl;
        volScalarField q(qheader, mesh);

        Info<< "    Reading T" << endl;
        volScalarField T(Theader, mesh);

        // specific enthalpy of dry air hda - ASHRAE 1.8
        volScalarField hda("hda", rho*Cpa*T-rho*Cpa*TRef);

        // specific enthalpy of dry vapor
        volScalarField hdv("hdv", rho*q*(lambda + Cpv*T) - rho*qRef*(lambda + Cpv*TRef));


        // specific enthalpy for moist air hmoist - ASHRAE 1.8
        volScalarField hmoist("hmoist", hda + hdv);

        if (writeResults)
        {
            hda.write();
            hdv.write();
            hmoist.write();
        }
        else
        {
            Info<< "        Min hda    : " << min(hda).value() << " [J/m3]"
                << "\n        Max hda    : "<< max(hda).value() << " [J/m3]" << endl;
            Info<< "        Min hdv    : " << min(hdv).value() << " [J/m3]"
                << "\n        Max hdv    : "<< max(hdv).value() << " [J/m3]" << endl;
            Info<< "        Min hmoist : " << min(hmoist).value() << " [J/m3]"
                << "\n        Max hmoist : "<< max(hmoist).value() << " [J/m3]" << endl;
        }


        // print results
       //
      //   surfaceScalarField hdaBoundary =
      //     fvc::interpolate(hda);
       //
      //   const surfaceScalarField::GeometricBoundaryField& patchhda =
      //       hdaBoundary.boundaryField();
      //   // const surfaceScalarField::GeometricBoundaryField& patchCondHeatFlux =
      //   //     condHeatFluxNormal.boundaryField();
      //   // const surfaceScalarField::GeometricBoundaryField& patchTurbHeatFlux =
      //   //     turbHeatFluxNormal.boundaryField();
      //   // const surfaceScalarField::GeometricBoundaryField& patchTotHeatFlux =
      //   //     totHeatFluxNormal.boundaryField();
       //
      //   Info<< "\nHeat at the boundaries " << endl;
      //   forAll(patchhda, patchi)
      //   {
      //       if ( (!isA<emptyFvPatch>(mesh.boundary()[patchi])) &&
      //            (mesh.boundary()[patchi].size() > 0) )
      //       {
      //           Info<< "    "
      //               << mesh.boundary()[patchi].name()
      //               << "\n        Total area [m2]                   : "
      //               << gSum(mesh.magSf().boundaryField()[patchi])
      //               << "\n        Integral Energy [J] : "
      //               << gSum
      //                  (
      //                      mesh.magSf().boundaryField()[patchi]
      //                     *patchhda[patchi]
      //                  )
      //               << nl << endl;
      //       }
      //  }
      //  Info << endl;

    }
    else
    {
        Info<< "    No q or No T" << endl;
    }

    Info<< "\nEnd\n" << endl;
}