decomposeFaFields.H
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-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
12
13Description
14 Write proc addressing and decompose area fields (parallel only).
15
16\*---------------------------------------------------------------------------*/
17
18if (doDecompose && Pstream::parRun())
19{
20 faMeshReconstructor reconstructor(aMesh);
21 reconstructor.writeAddressing();
22
23 Info<< "Wrote proc-addressing" << nl << endl;
24
25 // Handle area fields
26 // ------------------
28 faFieldDecomposer::fieldsCache areaFieldsCache;
29
30 const faMesh& fullMesh = reconstructor.mesh();
31
32 {
33 // Use uncollated (or master uncollated) file handler here.
34 // - each processor is reading in the identical serial fields.
35 // - nothing should be parallel-coordinated.
36
37 // Similarly, if we write the serial finite-area mesh, this is only
38 // done from one processor!
39
40 reconstructor.writeMesh();
41
42 if (doDecompFields)
43 {
44 const bool oldDistributed = fileHandler().distributed();
45 auto oldHandler = fileHandler(fileOperation::NewUncollated());
46 fileHandler().distributed(true);
47
48 IOobjectList objects(fullMesh.time(), runTime.timeName());
49
50 areaFieldsCache.readAllFields(fullMesh, objects);
51
52 // Restore old settings
53 if (oldHandler)
54 {
55 fileHandler(std::move(oldHandler));
56 }
57 fileHandler().distributed(oldDistributed);
58 }
59 }
60
61 const label nAreaFields = areaFieldsCache.size();
62
63 if (nAreaFields)
64 {
65 Info<< "Decomposing " << nAreaFields << " area fields" << nl;
66
67 faFieldDecomposer fieldDecomposer
68 (
69 fullMesh,
70 aMesh,
71 reconstructor.edgeProcAddressing(),
72 reconstructor.faceProcAddressing(),
73 reconstructor.boundaryProcAddressing()
74 );
75
76 // Report
77 areaFieldsCache.decomposeAllFields(fieldDecomposer, true);
78 Info<< endl;
79 }
80}
81
82
83// ************************************************************************* //
bool distributed() const noexcept
Distributed roots (parallel run)
engineTime & runTime
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
faMesh aMesh(mesh)