FaceZoneValueExpressionDriver::FaceZoneValueExpressionDriver(const word& id,const fvMesh&mesh)
 :
    SubsetValueExpressionDriver(true,false),
    faceZone_(
        mesh.faceZones()[
            getFaceZoneID(
                mesh,
                id
            )
        ]
    )
{
}
Exemple #2
0
Foam::dbse::dbse
(
    Time& runTime,
    fvMesh& mesh,
    const dictionary& snapEdgeDict
)
:
    runTime_(runTime),
    mesh_(mesh),
    dict_(snapEdgeDict),
    patches_(mesh.boundaryMesh()),
    zones_(mesh.faceZones()),
    points_(mesh.points()),
    snapPatches_(dict_.lookup("snapPatches")),
    snapZones_(dict_.lookup("snapZones")),
    stlFileNames_(dict_.lookup("stlFileNames")),
    tolerance_(readScalar(dict_.lookup("tolerance"))),
    relaxation_(readScalar(dict_.lookup("relaxation"))),
    featureAngle_(readScalar(dict_.lookup("featureAngle"))),
    excludeAngle_(readScalar(dict_.lookup("excludeEdgeAngle"))),
    parallelAngle_(readScalar(dict_.lookup("parallelAngle"))),
    includeInterior_(readBool(dict_.lookup("includeInterior"))),
    nIterations_(readLabel(dict_.lookup("nIterations"))),
    fitFactor_(readScalar(dict_.lookup("fitFactor"))),
    minFit_(-mag(fitFactor_)),
    maxFit_(1.0 + mag(fitFactor_)),

    newPoints_(points_),
    edgePoints_(0),
    nSTL_(stlFileNames_.size()),
    stlFeatures_(nSTL_),
    globalSTLPoints_(nSTL_),
    nEdgePoints_(nSTL_),

    cosFeature_(::cos(featureAngle_*deg2rad_)),
    cosFeature2_(::cos(featureAngle_*0.5*deg2rad_)),
    cosExclude_(::cos(excludeAngle_*deg2rad_)),
    cosParAngle_(::cos(parallelAngle_*deg2rad_)),
    smallestEdgeLength_(GREAT)

{

    forAll(stlFileNames_, is)
    {
        word stlFileName(stlFileNames_[is]);
	fileName stlFile("constant/triSurface/"+stlFileName);
        triSurface stlSurface(stlFile);
        
        const edgeList& stlEdges = stlSurface.edges();    
        const labelListList& stlEdgeFaces = stlSurface.edgeFaces();
        const vectorField& stlSf = stlSurface.faceNormals();
        const vectorField& stlPoints = stlSurface.localPoints();
        addToList(globalSTLPoints_[is], stlPoints);
        nEdgePoints_[is].setSize(stlPoints.size());

        Info << "Finding features for stl : " << stlFileName << endl;
        forAll(stlEdgeFaces, i)
        {
            if(!stlSurface.isInternalEdge(i))
            {
                addToList(stlFeatures_[is], stlEdges[i]);
                nEdgePoints_[is][stlEdges[i][0]]++;
                nEdgePoints_[is][stlEdges[i][1]]++;
            }
            else
            {
                label fi0 = stlEdgeFaces[i][0];
                label fi1 = stlEdgeFaces[i][1];
        
                scalar magF0 = mag(stlSf[fi0]);
                scalar magF1 = mag(stlSf[fi1]);
                if ( (magF0 < 1.0e-5) || (magF1 < 1.0e-5))
                {
                    Info << "Warning:: face normals are zero!?!" << endl;
                }
                vector f0 = stlSf[fi0]/magF0;
                vector f1 = stlSf[fi1]/magF1;
        
                scalar cosa = f0 & f1;
                if (cosa < cosFeature_)
                {
                    addToList(stlFeatures_[is], stlEdges[i]);
                    nEdgePoints_[is][stlEdges[i][0]]++;
                    nEdgePoints_[is][stlEdges[i][1]]++;
                }
            }
        }

        if (stlFeatures_[is].size() == 0)
        {
            Info << "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" << endl;
            Info << "WARNING!!! Your stl does not contain any feature lines." << endl;
            Info << "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" << endl;
        }

    }