Download data/applications/test/PatchEdgeFaceWave/Test-PatchEdgeFaceWave.C from introvoyz042/OpenFOAM-dev: direct link, hf CLI and curl.
- Browser
- Download file 4.76 kB
-
https://huggingface.co/datasets/introvoyz042/OpenFOAM-dev/resolve/main/data/applications/test/PatchEdgeFaceWave/Test-PatchEdgeFaceWave.C
- Command line
-
hf download hf://datasets/introvoyz042/OpenFOAM-dev/data/applications/test/PatchEdgeFaceWave/Test-PatchEdgeFaceWave.C
-
curl -L -o Test-PatchEdgeFaceWave.C https://huggingface.co/datasets/introvoyz042/OpenFOAM-dev/resolve/main/data/applications/test/PatchEdgeFaceWave/Test-PatchEdgeFaceWave.C
4.76 kB
| /*---------------------------------------------------------------------------*\ | |
| ========= | | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | |
| \\ / O peration | Website: https://openfoam.org | |
| \\ / A nd | Copyright (C) 2011-2026 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/>. | |
| Description | |
| Test PatchEdgeFaceWave. | |
| \*---------------------------------------------------------------------------*/ | |
| using namespace Foam; | |
| // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // | |
| int main(int argc, char *argv[]) | |
| { | |
| argList::validArgs.append("patch"); | |
| const polyBoundaryMesh& patches = mesh.poly().boundary(); | |
| // Get name of patch | |
| const word patchName = args[1]; | |
| const polyPatch& patch = patches[patchName]; | |
| // 1. Walk from a single edge | |
| { | |
| // Data on all edges and faces | |
| List<patchEdgeFacePoint> allEdgeInfo(patch.nEdges()); | |
| List<patchEdgeFacePoint> allFaceInfo(patch.size()); | |
| // Initial seed | |
| DynamicList<label> initialEdges; | |
| DynamicList<patchEdgeFacePoint> initialEdgesInfo; | |
| // Just set an edge on the master | |
| if (Pstream::master()) | |
| { | |
| label edgeI = 0; | |
| Info<< "Starting walk on edge " << edgeI << endl; | |
| initialEdges.append(edgeI); | |
| const edge& e = patch.edges()[edgeI]; | |
| initialEdgesInfo.append | |
| ( | |
| patchEdgeFacePoint | |
| ( | |
| e.centre(patch.localPoints()), | |
| 0.0 | |
| ) | |
| ); | |
| } | |
| // Walk | |
| PatchEdgeFaceWave<primitivePatch, patchEdgeFacePoint> calc | |
| ( | |
| mesh, | |
| patch, | |
| initialEdges, | |
| initialEdgesInfo, | |
| allEdgeInfo, | |
| allFaceInfo, | |
| returnReduce(patch.nEdges(), sumOp()) | |
| ); | |
| // Extract as patchField | |
| volScalarField vsf | |
| ( | |
| IOobject | |
| ( | |
| "patchDist", | |
| runTime.name(), | |
| mesh, | |
| IOobject::NO_READ, | |
| IOobject::AUTO_WRITE | |
| ), | |
| mesh, | |
| dimensionedScalar(dimensions::length, 0) | |
| ); | |
| scalarField pf(vsf.boundaryField()[patch.index()].size()); | |
| forAll(pf, facei) | |
| { | |
| pf[facei] = Foam::sqrt(allFaceInfo[facei].distSqr()); | |
| } | |
| vsf.boundaryFieldRef()[patch.index()] = pf; | |
| Info<< "Writing patchDist volScalarField to " << runTime.value() | |
| << endl; | |
| vsf.write(); | |
| } | |
| // 2. Use a wrapper to walk from all boundary edges on selected patches | |
| { | |
| labelHashSet otherPatchIDs(identityMap(mesh.poly().boundary().size())); | |
| otherPatchIDs.erase(patch.index()); | |
| Info<< "Walking on patch " << patch.index() | |
| << " from edges shared with patches " << otherPatchIDs | |
| << endl; | |
| patchPatchDist pwd(patch, otherPatchIDs); | |
| // Extract as patchField | |
| volScalarField vsf | |
| ( | |
| IOobject | |
| ( | |
| "otherPatchDist", | |
| runTime.name(), | |
| mesh, | |
| IOobject::NO_READ, | |
| IOobject::AUTO_WRITE | |
| ), | |
| mesh, | |
| dimensionedScalar(dimensions::length, 0) | |
| ); | |
| vsf.boundaryFieldRef()[patch.index()] = pwd; | |
| Info<< "Writing otherPatchDist volScalarField to " << runTime.value() | |
| << endl; | |
| vsf.write(); | |
| } | |
| Info<< "\nEnd\n" << endl; | |
| return 0; | |
| } | |
| // ************************************************************************* // | |