Skip to main content

Common Fluids Format 2023 R2

Ansys Common Fluids Examples

Last update: 27.11.2024

Introduction

A number of examples are available to help with understanding how to use the CFF API.

C++ examples

C examples

Reading Case and Data Files using C++ API

This example demonstrates how to use the CFF I/O SDK to read case and results files. To use it, you must provide the CFF case and data files on the command line.

/*
* Copyright ANSYS. All Rights Reserved.
*/
#include "CffInterface/printVersion.hpp"
#include "Factory/providers.hpp"
#include <algorithm>
#include <numeric>
#include "../Common/Output.hpp"
#include "../Common/Utilities.hpp"
#include "ReadByElement.hpp"
#include "ReadByZoneRange.hpp"
#include "ReadByZone.hpp"
void
showHelp(const std::string& arg0)
{
std::string prog(arg0);
size_t pos = prog.find_last_of("/\\");
std::string exec = pos == std::string::npos ? prog : prog.substr(pos+1);
std::cout << "Usage: " << exec << " [-h] [-H]"
<< std::endl
<< " [-c <cas-file>] [-d <dat-file>]"
<< std::endl
<< " [-q] "
<< std::endl
<< " [-O <method>] [-m <mesh>] [-t <target>]"
<< std::endl
<< " -h or -H Show this message."
<< std::endl;
std::cout << " -c <cas-file> Specify the cas file from which to read data."
<< std::endl
<< " If -c and -d options are missing 'elbow.cas.h5' will be used."
<< std::endl;
std::cout << " -d <dat-file> Specify the dat file from which to read data."
<< std::endl
<< " If -c and -d options are missing 'elbow.dat.h5' will be used."
<< std::endl;
std::cout << " -q Query the available meshes and targets."
<< std::endl;
std::cout << " -O <method> Specifies the method for reading heavy weight data for each zone"
<< std::endl
<< " <method> must be either:"
<< std::endl
<< " 'E' - read all data element by element."
<< std::endl
<< " 'R' - read all data using zone element range."
<< std::endl
<< " 'Z' - read all data by zone [Default]."
<< std::endl;
std::cout << " -m <mesh> Specifies the mesh with id <mesh> from which to read data."
<< std::endl;
std::cout << " -t <target> Specified the target from which to read data."
<< std::endl
<< " <target> must be either:"
<< std::endl
<< " 'restart'"
<< std::endl
<< " 'post'"
<< std::endl
<< std::endl;
}
bool
reportErrors(ansys::CffProvider* reader, const std::string& eTitle = "")
{
bool isOk = true;
if (reader) {
const auto& errors = reader->getErrors(false, true);
if (!errors.empty()) {
if (!eTitle.empty()) {
std::cerr << eTitle << std::endl;
}
for (const auto& e: errors) {
std::cerr << " " << e << std::endl;
}
isOk = false;
}
}
return isOk;
}
void
reportWarnings(ansys::CffProvider* reader)
{
if (reader) {
const auto& warnings = reader->getWarnings(false, true);
if (!warnings.empty()) {
for (const auto& w: warnings) {
std::cerr << w << std::endl;
}
}
}
}
int
main(int argc, char* argv[])
{
std::string casFileName;
std::string datFileName;
ansys::MeshIdType meshId = -1;
ansys::PartitionIdType partitionId = -1;
bool queryContents = false;
enum class HeavyweightReadMethod { Element, Range, Zone };
HeavyweightReadMethod heavyReadMethod = HeavyweightReadMethod::Element;
if (argc < 2) {
showHelp(argv[0]);
exit(0);
}
for (int n = 1; n != argc; ++n) {
std::string argValue(argv[n]);
if (argValue == "-h" || argValue == "-H") {
showHelp(argv[0]);
exit(0);
} else if (argValue == "-q") {
queryContents = true;
} else if (argValue == "-c") {
++n;
casFileName = std::string(argv[n]);
}
else if (argValue == "-d") {
++n;
datFileName = std::string(argv[n]);
}
else if (argValue == "-m") {
++n;
meshId = std::stoi(argv[n]);
}
else if (argValue == "-t") {
++n;
std::string target(argv[n]);
if (target == "restart") {
targetCategory = CFF_RESTART;
} else if (target == "post") {
targetCategory = CFF_POST;
} else if (target == "partitioned") {
targetCategory = CFF_PARTITIONED_POST;
}
}
else if (argValue == "-p") {
++n;
partitionId = std::stoi(argv[n]);
}
else if (argValue == "-O") {
++n;
char option = argv[n][0];
if (option == 'E') {
heavyReadMethod = HeavyweightReadMethod::Element;
} else if (option == 'R') {
heavyReadMethod = HeavyweightReadMethod::Range;
} else if (option == 'Z') {
heavyReadMethod = HeavyweightReadMethod::Zone;
}
}
}
// Fallback
if (casFileName.empty() && datFileName.empty()) {
casFileName = "elbow.cas.h5";
datFileName = "elbow.dat.h5";
}
if (queryContents && casFileName.empty()) {
std::cerr << "Unable to query contents without a case file" << std::endl;
exit(1);
}
std::unique_ptr<ansys::CffFileProvider> readerPtr;
if (!casFileName.empty()) {
readerPtr.reset(ansys::getDataProvider(casFileName));
} else if (!datFileName.empty()) {
readerPtr.reset(ansys::getDataProvider(datFileName));
}
if(!readerPtr) {
std::cerr << "Error creating provider for file" << std::endl;
return 1;
}
ansys::CffProvider& reader = *readerPtr;
if (queryContents) {
if (!readerPtr->startReading(casFileName, ansys::DataClass::CFF_CASE)) {
reportErrors(readerPtr.get(), "Error reading case file");
return 1;
}
reportWarnings(readerPtr.get());
DisplayMeshAndTargets(readerPtr.get());
exit(0);
}
// Set Mesh Id
if (meshId != -1) {
reader.setMeshId(meshId);
}
// Set Target
reader.setTarget(targetCategory);
// Set Partition Id
if (partitionId != -1) {
reader.setPartitionId(partitionId);
}
// Using default built-in options: debug=false, NCI=false, meshId=-1 (automatic), target = CFF_RESTART
//to switch to other format, need to setTarget to correct one.
if (!casFileName.empty()) {
if (!readerPtr->startReading(casFileName, ansys::DataClass::CFF_CASE)) {
reportErrors(readerPtr.get(), "Error reading case file");
return 1;
}
reportWarnings(readerPtr.get());
DisplayInfoForCase(readerPtr.get());
DisplayInfoForMesh(readerPtr.get());
DisplayInfoForNodeZones(readerPtr.get());
if (heavyReadMethod == HeavyweightReadMethod::Element) {
ReadNodeCoordinatesByElement(reader);
} else if (heavyReadMethod == HeavyweightReadMethod::Range) {
ReadNodeCoordinatesByZoneRange(reader);
} else {
ReadNodeCoordinatesByZone(reader);
}
// read edge related information
DisplayInfoForEdgeZones(readerPtr.get());
if (heavyReadMethod == HeavyweightReadMethod::Element) {
ReadEdgeNodesByElement(reader);
} else if (heavyReadMethod == HeavyweightReadMethod::Range) {
ReadEdgeNodesByZoneRange(reader);
} else {
ReadEdgeNodesByZone(reader);
}
// read face related information
DisplayInfoForFaceZones(readerPtr.get());
if (heavyReadMethod == HeavyweightReadMethod::Element) {
ReadFaceNodesByElement(reader);
ReadFaceCellParentsByElement(reader, 0);
ReadFaceCellParentsByElement(reader, 1);
} else if (heavyReadMethod == HeavyweightReadMethod::Range) {
ReadFaceNodesByZoneRange(reader);
ReadFaceCellParentsByZoneRange(reader, 0);
ReadFaceCellParentsByZoneRange(reader, 1);
} else {
ReadFaceNodesByZone(reader);
ReadFaceCellParentsByZone(reader, 0);
ReadFaceCellParentsByZone(reader, 1);
}
// read cell related information
DisplayInfoForCellZones(readerPtr.get());
if (heavyReadMethod == HeavyweightReadMethod::Element) {
ReadCellTypesByElement(reader);
ReadCellNodesByElement(reader);
ReadCellPartitionsByElement(reader);
ReadCellFacesByElement(reader);
} else if (heavyReadMethod == HeavyweightReadMethod::Range) {
ReadCellTypesByZoneRange(reader);
ReadCellNodesByZoneRange(reader);
ReadCellPartitionsByZoneRange(reader);
ReadCellFacesByZoneRange(reader);
} else {
ReadCellTypesByZone(reader);
ReadCellNodesByZone(reader);
ReadCellPartitionsByZone(reader);
ReadCellFacesByZone(reader);
}
}
// data-file
if (!datFileName.empty()) {
if (!readerPtr->startReading(datFileName, ansys::DataClass::CFF_RESULTS)) {
reportErrors(readerPtr.get(), "Error reading data file");
return 1;
}
reportWarnings(readerPtr.get());
if (heavyReadMethod == HeavyweightReadMethod::Element) {
ReadVariablesByElement(reader);
} else if (heavyReadMethod == HeavyweightReadMethod::Range) {
ReadVariablesByZoneRange(reader);
} else {
ReadVariablesByZone(reader);
}
}
std::cout << std::endl << "All done." << std::endl;
return 0;
}
std::vector< std::string > getErrors(bool formated=true, bool clear=false) const
returns, as strings, any unprocessed error messages registered
Definition: CffBaseMethods.cpp:1921
void setMeshId(const MeshIdType meshId)
Set the Identifier for active mesh being read or written.
Definition: CffBaseMethods.cpp:362
void setTarget(const TargetCategory target)
Set the target category for which the data is intended.
Definition: CffBaseMethods.cpp:400
std::vector< std::string > getWarnings(bool formated=true, bool clear=false) const
returns, as strings, any unprocessed warning messages registered
Definition: CffBaseMethods.cpp:1937
Class that provides functions to access data stored within a CFF database. The database may be stored...
Definition: CffProvider.hpp:21
CffTargetCategory
An enumeration that represents the target models available within a CFF database.
Definition: CffTypes.h:109
@ CFF_PARTITIONED_POST
Partitioned Post model.
Definition: CffTypes.h:165
@ CFF_POST
CFF Post model.
Definition: CffTypes.h:159
@ CFF_RESTART
CFF Restart model.
Definition: CffTypes.h:138
@ CFF_CASE
Definition: CffTypes.h:419
@ CFF_RESULTS
Definition: CffTypes.h:421
CffMeshIdType MeshIdType
Alias for CffMeshIdType ('C++' API only)
Definition: Types.hpp:26
CffPartitionIdType PartitionIdType
Alias for CffPartitionIdType ('C++' API only)
Definition: Types.hpp:31
ANSYS_FLUIDS_FACTORY_DLL CffFileProvider * getDataProvider(const std::string &sourceFile)
A function that provides that obtains an instance of an ansys::CffFileProvider that can be used to re...
Definition: providers.cpp:105
void ANSYS_FLUIDS_CFFINTERFACE_DLL printSDKVersion()
Writes the ANSYS CFF SDK version message to cout.
Definition: printVersion.cpp:69

We recommend using the option to read data by zone. The functions that do this are in the following file:

/*
* Copyright ANSYS. All Rights Reserved.
*/
void
ReadNodeCoordinatesByZone(ansys::CffProvider& reader)
{
ansys::ZoneIds zoneIds;
// get which node-zones have coordinate information
if (zoneIds.empty()) {
return;
}
PRINT_VECTOR_WITH_COMMA("Coordinates of node-zones", zoneIds);
std::cout << std::endl;
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
ansys::ElemIdType numElems = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems);
ansys::ElemIdType dimension = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_DIMENSION, dimension);
// allocate memory to store coordinates of all the nodes of this zone,
std::vector<double> coords(numElems * dimension);
reader.
getCoordinatesForNodesInZone(zoneIds[iz], coords.data(), coords.size());
std::cout << "Coordinates of zone-" << zoneIds[iz] << " is read into a "
<< numElems << " x " << dimension << " buffer." << std::endl;
}
std::cout << std::endl;
}
void
ReadEdgeNodesByZone(ansys::CffProvider& reader)
{
ansys::ZoneIds zoneIds;
reader.startReadingNodesForEdges(zoneIds);
if (zoneIds.empty()) {
return;
}
PRINT_VECTOR_WITH_COMMA("Edge-nodes of edge-zones", zoneIds);
std::cout << std::endl;
reader.startReadingNodeCountsForEdges();
std::vector<size_t> zaenc(zoneIds.size());
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
ansys::ElemIdType minId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_START_ID, minId);
ansys::ElemIdType maxId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_END_ID, maxId);
ansys::ElemIdType numElems = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems);
// allocate the memory to store all the node counts for each edge
std::vector<short> enc(numElems);
reader.getNodeCountsForEdgesInZone(zoneIds[iz], enc.data(), numElems);
std::cout << "Edge-node-counts of zone-" << zoneIds[iz]
<< " is read into a " << enc.size() << " x 1 buffer."
<< std::endl;
zaenc[iz] = std::accumulate(enc.begin(), enc.end(), 0);
}
std::cout << std::endl;
reader.endReadingNodeCountsForEdges();
reader.startReadingNodeIdsForEdges();
if (zoneIds.empty()) {
return;
}
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
if (0 == zaenc[iz]) {
continue;
}
// allocate the memory to store the nodes of all edges of this zone
std::vector<ansys::ElemIdType> enid(zaenc[iz]);
reader.getNodeIdsForEdgesInZone(zoneIds[iz], enid.data(), enid.size());
std::cout << "Edge-node-ids of zone-" << zoneIds[iz]
<< " is read into a " << enid.size() << " x 1 buffer."
<< std::endl;
}
std::cout << std::endl;
reader.endReadingNodeIdsForEdges();
reader.endReadingNodesForEdges();
}
void
ReadFaceNodesByZone(ansys::CffProvider& reader)
{
ansys::ZoneIds zoneIds;
reader.startReadingNodesForFaces(zoneIds);
if (zoneIds.empty()) {
return;
}
PRINT_VECTOR_WITH_COMMA("Face-nodes of face-zones", zoneIds);
std::cout << std::endl;
std::vector<size_t> zafnc(zoneIds.size());
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
ansys::ElemIdType numElems = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems);
short unc = 0;
if (reader.hasUniformNodeCountForFacesInZone(zoneIds[iz], &unc)) {
std::cout << "Faces in zone-" << zoneIds[iz]
<< " have a uniform face-node-count." << std::endl;
zafnc[iz] = numElems * unc;
} else {
// allocate memory to store node counts for all face in zone
std::vector<short> fnc(numElems);
reader.getNodeCountsForFacesInZone(zoneIds[iz], fnc.data(), numElems);
std::cout << "Face-node-counts of zone-" << zoneIds[iz]
<< " is read into a " << fnc.size() << " x 1 buffer."
<< std::endl;
zafnc[iz] = std::accumulate(fnc.begin(), fnc.end(), 0);
}
}
std::cout << std::endl;
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
if (0 == zafnc[iz]) {
continue;
}
// allocate the memory to store the nodes of all faces of this zone
std::vector<ansys::ElemIdType> fnid(zafnc[iz]);
reader.getNodeIdsForFacesInZone(zoneIds[iz], &fnid.at(0), fnid.size());
std::cout << "Face-node-ids of zone-" << zoneIds[iz]
<< " is read into a " << fnid.size() << " x 1 buffer."
<< std::endl;
}
std::cout << std::endl;
}
void
ReadFaceCellParentsByZone(ansys::CffProvider& reader, int side)
{
ansys::ZoneIds zoneIds;
if (side==0) {
reader.startReadingCell0sForFaces(zoneIds);
} else {
reader.startReadingCell1sForFaces(zoneIds);
}
if (zoneIds.empty()) {
return;
}
PRINT_VECTOR_WITH_COMMA("Cell-" + std::to_string(side) + " of face-zones",
zoneIds);
std::cout << std::endl;
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
ansys::ElemIdType numElems = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems);
// allocate the space required to read all parent cells for this face zone
std::vector<ansys::ElemIdType> fc(numElems);
if (side==0) {
reader.getCell0sForFacesInZone(zoneIds[iz], fc.data(), numElems);
} else {
reader.getCell1sForFacesInZone(zoneIds[iz], fc.data(), numElems);
}
std::cout << "Face-cell" << side << "-connectivity of zone-" << zoneIds[iz]
<< " is read into a " << fc.size() << " x 1 buffer."
<< std::endl;
}
std::cout << std::endl;
if (side==0) {
} else {
}
}
void
ReadCellTypesByZone(ansys::CffProvider& reader)
{
ansys::ZoneIds zoneIds;
// find which cell-zones have this information
reader.startReadingTypesForCells(zoneIds);
if (zoneIds.empty()) {
return;
}
PRINT_VECTOR_WITH_COMMA("Cell-types of cell-zones", zoneIds);
// a cell-zone can have uniform cell type (not poly);
// then, no need to read types of each cells in that zone one-by-one
std::vector<ansys::CellType> zct(zoneIds.size(), CFF_CELL_TYPE_MIXED);
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
// check if uniform cell-type; the type is returned in "cellType";
// if not-uniform, cellType shall have garbage value
if (reader.hasUniformTypeForCellsInZone(zoneIds[iz], &cellType)) {
zct[iz] = cellType;
}
}
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
std::cout << "Cell-type ids of zone-" << zoneIds[iz] << " is ";
if (CFF_CELL_TYPE_MIXED != zct[iz]) {
std::cout << "uniform (" << static_cast<short>(zct[iz]) << ")." << std::endl;
continue;
}
ansys::ElemIdType numElems = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems);
// allocate memory to store the cell types for all cells in zone
std::vector<ansys::CellType> ct(numElems);
std::cout << "read into a " << ct.size() << " x 1 buffer." << std::endl;
reader.getTypesForCellsInZone(zoneIds[iz], ct.data(), numElems);
}
std::cout << std::endl;
}
void
ReadCellNodesByZone(ansys::CffProvider& reader)
{
ansys::ZoneIds zoneIds;
reader.startReadingNodesForCells(zoneIds);
if (zoneIds.empty()) {
return;
}
PRINT_VECTOR_WITH_COMMA("Cell-nodes of cell-zones", zoneIds);
std::cout << std::endl;
std::vector<size_t> zacnc(zoneIds.size());
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
ansys::ElemIdType numElems = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems);
short unc = 0;
if (reader.hasUniformNodeCountForCellsInZone(zoneIds[iz], &unc)) {
std::cout << "Cells in zone-" << zoneIds[iz]
<< " have a uniform cell-node-count." << std::endl;
zacnc[iz] = numElems * unc;
} else {
// allocate memory, to store all node counts for cells in this zone
std::vector<short> cnc(numElems);
reader.getNodeCountsForCellsInZone(zoneIds[iz], cnc.data(), numElems);
std::cout << "Cell-node-counts of zone-" << zoneIds[iz]
<< " is read into a " << cnc.size() << " x 1 buffer."
<< std::endl;
zacnc[iz] = std::accumulate(cnc.begin(), cnc.end(), 0);
}
}
std::cout << std::endl;
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
if (0 == zacnc[iz]) {
continue;
}
// allocate the memory to store the nodes of all cells of this zone
std::vector<ansys::ElemIdType> cnid(zacnc[iz]);
reader.getNodeIdsForCellsInZone(zoneIds[iz], &cnid.at(0), cnid.size());
std::cout << "Cell-node-ids of zone-" << zoneIds[iz]
<< " is read into a " << cnid.size() << " x 1 buffer."
<< std::endl;
}
std::cout << std::endl;
}
void
ReadCellPartitionsByZone(ansys::CffProvider& reader)
{
ansys::ZoneIds zoneIds;
// find which cell-zones have this information
reader.startReadingPartitionIdsForCells(zoneIds);
if (zoneIds.empty()) {
return;
}
// store number of partitions of all zones;
// (this will be same for ANSYS Fluent across zones)
std::vector<int> znp(zoneIds.size(), 1);
// to store the cell-partition
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
znp[iz] = reader.getPartitionCountForZone(zoneIds[iz]);
}
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
std::cout << "Cell-partition ids of zone-" << zoneIds[iz] << " is ";
if (znp[iz] < 2) {
std::cout << "not read as partition-count is " << znp[iz] << "."
<< std::endl;
continue;
}
ansys::ElemIdType numElems = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems);
// Allocate memory to hold partitions for all cells in the zone
std::vector<ansys::PartitionIdType> cp(numElems);
reader.getPartitionIdsForCellsInZone(zoneIds[iz], cp.data(), numElems);
std::cout << " read into a " << cp.size() << " x 1 buffer."
<< std::endl;
}
std::cout << std::endl;
reader.endReadingPartitionIdsForCells();
}
void
ReadCellFacesByZone(ansys::CffProvider& reader)
{
ansys::ZoneIds zoneIds;
reader.startReadingFacesForCells(zoneIds);
if (zoneIds.empty()) {
return;
}
PRINT_VECTOR_WITH_COMMA("Cell-faces of cell-zones", zoneIds);
std::cout << std::endl;
reader.startReadingFaceCountsForCells();
std::vector<size_t> zacfc(zoneIds.size());
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
ansys::ElemIdType numElems = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems);
// allocate memory to store the face counts for each cell in the zone
std::vector<short> cfc(numElems);
reader.getFaceCountsForCellsInZone(zoneIds[iz], cfc.data(), numElems);
std::cout << "Cell-face-counts of zone-" << zoneIds[iz]
<< " is read into a " << cfc.size() << " x 1 buffer."
<< std::endl;
zacfc[iz] = std::accumulate(cfc.begin(), cfc.end(), 0);
}
std::cout << std::endl;
reader.endReadingFaceCountsForCells();
reader.startReadingFaceIdsForCells();
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
if (0 == zacfc[iz]) {
continue;
}
// allocate the memory to store the face ids for all cells in this zone
std::vector<ansys::ElemIdType> cfid(zacfc[iz]);
reader.getFaceIdsForCellsInZone(zoneIds[iz], cfid.data(), cfid.size());
std::cout << "Cell-face-ids of zone-" << zoneIds[iz]
<< " is read into a " << cfid.size() << " x 1 buffer."
<< std::endl;
}
std::cout << std::endl;
reader.endReadingFaceIdsForCells();
reader.endReadingFacesForCells();
}
void
ReadVariablesByZone(ansys::CffProvider& reader)
{
ansys::PhaseIds phaseIds;
// find out how many Eulerian phases are there in the data file
reader.getPhaseIds(phaseIds);
if (phaseIds.empty()) {
return;
}
PRINT_VECTOR_WITH_COMMA("Reading data of phases", phaseIds);
std::cout << std::endl;
// read the phases one-by-one
for (size_t ip = 0; ip < phaseIds.size(); ++ip) {
std::cout << "Reading data of phase-" << phaseIds[ip] << ":" << std::endl;
reader.startReadingPhase(phaseIds[ip]);
std::vector<ansys::ZoneCategory> zoneCategories =
// read the solution variable data one-by-one
for (const auto& zc : zoneCategories) {
// get what variables are there under this situation
std::vector<std::string> varName;
reader.getPhaseVariablesOfCategory(zc, varName);
if (varName.empty()) {
continue;
}
if (zc == CFF_FACE_ZONE) {
std::cout << " Face-Data" << std::endl;
} else if (zc == CFF_CELL_ZONE) {
std::cout << " Cell-Data" << std::endl;
} else if (zc == CFF_NODE_ZONE) {
std::cout << " Node-Data" << std::endl;
} else if (zc == CFF_EDGE_ZONE) {
std::cout << " Edge-Data" << std::endl;
}
reader.getPhaseVariablesOfCategory(zc, varIds);
// read all the vars one-by-one
for (size_t iv = 0; iv < varName.size(); ++iv) {
if (!reader.getAttributeValueOfPhaseVariable(varName[iv],
"Long Name",
longName)) {
longName = varName[iv];
}
std::cout << " " << longName << "(" << varIds[iv] << "):" << std::endl;
ansys::ZoneIds zoneIds;
// find out which zones have this variable and number of data per
// element
size_t numVarsPerElem =
reader.startReadingZonesOfCategoryWithPhaseVariable(zc,
varName[iv],
zoneIds);
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
ansys::ElemIdType numElems = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems);
// allocate memory
size_t dataCount = numElems * numVarsPerElem;
std::vector<double> dataBuf(dataCount);
reader.getValuesOfPhaseVariableForElementsInZone(zoneIds[iz],
dataBuf.data(),
dataBuf.size());
std::cout << " Data of zone-" << zoneIds[iz]
<< " is read into a " << numElems << " x "
<< numVarsPerElem << " buffer." << std::endl;
}
reader.endReadingZonesOfCategoryWithPhaseVariable();
}
}
reader.endReadingPhase();
}
}
void getZoneSizeInfo(const ZoneIdType zoneId, const ZoneSizeType sizeType, ElemIdType &size) const
Obtains a size setting of a zone.
Definition: CffBaseMethods.cpp:1008
void getPhaseIds(PhaseIds &phaseIds) const
Obtain the Identifiers of all Phase.
Definition: CffBaseMethods.cpp:1265
virtual bool hasUniformNodeCountForFacesInZone(const ZoneIdType zoneId, short *const ufnc) const
Query whether all faces in the face zone are defined using a uniform node count. i....
Definition: CffProviderMethods.cpp:1127
virtual void endReadingNodesForFaces() const
Finish reading the face node data.
Definition: CffProviderMethods.cpp:1392
virtual void startReadingNodeIdsForCells() const
Start reading the node identifiers for cells.
Definition: CffProviderMethods.cpp:2331
virtual void startReadingNodeCountsForCells() const
Start reading the cell node counts.
Definition: CffProviderMethods.cpp:2171
virtual void endReadingNodeCountsForFaces() const
Finish reading the face node counts.
Definition: CffProviderMethods.cpp:1241
virtual void startReadingCoordinatesForNodes(ZoneIds &zoneIds) const
Determine the node zones for which coordinates have been defined and prepare to read the coordinates ...
Definition: CffProviderMethods.cpp:675
virtual void startReadingNodesForFaces(ZoneIds &zoneIds) const
Determine the face zones for which nodes have been defined and prepare to read the nodes for those zo...
Definition: CffProviderMethods.cpp:1052
virtual void startReadingNodesForCells(ZoneIds &zoneIds) const
Determine the cell zones for which nodes have been defined and prepare to read the nodes for those zo...
Definition: CffProviderMethods.cpp:2152
virtual void startReadingNodeIdsForFaces() const
Start reading the face nodes.
Definition: CffProviderMethods.cpp:1260
virtual size_t getNodeCountsForFacesInZone(const ZoneIdType zoneId, short *const fnc, const size_t) const
Get the node counts for all faces within a face zone.
Definition: CffProviderMethods.cpp:1216
virtual void endReadingCoordinatesForNodes() const
Finish reading coordinates for nodes.
Definition: CffProviderMethods.cpp:839
virtual size_t getCell0sForFacesInZone(const ZoneIdType zoneId, ElemIdType *const cell0Id, const size_t) const
Obtain cell 0 parents for all faces in zone.
Definition: CffProviderMethods.cpp:1520
virtual void endReadingCell0sForFaces() const
Finish reading the cell 0 parents.
Definition: CffProviderMethods.cpp:1543
virtual void startReadingTypesForCells(ZoneIds &) const
Determine the cell zones for which cell types have been defined and prepare to read the cell types fo...
Definition: CffProviderMethods.cpp:1946
virtual size_t getNodeIdsForCellsInZone(const ZoneIdType zoneId, ElemIdType *const cnid, const size_t) const
Get the node identifiers for all cells within a cell zone.
Definition: CffProviderMethods.cpp:2419
virtual void endReadingTypesForCells() const
Finish reading the types of cells.
Definition: CffProviderMethods.cpp:2065
virtual void startReadingNodeCountsForFaces() const
Start reading the face node counts.
Definition: CffProviderMethods.cpp:1071
virtual bool getAttributeValueOfPhaseVariable(VariableIdType, const AttributeName &, AttributeValue &) const
Definition: CffProviderMethods.cpp:3164
virtual void endReadingNodeIdsForCells() const
Finish reading the node identifiers for cells.
Definition: CffProviderMethods.cpp:2444
virtual void startReadingPhase(const PhaseIdType=1) const
Definition: CffProviderMethods.cpp:2900
virtual size_t getTypesForCellsInZone(const ZoneIdType, CellType *const, const size_t) const
Obtain the types of all cells in a cell zone.
Definition: CffProviderMethods.cpp:2044
virtual void endReadingNodesForCells() const
Finish reading the cell node.
Definition: CffProviderMethods.cpp:2460
virtual void endReadingNodeCountsForCells() const
Finish reading the cell node counts.
Definition: CffProviderMethods.cpp:2312
virtual void endReadingCell1sForFaces() const
Finish reading the cell 1 parents.
Definition: CffProviderMethods.cpp:1649
virtual size_t getNodeCountsForCellsInZone(const ZoneIdType zoneId, short *const cnc, const size_t) const
Get the node counts for all cells within a cell zone.
Definition: CffProviderMethods.cpp:2286
virtual size_t getNodeIdsForFacesInZone(const ZoneIdType, ElemIdType *const, const size_t) const
Get the node identifiers for a all faces within a face zone.
Definition: CffProviderMethods.cpp:1348
virtual void startReadingCell0sForFaces(ZoneIds &zoneIds) const
Start reading the cell 0 parents.
Definition: CffProviderMethods.cpp:1453
virtual bool hasUniformTypeForCellsInZone(const ZoneIdType zoneId, CellType *const) const
Query whether all cells in the cell zone have the same cell type.
Definition: CffProviderMethods.cpp:1966
virtual bool hasUniformNodeCountForCellsInZone(const ZoneIdType zoneId, short *const ucnc) const
Query whether all cells in the cell zone are defined using a uniform node count.
Definition: CffProviderMethods.cpp:2197
virtual void startReadingCell1sForFaces(ZoneIds &zoneIds) const
Start reading the cell 1 parents.
Definition: CffProviderMethods.cpp:1559
virtual void endReadingNodeIdsForFaces() const
Finish reading the node identifiers for faces.
Definition: CffProviderMethods.cpp:1373
virtual size_t getCell1sForFacesInZone(const ZoneIdType zoneId, ElemIdType *const fc1, const size_t) const
Obtain cell 1 parents for all faces in zone.
Definition: CffProviderMethods.cpp:1626
CffCellType
An enumeration used to represet the type of a Cell element.
Definition: CffTypes.h:608
@ CFF_CELL_ZONE
Definition: CffTypes.h:205
@ CFF_NODE_ZONE
Definition: CffTypes.h:199
@ CFF_FACE_ZONE
Definition: CffTypes.h:203
@ CFF_EDGE_ZONE
Definition: CffTypes.h:201
@ CFF_ZONE_START_ID
Definition: CffTypes.h:227
@ CFF_ZONE_SIZE
Definition: CffTypes.h:231
@ CFF_ZONE_DIMENSION
Definition: CffTypes.h:233
@ CFF_ZONE_END_ID
Definition: CffTypes.h:229
@ CFF_CELL_TYPE_MIXED
Definition: CffTypes.h:612
std::string AttributeValue
Type used to represent the variable attribute value ('C++' API only)
Definition: Types.hpp:104
std::vector< ZoneIdType > ZoneIds
Type used to represent a number of zone identifiers('C++' API only)
Definition: Types.hpp:149
std::vector< PhaseIdType > PhaseIds
Type used to represent a number of phase identifiers ids('C++' API only)
Definition: Types.hpp:159
std::vector< VariableIdType > VariableIds
Type used to represent a number of variable identifiers ('C++' API only)
Definition: Types.hpp:189
CffElemIdType ElemIdType
Alias for CffElemIdType ('C++' API only)
Definition: Types.hpp:56

Additional files illustrate how to read data by range:

