void Foam::calcTypes::scalarMult::preCalc
(
    const argList& args,
    const Time& runTime,
    const fvMesh& mesh
)
{
    baseFieldName_ = args.additionalArgs()[1];

    if (args.optionFound("value"))
    {
        scalarMultValueStr_ = args.option("value");
    }
    else
    {
        FatalErrorIn("calcTypes::scalarMult::preCalc")
            << "scalarMult requires -value option"
            << nl << exit(FatalError);
    }

    if (args.optionFound("resultName"))
    {
        resultName_ = args.option("resultName");
    }
}
Beispiel #2
0
void Foam::calcTypes::interpolate::calc
(
    const argList& args,
    const Time& runTime,
    const fvMesh& mesh
)
{
    #ifdef FOAM_DEV
        const word& fieldName = args.additionalArgs()[1];
    #else
        const word fieldName = args[2];
    #endif

    IOobject fieldHeader
    (
        fieldName,
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ
    );

    // Check field exists
    if (fieldHeader.headerOk())
    {
        bool processed = false;

        writeInterpolateField<scalar>(fieldHeader, mesh, processed);
        writeInterpolateField<vector>(fieldHeader, mesh, processed);
        writeInterpolateField<sphericalTensor>(fieldHeader, mesh, processed);
        writeInterpolateField<symmTensor>(fieldHeader, mesh, processed);
        writeInterpolateField<tensor>(fieldHeader, mesh, processed);

        if (!processed)
        {
            FatalError
                << "Unable to process " << fieldName << nl
                << "No call to interpolate for fields of type "
                << fieldHeader.headerClassName() << nl << nl
                << exit(FatalError);
        }
    }
    else
    {
        Info<< "    No " << fieldName << endl;
    }
}
void Foam::calcTypes::domainIntegrate::calc
(
    const argList& args,
    const Time& runTime,
    const fvMesh& mesh
)
{
    const word& fieldName = args.additionalArgs()[1];

    IOobject fieldHeader
    (
        fieldName,
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ
    );

    // Check field exists
    if (fieldHeader.headerOk())
    {
        bool processed = false;

        calcDomainIntegrate<scalar>(fieldHeader, mesh, processed);
        calcDomainIntegrate<vector>(fieldHeader, mesh, processed);
        calcDomainIntegrate<sphericalTensor>(fieldHeader, mesh, processed);
        calcDomainIntegrate<symmTensor>(fieldHeader, mesh, processed);
        calcDomainIntegrate<tensor>(fieldHeader, mesh, processed);

        if (!processed)
        {
            FatalError
                << "Unable to process " << fieldName << nl
                << "No call to mag for fields of type "
                << fieldHeader.headerClassName() << nl << nl
                << exit(FatalError);
        }
    }
    else
    {
        Info<< "    No " << fieldName << endl;
    }
}
Beispiel #4
0
void Foam::calcTypes::div::calc
(
    const argList& args,
    const Time& runTime,
    const fvMesh& mesh
)
{
    const word& fieldName = args.additionalArgs()[1];

    IOobject fieldHeader
    (
        fieldName,
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ
    );

    // Check field exists
    if (fieldHeader.headerOk())
    {
        bool processed = false;

        writeDivField<surfaceScalarField>(fieldHeader, mesh, processed);
        writeDivField<volVectorField>(fieldHeader, mesh, processed);

        if (!processed)
        {
                FatalError
                    << "Unable to process " << fieldName << nl
                    << "No call to div for fields of type "
                    << fieldHeader.headerClassName() << nl << nl
                    << exit(FatalError);
        }
    }
    else
    {
        Info<< "    No " << fieldName << endl;
    }
}
Beispiel #5
0
void Foam::calcTypes::randomise::calc
(
    const argList& args,
    const Time& runTime,
    const fvMesh& mesh
)
{
    const stringList& params = args.additionalArgs();
    const scalar pertMag = readScalar(IStringStream(params[1])());
    const word& fieldName = params[2];

    Random rand(1234567);

    IOobject fieldHeader
    (
        fieldName,
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ
    );

    // Check field exists
    if (fieldHeader.headerOk())
    {
        bool processed = false;

        writeRandomField<vector>
        (
            fieldHeader,
            pertMag,
            rand,
            mesh,
            processed
        );
        writeRandomField<sphericalTensor>
        (
            fieldHeader,
            pertMag,
            rand,
            mesh,
            processed
        );
        writeRandomField<symmTensor>
        (
            fieldHeader,
            pertMag,
            rand,
            mesh,
            processed
        );
        writeRandomField<tensor>
        (
            fieldHeader,
            pertMag,
            rand,
            mesh,
            processed
        );

        if (!processed)
        {
            FatalError
                << "Unable to process " << fieldName << nl
                << "No call to randomise for fields of type "
                << fieldHeader.headerClassName() << nl << nl
                << exit(FatalError);
        }
    }
    else
    {
        Info<< "    No " << fieldName << endl;
    }
}
Beispiel #6
0
void Foam::calcTypes::fieldMap2d::preCalc
(
  const argList& args,
  const Time& runTime,
  const fvMesh& mesh
)
{
  
  const word dictName("fieldMap2dDict");
  IOdictionary dict
  (
    IOobject
    (
      dictName,
      runTime.system(),
      mesh,
      IOobject::MUST_READ,
      IOobject::NO_WRITE
    )
  );

  if( !dict.readIfPresent<word>("patchName", patchName) )
  {
    SeriousErrorIn("preCalc")
          << "There is no patchName parameter in fieldMap2dDict dictionary"
          << exit(FatalError);
  }
  
  if( !dict.readIfPresent<word>("geometry", geometry) )
  {
    SeriousErrorIn("preCalc")
          << "There is no geometry parameter in fieldMap2dDict dictionary"
          << exit(FatalError);
  }
  
  point minPoint;
  if( !dict.readIfPresent<point>("minPoint", minPoint) )
  {
    SeriousErrorIn("preCalc")
          << "There is no minPoint parameter in fieldMap2dDict dictionary"
          << exit(FatalError);
  }
  point maxPoint;
  if( !dict.readIfPresent<point>("maxPoint", maxPoint) )
  {
    SeriousErrorIn("preCalc")
          << "There is no maxPoint parameter in fieldMap2dDict dictionary"
          << exit(FatalError);
  }

  int integrationDir;
  if( !dict.readIfPresent<int>("integrationDirection", integrationDir) )
  {
    SeriousErrorIn("preCalc")
          << "There is no integrationDirection parameter "
             "in fieldMap2dDict dictionary"
          << exit(FatalError);
  }
  intDir = integrationDir;
  
  int flowDir;
  if( !dict.readIfPresent<int>("flowDirection", flowDir) )
  {
    SeriousErrorIn("preCalc")
          << "There is no flowDirection parameter "
             "in fieldMap2dDict dictionary"
          << exit(FatalError);
  }
  majDir = flowDir;

  int expectedNumberOfIntersections;
  if
  (
    !dict.readIfPresent<int>
          (
            "expectedNumberOfIntersections", 
            expectedNumberOfIntersections
          ) 
  )
  {
    SeriousErrorIn("preCalc")
          << "There is no expectedNumberOfIntersections parameter "
             "in fieldMap2dDict dictionary"
          << exit(FatalError);
  }
  expNI = expectedNumberOfIntersections;
  
  int numberOfIntegrationPoints;
  if
  (
    !dict.readIfPresent<int>
          (
            "numberOfIntegrationPoints",
            numberOfIntegrationPoints
          ) 
  )
  {
    SeriousErrorIn("preCalc")
          << "There is no numberOfIntegrationPoints parameter "
             "in fieldMap2dDict dictionary"
          << exit(FatalError);
  }
  
  
  #ifdef FOAM_DEV
    const word& processingType = args.additionalArgs()[1];
    const word& Nword = args.additionalArgs()[2];
    const word& Mword = args.additionalArgs()[3];
    const word& Kword = args.additionalArgs()[4];

    N_ = std::atoi( Nword.c_str() );
    M_ = std::atoi( Mword.c_str() );
    Info << "FOAM_DEV true: "<< FOAM_DEV <<nl;
  #else
    const word processingType = args[2];
    N_ = std::atoi( args[3].c_str() );
    M_ = std::atoi( args[4].c_str() );
    Info << "FOAM_DEV false: " <<nl;
  #endif
  processingType_ = const_cast<word&>(processingType);
  latDir = 3 - (intDir + majDir);
  
  Info<<"* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *"
          <<nl
          <<"Post-processing parameters:"<<nl
          <<"patchName:                 "<< patchName<<nl
          <<"geometry:                  "<< geometry<<nl
          <<"minPoint:                  "<< minPoint<<nl
          <<"maxPoint:                  "<< maxPoint<<nl
          <<"major direction:           "<< majDir<<nl
          <<"lateral direction:         "<< latDir<<nl
          <<"integration direction:     "<< intDir<<nl
          <<"number of intersections:   "<<expNI<<nl
          <<"number of integration points: "<< numberOfIntegrationPoints
          <<endl;
  
  if
  (
    processingType_!="ccAll" && geometry == "concentricCylinders"
  )
  {
    SeriousErrorIn("preCalc")
          << "Concentric cylinders geometry should have proc type ccAll"
          << exit(FatalError);
  }

  N1_ = N_+1;
  M1_ = M_+1;
  K_  = numberOfIntegrationPoints;
  K1_ = numberOfIntegrationPoints+1;
  
  N1M1 = N1_*M1_;

  // need temporary arguments in order to add a 0 time directory
  /*
  argList argsTmp = args;
  argsTmp.setOption("time", "0");
  Foam::Time timeTmp(Foam::Time::controlDictName, argsTmp);
  Foam::instantList timeDirs = Foam::timeSelector::select0(timeTmp, argsTmp);
  timeTmp.setTime(timeDirs[0], 0);
  
  Foam::fvMesh meshTmp
  (
      Foam::IOobject
      (
          Foam::fvMesh::defaultRegion,
          timeTmp.timeName(),
          timeTmp,
          Foam::IOobject::MUST_READ
      )
  );
  if( timeTmp.timeName()!="0" )
  {
    SeriousErrorIn("fieldOperations::getInletAreaT0")
            <<"There is no 0 time directory. Check your decomposition as well!"<<nl
            <<"TimeTmp: "<< timeTmp.timeName()<<nl
            <<exit(FatalError);
  }
  */
  
  //Info << "Calculating the max and min coordinates"<<nl;
  //const pointField &allPoints = meshTmp.points();
  //minPosX = min( allPoints.component(vector::X) );
  //minPosY = min( allPoints.component(vector::Y) );
  //minPosZ = min( allPoints.component(vector::Z) );
  
  if(geometry=="flat")
  {
    minPosMaj = minPoint.component(majDir);
    minPosLat = minPoint.component(latDir);
    minPosInt = minPoint.component(intDir);

    maxPosMaj = maxPoint.component(majDir);
    maxPosLat = maxPoint.component(latDir);
    maxPosInt = maxPoint.component(intDir);

    // z becomes x; x becomes y
    dx = (maxPosMaj - minPosMaj) / static_cast<scalar>(N_);
    dy = (maxPosLat - minPosLat) / static_cast<scalar>(M_);
  }
  else if(geometry=="concentricCylinders")
  {
    minPosMaj = minPoint.component(majDir);
    minPosLat = 0.0;
    minPosInt = 0.0;

    maxPosMaj = maxPoint.component(majDir);
    maxPosLat = constant::mathematical::twoPi;
    maxPosInt = maxPoint.component(intDir);

    // in case of concentric cylinders we go around the circle
    dx = (maxPosMaj - minPosMaj) / static_cast<scalar>(N_);
    dy = (maxPosLat - minPosLat) / static_cast<scalar>(M_);
  }
  else
  {
    FatalError<<"Unknown geometry"<<nl<<exit(FatalError);
  }
  
  
  // calculate the size of the current pattern being not bigger then 10^7
  thisTimeSize = min(N1M1, maxNumProcPoints);
  curNum = 0;
  curEnd = thisTimeSize;
  
  totNumLoop = (N1M1-1) / maxNumProcPoints + 1;
}