CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   conjugateHeatFoam for 4 different regions (https://www.cfd-online.com/Forums/openfoam/104325-conjugateheatfoam-4-different-regions.html)

lg88 July 6, 2012 21:04

conjugateHeatFoam for 4 different regions
 
1 Attachment(s)
Hello everybody,
I am going to use conjugateHeatFoam to simulate a conduction problem in a multi region case, thus including solid regions and fluid regions. I am using OF 1.6-ext.
There are 4 different regions, corresponding to different materials: A and C are solids, B and D is fluid (laminar). All the mesh is hexa,
Can solver conjugateHeatFoam realize my need?Do I need to modify the solver code?
thank you very much!

regards!

lg88

wyldckat July 9, 2012 17:29

Greetings lg88,

In response to the private message you sent me:
I'm not familiar with conjugateHeatFoam. But I think that chtMultiRegionFoam should be able to solve this issue, but again, I'm not very familiar with either one of these solvers.

Best regards,
Bruno

lg88 July 9, 2012 21:20

Thank you for your suggestion.But I am familiar with conjugateHeatFoam and my new solver is based on it.I hope use the solver to solve my problem.I found some information about the same problem I meet at [url]http://www.cfd-online.com/Forums/openfoam/89684-conjugateheatfoam-arbitrary-number-region.html.But there is not detailed construction.
Can anyone give me some idea?

Thank you very much!

lg88

su_junwei July 9, 2012 21:34

Quote:

Originally Posted by lg88 (Post 370178)
Hello everybody,
I am going to use conjugateHeatFoam to simulate a conduction problem in a multi region case, thus including solid regions and fluid regions. I am using OF 1.6-ext.
There are 4 different regions, corresponding to different materials: A and C are solids, B and D is fluid (laminar). All the mesh is hexa,
Can solver conjugateHeatFoam realize my need?Do I need to modify the solver code?
thank you very much!

regards!

lg88

conjugateHeatFoam can only deal with two different regions, three or more regions are not allowed. Use chtMultiRegionFoam instead please.

Regards, Junwei

lg88 July 11, 2012 00:25

hello
Thank you for your suggestion .I have checked in the forum and found that some people had applied conjugateHeatFoam to multi-regions successfully.And my new foam is developed based on the conjugateHeatFoam.

regards!

lg88

benk July 13, 2012 17:43

You need to edit the files attachPatches.H and detachPateches.H. You then have a main region and all other regions are treated as submeshes of the main region.

I've only done this for 3 regions, but 4 or more is definitely possible.

attachPatches.H (for 3 regions):

Code:

{
    const polyPatchList& patches = mesh.boundaryMesh();

    forAll (patches, patchI)
    {
        if (isType<regionCouplePolyPatch>(patches[patchI]))
        {
            const regionCouplePolyPatch& rcp =
                refCast<const regionCouplePolyPatch>(patches[patchI]);

            // Attach it here
            rcp.attach();
        }
    }

    // Force recalculation of weights
    mesh.surfaceInterpolation::movePoints();
   
    const polyPatchList& patches1 = separatorMesh.boundaryMesh();

    forAll (patches1, patchI)
    {
        if (isType<regionCouplePolyPatch>(patches1[patchI]))
        {
            const regionCouplePolyPatch& rcp =
                refCast<const regionCouplePolyPatch>(patches1[patchI]);

            // Attach it here
            rcp.attach();
        }
    }

    // Force recalculation of weights
    separatorMesh.surfaceInterpolation::movePoints();
   
    const polyPatchList& patches2 = positiveMesh.boundaryMesh();

    forAll (patches2, patchI)
    {
        if (isType<regionCouplePolyPatch>(patches2[patchI]))
        {
            const regionCouplePolyPatch& rcp =
                refCast<const regionCouplePolyPatch>(patches2[patchI]);

            // Attach it here
            rcp.attach();
        }
    }

    // Force recalculation of weights
    positiveMesh.surfaceInterpolation::movePoints();
}

detachPatches.H (for 3 regions):

Code:

{
    const polyPatchList& patches = mesh.boundaryMesh();

    forAll (patches, patchI)
    {
        if (isType<regionCouplePolyPatch>(patches[patchI]))
        {
            const regionCouplePolyPatch& rcp =
                refCast<const regionCouplePolyPatch>(patches[patchI]);

            // Detach it here
            rcp.detach();
        }
    }

    // Force recalculation of weights
    mesh.surfaceInterpolation::movePoints();

    const polyPatchList& patches1 = separatorMesh.boundaryMesh();

    forAll (patches1, patchI)
    {
        if (isType<regionCouplePolyPatch>(patches1[patchI]))
        {
            const regionCouplePolyPatch& rcp =
                refCast<const regionCouplePolyPatch>(patches1[patchI]);

            // Detach it here
            rcp.detach();
        }
    }

    // Force recalculation of weights
    separatorMesh.surfaceInterpolation::movePoints();
   
    const polyPatchList& patches2 = positiveMesh.boundaryMesh();

    forAll (patches2, patchI)
    {
        if (isType<regionCouplePolyPatch>(patches2[patchI]))
        {
            const regionCouplePolyPatch& rcp =
                refCast<const regionCouplePolyPatch>(patches2[patchI]);

            // Detach it here
            rcp.detach();
        }
    }

    // Force recalculation of weights
    positiveMesh.surfaceInterpolation::movePoints();
}

In the above, my submeshes are called "separatorMesh" and "positiveMesh".

Then in case/constant you have:
polyMesh/... (for the main mesh)
positive/polyMesh/... (for one submesh)
separator/polyMesh/... (for the other submesh)

In case/0 you have:
{fields for main mesh}
positive/{fields for positive mesh}
separator/{fields for separator mesh}

bryant_k July 14, 2012 10:53

Thank you for your detailed construction.I am also looking for the multi-region function of conjugateHeatFoam.

Regards!

kob

lg88 July 14, 2012 11:01

@benk
Thank you very much.I have modified my code as you said. Now it can work fluently and I am waiting for the results.Hoping it will work.

Regards!

lg88

ramon August 25, 2012 15:17

can anyone send me a simple tutorial of conjugateHeatFoam for multiregion (2fluid & 1solid) ?
Can anyone give me some idea?
thanks

mscheng October 19, 2013 22:35

Quote:

Originally Posted by lg88 (Post 371442)
@benk
Thank you very much.I have modified my code as you said. Now it can work fluently and I am waiting for the results.Hoping it will work.

Regards!

lg88

Hi lg88,

In your case, can the boudaryField fully show in the solution file (such as T) using conjugateHeatFoam?

Thanks!
CHENG

nilvxingren July 30, 2020 21:35

Hi, benk
I modified my code like these
attachPatches.H (for 4 regions):
Code:

{
    const polyPatchList& patches = mesh.boundaryMesh();

    forAll (patches, patchI)
    {
        if (isType<regionCouplePolyPatch>(patches[patchI]))
        {
            const regionCouplePolyPatch& rcp =
                refCast<const regionCouplePolyPatch>(patches[patchI]);

            // Attach it here
            rcp.attach();
        }
    }

    // Force recalculation of weights
    mesh.surfaceInterpolation::movePoints();

    //solidone
    const polyPatchList& patches1 = solidMesh1.boundaryMesh();

    forAll (patches1, patchI)
    {
        if (isType<regionCouplePolyPatch>(patches1[patchI]))
        {
            const regionCouplePolyPatch& rcp =
                refCast<const regionCouplePolyPatch>(patches1[patchI]);

            // Attach it here
            rcp.attach();
        }
    }

    // Force recalculation of weights
    solidMesh1.surfaceInterpolation::movePoints();


    //solidtwo
    const polyPatchList& patches2 = solidMesh2.boundaryMesh();

    forAll (patches2, patchI)
    {
        if (isType<regionCouplePolyPatch>(patches2[patchI]))
        {
            const regionCouplePolyPatch& rcp =
                refCast<const regionCouplePolyPatch>(patches2[patchI]);

            // Attach it here
            rcp.attach();
        }
    }

    // Force recalculation of weights
    solidMesh2.surfaceInterpolation::movePoints();

    //solidthree
    const polyPatchList& patches3 = solidMesh3.boundaryMesh();

    forAll (patches3, patchI)
    {
        if (isType<regionCouplePolyPatch>(patches3[patchI]))
        {
            const regionCouplePolyPatch& rcp =
                refCast<const regionCouplePolyPatch>(patches3[patchI]);

            // Attach it here
            rcp.attach();
        }
    }

    // Force recalculation of weights
    solidMesh3.surfaceInterpolation::movePoints();
}

detachPatches.H (for 4 regions):

Code:

{
    const polyPatchList& patches = mesh.boundaryMesh();

    forAll (patches, patchI)
    {
        if (isType<regionCouplePolyPatch>(patches[patchI]))
        {
            const regionCouplePolyPatch& rcp =
                refCast<const regionCouplePolyPatch>(patches[patchI]);

            // Detach it here
            rcp.detach();
        }
    }

    // Force recalculation of weights
    mesh.surfaceInterpolation::movePoints();

    //solidone
    const polyPatchList& patches1 = solidMesh1.boundaryMesh();

    forAll (patches1, patchI)
    {
        if (isType<regionCouplePolyPatch>(patches1[patchI]))
        {
            const regionCouplePolyPatch& rcp =
                refCast<const regionCouplePolyPatch>(patches1[patchI]);

            // Detach it here
            rcp.detach();
        }
    }

    // Force recalculation of weights
    solidMesh1.surfaceInterpolation::movePoints();


    //solidtwo
    const polyPatchList& patches2 = solidtMesh2.boundaryMesh();

    forAll (patches2, patchI)
    {
        if (isType<regionCouplePolyPatch>(patches2[patchI]))
        {
            const regionCouplePolyPatch& rcp =
                refCast<const regionCouplePolyPatch>(patches2[patchI]);

            // Detach it here
            rcp.detach();
        }
    }

    // Force recalculation of weights
    solidMesh2.surfaceInterpolation::movePoints();

    //solidthree
    const polyPatchList& patches3 = solidMesh3.boundaryMesh();

    forAll (patches3, patchI)
    {
        if (isType<regionCouplePolyPatch>(patches3[patchI]))
        {
            const regionCouplePolyPatch& rcp =
                refCast<const regionCouplePolyPatch>(patches3[patchI]);

            // Detach it here
            rcp.detach();
        }
    }

    // Force recalculation of weights
    solidMesh3.surfaceInterpolation::movePoints();
}

but, when I wmake, compile error has occurred:

Code:

In file included from createFields.H(80),
                from conjugateHeatThreesSimpleFoam.C(51):
attachPatches.H(20): error: identifier "solidMesh1" is undefined
      const polyPatchList& patches1 = solidMesh1.boundaryMesh();
                                      ^

In file included from createFields.H(80),
                from conjugateHeatThreesSimpleFoam.C(51):
attachPatches.H(39): error: identifier "solidMesh2" is undefined
      const polyPatchList& patches2 = solidMesh2.boundaryMesh();
                                      ^

In file included from createFields.H(80),
                from conjugateHeatThreesSimpleFoam.C(51):
attachPatches.H(57): error: identifier "solidMesh3" is undefined
      const polyPatchList& patches3 = solidMesh3.boundaryMesh();
                                      ^

In file included from conjugateHeatThreesSimpleFoam.C(67):
detachPatches.H(20): error: identifier "solidMesh1" is undefined
      const polyPatchList& patches1 = solidMesh1.boundaryMesh();
                                      ^

In file included from conjugateHeatThreesSimpleFoam.C(67):
detachPatches.H(39): error: identifier "solidtMesh2" is undefined
      const polyPatchList& patches2 = solidtMesh2.boundaryMesh();
                                      ^

In file included from conjugateHeatThreesSimpleFoam.C(67):
detachPatches.H(54): error: identifier "solidMesh2" is undefined
      solidMesh2.surfaceInterpolation::movePoints();
      ^

In file included from conjugateHeatThreesSimpleFoam.C(67):
detachPatches.H(58): error: identifier "solidMesh3" is undefined
      const polyPatchList& patches3 = solidMesh3.boundaryMesh();
                                      ^

In file included from conjugateHeatThreesSimpleFoam.C(87):
attachPatches.H(20): error: identifier "solidMesh1" is undefined
      const polyPatchList& patches1 = solidMesh1.boundaryMesh();
                                      ^

In file included from conjugateHeatThreesSimpleFoam.C(87):
attachPatches.H(39): error: identifier "solidMesh2" is undefined
      const polyPatchList& patches2 = solidMesh2.boundaryMesh();
                                      ^

In file included from conjugateHeatThreesSimpleFoam.C(87):
attachPatches.H(57): error: identifier "solidMesh3" is undefined
      const polyPatchList& patches3 = solidMesh3.boundaryMesh();
                                      ^

compilation aborted for conjugateHeatThreesSimpleFoam.C (code 2)

Am I missing something?
Thank you very much


All times are GMT -4. The time now is 15:52.