/*
* Copyright ANSYS. All Rights Reserved.
*/
void
ReadNodeCoordinatesByZoneRange(ansys::CffProvider& reader)
{
ansys::ZoneIds zoneIds;
// get which node-zones have coordinate information
if (zoneIds.empty()) {
return;
}
PRINT_VECTOR_WITH_COMMA("Coordinates of node-zones", zoneIds);
std::cout << std::endl;
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
ansys::ElemIdType minId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_START_ID, minId);
ansys::ElemIdType maxId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_END_ID, maxId);
ansys::ElemIdType numElems = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems);
ansys::ElemIdType dimension = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_DIMENSION, dimension);
std::vector<double> coords(numElems * dimension);
maxId,
coords.data(),
coords.size());
std::cout << "Coordinates of range: " << minId <<" - " << maxId
<< " is read into a "
<< numElems << " x " << dimension << " buffer." << std::endl;
}
}
void
ReadEdgeNodesByZoneRange(ansys::CffProvider& reader)
{
ansys::ZoneIds zoneIds;
reader.startReadingNodesForEdges(zoneIds);
if (zoneIds.empty()) {
return;
}
PRINT_VECTOR_WITH_COMMA("Edge-nodes of edge-zones", zoneIds);
std::cout << std::endl;
std::vector<size_t> zafnc(zoneIds.size());
reader.startReadingNodeCountsForEdges();
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
ansys::ElemIdType minId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_START_ID, minId);
ansys::ElemIdType maxId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_END_ID, maxId);
ansys::ElemIdType numElems = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems);
short unc = 0;
if (reader.hasUniformNodeCountForEdgesInRange(minId, maxId, &unc)) {
std::cout << "Edges in zone-" << zoneIds[iz]
<< " have a uniform edge-node-count." << std::endl;
zafnc[iz] = unc * numElems;
} else {
std::vector<short> fnc(numElems);
reader.getNodeCountsForEdgesInRange(minId, maxId, fnc.data(), fnc.size());
std::cout << "Edge-node-counts of range: " << minId <<" - " << maxId
<< " is read into a " << fnc.size() << " x 1 buffer."
<< std::endl;
zafnc[iz] = std::accumulate(fnc.begin(), fnc.end(), 0);
}
}
reader.endReadingNodeCountsForEdges();
std::cout << std::endl;
reader.startReadingNodeIdsForEdges();
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
ansys::ElemIdType minId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_START_ID, minId);
ansys::ElemIdType maxId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_END_ID, maxId);
ansys::ElemIdType numElems = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems);
std::vector<ansys::ElemIdType> fnid(zafnc[iz]);
reader.getNodeIdsForEdgesInRange(minId, maxId, fnid.data(), fnid.size());
std::cout << "Edge-node-ids of range: " << minId <<" - " << maxId
<< " is read into a " << fnid.size() << " x 1 buffer."
<< std::endl;
}
reader.endReadingNodeIdsForEdges();
reader.endReadingNodesForEdges();
std::cout << std::endl;
}
void
ReadFaceNodesByZoneRange(ansys::CffProvider& reader)
{
ansys::ZoneIds zoneIds;
reader.startReadingNodesForFaces(zoneIds);
if (zoneIds.empty()) {
return;
}
PRINT_VECTOR_WITH_COMMA("Face-nodes of face-zones", zoneIds);
std::cout << std::endl;
std::vector<size_t> zafnc(zoneIds.size());
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
ansys::ElemIdType minId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_START_ID, minId);
ansys::ElemIdType maxId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_END_ID, maxId);
ansys::ElemIdType numElems = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems);
short unc = 0;
if (reader.hasUniformNodeCountForFacesInRange(minId, maxId, &unc)) {
std::cout << "Faces in zone-" << zoneIds[iz]
<< " have a uniform face-node-count." << std::endl;
zafnc[iz] = unc * numElems;
} else {
std::vector<short> fnc(numElems);
reader.getNodeCountsForFacesInRange(minId, maxId, fnc.data(), fnc.size());
std::cout << "Face-node-counts of range: " << minId <<" - " << maxId
<< " is read into a " << fnc.size() << " x 1 buffer."
<< std::endl;
zafnc[iz] = std::accumulate(fnc.begin(), fnc.end(), 0);
}
}
std::cout << std::endl;
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
ansys::ElemIdType minId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_START_ID, minId);
ansys::ElemIdType maxId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_END_ID, maxId);
ansys::ElemIdType numElems = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems);
std::vector<ansys::ElemIdType> fnid(zafnc[iz]);
reader.getNodeIdsForFacesInRange(minId, maxId, fnid.data(), fnid.size());
std::cout << "Face-node-ids of range: " << minId <<" - " << maxId
<< " is read into a " << fnid.size() << " x 1 buffer."
<< std::endl;
}
std::cout << std::endl;
}
void
ReadFaceCellParentsByZoneRange(ansys::CffProvider& reader, int side)
{
ansys::ZoneIds zoneIds;
if (side == 0) {
reader.startReadingCell0sForFaces(zoneIds);
} else {
reader.startReadingCell1sForFaces(zoneIds);
}
if (zoneIds.empty()) {
return;
}
PRINT_VECTOR_WITH_COMMA("Cell-" + std::to_string(side) + " of face-zones",
zoneIds);
std::cout << std::endl;
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
ansys::ElemIdType minId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_START_ID, minId);
ansys::ElemIdType maxId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_END_ID, maxId);
ansys::ElemIdType numElems = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems);
std::vector<ansys::ElemIdType> fc(numElems);
if (side == 0) {
reader.getCell0sForFacesInRange(minId, maxId, fc.data(), fc.size());
} else {
reader.getCell1sForFacesInRange(minId, maxId, fc.data(), fc.size());
}
std::cout << "Face-cell" << side << "-connectivity of range: "
<< minId <<" - " << maxId << " is read into a "
<< numElems << " x 1" << " buffer." << std::endl;
}
std::cout << std::endl;
if (side == 0) {
} else {
}
}
void
ReadCellTypesByZoneRange(ansys::CffProvider& reader)
{
ansys::ZoneIds zoneIds;
// find which cell-zones have this information
reader.startReadingTypesForCells(zoneIds);
if (zoneIds.empty()) {
return;
}
PRINT_VECTOR_WITH_COMMA("Cell-types of cell-zones", zoneIds);
// a cell-zone can have uniform cell type (not poly);
// then, no need to read types of each cells in that zone one-by-one
std::vector<ansys::CellType> zct(zoneIds.size(), CFF_CELL_TYPE_MIXED);
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
// check if uniform cell-type; the type is returned in "cellType";
// if not-uniform, cellType shall have garbage value
if (reader.hasUniformTypeForCellsInZone(zoneIds[iz], &cellType)) {
zct[iz] = cellType;
}
}
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
std::cout << "Cell-type ids of zone-" << zoneIds[iz] << " is ";
if (CFF_CELL_TYPE_MIXED != zct[iz]) {
std::cout << "uniform (" << static_cast<short>(zct[iz]) << ")."
<< std::endl;
continue;
}
ansys::ElemIdType minId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_START_ID, minId);
ansys::ElemIdType maxId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_END_ID, maxId);
ansys::ElemIdType numElems = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems);
// Allocate memory to store all types for cells in this zone
std::vector<ansys::CellType> ct(numElems);
reader.getTypesForCellsInRange(minId, maxId, ct.data(), numElems);
std::cout << "read into a " << ct.size() << " x 1 buffer." << std::endl;
}
std::cout << std::endl;
}
void
ReadCellNodesByZoneRange(ansys::CffProvider& reader)
{
ansys::ZoneIds zoneIds;
reader.startReadingNodesForCells(zoneIds);
if (zoneIds.empty()) {
return;
}
PRINT_VECTOR_WITH_COMMA("Cell-nodes of face-zones", zoneIds);
std::cout << std::endl;
std::vector<size_t> zafnc(zoneIds.size());
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
ansys::ElemIdType minId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_START_ID, minId);
ansys::ElemIdType maxId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_END_ID, maxId);
ansys::ElemIdType numElems = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems);
std::vector<short> fnc(numElems);
reader.getNodeCountsForCellsInRange(minId, maxId, fnc.data(), fnc.size());
std::cout << "Cell-node-counts of range: " << minId <<" - " << maxId
<< " is read into a " << fnc.size() << " x 1 buffer."
<< std::endl;
zafnc[iz] = std::accumulate(fnc.begin(), fnc.end(), 0);
}
std::cout << std::endl;
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
ansys::ElemIdType minId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_START_ID, minId);
ansys::ElemIdType maxId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_END_ID, maxId);
ansys::ElemIdType numElems = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems);
std::vector<ansys::ElemIdType> fnid(zafnc[iz]);
reader.getNodeIdsForCellsInRange(minId, maxId, fnid.data(), fnid.size());
std::cout << "Cell-node-ids of range: " << minId <<" - " << maxId
<< " is read into a " << fnid.size() << " x 1 buffer."
<< std::endl;
}
std::cout << std::endl;
}
void
ReadCellPartitionsByZoneRange(ansys::CffProvider& reader)
{
ansys::ZoneIds zoneIds;
reader.startReadingPartitionIdsForCells(zoneIds);
if (zoneIds.empty()) {
return;
}
std::vector<int> znp(zoneIds.size(), 1);
// to store the cell-partition
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
znp[iz] = reader.getPartitionCountForZone(zoneIds[iz]);
}
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
std::cout << "Cell-partition ids of zone-" << zoneIds[iz] << " is ";
if (znp[iz] < 2) {
std::cout << "not read as partition-count is " << znp[iz] << "."
<< std::endl;
continue;
}
ansys::ElemIdType minId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_START_ID, minId);
ansys::ElemIdType maxId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_END_ID, maxId);
ansys::ElemIdType numElems = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems);
std::vector<ansys::PartitionIdType> cp(numElems * znp[iz]);
reader.getPartitionIdsForCellsInRange(minId, maxId, cp.data(), cp.size());
std::cout << "Cell partition of range: " << minId <<" - " << maxId
<< " is read into a "
<< numElems << " x " << znp[iz] << " buffer." << std::endl;
}
reader.endReadingPartitionIdsForCells();
std::cout << std::endl;
}
void
ReadCellFacesByZoneRange(ansys::CffProvider& reader)
{
ansys::ZoneIds zoneIds;
reader.startReadingFacesForCells(zoneIds);
if (zoneIds.empty()) {
return;
}
PRINT_VECTOR_WITH_COMMA("Cell-faces of cell-zones", zoneIds);
std::cout << std::endl;
// read number of nodes of each faces first for efficient memory
// allocation;
// can be skipped to read the face-nodes directly
reader.startReadingFaceCountsForCells();
std::vector<size_t> zacfc(zoneIds.size());
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
ansys::ElemIdType minId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_START_ID, minId);
ansys::ElemIdType maxId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_END_ID, maxId);
ansys::ElemIdType numElems = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems);
// allocate memory, or use previously allocated ones
std::vector<short> cfc(numElems);
reader.getFaceCountsForCellsInRange(minId, maxId, cfc.data(), cfc.size());
std::cout << "Cell-face-counts of zone-" << zoneIds[iz]
<< " is read into a " << cfc.size() << " x 1 buffer."
<< std::endl;
zacfc[iz] = std::accumulate(cfc.begin(), cfc.end(), 0);
}
std::cout << std::endl;
reader.endReadingFaceCountsForCells();
reader.startReadingFaceIdsForCells();
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
if (0 == zacfc[iz]) {
continue;
}
ansys::ElemIdType minId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_START_ID, minId);
ansys::ElemIdType maxId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_END_ID, maxId);
// allocate the memory to store the nodes of all faces of this zone
std::vector<ansys::ElemIdType> cfid(zacfc[iz]);
reader.getFaceIdsForCellsInRange(minId, maxId, cfid.data(), cfid.size());
std::cout << "Cell-face-ids of zone-" << zoneIds[iz]
<< " is read into a " << cfid.size() << " x 1 buffer."
<< std::endl;
}
reader.endReadingFaceIdsForCells();
reader.endReadingFacesForCells();
std::cout << std::endl;
}
void
ReadVariablesByZoneRange(ansys::CffProvider& reader)
{
ansys::PhaseIds phaseIds;
// find out how many Eulerian phases are there in the data file
reader.getPhaseIds(phaseIds);
if (phaseIds.empty()) {
return;
}
PRINT_VECTOR_WITH_COMMA("Reading data of phases", phaseIds);
std::cout << std::endl;
// read the phases one-by-one
for (size_t ip = 0; ip < phaseIds.size(); ++ip) {
std::cout << "Reading data of phase-" << phaseIds[ip] << ":" << std::endl;
reader.startReadingPhase(phaseIds[ip]);
std::vector<ansys::ZoneCategory> zoneCategories =
// read the solution variable data one-by-one
for (const auto& zc : zoneCategories) {
// get what variables are there under this situation
std::vector<std::string> varName;
reader.getPhaseVariablesOfCategory(zc, varName);
if (varName.empty()) {
continue;
}
if (zc == CFF_FACE_ZONE) {
std::cout << " Face-Data" << std::endl;
} else if (zc == CFF_CELL_ZONE) {
std::cout << " Cell-Data" << std::endl;
} else if (zc == CFF_NODE_ZONE) {
std::cout << " Node-Data" << std::endl;
} else if (zc == CFF_EDGE_ZONE) {
std::cout << " Edge-Data" << std::endl;
}
reader.getPhaseVariablesOfCategory(zc, varIds);
// read all the vars one-by-one
for (size_t iv = 0; iv < varName.size(); ++iv) {
if (!reader.getAttributeValueOfPhaseVariable(varName[iv],
"Long Name",
longName)) {
longName = varName[iv];
}
std::cout << " " << longName << "(" << varIds[iv] << "):" << std::endl;
ansys::ZoneIds zoneIds;
// find out which zones have this variable and number of data per
// element
size_t numVarsPerElem =
reader.startReadingZonesOfCategoryWithPhaseVariable(zc,
varName[iv],
zoneIds);
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
ansys::ElemIdType minId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_START_ID, minId);
ansys::ElemIdType maxId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_END_ID, maxId);
ansys::ElemIdType numElems = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems);
// allocate memory
std::vector<double> dataBuf(numElems * numVarsPerElem);
reader.getValuesOfPhaseVariableForElementsInRange(minId,
maxId,
dataBuf.data(),
dataBuf.size());
std::cout << " Data of zone-" << zoneIds[iz]
<< " is read into a " << numElems << " x "
<< numVarsPerElem << " buffer." << std::endl;
}
reader.endReadingZonesOfCategoryWithPhaseVariable();
}
}
reader.endReadingPhase();
}
}
virtual size_t getCoordinatesForNodesInRange(const ElemIdType minid, const ElemIdType maxId, float *const coords, const size_t) const
Obtain the coordinates for a node range.
Definition: CffProviderMethods.cpp:798
virtual size_t getCell0sForFacesInRange(const ElemIdType minId, const ElemIdType maxId, ElemIdType *const cell0Id, const size_t) const
Obtain cell 0 parents for all faces within a face range.
Definition: CffProviderMethods.cpp:1497
virtual size_t getNodeCountsForCellsInRange(const ElemIdType minId, const ElemIdType maxId, short *const cnc, const size_t) const
Get the node counts for a range of cells.
Definition: CffProviderMethods.cpp:2255
virtual size_t getCell1sForFacesInRange(const ElemIdType minId, const ElemIdType maxId, ElemIdType *const cell1, const size_t) const
Obtain cell 1 parents for all faces within a range.
Definition: CffProviderMethods.cpp:1603
virtual size_t getTypesForCellsInRange(const ElemIdType, const ElemIdType, CellType *const, const size_t) const
Obtain the types of all cells in a range.
Definition: CffProviderMethods.cpp:2017
virtual size_t getNodeIdsForCellsInRange(const ElemIdType minId, const ElemIdType maxId, ElemIdType *const cnid, const size_t) const
Get the node identifiers for a range of cells.
Definition: CffProviderMethods.cpp:2388
virtual size_t getNodeCountsForFacesInRange(const ElemIdType, const ElemIdType, short *const, const size_t) const
Get the node counts for a range of faces.
Definition: CffProviderMethods.cpp:1185
virtual size_t getNodeIdsForFacesInRange(const ElemIdType, const ElemIdType, ElemIdType *const, const size_t) const
Get the node identifiers for a range of faces.
Definition: CffProviderMethods.cpp:1317
virtual bool hasUniformNodeCountForFacesInRange(const ElemIdType minId, const ElemIdType maxId, short *const ufnc) const
Query whether all faces in the face range are defined using a uniform node count. i....
Definition: CffProviderMethods.cpp:1098

Read data by element:

/*
* Copyright ANSYS. All Rights Reserved.
*/
void
ReadNodeCoordinatesByElement(ansys::CffProvider& reader)
{
ansys::ZoneIds zoneIds;
// get which node-zones have coordinate information
if (zoneIds.empty()) {
return;
}
PRINT_VECTOR_WITH_COMMA("Coordinates of node-zones", zoneIds);
std::cout << std::endl;
// to store coordinates of one node
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
ansys::ElemIdType minId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_START_ID, minId);
ansys::ElemIdType maxId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_END_ID, maxId);
ansys::ElemIdType numElems = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems);
ansys::ElemIdType dimension = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_DIMENSION, dimension);
// Allocate memory to store coordinates of all the nodes of this zone
std::vector<double> coords(numElems * dimension);
std::vector<double> coord(dimension);
size_t count = 0;
for (ansys::ElemIdType elemId = minId; elemId <= maxId; ++elemId) {
const size_t numRead =
reader.getCoordinatesForNode(elemId, &coord.at(0), coord.size());
assert(numRead == coord.size());
std::copy(coord.begin(), coord.end(), coords.begin() + count);
count += coord.size();
}
std::cout << "Coordinates of zone-" << zoneIds[iz] << " is read into a "
<< numElems << " x " << dimension << " buffer." << std::endl;
}
std::cout << std::endl;
}
void
ReadEdgeNodesByElement(ansys::CffProvider& reader)
{
ansys::ZoneIds zoneIds;
reader.startReadingNodesForEdges(zoneIds);
if (zoneIds.empty()) {
return;
}
PRINT_VECTOR_WITH_COMMA("Edge-nodes of edge-zones", zoneIds);
std::cout << std::endl;
reader.startReadingNodeCountsForEdges();
std::vector<size_t> zaenc(zoneIds.size());
std::vector<ansys::ElemIdType> minId(zoneIds.size());
std::vector<ansys::ElemIdType> maxId(zoneIds.size());
std::vector<ansys::ElemIdType> numElems(zoneIds.size());
std::vector<std::vector<short>> enc(zoneIds.size());
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_START_ID, minId[iz]);
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_END_ID, maxId[iz]);
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems[iz]);
short unc = 0;
if (reader.hasUniformNodeCountForEdgesInZone(zoneIds[iz], &unc)) {
enc[iz].resize(1, unc);
std::cout << "Edges in zone-" << zoneIds[iz]
<< " have a uniform edge-node-count." << std::endl;
} else {
enc[iz].resize(numElems[iz]);
size_t count = 0;
for (ansys::ElemIdType elemId = minId[iz]; elemId <= maxId[iz]; ++elemId) {
enc[iz][count++] = reader.getNodeCountForEdge(elemId);
}
std::cout << "Edge-node-counts of zone-" << zoneIds[iz]
<< " is read into a " << enc[iz].size() << " x 1 buffer."
<< std::endl;
}
}
std::cout << std::endl;
reader.endReadingNodeCountsForEdges();
reader.startReadingNodeIdsForEdges();
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
const auto& zenc = enc[iz];
bool uniform = zenc.size() == 1;
size_t zaenc = 0;
if (uniform) {
// Uniform
zaenc = zenc[0] * numElems[iz];
} else {
zaenc = std::accumulate(zenc.begin(), zenc.end(), 0);
}
if (zaenc == 0) {
continue;
}
// Allocate the memory to store the nodes of all edges of this zone
std::vector<ansys::ElemIdType> enid(zaenc);
size_t eIdx = 0;
ansys::ElemIdType* nodeIds = enid.data();
ansys::ElemIdType elemId = minId[iz];
if (uniform) {
for (; elemId <= maxId[iz]; ++elemId) {
if (reader.getNodeIdsForEdge(elemId,
nodeIds,
zenc[eIdx]) != (size_t)zenc[eIdx]) {
break;
}
nodeIds += zenc[eIdx];
}
} else {
for (; elemId <= maxId[iz]; ++elemId) {
if (reader.getNodeIdsForEdge(elemId,
nodeIds,
zenc[eIdx]) != (size_t)zenc[eIdx]) {
break;
}
nodeIds += zenc[eIdx++];
}
}
if (elemId <= maxId[iz]) {
std::cout << "Failed to read edge-node-ids for edge "
<< elemId << " in zone-" << zoneIds[iz]
<< std::endl;
} else {
std::cout << "Edge-node-ids of zone-" << zoneIds[iz]
<< " is read into a " << enid.size() << " x 1 buffer."
<< std::endl;
}
}
std::cout << std::endl;
reader.endReadingNodeIdsForEdges();
reader.endReadingNodesForEdges();
}
void
ReadFaceNodesByElement(ansys::CffProvider& reader)
{
ansys::ZoneIds zoneIds;
reader.startReadingNodesForFaces(zoneIds);
if (zoneIds.empty()) {
return;
}
PRINT_VECTOR_WITH_COMMA("Face-nodes of face-zones", zoneIds);
std::cout << std::endl;
// read number of nodes of each faces first for efficient memory
// allocation;
// can be skipped to read the face-nodes directly
std::vector<size_t> zafnc(zoneIds.size());
std::vector<ansys::ElemIdType> minId(zoneIds.size());
std::vector<ansys::ElemIdType> maxId(zoneIds.size());
std::vector<ansys::ElemIdType> numElems(zoneIds.size());
std::vector<std::vector<short>> fnc(zoneIds.size());
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_START_ID, minId[iz]);
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_END_ID, maxId[iz]);
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems[iz]);
short unc = 0;
if (reader.hasUniformNodeCountForFacesInZone(zoneIds[iz], &unc)) {
fnc[iz].resize(1, unc);
std::cout << "Faces in zone-" << zoneIds[iz]
<< " have a uniform face-node-count." << std::endl;
} else {
fnc[iz].resize(numElems[iz]);
size_t count = 0;
for (ansys::ElemIdType elemId = minId[iz]; elemId <= maxId[iz]; ++elemId) {
fnc[iz][count++] = reader.getNodeCountForFace(elemId);
}
std::cout << "Face-node-counts of zone-" << zoneIds[iz]
<< " is read into a " << fnc[iz].size() << " x 1 buffer."
<< std::endl;
}
}
std::cout << std::endl;
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
const auto& zfnc = fnc[iz];
bool uniform = zfnc.size() == 1;
size_t zafnc = 0;
if (uniform) {
// Uniform
zafnc = zfnc[0] * numElems[iz];
} else {
zafnc = std::accumulate(zfnc.begin(), zfnc.end(), 0);
}
if (zafnc == 0) {
continue;
}
// Allocate the memory to store the nodes of all faces in this zone
std::vector<ansys::ElemIdType> fnid(zafnc);
size_t eIdx = 0;
ansys::ElemIdType* nodeIds = fnid.data();
ansys::ElemIdType elemId = minId[iz];
if (uniform) {
for (; elemId <= maxId[iz]; ++elemId) {
if (reader.getNodeIdsForFace(elemId,
nodeIds,
zfnc[eIdx]) != (size_t)zfnc[eIdx]) {
break;
}
nodeIds += zfnc[eIdx];
}
} else {
for (; elemId <= maxId[iz]; ++elemId) {
if (reader.getNodeIdsForFace(elemId,
nodeIds,
zfnc[eIdx]) != (size_t)zfnc[eIdx]) {
break;
}
nodeIds += zfnc[eIdx++];
}
}
if (elemId <= maxId[iz]) {
std::cout << "Failed to read face-node-ids for face "
<< elemId << " in zone-" << zoneIds[iz]
<< std::endl;
} else {
std::cout << "Face-node-ids of zone-" << zoneIds[iz]
<< " is read into a " << fnid.size() << " x 1 buffer."
<< std::endl;
}
}
std::cout << std::endl;
}
void
ReadFaceCellParentsByElement(ansys::CffProvider& reader, int side)
{
ansys::ZoneIds zoneIds;
// get which face-zones have cell-0 information
if (side == 0) {
reader.startReadingCell0sForFaces(zoneIds);
} else {
reader.startReadingCell1sForFaces(zoneIds);
}
if (zoneIds.empty()) {
return;
}
PRINT_VECTOR_WITH_COMMA("Cell-" + std::to_string(side) + " of face-zones",
zoneIds);
std::cout << std::endl;
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
ansys::ElemIdType minId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_START_ID, minId);
ansys::ElemIdType maxId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_END_ID, maxId);
ansys::ElemIdType numElems = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems);
std::vector<ansys::ElemIdType> fc(numElems);
if (side == 0) {
size_t count = 0;
for (ansys::ElemIdType elemId = minId; elemId <= maxId; ++elemId) {
fc[count++] = reader.getCell0ForFace(elemId);
}
} else {
size_t count = 0;
for (ansys::ElemIdType elemId = minId; elemId <= maxId; ++elemId) {
fc[count++] = reader.getCell1ForFace(elemId);
}
}
std::cout << "Face-cell" << side << "-connectivity of zone-" << zoneIds[iz]
<< " is read into a " << fc.size() << " x 1 buffer."
<< std::endl;
}
std::cout << std::endl;
if (side == 0) {
} else {
}
}
void
ReadCellTypesByElement(ansys::CffProvider& reader)
{
ansys::ZoneIds zoneIds;
// find which cell-zones have this information
reader.startReadingTypesForCells(zoneIds);
if (zoneIds.empty()) {
return;
}
PRINT_VECTOR_WITH_COMMA("Cell-types of cell-zones", zoneIds);
// a cell-zone can have uniform cell type (not poly);
// then, no need to read types of each cells in that zone one-by-one
std::vector<ansys::CellType> zct(zoneIds.size(), CFF_CELL_TYPE_MIXED);
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
// check if uniform cell-type; the type is returned in "cellType";
// if not-uniform, cellType shall have garbage value
if (reader.hasUniformTypeForCellsInZone(zoneIds[iz], &cellType)) {
zct[iz] = cellType;
}
}
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
std::cout << "Cell-type ids of zone-" << zoneIds[iz] << " is ";
if (CFF_CELL_TYPE_MIXED != zct[iz]) {
std::cout << "uniform (" << static_cast<short>(zct[iz]) << ")." << std::endl;
continue;
}
ansys::ElemIdType minId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_START_ID, minId);
ansys::ElemIdType maxId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_END_ID, maxId);
ansys::ElemIdType numElems = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems);
// Allocate memory to store the cell type for each cell in this zone
std::vector<ansys::CellType> ct(numElems);
size_t count = 0;
for (ansys::ElemIdType elemId = minId; elemId <= maxId; ++elemId, ++count) {
ct[count] = reader.getTypeForCell(elemId);
}
std::cout << "read into a " << ct.size() << " x 1 buffer." << std::endl;
}
std::cout << std::endl;
}
void
ReadCellNodesByElement(ansys::CffProvider& reader)
{
ansys::ZoneIds zoneIds;
reader.startReadingNodesForCells(zoneIds);
if (zoneIds.empty()) {
return;
}
PRINT_VECTOR_WITH_COMMA("Cell-nodes of cell-zones", zoneIds);
std::cout << std::endl;
std::vector<size_t> zacnc(zoneIds.size());
std::vector<ansys::ElemIdType> minId(zoneIds.size());
std::vector<ansys::ElemIdType> maxId(zoneIds.size());
std::vector<ansys::ElemIdType> numElems(zoneIds.size());
std::vector<std::vector<short>> cnc(zoneIds.size());
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_START_ID, minId[iz]);
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_END_ID, maxId[iz]);
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems[iz]);
short unc = 0;
if (reader.hasUniformNodeCountForCellsInZone(zoneIds[iz], &unc)) {
cnc[iz].resize(1, unc);
std::cout << "Cells in zone-" << zoneIds[iz]
<< " have a uniform cell-node-count." << std::endl;
} else {
cnc[iz].resize(numElems[iz]);
size_t count = 0;
for (ansys::ElemIdType elemId = minId[iz]; elemId <= maxId[iz]; ++elemId) {
cnc[iz][count++] = reader.getNodeCountForCell(elemId);
}
std::cout << "Cell-node-counts of zone-" << zoneIds[iz]
<< " is read into a " << cnc[iz].size() << " x 1 buffer."
<< std::endl;
}
}
std::cout << std::endl;
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
const auto& zcnc = cnc[iz];
bool uniform = zcnc.size() == 1;
size_t zacnc = 0;
if (uniform) {
// Uniform
zacnc = zcnc[0] * numElems[iz];
} else {
zacnc = std::accumulate(zcnc.begin(), zcnc.end(), 0);
}
if (zacnc == 0) {
continue;
}
// Allocate the memory to store the nodes of all cells in this zone
std::vector<ansys::ElemIdType> cnid(zacnc);
size_t eIdx = 0;
ansys::ElemIdType* nodeIds = cnid.data();
ansys::ElemIdType elemId = minId[iz];
if (uniform) {
for (; elemId <= maxId[iz]; ++elemId) {
if (reader.getNodeIdsForCell(elemId,
nodeIds,
zcnc[eIdx]) != (size_t)zcnc[eIdx]) {
break;
}
nodeIds += zcnc[eIdx];
}
} else {
for (; elemId <= maxId[iz]; ++elemId) {
if (reader.getNodeIdsForCell(elemId,
nodeIds,
zcnc[eIdx]) != (size_t)zcnc[eIdx]) {
break;
}
nodeIds += zcnc[eIdx++];
}
}
if (elemId <= maxId[iz]) {
std::cout << "Failed to read cell-node-ids for cell "
<< elemId << " in zone-" << zoneIds[iz]
<< std::endl;
} else {
std::cout << "Cell-node-ids of zone-" << zoneIds[iz]
<< " is read into a " << cnid.size() << " x 1 buffer."
<< std::endl;
}
}
std::cout << std::endl;
}
void
ReadCellPartitionsByElement(ansys::CffProvider& reader)
{
ansys::ZoneIds zoneIds;
// find which cell-zones have this information
reader.startReadingPartitionIdsForCells(zoneIds);
// store number of partitions of all zones;
// (this will be same for ANSYS Fluent across zones)
std::vector<int> znp(zoneIds.size(), 1);
// to store the cell-partition
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
znp[iz] = reader.getPartitionCountForZone(zoneIds[iz]);
}
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
std::cout << "Cell-partition ids of zone-" << zoneIds[iz] << " is ";
if (znp[iz] < 2) {
std::cout << "not read as partition-count is " << znp[iz] << "."
<< std::endl;
continue;
}
ansys::ElemIdType minId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_START_ID, minId);
ansys::ElemIdType maxId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_END_ID, maxId);
ansys::ElemIdType numElems = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems);
// Allocate memory to store the partition for each cell in this zone
std::vector<ansys::PartitionIdType> cp(numElems);
size_t count = 0;
for (ansys::ElemIdType elemId = minId; elemId <= maxId; ++elemId, ++count) {
cp[count] = reader.getPartitionIdForCell(elemId);
}
std::cout << " read into a " << cp.size() << " x 1 buffer."
<< std::endl;
}
std::cout << std::endl;
reader.endReadingPartitionIdsForCells();
}
void
ReadCellFacesByElement(ansys::CffProvider& reader)
{
ansys::ZoneIds zoneIds;
reader.startReadingFacesForCells(zoneIds);
if (zoneIds.empty()) {
return;
}
PRINT_VECTOR_WITH_COMMA("Cell-faces of cell-zones", zoneIds);
std::cout << std::endl;
reader.startReadingFaceCountsForCells();
// Allocate space for storing total face counts for zone
std::vector<std::vector<short>> zcfc(zoneIds.size());
std::vector<size_t> zacfc(zoneIds.size());
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
ansys::ElemIdType minId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_START_ID, minId);
ansys::ElemIdType maxId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_END_ID, maxId);
ansys::ElemIdType numElems = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems);
// Allocate memory required to store all face counts for cells in this zone
auto& cfc = zcfc[iz];
cfc.resize(numElems);
size_t count = 0;
for (ansys::ElemIdType elemId = minId; elemId <= maxId; ++elemId, ++count) {
cfc[count] = reader.getFaceCountForCell(elemId);
}
std::cout << "Cell-face-counts of zone-" << zoneIds[iz]
<< " is read into a " << cfc.size() << " x 1 buffer."
<< std::endl;
zacfc[iz] = std::accumulate(cfc.begin(), cfc.end(), 0);
}
std::cout << std::endl;
reader.endReadingFaceCountsForCells();
reader.startReadingFaceIdsForCells();
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
if (0 == zacfc[iz]) {
continue;
}
ansys::ElemIdType minId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_START_ID, minId);
ansys::ElemIdType maxId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_END_ID, maxId);
// Allocate memory to store the faces for all cells in this zone
std::vector<ansys::ElemIdType> zcfid(zacfc[iz]);
auto cfid = zcfid.data();
// Use previously read face counts while reading faces for cells in zone
const auto& cfc = zcfc[iz];
size_t count = 0;
for (ansys::ElemIdType elemId = minId; elemId <= maxId; ++elemId, ++count) {
reader.getFaceIdsForCell(elemId, cfid, cfc[count]);
cfid += cfc[count];
}
std::cout << "Cell-face-ids of zone-" << zoneIds[iz]
<< " is read into a " << zcfid.size() << " x 1 buffer."
<< std::endl;
}
std::cout << std::endl;
reader.endReadingFaceIdsForCells();
reader.endReadingFacesForCells();
}
void
ReadVariablesByElement(ansys::CffProvider& reader)
{
ansys::PhaseIds phaseIds;
// find out how many Eulerian phases are there in the data file
reader.getPhaseIds(phaseIds);
if (phaseIds.empty()) {
return;
}
PRINT_VECTOR_WITH_COMMA("Reading data of phases", phaseIds);
std::cout << std::endl;
// read the phases one-by-one
for (size_t ip = 0; ip < phaseIds.size(); ++ip) {
std::cout << "Reading data of phase-" << phaseIds[ip] << ":" << std::endl;
reader.startReadingPhase(phaseIds[ip]);
std::vector<ansys::ZoneCategory> zoneCategories =
// read the solution variable data one-by-one
for (const auto& zc : zoneCategories) {
// get what variables are there under this situation
std::vector<std::string> varName;
reader.getPhaseVariablesOfCategory(zc, varName);
if (varName.empty()) {
continue;
}
if (zc == CFF_FACE_ZONE) {
std::cout << " Face-Data" << std::endl;
} else if (zc == CFF_CELL_ZONE) {
std::cout << " Cell-Data" << std::endl;
} else if (zc == CFF_NODE_ZONE) {
std::cout << " Node-Data" << std::endl;
} else if (zc == CFF_EDGE_ZONE) {
std::cout << " Edge-Data" << std::endl;
}
reader.getPhaseVariablesOfCategory(zc, varIds);
// read all the vars one-by-one
for (size_t iv = 0; iv < varName.size(); ++iv) {
if (!reader.getAttributeValueOfPhaseVariable(varName[iv],
"Long Name",
longName)) {
longName = varName[iv];
}
std::cout << " " << longName << "(" << varIds[iv] << "):" << std::endl;
ansys::ZoneIds zoneIds;
// find out which zones have this variable and number of data per
// element
size_t numVarsPerElem =
reader.startReadingZonesOfCategoryWithPhaseVariable(zc,
varName[iv],
zoneIds);
for (size_t iz = 0; iz < zoneIds.size(); ++iz) {
ansys::ElemIdType minId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_START_ID, minId);
ansys::ElemIdType maxId = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_END_ID, maxId);
ansys::ElemIdType numElems = 0;
reader.getZoneSizeInfo(zoneIds[iz], CFF_ZONE_SIZE, numElems);
// allocate memory
std::vector<double> dataBuf(numElems * numVarsPerElem);
std::vector<double> elemData(numVarsPerElem);
size_t count = 0;
for (ansys::ElemIdType elemId = minId; elemId <= maxId; ++elemId) {
const size_t numRead =
reader.getValuesOfPhaseVariableForElement(elemId,
elemData.data(),
elemData.size());
assert(numRead == elemData.size());
std::copy(elemData.begin(),
elemData.begin() + numRead,
dataBuf.begin() + count);
count += numRead;
}
std::cout << " Data of zone-" << zoneIds[iz]
<< " is read into a " << numElems << " x "
<< numVarsPerElem << " buffer." << std::endl;
}
reader.endReadingZonesOfCategoryWithPhaseVariable();
}
}
reader.endReadingPhase();
}
}
virtual ElemIdType getCell0ForFace(const ElemIdType faceId) const
Obtain cell 0 parent for specified face.
Definition: CffProviderMethods.cpp:1470
virtual CellType getTypeForCell(const ElemIdType cellId) const
Query the type for a cell.
Definition: CffProviderMethods.cpp:1988
virtual size_t getNodeIdsForCell(const ElemIdType cellId, ElemIdType *const cnid, const size_t) const
Get the node identifiers for a specific cell.
Definition: CffProviderMethods.cpp:2357
virtual short getNodeCountForCell(const ElemIdType cellId) const
Get the node count for a sepcific cell.
Definition: CffProviderMethods.cpp:2222
virtual size_t getNodeIdsForFace(const ElemIdType faceId, ElemIdType *const fnid, const size_t) const
Get the node identifiers for a specific face.
Definition: CffProviderMethods.cpp:1286
virtual ElemIdType getCell1ForFace(const ElemIdType faceId) const
Obtain cell 1 parent for specified face.
Definition: CffProviderMethods.cpp:1576
virtual size_t getCoordinatesForNode(const ElemIdType nodeId, float *const coord, const size_t) const
Obtain the coordinates for a specific node.
Definition: CffProviderMethods.cpp:774
virtual short getNodeCountForFace(const ElemIdType faceId) const
Get the node count for a sepcific face.
Definition: CffProviderMethods.cpp:1152

Writing Case and Data Files using C++ API

The following example demonstrates how to use the CFF API to write case and results files.

