Esempio n. 1
0
// Finalise the output
// Currently just prints the time and the number of errors
// that occurred
void Logger::finalise()
{
  outfile << std::string(30, '-') << "\n";
  globalTime(); // Print time elapsed
  outfile << "Number of errors: " << nerr << "\n";
}
void Foam::multiSolver::setInitialSolverDomain(const word& solverDomainName)
{

    if (!solverDomains_.found(solverDomainName))
    {
        FatalErrorIn("multiSolver::setInitialSolverDomain")
            << "Initial solverDomainName '" << solverDomainName << "' does"
            << " not exist in multiSolver dictionary.  Found entries are: "
            << solverDomains_.toc()
            << abort(FatalError);
    }

    currentSolverDomain_ = solverDomainName;

    setSolverDomainControls(currentSolverDomain_);

    // Purge all time directories from case directory root
    purgeTimeDirs(multiDictRegistry_.path());
    
    // Purge any constant/superLoopData/
    fileName superLoopDataPath
    (
        multiDictRegistry_.path()/multiDictRegistry_.constant()
            /"superLoopData"
    );
    if (exists(superLoopDataPath))
    {
        rmDir(superLoopDataPath);
    }

    // Read initial settings and determine data source (from which path the
    // initial data is copied, the starting superLoop_, and the current
    // globalTime (used to determine globalOffset).  Rules that are applied:
    //
    //   1. superLoop_ = data source superLoop
    //       a. unless data source solverDomain != currentSolverDomain_, in
    //          which case, superLoop_ = data source superLoop + 1
    //   2. globalTime = data source globalTime.  globalTime does not increment
    //      when swapping solver domains.
    //   3. startTime = data source local time
    //       a. unless data source solverDomain != currentSolverDomain_, in
    //          which case, startTime is dictated by the solverDomains
    //          subdictionary.
    //   4. endTime is determined by the solverDomains subdictionary
    //       a. unless the finalStopAt trumps it

    // Find initial data source
    timeCluster tcSource(initialDataSource());

    fileName sourcePath(findInstancePath(tcSource, tcSource.size() - 1));
    superLoop_ = tcSource.superLoop();
    globalIndex_ = tcSource.globalIndex();
    
    // If starting from initial conditions, superLoop_ = -1
    if (superLoop_ < 0) superLoop_ = 0;
    scalar globalTime(tcSource.globalValue(tcSource.size() - 1));
    scalar localStartTime(tcSource.localValue(tcSource.size() -1));

    // Now to apply the exceptions if currentSolverDomain_ != data source
    // solverDomain (see long comment above).
    if (sourcePath.path().path().name() != currentSolverDomain_)
    {
        superLoop_++;
        globalIndex_++;
        
        switch (startFrom_)
        {
            case mtsFirstTime:
                localStartTime = 0;
                break;
            case mtsStartTime:
                localStartTime = startTime_;
                break;
            case mtsLatestTimeThisDomain:
                {
                    timeCluster tcTemp
                    (
                        findLatestLocalTime
                        (
                            readSolverDomainTimes(currentSolverDomain_)
                        )
                    );
                    localStartTime = tcTemp.localValue(0);
                }
                break;
            case mtsLatestTimeAllDomains:
                localStartTime = globalTime;
                break;
        }
    }

    startTime_ = localStartTime;

    globalTimeOffset_ = globalTime - startTime_;
    
    // Give multiDictRegistry a time value (required for regIOobject::write()
    // to case/[timeValue]
    multiDictRegistry_.setTime(startTime_, 0);

    // Copy the source data and any previous time directories to
    // case/[localTime]
    forAll(tcSource, i)
    {
        fileName copyMe(findInstancePath(tcSource, i));
        cp(copyMe, multiDictRegistry_.path());
    }