fvOptionsの使用でおきたエラー Entry 'name' not found in dictionary

76 views
Skip to first unread message

fujimoto

unread,
Aug 1, 2025, 2:07:57 AMAug 1
to OpenFOAM
お世話になっております。fujimotoです。
初歩的な質問で申し訳ないのですが、ぜひアドバイスをいただきたいです。

添付している画像のように下が固体(bottomSolid)、上が気体(topAir)の境界部分(bottomSolid側)にfvOptionsで熱量を加えようと考えています。そこでインターネット上の情報を見ながら試行錯誤してましたが、どうしても解決できない問題が出てきたので相談させていただきます。

fvOptionsを作成し、chtMultiRegionFoamを行ったところ、
Entry 'name' not found in dictionary "省略/0/bottomSolid/T/boundaryField/bottomSolid_to_topAir"
というようなエラーが出てきました。
ソースコード(/openfoam/openfoam2412/src/fvOptions/cellSetOption/cellSetOption.C)の説明を読んでも、'name'に関する説明がありませんでした。(ソースコードを全て読んでいけば分かるとは思いますが、その実力が今現在はありません。)

また、ケースディレクトリを添付します。chtMultiRegionFoamをおこなえば、エラーが再現できるようになっていると思います。

またfvOptionsの内容を以下に示します。お手数おかけしますがよろしくお願いいたします。

fujimoto

/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2412                                  |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    arch        "LSB;label=32;scalar=64";
    class       dictionary;
    location    "system/bottomSolid";
    object      fvOptions;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

energySource
{
    type            scalarCodedSource;
    name            sourceTime; 
   
    scalarCodedSourceCoeffs
    {
        selectionMode   all;

        fields          (h);

        codeCorrect
        #{
            Pout<< "**codeCorrect**" << endl;
        #};

        codeAddSup
        #{
            const Time& time = mesh().time();
            scalarField& heSource = eqn.source();
            const scalarField& cellx = mesh_.C().component(0);
            const scalarField& celly = mesh_.C().component(1);
            const scalarField& cellz = mesh_.C().component(2);
            const scalar qMax = 100; //熱量に関するパラメータ群
            const scalar absoptionRate = 0.4;
            const scalar x0 = 0.0;
            const scalar y0 = 0.0;
            const scalar radius = 0.01;
            const scalar startTime = 0.5;
            const scalar heatBottom = 0.019;
            const scalar pi = 3.1415;
            scalar q = 0;
            scalar r = 0;

            if (time.value() < startTime)
            {
                forAll(cellx, i)
                {
                    r = sqrt(pow(cellx[i], 2) + pow(celly[i], 2))
                    if (r < 1.5*radius && cellz[i] > heatBottom)
                    {
                        q = 2 * absoptionRate * qMax * exp(-2 * pow(r/radius, 2)) / (pi * pow(radius, 2));
                        heSource[cellI] += q;
                    }
                }
            }
        #};

        codeConstrain
        #{
            Pout<< "**codeConstrain**" << endl;
        #};
    }
}
tmp.png
cu_melting_fvoptions.zip

k k

unread,
Aug 1, 2025, 3:25:20 AMAug 1
to open...@googlegroups.com

こんにちは。

エラーを見ると領域分割かメッシュ作成あたりで失敗しているのではないでしょうか?

 

例えば、Allrun-serialを一気に計算実行まですると、splitMeshRegionsとかで失敗しているのにchtMultiRegionFoamを実行しようとしてエラーになることがあります。

確実に計算実行手前まで上手くいっているかを確認してからchtMultiRegionFoamを実行するのが良いかと思い、以下のようにしてみました。

 

1.Allrun-serialの以下をコメントアウトし、./Allrun-serialを実行。

======

# Run on single processor

# runApplication $(getApplication)

======

ここはうまくいきました。

 

2.次にchtMultiRegionFoamを実行すると、fvOptionsでエラーが出るので、以下のように変更するとうまくいきました。

■ r = sqrt(pow(cellx[i], 2) + pow(celly[i], 2));

;が忘れているので追加

■heSource[i] += q;

cellIは定義されていないのでiにした。

こちらは設定の意味を私が理解していないので、正しい設定にしてください。


上のように修正して改めてAllrun-serialのコメントアウトを外して実行すると計算までいけました。

 

ご確認よろしくお願いいたします。



2025年8月1日(金) 15:08 fujimoto <15000...@gmail.com>:
--
このメールは Google グループのグループ「OpenFOAM」に登録しているユーザーに送られています。
このグループから退会し、グループからのメールの配信を停止するには openfoam+u...@googlegroups.com にメールを送信してください。
このディスカッションを表示するには、https://groups.google.com/d/msgid/openfoam/24aa22c8-382a-4e99-8506-28009f03cdefn%40googlegroups.com にアクセスしてください。
Message has been deleted