/*
* Copyright ANSYS. All Rights Reserved.
*/
#include "CffInterface/printVersion.hpp"
#include "Factory/consumers.hpp"
#include "../Common/CasAndDatCreator.hpp"
#include <iostream>
#include <memory>
#include <vector>
int
main(int argc, char* argv[])
{
std::unique_ptr<ansys::CffFileConsumer> writerPtr(
ansys::getDataConsumer(CFF_HDF));
ansys::CffConsumer& writer = *writerPtr;
writer.setMeshId(1);
writer.setDebugOn(true);
writer.setCompression(1);
writer.setSolverType("ANSYS_FLUENT");
bool ok =
writerPtr->startWriting("write_new.cas.h5", ansys::DataClass::CFF_CASE);
if(!ok) {
std::cout << "Error writing to case file" << std::endl;
return 1;
}
ok =
writerPtr->startWriting("write_new.dat.h5", ansys::DataClass::CFF_RESULTS);
if(!ok) {
std::cout << "Error writing to data file" << std::endl;
return 1;
}
// top-level mesh information
size_t meshDimension, nodeCount, faceCount, cellCount;
// create those information
CreateMeshInfo(meshDimension, nodeCount, faceCount, cellCount);
// set these information in the writer
writer.setMeshSize(CFF_MESH_DIMENSION, meshDimension);
writer.setMeshSize(CFF_MESH_NODE_COUNT, nodeCount);
writer.setMeshSize(CFF_MESH_FACE_COUNT, faceCount);
writer.setMeshSize(CFF_MESH_CELL_COUNT, cellCount);
std::string units;
CreateMeshUnits(units);
writer.setMeshUnits(units);
// write those information
// nodes
{
ansys::ZoneIds nodeZone;
std::vector<ansys::ElemIdType> startId;
std::vector<ansys::ElemIdType> endId;
std::vector<short> dimension;
std::vector<std::string> names;
// create zone-level information of nodes
CreateNodeZones(nodeZone, startId, endId, dimension, names);
// set the node-zones
writer.setZoneIds(CFF_NODE_ZONE, nodeZone);
for (size_t iz = 0; iz < nodeZone.size(); ++iz) {
nodeZone[iz], CFF_ZONE_START_ID, startId[iz]);
nodeZone[iz], CFF_ZONE_END_ID, endId[iz]);
nodeZone[iz], CFF_ZONE_DIMENSION, dimension[iz]);
nodeZone[iz], CFF_ZONE_STRING_NAME, names[iz]);
}
// start writing about these node-zones
writer.startWritingNodes(nodeZone);
//Example showing usage of error status check, ideally such call should be called after every API call
if (writer.hasError())
{
for (auto err : writer.getErrors())
std::cout << err << std::endl;
}
//User can opt to check info and warning messages, these are more for future extension if needed.
if (writer.hasWarning())
{
for (auto war : writer.getWarnings())
std::cout << war << std::endl;
}
if (writer.hasInfo())
{
for (auto inf : writer.getInfos())
std::cout << inf << std::endl;
}
// node coordinates
{
ansys::ZoneIds nodeCoordsZone;
std::vector<std::vector<double> > coords;
// create node coordinates of appropriate zones
CreateNodeCoords(nodeCoordsZone, coords);
// start writing coordinates of these node-zones
writer.startWritingCoordinatesForNodes(nodeCoordsZone);
// write the coordinates
for (size_t iz = 0; iz < nodeCoordsZone.size(); ++iz) {
nodeCoordsZone[iz], &(coords[iz].at(0)), coords[iz].size());
}
// end writing the coordinates
}
// end writing about the node-zones
writer.endWritingNodes();
}
// faces
{
ansys::ZoneIds faceZone;
std::vector<ansys::ElemIdType> startId;
std::vector<ansys::ElemIdType> endId;
std::vector<short> dimension;
std::vector<ansys::ZoneIdType> shadowZoneId;
std::vector<ansys::ZoneIdType> childZoneId;
std::vector<ansys::FaceZoneType> zoneType;
std::vector<ansys::FaceType> elementType;
std::vector<short> flags;
std::vector<std::string> name;
std::vector<std::string> stringZoneType;
// create zone-level information of faces
CreateFaceZones(faceZone,
startId,
endId,
dimension,
shadowZoneId,
childZoneId,
zoneType,
elementType,
flags,
name,
stringZoneType);
writer.setZoneIds(CFF_FACE_ZONE, faceZone);
for (size_t iz = 0; iz < faceZone.size(); ++iz) {
faceZone[iz], CFF_ZONE_START_ID, startId[iz]);
faceZone[iz], CFF_ZONE_END_ID, endId[iz]);
faceZone[iz], CFF_ZONE_DIMENSION, dimension[iz]);
if (shadowZoneId[iz] > 0) {
faceZone[iz],
shadowZoneId[iz]);
}
if (childZoneId[iz] > 0) {
writer.setFaceZoneInfo(faceZone[iz],
childZoneId[iz]);
}
if (zoneType[iz] > -1) {
writer.setFaceZoneInfo(faceZone[iz],
zoneType[iz]);
}
if (elementType[iz] > -1) {
writer.setFaceZoneInfo(faceZone[iz],
elementType[iz]);
}
if (!name[iz].empty()) {
writer.setZoneStringInfo(faceZone[iz],
name[iz]);
}
if (!stringZoneType[iz].empty()) {
writer.setZoneStringInfo(faceZone[iz],
stringZoneType[iz]);
}
writer.setAllFaceZoneFlags(faceZone[iz], flags[iz]);
}
// start writing about thses face-zones
writer.startWritingFaces(faceZone);
// face-nodes
{
ansys::ZoneIds faceNodesZone;
std::vector<std::vector<short> > numNodes;
std::vector<std::vector<ansys::ElemIdType> > nodes;
// create face-node information of appropriate zones
CreateFaceNodes(faceNodesZone, numNodes, nodes);
writer.startWritingNodesForFaces(faceNodesZone);
for (size_t iz = 0; iz < faceNodesZone.size(); ++iz) {
faceNodesZone[iz], &(numNodes[iz].at(0)), numNodes[iz].size());
}
for (size_t iz = 0; iz < faceNodesZone.size(); ++iz) {
faceNodesZone[iz], &(nodes[iz].at(0)), nodes[iz].size());
}
}
// face-cell-0 s
{
ansys::ZoneIds faceC0Zone;
std::vector<std::vector<ansys::ElemIdType> > faceC0s;
CreateFaceC0s(faceC0Zone, faceC0s);
writer.startWritingCell0sForFaces(faceC0Zone);
for (size_t iz = 0; iz < faceC0Zone.size(); ++iz) {
faceC0Zone[iz], &(faceC0s[iz].at(0)), faceC0s[iz].size());
}
}
// face-cell-1 s
{
ansys::ZoneIds faceC1Zone;
std::vector<std::vector<ansys::ElemIdType> > faceC1s;
CreateFaceC1s(faceC1Zone, faceC1s);
writer.startWritingCell1sForFaces(faceC1Zone);
for (size_t iz = 0; iz < faceC1Zone.size(); ++iz) {
faceC1Zone[iz], &(faceC1s[iz].at(0)), faceC1s[iz].size());
}
}
writer.endWritingFaces();
}
// cells
{
ansys::ZoneIds cellZone;
std::vector<ansys::ElemIdType> startId;
std::vector<ansys::ElemIdType> endId;
std::vector<short> dimension;
std::vector<ansys::ZoneIdType> childZoneId;
std::vector<ansys::CellType> elementType;
std::vector<std::string> name;
std::vector<std::string> stringZoneType;
// create zone-level information of cells
CreateCellZones(
cellZone, startId, endId, dimension, childZoneId, elementType, name, stringZoneType);
// set the cell zones
writer.setZoneIds(CFF_CELL_ZONE, cellZone);
for (size_t iz = 0; iz < cellZone.size(); ++iz) {
cellZone[iz], CFF_ZONE_START_ID, startId[iz]);
cellZone[iz], CFF_ZONE_END_ID, endId[iz]);
cellZone[iz], CFF_ZONE_DIMENSION, dimension[iz]);
if (elementType[iz] >= 0)
writer.setCellZoneInfo(cellZone[iz],
elementType[iz]);
if (childZoneId[iz] > 0) {
writer.setCellZoneInfo(cellZone[iz],
childZoneId[iz]);
}
if (!name[iz].empty()) {
writer.setZoneStringInfo(cellZone[iz],
name[iz]);
}
if (!stringZoneType[iz].empty()) {
writer.setZoneStringInfo(cellZone[iz],
stringZoneType[iz]);
}
}
// start writing about these cell-zones
writer.startWritingCells(cellZone);
// cell-types
{
ansys::ZoneIds cellTypeZone;
std::vector<ansys::CellType> zoneCellTypes;
std::vector<std::vector<ansys::CellType> > allCellTypes;
// create cell-type information of appropriate zones;
CreateCellTypes(cellTypeZone, zoneCellTypes, allCellTypes);
writer.startWritingTypesForCells(cellTypeZone, zoneCellTypes);
for (size_t iz = 0; iz < cellTypeZone.size(); ++iz) {
if (CFF_CELL_TYPE_MIXED != zoneCellTypes[iz]) {
continue;
}
writer.setTypesForCellsInZone(cellTypeZone[iz],
&(allCellTypes[iz].at(0)),
allCellTypes[iz].size());
}
}
// cell-partitions
{
int numPartitions;
std::vector<ansys::ZoneIdType> cellPartitionZone;
std::vector< std::vector<ansys::PartitionIdType> > cellPartitions;
// create cell-partition information of appropriate zones;
CreateCellPartitions(cellPartitionZone, numPartitions, cellPartitions);
writer.startWritingPartitionIdsForCells(cellPartitionZone,
numPartitions);
if (numPartitions > 1) {
for (size_t iz = 0; iz < cellPartitionZone.size(); ++iz) {
writer.setPartitionIdsForCellsInZone(cellPartitionZone[iz],
&(cellPartitions[iz].at(0)),
cellPartitions[iz].size());
}
}
}
writer.endWritingCells();
}
writer.endWriting(ansys::DataClass::CFF_CASE);
// data-file
{
ansys::PhaseNames phaseNames;
// create the phases and get their ids
CreatePhases(phaseNames);
ansys::PhaseIds phaseIds;
writer.setPhaseNames(phaseNames,phaseIds);
for (size_t ip = 0; ip < phaseIds.size(); ++ip) {
writer.startWritingPhase(phaseIds[ip]);
std::vector<ansys::ZoneCategory> zoneCategory(2);
zoneCategory[0] = CFF_CELL_ZONE;
zoneCategory[1] = CFF_FACE_ZONE;
for (size_t izc = 0; izc < zoneCategory.size(); ++izc) {
std::vector<std::string> varName;
std::vector<int> varXFID;
CreateVarNames(phaseIds[ip], zoneCategory[izc], varName, varXFID);
writer.setPhaseVariablesOfCategory(zoneCategory[izc], varName);
for (size_t iv = 0; iv < varName.size(); ++iv) {
ansys::ZoneIds phaseCategoryVarZone;
size_t numColumns;
std::vector<std::vector<double> > data;
CreateVarsForThisCategory(phaseIds[ip],
zoneCategory[izc],
varXFID[iv],
phaseCategoryVarZone,
numColumns,
data);
zoneCategory[izc], varName[iv], phaseCategoryVarZone, numColumns);
for (size_t iz = 0; iz < phaseCategoryVarZone.size(); ++iz) {
phaseCategoryVarZone[iz], &(data[iz].at(0)), data[iz].size());
}
}
}
writer.endWritingPhase();
}
writer.endWriting(ansys::DataClass::CFF_RESULTS);
}
/*add string attribute to file*/
if (writer.addStringAttribute("write_new.cas.h5", "/meshes/1/faces", "groupAtt", "xyz"))
std::cout <<"writing of groupAtt successful!" << std::endl;
if (writer.addStringAttribute("write_new.dat.h5", "/results/1/phase-1/faces/SV_FLUX/1", "dsAtt", "abcd"))
std::cout <<"writing of dsAtt successful!" << std::endl;
/*to run locally, uncomment and provide either valid or invalid file name, invalid file will return false*/
if (writer.addStringAttribute("s2s123_old.cas.h5", "/meshes/1", "nfAtt", "1234"))
std::cout <<"writing of nfAtt successful!" << std::endl;
return 0;
}
std::vector< std::string > getInfos(bool formated=true, bool clear=false) const
returns, as strings, any unprocessed information messages registered
Definition: CffBaseMethods.cpp:1953
bool hasWarning() const
returns whether there are unprocessed warning messages registered.
Definition: CffBaseMethods.cpp:1898
void setMeshSize(const MeshSizeType type, const ElemIdType size)
Sets a value that defines the dimension or the global number of objects of a specific mesh entity.
Definition: CffBaseMethods.cpp:456
virtual void setSolverType(SolverType solverType)
Set the name of the application that is supplying the data.
Definition: CffBaseMethods.cpp:1713
void setZoneIds(const ZoneCategory zoneCategory, const ZoneIds &zonesIds)
Define the zones that are of a specific category.
Definition: CffBaseMethods.cpp:557
void setZoneStringInfo(const ZoneIdType zoneId, const ZoneStringInfoType type, const std::string &info)
Sets a string value associated with a zone.
Definition: CffBaseMethods.cpp:1148
void setCellZoneInfo(const ZoneIdType cellZoneId, const CellZoneInfoType cellZoneInfoType, const int info)
set certain zone level info for a cell zone.
Definition: CffBaseMethods.cpp:1048
void setFaceZoneInfo(const ZoneIdType faceZoneId, const FaceZoneInfoType faceZoneInfoType, const int info) const
set certain zone level info for a face zone.
Definition: CffBaseMethods.cpp:884
virtual void setDebugOn(bool debug)
Turn on/off debugging information.
Definition: CffBaseMethods.cpp:79
bool hasInfo() const
returns whether there are unprocessed informative messages registered.
Definition: CffBaseMethods.cpp:1908
void setZoneSizeInfo(const ZoneIdType zoneId, const ZoneSizeType sizeType, const ElemIdType size)
Sets a size setting of a zone.
Definition: CffBaseMethods.cpp:968
void setAllFaceZoneFlags(const ZoneIdType faceZoneId, const int allFlags)
Set flags for a face zone.
Definition: CffBaseMethods.cpp:694
bool hasError() const
returns whether there are unprocessed error messages registered.
Definition: CffBaseMethods.cpp:1888
void setMeshUnits(const std::string &units="m")
Define the units of length the mesh is defined in.
Definition: CffBaseMethods.cpp:524
Class that provides functions to write data within a CFF database. The database may be stored within ...
Definition: CffConsumer.hpp:18
virtual void setPartitionIdsForCellsInZone(const ZoneIdType, const PartitionIdType *const partIds, const size_t) const
set the partition ids for all cells in an cells zone
Definition: CffConsumerMethods.cpp:2107
virtual void startWritingNodeCountsForFaces() const
Start writing node counts for faces.
Definition: CffConsumerMethods.cpp:869
virtual void startWritingCoordinatesForNodes(const ZoneIds &zoneIds) const
Start writing the coorindinates for nodes.
Definition: CffConsumerMethods.cpp:286
virtual void endWritingNodeIdsForFaces() const
End of writing faces node ids.
Definition: CffConsumerMethods.cpp:1077
virtual void startWritingNodes(const ZoneIds &zoneIds) const
Definition: CffConsumerMethods.cpp:253
virtual void startWritingNodeIdsForFaces() const
Start writing faces node ids.
Definition: CffConsumerMethods.cpp:1012
virtual void setCoordinatesForNodesInZone(const ZoneIdType zoneId, const float *const coords, const size_t) const
Provide the coordinates for all nodes in zone.
Definition: CffConsumerMethods.cpp:424
virtual void startWritingCell0sForFaces(const ZoneIds &zoneIds) const
Start writing cell0 cell ids for faces.
Definition: CffConsumerMethods.cpp:1102
virtual void endWritingNodes() const
End writing nodes.
Definition: CffConsumerMethods.cpp:267
virtual void endWritingTypesForCells() const
End of writing cell types.
Definition: CffConsumerMethods.cpp:1659
virtual void setNodeIdsForFacesInZone(const ZoneIdType zoneId, const ElemIdType *const nodeIds, const size_t) const
set the node ids for all faces in a face zone
Definition: CffConsumerMethods.cpp:1062
virtual bool setPhaseVariablesOfCategory(const ZoneCategory zoneCategory, const VariableIds &ids) const
Add the variables in the currently active phase to zones of the category.
Definition: CffConsumerMethods.cpp:2644
virtual void startWritingPartitionIdsForCells(const ZoneIds &, const int) const
Start writing partition ids for cells.
Definition: CffConsumerMethods.cpp:2055
virtual void startWritingPhase(const PhaseIdType phaseId=1) const
Start writing a phase.
Definition: CffConsumerMethods.cpp:2523
virtual void startWritingCell1sForFaces(const ZoneIds &zoneIds) const
Start writing cell1 cell ids for faces.
Definition: CffConsumerMethods.cpp:1176
virtual void setCell0sForFacesInZone(const ZoneIdType zoneId, const ElemIdType *const faceC0s, const size_t) const
set the c0 cell ids for all faces in a face zone
Definition: CffConsumerMethods.cpp:1152
virtual void endWritingPhase() const
End of writing solution data for certain phase.
Definition: CffConsumerMethods.cpp:2534
virtual void startWritingFaces(const ZoneIds &zoneIds) const
Start of writing faces.
Definition: CffConsumerMethods.cpp:822
virtual void setTypesForCellsInZone(const ZoneIdType, const CellType *const cellTypes, const size_t) const
set the cell element types for all cells in a cell zone
Definition: CffConsumerMethods.cpp:1644
virtual void endWritingCoordinatesForNodes() const
Finish writing coordinates for nodes.
Definition: CffConsumerMethods.cpp:442
virtual void endWritingPhaseVariableInZonesOfCategory() const
End of writing one variable in certain zone category.
Definition: CffConsumerMethods.cpp:2965
virtual void endWritingCell1sForFaces() const
End of writing cell1 of faces.
Definition: CffConsumerMethods.cpp:1241
virtual void setValuesOfPhaseVariableForElementsInZone(const ZoneIdType zoneId, const double *const vals, const size_t dataSize) const
Set the solution data values for all elements in certain range.
Definition: CffConsumerMethods.cpp:2931
virtual void endWritingNodeCountsForFaces() const
End writing faces node counts.
Definition: CffConsumerMethods.cpp:1003
virtual void endWritingCell0sForFaces() const
End of writing cell0 of faces.
Definition: CffConsumerMethods.cpp:1167
virtual void startWritingPhaseVariableInZonesOfCategory(const ZoneCategory zoneCategory, const VariableIdType varId, ZoneIds &zoneIds, const size_t numCols) const
Start writing data for certain variable.
Definition: CffConsumerMethods.cpp:2808
virtual void startWritingNodesForFaces(const ZoneIds &zoneIds) const
Start writing faces nodes.
Definition: CffConsumerMethods.cpp:853
virtual bool setPhaseNames(const PhaseNames &phaseNames, PhaseIds &phaseIds) const
Define the set of unique phase names (all existing phase names and associated variables are deleted)
Definition: CffConsumerMethods.cpp:2455
virtual void endWritingPartitionIdsForCells() const
End of writing partition ids for cells.
Definition: CffConsumerMethods.cpp:2122
virtual void startWritingCells(const ZoneIds &) const
Start writing cells.
Definition: CffConsumerMethods.cpp:1567
virtual void setNodeCountsForFacesInZone(const ZoneIdType zoneId, const short *const nodeCounts, const size_t) const
Define the node count for the faces in the zone.
Definition: CffConsumerMethods.cpp:935
virtual void setCell1sForFacesInZone(const ZoneIdType zoneId, const ElemIdType *const faceC1s, const size_t) const
set the c1 cell ids for all faces in a face zone
Definition: CffConsumerMethods.cpp:1226
virtual void endWritingCells() const
End of writing cells.
Definition: CffConsumerMethods.cpp:1578
virtual void endWritingFaces() const
End of writing face data.
Definition: CffConsumerMethods.cpp:833
void setDataPrecision(DataPrecisionType ptype)
Sets the precision for solution data.
Definition: CffConsumerMethods.cpp:4436
virtual void endWritingNodesForFaces() const
End of writing faces nodes.
Definition: CffConsumerMethods.cpp:1087
virtual void startWritingTypesForCells(const ZoneIds &, const std::vector< CellType > &) const
Start writing cells types.
Definition: CffConsumerMethods.cpp:1592
virtual void writeMeshAttributes() const
Write the global mesh size attributes and units to the active mesh.
Definition: CffConsumerMethods.cpp:151
@ CFF_PRECISION_DOUBLE
Definition: CffTypes.h:436
@ CFF_ZONE_STRING_NAME
Definition: CffTypes.h:369
@ CFF_ZONE_STRING_TYPE
Definition: CffTypes.h:375
@ CFF_FACE_ZONE_CHILD_ZONE_ID
Definition: CffTypes.h:281
@ CFF_FACE_ZONE_TYPE
Definition: CffTypes.h:301
@ CFF_FACE_ZONE_FACE_TYPE
Definition: CffTypes.h:277
@ CFF_FACE_ZONE_SHADOW_ZONE_ID
Definition: CffTypes.h:294
@ CFF_HDF
Definition: CffTypes.h:648
@ CFF_CELL_ZONE_CHILD_ZONE_ID
Definition: CffTypes.h:329
@ CFF_CELL_ZONE_CELL_TYPE
Definition: CffTypes.h:325
@ CFF_MESH_NODE_COUNT
Definition: CffTypes.h:179
@ CFF_MESH_DIMENSION
Definition: CffTypes.h:177
@ CFF_MESH_CELL_COUNT
Definition: CffTypes.h:185
@ CFF_MESH_FACE_COUNT
Definition: CffTypes.h:183
std::vector< PhaseName > PhaseNames
Type used to represent a number of phase names ('C++' API only)
Definition: Types.hpp:169

The function uses data that is made available from some functions in a separate utility source file.

