Loading...
Searching...
No Matches
rawTopoChangerFvMeshTemplates.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2024 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
30
31template<class Type, template<class> class PatchField, class GeoMesh>
32void Foam::rawTopoChangerFvMesh::setUnmappedValues
33(
34 GeometricField<Type, PatchField, GeoMesh>& fld,
35 const bitSet& mappedFace,
36 const GeometricField<Type, PatchField, GeoMesh>& baseFld
37)
38{
39 //Pout<< "Checking field " << fld.name() << endl;
40
41 forAll(fld.boundaryField(), patchi)
42 {
43 auto& fvp = const_cast<PatchField<Type>&>(fld.boundaryField()[patchi]);
44
45 const label start = fvp.patch().start();
46 forAll(fvp, i)
47 {
48 if (!mappedFace[start+i])
49 {
50 //Pout<< "** Resetting unassigned value on patch "
51 // << fvp.patch().name()
52 // << " localface:" << i
53 // << " to:" << baseFld.boundaryField()[patchi][i] << endl;
54 fvp[i] = baseFld.boundaryField()[patchi][i];
55 }
56 }
57 }
58}
59
60
61template<class Type, template<class> class PatchField, class GeoMesh>
62void Foam::rawTopoChangerFvMesh::zeroUnmappedValues
63(
64 const bitSet& mappedFace
65) const
66{
68
69 std::unique_ptr<FieldType> zeroFieldPtr;
70
71 for (const word& fldName : names<FieldType>())
72 {
73 FieldType& fld = lookupObjectRef<FieldType>(fldName);
74 //Pout<< "Checking field " << fld.name() << endl;
75
76 if (!zeroFieldPtr)
77 {
78 zeroFieldPtr = std::make_unique<FieldType>
79 (
80 this->newIOobject("zero"),
81 *this,
82 Foam::zero{},
84 );
85 }
86
87 zeroFieldPtr->dimensions().reset(fld.dimensions());
88
89 setUnmappedValues(fld, mappedFace, *zeroFieldPtr);
90 }
91}
92
93
94// ************************************************************************* //
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Definition GeoMesh.H:46
Generic GeometricField class.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition bitSet.H:61
A class for handling words, derived from Foam::string.
Definition word.H:66
auto & names
const dimensionSet dimless
Dimensionless.
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299