切结边界网格命名问题



  • 我想将我的边界根据边界条件的不同类型划分为不同的类型场,以便以后调用,但是现在的代码报错

        const GeometricField<vector, fvPatchField, volMesh>::Boundary& 
            uBCs = U.boundaryField();
    
        forAll(uBCs, patchi)
        {
            if (uBCs[patchi].type() == "farField") //inlet
            {
                gSurf_.boundaryField().set
                (
                    patchi, 
                    fvsPatchField<scalar>::New
                    (
                        "farField", mesh.boundary()[patchi], gSurf_
                    )
                );
            }
            else if (uBCs[patchi].type() == "bounceBack") //maxwellWall
            {
                gSurf_.boundaryField().set
                (
                    patchi, 
                    fvsPatchField<scalar>::New
                    (
                        "bounceBack", mesh.boundary()[patchi], gSurf_
                    )
                );
            }
        }
    

    错误原因是

    createFields.H: In function ‘int main(int, char**)’:
    createFields.H:160:13: error: passing ‘const Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh>::Boundary’ as ‘this’ argument discards qualifiers [-fpermissive]
                 );
    

    求解我这问题在哪啊



  • 你第一段代码用在哪里了?

    把你createFields.H贴一下?



  • @李东岳 相关的createField.H

        volVectorField U
        (
            IOobject
            (
                "U",
                runTime.timeName(),
                mesh,
                IOobject::MUST_READ,
                IOobject::AUTO_WRITE
            ),
            mesh
        );
    
        surfaceScalarField gSurf_
        (
            IOobject
            (
                "gSurf",
                mesh.time().timeName(),
                mesh,
                IOobject::NO_READ,
                IOobject::NO_WRITE
            ),
            mesh,
            dimensionedScalar
            (
                "0", dimMass/pow3(dimLength), 0.0
            )
        );
    

    应该就这些了吧



  • 你用的什么版本,试试把U.boundaryField()改为U.boundaryFieldRef()


登录后回复
 

与 CFD中文网 的连接断开,我们正在尝试重连,请耐心等待