/*
* Copyright ANSYS. All Rights Reserved.
*/
#ifndef CASANDDATCREATOR_HPP_
#define CASANDDATCREATOR_HPP_
#include "CffInterface/Types.hpp"
#include <iostream>
#include <memory>
#include <vector>
#include <algorithm>
#include <iterator>
int
CreateMeshInfo(size_t& meshDimension,
size_t& nodeCount,
size_t& faceCount,
size_t& cellCount)
{
meshDimension = 3;
nodeCount = 268;
faceCount = 811;
cellCount = 226;
return 0;
}
int
CreateMeshUnits(std::string& units)
{
units = "mm";
return 0;
}
int
CreateNodeZones(ansys::ZoneIds& zoneIds,
std::vector<ansys::ElemIdType>& startId,
std::vector<ansys::ElemIdType>& endId,
std::vector<short>& dimension,
std::vector<std::string>& names)
{
zoneIds.resize(1);
startId.resize(1);
endId.resize(1);
dimension.resize(1);
names.resize(1);
zoneIds[0] = 1;
startId[0] = 1;
endId[0] = 268;
dimension[0] = 3;
names[0] = "nodes";
return 0;
}
int
CreateNodeCoords(ansys::ZoneIds& zoneIds,
std::vector<std::vector<double> >& coords)
{
zoneIds.resize(1);
coords.resize(1);
zoneIds[0] = 1;
{
double coordArray[804] = {
4, 5, -5, 5, 5, -5,
4.2949, 4.29203, -5, 5, 4, -5,
-5, 5, -5, -4, 5, -5,
-4.28449, 4.29336, -5, -5, 4, -5,
3.36679, 4.01827, -5, 3, 5, -5,
-3.4074, 4.16032, -5, -3, 5, -5,
4.16391, 3.425, -5, 5, 3, -5,
-3.99814, 3.36568, -5, -5, 3, -5,
4.13207, 2.43224, -5, 5, 2, -5,
-4.11523, 2.32634, -5, -5, 2, -5,
2.32413, 4.14427, -5, 2, 5, -5,
-2.4011, 4.12412, -5, -2, 5, -5,
1.33151, 4.17863, -5, 1, 5, -5,
4.15412, 1.43927, -5, 5, 1, -5,
-4.12597, 1.32028, -5, -5, 1, -5,
-1.37779, 4.12701, -5, -1, 5, -5,
-0.361047, 4.17443, -5, 0, 5, -5,
-4.1715, 0.314437, -5, 5, -1, -5,
4.00137, -0.334686, -5, 5, 0, -5,
4.28603, 0.554, -5, 0.489886, 4.33415, -5,
3.27584, 2.89718, -5, 2.56937, 3.33611, -5,
1.6395, 3.29373, -5, 0.485803, 3.42122, -5,
3.23962, 1.84968, -5, 3.36809, 0.72585, -5,
-2.85446, 3.26947, -5, -3.28514, 2.57466, -5,
-3.22381, 1.67259, -5, -3.27848, 0.608651, -5,
-1.79511, 3.22421, -5, -0.692263, 3.29081, -5,
-3.41982, -0.566414, -5, 3.16692, -0.971077, -5,
3.03932, -0.14658, -5, -2.27922, 2.22601, -5,
2.23483, 2.36929, -5, -1.14069, 2.39528, -5,
2.38029, 1.25286, -5, -2.34839, 1.05757, -5,
1.04639, 2.4209, -5, -1.40628, 1.43654, -5,
1.51141, 1.58652, -5, 2.13619, -0.51801, -5,
2.45026, 0.378916, -5, -2.42638, -0.0500925, -5,
-0.0340174, 2.44186, -5, 1.45748, 0.535142, -5,
-0.507031, 1.69288, -5, -1.47973, 0.405438, -5,
0.487921, 1.38142, -5, -0.51817, 0.821268, -5,
0.352882, 0.252772, -5, 5, 5, -4,
4.2949, 4.29203, -4, 4, 5, -4,
5, 4, -4, -4, 5, -4,
-4.28449, 4.29336, -4, -5, 5, -4,
-5, 4, -4, 3.36679, 4.01827, -4,
3, 5, -4, -3.4074, 4.16032, -4,
-3, 5, -4, 4.16391, 3.425, -4,
5, 3, -4, -3.99814, 3.36568, -4,
-5, 3, -4, 4.13207, 2.43224, -4,
5, 2, -4, -4.11523, 2.32634, -4,
-5, 2, -4, 2.32413, 4.14427, -4,
2, 5, -4, -2.4011, 4.12412, -4,
-2, 5, -4, 1.33151, 4.17863, -4,
1, 5, -4, 4.15412, 1.43927, -4,
5, 1, -4, -4.12597, 1.32028, -4,
-5, 1, -4, -1.37779, 4.12701, -4,
-1, 5, -4, -0.361047, 4.17443, -4,
0, 5, -4, -4.1715, 0.314437, -4,
4.00137, -0.334686, -4, 5, -1, -4,
5, 0, -4, 4.28603, 0.554, -4,
0.489886, 4.33415, -4, 3.27584, 2.89718, -4,
2.56937, 3.33611, -4, 1.6395, 3.29373, -4,
0.485803, 3.42122, -4, 3.23962, 1.84968, -4,
3.36809, 0.72585, -4, -2.85446, 3.26947, -4,
-3.28514, 2.57466, -4, -3.22381, 1.67259, -4,
-3.27848, 0.608651, -4, -1.79511, 3.22421, -4,
-0.692263, 3.29081, -4, 3.16692, -0.971077, -4,
-3.41982, -0.566414, -4, 3.03932, -0.14658, -4,
-2.27922, 2.22601, -4, 2.23483, 2.36929, -4,
-1.14069, 2.39528, -4, 2.38029, 1.25286, -4,
-2.34839, 1.05757, -4, 1.04639, 2.4209, -4,
-1.40628, 1.43654, -4, 1.51141, 1.58652, -4,
2.13619, -0.51801, -4, 2.45026, 0.378916, -4,
-2.42638, -0.0500925, -4, -0.0340174, 2.44186, -4,
1.45748, 0.535142, -4, -0.507031, 1.69288, -4,
-1.47973, 0.405438, -4, 0.487921, 1.38142, -4,
-0.51817, 0.821268, -4, 0.352882, 0.252772, -4,
-4, -5, -5, -5, -5, -5,
-4.30102, -4.28573, -5, -5, -4, -5,
5, -4, -5, 5, -5, -5,
4.29688, -4.29686, -5, 4, -5, -5,
-3.38547, -4.00046, -5, -3, -5, -5,
4.1662, -3.4372, -5, 5, -3, -5,
-4.17682, -3.40839, -5, -5, -3, -5,
3.37048, -4.03056, -5, 3, -5, -5,
-2.35127, -4.11775, -5, -2, -5, -5,
4.12722, -2.45332, -5, 5, -2, -5,
-4.15054, -2.39953, -5, -5, -2, -5,
2.32841, -4.14959, -5, 2, -5, -5,
-1.35007, -4.123, -5, -1, -5, -5,
4.09022, -1.43744, -5, -4.17527, -1.38782, -5,
-5, -1, -5, 1.33589, -4.17482, -5,
1, -5, -5, -0.348806, -4.1639, -5,
0, -5, -5, -5, 0, -5,
-4.33211, -0.528578, -5, 0.495674, -4.3258, -5,
3.27911, -2.93579, -5, 2.57619, -3.35689, -5,
1.64848, -3.2995, -5, 0.493433, -3.39937, -5,
3.2283, -1.95621, -5, -3.31463, -2.85404, -5,
-2.62181, -3.29356, -5, -1.73064, -3.2261, -5,
-0.673956, -3.26263, -5, -3.28714, -1.76643, -5,
2.24511, -2.41062, -5, -2.31288, -2.30325, -5,
2.45719, -1.46343, -5, -2.45086, -1.14567, -5,
-1.15733, -2.34335, -5, 1.0706, -2.41316, -5,
-1.60901, -1.56005, -5, 1.5713, -1.4756, -5,
-0.0570161, -2.37276, -5, -1.5263, -0.640689, -5,
-0.612207, -1.33597, -5, 0.522457, -1.48437, -5,
-0.619336, -0.197472, -5, 1.05492, -0.543938, -5,
0.133292, -0.666839, -5, -5, -5, -4,
-4.30102, -4.28573, -4, -4, -5, -4,
-5, -4, -4, 5, -5, -4,
4.29688, -4.29686, -4, 5, -4, -4,
4, -5, -4, -3.38547, -4.00046, -4,
-3, -5, -4, 4.1662, -3.4372, -4,
5, -3, -4, -4.17682, -3.40839, -4,
-5, -3, -4, 3.37048, -4.03056, -4,
3, -5, -4, -2.35127, -4.11775, -4,
-2, -5, -4, 4.12722, -2.45332, -4,
5, -2, -4, -4.15054, -2.39953, -4,
-5, -2, -4, 2.32841, -4.14959, -4,
2, -5, -4, -1.35007, -4.123, -4,
-1, -5, -4, 4.09022, -1.43744, -4,
-4.17527, -1.38782, -4, -5, -1, -4,
1.33589, -4.17482, -4, 1, -5, -4,
-0.348806, -4.1639, -4, 0, -5, -4,
-5, 0, -4, -4.33211, -0.528578, -4,
0.495674, -4.3258, -4, 3.27911, -2.93579, -4,
2.57619, -3.35689, -4, 1.64848, -3.2995, -4,
0.493433, -3.39937, -4, 3.2283, -1.95621, -4,
-3.31463, -2.85404, -4, -2.62181, -3.29356, -4,
-1.73064, -3.2261, -4, -0.673956, -3.26263, -4,
-3.28714, -1.76643, -4, 2.24511, -2.41062, -4,
-2.31288, -2.30325, -4, 2.45719, -1.46343, -4,
-2.45086, -1.14567, -4, -1.15733, -2.34335, -4,
1.0706, -2.41316, -4, -1.60901, -1.56005, -4,
1.5713, -1.4756, -4, -0.0570161, -2.37276, -4,
-1.5263, -0.640689, -4, -0.612207, -1.33597, -4,
0.522457, -1.48437, -4, -0.619336, -0.197472, -4,
1.05492, -0.543938, -4, 0.133292, -0.666839, -4};
coords[0].assign(coordArray, coordArray + 804);
}
return 0;
}
int
CreateFaceZones(ansys::ZoneIds& zoneIds,
std::vector<ansys::ElemIdType>& startId,
std::vector<ansys::ElemIdType>& endId,
std::vector<short>& dimension,
std::vector<ansys::ZoneIdType>& shadowZoneId,
std::vector<ansys::ZoneIdType>& childZoneId,
std::vector<ansys::FaceZoneType>& zoneType,
std::vector<ansys::FaceType>& elementType,
std::vector<short>& flags,
std::vector<std::string>& name,
std::vector<std::string>& stringZoneType)
{
zoneIds.resize(7, 0);
startId.resize(7, 0);
endId.resize(7, 0);
dimension.resize(7, 0);
shadowZoneId.resize(7, 0);
childZoneId.resize(7, 0);
zoneType.resize(7, CFF_FACE_ZONE_TYPE_MIN);
elementType.resize(7, CFF_FACE_TYPE_MIN);
flags.resize(7, 0);
name.resize(7);
stringZoneType.resize(7);
size_t zoneIdx = 0;
zoneIds[zoneIdx] = 7;
startId[zoneIdx] = 1;
endId[zoneIdx] = 226;
dimension[zoneIdx] = 3;
zoneType[zoneIdx] = CFF_FACE_ZONE_TYPE_WALL;
elementType[zoneIdx] = CFF_FACE_TYPE_TRI;
flags[zoneIdx] = 0;
name[zoneIdx] = "wall-1";
stringZoneType[zoneIdx]= "wall";
zoneIdx++;
zoneIds[zoneIdx] = 20;
startId[zoneIdx] = 227;
endId[zoneIdx] = 545;
dimension[zoneIdx] = 3;
zoneType[zoneIdx] = CFF_FACE_ZONE_TYPE_INTERIOR;
elementType[zoneIdx] = CFF_FACE_TYPE_QUAD;
flags[zoneIdx] = 0;
name[zoneIdx] = "interior-20";
stringZoneType[zoneIdx]= "interior";
zoneIdx++;
zoneIds[zoneIdx] = 28;
startId[zoneIdx] = 546;
endId[zoneIdx] = 771;
dimension[zoneIdx] = 3;
zoneType[zoneIdx] = CFF_FACE_ZONE_TYPE_WALL;
elementType[zoneIdx] = CFF_FACE_TYPE_TRI;
flags[zoneIdx] = 0;
name[zoneIdx] = "prism-cap-28";
stringZoneType[zoneIdx]= "wall";
zoneIdx++;
zoneIds[zoneIdx] = 31;
startId[zoneIdx] = 772;
endId[zoneIdx] = 781;
dimension[zoneIdx] = 3;
zoneType[zoneIdx] = CFF_FACE_ZONE_TYPE_WALL;
elementType[zoneIdx] = CFF_FACE_TYPE_QUAD;
flags[zoneIdx] = 0;
name[zoneIdx] = "wall-3-quad-32";
stringZoneType[zoneIdx]= "wall";
zoneIdx++;
zoneIds[zoneIdx] = 32;
startId[zoneIdx] = 782;
endId[zoneIdx] = 791;
dimension[zoneIdx] = 3;
zoneType[zoneIdx] = CFF_FACE_ZONE_TYPE_WALL;
elementType[zoneIdx] = CFF_FACE_TYPE_QUAD;
flags[zoneIdx] = 0;
name[zoneIdx] = "wall-4-quad-32";
stringZoneType[zoneIdx]= "wall";
zoneIdx++;
zoneIds[zoneIdx] = 33;
startId[zoneIdx] = 792;
endId[zoneIdx] = 801;
dimension[zoneIdx] = 3;
zoneType[zoneIdx] = CFF_FACE_ZONE_TYPE_WALL;
elementType[zoneIdx] = CFF_FACE_TYPE_QUAD;
flags[zoneIdx] = 0;
name[zoneIdx] = "wall-5-quad-33";
stringZoneType[zoneIdx]= "wall";
zoneIdx++;
zoneIds[zoneIdx] = 34;
startId[zoneIdx] = 802;
endId[zoneIdx] = 811;
dimension[zoneIdx] = 3;
zoneType[zoneIdx] = CFF_FACE_ZONE_TYPE_WALL;
elementType[zoneIdx] = CFF_FACE_TYPE_QUAD;
flags[zoneIdx] = 0;
name[zoneIdx] = "wall-6-quad-34";
stringZoneType[zoneIdx]= "wall";
return 0;
}
int
CreateFaceNodes(ansys::ZoneIds& zoneIds,
std::vector<std::vector<short> >& numNodes,
std::vector<std::vector<ansys::ElemIdType> >& nodes)
{
zoneIds.resize(7, 0);
numNodes.resize(7);
nodes.resize(7);
zoneIds[0] = 7;
numNodes[0].resize(226, 3);
{
ansys::ElemIdType nodesArray[678] = {
3, 2, 1, 4, 2, 3, 7, 6, 5, 8, 7, 5, 9, 3,
1, 10, 9, 1, 11, 6, 7, 12, 6, 11, 13, 4, 3, 14,
4, 13, 15, 7, 8, 16, 15, 8, 17, 14, 13, 18, 14, 17,
19, 15, 16, 20, 19, 16, 21, 9, 10, 22, 21, 10, 23, 12,
11, 24, 12, 23, 25, 21, 22, 26, 25, 22, 27, 18, 17, 28,
18, 27, 29, 19, 20, 30, 29, 20, 31, 24, 23, 32, 24, 31,
33, 32, 31, 34, 32, 33, 35, 29, 30, 38, 37, 36, 39, 28,
27, 38, 28, 39, 40, 25, 26, 34, 40, 26, 37, 38, 39, 33,
40, 34, 11, 7, 15, 9, 13, 3, 41, 17, 13, 9, 41, 13,
42, 9, 21, 41, 9, 42, 43, 21, 25, 42, 21, 43, 44, 25,
40, 43, 25, 44, 45, 27, 17, 41, 45, 17, 46, 39, 27, 45,
46, 27, 47, 23, 11, 15, 47, 11, 48, 15, 19, 47, 15, 48,
49, 19, 29, 48, 19, 49, 50, 29, 35, 49, 29, 50, 51, 31,
23, 47, 51, 23, 52, 33, 31, 51, 52, 31, 33, 44, 40, 44,
33, 52, 53, 50, 35, 46, 37, 39, 55, 54, 37, 46, 55, 37,
56, 51, 47, 48, 56, 47, 56, 48, 49, 57, 41, 42, 45, 41,
57, 57, 42, 43, 58, 52, 51, 56, 58, 51, 59, 46, 45, 57,
59, 45, 60, 49, 50, 56, 49, 60, 61, 43, 44, 57, 43, 61,
62, 56, 60, 58, 56, 62, 63, 57, 61, 59, 57, 63, 64, 54,
55, 65, 55, 46, 59, 65, 46, 50, 53, 66, 66, 60, 50, 67,
44, 52, 58, 67, 52, 67, 61, 44, 65, 64, 55, 68, 59, 63,
65, 59, 68, 69, 67, 58, 62, 69, 58, 70, 60, 66, 70, 62,
60, 71, 61, 67, 69, 71, 67, 71, 63, 61, 71, 68, 63, 68,
64, 65, 72, 62, 70, 69, 62, 72, 72, 71, 69, 73, 68, 71,
72, 73, 71, 149, 148, 147, 150, 148, 149, 153, 152, 151, 154, 152,
153, 155, 149, 147, 156, 155, 147, 157, 153, 151, 158, 157, 151, 159,
150, 149, 160, 150, 159, 161, 154, 153, 162, 154, 161, 163, 155, 156,
164, 163, 156, 165, 157, 158, 166, 165, 158, 167, 160, 159, 168, 160,
167, 169, 162, 161, 170, 162, 169, 171, 163, 164, 172, 171, 164, 173,
165, 166, 36, 173, 166, 174, 168, 167, 175, 168, 174, 176, 170, 169,
177, 170, 176, 178, 171, 172, 179, 178, 172, 180, 35, 30, 181, 175,
174, 180, 175, 181, 37, 173, 36, 182, 177, 176, 179, 177, 182, 35,
180, 181, 182, 178, 179, 157, 161, 153, 155, 159, 149, 183, 157, 165,
161, 157, 183, 184, 169, 161, 183, 184, 161, 185, 176, 169, 184, 185,
169, 186, 182, 176, 185, 186, 176, 187, 165, 173, 183, 165, 187, 54,
173, 37, 187, 173, 54, 188, 167, 159, 155, 188, 159, 189, 155, 163,
188, 155, 189, 190, 163, 171, 189, 163, 190, 191, 171, 178, 190, 171,
191, 192, 174, 167, 188, 192, 167, 53, 181, 174, 192, 53, 174, 186,
178, 182, 186, 191, 178, 53, 35, 181, 193, 184, 183, 187, 193, 183,
193, 185, 184, 194, 192, 188, 189, 194, 188, 194, 189, 190, 195, 187,
54, 193, 187, 195, 196, 53, 192, 194, 196, 192, 197, 190, 191, 194,
190, 197, 198, 186, 185, 193, 198, 185, 199, 194, 197, 196, 194, 199,
200, 193, 195, 198, 193, 200, 195, 54, 64, 66, 53, 196, 201, 186,
198, 191, 186, 201, 201, 197, 191, 200, 195, 64, 202, 196, 199, 66,
196, 202, 202, 70, 66, 203, 199, 197, 201, 203, 197, 204, 201, 198,
203, 201, 204, 204, 198, 200, 203, 202, 199, 205, 70, 202, 72, 70,
205, 206, 200, 64, 204, 200, 206, 207, 203, 204, 206, 207, 204, 206,
64, 68, 205, 202, 203, 205, 203, 207, 73, 72, 205, 73, 207, 206,
68, 73, 206, 205, 207, 73};
nodes[0].assign(nodesArray, nodesArray + 678);
}
zoneIds[1] = 20;
numNodes[1].resize(319, 4);
{
ansys::ElemIdType nodesArray[1276] = {
3, 75, 74, 2, 1, 76, 75, 3, 3, 75, 77, 4, 7, 79,
78, 6, 5, 80, 79, 7, 8, 81, 79, 7, 9, 82, 75, 3,
1, 76, 82, 9, 10, 83, 82, 9, 11, 84, 78, 6, 7, 79,
84, 11, 11, 84, 85, 12, 13, 86, 77, 4, 3, 75, 86, 13,
13, 86, 87, 14, 15, 88, 79, 7, 8, 81, 88, 15, 16, 89,
88, 15, 17, 90, 87, 14, 13, 86, 90, 17, 17, 90, 91, 18,
19, 92, 88, 15, 16, 89, 92, 19, 20, 93, 92, 19, 21, 94,
82, 9, 10, 83, 94, 21, 22, 95, 94, 21, 23, 96, 85, 12,
11, 84, 96, 23, 23, 96, 97, 24, 25, 98, 94, 21, 22, 95,
98, 25, 26, 99, 98, 25, 27, 100, 91, 18, 17, 90, 100, 27,
27, 100, 101, 28, 29, 102, 92, 19, 20, 93, 102, 29, 30, 103,
102, 29, 31, 104, 97, 24, 23, 96, 104, 31, 31, 104, 105, 32,
33, 106, 105, 32, 31, 104, 106, 33, 33, 106, 107, 34, 35, 108,
102, 29, 30, 103, 108, 35, 36, 110, 109, 37, 38, 111, 109, 37,
39, 112, 101, 28, 27, 100, 112, 39, 39, 112, 111, 38, 40, 113,
98, 25, 26, 99, 113, 40, 34, 107, 113, 40, 39, 112, 109, 37,
33, 106, 113, 40, 15, 88, 84, 11, 9, 82, 86, 13, 41, 114,
90, 17, 13, 86, 114, 41, 9, 82, 114, 41, 42, 115, 82, 9,
21, 94, 115, 42, 42, 115, 114, 41, 43, 116, 94, 21, 25, 98,
116, 43, 43, 116, 115, 42, 44, 117, 98, 25, 40, 113, 117, 44,
44, 117, 116, 43, 45, 118, 100, 27, 17, 90, 118, 45, 41, 114,
118, 45, 46, 119, 112, 39, 27, 100, 119, 46, 45, 118, 119, 46,
47, 120, 96, 23, 11, 84, 120, 47, 15, 88, 120, 47, 48, 121,
88, 15, 19, 92, 121, 48, 48, 121, 120, 47, 49, 122, 92, 19,
29, 102, 122, 49, 49, 122, 121, 48, 50, 123, 102, 29, 35, 108,
123, 50, 50, 123, 122, 49, 51, 124, 104, 31, 23, 96, 124, 51,
47, 120, 124, 51, 52, 125, 106, 33, 31, 104, 125, 52, 51, 124,
125, 52, 37, 109, 126, 54, 33, 106, 117, 44, 52, 125, 117, 44,
53, 127, 108, 35, 53, 127, 123, 50, 46, 119, 109, 37, 55, 128,
126, 54, 37, 109, 128, 55, 46, 119, 128, 55, 56, 129, 124, 51,
47, 120, 129, 56, 48, 121, 129, 56, 49, 122, 129, 56, 57, 130,
114, 41, 42, 115, 130, 57, 57, 130, 118, 45, 43, 116, 130, 57,
58, 131, 125, 52, 51, 124, 131, 58, 56, 129, 131, 58, 59, 132,
119, 46, 45, 118, 132, 59, 57, 130, 132, 59, 60, 133, 122, 49,
50, 123, 133, 60, 60, 133, 129, 56, 61, 134, 116, 43, 44, 117,
134, 61, 61, 134, 130, 57, 62, 135, 129, 56, 60, 133, 135, 62,
62, 135, 131, 58, 63, 136, 130, 57, 61, 134, 136, 63, 63, 136,
132, 59, 64, 137, 126, 54, 55, 128, 137, 64, 65, 138, 128, 55,
46, 119, 138, 65, 59, 132, 138, 65, 66, 139, 127, 53, 66, 139,
123, 50, 66, 139, 133, 60, 67, 140, 117, 44, 52, 125, 140, 67,
58, 131, 140, 67, 67, 140, 134, 61, 65, 138, 137, 64, 68, 141,
132, 59, 63, 136, 141, 68, 68, 141, 138, 65, 69, 142, 140, 67,
58, 131, 142, 69, 62, 135, 142, 69, 70, 143, 133, 60, 66, 139,
143, 70, 70, 143, 135, 62, 71, 144, 134, 61, 67, 140, 144, 71,
69, 142, 144, 71, 71, 144, 136, 63, 71, 144, 141, 68, 68, 141,
137, 64, 72, 145, 135, 62, 70, 143, 145, 72, 72, 145, 142, 69,
72, 145, 144, 71, 73, 146, 141, 68, 71, 144, 146, 73, 72, 145,
146, 73, 149, 209, 208, 148, 147, 210, 209, 149, 149, 209, 211, 150,
153, 213, 212, 152, 151, 214, 213, 153, 153, 213, 215, 154, 155, 216,
209, 149, 147, 210, 216, 155, 156, 217, 216, 155, 157, 218, 213, 153,
151, 214, 218, 157, 158, 219, 218, 157, 159, 220, 211, 150, 149, 209,
220, 159, 159, 220, 221, 160, 161, 222, 215, 154, 153, 213, 222, 161,
161, 222, 223, 162, 163, 224, 216, 155, 156, 217, 224, 163, 164, 225,
224, 163, 165, 226, 218, 157, 158, 219, 226, 165, 166, 227, 226, 165,
167, 228, 221, 160, 159, 220, 228, 167, 167, 228, 229, 168, 169, 230,
223, 162, 161, 222, 230, 169, 169, 230, 231, 170, 171, 232, 224, 163,
164, 225, 232, 171, 172, 233, 232, 171, 173, 234, 226, 165, 166, 227,
234, 173, 36, 110, 234, 173, 174, 235, 229, 168, 167, 228, 235, 174,
174, 235, 236, 175, 176, 237, 231, 170, 169, 230, 237, 176, 176, 237,
238, 177, 178, 239, 232, 171, 172, 233, 239, 178, 179, 240, 239, 178,
180, 241, 108, 35, 181, 242, 236, 175, 174, 235, 242, 181, 181, 242,
241, 180, 37, 109, 234, 173, 182, 243, 238, 177, 176, 237, 243, 182,
182, 243, 240, 179, 181, 242, 108, 35, 182, 243, 239, 178, 157, 218,
222, 161, 155, 216, 220, 159, 183, 244, 218, 157, 165, 226, 244, 183,
183, 244, 222, 161, 184, 245, 230, 169, 161, 222, 245, 184, 183, 244,
245, 184, 185, 246, 237, 176, 169, 230, 246, 185, 184, 245, 246, 185,
186, 247, 243, 182, 176, 237, 247, 186, 185, 246, 247, 186, 187, 248,
226, 165, 173, 234, 248, 187, 187, 248, 244, 183, 54, 126, 234, 173,
54, 126, 248, 187, 188, 249, 228, 167, 159, 220, 249, 188, 155, 216,
249, 188, 189, 250, 216, 155, 163, 224, 250, 189, 189, 250, 249, 188,
190, 251, 224, 163, 171, 232, 251, 190, 190, 251, 250, 189, 191, 252,
232, 171, 178, 239, 252, 191, 191, 252, 251, 190, 192, 253, 235, 174,
167, 228, 253, 192, 188, 249, 253, 192, 53, 127, 242, 181, 174, 235,
127, 53, 192, 253, 127, 53, 186, 247, 239, 178, 186, 247, 252, 191,
193, 254, 245, 184, 183, 244, 254, 193, 187, 248, 254, 193, 193, 254,
246, 185, 194, 255, 253, 192, 188, 249, 255, 194, 189, 250, 255, 194,
190, 251, 255, 194, 195, 256, 248, 187, 54, 126, 256, 195, 195, 256,
254, 193, 196, 257, 127, 53, 192, 253, 257, 196, 194, 255, 257, 196,
197, 258, 251, 190, 191, 252, 258, 197, 197, 258, 255, 194, 198, 259,
247, 186, 185, 246, 259, 198, 193, 254, 259, 198, 199, 260, 255, 194,
197, 258, 260, 199, 199, 260, 257, 196, 200, 261, 254, 193, 195, 256,
261, 200, 200, 261, 259, 198, 64, 137, 256, 195, 196, 257, 139, 66,
201, 262, 247, 186, 198, 259, 262, 201, 201, 262, 252, 191, 201, 262,
258, 197, 64, 137, 261, 200, 202, 263, 257, 196, 199, 260, 263, 202,
202, 263, 139, 66, 202, 263, 143, 70, 203, 264, 260, 199, 197, 258,
264, 203, 201, 262, 264, 203, 204, 265, 262, 201, 198, 259, 265, 204,
204, 265, 264, 203, 200, 261, 265, 204, 203, 264, 263, 202, 205, 266,
143, 70, 202, 263, 266, 205, 205, 266, 145, 72, 206, 267, 261, 200,
64, 137, 267, 206, 206, 267, 265, 204, 207, 268, 264, 203, 204, 265,
268, 207, 206, 267, 268, 207, 68, 141, 267, 206, 203, 264, 266, 205,
207, 268, 266, 205, 205, 266, 146, 73, 73, 146, 268, 207, 206, 267,
146, 73};
nodes[1].assign(nodesArray, nodesArray + 1276);
}
zoneIds[2] = 28;
numNodes[2].resize(226, 3);
{
ansys::ElemIdType nodesArray[678] = {
76, 74, 75, 75, 74, 77, 80, 78, 79, 80, 79, 81, 76, 75,
82, 76, 82, 83, 79, 78, 84, 84, 78, 85, 75, 77, 86, 86,
77, 87, 81, 79, 88, 81, 88, 89, 86, 87, 90, 90, 87, 91,
89, 88, 92, 89, 92, 93, 83, 82, 94, 83, 94, 95, 84, 85,
96, 96, 85, 97, 95, 94, 98, 95, 98, 99, 90, 91, 100, 100,
91, 101, 93, 92, 102, 93, 102, 103, 96, 97, 104, 104, 97, 105,
104, 105, 106, 106, 105, 107, 103, 102, 108, 110, 109, 111, 100, 101,
112, 112, 101, 111, 99, 98, 113, 99, 113, 107, 112, 111, 109, 107,
113, 106, 88, 79, 84, 75, 86, 82, 86, 90, 114, 86, 114, 82,
94, 82, 115, 115, 82, 114, 98, 94, 116, 116, 94, 115, 113, 98,
117, 117, 98, 116, 90, 100, 118, 90, 118, 114, 100, 112, 119, 100,
119, 118, 84, 96, 120, 84, 120, 88, 92, 88, 121, 121, 88, 120,
102, 92, 122, 122, 92, 121, 108, 102, 123, 123, 102, 122, 96, 104,
124, 96, 124, 120, 104, 106, 125, 104, 125, 124, 113, 117, 106, 125,
106, 117, 108, 123, 127, 112, 109, 119, 109, 126, 128, 109, 128, 119,
120, 124, 129, 120, 129, 121, 122, 121, 129, 115, 114, 130, 130, 114,
118, 116, 115, 130, 124, 125, 131, 124, 131, 129, 118, 119, 132, 118,
132, 130, 123, 122, 133, 133, 122, 129, 117, 116, 134, 134, 116, 130,
133, 129, 135, 135, 129, 131, 134, 130, 136, 136, 130, 132, 128, 126,
137, 119, 128, 138, 119, 138, 132, 139, 127, 123, 123, 133, 139, 125,
117, 140, 125, 140, 131, 117, 134, 140, 128, 137, 138, 136, 132, 141,
141, 132, 138, 131, 140, 142, 131, 142, 135, 139, 133, 143, 133, 135,
143, 140, 134, 144, 140, 144, 142, 134, 136, 144, 136, 141, 144, 138,
137, 141, 143, 135, 145, 145, 135, 142, 142, 144, 145, 144, 141, 146,
144, 146, 145, 210, 208, 209, 209, 208, 211, 214, 212, 213, 213, 212,
215, 210, 209, 216, 210, 216, 217, 214, 213, 218, 214, 218, 219, 209,
211, 220, 220, 211, 221, 213, 215, 222, 222, 215, 223, 217, 216, 224,
217, 224, 225, 219, 218, 226, 219, 226, 227, 220, 221, 228, 228, 221,
229, 222, 223, 230, 230, 223, 231, 225, 224, 232, 225, 232, 233, 227,
226, 234, 227, 234, 110, 228, 229, 235, 235, 229, 236, 230, 231, 237,
237, 231, 238, 233, 232, 239, 233, 239, 240, 103, 108, 241, 235, 236,
242, 242, 236, 241, 110, 234, 109, 237, 238, 243, 243, 238, 240, 242,
241, 108, 240, 239, 243, 213, 222, 218, 209, 220, 216, 226, 218, 244,
244, 218, 222, 222, 230, 245, 222, 245, 244, 230, 237, 246, 230, 246,
245, 237, 243, 247, 237, 247, 246, 234, 226, 248, 248, 226, 244, 109,
234, 126, 126, 234, 248, 220, 228, 249, 220, 249, 216, 224, 216, 250,
250, 216, 249, 232, 224, 251, 251, 224, 250, 239, 232, 252, 252, 232,
251, 228, 235, 253, 228, 253, 249, 235, 242, 127, 235, 127, 253, 243,
239, 247, 239, 252, 247, 242, 108, 127, 244, 245, 254, 244, 254, 248,
245, 246, 254, 249, 253, 255, 249, 255, 250, 251, 250, 255, 126, 248,
256, 256, 248, 254, 253, 127, 257, 253, 257, 255, 252, 251, 258, 258,
251, 255, 246, 247, 259, 246, 259, 254, 258, 255, 260, 260, 255, 257,
256, 254, 261, 261, 254, 259, 137, 126, 256, 257, 127, 139, 259, 247,
262, 262, 247, 252, 252, 258, 262, 137, 256, 261, 260, 257, 263, 263,
257, 139, 139, 143, 263, 258, 260, 264, 258, 264, 262, 259, 262, 265,
265, 262, 264, 261, 259, 265, 260, 263, 264, 263, 143, 266, 266, 143,
145, 137, 261, 267, 267, 261, 265, 265, 264, 268, 265, 268, 267, 141,
137, 267, 264, 263, 266, 268, 264, 266, 266, 145, 146, 267, 268, 146,
267, 146, 141, 146, 268, 266};
nodes[2].assign(nodesArray, nodesArray + 678);
}
zoneIds[3] = 31;
numNodes[3].resize(10, 4);
{
ansys::ElemIdType nodesArray[40] = {2, 74, 76, 1, 6, 78, 80, 5, 1, 76,
83, 10, 12, 85, 78, 6, 10, 83, 95, 22,
24, 97, 85, 12, 22, 95, 99, 26, 32, 105,
97, 24, 34, 107, 105, 32, 26, 99, 107, 34};
nodes[3].assign(nodesArray, nodesArray + 40);
}
zoneIds[4] = 32;
numNodes[4].resize(10, 4);
{
ansys::ElemIdType nodesArray[40] = {4, 77, 74, 2, 14, 87, 77, 4, 18, 91,
87, 14, 28, 101, 91, 18, 36, 110, 111, 38,
38, 111, 101, 28, 152, 212, 214, 151, 151, 214,
219, 158, 158, 219, 227, 166, 166, 227, 110, 36};
nodes[4].assign(nodesArray, nodesArray + 40);
}
zoneIds[5] = 33;
numNodes[5].resize(10, 4);
{
ansys::ElemIdType nodesArray[40] = {5, 80, 81, 8, 8, 81, 89, 16, 16, 89,
93, 20, 20, 93, 103, 30, 150, 211, 208, 148,
160, 221, 211, 150, 168, 229, 221, 160, 175, 236,
229, 168, 30, 103, 241, 180, 180, 241, 236, 175};
nodes[5].assign(nodesArray, nodesArray + 40);
}
zoneIds[6] = 34;
numNodes[6].resize(10, 4);
{
ansys::ElemIdType nodesArray[40] = {148, 208, 210, 147, 154, 215, 212, 152, 147, 210,
217, 156, 162, 223, 215, 154, 156, 217, 225, 164,
170, 231, 223, 162, 164, 225, 233, 172, 177, 238,
231, 170, 172, 233, 240, 179, 179, 240, 238, 177};
nodes[6].assign(nodesArray, nodesArray + 40);
}
return 0;
}
int
CreateFaceC0s(ansys::ZoneIds& zoneIds,
std::vector<std::vector<ansys::ElemIdType> >& faceC0s)
{
zoneIds.resize(7, 0);
faceC0s.resize(7);
zoneIds[0] = 7;
{
ansys::ElemIdType c0Array[226] = {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140,
141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168,
169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196,
197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210,
211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
225, 226};
faceC0s[0].assign(c0Array, c0Array + 226);
}
zoneIds[1] = 20;
{
ansys::ElemIdType c0Array[319] = {
1, 1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9, 9,
10, 11, 11, 12, 13, 13, 14, 15, 15, 16, 17, 17, 18, 19,
19, 20, 21, 21, 22, 23, 23, 24, 25, 25, 26, 27, 27, 28,
29, 29, 30, 31, 31, 147, 32, 33, 33, 34, 35, 35, 36, 37,
38, 39, 40, 41, 41, 42, 43, 43, 44, 45, 45, 46, 47, 47,
48, 49, 49, 50, 51, 51, 52, 53, 53, 54, 55, 55, 56, 57,
57, 58, 59, 59, 60, 61, 61, 62, 63, 63, 64, 164, 65, 66,
180, 67, 68, 69, 69, 70, 71, 71, 72, 73, 74, 74, 75, 76,
77, 77, 78, 79, 79, 80, 81, 81, 82, 83, 83, 84, 85, 85,
86, 87, 87, 88, 89, 89, 90, 90, 91, 200, 92, 93, 94, 94,
95, 96, 97, 98, 98, 99, 100, 100, 101, 102, 102, 103, 104, 104,
105, 106, 107, 108, 109, 109, 110, 111, 112, 112, 113, 114, 114, 115,
116, 116, 117, 118, 118, 119, 120, 120, 121, 122, 122, 123, 124, 124,
125, 126, 126, 127, 128, 128, 129, 130, 130, 131, 132, 132, 133, 134,
134, 135, 136, 136, 137, 138, 138, 139, 140, 140, 141, 142, 142, 143,
144, 145, 145, 146, 147, 148, 148, 149, 150, 151, 152, 153, 154, 154,
155, 156, 156, 157, 158, 158, 159, 160, 160, 161, 162, 162, 163, 164,
165, 166, 166, 167, 168, 168, 169, 170, 170, 171, 172, 172, 173, 174,
174, 175, 176, 176, 177, 178, 179, 181, 181, 182, 183, 184, 184, 185,
186, 187, 187, 188, 189, 189, 190, 191, 191, 192, 193, 193, 194, 195,
195, 196, 197, 197, 198, 199, 200, 201, 201, 202, 203, 204, 205, 205,
206, 207, 208, 208, 209, 210, 210, 211, 212, 213, 214, 214, 215, 216,
216, 217, 218, 218, 219, 220, 221, 222, 223, 224, 224};
faceC0s[1].assign(c0Array, c0Array + 319);
}
zoneIds[2] = 28;
{
ansys::ElemIdType c0Array[226] = {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140,
141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168,
169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196,
197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210,
211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
225, 226};
faceC0s[2].assign(c0Array, c0Array + 226);
}
zoneIds[3] = 31;
{
ansys::ElemIdType c0Array[10] = {1, 3, 6, 8, 18, 20, 22, 28, 30, 36};
faceC0s[3].assign(c0Array, c0Array + 10);
}
zoneIds[4] = 32;
{
ansys::ElemIdType c0Array[10] = {2, 10, 14, 24, 32, 34, 116, 121, 129, 137};
faceC0s[4].assign(c0Array, c0Array + 10);
}
zoneIds[5] = 33;
{
ansys::ElemIdType c0Array[10] = {4, 12, 16, 26, 115, 123, 131, 139, 144, 146};
faceC0s[5].assign(c0Array, c0Array + 10);
}
zoneIds[6] = 34;
{
ansys::ElemIdType c0Array[10] = {114, 117, 119, 125, 127, 133, 135, 141, 143, 149};
faceC0s[6].assign(c0Array, c0Array + 10);
}
return 0;
}
int
CreateFaceC1s(ansys::ZoneIds& zoneIds,
std::vector<std::vector<ansys::ElemIdType> >& faceC1s)
{
zoneIds.resize(1, 0);
faceC1s.resize(1);
zoneIds[0] = 20;
{
ansys::ElemIdType c1Array[319] = {
2, 5, 9, 7, 4, 11, 40, 6, 17, 8, 39, 19, 10, 40,
13, 39, 12, 15, 14, 41, 23, 55, 16, 25, 43, 18, 21, 20,
53, 27, 45, 22, 35, 24, 49, 33, 57, 26, 31, 28, 61, 29,
30, 63, 38, 59, 144, 32, 37, 34, 51, 37, 47, 36, 38, 68,
65, 54, 42, 50, 42, 44, 44, 46, 74, 46, 48, 76, 48, 65,
83, 52, 50, 75, 68, 52, 79, 62, 54, 56, 56, 58, 72, 58,
60, 73, 60, 67, 81, 64, 62, 71, 66, 64, 77, 69, 66, 94,
67, 92, 70, 89, 70, 90, 78, 72, 73, 82, 75, 76, 80, 84,
95, 78, 86, 91, 80, 88, 82, 93, 85, 84, 96, 87, 86, 103,
101, 88, 106, 98, 199, 97, 97, 91, 99, 92, 93, 102, 96, 95,
100, 104, 108, 99, 107, 108, 105, 101, 110, 103, 207, 109, 106, 105,
111, 107, 112, 220, 110, 215, 111, 113, 225, 113, 223, 115, 118, 122,
117, 120, 124, 153, 119, 126, 152, 121, 128, 123, 153, 130, 125, 152,
132, 168, 127, 134, 154, 129, 136, 131, 166, 138, 133, 156, 140, 170,
135, 142, 162, 137, 147, 139, 174, 145, 141, 158, 148, 172, 143, 151,
150, 146, 176, 150, 164, 149, 160, 151, 180, 178, 155, 167, 155, 163,
157, 159, 157, 181, 161, 159, 183, 178, 161, 193, 163, 165, 182, 165,
187, 175, 167, 169, 169, 171, 185, 171, 173, 186, 173, 179, 191, 177,
175, 184, 180, 177, 189, 179, 202, 183, 182, 188, 194, 190, 185, 186,
192, 188, 199, 197, 200, 190, 196, 192, 203, 195, 201, 194, 198, 196,
208, 205, 198, 204, 212, 204, 206, 202, 210, 203, 209, 216, 206, 213,
207, 214, 213, 209, 211, 211, 212, 218, 217, 221, 215, 221, 223, 217,
220, 219, 222, 219, 224, 225, 222, 226, 226, 226, 225};
faceC1s[0].assign(c1Array, c1Array + 319);
}
return 0;
}
int
CreateCellZones(ansys::ZoneIds& zoneIds,
std::vector<ansys::ElemIdType>& startId,
std::vector<ansys::ElemIdType>& endId,
std::vector<short>& dimension,
std::vector<ansys::ZoneIdType>& childZoneId,
std::vector<ansys::CellType>& elementType,
std::vector<std::string>& name,
std::vector<std::string>& stringZoneType)
{
zoneIds.resize(1, 0);
startId.resize(1, 0);
endId.resize(1, 0);
dimension.resize(1, 0);
childZoneId.resize(1, 0);
elementType.resize(1, CFF_CELL_TYPE_MIN);
name.resize(1);
stringZoneType.resize(1);
zoneIds[0] = 18;
startId[0] = 1;
endId[0] = 226;
dimension[0] = 3;
elementType[0] = CFF_CELL_TYPE_WEDGE;
name[0] = "prism-cells-18";
stringZoneType[0] = "fluid";
return 0;
}
int
CreateCellTypes(ansys::ZoneIds& zoneIds,
std::vector<ansys::CellType>& zoneCellTypes,
std::vector<std::vector<ansys::CellType> >& allCellTypes)
{
zoneIds.resize(1, 0);
zoneCellTypes.resize(1, CFF_CELL_TYPE_MIXED);
allCellTypes.resize(1);
zoneIds[0] = 18;
zoneCellTypes[0] = CFF_CELL_TYPE_WEDGE;
allCellTypes[0].clear();
return 0;
}
void setCellFaces(const ansys::ElemIdType startId,
const std::vector<ansys::ElemIdType>& cxArray,
std::vector<std::vector<ansys::ElemIdType> >& tempFId)
{
size_t i = 0;
for (const auto elem : cxArray)
{
tempFId.at(elem - 1).push_back(startId + i);
i++;
}
}
void
createCellFaces(ansys::ZoneIds& zoneIds,
std::vector<std::vector<ansys::ElemIdType> >& lCellConn,
std::vector<std::vector<short> >& lCellCounts)
{
zoneIds.clear();
zoneIds.push_back(18);
std::vector<std::vector<ansys::ElemIdType> > tempFId(226);
{
std::vector<ansys::ElemIdType>c1Array {
2, 5, 9, 7, 4, 11, 40, 6, 17, 8, 39, 19, 10, 40,
13, 39, 12, 15, 14, 41, 23, 55, 16, 25, 43, 18, 21, 20,
53, 27, 45, 22, 35, 24, 49, 33, 57, 26, 31, 28, 61, 29,
30, 63, 38, 59, 144, 32, 37, 34, 51, 37, 47, 36, 38, 68,
65, 54, 42, 50, 42, 44, 44, 46, 74, 46, 48, 76, 48, 65,
83, 52, 50, 75, 68, 52, 79, 62, 54, 56, 56, 58, 72, 58,
60, 73, 60, 67, 81, 64, 62, 71, 66, 64, 77, 69, 66, 94,
67, 92, 70, 89, 70, 90, 78, 72, 73, 82, 75, 76, 80, 84,
95, 78, 86, 91, 80, 88, 82, 93, 85, 84, 96, 87, 86, 103,
101, 88, 106, 98, 199, 97, 97, 91, 99, 92, 93, 102, 96, 95,
100, 104, 108, 99, 107, 108, 105, 101, 110, 103, 207, 109, 106, 105,
111, 107, 112, 220, 110, 215, 111, 113, 225, 113, 223, 115, 118, 122,
117, 120, 124, 153, 119, 126, 152, 121, 128, 123, 153, 130, 125, 152,
132, 168, 127, 134, 154, 129, 136, 131, 166, 138, 133, 156, 140, 170,
135, 142, 162, 137, 147, 139, 174, 145, 141, 158, 148, 172, 143, 151,
150, 146, 176, 150, 164, 149, 160, 151, 180, 178, 155, 167, 155, 163,
157, 159, 157, 181, 161, 159, 183, 178, 161, 193, 163, 165, 182, 165,
187, 175, 167, 169, 169, 171, 185, 171, 173, 186, 173, 179, 191, 177,
175, 184, 180, 177, 189, 179, 202, 183, 182, 188, 194, 190, 185, 186,
192, 188, 199, 197, 200, 190, 196, 192, 203, 195, 201, 194, 198, 196,
208, 205, 198, 204, 212, 204, 206, 202, 210, 203, 209, 216, 206, 213,
207, 214, 213, 209, 211, 211, 212, 218, 217, 221, 215, 221, 223, 217,
220, 219, 222, 219, 224, 225, 222, 226, 226, 226, 225};
ansys::ElemIdType startId = 227;
setCellFaces(startId, c1Array, tempFId);
}
{
std::vector<ansys::ElemIdType>c0Array{
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140,
141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168,
169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196,
197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210,
211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
225, 226};
ansys::ElemIdType startId = 1;
setCellFaces(startId, c0Array, tempFId);
}
{
std::vector<ansys::ElemIdType> c0Array{
1, 1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9, 9,
10, 11, 11, 12, 13, 13, 14, 15, 15, 16, 17, 17, 18, 19,
19, 20, 21, 21, 22, 23, 23, 24, 25, 25, 26, 27, 27, 28,
29, 29, 30, 31, 31, 147, 32, 33, 33, 34, 35, 35, 36, 37,
38, 39, 40, 41, 41, 42, 43, 43, 44, 45, 45, 46, 47, 47,
48, 49, 49, 50, 51, 51, 52, 53, 53, 54, 55, 55, 56, 57,
57, 58, 59, 59, 60, 61, 61, 62, 63, 63, 64, 164, 65, 66,
180, 67, 68, 69, 69, 70, 71, 71, 72, 73, 74, 74, 75, 76,
77, 77, 78, 79, 79, 80, 81, 81, 82, 83, 83, 84, 85, 85,
86, 87, 87, 88, 89, 89, 90, 90, 91, 200, 92, 93, 94, 94,
95, 96, 97, 98, 98, 99, 100, 100, 101, 102, 102, 103, 104, 104,
105, 106, 107, 108, 109, 109, 110, 111, 112, 112, 113, 114, 114, 115,
116, 116, 117, 118, 118, 119, 120, 120, 121, 122, 122, 123, 124, 124,
125, 126, 126, 127, 128, 128, 129, 130, 130, 131, 132, 132, 133, 134,
134, 135, 136, 136, 137, 138, 138, 139, 140, 140, 141, 142, 142, 143,
144, 145, 145, 146, 147, 148, 148, 149, 150, 151, 152, 153, 154, 154,
155, 156, 156, 157, 158, 158, 159, 160, 160, 161, 162, 162, 163, 164,
165, 166, 166, 167, 168, 168, 169, 170, 170, 171, 172, 172, 173, 174,
174, 175, 176, 176, 177, 178, 179, 181, 181, 182, 183, 184, 184, 185,
186, 187, 187, 188, 189, 189, 190, 191, 191, 192, 193, 193, 194, 195,
195, 196, 197, 197, 198, 199, 200, 201, 201, 202, 203, 204, 205, 205,
206, 207, 208, 208, 209, 210, 210, 211, 212, 213, 214, 214, 215, 216,
216, 217, 218, 218, 219, 220, 221, 222, 223, 224, 224};
ansys::ElemIdType startId = 227;
setCellFaces(startId, c0Array, tempFId);
}
{
std::vector<ansys::ElemIdType> c0Array{
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140,
141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168,
169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196,
197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210,
211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
225, 226};
ansys::ElemIdType startId = 546;
setCellFaces(startId, c0Array, tempFId);
}
{
std::vector<ansys::ElemIdType> c0Array{1, 3, 6, 8, 18, 20, 22, 28, 30, 36};
ansys::ElemIdType startId = 772;
setCellFaces(startId, c0Array, tempFId);
}
{
std::vector<ansys::ElemIdType> c0Array{2, 10, 14, 24, 32, 34, 116, 121, 129, 137};
ansys::ElemIdType startId = 782;
setCellFaces(startId, c0Array, tempFId);
}
{
std::vector<ansys::ElemIdType> c0Array{4, 12, 16, 26, 115, 123, 131, 139, 144, 146};
ansys::ElemIdType startId = 792;
setCellFaces(startId, c0Array, tempFId);
}
{
std::vector<ansys::ElemIdType> c0Array{114, 117, 119, 125, 127, 133, 135, 141, 143, 149};
ansys::ElemIdType startId = 802;
setCellFaces(startId, c0Array, tempFId);
}
lCellCounts.resize(1);
lCellCounts.at(0).clear();
lCellConn.resize(1);
lCellConn.at(0).clear();
for (const auto& vec : tempFId)
{
lCellCounts.at(0).push_back(static_cast<short>(vec.size()));
std::copy(vec.begin(), vec.end(), std::back_inserter(lCellConn.at(0)));
}
}
int
CreateCellPartitions(ansys::ZoneIds& zoneIds,
int& numPartitions,
std::vector<std::vector<ansys::PartitionIdType> >& cellPartitions)
{
zoneIds.resize(1, 0);
cellPartitions.resize(1);
numPartitions = 2;
zoneIds[0] = 18;
{
ansys::PartitionIdType cellPartitionsArray[226] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
cellPartitions[0].assign(cellPartitionsArray, cellPartitionsArray + 226);
}
return 0;
}
int
CreatePhases(ansys::PhaseNames& phaseNames)
{
phaseNames.resize(1, "phase-1");
return 0;
}
int
CreateVarNames(const ansys::PhaseIdType phaseId,
const ansys::ZoneCategory zoneCategory,
std::vector<int>& xfIds)
{
switch (phaseId) {
case 1:
switch (zoneCategory) {
vars.resize(11);
xfIds.resize(11);
vars[0] = "SV_DT_BC_SOURCE";
vars[1] = "SV_FLUX";
vars[2] = "SV_HEAT_FLUX";
vars[3] = "SV_P";
vars[4] = "SV_RAD_HEAT_FLUX";
vars[5] = "SV_U";
vars[6] = "SV_V";
vars[7] = "SV_W";
vars[8] = "SV_WALL_SHEAR";
vars[9] = "SV_WALL_V";
vars[10] = "SV_WALL_VV";
xfIds[0] = 1328;
xfIds[1] = 18;
xfIds[2] = 20;
xfIds[3] = 1;
xfIds[4] = 21;
xfIds[5] = 111;
xfIds[6] = 112;
xfIds[7] = 113;
xfIds[8] = 19;
xfIds[9] = 114;
xfIds[10] = 8553;
break;
vars.resize(8);
xfIds.resize(8);
vars[0] = "SV_BF_V";
vars[1] = "SV_DENSITY";
vars[2] = "SV_DPM_PARTITION";
vars[3] = "SV_MU_LAM";
vars[4] = "SV_P";
vars[5] = "SV_U";
vars[6] = "SV_V";
vars[7] = "SV_W";
xfIds[0] = 15;
xfIds[1] = 101;
xfIds[2] = 420;
xfIds[3] = 102;
xfIds[4] = 1;
xfIds[5] = 111;
xfIds[6] = 112;
xfIds[7] = 113;
break;
default:;
}
break;
case 2:
switch (zoneCategory) {
vars.resize(11);
xfIds.resize(11);
vars[0] = "SV_DT_BC_SOURCE";
vars[1] = "SV_FLUX";
vars[2] = "SV_HEAT_FLUX";
vars[3] = "SV_P";
vars[4] = "SV_RAD_HEAT_FLUX";
vars[5] = "SV_U";
vars[6] = "SV_V";
vars[7] = "SV_W";
vars[8] = "SV_WALL_SHEAR";
vars[9] = "SV_WALL_V";
vars[10] = "SV_WALL_VV";
xfIds[0] = 1328;
xfIds[1] = 18;
xfIds[2] = 20;
xfIds[3] = 1;
xfIds[4] = 21;
xfIds[5] = 111;
xfIds[6] = 112;
xfIds[7] = 113;
xfIds[8] = 19;
xfIds[9] = 114;
xfIds[10] = 8553;
break;
vars.resize(8);
xfIds.resize(8);
vars[0] = "SV_BF_V";
vars[1] = "SV_DENSITY";
vars[2] = "SV_DPM_PARTITION";
vars[3] = "SV_MU_LAM";
vars[4] = "SV_P";
vars[5] = "SV_U";
vars[6] = "SV_V";
vars[7] = "SV_W";
xfIds[0] = 15;
xfIds[1] = 101;
xfIds[2] = 420;
xfIds[3] = 102;
xfIds[4] = 1;
xfIds[5] = 111;
xfIds[6] = 112;
xfIds[7] = 113;
break;
default:;
}
break;
default:
std::cout << "No need to write phase-" << phaseId << "." << std::endl;
break;
}
return 0;
}
int
CreateVarsForThisCategory(const ansys::PhaseIdType phaseId,
const ansys::ZoneCategory zoneCategory,
const ansys::VariableIdType varId,
ansys::ZoneIds& zoneIds,
size_t& numColumns,
std::vector<std::vector<double> >& data)
{
switch (phaseId) {
case 1:
switch (zoneCategory) {
switch (varId) {
case 1328:
// "2nd Grad Bc Source"
zoneIds.resize(6);
data.resize(6);
zoneIds[0] = 7;
zoneIds[1] = 28;
zoneIds[2] = 31;
zoneIds[3] = 32;
zoneIds[4] = 33;
zoneIds[5] = 34;
numColumns = 1;
data[0].resize(226, 0.0);
data[1].resize(226, 0.0);
data[2].resize(10, 0.0);
data[3].resize(10, 0.0);
data[4].resize(10, 0.0);
data[5].resize(10, 0.0);
break;
case 18:
// "Mass Flux"
zoneIds.resize(7);
data.resize(7);
zoneIds[0] = 7;
zoneIds[1] = 20;
zoneIds[2] = 28;
zoneIds[3] = 31;
zoneIds[4] = 32;
zoneIds[5] = 33;
zoneIds[6] = 34;
numColumns = 1;
data[0].resize(226, 0.0);
data[1].resize(319, 0.0);
data[2].resize(226, 0.0);
data[3].resize(10, 0.0);
data[4].resize(10, 0.0);
data[5].resize(10, 0.0);
data[6].resize(10, 0.0);
break;
case 20:
// "Boundary heat flux":
zoneIds.resize(6);
data.resize(6);
zoneIds[0] = 7;
zoneIds[1] = 28;
zoneIds[2] = 31;
zoneIds[3] = 32;
zoneIds[4] = 33;
zoneIds[5] = 34;
numColumns = 1;
data[0].resize(226, 0.0);
data[1].resize(226, 0.0);
data[2].resize(10, 0.0);
data[3].resize(10, 0.0);
data[4].resize(10, 0.0);
data[5].resize(10, 0.0);
break;
case 1:
// "Pressure"
zoneIds.resize(7);
data.resize(7);
zoneIds[0] = 7;
zoneIds[1] = 20;
zoneIds[2] = 28;
zoneIds[3] = 31;
zoneIds[4] = 32;
zoneIds[5] = 33;
zoneIds[6] = 34;
numColumns = 1;
data[0].resize(226, 0.0);
data[1].resize(319, 0.0);
data[2].resize(226, 0.0);
data[3].resize(10, 0.0);
data[4].resize(10, 0.0);
data[5].resize(10, 0.0);
data[6].resize(10, 0.0);
break;
case 21:
// "Boundary rad heat flux"
zoneIds.resize(6);
data.resize(6);
zoneIds[0] = 7;
zoneIds[1] = 28;
zoneIds[2] = 31;
zoneIds[3] = 32;
zoneIds[4] = 33;
zoneIds[5] = 34;
numColumns = 1;
data[0].resize(226, 0.0);
data[1].resize(226, 0.0);
data[2].resize(10, 0.0);
data[3].resize(10, 0.0);
data[4].resize(10, 0.0);
data[5].resize(10, 0.0);
break;
case 111:
// "X Velocity"
zoneIds.resize(6);
data.resize(6);
zoneIds[0] = 7;
zoneIds[1] = 28;
zoneIds[2] = 31;
zoneIds[3] = 32;
zoneIds[4] = 33;
zoneIds[5] = 34;
numColumns = 1;
data[0].resize(226, 0.0);
data[1].resize(226, 0.0);
data[2].resize(10, 0.0);
data[3].resize(10, 0.0);
data[4].resize(10, 0.0);
data[5].resize(10, 0.0);
break;
case 112:
// "Y Velocity"
zoneIds.resize(6);
data.resize(6);
zoneIds[0] = 7;
zoneIds[1] = 28;
zoneIds[2] = 31;
zoneIds[3] = 32;
zoneIds[4] = 33;
zoneIds[5] = 34;
numColumns = 1;
data[0].resize(226, 0.0);
data[1].resize(226, 0.0);
data[2].resize(10, 0.0);
data[3].resize(10, 0.0);
data[4].resize(10, 0.0);
data[5].resize(10, 0.0);
break;
case 113:
// "Z Velocity"
zoneIds.resize(6);
data.resize(6);
zoneIds[0] = 7;
zoneIds[1] = 28;
zoneIds[2] = 31;
zoneIds[3] = 32;
zoneIds[4] = 33;
zoneIds[5] = 34;
numColumns = 1;
data[0].resize(226, 0.0);
data[1].resize(226, 0.0);
data[2].resize(10, 0.0);
data[3].resize(10, 0.0);
data[4].resize(10, 0.0);
data[5].resize(10, 0.0);
break;
case 19:
// "Wall shear"
zoneIds.resize(6);
data.resize(6);
zoneIds[0] = 7;
zoneIds[1] = 28;
zoneIds[2] = 31;
zoneIds[3] = 32;
zoneIds[4] = 33;
zoneIds[5] = 34;
numColumns = 3;
data[0].resize(678, 0.0);
data[1].resize(678, 0.0);
data[2].resize(30, 0.0);
data[3].resize(30, 0.0);
data[4].resize(30, 0.0);
data[5].resize(30, 0.0);
break;
case 114:
// "Wall Velocity"
zoneIds.resize(6);
data.resize(6);
zoneIds[0] = 7;
zoneIds[1] = 28;
zoneIds[2] = 31;
zoneIds[3] = 32;
zoneIds[4] = 33;
zoneIds[5] = 34;
numColumns = 3;
data[0].resize(678, 0.0);
data[1].resize(678, 0.0);
data[2].resize(30, 0.0);
data[3].resize(30, 0.0);
data[4].resize(30, 0.0);
data[5].resize(30, 0.0);
break;
case 8553:
// "Original Wall Velocity"
zoneIds.resize(6);
data.resize(6);
zoneIds[0] = 7;
zoneIds[1] = 28;
zoneIds[2] = 31;
zoneIds[3] = 32;
zoneIds[4] = 33;
zoneIds[5] = 34;
numColumns = 3;
data[0].resize(678, 0.0);
data[1].resize(678, 0.0);
data[2].resize(30, 0.0);
data[3].resize(30, 0.0);
data[4].resize(30, 0.0);
data[5].resize(30, 0.0);
break;
default:;
}
break;
switch (varId) {
case 15:
// "Body Force"
zoneIds.resize(1);
data.resize(1);
zoneIds[0] = 18;
numColumns = 3;
data[0].resize(678, 0.0);
break;
case 101:
// "Density"
zoneIds.resize(1);
data.resize(1);
zoneIds[0] = 18;
numColumns = 1;
data[0].resize(226, 1.225);
break;
case 420:
// "DPM-partition"
zoneIds.resize(1);
data.resize(1);
zoneIds[0] = 18;
numColumns = 1;
data[0].resize(226, 0.0);
break;
case 102:
// "Laminar Viscosity"
zoneIds.resize(1);
data.resize(1);
zoneIds[0] = 18;
numColumns = 1;
data[0].resize(226, 0.000018);
break;
case 1:
// "Pressure"
zoneIds.resize(1);
data.resize(1);
zoneIds[0] = 18;
numColumns = 1;
data[0].resize(226, 0.0);
break;
case 111:
// "X Velocity"
zoneIds.resize(1);
data.resize(1);
zoneIds[0] = 18;
numColumns = 1;
data[0].resize(226, 0.0);
break;
case 112:
// "Y Velocity"
zoneIds.resize(1);
data.resize(1);
zoneIds[0] = 18;
numColumns = 1;
data[0].resize(226, 0.0);
break;
case 113:
// "Z Velocity"
zoneIds.resize(1);
data.resize(1);
zoneIds[0] = 18;
numColumns = 1;
data[0].resize(226, 0.0);
break;
default:;
}
break;
default:;
}
break;
case 2:
switch (zoneCategory) {
switch (varId) {
case 1328:
// "2nd Grad Bc Source"
zoneIds.resize(6);
data.resize(6);
zoneIds[0] = 7;
zoneIds[1] = 28;
zoneIds[2] = 31;
zoneIds[3] = 32;
zoneIds[4] = 33;
zoneIds[5] = 34;
numColumns = 1;
data[0].resize(226, 0.0);
data[1].resize(226, 0.0);
data[2].resize(10, 0.0);
data[3].resize(10, 0.0);
data[4].resize(10, 0.0);
data[5].resize(10, 0.0);
break;
case 18:
// "Mass Flux"
zoneIds.resize(7);
data.resize(7);
zoneIds[0] = 7;
zoneIds[1] = 20;
zoneIds[2] = 28;
zoneIds[3] = 31;
zoneIds[4] = 32;
zoneIds[5] = 33;
zoneIds[6] = 34;
numColumns = 1;
data[0].resize(226, 0.0);
data[1].resize(319, 0.0);
data[2].resize(226, 0.0);
data[3].resize(10, 0.0);
data[4].resize(10, 0.0);
data[5].resize(10, 0.0);
data[6].resize(10, 0.0);
break;
case 20:
// "Boundary heat flux":
zoneIds.resize(6);
data.resize(6);
zoneIds[0] = 7;
zoneIds[1] = 28;
zoneIds[2] = 31;
zoneIds[3] = 32;
zoneIds[4] = 33;
zoneIds[5] = 34;
numColumns = 1;
data[0].resize(226, 0.0);
data[1].resize(226, 0.0);
data[2].resize(10, 0.0);
data[3].resize(10, 0.0);
data[4].resize(10, 0.0);
data[5].resize(10, 0.0);
break;
case 1:
// "Pressure"
zoneIds.resize(7);
data.resize(7);
zoneIds[0] = 7;
zoneIds[1] = 20;
zoneIds[2] = 28;
zoneIds[3] = 31;
zoneIds[4] = 32;
zoneIds[5] = 33;
zoneIds[6] = 34;
numColumns = 1;
data[0].resize(226, 0.0);
data[1].resize(319, 0.0);
data[2].resize(226, 0.0);
data[3].resize(10, 0.0);
data[4].resize(10, 0.0);
data[5].resize(10, 0.0);
data[6].resize(10, 0.0);
break;
case 21:
// "Boundary rad heat flux"
zoneIds.resize(6);
data.resize(6);
zoneIds[0] = 7;
zoneIds[1] = 28;
zoneIds[2] = 31;
zoneIds[3] = 32;
zoneIds[4] = 33;
zoneIds[5] = 34;
numColumns = 1;
data[0].resize(226, 0.0);
data[1].resize(226, 0.0);
data[2].resize(10, 0.0);
data[3].resize(10, 0.0);
data[4].resize(10, 0.0);
data[5].resize(10, 0.0);
break;
case 111:
// "X Velocity"
zoneIds.resize(6);
data.resize(6);
zoneIds[0] = 7;
zoneIds[1] = 28;
zoneIds[2] = 31;
zoneIds[3] = 32;
zoneIds[4] = 33;
zoneIds[5] = 34;
numColumns = 1;
data[0].resize(226, 0.0);
data[1].resize(226, 0.0);
data[2].resize(10, 0.0);
data[3].resize(10, 0.0);
data[4].resize(10, 0.0);
data[5].resize(10, 0.0);
break;
case 112:
// "Y Velocity"
zoneIds.resize(6);
data.resize(6);
zoneIds[0] = 7;
zoneIds[1] = 28;
zoneIds[2] = 31;
zoneIds[3] = 32;
zoneIds[4] = 33;
zoneIds[5] = 34;
numColumns = 1;
data[0].resize(226, 0.0);
data[1].resize(226, 0.0);
data[2].resize(10, 0.0);
data[3].resize(10, 0.0);
data[4].resize(10, 0.0);
data[5].resize(10, 0.0);
break;
case 113:
// "Z Velocity"
zoneIds.resize(6);
data.resize(6);
zoneIds[0] = 7;
zoneIds[1] = 28;
zoneIds[2] = 31;
zoneIds[3] = 32;
zoneIds[4] = 33;
zoneIds[5] = 34;
numColumns = 1;
data[0].resize(226, 0.0);
data[1].resize(226, 0.0);
data[2].resize(10, 0.0);
data[3].resize(10, 0.0);
data[4].resize(10, 0.0);
data[5].resize(10, 0.0);
break;
case 19:
// "Wall shear"
zoneIds.resize(6);
data.resize(6);
zoneIds[0] = 7;
zoneIds[1] = 28;
zoneIds[2] = 31;
zoneIds[3] = 32;
zoneIds[4] = 33;
zoneIds[5] = 34;
numColumns = 3;
data[0].resize(678, 0.0);
data[1].resize(678, 0.0);
data[2].resize(30, 0.0);
data[3].resize(30, 0.0);
data[4].resize(30, 0.0);
data[5].resize(30, 0.0);
break;
case 114:
// "Wall Velocity"
zoneIds.resize(6);
data.resize(6);
zoneIds[0] = 7;
zoneIds[1] = 28;
zoneIds[2] = 31;
zoneIds[3] = 32;
zoneIds[4] = 33;
zoneIds[5] = 34;
numColumns = 3;
data[0].resize(678, 0.0);
data[1].resize(678, 0.0);
data[2].resize(30, 0.0);
data[3].resize(30, 0.0);
data[4].resize(30, 0.0);
data[5].resize(30, 0.0);
break;
case 8553:
// "Original Wall Velocity"
zoneIds.resize(6);
data.resize(6);
zoneIds[0] = 7;
zoneIds[1] = 28;
zoneIds[2] = 31;
zoneIds[3] = 32;
zoneIds[4] = 33;
zoneIds[5] = 34;
numColumns = 3;
data[0].resize(678, 0.0);
data[1].resize(678, 0.0);
data[2].resize(30, 0.0);
data[3].resize(30, 0.0);
data[4].resize(30, 0.0);
data[5].resize(30, 0.0);
break;
default:;
}
break;
switch (varId) {
case 15:
// "Body Force"
zoneIds.resize(1);
data.resize(1);
zoneIds[0] = 18;
numColumns = 3;
data[0].resize(678, 0.0);
break;
case 101:
// "Density"
zoneIds.resize(1);
data.resize(1);
zoneIds[0] = 18;
numColumns = 1;
data[0].resize(226, 1.225);
break;
case 420:
// "DPM-partition"
zoneIds.resize(1);
data.resize(1);
zoneIds[0] = 18;
numColumns = 1;
data[0].resize(226, 0.0);
break;
case 102:
// "Laminar Viscosity"
zoneIds.resize(1);
data.resize(1);
zoneIds[0] = 18;
numColumns = 1;
data[0].resize(226, 0.000018);
break;
case 1:
// "Pressure"
zoneIds.resize(1);
data.resize(1);
zoneIds[0] = 18;
numColumns = 1;
data[0].resize(226, 0.0);
break;
case 111:
// "X Velocity"
zoneIds.resize(1);
data.resize(1);
zoneIds[0] = 18;
numColumns = 1;
data[0].resize(226, 0.0);
break;
case 112:
// "Y Velocity"
zoneIds.resize(1);
data.resize(1);
zoneIds[0] = 18;
numColumns = 1;
data[0].resize(226, 0.0);
break;
case 113:
// "Z Velocity"
zoneIds.resize(1);
data.resize(1);
zoneIds[0] = 18;
numColumns = 1;
data[0].resize(226, 0.0);
break;
default:;
}
break;
default:;
}
break;
default:
std::cout << "No need to write phase-" << phaseId << "." << std::endl;
break;
}
return 0;
}
void createSetsDataForFace(std::vector<std::vector<ansys::ElemIdType> >& elemIds,
std::vector<ansys::ElemIdType>& minIds,
std::vector<ansys::ElemIdType>& maxIds,
std::vector<ansys::ElemIdType>& minIndices,
std::vector<ansys::ElemIdType>& maxIndices,
std::vector<size_t>& elemNum,
std::vector<std::vector<double> >& doubleData,
size_t& doubleDim,
std::vector< std::vector<char> >& unsingedCharData,
size_t& unsingedCharDim,
std::vector< std::vector<int> >& intData,
std::vector< std::vector<ansys::CountType> >& intDataCounts)
{
elemIds.resize(3);
minIds.clear();
maxIds.clear();
minIndices.clear();
maxIndices.clear();
elemNum.clear();
doubleData.resize(3);
doubleDim = 5;
unsingedCharData.resize(3);
unsingedCharDim = 1;
intData.resize(3);
intDataCounts.resize(3);
//Two face zones are one section
elemIds.at(0).clear();
for (int i = 0; i < 545; i++)
elemIds[0].push_back(i+1);
minIds.push_back(1);
maxIds.push_back(545);
minIndices.push_back(1);
maxIndices.push_back(545);
elemNum.push_back(545);
doubleData.at(0).clear();
unsingedCharData.at(0).clear();
intData.at(0).clear();
intDataCounts.at(0).clear();
for (int i = 0; i < 545; i++)
{
for (int j = 0; j < 5; j++)
doubleData.at(0).push_back(0.1);
unsingedCharData.at(0).push_back('k');
if (i % 3 == 0)
{
intData.at(0).push_back(1);
intData.at(0).push_back(2);
intData.at(0).push_back(3);
intDataCounts.at(0).push_back(3);
}
else if (i % 3 == 1)
{
intData.at(0).push_back(10);
intData.at(0).push_back(20);
intData.at(0).push_back(30);
intData.at(0).push_back(40);
intDataCounts.at(0).push_back(4);
}
else if (i % 3 == 2)
{
intData.at(0).push_back(100);
intData.at(0).push_back(200);
intDataCounts.at(0).push_back(2);
}
}
//One face zone with discontinuous ids can also be one section
elemIds[1].clear();
for (int i = 0; i < 226; i = i + 2)
elemIds[1].push_back(i + 546);
minIds.push_back(546);
maxIds.push_back(546 + 226 - 2);
minIndices.push_back(546);
maxIndices.push_back(546 + 112);
elemNum.push_back(226/2);
doubleData.at(1).clear();
unsingedCharData.at(1).clear();
intData.at(1).clear();
intDataCounts.at(1).clear();
for (int i = 0; i < 226/2; i++)
{
for (int j = 0; j < 5; j++)
doubleData.at(1).push_back(0.1);
unsingedCharData.at(1).push_back('p');
if (i % 3 == 0)
{
intData.at(1).push_back(1);
intData.at(1).push_back(2);
intData.at(1).push_back(3);
intDataCounts.at(1).push_back(3);
}
else if (i % 3 == 1)
{
intData.at(1).push_back(10);
intData.at(1).push_back(20);
intData.at(1).push_back(30);
intData.at(1).push_back(40);
intDataCounts.at(1).push_back(4);
}
else if (i % 3 == 2)
{
intData.at(1).push_back(100);
intData.at(1).push_back(200);
intDataCounts.at(1).push_back(2);
}
}
// Third section
elemIds[2].clear();
for (int i = 0; i < 10; i++)
elemIds[2].push_back(i + 772);
minIds.push_back(772);
maxIds.push_back(781);
minIndices.push_back(546 + 112 + 1);
maxIndices.push_back(546 + 112 + 10);
elemNum.push_back(10);
doubleData.at(2).clear();
unsingedCharData.at(2).clear();
intData.at(2).clear();
intDataCounts.at(2).clear();
for (int i = 0; i < 10; i++){
for (int j = 0; j < 5; j++)
doubleData.at(2).push_back(0.1);
unsingedCharData.at(2).push_back('h');
if (i % 3 == 0)
{
intData.at(2).push_back(1);
intData.at(2).push_back(2);
intData.at(2).push_back(3);
intDataCounts.at(2).push_back(3);
}
else if (i % 3 == 1)
{
intData.at(2).push_back(10);
intData.at(2).push_back(20);
intData.at(2).push_back(30);
intData.at(2).push_back(40);
intDataCounts.at(2).push_back(4);
}
else if (i % 3 == 2)
{
intData.at(2).push_back(100);
intData.at(2).push_back(200);
intDataCounts.at(2).push_back(2);
}
}
}
template <typename Dtype>
void createOtherData(std::string& otherName,
std::vector<Dtype>& otherData,
size_t& numCols,
size_t& numRows)
{
otherName = "TryOther";
numCols = 4;
numRows = 120;
otherData.clear();
for (size_t i = 0; i < numRows*numCols; i++)
{
if (i % 4 == 0){
otherData.push_back(1);
}
else if (i % 4 == 1) {
otherData.push_back(5);
}
else if (i % 4 == 2) {
otherData.push_back(100);
}
else if (i % 4 == 3) {
otherData.push_back(72);
}
}
}
void createStringData(std::string& stringName, std::string& stringData)
{
stringName = "tryString";
stringData = "abcdfhdjghuegsdfgjkdhsdkfgskldghsjkdghd 34435u32iq 10 12 13.65! (xlds) ";
}
#endif /* CASANDDATCREATOR_HPP_ */
CffZoneCategory
An enumeration that is used with ansys::CffBase::getNumZones, ansys::CffBase::getZoneIds,...
Definition: CffTypes.h:195
@ CFF_FACE_ZONE_TYPE_INTERIOR
Definition: CffTypes.h:515
@ CFF_FACE_ZONE_TYPE_MIN
Definition: CffTypes.h:509
@ CFF_FACE_ZONE_TYPE_WALL
Definition: CffTypes.h:519
@ CFF_FACE_TYPE_MIN
Definition: CffTypes.h:581
@ CFF_FACE_TYPE_QUAD
Definition: CffTypes.h:589
@ CFF_FACE_TYPE_TRI
Definition: CffTypes.h:587
@ CFF_CELL_TYPE_MIN
Definition: CffTypes.h:610
@ CFF_CELL_TYPE_WEDGE
Definition: CffTypes.h:624
std::vector< VariableName > VariableNames
Type used to represent a number of variable names ('C++' API only)
Definition: Types.hpp:199
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

