コード例 #1
0
void Foam::codedFunctionObject::prepare
(
    dynamicCode& dynCode,
    const dynamicCodeContext& context
) const
{
    // Set additional rewrite rules
    dynCode.setFilterVariable("typeName", redirectType_);
    dynCode.setFilterVariable("codeRead", codeRead_);
    dynCode.setFilterVariable("codeExecute", codeExecute_);
    dynCode.setFilterVariable("codeEnd", codeEnd_);
    dynCode.setFilterVariable("codeData", codeData_);
    dynCode.setFilterVariable("codeTimeSet", codeTimeSet_);
    //dynCode.setFilterVariable("codeWrite", codeWrite_);

    // compile filtered C template
    dynCode.addCompileFile("functionObjectTemplate.C");
    dynCode.addCompileFile("FilterFunctionObjectTemplate.C");

    // copy filtered H template
    dynCode.addCopyFile("FilterFunctionObjectTemplate.H");
    dynCode.addCopyFile("functionObjectTemplate.H");
    dynCode.addCopyFile("IOfunctionObjectTemplate.H");

    // debugging: make BC verbose
    //         dynCode.setFilterVariable("verbose", "true");
    //         Info<<"compile " << redirectType_ << " sha1: "
    //             << context.sha1() << endl;

    // define Make/options
    dynCode.setMakeOptions
        (
            "EXE_INC = -g \\\n"
            "-I$(LIB_SRC)/finiteVolume/lnInclude \\\n"
            "-I$(LIB_SRC)/meshTools/lnInclude \\\n"
            + context.options()
            + "\n\nLIB_LIBS = \\\n"
            + "    -lOpenFOAM \\\n"
            + "    -lfiniteVolume \\\n"
            + "    -lmeshTools \\\n"
            + context.libs()
        );
}
コード例 #2
0
void Foam::fv::CodedSource<Type>::prepare
(
    dynamicCode& dynCode,
    const dynamicCodeContext& context
) const
{
    word sourceType(pTraits<Type>::typeName);

    // Set additional rewrite rules
    dynCode.setFilterVariable("typeName", name_);
    dynCode.setFilterVariable("TemplateType", sourceType);
    dynCode.setFilterVariable("SourceType", sourceType + "Source");

    //dynCode.removeFilterVariable("code");
    dynCode.setFilterVariable("codeCorrect", codeCorrect_);
    dynCode.setFilterVariable("codeAddSup", codeAddSup_);
    dynCode.setFilterVariable("codeSetValue", codeSetValue_);

    // compile filtered C template
    dynCode.addCompileFile("codedFvOptionTemplate.C");

    // copy filtered H template
    dynCode.addCopyFile("codedFvOptionTemplate.H");

    // debugging: make BC verbose
    //         dynCode.setFilterVariable("verbose", "true");
    //         Info<<"compile " << name_ << " sha1: "
    //             << context.sha1() << endl;

    // define Make/options
    dynCode.setMakeOptions
        (
            "EXE_INC = -g \\\n"
            "-I$(LIB_SRC)/finiteVolume/lnInclude \\\n"
            "-I$(LIB_SRC)/meshTools/lnInclude \\\n"
            "-I$(LIB_SRC)/sampling/lnInclude \\\n"
            "-I$(LIB_SRC)/fvOptions/lnInclude \\\n"
            + context.options()
            + "\n\nLIB_LIBS = \\\n"
            + "    -lmeshTools \\\n"
            + "    -lfvOptions \\\n"
            + "    -lsampling \\\n"
            + "    -lfiniteVolume \\\n"
            + context.libs()
        );
}
コード例 #3
0
void Foam::codedFixedValueFvPatchField<Type>::prepare
(
    dynamicCode& dynCode,
    const dynamicCodeContext& context
) const
{
    // take no chances - typeName must be identical to redirectType_
    dynCode.setFilterVariable("typeName", redirectType_);

    // set TemplateType and FieldType filter variables
    // (for fvPatchField)
    setFieldTemplates(dynCode);

    // compile filtered C template
    dynCode.addCompileFile(codeTemplateC);

    // copy filtered H template
    dynCode.addCopyFile(codeTemplateH);


    // debugging: make BC verbose
    //  dynCode.setFilterVariable("verbose", "true");
    //  Info<<"compile " << redirectType_ << " sha1: "
    //      << context.sha1() << endl;

    // define Make/options
    dynCode.setMakeOptions
        (
            "EXE_INC = -g \\\n"
            "-I$(LIB_SRC)/finiteVolume/lnInclude \\\n"
            + context.options()
            + "\n\nLIB_LIBS = \\\n"
            + "    -lOpenFOAM \\\n"
            + "    -lfiniteVolume \\\n"
            + context.libs()
        );
}
コード例 #4
0
void Foam::codedFunctionObject::createLibrary
(
    dynamicCode& dynCode,
    const dynamicCodeContext& context
) const
{
    bool create = Pstream::master();

    if (create)
    {
        // Write files for new library
        if (!dynCode.upToDate(context))
        {
            // filter with this context
            dynCode.reset(context);

            // Set additional rewrite rules
            dynCode.setFilterVariable("typeName", redirectType_);
            dynCode.setFilterVariable("codeRead", codeRead_);
            dynCode.setFilterVariable("codeExecute", codeExecute_);
            dynCode.setFilterVariable("codeEnd", codeEnd_);
            //dynCode.setFilterVariable("codeWrite", codeWrite_);

            // compile filtered C template
            dynCode.addCompileFile("functionObjectTemplate.C");
            dynCode.addCompileFile("FilterFunctionObjectTemplate.C");

            // copy filtered H template
            dynCode.addCopyFile("FilterFunctionObjectTemplate.H");
            dynCode.addCopyFile("functionObjectTemplate.H");
            dynCode.addCopyFile("IOfunctionObjectTemplate.H");

            // debugging: make BC verbose
            //         dynCode.setFilterVariable("verbose", "true");
            //         Info<<"compile " << redirectType_ << " sha1: "
            //             << context.sha1() << endl;

            // define Make/options
            dynCode.setMakeOptions
            (
                "EXE_INC = -g \\\n"
                "-I$(LIB_SRC)/finiteVolume/lnInclude \\\n"
              + context.options()
              + "\n\nLIB_LIBS = \\\n"
              + "    -lOpenFOAM \\\n"
              + "    -lfiniteVolume \\\n"
              + context.libs()
            );

            if (!dynCode.copyOrCreateFiles(true))
            {
                FatalIOErrorIn
                (
                    "codedFunctionObject::createLibrary(..)",
                    context.dict()
                )   << "Failed writing files for" << nl
                    << dynCode.libRelPath() << nl
                    << exit(FatalIOError);
            }
        }

        if (!dynCode.wmakeLibso())
        {
            FatalIOErrorIn
            (
                "codedFunctionObject::createLibrary(..)",
                context.dict()
            )   << "Failed wmake " << dynCode.libRelPath() << nl
                << exit(FatalIOError);
        }
    }


    // all processes must wait for compile to finish
    reduce(create, orOp<bool>());
}
コード例 #5
0
void Foam::codedFixedValueFvPatchField<Type>::createLibrary
(
    dynamicCode& dynCode,
    const dynamicCodeContext& context
) const
{
    bool create = Pstream::master();

    if (create)
    {
        // Write files for new library
        if (!dynCode.upToDate(context))
        {
            // filter with this context
            dynCode.reset(context);

            // take no chances - typeName must be identical to redirectType_
            dynCode.setFilterVariable("typeName", redirectType_);

            // set TemplateType and FieldType filter variables
            // (for fvPatchField)
            setFieldTemplates(dynCode);

            // compile filtered C template
            dynCode.addCompileFile(codeTemplateC);

            // copy filtered H template
            dynCode.addCopyFile(codeTemplateH);


            // debugging: make BC verbose
            //  dynCode.setFilterVariable("verbose", "true");
            //  Info<<"compile " << redirectType_ << " sha1: "
            //      << context.sha1() << endl;

            // define Make/options
            dynCode.setMakeOptions
            (
                "EXE_INC = -g \\\n"
                "-I$(LIB_SRC)/finiteVolume/lnInclude \\\n"
              + context.options()
              + "\n\nLIB_LIBS = \\\n"
              + "    -lOpenFOAM \\\n"
              + "    -lfiniteVolume \\\n"
              + context.libs()
            );

            if (!dynCode.copyOrCreateFiles(true))
            {
                FatalIOErrorIn
                (
                    "codedFixedValueFvPatchField<Type>::createLibrary(..)",
                    context.dict()
                )   << "Failed writing files for" << nl
                    << dynCode.libRelPath() << nl
                    << exit(FatalIOError);
            }
        }

        if (!dynCode.wmakeLibso())
        {
            FatalIOErrorIn
            (
                "codedFixedValueFvPatchField<Type>::createLibrary(..)",
                context.dict()
            )   << "Failed wmake " << dynCode.libRelPath() << nl
                << exit(FatalIOError);
        }
    }


    // all processes must wait for compile to finish
    reduce(create, orOp<bool>());
}