/* Main function */
int main (int argc, char *argv[]) {
	int temp_return;
	
	// Initially set temp_return equal to 0.
	temp_return = 0;
	
	if (argc == 1) { // If the user does not enter any arguments.
		temp_return = usage();
	}
	else if (argc == 2) { // If the user only enters a filename.
		temp_return = findStrings(argv[1], 4);
	}
	else if ((argc % 2) == 1) { // If the user enters an invalid number of arguments. 2 arguments for program name and filename, and then 2 more if a switch is used.
		printf("Invalid number of arguments!\n");
	}
	else if (((strcmp(argv[1],"-n")) == 0) && ( argc == 4)) { // If the minlen switch was used to specify a minlen.
		temp_return = findStrings(argv[3], atoi(argv[2]));
	}
	
	// If a bad filename was provided by the user.
	if (temp_return == 1) {
		printf("Bad file!\n");
	}
	
	return temp_return;
}
Foam::label Foam::sampledSurfaces::classifyFields()
{
    label nFields = 0;
    clearFieldGroups();

    // check files for a particular time
    if (loadFromFiles_)
    {
        IOobjectList objects(mesh_, mesh_.time().timeName());
        wordList allFields = objects.sortedNames();

        labelList indices = findStrings(fieldSelection_, allFields);

        forAll(indices, fieldI)
        {
            const word& fieldName = allFields[indices[fieldI]];

            nFields += appendFieldGroup
            (
                fieldName,
                objects.find(fieldName)()->headerClassName()
            );
        }
    }
    else
    {
Foam::label Foam::sampledSurfaces::classifyFields()
{
    label nFields = 0;

    if (loadFromFiles_)
    {
        // Check files for a particular time
        IOobjectList objects(mesh_, mesh_.time().timeName());
        wordList allFields = objects.sortedNames();

        forAll(fieldSelection_, i)
        {
            labelList indices = findStrings(fieldSelection_[i], allFields);

            if (indices.size())
            {
                nFields += indices.size();
            }
            else
            {
                WarningInFunction
                    << "Cannot find field file matching "
                    << fieldSelection_[i] << endl;
            }
        }
    }
Foam::patchInteractionDataList::patchInteractionDataList
(
    const polyMesh& mesh,
    const dictionary& dict
)
:
    List<patchInteractionData>(dict.lookup("patches")),
    patchGroupIDs_(this->size())
{
    const polyBoundaryMesh& bMesh = mesh.boundaryMesh();
    const wordList allPatchNames = bMesh.names();

    const List<patchInteractionData>& items = *this;
    forAllReverse(items, i)
    {
        const word& patchName = items[i].patchName();
        labelList patchIDs = findStrings(patchName, allPatchNames);

        if (patchIDs.empty())
        {
            WarningInFunction
                << "Cannot find any patch names matching " << patchName
                << endl;
        }

        patchGroupIDs_[i].transfer(patchIDs);
    }

    // Check that all patches are specified
    DynamicList<word> badPatches;
    forAll(bMesh, patchI)
    {
        const polyPatch& pp = bMesh[patchI];
        if
        (
            !pp.coupled()
         && !isA<emptyPolyPatch>(pp)
         && !isA<cyclicAMIPolyPatch>(pp)
         && applyToPatch(pp.index()) < 0
        )
        {
            badPatches.append(pp.name());
        }
    }

    if (badPatches.size() > 0)
    {
        FatalErrorInFunction
            << "All patches must be specified when employing local patch "
            << "interaction. Please specify data for patches:" << nl
            << badPatches << nl << exit(FatalError);
    }
}
示例#5
0
/*
 * main function of the program
 */
int main(int argc, char *argv[]) {
	long inputFileSize = 0;
	int targetStringCount = 0;
	// check arguments
	checkArgs(argc, argv);
	// get input file size
	getFileSize(argv[1], &inputFileSize);
	// find target strings
	findStrings(argv[1], inputFileSize,  argv[2], &targetStringCount);
	// print the result
	printResult(inputFileSize, targetStringCount, argv[3]);

	return 0;
}
        forAll(indices, fieldI)
        {
            const word& fieldName = allFields[indices[fieldI]];

            nFields += appendFieldGroup
            (
                fieldName,
                objects.find(fieldName)()->headerClassName()
            );
        }
    }
    else
    {
        wordList allFields = mesh_.sortedNames();
        labelList indices = findStrings(fieldSelection_, allFields);

        forAll(indices, fieldI)
        {
            const word& fieldName = allFields[indices[fieldI]];

            nFields += appendFieldGroup
            (
                fieldName,
                mesh_.find(fieldName)()->type()
            );
        }
    }

    return nFields;
}