Writing Files with Parallel Compression Enabled using C++ API

This example demonstrates how to use the CFF API to export case and results data using parallel compression.

/*
* Copyright ANSYS. All Rights Reserved.
*/
#ifndef PARALLELCASANDDATCREATOR_HPP_
#define PARALLELCASANDDATCREATOR_HPP_
#include "CffInterface/Types.hpp"
#include <iostream>
#include <memory>
#include <vector>
/*
*0 or not defined: each node contains the same data
* 1: each processor contain different data.
*2: offset mesh on different processors
*/
#define PARALLEL_IO_TEST_MODE 2
/*
* For testing special cases
* 1: the last processor will have no data
* 0: turn off this option
* Note: Should only turn this on when PARALLEL_IO_TEST_MODE==2
*/
#define NO_DATA_ON_LAST_PROCESSOR 0
#if PARALLEL_IO_TEST_MODE==1
template <class Dtype>
void allArrayElePlusRank (Dtype *array, int rank, int size)
{
for (int i=0; i<size; i++)
{
array[i] += rank;
}
};
template <class Dtype>
void allArrayElePlusRankOverTen (Dtype *array, int rank, int size)
{
for (int i=0; i<size; i++)
{
array[i] += (rank*0.1);
}
};
template <class Dtype>
void setPartitionIdToRank (Dtype *array, int rank, int size)
{
for (int i=0; i<size; i++)
{
array[i] = rank;
}
};
void createIndex(int rank, int numProc, int rowNum, std::vector<ansys::ElemIdType> &array, int offSet =0, int nonSense=0)
{
int i=0;
for ( i=offSet; i<rowNum+offSet; i++)
{
array.push_back(i*numProc+rank+1);
}
return;
};
#elif PARALLEL_IO_TEST_MODE==0
void createIndex(int rank, int numProc, int rowNum, std::vector<ansys::ElemIdType> &array, int offSet =0, int nonSense=0)
{
int i=0;
int localZoneStart = offSet*numProc + rank*rowNum;
for ( i=localZoneStart; i<localZoneStart + rowNum; i++)
{
array.push_back(i+1);
}
return;
};
#elif PARALLEL_IO_TEST_MODE==2
template <class Dtype>
void allArrayElePlusRankMulTen (Dtype *array, int rank, int size)
{
for (int i=0; i<size; i++)
{
array[i] += (rank*10);
}
}
template <class Dtype>
void allArrayOffset(Dtype *array, int rank, int size, int totalLocalNum)
{
int offSet = totalLocalNum*rank;
for (int i=0; i<size; i++)
{
array[i] += offSet;
}
}
template <class Dtype>
void setPartitionIdToRank (Dtype *array, int rank, int size)
{
for (int i=0; i<size; i++)
{
array[i] = rank;
}
}
void createIndex(int rank, int numProc, int rowNum, std::vector<ansys::ElemIdType> &array, int offSet =0, int totalLocal = 0)
{
int i=0;
#if NO_DATA_ON_LAST_PROCESSOR == 1
int localZoneStart = totalLocal*rank + offSet*(numProc-1);
#else
int localZoneStart = totalLocal*rank + offSet*numProc;
#endif
for ( i=localZoneStart; i<localZoneStart + rowNum; i++)
{
array.push_back(i+1);
}
return;
}
#endif
template <class Type>
void adjust(const int nump, const int rank, std::vector<std::vector<Type> >& data)
{
#if NO_DATA_ON_LAST_PROCESSOR == 1
if (nump-1 == rank)
{
for (int i = 0 ; i < data.size(); i++)
{
data[i].clear();
}
}
#endif
}
int
CreateMeshInfo(size_t& meshDimension,
size_t& nodeCount,
size_t& faceCount,
size_t& cellCount,
const int nump = 1)
{
meshDimension = 3;
nodeCount = 268*nump ;
faceCount = 811*nump ;
cellCount = 226*nump ;
#if NO_DATA_ON_LAST_PROCESSOR == 1
nodeCount = 268*( nump -1) ;
faceCount = 811*( nump -1) ;
cellCount = 226*( nump -1);
#endif
return 0;
}
int
CreateNodeZones(ansys::ZoneIds& zoneIds,
std::vector<short>& dimension,
std::vector<std::string>& names)
{
zoneIds.resize(1);
dimension.resize(1);
names.resize(1);
zoneIds[0] = 1;
dimension[0] = 3;
names[0] = "nodes";
return 0;
}
int
CreateNodeCoords(ansys::ZoneIds& zoneIds,
std::vector<std::vector<double> >& coords,
const int nump = 1,
const int rank=0)
{
zoneIds.resize(1);
coords.resize(1);
zoneIds[0] = 1;
{
double coordArray[804] = {
4, 5, -5, 5, 5, -5,
4.2949, 4.29203, -5, 5, 4, -5,
-5, 5, -5, -4, 5, -5,
-4.28449, 4.29336, -5, -5, 4, -5,
3.36679, 4.01827, -5, 3, 5, -5,
-3.4074, 4.16032, -5, -3, 5, -5,
4.16391, 3.425, -5, 5, 3, -5,
-3.99814, 3.36568, -5, -5, 3, -5,
4.13207, 2.43224, -5, 5, 2, -5,
-4.11523, 2.32634, -5, -5, 2, -5,
2.32413, 4.14427, -5, 2, 5, -5,
-2.4011, 4.12412, -5, -2, 5, -5,
1.33151, 4.17863, -5, 1, 5, -5,
4.15412, 1.43927, -5, 5, 1, -5,
-4.12597, 1.32028, -5, -5, 1, -5,
-1.37779, 4.12701, -5, -1, 5, -5,
-0.361047, 4.17443, -5, 0, 5, -5,
-4.1715, 0.314437, -5, 5, -1, -5,
4.00137, -0.334686, -5, 5, 0, -5,
4.28603, 0.554, -5, 0.489886, 4.33415, -5,
3.27584, 2.89718, -5, 2.56937, 3.33611, -5,
1.6395, 3.29373, -5, 0.485803, 3.42122, -5,
3.23962, 1.84968, -5, 3.36809, 0.72585, -5,
-2.85446, 3.26947, -5, -3.28514, 2.57466, -5,
-3.22381, 1.67259, -5, -3.27848, 0.608651, -5,
-1.79511, 3.22421, -5, -0.692263, 3.29081, -5,
-3.41982, -0.566414, -5, 3.16692, -0.971077, -5,
3.03932, -0.14658, -5, -2.27922, 2.22601, -5,
2.23483, 2.36929, -5, -1.14069, 2.39528, -5,
2.38029, 1.25286, -5, -2.34839, 1.05757, -5,
1.04639, 2.4209, -5, -1.40628, 1.43654, -5,
1.51141, 1.58652, -5, 2.13619, -0.51801, -5,
2.45026, 0.378916, -5, -2.42638, -0.0500925, -5,
-0.0340174, 2.44186, -5, 1.45748, 0.535142, -5,
-0.507031, 1.69288, -5, -1.47973, 0.405438, -5,
0.487921, 1.38142, -5, -0.51817, 0.821268, -5,
0.352882, 0.252772, -5, 5, 5, -4,
4.2949, 4.29203, -4, 4, 5, -4,
5, 4, -4, -4, 5, -4,
-4.28449, 4.29336, -4, -5, 5, -4,
-5, 4, -4, 3.36679, 4.01827, -4,
3, 5, -4, -3.4074, 4.16032, -4,
-3, 5, -4, 4.16391, 3.425, -4,
5, 3, -4, -3.99814, 3.36568, -4,
-5, 3, -4, 4.13207, 2.43224, -4,
5, 2, -4, -4.11523, 2.32634, -4,
-5, 2, -4, 2.32413, 4.14427, -4,
2, 5, -4, -2.4011, 4.12412, -4,
-2, 5, -4, 1.33151, 4.17863, -4,
1, 5, -4, 4.15412, 1.43927, -4,
5, 1, -4, -4.12597, 1.32028, -4,
-5, 1, -4, -1.37779, 4.12701, -4,
-1, 5, -4, -0.361047, 4.17443, -4,
0, 5, -4, -4.1715, 0.314437, -4,
4.00137, -0.334686, -4, 5, -1, -4,
5, 0, -4, 4.28603, 0.554, -4,
0.489886, 4.33415, -4, 3.27584, 2.89718, -4,
2.56937, 3.33611, -4, 1.6395, 3.29373, -4,
0.485803, 3.42122, -4, 3.23962, 1.84968, -4,
3.36809, 0.72585, -4, -2.85446, 3.26947, -4,
-3.28514, 2.57466, -4, -3.22381, 1.67259, -4,
-3.27848, 0.608651, -4, -1.79511, 3.22421, -4,
-0.692263, 3.29081, -4, 3.16692, -0.971077, -4,
-3.41982, -0.566414, -4, 3.03932, -0.14658, -4,
-2.27922, 2.22601, -4, 2.23483, 2.36929, -4,
-1.14069, 2.39528, -4, 2.38029, 1.25286, -4,
-2.34839, 1.05757, -4, 1.04639, 2.4209, -4,
-1.40628, 1.43654, -4, 1.51141, 1.58652, -4,
2.13619, -0.51801, -4, 2.45026, 0.378916, -4,
-2.42638, -0.0500925, -4, -0.0340174, 2.44186, -4,
1.45748, 0.535142, -4, -0.507031, 1.69288, -4,
-1.47973, 0.405438, -4, 0.487921, 1.38142, -4,
-0.51817, 0.821268, -4, 0.352882, 0.252772, -4,
-4, -5, -5, -5, -5, -5,
-4.30102, -4.28573, -5, -5, -4, -5,
5, -4, -5, 5, -5, -5,
4.29688, -4.29686, -5, 4, -5, -5,
-3.38547, -4.00046, -5, -3, -5, -5,
4.1662, -3.4372, -5, 5, -3, -5,
-4.17682, -3.40839, -5, -5, -3, -5,
3.37048, -4.03056, -5, 3, -5, -5,
-2.35127, -4.11775, -5, -2, -5, -5,
4.12722, -2.45332, -5, 5, -2, -5,
-4.15054, -2.39953, -5, -5, -2, -5,
2.32841, -4.14959, -5, 2, -5, -5,
-1.35007, -4.123, -5, -1, -5, -5,
4.09022, -1.43744, -5, -4.17527, -1.38782, -5,
-5, -1, -5, 1.33589, -4.17482, -5,
1, -5, -5, -0.348806, -4.1639, -5,
0, -5, -5, -5, 0, -5,
-4.33211, -0.528578, -5, 0.495674, -4.3258, -5,
3.27911, -2.93579, -5, 2.57619, -3.35689, -5,
1.64848, -3.2995, -5, 0.493433, -3.39937, -5,
3.2283, -1.95621, -5, -3.31463, -2.85404, -5,
-2.62181, -3.29356, -5, -1.73064, -3.2261, -5,
-0.673956, -3.26263, -5, -3.28714, -1.76643, -5,
2.24511, -2.41062, -5, -2.31288, -2.30325, -5,
2.45719, -1.46343, -5, -2.45086, -1.14567, -5,
-1.15733, -2.34335, -5, 1.0706, -2.41316, -5,
-1.60901, -1.56005, -5, 1.5713, -1.4756, -5,
-0.0570161, -2.37276, -5, -1.5263, -0.640689, -5,
-0.612207, -1.33597, -5, 0.522457, -1.48437, -5,
-0.619336, -0.197472, -5, 1.05492, -0.543938, -5,
0.133292, -0.666839, -5, -5, -5, -4,
-4.30102, -4.28573, -4, -4, -5, -4,
-5, -4, -4, 5, -5, -4,
4.29688, -4.29686, -4, 5, -4, -4,
4, -5, -4, -3.38547, -4.00046, -4,
-3, -5, -4, 4.1662, -3.4372, -4,
5, -3, -4, -4.17682, -3.40839, -4,
-5, -3, -4, 3.37048, -4.03056, -4,
3, -5, -4, -2.35127, -4.11775, -4,
-2, -5, -4, 4.12722, -2.45332, -4,
5, -2, -4, -4.15054, -2.39953, -4,
-5, -2, -4, 2.32841, -4.14959, -4,
2, -5, -4, -1.35007, -4.123, -4,
-1, -5, -4, 4.09022, -1.43744, -4,
-4.17527, -1.38782, -4, -5, -1, -4,
1.33589, -4.17482, -4, 1, -5, -4,
-0.348806, -4.1639, -4, 0, -5, -4,
-5, 0, -4, -4.33211, -0.528578, -4,
0.495674, -4.3258, -4, 3.27911, -2.93579, -4,
2.57619, -3.35689, -4, 1.64848, -3.2995, -4,
0.493433, -3.39937, -4, 3.2283, -1.95621, -4,
-3.31463, -2.85404, -4, -2.62181, -3.29356, -4,
-1.73064, -3.2261, -4, -0.673956, -3.26263, -4,
-3.28714, -1.76643, -4, 2.24511, -2.41062, -4,
-2.31288, -2.30325, -4, 2.45719, -1.46343, -4,
-2.45086, -1.14567, -4, -1.15733, -2.34335, -4,
1.0706, -2.41316, -4, -1.60901, -1.56005, -4,
1.5713, -1.4756, -4, -0.0570161, -2.37276, -4,
-1.5263, -0.640689, -4, -0.612207, -1.33597, -4,
0.522457, -1.48437, -4, -0.619336, -0.197472, -4,
1.05492, -0.543938, -4, 0.133292, -0.666839, -4};
#if PARALLEL_IO_TEST_MODE==1
allArrayElePlusRankOverTen <double> (coordArray, rank, 804);
#elif PARALLEL_IO_TEST_MODE==2
allArrayElePlusRankMulTen <double> (coordArray, rank, 804);
#endif
coords[0].assign(coordArray, coordArray + 804);
}
adjust(nump, rank, coords);
return 0;
}
//Only create local index
int
CreateNodeIds(std::vector<std::vector<ansys::ElemIdType> >& indexs,
const int totalProc,
const int rank=0)
{
indexs.resize(1);
indexs[0].clear();
createIndex(rank, totalProc, 268, indexs[0], 0, 268); //804/3 = 268
adjust(totalProc, rank, indexs);
return 0;
}
int
CreateFaceZones(ansys::ZoneIds& zoneIds,
std::vector<short>& dimension,
std::vector<ansys::ZoneIdType>& shadowZoneId,
std::vector<ansys::ZoneIdType>& childZoneId,
std::vector<ansys::FaceZoneType>& zoneType,
std::vector<ansys::FaceType>& elementType,
std::vector<short>& flags,
std::vector<std::string>& name,
std::vector<std::string>& stringZoneType)
{
zoneIds.resize(7, 0);
dimension.resize(7, 0);
shadowZoneId.resize(7, 0);
childZoneId.resize(7, 0);
zoneType.resize(7, CFF_FACE_ZONE_TYPE_MIN);
elementType.resize(7, CFF_FACE_TYPE_MIN);
flags.resize(7, 0);
name.resize(7);
stringZoneType.resize(7);
zoneIds[0] = 7;
dimension[0] = 3;
zoneType[0] = CFF_FACE_ZONE_TYPE_WALL;
elementType[0] = CFF_FACE_TYPE_TRI;
flags[0] = 0;
name[0] = "wall-1";
stringZoneType[0] = "wall";
zoneIds[1] = 20;
dimension[1] = 3;
elementType[1] = CFF_FACE_TYPE_QUAD;
flags[1] = 0;
name[1] = "interior-20";
stringZoneType[1] = "interior";
zoneIds[2] = 28;
dimension[2] = 3;
zoneType[2] = CFF_FACE_ZONE_TYPE_WALL;
elementType[2] = CFF_FACE_TYPE_TRI;
flags[2] = 0;
name[2] = "prism-cap-28";
stringZoneType[2] = "wall";
zoneIds[3] = 31;
dimension[3] = 3;
zoneType[3] = CFF_FACE_ZONE_TYPE_WALL;
elementType[3] = CFF_FACE_TYPE_QUAD;
flags[3] = 0;
name[3] = "wall-3-quad-32";
stringZoneType[3] = "wall";
zoneIds[4] = 32;
dimension[4] = 3;
zoneType[4] = CFF_FACE_ZONE_TYPE_WALL;
elementType[4] = CFF_FACE_TYPE_QUAD;
flags[4] = 0;
name[4] = "wall-4-quad-32";
stringZoneType[4] = "wall";
zoneIds[5] = 33;
dimension[5] = 3;
zoneType[5] = CFF_FACE_ZONE_TYPE_WALL;
elementType[5] = CFF_FACE_TYPE_QUAD;
flags[5] = 0;
name[5] = "wall-5-quad-33";
stringZoneType[5] = "wall";
zoneIds[6] = 34;
dimension[6] = 3;
zoneType[6] = CFF_FACE_ZONE_TYPE_WALL;
elementType[6] = CFF_FACE_TYPE_QUAD;
flags[6] = 0;
name[6] = "wall-6-quad-34";
stringZoneType[6] = "wall";
return 0;
}
int
CreateFaceNodes(ansys::ZoneIds& zoneIds,
std::vector<std::vector<short> >& numNodes,
std::vector<std::vector<ansys::ElemIdType> >& nodes,
const int nump = 1,
const int rank=0)
{
zoneIds.resize(7, 0);
numNodes.resize(7);
nodes.resize(7);
zoneIds[0] = 7;
numNodes[0].resize(226, 3);
{
ansys::ElemIdType nodesArray[678] = {
3, 2, 1, 4, 2, 3, 7, 6, 5, 8, 7, 5, 9, 3,
1, 10, 9, 1, 11, 6, 7, 12, 6, 11, 13, 4, 3, 14,
4, 13, 15, 7, 8, 16, 15, 8, 17, 14, 13, 18, 14, 17,
19, 15, 16, 20, 19, 16, 21, 9, 10, 22, 21, 10, 23, 12,
11, 24, 12, 23, 25, 21, 22, 26, 25, 22, 27, 18, 17, 28,
18, 27, 29, 19, 20, 30, 29, 20, 31, 24, 23, 32, 24, 31,
33, 32, 31, 34, 32, 33, 35, 29, 30, 38, 37, 36, 39, 28,
27, 38, 28, 39, 40, 25, 26, 34, 40, 26, 37, 38, 39, 33,
40, 34, 11, 7, 15, 9, 13, 3, 41, 17, 13, 9, 41, 13,
42, 9, 21, 41, 9, 42, 43, 21, 25, 42, 21, 43, 44, 25,
40, 43, 25, 44, 45, 27, 17, 41, 45, 17, 46, 39, 27, 45,
46, 27, 47, 23, 11, 15, 47, 11, 48, 15, 19, 47, 15, 48,
49, 19, 29, 48, 19, 49, 50, 29, 35, 49, 29, 50, 51, 31,
23, 47, 51, 23, 52, 33, 31, 51, 52, 31, 33, 44, 40, 44,
33, 52, 53, 50, 35, 46, 37, 39, 55, 54, 37, 46, 55, 37,
56, 51, 47, 48, 56, 47, 56, 48, 49, 57, 41, 42, 45, 41,
57, 57, 42, 43, 58, 52, 51, 56, 58, 51, 59, 46, 45, 57,
59, 45, 60, 49, 50, 56, 49, 60, 61, 43, 44, 57, 43, 61,
62, 56, 60, 58, 56, 62, 63, 57, 61, 59, 57, 63, 64, 54,
55, 65, 55, 46, 59, 65, 46, 50, 53, 66, 66, 60, 50, 67,
44, 52, 58, 67, 52, 67, 61, 44, 65, 64, 55, 68, 59, 63,
65, 59, 68, 69, 67, 58, 62, 69, 58, 70, 60, 66, 70, 62,
60, 71, 61, 67, 69, 71, 67, 71, 63, 61, 71, 68, 63, 68,
64, 65, 72, 62, 70, 69, 62, 72, 72, 71, 69, 73, 68, 71,
72, 73, 71, 149, 148, 147, 150, 148, 149, 153, 152, 151, 154, 152,
153, 155, 149, 147, 156, 155, 147, 157, 153, 151, 158, 157, 151, 159,
150, 149, 160, 150, 159, 161, 154, 153, 162, 154, 161, 163, 155, 156,
164, 163, 156, 165, 157, 158, 166, 165, 158, 167, 160, 159, 168, 160,
167, 169, 162, 161, 170, 162, 169, 171, 163, 164, 172, 171, 164, 173,
165, 166, 36, 173, 166, 174, 168, 167, 175, 168, 174, 176, 170, 169,
177, 170, 176, 178, 171, 172, 179, 178, 172, 180, 35, 30, 181, 175,
174, 180, 175, 181, 37, 173, 36, 182, 177, 176, 179, 177, 182, 35,
180, 181, 182, 178, 179, 157, 161, 153, 155, 159, 149, 183, 157, 165,
161, 157, 183, 184, 169, 161, 183, 184, 161, 185, 176, 169, 184, 185,
169, 186, 182, 176, 185, 186, 176, 187, 165, 173, 183, 165, 187, 54,
173, 37, 187, 173, 54, 188, 167, 159, 155, 188, 159, 189, 155, 163,
188, 155, 189, 190, 163, 171, 189, 163, 190, 191, 171, 178, 190, 171,
191, 192, 174, 167, 188, 192, 167, 53, 181, 174, 192, 53, 174, 186,
178, 182, 186, 191, 178, 53, 35, 181, 193, 184, 183, 187, 193, 183,
193, 185, 184, 194, 192, 188, 189, 194, 188, 194, 189, 190, 195, 187,
54, 193, 187, 195, 196, 53, 192, 194, 196, 192, 197, 190, 191, 194,
190, 197, 198, 186, 185, 193, 198, 185, 199, 194, 197, 196, 194, 199,
200, 193, 195, 198, 193, 200, 195, 54, 64, 66, 53, 196, 201, 186,
198, 191, 186, 201, 201, 197, 191, 200, 195, 64, 202, 196, 199, 66,
196, 202, 202, 70, 66, 203, 199, 197, 201, 203, 197, 204, 201, 198,
203, 201, 204, 204, 198, 200, 203, 202, 199, 205, 70, 202, 72, 70,
205, 206, 200, 64, 204, 200, 206, 207, 203, 204, 206, 207, 204, 206,
64, 68, 205, 202, 203, 205, 203, 207, 73, 72, 205, 73, 207, 206,
68, 73, 206, 205, 207, 73};
#if PARALLEL_IO_TEST_MODE==1
allArrayElePlusRank <ansys::ElemIdType> (nodesArray, rank, 678);
#elif PARALLEL_IO_TEST_MODE==2
allArrayOffset<ansys::ElemIdType> (nodesArray, rank, 678, 268);
#endif
nodes[0].assign(nodesArray, nodesArray + 678);
}
zoneIds[1] = 20;
numNodes[1].resize(319, 4);
{
ansys::ElemIdType nodesArray[1276] = {
3, 75, 74, 2, 1, 76, 75, 3, 3, 75, 77, 4, 7, 79,
78, 6, 5, 80, 79, 7, 8, 81, 79, 7, 9, 82, 75, 3,
1, 76, 82, 9, 10, 83, 82, 9, 11, 84, 78, 6, 7, 79,
84, 11, 11, 84, 85, 12, 13, 86, 77, 4, 3, 75, 86, 13,
13, 86, 87, 14, 15, 88, 79, 7, 8, 81, 88, 15, 16, 89,
88, 15, 17, 90, 87, 14, 13, 86, 90, 17, 17, 90, 91, 18,
19, 92, 88, 15, 16, 89, 92, 19, 20, 93, 92, 19, 21, 94,
82, 9, 10, 83, 94, 21, 22, 95, 94, 21, 23, 96, 85, 12,
11, 84, 96, 23, 23, 96, 97, 24, 25, 98, 94, 21, 22, 95,
98, 25, 26, 99, 98, 25, 27, 100, 91, 18, 17, 90, 100, 27,
27, 100, 101, 28, 29, 102, 92, 19, 20, 93, 102, 29, 30, 103,
102, 29, 31, 104, 97, 24, 23, 96, 104, 31, 31, 104, 105, 32,
33, 106, 105, 32, 31, 104, 106, 33, 33, 106, 107, 34, 35, 108,
102, 29, 30, 103, 108, 35, 36, 110, 109, 37, 38, 111, 109, 37,
39, 112, 101, 28, 27, 100, 112, 39, 39, 112, 111, 38, 40, 113,
98, 25, 26, 99, 113, 40, 34, 107, 113, 40, 39, 112, 109, 37,
33, 106, 113, 40, 15, 88, 84, 11, 9, 82, 86, 13, 41, 114,
90, 17, 13, 86, 114, 41, 9, 82, 114, 41, 42, 115, 82, 9,
21, 94, 115, 42, 42, 115, 114, 41, 43, 116, 94, 21, 25, 98,
116, 43, 43, 116, 115, 42, 44, 117, 98, 25, 40, 113, 117, 44,
44, 117, 116, 43, 45, 118, 100, 27, 17, 90, 118, 45, 41, 114,
118, 45, 46, 119, 112, 39, 27, 100, 119, 46, 45, 118, 119, 46,
47, 120, 96, 23, 11, 84, 120, 47, 15, 88, 120, 47, 48, 121,
88, 15, 19, 92, 121, 48, 48, 121, 120, 47, 49, 122, 92, 19,
29, 102, 122, 49, 49, 122, 121, 48, 50, 123, 102, 29, 35, 108,
123, 50, 50, 123, 122, 49, 51, 124, 104, 31, 23, 96, 124, 51,
47, 120, 124, 51, 52, 125, 106, 33, 31, 104, 125, 52, 51, 124,
125, 52, 37, 109, 126, 54, 33, 106, 117, 44, 52, 125, 117, 44,
53, 127, 108, 35, 53, 127, 123, 50, 46, 119, 109, 37, 55, 128,
126, 54, 37, 109, 128, 55, 46, 119, 128, 55, 56, 129, 124, 51,
47, 120, 129, 56, 48, 121, 129, 56, 49, 122, 129, 56, 57, 130,
114, 41, 42, 115, 130, 57, 57, 130, 118, 45, 43, 116, 130, 57,
58, 131, 125, 52, 51, 124, 131, 58, 56, 129, 131, 58, 59, 132,
119, 46, 45, 118, 132, 59, 57, 130, 132, 59, 60, 133, 122, 49,
50, 123, 133, 60, 60, 133, 129, 56, 61, 134, 116, 43, 44, 117,
134, 61, 61, 134, 130, 57, 62, 135, 129, 56, 60, 133, 135, 62,
62, 135, 131, 58, 63, 136, 130, 57, 61, 134, 136, 63, 63, 136,
132, 59, 64, 137, 126, 54, 55, 128, 137, 64, 65, 138, 128, 55,
46, 119, 138, 65, 59, 132, 138, 65, 66, 139, 127, 53, 66, 139,
123, 50, 66, 139, 133, 60, 67, 140, 117, 44, 52, 125, 140, 67,
58, 131, 140, 67, 67, 140, 134, 61, 65, 138, 137, 64, 68, 141,
132, 59, 63, 136, 141, 68, 68, 141, 138, 65, 69, 142, 140, 67,
58, 131, 142, 69, 62, 135, 142, 69, 70, 143, 133, 60, 66, 139,
143, 70, 70, 143, 135, 62, 71, 144, 134, 61, 67, 140, 144, 71,
69, 142, 144, 71, 71, 144, 136, 63, 71, 144, 141, 68, 68, 141,
137, 64, 72, 145, 135, 62, 70, 143, 145, 72, 72, 145, 142, 69,
72, 145, 144, 71, 73, 146, 141, 68, 71, 144, 146, 73, 72, 145,
146, 73, 149, 209, 208, 148, 147, 210, 209, 149, 149, 209, 211, 150,
153, 213, 212, 152, 151, 214, 213, 153, 153, 213, 215, 154, 155, 216,
209, 149, 147, 210, 216, 155, 156, 217, 216, 155, 157, 218, 213, 153,
151, 214, 218, 157, 158, 219, 218, 157, 159, 220, 211, 150, 149, 209,
220, 159, 159, 220, 221, 160, 161, 222, 215, 154, 153, 213, 222, 161,
161, 222, 223, 162, 163, 224, 216, 155, 156, 217, 224, 163, 164, 225,
224, 163, 165, 226, 218, 157, 158, 219, 226, 165, 166, 227, 226, 165,
167, 228, 221, 160, 159, 220, 228, 167, 167, 228, 229, 168, 169, 230,
223, 162, 161, 222, 230, 169, 169, 230, 231, 170, 171, 232, 224, 163,
164, 225, 232, 171, 172, 233, 232, 171, 173, 234, 226, 165, 166, 227,
234, 173, 36, 110, 234, 173, 174, 235, 229, 168, 167, 228, 235, 174,
174, 235, 236, 175, 176, 237, 231, 170, 169, 230, 237, 176, 176, 237,
238, 177, 178, 239, 232, 171, 172, 233, 239, 178, 179, 240, 239, 178,
180, 241, 108, 35, 181, 242, 236, 175, 174, 235, 242, 181, 181, 242,
241, 180, 37, 109, 234, 173, 182, 243, 238, 177, 176, 237, 243, 182,
182, 243, 240, 179, 181, 242, 108, 35, 182, 243, 239, 178, 157, 218,
222, 161, 155, 216, 220, 159, 183, 244, 218, 157, 165, 226, 244, 183,
183, 244, 222, 161, 184, 245, 230, 169, 161, 222, 245, 184, 183, 244,
245, 184, 185, 246, 237, 176, 169, 230, 246, 185, 184, 245, 246, 185,
186, 247, 243, 182, 176, 237, 247, 186, 185, 246, 247, 186, 187, 248,
226, 165, 173, 234, 248, 187, 187, 248, 244, 183, 54, 126, 234, 173,
54, 126, 248, 187, 188, 249, 228, 167, 159, 220, 249, 188, 155, 216,
249, 188, 189, 250, 216, 155, 163, 224, 250, 189, 189, 250, 249, 188,
190, 251, 224, 163, 171, 232, 251, 190, 190, 251, 250, 189, 191, 252,
232, 171, 178, 239, 252, 191, 191, 252, 251, 190, 192, 253, 235, 174,
167, 228, 253, 192, 188, 249, 253, 192, 53, 127, 242, 181, 174, 235,
127, 53, 192, 253, 127, 53, 186, 247, 239, 178, 186, 247, 252, 191,
193, 254, 245, 184, 183, 244, 254, 193, 187, 248, 254, 193, 193, 254,
246, 185, 194, 255, 253, 192, 188, 249, 255, 194, 189, 250, 255, 194,
190, 251, 255, 194, 195, 256, 248, 187, 54, 126, 256, 195, 195, 256,
254, 193, 196, 257, 127, 53, 192, 253, 257, 196, 194, 255, 257, 196,
197, 258, 251, 190, 191, 252, 258, 197, 197, 258, 255, 194, 198, 259,
247, 186, 185, 246, 259, 198, 193, 254, 259, 198, 199, 260, 255, 194,
197, 258, 260, 199, 199, 260, 257, 196, 200, 261, 254, 193, 195, 256,
261, 200, 200, 261, 259, 198, 64, 137, 256, 195, 196, 257, 139, 66,
201, 262, 247, 186, 198, 259, 262, 201, 201, 262, 252, 191, 201, 262,
258, 197, 64, 137, 261, 200, 202, 263, 257, 196, 199, 260, 263, 202,
202, 263, 139, 66, 202, 263, 143, 70, 203, 264, 260, 199, 197, 258,
264, 203, 201, 262, 264, 203, 204, 265, 262, 201, 198, 259, 265, 204,
204, 265, 264, 203, 200, 261, 265, 204, 203, 264, 263, 202, 205, 266,
143, 70, 202, 263, 266, 205, 205, 266, 145, 72, 206, 267, 261, 200,
64, 137, 267, 206, 206, 267, 265, 204, 207, 268, 264, 203, 204, 265,
268, 207, 206, 267, 268, 207, 68, 141, 267, 206, 203, 264, 266, 205,
207, 268, 266, 205, 205, 266, 146, 73, 73, 146, 268, 207, 206, 267,
146, 73};
#if PARALLEL_IO_TEST_MODE==1
allArrayElePlusRank <ansys::ElemIdType> (nodesArray, rank, 1276);
#elif PARALLEL_IO_TEST_MODE==2
allArrayOffset<ansys::ElemIdType> (nodesArray, rank, 1276, 268);
#endif
nodes[1].assign(nodesArray, nodesArray + 1276);
}
zoneIds[2] = 28;
numNodes[2].resize(226, 3);
{
ansys::ElemIdType nodesArray[678] = {
76, 74, 75, 75, 74, 77, 80, 78, 79, 80, 79, 81, 76, 75,
82, 76, 82, 83, 79, 78, 84, 84, 78, 85, 75, 77, 86, 86,
77, 87, 81, 79, 88, 81, 88, 89, 86, 87, 90, 90, 87, 91,
89, 88, 92, 89, 92, 93, 83, 82, 94, 83, 94, 95, 84, 85,
96, 96, 85, 97, 95, 94, 98, 95, 98, 99, 90, 91, 100, 100,
91, 101, 93, 92, 102, 93, 102, 103, 96, 97, 104, 104, 97, 105,
104, 105, 106, 106, 105, 107, 103, 102, 108, 110, 109, 111, 100, 101,
112, 112, 101, 111, 99, 98, 113, 99, 113, 107, 112, 111, 109, 107,
113, 106, 88, 79, 84, 75, 86, 82, 86, 90, 114, 86, 114, 82,
94, 82, 115, 115, 82, 114, 98, 94, 116, 116, 94, 115, 113, 98,
117, 117, 98, 116, 90, 100, 118, 90, 118, 114, 100, 112, 119, 100,
119, 118, 84, 96, 120, 84, 120, 88, 92, 88, 121, 121, 88, 120,
102, 92, 122, 122, 92, 121, 108, 102, 123, 123, 102, 122, 96, 104,
124, 96, 124, 120, 104, 106, 125, 104, 125, 124, 113, 117, 106, 125,
106, 117, 108, 123, 127, 112, 109, 119, 109, 126, 128, 109, 128, 119,
120, 124, 129, 120, 129, 121, 122, 121, 129, 115, 114, 130, 130, 114,
118, 116, 115, 130, 124, 125, 131, 124, 131, 129, 118, 119, 132, 118,
132, 130, 123, 122, 133, 133, 122, 129, 117, 116, 134, 134, 116, 130,
133, 129, 135, 135, 129, 131, 134, 130, 136, 136, 130, 132, 128, 126,
137, 119, 128, 138, 119, 138, 132, 139, 127, 123, 123, 133, 139, 125,
117, 140, 125, 140, 131, 117, 134, 140, 128, 137, 138, 136, 132, 141,
141, 132, 138, 131, 140, 142, 131, 142, 135, 139, 133, 143, 133, 135,
143, 140, 134, 144, 140, 144, 142, 134, 136, 144, 136, 141, 144, 138,
137, 141, 143, 135, 145, 145, 135, 142, 142, 144, 145, 144, 141, 146,
144, 146, 145, 210, 208, 209, 209, 208, 211, 214, 212, 213, 213, 212,
215, 210, 209, 216, 210, 216, 217, 214, 213, 218, 214, 218, 219, 209,
211, 220, 220, 211, 221, 213, 215, 222, 222, 215, 223, 217, 216, 224,
217, 224, 225, 219, 218, 226, 219, 226, 227, 220, 221, 228, 228, 221,
229, 222, 223, 230, 230, 223, 231, 225, 224, 232, 225, 232, 233, 227,
226, 234, 227, 234, 110, 228, 229, 235, 235, 229, 236, 230, 231, 237,
237, 231, 238, 233, 232, 239, 233, 239, 240, 103, 108, 241, 235, 236,
242, 242, 236, 241, 110, 234, 109, 237, 238, 243, 243, 238, 240, 242,
241, 108, 240, 239, 243, 213, 222, 218, 209, 220, 216, 226, 218, 244,
244, 218, 222, 222, 230, 245, 222, 245, 244, 230, 237, 246, 230, 246,
245, 237, 243, 247, 237, 247, 246, 234, 226, 248, 248, 226, 244, 109,
234, 126, 126, 234, 248, 220, 228, 249, 220, 249, 216, 224, 216, 250,
250, 216, 249, 232, 224, 251, 251, 224, 250, 239, 232, 252, 252, 232,
251, 228, 235, 253, 228, 253, 249, 235, 242, 127, 235, 127, 253, 243,
239, 247, 239, 252, 247, 242, 108, 127, 244, 245, 254, 244, 254, 248,
245, 246, 254, 249, 253, 255, 249, 255, 250, 251, 250, 255, 126, 248,
256, 256, 248, 254, 253, 127, 257, 253, 257, 255, 252, 251, 258, 258,
251, 255, 246, 247, 259, 246, 259, 254, 258, 255, 260, 260, 255, 257,
256, 254, 261, 261, 254, 259, 137, 126, 256, 257, 127, 139, 259, 247,
262, 262, 247, 252, 252, 258, 262, 137, 256, 261, 260, 257, 263, 263,
257, 139, 139, 143, 263, 258, 260, 264, 258, 264, 262, 259, 262, 265,
265, 262, 264, 261, 259, 265, 260, 263, 264, 263, 143, 266, 266, 143,
145, 137, 261, 267, 267, 261, 265, 265, 264, 268, 265, 268, 267, 141,
137, 267, 264, 263, 266, 268, 264, 266, 266, 145, 146, 267, 268, 146,
267, 146, 141, 146, 268, 266};
#if PARALLEL_IO_TEST_MODE==1
allArrayElePlusRank <ansys::ElemIdType> (nodesArray, rank, 678);
#elif PARALLEL_IO_TEST_MODE==2
allArrayOffset<ansys::ElemIdType> (nodesArray, rank, 678, 268);
#endif
nodes[2].assign(nodesArray, nodesArray + 678);
}
zoneIds[3] = 31;
numNodes[3].resize(10, 4);
{
ansys::ElemIdType nodesArray[40] = {2, 74, 76, 1, 6, 78, 80, 5, 1, 76,
83, 10, 12, 85, 78, 6, 10, 83, 95, 22,
24, 97, 85, 12, 22, 95, 99, 26, 32, 105,
97, 24, 34, 107, 105, 32, 26, 99, 107, 34};
#if PARALLEL_IO_TEST_MODE==1
allArrayElePlusRank <ansys::ElemIdType> (nodesArray, rank, 40);
#elif PARALLEL_IO_TEST_MODE==2
allArrayOffset<ansys::ElemIdType> (nodesArray, rank, 40, 268);
#endif
nodes[3].assign(nodesArray, nodesArray + 40);
}
zoneIds[4] = 32;
numNodes[4].resize(10, 4);
{
ansys::ElemIdType nodesArray[40] = {4, 77, 74, 2, 14, 87, 77, 4, 18, 91,
87, 14, 28, 101, 91, 18, 36, 110, 111, 38,
38, 111, 101, 28, 152, 212, 214, 151, 151, 214,
219, 158, 158, 219, 227, 166, 166, 227, 110, 36};
#if PARALLEL_IO_TEST_MODE==1
allArrayElePlusRank <ansys::ElemIdType> (nodesArray, rank, 40);
#elif PARALLEL_IO_TEST_MODE==2
allArrayOffset<ansys::ElemIdType> (nodesArray, rank, 40, 268);
#endif
nodes[4].assign(nodesArray, nodesArray + 40);
}
zoneIds[5] = 33;
numNodes[5].resize(10, 4);
{
ansys::ElemIdType nodesArray[40] = {5, 80, 81, 8, 8, 81, 89, 16, 16, 89,
93, 20, 20, 93, 103, 30, 150, 211, 208, 148,
160, 221, 211, 150, 168, 229, 221, 160, 175, 236,
229, 168, 30, 103, 241, 180, 180, 241, 236, 175};
#if PARALLEL_IO_TEST_MODE==1
allArrayElePlusRank <ansys::ElemIdType> (nodesArray, rank, 40);
#elif PARALLEL_IO_TEST_MODE==2
allArrayOffset<ansys::ElemIdType> (nodesArray, rank, 40, 268);
#endif
nodes[5].assign(nodesArray, nodesArray + 40);
}
zoneIds[6] = 34;
numNodes[6].resize(10, 4);
{
ansys::ElemIdType nodesArray[40] = {148, 208, 210, 147, 154, 215, 212, 152, 147, 210,
217, 156, 162, 223, 215, 154, 156, 217, 225, 164,
170, 231, 223, 162, 164, 225, 233, 172, 177, 238,
231, 170, 172, 233, 240, 179, 179, 240, 238, 177};
#if PARALLEL_IO_TEST_MODE==1
allArrayElePlusRank <ansys::ElemIdType> (nodesArray, rank, 40);
#elif PARALLEL_IO_TEST_MODE==2
allArrayOffset<ansys::ElemIdType> (nodesArray, rank, 40, 268);
#endif
nodes[6].assign(nodesArray, nodesArray + 40);
}
adjust(nump, rank, nodes);
adjust(nump, rank, numNodes);
return 0;
}
int
CreateFaceElemId(ansys::ZoneIds& zoneIds,
std::vector<std::vector<ansys::ElemIdType> >& indexs,
const int totalProc,
const int rank=0)
{
zoneIds.resize(7, 0);
zoneIds[0] = 7;
zoneIds[1] = 20;
zoneIds[2] = 28;
zoneIds[3] = 31;
zoneIds[4] = 32;
zoneIds[5] = 33;
zoneIds[6] = 34;
indexs.resize(7);
int offSet=0;
indexs[0].clear();
createIndex(rank, totalProc, 226, indexs[0], offSet, 226);
offSet += 226;
indexs[1].clear();
createIndex(rank, totalProc, 319, indexs[1], offSet, 319);
offSet += 319;
indexs[2].clear();
createIndex(rank, totalProc, 226, indexs[2], offSet, 226);
offSet += 226;
indexs[3].clear();
createIndex(rank, totalProc, 10, indexs[3], offSet, 10);
offSet += 10;
indexs[4].clear();
createIndex(rank, totalProc, 10, indexs[4], offSet, 10);
offSet += 10;
indexs[5].clear();
createIndex(rank, totalProc, 10, indexs[5], offSet, 10);
offSet += 10;
indexs[6].clear();
createIndex(rank, totalProc, 10, indexs[6], offSet, 10);
offSet += 10;
adjust(totalProc, rank, indexs);
return 0;
}
int
CreateFaceC0s(ansys::ZoneIds& zoneIds,
std::vector<std::vector<ansys::ElemIdType> >& faceC0s,
const int totalProc = 1,
const int rank = 0)
{
zoneIds.resize(7, 0);
faceC0s.resize(7);
zoneIds[0] = 7;
{
ansys::ElemIdType c0Array[226] = {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140,
141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168,
169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196,
197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210,
211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
225, 226};
#if PARALLEL_IO_TEST_MODE==1
allArrayElePlusRank <ansys::ElemIdType> (c0Array, rank, 226);
#elif PARALLEL_IO_TEST_MODE==2
allArrayOffset<ansys::ElemIdType> (c0Array, rank, 226, 226);
#endif
faceC0s[0].assign(c0Array, c0Array + 226);
}
zoneIds[1] = 20;
{
ansys::ElemIdType c0Array[319] = {
1, 1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9, 9,
10, 11, 11, 12, 13, 13, 14, 15, 15, 16, 17, 17, 18, 19,
19, 20, 21, 21, 22, 23, 23, 24, 25, 25, 26, 27, 27, 28,
29, 29, 30, 31, 31, 147, 32, 33, 33, 34, 35, 35, 36, 37,
38, 39, 40, 41, 41, 42, 43, 43, 44, 45, 45, 46, 47, 47,
48, 49, 49, 50, 51, 51, 52, 53, 53, 54, 55, 55, 56, 57,
57, 58, 59, 59, 60, 61, 61, 62, 63, 63, 64, 164, 65, 66,
180, 67, 68, 69, 69, 70, 71, 71, 72, 73, 74, 74, 75, 76,
77, 77, 78, 79, 79, 80, 81, 81, 82, 83, 83, 84, 85, 85,
86, 87, 87, 88, 89, 89, 90, 90, 91, 200, 92, 93, 94, 94,
95, 96, 97, 98, 98, 99, 100, 100, 101, 102, 102, 103, 104, 104,
105, 106, 107, 108, 109, 109, 110, 111, 112, 112, 113, 114, 114, 115,
116, 116, 117, 118, 118, 119, 120, 120, 121, 122, 122, 123, 124, 124,
125, 126, 126, 127, 128, 128, 129, 130, 130, 131, 132, 132, 133, 134,
134, 135, 136, 136, 137, 138, 138, 139, 140, 140, 141, 142, 142, 143,
144, 145, 145, 146, 147, 148, 148, 149, 150, 151, 152, 153, 154, 154,
155, 156, 156, 157, 158, 158, 159, 160, 160, 161, 162, 162, 163, 164,
165, 166, 166, 167, 168, 168, 169, 170, 170, 171, 172, 172, 173, 174,
174, 175, 176, 176, 177, 178, 179, 181, 181, 182, 183, 184, 184, 185,
186, 187, 187, 188, 189, 189, 190, 191, 191, 192, 193, 193, 194, 195,
195, 196, 197, 197, 198, 199, 200, 201, 201, 202, 203, 204, 205, 205,
206, 207, 208, 208, 209, 210, 210, 211, 212, 213, 214, 214, 215, 216,
216, 217, 218, 218, 219, 220, 221, 222, 223, 224, 224};
#if PARALLEL_IO_TEST_MODE==1
allArrayElePlusRank <ansys::ElemIdType> (c0Array, rank, 319);
#elif PARALLEL_IO_TEST_MODE==2
allArrayOffset<ansys::ElemIdType> (c0Array, rank, 319, 226);
#endif
faceC0s[1].assign(c0Array, c0Array + 319);
}
zoneIds[2] = 28;
{
ansys::ElemIdType c0Array[226] = {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140,
141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168,
169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196,
197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210,
211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
225, 226};
#if PARALLEL_IO_TEST_MODE==1
allArrayElePlusRank <ansys::ElemIdType> (c0Array, rank, 226);
#elif PARALLEL_IO_TEST_MODE==2
allArrayOffset<ansys::ElemIdType> (c0Array, rank, 226, 226);
#endif
faceC0s[2].assign(c0Array, c0Array + 226);
}
zoneIds[3] = 31;
{
ansys::ElemIdType c0Array[10] = {1, 3, 6, 8, 18, 20, 22, 28, 30, 36};
#if PARALLEL_IO_TEST_MODE==1
allArrayElePlusRank <ansys::ElemIdType> (c0Array, rank, 10);
#elif PARALLEL_IO_TEST_MODE==2
allArrayOffset<ansys::ElemIdType> (c0Array, rank, 10, 226);
#endif
faceC0s[3].assign(c0Array, c0Array + 10);
}
zoneIds[4] = 32;
{
ansys::ElemIdType c0Array[10] = {2, 10, 14, 24, 32, 34, 116, 121, 129, 137};
#if PARALLEL_IO_TEST_MODE==1
allArrayElePlusRank <ansys::ElemIdType> (c0Array, rank, 10);
#elif PARALLEL_IO_TEST_MODE==2
allArrayOffset<ansys::ElemIdType> (c0Array, rank, 10, 226);
#endif
faceC0s[4].assign(c0Array, c0Array + 10);
}
zoneIds[5] = 33;
{
ansys::ElemIdType c0Array[10] = {4, 12, 16, 26, 115, 123, 131, 139, 144, 146};
#if PARALLEL_IO_TEST_MODE==1
allArrayElePlusRank <ansys::ElemIdType> (c0Array, rank, 10);
#elif PARALLEL_IO_TEST_MODE==2
allArrayOffset<ansys::ElemIdType> (c0Array, rank, 10, 226);
#endif
faceC0s[5].assign(c0Array, c0Array + 10);
}
zoneIds[6] = 34;
{
ansys::ElemIdType c0Array[10] = {114, 117, 119, 125, 127, 133, 135, 141, 143, 149};
#if PARALLEL_IO_TEST_MODE==1
allArrayElePlusRank <ansys::ElemIdType> (c0Array, rank, 10);
#elif PARALLEL_IO_TEST_MODE==2
allArrayOffset<ansys::ElemIdType> (c0Array, rank, 10, 226);
#endif
faceC0s[6].assign(c0Array, c0Array + 10);
}
adjust(totalProc, rank, faceC0s);
return 0;
}
int
CreateFaceC1s(ansys::ZoneIds& zoneIds,
std::vector<std::vector<ansys::ElemIdType> >& faceC1s,
const int totalProc =1,
const int rank=0)
{
zoneIds.resize(1, 0);
faceC1s.resize(1);
zoneIds[0] = 20;
{
ansys::ElemIdType c1Array[319] = {
2, 5, 9, 7, 4, 11, 40, 6, 17, 8, 39, 19, 10, 40,
13, 39, 12, 15, 14, 41, 23, 55, 16, 25, 43, 18, 21, 20,
53, 27, 45, 22, 35, 24, 49, 33, 57, 26, 31, 28, 61, 29,
30, 63, 38, 59, 144, 32, 37, 34, 51, 37, 47, 36, 38, 68,
65, 54, 42, 50, 42, 44, 44, 46, 74, 46, 48, 76, 48, 65,
83, 52, 50, 75, 68, 52, 79, 62, 54, 56, 56, 58, 72, 58,
60, 73, 60, 67, 81, 64, 62, 71, 66, 64, 77, 69, 66, 94,
67, 92, 70, 89, 70, 90, 78, 72, 73, 82, 75, 76, 80, 84,
95, 78, 86, 91, 80, 88, 82, 93, 85, 84, 96, 87, 86, 103,
101, 88, 106, 98, 199, 97, 97, 91, 99, 92, 93, 102, 96, 95,
100, 104, 108, 99, 107, 108, 105, 101, 110, 103, 207, 109, 106, 105,
111, 107, 112, 220, 110, 215, 111, 113, 225, 113, 223, 115, 118, 122,
117, 120, 124, 153, 119, 126, 152, 121, 128, 123, 153, 130, 125, 152,
132, 168, 127, 134, 154, 129, 136, 131, 166, 138, 133, 156, 140, 170,
135, 142, 162, 137, 147, 139, 174, 145, 141, 158, 148, 172, 143, 151,
150, 146, 176, 150, 164, 149, 160, 151, 180, 178, 155, 167, 155, 163,
157, 159, 157, 181, 161, 159, 183, 178, 161, 193, 163, 165, 182, 165,
187, 175, 167, 169, 169, 171, 185, 171, 173, 186, 173, 179, 191, 177,
175, 184, 180, 177, 189, 179, 202, 183, 182, 188, 194, 190, 185, 186,
192, 188, 199, 197, 200, 190, 196, 192, 203, 195, 201, 194, 198, 196,
208, 205, 198, 204, 212, 204, 206, 202, 210, 203, 209, 216, 206, 213,
207, 214, 213, 209, 211, 211, 212, 218, 217, 221, 215, 221, 223, 217,
220, 219, 222, 219, 224, 225, 222, 226, 226, 226, 225};
#if PARALLEL_IO_TEST_MODE==1
allArrayElePlusRank <ansys::ElemIdType> (c1Array, rank, 319);
#elif PARALLEL_IO_TEST_MODE==2
allArrayOffset<ansys::ElemIdType> (c1Array, rank, 319, 226);
#endif
faceC1s[0].assign(c1Array, c1Array + 319);
}
adjust(totalProc, rank, faceC1s);
return 0;
}
int
CreateCellZones(ansys::ZoneIds& zoneIds,
std::vector<short>& dimension,
std::vector<ansys::ZoneIdType>& childZoneId,
std::vector<ansys::CellType>& elementType,
std::vector<std::string>& name,
std::vector<std::string>& stringZoneType)
{
zoneIds.resize(1, 0);
dimension.resize(1, 0);
childZoneId.resize(1, 0);
elementType.resize(1, CFF_CELL_TYPE_MIN);
name.resize(1);
stringZoneType.resize(1);
zoneIds[0] = 18;
dimension[0] = 3;
elementType[0] = CFF_CELL_TYPE_WEDGE;
name[0] = "prism-cells-18";
stringZoneType[0] = "fluid";
return 0;
}
int
CreateCellTypes(ansys::ZoneIds& zoneIds,
std::vector<ansys::CellType>& zoneCellTypes,
std::vector<std::vector<ansys::CellType> >& allCellTypes)
{
zoneIds.resize(1, 0);
zoneCellTypes.resize(1, CFF_CELL_TYPE_MIXED);
allCellTypes.resize(1);
zoneIds[0] = 18;
zoneCellTypes[0] = CFF_CELL_TYPE_WEDGE;
allCellTypes[0].clear();
return 0;
}
int
CreateCellPartitions(ansys::ZoneIds& zoneIds,
std::vector<std::vector<ansys::PartitionIdType> >& cellPartitions,
const int totalProc = 1,
const int rank=0)
{
zoneIds.resize(1, 0);
cellPartitions.resize(1);
zoneIds[0] = 18;
{
ansys::PartitionIdType cellPartitionsArray[226] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
#if PARALLEL_IO_TEST_MODE==1 || PARALLEL_IO_TEST_MODE==2
setPartitionIdToRank <int> (cellPartitionsArray, rank, 226);
#endif
cellPartitions[0].assign(cellPartitionsArray, cellPartitionsArray + 226);
}
adjust(totalProc, rank, cellPartitions);
return 0;
}
int
CreateCellElemIds(ansys::ZoneIds& zoneIds,
std::vector<std::vector<ansys::ElemIdType> >& indexs,
const int totalProc,
const int rank=0)
{
zoneIds.resize(1, 0);
indexs.resize(1);
zoneIds[0] = 18;
indexs[0].clear();
createIndex(rank, totalProc, 226, indexs[0], 0, 226);
adjust(totalProc, rank, indexs);
return 0;
}
int
CreatePhases(ansys::PhaseNames& phaseNames)
{
phaseNames.resize(1, "phase-1");
return 0;
}
int
CreateVarNames(const ansys::ZoneCategory zoneCategory,
std::vector<std::string>& vars,
std::vector<int>& xfIds)
{
switch (zoneCategory) {
vars.resize(11);
xfIds.resize(11);
vars[0] = "SV_DT_BC_SOURCE";
vars[1] = "SV_FLUX";
vars[2] = "SV_HEAT_FLUX";
vars[3] = "SV_P";
vars[4] = "SV_RAD_HEAT_FLUX";
vars[5] = "SV_U";
vars[6] = "SV_V";
vars[7] = "SV_W";
vars[8] = "SV_WALL_SHEAR";
vars[9] = "SV_WALL_V";
vars[10] = "SV_WALL_VV";
xfIds[0] = 1328;
xfIds[1] = 18;
xfIds[2] = 20;
xfIds[3] = 1;
xfIds[4] = 21;
xfIds[5] = 111;
xfIds[6] = 112;
xfIds[7] = 113;
xfIds[8] = 19;
xfIds[9] = 114;
xfIds[10] = 8553;
break;
vars.resize(8);
xfIds.resize(8);
vars[0] = "SV_BF_V";
vars[1] = "SV_DENSITY";
vars[2] = "SV_DPM_PARTITION";
vars[3] = "SV_MU_LAM";
vars[4] = "SV_P";
vars[5] = "SV_U";
vars[6] = "SV_V";
vars[7] = "SV_W";
xfIds[0] = 15;
xfIds[1] = 101;
xfIds[2] = 420;
xfIds[3] = 102;
xfIds[4] = 1;
xfIds[5] = 111;
xfIds[6] = 112;
xfIds[7] = 113;
break;
default:;
}
return 0;
}
int
CreateVarsForThisCategory(const ansys::ZoneCategory zoneCategory,
const int var,
ansys::ZoneIds& zoneIds,
size_t& numColumns,
std::vector<std::vector<double> >& data,
const int nump = 1,
const int rank = 0)
{
switch (zoneCategory) {
switch (var) {
case 1328:
// "2nd Grad Bc Source"
zoneIds.resize(6);
data.resize(6);
zoneIds[0] = 7;
zoneIds[1] = 28;
zoneIds[2] = 31;
zoneIds[3] = 32;
zoneIds[4] = 33;
zoneIds[5] = 34;
numColumns = 1;
data[0].resize(226, 0.1);
data[1].resize(226, 0.2);
data[2].resize(10, 0.3);
data[3].resize(10, 0.4);
data[4].resize(10, 0.5);
data[5].resize(10, 0.6);
adjust(nump, rank, data);
break;
case 18:
// "Mass Flux"
zoneIds.resize(7);
data.resize(7);
zoneIds[0] = 7;
zoneIds[1] = 20;
zoneIds[2] = 28;
zoneIds[3] = 31;
zoneIds[4] = 32;
zoneIds[5] = 33;
zoneIds[6] = 34;
numColumns = 1;
data[0].resize(226, 0.1);
data[1].resize(319, 0.2);
data[2].resize(226, 0.3);
data[3].resize(10, 0.4);
data[4].resize(10, 0.5);
data[5].resize(10, 0.6);
data[6].resize(10, 0.7);
adjust(nump, rank, data);
break;
case 20:
// "Boundary heat flux":
zoneIds.resize(6);
data.resize(6);
zoneIds[0] = 7;
zoneIds[1] = 28;
zoneIds[2] = 31;
zoneIds[3] = 32;
zoneIds[4] = 33;
zoneIds[5] = 34;
numColumns = 1;
data[0].resize(226, 0.1);
data[1].resize(226, 0.2);
data[2].resize(10, 0.3);
data[3].resize(10, 0.4);
data[4].resize(10, 0.5);
data[5].resize(10, 0.6);
adjust(nump, rank, data);
break;
case 1:
// "Pressure"
zoneIds.resize(7);
data.resize(7);
zoneIds[0] = 7;
zoneIds[1] = 20;
zoneIds[2] = 28;
zoneIds[3] = 31;
zoneIds[4] = 32;
zoneIds[5] = 33;
zoneIds[6] = 34;
numColumns = 1;
data[0].resize(226, 0.1);
data[1].resize(319, 0.2);
data[2].resize(226, 0.3);
data[3].resize(10, 0.4);
data[4].resize(10, 0.5);
data[5].resize(10, 0.6);
data[6].resize(10, 0.7);
adjust(nump, rank, data);
break;
case 21:
// "Boundary rad heat flux"
zoneIds.resize(6);
data.resize(6);
zoneIds[0] = 7;
zoneIds[1] = 28;
zoneIds[2] = 31;
zoneIds[3] = 32;
zoneIds[4] = 33;
zoneIds[5] = 34;
numColumns = 1;
data[0].resize(226, 0.1);
data[1].resize(226, 0.2);
data[2].resize(10, 0.3);
data[3].resize(10, 0.4);
data[4].resize(10, 0.5);
data[5].resize(10, 0.6);
adjust(nump, rank, data);
break;
case 111:
// "X Velocity"
zoneIds.resize(6);
data.resize(6);
zoneIds[0] = 7;
zoneIds[1] = 28;
zoneIds[2] = 31;
zoneIds[3] = 32;
zoneIds[4] = 33;
zoneIds[5] = 34;
numColumns = 1;
data[0].resize(226, 0.1);
data[1].resize(226, 0.2);
data[2].resize(10, 0.3);
data[3].resize(10, 0.4);
data[4].resize(10, 0.5);
data[5].resize(10, 0.6);
adjust(nump, rank, data);
break;
case 112:
// "Y Velocity"
zoneIds.resize(6);
data.resize(6);
zoneIds[0] = 7;
zoneIds[1] = 28;
zoneIds[2] = 31;
zoneIds[3] = 32;
zoneIds[4] = 33;
zoneIds[5] = 34;
numColumns = 1;
data[0].resize(226, 0.1);
data[1].resize(226, 0.2);
data[2].resize(10, 0.3);
data[3].resize(10, 0.4);
data[4].resize(10, 0.5);
data[5].resize(10, 0.6);
adjust(nump, rank, data);
break;
case 113:
// "Z Velocity"
zoneIds.resize(6);
data.resize(6);
zoneIds[0] = 7;
zoneIds[1] = 28;
zoneIds[2] = 31;
zoneIds[3] = 32;
zoneIds[4] = 33;
zoneIds[5] = 34;
numColumns = 1;
data[0].resize(226, 0.1);
data[1].resize(226, 0.2);
data[2].resize(10, 0.3);
data[3].resize(10, 0.4);
data[4].resize(10, 0.5);
data[5].resize(10, 0.6);
adjust(nump, rank, data);
break;
case 19:
// "Wall shear"
zoneIds.resize(6);
data.resize(6);
zoneIds[0] = 7;
zoneIds[1] = 28;
zoneIds[2] = 31;
zoneIds[3] = 32;
zoneIds[4] = 33;
zoneIds[5] = 34;
numColumns = 3;
data[0].resize(678, 0.1);
data[1].resize(678, 0.2);
data[2].resize(30, 0.3);
data[3].resize(30, 0.4);
data[4].resize(30, 0.5);
data[5].resize(30, 0.6);
adjust(nump, rank, data);
break;
case 114:
// "Wall Velocity"
zoneIds.resize(6);
data.resize(6);
zoneIds[0] = 7;
zoneIds[1] = 28;
zoneIds[2] = 31;
zoneIds[3] = 32;
zoneIds[4] = 33;
zoneIds[5] = 34;
numColumns = 3;
data[0].resize(678, 0.1);
data[1].resize(678, 0.2);
data[2].resize(30, 0.3);
data[3].resize(30, 0.4);
data[4].resize(30, 0.5);
data[5].resize(30, 0.6);
adjust(nump, rank, data);
break;
case 8553:
// "Original Wall Velocity"
zoneIds.resize(6);
data.resize(6);
zoneIds[0] = 7;
zoneIds[1] = 28;
zoneIds[2] = 31;
zoneIds[3] = 32;
zoneIds[4] = 33;
zoneIds[5] = 34;
numColumns = 3;
data[0].resize(678, 0.1);
data[1].resize(678, 0.2);
data[2].resize(30, 0.3);
data[3].resize(30, 0.4);
data[4].resize(30, 0.5);
data[5].resize(30, 0.6);
adjust(nump, rank, data);
break;
default:;
}
break;
switch (var) {
case 15:
// "Body Force"
zoneIds.resize(1);
data.resize(1);
zoneIds[0] = 18;
numColumns = 3;
data[0].resize(678, 0.0);
adjust(nump, rank, data);
break;
case 101:
// "Density"
zoneIds.resize(1);
data.resize(1);
zoneIds[0] = 18;
numColumns = 1;
data[0].resize(226, 1.225);
adjust(nump, rank, data);
break;
case 420:
// "DPM-partition"
zoneIds.resize(1);
data.resize(1);
zoneIds[0] = 18;
numColumns = 1;
data[0].resize(226, 0.1);
adjust(nump, rank, data);
break;
case 102:
// "Laminar Viscosity"
zoneIds.resize(1);
data.resize(1);
zoneIds[0] = 18;
numColumns = 1;
data[0].resize(226, 0.000018);
adjust(nump, rank, data);
break;
case 1:
// "Pressure"
zoneIds.resize(1);
data.resize(1);
zoneIds[0] = 18;
numColumns = 1;
data[0].resize(226, 0.1);
adjust(nump, rank, data);
break;
case 111:
// "X Velocity"
zoneIds.resize(1);
data.resize(1);
zoneIds[0] = 18;
numColumns = 1;
data[0].resize(226, 0.1);
adjust(nump, rank, data);
break;
case 112:
// "Y Velocity"
zoneIds.resize(1);
data.resize(1);
zoneIds[0] = 18;
numColumns = 1;
data[0].resize(226, 0.1);
adjust(nump, rank, data);
break;
case 113:
// "Z Velocity"
zoneIds.resize(1);
data.resize(1);
zoneIds[0] = 18;
numColumns = 1;
data[0].resize(226, 0.1);
adjust(nump, rank, data);
break;
default:;
}
break;
default:;
}
return 0;
}
#endif /* PARALLELCASANDDATCREATOR_HPP_ */

