checkMeshMoving.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 Check for "points" in any of the result directories (each region)
15
16\*---------------------------------------------------------------------------*/
17
18// All regions moving, or no regions moving. Do not mix.
19bool hasMovingMesh(false);
20
21if (timeDirs.size() > 1)
22{
23 // We already loaded meshes (usually from constant).
24 // See if any other "polyMesh/points" files exist too.
25
26 // Do all regions as moving, or all as static.
27
28 boolList isMoving(meshes.size(), false);
29 label nMoving = 0;
31 Info<< "Search for moving mesh ... " << flush;
32 for (const instant& inst : timeDirs)
33 {
34 const word& timeName = inst.name();
35
36 forAll(meshes, regioni)
37 {
38 const fvMesh& mesh = meshes[regioni];
39
40 if
41 (
42 !isMoving[regioni]
43 && (timeName != mesh.pointsInstance())
44 && IOobject
45 (
46 "points",
48 polyMesh::meshSubDir,
49 mesh,
50 IOobject::NO_READ,
51 IOobject::NO_WRITE,
52 false // no register
53 ).typeHeaderOk<pointIOField>(true, false)
54 )
55 {
56 isMoving[regioni] = true;
57 ++nMoving;
58 }
59 }
60
61 if (nMoving == isMoving.size())
62 {
63 break;
64 }
65 }
66
67 if (nMoving)
68 {
69 Info<< "found " << nMoving
70 << " moving regions. Writing meshes for every timestep." << endl;
71 }
72 else
73 {
74 Info<< "none detected." << endl;
75 }
76
77 hasMovingMesh = (nMoving != 0);
78}
79
80// Ensure consistency
81reduce(hasMovingMesh, orOp<bool>());
82
83// ************************************************************************* //
bool hasMovingMesh(false)
reduce(hasMovingMesh, orOp< bool >())
label size() const noexcept
The number of elements in the list.
Definition: UPtrListI.H:106
dynamicFvMesh & mesh
Foam::PtrList< Foam::fvMesh > meshes(regionNames.size())
word timeName
Definition: getTimeIndex.H:3
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333