92 #include "fv_reader_tags.h"
96 unsigned int fv_encode_elem_header(
int elem_type,
int wall_info[]);
107 static word getFieldViewName(
const word& foamName)
109 if (FieldviewNames.found(foamName))
111 return FieldviewNames[foamName];
124 Info<<
" " << names[fieldI] <<
'/' << getFieldViewName(names[fieldI]);
143 if (!usedVerts.found(f[fp]))
145 usedVerts.insert(f[fp]);
149 return usedVerts.toc().size();
153 static void writeFaceData
159 const bool writePolyFaces,
160 std::ofstream& fvFile
168 floatField fField(topo.
nPolyFaces()[patchI], 0.0);
174 if (pp[faceI].size() > 4)
176 fField[polyFaceI++] = float(patchField[faceI]);
182 reinterpret_cast<char*>(fField.begin()), fField.size()*
sizeof(float)
187 floatField fField(pp.size() - topo.
nPolyFaces()[patchI], 0.0);
193 if (pp[faceI].size() <= 4)
195 fField[quadFaceI++] = float(patchField[faceI]);
201 reinterpret_cast<char*>(fField.begin()), fField.size()*
sizeof(float)
210 int main(
int argc,
char *argv[])
224 FieldviewNames.insert(
"alpha",
"aalpha");
225 FieldviewNames.insert(
"Alpha",
"AAlpha");
226 FieldviewNames.insert(
"fsmach",
"ffsmach");
227 FieldviewNames.insert(
"FSMach",
"FFSMach");
228 FieldviewNames.insert(
"re",
"rre");
229 FieldviewNames.insert(
"Re",
"RRe");
230 FieldviewNames.insert(
"time",
"ttime");
231 FieldviewNames.insert(
"Time",
"TTime");
232 FieldviewNames.insert(
"pi",
"ppi");
233 FieldviewNames.insert(
"PI",
"PPI");
234 FieldviewNames.insert(
"x",
"xx");
235 FieldviewNames.insert(
"X",
"XX");
236 FieldviewNames.insert(
"y",
"yy");
237 FieldviewNames.insert(
"Y",
"YY");
238 FieldviewNames.insert(
"z",
"zz");
239 FieldviewNames.insert(
"Z",
"ZZ");
240 FieldviewNames.insert(
"rcyl",
"rrcyl");
241 FieldviewNames.insert(
"Rcyl",
"RRcyl");
242 FieldviewNames.insert(
"theta",
"ttheta");
243 FieldviewNames.insert(
"Theta",
"TTheta");
244 FieldviewNames.insert(
"rsphere",
"rrsphere");
245 FieldviewNames.insert(
"Rsphere",
"RRsphere");
246 FieldviewNames.insert(
"k",
"kk");
247 FieldviewNames.insert(
"Kcond",
"KKcond");
259 bool hasLagrangian =
false;
262 hasLagrangian =
true;
265 Info<<
"All fields: Foam/Fieldview" <<
endl;
266 Info<<
" volScalar :";
269 Info<<
" volVector :";
272 Info<<
" surfScalar :";
275 Info<<
" surfVector :";
278 Info<<
" sprayScalar :";
281 Info<<
" sprayVector :";
291 fileName fvPath(runTime.path()/
"Fieldview");
300 fileName fvParticleFileName(fvPath/runTime.caseName() +
".fvp");
303 Info<<
"Opening particle file " << fvParticleFileName <<
endl;
305 std::ofstream fvParticleFile(fvParticleFileName.c_str());
316 label fieldViewTime = 0;
320 runTime.setTime(timeDirs[timeI], timeI);
321 Info<<
"Time: " << runTime.timeName() <<
endl;
343 Info<<
" Mesh read:" << endl
344 <<
" tet : " << topoPtr().nTet() << endl
345 <<
" hex : " << topoPtr().nHex() << endl
346 <<
" prism : " << topoPtr().nPrism() << endl
347 <<
" pyr : " << topoPtr().nPyr() << endl
348 <<
" poly : " << topoPtr().nPoly() << endl
354 Info<<
" Points file detected - updating points" <<
endl;
366 fvPath/runTime.caseName() +
"_" +
Foam::name(timeI) +
".uns"
369 Info<<
" file:" << fvFileName.c_str() <<
endl;
372 std::ofstream fvFile(fvFileName.c_str());
396 fBuf[0] = runTime.value();
400 fvFile.write(reinterpret_cast<char*>(fBuf), 4*
sizeof(
float));
415 forAll (mesh.boundary(), patchI)
417 const fvPatch& currPatch = mesh.boundary()[patchI];
449 Info<<
" dummy field for "
475 Info<<
" dummy surface field for "
499 floatField fField(nPoints);
501 for (label pointi = 0; pointi<
nPoints; pointi++)
503 fField[pointi] = float(points[pointi][cmpt]);
508 reinterpret_cast<char*>(fField.begin()),
509 fField.size()*
sizeof(float)
519 forAll(mesh.boundary(), patchI)
530 reinterpret_cast<const char*>
532 nQuadFaces*4*
sizeof(
int)
543 forAll(mesh.boundary(), patchI)
547 writeInt(fvFile, FV_ARB_POLY_FACES);
553 const polyPatch& patchFaces = mesh.boundary()[patchI].patch();
557 const face& f = patchFaces[faceI];
587 topo.
nTet()*(1+4)*
sizeof(
int)
592 topo.
nHex()*(1+8)*
sizeof(
int)
597 topo.
nPrism()*(1+6)*
sizeof(
int)
602 topo.
nPyr()*(1+5)*
sizeof(
int)
616 if (topo.
nPoly() > 0)
618 writeInt(fvFile, FV_ARB_POLY_ELEMENTS);
623 if (cellShapes[celli].model() == unknown)
630 writeInt(fvFile, countVerts(mesh, celli));
636 label faceI = cll[cellFacei];
654 for (label fp = f.
size()-1; fp >= 0; fp--)
688 floatField fField(nPoints);
690 for (label pointi = 0; pointi<
nPoints; pointi++)
692 fField[pointi] = float(psf[pointi]);
697 reinterpret_cast<char*>(fField.begin()),
698 fField.size()*
sizeof(float)
704 floatField dummyField(nPoints, 0.0);
708 reinterpret_cast<char*>(dummyField.begin()),
709 dummyField.size()*
sizeof(float)
730 forAll (mesh.boundary(), patchI)
757 reinterpret_cast<char*>(fField.begin()),
758 fField.size()*
sizeof(float)
771 forAll (mesh.boundary(), patchI)
798 reinterpret_cast<char*>(fField.begin()),
799 fField.size()*
sizeof(float)
812 writeInt(fvFile, FV_ARB_POLY_BNDRY_VARS);
820 forAll (mesh.boundary(), patchI)
835 forAll (mesh.boundary(), patchI)
838 floatField fField(topo.
nPolyFaces()[patchI], 0.0);
842 reinterpret_cast<char*>(fField.begin()),
843 fField.size()*
sizeof(float)
857 forAll(mesh.boundary(), patchI)
884 reinterpret_cast<char*>(fField.begin()),
885 fField.size()*
sizeof(float)
921 writeInt(fvParticleFile, fieldViewTime + 1);
930 writeInt(fvParticleFile, parcels.size());
932 Info<<
" Writing " << parcels.size() <<
" particles." <<
endl;
945 elmnt != parcels.end();
949 writeInt(fvParticleFile, parcelNo+1);
979 sprayVectorField[parcelNo];
1015 rm(fvParticleFileName);