Reading Settings using C++ API

This example demonstrates how to use the CFF API to read settings from a cas.h5 file.

/*
* Copyright ANSYS. All Rights Reserved.
*/
#include "CffInterface/printVersion.hpp"
#include "Factory/providers.hpp"
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
#include "../Common/Output.hpp"
#include "../Common/Utilities.hpp"
namespace
{
const std::string c_fluent = "ANSYS_FLUENT";
}
void
displayFluentMeshSettings(const ansys::CffProvider& reader)
{
std::cout << "The following non standard settings are also available:"
<< std::endl;
// ----------------------------------- face zones
std::string key = "faceZones";
// get the face zones as one string comma separated
std::string value = reader.getSettings(dataClass, key);
PRINT_VALUE(key, value);
// get the face zones as a string vector
std::vector<std::string> values = reader.getSettings(dataClass, key);
PRINT_VECTOR_WITH_NEW_LINE(key, values);
ansys::CffVariant var;
key += "/";
if (!values.empty()) {
key += values[0];
var = reader.getSettings(dataClass, key);
// cells zones of the first face zone
values = var.cellZones();
PRINT_VECTOR_WITH_NEW_LINE(key + " cellZones", values);
// face zones of the first face zone
values = var.faceZones();
PRINT_VECTOR_WITH_NEW_LINE(key + " faceZones", values);
// node zones of the first face zone
values = var.nodeZones();
PRINT_VECTOR_WITH_NEW_LINE(key + " nodeZones", values);
// get the face zones as one string comma separated for phase 2, empty here
key = "faceZones";
value = reader.getSettings(dataClass, key, 2);
PRINT_VALUE(key + " for phase 2", value);
// ----------------------------------- cell zones
key = "cellZones";
// get the cell zones as one string comma separated
value = reader.getSettings(dataClass,key);
PRINT_VALUE(key, value);
// get the cell zones as a string vector
values = reader.getSettings(dataClass,key);
PRINT_VECTOR_WITH_NEW_LINE(key, values);
// for a cell zone, to find the bounding zones
key += "/";
if (!values.empty()) {
key += values[0];
var = reader.getSettings(dataClass,key);
values = var.bounds();
PRINT_VECTOR_WITH_NEW_LINE(key + " bounds", values);
// for a cell zone, to find the cell zones
values = var.cellZones();
PRINT_VECTOR_WITH_NEW_LINE(key + " cellZones", values);
// for a cell zone, to find the face zones
values = var.faceZones();
PRINT_VECTOR_WITH_NEW_LINE(key + " faceZones", values);
// for a cell zone, to find the node zones
values = var.nodeZones();
PRINT_VECTOR_WITH_NEW_LINE(key + " nodeZones", values);
// get cell zone material
std::string material = key + "/material";
value = reader.getSettings(dataClass,material);
PRINT_VALUE(material, value);
// get cell zone ID
std::string id = key + "/id";
value = reader.getSettings(dataClass, id);
PRINT_VALUE(id, value);
//To get rotational speed, will be zero if domain is not rotating
key = key + "/velocity/angular";
std::string rot = key + "/magnitude";
value = reader.getSettings(dataClass, rot);
PRINT_VALUE(rot, value);
//To get rotational axis origin
key = key + "/axis";
std::string axs = key + "/origin/x";
value = reader.getSettings(dataClass, axs);
PRINT_VALUE(axs, value);
axs = key + "/origin/y";
value = reader.getSettings(dataClass, axs);
PRINT_VALUE(axs, value);
axs = key + "/origin/z";
value = reader.getSettings(dataClass, axs);
PRINT_VALUE(axs, value);
//To get rotational axis direction
axs = key + "/direction/x";
value = reader.getSettings(dataClass, axs);
PRINT_VALUE(axs, value);
axs = key + "/direction/y";
value = reader.getSettings(dataClass, axs);
PRINT_VALUE(axs, value);
axs = key + "/direction/z";
value = reader.getSettings(dataClass, axs);
PRINT_VALUE(axs, value);
}
// ----------------------------------- node zones
key = "nodeZones";
// get the node zones as one string comma separated
value = reader.getSettings(dataClass, key);
PRINT_VALUE(key, value);
// get the node zones as a string vector
values = reader.getSettings(dataClass, key);
PRINT_VECTOR_WITH_NEW_LINE(key, values);
key += "/";
if (!values.empty()) {
key += values[0];
var = reader.getSettings(dataClass,key);
values = var.cellZones();
PRINT_VECTOR_WITH_NEW_LINE(key + " cellZones", values);
// for a cell zone, to find the face zones
values = var.faceZones();
PRINT_VECTOR_WITH_NEW_LINE(key + " faceZones", values);
// for a cell zone, to find the node zones
values = var.nodeZones();
PRINT_VECTOR_WITH_NEW_LINE(key + " nodeZones", values);
}
}
std::cout << std::endl;
}
void
displayStandardCaseSettings(const ansys::CffProvider& reader,
bool showAllStandardPhysics)
{
std::cout << "Standard settings:" << std::endl;
ansys::CffVariant var;
// ----------------------------------- domains
std::string key = "domains";
std::vector<std::string> values = reader.getSettings(dataClass, key);
PRINT_VECTOR_WITH_NEW_LINE(key, values);
if (!values.empty()) {
std::vector<std::string> objects;
if (showAllStandardPhysics) {
objects.swap(values);
} else {
objects.push_back(values[0]);
}
for (const auto& o : objects) {
std::string lkey = key;
lkey += "/";
lkey += o;
var = reader.getSettings(dataClass, lkey);
values = var.location();
PRINT_VECTOR_WITH_NEW_LINE(lkey + " location", values);
values = reader.getSettings(dataClass,lkey + "/type").asStringVector();
PRINT_VECTOR_WITH_NEW_LINE(lkey + " type", values);
std::vector<std::string> transformationKeys;
transformationKeys.
push_back("meshMotion/linearTransformation/displacement");
transformationKeys.
push_back("meshMotion/linearTransformation/position");
transformationKeys.
push_back("meshMotion/linearTransformation/velocity");
transformationKeys.
push_back("meshMotion/rotationalTransformation/axisStart");
transformationKeys.
push_back("meshMotion/rotationalTransformation/axisEnd");
transformationKeys.
push_back("meshMotion/rotationalTransformation/relativeRotationAngle");
// TO DO - replace this when the data is coming through correctly
for (const auto& tkey : transformationKeys) {
values = reader.getSettings(dataClass, lkey + "/" + tkey).asStringVector();
PRINT_VECTOR_WITH_NEW_LINE(lkey + " " + tkey, values);
}
}
}
// ----------------------------------- boundaries
key = "boundaries";
values = reader.getSettings(dataClass, key);
std::sort(values.begin(), values.end());
PRINT_VECTOR_WITH_NEW_LINE(key, values);
if (!values.empty()) {
std::vector<std::string> objects;
if (showAllStandardPhysics) {
objects.swap(values);
} else {
objects.push_back(values[0]);
}
for (const auto& o : objects) {
std::string lkey = key;
lkey += "/";
lkey += o;
values =
reader.getSettings(dataClass, lkey + "/location").asStringVector();
PRINT_VECTOR_WITH_NEW_LINE(lkey + "/location", values);
values = reader.getSettings(dataClass, lkey + "/type").asStringVector();
PRINT_VECTOR_WITH_NEW_LINE(lkey + "/type", values);
values = reader.getSettings(dataClass, lkey + "/domain").asStringVector();
PRINT_VECTOR_WITH_NEW_LINE(lkey + "/domain", values);
}
}
// ----------------------------------- subdomains
key = "subdomains";
values = reader.getSettings(dataClass, key);
PRINT_VECTOR_WITH_NEW_LINE(key, values);
if (!values.empty()) {
std::vector<std::string> objects;
if (showAllStandardPhysics) {
objects.swap(values);
} else {
objects.push_back(values[0]);
}
for (const auto& o : objects) {
std::string lkey = key;
lkey += "/";
lkey += o;
values =
reader.getSettings(dataClass, lkey + "/location").asStringVector();
PRINT_VECTOR_WITH_NEW_LINE(lkey + "/location", values);
values = reader.getSettings(dataClass, lkey + "/type").asStringVector();
PRINT_VECTOR_WITH_NEW_LINE(lkey + "/type", values);
values = reader.getSettings(dataClass, lkey + "/domain").asStringVector();
PRINT_VECTOR_WITH_NEW_LINE(lkey + "/domain", values);
}
}
// ----------------------------------- interfaces
key = "interfaces";
values = reader.getSettings(dataClass, key);
PRINT_VECTOR_WITH_NEW_LINE(key, values);
if (!values.empty()) {
std::vector<std::string> objects;
if (showAllStandardPhysics) {
objects.swap(values);
} else {
objects.push_back(values[0]);
}
{
std::vector<std::string> ikeys;
ikeys.push_back("/type");
ikeys.push_back("/conformal");
ikeys.push_back("/domainsSide1");
ikeys.push_back("/boundariesSide1");
ikeys.push_back("/domainsSide2");
ikeys.push_back("/boundariesSide2");
ikeys.push_back("/model/periodic/type");
ikeys.push_back("/model/periodic/axisStart");
ikeys.push_back("/model/periodic/axisEnd");
ikeys.push_back("/model/periodic/velocity/magnitude");
for (const auto& o : objects) {
std::string lkey = key;
lkey += "/";
lkey += o;
for (const auto& ikey: ikeys) {
values =
reader.getSettings(dataClass, lkey + ikey).asStringVector();
if (!values.empty()) {
PRINT_VECTOR_WITH_NEW_LINE(lkey + ikey, values);
}
}
}
}
}
key = "dimensionalUnits";
values = reader.getSettings(dataClass, key).asStringVector();
PRINT_VECTOR_WITH_NEW_LINE(key, values);
std::cout << std::endl;
}
void
displayFluentCaseSettings(const ansys::CffProvider& reader)
{
std::cout << "The following non standard settings are also available:"
<< std::endl;
{
std::cout << "Reading other rpVars ...." << std::endl;
std::string key = "settings/config";
// get the face zones as a string vector
std::vector<std::string> values = reader.getSettings(dataClass, key);
PRINT_VECTOR_WITH_NEW_LINE(key, values);
for (const auto& elem : values)
{
std::string newKey = key + "/";
newKey += elem;
std::string value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
}
key = "settings/";
std::string newKey = key + "initial/pressure";
std::string value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
key = "settings/";
key += "reference/";
newKey = key + "adiabaticIndex";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "velocity";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "viscosity";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "temperature";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "density";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "depth";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
key = "settings/";
key += "farField/";
newKey = key + "SoundSpeed";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "pressure";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "density";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
key = "settings/";
newKey = key + "operatingPressure";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "xVelocity/default";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "yVelocity/default";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "zVelocity/default";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "unitSystem";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "shell/thread-ids";
values = reader.getSettings(dataClass, newKey);
PRINT_VECTOR_WITH_NEW_LINE(newKey, values);
key = "fluentDomains/";
newKey = key;
values = reader.getSettings(dataClass, newKey);
PRINT_VECTOR_WITH_NEW_LINE(newKey, values);
for (const auto& elem : values)
{
newKey = key + elem;
std::string dKey = newKey + "/name";
value = reader.getSettings(dataClass, dKey);
PRINT_VALUE(dKey, value);
dKey = newKey + "/type";
value = reader.getSettings(dataClass, dKey);
PRINT_VALUE(dKey, value);
dKey = newKey + "/material";
value = reader.getSettings(dataClass, dKey);
PRINT_VALUE(dKey, value);
dKey = newKey + "/parentId";
value = reader.getSettings(dataClass, dKey);
PRINT_VALUE(dKey, value);
dKey = newKey + "/childrenIds";
value = reader.getSettings(dataClass, dKey);
PRINT_VALUE(dKey, value);
}
//Access of general rpVars
key = "settings/";
key += "rpvar/";
std::cout << "Reading rpVars ..." << std::endl;
newKey = key + "operating-pressure";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "initial-operating-pressure";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "reference-gamma";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "reference-velocity";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "reference-viscosity";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "reference-temperature";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "reference-density";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "far-field-sound-speed";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "far-field-pressure";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "far-field-density";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "x-velocity/default";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "y-velocity/default";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "z-velocity/default";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "case-file-units";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "shell/thread-ids";
values = reader.getSettings(dataClass, newKey);
PRINT_VECTOR_WITH_NEW_LINE(newKey, values);
newKey = key + "domains";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
}
//Material properties
{
std::cout << "Reading material properties ..." << std::endl;
std::string key = "materials";
// get the face zones as a string vector
std::vector<std::string> values = reader.getSettings(dataClass, key);
if (!values.empty())
{
PRINT_VECTOR_WITH_NEW_LINE(key, values);
key += "/";
for (const auto& elem : values)
{
std::string subKey = key + elem;
std::string value = reader.getSettings(dataClass, subKey + "/phase-type" );
PRINT_VALUE(subKey + "/phase-type", value);
std::string newKey = subKey + "/chemicalFormula";
value = reader.getSettings(dataClass, newKey );
PRINT_VALUE(newKey, value);
newKey = subKey + "/density/constant";
value = reader.getSettings(dataClass, newKey );
PRINT_VALUE(newKey, value);
newKey = subKey + "/viscosity/constant";
value = reader.getSettings(dataClass, newKey );
PRINT_VALUE(newKey, value);
newKey = subKey + "/molecularWeight/constant";
value = reader.getSettings(dataClass, newKey );
PRINT_VALUE(newKey, value);
newKey = subKey + "/specificHeat/constant";
value = reader.getSettings(dataClass, newKey );
PRINT_VALUE(newKey, value);
newKey = subKey + "/species/names";
value = reader.getSettings(dataClass, newKey );
PRINT_VALUE(newKey, value);
}
}
}
std::cout << std::endl;
// Sliding Interfaces
{
std::cout << "Reading sliding interfaces ..." << std::endl;
std::string key = "settings/slidingInterfaces";
std::vector<std::string> values = reader.getSettings(dataClass, key);
if (!values.empty())
{
PRINT_VECTOR_WITH_NEW_LINE(key, values);
for (const auto& value: values) {
std::string newKey = key + "/" + value + "/side1/zoneIds";
std::vector<std::string> zones = reader.getSettings(dataClass, newKey);
PRINT_VECTOR_WITH_NEW_LINE(newKey, zones);
newKey = key + "/" + value + "/side2/zoneIds";
zones = reader.getSettings(dataClass, newKey);
PRINT_VECTOR_WITH_NEW_LINE(newKey, zones);
}
}
}
std::cout << std::endl;
}
void
displayStandardResultsSettings(const ansys::CffProvider& reader)
{
std::cout << "Standard settings:" << std::endl;
{
std::string value;
std::string key = "simulation";
std::string newKey = key + "/type";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "/dataFile";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "/caseFile";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "/timeStep";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "/time";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "/crankAngle";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "/iteration";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
}
std::string key = "dimensionalUnits";
std::vector<std::string> values =
reader.getSettings(dataClass, key).asStringVector();
PRINT_VECTOR_WITH_NEW_LINE(key, values);
std::cout << std::endl;
}
void
displayFluentResultsSettings(const ansys::CffProvider& reader)
{
std::cout << "The following non standard settings are also available:"
<< std::endl;
//Access of general data Vars from data file
{
std::string value;
std::string key = "settings/";
key += "dtvar/";
std::cout << "Reading rpVars ..." << std::endl;
std::string newKey = key + "flow-time";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "time-step";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "physical-time-step-m1";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
key = "simulation";
newKey = key + "/history/dataFiles";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "/history/caseFiles";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "/history/timeSteps";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "/history/times";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value);
newKey = key + "/history/crankAngles";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value)
newKey = key + "/history/iterations";
value = reader.getSettings(dataClass, newKey);
PRINT_VALUE(newKey, value)
}
std::cout << std::endl;
}
void
displayCaseSettings(const ansys::CffProvider& reader,
bool showAllStandardPhysics,
bool showSolverSettings)
{
// get the top-level mesh-information
{
ansys::ElemIdType nodeCount = 0, faceCount = 0, cellCount = 0,
meshDimension = 0;
reader.getMeshSize(CFF_MESH_NODE_COUNT, nodeCount);
std::cout << "Node-count = " << nodeCount << std::endl;
reader.getMeshSize(CFF_MESH_FACE_COUNT, faceCount);
std::cout << "Face-count = " << faceCount << std::endl;
reader.getMeshSize(CFF_MESH_CELL_COUNT, cellCount);
std::cout << "Cell-count = " << cellCount << std::endl;
// set the dimension of the problem
reader.getMeshSize(CFF_MESH_DIMENSION, meshDimension);
std::cout << "Dimension = " << meshDimension << std::endl;
std::cout << std::endl;
// allocate memory according to your program
}
// zone and other light-weight information
if (showSolverSettings) {
if (reader.getSolverType() == c_fluent) {
displayFluentMeshSettings(reader);
}
}
displayStandardCaseSettings(reader, showAllStandardPhysics);
if (showSolverSettings) {
// Other Non Standard settings
if (reader.getSolverType() == c_fluent) {
displayFluentCaseSettings(reader);
}
}
}
void
displayResultsSettings(const ansys::CffProvider& reader, bool showSolverSettings)
{
displayStandardResultsSettings(reader);
if (showSolverSettings) {
if (reader.getSolverType() == c_fluent) {
displayFluentResultsSettings(reader);
}
}
}
int
main(int argc, char* argv[])
{
std::string casFileName;
std::string datFileName;
std::string optFileName;
bool showAllStandardPhysics = false;
bool showSolverSettings = true;
for (int n = 1; n != argc; ++n) {
std::string argValue(argv[n]);
if (argValue == "-c") {
++n;
casFileName = std::string(argv[n]);
}
else if (argValue == "-d") {
++n;
datFileName = std::string(argv[n]);
}
else if (argValue == "-o") {
++n;
optFileName = std::string(argv[n]);
}
else if (argValue == "-S") {
showSolverSettings = false;
}
else if (argValue == "-a") {
showAllStandardPhysics = true;
} else if (argValue == "-h" ||
argValue == "--help") {
std::cout << "Usage:" << std::endl;
std::string appName(argv[0]);
std::string::size_type sep = appName.find_last_of("'\\/");
if (sep != std::string::npos) {
appName = appName.substr(sep+1);
}
std::cout << appName << " [-c <cas file>] [-d <dat file>] [-s] [-a]"
<< std::endl;
std::cout
<< " -c <cas file> Read settings from supplied case file" << std::endl
<< " -d <dat file> Read settings from supplied data file" << std::endl
<< " -S Ignore solver specific settings" << std::endl
<< " -a Show settings for all physics objects" << std::endl
<< " Default is to just show first object of each type"
<< std::endl;
exit(0);
}
}
if (casFileName.empty() && datFileName.empty() && optFileName.empty()) {
casFileName = "elbow.cas.h5";
datFileName = "elbow.dat.h5";
}
std::string sourceFile;
if (!casFileName.empty()) {
sourceFile = casFileName;
} else if (!datFileName.empty()) {
sourceFile = datFileName;
} else if (!optFileName.empty()) {
sourceFile = optFileName;
}
std::unique_ptr<ansys::CffFileProvider>
readerPtr(ansys::getDataProvider(sourceFile));
if (!readerPtr) {
std::cerr << "Unable to open file '" << sourceFile << "'" << std::endl;
exit(1);
}
ansys::CffProvider& reader = *readerPtr;
// Default built-in options: debug=false, NCI=false, meshId=-1 (automatic), skipReadingZoneTopology = false
bool skipzt = false;
readerPtr->setSkipReadZoneTopology(skipzt);
if (!casFileName.empty()) {
bool lOK = readerPtr->startReading(casFileName, ansys::DataClass::CFF_CASE);
if (!lOK) {
std::cout << "Error reading case file" << std::endl;
return 1;
} else {
std::string caseVersion;
readerPtr->getFileVersion(ansys::DataClass::CFF_CASE, caseVersion);
std::cout << "Case-file version = " << caseVersion << std::endl << std::endl;
displayCaseSettings(reader, showAllStandardPhysics, showSolverSettings);
}
}
if (!datFileName.empty()) {
bool lOK = readerPtr->startReading(datFileName, dataClass);
if (!lOK) {
std::cout << "Error reading data file" << std::endl;
return 1;
}
std::string resultsVersion;
readerPtr->getFileVersion(ansys::DataClass::CFF_RESULTS, resultsVersion);
std::cout << "Data-file version = " << resultsVersion << std::endl << std::endl;
displayResultsSettings(reader, showSolverSettings);
}
//Optional read another data file with the same case file
if (!optFileName.empty()) {
bool lOK = readerPtr->startReading(optFileName, dataClass);
if (!lOK)
{
std::cout << "Error reading second data file: " << optFileName
<< std::endl;
return 1;
}
std::string resultsVersion;
readerPtr->getFileVersion(ansys::DataClass::CFF_RESULTS, resultsVersion);
std::cout << "Data-file version = " << resultsVersion << std::endl << std::endl;
displayResultsSettings(reader, showSolverSettings);
}
std::cout << std::endl << "All done." << std::endl;
return 0;
}
SolverType getSolverType() const
Obtains the owner of the data in the model.
Definition: CffBaseMethods.cpp:1727
void getMeshSize(const MeshSizeType type, ElemIdType &size) const
Obtains a value that defines the dimension or the global number of objects of a specific mesh entity.
Definition: CffBaseMethods.cpp:488
virtual void setSkipReadZoneTopology(bool skip)
Set whether mesh zone to mesh zone topology topology should be constructed when the case data is read...
Definition: CffProviderMethods.cpp:84
CffVariant getSettings(const DataClass type, const std::string &key, const PhaseIdType phaseId=1) const
Return the value as a variable for a specific key in the Ansys Common Fluids Settings Data Model.
Definition: CffProviderMethods.cpp:294
CffDataClass
An enumeration that is used within the API to caterorize types of CFF data.
Definition: CffTypes.h:415