fujimoto

unread,
Aug 2, 2025, 7:24:32 AMAug 2
to OpenFOAM
kk様

アドバイスありがとうございます。
返信が遅くなり申し訳ございません。

指摘していただいた内容を反映すると、次のようなエラーが起きました。

Using dynamicCode for fvOption::sourceTime at line 26 in "/home/Develop/openfoam/run/heatTransfer/chtMultiRegionFoam/cu_melting_fvoptions/system/bottomSolid/fvOptions/energySource/scalarCodedSourceCoeffs"
Selecting finite volume options type sourceTime
    Source: sourceTime
    - selecting all cells
    - selected 30000 cell(s) with volume 0.00019208

--> FOAM FATAL ERROR: (openfoam-2412 patch=250528)
Not implemented

そこで、ソースコード(openfoam/user-v2412/src/finiteVolume/cfdTools/general/fvOptions/fvOption.C)を見ると

void Foam::fv::option::addSup
(
    const volScalarField& rho,
    fvMatrix<scalar>& eqn,
    const label fieldi
)
{}

となっており、定義されていないように見受けられました。
これはESI版のopenfoam-2412ではfvoptionsによって熱量を与える( scalarCodedSource)はデフォルトの状態では出来ないという理解でよろしいでしょうか。

お手数おかけしますが、ご教授いただければ幸いです。

fujimoto

k k

unread,
Aug 2, 2025, 10:43:24 AMAug 2
to open...@googlegroups.com
こんにちは。
> これはESI版のopenfoam-2412ではfvoptionsによって熱量を与える( scalarCodedSource)はデフォルトの状態では出来ないという理解でよろしいでしょうか。
すみません。
ちゃんと調べていないので正確には答えられないですが、単純にメッシュ情報を取得して熱量を与えるのであれば、以下のようにsystem/controlDictで毎イタレーションで与えることもできると思います。

system/controlDict
functions
{
    #include "vtkWrite"
    customHeat
    {
        type coded;
        libs ("libutilityFunctionObjects.so");
        name customHeat;
        region bottomSolid;  // bottomSolid 領域だけ(座標で検知しているのであまり意味ないかもしれないが...)

        writeControl timeStep; // 用途に合わせて変更
        writeInterval 1; // 用途に合わせて変更

        codeExecute
        #{
            const Time& time = mesh().time();
            volScalarField& h = const_cast<volScalarField&>(mesh().lookupObject<volScalarField>("h"));

            const scalarField& cellx = mesh().C().component(0);
            const scalarField& celly = mesh().C().component(1);
            const scalarField& cellz = mesh().C().component(2);
            const scalarField& V = mesh().V();

            const scalar qMax = 100;
            const scalar absoptionRate = 0.4;
            const scalar radius = 0.01;
            const scalar startTime = 0.5;
            const scalar heatBottom = 0.019;
            const scalar pi = 3.1415;
   

            if (time.value() <startTime)
            {
                Info << "[customHeat] applying source at t = " << time.value() << endl;

                forAll(cellx, i)
                {
                    scalar r = sqrt(pow(cellx[i], 2) + pow(celly[i], 2));
                    if (r < 1.5 * radius && cellz[i] > heatBottom)
                    {
                        scalar q = 2 * absoptionRate * qMax *
                                   exp(-2 * pow(r / radius, 2)) / (pi * pow(radius, 2));
                        h[i] += q * V[i];  // 熱エネルギーを加える
                    }
                }
            }
        #};
    }
}
ご確認よろしくお願いいたします。

2025年8月2日(土) 20:24 fujimoto <15000...@gmail.com>:
--
このメールは Google グループのグループ「OpenFOAM」に登録しているユーザーに送られています。
このグループから退会し、グループからのメールの配信を停止するには openfoam+u...@googlegroups.com にメールを送信してください。
このディスカッションを表示するには、https://groups.google.com/d/msgid/openfoam/ab5f43a5-f630-4f17-b7ec-086c0e7569a3n%40googlegroups.com にアクセスしてください。
Message has been deleted

fujimoto

unread,
Aug 5, 2025, 12:45:20 AMAug 5
to OpenFOAM
kk様

fujimotoです。

なるほど、こういう方法があるのですね。てっきり、ソースコードをカスタムするか、openfoam foundation版を使用するしかないと考えていました。
非常に勉強になります。ありがとうございます。

試させていただきます。

fujimoto

2025年8月2日土曜日 23:43:24 UTC+9 k k:
Reply all
Reply to author
Forward
Message has been deleted
0 new messages