Download data/src/OpenFOAM/meshes/polyMesh/polyMeshInitMesh.C from introvoyz042/OpenFOAM-dev: direct link, hf CLI and curl.
- Browser
- Download file 5.04 kB
-
https://huggingface.co/datasets/introvoyz042/OpenFOAM-dev/resolve/main/data/src/OpenFOAM/meshes/polyMesh/polyMeshInitMesh.C
- Command line
-
hf download hf://datasets/introvoyz042/OpenFOAM-dev/data/src/OpenFOAM/meshes/polyMesh/polyMeshInitMesh.C
-
curl -L -o polyMeshInitMesh.C https://huggingface.co/datasets/introvoyz042/OpenFOAM-dev/resolve/main/data/src/OpenFOAM/meshes/polyMesh/polyMeshInitMesh.C
5.04 kB
| /*---------------------------------------------------------------------------*\ | |
| ========= | | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | |
| \\ / O peration | Website: https://openfoam.org | |
| \\ / A nd | Copyright (C) 2011-2025 OpenFOAM Foundation | |
| \\/ M anipulation | | |
| ------------------------------------------------------------------------------- | |
| License | |
| This file is part of OpenFOAM. | |
| OpenFOAM is free software: you can redistribute it and/or modify it | |
| under the terms of the GNU General Public License as published by | |
| the Free Software Foundation, either version 3 of the License, or | |
| (at your option) any later version. | |
| OpenFOAM is distributed in the hope that it will be useful, but WITHOUT | |
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| for more details. | |
| You should have received a copy of the GNU General Public License | |
| along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. | |
| \*---------------------------------------------------------------------------*/ | |
| // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // | |
| void Foam::polyMesh::initMesh() | |
| { | |
| DebugInFunction << "Initialising primitiveMesh" << endl; | |
| // For backward compatibility check if the neighbour array is the same | |
| // length as the owner and shrink to remove the -1s padding | |
| if (neighbour_.size() == owner_.size()) | |
| { | |
| label nInternalFaces = 0; | |
| forAll(neighbour_, facei) | |
| { | |
| if (neighbour_[facei] == -1) | |
| { | |
| break; | |
| } | |
| else | |
| { | |
| nInternalFaces++; | |
| } | |
| } | |
| neighbour_.setSize(nInternalFaces); | |
| } | |
| label nCells = -1; | |
| forAll(owner_, facei) | |
| { | |
| if (owner_[facei] < 0) | |
| { | |
| FatalErrorInFunction | |
| << "Illegal cell label " << owner_[facei] | |
| << " in neighbour addressing for face " << facei | |
| << exit(FatalError); | |
| } | |
| nCells = max(nCells, owner_[facei]); | |
| } | |
| // The neighbour array may or may not be the same length as the owner | |
| forAll(neighbour_, facei) | |
| { | |
| if (neighbour_[facei] < 0) | |
| { | |
| FatalErrorInFunction | |
| << "Illegal cell label " << neighbour_[facei] | |
| << " in neighbour addressing for face " << facei | |
| << exit(FatalError); | |
| } | |
| nCells = max(nCells, neighbour_[facei]); | |
| } | |
| nCells++; | |
| // Reset the primitiveMesh with the sizes of the primitive arrays | |
| primitiveMesh::reset | |
| ( | |
| points_.size(), | |
| neighbour_.size(), | |
| owner_.size(), | |
| nCells | |
| ); | |
| string meshInfo = | |
| "nPoints:" + Foam::name(nPoints()) | |
| + " nCells:" + Foam::name(this->nCells()) | |
| + " nFaces:" + Foam::name(nFaces()) | |
| + " nInternalFaces:" + Foam::name(nInternalFaces()); | |
| owner_.note() = meshInfo; | |
| neighbour_.note() = meshInfo; | |
| } | |
| void Foam::polyMesh::initMesh(cellList& c) | |
| { | |
| DebugInFunction << "Calculating owner-neighbour arrays" << endl; | |
| owner_.setSize(faces_.size(), -1); | |
| neighbour_.setSize(faces_.size(), -1); | |
| boolList markedFaces(faces_.size(), false); | |
| label nInternalFaces = 0; | |
| forAll(c, celli) | |
| { | |
| // get reference to face labels for current cell | |
| const labelList& cellfaces = c[celli]; | |
| forAll(cellfaces, facei) | |
| { | |
| if (cellfaces[facei] < 0) | |
| { | |
| FatalErrorInFunction | |
| << "Illegal face label " << cellfaces[facei] | |
| << " in cell " << celli | |
| << exit(FatalError); | |
| } | |
| if (!markedFaces[cellfaces[facei]]) | |
| { | |
| // First visit: owner | |
| owner_[cellfaces[facei]] = celli; | |
| markedFaces[cellfaces[facei]] = true; | |
| } | |
| else | |
| { | |
| // Second visit: neighbour | |
| neighbour_[cellfaces[facei]] = celli; | |
| nInternalFaces++; | |
| } | |
| } | |
| } | |
| // The neighbour array is initialised with the same length as the owner | |
| // padded with -1s and here it is truncated to the correct size of the | |
| // number of internal faces. | |
| neighbour_.setSize(nInternalFaces); | |
| // Reset the primitiveMesh | |
| primitiveMesh::reset | |
| ( | |
| points_.size(), | |
| neighbour_.size(), | |
| owner_.size(), | |
| c.size(), | |
| c | |
| ); | |
| string meshInfo = | |
| "nPoints: " + Foam::name(nPoints()) | |
| + " nCells: " + Foam::name(nCells()) | |
| + " nFaces: " + Foam::name(nFaces()) | |
| + " nInternalFaces: " + Foam::name(this->nInternalFaces()); | |
| owner_.note() = meshInfo; | |
| neighbour_.note() = meshInfo; | |
| } | |
| // ************************************************************************* // | |