예제 #1
0
// Construct from components
Foam::commonRailInjector::commonRailInjector
(
    const Foam::Time& t,
    const Foam::dictionary& dict
)
:
    injectorType(t, dict),
    propsDict_(dict.subDict(typeName + "Props")),
    position_(propsDict_.lookup("position")),
    direction_(propsDict_.lookup("direction")),
    d_(readScalar(propsDict_.lookup("diameter"))),
    mass_(readScalar(propsDict_.lookup("mass"))),
    injectionPressure_(readScalar(propsDict_.lookup("injectionPressure"))),
    T_(readScalar(propsDict_.lookup("temperature"))),
    nParcels_(readLabel(propsDict_.lookup("nParcels"))),
    X_(propsDict_.lookup("X")),
    massFlowRateProfile_(propsDict_.lookup("massFlowRateProfile")),
    velocityProfile_(massFlowRateProfile_),
    injectionPressureProfile_(propsDict_.lookup("injectionPressureProfile")),
    CdProfile_(massFlowRateProfile_),
    TProfile_(massFlowRateProfile_),
    averageParcelMass_(mass_/nParcels_),
    pressureIndependentVelocity_(false)
{

    // convert CA to real time
    forAll(massFlowRateProfile_, i)
    {
        massFlowRateProfile_[i][0] = t.userTimeToTime(massFlowRateProfile_[i][0]);
        velocityProfile_[i][0] = t.userTimeToTime(massFlowRateProfile_[i][0]);
    }
예제 #2
0
// Construct from components
Foam::unitInjector::unitInjector
(
    const Foam::Time& t,
    const Foam::dictionary& dict
)
:
    injectorType(t, dict),
    propsDict_(dict.subDict(typeName + "Props")),
    position_(propsDict_.lookup("position")),
    direction_(propsDict_.lookup("direction")),
    d_(readScalar(propsDict_.lookup("diameter"))),
    Cd_(readScalar(propsDict_.lookup("Cd"))),
    mass_(readScalar(propsDict_.lookup("mass"))),
    nParcels_(readLabel(propsDict_.lookup("nParcels"))),
    X_(propsDict_.lookup("X")),
    massFlowRateProfile_(propsDict_.lookup("massFlowRateProfile")),
    velocityProfile_(massFlowRateProfile_),
    injectionPressureProfile_(massFlowRateProfile_),
    CdProfile_(massFlowRateProfile_),
    TProfile_(propsDict_.lookup("temperatureProfile")),
    averageParcelMass_(mass_/nParcels_),
    pressureIndependentVelocity_(true)
{

    // check if time entries for soi and eoi match
    if (mag(massFlowRateProfile_[0][0]-TProfile_[0][0]) > SMALL)
    {
        FatalErrorIn
        (
            "unitInjector::unitInjector(const time& t, const dictionary dict)"
        )<< "start-times do not match for TemperatureProfile and "
         << " massFlowRateProfile." << nl << exit (FatalError);
    }

    if
    (
        mag(massFlowRateProfile_[massFlowRateProfile_.size()-1][0]
      - TProfile_[TProfile_.size()-1][0])
      > SMALL
    )
    {
        FatalErrorIn
        (
            "unitInjector::unitInjector(const time& t, const dictionary dict)"
        )<< "end-times do not match for TemperatureProfile and "
         << "massFlowRateProfile." << nl << exit(FatalError);
    }

    // convert CA to real time
    forAll(massFlowRateProfile_, i)
    {
        massFlowRateProfile_[i][0] =
            t.userTimeToTime(massFlowRateProfile_[i][0]);
        velocityProfile_[i][0] = massFlowRateProfile_[i][0];
        injectionPressureProfile_[i][0] = massFlowRateProfile_[i][0];
    }
// Construct from components
Foam::multiHoleInjector::multiHoleInjector
(
    const Foam::Time& t,
    const Foam::dictionary& dict
)
:
    injectorType(t, dict),
    propsDict_(dict.subDict(typeName + "Props")),
    centerPosition_(propsDict_.lookup("position")),
    xyAngle_(readScalar(propsDict_.lookup("xyAngle"))),
    zAngle_(readScalar(propsDict_.lookup("zAngle"))),
    nHoles_(readLabel(propsDict_.lookup("nHoles"))),
    umbrellaAngle_(readScalar(propsDict_.lookup("umbrellaAngle"))),
    nozzleTipDiameter_(readScalar(propsDict_.lookup("nozzleTipDiameter"))),
    angleSpacing_(propsDict_.lookup("angleSpacing")),
    d_(readScalar(propsDict_.lookup("diameter"))),
    Cd_(readScalar(propsDict_.lookup("Cd"))),
    mass_(readScalar(propsDict_.lookup("mass"))),
    nParcels_(readLabel(propsDict_.lookup("nParcels"))),
    X_(propsDict_.lookup("X")),
    massFlowRateProfile_(propsDict_.lookup("massFlowRateProfile")),
    velocityProfile_(massFlowRateProfile_),
    injectionPressureProfile_(massFlowRateProfile_),
    CdProfile_(massFlowRateProfile_),
    TProfile_(propsDict_.lookup("temperatureProfile")),
    averageParcelMass_(nHoles_*mass_/nParcels_),
    direction_(nHoles_),
    position_(nHoles_),
    pressureIndependentVelocity_(true),
    tangentialInjectionVector1_(nHoles_),
    tangentialInjectionVector2_(nHoles_)
{


    // check if time entries for soi and eoi match
    if (mag(massFlowRateProfile_[0][0]-TProfile_[0][0]) > SMALL)
    {
        FatalError << "multiHoleInjector::multiHoleInjector(const time& t, const dictionary dict) " << endl
            << " start-times do not match for TemperatureProfile and massFlowRateProfile."
            << abort(FatalError);
    }

    if (mag(massFlowRateProfile_[massFlowRateProfile_.size()-1][0]-TProfile_[TProfile_.size()-1][0]) > SMALL)
    {
        FatalError << "multiHoleInjector::multiHoleInjector(const time& t, const dictionary dict) " << endl
            << " end-times do not match for TemperatureProfile and massFlowRateProfile."
            << abort(FatalError);
    }

    // convert CA to real time
    forAll(massFlowRateProfile_, i)
    {
        massFlowRateProfile_[i][0] = t.userTimeToTime(massFlowRateProfile_[i][0]);
        velocityProfile_[i][0] = massFlowRateProfile_[i][0];
        injectionPressureProfile_[i][0] = massFlowRateProfile_[i][0];
    }
예제 #4
0
// Analyse mesh topology and perform CFD-side CPL_init.
void CPLSocket::\
    initCFD (const Foam::Time &runTime, const Foam::fvMesh &mesh) {

    Foam::Info << "CPLSocket: Analysing processor and mesh topology"
               << Foam::endl;

    // Read from decomposePar dictionary the number of processors in each
    // direction. Must be decomposed with the "simple" method.
    Foam::IOdictionary decomposeDict
    (
        Foam::IOobject ("decomposeParDict", runTime.time().system(), runTime,
                        IOobject::MUST_READ, IOobject::NO_WRITE, false)
    );
    Foam::dictionary simpleCoeffs = decomposeDict.subDict ("simpleCoeffs");
    Foam::Vector<int> np = simpleCoeffs.lookup ("n");
    nprocs = np.x() * np.y() * np.z();

    // Define arrays needed by MPI & CPL cart create routines 
    npxyz[0] = np.x();
    npxyz[1] = np.y();
    npxyz[2] = np.z();
    periods[0] = 1;
    periods[1] = 0;
    periods[2] = 1;

    // Get info needed to calculate this processor's spatial coordinates
    Foam::pointField points = mesh.points();
    Foam::Vector<double> procMaxPoints (maxPoints (points));
    Foam::Vector<double> procMinPoints (minPoints (points));

    // Reduce all with min/max operator to find global min/max
    Foam::Vector<double> globMaxPoints (procMaxPoints);
    Foam::Vector<double> globMinPoints (procMinPoints);
    Foam::reduce (globMaxPoints, maxOp<Foam::Vector<double>>());
    Foam::reduce (globMinPoints, minOp<Foam::Vector<double>>());

    Foam::Vector<double> domainLength (globMaxPoints - globMinPoints);

//    std::cout << "domainlength " << domainLength.x() << " " << domainLength.y() << " " << domainLength.z() << std::endl;
//    std::cout << "proc_min" << procMinPoints.x() << " " << procMinPoints.y() << " " << procMinPoints.z() \
    << "glob_min" << globMinPoints.x() << " " << globMinPoints.y() << " " << globMinPoints.z() << std::endl;