Loading...
Searching...
No Matches
convertLagrangian.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) 2018-2022 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
12
13Description
14 Code chunk for post-processing conversion of cloud(s) to Ensight
15
16\*---------------------------------------------------------------------------*/
17
18// Cloud field data output
19if (doLagrangian)
20{
21 // Lagrangian
22 const auto& cloudFields = regionCloudFields[regioni];
23 const auto& cloudNames = regionCloudNames[regioni];
24
25 for (const word& cloudName : cloudNames)
26 {
27 const HashTable<word>& theseCloudFields = cloudFields[cloudName];
28
29 fileNameList currentCloudDirs
30 (
31 readDir
32 (
33 runTime.timePath()/regionDir/cloud::prefix,
34 fileName::DIRECTORY
35 )
36 );
37
38 Info<< "Cloud " << cloudName << " (";
39
40 const bool cloudExists =
41 returnReduceOr(currentCloudDirs.found(cloudName));
42
43 {
44 autoPtr<ensightFile> os = ensCase.newCloud(cloudName);
45
46 ensightOutput::writeCloudPositions
47 (
48 os.ref(),
49 mesh,
51 cloudExists
52 );
53
54 Info<< " positions";
55 if (!cloudExists)
56 {
57 Info<< "{0}"; // report empty field
58 }
59 }
60
61 // Field order may differ on individual processors, so sort by name
62 for (const word& fieldName : theseCloudFields.sortedToc())
63 {
64 const word& fieldType = theseCloudFields[fieldName];
65
66 IOobject fieldObject
67 (
68 fieldName,
69 mesh.time().timeName(),
70 cloud::prefix/cloudName,
71 mesh,
72 IOobject::MUST_READ
73 );
74
75 bool fieldExists = cloudExists; // No field without positions
76 if (cloudExists)
77 {
78 // Want MUST_READ (globally) and valid=false (locally),
79 // but that combination does not work.
80 // So check the header and sync globally
81
82 const bool oldParRun = UPstream::parRun(false);
83 fieldExists = fieldObject.typeHeaderOk<IOField<scalar>>(false);
84 UPstream::parRun(oldParRun); // Restore parallel state
85 UPstream::reduceOr(fieldExists, UPstream::worldComm);
86 }
87
88 bool wrote = false;
89 do
90 {
91 #undef doLocalWriteCode
92 #define doLocalWriteCode(Type) \
93 \
94 if (fieldType == IOField<Type>::typeName) \
95 { \
96 autoPtr<ensightFile> os = \
97 ensCase.newCloudData<Type> \
98 ( \
99 cloudName, \
100 fieldName \
101 ); \
102 \
103 wrote = ensightOutput::readWriteCloudField<Type> \
104 ( \
105 os.ref(), \
106 fieldObject, \
107 fieldExists \
108 ); \
109 break; \
110 }
111
112 doLocalWriteCode(scalar);
114
115 #undef doLocalWriteCode
116 }
117 while (false);
118
119 if (wrote)
120 {
121 Info<< ' ' << fieldName;
122 if (!fieldExists)
123 {
124 Info<< "{0}"; // report empty field
125 }
126 }
127 }
128 Info<< " )" << nl;
129 }
130}
131
132
133// ************************************************************************* //
const word cloudName(propsDict.get< word >("cloud"))
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
dynamicFvMesh & mesh
engineTime & runTime
OBJstream os(runTime.globalPath()/outputName)
List< wordList > regionCloudNames(meshes.size())
List< HashTable< HashTable< word > > > regionCloudFields(meshes.size())
const word & regionDir
#define doLocalWriteCode(Type)