Пример #1
0
Foam::twoPhaseMixture::twoPhaseMixture
(
    const fvMesh& mesh,
    const dictionary& dict
)
:
    phase1Name_(wordList(dict.lookup("phases"))[0]),
    phase2Name_(wordList(dict.lookup("phases"))[1]),

    alpha1_
    (
        IOobject
        (
            IOobject::groupName("alpha", phase1Name_),
            mesh.time().timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    ),

    alpha2_
    (
        IOobject
        (
            IOobject::groupName("alpha", phase2Name_),
            mesh.time().timeName(),
            mesh
        ),
        1.0 - alpha1_
    )
{}
void workflowControls::setStepCompleted() const
{
    if( mesh_.metaData().found("lastStep") )
    {
        mesh_.metaData().set("lastStep", currentStep_);
    }
    else
    {
        mesh_.metaData().add("lastStep", currentStep_);
    }

    DynList<word> completedSteps;
    if( mesh_.metaData().found("completedSteps") )
        completedSteps = wordList(mesh_.metaData().lookup("completedSteps"));

    completedSteps.append(currentStep_);

    if( mesh_.metaData().found("completedSteps") )
    {
        mesh_.metaData().set("completedSteps", completedSteps);
    }
    else
    {
        mesh_.metaData().add("completedSteps", completedSteps);
    }
}
Пример #3
0
/*
 * Function: main
 * -----------------
 * Serves as entry point of program. Takes in all user inputs to determine specific boggle configuration.
 * Then, it gives the user a chance to find words in the boggleBoard. Then, the computer takes over
 * to find any remaining words. Finally, gives user option to play another round.
 *
 *@return 0 if program completed successfully.
 */
int main()
{
	Randomize(); //initializes random constructor
	SetWindowSize(8, 5);
	InitGraphics();
	Welcome();
	GiveInstructions();
	Lexicon wordList("lexicon.dat"); //generates list of all possible words
	while (true) {
		Lexicon usedWords; //generates a list that stores all words found by the player and computer
		InitGraphics();
		SoundFeature();
		int boardDimension = BoggleBoardSize();
		DrawBoard(boardDimension, boardDimension);
		Grid<char> boggleBoard(boardDimension, boardDimension);
		if (!UserBoardConfiguration()) {
			InitializeRandomBoard(boggleBoard); //if user chooses not to specify board configuration, a random one is generated
		} else {
			string diceConfig = GetDiceConfiguration(boardDimension);
			SetDiceConfiguration(boggleBoard, diceConfig);
		}
		DrawBoggleBoard(boggleBoard);
		Grid<bool> usedDice(boggleBoard.numRows(), boggleBoard.numCols());
		CreateMarker(usedDice);
		InputGuesses(boggleBoard, wordList, usedWords, usedDice); //player's turn
		FindRemainingWords(boggleBoard, wordList, usedWords, usedDice); //computer's turn
		PlayNamedSound("thats pathetic.wav"); //assumes the player will always lose to the computer
		if (!GameContinue()) break;
	}
	return 0;
}
Пример #4
0
Foam::twoPhaseMixture::twoPhaseMixture
(
    const fvMesh& mesh,
    const dictionary& dict,
    const word& alpha1Name,
    const word& alpha2Name
)
:
    phase1Name_
    (
        dict.found("phases")
      ? wordList(dict.lookup("phases"))[0]
      : "1"
    ),
    phase2Name_
    (
        dict.found("phases")
      ? wordList(dict.lookup("phases"))[1]
      : "2"
    ),

    alpha1_
    (
        IOobject
        (
            dict.found("phases") ? word("alpha" + phase1Name_) : alpha1Name,
            mesh.time().timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    ),

    alpha2_
    (
        IOobject
        (
            dict.found("phases") ? word("alpha" + phase2Name_) : alpha2Name,
            mesh.time().timeName(),
            mesh
        ),
        1.0 - alpha1_
    )
{}
DynList<word> workflowControls::completedSteps() const
{
    DynList<word> completedSteps;

    if( mesh_.metaData().found("completedSteps") )
        completedSteps = wordList(mesh_.metaData().lookup("completedSteps"));

    return completedSteps;
}
Пример #6
0
Foam::structuredDecomp::structuredDecomp(const dictionary& decompositionDict)
:
    decompositionMethod(decompositionDict),
    methodDict_(decompositionDict_.subDict(typeName + "Coeffs"))
{
    methodDict_.set("numberOfSubdomains", nDomains());
    method_ = decompositionMethod::New(methodDict_);
    patches_ = wordList(methodDict_.lookup("patches"));
}
Пример #7
0
Foam::coalCloudList::coalCloudList
(
    const volScalarField& rho,
    const volVectorField& U,
    const dimensionedVector& g,
    const SLGThermo& slgThermo
)
:
    PtrList<coalCloud>(),
    mesh_(rho.mesh())
{
    IOdictionary props
    (
        IOobject
        (
            "coalCloudList",
            mesh_.time().constant(),
            mesh_,
            IOobject::MUST_READ
        )
    );

    const wordHashSet cloudNames(wordList(props.lookup("clouds")));

    setSize(cloudNames.size());

    label i = 0;
    forAllConstIter(wordHashSet, cloudNames, iter)
    {
        const word& name = iter.key();

        Info<< "creating cloud: " << name << endl;

        set
        (
            i++,
            new coalCloud
            (
                name,
                rho,
                U,
                g,
                slgThermo
            )
        );

        Info<< endl;
    }
}
Пример #8
0
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), longestWord("")
{
    ui->setupUi(this);

    // load the word list
    QFile file(QCoreApplication::applicationDirPath() + "/Dictionary.txt");
    if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
        return;

    QTextStream wordList(&file);

    QString current = "";

    do
    {
        current = wordList.readLine();
        words.append(current.toUpper());

        // find the biggest word
        if (current.length() > longestWord.length())
            longestWord = current.toUpper();
    }
    while (current != "");
    file.close();

    // add all the text edits to a list for ease of access later
    textEdits.push_back(ui->textEdit00);
    textEdits.push_back(ui->textEdit01);
    textEdits.push_back(ui->textEdit02);
    textEdits.push_back(ui->textEdit03);
    textEdits.push_back(ui->textEdit10);
    textEdits.push_back(ui->textEdit11);
    textEdits.push_back(ui->textEdit12);
    textEdits.push_back(ui->textEdit13);
    textEdits.push_back(ui->textEdit20);
    textEdits.push_back(ui->textEdit21);
    textEdits.push_back(ui->textEdit22);
    textEdits.push_back(ui->textEdit23);
    textEdits.push_back(ui->textEdit30);
    textEdits.push_back(ui->textEdit31);
    textEdits.push_back(ui->textEdit32);
    textEdits.push_back(ui->textEdit33);

    // connect all the text changed signals of the text edits to the slot onTextChanged
    // so we can set a maximum length of 1 for all of them
    foreach (QTextEdit *textEdit, textEdits)
        connect(textEdit, SIGNAL(textChanged()), this, SLOT(onTextChanged()));
}
Пример #9
0
void Foam::turbulenceFields::read(const dictionary& dict)
{
    if (active_)
    {
        fieldSet_.insert(wordList(dict.lookup("fields")));

        Info<< type() << " " << name_ << ": ";
        if (fieldSet_.size())
        {
            Info<< "storing fields:" << nl;
            forAllConstIter(wordHashSet, fieldSet_, iter)
            {
                Info<< "    " << modelName << ':' << iter.key() << nl;
            }
            Info<< endl;
        }
        else
        {
void sixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs()
{
    if (this->updated())
    {
        return;
    }

    if (lookupGravity_ < 0)
    {
        if (db().foundObject<uniformDimensionedVectorField>("g"))
        {
            if (lookupGravity_ == -2)
            {
                FatalErrorIn
                (
                    "void sixDoFRigidBodyDisplacementPointPatchVectorField"
                    "::updateCoeffs()"
                )
                    << "Specifying the value of g in this boundary condition "
                    << "when g is available from the database is considered "
                    << "a fatal error to avoid the possibility of inconsistency"
                    << exit(FatalError);
            }
            else
            {
                lookupGravity_ = 1;
            }
        }
        else
        {
            lookupGravity_ = 0;
        }
    }

    const polyMesh& mesh = this->dimensionedInternalField().mesh()();
    const Time& t = mesh.time();
    const pointPatch& ptPatch = this->patch();

    // Patch force data is valid for the current positions, so
    // calculate the forces on the motion object from this data, then
    // update the positions

    motion_.updatePosition(t.deltaTValue(), t.deltaT0Value());

    dictionary forcesDict;

    forcesDict.add("patches", wordList(1, ptPatch.name()));
    forcesDict.add("rhoInf", rhoInf_);
    forcesDict.add("rhoName", rhoName_);
    forcesDict.add("CofR", motion_.centreOfMass());

    forces f("forces", db(), forcesDict);

    forces::forcesMoments fm = f.calcForcesMoment();

    // Get the forces on the patch faces at the current positions

    if (lookupGravity_ == 1)
    {
        uniformDimensionedVectorField g =
            db().lookupObject<uniformDimensionedVectorField>("g");

        g_ = g.value();
    }

    motion_.updateForce
    (
        fm.first().first() + fm.first().second() + g_*motion_.mass(),
        fm.second().first() + fm.second().second(),
        t.deltaTValue()
    );

    Field<vector>::operator=
    (
        relaxationFactor_
       *(
           motion_.currentPosition(initialPoints_)
         - initialPoints_
       )
    );

    fixedValuePointPatchField<vector>::updateCoeffs();
}
Пример #11
0
void Foam::multiSolver::buildDictionary
(
    dictionary& outputDict,
    const dictionary& inputDict,
    const word& solverDomainName
)
{
    outputDict.remove("sameAs");
    outputDict.remove("multiLoad");
    wordList alreadyMerged(0);
    wordList mergeMe(0);
    if (inputDict.found("default"))
    {
        if (outputDict.found("multiLoad"))
        {
            mergeMe = wordList(outputDict.lookup("multiLoad"));
            outputDict.remove("multiLoad");
        }
        if (outputDict.found("sameAs"))
        {
            label newIndex(mergeMe.size());
            mergeMe.setSize(newIndex + 1);
            mergeMe[newIndex] = word(outputDict.lookup("sameAs"));
            outputDict.remove("sameAs");
        }
    }
    
    // We load solverDomain last, but we need its sameAs / multiLoad now
    if (inputDict.found(solverDomainName))
    {
        const dictionary& solverDict(inputDict.subDict(solverDomainName));
        if (solverDict.found("multiLoad"))
        {
            mergeMe.append(wordList(solverDict.lookup("multiLoad")));
        }
        if (solverDict.found("sameAs"))
        {
            label newIndex(mergeMe.size());
            mergeMe.setSize(newIndex + 1);
            mergeMe[newIndex] = word(solverDict.lookup("sameAs"));
        }
    }
    
    label mergeI(-1);
    while ((mergeI + 1) < mergeMe.size())
    {
        mergeI++;
        bool skipMe(false);
        forAll(alreadyMerged, alreadyI)
        {
            if (mergeMe[mergeI] == alreadyMerged[alreadyI])
            {
                skipMe = true;
                break;
            }
        }
        if (skipMe)
        {
            break;
        }
        outputDict.merge(inputDict.subDict(mergeMe[mergeI]));
        
        // Add to alreadyMerged
        label mergedIndex(alreadyMerged.size());
        alreadyMerged.setSize(mergedIndex + 1);
        alreadyMerged[mergedIndex] = mergeMe[mergeI];
        
        // Recursive search
        if (outputDict.found("multiLoad"))
        {
            mergeMe.append(wordList(outputDict.lookup("multiLoad")));
            outputDict.remove("multiLoad");
        }
        if (outputDict.found("sameAs"))
        {
            label newMergeMeIndex(mergeMe.size());
            mergeMe.setSize(newMergeMeIndex + 1);
            mergeMe[newMergeMeIndex] = word(outputDict.lookup("sameAs"));
            outputDict.remove("sameAs");
        }
    }
    
    // Merge the solverDomain name, even if it already has merged
    if (inputDict.found(solverDomainName))
    {
        outputDict.merge(inputDict.subDict(solverDomainName));

        // These have been handled already        
        outputDict.remove("sameAs");
        outputDict.remove("multiLoad");
    }
}
Пример #12
0
    eqn -= alpha*porosityEqn;
}


bool Foam::fv::explicitPorositySource::read(const dictionary& dict)
{
    if (cellSetOption::read(dict))
    {
        if (coeffs_.found("UNames"))
        {
            coeffs_.lookup("UNames") >> fieldNames_;
        }
        else if (coeffs_.found("UName"))
        {
            word UName(coeffs_.lookup("UName"));
            fieldNames_ = wordList(1, UName);
        }
        else
        {
            fieldNames_ = wordList(1, "U");
        }

        applied_.setSize(fieldNames_.size(), false);

        return true;
    }
    else
    {
        return false;
    }
}
void sixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs()
{
    if (this->updated())
    {
        return;
    }

    if (lookupGravity_ < 0)
    {
        if (db().foundObject<uniformDimensionedVectorField>("g"))
        {
            if (lookupGravity_ == -2)
            {
                FatalErrorInFunction
                    << "Specifying the value of g in this boundary condition "
                    << "when g is available from the database is considered "
                    << "a fatal error to avoid the possibility of inconsistency"
                    << exit(FatalError);
            }
            else
            {
                lookupGravity_ = 1;
            }
        }
        else
        {
            lookupGravity_ = 0;
        }
    }

    const polyMesh& mesh = this->internalField().mesh()();
    const Time& t = mesh.time();
    const pointPatch& ptPatch = this->patch();

    // Store the motion state at the beginning of the time-step
    bool firstIter = false;
    if (curTimeIndex_ != t.timeIndex())
    {
        motion_.newTime();
        curTimeIndex_ = t.timeIndex();
        firstIter = true;
    }

    dictionary forcesDict;

    forcesDict.add("type", functionObjects::forces::typeName);
    forcesDict.add("patches", wordList(1, ptPatch.name()));
    forcesDict.add("rhoInf", rhoInf_);
    forcesDict.add("rho", rhoName_);
    forcesDict.add("CofR", motion_.centreOfRotation());

    functionObjects::forces f("forces", db(), forcesDict);

    f.calcForcesMoment();

    // Get the forces on the patch faces at the current positions

    if (lookupGravity_ == 1)
    {
        uniformDimensionedVectorField g =
            db().lookupObject<uniformDimensionedVectorField>("g");

        g_ = g.value();
    }

    // scalar ramp = min(max((t.value() - 5)/10, 0), 1);
    scalar ramp = 1.0;

    motion_.update
    (
        firstIter,
        ramp*(f.forceEff() + motion_.mass()*g_),
        ramp*(f.momentEff() + motion_.mass()*(motion_.momentArm() ^ g_)),
        t.deltaTValue(),
        t.deltaT0Value()
    );

    Field<vector>::operator=
    (
        motion_.transform(initialPoints_) - initialPoints_
    );

    fixedValuePointPatchField<vector>::updateCoeffs();
}
Пример #14
0
int main(int argc, char *argv[])
{

    Foam::timeSelector::addOptions(false);
    Foam::argList::validArgs.append("expressionDict");
#   include "addRegionOption.H"
    argList::validOptions.insert("noDimensionChecking","");
    argList::validOptions.insert("foreignMeshesThatFollowTime",
                                  "<list of mesh names>");

#   include "setRootCase.H"

    printSwakVersion();

    IFstream theFile(args.args()[1]);
    dictionary theExpressions(theFile);
    wordList foreignMeshesThatFollowTime(0);

    if (!args.options().found("time") && !args.options().found("latestTime")) {
        FatalErrorIn("main()")
            << args.executable()
                << ": time/latestTime option is required" << endl
            << exit(FatalError);
    }

    if(args.options().found("noDimensionChecking")) {
        dimensionSet::debug=0;
    }
    if(args.options().found("foreignMeshesThatFollowTime")) {
        string followMeshes(
            args.options()["foreignMeshesThatFollowTime"]
        );
        IStringStream followStream("("+followMeshes+")");
        foreignMeshesThatFollowTime=wordList(followStream);
    }

#   include "createTime.H"
    Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args);

#   include "createNamedMesh.H"

    forAllConstIter(IDLList<entry>, theExpressions, iter)
    {
        const dictionary &dict=iter().dict();

        CommonValueExpressionDriver::readForeignMeshInfo(dict);
    }

    forAll(timeDirs, timeI)
    {
        runTime.setTime(timeDirs[timeI], timeI);

        Foam::Info << "\nTime = " << runTime.timeName() << Foam::endl;

        mesh.readUpdate();

        forAll(foreignMeshesThatFollowTime,i) {
            const word &name=foreignMeshesThatFollowTime[i];
            if(MeshesRepository::getRepository().hasMesh(name)) {
                Info << "Setting mesh " << name << " to current Time"
                    << endl;

                MeshesRepository::getRepository().setTime(
                    name,
                    runTime.value()
                );
            } else {
                FatalErrorIn(args.executable())
                    << "No mesh with name " << name << " declared. " << nl
                        << "Can't follow current time"
                        << endl
                        << exit(FatalError);

            }
        }

        forAllConstIter(IDLList<entry>, theExpressions, iter)
        {
            Info << iter().keyword() << " : " << flush;

            const dictionary &dict=iter().dict();

            autoPtr<CommonValueExpressionDriver> driver=
                CommonValueExpressionDriver::New(dict,mesh);
            wordList accumulations(dict.lookup("accumulations"));

            driver->setSearchBehaviour(
                true,
                true,
                true         // search on disc
            );

            driver->clearVariables();
            driver->parse(string(dict.lookup("expression")));
            word rType=driver->CommonValueExpressionDriver::getResultType();

            if(rType==pTraits<scalar>::typeName) {
                writeData<scalar>(driver(),accumulations);
            } else if(rType==pTraits<vector>::typeName) {
                writeData<vector>(driver(),accumulations);
            } else if(rType==pTraits<tensor>::typeName) {
                writeData<tensor>(driver(),accumulations);
            } else if(rType==pTraits<symmTensor>::typeName) {
                writeData<symmTensor>(driver(),accumulations);
            } else if(rType==pTraits<sphericalTensor>::typeName) {
                writeData<sphericalTensor>(driver(),accumulations);
            } else {
                WarningIn(args.executable())
                    << "Don't know how to handle type " << rType
                        << endl;
            }

            Info << endl;
        }
Пример #15
0
int main(int argc, char *argv[])
{

#   include "setRootCase.H"
#   include "createTime.H"

    instantList Times = runTime.times();
#   include "checkTimeOptions.H"
    runTime.setTime(Times[startTime],startTime);
#   include "createMesh.H"

    typedef VectorSpace<Vector<scalar>,scalar,4> quad;
    typedef VectorSpace<Vector<scalar>,scalar,6> hex;
    
    //read setDiscreteFieldsDictionary

    IOdictionary setDiscreteFieldsDict
      (
       IOobject
       (
	"setDiscreteFieldsDict",
	runTime.system(),
	mesh,
	IOobject::MUST_READ,
	IOobject::NO_WRITE
	)
       );
    // read pointer lists of each "Fields"
    PtrList<entry> parts=setDiscreteFieldsDict.lookup("Fields");

    forAll(parts,partI) {
      const dictionary &part=parts[partI].dict();
      Info <<part <<endl;

      // "field" ,"type", and "profile" are required in setDiscreteFieldsDict
      word field=part["field"];

      word type=part["type"];

      // "direction", "internal", and "patchNames" are option
      string direction="x";
      if (part.found("direction")) {
	direction=part["direction"];
      }

      bool internal=true;
      if (part.found("internal")) {
	internal=readBool(part["internal"]);
      }
      
      wordList patchNames;      
      if (part.found("patchNames")){
	patchNames=wordList(part.lookup("patchNames"));
      }

      const string &time = runTime.timeName();
      Info <<"time " <<time <<"\n";

      // for scalar field
      if(type=="scalar"){
        Info << "set " <<field <<endl;

        // read profile
	List<quad> profile(part.lookup("profile"));
	scalarField posX(profile.size());
	scalarField posY(profile.size());
	scalarField posZ(profile.size());
	scalarField fX(profile.size());
	forAll(profile,i)
	  {
	    posX[i]=profile[i][0];
	    posY[i]=profile[i][1];
	    posZ[i]=profile[i][2];
	    fX[i]=profile[i][3];
	  }
        // read target field (scalar)
	volScalarField tmpField
	  (
	   IOobject
	   (
	    field,
	    time,
	    mesh,
	    IOobject::MUST_READ,
	    IOobject::AUTO_WRITE
	    ),
	   mesh
	   );
	
	//read cellCenter of targetMesh
	volVectorField center=tmpField.mesh().C();

	//internalField
	if(internal){
          scalarField &Ifield = tmpField.internalField();
          scalarField Icenter(Ifield.size());
          scalarField newIField(Ifield.size());
          if(direction=="x"){
            Icenter = center.internalField().component(vector::X);
            newIField = interpolateXY(Icenter,posX,fX);
          }	
          else if(direction=="y"){
            Icenter = center.internalField().component(vector::Y);
            newIField = interpolateXY(Icenter,posY,fX);
          }	
          else if(direction=="z"){
            Icenter = center.internalField().component(vector::Z);
            newIField  = interpolateXY(Icenter,posZ,fX);
          }	
          Ifield = newIField;
        }
	//patch
	forAll(patchNames,patchNameI)
	  {
	    label patchID=mesh.boundaryMesh().findPatchID(patchNames[patchNameI]);
	    scalarField &Pfield = tmpField.boundaryField()[patchID];
	    scalarField newPField(Pfield.size());
	    scalarField Pcenter(Pfield.size());
	    if(direction=="x"){
	      Pcenter = center.boundaryField()[patchID].component(vector::X);
	      newPField = interpolateXY(Pcenter,posX,fX);
	    }	
	    else if(direction=="y"){
	      Pcenter = center.boundaryField()[patchID].component(vector::Y);
	      newPField = interpolateXY(Pcenter,posY,fX);
	    }	
	    else if(direction=="z"){
	      Pcenter = center.boundaryField()[patchID].component(vector::Z);
	      newPField = interpolateXY(Pcenter,posZ,fX);
	    }	
	    Pfield = newPField;
	  }
wordList swakExpressionAverageDistributionFunctionObject::fileNames()
{
    return wordList();
}