NEMoSys  0.63.0
A modular, extensible resource with robust automated mesh generation, mesh quality analysis, adaptive mesh refinement, and data transfer between arbitrary meshes.
FoamRefineDriver.H
Go to the documentation of this file.
1 /*******************************************************************************
2 * Promesh *
3 * Copyright (C) 2022, IllinoisRocstar LLC. All rights reserved. *
4 * *
5 * Promesh is the property of IllinoisRocstar LLC. *
6 * *
7 * IllinoisRocstar LLC *
8 * Champaign, IL *
9 * www.illinoisrocstar.com *
10 * promesh@illinoisrocstar.com *
11 *******************************************************************************/
12 /*******************************************************************************
13 * This file is part of Promesh *
14 * *
15 * This version of Promesh is free software: you can redistribute it and/or *
16 * modify it under the terms of the GNU Lesser General Public License as *
17 * published by the Free Software Foundation, either version 3 of the License, *
18 * or (at your option) any later version. *
19 * *
20 * Promesh is distributed in the hope that it will be useful, but WITHOUT ANY *
21 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more *
23 * details. *
24 * *
25 * You should have received a copy of the GNU Lesser General Public License *
26 * along with this program. If not, see <https://www.gnu.org/licenses/>. *
27 * *
28 *******************************************************************************/
29 #ifndef NEMOSYS_FOAMREFINEDRIVER_H_
30 #define NEMOSYS_FOAMREFINEDRIVER_H_
31 #include "nemosys_export.h"
33 
34 namespace NEM {
35 namespace DRV {
36 
37 struct NEMOSYS_EXPORT FoamRefineOptsBase {
38  public:
39  int refineInterval{1};
40  int maxRefinement{1};
41  int nBufferLayers{1};
42  int maxCells{500000};
43  bool writeFieldData{false};
44  bool writeMesh{false};
45  bool writeRefHistory{false};
46  double timeStep{1.};
47  double endTime{1.};
48  double startTime{0.};
49 
50  JSONCONS_TYPE_TRAITS_FRIEND
51 
52  protected:
53  // Hide; should use children
54  FoamRefineOptsBase() = default;
55  static constexpr const char *method = "FV";
56 };
57 
58 class NEMOSYS_EXPORT FoamRefineDriver : public RefineDriver {
59  public:
60  struct NEMOSYS_EXPORT Opts : public FoamRefineOptsBase {
61  public:
62  enum class Criteria { VALUE, GRADIENT };
63  Opts(Criteria refCriteria, std::string inputFieldFile);
64  std::string inputFieldFile{};
65  double lowerRefineLevel{-1.};
66  double upperRefineLevel{-1.};
67  double unrefineAbove{-1.};
68  double unrefineBelow{-1.};
69  Criteria refCriteria{};
70  JSONCONS_TYPE_TRAITS_FRIEND
71  private:
72  Opts() = default;
73  };
74 
75  FoamRefineDriver(Files files, Opts opts);
76 
77  const Opts &getOpts() const;
78  void setOpts(Opts opts);
79  void execute() const override;
80 
81  JSONCONS_TYPE_TRAITS_FRIEND
82 
83  private:
85 
87 };
88 
89 #ifdef MLAMR
90 class NEMOSYS_EXPORT FoamMLRefineDriver : public RefineDriver {
91  public:
92  struct NEMOSYS_EXPORT Opts : public FoamRefineOptsBase {
93  public:
94  Opts() = default;
95  std::string mlModel{"fdeep_model.json"};
96  JSONCONS_TYPE_TRAITS_FRIEND
97  private:
98  static constexpr const char *refCriteria = "ml";
99  };
100 
101  FoamMLRefineDriver(Files files, Opts opts);
102 
103  const Opts &getOpts() const;
104  void setOpts(Opts opts);
105  void execute() const override;
106 
107  JSONCONS_TYPE_TRAITS_FRIEND
108 
109  private:
110  FoamMLRefineDriver();
111 
112  Opts opts_;
113 };
114 #endif
115 
116 } // namespace DRV
117 } // namespace NEM
118 #endif // NEMOSYS_FOAMREFINEDRIVER_H_