DACheckMesh.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2 
3  DAFoam : Discrete Adjoint with OpenFOAM
4  Version : v3
5 
6 \*---------------------------------------------------------------------------*/
7 
8 #include "DACheckMesh.H"
9 
10 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
11 
12 namespace Foam
13 {
14 
15 // Constructors
16 DACheckMesh::DACheckMesh(
17  const DAOption& daOption,
18  const Time& runTime1,
19  const fvMesh& mesh1)
20  : daOption_(daOption),
21  runTime(runTime1),
22  mesh(mesh1),
23  surfWriter(nullptr),
24  setWriter(nullptr)
25 {
26  // Give an option to overwrite the default value of mesh quality check threshold
27  fvMesh& meshNew = const_cast<fvMesh&>(mesh);
28  maxNonOrth_ = daOption_.getSubDictOption<scalar>("checkMeshThreshold", "maxNonOrth");
29  maxSkewness_ = daOption_.getSubDictOption<scalar>("checkMeshThreshold", "maxSkewness");
30  maxAspectRatio_ = daOption_.getSubDictOption<scalar>("checkMeshThreshold", "maxAspectRatio");
31  maxIncorrectlyOrientedFaces_ =
32  daOption_.getSubDictOption<label>("checkMeshThreshold", "maxIncorrectlyOrientedFaces");
33  meshNew.setNonOrthThreshold(maxNonOrth_);
34  meshNew.setSkewThreshold(maxSkewness_);
35  meshNew.setAspectThreshold(maxAspectRatio_);
36 
37  Info << "DACheckMesh Thresholds: " << endl;
38  Info << "maxNonOrth: " << maxNonOrth_ << endl;
39  Info << "maxSkewness: " << maxSkewness_ << endl;
40  Info << "maxAspectRatio: " << maxAspectRatio_ << endl;
41  Info << "maxIncorrectlyOrientedFaces: " << maxIncorrectlyOrientedFaces_ << endl;
42 
43  word surfaceFormat = "vtk";
44  surfWriter.reset(surfaceWriter::New(surfaceFormat));
45  setWriter.reset(writer<scalar>::New(vtkSetWriter<scalar>::typeName));
46 }
47 
49 {
50 }
51 
52 label DACheckMesh::run() const
53 {
54  /*
55  Description:
56  Run checkMesh and return meshOK
57 
58  Output:
59  meshOK: 1 means quality passes
60  */
61 
62  label meshOK = 1;
63 
64  Info << "Checking mesh quality for time = " << runTime.timeName() << endl;
65 
66  label nFailedChecks = checkGeometry(mesh, surfWriter, setWriter, maxIncorrectlyOrientedFaces_);
67 
68  if (nFailedChecks)
69  {
70  Info << "\nFailed " << nFailedChecks << " mesh checks.\n"
71  << endl;
72  meshOK = 0;
73  }
74  else
75  {
76  Info << "\nMesh OK.\n"
77  << endl;
78  }
79 
80  return meshOK;
81 }
82 
83 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
84 
85 } // End namespace Foam
86 
87 // ************************************************************************* //
Foam::DAOption
Definition: DAOption.H:29
DACheckMesh.H
daOption
DAOption daOption(mesh, pyOptions_)
mesh
fvMesh & mesh
Definition: createRefsHeatTransfer.H:4
Foam::DAOption::getSubDictOption
classType getSubDictOption(const word subDict, const word subDictKey) const
get an dictionary option from subDict and key
Definition: DAOption.H:165
Foam
Definition: multiFreqScalarFvPatchField.C:144
Foam::checkGeometry
label checkGeometry(const polyMesh &mesh, const autoPtr< surfaceWriter > &surfWriter, const autoPtr< writer< scalar >> &setWriter, const label maxIncorrectlyOrientedFaces)
check mesh quality
Definition: checkGeometry.C:233
Foam::DACheckMesh::~DACheckMesh
virtual ~DACheckMesh()
Destructor.
Definition: DACheckMesh.C:48
runTime
Time & runTime
Definition: createRefsHeatTransfer.H:1
Foam::DACheckMesh::run
label run() const
run meshCheck and return meshOK
Definition: DACheckMesh.C:52