Reading Discrete Phase Model (DPM) Particle Data using C++ API

This example demonstrates how to use the CFF API to read discrete phase model (DPM) particle data. To execute this example, you must supply a data file that has DPM particle data in it. Ansys Fluent writes such data files for cases in which an injection is defined, and the files are in a compatible format by default.

/*
* Copyright ANSYS. All Rights Reserved.
*/
#include "CffInterface/printVersion.hpp"
#include "Factory/providers.hpp"
#include <memory>
#include <algorithm>
#include <cassert>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <utility>
#include <vector>
#include "../Common/Output.hpp"
#include "../Common/Utilities.hpp"
bool readAllParticles(ansys::CffProvider& reader, const ansys::PhaseIdType phaseId = 0)
{
std::cout << "Reading particle data from phase" << phaseId << std::endl;
bool hasParticles = false;
if (phaseId == 0)
hasParticles = reader.startReadingParticles();
else
hasParticles = reader.startReadingParticles(phaseId);
if (!hasParticles)
{
std::cout << "No particle data in phase: " << phaseId << std::endl;
return false;
}
// get injection names
std::vector<std::string> injName;
reader.getInjectionNames(injName);
for (auto& inj : injName)
{
std::cout << " Reading data for " << inj << ":" << std::endl;
// get what variables are there under this situation
reader.getVariablesOfInjection(inj, varName);
reader.getVariablesOfInjection(inj, varIds);
size_t particlesNum = reader.getNumOfParticlesInInjection(inj);
// read all the vars one-by-one
for (size_t iv = 0; iv < varName.size(); ++iv) {
// find out number of data per particles and dataTypes
size_t numVarsPerParticle = reader.startReadingVariableForParticlesInInjection(inj, varName[iv], dataType);
switch (dataType){
{
std::vector<unsigned char> dataBuf(particlesNum * numVarsPerParticle);
reader.getValuesOfVariableForParticlesInInjection(dataBuf.data(), particlesNum * numVarsPerParticle);
break;
}
{
std::vector<char> dataBuf(particlesNum * numVarsPerParticle);
reader.getValuesOfVariableForParticlesInInjection(dataBuf.data(), particlesNum * numVarsPerParticle);
break;
}
{
std::vector<double> dataBuf(particlesNum * numVarsPerParticle);
reader.getValuesOfVariableForParticlesInInjection(dataBuf.data(), particlesNum * numVarsPerParticle);
break;
}
{
std::vector<float> dataBuf(particlesNum * numVarsPerParticle);
reader.getValuesOfVariableForParticlesInInjection(dataBuf.data(), particlesNum * numVarsPerParticle);
break;
}
{
std::vector<int> dataBuf(particlesNum * numVarsPerParticle);
reader.getValuesOfVariableForParticlesInInjection(dataBuf.data(), particlesNum * numVarsPerParticle);
break;
}
{
std::vector<unsigned int> dataBuf(particlesNum * numVarsPerParticle);
reader.getValuesOfVariableForParticlesInInjection(dataBuf.data(), particlesNum * numVarsPerParticle);
break;
}
{
std::vector<long> dataBuf(particlesNum * numVarsPerParticle);
reader.getValuesOfVariableForParticlesInInjection(dataBuf.data(), particlesNum * numVarsPerParticle);
break;
}
{
std::vector<long long> dataBuf(particlesNum * numVarsPerParticle);
reader.getValuesOfVariableForParticlesInInjection(dataBuf.data(), particlesNum * numVarsPerParticle);
break;
}
{
std::vector<size_t> dataBuf(particlesNum * numVarsPerParticle);
reader.getValuesOfVariableForParticlesInInjection(dataBuf.data(), particlesNum * numVarsPerParticle);
break;
}
default:
{
std::cout << "unknown data type, skip reading!" <<std::endl;
}
}
std::cout << " Data of " << varName[iv] << "(" << varIds[iv] << ")"
<< " is read into a " << particlesNum << " x "
<< numVarsPerParticle << " buffer." << std::endl;
reader.endReadingVariableForParticlesInInjection();
}
}
reader.endReadingParticles();
return true;
}
int
main(int argc, char* argv[])
{
std::string casFileName;
std::string datFileName;
ansys::MeshIdType meshId = -1;
ansys::PartitionIdType partitionId = -1;
bool queryContents = false;
for (int n = 1; n != argc; ++n) {
std::string argValue(argv[n]);
if (argValue == "-q") {
queryContents = true;
} else if (argValue == "-c") {
++n;
casFileName = std::string(argv[n]);
}
else if (argValue == "-d") {
++n;
datFileName = std::string(argv[n]);
}
else if (argValue == "-m") {
++n;
meshId = std::stoi(argv[n]);
}
else if (argValue == "-t") {
++n;
std::string target(argv[n]);
if (target == "restart") {
targetCategory = CFF_RESTART;
} else if (target == "post") {
targetCategory = CFF_POST;
} else if (target == "partitioned") {
targetCategory = CFF_PARTITIONED_POST;
}
}
else if (argValue == "-p") {
++n;
partitionId = std::stoi(argv[n]);
}
}
// Fallback
if (casFileName.empty() && datFileName.empty()) {
casFileName = "ice_2m.cas.h5";
datFileName = "ice_2m.dat.h5";
}
if (queryContents && casFileName.empty()) {
std::cerr << "Unable to query contents without a case file" << std::endl;
exit(1);
}
std::unique_ptr<ansys::CffFileProvider> readerPtr;
if (!casFileName.empty()) {
readerPtr.reset(ansys::getDataProvider(casFileName));
} else if (!datFileName.empty()) {
readerPtr.reset(ansys::getDataProvider(datFileName));
}
if(!readerPtr) {
std::cout << "Error creating provider for file" << std::endl;
return 1;
}
ansys::CffProvider& reader = *readerPtr;
if (queryContents) {
if (!readerPtr->startReading(casFileName, ansys::DataClass::CFF_CASE)) {
std::cout << "Error reading case file" << std::endl;
return 1;
}
DisplayMeshAndTargets(readerPtr.get());
exit(0);
}
// Set Mesh Id
if (meshId != -1) {
reader.setMeshId(meshId);
}
// Set Target
reader.setTarget(targetCategory);
// Set Partition Id
if (partitionId != -1) {
reader.setPartitionId(partitionId);
}
// Using default built-in options: debug=false, NCI=false, meshId=-1 (automatic), target = CFF_RESTART
//to switch to other format, need to setTarget to correct one.
if (!casFileName.empty()) {
if (!readerPtr->startReading(casFileName, ansys::DataClass::CFF_CASE)) {
std::cout << "Error reading case file" << std::endl;
return 1;
}
DisplayInfoForCase(readerPtr.get());
DisplayInfoForMesh(readerPtr.get());
}
// data-file
if (!datFileName.empty()) {
if (!readerPtr->startReading(datFileName, ansys::DataClass::CFF_RESULTS)) {
std::cout << "Error reading data file" << std::endl;
return 1;
}
//Reading particle data
ansys::PhaseIds phaseIds;
reader.getPhaseIds(phaseIds);
for (auto phaseId : phaseIds)
{
// Scenario 1: user want to read particle data and other cell zone data / face zone data
reader.startReadingPhase(phaseId);
//Here user can insert code for reading cell zone data or face zone data
if (reader.hasParticles())
readAllParticles(reader);
reader.endReadingPhase();
// Scenario 2: user only want to read particle data
if (reader.hasParticles(phaseId))
readAllParticles(reader, phaseId);
}
std::cout << std::endl << "All done." << std::endl;
}
return 0;
}
virtual void getInjectionNames(InjectionNames &) const
Definition: CffProviderMethods.cpp:3467
CffPlainDataType
Datatypes available in certain CFF functions.
Definition: CffTypes.h:383
@ CFF_DATATYPE_UCHAR
Definition: CffTypes.h:389
@ CFF_DATATYPE_LLONG
Definition: CffTypes.h:405
@ CFF_DATATYPE_UINT
Definition: CffTypes.h:395
@ CFF_DATATYPE_INT
Definition: CffTypes.h:393
@ CFF_DATATYPE_FLOAT
Definition: CffTypes.h:399
@ CFF_DATATYPE_LONG
Definition: CffTypes.h:397
@ CFF_DATATYPE_DOUBLE
Definition: CffTypes.h:401
@ CFF_DATATYPE_SIZE_T
Definition: CffTypes.h:403
@ CFF_DATATYPE_CHAR
Definition: CffTypes.h:387

