Skip to main content

Common Fluids Format 2023 R2

CffBase

Last update: 16.07.2025
1/*
2 * Copyright ANSYS. All Rights Reserved.
3 */
4
5#ifndef CFFSDK_CFFINTERFACE_CFFBASE_HPP_
6#define CFFSDK_CFFINTERFACE_CFFBASE_HPP_
7
8#include "LibraryType.hpp"
9
10#include "CffVersion.hpp"
11#include "Types.hpp"
12#include "CffLocationModel.hpp"
13#include "CffSettingsParser.hpp"
14#include "CffSolutionModel.hpp"
15#include "CffVariableAttributeProvider.hpp"
16
17#include <cstddef>
18#include <list>
19#include <map>
20#include <memory>
21#include <string>
22#include <vector>
23
24#if defined(_WIN32)
25#pragma warning(push)
26#pragma warning(disable:4251)
27#endif
28
29namespace ansys {
30
31class CffLocationModel;
32class CffMessageRegistrar;
33class DataInterface;
34
35class ANSYS_FLUIDS_CFFINTERFACE_DLL CffBase : public CffVersion {
36public:
37 CffBase();
38
39 virtual ~CffBase();
40
41 void setApplicationName(const std::string& applicationName);
42
43 void setMeshId(const MeshIdType meshId);
44
45 MeshIdType getMeshId() const;
46
47 void setTarget(const TargetCategory target);
48
49 TargetCategory getTarget() const;
50
51 void setPartitionId(const PartitionIdType pId);
52
53 PartitionIdType getPartitionId() const;
54
55 virtual void setDebugOn(bool debug);
56 virtual void setReadNCIOn(bool readNCI);
57
58 void setMeshSize(const MeshSizeType type, const ElemIdType size);
59 void getMeshSize(const MeshSizeType type, ElemIdType& size) const;
60
61 void setMeshUnits(const std::string& units = "m");
62 void getMeshUnits(std::string& unit) const;
63
64 void setZoneIds(const ZoneCategory zoneCategory, const ZoneIds& zonesIds);
65
66 virtual size_t getNumZones(const ZoneCategory) const;
67
68 virtual void getZoneIds(const ZoneCategory zoneCategory,
69 ZoneIds& zoneIds) const;
70
71 void setNodeZoneInfo(const ZoneIdType nodeZoneId,
72 const NodeZoneInfoType nodeZoneInfoType,
73 const int info) const;
74
75 void getNodeZoneInfo(const ZoneIdType nodeZoneId,
76 const NodeZoneInfoType nodeZoneInfoType,
77 int& info) const;
78
79 void setAllFaceZoneFlags(const ZoneIdType faceZoneId, const int allFlags);
80
81 void getAllFaceZoneFlags(const ZoneIdType faceZoneId, int& allFlags) const;
82
83 void setFaceZoneType(const ZoneIdType faceZoneId,
84 const FaceZoneType zoneType);
85
86 void getFaceZoneType(const ZoneIdType faceZoneId,
87 FaceZoneType& zoneType) const;
88
89 void setFaceZoneInfo(const ZoneIdType faceZoneId,
90 const FaceZoneInfoType faceZoneInfoType,
91 const int info) const;
92
93 void getFaceZoneInfo(const ZoneIdType faceZoneId,
94 const FaceZoneInfoType faceZoneInfoType,
95 int& info) const;
96
97 void setFaceZoneProp(const ZoneIdType faceZoneId,
98 const FaceZonePropType faceZonePropType);
99
100 bool getFaceZoneProp(const ZoneIdType faceZoneId,
101 const FaceZonePropType) const;
102
103 void setZoneSizeInfo(const ZoneIdType zoneId,
104 const ZoneSizeType sizeType,
105 const ElemIdType size);
106
107 void getZoneSizeInfo(const ZoneIdType zoneId,
108 const ZoneSizeType sizeType,
109 ElemIdType& size) const;
110
111 void setCellZoneInfo(const ZoneIdType cellZoneId,
112 const CellZoneInfoType cellZoneInfoType,
113 const int info);
114
115 void getCellZoneInfo(const ZoneIdType cellZoneId,
116 const CellZoneInfoType cellZoneInfoType,
117 int& info) const;
118
119 void
120 setEdgeZoneType(const ZoneIdType edgeZoneId,
121 const EdgeZoneType zoneType);
122
123 void
124 getEdgeZoneType(const ZoneIdType edgeZoneId,
125 EdgeZoneType& zoneType) const;
126
127 void
128 setEdgeZoneInfo(const ZoneIdType edgeZoneId,
129 const EdgeZoneInfoType edgeZoneInfoType,
130 const int info);
131
132 void
133 getEdgeZoneInfo(const ZoneIdType edgeZoneId,
134 const EdgeZoneInfoType edgeZoneInfoType,
135 int& info) const;
136
137 void
138 setZoneStringInfo(const ZoneIdType zoneId,
139 const ZoneStringInfoType type,
140 const std::string& info);
141
142 void
143 getZoneStringInfo(const ZoneIdType zoneId,
144 const ZoneStringInfoType type,
145 std::string& info) const;
146
147 void
148 getPhaseIds(PhaseIds& phaseIds) const;
149
150 bool
151 getPhaseName(const PhaseIdType phaseId, PhaseName& phaseName) const;
152
154 getPhaseName(const PhaseIdType phaseId) const;
155
156 void
157 getFaceCellZone0Ids(const ZoneIdType faceZoneId,
158 std::list<ZoneIdType>& zoneIds);
159
160 void
161 getFaceCellZone1Ids(const ZoneIdType faceZoneId,
162 std::list<ZoneIdType>& zoneIds);
163
164 void
165 getCellFaceZoneIds(const ZoneIdType cellZoneId,
166 std::list<ZoneIdType>& zoneIds);
167
168 virtual void
169 setSolverType(SolverType solverType);
170
172 getSolverType() const;
173
174 const TimeLevels&
175 getTimeLevels() const;
176
178 getTimeLevel() const;
179
180 const CffLocationModel*
181 getLocationModel() const;
182
183 void
184 setVariableAttributeProvider(const CffVariableAttributeProvider*,
185 bool takeOwnership = false);
186
187 CffMessageRegistrar* getMessageRegistrar() const;
188
189 bool
190 hasError() const;
191
192 bool
193 hasWarning() const;
194
195 bool
196 hasInfo() const;
197
198 std::vector<std::string>
199 getErrors(bool formated = true,bool clear = false) const;
200
201 std::vector<std::string>
202 getWarnings(bool formated = true,bool clear = false) const;
203
204 std::vector<std::string>
205 getInfos(bool formated = true,bool clear = false) const;
206
207protected:
208 CffReadable isSupported(const std::string& version) const;
209
210 void setMeshSize(const ElemIdType nDims,
211 const ElemIdType nodesCount,
212 const ElemIdType edgesCount,
213 const ElemIdType facesCount,
214 const ElemIdType cellsCount);
215
216 virtual void setZoneAdjacency();
217
218 void setFaceCellZone0Ids(const std::map<ZoneIdType, std::list<ZoneIdType> >&);
219
220 void setFaceCellZone1Ids(const std::map<ZoneIdType, std::list<ZoneIdType> >&);
221
222 void getFaceCellZone0Ids(std::map<ZoneIdType, std::list<ZoneIdType> >&);
223
224 void getFaceCellZone1Ids(std::map<ZoneIdType, std::list<ZoneIdType> >&);
225
226 void setCellFaceZoneIds(const std::map<ZoneIdType, std::list<ZoneIdType> >&);
227
228 void setZoneCategory(const ZoneIds&, const ZoneCategory);
229
230 ZoneCategory getZoneCategory(const ZoneIdType zoneId) const;
231
232 void getSortedMinIdZoneId(
233 const ZoneCategory,
234 std::vector<std::pair<ElemIdType, ZoneIdType> >& minIdZoneId) const;
235
236 std::string getGroupNameForPhase(PhaseIdType phaseId) const;
237
238 CffSolutionModel* solutionModel() const;
239
240 virtual void initLocationModel() const {}
241 CffLocationModel* locationModel() const;
242
243 void addVariableOfCategory(VariableIdType, ZoneCategory) const;
244
245 void initializeVariableAttributeProvider(const SolverType& solverType,
246 const std::string& variableTarget);
247
248public:
249 void registerSettingsParser(CffSettingsParser*);
250
251 bool addSetting(const DataClass dataClass,
252 const std::string& key,
253 const std::string& value,
254 const SolverType& solverType = "CFF_GENERIC");
255
256 bool addSettingsDataSet(const DataClass dataClass,
257 const std::string& dataSetPath,
258 const std::string& data,
259 const SolverType& solverType = "CFF_GENERIC",
260 const std::vector<std::string>& settingsKeys= std::vector<std::string>());
261
262 static std::string _defaultSettingsPath;
263
264protected:
265 std::string getApplicationName() const;
266
267 void addTimeLevel(TimeLevelType) const;
268 bool setTimeLevel(TimeLevelType) const;
269
270 bool getActivePhase(PhaseIdType&) const;
271 bool setActivePhase(PhaseIdType) const;
272
273 bool getActivePhase(PhaseName&) const;
274 bool setActivePhase(const PhaseName&) const;
275
276 virtual bool updateData(DataClass) { return true; }
277
278 enum class UpdateMethod { CaseOnly = 1, ResultsOnly, CaseAndResults };
279 bool setMeshContext(MeshId, TargetCategory, PartitionIdType,
280 UpdateMethod = UpdateMethod::CaseAndResults);
281
282private:
283 void initializeVariableMappingConfigurations();
284
285protected:
286 std::unique_ptr<DataInterface> _data;
287 std::unique_ptr<const CffVariableAttributeProvider> _varAttrProvider;
288
289private:
290 std::string _applicationName;
291 SolverType _solverType;
292 std::string _variableTarget;
293 mutable bool _isLocationModelInitialised;
294 std::unique_ptr<CffLocationModel> _locationModel;
295 std::map<SolverType, CffSettingsParser*> _settingsParsers;
296 bool _varAttrProviderOwned;
297};
298
299#if defined(_WIN32)
300#pragma warning(pop)
301#endif
302
303} // namespace ansys
304
305#endif // CFFSDK_CFFINTERFACE_CFFBASE_HPP_
Base class that provides common function used by both CffConsumer and CffProvider classes.
Definition: CffBase.hpp:35
A Topology model providing user visible topological names.
Definition: CffLocationModel.hpp:64
Provides some basic version extraction and comparison functions.
Definition: CffVersion.hpp:14
CffReadable
An enumerator indicating how well a given file is supported by the API being used.
Definition: CffTypes.h:35
CffFaceZoneType
An enumerated type representing the boundary type of a face zone which may be returned from the funct...
Definition: CffTypes.h:507
CffZoneCategory
An enumeration that is used with ansys::CffBase::getNumZones, ansys::CffBase::getZoneIds,...
Definition: CffTypes.h:195
CffTargetCategory
An enumeration that represents the target models available within a CFF database.
Definition: CffTypes.h:109
CffZoneSizeType
An enumeration that is used to query or suppply the first and last element ids within a zone,...
Definition: CffTypes.h:223
CffZoneStringInfoType
An enumerated type that used when querying or setting string properties of zones using ansys::CffBase...
Definition: CffTypes.h:365
CffFaceZoneInfoType
An enumerated type that used when querying or setting information that is specific to a face zones us...
Definition: CffTypes.h:273
CffCellZoneInfoType
An enumerated type that used when querying or setting information that is specific to a cell zones us...
Definition: CffTypes.h:321
CffEdgeZoneInfoType
An enumerated type that used when querying or setting information that is specific to a edge zones us...
Definition: CffTypes.h:257
CffDataClass
An enumeration that is used within the API to caterorize types of CFF data.
Definition: CffTypes.h:415
CffEdgeZoneType
An enumerated type representing the type of an edge zone which may be returned from the function ansy...
Definition: CffTypes.h:468
CffNodeZoneInfoType
An enumerated type that used when querying or setting information that is specific to a node zones us...
Definition: CffTypes.h:243
CffFaceZonePropType
An enumerated type that used when querying or setting Fluent properties that are specific to faces zo...
Definition: CffTypes.h:347
CffMeshSizeType
An enumeration that is used with ansys::CffBase::getMeshSize and ansys::CffBase::setMeshSize.
Definition: CffTypes.h:173
std::vector< TimeLevelType > TimeLevels
Type used to represent a number of time levels ('C++' API only)
Definition: Types.hpp:114
std::string SolverType
Type used to represent the solver type ('C++' API only)
Definition: Types.hpp:214
std::vector< ZoneIdType > ZoneIds
Type used to represent a number of zone identifiers('C++' API only)
Definition: Types.hpp:149
CffZoneIdType ZoneIdType
Alias for CffZoneIdType ('C++' API only)
Definition: Types.hpp:144
std::vector< PhaseIdType > PhaseIds
Type used to represent a number of phase identifiers ids('C++' API only)
Definition: Types.hpp:159
CffMeshIdType MeshIdType
Alias for CffMeshIdType ('C++' API only)
Definition: Types.hpp:26
CffPartitionIdType PartitionIdType
Alias for CffPartitionIdType ('C++' API only)
Definition: Types.hpp:31
CffTimeLevelType TimeLevelType
Alias for CffTimeLevelType ('C++' API only)
Definition: Types.hpp:109
CffPhaseIdType PhaseIdType
Alias for CffPhaseIdType ('C++' API only)
Definition: Types.hpp:154
CffVariableIdType VariableIdType
Type used to represent the identifier of a variable ('C++' API only)
Definition: Types.hpp:184
CffElemIdType ElemIdType
Alias for CffElemIdType ('C++' API only)
Definition: Types.hpp:56
std::string PhaseName
Type used to represent a name of a phase ('C++' API only)
Definition: Types.hpp:164
Definition: API.dox:1

Connect with Ansys