CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   FaceID from code to FaceSet from FaceID is not properly obtained. (https://www.cfd-online.com/Forums/openfoam-programming-development/236008-faceid-code-faceset-faceid-not-properly-obtained.html)

sunagra27 May 10, 2021 00:55

FaceID from code to FaceSet from FaceID is not properly obtained.
 
Dear all,


I have a 3D domain which consists of 3 patches in total.


I wanted to extract the faceID of one particular patch and convert to faceSet so that I could obtain BC using createPatch for that faceSet.


I obtained faceID from the below code:


Code:

code
      #{

   
        const fvPatch& mesh = this->patch();
        const fvBoundaryMesh& boundaryMesh = mesh.boundaryMesh();
   
   
        for (int patch = 0; patch < 1; patch++)
        {
       
            const word& patchName = mesh.boundaryMesh()[patch].name();
            Info << patchName << endl;
            std::ofstream file;
            file.open("faceID.txt");
            for (int facei = 0; facei < mesh.boundaryMesh()[patch].size(); facei++)
            {
           
                const label& face = boundaryMesh[patch].start() + facei;
                Info << face << endl;
                file << face << endl;
                file << nl << endl;
           
            }
       
            file.close();

        }

I have outputted to file and created faceSet using topoSet. Then, I created this faceSet to VTK format using foamToVTK -faceset "name".



All these are working fine.



But, when I visualize in paraview, the patch is taking faceIDs from different patch too, even though the length of the facelabels is same as the current patch. How is this possible? What wrong am I doing?


I have attached two images, one with what faceSet has been obtained from code and the other with what I needed ( the one with complete plain structure).


1. Original which I wanted from code:
https://drive.google.com/file/d/1_9A...ew?usp=sharing


2. What I have obtained from code:
https://drive.google.com/file/d/14QM...ew?usp=sharing


Any leads will be appreciated.


Regards,


Sunag R A.


All times are GMT -4. The time now is 21:51.