Reading a CFF file using C API

This example demonstrates how to use the CFF API wrapper in C code to read a CFF file.

/*
* Copyright ANSYS. All Rights Reserved.
*/
#include "Factory/CffCAPI.h"
#include "CffInterface/CffTypes.h"
#include <stdio.h>
#include <string.h>
void
displayZoneIds(const char* cat, const CffZoneIds zoneIds, size_t numZoneIds)
{
fprintf(stdout, "%s : ", cat);
for (size_t n = 0; n != numZoneIds; ++n) {
if (n != 0) {
fprintf(stdout, ", %u", zoneIds[n]);
} else {
fprintf(stdout, "%u", zoneIds[n]);
}
}
fprintf(stdout, ".\n\n");
}
int main(int argc, char* argv[])
{
char* casFileName = NULL;
for (int n = 1; n != argc; ++n) {
if (!strcmp(argv[n], "-c")) {
++n;
casFileName = argv[n];
}
}
if (!casFileName || !strlen(casFileName)) {
casFileName = "elbow.cas.h5";
}
CffReader* reader = (CffReader*)malloc(sizeof(CffReader));
int ret = cffInitializeReader(reader, casFileName);
if (!ret) {
fprintf(stderr, "Unable to initialize reader from %s\n", casFileName);
exit(1);
}
CffDataClass data_class = CFF_CASE;
cffStartReadingFile(reader, casFileName, data_class);
CffElemIdType dim = 0;
CffElemIdType nodeCount = 0, edgeCount = 0, faceCount = 0, cellCount = 0;
cffGetMeshSize(reader, CFF_MESH_DIMENSION, &dim);
cffGetMeshSize(reader, CFF_MESH_NODE_COUNT, &nodeCount);
cffGetMeshSize(reader, CFF_MESH_EDGE_COUNT, &edgeCount);
cffGetMeshSize(reader, CFF_MESH_FACE_COUNT, &faceCount);
cffGetMeshSize(reader, CFF_MESH_CELL_COUNT, &cellCount);
fprintf(stdout,
"Node-count = %zu\nEdge-count = %zu\nFace-count = %zu\nCell-count = %zu\nDimension = %zu\n\n",
nodeCount,
edgeCount,
faceCount,
cellCount,
dim);
/* Process Node Zones */
size_t numNodeZones = 0;
cffGetNumZones(reader, CFF_NODE_ZONE, &numNodeZones);
if (numNodeZones) {
CffZoneIds nodeZones =
(CffZoneIds)malloc(sizeof(CffZoneIdType)*numNodeZones);
cffGetZoneIds(reader, CFF_NODE_ZONE, nodeZones);
displayZoneIds("Node-zone id", nodeZones, numNodeZones);
for (size_t n = 0; n != numNodeZones; ++n) {
CffElemIdType startId = 0;
cffGetZoneSizeInfo(reader, nodeZones[n], CFF_ZONE_START_ID, &startId);
CffElemIdType endId = 0;
cffGetZoneSizeInfo(reader, nodeZones[n], CFF_ZONE_END_ID, &endId);
CffElemIdType dimension = 0;
cffGetZoneSizeInfo(reader, nodeZones[n], CFF_ZONE_DIMENSION, &dimension);
fprintf(stdout, "Node-zone %u:\n", nodeZones[n]);
fprintf(stdout, " minId = %zu\n", startId);
fprintf(stdout, " maxId = %zu\n", endId);
fprintf(stdout, " dimension = %zu\n\n", dimension);
}
displayZoneIds("Coordinates of node-zones", nodeZones, numNodeZones);
cffStartReadingCoordinatesForNodes(reader);
for (size_t n = 0; n != numNodeZones; ++n) {
CffElemIdType startId = 0;
cffGetZoneSizeInfo(reader, nodeZones[n], CFF_ZONE_START_ID, &startId);
CffElemIdType endId = 0;
cffGetZoneSizeInfo(reader, nodeZones[n], CFF_ZONE_END_ID, &endId);
CffElemIdType count = 0;
cffGetZoneSizeInfo(reader, nodeZones[n], CFF_ZONE_SIZE, &count);
CffElemIdType dimension = 0;
cffGetZoneSizeInfo(reader, nodeZones[n], CFF_ZONE_DIMENSION, &dimension);
size_t coordsSZ = count * dimension;
double* coords = (double*)malloc(sizeof(double) * coordsSZ);
cffGetCoordinatesForNodesInRange(reader, startId, endId, coords, coordsSZ);
fprintf(stdout,
"Coordinates of zone-%u is read into a %zu x %zu buffer.\n\n",
nodeZones[n],
count,
dimension);
}
}
/* Process Edge Zones */
size_t numEdgeZones = 0;
cffGetNumZones(reader, CFF_EDGE_ZONE, &numEdgeZones);
if (numEdgeZones) {
CffZoneIds edgeZones =
(CffZoneIds)malloc(sizeof(CffZoneIdType)*numEdgeZones);
cffGetZoneIds(reader, CFF_EDGE_ZONE, edgeZones);
displayZoneIds("Edge-zone id", edgeZones, numEdgeZones);
for (size_t n = 0; n < numEdgeZones; ++n) {
CffElemIdType startId = 0;
cffGetZoneSizeInfo(reader, edgeZones[n], CFF_ZONE_START_ID, &startId);
CffElemIdType endId = 0;
cffGetZoneSizeInfo(reader, edgeZones[n], CFF_ZONE_END_ID, &endId);
CffElemIdType dimension = 0;
cffGetZoneSizeInfo(reader, edgeZones[n], CFF_ZONE_DIMENSION, &dimension);
int zoneType = 0;
cffGetEdgeZoneInfo(reader, edgeZones[n], CFF_EDGE_ZONE_TYPE, &zoneType);
int elementType = 0;
cffGetEdgeZoneInfo(reader, edgeZones[n], CFF_EDGE_ZONE_EDGE_TYPE, &elementType);
const char* name =
cffGetZoneStringInfo(reader, edgeZones[n], CFF_ZONE_STRING_NAME);
fprintf(stdout, "Edge-zone %u:\n", edgeZones[n]);
fprintf(stdout, " minId = %zu\n", startId);
fprintf(stdout, " maxId = %zu\n", endId);
fprintf(stdout, " dimension = %zu\n", dimension);
if (zoneType > -1) {
fprintf(stdout, " edge-zone-type = %d\n", zoneType);
}
if (elementType > -1) {
fprintf(stdout, " edge-type = %d\n", elementType);
}
if (name) {
fprintf(stdout, " name = %s\n", name);
free((char*)name);
name = NULL;
}
}
}
/* Process Face Zones */
size_t numFaceZones = 0;
cffGetNumZones(reader, CFF_FACE_ZONE, &numFaceZones);
if (numFaceZones) {
CffZoneIds faceZones =
(CffZoneIds)malloc(sizeof(CffZoneIdType)*numFaceZones);
if (!faceZones) {
fprintf(stderr, "Unable to allocate memory for face zones\n");
exit(1);
}
cffGetZoneIds(reader, CFF_FACE_ZONE, faceZones);
displayZoneIds("Face-zone id", faceZones, numFaceZones);
for (size_t n = 0; n < numFaceZones; ++n) {
CffElemIdType startId = 0;
cffGetZoneSizeInfo(reader, faceZones[n], CFF_ZONE_START_ID, &startId);
CffElemIdType endId = 0;
cffGetZoneSizeInfo(reader, faceZones[n], CFF_ZONE_END_ID, &endId);
CffElemIdType dimension = 0;
cffGetZoneSizeInfo(reader, faceZones[n], CFF_ZONE_DIMENSION, &dimension);
int shadowZoneId = 0;
cffGetFaceZoneInfo(reader, faceZones[n], CFF_FACE_ZONE_SHADOW_ZONE_ID,
&shadowZoneId);
int childZoneId = 0;
cffGetFaceZoneInfo(reader, faceZones[n], CFF_FACE_ZONE_CHILD_ZONE_ID,
&childZoneId);
int zoneType = 0;
cffGetFaceZoneInfo(reader, faceZones[n], CFF_FACE_ZONE_TYPE, &zoneType);
int elementType = 0;
cffGetFaceZoneInfo(reader, faceZones[n], CFF_FACE_ZONE_FACE_TYPE,
&elementType);
int flags = 0;
cffGetAllFaceZoneFlags(reader, faceZones[n], &flags);
const char* name =
cffGetZoneStringInfo(reader, faceZones[n], CFF_ZONE_STRING_NAME);
const char* type =
cffGetZoneStringInfo(reader, faceZones[n], CFF_ZONE_STRING_TYPE);
fprintf(stdout, "Face-zone %u:\n", faceZones[n]);
fprintf(stdout, " minId = %zu\n", startId);
fprintf(stdout, " maxId = %zu\n", endId);
fprintf(stdout, " dimension = %zu\n", dimension);
if (shadowZoneId > 0) {
fprintf(stdout, " shadow-zone-id = %u\n", shadowZoneId);
}
if (childZoneId > 0) {
fprintf(stdout, " child-zone-id = %u\n", childZoneId);
}
if (zoneType > -1) {
fprintf(stdout, " face-zone-type = %d\n", zoneType);
}
if (elementType > -1) {
fprintf(stdout, " face-type = %d\n", elementType);
}
fprintf(stdout, " flags = %d\n", flags);
if (name) {
if (strlen(name)) {
fprintf(stdout, " name = %s\n", name);
}
free((char*)name);
name = NULL;
}
if (type) {
if (strlen(type)) {
fprintf(stdout, " type = %s\n", type);
}
free((char*)type);
type = NULL;
}
}
fprintf(stdout, "\n");
CffZoneIds available =
(CffZoneIds)malloc(sizeof(CffZoneIdType)*numFaceZones);
if (!available) {
fprintf(stderr, "Unable to allocate memory for availability array\n");
exit(1);
}
cffStartReadingNodesForFaces(reader, available, numFaceZones);
size_t numAvailable = numFaceZones;
for (size_t n = 0; n != numFaceZones; ++n) {
if (!available[n]) {
numAvailable = n;
break;
}
}
if (numAvailable) {
/* Read face/node zones */
displayZoneIds("Face-nodes of face-zones", available, numAvailable);
cffStartReadingNodeCountsForFaces(reader);
size_t* szNodeIds =
(size_t*)calloc(numAvailable, sizeof(size_t));
if (!szNodeIds) {
fprintf(stderr, "Unable to allocate memory for face node counts\n");
exit(1);
}
/* Now read face node counts for each face zone */
for (size_t n = 0; n != numAvailable; ++n) {
CffElemIdType numFaces = 0;
cffGetZoneSizeInfo(reader, available[n], CFF_ZONE_SIZE, &numFaces);
short* nodeCounts = (short*)malloc(sizeof(short) * numFaces);
if (!nodeCounts) {
fprintf(stderr, "Unable to allocate memory for face node counts\n");
exit(1);
}
cffGetNodeCountsForFacesInZone(reader,
available[n],
nodeCounts,
numFaces);
fprintf(stdout,
"Face-node-counts of zone-%u is read into a %zu x 1 buffer.\n",
available[n],
numFaces);
/* Cache size so we know the number of node ids too read */
szNodeIds[n] = 0;
for (size_t ni = 0; ni != numFaces; ++ni) {
szNodeIds[n] += (size_t)nodeCounts[ni];
}
free(nodeCounts);
}
cffEndReadingNodeCountsForFaces(reader);
fprintf(stdout, "\n");
/* Now read face node ids for each face zone */
cffStartReadingNodeIdsForFaces(reader);
for (size_t n = 0; n != numAvailable; ++n) {
CffElemIdType* nodeIds =
(CffElemIdType*)malloc(sizeof(CffElemIdType) * szNodeIds[n]);
if (!nodeIds) {
fprintf(stderr, "Unable to allocate memory for face node ids\n");
exit(1);
}
cffGetNodeIdsForFacesInZone(reader,
available[n],
nodeIds,
szNodeIds[n]);
fprintf(stdout,
"Face-node-ids of zone-%u is read into a %zu x 1 buffer.\n",
available[n],
szNodeIds[n]);
free(nodeIds);
}
cffEndReadingNodeIdsForFaces(reader);
free(szNodeIds);
fprintf(stdout, "\n");
}
cffEndReadingNodesForFaces(reader);
/* Cell parents - C0 */
cffStartReadingCell0sForFaces(reader, available, numFaceZones);
numAvailable = numFaceZones;
for (size_t n = 0; n != numFaceZones; ++n) {
if (!available[n]) {
numAvailable = n;
break;
}
}
if (numAvailable) {
displayZoneIds("Cell-0 of face-zones", available, numAvailable);
for (size_t n = 0; n != numAvailable; ++n) {
CffElemIdType numFaces = 0;
cffGetZoneSizeInfo(reader, available[n], CFF_ZONE_SIZE, &numFaces);
(CffElemIdType*)malloc(sizeof(CffElemIdType) * numFaces);
if (!c0s) {
fprintf(stderr, "Unable to allocate memory for c0 array\n");
exit(1);
}
cffGetCell0sForFacesInZone(reader, available[n], c0s, numFaces);
fprintf(stdout,
"Face-cell0-connectivity of zone-%u is read into a %zu x 1 buffer.\n",
available[n],
numFaces);
free(c0s);
}
fprintf(stdout, "\n");
}
cffEndReadingCell0sForFaces(reader);
/* Cell parents - C1 */
cffStartReadingCell1sForFaces(reader, available, numFaceZones);
numAvailable = numFaceZones;
for (size_t n = 0; n != numFaceZones; ++n) {
if (!available[n]) {
numAvailable = n;
break;
}
}
if (numAvailable) {
displayZoneIds("Cell-1 of face-zones", available, numAvailable);
for (size_t n = 0; n != numAvailable; ++n) {
CffElemIdType numFaces = 0;
cffGetZoneSizeInfo(reader, available[n], CFF_ZONE_SIZE, &numFaces);
(CffElemIdType*)malloc(sizeof(CffElemIdType) * numFaces);
if (!c1s) {
fprintf(stderr, "Unable to allocate memory for c1 array\n");
exit(1);
}
cffGetCell1sForFacesInZone(reader, available[n], c1s, numFaces);
fprintf(stdout,
"Face-cell1-connectivity of zone-%u is read into a %zu x 1 buffer.\n",
available[n],
numFaces);
free(c1s);
}
fprintf(stdout, "\n");
}
cffEndReadingCell1sForFaces(reader);
free(available);
}
/* Process Cell Zones */
size_t numCellZones = 0;
cffGetNumZones(reader, CFF_CELL_ZONE, &numCellZones);
if (numCellZones) {
CffZoneIds cellZones =
(CffZoneIds)malloc(sizeof(CffZoneIdType)*numCellZones);
if (!cellZones) {
fprintf(stderr, "Unable to allocate memory for cell zones\n");
exit(1);
}
cffGetZoneIds(reader, CFF_CELL_ZONE, cellZones);
displayZoneIds("Cell-zone id", cellZones, numCellZones);
for (size_t n = 0; n < numCellZones; ++n) {
CffElemIdType startId = 0;
cffGetZoneSizeInfo(reader, cellZones[n], CFF_ZONE_START_ID, &startId);
CffElemIdType endId = 0;
cffGetZoneSizeInfo(reader, cellZones[n], CFF_ZONE_END_ID, &endId);
CffElemIdType dimension = 0;
cffGetZoneSizeInfo(reader, cellZones[n], CFF_ZONE_DIMENSION, &dimension);
int childZoneId = 0;
cffGetCellZoneInfo(reader, cellZones[n], CFF_CELL_ZONE_CHILD_ZONE_ID,
&childZoneId);
const char* name =
cffGetZoneStringInfo(reader, cellZones[n], CFF_ZONE_STRING_NAME);
const char* type =
cffGetZoneStringInfo(reader, cellZones[n], CFF_ZONE_STRING_TYPE);
fprintf(stdout, "Cell-zone %u:\n", cellZones[n]);
fprintf(stdout, " minId = %zu\n", startId);
fprintf(stdout, " maxId = %zu\n", endId);
fprintf(stdout, " dimension = %zu\n", dimension);
if (childZoneId > 0) {
fprintf(stdout, " child-zone-id = %u\n", childZoneId);
}
if (name) {
if (strlen(name)) {
fprintf(stdout, " name = %s\n", name);
}
free((char*)name);
name = NULL;
}
if (type) {
if (strlen(type)) {
fprintf(stdout, " zone-type-name = %s\n", type);
}
free((char*)type);
type = NULL;
}
}
fprintf(stdout, "\n");
CffZoneIds available =
(CffZoneIds)malloc(sizeof(CffZoneIdType)*numCellZones);
if (!available) {
fprintf(stderr, "Unable to allocate memory for availability array\n");
exit(1);
}
/* Read cell types */
cffStartReadingTypesForCells(reader, available, numCellZones);
size_t numAvailable = numCellZones;
for (size_t n = 0; n != numCellZones; ++n) {
if (!available[n]) {
numAvailable = n;
break;
}
}
if (numAvailable) {
displayZoneIds("Cell-types of cell-zones", available, numAvailable);
for (size_t n = 0; n != numAvailable; ++n) {
CffElemIdType numCells = 0;
cffGetZoneSizeInfo(reader, available[n], CFF_ZONE_SIZE, &numCells);
CffCellType* types =
(CffCellType*)malloc(numCells * sizeof(CffCellType));
cffGetTypesForCellsInZone(reader, available[n], types, numCells);
fprintf(stdout,
"Cell-type ids of zone-%u is read into a %zu x 1 buffer.\n",
available[n],
numCells);
free(types);
}
fprintf(stdout, "\n");
}
cffEndReadingTypesForCells(reader);
/* Read cell node ids */
cffStartReadingNodesForCells(reader, available, numCellZones);
numAvailable = numCellZones;
for (size_t n = 0; n != numCellZones; ++n) {
if (!available[n]) {
numAvailable = n;
break;
}
}
if (numAvailable) {
/* Read cell/node zones */
displayZoneIds("Cell-nodes of cell-zones", available, numAvailable);
cffStartReadingNodeCountsForCells(reader);
size_t* szNodeIds =
(size_t*)calloc(numAvailable, sizeof(size_t));
if (!szNodeIds) {
fprintf(stderr, "Unable to allocate memory for cell node counts\n");
exit(1);
}
/* Now read cell node counts for each cell zone */
for (size_t n = 0; n != numAvailable; ++n) {
CffElemIdType numCells = 0;
cffGetZoneSizeInfo(reader, available[n], CFF_ZONE_SIZE, &numCells);
short* nodeCounts = (short*)malloc(sizeof(short) * numCells);
if (!nodeCounts) {
fprintf(stderr, "Unable to allocate memory for cell node counts\n");
exit(1);
}
cffGetNodeCountsForCellsInZone(reader,
available[n],
nodeCounts,
numCells);
fprintf(stdout,
"Cell-node-counts of zone-%u is read into a %zu x 1 buffer.\n",
available[n],
numCells);
/* Cache size so we know the number of node ids too read */
szNodeIds[n] = 0;
for (size_t ni = 0; ni != numCells; ++ni) {
szNodeIds[n] += (size_t)nodeCounts[ni];
}
free(nodeCounts);
}
cffEndReadingNodeCountsForCells(reader);
fprintf(stdout, "\n");
/* Now read cell node ids for each cell zone */
cffStartReadingNodeIdsForCells(reader);
for (size_t n = 0; n != numAvailable; ++n) {
CffElemIdType* nodeIds =
(CffElemIdType*)malloc(sizeof(CffElemIdType) * szNodeIds[n]);
if (!nodeIds) {
fprintf(stderr, "Unable to allocate memory for cell node ids\n");
exit(1);
}
cffGetNodeIdsForCellsInZone(reader,
available[n],
nodeIds,
szNodeIds[n]);
fprintf(stdout,
"Cell-node-ids of zone-%u is read into a %zu x 1 buffer.\n",
available[n],
szNodeIds[n]);
free(nodeIds);
}
cffEndReadingNodeIdsForCells(reader);
free(szNodeIds);
fprintf(stdout, "\n");
}
cffEndReadingNodesForCells(reader);
/* Read cell partion ids */
cffStartReadingPartitionIdsForCells(reader, available, numCellZones);
numAvailable = numCellZones;
for (size_t n = 0; n != numCellZones; ++n) {
if (!available[n]) {
numAvailable = n;
break;
}
}
if (numAvailable) {
displayZoneIds("Cell-partition-ids of cell-zones",
available,
numAvailable);
for (size_t n = 0; n != numAvailable; ++n) {
fprintf(stdout, "Cell-partition ids of zone-%u is ", available[n]);
int partitionCount = cffGetPartitionCountForZone(reader, available[n]);
if (partitionCount < 2) {
fprintf(stdout,
"not read as partition-count is %d.\n",
partitionCount);
continue;
}
CffElemIdType numCells = 0;
cffGetZoneSizeInfo(reader, available[n], CFF_ZONE_SIZE, &numCells);
CffElemIdType minId = 0;
cffGetZoneSizeInfo(reader, available[n], CFF_ZONE_START_ID, &minId);
CffElemIdType maxId = 0;
cffGetZoneSizeInfo(reader, available[n], CFF_ZONE_START_ID, &maxId);
CffPartitionIdType* partitions =
(CffPartitionIdType*)malloc(numCells * sizeof(CffPartitionIdType));
cffGetPartitionIdsForCellsInRange(reader,
minId,
maxId,
partitions,
numCells);
fprintf(stdout, "read into a %zu x 1 buffer.\n", numCells);
free(partitions);
}
fprintf(stdout, "\n");
}
cffEndReadingPartitionIdsForCells(reader);
}
cffEndReading(reader, data_class);
cffFinalizeReader(reader);
printf("All done.\n");
return 0;
}
@ CFF_EDGE_ZONE_EDGE_TYPE
Definition: CffTypes.h:263
@ CFF_EDGE_ZONE_TYPE
Definition: CffTypes.h:261
@ CFF_MESH_EDGE_COUNT
Definition: CffTypes.h:181
CffZoneIdType * CffZoneIds
Type used to represent pointer to multiple zone ids ('C' API only)
Definition: CffTypes.h:753
int CffZoneIdType
Type used to represent the identifier of a zone.
Definition: CffTypes.h:747
int CffPartitionIdType
Type of a variable used to represent the identifier of a partition.
Definition: CffTypes.h:673
size_t CffElemIdType
Type used when representing the identifier of an element or the size of a zone.
Definition: CffTypes.h:707

Writing a CFF file using C API

This example demonstrates how to use the CFF API wrapper in C code to write a CFF file.

/*
* Copyright ANSYS. All Rights Reserved.
*/
#include "Factory/CffCAPI.h"
#include "../Common/CasAndDatCreator.hpp"
/* This is for convenience of creating the mesh, for C this is not needed */
#include <iostream>
#include <memory>
#include <vector>
int main(const int argc, const char** argv)
{
CffWriter writer = {0};
if (cffInitializeWriter(&writer, CFF_HDF))
{
cffSetMeshId(&writer, 1);
cffSetDataPrecision(&writer, CFF_PRECISION_DOUBLE);
cffSetDebugOn(&writer, 1);
cffSetCompression(&writer, 1);
cffSetSolverType(&writer, "ANSYS_FLUENT");
if (!cffStartWritingFile(&writer, "write_new.cas.h5", CFF_CASE))
{
std::cout << "Error writing to case file" << std::endl;
return 1;
}
if (!cffStartWritingFile(&writer, "write_new.dat.h5", CFF_RESULTS))
{
std::cout << "Error writing to data file" << std::endl;
return 1;
}
}
else
{
std::cout << "Error initialize writer" << std::endl;
return 1;
}
// top-level mesh information
size_t meshDimension, nodeCount, faceCount, cellCount;
// create those information
CreateMeshInfo(meshDimension, nodeCount, faceCount, cellCount);
// set these information in the writer
cffSetMeshSize(&writer, CFF_MESH_DIMENSION, meshDimension);
cffSetMeshSize(&writer, CFF_MESH_NODE_COUNT, nodeCount);
cffSetMeshSize(&writer, CFF_MESH_FACE_COUNT, faceCount);
cffSetMeshSize(&writer, CFF_MESH_CELL_COUNT, cellCount);
// write those information
cffWriteMeshSize(&writer);
// nodes
{
ansys::ZoneIds nodeZone;
std::vector<ansys::ElemIdType> startId;
std::vector<ansys::ElemIdType> endId;
std::vector<short> dimension;
std::vector<std::string> names;
// create zone-level information of nodes
CreateNodeZones(nodeZone, startId, endId, dimension, names);
// set the node-zones
cffSetZoneIds(&writer, CFF_NODE_ZONE, nodeZone.data(), nodeZone.size());
for (size_t iz = 0; iz < nodeZone.size(); ++iz) {
cffSetZoneSizeInfo(&writer,
nodeZone[iz], CFF_ZONE_START_ID, startId[iz]);
cffSetZoneSizeInfo(&writer,
nodeZone[iz], CFF_ZONE_END_ID, endId[iz]);
cffSetZoneSizeInfo(&writer,
nodeZone[iz], CFF_ZONE_DIMENSION, dimension[iz]);
cffSetZoneStringInfo(&writer,
nodeZone[iz], CFF_ZONE_STRING_NAME, names[iz].data());
}
// start writing about these node-zones
cffStartWritingNodes(&writer, nodeZone.data(), nodeZone.size());
// node coordinates
{
ansys::ZoneIds nodeCoordsZone;
std::vector<std::vector<double> > coords;
// create node coordinates of appropriate zones
CreateNodeCoords(nodeCoordsZone, coords);
// start writing coordinates of these node-zones
cffStartWritingCoordinatesForNodes(&writer, nodeCoordsZone.data(), nodeCoordsZone.size());
// write the coordinates
for (size_t iz = 0; iz < nodeCoordsZone.size(); ++iz) {
cffSetCoordinatesForNodesInZone(&writer,
nodeCoordsZone[iz], &(coords[iz].at(0)), coords[iz].size());
}
// end writing the coordinates
cffEndWritingCoordinatesForNodes(&writer);
}
// end writing about the node-zones
cffEndWritingNodes(&writer);
}
// faces
{
ansys::ZoneIds faceZone;
std::vector<ansys::ElemIdType> startId;
std::vector<ansys::ElemIdType> endId;
std::vector<short> dimension;
std::vector<ansys::ZoneIdType> shadowZoneId;
std::vector<ansys::ZoneIdType> childZoneId;
std::vector<ansys::FaceZoneType> zoneType;
std::vector<ansys::FaceType> elementType;
std::vector<short> flags;
std::vector<std::string> name;
std::vector<std::string> stringZoneType;
// create zone-level information of faces
CreateFaceZones(faceZone,
startId,
endId,
dimension,
shadowZoneId,
childZoneId,
zoneType,
elementType,
flags,
name,
stringZoneType);
// set the face zones
cffSetZoneIds(&writer, CFF_FACE_ZONE, faceZone.data(), faceZone.size());
for (size_t iz = 0; iz < faceZone.size(); ++iz) {
cffSetZoneSizeInfo(&writer,
faceZone[iz], CFF_ZONE_START_ID, startId[iz]);
cffSetZoneSizeInfo(&writer,
faceZone[iz], CFF_ZONE_END_ID, endId[iz]);
cffSetZoneSizeInfo(&writer,
faceZone[iz], CFF_ZONE_DIMENSION, dimension[iz]);
if (shadowZoneId[iz] > 0) {
cffSetFaceZoneInfo(&writer,
faceZone[iz],
shadowZoneId[iz]);
}
if (childZoneId[iz] > 0) {
cffSetFaceZoneInfo(&writer, faceZone[iz],
childZoneId[iz]);
}
if (zoneType[iz] > -1) {
cffSetFaceZoneInfo(&writer, faceZone[iz],
zoneType[iz]);
}
if (elementType[iz] > -1) {
cffSetFaceZoneInfo(&writer, faceZone[iz],
elementType[iz]);
}
if (!name[iz].empty()) {
cffSetZoneStringInfo(&writer, faceZone[iz],
name[iz].data());
}
if (!stringZoneType[iz].empty()) {
cffSetZoneStringInfo(&writer, faceZone[iz],
stringZoneType[iz].data());
}
}
// start writing about these face-zones
cffStartWritingFaces(&writer, faceZone.data(), faceZone.size());
// face-nodes
{
ansys::ZoneIds faceNodesZone;
std::vector<std::vector<short> > numNodes;
std::vector<std::vector<ansys::ElemIdType> > nodes;
// create face-node information of appropriate zones
CreateFaceNodes(faceNodesZone, numNodes, nodes);
cffStartWritingNodesForFaces(&writer, faceNodesZone.data(), faceNodesZone.size());
cffStartWritingNodeCountsForFaces(&writer);
for (size_t iz = 0; iz < faceNodesZone.size(); ++iz) {
cffSetNodeCountsForFacesInZone(&writer,
faceNodesZone[iz], &(numNodes[iz].at(0)), numNodes[iz].size());
}
cffEndWritingNodeCountsForFaces(&writer);
cffStartWritingNodeIdsForFaces(&writer);
for (size_t iz = 0; iz < faceNodesZone.size(); ++iz) {
cffSetNodeIdsForFacesInZone(&writer,
faceNodesZone[iz], &(nodes[iz].at(0)), nodes[iz].size());
}
cffEndWritingNodeIdsForFaces(&writer);
cffEndWritingNodesForFaces(&writer);
}
// face-cell-0 s
{
ansys::ZoneIds faceC0Zone;
std::vector<std::vector<ansys::ElemIdType> > faceC0s;
CreateFaceC0s(faceC0Zone, faceC0s);
cffStartWritingCell0sForFaces(&writer, faceC0Zone.data(), faceC0Zone.size());
for (size_t iz = 0; iz < faceC0Zone.size(); ++iz) {
cffSetCell0sForFacesInZone(&writer,
faceC0Zone[iz], &(faceC0s[iz].at(0)), faceC0s[iz].size());
}
cffEndWritingCell0sForFaces(&writer);
}
// face-cell-1 s
{
ansys::ZoneIds faceC1Zone;
std::vector<std::vector<ansys::ElemIdType> > faceC1s;
CreateFaceC1s(faceC1Zone, faceC1s);
cffStartWritingCell1sForFaces(&writer, faceC1Zone.data(), faceC1Zone.size());
for (size_t iz = 0; iz < faceC1Zone.size(); ++iz) {
cffSetCell1sForFacesInZone(&writer,
faceC1Zone[iz], &(faceC1s[iz].at(0)), faceC1s[iz].size());
}
cffEndWritingCell1sForFaces(&writer);
}
cffEndWritingFaces(&writer);
}
// cells
{
ansys::ZoneIds cellZone;
std::vector<ansys::ElemIdType> startId;
std::vector<ansys::ElemIdType> endId;
std::vector<short> dimension;
std::vector<ansys::ZoneIdType> childZoneId;
std::vector<ansys::CellType> elementType;
std::vector<std::string> name;
std::vector<std::string> stringZoneType;
// create zone-level information of cells
CreateCellZones(
cellZone, startId, endId, dimension, childZoneId, elementType, name, stringZoneType);
// set the cell zones
cffSetZoneIds(&writer, CFF_CELL_ZONE, cellZone.data(), cellZone.size());
for (size_t iz = 0; iz < cellZone.size(); ++iz) {
cffSetZoneSizeInfo(&writer,
cellZone[iz], CFF_ZONE_START_ID, startId[iz]);
cffSetZoneSizeInfo(&writer,
cellZone[iz], CFF_ZONE_END_ID, endId[iz]);
cffSetZoneSizeInfo(&writer,
cellZone[iz], CFF_ZONE_DIMENSION, dimension[iz]);
if (elementType[iz] >= 0)
cffSetCellZoneInfo(&writer, cellZone[iz],
elementType[iz]);
if (childZoneId[iz] > 0) {
cffSetCellZoneInfo(&writer, cellZone[iz],
childZoneId[iz]);
}
if (!name[iz].empty()) {
cffSetZoneStringInfo(&writer, cellZone[iz],
name[iz].data());
}
if (!stringZoneType[iz].empty()) {
cffSetZoneStringInfo(&writer, cellZone[iz],
stringZoneType[iz].data());
}
}
// start writing about these cell-zones
cffStartWritingCells(&writer, cellZone.data(), cellZone.size());
// cell-types
{
ansys::ZoneIds cellTypeZone;
std::vector<ansys::CellType> zoneCellTypes;
std::vector<std::vector<ansys::CellType> > allCellTypes;
// create cell-type information of appropriate zones;
CreateCellTypes(cellTypeZone, zoneCellTypes, allCellTypes);
cffStartWritingTypesForCells(&writer, cellTypeZone.data(), cellTypeZone.size(), zoneCellTypes.data(), zoneCellTypes.size());
for (size_t iz = 0; iz < cellTypeZone.size(); ++iz) {
if (CFF_CELL_TYPE_MIXED != zoneCellTypes[iz]) {
continue;
}
cffSetTypesForCellsInZone(&writer, cellTypeZone[iz],
&(allCellTypes[iz].at(0)),
allCellTypes[iz].size());
}
cffEndWritingTypesForCells(&writer);
}
// cell-partitions
{
int numPartitions;
std::vector<ansys::ZoneIdType> cellPartitionZone;
std::vector< std::vector<ansys::PartitionIdType> > cellPartitions;
// create cell-partition information of appropriate zones;
CreateCellPartitions(cellPartitionZone, numPartitions, cellPartitions);
cffStartWritingPartitionIdsForCells(&writer, cellPartitionZone.data(), cellPartitionZone.size(),
numPartitions);
if (numPartitions > 1) {
for (size_t iz = 0; iz < cellPartitionZone.size(); ++iz) {
cffSetPartitionIdsForCellsInZone(&writer, cellPartitionZone[iz],
&(cellPartitions[iz].at(0)),
cellPartitions[iz].size());
}
}
cffEndWritingPartitionIdsForCells(&writer);
}
cffEndWritingCells(&writer);
}
cffEndWriting(&writer, CFF_CASE);
// data-file
{
ansys::PhaseNames phaseNames;
std::vector<const char*> phaseNamesChar;
std::vector<const char*> varNamesChar;
// create the phases and get their ids
CreatePhases(phaseNames);
phaseNamesChar.resize(phaseNames.size());
for(size_t i = 0; i<phaseNames.size(); i++)
phaseNamesChar[i] = phaseNames[i].data();
ansys::PhaseIds phaseIds(phaseNames.size());
cffSetPhaseNames(&writer, (const CffPhaseNames)phaseNamesChar.data(), phaseNamesChar.size(), phaseIds.data());
for (size_t ip = 0; ip < phaseIds.size(); ++ip) {
cffStartWritingPhase(&writer, phaseIds[ip]);
std::vector<ansys::ZoneCategory> zoneCategory(2);
zoneCategory[0] = CFF_CELL_ZONE;
zoneCategory[1] = CFF_FACE_ZONE;
for (size_t izc = 0; izc < zoneCategory.size(); ++izc) {
std::vector<std::string> varName;
std::vector<int> varXFID;
CreateVarNames(phaseIds[ip], zoneCategory[izc], varName, varXFID);
varNamesChar.resize(varName.size());
for(size_t i = 0; i<varName.size(); i++) {
varNamesChar[i] = varName[i].data();
}
cffSetPhaseVariablesOfCategoryName(&writer, zoneCategory[izc], (const CffVariableNames)varNamesChar.data(), varNamesChar.size());
for (size_t iv = 0; iv < varName.size(); ++iv) {
ansys::ZoneIds phaseCategoryVarZone;
size_t numColumns;
std::vector<std::vector<double> > data;
CreateVarsForThisCategory(phaseIds[ip],
zoneCategory[izc],
varXFID[iv],
phaseCategoryVarZone,
numColumns,
data);
cffStartWritingPhaseVariableInZonesOfCategory(&writer,
zoneCategory[izc], (const CffVariableName)varName[iv].data(), phaseCategoryVarZone.data(), phaseCategoryVarZone.size(), numColumns);
for (size_t iz = 0; iz < phaseCategoryVarZone.size(); ++iz) {
cffSetValuesOfPhaseVariableForElementsInZone(&writer,
phaseCategoryVarZone[iz], &(data[iz].at(0)), data[iz].size());
}
cffEndWritingPhaseVariableInZonesOfCategory(&writer);
}
}
cffEndWritingPhase(&writer);
}
cffEndWriting(&writer, CFF_RESULTS);
}
if (cffAddStringAttribute(&writer, "write_new.cas.h5", "/meshes/1/faces", "groupAtt", "xyz"))
std::cout <<"writing of groupAtt successful!" << std::endl;
cffFinalizeWriter(&writer);
return 0;
}
CffPhaseName * CffPhaseNames
Type used to represent pointer to multiple phase names ('C' API only)
Definition: CffTypes.h:777
char * CffVariableName
Type used to represent the name of a variable ('C' API only)
Definition: CffTypes.h:806
CffVariableName * CffVariableNames
Type used to represent pointer to multiple variable names ('C' API only)
Definition: CffTypes.h:812