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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
12 
13 Description
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.
19 bool hasMovingMesh(false);
20 
21 if (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;
30 
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",
47  timeName,
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
81 reduce(hasMovingMesh, orOp<bool>());
82 
83 // ************************************************************************* //
Foam::boolList
List< bool > boolList
A List of bools.
Definition: List.H:65
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::flush
Ostream & flush(Ostream &os)
Flush stream.
Definition: Ostream.H:361
Foam::pointIOField
vectorIOField pointIOField
pointIOField is a vectorIOField.
Definition: pointIOField.H:44
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
meshes
Foam::PtrList< Foam::fvMesh > meshes(regionNames.size())
timeName
word timeName
Definition: getTimeIndex.H:3
reduce
reduce(hasMovingMesh, orOp< bool >())
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
hasMovingMesh
bool hasMovingMesh(false)