domainDecompositionWrite.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) 2021 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "domainDecomposition.H"
30 #include "volFields.H"
32 
33 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
34 
36 (
37  const word& timeName
38 ) const
39 {
40  const labelList& procIds = this->cellToProc();
41 
42  // Write decomposition as volScalarField for visualization
43  volScalarField cellDist
44  (
45  IOobject
46  (
47  "cellDist",
48  timeName,
49  this->mesh(),
52  false
53  ),
54  this->mesh(),
55  dimensionedScalar("cellDist", dimless, -1),
56  zeroGradientFvPatchScalarField::typeName
57  );
58 
59  forAll(procIds, celli)
60  {
61  cellDist[celli] = procIds[celli];
62  }
63 
64  cellDist.correctBoundaryConditions();
65  cellDist.write();
66 
67  Info<< nl << "Wrote decomposition to "
68  << cellDist.objectRelPath()
69  << " (volScalarField) for visualization."
70  << endl;
71 }
72 
73 
74 void Foam::domainDecomposition::writeVTK(const fileName& file) const
75 {
76  const vtk::vtuCells cells(this->mesh());
77 
78  // not parallel
79  vtk::internalMeshWriter writer(this->mesh(), cells, file, false);
80 
83  writer.writeCellData("procID", cellToProc());
84 
85  Info<< "Wrote decomposition to "
86  << this->mesh().time().relativePath(writer.output())
87  << " for visualization."
88  << endl;
89 }
90 
91 
92 // ************************************************************************* //
Foam::IOobject::NO_WRITE
@ NO_WRITE
Definition: IOobject.H:191
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:63
volFields.H
Foam::domainDecomposition::writeVolField
void writeVolField(const word &timeName) const
Foam::vtk::fileWriter::output
const fileName & output() const noexcept
Definition: foamVtkFileWriterI.H:85
Foam::IOobject::IOobject
IOobject(const IOobject &)=default
Foam::endl
Ostream & endl(Ostream &os)
Definition: Ostream.H:381
domainDecomposition.H
forAll
#define forAll(list, i)
Definition: stdFoam.H:349
Foam::TimePaths::relativePath
fileName relativePath(const fileName &input, const bool caseTag=false) const
Definition: TimePathsI.H:80
Foam::Info
messageStream Info
Foam::domainDecomposition::mesh
const fvMesh & mesh() const noexcept
Definition: domainDecomposition.H:180
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:36
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:53
timeName
word timeName
Definition: getTimeIndex.H:3
Foam::vtk::internalMeshWriter::writeCellData
void writeCellData(const word &fieldName, const UList< Type > &field)
Definition: foamVtkInternalMeshWriterTemplates.C:65
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::domainDecomposition::writeVTK
void writeVTK(const fileName &file) const
Foam::domainDecomposition::cellToProc
const labelList & cellToProc() const noexcept
Definition: domainDecomposition.H:219
Foam::nl
constexpr char nl
Definition: Ostream.H:424
Foam::vtk::internalMeshWriter::beginCellData
virtual bool beginCellData(label nFields=0)
Definition: foamVtkInternalMeshWriter.C:589
foamVtkInternalMeshWriter.H
Foam::fvMesh::time
const Time & time() const
Definition: fvMesh.H:276
cells
const cellShapeList & cells
Definition: gmvOutputHeader.H:3
Foam::IOobject::NO_READ
@ NO_READ
Definition: IOobject.H:184
writer
vtk::internalMeshWriter writer(topoMesh, topoCells, vtk::formatType::INLINE_ASCII, runTime.path()/"blockTopology")
zeroGradientFvPatchFields.H
Foam::vtk::internalMeshWriter::writeGeometry
virtual bool writeGeometry()
Definition: foamVtkInternalMeshWriter.C:552
Foam::dimless
const dimensionSet dimless
Definition: dimensionSets.C:182