/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . \*---------------------------------------------------------------------------*/ #include "runTimeControl.H" #include "dictionary.H" #include "runTimeCondition.H" #include "fvMesh.H" #include "Time.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { defineTypeNameAndDebug(runTimeControl, 0); } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::runTimeControl::runTimeControl ( const word& name, const objectRegistry& obr, const dictionary& dict, const bool loadFromFiles ) : functionObjectState(obr, name), obr_(obr), conditions_(), groupMap_(), nWriteStep_(0), writeStepI_(0) { // Check if the available mesh is an fvMesh, otherwise deactivate if (setActive()) { read(dict); // Check that some conditions are set if (conditions_.empty()) { Info<< type() << " " << name_ << " output:" << nl << " No conditions present - deactivating" << nl << endl; active_ = false; } else { // Check that at least one condition is active active_ = false; forAll(conditions_, conditionI) { if (conditions_[conditionI].active()) { active_ = true; break; } } if (!active_) { Info<< type() << " " << name_ << " output:" << nl << " All conditions inactive - deactivating" << nl << endl; } } } } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::runTimeControl::~runTimeControl() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::runTimeControl::read(const dictionary& dict) { if (active_) { const dictionary& conditionsDict = dict.subDict("conditions"); const wordList conditionNames(conditionsDict.toc()); conditions_.setSize(conditionNames.size()); label uniqueGroupI = 0; forAll(conditionNames, conditionI) { const word& conditionName = conditionNames[conditionI]; const dictionary& dict = conditionsDict.subDict(conditionName); conditions_.set ( conditionI, runTimeCondition::New(conditionName, obr_, dict, *this) ); label groupI = conditions_[conditionI].groupID(); if (groupMap_.insert(groupI, uniqueGroupI)) { uniqueGroupI++; } } dict.readIfPresent("nWriteStep", nWriteStep_); } } void Foam::runTimeControl::execute() { if (!active_) { return; } Info<< type() << " " << name_ << " output:" << nl; // IDs of satisfied conditions DynamicList