diff --git a/ReleaseNotes-dev b/ReleaseNotes-dev index 227041536f1268daf4b3ab5b1356ea9d9fe131d0..230a1168263fc7d0fe9ad64a916a5b3ef9557263 100644 --- a/ReleaseNotes-dev +++ b/ReleaseNotes-dev @@ -104,6 +104,11 @@ taking film into account + Parallel aware *** *New* ptscotch decomposition method +*** *Updated* scotch decomposition method to run in parallel by doing + decomposition on the master. Unfortunately scotch and ptscotch cannot + be linked in to the same executable. +*** *Updated* simple decomposition method to run in parallel by doing + decomposition on the master. *** *Updated* decomposePar maps polyPatches instead of recreating them so polyPatches holding data can map the data. *** *Updated* particle tracking algorithm @@ -183,6 +188,9 @@ e.g. pitzDailyDirectMapped tutorial. + =setSet=: allows time range (e.g. 0:100) in combination with -batch argument to execute the commands for multiple times. + + =extrudeMesh=: + - option to add extrusion to existing mesh. + - works in parallel * Post-processing + =paraFoam=, =foamToVTK=: full support for polyhedral cell type in recent Paraview versions. diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/alphaEqn.H b/applications/solvers/multiphase/twoPhaseEulerFoam/alphaEqn.H index cac8e52a8efb7d6a1b9115afc595e4b4617f88eb..8f1ad9df8e3387677a5e4d1b9f61e88236dd3524 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/alphaEqn.H +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/alphaEqn.H @@ -2,8 +2,8 @@ word scheme("div(phi,alpha)"); word schemer("div(phir,alpha)"); - surfaceScalarField phic(phi); - surfaceScalarField phir(phia - phib); + surfaceScalarField phic("phic", phi); + surfaceScalarField phir("phir", phia - phib); if (g0.value() > 0.0) { @@ -41,7 +41,7 @@ alphaEqn.relax(); alphaEqn.solve(); -# include "packingLimiter.H" + #include "packingLimiter.H" beta = scalar(1) - alpha; diff --git a/applications/test/Polynomial/Test-Polynomial.C b/applications/test/Polynomial/Test-Polynomial.C index fbfbcc20006505bcabf9ff34e117f7021bbf6dab..c251bade747cf2f98202b662c3d74176b2c3fb0c 100644 --- a/applications/test/Polynomial/Test-Polynomial.C +++ b/applications/test/Polynomial/Test-Polynomial.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -31,6 +31,7 @@ Description #include "IStringStream.H" #include "Polynomial.H" +#include "polynomialFunction.H" #include "Random.H" #include "cpuTime.H" @@ -38,7 +39,7 @@ using namespace Foam; const int PolySize = 8; const scalar coeff[] = { 0.11, 0.45, -0.94, 1.58, -2.58, 0.08, 3.15, -4.78 }; -const char* polyDef = "testPoly (0.11 0.45 -0.94 1.58 -2.58 0.08 3.15 -4.78)"; +const char* polyDef = "(0.11 0.45 -0.94 1.58 -2.58 0.08 3.15 -4.78)"; scalar polyValue(const scalar x) @@ -58,7 +59,7 @@ scalar polyValue(const scalar x) scalar intPolyValue(const scalar x) { - // Hard-coded integrated form of above polynomial + // Hard-coded integral form of above polynomial return coeff[0]*x + coeff[1]/2.0*sqr(x) @@ -109,27 +110,44 @@ int main(int argc, char *argv[]) const label nIters = 1000; scalar sum = 0.0; - Info<< "null poly = " << (Polynomial<8>()) << nl << endl; + Info<< "null poly = " << (Polynomial<8>()) << nl + << "null poly = " << (polynomialFunction(8)) << nl + << endl; - // Polynomial<8> poly("testPoly", IStringStream(polyDef)()); Polynomial<8> poly(coeff); - Polynomial<9> intPoly(poly.integrate(0.0)); + Polynomial<9> intPoly(poly.integral(0.0)); - Info<< "poly = " << poly << endl; - Info<< "intPoly = " << intPoly << nl << endl; + IStringStream is(polyDef); + polynomialFunction polyfunc(is); - Info<< "2*poly = " << 2*poly << endl; - Info<< "poly+poly = " << poly + poly << nl << endl; + Info<< "poly = " << poly << nl + << "intPoly = " << intPoly << nl + << endl; - Info<< "3*poly = " << 3*poly << endl; - Info<< "poly+poly+poly = " << poly + poly + poly << nl << endl; + Info<< "2*poly = " << 2*poly << nl + << "poly+poly = " << poly + poly << nl + << "3*poly = " << 3*poly << nl + << "poly+poly+poly = " << poly + poly + poly << nl + << "3*poly - 2*poly = " << 3*poly - 2*poly << nl + << endl; + + Info<< nl << "--- as polynomialFunction" << nl << endl; + Info<< "polyf = " << polyfunc << nl + << "intPoly = " << poly.integral(0.0) << nl + << endl; + + Info<< "2*polyf = " << 2*polyfunc << nl + << "polyf+polyf = " << polyfunc + polyfunc << nl + << "3*polyf = " << 3*polyfunc << nl + << "polyf+polyf+polyf = " << polyfunc + polyfunc + polyfunc << nl + << "3*polyf - 2*polyf = " << 3*polyfunc - 2*polyfunc << nl + << endl; - Info<< "3*poly - 2*poly = " << 3*poly - 2*poly << nl << endl; Polynomial<8> polyCopy = poly; Info<< "poly, polyCopy = " << poly << ", " << polyCopy << nl << endl; polyCopy = 2.5*poly; - Info<< "2.5*polyCopy = " << polyCopy << nl << endl; + Info<< "2.5*poly = " << polyCopy << nl << endl; Random rnd(123456); for (int i=0; i<10; i++) @@ -139,8 +157,8 @@ int main(int argc, char *argv[]) scalar px = polyValue(x); scalar ipx = intPolyValue(x); - scalar pxTest = poly.evaluate(x); - scalar ipxTest = intPoly.evaluate(x); + scalar pxTest = poly.value(x); + scalar ipxTest = intPoly.value(x); Info<<"\nx = " << x << endl; Info<< " px, pxTest = " << px << ", " << pxTest << endl; @@ -173,10 +191,21 @@ int main(int argc, char *argv[]) sum = 0.0; for (label iter = 0; iter < nIters; ++iter) { - sum += poly.evaluate(loop+iter); + sum += poly.value(loop+iter); + } + } + Info<< "value: " << sum + << " in " << timer.cpuTimeIncrement() << " s\n"; + + for (int loop = 0; loop < n; ++loop) + { + sum = 0.0; + for (label iter = 0; iter < nIters; ++iter) + { + sum += polyfunc.value(loop+iter); } } - Info<< "evaluate: " << sum + Info<< "via function: " << sum << " in " << timer.cpuTimeIncrement() << " s\n"; diff --git a/applications/test/syncTools/Test-syncTools.C b/applications/test/syncTools/Test-syncTools.C index 6f9d5f408a802e5e2c08b79b264952138073b0af..2638f0fb67ef3aeb939afdc118feb61b84a3f2f4 100644 --- a/applications/test/syncTools/Test-syncTools.C +++ b/applications/test/syncTools/Test-syncTools.C @@ -210,7 +210,7 @@ void testSparseData(const polyMesh& mesh, Random& rndGen) { // Create some data. Use slightly perturbed positions. Map<point> sparseData; - pointField fullData(mesh.nPoints(), point::max); + pointField fullData(mesh.nPoints(), point(GREAT, GREAT, GREAT)); forAll(localPoints, i) { @@ -236,7 +236,7 @@ void testSparseData(const polyMesh& mesh, Random& rndGen) mesh, fullData, minMagSqrEqOp<point>(), - point::max + point(GREAT, GREAT, GREAT) // true // apply separation ); @@ -246,7 +246,7 @@ void testSparseData(const polyMesh& mesh, Random& rndGen) { const point& fullPt = fullData[meshPointI]; - if (fullPt != point::max) + if (fullPt != point(GREAT, GREAT, GREAT)) { const point& sparsePt = sparseData[meshPointI]; @@ -286,7 +286,7 @@ void testSparseData(const polyMesh& mesh, Random& rndGen) { // Create some data. Use slightly perturbed positions. EdgeMap<point> sparseData; - pointField fullData(mesh.nEdges(), point::max); + pointField fullData(mesh.nEdges(), point(GREAT, GREAT, GREAT)); const edgeList& edges = allBoundary.edges(); const labelList meshEdges = allBoundary.meshEdges @@ -320,7 +320,7 @@ void testSparseData(const polyMesh& mesh, Random& rndGen) mesh, fullData, minMagSqrEqOp<point>(), - point::max + point(GREAT, GREAT, GREAT) ); // Compare. @@ -329,7 +329,7 @@ void testSparseData(const polyMesh& mesh, Random& rndGen) { const point& fullPt = fullData[meshEdgeI]; - if (fullPt != point::max) + if (fullPt != point(GREAT, GREAT, GREAT)) { const point& sparsePt = sparseData[mesh.edges()[meshEdgeI]]; @@ -385,7 +385,7 @@ void testPointSync(const polyMesh& mesh, Random& rndGen) mesh, syncedPoints, minMagSqrEqOp<point>(), - point::max + point(GREAT, GREAT, GREAT) ); forAll(syncedPoints, pointI) @@ -461,7 +461,7 @@ void testEdgeSync(const polyMesh& mesh, Random& rndGen) mesh, syncedMids, minMagSqrEqOp<point>(), - point::max + point(GREAT, GREAT, GREAT) ); forAll(syncedMids, edgeI) diff --git a/applications/utilities/mesh/conversion/foamToStarMesh/foamToStarMesh.C b/applications/utilities/mesh/conversion/foamToStarMesh/foamToStarMesh.C index b154a3816d7323d06f25619fd4506c225765b5e9..af4985dd4331d19c115c34761c63455940e651b7 100644 --- a/applications/utilities/mesh/conversion/foamToStarMesh/foamToStarMesh.C +++ b/applications/utilities/mesh/conversion/foamToStarMesh/foamToStarMesh.C @@ -40,7 +40,7 @@ Usage Note The cellTable information available in the files - \c constant/cellTable and @c constant/polyMesh/cellTableId + \c constant/cellTable and \c constant/polyMesh/cellTableId will be used if available. Otherwise the cellZones are used when creating the cellTable information. diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C index 8a7296eca00a1627cdc50abb9e53a27c9ad0ec64..5804d962c81949135978a2a61af2ec67b2c68221 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C @@ -43,6 +43,7 @@ Description #include "addPatchCellLayer.H" #include "fvMesh.H" #include "MeshedSurfaces.H" +#include "globalIndex.H" #include "extrudedMesh.H" #include "extrudeModel.H" @@ -261,6 +262,12 @@ int main(int argc, char *argv[]) sourceCasePath.expand(); fileName sourceRootDir = sourceCasePath.path(); fileName sourceCaseDir = sourceCasePath.name(); + if (Pstream::parRun()) + { + sourceCaseDir = + sourceCaseDir + /"processor" + Foam::name(Pstream::myProcNo()); + } wordList sourcePatches; dict.lookup("sourcePatches") >> sourcePatches; @@ -279,54 +286,173 @@ int main(int argc, char *argv[]) sourceRootDir, sourceCaseDir ); + #include "createMesh.H" const polyBoundaryMesh& patches = mesh.boundaryMesh(); - // Topo change container. Either copy an existing mesh or start - // with empty storage (number of patches only needed for checking) - autoPtr<polyTopoChange> meshMod - ( - ( - mode == MESH - ? new polyTopoChange(mesh) - : new polyTopoChange(patches.size()) - ) - ); - // Extrusion engine. Either adding to existing mesh or // creating separate mesh. addPatchCellLayer layerExtrude(mesh, (mode == MESH)); + const labelList meshFaces(patchFaces(patches, sourcePatches)); indirectPrimitivePatch extrudePatch ( IndirectList<face> ( mesh.faces(), - patchFaces(patches, sourcePatches) + meshFaces ), mesh.points() ); + // Determine extrudePatch normal + pointField extrudePatchPointNormals + ( + PatchTools::pointNormals //calcNormals + ( + mesh, + extrudePatch, + meshFaces + ) + ); + + + // Precalculate mesh edges for pp.edges. + const labelList meshEdges + ( + extrudePatch.meshEdges + ( + mesh.edges(), + mesh.pointEdges() + ) + ); + + // Global face indices engine + const globalIndex globalFaces(mesh.nFaces()); + + // Determine extrudePatch.edgeFaces in global numbering (so across + // coupled patches) + labelListList edgeGlobalFaces + ( + addPatchCellLayer::globalEdgeFaces + ( + mesh, + globalFaces, + extrudePatch + ) + ); + + + // Determine what patches boundary edges need to get extruded into. + // This might actually cause edge-connected processors to become + // face-connected so might need to introduce new processor boundaries. + // Calculates: + // - per pp.edge the patch to extrude into + // - any additional processor boundaries (patchToNbrProc = map from + // new patchID to neighbour processor) + // - number of new patches (nPatches) + + labelList sidePatchID; + label nPatches; + Map<label> nbrProcToPatch; + Map<label> patchToNbrProc; + addPatchCellLayer::calcSidePatch + ( + mesh, + globalFaces, + edgeGlobalFaces, + extrudePatch, + + sidePatchID, + nPatches, + nbrProcToPatch, + patchToNbrProc + ); + + + // Add any patches. + + label nAdded = nPatches - mesh.boundaryMesh().size(); + reduce(nAdded, sumOp<label>()); + + Info<< "Adding overall " << nAdded << " processor patches." << endl; + + if (nAdded > 0) + { + DynamicList<polyPatch*> newPatches(nPatches); + forAll(mesh.boundaryMesh(), patchI) + { + newPatches.append + ( + mesh.boundaryMesh()[patchI].clone + ( + mesh.boundaryMesh() + ).ptr() + ); + } + for + ( + label patchI = mesh.boundaryMesh().size(); + patchI < nPatches; + patchI++ + ) + { + label nbrProcI = patchToNbrProc[patchI]; + word name = + "procBoundary" + + Foam::name(Pstream::myProcNo()) + + "to" + + Foam::name(nbrProcI); + + Pout<< "Adding patch " << patchI + << " name:" << name + << " between " << Pstream::myProcNo() + << " and " << nbrProcI + << endl; + + + newPatches.append + ( + new processorPolyPatch + ( + name, + 0, // size + mesh.nFaces(), // start + patchI, // index + mesh.boundaryMesh(),// polyBoundaryMesh + Pstream::myProcNo(),// myProcNo + nbrProcI // neighbProcNo + ) + ); + } + + // Add patches. Do no parallel updates. + mesh.removeFvBoundary(); + mesh.addFvPatches(newPatches, true); + } + + + // Only used for addPatchCellLayer into new mesh - labelList exposedPatchIDs; + labelList exposedPatchID; if (mode == PATCH) { dict.lookup("exposedPatchName") >> backPatchName; - exposedPatchIDs.setSize + exposedPatchID.setSize ( extrudePatch.size(), findPatchID(patches, backPatchName) ); } - + // Determine points and extrusion pointField layer0Points(extrudePatch.nPoints()); pointField displacement(extrudePatch.nPoints()); forAll(displacement, pointI) { - const vector& patchNormal = extrudePatch.pointNormals()[pointI]; + const vector& patchNormal = extrudePatchPointNormals[pointI]; // layer0 point layer0Points[pointI] = model() @@ -373,15 +499,31 @@ int main(int argc, char *argv[]) // Layers per point labelList nPointLayers(extrudePatch.nPoints(), model().nLayers()); // Displacement for first layer - vectorField firstLayerDisp(displacement*model().sumThickness(1)); + vectorField firstLayerDisp = displacement*model().sumThickness(1); + // Expansion ratio not used. scalarField ratio(extrudePatch.nPoints(), 1.0); + // Topo change container. Either copy an existing mesh or start + // with empty storage (number of patches only needed for checking) + autoPtr<polyTopoChange> meshMod + ( + ( + mode == MESH + ? new polyTopoChange(mesh) + : new polyTopoChange(patches.size()) + ) + ); + layerExtrude.setRefinement ( + globalFaces, + edgeGlobalFaces, + ratio, // expansion ratio extrudePatch, // patch faces to extrude - exposedPatchIDs, // if new mesh: patches for exposed faces + sidePatchID, // if boundary edge: patch to use + exposedPatchID, // if new mesh: patches for exposed faces nFaceLayers, nPointLayers, firstLayerDisp, @@ -401,7 +543,7 @@ int main(int argc, char *argv[]) model() ( extrudePatch.localPoints()[pointI], - extrudePatch.pointNormals()[pointI], + extrudePatchPointNormals[pointI], pPointI+1 // layer ) ); diff --git a/applications/utilities/mesh/manipulation/insideCells/insideCells.C b/applications/utilities/mesh/manipulation/insideCells/insideCells.C index 967240701ec1f68a236f819aa5a6319aad28a350..16a37594d8f10445d76cfee617cd5869eadae4ca 100644 --- a/applications/utilities/mesh/manipulation/insideCells/insideCells.C +++ b/applications/utilities/mesh/manipulation/insideCells/insideCells.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -22,8 +22,8 @@ License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. Description - Picks up cells with cell centre 'inside' of surface. Requires surface - to be closed and singly connected. + Picks up cells with cell centre 'inside' of surface. + Requires surface to be closed and singly connected. \*---------------------------------------------------------------------------*/ @@ -42,9 +42,16 @@ using namespace Foam; int main(int argc, char *argv[]) { + argList::addNote + ( + "Create a cellSet for cells with their centres inside the defined " + "surface.\n" + "Surface must be closed and singly connected." + ); + argList::noParallel(); - argList::validArgs.append("surface file"); - argList::validArgs.append("destination cellSet"); + argList::validArgs.append("surfaceFile"); + argList::validArgs.append("cellSet"); # include "setRootCase.H" # include "createTime.H" @@ -75,14 +82,13 @@ int main(int argc, char *argv[]) } - Info<< "Selected " << insideCells.size() - << " cells out of " << mesh.nCells() << endl - << endl + Info<< "Selected " << insideCells.size() << " of " << mesh.nCells() + << " cells" << nl << nl << "Writing selected cells to cellSet " << insideCells.name() - << endl << endl - << "Use this cellSet e.g. with subsetMesh : " << endl << endl - << " subsetMesh <root> <case> " << insideCells.name() - << endl << endl; + << nl << nl + << "Use this cellSet e.g. with subsetMesh : " << nl << nl + << " subsetMesh " << insideCells.name() + << nl << endl; insideCells.write(); diff --git a/applications/utilities/miscellaneous/foamDebugSwitches/Make/options b/applications/utilities/miscellaneous/foamDebugSwitches/Make/options index 826bc4c144f01bf27c3e9f1ac301e3c612c58611..e0635ddb6e23ad60ad8541e5eb9c1ef9ddfb93a8 100644 --- a/applications/utilities/miscellaneous/foamDebugSwitches/Make/options +++ b/applications/utilities/miscellaneous/foamDebugSwitches/Make/options @@ -1,6 +1,7 @@ EXE_LIBS = \ -lautoMesh \ -lbarotropicCompressibilityModel \ + -lbasicSolidThermo \ -lbasicThermophysicalModels \ -lblockMesh \ -lchemistryModel \ @@ -11,15 +12,19 @@ EXE_LIBS = \ -lconversion \ -ldecompositionMethods \ -ldieselSpray \ + -ldistributed \ + -ldistributionModels \ -ldsmc \ -ldynamicFvMesh \ -ldynamicMesh \ -ledgeMesh \ -lengine \ -lerrorEstimation \ + -lextrudeModel \ -lfieldFunctionObjects \ -lfileFormats \ -lfiniteVolume \ + -lfoamCalcFunctions \ -lforces \ -lfvMotionSolvers \ -lgenericPatchFields \ @@ -29,6 +34,8 @@ EXE_LIBS = \ -lincompressibleTurbulenceModel \ -linterfaceProperties \ -lIOFunctionObjects \ + -ljobControl \ + -lkineticTheoryModel \ -llagrangian \ -llagrangianIntermediate \ -llaminarFlameSpeedModels \ @@ -37,22 +44,29 @@ EXE_LIBS = \ -lliquidMixtureProperties \ -lliquidProperties \ -lmeshTools \ + -lMGridGenGAMGAgglomeration \ -lmolecularMeasurements \ -lmolecule \ + -lmultiphaseInterFoam \ -lODE \ -lOpenFOAM \ - -ldistributionModels \ + -lphaseModel \ -lpotential \ -lradiationModels \ -lrandomProcesses \ -lreactionThermophysicalModels \ + -lreconstruct \ -lsampling \ + -lSLGThermo \ -lsolidMixtureProperties \ -lsolidParticle \ -lsolidProperties \ + -lsolid \ -lspecie \ + -lsurfaceFilmModels \ -lsurfMesh \ -lsystemCall \ + -ltabulatedWallFunctions \ -lthermalPorousZone \ -lthermophysicalFunctions \ -ltopoChangerFvMesh \ diff --git a/applications/utilities/parallelProcessing/redistributeMeshPar/redistributeMeshPar.C b/applications/utilities/parallelProcessing/redistributeMeshPar/redistributeMeshPar.C index f429d63f571b97ff373e48d25d8da5fede364357..11922c3c380dc55c9df1c77d9ad102929f8a7c70 100644 --- a/applications/utilities/parallelProcessing/redistributeMeshPar/redistributeMeshPar.C +++ b/applications/utilities/parallelProcessing/redistributeMeshPar/redistributeMeshPar.C @@ -73,8 +73,8 @@ autoPtr<fvMesh> createMesh const bool haveMesh ) { - Pout<< "Create mesh for time = " - << runTime.timeName() << nl << endl; + //Pout<< "Create mesh for time = " + // << runTime.timeName() << nl << endl; IOobject io ( @@ -98,12 +98,12 @@ autoPtr<fvMesh> createMesh xferCopy(labelList()), false ); - Pout<< "Writing dummy mesh to " << dummyMesh.polyMesh::objectPath() - << endl; + //Pout<< "Writing dummy mesh to " << dummyMesh.polyMesh::objectPath() + // << endl; dummyMesh.write(); } - Pout<< "Reading mesh from " << io.objectPath() << endl; + //Pout<< "Reading mesh from " << io.objectPath() << endl; autoPtr<fvMesh> meshPtr(new fvMesh(io)); fvMesh& mesh = meshPtr(); @@ -201,9 +201,8 @@ autoPtr<fvMesh> createMesh break; } - Pout<< "Adding patch:" << nPatches - << " name:" << name - << " type:" << type << endl; + //Pout<< "Adding patch:" << nPatches + // << " name:" << name << " type:" << type << endl; dictionary patchDict(e.dict()); patchDict.remove("nFaces"); @@ -282,8 +281,7 @@ autoPtr<fvMesh> createMesh if (!haveMesh) { // We created a dummy mesh file above. Delete it. - Pout<< "Removing dummy mesh " << io.objectPath() - << endl; + //Pout<< "Removing dummy mesh " << io.objectPath() << endl; rmDir(io.objectPath()); } @@ -351,17 +349,19 @@ scalar getMergeDistance } -void printMeshData(Ostream& os, const polyMesh& mesh) -{ - os << "Number of points: " << mesh.points().size() << nl - << " faces: " << mesh.faces().size() << nl - << " internal faces: " << mesh.faceNeighbour().size() << nl - << " cells: " << mesh.cells().size() << nl - << " boundary patches: " << mesh.boundaryMesh().size() << nl - << " point zones: " << mesh.pointZones().size() << nl - << " face zones: " << mesh.faceZones().size() << nl - << " cell zones: " << mesh.cellZones().size() << nl; -} +//void printMeshData(Ostream& os, const polyMesh& mesh) +//{ +// os << "Number of points: " << mesh.points().size() << nl +// << " faces: " << mesh.faces().size() << nl +// << " internal faces: " << mesh.faceNeighbour().size() << nl +// << " cells: " << mesh.cells().size() << nl +// << " boundary patches: " << mesh.boundaryMesh().size() << nl +// << " point zones: " << mesh.pointZones().size() << nl +// << " face zones: " << mesh.faceZones().size() << nl +// << " cell zones: " << mesh.cellZones().size() << nl; +//} + + void printMeshData(const polyMesh& mesh) { // Collect all data on master @@ -525,6 +525,7 @@ void readFields // Receive field IPstream fromMaster(Pstream::blocking, Pstream::masterNo()); + dictionary fieldDict(fromMaster); fields.set ( @@ -540,7 +541,7 @@ void readFields IOobject::AUTO_WRITE ), mesh, - fromMaster + fieldDict ) ); @@ -916,8 +917,8 @@ int main(int argc, char *argv[]) // Mesh distribution engine fvMeshDistribute distributor(mesh, tolDim); - Pout<< "Wanted distribution:" - << distributor.countCells(finalDecomp) << nl << endl; + //Pout<< "Wanted distribution:" + // << distributor.countCells(finalDecomp) << nl << endl; // Do actual sending/receiving of mesh autoPtr<mapDistributePolyMesh> map = distributor.distribute(finalDecomp); @@ -987,7 +988,7 @@ int main(int argc, char *argv[]) Info<< endl; - Pout<< "End\n" << endl; + Info<< "End\n" << endl; return 0; } diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/Allwmake b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/Allwmake new file mode 100755 index 0000000000000000000000000000000000000000..935e8e3993a65f7b1e55d49fc929f166372fe807 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/Allwmake @@ -0,0 +1,14 @@ +#!/bin/sh +# +# Build optional components (eg, may depend on third-party libraries) +# ----------------------------------------------------------------------------- +cd ${0%/*} || exit 1 # run from this directory +set -x + +# build tecio +wmake libso tecio/tecsrc + +# build converter +wmake + +# ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/Make/options b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/Make/options index 97a2251f7bb9bf8d90bb23bd4ddbccf3c74a04a9..4776ad7d6489cf454920225a179ab1e304ebefff 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/Make/options +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/Make/options @@ -1,5 +1,5 @@ EXE_INC = \ - -I$(WM_THIRD_PARTY_DIR)/tecio/tecsrc/lnInclude \ + -Itecio/tecsrc/lnInclude \ -I$(LIB_SRC)/lagrangian/basic/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude @@ -10,4 +10,4 @@ EXE_LIBS = \ -lfiniteVolume \ -lgenericPatchFields \ -lmeshTools \ - -L$(FOAM_EXT_LIBBIN) -ltecio + -ltecio diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/Runmake b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/Runmake new file mode 100755 index 0000000000000000000000000000000000000000..a22d0c0a86288ab89b2d61fa5da55e25ce42ced7 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/Runmake @@ -0,0 +1,277 @@ +#!/bin/sh + +MAKEWHAT= +EXTRAFLAGS= +STRIPFLAG=-s +isrelease=n +skipcompile=n +if test $# -ge 1 ; then + Platname=$1 + shift + while test $# -ge 1 + do + if test "$1" = "-release" ; then + isrelease=y + elif test "$1" = "-skipcompile" ; then + skipcompile=y + elif test "$1" = "-tecio" ; then + MAKEWHAT=tecio.a + else + EXTRAFLAGS="$EXTRAFLAGS $1" + fi + shift + done +else + echo "Choose platform:" + echo " " + echo " macux.104" + echo " macix64.105" + echo " sgix.62" + echo " sgix3.62" + echo " sgix.65" + echo " sgix64.65" + echo " sgix2.65" + echo " sun4.57" + echo " sun464.57" + echo " sun86.54" + echo " ibmx.43" + echo " ibmx64.43" + echo " ibmx.51" + echo " ibmx64.51" + echo " ibmx64.53" + echo " decalpha.32" + echo " compaq.51" + echo " hp7xx.11" + echo " hp7xx64.11" + echo " hpi64.11" + echo " linux.24" + echo " linuxi64.24" + echo " linux.22" + echo " linuxa.22" + echo " linuxg248x64.26" + echo " linuxg27x64.26" + echo " crayc90" + echo "->\c" + read Platname + + echo "Choose:" + echo " 1. Make tecio.a only" + echo " 2. Make tecio.a and pltview" + + read choice + + if test $choice -eq 1 ;then + MAKEWHAT=tecio.a + fi +fi + +MAKECMD=make +LINKFLAGS= +LINKLIBS= +AR=ar +ARFLAGS=qv +DISTSUBDIR2= + +case $Platname in + mac*) CCOMP=g++ + FINALCFLAGS="-arch ppc -arch i386 -arch ppc64 -arch x86_64 -DDARWIN -DLONGIS64 -I/usr/X11R6/include" + STRIPFLAG=-Wl,-x + LINKFLAGS="-arch ppc -arch i386 -arch ppc64 -arch x86_64" + ;; + sgix.65-64) CCOMP=CC + FINALCFLAGS="-DIRISX -DLONGIS64 -mips4 -64" + LINKFLAGS="-mips4 -64" + ;; + sgix64.65) CCOMP=CC + FINALCFLAGS="-DIRISX -DLONGIS64 -mips4 -64" + LINKFLAGS="-mips4 -64" + ;; + sgix.65) CCOMP=CC + FINALCFLAGS="-DIRISX -mips4 -n32" + LINKFLAGS="-mips4 -n32" + ;; + sgix2.65) CCOMP=CC + FINALCFLAGS="-DIRISX -o32" + LINKFLAGS="-o32" + ;; + sgix.62-64) CCOMP=CC + FINALCFLAGS="-DIRISX -DIRIX62 -DLONGIS64 -mips4 -64" + LINKFLAGS="-mips4 -64" + ;; + sgix.62) CCOMP=CC + FINALCFLAGS="-DIRISX -DIRIX62 -mips4 -n32" + LINKFLAGS="-mips4 -n32" + ;; + sgix1.62) CCOMP=CC + FINALCFLAGS="-DIRISX -DIRIX62 -mips1 -32" + LINKFLAGS="-mips1 -32" + ;; + sgix3.62) CCOMP=CC + FINALCFLAGS="-DIRISX -DIRIX62 -mips3 -n32" + LINKFLAGS="-mips3 -n32" + ;; + ibmx.*) CCOMP=xlC + FINALCFLAGS=-DIBMRS6000X + ;; + ibmx64.*) CCOMP=xlC + FINALCFLAGS="-DIBMRS6000X -DLONGIS64 -q64" + ARFLAGS="-X64 qv" + ;; + compaq.51) CCOMP=cxx + FINALCFLAGS="-DCOMPAQX -I/usr/include -ieee_with_inexact" + ;; + decalpha.32)CCOMP=cc + FINALCFLAGS="-DDECALPHAX -I/usr/include -ieee_with_inexact" + ;; + hp7xx.*-64) CCOMP=aCC + FINALCFLAGS="+DD64 +DS2.0 -AA -DHPX -DLONGIS64 -I/usr/include/X11R6 -I/usr/include/Motif2.1" + LINKFLAGS="+DA2.0W +DD64 +DS2.0W" + ;; + hp7xx64.11) CCOMP=aCC + FINALCFLAGS="+DA2.0W +DD64 +DS2.0W -AA -DHPX -DLONGIS64 -I/usr/include/X11R6 -I/usr/include/Motif2.1" + LINKFLAGS="+DA2.0W +DD64 +DS2.0W" + ;; + hpi64.11) CCOMP=aCC + FINALCFLAGS="+DD64 -AA -DHPX -DLONGIS64 -I/usr/include/X11R6 -I/usr/include/Motif2.1" + LINKFLAGS="+DD64" + ;; + hp7xx.11) CCOMP=aCC + FINALCFLAGS="+DAportable -AA -DHPX -I/usr/include/X11R6 -I/usr/include/Motif2.1" + LINKFLAGS="+DAportable" + ;; + crayc90) CCOMP=cc + FINALCFLAGS="-DCRAY -DUNIXX" + ;; + linux*i64.*)CCOMP=g++ + FINALCFLAGS="-fPIC -DLINUX -DLINUXI64" + ;; + linux*64.*) CCOMP=g++ + FINALCFLAGS="-fPIC -DLINUX -DLINUX64" + ;; + linux*) CCOMP=g++ + FINALCFLAGS="-fPIC -DLINUX" + ;; + sun4.54) CCOMP=/opt/SUNWspro/bin/CC + FINALCFLAGS="-DSUN -DSUNSOLARISX -I/usr/openwin/include -I/usr/dt/include -library=libC -library=Cstd -library=no%rwtools7 -library=no%rwtools7_dbg -xO1" + LINKFLAGS="-library=libC -library=Cstd -library=no%rwtools7 -library=no%rwtools7_dbg" + MAKECMD=/usr/ccs/bin/make + AR=/opt/SUNWspro/bin/CC + ARFLAGS="-xar -o" + ;; + sun4.55) CCOMP=/opt/SUNWspro/bin/CC + FINALCFLAGS="-DSUN -DSUNSOLARISX -I/usr/openwin/include -I/usr/dt/include -library=libC -library=Cstd -library=no%rwtools7 -library=no%rwtools7_dbg -xO1" + LINKFLAGS="-library=libC -library=Cstd -library=no%rwtools7 -library=no%rwtools7_dbg" + MAKECMD=/usr/ccs/bin/make + AR=/opt/SUNWspro/bin/CC + ARFLAGS="-xar -o" + ;; + sun4.57) CCOMP=/opt/SUNWspro/bin/CC + FINALCFLAGS="-DSUNSOLARISX -I/usr/openwin/include -I/usr/dt/include -library=libC -library=Cstd -library=no%rwtools7 -library=no%rwtools7_dbg -xO1" + LINKFLAGS="-library=libC -library=Cstd -library=no%rwtools7 -library=no%rwtools7_dbg" + MAKECMD=/usr/ccs/bin/make + AR=/opt/SUNWspro/bin/CC + ARFLAGS="-xar -o" + ;; + sun4.57-64) CCOMP=/opt/SUNWspro/bin/CC + FINALCFLAGS="-DSUNSOLARISX -DLONGIS64 -KPIC -xarch=v9 -I/usr/openwin/include -I/usr/dt/include -library=libC -library=Cstd -library=no%rwtools7 -library=no%rwtools7_dbg -xO1" + LINKFLAGS="-KPIC -xarch=v9 -library=libC -library=Cstd -library=no%rwtools7 -library=no%rwtools7_dbg" + MAKECMD=/usr/ccs/bin/make + AR=/opt/SUNWspro/bin/CC + ARFLAGS="-xar -o" + ;; + sun464.57) CCOMP=/opt/SUNWspro/bin/CC + FINALCFLAGS="-DSUNSOLARISX -DLONGIS64 -KPIC -xarch=v9 -I/usr/openwin/include -I/usr/dt/include -library=libC -library=Cstd -library=no%rwtools7 -library=no%rwtools7_dbg -xO1" + LINKFLAGS="-KPIC -xarch=v9 -library=libC -library=Cstd -library=no%rwtools7 -library=no%rwtools7_dbg" + MAKECMD=/usr/ccs/bin/make + AR=/opt/SUNWspro/bin/CC + ARFLAGS="-xar -o" + ;; + sun464.59) CCOMP=/opt/SUNWspro/bin/CC + FINALCFLAGS="-DSUNSOLARISX -DLONGIS64 -KPIC -m64 -xarch=generic -I/usr/openwin/include -I/usr/dt/include -library=libC -library=Cstd -library=no%rwtools7 -library=no%rwtools7_dbg -xO1" + LINKFLAGS="-KPIC -m64 -xarch=generic -library=libC -library=Cstd -library=no%rwtools7 -library=no%rwtools7_dbg" + MAKECMD=/usr/ccs/bin/make + AR=/opt/SUNWspro/bin/CC + ARFLAGS="-xar -o" + ;; + sun86.54) CCOMP=/opt/SUNWspro/bin/CC + FINALCFLAGS="-DSUN -DSUNSOLARISX -I/usr/openwin/include -I/usr/dt/include" + MAKECMD=/usr/ccs/bin/make + AR=/opt/SUNWspro/bin/CC + ARFLAGS="-xar -o" + ;; + *) echo "Err: Invalid platform" + exit + ;; +esac + +if test "$isrelease" = "y" ; then + EXTRAFLAGS="$EXTRAFLAGS -DNO_ASSERTS" +else + STRIPFLAG= +fi + +if test "$skipcompile" = "n" ; then + rm -f *.o */*.o *.a > /dev/null 2>&1 +fi + +rm -f *.a > /dev/null 2>&1 + + + +FINALCFLAGS="$FINALCFLAGS $EXTRAFLAGS -DUSEENUM -DTHREED" +# +# NOTE: Used to use make here but had problems with using remsh to run +# make multiple times to get 64 bit and 32 bit versions of libraries.... +# +# $MAKECMD $MAKEWHAT AR=$AR CC=$CCOMP LINKFLAGS="$LINKFLAGS" STRIPFLAG=$STRIPFLAG CFLAGS="$EXTRAFLAGS -DUSEENUM -DTHREED $FINALCFLAGS" +# +# +# + +cd tecsrc + +BASELIST=`/bin/ls -1 *.cpp` + +OBJLIST= +for file in $BASELIST +do + OBJNAME=`echo $file | sed 's/\.cpp/.o/'` + OBJLIST="$OBJLIST tecsrc/$OBJNAME" +done + + + +if test "$skipcompile" = "n" ; then + for file in $BASELIST + do + case $file in + tecxxx.cpp) ARCHIVEFLAG=-DMAKEARCHIVE;; + arrlist.cpp) ARCHIVEFLAG=-DMAKEARCHIVE;; + datautil.cpp) ARCHIVEFLAG=-DMAKEARCHIVE;; + *) ARCHIVEFLAG= ;; + esac + echo "$CCOMP $FINALCFLAGS $ARCHIVEFLAG -c $file" + $CCOMP $FINALCFLAGS $ARCHIVEFLAG -c $file + done +fi + +cd .. + +pwd + + +echo "$AR $ARFLAGS tecio.a $OBJLIST" +$AR $ARFLAGS tecio.a $OBJLIST +if test -f /bin/ranlib ; then + /bin/ranlib tecio.a; +elif test -f /usr/bin/ranlib ; then + /usr/bin/ranlib tecio.a; +elif test -f /usr/ucb/ranlib ; then + /usr/ucb/ranlib tecio.a; +fi + +echo "$CCOMP -I./tecsrc -DMAKEARCHIVE $FINALCFLAGS -c pltview.cpp" +$CCOMP -I./tecsrc -DMAKEARCHIVE $FINALCFLAGS -c pltview.cpp + +echo "$CCOMP $FINALCFLAGS pltview.o tecio.a $LINKFLAGS $LINKLIBS $STRIPFLAG -lm -o pltview" +$CCOMP $FINALCFLAGS pltview.o tecio.a $LINKFLAGS $LINKLIBS $STRIPFLAG -lm -o pltview diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/arrow/Arrow.plt b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/arrow/Arrow.plt new file mode 100644 index 0000000000000000000000000000000000000000..ee207b04df6aaba46a2454f97f3ce51226b5c642 Binary files /dev/null and b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/arrow/Arrow.plt differ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/arrow/Makefile b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/arrow/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..3fa4b11f3f00acbc7f1421864d34acb54a09bcaa --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/arrow/Makefile @@ -0,0 +1,11 @@ +# Set to appropriate C++ compiler +CPP=g++ +CPPFLAGS=-I../../tecsrc ../../tecio.a +EXECUTABLE=arrow +FILES=$(EXECUTABLE).cpp + +build: + $(CPP) $(FILES) $(CPPFLAGS) -o $(EXECUTABLE) + +clean: + rm -f $(EXECUTABLE) \ No newline at end of file diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/arrow/arrow.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/arrow/arrow.cpp new file mode 100644 index 0000000000000000000000000000000000000000..432022be519670677b74d0458f74ece1b5001650 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/arrow/arrow.cpp @@ -0,0 +1,530 @@ +/* This example creates two simple polyhedral zones in the shape + * of a three-dimensional arrow. Obscured boundary faces are used. + */ + +#include <stdio.h> +#include "TECIO.h" + +int main() +{ + /* DOCSTART:arrow_tecini.txt*/ + INTEGER4 Debug = 1; + INTEGER4 VIsDouble = 1; + INTEGER4 FileType = 0; + INTEGER4 I; + + /* Open the file and write the Tecplot datafile + * header information + */ + I = TECINI112((char*)"Multiple polyhedral zones", /* Name of the entire + * dataset. + */ + (char*)"X Y Z P", /* Defines the variables for the data + * file. Each zone must contain each of + * the variables listed here. The order + * of the variables in the list is used + * to define the variable number (e.g. + * X is Var 1). + */ + (char*)"Arrow.plt", + (char*)".", /* Scratch Directory */ + &FileType, + &Debug, + &VIsDouble); + + /* DOCEND */ + + + /* After TECINI is called, call TECZNE to create one or more + * zones for your data file. In this example, Zone 1 contains a + * single rectangular solid created as a face-based finite-element + * (i.e. polyhedral zone). The zone has eight points (or nodes), + * six faces and one element. + */ + /* DOCSTART:arrow_teczne_rect.txt*/ + /* TECZNE Parameters */ + INTEGER4 ZoneType = 7; /* sets the zone type + * to polyhedral */ + INTEGER4 NumPts_Rect = 8; + INTEGER4 NumElems_Rect = 1; + INTEGER4 NumFaces_Rect = 6; + INTEGER4 ICellMax = 0; /* not used */ + INTEGER4 JCellMax = 0; /* not used */ + INTEGER4 KCellMax = 0; /* not used */ + double SolutionTime = 0.0; + INTEGER4 StrandID = 0; + INTEGER4 ParentZone = 0; + INTEGER4 IsBlock = 1; + INTEGER4 NumFaceConnections = 0; /* not used */ + INTEGER4 FaceNeighborMode = 1; /* not used */ + INTEGER4 SharConn = 0; + + /* In a rectangular solid, each face is composed of four nodes. + * As such, the total number of face nodes is twenty-four (four + * nodes for each of the six faces). + */ + INTEGER4 TotalNumFaceNodes_Rect = 24; + + /* There is one connected boundary face in this zone (the face on + * the rectangle adjacent to the arrowhead). Refer to the Data + * Format Guide for additional information. */ + INTEGER4 NumConnBndryFaces_Rect = 1; + + /* The connected boundary face has one connection, the face on + * the bottom of the arrowhead. A connection is an element-zone + * tuple that indicates a neighboring element (and its zone) when + * the neighboring element is in a different zone. Generally, + * there will be one boundary connection for each boundary face. + */ + INTEGER4 TotalNumBndryConns_Rect = 1; + + /* For illustrative purposes, the grid variables (X, Y, and Z) + * are nodal variables (i.e. ValueLocation = 1), and the pressure + * variable (P) is a cell-centered variable (i.e. + * ValueLocation = 0). + */ + INTEGER4 ValueLocation[4] = { 1, 1, 1, 0 }; + + I = TECZNE112((char*)"Zone 1: Rectangular Solid", + &ZoneType, + &NumPts_Rect, + &NumElems_Rect, + &NumFaces_Rect, + &ICellMax, + &JCellMax, + &KCellMax, + &SolutionTime, + &StrandID, + &ParentZone, + &IsBlock, + &NumFaceConnections, + &FaceNeighborMode, + &TotalNumFaceNodes_Rect, + &NumConnBndryFaces_Rect, + &TotalNumBndryConns_Rect, + NULL, + ValueLocation, + NULL, + &SharConn); + + /* DOCEND */ + + /* DOCSTART:arrow_tecdat_rect.txt*/ + //set variable values (X_Rect, Y_Rect, Z_Rect & P_Rect) + double *X_Rect = new double[NumPts_Rect]; + double *Y_Rect = new double[NumPts_Rect]; + double *Z_Rect = new double[NumPts_Rect]; + double *P_Rect = new double[NumElems_Rect]; + + for (INTEGER4 ii = 0; ii <= NumPts_Rect / 2; ii += 4) + { + X_Rect[ii] = 0; + X_Rect[ii+1] = 3; + X_Rect[ii+2] = 3; + X_Rect[ii+3] = 0; + + Y_Rect[ii] = 3; + Y_Rect[ii+1] = 3; + Y_Rect[ii+2] = 1; + Y_Rect[ii+3] = 1; + } + + for (INTEGER4 ii = 0; ii < 4; ii++) + Z_Rect[ii] = 0; + + for (INTEGER4 ii = 4; ii < NumPts_Rect; ii++) + Z_Rect[ii] = -2; + + P_Rect[0] = 10; + + + INTEGER4 IsDouble = 1; + I = TECDAT112(&NumPts_Rect, X_Rect, &IsDouble); + I = TECDAT112(&NumPts_Rect, Y_Rect, &IsDouble); + I = TECDAT112(&NumPts_Rect, Z_Rect, &IsDouble); + I = TECDAT112(&NumElems_Rect, P_Rect, &IsDouble); + /* DOCEND */ + + /* DOCSTART:arrow_facenodes_rect.txt*/ + + /* The FaceNodeCounts array is used to describe the number of + * nodes in each face of the zone. The first value in the array + * is the number of nodes in Face 1, the second value is the + * number of nodes in Face 2 and so forth. In this example, each + * face of the zone has four nodes. + */ + + INTEGER4 *FaceNodeCounts_Rect = new INTEGER4[NumFaces_Rect]; + //For this particular zone, each face has the 4 nodes + for (INTEGER4 ii = 0; ii < NumFaces_Rect; ii++) + FaceNodeCounts_Rect[ii] = 4; + + /* The FaceNodes array is used to specify the nodes that compose + * each face. For each face (n of N), the number of nodes used + * to define the face is specified by the nth value in the + * FaceNodeCounts array. For example, if the first value in the + * FaceNodeCounts array is 4 (indicating Face 1 is composed of + * four nodes), the first four values in the FaceNodes array are + * the node numbers of the nodes in Face 1. + * + * ------------ + * WARNING + * When providing the node numbers for each face, you must + * provide the node numbers in a consistent order (either + * clockwise or counter-clockwise. Providing the node numbers + * out of order results in contorted faces. + * ------------ + */ + + INTEGER4 *FaceNodes_Rect = new INTEGER4[TotalNumFaceNodes_Rect]; + + //Nodes for Face 1 + FaceNodes_Rect[0] = 1; + FaceNodes_Rect[1] = 2; + FaceNodes_Rect[2] = 3; + FaceNodes_Rect[3] = 4; + + //Nodes for Face 2 + FaceNodes_Rect[4] = 1; + FaceNodes_Rect[5] = 4; + FaceNodes_Rect[6] = 8; + FaceNodes_Rect[7] = 5; + + //Nodes for Face 3 + FaceNodes_Rect[8] = 5; + FaceNodes_Rect[9] = 8; + FaceNodes_Rect[10] = 7; + FaceNodes_Rect[11] = 6; + + //Nodes for Face 4 + FaceNodes_Rect[12] = 2; + FaceNodes_Rect[13] = 6; + FaceNodes_Rect[14] = 7; + FaceNodes_Rect[15] = 3; + +//Nodes for Face 5 + FaceNodes_Rect[16] = 6; + FaceNodes_Rect[17] = 2; + FaceNodes_Rect[18] = 1; + FaceNodes_Rect[19] = 5; + + //Nodes for Face 6 + FaceNodes_Rect[20] = 3; + FaceNodes_Rect[21] = 7; + FaceNodes_Rect[22] = 8; + FaceNodes_Rect[23] = 4; + /* DOCEND */ + + /* DOCSTART:arrow_neighbors_rect.txt*/ + INTEGER4 *FaceLeftElems_Rect = new INTEGER4[NumFaces_Rect]; + INTEGER4 *FaceRightElems_Rect = new INTEGER4[NumFaces_Rect]; + + /* Since this zone has just one element, all leftelems are + * NoNeighboring Element and all right elems are itself + */ + for (INTEGER4 ii = 0; ii < NumFaces_Rect; ii++) + { + FaceRightElems_Rect[ii] = 1; + FaceLeftElems_Rect[ii] = 0; + } + + /* The negative value in the FaceLeftElems array indicates that + * the face is connected to an element in another zone. In this + * case, Face 4 is connected to a face in Zone 2 (to be defined + * later in the example). The FaceBoundaryConnectionElems array + * lists all of the element numbers in other zones that the + * current zone shares boundary connections with. Similarly, the + * FaceBoundaryConnectionZones array lists all of the zone numbers + * with which the current zone shares boundaries. A negative + * value in the FaceLeftElems or FaceRightElems array indicates + * the position within these arrays that defines the neighboring + * element and zone for a face. + * + * For example, if the FaceBoundaryConnectionElems array is: + * [1 8 2] and the FaceBoundaryConnectionZones array is: [2 5 3], + * a FaceLeftElems or FaceRightElems value of -2 indicates that + * the face in question has a boundary connection with Element 8 + * in Zone 5. + */ + FaceLeftElems_Rect[3] = -1; + /* DOCEND */ + + /* DOCSTART:arrow_tecpoly_rect.txt*/ + /* The FaceBndryConnectionCounts array is used to define the + * number of boundary connections for each face that has a + * boundary connection. For example, if a zone has three boundary + * connections in total (NumConnectedBoundaryFaces), two of those + * boundary connections are in one face, and the remaining + * boundary connection is in a second face, the + * FaceBndryConnectionCounts array would be: [2 1]. + * In this example, the total number of connected boundary faces + * (specified via TECZNE) is equal to one, so the + * FaceBoundaryConnectionCounts array contains a single value (1). + */ + INTEGER4 *FaceBndryConnCounts_Rect = new INTEGER4[NumConnBndryFaces_Rect]; + FaceBndryConnCounts_Rect[0] = 1; + + /* The value(s) in the FaceBndryConnectionElems and + * FaceBndryConnectionZones arrays specify the element number and + * zone number, respectively, that a given boundary connection is + * connected to. In this case, the boundary connection face is + * connected to Element 1 in Zone 2. + */ + INTEGER4 *FaceBndryConnElems_Rect = new INTEGER4[TotalNumBndryConns_Rect]; + INTEGER4 *FaceBndryConnZones_Rect = new INTEGER4[TotalNumBndryConns_Rect]; + + FaceBndryConnElems_Rect[0] = 1; + FaceBndryConnZones_Rect[0] = 2; + + I = TECPOLY112(FaceNodeCounts_Rect, + FaceNodes_Rect, + FaceLeftElems_Rect, + FaceRightElems_Rect, + FaceBndryConnCounts_Rect, + FaceBndryConnElems_Rect, + FaceBndryConnZones_Rect); + + /* cleanup */ + delete X_Rect; + delete Y_Rect; + delete Z_Rect; + delete P_Rect; + delete FaceNodeCounts_Rect; + delete FaceNodes_Rect; + delete FaceLeftElems_Rect; + delete FaceRightElems_Rect; + delete FaceBndryConnCounts_Rect; + delete FaceBndryConnElems_Rect; + delete FaceBndryConnZones_Rect; + /* DOCEND */ + + /* The data for Zone 1 has been written to the data file, so we + * are ready to create Zone 2. For simplicity, we will reuse many + * of the variables created for the rectangular zone that are not + * relevant to this tutorial. */ + + /* Zone 2 (the arrowhead or prism) has a single element composed + * of six nodes and five faces. + */ + + /* DOCSTART:arrow_teczne_prism.txt*/ + //TECZNE Parameters + INTEGER4 NumPts_Prism = 6; + INTEGER4 NumElems_Prism = 1; + INTEGER4 NumFaces_Prism = 5; + + /* The prism is composed of two triangular faces and three + * rectangular faces. The total number of face nodes is the sum + * of the nodes in each triangular face (2 times 3) and the nodes + * in each rectangular face (3 times 4). + */ + INTEGER4 TotalNumFaceNodes_Prism = 18; + + /* As with Zone 1, Zone 2 has one connected boundary face, the + * face that is connected to Zone 1. + */ + INTEGER4 NumConnBndryFaces_Prism = 1; + + /* In this case, we have set the total number of boundary + * connections for the connected face to two. The first boundary + * connection is the connection to Zone 1. The second boundary + * connection is used to indicate that the face is only partially + * obscured by the face from Zone 1. If we omitted the second + * boundary connection, the connected face of the prism would + * disappear if the rectangular zone was deactivated. + */ + INTEGER4 TotalNumBndryConns_Prism = 2; + + I = TECZNE112((char*)"Zone 2: Prism", + &ZoneType, + &NumPts_Prism, + &NumElems_Prism, + &NumFaces_Prism, + &ICellMax, + &JCellMax, + &KCellMax, + &SolutionTime, + &StrandID, + &ParentZone, + &IsBlock, + &NumFaceConnections, + &FaceNeighborMode, + &TotalNumFaceNodes_Prism, + &NumConnBndryFaces_Prism, + &TotalNumBndryConns_Prism, + NULL, + ValueLocation, + NULL, + &SharConn); + /* DOCEND */ + + /* DOCSTART:arrow_tecdat_prism.txt*/ + + + double *X_Prism = new double[NumPts_Prism]; + double *Y_Prism = new double[NumPts_Prism]; + double *Z_Prism = new double[NumPts_Prism]; + + + /* Set the X and Y variable values, one z-plane at a time */ + double ZVal = 0; + for (INTEGER4 ii = 0; ii < 2; ii++) + { + // triangle in Z=ZVal plane + X_Prism[3*ii] = 3; + Y_Prism[3*ii] = 4; + Z_Prism[3*ii] = ZVal; + + X_Prism[3*ii+1] = 7; + Y_Prism[3*ii+1] = 2; + Z_Prism[3*ii+1] = ZVal; + + X_Prism[3*ii+2] = 3; + Y_Prism[3*ii+2] = 0; + Z_Prism[3*ii+2] = ZVal; + + ZVal = ZVal - 2; + } + + /* When we called TecZne, we specified that the variable 4 + * (pressure) is cell-centered. As such, only NumElements number + * of values needs to be written to the data file for the pressure + * variable. + */ + double *P_Prism = new double[NumElems_Prism]; + P_Prism[0] = 20; + + I = TECDAT112(&NumPts_Prism, X_Prism, &IsDouble); + I = TECDAT112(&NumPts_Prism, Y_Prism, &IsDouble); + I = TECDAT112(&NumPts_Prism, Z_Prism, &IsDouble); + I = TECDAT112(&NumElems_Prism, P_Prism, &IsDouble); + /* DOCEND */ + + /* DOCSTART:arrow_facemap_prism.txt*/ + INTEGER4 *FaceNodeCounts_Prism = new INTEGER4[NumFaces_Prism]; + INTEGER4 *FaceNodes_Prism = new INTEGER4[TotalNumFaceNodes_Prism]; + + /* Because of the way we chose to number our faces, the first + * three faces are rectangular and the last two are triangular. + * The numbering of the faces is arbitrary, but the faces must + * be referred to consistently. + */ + for (INTEGER4 ii = 0; ii < 3; ii++) + FaceNodeCounts_Prism[ii] = 4; + + for (INTEGER4 ii = 3; ii < NumFaces_Prism; ii++) + FaceNodeCounts_Prism[ii] = 3; + + //Nodes for Face 1 + FaceNodes_Prism[0] = 1; + FaceNodes_Prism[1] = 3; + FaceNodes_Prism[2] = 6; + FaceNodes_Prism[3] = 4; + + //Nodes for Face 2 + FaceNodes_Prism[4] = 1; + FaceNodes_Prism[5] = 4; + FaceNodes_Prism[6] = 5; + FaceNodes_Prism[7] = 2; + + //Nodes for Face 3 + FaceNodes_Prism[8] = 3; + FaceNodes_Prism[9] = 2; + FaceNodes_Prism[10] = 5; + FaceNodes_Prism[11] = 6; + + //Nodes for Face 4 + FaceNodes_Prism[12] = 5; + FaceNodes_Prism[13] = 4; + FaceNodes_Prism[14] = 6; + +//Nodes for Face 5 + FaceNodes_Prism[15] = 1; + FaceNodes_Prism[16] = 2; + FaceNodes_Prism[17] = 3; + /* DOCEND */ + + /* DOCSTART:arrow_neighbors_prism.txt*/ + /* Since this zone has just one element, all leftelems are + * NoNeighboring Element and all right elems are itself. + */ + INTEGER4 *FaceLeftElems_Prism = new INTEGER4[NumFaces_Prism]; + INTEGER4 *FaceRightElems_Prism = new INTEGER4[NumFaces_Prism]; + + for (INTEGER4 ii = 0; ii < NumFaces_Prism; ii++) + { + FaceRightElems_Prism[ii] = 1; + FaceLeftElems_Prism[ii] = 0; + } + + /* The negative value in the FaceLeftElems array indicates that + * the face is connected to an element in another zone. In this + * case, Face 1 is connected to a face in Zone 1 (as indicated in + * Line 6). The FaceBoundaryConnectionElems array lists all of + * the element numbers in other zones that the current zone shares + * boundary connections with. Similarly, the + * FaceBoundaryConnectionZones array lists all of the zone numbers + * with which the current zone shares boundaries. A negative + * value in the FaceLeftElems or FaceRightElems array indicates + * the position within these arrays that defines the neighboring + * element and zone for a face. + */ + FaceLeftElems_Prism[0] = -1; + /* DOCEND */ + + /* DOCSTART:arrow_tecpoly_prism.txt*/ + + INTEGER4 *FaceBndryConnCounts_Prism = new INTEGER4[NumConnBndryFaces_Prism]; + FaceBndryConnCounts_Prism[0] = 2; + + INTEGER4 *FaceBndryConnElems_Prism = new INTEGER4[TotalNumBndryConns_Prism]; + INTEGER4 *FaceBndryConnZones_Prism = new INTEGER4[TotalNumBndryConns_Prism]; + + /* As previously mentioned, a connected boundary face is a face + * that has either multiple neighboring faces or neighbor(s) that + * belong to another zone. Those cases are sufficient when the + * combination of all of the face’s neighbors completely cover the + * face. However, there are some cases (such as the bottom of the + * arrowhead) where the face is not completely covered by its + * neighbors. In those cases the face is referred to as “partially + * obscured”. A partially obscured face is indicated by + * incrementing the value in TotalNumConnectedBoundaryFaces and + * entering a value of 0 in both the FaceBndryConnectionElems and + * FaceBoundaryConnectionZones arrays for the boundary connection + * for the partially obscured face. + */ + FaceBndryConnElems_Prism[0] = 0; + FaceBndryConnZones_Prism[0] = 0; + + /* Indicates that Face 1 is connected to Element 1 in Zone 1. */ + FaceBndryConnElems_Prism[1] = 1; + FaceBndryConnZones_Prism[1] = 1; + + I = TECPOLY112(FaceNodeCounts_Prism, + FaceNodes_Prism, + FaceLeftElems_Prism, + FaceRightElems_Prism, + FaceBndryConnCounts_Prism, + FaceBndryConnElems_Prism, + FaceBndryConnZones_Prism); + + /* cleanup */ + delete X_Prism; + delete Y_Prism; + delete Z_Prism; + delete P_Prism; + delete FaceNodeCounts_Prism; + delete FaceNodes_Prism; + delete FaceLeftElems_Prism; + delete FaceRightElems_Prism; + delete FaceBndryConnCounts_Prism; + delete FaceBndryConnElems_Prism; + delete FaceBndryConnZones_Prism; + /* DOCEND */ + + /* DOCSTART:arrow_tecend.txt*/ + I = TECEND112(); + /* DOCEND */ + + return 0; +} diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/arrow/arrow.vcproj b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/arrow/arrow.vcproj new file mode 100644 index 0000000000000000000000000000000000000000..31f69eedf107bd4df7d4630066ad847566097de9 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/arrow/arrow.vcproj @@ -0,0 +1,172 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="arrow" + ProjectGUID="{3C1105D7-5690-48E0-9402-111CBDC84B42}" + RootNamespace="arrow" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + GenerateDebugInformation="true" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="2" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + RuntimeLibrary="2" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + GenerateDebugInformation="true" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <File + RelativePath=".\arrow.cpp" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/comtest/Makefile b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/comtest/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..2c6009b07305b63ddd8787e3fcbe020e820719df --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/comtest/Makefile @@ -0,0 +1,11 @@ +# Set to appropriate C++ compiler +CPP=g++ +CPPFLAGS=-I../../tecsrc ../../tecio.a +EXECUTABLE=comtest +FILES=$(EXECUTABLE).c + +build: + $(CPP) $(FILES) $(CPPFLAGS) -o $(EXECUTABLE) + +clean: + rm -f $(EXECUTABLE) diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/comtest/comtest.c b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/comtest/comtest.c new file mode 100644 index 0000000000000000000000000000000000000000..c290dcef40e3a73694bb3c2c15d0b8616274b275 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/comtest/comtest.c @@ -0,0 +1,492 @@ +/* + * Complex example C program to write a + * binary data file for Tecplot. This example + * does the following: + * + * 1. Open a data file called "field.plt." + * 2. Open a data file called "line.plt." + * 3. Assign values for X, Y and P. These will be used + * in both the ordered and finite-element data files. + * 4. Write out an ordered zone dimensioned 4 x 5 to "field.plt." + * 5. Assign values for XL and YL arrays. + * 6. Write out data for line plot to "line.plt." Make the data + * use double precision. + * 7. Write out a finite-element zone to "field.plt." + * 8. Write out a text record to "field.plt." + * 9. Write out a geometry (circle) record to "field.plt." + * 10. Close file 1. + * 11. Close file 2. + */ + +#include <stdio.h> +#include <math.h> +#include "TECIO.h" + +int main(void) +{ + float X[5][4], Y[5][4], P[5][4]; + double XL[50], YL[50]; + double SolTime; + INTEGER4 Debug, I, J, K, L, III, NPts, NElm, DIsDouble, VIsDouble, IMax, JMax, KMax; + INTEGER4 ICellMax, JCellMax, KCellMax, ZoneType, Clipping; + INTEGER4 StrandID, ParentZn, FieldFileType, LineFileType; + INTEGER4 SharingZone[3] = {0, 0, 0}; + INTEGER4 IsBlock, NumFaceConnections, FaceNeighborMode, ShareConnectivityFromZone; + INTEGER4 NM[12][4]; + double XP, YP, ZP, FH, LineSpacing, PatternLength; + double BoxMargin, BoxLineThickness, TextAngle; + INTEGER4 AttachToZone, Zone, Scope, PositionCoordSys, FontType, HeightUnits; + INTEGER4 IsFilled, GeomType, LinePattern, NumEllipsePts; + INTEGER4 Anchor, BoxType, BoxColor, BoxFillColor, TextColor, Color, FillColor; + INTEGER4 ArrowheadStyle, ArrowheadAttachment, NumSegments, NumSegPts[1]; + double LineThickness, ArrowheadSize, ArrowheadAngle; + float XGeomData[1], YGeomData[1], ZGeomData[1]; + enum FileType { FULL = 0, GRID = 1, SOLUTION = 2 }; + + Debug = 2; + VIsDouble = 0; + DIsDouble = 0; + FieldFileType = FULL; + LineFileType = FULL; + /* + * Open order.plt and write the header information. + */ + I = TECINI112((char*)"DATASET WITH ONE ORDERED ZONE AND ONE FE-QUAD ZONE OVER 2 TIME STEPS", + (char*)"X Y P", + (char*)"field.plt", + (char*)".", + &FieldFileType, + &Debug, + &VIsDouble); + /* + * Open line.plt and write the header information. + */ + VIsDouble = 1; + I = TECINI112((char*)"DATASET WITH ONE I-ORDERED ZONE", + (char*)"X Y", + (char*)"line.plt", + (char*)".", + &LineFileType, + &Debug, + &VIsDouble); + + /* + * Calculate values for the field variables. + */ + for (J = 0; J < 5; J++) + for (I = 0; I < 4; I++) + { + X[J][I] = (float)(I + 1); + Y[J][I] = (float)(J + 1); + P[J][I] = (float)((I + 1) * (J + 1)); + } + + /* + * Make sure writing to file #1. + */ + III = 1; + I = TECFIL112(&III); + + /* + * Write the zone header information for the ordered zone. + */ + IMax = 4; + JMax = 5; + KMax = 1; + ICellMax = 0; + JCellMax = 0; + KCellMax = 0; + ZoneType = 0; + SolTime = 10.0; + StrandID = 1; + ParentZn = 0; + IsBlock = 1; + NumFaceConnections = 0; + FaceNeighborMode = 0; + ShareConnectivityFromZone = 0; + I = TECZNE112((char*)"Ordered Zone 1", + &ZoneType, + &IMax, + &JMax, + &KMax, + &ICellMax, + &JCellMax, + &KCellMax, + &SolTime, + &StrandID, + &ParentZn, + &IsBlock, + &NumFaceConnections, + &FaceNeighborMode, + NULL, /* PassiveVarList */ + NULL, /* ValueLocation */ + NULL, /* ShareVarFromZone */ + 0, /* TotalNumFaceNodes */ + 0, /* NumConnectedBoundaryFaces */ + 0, /* TotalNumBoundaryConnections */ + &ShareConnectivityFromZone); + /* + * Write out the field data for the ordered zone. + */ + III = IMax * JMax; + I = TECDAT112(&III, &X[0][0], &DIsDouble); + I = TECDAT112(&III, &Y[0][0], &DIsDouble); + I = TECDAT112(&III, &P[0][0], &DIsDouble); + + /* + * Calculate values for the I-ordered zone. + */ + + for (I = 0; I < 50; I++) + { + XL[I] = I + 1; + YL[I] = sin((double)(I + 1) / 20.0); + } + /* + * Switch to the "line.plt" file (file number 2) + * and write out the line plot data. + */ + + III = 2; + I = TECFIL112(&III); + + /* + * Write the zone header information for the XY-data. + */ + IMax = 50; + JMax = 1; + KMax = 1; + SolTime = 0.0; + StrandID = 0; /* StaticZone */ + I = TECZNE112((char*)"XY Line plot", + &ZoneType, + &IMax, + &JMax, + &KMax, + &ICellMax, + &JCellMax, + &KCellMax, + &SolTime, + &StrandID, + &ParentZn, + &IsBlock, + &NumFaceConnections, + &FaceNeighborMode, + 0, /* TotalNumFaceNodes */ + 0, /* NumConnectedBoundaryFaces */ + 0, /* TotalNumBoundaryConnections */ + NULL, /* PassiveVarList */ + NULL, /* ValueLocation */ + NULL, /* ShareVarFromZone */ + &ShareConnectivityFromZone); + /* + * Write out the line plot. + */ + DIsDouble = 1; + III = IMax; + I = TECDAT112(&III, (float *) & XL[0], &DIsDouble); + I = TECDAT112(&III, (float *) & YL[0], &DIsDouble); + + /* + * Switch back to the field plot file and write out + * the finite-element zone. + */ + III = 1; + I = TECFIL112(&III); + + /* + * Move the coordinates so this zone's not on top of the other + */ + for (J = 0; J < 5; J++) + for (I = 0; I < 4; I++) + { + X[J][I] = (float)(I + 6); + Y[J][I] = (float)(J + 1); + P[J][I] = (float)((I + 1) * (J + 1)); + } + + /* + * Write the zone header information for the finite-element zone. + */ + ZoneType = 3; /* FEQuad */ + NPts = 20; /* Number of points */ + NElm = 12; /* Number of elements */ + KMax = 0; /* Unused */ + SolTime = 10.0; + StrandID = 2; + I = TECZNE112((char*)"Finite Zone 1", + &ZoneType, + &NPts, + &NElm, + &KMax, + &ICellMax, + &JCellMax, + &KCellMax, + &SolTime, + &StrandID, + &ParentZn, + &IsBlock, + &NumFaceConnections, + &FaceNeighborMode, + 0, /* TotalNumFaceNodes */ + 0, /* NumConnectedBoundaryFaces */ + 0, /* TotalNumBoundaryConnections */ + NULL, /* PassiveVarList */ + NULL, /* ValueLocation */ + NULL, /* ShareVarFromZone */ + &ShareConnectivityFromZone); + /* + * Write out the field data for the finite-element zone. + */ + IMax = 4; + JMax = 5; + III = IMax * JMax; + DIsDouble = 0; + I = TECDAT112(&III, &X[0][0], &DIsDouble); + I = TECDAT112(&III, &Y[0][0], &DIsDouble); + I = TECDAT112(&III, &P[0][0], &DIsDouble); + + /* + * Calculate and then write out the connectivity list. + * Note: The NM array references cells starting with + * offset of 1. + */ + + for (I = 1; I < IMax; I++) + for (J = 1; J < JMax; J++) + { + K = I + (J - 1) * (IMax - 1); + L = I + (J - 1) * IMax; + NM[K-1][0] = L; + NM[K-1][1] = L + 1; + NM[K-1][2] = L + IMax + 1; + NM[K-1][3] = L + IMax; + } + + I = TECNOD112((INTEGER4 *)NM); + + /* + * Calculate values for the new solution variable. + */ + for (J = 0; J < 5; J++) + for (I = 0; I < 4; I++) + { + P[J][I] = (float)(2.0 * (I + 1) * (J + 1)); + } + + /* + * Write the zone header information for time step 2 + */ + ZoneType = 0; + IMax = 4; + JMax = 5; + KMax = 1; + SolTime = 20.0; + StrandID = 1; + SharingZone[0] = 1; + SharingZone[1] = 1; + SharingZone[2] = 0; /* solution variable is not shared */ + ShareConnectivityFromZone = 0; + + I = TECZNE112((char*)"Ordered Zone 2", + &ZoneType, + &IMax, + &JMax, + &KMax, + &ICellMax, + &JCellMax, + &KCellMax, + &SolTime, + &StrandID, + &ParentZn, + &IsBlock, + &NumFaceConnections, + &FaceNeighborMode, + 0, /* TotalNumFaceNodes */ + 0, /* NumConnectedBoundaryFaces */ + 0, /* TotalNumBoundaryConnections */ + NULL, + NULL, + SharingZone, + &ShareConnectivityFromZone); + + /* + * Write out the solution variable the grid variables are shared. + */ + IMax = 4; + JMax = 5; + III = IMax * JMax; + DIsDouble = 0; + I = TECDAT112(&III, &P[0][0], &DIsDouble); + + /* + * Calculate values for the new solution variable. + */ + for (J = 0; J < 5; J++) + for (I = 0; I < 4; I++) + { + P[J][I] = (float)(3.0 * (I + 1) * (J + 1)); + } + + /* + * Write another time step for the FEZone and share from the first + */ + ZoneType = 3; + SolTime = 20.0; + StrandID = 2; + KMax = 0; + SharingZone[0] = 2; + SharingZone[1] = 2; + SharingZone[2] = 0; /* solution variable is not shared */ + ShareConnectivityFromZone = 2; + I = TECZNE112((char*)"Finite Zone 2", + &ZoneType, + &NPts, + &NElm, + &KMax, + &ICellMax, + &JCellMax, + &KCellMax, + &SolTime, + &StrandID, + &ParentZn, + &IsBlock, + &NumFaceConnections, + &FaceNeighborMode, + 0, /* TotalNumFaceNodes */ + 0, /* NumConnectedBoundaryFaces */ + 0, /* TotalNumBoundaryConnections */ + NULL, /* PassiveVarList */ + NULL, /* ValueLocation */ + SharingZone, + &ShareConnectivityFromZone); + + /* + * Write out the solution variable the grid variables are shared. + */ + IMax = 4; + JMax = 5; + III = IMax * JMax; + DIsDouble = 0; + I = TECDAT112(&III, &P[0][0], &DIsDouble); + + /* + * Prepare to write out text record. Text is positioned + * at 0.5, 0.5 in frame units and has a height + * of 0.05 frame units. + */ + XP = 50.0; + YP = 50.0; + ZP = 0.0; + FH = 5.0; + Scope = 1; /* Local */ + Clipping = 1; /* Clip to frame */ + PositionCoordSys = 1; /* Frame */ + FontType = 1; /* Helv Bold */ + HeightUnits = 1; /* Frame */ + AttachToZone = 0; + Zone = 0; + BoxType = 0; /* None */ + BoxMargin = 5.0; + BoxLineThickness = 0.5; + BoxColor = 3; + BoxFillColor = 7; + TextAngle = 0.0; + Anchor = 0; /* Left */ + LineSpacing = 1.0; + TextColor = 0; /* Black */ + + III = TECTXT112(&XP, + &YP, + &ZP, + &PositionCoordSys, + &AttachToZone, + &Zone, + &FontType, + &HeightUnits, + &FH, + &BoxType, + &BoxMargin, + &BoxLineThickness, + &BoxColor, + &BoxFillColor, + &TextAngle, + &Anchor, + &LineSpacing, + &TextColor, + &Scope, + &Clipping, + (char*)"Hi Mom", + (char*)""); + + /* + * Prepare to write out geometry record (circle). Circle is + * positioned at 25, 25 (in frame units) and has a radius of + * 20 percent. Circle is drawn using a dashed line. + */ + + + XP = 25.0; + YP = 25.0; + ZP = 0.0; + IsFilled = 0; + Color = 0; + FillColor = 7; + GeomType = 3; /* Circle */ + LinePattern = 1; /* Dashed */ + LineThickness = 0.3; + PatternLength = 1.5; + NumEllipsePts = 72; + ArrowheadStyle = 0; + ArrowheadAttachment = 0; + ArrowheadSize = 0.1; + ArrowheadAngle = 15.0; + NumSegments = 1; + NumSegPts[0] = 1; + + XGeomData[0] = 20.0; + YGeomData[0] = 0.0; + ZGeomData[0] = 0.0; + + + III = TECGEO112(&XP, + &YP, + &ZP, + &PositionCoordSys, + &AttachToZone, + &Zone, + &Color, + &FillColor, + &IsFilled, + &GeomType, + &LinePattern, + &PatternLength, + &LineThickness, + &NumEllipsePts, + &ArrowheadStyle, + &ArrowheadAttachment, + &ArrowheadSize, + &ArrowheadAngle, + &Scope, + &Clipping, + &NumSegments, + NumSegPts, + &XGeomData[0], + &YGeomData[0], + &ZGeomData[0], + (char*)""); + + /* + * Close out file 1. + */ + I = TECEND112(); + + /* + * Close out file 2. + */ + III = 2; + I = TECFIL112(&III); + I = TECEND112(); + + return 0; +} diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/comtest/comtest.f b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/comtest/comtest.f new file mode 100644 index 0000000000000000000000000000000000000000..c8d6e2ce5aab81b4297ea3d85a4c3e6c46629390 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/comtest/comtest.f @@ -0,0 +1,467 @@ +C +C Complex example FORTRAN program to write a +C binary data file for Tecplot. This example +C does the following: +C +C 1. Open a data file called "field.plt." +C 2. Open a data file called "line.plt." +C 3. Assign values for X, Y and P. These will be used +C in both the ordered and FE data files. +C 4. Write out an ordered zone dimensioned 4 x 5 to "field.plt." +C 5. Assign values for XL and YL arrays. +C 6. Write out data for line plot to "line.plt." Make the data +C use double precision. +C 7. Write out a finite element zone to "field.plt." +C 8. Write out a text record to "field.plt." +C 9. Write out a geometry (circle) record to "field.plt." +C 10. Close file 1. +C 11. Close file 2. +C + Program ComplexTest + + Include "tecio.inc" + + REAL*4 X(4,5), Y(4,5), P(4,5) + REAL*8 XL(50), YL(50) + REAL*4 XLDummy(1), YLDummy(1) + EQUIVALENCE (XLDummy(1), XL(1)) + EQUIVALENCE (YLDummy(1), YL(1)) + REAL*8 SolTime + INTEGER*4 Debug,I,J,K,L,III,NPts,NElm,DIsDouble,VIsDouble + INTEGER*4 IMax,JMax,KMax,NM(4,12),FileType + INTEGER*4 StrandID,ParentZn + INTEGER*4 SharingZone(3) + REAL*8 XP, YP, ZP, FH, LineSpacing, PatternLength + REAL*8 BoxMargin, BoxLineThickness, TextAngle + INTEGER*4 AttachToZone, Zone, Scope, PositionCoordSys + INTEGER*4 Clipping + INTEGER*4 FontType, HeightUnits, Anchor, BoxType + INTEGER*4 IsFilled, GeomType, LinePattern, NumEllipsePts + INTEGER*4 BoxColor, BoxFillColor, TextColor, Color, FillColor + INTEGER*4 ArrowheadStyle, ArrowheadAttachment, NumSegments + INTEGER*4 NumSegPts(1) + REAL*8 LineThickness, ArrowheadSize, ArrowheadAngle + REAL*4 XGeomData(1), YGeomData(1), ZGeomData(1) + CHARACTER*1 NULCHAR + INTEGER*4 Zero + POINTER (NullPtr,Null) + INTEGER*4 Null(*) + + Debug = 2 + VIsDouble = 0 + FileType = 0 + DIsDouble = 0 + NULCHAR = CHAR(0) + Zero = 0 + NullPtr = 0 +C +C Open field.plt and write the header information. +C + I = TECINI112('DATASET WITH 1 ORDERED ZONE, '// + & '1 QUAD ZONE OVER 2 TIME STEPS'//NULCHAR, + & 'X Y P'//NULCHAR, + & 'field.plt'//NULCHAR, + & '.'//NULCHAR, + & FileType, + & Debug, + & VIsDouble) +C +C Open line.plt and write the header information. +C + VIsDouble = 1 + I = TECINI112('DATASET WITH ONE I-ORDERED ZONE'//NULCHAR, + & 'X Y'//NULCHAR, + & 'line.plt'//NULCHAR, + & '.'//NULCHAR, + & FileType, + & Debug, + & VIsDouble) + +C +C Calculate values for the field variables. +C + Do 10 J = 1,5 + Do 10 I = 1,4 + X(I,J) = I + Y(I,J) = J + P(I,J) = I*J + 10 Continue + +C +C Make sure writing to file #1. +C + III = 1 + I = TECFIL112(III) + +C +C Write the zone header information for the ordered zone. +C + IMax = 4 + JMax = 5 + KMax = 1 + SolTime = 10.0 + StrandID = 1 + ParentZn = 0 + I = TECZNE112('Ordered Zone 1'//NULCHAR, + & 0, ! ZONETYPE + & IMax, + & JMax, + & KMax, + & 0, + & 0, + & 0, + & SolTime, + & StrandID, + & ParentZn, + & 1, ! ISBLOCK + & 0, ! NumFaceConnections + & 0, ! FaceNeighborMode + & 0, ! TotalNumFaceNodes + & 0, ! NumConnectedBoundaryFaces + & 0, ! TotalNumBoundaryConnections + & Null, ! PassiveVarList + & Null, ! ValueLocation + & Null, ! ShareVarFromZone + & 0) ! ShareConnectivityFromZone) + +C +C Write out the field data for the ordered zone. +C + III = IMax*JMax + I = TECDAT112(III,X,DIsDouble) + I = TECDAT112(III,Y,DIsDouble) + I = TECDAT112(III,P,DIsDouble) + +C +C Calculate values for the I-ordered zone. +C + + Do 20 I = 1,50 + XL(I) = I + YL(I) = sin(I/20.0) + 20 Continue +C +C Switch to the 'line.plt' file (file number 2) +C and write out the line plot data. +C + III = 2 + I = TECFIL112(III) +C +C Write the zone header information for the XY-data. +C + IMax = 50 + JMax = 1 + KMax = 1 + SolTime = 0.0 + StrandID = 0 + I = TECZNE112('XY Line plot'//NULCHAR, + & 0, + & IMax, + & JMax, + & KMax, + & 0, + & 0, + & 0, + & SolTime, + & StrandID, + & ParentZn, + & 1, + & 0, + & 0, + & 0, + & 0, + & 0, + & Null, + & Null, + & Null, + & 0) +C +C Write out the line plot. +C + DIsDouble = 1 + III = IMax + I = TECDAT112(III,XLDummy,DIsDouble) + I = TECDAT112(III,YLDummy,DIsDouble) + +C +C Switch back to the field plot file and write out +C the finite-element zone. +C + III = 1 + I = TECFIL112(III) +C +C Move the coordinates so this zone's not on top of the other +C + Do 30 J = 1,5 + Do 30 I = 1,4 + X(I,J) = I+5 + Y(I,J) = J + P(I,J) = I*J + 30 Continue +C +C Write the zone header information for the finite-element zone. +C + NPts = 20 + NElm = 12 + KMax = 1 + SolTime = 10.0 + StrandID = 2 + I = TECZNE112('Finite Zone 1'//NULCHAR, + & 3, ! FEQUADRILATERAL + & NPts, + & NElm, + & KMax, + & 0, + & 0, + & 0, + & SolTime, + & StrandID, + & ParentZn, + & 1, + & 0, + & 0, + & 0, + & 0, + & 0, + & Null, + & Null, + & Null, + & 0) +C +C Write out the field data for the finite-element zone. +C + IMax = 4 + JMax = 5 + III = IMax*JMax + DIsDouble = 0 + I = TECDAT112(III,X,DIsDouble) + I = TECDAT112(III,Y,DIsDouble) + I = TECDAT112(III,P,DIsDouble) + +C +C Calculate and then write out the connectivity list. +C Note: The NM array references cells starting with +C offset of 1. +C + + Do 40 I = 1,IMax-1 + Do 40 J = 1,JMax-1 + K = I+(J-1)*(IMax-1) + L = I+(J-1)*IMax + NM(1,K) = L + NM(2,K) = L+1 + NM(3,K) = L+IMax+1 + NM(4,K) = L+IMax + 40 Continue + + I = TECNOD112(NM) +C +C Calculate vlues for the new solution variable. +C + Do 50 J = 1,5 + Do 50 I = 1,4 + P(I,J) = 2*I*J + 50 Continue +C +C Write the zone header information for time step 2 +C + IMax = 4 + JMax = 5 + KMax = 1 + SolTime = 20.0 + StrandID = 1 + SharingZone(1) = 1 + SharingZone(2) = 1 + SharingZone(3) = 0 + I = TECZNE112('Ordered Zone 2'//NULCHAR, + & 0, ! ORDERED + & IMax, + & JMax, + & KMax, + & 0, + & 0, + & 0, + & SolTime, + & StrandID, + & ParentZn, + & 1, + & 0, + & 0, + & 0, + & 0, + & 0, + & Null, + & Null, + & SharingZone, + & 0) +C +C Write out the solution variable the grid variables are shared. +C + IMax = 4 + JMax = 5 + III = IMax*JMax + DIsDouble = 0 + I = TECDAT112(III,P,DIsDouble) +C +C Calculate values for the new solution variable. +C + Do 60 J = 1,5 + Do 60 I = 1,4 + P(I,J) = 3*I*J + 60 Continue +C +C Write another time step for the FEZone and share from the first +C + SolTime = 20.0 + StrandID = 2 + KMax = 0 + SharingZone(1) = 2 + SharingZone(2) = 2 + SharingZone(3) = 0 + I = TECZNE112('Finite Zone 2'//NULCHAR, + & 3, ! FEQUADRILATERAL + & NPts, + & NElm, + & KMax, + & 0, + & 0, + & 0, + & SolTime, + & StrandID, + & ParentZn, + & 1, + & 0, + & 0, + & 0, + & 0, + & 0, + & Null, + & Null, + & SharingZone, + & 2) +C +C Write out the solution variable the grid variables are shared. +C + IMax = 4 + JMax = 5 + III = IMax*JMax + DIsDouble = 0 + I = TECDAT112(III,P,DIsDouble) + +C +C Prepare to write out text record. Text is positioned +C at 50, 50 in frame units and has a height 5 frame units. +C + XP = 50 + YP = 50 + FH = 5 + Scope = 1 + Clipping = 0 + PositionCoordSys = 1 + FontType = 1 + HeightUnits = 1 + AttachToZone = 0 + Zone = 0 + BoxType = 0 + BoxMargin = 5.0 + BoxLineThickness = 0.5 + BoxColor = 3 + BoxFillColor = 7 + TextAngle = 0.0 + Anchor = 0 + LineSpacing = 1.5 + TextColor = 0 + + III = TECTXT112(XP, + & YP, + & 0.0d0, + & PositionCoordSys, + & AttachToZone, + & Zone, + & FontType, + & HeightUnits, + & FH, + & BoxType, + & BoxMargin, + & BoxLineThickness, + & BoxColor, + & BoxFillColor, + & TextAngle, + & Anchor, + & LineSpacing, + & TextColor, + & Scope, + & Clipping, + & 'Hi Mom'//NULCHAR, + & NULCHAR) + +C +C Prepare to write out geometry record (circle). Circle is +C positioned at 25, 25 in frame units and has a radius of 30. +C Circle is drawn using a dashed line pattern. +C + + + XP = 25 + YP = 25 + ZP = 0.0 + IsFilled = 0 + Color = 0 + FillColor = 7 + GeomType = 2 + LinePattern = 1 + LineThickness = 0.3 + PatternLength = 1 + NumEllipsePts = 72 + ArrowheadStyle = 0 + ArrowheadAttachment = 0 + ArrowheadSize = 0.0 + ArrowheadAngle = 15.0 + NumSegments = 1 + NumSegPts(1) = 1 + + XGeomData(1) = 30 + YGeomData(1) = 0.0 + ZGeomData(1) = 0.0 + + + III = TECGEO112(XP, + & YP, + & ZP, + & PositionCoordSys, + & AttachToZone, + & Zone, + & Color, + & FillColor, + & IsFilled, + & GeomType, + & LinePattern, + & PatternLength, + & LineThickness, + & NumEllipsePts, + & ArrowheadStyle, + & ArrowheadAttachment, + & ArrowheadSize, + & ArrowheadAngle, + & Scope, + & Clipping, + & NumSegments, + & NumSegPts, + & XGeomData, + & YGeomData, + & ZGeomData, + & NULCHAR) + +C +C Close out file 1. +C + I = TECEND112() + +C +C Close out file 2. +C + III = 2 + I = TECFIL112(III) + I = TECEND112() + STOP + END diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/comtest/comtest.f90 b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/comtest/comtest.f90 new file mode 100644 index 0000000000000000000000000000000000000000..56b3d560c39bee690d927fb11a3cde3694921d77 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/comtest/comtest.f90 @@ -0,0 +1,467 @@ +! +! Complex example FORTRAN program to write a +! binary data file for Tecplot. This example +! does the following: +! +! 1. Open a data file called "field.plt." +! 2. Open a data file called "line.plt." +! 3. Assign values for X, Y and P. These will be used +! in both the ordered and FE data files. +! 4. Write out an ordered zone dimensioned 4 x 5 to "field.plt." +! 5. Assign values for XL and YL arrays. +! 6. Write out data for line plot to "line.plt." Make the data +! use double precision. +! 7. Write out a finite element zone to "field.plt." +! 8. Write out a text record to "field.plt." +! 9. Write out a geometry (circle) record to "field.plt." +! 10. Close file 1. +! 11. Close file 2. +! + Program ComplexTest + + Include "tecio.f90" + + REAL*4 X(4,5), Y(4,5), P(4,5) + REAL*8 XL(50), YL(50) + REAL*4 XLDummy(1), YLDummy(1) + EQUIVALENCE (XLDummy(1), XL(1)) + EQUIVALENCE (YLDummy(1), YL(1)) + REAL*8 SolTime + INTEGER*4 Debug,I,J,K,L,III,NPts,NElm,DIsDouble,VIsDouble,FileType + INTEGER*4 IMax,JMax,KMax,NM(4,12) + INTEGER*4 StrandID,ParentZn + INTEGER*4 SharingZone(3) + REAL*8 XP, YP, ZP, FH, LineSpacing, PatternLength + REAL*8 BoxMargin, BoxLineThickness, TextAngle + INTEGER*4 AttachToZone, Zone, Scope, PositionCoordSys + INTEGER*4 Clipping + INTEGER*4 FontType, HeightUnits, Anchor, BoxType + INTEGER*4 IsFilled, GeomType, LinePattern, NumEllipsePts + INTEGER*4 BoxColor, BoxFillColor, TextColor, Color, FillColor + INTEGER*4 ArrowheadStyle, ArrowheadAttachment, NumSegments + INTEGER*4 NumSegPts(1) + REAL*8 LineThickness, ArrowheadSize, ArrowheadAngle + REAL*4 XGeomData(1), YGeomData(1), ZGeomData(1) + CHARACTER*1 NULCHAR + INTEGER*4 Zero + POINTER (NullPtr,Null) + INTEGER*4 Null(*) + + Debug = 2 + VIsDouble = 0 + FileType = 0 + DIsDouble = 0 + NULCHAR = CHAR(0) + Zero = 0 + NullPtr = 0 +! +! Open field.plt and write the header information. +! + I = TECINI112('DATASET WITH 1 ORDERED ZONE, '// & + '1 QUAD ZONE OVER 2 TIME STEPS'//NULCHAR, & + 'X Y P'//NULCHAR, & + 'field.plt'//NULCHAR, & + '.'//NULCHAR, & + FileType, & + Debug, & + VIsDouble) +! +! Open line.plt and write the header information. +! + VIsDouble = 1 + I = TECINI112('DATASET WITH ONE I-ORDERED ZONE'//NULCHAR, & + 'X Y'//NULCHAR, & + 'line.plt'//NULCHAR, & + '.'//NULCHAR, & + FileType, & + Debug, & + VIsDouble) + +! +! Calculate values for the field variables. +! + Do 10 J = 1,5 + Do 10 I = 1,4 + X(I,J) = I + Y(I,J) = J + P(I,J) = I*J + 10 Continue + +! +! Make sure writing to file #1. +! + III = 1 + I = TECFIL112(III) + +! +! Write the zone header information for the ordered zone. +! + IMax = 4 + JMax = 5 + KMax = 1 + SolTime = 10.0 + StrandID = 1 + ParentZn = 0 + I = TECZNE112('Ordered Zone 1'//NULCHAR, & + 0, & ! ZONETYPE + IMax, & + JMax, & + KMax, & + 0, & + 0, & + 0, & + SolTime, & + StrandID, & + ParentZn, & + 1, & ! ISBLOCK + 0, & ! NumFaceConnections + 0, & ! FaceNeighborMode + 0, & ! TotalNumFaceNodes + 0, & ! NumConnectedBoundaryFaces + 0, & ! TotalNumBoundaryConnections + Null, & ! PassiveVarList + Null, & ! ValueLocation + Null, & ! ShareVarFromZone + 0) ! ShareConnectivityFromZone) + +! +! Write out the field data for the ordered zone. +! + III = IMax*JMax + I = TECDAT112(III,X,DIsDouble) + I = TECDAT112(III,Y,DIsDouble) + I = TECDAT112(III,P,DIsDouble) + +! +! Calculate values for the I-ordered zone. +! + + Do 20 I = 1,50 + XL(I) = I + YL(I) = sin(I/20.0) + 20 Continue +! +! Switch to the 'line.plt' file (file number 2) +! and write out the line plot data. +! + III = 2 + I = TECFIL112(III) +! +! Write the zone header information for the XY-data. +! + IMax = 50 + JMax = 1 + KMax = 1 + SolTime = 0.0 + StrandID = 0 + I = TECZNE112('XY Line plot'//NULCHAR, & + 0, & + IMax, & + JMax, & + KMax, & + 0, & + 0, & + 0, & + SolTime, & + StrandID, & + ParentZn, & + 1, & + 0, & + 0, & + 0, & + 0, & + 0, & + Null, & + Null, & + Null, & + 0) +! +! Write out the line plot. +! + DIsDouble = 1 + III = IMax + I = TECDAT112(III,XLDummy,DIsDouble) + I = TECDAT112(III,YLDummy,DIsDouble) + +! +! Switch back to the field plot file and write out +! the finite-element zone. +! + III = 1 + I = TECFIL112(III) +! +! Move the coordinates so this zone's not on top of the other +! + Do 30 J = 1,5 + Do 30 I = 1,4 + X(I,J) = I+5 + Y(I,J) = J + P(I,J) = I*J + 30 Continue +! +! Write the zone header information for the finite-element zone. +! + NPts = 20 + NElm = 12 + KMax = 1 + SolTime = 10.0 + StrandID = 2 + I = TECZNE112('Finite Zone 1'//NULCHAR, & + 3, & ! FEQUADRILATERAL + NPts, & + NElm, & + KMax, & + 0, & + 0, & + 0, & + SolTime, & + StrandID, & + ParentZn, & + 1, & + 0, & + 0, & + 0, & + 0, & + 0, & + Null, & + Null, & + Null, & + 0) +! +! Write out the field data for the finite-element zone. +! + IMax = 4 + JMax = 5 + III = IMax*JMax + DIsDouble = 0 + I = TECDAT112(III,X,DIsDouble) + I = TECDAT112(III,Y,DIsDouble) + I = TECDAT112(III,P,DIsDouble) + +! +! Calculate and then write out the connectivity list. +! Note: The NM array references cells starting with +! offset of 1. +! + + Do 40 I = 1,IMax-1 + Do 40 J = 1,JMax-1 + K = I+(J-1)*(IMax-1) + L = I+(J-1)*IMax + NM(1,K) = L + NM(2,K) = L+1 + NM(3,K) = L+IMax+1 + NM(4,K) = L+IMax + 40 Continue + + I = TECNOD112(NM) +! +! Calculate vlues for the new solution variable. +! + Do 50 J = 1,5 + Do 50 I = 1,4 + P(I,J) = 2*I*J + 50 Continue +! +! Write the zone header information for time step 2 +! + IMax = 4 + JMax = 5 + KMax = 1 + SolTime = 20.0 + StrandID = 1 + SharingZone(1) = 1 + SharingZone(2) = 1 + SharingZone(3) = 0 + I = TECZNE112('Ordered Zone 2'//NULCHAR, & + 0, & ! ORDERED + IMax, & + JMax, & + KMax, & + 0, & + 0, & + 0, & + SolTime, & + StrandID, & + ParentZn, & + 1, & + 0, & + 0, & + 0, & + 0, & + 0, & + Null, & + Null, & + SharingZone, & + 0) +! +! Write out the solution variable the grid variables are shared. +! + IMax = 4 + JMax = 5 + III = IMax*JMax + DIsDouble = 0 + I = TECDAT112(III,P,DIsDouble) +! +! Calculate values for the new solution variable. +! + Do 60 J = 1,5 + Do 60 I = 1,4 + P(I,J) = 3*I*J + 60 Continue +! +! Write another time step for the FEZone and share from the first +! + SolTime = 20.0 + StrandID = 2 + KMax = 0 + SharingZone(1) = 2 + SharingZone(2) = 2 + SharingZone(3) = 0 + I = TECZNE112('Finite Zone 2'//NULCHAR, & + 3, & ! FEQUADRILATERAL + NPts, & + NElm, & + KMax, & + 0, & + 0, & + 0, & + SolTime, & + StrandID, & + ParentZn, & + 1, & + 0, & + 0, & + 0, & + 0, & + 0, & + Null, & + Null, & + SharingZone, & + 2) +! +! Write out the solution variable the grid variables are shared. +! + IMax = 4 + JMax = 5 + III = IMax*JMax + DIsDouble = 0 + I = TECDAT112(III,P,DIsDouble) + +! +! Prepare to write out text record. Text is positioned +! at 50, 50 in frame units and has a height 5 frame units. +! + XP = 50 + YP = 50 + FH = 5 + Scope = 1 + Clipping = 0 + PositionCoordSys = 1 + FontType = 1 + HeightUnits = 1 + AttachToZone = 0 + Zone = 0 + BoxType = 0 + BoxMargin = 5.0 + BoxLineThickness = 0.5 + BoxColor = 3 + BoxFillColor = 7 + TextAngle = 0.0 + Anchor = 0 + LineSpacing = 1.5 + TextColor = 0 + + III = TECTXT112(XP, & + YP, & + 0.0d0, & + PositionCoordSys, & + AttachToZone, & + Zone, & + FontType, & + HeightUnits, & + FH, & + BoxType, & + BoxMargin, & + BoxLineThickness, & + BoxColor, & + BoxFillColor, & + TextAngle, & + Anchor, & + LineSpacing, & + TextColor, & + Scope, & + Clipping, & + 'Hi Mom'//NULCHAR, & + NULCHAR) + +! +! Prepare to write out geometry record (circle). Circle is +! positioned at 25, 25 in frame units and has a radius of 30. +! Circle is drawn using a dashed line pattern. +! + + + XP = 25 + YP = 25 + ZP = 0.0 + IsFilled = 0 + Color = 0 + FillColor = 7 + GeomType = 2 + LinePattern = 1 + LineThickness = 0.3 + PatternLength = 1 + NumEllipsePts = 72 + ArrowheadStyle = 0 + ArrowheadAttachment = 0 + ArrowheadSize = 0.0 + ArrowheadAngle = 15.0 + NumSegments = 1 + NumSegPts(1) = 1 + + XGeomData(1) = 30 + YGeomData(1) = 0.0 + ZGeomData(1) = 0.0 + + + III = TECGEO112(XP, & + YP, & + ZP, & + PositionCoordSys, & + AttachToZone, & + Zone, & + Color, & + FillColor, & + IsFilled, & + GeomType, & + LinePattern, & + PatternLength, & + LineThickness, & + NumEllipsePts, & + ArrowheadStyle, & + ArrowheadAttachment, & + ArrowheadSize, & + ArrowheadAngle, & + Scope, & + Clipping, & + NumSegments, & + NumSegPts, & + XGeomData, & + YGeomData, & + ZGeomData, & + NULCHAR) + +! +! Close out file 1. +! + I = TECEND112() + +! +! Close out file 2. +! + III = 2 + I = TECFIL112(III) + I = TECEND112() + STOP + END diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/comtest/comtestc.vcproj b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/comtest/comtestc.vcproj new file mode 100644 index 0000000000000000000000000000000000000000..23da375e8d60fac96e30d9adf617845c53c791b6 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/comtest/comtestc.vcproj @@ -0,0 +1,346 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="comtestc" + ProjectGUID="{723FBFD1-5AF2-4154-B77A-CE3849EAFCA2}" + RootNamespace="comtestc" + Keyword="Win32Proj" + > + <Platforms> + <Platform + Name="Win32" + /> + <Platform + Name="x64" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(PlatformName)/$(ConfigurationName)" + IntermediateDirectory="$(SolutionDir)$(PlatformName)/$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + LinkIncremental="2" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + SubSystem="1" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Debug|x64" + OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)" + IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + TargetEnvironment="3" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + LinkIncremental="2" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + SubSystem="1" + TargetMachine="17" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)$(PlatformName)/$(ConfigurationName)" + IntermediateDirectory="$(SolutionDir)$(PlatformName)/$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="1" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + LinkIncremental="1" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|x64" + OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)" + IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="1" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + TargetEnvironment="3" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + LinkIncremental="1" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="17" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <File + RelativePath=".\comtest.c" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/comtest/comtestf.vfproj b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/comtest/comtestf.vfproj new file mode 100644 index 0000000000000000000000000000000000000000..dc894475f3dab497d6b1c191b1850c737c59b90e --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/comtest/comtestf.vfproj @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<VisualStudioProject ProjectCreator="Intel Fortran" Keyword="Console Application" Version="9.10" ProjectIdGuid="{861BC05F-1E95-401A-A80E-7589ADD1C79E}"> + <Platforms> + <Platform Name="Win32"/></Platforms> + <Configurations> + <Configuration Name="Debug|Win32" OutputDirectory="$(SolutionDir)$(PlatformName)/$(ConfigurationName)" IntermediateDirectory="$(SolutionDir)$(PlatformName)/$(ConfigurationName)" DeleteExtensionsOnClean="*.obj;*.mod;*.pdb;*.asm;*.map;*.dyn;*.dpi;*.tmp;*.log;*.ilk;*.exe;$(TargetPath)"> + <Tool Name="VFMidlTool" SuppressStartupBanner="true" HeaderFileName="$(InputName).h" TypeLibraryName="$(IntDir)/$(InputName).tlb"/> + <Tool Name="VFPreBuildEventTool"/> + <Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" DebugInformationFormat="debugEnabled" Optimization="optimizeDisabled" AdditionalIncludeDirectories="$(TEC_360_2009)/Include" ModulePath="$(INTDIR)/" ObjectFile="$(INTDIR)/" Traceback="true" BoundsCheck="true" RuntimeLibrary="rtMultiThreadedDebug" CompileOnly="true"/> + <Tool Name="VFPostBuildEventTool"/> + <Tool Name="VFCustomBuildTool"/> + <Tool Name="VFLinkerTool" OutputFile="$(OUTDIR)/comtestf.exe" LinkIncremental="linkIncrementalNo" SuppressStartupBanner="true" AdditionalLibraryDirectories="$(TEC_360_2009)/Bin" GenerateDebugInformation="true" ProgramDatabaseFile="$(OUTDIR)/comtestf.pdb" SubSystem="subSystemConsole" AdditionalDependencies="tecio.lib"/> + <Tool Name="VFResourceCompilerTool" ResourceOutputFileName="$(IntDir)/$(InputName).res"/> + <Tool Name="VFPreLinkEventTool"/></Configuration> + <Configuration Name="Release|Win32" OutputDirectory="$(SolutionDir)$(PlatformName)/$(ConfigurationName)" IntermediateDirectory="$(SolutionDir)$(PlatformName)/$(ConfigurationName)" DeleteExtensionsOnClean="*.obj;*.mod;*.pdb;*.asm;*.map;*.dyn;*.dpi;*.tmp;*.log;*.ilk;*.exe;$(TargetPath)" MustRebuild="true"> + <Tool Name="VFMidlTool" SwitchesHaveChanged="true" SuppressStartupBanner="true" HeaderFileName="$(InputName).h" TypeLibraryName="$(IntDir)/$(InputName).tlb"/> + <Tool Name="VFPreBuildEventTool"/> + <Tool Name="VFFortranCompilerTool" SwitchesHaveChanged="true" SuppressStartupBanner="true" AdditionalIncludeDirectories="$(TEC_360_2009)/Include" ModulePath="$(INTDIR)/" ObjectFile="$(INTDIR)/" RuntimeLibrary="rtMultiThreaded" CompileOnly="true"/> + <Tool Name="VFPostBuildEventTool"/> + <Tool Name="VFCustomBuildTool"/> + <Tool Name="VFLinkerTool" SwitchesHaveChanged="true" MustRebuild="true" OutputFile="$(OUTDIR)/comtestf.exe" LinkIncremental="linkIncrementalNo" SuppressStartupBanner="true" AdditionalLibraryDirectories="$(TEC_360_2009)/Bin" SubSystem="subSystemConsole" AdditionalDependencies="tecio.lib"/> + <Tool Name="VFResourceCompilerTool" SwitchesHaveChanged="true" ResourceOutputFileName="$(IntDir)/$(InputName).res"/> + <Tool Name="VFPreLinkEventTool"/></Configuration></Configurations> + <Files> + <File RelativePath="comtest.f90"/></Files> + <Globals/></VisualStudioProject> diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/faceneighbors/FaceNeighbors.plt b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/faceneighbors/FaceNeighbors.plt new file mode 100644 index 0000000000000000000000000000000000000000..6581f95bdce627599a21174508c20d3b7eabb0b7 Binary files /dev/null and b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/faceneighbors/FaceNeighbors.plt differ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/faceneighbors/Makefile b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/faceneighbors/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..cc8b9bf18e217702771b7c6188d97df31d233c7f --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/faceneighbors/Makefile @@ -0,0 +1,11 @@ +# Set to appropriate C++ compiler +CPP=g++ +CPPFLAGS=-I../../tecsrc ../../tecio.a +EXECUTABLE=faceneighbors +FILES=$(EXECUTABLE).cpp + +build: + $(CPP) $(FILES) $(CPPFLAGS) -o $(EXECUTABLE) + +clean: + rm -f $(EXECUTABLE) \ No newline at end of file diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/faceneighbors/faceneighbors.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/faceneighbors/faceneighbors.cpp new file mode 100644 index 0000000000000000000000000000000000000000..30b949e3f8e3d85d8bcaf9192e637344005e97c5 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/faceneighbors/faceneighbors.cpp @@ -0,0 +1,354 @@ +/* This example illustrates how to create two simple + * FE-quadilateral zones and create a face neighbor + * connection between the two zones. In order to keep the + * example as simple as possible, error checking is not included. + */ + +#include "TECIO.h" +#include "MASTER.h" + +int main() +{ + /* Initialize the Data File using TECINI. TECINI is required + * for all data files. It is used to: open the data file and + * initialize the file header information (name the data file, + * the variables for the data file, and the file type). + */ + + /* DOCSTART:faceneighbors_tecini.txt*/ + + INTEGER4 Debug = 1; + INTEGER4 VIsDouble = 0; + INTEGER4 FileType = 0; + INTEGER4 I = 0; /* Used to track return codes */ + + I = TECINI112((char*)"Face Neighbors Example", /* Specifies the name + * of the entire + * dataset + */ + (char*)"X Y P", /* Defines the + * variables for the + * data file. Each + * zone must contain + * each of the vars + * listed. The order + * of the variables in + * the list is used to + * define the variable + * number (e.g. X is + * Var 1.) + */ + + (char*)"FaceNeighbors.plt", /* Specifies the + * file name. + */ + (char*)".", + &FileType, /* The FileType is set to + * zero, indicating it is + * a full file (containing + * both grid and solution + * data). + */ + &Debug, + &VIsDouble); + /* DOCEND */ + + /* After TECINI is called, call TECZNE to create one or + * more zones for your data file. + */ + /* DOCSTART:faceneighbors_teczne1.txt*/ + INTEGER4 ZoneType = 3; /* set the zone type to + * FEQuadrilateral + */ + INTEGER4 NumPts = 6; + INTEGER4 NumElems = 2; + INTEGER4 NumFaces = 8; + INTEGER4 ICellMax = 0; /* not used */ + INTEGER4 JCellMax = 0; /* not used */ + INTEGER4 KCellMax = 0; /* not used */ + double SolTime = 360.0; + INTEGER4 StrandID = 0; /* StaticZone */ + INTEGER4 ParentZn = 0; + INTEGER4 IsBlock = 1; /* Block */ + INTEGER4 NFConns = 1; /* Specify the number of Face + * Neighbor Connections in the + * Zone. When this value is + * greater than zero, TECFACE must + * be called prior to creating the + * next zone or ending the file. + */ + + /* Specify the Face Neighbor Mode. + * A value of 2 indicated that the face neighbor mode is global + * one-to-one. The scope of the face neighbors (local or + * global) is with respect to the zones. A value of global + * indicates that the face neighbor(s) is/are shared aross zones; + * a value of local indicates that the face neighbor(s) are + * shared within the current zone. The terms one-to-one and + * one-to-many are used to indicate whether the face in question + * is shared with one cell or several cells. + * For example, if your data is arranged as follows: + + ----------------------- + | | | | + | 1 | 2 | 3 | + | | | | + ----------------------- + | | | + | 4 | 5 | + | | | + ----------------------- + * The face between 1 & 4 is local-one-to-one. The face between + * 5 and (2 & 3) is local one-to-many. + */ + + INTEGER4 FNMode = 2; + + INTEGER4 TotalNumFaceNodes = 1; /* Not used for + * FEQuad zones*/ + INTEGER4 NumConnectedBoundaryFaces = 1; /* Not used for + * FEQuad zones*/ + INTEGER4 TotalNumBoundaryConnections = 1; /* Not used for + * FEQuad zones*/ + INTEGER4 ShrConn = 0; + + INTEGER4 ValueLocation[3] = {1, 1, 1}; /* Specify the variable + * values at the nodes. + * NOTE: Because all of + * the variables are + * defined at the nodes, + * we can just pass + * NULL for this array. + * We are providing the + * array for illustration + * purposes. + */ + + I = TECZNE112((char*)"Zone 1", + &ZoneType, + &NumPts, + &NumElems, + &NumFaces, + &ICellMax, + &JCellMax, + &KCellMax, + &SolTime, + &StrandID, + &ParentZn, + &IsBlock, + &NFConns, + &FNMode, + &TotalNumFaceNodes, + &NumConnectedBoundaryFaces, + &TotalNumBoundaryConnections, + NULL, + ValueLocation, + NULL, + &ShrConn); + /* DOCEND */ + + /* Set up the variable values. The variable values will be + * written to the file using TECDAT. Because we are specifying + * nodal variables (as specified via the ValueLocation + * parameter in TECZNE, each variable is dimensioned by the + * number of points (NumPts) in the Zone. You have the option + * to specify some variables with nodal values and some with + * cell-centered values. Refer to the Binary Function + * Reference for details. + */ + + /* DOCSTART:faceneighbors_tecdat1.txt*/ + float *X = new float[NumPts]; + float *Y = new float[NumPts]; + float *P = new float[NumPts]; + + /* For this example, we will create 2 rectangular cells in Zone + * 1. Before defining your variables, you must establish a + * consistent node numbering scheme for your data. Once the + * node numbers are defined, supply the variable values in the + * node numbering order. In this example, node 1 is defined at + * X = 0 and Y = 0. As such, the first value supplied for X + * (i.e. X[0]) is 0. Similarly, the first value supplied for Y + * is 0. + * + * It is important that you refer to node numbers consistently. + * The node numbers will be used later to define the + * connectivity for each element. + */ + + X[0] = 0; + X[1] = 0; + X[2] = 1; + X[3] = 1; + X[4] = 2; + X[5] = 2; + + Y[0] = 0; + Y[1] = 1; + Y[2] = 0; + Y[3] = 1; + Y[4] = 0; + Y[5] = 1; + + for (INTEGER4 ii = 0; ii < NumPts; ii++) + P[ii] = (float)(NumPts - ii); + + INTEGER4 DIsDouble = 0; /* Set DIsDouble to zero to use + * variables in float format. + */ + + /* Call TECDAT once for each variable */ + I = TECDAT112(&NumPts, &X[0], &DIsDouble); + I = TECDAT112(&NumPts, &Y[0], &DIsDouble); + I = TECDAT112(&NumPts, &P[0], &DIsDouble); + /* DOCEND */ + + /* Define the face neighbors connections. + * The Connectivity List is used to specify the nodes that + * compose each element. When working with nodal variables, the + * numbering of the nodes is implicitly defined when the + * variables are declared. The first value of each variable is + * for node one, the second value for node two, and so on. + * + * Because this zone contains two quadilateral elements, we must + * supply 8 values in the connectivity list. The first four + * values define the nodes that form element 1. Similarly, the + * second four values define the nodes that form element 2. + */ + + /* DOCSTART:faceneighbors_tecnod1.txt*/ + INTEGER4 ConnList[8] = {1, 3, 4, 2, + 3, 5, 6, 4 + }; + I = TECNOD112(ConnList); + /* DOCEND */ + + /* TIP! It is important to provide the node list in either a + * clockwise or counter-clockwise order. Otherwise, your + * elements will be misformed. For example, if the first two + * numbers in the above connectivity list, the zone would + * appear as follows: + */ + + /* Now that TECNOD has been called, the creation of Zone 1 + * is complete. However, in this example, we will define a + * face neighbor between Zone 1 and Zone 2 (to be created + * later in the example). Face Neighbor connections are used + * to define connections that are not created via the + * connectivity list. For example, local face neighbors may + * need to be defined when a zone wraps itself and global face + * neighbors may need to be defined to smooth edges across + * zones. Face Neighbors are used when deriving variables and + * drawing contours. + * + * In this example, we are creating a face neighbor connection + * between cell 2 in Zone 1 and cell 1 in Zone 2. The + * information required when specifying face neighbors + * depends upon the type of connection. + * + * In this case, we must supply (in this order): + * - the cell number in the current zone that contains the + * - the number of the face in that cell that contains the + * face neighbor + * - the number of the other zone to which the face is + * connected + * - the number of the cell in the other zone to which the + * face is connected + * The face numbering for cell-based finite elements is + * defined using the picture displayed in the Data Format + * Guide. In this example, face 2 in cell 2 in the current + * zone is connected to cell 1 in zone 2. + */ + + /* DOCSTART:faceneighbors_tecface1.txt*/ + INTEGER4 FaceConn[4] = {2, 2, 2, 1}; + I = TECFACE112(FaceConn); + /* DOCEND */ + + /* The creation of Zone 1 is complete. We are ready to create + * Zone 2. For simplicity, Zone 2 is a copy of Zone 1 shifted + * along the X-axis. As such, many of the variables used to + * create Zone 1 are re-used here. + */ + /* DOCSTART:faceneighbors_teczne2.txt*/ + /* Call TECZNE to create Zone 2 */ + I = TECZNE112((char*)"Zone 2", + &ZoneType, + &NumPts, + &NumElems, + &NumFaces, + &ICellMax, + &JCellMax, + &KCellMax, + &SolTime, + &StrandID, + &ParentZn, + &IsBlock, + &NFConns, + &FNMode, + &TotalNumFaceNodes, + &NumConnectedBoundaryFaces, + &TotalNumBoundaryConnections, + NULL, + ValueLocation, + NULL, + &ShrConn); + /* DOCEND */ + + /* Define the variables for Zone 2. Because Zone 2 is a copy + * of Zone 1, shifted along the X-axis, we can share the Y + * variable definition used to Zone. We will also create a + * second pressure variable for Zone 2 (P2). + */ + + /* DOCSTART:faceneighbors_tecdat2.txt*/ + float *X2 = new float[NumPts]; + float *P2 = new float[NumPts]; + + for (INTEGER4 ii = 0; ii < NumPts; ii++) + { + X2[ii] = X[ii] + 2; + P2[ii] = 2 * (float)ii; + } + + I = TECDAT112(&NumPts, &X2[0], &DIsDouble); + I = TECDAT112(&NumPts, &Y[0], &DIsDouble); + I = TECDAT112(&NumPts, &P2[0], &DIsDouble); + + delete X; + delete Y; + delete P; + delete X2; + delete P2; + /* DOCEND */ + + /* As with Zone 1, we must define the connectivity list for + * Zone 2. Because, the node numbering restarts at one for each + * new zone and the nodal arrangement is identical between the + * two zones, we may reuse the connectivity list from Zone 1. + */ + + /* DOCSTART:faceneighbors_tecnod2.txt*/ + I = TECNOD112(ConnList); + /* DOCEND */ + + /* We will now specify the face neighbor connection with + * respect to our new current zone of Zone 2. + */ + + /* DOCSTART:faceneighbors_tecface2.txt*/ + INTEGER4 FaceConn2[4] = {1, 4, 1, 2}; /* cell 1, face 4 in + * current zone is a + * neighbor to cell 2 in + * zone 1. + */ + I = TECFACE112(FaceConn2); + /* DOCEND */ + + /* Call TECEND to close the file */ + /* DOCSTART:faceneighbors_tecend.txt*/ + I = TECEND112(); + /* DOCEND */ + + return 0; +} diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/faceneighbors/faceneighbors.vcproj b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/faceneighbors/faceneighbors.vcproj new file mode 100644 index 0000000000000000000000000000000000000000..c3099ffedb9f173bdcb8776047d2b4586ad16906 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/faceneighbors/faceneighbors.vcproj @@ -0,0 +1,172 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="faceneighbors" + ProjectGUID="{1074FD63-4831-4D1B-8A27-94A3AC33A509}" + RootNamespace="faceneighbors" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + GenerateDebugInformation="true" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="2" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + RuntimeLibrary="2" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + GenerateDebugInformation="true" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <File + RelativePath=".\faceneighbors.cpp" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/gridsolution/Makefile b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/gridsolution/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..d901ed95c19213aa88cf9dffea79c48a62897657 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/gridsolution/Makefile @@ -0,0 +1,11 @@ +# Set to appropriate C++ compiler +CPP=g++ +CPPFLAGS=-I../../tecsrc ../../tecio.a +EXECUTABLE=gridsolution +FILES=$(EXECUTABLE).cpp + +build: + $(CPP) $(FILES) $(CPPFLAGS) -o $(EXECUTABLE) + +clean: + rm -f $(EXECUTABLE) diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/gridsolution/gridsolution.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/gridsolution/gridsolution.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8cf2e5489493aebf31bf8a0f452c86302ea2e7fc --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/gridsolution/gridsolution.cpp @@ -0,0 +1,376 @@ +/* This example illustrates using separate grid + * and solution files. + */ + +#include "TECIO.h" +#include "MASTER.h" /* for defintion of NULL */ + +int main() +{ + /* DOCSTART:gridsolution_grid_tecini.txt*/ + INTEGER4 I; /* use to check return values */ + + INTEGER4 Debug = 1; + INTEGER4 VIsDouble = 0; + INTEGER4 FileType = 1; /* 1 = grid file. */ + + I = TECINI112((char*)"Example: Separate grid and solution files", + (char*)"X Y Z", /* Defines the variables for the data file. + * Each zone must contain each of the vars + * listed here. The order of the variables + * in the list is used to define the + * variable number (e.g. X is Variable 1). + * When referring to variables in other + * TecIO functions, you will refer to the + * variable by its number. + */ + (char*)"grid.plt", + (char*)".", /* scratch directory */ + &FileType, + &Debug, + &VIsDouble); + /* DOCEND */ + + /* DOCSTART:gridsolution_grid_teczne.txt*/ + /* TECZNE Parameters */ + INTEGER4 ZoneType = 7; /* FE Polyhedron */ + INTEGER4 NumPts = 20; /* the number of unique + * nodes in the zone. + */ + INTEGER4 NumElems = 1; + INTEGER4 NumFaces = 12; /* the number of unique + * faces in the zone. + */ + INTEGER4 ICellMax = 0; /* not used */ + INTEGER4 JCellMax = 0; /* not used */ + INTEGER4 KCellMax = 0; /* not used */ + double SolutionTime = 0.0; + INTEGER4 StrandID = 1; /* time strand for + * unsteady solution. + */ + INTEGER4 ParentZone = 0; + INTEGER4 IsBlock = 1; + INTEGER4 NumFaceConnections = 0; + INTEGER4 FaceNeighborMode = 1; + INTEGER4 SharConn = 0; + + /* For this zone, the total number of face nodes is + * five times number of faces, because each face + * is a pentagon. + */ + INTEGER4 TotalNumFaceNodes = 5 * NumFaces; + + /* This zone has no connected boundary faces. + */ + INTEGER4 TotalNumBndryFaces = 0; + INTEGER4 TotalNumBndryConns = 0; + + I = TECZNE112((char*)"Dodecahedron", /* Name of the zone. */ + &ZoneType, + &NumPts, + &NumElems, + &NumFaces, + &ICellMax, + &JCellMax, + &KCellMax, + &SolutionTime, + &StrandID, + &ParentZone, + &IsBlock, + &NumFaceConnections, + &FaceNeighborMode, + &TotalNumFaceNodes, + &TotalNumBndryFaces, + &TotalNumBndryConns, + NULL, + NULL, /* All nodal variables */ + NULL, + &SharConn); + /* DOCEND */ + + /* DOCSTART:gridsolution_grid_tecdat.txt*/ + + /* TECDAT Parameters */ + double Phi = 0.5 * (1.0 + sqrt(5.0)); + double Pi = 3.141592653578; + double *X = new double[NumPts]; + double *Y = new double[NumPts]; + double *Z = new double[NumPts]; + int Count = 0; + + for(int J = 0; J <= 4; J++) + { + X[Count] = 2.0 * cos(2.0 / 5.0 * Pi * J); + Y[Count] = 2.0 * sin(2.0 / 5.0 * Pi * J); + Z[Count] = Phi + 1.0; + Count++; + + X[Count] = -X[Count - 1]; + Y[Count] = -Y[Count - 1]; + Z[Count] = -Z[Count - 1]; + Count++; + + X[Count] = 2.0 * Phi * cos(2.0 / 5.0 * Pi * J); + Y[Count] = 2.0 * Phi * sin(2.0 / 5.0 * Pi * J); + Z[Count] = Phi - 1.0; + Count++; + + X[Count] = -X[Count - 1]; + Y[Count] = -Y[Count - 1]; + Z[Count] = -Z[Count - 1]; + Count++; + } + + INTEGER4 IsDouble = 1; + + I = TECDAT112(&NumPts, X, &IsDouble); + I = TECDAT112(&NumPts, Y, &IsDouble); + I = TECDAT112(&NumPts, Z, &IsDouble); + + delete X; + delete Y; + delete Z; + + /* DOCEND */ + + /* DOCSTART:gridsolution_grid_facenodes.txt*/ + /* TecPoly Parameters */ + + /* Create a FaceNodes array, dimensioned by the total number + * of face nodes in the zone. + */ + INTEGER4 *FaceNodes = new INTEGER4[TotalNumFaceNodes]; + int n = 0; + + /* Face Nodes for face 1 of the dodecahedron */ + FaceNodes[n++] = 2; + FaceNodes[n++] = 6; + FaceNodes[n++] = 10; + FaceNodes[n++] = 14; + FaceNodes[n++] = 18; + + /* Face Nodes for face 2 */ + FaceNodes[n++] = 6; + FaceNodes[n++] = 8; + FaceNodes[n++] = 19; + FaceNodes[n++] = 12; + FaceNodes[n++] = 10; + + /* Face Nodes for face 3 */ + FaceNodes[n++] = 3; + FaceNodes[n++] = 12; + FaceNodes[n++] = 10; + FaceNodes[n++] = 14; + FaceNodes[n++] = 16; + + /* Face Nodes for face 4 */ + FaceNodes[n++] = 7; + FaceNodes[n++] = 16; + FaceNodes[n++] = 14; + FaceNodes[n++] = 18; + FaceNodes[n++] = 20; + + /* Face Nodes for face 5 */ + FaceNodes[n++] = 2; + FaceNodes[n++] = 4; + FaceNodes[n++] = 11; + FaceNodes[n++] = 20; + FaceNodes[n++] = 18; + + /* Face Nodes for face 6 */ + FaceNodes[n++] = 2; + FaceNodes[n++] = 4; + FaceNodes[n++] = 15; + FaceNodes[n++] = 8; + FaceNodes[n++] = 6; + + /* Face Nodes for face 7 */ + FaceNodes[n++] = 1; + FaceNodes[n++] = 3; + FaceNodes[n++] = 12; + FaceNodes[n++] = 19; + FaceNodes[n++] = 17; + + /* Face Nodes for face 8 */ + FaceNodes[n++] = 1; + FaceNodes[n++] = 3; + FaceNodes[n++] = 16; + FaceNodes[n++] = 7; + FaceNodes[n++] = 5; + + /* Face Nodes for face 9 */ + FaceNodes[n++] = 5; + FaceNodes[n++] = 7; + FaceNodes[n++] = 20; + FaceNodes[n++] = 11; + FaceNodes[n++] = 9; + + /* Face Nodes for face 10 */ + FaceNodes[n++] = 4; + FaceNodes[n++] = 11; + FaceNodes[n++] = 9; + FaceNodes[n++] = 13; + FaceNodes[n++] = 15; + + /* Face Nodes for face 11 */ + FaceNodes[n++] = 8; + FaceNodes[n++] = 15; + FaceNodes[n++] = 13; + FaceNodes[n++] = 17; + FaceNodes[n++] = 19; + + /* Face Nodes for face 12 */ + FaceNodes[n++] = 1; + FaceNodes[n++] = 5; + FaceNodes[n++] = 9; + FaceNodes[n++] = 13; + FaceNodes[n++] = 17; + + /* DOCEND */ + + /* Specify the number of nodes for each face, and the right and + * left neighboring elements. The neighboring elements can be + * determined using the right-hand rule. For each face, curl + * the fingers of your right hand in the direction of + * incrementing node numbers (i.e. from Node 1 to Node 2 and + * so on). Your thumb will point toward the right element. + * A value of zero indicates that there is no + * neighboring element on that side. A negative value + * indicates that the neighboring element is in another zone. + * In that case, the number is a pointer into the + * FaceBndryConnectionElems and FaceBndryConnectionZones arrays. + */ + + /* DOCSTART:gridsolution_grid_tecpoly.txt*/ + INTEGER4 *FaceNodeCounts = new INTEGER4[NumFaces]; + INTEGER4 *FaceLeftElems = new INTEGER4[NumFaces]; + INTEGER4 *FaceRightElems = new INTEGER4[NumFaces]; + + /* For this particular zone, each face has the 5 nodes. */ + for(int J = 0; J < NumFaces; J++) + FaceNodeCounts[J] = 5; + + /* Set the right and left elements for each face. */ + FaceRightElems[0] = 1; + FaceRightElems[1] = 1; + FaceRightElems[2] = 0; + FaceRightElems[3] = 0; + FaceRightElems[4] = 0; + FaceRightElems[5] = 1; + FaceRightElems[6] = 1; + FaceRightElems[7] = 0; + FaceRightElems[8] = 0; + FaceRightElems[9] = 1; + FaceRightElems[10] = 1; + FaceRightElems[11] = 0; + + FaceLeftElems[0] = 0; + FaceLeftElems[1] = 0; + FaceLeftElems[2] = 1; + FaceLeftElems[3] = 1; + FaceLeftElems[4] = 1; + FaceLeftElems[5] = 0; + FaceLeftElems[6] = 0; + FaceLeftElems[7] = 1; + FaceLeftElems[8] = 1; + FaceLeftElems[9] = 0; + FaceLeftElems[10] = 0; + FaceLeftElems[11] = 1; + + I = TECPOLY112(FaceNodeCounts, + FaceNodes, + FaceLeftElems, + FaceRightElems, + NULL, /* No boundary connections. */ + NULL, + NULL); + + delete FaceNodes; + delete FaceLeftElems; + delete FaceRightElems; + + /* DOCEND */ + + + /* DOCSTART:gridsolution_grid_tecend.txt*/ + I = TECEND112(); + /* DOCEND */ + + /* DOCSTART:gridsolution_solution_tecini.txt*/ + for(int J = 0; J < 5; J++) + { + char SolutionFileName[128]; + sprintf(SolutionFileName, "solution%d.plt", J); + + /* DOCSTART:gridsolution_solution_tecini.txt*/ + FileType = 2; /* 1 = solution file. */ + + I = TECINI112((char*)"Example: Separate grid and solution files", + (char*)"P T", /* Defines the variables for the solution file. + * Note that these are different variables from + * the grid file. + */ + SolutionFileName, + (char*)".", /* scratch directory */ + &FileType, + &Debug, + &VIsDouble); + /* DOCEND */ + + /* DOCSTART:gridsolution_solution_teczne.txt*/ + /* TECZNE Parameters are mostly unchanged from creation of the grid file. */ + TotalNumFaceNodes = 0; + SolutionTime = J; + + char ZoneName[128]; + sprintf(ZoneName, "Dodecahedron Time=%g", SolutionTime); + I = TECZNE112(ZoneName, + &ZoneType, + &NumPts, + &NumElems, + &NumFaces, + &ICellMax, + &JCellMax, + &KCellMax, + &SolutionTime, + &StrandID, + &ParentZone, + &IsBlock, + &NumFaceConnections, + &FaceNeighborMode, + &TotalNumFaceNodes, + &TotalNumBndryFaces, + &TotalNumBndryConns, + NULL, + NULL, /* All nodal variables */ + NULL, + &SharConn); + /* DOCEND */ + + /* DOCSTART:gridsolution_solution_tecdat.txt*/ + + /* TECDAT Parameters */ + double *P = new double[NumPts]; + double *T = new double[NumPts]; + + for(int K = 0; K < NumPts; K++) + { + P[K] = (double)(K + J); + T[K] = 1.0 + K + K; + } + + I = TECDAT112(&NumPts, P, &IsDouble); + I = TECDAT112(&NumPts, T, &IsDouble); + + delete P; + delete T; + + /* DOCEND */ + + /* DOCSTART:gridsolution_solution_tecend.txt*/ + I = TECEND112(); + /* DOCEND */ + } + + return 0; +} diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/gridsolution/gridsolution.vcproj b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/gridsolution/gridsolution.vcproj new file mode 100644 index 0000000000000000000000000000000000000000..7e333fd22708314290305bc0345e86642c24e485 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/gridsolution/gridsolution.vcproj @@ -0,0 +1,321 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="gridsolution" + ProjectGUID="{D2747EA6-7807-42E1-984D-C946B3D97D95}" + RootNamespace="mulitplepolygons" + > + <Platforms> + <Platform + Name="Win32" + /> + <Platform + Name="x64" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + GenerateDebugInformation="true" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="2" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + RuntimeLibrary="2" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + GenerateDebugInformation="true" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Debug|x64" + OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)" + IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + TargetEnvironment="3" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + GenerateDebugInformation="true" + TargetMachine="17" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|x64" + OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)" + IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="2" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + TargetEnvironment="3" + /> + <Tool + Name="VCCLCompilerTool" + RuntimeLibrary="2" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + GenerateDebugInformation="true" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="17" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <File + RelativePath=".\gridsolution.cpp" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/ij_ordered/Makefile b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/ij_ordered/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..90411d11e22dbb5b2625cb51ed580a598d6e0709 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/ij_ordered/Makefile @@ -0,0 +1,11 @@ +# Set to appropriate C++ compiler +CPP=g++ +CPPFLAGS=-I../../tecsrc ../../tecio.a +EXECUTABLE=ij_ordered +FILES=$(EXECUTABLE).cpp + +build: + $(CPP) $(FILES) $(CPPFLAGS) -o $(EXECUTABLE) + +clean: + rm -f $(EXECUTABLE) \ No newline at end of file diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/ij_ordered/ij_ordered.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/ij_ordered/ij_ordered.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2f13c1f4a37f46f00483d38184f1c3e036b9acf9 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/ij_ordered/ij_ordered.cpp @@ -0,0 +1,149 @@ +/* This example creates a simple set of IJ-ordered zones */ +/* DOCSTART:ij_ordered.txt*/ +#include "TECIO.h" +#include "MASTER.h" /* for defintion of NULL */ + +int main() +{ + INTEGER4 Debug = 1; + INTEGER4 VIsDouble = 0; + INTEGER4 FileType = 0; + INTEGER4 I = 0; /* Used to track return codes */ + + /* + * Open the file and write the tecplot datafile + * header information + */ + I = TECINI112((char*)"IJ Ordered Zones", /* Name of the entire + * dataset. + */ + (char*)"X Y P", /* Defines the variables for the data + * file. Each zone must contain each of + * the variables listed here. The order + * of the variables in the list is used + * to define the variable number (e.g. + * X is Var 1). + */ + (char*)"ij_ordered.plt", + (char*)".", /* Scratch Directory */ + &FileType, + &Debug, + &VIsDouble); + + float X1[4]; + float Y1[4]; + float P1[4]; + float X2[4]; + float Y2[4]; + float P2[4]; + + INTEGER4 ICellMax = 0; + INTEGER4 JCellMax = 0; + INTEGER4 KCellMax = 0; + INTEGER4 DIsDouble = 0; + double SolTime = 360.0; + INTEGER4 StrandID = 0; /* StaticZone */ + INTEGER4 ParentZn = 0; + INTEGER4 IsBlock = 1; /* Block */ + INTEGER4 NFConns = 0; + INTEGER4 FNMode = 0; + INTEGER4 TotalNumFaceNodes = 1; + INTEGER4 TotalNumBndryFaces = 1; + INTEGER4 TotalNumBndryConnections = 1; + INTEGER4 ShrConn = 0; + + /*Ordered Zone Parameters*/ + INTEGER4 IMax = 2; + INTEGER4 JMax = 2; + INTEGER4 KMax = 1; + + X1[0] = .125; + Y1[0] = .5; + P1[0] = 5; + + X1[1] = .625; + Y1[1] = .5; + P1[1] = 7.5; + + X1[2] = .125; + Y1[2] = .875; + P1[2] = 10; + + X1[3] = .625; + Y1[3] = .875; + P1[3] = 7.5; + + X2[0] = .375; + Y2[0] = .125; + P2[0] = 5; + + X2[1] = .875; + Y2[1] = .125; + P2[1] = 7.5; + + X2[2] = .375; + Y2[2] = .5; + P2[2] = 10; + + X2[3] = .875; + Y2[3] = .5; + P2[3] = 7.5; + + /* Ordered Zone */ + INTEGER4 ZoneType = 0; + I = TECZNE112((char*)"Ordered Zone", + &ZoneType, + &IMax, + &JMax, + &KMax, + &ICellMax, + &JCellMax, + &KCellMax, + &SolTime, + &StrandID, + &ParentZn, + &IsBlock, + &NFConns, + &FNMode, + &TotalNumFaceNodes, + &TotalNumBndryFaces, + &TotalNumBndryConnections, + NULL, + NULL, + NULL, + &ShrConn); + INTEGER4 III = IMax * JMax * KMax; + I = TECDAT112(&III, X1, &DIsDouble); + I = TECDAT112(&III, Y1, &DIsDouble); + I = TECDAT112(&III, P1, &DIsDouble); + + I = TECZNE112((char*)"Ordered Zone2", + &ZoneType, + &IMax, + &JMax, + &KMax, + &ICellMax, + &JCellMax, + &KCellMax, + &SolTime, + &StrandID, + &ParentZn, + &IsBlock, + &NFConns, + &FNMode, + &TotalNumFaceNodes, + &TotalNumBndryFaces, + &TotalNumBndryConnections, + NULL, + NULL, + NULL, + &ShrConn); + + I = TECDAT112(&III, X2, &DIsDouble); + I = TECDAT112(&III, Y2, &DIsDouble); + I = TECDAT112(&III, P2, &DIsDouble); + + I = TECEND112(); + return 0; +} +/* DOCEND */ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/ij_ordered/ij_ordered.plt b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/ij_ordered/ij_ordered.plt new file mode 100644 index 0000000000000000000000000000000000000000..81f210b6c2d7abc0e87795395027da100999e7af Binary files /dev/null and b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/ij_ordered/ij_ordered.plt differ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/ij_ordered/ij_ordered.vcproj b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/ij_ordered/ij_ordered.vcproj new file mode 100644 index 0000000000000000000000000000000000000000..94c67c6c071e2636874d7be8727461c41af11a7f --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/ij_ordered/ij_ordered.vcproj @@ -0,0 +1,172 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="ij_ordered" + ProjectGUID="{47556A00-C441-4B9A-8920-91CA63AC1595}" + RootNamespace="ij_ordered" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + GenerateDebugInformation="true" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="2" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + RuntimeLibrary="2" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + GenerateDebugInformation="true" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <File + RelativePath=".\ij_ordered.cpp" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/multiplefiles/Makefile b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/multiplefiles/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..d55d2ee044072de104c6ec3e8ab53bccf1a6e061 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/multiplefiles/Makefile @@ -0,0 +1,11 @@ +# Set to appropriate C++ compiler +CPP=g++ +CPPFLAGS=-I../../tecsrc ../../tecio.a +EXECUTABLE=multiplefiles +FILES=$(EXECUTABLE).cpp + +build: + $(CPP) $(FILES) $(CPPFLAGS) -o $(EXECUTABLE) + +clean: + rm -f $(EXECUTABLE) \ No newline at end of file diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/multiplefiles/file1.plt b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/multiplefiles/file1.plt new file mode 100644 index 0000000000000000000000000000000000000000..b0c368e03f3ff83c0a739471d901361b130eb257 Binary files /dev/null and b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/multiplefiles/file1.plt differ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/multiplefiles/file2.plt b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/multiplefiles/file2.plt new file mode 100644 index 0000000000000000000000000000000000000000..8a36da392bfd89d1328b3cf5bec0e5bfbb1fbd0d Binary files /dev/null and b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/multiplefiles/file2.plt differ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/multiplefiles/multiplefiles.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/multiplefiles/multiplefiles.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b79085ff561fad2a323ae1bdc092d8a13feecf42 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/multiplefiles/multiplefiles.cpp @@ -0,0 +1,214 @@ +/* This example illustrates working with TecFil to create multiple + * plt files simultaneously. + */ +#if defined _MSC_VER +#pragma warning (disable: 4996) /* Windows strcpy warning off */ +#endif +/* DOCSTART:mulitplefiles.txt */ +#include "TECIO.h" +#include "MASTER.h" /* for defintion of NULL */ +#include <string.h> + +int main() +{ + /* + * Open the file and write the tecplot datafile + * header information + */ + INTEGER4 Debug = 1; + INTEGER4 VIsDouble = 0; + INTEGER4 FileType = 0; + INTEGER4 I = 0; /* Used to check the return value */ + + I = TECINI112((char*)"SIMPLE DATASET", /* Name of the entire dataset.*/ + + (char*)"X1 Y1 P1", /* Defines the variables for the data + * file. Each zone must contain each of + * the variables listed here. The order + * of the variables in the list is used + * to define the variable number (e.g. + * X1 is Var 1). + */ + (char*)"file1.plt", + (char*)".", /* Scratch Directory */ + &FileType, + &Debug, + &VIsDouble); + + /* Set the parameters for TecZne */ + INTEGER4 ZoneType = 0; /* sets the zone type to + * ordered + */ + INTEGER4 IMax = 2; /* Create an IJ-ordered zone, + * by using IMax and JMax + * values that are greater + * than one, and setting KMax + * to one. + */ + INTEGER4 JMax = 2; + INTEGER4 KMax = 1; + + double SolTime = 0; + INTEGER4 StrandID = 0; /* StaticZone */ + INTEGER4 ParentZn = 0; /* used for surface streams */ + + INTEGER4 ICellMax = 0; /* not used */ + INTEGER4 JCellMax = 0; /* not used */ + INTEGER4 KCellMax = 0; /* not used */ + + INTEGER4 IsBlock = 1; /* Block */ + + INTEGER4 NFConns = 0; /* this example does not use + * face neighbors */ + INTEGER4 FNMode = 0; + INTEGER4 TotalNumFaceNodes = 1; + INTEGER4 TotalNumBndryFaces = 1; + INTEGER4 TotalNumBndryConn = 1; + INTEGER4 ShrConn = 0; + + + /* Create an Ordered Zone */ + I = TECZNE112((char*)"Ordered Zone", + &ZoneType, + &IMax, + &JMax, + &KMax, + &ICellMax, + &JCellMax, + &KCellMax, + &SolTime, + &StrandID, + &ParentZn, + &IsBlock, + &NFConns, + &FNMode, + &TotalNumFaceNodes, + &TotalNumBndryFaces, + &TotalNumBndryConn, + NULL, + NULL, + NULL, + &ShrConn); + + /* Set the variable values for the ordered zone. */ + float X1[4]; + float Y1[4]; + float P1[4]; + + X1[0] = 0.125; + Y1[0] = 0.5; + P1[0] = 7.5; + + X1[1] = 0.625; + Y1[1] = 0.5; + P1[1] = 10.0; + + X1[2] = 0.125; + Y1[2] = 0.875; + P1[2] = 5.0; + + X1[3] = 0.625; + Y1[3] = 0.875; + P1[3] = 7.5; + + INTEGER4 DIsDouble = 0; /* set DIsDouble to 0, for float + * values. + */ + + INTEGER4 III = IMax * JMax * KMax; + I = TECDAT112(&III, X1, &DIsDouble); + I = TECDAT112(&III, Y1, &DIsDouble); + I = TECDAT112(&III, P1, &DIsDouble); + + /* Open a new data file. note: the first file is still open + * because TecEnd was not called. + */ + I = TECINI112((char*)"Auxiliary Data", + (char*)"X1 Y1 P1", + (char*)"file2.plt", + (char*)".", + &FileType, + &Debug, + &VIsDouble); + + /* Switch the active file to the newly created data file + * (file2.plt) which is the second file opened with TECINI112 + * so we use 2. + */ + INTEGER4 WhichFile = 2; + I = TECFIL112(&WhichFile); + + /* Create a second zone, using many of the values from the first + * zone, and write it to the second data file. + */ + + I = TECZNE112((char*)"Ordered Zone2", + &ZoneType, + &IMax, + &JMax, + &KMax, + &ICellMax, + &JCellMax, + &KCellMax, + &SolTime, + &StrandID, + &ParentZn, + &IsBlock, + &NFConns, + &FNMode, + &TotalNumFaceNodes, + &TotalNumBndryFaces, + &TotalNumBndryConn, + NULL, + NULL, + NULL, + &ShrConn); + /* set the variable values for the second zone */ + float X2[4]; + float Y2[4]; + float P2[4]; + + X2[0] = 0.375; + Y2[0] = 0.125; + P2[0] = 5; + + X2[1] = 0.875; + Y2[1] = 0.125; + P2[1] = 7.5; + + X2[2] = 0.375; + Y2[2] = 0.5; + P2[2] = 10; + + Y2[3] = 0.5; + X2[3] = 0.875; + P2[3] = 7.5; + + III = IMax * JMax * KMax; + I = TECDAT112(&III, X2, &DIsDouble); + I = TECDAT112(&III, Y2, &DIsDouble); + I = TECDAT112(&III, P2, &DIsDouble); + + /* Switch to the first file. */ + WhichFile = 1; + I = TECFIL112(&WhichFile); + + /* Create an auxiliary data value and write it to the file */ + char DeformationValue[128]; + strcpy(DeformationValue, "0.98"); + + I = TECAUXSTR112((char*)"DeformationValue", + DeformationValue); + /* Close the first file */ + I = TECEND112(); + + /* The remaining file will become the active file. As such, + * TecFil does not need to be called again to close the second + * file. + */ + I = TECEND112(); + + return 0; +} + +/* DOCEND */ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/multiplefiles/multiplefiles.vcproj b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/multiplefiles/multiplefiles.vcproj new file mode 100644 index 0000000000000000000000000000000000000000..84651a69d03fdb5c920b3239c46f5df7be908a76 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/multiplefiles/multiplefiles.vcproj @@ -0,0 +1,172 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="multiplefiles" + ProjectGUID="{93CB23B2-530F-4D6F-900F-893815299C7F}" + RootNamespace="multiplefiles" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + GenerateDebugInformation="true" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="2" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + RuntimeLibrary="2" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + GenerateDebugInformation="true" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <File + RelativePath=".\multiplefiles.cpp" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/multiplepolygons/HexagonsAndOctagon.plt b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/multiplepolygons/HexagonsAndOctagon.plt new file mode 100644 index 0000000000000000000000000000000000000000..3b4f3042c69b7ea023e8de723b7e40c5b7f6eaf2 Binary files /dev/null and b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/multiplepolygons/HexagonsAndOctagon.plt differ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/multiplepolygons/Makefile b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/multiplepolygons/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..d11ec5afd65b1b797a81c71dfc6da34109dd018f --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/multiplepolygons/Makefile @@ -0,0 +1,11 @@ +# Set to appropriate C++ compiler +CPP=g++ +CPPFLAGS=-I../../tecsrc ../../tecio.a +EXECUTABLE=multiplepolygons +FILES=$(EXECUTABLE).cpp + +build: + $(CPP) $(FILES) $(CPPFLAGS) -o $(EXECUTABLE) + +clean: + rm -f $(EXECUTABLE) \ No newline at end of file diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/multiplepolygons/multiplepolygons.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/multiplepolygons/multiplepolygons.cpp new file mode 100644 index 0000000000000000000000000000000000000000..25632634f98b972d4e4f48282d91279ff1d39217 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/multiplepolygons/multiplepolygons.cpp @@ -0,0 +1,569 @@ +/* This example illustrates using TecPoly to create two polygonal + * zones. The first zone contains six hexagons, and the second + * zone contains a hexagon and an octagon. Refer to the Data + * Format Guide for a picture of the configuration, including node + * and face numbers. + */ + +#include "TECIO.h" +#include "MASTER.h" /* for defintion of NULL */ + +int main() +{ + /* DOCSTART:hexagons_tecini.txt*/ + INTEGER4 I; /* use to check return values */ + + INTEGER4 Debug = 1; + INTEGER4 VIsDouble = 0; + INTEGER4 FileType = 0; + + I = TECINI112((char*)"Example: Multiple polygonal zones", + (char*)"X Y P", /* Defines the variables for the data file. + * Each zone must contain each of the vars + * listed here. The order of the variables + * in the list is used to define the + * variable number (e.g. X is Variable 1). + * When referring to variables in other + * TecIO functions, you will refer to the + * variable by its number. + */ + (char*)"HexagonsAndOctagon.plt", + (char*)".", /* scratch directory */ + &FileType, + &Debug, + &VIsDouble); + /* DOCEND */ + + /* DOCSTART:hexagons_zone1_teczne.txt*/ + /* TECZNE Parameters */ + INTEGER4 ZoneType = 6; /* FE Polygon */ + INTEGER4 NumPts_Z1 = 13; /* the number of unique + * nodes in the zone. + */ + INTEGER4 NumElems_Z1 = 3; + INTEGER4 NumFaces_Z1 = 15; /* the number of unique + * faces in the zone. + */ + INTEGER4 ICellMax = 0; /* not used */ + INTEGER4 JCellMax = 0; /* not used */ + INTEGER4 KCellMax = 0; /* not used */ + double SolutionTime = 0.0; + INTEGER4 StrandID = 0; + INTEGER4 ParentZone = 0; + INTEGER4 IsBlock = 1; + INTEGER4 NumFaceConnections = 0; + INTEGER4 FaceNeighborMode = 1; + INTEGER4 SharConn = 0; + + INTEGER4 ValueLocation[3] = { 1, 1, 0 }; + + /* For a polygonal zone, the total number of face nodes is + * twice the total number of faces. This is because each face + * is composed of exactly two nodes. + */ + INTEGER4 TotalNumFaceNodes_Z1 = 2 * NumFaces_Z1; + + /* A boundary face is a face that is neighbored by an element + * or elements in another zone or zone(s). In Zone 1, Face 9, + * Face 10 and Face 12 have a neighbor in Zone 2. Therefore, + * the total number of boundary faces is “3”. + */ + INTEGER4 TotalNumBndryFaces_Z1 = 3; + + /* Each boundary face has one or more boundary connections. A + * boundary connection is defined as another element in another + * zone. Face 9 has a boundary connection with Element 1 in + * Zone 2. In this example, each boundary face is connected to + * one other element, so the total number of boundary + * connections is equivalent to the total number of boundary + * faces (3). + */ + INTEGER4 TotalNumBndryConns_Z1 = 3; + + I = TECZNE112((char*)"Zone 1: 3 Hexagons", /* Specifies the name of + * the entire dataset. When + * the file is loaded into + * Tecplot, the value is + * available via the Data + * Set Info dialog. + */ + &ZoneType, + &NumPts_Z1, + &NumElems_Z1, + &NumFaces_Z1, + &ICellMax, + &JCellMax, + &KCellMax, + &SolutionTime, + &StrandID, + &ParentZone, + &IsBlock, + &NumFaceConnections, + &FaceNeighborMode, + &TotalNumFaceNodes_Z1, + &TotalNumBndryFaces_Z1, + &TotalNumBndryConns_Z1, + NULL, + ValueLocation, + NULL, + &SharConn); + /* DOCEND */ + + /* DOCSTART:hexagons_zone1_tecdat.txt*/ + + /* TECDAT Parameters */ + double *X_Z1 = new double[NumPts_Z1]; + double *Y_Z1 = new double[NumPts_Z1]; + + X_Z1[0] = 1; + Y_Z1[0] = 6; + + X_Z1[1] = 2; + Y_Z1[1] = 6; + + X_Z1[2] = 3; + Y_Z1[2] = 5; + + X_Z1[3] = 2; + Y_Z1[3] = 4; + + X_Z1[4] = 1; + Y_Z1[4] = 4; + + X_Z1[5] = 0; + Y_Z1[5] = 5; + + X_Z1[6] = 4; + Y_Z1[6] = 5; + + X_Z1[7] = 5; + Y_Z1[7] = 4; + + X_Z1[8] = 4; + Y_Z1[8] = 3; + + X_Z1[9] = 3; + Y_Z1[9] = 3; + + X_Z1[10] = 2; + Y_Z1[10] = 2; + + X_Z1[11] = 1; + Y_Z1[11] = 2; + + X_Z1[12] = 0; + Y_Z1[12] = 3; + + + double *P_Z1 = new double[NumElems_Z1]; + P_Z1[0] = 2; + P_Z1[1] = 4; + P_Z1[2] = 5; + + + INTEGER4 IsDouble = 1; + I = TECDAT112(&NumPts_Z1, X_Z1, &IsDouble); + I = TECDAT112(&NumPts_Z1, Y_Z1, &IsDouble); + I = TECDAT112(&NumElems_Z1, P_Z1, &IsDouble); + delete X_Z1; + delete Y_Z1; + delete P_Z1; + /* DOCEND */ + + /* DOCSTART:hexagons_zone1_facenodes.txt*/ + /* TecPoly Parameters */ + + /* Create a FaceNodes array, dimensioned by the total number + * of face nodes in the zone. + */ + INTEGER4 *FaceNodes_Z1 = new INTEGER4[TotalNumFaceNodes_Z1]; + + /* Face Nodes for Element 1 */ + FaceNodes_Z1[0] = 1; + FaceNodes_Z1[1] = 2; + + FaceNodes_Z1[2] = 2; + FaceNodes_Z1[3] = 3; + + FaceNodes_Z1[4] = 3; + FaceNodes_Z1[5] = 4; + + FaceNodes_Z1[6] = 4; + FaceNodes_Z1[7] = 5; + + FaceNodes_Z1[8] = 5; + FaceNodes_Z1[9] = 6; + + FaceNodes_Z1[10] = 6; + FaceNodes_Z1[11] = 1; + + /* Face Nodes for Element 2 */ + FaceNodes_Z1[12] = 3; + FaceNodes_Z1[13] = 7; + + FaceNodes_Z1[14] = 7; + FaceNodes_Z1[15] = 8; + + FaceNodes_Z1[16] = 8; + FaceNodes_Z1[17] = 9; + + FaceNodes_Z1[18] = 9; + FaceNodes_Z1[19] = 10; + + FaceNodes_Z1[20] = 10; + FaceNodes_Z1[21] = 4; + + /* Face Nodes for Element 3 */ + FaceNodes_Z1[22] = 10; + FaceNodes_Z1[23] = 11; + + FaceNodes_Z1[24] = 11; + FaceNodes_Z1[25] = 12; + + FaceNodes_Z1[26] = 12; + FaceNodes_Z1[27] = 13; + + FaceNodes_Z1[28] = 13; + FaceNodes_Z1[29] = 5; + + /* DOCEND */ + + /* Specify the right and left neighboring elements. + * The neighboring elements can be determined using the + * right-hand rule. For each face, place your right-hand along + * the face with your fingers pointing the direction of + * incrementing node numbers (i.e. from Node 1 to Node 2). The + * right side of your hand will indicate the right element, + * and the left side of your hand will indicate the left + * element. A value of zero indicates that there is no + * neighboring element on that side. A negative value + * indicates that the neighboring element is in another zone. + * The number is a pointer into the FaceBndryConnectionElems + * and FaceBndryConnectionZones arrays. + */ + + /* DOCSTART:hexagons_zone1_neighbors.txt*/ + INTEGER4 *FaceLeftElems_Z1 = new INTEGER4[NumFaces_Z1]; + INTEGER4 *FaceRightElems_Z1 = new INTEGER4[NumFaces_Z1]; + + /* Left Face Elems for Element 1 */ + FaceLeftElems_Z1[0] = 0; + FaceLeftElems_Z1[1] = 0; + FaceLeftElems_Z1[2] = 2; + FaceLeftElems_Z1[3] = 3; + FaceLeftElems_Z1[4] = 0; + + /* Left Face Elems for Element 2 */ + FaceLeftElems_Z1[5] = 0; + FaceLeftElems_Z1[6] = 0; + FaceLeftElems_Z1[7] = 0; + FaceLeftElems_Z1[8] = -1; + FaceLeftElems_Z1[9] = -2; + FaceLeftElems_Z1[10] = 2; + + /* Left Face Elems for Element 3 */ + FaceLeftElems_Z1[11] = -3; + FaceLeftElems_Z1[12] = 0; + FaceLeftElems_Z1[13] = 0; + FaceLeftElems_Z1[14] = 0; + + /* Set Right Face Elems. Because of the way we numbered the + * nodes and faces, the right element for every face is the + * element itself. + */ + for (INTEGER4 ii = 0; ii < 6; ii++) + FaceRightElems_Z1[ii] = 1; + + for (INTEGER4 ii = 6; ii < 10; ii++) + FaceRightElems_Z1[ii] = 2; + + for (INTEGER4 ii = 10; ii <= 14; ii++) + FaceRightElems_Z1[ii] = 3; + /* DOCEND */ + + /* DOCSTART:hexagons_zone1_tecpoly.txt */ + + /* The FaceBndryConnectionCounts array is used to define the + * number of boundary connections for each face that has a + * boundary connection. For example, if a zone has three + * boundary connections in total (NumConnectedBoundaryFaces), + * two of those boundary connections are in one face, and the + * remaining boundary connection is in a second face, the + * FaceBndryConnectionCounts array would be: [2 1]. + * + * In this example, the total number of connected boundary + * faces (specified via TECZNE) is equal to three. Each + * boundary face is connected to only one other element, + * so the FaceBoundaryConnectionCounts array is (1, 1, 1). + */ + INTEGER4 FaceBndryConnectionCounts_Z1[3] = {1, 1, 1}; + + /* The value(s) in the FaceBndryConnectionElems and + * FaceBndryConnectionZones arrays specifies the element number + * and zone number, respectively, that a given boundary + * connection is connected to. In this case, the first + * boundary connection face is connected to Element 1 in Zone 2 + * and the remaining connection is to Element 2 in Zone 2. + */ + INTEGER4 FaceBndryConnectionElems_Z1[3] = {1, 2, 2}; + INTEGER4 FaceBndryConnectionZones_Z1[3] = {2, 2, 2}; + + + I = TECPOLY112(NULL, /* Not used for polygon zones */ + FaceNodes_Z1, + FaceLeftElems_Z1, + FaceRightElems_Z1, + FaceBndryConnectionCounts_Z1, + FaceBndryConnectionElems_Z1, + FaceBndryConnectionZones_Z1); + + delete FaceNodes_Z1; + delete FaceLeftElems_Z1; + delete FaceRightElems_Z1; + + /* DOCEND */ + + /* Define Zone 2. Zone 2 contains an octagon and a hexagon. */ + /* TECZNE Parameters */ + /* DOCSTART:hexagons_zone2_teczne.txt*/ + INTEGER4 NumPts_Z2 = 12; /* number of unique + * nodes in the zone + */ + INTEGER4 NumElems_Z2 = 2; + INTEGER4 NumFaces_Z2 = 13; /* number of unique + * faces in the zone + */ + INTEGER4 NumFaceConnections_Z2 = 0; + /* In polygonal zones, each face has exactly two nodes */ + INTEGER4 TotalNumFaceNodes_Z2 = NumFaces_Z2 * 2; + + /* A boundary face is a face that is neighbored by an element or + * elements from another zone or zone(s). In Zone 2, Face 6, + * Face 7 and Face 13 have a neighbor in Zone 1. Therefore, the + * total number of boundary faces is “3”. + */ + INTEGER4 TotalNumBndryFaces_Z2 = 3; + + /* Each boundary face has one or more boundary connections. In + * this example, each boundary face is connected to one other + * element (i.e. the number of boundary faces and the number of + * boundary connections is one-to-one). + */ + INTEGER4 TotalNumBndryConns_Z2 = 3; + + I = TECZNE112((char*)"Zone 2: 1 Hexagon and 1 Octagon", + &ZoneType, + &NumPts_Z2, + &NumElems_Z2, + &NumFaces_Z2, + &ICellMax, + &JCellMax, + &KCellMax, + &SolutionTime, + &StrandID, + &ParentZone, + &IsBlock, + &NumFaceConnections_Z2, + &FaceNeighborMode, + &TotalNumFaceNodes_Z2, + &TotalNumBndryFaces_Z2, + &TotalNumBndryConns_Z2, + NULL, + ValueLocation, + NULL, + &SharConn); + /* DOCEND */ + + /* TECDAT Parameters */ + /* DOCSTART:hexagons_zone2_tecdat.txt*/ + double *X_Z2 = new double[NumPts_Z2]; + double *Y_Z2 = new double[NumPts_Z2]; + + X_Z2[0] = 5; + Y_Z2[0] = 4; + + X_Z2[1] = 6; + Y_Z2[1] = 4; + + X_Z2[2] = 7; + Y_Z2[2] = 3; + + X_Z2[3] = 6; + Y_Z2[3] = 2; + + X_Z2[4] = 5; + Y_Z2[4] = 2; + + X_Z2[5] = 4; + Y_Z2[5] = 3; + + + X_Z2[6] = 3; + Y_Z2[6] = 3; + + X_Z2[7] = 5; + Y_Z2[7] = 1; + + X_Z2[8] = 4; + Y_Z2[8] = 0; + + X_Z2[9] = 3; + Y_Z2[9] = 0; + + X_Z2[10] = 2; + Y_Z2[10] = 1; + + X_Z2[11] = 2; + Y_Z2[11] = 2; + + /* In the call to TecZne, P was set to a cell centered variable. + * As such, only two values need to be defined. + */ + double *P_Z2 = new double[NumPts_Z2]; + + P_Z2[0] = 8; + P_Z2[1] = 6; + + I = TECDAT112(&NumPts_Z2, X_Z2, &IsDouble); + I = TECDAT112(&NumPts_Z2, Y_Z2, &IsDouble); + I = TECDAT112(&NumElems_Z2, P_Z2, &IsDouble); + + delete X_Z2; + delete Y_Z2; + delete P_Z2; + /* DOCEND */ + + /* TecPoly Parameters */ + /* DOCSTART:hexagons_zone2_facemap.txt*/ + INTEGER4 *FaceNodes_Z2; + FaceNodes_Z2 = new INTEGER4[TotalNumFaceNodes_Z2]; + + /* Face Nodes for Element 1 */ + FaceNodes_Z2[0] = 1; + FaceNodes_Z2[1] = 2; + + FaceNodes_Z2[2] = 2; + FaceNodes_Z2[3] = 3; + + FaceNodes_Z2[4] = 3; + FaceNodes_Z2[5] = 4; + + FaceNodes_Z2[6] = 4; + FaceNodes_Z2[7] = 5; + + FaceNodes_Z2[8] = 5; + FaceNodes_Z2[9] = 6; + + FaceNodes_Z2[10] = 6; + FaceNodes_Z2[11] = 1; + + + /* Face Nodes for Element 2 */ + FaceNodes_Z2[12] = 7; + FaceNodes_Z2[13] = 6; + + FaceNodes_Z2[14] = 5; + FaceNodes_Z2[15] = 8; + + FaceNodes_Z2[16] = 8; + FaceNodes_Z2[17] = 9; + + FaceNodes_Z2[18] = 9; + FaceNodes_Z2[19] = 10; + + FaceNodes_Z2[20] = 10; + FaceNodes_Z2[21] = 11; + + FaceNodes_Z2[22] = 11; + FaceNodes_Z2[23] = 12; + + FaceNodes_Z2[24] = 12; + FaceNodes_Z2[25] = 7; + /* DOCEND */ + + + /* DOCSTART:hexagons_zone2_tecpoly.txt*/ + /* Specify the right and left neighboring elements. + * The neighboring elements can be determined using the + * right-hand rule. For each face, place your right-hand along + * the face with your fingers pointing the direction of + * incrementing node numbers (i.e. from Node 1 to Node 2). The + * right side of your hand will indicate the right element, + * and the left side of your hand will indicate the left + * element. A value of zero indicates that there is no + * neighboring element on that side. A negative value + * indicates that the neighboring element is in another zone. + * The number is a pointer into the FaceBndryConnectionElems + * and FaceBndryConnectionZones arrays. + */ + + INTEGER4 *FaceLeftElems_Z2 = new INTEGER4[NumFaces_Z2]; + INTEGER4 *FaceRightElems_Z2 = new INTEGER4[NumFaces_Z2]; + + /* Left Face Elems for Element 1 */ + FaceLeftElems_Z2[0] = 0; + FaceLeftElems_Z2[1] = 0; + FaceLeftElems_Z2[2] = 0; + FaceLeftElems_Z2[3] = 0; + FaceLeftElems_Z2[4] = 2; + FaceLeftElems_Z2[5] = -1; + + /* Left Face Elems for Element 2 */ + FaceLeftElems_Z2[6] = -2; + FaceLeftElems_Z2[7] = 0; + FaceLeftElems_Z2[8] = 0; + FaceLeftElems_Z2[9] = 0; + FaceLeftElems_Z2[10] = 0; + FaceLeftElems_Z2[11] = 0; + FaceLeftElems_Z2[12] = -3; + + /* Set Right Face Elems. Because of the way we numbered the + * nodes and faces, the right element for every face is the + * element itself. */ + for (INTEGER4 ii = 0; ii < 6; ii++) + FaceRightElems_Z2[ii] = 1; + + for (INTEGER4 ii = 6; ii < 13; ii++) + FaceRightElems_Z2[ii] = 2; + /* DOCEND */ + + /* DOCSTART:hexagons_zone2_tecpoly.txt*/ + /* The FaceBndryConnectionCounts array is used to define the + * number of boundary connections for each face that has a + * boundary connection. In this example, the total number of + * connected boundary faces (specified via TECZNE) is equal to + * three. Each boundary face is connected to only one other + * element, so the FaceBoundaryConnectionCounts array is + * (1, 1, 1). + */ + INTEGER4 FaceBndryConnectionCounts_Z2[3] = {1, 1, 1}; + + /* The value(s) in the FaceBndryConnectionElems and + * FaceBndryConnectionZones arrays specifies that element + * number and zone number, respectively, that a given boundary + * connection is connected to. In this case, the first boundary + * connection face is connected to Element 2 in Zone 1 and the + * remaining connections are Element 3 in Zone 1. + */ + INTEGER4 FaceBndryConnectionElems_Z2[3] = {2, 3, 3}; + INTEGER4 FaceBndryConnectionZones_Z2[3] = {1, 1, 1}; + + I = TECPOLY112(NULL, + FaceNodes_Z2, + FaceLeftElems_Z2, + FaceRightElems_Z2, + FaceBndryConnectionCounts_Z2, + FaceBndryConnectionElems_Z2, + FaceBndryConnectionZones_Z2); + + delete FaceNodes_Z2; + delete FaceLeftElems_Z2; + delete FaceRightElems_Z2; + /* DOCEND */ + + /* DOCSTART:hexagons_tecend.txt*/ + I = TECEND112(); + /* DOCEND */ + + return 0; +} diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/multiplepolygons/multiplepolygons.vcproj b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/multiplepolygons/multiplepolygons.vcproj new file mode 100644 index 0000000000000000000000000000000000000000..da0df3a5c35353857954fd8dda130437a55e88f9 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/multiplepolygons/multiplepolygons.vcproj @@ -0,0 +1,172 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="multiplepolygons" + ProjectGUID="{D2747EA6-7807-42E1-984D-C946B3D97D95}" + RootNamespace="mulitplepolygons" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + GenerateDebugInformation="true" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="2" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + RuntimeLibrary="2" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + GenerateDebugInformation="true" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <File + RelativePath=".\multiplepolygons.cpp" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/octagon/Makefile b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/octagon/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..b1a061516567b7dd35dc40e1b89027cd268cbccc --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/octagon/Makefile @@ -0,0 +1,11 @@ +# Set to appropriate C++ compiler +CPP=g++ +CPPFLAGS=-I../../tecsrc ../../tecio.a +EXECUTABLE=octagon +FILES=$(EXECUTABLE).cpp + +build: + $(CPP) $(FILES) $(CPPFLAGS) -o $(EXECUTABLE) + +clean: + rm -f $(EXECUTABLE) \ No newline at end of file diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/octagon/Octagon.plt b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/octagon/Octagon.plt new file mode 100644 index 0000000000000000000000000000000000000000..e09f4f79b80a9b520bcfb359211fa932e5f2e8c0 Binary files /dev/null and b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/octagon/Octagon.plt differ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/octagon/octagon.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/octagon/octagon.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c9d64aece179bcb89452d338a6a2ac45a6651553 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/octagon/octagon.cpp @@ -0,0 +1,248 @@ +/* This example illustrates how to create a zone with a single + * polygonal cell. Please refer to the Data Format Guide for + * additional information, including figures that display node + * numbering. + */ + +#include "TECIO.h" +#include "MASTER.h" /* for defintion of NULL */ + +int main() +{ + /* DOCSTART:octagon_tecini.txt*/ + INTEGER4 Debug = 1; + INTEGER4 VIsDouble = 0; + INTEGER4 FileType = 0; + INTEGER4 I; /* used to check return codes */ + + /* + * Open the file and write the Tecplot datafile + * header information + */ + + I = TECINI112((char*)"Octagon", + (char*)"X Y P", /* Defines the variables for the data + * file. Each zone must contain each + * of the vars listed here. The order + * of the variables in the list is + * used to define the variable number + * (e.g. X is Variable 1). When + * referring to variables in other + * TecIO functions, you will refer to + * thevariable by its number. + */ + (char*)"Octagon.plt", + (char*)".", /* scratch directory */ + &FileType, + &Debug, + &VIsDouble); + /* DOCEND */ + + /* Declare TECZNE variables */ + /* DOCSTART:octagon_teczne.txt*/ + /* In this example, we will create a single octagonal cell in + * Tecplot 360's polyhedral file format. + */ + INTEGER4 ZoneType = 6; /* FEPolygon */ + INTEGER4 NumNodes = 8; /* Number of nodes in the octagon.*/ + INTEGER4 NumElems = 1; /* Number of octagonal elements. */ + INTEGER4 NumFaces = 8; /* Number of faces in the octagon.*/ + INTEGER4 ICellMax = 0; /* Not Used */ + INTEGER4 JCellMax = 0; /* Not Used */ + INTEGER4 KCellMax = 0; /* Not Used */ + double SolTime = 360.0; + INTEGER4 StrandID = 0; /* Static Zone */ + INTEGER4 ParentZn = 0; /* No Parent Zone */ + INTEGER4 IsBlock = 1; /* Block */ + INTEGER4 NFConns = 0; + INTEGER4 FNMode = 0; + + + /* For polygonal zones, the total number of face nodes is equal + * to twice the number of nodes. This is because, each face + * has exactly two nodes. + */ + INTEGER4 NumFaceNodes = 2 * NumNodes; + /* Boundary Faces and Boundary Connections are not used in this + * example. + */ + INTEGER4 NumBFaces = 0; + INTEGER4 NumBConnections = 0; + + INTEGER4 ShrConn = 0; + + I = TECZNE112((char*)"Octagonal Zone", + &ZoneType, + &NumNodes, + &NumElems, + &NumFaces, + &ICellMax, + &JCellMax, + &KCellMax, + &SolTime, + &StrandID, + &ParentZn, + &IsBlock, + &NFConns, + &FNMode, + &NumFaceNodes, + &NumBFaces, + &NumBConnections, + NULL, + NULL, /* When Value Location is not specified, + * Tecplot will treat all variables as + * nodal variables. + */ + NULL, + &ShrConn); + /* DOCEND */ + + /* Establish numbering. + * For this example, we will a single octagonal cell. + * Before defining your variables, you must establish a + * consistent node numbering scheme for your data. Once the + * node numbers are defined, supply the variable values in the + * node numbering order. In this example, node 1 is defined at + * X = 0 and Y = 0. As such, the first value supplied for X + * (i.e. X[0]) is 0. Similarly, the first value supplied for + * Y is 0. + * + * It is important that you refer to node numbers consistently. + * The node numbers will be used later to define the + * connectivity for each element. + */ + + /* TECDAT Variables */ + /* Set up the variable values. The variable values will be + * written to the file using TECDAT. Because we are specifying + * nodal variables (as specified via the ValueLocation + * parameter in TECZNE, each variable is dimensioned by the + * number of points (NumPts) in the Zone. You have the option + * to specify some variables with nodal values and some with + * cell-centered values. Refer to the Binary Function Reference + * for details. + */ + /* DOCSTART:octagon_tecdat.txt*/ + float *X = new float[NumNodes]; + float *Y = new float[NumNodes]; + float *P = new float[NumNodes]; + + //Define the grid values. + X[0] = 0.25; + Y[0] = 0.0; + + X[1] = 0.75; + Y[1] = 0.0; + + X[2] = 1.0; + Y[2] = 0.25; + + X[3] = 1.0; + Y[3] = 0.75; + + X[4] = 0.75; + Y[4] = 1.0; + + X[5] = 0.25; + Y[5] = 1.0; + + X[6] = 0.0; + Y[6] = 0.75; + + X[7] = 0.0; + Y[7] = 0.25; + + for (INTEGER4 ii = 0; ii < 8; ii++) + P[ii] = .5; + + /* Write out the field data using TECDAT */ + INTEGER4 DIsDouble = 0; /* set IsDouble to 0 to use float + * variables. */ + + I = TECDAT112(&NumNodes, X, &DIsDouble); + I = TECDAT112(&NumNodes, Y, &DIsDouble); + I = TECDAT112(&NumNodes, P, &DIsDouble); + + delete X; + delete Y; + delete P; + /* DOCEND */ + + /* Define the Face Nodes. + + * The FaceNodes array is used to indicate which nodes define + * which face. As mentioned earlier, the number of the nodes is + * implicitly defined by the order in which the nodal data is + * provided. The first value of each nodal variable describes + * node 1, the second value describes node 2, and so on. + * + * The face numbering is implicitly defined. Because there are + * two nodes in each face, the first two nodes provided define + * face 1, the next two define face 2 and so on. If there was + * a variable number of nodes used to define the faces, the + * array would be more complicated. + */ + /* DOCSTART:octagon_facenodes.txt*/ + INTEGER4 *FaceNodes = new INTEGER4[NumFaceNodes]; + + /* + * Loop over number of sides, and set each side to two + * consecutive nodes. + */ + for (INTEGER4 ii = 0; ii < 8; ii++) + { + FaceNodes[2*ii] = ii + 1; + FaceNodes[2*ii+1] = ii + 2; + } + FaceNodes[15] = 1; + + /* DOCEND */ + /* Define the right and left elements of each face. + + * The last step for writing out the polyhedral data is to + * define the right and left neighboring elements for each + * face. The neighboring elements can be determined using the + * right-hand rule. For each face, place your right-hand along + * the face which your fingers pointing the direction of + * incrementing node numbers (i.e. from node 1 to node 2). + * Your right thumb will point towards the right element; the + * element on the other side of your hand is the left element. + * + * The number zero is used to indicate that there isn't an + * element on that side of the face. + * + * Because of the way we numbered the nodes and faces, the + * right element for every face is the element itself + * (element 1) and the left element is "no-neighboring element" + * (element 0). + */ + /* DOCSTART:octagon_rightleft.txt*/ + INTEGER4 *FaceLeftElems = new INTEGER4[NumFaces]; + INTEGER4 *FaceRightElems = new INTEGER4[NumFaces]; + + for (INTEGER4 ii = 0; ii < NumFaces; ii++) + { + FaceLeftElems[ii] = 0; + FaceRightElems[ii] = 1; + } + /* DOCEND */ + /* Write the polyhedral data to the file. */ + /* DOCSTART:octagon_tecpoly.txt*/ + I = TECPOLY112(NULL, + FaceNodes, + FaceLeftElems, + FaceRightElems, + NULL, + NULL, + NULL); + + delete FaceNodes; + delete FaceLeftElems; + delete FaceRightElems; + /* DOCEND */ + /* DOCSTART:octagon_tecend.txt*/ + I = TECEND112(); + /* DOCEND */ + + return 0; +} diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/octagon/octagon.vcproj b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/octagon/octagon.vcproj new file mode 100644 index 0000000000000000000000000000000000000000..9d33ad0bde4dfa89e9296247d2139b4e3bbfadbe --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/octagon/octagon.vcproj @@ -0,0 +1,172 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="octagon" + ProjectGUID="{C4BEE7D4-6449-468F-81CC-3BEFDA554F31}" + RootNamespace="octagon" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + GenerateDebugInformation="true" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="2" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + RuntimeLibrary="2" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + GenerateDebugInformation="true" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <File + RelativePath=".\octagon.cpp" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/pyramid/Makefile b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/pyramid/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..38cb009fcab781d3cb723d83445fccdf408624bd --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/pyramid/Makefile @@ -0,0 +1,11 @@ +# Set to appropriate C++ compiler +CPP=g++ +CPPFLAGS=-I../../tecsrc ../../tecio.a +EXECUTABLE=pyramid +FILES=$(EXECUTABLE).cpp + +build: + $(CPP) $(FILES) $(CPPFLAGS) -o $(EXECUTABLE) + +clean: + rm -f $(EXECUTABLE) \ No newline at end of file diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/pyramid/pyramid.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/pyramid/pyramid.cpp new file mode 100644 index 0000000000000000000000000000000000000000..864bb754bad228d233bd89fa81509de08d60abcf --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/pyramid/pyramid.cpp @@ -0,0 +1,222 @@ +/* This example creates a zone with a single polyhedral cell. */ + +/* DOCSTART:pyramid.txt*/ +#include "TECIO.h" +#include "MASTER.h" /* for defintion of NULL */ + +int main() +{ + /* Call TECINI112 */ + INTEGER4 FileType = 0; /* 0 for full file */ + INTEGER4 Debug = 0; + INTEGER4 VIsDouble = 1; + INTEGER4 I = 0; /* use to check return codes */ + + I = TECINI112((char*)"Pyramid", /* Data Set Title */ + (char*)"X Y Z", /* Variable List */ + (char*)"pyramid.plt", /* File Name */ + (char*)".", /* Scratch Directory */ + &(FileType), + &(Debug), + &(VIsDouble)); + + + /* Call TECZNE112 */ + INTEGER4 ZoneType = 7; /* 7 for FEPolyhedron */ + INTEGER4 NumNodes = 5; /* number of unique nodes */ + INTEGER4 NumElems = 1; /* number of elements */ + INTEGER4 NumFaces = 5; /* number of unique faces */ + + INTEGER4 ICellMax = 0; /* Not Used, set to zero */ + INTEGER4 JCellMax = 0; /* Not Used, set to zero */ + INTEGER4 KCellMax = 0; /* Not Used, set to zero */ + + double SolTime = 12.65; /* solution time */ + INTEGER4 StrandID = 0; /* static zone */ + INTEGER4 ParentZone = 0; /* no parent zone */ + + INTEGER4 IsBlock = 1; /* block format */ + + INTEGER4 NFConns = 0; /* not used for FEPolyhedron + * zones + */ + INTEGER4 FNMode = 0; /* not used for FEPolyhedron + * zones + */ + + INTEGER4 *PassiveVarArray = NULL; + INTEGER4 *ValueLocArray = NULL; + INTEGER4 *VarShareArray = NULL; + + INTEGER4 ShrConn = 0; + + /* The number of face nodes in the zone. This example creates + * a zone with a single pyramidal cell. This cell has four + * triangular faces and one rectangular face, yielding a total + * of 16 face nodes. + */ + INTEGER4 NumFaceNodes = 16; + INTEGER4 NumBConns = 0; /* No Boundary Connections */ + INTEGER4 NumBItems = 0; /* No Boundary Items */ + + I = TECZNE112((char*)"Polyhedral Zone (Octahedron)", + &ZoneType, + &NumNodes, + &NumElems, + &NumFaces, + &ICellMax, + &JCellMax, + &KCellMax, + &SolTime, + &StrandID, + &ParentZone, + &IsBlock, + &NFConns, + &FNMode, + &NumFaceNodes, + &NumBConns, + &NumBItems, + PassiveVarArray, + ValueLocArray, + VarShareArray, + &ShrConn); + + /* Initialize arrays of nodal data */ + double *X = new double[NumNodes]; + double *Y = new double[NumNodes]; + double *Z = new double[NumNodes]; + + X[0] = 0; + Y[0] = 0; + Z[0] = 0; + + X[1] = 1; + Y[1] = 1; + Z[1] = 2; + + X[2] = 2; + Y[2] = 0; + Z[2] = 0; + + X[3] = 2; + Y[3] = 2; + Z[3] = 0; + + X[4] = 0; + Y[4] = 2; + Z[4] = 0; + + /* Write the data (using TECDAT112) */ + INTEGER4 DIsDouble = 1; /* One for double precision */ + I = TECDAT112(&NumNodes, X, &DIsDouble); + I = TECDAT112(&NumNodes, Y, &DIsDouble); + I = TECDAT112(&NumNodes, Z, &DIsDouble); + + delete X; + delete Y; + delete Z; + + /* Define the Face Nodes. + + * The FaceNodes array is used to indicate which nodes define + * which face. As mentioned earlier, the number of the nodes is + * implicitly defined by the order in which the nodal data is + * provided. The first value of each nodal variable describes + * node 1, the second value describes node 2, and so on. + * + * The face numbering is implicitly defined. Because there are + * two nodes in each face, the first two nodes provided define + * face 1, the next two define face 2 and so on. If there was + * a variable number of nodes used to define the faces, the + * array would be more complicated. + */ + + INTEGER4 *FaceNodeCounts = new INTEGER4[NumFaces]; + /* The first four faces are triangular, i.e. have three nodes. + * The fifth face is rectangular, i.e. has four nodes. */ + FaceNodeCounts[0] = 3; + FaceNodeCounts[1] = 3; + FaceNodeCounts[2] = 3; + FaceNodeCounts[3] = 3; + FaceNodeCounts[4] = 4; + + INTEGER4 *FaceNodes = new INTEGER4[NumFaceNodes]; + /* Face Nodes for Face 1 */ + FaceNodes[0] = 1; + FaceNodes[1] = 2; + FaceNodes[2] = 3; + + /* Face Nodes for Face 2 */ + FaceNodes[3] = 3; + FaceNodes[4] = 2; + FaceNodes[5] = 4; + + /* Face Nodes for Face 3 */ + FaceNodes[6] = 5; + FaceNodes[7] = 2; + FaceNodes[8] = 4; + + /* Face Nodes for Face 4 */ + FaceNodes[9] = 1; + FaceNodes[10] = 2; + FaceNodes[11] = 5; + + /* Face Nodes for Face 5 */ + FaceNodes[12] = 1; + FaceNodes[13] = 5; + FaceNodes[14] = 4; + FaceNodes[15] = 3; + + /* Define the right and left elements of each face. + * + * The last step for writing out the polyhedral data is to + * define the right and left neighboring elements for each + * face. The neighboring elements can be determined using the + * right-hand rule. For each face, place your right-hand along + * the face which your fingers pointing the direction of + * incrementing node numbers (i.e. from node 1 to node 2). + * Your right thumb will point towards the right element; the + * element on the other side of your hand is the left element. + * + * The number zero is used to indicate that there isn't an + * element on that side of the face. + * + * Because of the way we numbered the nodes and faces, the + * right element for every face is the element itself + * (element 1) and the left element is "no-neighboring element" + * (element 0). + */ + + INTEGER4 *FaceLeftElems = new INTEGER4[NumFaces]; + FaceLeftElems[0] = 1; + FaceLeftElems[1] = 1; + FaceLeftElems[2] = 0; + FaceLeftElems[3] = 0; + FaceLeftElems[4] = 0; + + INTEGER4 *FaceRightElems = new INTEGER4[NumFaces]; + FaceRightElems[0] = 0; + FaceRightElems[1] = 0; + FaceRightElems[2] = 1; + FaceRightElems[3] = 1; + FaceRightElems[4] = 1; + + /* Write the face map (created above) using TECPOLY112. */ + I = TECPOLY112(FaceNodeCounts, /* The face node counts array */ + FaceNodes, /* The face nodes array */ + FaceLeftElems, /* The left elements array */ + FaceRightElems, /* The right elements array */ + NULL, /* No boundary connection counts */ + NULL, /* No boundary connection elements */ + NULL); /* No boundary connection zones */ + + delete FaceNodeCounts; + delete FaceNodes; + delete FaceLeftElems; + delete FaceRightElems; + + I = TECEND112(); + return 0; +} + +/* DOCEND */ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/pyramid/pyramid.plt b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/pyramid/pyramid.plt new file mode 100644 index 0000000000000000000000000000000000000000..d85447466118fc7a63af724aa0bd550a2382ac6b Binary files /dev/null and b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/pyramid/pyramid.plt differ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/pyramid/pyramid.vcproj b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/pyramid/pyramid.vcproj new file mode 100644 index 0000000000000000000000000000000000000000..e44e390db6fdb06573ed960f31a186150732f3fc --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/pyramid/pyramid.vcproj @@ -0,0 +1,172 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="pyramid" + ProjectGUID="{CFED06AE-48C6-491C-AE5F-E1B7882A44E9}" + RootNamespace="pyramid" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + GenerateDebugInformation="true" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="2" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + RuntimeLibrary="2" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + GenerateDebugInformation="true" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <File + RelativePath=".\pyramid.cpp" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/simtest/Makefile b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/simtest/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..9e40ebe34bc211c6f4f450dca331aa3b93a39d11 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/simtest/Makefile @@ -0,0 +1,11 @@ +# Set to appropriate C++ compiler +CPP=g++ +CPPFLAGS=-I../../tecsrc ../../tecio.a +EXECUTABLE=simtest +FILES=$(EXECUTABLE).c + +build: + $(CPP) $(FILES) $(CPPFLAGS) -o $(EXECUTABLE) + +clean: + rm -f $(EXECUTABLE) diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/simtest/simtest.c b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/simtest/simtest.c new file mode 100644 index 0000000000000000000000000000000000000000..fe35a33234ad2583614c0cf55337a2668598a905 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/simtest/simtest.c @@ -0,0 +1,100 @@ +/* + * Simple example c program to write a + * binary datafile for tecplot. This example + * does the following: + * + * 1. Open a datafile called "t.plt" + * 2. Assign values for X,Y, and P + * 3. Write out a zone dimensioned 4x5 + * 4. Close the datafile. + */ + +#include "TECIO.h" + +#ifndef NULL +#define NULL 0 +#endif + +enum FileType { FULL = 0, GRID = 1, SOLUTION = 2 }; + +int main(void) +{ + float X[5][4], Y[5][4], P[5][4]; + double SolTime; + INTEGER4 Debug, I, J, III, DIsDouble, VIsDouble, IMax, JMax, KMax, ZoneType, StrandID, ParentZn, IsBlock; + INTEGER4 ICellMax, JCellMax, KCellMax, NFConns, FNMode, ShrConn, FileType; + + Debug = 1; + VIsDouble = 0; + DIsDouble = 0; + IMax = 4; + JMax = 5; + KMax = 1; + ZoneType = 0; /* Ordered */ + SolTime = 360.0; + StrandID = 0; /* StaticZone */ + ParentZn = 0; /* No Parent */ + IsBlock = 1; /* Block */ + ICellMax = 0; + JCellMax = 0; + KCellMax = 0; + NFConns = 0; + FNMode = 0; + ShrConn = 0; + FileType = FULL; + + /* + * Open the file and write the tecplot datafile + * header information + */ + I = TECINI112((char*)"SIMPLE DATASET", + (char*)"X Y P", + (char*)"t.plt", + (char*)".", + &FileType, + &Debug, + &VIsDouble); + + for (J = 0; J < 5; J++) + for (I = 0; I < 4; I++) + { + X[J][I] = (float)(I + 1); + Y[J][I] = (float)(J + 1); + P[J][I] = (float)((I + 1) * (J + 1)); + } + /* + * Write the zone header information. + */ + I = TECZNE112((char*)"Simple Zone", + &ZoneType, + &IMax, + &JMax, + &KMax, + &ICellMax, + &JCellMax, + &KCellMax, + &SolTime, + &StrandID, + &ParentZn, + &IsBlock, + &NFConns, + &FNMode, + 0, /* TotalNumFaceNodes */ + 0, /* NumConnectedBoundaryFaces */ + 0, /* TotalNumBoundaryConnections */ + NULL, /* PassiveVarList */ + NULL, /* ValueLocation = Nodal */ + NULL, /* SharVarFromZone */ + &ShrConn); + /* + * Write out the field data. + */ + III = IMax * JMax; + I = TECDAT112(&III, &X[0][0], &DIsDouble); + I = TECDAT112(&III, &Y[0][0], &DIsDouble); + I = TECDAT112(&III, &P[0][0], &DIsDouble); + + I = TECEND112(); + + return 0; +} diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/simtest/simtest.f b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/simtest/simtest.f new file mode 100644 index 0000000000000000000000000000000000000000..d980915100f49ca991a9402c4814a31f19211482 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/simtest/simtest.f @@ -0,0 +1,98 @@ +C +C Simple example fortran program to write a +C binary datafile for tecplot. This example +C does the following: +C +C 1. Open a datafile called "t.plt" +C 2. Assign values for X,Y, and P +C 3. Write out a zone dimensioned 4x5 +C 4. Close the datafile. +C +C + program test + + INCLUDE 'tecio.inc' + + character*1 NULLCHR + Integer*4 Debug,III,NPts,NElm + + Dimension X(4,5), Y(4,5), P(4,5) + Real*8 SolTime + Integer*4 VIsDouble, FileType + Integer*4 ZoneType,StrandID,ParentZn,IsBlock + Integer*4 ICellMax,JCellMax,KCellMax,NFConns,FNMode,ShrConn + POINTER (NullPtr,Null) + Integer*4 Null(*) + + NULLCHR = CHAR(0) + NullPtr = 0 + Debug = 1 + FileType = 0 + VIsDouble = 0 + IMax = 4 + JMax = 5 + KMax = 1 + ZoneType = 0 + SolTime = 360.0 + StrandID = 0 + ParentZn = 0 + IsBlock = 1 + ICellMax = 0 + JCellMax = 0 + KCellMax = 0 + NFConns = 0 + FNMode = 0 + ShrConn = 0 +C +C... Open the file and write the tecplot datafile +C... header information. +C + I = TecIni112('SIMPLE DATASET'//NULLCHR, + & 'X Y P'//NULLCHR, + & 't.plt'//NULLCHR, + & '.'//NULLCHR, + & FileType, + & Debug, + & VIsDouble) + + Do 10 I = 1,4 + Do 10 J = 1,5 + X(I,J) = I + Y(I,J) = J + P(I,J) = I*J + 10 Continue +C +C... Write the zone header information. +C + I = TecZne112('Simple Zone'//NULLCHR, + & ZoneType, + & IMax, + & JMax, + & KMax, + & ICellMax, + & JCellMax, + & KCellMax, + & SolTime, + & StrandID, + & ParentZn, + & IsBlock, + & NFConns, + & FNMode, + & 0, + & 0, + & 0, + & Null, + & Null, + & Null, + & ShrConn) +C +C... Write out the field data. +C + III = IMax*JMax + I = TecDat112(III,X,0) + I = TecDat112(III,Y,0) + I = TecDat112(III,P,0) + + I = TecEnd112() + Stop + End diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/simtest/simtest.f90 b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/simtest/simtest.f90 new file mode 100644 index 0000000000000000000000000000000000000000..1706de59841ed1795e3b79fe9df00088363eb4a0 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/simtest/simtest.f90 @@ -0,0 +1,98 @@ +! +! Simple example fortran program to write a +! binary datafile for tecplot. This example +! does the following: +! +! 1. Open a datafile called "t.plt" +! 2. Assign values for X,Y, and P +! 3. Write out a zone dimensioned 4x5 +! 4. Close the datafile. +! +! + program test + + INCLUDE 'tecio.f90' + + character*1 NULLCHR + Integer*4 Debug,III,NPts,NElm + + Dimension X(4,5), Y(4,5), P(4,5) + Real*8 SolTime + Integer*4 VIsDouble, FileType + Integer*4 ZoneType,StrandID,ParentZn,IsBlock + Integer*4 ICellMax,JCellMax,KCellMax,NFConns,FNMode,ShrConn + POINTER (NullPtr,Null) + Integer*4 Null(*) + + NULLCHR = CHAR(0) + NullPtr = 0 + Debug = 1 + FileType = 0 + VIsDouble = 0 + IMax = 4 + JMax = 5 + KMax = 1 + ZoneType = 0 + SolTime = 360.0 + StrandID = 0 + ParentZn = 0 + IsBlock = 1 + ICellMax = 0 + JCellMax = 0 + KCellMax = 0 + NFConns = 0 + FNMode = 0 + ShrConn = 0 +! +!... Open the file and write the tecplot datafile +!... header information. +! + I = TecIni112('SIMPLE DATASET'//NULLCHR, & + 'X Y P'//NULLCHR, & + 't.plt'//NULLCHR, & + '.'//NULLCHR, & + FileType, & + Debug, & + VIsDouble) + + Do 10 I = 1,4 + Do 10 J = 1,5 + X(I,J) = I + Y(I,J) = J + P(I,J) = I*J + 10 Continue +! +!... Write the zone header information. +! + I = TecZne112('Simple Zone'//NULLCHR, & + ZoneType, & + IMax, & + JMax, & + KMax, & + ICellMax, & + JCellMax, & + KCellMax, & + SolTime, & + StrandID, & + ParentZn, & + IsBlock, & + NFConns, & + FNMode, & + 0, & + 0, & + 0, & + Null, & + Null, & + Null, & + ShrConn) +! +!... Write out the field data. +! + III = IMax*JMax + I = TecDat112(III,X,0) + I = TecDat112(III,Y,0) + I = TecDat112(III,P,0) + + I = TecEnd112() + Stop + End diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/simtest/simtestc.vcproj b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/simtest/simtestc.vcproj new file mode 100644 index 0000000000000000000000000000000000000000..814cc761f3db60f677f273b5269c9bdd65766478 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/simtest/simtestc.vcproj @@ -0,0 +1,346 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="simtestc" + ProjectGUID="{62FA6E8C-388E-4047-BC9D-574B470B94DE}" + RootNamespace="simtestc" + Keyword="Win32Proj" + > + <Platforms> + <Platform + Name="Win32" + /> + <Platform + Name="x64" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(PlatformName)/$(ConfigurationName)" + IntermediateDirectory="$(SolutionDir)$(PlatformName)/$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + LinkIncremental="2" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + SubSystem="1" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Debug|x64" + OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)" + IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + TargetEnvironment="3" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + LinkIncremental="2" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + SubSystem="1" + TargetMachine="17" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)$(PlatformName)/$(ConfigurationName)" + IntermediateDirectory="$(SolutionDir)$(PlatformName)/$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="1" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + LinkIncremental="1" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|x64" + OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)" + IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="1" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + TargetEnvironment="3" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + LinkIncremental="1" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="17" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <File + RelativePath=".\simtest.c" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/simtest/simtestf.vfproj b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/simtest/simtestf.vfproj new file mode 100644 index 0000000000000000000000000000000000000000..2b20da05b12e68fa0e676b330ff90f2e71896e12 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/simtest/simtestf.vfproj @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<VisualStudioProject ProjectCreator="Intel Fortran" Keyword="Console Application" Version="9.10" ProjectIdGuid="{861BC05F-1E95-401A-A80E-7589ADD1C79E}"> + <Platforms> + <Platform Name="Win32"/></Platforms> + <Configurations> + <Configuration Name="Debug|Win32" OutputDirectory="$(SolutionDir)$(PlatformName)/$(ConfigurationName)" IntermediateDirectory="$(SolutionDir)$(PlatformName)/$(ConfigurationName)" DeleteExtensionsOnClean="*.obj;*.mod;*.pdb;*.asm;*.map;*.dyn;*.dpi;*.tmp;*.log;*.ilk;*.exe;$(TargetPath)"> + <Tool Name="VFMidlTool" SuppressStartupBanner="true" HeaderFileName="$(InputName).h" TypeLibraryName="$(IntDir)/$(InputName).tlb"/> + <Tool Name="VFPreBuildEventTool"/> + <Tool Name="VFPostBuildEventTool"/> + <Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" DebugInformationFormat="debugEnabled" Optimization="optimizeDisabled" AdditionalIncludeDirectories="$(TEC_360_2009)/Include" ModulePath="$(INTDIR)/" ObjectFile="$(INTDIR)/" Traceback="true" BoundsCheck="true" RuntimeLibrary="rtMultiThreadedDebug" CompileOnly="true"/> + <Tool Name="VFCustomBuildTool"/> + <Tool Name="VFLinkerTool" OutputFile="$(OUTDIR)/simtestf.exe" LinkIncremental="linkIncrementalNo" SuppressStartupBanner="true" AdditionalLibraryDirectories="$(TEC_360_2009)/Bin" GenerateDebugInformation="true" ProgramDatabaseFile="$(OUTDIR)/simtestf.pdb" SubSystem="subSystemConsole" AdditionalDependencies="tecio.lib"/> + <Tool Name="VFPreLinkEventTool"/> + <Tool Name="VFResourceCompilerTool" ResourceOutputFileName="$(IntDir)/$(InputName).res"/></Configuration> + <Configuration Name="Release|Win32" OutputDirectory="$(SolutionDir)$(PlatformName)/$(ConfigurationName)" IntermediateDirectory="$(SolutionDir)$(PlatformName)/$(ConfigurationName)" DeleteExtensionsOnClean="*.obj;*.mod;*.pdb;*.asm;*.map;*.dyn;*.dpi;*.tmp;*.log;*.ilk;*.exe;$(TargetPath)"> + <Tool Name="VFMidlTool" SuppressStartupBanner="true" HeaderFileName="$(InputName).h" TypeLibraryName="$(IntDir)/$(InputName).tlb"/> + <Tool Name="VFPreBuildEventTool"/> + <Tool Name="VFPostBuildEventTool"/> + <Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" AdditionalIncludeDirectories="$(TEC_360_2009)/Include" ModulePath="$(INTDIR)/" ObjectFile="$(INTDIR)/" RuntimeLibrary="rtMultiThreaded" CompileOnly="true"/> + <Tool Name="VFCustomBuildTool"/> + <Tool Name="VFLinkerTool" OutputFile="$(OUTDIR)/simtestf.exe" LinkIncremental="linkIncrementalNo" SuppressStartupBanner="true" AdditionalLibraryDirectories="$(TEC_360_2009)/Bin" SubSystem="subSystemConsole" AdditionalDependencies="tecio.lib"/> + <Tool Name="VFPreLinkEventTool"/> + <Tool Name="VFResourceCompilerTool" ResourceOutputFileName="$(IntDir)/$(InputName).res"/></Configuration></Configurations> + <Files> + <File RelativePath="simtest.f90"/></Files> + <Globals/></VisualStudioProject> diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/squares/Makefile b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/squares/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..120b910d62d926cad659313c6a1d48308765ae10 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/squares/Makefile @@ -0,0 +1,11 @@ +# Set to appropriate C++ compiler +CPP=g++ +CPPFLAGS=-I../../tecsrc ../../tecio.a +EXECUTABLE=squares +FILES=$(EXECUTABLE).cpp + +build: + $(CPP) $(FILES) $(CPPFLAGS) -o $(EXECUTABLE) + +clean: + rm -f $(EXECUTABLE) \ No newline at end of file diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/squares/squares.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/squares/squares.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e5d9a0f5e2bba0a945ac5f2873d5f3cccc0c0825 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/squares/squares.cpp @@ -0,0 +1,124 @@ +/* This example creates a group of square geometries, each with a + * different fill color */ +#if defined _MSC_VER +#pragma warning (disable: 4996) /* Windows strcpy warning off */ +#endif + +/* DOCSTART:tecgeo.txt*/ +#include "TECIO.h" +#include <string.h> + +int main() +{ + INTEGER4 Debug = 1; + INTEGER4 VIsDouble = 0; + INTEGER4 FileType = 0; + INTEGER4 I = 0; /* use to check return values */ + + + /* Open the file and write the tecplot datafile + * header information + */ + I = TECINI112((char*)"Square Geometries", + (char*)"X Y P", + (char*)"squares.plt", + (char*)".", + &FileType, + &Debug, + &VIsDouble); + + double ZPos = 0.0; /* N/A for squares */ + double XPos; + double YPos; + + INTEGER4 PosCoordMode = 0; /* use grid coordinates */ + + /* opt not to attach the text to a given zone. When text is + * attached to a given zone, it is displayed only when the zone + * is displayed. + */ + INTEGER4 AttachToZone = 0; + INTEGER4 Zone = 1; + + /* Set the Geometry Style Values */ + INTEGER4 Color = 0; /* set the outline color to + * black + */ + INTEGER4 IsFilled = 1; + INTEGER4 GeomType = 2; /* set the geometry type to + * square + */ + INTEGER4 LinePattern = 5; /* set the line pattern to + * DashDotDot + */ + double PatternLength = .1; + double LineThick = .2; + + /* N/A for square geometries */ + INTEGER4 NumPts = 100; + INTEGER4 ArrowStyle = 1; + INTEGER4 ArrowAttach = 0; + double ArrowSize = 1; + double ArrowAngle = 30; + INTEGER4 NumSegments = 15; + INTEGER4 NumSegPts = 25; + + + INTEGER4 Scope = 1; /* set the text to "local", i.e. + * available in the current frame + * only. + */ + INTEGER4 Clipping = 1; + + /* Specify the length of a side of the square. The units used + * are those defined with PosCoordMode. + */ + float XGeomData = 2.5; + + float YGeomData = 0; /* N/A for square geometries */ + float ZGeomData = 0; /* N/A for square geometries */ + + char * MFC = new char[128]; + strcpy(MFC, "SQUARE"); + + for (INTEGER4 ii = 0; ii <= 7; ii++) + { + INTEGER4 FillColor = ii; + XPos = (double) ii; + YPos = (double) ii; + + I = TECGEO112(&XPos, + &YPos, + &ZPos, + &PosCoordMode, + &AttachToZone, + &Zone, + &Color, + &FillColor, + &IsFilled, + &GeomType, + &LinePattern, + &PatternLength, + &LineThick, + &NumPts, + &ArrowStyle, + &ArrowAttach, + &ArrowSize, + &ArrowAngle, + &Scope, + &Clipping, + &NumSegments, + &NumSegPts, + &XGeomData, + &YGeomData, + &ZGeomData, + MFC); + } + + I = TECEND112(); + + delete MFC; + return 0; +} + +/* DOCEND */ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/squares/squares.plt b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/squares/squares.plt new file mode 100644 index 0000000000000000000000000000000000000000..c8e0848cfae0353501b89930becf07c7dd920c72 Binary files /dev/null and b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/squares/squares.plt differ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/squares/squares.vcproj b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/squares/squares.vcproj new file mode 100644 index 0000000000000000000000000000000000000000..359ce967c4d251dd3a9ac6fba2e8c126e9d717c2 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/squares/squares.vcproj @@ -0,0 +1,172 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="squares" + ProjectGUID="{2E5EC0A5-5902-4A66-8A67-A61EC9EB0855}" + RootNamespace="squares" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + GenerateDebugInformation="true" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="2" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + RuntimeLibrary="2" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + GenerateDebugInformation="true" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <File + RelativePath=".\squares.cpp" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/text/Makefile b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/text/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..415b65fd1338f042275397f5c4d5fdf265b82f47 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/text/Makefile @@ -0,0 +1,11 @@ +# Set to appropriate C++ compiler +CPP=g++ +CPPFLAGS=-I../../tecsrc ../../tecio.a +EXECUTABLE=text +FILES=$(EXECUTABLE).cpp + +build: + $(CPP) $(FILES) $(CPPFLAGS) -o $(EXECUTABLE) + +clean: + rm -f $(EXECUTABLE) \ No newline at end of file diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/text/text.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/text/text.cpp new file mode 100644 index 0000000000000000000000000000000000000000..66df8d723d2c86241987a8969878a4c8add75542 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/text/text.cpp @@ -0,0 +1,112 @@ +/* This example demonstrates adding a text object to a Tecplot + * data file. + */ +#if defined _MSC_VER +#pragma warning (disable: 4996) /* Windows strcpy warning off */ +#endif + +/* DOCSTART:tectxt.txt*/ +#include "TECIO.h" +#include <string.h> + +int main() +{ + /* Open the file & write the datafile header information */ + INTEGER4 Debug = 1; + INTEGER4 VIsDouble = 0; + INTEGER4 FileType = 0; + INTEGER4 I = 0; /* used to check the return value */ + + I = TECINI112((char*)"Text", + (char*)"X Y P", + (char*)"text.plt", + (char*)".", + &FileType, + &Debug, + &VIsDouble); + + /* Specify the X, Y and Z position of the anchor point */ + double XPos = 0.0; + double YPos = 1.0; + double ZPos = 0.0; /* N/A for 2D text */ + + INTEGER4 PosCoordMode = 0; /* use grid coordinates */ + + /* opt not to attach the text to a given zone. When text is + * attached to a given zone, it is displayed only when the zone + * is displayed. + */ + INTEGER4 AttachToZone = 0; + INTEGER4 Zone = 2; + + + /* Specify the font values */ + INTEGER4 Font = 1; /* Helvetica Bold */ + INTEGER4 FontHeightUnits = 2; /* in grid coordinates */ + double FontHeight = 18; + + /* Set the box style parameters */ + INTEGER4 BoxType = 1; /* filled box */ + double BoxMargin = .5; /* margin between the text + * and the text box + */ + double BoxLineThickness = .1; + INTEGER4 BoxColor = 0; /* set the box line color + * to black. + */ + INTEGER4 BoxFillColor = 1; /* set the box fill color + * to red. + */ + + /* set the font properties */ + double Angle = 30; /* angle of the text */ + INTEGER4 Anchor = 1; /* set the anchor point to + * the center of the text + * box. + */ + double LineSpacing = 1.5; + INTEGER4 TextColor = 7; /* set the font color to + * white + */ + + INTEGER4 Scope = 1; /* set the text to "local", + * i.e. available in the + * current frame only. + */ + INTEGER4 Clipping = 1; + + + char Text[60]; + char MFC[24]; + strcpy(Text, "Sample Text"); + strcpy(MFC, "My Macro"); + + I = TECTXT112(&XPos, + &YPos, + &ZPos, + &PosCoordMode, + &AttachToZone, + &Zone, + &Font, + &FontHeightUnits, + &FontHeight, + &BoxType, + &BoxMargin, + &BoxLineThickness, + &BoxColor, + &BoxFillColor, + &Angle, + &Anchor, + &LineSpacing, + &TextColor, + &Scope, + &Clipping, + Text, + MFC); + + I = TECEND112(); + + return 0; +} + +/* DOCEND */ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/text/text.plt b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/text/text.plt new file mode 100644 index 0000000000000000000000000000000000000000..5d0ecd945ad1051efda3afc29c1ee7fcdc53a335 Binary files /dev/null and b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/text/text.plt differ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/text/text.vcproj b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/text/text.vcproj new file mode 100644 index 0000000000000000000000000000000000000000..9018c6a89c04c678c65a3f77ff14db7632ae441c --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/examples/text/text.vcproj @@ -0,0 +1,172 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="text" + ProjectGUID="{FE2A061A-1787-410B-ABA0-366D6EA603FB}" + RootNamespace="text" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + GenerateDebugInformation="true" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="..\TecIO_Examples.vsprops" + CharacterSet="2" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + RuntimeLibrary="2" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + GenerateDebugInformation="true" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <File + RelativePath=".\text.cpp" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/pltview.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/pltview.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fd9dd63976dd0bef2a6e6845f8e33c3657c83633 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/pltview.cpp @@ -0,0 +1,559 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +/* +***************************************************************** +***************************************************************** +******* ******** +****** (C) Copyright 2004-2006 by Tecplot, Inc. ******** +****** (C) Copyright 1989-2003 by AMTEC ENGINEERING INC.******** +******* All Rights Reserved. ******** +******* ******** +***************************************************************** +***************************************************************** +*/ + + +/* +**************************************************************** +****************** BEGIN DEVELOPMENT NOTES ********************* +**************************************************************** + +BEGIN CODELOG PLTVIEW +V 09/04/98 +V **************************************************************** +V * Build 1.0 9-04-98 * +V **************************************************************** +END CODELOG + +********************************************************************* +* IMPORTANT NOTE: Only development notes for "pltview" stand-alone * +* belong in this file. See "ADDONVER.h" for changes * +* related to the add-on. * +********************************************************************* + +**************************************************************** +* V in column 1 marks date information. * +* C in column 1 marks notes on new changes. * +* B in column 1 marks notes on bug fixes. * +**************************************************************** + +**************************************************************** +****************** END DEVELOPMENT NOTES *********************** +**************************************************************** +*/ + +#if defined ADDON +#include "TECADDON.h" +#include "GUIDEFS.h" +#include "GUI.h" +#define READTEC TecUtilReadBinaryData +#define SHOWINFO(S) TecGUITextAppendString(Output_T_D1,S); +#define ERRMSG(S) TecUtilDialogErrMsg(S) +#define ALLOC_ARRAY(N,Type,S) (Type *)TecUtilStringAlloc((N)*sizeof(Type),"debug info") +#define FREE_ARRAY(N,S) TecUtilStringDealloc((char **)&N) +#define STRINGLISTGETSTRING(S,N) TecUtilStringListGetString(S,N) +#define STRINGLISTGETCOUNT(S) TecUtilStringListGetCount(S) +#define STRINGLISTDEALLOC(S) TecUtilStringListDealloc(S) +#else +#include "MASTER.h" +#include "GLOBAL.h" +#include "TASSERT.h" +#define ALLOC_ARRAY(N,Type,S) (Type *)TecAlloc((N)*sizeof(Type)) +#define FREE_ARRAY(N,S) TecFree((void *)N) +#include "ARRLIST.h" +#include "STRLIST.h" +#include "DATAUTIL.h" + +/* +#include "TECADDON.h" +#include "TECXXX.h" +#include "DATAUTIL.h" +#include "STRLIST.h" +*/ + +#define READTEC ReadTec +#define SHOWINFO(S) printf("%s",S); +#define ERRMSG(S) printf("Err: %s\n",S); +#define STRINGLISTGETSTRING(S,N) StringListGetString(S,(N)-1) +#define STRINGLISTGETCOUNT(S) StringListCount(S) +#define STRINGLISTDEALLOC(S) StringListDealloc(S) +#define MaxCharsUserRec 500 +#endif + + +static int GetNumPtsPerCell(ZoneType_e ZoneType) +{ + int NumPts = 0; + switch (ZoneType) + { + case ZoneType_FETriangle : NumPts = 3; break; + case ZoneType_FEQuad : NumPts = 4; break; + case ZoneType_FETetra : NumPts = 4; break; + case ZoneType_FEBrick : NumPts = 8; break; + default : NumPts = 0; + } + return (NumPts); +} + +static int GetNumPts(ZoneType_e ZoneType, + LgIndex_t NumPtsI, + LgIndex_t NumPtsJ, + LgIndex_t NumPtsK) +{ + int NumPts = 0; + switch (ZoneType) + { + case ZoneType_FETriangle : + case ZoneType_FEQuad : + case ZoneType_FETetra : + case ZoneType_FEBrick : + case ZoneType_FEPolygon : + case ZoneType_FEPolyhedron: NumPts = NumPtsI; break; + default : NumPts = NumPtsI*NumPtsJ*NumPtsK; + } + return (NumPts); +} + + + +static void DeallocHeaderInfo(char **DataSetTitle, + StringList_pa *VarNames, + StringList_pa *ZoneNames, + LgIndex_t **NumPtsI, + LgIndex_t **NumPtsJ, + LgIndex_t **NumPtsK, + ZoneType_e **ZoneType, + StringList_pa *UserRec) +{ + if (*DataSetTitle) + FREE_ARRAY(*DataSetTitle, "data set title"); + if (*VarNames) + STRINGLISTDEALLOC(VarNames); + if (*ZoneNames) + STRINGLISTDEALLOC(ZoneNames); + if (*NumPtsI) + FREE_ARRAY(*NumPtsI, "NumPtsI Array"); + if (*NumPtsJ) + FREE_ARRAY(*NumPtsJ, "NumPtsJ Array"); + if (*NumPtsK) + FREE_ARRAY(*NumPtsK, "NumPtsK Array"); + if (*ZoneType) + FREE_ARRAY(*ZoneType, "ZoneType Array"); + if (*UserRec) + STRINGLISTDEALLOC(UserRec); + + *DataSetTitle = NULL; + *VarNames = NULL; + *ZoneNames = NULL; + *NumPtsI = NULL; + *NumPtsJ = NULL; + *NumPtsK = NULL; + *ZoneType = NULL; + *UserRec = NULL; +} + + + +#define MAXCHARSINFOLINE 5000 + + +void ReportFileInfo(char *FName, + Boolean_t LoadRawData, + Boolean_t AllocateRawDataSpaceLocally) +{ + short IVersion; + EntIndex_t NumZones; + EntIndex_t NumVars; + char *DataSetTitle = NULL; + StringList_pa VarNames = NULL; + StringList_pa ZoneNames = NULL; + LgIndex_t *NumPtsI = NULL; + LgIndex_t *NumPtsJ = NULL; + LgIndex_t *NumPtsK = NULL; + ZoneType_e *ZoneType = NULL; + StringList_pa UserRec = NULL; + int CZ, CV; + char InfoLine[MAXCHARSINFOLINE+1]; + double **VDataBase = NULL; + NodeMap_t **NodeMap = NULL; + + /* + * Load in the header information only. + */ + + if (!READTEC(TRUE, + FName, + &IVersion, + &DataSetTitle, + &NumZones, + &NumVars, + &VarNames, + &ZoneNames, + &NumPtsI, + &NumPtsJ, + &NumPtsK, + &ZoneType, + &UserRec, + FALSE, + (NodeMap_t ***)NULL, + (double ***)NULL)) + { + sprintf(InfoLine, "Cannot read file \"%s\"\nor file is not a Tecplot binary data file.\n", FName); + ERRMSG(InfoLine); + } + else + { + Boolean_t IsOk = TRUE; + if (LoadRawData) + { + if (AllocateRawDataSpaceLocally) + { + int NumPts; + VDataBase = ALLOC_ARRAY(NumZones * NumVars, double *, "vdatabase array"); + for (CZ = 0; CZ < NumZones; CZ++) + for (CV = 0; CV < NumVars; CV++) + { + NumPts = GetNumPts(ZoneType[CZ], NumPtsI[CZ], NumPtsJ[CZ], NumPtsK[CZ]); + if (NumPts >= 1) + VDataBase[CZ*NumVars+CV] = ALLOC_ARRAY(NumPts, double, "vdatabase array"); + else + VDataBase[CZ*NumVars+CV] = NULL; + } + + NodeMap = ALLOC_ARRAY(NumZones, NodeMap_t *, "nodemap array"); + for (CZ = 0; CZ < NumZones; CZ++) + { + if (ZoneType[CZ] == ZoneType_Ordered) + NodeMap[CZ] = NULL; + else + { + int PtsPerCell = GetNumPtsPerCell(ZoneType[CZ]); + NodeMap[CZ] = ALLOC_ARRAY(PtsPerCell * NumPtsJ[CZ], + NodeMap_t, "zone nodemap"); + } + } + } + else + { + VDataBase = NULL; + NodeMap = NULL; + } + + /* + * NOTE: If any of the above alloc's failed then no big deal. ReadTec + * itself "skips" vars if memory was not allocated for it. + */ + + DeallocHeaderInfo(&DataSetTitle, + &VarNames, + &ZoneNames, + &NumPtsI, + &NumPtsJ, + &NumPtsK, + &ZoneType, + &UserRec); + + /* + * Reread the datafile. This time load in the header AND the raw data + * Note that VDataBase may be preallocated or may be left up to ReadTec + * to allocate (See AllocateRawDataSpaceLocally above). + */ + if (!READTEC(FALSE, + FName, + &IVersion, + &DataSetTitle, + &NumZones, + &NumVars, + &VarNames, + &ZoneNames, + &NumPtsI, + &NumPtsJ, + &NumPtsK, + &ZoneType, + &UserRec, + AllocateRawDataSpaceLocally, + &NodeMap, + &VDataBase)) + { + if (IVersion > 99) + { + sprintf(InfoLine, + "Error: ***\n" + " This add-on can only display raw nodal data\n" + " and it appears to contain cell centered data.\n"); + SHOWINFO(InfoLine); + } + else + { + sprintf(InfoLine, + "Cannot Read File, %s.\n" + "File may not be a tecplot binary data file.", + FName); + ERRMSG(InfoLine); + } + IsOk = FALSE; + } + } + + SHOWINFO("\n"); + sprintf(InfoLine, "FileName : %s\n", FName); + SHOWINFO(InfoLine); + sprintf(InfoLine, "File Version: %3.1f\n", IVersion / 10.0); + SHOWINFO(InfoLine); + + /* if the file contains filetype, then retrieve that separately since ReadTec should not be changed */ + if (IVersion >= 109) + { + DataFileType_e FileType = DataFileType_Full; + char FileTypeStr[32]; + FILE *F = NULL; + + /* open the file and get the filetype */ + F = fopen(FName, "rb"); + if (F) + { + char Buffer[8]; + Int32_t One; + Int32_t FileTypeInt; + + /* 8 bytes for magic# and version and 4 bytes for Int32 */ + fread(Buffer, sizeof(Buffer[0]), 8, F); + fread(&One, sizeof(One), 1, F); + fread(&FileTypeInt, sizeof(FileTypeInt), 1, F); + FileType = (DataFileType_e)FileTypeInt; + fclose(F); + F = NULL; + } + /* map the filetype */ + switch (FileType) + { + case DataFileType_Full: + strcpy(FileTypeStr, "Full"); + break; + case DataFileType_Grid: + strcpy(FileTypeStr, "Grid"); + break; + case DataFileType_Solution: + strcpy(FileTypeStr, "Solution"); + break; + default: + IsOk = FALSE; + CHECK(FALSE); + break; + } + sprintf(InfoLine, "File Type : %s\n", FileTypeStr); + SHOWINFO(InfoLine); + } + + sprintf(InfoLine, "DataSetTitle: %s\n", DataSetTitle ? DataSetTitle : " "); + SHOWINFO(InfoLine); + sprintf(InfoLine, "NumZones : %d\n", (int)NumZones); + SHOWINFO(InfoLine); + sprintf(InfoLine, "NumVars : %d\n", (int)NumVars); + SHOWINFO(InfoLine); + if (IsOk && (NumZones > 0)) + { + SHOWINFO("Var Names : "); + for (CZ = 0; CZ < NumVars; CZ++) + { + char *VarName = STRINGLISTGETSTRING(VarNames, CZ + 1); + sprintf(InfoLine, "%s", VarName ? VarName : "NULL"); + if (CZ < NumVars - 1) + strcat(InfoLine, ","); + else + strcat(InfoLine, "\n\n"); + SHOWINFO(InfoLine); + if (VarName) + FREE_ARRAY(VarName, "VarName array"); + } + SHOWINFO("ZoneName IMax JMax KMax Node Face Elmt EType\n"); + SHOWINFO("-------------------------------------------------------------------------------\n"); + + for (CZ = 0; CZ < NumZones; CZ++) + { + char *ZoneName = STRINGLISTGETSTRING(ZoneNames, CZ + 1); + if (ZoneType[CZ] != ZoneType_Ordered) + { + if (ZoneType[CZ] == ZoneType_FEPolygon || + ZoneType[CZ] == ZoneType_FEPolyhedron) + sprintf(InfoLine, "%-20s --- --- --- %-8ld %-8ld %-8ld ", + (ZoneName ? ZoneName : "NULL"), + (long)NumPtsI[CZ], + (long)NumPtsK[CZ], + (long)NumPtsJ[CZ]); + else + sprintf(InfoLine, "%-20s --- --- --- %-8ld --- %-8ld ", + (ZoneName ? ZoneName : "NULL"), + (long)NumPtsI[CZ], + (long)NumPtsJ[CZ]); + SHOWINFO(InfoLine); + switch (ZoneType[CZ]) + { + case ZoneType_FETriangle : SHOWINFO("Tri\n"); break; + case ZoneType_FEQuad : SHOWINFO("Quad\n"); break; + case ZoneType_FETetra : SHOWINFO("Tetra\n"); break; + case ZoneType_FEBrick : SHOWINFO("Brick\n"); break; + case ZoneType_FELineSeg : SHOWINFO("LineSeg\n"); break; + case ZoneType_FEPolygon : SHOWINFO("Polygon\n"); break; + case ZoneType_FEPolyhedron: SHOWINFO("Polyhed\n"); break; + default: CHECK(FALSE); break; + } + } + else + { + sprintf(InfoLine, "%-20s %-7ld %-7ld %-7ld --- --- --- ---\n", + (ZoneName ? ZoneName : "NULL"), + (long)NumPtsI[CZ], + (long)NumPtsJ[CZ], + (long)NumPtsK[CZ]); + SHOWINFO(InfoLine); + } + if (ZoneName) + FREE_ARRAY(ZoneName, "ZoneName Array"); + } + } + + if (IsOk) + { + for (CZ = 1; CZ <= STRINGLISTGETCOUNT(UserRec); CZ++) + { + char *S = STRINGLISTGETSTRING(UserRec, CZ); + if (S) + { + int L; + strcpy(InfoLine, "UserRec: "); + L = (int)strlen(InfoLine); + strncat(&InfoLine[L], S, MAXCHARSINFOLINE - L - 2); + strcat(&InfoLine[strlen(InfoLine)], "\n"); + SHOWINFO(InfoLine); + FREE_ARRAY(S, "temp string"); + } + } + + + if (LoadRawData) + { + for (CZ = 0; CZ < NumZones; CZ++) + { + int CV; + for (CV = 0; CV < NumVars; CV++) + if (VDataBase[CZ*NumVars+CV]) + { + int I; + int NumPts = GetNumPts(ZoneType[CZ], NumPtsI[CZ], NumPtsJ[CZ], NumPtsK[CZ]); + int SLen = 0; + sprintf(InfoLine, "\n\nVariable data for zone %d, Var %d\n", CZ + 1, CV + 1); + SHOWINFO(InfoLine); + InfoLine[0] = '\0'; + for (I = 0; I < NumPts; I++) + { + char PString[50]; + if (SLen + 50 > MAXCHARSINFOLINE) + { + SHOWINFO(InfoLine); + InfoLine[0] = '\0'; + SLen = 0; + } + + sprintf(PString, "%lG ", VDataBase[CZ*NumVars+CV][I]); + strcat(InfoLine, PString); + SLen += (int)strlen(PString); + + if ((I % 5) == 4) + { + strcat(InfoLine, "\n"); + SLen++; + } + } + if (*InfoLine) + SHOWINFO(InfoLine); + FREE_ARRAY(VDataBase[CZ*NumVars+CV], "vdatabase double"); + } + if (NodeMap[CZ]) + { + int I, J; + int PtsPerCell = GetNumPtsPerCell(ZoneType[CZ]); + int SLen = 0; + SHOWINFO("\nConnectivity list:\n"); + InfoLine[0] = '\0'; + for (J = 0; J < NumPtsJ[CZ]; J++) + { + if (SLen + 200 > MAXCHARSINFOLINE) + { + SHOWINFO(InfoLine); + InfoLine[0] = '\0'; + SLen = 0; + } + for (I = 0; I < PtsPerCell; I++) + { + char NString[20]; + sprintf(NString, "%u ", (unsigned int)NodeMap[CZ][J*PtsPerCell+I] + 1); + strcat(InfoLine, NString); + SLen += (int)strlen(NString); + } + strcat(InfoLine, "\n"); + SLen++; + } + if (*InfoLine) + SHOWINFO(InfoLine); + FREE_ARRAY(NodeMap[CZ], "nodemap"); + } + } + FREE_ARRAY(NodeMap, "Nodemap base array"); + FREE_ARRAY(VDataBase, "vdatabase base array"); + } + } + + SHOWINFO("\n\n"); + + DeallocHeaderInfo(&DataSetTitle, + &VarNames, + &ZoneNames, + &NumPtsI, + &NumPtsJ, + &NumPtsK, + &ZoneType, + &UserRec); + } +} + + + +#if !defined ADDON +int main(int argc, char *(argv[])) +{ + short CurFile; + + if (argc == 1) + { + printf("Err: Need: pltview file1 [file2] ...\n"); + exit(-1); + } + + for (CurFile = 1; CurFile < argc; CurFile++) + ReportFileInfo(argv[CurFile], FALSE, FALSE); + + return 0; +} +#endif diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/readme.txt b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/readme.txt new file mode 100644 index 0000000000000000000000000000000000000000..5b47bdb4eae7d52f588aec0629402c9d3b187361 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/readme.txt @@ -0,0 +1,51 @@ +*********************************************** +** README ** +*********************************************** + +To build the TecIO library and/or the pltview utility +simply run the Runmake script in this directory. + +If customization is needed it will most likely be done +in GLOBAL.h (to identify machine as 64 bit) and/or in +dataio4.c. Just look for CRAY in dataio4.c and you +will find most of the critical areas. Note that the +existing code defined by CRAY is quite old and has +not been in use for some time. + +Each example has its own Makefile. You may have to adjust +the variables at the top of the Makefile for your platform. + + +ReadTec() + +The ReadTec() is included in the tecio library but is +not supported by Tecplot, Inc. ReadTec is used +to read Tecplot binary data files (all versions at or +older than the Tecplot version providing the tecio +library). See tecsrc/DATAUTIL.h for more information. + +The pltview example app gives an example of using ReadTec +to read just the header from a file as well as loading all +field data from a file./* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/ALLOC.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/ALLOC.h new file mode 100644 index 0000000000000000000000000000000000000000..f07fc07f905a3873d2002b5d3133fab453a28d78 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/ALLOC.h @@ -0,0 +1,205 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +/* +****************************************************************** +****************************************************************** +******* ******** +****** (C) 1988-2009 Tecplot, Inc. ******* +******* ******** +****************************************************************** +****************************************************************** +*/ +#ifndef ALLOC_H +#define ALLOC_H + +#include "TASSERT.h" +#if defined __cplusplus +#include <new> +#endif + +#if !defined __cplusplus +#define ALLOC_ARRAY(N,Type,str) (Type *)malloc((N)*sizeof(Type)) +#define ALLOC_ITEM(Type,str) (Type *)malloc(sizeof(Type)) +#ifdef _DEBUG +/* NOTE: the pointer is set to 0xFFFF after the free for debug */ +/* versions in the hopes of catching invalid pointer usage */ +#define FREE_ARRAY(X,str) do { free((void *)(X)); *((void **)&(X)) = (void *)0xFFFF; } while (0) +#define FREE_ITEM(X,str) do { free((void *)(X)); *((void **)&(X)) = (void *)0xFFFF; } while (0) +#else +#define FREE_ARRAY(X,str) free((void *)(X)) +#define FREE_ITEM(X,str) free((void *)(X)) +#endif +#else +#ifdef TRACK_MEMORY_USAGE +extern void initMemoryUsageTracking(void); +extern void cleanUpMemoryUsageTracking(void); +extern void trackMemoryAlloc(size_t size); +extern void trackMemoryFree(size_t size); +extern void trackMemoryClearHighMark(void); +extern void trackMemorySaveHighMark(void); +extern void getMemoryUsage(size_t* memoryInUse, + size_t* memoryCurrentHighMark, + size_t* memorySavedHighMark, + size_t* memoryTotalHighMark); +#endif +/* +* Create a version of new that returns NULL instead +* of throwing std::bad_alloc. A lot of code is written using +* ALLOC_ITEM and ALLOC_ARRAY that expect a return value of +* NULL on failure instead of the exception. 2008-05-08 CAM +*/ +#if defined MSWIN && defined _DEBUG +template <typename T> +inline T *nonExceptionNew(size_t numItems, + const char* fileName, + int lineNumber) +{ + REQUIRE(numItems > 0); + REQUIRE(VALID_REF(fileName)); + REQUIRE(lineNumber > 0); + T* result; + try + { +#ifdef DEBUG_NEW +#ifdef new +#undef new +#define USING_DEBUG_NEW +#endif + result = new(fileName, lineNumber) T[numItems]; +#ifdef USING_DEBUG_NEW +#define new DEBUG_NEW +#undef USING_DEBUG_NEW +#endif +#else + result = new T[numItems]; +#endif + } + catch (std::bad_alloc&) + { + result = NULL; + } +#ifdef TRACK_MEMORY_USAGE + if (result != NULL) + { +#ifdef MSWIN + trackMemoryAlloc(_msize(result)); +#else + trackMemoryAlloc(malloc_usable_size(result)); +#endif + } +#endif + ENSURE(VALID_REF_OR_NULL(result)); + return result; +} +#define ALLOC_ARRAY(N,Type,str) nonExceptionNew<Type>((N),__FILE__,__LINE__) +#else +template <typename T> +inline T *nonExceptionNew(size_t numItems) +{ + REQUIRE(numItems > 0); + T *result; + try + { + result = new T[numItems]; + } + catch (std::bad_alloc&) + { + result = NULL; + } +#ifdef TRACK_MEMORY_USAGE + if (result != NULL) + { +#ifdef MSWIN + trackMemoryAlloc(_msize(result)); +#else + trackMemoryAlloc(malloc_usable_size(result)); +#endif + } +#endif + ENSURE(VALID_REF_OR_NULL(result)); + return result; +} +#define ALLOC_ARRAY(N,Type,str) nonExceptionNew<Type>((N)) +#endif +#define ALLOC_ITEM(Type,str) ALLOC_ARRAY(1,Type,str) + +/* +* Although delete doesn't throw exceptions, this function matches +* nonExceptionNew, and also reports the size of the block if we +* are tracking memory. +*/ +template <typename T> +inline void nonExceptionDelete(T* &ptr) +{ +#if defined MSWIN && !defined NO_ASSERTS + CHECK(!IsBadReadPtr((void*)ptr, 1)); +#endif +#if defined TRACK_MEMORY_USAGE + if (ptr != NULL) + { +#ifdef MSWIN + trackMemoryFree(_msize(ptr)); +#else + trackMemoryFree(malloc_usable_size(ptr)); +#endif + } +#endif + + delete [] ptr; +#if !defined NO_ASSERTS + /* + * NOTE: the pointer is set to 0xFFFF after the free for asserted + * builds in the hopes of catching invalid pointer usage + */ + ptr = (T*)(void*)0xFFFF; +#endif +} +#define FREE_ARRAY(ptr,str) nonExceptionDelete((ptr)) +#define FREE_ITEM(ptr,str) FREE_ARRAY(ptr,str) +#endif + +/** +* The following functor can be used to easily deallocate memory from containers +* that hold pointers to allocated objects. For example: +* +* vector<MyObject*> container; +* for (int ii = 0; ii < 10; ii++ +* container.push_back(new MyObject); +* ... do something with the objects ... +* ... now we need to clean up ... +* for_each(container.begin(), +* container.end(), +* DeleteItem()); +*/ +struct DeleteItem +{ + template<typename T> + void operator()(T*& object) + { + delete object; + object = NULL; + } +}; + +#endif /* ALLOC_H */ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/ARRLIST.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/ARRLIST.h new file mode 100644 index 0000000000000000000000000000000000000000..0203dae29b7cf02a2f228d7dfd561c1c899f83b5 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/ARRLIST.h @@ -0,0 +1,626 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +/* +***************************************************************** +***************************************************************** +******* ******** +****** Copyright (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +***************************************************************** +***************************************************************** +*/ +#if !defined ARRLIST_h +#define ARRLIST_h + +#if defined EXTERN +# undef EXTERN +#endif +#if defined ARRLISTMODULE +# define EXTERN +#else +# define EXTERN extern +#endif + +typedef enum +{ + ArrayListType_UnsignedChar, + ArrayListType_UnsignedShort, + ArrayListType_UnsignedInt, + ArrayListType_UnsignedLong, + ArrayListType_Int64, + ArrayListType_Char, + ArrayListType_Short, + ArrayListType_Int, + ArrayListType_Long, + ArrayListType_Float, + ArrayListType_Double, + ArrayListType_LgIndex, + ArrayListType_EntIndex, + ArrayListType_SmInteger, + ArrayListType_Boolean, + ArrayListType_ArbParam, + ArrayListType_UnsignedCharPtr, + ArrayListType_UnsignedShortPtr, + ArrayListType_UnsignedIntPtr, + ArrayListType_UnsignedLongPtr, + ArrayListType_Int64Ptr, + ArrayListType_CharPtr, + ArrayListType_ShortPtr, + ArrayListType_IntPtr, + ArrayListType_LongPtr, + ArrayListType_FloatPtr, + ArrayListType_DoublePtr, + ArrayListType_LgIndexPtr, + ArrayListType_EntIndexPtr, + ArrayListType_SmIntegerPtr, + ArrayListType_BooleanPtr, + ArrayListType_ArbParamPtr, + ArrayListType_VoidPtr, + ArrayListType_FunctionPtr, + ArrayListType_Any, + END_ArrayListType_e, + ArrayListType_Invalid = BadEnumValue +} ArrayListType_e; + +typedef union +{ + unsigned char UnsignedChar; + unsigned short UnsignedShort; + unsigned int UnsignedInt; + unsigned long UnsignedLong; + Int64_t Int64; + char Char; + short Short; + int Int; + long Long; + float Float; + double Double; + LgIndex_t LgIndex; + EntIndex_t EntIndex; + SmInteger_t SmInteger; + Boolean_t BBoolean; /* X-Windows uses Boolean */ + ArbParam_t ArbParam; + unsigned char *UnsignedCharPtr; + unsigned short *UnsignedShortPtr; + unsigned int *UnsignedIntPtr; + unsigned long *UnsignedLongPtr; + Int64_t *Int64Ptr; + char *CharPtr; + short *ShortPtr; + int *IntPtr; + long *LongPtr; + float *FloatPtr; + double *DoublePtr; + LgIndex_t *LgIndexPtr; + EntIndex_t *EntIndexPtr; + SmInteger_t *SmIntegerPtr; + Boolean_t *BooleanPtr; + ArbParam_t *ArbParamPtr; + void *VoidPtr; + void (*FunctionPtr)(void); +} ArrayListItem_u; + +/** + * NULL array list item for added convenience of inserting a NULL item without + * having to declare and assign one. Can be used as follows: + * + * IsOk = ArrayListInsertItem(SomeArrayList, SomeIndex, ArrayListNumItem); + * + * NOTE: This value must be set to zero before Tecplot uses array lists. + * memset(&ArrayListNullItem, 0, sizeof(ArrayListType_Any)); + */ +EXTERN ArrayListItem_u ArrayListNullItem; + +/** + * Visitor for traversing an array list. An iterator may not perform any + * operation that will adjust the size of the list. In other words it may not + * insert or delete items from the list. However an iterator may perform a get + * operation or a set operation that do not expand the list size. + * + * param ItemRef + * Reference to the array list item visited. + * param ClientData + * Any client data required for the visitor. + * + * return + * TRUE to continue visiting items, otherwise + * FALSE to discontinue visiting + */ +typedef Boolean_t (*ArrayListItemVisitor_pf)(void *ItemRef, + ArbParam_t ClientData); +#if 0 /* use this stub as a starting place */ +{ + REQUIRE(VALID_REF(TypeRef)); + REQUIRE(VALID_REF(*TypeRef) || *TypeRef == NULL); + + Boolean_t DoContinue = TRUE; + <type> *TypeRef = (<type> *)ItemRef; + + ENSURE(VALID_BOOLEAN(DoContinue)); + return DoContinue; +} +#endif + + +/** + * Destructor for cleaning up one or more array list items. If a destructor is + * not supplied then the array items are simply discarded. + * + * NOTE: The only change to ArrayListItemVisitor_pf is the policy which + * requires that the return value is TRUE. + * + * param ItemRef + * Reference to the array list item to cleanup. + * param ClientData + * Any client data required for cleanup. + * + * return + * TRUE is a requirement + */ +typedef ArrayListItemVisitor_pf ArrayListItemDestructor_pf; + + +/** + * Duplicator for copying one or more array list items. If a duplicator is not + * supplied then the array items are simply copied. For pointer types this + * means by reference. Note that if a duplicator is used the rules for + * duplication and subsequent cleanup are defined by the client. + * + * param TargetItemRef + * Reference to the array list to receive the duplicate. + * param SourceItemRef + * Reference to the array list item to duplicate. + * param ClientData + * Any client data required for duplication. + * + * return + * TRUE if the duplication was a success + * FALSE otherwise. If the duplication failed it + * is the client's responsibility to cleanup any + * partial duplication + */ +typedef Boolean_t (*ArrayListItemDuplicator_pf)(void *TargetItemRef, + void *SourceItemRef, + ArbParam_t ClientData); +#if 0 /* use this stub as a starting place */ +{ + REQUIRE(VALID_REF(TargetTypeRef)); + REQUIRE(VALID_REF(SourceTypeRef)); + REQUIRE(VALID_REF(*SourceTypeRef) || *SourceTypeRef == NULL); + + Boolean_t IsOk = TRUE; + <type> *TargetTypeRef = (<type> *)TargetItemRef; + <type> *SourceTypeRef = (<type> *)SourceItemRef; + + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} +#endif + + +/** + * Adjusts the capacity request as necessary to minimize memory reallocations + * for large lists. Unless the request exceeds the maximum the adjusted + * capacity will be at least as big as requested however it may be larger if it + * is determined that the space requirement is growing faster. If the maximum + * is exceeded zero should be returned. + * + * param ArrayList + * Array list requesting the change in capacity. + * param CurrentCapacity + * Current capacity of the array list. + * param RequestedCapacity + * Capacity request or zero for default size. + * param ClientData + * Any client data needed for the adjustment. + * + * return + * Adjusted capacity that is at least as large as the request or zero if + * unable to satisfy the requested capacity. + */ +typedef LgIndex_t (*ArrayListCapacityRequestAdjuster_pf)(ArrayList_pa ArrayList, + LgIndex_t CurrentCapacity, + LgIndex_t RequestedCapacity, + ArbParam_t ClientData); +#if 0 /* use this stub as a starting place */ +{ + REQUIRE(ArrayListIsValid(ArrayList)); + REQUIRE((RequestedCapacity == 0 && CurrentCapacity == 0) || + RequestedCapacity > ArrayList->Capacity); + + LgIndex_t Result; + + ENSURE(Result == 0 || Result >= RequestedCapacity); + return Result; +} +#endif + + +/* private ArrayList structure: only exposed so STRUTIL can use it */ +typedef struct _ArrayList_s +{ + char *Array; /* byte array for holding the items */ + ArrayListType_e Type; /* type of array items */ + SmInteger_t ItemSize; /* byte size of an individual item */ + LgIndex_t Count; /* number of items in the array */ + LgIndex_t Capacity; /* maximum holding capacity of the array */ + Boolean_t IsVisitingItems; /* indicates if an iteration is in progress */ + ArrayListCapacityRequestAdjuster_pf CapacityRequestAdjuster; + ArbParam_t CapacityRequestAdjusterClientData; +} ArrayList_s; + + +/** + * Compares two array list elements. Note that either string may be + * NULL as array lists allow for NULL elements. + * + * @param Item1 + * Element to compare against Item2. + * @param Item2 + * Element to compare against Item1. + * @param ClientData + * Contextual information that was passed to the 'ArrayListQSort' function. + * + * @return + * - A value less than zero if Item1 is less than Item2. + * - A value of zero if Item1 is equal to Item2. + * - A value greater than zero if Item1 is greater than Item2. + */ +typedef int (STDCALL *ArrayListItemComparator_pf)(ArrayListItem_u Item1, + ArrayListItem_u Item2, + ArbParam_t ClientData); + +EXTERN Boolean_t ArrayListIsValid(ArrayList_pa ArrayList); +EXTERN ArrayListType_e ArrayListGetType(ArrayList_pa ArrayList); +EXTERN Boolean_t ArrayListEnlargeCapacity(ArrayList_pa ArrayList, + LgIndex_t RequestedCapacity); +EXTERN ArrayList_pa ArrayListAlloc(LgIndex_t EstimatedCapacity, + ArrayListType_e Type, + ArrayListCapacityRequestAdjuster_pf CapacityRequestAdjuster, + ArbParam_t CapacityRequestAdjusterClientData); +EXTERN void ArrayListDealloc(ArrayList_pa *ArrayList, + ArrayListItemDestructor_pf ItemDestructor, + ArbParam_t ClientData); +EXTERN void ArrayListDeleteAllItems(ArrayList_pa ArrayList, + ArrayListItemDestructor_pf ItemDestructor, + ArbParam_t ClientData); +EXTERN void ArrayListDeleteItems(ArrayList_pa ArrayList, + LgIndex_t ItemOffset, + LgIndex_t Count, + ArrayListItemDestructor_pf ItemDestructor, + ArbParam_t ClientData); +EXTERN void ArrayListDeleteItem(ArrayList_pa ArrayList, + LgIndex_t ItemOffset, + ArrayListItemDestructor_pf ItemDestructor, + ArbParam_t ClientData); +EXTERN ArrayList_pa ArrayListRemoveItems(ArrayList_pa ArrayList, + LgIndex_t ItemOffset, + LgIndex_t Count); +EXTERN ArrayListItem_u ArrayListRemoveItem(ArrayList_pa ArrayList, + LgIndex_t ItemOffset); +EXTERN Boolean_t ArrayListInsertItem(ArrayList_pa ArrayList, + LgIndex_t ItemOffset, + ArrayListItem_u Item); +EXTERN Boolean_t ArrayListInsert(ArrayList_pa Target, + LgIndex_t ItemOffset, + ArrayList_pa Source); +EXTERN Boolean_t ArrayListVisitItems(ArrayList_pa ArrayList, + LgIndex_t ItemOffset, + LgIndex_t Count, + ArrayListItemVisitor_pf ItemVisitor, + ArbParam_t ClientData); +EXTERN ArrayList_pa ArrayListGetItems(ArrayList_pa ArrayList, + LgIndex_t ItemOffset, + LgIndex_t Count); +EXTERN ArrayListItem_u ArrayListGetItem(ArrayList_pa ArrayList, + LgIndex_t ItemOffset); +EXTERN Boolean_t ArrayListSetItem(ArrayList_pa ArrayList, + LgIndex_t ItemOffset, + ArrayListItem_u Item, + ArrayListItemDestructor_pf ItemDestructor, + ArbParam_t ClientData); +EXTERN Boolean_t ArrayListAppendItem(ArrayList_pa ArrayList, + ArrayListItem_u Item); +EXTERN Boolean_t ArrayListAppend(ArrayList_pa Target, + ArrayList_pa Source); +EXTERN ArrayList_pa ArrayListCopy(ArrayList_pa ArrayList, + ArrayListItemDuplicator_pf ItemDuplicator, + ArbParam_t ClientData); +EXTERN void *ArrayListToArray(ArrayList_pa ArrayList, + ArrayListItemDuplicator_pf ItemDuplicator, + ArbParam_t ClientData); +EXTERN ArrayList_pa ArrayListFromArray(void *Source, + LgIndex_t Count, + ArrayListType_e Type, + ArrayListItemDuplicator_pf ItemDuplicator, + ArbParam_t ClientData); + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif +EXTERN void ArrayListQSort(ArrayList_pa ArrayList, + ArrayListItemComparator_pf Comparator, + ArbParam_t ClientData); +EXTERN Boolean_t ArrayListBSearch(ArrayList_pa ArrayList, + ArrayListItem_u Item, + ArrayListItemComparator_pf Comparator, + ArbParam_t ClientData, + LgIndex_t *ItemIndex); + +#if defined USE_MACROS_FOR_FUNCTIONS +/** + * Gets the array list's internal buffer representation. + * Use ArrayListGetXxx accessors whenever possible as their + * implementation in the release build is as fast as using + * the array directly anyway. + * + * WARNING: + * Some array list functions modify the internal buffer. + * This will invalidate this reference however it is + * the client's responsibility not to make further use + * of it. In addition, this reference should never be + * deallocated directly as the array list assumes the + * responsible for the cleanup. + * + * param ArrayList + * Array list for which a reference to the internal + * buffer is desired. + * + * return + * Reference to the array list's internal buffer. + */ +# define ArrayListGetInternalRef ArrayListGetInternalRef_MACRO +/** + * Gets the item's internal reference at the specified offset in the list. + * + * WARNING: + * Some array list functions modify the internal buffer. + * This will invalidate this reference however it is + * the client's responsibility not to make further use + * of it. In addition, this reference should never be + * deallocated directly as the array list assumes the + * responsible for the cleanup. + * + * param ArrayList + * Array list containing the desired item. + * param ItemOffset + * Offset to the item in the list. + * + * return + * The internal reference to the requested item. + */ +# define ArrayListGetItemInternalRef ArrayListGetItemInternalRef_MACRO +# define ArrayListGetCount ArrayListGetCount_MACRO + +# define ArrayListGetUnsignedChar(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, unsigned char) +# define ArrayListGetUnsignedShort(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, unsigned short) +# define ArrayListGetUnsignedInt(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, unsigned int) +# define ArrayListGetUnsignedLong(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, unsigned long) +# define ArrayListGetInt64(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, Int64_t) +# define ArrayListGetChar(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, char) +# define ArrayListGetShort(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, short) +# define ArrayListGetInt(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, int) +# define ArrayListGetLong(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, long) +# define ArrayListGetFloat(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, float) +# define ArrayListGetDouble(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, double) +# define ArrayListGetLgIndex(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, LgIndex_t) +# define ArrayListGetEntIndex(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, EntIndex_t) +# define ArrayListGetSmInteger(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, SmInteger_t) +# define ArrayListGetBoolean(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, Boolean_t) +# define ArrayListGetArbParam(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, ArbParam_t) +# define ArrayListGetUnsignedCharPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, unsigned char *) +# define ArrayListGetUnsignedShortPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, unsigned short *) +# define ArrayListGetUnsignedIntPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, unsigned int *) +# define ArrayListGetUnsignedLongPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, unsigned long *) +# define ArrayListGetInt64Ptr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, Int64_t *) +# define ArrayListGetCharPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, char *) +# define ArrayListGetShortPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, short *) +# define ArrayListGetIntPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, int *) +# define ArrayListGetLongPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, long *) +# define ArrayListGetFloatPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, float *) +# define ArrayListGetDoublePtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, double *) +# define ArrayListGetLgIndexPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, LgIndex_t *) +# define ArrayListGetEntIndexPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, EntIndex_t *) +# define ArrayListGetSmIntegerPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, SmInteger_t *) +# define ArrayListGetBooleanPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, Boolean_t *) +# define ArrayListGetArbParamPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, ArbParam_t *) +# define ArrayListGetVoidPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, void *) +# define ArrayListGetFunctionPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, (**)(void)) +#else +# define ArrayListGetInternalRef ArrayListGetInternalRef_FUNC +# define ArrayListGetItemInternalRef ArrayListGetItemInternalRef_FUNC +# define ArrayListGetCount ArrayListGetCount_FUNC + +# define ArrayListGetUnsignedChar(ArrayList, ItemOffset) (*((unsigned char *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetUnsignedShort(ArrayList, ItemOffset) (*((unsigned short *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetUnsignedInt(ArrayList, ItemOffset) (*((unsigned int *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetUnsignedLong(ArrayList, ItemOffset) (*((unsigned long *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetInt64(ArrayList, ItemOffset) (*((Int64_t *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetChar(ArrayList, ItemOffset) (*((char *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetShort(ArrayList, ItemOffset) (*((short *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetInt(ArrayList, ItemOffset) (*((int *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetLong(ArrayList, ItemOffset) (*((long *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetFloat(ArrayList, ItemOffset) (*((float *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetDouble(ArrayList, ItemOffset) (*((double *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetLgIndex(ArrayList, ItemOffset) (*((LgIndex_t *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetEntIndex(ArrayList, ItemOffset) (*((EntIndex_t *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetSmInteger(ArrayList, ItemOffset) (*((SmInteger_t *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetBoolean(ArrayList, ItemOffset) (*((Boolean_t *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetArbParam(ArrayList, ItemOffset) (*((ArbParam_t *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetUnsignedCharPtr(ArrayList, ItemOffset) (*((unsigned char * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetUnsignedShortPtr(ArrayList, ItemOffset) (*((unsigned short * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetUnsignedIntPtr(ArrayList, ItemOffset) (*((unsigned int * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetUnsignedLongPtr(ArrayList, ItemOffset) (*((unsigned long * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetInt64Ptr(ArrayList, ItemOffset) (*((Int64_t * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetCharPtr(ArrayList, ItemOffset) (*((char * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetShortPtr(ArrayList, ItemOffset) (*((short * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetIntPtr(ArrayList, ItemOffset) (*((int * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetLongPtr(ArrayList, ItemOffset) (*((long * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetFloatPtr(ArrayList, ItemOffset) (*((float * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetDoublePtr(ArrayList, ItemOffset) (*((double * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetLgIndexPtr(ArrayList, ItemOffset) (*((LgIndex_t * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetEntIndexPtr(ArrayList, ItemOffset) (*((EntIndex_t * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetSmIntegerPtr(ArrayList, ItemOffset) (*((SmInteger_t * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetBooleanPtr(ArrayList, ItemOffset) (*((Boolean_t * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetArbParamPtr(ArrayList, ItemOffset) (*((ArbParam_t * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetVoidPtr(ArrayList, ItemOffset) (*((void * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +# define ArrayListGetFunctionPtr(ArrayList, ItemOffset) (*(((**)(void) *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))) +#endif + +#if !defined USE_MACROS_FOR_FUNCTIONS +EXTERN const void *ArrayListGetInternalRef_FUNC(ArrayList_pa ArrayList); +EXTERN const void *ArrayListGetItemInternalRef_FUNC(ArrayList_pa ArrayList, + LgIndex_t ItemOffset); +EXTERN LgIndex_t ArrayListGetCount_FUNC(ArrayList_pa ArrayList); +#endif + +#define ArrayListGetInternalRef_MACRO(ArrayList) ((const void *)((ArrayList)->Array)) +#define ArrayListGetItemInternalRef_MACRO(ArrayList, ItemOffset) ((const void *)&((ArrayList)->Array[(ItemOffset)*(ArrayList)->ItemSize])) +#define ArrayListGetCount_MACRO(ArrayList) ((ArrayList)->Count) +#define ArrayListGetTypedArrayRef(ArrayList, NativeType) ((NativeType *)((ArrayList)->Array)) +#define ArrayListGetTypedItem(ArrayList, ItemOffset, NativeType) (ArrayListGetTypedArrayRef(ArrayList,NativeType)[ItemOffset]) + +/** + * Simple macro to determine if the item offset is within the array list + * capacity. In the debug or checked builds we also perform a lower bound + * assertion check. + */ +#if defined NO_ASSERTS +# define ArrayListOffsetWithinCapacity(ArrayList, ItemOffset) ((ItemOffset) < (ArrayList)->Capacity) +#else +/** + * Using 'assert' rather than 'REQUIRE' because under Windows, REQUIRE (and ASSERT) trickles down to being a + * do-while loop, which doesn't jive well with the comma operator. + */ +# define ArrayListOffsetWithinCapacity(ArrayList, ItemOffset) ((assert((ItemOffset) >= 0),TRUE) && ((ItemOffset) < (ArrayList)->Capacity)) +#endif + +/** + * Places the item at the specified offset. If the offset is beyond the + * end of the list it is sized accordingly and the intervening items + * between the last item of the original state and the last item of the + * new state are guaranteed to be 0. + * + * This is the workhorse of the set and append convenience macros that follow. + * Please note that unlike ArrayListSetItem no destructor facility is provided + * therefore if an item previously occupied 'ItemOffset' it will be replaced. + * + * param ArrayList + * Array list target in which to set the item. + * param ItemOffset + * Offset of the item. + * param Item + * Item to set at the specified offset. Its native type must + * match 'NativeType' + * param NativeType + * Native type of 'Item'. + * + * return + * TRUE if sufficient memory permitted the operation, otherwise FALSE. + */ +#define ArrayListSetTypedItem(ArrayList, ItemOffset, Item, NativeType) \ + ((ArrayListOffsetWithinCapacity((ArrayList), (ItemOffset)) || \ + ArrayListEnlargeCapacity((ArrayList), (ItemOffset)+1)) \ + ? (((((NativeType *)((ArrayList)->Array))[(ItemOffset)]) = (Item)), \ + (((ItemOffset)+1 > (ArrayList)->Count) \ + ? (((ArrayList)->Count = (ItemOffset)+1), TRUE) \ + : (TRUE))) \ + : (FALSE)) + +/** + * This section provides macros for high speed setting and appending to an + * array list of a known type. The only additional overhead incurred versus just + * using a simple array is the cost of testing the array list capacity. + */ +#define ArrayListSetUnsignedChar(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, unsigned char) +#define ArrayListSetUnsignedShort(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, unsigned short) +#define ArrayListSetUnsignedInt(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, unsigned int) +#define ArrayListSetUnsignedLong(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, unsigned long) +#define ArrayListSetInt64(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, Int64_t) +#define ArrayListSetChar(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, char) +#define ArrayListSetShort(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, short) +#define ArrayListSetInt(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, int) +#define ArrayListSetLong(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, long) +#define ArrayListSetFloat(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, float) +#define ArrayListSetDouble(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, double) +#define ArrayListSetLgIndex(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, LgIndex_t) +#define ArrayListSetEntIndex(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, EntIndex_t) +#define ArrayListSetSmInteger(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, SmInteger_t) +#define ArrayListSetBoolean(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, Boolean_t) +#define ArrayListSetArbParam(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, ArbParam_t) +#define ArrayListSetUnsignedCharPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, unsigned char *) +#define ArrayListSetUnsignedShortPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, unsigned short *) +#define ArrayListSetUnsignedIntPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, unsigned int *) +#define ArrayListSetUnsignedLongPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, unsigned long *) +#define ArrayListSetInt64Ptr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, Int64_t *) +#define ArrayListSetCharPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, char *) +#define ArrayListSetShortPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, short *) +#define ArrayListSetIntPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, int *) +#define ArrayListSetLongPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, long *) +#define ArrayListSetFloatPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, float *) +#define ArrayListSetDoublePtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, double *) +#define ArrayListSetLgIndexPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, LgIndex_t *) +#define ArrayListSetEntIndexPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, EntIndex_t *) +#define ArrayListSetSmIntegerPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, SmInteger_t *) +#define ArrayListSetBooleanPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, Boolean_t *) +#define ArrayListSetArbParamPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, ArbParam_t *) +#define ArrayListSetVoidPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, void *) +#define ArrayListSetFunctionPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, (**)(void)) + +#define ArrayListAppendUnsignedChar(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, unsigned char) +#define ArrayListAppendUnsignedShort(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, unsigned short) +#define ArrayListAppendUnsignedInt(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, unsigned int) +#define ArrayListAppendUnsignedLong(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, unsigned long) +#define ArrayListAppendInt64(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, Int64_t) +#define ArrayListAppendChar(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, char) +#define ArrayListAppendShort(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, short) +#define ArrayListAppendInt(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, int) +#define ArrayListAppendLong(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, long) +#define ArrayListAppendFloat(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, float) +#define ArrayListAppendDouble(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, double) +#define ArrayListAppendLgIndex(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, LgIndex_t) +#define ArrayListAppendEntIndex(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, EntIndex_t) +#define ArrayListAppendSmInteger(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, SmInteger_t) +#define ArrayListAppendBoolean(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, Boolean_t) +#define ArrayListAppendArbParam(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, ArbParam_t) +#define ArrayListAppendUnsignedCharPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, unsigned char *) +#define ArrayListAppendUnsignedShortPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, unsigned short *) +#define ArrayListAppendUnsignedIntPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, unsigned int *) +#define ArrayListAppendUnsignedLongPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, unsigned long *) +#define ArrayListAppendInt64Ptr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, Int64_t *) +#define ArrayListAppendCharPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, char *) +#define ArrayListAppendShortPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, short *) +#define ArrayListAppendIntPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, int *) +#define ArrayListAppendLongPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, long *) +#define ArrayListAppendFloatPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, float *) +#define ArrayListAppendDoublePtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, double *) +#define ArrayListAppendLgIndexPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, LgIndex_t *) +#define ArrayListAppendEntIndexPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, EntIndex_t *) +#define ArrayListAppendSmIntegerPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, SmInteger_t *) +#define ArrayListAppendBooleanPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, Boolean_t *) +#define ArrayListAppendArbParamPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, ArbParam_t *) +#define ArrayListAppendVoidPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, void *) +#define ArrayListAppendFunctionPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, (**)(void)) + +#endif /* ARRLIST_h */ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/AUXDATA.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/AUXDATA.h new file mode 100644 index 0000000000000000000000000000000000000000..27c4747a3d2867dce50e248e3b06d0acc407943a --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/AUXDATA.h @@ -0,0 +1,130 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +/* + ***************************************************************** + ***************************************************************** + ******* ******** + ****** Copyright (C) 1988-2008 Tecplot, Inc. ******* + ******* ******** + ***************************************************************** + ***************************************************************** + */ +#if !defined AUXDATA_h +#define AUXDATA_h + +#if defined EXTERN +# undef EXTERN +#endif +#if defined AUXDATAMODULE +# define EXTERN +#else +# define EXTERN extern +#endif + +/** + */ +EXTERN Boolean_t AuxDataIsValidNameChar(char Char, + Boolean_t IsLeadChar); +/** + */ +EXTERN Boolean_t AuxDataIsValidName(const char *Name); + +/** + */ +EXTERN AuxData_pa AuxDataAlloc(void); + +/** + */ +EXTERN void AuxDataDealloc(AuxData_pa *AuxData); + +/** + */ +EXTERN Boolean_t AuxDataItemDestructor(void *ItemRef, + ArbParam_t ClientData); +/** + */ +EXTERN AuxData_pa AuxDataCopy(AuxData_pa AuxData, + Boolean_t ConsiderRetain); + +/** + */ +EXTERN LgIndex_t AuxDataGetNumItems(AuxData_pa AuxData); + +/** + */ +EXTERN Boolean_t AuxDataGetItemIndex(AuxData_pa AuxData, + const char *Name, + LgIndex_t *ItemIndex); +/** + */ +EXTERN void AuxDataGetItemByIndex(AuxData_pa AuxData, + LgIndex_t Index, + const char **Name, + ArbParam_t *Value, + AuxDataType_e *Type, + Boolean_t *Retain); + +/** + */ +EXTERN Boolean_t AuxDataGetItemByName(AuxData_pa AuxData, + const char *Name, + ArbParam_t *Value, + AuxDataType_e *Type, + Boolean_t *Retain); + +/** + */ +EXTERN Boolean_t AuxDataGetBooleanItemByName(AuxData_pa AuxData, + const char *Name, + Boolean_t *Value, + AuxDataType_e *Type, + Boolean_t *Retain); + +/** + */ +EXTERN Boolean_t AuxDataSetItem(AuxData_pa AuxData, + const char *Name, + ArbParam_t Value, + AuxDataType_e Type, + Boolean_t Retain); + +/** + */ +EXTERN Boolean_t AuxDataDeleteItemByName(AuxData_pa AuxData, + const char *Name); + +/** + */ +EXTERN Boolean_t AuxDataAppendItems(AuxData_pa TargetAuxData, + AuxData_pa SourceAuxData); +/** + */ +EXTERN void AuxDataDeleteItemByIndex(AuxData_pa AuxData, + LgIndex_t Index); + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif /* TECPLOTKERNEL */ + +#endif /* !defined AUXDATA_h */ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/DATAIO.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/DATAIO.h new file mode 100644 index 0000000000000000000000000000000000000000..c57df19edd93eadabe8fa3138f110ab9411121a4 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/DATAIO.h @@ -0,0 +1,63 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +#if defined EXTERN +#undef EXTERN +#endif +#if defined DATAIOMODULE +#define EXTERN +#else +#define EXTERN extern +#endif + +EXTERN Boolean_t OpenBinaryFileAndCheckMagicNumber(FileStream_s **FileStream, + char *FName, + FileOffset_t StartOffset, + short *IVersion); + +EXTERN Boolean_t ReadDataFileHeader(FileStream_s *FileStream, + short IVersion, + Boolean_t ShowDataIOStatus, + EntIndex_t *NumZones, + EntIndex_t *NumVars, + SmInteger_t *NumCustomLabelSets, + char **DataSetTitle, + Text_s **BaseText, + Geom_s **BaseGeom, + StringList_pa **CustomLabelBase, + StringList_pa *UserRec, + AuxData_pa *DataSetAuxData, + Set_pa **IsVarCellCentered, + Boolean_t *HasText, + Boolean_t *HasGeoms, + ArrayList_pa *ZoneSpecList, + StringList_pa *VarNames, + ArrayList_pa *VarAuxDataList, /*<AuxData_pa>[NumVars]*/ + Set_pa *IsRawFNAvailable, /* classic data only */ + LgIndex_t **FNNumBndryConns, /* classic data only */ + DataFileType_e *FileType); + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/DATAIO4.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/DATAIO4.h new file mode 100644 index 0000000000000000000000000000000000000000..7e97dc98f646954e43808fccab76f31488ee2db0 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/DATAIO4.h @@ -0,0 +1,213 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +#ifndef DATAIO4_H +#define DATAIO4_H +/* +****************************************************************** +****************************************************************** +******* ******** +****** (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +****************************************************************** +****************************************************************** +*/ + +#include <set> + +#if defined EXTERN +#undef EXTERN +#endif +#if defined DATAIO4MODULE +#define EXTERN +#else +#define EXTERN extern +#endif + +EXTERN double GetNextValue(FileStream_s *FileStream, + FieldDataType_e FieldDataType, + double Min, + double Max, + Boolean_t *IsOk); +EXTERN LgIndex_t GetNextI(FileStream_s *FileStream, + Boolean_t *IsOk); +EXTERN LgIndex_t GetIoFileInt(FileStream_s *FileStream, + short Version, + LgIndex_t Min, + LgIndex_t Max, + Boolean_t *IsOk); +EXTERN Boolean_t ReadInString(FileStream_s *FileStream, + short IVersion, + int MaxCharacters, + char **S, + Boolean_t ProcessData); +EXTERN void ReadByteBlock(FileStream_s *FileStream, + Boolean_t DoRead, + Byte_t *Buffer, + HgIndex_t StartIndex, + HgIndex_t NumValues, + Boolean_t *IsOk); +EXTERN void ReadInt16Block(FileStream_s *FileStream, + Boolean_t DoRead, + Int16_t *Buffer, + HgIndex_t StartIndex, + HgIndex_t NumValues, + Boolean_t *IsOk); +EXTERN void ReadInt16BlockToInt32(FileStream_s *FileStream, + Boolean_t DoRead, + Int32_t *Buffer, + HgIndex_t StartIndex, + HgIndex_t NumValues, + Boolean_t *IsOk); +EXTERN void ReadInt32Block(FileStream_s *FileStream, + Boolean_t DoRead, + Int32_t *Buffer, + HgIndex_t StartIndex, + HgIndex_t NumValues, + Boolean_t *IsOk); +EXTERN void ReadPureBlock(FileStream_s *FileStream, + Boolean_t DoRead, + void *Buffer, + FieldDataType_e FieldDataType, + HgIndex_t StartIndex, + HgIndex_t NumValues, + Boolean_t *IsOk); +EXTERN void ReadBlock(FileStream_s *FileStream, + FieldData_pa FieldData, + Boolean_t DoRead, + FieldDataType_e FieldDataTypeInFile, + HgIndex_t StartIndex, + HgIndex_t EndIndex, + Boolean_t *IsOk); +EXTERN void ReadClassicOrderedCCBlock(FileStream_s *DataFileStream, + FieldData_pa FieldData, + FieldDataType_e FieldDataTypeInFile, + LgIndex_t NumIPtsInFile, + LgIndex_t NumJPtsInFile, + LgIndex_t NumKPtsInFile, + Boolean_t *IsOk); +EXTERN Boolean_t ReadInDataFileTypeTitleAndVarNames(FileStream_s *FileStream, + short IVersion, + char **DataSetTitle, + DataFileType_e *FileType, + int *NumVars, + StringList_pa *VarNames); +EXTERN Boolean_t ReadInZoneHeader(FileStream_s *FileStream, + short IVersion, + ZoneSpec_s *ZoneSpec, + Set_pa IsVarCellCentered, + EntIndex_t NumVars, + Boolean_t *IsRawFNAvailable, + LgIndex_t *FNNumBndryConns); +EXTERN Boolean_t ReadInCustomLabels(FileStream_s *FileStream, + short IVersion, + Boolean_t OkToLoad, + StringList_pa *CustomLabelBase); +EXTERN Boolean_t ReadInUserRec(FileStream_s *FileStream, + short IVersion, + int MaxCharactersAllowed, + char **UserRec); +EXTERN Boolean_t ReadInAuxData(FileStream_s *FileStream, + short IVersion, + AuxData_pa AuxData); +EXTERN Boolean_t ReadInGeometry(FileStream_s *FileStream, + short IVersion, + Boolean_t OkToLoad, + Geom_s *G, + LgIndex_t MaxDataPts); +EXTERN Boolean_t ReadInText(FileStream_s *FileStream, + short IVersion, + Boolean_t OkToLoad, + Text_s *T, + LgIndex_t MaxTextLen); +/* + * STDCALL since PreplotAsciiDatafile is sent to RegisterDataSetReader + * which can also be used by addons. + */ +EXTERN Boolean_t STDCALL PreplotAsciiDatafile(char *CurFName, + char *BinaryFName, + char **MessageString); +EXTERN short GetInputVersion(FileStream_s *FileStream); + +EXTERN Boolean_t WriteBinaryInt16BlockUnaligned(FileStream_s *FileStream, + Byte_t *Int16Values, + HgIndex_t NumValues, + Boolean_t ValuesInNativeOrdering); +EXTERN Boolean_t WriteBinaryInt32BlockUnaligned(FileStream_s *FileStream, + Byte_t *Int32Values, + HgIndex_t NumValues, + Boolean_t ValuesInNativeOrdering); +EXTERN Boolean_t WriteBinaryByteBlock(FileStream_s *FileStream, + const Byte_t *ByteValues, + const HgIndex_t NumValues); +EXTERN Boolean_t WriteBinaryInt16(FileStream_s *FileStream, + Int16_t Value); +EXTERN Boolean_t WriteBinaryInt32(FileStream_s *FileStream, + Int32_t Value); +EXTERN Boolean_t WriteBinaryReal(FileStream_s *FileStream, + double RR, + FieldDataType_e FieldDataType); +EXTERN Boolean_t WriteFieldDataType(FileStream_s *FileStream, + FieldDataType_e FDT, + Boolean_t WriteBinary); +EXTERN Boolean_t WriteBinaryFieldDataBlock(FileStream_s *FileStream, + FieldData_pa D, + LgIndex_t StartI, + LgIndex_t NumValues); +EXTERN Boolean_t WriteCCFieldDataBlock(FileStream_s *FileStream, + FieldData_pa FieldData, + Boolean_t IsOrderedData, + LgIndex_t NumIPts, + LgIndex_t NumJPts, + LgIndex_t NumKPts, + Boolean_t WriteBinary, + SmInteger_t AsciiPrecision); +EXTERN Boolean_t DumpDatafileString(FileStream_s *FileStream, + const char *S, + Boolean_t WriteBinary); +bool DumpGeometry(FileStream_s* FileStream, + Geom_s const* Geom, + Boolean_t WriteBinary, + Boolean_t WriteGridDataAsPolar); +bool DumpText(FileStream_s* FileStream, + Text_s const* Text, + Boolean_t WriteBinary, + Boolean_t WriteGridDataAsPolar); +EXTERN Boolean_t DumpCustomAxisLabels(FileStream_s *FileStream, + Boolean_t WriteBinary, + StringList_pa LabelBase); + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +EXTERN Boolean_t WriteBinaryMagic(FileStream_s *FileStream); + +bool writeBinaryVersionNumber(FileStream_s& fileStream, + int versionNumber); + +#endif //DATAIO4_H diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/DATASET.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/DATASET.h new file mode 100644 index 0000000000000000000000000000000000000000..89cc27ff9c313daa8c6d0dd960afed66a09e91e4 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/DATASET.h @@ -0,0 +1,90 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +#ifndef DATASET_h__ +#define DATASET_h__ + +/* +****************************************************************** +****************************************************************** +******* ******** +****** (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +****************************************************************** +****************************************************************** +*/ + + +/* + * DataSet functions involving zones, vars and the + * DataSet_s structure. See dataset0.c for low level + * dataset functions and dataset2 for higher level + * functions. + */ + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if defined USE_MACROS_FOR_FUNCTIONS +#else +#endif +#endif /* TECPLOTKERNEL */ + +Boolean_t FieldDataItemDestructor(void *ItemRef, + ArbParam_t ClientData); +Boolean_t ZoneSpecItemDestructor(void *ItemRef, + ArbParam_t ClientData); +LgIndex_t ZoneOrVarListAdjustCapacityRequest(ArrayList_pa ZoneOrVarArrayList, + LgIndex_t CurrentCapacity, + LgIndex_t RequestedCapacity, + ArbParam_t ClientData); +void CleanoutZoneSpec(ZoneSpec_s *ZoneSpec); +void ZoneSpecExcludeBndryConnsFromMetrics(ZoneSpec_s* ZoneSpec); +ZoneSpec_s *ZoneSpecAlloc(void); +void ZoneSpecDealloc(ZoneSpec_s **ZoneSpec); +void SetZoneSpecDefaults(ZoneSpec_s *ZoneSpec); + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if defined USE_MACROS_FOR_FUNCTIONS +#else +#endif +#endif + +#define GetZoneSpec(ZoneSpecList,Zone) ((ZoneSpec_s *)ArrayListGetVoidPtr(ZoneSpecList,Zone)) +#define GetZoneAuxData(DataSet, Zone) (GetZoneSpec((DataSet)->ZoneSpecList, (Zone))->AuxData) +#define GetVarSpec(VarSpecList,Var) ((VarSpec_s *)ArrayListGetVoidPtr(VarSpecList,Var)) +#define GetVarAuxData(DataSet, Var) (GetVarSpec((DataSet)->VarSpecList, (Var))->AuxData) +#define GetStrandInfo(StrandInfoList, StrandID) ((StrandInfo_s *)ArrayListGetVoidPtr(StrandInfoList,StrandID)) + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif /* defined TECPLOTKERNEL */ + +#endif // DATASET_h__ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/DATASET0.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/DATASET0.h new file mode 100644 index 0000000000000000000000000000000000000000..ee33773f304c8480d263c751482bf130359e58f0 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/DATASET0.h @@ -0,0 +1,404 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +#if defined EXTERN +#undef EXTERN +#endif +#if defined DATASET0MODULE +#define EXTERN +#else +#define EXTERN extern +#endif + +/* +****************************************************************** +****************************************************************** +******* ******** +****** (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +****************************************************************** +****************************************************************** +*/ + +namespace tecplot +{ +namespace io +{ +class File; +} +} + +EXTERN void OutOfMemoryMsg(void); + +/* + * Turn on DEBUG_FIELDVALUES by default in any build with assertions on + * (including checked builds), but allow turning this off with + * NO_DEBUG_FIELDVALUES + */ +#if !defined NO_ASSERTS && !defined NO_DEBUG_FIELDVALUES && !defined DEBUG_FIELDVALUES +#define DEBUG_FIELDVALUES +#endif + +/* FieldData_a is intentionally not defined to further + * deter usage of this private structure */ +struct _FieldData_a +{ + void *Data; /* ...placed first in the structure for fastest access */ +# if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# else + void *GetValueCallback[1]; /* ...this field is for TecIO only */ + void *SetValueCallback[1]; /* ...this field is for TecIO only */ +# endif + + /* PRIVATE */ + FieldDataType_e Type; + ValueLocation_e ValueLocation; + LgIndex_t RefCount; + LgIndex_t VarShareRefCount; + LgIndex_t NumValues; +# if defined TECPLOTKERNEL /* TecIO doesn't require these features yet. */ +/* CORE SOURCE CODE REMOVED */ +# endif +}; + + +/* * + * * NOTE: "FieldData_pa" here is an "abstract type". + * * Any routines dealing with the internals workings + * * of FieldData_pa must be in the same file as these + * * routines + * */ + +#if defined USE_MACROS_FOR_FUNCTIONS +#define USE_MACROS_FOR_FIELD_DATA_FUNCTIONS +#endif + +/* + * These are low-level (private) FD manipulation functions. In + * most cases, you should use some higher-level function. These + * macros are supplied for the dataset functions to use. + */ +#if defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS +#define GetFieldDataType GetFieldDataType_MACRO +#define GetFieldDataGetFunction GetFieldDataGetFunction_MACRO +#define GetFieldDataSetFunction GetFieldDataSetFunction_MACRO +#define GetFieldDataNumValues GetFieldDataNumValues_MACRO +#define GetFieldDataValueLocation GetFieldDataValueLocation_MACRO +#define IsFieldDataDirectAccessAllowed IsFieldDataDirectAccessAllowed_MACRO +#else +#define GetFieldDataType GetFieldDataType_FUNC +#define GetFieldDataGetFunction GetFieldDataGetFunction_FUNC +#define GetFieldDataSetFunction GetFieldDataSetFunction_FUNC +#define GetFieldDataNumValues GetFieldDataNumValues_FUNC +#define GetFieldDataValueLocation GetFieldDataValueLocation_FUNC +#define IsFieldDataDirectAccessAllowed IsFieldDataDirectAccessAllowed_FUNC +#endif + +#define GetFieldDataType_MACRO(FieldData) ((FieldData)->Type) +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#else /* ...for TecIO only */ +#define GetFieldDataGetFunction_MACRO(FieldData) ((FieldValueGetFunction_pf)(FieldData)->GetValueCallback[0]) +#define GetFieldDataSetFunction_MACRO(FieldData) ((FieldValueSetFunction_pf)(FieldData)->SetValueCallback[0]) +#endif +#define GetFieldDataNumValues_MACRO(FieldData) ((FieldData)->NumValues) +#define GetFieldDataValueLocation_MACRO(FieldData) ((FieldData)->ValueLocation) + +EXTERN double STDCALL GetFieldValueForFloat(const FieldData_pa fd, LgIndex_t pt); +EXTERN double STDCALL GetFieldValueForDouble(const FieldData_pa fd, LgIndex_t pt); +EXTERN double STDCALL GetFieldValueForInt32(const FieldData_pa fd, LgIndex_t pt); +EXTERN double STDCALL GetFieldValueForInt16(const FieldData_pa fd, LgIndex_t pt); +EXTERN double STDCALL GetFieldValueForByte(const FieldData_pa fd, LgIndex_t pt); +EXTERN double STDCALL GetFieldValueForBit(const FieldData_pa fd, LgIndex_t pt); + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#else +#define IsFieldDataDirectAccessAllowed_MACRO(FieldData) ((FieldData)->Data != NULL) +#endif + +#if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS +EXTERN FieldDataType_e GetFieldDataType_FUNC(FieldData_pa FieldData); +EXTERN FieldValueGetFunction_pf GetFieldDataGetFunction_FUNC(FieldData_pa FieldData); +EXTERN FieldValueSetFunction_pf GetFieldDataSetFunction_FUNC(FieldData_pa FieldData); +EXTERN LgIndex_t GetFieldDataNumValues_FUNC(FieldData_pa FieldData); +EXTERN ValueLocation_e GetFieldDataValueLocation_FUNC(FieldData_pa FieldData); +EXTERN Boolean_t IsFieldDataDirectAccessAllowed_FUNC(FieldData_pa FieldData); +#endif + + +/* + * Use separate types for reversed byte data than unreversed data so we + * have better compiler checking. + */ +typedef UInt32_t FloatRev_t; +typedef UInt64_t DoubleRev_t; +typedef UInt16_t Int16Rev_t; +typedef UInt32_t Int32Rev_t; +typedef UInt64_t Int64Rev_t; + + +/* + * Note: there are so many GetFieldData*Ptr functions because we + * want a bunch of error checking. The Type and TypeRev check + * for that type. The Byte, 2Byte, etc. just make sure it is + * that type. + * GetFieldDataVoidPtr checks nothing, and thus should only be + * used with extreme caution (that is, checking the alignment + * and byte order by hand). + */ +#if defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS +#define GetFieldDataFloatPtr GetFieldDataFloatPtr_MACRO +#define GetFieldDataFloatRevPtr GetFieldDataFloatRevPtr_MACRO +#define GetFieldDataDoublePtr GetFieldDataDoublePtr_MACRO +#define GetFieldDataDoubleRevPtr GetFieldDataDoubleRevPtr_MACRO +#define GetFieldDataInt64Ptr GetFieldDataInt64Ptr_MACRO +#define GetFieldDataInt64RevPtr GetFieldDataInt64RevPtr_MACRO +#define GetFieldDataInt32Ptr GetFieldDataInt32Ptr_MACRO +#define GetFieldDataInt32RevPtr GetFieldDataInt32RevPtr_MACRO +#define GetFieldDataInt16Ptr GetFieldDataInt16Ptr_MACRO +#define GetFieldDataInt16RevPtr GetFieldDataInt16RevPtr_MACRO +#define GetFieldDataBytePtr GetFieldDataBytePtr_MACRO +#define GetFieldData2BytePtr GetFieldData2BytePtr_MACRO +#define GetFieldData4BytePtr GetFieldData4BytePtr_MACRO +#define GetFieldData8BytePtr GetFieldData8BytePtr_MACRO +#define GetFieldDataVoidPtr GetFieldDataVoidPtr_MACRO /*danger:see above*/ +#else +#define GetFieldDataFloatPtr GetFieldDataFloatPtr_FUNC +#define GetFieldDataFloatRevPtr GetFieldDataFloatRevPtr_FUNC +#define GetFieldDataDoublePtr GetFieldDataDoublePtr_FUNC +#define GetFieldDataDoubleRevPtr GetFieldDataDoubleRevPtr_FUNC +#define GetFieldDataInt64Ptr GetFieldDataInt64Ptr_FUNC +#define GetFieldDataInt64RevPtr GetFieldDataInt64RevPtr_FUNC +#define GetFieldDataInt32Ptr GetFieldDataInt32Ptr_FUNC +#define GetFieldDataInt32RevPtr GetFieldDataInt32RevPtr_FUNC +#define GetFieldDataInt16Ptr GetFieldDataInt16Ptr_FUNC +#define GetFieldDataInt16RevPtr GetFieldDataInt16RevPtr_FUNC +#define GetFieldDataBytePtr GetFieldDataBytePtr_FUNC +#define GetFieldData2BytePtr GetFieldData2BytePtr_FUNC +#define GetFieldData4BytePtr GetFieldData4BytePtr_FUNC +#define GetFieldData8BytePtr GetFieldData8BytePtr_FUNC +#define GetFieldDataVoidPtr GetFieldDataVoidPtr_FUNC /*danger:see above*/ +#endif + +#define GetFieldDataFloatPtr_MACRO(FieldData) ((float *)((FieldData)->Data)) +#define GetFieldDataFloatRevPtr_MACRO(FieldData) ((FloatRev_t *)((FieldData)->Data)) +#define GetFieldDataDoublePtr_MACRO(FieldData) ((double *)((FieldData)->Data)) +#define GetFieldDataDoubleRevPtr_MACRO(FieldData) ((DoubleRev_t *)((FieldData)->Data)) +#define GetFieldDataInt64Ptr_MACRO(FieldData) ((Int64_t *)((FieldData)->Data)) +#define GetFieldDataInt64RevPtr_MACRO(FieldData) ((Int64Rev_t *)((FieldData)->Data)) +#define GetFieldDataInt32Ptr_MACRO(FieldData) ((Int32_t *)((FieldData)->Data)) +#define GetFieldDataInt32RevPtr_MACRO(FieldData) ((Int32Rev_t *)((FieldData)->Data)) +#define GetFieldDataInt16Ptr_MACRO(FieldData) ((Int16_t *)((FieldData)->Data)) +#define GetFieldDataInt16RevPtr_MACRO(FieldData) ((Int16Rev_t *)((FieldData)->Data)) +#define GetFieldDataBytePtr_MACRO(FieldData) ((Byte_t *)((FieldData)->Data)) +#define GetFieldData2BytePtr_MACRO(FieldData) ((UInt16_t *)((FieldData)->Data)) +#define GetFieldData4BytePtr_MACRO(FieldData) ((UInt32_t *)((FieldData)->Data)) +#define GetFieldData8BytePtr_MACRO(FieldData) ((UInt64_t *)((FieldData)->Data)) +#define GetFieldDataVoidPtr_MACRO(FieldData) ((void *)((FieldData)->Data)) /*danger:see above*/ + +#if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS +EXTERN float *GetFieldDataFloatPtr_FUNC(FieldData_pa fd); +EXTERN FloatRev_t *GetFieldDataFloatRevPtr_FUNC(FieldData_pa fd); +EXTERN double *GetFieldDataDoublePtr_FUNC(FieldData_pa fd); +EXTERN DoubleRev_t *GetFieldDataDoubleRevPtr_FUNC(FieldData_pa fd); +EXTERN Int64_t *GetFieldDataInt64Ptr_FUNC(FieldData_pa fd); +EXTERN Int64Rev_t *GetFieldDataInt64RevPtr_FUNC(FieldData_pa fd); +EXTERN Int32_t *GetFieldDataInt32Ptr_FUNC(FieldData_pa fd); +EXTERN Int32Rev_t *GetFieldDataInt32RevPtr_FUNC(FieldData_pa fd); +EXTERN Int16_t *GetFieldDataInt16Ptr_FUNC(FieldData_pa fd); +EXTERN Int16Rev_t *GetFieldDataInt16RevPtr_FUNC(FieldData_pa fd); +EXTERN Byte_t *GetFieldDataBytePtr_FUNC(FieldData_pa fd); +EXTERN UInt16_t *GetFieldData2BytePtr_FUNC(FieldData_pa fd); +EXTERN UInt32_t *GetFieldData4BytePtr_FUNC(FieldData_pa fd); +EXTERN UInt64_t *GetFieldData8BytePtr_FUNC(FieldData_pa fd); +EXTERN void *GetFieldDataVoidPtr_FUNC(FieldData_pa fd); /*danger:see above*/ +#endif + +/** + */ +EXTERN FieldData_pa AllocScratchNodalFieldDataPtr(LgIndex_t NumValues, + FieldDataType_e Type, + Boolean_t ShowErrMsg); + +/** + */ +EXTERN void DeallocScratchNodalFieldDataPtr(FieldData_pa *ScratchFieldData); + +/** + * Assume that indexrange has already been converted to the actual indices. + */ +EXTERN void CalcFieldDataMinMaxUsingRange(FieldData_pa field_data, + double *min_ptr, + double *max_ptr, + LgIndex_t startindex, + IndexRange_s *indexrange); + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +/** + */ +EXTERN void CopyTypedValueArray(FieldDataType_e ValueType, + void *DstArray, + LgIndex_t DstStart, + void *SrcArray, + LgIndex_t SrcStart, + LgIndex_t SrcEnd); + +EXTERN void SwapBytesInTypedValueArray(FieldDataType_e ValueType, + void *SrcArray, + LgIndex_t SrcStart, + LgIndex_t SrcEnd, + LgIndex_t SrcSkip); + +EXTERN void SwapBytesInUnalignedTypedValueArray(FieldDataType_e ValueType, + void *SrcArray, + LgIndex_t SrcStart, + LgIndex_t SrcEnd, + LgIndex_t SrcSkip); + + +/* + * Copies values from "src" to "dst". "src" or "dst" may + * be differing types. Either or both may be V3D data pointers. + */ +EXTERN void CopyFieldDataRange(FieldData_pa dst, + LgIndex_t dst_start, + FieldData_pa src, + LgIndex_t src_start, + LgIndex_t src_end); /* -1 means last point */ + +/* + * Copy all values in field data + */ +EXTERN void CopyFieldData(FieldData_pa dst, + FieldData_pa src); + +/* + * Like CopyFieldData except for single value. + */ +EXTERN void CopyFieldValue(FieldData_pa dst, + LgIndex_t dstindex, + FieldData_pa src, + LgIndex_t srcindex); + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +/* + * Sets all values in the field data pointer "field_data" + * to zero. + */ +EXTERN void SetFieldDataPtrToAllZeros(FieldData_pa field_data); + +/* + * GetFieldValue macro + */ +#if !defined GET_FIELD_VALUE_BY_VIRTUAL_FUNCTION && \ + !defined GET_FIELD_VALUE_BY_FLOAT_ONLY_MACRO && \ + !defined GET_FIELD_VALUE_BY_DOUBLE_ONLY_MACRO && \ + !defined GET_FIELD_VALUE_BY_FLOAT_AND_DOUBLE_MACRO +#if !defined NO_ASSERTS || defined DEBUG_FIELDVALUES +#define GET_FIELD_VALUE_BY_VIRTUAL_FUNCTION +#else +#define GET_FIELD_VALUE_BY_FLOAT_AND_DOUBLE_MACRO +#endif +#endif + +#if defined GET_FIELD_VALUE_BY_VIRTUAL_FUNCTION +#define GetFieldValue(fd,pt) ((GetFieldDataGetFunction(fd))((fd),(pt))) +#elif defined GET_FIELD_VALUE_BY_FLOAT_ONLY_MACRO +#define GetFieldValue(fd,pt) (GetFieldDataGetFunction(fd)==GetFieldValueForFloat \ + ?GetFieldDataFloatPtr(fd)[(pt)] \ + :(GetFieldDataGetFunction(fd))((fd),(pt))) +#elif defined GET_FIELD_VALUE_BY_DOUBLE_ONLY_MACRO +#define GetFieldValue(fd,pt) (GetFieldDataGetFunction(fd)==GetFieldValueForDouble \ + ?GetFieldDataDoublePtr(fd)[(pt)] \ + :(GetFieldDataGetFunction(fd))((fd),(pt))) +#elif defined GET_FIELD_VALUE_BY_FLOAT_AND_DOUBLE_MACRO +#define GetFieldValue(fd,pt) (GetFieldDataGetFunction(fd)==GetFieldValueForFloat \ + ?GetFieldDataFloatPtr(fd)[(pt)] \ + :GetFieldDataGetFunction(fd)==GetFieldValueForDouble \ + ?GetFieldDataDoublePtr(fd)[(pt)] \ + :(GetFieldDataGetFunction(fd))((fd),(pt))) +#else +#error "Need to define one of FIELD_VALUE_MACRO constants" +#endif + + +/* + * SetFieldValue macro + */ +#define SetFieldValue(fd,pt,val) ((GetFieldDataSetFunction(fd))((fd),(pt),(val))) + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif /* TECPLOTKERNEL */ + +#if defined _DEBUG +#define USEFUNCTIONSFORNODEVALUES +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if !defined NO_ASSERTS +#endif +#endif /* TECPLOTKERNEL */ + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif /* TECPLOTKERNEL */ + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/DATASHR.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/DATASHR.h new file mode 100644 index 0000000000000000000000000000000000000000..ea8b1d26d20f7f8df627e654f5248d48fac18c5e --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/DATASHR.h @@ -0,0 +1,70 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +#if defined EXTERN +#undef EXTERN +#endif +#if defined DATASHRMODULE +#define EXTERN +#else +#define EXTERN extern +#endif + +/* +***************************************************************** +***************************************************************** +******* ******** +****** Copyright (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +***************************************************************** +***************************************************************** +*/ + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif /* TECPLOTKERNEL */ + +/* + * General set of macros for reference count mananagement. + */ +#define IncStructureReference(V) ((V)->RefCount++) +#define DecStructureReference(V) ((V)->RefCount--) +#define IsStructureShared(V) ((V)->RefCount > 1) +#define IsStructureReferenced(V) ((V)->RefCount > 0) + +/* + * Special set of macros for field data that is having variable sharing between + * zones tracked. Field data maintains two reference counts: The first, + * RefCount, is used to keep track of when the field data needs to be + * deallocated; the second, VarShareRefCount, is used to track variable sharing + * between zones. + */ +#define IncVarStructureReference(V) ((V)->VarShareRefCount++) +#define DecVarStructureReference(V) ((V)->VarShareRefCount--) +#define IsVarStructureShared(V) ((V)->VarShareRefCount > 1) +#define IsVarStructureReferenced(V) ((V)->VarShareRefCount > 0) + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif /* TECPLOTKERNEL */ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/DATAUTIL.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/DATAUTIL.h new file mode 100644 index 0000000000000000000000000000000000000000..cf0195fffc2381dfea21df155b1e7f558d163335 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/DATAUTIL.h @@ -0,0 +1,116 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +/* + * DATAUTIL.h : COPYRIGHT (C)1987-2002 Tecplot, Inc. + * ALL RIGHTS RESERVED + * + * NOTE: THIS MODULE NOW IS PART OF THE TECPLOT SOURCE + * ONLY EDIT THIS IN THE MAIN TECPLOT SOURCE DIRECTORY. + * + * + */ +#ifndef DATAUTIL_H +#define DATAUTIL_H +#define DATAUTIL_VERSION 61 + +#if defined MAKEARCHIVE +extern void InitInputSpecs(void); +#endif + + +/* + * + * Read a binary tecplot datafile. + * + * @param GetHeaderInfoOnly + * Return only the header info from the datafile. + * + * @param FName + * Name of the file to read. + * + * @param IVersion + * Returns version of the input file. + * + * @param DataSetTitle + * Allocates space for and returns dataset title. + * + * @param NumZones + * Returns the number of zones. + * + * @param NumVars + * Returns the number of variables. + * + * @param VarNames + * Allocates space for and returns the var names. + * + * @param ZoneNames + * Allocates space for and returns the zone names. + * + * @param NumPtsI, NumPtsJ, NumPtsK + * Zone dimensions loaded into LgIndex_t arrays. + * + * @param ZoneNames + * Zone types loaded into ZoneType_e array. + * + * @param UserRec + * Allocates space for and returns the user records. + * + * @param RawDataspaceAllocated + * Only used if GetHeaderInfoOnly is FALSE. TRUE = calling program has alloced space for + * the raw data. FALSE= let ReadTec allocate space for the raw data. + * + * @param NodeMap + * Finite Element connectivity information. ReadTec + * will allocate the space for you if RawDataspaceAllocated is FALSE. + * + * @param VDataBase + * Raw field data loaded into double arrays. ReadTec + * will allocate the space for you if RawDataspaceAllocated is + * FALSE. If RawDataspaceAllocated is TRUE then ReadTec will + * only load the arrays that have non NULL addresses. + * + */ +LIBFUNCTION Boolean_t STDCALL ReadTec(Boolean_t GetHeaderInfoOnly, + char *FName, + short *IVersion, + char **DataSetTitle, + EntIndex_t *NumZones, + EntIndex_t *NumVars, + StringList_pa *VarNames, + StringList_pa *ZoneNames, + LgIndex_t **NumPtsI, + LgIndex_t **NumPtsJ, + LgIndex_t **NumPtsK, + ZoneType_e **ZoneType, + StringList_pa *UserRec, + Boolean_t RawDataspaceAllocated, + NodeMap_t ***NodeMap, + double ***VDataBase); + +LIBFUNCTION void * STDCALL TecAlloc(size_t size); + +LIBFUNCTION void STDCALL TecFree(void *ptr); + + +#endif /* !DATAUTIL_H */ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/FACE.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/FACE.h new file mode 100644 index 0000000000000000000000000000000000000000..c0c89a9b432872f32760eb47191dc162c18af7df --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/FACE.h @@ -0,0 +1,149 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +/* +****************************************************************** +****************************************************************** +******* ******** +****** (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +****************************************************************** +****************************************************************** +*/ +#ifndef _FACE_H_ +#define _FACE_H_ + +#if defined EXTERN +#undef EXTERN +#endif +#if defined FACEMODULE +#define EXTERN +#else +#define EXTERN extern +#endif + +namespace tecplot +{ +namespace kernel +{ +class SubElemValueProducerInterface; +} +} + + +/** + */ +inline Boolean_t IsCellFaceLogicallyCollapsed(LgIndex_t I1, + LgIndex_t I2, + LgIndex_t I3, + LgIndex_t I4) +{ + return ((I1 == I2 && I3 == I4) || + (I1 == I4 && I2 == I3) || + (I1 == I3) || + (I2 == I4)); +} + +/** + * IMPORTANT NOTE: + * A face obscuration of FaceObscuration_LogicallyObscured means that the + * face is entirely obscured by either an implicit neighbor for inside faces + * of ordered data or an auto generated neighbor for finite element data. In + * either case, logical obscuration is not considered if user defined + * neighbors have been specified for the face. Therefore, interior faces of + * ordered data can have an indication of FaceObscuration_PartiallyObscured. + */ +typedef enum +{ + FaceObscuration_NotObscured, + FaceObscuration_PartiallyObscured, + FaceObscuration_EntirelyObscured, + FaceObscuration_LogicallyObscured, + END_FaceObscuration_e, + FaceObscuration_Invalid = BadEnumValue +} FaceObscuration_e; + +/** + */ +EXTERN LgIndex_t GetLogicalOrderedNeighbor(LgIndex_t NumIPts, + LgIndex_t NumJPts, + LgIndex_t NumKPts, + LgIndex_t Element, + LgIndex_t Face); + +/** + * Function to determine a cell's neighbor. It calls FaceNeighborGetSurfaceCellNeighbor() + * for classic zones. + */ +EXTERN void GetSurfaceCellNeighbor(CZInfo_s const* CZInfo, + CZData_s const* CZData, + LgIndex_t SurfaceCellIndex, + tecplot::kernel::SubElemValueProducerInterface* NodeValueProducer, + ElemFaceOffset_t PlaneOrFaceOffset, + ElemFaceOffset_t Edge, + LgIndex_t* NeighborSurfaceCellElem, + EntIndex_t* NeighborSurfaceCellZone); +/** + */ +EXTERN FaceObscuration_e GetFaceObscuration(CZInfo_s const* CZInfo, + CZData_s const* CZData, + Set_pa ActiveRelevantZones, + LgIndex_t Element, + LgIndex_t FOffset, + Boolean_t ConsiderValueBlanking, + Boolean_t ConsiderIJKBlanking, + Boolean_t ConsiderDepthBlanking); + +EXTERN EntIndex_t GetNodesPerElementFace(ZoneType_e ZoneType); + +EXTERN EntIndex_t GetFacesPerElement(ZoneType_e ZoneType, + LgIndex_t IMax, + LgIndex_t JMax, + LgIndex_t KMax); + +EXTERN CollapsedStatus_e GetSurfaceCellCollapsedStatus(CZInfo_s const* CZInfo, + CZData_s const* CZData, + tecplot::kernel::SubElemValueProducerInterface* SubElemValueProducer); +EXTERN CollapsedStatus_e GetSurfaceCellCollapsedStatus(CZInfo_s const* CZInfo, + CZData_s const* CZData, + LgIndex_t I1, + LgIndex_t I2, + LgIndex_t I3, + LgIndex_t I4); +EXTERN CollapsedStatus_e GetSurfaceCellLogicalCollapsedStatus(ZoneType_e ZoneType, + LgIndex_t I1, + LgIndex_t I2, + LgIndex_t I3, + LgIndex_t I4); +EXTERN CollapsedStatus_e GetSurfEdgeOrVolFaceLogicalCollapsedStatus(NodeMap_pa NodeMap, + LgIndex_t Element, + EntIndex_t Face); +#if defined ALLOW_USERDEF_NO_NEIGHBORING_ELEMENT +/** + */ +EXTERN Boolean_t IsUserDefFaceNeighborBoundary(FaceNeighbor_pa FaceNeighbor, + LgIndex_t Element, + LgIndex_t Face); +#endif + +#endif diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/FILESTREAM.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/FILESTREAM.h new file mode 100644 index 0000000000000000000000000000000000000000..edb10ce253204c3b8b8390df395b058ff5300246 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/FILESTREAM.h @@ -0,0 +1,75 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +/* + ***************************************************************** + ***************************************************************** + ******* ******** + ****** Copyright (C) 1988-2008 Tecplot, Inc. ******* + ******* ******** + ***************************************************************** + ***************************************************************** +*/ +#if !defined FILESTREAM_h +#define FILESTREAM_h + +#if defined EXTERN +# undef EXTERN +#endif +#if defined FILESTREAMMODULE +# define EXTERN +#else +# define EXTERN extern +#endif + +typedef struct +{ + FILE *File; + Boolean_t IsByteOrderNative; +} FileStream_s; + +/** + * Creates a structure for associating an open file stream with its byte + * order. The byte order can changed at any time. + * + * @param File + * Handle to a file which can be NULL. + * @param IsByteOrderNative + * TRUE if the file's byte order is native, FALSE if foreign. + * + * @return + * An allocated structure associating an open file to its byte order. + */ +EXTERN FileStream_s *FileStreamAlloc(FILE *File, + Boolean_t IsByteOrderNative); + +/** + * Deallocates the structure associating the file stream with the byte order. + * This function does NOT close the file. + * + * @param FileStream + * Pointer to an open file stream or a pointer to NULL. + */ +EXTERN void FileStreamDealloc(FileStream_s **FileStream); + +#endif diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/GEOM.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/GEOM.h new file mode 100644 index 0000000000000000000000000000000000000000..092b92dfd2d993fffc0f100936de22bf87651182 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/GEOM.h @@ -0,0 +1,71 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +/* +***************************************************************** +***************************************************************** +******* ******** +****** Copyright (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +***************************************************************** +***************************************************************** +*/ + +#if defined EXTERN +#undef EXTERN +#endif +#if defined GEOMMODULE +#define EXTERN +#else +#define EXTERN extern +#endif + + +/* * macros for checking CoordSys_e * */ +#define VALID_RECTANGLE_COORDSYS(sys) \ + (((sys)==CoordSys_Frame) || \ + ((sys)==CoordSys_Grid)) +#define VALID_SQUARE_COORDSYS(sys) VALID_RECTANGLE_COORDSYS((sys)) +#define VALID_ELLIPSE_COORDSYS(sys) VALID_RECTANGLE_COORDSYS((sys)) +#define VALID_CIRCLE_COORDSYS(sys) VALID_ELLIPSE_COORDSYS((sys)) +#define VALID_IMAGE_COORDSYS(sys) VALID_RECTANGLE_COORDSYS((sys)) +#define VALID_LINESEG_COORDSYS(sys) \ + (((sys)==CoordSys_Frame) || \ + ((sys)==CoordSys_Grid) || \ + ((sys)==CoordSys_Grid3D)) +#define VALID_GEOM_COORDSYS(sys) \ + (((sys)==CoordSys_Frame) || \ + ((sys)==CoordSys_Grid) || \ + ((sys)==CoordSys_Grid3D)) + +#define VALID_GEOM_TYPE(geomtype) \ + ( VALID_ENUM((geomtype),GeomType_e) && \ + (geomtype)!=GeomType_LineSegs3D ) + +#define VALID_GEOM_FIELD_DATA_TYPE(datatype) \ + ( ( (datatype) == FieldDataType_Float ) || \ + ( (datatype) == FieldDataType_Double ) ) + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif /* TECPLOTKERNEL */ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/GEOM2.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/GEOM2.h new file mode 100644 index 0000000000000000000000000000000000000000..9dcd68acbacfbd647566fd1e41837b73f698294f --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/GEOM2.h @@ -0,0 +1,46 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +/* +***************************************************************** +***************************************************************** +******* ******** +****** Copyright (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +***************************************************************** +***************************************************************** +*/ +#if defined EXTERN +#undef EXTERN +#endif +#if defined GEOM2MODULE +#define EXTERN +#else +#define EXTERN extern +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif /* TECPLOTKERNEL */ + +EXTERN FieldDataType_e GetGeomFieldDataType(Geom_s const* Geom); diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/GLOBAL.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/GLOBAL.h new file mode 100644 index 0000000000000000000000000000000000000000..21e35a947c20131cee3a77b1294ad7fdd9d39c7c --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/GLOBAL.h @@ -0,0 +1,7271 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +/* BEGINREMOVEFROMADDON */ +/* NOTE: All code contained between comments that look like + * BEGINREMOVEFROMADDON + * ENDREMOVEFROMADDON + * are pulled out to create the GLOBAL.h file used in addons. + */ +/* ENDREMOVEFROMADDON */ + +/* +****************************************************************** +****************************************************************** +******* ******** +****** (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +****************************************************************** +****************************************************************** +*/ + +#ifndef _GLOBAL_H +#define _GLOBAL_H + +#if defined EXTERN +#undef EXTERN +#endif +#if defined Q_MAINMODULE && defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#else +#define EXTERN extern +#endif + +#define EXPORT_DEPRECATED_INTERFACES_TO_ADK_ONLY +/* BEGINREMOVEFROMADDON */ +/* + * The reason for wrapping this test with "begin and end remove from addon" key + * words is so that the ADK users doesn't have to see this mess. + */ +#if !defined COREAPI && \ + !defined TECUTILMMODULE && \ + !defined TECUTILOMODULE && \ + !defined TECUTILQMODULE && \ + !defined TECUTILSMODULE +/* we don't want Tecplot internals using deprecated interfaces */ +# undef EXPORT_DEPRECATED_INTERFACES_TO_ADK_ONLY +#endif +/* ENDREMOVEFROMADDON */ + + +/**************************************************************** + * * + * MACROS * + * * + ****************************************************************/ +#if defined TRUE +#undef TRUE +#endif +#if defined FALSE +#undef FALSE +#endif +#if defined MIN +#undef MIN +#endif +#if defined MAX +#undef MAX +#endif +#if defined ROUND +#undef ROUND +#endif +#if defined ROUND2 +#undef ROUND2 +#endif +#if defined TRUNC +#undef TRUNC +#endif + +#define TRUE ((Boolean_t)1) +#define FALSE ((Boolean_t)0) + +/**************************************************************** + * * + * MACROS * + * * + ****************************************************************/ +#define ABS(X) ((X) >= 0 ? (X) : -(X) ) +#define MAX(X,Y) ((X) > (Y) ? (X) : (Y) ) +#define MIN(X,Y) ((X) < (Y) ? (X) : (Y) ) +#define BESTSHOWCOLOR(X) ((X) == White_C ? Black_C : White_C) +#define ROUND_TO_BYTE(X) ((BYTE)((X)+0.499)) +#define ROUNDS(X) ((short)((X)+0.499)) +#define ROUNDL(X) ((LgIndex_t)((X)+0.499)) +#define ROUND2(X) ((X) >= 0 ? ((int)((X)+0.499)) : ((int)((X)-0.499))) +#define TRUNC(X) ((short) (X)) +#define RAD_TO_DEG(rad) (180.*(rad)/PI) +#define DEG_TO_RAD(deg) (PI*(deg)/180.) + +# define CAPITAL(C) ( ('a'<=(C)&&(C)<='z') ? ((C)+('A'-'a')) : (C) ) /* okay for UNICODE */ + +#include "TASSERT.h" + +#if defined TECPLOTKERNEL && defined MSWIN +/* CORE SOURCE CODE REMOVED */ +#else +#define ISEMPTYSTRING(S) ( ((const char*)(S))[0] == '\0' ) +#endif + +#define ISWHITESPACE(C) ((C == ' ') || (C == '\t') || (C == '\n')) +#define ISSEPARATOR(C) ((C == ' ') || (C == '\t') || (C == ',')) +/* clamp the input to the specified range */ +#define CLAMP(value,low,high) ((value)<(low) ? (low) : (value) > (high) ? (high) : (value)) +/* integer division rounds any fraction up (for example n=16,d=3 results in 6) */ +#define INTEGER_DIVIDE_AND_ROUND_UP(n, d) (((int)(n)+(int)(d)-1)/(int)(d)) + +/* BEGINREMOVEFROMADDON */ +/** + * Calcualtes the cell's primary corner or cell centered index from the I, J, + * and K indices. + * + * Consider this IJ zone dimensioned 4 by 3: + * @verbatim + +-------+-------+-------+-------+ + | | | | | + | <8> | <9> | <10> | <11> | <--- ghost cells + | | | | | + |8 |9 |10 |11 | + +-------+-------+-------+-------+ + | | | | | + | <4> | <5> | <6> | <7> | + | | | | | + |4 |5 |6 |7 | + +-------+-------+-------+-------+ + | | | | | + | <0> | <1> | <2> | <3> | + | | | | | + |0 |1 |2 |3 | + +-------+-------+-------+-------+ + . + /|\ + | + | + ghost cells +@endverbatim + */ +#define IJKINDEX(CZData,I,J,K) ((I) + \ + ((J)*(CZData)->NumIPts) + \ + ((K)*(CZData)->NumIJPts)) + +/** + * Calculates the I indice from the cell's primary corner or cell centered + * index. See IJKINDEX() for a picture. + */ +#define IINDEX(CZData,N) ((N) % (CZData)->NumIPts) + +/** + * Calculates the J indice from the cell's primary corner or cell centered + * index. See IJKINDEX() for a picture. + */ +#define JINDEX(CZData,N) (((N) % (CZData)->NumIJPts)/(CZData)->NumIPts) + +/** + * Calculates the K indice from the cell's primary corner or cell centered + * index. See IJKINDEX() for a picture. + */ +#define KINDEX(CZData,N) ((N)/(CZData)->NumIJPts) +/* ENDREMOVEFROMADDON */ + +/* */ +#define SWITCH(Type,A,B) do {Type T = (A); (A) = (B); (B) = T;} while (FALSE) +#define SWITCH_DOUBLES(A,B) SWITCH(double, (A), (B)) +#define FPRINTFOK(x) (Boolean_t)((x) > 0) +#define GRAPHICSARE3D(F) ((F->PlotType == PlotType_Cartesian3D)) + +/* convenience macros for implication, P -> Q, and equivalence, P <-> Q. */ +#define IMPLICATION(P,Q) (!(P) || (Q)) +#define EQUIVALENCE(P,Q) ((P) == (Q)) + +/* suppress compiler warnings about unused parameters */ +#if defined UNUSED +#undef UNUSED +#endif +#define UNUSED(param) (void)param + +/** + * Converts a double into a float value + * + * param val + * double value to be converted + */ +#define CONVERT_DOUBLE_TO_FLOAT(val) \ + ( (val) >= SMALLFLOAT \ + ? ( (val) < LARGEFLOAT \ + ? (float)(val) \ + : (float)LARGEFLOAT \ + ) \ + : ( (val) <= -SMALLFLOAT \ + ? ( (val) > -LARGEFLOAT \ + ? (float)(val) \ + : (float)-LARGEFLOAT \ + ) \ + : (float)0.0 \ + ) \ + ) + + +/** + * Clamps a double at the limits of Tecplot's precision + * + * param val + * double value to be clamped + */ +#define CLAMP_DOUBLE(val) \ + ( (val) >= SMALLDOUBLE \ + ? ( (val) < LARGEDOUBLE \ + ? (double)(val) \ + : (double)LARGEDOUBLE \ + ) \ + : ( (val) <= -SMALLDOUBLE \ + ? ( (val) > -LARGEDOUBLE \ + ? (double)(val) \ + : (double)-LARGEDOUBLE \ + ) \ + : (double)0.0 \ + ) \ + ) + + +/** + * Converts a double into a 4-byte (signed) integer value + * + * param val + * double value to be converted + */ +#define CONVERT_DOUBLE_TO_INT32(val) \ + ( (val) >= 1.0 \ + ? ( (val) < MAXINT32 \ + ? (Int32_t)(val) \ + : (Int32_t)MAXINT32 \ + ) \ + : ( (val) <= -1.0 \ + ? ( (val) > (Int32_t)-MAXINT32 \ + ? (Int32_t)(val) \ + : (Int32_t)-MAXINT32 \ + ) \ + : (Int32_t)0.0 \ + ) \ + ) + + +/** + * Converts a double into a 2-byte (signed) integer value + * + * param val + * double value to be converted + */ +#define CONVERT_DOUBLE_TO_INT16(val) \ + ( (val) >= 1.0 \ + ? ( (val) < MAXINT16 \ + ? (Int16_t)(val) \ + : (Int16_t)MAXINT16 \ + ) \ + : ( (val) <= -1.0 \ + ? ( (val) > (Int16_t)-MAXINT16 \ + ? (Int16_t)(val) \ + : (Int16_t)-MAXINT16 \ + ) \ + : (Int16_t)0.0 \ + ) \ + ) + +/** + * Copies two bytes from SrcBuffer to DstBuffer without causing a page + * fault due to misaligned words. + * + * param DstBuffer + * Pointer the buffer to send the two bytes to + * param SrcBuffer + * Pointer the buffer to get the two bytes from + */ +#define COPY_2_UNALIGNED_BYTES(DstBuffer, SrcBuffer) \ + do { \ + /* cannot check sizeof(SrcBuffer) or sizeof(DstBuffer) because they are */ \ + /* most likely single byte pointers into unaligned blocks of data */ \ + ((Byte_t *)(DstBuffer))[0] = ((Byte_t *)(SrcBuffer))[0]; \ + ((Byte_t *)(DstBuffer))[1] = ((Byte_t *)(SrcBuffer))[1]; \ + } while (FALSE) + +/** + * Copies two bytes from SrcBuffer to DstBuffer swapping the bytes + * as it copies. Will not cause a page fault due to misaligned words. + * + * param DstBuffer + * Pointer the buffer to send the two bytes to + * param SrcBuffer + * Pointer the buffer to get the two bytes from + */ +#define COPY_AND_REVERSE_2_UNALIGNED_BYTES(DstBuffer, SrcBuffer) \ + do { \ + /* cannot check sizeof(SrcBuffer) or sizeof(DstBuffer) because they are */ \ + /* most likely single byte pointers into unaligned blocks of data */ \ + ((Byte_t *)(DstBuffer))[0] = ((Byte_t *)(SrcBuffer))[1]; \ + ((Byte_t *)(DstBuffer))[1] = ((Byte_t *)(SrcBuffer))[0]; \ + } while (FALSE) + +/** + * Copies four bytes from SrcBuffer to DstBuffer without causing a page + * fault due to misaligned words. + * + * param DstBuffer + * Pointer the buffer to send the four bytes to + * param SrcBuffer + * Pointer the buffer to get the four bytes from + */ +#define COPY_4_UNALIGNED_BYTES(DstBuffer, SrcBuffer) \ + do { \ + /* cannot check sizeof(SrcBuffer) or sizeof(DstBuffer) because they are */ \ + /* most likely single byte pointers into unaligned blocks of data */ \ + ((Byte_t *)(DstBuffer))[0] = ((Byte_t *)(SrcBuffer))[0]; \ + ((Byte_t *)(DstBuffer))[1] = ((Byte_t *)(SrcBuffer))[1]; \ + ((Byte_t *)(DstBuffer))[2] = ((Byte_t *)(SrcBuffer))[2]; \ + ((Byte_t *)(DstBuffer))[3] = ((Byte_t *)(SrcBuffer))[3]; \ + } while (FALSE) + +/** + * Copies four bytes from SrcBuffer to DstBuffer swapping the bytes + * as it copies. Will not cause a page fault due to misaligned words. + * + * param DstBuffer + * Pointer the buffer to send the four bytes to + * param SrcBuffer + * Pointer the buffer to get the four bytes from + */ +#define COPY_AND_REVERSE_4_UNALIGNED_BYTES(DstBuffer, SrcBuffer) \ + do { \ + /* cannot check sizeof(SrcBuffer) or sizeof(DstBuffer) because they are */ \ + /* most likely single byte pointers into unaligned blocks of data */ \ + ((Byte_t *)(DstBuffer))[0] = ((Byte_t *)(SrcBuffer))[3]; \ + ((Byte_t *)(DstBuffer))[1] = ((Byte_t *)(SrcBuffer))[2]; \ + ((Byte_t *)(DstBuffer))[2] = ((Byte_t *)(SrcBuffer))[1]; \ + ((Byte_t *)(DstBuffer))[3] = ((Byte_t *)(SrcBuffer))[0]; \ + } while (FALSE) + +/** + * Copies four bytes from SrcBuffer to DstBuffer without causing a page + * fault due to misaligned words. + * + * param DstBuffer + * Pointer the buffer to send the four bytes to + * param SrcBuffer + * Pointer the buffer to get the four bytes from + */ +#define COPY_8_UNALIGNED_BYTES(DstBuffer, SrcBuffer) \ + do { \ + /* cannot check sizeof(SrcBuffer) or sizeof(DstBuffer) because they are */ \ + /* most likely single byte pointers into unaligned blocks of data */ \ + ((Byte_t *)(DstBuffer))[0] = ((Byte_t *)(SrcBuffer))[0]; \ + ((Byte_t *)(DstBuffer))[1] = ((Byte_t *)(SrcBuffer))[1]; \ + ((Byte_t *)(DstBuffer))[2] = ((Byte_t *)(SrcBuffer))[2]; \ + ((Byte_t *)(DstBuffer))[3] = ((Byte_t *)(SrcBuffer))[3]; \ + ((Byte_t *)(DstBuffer))[4] = ((Byte_t *)(SrcBuffer))[4]; \ + ((Byte_t *)(DstBuffer))[5] = ((Byte_t *)(SrcBuffer))[5]; \ + ((Byte_t *)(DstBuffer))[6] = ((Byte_t *)(SrcBuffer))[6]; \ + ((Byte_t *)(DstBuffer))[7] = ((Byte_t *)(SrcBuffer))[7]; \ + } while (FALSE) + +/** + * Copies eight bytes from SrcBuffer to DstBuffer swapping the bytes + * as it copies. Will not cause a page fault due to misaligned words. + * + * param DstBuffer + * Pointer the buffer to send the four bytes to + * param SrcBuffer + * Pointer the buffer to get the four bytes from + */ +#define COPY_AND_REVERSE_8_UNALIGNED_BYTES(DstBuffer, SrcBuffer) \ + do { \ + /* cannot check sizeof(SrcBuffer) or sizeof(DstBuffer) because they are */ \ + /* most likely single byte pointers into unaligned blocks of data */ \ + ((Byte_t *)(DstBuffer))[0] = ((Byte_t *)(SrcBuffer))[7]; \ + ((Byte_t *)(DstBuffer))[1] = ((Byte_t *)(SrcBuffer))[6]; \ + ((Byte_t *)(DstBuffer))[2] = ((Byte_t *)(SrcBuffer))[5]; \ + ((Byte_t *)(DstBuffer))[3] = ((Byte_t *)(SrcBuffer))[4]; \ + ((Byte_t *)(DstBuffer))[4] = ((Byte_t *)(SrcBuffer))[3]; \ + ((Byte_t *)(DstBuffer))[5] = ((Byte_t *)(SrcBuffer))[2]; \ + ((Byte_t *)(DstBuffer))[6] = ((Byte_t *)(SrcBuffer))[1]; \ + ((Byte_t *)(DstBuffer))[7] = ((Byte_t *)(SrcBuffer))[0]; \ + } while (FALSE) + +/** + * Reverses the byte order of the specified 2 byte buffer. + * + * param Buffer + * Pointer to the 2 bytes needing byte order reversal. + */ +#define REVERSE_2_BYTES_1_AT_A_TIME(Buffer) \ + do { \ + Byte_t Byte0 = ((Byte_t *)(Buffer))[0]; \ + CHECK(sizeof(*(Buffer))==1 || sizeof(*(Buffer))==2); \ + ((Byte_t *)(Buffer))[0] = ((Byte_t *)(Buffer))[1]; \ + ((Byte_t *)(Buffer))[1] = Byte0; \ + } while (FALSE) + +#define REVERSE_2_BYTES_2_AT_A_TIME(Buffer) \ + do { \ + UInt16_t data_bits = ((UInt16_t *)(Buffer))[0]; \ + CHECK(sizeof(*(Buffer))==1 || sizeof(*(Buffer))==2); \ + ((UInt16_t *)(Buffer))[0] = (((data_bits)<<8) | \ + ((data_bits&0xff))); \ + } while (FALSE) + +/* REVERSE_2_BYTES_2_AT_A_TIME may actually be slower, needs testing. */ +#define REVERSE_2_BYTES REVERSE_2_BYTES_1_AT_A_TIME + +/** + * Reverses the byte order of the specified 4 byte buffer. + * + * param Buffer + * Pointer to the 4 bytes needing byte order reversal. + * + * How this works: + * + * ABCD + * D--- <<24 (1) + * + * ABCD + * --C- &0x0000ff00 + * -C-- <<8 (2) + * + * ABCD + * -B-- &0x00ff0000 + * --B- >>8 (3) + * + * ABCD + * ---A >>24 (4) + * + * (1) | (2) | (3) | (4) = DCBA. + * + */ +#define REVERSE_4_BYTES_1_AT_A_TIME(Buffer) \ + do { \ + Byte_t Byte0 = ((Byte_t *)(Buffer))[0]; \ + Byte_t Byte1 = ((Byte_t *)(Buffer))[1]; \ + CHECK(sizeof(*(Buffer))==1 || sizeof(*(Buffer))==4); \ + ((Byte_t *)(Buffer))[0] = ((Byte_t *)(Buffer))[3]; \ + ((Byte_t *)(Buffer))[1] = ((Byte_t *)(Buffer))[2]; \ + ((Byte_t *)(Buffer))[2] = Byte1; \ + ((Byte_t *)(Buffer))[3] = Byte0; \ + } while (FALSE) + +#define REVERSE_4_BYTES_4_AT_A_TIME(Buffer) \ + do { \ + UInt32_t data_bits = *((UInt32_t *)(Buffer)); \ + CHECK(sizeof(*(Buffer))==1 || sizeof(*(Buffer))==4); \ + *((UInt32_t *)(Buffer)) = (((data_bits)<<24) | \ + ((data_bits&0x0000ff00)<<8) | \ + ((data_bits&0x00ff0000)>>8) | \ + ((data_bits)>>24)); \ + } while (FALSE) + +#if defined MSWIN +/* + * The DevStuido compiler seems to be the only one that can truly handle this + * when optimization is turned on. + */ +#define REVERSE_4_BYTES REVERSE_4_BYTES_4_AT_A_TIME +#else +#define REVERSE_4_BYTES REVERSE_4_BYTES_1_AT_A_TIME +#endif + +/** + * Reverses the byte order of the specified 8 byte buffer. + * + * param Buffer + * Pointer to the 8 bytes needing byte order reversal. + */ +#define REVERSE_8_BYTES_1_AT_A_TIME(Buffer) \ + do { \ + Byte_t Byte0 = ((Byte_t *)(Buffer))[0]; \ + Byte_t Byte1 = ((Byte_t *)(Buffer))[1]; \ + Byte_t Byte2 = ((Byte_t *)(Buffer))[2]; \ + Byte_t Byte3 = ((Byte_t *)(Buffer))[3]; \ + CHECK(sizeof(*(Buffer))==1 || sizeof(*(Buffer))==8); \ + ((Byte_t *)(Buffer))[0] = ((Byte_t *)(Buffer))[7]; \ + ((Byte_t *)(Buffer))[1] = ((Byte_t *)(Buffer))[6]; \ + ((Byte_t *)(Buffer))[2] = ((Byte_t *)(Buffer))[5]; \ + ((Byte_t *)(Buffer))[3] = ((Byte_t *)(Buffer))[4]; \ + ((Byte_t *)(Buffer))[4] = Byte3; \ + ((Byte_t *)(Buffer))[5] = Byte2; \ + ((Byte_t *)(Buffer))[6] = Byte1; \ + ((Byte_t *)(Buffer))[7] = Byte0; \ + } while (FALSE) + +#define REVERSE_8_BYTES_2_AT_A_TIME(Buffer) \ + do { \ + UInt16_t data_bits_0 = ((UInt16_t *)(Buffer))[0]; \ + UInt16_t data_bits_1 = ((UInt16_t *)(Buffer))[1]; \ + UInt16_t data_bits_2 = ((UInt16_t *)(Buffer))[2]; \ + UInt16_t data_bits_3 = ((UInt16_t *)(Buffer))[3]; \ + CHECK(sizeof(*(Buffer))==1 || sizeof(*(Buffer))==8); \ + ((UInt16_t *)(Buffer))[0] = (((data_bits_3)<<8) | \ + ((data_bits_3&0xff))); \ + ((UInt16_t *)(Buffer))[1] = (((data_bits_2)<<8) | \ + ((data_bits_2&0xff))); \ + ((UInt16_t *)(Buffer))[2] = (((data_bits_1)<<8) | \ + ((data_bits_1&0xff))); \ + ((UInt16_t *)(Buffer))[3] = (((data_bits_0)<<8) | \ + ((data_bits_0&0xff))); \ + } while (FALSE) + +#define REVERSE_8_BYTES_4_AT_A_TIME(Buffer) \ + do { \ + UInt32_t data_bits_0 = ((UInt32_t *)(Buffer))[0]; \ + UInt32_t data_bits_1 = ((UInt32_t *)(Buffer))[1]; \ + CHECK(sizeof(*(Buffer))==1 || sizeof(*(Buffer))==8); \ + ((UInt32_t *)(Buffer))[0] = (((data_bits_1)<<24) | \ + ((data_bits_1&0x0000ff00)<<8) | \ + ((data_bits_1&0x00ff0000)>>8) | \ + ((data_bits_1)>>24)); \ + ((UInt32_t *)(Buffer))[1] = (((data_bits_0)<<24) | \ + ((data_bits_0&0x0000ff00)<<8) | \ + ((data_bits_0&0x00ff0000)>>8) | \ + ((data_bits_0)>>24)); \ + } while (FALSE) + +#define REVERSE_8_BYTES_8_AT_A_TIME(Buffer) \ + do { \ + UInt64_t data_bits = *((UInt64_t *)(Buffer)); \ + CHECK(sizeof(*(Buffer))==1 || sizeof(*(Buffer))==8); \ + *((UInt64_t *)(Buffer)) = (((data_bits)<<56) | \ + ((data_bits&0x000000000000ff00)<<40) | \ + ((data_bits&0x0000000000ff0000)<<24) | \ + ((data_bits&0x00000000ff000000)<<8) | \ + ((data_bits&0x000000ff00000000)>>8) | \ + ((data_bits&0x0000ff0000000000)>>24) | \ + ((data_bits&0x00ff000000000000)>>40) | \ + ((data_bits)>>56)); \ + } while (FALSE) + + +#if defined MSWIN +/* + * The DevStuido compiler seems to be the only one that can truly handle this + * when optimization is turned on. + */ +#define REVERSE_8_BYTES REVERSE_8_BYTES_4_AT_A_TIME +#else +#define REVERSE_8_BYTES REVERSE_8_BYTES_1_AT_A_TIME +#endif + + +/**************************************************************** + * * + * ADD-ON MSWIN IMPORT/EXPORT DEFINITIONS * + * * + ****************************************************************/ +#if defined MSWIN +# define STDCALL __stdcall +#else +# define STDCALL +#endif /* MSWIN */ + +#if defined (__cplusplus) +# define EXTERNC extern "C" +#else +# define EXTERNC +#endif /* __cplusplus */ + +#if defined MSWIN +#if defined AMTEC_INTERNAL_MAKELIBTEC || defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# else +# define TECPLOT_DLLAPI _declspec ( dllimport ) +# endif +#else +# define TECPLOT_DLLAPI +#endif + +#define LINKTOADDON EXTERNC TECPLOT_DLLAPI + + +/* + * + * Usage: + * EXPORTFROMADDON void STDCALL InitTecAddOn(void) { ... } + * + */ +#if defined MSWIN +# define EXPORTFROMADDON EXTERNC _declspec ( dllexport ) +#else +# define EXPORTFROMADDON EXTERNC +#endif /* MSWIN */ + +#define EXPORTFROMDLL EXPORTFROMADDON + +#define InitTecAddOn InitTecAddOn113 +#define TEC_INIT_FUNCTION_NAME "InitTecAddOn113" + +/* BEGINREMOVEFROMADDON */ +/* Use INLINE for static functions that could be optimized as inline. */ +#if defined (__cplusplus) && !defined _DEBUG +# define INLINE inline +#else +# define INLINE static +#endif /* __cplusplus */ +/* ENDREMOVEFROMADDON */ + + +/* BEGINREMOVEFROMADDON */ +#if defined (MSWIN) ||\ + defined (INTERX) ||\ + defined (LINUX) ||\ + defined (SUNSOLARIS86X) ||\ + defined (COMPAQALPHA) ||\ + defined (DEC) ||\ + defined (__LITTLE_ENDIAN__) +#define MACHINE_DOES_INTEL_ORDER +#endif + +#if defined( MACHINE_DOES_INTEL_ORDER ) +# define SwapBytes(IntelOrder) (!(IntelOrder)) +#else +# define SwapBytes(IntelOrder) (IntelOrder) +#endif +/* ENDREMOVEFROMADDON */ + +#if defined DECALPHA || \ + defined LINUXALPHA || \ + defined LINUXI64 || \ + defined LINUX64 || \ + defined MAC64 || \ + defined COMPAQALPHA +#define LONGIS64 +#endif + +/**************************************************************** + * * + * HARD CONSTANTS * + * * + ****************************************************************/ +#define LARGEMEMORY ((size_t)-1) + +/* BEGINREMOVEFROMADDON */ +/* Tclinterp add-on barfs on these huge integer constants */ +/* Note: Tecplot is conservative by one on LARGEINTs max */ +#define LARGEINT64 9223372036854775806LL +/* ENDREMOVEFROMADDON */ +#define LARGEINT32 2147483646 +#define LARGEINT16 32766 +#define LARGEINT8 126 + +/* BEGINREMOVEFROMADDON */ +#define LARGEUINT64 18446744073709551614ULL +/* ENDREMOVEFROMADDON */ +#define LARGEUINT32 4294967294 +#define LARGEUINT16 65534 +#define LARGEUINT8 254 + +#ifdef INDEX_16_BIT +#define MAXINDEX ((LgIndex_t)LARGEINT16) +#else +#define MAXINDEX ((LgIndex_t)LARGEINT32) +#endif +#define MAXZONEMAP MAXINDEX +#define LARGEDOUBLE 1.0e+150 +#define SMALLDOUBLE 1.0e-150 +#define LARGESTEXPONENT 150 +#define SMALLESTEXPONENT -150 + +#define SMALLESTDOUBLE SMALLDOUBLE + +#define LARGESTDOUBLEEXPONENT 308 +#define SMALLESTDOUBLEEXPONENT -307 +#define LARGESTDOUBLE 1.0e+308 +#define LARGEFLOAT 3.40282347E+38 +#define SMALLFLOAT 1.17549435E-38 +#define SMALLSTDOUBLE 1.0e-307 + +/* Visual Studio 2008 defines MAXINT32, MAXINT16 which collide with ours */ +#if defined MAXINT32 +#undef MAXINT32 +#endif +#if defined MAXINT16 +#undef MAXINT16 +#endif + +#define MAXINT32 LARGEINT32 +#define MAXINT16 LARGEINT16 +#define ETX 3 +#define LN2 0.69314718055994530942 +#define LN10 2.30258509299404568402 +#define PIOVER2 1.57079632679489661923 +#define TWOPI 6.28318530717958647692 +#if defined PI +#undef PI +#endif +#define PI 3.14159265358979323846 +#define ANGLEEPSILON 1.0e-10 +#define LARGESTANGLE (4*PI+ANGLEEPSILON) +#define DEGPERRADIANS 57.295779513082323 +#define CMPERINCH 2.54 +#define POINTSPERINCH 72.0 +#define FONTMOVEMARK 192 +#define FONTDECISIONMARK 128 +#define FONTLINEMARK 64 +#define BAD_SET_VALUE ((SetIndex_t)-1) +#define MENU_POSITION_FIRST (0) +#define MENU_POSITION_LAST (-1) +#define INVALID_UNIQUE_ID 0 + +#define BADSETVALUE BAD_SET_VALUE +#define SOLID_TRANSLUCENCY 0 +#define BAD_DISTANCE (-1.0) +/* MIN_CIRCUMFERENTIAL_INDEX is the min J dimension for circular zones */ +#define MIN_CIRCUMFERENTIAL_INDEX 4 + +#define VALID_STRAND_ID(StrandID) (0 <= (StrandID) && (StrandID) < MAXZONEMAP) +#define STRAND_ID_STATIC (-1) +#define STRAND_ID_PENDING (-2) + +/* + * Need 3 passes for "Rest of pie" method but can only use 3 clip planes + * Need only 1 pass for "Piece of pie" method and can use 6 clip planes +*/ +#define MAX_ALLOWABLE_CLIPPASSES 1 +#define MAX_ALLOWABLE_CLIPPLANES 6 + +/* BEGINREMOVEFROMADDON */ +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if defined _DEBUG +#else +#endif +#if 0 /* NOTUSED */ +#endif +#endif /* TECPLOTKERNEL */ +/* ENDREMOVEFROMADDON */ + + +/* + * NOTE: If you change TecplotBinaryFileVersion, you MUST also: + * + * 1. Update preplot: + * - Change this define symbol in preplot.cpp + * - Change version number in the data file format in the comments in preplot.cpp + * - Change the version number of Preplot itself in preplot.cpp + * 2. Maintain the ability to write the old plt file format: + * - Add a new entry to BinaryFileVersion_e + * - Add a concrete class of the VersionWriterInterface, and update + * VersionWriterAbstractFactory to return the correct instance for the previous and + * new BinaryFileVersion_e + * - Abstract away the difference in the two versions behind an interface (if one does + * not yet exist) and create concrete implementations that can write the old and the + * new versions. For a trivial example of this, see FileTypeWriterInterface and its + * associated factory and concrete classes. + */ +#define TecplotBinaryFileVersion 112 +#define TecplotInterfaceVersion 120 +#define TecplotInterfaceVersionStr "120" /* stay in lockstep with TecplotInterfaceVersion */ +#if defined FLEXLM +#define TecplotLicenseVersion 119 /* may vary from TecplotInterfaceVersion */ +#define TecplotLicenseVersionStr "11.9" /* stay in lockstep with TecplotLicenseVersion */ +#else /* FLEXLM */ +#define TecplotLicenseVersion 120 /* may vary from TecplotInterfaceVersion */ +#define TecplotLicenseVersionStr "12.0" /* stay in lockstep with TecplotLicenseVersion */ +#endif /* FLEXLM */ +/* Also change the macro version number in COMMAND.MASTER.h */ + +#define MaxNumZonesOrVars MAXZONEMAP +#define MaxXAxes 5 +#define MaxYAxes 5 +#define MaxGeoSegments 50 +#define MaxPtsCircleOrEllipse 720 +#define MaxFrames 2048 +#define MaxCustomLabelSets 10 +#define MaxFontMoves 20000 +#define MaxColorMapOverrides 16 +#define MaxValueBlankConstraints 8 +#define MaxContourGroups 8 +#define MaxIsoSurfaceGroups 8 +#define MaxSliceGroups 8 + +#define MaxColorMapGroups 8 +#define DefaultNumContLevels 15 + + +#define DefaultColorMapGroup ((SmInteger_t)0) +#define BADGROUPNUMBER ((SmInteger_t)-1) +#define UNUSEDGROUPNUMBER ((SmInteger_t)0) + +#define VALID_ISOSURFACE_GROUP(Group) (((((SmInteger_t)Group) >= 0) && (((SmInteger_t)Group) < MaxIsoSurfaceGroups))) +#define VALID_SLICE_GROUP(Group) (((((SmInteger_t)Group) >= 0) && (((SmInteger_t)Group) < MaxSliceGroups))) +#define VALID_COLORMAP_GROUP(Group) (((((SmInteger_t)Group) >= 0) && (((SmInteger_t)Group) < MaxColorMapGroups))) + + + +/* + * If any of these values changes its corresponding value in preplot.c must + * change to match it so that files created by preplot and Tecplot are + * consistent. + */ +#define MaxChrsDatasetTitle 256 +#define MaxChrsZnTitle 128 +#define MaxChrsVarName 128 +#define MaxChrsZnOrVarName 128 +/* currently limited to MaxLineIndex in preplot.c */ +#define MaxChrsAuxValueString 32000 + +#define MaxNumViews 16 +#define MaxBasicSizes 5 +#define MaxColorMapControlPoints 50 +#define MaxRawColorMapEntries 800 +#define MaxDataSetReaders 100 +#define MaxExtendedCurveFits 100 +#define MaxColorMapCycles 20 + + +/* Dimension Limits */ + +#define MinPaperDimInWorkArea 0.5 +#define MinFrameWidth 0.25 +#define MinFrameHeight 0.25 +#define MinAxisLength 0.1 + + +#define BadEnumValue 255 + +/* BEGINREMOVEFROMADDON */ +/* define class element limits */ +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif +/* ENDREMOVEFROMADDON */ + +/* + * Floating point values are written to layouts with a certain precision. + * A high precision is necessary in some cases (like streamtrace starting locations) + * This used to be set to 12 which was not high enough. It is now set to 16 which + * appears to be sufficient. This also seems to jive with the number of digits of + * precision that are found in "ieee double precision" values which is 53 bits or + * equivalent to approximately 16 digits. -bdp + * + */ +#define STYLE_FLOAT_PRECISION 16 + + +/* + * Auxiliary data common names. + * + * Define Name Data Name Data Type Data Location + * ------------------------------------------ ------------------------------------ --------- ------------- + */ +#define AuxData_Common_Incompressible "Common.Incompressible" /* Boolean_t Dataset */ +#define AuxData_Common_Density "Common.Density" /* double Dataset */ +#define AuxData_Common_SpecificHeat "Common.SpecificHeat" /* double Dataset */ +#define AuxData_Common_SpecificHeatVar "Common.SpecificHeatVar" /* int Dataset */ +#define AuxData_Common_GasConstant "Common.GasConstant" /* double Dataset */ +#define AuxData_Common_GasConstantVar "Common.GasConstantVar" /* int Dataset */ +#define AuxData_Common_Gamma "Common.Gamma" /* double Dataset */ +#define AuxData_Common_GammaVar "Common.GammaVar" /* int Dataset */ +#define AuxData_Common_Viscosity "Common.Viscosity" /* double Dataset */ +#define AuxData_Common_ViscosityVar "Common.ViscosityVar" /* int Dataset */ +#define AuxData_Common_Conductivity "Common.Conductivity" /* double Dataset */ +#define AuxData_Common_ConductivityVar "Common.ConductivityVar" /* int Dataset */ +#define AuxData_Common_AngleOfAttack "Common.AngleOfAttack" /* double Dataset */ +#define AuxData_Common_SpeedOfSound "Common.SpeedOfSound" /* double Dataset */ +#define AuxData_Common_ReferenceU "Common.ReferenceU" /* double Dataset */ +#define AuxData_Common_ReferenceV "Common.ReferenceV" /* double Dataset */ +#define AuxData_Common_XVar "Common.XVar" /* int Dataset */ +#define AuxData_Common_YVar "Common.YVar" /* int Dataset */ +#define AuxData_Common_ZVar "Common.ZVar" /* int Dataset */ +#define AuxData_Common_CVar "Common.CVar" /* int Dataset */ +#define AuxData_Common_UVar "Common.UVar" /* int Dataset */ +#define AuxData_Common_VVar "Common.VVar" /* int Dataset */ +#define AuxData_Common_WVar "Common.WVar" /* int Dataset */ +#define AuxData_Common_VectorVarsAreVelocity "Common.VectorVarsAreVelocity" /* Boolean_t Dataset */ +#define AuxData_Common_PressureVar "Common.PressureVar" /* int Dataset */ +#define AuxData_Common_TemperatureVar "Common.TemperatureVar" /* int Dataset */ +#define AuxData_Common_DensityVar "Common.DensityVar" /* int Dataset */ +#define AuxData_Common_StagnationEnergyVar "Common.StagnationEnergyVar" /* int Dataset */ +#define AuxData_Common_MachNumberVar "Common.MachNumberVar" /* int Dataset */ +#define AuxData_Common_ReferenceMachNumber "Common.ReferenceMachNumber" /* double Dataset */ +#define AuxData_Common_ReferenceW "Common.ReferenceW" /* double Dataset */ +#define AuxData_Common_PrandtlNumber "Common.PrandtlNumber" /* double DataSet */ +#define AuxData_Common_Axisymmetric "Common.Axisymmetric" /* Boolean_t Dataset */ +#define AuxData_Common_AxisOfSymmetryVarAssignment "Common.AxisOfSymmetryVarAssignment" /* int Dataset */ +#define AuxData_Common_AxisValue "Common.AxisValue" /* double Dataset */ +#define AuxData_Common_SteadyState "Common.SteadyState" /* Boolean_t Dataset */ +#define AuxData_Common_TurbulentKineticEnergyVar "Common.TurbulentKineticEnergyVar" /* int Dataset */ +#define AuxData_Common_TurbulentDissipationRateVar "Common.TurbulentDissipationRateVar" /* int Dataset */ +#define AuxData_Common_TurbulentViscosityVar "Common.TurbulentViscosityVar" /* int Dataset */ +#define AuxData_Common_TurbulentFrequencyVar "Common.TurbulentFrequencyVar" /* int Dataset */ +#define AuxData_Common_Gravity "Common.Gravity" /* double Dataset */ +#define AuxData_Common_IsBoundaryZone "Common.IsBoundaryZone" /* Boolean_t Zone */ +#define AuxData_Common_BoundaryCondition "Common.BoundaryCondition" /* BCondition Zone */ +#define AuxData_Common_Time "Common.Time" /* double Zone */ +#define AuxData_Common_Mean "Common.Mean" /* double Variable */ +#define AuxData_Common_Median "Common.Median" /* double Variable */ +#define AuxData_Common_Variance "Common.Variance" /* double Variable */ +#define AuxData_Common_StdDev "Common.StdDev" /* double Variable */ +#define AuxData_Common_AvgDev "Common.AvgDev" /* double Variable */ +#define AuxData_Common_GeoMean "Common.GeoMean" /* double Variable */ +#define AuxData_Common_ChiSqre "Common.ChiSqre" /* double Variable */ + + + + + + + +/* BEGINREMOVEFROMADDON */ +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if defined THREED +#endif +#endif /* TECPLOTKERNEL */ +/* ENDREMOVEFROMADDON */ + +/* Tecplot Add-on Custom Products */ + +/* BEGINREMOVEFROMADDON */ +/* In activeX, the color constants are an enum type, + so the activeX source code parser handles these as + a special case, and the types do not need to be + indicated as with the other hard #define constants */ +/* ENDREMOVEFROMADDON */ + +#define Black_C ((ColorIndex_t)0) +#define Red_C ((ColorIndex_t)1) +#define Green_C ((ColorIndex_t)2) +#define Blue_C ((ColorIndex_t)3) +#define Cyan_C ((ColorIndex_t)4) +#define Yellow_C ((ColorIndex_t)5) +#define Purple_C ((ColorIndex_t)6) +#define White_C ((ColorIndex_t)7) + +#define Custom1_C ((ColorIndex_t)8) +#define Custom2_C ((ColorIndex_t)9) +#define Custom3_C ((ColorIndex_t)10) +#define Custom4_C ((ColorIndex_t)11) +#define Custom5_C ((ColorIndex_t)12) +#define Custom6_C ((ColorIndex_t)13) +#define Custom7_C ((ColorIndex_t)14) +#define Custom8_C ((ColorIndex_t)15) +#define Custom9_C ((ColorIndex_t)16) + +#define Custom10_C ((ColorIndex_t)17) +#define Custom11_C ((ColorIndex_t)18) +#define Custom12_C ((ColorIndex_t)19) +#define Custom13_C ((ColorIndex_t)20) +#define Custom14_C ((ColorIndex_t)21) +#define Custom15_C ((ColorIndex_t)22) +#define Custom16_C ((ColorIndex_t)23) +#define Custom17_C ((ColorIndex_t)24) +#define Custom18_C ((ColorIndex_t)25) +#define Custom19_C ((ColorIndex_t)26) + +#define Custom20_C ((ColorIndex_t)27) +#define Custom21_C ((ColorIndex_t)28) +#define Custom22_C ((ColorIndex_t)29) +#define Custom23_C ((ColorIndex_t)30) +#define Custom24_C ((ColorIndex_t)31) +#define Custom25_C ((ColorIndex_t)32) +#define Custom26_C ((ColorIndex_t)33) +#define Custom27_C ((ColorIndex_t)34) +#define Custom28_C ((ColorIndex_t)35) +#define Custom29_C ((ColorIndex_t)36) + +#define Custom30_C ((ColorIndex_t)37) +#define Custom31_C ((ColorIndex_t)38) +#define Custom32_C ((ColorIndex_t)39) +#define Custom33_C ((ColorIndex_t)40) +#define Custom34_C ((ColorIndex_t)41) +#define Custom35_C ((ColorIndex_t)42) +#define Custom36_C ((ColorIndex_t)43) +#define Custom37_C ((ColorIndex_t)44) +#define Custom38_C ((ColorIndex_t)45) +#define Custom39_C ((ColorIndex_t)46) + +#define Custom40_C ((ColorIndex_t)47) +#define Custom41_C ((ColorIndex_t)48) +#define Custom42_C ((ColorIndex_t)49) +#define Custom43_C ((ColorIndex_t)50) +#define Custom44_C ((ColorIndex_t)51) +#define Custom45_C ((ColorIndex_t)52) +#define Custom46_C ((ColorIndex_t)53) +#define Custom47_C ((ColorIndex_t)54) +#define Custom48_C ((ColorIndex_t)55) +#define Custom49_C ((ColorIndex_t)56) + +#define Custom50_C ((ColorIndex_t)57) +#define Custom51_C ((ColorIndex_t)58) +#define Custom52_C ((ColorIndex_t)59) +#define Custom53_C ((ColorIndex_t)60) +#define Custom54_C ((ColorIndex_t)61) +#define Custom55_C ((ColorIndex_t)62) +#define Custom56_C ((ColorIndex_t)63) + +#define MultiColor_C ((ColorIndex_t)(-1)) +#define NoColor_C ((ColorIndex_t)(-2)) +#define MultiColor2_C ((ColorIndex_t)(-3)) +#define MultiColor3_C ((ColorIndex_t)(-4)) +#define MultiColor4_C ((ColorIndex_t)(-5)) +#define RGBColor_C ((ColorIndex_t)(-6)) +#define MultiColor5_C ((ColorIndex_t)(-7)) +#define MultiColor6_C ((ColorIndex_t)(-8)) +#define MultiColor7_C ((ColorIndex_t)(-9)) +#define MultiColor8_C ((ColorIndex_t)(-10)) +#define InvalidColor_C ((ColorIndex_t)(-255)) + +#define FirstCustomColor Custom1_C +#define LastCustomColor Custom56_C +#define NumCustomColors (LastCustomColor-FirstCustomColor+1) + +#define FirstBasicColor Black_C +#define LastBasicColor LastCustomColor +#define NumBasicColors (LastBasicColor-FirstBasicColor+1) + +/* BEGINREMOVEFROMADDON */ + +/* + * V8 and earlier used this for MultiColor_C. We adjust this + * to the new value in the SetValue layer so old addons work. + */ +#define OldMultiColor_C ((ColorIndex_t)255) +/* + * Gray is only used in the interface for workspace background and + * for insensitive buttons in Motif. + * True Black and True White are also interface only. They draw + * true black or true white - regardless of what the user has set + * the RGB values for the black and white basic colors. + * XOrColor_C is also for interface only. + */ +#define Gray_C (LastBasicColor+1) +#define DarkGray_C (LastBasicColor+2) /* Used for inactive frame border color */ +#define XOrColor_C (LastBasicColor+3) +#define FirstInterfaceColor Gray_C +#define LastInterfaceColor XOrColor_C + +#define NumInterfaceColors (LastInterfaceColor-FirstInterfaceColor+1) +#define NumContourShades (GeneralBase.Limits.MaxNumContourLevels+1) +#define NumColorsInColorTable (NumBasicColors+NumInterfaceColors+NumContourShades) +#define BasicColorOffset (0) +#define InterfaceColorOffset (NumBasicColors) +#define ContourColorOffset (NumBasicColors+NumInterfaceColors) + +#define BadKey (short)31 +#define Plus (short)43 +#define Minus (short)45 +#define RetKey (short)13 +#define DeleteKey (short)127 +#define ShiftDelete (short)128 +#define BackSpace (short)8 +#define LeftArrow (short)29 +#define RightArrow (short)30 +#define UpArrow (short)11 +#define DownArrow (short)10 +#define Toggle (short)19 +#define Esc (short)27 +#define RegFrame (short)18 +#define DoBitDump (short)2 + + +/* File Markers */ +#define ZoneMarker 299.0 +#define GeomMarker 399.0 +#define TextMarker 499.0 +#define CustomLabelMarker 599.0 +#define UserRecMarker 699.0 +#define DataSetAuxMarker 799.0 +#define VarAuxMarker 899.0 +#define EndHeaderMarker 357.0 + + +/* + * Additional objects that have plotter + * pens assigned to them. + */ +#define AxisPen Custom8_C+1 +#define MajGridPen Custom8_C+2 +#define MinGridPen Custom8_C+3 +#define StreamlinePen Custom8_C+4 +#define ColoredLinePen Custom8_C+5 +#define BoundaryPen Custom8_C+6 +#define LabelPen Custom8_C+7 +#define NumPlotterPens Custom8_C+8 +/* AutoSelectPen will select the correct pen from Black_C thru Custom8_C or ColoredLinePen */ +#define AutoSelectPen Custom8_C+9 +#define InvalidPen Custom8_C+99 + +#define FirstObjectPen AxisPen +#define LastObjectPen LabelPen + +#define DelZFactor 0.0001 + +#define BadBaseValue NULL + + +/* + * NOTES ON TYPEDEFS: + * + * TYPEDEF TYPE Suffix + * ------------ ------ + * simple _t + * enumerated _e + * structure _s + * union _u + * abstract _a + * pointer to simple _pt + * pointer to enumerated _pe + * pointer to structure _ps + * pointer to union _pu + * pointer to abstract _pa + * pointer to function _pf + * + * + * The only execption is char * typedef's these use _t + * + * Abstract types are intentionally made to be + * obscure. The programmer should not have to know + * what the underlying structure really is for abstract + * types. + * + */ + + +#ifdef MSWIN +# define DIR_SEPARATOR "\\" +#else +# define DIR_SEPARATOR "/" +#endif + +/* ENDREMOVEFROMADDON */ + +/* BEGINREMOVEFROMADDON */ +#if defined MSWIN +#define TP_FWRITE fwrite +#define TP_FFLUSH fflush +#define TP_FCLOSE fclose + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#else +#define TP_UNLINK remove +#define TP_RMDIR _rmdir +#define TP_FREAD ::fread +#define TP_FOPEN ::fopen +#define TP_FREOPEN ::freopen +#define TP_STAT ::_stat +#define TP_GETENV ::getenv +#endif /* TECPLOTKERNEL */ + +#if defined _WIN64 +#define TP_FSEEK(stream,offset,whence) _fseeki64((stream),(__int64)(offset),(whence)) +#define TP_FTELL _ftelli64 +#else +#define TP_FSEEK(stream, offset, whence) fseek((stream), (long)(offset), (whence)) +#define TP_FTELL ftell +#endif + +#else +#define TP_RMDIR rmdir +#define TP_UNLINK unlink +#define TP_FOPEN fopen +#define TP_FREOPEN freopen +#define TP_FCLOSE fclose +#define TP_FREAD fread +#define TP_FWRITE fwrite +#define TP_FFLUSH fflush +#define TP_FSEEK fseeko +#define TP_FTELL ftello +#define TP_STAT stat +#define _stat stat // ...make the UNIXX and MSWIN platforms have the same syntax to use "struct _stat" +#define TP_GETENV getenv +#endif +/* ENDREMOVEFROMADDON */ + +/**************************************************************** + * * + * SIMPLE TYPEDEFS * + * * + ****************************************************************/ + + + +/* How to define UInt64_t/Int64_t is platform specific, but they are always 8-bytes */ +#if defined MSWIN +typedef unsigned __int64 UInt64_t; +typedef __int64 Int64_t; +#else +#if defined CRAY +typedef unsigned int UInt64_t; +typedef int Int64_t; +#else +#if defined LONGIS64 +typedef unsigned long UInt64_t; +typedef long Int64_t; +#else +typedef unsigned long long UInt64_t; +typedef long long Int64_t; +#endif +#endif +#endif + +#if defined LONGIS64 +typedef unsigned int UInt32_t; +typedef int Int32_t; +typedef int LgInteger_t; +#else +typedef unsigned int UInt32_t; +typedef int Int32_t; +typedef int LgInteger_t; +#endif + +typedef short Int16_t; +typedef unsigned short UInt16_t; +typedef signed char Int8_t; +typedef unsigned char UInt8_t; + +#ifdef INDEX_16_BIT +typedef Int16_t LgIndex_t; +#else +typedef Int32_t LgIndex_t; +#endif +typedef LgIndex_t NodeMap_t; +typedef LgIndex_t ScreenDim_t; + +/** + * ArbParam_t type is used for passing arbitrary integers or pointers in + * parameters. HgIndex_t is used for counting node maps and other things that + * may individually be LgIndex_t, but in total exceed 32-bit. + * The general rule is that these are 4 bytes on "32-bit" machines + * and 8 bytes on "64-bit" machines. + */ +#if defined CRAY +typedef char *ArbParam_t; +typedef long HgIndex_t; +#elif defined LONGIS64 +typedef long ArbParam_t; +typedef long HgIndex_t; +#elif defined MSWIN && (defined _M_IA64 || defined _M_AMD64) +typedef INT_PTR ArbParam_t; +typedef INT_PTR HgIndex_t; +#else +typedef int ArbParam_t; +typedef int HgIndex_t; +#endif + +typedef ArbParam_t UniqueID_t; + +/* 64 bit offset used to hold file offset and size values. */ +typedef Int64_t FileOffset_t; + +/** + * 64 bit offset for memory mapped I/O. + */ +typedef UInt64_t MemMapOffset_t; + +/* + * SmInteger must be at least a short.... + */ + +typedef unsigned char Byte_t; +typedef short SmInteger_t; +typedef SmInteger_t ColorIndex_t; +#ifdef INDEX_16_BIT +typedef Int16_t EntIndex_t; +#else +typedef Int32_t EntIndex_t; +#endif +typedef Int16_t SubZoneIndex_t; + +typedef char Boolean_t; +typedef char *ZoneName_t; +typedef char *VarName_t; +typedef char *LString_t; + +typedef LgIndex_t Strand_t; +typedef LgIndex_t HeapLength_t; +typedef LgIndex_t SegPtsArray_t[MaxGeoSegments]; +typedef double BasicSize_t[MaxBasicSizes]; +typedef double *VarList_t; + +typedef long SetIndex_t; + +typedef unsigned long SetData_t; +typedef SetData_t *SetData_pt; + +/* BEGINREMOVEFROMADDON */ +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif /* TECPLOTKERNEL */ + +/* The following list identifies items that can be inhibited. */ +#define FEATURE_3D (1L << 0) +#define FEATURE_3DVOLUME (1L << 1) +#define FEATURE_2D (1L << 2) +#define FEATURE_XY (1L << 3) +#define FEATURE_DATAALTER (1L << 4) +#define FEATURE_UNSTRUCTUREDDATA (1L << 5) +#define FEATURE_MULTIPLEFRAMES1 (1L << 6) +#define FEATURE_MULTIPLEZONES1 (1L << 7) +#define FEATURE_MULTIPLEFRAMES5 (1L << 8) +#define FEATURE_MULTIPLEZONES5 (1L << 9) +#define FEATURE_MULTIPLEFRAMES10 (1L << 10) +#define FEATURE_MULTIPLEZONES10 (1L << 11) +#define FEATURE_READNONOEMDATA (1L << 12) /* Added 07/22/2000 */ +#define FEATURE_DATALOADERS (1L << 13) /* Added 07/22/2000 */ +#define FEATURE_DATALOADERS_EXCEPTONE (1L << 14) /* Added 11/26/2001 */ +#define FEATURE_LOADONDEMAND (1L << 15) /* Added 09/13/2007 */ +#define FEATURE_MULTIPLEWORKERTHREADS (1L << 16) /* Added 09/13/2007 */ +#define FEATURE_ISOSURFACEGROUPS (1L << 17) /* Added 09/21/2007 */ +#define FEATURE_SLICEGROUPS (1L << 18) /* Added 09/21/2007 */ +#define FEATURE_STREAMTRACEGROUPS (1L << 19) /* Added 09/25/2007 not used yet */ +#define FEATURE_FEPOLYHEDRON (1L << 20) /* Added 09/25/2007 */ +#define FEATURE_FEPOLYGON (1L << 21) /* Added 09/25/2007 */ + +/* + * KnowFeaturesToInhibit must be updated whenever a new + * item is added above. + */ +#define KnownFeaturesToInhibit (FEATURE_3D |\ + FEATURE_3DVOLUME |\ + FEATURE_2D |\ + FEATURE_XY |\ + FEATURE_DATAALTER |\ + FEATURE_UNSTRUCTUREDDATA |\ + FEATURE_MULTIPLEFRAMES1 |\ + FEATURE_MULTIPLEZONES1 |\ + FEATURE_MULTIPLEFRAMES5 |\ + FEATURE_MULTIPLEZONES5 |\ + FEATURE_MULTIPLEFRAMES10 |\ + FEATURE_MULTIPLEZONES10 |\ + FEATURE_READNONOEMDATA |\ + FEATURE_DATALOADERS |\ + FEATURE_DATALOADERS_EXCEPTONE |\ + FEATURE_LOADONDEMAND |\ + FEATURE_MULTIPLEWORKERTHREADS |\ + FEATURE_ISOSURFACEGROUPS |\ + FEATURE_SLICEGROUPS |\ + FEATURE_STREAMTRACEGROUPS |\ + FEATURE_FEPOLYHEDRON |\ + FEATURE_FEPOLYGON) + +#define VALID_FEATURE_INHIBIT_FLAG(feature) (((feature) & KnownFeaturesToInhibit) != 0) +#define VALID_FEATURE_INHIBIT_MASK(mask) (((mask) & ~KnownFeaturesToInhibit)==0) + + + +/* The following are used by the OEM libs, so they need + to be outside of TECPLOTKERNEL */ +typedef unsigned long FeatureFlag_t; +typedef unsigned long FeatureMask_t; + +/* ENDREMOVEFROMADDON */ + +typedef char SymbolChar_t[3]; + +/** + * Face node offset used for identifying which node of a polytope face is + * desired. + */ +typedef LgIndex_t FaceNodeOffset_t; + +/** + * Element face offset used for identifying which face of a polytope element is + * desired. + */ +typedef LgIndex_t ElemFaceOffset_t; + +/** + * Face boundary item offset used for identifying which boundary item of a + * polytope face is desired. + */ +typedef LgIndex_t FaceBndryItemOffset_t; + +/**************************************************************** + * * + * ENUMERATED TYPEDEFS * + * * + ****************************************************************/ + +typedef enum +{ + PlacementPlaneOrientation_X, + PlacementPlaneOrientation_Y, + PlacementPlaneOrientation_Z, + END_PlacementPlaneOrientation_e, + PlacementPlaneOrientation_Invalid = BadEnumValue +} PlacementPlaneOrientation_e; + +typedef enum +{ + StringMode_ASCII, + StringMode_UTF8, + StringMode_Blend, + END_StringMode_e, + StringMode_Invalid = BadEnumValue + +} StringMode_e; + +typedef enum +{ + SidebarSizing_MaxOfAll, + SidebarSizing_Dynamic, + END_SidebarSizing_e, + SidebarSizing_Invalid = BadEnumValue + +} SidebarSizing_e; + +typedef enum +{ + SidebarLocation_Left, + SidebarLocation_Right, /* Not allowed at this time */ + SidebarLocation_Top, /* Not allowed at this time */ + SidebarLocation_Bottom, /* Not allowed at this time */ + END_SidebarLocation_e, + SidebarLocation_Invalid = BadEnumValue + +} SidebarLocation_e; + +typedef enum +{ + MenuItem_Option, + MenuItem_Toggle, + MenuItem_Separator, + MenuItem_SubMenu, + END_MenuItem_e, + MenuItem_Invalid = BadEnumValue +} MenuItem_e; + +typedef enum +{ + StandardMenu_File, + StandardMenu_Edit, + StandardMenu_View, + StandardMenu_Plot, + StandardMenu_Insert, + StandardMenu_Data, + StandardMenu_Frame, + StandardMenu_Workspace, /* deprecated: use Options instead */ + StandardMenu_Tools, + StandardMenu_Help, + StandardMenu_Animate, + StandardMenu_Options, + StandardMenu_Scripting, + END_StandardMenu_e, + StandardMenu_Invalid = BadEnumValue +} StandardMenu_e; + +typedef enum +{ + FieldProbeDialogPage_NodalValues, + FieldProbeDialogPage_CellCenteredValues, + FieldProbeDialogPage_ZoneCellInfo, + FieldProbeDialogPage_FaceNeighbors, + END_FieldProbeDialogPage_e, + FieldProbeDialogPage_Invalid = BadEnumValue +} FieldProbeDialogPage_e; + +/* BEGINREMOVEFROMADDON */ + +/* used for caches of boolean type */ +typedef enum +{ + BooleanCache_False, /* Value is cached and is FALSE */ + BooleanCache_True, /* Value is cached and is TRUE */ + BooleanCache_Uncached, /* Value is not cached. Value is unknown. */ + END_BooleanCache_e, + BooleanCache_Invalid = BadEnumValue +} BooleanCache_e; + +/* + * For determining pick location along a line + */ +typedef enum +{ + LinePickLocation_None, + LinePickLocation_StartHandle, + LinePickLocation_MidLineOnHandle, + LinePickLocation_MidLineOffHandles, + LinePickLocation_EndHandle, + END_LinePickLocation_e, + LinePickLocation_Invalid = BadEnumValue +} LinePickLocation_e; + + +/* + * Defines destination for setting up views: hardware (ie, OpenGL) or + * software (ie, internal transformation matrices). + */ +typedef enum +{ + ViewDest_Hardware, + ViewDest_Software, + END_ViewDest_e, + ViewDest_Invalid = BadEnumValue +} ViewDest_e; + +/* used for identifying the origin of the dataset reader */ +typedef enum +{ + DataSetReaderOrigin_Native, /* created by Tecplot */ + DataSetReaderOrigin_Foreign, /* created by an add-on */ + END_DataSetReaderOrigin_e, + DataSetReaderOrigin_Invalid = BadEnumValue +} DataSetReaderOrigin_e; + +/* used for identifying the origin of the extended curve fit */ +typedef enum +{ + ExtendedCurveFitOrigin_Native, /* created by Tecplot */ + ExtendedCurveFitOrigin_Foreign, /* created by an add-on */ + END_ExtendedCurveFitOrigin_e, + ExtendedCurveFitOrigin_Invalid = BadEnumValue +} ExtendedCurveFitOrigin_e; + +typedef enum +{ + CollapsedStatus_NotCollapsed, + CollapsedStatus_CollapsedToPoint, + CollapsedStatus_CollapsedToLine, + CollapsedStatus_CollapsedToSegmentedLine, + CollapsedStatus_CollapsedToTriangle, + END_CollapsedStatus_e, + CollapsedStatus_Invalid = BadEnumValue +} CollapsedStatus_e; +/* ENDREMOVEFROMADDON */ + +/** + */ +typedef enum +{ + UndoStateCategory_Frame, + UndoStateCategory_Picked, /* picked changes, not the pick itself */ + UndoStateCategory_Text, + UndoStateCategory_Geom, + UndoStateCategory_View, + UndoStateCategory_WorkspaceView, + UndoStateCategory_Style, /* style less text and geometries */ + UndoStateCategory_SpecificStyle, /* meaning that specific undo style will be added by the caller */ + UndoStateCategory_Data, + UndoStateCategory_DataAndStyle, + UndoStateCategory_StyleIncTextGeom, /* style including text and geometires */ + UndoStateCategory_GlobalStyle, /* style less field, map, text and geometries */ + UndoStateCategory_PageAction, + END_UndoStateCategory_e, + UndoStateCategory_Invalid = BadEnumValue +} UndoStateCategory_e; + + +/* + * Used only for Action_PropagateLinking + */ +typedef enum +{ + LinkType_WithinFrame, + LinkType_BetweenFrames, + END_LinkType_e, + LinkType_Invalid = BadEnumValue +} LinkType_e; + +typedef enum +{ + FrameCollection_All, + FrameCollection_Picked, + END_FrameCollection_e, + FrameCollection_Invalid = BadEnumValue +} FrameCollection_e; + + + +typedef enum +{ + LegendProcess_DrawLegend, + LegendProcess_EraseLegend, + LegendProcess_GetExtents, + END_LegendProcess_e, + LegendProcess_Invalid = BadEnumValue +} LegendProcess_e; + + +typedef enum +{ + RGBLegendOrientation_RGB, + RGBLegendOrientation_GBR, + RGBLegendOrientation_BRG, + RGBLegendOrientation_RBG, + RGBLegendOrientation_GRB, + RGBLegendOrientation_BGR, + END_RGBLegendOrientation_e, + RGBLegendOrientation_Invalid = BadEnumValue +} RGBLegendOrientation_e; + + + +/* BEGINREMOVEFROMADDON */ +/* Used by some of the image exporters/animators */ +typedef struct +{ + Byte_t R; + Byte_t G; + Byte_t B; +} RGBTriple_s; + +typedef RGBTriple_s RGBPalette_t[256]; + +/* ENDREMOVEFROMADDON */ + +/* BEGINREMOVEFROMADDON */ +/* The tag on the following line is so that the Windows + build script can parse all of the current state changes + out of this file, and compare them to the state changes + found in the main.c template file. + Do not change or delete the line below.*/ +/*StateChange_e_BeginDef*/ +/* ENDREMOVEFROMADDON */ + +typedef enum +{ + StateChange_VarsAltered, + StateChange_VarsAdded, + StateChange_ZonesDeleted, + StateChange_ZonesAdded, + StateChange_NodeMapsAltered, + StateChange_FrameDeleted, + StateChange_NewTopFrame, /* deprecated: use NewActiveFrame and/or FrameOrderChange */ + StateChange_Style, + StateChange_DataSetReset, + StateChange_NewLayout, + StateChange_CompleteReset, /* deprecated: no longer broadcast */ + StateChange_LineMapAssignment, /* was StateChange_XYMapAssignment */ + StateChange_ContourLevels, + StateChange_ModalDialogLaunch, + StateChange_ModalDialogDismiss, + StateChange_QuitTecplot, + StateChange_ZoneName, + StateChange_VarName, + StateChange_LineMapName, /* was StateChange_XYMapName */ + StateChange_LineMapAddDeleteOrReorder, /* was StateChange_XYMapAddDeleteOrReorder */ + StateChange_View, + StateChange_ColorMap, + StateChange_ContourVar, + StateChange_Streamtrace, + StateChange_NewAxisVariables, + StateChange_MouseModeUpdate, + StateChange_PickListCleared, + StateChange_PickListGroupSelect, + StateChange_PickListSingleSelect, + StateChange_PickListStyle, + StateChange_DataSetFileName, + StateChange_UnsuspendInterface, /* was StateChange_DrawGraphicsOn */ + StateChange_SuspendInterface, /* was StateChange_DrawGraphicsOff */ + StateChange_DataSetLockOn, + StateChange_DataSetLockOff, + StateChange_Text, + StateChange_Geom, + StateChange_DataSetTitle, + StateChange_DrawingInterrupted, + StateChange_PrintPreviewLaunch, + StateChange_PrintPreviewDismiss, + StateChange_AuxDataAdded, + StateChange_AuxDataDeleted, + StateChange_AuxDataAltered, + StateChange_VarsDeleted, + StateChange_TecplotIsInitialized, + StateChange_ImageExported, + StateChange_VariableLockOn, + StateChange_VariableLockOff, + StateChange_PageDeleted, + StateChange_NewTopPage, + StateChange_NewActiveFrame, + StateChange_FrameOrderChanged, + END_StateChange_e, + StateChange_Invalid = BadEnumValue, + /* deprecated values */ + StateChange_DrawGraphicsOn = StateChange_UnsuspendInterface, + StateChange_DrawGraphicsOff = StateChange_SuspendInterface, + StateChange_XYMapAssignment = StateChange_LineMapAssignment, + StateChange_XYMapName = StateChange_LineMapName, + StateChange_XYMapAddDeleteOrReorder = StateChange_LineMapAddDeleteOrReorder +} StateChange_e; + +typedef enum +{ + StateChangeMode_v75, + StateChangeMode_v80, + StateChangeMode_v100, + StateChangeMode_v113, + END_StateChangeMode_e, + StateChangeMode_Invalid = BadEnumValue +} StateChangeMode_e; + +typedef enum +{ + StateChangeCallbackAPI_Classic, + StateChangeCallbackAPI_ChangeOnly, + StateChangeCallbackAPI_ChangePlusClient, + END_StateChangeCallbackAPI_e, + StateChangeCallbackAPI_Invalid = BadEnumValue +} StateChangeCallbackAPI_e; + +typedef enum +{ + AppMode_Normal, + AppMode_Demo, + AppMode_OEM, + END_AppMode_e, + AppMode_Invalid = BadEnumValue +} AppMode_e; + +typedef enum +{ + ProductFlavor_TecplotFocus, + ProductFlavor_Tecplot360, + ProductFlavor_TecplotRS, + ProductFlavor_TecplotSDK, + END_ProductFlavor_e, + ProductFlavor_Invalid = BadEnumValue, + ProductFlavor_Focus = ProductFlavor_TecplotFocus, /* deprecated */ + ProductFlavor_360 = ProductFlavor_Tecplot360, /* deprecated */ + ProductFlavor_RS = ProductFlavor_TecplotRS, /* deprecated */ + ProductFlavor_SDK = ProductFlavor_TecplotSDK /* deprecated */ +} ProductFlavor_e; + +typedef enum +{ + LayoutPackageObject_Image, + LayoutPackageObject_Layout, + LayoutPackageObject_Data, + END_LayoutPackageObject_e, + LayoutPackageObject_Invalid = BadEnumValue +} LayoutPackageObject_e; + +typedef enum +{ + VarLoadMode_ByName, + VarLoadMode_ByPosition, + END_VarLoadMode_e, + VarLoadMode_Invalid = BadEnumValue +} VarLoadMode_e; + +typedef enum +{ + ImageSelection_OnePerFrame, + ImageSelection_WorkspaceOnly, + END_ImageSelection_e, + ImageSelection_Invalid = BadEnumValue +} ImageSelection_e; + +typedef enum +{ + LibraryType_Foreign, + LibraryType_V7Standard, + LibraryType_V7ActiveX, + END_LibraryType_e, + LibraryType_Invalid = BadEnumValue +} LibraryType_e; /* <help> "Add-on types" */ + + +typedef enum +{ + AssignOp_Equals, + AssignOp_PlusEquals, + AssignOp_MinusEquals, + AssignOp_TimesEquals, + AssignOp_DivideEquals, + AssignOp_ConvertFromCm, + AssignOp_ConvertFromIn, + AssignOp_ConvertFromPt, + AssignOp_ConvertFromPix, + END_AssignOp_e, + AssignOp_Invalid = BadEnumValue +} AssignOp_e; + +typedef enum +{ + Dialog_ColorMap, + Dialog_Equation, + Dialog_MacroViewer, + Dialog_ZoneMapStyle, /* was Dialog_PlotAttributes*/ + Dialog_QuickEdit, + Dialog_QuickMacroPanel, + Dialog_ValueBlanking, + Dialog_Probe, /* used for dialog positioning only */ + Dialog_ProbeAt, + Dialog_NewLayout, + Dialog_OpenLayout, + Dialog_Save, + Dialog_SaveAs, + Dialog_LoadData, + Dialog_WriteData, + Dialog_Print, + Dialog_Import, + Dialog_Export, + Dialog_MacroPlay, + Dialog_MacroRecord, + Dialog_AxisEdit, + Dialog_SpatialVars, + Dialog_Reset3DAxes, + Dialog_ThreeDAxisLimits, + Dialog_ThreeDOrientationAxis, + Dialog_Streamtraces, + Dialog_IsoSurfaces, + Dialog_Slices, + Dialog_Contour, + Dialog_VectorLength, + Dialog_VectorVars, + Dialog_VectorArrowheads, + Dialog_VectorReferenceVector, + Dialog_ScatterSizeAndFont, + Dialog_ScatterLegend, + Dialog_ScatterReferenceSymbol, + Dialog_RGBColorVarsAndRange, + Dialog_RGBColorLegend, + Dialog_LineMapLegend, + Dialog_IJKBlanking, + Dialog_DepthBlanking, + Dialog_LightSource, + Dialog_Advanced3DControl, + Dialog_TwoDDrawOrder, + Dialog_PolarDrawingOptions, + Dialog_DataLabels, + Dialog_StyleLinking, + Dialog_Smooth, + Dialog_TransformCoordinates, + Dialog_Rotate2DData, + Dialog_Create1DLine, + Dialog_CreateRectangularZone, + Dialog_CreateCircularZone, + Dialog_DuplicateZone, + Dialog_MirrorZone, + Dialog_CreateZoneFromPolylines, + Dialog_CreateZoneFromValues, + Dialog_DeleteVariables, + Dialog_DeleteZones, + Dialog_ExtractContourLines, + Dialog_ExtractFEBoundary, + Dialog_ExtractIsoSurfaces, + Dialog_ExtractSlices, + Dialog_ExtractSliceFromPlane, + Dialog_ExtractStreamtraces, + Dialog_ExtractSubZone, + Dialog_ExtractDiscretePoints, + Dialog_ExtractPointsFromPolyline, + Dialog_ExtractPointsFromGeometry, + Dialog_LinearInterpolation, + Dialog_InverseDistanceInterpolation, + Dialog_KrigingInterpolation, + Dialog_Triangulate, + Dialog_DataInfo, + Dialog_CurveInfo, + Dialog_DataSpreadsheet, + Dialog_PaperSetup, + Dialog_OrderFrames, + Dialog_RulerGrid, + Dialog_ThreeDViewRotate, + Dialog_ThreeDViewDetails, + Dialog_TranslateMagnify, + Dialog_PrintPreview, + Dialog_ColorPreferences, + Dialog_MiscPreferences, + Dialog_SizePreferences, + Dialog_SaveConfiguration, + Dialog_SaveColorMap, + Dialog_LoadColorMap, + Dialog_HelpAboutTecplot, + Dialog_HelpAboutAddOns, + Dialog_Publish, + Dialog_EditFrame, + Dialog_CopyToClipboard, + Dialog_ThreeDEdge, + Dialog_TimeDetails, + Dialog_Performance, + END_Dialog_e, + Dialog_Invalid = BadEnumValue, + /* deprecated values */ + Dialog_PlotAttributes = Dialog_ZoneMapStyle +} Dialog_e; /* <help> "Tecplot dialog types" */ + +typedef enum +{ + AnchorAlignment_TopLeft, + AnchorAlignment_TopCenter, + AnchorAlignment_TopRight, + AnchorAlignment_MiddleLeft, + AnchorAlignment_MiddleCenter, + AnchorAlignment_MiddleRight, + AnchorAlignment_BottomLeft, + AnchorAlignment_BottomCenter, + AnchorAlignment_BottomRight, + END_AnchorAlignment_e, + AnchorAlignment_Invalid = BadEnumValue +} AnchorAlignment_e; + +/* BEGINREMOVEFROMADDON */ +typedef enum +{ + PositionAtAnchor_Never, + PositionAtAnchor_Once, + PositionAtAnchor_Always, + END_PositionAtAnchor_e, + PositionAtAnchor_Invalid = BadEnumValue +} PositionAtAnchor_e; +/* ENDREMOVEFROMADDON */ + +/* BEGINREMOVEFROMADDON */ +typedef struct +{ + AnchorAlignment_e AnchorAlignment; + Boolean_t AnchorHorizontalInside; + Boolean_t AnchorVerticalInside; + SmInteger_t MinVisibilityPercentage; + LgIndex_t IOffset; + LgIndex_t JOffset; + PositionAtAnchor_e PositionAtAnchor; + Boolean_t HasBeenPositioned; /* not persistent */ +} DialogPosition_s; +/* ENDREMOVEFROMADDON */ + + +#if defined EXPORT_DEPRECATED_INTERFACES_TO_ADK_ONLY +/** + * @deprecated + * Please use \ref CurveInfoMode_e instead. + */ +typedef enum +{ + ProcessXYMode_NotUsed1, /* deprecated: do not use */ + ProcessXYMode_NotUsed2, /* deprecated: do not use */ + ProcessXYMode_NotUsed3, /* deprecated: do not use */ + ProcessXYMode_NotUsed4, /* deprecated: do not use */ + ProcessXYMode_NotUsed5, /* deprecated: do not use */ + ProcessXYMode_NotUsed6, /* deprecated: do not use */ + ProcessXYMode_NotUsed7, /* deprecated: do not use */ + ProcessXYMode_NotUsed8, /* deprecated: do not use */ + ProcessXYMode_NotUsed9, /* deprecated: do not use */ + ProcessXYMode_WriteCurveCoef, /* deprecated: use CurveInfoMode_Coefficients */ + ProcessXYMode_WriteCurvePoints, /* deprecated: use CurveInfoMode_RawData */ + END_ProcessXYMode_e, + ProcessXYMode_Invalid = BadEnumValue +} ProcessXYMode_e; +#endif + +typedef enum +{ + CurveInfoMode_Coefficients, /* ProcessXYMode_WriteCurveCoef */ + CurveInfoMode_RawData, /* ProcessXYMode_WriteCurvePoints */ + CurveInfoMode_Macro, /* ProcessXYMode_WriteCurveCoefMacro */ + END_CurveInfoMode_e, + CurveInfoMode_Invalid = BadEnumValue +} CurveInfoMode_e; + +/* BEGINREMOVEFROMADDON */ +typedef enum +{ + ProcessLineMapMode_Draw, + ProcessLineMapMode_GetXYMinMax, + ProcessLineMapMode_GetDataMinMax, + ProcessLineMapMode_GetSinglePick, + ProcessLineMapMode_CheckOnlyForGroupPick, + ProcessLineMapMode_GetGroupPick, + ProcessLineMapMode_GetFirstValidDataPoint, + ProcessLineMapMode_GetNearestPoint, + ProcessLineMapMode_GetDependentValue, + ProcessLineMapMode_GetRSquaredGoodness, + ProcessLineMapMode_DisplayCurveCoef, + ProcessLineMapMode_WriteCurveCoef, + ProcessLineMapMode_WriteCurvePoints, + ProcessLineMapMode_InsertLabels, + ProcessLineMapMode_GetIndependentValue, + ProcessLineMapMode_WriteCurveCoefMacro, + END_ProcessLineMapMode_e, + ProcessLineMapMode_Invalid = BadEnumValue +} ProcessLineMapMode_e; +/* ENDREMOVEFROMADDON */ + +typedef enum +{ + StyleBase_Factory, + StyleBase_Config, + END_StyleBase_e, + StyleBase_Invalid = BadEnumValue +} StyleBase_e; + + +typedef enum +{ + ReadDataOption_NewData, + ReadDataOption_AppendData, + ReadDataOption_ReplaceData, + END_ReadDataOption_e, + ReadDataOption_Invalid = BadEnumValue +} ReadDataOption_e; + +#if defined EXPORT_DEPRECATED_INTERFACES_TO_ADK_ONLY +/** + * @deprecated + * Please use \ref LabelType_e instead. + */ +typedef enum +{ + NodeLabel_Index, /* deprecated: use LabelType_Index */ + NodeLabel_VarValue, /* deprecated: use LabelType_VarValue */ + NodeLabel_XAndYVarValue, /* deprecated: use LabelType_XAndYVarValue */ + END_NodeLabel_e, + NodeLabel_Invalid = BadEnumValue +} NodeLabel_e; +#endif + +typedef enum +{ + LabelType_Index, /* NodeLabel_Index */ + LabelType_VarValue, /* NodeLabel_VarValue */ + LabelType_XAndYVarValue, /* NodeLabel_XAndYVarValue */ + END_LabelType_e, + LabelType_Invalid = BadEnumValue +} LabelType_e; + + +#if defined EXPORT_DEPRECATED_INTERFACES_TO_ADK_ONLY +/** + * @deprecated + * Please use \ref BorderAction_e instead. + */ +typedef enum +{ + SubBoundaryEditOption_All, /* deprecated: use BorderAction_AddAll */ + SubBoundaryEditOption_Add, /* deprecated: use BorderAction_Add */ + SubBoundaryEditOption_Remove, /* deprecated: use BorderAction_Remove */ + SubBoundaryEditOption_AddOnly, /* deprecated: use BorderAction_AddOnly */ + END_SubBoundaryEditOption_e, + SubBoundaryEditOption_Invalid = BadEnumValue +} SubBoundaryEditOption_e; +#endif + +typedef enum +{ + BorderAction_AddAll, /* SubBoundaryEditOption_All */ + BorderAction_Add, /* SubBoundaryEditOption_Add */ + BorderAction_Remove, /* SubBoundaryEditOption_Remove */ + BorderAction_AddOnly, /* SubBoundaryEditOption_AddOnly */ + END_BorderAction_e, + BorderAction_Invalid = BadEnumValue +} BorderAction_e; + + +typedef enum +{ + PointerStyle_NotUsed1, + PointerStyle_NotUsed2, + PointerStyle_NotUsed3, + PointerStyle_AllDirections, + PointerStyle_NotUsed4, + PointerStyle_NotUsed5, + PointerStyle_NotUsed6, + PointerStyle_UpperLeftBracket, + PointerStyle_UpperRightBracket, + PointerStyle_LeftBracket, + PointerStyle_LowerLeftBracket, + PointerStyle_LowerRightBracket, + PointerStyle_RightBracket, + PointerStyle_BottomBracket, + PointerStyle_TopBracket, + PointerStyle_UpDown, + PointerStyle_LeftRight, + END_PointerStyle_e, + PointerStyle_Invalid = BadEnumValue +} PointerStyle_e; + +typedef enum +{ + CursorStyle_Undefined, + CursorStyle_StandardArrow, + CursorStyle_AdjusterArrow, + CursorStyle_AllDirections, + CursorStyle_Rotate, + CursorStyle_Zoom, + CursorStyle_Locate, + CursorStyle_UpperLeftBracket, + CursorStyle_UpperRightBracket, + CursorStyle_LeftBracket, + CursorStyle_LowerLeftBracket, + CursorStyle_LowerRightBracket, + CursorStyle_RightBracket, + CursorStyle_BottomBracket, + CursorStyle_TopBracket, + CursorStyle_UpDown, + CursorStyle_LeftRight, + CursorStyle_Waiting, + END_CursorStyle_e, + CursorStyle_Invalid = BadEnumValue +} CursorStyle_e; + + +typedef enum +{ + PickSubPosition_All, + PickSubPosition_Top, + PickSubPosition_Bottom, + PickSubPosition_Left, + PickSubPosition_Right, + PickSubPosition_TopLeft, + PickSubPosition_TopRight, + PickSubPosition_BottomLeft, + PickSubPosition_BottomRight, + PickSubPosition_BottomAndTop, + PickSubPosition_LeftAndRight, + END_PickSubPosition_e, + PickSubPosition_Invalid = BadEnumValue +} PickSubPosition_e; + +typedef enum +{ + TecEngInitReturnCode_Ok, + TecEngInitReturnCode_LicenseIsInvalid, + TecEngInitReturnCode_LicenseExpired, + TecEngInitReturnCode_InternalInitializationError, + END_TecEngInitReturnCode_e, + TecEngInitReturnCode_Invalid = BadEnumValue +} TecEngInitReturnCode_e; + +typedef enum +{ + GetValueReturnCode_Ok, + GetValueReturnCode_ResultTypeError, + GetValueReturnCode_SyntaxError, + GetValueReturnCode_ContextError, + GetValueReturnCode_DeprecatedError, + END_GetValueReturnCode_e, + GetValueReturnCode_Invalid = BadEnumValue, + /* deprecated values */ + GetValue_Ok = GetValueReturnCode_Ok, /* deprecated */ + GetValue_ResultTypeError = GetValueReturnCode_ResultTypeError, /* deprecated */ + GetValue_SyntaxError = GetValueReturnCode_SyntaxError, /* deprecated */ + GetValue_ContextError = GetValueReturnCode_ContextError, /* deprecated */ + GetValue_DeprecatedError = GetValueReturnCode_DeprecatedError, /* deprecated */ + GetValue_Invalid = GetValueReturnCode_Invalid /* deprecated */ +} GetValueReturnCode_e; + +typedef enum +{ + SetValueReturnCode_Ok, + SetValueReturnCode_DuplicateValue, + SetValueReturnCode_InvalidCommandOption, + SetValueReturnCode_NoAttachedDatasetError, + SetValueReturnCode_NoAttachedFrameError, + SetValueReturnCode_NotAllowedInConfigError, + SetValueReturnCode_ValueRangeError, + SetValueReturnCode_ValueSyntaxError, + SetValueReturnCode_AssignOpError, + SetValueReturnCode_InvalidVarOrZone, + SetValueReturnCode_InternalMemoryError, + SetValueReturnCode_ContextError1, + SetValueReturnCode_ContextError2, + SetValueReturnCode_OnlyAllowedInConfigError, + SetValueReturnCode_FeatureNotAvailable, + END_SetValueReturnCode_e, + /* BEGINREMOVEFROMADDON */ + /* For now this value is only used in Tecplot code. + * the value is here as an option for the future. */ + SetValueReturnCode_Ignored = SetValueReturnCode_DuplicateValue, + /* ENDREMOVEFROMADDON */ + SetValueReturnCode_Invalid = BadEnumValue, + /* deprecated values */ + SetValue_Ok = SetValueReturnCode_Ok, /* deprecated */ + SetValue_DuplicateValue = SetValueReturnCode_DuplicateValue, /* deprecated */ + SetValue_InvalidCommandOption = SetValueReturnCode_InvalidCommandOption, /* deprecated */ + SetValue_NoAttachedDatasetError = SetValueReturnCode_NoAttachedDatasetError, /* deprecated */ + SetValue_NoAttachedFrameError = SetValueReturnCode_NoAttachedFrameError, /* deprecated */ + SetValue_NotAllowedInConfigError = SetValueReturnCode_NotAllowedInConfigError, /* deprecated */ + SetValue_ValueRangeError = SetValueReturnCode_ValueRangeError, /* deprecated */ + SetValue_ValueSyntaxError = SetValueReturnCode_ValueSyntaxError, /* deprecated */ + SetValue_AssignOpError = SetValueReturnCode_AssignOpError, /* deprecated */ + SetValue_InvalidVarOrZone = SetValueReturnCode_InvalidVarOrZone, /* deprecated */ + SetValue_InternalMemoryError = SetValueReturnCode_InternalMemoryError, /* deprecated */ + SetValue_ContextError1 = SetValueReturnCode_ContextError1, /* deprecated */ + SetValue_ContextError2 = SetValueReturnCode_ContextError2, /* deprecated */ + SetValue_OnlyAllowedInConfigError = SetValueReturnCode_OnlyAllowedInConfigError, /* deprecated */ + SetValue_FeatureNotAvailable = SetValueReturnCode_FeatureNotAvailable, /* deprecated */ + /* BEGINREMOVEFROMADDON */ + SetValue_Ignored = SetValueReturnCode_Ignored, /* deprecated */ + /* ENDREMOVEFROMADDON */ + SetValue_Invalid = SetValueReturnCode_Invalid /* deprecated */ +} SetValueReturnCode_e; + + +typedef enum +{ + ObjectAlign_LeftJustify, + ObjectAlign_RightJustify, + ObjectAlign_Center, + ObjectAlign_Top, + ObjectAlign_Bottom, + END_ObjectAlign_e, + ObjectAlign_Invalid = BadEnumValue +} ObjectAlign_e; + + +/* + * For 3D axis labels only. + */ +typedef enum +{ + LabelAlignment_ByAngle, + LabelAlignment_AlongAxis, + LabelAlignment_PerpendicularToAxis, + END_LabelAlignment_e, + LabelAlignment_Invalid = BadEnumValue +} LabelAlignment_e; /* <help> Label alignment for 3D axis labels only" */ + +/* + * View_SetMagnification added 02/24/03 so all plot types + * can behave the same way "do a 'centered' magnifacation change". + * Line plots will still accept View_Scale option and zoom towards + * the corner so old macros/addons still work. + */ +typedef enum +{ + View_Fit, + View_DataFit, + View_AxisFit, + View_Scale, /* deprecated, Use SetMagnification */ + View_Center, + View_Translate, + View_Zoom, + View_Last, + View_Copy, + View_Paste, + View_Push, /* End of V9 enums */ + View_SetMagnification, + View_NiceFit, + View_AxisNiceFit, + View_MakeCurrentViewNice, + View_AxisMakeCurrentValuesNice, + View_AxisResetToEntireCircle, + View_FitSurfaces, + END_View_e, + View_Invalid = BadEnumValue +} View_e; + + + +typedef enum +{ + WorkspaceView_FitSelectedFrames, + WorkspaceView_FitAllFrames, + WorkspaceView_FitPaper, + WorkspaceView_Maximize, + WorkspaceView_LastView, + WorkspaceView_Zoom, + WorkspaceView_Translate, + WorkspaceView_UnMaximize, + END_WorkspaceView_e, + WorkspaceView_Invalid = BadEnumValue +} WorkspaceView_e; + + +typedef enum +{ + ArrowheadStyle_Plain, + ArrowheadStyle_Filled, + ArrowheadStyle_Hollow, + END_ArrowheadStyle_e, + ArrowheadStyle_Invalid = BadEnumValue, + /* deprecated values */ + Arrowhead_Plain = ArrowheadStyle_Plain, /* deprecated */ + Arrowhead_Filled = ArrowheadStyle_Filled, /* deprecated */ + Arrowhead_Hollow = ArrowheadStyle_Hollow, /* deprecated */ + Arrowhead_Invalid = ArrowheadStyle_Invalid /* deprecated */ +} ArrowheadStyle_e; + + +typedef enum +{ + ArrowheadAttachment_None, + ArrowheadAttachment_AtBeginning, + ArrowheadAttachment_AtEnd, + ArrowheadAttachment_AtBothEnds, + END_ArrowheadAttachment_e, + ArrowheadAttachment_Invalid = BadEnumValue, + /* deprecated values */ + ArrowheadAttach_None = ArrowheadAttachment_None, /* deprecated */ + ArrowheadAttach_AtBeginning = ArrowheadAttachment_AtBeginning, /* deprecated */ + ArrowheadAttach_AtEnd = ArrowheadAttachment_AtEnd, /* deprecated */ + ArrowheadAttach_AtBothEnds = ArrowheadAttachment_AtBothEnds, /* deprecated */ + ArrowheadAttach_Invalid = ArrowheadAttachment_Invalid /* deprecated */ +} ArrowheadAttachment_e; + +typedef enum +{ + Clipping_ClipToViewport, + Clipping_ClipToFrame, + END_Clipping_e, + Clipping_Invalid = BadEnumValue +} Clipping_e; + +typedef enum +{ + StatusInfo_Hover, + StatusInfo_Identify, + StatusInfo_Instruction, + StatusInfo_Working, + StatusInfo_PercentDone, + END_StatusInfo_e, + StatusInfo_Invalid = BadEnumValue +} StatusInfo_e; + + +#if defined EXPORT_DEPRECATED_INTERFACES_TO_ADK_ONLY +/** + * @deprecated + * Please use \ref PlotType_e instead. + */ +typedef enum +{ + FrameMode_Empty, /* deprecated: use PlotType_Automatic */ + FrameMode_ThreeD, /* deprecated: use PlotType_Cartesian3D */ + FrameMode_TwoD, /* deprecated: use PlotType_Cartesian2D */ + FrameMode_XY, /* deprecated: use PlotType_XYLine */ + FrameMode_Sketch, /* deprecated: use PlotType_Sketch */ + END_FrameMode_e, + FrameMode_Invalid = BadEnumValue, + /* deprecated values */ + Frame_Empty = FrameMode_Empty, /* deprecated */ + Frame_ThreeD = FrameMode_ThreeD, /* deprecated */ + Frame_TwoD = FrameMode_TwoD, /* deprecated */ + Frame_XY = FrameMode_XY, /* deprecated */ + Frame_Sketch = FrameMode_Sketch, /* deprecated */ + Frame_Invalid = FrameMode_Invalid /* deprecated */ +} FrameMode_e; +#endif + + +typedef enum +{ + PlotType_Automatic, /* Frame_Empty */ + PlotType_Cartesian3D, /* Frame_ThreeD */ + PlotType_Cartesian2D, /* Frame_TwoD */ + PlotType_XYLine, /* Frame_XY */ + PlotType_Sketch, /* Frame_Sketch */ + PlotType_PolarLine, + END_PlotType_e, + PlotType_Invalid = BadEnumValue +} PlotType_e; + + +#define VALID_PLOTTYPE(PlotType) ( VALID_ENUM((PlotType), PlotType_e) && \ + ((PlotType) != PlotType_Automatic) ) +#define VALID_LINEPLOT_PLOTTYPE(PlotType) ( (PlotType) == PlotType_XYLine || \ + (PlotType) == PlotType_PolarLine ) +#define VALID_FIELDPLOT_PLOTTYPE(PlotType) ( (PlotType) == PlotType_Cartesian2D || \ + (PlotType) == PlotType_Cartesian3D ) +#define PLOTTYPE_USES_FIELDZONES(PlotType) VALID_FIELDPLOT_PLOTTYPE((PlotType)) +#define PLOTTYPE_USES_LINEMAPS(PlotType) VALID_LINEPLOT_PLOTTYPE((PlotType)) +#define VALID_V9_PLOTTYPE(PlotType) ( (PlotType) == PlotType_Sketch || \ + (PlotType) == PlotType_XYLine || \ + (PlotType) == PlotType_Cartesian2D || \ + (PlotType) == PlotType_Cartesian3D ) + + +typedef enum +{ + ContLineCreateMode_OneZonePerContourLevel, + ContLineCreateMode_OneZonePerIndependentPolyline, + END_ContLineCreateMode_e, + ContLineCreateMode_Invalid = BadEnumValue +} ContLineCreateMode_e; + + +typedef enum +{ + PickObjects_None, + PickObjects_Frame, + PickObjects_Axis, + PickObjects_ThreeDOrientationAxis, + PickObjects_Geom, + PickObjects_Text, + PickObjects_ContourLegend, + PickObjects_ContourLabel, + PickObjects_ScatterLegend, + PickObjects_LineLegend, + PickObjects_ReferenceVector, + PickObjects_ReferenceScatterSymbol, + PickObjects_StreamtracePosition, + PickObjects_StreamtraceTermLine, + PickObjects_Paper, + PickObjects_Zone, + PickObjects_XYMapping, /* deprecated: use PickObject_LineMapping */ + PickObjects_StreamtraceCOB, + PickObjects_SliceCOB, + PickObjects_IsoSurfaceCOB, + PickObjects_RGBLegend, + PickObjects_LineMapping, + END_PickObjects_e, + PickObjects_Invalid = BadEnumValue, + /* deprecated values */ + PickObject_None = PickObjects_None, /* deprecated */ + PickObject_Frame = PickObjects_Frame, /* deprecated */ + PickObject_Axis = PickObjects_Axis, /* deprecated */ + PickObject_3DOrientationAxis = PickObjects_ThreeDOrientationAxis, /* deprecated */ + PickObject_Geom = PickObjects_Geom, /* deprecated */ + PickObject_Text = PickObjects_Text, /* deprecated */ + PickObject_ContourLegend = PickObjects_ContourLegend, /* deprecated */ + PickObject_ContourLabel = PickObjects_ContourLabel, /* deprecated */ + PickObject_ScatterLegend = PickObjects_ScatterLegend, /* deprecated */ + PickObject_LineLegend = PickObjects_LineLegend, /* deprecated */ + PickObject_XYLegend = PickObjects_LineLegend, /* deprecated */ + PickObject_ReferenceVector = PickObjects_ReferenceVector, /* deprecated */ + PickObject_ReferenceScatterSymbol = PickObjects_ReferenceScatterSymbol, /* deprecated */ + PickObject_StreamtracePosition = PickObjects_StreamtracePosition, /* deprecated */ + PickObject_StreamtraceTermLine = PickObjects_StreamtraceTermLine, /* deprecated */ + PickObject_Paper = PickObjects_Paper, /* deprecated */ + PickObject_Zone = PickObjects_Zone, /* deprecated */ + PickObject_XYMapping = PickObjects_XYMapping, /* deprecated */ + PickObject_StreamtraceCOB = PickObjects_StreamtraceCOB, /* deprecated */ + PickObject_SliceCOB = PickObjects_SliceCOB, /* deprecated */ + PickObject_IsoSurfaceCOB = PickObjects_IsoSurfaceCOB, /* deprecated */ + PickObject_RGBLegend = PickObjects_RGBLegend, /* deprecated */ + PickObject_LineMapping = PickObjects_LineMapping, /* deprecated */ + PickObject_Invalid = PickObjects_Invalid /* deprecated */ +} PickObjects_e; + + +/* BEGINREMOVEFROMADDON */ +typedef enum +{ + SingleEditState_NotEditing, + SingleEditState_ActivelyEditing, + SingleEditState_WasEditing, + END_SingleEditState_e, + EditingInvalid = BadEnumValue +} SingleEditState_e; + + +typedef enum +{ + AxisSubObject_GridArea, + AxisSubObject_AxisLine, + AxisSubObject_Title, + END_AxisSubObject_e, + AxisSubObject_Invalid = BadEnumValue +} AxisSubObject_e; + +typedef enum +{ + AxisSubPosition_GridMinBorder, + AxisSubPosition_GridMaxBorder, + AxisSubPosition_MainAxisLine, + AxisSubPosition_BackAxisLine, + AxisSubPosition_PerpAxisLine, + AxisSubPosition_PerpBackAxisLine, + END_AxisSubPosition_e, + AxisSubPosition_Invalid = BadEnumValue, + AxisSubPosition_2DStart = AxisSubPosition_GridMinBorder, + AxisSubPosition_2DEnd = AxisSubPosition_MainAxisLine, + AxisSubPosition_PolarStart = AxisSubPosition_GridMinBorder, + AxisSubPosition_PolarEnd = AxisSubPosition_PerpBackAxisLine +} AxisSubPosition_e; +/* ENDREMOVEFROMADDON */ + +/* + * NOTE: The _NoOp value is not at the top so this + * enumeration aligns with the old AltMouseButtonMode_e + * enumeration. + */ +typedef enum +{ + MouseButtonClick_Redraw, + MouseButtonClick_RevertToSelect, + MouseButtonClick_NoOp, + END_MouseButtonClick_e, + MouseButtonClick_Invalid = BadEnumValue +} MouseButtonClick_e; + + +typedef enum +{ + MouseButtonDrag_NoOp, + MouseButtonDrag_ZoomPaper, + MouseButtonDrag_TranslatePaper, + MouseButtonDrag_ZoomData, + MouseButtonDrag_TranslateData, + MouseButtonDrag_RlrBallRtatData, + MouseButtonDrag_SpherRtatData, + MouseButtonDrag_XRotateData, + MouseButtonDrag_YRotateData, + MouseButtonDrag_ZRotateData, + MouseButtonDrag_TwistRotateData, + MouseButtonDrag_ZoomViewer, + MouseButtonDrag_TranslateViewer, + MouseButtonDrag_RlrBallRtatVwr, + MouseButtonDrag_SpherRotateVwr, + MouseButtonDrag_XRotateViewer, + MouseButtonDrag_YRotateViewer, + MouseButtonDrag_ZRotateViewer, + MouseButtonDrag_TwistRotateViewer, + END_MouseButtonDrag_e, + MouseButtonDrag_Invalid = BadEnumValue +} MouseButtonDrag_e; + + +/* BEGINREMOVEFROMADDON */ +typedef struct +{ + MouseButtonClick_e ButtonClick; + MouseButtonDrag_e SimpleDrag; + MouseButtonDrag_e ControlledDrag; + MouseButtonDrag_e AltedDrag; + MouseButtonDrag_e ShiftedDrag; + MouseButtonDrag_e ControlAltedDrag; + MouseButtonDrag_e ControlShiftedDrag; + MouseButtonDrag_e AltShiftedDrag; + MouseButtonDrag_e ControlAltShiftedDrag; +} MouseButtonAction_s; + + +typedef struct +{ + MouseButtonAction_s MiddleButton; + MouseButtonAction_s RightButton; +} MouseActions_s; +/* ENDREMOVEFROMADDON */ + + +typedef enum /* deprecated */ +{ + AltMouseButtonMode_Regen, + AltMouseButtonMode_RevertToSelect, + END_AltMouseButtonMode_e, + AltMouseButtonMode_Invalid = BadEnumValue +} AltMouseButtonMode_e; + + +typedef enum +{ + MouseButtonMode_NoMode, + MouseButtonMode_Select, + MouseButtonMode_Adjust, + MouseButtonMode_Zoom, + MouseButtonMode_Translate, + MouseButtonMode_Probe, + MouseButtonMode_Text, + MouseButtonMode_GeomPolyline, + MouseButtonMode_GeomSquare, + MouseButtonMode_GeomCircle, + MouseButtonMode_GeomRectangle, + MouseButtonMode_GeomEllipse, + MouseButtonMode_GeomSpline, + MouseButtonMode_CreateFrame, + MouseButtonMode_RotateSpherical, + MouseButtonMode_RotateRollerBall, + MouseButtonMode_RotateTwist, + MouseButtonMode_RotateXAxis, + MouseButtonMode_RotateYAxis, + MouseButtonMode_RotateZAxis, + MouseButtonMode_ContourLabel, + MouseButtonMode_ContourAdd, + MouseButtonMode_ContourDelete, + MouseButtonMode_StreamPoints, + MouseButtonMode_StreamEndLine, + MouseButtonMode_ExtractPoints, + MouseButtonMode_ExtractLine, + MouseButtonMode_CreateRectangularZone, + MouseButtonMode_CreateCircularZone, + MouseButtonMode_Slice, + MouseButtonMode_LightSource, + MouseButtonMode_User1, + MouseButtonMode_User2, + MouseButtonMode_User3, + MouseButtonMode_User4, + END_MouseButtonMode_e, + MouseButtonMode_Invalid = BadEnumValue, + /* deprecated values */ + Mouse_NoMode = MouseButtonMode_NoMode, /* deprecated */ + Mouse_Select = MouseButtonMode_Select, /* deprecated */ + Mouse_Adjust = MouseButtonMode_Adjust, /* deprecated */ + Mouse_Zoom = MouseButtonMode_Zoom, /* deprecated */ + Mouse_Translate = MouseButtonMode_Translate, /* deprecated */ + Mouse_Probe = MouseButtonMode_Probe, /* deprecated */ + Mouse_Text = MouseButtonMode_Text, /* deprecated */ + Mouse_GeomPolyline = MouseButtonMode_GeomPolyline, /* deprecated */ + Mouse_GeomSquare = MouseButtonMode_GeomSquare, /* deprecated */ + Mouse_GeomCircle = MouseButtonMode_GeomCircle, /* deprecated */ + Mouse_GeomRectangle = MouseButtonMode_GeomRectangle, /* deprecated */ + Mouse_GeomEllipse = MouseButtonMode_GeomEllipse, /* deprecated */ + Mouse_GeomSpline = MouseButtonMode_GeomSpline, /* deprecated */ + Mouse_CreateFrame = MouseButtonMode_CreateFrame, /* deprecated */ + Mouse_RotateSpherical = MouseButtonMode_RotateSpherical, /* deprecated */ + Mouse_RotateRollerBall = MouseButtonMode_RotateRollerBall, /* deprecated */ + Mouse_RotateTwist = MouseButtonMode_RotateTwist, /* deprecated */ + Mouse_RotateXAxis = MouseButtonMode_RotateXAxis, /* deprecated */ + Mouse_RotateYAxis = MouseButtonMode_RotateYAxis, /* deprecated */ + Mouse_RotateZAxis = MouseButtonMode_RotateZAxis, /* deprecated */ + Mouse_ContourLabel = MouseButtonMode_ContourLabel, /* deprecated */ + Mouse_ContourAdd = MouseButtonMode_ContourAdd, /* deprecated */ + Mouse_ContourDelete = MouseButtonMode_ContourDelete, /* deprecated */ + Mouse_StreamPoints = MouseButtonMode_StreamPoints, /* deprecated */ + Mouse_StreamEndLine = MouseButtonMode_StreamEndLine, /* deprecated */ + Mouse_ExtractPoints = MouseButtonMode_ExtractPoints, /* deprecated */ + Mouse_ExtractLine = MouseButtonMode_ExtractLine, /* deprecated */ + Mouse_CreateRectangularZone = MouseButtonMode_CreateRectangularZone, /* deprecated */ + Mouse_CreateCircularZone = MouseButtonMode_CreateCircularZone, /* deprecated */ + Mouse_Slice = MouseButtonMode_Slice, /* deprecated */ + Mouse_User1 = MouseButtonMode_User1, /* deprecated */ + Mouse_User2 = MouseButtonMode_User2, /* deprecated */ + Mouse_User3 = MouseButtonMode_User3, /* deprecated */ + Mouse_User4 = MouseButtonMode_User4, /* deprecated */ + Mouse_Invalid = MouseButtonMode_Invalid /* deprecated */ +} MouseButtonMode_e; + + +typedef enum +{ + DetailsButtonState_QuickEdit, + DetailsButtonState_ObjectDetails, + DetailsButtonState_ToolDetails, + END_DetailsButtonState_e, + DetailsButtonState_Invalid = BadEnumValue +} DetailsButtonState_e; + + +typedef enum +{ + Event_ButtonPress, + Event_ButtonRelease, + Event_ButtonDoublePress, + Event_Motion, + Event_Drag, + Event_KeyPress, + END_Event_e, + Event_Invalid = BadEnumValue +} Event_e; + + +typedef enum +{ + ObjectDrawMode_DrawFirst, + ObjectDrawMode_Move, + ObjectDrawMode_Remove, + ObjectDrawMode_Place, + END_ObjectDrawMode_e, + ObjectDrawMode_Invalid = BadEnumValue +} ObjectDrawMode_e; + + +typedef enum +{ + ThreeDViewChangeDrawLevel_Full, + ThreeDViewChangeDrawLevel_Trace, + END_ThreeDViewChangeDrawLevel_e, + ThreeDViewChangeDrawLevel_Invalid = BadEnumValue +} ThreeDViewChangeDrawLevel_e; /* <help> "ThreeDViewChangeDrawLevel is deprecated. Use PlotApproximateMode.\n"*/ + +typedef enum +{ + NonCurrentFrameRedrawLevel_Full, + NonCurrentFrameRedrawLevel_Trace, + END_NonCurrentFrameRedrawLevel_e, + NonCurrentFrameRedrawLevel_Invalid = BadEnumValue +} NonCurrentFrameRedrawLevel_e; /* <help> "NonCurrentFrameRedrawLevel is deprecated. Use PlotApproximateMode.\n"*/ + + +/** + * Enumerates the redraw reasons and is passed as an argument to registered + * draw event callbacks. + * + * - RedrawReason_UserReqRedrawActiveFrame:\n + * The full draw event is in response to the "redraw" action function. + * + * - RedrawReason_UserReqTraceActiveFrame:\n + * The approximate draw event is in response to the "redraw" action function. + * + * - RedrawReason_UserReqRedrawAllFrames:\n + * The full draw event is in response to the "redraw all" action function. + * + * - RedrawReason_UserReqTraceAllFrames:\n + * The approximate draw event is in response to the "redraw all" action function. + * + * - RedrawReason_InteractiveDataViewChange:\n + * The draw event is in response to an interactive data view change such as + * rotate, translate, zoom, etc. + * + * - RedrawReason_InteractivePaperViewChange:\n + * The draw event is in response to an interactive paper translate view or + * paper zoom view change. + * + * - RedrawReason_InteractiveStyleChange:\n + * The draw event is in response to an interactive style changes such as + * dragging a contour level or a slice. + * + * - RedrawReason_Animation:\n + * The draw event is in response to an animation. + * + * - RedrawReason_AutoRedraw:\n + * The draw event is in response to an auto redraw. + * + * - RedrawReason_RedrawForcedViewUpdate:\n + * The draw event is in response to forced view update when auto redraw is + * off such as a view fit or movement of the frame. + * + * - RedrawReason_RedrawForcedStyleUpdate:\n + * The draw event is in response to forced view update when auto redraw is + * off such as deleting a contour level. + * + * - RedrawReason_PreFullRedrawTraceOfAllFrames:\n + * The draw event is an approximate redraw done prior to a full redraw. + * + * @sa TecUtilEventAddPreDrawCallback(), TecUtilEventAddPostDrawCallback() + */ +typedef enum +{ + RedrawReason_UserReqRedrawActiveFrame, + RedrawReason_UserReqTraceActiveFrame, + RedrawReason_UserReqRedrawAllFrames, + RedrawReason_UserReqTraceAllFrames, + RedrawReason_InteractiveDataViewChange, + RedrawReason_InteractivePaperViewChange, + RedrawReason_InteractiveStyleChange, + RedrawReason_Animation, + RedrawReason_AutoRedraw, + RedrawReason_RedrawForcedViewUpdate, + RedrawReason_RedrawForcedStyleUpdate, + RedrawReason_PreFullRedrawTraceOfAllFrames, + END_RedrawReason_e, + RedrawReason_Invalid = BadEnumValue, + RedrawReason_UserReqRedrawCurrentFrame = RedrawReason_UserReqRedrawActiveFrame, + RedrawReason_UserReqTraceCurrentFrame = RedrawReason_UserReqTraceActiveFrame +} RedrawReason_e; + +typedef enum +{ + RotationMode_XYZAxis, + RotationMode_Spherical, + RotationMode_RollerBall, + END_RotationMode_e, + RotationMode_Invalid = BadEnumValue +} RotationMode_e; + +typedef enum +{ + RotateAxis_X, + RotateAxis_Y, + RotateAxis_Z, + RotateAxis_Psi, + RotateAxis_Theta, + RotateAxis_Alpha, + RotateAxis_Twist, + RotateAxis_VertRollerBall, + RotateAxis_HorzRollerBall, + RotateAxis_AboutVector, + /* BEGINREMOVEFROMADDON */ + RotateAxis_DontCare, /* internal use only */ + /* ENDREMOVEFROMADDON */ + END_RotateAxis_e, + RotateAxis_Invalid = BadEnumValue +} RotateAxis_e; + +typedef enum +{ + RotateOriginLocation_DefinedOrigin, + RotateOriginLocation_Viewer, + END_RotateOriginLocation_e, + RotateOriginLocation_Invalid = BadEnumValue +} RotateOriginLocation_e; + +/* + * NOTE: This is only used with the $!Reset3DOrigin command. + */ +typedef enum +{ + OriginResetLocation_DataCenter, + OriginResetLocation_ViewCenter, + END_OriginResetLocation_e, + OriginResetLocation_Invalid = BadEnumValue +} OriginResetLocation_e; + +/* + * NOTE: This is only used with the $!CreateSliceZoneFromPlane command. + */ +typedef enum +{ + SliceSource_SurfaceZones, + SliceSource_VolumeZones, + SliceSource_SurfacesOfVolumeZones, + SliceSource_LinearZones, + END_SliceSource_e, + SliceSource_Invalid = BadEnumValue +} SliceSource_e; + + + + + +typedef enum +{ + Input_SmInteger, + Input_Short, + Input_Integer, + Input_Float, + Input_Double, + Input_Radians, + Input_TimeDateDouble, + Input_ElapsedTimeDouble, + END_Input_e, + Input_Invalid = BadEnumValue +} Input_e; + + + +typedef enum +{ + PtSelection_All, + PtSelection_NearestN, + PtSelection_OctantN, + END_PtSelection_e, + PtSelection_Invalid = BadEnumValue +} PtSelection_e; + + + +typedef enum +{ + Drift_None, + Drift_Linear, + Drift_Quad, + END_Drift_e, + Drift_Invalid = BadEnumValue +} Drift_e; + + + +/* atpoint is simple boundary condition. + atpointb2 is better boundary condition. +*/ +typedef enum +{ + DerivPos_atpoint, + DerivPos_atpointb2, + DerivPos_kphalf, + DerivPos_jphalf, + DerivPos_iphalf, + END_DerivPos_e, + DerivPos_Invalid = BadEnumValue +} DerivPos_e; /*<help>"atpoint is the simple boundary condition\n"*/ +/*<help>"atpointb2 is a better boundary condition"*/ + + +typedef enum +{ + LinearInterpMode_DontChange, + LinearInterpMode_SetToConst, + END_LinearInterpMode_e, + LinearInterpMode_Invalid = BadEnumValue +} LinearInterpMode_e; + +typedef enum +{ + VolumeCellInterpolationMode_PiecewiseLinear, + VolumeCellInterpolationMode_TriLinear, + END_VolumeCellInterpolationMode_e, + VolumeCellInterpolationMode_Invalid = BadEnumValue +} VolumeCellInterpolationMode_e; + +typedef enum +{ + PolyCellInterpolationMode_UseCCValue, + PolyCellInterpolationMode_AverageNodes, + END_PolyCellInterpolationMode_e, + PolyCellInterpolationMode_Invalid = BadEnumValue +} PolyCellInterpolationMode_e; + +typedef enum +{ + ConstraintOp2Mode_UseVar, + ConstraintOp2Mode_UseConstant, + END_ConstraintOp2Mode_e, + ConstraintOp2Mode_Invalid = BadEnumValue +} ConstraintOp2Mode_e; + +/** + * Controls how data is loaded for interactive probe events. + * DataProbeVarLoadMode_IncrementallyLoadAll will load as much data as possible within + * load-on-demand time/space thresholds. DataProbeVarLoadMode_LoadRequiredVarsOnly will + * load only the data necessary to complete the probe request. + * DataProbeVarLoadMode_IncrementallyLoadAll is the default. + */ +typedef enum +{ + DataProbeVarLoadMode_IncrementallyLoadAll, + DataProbeVarLoadMode_LoadRequiredVarsOnly, + END_DataProbeVarLoadMode_e, + DataProbeVarLoadMode_Invalid = BadEnumValue +} DataProbeVarLoadMode_e; + +typedef enum +{ + ValueBlankCellMode_AllCorners, + ValueBlankCellMode_AnyCorner, + ValueBlankCellMode_PrimaryValue, + END_ValueBlankCellMode_e, + ValueBlankCellMode_Invalid = BadEnumValue, + /* deprecated values */ + ValueBlankCellMode_PrimaryCorner = ValueBlankCellMode_PrimaryValue +} ValueBlankCellMode_e; + + +/* + * deprecated: ValueBlankMode_e enumeration will not be supported after + * version 8. This API was retained for add-on developers + * using the TecUtilStyleSetLowLevel API. + */ +typedef enum +{ + ValueBlankMode_AndRule, + ValueBlankMode_OrRule, + ValueBlankMode_CornerRule, + END_ValueBlankMode_e, + ValueBlankMode_Invalid = BadEnumValue +} ValueBlankMode_e; /*<help>"DEPRECATED: ValueBlankMode_e will not be supported after version 8"*/ + + +typedef enum +{ + CellBlankedCond_NotBlanked, + CellBlankedCond_PartiallyBlanked, + CellBlankedCond_EntirelyBlanked, + CellBlankedCond_Uncertain, + END_CellBlankedCond_e, + CellBlankedCond_Invalid = BadEnumValue +} CellBlankedCond_e; + + +typedef enum +{ + RelOp_LessThanOrEqual, + RelOp_GreaterThanOrEqual, + RelOp_LessThan, + RelOp_GreaterThan, + RelOp_EqualTo, + RelOp_NotEqualTo, + END_RelOp_e, + RelOp_Invalid = BadEnumValue +} RelOp_e; + + + +typedef enum +{ + IJKBlankMode_BlankInterior, + IJKBlankMode_BlankExterior, + END_IJKBlankMode_e, + IJKBlankMode_Invalid = BadEnumValue +} IJKBlankMode_e; + + +typedef enum +{ + PlotApproximationMode_Automatic, + PlotApproximationMode_NonCurrentAlwaysApproximated, + PlotApproximationMode_AllFramesAlwaysApproximated, + END_PlotApproximationMode_e, + PlotApproximationMode_Invalid = BadEnumValue +} PlotApproximationMode_e; + +typedef enum +{ + SphereScatterRenderQuality_Low, + SphereScatterRenderQuality_Medium, + SphereScatterRenderQuality_High, + END_SphereScatterRenderQuality_e, + SphereScatterRenderQuality_Invalid = BadEnumValue +} SphereScatterRenderQuality_e; + +/* + * NOTE: FillPat_e is deprecated. It must be retained to maintain + * backward compatibility with the TecUtil layer however. + * This has been replaced by Translucency_e. + */ +typedef enum +{ + Pattern_Solid, + Pattern_LowTranslucent, + Pattern_MedTranslucent, + Pattern_HighTranslucent, + END_FillPat_e, + Pattern_Invalid = BadEnumValue +} FillPat_e; /*<help>"DEPRECATED: Replaced by Translucency_e"*/ + + +typedef enum +{ + Translucency_Solid, + Translucency_Low, + Translucency_Medium, + Translucency_High, + END_Translucency_e, + Translucency_Invalid = BadEnumValue +} Translucency_e; + + + +typedef enum +{ + SunRaster_OldFormat, + SunRaster_Standard, + SunRaster_ByteEncoded, + END_SunRaster_e, + SunRaster_Invalid = BadEnumValue +} SunRaster_e; + + +typedef enum +{ + BoundaryCondition_Fixed, + BoundaryCondition_ZeroGradient, + BoundaryCondition_Zero2nd, + END_BoundaryCondition_e, + BoundaryCondition_Invalid = BadEnumValue +} BoundaryCondition_e; + + + +/* Note: + * In 2D: AxisMode_Independent and AxisMode_XYDependent are used; + * in 3D: AxisMode_Independent, AxisMode_XYZDependent, and AxisMode_XYDependent are used. + */ +typedef enum +{ + AxisMode_Independent, + AxisMode_XYZDependent, + AxisMode_XYDependent, + END_AxisMode_e, + AxisMode_Invalid = BadEnumValue +} AxisMode_e;/*<help>"In 2D AxisMode_Independent and AxisMode_XYDependent are used\n"*/ +/*<help>"In 3D AxisMode_Independent, "*/ +/*<help>"AxisMode_XYZDependent, and AxisMode_XYDependent are used."*/ + +typedef enum +{ + Quick_LineColor, + Quick_FillColor, + Quick_TextColor, + END_QuickColorMode_e, + Quick_Invalid = BadEnumValue +} QuickColorMode_e; + + +typedef enum +{ + FillMode_None, + FillMode_UseSpecificColor, + FillMode_UseLineColor, + FillMode_UseBackgroundColor, + END_FillMode_e, + FillMode_Invalid = BadEnumValue +} FillMode_e; + + +typedef enum +{ + LinePattern_Solid, + LinePattern_Dashed, + LinePattern_DashDot, + LinePattern_Dotted, + LinePattern_LongDash, + LinePattern_DashDotDot, + END_LinePattern_e, + LinePattern_Invalid = BadEnumValue +} LinePattern_e; + + + +typedef enum +{ + Join_Miter, + Join_Round, + Join_Bevel, + END_LineJoin_e, + Join_Invalid = BadEnumValue +} LineJoin_e; + + + +typedef enum +{ + Cap_Flat, + Cap_Round, + Cap_Square, + END_LineCap_e, + Cap_Invalid = BadEnumValue +} LineCap_e; + + + +typedef enum +{ + GeomForm_LineSegs, + GeomForm_Rectangle, + GeomForm_Square, + GeomForm_Circle, + GeomForm_Ellipse, + GeomForm_LineSegs3D, /* deprecated: use GeomForm_LineSegs with CoordSys_Grid3D */ + GeomForm_Image, + END_GeomForm_e, + GeomForm_Invalid = BadEnumValue, + /* new value names */ + GeomType_LineSegs = GeomForm_LineSegs, + GeomType_Rectangle = GeomForm_Rectangle, + GeomType_Square = GeomForm_Square, + GeomType_Circle = GeomForm_Circle, + GeomType_Ellipse = GeomForm_Ellipse, + GeomType_LineSegs3D = GeomForm_LineSegs3D, /* deprecated: use GeomType_LineSegs with CoordSys_Grid3D */ + GeomType_Image = GeomForm_Image, + END_GeomType_e = END_GeomForm_e, + GeomType_Invalid = GeomForm_Invalid +} GeomForm_e; + +typedef GeomForm_e GeomType_e; + +typedef enum +{ + VariableDerivationMethod_Fast, + VariableDerivationMethod_Accurate, + END_VariableDerivationMethod_e, + VariableDerivationMethod_Invalid = BadEnumValue +} VariableDerivationMethod_e; + +/** + */ +typedef enum +{ + AuxDataType_String, + END_AuxDataType_e, + AuxDataType_Invalid = BadEnumValue +} AuxDataType_e; + +/** + */ +typedef enum +{ + AuxDataLocation_Zone, + AuxDataLocation_DataSet, + AuxDataLocation_Frame, + AuxDataLocation_Var, + AuxDataLocation_LineMap, + AuxDataLocation_Page, + END_AuxDataLocation_e, + AuxDataLocation_Invalid = BadEnumValue +} AuxDataLocation_e; + + +/* Note: This replaces Element_e */ +typedef enum +{ + ZoneType_Ordered, + ZoneType_FETriangle, + ZoneType_FEQuad, + ZoneType_FETetra, + ZoneType_FEBrick, + ZoneType_FELineSeg, + ZoneType_FEPolygon, + ZoneType_FEPolyhedron, + END_ZoneType_e, + ZoneType_Invalid = BadEnumValue +} ZoneType_e; + +typedef enum +{ + ZoneOrder_I, + ZoneOrder_J, + ZoneOrder_K, + ZoneOrder_IJ, + ZoneOrder_IK, + ZoneOrder_JK, + ZoneOrder_IJK, + END_ZoneOrder_e, + ZoneOrder_Invalid = BadEnumValue +} ZoneOrder_e; + +/* deprecated: replaced by ZoneType_e DataPacking_e */ +typedef enum +{ + DataFormat_IJKBlock, + DataFormat_IJKPoint, + DataFormat_FEBlock, + DataFormat_FEPoint, + END_DataFormat_e, + DataFormat_Invalid = BadEnumValue +} DataFormat_e; + +typedef enum +{ + DataPacking_Block, + DataPacking_Point, + END_DataPacking_e, + DataPacking_Invalid = BadEnumValue +} DataPacking_e; + + + +typedef enum +{ + PD_HPGL, + PD_HPGL2, + PD_PS, + PD_LASERG, /* deprecated */ + PD_EPS, + PD_WINDOWS, /* Windows Print Driver */ + PD_WMF, /* Windows MetaFile (used from Export only) */ + PD_X3D, + END_PrinterDriver_e, + PD_Invalid = BadEnumValue +} PrinterDriver_e; + + + +typedef enum +{ + Image_None, + Image_TIFF, + Image_EPSI2, + Image_FRAME, + END_EPSPreviewImage_e, + Image_Invalid = BadEnumValue +} EPSPreviewImage_e; + +typedef enum +{ + TIFFByteOrder_Intel, + TIFFByteOrder_Motorola, + END_TIFFByteOrder_e, + TIFFByteOrder_Invalid = BadEnumValue +} TIFFByteOrder_e; + +typedef enum +{ + JPEGEncoding_Standard, + JPEGEncoding_Progressive, + END_JPEGEncoding_e, + JPEGEncoding_Invalid = BadEnumValue +} JPEGEncoding_e; + + +typedef enum +{ + FlashImageType_Lossless, + FlashImageType_JPEG, + FlashImageType_Color256, + END_FlashImageType_e, + FlashImageType_Invalid = BadEnumValue, + /* deprecated values */ + FlashImageType_256Color = FlashImageType_Color256 +} FlashImageType_e; + +typedef enum +{ + FlashCompressionType_BestSpeed, + FlashCompressionType_SmallestSize, + END_FlashCompressionType_e, + FlashCompressionType_Invalid = BadEnumValue +} FlashCompressionType_e; + + +typedef enum +{ + ExportFormat_RasterMetafile, + ExportFormat_TIFF, + ExportFormat_SGI, + ExportFormat_SunRaster, + ExportFormat_XWindows, + ExportFormat_PSImage, /* deprecated */ + ExportFormat_HPGL, + ExportFormat_HPGL2, + ExportFormat_PS, + ExportFormat_EPS, + ExportFormat_LaserGraphics, /* deprecated */ + ExportFormat_WindowsMetafile, + ExportFormat_BMP, + ExportFormat_PNG, + ExportFormat_AVI, + ExportFormat_Custom, /* May be used in a future version */ + ExportFormat_JPEG, + ExportFormat_Flash, + ExportFormat_X3D, + ExportFormat_TecplotViewer, + END_ExportFormat_e, + ExportFormat_Invalid = BadEnumValue +} ExportFormat_e; + +typedef enum +{ + AVICompression_ColorPreserving, + AVICompression_LinePreserving, + AVICompression_LosslessUncompressed, + END_AVICompression_e, + AVICompression_Invalid = BadEnumValue +} AVICompression_e; + +typedef enum +{ + AnimationDest_Screen, + AnimationDest_AVI, + AnimationDest_RM, + AnimationDest_Flash, + END_AnimationDest_e, + AnimationDest_Invalid = BadEnumValue +} AnimationDest_e; + + + +typedef enum +{ + AnimationOperation_Forward, + AnimationOperation_Backward, + AnimationOperation_Loop, + AnimationOperation_Bounce, + END_AnimationOperation_e, + AnimationOperation_Invalid = BadEnumValue +} AnimationOperation_e; + +typedef enum +{ + AnimationStep_First, + AnimationStep_Second, + AnimationStep_Current, + AnimationStep_SecondToLast, + AnimationStep_Last, + AnimationStep_Previous, + AnimationStep_Next, + END_AnimationStep_e, + AnimationStep_Invalid = BadEnumValue +} AnimationStep_e; + +typedef enum +{ + ZoneAnimationMode_StepByNumber, + ZoneAnimationMode_GroupStepByNumber, + ZoneAnimationMode_StepByTime, + END_ZoneAnimationMode_e, + ZoneAnimationMode_Invalid = BadEnumValue +} ZoneAnimationMode_e; + +#if defined EXPORT_DEPRECATED_INTERFACES_TO_ADK_ONLY +/** + * @deprecated + * Please use \ref ExportRegion_e instead. + */ +typedef enum +{ + BitDumpRegion_CurrentFrame, + BitDumpRegion_AllFrames, + BitDumpRegion_WorkArea, + END_BitDumpRegion_e, + BitDumpRegion_Invalid = BadEnumValue +} BitDumpRegion_e; +#endif + +typedef enum +{ + ExportRegion_CurrentFrame, + ExportRegion_AllFrames, + ExportRegion_WorkArea, + END_ExportRegion_e, + ExportRegion_Invalid = BadEnumValue +} ExportRegion_e; + +typedef enum +{ + Paper_Letter, + Paper_Double, + Paper_A4, + Paper_A3, + Paper_Custom1, + Paper_Custom2, + END_PaperSize_e, + Paper_Invalid = BadEnumValue +} PaperSize_e; + + + +typedef enum +{ + PaperUnitSpacing_HalfCentimeter, + PaperUnitSpacing_OneCentimeter, + PaperUnitSpacing_TwoCentimeters, + PaperUnitSpacing_QuarterInch, + PaperUnitSpacing_HalfInch, + PaperUnitSpacing_OneInch, + PaperUnitSpacing_TenPoints, + PaperUnitSpacing_TwentyFourPoints, + PaperUnitSpacing_ThirtySixPoints, + PaperUnitSpacing_FiftyPoints, + PaperUnitSpacing_SeventyTwoPoints, + PaperUnitSpacing_OneTenthInch, + PaperUnitSpacing_OneTenthCentimeter, + END_PaperUnitSpacing_e, + PaperUnitSpacing_Invalid = BadEnumValue +} PaperUnitSpacing_e; + + +typedef enum +{ + Palette_Monochrome, + Palette_PenPlotter, + Palette_Color, + END_Palette_e, + Palette_Invalid = BadEnumValue +} Palette_e; + + +typedef enum +{ + PrintRenderType_Vector, + PrintRenderType_Image, + END_PrintRenderType_e, + PrintRenderType_Invalid = BadEnumValue +} PrintRenderType_e; + + +typedef enum +{ + Units_Grid, + Units_Frame, + Units_Point, + Units_Screen, + Units_AxisPercentage, + END_Units_e, + Units_Invalid = BadEnumValue +} Units_e; + + +typedef enum +{ + CoordScale_Linear, + CoordScale_Log, + END_CoordScale_e, + CoordScale_Invalid = BadEnumValue, + /* old names for the same values */ + Scale_Linear = CoordScale_Linear, + Scale_Log = CoordScale_Log, + Scale_Invalid = CoordScale_Invalid +} CoordScale_e; + +/* BEGINREMOVEFROMADDON */ +#define GetLog10(R) ( ((R) < SMALLDOUBLE) ? SMALLESTEXPONENT : ( ((R) > LARGEDOUBLE) ? LARGESTEXPONENT : log10((R)) ) ) +/* ENDREMOVEFROMADDON */ + +typedef enum +{ + CoordSys_Grid, + CoordSys_Frame, + CoordSys_FrameOffset, + CoordSys_Paper, + CoordSys_Screen, + CoordSys_Hardcopy, + CoordSys_Grid3D, + END_CoordSys_e, + CoordSys_Invalid = BadEnumValue +} CoordSys_e; + +/* + * NOTE: CoordSys_FrameOffset always is stored in inches internally. + * in stylesheet this may be written in other units if + * appropriate suffix is added. + * + */ + + + +typedef enum +{ + Scope_Global, + Scope_Local, + END_Scope_e, + Scope_Invalid = BadEnumValue +} Scope_e; + + +typedef enum +{ + TextAnchor_Left, + TextAnchor_Center, + TextAnchor_Right, + TextAnchor_MidLeft, + TextAnchor_MidCenter, + TextAnchor_MidRight, + TextAnchor_HeadLeft, + TextAnchor_HeadCenter, + TextAnchor_HeadRight, + TextAnchor_OnSide, + END_TextAnchor_e, + TextAnchor_Invalid = BadEnumValue +} TextAnchor_e; + + + +typedef enum +{ + TextBox_None, + TextBox_Filled, + TextBox_Hollow, + END_TextBox_e, + TextBox_Invalid = BadEnumValue +} TextBox_e; + + + +typedef enum +{ + GeomShape_Square, + GeomShape_Del, + GeomShape_Grad, + GeomShape_RTri, + GeomShape_LTri, + GeomShape_Diamond, + GeomShape_Circle, + GeomShape_Cube, + GeomShape_Sphere, + GeomShape_Octahedron, + GeomShape_Point, + END_GeomShape_e, + GeomShape_Invalid = BadEnumValue +} GeomShape_e; + + +typedef enum +{ + BasicSize_Tiny, + BasicSize_Small, + BasicSize_Medium, + BasicSize_Large, + BasicSize_Huge, + END_BasicSize_e, + BasicSize_Invalid = BadEnumValue +} BasicSize_e; + + + +/* + * NOTE: LineForm_e is deprecated. It must be retained to maintain + * backward compatibility with the TecUtil layer however. + * This has been replaced by CurveType_e. + */ +typedef enum +{ + LineForm_LineSeg, + LineForm_CurvFit, + LineForm_EToRFit, + LineForm_PowerFit, + LineForm_Spline, + LineForm_ParaSpline, + END_LineForm_e, + LineForm_Invalid = BadEnumValue +} LineForm_e; + + +typedef enum +{ + CurveType_LineSeg, + CurveType_PolynomialFit, + CurveType_EToRFit, + CurveType_PowerFit, + CurveType_Spline, + CurveType_ParaSpline, + CurveType_Extended, + END_CurveType_e, + CurveType_Invalid = BadEnumValue, + CurveType_CurvFit = CurveType_PolynomialFit +} CurveType_e; + +typedef enum +{ + Script_None, + Script_Super, + Script_Sub, + END_Script_e, + Script_Invalid = BadEnumValue +} Script_e; + + +typedef enum +{ + Font_Helvetica, + Font_HelveticaBold, + Font_Greek, + Font_Math, + Font_UserDefined, + Font_Times, + Font_TimesItalic, + Font_TimesBold, + Font_TimesItalicBold, + Font_Courier, + Font_CourierBold, + END_Font_e, + Font_Invalid = BadEnumValue +} Font_e; + +typedef enum +{ + TwoDDrawOrder_ByZone, + TwoDDrawOrder_ByLayer, + END_TwoDDrawOrder_e, + TwoDDrawOrder_Invalid = BadEnumValue +} TwoDDrawOrder_e; + +typedef enum +{ + DrawOrder_AfterData, + DrawOrder_BeforeData, + END_DrawOrder_e, + DrawOrder_Invalid = BadEnumValue +} DrawOrder_e; + +/* + * + * NOTE: Streamtrace_TwoDLine is new. All 2D + * streamtraces are assigned this value. + */ +typedef enum +{ + Streamtrace_SurfaceLine, + Streamtrace_SurfaceRibbon, + Streamtrace_VolumeLine, + Streamtrace_VolumeRibbon, + Streamtrace_VolumeRod, + Streamtrace_TwoDLine, + END_Streamtrace_e, + Streamtrace_Invalid = BadEnumValue +} Streamtrace_e; + + + +typedef enum +{ + StreamDir_Forward, + StreamDir_Reverse, + StreamDir_Both, + END_StreamDir_e, + StreamDir_Invalid = BadEnumValue +} StreamDir_e; + +typedef enum +{ + IsoSurfaceSelection_AllContourLevels, + IsoSurfaceSelection_OneSpecificValue, + IsoSurfaceSelection_TwoSpecificValues, + IsoSurfaceSelection_ThreeSpecificValues, + END_IsoSurfaceSelection_e, + IsoSurfaceSelection_Invalid = BadEnumValue +} IsoSurfaceSelection_e; + + +typedef enum +{ + ValueLocation_CellCentered, + ValueLocation_Nodal, + END_ValueLocation_e, + ValueLocation_Invalid = BadEnumValue +} ValueLocation_e; + +typedef enum +{ + FieldDataType_Reserved, /* never use */ + FieldDataType_Float, + FieldDataType_Double, + FieldDataType_Int32, + FieldDataType_Int16, + FieldDataType_Byte, + FieldDataType_Bit, + END_FieldDataType_e, + FieldDataType_IJKFunction, /* Not used yet */ + FieldDataType_Int64, /* Not used yet */ +#if defined EXPORT_DEPRECATED_INTERFACES_TO_ADK_ONLY + FieldDataType_LongInt = FieldDataType_Int32, + FieldDataType_ShortInt = FieldDataType_Int16, +#endif + FieldDataType_Invalid = BadEnumValue +} FieldDataType_e; + +#define VALID_FIELD_DATA_TYPE(FieldDataType) (VALID_ENUM((FieldDataType),FieldDataType_e) && \ + (FieldDataType)!=FieldDataType_Reserved) + +#if defined EXPORT_DEPRECATED_INTERFACES_TO_ADK_ONLY +/** + * @deprecated + * Please use \ref MeshType_e instead. + */ +typedef enum +{ + Mesh_Wireframe, /* deprecated: use MeshType_Wireframe */ + Mesh_Overlay, /* deprecated: use MeshType_Overlay */ + Mesh_HiddenLine, /* deprecated: use MeshType_HiddenLine */ + END_MeshPlotType_e, + Mesh_Invalid = BadEnumValue +} MeshPlotType_e; +#endif + +typedef enum +{ + MeshType_Wireframe, /* Mesh_Wireframe */ + MeshType_Overlay, /* Mesh_Overlay */ + MeshType_HiddenLine, /* Mesh_HiddenLine */ + END_MeshType_e, + MeshType_Invalid = BadEnumValue +} MeshType_e; + + + + +#if defined EXPORT_DEPRECATED_INTERFACES_TO_ADK_ONLY +/** + * @deprecated + * Please use \ref ContourType_e instead. + */ +typedef enum +{ + Contour_Lines, /* deprecated: use ContourType_Lines */ + Contour_Flood, /* deprecated: use ContourType_Flood */ + Contour_Overlay, /* deprecated: use ContourType_Overlay */ + Contour_AverageCell, /* deprecated: use ContourType_AverageCell */ + Contour_CornerCell, /* deprecated: use ContourType_PrimaryValue */ + END_ContourPlotType_e, + Contour_Invalid = BadEnumValue +} ContourPlotType_e; +#endif + + +typedef enum +{ + ContourType_Lines, /* Contour_Lines */ + ContourType_Flood, /* Contour_Flood */ + ContourType_Overlay, /* Contour_Overlay */ + ContourType_AverageCell, /* Contour_AverageCell */ + ContourType_PrimaryValue, /* Contour_CornerCell */ + END_ContourType_e, + ContourType_Invalid = BadEnumValue +} ContourType_e; + +typedef enum +{ + ContourColoring_RGB, + ContourColoring_Group1, + ContourColoring_Group2, + ContourColoring_Group3, + ContourColoring_Group4, + ContourColoring_Group5, + ContourColoring_Group6, + ContourColoring_Group7, + ContourColoring_Group8, + END_ContourColoring_e, + ContourColoring_Invalid = BadEnumValue +} ContourColoring_e; + +#if defined EXPORT_DEPRECATED_INTERFACES_TO_ADK_ONLY +/** + * @deprecated + * Please use \ref VectorType_e instead. + */ +typedef enum +{ + Vector_TailAtPoint, /* deprecated: use VectorType_TailAtPoint */ + Vector_HeadAtPoint, /* deprecated: use VectorType_HeadAtPoint */ + Vector_MidAtPoint, /* deprecated: use VectorType_MidAtPoint */ + Vector_HeadOnly, /* deprecated: use VectorType_HeadOnly */ + END_VectorPlotType_e, + Vector_Invalid = BadEnumValue +} VectorPlotType_e; +#endif + + +typedef enum +{ + VectorType_TailAtPoint, /* Vector_TailAtPoint */ + VectorType_HeadAtPoint, /* Vector_HeadAtPoint */ + VectorType_MidAtPoint, /* Vector_MidAtPoint */ + VectorType_HeadOnly, /* Vector_HeadOnly */ + END_VectorType_e, + VectorType_Invalid = BadEnumValue +} VectorType_e; + + +/* + * NOTE: ShadePlotType_e is deprecated. It must be retained to maintain + * backward compatibility with the TecUtil layer however. + * This has been replaced by LightingEffect_e. + */ +typedef enum +{ + Shade_SolidColor, + Shade_Paneled, + Shade_Gouraud, + Shade_ColoredPaneled, + Shade_ColoredGouraud, + END_ShadePlotType_e, + Shade_Invalid = BadEnumValue +} ShadePlotType_e; + +/* + * NOTE: LightingEffect_None is deprecated. It must remain + * in the list to allow macro processing of older + * (i.e. early v9) macros. + */ +typedef enum +{ + LightingEffect_Paneled, + LightingEffect_Gouraud, + LightingEffect_None, + END_LightingEffect_e, + LightingEffect_Invalid = BadEnumValue +} LightingEffect_e; + +typedef enum +{ + IJKLines_I, + IJKLines_J, + IJKLines_K, + END_IJKLines_e, + IJKLines_Invalid = BadEnumValue, + /* deprecated values */ + Lines_I = IJKLines_I, /* deprecated */ + Lines_J = IJKLines_J, /* deprecated */ + Lines_K = IJKLines_K, /* deprecated */ + Lines_Invalid = IJKLines_Invalid /* deprecated */ +} IJKLines_e; + +typedef enum +{ + IJKCellType_Planes, + IJKCellType_FacePlanes, + IJKCellType_Volume, + END_IJKCellType_e, + IJKCellType_Invalid = BadEnumValue +} IJKCellType_e; + + +/* + * Ver 6 used PlaneSet. Ver 7 uses CellType and Planes variables. + * + * "PlaneSet" in version 6 vs. IJKPlanes in v7: + * + * 'A' = AllPlanes CellType = IJKCellType_Volume + * 'd','e','f','C' = ComboPlanes CellType = IJKCellType_Planes, IJKPlanes = depends on defC + * 'F' = Faces Planes Only CellType = IJKCellType_FacePlanes + * 'I' = I-Planes CellType = IJKCellType_Planes, IJKPlanes = IJKPlanes_I + * 'J' = J-Planes CellType = IJKCellType_Planes, IJKPlanes = IJKPlanes_J + * 'K' = K-Planes CellType = IJKCellType_Planes, IJKPlanes = IJKPlanes_K + * + * + * NOTE: IJKPlanes_e is still used internally in tecplot (and in the TecUtil layer). + * it has been relagated to communicating which planes of an IJK zone are in + * use. + * + */ + +typedef enum +{ + IJKPlanes_I, + IJKPlanes_J, + IJKPlanes_K, + IJKPlanes_Face, /* used on the panel heap */ + IJKPlanes_IJ, /* deprecated */ + IJKPlanes_JK, /* deprecated */ + IJKPlanes_IK, /* deprecated */ + IJKPlanes_IJK, /* deprecated */ + IJKPlanes_Volume, + IJKPlanes_Unused, + END_IJKPlanes_e, + IJKPlanes_Invalid = BadEnumValue, + /* deprecated values */ + Planes_I = IJKPlanes_I, /* deprecated */ + Planes_J = IJKPlanes_J, /* deprecated */ + Planes_K = IJKPlanes_K, /* deprecated */ + Planes_IJ = IJKPlanes_IJ, /* deprecated */ + Planes_JK = IJKPlanes_JK, /* deprecated */ + Planes_IK = IJKPlanes_IK, /* deprecated */ + Planes_IJK = IJKPlanes_IJK, /* deprecated */ + Planes_Face = IJKPlanes_Face, /* deprecated */ + Planes_Volume = IJKPlanes_Volume, /* deprecated */ + Planes_Unused = IJKPlanes_Unused, /* deprecated */ + Planes_Invalid = IJKPlanes_Invalid /* deprecated */ +} IJKPlanes_e; + + + +typedef enum +{ + SurfacesToPlot_BoundaryFaces, + SurfacesToPlot_ExposedCellFaces, + SurfacesToPlot_IPlanes, + SurfacesToPlot_JPlanes, + SurfacesToPlot_KPlanes, + SurfacesToPlot_IJPlanes, + SurfacesToPlot_JKPlanes, + SurfacesToPlot_IKPlanes, + SurfacesToPlot_IJKPlanes, + SurfacesToPlot_All, + SurfacesToPlot_None, + END_SurfacesToPlot_e, + SurfacesToPlot_Invalid = BadEnumValue +} SurfacesToPlot_e; + +typedef enum +{ + PointsToPlot_SurfaceNodes, /* was _SurfacesOnly */ + PointsToPlot_AllNodes, /* was _All */ + PointsToPlot_SurfaceCellCenters, + PointsToPlot_AllCellCenters, + PointsToPlot_AllConnected, + END_PointsToPlot_e, +#if defined EXPORT_DEPRECATED_INTERFACES_TO_ADK_ONLY + PointsToPlot_SurfacesOnly = PointsToPlot_SurfaceNodes, /* deprecated */ + PointsToPlot_All = PointsToPlot_AllNodes, /* deprecated */ +#endif + PointsToPlot_Invalid = BadEnumValue +} PointsToPlot_e; + + +typedef enum +{ + SliceSurface_XPlanes, + SliceSurface_YPlanes, + SliceSurface_ZPlanes, + SliceSurface_IPlanes, + SliceSurface_JPlanes, + SliceSurface_KPlanes, + END_SliceSurface_e, + SliceSurface_Invalid = BadEnumValue +} SliceSurface_e; + + +typedef enum +{ + ClipPlane_None, + ClipPlane_BelowPrimarySlice, + ClipPlane_AbovePrimarySlice, + END_ClipPlane_e, + ClipPlane_Invalid = BadEnumValue +} ClipPlane_e; + +typedef enum +{ + Skip_ByIndex, + Skip_ByFrameUnits, + END_SkipMode_e, + Skip_Invalid = BadEnumValue +} SkipMode_e; + + +typedef enum +{ + EdgeType_Borders, + EdgeType_Creases, + EdgeType_BordersAndCreases, + END_EdgeType_e, + EdgeType_Invalid = BadEnumValue +} EdgeType_e; + +#if defined EXPORT_DEPRECATED_INTERFACES_TO_ADK_ONLY +/** + * @deprecated + * Please use \ref BorderLocation_e instead. + */ +typedef enum +{ + Boundary_None, /* deprecated: use BoundaryType_None */ + Boundary_Min, /* deprecated: use BoundaryType_Min */ + Boundary_Max, /* deprecated: use BoundaryType_Max */ + Boundary_Both, /* deprecated: use BoundaryType_Both */ + END_BoundPlotType_e, + Boundary_Invalid = BadEnumValue +} BoundPlotType_e; +#endif + +typedef enum +{ + BoundaryType_None, /* Boundary_None */ + BoundaryType_Min, /* Boundary_Min */ + BoundaryType_Max, /* Boundary_Max */ + BoundaryType_Both, /* Boundary_Both */ + END_BoundaryType_e, + BoundaryType_Invalid = BadEnumValue +} BoundaryType_e; /* deprecated */ + +typedef enum +{ + BorderLocation_None, /* Boundary_None */ + BorderLocation_Min, /* Boundary_Min */ + BorderLocation_Max, /* Boundary_Max */ + BorderLocation_Both, /* Boundary_Both */ + END_BorderLocation_e, + BorderLocation_Invalid = BadEnumValue +} BorderLocation_e; + +typedef enum +{ + ContourColorMap_SmRainbow, + ContourColorMap_LgRainbow, + ContourColorMap_Modern, + ContourColorMap_GrayScale, + ContourColorMap_Wild, + ContourColorMap_UserDef, + ContourColorMap_TwoColor, + ContourColorMap_RawUserDef, + END_ContourColorMap_e, + ContourColorMap_Invalid = BadEnumValue, + /* deprecated values */ + ColorMap_SmRainbow = ContourColorMap_SmRainbow, /* deprecated */ + ColorMap_LgRainbow = ContourColorMap_LgRainbow, /* deprecated */ + ColorMap_Modern = ContourColorMap_Modern, /* deprecated */ + ColorMap_GrayScale = ContourColorMap_GrayScale, /* deprecated */ + ColorMap_Wild = ContourColorMap_Wild, /* deprecated */ + ColorMap_UserDef = ContourColorMap_UserDef, /* deprecated */ + ColorMap_TwoColor = ContourColorMap_TwoColor, /* deprecated */ + ColorMap_RawUserDef = ContourColorMap_RawUserDef, /* deprecated */ + ColorMap_Invalid = ContourColorMap_Invalid /* deprecated */ +} ContourColorMap_e; + + + +typedef enum +{ + ErrorBar_Up, + ErrorBar_Down, + ErrorBar_Left, + ErrorBar_Right, + ErrorBar_Horz, + ErrorBar_Vert, + ErrorBar_Cross, + END_ErrorBar_e, + ErrorBar_Invalid = BadEnumValue +} ErrorBar_e; + + + +typedef enum +{ + ContourLineMode_UseZoneLineType, + ContourLineMode_SkipToSolid, + ContourLineMode_DashNegative, + END_ContourLineMode_e, + ContourLineMode_Invalid = BadEnumValue +} ContourLineMode_e; + + +/* BEGINREMOVEFROMADDON */ +typedef enum +{ + Panel_Bad, + Panel_Cell, /* FieldZone */ + Panel_Vector, /* FieldZone */ + Panel_Scatter, /* FieldZone */ + Panel_IJKBorderLine, /* FieldZone IJK border lines */ + Panel_CellEdge, /* FieldZone border lines and creases */ + Panel_FEBoundaryCell, /* FieldZone */ + Panel_NodeLabel, /* FieldZone */ + Panel_CellLabel, /* FieldZone */ + Panel_StreamtraceCell, /* Streamtrace COB */ + Panel_StreamtraceMarker, /* StreamtraceMarker COB (Scatter Symbol) */ + Panel_StreamtraceArrowhead, /* StreamtraceArrowhead COB (Vector) */ + Panel_IsoSurfaceCell, /* IsoSurface COB */ + Panel_IsoSurfaceCellEdge, /* IsoSurface COB border lines and creases (border lines and creases not currently used) */ + Panel_SliceCell, /* Slice COB */ + Panel_SliceVector, /* Slice COB */ + Panel_SliceIJKBorderLine, /* Slice COB IJK border lines */ + Panel_SliceCellEdge, /* Slice COB border lines and creases (creases not currently used) */ + Panel_Geom, /* Misc */ + Panel_Text, /* Misc */ + END_Panel_e, + Panel_Invalid = BadEnumValue +} Panel_e; +/* ENDREMOVEFROMADDON */ + + +typedef enum +{ + MessageBoxType_Error, + MessageBoxType_Warning, + MessageBoxType_Information, + MessageBoxType_Question, /* Ok, Cancel buttons */ + MessageBoxType_YesNo, + MessageBoxType_YesNoCancel, + MessageBoxType_WarningOkCancel, + END_MessageBoxType_e, + MessageBoxType_Invalid = BadEnumValue, + /* deprecated values */ + MessageBox_Error = MessageBoxType_Error, /* deprecated */ + MessageBox_Warning = MessageBoxType_Warning, /* deprecated */ + MessageBox_Information = MessageBoxType_Information, /* deprecated */ + MessageBox_Question = MessageBoxType_Question, /* deprecated */ + MessageBox_YesNo = MessageBoxType_YesNo, /* deprecated */ + MessageBox_YesNoCancel = MessageBoxType_YesNoCancel, /* deprecated */ + MessageBox_WarningOkCancel = MessageBoxType_WarningOkCancel, /* deprecated */ + MessageBox_Invalid = MessageBoxType_Invalid /* deprecated */ +} MessageBoxType_e; + + +typedef enum +{ + MessageBoxReply_Yes, + MessageBoxReply_No, + MessageBoxReply_Cancel, + MessageBoxReply_Ok, + END_MessageBoxReply_e, + MessageBoxReply_Invalid = BadEnumValue +} MessageBoxReply_e; + +typedef enum +{ + NumberFormat_Integer, + NumberFormat_FixedFloat, + NumberFormat_Exponential, + NumberFormat_BestFloat, + NumberFormat_SuperScript, + NumberFormat_CustomLabel, + NumberFormat_LogSuperScript, + NumberFormat_RangeBestFloat, + NumberFormat_DynamicLabel, + NumberFormat_TimeDate, + END_NumberFormat_e, + NumberFormat_Invalid = BadEnumValue +} NumberFormat_e; + +/* For backward compatibility with v9- */ +typedef NumberFormat_e ValueFormat_e; + + +typedef enum +{ + BackingStoreMode_QuickAndDirty, + BackingStoreMode_RealTimeUpdate, + BackingStoreMode_PeriodicUpdate, + END_BackingStoreMode_e, + BackingStoreMode_Invalid = BadEnumValue +} BackingStoreMode_e; + + +typedef enum +{ + TickDirection_In, + TickDirection_Out, + TickDirection_Centered, + END_TickDirection_e, + TickDirection_Invalid = BadEnumValue +} TickDirection_e; + +/* This enumerated type is no longer used as of Tecplot V10. */ +typedef enum +{ + AxisTitlePosition_Left, + AxisTitlePosition_Center, + AxisTitlePosition_Right, + END_AxisTitlePosition_e, + AxisTitlePosition_Invalid = BadEnumValue +} AxisTitlePosition_e; + +typedef enum +{ + AxisTitleMode_NoTitle, + AxisTitleMode_UseVarName, + AxisTitleMode_UseText, + END_AxisTitleMode_e, + AxisTitleMode_Invalid = BadEnumValue +} AxisTitleMode_e; + +typedef enum +{ + AxisAlignment_WithViewport, + AxisAlignment_WithOpposingAxisValue, + AxisAlignment_WithGridMin, + AxisAlignment_WithGridMax, + AxisAlignment_WithSpecificAngle, + AxisAlignment_WithGridAreaTop, + AxisAlignment_WithGridAreaBottom, + AxisAlignment_WithGridAreaLeft, + AxisAlignment_WithGridAreaRight, + END_AxisAlignment_e, + AxisAlignment_Invalid = BadEnumValue +} AxisAlignment_e; + +typedef enum +{ + FunctionDependency_XIndependent, + FunctionDependency_YIndependent, + END_FunctionDependency_e, + FunctionDependency_Invalid = BadEnumValue, + FunctionDependency_ThetaIndependent = FunctionDependency_XIndependent, + FunctionDependency_RIndependent = FunctionDependency_YIndependent +} FunctionDependency_e; + +typedef enum +{ + LegendShow_Yes, + LegendShow_No, + LegendShow_Auto, + END_LegendShow_e, + LegendShow_Invalid = BadEnumValue +} LegendShow_e; + +typedef enum +{ + LineMapSort_None, + LineMapSort_IndependentVar, + LineMapSort_DependentVar, + LineMapSort_SpecificVar, + END_LineMapSort_e, + LineMapSort_Invalid = BadEnumValue +} LineMapSort_e; + +typedef enum +{ + ContLegendLabelLocation_ContourLevels, + ContLegendLabelLocation_Increment, + ContLegendLabelLocation_ColorMapDivisions, + END_ContLegendLabelLocation_e, + ContLegendLabelLocation_Invalid = BadEnumValue +} ContLegendLabelLocation_e; + +typedef enum +{ + ThetaMode_Degrees, + ThetaMode_Radians, + ThetaMode_Arbitrary, + END_ThetaMode_e, + ThetaMode_Invalid = BadEnumValue +} ThetaMode_e; + +typedef enum +{ + Transform_PolarToRect, + Transform_SphericalToRect, + Transform_RectToPolar, + Transform_RectToSpherical, + END_Transform_e, + Transform_Invalid = BadEnumValue +} Transform_e; + +typedef enum +{ + LaunchDialogMode_ModalSync, + LaunchDialogMode_Modeless, + LaunchDialogMode_ModalAsync, + END_LaunchDialogMode_e, + LaunchDialogMode_Invalid = BadEnumValue +} LaunchDialogMode_e; + + +typedef enum +{ + SelectFileOption_ReadSingleFile, + SelectFileOption_ReadMultiFile, + SelectFileOption_AllowMultiFileRead, + SelectFileOption_WriteFile, + SelectFileOption_SelectDirectory, + END_SelectFileOption_e, + SelectFileOption_Invalid = BadEnumValue +} SelectFileOption_e; + +typedef enum +{ + BinaryFileVersion_Tecplot2006, + BinaryFileVersion_Tecplot2008, + BinaryFileVersion_Tecplot2009, + BinaryFileVersion_Current, + END_BinaryFileVersion_e, + BinaryFileVersion_Invalid = BadEnumValue +} BinaryFileVersion_e; + +/* CURRENTLY NOT USED .... */ +typedef enum +{ + ViewActionDrawMode_NoDraw, + ViewActionDrawMode_DrawTrace, + ViewActionDrawMode_DrawFull, + END_ViewActionDrawMode_e, + ViewActionDrawMode_Invalid = BadEnumValue +} ViewActionDrawMode_e; + +typedef enum +{ + PageAction_Create, + PageAction_Delete, + PageAction_Clear, + PageAction_SetCurrentToNext, + PageAction_SetCurrentToPrev, + PageAction_SetCurrentByName, + PageAction_SetCurrentByUniqueID, + END_PageAction_e, + PageAction_Invalid = BadEnumValue +} PageAction_e; + +typedef enum +{ + FrameAction_PushTop, + FrameAction_PopByNumber, + FrameAction_PopAtPosition, + FrameAction_DeleteActive, + FrameAction_FitAllToPaper, + FrameAction_PushByName, + FrameAction_PopByName, + FrameAction_PushByNumber, + FrameAction_ActivateTop, + FrameAction_ActivateNext, + FrameAction_ActivatePrevious, + FrameAction_ActivateAtPosition, + FrameAction_ActivateByName, + FrameAction_ActivateByNumber, + FrameAction_MoveToTopActive, + FrameAction_MoveToTopByName, + FrameAction_MoveToTopByNumber, + FrameAction_MoveToBottomActive, + FrameAction_MoveToBottomByName, + FrameAction_MoveToBottomByNumber, + END_FrameAction_e, + FrameAction_Invalid = BadEnumValue, + FrameAction_Pop = FrameAction_PopByNumber, + FrameAction_Push = FrameAction_PushByNumber, + FrameAction_DeleteTop = FrameAction_DeleteActive +} FrameAction_e; + +typedef enum +{ + DoubleBufferAction_On, + DoubleBufferAction_Off, + DoubleBufferAction_Swap, + END_DoubleBufferAction_e, + DoubleBufferAction_Invalid = BadEnumValue +} DoubleBufferAction_e; + +/* + * PickAction_CheckToAdd had the side effects of popping a frame that was selected + * only if not collecting. Pick_AddAtPosition avoids this. + */ +typedef enum +{ + PickAction_CheckToAdd, /* deprecated: use Pick_AddAtPosition */ + PickAction_AddAll, + PickAction_AddAllInRegion, + PickAction_Edit, + PickAction_Cut, + PickAction_Copy, + PickAction_Clear, + PickAction_Paste, + PickAction_PasteAtPosition, + PickAction_Shift, + PickAction_Magnify, + PickAction_Push, + PickAction_Pop, + PickAction_SetMouseMode, + PickAction_DeselectAll, + PickAction_AddZones, + PickAction_AddXYMaps, /* deprecated: use PickAction_AddLineMaps */ + PickAction_AddLineMaps, + PickAction_AddAtPosition, + END_PickAction_e, + PickAction_Invalid = BadEnumValue +} PickAction_e; + + +typedef enum +{ + ContourLevelAction_Add, + ContourLevelAction_New, + ContourLevelAction_DeleteRange, + ContourLevelAction_Reset, + ContourLevelAction_ResetToNice, + ContourLevelAction_DeleteNearest, + END_ContourLevelAction_e, + ContourLevelAction_Invalid = BadEnumValue +} ContourLevelAction_e; + +typedef enum +{ + ContourLabelAction_Add, + ContourLabelAction_DeleteAll, + END_ContourLabelAction_e, + ContourLabelAction_Invalid = BadEnumValue +} ContourLabelAction_e; + +typedef enum +{ + StreamtraceAction_Add, + StreamtraceAction_DeleteAll, + StreamtraceAction_DeleteRange, + StreamtraceAction_SetTerminationLine, + StreamtraceAction_ResetDeltaTime, + END_StreamtraceAction_e, + StreamtraceAction_Invalid = BadEnumValue +} StreamtraceAction_e; + +typedef enum +{ + ColorMapControlAction_RedistributeControlPoints, + ColorMapControlAction_CopyCannedColorMap, + ColorMapControlAction_ResetToFactoryDefaults, + END_ColorMapControlAction_e, + ColorMapControlAction_Invalid = BadEnumValue +} ColorMapControlAction_e; + +typedef enum +{ + ColorMapDistribution_Continuous, + ColorMapDistribution_Banded, + END_ColorMapDistribution_e, + ColorMapDistribution_Invalid = BadEnumValue +} ColorMapDistribution_e; + +typedef enum +{ + RGBMode_SpecifyRGB, + RGBMode_SpecifyRG, + RGBMode_SpecifyRB, + RGBMode_SpecifyGB, + END_RGBMode_e, + RGBMode_Invalid = BadEnumValue +} RGBMode_e; + +typedef enum +{ + TecUtilErr_None, + TecUtilErr_Undetermined, + END_TecUtilErr_e, + TecUtilErr_Invalid = BadEnumValue +} TecUtilErr_e; + +/* BEGINREMOVEFROMADDON */ +/* deprecated type from alpha/beta v10 */ +typedef enum +{ + AxisShape_Ray, + AxisShape_LineTwoDirections, + AxisShape_LShape, + AxisShape_CrossOrBox, + END_AxisShape_e, + AxisShape_Invalid = BadEnumValue +} AxisShape_e; + +/* licensing enums : keep hidden */ +typedef enum +{ + RunMode_Demo, + RunMode_Eval, + RunMode_Full, + /**/ + END_RunMode_e, + /**/ + RunMode_Invalid = BadEnumValue +} RunMode_e; + +/* ENDREMOVEFROMADDON */ + +typedef enum /* Custom exporter error message */ +{ + ExportCustReturnCode_Ok, + ExportCustReturnCode_Failed, + ExportCustReturnCode_TecplotLocked, + ExportCustReturnCode_ExporterNotLoaded, + ExportCustReturnCode_ExportCallbackFailed, + ExportCustReturnCode_NotAnImageExporter, + ExportCustReturnCode_NotAFieldDataExporter, + END_ExportCustReturnCode_e, + ExportCustReturnCode_Invalid = BadEnumValue +} ExportCustReturnCode_e; + +/** + * COB/Zone types. + */ +typedef enum +{ + CZType_FieldDataZone, + CZType_FEBoundaryCOB, + CZType_IsoSurfaceCOB, + CZType_SliceCOB, + CZType_StreamtraceCOB, + CZType_StreamtraceMarkerCOB, + CZType_StreamtraceArrowheadCOB, + END_CZType_e, + CZType_Invalid = BadEnumValue +} CZType_e; + +/** + */ +typedef enum +{ + FaceNeighborMode_LocalOneToOne, + FaceNeighborMode_LocalOneToMany, + FaceNeighborMode_GlobalOneToOne, + FaceNeighborMode_GlobalOneToMany, + END_FaceNeighborMode_e, + FaceNeighborMode_Invalid = BadEnumValue +} FaceNeighborMode_e; + + +/** + * Page render destinations. + */ +typedef enum +{ + PageRenderDest_None, + PageRenderDest_OnScreen, + PageRenderDest_OffScreen, + END_PageRenderDest_e, + PageRenderDest_Invalid = BadEnumValue +} PageRenderDest_e; + +/* BEGINREMOVEFROMADDON */ +/* + * Destination for all internal rendering (VDI/Gr) functions. For external + * linkage we translate RenderDest_WorkArea to PageRenderDest_OnScreen, + * RenderDest_OffscreenBitmap to PageRenderDest_OffScreen and + * RenderDest_Invalid to PageRenderDest_None. + */ +typedef enum +{ + RenderDest_WorkArea, /* Do not move from start of screen entries */ + RenderDest_ExampleText, + RenderDest_ExampleLightSourcePosition, + RenderDest_ExampleColorMap, + RenderDest_ExampleBasicColor, /* Do not move from end of screen entries */ + RenderDest_OffscreenBitmap, + RenderDest_Hardcopy, + END_RenderDest_e, + RenderDest_Invalid = BadEnumValue, + /* + * These next two are optimizations to make the + * RDT_IsScreen() macro as efficient as possible. + */ + RenderDest_FirstScreenEntry = RenderDest_WorkArea, + RenderDest_LastScreenEntry = RenderDest_ExampleBasicColor +} RenderDest_e; +/* ENDREMOVEFROMADDON */ + +typedef enum +{ + Stipple_All, + Stipple_Critical, + Stipple_None, + END_Stipple_e, + Stipple_Invalid = BadEnumValue +} Stipple_e; + +typedef enum +{ + DataFileType_Full, + DataFileType_Grid, + DataFileType_Solution, + END_DataFileType_e, + DataFileType_Invalid = BadEnumValue +} DataFileType_e; + +typedef enum +{ + ConditionAwakeReason_Signaled, + ConditionAwakeReason_TimedOut, + END_ConditionAwakeReason_e, + ConditionAwakeReason_Invalid = BadEnumValue +} ConditionAwakeReason_e; + +/**************************************************************** + * * + * STRUCTURE TYPEDEFS * + * * + ****************************************************************/ + +/* + * These are defined to work with pthreads, more work for WINAPI needed + */ +typedef struct _Mutex_a* Mutex_pa; + +typedef void*(STDCALL *ThreadFunction_pf)(ArbParam_t ThreadData); + +typedef struct _Condition_a* Condition_pa; + +typedef struct _JobControl_s* JobControl_pa; + +typedef void (STDCALL *ThreadPoolJob_pf)(ArbParam_t JobData); + +/* BEGINREMOVEFROMADDON */ +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if defined USE_OOSTYLE +#endif +#endif /* TECPLOTKERNEL */ +/* ENDREMOVEFROMADDON */ + +typedef struct _StringList_s *StringList_pa; +typedef struct _Menu_s *Menu_pa; +/* BEGINREMOVEFROMADDON */ +typedef struct _ArrayList_s *ArrayList_pa; +/* ENDREMOVEFROMADDON */ + +typedef enum +{ + ImageResizeFilter_Texture, + ImageResizeFilter_Box, + ImageResizeFilter_Lanczos2, + ImageResizeFilter_Lanczos3, + ImageResizeFilter_Triangle, + ImageResizeFilter_Bell, + ImageResizeFilter_BSpline, + ImageResizeFilter_Cubic, + ImageResizeFilter_Mitchell, + ImageResizeFilter_Gaussian, + END_ImageResizeFilter_e, + ImageResizeFilter_Invalid = BadEnumValue +} ImageResizeFilter_e; + +typedef enum +{ + VarStatus_Passive, + VarStatus_Custom, + VarStatus_Map, + VarStatus_Heap, + VarStatus_NotLoaded, + END_VarStatus_e, + VarStatus_Invalid = BadEnumValue +} VarStatus_e; + + + +/* BEGINREMOVEFROMADDON */ + +/* here until GR and GRHW layer can be rearranged. */ +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# if !defined NO_ASSERTS +# endif +#endif /* TECPLOTKERNEL */ + +/* ENDREMOVEFROMADDON */ + +typedef struct _Set_a *Set_pa; + +typedef struct +{ + double X; + double Y; + double Z; +} XYZ_s; + +/* BEGINREMOVEFROMADDON */ + +typedef struct _Generic3Var_s +{ + double V1; + double V2; + double V3; +} Generic3Var_s; + +typedef struct _ThetaR_s +{ + double Theta; + double R; +} ThetaR_s; + +/* + * This union is designed to allow different plottypes + * to access the same values by different names. In + * C++ we could use member access functions, or we + * could have used macros, but instead we use this + * union. NOTE: This only works if all the structures + * have the same alignment. + */ +typedef union _AnchorPos_u +{ + Generic3Var_s Generic; + XYZ_s XYZ; + ThetaR_s ThetaR; +} AnchorPos_u; + +typedef struct _DataFileInfo_s +{ + char *PrimaryFName; + char *TempBinaryFName; + DataFileType_e FileType; + FileOffset_t DataFileOffset; + StringList_pa VarName; + EntIndex_t NumZones; + EntIndex_t NumVars; + double SolutionFileTime; + struct _DataFileInfo_s *NextFile; +} DataFileInfo_s; + +typedef struct _StylesheetIOFlags_s +{ + Boolean_t IncludePlotStyle; + Boolean_t IncludeFieldAndMapStyle; /* Only used for undo */ + Boolean_t IncludeUniqueIDs; /* Only used for undo */ + Boolean_t IncludeText; + Boolean_t IncludeGeom; + Boolean_t IncludeGeomImageData; + Boolean_t IncludeAuxData; + Boolean_t IncludeStreamPositions; + Boolean_t IncludeContourLevels; + Boolean_t IncludeFactoryDefaults; /* Only used when writing */ + Boolean_t CompressStyleCommands; /* Only used when writing */ + Boolean_t MergeStyle; /* Only used when reading */ + Boolean_t IncludeFrameSizeAndPosition; /* Only used when reading */ + Boolean_t UseRelativePaths; +} StylesheetIOFlags_s; + + +/** + */ +typedef struct +{ + Boolean_t Show; /* power switch */ + Boolean_t ShowMesh; + Boolean_t ShowContour; + Boolean_t ShowShade; + Boolean_t UseLightingEffect; + Boolean_t UseTranslucency; +} IsoSurfaceLayers_s; + +/** + */ +typedef struct +{ + Boolean_t Show; /* power switch */ + Boolean_t ShowMesh; + Boolean_t ShowContour; + Boolean_t ShowVector; + Boolean_t ShowShade; + Boolean_t ShowEdge; + Boolean_t UseLightingEffect; + Boolean_t UseTranslucency; +} SliceLayers_s; + +/** + */ +typedef struct +{ + Boolean_t Show; /* power switch */ + Boolean_t ShowPaths; + Boolean_t ShowDashes; + Boolean_t ShowArrowheads; + Boolean_t ShowMesh; + Boolean_t ShowContour; + Boolean_t ShowShade; + Boolean_t ShowMarkers; + Boolean_t UseLightingEffect; + Boolean_t UseTranslucency; +} StreamtraceLayers_s; + +/** + */ +typedef struct +{ +#if 0 /* in the future we may add a main power switch */ + Boolean_t Show; /* power switch */ +#endif + TwoDDrawOrder_e TwoDDrawOrder; + Boolean_t ShowMesh; + Boolean_t ShowContour; + Boolean_t ShowVector; + Boolean_t ShowScatter; + Boolean_t ShowShade; + Boolean_t ShowEdge; + Boolean_t UseLightingEffect; + Boolean_t UseTranslucency; +} FieldLayers_s; + +/** + * General purpose field layers structure used for low level drawing code only. + * SetupXxxx is responsible for populating this general field layers structure + * from the specific layer structures above for CZInfo. + */ +typedef struct +{ + Boolean_t ShowMesh; + Boolean_t ShowContour; + Boolean_t ShowVector; + Boolean_t ShowScatter; + Boolean_t ShowShade; + Boolean_t ShowEdge; + Boolean_t UseLightingEffect; + Boolean_t UseTranslucency; +} CZFieldLayers_s; + +/** + */ +typedef struct _LinePlotLayers_s +{ +#if 0 /* in the future we may add a main power switch */ + Boolean_t Show; /* power switch */ +#endif + Boolean_t ShowLines; + Boolean_t ShowSymbols; + Boolean_t ShowBarCharts; + Boolean_t ShowErrorBars; +} LinePlotLayers_s; + + +typedef union _InterfaceAdjust_u +{ + double ScaleFact; + LgIndex_t Shift; +} InterfaceAdjust_u; + +typedef Boolean_t (*SuffixModifier_pf)(TP_IN_OUT double* Value, + const char* Suffix); + +typedef struct _InputSpecs_s +{ + Input_e Type; + double Min; + double Max; + InterfaceAdjust_u InterfaceAdjust; + SuffixModifier_pf SuffixModifier; +} InputSpec_s; + + +typedef struct _RGB_s +{ + ColorIndex_t R; + ColorIndex_t G; + ColorIndex_t B; +} RGB_s; + + +typedef struct _ControlPoint_s +{ + double ColorMapFraction; + RGB_s LeadRGB; + RGB_s TrailRGB; +} ControlPoint_s; + + +typedef struct _ColorMapBand_s +{ + short NumControlPoints; + ControlPoint_s ControlPoint[MaxColorMapControlPoints]; +} ColorMapBand_s; + + +typedef struct _EventAction_s +{ + int I; + int J; + int LastI; + int LastJ; + int BaseI; + int BaseJ; + int ButtonOrKey; + Event_e Event; + Boolean_t IsShifted; + Boolean_t IsAlted; + Boolean_t IsControlled; + Boolean_t WasShiftedOnButtonPress; + Boolean_t WasAltedOnButtonPress; + Boolean_t WasControlledOnButtonPress; +} EventAction_s; + +typedef struct _MacroCmd_s +{ + LString_t MacroLine; + struct _MacroCmd_s *NextCmd; +} MacroCmd_s; + + +typedef struct _IntegerRect_s +{ + LgIndex_t X1; + LgIndex_t Y1; + LgIndex_t X2; + LgIndex_t Y2; +} IntegerRect_s; + + +typedef struct _Rect_s +{ + double X1; + double Y1; + double X2; + double Y2; +} Rect_s; + +typedef struct _XY_s +{ + double X; + double Y; +} XY_s; + +typedef struct _IJKSkip_s +{ + LgIndex_t I; + LgIndex_t J; + LgIndex_t K; +} IJKSkip_s; + + + +/* + * + * NOTE ON RANGES (Ent and Index) + * + * Min, Max and Skip all use the following assignment logic: + * + * 0 = First element + * -1 = mxindex value, (X[mxindex-1] in c) + * -n = mxindex-n+1 value (X[mxindex+n] in c) + * n = n+1 value (X[n] in c) + * + */ + +/* + * 2/28/95: NOTE: EntRange_s is no longer used but may be + * needed later. + */ + +typedef struct _EntRange_s +{ + EntIndex_t Min; + EntIndex_t Max; + EntIndex_t Skip; +} EntRange_s; + + +typedef struct _IndexRange_s +{ + LgIndex_t Min; + LgIndex_t Max; + LgIndex_t Skip; +} IndexRange_s; + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if defined (THREED) +#endif +#endif /* TECPLOTKERNEL */ + +typedef struct _TextShape_s +{ + Font_e Font; + double Height; + Units_e SizeUnits; +} TextShape_s; + +#define AsciiShapeFontIsGreek(S) (((S)->UseBaseFont == FALSE) && ((S)->FontOverride == Font_Greek)) +#define AsciiShapeFontIsMath(S) (((S)->UseBaseFont == FALSE) && ((S)->FontOverride == Font_Math)) +#define AsciiShapeFontIsUserDefined(S) (((S)->UseBaseFont == FALSE) && ((S)->FontOverride == Font_UserDefined)) + + +typedef struct +{ + Boolean_t UseBaseFont; /* (Default = TRUE) */ + Font_e FontOverride;/* (Default = Font_Math)*/ + SymbolChar_t Char; +} AsciiShape_s; + +typedef struct _SymbolShape_s +{ + GeomShape_e GeomShape; + Boolean_t IsAscii; + AsciiShape_s AsciiShape; +} SymbolShape_s; + +#ifdef NOT_USED +struct _AddOnList_a +{ + /* added temporarily so Windows makelibtec works */ + int dummy; +}; +#endif + +/* ENDREMOVEFROMADDON */ + +typedef struct _AddOnList_a *AddOn_pa; + +typedef struct _NodeMap_a *NodeMap_pa; + +/* BEGINREMOVEFROMADDON */ +typedef struct _StylePointState_a *StylePointState_pa; +typedef struct _DataElementState_a *DataElementState_pa; +typedef struct _StyleElementState_a *StyleElementState_pa; +typedef struct _NormalCache_a *NormalCache_pa; +/* ENDREMOVEFROMADDON */ + + +#define INVALID_INDEX (-1) + +/* used to indicate that no neighboring element or zone exists */ +#define NO_NEIGHBORING_ELEMENT (-1) +#define NO_NEIGHBORING_ZONE (-1) + +typedef struct _FaceNeighbor_a *FaceNeighbor_pa; + +/** + */ +typedef struct _FaceMap_a *FaceMap_pa; + +/** + */ +typedef struct _ElemToFaceMap_a *ElemToFaceMap_pa; + +/** + */ +typedef struct _NodeToElemMap_a *NodeToElemMap_pa; + +/* BEGINREMOVEFROMADDON */ + +/* + * Enumerates the face neighbor array members to make indexed members + * identifiable. + */ +typedef enum +{ + FaceNeighborMemberArray_CellFaceNbrs, + FaceNeighborMemberArray_BndryConnectNbrsCompObscure, + FaceNeighborMemberArray_BndryConnectFaceToCellsMap, + FaceNeighborMemberArray_BndryConnectIsPerfectNbr, + FaceNeighborMemberArray_BndryConnectCellList, + FaceNeighborMemberArray_BndryConnectZoneList, + END_FaceNeighborMemberArray_e, + FaceNeighborMemberArray_Invalid = BadEnumValue +} FaceNeighborMemberArray_e; + +int const FaceNeighborNumMemberArrays = (int)END_FaceNeighborMemberArray_e; + +/* + * Enumerates the face map's array members to make indexed members + * identifiable. + */ +typedef enum +{ + FaceMapMemberArray_FaceNodeOffsets, + FaceMapMemberArray_FaceNodes, + FaceMapMemberArray_FaceLeftElems, + FaceMapMemberArray_FaceRightElems, + FaceMapMemberArray_FaceBndryItemOffsets, + FaceMapMemberArray_FaceBndryItemElems, + FaceMapMemberArray_FaceBndryItemElemZones, + END_FaceMapMemberArray_e, + FaceMapMemberArray_Invalid = BadEnumValue +} FaceMapMemberArray_e; + +const int FaceMapNumMemberArrays = (int)END_FaceMapMemberArray_e; + +/* + * Enumerates the element to face map's array members to make indexed members + * identifiable. + */ +typedef enum +{ + ElemToFaceMapMemberArray_ElemFaceOffsets, + ElemToFaceMapMemberArray_ElemFaces, + END_ElemToFaceMapMemberArray_e, + ElemToFaceMapMemberArray_Invalid = BadEnumValue +} ElemToFaceMapMemberArray_e; + +const int ElemToFaceMapNumMemberArrays = (int)END_ElemToFaceMapMemberArray_e; + +/* + * Enumerates the element map's array members to make indexed members + * identifiable. + */ +typedef enum +{ + NodeToElemMapMemberArray_NodeElemOffsets, + NodeToElemMapMemberArray_NodeElems, + END_NodeToElemMapMemberArray_e, + NodeToElemMapMemberArray_Invalid = BadEnumValue +} NodeToElemMapMemberArray_e; + +const int NodeToElemMapNumMemberArrays = (int)END_NodeToElemMapMemberArray_e; + +/* ENDREMOVEFROMADDON */ + + +typedef struct _FieldData_a *FieldData_pa; + +/** + */ +typedef struct _AuxData_s *AuxData_pa; + + +/** + * Enumerates the data value structure of a variable in a data file. + * For all but ordered cell centered data the classic, classic padded and + * classic plus formats are identical. All values are laid out contiguously + * in the file. The number of values written depends upon the value location: + * + * - FE nodal:\n + * The number of values equals the number of data points. + * - FE cell centered:\n + * The number of values equals the number of elements. + * - Ordered nodal:\n + * The number of values equals the number of data points. + * - Ordered cell centered:\n + * There are three formats: + * -# Classic (binary version < 103):\n + * Classic is a compressed format of ordered cell centered data in + * that it does not include ghost cells. The cell index of each cell + * does not correspond to the lowest corner point index of each cell + * as it does internally in Tecplot.\n + * The number of values in the data file is calculated as follows: + * @code + * NumValues = MAX(IMax-1,1) * MAX(JMax-1,1) * MAX(KMax-1,1); + * @endcode + * Where IMax, JMax, and KMax are the maximum point dimensions of the + * zone. + * -# Classic padded (binary version < 104):\n + * Classic padded is an intermediary format that was available only + * within Tecplot, Inc. The cell centered data includes the ghost cells + * and each cell index corresponds to the lowest corner point index of + * each cell.\n + * The number of values in the data file (including ghost cells) is + * calculated as follows: + * @code + * NumValues = IMax * JMax * KMax; + * @endcode + * Where IMax, JMax, and KMax are the maximum point dimensions of the + * zone. The contents of the ghost cells is undefined and should not + * be used. + * -# Classic plus (binary version >= 104):\n + * Classic plus is similar to classic padded except that it does not + * include the ghost cells of the slowest moving index greater than + * one.\n + * The number of values in the data file (including ghost cells) is + * calculated as follows: + * @code + * FinalIMax = IMax; + * FinalJMax = JMax; + * FinalKMax = KMax; + * + * // decrement the max index of the slowest moving index greater than 1 + * if (KMax > 1) + * FinalKMax--; + * else if (JMax > 1) + * FinalJMax--; + * else if (IMax > 1) + * FinalIMax--; + * + * NumValues = FinalIMax * FinalJMax * FinalKMax; + * @endcode + * Where IMax, JMax, and KMax are the maximum point dimensions of the + * zone. The contents of the ghost cells is undefined and should not + * be used. + */ +typedef enum +{ + DataValueStructure_Classic, + DataValueStructure_ClassicPadded, + DataValueStructure_ClassicPlus, + END_DataValueStructure_e, + /* BEGINREMOVEFROMADDON */ + DataValueStructure_Latest = (END_DataValueStructure_e - 1), + /* ENDREMOVEFROMADDON */ + DataValueStructure_Invalid = BadEnumValue +} DataValueStructure_e; + +/** + * Enumerates the data node structure of a node map in a data file. The classic + * format uses 1 based nodes while the classic plus format uses zero based + * node. + */ +typedef enum +{ + DataNodeStructure_Classic, /* ones based node maps */ + DataNodeStructure_ClassicPlus, /* zero based node maps */ + END_DataNodeStructure_e, + DataNodeStructure_Invalid = BadEnumValue +} DataNodeStructure_e; + +/** + * Enumerates the variable locking modes. The \ref VarLockMode_ValueChange mode + * prevents modification of the values in a variable but permits deletion, and + * the \ref VarLockMode_Delete mode prevents deletion of a varaible but permits + * modification. + */ +typedef enum +{ + VarLockMode_ValueChange, + VarLockMode_Delete, + END_VarLockMode_e, + VarLockMode_Invalid = BadEnumValue +} VarLockMode_e; + +typedef enum +{ + FieldMapMode_UseStrandID, + FieldMapMode_UseZoneSet, + END_FieldMapMode_e, + FieldMapMode_Invalid = BadEnumValue +} FieldMapMode_e; + +typedef enum +{ + UnloadStrategy_Auto, + UnloadStrategy_NeverUnload, + UnloadStrategy_MinimizeMemoryUse, + END_UnloadStrategy_e, + UnloadStrategy_Invalid = BadEnumValue +} UnloadStrategy_e; + +/* BEGINREMOVEFROMADDON */ + + + +typedef struct +{ + ColorIndex_t PresetZoneColor; + Boolean_t IsInBlockFormat; +} ZoneLoadInfo_s; + +/* + * Note: For FE Data, NumPtsI = Number of data points. + * NumPtsJ = Number of elements. + * NumPtsK = Number of points per element. + */ + +typedef struct _ZoneSpec_s +{ + UniqueID_t UniqueID; + ZoneName_t Name; + EntIndex_t ParentZone; + Strand_t StrandID; + double SolutionTime; + LgIndex_t NumPtsI; // ...NumDataPts + LgIndex_t NumPtsJ; // ...NumElements + LgIndex_t NumPtsK; // ...NumPtsPerElem or NumFaces + LgIndex_t ICellDim; // ...currently not used + LgIndex_t JCellDim; // ...currently not used + LgIndex_t KCellDim; // ...currently not used + ZoneType_e Type; + ZoneLoadInfo_s ZoneLoadInfo; + AuxData_pa AuxData; + Boolean_t BuildZoneOptInfo; + + /* classic data only */ + FaceNeighborMode_e FNMode; + Boolean_t FNAreCellFaceNbrsSupplied; // ...meaning we don't need to update them + + /* polytope data only */ + LgIndex_t NumFaceNodes; + LgIndex_t NumFaceBndryFaces; + LgIndex_t NumFaceBndryItems; +} ZoneSpec_s; + + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif /* TECPLOTKERNEL */ + +typedef struct _GenericImage_a *GenericImage_pa; + +typedef struct _TextBox_s +{ + TextBox_e BoxType; /* Used to be textbox */ + double Margin; /* Used to be textboxmargin */ + double LineThickness; /* Used to be textboxmargin */ + ColorIndex_t BColor; /* Used to be textboxcolor */ + ColorIndex_t FillBColor; /* Used to be textboxfillcolor */ +} TextBox_s; + + +typedef struct _Text_s +{ + UniqueID_t UniqueID; /* Not used yet */ + AnchorPos_u AnchorPos; + CoordSys_e PositionCoordSys; + EntIndex_t Zone; + Boolean_t AttachToZone; /* New */ + ColorIndex_t BColor; /* Used to be TextColor */ + TextShape_s TextShape; + TextBox_s Box; /* Box items used to be here*/ + double Angle; /* NOTE: short in v6, now in rad */ + TextAnchor_e Anchor; /* New */ + double LineSpacing; /* New */ + Scope_e Scope; + char *MacroFunctionCommand; + Clipping_e Clipping; + char *Text; + struct _Text_s *NextText; + struct _Text_s *PrevText; +} Text_s; + + +typedef struct _GenericGeomData_s +{ + FieldData_pa V1Base; + FieldData_pa V2Base; + FieldData_pa V3Base; +} GenericGeomData_s; + +typedef struct _PolarGeomData_s +{ + FieldData_pa ThetaBase; + FieldData_pa RBase; +} PolarGeomData_s; + +typedef struct _CartesianGeomData_s +{ + FieldData_pa XBase; + FieldData_pa YBase; + FieldData_pa ZBase; +} CartesianGeomData_s; + +/* + * This union is designed to allow different plottypes + * to access the same values by different names. In + * C++ we could use member access functions, or we + * could have used macros, but instead we use this + * union. NOTE: This only works if all the structures + * have the same alignment. + */ +typedef union _GeomData_u +{ + GenericGeomData_s Generic; + CartesianGeomData_s XYZ; + PolarGeomData_s ThetaR; +} GeomData_u; + +typedef struct _Geom_s +{ + UniqueID_t UniqueID; + GeomType_e GeomType; + CoordSys_e PositionCoordSys; + AnchorPos_u AnchorPos; + Boolean_t AttachToZone; + EntIndex_t Zone; + ColorIndex_t BColor; + Boolean_t IsFilled; + ColorIndex_t FillBColor; + LinePattern_e LinePattern; + double PatternLength; + double LineThickness; + Scope_e Scope; + DrawOrder_e DrawOrder; + Clipping_e Clipping; + FieldDataType_e DataType; + char *MacroFunctionCommand; + ArrowheadStyle_e ArrowheadStyle; + ArrowheadAttachment_e ArrowheadAttachment; + double ArrowheadSize; + double ArrowheadAngle; + SmInteger_t NumEllipsePts; + char *ImageFileName; + LgIndex_t ImageNumber; /* used only to locate images within .lpk files */ + Boolean_t MaintainAspectRatio; + double PixelAspectRatio; /* VerticalPixelsPerHorizontalPixel */ + SmInteger_t NumSegments; + SegPtsArray_t NumSegPts; + GeomData_u GeomData; + ImageResizeFilter_e ImageResizeFilter; + /* Internal Scratch */ + GenericImage_pa _ImageData; + struct _Geom_s *_NextGeom; + struct _Geom_s *_PrevGeom; +} Geom_s; + + +typedef struct _Text_s *Text_pa; +typedef struct _Geom_s *Geom_pa; + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if defined USE_OOSTYLE +#endif +#if defined USE_OOSTYLE +#endif +#endif /* TECPLOTKERNEL */ + +/* ENDREMOVEFROMADDON */ +/* - NO DOXYGEN COMMENT GENERATION - + * Page creation callback is responsible for creating a RenderHandler for the page and + * calling @ref TecEngPageCreateNew(ArbParam_t RenderHandle) + * + * The RenderHandler type can be anything, for example,a pointer to a class instance that will + * be responsible for handling requests from the engine to perform operations on + * a page. + * + * @param PageConstructionHints a string list of construction hints that can be used for deciding + * how the page should be displayed in an application's UI. The construction hints could have been + * restored from a saved layout file or passed to @ref TecUtilPageCreateNew function. + * + * @param RegistrationClientData + * Client data that was registered with the callback. + * + * @return TRUE if page create request was handled and TecEngPageCreateNew() returned TRUE. + * + * @sa TecEngPageCreateRegisterCallback, TecEngPageCreateNew + * + * @since + * 11.0-5-014 + */ +typedef Boolean_t (STDCALL *PageCreateCallback_pf)(StringList_pa PageConstructionHints, + ArbParam_t RegistrationClientData); + +/* - NO DOXYGEN COMMENT GENERATION - + * Page destruction callback responsible for destroying a page. + * + * @param PageClientData + * Data associated with a page that was returned from the PageCreateCallback_pf + * callback function. You will get a different value for each page. + * + * @param RegistrationClientData + * Data associated with the registration of this function. This will always return + * the value supplied in the original registration of this function. + * + * @sa TecEngPageDestroyRegisterCallback, PageCreateCallback_pf + * + * @since + * 11.0-5-014 + */ +typedef void (STDCALL *PageDestroyCallback_pf)(ArbParam_t PageClientData, + ArbParam_t RegistrationClientData); + +/* - NO DOXYGEN COMMENT GENERATION - + * Callback responsible for informing the parent application of a new current page. + * Note that this could be done via a state change monitor but a more secure method + * is needed as state changes may be shut down from time to time. + * + * @param PageClientData + * Data associated with a page that was returned from the PageCreateCallback_pf + * callback function. You will get a different value for each page. + * + * @param RegistrationClientData + * Data associated with the registration of this function. This will always return + * the value supplied in the original registration of this function. + * + * @since + * 11.0-5-017 + */ +typedef void (STDCALL *PageNewCurrentCallback_pf)(ArbParam_t PageClientData, + ArbParam_t RegistrationClientData); + +/* - NO DOXYGEN COMMENT GENERATION - + * Callback responsible for creation of an offscreen image. + * + * @param RegistrationClientData + * Data associated with the registration of this function. This will always return + * the value supplied in the original registration of this function. + * + * @param ImageHandle handle to a newly created image. This is an output parameter. + * + * @return TRUE if an offscreen image was created successfully. + * + * @since + * 11.2-0-054 + */ +typedef Boolean_t (STDCALL *OffscreenImageCreateCallback_pf)(ScreenDim_t Width, + ScreenDim_t Height, + ArbParam_t RegistrationClientData, + TP_OUT ArbParam_t* ImageHandle); + +/* - NO DOXYGEN COMMENT GENERATION - + * Callback responsible for destruction of an offscreen image. + * + * @param ImageHandle handle to an offscreen image to be destroyed. + * + * @param RegistrationClientData + * Data associated with the registration of this function. This will always return + * the value supplied in the original registration of this function. + * + * @since + * 11.2-0-054 + */ +typedef void (STDCALL *OffscreenImageDestroyCallback_pf)(ArbParam_t ImageHandle, + ArbParam_t RegistrationClientData); + +/* - NO DOXYGEN COMMENT GENERATION - + * Callback responsible for returning RGB values for a row. + * + * @param ImageHandle + * Handle to an off-screen image from which RGB values to be retrieved. + * + * @param Row + * Row for which RGB values to be retrieved. + * + * @param RedArray + * Array to receive the red byte values for the specified Row. The number of values in + * the array must equal the width of the image. The array address is maintained by the + * Tecplot Engine until the image is destroyed however it is reused for each invocation + * of this callback. + * + * @param GreenArray + * Array to receive the green byte values for the specified Row. The number of values in + * the array must equal the width of the image. The array address is maintained by the + * Tecplot Engine until the image is destroyed however it is reused for each invocation + * of this callback. + * + * @param BlueArray + * Array to receive the blue byte values for the specified Row. The number of values in + * the array must equal the width of the image. The array address is maintained by the + * Tecplot Engine until the image is destroyed however it is reused for each invocation + * of this callback. + * + * @param RegistrationClientData + * Data associated with the registration of this function. This will always return + * the value supplied in the original registration of this function. + * + * @return TRUE if successful, FALSE otherwise. + * + * @since + * 11.2-0-054 + */ +typedef Boolean_t (STDCALL *OffscreenImageGetRGBRowCallback_pf)(ArbParam_t ImageHandle, + ScreenDim_t Row, + ArbParam_t RegistrationClientData, + TP_ARRAY_OUT Byte_t* RedArray, + TP_ARRAY_OUT Byte_t* GreenArray, + TP_ARRAY_OUT Byte_t* BlueArray); + +#if defined MSWIN +/* - NO DOXYGEN COMMENT GENERATION - + * Callback responsible for printing an image on the specified printer DC + * + * @param PrintDC a device context of a printer on which the printing should be performed. + * + * @param ImageHandle handle to an image to print. + * + * @param Palette specifies if an image should be printed as a color or monochrome image. + * + * @param RegistrationClientData + * Data associated with the registration of this function. This will always return + * the value supplied in the original registration of this function. + * + * @return TRUE if the printing operation was successfull. + * + * @since + * 11.2-0-463 + */ +typedef Boolean_t (STDCALL *WinPrintImageCallback_pf)(HDC PrintDC, + ArbParam_t ImageHandle, + Palette_e Palette, + ArbParam_t RegistrationClientData); + +#endif /* MSWIN */ + +#if defined MSWIN +/* - NO DOXYGEN COMMENT GENERATION - + * Callback responsible for providing a printer context. + * + * @param RegistrationClientData + * Data associated with the registration of this function. This will always return + * the value supplied in the original registration of this function. + * + * @return HDC context of the destination printer. + * + * @since + * 11.2-0-468 + */ +typedef HDC(STDCALL *WinPrinterGetContextCallback_pf)(ArbParam_t RegistrationClientData); + +#endif /* MSWIN */ + +/* - NO DOXYGEN COMMENT GENERATION - + * Render destination callback responsible for switching the render destination + * of the OpenGL drawing state when requested by the Tecplot engine. + * + * @since + * 11.0-0-397 + * + * @param PageRenderDest + * Enumeration of page render destination of interest. + * + * @param RenderDestClientData + * Data associated with a render destination, such as returned from the PageCreateCallback_pf or + * OffscreenImageCreate_pf callback functions. + * + * @param RegistrationClientData + * Data associated with the registration of this function. This will always return + * the value supplied in the original registration of this function. + * + * @return + * TRUE if render destination was set successfully. FALSE, otherwise. + * + * @sa TecEngRenderDestRegisterCallback + */ +typedef Boolean_t (STDCALL *RenderDestCallback_pf)(PageRenderDest_e PageRenderDest, + ArbParam_t RenderDestClientData, + ArbParam_t RegistrationClientData); + +/* - NO DOXYGEN COMMENT GENERATION - + * Render query callback responsible for informing Tecplot if the page + * associated with the PageClientData should be rendered into. + * + * @since + * 11.0-5-018 + * + * @param PageClientData + * Data associated with a page that was returned from the + * PageCreateCallback_pf callback function. + * @param RegistrationClientData + * Data associated with the registration of this function. This will always + * return the value supplied in the original registration of this function. + * + * + * @return + * TRUE if Tecplot should render to the page identified by the + * PageClientData, FALSE otherwise. + * + * @sa TecEngRenderQueryRegisterCallback + */ +typedef Boolean_t (STDCALL *RenderQueryCallback_pf)(ArbParam_t PageClientData, + ArbParam_t RegistrationClientData); +/* - NO DOXYGEN COMMENT GENERATION - + * Render destination size callback responsible for returning the size of the + * specified render destination when requested by the Tecplot engine. + * + * @since + * 11.0-0-397 + * + * @param PageClientData + * Data associated with a page that was returned from the + * PageCreateCallback_pf callback function. + * @param RegistrationClientData + * Client data that was registered with the callback. + * @param Width + * Pointer who's contents should receive the width of the current render + * destination. + * @param Height + * Pointer who's contents should receive the height of the current render + * destination. + * + * @sa TecEngRenderDestSizeRegisterCallback + */ +typedef void (STDCALL *RenderDestSizeCallback_pf)(ArbParam_t PageClientData, + ArbParam_t RegistrationClientData, + TP_OUT LgIndex_t* Width, + TP_OUT LgIndex_t* Height); + +/* - NO DOXYGEN COMMENT GENERATION - + * Callback responsible for swapping the front and back buffers for the current + * OpenGL drawing state's render destination when requested by the Tecplot + * engine. + * + * @since + * 11.0-0-397 + * + * @param RegistrationClientData + * Client data that was registered with the callback. + * + * @sa TecUtilpBuffersRegisterCallback + */ +typedef void (STDCALL *SwapBuffersCallback_pf)(ArbParam_t RegistrationClientData); + + +/* - NO DOXYGEN COMMENT GENERATION - + * Callback responsible for querying of key states. + * + * @since + * 11.0-0-399 + * + * @param RegistrationClientData + * Client data that was registered with the callback. + * @param IsShiftKeyDown + * Boolean pointer. If non-NULL, set the boolean to TRUE if the Shift key is + * down or FALSE if it is up. + * @param IsAltKeyDown + * Boolean pointer. If non-NULL, set the boolean to TRUE if the Alt key is + * down or FALSE if it is up. + * @param IsCntrlKeyDown + * Boolean pointer. If non-NULL, set the boolean to TRUE if the Cntrl key is + * down or FALSE if it is up. + * + * @sa TecEngKeyStateRegisterCallback + */ +typedef void (STDCALL *KeyStateCallback_pf)(ArbParam_t RegistrationClientData, + TP_OUT Boolean_t* IsShiftKeyDown, + TP_OUT Boolean_t* IsAltKeyDown, + TP_OUT Boolean_t* IsCntrlKeyDown); + +/* - NO DOXYGEN COMMENT GENERATION - + * Callback responsible for querying of a mouse button state. + * + * @since + * 11.0-0-424 + * + * @param Button + * Mouse button number to query. Button numbers start at one. + * @param RegistrationClientData + * Client data that was registered with the callback. + * + * @return + * TRUE if the specified mouse button is down, FALSE otherwise. + * + * @sa TecEngMouseButtonStateRegisterCallback + */ +typedef Boolean_t (STDCALL *MouseButtonStateCallback_pf)(int Button, + ArbParam_t RegistrationClientData); + +/* - NO DOXYGEN COMMENT GENERATION - + * Callback responsible for setting wait cursor when requested by the kernel + * + * @since + * 11.2-0-302 + * + * @param Activate + * TRUE if the kernel is requesting that the wait cursor be activated. + * FALSE if the kernel is requesting that the wait cursor be deactivated. + * @param RegistractionClientData + * Client data that was registered with the callback. + * + * @sa TecEngWaitCursorStateRegisterCallback + */ +typedef void (STDCALL *WaitCursorStateCallback_pf)(Boolean_t Activate, + ArbParam_t RegistrationClientData); + +/* - NO DOXYGEN COMMENT GENERATION - + * Callback responsible for setting cursor style when requested by the kernel + * + * @since + * 11.2-0-302 + * + * @param CursorStyle + * The cursor style which the kernel is requesting. + * @param RenderHandle + * Handle to page where new cursor shape is being set. + * @param RegistractionClientData + * Client data that was registered with the callback. + * + * @sa TecEngBaseCursorStyleRegisterCallback + */ +typedef void (STDCALL *BaseCursorStyleCallback_pf)(CursorStyle_e CursorStyle, + ArbParam_t RenderHandle, + ArbParam_t RegistrationClientData); + +/* - NO DOXYGEN COMMENT GENERATION - + * Callback responsible for processing events when the Tecplot engine is busy + * peforming a requested operation. This callback will be called at regular + * intervals to repair the interface and if required check for interrupts. Very + * little work should be done by this function. + * + * @since + * 11.0-0-415 + * + * @param RegistrationClientData + * Client data that was registered with the callback. + * + * @sa TecEngProcessBusyEventsRegisterCallback, TecUtilInterrupt + */ +typedef void (STDCALL *ProcessBusyEventsCallback_pf)(ArbParam_t RegistrationClientData); + +/* - NO DOXYGEN COMMENT GENERATION - + * Callback responsible for launching a dialog. + * + * @since + * 11.0-0-415 + * + * @param RegistrationClientData + * Client data that was registered with this launch dialog callback. + * + * @return + * TRUE if the dialog was launched, FALSE if it could not be launched + * programmatically. + * + * @sa TecUtilDialogLaunch, TecUtilDialogDrop + */ +typedef Boolean_t (STDCALL *DialogLaunchCallback_pf)(ArbParam_t RegistrationClientData); + +/* - NO DOXYGEN COMMENT GENERATION - + * Callback responsible for dropping a dialog. + * + * @since + * 11.0-0-407 + * + * @param RegistrationClientData + * Client data that was registered with this drop dialog callback. + * + * @sa TecUtilDialogLaunch, TecUtilDialogDrop + */ +typedef void (STDCALL *DialogDropCallback_pf)(ArbParam_t RegistrationClientData); + +/* - NO DOXYGEN COMMENT GENERATION - + * Callback responsible for querying of the physical display's horizontal and + * vertical dot pitch. + * + * @since + * 11.0-0-407 + * + * @param RegistrationClientData + * Client data that was registered with the callback. + * @param IDotsPerCm + * Pointer who's contents should receive the physical display's horizontal + * dot pitch in terms of the number of dots per centimeter. + * @param JDotsPerCm + * Pointer who's contents should receive the physical display's vertical + * dot pitch in terms of the number of dots per centimeter. + * + * @sa TecEngDotPitchRegisterCallback + */ +typedef void (STDCALL *DotPitchCallback_pf)(ArbParam_t RegistrationClientData, + TP_OUT double* IDotsPerCm, + TP_OUT double* JDotsPerCm); + +/* - NO DOXYGEN COMMENT GENERATION - + * Callback responsible for querying of the physical display's width and + * height in pixels. + * + * @since + * 11.2-0-471 + * + * @param RegistrationClientData + * Client data that was registered with the callback. + * @param WidthInPixels + * Pointer who's contents should receive the physical display's width + * in pixels. NULL may be passed. + * @param HeightInPixels + * Pointer who's contents should receive the physical display's height + * in pixels. NULL may be passed. + * + * @sa TecEngScreenSizeRegisterCallback + */ +typedef void (STDCALL *ScreenSizeCallback_pf)(ArbParam_t RegistrationClientData, + TP_OUT int* WidthInPixels, + TP_OUT int* HeightInPixels); + +/* - NO DOXYGEN COMMENT GENERATION - + * Callback responsible for displaying a message box dialog and returning the + * user's response. + * + * @since + * 11.0-0-415 + * + * @param MessageString + * Message string to display in the dialog. + * @param MessageBoxType + * Type of message box to display. + * @param RegistrationClientData + * Client data that was registered with the callback. + * + * @return + * Result of user's response to the dialog. + * + * @sa TecEngDialogMessageBoxRegisterCallback + */ +typedef MessageBoxReply_e(STDCALL *DialogMessageBoxCallback_pf)(const char* MessageString, + MessageBoxType_e MessageBoxType, + ArbParam_t RegistrationClientData); + +/* - NO DOXYGEN COMMENT GENERATION - + * Callback responsible for displaying a status line + * + * @since + * 11.2-0-085 + * + * @param StatusString + * Message string to display in the dialog. + * + * @param RegistrationClientData + * Client data that was registered with the callback. + * + * @sa TecEngStatusLineRegisterCallback + */ +typedef void (STDCALL *StatusLineCallback_pf)(const char* StatusString, + ArbParam_t RegistrationClientData); + +/* - NO DOXYGEN COMMENT GENERATION - + * Callback that will be called with the updated progress status. + * + * @since 11.2-0-098 + * + * + * @param ProgressStatus + * Percentage of the progress. + * + * @param RegistrationClientData + * Client data that was registered with the callback. + * + * @sa TecEngProgressMonitorRegisterCallback + */ +typedef void (STDCALL *ProgressMonitorCallback_pf)(int ProgressStatus, + ArbParam_t RegistrationClientData); +/* - NO DOXYGEN COMMENT GENERATION - + * Callback that will be called with Tecplot Engine is about to perform a lengthy operation. + * The client that registers such the callback may present a user with a progress bar, + * if the ShowProgressBar argument is TRUE, and a stop button that would interrupt the operation by + * calling TecUtilInterrupt(). + * + * @since 11.2-0-098 + * + * @param ShowProgressBar + * Boolean indicating if the progress steps can be monitored for an operation. If TRUE, Tecplot Engine will be calling + * the registered ProgressMonitorCallback_pf function with the updated progress status. + * + * @param IsInterruptible + * Boolean indicating if the operation can be interrupted before completion. + * + * @param RegistrationClientData + * Client data that was registered with the callback. + * + * @sa TecEngProgressMonitorRegisterCallback + */ +typedef void (STDCALL *ProgressMonitorStartCallback_pf)(Boolean_t ShowProgressBar, + Boolean_t IsInterruptible, + ArbParam_t RegistrationClientData); +/* - NO DOXYGEN COMMENT GENERATION - + * Callback tht will be called with Tecplot Engine has finished performing a lengthy operation. + * At this point, client may hide progress bar that was shown during handling of ProgressMonitorStartCallback callback and + * disable or hide the stop button. + * + * @since 11.2-0-098 + * + * @param RegistrationClientData + * Client data that was registered with the callback. + * + * @sa TecEngProgressMonitorRegisterCallback + */ +typedef void (STDCALL *ProgressMonitorFinishCallback_pf)(ArbParam_t RegistrationClientData); + +/********************************************************* + * Add-on Timers + *********************************************************/ +/** + * This is called when a registered timer fires. + * + * @par Limitation: + * Unix and Linux versions of Tecplot currently do not fire timer events when + * Tecplot is running in batch mode (with the -b flag). This behavior + * limitation is subject to change. + * + * @param ClientData + * Arbitrary client data. + * + * @return + * Return TRUE if the timer should be reinstated. Return FALSE + * to stop subsequent callbacks. + * + * + * <FortranSyntax> + * INTEGER*4 FUNCTION MyAddOnTimerCallback( + * & ClientDataPtr) + * POINTER (ClientDataPtr,DummyClientData) + * </FortranSyntax> + */ +typedef Boolean_t (STDCALL *AddOnTimerCallback_pf)(ArbParam_t ClientData); + +/* - NO DOXYGEN COMMENT GENERATION - + * Callback that will be called when Tecplot Engine has requested an event timer to be created. + * + * @since 12.0.1.5642 + * + * @param ClientData + * ClientData that should be sent in the callback. + * + * @param TimerCallback + * Callback to fire when the timer interval has expired. + * + * @param Interval + * The time (in milliseconds) after which the timer callback should be called. + * + * @param RegistrationClientData + * Client data that was registered via TecEngTimerRegisterCallback. + * + * @return + * Return TRUE if the timer was successfully created, FALSE if not. + */ +typedef Boolean_t (STDCALL *TimerCallback_pf)(AddOnTimerCallback_pf TimerCallback, + ArbParam_t ClientData, + UInt32_t Interval, + ArbParam_t RegistrationClientData); + +/** + * This function is called when the user activates a menu item + * added via TecUtilMenuInsertOption or TecUtilMenuInsertToggle. + * + * @param RegistrationClientData + * Arbitrary client data. + */ +typedef void (STDCALL *MenuActivateCallback_pf)(ArbParam_t RegistrationClientData); + +/** + * This function is called when the a menu is deleted. + * + * @param RegistrationClientData + * Arbitrary client data. + */ +typedef void (STDCALL *MenuDeleteCallback_pf)(ArbParam_t RegistrationClientData); + +/** + * This function is called to determine the sensitivity for a menu item (option, + * toggle or submenu). + * + * @param RegistrationClientData + * Arbitrary client data. + * + * @return + * Return TRUE if the menu item should be sensitive to user input, + * or FALSE if it should be insensitive to user input (gray). + */ +typedef Boolean_t (STDCALL *MenuGetSensitivityCallback_pf)(ArbParam_t RegistrationClientData); + +/** + * This function is called to determine the checked state for a toggle menu item. + * + * @param RegistrationClientData + * Arbitrary client data. + * + * @return + * Return TRUE if the toggle should be checked, + * or FALSE if it should be unchecked. + */ +typedef Boolean_t (STDCALL *MenuGetToggleStateCallback_pf)(ArbParam_t RegistrationClientData); + + +/** + * This function is called when the user performs a probe event. + * + * @param IsNearestPoint + * This is TRUE if the previous probe event was a nearest point probe. + * This is FALSE if it was an interpolated probe. + * + * <FortranSyntax> + * SUBROUTINE MyProbeDestinationCallback( + * IsNearestPoint) + * INTEGER*4 IsNearestPoint + * </FortranSyntax> + */ +typedef void (STDCALL *ProbeDestination_pf)(Boolean_t IsNearestPoint); + + +/** + * This function type called when a probe callback is installed via + * TecUtilProbeInstallCallbackX. + * + * @param WasSuccessful + * This is TRUE if the previous probe event was successful. + * This is FALSE if it was the probe failed. Probe events may fail if the + * user probes in a region of the plot that contains no data. + * + * @param IsNearestPoint + * This is TRUE if the previous probe event was a nearest point probe. + * This is FALSE if it was an interpolated probe. + * + * @param ClientData + * Arbitrary client data. + * + */ +typedef void (STDCALL *ProbeDestinationX_pf)(Boolean_t WasSuccessful, + Boolean_t IsNearestPoint, + ArbParam_t ClientData); + + +/** + * DynamicMenu Functions are called upon a user selecting + * a menu item added via TecUtilMenuAddOption. + * + * <FortranSyntax> + * SUBROUTINE MyDynamicMenuCallback() + * </FortranSyntax> + */ +typedef void (STDCALL *DynamicMenuCallback_pf)(void); + +/** + * This callback signature is used to perform redraw events. + * + * @since + * 11.0-0-363 + * + * @param RedrawReason + * An enumerated value describing the reason for the re-draw event. + * @param ClientData + * Client data that was registered with the callback. + * + * @return + * TRUE if successfull, FALSE otherwise. + * + * <FortranSyntax> + * INTEGER*4 FUNCTION DrawEventCallback( + * & RedrawReason, + * & ClientDataPtr) + * INTEGER*4 RedrawReason + * POINTER (ClientDataPtr,ClientData) + * </FortranSyntax> + * + * @sa TecUtilEventAddPreDrawCallback(), TecUtilEventAddPostDrawCallback() + */ +typedef Boolean_t (STDCALL *DrawEventCallback_pf)(RedrawReason_e RedrawReason, + ArbParam_t ClientData); + + +/** + * Compares two strings from a list string. Note that either string may be NULL + * as StringLists allow for NULL elements. + * + * @param String1 + * String to compare against String2. + * @param String2 + * String to compare against String1. + * @param ClientData + * Contextual information that was passed to the 'StringListSort' function. + * + * @return + * - A value less than zero if String1 is less than String2. + * - A value of zero if String1 is equal to String2. + * - A value greater than zero if String1 is greater than String2. + */ +typedef int (STDCALL *StringListStringComparator_pf)(const char* String1, + const char* String2, + ArbParam_t ClientData); + +/** + * Gets a value at the specified point index using, if necessary, the private + * client data retrieved from the field data handle. + * + * @par Note: + * This callback is called asynchronously. This callback should NOT + * lock/unlock Tecplot. + * + * @since + * 10.0-3-128 + * + * @param FD + * Field data handle for which to set the value. This + * FieldValueGetFunction_pf must have been retrieved from this field data + * handle via TecUtilDataValueRefGetGetFunc. + * + * @param pt + * Zero-based index into the field data. + * + * @return + * Value for that index, always passed as a double precision floating-point + * value regardless of the data type of the field data handle. + * + * @sa TecUtilDataValueCustomLOD(), TecUtilDataValueGetClientData() + */ +typedef double(STDCALL *FieldValueGetFunction_pf)(const FieldData_pa FD, + LgIndex_t pt); + +/** + * Sets a value at the specified index using the private client data retrieved + * from the field data handle. + * + * @par Note: + * This callback is called asynchronously. This callback should NOT + * lock/unlock Tecplot. + * + * @since + * 10.0-3-128 + * + * @param FD + * Field data handle for which to set the value. This + * FieldValueSetFunction_pf must have been retrieved from this field data + * handle via TecUtilDataValueRefGetSetFunc. + * + * @param pt + * Zero-based index into the field data. + * + * @param val + * New value for that index, always passed as a double precision + * floating-point value regardless of the data type of the field data handle. + * + * @sa TecUtilDataValueCustomLOD(), TecUtilDataValueGetClientData() + */ +typedef void (STDCALL *FieldValueSetFunction_pf)(FieldData_pa FD, + LgIndex_t pt, + double val); + +/** + * Callback responsible for loading the specified variable for Tecplot using + * the private client data retrieved from the field data handle. + * + * @par Note: + * This callback is called asynchronously. With the exception of calls to + * modify the field data all calls back to Tecplot through the TecUtil layer + * should be limited to queries. + * + * @since + * 11.0-0-001 + * + * @param FieldData + * Field data handle of the variable load. + * + * @result + * TRUE if the variable was loaded, FALSE if unable to do so. + * + * @code + * typedef struct + * { + * char *DataFileName; + * long SeekOffset; + * LgIndex_t NumValues; + * ... other information needed to load variable data + * } MyVariableClientData_s; + * + * Boolean_t STDCALL MyVariableLoader(FieldData_pa FieldData) + * { + * REQUIRE(VALID_REF(FieldData)); + * + * MyVariableClientData_s *MyClientData = (MyVariableClientData_s *)TecUtilDataValueGetClientData(FieldData); + * + * // open the data file + * FILE *MyDataFile = fopen(MyClientData->DataFileName, "rb"); + * Boolean_t IsOk = (MyDataFile != NULL); + * + * // seek to the place in the file where the variable data is located + * IsOk = IsOk && (fseek(MyDataFile, MyClientData->SeekOffset, SEEK_SET) == 0); + * if (IsOk) + * { + * // load the data into the variable's field data + * IsOk = ReadMyDataInfoVariable(MyDataFile, MyClientData, FieldData); + * } + * + * // cleanup + * if (MyDataFile != NULL) + * fclose(MyDataFile); + * + * ENSURE(VALID_BOOLEAN(IsOk)); + * return IsOk; + * } + * @endcode + * + * @sa TecUtilDataValueCustomLOD(), TecUtilDataValueGetClientData() + */ +typedef Boolean_t (STDCALL *LoadOnDemandVarLoad_pf)(FieldData_pa FieldData); + +/** + * Callback responsible for performing private actions associated with a + * variable being unloaded using the private client data retrieved from the + * field data handle. Whenever possible the callback should honor Tecplot's + * request to unload the variable by returning TRUE. This callback is + * responsible for performing private actions associated with a variable being + * unloaded. + * + * Most add-ons should simply supply NULL for this callback thereby instructing + * Tecplot to handle the unloading (and subsequent reloading) of the variable + * without the intervention of the add-on. + * + * @par Note: + * This callback is called asynchronously. All calls back to Tecplot through + * the TecUtil layer should be limited to queries. + * + * @since + * 11.0-0-001 + * + * @param FieldData + * Field data handle of the variable Tecplot wants to unload. + * + * @code + * typedef struct + * { + * char *DataFileName; + * long SeekOffset; + * LgIndex_t NumValues; + * ... other information needed to load variable data + * } MyVariableClientData_s; + * + * Boolean_t STDCALL MyVariableUnload(FieldData_pa FieldData) + * { + * REQUIRE(VALID_REF(FieldData)); + * + * // We don't have any private data to cleanup (i.e in addition to the + * // private client data which we don't cleanup here) so all we have to do + * // is return TRUE or FALSE letting Tecplot know that it can or can not + * // unload the variable. + * Boolean_t Result = TRUE; // ...tell Tecplot to go ahead and unload the variable + * + * ENSURE(VALID_BOOLEAN(Result)); + * return Result; + * } + * @endcode + * + * @result + * TRUE if the variable can be unloaded, FALSE otherwise. The add-on should + * if at all possible honor the request to unload the variable. Most add-ons + * should return TRUE. + * + * @sa TecUtilDataValueCustomLOD(), TecUtilDataValueGetClientData() + */ +typedef Boolean_t (STDCALL *LoadOnDemandVarUnload_pf)(FieldData_pa FieldData); + +/** + * Callback responsible for performing private actions associated with a + * variable being cleaned up using the private client data retrieved from the + * field data handle. Most add-ons will need to register this callback in order + * to cleanup privately allocated client data. + * + * @par Note: + * This callback is called asynchronously. All calls back to Tecplot through + * the TecUtil layer should be limited to queries. + * + * @since + * 11.0-0-001 + * + * @param FieldData + * Field data handle of the variable being cleaned up. + * + * @code + * typedef struct + * { + * char *DataFileName; + * long SeekOffset; + * LgIndex_t NumValues; + * ... other information needed to load variable data + * } MyVariableClientData_s; + * + * void STDCALL MyVariableCleanup(FieldData_pa FieldData) + * { + * REQUIRE(VALID_REF(FieldData)); + * + * MyVariableClientData_s *MyClientData = (MyVariableClientData_s *)TecUtilDataValueGetClientData(FieldData); + * + * // cleanup privately allocated resources + * free(MyClientData->DataFileName); + * free(MyClientData); + * } + * @endcode + * + * @sa TecUtilDataValueCustomLOD(), TecUtilDataValueGetClientData() + */ +typedef void (STDCALL *LoadOnDemandVarCleanup_pf)(FieldData_pa FieldData); + +/** + * Callback responsible for loading the specified node mapping for Tecplot + * using the private client data retrieved from the node mapping handle. + * + * @par Note: + * This callback is called asynchronously. With the exception of calls to + * modify the node mapping, all calls back to Tecplot through the TecUtil + * layer should be limited to queries. + * + * @since + * 11.3-0-010 + * + * @param NodeMap + * Handle of the node mapping. + * + * @result + * TRUE if the node mapping was loaded, FALSE if unable to do so. + * + * @code + * typedef struct + * { + * char *DataFileName; + * long SeekOffset; + * ... other information needed to load node map data + * } MyNodeMapClientData_s; + * + * Boolean_t STDCALL MyNodeMapLoader(NodeMap_pa NodeMap) + * { + * REQUIRE(VALID_REF(NodeMap)); + * + * MyNodeMapClientData_s *MyClientData = + * (MyNodeMapClientData_s *)TecUtilDataNodeGetClientData(NodeMap); + * + * // open the data file + * FILE *MyDataFile = fopen(MyClientData->DataFileName, "rb"); + * Boolean_t IsOk = (MyDataFile != NULL); + * + * // seek to the place in the file where the node map data is located + * IsOk = IsOk && (fseek(MyDataFile, MyClientData->SeekOffset, SEEK_SET) == 0); + * if (IsOk) + * { + * // load the data into the zone's node map + * IsOk = ReadMyNodeMapDataIntoZone(MyDataFile, MyClientData, NodeMap); + * } + * + * // cleanup + * if (MyDataFile != NULL) + * fclose(MyDataFile); + * + * ENSURE(VALID_BOOLEAN(IsOk)); + * return IsOk; + * } + * @endcode + * + * @sa TecUtilDataNodeCustomLOD(), TecUtilDataNodeGetClientData() + */ +typedef Boolean_t (STDCALL *LoadOnDemandNodeMapLoad_pf)(NodeMap_pa NodeMap); + +/** + * Callback responsible for performing private actions associated with a + * node mapping being unloaded using the private client data retrieved from the + * node mapping handle. Whenever possible the callback should honor Tecplot's + * request to unload the node mapping by returning TRUE. + * + * Most add-ons should simply supply NULL for this callback thereby instructing + * Tecplot to handle the unloading (and subsequent reloading) of the node mapping + * without the intervention of the add-on. + * + * @par Note: + * This callback is called asynchronously. All calls back to Tecplot through + * the TecUtil layer should be limited to queries. + * + * @since + * 11.3-0-010 + * + * @param NodeMap + * Node mapping handle of the node mapping Tecplot wants to unload. + * + * @code + * Boolean_t STDCALL MyNodeMapUnload(NodeMap_pa NodeMap) + * { + * REQUIRE(VALID_REF(NodeMap)); + * + * // We don't have any private data to cleanup (i.e in addition to the + * // private client data which we don't cleanup here) so all we have to do + * // is return TRUE or FALSE letting Tecplot know that it can or can not + * // unload the variable. + * Boolean_t Result = TRUE; // ...tell Tecplot to go ahead and unload the node mapping + * + * ENSURE(VALID_BOOLEAN(Result)); + * return Result; + * } + * @endcode + * + * @result + * TRUE if the node mapping can be unloaded, FALSE otherwise. The add-on should + * if at all possible honor the request to unload the node mapping. Most add-ons + * should return TRUE. + * + * @sa TecUtilDataNodeCustomLOD(), TecUtilDataNodeGetClientData() + */ +typedef Boolean_t (STDCALL *LoadOnDemandNodeMapUnload_pf)(NodeMap_pa NodeMap); + +/** + * Callback responsible for performing private actions associated with a + * node mapping being cleaned up using the private client data retrieved from the + * node mapping handle. Most add-ons will need to register this callback in order + * to cleanup privately allocated client data. + * + * @par Note: + * This callback is called asynchronously. All calls back to Tecplot through + * the TecUtil layer should be limited to queries. + * + * @since + * 11.3-0-010 + * + * @param NodeMap + * Node Mapping data handle of the node mapping being cleaned up. + * + * @code + * typedef struct + * { + * char *DataFileName; + * long SeekOffset; + * ... other information needed to load node map data + * } MyNodeMapClientData_s; + * + * void STDCALL MyNodeMapCleanup(NodeMap_pa NodeMap) + * { + * REQUIRE(VALID_REF(NodeMap)); + * + * MyNodeMapClientData_s *MyClientData = (MyNodeMapClientData_s *)TecUtilDataNodeGetClientData(NodeMap); + * + * // cleanup privately allocated resources + * free(MyClientData->DataFileName); + * free(MyClientData); + * } + * @endcode + * + * @sa TecUtilDataNodeCustomLOD(), TecUtilDataNodeGetClientData() + */ +typedef void (STDCALL *LoadOnDemandNodeMapCleanup_pf)(NodeMap_pa NodeMap); + +/** + * Callback responsible for loading the specified face neighbor for Tecplot + * using the private client data retrieved from the face neighbor handle. + * + * @par Note: + * This callback is called asynchronously. With the exception of calls to + * modify the face neighbors, all calls back to Tecplot through the TecUtil + * layer should be limited to queries. + * + * @since + * 11.3-0-010 + * + * @param FaceNeighbor + * Handle of the face neighbors. + * + * @result + * TRUE if the face neighbors was loaded, FALSE if unable to do so. + * + * @code + * typedef struct + * { + * char *DataFileName; + * long SeekOffset; + * ...other information needed to load face neighbor data + * } MyFaceNeighborClientData_s; + * + * Boolean_t STDCALL MyFaceNeighborLoader(FaceNeighbor_pa FaceNeighbor) + * { + * REQUIRE(VALID_REF(FaceNeighbor)); + * + * MyFaceNeighborClientData_s *MyClientData = + * (MyFaceNeighborClientData_s*)TecUtilDataFaceNbrGetClientData(FaceNeighbor); + * + * // open the data file + * FILE *MyDataFile = fopen(MyClientData->DataFileName, "rb"); + * Boolean_t IsOk = (MyDataFile != NULL); + * + * // seek to the place in the file where the face neighbor data is located + * IsOk = IsOk && (fseek(MyDataFile, MyClientData->SeekOffset, SEEK_SET) == 0); + * if (IsOk) + * { + * // load the data into the zone's face neighbor + * IsOk = ReadMyFaceNeighborDataIntoZone(MyDataFile, MyClientData, FaceNeighbor); + * } + * + * // cleanup + * if (MyDataFile != NULL) + * fclose(MyDataFile); + * + * ENSURE(VALID_BOOLEAN(IsOk)); + * return IsOk; + * } + * @endcode + * + * @sa TecUtilDataFaceNbrCustomLOD(), TecUtilDataFaceNbrGetClientData() + */ +typedef Boolean_t (STDCALL *LoadOnDemandFaceNeighborLoad_pf)(FaceNeighbor_pa FaceNeighbor); + +/** + * Callback responsible for performing private actions associated with a + * face neighbors being unloaded using the private client data retrieved from + * the face neighbor handle. Whenever possible the callback should honor + * Tecplot's request to unload the face neighbors by returning TRUE. + * + * Most add-ons should simply supply NULL for this callback thereby instructing + * Tecplot to handle the unloading (and subsequent reloading) of the face + * neighbors without the intervention of the add-on. + * + * @par Note: + * This callback is called asynchronously. All calls back to Tecplot through + * the TecUtil layer should be limited to queries. + * + * @since + * 11.3-0-010 + * + * @param FaceNeighbor + * Face neighbor handle of the face neighbors Tecplot wants to unload. + * + * @code + * Boolean_t STDCALL MyFaceNeighborUnload(FaceNeighbor_pa FaceNeighbor) + * { + * REQUIRE(VALID_REF(FaceNeighbor)); + * + * // We don't have any private data to cleanup (i.e in addition to the + * // private client data which we don't cleanup here) so all we have to do + * // is return TRUE or FALSE letting Tecplot know that it can or can not + * // unload the variable. + * Boolean_t Result = TRUE; // ...tell Tecplot to go ahead and unload the face neighbors + * + * ENSURE(VALID_BOOLEAN(Result)); + * return Result; + * } + * @endcode + * + * @result + * TRUE if the face neighbors can be unloaded, FALSE otherwise. The add-on + * should if at all possible honor the request to unload the face neighbors. + * Most add-ons should return TRUE. + * + * @sa TecUtilDataFaceNbrCustomLOD(), TecUtilDataFaceNbrGetClientData() + */ +typedef Boolean_t (STDCALL *LoadOnDemandFaceNeighborUnload_pf)(FaceNeighbor_pa FaceNeighbor); + +/** + * Callback responsible for performing private actions associated with a face + * neighbors being cleaned up using the private client data retrieved from the + * face neighbor handle. Most add-ons will need to register this callback in + * order to cleanup privately allocated client data. + * + * @par Note: + * This callback is called asynchronously. All calls back to Tecplot through + * the TecUtil layer should be limited to queries. + * + * @since + * 11.3-0-010 + * + * @param FaceNeighbor + * Face neighbor data handle of the Face neighbors being cleaned up. + * + * @code + * typedef struct + * { + * char *DataFileName; + * long SeekOffset; + * ... other information needed to load face neighbor data + * } MyFaceNeighborClientData_s; + * + * void STDCALL MyFaceNeighborCleanup(FaceNeighbor_pa FaceNeighbor) + * { + * REQUIRE(VALID_REF(FaceNeighbor)); + * + * MyFaceNeighborClientData_s *MyClientData = (MyFaceNeighborClientData_s *)TecUtilDataFaceNbrGetClientData(FaceNeighbor); + * + * // cleanup privately allocated resources + * free(MyClientData->DataFileName); + * free(MyClientData); + * } + * @endcode + * + * @sa TecUtilDataFaceNbrCustomLOD(), TecUtilDataFaceNbrGetClientData() + */ +typedef void (STDCALL *LoadOnDemandFaceNeighborCleanup_pf)(FaceNeighbor_pa FaceNeighbor); + +/** + * Callback responsible for loading the specified face mapping for Tecplot + * using the private client data retrieved from the face mapping handle. + * + * @par Note: + * This callback is called asynchronously. With the exception of calls to + * modify the face mapping, all calls back to Tecplot through the TecUtil + * layer should be limited to queries. + * + * @since + * 11.2-1-0 + * + * @param FaceMap + * Handle of the face mapping. + * + * @result + * TRUE if the face mapping was loaded, FALSE if unable to do so. + * + * @code + * typedef struct + * { + * char *DataFileName; + * long SeekOffset; + * ... other information needed to load face map data + * } MyFaceMapClientData_s; + * + * Boolean_t STDCALL MyFaceMapLoader(FaceMap_pa FaceMap) + * { + * REQUIRE(VALID_REF(FaceMap)); + * + * MyFaceMapClientData_s *MyClientData = + * (MyFaceMapClientData_s *)TecUtilDataFaceMapGetClientData(FaceMap); + * + * // open the data file + * FILE *MyDataFile = fopen(MyClientData->DataFileName, "rb"); + * Boolean_t IsOk = (MyDataFile != NULL); + * + * // seek to the place in the file where the face map data is located + * IsOk = IsOk && (fseek(MyDataFile, MyClientData->SeekOffset, SEEK_SET) == 0); + * if (IsOk) + * { + * // load the data into the zone's face map + * IsOk = ReadMyFaceMapDataIntoZone(MyDataFile, MyClientData, FaceMap); + * } + * + * // cleanup + * if (MyDataFile != NULL) + * fclose(MyDataFile); + * + * ENSURE(VALID_BOOLEAN(IsOk)); + * return IsOk; + * } + * @endcode + * + * @sa TecUtilDataFaceMapCustomLOD(), TecUtilDataFaceMapGetClientData() + */ +typedef Boolean_t (STDCALL *LoadOnDemandFaceMapLoad_pf)(FaceMap_pa FaceMap); + +/** + * Callback responsible for performing private actions associated with a + * face mapping being unloaded using the private client data retrieved from the + * face mapping handle. Whenever possible the callback should honor Tecplot's + * request to unload the face mapping by returning TRUE. + * + * Most add-ons should simply supply NULL for this callback thereby instructing + * Tecplot to handle the unloading (and subsequent reloading) of the face mapping + * without the intervention of the add-on. + * + * @par Note: + * This callback is called asynchronously. All calls back to Tecplot through + * the TecUtil layer should be limited to queries. + * + * @since + * 11.2-1-0 + * + * @param FaceMap + * Face mapping handle of the face mapping Tecplot wants to unload. + * + * @code + * Boolean_t STDCALL MyFaceMapUnload(FaceMap_pa FaceMap) + * { + * REQUIRE(VALID_REF(FaceMap)); + * + * // We don't have any private data to cleanup (i.e in addition to the + * // private client data which we don't cleanup here) so all we have to do + * // is return TRUE or FALSE letting Tecplot know that it can or can not + * // unload the variable. + * Boolean_t Result = TRUE; // ...tell Tecplot to go ahead and unload the face mapping + * + * ENSURE(VALID_BOOLEAN(Result)); + * return Result; + * } + * @endcode + * + * @result + * TRUE if the face mapping can be unloaded, FALSE otherwise. The add-on should + * if at all possible honor the request to unload the face mapping. Most add-ons + * should return TRUE. + * + * @sa TecUtilDataFaceMapCustomLOD(), TecUtilDataFaceMapGetClientData() + */ +typedef Boolean_t (STDCALL *LoadOnDemandFaceMapUnload_pf)(FaceMap_pa FaceMap); + +/** + * Callback responsible for performing private actions associated with a + * face mapping being cleaned up using the private client data retrieved from the + * face mapping handle. Most add-ons will need to register this callback in order + * to cleanup privately allocated client data. + * + * @par Note: + * This callback is called asynchronously. All calls back to Tecplot through + * the TecUtil layer should be limited to queries. + * + * @since + * 11.2-1-0 + * + * @param FaceMap + * Face Mapping data handle of the face mapping being cleaned up. + * + * @code + * typedef struct + * { + * char *DataFileName; + * long SeekOffset; + * ... other information needed to load face map data + * } MyFaceMapClientData_s; + * + * void STDCALL MyFaceMapCleanup(FaceMap_pa FaceMap) + * { + * REQUIRE(VALID_REF(FaceMap)); + * + * MyFaceMapClientData_s *MyClientData = (MyFaceMapClientData_s *)TecUtilDataFaceMapGetClientData(FaceMap); + * + * // cleanup privately allocated resources + * free(MyClientData->DataFileName); + * free(MyClientData); + * } + * @endcode + * + * @sa TecUtilDataFaceMapCustomLOD(), TecUtilDataFaceMapGetClientData() + */ +typedef void (STDCALL *LoadOnDemandFaceMapCleanup_pf)(FaceMap_pa FaceMap); + + +/** + * ExtractDestination functions are called upon successful completion of an + * extract polyline or extract discrete points operation. + * + * @param NumPts + * Number of points extracted. + * + * @param XValues + * Double precision array of X-Coordinates of the extracted polyline. + * + * @param YValues + * Double precision array of Y-Coordinates of the extracted polyline. + * + * <FortranSyntax> + * INTEGER*4 FUNCTION MyExtractDestinationCallback( + * & NumPts, + * & XValues, + * & YValues) + * INTEGER*4 NumPts + * REAL*8 XValues + * REAL*8 YValues + * </FortranSyntax> + */ +typedef void (STDCALL *ExtractDestination_pf)(LgIndex_t NumPts, + double* XValues, + double* YValues); + + + +/** + * SelectFileOptionsCallback Functions are called when the + * "Options" button is pressed in the modal file selection + * dialog. + * + * <FortranSyntax> + * SUBROUTINE MySelectFileOptionsCallback() + * </FortranSyntax> + */ +typedef void (STDCALL *SelectFileOptionsCallback_pf)(void); + + + + +/** + * Post data load instruction callback for "Converter-Plus" addons. + * + * @param PreviousInstructions + * The previous set of instructions used by the converter. + * + * @param PreviousRawData + * The previous raw data associated with the instructions. + * + * @param PreviousZones + * Set of zones loaded with the previous instructions. + * + * <FortranSyntax> + * SUBROUTINE MyConverterPostReadCallback( + * & PreviousInstructions, + * & PreviousRawData, + * & PreviousZones) + * CHARACTER*(*) CommandString + * CHARACTER*(*) ErrMsgString + * POINTER (PreviousZones,DummyPreviousZonesData) + * </FortranSyntax> + * + */ +typedef void (STDCALL *ConverterPostReadCallback_pf)(const char* PreviousInstructions, + const char* PreviousRawData, + const Set_pa PreviousZones); + + +/** + * Callback registered by your addon to convert a foreign datafile into a + * Tecplot Binary datafile format. + * + * @return + * Return TRUE if the conversion is successful. Otherwise return FALSE. + * If FALSE is returned then *MessageString is assumed to contain an error + * message. + * + * @param DataFName + * Name of the original foreign data file to be converted. + * + * @param TempBinFName + * Name of the temporary binary datafile that is created (by your converter). + * + * @param MessageString + * Reference to a string. If an error occurs during conversion allocate space + * for an error message and copy the message string into that allocated + * space otherwise be sure to assign *MessageString to NULL. If + * *MessageString is non NULL Tecplot will release the allocated memory when + * finished. + * + * <FortranSyntax> + * INTEGER*4 FUNCTION MyDataSetConverterCallback( + * & DataFName, + * & TempBinFName, + * & MessageString) + * CHARACTER*(*) DataFName + * CHARACTER*(*) TempBinFName + * CHARACTER*(*) MessageString + * </FortranSyntax> + * + */ +typedef Boolean_t (STDCALL *DataSetConverter_pf)(char* DataFName, + char* TempBinFName, + TP_GIVES char** MessageString); + + + + + + + +/** + * Callback registered by your addon to process foreign loader instructions. + * When called, it must parse the supplied instructions and load the data into Tecplot. + * + * @return + * Return TRUE if the data is loaded successfully. Otherwise, FALSE. + * + * @param Instructions + * This contains all of the instructions needed to load the data. + * + * + * <FortranSyntax> + * INTEGER*4 FUNCTION MyDataSetLoaderCallback( + * & Instructions) + * POINTER (Instructions,DummyInstructionsData) + * </FortranSyntax> + */ +typedef Boolean_t (STDCALL *DataSetLoader_pf)(StringList_pa Instructions); + + + + + +/** + * Callback used to provide the ability to override data loader instructions + * while processing a layout. + * + * @return + * Return TRUE if the instructions are successfully replaced or left alone. + * Return FALSE if the user cancels the operation. + * + * @param Instructions + * The original instructions needed to load the data. + * + * <FortranSyntax> + * INTEGER*4 FUNCTION MyDataSetLoaderInstOverCallback( + * & Instructions) + * POINTER (Instructions,DummyInstructionsData) + * </FortranSyntax> + * + */ +typedef Boolean_t (STDCALL *DataSetLoaderInstructionOverride_pf)(StringList_pa Instructions); + + + +/** + * Callback used to assign extended curve settings. + * This is called when the user presses the "Curve Settings" + * button in the mapping style dialog. + * + * @param LineMapSet + * Set of line maps currently selected. + * @param SelectedLineMapSettings + * A string list of the curve settings for the Line-maps that are selected in the + * Line mappings dialog. + * + * <FortranSyntax> + * SUBROUTINE MyGetCurveSettingsCallback( + * & LineMapSet, + * & SelectedLineMapSettings) + * POINTER (LineMapSet,DummyLineMapData) + * POINTER (SelectedLineMapSettings,DummyLineMapSettings) + * </FortranSyntax> + */ +typedef void (STDCALL *GetCurveSettingsCallback_pf)(Set_pa LineMapSet, + StringList_pa SelectedLineMapSettings); + + + + +/** + * Callback function that returns an abbreviated version of the curve settings + * for a particular Line Map for display in the Line Mappings dialog. + * + * @param LineMap + * The map number that is currently being operated on. + * @param CurveSettings + * The string that Tecplot maintains which contains the extended curve fit + * settings for the current Line-map. This argument may be NULL indicating + * that defaults should be used. + * @param AbbreviatedSettings + * The short form of the CurveSettings that is allocated and returned from + * your function and used by Tecplot. This must be allocated by the addon + * using TecUtilStringAlloc(). + * + * <FortranSyntax> + * SUBROUTINE MyGetAbrevSettingsStringCallback( + * & LineMap, + * & CurveSettings, + * & AbbreviatedSettings), + * INTEGER*4 LineMap + * CHARACTER*(*) CurveSettings + * CHARACTER*(*) AbbreviatedSettings + * </FortranSyntax> + */ +typedef void (STDCALL *GetAbbreviatedSettingsStringCallback_pf)(EntIndex_t LineMap, + char* CurveSettings, + TP_GIVES char** AbbreviatedSettings); + + + + +/** + * This function returns a string (CurveInfoString) for Tecplot to display + * information about a particular curve in the curve info dialog. + * + * @param RawIndV + * The handle to the raw field data of the independent variable. + * @param RawDepV + * The handle to the raw field data of the dependent variable. + * @param IndVCoordScale + * An enumerated variable whose values are Scale_linear when the independent variable + * axis has a linear scale and Scale_log when it has a log scale. + * @param DepVCoordScale + * An enumerated variable whose values are Scale_linear when the dependent variable axis + * has a linear scale and Scale_log when it has a log scale. + * @param NumRawPts + * number of raw field data values. + * @param LineMap + * The map number that is currently being operated on. + * @param CurveSettings + * The curve settings string for the current Line-map. This argument may be + * NULL indicating that defaults should be used. + * @param CurveInfoString + * The string that is allocated and returned by your function and be + * presented in the Data/XY-Plot Curve Info dialog. The CurveInfoString must + * be allocated by the addon using TecUtilStringAlloc(). + * + * @return + * Return TRUE if the curve info string can be generated, otherwise FALSE. + * + * <FortranSyntax> + * INTEGER*4 FUNCTION MyGetCurveInfoStringCallback( + * & RawIndV, + * & RawDepV, + * & IndVCoordScale, + * & DepVCoordScale, + * & NumRawPts, + * & LineMap, + * & CurveSettings, + * & CurveInfoString) + * POINTER (RawIndV,DummyRawIndVData) + * POINTER (RawDepV,DummyRawDepVData) + * INTEGER*4 IndVCoordScale + * INTEGER*4 DepVCoordScale + * INTEGER*4 NumRawPts + * INTEGER*4 LineMap + * CHARACTER*(*) CurveSettings + * CHARACTER*(*) CurveInfoString + * </FortranSyntax> + */ +typedef Boolean_t (STDCALL *GetCurveInfoStringCallback_pf)(FieldData_pa RawIndV, + FieldData_pa RawDepV, + CoordScale_e IndVCoordScale, + CoordScale_e DepVCoordScale, + LgIndex_t NumRawPts, + EntIndex_t LineMap, + char* CurveSettings, + TP_GIVES char** CurveInfoString); + +/** + * Callback function used to calculate data points for an extended curve fit. + * + * @return + * Return TRUE if the curve can be calculated, otherwise FALSE. + * + * @param RawIndV + * The handle to the raw field data of the independent variable. + * @param RawDepV + * The handle to the raw field data of the dependent variable. + * @param IndVCoordScale + * An enumerated variable whose values are Scale_linear when the independent variable + * axis has a linear scale and Scale_log when it has a log scale. + * @param DepVCoordScale + * An enumerated variable whose values are Scale_linear when the dependent variable axis + * has a linear scale and Scale_log when it has a log scale. + * @param NumRawPts + * number of raw field data values. + * @param NumCurvePts + * The number of points that will construct the curve fit. + * @param LineMap + * The line map to operated on. + * @param CurveSettings + * The curve settings string for the current Line-map. This argument may be + * NULL indicating that defaults should be used. + * @param IndCurveValues + * A pre-allocated array of size NumCurvePts which the addon will populate with + * the independent values for the curve fit + * @param DepCurveValues. + * A pre-allocated array of size NumCurvePts which the add-on will populate + * with the dependent values for the curve fit. + * + * <FortranSyntax> + * INTEGER*4 FUNCTION MyGetLinePlotDataPointsCallback( + * & RawIndV, + * & RawDepV, + * & IndVCoordScale, + * & DepVCoordScale, + * & NumRawPts, + * & NumCurvePts, + * & LineMap, + * & CurveSettings, + * & IndCurveValues, + * & DepCurveValues) + * POINTER (RawIndV,DummyRawIndVData) + * POINTER (RawDepV,DummyRawDepVData) + * INTEGER*4 IndVCoordScale + * INTEGER*4 DepVCoordScale + * INTEGER*4 NumRawPts + * INTEGER*4 NumCurvePts + * INTEGER*4 LineMap + * CHARACTER*(*) CurveSettings + * REAL*8 IndCurveValues() + * REAL*8 DepCurveValues() + * </FortranSyntax> + */ +typedef Boolean_t (STDCALL *GetLinePlotDataPointsCallback_pf)(FieldData_pa RawIndV, + FieldData_pa RawDepV, + CoordScale_e IndVCoordScale, + CoordScale_e DepVCoordScale, + LgIndex_t NumRawPts, + LgIndex_t NumCurvePts, + EntIndex_t LineMap, + char* CurveSettings, + TP_OUT double* IndCurveValues, + TP_OUT double* DepCurveValues); +#if defined EXPORT_DEPRECATED_INTERFACES_TO_ADK_ONLY +/** + * @deprecated + * Please use \ref GetLinePlotDataPointsCallback_pf instead. + */ +typedef GetLinePlotDataPointsCallback_pf GetXYDataPointsCallback_pf; +#endif + + + + +/** + * A Callback function used to obtain an interpolated dependent value for an + * extended curve fit given an independent value. + * + * @return + * Return TRUE if it is possible to obtain the interpolated value, otherwise FALSE. + * + * @param RawIndV + * handle to the raw field data of the independent variable. + * @param RawDepV + * The handle to the raw field data of the dependent variable. + * @param IndVCoordScale + * An enumerated variable whose values are Scale_linear when the independent variable + * axis has a linear scale and Scale_log when it has a log scale. + * @param DepVCoordScale + * An enumerated variable whose values are Scale_linear when the dependent variable axis + * has a linear scale and Scale_log when it has a log scale. + * @param NumRawPts + * The number of field data values. + * @param NumCurvePts + * The number of points used to construct the curve fit. + * @param LineMapNum + * The line map number currently being operated on. + * @param CurveSettings + * The curve settings string for the current Line-map. This argument may be + * NULL indicating that defaults should be used. + * @param ProbeIndValue + * The independent value location of the probe (supplied). + * @param ProbeDepValue + * Reference to the calculated dependent value location of the probe. + * + * <FortranSyntax> + * INTEGER*4 FUNCTION MyGetProbeValueCallback( + * & RawIndV, + * & RawDepV, + * & IndVCoordScale, + * & DepVCoordScale, + * & NumRawPts, + * & NumCurvePts, + * & LineMapNum, + * & CurveSettings, + * & CurveInfoString, + * & ProbeIndValue, + * & ProbeDepValue) + * POINTER (RawIndV,DummyRawIndVData) + * POINTER (RawDepV,DummyRawDepVData) + * INTEGER*4 IndVCoordScale + * INTEGER*4 DepVCoordScale + * INTEGER*4 NumRawPts + * INTEGER*4 NumCurvePts + * INTEGER*4 LineMapNum + * CHARACTER*(*) CurveSettings + * REAL*8 ProbeIndValue + * REAL*8 ProbeDepValue + * </FortranSyntax> + * + */ +typedef Boolean_t (STDCALL *GetProbeValueCallback_pf)(FieldData_pa RawIndV, + FieldData_pa RawDepV, + CoordScale_e IndVCoordScale, + CoordScale_e DepVCoordScale, + LgIndex_t NumRawPts, + LgIndex_t NumCurvePts, + EntIndex_t LineMapNum, + char* CurveSettings, + double ProbeIndValue, + TP_OUT double* ProbeDepValue); + + + +#if defined MSWIN +typedef Boolean_t (STDCALL *PreTranslateMessage_pf)(MSG *pMsg); +#endif + + +/** + * Callback function pointer for providing a Dynamic Axis labels. + * @since + * 10.0-6-015 + * @param Value + * Value that corresponds to a tick label that will be drwan. + * + * @param ClientData + * Convenience storage of user client data. + * + * @param LabelString + * Output label for the tick mark. + * This must be allocated by the addon using TecUtilStringAlloc(). + * + * @return + * Returns TRUE if the LabelString has been successfully allocated. + * Otherwise, FALSE is returned. + */ +typedef Boolean_t (STDCALL *DynamicLabelCallback_pf)(double Value, + ArbParam_t ClientData, + TP_GIVES char** LabelString); + +/** + * This is called when Tecplot is idle. + * + * @par Note: + * Tecplot is never idle when running in batch mode (with the -b flag). + * + * @param ClientData + * Arbitrary client data. + * + * <FortranSyntax> + * INTEGER*4 FUNCTION MyOnIdleCallback( + * & ClientDataPtr) + * POINTER (ClientDataPtr,DummyClientData) + * </FortranSyntax> + * + */ +typedef void (STDCALL *OnIdleCallback_pf)(ArbParam_t ClientData); + +/** + * Callback responsible for executing the specified script file. + * + * @since + * 11.0-2-005 + * + * @param ScriptFileName + * Relative or absolute file name of the script to execute. If the path + * is relative it is relative to the current working directory. + * @param ClientData + * Client data registered with the callback. + * + * @return + * TRUE if the script executed successfully, FALSE otherwise. + * + * @sa TecUtilScriptExecRegisterCallback + */ +typedef Boolean_t (STDCALL *ScriptExecCallback_pf)(const char *ScriptFileName, + ArbParam_t ClientData); + +/* BEGINREMOVEFROMADDON */ +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if 0 /* NOTUSED */ +#endif +#if !defined NO_ASSERTS +#endif +#if defined MSWIN +#endif /* MSWIN */ +#if !defined (MSWIN) +#endif +#if defined Q_MAINMODULE +#else +#endif +#if 0 /* NOTUSED */ +#endif +#endif /* TECPLOTKERNEL */ + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif /* TECPLOTKERNEL */ + + +/* ENDREMOVEFROMADDON */ +struct _ViewState_a; +typedef struct _ViewState_a *SavedView_pa, *ViewState_pa; + + +#endif /* _GLOBAL_H */ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/INPUT.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/INPUT.h new file mode 100644 index 0000000000000000000000000000000000000000..d778ee598460e9f56cc51b2fbcc81fbcc91db49b --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/INPUT.h @@ -0,0 +1,196 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +/* +***************************************************************** +***************************************************************** +******* ******** +****** Copyright (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +***************************************************************** +***************************************************************** +*/ +#if defined EXTERN +#undef EXTERN +#endif +#if defined INITMODULE +#define EXTERN +#else +#define EXTERN extern +#endif + +/* Input Specification limits */ + +/* General */ +EXTERN InputSpec_s /*X*/ GridCoordInputSpec; +EXTERN InputSpec_s /*X*/ GridCoordFloatInputSpec; +EXTERN InputSpec_s /*X*/ XFrameCoordInputSpec; +EXTERN InputSpec_s /*X*/ YFrameCoordInputSpec; +EXTERN InputSpec_s /*X*/ XFrameCoordFloatInputSpec; +EXTERN InputSpec_s /*X*/ YFrameCoordFloatInputSpec; +EXTERN InputSpec_s /*X*/ XFrameCoordDeltaInputSpec; +EXTERN InputSpec_s /*X*/ YFrameCoordDeltaInputSpec; +EXTERN InputSpec_s /*X*/ XFrameCoordFloatDeltaInputSpec; +EXTERN InputSpec_s /*X*/ YFrameCoordFloatDeltaInputSpec; +EXTERN InputSpec_s /*X*/ FrameOffsetCoordInputSpec; +EXTERN InputSpec_s /*X*/ XPaperCoordInputSpec; +EXTERN InputSpec_s /*X*/ YPaperCoordInputSpec; +EXTERN InputSpec_s /*X*/ AxisPercentageInputSpec; +EXTERN InputSpec_s /*X*/ AngleInputSpec; +EXTERN InputSpec_s /*X*/ AngleToApproxInputSpec; +EXTERN InputSpec_s /*X*/ FieldOfViewInputSpec; +EXTERN InputSpec_s /*X*/ ZeroAndAboveLgIndexInputSpec; +EXTERN InputSpec_s /*X*/ ZeroAndAboveSmIntegerInputSpec; +EXTERN InputSpec_s /*X*/ ZeroAndAboveDoubleInputSpec; +EXTERN InputSpec_s /*X*/ AboveZeroLgIndexInputSpec; +EXTERN InputSpec_s /*X*/ AboveZeroDoubleInputSpec; +EXTERN InputSpec_s /*X*/ DoubleInputSpec; +EXTERN InputSpec_s /*X*/ EntIndexInputSpec; +EXTERN InputSpec_s /*X*/ EntRangeInputSpec; +EXTERN InputSpec_s /*X*/ IndexRangeInputSpec; +EXTERN InputSpec_s /*X*/ AboveZeroIndexRangeInputSpec; +EXTERN InputSpec_s /*X*/ ZeroToOneInputSpec; +EXTERN InputSpec_s /*X*/ PercentageInputSpec; +EXTERN InputSpec_s /*X*/ AboveZeroPercentageInputSpec; +EXTERN InputSpec_s /*X*/ SignedPercentageInputSpec; +EXTERN InputSpec_s /*X*/ RadiansInputSpec; +EXTERN InputSpec_s /*X*/ AboveZeroRadiansInputSpec; +EXTERN InputSpec_s /*X*/ TimeDateDoubleInputSpec; +EXTERN InputSpec_s /*X*/ AboveZeroTimeDateDoubleInputSpec; +EXTERN InputSpec_s /*X*/ AboveZeroElapsedTimeInputSpec; + + +/* Specific */ +#define MIN_VIEWPORT_SIZE 0.05 +EXTERN InputSpec_s /*X*/ SurfaceTranslucencyInputSpec; +EXTERN InputSpec_s /*X*/ MaxDepthBufferSizeInputSpec; +EXTERN InputSpec_s /*X*/ MaxMultiSamplesInputSpec; +EXTERN InputSpec_s /*X*/ MinBitsPerRGBPlaneInputSpec; +EXTERN InputSpec_s /*X*/ AnimationSpeedInputSpec; +EXTERN InputSpec_s /*X*/ AnimationNumStepsInputSpec; +EXTERN InputSpec_s /*X*/ MaxCustomColorsInInterfaceInputSpec; +EXTERN InputSpec_s /*X*/ MaxReducedPointsInputSpec; +EXTERN InputSpec_s /*X*/ MaxStripLengthInputSpec; +EXTERN InputSpec_s /*X*/ MaxPrimativesPerBlockInputSpec; +EXTERN InputSpec_s /*X*/ MaxTextureSizeInputSpec; +EXTERN InputSpec_s /*X*/ SuperSampleFactorInputSpec; +EXTERN InputSpec_s /*X*/ TickLengthInputSpec; +EXTERN InputSpec_s /*X*/ BorrowLicenseInputSpec; + + + + +/* I/O Related */ +EXTERN InputSpec_s /*X*/ HardcopyPaperSizeInputSpec; +EXTERN InputSpec_s /*X*/ HardcopyNumCopiesInputSpec; +EXTERN InputSpec_s /*X*/ HardcopyPrecisionInputSpec; +EXTERN InputSpec_s /*X*/ HardcopyPenSpeedInputSpec; +EXTERN InputSpec_s /*X*/ PenPlotterPenNumberInputSpec; +EXTERN InputSpec_s /*X*/ BitDumpDepthInputSpec; + + +/* Widths, physical lengths, etc. */ +EXTERN InputSpec_s /*X*/ XFrameDimensionInputSpec; +EXTERN InputSpec_s /*X*/ YFrameDimensionInputSpec; +EXTERN InputSpec_s /*X*/ LineThicknessInputSpec; +EXTERN InputSpec_s /*X*/ PatternLengthInputSpec; +EXTERN InputSpec_s /*X*/ AxisPercentageTextSizeInputSpec; +EXTERN InputSpec_s /*X*/ FrameTextSizeInputSpec; +EXTERN InputSpec_s /*X*/ GridTextSizeInputSpec; +EXTERN InputSpec_s /*X*/ PointTextSizeInputSpec; +EXTERN InputSpec_s /*X*/ TextBoxMarginInputSpec; +EXTERN InputSpec_s /*X*/ TextLineSpacingInputSpec; +EXTERN InputSpec_s /*X*/ ArrowheadSizeInputSpec; +EXTERN InputSpec_s /*X*/ AxisLabelOffsetInputSpec; +EXTERN InputSpec_s /*X*/ LegendLineSpacingInputSpec; +EXTERN InputSpec_s /*X*/ StreamStepSizeInputSpec; +EXTERN InputSpec_s /*X*/ StreamMaxStepsInputSpec; +EXTERN InputSpec_s /*X*/ ArrowheadSpacingInputSpec; +EXTERN InputSpec_s /*X*/ RulerPaddingInputSpec; +EXTERN InputSpec_s /*X*/ RulerThicknessInputSpec; +EXTERN InputSpec_s /*X*/ PickHandleWidthInputSpec; +EXTERN InputSpec_s /*X*/ ImageDimensionInputSpec; +EXTERN InputSpec_s /*X*/ ZoomScalePerFrameUnitInputSpec; +EXTERN InputSpec_s /*X*/ RGBLegendHeightInputSpec; + + + +/* Limit the number of objects or limit which object can be selected*/ +EXTERN InputSpec_s /*X*/ ColorMapGroupInputSpec; +EXTERN InputSpec_s /*X*/ SliceGroupInputSpec; +EXTERN InputSpec_s /*X*/ IsoSurfaceGroupInputSpec; +EXTERN InputSpec_s /*X*/ ContourGroupInputSpec; +EXTERN InputSpec_s /*X*/ ColorIndexInputSpec; +EXTERN InputSpec_s /*X*/ NumLightSourceShadesInputSpec; +EXTERN InputSpec_s /*X*/ NumberOfControlPointsInputSpec; +EXTERN InputSpec_s /*X*/ CustomLabelNumberInputSpec; +EXTERN InputSpec_s /*X*/ NumMinorTicksInputSpec; +EXTERN InputSpec_s /*X*/ AxisEdgeNumberInputSpec; +EXTERN InputSpec_s /*X*/ LineMapWhichXAxisInputSpec; +EXTERN InputSpec_s /*X*/ LineMapWhichYAxisInputSpec; +EXTERN InputSpec_s /*X*/ NumberOfCurvePointsInputSpec; +EXTERN InputSpec_s /*X*/ NumberOfContourLevelsInputSpec; +EXTERN InputSpec_s /*X*/ ColorMapOverrideLevelInputSpec; +EXTERN InputSpec_s /*X*/ ColorMapOverrideNumberInputSpec; +EXTERN InputSpec_s /*X*/ NumberOfColorMapCyclesInputSpec; +EXTERN InputSpec_s /*X*/ NumberOfRodPointsInputSpec; +EXTERN InputSpec_s /*X*/ NumberOfStreamtracesInputSpec; +EXTERN InputSpec_s /*X*/ NumberOfEllipsePointsInputSpec; +EXTERN InputSpec_s /*X*/ MaxPtsInALineInputSpec; +EXTERN InputSpec_s /*X*/ MaxChrsTextLabelsInputSpec; +EXTERN InputSpec_s /*X*/ MaxContourLevelsInputSpec; +EXTERN InputSpec_s /*X*/ MaxLinkGroupsInputSpec; + + +/* Ratios */ +EXTERN InputSpec_s /*X*/ DataAspectRatioLimitInputSpec; +EXTERN InputSpec_s /*X*/ DataAspectRatioResetInputSpec; +EXTERN InputSpec_s /*X*/ AxisBoxAspectRatioLimitInputSpec; +EXTERN InputSpec_s /*X*/ AxisBoxAspectRatioResetInputSpec; +EXTERN InputSpec_s /*X*/ AxisRatioInputSpec; +EXTERN InputSpec_s /*X*/ AxisBoxPaddingInputSpec; +EXTERN InputSpec_s /*X*/ ScreenDistanceRatioInputSpec; +EXTERN InputSpec_s /*X*/ LiftFractionInputSpec; +EXTERN InputSpec_s /*X*/ ZClipInputSpec; +EXTERN InputSpec_s /*X*/ VectorHeadSizeFractionInputSpec; + + +/* Misc */ +EXTERN InputSpec_s /*X*/ ValuePrecisionInputSpec; +EXTERN InputSpec_s /*X*/ PolynomialOrderInputSpec; +EXTERN InputSpec_s /*X*/ SplineSlopeInputSpec; +EXTERN InputSpec_s /*X*/ RotationStepSizeInputSpec; +EXTERN InputSpec_s /*X*/ SmoothRotationDegPerFrameUnitInputSpec; +EXTERN InputSpec_s /*X*/ TranslationStepSizeInputSpec; +EXTERN InputSpec_s /*X*/ ScaleStepSizeInputSpec; +EXTERN InputSpec_s /*X*/ SortLevelInputSpec; +EXTERN InputSpec_s /*X*/ AxisLabelSkipInputSpec; +EXTERN InputSpec_s /*X*/ TextAngleInputSpec; +EXTERN InputSpec_s /*X*/ ArrowheadAngleInputSpec; +EXTERN InputSpec_s /*X*/ MinCreaseAngleInputSpec; +EXTERN InputSpec_s /*X*/ ExponentInputSpec; +EXTERN InputSpec_s /*X*/ SmoothWeightInputSpec; +EXTERN InputSpec_s /*X*/ TriangleKeepFactorInputSpec; +EXTERN InputSpec_s /*X*/ PlotAttrColumnWidthInputSpec; +EXTERN InputSpec_s /*X*/ ImageQualityInputSpec; + diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/MASTER.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/MASTER.h new file mode 100644 index 0000000000000000000000000000000000000000..38c495dcf8cd913fd00f81a73a488ea01b521a2a --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/MASTER.h @@ -0,0 +1,684 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +/***************************************************************** + ***************************************************************** + ******* ******** + ****** Copyright (C) 1988-2008 Tecplot, Inc. ******* + ******* ******** + ***************************************************************** + *****************************************************************/ +/* BEGINREMOVEFROMADDON */ +/* NOTE: All code contained between comments that look like + * BEGINREMOVEFROMADDON + * ENDREMOVEFROMADDON + * are pulled out to create the MASTER.h file used in addons. + */ +/* ENDREMOVEFROMADDON */ + +#ifndef _MASTER_H_ +#define _MASTER_H_ + +/* + * Annotations that specify the life cycle of objects returned from functions + * and input and output parameters sent as function parameters. The following + * table specifies the meaning in their context. The annotations provide code + * generation tools with information for building language bindings to various + * Tecplot 360 and Tecplot SDK related libraries. + * + * For purposes of this table the client is one making the call and the service + * is the recipient. + * + * +==================+=========================+=================================================================+ + * | Function Context | Annotation | Meaning | + * | Result or | | | + * | Parameter | | | + * |==================+=========================+=================================================================| + * | Result | TP_OUT | Default for a function return value that does not transfer | + * | | | ownership. Because this is the most common scenario this | + * | | | annotation is implied and never explicitly used in this | + * | | | context. | + * |------------------+-------------------------+-----------------------------------------------------------------| + * | Scalar Result | TP_GIVES | Annotates a function scalar return value as one who's ownership | + * | | | is transfered to the client. The client is responsible for | + * | | | properly disposing the value. | + * |------------------+-------------------------+-----------------------------------------------------------------| + * | Array Result | TP_ARRAY_GIVES | Annotates a function array return value as one who's ownership | + * | | | is transfered to the client. The client is responsible for | + * | | | properly disposing the value. | + * |==================+=========================+=================================================================| + * | Parameter | TP_IN | Default for a function input parameter value sent to the | + * | | | service. Because this is the most common scenario this | + * | | | annotation is implied and never explicitly used. | + * |------------------+-------------------------+-----------------------------------------------------------------| + * | Parameter | TP_ACQUIRES | Annotates a function parameter as one that sends a value to | + * | | | the service through the parameter and acquires shared | + * | | | ownership of the input value with the client. The service is | + * | | | not responsible for disposing the value however it is | + * | | | expected that a symmetric API exists that "releases" the | + * | | | library of this shared ownership. For example: | + * | | | void addListener(TP_ACQUIRES Listener& listener); | + * | | | void removeListener(TP_RELEASES Listener& listener); | + * |------------------+-------------------------+-----------------------------------------------------------------| + * | Parameter | TP_RELEASES | Annotates a function parameter as one that sends a value to | + * | | | the service through the parameter and releases previously | + * | | | shared ownership of the | + * | | | input value with the client. The service is not responsible | + * | | | for disposing the value however it is expected that a | + * | | | symmetric API exists that "releases" the library of this | + * | | | shared ownership. For example: | + * | | | void addListener(TP_ACQUIRES Listener& listener); | + * | | | void removeListener(TP_RELEASES Listener& listener); | + * |------------------+-------------------------+-----------------------------------------------------------------| + * | Scalar Parameter | TP_OUT | Annotates a function scalar parameter as one that returns a | + * | | | value to the client through the parameter but does not | + * | | | transfer ownership of the output value to the client. | + * | | | The client is not responsible for disposing the value. | + * |------------------+-------------------------+-----------------------------------------------------------------| + * | Scalar Parameter | TP_IN_OUT | Annotates a function scalar parameter as one that both sends | + * | | | a value to the service and returns a value to the client | + * | | | through the parameter. Ownership of the input value is not | + * | | | transfered to the service nor is ownership of the output value | + * | | | transfered to the client. The service is not responsible for | + * | | | disposing the input value and the client is not responsible | + * | | | for disposing the output value. | + * |------------------+-------------------------+-----------------------------------------------------------------| + * | Array Parameter | TP_ARRAY_OUT | Annotates a function array parameter as one that returns a | + * | | | value to the client through the parameter but does not | + * | | | transfer ownership of the output value to the client. | + * | | | The client is not responsible for disposing the value. | + * |------------------+-------------------------+-----------------------------------------------------------------| + * | Array Parameter | TP_ARRAY_IN_OUT | Annotates a function array parameter as one that both sends | + * | | | a value to the service and returns a value to the client | + * | | | through the parameter. Ownership of the input value is not | + * | | | transfered to the service nor is ownership of the output value | + * | | | transfered to the client. The service is not responsible for | + * | | | disposing the input value and the client is not responsible | + * | | | for disposing the output value. | + * |------------------+-------------------------+-----------------------------------------------------------------| + * | Scalar Parameter | TP_GIVES | Annotates a function scalar parameter as one that returns a | + * | | | value to the client through the parameter and transfers | + * | | | ownership of the output value to the client. The client is | + * | | | responsible for properly disposing the value. | + * |------------------+-------------------------+-----------------------------------------------------------------| + * | Scalar Parameter | TP_RECEIVES | Annotates a function scalar parameter as one that sends a value | + * | | | to the service through the parameter and transfers ownership | + * | | | of the input value to the service. The service is responsible | + * | | | for properly disposing the value. | + * |------------------+-------------------------+-----------------------------------------------------------------| + * | Scalar Parameter | TP_RECEIVES_GIVES | Annotates a function scalar parameter as one that both sends | + * | | | a value to the service and returns a value to the client | + * | | | through the parameter. Ownership of the input value is | + * | | | transfered to the service and ownership of the output value is | + * | | | transfered to the client. The service is responsible for | + * | | | properly disposing the input value and the client is | + * | | | responsible for properly disposing the output value. | + * |------------------+-------------------------+-----------------------------------------------------------------| + * | Array Parameter | TP_ARRAY_GIVES | Annotates a function array parameter as one that returns a | + * | | | value to the client through the parameter and transfers | + * | | | ownership of the output value to the client. The client is | + * | | | responsible for properly disposing the value. | + * |------------------+-------------------------+-----------------------------------------------------------------| + * | Array Parameter | TP_ARRAY_RECEIVES | Annotates a function array parameter as one that sends a value | + * | | | to the service through the parameter and transfers ownership | + * | | | of the input value to the service. The service is responsible | + * | | | for properly disposing the value. | + * |------------------+-------------------------+-----------------------------------------------------------------| + * | Array Parameter | TP_ARRAY_RECEIVES_GIVES | Annotates a function array parameter as one that both sends | + * | | | a value to the service and returns a value to the client | + * | | | through the parameter. Ownership of the input value is | + * | | | transfered to the service and ownership of the output value is | + * | | | transfered to the client. The service is responsible for | + * | | | properly disposing the input value and the client is | + * | | | responsible for properly disposing the output value. | + * |==================+===================+=======================================================================| + */ + +/* + * First check to make sure that our life-cycle keywords are not in conflict with any system defines. + */ +#if defined TP_ACQUIRES || \ + defined TP_RELEASES || \ + defined TP_OUT || \ + defined TP_IN_OUT || \ + defined TP_ARRAY_OUT || \ + defined TP_ARRAY_IN_OUT || \ + defined TP_GIVES || \ + defined TP_RECEIVES || \ + defined TP_RECEIVES_GIVES || \ + defined TP_ARRAY_GIVES || \ + defined TP_ARRAY_RECEIVES || \ + defined TP_ARRAY_RECEIVES_GIVES + #error "Tecplot's parameter life-cycle keywords are in direct conflict with other meanings." +#endif + +#if defined INCLUDE_OBJECT_LIFECYCLE_ANNOTATIONS + #define TP_ACQUIRES __attribute((gccxml("acquires","in"))) + #define TP_RELEASES __attribute((gccxml("releases","in"))) + #define TP_OUT __attribute((gccxml("out"))) + #define TP_IN_OUT __attribute((gccxml("in","out"))) + #define TP_ARRAY_OUT __attribute((gccxml("array","out"))) + #define TP_ARRAY_IN_OUT __attribute((gccxml("array","in","out"))) + #define TP_GIVES __attribute((gccxml("gives","out"))) + #define TP_RECEIVES __attribute((gccxml("receives","in"))) + #define TP_RECEIVES_GIVES __attribute((gccxml("receives","in","gives","out"))) + #define TP_ARRAY_GIVES __attribute((gccxml("array","gives","out"))) + #define TP_ARRAY_RECEIVES __attribute((gccxml("array","receives","in"))) + #define TP_ARRAY_RECEIVES_GIVES __attribute((gccxml("array","receives","in","gives","out"))) +#else + #define TP_ACQUIRES + #define TP_RELEASES + #define TP_OUT + #define TP_IN_OUT + #define TP_ARRAY_OUT + #define TP_ARRAY_IN_OUT + #define TP_GIVES + #define TP_RECEIVES + #define TP_RECEIVES_GIVES + #define TP_ARRAY_GIVES + #define TP_ARRAY_RECEIVES + #define TP_ARRAY_RECEIVES_GIVES +#endif + +/* BEGINREMOVEFROMADDON */ +#ifdef NO_ASSERTS /* obfuscate names */ +#define ShutDownLicensing FreeAllExtraMapData +#define ProcessYMapInXDirection +#endif /* NO_ASSERTS */ + + +/************************************** + * LICENSING + **************************************/ +#if defined TECPLOTKERNEL && !defined ENGINE +/* CORE SOURCE CODE REMOVED */ +#if defined FLEXLM && defined RLM +#endif +#if !defined FLEXLM && !defined RLM +#endif +#endif + +#include "stdafx.h" + +#if defined MSWIN +#include "W__BASE.h" +#endif + +#include <string> +#include <map> +#include <vector> +#include <queue> + +#include "TranslatedString.h" + +/* + * The following is a temporary fix for figuring out which product is + * running. In the future when Focus and 360 use the same code base, + * we will have to do this dynamically (either with flags on the compiler + * or variables within Tecplot). + */ +/* ENDREMOVEFROMADDON */ + +#if defined _WIN32 + +#if !defined TECPLOTKERNEL + +#if !defined MSWIN +#define MSWIN +#endif /* !MSWIN */ + +/* For the sake of some older add-ons, + defined _WINDOWS, WINDOWS, and WIN32 + New code should always use MSWIN */ + +#if !defined WINDOWS +#define WINDOWS +#endif /* WINDOWS */ + +#if !defined _WINDOWS +#define _WINDOWS +#endif /* !_WINDOWS */ + +#if !defined WIN32 +#define WIN32 +#endif /* !WIN32 */ + +#if defined _DEBUG +#if !defined DEBUG +#define DEBUG +#endif +#elif defined CHECKED_BUILD +#if defined NO_ASSERTS +#undef NO_ASSERTS +#endif +#if defined NDEBUG +#undef NDEBUG +#endif +#else /* RELEASE */ +#if !defined NDEBUG +#define NDEBUG +#endif +#if !defined NO_ASSERTS +#define NO_ASSERTS +#endif +#endif /* _DEBUG */ +#endif /* TECPLOTKERNEL */ + +#if _MSC_VER >= 1400 +#define VS_2005 /* Using VS2005 Compiler */ +#endif + +#if !defined TECPLOTKERNEL && defined VS_2005 +/* Suppress the warnings about the + deprecated c runtime functions. */ + +#if !defined _CRT_SECURE_NO_DEPRECATE +#define _CRT_SECURE_NO_DEPRECATE +#endif +#endif /* !TECPLOTKERNEL && VS_2005 */ + +#endif /* MSWIN */ + +#ifdef NDEBUG +# ifdef _DEBUG +# error "Both NDEBUG and _DEBUG defined" +# endif +#elif defined TECPLOTKERNEL +# ifndef _DEBUG +# define _DEBUG +# endif +#endif + +/* Now a requirement */ +#define USE_3D_HARDWARE + +#ifndef THREED +# define THREED +#endif + +#include <stdio.h> +#include <ctype.h> +#include <math.h> + +#if defined QUICKDEMO +#define DEMO +#endif + +#if defined MicrosoftC +#define DOS +#endif + +#if defined CRAYX +#define CRAY +#endif + +#if defined IRISX +#define IRIS +#endif + +#if defined HPX +#define HPUX +#define HP +#endif + +#if defined IBMRS6000X +#define IBMRS6000 +#endif + +#if defined COMPAQALPHAX +#define COMPAQALPHA +#define COMPAQX +#define COMPAQ +#endif + +#if defined DECALPHAX +#define DECALPHA +#define DECX +#endif + +#if defined DECX +#define DEC +#endif + +#if defined SUNSOLARISX || defined SUNSOLARIS86X +#define SUNX +#endif + +#if defined SUNX +#define SUN +#endif + +#if defined IRISX || defined CRAYX || defined HPX || defined SUNX || defined CONVEXX +#define UNIXX +#define SYSV +#endif + +#if defined DECX || defined LINUX || defined IBMRS6000X || defined COMPAQX || defined DARWIN +#define UNIXX +#endif + +/* BEGINREMOVEFROMADDON */ +#include <stdarg.h> + + +/* A bit of OEM stuff */ +#define OEM_INVALID_CHECKSUM (LgIndex_t) -1 + +/* Hide the name of the checksum function */ +#if defined NDEBUG +# define DECRYPTTIMEDCODE FixupPlot +# define CHECKHASHEDCODE ExpandPlot +# define UPDATECLASSICOEMEHCKSUM ToggleQuadrants +# define UPDATEOEMCHECKSUM ComputeAngleFromQuatrant +# define InitOemSettings InitAngleQuatrantSettings +#endif + +#if defined MSWIN +#define USE_TRUETYPEFONTS +#endif +/* ENDREMOVEFROMADDON */ + +/* BEGINREMOVEFROMADDON */ + +#ifdef __cplusplus // STL + +#ifdef MSWIN + +#pragma warning(push, 1) /* warning disabling bellow doesn't actually have any effect on compiler warning. +* It appears that Microsft STL enables all the warning right back on. +* Therefore, the only way to hide them is to push existing warning level, +* lower the level for the time while STL headers are included and then restore + * previous warning level with a "pragma warning(pop)" + */ + +#pragma warning(disable: 4018) // signed/unsigned mismatch +#pragma warning(disable: 4100) // unreferenced formal parameter +#pragma warning(disable: 4146) // unary minus operator applied to unsigned type, + // result still unsigned +#pragma warning(disable: 4244) // 'conversion' conversion from 'type1' to 'type2', + // possible loss of data +#pragma warning(disable: 4245) // conversion from 'type1' to 'type2', signed/unsigned + // mismatch +#pragma warning(disable: 4511) // 'class' : copy constructor could not be generated +#pragma warning(disable: 4512) // 'class' : assignment operator could not be generated +#pragma warning(disable: 4663) // C++ language change: to explicitly specialize class + // template 'vector' +#pragma warning(disable: 4710) // 'function' : function not inlined +#pragma warning(disable: 4786) // identifier was truncated to 'number' characters + // in the debug information +#endif + +#ifdef MSWIN +#pragma warning(pop) //Restore old warning state. +#endif //MSWIN + +#endif //__cplusplus + + /* ENDREMOVEFROMADDON */ + +#ifdef MSWIN + /* BEGINREMOVEFROMADDON */ +#ifdef TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#ifdef _DEBUG +#endif +#endif /* TECPLOTKERNEL */ + /* ENDREMOVEFROMADDON */ + +#ifndef TECPLOTKERNEL +#if defined VS_2005 +#define Widget LONG_PTR /* correct for 32 & 64 bit builds */ +#else +#define Widget long +#endif +#endif + + + +#endif /* MSWIN */ + + +#if defined UNIXX && defined ENGINE + typedef void *Widget; +#endif + + +#include <string.h> + +#if !defined SYSV && !defined MSWIN +#include <strings.h> +#endif + +#if defined (MicrosoftC) +#include <stdlib.h> +#define EXECOS +#ifndef FAR +#define FAR +#endif +#define VOID void +#endif + +#include <sys/types.h> +#include <stdlib.h> + +#if defined UNIXX +#if !defined ENGINE +#define X11 +#define MOTIF +#endif +#define FAR +#define NEAR +#include <unistd.h> +#endif + +/* BEGINREMOVEFROMADDON */ +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if !defined THREADS_BY_PTHREADS && !defined THREADS_BY_WINAPI +#endif +#if defined THREADS_BY_PTHREADS +#endif +#endif +/* ENDREMOVEFROMADDON */ + +/* BEGINREMOVEFROMADDON */ +/* OPENGL currently a must have */ +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# if !defined ENGINE +# if defined UNIXX +# endif +# endif +#endif +/* ENDREMOVEFROMADDON */ +/* + * If not building the tecplot kernel then at least + * include the X Instrinsics. This will make most + * development for addons etc work. + */ + +/* NOTE: MOTIF not defined if ENGINE is defined */ +#if defined MOTIF +# if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# if XmVERSION == 1 && XmREVISION == 0 +# endif +# else +# include <X11/Intrinsic.h> +# endif +#endif + +#if defined MOTIF +#define CREATE_DIALOG_PARAMS Widget W +typedef Widget ComboBoxWidget_t; +typedef Widget DropDownListWidget_t; +typedef Widget FileDialogWidget_t; +typedef Widget LabelWidget_t; +typedef Widget ListWidget_t; +typedef Widget OptionMenuWidget_t; +typedef Widget PullDownMenuWidget_t; +typedef Widget ScaleWidget_t; +typedef Widget TextFieldWidget_t; +typedef Widget ToggleWidget_t; +typedef Widget ButtonWidget_t; +typedef Widget GridWidget_t; +#endif +#if defined MSWIN +#include <windows.h> +#define CREATE_DIALOG_PARAMS CWnd *, LaunchDialogMode_e +typedef Widget ComboBoxWidget_t; +typedef Widget DropDownListWidget_t; +typedef Widget FileDialogWidget_t; +typedef Widget LabelWidget_t; +typedef Widget ListWidget_t; +typedef Widget OptionMenuWidget_t; +typedef Widget PullDownMenuWidget_t; +typedef Widget ScaleWidget_t; +typedef Widget TextFieldWidget_t; +typedef Widget ToggleWidget_t; +typedef Widget ButtonWidget_t; +typedef Widget GridWidget_t; +#endif + +/* BEGINREMOVEFROMADDON */ +#if defined MSWIN && defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if defined TRACE +#endif +#if defined TRACE0 +#endif +#if defined TRACE1 +#endif +#if defined TRACE2 +#endif +#if defined TRACE3 +#endif +#if defined NDEBUG +#else +#endif +#endif /* MSWIN */ + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif /* TECPLOTKERNEL */ +/* ENDREMOVEFROMADDON */ + +/* Assume that if TRACE is not defined, then none of the TRACE macros are */ +#if !defined (TRACE) +/* TRACE is not used by non-debug builds */ +#if defined NDEBUG +#if defined MSWIN +#define TRACE __noop +#define TRACE0(s) __noop +#define TRACE1(S,a1) __noop +#define TRACE2(s,a1,a2) __noop +#define TRACE3(s,a1,a2,a3) __noop +#else +#define TRACE(str) ((void)0) +#define TRACE0(str) ((void)0) +#define TRACE1(str,a1) ((void)0) +#define TRACE2(str,a1,a2) ((void)0) +#define TRACE3(str,a1,a2,a3) ((void)0) +#endif /* MSWIN */ +#else /* DEBUG */ +#if defined MSWIN +/* If the add-on is running in debug mode but does not + * use MFC, then no TRACE macro is available. Thus, to make tracing available, + * map TRACE to the win32 OutpuDebugString() function. + */ +# define TRACE(str) do { OutputDebugStringA(str); } while (0) +# define TRACE1(str,a1) do { char s[5000]; sprintf(s,str,a1); OutputDebugStringA(s); } while (0) +# define TRACE2(str,a1,a2) do { char s[5000]; sprintf(s,str,a1,a2); OutputDebugStringA(s); } while (0) +# define TRACE3(str,a1,a2,a3) do { char s[5000]; sprintf(s,str,a1,a2,a3); OutputDebugStringA(s); } while (0) +# define TRACE0(str) TRACE(str) +#else +#define TRACE printf +#define TRACE0 printf +#define TRACE1 printf +#define TRACE2 printf +#define TRACE3 printf +#endif /* MSWIN */ +#endif /* NDEBUG */ +#endif /* !defined (TRACE) */ + + +/* + Platform independent way for add-ons to know how much space + to allocate for a filename. +*/ +#if !defined MAX_SIZEOFUTF8CHAR +#define MAX_SIZEOFUTF8CHAR 1 +#endif + +#if !defined (MaxCharsFilePath) +# if defined (MSWIN) +# define MaxCharsFilePath (_MAX_PATH*MAX_SIZEOFUTF8CHAR+1) /* Includes traling '\0' */ +# else +# define MaxCharsFilePath 2047 /* ...not really a hard limit for Linux/Unix */ +# endif /* MSWIN */ +#endif /* !MaxCharsFilePath */ + +/* BEGINREMOVEFROMADDON */ + +/* + * Under Windows, if we are doing a release build (NDEBUG) that is not a CHECKED_BUILD + * then NO_ASSERTS should be defined + */ +#if defined MSWIN && defined NDEBUG && !defined NO_ASSERTS && !defined CHECKED_BUILD +/* intentionally break the compile */ +# error "define NO_ASSERTS for release builds" +#endif + +/* + * Under Windows, if we are doing a CHECKED_BUILD then it should + * also be a release build (NDEBUG) + */ +#if defined MSWIN && defined CHECKED_BUILD && !defined NDEBUG +# error "CHECKED_BUILDS must also be release builds" +#endif + + +#if defined NO_ASSERTS +# define USE_MACROS_FOR_FUNCTIONS +#endif +/* ENDREMOVEFROMADDON */ + +/* BEGINREMOVEFROMADDON */ +/* + * Under Linux the definition of NULL has a cast that conflicts with our own + * casting causing warnings that make it tough to find real problems. + */ +#if defined LINUX && defined NULL +# undef NULL +# define NULL 0 +#endif + +/* + */ +#if !defined MSWIN && !defined ENGINE && !defined ISMESA +#define DISALLOW_OFFSCREEN_EXPORT_IN_BATCH +#endif + +/* ENDREMOVEFROMADDON */ + +#endif /* _MASTER_H_ */ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/Make/files b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..084478a07adbccaba833762d6eb736781b56cd17 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/Make/files @@ -0,0 +1,21 @@ +alloc.cpp +arrlist.cpp +auxdata.cpp +dataio4.cpp +dataio.cpp +dataset0.cpp +dataset.cpp +datautil.cpp +filestream.cpp +geom2.cpp +q_msg.cpp +q_unicode.cpp +set.cpp +strlist.cpp +strutil.cpp +tassert.cpp +tecxxx.cpp +TranslatedString.cpp + +LIB = $(FOAM_LIBBIN)/libtecio + diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/Make/options b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..a355d90c5eee1f81e6784e993cc2b70acca5b431 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/Make/options @@ -0,0 +1,7 @@ +#include "tecioOptions" + +EXE_INC = \ + $(TECIO_FLAGS) $(TECIO_INC) + +LIB_LIBS = \ + $(TECIO_LIBS) diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/Make/tecioOptions b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/Make/tecioOptions new file mode 100644 index 0000000000000000000000000000000000000000..f8dcf487594354360c5c7fb4094565f145b7c992 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/Make/tecioOptions @@ -0,0 +1,20 @@ +#if defined(linux64) + + TECIO_FLAGS = -DMAKEARCHIVE -DLINUX -DLINUX64 -DUSEENUM -DTHREED -U_WIN32 + +#elif defined(linuxIA64) + + TECIO_FLAGS = -DMAKEARCHIVE -DLINUX -DLINUXI64 -DUSEENUM -DTHREED -U_WIN32 + +#elif defined(linux) + + TECIO_FLAGS = -DMAKEARCHIVE -DLINUX -DUSEENUM -DTHREED -U_WIN32 + +#else + +# error architecture not supported for compiling tecio. + +#endif + +TECIO_INC = +TECIO_LIBS = diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/Q_MSG.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/Q_MSG.h new file mode 100644 index 0000000000000000000000000000000000000000..84f1d1af76ed05ab6e794f8dcd6210dd7cea0d60 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/Q_MSG.h @@ -0,0 +1,72 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +#ifndef Q_MSG_H +#define Q_MSG_H +/* +****************************************************************** +****************************************************************** +******* ******** +****** (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +****************************************************************** +****************************************************************** +*/ +#if defined EXTERN +#undef EXTERN +#endif +#if defined Q_MSGMODULE +#define EXTERN +#else +#define EXTERN extern +#endif + +#define MAX_STATUS_LINE_MSG_LEN 255 + +#include "TranslatedString.h" + +EXTERN Boolean_t WrapString(const char *OldString, + char **NewString); +EXTERN void Warning(tecplot::strutil::TranslatedString Format, + ...); /* zero or more arguments */ +# if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif +EXTERN void ErrMsg(tecplot::strutil::TranslatedString Format, + ...); /* zero or more arguments */ +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if !defined ENGINE +#endif +#if !defined ENGINE +#if defined MOTIF +#endif +#endif +#if !defined ENGINE +#endif +#if defined Q_MSGMODULE +#else +#endif +#endif // TECPLOTKERNEL + +#endif // Q_MSG_H diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/Q_UNICODE.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/Q_UNICODE.h new file mode 100644 index 0000000000000000000000000000000000000000..b91c2ca65ec21b810fc7022572b391f0f974ecab --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/Q_UNICODE.h @@ -0,0 +1,93 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +/* +****************************************************************** +****************************************************************** +******* ******** +****** (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +****************************************************************** +****************************************************************** +*/ + + +#if !defined Q_UNICODE_H_ +# define Q_UNICODE_H_ + +#if defined EXTERN +#undef EXTERN +#endif +#if defined Q_UNICODEMODULE +#define EXTERN +#else +#define EXTERN extern +#endif + +namespace tecplot +{ +namespace strutil +{ + +// functions +Boolean_t IsValidUtf8LeadByte(Byte_t ch); +Boolean_t IsValidUtf8ContinuingByte(Byte_t ch); +Boolean_t IsValidUtf8Byte(Byte_t ch); + +Boolean_t IsValidUtf8String(const char *str); +Boolean_t ShouldConvertWideStringToUtf8String(const wchar_t *str); +void InitTranslatedStrings(); +void CleanUpTranslatedStrings(); + +Boolean_t IsNullOrZeroLengthString(const char *S); +Boolean_t IsNullOrZeroLengthString(tecplot::strutil::TranslatedString TS); + +Boolean_t IsEmptyString(const char *S); +Boolean_t IsEmptyString(tecplot::strutil::TranslatedString S); +Boolean_t IsEmptyString(const wchar_t* S); + +#if defined MSWIN + +std::string LookUpTranslation(std::string& strEnglish); +void MsWinInitTranslatedStrings(); + +std::string WStringToString(std::wstring str); +std::wstring StringToWString(std::string str); + +std::wstring MultiByteToWideChar(const char *Utf8Str, + unsigned int CodePage); + +std::string WideCharToMultiByte(const wchar_t *WideStr, + unsigned int CodePage); + +// Conversion +std::string WideCharToUtf8(const wchar_t* str); +std::wstring Utf8ToWideChar(const char *str); +char *getenv(const char *str); + +#endif + +} +} + +#endif diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/SET.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/SET.h new file mode 100644 index 0000000000000000000000000000000000000000..2ab99f64a03cf46447996b42e62fd29224c15c72 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/SET.h @@ -0,0 +1,283 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +#if defined EXTERN +#undef EXTERN +#endif +#if defined SETMODULE +#define EXTERN +#else +#define EXTERN extern +#endif + +#ifndef _SET_H_INCLUDED +#define _SET_H_INCLUDED + +/* +***************************************************************** +***************************************************************** +******* ******** +****** Copyright (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +***************************************************************** +***************************************************************** +*/ + +#define PadOut(X,Y) ((int)(((X)-1)/(Y)+1)*(Y)) +#define SetBitSize (8*sizeof(SetData_t)) +#define SetLastBit (((unsigned long)1)<<(SetBitSize-1)) + +#if defined _DEBUG +# define USE_FUNCTIONS_FOR_SETS +#endif + +/* * + * * NOTE: "Set_pa" is a pointer to an "abstract type", + * * hence the "_pa". Pointer here is akin to "handle". + * * Any routines dealing with the internals of Set_pa + * * or Set_a must be in the same file as these routines + * */ + +/* Set_a is intentionally not defined to further + * deter usage of this private structure */ +struct _Set_a +{ + /* * PRIVATE * */ + SetIndex_t size; + SetData_pt data; +}; + +/* + * Checks set for NULL. + */ +#define IsSetNull(Set) ((Set)==NULL) + +/** + * Indicates how many bytes are required to store the set data. + */ +inline size_t SetDataSizeInBytes(Set_pa Set) +{ + REQUIRE(VALID_REF(Set)); + return Set->size / SetBitSize * sizeof(SetData_t); +} + +/* + * Allocates a new empty set. Returns NULL if not enough memory. + */ +EXTERN Set_pa AllocSet(Boolean_t show_error_msg); + +/* + * Frees all memory associated with set "*set", and + * sets "*set" to NULL. + */ +EXTERN void DeallocSet(Set_pa *Set); + +/** + * This function adapts the DeallocSet function to work with the + * ArrayList's deallocation callback. + */ +EXTERN Boolean_t SetItemDestructor(void *ItemRef, + ArbParam_t ClientData); +/* + * Makes sure set "set" can hold at least "max_val" elements. + * Returns TRUE if successful, FALSE otherwise. A successful + * call to ExpandSet() guarentees that any calls to AddToSet() + * will be successful as long as the elements added are less + * than "max_val". + */ +EXTERN Boolean_t ExpandSet(Set_pa Set, + SetIndex_t max_val, + Boolean_t show_error_msg); + +/* + * Copies set "src" to set "dst". Returns TRUE if successful, + * FALSE if "src" contains elements it is unable to add to "dst". + */ +EXTERN Boolean_t CopySet(Set_pa dst, + Set_pa src, + Boolean_t show_error_msg); + +/* + * Appends set "src" to set "dst". Returns TRUE if successful, + * FALSE if "src" contains elements it is unable to add to "dst". + */ +EXTERN Boolean_t AppendSet(Set_pa dst, + Set_pa src, + Boolean_t show_error_msg); +/* + * Empties the set "set". + */ +EXTERN void ClearSet(Set_pa Set); + +/* + * Adds "member" to set "set". Returns TRUE if successful, + * FALSE otherwise. AddToSet() can only return FALSE if + * "member" is greater than any previous member of "set" and + * also greater that any "max_val" set with ExpandSet(). + */ +#if defined USE_FUNCTIONS_FOR_SETS +EXTERN Boolean_t AddToSet(Set_pa Set, + SetIndex_t member, + Boolean_t show_error_msg); +#else +# if defined __cplusplus +inline Boolean_t AddToSet(Set_pa Set, + SetIndex_t member, + Boolean_t show_error_msg) +{ + if (Set && + (member + 1 <= Set->size || + ExpandSet(Set, member + 1, show_error_msg))) + { + SetIndex_t word = member / SetBitSize; + SetData_t bit = (SetData_t)1 << (member % SetBitSize); + Set->data[word] |= bit; + return TRUE; + } + else + return FALSE; +} /* AddToSet() */ +# else +# define AddToSet(Set,member,show_error_msg) \ + (((Set) && \ + ((member)+1 <= (Set)->size || \ + ExpandSet((Set), (member)+1, (show_error_msg)))) \ + ? (((Set)->data[(member) / SetBitSize] |= (SetData_t)1 << ((member) % SetBitSize)), TRUE) \ + : FALSE) +# endif +#endif + +/* + * Removes "member" from set "set". + */ +EXTERN void RemoveFromSet(Set_pa Set, + SetIndex_t member); + +EXTERN void DeleteSetMember(Set_pa Set, + SetIndex_t Member); +EXTERN Boolean_t InsertSetMember(Set_pa Set, + SetIndex_t Member, + Boolean_t ShowErrMsg); +/* + * Test for membership of "member" in set "set". This is the only + * function worth making into a macro or inline function. + */ +#if defined USE_FUNCTIONS_FOR_SETS +EXTERN Boolean_t InSet(Set_pa Set, + SetIndex_t member); +#else +# if defined __cplusplus +inline Boolean_t InSet(Set_pa Set, + SetIndex_t member) +{ + if (Set && (0 <= member && member < Set->size)) + { + SetIndex_t word = member / SetBitSize; + SetData_t bit = (SetData_t)1 << (member % SetBitSize); + return (Set->data[word]&bit) != 0; + } + else + return FALSE; +} /* InSet() */ +# else +# define InSet(Set,member) ((Set && (0<=(member) && (member)<(Set)->size)) \ + ? ((Set)->data[(member)/SetBitSize]&((SetData_t)1<<((member)%SetBitSize)))!=0 \ + : FALSE) +# endif +#endif + +/* + * Returns TRUE if set "set" is empty. + */ +EXTERN Boolean_t IsEmpty(Set_pa Set); + +/* + * Returns TRUE if Set has voids. + */ +EXTERN Boolean_t HasVoids(Set_pa Set); + +/* + * Returns number of members in Set "Set". + */ +EXTERN SetIndex_t MemberCount(Set_pa Set); + +/* + * Returns the next member in set "set" after member "start_at". + * Use "start_at" of BAD_ZV_VALUE to find first member. + */ +EXTERN SetIndex_t GetNextMember(Set_pa Set, + SetIndex_t start_at); + +/* + * Returns the previous member in set "set" before member + * "start_at". Use "start_at" of BAD_ZV_VALUE to find last member. + */ +EXTERN SetIndex_t GetPrevMember(Set_pa Set, + SetIndex_t start_at); + +/* + * Returns TRUE if sets are equal (have same members). FALSE otherwise. + */ +EXTERN Boolean_t EqualSets(Set_pa set1, + Set_pa set2); + +/* + * Returns TRUE if all members of childset are contained in parentset. + */ +EXTERN Boolean_t IsSubSet(Set_pa childset, + Set_pa parentset); + +EXTERN SetIndex_t MemberOffset(Set_pa Set, + SetIndex_t Member); + +EXTERN SetIndex_t OffsetMember(Set_pa Set, + SetIndex_t Offset); + + +EXTERN Boolean_t CopySetMember(Set_pa DstSet, + SetIndex_t DstOffset, + Set_pa SrcSet, + SetIndex_t SrcOffset); + +EXTERN void ShiftSet(Set_pa Set, + SetIndex_t ShiftPos1, + SetIndex_t ShiftPos2, + SetIndex_t ShiftAmount); + + +/* + * Handy macros + */ +#define GetFirstSetMember(Set) (GetNextMember((Set), BAD_SET_VALUE)) +#define GetLastSetMember(Set) (GetPrevMember((Set), BAD_SET_VALUE)) + +#define ForAllMembersInSet(Member, Set) \ + for (Member = GetFirstSetMember((Set)); \ + Member != BAD_SET_VALUE; \ + Member = GetNextMember((Set), (Member))) +#define ForAllMembersInReversedSet(Member, Set) \ + for (Member = GetLastSetMember((Set)); \ + Member != BAD_SET_VALUE; \ + Member = GetPrevMember((Set), (Member))) + +#endif // _SET_H_INCLUDED diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/STRLIST.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/STRLIST.h new file mode 100644 index 0000000000000000000000000000000000000000..04d1673b11806d7588f483bb446d384fc4056232 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/STRLIST.h @@ -0,0 +1,122 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +/* +***************************************************************** +***************************************************************** +******* ******** +****** Copyright (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +***************************************************************** +***************************************************************** +*/ +#if defined EXTERN +# undef EXTERN +#endif +#if defined STRLISTMODULE +# define EXTERN +#else +# define EXTERN extern +#endif + +#if !defined ARRLIST_h +# error "Include ARRLIST.h before including STRLIST.h" +#endif + +/* + * + * For building pltview.exe under Windows, we use + * tecio.dll (which is linked to pltview). + * Since pltview.exe uses a few of the + * functions here, they need to be exported into + * the tecio.dll, thus "TECXXX.h" is included for the + * LIBFUNCTION & LIBCALL keywords. They are not + * documented with the other TECXXX() functions, + * however. + * + * If pltview requires other string functions + * in the future, they can be added to the dll + * by adding LIBFUNCTION & LIBCALL as in + * StringListDealloc(), etc. below. + * + * When building the tecplot kernal, LIBFUNCTION + * and LIBCALL are nop's. + * + */ +#include "TECXXX.h" + +EXTERN Boolean_t StringListValid(StringList_pa StringList); +EXTERN void StringListClear(StringList_pa StringList); +EXTERN void StringListRemoveStrings(StringList_pa StringList, + LgIndex_t StringOffset, + LgIndex_t Count); +EXTERN void StringListRemoveString(StringList_pa StringList, + LgIndex_t StringOffset); +LIBFUNCTION void LIBCALL StringListDealloc(StringList_pa *StringList); +EXTERN StringList_pa StringListAlloc(void); +EXTERN Boolean_t StringListAppendString(StringList_pa StringList, + const char *String); +LIBFUNCTION LgIndex_t LIBCALL StringListCount(StringList_pa StringList); +LIBFUNCTION char * LIBCALL StringListGetString(StringList_pa StringList, + LgIndex_t StringOffset); + +#if defined USE_MACROS_FOR_FUNCTIONS +# define StringListGetStringRef StringListGetStringRef_MACRO +#else +# define StringListGetStringRef StringListGetStringRef_FUNC +#endif + +#if !defined USE_MACROS_FOR_FUNCTIONS +EXTERN const char * StringListGetStringRef_FUNC(StringList_pa StringList, + LgIndex_t StringOffset); +#endif +/** + * To maintain the string list's integrity the result is cast to a + * (const char *) to minimize the risk of users passing the result + * to FREE_ARRAY. + */ +#define StringListGetStringRef_MACRO(StringList, StringOffset) \ + ((const char *)ArrayListGetCharPtr((ArrayList_pa)(StringList), StringOffset)) + +EXTERN Boolean_t StringListSetString(StringList_pa StringList, + LgIndex_t StringOffset, + const char *String); +EXTERN Boolean_t StringListInsertString(StringList_pa StringList, + LgIndex_t StringOffset, + const char *String); +EXTERN StringList_pa StringListCopy(StringList_pa StringList); +EXTERN Boolean_t StringListAppend(StringList_pa Target, + StringList_pa Source); + +EXTERN char *StringListToNLString(StringList_pa StringList); +EXTERN StringList_pa StringListFromNLString(const char *String); +EXTERN char **StringListToArray(StringList_pa StringList); +EXTERN StringList_pa StringListFromArray(const char **StringArray, + LgIndex_t Count); +EXTERN StringList_pa StringListFromCompound(const char *String); +EXTERN char *StringListToCompound(StringList_pa StringList, + char GroupJoinCharacter, + const char *CharsToEscape); +EXTERN void StringListSort(StringList_pa StringList, + StringListStringComparator_pf Comparator, + ArbParam_t ClientData); diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/STRUTIL.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/STRUTIL.h new file mode 100644 index 0000000000000000000000000000000000000000..c8e0c2b5a33d75aaba1b3e58fc629424808b570b --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/STRUTIL.h @@ -0,0 +1,218 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +/* +****************************************************************** +****************************************************************** +******* ******** +****** (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +****************************************************************** +****************************************************************** +*/ + +#if defined EXTERN +#undef EXTERN +#endif +#if defined STRUTILMODULE +#define EXTERN +#else +#define EXTERN extern +#endif + +#include <string> + +namespace tecplot +{ +namespace strutil +{ +class Scanner; +} +} + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + + +EXTERN void FormatStringBufferCleanup(void); + +/* + * This is a helper function for FormatString or any other functions that want + * to format a string based on a format string followed by a set of arguments. + * See FormatString or ErrMsg functions for example usage. + * + * @param Format + * C format string. + * @param Arguments + * Variable argument list already fetched using va_start(). + * + * @return + * Allocated string with the formatted string or NULL if it failed. + */ +EXTERN char *vFormatString(const char *Format, + va_list Arguments); + +/** + * Formats a string using the specified C format string. + * + * @param Format + * C format string. + * @param ... + * Any arguments needed by the C format string. + * + * @return + * Allocated string with the formatted string or NULL if it failed. The + * client is responsible for deallocating the resource. + */ +EXTERN char *FormatString(tecplot::strutil::TranslatedString Format, + ...); /* 0 or more variable arguments */ + +/** + * Formats a string using the specified C format string and places the result + * in the string buffer. + * + * @param Buffer + * String buffer to receive the formatted string. + * @param Format + * C format string. + * @param ... + * Any arguments needed by the C format string. + * + * @return + * Upon successful return, these functions return the number of characters + * printed, not including the trailing '\0' used to end output to strings. If + * unsuccessful -1 is returned. + */ +EXTERN int FormatString(std::string& Buffer, + tecplot::strutil::TranslatedString Format + ...); /* 0 or more variable arguments */ +EXTERN char *DupString(tecplot::strutil::TranslatedString String); +EXTERN void CopySubString(char *Target, + const char *Source, + int Index, + int Count); + +#if !defined MSWIN + +EXTERN void ReplaceCharInString(char *S, + short OldChar, + short NewChar); +#endif + +EXTERN void MakeStringLowerCase(char *str); +EXTERN void MakeStringUpperCase(char *str); +EXTERN char *TrimLeadAndTrailSpaces(char *String); +EXTERN char *StringFlushLeft(char *String); +EXTERN char *StringTruncate(char *String, + LgIndex_t MaxLength); +EXTERN char *StringTrimAndTruncate(char *String, + LgIndex_t MaxLength); + +#ifndef MSWIN +EXTERN StringList_pa LineBreakString(const char *String, + UInt32_t WrapMargin); +#endif + +EXTERN Boolean_t MatchKey(char *StringToMatch, + char *Key); +EXTERN void RemoveSeparator(const char **CPtr); +EXTERN void SkipWhiteSpace(const char **CPtr); +EXTERN void SkipNonWhiteSpace(char **CPtr); +EXTERN const char *ustrstr(const char *s1, + const char *s2); +EXTERN int ustrncmp(const char *s1, + const char *s2, + size_t Len); +EXTERN int ustrcmp(const char *s1, + const char *s2); +/* public access */ +/* InternalResetString should not be used directly (use ResetString macro) */ +#if !defined NO_ASSERTS +EXTERN Boolean_t InternalResetString(char **SBase, + const char *NewString, + Boolean_t IssueErrMsg, + const char *FileName, + int LineNumber); +# define ResetString(SBase, NewString, IssueErrMsg) InternalResetString( \ + SBase, \ + NewString, \ + IssueErrMsg, \ + __FILE__, __LINE__) +#else +EXTERN Boolean_t InternalResetString(char **SBase, + const char *NewString, + Boolean_t IssueErrMsg); +# define ResetString(SBase, NewString, IssueErrMsg) InternalResetString( \ + SBase, \ + NewString, \ + IssueErrMsg) +#endif + +EXTERN Boolean_t ScanForString(tecplot::strutil::Scanner &scanner, + std::string &DestString, + Boolean_t GrabEntireStringIncludingDelimiters); +EXTERN Boolean_t TackOnString(char **SBase, + const char *StringToAdd, + Boolean_t DeleteStringToAdd, + Boolean_t ConvertNewlineToAscii); +EXTERN Boolean_t TackOnConstString(char **SBase, + const char *StringToAdd, + Boolean_t ConvertNewlineToAscii); +EXTERN Boolean_t TackOnChar(char **SBase, + char CharToAdd); +EXTERN Boolean_t ReplaceNewlineWithBackslashN(char **String); +EXTERN Boolean_t ReplaceBackslashNWithNewline(char **S); + +EXTERN Boolean_t EscapeOutDelimitersInString(char **S, + char Delimiter); +EXTERN Boolean_t ScanForSymbol(tecplot::strutil::Scanner &scanner, + char Symbol, + Boolean_t OnlySkipWhiteSpace); + + +/* Newline Delimited Strings */ +EXTERN char *ConvertStringToNewlineDelimitedString(const char *OriginalString); +EXTERN char *ConvertNewlineDelimitedStringToQuotedString(const char *NewlineDelimitedString, + Boolean_t SeparateInstructionsWithPlus); + + + +EXTERN char *InsertNameAtPlaceHolder(char *BaseString, + char *NameToInsert); +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if !defined NO_ASSERTS +#endif /* !NO_ASSERTS */ +#endif //TECPLOTKERNEL + +inline char* EndOfString(char* str) +{ + return str + strlen(str); +}; +inline char const* EndOfString(char const* str) +{ + return str + strlen(str); +}; diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/SYSTEM.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/SYSTEM.h new file mode 100644 index 0000000000000000000000000000000000000000..6e510359a5b7038510c775bd99c26fffc818665f --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/SYSTEM.h @@ -0,0 +1,67 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +/* +***************************************************************** +***************************************************************** +******* ******** +****** Copyright (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +***************************************************************** +***************************************************************** +*/ +#if defined EXTERN +#undef EXTERN +#endif +#if defined SYSTEMMODULE +#define EXTERN +#else +#define EXTERN extern +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif +EXTERN int OpenFileListGetCount(void); +EXTERN char *GetLongFileName(const char *FileName); +EXTERN Boolean_t VerifyToOverwriteFile(const char *FName); +EXTERN Boolean_t IsValidDirectory(const char *FName); +EXTERN Boolean_t FileExists(const char *F, + Boolean_t ShowErr); +EXTERN Boolean_t IsOkFNameChar(unsigned char ch); +EXTERN void ErrFName(const char *FName); +EXTERN Boolean_t IsValidFileName(const char *FileName, + Boolean_t IsReading, + Boolean_t ShowError); +EXTERN Boolean_t ResizeFile(FILE *File, + Int64_t Length); +EXTERN Boolean_t Close_File(FILE **F, + Boolean_t ShowErr); +EXTERN Boolean_t Open_File(FILE **F, + const char *FName, + Boolean_t IsReading, + Boolean_t IsAppending, + Boolean_t ForceOpen, + Boolean_t ShowErr, + Boolean_t IsAscii); + diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/TASSERT.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/TASSERT.h new file mode 100644 index 0000000000000000000000000000000000000000..78252294d340e4f149e2b4513f4915fdb70bfda3 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/TASSERT.h @@ -0,0 +1,513 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +/* +****************************************************************** +****************************************************************** +******* ******** +****** (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +****************************************************************** +****************************************************************** +*/ +/* + * Provide four levels of assertion control. Assertions provide a mechanism + * to enforce a contract between a client and service provider. The assertions + * are listed in order of highest to lowest priority. Assertions can be turned + * off individually by defining the appropriate name (see preprossessor + * definitions below), however, lower priority assertions should be turned + * off prior to higher ones. As confidence in the code increases all assertions + * can be turned off by defining NO_ASSERTS. + * + * The assertions defined below have the following meanings: + * + * INVARIANT - Asserts that a property's state is invariant throughout the + * life of the property's scope. Stating invariant properties + * of an application provides a deeper understanding of the + * application's state. These statements are usually + * positioned just ahead of the preconditions and just after + * the postconditions. + * + * REQUIRE - Asserts that a method's preconditions are within their + * valid domains. Preconditions are conditions placed upon + * any state information relied upon for the call. These + * statements should be as close to the top of the method + * as possible (except for assertions on invariant properties). + * + * ENSURE - Asserts that a method's postconditions are within their + * valid ranges. Postconditions are conditions placed upon + * any state information modified by the call. These + * statements should be as close to the bottom of the method + * (presumably there is only one exit point) as possible + * (except for assertions on invariant properties). + * + * CHECK - Any other assertion not covered by the above assertions. + * These are often added within a method body to specify + * something that may not be immediately obvious to the reader + * or to validate your assumptions about a call to a 3rd party + * method that does not use runtime assertions for its + * preconditions or postconditions. Obviously if the 3rd party + * method uses assertions then there is no need for the CHECK. + * + * Additionally a convenience macro is available to place in code that is + * pending implementation. + * + * NOT_IMPLEMENTED - Assertion that always fails during runtime for debug + * builds and always fails at compile time for release + * builds. + */ +#if !defined TASSERT_H +#define TASSERT_H + +#if defined (MSWIN) +# include <assert.h> +#endif /* MSWIN */ + +#if !defined TECPLOTKERNEL && !defined STD_ASSERTS +#define STD_ASSERTS +#endif + +#if !defined (MSWIN) +# include <assert.h> +# if !defined ASSERT +# define ASSERT assert +# endif +#endif + +#if defined MSWIN +/* MFC .NET defines ENSURE, so we undefine it here */ +#if defined ENSURE +#undef ENSURE +#endif /* ENSURE */ +#endif /* MSWIN */ + +/* BEGINREMOVEFROMADDON */ +#define INVALID_REF ((void *)0x0000FFFF) +/* + * Chances are low the address 0x11111111 will be used, so we'll risk asserting + * against it (see unitialized assignment in newmalloc). + */ +#define UNINITIALIZED_REF ((void *)0x11111111) +#define INVALID_FN_REF ((void *)NULL) +/* ENDREMOVEFROMADDON */ + +#ifdef UNIXX +/* BEGINREMOVEFROMADDON */ +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# if defined NO_ASSERTS +# else +# endif +#endif /* TECPLOTKERNAL */ +/* ENDREMOVEFROMADDON */ + +/* BEGINREMOVEFROMADDON */ +#if !defined TECPLOTKERNEL +/* For add-ons, there is a problem with VALID_REF, so just test for non-NULL */ +/* ENDREMOVEFROMADDON */ +# define VALID_REF(p) ( (p) != NULL ) +# define VALID_FN_REF(fp) ( (fp) != NULL ) +/* BEGINREMOVEFROMADDON */ +#endif /* !defined TECPLOTKERNAL */ +/* ENDREMOVEFROMADDON */ + +/* BEGINREMOVEFROMADDON */ +/* Widgets are pointers under Motif */ +# define VALID_WIDGET(widget) VALID_REF((widget)) +/* Menu widgets are pointers too */ +# define VALID_MENU_WIDGET(widget) VALID_REF((widget)) +/* ENDREMOVEFROMADDON */ +#endif /* UNIXX */ + +#ifdef MSWIN +/* BEGINREMOVEFROMADDON */ +/* Don't use AfxIsValidAddress()! See Bug <7245>. + 1/4/08, dto. */ +/* ENDREMOVEFROMADDON */ + +#if defined NO_ASSERTS +/* release build in TecUtil layer uses these for TUASSERT */ +# define VALID_REF(p) ((p) != NULL) +# define VALID_FN_REF(pf) ((pf) != NULL) +#else +# define VALID_REF(p) ((p) != NULL && !IsBadReadPtr((const void *)(p), 1)) +# define VALID_FN_REF(pf) ((pf) != NULL && !IsBadReadPtr((const void *)(pf),(UINT_PTR)sizeof(const void*))) +#endif + +/* BEGINREMOVEFROMADDON */ +/* Widgets are numbers under Windows, so we decode it with GetWindowFromWidget */ +# if defined ENGINE +# define VALID_WIDGET(widget) ((widget) != NULL) +# else +# define VALID_WIDGET(widget) ((widget) != NULL && GetWindowFromWidget((widget))!=NULL) +# endif // ENGINE + +/* Menu widgets are numbers too, so we just check against zero */ +# define VALID_MENU_WIDGET(widget) ((widget)!=NULL) +/* ENDREMOVEFROMADDON */ +#endif /* MSWIN */ +/* BEGINREMOVEFROMADDON */ +/* handles are not pointers to memory, so the only test we can */ +/* perform is to check for 0 */ +#define VALID_HANDLE(handle) ((handle)!=0) + +#if defined FLEXLM +#define VALID_FLEX_JOB_HANDLE(handle) ((handle) != NULL) +#define VALID_FLEX_ERROR_CODE(ErrorCode)(ErrorCode <= 0) +#endif /* FLEXLM */ + +/* ENDREMOVEFROMADDON */ +/* other useful validity checks */ +#define VALID_BOOLEAN(b) ((b) == TRUE || (b) == FALSE) +#define VALID_ENUM(value, type) (0 <= (value) && \ + (value) < END_##type) + +/* Test a parameter than can be NULL or a valid pointer */ +#define VALID_REF_OR_NULL(ptr) IMPLICATION((ptr) != NULL, VALID_REF(ptr)) +#define VALID_FN_REF_OR_NULL(ptr) IMPLICATION((ptr) != NULL, VALID_FN_REF(ptr)) + +/* BEGINREMOVEFROMADDON */ +#define VALID_TRANSLATED_STRING(ts) (!(ts).isNull()) + +/** + * These macros are a little complicated but it allows one to + * write a simple assertion regardless of the zone type or + * selected plane: + * + * REQUIRE(VALID_CELL_INDEX(CZData, CellIndex, Plane))); + * + * Prior to using the macros a call to SetupXxx, + * or at a minimum SetupCZData, must be called to setup + * the globals defining the dataset structure. + */ +#define VALID_FE_CELL_INDEX(CZData, CellIndex) \ + (/* CellIndex range test */ \ + 0 <= (CellIndex) && \ + (CellIndex) < (CZData)->NumElements) + +#define VALID_IPLANE_CELL_INDEX(CZData,CellIndex) \ + (/* CellIndex range test */ \ + (CellIndex) >= 0 && \ + IINDEX((CZData),CellIndex) <= MAX((CZData)->NumIPtsM1,1) && \ + JINDEX((CZData),CellIndex) < MAX((CZData)->NumJPtsM1,1) && \ + KINDEX((CZData),CellIndex) < MAX((CZData)->NumKPtsM1,1)) + +#define VALID_JPLANE_CELL_INDEX(CZData,CellIndex) \ + (/* CellIndex range test */ \ + (CellIndex) >= 0 && \ + IINDEX((CZData),CellIndex) < MAX((CZData)->NumIPtsM1,1) && \ + JINDEX((CZData),CellIndex) <= MAX((CZData)->NumJPtsM1,1) && \ + KINDEX((CZData),CellIndex) < MAX((CZData)->NumKPtsM1,1)) + +#define VALID_KPLANE_CELL_INDEX(CZData,CellIndex) \ + (/* CellIndex range test */ \ + (CellIndex) >= 0 && \ + IINDEX((CZData),CellIndex) < MAX((CZData)->NumIPtsM1,1) && \ + JINDEX((CZData),CellIndex) < MAX((CZData)->NumJPtsM1,1) && \ + KINDEX((CZData),CellIndex) <= MAX((CZData)->NumKPtsM1,1)) + +#define VALID_ORDERED_CELL_INDEX(CZData, CellIndex, Plane) \ + (/* macro preconditions */ \ + ((IJKPlanes_e)(Plane) == IJKPlanes_I || \ + (IJKPlanes_e)(Plane) == IJKPlanes_J || \ + (IJKPlanes_e)(Plane) == IJKPlanes_K || \ + (IJKPlanes_e)(Plane) == IJKPlanes_Volume) && \ +\ + /* CellIndex range test */ \ + (IMPLICATION(((IJKPlanes_e)(Plane) == IJKPlanes_I || \ + (IJKPlanes_e)(Plane) == IJKPlanes_Volume), \ + VALID_IPLANE_CELL_INDEX((CZData),CellIndex)) && \ + IMPLICATION(((IJKPlanes_e)(Plane) == IJKPlanes_J || \ + (IJKPlanes_e)(Plane) == IJKPlanes_Volume), \ + VALID_JPLANE_CELL_INDEX((CZData),CellIndex)) && \ + IMPLICATION(((IJKPlanes_e)(Plane) == IJKPlanes_K || \ + (IJKPlanes_e)(Plane) == IJKPlanes_Volume), \ + VALID_KPLANE_CELL_INDEX((CZData),CellIndex)))) + +#define VALID_CELL_INDEX(CZData, CellIndex, Plane) \ + (((CZData)->NM != NULL || (CZData)->FM != NULL) ? \ + VALID_FE_CELL_INDEX((CZData), (CellIndex)) : \ + VALID_ORDERED_CELL_INDEX((CZData), (CellIndex), (Plane))) + +#define VALID_DATASET(dataSet,checkNumZones) (((dataSet) != NULL) && \ + IMPLICATION((checkNumZones),(dataSet)->NumZones >= 1)) + + + +#ifdef MSWIN +/* Here is a more specific check in Windows for a valid + pointer to an MFC Window object. + Note that GetSafeHwnd() works even if pWnd is NULL, because + it checks the 'this' pointer first */ +# define VALID_WND(pWnd) (::IsWindow((pWnd)->GetSafeHwnd())) + +#else /* !MSWIN */ +# define VALID_WND(pWnd) /* Should not be used in Motif */ +#endif /* MSWIN */ +/* ENDREMOVEFROMADDON */ + +/* Check for a non-zero length string */ +#if defined MSWIN +# if defined NO_ASSERTS +# define VALID_NON_ZERO_LEN_STR(str) (VALID_REF(str) && !ISEMPTYSTRING(str)) +# else +# define VALID_NON_ZERO_LEN_STR(str) \ + (VALID_REF(str) && \ + !IsBadReadPtr((const void*)(str),(UINT_PTR)(1+strlen((const char*)(str)))) && \ + !ISEMPTYSTRING(str)) +# endif +#else +# define VALID_NON_ZERO_LEN_STR(str) (VALID_REF(str) && !ISEMPTYSTRING(str)) +#endif + +#define VALID_SET_INDEX(setIndex) (((SetIndex_t)setIndex)>=(SetIndex_t)1) + +/* Check for valid stdio file handle */ +#define VALID_FILE_HANDLE(stream) ((stream) != NULL) + +/* To check colors and pen numbers */ +/* BEGINREMOVEFROMADDON */ +#define VALID_BASIC_COLOR(BColor) \ + (FirstBasicColor<=(BColor) && (BColor)<=LastBasicColor) +#define VALID_CONTOUR_COLOR(Color) \ + (ContourColorOffset<=(Color) && \ + (Color)<ContourColorOffset+GeneralBase.Limits.MaxNumContourLevels+1) +#define VALID_PLOTTING_COLOR(Color) \ + (VALID_BASIC_COLOR(Color) || VALID_CONTOUR_COLOR(Color)) +#define VALID_INTERFACE_SPECIFIC_COLOR(BColor) \ + (FirstInterfaceColor<=(BColor) && (BColor)<=LastInterfaceColor) +#define VALID_INTERFACE_COLOR(Color) \ + (VALID_PLOTTING_COLOR(Color) || VALID_INTERFACE_SPECIFIC_COLOR(Color)) +#define VALID_MULTICOLOR_COLOR(Color) \ + (((Color) == MultiColor_C) || ((Color) == MultiColor2_C) || \ + ((Color) == MultiColor3_C) || ((Color) == MultiColor4_C) || \ + ((Color) == MultiColor5_C) || ((Color) == MultiColor6_C) || \ + ((Color) == MultiColor7_C) || ((Color) == MultiColor8_C)) +#define VALID_RGB_COLOR(Color) \ + ((Color) == RGBColor_C) +#define VALID_ASSIGNABLE_COLOR(C) \ + (VALID_BASIC_COLOR(C) || \ + VALID_MULTICOLOR_COLOR(C) || \ + VALID_RGB_COLOR(C)) +#define VALID_PEN_OFFSET(PenOffset) \ + (Black_C<=(PenOffset) && (PenOffset)<=NumPlotterPens) +#define VALID_PEN_OFFSET_FOR_OBJECT(PenOffset) \ + (FirstObjectPen<=(PenOffset) && (PenOffset)<=LastObjectPen) + + +/* to check FE cells */ +#define VALID_ELEMENT_TYPE(element_type) \ + ((element_type) == ZoneType_FETriangle || \ + (element_type) == ZoneType_FEQuad || \ + (element_type) == ZoneType_FETetra || \ + (element_type) == ZoneType_FEBrick || \ + (element_type) == ZoneType_FELineSeg) + + + +/* + * Test validity of zone and variable names. A valid name is one that has a + * valid reference, is not padded with spaces and is within the maximum + * specified length. + */ +#define VALID_NAME(Name, MaxLength) \ + (VALID_REF(Name) && \ + (ISEMPTYSTRING(Name) || \ + (!isspace((Name)[0]) && !isspace((Name)[strlen(Name)-1]))) && \ + strlen(Name) <= (MaxLength)) +#define VALID_ZONE_NAME(Name) VALID_NAME((Name), MaxChrsZnTitle) +#define VALID_VAR_NAME(Name) VALID_NAME((Name), MaxChrsVarName) + + +/* Special test for lighting effect (don't allow "none" in some cases) */ +#define VALID_LIGHTINGEFFECT(L) \ + (((L) == LightingEffect_Paneled) || ((L) == LightingEffect_Gouraud)) + + +/* type definition for assert failure notification function */ +typedef void (*TAssertFailureNotifyFunc)( + const char *expression, /* text representation of the assertion */ + const char *file_name, /* name of the file containing the assertion */ + int line); /* line number in the file of the assertion */ + +#if !defined STD_ASSERTS +/* external function prototypes */ +extern void TAssert( + const char *expression, /* text representation of the assertion */ + const char *file_name, /* name of the file containing the assertion */ + int line); /* line number in the file of the assertion */ + +extern TAssertFailureNotifyFunc InstallTAssertFailureNotify( + TAssertFailureNotifyFunc new_function); /* new notification function */ +#endif /* !STD_ASSERTS */ +/* ENDREMOVEFROMADDON */ + +#if defined NO_ASSERTS +/* BEGINREMOVEFROMADDON */ +# define TASSERT(EXPR) +/* ENDREMOVEFROMADDON */ +# define INVARIANT(EXPR) +# define REQUIRE(EXPR) +# define ENSURE(EXPR) +# define CHECK(EXPR) +# ifdef VERIFY +# undef VERIFY +# endif +# define VERIFY(EXPR) ((void)(EXPR)) +/* + * Only define IGNORENOTIMPLEMENTED if building a "test" release build + * that you are fully aware may contain unimplemented features. + */ +# if defined IGNORENOTIMPLEMENTED +# define NOT_IMPLEMENTED() CHECK(FALSE) +# else +# if defined MSWIN +/* + * NOT_IMPLEMENTED is defined using a parameter, but should be called with none, + * this will then throw a warning and not break the compile. Unix doesn't pick + * up this warning, so break the compile under Unix + */ +# define NOT_IMPLEMENTED(x) TAssert("Not Implemented", __FILE__, __LINE__) +# endif +# if defined UNIXX +# define NOT_IMPLEMENTED() not implemented /* intentionally break the compile */ +# endif +# endif +#elif defined STD_ASSERTS +/* BEGINREMOVEFROMADDON */ +# define TASSERT(EXPR) assert(EXPR) +/* ENDREMOVEFROMADDON */ +# define INVARIANT(EXPR) assert(EXPR) +# define REQUIRE(EXPR) assert(EXPR) +# define ENSURE(EXPR) assert(EXPR) +# define CHECK(EXPR) assert(EXPR) +# ifdef VERIFY +# undef VERIFY +# endif +# ifndef VERIFY +# if defined NDEBUG +# define VERIFY(EXPR) ((void)(EXPR)) +# else +# define VERIFY(EXPR) assert(EXPR) +# endif +# endif /* VERIFY */ +# define NOT_IMPLEMENTED() assert(!("Not Implemented")) +#else +/* BEGINREMOVEFROMADDON */ +#if defined (MSWIN) +#if defined CHECKED_BUILD +#include <string> +#include <vector> +#include <algorithm> + +class AssertionLog +{ +public: + static void initializeAssertLog(const std::string &fileName); + static bool isLoggingAssertions(); + static void addAssertion(const std::string &message); +private: + static void writeOutAssertion(const std::string &message); +private: + static bool logAssertions; + static std::string logFileName; + static std::vector<std::string> assertList; +}; + +extern void TWinCheckedFailedLine(const char *Expr, + const char *FileName, + int LineNum); + +#define TASSERT(EXPR)\ + do { if (!(EXPR)) { TWinCheckedFailedLine(#EXPR,__FILE__,__LINE__); } } while (0) +#else +#define TASSERT(EXPR) ASSERT(EXPR) /* MFC assert. +Works in both release & debug builds */ +#endif /* CHECKED_BUILD */ +#else +#define TASSERT(EXPR) (void)((EXPR) || (TAssert(#EXPR, __FILE__, __LINE__), 0)) +#endif + +# if defined NO_INVARIANTS +# define INVARIANT(EXPR) +# else +# define INVARIANT(EXPR) TASSERT(EXPR) +# endif + +# if defined NO_PRECONDITIONS +# define REQUIRE(EXPR) +# else +# define REQUIRE(EXPR) TASSERT(EXPR) +# endif + +# if defined NO_POSTCONDITIONS +# define ENSURE(EXPR) +# else +# define ENSURE(EXPR) TASSERT(EXPR) +# endif + +# if defined VERIFY +# undef VERIFY +# endif + +# if defined NO_CHECKS +# define CHECK(EXPR) +# define VERIFY(EXPR) ((void)(EXPR)) +# else +# define CHECK(EXPR) TASSERT(EXPR) +# if defined NDEBUG +# define VERIFY(EXPR) ((void)(EXPR)) +# else +# define VERIFY(EXPR) TASSERT(EXPR) +# endif +# endif + +# if defined NICE_NOT_IMPLEMENTED +# define NOT_IMPLEMENTED() NiceNotImplemented() +# else +# define NOT_IMPLEMENTED() TASSERT(!("Not Implemented")) +# endif +/* ENDREMOVEFROMADDON */ +#endif +/* BEGINREMOVEFROMADDON */ +#if !defined STD_ASSERTS +extern void TecplotMopupOnAssert(void); +#endif /* !STD_ASSERTS */ + +#if defined NICE_NOT_IMPLEMENTED +extern void NiceNotImplemented(void); +#endif +/* ENDREMOVEFROMADDON */ + +/* convenience macros for implication, P -> Q, and equivalence, P <-> Q. */ +#define IMPLICATION(P,Q) (!(P) || (Q)) +#define EQUIVALENCE(P,Q) ((P) == (Q)) + +/* BEGINREMOVEFROMADDON */ +#if defined RLM +#define VALID_RLM_HANDLE(h) ((h) != NULL) +#endif /* RLM */ +/* ENDREMOVEFROMADDON */ + + +#endif /* TASSERT_H */ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/TECIO.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/TECIO.h new file mode 100644 index 0000000000000000000000000000000000000000..fabb1344b0b0d0e3d348b30c5c1c14d52ce29b68 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/TECIO.h @@ -0,0 +1,24 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +#include "TECXXX.h" diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/TECXXX.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/TECXXX.h new file mode 100644 index 0000000000000000000000000000000000000000..a61539e90bcd1c8a1650cc281f7962b290a0cbb1 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/TECXXX.h @@ -0,0 +1,698 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +/* + * TECXXX.h: Copyright (C) 1988-2008 Tecplot, Inc. + */ + +#if !defined TECXXX_H_ +#define TECXXX_H_ + +#if !defined CRAY +# define TECFOREIGN112 tecforeign112 +# define TECINI112 tecini112 +# define TECZNE112 teczne112 +# define TECDAT112 tecdat112 +# define TECNOD112 tecnod112 +# define TECGEO112 tecgeo112 +# define TECTXT112 tectxt112 +# define TECLAB112 teclab112 +# define TECFIL112 tecfil112 +# define TECEND112 tecend112 +# define TECUSR112 tecusr112 +# define TECAUXSTR112 tecauxstr112 +# define TECZAUXSTR112 teczauxstr112 +# define TECVAUXSTR112 tecvauxstr112 +# define TECFACE112 tecface112 +# define TECPOLY112 tecpoly112 + +# define TECFOREIGN111 tecforeign111 +# define TECINI111 tecini111 +# define TECZNE111 teczne111 +# define TECDAT111 tecdat111 +# define TECNOD111 tecnod111 +# define TECGEO111 tecgeo111 +# define TECTXT111 tectxt111 +# define TECLAB111 teclab111 +# define TECFIL111 tecfil111 +# define TECEND111 tecend111 +# define TECUSR111 tecusr111 +# define TECAUXSTR111 tecauxstr111 +# define TECZAUXSTR111 teczauxstr111 +# define TECVAUXSTR111 tecvauxstr111 +# define TECFACE111 tecface111 +# define TECPOLY111 tecpoly111 + +# define TECFOREIGN110 tecforeign110 +# define TECINI110 tecini110 +# define TECZNE110 teczne110 +# define TECDAT110 tecdat110 +# define TECNOD110 tecnod110 +# define TECGEO110 tecgeo110 +# define TECTXT110 tectxt110 +# define TECLAB110 teclab110 +# define TECFIL110 tecfil110 +# define TECEND110 tecend110 +# define TECUSR110 tecusr110 +# define TECAUXSTR110 tecauxstr110 +# define TECZAUXSTR110 teczauxstr110 +# define TECVAUXSTR110 tecvauxstr110 +# define TECFACE110 tecface110 + +# define TECFOREIGN100 tecforeign100 +# define TECINI100 tecini100 +# define TECZNE100 teczne100 +# define TECDAT100 tecdat100 +# define TECNOD100 tecnod100 +# define TECGEO100 tecgeo100 +# define TECTXT100 tectxt100 +# define TECLAB100 teclab100 +# define TECFIL100 tecfil100 +# define TECEND100 tecend100 +# define TECUSR100 tecusr100 +# define TECAUXSTR100 tecauxstr100 +# define TECZAUXSTR100 teczauxstr100 +# define TECVAUXSTR100 tecvauxstr100 +# define TECFACE100 tecface100 + +# define TECINI tecini +# define TECZNE teczne +# define TECDAT tecdat +# define TECNOD tecnod +# define TECGEO tecgeo +# define TECTXT tectxt +# define TECLAB teclab +# define TECFIL tecfil +# define TECEND tecend +# define TECUSR tecusr +#endif + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#else +#define INTEGER4 int +#define INTEGER2 short +#endif + +#if defined _WIN32 +#if !defined MSWIN +#define MSWIN /* MSWIN */ +#endif +#endif /* _WIN32 */ + +#if !defined (EXTERNC) +# if defined (__cplusplus) +# define EXTERNC extern "C" +# else +# define EXTERNC +# endif /* __cplusplus */ +#endif /* EXTERN_C */ + +#if !defined (STDCALL) +# if defined MSWIN +# define STDCALL __stdcall +# else /* !MSWIN */ +# define STDCALL +# endif /* MSWIN */ +#endif /* STDCALL */ + +#if !defined (DLLEXPORT) +# if defined (MSWIN) +# define DLLEXPORT _declspec (dllexport) +# else +# define DLLEXPORT +# endif /* MSWIN */ +#endif /* DLLEXPORT */ + +#if !defined (DLLIMPORT) +# if defined (MSWIN) +# define DLLIMPORT _declspec (dllimport) +# else +# define DLLIMPORT +# endif /* MSWIN */ +#endif /* DLLIMPORT */ + + +#if defined (TECPLOTKERNEL) +/* CORE SOURCE CODE REMOVED */ +#else /* !TECPLOTKERNAL && !MAKEARCHIVE */ +# define LIBCALL STDCALL +# define LIBFUNCTION EXTERNC DLLIMPORT +#endif + +/* + * V11.3 tecio functions + */ + +LIBFUNCTION void LIBCALL TECFOREIGN112(INTEGER4 *OutputForeignByteOrder); + +LIBFUNCTION INTEGER4 LIBCALL TECINI112(char *Title, + char *Variables, + char *FName, + char *ScratchDir, + INTEGER4 *FileType, + INTEGER4 *Debug, + INTEGER4 *VIsDouble); + +LIBFUNCTION INTEGER4 LIBCALL TECZNE112(char *ZoneTitle, + INTEGER4 *ZoneType, + INTEGER4 *IMxOrNumPts, + INTEGER4 *JMxOrNumElements, + INTEGER4 *KMxOrNumFaces, + INTEGER4 *ICellMx, + INTEGER4 *JCellMx, + INTEGER4 *KCellMx, + double *SolutionTime, + INTEGER4 *StrandID, + INTEGER4 *ParentZone, + INTEGER4 *IsBlock, + INTEGER4 *NumFaceConnections, + INTEGER4 *FaceNeighborMode, + INTEGER4 *TotalNumFaceNodes, + INTEGER4 *NumConnectedBoundaryFaces, + INTEGER4 *TotalNumBoundaryConnections, + INTEGER4 *PassiveVarList, + INTEGER4 *ValueLocation, + INTEGER4 *ShareVarFromZone, + INTEGER4 *ShareConnectivityFromZone); + +LIBFUNCTION INTEGER4 LIBCALL TECDAT112(INTEGER4 *N, + void *FieldData, + INTEGER4 *IsDouble); + +LIBFUNCTION INTEGER4 LIBCALL TECNOD112(INTEGER4 *NData); + +LIBFUNCTION INTEGER4 LIBCALL TECEND112(void); + +LIBFUNCTION INTEGER4 LIBCALL TECLAB112(char *S); + +LIBFUNCTION INTEGER4 LIBCALL TECUSR112(char *S); + +LIBFUNCTION INTEGER4 LIBCALL TECGEO112(double *XPos, + double *YPos, + double *ZPos, + INTEGER4 *PosCoordMode, + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *Color, + INTEGER4 *FillColor, + INTEGER4 *IsFilled, + INTEGER4 *GeomType, + INTEGER4 *LinePattern, + double *PatternLength, + double *LineThickness, + INTEGER4 *NumEllipsePts, + INTEGER4 *ArrowheadStyle, + INTEGER4 *ArrowheadAttachment, + double *ArrowheadSize, + double *ArrowheadAngle, + INTEGER4 *Scope, + INTEGER4 *Clipping, + INTEGER4 *NumSegments, + INTEGER4 *NumSegPts, + float *XGeomData, + float *YGeomData, + float *ZGeomData, + char *mfc); + +LIBFUNCTION INTEGER4 LIBCALL TECTXT112(double *XOrThetaPos, + double *YOrRPos, + double *ZOrUnusedPos, + INTEGER4 *PosCoordMode, + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *BFont, + INTEGER4 *FontHeightUnits, + double *FontHeight, + INTEGER4 *BoxType, + double *BoxMargin, + double *BoxLineThickness, + INTEGER4 *BoxColor, + INTEGER4 *BoxFillColor, + double *Angle, + INTEGER4 *Anchor, + double *LineSpacing, + INTEGER4 *TextColor, + INTEGER4 *Scope, + INTEGER4 *Clipping, + char *String, + char *mfc); + +LIBFUNCTION INTEGER4 LIBCALL TECFIL112(INTEGER4 *F); + +LIBFUNCTION INTEGER4 LIBCALL TECAUXSTR112(char *Name, + char *Value); + +LIBFUNCTION INTEGER4 LIBCALL TECZAUXSTR112(char *Name, + char *Value); + +LIBFUNCTION INTEGER4 LIBCALL TECVAUXSTR112(INTEGER4 *Var, + char *Name, + char *Value); + +LIBFUNCTION INTEGER4 LIBCALL TECFACE112(INTEGER4 *FaceConnections); + +LIBFUNCTION INTEGER4 LIBCALL TECPOLY112(INTEGER4 *FaceNodeCounts, + INTEGER4 *FaceNodes, + INTEGER4 *FaceLeftElems, + INTEGER4 *FaceRightElems, + INTEGER4 *FaceBndryConnectionCounts, + INTEGER4 *FaceBndryConnectionElems, + INTEGER4 *FaceBndryConnectionZones); + +/* + * V11.1 tecio functions TODO (JN): Tecplot's version is still in flux so the .1 may change + */ + +LIBFUNCTION void LIBCALL TECFOREIGN111(INTEGER4 *OutputForeignByteOrder); + +LIBFUNCTION INTEGER4 LIBCALL TECINI111(char *Title, + char *Variables, + char *FName, + char *ScratchDir, + INTEGER4 *FileType, + INTEGER4 *Debug, + INTEGER4 *VIsDouble); + +LIBFUNCTION INTEGER4 LIBCALL TECZNE111(char *ZoneTitle, + INTEGER4 *ZoneType, + INTEGER4 *IMxOrNumPts, + INTEGER4 *JMxOrNumElements, + INTEGER4 *KMxOrNumFaces, + INTEGER4 *ICellMx, + INTEGER4 *JCellMx, + INTEGER4 *KCellMx, + double *SolutionTime, + INTEGER4 *StrandID, + INTEGER4 *ParentZone, + INTEGER4 *IsBlock, + INTEGER4 *NumFaceConnections, + INTEGER4 *FaceNeighborMode, + INTEGER4 *TotalNumFaceNodes, + INTEGER4 *NumConnectedBoundaryFaces, + INTEGER4 *TotalNumBoundaryConnections, + INTEGER4 *PassiveVarList, + INTEGER4 *ValueLocation, + INTEGER4 *ShareVarFromZone, + INTEGER4 *ShareConnectivityFromZone); + +LIBFUNCTION INTEGER4 LIBCALL TECDAT111(INTEGER4 *N, + void *FieldData, + INTEGER4 *IsDouble); + +LIBFUNCTION INTEGER4 LIBCALL TECNOD111(INTEGER4 *NData); + +LIBFUNCTION INTEGER4 LIBCALL TECEND111(void); + +LIBFUNCTION INTEGER4 LIBCALL TECLAB111(char *S); + +LIBFUNCTION INTEGER4 LIBCALL TECUSR111(char *S); + +LIBFUNCTION INTEGER4 LIBCALL TECGEO111(double *XPos, + double *YPos, + double *ZPos, + INTEGER4 *PosCoordMode, + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *Color, + INTEGER4 *FillColor, + INTEGER4 *IsFilled, + INTEGER4 *GeomType, + INTEGER4 *LinePattern, + double *PatternLength, + double *LineThickness, + INTEGER4 *NumEllipsePts, + INTEGER4 *ArrowheadStyle, + INTEGER4 *ArrowheadAttachment, + double *ArrowheadSize, + double *ArrowheadAngle, + INTEGER4 *Scope, + INTEGER4 *Clipping, + INTEGER4 *NumSegments, + INTEGER4 *NumSegPts, + float *XGeomData, + float *YGeomData, + float *ZGeomData, + char *mfc); + +LIBFUNCTION INTEGER4 LIBCALL TECTXT111(double *XOrThetaPos, + double *YOrRPos, + double *ZOrUnusedPos, + INTEGER4 *PosCoordMode, + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *BFont, + INTEGER4 *FontHeightUnits, + double *FontHeight, + INTEGER4 *BoxType, + double *BoxMargin, + double *BoxLineThickness, + INTEGER4 *BoxColor, + INTEGER4 *BoxFillColor, + double *Angle, + INTEGER4 *Anchor, + double *LineSpacing, + INTEGER4 *TextColor, + INTEGER4 *Scope, + INTEGER4 *Clipping, + char *String, + char *mfc); + +LIBFUNCTION INTEGER4 LIBCALL TECFIL111(INTEGER4 *F); + +LIBFUNCTION INTEGER4 LIBCALL TECAUXSTR111(char *Name, + char *Value); + +LIBFUNCTION INTEGER4 LIBCALL TECZAUXSTR111(char *Name, + char *Value); + +LIBFUNCTION INTEGER4 LIBCALL TECVAUXSTR111(INTEGER4 *Var, + char *Name, + char *Value); + +LIBFUNCTION INTEGER4 LIBCALL TECFACE111(INTEGER4 *FaceConnections); + +LIBFUNCTION INTEGER4 LIBCALL TECPOLY111(INTEGER4 *FaceNodeCounts, + INTEGER4 *FaceNodes, + INTEGER4 *FaceLeftElems, + INTEGER4 *FaceRightElems, + INTEGER4 *FaceBndryConnectionCounts, + INTEGER4 *FaceBndryConnectionElems, + INTEGER2 *FaceBndryConnectionZones); + + +/* + * V11 tecio functions + */ + +LIBFUNCTION void LIBCALL TECFOREIGN110(INTEGER4 *OutputForeignByteOrder); + +LIBFUNCTION INTEGER4 LIBCALL TECINI110(char *Title, + char *Variables, + char *FName, + char *ScratchDir, + INTEGER4 *Debug, + INTEGER4 *VIsDouble); + +LIBFUNCTION INTEGER4 LIBCALL TECZNE110(char *ZoneTitle, + INTEGER4 *ZoneType, + INTEGER4 *IMxOrNumPts, + INTEGER4 *JMxOrNumElements, + INTEGER4 *KMxOrNumFaces, + INTEGER4 *ICellMx, + INTEGER4 *JCellMx, + INTEGER4 *KCellMx, + double *SolutionTime, + INTEGER4 *StrandID, + INTEGER4 *ParentZone, + INTEGER4 *IsBlock, + INTEGER4 *NumFaceConnections, + INTEGER4 *FaceNeighborMode, + INTEGER4 *PassiveVarList, + INTEGER4 *ValueLocation, + INTEGER4 *ShareVarFromZone, + INTEGER4 *ShareConnectivityFromZone); + +LIBFUNCTION INTEGER4 LIBCALL TECDAT110(INTEGER4 *N, + void *FieldData, + INTEGER4 *IsDouble); + +LIBFUNCTION INTEGER4 LIBCALL TECNOD110(INTEGER4 *NData); + +LIBFUNCTION INTEGER4 LIBCALL TECEND110(void); + +LIBFUNCTION INTEGER4 LIBCALL TECLAB110(char *S); + +LIBFUNCTION INTEGER4 LIBCALL TECUSR110(char *S); + +LIBFUNCTION INTEGER4 LIBCALL TECGEO110(double *XPos, + double *YPos, + double *ZPos, + INTEGER4 *PosCoordMode, + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *Color, + INTEGER4 *FillColor, + INTEGER4 *IsFilled, + INTEGER4 *GeomType, + INTEGER4 *LinePattern, + double *PatternLength, + double *LineThickness, + INTEGER4 *NumEllipsePts, + INTEGER4 *ArrowheadStyle, + INTEGER4 *ArrowheadAttachment, + double *ArrowheadSize, + double *ArrowheadAngle, + INTEGER4 *Scope, + INTEGER4 *Clipping, + INTEGER4 *NumSegments, + INTEGER4 *NumSegPts, + float *XGeomData, + float *YGeomData, + float *ZGeomData, + char *mfc); + +LIBFUNCTION INTEGER4 LIBCALL TECTXT110(double *XOrThetaPos, + double *YOrRPos, + double *ZOrUnusedPos, + INTEGER4 *PosCoordMode, + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *BFont, + INTEGER4 *FontHeightUnits, + double *FontHeight, + INTEGER4 *BoxType, + double *BoxMargin, + double *BoxLineThickness, + INTEGER4 *BoxColor, + INTEGER4 *BoxFillColor, + double *Angle, + INTEGER4 *Anchor, + double *LineSpacing, + INTEGER4 *TextColor, + INTEGER4 *Scope, + INTEGER4 *Clipping, + char *String, + char *mfc); + +LIBFUNCTION INTEGER4 LIBCALL TECFIL110(INTEGER4 *F); + +LIBFUNCTION INTEGER4 LIBCALL TECAUXSTR110(char *Name, + char *Value); + +LIBFUNCTION INTEGER4 LIBCALL TECZAUXSTR110(char *Name, + char *Value); + +LIBFUNCTION INTEGER4 LIBCALL TECVAUXSTR110(INTEGER4 *Var, + char *Name, + char *Value); + +LIBFUNCTION INTEGER4 LIBCALL TECFACE110(INTEGER4 *FaceConnections); + + +/* + * V10 tecio functions kept for backward compatability. + */ + +LIBFUNCTION void LIBCALL TECFOREIGN100(INTEGER4 *OutputForeignByteOrder); + +LIBFUNCTION INTEGER4 LIBCALL TECINI100(char *Title, + char *Variables, + char *FName, + char *ScratchDir, + INTEGER4 *Debug, + INTEGER4 *VIsDouble); + +LIBFUNCTION INTEGER4 LIBCALL TECZNE100(char *ZoneTitle, + INTEGER4 *ZoneType, + INTEGER4 *IMxOrNumPts, + INTEGER4 *JMxOrNumElements, + INTEGER4 *KMxOrNumFaces, + INTEGER4 *ICellMx, + INTEGER4 *JCellMx, + INTEGER4 *KCellMx, + INTEGER4 *IsBlock, + INTEGER4 *NumFaceConnections, + INTEGER4 *FaceNeighborMode, + INTEGER4 *ValueLocation, + INTEGER4 *ShareVarFromZone, + INTEGER4 *ShareConnectivityFromZone); + +LIBFUNCTION INTEGER4 LIBCALL TECDAT100(INTEGER4 *N, + void *FieldData, + INTEGER4 *IsDouble); + +LIBFUNCTION INTEGER4 LIBCALL TECNOD100(INTEGER4 *NData); + +LIBFUNCTION INTEGER4 LIBCALL TECEND100(void); + +LIBFUNCTION INTEGER4 LIBCALL TECLAB100(char *S); + +LIBFUNCTION INTEGER4 LIBCALL TECUSR100(char *S); + +LIBFUNCTION INTEGER4 LIBCALL TECGEO100(double *XPos, + double *YPos, + double *ZPos, + INTEGER4 *PosCoordMode, + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *Color, + INTEGER4 *FillColor, + INTEGER4 *IsFilled, + INTEGER4 *GeomType, + INTEGER4 *LinePattern, + double *PatternLength, + double *LineThickness, + INTEGER4 *NumEllipsePts, + INTEGER4 *ArrowheadStyle, + INTEGER4 *ArrowheadAttachment, + double *ArrowheadSize, + double *ArrowheadAngle, + INTEGER4 *Scope, + INTEGER4 *Clipping, + INTEGER4 *NumSegments, + INTEGER4 *NumSegPts, + float *XGeomData, + float *YGeomData, + float *ZGeomData, + char *mfc); + +LIBFUNCTION INTEGER4 LIBCALL TECTXT100(double *XOrThetaPos, + double *YOrRPos, + double *ZOrUnusedPos, + INTEGER4 *PosCoordMode, + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *BFont, + INTEGER4 *FontHeightUnits, + double *FontHeight, + INTEGER4 *BoxType, + double *BoxMargin, + double *BoxLineThickness, + INTEGER4 *BoxColor, + INTEGER4 *BoxFillColor, + double *Angle, + INTEGER4 *Anchor, + double *LineSpacing, + INTEGER4 *TextColor, + INTEGER4 *Scope, + INTEGER4 *Clipping, + char *String, + char *mfc); + +LIBFUNCTION INTEGER4 LIBCALL TECFIL100(INTEGER4 *F); + +LIBFUNCTION INTEGER4 LIBCALL TECAUXSTR100(char *Name, + char *Value); + +LIBFUNCTION INTEGER4 LIBCALL TECZAUXSTR100(char *Name, + char *Value); + +LIBFUNCTION INTEGER4 LIBCALL TECVAUXSTR100(INTEGER4 *Var, + char *Name, + char *Value); + +LIBFUNCTION INTEGER4 LIBCALL TECFACE100(INTEGER4 *FaceConnections); + +/* Old V9 functions retained for backward compatibility */ + +LIBFUNCTION INTEGER4 LIBCALL TECINI(char *Title, + char *Variables, + char *FName, + char *ScratchDir, + INTEGER4 *Debug, + INTEGER4 *VIsDouble); + +LIBFUNCTION INTEGER4 LIBCALL TECZNE(char *ZoneTitle, + INTEGER4 *IMx, + INTEGER4 *JMx, + INTEGER4 *KMx, + char *ZFormat, + char *DupList); + +LIBFUNCTION INTEGER4 LIBCALL TECDAT(INTEGER4 *N, + void *FieldData, + INTEGER4 *IsDouble); + +LIBFUNCTION INTEGER4 LIBCALL TECNOD(INTEGER4 *NData); + +LIBFUNCTION INTEGER4 LIBCALL TECEND(void); + +LIBFUNCTION INTEGER4 LIBCALL TECLAB(char *S); + +LIBFUNCTION INTEGER4 LIBCALL TECUSR(char *S); + +LIBFUNCTION INTEGER4 LIBCALL TECGEO(double *XPos, + double *YPos, + double *ZPos, + INTEGER4 *PosCoordMode, + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *Color, + INTEGER4 *FillColor, + INTEGER4 *IsFilled, + INTEGER4 *GeomType, + INTEGER4 *LinePattern, + double *PatternLength, + double *LineThickness, + INTEGER4 *NumEllipsePts, + INTEGER4 *ArrowheadStyle, + INTEGER4 *ArrowheadAttachment, + double *ArrowheadSize, + double *ArrowheadAngle, + INTEGER4 *Scope, + INTEGER4 *NumSegments, + INTEGER4 *NumSegPts, + float *XGeomData, + float *YGeomData, + float *ZGeomData, + char *mfc); + +LIBFUNCTION INTEGER4 LIBCALL TECTXT(double *XPos, + double *YPos, + INTEGER4 *PosCoordMode, + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *BFont, + INTEGER4 *FontHeightUnits, + double *FontHeight, + INTEGER4 *BoxType, + double *BoxMargin, + double *BoxLineThickness, + INTEGER4 *BoxColor, + INTEGER4 *BoxFillColor, + double *Angle, + INTEGER4 *Anchor, + double *LineSpacing, + INTEGER4 *TextColor, + INTEGER4 *Scope, + char *Text, + char *mfc); + +LIBFUNCTION INTEGER4 LIBCALL TECFIL(INTEGER4 *F); + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif +#endif /* TECXXX_H_ */ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/TEXT.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/TEXT.h new file mode 100644 index 0000000000000000000000000000000000000000..06887c923bf30059daaf4204e5d76698166c1cb5 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/TEXT.h @@ -0,0 +1,62 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +/* +****************************************************************** +****************************************************************** +******* ******** +****** (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +****************************************************************** +****************************************************************** +*/ + +#if defined EXTERN +#undef EXTERN +#endif +#if defined TEXTMODULE +#define EXTERN +#else +#define EXTERN extern +#endif + +#define _TEXT_H_INCLUDED + +/* These macros for checking CoordSys_e and Units of text objects (i.e., those associated with the text tool). */ +#define VALID_TEXT_COORDSYS(sys) (((sys)==CoordSys_Frame)||((sys)==CoordSys_Grid)||((sys)==CoordSys_Grid3D)) +#define VALID_TEXT_UNITS(units) (((units)==Units_Grid)||((units)==Units_Frame)||((units)==Units_Point)) +#define VALID_TEXT_COORDSYS_AND_UNITS(pos_sys, size_units) \ + ( VALID_TEXT_COORDSYS((pos_sys)) && \ + VALID_TEXT_UNITS((size_units)) && \ + ! ((pos_sys) == CoordSys_Frame && (size_units) == Units_Grid) ) + +/* This is for any type of font in Tecplot. */ +#define VALID_FONT_SIZEUNITS(units) (((units)==Units_Grid)||((units)==Units_Frame)||((units)==Units_Point)||(units)==Units_AxisPercentage) + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if 0 /* contract template */ +#endif +#if 0 /* contract template */ +#endif +#endif /* TECPLOTKERNEL */ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/TranslatedString.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/TranslatedString.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5ae0cb73a0aec49e7b36ac4b709c08d4e1202f89 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/TranslatedString.cpp @@ -0,0 +1,362 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +#include "stdafx.h" +#include "MASTER.h" +#define TECPLOTENGINEMODULE +/* +***************************************************************** +***************************************************************** +******* ******** +****** Copyright (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +***************************************************************** +***************************************************************** +*/ + +#include "GLOBAL.h" +#include "TASSERT.h" +#include "Q_UNICODE.h" + + +using namespace std; + +namespace tecplot +{ +namespace strutil +{ + +#if defined MSWIN && !defined TECPLOTKERNEL +/** + * Stub function for non-TECPLOTKERNEL + */ +string LookUpTranslation(string& str) +{ + return string(str); +} +#endif + +/** + * Convenience function for creating Utf8 string translations. + * + * @param str + * String to translate. + * + * @return + * A new Utf8 translated string. + */ +static inline string* createUtf8StringTranslation(string& str) +{ +#if defined MSWIN + string *result = new string(LookUpTranslation(str)); +#else + string *result = new string(str); +#endif + ENSURE(VALID_REF(result)); + return result; +} + +#if defined MSWIN +/** + * Convenience function for creating wide string translations. + * + * @param str + * String to translate. + * + * @return + * A new wide translated string. + */ +static inline wstring* createWideStringTranslation(string& str) +{ + wstring *result = new wstring; + *result = StringToWString(LookUpTranslation(str)); + + ENSURE(VALID_REF(result)); + return result; +} +#endif + +#if defined MSWIN +/** + * Convenience function for creating wide string with the given mode. + * + * @param mode + * Indicates if this string is to be translated or not. + * @param str + * String to translate. + * + * @return + * A new wide translated string. + */ +static inline wstring* createWideString(TranslatedString::Mode mode, + string& str) +{ + REQUIRE(mode == TranslatedString::DoTranslate || mode == TranslatedString::DontTranslate); + + wstring* result; + if (mode == TranslatedString::DoTranslate) + result = createWideStringTranslation(str); + else + result = new wstring(StringToWString(str)); + + return result; +} +#endif + +/** + */ +void TranslatedString::init(TranslatedString::Mode mode, + const char* str, + const char* translatorNotes) +{ + REQUIRE(mode == DoTranslate || mode == DontTranslate); + REQUIRE(VALID_REF_OR_NULL(str)); + REQUIRE(VALID_REF_OR_NULL(translatorNotes)); + + m_mode = mode; + m_isNull = (str == NULL); + if (!m_isNull) + m_string = str; + m_utf8String = NULL; // ...on demand resource +#if defined MSWIN + m_wideString = NULL; // ...on demand resource +#endif +} + +/** + */ +TranslatedString::TranslatedString() +{ + init(DontTranslate, (const char*)NULL, (const char*)NULL); + ENSURE(this->isValid()); +} + +/** + */ +TranslatedString TranslatedString::null() +{ + return dontTranslate(NULL); +} + +/** + */ +TranslatedString::TranslatedString(TranslatedString::Mode mode, + const char* str, + const char* translatorNotes) +{ + + REQUIRE(mode == DoTranslate || mode == DontTranslate); + REQUIRE(VALID_REF_OR_NULL(str)); + REQUIRE(VALID_REF_OR_NULL(translatorNotes)); + + init(mode, str, translatorNotes); + ENSURE(this->isValid()); +} + +/** + */ +TranslatedString::~TranslatedString() +{ + delete m_utf8String; +#if defined MSWIN + delete m_wideString; +#endif +} + +#if !defined NO_ASSERTS +/** + */ +bool TranslatedString::isValid() const +{ + CHECK(IMPLICATION(m_isNull, m_string.length() == 0)); +#if 0 + /* TODO(DTO/RMS/CAM): 11/2/2007 + * Code currently exists in Tecplot where we call translate() on a + * variable. This seems wrong and at times (PleaseWait() in + * particular) the variable passed is a NULL pointer which causes + * this assertion to fail. There is not enough time before v11.2 + * release to remove all translate() calls to non-literal strings so + * we'll have to do this as a post release cleanup. For now just + * deactivate this assertion. + */ + CHECK(IMPLICATION(m_isNull, m_mode == DontTranslate)); +#endif + + return true; +} +#endif + +/** + */ +bool TranslatedString::isNull() const +{ + INVARIANT(this->isValid()); + return m_isNull; +} + +/** + */ +bool TranslatedString::isNullOrZeroLength() const +{ + INVARIANT(this->isValid()); + return m_isNull || m_string.length() == 0; +} + +/** + */ +const char* TranslatedString::c_str() +{ + INVARIANT(this->isValid()); + + const char* result = NULL; + if (!isNull()) + { + if (m_mode == DoTranslate) + { + if (m_utf8String == NULL) + m_utf8String = createUtf8StringTranslation(m_string); + result = m_utf8String->c_str(); + } + else // ...if we aren't translating don't bother creating another Utf8 copy just use m_string + result = m_string.c_str(); + } + + ENSURE(result == NULL || VALID_REF(result)); + return result; +} + +#if defined MSWIN +/** + */ +const wchar_t *TranslatedString::c_wstr() +{ + INVARIANT(this->isValid()); + + const wchar_t *result = NULL; + if (!isNull()) + { + if (m_wideString == NULL) + m_wideString = createWideString(m_mode, m_string); + result = m_wideString->c_str(); + } + + ENSURE(result == NULL || VALID_REF(result)); + return result; +} +#endif + +/** + */ +TranslatedString::operator string() +{ + INVARIANT(this->isValid()); + REQUIRE(!isNull()); + + string* result; + if (m_mode == DoTranslate) + { + if (m_utf8String == NULL) + m_utf8String = createUtf8StringTranslation(m_string); + result = m_utf8String; + } + else // ...if we aren't translating don't bother creating another Utf8 copy just use m_string + result = &m_string; + + return *result; +} + +#if defined MSWIN +/** + */ +TranslatedString::operator wstring() +{ + INVARIANT(this->isValid()); + REQUIRE(!isNull()); + + if (m_wideString == NULL) + m_wideString = createWideString(m_mode, m_string); + + return *m_wideString; +} +#endif + +/** + */ +TranslatedString& TranslatedString::operator =(const TranslatedString& other) +{ + REQUIRE(other.isValid()); + + if (this != &other) // ...only perform if not self assignment + { + m_mode = other.m_mode; + m_isNull = other.m_isNull; + m_string = other.m_string; + m_utf8String = (other.m_utf8String != NULL ? new string(*other.m_utf8String) : NULL); +#if defined MSWIN + m_wideString = (other.m_wideString != NULL ? new wstring(*other.m_wideString) : NULL); +#endif + } + + ENSURE(this->isValid()); + return *this; +} + +/** + */ +TranslatedString::TranslatedString(const TranslatedString& other) +{ + REQUIRE(other.isValid()); + + m_mode = other.m_mode; + m_isNull = other.m_isNull; + m_string = other.m_string; + m_utf8String = (other.m_utf8String != NULL ? new string(*other.m_utf8String) : NULL); +#if defined MSWIN + m_wideString = (other.m_wideString != NULL ? new wstring(*other.m_wideString) : NULL); +#endif + + ENSURE(this->isValid()); +} + +/** + */ +TranslatedString TranslatedString::translate(const char* str, + const char* translatorNotes) +{ + REQUIRE(VALID_REF_OR_NULL(str)); + REQUIRE(VALID_REF_OR_NULL(translatorNotes)); + + return TranslatedString(DoTranslate, str, translatorNotes); +} + +/** + */ +TranslatedString TranslatedString::dontTranslate(const char* str) +{ + REQUIRE(VALID_REF_OR_NULL(str)); + + return TranslatedString(DontTranslate, str, NULL); +} + +} +} diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/TranslatedString.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/TranslatedString.h new file mode 100644 index 0000000000000000000000000000000000000000..9e3311a2e365cd8b42754d72421fde5775e8dfdb --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/TranslatedString.h @@ -0,0 +1,293 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +/* +***************************************************************** +***************************************************************** +******* ******** +****** Copyright (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +***************************************************************** +***************************************************************** +*/ + +#ifndef TECPLOT_STRUTIL_TRANSLATEDSTRING +#define TECPLOT_STRUTIL_TRANSLATEDSTRING + +#if defined MSWIN +#pragma warning(disable : 4181) +#endif + +namespace tecplot +{ +namespace strutil +{ + +/** + * Class responsible for translating strings for internationalization. This + * class is used both to perform the translation and to identify which strings + * are/aren't in need of translation. + * + * With the exception of the empty constructor all translated strings are + * created via static methods or inline helper functions named translate() and + * dontTranslate(). Translated strings created with a call to translate() are + * flagged as needing human translation and return the translated value at + * runtime. Translated strings created with a call to dontTranslate() are + * flagged as not needing human translation and return the non-translated value + * at runtime. Examples: + * + * ErrMsg(translate("Can I have %d cookies?", numCookies); + * ErrMsg(dontTranslate("%s"), errMsgString); + * + * Conversion methods exists for std::string so that they operate well + * together. Therefore you can pass translated strings to methods or functions + * that receive std::string or std::string references. Additionally you can + * perform std::string operations by casting the translated string to a + * std::string. For example: + * + * if (string(dialogTitle).size() != 0) + * ...do something useful + * + * We have intentionally not provided conversion methods for "const char*" (an + * internal representation of the object's string) because of the risk of the + * client using the pointer after the translated string object goes out of + * scope. + * + * @author David Ossorio + */ +class TranslatedString +{ +public: + /** + * Enumeration describing available translation modes. + */ + typedef enum { DontTranslate, DoTranslate } Mode; + + /** + * Constructs an empty translated string. It is equivalent to calling + * TranslatedString::null(). + */ + TranslatedString(); + + /** + * Convenience function for creating a NULL translated string. + * + * @return + * NULL translated string. + */ + static TranslatedString null(); + + /** + * Creates a translated string object and marks it as a string needing + * translation. + * + * @param str + * Character string to translate. + * @param translatorNotes + * Optional notes for the human translator describing the meaning + * of the string. + */ + static TranslatedString translate(const char* str, + const char* translatorNotes = NULL); + + /** + * Creates a translated string object and marks it as a string not needing + * translation. + * + * @param str + * Character string to translate. The str parameter can be a NULL + * pointer. + */ + static TranslatedString dontTranslate(const char* str); + + /** + * Destructor. + */ + virtual ~TranslatedString(); + + /** + * Indicates if the object's string is NULL. + * + * @return + * true if the object's string is NULL, false otherwise. + */ + virtual bool isNull() const; + + /** + * Indicates if the object's string is NULL or zero length. + * + * @return + * true if the object's string is NULL or zero length, false otherwise. + */ + virtual bool isNullOrZeroLength() const; + + /** + * Returns the internal representation of the object's string. Use this + * result carefully. When this object goes out of scope so does this + * references. + * + * @return + * Pointer to the internal representation of the object's string. + */ + virtual const char* c_str(); + +#if defined MSWIN + /** + * Returns the internal representation of the wide character version of the + * object's string. Use this result carefully. When this object goes out of + * scope so does this references. + * + * @return + * Pointer to the internal representation of the object's string. + */ + virtual const wchar_t* c_wstr(); +#endif + + /** + * Returns a copy of the object's string by this object. The result is + * translated or not depending on the platform and how it was created. + * + * @return + * Copy of the object's string. + */ + virtual operator std::string(); + +#if defined MSWIN + /** + * Returns a copy of the wide character version of the object's string. + * The result is translated or not depending on the platform and how it was + * created. + * + * @return + * Copy of the wide character version of the object's string. + */ + virtual operator std::wstring(); +#endif + + /** + * Assignment operator. + */ + virtual TranslatedString& operator =(const TranslatedString& other); + + /** + * Copy constructor. + */ + TranslatedString(const TranslatedString& other); + +#if !defined NO_ASSERTS + /** + * Used only for assertions. + */ + virtual bool isValid() const; +#endif /* !NO_ASSERTS */ + +private: + /** + * Constructs a translated string. This is declared private to make sure + * clients use translate() or dontTranslate() so that Tecplot's translation + * parser can easily extract strings from the source code. + * + * @param mode + * Indicates if this string is to be translated or not at runtime. + * @param str + * Character string to translate. + * @param translatorNotes + * Optional notes for the human translator describing the meaning + * of the string. + */ + TranslatedString(TranslatedString::Mode mode, + const char* str, + const char* translatorNotes); + + /** + * Convenience method for initialize a translated string. + * + * @param mode + * Indicates if this string is to be translated or not at runtime. + * @param str + * Character string to translate. + * @param translatorNotes + * Optional notes for the human translator describing the meaning + * of the string. + */ + void init(TranslatedString::Mode mode, + const char* str, + const char* translatorNotes); + + /** + * Private instance data. + */ + TranslatedString::Mode m_mode; + bool m_isNull; + std::string m_string; + std::string *m_utf8String; +#if defined MSWIN + std::wstring *m_wideString; +#endif +}; + +/** + * Convenience function for creating a translated string object and marking it + * as a string needing translation. + * + * @param str + * Character string to translate. + * @param translatorNotes + * Optional notes for the human translator describing the meaning + * of the string. + */ +inline TranslatedString translate(const char* str, + const char* translatorNotes = NULL) +{ + return TranslatedString::translate(str, translatorNotes); +} + +/** + * Convenience function for creating a translated string object and marking it + * as a string not needing translation. + * + * @param str + * Character string to translate. The str parameter can be a NULL + * pointer. + */ +inline TranslatedString dontTranslate(const char* str) +{ + return TranslatedString::dontTranslate(str); +} + +/** + * Convenience function for creating a translated string object and marks it as + * a string not needing translation. + * + * @param str + * String to translate. + */ +inline TranslatedString dontTranslate(const std::string& str) +{ + return TranslatedString::dontTranslate(str.c_str()); +} + +} +} + +#endif diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/VERSION.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/VERSION.h new file mode 100644 index 0000000000000000000000000000000000000000..a6528cf9deaee92e075984c0c4e59dc1e37fd158 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/VERSION.h @@ -0,0 +1,23 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/alloc.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/alloc.cpp new file mode 100644 index 0000000000000000000000000000000000000000..be5a0b0127ac9b40cc17dc25b3ebd71ba4420315 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/alloc.cpp @@ -0,0 +1,161 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +#include "stdafx.h" +#include "MASTER.h" + +#define TECPLOTENGINEMODULE + +/* +****************************************************************** +****************************************************************** +******* ******** +****** (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +****************************************************************** +****************************************************************** +*/ + +#define ALLOCMODULE +#include "GLOBAL.h" +#include "ALLOC.h" +#include "TASSERT.h" +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TRACK_MEMORY_USAGE +static size_t memInUse = 0; +static size_t memTotalHighMark = 0; +static size_t memCurrentHighMark = 0; +static size_t memSavedHighMark = 0; +Mutex_pa memMutex; + +void initMemoryUsageTracking(void) +{ + REQUIRE(!Thread_ThreadingIsInitialized()); + Thread_InitMutex(&memMutex); +} + +void cleanUpMemoryUsageTracking(void) +{ + REQUIRE(!Thread_ThreadingIsInitialized()); + Thread_FreeMutex(&memMutex); +} + +void trackMemoryClearHighMark(void) +{ + memCurrentHighMark = memInUse; +} + +void trackMemorySaveHighMark(void) +{ + memSavedHighMark = memCurrentHighMark; +} + +void trackMemoryAlloc(size_t size) +{ + REQUIRE(memInUse >= 0); + + if (Thread_ThreadingIsInitialized()) + Thread_LockMutex(memMutex); + + memInUse += size; + if (memInUse > memTotalHighMark) + memTotalHighMark = memInUse; + if (memInUse > memCurrentHighMark) + memCurrentHighMark = memInUse; + + if (Thread_ThreadingIsInitialized()) + Thread_UnlockMutex(memMutex); +} + +void trackMemoryFree(size_t size) +{ + if (Thread_ThreadingIsInitialized()) + Thread_LockMutex(memMutex); + + memInUse -= size; + + if (Thread_ThreadingIsInitialized()) + Thread_UnlockMutex(memMutex); + + ENSURE(memInUse >= 0); +} + +void getMemoryUsage(size_t* memoryInUse, + size_t* memoryCurrentHighMark, + size_t* memorySavedHighMark, + size_t* memoryTotalHighMark) +{ + REQUIRE(VALID_REF_OR_NULL(memoryInUse)); + REQUIRE(VALID_REF_OR_NULL(memoryCurrentHighMark)); + REQUIRE(VALID_REF_OR_NULL(memorySavedHighMark)); + REQUIRE(VALID_REF_OR_NULL(memoryTotalHighMark)); + if (memoryInUse != NULL) + *memoryInUse = memInUse; + if (memoryCurrentHighMark != NULL) + *memoryCurrentHighMark = memCurrentHighMark; + if (memorySavedHighMark != NULL) + *memorySavedHighMark = memSavedHighMark; + if (memoryTotalHighMark != NULL) + *memoryTotalHighMark = memTotalHighMark; +} +#endif + +#if defined MSWIN && defined ALLOC_HEAP +#define HEAPMIN 512 +#endif + +#if defined MSWIN && defined ALLOC_HEAP +/** + */ +void *MSWinAlloc(DWORD nSize) +{ + long *pMem = NULL; + if (nSize < HEAPMIN) + pMem = (long *)malloc(sizeof(long) + nSize); + else + pMem = (long *)HeapAlloc(GetProcessHeap(), NULL, sizeof(long) + nSize); + if (pMem) + pMem[0] = nSize; + return (void *)&(pMem[1]); +} +#endif + +#if defined MSWIN && defined ALLOC_HEAP +/** + */ +void MSWinFree(void *pMem) +{ + REQUIRE(VALID_REF(pMem)); + if (pMem) + { + long *pMemLong = &(((long *)pMem)[-1]); + if (pMemLong[0] < HEAPMIN) + free((void *)pMemLong); + else + HeapFree(GetProcessHeap(), NULL, (void *)pMemLong); + } +} +#endif diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/arrlist.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/arrlist.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c4955817eeda7aa202f00045874afd301ccaf495 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/arrlist.cpp @@ -0,0 +1,1671 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +#include "stdafx.h" +#include "MASTER.h" +#define TECPLOTENGINEMODULE + +/* + ***************************************************************** + ***************************************************************** + ******* ******** + ****** Copyright (C) 1988-2008 Tecplot, Inc. ******** + ******* All Rights Reserved. ******** + ******* ******** + ***************************************************************** + ***************************************************************** + */ + +#define ARRLISTMODULE +#include "GLOBAL.h" +#include "TASSERT.h" +#include "ALLOC.h" +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif +#include "ARRLIST.h" + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +/* + * ABSTRACT: + * + * This general purpose list uses an array implementation. The high use member + * functions have macro covers to make the implementation both efficient with + * respect to speed without compromising the internal representation. The + * internal array is allocated to fit the requested type's item size. Most + * intrinsic 'C' and Tecplot types are available. + */ + + +/** + * Copies the private array items from the specified source to the target + * location. The buffers may overlap. + * + * note + * Originally this function was a macro that called memmove + * directly: + * + * #define CopyArrayItems(TargetArray, TargetOffset, \ + * SourceArray, SourceOffset, \ + * Count, ItemSize) \ + * (memmove(&((TargetArray)[(TargetOffset)*ItemSize]), \ + * &((SourceArray)[(SourceOffset)*ItemSize]), \ + * Count*ItemSize)) + * + * This however proved troublesome as some machines replaced the memmove + * with a call to memcpy in the linker. The memcpy function does not support + * overlapping moves so I could not use it. This function should be just + * about as fast however so it is no big deal. + * + * param TargetArray + * Base address of the target array to receive the items. + * param TargetOffset + * Target offset of the first item. + * param SourceArray + * Base address of the source array supplying the items. + * param SourceOffset + * Source offset of the first item. + * param Count + * Number of items to copy. + * param ItemSize + * Item size in bytes. + */ +static void CopyArrayItems(char *TargetArray, + LgIndex_t TargetOffset, + char *SourceArray, + LgIndex_t SourceOffset, + LgIndex_t Count, + SmInteger_t ItemSize) +{ + REQUIRE(VALID_REF(TargetArray)); + REQUIRE(TargetOffset >= 0); + REQUIRE(VALID_REF(SourceArray)); + REQUIRE(SourceOffset >= 0); + REQUIRE(&TargetArray[TargetOffset] != &SourceArray[SourceOffset]); + REQUIRE(Count >= 1); + REQUIRE(1 <= ItemSize && ItemSize <= (SmInteger_t)sizeof(ArrayListItem_u)); + + void* TargetPtr = &TargetArray[TargetOffset * ItemSize]; + void* SourcePtr = &SourceArray[SourceOffset * ItemSize]; + memmove(TargetPtr, SourcePtr, ((size_t)Count) * ItemSize); +} + + +/** + * Adjusts the capacity request as necessary to minimize memory reallocations + * for large lists. Unless the request exceeds the maximum the adjusted + * capacity will be at least as big as requested however it may be larger if it + * is determined that the space requirement is growing faster. If the maximum + * is exceeded zero should be returned. + * + * param ArrayList + * Array list requesting the change in capacity. + * param CurrentCapacity + * Current capacity of the array list. + * param RequestedCapacity + * Capacity request or zero for default size. + * param ClientData + * Any client data needed for the adjustment. + * + * return + * Adjusted capacity that is at least as large as the request or zero if + * unable to satisfy the requested capacity. + */ +static LgIndex_t AdjustCapacityRequest(ArrayList_pa ArrayList, + LgIndex_t CurrentCapacity, + LgIndex_t RequestedCapacity, + ArbParam_t ClientData) +{ + LgIndex_t Result; + + REQUIRE(ArrayListIsValid(ArrayList)); + REQUIRE((RequestedCapacity == 0 && CurrentCapacity == 0) || + RequestedCapacity > CurrentCapacity); + + if (RequestedCapacity != 0 && CurrentCapacity == 0) + { + /* first allocation; assume the request is the desired capacityy */ + Result = RequestedCapacity; + } + else + { + const LgIndex_t DEFAULT_CAPACITY = 32; + LgIndex_t BlockSize = MAX(DEFAULT_CAPACITY, CurrentCapacity / 2); + if (RequestedCapacity == 0) + Result = DEFAULT_CAPACITY; + else + Result = ((RequestedCapacity - 1) / BlockSize + 1) * BlockSize; + } + + ENSURE(Result == 0 || Result >= RequestedCapacity); + return Result; +} + + +/** + * Gets the size of an individual element. + * + * param Type + * Array list element type. + * + * return + * Element size corresponding to the type. + */ +static SmInteger_t GetElementSize(ArrayListType_e Type) +{ + SmInteger_t Result; + + REQUIRE(VALID_ENUM(Type, ArrayListType_e)); + + switch (Type) + { + case ArrayListType_UnsignedChar: + Result = (SmInteger_t)sizeof(unsigned char); + break; + case ArrayListType_UnsignedShort: + Result = (SmInteger_t)sizeof(unsigned short); + break; + case ArrayListType_UnsignedInt: + Result = (SmInteger_t)sizeof(unsigned int); + break; + case ArrayListType_UnsignedLong: + Result = (SmInteger_t)sizeof(unsigned long); + break; + case ArrayListType_Int64: + Result = (SmInteger_t)sizeof(Int64_t); + break; + case ArrayListType_Char: + Result = (SmInteger_t)sizeof(char); + break; + case ArrayListType_Short: + Result = (SmInteger_t)sizeof(short); + break; + case ArrayListType_Int: + Result = (SmInteger_t)sizeof(int); + break; + case ArrayListType_Long: + Result = (SmInteger_t)sizeof(long); + break; + case ArrayListType_Float: + Result = (SmInteger_t)sizeof(float); + break; + case ArrayListType_Double: + Result = (SmInteger_t)sizeof(double); + break; + case ArrayListType_LgIndex: + Result = (SmInteger_t)sizeof(LgIndex_t); + break; + case ArrayListType_EntIndex: + Result = (SmInteger_t)sizeof(EntIndex_t); + break; + case ArrayListType_SmInteger: + Result = (SmInteger_t)sizeof(SmInteger_t); + break; + case ArrayListType_Boolean: + Result = (SmInteger_t)sizeof(Boolean_t); + break; + case ArrayListType_ArbParam: + Result = (SmInteger_t)sizeof(ArbParam_t); + break; + + case ArrayListType_UnsignedCharPtr: + Result = (SmInteger_t)sizeof(unsigned char *); + break; + case ArrayListType_UnsignedShortPtr: + Result = (SmInteger_t)sizeof(unsigned short *); + break; + case ArrayListType_UnsignedIntPtr: + Result = (SmInteger_t)sizeof(unsigned int *); + break; + case ArrayListType_UnsignedLongPtr: + Result = (SmInteger_t)sizeof(unsigned long *); + break; + case ArrayListType_Int64Ptr: + Result = (SmInteger_t)sizeof(Int64_t *); + break; + case ArrayListType_CharPtr: + Result = (SmInteger_t)sizeof(char *); + break; + case ArrayListType_ShortPtr: + Result = (SmInteger_t)sizeof(short *); + break; + case ArrayListType_IntPtr: + Result = (SmInteger_t)sizeof(int *); + break; + case ArrayListType_LongPtr: + Result = (SmInteger_t)sizeof(long *); + break; + case ArrayListType_FloatPtr: + Result = (SmInteger_t)sizeof(float *); + break; + case ArrayListType_DoublePtr: + Result = (SmInteger_t)sizeof(double *); + break; + case ArrayListType_LgIndexPtr: + Result = (SmInteger_t)sizeof(LgIndex_t *); + break; + case ArrayListType_EntIndexPtr: + Result = (SmInteger_t)sizeof(EntIndex_t *); + break; + case ArrayListType_SmIntegerPtr: + Result = (SmInteger_t)sizeof(SmInteger_t *); + break; + case ArrayListType_BooleanPtr: + Result = (SmInteger_t)sizeof(Boolean_t *); + break; + case ArrayListType_ArbParamPtr: + Result = (SmInteger_t)sizeof(ArbParam_t *); + break; + + case ArrayListType_VoidPtr: + Result = (SmInteger_t)sizeof(void *); + break; + case ArrayListType_FunctionPtr: + Result = (SmInteger_t)sizeof(void (*)()); + break; + case ArrayListType_Any: /* allows a mixed bag of items */ + Result = (SmInteger_t)sizeof(ArrayListItem_u); + break; + + default: + Result = 0; /* make some compilers happy. */ + CHECK(FALSE); + break; + } + + ENSURE(1 <= Result && Result <= (SmInteger_t)sizeof(ArrayListItem_u)); + return Result; +} + + +/** + * Calls the item destructor for each item specified. + * + * param ArrayList + * Array list needing its items destroyed. + * param ItemOffset + * Offset to the first item to destroy in the list. + * param ItemSize + * Size of each array list item. + * param Count + * Number of items to destroy. + * param ItemDestructor + * Function called for each array list item. + * param CientData + * Any client data needed for the destructor. + */ +static void DestroyItems(ArrayList_pa ArrayList, + LgIndex_t ItemOffset, + SmInteger_t ItemSize, + LgIndex_t Count, + ArrayListItemDestructor_pf ItemDestructor, + ArbParam_t ClientData) +{ + LgIndex_t Index; + + REQUIRE(ArrayListIsValid(ArrayList)); + REQUIRE(0 <= ItemOffset && ItemOffset <= ArrayList->Count - 1); + REQUIRE(1 <= Count && ItemOffset + Count <= ArrayList->Count); + REQUIRE(VALID_FN_REF(ItemDestructor)); + + for (Index = 0; + Index < Count; + Index++) + { + LgIndex_t ItemIndex = (Index + ItemOffset) * ItemSize; +#if !defined NO_ASSERTS + Boolean_t DoContinue = ItemDestructor((void *) & ArrayList->Array[ItemIndex], ClientData); + CHECK(DoContinue); /* this is a requirement of ArrayListItemDestructor_pf */ +#else + ItemDestructor((void *)&ArrayList->Array[ItemIndex], ClientData); +#endif + } +} + + +/** + * Calls the item duplicator for each item specified. + * + * param TargetArray + * Target array needing its items duplicated. + * param TargetItemOffset + * Target offset to the first duplicated item. + * param SourceArray + * Source array needing its items duplicated. + * param SourceItemOffset + * Source offset to the first item to duplicate in the list. + * param ItemSize + * Size of each array list item. + * param Count + * Number of items to duplicate. + * param ItemDuplicator + * Function called for each array list item. + * param CientData + * Any client data needed for the destructor. + * + * return + * TRUE if the duplication was a success + * FALSE otherwise + */ +static Boolean_t DuplicateItems(char *TargetArray, + LgIndex_t TargetItemOffset, + char *SourceArray, + LgIndex_t SourceItemOffset, + SmInteger_t ItemSize, + LgIndex_t Count, + ArrayListItemDuplicator_pf ItemDuplicator, + ArbParam_t ClientData) +{ + Boolean_t IsOk = TRUE; + LgIndex_t Index; + + REQUIRE(VALID_REF(TargetArray)); + REQUIRE(TargetItemOffset >= 0); + REQUIRE(VALID_REF(SourceArray)); + REQUIRE(SourceItemOffset >= 0); + REQUIRE(1 <= ItemSize && + ItemSize <= (SmInteger_t)sizeof(ArrayListItem_u)); + REQUIRE(Count >= 1); + REQUIRE(VALID_FN_REF(ItemDuplicator)); + + for (Index = 0; + Index < Count && IsOk; + Index++) + { + LgIndex_t TargetItemIndex = (Index + TargetItemOffset) * ItemSize; + LgIndex_t SourceItemIndex = (Index + SourceItemOffset) * ItemSize; + IsOk = ItemDuplicator((void *) & TargetArray[TargetItemIndex], + (void *) & SourceArray[SourceItemIndex], + ClientData); + } + + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + + +/** + * Determine if the list handle is sane. + * + * param ArrayList + * Array list in question. + * + * return + * TRUE if the array list is valid, otherwise FALSE. + */ +Boolean_t ArrayListIsValid(ArrayList_pa ArrayList) +{ + Boolean_t IsValid; + + /* this just makes sure that the NULL item global was initialized */ + INVARIANT(ArrayListNullItem.Double == 0.0); + + IsValid = (VALID_REF(ArrayList) && + VALID_ENUM(ArrayList->Type, ArrayListType_e) && + (1 <= ArrayList->ItemSize && + ArrayList->ItemSize <= (SmInteger_t)sizeof(ArrayListItem_u)) && + (0 <= ArrayList->Count && + ArrayList->Count <= ArrayList->Capacity)); + + ENSURE(VALID_BOOLEAN(IsValid)); + return IsValid; +} + + +/** + * Gets the specified array list's type. + * + * param ArrayList + * Array list of which the type is desired. + * + * return + * Array list type. + */ +ArrayListType_e ArrayListGetType(ArrayList_pa ArrayList) +{ + ArrayListType_e Result; + + REQUIRE(ArrayListIsValid(ArrayList)); + + Result = ArrayList->Type; + + ENSURE(VALID_ENUM(Result, ArrayListType_e)); + return Result; +} + + +/** + * Enlarge the list capacity to accommodate, at a minimum, the requested + * capacity (number of items). The enlarged section is initialized with zeros. + * This function can be called by clients who want to ensure that calls to + * the ArrayListSetXxx class of functions will never fail for offsets within + * the RequestedCapacity. + * + * param ArrayList + * Current capacity used as a helpful hint for the adjustment algorythm. + * param RequestedCapacity + * Capacity (number ot items) request or zero for default size. + * + * return + * TRUE if the list could be enlarged (or was large enough), + * otherwise FALSE. + */ +Boolean_t ArrayListEnlargeCapacity(ArrayList_pa ArrayList, + LgIndex_t RequestedCapacity) +{ + Boolean_t IsOk; + LgIndex_t AdjustedCapacity; + char *EnlargedArray; + + REQUIRE(ArrayListIsValid(ArrayList)); + REQUIRE(IMPLICATION(RequestedCapacity == 0, ArrayList->Capacity == 0)); + + if (RequestedCapacity == 0 || + RequestedCapacity > ArrayList->Capacity) + { + AdjustedCapacity = + ArrayList->CapacityRequestAdjuster(ArrayList, + ArrayList->Capacity, + RequestedCapacity, + ArrayList->CapacityRequestAdjusterClientData); + CHECK(AdjustedCapacity == 0 || + AdjustedCapacity >= RequestedCapacity); + + IsOk = (AdjustedCapacity != 0); /* ...were we able to meet the request? */ + if (IsOk) + { + EnlargedArray = ALLOC_ARRAY(AdjustedCapacity * ArrayList->ItemSize, + char, "array list"); + if (EnlargedArray == NULL) + { + /* try again with minimum capacity request */ + if (RequestedCapacity != 0) + AdjustedCapacity = RequestedCapacity; + else + AdjustedCapacity = 1; /* can't get smaller than this */ + EnlargedArray = ALLOC_ARRAY(AdjustedCapacity * ArrayList->ItemSize, + char, "array list"); + } + IsOk = (EnlargedArray != NULL); + } + + if (IsOk) + { + /* + * Initialize the expanded section of the array with zeros. This default + * value of zero is necessary for many other array list operations. + */ + memset(&EnlargedArray[ArrayList->Count*ArrayList->ItemSize], 0, + (AdjustedCapacity - ArrayList->Count)*ArrayList->ItemSize); + + if (ArrayList->Array != NULL) + { + if (ArrayList->Count != 0) + CopyArrayItems(EnlargedArray, 0, + ArrayList->Array, 0, + ArrayList->Count, + ArrayList->ItemSize); + FREE_ARRAY(ArrayList->Array, "array list"); + } + + ArrayList->Array = EnlargedArray; + ArrayList->Capacity = AdjustedCapacity; + } + } + else + { + IsOk = TRUE; + } + + ENSURE(ArrayListIsValid(ArrayList)); + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + + +/** + * Allocates an array list handle with the estimated capacity + * or a suitable default if an estimate is unavailable. + * + * param EstimatedCapacity + * Clients best guess at the estimated capacity (number of items) needed. + * If an estimate is not available zero the zero should be used to get the + * default capacity. + * param Type + * Type of array list being allocated. + * param CapacityRequestAdjuster + * Function to use to adjust any capacity change requests or + * NULL if the default adjuster is good enough. + * param CapacityRequestAdjusterClientData + * Any client data needed for the capacity adjustment. + * + * return + * Array list handle if sufficient memory was available, + * otherwise a handle to NULL. + */ +ArrayList_pa ArrayListAlloc(LgIndex_t EstimatedCapacity, + ArrayListType_e Type, + ArrayListCapacityRequestAdjuster_pf CapacityRequestAdjuster, + ArbParam_t CapacityRequestAdjusterClientData) +{ + ArrayList_pa Result; + + REQUIRE(EstimatedCapacity >= 0); + REQUIRE(VALID_ENUM(Type, ArrayListType_e)); + + Result = ALLOC_ITEM(ArrayList_s, "ArrayList structure"); + if (Result != NULL) + { + Result->Array = NULL; + Result->Type = Type; + Result->ItemSize = GetElementSize(Type); + Result->Count = 0; + Result->Capacity = 0; + Result->IsVisitingItems = FALSE; + if (CapacityRequestAdjuster != NULL) + { + /* install the client's capacity request adjuster */ + Result->CapacityRequestAdjuster = CapacityRequestAdjuster; + Result->CapacityRequestAdjusterClientData = CapacityRequestAdjusterClientData; + } + else + { + /* install the default capacity request adjuster */ + Result->CapacityRequestAdjuster = AdjustCapacityRequest; + Result->CapacityRequestAdjusterClientData = 0; + } + + /* enalarge the list to the estimated capacity */ + if (!ArrayListEnlargeCapacity(Result, EstimatedCapacity)) + ArrayListDealloc(&Result, NULL, 0); + } + + ENSURE(ArrayListIsValid(Result) || Result == NULL); + ENSURE(IMPLICATION(Result != NULL, Result->Capacity >= EstimatedCapacity)); + return Result; +} + + +/** + * Deallocates the list handle and set the handle to NULL. + * + * param ArrayList + * Reference to an array list handle. + * param ItemDestructor + * Destructor responsible for array list item cleanup or + * NULL if no item cleanup is desired. + * param ClientData + * Any client data needed for cleanup. + */ +void ArrayListDealloc(ArrayList_pa *ArrayList, + ArrayListItemDestructor_pf ItemDestructor, + ArbParam_t ClientData) +{ + REQUIRE(VALID_REF(ArrayList)); + REQUIRE(ArrayListIsValid(*ArrayList) || *ArrayList == NULL); + REQUIRE(VALID_FN_REF(ItemDestructor) || ItemDestructor == NULL); + + if (*ArrayList != NULL) + { + /* request item cleanup if a destructor was supplied */ + if (ItemDestructor != NULL && (*ArrayList)->Count != 0) + DestroyItems(*ArrayList, 0, (*ArrayList)->ItemSize, (*ArrayList)->Count, + ItemDestructor, ClientData); + + /* release the list */ + if ((*ArrayList)->Capacity != 0) + FREE_ARRAY((*ArrayList)->Array, "array list"); + + /* release the list structure itself */ + FREE_ITEM(*ArrayList, "ArrayList structure"); + *ArrayList = NULL; + } + + ENSURE(*ArrayList == NULL); +} + + +#if !defined USE_MACROS_FOR_FUNCTIONS +/** + * Gets the number of items currently maintained by the list. + * + * param + * Array list in question. + * + * return + * Number of items maintained by the list. + */ +LgIndex_t ArrayListGetCount_FUNC(ArrayList_pa ArrayList) +{ + LgIndex_t Result; + + REQUIRE(ArrayListIsValid(ArrayList)); + + Result = ArrayListGetCount_MACRO(ArrayList); + + ENSURE(Result >= 0); + return Result; +} +#endif + + +/** + * Empties the array list of all items. + * + * param ArrayList + * Array list from which to delete all items. + * param ItemDestructor + * Destructor responsible for array list item cleanup or + * NULL if no item cleanup is desired. + * param ClientData + * Any client data needed for cleanup. + */ +void ArrayListDeleteAllItems(ArrayList_pa ArrayList, + ArrayListItemDestructor_pf ItemDestructor, + ArbParam_t ClientData) +{ + REQUIRE(ArrayListIsValid(ArrayList)); + REQUIRE(VALID_FN_REF(ItemDestructor) || ItemDestructor == NULL); + REQUIRE(!ArrayList->IsVisitingItems); + + /* request item cleanup if a destructor was supplied */ + if (ItemDestructor != NULL && ArrayList->Count != 0) + DestroyItems(ArrayList, 0, ArrayList->ItemSize, ArrayList->Count, + ItemDestructor, ClientData); + + /* + * Fill the vacated items with zeros. This default value of zero is necessary + * for many other array list operations. + */ + if (ArrayList->Count != 0) + memset(&ArrayList->Array[0], 0, ArrayList->Count*ArrayList->ItemSize); + + ArrayList->Count = 0; + + ENSURE(ArrayListIsValid(ArrayList) && ArrayList->Count == 0); +} + + +/** + * Deletes 'Count' items from the array list. The members following the + * items deleted are shifted down accordingly to fill the vacated space. + * + * param ArrayList + * Array list containing the items to delete. + * param ItemOffset + * Offset to the first item to delete in the list. + * param Count + * Number of items to delete. + * param ItemDestructor + * Destructor responsible for array list item cleanup or + * NULL if no item cleanup is desired. + * param ClientData + * Any client data needed for cleanup. + */ +void ArrayListDeleteItems(ArrayList_pa ArrayList, + LgIndex_t ItemOffset, + LgIndex_t Count, + ArrayListItemDestructor_pf ItemDestructor, + ArbParam_t ClientData) +{ + REQUIRE(ArrayListIsValid(ArrayList)); + REQUIRE(0 <= ItemOffset && ItemOffset <= ArrayList->Count - 1); + REQUIRE(1 <= Count && ItemOffset + Count <= ArrayList->Count); + REQUIRE(VALID_FN_REF(ItemDestructor) || ItemDestructor == NULL); + REQUIRE(!ArrayList->IsVisitingItems); + + /* release the items if a destructor is installed */ + if (ItemDestructor != NULL) + DestroyItems(ArrayList, ItemOffset, ArrayList->ItemSize, Count, + ItemDestructor, ClientData); + + /* if we deleted the items from the middle of the array then */ + /* shift the end items down by 'Count' to fill the vacated space */ + if (ItemOffset + Count < ArrayList->Count) + CopyArrayItems(ArrayList->Array, ItemOffset, + ArrayList->Array, ItemOffset + Count, + ArrayList->Count - (ItemOffset + Count), + ArrayList->ItemSize); + /* + * Fill the vacated items with zeros. This default value of zero is necessary + * for many other array list operations. + */ + memset(&ArrayList->Array[(ArrayList->Count - Count)*ArrayList->ItemSize], + 0, Count*ArrayList->ItemSize); + + /* update the count but leave the capacity alone */ + ArrayList->Count -= Count; + + ENSURE(ArrayListIsValid(ArrayList)); +} + + +/** + * Deletes an item from the array list. The members following the item + * deleted are shifted down accordingly to fill the vacated space. + * + * param ArrayList + * Array list containing the item to delete. + * param ItemOffset + * Offset to the item in the list. + * param ItemDestructor + * Destructor responsible for array list item cleanup or + * NULL if no item cleanup is desired. + * param ClientData + * Any client data needed for cleanup. + */ +void ArrayListDeleteItem(ArrayList_pa ArrayList, + LgIndex_t ItemOffset, + ArrayListItemDestructor_pf ItemDestructor, + ArbParam_t ClientData) +{ + REQUIRE(ArrayListIsValid(ArrayList)); + REQUIRE(0 <= ItemOffset && ItemOffset <= ArrayList->Count - 1); + REQUIRE(VALID_FN_REF(ItemDestructor) || ItemDestructor == NULL); + + ArrayListDeleteItems(ArrayList, ItemOffset, 1, ItemDestructor, ClientData); + + ENSURE(ArrayListIsValid(ArrayList)); +} + + +/** + * Removes 'Count' items from the array list beginning at the specified + * item offset. The members following the items removed are shifted down + * accordingly to fill the vacated space. + * + * param ArrayList + * Array list containing the items to remove. + * param ItemOffset + * Offset to the first item to remove in the list. + * param Count + * Number of items to remove. + * + * return + * Array list handle referring to the removed items if sufficient + * memory was available, otherwise a handle to NULL. + */ +ArrayList_pa ArrayListRemoveItems(ArrayList_pa ArrayList, + LgIndex_t ItemOffset, + LgIndex_t Count) +{ + ArrayList_pa Result; + + REQUIRE(ArrayListIsValid(ArrayList)); + REQUIRE(0 <= ItemOffset && ItemOffset <= ArrayList->Count - 1); + REQUIRE(1 <= Count && ItemOffset + Count <= ArrayList->Count); + REQUIRE(!ArrayList->IsVisitingItems); + + /* get a copy of the items and delete them from the source */ + Result = ArrayListGetItems(ArrayList, ItemOffset, Count); + if (Result != NULL) + ArrayListDeleteItems(ArrayList, ItemOffset, Count, NULL, 0); + + ENSURE(ArrayListIsValid(ArrayList)); + ENSURE(ArrayListIsValid(Result) || Result == NULL); + return Result; +} + + +/** + * Removes an item from the array list. The members following the item + * removed are shifted down accordingly to fill the vacated space. + * + * param ArrayList + * Array list containing the item to remove. + * param ItemOffset + * Offset to the item in the list. + * + * return + * Item removed from the array list. + */ +ArrayListItem_u ArrayListRemoveItem(ArrayList_pa ArrayList, + LgIndex_t ItemOffset) +{ + ArrayListItem_u Result; + + REQUIRE(ArrayListIsValid(ArrayList)); + REQUIRE(0 <= ItemOffset && ItemOffset <= ArrayList->Count - 1); + REQUIRE(!ArrayList->IsVisitingItems); + + /* record the original item */ + CopyArrayItems((char *)&Result, 0, + ArrayList->Array, ItemOffset, + 1, ArrayList->ItemSize); + + /* delete the item from the array */ + ArrayListDeleteItems(ArrayList, ItemOffset, 1, NULL, 0); + + ENSURE(ArrayListIsValid(ArrayList)); + return Result; +} + + +/** + * Inserts copies of the items from the source list to the target list at + * the specified offset. The target list will expand to accommodate the + * additional items. The source list remains unchanged. + * + * param Target + * Array list receiving the source items. + * param ItemOffset + * Offset at which to insert the source list items. + * param Source + * Array list supplying the source items. + * + * return + * TRUE if sufficient memory permitted the operation, otherwise FALSE. + */ +Boolean_t ArrayListInsert(ArrayList_pa Target, + LgIndex_t ItemOffset, + ArrayList_pa Source) +{ + Boolean_t IsOk = TRUE; + + REQUIRE(ArrayListIsValid(Target)); + REQUIRE(ItemOffset >= 0); + REQUIRE(ArrayListIsValid(Source)); + REQUIRE(Target != Source); + REQUIRE(Target->Type == Source->Type); + REQUIRE(!Target->IsVisitingItems); + + if (Source->Count != 0) + { + LgIndex_t NeededCapacity; + + /* if necessary enlarge the target list to accommodate the request */ + if (ItemOffset > Target->Count) + NeededCapacity = ItemOffset + Source->Count; + else + NeededCapacity = Target->Count + Source->Count; + if (NeededCapacity > Target->Capacity) + IsOk = ArrayListEnlargeCapacity(Target, NeededCapacity); + + if (IsOk) + { + if (ItemOffset < Target->Count) + { + /* shift all items in the target list ahead of the */ + /* insert position up by the number of items in the */ + /* source list to make room for the new items */ + CopyArrayItems(Target->Array, ItemOffset + Source->Count, + Target->Array, ItemOffset, + Target->Count - ItemOffset, + Target->ItemSize); + Target->Count += Source->Count; + } + else + { + /* no shifting to do, just update the count */ + if (ItemOffset > Target->Count) + Target->Count = ItemOffset + Source->Count; + else + Target->Count += Source->Count; + } + + /* insert the items and update the count */ + CopyArrayItems(Target->Array, ItemOffset, + Source->Array, 0, + Source->Count, Source->ItemSize); + } + } + + ENSURE(ArrayListIsValid(Target)); + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + + +/** + * Inserts the item into the array list at the specified offset. The list will + * be expanded to accommodate the additional item. If the offset is beyond the + * end of the list it is sized accordingly and the intervening items between + * the last item of the original state and the last item of the new state are + * guaranteed to be 0. + * + * param ArrayList + * Array list target in which to insert the item. + * param ItemOffset + * Offset at which to insert the item. + * param Item + * Item to insert at the specified offset. + * + * return + * TRUE if sufficient memory permitted the operation, otherwise FALSE. + */ +Boolean_t ArrayListInsertItem(ArrayList_pa ArrayList, + LgIndex_t ItemOffset, + ArrayListItem_u Item) +{ + Boolean_t IsOk = TRUE; + LgIndex_t NeededCapacity; + + REQUIRE(ArrayListIsValid(ArrayList)); + REQUIRE(ItemOffset >= 0); + REQUIRE(!ArrayList->IsVisitingItems); + + /* if necessary enlarge the list to accommodate the request */ + if (ItemOffset > ArrayList->Count) + NeededCapacity = ItemOffset + 1; + else + NeededCapacity = ArrayList->Count + 1; + if (NeededCapacity > ArrayList->Capacity) + IsOk = ArrayListEnlargeCapacity(ArrayList, NeededCapacity); + + if (IsOk) + { + if (ItemOffset < ArrayList->Count) + { + /* shift all items in the target list ahead of the insert */ + /* position up by one to make room for the new item */ + CopyArrayItems(ArrayList->Array, ItemOffset + 1, + ArrayList->Array, ItemOffset, + ArrayList->Count - ItemOffset, + ArrayList->ItemSize); + ArrayList->Count++; + } + else + { + /* no shifting to do, just update the count */ + if (ItemOffset > ArrayList->Count) + ArrayList->Count = ItemOffset + 1; + else + ArrayList->Count++; + } + + /* insert the item */ + CopyArrayItems(ArrayList->Array, ItemOffset, + (char *)&Item, 0, + 1, ArrayList->ItemSize); + } + + ENSURE(ArrayListIsValid(ArrayList)); + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + + +/** + * Visits array list items calling the item visitor for each item. + * + * param ArrayList + * Array list needing its items destroyed. + * param ItemOffset + * Offset to the first item to visit from the list. + * param Count + * Number of items to visit. + * param ItemVisitor + * Function called for each array list item. + * param CientData + * Any client data needed for the visitor. + * + * return + * TRUE if the all element were visited, otherwise + * FALSE if the visitation was terminated early + */ +Boolean_t ArrayListVisitItems(ArrayList_pa ArrayList, + LgIndex_t ItemOffset, + LgIndex_t Count, + ArrayListItemVisitor_pf ItemVisitor, + ArbParam_t ClientData) +{ + Boolean_t DoContinue = TRUE; + Boolean_t IsVisitingItems; + SmInteger_t ItemSize; + LgIndex_t Index; + + REQUIRE(ArrayListIsValid(ArrayList)); + REQUIRE(VALID_FN_REF(ItemVisitor)); + + IsVisitingItems = ArrayList->IsVisitingItems; + ArrayList->IsVisitingItems = TRUE; /* guards against structure changes */ + + for (Index = 0, ItemSize = ArrayList->ItemSize; + Index < Count && DoContinue; + Index++) + { + LgIndex_t ItemIndex = (Index + ItemOffset) * ItemSize; + DoContinue = ItemVisitor((void *) & ArrayList->Array[ItemIndex], ClientData); + } + + ArrayList->IsVisitingItems = IsVisitingItems; + + ENSURE(ArrayList->IsVisitingItems == IsVisitingItems); + ENSURE(VALID_BOOLEAN(DoContinue)); + return DoContinue; +} + + +/** + * Gets copies of 'Count' items from the array list beginning at the + * specified item offset. Note that if the items are pointer types + * the copies are of the pointers and not the pointees. + * + * param ArrayList + * Array list containing the items to copy. + * param ItemOffset + * Offset to the first item to copy from the list. + * param Count + * Number of items to copy. + * + * return + * Array list handle referring to the copied items if sufficient + * memory was available, otherwise a handle to NULL. + */ +ArrayList_pa ArrayListGetItems(ArrayList_pa ArrayList, + LgIndex_t ItemOffset, + LgIndex_t Count) +{ + ArrayList_pa Result; + + REQUIRE(ArrayListIsValid(ArrayList)); + REQUIRE(0 <= ItemOffset && ItemOffset <= ArrayList->Count - 1); + REQUIRE(1 <= Count && ItemOffset + Count <= ArrayList->Count); + + Result = ArrayListAlloc(Count, ArrayList->Type, + ArrayList->CapacityRequestAdjuster, + ArrayList->CapacityRequestAdjusterClientData); + if (Result != NULL) + { + /* copy the original items into the result */ + CopyArrayItems(Result->Array, 0, + ArrayList->Array, ItemOffset, + Count, ArrayList->ItemSize); + Result->Count = Count; + } + + ENSURE(ArrayListIsValid(ArrayList)); + ENSURE(ArrayListIsValid(Result) || Result == NULL); + return Result; +} + + +/** + * Gets the item at the specified offset in the list. + * + * param ArrayList + * Array list containing the desired item. + * param ItemOffset + * Offset to the item in the list. + * + * return + * The requested item. + */ +ArrayListItem_u ArrayListGetItem(ArrayList_pa ArrayList, + LgIndex_t ItemOffset) +{ + ArrayListItem_u Result; + + REQUIRE(ArrayListIsValid(ArrayList)); + REQUIRE(0 <= ItemOffset && ItemOffset <= ArrayList->Count - 1); + + CopyArrayItems((char *)&Result, 0, + ArrayList->Array, ItemOffset, + 1, ArrayList->ItemSize); + + return Result; +} + + +#if !defined USE_MACROS_FOR_FUNCTIONS +/** + * Gets the item's internal reference at the specified offset in the list. + * + * WARNING: + * Some array list functions modify the internal buffer. + * This will invalidate this reference however it is + * the client's responsibility not to make further use + * of it. In addition, this reference should never be + * deallocated directly as the array list assumes the + * responsible for the cleanup. + * + * param ArrayList + * Array list containing the desired item. + * param ItemOffset + * Offset to the item in the list. + * + * return + * The internal reference to the requested item. + */ +const void *ArrayListGetItemInternalRef_FUNC(ArrayList_pa ArrayList, + LgIndex_t ItemOffset) +{ + REQUIRE(ArrayListIsValid(ArrayList)); + REQUIRE(0 <= ItemOffset && ItemOffset <= ArrayList->Count - 1); + + const void *Result = ArrayListGetItemInternalRef_MACRO(ArrayList, ItemOffset); + ENSURE(Result == NULL || VALID_REF(Result)); + return Result; +} +#endif + + +/** + * Places the item at the specified offset. If the offset is beyond the + * end of the list it is sized accordingly and the intervening items + * between the last item of the original state and the last item of the + * new state are guaranteed to be 0. + * + * param ArrayList + * Array list target in which to set the item. + * param ItemOffset + * Offset of the item. + * param Item + * Item to set at the specified offset. + * param ItemDestructor + * Destructor responsible for array list item cleanup or + * NULL if no item cleanup is desired. + * param ClientData + * Any client data needed for cleanup. + * + * return + * TRUE if sufficient memory permitted the operation, otherwise FALSE. + */ +Boolean_t ArrayListSetItem(ArrayList_pa ArrayList, + LgIndex_t ItemOffset, + ArrayListItem_u Item, + ArrayListItemDestructor_pf ItemDestructor, + ArbParam_t ClientData) +{ + Boolean_t IsOk = TRUE; + + REQUIRE(ArrayListIsValid(ArrayList)); + REQUIRE(ItemOffset >= 0); + REQUIRE(VALID_FN_REF(ItemDestructor) || ItemDestructor == NULL); + REQUIRE(IMPLICATION(ItemOffset + 1 > ArrayList->Count, + !ArrayList->IsVisitingItems)); + + /* release the item if a destructor is installed */ + if (ItemDestructor != NULL && ItemOffset < ArrayList->Count) + DestroyItems(ArrayList, ItemOffset, ArrayList->ItemSize, 1, + ItemDestructor, ClientData); + + /* if necessary enlarge the list to accommodate the request */ + if (ItemOffset + 1 > ArrayList->Capacity) + IsOk = ArrayListEnlargeCapacity(ArrayList, ItemOffset + 1); + + if (IsOk) + { + if (ItemOffset + 1 > ArrayList->Count) + ArrayList->Count = ItemOffset + 1; + CopyArrayItems(ArrayList->Array, ItemOffset, + (char *)&Item, 0, + 1, ArrayList->ItemSize); + } + + ENSURE(ArrayListIsValid(ArrayList)); + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + + +/** + * Appends the item to the list. The list will be expanded + * to accommodate the additional item. + * + * param ArrayList + * Array list target to which the item is to be appended. + * param Item + * Item to append to the array list. + * + * return + * TRUE if sufficient memory permitted the operation, otherwise FALSE. + */ +Boolean_t ArrayListAppendItem(ArrayList_pa ArrayList, + ArrayListItem_u Item) +{ + Boolean_t IsOk; + + REQUIRE(ArrayListIsValid(ArrayList)); + REQUIRE(!ArrayList->IsVisitingItems); + + IsOk = ArrayListInsertItem(ArrayList, ArrayList->Count, Item); + + ENSURE(ArrayListIsValid(ArrayList)); + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + + +/** + * Appends copies of the items from the source list to the target list. + * The source list remains unchanged. + * + * param Target + * Array list receiving the source items. + * param Source + * Array list supplying the source items. + * + * return + * TRUE if sufficient memory permitted the operation, otherwise FALSE. + */ +Boolean_t ArrayListAppend(ArrayList_pa Target, + ArrayList_pa Source) +{ + Boolean_t IsOk; + + REQUIRE(ArrayListIsValid(Target)); + REQUIRE(ArrayListIsValid(Source)); + REQUIRE(Target != Source); + REQUIRE(Target->Type == Source->Type); + REQUIRE(!Target->IsVisitingItems); + + IsOk = ArrayListInsert(Target, Target->Count, Source); + + ENSURE(ArrayListIsValid(Target)); + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + + +/** + * Copies the items of the array list. + * + * param ArrayList + * Array list to copy. + * param ItemDuplicator + * Duplicator responsible for array list item duplication or + * NULL if an exact item copy is desired. In other words for + * pointer types the effect is copy by reference. + * param ClientData + * Any client data needed for duplication. + * + * return + * Handle to a duplicate of the specified array list if sufficient + * memory permitted the operation, otherwise NULL. + */ +ArrayList_pa ArrayListCopy(ArrayList_pa ArrayList, + ArrayListItemDuplicator_pf ItemDuplicator, + ArbParam_t ClientData) +{ + ArrayList_pa Result; + + REQUIRE(ArrayListIsValid(ArrayList)); + REQUIRE(VALID_FN_REF(ItemDuplicator) || ItemDuplicator == NULL); + + Result = ArrayListAlloc(ArrayList->Count, ArrayList->Type, + ArrayList->CapacityRequestAdjuster, + ArrayList->CapacityRequestAdjusterClientData); + if (Result != NULL && ArrayList->Count != 0) + { + Boolean_t IsOk = TRUE; + if (ItemDuplicator != NULL) + /* client defines how the item duplication is performed */ + IsOk = DuplicateItems(Result->Array, 0, + ArrayList->Array, 0, + ArrayList->ItemSize, ArrayList->Count, + ItemDuplicator, ClientData); + else + /* copy the original items into the result */ + CopyArrayItems(Result->Array, 0, + ArrayList->Array, 0, + ArrayList->Count, + ArrayList->ItemSize); + if (IsOk) + Result->Count = ArrayList->Count; + else + ArrayListDealloc(&Result, NULL, 0); + } + + ENSURE(Result == NULL || + (ArrayListIsValid(Result) && Result->Count == ArrayList->Count)); + return Result; +} + + +/** + * Creates a native 'C' array containing copies of the items held in the + * source array list. + * + * param Source + * Array list containing the items of interest. + * param ItemDuplicator + * Duplicator responsible for array list item duplication or + * NULL if an exact item copy is desired. In other words for + * pointer types the effect is copy by reference. + * param ClientData + * Any client data needed for duplication. + * + * return + * Allocated array populated with copies of the members of the array list + * or NULL if there are no items in the list or if the allocation was + * not successful. The caller is responsible for deallocation of the + * array (but not the individual members unless a item duplication function + * was supplied) when it is no longer needed. + */ +void *ArrayListToArray(ArrayList_pa Source, + ArrayListItemDuplicator_pf ItemDuplicator, + ArbParam_t ClientData) +{ + void *Result; + + REQUIRE(ArrayListIsValid(Source)); + REQUIRE(VALID_FN_REF(ItemDuplicator) || ItemDuplicator == NULL); + + if (Source->Count != 0) + Result = (void *)ALLOC_ARRAY(Source->Count * Source->ItemSize, + char, "native array"); + else + Result = NULL; + + if (Result != NULL) + { + Boolean_t IsOk = TRUE; + if (ItemDuplicator != NULL) + /* client defines how the item duplication is performed */ + IsOk = DuplicateItems((char*)Result, 0, + Source->Array, 0, + Source->ItemSize, Source->Count, + ItemDuplicator, ClientData); + else + /* copy the original items into the result */ + CopyArrayItems((char *)Result, 0, + Source->Array, 0, + Source->Count, + Source->ItemSize); + if (!IsOk) + { + /* Hack to remove delete warning... */ + char *Tmp = (char *)Result; + FREE_ARRAY(Tmp, "native array"); + } + } + + ENSURE(VALID_REF(Result) || Result == NULL); + return Result; +} + + +/** + * Creates an array list containing copies of the items held in the + * native 'C' array. + * + * param Source + * Native 'C' array containing the items of interest. + * param Count + * Number of items contained in the native 'C' array. + * param Type + * Type of items contained in the native 'C' array. + * param ItemDuplicator + * Duplicator responsible for array list item duplication or + * NULL if an exact item copy is desired. In other words for + * pointer types the effect is copy by reference. + * param ClientData + * Any client data needed for duplication. + * + * return + * Array list handle containing copies of the items held in the + * native 'C' array if sufficient memory was available, otherwise + * a handle to NULL. + */ +ArrayList_pa ArrayListFromArray(void *Source, + LgIndex_t Count, + ArrayListType_e Type, + ArrayListItemDuplicator_pf ItemDuplicator, + ArbParam_t ClientData) +{ + ArrayList_pa Result; + + REQUIRE(VALID_REF(Source)); + REQUIRE(Count >= 0); + REQUIRE(VALID_ENUM(Type, ArrayListType_e)); + REQUIRE(VALID_FN_REF(ItemDuplicator) || ItemDuplicator == NULL); + + Result = ArrayListAlloc(Count, Type, NULL, 0); + if (Result != NULL && Count != 0) + { + Boolean_t IsOk = TRUE; + if (ItemDuplicator != NULL) + /* client defines how the item duplication is performed */ + IsOk = DuplicateItems(Result->Array, 0, + (char*)Source, 0, + Result->ItemSize, Count, + ItemDuplicator, ClientData); + else + /* copy the original items into the result */ + CopyArrayItems(Result->Array, 0, + (char *)Source, 0, + Count, Result->ItemSize); + if (IsOk) + Result->Count = Count; + else + ArrayListDealloc(&Result, NULL, 0); + } + + ENSURE(ArrayListIsValid(Result) || Result == NULL); + return Result; +} + + +/** + * Holds the comparator function pointer for sorting. + */ +static ArrayListItemComparator_pf ComparatorFunction = NULL; + + +/** + * Holds the context for comparisons. This information is forwarded to + * the item comparator function for sorting. + */ +static ArbParam_t ComparatorClientData = 0; + + +/** + * Holds the item size of the individual array components for sorting. + */ +static SmInteger_t ComparatorItemSize = 0; + + +/** + * Forwards the comparison test to the 'Comparator' supplied to the + * 'ArrayListQSort' function. + * + * param Item1Ref + * Reference to base address of Item1. + * param Item2Ref + * Reference to base address of Item2. + * + * return + * - A value less than zero if Item1 is less than Item2. + * - A value of zero if Item1 is equal to Item2. + * - A value greater than zero if Item1 is greater than Item2. + */ +static int QSortCompareItemsAdapter(const void *Item1Ref, + const void *Item2Ref) +{ + int Result; + ArrayListItem_u Item1; + ArrayListItem_u Item2; + + REQUIRE(Item1Ref != NULL); + REQUIRE(Item2Ref != NULL); + + /* collect up the items */ + CopyArrayItems((char *)&Item1, 0, + (char *)Item1Ref, 0, + 1, ComparatorItemSize); + CopyArrayItems((char *)&Item2, 0, + (char *)Item2Ref, 0, + 1, ComparatorItemSize); + + /* forward the call */ + Result = ComparatorFunction(Item1, Item2, ComparatorClientData); + + ENSURE(Result == -1 || Result == 0 || Result == 1); + return Result; +} + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +/** + * Sorts the array list using the qsort algorithm. + * + * param ArrayList + * Array list to sort. + * param Comparator + * Function called to compare two array list elements. + * param ClientData + * Contextual information that is passed along to the comparator function. + */ +void ArrayListQSort(ArrayList_pa ArrayList, + ArrayListItemComparator_pf Comparator, + ArbParam_t ClientData) +{ + ArrayListItemComparator_pf CurComparatorFunction; + ArbParam_t CurComparatorClientData; + SmInteger_t CurComparatorItemSize; + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + REQUIRE(ArrayListIsValid(ArrayList)); + REQUIRE(VALID_FN_REF(Comparator)); + + /* to support sort recursion we need to save off the current values */ + CurComparatorFunction = ComparatorFunction; + CurComparatorClientData = ComparatorClientData; + CurComparatorItemSize = ComparatorItemSize; + + /* set up for comparison proxy */ + ComparatorFunction = Comparator; + ComparatorClientData = ClientData; + ComparatorItemSize = ArrayList->ItemSize; + + /* sort the array */ + qsort(ArrayList->Array, ArrayList->Count, + ArrayList->ItemSize, QSortCompareItemsAdapter); + + /* cleanup */ + ComparatorFunction = CurComparatorFunction; + ComparatorClientData = CurComparatorClientData; + ComparatorItemSize = CurComparatorItemSize; + + ENSURE(ArrayListIsValid(ArrayList)); +} + +/** + * Binary searches a sorted array looking for a match using the supplied + * comparator function. If a match is found the resulting item index refers to + * the location otherwise it refers to the location where the item could be + * inserted in sorted order. + * + * param ArrayList + * Array list to sort. + * param Item + * The item for which to search. + * param Comparator + * Function called to compare the Item to the array list elements. + * param ClientData + * Contextual information that is passed along to the comparator function. + * param ItemIndex + * Pointer to the resulting position where the item was found or where the + * item could be inserted in sorted order. If the pointer is NULL the + * result position is not returned. + * + * result + * TRUE if the item was found in the list, FALSE otherwise. + */ +Boolean_t ArrayListBSearch(ArrayList_pa ArrayList, + ArrayListItem_u Item, + ArrayListItemComparator_pf Comparator, + ArbParam_t ClientData, + LgIndex_t *ItemIndex) +{ + REQUIRE(ArrayListIsValid(ArrayList)); + REQUIRE(VALID_FN_REF(Comparator)); + REQUIRE(ItemIndex == NULL || VALID_REF(ItemIndex)); + + LgIndex_t MiddleItemIndex = 0; + LgIndex_t FirstItemIndex = 0; + LgIndex_t NumItems = ArrayListGetCount(ArrayList); + LgIndex_t LastItemIndex = NumItems - 1; + Boolean_t Found = FALSE; + while (FirstItemIndex <= LastItemIndex && !Found) + { + /* calculate the middle item index for current sub-range */ + MiddleItemIndex = (FirstItemIndex + LastItemIndex) / 2; + + int CompareResult = Comparator(ArrayListGetItem(ArrayList, MiddleItemIndex), Item, ClientData); + if (CompareResult > 0) + LastItemIndex = MiddleItemIndex - 1; + else if (CompareResult < 0) + FirstItemIndex = MiddleItemIndex + 1; + else + Found = TRUE; + } + + if (ItemIndex != NULL) + { + if (Found || NumItems == 0 || FirstItemIndex < NumItems) + *ItemIndex = MiddleItemIndex; + else + *ItemIndex = NumItems; /* ...in other words it goes on the end */ + } + + ENSURE(IMPLICATION(ItemIndex != NULL, + 0 <= *ItemIndex && *ItemIndex <= ArrayListGetCount(ArrayList))); + ENSURE(VALID_BOOLEAN(Found)); + return Found; +} + +#if !defined USE_MACROS_FOR_FUNCTIONS +/** + * Gets the array list's internal buffer representation. + * + * WARNING: + * Some array list functions modify the internal buffer. + * This will invalidate this reference however it is + * the client's responsibility not to make further use + * of it. In addition, this reference should never be + * deallocated directly as the array list assumes the + * responsible for the cleanup. + * + * param ArrayList + * Array list for which a reference to the internal + * buffer is desired. + * + * return + * Reference to the array list's internal buffer. + */ +const void *ArrayListGetInternalRef_FUNC(ArrayList_pa ArrayList) +{ + REQUIRE(ArrayListIsValid(ArrayList)); + + const void *Result = ArrayListGetInternalRef_MACRO(ArrayList); + ENSURE(Result == NULL || VALID_REF(Result)); + return Result; +} +#endif diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/auxdata.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/auxdata.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c42b2220461b2fea7dc6c5d7aa44ae16be239684 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/auxdata.cpp @@ -0,0 +1,809 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +#include "stdafx.h" +#include "MASTER.h" +#define TECPLOTENGINEMODULE + +/* + ***************************************************************** + ***************************************************************** + ******* ******** + ****** Copyright (C) 1988-2008 Tecplot, Inc. ******** + ******* All Rights Reserved. ******** + ******* ******** + ***************************************************************** + ***************************************************************** + */ + +#define AUXDATAMODULE +#include "GLOBAL.h" +#include "TASSERT.h" +#include "Q_UNICODE.h" +#include "ALLOC.h" +#include "STRUTIL.h" +#include "ARRLIST.h" +#include "DATASET.h" +#include "STRLIST.h" +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif +#include "SET.h" +#include "AUXDATA.h" + +using namespace tecplot::strutil; + +/** + * Private auxiliary data item structure. + */ +typedef struct +{ + const char *Name; + ArbParam_t Value; + AuxDataType_e Type; + Boolean_t Retain; +} AuxDataItem_s; + +/** + * Private auxiliary data item container structure. + */ +typedef struct _AuxData_s +{ + /* invariant: ItemList is case-insensitive sorted by AuxDataItem->Name */ + ArrayList_pa ItemList; /* <AuxDataItem_s *>[dynamic] */ +} AuxData_s; + +static Mutex_pa AuxDataMutex = NULL; + + +/** + * A valid auxiliary data name character must begin with a '_' or alpha + * character and may be followed by one or more '_', '.', alpha or digit + * characters. + */ +Boolean_t AuxDataIsValidNameChar(char Char, + Boolean_t IsLeadChar) +{ + Boolean_t IsValidNameChar; + + REQUIRE("Char can be any value"); + REQUIRE(VALID_BOOLEAN(IsLeadChar)); + + IsValidNameChar = (Char == '_' || + isalpha(Char)); + if (!IsLeadChar) + IsValidNameChar = (IsValidNameChar || + Char == '.' || + isdigit(Char)); + + ENSURE(VALID_BOOLEAN(IsValidNameChar)); + return IsValidNameChar; +} + +/** + * Indicates if the auxiliary data name is valid. A valid auxiliary data name + * must begin with a '_' or alpha character and may be followed by one or + * more '_', '.', alpha or digit characters. + */ +Boolean_t AuxDataIsValidName(const char *Name) +{ + Boolean_t IsValidName; + const char *NPtr; + REQUIRE(VALID_REF(Name)); + + for (NPtr = Name, IsValidName = AuxDataIsValidNameChar(*NPtr, TRUE); + IsValidName && *NPtr != '\0'; + NPtr++) + { + IsValidName = AuxDataIsValidNameChar(*NPtr, FALSE); + } + + ENSURE(VALID_BOOLEAN(IsValidName)); + return IsValidName; +} + +/** + * Deallocates an auxiliary data item and its contents and sets the target to + * NULL. + * + * param AuxDataItem + * Reference to an auxiliary data item. + */ +static void AuxDataItemDealloc(AuxDataItem_s **AuxDataItem) +{ + REQUIRE(VALID_REF(AuxDataItem)); + REQUIRE(VALID_REF(*AuxDataItem) || *AuxDataItem == NULL); + + if (*AuxDataItem != NULL) + { + char *Name = (char *)(*AuxDataItem)->Name; + if (Name != NULL) + FREE_ARRAY(Name, "auxiliary name"); + + if ((*AuxDataItem)->Type == AuxDataType_String) + { + char *Value = (char *)(*AuxDataItem)->Value; + if (Value != NULL) + FREE_ARRAY(Value, "auxiliary value"); + } + else + CHECK(FALSE); + + FREE_ITEM(*AuxDataItem, "auxiliary data item"); + *AuxDataItem = NULL; + } + + ENSURE(*AuxDataItem == NULL); +} + +/** + * Allocates an auxiliary data item. + * + * NOTE: Copies are made of the name and value. + * + * param Name + * Auxiliary data item's name (case insenstive). + * param Value + * Auxiliary data item's value. + * param Type + * Auxiliary data item's value type. + * param Retain + * Indicates if the auxiliary data item should persist. In other words + * copied, saved, etc. + * + * return + * A new auxiliary data item or NULL if sufficient memory was not + * available. + */ +static AuxDataItem_s *AuxDataItemAlloc(const char *Name, + ArbParam_t Value, + AuxDataType_e Type, + Boolean_t Retain) +{ + AuxDataItem_s *Result; + + REQUIRE(VALID_REF(Name) && AuxDataIsValidName(Name)); + REQUIRE(IMPLICATION(Type == AuxDataType_String, + (VALID_REF((char *)Value) || + (char *)Value == NULL))); + REQUIRE(VALID_ENUM(Type, AuxDataType_e)); + REQUIRE(VALID_BOOLEAN(Retain)); + + Result = ALLOC_ITEM(AuxDataItem_s, "auxiliary data item"); + if (Result != NULL) + { + Boolean_t IsOk; + Result->Type = Type; + Result->Retain = Retain; + Result->Name = DupString(dontTranslate(Name)); + IsOk = (Result->Name != NULL); + Result->Value = 0; /* to satisfy some compilers' uninitialized warnings */ + if (IsOk && Type == AuxDataType_String) + { + char *strValue = (char *)Value; + if (strValue != NULL) + { + char *strCopy = DupString(dontTranslate(strValue)); + Result->Value = (ArbParam_t)strCopy; + IsOk = (strCopy != NULL); + } + else + Result->Value = (ArbParam_t)NULL; + } + else + CHECK(FALSE); + + if (!IsOk) + AuxDataItemDealloc(&Result); + } + + ENSURE(VALID_REF(Result) || Result == NULL); + return Result; +} + +/** + * Destroys an auxiliary data item list item. This is an item destructor + * callback for ArrayList's private data. + * + * param ItemRef + * Reference to the auxiliary data item to cleanup. + * param ClientData + * Not used. + * + * return + * TRUE is a requirement + */ +static Boolean_t AuxDataItemListItemDestructor(void *ItemRef, + ArbParam_t ClientData) +{ + AuxDataItem_s **AuxDataItemRef = (AuxDataItem_s **)ItemRef; + + REQUIRE(VALID_REF(AuxDataItemRef)); + REQUIRE(VALID_REF(*AuxDataItemRef) || *AuxDataItemRef == NULL); + + if (*AuxDataItemRef != NULL) + AuxDataItemDealloc(AuxDataItemRef); + + ENSURE(*AuxDataItemRef == NULL); + return TRUE; +} + +/** + * Destroys an auxiliary data item. This is an item destructor + * callback for ArrayList's private data. + * + * param ItemRef + * Reference to the auxiliary data to cleanup. + * param ClientData + * Not used. + * + * return + * TRUE is a requirement + */ +Boolean_t AuxDataItemDestructor(void *ItemRef, + ArbParam_t ClientData) +{ + AuxData_pa *AuxDataRef = (AuxData_pa *)ItemRef; + + REQUIRE(VALID_REF(AuxDataRef)); + REQUIRE(VALID_REF(*AuxDataRef) || *AuxDataRef == NULL); + + if (*AuxDataRef != NULL) + AuxDataDealloc(AuxDataRef); + + ENSURE(*AuxDataRef == NULL); + return TRUE; +} + + +/** + * Duplicates an auxiliary data item if its Retain flag is TRUE or if directed + * by the callback data. This is an item duplicator callback for ArrayList. + * + * param TargetItemRef + * Reference to the auxiliary data item to receive duplicate. + * param SourceItemRef + * Reference to the auxiliary data item to duplicate. + * param ClientData + * Boolean indicating if the Retain flag should be considered. + * + * return + * TRUE if the duplication was a success + * FALSE otherwise. + */ +static Boolean_t AuxDataItemDuplicator(void *TargetItemRef, + void *SourceItemRef, + ArbParam_t ClientData) +{ + Boolean_t IsOk = TRUE; + AuxDataItem_s **TargetAuxDataItemRef = (AuxDataItem_s **)TargetItemRef; + AuxDataItem_s **SourceAuxDataItemRef = (AuxDataItem_s **)SourceItemRef; + Boolean_t ConsiderRetain; + + REQUIRE(VALID_REF(TargetAuxDataItemRef)); + REQUIRE(VALID_REF(SourceAuxDataItemRef)); + REQUIRE(VALID_REF(*SourceAuxDataItemRef) || *SourceAuxDataItemRef == NULL); + REQUIRE(VALID_BOOLEAN((Boolean_t)ClientData)); + + ConsiderRetain = (Boolean_t)ClientData; + + /* duplicate the item */ + if (*SourceAuxDataItemRef != NULL && + (!ConsiderRetain || (*SourceAuxDataItemRef)->Retain)) + { + *TargetAuxDataItemRef = AuxDataItemAlloc((*SourceAuxDataItemRef)->Name, + (*SourceAuxDataItemRef)->Value, + (*SourceAuxDataItemRef)->Type, + (*SourceAuxDataItemRef)->Retain); + IsOk = (*TargetAuxDataItemRef != NULL); + } + else + *TargetAuxDataItemRef = NULL; + + ENSURE(VALID_REF(*TargetAuxDataItemRef) || *TargetAuxDataItemRef == NULL); + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + +/** + * Deallocates an auxiliary data handle and sets the handle to NULL. + * + * param AuxData + * Reference to an auxiliary data handle or reference to NULL. + */ +void AuxDataDealloc(AuxData_pa *AuxData) +{ + REQUIRE(VALID_REF(AuxData)); + REQUIRE(VALID_REF(*AuxData) || *AuxData == NULL); + + if (*AuxData != NULL) + { + ArrayListDealloc(&(*AuxData)->ItemList, AuxDataItemListItemDestructor, 0); + FREE_ITEM(*AuxData, "auxiliary data container"); + *AuxData = NULL; + } + + ENSURE(*AuxData == NULL); +} + +/** + * Allocates an auxiliary data handle. + * + * return + * Auxiliary data handle or NULL if sufficient memory was not available. + */ +AuxData_pa AuxDataAlloc(void) +{ + AuxData_pa Result = ALLOC_ITEM(AuxData_s, "auxiliary data container"); + if (Result != NULL) + { + Result->ItemList = ArrayListAlloc(0, ArrayListType_VoidPtr, NULL, 0); + if (Result->ItemList == NULL) + AuxDataDealloc(&Result); + } + + ENSURE(VALID_REF(Result) || Result == NULL); + return Result; +} + +/** + * Copies the auxiliary data and all its members who's Retain flag is TRUE + * if the ConsiderRetain flag is TRUE otherwise it copies everything. + */ +AuxData_pa AuxDataCopy(AuxData_pa AuxData, + Boolean_t ConsiderRetain) +{ + AuxData_pa Result; + + REQUIRE(VALID_REF(AuxData)); + REQUIRE(VALID_BOOLEAN(ConsiderRetain)); + + Result = ALLOC_ITEM(AuxData_s, "auxiliary data container"); + if (Result != NULL) + { + Result->ItemList = ArrayListCopy(AuxData->ItemList, + AuxDataItemDuplicator, + ConsiderRetain); + if (Result->ItemList != NULL) + { + if (ConsiderRetain) + { + /* + * Now pass through the array cleaning up the holes left by those + * auxiliary data item member who's Retain flag was FALSE and + * therefore left a VOID pointer because it was not copied. + */ + LgIndex_t ItemOffset = 0; + LgIndex_t ItemCount = ArrayListGetCount(Result->ItemList); + while (ItemOffset < ItemCount) + { + /* if there is more than one in a row remove them all at once */ + if (ArrayListGetVoidPtr(Result->ItemList, ItemOffset) == NULL) + { + LgIndex_t BaseOffsetToRemove = ItemOffset; + LgIndex_t NumItemsToRemove = 1; + while (BaseOffsetToRemove + NumItemsToRemove < ItemCount && + ArrayListGetVoidPtr(Result->ItemList, + BaseOffsetToRemove + NumItemsToRemove) == NULL) + NumItemsToRemove++; + + /* delete the NULL items */ + ArrayListDeleteItems(Result->ItemList, + BaseOffsetToRemove, + NumItemsToRemove, + NULL, 0); + + /* + * Update ItemCount but leave ItemOffset alone as it is now + * indexing the next item to examine. + */ + ItemCount = ArrayListGetCount(Result->ItemList); + } + else + ItemOffset++; + } + } + } + else + AuxDataDealloc(&Result); + } + + ENSURE(VALID_REF(Result) || Result == NULL); + return Result; +} + +/** + * Gets the current number of auxiliary data items maintained by the auxiliary. + * + * param AuxData + * Handle to auxiliary data. + * + * return + * Number of items maintained by the auxiliary data. + */ +LgIndex_t AuxDataGetNumItems(AuxData_pa AuxData) +{ + LgIndex_t NumItems; + + REQUIRE(VALID_REF(AuxData)); + + NumItems = ArrayListGetCount(AuxData->ItemList); + + ENSURE(NumItems >= 0); + return NumItems; +} + +/** + * Gets the item index of the name if found or if not found the index where an + * auxiliary data item could be inserted. + * + * param AuxData + * Handle to auxiliary data. + * param Name + * Name used for the search (case insensitive). + * param ItemIndex + * Address to hold the index of the found item or the index where an + * auxiliary data item could be inserted. + * + * return + * TRUE if the named item was found, + * FALSE otherwise. + */ +Boolean_t AuxDataGetItemIndex(AuxData_pa AuxData, + const char *Name, + LgIndex_t *ItemIndex) +{ + Boolean_t FoundItem = FALSE; + LgIndex_t Index; + LgIndex_t NumItems; + + REQUIRE(VALID_REF(AuxData)); + INVARIANT("AuxData->ItemList is case-insensitive sorted by AuxDataItem->Name"); + REQUIRE(VALID_REF(Name) && AuxDataIsValidName(Name)); + REQUIRE(VALID_REF(ItemIndex)); + + /* + * Note that the current implementation just does a linear search + * though the array looking for the index of the item or if not + * found the index of the insertion point. This should be replaced + * with a binary search. + */ + NumItems = AuxDataGetNumItems(AuxData); + +# if defined DO_LINEAR_SEARCH + { + for (Index = 0; Index < NumItems; Index++) + { + AuxDataItem_s *AuxDataItem = + (AuxDataItem_s *)ArrayListGetVoidPtr(AuxData->ItemList, Index); + int CompareResult = ustrcmp(AuxDataItem->Name, Name); + if (CompareResult >= 0) + { + FoundItem = (CompareResult == 0); + break; + } + } + } +# else + { + int low, high; + low = 0; + high = NumItems - 1; + Index = 0; + while (low <= high) + { + AuxDataItem_s *AuxDataItem; + int CompareResult; + Index = (low + high) / 2; + AuxDataItem = (AuxDataItem_s *)ArrayListGetVoidPtr(AuxData->ItemList, Index); + CompareResult = ustrcmp(Name, AuxDataItem->Name); + if (CompareResult < 0) + high = Index - 1; /* If the new name is "less" than the one we're comparing to, + don't change Index since Index is already in the right spot */ + else if (CompareResult > 0) + low = ++Index; /* If the new name it "greater" than the one we're comparing + against, we want to make sure its Index is greater than + the current name's index as well, that's why we increment Index here. */ + else + { + FoundItem = TRUE; + break; + } + } + } +# endif + + *ItemIndex = Index; + + ENSURE(VALID_BOOLEAN(FoundItem)); + ENSURE(0 <= *ItemIndex && + ((FoundItem && *ItemIndex < NumItems) || + (!FoundItem && *ItemIndex <= NumItems))); + return FoundItem; +} + +/** + * Gets the auxiliary data item at the specified index. + * + * NOTE: The name and value are a references, NOT copies. + * + * param AuxData + * Handle to auxiliary data. + * param Index + * Index of the auxiliary data item of interest. + * param Name + * Address to hold the auxiliary data item name. + * param Value + * Address to hold the auxiliary data item value. + * param Type + * Address to hold the auxiliary data item type. + * param Retain + * Address to hold the auxiliary data item retain flag. + */ +void AuxDataGetItemByIndex(AuxData_pa AuxData, + LgIndex_t Index, + const char **Name, + ArbParam_t *Value, + AuxDataType_e *Type, + Boolean_t *Retain) +{ + AuxDataItem_s *AuxDataItem; + + REQUIRE(VALID_REF(AuxData)); + INVARIANT("AuxData->ItemList is case-insensitive sorted by AuxDataItem->Name"); + REQUIRE(0 <= Index && Index < ArrayListGetCount(AuxData->ItemList)); + REQUIRE(VALID_REF(Name)); + REQUIRE(VALID_REF(Value)); + REQUIRE(VALID_REF(Type)); + REQUIRE(VALID_REF(Retain)); + + AuxDataItem = (AuxDataItem_s *)ArrayListGetVoidPtr(AuxData->ItemList, Index); + *Name = AuxDataItem->Name; + *Value = AuxDataItem->Value; + *Type = AuxDataItem->Type; + *Retain = AuxDataItem->Retain; + + ENSURE(VALID_REF(*Name) && AuxDataIsValidName(*Name)); + ENSURE(IMPLICATION(*Type == AuxDataType_String, + (VALID_REF((char *)(*Value)) || + (char *)(*Value) == NULL))); + ENSURE(VALID_ENUM(*Type, AuxDataType_e)); + ENSURE(VALID_BOOLEAN(*Retain)); +} + +/** + * Gets the auxiliary data item by the specified name if it exists. + * + * NOTE: The name and value are a references, NOT copies. + * + * param AuxData + * Handle to auxiliary data. + * param Name + * Name used for the search (case insensitive). + * param Value + * Address to hold the auxiliary data item value. + * param Type + * Address to hold the auxiliary data item type. + * param Retain + * Address to hold the auxiliary data item retain flag. + * + * return + * TRUE if the an auxilary data item by the specified name was found, + * FALSE otherwise. + */ +Boolean_t AuxDataGetItemByName(AuxData_pa AuxData, + const char *Name, + ArbParam_t *Value, + AuxDataType_e *Type, + Boolean_t *Retain) +{ + Boolean_t FoundItem; + LgIndex_t ItemIndex; + + REQUIRE(VALID_REF(AuxData)); + INVARIANT("AuxData->ItemList is case-insensitive sorted by AuxDataItem->Name"); + REQUIRE(VALID_REF(Name) && AuxDataIsValidName(Name)); + REQUIRE(VALID_REF(Value)); + REQUIRE(VALID_REF(Type)); + REQUIRE(VALID_REF(Retain)); + + FoundItem = AuxDataGetItemIndex(AuxData, Name, &ItemIndex); + if (FoundItem) + { + const char *SameName; + AuxDataGetItemByIndex(AuxData, ItemIndex, &SameName, + Value, Type, Retain); + CHECK(ustrcmp(Name, SameName) == 0); + } + + ENSURE(VALID_BOOLEAN(FoundItem)); + ENSURE(IMPLICATION(FoundItem, + IMPLICATION(*Type == AuxDataType_String, + (VALID_REF((char *)(*Value)) || + (char *)(*Value) == NULL)))); + ENSURE(IMPLICATION(FoundItem, + VALID_ENUM(*Type, AuxDataType_e))); + ENSURE(IMPLICATION(FoundItem, + VALID_BOOLEAN(*Retain))); + return FoundItem; +} + + +/** + * Get a string value from AuxData and convert it to a boolean. + */ +Boolean_t AuxDataGetBooleanItemByName(AuxData_pa AuxData, /* IN */ + const char *Name, /* IN */ + Boolean_t *Value, /* OUT */ + AuxDataType_e *Type, /* OUT */ + Boolean_t *Retain) /* OUT */ +{ + Boolean_t FoundItem; + + REQUIRE(VALID_REF(AuxData)); + INVARIANT("AuxData->ItemList is case-insensitive sorted by AuxDataItem->Name"); + REQUIRE(VALID_REF(Name) && AuxDataIsValidName(Name)); + REQUIRE(VALID_REF(Value)); + REQUIRE(VALID_REF(Type)); + REQUIRE(VALID_REF(Retain)); + + ArbParam_t strValue; + FoundItem = AuxDataGetItemByName(AuxData, + Name, + &strValue, + Type, + Retain); + + if (FoundItem && + (ustrcmp((char *)strValue, "YES") == 0 || + ustrcmp((char *)strValue, "YEP") == 0 || + ustrcmp((char *)strValue, "Y") == 0 || + ustrcmp((char *)strValue, "TRUE") == 0 || + ustrcmp((char *)strValue, "T") == 0 || + ustrcmp((char *)strValue, "ON") == 0 || + ustrcmp((char *)strValue, "1") == 0)) + { + *Value = TRUE; + } + else + { + *Value = FALSE; + } + + ENSURE(VALID_BOOLEAN(FoundItem)); + ENSURE(VALID_BOOLEAN(*Value)); + return FoundItem; +} + + +/** + * Adds the auxiliary data item to the auxiliary data or replaces it if one + * already exists by the same name. + * + * NOTE: The auxiliary data makes copies of the name and value. + * + * param AuxData + * Auxiliary data handle. + * param Name + * Auxiliary data item's name (case insenstive). + * param Value + * Auxiliary data item's value. + * param Type + * Auxiliary data item's value type. + * param Retain + * Indicates if the auxiliary data item should persist. + * + * return + * TRUE if the item was added to the auxiliary data. + */ +Boolean_t AuxDataSetItem(AuxData_pa AuxData, + const char *Name, + ArbParam_t Value, + AuxDataType_e Type, + Boolean_t Retain) +{ + Boolean_t IsOk; + AuxDataItem_s *AuxDataItem; + + REQUIRE(VALID_REF(AuxData)); + INVARIANT("AuxData->ItemList is case-insensitive sorted by AuxDataItem->Name"); + REQUIRE(VALID_REF(Name) && AuxDataIsValidName(Name)); + REQUIRE(IMPLICATION(Type == AuxDataType_String, + (VALID_REF((char *)Value) || + (char *)Value == NULL))); + REQUIRE(VALID_ENUM(Type, AuxDataType_e)); + REQUIRE(VALID_BOOLEAN(Retain)); + + AuxDataItem = AuxDataItemAlloc(Name, Value, Type, Retain); + IsOk = (AuxDataItem != NULL); + if (IsOk) + { + LgIndex_t ItemIndex; + ArrayListItem_u ListItem; + + /* add or replace the item to the list */ + ListItem.VoidPtr = (void *)AuxDataItem; + if (!AuxDataGetItemIndex(AuxData, Name, &ItemIndex)) + IsOk = ArrayListInsertItem(AuxData->ItemList, ItemIndex, ListItem); + else + IsOk = ArrayListSetItem(AuxData->ItemList, ItemIndex, ListItem, + AuxDataItemListItemDestructor, 0); + + if (!IsOk) + AuxDataItemDealloc(&AuxDataItem); + } + + ENSURE(VALID_BOOLEAN(IsOk)); + INVARIANT("AuxData->ItemList is case-insensitive sorted by AuxDataItem->Name"); + return IsOk; +} + +/** + * Deletes the auxiliary data item at the specified index. + * + * param AuxData + * Auxiliary data handle. + * param Index + * Index of the auxiliary data item of interest. + */ +void AuxDataDeleteItemByIndex(AuxData_pa AuxData, + LgIndex_t Index) +{ + REQUIRE(VALID_REF(AuxData)); + REQUIRE(0 <= Index && Index < ArrayListGetCount(AuxData->ItemList)); + + ArrayListDeleteItem(AuxData->ItemList, Index, AuxDataItemListItemDestructor, 0); +} + +/** + * Deletes the auxiliary data item by the specified name if it exists. + * + * param AuxData + * Auxiliary data handle. + * param Name + * Name used for the search (case insensitive). + * + * return + * TRUE if the an auxilary data item by the specified name was found, + * FALSE otherwise. + */ +Boolean_t AuxDataDeleteItemByName(AuxData_pa AuxData, + const char *Name) +{ + Boolean_t FoundItem; + LgIndex_t ItemIndex; + + REQUIRE(VALID_REF(AuxData)); + REQUIRE(VALID_REF(Name) && AuxDataIsValidName(Name)); + + FoundItem = AuxDataGetItemIndex(AuxData, Name, &ItemIndex); + if (FoundItem) + AuxDataDeleteItemByIndex(AuxData, ItemIndex); + + ENSURE(VALID_BOOLEAN(FoundItem)); + return FoundItem; +} + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif /* TECPLOTKERNEL */ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/dataio.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/dataio.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a88c7c1f43206df6cf82964f035df35a9bf611ac --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/dataio.cpp @@ -0,0 +1,695 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +#include "stdafx.h" +#include "MASTER.h" +#define TECPLOTENGINEMODULE + +/* +****************************************************************** +****************************************************************** +******* ******** +****** (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +****************************************************************** +****************************************************************** +*/ + +#define DATAIOMODULE +#include "GLOBAL.h" +#include "TASSERT.h" +#include "Q_UNICODE.h" +#include "TranslatedString.h" + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#else +#ifdef MSWIN +/* Disable warning about conversion from long to short. + Even if we have disabled it in stdafx.h, + we still need to disable here also for + tecio, which includes this cpp file. */ + +#pragma warning (disable : 4244) +#endif +/* + * Temp text and geom buffers. + */ +static Geom_s TempGeom; +static Text_s TempText; +#endif + +#include "DATASET0.h" +#include "SET.h" +#include "FILESTREAM.h" +#include "DATAIO.h" +#include "DATAIO4.h" +#include "STRUTIL.h" +#include "AUXDATA.h" +#include "ARRLIST.h" +#include "STRLIST.h" +#include "ALLOC.h" +#include "DATASET.h" +#include "SYSTEM.h" +#include "Q_MSG.h" + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif +using namespace tecplot::strutil; + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if !defined ENGINE +#endif +#if !defined ENGINE /* TODO(RMS)-M 12/13/2005: ENGINE-P2 - no status feedback */ +#endif +#endif /* TECPLOTKERNEL */ + + +/* + * Multi-Purpose datafile header reader. This is designed so that + * not all parts of the header is loaded and so that the task of loading + * the header information is separated out from installing of that + * information into a dataset. + * + */ + +Boolean_t ReadDataFileHeader(FileStream_s *FileStream, + short IVersion, + Boolean_t ShowDataIOStatus, + EntIndex_t *NumZones, + EntIndex_t *NumVars, + SmInteger_t *NumCustomLabelSets, + char **DataSetTitle, + Text_s **BaseText, + Geom_s **BaseGeom, + StringList_pa **CustomLabelBase, + StringList_pa *UserRec, + AuxData_pa *DataSetAuxData, + Set_pa **IsVarCellCentered, /* Create an Array dim by zones */ + Boolean_t *HasText, + Boolean_t *HasGeoms, + ArrayList_pa *ZoneSpecList, + StringList_pa *VarNames, + ArrayList_pa *VarAuxDataList, /*<AuxData_pa>[NumVars]*/ + Set_pa *IsRawFNAvailable, /* classic data only */ + LgIndex_t **FNNumBndryConns, /* classic data only */ + DataFileType_e *FileType) +{ + Boolean_t IsOk = TRUE; + Boolean_t SentError = FALSE; + double X1; + int Pass; + FileOffset_t InitialFilePosition; + + REQUIRE(VALID_REF(FileStream) && VALID_REF(FileStream->File)); + REQUIRE(IVersion > 0); + REQUIRE(VALID_BOOLEAN(ShowDataIOStatus)); + REQUIRE(VALID_REF(NumZones)); + REQUIRE(VALID_REF(NumVars)); + REQUIRE(VALID_REF(DataSetTitle) || (DataSetTitle == NULL)); + REQUIRE(VALID_REF(BaseText) || (BaseText == NULL)); + REQUIRE(VALID_REF(BaseGeom) || (BaseGeom == NULL)); + REQUIRE(VALID_REF(HasText) || (HasText == NULL)); + REQUIRE(VALID_REF(HasGeoms) || (HasGeoms == NULL)); + REQUIRE(VALID_REF(ZoneSpecList) || (ZoneSpecList == NULL)); + REQUIRE(VALID_REF(VarNames) || (VarNames == NULL)); + REQUIRE(VALID_REF(NumCustomLabelSets) || (NumCustomLabelSets == NULL)); + REQUIRE(VALID_REF(UserRec) || (UserRec == NULL)); + REQUIRE((VALID_REF(DataSetAuxData) && + (VALID_REF(*DataSetAuxData) || *DataSetAuxData == NULL)) || + DataSetAuxData == NULL); + REQUIRE((VALID_REF(VarAuxDataList) && + (VALID_REF(*VarAuxDataList) || *VarAuxDataList == NULL)) || + VarAuxDataList == NULL); + REQUIRE(VALID_REF(IsVarCellCentered) || (IsVarCellCentered == NULL)); + REQUIRE((VALID_REF(CustomLabelBase) && VALID_REF(NumCustomLabelSets)) || (CustomLabelBase == NULL)); + REQUIRE(VALID_REF(IsRawFNAvailable) || (IsRawFNAvailable == NULL)); + REQUIRE(VALID_REF(FNNumBndryConns) || (FNNumBndryConns == NULL)); + REQUIRE(VALID_REF(FileType) || (FileType == NULL)); + + if (DataSetTitle) + *DataSetTitle = NULL; + if (BaseText) + *BaseText = NULL; + if (BaseGeom) + *BaseGeom = NULL; + if (HasText) + *HasText = FALSE; + if (HasGeoms) + *HasGeoms = FALSE; + if (ZoneSpecList) + *ZoneSpecList = NULL; + if (VarNames) + *VarNames = NULL; + if (NumCustomLabelSets) + *NumCustomLabelSets = 0; + if (CustomLabelBase) + *CustomLabelBase = NULL; + if (DataSetAuxData != NULL) + { + /* + * Note unlike most of the other output only parameters that we nullify, + * DataSetAuxData is both an input and output parameter therefore we do + * not nullify it. The CHECK is here for clarity. + */ + CHECK(VALID_REF(*DataSetAuxData) || *DataSetAuxData == NULL); + } + if (VarAuxDataList != NULL) + { + /* + * Note unlike most of the other output only parameters that we nullify, + * VarAuxDataList is both an input and output parameter therefore we do + * not nullify it. The CHECK is here for clarity. + */ + CHECK(VALID_REF(*VarAuxDataList) || *VarAuxDataList == NULL); + } + if (UserRec) + *UserRec = NULL; + if (IsVarCellCentered) + *IsVarCellCentered = NULL; + + if (IsRawFNAvailable) + *IsRawFNAvailable = NULL; + + if (FNNumBndryConns) + *FNNumBndryConns = NULL; + + if (FileType) + *FileType = DataFileType_Full; + + /* + * Pass 1 is used only to count up the number of zones and custom label sets, + * Also determine if there are any preset zone colors. + */ + + InitialFilePosition = TP_FTELL(FileStream->File); + + for (Pass = 1; IsOk && (Pass <= 2); Pass++) + { + if (Pass == 2) + { + if (TP_FSEEK(FileStream->File, InitialFilePosition, SEEK_SET) != 0) + IsOk = FALSE; + + if (IsOk && (*NumZones > 0 && ZoneSpecList != NULL && *ZoneSpecList == NULL)) + { + *ZoneSpecList = ArrayListAlloc(*NumZones, ArrayListType_VoidPtr, + ZoneOrVarListAdjustCapacityRequest, 0); + IsOk = (*ZoneSpecList != NULL); + } + if (IsOk && (CustomLabelBase != NULL && + *CustomLabelBase == NULL && + *NumCustomLabelSets > 0)) + { + *CustomLabelBase = ALLOC_ARRAY(*NumCustomLabelSets, StringList_pa, "CustomLabel Sets"); + IsOk = (*CustomLabelBase != NULL); + if (IsOk) + { + SmInteger_t N; + for (N = 0; N < *NumCustomLabelSets; N++) + (*CustomLabelBase)[N] = NULL; + } + } + if (IsOk && (UserRec != NULL && *UserRec == NULL)) + { + *UserRec = StringListAlloc(); + IsOk = (Boolean_t)(*UserRec != NULL); + } + if (IsOk && (DataSetAuxData != NULL && *DataSetAuxData == NULL)) + { + *DataSetAuxData = AuxDataAlloc(); + IsOk = (Boolean_t)(*DataSetAuxData != NULL); + } + if (IsOk && (VarAuxDataList != NULL && *VarAuxDataList == NULL) && *NumVars > 0) + { + *VarAuxDataList = ArrayListAlloc(0, ArrayListType_VoidPtr, + ZoneOrVarListAdjustCapacityRequest, 0); + IsOk = (*VarAuxDataList != NULL && + ArrayListSetVoidPtr(*VarAuxDataList, *NumVars - 1, NULL)); + } + if (IsOk && + (*NumZones > 0) && + (IsVarCellCentered != NULL) && + (*IsVarCellCentered == NULL)) + { + /* + * First construct the array of sets... + */ + *IsVarCellCentered = ALLOC_ARRAY(*NumZones, Set_pa, "Array of IsVarCellCentered sets"); + if (*IsVarCellCentered) + { + EntIndex_t Z; + for (Z = 0; IsOk && (Z < *NumZones); Z++) + { + /* + * Now allocate a set for each zone + */ + (*IsVarCellCentered)[Z] = AllocSet(FALSE); + IsOk = (Boolean_t)((*IsVarCellCentered)[Z] != NULL); + } + } + else + IsOk = FALSE; + } + if (IsOk && *NumZones > 0 && IsRawFNAvailable != NULL) + { + *IsRawFNAvailable = AllocSet(FALSE); + IsOk = (*IsRawFNAvailable != NULL); + } + if (IsOk && *NumZones > 0 && FNNumBndryConns != NULL) + { + *FNNumBndryConns = ALLOC_ARRAY(*NumZones, LgIndex_t, "Array of FNNumBndryConns"); + IsOk = (*FNNumBndryConns != NULL); + if (IsOk) + for (LgIndex_t i = 0; i < *NumZones; i++) + (*FNNumBndryConns)[i] = 0; + } + } + + if (NumCustomLabelSets != NULL) + *NumCustomLabelSets = 0; + + EntIndex_t TotalNumZones = *NumZones; /* ...only meaningful for pass 2 */ + + *NumZones = 0; + *NumVars = 0; + + if (IsOk) + { + char *S = NULL; + int INumVars; + + IsOk = ReadInDataFileTypeTitleAndVarNames(FileStream, + IVersion, + ((Pass == 2) ? &S : (char **)NULL), + ((Pass == 2) ? FileType : (DataFileType_e *)NULL), + &INumVars, + ((Pass == 2) ? VarNames : (StringList_pa *)NULL)); + + if (IsOk) + *NumVars = (EntIndex_t)INumVars; + + if ((Pass == 2) && S && IsOk && DataSetTitle) + *DataSetTitle = S; + else if (S != NULL) + FREE_ARRAY(S, "data set title"); + } + + if (IsOk) + { +#if !defined ENGINE /* TODO(RMS)-M 12/13/2005: ENGINE-P2 - no dialog feedback */ + LgIndex_t NumGeoms = 0; + LgIndex_t NumTexts = 0; +#endif + + if (IsOk) + X1 = GetNextValue(FileStream, FieldDataType_Float, 0.0, 1000.0, &IsOk); + + while (IsOk && (X1 != EndHeaderMarker)) + { + if (X1 == ZoneMarker) + { + ZoneSpec_s *ZoneSpec = ZoneSpecAlloc(); + Boolean_t OkToLoad = (Pass == 2 && + IsVarCellCentered != NULL); + IsOk = (ZoneSpec != NULL); + if (IsOk) + { + Boolean_t LocalIsRawFNAvailable; + LgIndex_t LocalFNNumBndryConns; + IsOk = ReadInZoneHeader(FileStream, IVersion, ZoneSpec, + OkToLoad ? (*IsVarCellCentered)[*NumZones] : NULL, + *NumVars, &LocalIsRawFNAvailable, + &LocalFNNumBndryConns); + if (IsOk && OkToLoad && IsRawFNAvailable != NULL) + { + if (LocalIsRawFNAvailable) + IsOk = AddToSet(*IsRawFNAvailable, *NumZones, FALSE); + } + if (IsOk && OkToLoad && FNNumBndryConns != NULL) + (*FNNumBndryConns)[*NumZones] = LocalFNNumBndryConns; + } + + if (IsOk && + ZoneSpecList != NULL && + Pass == 2) + { + IsOk = (ZoneSpec->ParentZone == BAD_SET_VALUE || + (ZoneSpec->ParentZone != *NumZones && + (0 <= ZoneSpec->ParentZone && ZoneSpec->ParentZone < TotalNumZones))); + if (IsOk) + { + ArrayListItem_u CurZoneSpecItem; + CurZoneSpecItem.VoidPtr = (void *)ZoneSpec; + ArrayListSetItem(*ZoneSpecList, *NumZones, + CurZoneSpecItem, + ZoneSpecItemDestructor, 0); + } + else + { + if (ZoneSpec->ParentZone == *NumZones) + ErrMsg(translate("Parent zone assignment for zone %d " + "may not be self referencing."), + *NumZones + 1); + else + ErrMsg(translate("Parent zone assignment for zone %d " + "must be to an existing zone within the datafile."), + *NumZones + 1); + ZoneSpecDealloc(&ZoneSpec); + SentError = TRUE; + } + } + else + ZoneSpecDealloc(&ZoneSpec); + + if (IsOk) + (*NumZones)++; + if (*NumZones > MaxNumZonesOrVars) + { + ErrMsg(translate("Exceeding Tecplot's current zone limit of %d. " + "Reduce the number of zones being loaded."), MaxNumZonesOrVars); + IsOk = FALSE; + SentError = TRUE; + } + } + else if (X1 == GeomMarker) + { +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#else + IsOk = ReadInGeometry(FileStream, + IVersion, + FALSE, + &TempGeom, + 5000); +#endif + if (IsOk) + { + if (Pass == 1) + { + if (HasGeoms) + *HasGeoms = TRUE; + } +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + } +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if !defined ENGINE /* TODO(RMS)-M 12/13/2005: ENGINE-P2 - no status feedback */ +#endif +#endif + } + else if (X1 == TextMarker) + { +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#else + IsOk = ReadInText(FileStream, + IVersion, + FALSE, + &TempText, + 200); +#endif + if (IsOk) + { + if (Pass == 1) + { + if (HasText) + *HasText = TRUE; + } +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + } +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if !defined ENGINE /* TODO(RMS)-M 12/13/2005: ENGINE-P2 - no status feedback */ +#endif +#endif + } + else if (X1 == CustomLabelMarker) + { + Boolean_t OkToLoad; + + OkToLoad = (Pass == 2) && + NumCustomLabelSets && + (*NumCustomLabelSets < MaxCustomLabelSets) && + CustomLabelBase; + + IsOk = ReadInCustomLabels(FileStream, + IVersion, + OkToLoad, + (OkToLoad ? &(*CustomLabelBase)[*NumCustomLabelSets] : NULL)); + if (IsOk && NumCustomLabelSets) + (*NumCustomLabelSets)++; + } + else if (X1 == UserRecMarker) + { + Boolean_t OkToLoad; + char *CurUserRec = NULL; + + OkToLoad = (Boolean_t)((Pass == 2) && UserRec); + + IsOk = ReadInUserRec(FileStream, + IVersion, + 500, + OkToLoad ? &CurUserRec : (char **)NULL); + if (IsOk && OkToLoad) + IsOk = StringListAppendString(*UserRec, CurUserRec); + if (CurUserRec) + FREE_ARRAY(CurUserRec, "temp user rec"); + CurUserRec = NULL; + } + else if (X1 == DataSetAuxMarker) + { + Boolean_t OkToLoad; + CHECK(IVersion >= 101); + OkToLoad = (Pass == 2 && + DataSetAuxData != NULL); + IsOk = ReadInAuxData(FileStream, IVersion, + OkToLoad ? *DataSetAuxData : NULL); + if (!IsOk) + { + ErrMsg(translate("Invalid DATASETAUXDATA record in binary datafile")); + SentError = TRUE; + } + } + else if (X1 == VarAuxMarker) + { + Boolean_t OkToLoad; + LgIndex_t VarNum; + CHECK(IVersion >= 102); + OkToLoad = (Pass == 2 && + VarAuxDataList != NULL); + VarNum = GetIoFileInt(FileStream, IVersion, 0, *NumVars - 1, &IsOk); + if (IsOk) + { + AuxData_pa VarAuxData; + if (OkToLoad) + { + VarAuxData = (AuxData_pa)ArrayListGetVoidPtr(*VarAuxDataList, VarNum); + if (VarAuxData == NULL) + { + VarAuxData = AuxDataAlloc(); + IsOk = (VarAuxData != NULL && + ArrayListSetVoidPtr(*VarAuxDataList, VarNum, VarAuxData)); + } + } + else + VarAuxData = NULL; + + IsOk = IsOk && ReadInAuxData(FileStream, IVersion, VarAuxData); + if (!IsOk) + { + ErrMsg(translate("Invalid VARAUXDATA record in binary datafile")); + SentError = TRUE; + } + } + else + { + ErrMsg(translate("Invalid VARAUXDATA variable number association")); + SentError = TRUE; + } + } + else + IsOk = FALSE; + if (IsOk) + X1 = GetNextValue(FileStream, FieldDataType_Float, 0.0, 1000.0, &IsOk); + } + } + } + + /* + * Old plt files that did not contain data still contained variable name + * definitions in the header. This is no longer necessary and in fact can + * cause confusion in the data read options dialog. If the number of zones + * in the datafile is zero set the number of variables to 0 and dealloc the + * variable name list. + */ + + if (IsOk && (*NumZones == 0) && (*NumVars > 0)) + { + *NumVars = 0; + if (VarNames && *VarNames) + { + StringListDealloc(VarNames); + } + } + + + if (!IsOk) + { + if (ZoneSpecList && *ZoneSpecList) + ArrayListDealloc(ZoneSpecList, ZoneSpecItemDestructor, 0); + if (DataSetTitle && *DataSetTitle) + { + FREE_ARRAY(*DataSetTitle, "DataSetTitle"); + *DataSetTitle = NULL; + } +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + if (VarNames && *VarNames) + { + StringListDealloc(VarNames); + } +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + if (UserRec && *UserRec) + StringListDealloc(UserRec); + } + + /* If there was an error, get rid of the auxiliary data list. */ + if ((DataSetAuxData != NULL && *DataSetAuxData != NULL) && + (!IsOk)) + AuxDataDealloc(DataSetAuxData); + + if (!IsOk && !SentError) + ErrMsg(translate("Invalid header in binary datafile")); + + /* + * NOTE: Do not close the file. Some calling functions will continue + * to read from this point on. + */ + + ENSURE((VarNames == NULL) || (*VarNames == NULL) || StringListValid(*VarNames)); + ENSURE(IMPLICATION(UserRec != NULL, + (*UserRec == NULL || + StringListValid(*UserRec)))); + ENSURE(IMPLICATION(DataSetAuxData != NULL, + (*DataSetAuxData == NULL || + VALID_REF(*DataSetAuxData)))); + return (IsOk); +} + + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif /* TECPLOTKERNEL */ + + +Boolean_t OpenBinaryFileAndCheckMagicNumber(FileStream_s **FileStream, + char *FName, + FileOffset_t StartOffset, + short *IVersion) +{ + Boolean_t Result = TRUE; + REQUIRE(VALID_REF(FileStream)); + REQUIRE(*FileStream == NULL); + REQUIRE(VALID_REF(FName)); + REQUIRE(StartOffset >= 0); + REQUIRE(VALID_REF(IVersion)); + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#else + FILE *File = TP_FOPEN(FName, "rb"); + if (File == NULL) + Result = FALSE; +#endif + if (Result) + { + *FileStream = FileStreamAlloc(File, TRUE); + Result = (*FileStream != NULL); + } + Result = Result && (TP_FSEEK((*FileStream)->File, StartOffset, SEEK_SET) == 0); + if (Result) + { + *IVersion = GetInputVersion(*FileStream); + /* + * After version 71 we started listing individual valid + * versions. Before that time we just listed ranges. Also, + * note that versions 72, 73, and 74 were invalid. + */ + Result = (/* past valid plt file version ranges follow: */ + (40 <= *IVersion && *IVersion <= 71) || + (*IVersion == 75) || + (100 <= *IVersion && *IVersion <= TecplotBinaryFileVersion)); + + /* + * This check is put here to make sure that the above code gets visited + * when the TecplotBinaryFileVersion number changes. When the version + * changes the "past valid plt file version ranges" above and the number + * compared to the TecplotBinaryFileVersion below may need to be + * adjusted such as when we skip a consecutive number as we did between + * version 71 and 75, and between 75 and 100. + */ + CHECK(TecplotBinaryFileVersion == 112); + } + + ENSURE(VALID_BOOLEAN(Result)); + return (Result); +} + + + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ + #if !defined NO_ASSERTS + #endif + #if !defined NO_ASSERTS + #endif +#if !defined ENGINE /* TODO(RMS)-M 12/13/2005: ENGINE-P2 - no status feedback */ +#endif +#if !defined ENGINE /* TODO(RMS)-M 12/13/2005: ENGINE-P2 - no status feedback */ +#endif +#if !defined ENGINE /* TODO(RMS)-M 12/13/2005: ENGINE-P2 - no status feedback */ +#endif +#if !defined ENGINE /* TODO(RMS)-M 12/13/2005: ENGINE-P2 - no status feedback */ +#endif +#if !defined ENGINE /* TODO(RMS)-M 12/13/2005: ENGINE-P2 - no status feedback */ +#endif +#if !defined ENGINE /* TODO(RMS)-M 12/13/2005: ENGINE-P2 - no status feedback */ +#endif +#if !defined ENGINE /* TODO(RMS)-H 12/12/2005: ENGINE: refactor to use just the Interrupted flag as-is */ +#else +#endif +#if 0 /* we changed this behavior... not sure when */ +#endif +#endif /* TECPLOTKERNEL */ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/dataio4.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/dataio4.cpp new file mode 100644 index 0000000000000000000000000000000000000000..18374dfe7b0392a91053711db2b247180e453772 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/dataio4.cpp @@ -0,0 +1,3357 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +#include "stdafx.h" +#include "MASTER.h" +#define TECPLOTENGINEMODULE + +/* +****************************************************************** +****************************************************************** +******* ******** +****** (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +****************************************************************** +****************************************************************** +*/ + +#define DATAIO4MODULE +#include "GLOBAL.h" +#include "TASSERT.h" +#include "Q_UNICODE.h" +#include "ALLOC.h" + +#include "AUXDATA.h" +#include "DATASET.h" +#include "FILESTREAM.h" + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#include "GEOM2.h" +#include "GEOM.h" +#include "INPUT.h" +#include "SET.h" +#include "TEXT.h" +#include "DATAIO4.h" +#include "DATASET0.h" + +#include "STRUTIL.h" +#include "ARRLIST.h" +#include "STRLIST.h" +#include "Q_MSG.h" + +#if defined IRIS +#include <ieeefp.h> +#endif + +using namespace tecplot::strutil; + +#if !defined(TECPLOTKERNEL) && defined(MSWIN) +# pragma warning(disable : 4244) +#endif + +/*END HEADER*/ + +/* + * This module contains mostly low level i/o functions. + */ + +#if defined DECALPHA || defined COMPAQALPHA +#define _IEEE_FP_INEXACT +#define _IEEE_FP +#endif + +#if defined SUN41 +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +/********************************************************************** + ********************************************************************** + ********************** INPUT ************************** + ********************************************************************** + **********************************************************************/ + +static char FilterFloatChar(float X) +{ + char C; + if (((X >= 32.0) && (X <= 127.0)) || + ((X >= 160.0) && (X <= 255.0)) || + (X == 0.0)) + C = (char)X; + else + C = '?'; + return (C); +} + + +double GetNextValue(FileStream_s *FileStream, + FieldDataType_e FieldDataType, + double VMin, + double VMax, + Boolean_t *IsOk) +{ + double X = 0.0; + + REQUIRE(VALID_REF(IsOk) && VALID_BOOLEAN(*IsOk)); + REQUIRE(!(*IsOk) || VALID_FIELD_DATA_TYPE(FieldDataType)); + REQUIRE(!(*IsOk) || VALID_REF(FileStream)); + + if (*IsOk) + { + switch (FieldDataType) + { + case FieldDataType_Float : + { + float XX; + + *IsOk = (TP_FREAD(&XX, 4, 1, FileStream->File) == 1); + + if (!FileStream->IsByteOrderNative) + REVERSE_4_BYTES(&XX); + + if (*IsOk) + X = XX; + else + X = 0.0; + } break; + case FieldDataType_Double : + { + double XX; + + *IsOk = (TP_FREAD(&XX, sizeof(double), 1, FileStream->File) == 1); + if (!FileStream->IsByteOrderNative) + REVERSE_8_BYTES(&XX); + + if (*IsOk) + X = XX; + else + X = 0.0; + } break; + case FieldDataType_Int32 : + { + Int32_t L; + *IsOk = (TP_FREAD(&L, sizeof(Int32_t), 1, FileStream->File) == 1); + if (!FileStream->IsByteOrderNative) + REVERSE_4_BYTES(&L); + if (*IsOk) + X = (double)L; + } break; + case FieldDataType_Int16 : + { + Int16_t S; + *IsOk = (TP_FREAD(&S, sizeof(Int16_t), 1, FileStream->File) == 1); + if (!FileStream->IsByteOrderNative) + REVERSE_2_BYTES(&S); + if (*IsOk) + X = (double)S; + } break; + case FieldDataType_Byte : + { + Byte_t B; + *IsOk = (TP_FREAD(&B, sizeof(Byte_t), 1, FileStream->File) == 1); + if (*IsOk) + X = (double)B; + } break; + case FieldDataType_Bit : + { + /* + * Important note: + * Reading bit data a value at a time is only valid for a + * single bit value. If the file contains a block of more than + * one bit value and you attempt to read it a bit at a time it + * will not work as Tecplot does not buffer the read. In order + * to read a block of bits you must perform a block read. + */ + Byte_t B; + *IsOk = (TP_FREAD(&B, sizeof(Byte_t), 1, FileStream->File) == 1); + if (*IsOk) + X = (double)(B & (Byte_t)01); + } break; + default: CHECK(FALSE); break; + } + + if (*IsOk) + { + if ((X < VMin) || (X > VMax)) + { + *IsOk = FALSE; + } + } + } + + return X; +} + + +LgIndex_t GetNextI(FileStream_s *FileStream, + Boolean_t *IsOk) +{ + LgIndex_t I = 0; + + REQUIRE(VALID_REF(IsOk) && VALID_BOOLEAN(*IsOk)); + REQUIRE(!(*IsOk) || (VALID_REF(FileStream) && VALID_REF(FileStream->File))); + + if (*IsOk) + { + Int32_t Int32Val; + *IsOk = (TP_FREAD((void *) & Int32Val, 4, 1, FileStream->File) == 1); + if (!FileStream->IsByteOrderNative) + REVERSE_4_BYTES(&Int32Val); + + I = Int32Val; + } + return I; +} + + +LgIndex_t GetIoFileInt(FileStream_s *FileStream, + short Version, + LgIndex_t IMin, + LgIndex_t IMax, + Boolean_t *IsOk) +{ + LgIndex_t I = 0; + + REQUIRE(VALID_REF(IsOk) && VALID_BOOLEAN(*IsOk)); + REQUIRE(!(*IsOk) || (0 < Version && Version <= TecplotBinaryFileVersion)); + REQUIRE(!(*IsOk) || (VALID_REF(FileStream) && VALID_REF(FileStream->File))); + REQUIRE(!(*IsOk) || IMin <= IMax); + + if (!(*IsOk)) + return (0); + + if (Version <= 63) + { + float X; + if (*IsOk) + { + X = (float)GetNextValue(FileStream, FieldDataType_Float, + (double)IMin - 1.0e-10, + (double)IMax + 1.0e-10, IsOk); + if (*IsOk) + { + if (ABS(X) < (float)MAXINDEX) + I = (LgIndex_t)X; + else + *IsOk = FALSE; + } + else + *IsOk = FALSE; + } + } + else + { + I = GetNextI(FileStream, IsOk); + } + + if ((I < IMin) || (I > IMax)) + *IsOk = FALSE; + + return (I); +} + +/** + * Basically this is "realloc" but apparently "realloc" doesn't behave reliably + * on all platforms. + */ +static Boolean_t ReallocString(char **String, + LgIndex_t NewLength) +{ + Boolean_t IsOk; + char *NewString; + + REQUIRE(VALID_REF(String)); + REQUIRE(*String == NULL || VALID_REF(*String)); + REQUIRE((*String != NULL && NewLength >= (LgIndex_t)strlen(*String)) || + (*String == NULL && NewLength >= 0)); + + NewString = ALLOC_ARRAY(NewLength + 1, char, "reallocated string"); + IsOk = (NewString != NULL); + if (IsOk) + { + if (*String == NULL) + { + NewString[0] = '\0'; + } + else + { + strcpy(NewString, *String); + FREE_ARRAY(*String, "old string"); + } + *String = NewString; + } + + ENSURE(VALID_BOOLEAN(IsOk)); + ENSURE(IMPLICATION(IsOk, VALID_REF(*String))); + return IsOk; +} + + +/** + * Reads a string from all versions of a binary plt file. + * + * param FileStream + * Open file stream positioned at the string to read. + * param IVersion + * Binary file version number. + * param MaxCharacters + * IVersion < 63 + * This value is exactly the number of characters (actually floats, each + * one representing a character's ordinal value) to read from the file. + * IVersion >= 63 and ProcessData == TRUE + * If non-zero, this value represents the largest string to be returned. + * In other words, larger strings are read from the file but an allocated + * string of up to MaxCharacters is returned. A zero value indicates that + * the string size is unlimited and determined only by the actual length + * of the string in the file. + * param TargetStr + * Pointer to hold the allocated string if ProcessData == TRUE. + * param ProcessData + * Indicates if the read string should be retrieved. + * + * return + * TRUE if the read was successful with an allocated string *TargetStr + * containing the string read (no larger than requested or necessary), + * FALSE otherwise. + */ +Boolean_t ReadInString(FileStream_s *FileStream, + short IVersion, + int MaxCharacters, + char **TargetStr, + Boolean_t ProcessData) +{ + Boolean_t IsOk = TRUE; + + REQUIRE(VALID_REF(FileStream) && VALID_REF(FileStream->File)); + REQUIRE(0 < IVersion && IVersion <= TecplotBinaryFileVersion); + REQUIRE(IMPLICATION(IVersion < 63 || ProcessData, MaxCharacters >= 0)); + REQUIRE(IMPLICATION(ProcessData, VALID_REF(TargetStr))); + REQUIRE(VALID_BOOLEAN(ProcessData)); + + if (IVersion < 63) + { + /* + * One word per character. Read Exactly "MaxCharacters" number of words. + */ + float X; + + if (ProcessData) + { + *TargetStr = ALLOC_ARRAY(MaxCharacters + 1, char, "target string"); + IsOk = (*TargetStr != NULL); + } + + if (IsOk) + { + LgIndex_t I; + for (I = 0; IsOk && I < MaxCharacters; I++) + { + X = (float)GetNextValue(FileStream, FieldDataType_Float, 0.0, 127.0, &IsOk); + if (!IsOk) + break; + if (ProcessData) + (*TargetStr)[I] = FilterFloatChar(X); + } + if (ProcessData) + (*TargetStr)[I] = '\0'; + } + else + { + ErrMsg(translate("Cannot allocate memory for string during read", + "'string' meaning the computer science data type")); + } + } + else + { +#define MAX_STRBUFFER_LEN 4095 + static char StrBuffer[MAX_STRBUFFER_LEN+1]; + LgIndex_t StrBufferLen = 0; + LgIndex_t TargetStrLen = 0; + LgIndex_t I = 0; + LgIndex_t CharValue = 0; + + if (ProcessData) + *TargetStr = NULL; + + do + { + CharValue = GetIoFileInt(FileStream, IVersion, 0, 255, &IsOk); + if (IsOk && ProcessData) + { + /* massage the character if necessary */ + if ((CharValue < 32 && CharValue != '\0' && CharValue != '\n') || + (CharValue >= 128 && CharValue < 160)) + CharValue = ' '; + + /* + * if the limit is not exceded, stuff the + * character into the buffer + */ + if (CharValue != '\0' && + (I < MaxCharacters || MaxCharacters == 0)) + { + StrBuffer[StrBufferLen] = (char)CharValue; + StrBufferLen++; + } + + if (CharValue == '\0' || + StrBufferLen == MAX_STRBUFFER_LEN) + { + if (StrBufferLen != 0 || *TargetStr == NULL) + { + StrBuffer[StrBufferLen] = '\0'; + TargetStrLen += StrBufferLen; + IsOk = ReallocString(TargetStr, TargetStrLen); + if (IsOk) + strcat(*TargetStr, StrBuffer); + StrBufferLen = 0; /* reset the string buffer */ + } + } + } + + I++; + } + while (IsOk && (char)CharValue != '\0'); + + /* if we failed cleanup if necessary */ + if (!IsOk && + ProcessData && + *TargetStr != NULL) + { + FREE_ARRAY(*TargetStr, "failed read string"); + *TargetStr = NULL; + } + } + + ENSURE(IMPLICATION(ProcessData, + (VALID_REF(*TargetStr) || *TargetStr == NULL))); + ENSURE(VALID_BOOLEAN(IsOk)); + return (IsOk); +} + +/** + */ +static void ReadDoubleBlock(FileStream_s *FileStream, + Boolean_t DoRead, + double *Buffer, + LgIndex_t StartIndex, + LgIndex_t NumValues, + Boolean_t *IsOk) +{ + if (DoRead) + { + double *DPtr = Buffer + StartIndex; + *IsOk = (TP_FREAD(DPtr, sizeof(double), NumValues, FileStream->File) == (size_t)NumValues); + if (!FileStream->IsByteOrderNative && *IsOk) + { + LgIndex_t N; + for (N = 0; N < NumValues; N++) + REVERSE_8_BYTES(&DPtr[N]); + } + } + else + *IsOk = (TP_FSEEK(FileStream->File, NumValues * sizeof(double), SEEK_CUR) == 0); +} + +/** + */ +static void ReadFloatBlock(FileStream_s *FileStream, + Boolean_t DoRead, + float *Buffer, + LgIndex_t StartIndex, + LgIndex_t NumValues, + Boolean_t *IsOk) +{ + if (DoRead) + { + float *FPtr = Buffer + StartIndex; + *IsOk = (TP_FREAD(FPtr, sizeof(float), NumValues, FileStream->File) == (size_t)NumValues); + if (!FileStream->IsByteOrderNative && *IsOk) + { + LgIndex_t N; + for (N = 0; N < NumValues; N++) + REVERSE_4_BYTES(&FPtr[N]); + } + } + else + *IsOk = (TP_FSEEK(FileStream->File, NumValues * sizeof(float), SEEK_CUR) == 0); +} + + +/** + */ +static void ReadBitBlock(FileStream_s *FileStream, + Boolean_t DoRead, + Byte_t *Buffer, + LgIndex_t NumValues, + Boolean_t *IsOk) +{ + /* + * Do not allow reading of bit values if startindex is not 0. + * (This means geometries cannot use bit data. + */ + LgIndex_t NumBytes = (NumValues + 7) / 8; + if (DoRead) + { + *IsOk = (TP_FREAD(Buffer, + sizeof(Byte_t), + NumBytes, + FileStream->File) == (size_t)NumBytes); + } + else + *IsOk = (TP_FSEEK(FileStream->File, NumBytes * sizeof(Byte_t), SEEK_CUR) == 0); +} + +/** + */ +void ReadByteBlock(FileStream_s *FileStream, + Boolean_t DoRead, + Byte_t *Buffer, + HgIndex_t StartIndex, + HgIndex_t NumValues, + Boolean_t *IsOk) +{ + if (DoRead) + { + *IsOk = (TP_FREAD(Buffer + StartIndex, + sizeof(Byte_t), + NumValues, + FileStream->File) == (size_t)NumValues); + } + else + *IsOk = (TP_FSEEK(FileStream->File, NumValues * sizeof(Byte_t), SEEK_CUR) == 0); +} + + +/** + */ +void ReadInt16Block(FileStream_s *FileStream, + Boolean_t DoRead, + Int16_t *Buffer, + HgIndex_t StartIndex, + HgIndex_t NumValues, + Boolean_t *IsOk) +{ + if (DoRead) + { + Int16_t *IntPtr = Buffer + StartIndex; + *IsOk = (TP_FREAD(IntPtr, + sizeof(Int16_t), + NumValues, + FileStream->File) == (size_t)NumValues); + + if (!FileStream->IsByteOrderNative && *IsOk) + { + LgIndex_t N; + for (N = 0; N < NumValues; N++) + REVERSE_2_BYTES(&IntPtr[N]); + } + } + else + *IsOk = (TP_FSEEK(FileStream->File, NumValues * sizeof(Int16_t), SEEK_CUR) == 0); +} + +/** + */ +void ReadInt16BlockToInt32(FileStream_s *FileStream, + Boolean_t DoRead, + Int32_t *Buffer, + HgIndex_t StartIndex, + HgIndex_t NumValues, + Boolean_t *IsOk) +{ + REQUIRE(VALID_REF(FileStream)); + REQUIRE(VALID_BOOLEAN(DoRead)); + REQUIRE(VALID_REF(Buffer)); + REQUIRE(StartIndex >= 0); + REQUIRE(NumValues >= 0); + REQUIRE(VALID_REF(IsOk) && VALID_BOOLEAN(*IsOk)); + + if (DoRead) + { + HgIndex_t EndIndex = StartIndex + NumValues; + for (HgIndex_t ValueIndex = StartIndex; *IsOk && ValueIndex < EndIndex; ValueIndex++) + { + Int16_t Value; + *IsOk = (TP_FREAD(&Value, sizeof(Int16_t), 1, FileStream->File) == 1); + if (!FileStream->IsByteOrderNative && *IsOk) + REVERSE_2_BYTES(&Value); + Buffer[ValueIndex] = (Int32_t)Value; + } + } + else + *IsOk = (TP_FSEEK(FileStream->File, NumValues * sizeof(Int16_t), SEEK_CUR) == 0); +} + +/** + */ +void ReadInt32Block(FileStream_s *FileStream, + Boolean_t DoRead, + Int32_t *Buffer, + HgIndex_t StartIndex, + HgIndex_t NumValues, + Boolean_t *IsOk) +{ + if (DoRead) + { + Int32_t *IntPtr = Buffer + StartIndex; + *IsOk = (TP_FREAD(IntPtr, + sizeof(Int32_t), + NumValues, + FileStream->File) == (size_t)NumValues); + + if (!FileStream->IsByteOrderNative && *IsOk) + { + LgIndex_t N; + for (N = 0; N < NumValues; N++) + REVERSE_4_BYTES(&IntPtr[N]); + } + } + else + *IsOk = (TP_FSEEK(FileStream->File, NumValues * sizeof(Int32_t), SEEK_CUR) == 0); +} + +/** + */ +void ReadPureBlock(FileStream_s *FileStream, + Boolean_t DoRead, + void *Buffer, + FieldDataType_e FieldDataType, + HgIndex_t StartIndex, + HgIndex_t NumValues, + Boolean_t *IsOk) +{ + REQUIRE(VALID_REF(FileStream) && VALID_REF(FileStream->File)); + REQUIRE(VALID_BOOLEAN(DoRead)); + REQUIRE(!DoRead || VALID_REF(Buffer)); + REQUIRE(VALID_FIELD_DATA_TYPE(FieldDataType)); + REQUIRE(StartIndex >= 0); + REQUIRE(NumValues >= 0); + REQUIRE(VALID_REF(IsOk) && VALID_BOOLEAN(*IsOk)); + + switch (FieldDataType) + { + case FieldDataType_Float : + { + ReadFloatBlock(FileStream, + DoRead, + (float *)Buffer, + StartIndex, + NumValues, + IsOk); + } break; + case FieldDataType_Double : + { + ReadDoubleBlock(FileStream, + DoRead, + (double *)Buffer, + StartIndex, + NumValues, + IsOk); + } break; + case FieldDataType_Bit : + { + if (StartIndex != 0) + { + ErrMsg(translate("Internal Error: Attempt to read bit data at non-zero offset", + "see Tecplot User's manual for a definition of 'bit' data")); + *IsOk = FALSE; + } + else + ReadBitBlock(FileStream, + DoRead, + (Byte_t *)Buffer, + NumValues, + IsOk); + } break; + case FieldDataType_Byte : + { + ReadByteBlock(FileStream, + DoRead, + (Byte_t *)Buffer, + StartIndex, + NumValues, + IsOk); + } break; + case FieldDataType_Int16 : + { + ReadInt16Block(FileStream, + DoRead, + (Int16_t *)Buffer, + StartIndex, + NumValues, + IsOk); + } break; + case FieldDataType_Int32 : + { + ReadInt32Block(FileStream, + DoRead, + (Int32_t *)Buffer, + StartIndex, + NumValues, + IsOk); + } break; + case FieldDataType_IJKFunction : /* Not used yet */ + case FieldDataType_Int64 : /* Not used yet */ + default: CHECK(FALSE); break; + } + ENSURE(VALID_BOOLEAN(*IsOk)); +} + +/** + */ +void ReadBlock(FileStream_s *FileStream, + FieldData_pa FieldData, + Boolean_t DoRead, + FieldDataType_e FieldDataTypeInFile, + HgIndex_t StartIndex, + HgIndex_t EndIndex, + Boolean_t *IsOk) +{ + REQUIRE(VALID_REF(IsOk) && VALID_BOOLEAN(*IsOk)); + REQUIRE(IMPLICATION(IsOk, VALID_REF(FileStream))); + REQUIRE(IMPLICATION(IsOk, VALID_FIELD_DATA_TYPE(FieldDataTypeInFile))); + REQUIRE(VALID_BOOLEAN(DoRead)); + REQUIRE(IMPLICATION(DoRead, VALID_REF(FieldData))); + + /* + * Bit data is packed into bytes. Since Tecplot doesn't buffer reads it can + * not perform bit by bit value reads and therefore must only perform block + * reads of bit data. + */ + Boolean_t ReadByBlock = IMPLICATION(DoRead, GetFieldDataType(FieldData) == FieldDataTypeInFile); + REQUIRE(ReadByBlock || (FieldDataTypeInFile != FieldDataType_Bit)); + + if (*IsOk) + { + LgIndex_t NumValues = EndIndex - StartIndex + 1; + if (ReadByBlock) + { + void *data_array; + if (DoRead) + data_array = GetFieldDataVoidPtr(FieldData); + else + data_array = NULL; + ReadPureBlock(FileStream, + DoRead, + data_array, + FieldDataTypeInFile, + StartIndex, + NumValues, + IsOk); + } + else + { + LgIndex_t N; + for (N = 0; *IsOk && (N < NumValues); N++) + { + double D = GetNextValue(FileStream, FieldDataTypeInFile, -LARGEDOUBLE, LARGEDOUBLE, IsOk); + if (DoRead) + SetFieldValue(FieldData, N + StartIndex, D); + } + } + } +} + +/** + */ +void ReadClassicOrderedCCBlock(FileStream_s *DataFileStream, + FieldData_pa FieldData, + FieldDataType_e FieldDataTypeInFile, + LgIndex_t NumIPtsInFile, + LgIndex_t NumJPtsInFile, + LgIndex_t NumKPtsInFile, + Boolean_t *IsOk) +{ + REQUIRE(IMPLICATION(*IsOk, VALID_REF(DataFileStream))); + REQUIRE(IMPLICATION(*IsOk, VALID_FIELD_DATA_TYPE(FieldDataTypeInFile))); + REQUIRE(VALID_REF(FieldData)); + REQUIRE(NumIPtsInFile >= 0); + REQUIRE(NumJPtsInFile >= 0); + REQUIRE(NumKPtsInFile >= 0); + REQUIRE(VALID_REF(IsOk) && VALID_BOOLEAN(*IsOk)); + + if (*IsOk) + { + LgIndex_t J, K; + LgIndex_t NumIJPts = NumIPtsInFile * NumJPtsInFile; + LgIndex_t IEnd = MAX(NumIPtsInFile - 1, 1); + LgIndex_t JEnd = MAX(NumJPtsInFile - 1, 1); + LgIndex_t KEnd = MAX(NumKPtsInFile - 1, 1); + LgIndex_t NumValues = (IEnd * JEnd * KEnd); + Boolean_t IsLinear = ((NumJPtsInFile == 1 && NumKPtsInFile == 1) || + (NumIPtsInFile == 1 && NumKPtsInFile == 1) || + (NumIPtsInFile == 1 && NumJPtsInFile == 1)); + if (IsLinear) + ReadBlock(DataFileStream, FieldData, TRUE, FieldDataTypeInFile, + 0, NumValues - 1, IsOk); + else + for (K = 0; K < KEnd && IsOk; K++) + for (J = 0; J < JEnd && IsOk; J++) + { + LgIndex_t CellIndex = 0 + (J * NumIPtsInFile) + (K * NumIJPts); + ReadBlock(DataFileStream, FieldData, TRUE, FieldDataTypeInFile, + CellIndex, CellIndex + IEnd - 1, IsOk); + } + } + + ENSURE(VALID_BOOLEAN(*IsOk)); +} + +/** + */ +static void AdjustCustomColor(short IVersion, + ColorIndex_t *BColor) +{ + REQUIRE(0 < IVersion && IVersion <= TecplotBinaryFileVersion); + REQUIRE(VALID_REF(BColor)); + + if ((IVersion < 70) && (*BColor >= 15) && (*BColor <= 22)) + *BColor -= 7; +} + + +/* + * ReadInDataFileTypeTitleAndVarNames replaces ReadInDataFileTitleAndVarNames + * and reads in the filetype as well in files with version >= 109. + */ +Boolean_t ReadInDataFileTypeTitleAndVarNames(FileStream_s *FileStream, + short IVersion, + char **DataSetTitle, + DataFileType_e *FileType, + int *NumVars, + StringList_pa *VarNames) +{ + EntIndex_t CurVar; + Boolean_t IsOk = TRUE; + + REQUIRE(VALID_REF(FileStream) && VALID_REF(FileStream->File)); + REQUIRE(0 < IVersion && IVersion <= TecplotBinaryFileVersion); + REQUIRE(VALID_REF(DataSetTitle) || (DataSetTitle == NULL)); + REQUIRE(VALID_REF(FileType) || (FileType == NULL)); + REQUIRE(VALID_REF(NumVars)); + REQUIRE(VALID_REF(VarNames) || (VarNames == NULL)); + + *NumVars = 0; + if (DataSetTitle) + *DataSetTitle = NULL; + if (IVersion >= 109) + { + if (FileType) + *FileType = (DataFileType_e)GetIoFileInt(FileStream, + IVersion, + 0, + DataFileType_Solution, + &IsOk); + else + GetIoFileInt(FileStream, + IVersion, + 0, + DataFileType_Solution, + &IsOk); + } + if (ReadInString(FileStream, + IVersion, + ((IVersion < 63) ? 80 : MaxChrsDatasetTitle), + DataSetTitle, + (Boolean_t)(DataSetTitle != NULL))) + { + if (DataSetTitle) + TrimLeadAndTrailSpaces(*DataSetTitle); + *NumVars = GetIoFileInt(FileStream, IVersion, 0, MAXZONEMAP, &IsOk); + } + else + IsOk = FALSE; + + if (IsOk && (*NumVars > MaxNumZonesOrVars)) + { + ErrMsg(translate("Too many variables")); + IsOk = FALSE; + } + + if (IsOk && VarNames) + { + if (*NumVars > 0) + { + /* allocate a string list filled with NULL's */ + *VarNames = StringListAlloc(); + IsOk = (*VarNames != NULL); + if (IsOk) + IsOk = StringListSetString(*VarNames, *NumVars - 1, NULL); + + if (!IsOk) + { + if (*VarNames != NULL) + StringListDealloc(VarNames); + ErrMsg(translate("Out of space while allocating var names")); + } + } + } + + for (CurVar = 0; IsOk && (CurVar < *NumVars); CurVar++) + { + char *VName = NULL; + + IsOk = ReadInString(FileStream, + IVersion, + ((IVersion < 63) ? 5 : MaxChrsVarName), + VarNames ? &VName : NULL, + (Boolean_t)(VarNames != NULL)); + if (IsOk && VarNames) + { + if (VName == NULL) + { + /* NULL variable names are converted to empty names */ + VName = ALLOC_ARRAY(1, char, "empty variable name"); + strcpy(VName, ""); + } + TrimLeadAndTrailSpaces(VName); + + /* + * variables are not allowed to have litteral new line characters + * within them but they can sneek in from ASCII data files so + * convert any to their appropriate two character representation + */ + IsOk = ReplaceNewlineWithBackslashN(&VName); + + IsOk = IsOk && StringListSetString(*VarNames, CurVar, VName); + if (VName != NULL) + FREE_ARRAY(VName, "variable name"); + } + + if (!IsOk) + { + if (VarNames && *VarNames) + StringListDealloc(VarNames); + ErrMsg(translate("Out of space while allocating variable names")); + } + } + ENSURE(VALID_BOOLEAN(IsOk)); + return (IsOk); +} + + + + +/** + */ +static Boolean_t ReadInPresetZoneColor(FileStream_s *FileStream, + short IVersion, + ZoneSpec_s *ZoneSpec) +{ + Boolean_t IsOk = TRUE; + LgIndex_t ZoneColor; + + REQUIRE(VALID_REF(FileStream) && VALID_REF(FileStream->File)); + REQUIRE(0 < IVersion && IVersion <= TecplotBinaryFileVersion); + REQUIRE(VALID_REF(ZoneSpec)); + + ZoneColor = GetIoFileInt(FileStream, IVersion, -1, LastBasicColor, &IsOk); + if (IsOk) + { + if (VALID_BASIC_COLOR(ZoneColor)) + { + ZoneSpec->ZoneLoadInfo.PresetZoneColor = (EntIndex_t)ZoneColor; + AdjustCustomColor(IVersion, &ZoneSpec->ZoneLoadInfo.PresetZoneColor); + } + else if (ZoneColor != -1) + IsOk = FALSE; + } + + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + +/** + */ +static void ConvertCommonTimeToSolutionTime(ZoneSpec_s *ZoneSpec) +{ + REQUIRE(VALID_REF(ZoneSpec)); + REQUIRE(ZoneSpec->AuxData == NULL || VALID_REF(ZoneSpec->AuxData)); + + LgIndex_t ItemIndex; + if (ZoneSpec->AuxData != NULL && + AuxDataGetItemIndex(ZoneSpec->AuxData, AuxData_Common_Time, &ItemIndex)) + { + const char *SameName; + ArbParam_t Value; + AuxDataType_e Type; + Boolean_t Retain; + + AuxDataGetItemByIndex(ZoneSpec->AuxData, ItemIndex, + &SameName, &Value, &Type, &Retain); + CHECK(ustrcmp(AuxData_Common_Time, SameName) == 0); + CHECK(Type == AuxDataType_String); + + char *EndPtr = NULL; + double SolutionTime = strtod((const char *)Value, &EndPtr); + if (EndPtr != (char *)Value) + { + /* we only allow white space to trail a value */ + while (isspace(*EndPtr)) + EndPtr++; + } + if (EndPtr != (char *)Value && *EndPtr == '\0') + { + ZoneSpec->SolutionTime = SolutionTime; + ZoneSpec->StrandID = STRAND_ID_PENDING; + AuxDataDeleteItemByIndex(ZoneSpec->AuxData, ItemIndex); + } + } +} + +/* + * Pass1 for a zone reads in and initializes the zone structures. + * These structures are released later if the user elects to not read them + * in. + */ +Boolean_t ReadInZoneHeader(FileStream_s *FileStream, + short IVersion, + ZoneSpec_s *ZoneSpec, + Set_pa IsVarCellCentered, + EntIndex_t NumVars, + Boolean_t *IsRawFNAvailable, + LgIndex_t *FNNumBndryConns) +{ + EntIndex_t Var; + Boolean_t IsOk = TRUE; + LgIndex_t I1; + + REQUIRE(VALID_REF(FileStream) && VALID_REF(FileStream->File)); + REQUIRE(0 < IVersion && IVersion <= TecplotBinaryFileVersion); + REQUIRE(VALID_REF(ZoneSpec)); + REQUIRE(IsVarCellCentered == NULL || VALID_REF(IsVarCellCentered)); + REQUIRE(NumVars >= 0); + REQUIRE(VALID_REF(IsRawFNAvailable)); + REQUIRE(VALID_REF(FNNumBndryConns)); + + SetZoneSpecDefaults(ZoneSpec); + + if (IsVarCellCentered != NULL) + { + /* assign default variable value location: nodal */ + ClearSet(IsVarCellCentered); + IsOk = ExpandSet(IsVarCellCentered, NumVars, FALSE); + } + + if (IsOk) + IsOk = ReadInString(FileStream, IVersion, + ((IVersion < 63) ? 10 : MaxChrsZnTitle), + &ZoneSpec->Name, + TRUE); + + if (IsOk && ZoneSpec->Name == NULL) + { + /* NULL zone names are converted to empty names */ + ZoneSpec->Name = ALLOC_ARRAY(1, char, "empty zone name"); + IsOk = (ZoneSpec->Name != NULL); + if (IsOk) + strcpy(ZoneSpec->Name, ""); + } + + if (IsOk) + TrimLeadAndTrailSpaces(ZoneSpec->Name); + + if (IVersion < 101) + { + Boolean_t IsZoneFinite; + DataFormat_e ZoneDataFormat; + + I1 = GetIoFileInt(FileStream, IVersion, 0, 3, &IsOk); + + if ((I1 < 0) || (I1 > 3)) + { + return (FALSE); + } + + ZoneDataFormat = (DataFormat_e)I1; + + IsZoneFinite = (ZoneDataFormat == DataFormat_FEPoint || + ZoneDataFormat == DataFormat_FEBlock); + + ZoneSpec->ZoneLoadInfo.IsInBlockFormat = (ZoneDataFormat == DataFormat_IJKBlock || + ZoneDataFormat == DataFormat_FEBlock); + + if (IVersion > 62) + IsOk = ReadInPresetZoneColor(FileStream, IVersion, ZoneSpec); + + if (IVersion < 60) + GetNextValue(FileStream, FieldDataType_Float, -LARGEDOUBLE, LARGEDOUBLE, &IsOk); /* Old ZPlane Value */ + + if (IsOk) + { + ZoneSpec->NumPtsI = GetIoFileInt(FileStream, IVersion, 0, MAXINDEX, &IsOk); + ZoneSpec->NumPtsJ = GetIoFileInt(FileStream, IVersion, 0, MAXINDEX, &IsOk); + if (IVersion >= 60) + ZoneSpec->NumPtsK = GetIoFileInt(FileStream, IVersion, 0, MAXINDEX, &IsOk); + else + ZoneSpec->NumPtsK = 1; + } + + if (IsOk) + { + /* If IMax,JMax, & KMax are all zero then this zone was "zombied" by + a partial read to make layout files align. */ + + if (!((ZoneSpec->NumPtsI == 0) && + (ZoneSpec->NumPtsJ == 0) && + (ZoneSpec->NumPtsK == 0)) && + ((ZoneSpec->NumPtsI <= 0) || + (ZoneSpec->NumPtsJ <= 0) || + (ZoneSpec->NumPtsK < 0) || + ((!IsZoneFinite && (ZoneSpec->NumPtsK == 0))))) + { + ErrMsg(translate("Datafile is corrupted")); + IsOk = FALSE; + } + + if (IsZoneFinite) + { + if (IVersion >= 61) + { + ZoneSpec->Type = (ZoneType_e)(ZoneSpec->NumPtsK + 1); + switch (ZoneSpec->Type) + { + case ZoneType_FETriangle: ZoneSpec->NumPtsK = 3; break; + case ZoneType_FEQuad: ZoneSpec->NumPtsK = 4; break; + case ZoneType_FETetra: ZoneSpec->NumPtsK = 4; break; + case ZoneType_FEBrick: ZoneSpec->NumPtsK = 8; break; + case ZoneType_FELineSeg: ZoneSpec->NumPtsK = 2; break; + default: + { + ErrMsg(translate("Datafile corrupted: Invalid element type for FE DataSet")); + IsOk = FALSE; + } + } + } + else + { + ZoneSpec->Type = ZoneType_FEQuad; + ZoneSpec->NumPtsK = 4; + } + } + else + { + ZoneSpec->Type = ZoneType_Ordered; + + ZoneSpec->ICellDim = ZoneSpec->NumPtsI - 1; + ZoneSpec->JCellDim = ZoneSpec->NumPtsJ - 1; + ZoneSpec->KCellDim = ZoneSpec->NumPtsK - 1; + } + } + + /* + * Raw and user defined boundary face neighbors connections were not in + * this or previous versions of the binary data files. + */ + *IsRawFNAvailable = FALSE; + *FNNumBndryConns = 0; + } + else + { + if (IsOk && (IVersion >= 107)) + { + ZoneSpec->ParentZone = GetIoFileInt(FileStream, IVersion, -1, MAXZONEMAP - 1, &IsOk); + if (!IsOk) + ErrMsg(translate("Invalid datafile: parent zone assignment must be to an existing zone within the same datafile.")); + } + + if (IsOk && (IVersion >= 106)) + { + /* Strand ID and solution time. Strand ID's of STRAND_ID_PENDING, -2, instruct Tecplot to generate strand ID's */ + ZoneSpec->StrandID = GetIoFileInt(FileStream, IVersion, -2, MAXZONEMAP - 1, &IsOk); + ZoneSpec->SolutionTime = GetNextValue(FileStream, FieldDataType_Double, -LARGEDOUBLE, LARGEDOUBLE, &IsOk); + if (!IsOk) + ErrMsg(translate("Invalid datafile: bad StrandID or SolutionTime")); + } + + /* preset zone color */ + IsOk = IsOk && ReadInPresetZoneColor(FileStream, IVersion, ZoneSpec); + + /* ZoneType */ + I1 = (ZoneType_e)GetIoFileInt(FileStream, IVersion, 0, 7, &IsOk); + switch (I1) + { + case 0: ZoneSpec->Type = ZoneType_Ordered; break; + case 1: ZoneSpec->Type = ZoneType_FELineSeg; break; + case 2: ZoneSpec->Type = ZoneType_FETriangle; break; + case 3: ZoneSpec->Type = ZoneType_FEQuad; break; + case 4: ZoneSpec->Type = ZoneType_FETetra; break; + case 5: ZoneSpec->Type = ZoneType_FEBrick; break; + case 6: ZoneSpec->Type = ZoneType_FEPolygon; break; + case 7: ZoneSpec->Type = ZoneType_FEPolyhedron; break; + default: + { + ErrMsg(translate("Invalid datafile: unknown zone type.")); + IsOk = FALSE; + } break; + } + + /* DataPacking (Always BLOCK starting with file version 112 so removed from binary format) */ + if (IVersion < 112) + ZoneSpec->ZoneLoadInfo.IsInBlockFormat = + ((DataPacking_e)GetIoFileInt(FileStream, IVersion, 0, 1, &IsOk) == DataPacking_Block); + else + ZoneSpec->ZoneLoadInfo.IsInBlockFormat = TRUE; + + /* is the variable value location specified? */ + if ((Boolean_t)GetIoFileInt(FileStream, IVersion, 0, 1, &IsOk) && IsOk) + { + /* Variable Value Location foreach Var */ + for (Var = 0; Var < NumVars && IsOk; Var++) + { + if ((Boolean_t)GetIoFileInt(FileStream, IVersion, 0, 1, &IsOk) && IsOk && + IsVarCellCentered != NULL) + { + IsOk = (ZoneSpec->ZoneLoadInfo.IsInBlockFormat); + if (IsOk) + IsOk = AddToSet(IsVarCellCentered, Var, FALSE); + else + ErrMsg(translate("Invalid datafile: cell centered " + "variable must be in block format.", + "See the Tecplot User's Manual for a definition of 'block format'")); + } + } + } + + /* are raw face neighbors supplied in the data section? */ + if (IVersion >= 108 && IsOk) + { + *IsRawFNAvailable = GetIoFileInt(FileStream, IVersion, 0, 1, &IsOk); + if (*IsRawFNAvailable && + (ZoneSpec->Type == ZoneType_Ordered || + ZoneSpec->Type == ZoneType_FELineSeg)) + { + IsOk = FALSE; + ErrMsg(translate("Invalid datafile: raw face neighbors may not be " + "supplied for ordered or FE line segment zones.")); + } + } + else + *IsRawFNAvailable = FALSE; + + /* + * If raw face neighbors are available in the datafile then Tecplot + * should not auto-assign the neighbors after the load. + */ + ZoneSpec->FNAreCellFaceNbrsSupplied = *IsRawFNAvailable; + + /* miscellaneous face neighbor info */ + *FNNumBndryConns = GetIoFileInt(FileStream, IVersion, 0, MAXINDEX, &IsOk); + if (*FNNumBndryConns != 0) + ZoneSpec->FNMode = (FaceNeighborMode_e)GetIoFileInt(FileStream, IVersion, 0, 3, &IsOk); + + if (IVersion >= 108 && IsOk) + { + Boolean_t FaceNeighborsComplete = FALSE; + if (*FNNumBndryConns != 0 && + ZoneSpec->Type != ZoneType_Ordered) + FaceNeighborsComplete = (Boolean_t)GetIoFileInt(FileStream, IVersion, 0, 1, &IsOk); + + /* + * If the user defined face neighbors completely specify all the + * face neighbors then we don't want to auto-assign the cell face + * neighbors after loading. If they are not complete then leave the + * setting (as set above) dependent on the availability of the raw + * face neighbors. + * + * NOTE: + * This is a rather inefficient way to specify face neighbors. + */ + if (FaceNeighborsComplete) + ZoneSpec->FNAreCellFaceNbrsSupplied = TRUE; + } + + if (ZoneSpec->Type == ZoneType_Ordered) + { + /* IMax, JMax, KMax */ + ZoneSpec->NumPtsI = GetIoFileInt(FileStream, IVersion, 0, MAXINDEX, &IsOk); + ZoneSpec->NumPtsJ = GetIoFileInt(FileStream, IVersion, 0, MAXINDEX, &IsOk); + ZoneSpec->NumPtsK = GetIoFileInt(FileStream, IVersion, 0, MAXINDEX, &IsOk); + /* + * if not a zombie zone (zombie zone: points in all dimensions are + * zero) then points in each direction must be specified + */ + if (IsOk && + !(ZoneSpec->NumPtsI == 0 && + ZoneSpec->NumPtsJ == 0 && + ZoneSpec->NumPtsK == 0) && + (ZoneSpec->NumPtsI == 0 || + ZoneSpec->NumPtsJ == 0 || + ZoneSpec->NumPtsK == 0)) + { + ErrMsg(translate("Invalid data file: incorrect specification of " + "I, J, or K points for ordered data set.")); + IsOk = FALSE; + } + } + else + { + ZoneSpec->NumPtsI = GetIoFileInt(FileStream, IVersion, 0, MAXINDEX, &IsOk); + if (ZoneSpec->Type == ZoneType_FEPolygon || ZoneSpec->Type == ZoneType_FEPolyhedron) + { + ZoneSpec->NumPtsK = GetIoFileInt(FileStream, IVersion, 0, MAXINDEX, &IsOk); // ...NumFaces + if (IVersion >= 111) + { + ZoneSpec->NumFaceNodes = GetIoFileInt(FileStream, IVersion, 0, MAXINDEX, &IsOk); + ZoneSpec->NumFaceBndryFaces = GetIoFileInt(FileStream, IVersion, 0, MAXINDEX, &IsOk); + ZoneSpec->NumFaceBndryItems = GetIoFileInt(FileStream, IVersion, 0, MAXINDEX, &IsOk); + } + } + else + { + switch (ZoneSpec->Type) + { + case ZoneType_FETriangle: ZoneSpec->NumPtsK = 3; break; + case ZoneType_FEQuad: ZoneSpec->NumPtsK = 4; break; + case ZoneType_FETetra: ZoneSpec->NumPtsK = 4; break; + case ZoneType_FEBrick: ZoneSpec->NumPtsK = 8; break; + case ZoneType_FELineSeg: ZoneSpec->NumPtsK = 2; break; + default : + { + ErrMsg(translate("Invalid data file: invalid element type for FE data set.")); + IsOk = FALSE; + } + } + } + ZoneSpec->NumPtsJ = GetIoFileInt(FileStream, IVersion, 0, MAXINDEX, &IsOk); + + ZoneSpec->ICellDim = GetIoFileInt(FileStream, IVersion, 0, MAXINDEX, &IsOk); + ZoneSpec->JCellDim = GetIoFileInt(FileStream, IVersion, 0, MAXINDEX, &IsOk); + ZoneSpec->KCellDim = GetIoFileInt(FileStream, IVersion, 0, MAXINDEX, &IsOk); + } + + /* Zone Auxiliary Data indicator followed by Zone Auxiliary Data */ + for (I1 = GetIoFileInt(FileStream, IVersion, 0, 1, &IsOk); + IsOk && I1 != 0; + I1 = GetIoFileInt(FileStream, IVersion, 0, 1, &IsOk)) + { + if (ZoneSpec->AuxData == NULL) + ZoneSpec->AuxData = AuxDataAlloc(); + IsOk = (ZoneSpec->AuxData != NULL); + if (IsOk) + IsOk = ReadInAuxData(FileStream, IVersion, ZoneSpec->AuxData); + } + } + + /* + * Convert AuxZone's Common.Time from non-time aware data files to zone + * solution time if it exists. + */ + if (IVersion < 106 && IsOk) + ConvertCommonTimeToSolutionTime(ZoneSpec); + + ENSURE(VALID_BOOLEAN(IsOk)); + return (IsOk); +} + + + + +/* + * Pass1 for Custom labels simply acknowledges that a custom label was + * parsed and skips over the labels. + */ + +Boolean_t ReadInCustomLabels(FileStream_s *FileStream, + short IVersion, + Boolean_t OkToLoad, + StringList_pa *CustomLabelBase) +{ + LgIndex_t NumLabels; + short I; + Boolean_t IsOk = TRUE; + + REQUIRE(VALID_REF(FileStream) && VALID_REF(FileStream->File)); + REQUIRE(IVersion > 0); + REQUIRE(VALID_BOOLEAN(OkToLoad)); + REQUIRE(!(OkToLoad) || VALID_REF(CustomLabelBase)); + + NumLabels = (short)GetIoFileInt(FileStream, IVersion, 1, MAXINDEX, &IsOk); + if (IsOk && NumLabels != 0 && OkToLoad) + { + *CustomLabelBase = StringListAlloc(); + IsOk = (*CustomLabelBase != NULL); + if (!IsOk) + ErrMsg(translate("Cannot allocate memory for Custom Labels.")); + } + + for (I = 0; IsOk && (I < NumLabels); I++) + { + char *TLabel = NULL; + + IsOk = ReadInString(FileStream, IVersion, + 1024, + &TLabel, + OkToLoad); + TrimLeadAndTrailSpaces(TLabel); + + if (IsOk && OkToLoad) + { +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + IsOk = StringListAppendString(*CustomLabelBase, TLabel); + if (TLabel != NULL) + FREE_ARRAY(TLabel, "custom label"); + if (!IsOk) + ErrMsg(translate("Cannot allocate memory for Custom Label.")); + } + } + if (!IsOk) + ErrMsg(translate("Invalid custom axis label record in binary datafile")); + + ENSURE(VALID_BOOLEAN(IsOk)); + ENSURE(!(IsOk && NumLabels != 0 && OkToLoad) || + StringListValid(*CustomLabelBase)); + return IsOk; +} + + +Boolean_t ReadInUserRec(FileStream_s *FileStream, + short IVersion, + int MaxCharactersAllowed, + char **UserRec) /* NULL if to ignore */ +{ + if (!ReadInString(FileStream, IVersion, + MaxCharactersAllowed, + UserRec, + (Boolean_t)(UserRec != NULL))) + { + ErrMsg(translate("Invalid USERREC record in binary datafile")); + return (FALSE); + } + return (TRUE); +} + + +/** + */ +Boolean_t ReadInAuxData(FileStream_s *FileStream, + short IVersion, + AuxData_pa AuxData) +{ + Boolean_t IsOk; + Boolean_t DoCollectData; + char *AuxName = NULL; + LgIndex_t AuxValueType; + char *AuxValue = NULL; + + REQUIRE(VALID_REF(FileStream) && VALID_REF(FileStream->File)); + REQUIRE(0 < IVersion && IVersion <= TecplotBinaryFileVersion); + REQUIRE(AuxData == NULL || VALID_REF(AuxData)); + + DoCollectData = (AuxData != NULL); + IsOk = ReadInString(FileStream, + IVersion, + MaxChrsVarName, /* ... seems reasonable */ + &AuxName, + DoCollectData); + if (IsOk && DoCollectData && !AuxDataIsValidName(AuxName)) + { + ErrMsg(translate("Invalid auxiliary data name.")); + IsOk = FALSE; + } + + /* + * currently only one value type is supported + * 0: AuxiliaryValueFormat_String + */ + if (IsOk) + { + AuxValueType = GetIoFileInt(FileStream, IVersion, 0, 0, &IsOk); + if (IsOk && (AuxValueType != (LgIndex_t)AuxDataType_String)) + { + ErrMsg(translate("Unsupported auxiliary data type")); + IsOk = FALSE; + } + } + + if (IsOk) + IsOk = ReadInString(FileStream, + IVersion, + MaxChrsAuxValueString, + &AuxValue, + DoCollectData); + if (IsOk && DoCollectData) + IsOk = AuxDataSetItem(AuxData, + AuxName, (ArbParam_t)AuxValue, + AuxDataType_String, + TRUE); /* Retain */ + + /* cleanup: auxiliary data made a copy of the name and value */ + if (AuxName != NULL) + FREE_ARRAY(AuxName, "data set auxiliary data item name"); + if (AuxValue != NULL) + FREE_ARRAY(AuxValue, "data set auxiliary data item value"); + + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + + +static void GetZoneAttachment(FileStream_s *FileStream, + short IVersion, + EntIndex_t *Z, + Boolean_t *IsAttached, + Boolean_t *IsOk) +{ + REQUIRE(VALID_REF(FileStream) && VALID_REF(FileStream->File)); + REQUIRE(VALID_REF(Z)); + REQUIRE(VALID_REF(IsAttached)); + REQUIRE(VALID_REF(IsOk) && VALID_BOOLEAN(*IsOk)); + + if (IVersion >= 47) + *Z = (EntIndex_t)GetIoFileInt(FileStream, IVersion, -1, MAXZONEMAP, IsOk); + else + *Z = 0; + + if (IVersion < 70) + (*Z)--; + + if (*Z == -1) + { + *Z = 0; + *IsAttached = FALSE; + } + else + *IsAttached = TRUE; + + ENSURE(VALID_BOOLEAN(*IsAttached)); + ENSURE(VALID_BOOLEAN(*IsOk)); + ENSURE(*Z >= 0); +} + + +static Boolean_t ReadMacroFunctionCommand(FileStream_s *FileStream, + short IVersion, + Boolean_t OkToLoad, + char **MacroFunctionCommand) +{ + Boolean_t Result = FALSE; + REQUIRE(VALID_REF(FileStream) && VALID_REF(FileStream->File)); + REQUIRE(IVersion > 0); + REQUIRE(VALID_BOOLEAN(OkToLoad)); + REQUIRE(VALID_REF(MacroFunctionCommand)); + + Result = ReadInString(FileStream, IVersion, 0, MacroFunctionCommand, OkToLoad); + + ENSURE(VALID_BOOLEAN(Result)); + return (Result); +} + + +/* + * Pass1 for Geometries simply acknowledges that a geometry was + * parsed and skips over the geometry. + */ +Boolean_t ReadInGeometry(FileStream_s *FileStream, + short IVersion, + Boolean_t OkToLoad, + Geom_s *Geom, + LgIndex_t MaxDataPts) +{ + LgIndex_t I; + LgIndex_t S; + FieldDataType_e FFT; + Boolean_t IsOk = TRUE; + TranslatedString ErrMsgString = translate("Invalid geometry record"); + + REQUIRE(VALID_REF(Geom)); + + if (IVersion < 70) + FFT = FieldDataType_Float; + else + FFT = FieldDataType_Double; + + if (IVersion < 101) + I = GetIoFileInt(FileStream, IVersion, 0, 1, &IsOk); + else + I = GetIoFileInt(FileStream, IVersion, 0, 4, &IsOk); + + if (I == 0) + Geom->PositionCoordSys = CoordSys_Grid; + else if (I == 1) + Geom->PositionCoordSys = CoordSys_Frame; + /* + * I == 2 is for CoordSys_FrameOffset and is not used currently + * + * I == 3 is for the old window coordinate system + */ + else if (I == 4) + Geom->PositionCoordSys = CoordSys_Grid3D; + else + { + ErrMsgString = translate("Invalid geometry coordinate system"); + IsOk = FALSE; + } + + Geom->Scope = (Scope_e)GetIoFileInt(FileStream, IVersion, 0, 1, &IsOk); + if (IVersion >= 102) + Geom->DrawOrder = (DrawOrder_e)GetIoFileInt(FileStream, IVersion, 0, 1, &IsOk); + Geom->AnchorPos.Generic.V1 = GetNextValue(FileStream, FFT, -LARGEDOUBLE, LARGEDOUBLE, &IsOk); + Geom->AnchorPos.Generic.V2 = GetNextValue(FileStream, FFT, -LARGEDOUBLE, LARGEDOUBLE, &IsOk); + if (IVersion >= 45) + Geom->AnchorPos.Generic.V3 = GetNextValue(FileStream, FFT, -LARGEDOUBLE, LARGEDOUBLE, &IsOk); + else + Geom->AnchorPos.Generic.V3 = 0.0; + + GetZoneAttachment(FileStream, IVersion, &Geom->Zone, &Geom->AttachToZone, &IsOk); + + Geom->BColor = (SmInteger_t)GetIoFileInt(FileStream, IVersion, 0, 255, &IsOk); + + AdjustCustomColor(IVersion, &Geom->BColor); + + if (IVersion > 47) + { + Geom->FillBColor = (SmInteger_t)GetIoFileInt(FileStream, IVersion, 0, 255, &IsOk); + Geom->IsFilled = (Boolean_t)GetIoFileInt(FileStream, IVersion, 0, 1, &IsOk); + AdjustCustomColor(IVersion, &Geom->FillBColor); + } + else + { + Geom->FillBColor = Geom->BColor; + Geom->IsFilled = FALSE; + } + + if (IVersion < 101) + { + Geom->GeomType = (GeomType_e)GetIoFileInt(FileStream, IVersion, 0, 5, &IsOk); + if (Geom->GeomType == GeomType_LineSegs3D) + { + /* + * GeomType_LineSegs3D is deprecated, converter to GeomType_LineSegs + * with CoordSys_Grid3D instead + */ + Geom->GeomType = GeomType_LineSegs; + Geom->PositionCoordSys = CoordSys_Grid3D; /*...should have been anyway */ + } + } + else + { + Geom->GeomType = (GeomType_e)GetIoFileInt(FileStream, IVersion, 0, 4, &IsOk); + } + + /* + * Check geom coord sys versus geom type + */ + if (Geom->PositionCoordSys == CoordSys_Grid3D && + Geom->GeomType != GeomType_LineSegs) + { + ErrMsgString = translate("Mismatch between geometry coordinate system and geometry type"); + IsOk = FALSE; + } + + if (IVersion > 41) + { + Geom->LinePattern = (LinePattern_e)GetIoFileInt(FileStream, IVersion, 0, (LgIndex_t)LinePattern_DashDotDot, &IsOk); + } + else + { + Geom->LinePattern = (LinePattern_e)((int)Geom->GeomType % 2); + Geom->GeomType = (GeomType_e)((int)Geom->GeomType / 10); + } + + if ((IVersion < 49) && ((short)(Geom->GeomType) == 2)) + { + Geom->GeomType = GeomType_Rectangle; + Geom->IsFilled = TRUE; + } + + if ((IVersion < 70) && ((short)(Geom->GeomType) > 1)) + Geom->GeomType = (GeomType_e)((short)Geom->GeomType + 1); + + ResetString(&Geom->MacroFunctionCommand, NULL, TRUE); + + Geom->ImageResizeFilter = ImageResizeFilter_Texture; + + if (IVersion >= 70) + { + Geom->PatternLength = GetNextValue(FileStream, FFT, + PatternLengthInputSpec.Min, + PatternLengthInputSpec.Max, + &IsOk); + Geom->LineThickness = GetNextValue(FileStream, FFT, + LineThicknessInputSpec.Min, + LineThicknessInputSpec.Max, + &IsOk); + Geom->NumEllipsePts = (SmInteger_t)GetIoFileInt(FileStream, IVersion, 2, MaxPtsCircleOrEllipse, &IsOk); + Geom->ArrowheadStyle = (ArrowheadStyle_e)GetIoFileInt(FileStream, IVersion, 0, (LgIndex_t)ArrowheadStyle_Hollow, &IsOk); + Geom->ArrowheadAttachment = (ArrowheadAttachment_e)GetIoFileInt(FileStream, IVersion, + 0, + (LgIndex_t)ArrowheadAttachment_AtBothEnds, + &IsOk); + + Geom->ArrowheadSize = GetNextValue(FileStream, FFT, + ArrowheadSizeInputSpec.Min, + ArrowheadSizeInputSpec.Max, + &IsOk); + Geom->ArrowheadAngle = GetNextValue(FileStream, FFT, + ArrowheadAngleInputSpec.Min, + ArrowheadAngleInputSpec.Max, + &IsOk); + + if (IVersion >= 75) + { + IsOk = ReadMacroFunctionCommand(FileStream, + IVersion, + OkToLoad, + &Geom->MacroFunctionCommand); + } /* version >= 75 */ + } /* version >= 70 */ + else + { + Geom->LineThickness = 0.001; + Geom->PatternLength = 0.02; + Geom->ArrowheadStyle = ArrowheadStyle_Plain; + Geom->ArrowheadAttachment = ArrowheadAttachment_None; + Geom->ArrowheadSize = 0.05; + Geom->ArrowheadAngle = 12.0 / DEGPERRADIANS; + } + + if (IVersion < 41) + { + GetNextValue(FileStream, FieldDataType_Float, -LARGEDOUBLE, LARGEDOUBLE, &IsOk); + GetNextValue(FileStream, FieldDataType_Float, -LARGEDOUBLE, LARGEDOUBLE, &IsOk); + GetNextValue(FileStream, FieldDataType_Float, -LARGEDOUBLE, LARGEDOUBLE, &IsOk); + } + + if (IVersion < 70) + Geom->DataType = FieldDataType_Float; + else + Geom->DataType = (FieldDataType_e)GetIoFileInt(FileStream, IVersion, 1, 2, &IsOk); + CHECK(VALID_GEOM_FIELD_DATA_TYPE(Geom->DataType)); + + Geom->Clipping = Clipping_ClipToViewport; /* default value for pre 101 versions */ + if (IVersion >= 101) + { + Geom->Clipping = (Clipping_e)GetIoFileInt(FileStream, IVersion, 0, 2, &IsOk); + /* + * The second clipping value was deprecated during v10 development and thus removed. + * This moved Clipping_ClipToFrame to the 2nd position from the 3rd, so we convert + * value 2 to ClipToFrame to support files made during v10 developement. + */ + if (Geom->Clipping == (Clipping_e)2) + Geom->Clipping = Clipping_ClipToFrame; + } + + if (IVersion < 50 || + Geom->GeomType == GeomType_LineSegs) + { + Geom->NumSegments = (SmInteger_t)GetIoFileInt(FileStream, IVersion, 1, MaxGeoSegments, &IsOk); +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + S = -1; + I = 0; + while ((S + 1 < Geom->NumSegments) && + !feof(FileStream->File) && IsOk) + { + S++; + Geom->NumSegPts[S] = GetIoFileInt(FileStream, IVersion, 1, MAXINDEX, &IsOk); + if ((I + Geom->NumSegPts[S] > MaxDataPts) && OkToLoad) + { + ErrMsgString = translate("Geometry is too big"); + IsOk = FALSE; + } + else + { + ReadBlock(FileStream, Geom->GeomData.Generic.V1Base, OkToLoad, Geom->DataType, I, I + Geom->NumSegPts[S] - 1, &IsOk); + ReadBlock(FileStream, Geom->GeomData.Generic.V2Base, OkToLoad, Geom->DataType, I, I + Geom->NumSegPts[S] - 1, &IsOk); + if (Geom->PositionCoordSys == CoordSys_Grid3D) + ReadBlock(FileStream, Geom->GeomData.Generic.V3Base, OkToLoad, Geom->DataType, I, I + Geom->NumSegPts[S] - 1, &IsOk); + I += Geom->NumSegPts[S]; + } + } + if (IsOk && (Geom->GeomType == GeomType_Rectangle)) /* IVersion < 50 */ + { + if (OkToLoad) + { + CopyFieldValue(Geom->GeomData.Generic.V1Base, 0, Geom->GeomData.Generic.V1Base, 2); + CopyFieldValue(Geom->GeomData.Generic.V2Base, 0, Geom->GeomData.Generic.V2Base, 2); + } + } + } + else if (Geom->GeomType == GeomType_Rectangle || + Geom->GeomType == GeomType_Ellipse) + { + double XX, YY; + XX = GetNextValue(FileStream, Geom->DataType, -LARGEDOUBLE, LARGEDOUBLE, &IsOk); + YY = GetNextValue(FileStream, Geom->DataType, -LARGEDOUBLE, LARGEDOUBLE, &IsOk); + if (OkToLoad) + { + SetFieldValue(Geom->GeomData.XYZ.XBase, 0, XX); + SetFieldValue(Geom->GeomData.XYZ.YBase, 0, YY); + } + Geom->NumSegments = 1; + Geom->NumSegPts[0] = 1; + } + else + { + double XX; + CHECK((Geom->GeomType == GeomType_Square) || + (Geom->GeomType == GeomType_Circle)); + XX = GetNextValue(FileStream, Geom->DataType, -LARGEDOUBLE, LARGEDOUBLE, &IsOk); + if (OkToLoad) + { + SetFieldValue(Geom->GeomData.XYZ.XBase, 0, XX); + } + Geom->NumSegments = 1; + Geom->NumSegPts[0] = 1; + } + + if (!IsOk) + ErrMsg(ErrMsgString); + + return (IsOk); +} + +/* + * Pass1 for text simply acknowledges that a text was + * parsed and skips over the text. + */ +Boolean_t ReadInText(FileStream_s *FileStream, + short IVersion, + Boolean_t OkToLoad, + Text_s *Text, + LgIndex_t MaxTextLen) +{ + LgIndex_t I; + FieldDataType_e FFT; + SmInteger_t TextLength = 0; + Boolean_t IsOk = TRUE; + TranslatedString ErrMsgString = translate("Invalid text record"); + + REQUIRE(VALID_REF(Text)); + + if (IVersion < 70) + FFT = FieldDataType_Float; + else + FFT = FieldDataType_Double; + + if (IVersion < 101) + I = GetIoFileInt(FileStream, IVersion, 0, 1, &IsOk); + else + I = GetIoFileInt(FileStream, IVersion, 0, 4, &IsOk); + + if (I == 0) + Text->PositionCoordSys = CoordSys_Grid; + else if (I == 1) + Text->PositionCoordSys = CoordSys_Frame; + /* + * I == 2 is for CoordSys_FrameOffset and is not used currently + * + * I == 3 is for the old window coordinate system + */ + else if (I == 4) + Text->PositionCoordSys = CoordSys_Grid3D; + else + { + ErrMsgString = translate("Invalid text coordinate system."); + IsOk = FALSE; + } + + Text->Scope = (Scope_e)GetIoFileInt(FileStream, IVersion, 0, 1, &IsOk); + Text->AnchorPos.Generic.V1 = GetNextValue(FileStream, FFT, -LARGEDOUBLE, LARGEDOUBLE, &IsOk); + Text->AnchorPos.Generic.V2 = GetNextValue(FileStream, FFT, -LARGEDOUBLE, LARGEDOUBLE, &IsOk); + if (IVersion >= 101) + Text->AnchorPos.Generic.V3 = GetNextValue(FileStream, FFT, -LARGEDOUBLE, LARGEDOUBLE, &IsOk); + else + Text->AnchorPos.Generic.V3 = 0.0; /* default value for pre 101 versions */ + + if (IVersion > 40) + Text->TextShape.Font = (Font_e)GetIoFileInt(FileStream, IVersion, 0, (LgIndex_t)Font_CourierBold, &IsOk); + else + Text->TextShape.Font = Font_Helvetica; + if (IVersion < 43) + GetNextValue(FileStream, FFT, -LARGEDOUBLE, LARGEDOUBLE, &IsOk); + if (IVersion < 70) + { + if (Text->PositionCoordSys == CoordSys_Grid) + Text->TextShape.SizeUnits = Units_Grid; + else + Text->TextShape.SizeUnits = Units_Frame; + } + else + Text->TextShape.SizeUnits = (Units_e)GetIoFileInt(FileStream, IVersion, 0, (LgIndex_t)Units_Point, &IsOk); + + Text->TextShape.Height = GetNextValue(FileStream, FFT, -LARGEDOUBLE, LARGEDOUBLE, &IsOk); + if (IVersion > 47) + { + Text->Box.BoxType = (TextBox_e)GetIoFileInt(FileStream, IVersion, 0, (LgIndex_t)TextBox_Hollow, &IsOk); + if (IVersion < 70) + { + if (Text->Box.BoxType == TextBox_Hollow) + Text->Box.BoxType = TextBox_Filled; + else if (Text->Box.BoxType == TextBox_Filled) + Text->Box.BoxType = TextBox_Hollow; + } + Text->Box.Margin = GetNextValue(FileStream, FFT, + TextBoxMarginInputSpec.Min, + TextBoxMarginInputSpec.Max, + &IsOk); + if (IVersion >= 70) + Text->Box.LineThickness = GetNextValue(FileStream, FFT, + LineThicknessInputSpec.Min, + LineThicknessInputSpec.Max, + &IsOk); + else + Text->Box.LineThickness = 0.01; + Text->Box.BColor = (ColorIndex_t)GetIoFileInt(FileStream, IVersion, 0, 255, &IsOk); + Text->Box.FillBColor = (ColorIndex_t)GetIoFileInt(FileStream, IVersion, 0, 255, &IsOk); + AdjustCustomColor(IVersion, &Text->Box.BColor); + AdjustCustomColor(IVersion, &Text->Box.FillBColor); + } + else + { + Text->Box.BoxType = TextBox_None; + Text->Box.Margin = 0.0; + Text->Box.BColor = White_C; + Text->Box.FillBColor = Black_C; + } + if (IVersion < 70) + { + Text->Angle = GetIoFileInt(FileStream, IVersion, -720, 720, &IsOk) / DEGPERRADIANS; + Text->LineSpacing = 1; + Text->Anchor = TextAnchor_Left; + } + else + { + Text->Angle = GetNextValue(FileStream, FFT, + TextAngleInputSpec.Min, + TextAngleInputSpec.Max, + &IsOk); + Text->LineSpacing = GetNextValue(FileStream, FFT, + TextLineSpacingInputSpec.Min, + TextLineSpacingInputSpec.Max, + &IsOk); + Text->Anchor = (TextAnchor_e)GetIoFileInt(FileStream, IVersion, 0, (LgIndex_t)TextAnchor_HeadRight, &IsOk); + } + + GetZoneAttachment(FileStream, IVersion, &Text->Zone, &Text->AttachToZone, &IsOk); + + Text->BColor = (ColorIndex_t)GetIoFileInt(FileStream, IVersion, 0, 255, &IsOk); + AdjustCustomColor(IVersion, &Text->BColor); + if (IVersion < 70) + TextLength = (short)GetIoFileInt(FileStream, IVersion, 0, 5000, &IsOk); + + ResetString(&Text->MacroFunctionCommand, NULL, TRUE); + + Text->Clipping = Clipping_ClipToViewport; /* default value for pre 101 versions */ + + if (IVersion < 70) + { + short I, S; + for (I = 0; I < TextLength; I++) + { + S = (short)GetIoFileInt(FileStream, IVersion, 0, 1000, &IsOk); + if (OkToLoad && (I <= MaxTextLen)) + Text->Text[I] = (char)S; + } + if (OkToLoad) + Text->Text[MIN(TextLength, MaxTextLen)] = '\0'; + } + else + { + char *S = NULL; + + if (IVersion >= 75) + { + IsOk = ReadMacroFunctionCommand(FileStream, + IVersion, + OkToLoad, + &Text->MacroFunctionCommand); + } /* IVersion >= 75 */ + + if (IVersion >= 101) + { + /* + * The second clipping value was deprecated during v10 development and thus removed. + * This moved Clipping_ClipToFrame to the 2nd position from the 3rd, so we convert + * value 2 to ClipToFrame to support files made during v10 developement. + */ + Text->Clipping = (Clipping_e)GetIoFileInt(FileStream, IVersion, 0, 2, &IsOk); + if (Text->Clipping == (Clipping_e)2) + Text->Clipping = Clipping_ClipToFrame; + } + + if (ReadInString(FileStream, + IVersion, + MaxTextLen, + &S, + OkToLoad)) + { + REQUIRE(!(S || OkToLoad) || VALID_REF(Text->Text)); + if (S) + { +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif /* TECPLOTKERNEL */ + if (IsOk) + { + strcpy(Text->Text, S); + } + FREE_ARRAY(S, "Release temp string for new text label"); + } + else if (OkToLoad) + Text->Text[0] = '\0'; + } + else + IsOk = FALSE; + } + + if (!IsOk) + ErrMsg(ErrMsgString); + + return (IsOk); +} + + +static Boolean_t CompareVersion(float Version, + char *VersionString, + Boolean_t IsByteOrderNative) +{ + char *VersionBuf = (char *) & Version; + + REQUIRE(VALID_REF(VersionString)); + + if (IsByteOrderNative) + return ((VersionString[0] == VersionBuf[0]) && + (VersionString[1] == VersionBuf[1]) && + (VersionString[2] == VersionBuf[2]) && + (VersionString[3] == VersionBuf[3])); + else + return ((VersionString[3] == VersionBuf[0]) && + (VersionString[2] == VersionBuf[1]) && + (VersionString[1] == VersionBuf[2]) && + (VersionString[0] == VersionBuf[3])); +} + +static float ValidVersions[] = {7.0F, + 6.3F, 6.2F, 6.1F, 6.0F, + 5.0F, + 4.7F, 4.6F, 4.5F, 4.4F, 4.3F, 4.2F, 4.1F, 4.0F + }; +#define NUMVALIDVERSIONS ((int)(sizeof(ValidVersions)/sizeof(ValidVersions[0]))) + + +/* + * Extra caution taken here in case value read is invalid float + */ +static Boolean_t GetDoubleVersion(char *VersionString, + float *FInputVersion, + Boolean_t IsByteOrderNative) +{ + int I; + REQUIRE(VALID_REF(FInputVersion)); + + for (I = 0; I < NUMVALIDVERSIONS; I++) + if (CompareVersion(ValidVersions[I], VersionString, IsByteOrderNative)) + { + *FInputVersion = ValidVersions[I]; + return (TRUE); + } + return (FALSE); +} + + +static short GetNewInputVersion(FileStream_s *FileStream) +{ + /* + * + */ + char Buf[4]; + short IVersion = 0; + short I; + LgIndex_t OneValue; + Boolean_t IsOk = TRUE; + + REQUIRE(VALID_REF(FileStream) && VALID_REF(FileStream->File)); + REQUIRE(FileStream->IsByteOrderNative); + + if (TP_FREAD(Buf, 4, 1, FileStream->File) != 1) + return (0); + + if (strncmp(Buf, "#!TD", 4)) + return (0); + + if (TP_FREAD(Buf, 4, 1, FileStream->File) != 1) + return (0); + + if (Buf[0] != 'V') + return (0); + + I = 1; + while ((I < 4) && isdigit(Buf[I])) + IVersion = IVersion * 10 + Buf[I++] - '0'; + + if (IVersion < 70) + return (0); + else if (IVersion > TecplotBinaryFileVersion) + { + ErrMsg(translate("Binary file version newer than Tecplot version. " + "Upgrade Tecplot or use an older Preplot to produce " + "the datafile.")); + return (IVersion); + } + + /* + * Determine Byte Order. + */ + + OneValue = GetIoFileInt(FileStream, + IVersion, + -MAXINDEX, + MAXINDEX, + &IsOk); + + if (!IsOk) + return (0); + + FileStream->IsByteOrderNative = (OneValue == 1); + + return (IVersion); +} + +/** + * Return value of zero is to be considered as an invalid + * tecplot binary datafile header. Actually binary files + * older than version 4.0 (return value of 40) are not supported + * (See notes in preplot.c). + */ +short GetInputVersion(FileStream_s *FileStream) +{ + Boolean_t IsOk = TRUE; + float FInputVersion; + short IVersion; + char VersionString[4]; + FileOffset_t StartOffset = 0; + + /* + * First check to see if file uses new + * input version format. + */ + + /* keep track of our start offset */ + StartOffset = TP_FTELL(FileStream->File); + + IVersion = GetNewInputVersion(FileStream); + + if (IVersion > TecplotBinaryFileVersion) + return IVersion; /* unsupported version */ + else if (IVersion == 0) + { + /* rewind to clear any errors and seek to the start offset */ + rewind(FileStream->File); + IsOk = (TP_FSEEK(FileStream->File, StartOffset, SEEK_SET) == 0); + + if (IsOk && TP_FREAD(VersionString, 4, 1, FileStream->File) == 1) + { + /* try both native and foreign versions numbers */ + if (!GetDoubleVersion(VersionString, &FInputVersion, FileStream->IsByteOrderNative)) + { + FileStream->IsByteOrderNative = !FileStream->IsByteOrderNative; /* ...reverse the byte order */ + IsOk = GetDoubleVersion(VersionString, &FInputVersion, FileStream->IsByteOrderNative); + } + if (IsOk) + IVersion = ROUNDS(FInputVersion * 10); + } + } + + if (IsOk) + return (IVersion); + else + return ((short)0); +} + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if !defined ENGINE /* TODO(RMS)-H 12/12/2005: ENGINE: refactor to use just the Interrupted flag as-is */ +#else +#endif +#endif + + + +/********************************************************************** + ********************************************************************** + ********************** OUTPUT ************************** + ********************************************************************** + **********************************************************************/ + + +/** + * Byte blocks cannot be unaligned or reversed in bytes + */ +Boolean_t WriteBinaryByteBlock(FileStream_s *FileStream, + const Byte_t *ByteValues, + const HgIndex_t NumValues) +{ + REQUIRE(VALID_REF(FileStream) && VALID_REF(FileStream->File)); + REQUIRE(VALID_REF(ByteValues)); + REQUIRE(NumValues >= 0); + + Boolean_t IsOk = TP_FWRITE(ByteValues, + sizeof(Byte_t), + (size_t)NumValues, + FileStream->File) == (size_t)NumValues; + + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + +/** + * Type Byte_t cannot be unaligned or reversed in byte order + */ +static inline Boolean_t WriteBinaryByte(FileStream_s *FileStream, + Byte_t ByteValue) +{ + REQUIRE(VALID_REF(FileStream) && VALID_REF(FileStream->File)); + Boolean_t IsOk = WriteBinaryByteBlock(FileStream, &ByteValue, 1); + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + +/** + */ +template <typename T> +void CopyAndReverseUnalignedBytes(T *DstBuffer, + const Byte_t *SrcBuffer) +{ + REQUIRE(VALID_REF(DstBuffer)); + REQUIRE(VALID_REF(SrcBuffer)); + size_t typeSize = sizeof(T); + for (size_t ii = 0; ii < typeSize; ii++) + ((Byte_t *)(DstBuffer))[ii] = ((Byte_t *)(SrcBuffer))[typeSize-1-ii]; +} + +/** + */ +template <typename T> +void CopyUnalignedBytes(T *DstBuffer, + const Byte_t *SrcBuffer) +{ + REQUIRE(VALID_REF(DstBuffer)); + REQUIRE(VALID_REF(SrcBuffer)); + for (size_t ii = 0; ii < sizeof(T); ii++) + ((Byte_t *)(DstBuffer))[ii] = ((Byte_t *)(SrcBuffer))[ii]; +} + +/** + */ +template <typename T> +Boolean_t WriteBinaryDataUnaligned(FileStream_s *FileStream, + const Byte_t *ValueBuffer, + const Boolean_t ValueInNativeOrder) +{ + REQUIRE(VALID_REF(FileStream) && VALID_FILE_HANDLE(FileStream->File)); + REQUIRE(VALID_REF(ValueBuffer)); + REQUIRE(VALID_BOOLEAN(ValueInNativeOrder)); + + T DataValue; + if (ValueInNativeOrder != FileStream->IsByteOrderNative) + CopyAndReverseUnalignedBytes<T>(&DataValue, ValueBuffer); + else + CopyUnalignedBytes<T>(&DataValue, ValueBuffer); + + Boolean_t IsOk = TP_FWRITE(&DataValue, sizeof(T), 1, FileStream->File) == 1; + + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + + +/** + * This is used in many places and requires the value be in proper order. + */ +Boolean_t WriteBinaryInt16(FileStream_s *FileStream, + Int16_t Value) +{ + Boolean_t IsOk; + REQUIRE(VALID_REF(FileStream) && VALID_REF(FileStream->File)); + REQUIRE("Value can be any Int16_t"); + IsOk = WriteBinaryDataUnaligned<Int16_t>(FileStream, (Byte_t *) & Value, TRUE/*ValueInNativeOrder*/); + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + +/** + * This is used in many places and requires the value be in proper order. + */ +Boolean_t WriteBinaryInt32(FileStream_s *FileStream, + Int32_t Value) +{ + Boolean_t IsOk; + REQUIRE(VALID_REF(FileStream) && VALID_REF(FileStream->File)); + REQUIRE("Value can be any Int32_t"); + IsOk = WriteBinaryDataUnaligned<Int32_t>(FileStream, (Byte_t *) & Value, TRUE/*ValueInNativeOrder*/); + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + +/** + */ +template <typename T> +Boolean_t WriteBinaryBlockUnaligned(FileStream_s *FileStream, + const Byte_t *Values, + const HgIndex_t NumValues, + const Boolean_t ValuesInNativeOrdering) +{ + Boolean_t IsOk = TRUE; + Boolean_t WriteEachValueSeparately; + + REQUIRE(VALID_REF(FileStream) && VALID_REF(FileStream->File)); + REQUIRE(VALID_REF(Values)); + REQUIRE(NumValues >= 0); + REQUIRE(VALID_BOOLEAN(ValuesInNativeOrdering)); + + WriteEachValueSeparately = (ValuesInNativeOrdering != FileStream->IsByteOrderNative); + + if (WriteEachValueSeparately) + { + for (HgIndex_t NIndex = 0; IsOk && NIndex < NumValues; NIndex++) + { + IsOk = WriteBinaryDataUnaligned<T>(FileStream, Values + NIndex * sizeof(T), ValuesInNativeOrdering); + } + } + else + { +#if 1 + size_t NumBytesToWrite = NumValues * sizeof(T); + size_t NumBytesWritten = TP_FWRITE(Values, sizeof(Byte_t), NumBytesToWrite, FileStream->File); + IsOk = NumBytesToWrite == NumBytesWritten; +#else + IsOk = WriteBinaryByteBlock(FileStream, Values, NumValues * sizeof(T)); +#endif + } + + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + + +/** + * Use Byte_t instead of Int16_t to support unaligned values + */ +Boolean_t WriteBinaryInt16BlockUnaligned(FileStream_s *FileStream, + Byte_t *Int16Values, + HgIndex_t NumValues, + Boolean_t ValuesInNativeOrdering) +{ + REQUIRE(VALID_REF(FileStream) && VALID_REF(FileStream->File)); + REQUIRE(VALID_REF(Int16Values)); + REQUIRE(NumValues >= 0); + REQUIRE(VALID_BOOLEAN(ValuesInNativeOrdering)); + + Boolean_t IsOk = WriteBinaryBlockUnaligned<Int16_t>(FileStream, + Int16Values, + NumValues, + ValuesInNativeOrdering); + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + + +/** + * Use Byte_t instead of Int32_t to support unaligned values + */ +Boolean_t WriteBinaryInt32BlockUnaligned(FileStream_s *FileStream, + Byte_t *Int32Values, + HgIndex_t NumValues, + Boolean_t ValuesInNativeOrdering) +{ + REQUIRE(VALID_REF(FileStream) && VALID_REF(FileStream->File)); + REQUIRE(VALID_REF(Int32Values)); + REQUIRE(NumValues >= 0); + REQUIRE(VALID_BOOLEAN(ValuesInNativeOrdering)); + + Boolean_t IsOk = WriteBinaryBlockUnaligned<Int32_t>(FileStream, + Int32Values, + NumValues, + ValuesInNativeOrdering); + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + + + +/** + */ +Boolean_t WriteBinaryReal(FileStream_s *FileStream, + double RR, + FieldDataType_e FieldDataType) +{ + Boolean_t IsOk = FALSE; /* ...quite compiler */ + + REQUIRE(VALID_REF(FileStream) && VALID_REF(FileStream->File)); + REQUIRE((FieldDataType == FieldDataType_Float) || + (FieldDataType == FieldDataType_Double) || + (FieldDataType == FieldDataType_Byte)); + + switch (FieldDataType) + { + case FieldDataType_Float : + { + float FloatVal = CONVERT_DOUBLE_TO_FLOAT(RR); + IsOk = WriteBinaryDataUnaligned<float>(FileStream, (Byte_t *) & FloatVal, TRUE/*NativeOrdering*/); + } break; + case FieldDataType_Double : + { + double DoubleVal = CLAMP_DOUBLE(RR); + IsOk = WriteBinaryDataUnaligned<double>(FileStream, (Byte_t *) & DoubleVal, TRUE/*NativeOrdering*/); + } break; + case FieldDataType_Byte : + { + /* Note: type Byte cannot be unaligned or reversed in bytes */ + Byte_t B; + if (RR > 255) + B = 255; + else if (RR < 0) + B = 0; + else + B = (Byte_t)RR; + IsOk = WriteBinaryByte(FileStream, B); + } break; + default: CHECK(FALSE); break; + } + + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + + +Boolean_t WriteFieldDataType(FileStream_s *FileStream, + FieldDataType_e FDT, + Boolean_t WriteBinary) +{ + if (WriteBinary) + return (WriteBinaryInt32(FileStream, (LgIndex_t)FDT)); + else + { + short S = 0; + switch (FDT) + { + case FieldDataType_Float : S = fprintf(FileStream->File, "SINGLE "); break; + case FieldDataType_Double : S = fprintf(FileStream->File, "DOUBLE "); break; + case FieldDataType_Int32 : S = fprintf(FileStream->File, "LONGINT "); break; + case FieldDataType_Int16 : S = fprintf(FileStream->File, "SHORTINT "); break; + case FieldDataType_Byte : S = fprintf(FileStream->File, "BYTE "); break; + case FieldDataType_Bit : S = fprintf(FileStream->File, "BIT "); break; + default: CHECK(FALSE); + } + return (FPRINTFOK(S)); + } +} + +/** + */ +template <typename T> +Boolean_t WriteBinaryChecksumByteValues(FileStream_s *FileStream, + const Byte_t *ByteValues, + const HgIndex_t NumValues) +{ + REQUIRE(VALID_REF(FileStream) && VALID_FILE_HANDLE(FileStream->File)); + REQUIRE(VALID_REF(ByteValues)); + REQUIRE(NumValues >= 1); + + Boolean_t IsOk; + if (NumValues == 1) + IsOk = WriteBinaryDataUnaligned<T>(FileStream, ByteValues, TRUE); + else + IsOk = WriteBinaryBlockUnaligned<T>(FileStream, ByteValues, NumValues, TRUE); + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + +/** + * For FieldData of Type Bit, use WriteBinaryFieldDataBlockOfTypeBit instead. + */ +template <typename T> +Boolean_t WriteBinaryFieldDataBlockOfType(FileStream_s *FileStream, + const FieldData_pa FieldData, + const LgIndex_t StartOffset, + const LgIndex_t NumValues) +{ +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + Boolean_t IsOk = FALSE; + if (IsFieldDataDirectAccessAllowed(FieldData)) + { + Byte_t *ByteArray = GetFieldDataBytePtr(FieldData) + StartOffset * sizeof(T); + IsOk = WriteBinaryChecksumByteValues<T>(FileStream, ByteArray, (HgIndex_t)NumValues); + } + else + { + for (LgIndex_t Offset = StartOffset; Offset < NumValues; Offset++) + { + T ValueBuffer = (T)GetFieldValue(FieldData, Offset); + Byte_t *ByteValue = (Byte_t *) & ValueBuffer; + IsOk = WriteBinaryChecksumByteValues<T>(FileStream, ByteValue, 1); + } + } + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + +static Boolean_t WriteBinaryFieldDataBlockOfTypeBit(FileStream_s *FileStream, + const FieldData_pa FieldData, + const LgIndex_t StartOffset, /* Not used */ + const LgIndex_t NumValues) +{ +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + Boolean_t IsOk = FALSE; + size_t NumBytes = 1 + (NumValues - 1) / 8; + if (IsFieldDataDirectAccessAllowed(FieldData)) + { + Byte_t *ByteArray = GetFieldDataBytePtr(FieldData); + IsOk = WriteBinaryChecksumByteValues<Byte_t>(FileStream, ByteArray, (HgIndex_t)NumBytes); + } + else + { + // Bits are written out a Byte at a time and since we only come in here every 8th + // bit, make sure to assemble a Byte value from the next 8 bits. + for (LgIndex_t Offset = 0; Offset < NumValues; Offset += 8) + { + Byte_t ValueBuffer = 0; + for (int ii = 0; ii < 8; ii++) + { + Byte_t CurBit = (Byte_t)GetFieldValue(FieldData, Offset + ii); + ValueBuffer |= (CurBit << ii); + } + IsOk = WriteBinaryChecksumByteValues<Byte_t>(FileStream, &ValueBuffer, 1); + } + } + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + +/* + */ +Boolean_t WriteBinaryFieldDataBlock(FileStream_s *FileStream, + FieldData_pa FieldData, + LgIndex_t StartOffset, + LgIndex_t NumValues) +{ +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + Boolean_t IsOk = FALSE; + switch (GetFieldDataType(FieldData)) + { + case FieldDataType_Float : IsOk = WriteBinaryFieldDataBlockOfType<float>(FileStream, FieldData, StartOffset, NumValues); break; + case FieldDataType_Double : IsOk = WriteBinaryFieldDataBlockOfType<double>(FileStream, FieldData, StartOffset, NumValues); break; + case FieldDataType_Int32 : IsOk = WriteBinaryFieldDataBlockOfType<Int32_t>(FileStream, FieldData, StartOffset, NumValues); break; + case FieldDataType_Int16 : IsOk = WriteBinaryFieldDataBlockOfType<Int16_t>(FileStream, FieldData, StartOffset, NumValues); break; + case FieldDataType_Byte : IsOk = WriteBinaryFieldDataBlockOfType<Byte_t>(FileStream, FieldData, StartOffset, NumValues); break; + case FieldDataType_Bit : IsOk = WriteBinaryFieldDataBlockOfTypeBit(FileStream, FieldData, StartOffset, NumValues); break; + default: CHECK(FALSE); break; + } + + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + + +static Boolean_t WriteASCIIFieldDataValue(FileStream_s *FileStream, + FieldData_pa FieldData, + LgIndex_t Offset, + SmInteger_t AsciiPrecision) +{ + Boolean_t IsOk = FALSE; /* ...quiet compiler */ + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + double V = 0.0; + char buffer[100*MAX_SIZEOFUTF8CHAR]; + char *AsciiValue = buffer; + +#ifdef TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + V = GetFieldValue(FieldData, Offset); + + switch (GetFieldDataType(FieldData)) + { + case FieldDataType_Float : + case FieldDataType_Double : + /*IsOk = FPRINTFOK(fprintf(FileStream->File," %.*E",(int)AsciiPrecision,V)); */ + sprintf(buffer, " %.*E", (int)AsciiPrecision, V); + break; + case FieldDataType_Int32 : + /* IsOk = FPRINTFOK(fprintf(FileStream->File," %*d",(int)AsciiPrecision,ROUNDL(V))); */ + sprintf(buffer, " %*d", (int)AsciiPrecision, ROUNDL(V)); + break; + case FieldDataType_Int16 : + /* IsOk = FPRINTFOK(fprintf(FileStream->File," %6d",ROUND2(V))); */ + sprintf(buffer, " %6d", ROUND2(V)); + break; + case FieldDataType_Byte : + /* IsOk = FPRINTFOK(fprintf(FileStream->File," %3d",ROUNDS(V))); */ + sprintf(buffer, " %3d", ROUNDS(V)); + break; + case FieldDataType_Bit : + /* IsOk = FPRINTFOK(fprintf(FileStream->File," %c",((V == 0) ? '0' : '1'))); */ + sprintf(buffer, " %c", ((V == 0) ? '0' : '1')); + break; + default: CHECK(FALSE); break; + } + IsOk = FPRINTFOK(fprintf(FileStream->File, buffer)); +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + ENSURE(VALID_BOOLEAN(IsOk)); + return (IsOk); +} + + +/** + */ +Boolean_t WriteCCFieldDataBlock(FileStream_s *FileStream, + FieldData_pa FieldData, + Boolean_t IsOrderedData, + LgIndex_t NumIPts, + LgIndex_t NumJPts, + LgIndex_t NumKPts, + Boolean_t WriteBinary, + SmInteger_t AsciiPrecision) +{ + Boolean_t IsOk = TRUE; + LgIndex_t NumValues; + LgIndex_t I, J, K; + LgIndex_t NumIJPts = -1; + LgIndex_t IEnd = -1; + LgIndex_t JEnd = -1; + LgIndex_t KEnd = -1; + Boolean_t IsLinear = -1; + + REQUIRE(VALID_REF(FileStream) && VALID_REF(FileStream->File)); + REQUIRE(VALID_REF(FieldData)); + REQUIRE(VALID_BOOLEAN(IsOrderedData)); + REQUIRE(NumIPts >= 0); + REQUIRE(NumJPts >= 0); + REQUIRE(NumKPts >= 0); + REQUIRE(VALID_BOOLEAN(WriteBinary)); + REQUIRE(IMPLICATION(!WriteBinary, AsciiPrecision >= 0)); + + /* + * As of version 103 Tecplot writes binary data files so that ordered cell + * centered field data includes the ghost cells. This makes it much easier + * for Tecplot to map the data when reading by simply writing out + * FieldData->NumValues. As of version 104 the ghost cells of the slowest + * moving index are not included but that does effect the output as it is + * still FieldData->NumValues. + */ + if (IsOrderedData && !WriteBinary) + { + /* + * Ordered ASCII output is always layed out using + * DataValueStructure_Classic format. + */ + NumIJPts = NumIPts * NumJPts; + IEnd = MAX(NumIPts - 1, 1); + JEnd = MAX(NumJPts - 1, 1); + KEnd = MAX(NumKPts - 1, 1); + NumValues = (IEnd * JEnd * KEnd); + IsLinear = ((NumJPts == 1 && NumKPts == 1) || + (NumIPts == 1 && NumKPts == 1) || + (NumIPts == 1 && NumJPts == 1)); + } + else + { + NumValues = GetFieldDataNumValues(FieldData); + } + + if (WriteBinary) + { + IsOk = WriteBinaryFieldDataBlock(FileStream, FieldData, 0, NumValues); + } + else + { + LgIndex_t NumValuesPerLine = 80 / (AsciiPrecision + 5); + if (IsOrderedData && !IsLinear) + { + LgIndex_t ValueIndex = 0; + for (K = 0; K < KEnd && IsOk; K++) + for (J = 0; J < JEnd && IsOk; J++) + for (I = 0; I < IEnd && IsOk; I++) + { + LgIndex_t CellIndex = I + (J * NumIPts) + (K * NumIJPts); + IsOk = WriteASCIIFieldDataValue(FileStream, + FieldData, + CellIndex, + AsciiPrecision); + if ((ValueIndex + 1) % NumValuesPerLine == 0 || ValueIndex == NumValues - 1) + IsOk = (fputc('\n', FileStream->File) != EOF); + ValueIndex++; + } + } + else + { + for (I = 0; I < NumValues && IsOk; I++) + { + IsOk = WriteASCIIFieldDataValue(FileStream, + FieldData, + I, + AsciiPrecision); + if ((I + 1) % NumValuesPerLine == 0 || I == NumValues - 1) + IsOk = (fputc('\n', FileStream->File) != EOF); + } + } + } + + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + + +Boolean_t DumpDatafileString(FileStream_s *FileStream, + const char *S, + Boolean_t WriteBinary) +{ + Boolean_t IsOk = TRUE; + const char *CPtr = S; + if (WriteBinary) + { + const char *CPtr = S; + while (IsOk && CPtr && *CPtr) + IsOk = WriteBinaryInt32(FileStream, (LgIndex_t)(unsigned char) * CPtr++); + if (IsOk) + IsOk = WriteBinaryInt32(FileStream, 0); + } + else + { + fputc('"', FileStream->File); + while (CPtr && *CPtr) + { + if (*CPtr == '\n') + { + CPtr++; + fputc('\\', FileStream->File); + fputc('\\', FileStream->File); + fputc('n', FileStream->File); + } + else + { + if ((*CPtr == '"') || (*CPtr == '\\')) + fputc('\\', FileStream->File); + fputc(*CPtr++, FileStream->File); + } + } + fputc('"', FileStream->File); + IsOk = (fputc('\n', FileStream->File) != EOF); + } + return (IsOk); +} + + +static void WriteAsciiColor(FILE *File, + ColorIndex_t Color) +{ + if (Color >= FirstCustomColor && Color <= LastCustomColor) + fprintf(File, "CUST%1d ", Color - FirstCustomColor + 1); + else + { + switch (Color) + { + case Black_C : fprintf(File, "BLACK "); break; + case Red_C : fprintf(File, "RED "); break; + case Green_C : fprintf(File, "GREEN "); break; + case Blue_C : fprintf(File, "BLUE "); break; + case Cyan_C : fprintf(File, "CYAN "); break; + case Yellow_C : fprintf(File, "YELLOW "); break; + case Purple_C : fprintf(File, "PURPLE "); break; + case White_C : fprintf(File, "WHITE "); break; + } + } +} + +static void WriteAsciiTextGeomBasics(FILE* File, + CoordSys_e CoordSys, + Boolean_t AttachToZone, + EntIndex_t Zone, + ColorIndex_t Color, + Scope_e Scope, + Boolean_t IncludeZ, + Boolean_t WriteGridDataAsPolar, + AnchorPos_u const* AnchorPos, + double ScaleFact) +{ + REQUIRE(VALID_REF(File)); + REQUIRE(VALID_TEXT_COORDSYS(CoordSys) || VALID_GEOM_COORDSYS(CoordSys)); + REQUIRE(VALID_BOOLEAN(AttachToZone)); + REQUIRE(IMPLICATION(AttachToZone, Zone >= 0)); + REQUIRE(VALID_ENUM(Scope, Scope_e)); + REQUIRE(VALID_BOOLEAN(IncludeZ)); + REQUIRE(VALID_BOOLEAN(WriteGridDataAsPolar)); + REQUIRE(VALID_REF(AnchorPos)); + + fprintf(File, "CS="); + if (CoordSys == CoordSys_Frame) + fprintf(File, "FRAME"); + else if (CoordSys == CoordSys_Grid) + fprintf(File, "GRID"); + /* + * Not currently used + * + else if (CoordSys == CoordSys_FrameOffset) + fprintf(File,"FRAMEOFFSET"); + */ + else if (CoordSys == CoordSys_Grid3D) + fprintf(File, "GRID3D"); + else + CHECK(FALSE); + + if (CoordSys == CoordSys_Grid && !IncludeZ && WriteGridDataAsPolar) + { + fprintf(File, "\nTHETA=%.12G,R=%.12G", + ScaleFact*AnchorPos->ThetaR.Theta, + ScaleFact*AnchorPos->ThetaR.R); + CHECK(!IncludeZ); + } + else + { + fprintf(File, "\nX=%.12G,Y=%.12G", + ScaleFact*AnchorPos->XYZ.X, + ScaleFact*AnchorPos->XYZ.Y); + if (IncludeZ) + fprintf(File, ",Z=%.12G", ScaleFact*AnchorPos->XYZ.Z); + } + + if (AttachToZone) + fprintf(File, "\nZN=%d", Zone + 1); + + fprintf(File, "\nC="); + WriteAsciiColor(File, Color); + + fprintf(File, "\nS="); + if (Scope == Scope_Global) + fprintf(File, "GLOBAL"); + else if (Scope == Scope_Local) + fprintf(File, "LOCAL"); + else + CHECK(FALSE); + + fputc('\n', File); +} + + +bool DumpGeometry(FileStream_s* FileStream, + Geom_s const* Geom, + Boolean_t WriteBinary, + Boolean_t WriteGridDataAsPolar) +{ + LgIndex_t I, Index; + LgIndex_t SegIndex; + bool IsOk = TRUE; + FieldDataType_e FDT; + + REQUIRE(VALID_REF(FileStream) && VALID_REF(FileStream->File)); + REQUIRE(VALID_REF(Geom)); + REQUIRE(Geom->GeomType != GeomType_Image); + + if (WriteBinary) + { + WriteBinaryReal(FileStream, GeomMarker, FieldDataType_Float); + if (Geom->PositionCoordSys == CoordSys_Grid) + WriteBinaryInt32(FileStream, 0); + else if (Geom->PositionCoordSys == CoordSys_Frame) + WriteBinaryInt32(FileStream, 1); +#if 0 /* + * Not currently used + */ + else if (Geom->PositionCoordSys == CoordSys_FrameOffset) + WriteBinaryInt32(FileStream, 2); +#endif + /* + * PositionCoordSys == 3 is for old window coordinate system + */ + else if (Geom->PositionCoordSys == CoordSys_Grid3D) + WriteBinaryInt32(FileStream, 4); + else + CHECK(FALSE); + + WriteBinaryInt32(FileStream, (LgIndex_t)Geom->Scope); + WriteBinaryInt32(FileStream, (LgIndex_t)Geom->DrawOrder); + WriteBinaryReal(FileStream, Geom->AnchorPos.Generic.V1, FieldDataType_Double); + WriteBinaryReal(FileStream, Geom->AnchorPos.Generic.V2, FieldDataType_Double); + WriteBinaryReal(FileStream, Geom->AnchorPos.Generic.V3, FieldDataType_Double); + if (Geom->AttachToZone) + WriteBinaryInt32(FileStream, (LgIndex_t)Geom->Zone); + else + WriteBinaryInt32(FileStream, (LgIndex_t) - 1); + WriteBinaryInt32(FileStream, (LgIndex_t)Geom->BColor); + WriteBinaryInt32(FileStream, (LgIndex_t)Geom->FillBColor); + WriteBinaryInt32(FileStream, (LgIndex_t)Geom->IsFilled); + CHECK(Geom->GeomType != GeomType_LineSegs3D); /* deprecated */ + WriteBinaryInt32(FileStream, (LgIndex_t)Geom->GeomType); + WriteBinaryInt32(FileStream, (LgIndex_t)Geom->LinePattern); + WriteBinaryReal(FileStream, Geom->PatternLength, FieldDataType_Double); + WriteBinaryReal(FileStream, Geom->LineThickness, FieldDataType_Double); + WriteBinaryInt32(FileStream, (LgIndex_t)Geom->NumEllipsePts); + WriteBinaryInt32(FileStream, (LgIndex_t)Geom->ArrowheadStyle); + WriteBinaryInt32(FileStream, (LgIndex_t)Geom->ArrowheadAttachment); + WriteBinaryReal(FileStream, Geom->ArrowheadSize, FieldDataType_Double); + + WriteBinaryReal(FileStream, Geom->ArrowheadAngle, FieldDataType_Double); + + /* MACRO FUNCTION COMMAND */ + DumpDatafileString(FileStream, Geom->MacroFunctionCommand, TRUE); + + /* + * Assume geometry has X,Y (and Z) all using same field + * data type. + */ + FDT = GetGeomFieldDataType(Geom); + WriteFieldDataType(FileStream, FDT, TRUE); + WriteBinaryInt32(FileStream, (LgIndex_t)Geom->Clipping); + + if (Geom->GeomType == GeomType_LineSegs) + { + short S; + WriteBinaryInt32(FileStream, Geom->NumSegments); + I = 0; + for (S = 0; IsOk && (S < Geom->NumSegments); S++) + { + WriteBinaryInt32(FileStream, Geom->NumSegPts[S]); + WriteBinaryFieldDataBlock(FileStream, Geom->GeomData.Generic.V1Base, I, Geom->NumSegPts[S]); + IsOk = WriteBinaryFieldDataBlock(FileStream, Geom->GeomData.Generic.V2Base, I, Geom->NumSegPts[S]) == TRUE; + if (Geom->PositionCoordSys == CoordSys_Grid3D) + IsOk = WriteBinaryFieldDataBlock(FileStream, Geom->GeomData.Generic.V3Base, I, Geom->NumSegPts[S]) == TRUE; + I += Geom->NumSegPts[S]; + } + } + else if (Geom->GeomType == GeomType_Rectangle || + Geom->GeomType == GeomType_Ellipse) + { + WriteBinaryReal(FileStream, GetFieldValue(Geom->GeomData.XYZ.XBase, 0), FDT); + IsOk = WriteBinaryReal(FileStream, GetFieldValue(Geom->GeomData.XYZ.YBase, 0), FDT) == TRUE; + } + else + { + CHECK((Geom->GeomType == GeomType_Square) || + (Geom->GeomType == GeomType_Circle)); + IsOk = WriteBinaryReal(FileStream, GetFieldValue(Geom->GeomData.XYZ.XBase, 0), FDT) == TRUE; + } + + } + else + { + double ScaleFact; + if (Geom->PositionCoordSys == CoordSys_Frame) + ScaleFact = 100.0; + else + ScaleFact = 1.0; + + fprintf(FileStream->File, "GEOMETRY\nF=POINT\n"); + WriteAsciiTextGeomBasics(FileStream->File, + Geom->PositionCoordSys, + Geom->AttachToZone, + Geom->Zone, + Geom->BColor, + Geom->Scope, + TRUE, + WriteGridDataAsPolar, + &Geom->AnchorPos, + ScaleFact); + + switch (Geom->LinePattern) + { + case LinePattern_Solid : fprintf(FileStream->File, "L=SOLID\n"); break; + case LinePattern_Dashed : fprintf(FileStream->File, "L=DASHED\n"); break; + case LinePattern_DashDot : fprintf(FileStream->File, "L=DASHDOT\n"); break; + case LinePattern_Dotted : fprintf(FileStream->File, "L=DOTTED\n"); break; + case LinePattern_LongDash : fprintf(FileStream->File, "L=LONGDASH\n"); break; + case LinePattern_DashDotDot : fprintf(FileStream->File, "L=DASHDOTDOT\n"); break; + default: CHECK(FALSE); break; + } + fprintf(FileStream->File, "PL=%.12G\n", + Geom->PatternLength*PatternLengthInputSpec.InterfaceAdjust.ScaleFact); + fprintf(FileStream->File, "LT=%.12G\n", + Geom->LineThickness*LineThicknessInputSpec.InterfaceAdjust.ScaleFact); + + if (Geom->IsFilled) + { + fprintf(FileStream->File, "FC="); + WriteAsciiColor(FileStream->File, Geom->FillBColor); + } + + if (Geom->Clipping == Clipping_ClipToViewport) + fprintf(FileStream->File, "CLIPPING=CLIPTOVIEWPORT\n"); + else if (Geom->Clipping == Clipping_ClipToFrame) + fprintf(FileStream->File, "CLIPPING=CLIPTOFRAME\n"); + else + CHECK(FALSE); + + if (Geom->DrawOrder == DrawOrder_AfterData) + fprintf(FileStream->File, "DRAWORDER=AFTERDATA\n"); + else if (Geom->DrawOrder == DrawOrder_BeforeData) + fprintf(FileStream->File, "DRAWORDER=BEFOREDATA\n"); + else + CHECK(FALSE); + + /* Macro function command */ + fprintf(FileStream->File, "MFC="); + DumpDatafileString(FileStream, Geom->MacroFunctionCommand, FALSE); + + if ((Geom->GeomType == GeomType_Circle) || (Geom->GeomType == GeomType_Ellipse)) + fprintf(FileStream->File, "EP=%ld\n", (long)Geom->NumEllipsePts); + + if (Geom->GeomType == GeomType_LineSegs && Geom->PositionCoordSys != CoordSys_Grid3D) + { + switch (Geom->ArrowheadStyle) + { + case ArrowheadStyle_Plain : fprintf(FileStream->File, "AST=PLAIN\n"); break; + case ArrowheadStyle_Filled : fprintf(FileStream->File, "AST=FILLED\n"); break; + case ArrowheadStyle_Hollow : fprintf(FileStream->File, "AST=HOLLOW\n"); break; + default: CHECK(FALSE); break; + } + + switch (Geom->ArrowheadAttachment) + { + case ArrowheadAttachment_None : break; + case ArrowheadAttachment_AtBeginning : fprintf(FileStream->File, "AAT=BEGINNING\n"); break; + case ArrowheadAttachment_AtEnd : fprintf(FileStream->File, "AAT=END\n"); break; + case ArrowheadAttachment_AtBothEnds : fprintf(FileStream->File, "AAT=BOTH\n"); break; + default: CHECK(FALSE); break; + } + if (Geom->ArrowheadAttachment != ArrowheadAttachment_None) + { + fprintf(FileStream->File, "ASZ=%.12G\n", + Geom->ArrowheadSize*ArrowheadSizeInputSpec.InterfaceAdjust.ScaleFact); + fprintf(FileStream->File, "AAN=%.12G\n", + Geom->ArrowheadAngle*ArrowheadAngleInputSpec.InterfaceAdjust.ScaleFact); + } + } + + switch (Geom->GeomType) + { + case GeomType_LineSegs : + { + fprintf(FileStream->File, "T=LINE\n"); + fprintf(FileStream->File, "DT="); + WriteFieldDataType(FileStream, GetFieldDataType(Geom->GeomData.Generic.V1Base), FALSE); + fputc('\n', FileStream->File); + fprintf(FileStream->File, "%d\n", (int)Geom->NumSegments); + SegIndex = 0; + for (I = 0; IsOk && (I < Geom->NumSegments); I++) + { + fprintf(FileStream->File, "%ld\n", (long)Geom->NumSegPts[I]); + for (Index = 0; Index < Geom->NumSegPts[I]; Index++) + { + fprintf(FileStream->File, "%.12G ", GetFieldValue(Geom->GeomData.Generic.V1Base, SegIndex + Index)*ScaleFact); + fprintf(FileStream->File, "%.12G", GetFieldValue(Geom->GeomData.Generic.V2Base, SegIndex + Index)*ScaleFact); + if (Geom->PositionCoordSys == CoordSys_Grid3D) + IsOk = FPRINTFOK(fprintf(FileStream->File, " %.12G\n", GetFieldValue(Geom->GeomData.Generic.V3Base, SegIndex + Index))); + else + IsOk = (Boolean_t)(fputc('\n', FileStream->File) != EOF); + } + SegIndex += Geom->NumSegPts[I]; + } + } break; + case GeomType_Rectangle : + { + fprintf(FileStream->File, "T=RECTANGLE %.12G %.12G\n", + GetFieldValue(Geom->GeomData.XYZ.XBase, 0)*ScaleFact, + GetFieldValue(Geom->GeomData.XYZ.YBase, 0)*ScaleFact); + } break; + case GeomType_Square : + { + fprintf(FileStream->File, "T=SQUARE %.12G\n", + GetFieldValue(Geom->GeomData.XYZ.XBase, 0)*ScaleFact); + } break; + case GeomType_Circle : + { + fprintf(FileStream->File, "T=CIRCLE %.12G\n", + GetFieldValue(Geom->GeomData.XYZ.XBase, 0)*ScaleFact); + } break; + case GeomType_Ellipse : + { + fprintf(FileStream->File, "T=ELLIPSE %.12G %.12G\n", + GetFieldValue(Geom->GeomData.XYZ.XBase, 0)*ScaleFact, + GetFieldValue(Geom->GeomData.XYZ.YBase, 0)*ScaleFact); + } break; + default: CHECK(FALSE); + } + } + return IsOk; +} + +/** + */ +bool DumpText(FileStream_s* FileStream, + Text_s const* Text, + Boolean_t WriteBinary, + Boolean_t WriteGridDataAsPolar) +{ + REQUIRE(VALID_REF(FileStream) && VALID_REF(FileStream->File)); + REQUIRE(VALID_REF(Text)); + REQUIRE(VALID_BOOLEAN(WriteBinary)); + REQUIRE(VALID_BOOLEAN(WriteGridDataAsPolar)); + + if (WriteBinary) + { + WriteBinaryReal(FileStream, TextMarker, FieldDataType_Float); + if (Text->PositionCoordSys == CoordSys_Grid) + WriteBinaryInt32(FileStream, 0); + else if (Text->PositionCoordSys == CoordSys_Frame) + WriteBinaryInt32(FileStream, 1); +#if 0 /* + * Not currently used + */ + else if (Geom->PositionCoordSys == CoordSys_FrameOffset) + WriteBinaryInt32(FileStream, 2); +#endif + /* + * 3 is used for old window coordinate system + */ + else if (Text->PositionCoordSys == CoordSys_Grid3D) + WriteBinaryInt32(FileStream, 4); + else + CHECK(FALSE); + + WriteBinaryInt32(FileStream, (LgIndex_t)Text->Scope); + WriteBinaryReal(FileStream, Text->AnchorPos.Generic.V1, FieldDataType_Double); + WriteBinaryReal(FileStream, Text->AnchorPos.Generic.V2, FieldDataType_Double); + WriteBinaryReal(FileStream, Text->AnchorPos.Generic.V3, FieldDataType_Double); + WriteBinaryInt32(FileStream, (LgIndex_t)Text->TextShape.Font); + WriteBinaryInt32(FileStream, (LgIndex_t)Text->TextShape.SizeUnits); + WriteBinaryReal(FileStream, Text->TextShape.Height, FieldDataType_Double); + WriteBinaryInt32(FileStream, (LgIndex_t)Text->Box.BoxType); + WriteBinaryReal(FileStream, Text->Box.Margin, FieldDataType_Double); + WriteBinaryReal(FileStream, Text->Box.LineThickness, FieldDataType_Double); + WriteBinaryInt32(FileStream, (LgIndex_t)Text->Box.BColor); + WriteBinaryInt32(FileStream, (LgIndex_t)Text->Box.FillBColor); + WriteBinaryReal(FileStream, Text->Angle, FieldDataType_Double); + WriteBinaryReal(FileStream, Text->LineSpacing, FieldDataType_Double); + WriteBinaryInt32(FileStream, (LgIndex_t)Text->Anchor); + if (Text->AttachToZone) + WriteBinaryInt32(FileStream, (LgIndex_t)Text->Zone); + else + WriteBinaryInt32(FileStream, (LgIndex_t) - 1); + WriteBinaryInt32(FileStream, (LgIndex_t)Text->BColor); + } + else + { + double ScaleFact; + Boolean_t IncludeZ = Text->PositionCoordSys == CoordSys_Grid3D; + if (Text->PositionCoordSys == CoordSys_Frame) + ScaleFact = 100.0; + else + ScaleFact = 1.0; + fprintf(FileStream->File, "TEXT\n"); + WriteAsciiTextGeomBasics(FileStream->File, + Text->PositionCoordSys, + Text->AttachToZone, + Text->Zone, + Text->BColor, + Text->Scope, + IncludeZ, + WriteGridDataAsPolar, + &Text->AnchorPos, + ScaleFact); + fprintf(FileStream->File, "HU="); + switch (Text->TextShape.SizeUnits) + { + case Units_Grid : fprintf(FileStream->File, "GRID\n"); break; + case Units_Frame : fprintf(FileStream->File, "FRAME\n"); break; + case Units_Point : fprintf(FileStream->File, "POINT\n"); break; + case Units_AxisPercentage : /* Not allowed */ + default: CHECK(FALSE); break; + } + + fprintf(FileStream->File, "LS=%.4G ", Text->LineSpacing); + + fprintf(FileStream->File, "AN="); + switch (Text->Anchor) + { + case TextAnchor_Left : fprintf(FileStream->File, "LEFT\n"); break; + case TextAnchor_Center : fprintf(FileStream->File, "CENTER\n"); break; + case TextAnchor_Right : fprintf(FileStream->File, "RIGHT\n"); break; + case TextAnchor_MidLeft : fprintf(FileStream->File, "MIDLEFT\n"); break; + case TextAnchor_MidCenter : fprintf(FileStream->File, "MIDCENTER\n"); break; + case TextAnchor_MidRight : fprintf(FileStream->File, "MIDRIGHT\n"); break; + case TextAnchor_HeadLeft : fprintf(FileStream->File, "HEADLEFT\n"); break; + case TextAnchor_HeadCenter : fprintf(FileStream->File, "HEADCENTER\n"); break; + case TextAnchor_HeadRight : fprintf(FileStream->File, "HEADRIGHT\n"); break; + default: CHECK(FALSE); break; + } + + switch (Text->Box.BoxType) + { + case TextBox_Hollow : fprintf(FileStream->File, "BX=Hollow "); break; + case TextBox_Filled : fprintf(FileStream->File, "BX=Filled "); break; + default :; + } + fprintf(FileStream->File, "BXM=%.4G ", Text->Box.Margin*100); + fprintf(FileStream->File, "LT=%.4G ", Text->Box.LineThickness*100.0); + fprintf(FileStream->File, "BXO="); WriteAsciiColor(FileStream->File, Text->Box.BColor); + fprintf(FileStream->File, "BXF="); WriteAsciiColor(FileStream->File, Text->Box.FillBColor); + + fprintf(FileStream->File, "\nF="); + switch (Text->TextShape.Font) + { + case Font_Helvetica : fprintf(FileStream->File, "HELV"); break; + case Font_HelveticaBold : fprintf(FileStream->File, "HELV-BOLD"); break; + case Font_Times : fprintf(FileStream->File, "TIMES"); break; + case Font_TimesBold: fprintf(FileStream->File, "TIMES-BOLD"); break; + case Font_TimesItalic : fprintf(FileStream->File, "TIMES-ITALIC"); break; + case Font_TimesItalicBold : fprintf(FileStream->File, "TIMES-ITALIC-BOLD"); break; + case Font_Courier : fprintf(FileStream->File, "COURIER"); break; + case Font_CourierBold : fprintf(FileStream->File, "COURIER-BOLD"); break; + case Font_Greek : fprintf(FileStream->File, "GREEK"); break; + case Font_Math : fprintf(FileStream->File, "MATH"); break; + case Font_UserDefined : fprintf(FileStream->File, "USER-DEF"); break; + default: CHECK(FALSE); break; + } + if (Text->TextShape.SizeUnits == Units_Frame) + ScaleFact = 100.0; + else + ScaleFact = 1.0; + fprintf(FileStream->File, "\nH=%.12G A=%.12G", + Text->TextShape.Height*ScaleFact, + Text->Angle*DEGPERRADIANS); + } + + + if (!WriteBinary) + fprintf(FileStream->File, "\nMFC="); + + DumpDatafileString(FileStream, Text->MacroFunctionCommand, WriteBinary); + + if (!WriteBinary) + { + if (Text->Clipping == Clipping_ClipToViewport) + fprintf(FileStream->File, "CLIPPING=CLIPTOVIEWPORT\n"); + else if (Text->Clipping == Clipping_ClipToFrame) + fprintf(FileStream->File, "CLIPPING=CLIPTOFRAME\n"); + else + CHECK(FALSE); + } + else + { + WriteBinaryInt32(FileStream, (LgIndex_t)Text->Clipping); + } + + if (!WriteBinary) + fprintf(FileStream->File, "T="); + + return DumpDatafileString(FileStream, Text->Text, WriteBinary) == TRUE; +} + +Boolean_t DumpCustomAxisLabels(FileStream_s *FileStream, + Boolean_t WriteBinary, + StringList_pa LabelBase) +{ + Boolean_t IsOk = TRUE; + LgIndex_t Index = 0; + LgIndex_t Count = 0; + + REQUIRE(VALID_REF(FileStream) && VALID_REF(FileStream->File)); + REQUIRE(VALID_BOOLEAN(WriteBinary)); + REQUIRE(StringListValid(LabelBase)); + + Count = StringListCount(LabelBase); + if (WriteBinary) + { + WriteBinaryReal(FileStream, CustomLabelMarker, FieldDataType_Float); + WriteBinaryInt32(FileStream, Count); + } + else + { + fprintf(FileStream->File, " CUSTOMLABELS = \n"); + } + + for (Index = 0, IsOk = TRUE; Index < Count && IsOk; Index++) + { + const char *CurLabel = StringListGetStringRef(LabelBase, Index); + IsOk = DumpDatafileString(FileStream, CurLabel, WriteBinary); + } + + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + +/** + */ +Boolean_t WriteBinaryMagic(FileStream_s *FileStream) +{ + /* + * Write an integer value of 1 to the file. This is used + * by the reader to determine byte order of the file. + */ + return (WriteBinaryInt32(FileStream, 1)); +} + +/** + */ +bool writeBinaryVersionNumber(FileStream_s& fileStream, + int versionNumber) +{ + char buffer[5]; + sprintf(buffer, + "V%-3d", + versionNumber); + CHECK(strlen(buffer) == 4); + return fprintf(fileStream.File, + "#!TD%s", + buffer) > 0; +} + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if !defined SUN +#else +#endif +#if !defined NO_ASSERTS +#endif +#if defined ALLOW_USERDEF_NO_NEIGHBORING_ELEMENT +#else +#endif +#if 0 /* not used yet */ +#endif +#if defined TECPLOTKERNEL +#endif +#if defined TECPLOTKERNEL +#endif +#endif diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/dataset.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/dataset.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fd35a87dcf20358649b4e6d518e28bdefa70c401 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/dataset.cpp @@ -0,0 +1,283 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +#include "stdafx.h" +#include "MASTER.h" +#define TECPLOTENGINEMODULE + +/* +****************************************************************** +****************************************************************** +******* ******** +****** (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +****************************************************************** +****************************************************************** +*/ + +#define DATASETMODULE +#include "GLOBAL.h" +#include "TASSERT.h" +#include "Q_UNICODE.h" +#include "STRUTIL.h" +#include "AUXDATA.h" +#include "ARRLIST.h" +#include "STRLIST.h" +#include "ALLOC.h" +#include "SET.h" +#include "DATASET.h" +#include "FILESTREAM.h" + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif +#include "DATASET0.h" + + +#include <float.h> + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if !defined ENGINE /* TODO(RMS)-H 12/12/2005: ENGINE: refactor to use just the Interrupted flag as-is */ +#else +#endif +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if !defined USE_MACROS_FOR_FUNCTIONS +#endif +#if !defined USE_MACROS_FOR_FUNCTIONS +#endif +#endif /* TECPLOTKERNEL */ + +/** + * Cleanout the contents of the zone spec item but leaves the zone spec item. + * This effectively leaves the zone spec structure in the same state as calling + * ZoneSpecAlloc initially. + * + * param ZoneSpec + * Zone spec item to cleanup. + */ +void CleanoutZoneSpec(ZoneSpec_s *ZoneSpec) +{ + REQUIRE(VALID_REF(ZoneSpec)); + + if (ZoneSpec->Name != NULL) + FREE_ARRAY(ZoneSpec->Name, "ZoneSpec name"); + if (ZoneSpec->AuxData != NULL) + AuxDataDealloc(&ZoneSpec->AuxData); + SetZoneSpecDefaults(ZoneSpec); +} + + +/** + */ +void ZoneSpecDealloc(ZoneSpec_s **ZoneSpec) +{ + REQUIRE(VALID_REF(ZoneSpec)); + REQUIRE(VALID_REF(*ZoneSpec) || *ZoneSpec == NULL); + + if (*ZoneSpec != NULL) + { + CleanoutZoneSpec(*ZoneSpec); + + FREE_ITEM(*ZoneSpec, "ZoneSpec structure"); + *ZoneSpec = NULL; + } + + ENSURE(*ZoneSpec == NULL); +} + +/** + */ +Boolean_t ZoneSpecItemDestructor(void *ItemRef, + ArbParam_t ClientData) +{ + ZoneSpec_s **ZoneSpecRef = (ZoneSpec_s **)ItemRef; + + REQUIRE(VALID_REF(ZoneSpecRef)); + REQUIRE(VALID_REF(*ZoneSpecRef) || *ZoneSpecRef == NULL); + + if (*ZoneSpecRef != NULL) + ZoneSpecDealloc(ZoneSpecRef); + + ENSURE(*ZoneSpecRef == NULL); + return TRUE; +} + +/** + */ +void SetZoneSpecDefaults(ZoneSpec_s *ZoneSpec) +{ + REQUIRE(VALID_REF(ZoneSpec)); + ZoneSpec->Name = NULL; + ZoneSpec->UniqueID = INVALID_UNIQUE_ID; + ZoneSpec->ParentZone = BAD_SET_VALUE; + ZoneSpec->StrandID = STRAND_ID_STATIC; + ZoneSpec->SolutionTime = 0.0; + ZoneSpec->NumPtsI = 0; + ZoneSpec->NumPtsJ = 0; + ZoneSpec->NumPtsK = 0; + ZoneSpec->ICellDim = 0; // ...currently not used + ZoneSpec->JCellDim = 0; // ...currently not used + ZoneSpec->KCellDim = 0; // ...currently not used + ZoneSpec->Type = ZoneType_Ordered; + ZoneSpec->ZoneLoadInfo.PresetZoneColor = NoColor_C; + ZoneSpec->ZoneLoadInfo.IsInBlockFormat = TRUE; + ZoneSpec->AuxData = NULL; + ZoneSpec->BuildZoneOptInfo = TRUE; + + /* classic data only */ + ZoneSpec->FNMode = FaceNeighborMode_LocalOneToOne; + ZoneSpec->FNAreCellFaceNbrsSupplied = FALSE; + + /* polytope data only */ + ZoneSpec->NumFaceNodes = 0; + ZoneSpec->NumFaceBndryFaces = 0; + ZoneSpec->NumFaceBndryItems = 0; +} + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif /* TECPLOTKERNEL */ + +/** + */ +void ZoneSpecExcludeBndryConnsFromMetrics(ZoneSpec_s* ZoneSpec) +{ + REQUIRE(VALID_REF(ZoneSpec)); + + /* classic data face connectivity fixup (leave FNMode as-is) */ + ZoneSpec->FNAreCellFaceNbrsSupplied = FALSE; // ...if we invalidate boundary connections CellFaceNbrs must now be auto-generated + + /* polytope data face connectivity fixup */ + ZoneSpec->NumFaceBndryFaces = 0; + ZoneSpec->NumFaceBndryItems = 0; +} + +/** + */ +ZoneSpec_s *ZoneSpecAlloc(void) +{ + ZoneSpec_s *Result; + + Result = (ZoneSpec_s *)ALLOC_ITEM(ZoneSpec_s, "ZoneSpec structure"); + if (Result != NULL) + SetZoneSpecDefaults(Result); + + ENSURE(Result == NULL || VALID_REF(Result)); + return Result; +} + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +/** + * Adjusts the capacity request as necessary to minimize memory reallocations + * for large lists. The adjusted capacity will be at least as big as requested + * however it may be larger if it is determined that the space requirement is + * growing faster. + * + * param ZoneOrVarArrayList + * Array list requesting the change in capacity. + * param CurrentCapacity + * Current capacity of the array list. + * param RequestedCapacity + * Capacity request or zero for default size. + * param ClientData + * Any client data needed for the adjustment. + * + * return + * Adjusted capacity that is at least as large as the request or zero if + * unable to satisfy the requested capacity. + */ +LgIndex_t ZoneOrVarListAdjustCapacityRequest(ArrayList_pa ZoneOrVarArrayList, + LgIndex_t CurrentCapacity, + LgIndex_t RequestedCapacity, + ArbParam_t ClientData) +{ + LgIndex_t Result; + + REQUIRE(ArrayListIsValid(ZoneOrVarArrayList)); + REQUIRE((RequestedCapacity == 0 && CurrentCapacity == 0) || + RequestedCapacity > CurrentCapacity); + REQUIRE(CurrentCapacity <= MaxNumZonesOrVars); + + if (RequestedCapacity <= MaxNumZonesOrVars) + { + if (RequestedCapacity != 0 && CurrentCapacity == 0) + { + /* first allocation; assume the request is the desired capacityy */ + Result = RequestedCapacity; + } + else + { + const LgIndex_t DEFAULT_CAPACITY = 32; + LgIndex_t BlockSize = MAX(DEFAULT_CAPACITY, CurrentCapacity / 2); + if (RequestedCapacity == 0) + Result = DEFAULT_CAPACITY; + else + Result = ((RequestedCapacity - 1) / BlockSize + 1) * BlockSize; + + /* put a cap on the maximum */ + if (Result > MaxNumZonesOrVars) + Result = MaxNumZonesOrVars; + } + } + else + Result = 0; /* request exceeded maximum; unable to satisfy request */ + + ENSURE(Result == 0 || Result >= RequestedCapacity); + ENSURE(Result <= MaxNumZonesOrVars); + return Result; +} + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if !defined USE_MACROS_FOR_FUNCTIONS +#endif +# if defined DEBUGUNIQUE +# endif +#endif /* TECPLOTKERNEL */ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/dataset0.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/dataset0.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c18ca539d9f0c3afefa45dff7f33543eb968f83c --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/dataset0.cpp @@ -0,0 +1,1668 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +#include "stdafx.h" +#include "MASTER.h" +#define TECPLOTENGINEMODULE + +/* +****************************************************************** +****************************************************************** +******* ******** +****** (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +****************************************************************** +****************************************************************** +*/ + +#define DATASET0MODULE +#include "GLOBAL.h" +#include "TASSERT.h" +#include "Q_UNICODE.h" +#include "ALLOC.h" +#include "ARRLIST.h" +#include "DATASET.h" +#include "SET.h" +#include "DATASHR.h" +#include "FILESTREAM.h" +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif +#include "Q_MSG.h" +#include "DATASET0.h" + +using namespace tecplot::strutil; +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +/* + * Low level dataset functions. No references to zones, vars or + * the DataSet_s master structure here. + */ + + +/* + */ +void OutOfMemoryMsg(void) +{ + ErrMsg(translate("Cannot allocate enough memory for this operation.")); +} /* OutOfMemoryMsg() */ + + +/** + */ +FieldData_pa FieldDataAlloc(void) +{ + FieldData_pa Result; + + Result = (FieldData_pa)ALLOC_ITEM(struct _FieldData_a, "FieldDataPtr"); + if (Result != NULL) + { + Result->Data = NULL; + +# if defined TECPLOTKERNEL /* TecIO doesn't require these features yet */ +/* CORE SOURCE CODE REMOVED */ +# else /* ...for TecIO only */ + Result->GetValueCallback[0] = NULL; + Result->SetValueCallback[0] = NULL; +# endif + +# if defined TECPLOTKERNEL /* TecIO doesn't require these features yet */ +/* CORE SOURCE CODE REMOVED */ +# endif + + Result->Type = FieldDataType_Invalid; + Result->ValueLocation = ValueLocation_Invalid; + Result->RefCount = 1; /* self */ + Result->VarShareRefCount = 1; /* self */ + Result->NumValues = 0; +# if defined TECPLOTKERNEL /* TecIO doesn't require these features yet */ +/* CORE SOURCE CODE REMOVED */ +# endif + } + + ENSURE(VALID_REF(Result) || Result == NULL); + return Result; +} + +/** + * Most clients should not call this function but FieldDataCleanup() instead. + * An exception to this would be Tecplot's own storable load-on-demand + * functions. + */ +void FieldDataDeallocData(FieldData_pa FieldData) +{ + REQUIRE(VALID_REF(FieldData)); + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + if (FieldData->Data != NULL) + { + /* Hack to remove 'deleting void* is undefined' warning... */ + char *Tmp = (char *)FieldData->Data; + FREE_ARRAY(Tmp, "FieldData _Data"); + FieldData->Data = NULL; + } + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + ENSURE(FieldData->Data == NULL); +} + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +/** + */ +void FieldDataCleanup(FieldData_pa FieldData) +{ + REQUIRE(VALID_REF(FieldData)); + +# if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# else + FieldDataDeallocData(FieldData); +# endif +} + +/** + */ +void FieldDataDealloc(FieldData_pa *FieldData, + Boolean_t DoTrackVarSharing) +{ + REQUIRE(VALID_REF(FieldData)); + REQUIRE(VALID_REF(*FieldData) || *FieldData == NULL); + REQUIRE(IMPLICATION(*FieldData != NULL, + IsStructureReferenced(*FieldData))); + REQUIRE(IMPLICATION(*FieldData != NULL && DoTrackVarSharing, + IsVarStructureReferenced(*FieldData))); + REQUIRE(VALID_BOOLEAN(DoTrackVarSharing)); + REQUIRE(IMPLICATION(*FieldData != NULL, + (*FieldData)->RefCount >= (*FieldData)->VarShareRefCount)); + + if (*FieldData != NULL) + { + if (DoTrackVarSharing) + DecVarStructureReference(*FieldData); + DecStructureReference(*FieldData); + if (!IsStructureReferenced(*FieldData)) + { + FieldDataCleanup(*FieldData); + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + FREE_ITEM(*FieldData, "field data"); + } + *FieldData = NULL; + } + + ENSURE(*FieldData == NULL); +} + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if !defined NDEBUG || defined CHECKED_BUILD +#endif +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if !defined NDEBUG || defined CHECKED_BUILD +#endif +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +template <typename T> +static void copyTypedValueArray(void* DstArray, + LgIndex_t DstStart, + void* SrcArray, + LgIndex_t SrcStart, + LgIndex_t SrcEnd) +{ + T* SrcPtr = ((T*)SrcArray) + SrcStart; + T* DstPtr = ((T*)DstArray) + DstStart; + size_t numBytes = sizeof(T) * (SrcEnd - SrcStart + 1); + memcpy(DstPtr, SrcPtr, numBytes); +} +/** + * DstArray and SrcArray are aligned on proper word boundaries. + */ +void CopyTypedValueArray(FieldDataType_e ValueType, + void *DstArray, + LgIndex_t DstStart, + void *SrcArray, + LgIndex_t SrcStart, + LgIndex_t SrcEnd) +{ + REQUIRE(VALID_FIELD_DATA_TYPE(ValueType) && + ValueType != FieldDataType_Bit); + REQUIRE(VALID_REF(DstArray)); + REQUIRE(DstStart >= 0); + REQUIRE(VALID_REF(SrcArray)); + REQUIRE(0 <= SrcStart && SrcStart <= SrcEnd); + REQUIRE(DstArray != SrcArray); + + switch (ValueType) + { + case FieldDataType_Int64 : CHECK(FALSE); /* Future work: remove check */ + case FieldDataType_Double : + { + CHECK(sizeof(UInt64_t) == 8 && sizeof(double) == 8); + copyTypedValueArray<UInt64_t>(DstArray, + DstStart, + SrcArray, + SrcStart, + SrcEnd); + } break; + case FieldDataType_Float : + case FieldDataType_Int32 : + { + CHECK(sizeof(UInt32_t) == 4 && sizeof(float) == 4); + copyTypedValueArray<UInt32_t>(DstArray, + DstStart, + SrcArray, + SrcStart, + SrcEnd); + } break; + case FieldDataType_Int16 : + { + CHECK(sizeof(UInt16_t) == 2); + copyTypedValueArray<UInt16_t>(DstArray, + DstStart, + SrcArray, + SrcStart, + SrcEnd); + } break; + case FieldDataType_Byte : + { + copyTypedValueArray<Byte_t>(DstArray, + DstStart, + SrcArray, + SrcStart, + SrcEnd); + } break; + default : CHECK(FALSE); + } +} + +/** + * SrcArray is aligned on proper word boundaries. + */ +void SwapBytesInTypedValueArray(FieldDataType_e ValueType, + void *SrcArray, + LgIndex_t SrcStart, + LgIndex_t SrcEnd, + LgIndex_t SrcSkip) +{ + REQUIRE(VALID_FIELD_DATA_TYPE(ValueType) && + ValueType != FieldDataType_Bit); + REQUIRE(VALID_REF(SrcArray)); + REQUIRE(0 <= SrcStart && SrcStart <= SrcEnd); + REQUIRE(SrcSkip > 0); + + switch (ValueType) + { + case FieldDataType_Int64: CHECK(FALSE); /* Future work: remove CHECK */ + case FieldDataType_Double: + { + /* swap 8 bytes blocks */ + UInt64_t *SrcPtr = ((UInt64_t *)SrcArray) + SrcStart; + UInt64_t *SrcPtrEnd = ((UInt64_t *)SrcArray) + SrcEnd; + CHECK(sizeof(UInt64_t) == 8 && sizeof(double) == 8); + while (SrcPtr <= SrcPtrEnd) + { + REVERSE_8_BYTES(SrcPtr); + SrcPtr += SrcSkip; + } + } break; + case FieldDataType_Float: + case FieldDataType_Int32: + { + /* swap 4 bytes blocks */ + UInt32_t *SrcPtr = ((UInt32_t *)SrcArray) + SrcStart; + UInt32_t *SrcPtrEnd = ((UInt32_t *)SrcArray) + SrcEnd; + CHECK(sizeof(UInt32_t) == 4 && sizeof(float) == 4); + while (SrcPtr <= SrcPtrEnd) + { + REVERSE_4_BYTES(SrcPtr); + SrcPtr += SrcSkip; + } + } break; + case FieldDataType_Int16: + { + /* swap 4 bytes blocks */ + UInt16_t *SrcPtr = ((UInt16_t *)SrcArray) + SrcStart; + UInt16_t *SrcPtrEnd = ((UInt16_t *)SrcArray) + SrcEnd; + CHECK(sizeof(UInt16_t) == 2); + while (SrcPtr <= SrcPtrEnd) + { + REVERSE_2_BYTES(SrcPtr); + SrcPtr += SrcSkip; + } + } break; + case FieldDataType_Byte: + case FieldDataType_Bit: + { + /* nothing to do */ + } break; + default: CHECK(FALSE); + } +} + +/** + * Same as SwapBytesInTypedValueArray, but does extra work. Doesn't assume + * DstArray and SrcArray are aligned on proper word boundaries. + */ +void SwapBytesInUnalignedTypedValueArray(FieldDataType_e ValueType, + void *SrcArray, + LgIndex_t SrcStart, + LgIndex_t SrcEnd, + LgIndex_t SrcSkip) +{ + REQUIRE(VALID_FIELD_DATA_TYPE(ValueType) && + ValueType != FieldDataType_Bit); + REQUIRE(VALID_REF(SrcArray)); + REQUIRE(0 <= SrcStart && SrcStart <= SrcEnd); + REQUIRE(SrcSkip > 0); + + switch (ValueType) + { + case FieldDataType_Int64: CHECK(FALSE); /* Future work: remove CHECK */ + case FieldDataType_Double: + { + /* swap 8-byte blocks */ + Byte_t *SrcPtr = ((Byte_t *)SrcArray) + SrcStart * sizeof(UInt64_t); + Byte_t *SrcPtrEnd = ((Byte_t *)SrcArray) + SrcEnd * sizeof(UInt64_t); + size_t byte_skip = SrcSkip * sizeof(UInt64_t); + CHECK(sizeof(UInt64_t) == 8 && sizeof(double) == 8); + while (SrcPtr <= SrcPtrEnd) + { + REVERSE_8_BYTES_1_AT_A_TIME(SrcPtr); + SrcPtr += byte_skip; + } + } break; + case FieldDataType_Float: + case FieldDataType_Int32: + { + /* swap 4-byte blocks */ + Byte_t *SrcPtr = ((Byte_t *)SrcArray) + SrcStart * sizeof(UInt32_t); + Byte_t *SrcPtrEnd = ((Byte_t *)SrcArray) + SrcEnd * sizeof(UInt32_t); + size_t byte_skip = SrcSkip * sizeof(UInt32_t); + CHECK(sizeof(UInt32_t) == 4 && sizeof(float) == 4); + while (SrcPtr <= SrcPtrEnd) + { + REVERSE_4_BYTES_1_AT_A_TIME(SrcPtr); + SrcPtr += byte_skip; + } + } break; + case FieldDataType_Int16: + { + /* swap 2-byte blocks */ + Byte_t *SrcPtr = ((Byte_t *)SrcArray) + SrcStart * sizeof(UInt16_t); + Byte_t *SrcPtrEnd = ((Byte_t *)SrcArray) + SrcEnd * sizeof(UInt16_t); + size_t byte_skip = SrcSkip * sizeof(UInt16_t); + CHECK(sizeof(UInt16_t) == 2); + while (SrcPtr <= SrcPtrEnd) + { + REVERSE_2_BYTES_1_AT_A_TIME(SrcPtr); + SrcPtr += byte_skip; + } + } break; + case FieldDataType_Byte: + case FieldDataType_Bit: + { + /* No swapping required. */ + } break; + default: CHECK(FALSE); + } +} + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined DEBUG_FIELDVALUES +# define DEBUG_FIELDVALUES_BAD_VALUE 0x11 +static unsigned char BadValueStr[] = +{ + DEBUG_FIELDVALUES_BAD_VALUE, + DEBUG_FIELDVALUES_BAD_VALUE, + DEBUG_FIELDVALUES_BAD_VALUE, + DEBUG_FIELDVALUES_BAD_VALUE, + DEBUG_FIELDVALUES_BAD_VALUE, + DEBUG_FIELDVALUES_BAD_VALUE, + DEBUG_FIELDVALUES_BAD_VALUE, + DEBUG_FIELDVALUES_BAD_VALUE +}; +/** + * If Tecplot is responsible for managing (allocating and deallocating) the + * raw data then + */ +# if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# else +# define FIELD_DATA_VALUE_IS_INITIALIZED(fd, pt, type) \ + ((sizeof(type) < 4) /* cannot make reliably test with less than four bytes */ || \ + memcmp(BadValueStr,((char *)((fd)->Data))+sizeof(type)*(pt), sizeof(type)) != 0) +# endif +#else +# define FIELD_DATA_VALUE_IS_INITIALIZED(fd, pt, type) TRUE +#endif + + + +/** + * Used in macros, thus not static + */ +double STDCALL GetFieldValueForFloat(const FieldData_pa fd, + LgIndex_t pt) +{ + REQUIRE(VALID_REF(fd)); +# if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# endif + REQUIRE(0 <= pt && pt < GetFieldDataNumValues(fd)); + REQUIRE(FIELD_DATA_VALUE_IS_INITIALIZED(fd, pt, float)); + + double Result = (double)GetFieldDataFloatPtr(fd)[pt]; + + return Result; +} + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + +/** + * Used in macros, thus not static + */ +double STDCALL GetFieldValueForDouble(const FieldData_pa fd, + LgIndex_t pt) +{ + REQUIRE(VALID_REF(fd)); +# if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# endif + REQUIRE(0 <= pt && pt < GetFieldDataNumValues(fd)); + REQUIRE(FIELD_DATA_VALUE_IS_INITIALIZED(fd, pt, double)); + + double Result = GetFieldDataDoublePtr(fd)[pt]; + + return Result; +} + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + +/** + */ +double STDCALL GetFieldValueForInt32(const FieldData_pa fd, + LgIndex_t pt) +{ + REQUIRE(VALID_REF(fd)); +# if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# endif + REQUIRE(0 <= pt && pt < GetFieldDataNumValues(fd)); + REQUIRE(FIELD_DATA_VALUE_IS_INITIALIZED(fd, pt, Int32_t)); + + double Result = (double)GetFieldDataInt32Ptr(fd)[pt]; + + return Result; +} + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + +/** + */ +double STDCALL GetFieldValueForInt16(const FieldData_pa fd, + LgIndex_t pt) +{ + REQUIRE(VALID_REF(fd)); +# if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# endif + REQUIRE(0 <= pt && pt < GetFieldDataNumValues(fd)); + REQUIRE(FIELD_DATA_VALUE_IS_INITIALIZED(fd, pt, Int16_t)); + + double Result = (double)GetFieldDataInt16Ptr(fd)[pt]; + + return Result; +} + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + +/** + */ +double STDCALL GetFieldValueForByte(const FieldData_pa fd, + LgIndex_t pt) +{ + REQUIRE(VALID_REF(fd)); +# if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# endif + REQUIRE(fd->Type == FieldDataType_Byte); + REQUIRE(0 <= pt && pt < GetFieldDataNumValues(fd)); + REQUIRE(FIELD_DATA_VALUE_IS_INITIALIZED(fd, pt, Byte_t)); + + double Result = (double)GetFieldDataBytePtr(fd)[pt]; + + return Result; +} + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + +/** + */ +double STDCALL GetFieldValueForBit(const FieldData_pa fd, + LgIndex_t pt) +{ + REQUIRE(VALID_REF(fd)); +# if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# endif + REQUIRE(fd->Type == FieldDataType_Bit); + REQUIRE(0 <= pt && pt < GetFieldDataNumValues(fd)); + REQUIRE(FIELD_DATA_VALUE_IS_INITIALIZED(fd, pt / 8, Byte_t)); + + LgIndex_t ByteOffset = pt / 8; + Byte_t BitMask = (01 << (pt % 8)); + + Byte_t *byte_array = GetFieldDataBytePtr(fd); + double Result = (byte_array[ByteOffset] & BitMask) ? 1.0 : 0.0; + + return Result; +} + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + +/** + */ +FieldValueGetFunction_pf DetermineFieldDataGetFunction(FieldDataType_e DataType, + Boolean_t IsFragmented) +{ + FieldValueGetFunction_pf Result; + + REQUIRE(VALID_FIELD_DATA_TYPE(DataType)); + REQUIRE(VALID_BOOLEAN(IsFragmented)); + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + { + switch (DataType) + { + case FieldDataType_Float : + { + Result = GetFieldValueForFloat; + } break; + case FieldDataType_Double : + { + Result = GetFieldValueForDouble; + } break; + case FieldDataType_Int32 : + { + Result = GetFieldValueForInt32; + } break; + case FieldDataType_Int16 : + { + Result = GetFieldValueForInt16; + } break; + case FieldDataType_Byte : + { + Result = GetFieldValueForByte; + } break; + case FieldDataType_Bit : + { + Result = GetFieldValueForBit; + } break; + default : + { + CHECK(FALSE); + Result = NULL; /* satisfy compiler */ + } break; + } + } + return (Result); +} + +/** + */ +static void STDCALL SetFieldValueForFloat(FieldData_pa fd, + LgIndex_t pt, + double val) +{ + REQUIRE(VALID_REF(fd)); +# if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# endif + REQUIRE(0 <= pt && pt < GetFieldDataNumValues(fd)); + REQUIRE("val can have any value"); + + GetFieldDataFloatPtr(fd)[pt] = CONVERT_DOUBLE_TO_FLOAT(val); + + ENSURE(FIELD_DATA_VALUE_IS_INITIALIZED(fd, pt, float)); +} + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + +/** + */ +static void STDCALL SetFieldValueForDouble(FieldData_pa fd, + LgIndex_t pt, + double val) +{ + REQUIRE(VALID_REF(fd)); +# if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# endif + REQUIRE(0 <= pt && pt < GetFieldDataNumValues(fd)); + REQUIRE("val can have any value"); + + GetFieldDataDoublePtr(fd)[pt] = CLAMP_DOUBLE(val); + + ENSURE(FIELD_DATA_VALUE_IS_INITIALIZED(fd, pt, double)); +} + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + +/** + */ +static void STDCALL SetFieldValueForInt32(FieldData_pa fd, + LgIndex_t pt, + double val) +{ + REQUIRE(VALID_REF(fd)); +# if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# endif + REQUIRE(0 <= pt && pt < GetFieldDataNumValues(fd)); + REQUIRE("val can have any value"); + + GetFieldDataInt32Ptr(fd)[pt] = CONVERT_DOUBLE_TO_INT32(val); + + ENSURE(FIELD_DATA_VALUE_IS_INITIALIZED(fd, pt, Int32_t)); +} + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + +/** + */ +static void STDCALL SetFieldValueForInt16(FieldData_pa fd, + LgIndex_t pt, + double val) +{ + REQUIRE(VALID_REF(fd)); +# if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# endif + REQUIRE(0 <= pt && pt < GetFieldDataNumValues(fd)); + REQUIRE("val can have any value"); + + GetFieldDataInt16Ptr(fd)[pt] = CONVERT_DOUBLE_TO_INT16(val); + + ENSURE(FIELD_DATA_VALUE_IS_INITIALIZED(fd, pt, Int16_t)); +} + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + +/** + */ +static void STDCALL SetFieldValueForByte(FieldData_pa fd, + LgIndex_t pt, + double val) +{ + REQUIRE(VALID_REF(fd)); +# if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# endif + REQUIRE(fd->Type == FieldDataType_Byte); + REQUIRE(0 <= pt && pt < GetFieldDataNumValues(fd)); + REQUIRE("val can have any value"); + + if (val < 1.0) + GetFieldDataBytePtr(fd)[pt] = 0; + else if (val > 255.0) + GetFieldDataBytePtr(fd)[pt] = 255; + else + GetFieldDataBytePtr(fd)[pt] = (Byte_t)val; + + ENSURE(FIELD_DATA_VALUE_IS_INITIALIZED(fd, pt, Byte_t)); +} + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + +/** + */ +static void STDCALL SetFieldValueForBit(FieldData_pa fd, + LgIndex_t pt, + double val) +{ + REQUIRE(VALID_REF(fd)); +# if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# endif + REQUIRE(fd->Type == FieldDataType_Bit); + REQUIRE(0 <= pt && pt < GetFieldDataNumValues(fd)); + REQUIRE("val can have any value"); + + LgIndex_t ByteOffset = pt / 8; + Byte_t BitMask = (01 << (pt % 8)); + + if (val < 1.0) + GetFieldDataBytePtr(fd)[ByteOffset] &= ~BitMask; + else + GetFieldDataBytePtr(fd)[ByteOffset] |= BitMask; + + ENSURE(FIELD_DATA_VALUE_IS_INITIALIZED(fd, pt / 8, Byte_t)); +} + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + +/** + */ +FieldValueSetFunction_pf DetermineFieldDataSetFunction(FieldDataType_e DataType, + Boolean_t IsFragmented) +{ + FieldValueSetFunction_pf Result; + + REQUIRE(VALID_FIELD_DATA_TYPE(DataType)); + REQUIRE(VALID_BOOLEAN(IsFragmented)); + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + { + switch (DataType) + { + case FieldDataType_Float : + { + Result = SetFieldValueForFloat; + } break; + case FieldDataType_Double : + { + Result = SetFieldValueForDouble; + } break; + case FieldDataType_Int32 : + { + Result = SetFieldValueForInt32; + } break; + case FieldDataType_Int16 : + { + Result = SetFieldValueForInt16; + } break; + case FieldDataType_Byte : + { + Result = SetFieldValueForByte; + } break; + case FieldDataType_Bit : + { + Result = SetFieldValueForBit; + } break; + default : + { + CHECK(FALSE); + Result = NULL; /* satisfy compiler */ + } break; + } + } + return (Result); +} + + +/** + */ +Int64_t FieldDataGetBytesNeeded(LgIndex_t NumValues, + FieldDataType_e DataType) +{ + Int64_t Result = 0; /* ...quite compiler */ + + REQUIRE(NumValues >= 0); + REQUIRE(VALID_FIELD_DATA_TYPE(DataType)); + + switch (DataType) + { + case FieldDataType_Float: Result = ((Int64_t)NumValues)*sizeof(float); break; + case FieldDataType_Double: Result = ((Int64_t)NumValues)*sizeof(double); break; + case FieldDataType_Int32: Result = ((Int64_t)NumValues)*sizeof(LgIndex_t); break; + case FieldDataType_Int16: Result = ((Int64_t)NumValues)*sizeof(SmInteger_t); break; + case FieldDataType_Byte: Result = ((Int64_t)NumValues)*sizeof(Byte_t); break; + case FieldDataType_Bit: Result = ((Int64_t)(NumValues+7)/8)*sizeof(Byte_t); break; + default: CHECK(FALSE); break; + } + + ENSURE(Result >= 0); + return Result; +} + +/** + * On the SGI, HP, and Sun machines 64 bit objects such as doubles must be 8 + * byte aligned while on all other machines 32 bit alignment suffices. Some + * allow 1 byte alignment but we won't bother with that. + */ +#if defined IRISX || defined HPUX || defined SUNX +# define SIZEOF_LARGEST_OBJECT_TO_ALIGN sizeof(Int64_t) +#else +# define SIZEOF_LARGEST_OBJECT_TO_ALIGN sizeof(Int32_t) +#endif + +/** + */ +Boolean_t IsOffsetAlignedForFieldDataType(FieldDataType_e FieldDataType, + Int64_t Offset) +{ + REQUIRE(VALID_FIELD_DATA_TYPE(FieldDataType)); + REQUIRE(Offset >= 0); + + Int64_t SizeOfType = FieldDataGetBytesNeeded(1, FieldDataType); + if (SizeOfType > (Int64_t)SIZEOF_LARGEST_OBJECT_TO_ALIGN) + SizeOfType = SIZEOF_LARGEST_OBJECT_TO_ALIGN; + + Boolean_t HasValidAlignment = (Offset % SizeOfType == 0); + + ENSURE(VALID_BOOLEAN(HasValidAlignment)); + return HasValidAlignment; +} + +/** + */ +Int64_t GetAlignedOffsetForFieldDataType(FieldDataType_e FieldDataType, + Int64_t Offset) +{ + REQUIRE(VALID_FIELD_DATA_TYPE(FieldDataType)); + REQUIRE(Offset >= 0); + + Int64_t SizeOfType = FieldDataGetBytesNeeded(1, FieldDataType); + if (SizeOfType > (Int64_t)SIZEOF_LARGEST_OBJECT_TO_ALIGN) + SizeOfType = SIZEOF_LARGEST_OBJECT_TO_ALIGN; + + Int64_t NumBytesPastAlignment = (Offset % SizeOfType); + Int64_t Result = Offset - NumBytesPastAlignment; + + ENSURE(0 <= Result && Result <= Offset); + ENSURE(IsOffsetAlignedForFieldDataType(FieldDataType, Result)); + return Result; +} + +/** + */ +void FieldDataDefineData(FieldData_pa FieldData, + LgIndex_t NumValues, + FieldDataType_e DataType, + ValueLocation_e ValueLocation) +{ + REQUIRE(VALID_REF(FieldData)); + REQUIRE(NumValues >= 0); + REQUIRE(VALID_FIELD_DATA_TYPE(DataType)); + REQUIRE(VALID_ENUM(ValueLocation, ValueLocation_e)); + + /* + * Remove any old data (transformed UVW is one example that calls this + * function with a non-null data pointer when switching the value location + * when style changes the value location and therefore the amount of data + * allocated.) + */ + FieldDataCleanup(FieldData); + + /* + * The reference count is not modified here. This function only allocates the + * structure and makes adjustments to the some of the members. The reference + * count was initialized when the structure was initially created and the + * structure may be shared before the data portion is even allocated. + */ + FieldData->NumValues = NumValues; + FieldData->Type = DataType; + FieldData->ValueLocation = ValueLocation; +# if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# else /* ...for TecIO only */ + FieldData->GetValueCallback[0] = (void *)DetermineFieldDataGetFunction(DataType, FALSE); + FieldData->SetValueCallback[0] = (void *)DetermineFieldDataSetFunction(DataType, FALSE); +#endif + + ENSURE(FieldData->Data == NULL); +} + +/** + */ +Boolean_t FieldDataAllocData(FieldData_pa FieldData, + Boolean_t ShowErrMsg) +{ + REQUIRE(VALID_REF(FieldData)); + REQUIRE(FieldData->Type != FieldDataType_Invalid); /* ...must call FieldDataDefineData first */ + REQUIRE(FieldData->Data == NULL); + REQUIRE(VALID_BOOLEAN(ShowErrMsg)); + + /* + * The size of size_t may be smaller than our unsigned 64 bit integer value + * so we might have to squeeze it down possibly loosing precision. + */ + Int64_t ActualBytesNeeded = FieldDataGetBytesNeeded(FieldData->NumValues, FieldData->Type); + size_t BytesToAllocate = (size_t)ActualBytesNeeded; + + /* + * 64 bit architectures are effectively unlimited in their allocation size + * while 32 architectures are limited to 4GB (some may limit further to 2GB + * which will be borne out by the call to malloc). + */ + CHECK(sizeof(size_t) == 4 || sizeof(size_t) == 8); + Boolean_t IsOk = (FieldData->NumValues <= MAXINDEX && + IMPLICATION(sizeof(size_t) == 4, + ActualBytesNeeded <= (Int64_t)0xffffffff)); + if (IsOk) + { + if (FieldData->NumValues > 0) + { + FieldData->Data = (void *)ALLOC_ARRAY(BytesToAllocate, char, "FieldData's Data"); + #if defined DEBUG_FIELDVALUES + { + if (FieldData->Data != NULL) + memset(FieldData->Data, DEBUG_FIELDVALUES_BAD_VALUE, BytesToAllocate); + } + #endif + /* + * For bit type data zero the last byte in the data array. We do + * this because NumValues is probably not a multiple of 8 bits and + * thus the valid bit values will not occupy all bits of the last + * byte. By zeroing the unused bits at the end of the array we + * produce consistent data files when written to disk. + */ + if (FieldData->Type == FieldDataType_Bit) + ((char*)FieldData->Data)[BytesToAllocate-1] = '\0'; + } + IsOk = (FieldData->NumValues == 0 || + FieldData->Data != NULL); + if (!IsOk && ShowErrMsg) + OutOfMemoryMsg(); + } + else if (ShowErrMsg) + ErrMsg(translate("Storage limit (%ld) exceeded for a single variable."), (long)MAXINDEX); + +# if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# endif + + ENSURE(VALID_REF(FieldData->Data) || FieldData->Data == NULL); + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if !defined NO_ASSERTS +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +/** + * Allocates a field data pointer with space for "num_pts" of field data type + * "field_data_type" nodal values. + * + * IMPORTANT: + * This field data may NOT be used for zones but only for things like + * geometries or other temporary field data that will never be placed + * into a COB or zone. + */ +FieldData_pa AllocScratchNodalFieldDataPtr(LgIndex_t NumValues, + FieldDataType_e Type, + Boolean_t ShowErrMsg) +{ + REQUIRE(NumValues >= 0); + REQUIRE(VALID_FIELD_DATA_TYPE(Type)); + REQUIRE(VALID_BOOLEAN(ShowErrMsg)); + + FieldData_pa Result = FieldDataAlloc(); + if (Result != NULL) + { + FieldDataDefineData(Result, NumValues, Type, ValueLocation_Nodal); + if (!FieldDataAllocData(Result, ShowErrMsg)) + FieldDataDealloc(&Result, FALSE); + } + else if (ShowErrMsg) + OutOfMemoryMsg(); + + ENSURE(VALID_REF(Result) || Result == NULL); +# if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# endif + ENSURE(IMPLICATION(Result != NULL, + (Result->NumValues >= 0 && + IMPLICATION(Result->NumValues != 0, + VALID_REF(Result->Data)) && + VALID_FIELD_DATA_TYPE(Result->Type)))); + + return Result; +} + + +/** + * Frees memory allocated with AllocScratchNodalFieldDataPtr(). + * + * @param ScratchFieldData + * Scratch field data pointer to deallocate. This should NEVER be a field + * data from a zone or COB. See note in AllocScratchNodalFieldDataPtr(). + */ +void DeallocScratchNodalFieldDataPtr(FieldData_pa *FieldDataRef) +{ + FieldDataDealloc(FieldDataRef, + FALSE); /* DoTrackVarSharing */ +} + + +#if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS +/** + */ +FieldDataType_e GetFieldDataType_FUNC(FieldData_pa FieldData) +{ + REQUIRE(VALID_REF(FieldData)); + + FieldDataType_e Result = GetFieldDataType_MACRO(FieldData); + + ENSURE(VALID_FIELD_DATA_TYPE(Result)); + return Result; +} +#endif /* !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS */ + + +#if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS +/** + */ +FieldValueGetFunction_pf GetFieldDataGetFunction_FUNC(FieldData_pa FieldData) +{ + REQUIRE(VALID_REF(FieldData)); + + FieldValueGetFunction_pf Result = GetFieldDataGetFunction_MACRO(FieldData); + + ENSURE(VALID_FN_REF(Result)); + return Result; +} +#endif /* !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS */ + + +#if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS +/** + */ +FieldValueSetFunction_pf GetFieldDataSetFunction_FUNC(FieldData_pa FieldData) +{ + REQUIRE(VALID_REF(FieldData)); + + FieldValueSetFunction_pf Result = GetFieldDataSetFunction_MACRO(FieldData); + + ENSURE(VALID_FN_REF(Result)); + return Result; +} +#endif /* !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS */ + + +#if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS +/** + */ +LgIndex_t GetFieldDataNumValues_FUNC(FieldData_pa FieldData) +{ + REQUIRE(VALID_REF(FieldData)); + + LgIndex_t Result = GetFieldDataNumValues_MACRO(FieldData); + + ENSURE(Result >= 0); + return Result; +} +#endif /* !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS */ + + +#if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS +/** + */ +ValueLocation_e GetFieldDataValueLocation_FUNC(FieldData_pa FieldData) +{ + REQUIRE(VALID_REF(FieldData)); + + ValueLocation_e Result = GetFieldDataValueLocation_MACRO(FieldData); + + ENSURE(Result == ValueLocation_Invalid || /* i.e. pending assignment */ + VALID_ENUM(Result, ValueLocation_e)); + return Result; +} +#endif /* !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS */ + + +#if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS +/** + */ +Boolean_t IsFieldDataDirectAccessAllowed_FUNC(FieldData_pa FieldData) +{ + REQUIRE(VALID_REF(FieldData)); + + Boolean_t Result = IsFieldDataDirectAccessAllowed_MACRO(FieldData); + + ENSURE(VALID_BOOLEAN(Result)); + return Result; +} +#endif + + +#if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS +/** + */ +float *GetFieldDataFloatPtr_FUNC(FieldData_pa fd) +{ + REQUIRE(VALID_REF(fd)); + + float *Result = GetFieldDataFloatPtr_MACRO(fd); + + ENSURE(VALID_REF(Result)); + return Result; +} +#endif + + +#if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS +/** + */ +double *GetFieldDataDoublePtr_FUNC(FieldData_pa fd) +{ + REQUIRE(VALID_REF(fd)); + + double *Result = GetFieldDataDoublePtr_MACRO(fd); + + ENSURE(VALID_REF(Result)); + return Result; +} +#endif + + +#if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS +/** + */ +Int64_t *GetFieldDataInt64Ptr_FUNC(FieldData_pa fd) +{ + REQUIRE(VALID_REF(fd)); + + Int64_t *Result = GetFieldDataInt64Ptr_MACRO(fd); + + ENSURE(VALID_REF(Result)); + return Result; +} +#endif + + +#if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS +/** + */ +Int32_t *GetFieldDataInt32Ptr_FUNC(FieldData_pa fd) +{ + REQUIRE(VALID_REF(fd)); + + Int32_t *Result = GetFieldDataInt32Ptr_MACRO(fd); + + ENSURE(VALID_REF(Result)); + return Result; +} +#endif + + +#if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS +/** + */ +Int16_t *GetFieldDataInt16Ptr_FUNC(FieldData_pa fd) +{ + REQUIRE(VALID_REF(fd)); + + Int16_t *Result = GetFieldDataInt16Ptr_MACRO(fd); + + ENSURE(VALID_REF(Result)); + return Result; +} +#endif + + +#if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS +/* + * No byte ordering or alignment issues with single bytes (which are also used with the "Bit" type) + */ +Byte_t *GetFieldDataBytePtr_FUNC(FieldData_pa fd) +{ + /* + * This function gets called for Byte and Bit types, but we cannot REQUIRE + * those types because it is also used for non-aligned values. We can't + * check for non-aligned because we might be copying aligned bytes to a + * non-aligned location. + */ + REQUIRE(VALID_REF(fd)); + + Byte_t *Result = GetFieldDataBytePtr_MACRO(fd); + + ENSURE(VALID_REF(Result)); + return Result; +} +#endif + + +#if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS +/** + * Gets a ptr to 2-byte blocks regardless of byte ordering, but still has to + * worry about byte alignment + */ +UInt16_t *GetFieldData2BytePtr_FUNC(FieldData_pa fd) +{ + REQUIRE(VALID_REF(fd)); + REQUIRE(fd->Type == FieldDataType_Int16); + + UInt16_t *Result = GetFieldData2BytePtr_MACRO(fd); + + ENSURE(VALID_REF(Result)); + return Result; +} +#endif + + +#if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS +/* + * Gets a ptr to 4-byte blocks regardless of byte ordering, but still has to + * worry about byte alignment + */ +UInt32_t *GetFieldData4BytePtr_FUNC(FieldData_pa fd) +{ + REQUIRE(VALID_REF(fd)); + REQUIRE(fd->Type == FieldDataType_Int32 || fd->Type == FieldDataType_Float); + + UInt32_t *Result = GetFieldData4BytePtr_MACRO(fd); + + ENSURE(VALID_REF(Result)); + return Result; +} +#endif + + +#if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS +/* + * Gets a ptr to 8-byte blocks regardless of byte ordering, but still has to + * worry about byte alignment + */ +UInt64_t *GetFieldData8BytePtr_FUNC(FieldData_pa fd) +{ + REQUIRE(VALID_REF(fd)); + REQUIRE(fd->Type == FieldDataType_Int64 || fd->Type == FieldDataType_Double); + + UInt64_t *Result = GetFieldData8BytePtr_MACRO(fd); + + ENSURE(VALID_REF(Result)); + return Result; +} +#endif + + +#if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS +/* + * WARNING: GetFieldDataVoidPtr checks nothing, and thus should only be + * used with extreme caution (that is, checking the alignment + * and byte order by hand). + */ +void *GetFieldDataVoidPtr_FUNC(FieldData_pa fd) +{ + REQUIRE(VALID_REF(fd)); + + void *Result = GetFieldDataVoidPtr_MACRO(fd); + + ENSURE(VALID_REF(Result)); + return Result; +} +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif /* TECPLOTKERNEL */ + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif /* TECPLOTKERNEL */ + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + +/* + */ +void CopyFieldValue(FieldData_pa dst, + LgIndex_t dstindex, + FieldData_pa src, + LgIndex_t srcindex) +{ + REQUIRE(VALID_REF(dst)); + REQUIRE(VALID_REF(src)); +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif /* TECPLOTKERNEL */ + REQUIRE(dstindex >= 0 && dstindex < GetFieldDataNumValues(dst) && + srcindex >= 0 && srcindex < GetFieldDataNumValues(src)); + + Boolean_t DoBruteForceCopy = TRUE; + + if (IsFieldDataDirectAccessAllowed(src) && + IsFieldDataDirectAccessAllowed(dst) && + GetFieldDataType(src) == GetFieldDataType(dst)) + { + switch (GetFieldDataType(src)) + { + case FieldDataType_Int64 : CHECK(FALSE); /* Future work: remove and let fall through */ + case FieldDataType_Double : + { + CHECK(sizeof(UInt64_t) == 8 && sizeof(double) == 8); + UInt64_t *dst_ptr = GetFieldData8BytePtr(dst) + dstindex; + UInt64_t *src_ptr = GetFieldData8BytePtr(src) + srcindex; + *dst_ptr = *src_ptr; + DoBruteForceCopy = FALSE; + } break; + case FieldDataType_Float : + case FieldDataType_Int32 : + { + CHECK(sizeof(UInt32_t) == 4 && sizeof(float) == 4); + UInt32_t *dst_ptr = GetFieldData4BytePtr(dst) + dstindex; + UInt32_t *src_ptr = GetFieldData4BytePtr(src) + srcindex; + *dst_ptr = *src_ptr; + DoBruteForceCopy = FALSE; + } break; + case FieldDataType_Int16 : + { + CHECK(sizeof(UInt16_t) == 2); + UInt16_t *dst_ptr = GetFieldData2BytePtr(dst) + dstindex; + UInt16_t *src_ptr = GetFieldData2BytePtr(src) + srcindex; + *dst_ptr = *src_ptr; + } break; + case FieldDataType_Byte : + { + GetFieldDataBytePtr(dst)[dstindex] = GetFieldDataBytePtr(src)[srcindex]; + DoBruteForceCopy = FALSE; + } break; + case FieldDataType_Bit : break; /* handle below */ + default : CHECK(FALSE); /* Future work: when more complex types are added, remove this CHECK */ + } + } + + if (DoBruteForceCopy) + { + double val = GetFieldValue(src, srcindex); + SetFieldValue(dst, dstindex, val); + } +} /* CopyFieldValue() */ + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif /* TECPLOTKERNEL */ + + +/* + */ +void SetFieldDataPtrToAllZeros(FieldData_pa fd) +{ + REQUIRE(VALID_REF(fd)); +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif /* TECPLOTKERNEL */ + + LgIndex_t NumValues = GetFieldDataNumValues(fd); + + /* + * memset each byte to 0 works for floats and doubles and works regardless + * of byte ordering or alignment. + */ + size_t NumBytesToMemSet = 0; + if (IsFieldDataDirectAccessAllowed(fd)) + { + switch (GetFieldDataType(fd)) + { + case FieldDataType_Int64 : CHECK(FALSE); /* Future work: remove CHECK */ + case FieldDataType_Double : + { + CHECK(sizeof(UInt64_t) == 8 && sizeof(double) == 8); + NumBytesToMemSet = NumValues * sizeof(Int64_t); + } break; + case FieldDataType_Int32 : + case FieldDataType_Float : + { + CHECK(sizeof(UInt32_t) == 4 && sizeof(float) == 4); + NumBytesToMemSet = NumValues * sizeof(Int32_t); + } break; + case FieldDataType_Int16 : + { + CHECK(sizeof(UInt16_t) == 2); + NumBytesToMemSet = NumValues * sizeof(Int16_t); + } break; + case FieldDataType_Byte : + { + NumBytesToMemSet = NumValues * sizeof(Byte_t); + } break; + case FieldDataType_Bit : + { + NumBytesToMemSet = ((NumValues + 7) / 8) * sizeof(Byte_t); + } break; + default : + { + CHECK(FALSE); + } break; + } + } + + if (NumBytesToMemSet > 0) + { + void *fd_data = GetFieldDataVoidPtr(fd); + memset(fd_data, 0, NumBytesToMemSet); + } + else + { + int ii; + for (ii = 0; ii < NumValues; ii++) + SetFieldValue(fd, ii, 0.0); + } + +} /* SetFieldDataPtrToAllZeros() */ + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif /* TECPLOTKERNEL */ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/datautil.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/datautil.cpp new file mode 100644 index 0000000000000000000000000000000000000000..783abec0c404116d4c98ccb122d20f3746769306 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/datautil.cpp @@ -0,0 +1,941 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +#include "stdafx.h" +#include "MASTER.h" +#define TECPLOTENGINEMODULE +/* +****************************************************************** +****************************************************************** +******* ******** +****** (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +****************************************************************** +****************************************************************** +*/ + +/* + * datautil.c: + * + * version 1.00 : 12/10/91 (cm) changes made for manual + * version 1.01 : 12/30/91 Get and ReturnHugeBlock are now ptr to function + * version 6.00 : 04/21/92 updated to match version 6 of tecplot. + * version 6.30 : 10/15/92 updated to match binary file version 6.3 + * version 6.30a: 05/04/93 (cm) minor changes to prototypes + * version : 11/01/93 (cm) put in D4GW stuff + * version 6.30b: 12/27/93 (cm) fixed missing NumKPts in DumpZone + * version 6.30c: 12/27/93 (cm) put back in D4GW stuff +BEGIN CODELOG TECXXX +C 03/06/96 (BDP) +C Update to V7 +C +C 03/14/97 (BDP) +C Added code to main tecplot source. Now can +C be built stand alone or added so TecUtil_ functions +C can access. +C 06/02/98 (bdp) +C v75 coding. Also removed Array of ZoneSpec_s +C structs in favor of zonenames, i,j,and k dimensions +C and zonetype array. +END CODELOG + */ + + + +#include "GLOBAL.h" +#include "TASSERT.h" +#include "Q_UNICODE.h" +#include "SYSTEM.h" +#include "ALLOC.h" +#include "TECXXX.h" +#include "ARRLIST.h" +#include "SET.h" +#include "DATASET.h" +#include "FILESTREAM.h" +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif +#include "DATAIO.h" +#include "DATAIO4.h" +#include "DATAUTIL.h" +#include "STRLIST.h" +#include "Q_MSG.h" +#if defined MAKEARCHIVE +#define INITMODULE +#endif +#include "INPUT.h" + +using namespace tecplot::strutil; + +#if defined MAKEARCHIVE +#define ANGLEEPSILON 1.0e-10 + +void InitInputSpecs(void) +{ + LineThicknessInputSpec.Type = Input_Double; + LineThicknessInputSpec.Min = 0.000001; + LineThicknessInputSpec.Max = 1.0; + LineThicknessInputSpec.InterfaceAdjust.ScaleFact = 100.0; + LineThicknessInputSpec.SuffixModifier = NULL; + + PatternLengthInputSpec.Type = Input_Double; + PatternLengthInputSpec.Min = 0.0001; + PatternLengthInputSpec.Max = 1.0; + PatternLengthInputSpec.InterfaceAdjust.ScaleFact = 100.0; + PatternLengthInputSpec.SuffixModifier = NULL; + + TextBoxMarginInputSpec.Type = Input_Double; + TextBoxMarginInputSpec.Min = 0.0; + TextBoxMarginInputSpec.Max = 20.0; + TextBoxMarginInputSpec.InterfaceAdjust.ScaleFact = 100.0; + TextBoxMarginInputSpec.SuffixModifier = NULL; + + TextLineSpacingInputSpec.Type = Input_Double; + TextLineSpacingInputSpec.Min = 0.0; + TextLineSpacingInputSpec.Max = 5.0; + TextLineSpacingInputSpec.InterfaceAdjust.ScaleFact = 1.0; + TextLineSpacingInputSpec.SuffixModifier = NULL; + + + ArrowheadSizeInputSpec.Type = Input_Double; + ArrowheadSizeInputSpec.Min = 0.0; + ArrowheadSizeInputSpec.Max = 0.5; + ArrowheadSizeInputSpec.InterfaceAdjust.ScaleFact = 100.0; + ArrowheadSizeInputSpec.SuffixModifier = NULL; + + TextAngleInputSpec.Type = Input_Double; + TextAngleInputSpec.Min = -PI - ANGLEEPSILON; + TextAngleInputSpec.Max = PI + ANGLEEPSILON; + TextAngleInputSpec.InterfaceAdjust.ScaleFact = DEGPERRADIANS; + TextAngleInputSpec.SuffixModifier = NULL; + + ArrowheadAngleInputSpec.Type = Input_Double; + ArrowheadAngleInputSpec.Min = 1.0 / DEGPERRADIANS - ANGLEEPSILON; + ArrowheadAngleInputSpec.Max = PIOVER2 + ANGLEEPSILON; + ArrowheadAngleInputSpec.InterfaceAdjust.ScaleFact = DEGPERRADIANS; + ArrowheadAngleInputSpec.SuffixModifier = NULL; +} +#endif + + + + +void LocalReadBlock(FileStream_s *FileStream, + double *CurVPtr, + FieldDataType_e FieldDataTypeInFile, + HgIndex_t NumValues, + Boolean_t *IsOk) +{ + REQUIRE(VALID_REF(IsOk) && VALID_BOOLEAN(*IsOk)); + REQUIRE(!(*IsOk) || VALID_REF(FileStream)); + REQUIRE(!(*IsOk) || VALID_FIELD_DATA_TYPE(FieldDataTypeInFile)); + + if (*IsOk) + { + Boolean_t DoRead = (CurVPtr != NULL); + Boolean_t ReadByBlock = (FieldDataType_Double == FieldDataTypeInFile) || !DoRead; + if (ReadByBlock) + { + ReadPureBlock(FileStream, + DoRead, + (void *)CurVPtr, + FieldDataTypeInFile, + 0, + NumValues, + IsOk); + } + else + { + LgIndex_t N; + for (N = 0; *IsOk && (N < NumValues); N++) + { + double D = GetNextValue(FileStream, FieldDataTypeInFile, -LARGEDOUBLE, LARGEDOUBLE, IsOk); + if (DoRead) + CurVPtr[N] = D; + } + } + } +} + + + + +/* + * + * NOTE: ReadTec only allocates space for NodeMap and VDataBase + * if RawDataSpaceAllocated == FALSE and GetHeaderInfoOnly + * is FALSE. + * + * Also note that all data read in by ReadTec is currently + * limited to be in double precision. + * + */ + + +Boolean_t STDCALL ReadTec(Boolean_t GetHeaderInfoOnly, + char *FName, + short *IVersion, + char **DataSetTitle, + EntIndex_t *NumZones, + EntIndex_t *NumVars, + StringList_pa *VarNames, + StringList_pa *ZoneNames, + LgIndex_t **NumPtsI, + LgIndex_t **NumPtsJ, + LgIndex_t **NumPtsK, + ZoneType_e **ZoneType, + StringList_pa *UserRec, + Boolean_t RawDataSpaceAllocated, + NodeMap_t ***NodeMap, + double ***VDataBase) +{ + Boolean_t InputIsOk = FALSE; + ArrayList_pa ZoneSpecList = NULL; + LgIndex_t *FNNumBndryConns = NULL; /* [NumZones] */ + FileStream_s *ReadTecFileStream = NULL; + Set_pa *IsVarCellCentered = NULL; /* [NumZones] */ + + REQUIRE(VALID_BOOLEAN(GetHeaderInfoOnly)); + REQUIRE(VALID_NON_ZERO_LEN_STR(FName)); + REQUIRE(VALID_REF(IVersion)); + REQUIRE(VALID_REF(DataSetTitle) || DataSetTitle == NULL); + REQUIRE(VALID_REF(NumZones)); + REQUIRE(VALID_REF(NumVars)); + REQUIRE(VarNames == NULL || VALID_REF(VarNames)); + REQUIRE(ZoneNames == NULL || VALID_REF(ZoneNames)); + REQUIRE(NumPtsI == NULL || VALID_REF(NumPtsI)); + REQUIRE(NumPtsJ == NULL || VALID_REF(NumPtsJ)); + REQUIRE(NumPtsK == NULL || VALID_REF(NumPtsK)); + REQUIRE(ZoneType == NULL || VALID_REF(ZoneType)); + REQUIRE(UserRec == NULL || VALID_REF(UserRec)); + REQUIRE(VALID_BOOLEAN(RawDataSpaceAllocated)); + REQUIRE(IMPLICATION(!GetHeaderInfoOnly && RawDataSpaceAllocated, + VALID_REF(NodeMap) && VALID_REF(VDataBase))); + +#if defined MAKEARCHIVE + InitInputSpecs(); +#endif + + InputIsOk = OpenBinaryFileAndCheckMagicNumber(&ReadTecFileStream, + FName, + 0, + IVersion); + + if (InputIsOk) + InputIsOk = ReadDataFileHeader(ReadTecFileStream, + *IVersion, + FALSE, + NumZones, + NumVars, + (SmInteger_t *)NULL, + DataSetTitle, + (Text_s **)NULL, + (Geom_s **)NULL, + (StringList_pa **)NULL, + UserRec, + (AuxData_pa *)NULL, + &IsVarCellCentered, + (Boolean_t *)NULL, + (Boolean_t *)NULL, + &ZoneSpecList, + VarNames, + (ArrayList_pa *)NULL, + (Set_pa *)NULL, + &FNNumBndryConns, + (DataFileType_e *)NULL); + + + + if (InputIsOk) + { + if (*NumZones == 0) + *NumVars = 0; + else if (*IVersion > 112) + { + /* + * This may not be true but we put it hear to remind us to make + * updates to this code when we change the version number. + */ + ErrMsg(translate("ReadTec does not yet support version %d " + "Tecplot binary data files."), *IVersion); + InputIsOk = FALSE; + } + else if (!GetHeaderInfoOnly) + { + EntIndex_t Z; + for (Z = 0; Z < *NumZones && InputIsOk; Z++) + { + InputIsOk = (MemberCount(IsVarCellCentered[Z]) == 0); + if (!InputIsOk) + ErrMsg(translate("Cell centered data not supported by ReadTec.")); + } + } + } + + if (IsVarCellCentered != NULL) + { + EntIndex_t Z; + for (Z = 0; Z < *NumZones; Z++) + DeallocSet(&IsVarCellCentered[Z]); + FREE_ARRAY(IsVarCellCentered, "Array of IsVarCellCentered sets"); + } + + if (InputIsOk) + { + EntIndex_t Z; + /* + * Allocate space for the zone info pieces. + */ + if (ZoneNames) + *ZoneNames = StringListAlloc(); + if (NumPtsI) + *NumPtsI = ALLOC_ARRAY(*NumZones, LgIndex_t, "numptsi"); + if (NumPtsJ) + *NumPtsJ = ALLOC_ARRAY(*NumZones, LgIndex_t, "numptsj"); + if (NumPtsK) + *NumPtsK = ALLOC_ARRAY(*NumZones, LgIndex_t, "numptsk"); + if (ZoneType) + *ZoneType = ALLOC_ARRAY(*NumZones, ZoneType_e, "zonetype"); + for (Z = 0; Z < *NumZones; Z++) + { + ZoneSpec_s *ZoneSpec = GetZoneSpec(ZoneSpecList, Z); + if (ZoneSpec != NULL) + { + if (ZoneNames && *ZoneNames) + StringListAppendString(*ZoneNames, ZoneSpec->Name); + + if (NumPtsI && *NumPtsI) + (*NumPtsI)[Z] = ZoneSpec->NumPtsI; + + if (NumPtsJ && *NumPtsJ) + (*NumPtsJ)[Z] = ZoneSpec->NumPtsJ; + + if (NumPtsK && *NumPtsK) + (*NumPtsK)[Z] = ZoneSpec->NumPtsK; + + if (ZoneType && *ZoneType) + (*ZoneType)[Z] = ZoneSpec->Type; + } + else + { + if (ZoneNames && *ZoneNames) + StringListAppendString(*ZoneNames, NULL); + + if (NumPtsI && *NumPtsI) + (*NumPtsI)[Z] = 0; + + if (NumPtsJ && *NumPtsJ) + (*NumPtsJ)[Z] = 0; + + if (NumPtsK && *NumPtsK) + (*NumPtsK)[Z] = 0; + + if (ZoneType && *ZoneType) + (*ZoneType)[Z] = ZoneType_Invalid; + } + } + } + if (!GetHeaderInfoOnly && InputIsOk && (*NumZones > 0)) + { + EntIndex_t *VarSharesFromZone = NULL; /* [NumVars] */ + Boolean_t *IsVarPassive = NULL; /* [NumVars] */ + EntIndex_t *ConnectivitySharesFromZone = NULL; /* [NumZones] */ + FieldDataType_e *VarType = NULL; + int CurZone; + int CurVar; + LgIndex_t NumIPts = 0; + LgIndex_t NumJPts = 0; + LgIndex_t NumKPts = 0; + LgIndex_t TotalNumPts; + LgIndex_t I, J; + + if ((*NumZones > 0) && !RawDataSpaceAllocated) + { + *VDataBase = ALLOC_ARRAY(*NumZones * (*NumVars), double *, "vdatabase array"); + if (*VDataBase == NULL) + { + ErrMsg(translate("Cannot allocate space for field data")); + InputIsOk = FALSE; + } + else + { + int I; + for (I = 0; I < *NumZones*(*NumVars); I++) + (*VDataBase)[I] = NULL; + } + + if (InputIsOk) + { + *NodeMap = ALLOC_ARRAY(*NumZones, NodeMap_t *, "nodemap array"); + if (*NodeMap == NULL) + { + ErrMsg(translate("Cannot allocate space for nodemap")); + InputIsOk = FALSE; + } + else + { + int I; + for (I = 0; I < *NumZones; I++) + (*NodeMap)[I] = NULL; + } + } + } + + if (InputIsOk) + { + VarType = ALLOC_ARRAY(*NumVars + 1, FieldDataType_e, "Var Type"); + VarSharesFromZone = ALLOC_ARRAY(*NumVars + 1, EntIndex_t, "VarSharesFromZone"); + IsVarPassive = ALLOC_ARRAY(*NumVars + 1, Boolean_t, "IsVarPassive"); + + ConnectivitySharesFromZone = ALLOC_ARRAY(*NumZones, EntIndex_t, "ConnectivitySharesFromZone"); + InputIsOk = (VarType != NULL && + VarSharesFromZone != NULL && + IsVarPassive != NULL && + ConnectivitySharesFromZone != NULL); + } + + /* for each zone */ + for (CurZone = 0; CurZone < *NumZones && InputIsOk; CurZone++) + { + double X1 = GetNextValue(ReadTecFileStream, FieldDataType_Float, 0.0, 1000.0, &InputIsOk); + if (InputIsOk && (X1 == ZoneMarker)) + { + ZoneSpec_s *CurZoneSpec = GetZoneSpec(ZoneSpecList, CurZone); + Boolean_t ZoneIsFinite = (CurZoneSpec->Type != ZoneType_Ordered); + Boolean_t ZoneIsFEPoly = (CurZoneSpec->Type == ZoneType_FEPolygon || + CurZoneSpec->Type == ZoneType_FEPolyhedron); + Boolean_t InBlockFormat = CurZoneSpec->ZoneLoadInfo.IsInBlockFormat; + for (J = 0; J < *NumVars; J++) + { + VarSharesFromZone[J] = -1; /* eumulate DupVar: no DupVar */ + VarType[J] = FieldDataType_Float; + IsVarPassive[J] = FALSE; + } + + /* dupvars */ + if (*IVersion > 45 && *IVersion < 101 && InputIsOk) + { + EntIndex_t NumDupVars, ZZ; + + NumDupVars = (EntIndex_t)GetIoFileInt(ReadTecFileStream, *IVersion, 0, (LgIndex_t) * NumVars, &InputIsOk); + for (J = 0; J < NumDupVars; J++) + { + ZZ = (EntIndex_t)GetIoFileInt(ReadTecFileStream, *IVersion, 0, *NumVars, &InputIsOk) - 1; + VarSharesFromZone[ZZ] = CurZone - 1; /* emulate DupVar: share from previous zone */ + } + /* Can't duplicate from the first zone */ + if ((NumDupVars > 0) && (CurZone == 0)) + { + ErrMsg(translate("Cannot duplicate variables from the first zone since there are " + "no previous zones to duplicate from.")); + InputIsOk = FALSE; + } + } + + /* get the data type for each variable */ + if (*IVersion >= 70 && InputIsOk) + { + for (J = 0; J < *NumVars; J++) + { + VarType[J] = (FieldDataType_e)GetIoFileInt(ReadTecFileStream, *IVersion, + 0, + (LgIndex_t)FieldDataType_Bit, + &InputIsOk); + if (!InputIsOk) + { + ErrMsg(translate("Invalid data type - binary input file corrupted")); + InputIsOk = FALSE; + } + } + } + + if (InputIsOk) + { + NumIPts = CurZoneSpec->NumPtsI; + NumJPts = CurZoneSpec->NumPtsJ; + NumKPts = CurZoneSpec->NumPtsK; + } + + if (ZoneIsFinite) + TotalNumPts = NumIPts; + else + TotalNumPts = (NumIPts * NumJPts * NumKPts); + + for (CurVar = 0; CurVar < *NumVars && InputIsOk; CurVar++) + { + if (!RawDataSpaceAllocated && TotalNumPts >= 1) + { + /* + * The calling program did not allocate space for the + * data so do it here. + */ + (*VDataBase)[CurVar+CurZone*(*NumVars)] = + ALLOC_ARRAY(TotalNumPts, double, "raw data"); + } + } + + if (*IVersion >= 105 && InputIsOk) + { + /* passive variables */ + if ((Boolean_t)GetIoFileInt(ReadTecFileStream, *IVersion, 0, 1, &InputIsOk) && InputIsOk) + { + for (CurVar = 0; CurVar < *NumVars && InputIsOk; CurVar++) + { + IsVarPassive[CurVar] = (Boolean_t)GetIoFileInt(ReadTecFileStream, + *IVersion, + 0, 1, &InputIsOk); + } + } + } + + if (*IVersion >= 101 && InputIsOk) + { + /* variable sharing: equivalent to DupVar for ReadTec */ + if ((Boolean_t)GetIoFileInt(ReadTecFileStream, *IVersion, 0, 1, &InputIsOk) && InputIsOk) + { + for (CurVar = 0; CurVar < *NumVars && InputIsOk; CurVar++) + { + EntIndex_t SharedZone = GetIoFileInt(ReadTecFileStream, *IVersion, + -1, MaxNumZonesOrVars - 1, + &InputIsOk); + if (SharedZone != -1 && InputIsOk) + VarSharesFromZone[CurVar] = SharedZone; + } + } + + /* face neighbor or FE node connectivity sharing */ + if (InputIsOk) + { + EntIndex_t SharedZone = GetIoFileInt(ReadTecFileStream, *IVersion, + -1, MaxNumZonesOrVars - 1, + &InputIsOk); + if (InputIsOk) + ConnectivitySharesFromZone[CurZone] = SharedZone; + } + } + + /* + * Non-shared variable min/max (but not for Zombie zones). + */ + if (*IVersion >= 103 && InputIsOk) + { + for (CurVar = 0; CurVar < *NumVars && InputIsOk; CurVar++) + { + if (VarSharesFromZone[CurVar] == -1 && !IsVarPassive[CurVar]) + { + /* + * Currently ReadTec doesn't do anything with the + * min/max values. + */ + GetNextValue(ReadTecFileStream, FieldDataType_Double, + -LARGEDOUBLE, LARGEDOUBLE, + &InputIsOk); + GetNextValue(ReadTecFileStream, FieldDataType_Double, + -LARGEDOUBLE, LARGEDOUBLE, + &InputIsOk); + } + } + } + + if (InBlockFormat) + { + CurVar = -1; + while (InputIsOk && ((CurVar + 1) < *NumVars)) + { + CurVar++; + if ((CurVar < *NumVars) && (TotalNumPts > 0)) + { + double *CurVPtr = (*VDataBase)[CurVar+CurZone*(*NumVars)]; + J = 0; + if (VarSharesFromZone[CurVar] != -1) + { + LgIndex_t M; + EntIndex_t SourceZone = VarSharesFromZone[CurVar]; + double *SourceVPtr = (*VDataBase)[CurVar+SourceZone*(*NumVars)]; + for (M = 0; M < TotalNumPts; M++) + CurVPtr[M] = SourceVPtr[M]; + } + else if (!IsVarPassive[CurVar]) + { + LocalReadBlock(ReadTecFileStream, + CurVPtr, + VarType[CurVar], + TotalNumPts, + &InputIsOk); + } + } + } + if (!InputIsOk) + ErrMsg(translate("Invalid raw data section of binary file")); + } + else if (TotalNumPts > 0) + { + /* + * Zone is not empty and is in POINT format + */ + J = -1; + if (InputIsOk) + { + LgIndex_t N; + N = 0; + while (InputIsOk && (N < TotalNumPts)) + { + EntIndex_t CurVar; + for (CurVar = 0; InputIsOk && (CurVar < *NumVars); CurVar++) + { + double *CurVPtr = (*VDataBase)[CurVar+CurZone*(*NumVars)]; + if (VarSharesFromZone[CurVar] != -1) + { + EntIndex_t SourceZone = VarSharesFromZone[CurVar]; + double *SourceVPtr = (*VDataBase)[CurVar+SourceZone*(*NumVars)]; + CurVPtr[N] = SourceVPtr[N]; + } + else if (!IsVarPassive[CurVar]) + { + double D = GetNextValue(ReadTecFileStream, + VarType[CurVar], + -LARGEDOUBLE, + LARGEDOUBLE, + &InputIsOk); + + if (InputIsOk && CurVPtr) + CurVPtr[N] = D; + } + } + + if (!InputIsOk) + ErrMsg(translate("Binary datafile corrupted!")); + N++; + } + } + } + + if (InputIsOk && *IVersion < 101) + { + if (ZoneIsFinite) + { + /* + * Pre-version 101 had FE connectivity sharing, + * FECONNECT, information here. + */ + Boolean_t DupConnectivity; + if (*IVersion > 61) + DupConnectivity = GetIoFileInt(ReadTecFileStream, *IVersion, 0, 1, &InputIsOk); + else + DupConnectivity = FALSE; + + if (DupConnectivity) + ConnectivitySharesFromZone[CurZone] = CurZone - 1; /* previous zone */ + else + ConnectivitySharesFromZone[CurZone] = -1; + } + else + ConnectivitySharesFromZone[CurZone] = -1; + } + + if (InputIsOk && ZoneIsFinite && !ZoneIsFEPoly) + { + Boolean_t SkipNodemap; + NodeMap_t *NM = NULL; + NodeMap_t *ONM = NULL; + /* + * Allocate the nodemap ptr if necessary Note that if + * RawDataSpaceAllocated is TRUE then (*NodeMap)[CurZone] + * can either contain a valid address (read the connectivity + * list) or be NULL (skip the list). + */ + if (!RawDataSpaceAllocated && NumKPts*NumJPts >= 1) + { + (*NodeMap)[CurZone] = ALLOC_ARRAY(NumKPts * NumJPts, NodeMap_t, "node map"); + if ((*NodeMap)[CurZone] == NULL) + ErrMsg(translate("Cannot allocate space for connectivity list", + "See the Tecplot User's Manual for a definition of 'connectivity list'")); + } + + if (InputIsOk) + NM = (*NodeMap)[CurZone]; + + SkipNodemap = (NM == NULL); + + if (InputIsOk && ConnectivitySharesFromZone[CurZone] != -1) + { + EntIndex_t SourceZone = ConnectivitySharesFromZone[CurZone]; + if (SourceZone >= CurZone) + { + ErrMsg(translate("Zone %d is attempting to share connectivity " + "with a zone that has not yet been loaded."), + CurZone + 1); + InputIsOk = FALSE; + } + else + { + ONM = (*NodeMap)[SourceZone]; + if (ONM == NULL) + { + ErrMsg(translate("Zone %d is attempting to share connectivity " + "with a zone that is not finite element."), + CurZone + 1); + InputIsOk = FALSE; + } + } + } + + if (InputIsOk) + { + /* load the FE node connectivity */ + for (J = 0; J < NumJPts; J++) + for (I = 0; I < NumKPts; I++) + { + LgIndex_t M; + LgIndex_t L = J * NumKPts + I; + if (ConnectivitySharesFromZone[CurZone] != -1) + M = ONM[L]; + else + M = GetNextI(ReadTecFileStream, &InputIsOk) - 1; + if (!SkipNodemap) + NM[L] = M; + } + } + } + + /* skip over the face neighbor connectivity */ + if (*IVersion >= 101 && InputIsOk) + { + EntIndex_t SharedZone = ConnectivitySharesFromZone[CurZone]; + if (SharedZone == -1 && FNNumBndryConns[CurZone] != 0) + { + LgIndex_t Connection = 0; + while (Connection < FNNumBndryConns[CurZone] && InputIsOk) + { + /* + * Face neighbor connection have the following format for both + * ASCII and binary: + * + * FaceNeighborMode_LocalOneToOne 3 cz,fz,cz + * FaceNeighborMode_LocalOneToMany nz+4 cz,fz,oz,nz,cz1,cz2,...,czn + * FaceNeighborMode_GlobalOneToOne 4 cz,fz,ZZ,CZ + * FaceNeighborMode_GlobalOneToMany 2*nz+4 cz,fz,oz,nz,ZZ1,CZ1,ZZ2,CZ2,...,ZZn,CZn + * + * Where: + * cz = cell in current zone + * fz = face of cell in current zone + * oz = face obsuration flag (only applies to one-to-many): + * 0 = face partially obscured + * 1 = face entirely obscured + * nz = number of cell or zone/cell associations (only applies to one-to-many) + * ZZ = remote Zone + * CZ = cell in remote zone + */ + (void)GetNextI(ReadTecFileStream, &InputIsOk); /* read cz */ + if (!InputIsOk) + ErrMsg(translate("Unexpected end-of-file while reading face neighbor data.")); + + (void)GetNextI(ReadTecFileStream, &InputIsOk); /* read fz */ + + if (InputIsOk) + { + /* + * read FaceNeighborMode_LocalOneToOne: cz || + * FaceNeighborMode_LocalOneToMany: oz || + * FaceNeighborMode_GlobalOneToOne: ZZ || + * FaceNeighborMode_GlobalOneToMany: oz + */ + if (CurZoneSpec->FNMode == FaceNeighborMode_LocalOneToOne) + (void)GetNextI(ReadTecFileStream, &InputIsOk); + else if (CurZoneSpec->FNMode == FaceNeighborMode_LocalOneToMany) + (void)GetNextI(ReadTecFileStream, &InputIsOk); + else if (CurZoneSpec->FNMode == FaceNeighborMode_GlobalOneToOne) + (void)GetNextI(ReadTecFileStream, &InputIsOk); + else if (CurZoneSpec->FNMode == FaceNeighborMode_GlobalOneToMany) + (void)GetNextI(ReadTecFileStream, &InputIsOk); + else + CHECK(FALSE); + + if (CurZoneSpec->FNMode != FaceNeighborMode_LocalOneToOne && InputIsOk) + { + LgIndex_t NumAssociations = 0; + /* + * read FaceNeighborMode_LocalOneToMany: nz || + * FaceNeighborMode_GlobalOneToOne: CZ || + * FaceNeighborMode_GlobalOneToMany: nz + */ + if (CurZoneSpec->FNMode == FaceNeighborMode_LocalOneToMany) + NumAssociations = GetNextI(ReadTecFileStream, &InputIsOk); + else if (CurZoneSpec->FNMode == FaceNeighborMode_GlobalOneToOne) + (void)GetNextI(ReadTecFileStream, &InputIsOk); + else if (CurZoneSpec->FNMode == FaceNeighborMode_GlobalOneToMany) + NumAssociations = GetNextI(ReadTecFileStream, &InputIsOk); + else + CHECK(FALSE); + + if (CurZoneSpec->FNMode != FaceNeighborMode_GlobalOneToOne && InputIsOk) + { + LgIndex_t Assoc; + if (CurZoneSpec->FNMode == FaceNeighborMode_LocalOneToMany) + for (Assoc = 0; Assoc < NumAssociations && InputIsOk; Assoc++) + (void)GetNextI(ReadTecFileStream, &InputIsOk); /* read czn */ + else if (CurZoneSpec->FNMode == FaceNeighborMode_GlobalOneToMany) + for (Assoc = 0; Assoc < NumAssociations && InputIsOk; Assoc++) + { + (void)GetNextI(ReadTecFileStream, &InputIsOk); /* read ZZn */ + (void)GetNextI(ReadTecFileStream, &InputIsOk); /* read CZn */ + } + else + CHECK(FALSE); + + if (InputIsOk) + Connection += NumAssociations; + } + else if (InputIsOk) /* CurZoneSpec->FNMode == FaceNeighborMode_GlobalOneToOne */ + Connection += 1; + } + else if (InputIsOk) /* CurZoneSpec->FNMode == FaceNeighborMode_LocalOneToOne */ + Connection += 1; + + if (!InputIsOk) + ErrMsg(translate("Corrupt input file: invalid face neighbors.")); + } + } + } + }/* face neighbor connectivity */ + /* skip over face map section */ + if (ZoneIsFEPoly && + *IVersion >= 110 && + ConnectivitySharesFromZone[CurZone] != -1 && + InputIsOk) + { + if (!InBlockFormat) + { + ErrMsg(translate("Poly zones must be in block format")); + InputIsOk = FALSE; + } + if (InputIsOk) + { + HgIndex_t NumFaces = CurZoneSpec->NumPtsK; + if (*IVersion == 110) // ...version 111 moved these to the zone header + { + CurZoneSpec->NumFaceNodes = GetNextI(ReadTecFileStream, &InputIsOk); + CurZoneSpec->NumFaceBndryFaces = GetNextI(ReadTecFileStream, &InputIsOk); + CurZoneSpec->NumFaceBndryItems = GetNextI(ReadTecFileStream, &InputIsOk); + } + HgIndex_t TotalNumFaceNodes = CurZoneSpec->NumFaceNodes; + HgIndex_t TotalNumBndryFaces = CurZoneSpec->NumFaceBndryFaces; + HgIndex_t TotalNumBndryItems = CurZoneSpec->NumFaceBndryItems; + if (CurZoneSpec->Type == ZoneType_FEPolyhedron) + ReadInt32Block(ReadTecFileStream, FALSE, NULL, 0, NumFaces + 1, &InputIsOk); + if (InputIsOk) + ReadInt32Block(ReadTecFileStream, FALSE, NULL, 0, TotalNumFaceNodes, &InputIsOk); + if (InputIsOk) + ReadInt32Block(ReadTecFileStream, FALSE, NULL, 0, NumFaces, &InputIsOk); + if (InputIsOk) + ReadInt32Block(ReadTecFileStream, FALSE, NULL, 0, NumFaces, &InputIsOk); + if (TotalNumBndryFaces > 0) + { + if (InputIsOk) + ReadInt32Block(ReadTecFileStream, FALSE, NULL, 0, TotalNumBndryFaces + 1, &InputIsOk); + if (InputIsOk) + ReadInt32Block(ReadTecFileStream, FALSE, NULL, 0, TotalNumBndryItems, &InputIsOk); + if (InputIsOk) + { + if (*IVersion >= 112) + ReadInt32Block(ReadTecFileStream, FALSE, NULL, 0, TotalNumBndryItems, &InputIsOk); + else + ReadInt16Block(ReadTecFileStream, FALSE, NULL, 0, TotalNumBndryItems, &InputIsOk); + } + } + } + }/* face map section */ + } + else + { + ErrMsg(translate("Corrupt input file")); + InputIsOk = FALSE; + } + } + + if (VarSharesFromZone) + FREE_ARRAY(VarSharesFromZone, "VarSharesFromZone"); + if (IsVarPassive) + FREE_ARRAY(IsVarPassive, "IsVarPassive"); + if (ConnectivitySharesFromZone) + FREE_ARRAY(ConnectivitySharesFromZone, "ConnectivitySharesFromZone"); + if (VarType) + FREE_ARRAY(VarType, "VarType"); + + if (!InputIsOk && !RawDataSpaceAllocated) + { + int I; + if (*VDataBase) + { + for (I = 0; I < *NumZones*(*NumVars); I++) + { + if ((*VDataBase)[I]) + FREE_ARRAY((*VDataBase)[I], "vdatabase array"); + } + FREE_ARRAY(*VDataBase, "vdatabase pointer array"); + } + + + if (*NodeMap) + { + for (I = 0; I < *NumZones; I++) + { + if ((*NodeMap)[I]) + FREE_ARRAY((*NodeMap)[I], "connectivity list"); + } + FREE_ARRAY(*NodeMap, "connectivity pointer array"); + } + } + } /*Reading Raw Data*/ + + if (FNNumBndryConns != NULL) + FREE_ARRAY(FNNumBndryConns, "FNNumBndryConns"); + if (ZoneSpecList) + ArrayListDealloc(&ZoneSpecList, ZoneSpecItemDestructor, 0); + + if (ReadTecFileStream) + { +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#else + TP_FCLOSE(ReadTecFileStream->File); + free(ReadTecFileStream); +#endif + } + return (InputIsOk); +} + + +void * STDCALL TecAlloc(size_t size) +{ + return (void *)ALLOC_ARRAY(size, char, "TecAlloc"); +} + +void STDCALL TecFree(void *ptr) +{ + /* Hack to remove delete warning... */ + char *Tmp = (char *)ptr; + FREE_ARRAY(Tmp, "TecAlloc"); +} + + diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/filestream.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/filestream.cpp new file mode 100644 index 0000000000000000000000000000000000000000..049f99ed74791f968339faff51af265fb9a231f0 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/filestream.cpp @@ -0,0 +1,78 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +#include "stdafx.h" +#include "MASTER.h" +#define TECPLOTENGINEMODULE + +/* + ***************************************************************** + ***************************************************************** + ******* ******** + ****** Copyright (C) 1988-2008 Tecplot, Inc. ******* + ******* ******** + ***************************************************************** + ***************************************************************** +*/ + +#define FILESTREAMMODULE + +#include "GLOBAL.h" +#include "TASSERT.h" +#include "ALLOC.h" +#include "SYSTEM.h" +#include "FILESTREAM.h" + +/** + */ +FileStream_s *FileStreamAlloc(FILE *File, + Boolean_t IsByteOrderNative) +{ + REQUIRE(VALID_REF(File) || File == NULL); + + FileStream_s *Result = ALLOC_ITEM(FileStream_s, "FileStream"); + if (Result != NULL) + { + Result->File = File; + Result->IsByteOrderNative = IsByteOrderNative; + } + + ENSURE(VALID_REF(Result) || Result == NULL); + return Result; +} + +/** + */ +void FileStreamDealloc(FileStream_s **FileStream) +{ + REQUIRE(VALID_REF(FileStream)); + REQUIRE(VALID_REF(*FileStream) || *FileStream == NULL); + + if (*FileStream != NULL) + { + FREE_ITEM(*FileStream, "FileStream"); + *FileStream = NULL; + } + + ENSURE(*FileStream == NULL); +} diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/geom2.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/geom2.cpp new file mode 100644 index 0000000000000000000000000000000000000000..198f096fd9efe20dfaabd2d99fb4c4902a848f74 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/geom2.cpp @@ -0,0 +1,89 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +#include "stdafx.h" +#include "MASTER.h" +#define TECPLOTENGINEMODULE + +/* +***************************************************************** +***************************************************************** +******* ******** +****** Copyright (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +***************************************************************** +***************************************************************** +*/ + +#define GEOM2MODULE +#include "GLOBAL.h" +#include "TASSERT.h" +#include "Q_UNICODE.h" +#include "ALLOC.h" + +#include "GEOM.h" +#include "TEXT.h" +#include "STRUTIL.h" +#include "GEOM2.h" + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif +#include "DATASET0.h" + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# if 0 /* 3D geometry arrowheads are not drawn at this time. */ +#endif +# if 0 /* 3D geometry arrowheads are not drawn at this time. */ +# endif +#if 0 +#endif +# ifndef NO_ASSERTS +# endif +# ifndef NO_ASSERTS +# endif +#endif /* TECPLOTKERNEL */ + + +FieldDataType_e GetGeomFieldDataType(Geom_s const* Geom) +{ + FieldDataType_e Result; + + REQUIRE(VALID_REF(Geom)); + REQUIRE(VALID_REF(Geom->GeomData.Generic.V1Base)); + + Result = Geom->DataType; + + ENSURE(VALID_GEOM_FIELD_DATA_TYPE(Result)); + /* + * Check that the geom's field data arrays (if they exist) + * have the same type as the geometry. + */ + ENSURE(IMPLICATION(VALID_REF(Geom->GeomData.Generic.V1Base), Result == GetFieldDataType(Geom->GeomData.Generic.V1Base))); + ENSURE(IMPLICATION(VALID_REF(Geom->GeomData.Generic.V2Base), Result == GetFieldDataType(Geom->GeomData.Generic.V2Base))); + ENSURE(IMPLICATION(VALID_REF(Geom->GeomData.Generic.V3Base), Result == GetFieldDataType(Geom->GeomData.Generic.V3Base))); + + return Result; +} diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/q_msg.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/q_msg.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6a20cf56041abe9cb11696a33ab6c81d00de9729 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/q_msg.cpp @@ -0,0 +1,415 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +#include "stdafx.h" +#include "MASTER.h" + +#define TECPLOTENGINEMODULE + +/* +****************************************************************** +****************************************************************** +******* ******** +****** (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +****************************************************************** +****************************************************************** +*/ + +#define Q_MSGMODULE +#include "GLOBAL.h" +#include "TASSERT.h" +#include "Q_UNICODE.h" +#include "ALLOC.h" +#include "ARRLIST.h" + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if !defined ENGINE +#if defined MOTIF +#endif +#if defined MSWIN +#endif +#endif +#endif + +#include "STRUTIL.h" +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +using std::string; +using namespace tecplot::strutil; +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#define MAXCHARACTERSPERLINE 60 +/* + * Wrap a string so it contains at most CharactersPerLine + * characters. Embedded newlines are left alone. Spaces + * following newlines are also left alone. + */ +Boolean_t WrapString(const char *OldString, + char **NewString) +{ + size_t L; + if (OldString == NULL) + return (FALSE); + + /* + * Assume Old string has ample spaces. Will only be + * replacing some spaces with newlines and removing + * other spaces. New string can be allocated to be + * same length as old string. + */ + + L = strlen(OldString); + *NewString = ALLOC_ARRAY(L + 1, char, "new error message string"); + if (*NewString == NULL) + return (FALSE); + + strcpy(*NewString, OldString); + + if (L > MAXCHARACTERSPERLINE) + { + char *LineStart = *NewString; + char *LastWord = *NewString; + char *WPtr = *NewString; + while (WPtr && (*WPtr != '\0')) + { + size_t CurLen; + /* + * Find next hard newline. If there is one befor the + * line should be chopped then reset the Last Word to + * be at the first word after the newline. + */ + WPtr = strchr(LineStart, '\n'); + if (WPtr && ((WPtr - LineStart) < MAXCHARACTERSPERLINE)) + { + WPtr++; + while (*WPtr == '\n') + WPtr++; + LineStart = WPtr; + /* + * Skip over trailing spaces. Special handling to + * allow indent after hard newline. + */ + while (*WPtr == ' ') + WPtr++; + LastWord = WPtr; + continue; + } + /* + * Find next "word" + */ + WPtr = strchr(LastWord, ' '); + if (WPtr != NULL) + { + while (*WPtr == ' ') + WPtr++; + } + + if (WPtr == NULL) + { + CurLen = strlen(LineStart); + } + else + { + CurLen = WPtr - LineStart; + } + + if (CurLen > MAXCHARACTERSPERLINE) + { + /* + * Line is too long. Back up to previous + * word and replace preceeding space with + * a newline. + */ + if (LastWord == LineStart) + { + /* + * Bad news, line has very long word. + */ + if (WPtr && (*WPtr != '\0')) + { + *(WPtr - 1) = '\n'; + LastWord = WPtr; + } + } + else + { + *(LastWord - 1) = '\n'; + } + LineStart = LastWord; + } + else + LastWord = WPtr; + } + } + return (TRUE); +} + + +static void SendWarningToFile(FILE *F, + const char *S) +{ + char *S2; + REQUIRE(VALID_REF(F)); + REQUIRE(VALID_REF(S)); + if (WrapString(S, &S2)) + { + fprintf(F, "Warning: %s\n", S2); + FREE_ARRAY(S2, "temp warning string"); + } +} + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + +/** + * Show the warning message. Note that the Format string can be the only + * argument, in which case it is essentially the warning message itself. + * + * param Format + * C Format string or a simple message. + * param ... + * Zero or more variable arguments. The number of arguments must correspond + * to the placeholders in the format string. + */ +void Warning(TranslatedString Format, + ...) /* zero or more arguments */ +{ + REQUIRE(!Format.isNull()); + + static Boolean_t InWarning = FALSE; /* ...used to prevent recursive deadlock */ + if (!InWarning) + { +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + InWarning = TRUE; + { + /* + * Attempt to format the string. Failing that simply use the original format + * string argument which, if we ran out of memory while formatting, is + * probably just an warning message saying that we ran out of memory in some + * previous operation anyway. + */ + Boolean_t cleanUp = TRUE; + + va_list Arguments; + va_start(Arguments, Format); + char* message = vFormatString(Format.c_str(), Arguments); + va_end(Arguments); + + if (message == NULL) + { + cleanUp = FALSE; // ...this boolean allows us to "carefully" cast away the const'ness + message = (char*)Format.c_str(); + } + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#ifdef MSWIN +#endif +#if defined UNIXX +#endif +#if defined MSWIN +#endif +#else /* !TECPLOTKERNEL */ + { + SendWarningToFile(stderr, message); + } +#endif + + if (cleanUp) + FREE_ARRAY(message, "message"); + } + InWarning = FALSE; + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + } +} + + +static void SendErrToFile(FILE *File, + const char *Msg) +{ + char *FormattedMsg; + REQUIRE(VALID_REF(File)); + REQUIRE(VALID_REF(Msg)); + if (WrapString(Msg, &FormattedMsg)) + { + fprintf(File, "Err: %s\n", FormattedMsg); + FREE_ARRAY(FormattedMsg, "temp error string"); + } + else + fprintf(File, "Err: %s\n", Msg); +} + + +/* Fall-back ErrMsg procedure when nothing else works */ +static void DefaultErrMsg(const char *Msg) +{ + REQUIRE(VALID_REF(Msg)); + +#ifdef MSWIN +#ifdef TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#else + MessageBox(NULL, Msg, "Error", MB_OK | MB_ICONERROR); +#endif +#else + SendErrToFile(stderr, Msg); +#endif +} + +static void PostErrorMessage(TranslatedString Format, + va_list Arguments) +{ + REQUIRE(!Format.isNull()); + + /* + * Attempt to format the string. Failing that simply use the original format + * string argument which, if we ran out of memory while formatting, is + * probably just an error message saying that we ran out of memory in some + * previous operation anyway. + */ + Boolean_t cleanUp = TRUE; + char* messageString = vFormatString(Format.c_str(), Arguments); + if (messageString == NULL) + { + cleanUp = FALSE; // ...this boolean allows us to "carefully" cast away the const'ness + messageString = (char*)Format.c_str(); + } + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#ifdef MSWIN +#endif +#if defined UNIXX +#if !defined ENGINE +#endif +#endif +#else /* !TECPLOTKERNEL */ + { + DefaultErrMsg(messageString); + } +#endif + + /* cleanup if we allocated the string */ + if (cleanUp) + FREE_ARRAY(messageString, "messageString"); +} + +/* + * NOTES: + * This function is thread safe in that it may be safely called by multiple + * threads however when running interactively only the first error message is + * queued for display on idle. In batch mode all messages are sent to the + * batch log file. + */ +void vErrMsg(TranslatedString Format, + va_list Arguments) +{ + REQUIRE(!Format.isNull()); + + static Boolean_t InErrMsg = FALSE; /* ...used to prevent recursive deadlock */ + if (!InErrMsg) + { +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + InErrMsg = TRUE; + { + PostErrorMessage(Format, Arguments); + } + InErrMsg = FALSE; + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + } +} + +/** + * Show the error message. Note that the Format string can be the only + * argument, in which case it is essentially the error message itself. + * + * @param Format + * C Format string or a simple message. + * @param ... + * Zero or more variable arguments. The number of arguments must correspond + * to the placeholders in the format string. + */ +void ErrMsg(TranslatedString Format, + ...) /* zero or more arguments */ +{ + REQUIRE(!Format.isNull()); + + va_list Arguments; + va_start(Arguments, Format); +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#else + PostErrorMessage(Format, Arguments); +#endif + va_end(Arguments); +} + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if !defined ENGINE +#endif +#if !defined ENGINE +#if defined MOTIF +#endif +#if defined MSWIN +#endif +#endif +#if !defined ENGINE +#if defined MOTIF +#endif +#if defined MSWIN +#endif +#endif +#if !defined ENGINE +#if defined MOTIF +#endif /* MOTIF */ +#if defined MSWIN +#endif +#if defined MOTIF +#endif /* MOTIF */ +#endif +#if !defined ENGINE +#endif +#endif /* TECPLOTKERNEL */ + diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/q_unicode.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/q_unicode.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4d4db61e1ddb9fd3fec146882ef268a9b4973ea1 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/q_unicode.cpp @@ -0,0 +1,447 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +#include "stdafx.h" +#include "MASTER.h" + +#define TECPLOTENGINEMODULE + +/* +****************************************************************** +****************************************************************** +******* ******** +****** (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +****************************************************************** +****************************************************************** +*/ +#define Q_UNICODEMODULE + +#include "GLOBAL.h" +#include "TASSERT.h" + +#if !defined TECPLOTKERNEL +#include "TranslatedString.h" +#endif + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#include "ALLOC.h" + +#include "Q_UNICODE.h" + +using namespace std; + +namespace tecplot +{ +namespace strutil +{ + +typedef std::map<std::string, char *> EnvStringPoolMap_t; +static EnvStringPoolMap_t mapEnvStringPool; + + +#if defined MSWIN + + +string WStringToString(wstring str) +{ + REQUIRE("str is any wide string"); + string Result = WideCharToUtf8(str.c_str()); + + ENSURE("Result is any string"); + return Result; +} + +wstring StringToWString(string str) +{ + REQUIRE("str is any string"); + + wstring Result = Utf8ToWideChar(str.c_str()); + + ENSURE("Result is any string"); + return Result; +} +#endif + +/************************************************ + * Utf8Api + ************************************************/ +#define VALID_CODE_PAGE(cp) \ + ( (cp) == 932 || (cp) == CP_UTF8 || (cp) == CP_ACP || (cp) == CP_OEMCP || (cp) == CP_THREAD_ACP ) + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if defined MSWIN && !defined ENGINE +#endif +#if defined MSWIN +#endif +#endif + + +#if defined MSWIN + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif /* TECPLOTKERNEL */ + +std::string WideCharToMultiByte(const wchar_t* WideString, + unsigned int CodePage) +{ + REQUIRE(VALID_REF(WideString)); + REQUIRE(VALID_CODE_PAGE(CodePage)); + + string strResult; + wstring wString(WideString); + + + if (wString.length() > 0) + { + size_t nLen = + (size_t) ::WideCharToMultiByte(CodePage, + 0, + wString.c_str(), + -1, + NULL, + 0, + NULL, + NULL); + if (nLen > 0) + { + char *pBuffer = ALLOC_ARRAY(nLen, char, "pBuffer"); + + VERIFY(::WideCharToMultiByte(CodePage, + 0, + WideString, + (int)(wString.length() + 1), + pBuffer, + (int)nLen, + NULL, + NULL) != 0); + + strResult = pBuffer; + FREE_ARRAY(pBuffer, "pBuffer"); + + } + else + { + // this should never be an error + CHECK(FALSE); + } + } + else + { + // output 'str' remains empty + } + + ENSURE("strResult is a valid STL string"); + return strResult; + + +} + +wstring MultiByteToWideChar(const char *UTF8String, + unsigned int CodePage) +{ + REQUIRE(VALID_REF(UTF8String)); + REQUIRE(VALID_CODE_PAGE(CodePage)); + + wstring strResult; + string UTF8str(UTF8String); + + size_t wLen; + + if (UTF8str.length() > 0) + { + wLen = + (size_t) ::MultiByteToWideChar(CodePage, + 0, + UTF8str.c_str(), + -1, + NULL, + 0); + if (wLen > 0) + { + wchar_t *wBuffer = ALLOC_ARRAY(wLen + 1, wchar_t, "wBuffer"); + VERIFY(::MultiByteToWideChar(CodePage, + 0, + UTF8str.c_str(), + (int)(UTF8str.length() + 1), + wBuffer, + (int)wLen) != 0); + + strResult = wBuffer; + FREE_ARRAY(wBuffer, "wBuffer"); + + } + else + { + CHECK(FALSE); // We should never get an error here + } + } + else + { + // strResult is left empty + } + + ENSURE("strResult is a valid CString"); + + wstring strRet(strResult); + return strRet; + +} +#endif + + + +#if defined MSWIN +std::string WideCharToUtf8(const wchar_t *str) +{ + REQUIRE(VALID_REF(str)); /* really cannot be NULL - 2007-10-22 CAM/DTO */ + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + UINT CodePage = CP_ACP; + + string Result = ""; + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + Result = WideCharToMultiByte(str, CodePage); + + ENSURE("Result is any string"); + return Result; +} + +wstring Utf8ToWideChar(const char *str) +{ + REQUIRE(VALID_REF(str)); /* really cannot be NULL - 2007-10-22 CAM/DTO */ + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + UINT CodePage = CP_ACP; + wstring Result; + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + Result = MultiByteToWideChar(str, CodePage); + + ENSURE("Result is any string"); + return Result; +} +#endif + + +Boolean_t IsValidUtf8LeadByte(Byte_t uch) +{ + REQUIRE("uch is any byte"); + Boolean_t Result = + uch <= 0x7F || + (uch >= 0xC0 && uch <= 0xDF) || + (uch >= 0xE0 && uch <= 0xEF) || + (uch >= 0xF0 && uch <= 0xF4); + + ENSURE(VALID_BOOLEAN(Result)); + return Result; +} + +Boolean_t IsValidUtf8ContinuingByte(Byte_t uch) +{ + REQUIRE("uch is any char"); + + Boolean_t Result = + (uch >= 0x80 && uch <= 0xBF); + + ENSURE(VALID_BOOLEAN(Result)); + return Result; +} + +Boolean_t IsValidUtf8Byte(Byte_t uch) +{ + REQUIRE("uch is any char"); + Boolean_t Result = + IsValidUtf8LeadByte(uch) || + IsValidUtf8ContinuingByte(uch); + + REQUIRE(VALID_BOOLEAN(Result)); + return Result; +} + + +Boolean_t ShouldConvertWideStringToUtf8String(const wchar_t *str) +{ + Boolean_t Result = FALSE; + +#if defined MSWIN && defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif /* MSWIN and TECPLOTKERNEL */ + + ENSURE(VALID_BOOLEAN(Result)); + return Result; + +} + +Boolean_t IsValidUtf8String(const char *str) +{ + Boolean_t IsValid = TRUE; + REQUIRE(VALID_REF(str)); + +#if defined MSWIN + size_t len = strlen(str); + Boolean_t InUtf8Sequence = FALSE; + int Utf8SequenceCount = 0; + int MaxUtf8SequenceCount = 0; + + /* we want to process the final \0, so go to <= len */ + + for (size_t ii = 0; IsValid && ii <= len; ii++) + { + Byte_t uch = (Byte_t)str[ii]; + + if (uch <= 0x7F) + { + /* This must be the end of a sequence, + so the sequence count must match + the max sequence count */ + + InUtf8Sequence = FALSE; + IsValid = (Utf8SequenceCount == MaxUtf8SequenceCount); + Utf8SequenceCount = 0; + MaxUtf8SequenceCount = 0; + } + else if (uch >= 0x80 && uch <= 0xBF) + { + /* Continuing byte in a multi byte sequence */ + if (InUtf8Sequence) + { + Utf8SequenceCount++; + } + else + { + IsValid = FALSE; + } + + } + else if (uch >= 0xC0 && uch <= 0xDF) + { + /* Lead byte of 000080-0007FF */ + IsValid = (Utf8SequenceCount == MaxUtf8SequenceCount); + InUtf8Sequence = TRUE; + Utf8SequenceCount = 0; + MaxUtf8SequenceCount = 1; + } + else if (uch >= 0xE0 && uch <= 0xEF) + { + /* Lead byte of 000800-00FFFF */ + IsValid = (Utf8SequenceCount == MaxUtf8SequenceCount); + InUtf8Sequence = TRUE; + Utf8SequenceCount = 0; + MaxUtf8SequenceCount = 2; + } + else if (uch >= 0xF0 && uch <= 0xF4) + { + /* Lead byte of 010000-10FFFF */ + IsValid = (Utf8SequenceCount == MaxUtf8SequenceCount); + Utf8SequenceCount = 0; + InUtf8Sequence = TRUE; + MaxUtf8SequenceCount = 3; + } + + else + { + /* Invalid Utf 8 */ + IsValid = FALSE; + } + } +#endif + + ENSURE(VALID_BOOLEAN(IsValid)); + return IsValid; +} + + +/** + */ +Boolean_t IsNullOrZeroLengthString(const char *str) +{ + REQUIRE(VALID_REF_OR_NULL(str)); + + Boolean_t Result = (str == NULL || strlen(str) == 0); + + ENSURE(VALID_BOOLEAN(Result)); + return Result; +} + +/** + */ +Boolean_t IsNullOrZeroLengthString(TranslatedString TS) +{ + REQUIRE(TS.isValid()); + return TS.isNullOrZeroLength(); +} + + +} +} + +#if defined MSWIN && TECPLOTKERNEL && (!defined NO_ASSERTS || defined CHECKED_BUILD) +/* Keeping Trace out of the release builds + will verify for us that it has been optimized away. + + See the definition of TRACE in MASTER.h for + more information... */ +void MSWinTrace(const char *Format, ...) +{ + REQUIRE(VALID_REF(Format)); + + const int BufferSize = 512; /* Only print the first 512 characers */ + va_list Arguments; + + /* Don't use ALLOC_ARRAY here */ + char *buffer = new char[BufferSize]; + memset(buffer, 0, BufferSize); + + va_start(Arguments, Format); + _vsnprintf(buffer, BufferSize - 1, Format, Arguments); + va_end(Arguments); + + ::OutputDebugStringA(buffer); + + delete [] buffer; +} + + + +#endif diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/set.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/set.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2f6252a4c9893a028d15cc535c20572e53ee46ea --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/set.cpp @@ -0,0 +1,696 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +#include "stdafx.h" +#include "MASTER.h" +#define TECPLOTENGINEMODULE + + +/* +***************************************************************** +***************************************************************** +******* ******** +****** Copyright (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +***************************************************************** +***************************************************************** +*/ + + + +#define SETMODULE +#include "GLOBAL.h" +#include "TASSERT.h" +#include "Q_UNICODE.h" +#include "ALLOC.h" +#include "SET.h" + + +/* * SET FUNCTIONS * */ + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if InitNumZones > InitNumVars +#else +#endif +#if ZoneExpansionFactor > VarExpansionFactor +#else +#endif +#else +#define SetInitSize (PadOut(1,SetBitSize)) +#define SetExpansionFactor 2 +#endif + +using namespace tecplot::strutil; + +/* + */ +Set_pa AllocSet(Boolean_t show_error_msg) +{ + Set_pa Set = ALLOC_ITEM(struct _Set_a, "Set header"); + if (Set) + { + Set->size = SetInitSize; + Set->data = ALLOC_ARRAY(SetInitSize / SetBitSize, SetData_t, "Set data"); + if (Set->data == NULL) + DeallocSet(&Set); + else + ClearSet(Set); + } + if ((Set == NULL) && show_error_msg) + { +# if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# else + fprintf(stderr, "Out of memory for sets"); +# endif + } + return Set; +} /* AllocSet() */ + + +/* + */ +void DeallocSet(Set_pa *Set) +{ + if (Set && *Set) + { + if ((*Set)->data) + FREE_ARRAY((*Set)->data, "Set data"); + FREE_ITEM(*Set, "Set header"); + *Set = NULL; + } +} /* DeallocSet() */ + + +/** + * This function adapts the DeallocSet function to work with the + * ArrayList's deallocation callback. + */ +Boolean_t SetItemDestructor(void *ItemRef, + ArbParam_t ClientData) +{ + Set_pa *SetRef = (Set_pa *)ItemRef; + + REQUIRE(VALID_REF(SetRef)); + REQUIRE(VALID_REF(*SetRef) || *SetRef == NULL); + + if (*SetRef != NULL) + DeallocSet(SetRef); + + ENSURE(*SetRef == NULL); + return TRUE; +} + + +/* + */ +Boolean_t ExpandSet(Set_pa Set, + SetIndex_t max_val, + Boolean_t show_error_msg) +{ + SetData_t *data; + long new_size; + + REQUIRE(max_val >= 0); + + if (!Set) + { + if (show_error_msg) + { +# if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# else + fprintf(stderr, "Null Set expand"); +# endif + } + return FALSE; + } + + if (max_val <= Set->size) + return TRUE; + + new_size = Set->size; + while (new_size < max_val) + new_size *= SetExpansionFactor; + + new_size = PadOut(new_size, SetBitSize); + + data = ALLOC_ARRAY(new_size / SetBitSize, SetData_t, "new Set data"); + + if (!data) + { + if (show_error_msg) + { +# if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# else + fprintf(stderr, "Out of memory for sets"); +# endif + } + return FALSE; + } + size_t old_set_size_in_bytes = sizeof(data[0]) * (Set->size / SetBitSize); + memcpy(data, Set->data, old_set_size_in_bytes); + + size_t new_set_size_in_bytes = sizeof(data[0]) * (new_size / SetBitSize); + size_t numBytesToReset = new_set_size_in_bytes - old_set_size_in_bytes; + memset(((char*)data) + old_set_size_in_bytes, 0, numBytesToReset); + + FREE_ARRAY(Set->data, "old Set data"); + Set->data = data; + Set->size = new_size; + return TRUE; +} /* ExpandSet() */ + + +/* + */ +Boolean_t CopySet(Set_pa dst, + Set_pa src, + Boolean_t show_error_msg) +{ + if (dst && dst->data && + src && src->data && + ExpandSet(dst, src->size, show_error_msg)) + { + SetIndex_t src_size_in_words = src->size / SetBitSize; + size_t numBytesToCopy = sizeof(dst->data[0]) * src_size_in_words; + memcpy(dst->data, src->data, numBytesToCopy); + + SetIndex_t dst_size_in_words = dst->size / SetBitSize; + CHECK(dst_size_in_words>=src_size_in_words); // ...guaranteed by above ExpandSet() call + size_t numBytesToReset = sizeof(dst->data[0]) * (dst_size_in_words - src_size_in_words); + memset((char*)(dst->data + src_size_in_words), 0, numBytesToReset); + + return TRUE; + } + else + return FALSE; +} /* CopySet() */ + + +/* + */ +Boolean_t AppendSet(Set_pa dst, + Set_pa src, + Boolean_t show_error_msg) +{ + if (dst && dst->data && + src && src->data) + { + SetIndex_t member; + ForAllMembersInSet(member, src) + { + if (!AddToSet(dst, member, TRUE)) + return FALSE; + } + return TRUE; + } + else + return FALSE; +} /* AppendSet() */ + + +/* + */ +void ClearSet(Set_pa Set) +{ + if (Set && Set->data) + memset(Set->data, 0, Set->size / SetBitSize * sizeof(Set->data[0])); +} /* ClearSet() */ + + +#if defined USE_FUNCTIONS_FOR_SETS +/* + */ +Boolean_t AddToSet(Set_pa Set, + SetIndex_t member, + Boolean_t show_error_msg) +{ + REQUIRE(member >= 0); + if (Set && + Set->data && + ((member + 1 <= Set->size) || ExpandSet(Set, member + 1, show_error_msg))) + { + SetIndex_t word = member / SetBitSize; + SetData_t bit = (SetData_t)1 << (member % SetBitSize); + Set->data[word] |= bit; + return TRUE; + } + else + return FALSE; +} /* AddToSet() */ +#endif + + +/* + */ +void RemoveFromSet(Set_pa Set, + SetIndex_t member) +{ + REQUIRE(member >= 0); + if (Set && (member < Set->size) && Set->data) + { + SetIndex_t word = member / SetBitSize; + SetData_t bit = (SetData_t)1 << (member % SetBitSize); + Set->data[word] &= (((SetData_t) - 1) ^ bit); + } +} /* RemoveFromSet() */ + + +/** + * Similar to RemoveFromSet except it shifts the Set. + */ +void DeleteSetMember(Set_pa Set, + SetIndex_t Member) +{ + SetIndex_t LastMember; + + REQUIRE(VALID_REF(Set)); + REQUIRE(Member >= 0); + + LastMember = GetPrevMember(Set, BAD_SET_VALUE); + if (Member <= LastMember) + { + ShiftSet(Set, Member + 1, LastMember, -1); + RemoveFromSet(Set, LastMember); + } +} + + +/** + * Similar to AddToSet except that if the new member is within the currently + * defined set the members are shifted accordingly. + */ +Boolean_t InsertSetMember(Set_pa Set, + SetIndex_t Member, + Boolean_t ShowErrMsg) +{ + Boolean_t IsOk = TRUE; + SetIndex_t OrigLastMember; + + REQUIRE(VALID_REF(Set)); + + /* first, determine if we need to shift the set */ + OrigLastMember = GetPrevMember(Set, BAD_SET_VALUE); + if (Member <= OrigLastMember) + { + IsOk = ExpandSet(Set, (OrigLastMember + 1) + 1, ShowErrMsg); + ShiftSet(Set, Member, OrigLastMember, 1); + } + + if (IsOk) + IsOk = AddToSet(Set, Member, ShowErrMsg); + + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + +#if defined USE_FUNCTIONS_FOR_SETS +/* + */ +Boolean_t InSet(Set_pa Set, + SetIndex_t member) +{ + /* + * Sometimes InSet is called with negative numbers. This is not correct, but + * its what we have to work with. Maybe some day, we can make this assertion. + REQUIRE(member>=0); + */ + if (Set && (0 <= member && member < Set->size)) + { + SetIndex_t word = member / SetBitSize; + SetData_t bit = (SetData_t)1 << (member % SetBitSize); + return (Set->data[word]&bit) != 0; + } + else + return FALSE; +} /* InSet() */ +#endif + + +/* + */ +Boolean_t IsEmpty(Set_pa Set) +{ + if (Set && Set->data) + { + SetIndex_t set_size_in_words = Set->size / SetBitSize; + SetIndex_t word; + for (word = 0; word < set_size_in_words; word++) + if (Set->data[word] != 0) + return FALSE; + } + return TRUE; +} /* IsEmpty() */ + + +/* + */ +Boolean_t HasVoids(Set_pa Set) +{ + Boolean_t Result = FALSE; + SetIndex_t ContiguousMember = 0; + SetIndex_t Member = 0; + + REQUIRE(VALID_REF(Set)); + + /* look for voids in the set */ + ForAllMembersInSet(Member, Set) + { + if (Member == ContiguousMember) + { + ContiguousMember++; + } + else + { + Result = TRUE; + break; + } + } + + ENSURE(VALID_BOOLEAN(Result)); + return Result; +} + + +/* + */ +SetIndex_t MemberCount(Set_pa Set) +{ + SetIndex_t count = 0; + if (Set && Set->data) + { + SetIndex_t set_size_in_words = Set->size / SetBitSize; + SetIndex_t word; + for (word = 0; word < set_size_in_words; word++) + { + SetData_t word_val = Set->data[word]; + while (word_val) + { + if (word_val&1) + count++; + word_val = word_val >> 1; + } + } + } + return count; +} /* MemberCount() */ + + +/* + */ +SetIndex_t GetNextMember(Set_pa Set, + SetIndex_t start_at) +{ + SetIndex_t next_member = BAD_SET_VALUE; + if (Set && Set->data) + { + SetIndex_t set_size_in_words = Set->size / SetBitSize; + SetIndex_t word; + SetData_t word_val = 0; + int bit; + if (start_at == BAD_SET_VALUE) + { + word = 0; + bit = 0; + if (word < set_size_in_words) + word_val = Set->data[0]; + } + else if (start_at + 1 < Set->size) + { + word = (start_at + 1) / SetBitSize; + bit = (start_at + 1) % SetBitSize; + if (word < set_size_in_words) + word_val = Set->data[word] >> bit; + } + else + { + return BAD_SET_VALUE; + } + while ((word < set_size_in_words) && (word_val == 0)) + { + word++; + bit = 0; + if (word < set_size_in_words) + word_val = Set->data[word]; + } + if (word < set_size_in_words) + { + while (!(word_val&1)) + { + word_val >>= 1; + bit++; + } + next_member = word * SetBitSize + bit; + } + } + return next_member; +} /* GetNextMember() */ + + +/* + */ +SetIndex_t GetPrevMember(Set_pa Set, + SetIndex_t start_at) +{ + SetIndex_t next_member = BAD_SET_VALUE; + if (Set && Set->data) + { + SetIndex_t set_size_in_words = Set->size / SetBitSize; + SetIndex_t word; + SetData_t word_val = 0; + int bit; + if (start_at == BAD_SET_VALUE) + { + word = set_size_in_words - 1; + bit = SetBitSize - 1; + if (word >= 0) + word_val = Set->data[word]; + } + else if (start_at > 0) + { + word = (start_at - 1) / SetBitSize; + bit = (start_at - 1) % SetBitSize; + if (word >= 0) + word_val = Set->data[word] << (SetBitSize - bit - 1); + } + else + { + return BAD_SET_VALUE; + } + while ((word >= 0) && (word_val == 0)) + { + word--; + bit = SetBitSize - 1; + if (word >= 0) + word_val = Set->data[word] << (SetBitSize - bit - 1); + } + if (word >= 0) + { + while (!(word_val&SetLastBit)) + { + word_val <<= 1; + bit--; + } + next_member = word * SetBitSize + bit; + } + } + return next_member; +} /* GetPrevMember() */ + + +/* + */ +Boolean_t EqualSets(Set_pa set1, + Set_pa set2) +{ + SetIndex_t set1_size_in_words, + set2_size_in_words, + min_set_size_in_words, + ii; + if (!set1 || !set2) + return FALSE; + + set1_size_in_words = set1->size / SetBitSize; + set2_size_in_words = set2->size / SetBitSize; + min_set_size_in_words = MIN(set1_size_in_words, set2_size_in_words); + + for (ii = 0; ii < min_set_size_in_words; ii++) + if (set1->data[ii] != set2->data[ii]) + return FALSE; + for (ii = min_set_size_in_words; ii < set1_size_in_words; ii++) + if (set1->data[ii] != 0) + return FALSE; + for (ii = min_set_size_in_words; ii < set2_size_in_words; ii++) + if (set2->data[ii] != 0) + return FALSE; + + return TRUE; + +} /* EqualSets() */ + + +Boolean_t IsSubSet(Set_pa childset, + Set_pa parentset) +{ + SetIndex_t s; + + ForAllMembersInSet(s, childset) + { + if (!InSet(parentset, s)) + return (FALSE); + } + + return (TRUE); + +} /* IsSubSet() */ + + + + + + +/* + * functions added 11/7 by byron. These are roughed in for now and could + * stand to be optimized later..... + */ + +/* + * Return the number of members in a set that preceed a given member. + */ + +SetIndex_t MemberOffset(Set_pa Set, + SetIndex_t Member) +{ + SetIndex_t I; + SetIndex_t Offset = -1; + if (InSet(Set, Member)) + { + for (I = 0; I <= Member; I++) + { + if (InSet(Set, I)) + Offset++; + } + } + return (Offset); +} + +/* + * Return the position in the set of the nth member of a set. + */ +SetIndex_t OffsetMember(Set_pa Set, + SetIndex_t Offset) +{ + SetIndex_t I; + SetIndex_t Member = BAD_SET_VALUE; + for (I = 0; I <= Offset; I++) + { + Member = GetNextMember(Set, Member); + if (Member == BAD_SET_VALUE) + break; + } + return (Member); +} + +Boolean_t CopySetMember(Set_pa DstSet, + SetIndex_t DstOffset, + Set_pa SrcSet, + SetIndex_t SrcOffset) +{ + if (InSet(SrcSet, SrcOffset)) + return (AddToSet(DstSet, DstOffset, TRUE)); + else + RemoveFromSet(DstSet, DstOffset); + return (TRUE); +} + + + +/* + * Initial: + * v---ShiftPos1 v--ShiftPos2 + * +-------------------------------------+ + * | | | | | | | |x| | | | | | | |x| | | | + * +-------------------------------------+ + * + * Shift +2 + * v---ShiftPos1 v--ShiftPos2 + * +-------------------------------------+ + * | | | | | | | | | |x| | | | | | | |x| | + * +-------------------------------------+ + * + * + * Shift all bits between ShiftPos1 and ShiftPos2 + * by ShiftAmount. The bits that the shift + * replaces fill in the hole left by the shift + * + * + */ +void ShiftSet(Set_pa Set, + SetIndex_t ShiftPos1, + SetIndex_t ShiftPos2, + SetIndex_t ShiftAmount) +{ + Set_pa NewSet; + SetIndex_t DPos; + SetIndex_t SPos; + + if ((Set == NULL) || (IsEmpty(Set))) + return; + + NewSet = AllocSet(TRUE); + + if (NewSet == NULL) + return; + + if (!CopySet(NewSet, Set, TRUE)) + return; + + if (ShiftAmount < 0) + { + DPos = ShiftPos2; + SPos = ShiftPos1 - 1; + while (DPos > ShiftPos2 + ShiftAmount) + CopySetMember(NewSet, DPos--, Set, SPos--); + SPos = ShiftPos2; + while (SPos >= ShiftPos1) + CopySetMember(NewSet, DPos--, Set, SPos--); + } + else if (ShiftAmount > 0) + { + DPos = ShiftPos1; + SPos = ShiftPos2 + 1; + while (DPos < ShiftPos1 + ShiftAmount) + CopySetMember(NewSet, DPos++, Set, SPos++); + SPos = ShiftPos1; + while (SPos <= ShiftPos2) + CopySetMember(NewSet, DPos++, Set, SPos++); + } + CopySet(Set, NewSet, TRUE); + DeallocSet(&NewSet); +} + + + diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/stdafx.h b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/stdafx.h new file mode 100644 index 0000000000000000000000000000000000000000..066d102e7c732daf416bdf937ab64b3c5ea05500 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/stdafx.h @@ -0,0 +1,130 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +#if !defined STDAFX_H_ +# define STDAFX_H_ + +/* +****************************************************************** +****************************************************************** +******* ******** +****** (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +****************************************************************** +****************************************************************** +*/ +/* + * stdafx.h : include file for standard system include files, + * or project specific include files that are used frequently, but + * are changed infrequently + * Used for Windows only + */ +#if defined _WIN32 + +/* + * Set NDEBUG before including "custafx.h" since that file may + * use NDEBUG. (In fact, for SmartHeap builds this is the case.) + * CAM 2007-04-11 + * + * Previous comment: "Note that _DEBUG is defined by the Windows compiler + * if any of the multi-threaded DLL runtime libraries are used." + */ +#if !defined _DEBUG +#if !defined NDEBUG +#define NDEBUG +#endif +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif /* TECPLOTKERNEL */ + +#if !defined MSWIN +#define MSWIN +#endif + +#define ENGLISH_ONLY // remove to support non-english dll's + +#if !defined WINVER +#define WINVER 0x0500 +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if defined CHECKED_BUILD || defined _DEBUG && !defined COREAPI +#if defined _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES +#endif +#else +#endif +#endif /* TECPLOTKERNEL */ + +/* Windows builds are UNICODE */ +#pragma warning(disable : 4786) /* truncated identifiers in debug symbol table. */ +#pragma warning(disable : 4996) /* deprecated functions */ + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if !defined UNICODE +#endif +#if !defined _AFXDLL +#endif +#if defined _M_IX86 +#else +#endif +#if defined _WIN64 +#if !defined _M_IA64 && !defined _M_AMD64 +#endif +#endif +#if !defined MSWIN +#endif +#if !defined THREED +#endif +#ifndef _AFX_NO_AFXCMN_SUPPORT +#endif /* _AFX_NO_AFXCMN_SUPPORT */ +#ifndef _AFX +#endif +#else /* !TECPLOTKERNEL */ +#define AfxIsValidAddress(ptr,bb) ((ptr)!=NULL) +#endif + +/* 64-bit adjustments */ +#if defined _M_IA64 || defined _M_AMD64 +#define WININT INT_PTR +#define WINUINT UINT_PTR +#else +#define WININT int +#define WINUINT UINT +#endif + +#define WINCALLBACK CALLBACK + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if defined (NDEBUG) +#else +#endif +#endif /* TECPLOTKERNEL */ +#endif /* _WIN32 */ + + +#endif /* STDAFX_H_ */ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/strlist.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/strlist.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ab34a5274c9eac16224facd1c66456348a718c5b --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/strlist.cpp @@ -0,0 +1,1065 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +#include "stdafx.h" +#include "MASTER.h" +#define TECPLOTENGINEMODULE + +/* +****************************************************************** +****************************************************************** +******* ******** +****** (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +****************************************************************** +****************************************************************** +*/ + +#define STRLISTMODULE +#include "GLOBAL.h" +#include "TASSERT.h" +#include "Q_UNICODE.h" +#include "STRUTIL.h" +#include "ALLOC.h" +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif +#include "ARRLIST.h" +#include "STRLIST.h" + +/* END HEADER */ + +using namespace tecplot::strutil; + +/* + * This set of functions provide a wrapper around the array list utilities + * thereby making it aware of item allocation and deallocation. All strings + * given to the string list and returned to the client are copies. Therefore + * it is the client's responsibility to deallocate string results when no + * longer needed. + */ + + +/* + * Destructor for cleaning up string allocations. + * + * param ItemRef + * Reference to the string item to destroy. + * param ClientData + * Any client data needed for destroying the string. + * + * return + * TRUE is a requirement + */ +static Boolean_t StringListItemDestructor(void *ItemRef, + ArbParam_t ClientData) +{ + char **StringRef = (char **)ItemRef; + + REQUIRE(VALID_REF(StringRef)); + REQUIRE(VALID_REF(*StringRef) || *StringRef == NULL); + + if (*StringRef != NULL) + { + FREE_ARRAY(*StringRef, "string"); + *StringRef = NULL; + } + + ENSURE(*StringRef == NULL); + return TRUE; +} + +/* + * String item duplicator. + * + * param TargetItemRef + * Reference to the string list item to receive the duplicate. + * param SourceItemRef + * Reference to the string list item to duplicate. + * param ClientData + * Any client data required for duplication. + * + * return + * TRUE if the duplication was a success + * FALSE otherwise. If the duplication failed it + * is the client's responsibility to cleanup any + * partial duplication + */ +static Boolean_t StringListItemDuplicator(void *TargetItemRef, + void *SourceItemRef, + ArbParam_t ClientData) +{ + Boolean_t IsOk = TRUE; + char **TargetStringRef = (char **)TargetItemRef; + char **SourceStringRef = (char **)SourceItemRef; + + REQUIRE(VALID_REF(TargetStringRef)); + REQUIRE(VALID_REF(SourceStringRef)); + REQUIRE(VALID_REF(*SourceStringRef) || *SourceStringRef == NULL); + + if (*SourceStringRef != NULL) + IsOk = ((*TargetStringRef = DupString(dontTranslate(*SourceStringRef))) != NULL); + else + *TargetStringRef = NULL; + + ENSURE(VALID_REF(*TargetStringRef) || *TargetStringRef == NULL); + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; +} + + +/* + * Determine if the string list handle and its members are sane. + */ +Boolean_t StringListValid(StringList_pa stringList) +{ + Boolean_t isValid = ArrayListIsValid((ArrayList_pa)stringList); + + if (isValid) + { + LgIndex_t stringCount = ArrayListGetCount((ArrayList_pa)stringList); + +#if defined PERFORM_EXPENSIVE_STRLIST_TESTS + { + for (LgIndex_t index = 0; index < stringCount; index++) + { + char *string = ArrayListGetCharPtr((ArrayList_pa)stringList, index); + if (string != NULL && !VALID_REF(string)) + { + isValid = FALSE; + break; + } + } +#else + { + /* Check first and last only */ + if (stringCount > 0) + { + char *string = ArrayListGetCharPtr((ArrayList_pa)stringList, 0); + if (string != NULL && !VALID_REF(string)) + { + isValid = FALSE; + } + } + if (isValid && stringCount > 1) + { + char *string = ArrayListGetCharPtr((ArrayList_pa)stringList, stringCount - 1); + if (string != NULL && !VALID_REF(string)) + { + isValid = FALSE; + } + } + } +#endif /* PERFORM_SKIP_EXPENSIVE_STRLIST_TESTS */ + } + + ENSURE(VALID_BOOLEAN(isValid)); + return isValid; + } + + + /* + * Remove all members of the string list. + */ + void StringListClear(StringList_pa StringList) + { + REQUIRE(StringListValid(StringList)); + + ArrayListDeleteAllItems((ArrayList_pa)StringList, StringListItemDestructor, 0); + + ENSURE(StringListValid(StringList) && StringListCount(StringList) == 0); + } + + + /* + * Remove 'Count' strings from the list beginning at the specified offset. + * The members following the items removed are shifted down accordingly to + * fill the vacated space. + */ + void StringListRemoveStrings(StringList_pa StringList, + LgIndex_t StringOffset, + LgIndex_t Count) + { + REQUIRE(StringListValid(StringList)); + REQUIRE(0 <= StringOffset && StringOffset <= StringListCount(StringList) - 1); + REQUIRE(1 <= Count && StringOffset + Count <= StringListCount(StringList)); + + ArrayListDeleteItems((ArrayList_pa)StringList, StringOffset, Count, + StringListItemDestructor, 0); + + ENSURE(StringListValid(StringList)); + } + + + /* + * Remove the string from the list at the specified offset. The members + * following the item removed are shifted down accordingly to fill the + * vacated space. + */ + void StringListRemoveString(StringList_pa StringList, + LgIndex_t StringOffset) + { + REQUIRE(StringListValid(StringList)); + REQUIRE(0 <= StringOffset && StringOffset <= StringListCount(StringList) - 1); + + ArrayListDeleteItems((ArrayList_pa)StringList, StringOffset, 1, + StringListItemDestructor, 0); + + ENSURE(StringListValid(StringList)); + } + + + /* + * Deallocate the string list members and handle and set the handle to NULL. + */ + void LIBCALL StringListDealloc(StringList_pa *StringList) + { + REQUIRE(VALID_REF(StringList)); + REQUIRE(*StringList == NULL || StringListValid(*StringList)); + + if (*StringList != NULL) + ArrayListDealloc((ArrayList_pa *)StringList, StringListItemDestructor, 0); + + ENSURE(*StringList == NULL); + } + + + /* + * Allocate a string list handle. A handle of NULL is + * returned if sufficient memory is not available. + */ + StringList_pa StringListAlloc(void) + { + StringList_pa Result; + + Result = (StringList_pa)ArrayListAlloc(0, ArrayListType_CharPtr, NULL, 0); + + ENSURE(Result == NULL || StringListValid(Result)); + return Result; + } + + + /* + * Append a copy of the string to the string list. The string list will be + * expanded to accommodate the additional item. A return value of TRUE + * indicates the operation was successful otherwise FALSE is returned + * indicating that sufficient memory was not available for the additional + * item. + */ + Boolean_t StringListAppendString(StringList_pa StringList, + const char *String) + { + Boolean_t IsOk; + + REQUIRE(StringListValid(StringList)); + REQUIRE(String == NULL || VALID_REF(String)); + + IsOk = StringListSetString(StringList, StringListCount(StringList), String); + + ENSURE(StringListValid(StringList)); + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; + } + + + /* + * Return the number of strings currently in the string list. + */ + LgIndex_t LIBCALL StringListCount(StringList_pa StringList) + { + LgIndex_t Result; + + REQUIRE(StringListValid(StringList)); + + Result = ArrayListGetCount((ArrayList_pa)StringList); + + ENSURE(Result >= 0); + return Result; + } + + + /* + * Return a copy of the string at the specified offset in the string list. + */ + char * LIBCALL StringListGetString(StringList_pa StringList, + LgIndex_t StringOffset) + { + char *Result; + const char *StringRef; + + REQUIRE(StringListValid(StringList)); + REQUIRE(0 <= StringOffset && StringOffset <= StringListCount(StringList) - 1); + + StringRef = StringListGetStringRef(StringList, StringOffset); + if (StringRef == NULL) + Result = NULL; + else + Result = DupString(dontTranslate(StringRef)); + + ENSURE(Result == NULL || VALID_REF(Result)); + return Result; + } + + +#if !defined USE_MACROS_FOR_FUNCTIONS + /* + * Returns actual string at the specified offset in the string list. Do not + * attempt to free this string. Changing this string should be done with + * utmost caution. + */ + const char *StringListGetStringRef_FUNC(StringList_pa StringList, + LgIndex_t StringOffset) + { + const char *Result; + + REQUIRE(StringListValid(StringList)); + REQUIRE(0 <= StringOffset && StringOffset <= StringListCount(StringList) - 1); + + Result = StringListGetStringRef_MACRO(StringList, StringOffset); + + ENSURE(Result == NULL || VALID_REF(Result)); + return Result; + } +#endif + + + /* + * Place a copy of the specified string at the specified offset. If the offset + * is beyond the end of the string list it is sized accordingly and the + * intervening string references between the last item of the original + * state and the last item of the new state are assigned NULL. If a string + * already exists at the specified location its resources are released. + * A return value of TRUE indicates the operation was successful otherwise + * FALSE is returned indicating that sufficient memory was not available + * for the additional item at the specified offset. + */ + Boolean_t StringListSetString(StringList_pa StringList, + LgIndex_t StringOffset, + const char *String) + { + Boolean_t IsOk; + ArrayListItem_u ItemCopy; + + REQUIRE(StringListValid(StringList)); + REQUIRE(StringOffset >= 0); + REQUIRE(String == NULL || VALID_REF(String)); + + if (String != NULL) + { + ItemCopy.CharPtr = DupString(dontTranslate(String)); + IsOk = (ItemCopy.CharPtr != NULL); + } + else + { + ItemCopy.CharPtr = NULL; + IsOk = TRUE; + } + + if (IsOk) + IsOk = ArrayListSetItem((ArrayList_pa)StringList, StringOffset, ItemCopy, + StringListItemDestructor, 0); + + ENSURE(StringListValid(StringList)); + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; + } + + + /* + * Insert a copy of the string into the string list at the specified offset. + * The string list will be expanded to accommodate the additional item. + * A return value of TRUE indicates the operation was successful otherwise + * FALSE is returned indicating that sufficient memory was not available + * for the additional item. + */ + Boolean_t StringListInsertString(StringList_pa StringList, + LgIndex_t StringOffset, + const char *String) + { + Boolean_t IsOk; + ArrayListItem_u ItemCopy; + + REQUIRE(StringListValid(StringList)); + REQUIRE(StringOffset >= 0); + REQUIRE(String == NULL || VALID_REF(String)); + + if (String != NULL) + { + ItemCopy.CharPtr = DupString(dontTranslate(String)); + IsOk = (ItemCopy.CharPtr != NULL); + } + else + { + ItemCopy.CharPtr = NULL; + IsOk = TRUE; + } + + if (IsOk) + IsOk = ArrayListInsertItem( + (ArrayList_pa)StringList, StringOffset, ItemCopy); + + ENSURE(StringListValid(StringList)); + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; + } + + + /* + * Return a handle to a duplicate of the specified string list and its contents. + * A handle of NULL is returned if sufficient memory is not available. + */ + StringList_pa StringListCopy(StringList_pa StringList) + { + StringList_pa Result; + + REQUIRE(StringListValid(StringList)); + + Result = (StringList_pa)ArrayListCopy((ArrayList_pa)StringList, + StringListItemDuplicator, 0); + + ENSURE(Result == NULL || + (StringListValid(Result) && + StringListCount(Result) == StringListCount(StringList))); + return Result; + } + + + + /* + * Append a copy of the contents of the source list to the target list. + * A return value of TRUE indicates the operation was successful otherwise + * FALSE is returned indicating that sufficient memory was not available + * for the request. + */ + Boolean_t StringListAppend(StringList_pa Target, + StringList_pa Source) + { + Boolean_t IsOk; + StringList_pa SourceCopy; + + REQUIRE(StringListValid(Target)); + REQUIRE(StringListValid(Source)); + + SourceCopy = StringListCopy(Source); + IsOk = (SourceCopy != NULL); + if (IsOk) + { + ArrayListAppend((ArrayList_pa)Target, (ArrayList_pa)SourceCopy); + /* deallocate the list but not the string items since Target now owns them */ + ArrayListDealloc((ArrayList_pa *)(void *)&SourceCopy, NULL, 0); + } + + ENSURE(StringListValid(Target)); + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; + } + + + + /* + * Return a new line, '\n', separated string representation of the string list. + * Caller is responsible for de-allocating the result. + */ + char *StringListToNLString(StringList_pa StringList) + { + char *Result; + int Count; + size_t Length = 0; + + REQUIRE(StringListValid(StringList)); + + /* determine the resulting new line, '\n', separated string length */ + Count = StringListCount(StringList); + if (Count >= 1) + { + int Index; + for (Index = 0, Length = strlen("\n") * (Count - 1); + Index < Count; + Index++) + { + char *String = ArrayListGetCharPtr((ArrayList_pa)StringList, Index); + if (String != NULL) + Length += strlen(String); + } + } + + /* create a new line, '\n', separated string */ + Result = ALLOC_ARRAY(Length + 1, char, "new line separated string"); + if (Result != NULL) + { + int Index; + for (Index = 0, strcpy(Result, ""); + Index < Count; + Index++) + { + char *String = ArrayListGetCharPtr( + (ArrayList_pa)StringList, Index); + + if (Index != 0) + strcat(Result, "\n"); + + if (String != NULL) + strcat(Result, String); + } + } + + ENSURE(Result == NULL || VALID_REF(Result)); + return Result; + } + + + /* + * Create a string list from the new line, '\n', separated string. The string + * is copied and therefore owned and managed by the caller. + */ + StringList_pa StringListFromNLString(const char *String) + { + StringList_pa Result; + LgIndex_t StartIndex; + LgIndex_t EndIndex; + + REQUIRE(VALID_REF(String)); + + /* create the string list and scan the entire string */ + Result = StringListAlloc(); + for (StartIndex = EndIndex = 0; Result != NULL; EndIndex++) + { + /* end of sub-string ? */ + if (String[EndIndex] == '\n' || String[EndIndex] == '\0') + { + /* extract the sub-string and append it to the string list */ + LgIndex_t Length = EndIndex - StartIndex; + char *SubString = ALLOC_ARRAY(Length + 1, char, "sub string"); + if (SubString != NULL) + { + CopySubString(SubString, String, StartIndex, Length); + StringListAppendString(Result, SubString); + + FREE_ARRAY(SubString, "sub string"); + + if (String[EndIndex] != '\0') + StartIndex = EndIndex + 1; + else + break; /* nothing left to scan */ + } + else + { + /* memory allocation failure: bail out */ + StringListDealloc(&Result); + Result = NULL; + break; + } + } + } + + ENSURE(Result == NULL || StringListValid(Result)); + return Result; + } + + + /* + * Return a 'C' string array representation of the string list. + * Caller is responsible for de-allocating the result. + */ + char **StringListToArray(StringList_pa StringList) + { + char **Result; + + REQUIRE(StringListValid(StringList)); + + Result = (char **)ArrayListToArray((ArrayList_pa)StringList, + StringListItemDuplicator, 0); + + ENSURE(Result == NULL || VALID_REF(Result)); + return Result; + } + + + + /* + * Create a string list from the 'C' string array. The string array + * is copied and therefore owned and managed by the caller. + */ + StringList_pa StringListFromArray(const char **StringArray, + LgIndex_t Count) + { + StringList_pa Result; + + REQUIRE((Count == 0 && StringArray == NULL) || + (Count >= 1 && VALID_REF(StringArray))); + + Result = (StringList_pa)ArrayListFromArray((void *)StringArray, + Count, ArrayListType_CharPtr, + StringListItemDuplicator, 0); + + ENSURE(Result == NULL || StringListValid(Result)); + return Result; + } + + + +#define ISJOINCHAR(c) ((c == ';') || (c == '+')) + + static void SkipWhiteSpaceOrComma(const char **CPtr) + { + REQUIRE(VALID_REF(CPtr) && VALID_REF(*CPtr)); + while (ISWHITESPACE(**CPtr) || (**CPtr == ',')) + (*CPtr)++; + } + + /* + * Obtain the next sub-string. This can be of the form: + * + * [del]any-character-sequence[del] + * + * or + * + * limited-character-sequence + * + * where a limited-character-sequence cannot contain + * any of the following characters: +;,<space> + * + */ + static Boolean_t GetNextSubString(const char **OriginalCPtr, + char **NextSubString) + { + Boolean_t IsOk = TRUE; + const char *CStart; + const char *CPtr; + char InsideDelimiter = '\0'; + + REQUIRE(VALID_REF(OriginalCPtr) && (VALID_REF(*OriginalCPtr))); + REQUIRE(VALID_REF(NextSubString)); + + *NextSubString = NULL; + + CPtr = *OriginalCPtr; + SkipWhiteSpaceOrComma(&CPtr); + + if (*CPtr == '"' || *CPtr == '\'') + { + InsideDelimiter = *CPtr; + CPtr++; + } + + CStart = CPtr; + + while (*CPtr && + ((InsideDelimiter && (*CPtr != InsideDelimiter)) || + (!InsideDelimiter && (*CPtr != ',') && + !ISJOINCHAR(*CPtr) && + !ISWHITESPACE(*CPtr)))) + { + if (InsideDelimiter && + (*CPtr == '\\') && + (*(CPtr + 1) == InsideDelimiter)) + CPtr += 2; + else + CPtr++; + } + + if (InsideDelimiter && (*CPtr != InsideDelimiter)) + IsOk = FALSE; + + + if (IsOk && CStart < CPtr) + { + size_t StrLen = (size_t)(CPtr - CStart); + *NextSubString = ALLOC_ARRAY(StrLen + 1, char, "GetNextSubString: NextSubString"); + if (*NextSubString) + { + char *NPtr = *NextSubString; + /* + * Don't just copy the string because escaped delimiters need to have + * the escape removed... + */ + while (CStart < CPtr) + { + if ((*CStart == '\\') && (*(CStart + 1) == InsideDelimiter)) + CStart++; + *NPtr++ = *CStart++; + } + *NPtr = '\0'; + } + else + IsOk = FALSE; + } + + if (IsOk) + { + if (InsideDelimiter) + CPtr++; + SkipWhiteSpaceOrComma(&CPtr); + *OriginalCPtr = CPtr; + } + + ENSURE(VALID_BOOLEAN(IsOk)); + return IsOk; + } + + + + + /* + * Return a string list representation of a compound string. + * + * The compound String parameter has the following form: + * + * [del]<character-sequence>[del] [GroupJoinCharacter] [del]<character-sequence>[del] [GroupJoinCharacter] ..... + * or + * <nospace-character-sequence> <nospace-character-sequence> ... + * + * where: + * [del] is an optional single quote or a double quote. [del] must be used + * if <character-sequence> contains spaces, commas, or the plus symbol. + * + * GroupJoinCharacter can be either a "+" or a ";" + * + * The GroupJoinCharacter symbol is used to separate character sequences that + * are to be grouped together. If the GroupJoinCharacter symbol is omitted then + * a new group is started. + * + * Internally, the original string is converted to a list of strings where + * each string uses newlines to separate one sub-string from the next. + */ + StringList_pa StringListFromCompound(const char *String) + { + const char *CPtr; + StringList_pa Result; + Boolean_t IsOk = TRUE; + char *CurString = NULL; + + REQUIRE(VALID_REF(String)); + SkipWhiteSpaceOrComma(&String); + REQUIRE(!ISJOINCHAR(*String)); + + /* extract character sequences */ + Result = StringListAlloc(); + CPtr = String; + + while (IsOk && *CPtr != '\0') + { + char *NextSubString = NULL; + Boolean_t WantsToJoin = FALSE; + + if (ISJOINCHAR(*CPtr)) + { + WantsToJoin = TRUE; + CPtr++; + SkipWhiteSpaceOrComma(&CPtr); + } + + IsOk = GetNextSubString(&CPtr, + &NextSubString); + + if (IsOk) + { + /* + * Tack on the sub-string to the running string. + */ + if (WantsToJoin) + TackOnChar(&CurString, '\n'); + if (NextSubString != NULL && strlen(NextSubString) != 0) + IsOk = TackOnString(&CurString, NextSubString, FALSE, FALSE); + else if (CurString == NULL) + CurString = DupString(dontTranslate("")); + } + + if (NextSubString != NULL) + FREE_ARRAY(NextSubString, "StringListFromCompound: NextSubString"); + + /* + * If this is the end of processing or if the next character is + * not a join character then add the current string to the stringlist. + */ + + if (IsOk && !ISJOINCHAR(*CPtr)) + { + StringListAppendString(Result, CurString); + if (CurString != NULL) + FREE_ARRAY(CurString, "current string"); + CurString = NULL; + } + } + + if (CurString != NULL) + FREE_ARRAY(CurString, "current string"); + + if (!IsOk) + StringListDealloc(&Result); + + ENSURE(Result == NULL || StringListValid(Result)); + return Result; + } + + + /* + * Return a compound string representation of a string list. + * + * One common usage in Tecplot: + * The $!OpenLayout command in tecplot has the sub-option + * ALTDATALOADINSTRUCTIONS that has the form: + * '"instr-string1" [GroupJoinCharacter] "instr-string2" [+] ...' + */ + char *StringListToCompound(StringList_pa StringList, + char GroupJoinCharacter, + const char *CharsToEscape) + { + Boolean_t IsOk = TRUE; + LgIndex_t Index; + LgIndex_t Count; + char *Result = NULL; + + REQUIRE(StringListValid(StringList)); + REQUIRE(StringListCount(StringList) >= 1); + REQUIRE(ISJOINCHAR(GroupJoinCharacter)); + REQUIRE(VALID_REF(CharsToEscape)); + + for (Index = 0, Count = StringListCount(StringList), IsOk = TRUE; + Index < Count && IsOk; + Index++) + { + char *String = StringListGetString(StringList, Index); + + if (String != NULL && strlen(String) != 0) + { + char *CStart = NULL; + char *CEnd = NULL; + char *EscapedString = NULL; + const char *EscChar = NULL; + char *StrChar = NULL; + + /* First scan the string and escape any specified characters. */ + /* Note that the Escape sequence is a double backslash because */ + /* it the first escape escapes the escape for variable usage. */ + for (StrChar = String; *StrChar != '\0'; StrChar++) + { + for (EscChar = CharsToEscape; *EscChar != '\0'; EscChar++) + if (*StrChar == *EscChar) + { + IsOk = TackOnChar(&EscapedString, '\\'); + IsOk = TackOnChar(&EscapedString, '\\'); + break; + } + IsOk = TackOnChar(&EscapedString, *StrChar); + } + + CEnd = EscapedString; + while (IsOk && *CEnd != '\0') + { + int Len = 0; + char *TString; + + CStart = CEnd; + while (*CEnd != '\0' && *CEnd != '\n') + { + Len++; + if (*CEnd == '"') + Len++; + CEnd++; + } + + TString = ALLOC_ARRAY(Len + 4, char, "temp compound sub-string"); + if (TString != NULL) + { + char *TStr; + + /* prepend the new string with either */ + /* a space character or the plus symbol */ + if (CStart == EscapedString) + { + if (Index != 0) + IsOk = TackOnChar(&Result, ' '); + } + else + { + IsOk = TackOnChar(&Result, GroupJoinCharacter); + } + + /* stuff TString and append the new string */ + TStr = TString; + *TStr++ = '"'; + while (CStart != CEnd) + { + if (*CStart == '"') + *TStr++ = '\\'; + *TStr++ = *CStart++; + } + *TStr++ = '"'; + *TStr = '\0'; + + TackOnString(&Result, TString, FALSE, FALSE); + FREE_ARRAY(TString, "StringListToCompound"); + TString = NULL; + if (*CEnd) + CEnd++; + } + else + { + IsOk = FALSE; + } + } + + if (EscapedString != NULL) + FREE_ARRAY(EscapedString, "escaped string"); + } + else + { + /* a null pointer or length of zero indicates an empty sub-string */ + if (Index == 0) + TackOnString(&Result, "\"\"", FALSE, FALSE); + else + TackOnString(&Result, " \"\"", FALSE, FALSE); + } + + if (String != NULL) + FREE_ARRAY(String, "string list item"); + } + + if (!IsOk) + { + if (Result != NULL) + { + FREE_ARRAY(Result, "StringListToCompound"); + Result = NULL; + } + } + + ENSURE(Result == NULL || VALID_REF(Result)); + return Result; + } + + + /** + * Holds the comparator function pointer. + */ + static StringListStringComparator_pf ComparatorFunction = NULL; + + + /** + * Forwards the comparison test to the 'Comparator' supplied to the + * 'StringListSort' function. + * + * param Item1 + * Item to compare against Item2. + * param Item2 + * Item to compare against Item1. + * param ClientData + * Contextual information that was passed to the 'ArrayListQSort' function. + * + * return + * -1: if Item1 is less than Item2 + * 0: if Item1 is equal to Item2 + * 1: if Item1 is greater than Item2 + */ + static int STDCALL ComparatorProxy(ArrayListItem_u Item1, + ArrayListItem_u Item2, + ArbParam_t ClientData) + { + /* forward the request */ + return ComparatorFunction(Item1.CharPtr, Item2.CharPtr, ClientData); + } + + + /** + * Compares two strings from a list string. Note that either string may be + * NULL as StringLists allow for NULL elements. + * + * param String1 + * String to compare against String2. + * param String2 + * String to compare against String1. + * param ClientData + * Contextual information that was passed to the 'StringListSort' function. + * + * return + * - A value less than zero if String1 is less than String2. + * - A value of zero if String1 is equal to String2. + * - A value greater than zero if String1 is greater than String2. + */ + static int STDCALL DefaultStrcmpComparator(const char *String1, + const char *String2, + ArbParam_t ClientData) + { + int Result = 0; /* ...quite compiler */ + + REQUIRE(VALID_REF(String1) || String1 == NULL); + REQUIRE(VALID_REF(String2) || String2 == NULL); + + if (String1 != NULL && String2 != NULL) + { + Result = strcmp(String1, String2); + if (Result < 0) + Result = -1; + else if (Result > 0) + Result = 1; + } + else if (String1 == NULL && String2 == NULL) + Result = 0; + else if (String1 == NULL) + Result = -1; + else if (String2 == NULL) + Result = 1; + else + CHECK(FALSE); + + ENSURE((Result == -1) || (Result == 0) || (Result == 1)); + return Result; + } + + /** + * Sorts the string list by repeatedly calling the 'Comparator' function until + * the list is in order. + * + * param StringList + * String list to sort. + * param Comparator + * Function called to compare two string list strings or NULL for the + * default sort. The default sorting handles NULL elements and uses the + * system's strcmp utility for comparing valid strings elements. + * param ClientData + * Contextual information that is passed along to the comparator function. + */ + void StringListSort(StringList_pa StringList, + StringListStringComparator_pf Comparator, + ArbParam_t ClientData) + { +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + REQUIRE(VALID_REF(StringList)); + REQUIRE(VALID_FN_REF(Comparator) || Comparator == NULL); + + /* set up for comparator proxy */ + if (Comparator != NULL) + ComparatorFunction = Comparator; + else + ComparatorFunction = DefaultStrcmpComparator; + + /* sort the array using the comparator proxy to forward */ + /* the comparison request to the supplied comparator */ + ArrayListQSort((ArrayList_pa)StringList, ComparatorProxy, ClientData); + + /* cleanup */ + ComparatorFunction = NULL; + } diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/strutil.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/strutil.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9611722224db84ca7d0600cb9c52b007f35a2897 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/strutil.cpp @@ -0,0 +1,936 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +#include "stdafx.h" +#include "MASTER.h" +#define TECPLOTENGINEMODULE + +/* +****************************************************************** +****************************************************************** +******* ******** +****** (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +****************************************************************** +****************************************************************** +*/ + +#define STRUTILMODULE +#include "GLOBAL.h" +#include "TASSERT.h" +#include "Q_UNICODE.h" +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif +#include "ARRLIST.h" +#include "STRLIST.h" +#include "STRUTIL.h" +#include "ALLOC.h" + +#include "Q_MSG.h" + +#include <algorithm> +#include <cctype> // ...needed to find std::tolower and std::toupper +#include <limits.h> +#include "TranslatedString.h" +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +using namespace std; +using namespace tecplot::strutil; + +#ifdef MSWIN +# pragma warning (disable : 4786) /* STL warning about trucated identifiers */ +#endif + +/* END HEADER */ + +/** + */ +#define INITIAL_FORMAT_BUFFER_SIZE 16384*3 +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif +static char *FormatStringBuffer = NULL; +static int FormatStringBufferSize = INITIAL_FORMAT_BUFFER_SIZE; + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if defined MSWIN +#else +#endif /* !MSWIN */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +/** + * This should be one of the last functions called by Tecplot while mopping up. + */ +void FormatStringBufferCleanup(void) +{ + /* + * NOTE: We use free instead of FREE_ARRAY for the scratch buffer because in + * debug mode FREE_ARRAY uses ErrMsg which uses vFormatString causing + * infinite recursion. + */ + if (FormatStringBuffer != NULL) + free(FormatStringBuffer); + FormatStringBuffer = NULL; +} + +/** + */ +char *vFormatString(const char *Format, + va_list Arguments) +{ + char *Result = NULL; + + REQUIRE(VALID_REF(Format)); + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + /* + * NOTE: We use malloc instead of ALLOC_ARRAY for the scratch buffer because + * in debug mode ALLOC_ARRAY uses ErrMsg which uses vFormatString + * causing infinite recursion. + */ + if (FormatStringBuffer == NULL) + FormatStringBuffer = (char *)malloc(FormatStringBufferSize); + + if (FormatStringBuffer != NULL) + { + Boolean_t TryAgain = FALSE; + do + { + /* + * Assign a value other than '\0' to the end of the buffer so that we + * can determine if the buffer needs to be expanded. If after we call + * vsnprintf the end of the buffer has a '\0' we need to expand it. + */ + FormatStringBuffer[FormatStringBufferSize - 1] = (char)!'\0'; + +# if defined MSWIN + memset(FormatStringBuffer, 0, FormatStringBufferSize - 1); + + TryAgain = + _vsnprintf(FormatStringBuffer, + FormatStringBufferSize, + Format, + Arguments) == -1; +# elif defined IRIX62 + vsprintf(FormatStringBuffer, + Format, + Arguments); + CHECK(strlen(FormatStringBuffer) < FormatStringBufferSize); +# else + vsnprintf(FormatStringBuffer, + FormatStringBufferSize, + Format, + Arguments); +# endif + +#ifndef MSWIN + TryAgain = (FormatStringBuffer[FormatStringBufferSize - 1] == '\0'); +#endif + if (TryAgain) + { + /* + * Reallocate the buffer and try again. + * + * NOTE: We use malloc/free instead of ALLOC/FREE_ARRAY for the + * scratch buffer because in debug mode ALLOC/FREE_ARRAY + * uses ErrMsg which uses vFormatString causing infinite + * recursion. + */ + free(FormatStringBuffer); + FormatStringBufferSize += MAX(1, FormatStringBufferSize / 2); + FormatStringBuffer = (char *)malloc(FormatStringBufferSize); + TryAgain = (FormatStringBuffer != NULL); + if (!TryAgain) + FormatStringBufferSize = INITIAL_FORMAT_BUFFER_SIZE; + } + } + while (TryAgain); + + if (FormatStringBuffer != NULL) + Result = DupString(dontTranslate(FormatStringBuffer)); + } + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + ENSURE(VALID_REF(Result) || Result == NULL); + return Result; +} + +/** + */ +char *FormatString(TranslatedString Format, + ...) /* 0 or more variable arguments */ +{ + REQUIRE(!Format.isNull()); + + va_list Arguments; + va_start(Arguments, Format); + char *Result = vFormatString(Format.c_str(), Arguments); + va_end(Arguments); + + ENSURE(VALID_REF(Result) || Result == NULL); + return Result; +} + +/** + */ +int FormatString(string& Buffer, + TranslatedString Format + ...) /* 0 or more variable arguments */ +{ + REQUIRE(!Format.isNull()); + + va_list Arguments; + va_start(Arguments, Format); + char *FormattedString = vFormatString(Format.c_str(), Arguments); + va_end(Arguments); + + int Result; + if (FormattedString != NULL) + { + Buffer.assign(FormattedString); + Result = (int)Buffer.size(); + FREE_ARRAY(FormattedString, "FormattedString"); + } + else + Result = -1; + + + ENSURE(Result == -1 || Result >= 0); + return Result; +} + +/** + * Returns a duplicate of the string or NULL if sufficient memory is not + * available. + * + * NOTE: This function was created because ResetString(...) does not + * duplicate zero length strings but returns NULL instead. + */ +char *DupString(TranslatedString String) +{ + REQUIRE(VALID_TRANSLATED_STRING(String)); + + char *Result = ALLOC_ARRAY(strlen(String.c_str()) + 1, char, "duplicate string"); + if (Result != NULL) + strcpy(Result, String.c_str()); + + ENSURE(Result == NULL || (VALID_REF(Result) && strcmp(Result, String.c_str()) == 0)); + return Result; +} + + +/* + * Copy up to 'Count' characters from the 'Source' string beginning at + * position 'Index' to the 'Target' string. The actual number of characters + * copied may be less than 'Count' if a '\0' was encountered in the + * 'Source' string before 'Count' characters were copied. + * + * NOTE: The 'Target' and 'Source' strings may overlap. + */ +void CopySubString(char *Target, + const char *Source, + int Index, + int Count) +{ + LgIndex_t Length = 0; + + REQUIRE(VALID_REF(Target)); + REQUIRE("Target string is sized to accommodate a string who's length " + "is at least MIN(strlen(&Source[Index]), Count) characters."); + REQUIRE(VALID_REF(Source)); + REQUIRE(0 <= Index && Index <= (LgIndex_t)strlen(Source)); + REQUIRE(Count >= 0); + + Length = MIN((LgIndex_t)strlen(&Source[Index]), Count); + memmove(Target, &Source[Index], Length); + Target[Length] = '\0'; + + ENSURE(VALID_REF(Target) && (LgIndex_t)strlen(Target) == Length); +} + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif /* TECPLOTKERNEL */ + +/* + * Remove any leading white space from the string and return + * a reference to it. NOTE: The input string is modified. + */ +char *StringFlushLeft(char *String) +{ + char *Result = String; + char *Start = String; + + REQUIRE(VALID_REF(String)); + + /* move the substring beginning at the first non-whitespace */ + /* character to the head of the string */ + while (isspace(*Start)) + Start++; + if (Start != String) + memmove(String, Start, strlen(Start) + 1); + + ENSURE(VALID_REF(Result) && Result == String); + return Result; +} + + +/* + * Remove any trailing white space from the string and return + * a reference to it. NOTE: The input string is modified. + */ +static char *StringFlushRight(char *String) +{ + char *Result = String; + char *End = NULL; + + REQUIRE(VALID_REF(String)); + + for (End = EndOfString(String); End != String && isspace(End[-1]); End--) + End[-1] = '\0'; + + ENSURE(VALID_REF(Result) && Result == String); + return Result; +} + + +/* + * Remove any leading and trailing white space from the string + * and return a reference to it. The return value is not + * absolutely necessary since the input string is modified + * but it is convenient sometimes. + * NOTE: The input string is modified but no memory is + * allocated nor deallocated. + */ +char *TrimLeadAndTrailSpaces(char *String) +{ + REQUIRE((String == NULL) || VALID_REF(String)); + if (String) + return (StringFlushLeft(StringFlushRight(String))); + else + return String; +} + + +/* + * If the specified string is longer than the maximum specified length + * truncate it and return a reference to it. + * + * String + * String to truncate if necessary. + * MaxLength + * Length at which to truncate the specified string if exceeded. + * + * Return + * Reference to the input string. + */ + +// Okay for UTF-8 +char *StringTruncate(char *String, + LgIndex_t MaxLength) +{ + REQUIRE(VALID_REF(String)); + REQUIRE(MaxLength >= 0); + + if ((LgIndex_t)strlen(String) > MaxLength) + String[MaxLength] = '\0';/* UTF8_SetAt(String,'\0',MaxLength); */ + + ENSURE(VALID_REF(String)); + ENSURE((LgIndex_t)strlen(String) <= MaxLength); + return String; +} + + +/* + * Trim and truncate the specified string such that its trimmed length + * does not exceed the specified length and return a reference to it. + * + * String + * String to trim and truncate if necessary. + * MaxLength + * Length at which to truncate the trimmed string if exceeded. + * + * Return + * Reference to the input string. + */ +char *StringTrimAndTruncate(char *String, + LgIndex_t MaxLength) +{ + REQUIRE(VALID_REF(String)); + REQUIRE(MaxLength >= 0); + + TrimLeadAndTrailSpaces(String); + StringTruncate(String, MaxLength); + + ENSURE(VALID_REF(String)); + ENSURE((LgIndex_t)strlen(String) <= MaxLength); + return String; +} + +/** + */ + +#ifndef MSWIN +StringList_pa LineBreakString(const char *String, + UInt32_t WrapMargin) +{ + REQUIRE(VALID_REF(String)); + + StringList_pa Result = StringListAlloc(); + if (Result != NULL) + { + Boolean_t IsOk = TRUE; + if (strlen(String) > WrapMargin) + { + char *StringCopy = DupString(dontTranslate(String)); + IsOk = (StringCopy != NULL); + if (IsOk) + { + char *CPtr = StringCopy; + char *SubString = StringCopy; + UInt32_t SubStringLen = 0; + while (*CPtr != '\0' && IsOk) + { + while (*CPtr != '\0' && SubStringLen < WrapMargin) + { + /* look for a hard break */ + if (*CPtr == '\n') + { + *CPtr = '\0'; /* replace the newline */ + CPtr++; + break; + } + + CPtr++; + SubStringLen++; + } + + /* + * If we didn't find a hard break or the end of the string + * then we need to back up and find the closest space. + */ + if (*CPtr != '\0' && SubStringLen == WrapMargin) + { + /* find the closes space from the right */ + if (*CPtr != ' ') + { + while (CPtr != SubString && *CPtr != ' ') + CPtr--; + if (*CPtr != ' ') + { + /* + * Bummer, this line will exceed the wrap margin. + * Search forward for the next space or newline. + */ + while (*CPtr != '\0' && *CPtr != ' ' && *CPtr != '\n') + CPtr++; + while (*CPtr != '\0' && *CPtr == ' ') + CPtr++; /* skip over the white space */ + } + } + + if (*CPtr != '\0') + { + *CPtr = '\0'; + CPtr++; + } + StringFlushRight(SubString); + } + + IsOk = StringListAppendString(Result, SubString); + SubString = CPtr; + SubStringLen = 0; + } + + FREE_ARRAY(StringCopy, "StringCopy"); + } + } + else + IsOk = StringListAppendString(Result, String); + + if (!IsOk) + StringListDealloc(&Result); + } + + ENSURE(Result == NULL || VALID_REF(Result)); + return Result; +} +#endif + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif /* TECPLOTKERNEL */ + + +/** + * Lexicographically compares, at most, the first 'Len' characters of + * s1 and s2. + * + * param s1 + * First string or NULL. + * param s2 + * Second string or NULL. + * param Len + * Maximum number of characters to compare. + * return + * Integer value greater than, equal to, or less than zero according + * to whether the first 'Len' characters of 's1' are greater than, + * equal to, or less than 's2'. + */ + +// Okay for UTF-8 +int ustrncmp(const char *s1, + const char *s2, + size_t Len) +{ + REQUIRE((s1 == NULL) || VALID_REF(s1)); + REQUIRE((s2 == NULL) || VALID_REF(s2)); + REQUIRE(Len >= 0); + + char *t1; + char *t2; + char ct1; + char ct2; + size_t I = 0; + if ((s1 == NULL) && (s2 == NULL)) + return 0; + if (s1 == NULL) + return -1; + else if (s2 == NULL) + return 1; + + t1 = (char*)s1; + t2 = (char*)s2; + + while (*t1 && *t2 && (I < Len)) + { + ct1 = CAPITAL(*t1); + ct2 = CAPITAL(*t2); + if (ct1 != ct2) + return (ct1 - ct2); + t1++; + t2++; + I++; + } + if ((I == Len) || + ((*t1 == '\0') && (*t2 == '\0'))) + return 0; + else + return CAPITAL(*t1) - CAPITAL(*t2); + + +} + + +/** + * Lexicographically compares the characters of s1 and s2. + * + * param s1 + * First string or NULL. + * param s2 + * Second string or NULL. + * return + * Integer value greater than, equal to, or less than zero according to + * whether the characters of 's1' are greater than, equal to, or less + * than 's2'. + */ +int ustrcmp(const char *s1, + const char *s2) +{ + REQUIRE((s1 == NULL) || VALID_REF(s1)); + REQUIRE((s2 == NULL) || VALID_REF(s2)); + + return (ustrncmp(s1, s2, INT_MAX)); +} + + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if !defined NO_ASSERTS && defined DEBUG_ALLOC +#endif +#endif /* TECPLOTKERNEL */ + + +/* + * The problem with passing file names for release builds is that + * the full path name is used (i.e., c:\user\craig\v7.5\tecplot\alloc.c) + */ + +// Okay for UTF-8 + +#if !defined NO_ASSERTS +Boolean_t InternalResetString(char **SBase, + const char *NewString, + Boolean_t IssueErrMsg, + const char *FileName, + int LineNumber) +#else +Boolean_t InternalResetString(char **SBase, + const char *NewString, + Boolean_t IssueErrMsg) +#endif +{ + REQUIRE(VALID_REF(SBase)); + REQUIRE(*SBase == NULL || VALID_REF(*SBase)); + REQUIRE(NewString == NULL || VALID_REF(NewString)); + REQUIRE(IMPLICATION(VALID_REF(*SBase), *SBase != NewString)); /* Prevent calling with same string. */ + REQUIRE(VALID_BOOLEAN(IssueErrMsg)); + REQUIRE(VALID_NON_ZERO_LEN_STR(FileName)); + REQUIRE(LineNumber >= 1); + + if (*SBase) + { +#if !defined NO_ASSERTS && defined DEBUG_ALLOC + char S[80+1]; + MakeDebugRecord(FileName, LineNumber, "releasing", *SBase, S, 80); + FREE_ARRAY(*SBase, S); +#else + FREE_ARRAY(*SBase, ""); +#endif + } + if (NewString == NULL) + { + *SBase = NULL; + return (TRUE); + } + else + { +#if !defined NO_ASSERTS && defined DEBUG_ALLOC + char S[80+1]; + MakeDebugRecord(FileName, LineNumber, "duplicating", NewString, S, 80); + *SBase = ALLOC_ARRAY(strlen(NewString) + 1, char, S); +#else +# if defined MSWIN && defined _DEBUG && !defined(MAKEARCHIVE) && !defined(NO_ASSERTS) + /* Allow the MFC memory leak detection to report the leak at the + * calling programs location, and not here (which is fairly useless). + * But first, we have to turn off the preprocessor definition of new + * and get to the original. */ +# undef new + *SBase = new(FileName, LineNumber) char[strlen(NewString)+1]; +# define new DEBUG_NEW +# else + *SBase = ALLOC_ARRAY(strlen(NewString) + 1, char, ""); +# endif +#endif + if (*SBase) + { + strcpy(*SBase, NewString); + return (TRUE); + } + else + { + if (IssueErrMsg) + ErrMsg(translate("Out of memory")); + return (FALSE); + } + } +} + + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + + +/* + * Unfortunately, this routine uses the interface of DeleteStringToAdd + * forcing StringToAdd to be non-const. Another copy of this routine + * for const char *'s is below. Eventually we should get rid of + * the two routines and DeleteStringToAdd, always using the const version + * and deleting the string if necessary in the code that calls TackOnString. + */ +Boolean_t TackOnString(char **SBase, + const char *StringToAdd, + Boolean_t DeleteStringToAdd, + Boolean_t ConvertNewlinesToAscii) +{ + size_t CurLen; + size_t NewLen; + int NumNewlines = 0; + char *NewString; + const char *CPtr = StringToAdd; + Boolean_t IsOk = TRUE; + + REQUIRE(VALID_REF(SBase)); + REQUIRE((StringToAdd == NULL) || VALID_REF(StringToAdd)); + REQUIRE(VALID_BOOLEAN(DeleteStringToAdd)); + REQUIRE(VALID_BOOLEAN(ConvertNewlinesToAscii)); + + if ((StringToAdd == NULL) || + (*StringToAdd == '\0')) + { + if (StringToAdd && + (*StringToAdd == '\0') && + DeleteStringToAdd) + { + char *TMP = (char *)StringToAdd; + FREE_ARRAY(TMP, "empty string to add"); + } + } + else + { + + if (*SBase == NULL) + CurLen = 0; + else + CurLen = strlen(*SBase); + + while (*CPtr) + if (*CPtr++ == '\n') + NumNewlines++; + + NewLen = CurLen + strlen(StringToAdd) + 1 + NumNewlines; + + NewString = ALLOC_ARRAY(NewLen, char, StringToAdd); + + if (NewString == NULL) + { + if (DeleteStringToAdd) + { + char *TMP = (char *)StringToAdd; + FREE_ARRAY(TMP, StringToAdd); + } + IsOk = FALSE; + } + else + { + if (*SBase) + { + strcpy(NewString, *SBase); + FREE_ARRAY(*SBase, (CurLen > 0 ? *SBase : "previous text")); + } + else + *NewString = '\0'; + + { + char *NPtr = EndOfString(NewString); + const char *APtr = StringToAdd; + while (*APtr) + { + if ((*APtr == '\n') && ConvertNewlinesToAscii) + { + *NPtr++ = '\\'; + *NPtr++ = 'n'; + } + else + *NPtr++ = *APtr; //UTF8_AssignAndIncrement(&NPtr,(char**)&APtr,TRUE,FALSE); //*NPtr++ = *APtr; + APtr++; + } + *NPtr = '\0'; + } + + if (DeleteStringToAdd) + { + char *TMP = (char *)StringToAdd; + FREE_ARRAY(TMP, StringToAdd); + } + + *SBase = NewString; + } + } + + ENSURE(VALID_BOOLEAN(IsOk)); + return (IsOk); +} + + +/* + * See TackOnString for discussion. + */ + +// Okay for UTF-8 +Boolean_t TackOnConstString(char **SBase, + const char *StringToAdd, + Boolean_t ConvertNewlinesToAscii) +{ + size_t CurLen; + size_t NewLen; + int NumNewlines = 0; + char *NewString; + const char *CPtr = StringToAdd; + Boolean_t IsOk = TRUE; + + REQUIRE(VALID_REF(SBase)); + REQUIRE((StringToAdd == NULL) || VALID_REF(StringToAdd)); + REQUIRE(VALID_BOOLEAN(ConvertNewlinesToAscii)); + + if ((StringToAdd != NULL) && + (*StringToAdd != '\0')) + { + if (*SBase == NULL) + CurLen = 0; + else + CurLen = strlen(*SBase); + + while (*CPtr) + if (*CPtr++ == '\n') + NumNewlines++; + + NewLen = CurLen + strlen(StringToAdd) + 1 + NumNewlines; + + NewString = ALLOC_ARRAY(NewLen, char, StringToAdd); + + if (NewString == NULL) + { + IsOk = FALSE; + } + else + { + if (*SBase) + { + strcpy(NewString, *SBase); + FREE_ARRAY(*SBase, (CurLen > 0 ? *SBase : "previous text")); + } + else + *NewString = '\0'; + + { + char *NPtr = EndOfString(NewString); + const char *APtr = StringToAdd; + while (*APtr) + { + if ((*APtr == '\n') && ConvertNewlinesToAscii) + { + *NPtr++ = '\\'; + *NPtr++ = 'n'; + } + else + *NPtr++ = *APtr; // UTF8_AssignAndIncrement(&NPtr,(char**)&APtr,TRUE,FALSE); + APtr++; + } + *NPtr = '\0'; + } + *SBase = NewString; + } + } + + ENSURE(VALID_BOOLEAN(IsOk)); + return (IsOk); +} + + +// Okay for UTF-8 +Boolean_t TackOnChar(char **SBase, + char CharToAdd) +{ + REQUIRE(VALID_REF(SBase)); + + char S[2]; + S[0] = CharToAdd; + S[1] = '\0'; + + return (TackOnString(SBase, S, FALSE, FALSE)); +} + + + +/** + * Converts all one character new line characters in the allocated string + * to a two character "\n" sequence. + * + * param String + * String to scan and convert if necessary. Note that the string will + * be reallocated if any new line characters are discovered. + * + * return + * TRUE if the request was successfull, FALSE otherwise. + */ + +// Okay for UTF-8 +Boolean_t ReplaceNewlineWithBackslashN(char **String) +{ + size_t I; + LgIndex_t NewlineCount; + size_t Length; + char *Replacement; + + REQUIRE(VALID_REF(String)); + REQUIRE(VALID_REF(*String)); + + /* count how many new line character are present */ + NewlineCount = 0; + Length = strlen(*String); + for (I = 0; I < Length; I++) + if ((*String)[I] == '\n') + NewlineCount++; + + if (NewlineCount != 0) + { + /* allocate a new string and convert */ + Replacement = ALLOC_ARRAY(Length + NewlineCount + 1, char, + "replacement string"); + if (Replacement != NULL) + { + size_t J; + for (I = J = 0; I < Length + 1; I++, J++) + { + if ((*String)[I] == '\n') + { + Replacement[J] = '\\'; + J++; + Replacement[J] = 'n'; + } + else + { + Replacement[J] = (*String)[I]; + } + } + + /* sanity check */ + CHECK(I == Length + 1); + CHECK(J == Length + NewlineCount + 1); + } + + /* release the old string and record the new one */ + FREE_ARRAY(*String, "original string"); + *String = Replacement; + } + + ENSURE(*String == NULL || VALID_REF(*String)); + return (*String != NULL); +} + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if defined TECPLOTKERNEL +#if !defined NO_ASSERTS +#endif /* !NO_ASSERTS */ +#endif /*TECPLOTKERNEL*/ +#endif diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/tassert.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/tassert.cpp new file mode 100644 index 0000000000000000000000000000000000000000..75b3586225ced6efc6213a1bc82de9fba0043e04 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/tassert.cpp @@ -0,0 +1,261 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +#include "stdafx.h" +#include "MASTER.h" +#define TECPLOTENGINEMODULE + +/* +***************************************************************** +***************************************************************** +******* ******** +****** Copyright (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +***************************************************************** +***************************************************************** +*/ + +#define TASSERTMODULE +#include "GLOBAL.h" +#include "TASSERT.h" +#include "Q_UNICODE.h" +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if defined (MSWIN) +#endif +#endif + +#include "STRUTIL.h" + +using namespace tecplot::strutil; +using namespace std; + +#define MAX_ERRMSG_LENGTH 2096 + +/* the mopup from assert and the writing out of crash.lay are */ +/* used by TUASSERT and thus are needed even if NO_ASSERTS */ +/* is set */ +#if !defined NO_TU_ASSERTS || !defined NO_ASSERTS + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if defined MSWIN /* ...Unix/Linux calls this via signal handlers */ +#endif +#endif /* TECPLOTKERNEL */ + +#endif /* Mopup function needed ... */ + + + +#if !defined STD_ASSERTS +/* + * Define the final assertion notification function. + */ +#if defined UNIXX && !defined NO_ASSERTS +/******************************************************************* + * * + * UNIX * + * * + *******************************************************************/ + + +# if defined NDEBUG +/* + * if NDEBUG is defined __assert is NOT defined so we must supply + * our own assertion notification function..... + */ +# define ASSERT assert +static void UnixAssert(const char *expression, + const char *file_name, + int line) +{ + fprintf(stderr, "Assertion: %s\n" + "Tecplot version: %s\n" + "File Name: %s\n" + "Line Number: %d\n", + expression, TecVersionId, file_name, line); + exit(ExitCode_AssertionFailure); +} +static TAssertFailureNotifyFunc assert_failure_notify = UnixAssert; +# else +/* + * NDEBUG is not defined so __assert is available.... + */ +# if defined LINUX +# define LOWLEVELASSERTFUNCTION __linuxassertproxy +/* + * In linux, __assert does not exist but rather + * __assert_fail which has a differnt API. Thus + * a proxy is provided + */ +static void __linuxassertproxy(const char *__assertion, + const char *__file, + int __line) +{ + __assert_fail(__assertion, __file, __line, __ASSERT_FUNCTION); +} +# elif defined DARWIN +# define LOWLEVELASSERTFUNCTION __darwinassertproxy +/* + * In Darwin (Mac OS X), __assert is #defined to a call to __eprintf, + * which also has a different API. Another proxy... + */ +static void __darwinassertproxy(const char *__assertion, + const char *__file, + int __line) +{ + __eprintf("Assertion: %s\n" + "Tecplot version: %s\n" + "File Name: %s\n" + "Line Number: %d\n", + __assertion, TecVersionId, __file, (unsigned)__line); +} +# else +# define LOWLEVELASSERTFUNCTION __assert +# endif + +static TAssertFailureNotifyFunc assert_failure_notify = (TAssertFailureNotifyFunc) LOWLEVELASSERTFUNCTION; + +# endif +#endif /* UNIXX */ + +#if defined UNIXX && !defined NO_ASSERTS +/* + * Replace the current assert failure notification function and + * return the current one. + * + * Assumptions: + * new function points to valid function (not null) that + * conforms to the specified prototype + * + * Guarantees: + * result is a pointer to the previously installed + * function (not null) + */ +TAssertFailureNotifyFunc InstallTAssertFailureNotify( + TAssertFailureNotifyFunc new_function) /* new notification function */ +{ + TAssertFailureNotifyFunc result = 0; /* old function address */ + + ASSERT(new_function != 0); + + result = assert_failure_notify; + assert_failure_notify = new_function; + + ASSERT(result != 0); + return result; +} + + + + + + +/* + * Perform the installed assert failure notification action. + */ +void TAssert(const char *expression, /* text representation of the assertion */ + const char *file_name, /* name of the file containing the assertion */ + int line) /* line number in the file of the assertion */ +{ + static Boolean_t InTAssert = FALSE; +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + char Message[MAX_ERRMSG_LENGTH+1]; + ASSERT(expression != 0 && strlen(expression) != 0); + ASSERT(file_name != 0 && strlen(file_name) != 0); + ASSERT(line >= 1); + + /* check for recursion */ + if (InTAssert) + { + fprintf(stderr, "Already in assert!\n"); + fprintf(stderr, "Assertion: %s\n" + "Tecplot version: %s\n" + "File Name: %s\n" + "Line Number: %d\n", + expression, TecVersionId, file_name, line); + PrintCurBacktrace(stderr, 100); + ASSERT(FALSE); /*... really exit */ + } + + InTAssert = TRUE; + + sprintf(Message, "Assertion: %s\n" + "Tecplot version: %s\n" + "File Name: %s\n" + "Line Number: %d\n", + expression, TecVersionId, file_name, line); + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +# if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +# else + fprintf(stderr, "%s", Message); +# endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + (*assert_failure_notify)(expression, file_name, line); +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif + + InTAssert = FALSE; /* just in case assert_failure_notify has an ignore */ +} +#endif /* defined UNIXX && !defined NO_ASSERTS */ +#endif /* STD_ASSERTS */ + + +#if defined MSWIN && defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#if defined CHECKED_BUILD +#endif +#if !defined ENGINE +# if defined CHECKED_BUILD +# endif // CHECKED_BUILD +#endif //!ENGINE +#endif /* MSWIN */ + + +#if defined NICE_NOT_IMPLEMENTED +static Boolean_t NotImplementedCalled = FALSE; +void NiceNotImplemented(void) +{ + if (!NotImplementedCalled) + { + Warning("Not Implemented!"); + NotImplementedCalled = TRUE; + } +} +#endif diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/tecxxx.cpp b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/tecxxx.cpp new file mode 100644 index 0000000000000000000000000000000000000000..dbace9f91fbff4104c08251de4f8659d521cd8d1 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/tecxxx.cpp @@ -0,0 +1,4812 @@ +/* + * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM + * + * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide. + * + * Tecplot hereby grants OpenCFD limited authority to distribute without + * alteration the source code to the Tecplot Input/Output library, known + * as TecIO, as part of its distribution of OpenFOAM and the + * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby + * granted access to the TecIO source code, and may redistribute it for the + * purpose of maintaining the converter. However, no authority is granted + * to alter the TecIO source code in any form or manner. + * + * This limited grant of distribution does not supersede Tecplot, Inc.'s + * copyright in TecIO. Contact Tecplot, Inc. for further information. + * + * Tecplot, Inc. + * 3535 Factoria Blvd, Ste. 550 + * Bellevue, WA 98006, USA + * Phone: +1 425 653 1200 + * http://www.tecplot.com/ + * + */ +#include "stdafx.h" +#include "MASTER.h" + +#define TECPLOTENGINEMODULE + +/* +****************************************************************** +****************************************************************** +******* ******** +****** (C) 1988-2008 Tecplot, Inc. ******* +******* ******** +****************************************************************** +****************************************************************** +*/ +/* Source file revision $Revision: 7627 $ */ + +#include "GLOBAL.h" +#include "TASSERT.h" +#include "Q_UNICODE.h" +#include "SYSTEM.h" +#include "FILESTREAM.h" +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif +#include "DATAIO4.h" +#include "DATASET0.h" +#include "TECXXX.h" +#include "DATAUTIL.h" +#include "ALLOC.h" +#include <vector> + +#if !defined MAKEARCHIVE +#include "AUXDATA.h" +#endif /* MAKEARCHIVE */ + +#if defined MSWIN +#include <io.h> +#endif + +#if defined UNIXX +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif +using namespace std; + +#if defined MAKEARCHIVE + #if defined MSWIN && defined _DEBUG +/* For debug .dll builds, send debug info to debug window. */ + #define PRINT0(s) do { OutputDebugString(s); } while (0) + #define PRINT1(s,a1) do { char buffer[512]; sprintf(buffer,s,a1); OutputDebugString(buffer); } while (0) + #define PRINT2(s,a1,a2) do { char buffer[512]; sprintf(buffer,s,a1,a2); OutputDebugString(buffer); } while (0) + #else +/* For all other builds (including release .dll), send debug info to stdout. */ + #define PRINT0(s) printf(s) + #define PRINT1(s,a1) printf(s,a1) + #define PRINT2(s,a1,a2) printf(s,a1,a2) +#endif +#else + #if defined MSWIN +/* For nonarchive, Windows, don't send debug info. */ + #define PRINT0(s) ((void)0) + #define PRINT1(s,a1) ((void)0) + #define PRINT2(s,a1,a2) ((void)0) + #else +/* For nonarchive, nonwindows, send debug info to stdout. */ + #define PRINT0(s) printf(s) + #define PRINT1(s,a1) printf(s,a1) + #define PRINT2(s,a1,a2) printf(s,a1,a2) + #endif +#endif + +typedef char *FNameType; +typedef FILE *FilePtr; + +#define MaxNumFiles 10 +#define MAX_DUPLIST_VARS 50 /* maybe crank up in the future */ + +#define BYTES_PER_CHUNK 4096 +#define TECIO_NO_NEIGHBORING_ELEM 0 +#define TECIO_NO_NEIGHBORING_ZONE 0 + +#if defined MAKEARCHIVE +static LgIndex_t DebugLevel[MaxNumFiles] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +#endif +static INTEGER4 IsOpen[MaxNumFiles] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +static INTEGER4 NumErrs[MaxNumFiles] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +static INTEGER4 NumVars[MaxNumFiles]; +static FNameType DestFName[MaxNumFiles] = {NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL + }; +static FNameType BlckFName[MaxNumFiles] = {NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL + }; +static FileStream_s* BlckFile[MaxNumFiles]; +static FileStream_s* HeadFile[MaxNumFiles]; +static vector<FileOffset_t> MinMaxOffset[MaxNumFiles]; /* vector dimensioned by num zones */ +static vector<double> VarMinValue[MaxNumFiles]; /* vector dimensioned by num vars */ +static vector<double> VarMaxValue[MaxNumFiles]; /* vector dimensioned by num vars */ +static INTEGER4 DoWriteForeign = FALSE; /* ...default is to write native */ +static INTEGER4 IsWritingNative[MaxNumFiles]; +static INTEGER4 IsBlock[MaxNumFiles]; +static INTEGER4 ZoneType[MaxNumFiles]; +static LgIndex_t IMax[MaxNumFiles]; /* ones based indices */ +static LgIndex_t JMax[MaxNumFiles]; /* ones based indices */ +static LgIndex_t KMax[MaxNumFiles]; /* ones based indices */ +static vector<LgIndex_t> TotalNumFaceNodes[MaxNumFiles]; /* vector dimensioned by num zones */ +static LgIndex_t TotalNumFaceBndryFaces[MaxNumFiles]; +static LgIndex_t TotalNumFaceBndryConns[MaxNumFiles]; +static LgIndex_t ICellMax[MaxNumFiles]; +static LgIndex_t JCellMax[MaxNumFiles]; +static LgIndex_t KCellMax[MaxNumFiles]; +static vector<INTEGER4> NumFaceConnections[MaxNumFiles]; /* vector dimensioned by num zones */ +static INTEGER4 FaceNeighborMode[MaxNumFiles]; +static vector<INTEGER4> FaceNeighborsOrMapWritten[MaxNumFiles]; /* vector dimensioned by num zones */ +static INTEGER4 NumIndices[MaxNumFiles]; +static LgIndex_t NumDataValuesWritten[MaxNumFiles]; +static LgIndex_t NumOrderedCCDataValuesWritten[MaxNumFiles]; /* CC data only */ +static LgIndex_t NumDataValuesToWrite[MaxNumFiles]; +static vector<LgIndex_t> NumRunningVarValues[MaxNumFiles]; /* vector dimensioned by num vars */ +static vector<Boolean_t> IsSharedVar[MaxNumFiles]; /* vector dimensioned by num vars */ +static vector<Boolean_t> IsPassiveVar[MaxNumFiles]; /* vector dimensioned by num vars */ +static INTEGER4 CurZone[MaxNumFiles]; /* zero based zone numbers */ +static INTEGER4 CurVar[MaxNumFiles]; /* zero based var numbers */ +static INTEGER4 FieldDataType; +static INTEGER4 CurFile = -1; +static vector<Boolean_t> IsCellCentered[MaxNumFiles]; /* vector dimensioned by num vars */ +static Boolean_t HasFECONNECT[MaxNumFiles]; +static INTEGER4 FileTypes[MaxNumFiles]; +static vector<INTEGER4> NumConnectivityNodes[MaxNumFiles]; /* vector dimensioned by num zones */ +static vector<Boolean_t> ConnectivityWritten[MaxNumFiles]; /* vector dimensioned by num zones */ + +/* + * From preplot.cpp: + * + * ZoneType 0=ORDERED,1=FELINESEG,2=FETRIANGLE, + * 3=FEQUADRILATERAL,4=FETETRAHEDRON,5=FEBRICK, + * 6=FEPOLYGON,7=FEPOLYHEDRON + */ +#define ORDERED 0 +#define FELINESEG 1 +#define FETRIANGLE 2 +#define FEQUADRILATERAL 3 +#define FETETRAHEDRON 4 +#define FEBRICK 5 +#define FEPOLYGON 6 +#define FEPOLYHEDRON 7 +/* + * FileType 0=FULLFILE,1=GRIDFILE,2=SOLUTIONFILE + */ +#define FULLFILE 0 +#define GRIDFILE 1 +#define SOLUTIONFILE 2 + +#if defined MAKEARCHIVE +static char const* ZoneTypes[] = +{ + "ORDERED", + "FELINESEG", + "FETRIANGLE", + "FEQUADRILATERAL", + "FETETRAHEDRON", + "FEBRICK", + "FEPOLYGON", + "FEPOLYHEDRON" +}; +#endif /* MAKEARCHIVE */ + + +static void WriteErr(const char *routine_name) +{ + #if defined MAKEARCHIVE + PRINT2("Err: (%s) Write failure on file %d.\n", routine_name, CurFile + 1); + #endif + NumErrs[CurFile]++; +} + +static LgIndex_t TecXXXZoneNum = 0; + +Boolean_t ParseDupList(LgIndex_t **ShareVarFromZone, + LgIndex_t *ShareConnectivityFromZone, + const char *DupList) +{ + Boolean_t IsOk = TRUE; + + REQUIRE(VALID_REF(ShareVarFromZone) && *ShareVarFromZone == NULL); + REQUIRE(VALID_REF(ShareConnectivityFromZone)); + REQUIRE(VALID_REF(DupList)); + + while (IsOk && *DupList) + { + /* skip leading spaces */ + while (*DupList && *DupList == ' ') + DupList++; + + /* is this the FECONNECT keyword? */ + if (*DupList && !strncmp(DupList, "FECONNECT", 9)) + *ShareConnectivityFromZone = TecXXXZoneNum; + + else if (*DupList && !isdigit(*DupList)) + IsOk = FALSE; /* syntax error */ + + else if (*DupList) + { + char *NotUsed = NULL; + EntIndex_t WhichVar = strtol(DupList, &NotUsed, 10); + EntIndex_t numVarsForFile = NumVars[CurFile]; + + if (0 < WhichVar && WhichVar < numVarsForFile) + { + if (!(*ShareVarFromZone)) + { + *ShareVarFromZone = ALLOC_ARRAY(numVarsForFile, LgIndex_t, "Variable sharing list"); + if (*ShareVarFromZone) + memset(*ShareVarFromZone, (char)0, numVarsForFile * sizeof(LgIndex_t)); + } + + if (*ShareVarFromZone) + (*ShareVarFromZone)[WhichVar - 1] = TecXXXZoneNum; + else + IsOk = FALSE; + } + else + { + /* Invalid var num */ + IsOk = FALSE; + } + } + + /* + * Skip to the comma. This + * will also allow the syntax error + * of more than one consecutive comma + */ + + while (*DupList && *DupList != ',') + DupList++; + + /* skip past the comma (can handle the syntax error of more than 1 comma) */ + while (*DupList && *DupList == ',') + DupList++; + } + + return IsOk; +} + +/** + */ +static FileStream_s *OpenFileStream(const char *FilePath, + const char *AccessMode, + Boolean_t IsByteOrderNative) +{ + REQUIRE(VALID_REF(FilePath)); + REQUIRE(VALID_REF(AccessMode)); + + FileStream_s *Result = NULL; + FILE *File = TP_FOPEN(FilePath, AccessMode); + if (File != NULL) + { + Result = FileStreamAlloc(File, IsByteOrderNative); + if (Result == NULL) + TP_FCLOSE(File); + } + + ENSURE((VALID_REF(Result) && VALID_REF(Result->File)) || Result == NULL); + return Result; +} + +/** + */ +static void CloseFileStream(FileStream_s **FileStream) +{ + REQUIRE(VALID_REF(FileStream)); + REQUIRE(VALID_REF(*FileStream) || *FileStream == NULL); + + if (*FileStream != NULL) + { + TP_FCLOSE((*FileStream)->File); + FileStreamDealloc(FileStream); + } + + ENSURE(*FileStream == NULL); +} + +/** + * Get the best terminator (separator) character to use for the string. First + * precedence goes to the new line then the command and finally by default the + * space. NOTE: We use a do loop to allow it to be used as a single statement. + */ +#define GET_BEST_TERMINATOR_CHAR(CompoundStr, TerminatorChar) \ + do \ + { \ + if (strchr((CompoundStr), '\n') != NULL) \ + (TerminatorChar) = '\n'; \ + else if (strchr((CompoundStr), ',') != NULL) \ + (TerminatorChar) = ','; \ + else \ + (TerminatorChar) = ' '; \ + } while (0) + + +/** + * TECINIXXX + */ +INTEGER4 LIBCALL TECINI112(char *Title, + char *Variables, + char *FName, + char *ScratchDir, + INTEGER4 *FileType, + INTEGER4 *Debug, + INTEGER4 *VIsDouble) +{ + size_t L; + int I; + char RName[80]; + char *CPtr; + int NewFile = -1; + + /* + * Note that users should not mix TECXXX, TEC100XXX, and TEC110XXX calls, but + * just in case, initialize the TecXXXZoneNum variable. It may not help, but + * it doesn't hurt... + */ + TecXXXZoneNum = 0; + + #if defined MAKEARCHIVE + InitInputSpecs(); + #endif + + for (I = 0; (I < MaxNumFiles) && (NewFile == -1); I++) + { + if (!IsOpen[I]) + NewFile = I; + } + + if (NewFile == -1) + { + #if defined MAKEARCHIVE + PRINT1("Err: (TECINI112) Too many files (%d) opened for printing.\n", NewFile); + #endif + return (-1); + } + + if (CurFile == -1) + CurFile = 0; + + #if defined MAKEARCHIVE + DebugLevel[NewFile] = *Debug; + #endif + /* check sizes for array sized by number of variables */ + CHECK(VarMinValue[NewFile].empty()); + CHECK(VarMaxValue[NewFile].empty()); + CHECK(NumRunningVarValues[NewFile].empty()); + CHECK(IsSharedVar[NewFile].empty()); + CHECK(IsPassiveVar[NewFile].empty()); + CHECK(IsCellCentered[NewFile].empty()); + + /* check sizes for array sized by number of zones */ + CHECK(MinMaxOffset[NewFile].empty()); + CHECK(TotalNumFaceNodes[NewFile].empty()); + CHECK(NumFaceConnections[NewFile].empty()); + CHECK(FaceNeighborsOrMapWritten[NewFile].empty()); + CHECK(NumConnectivityNodes[NewFile].empty()); + CHECK(ConnectivityWritten[NewFile].empty()); + + CurZone[NewFile] = -1; + L = 0; + if (FName != NULL) + L = strlen(FName); + if (L == 0) + { + #if defined MAKEARCHIVE + PRINT1("Err: (TECINI112) Bad file name for file %d.\n", NewFile); + #endif + return (-1); + } + DestFName[NewFile] = ALLOC_ARRAY(L + 1, char, "data set fname"); + strcpy(DestFName[NewFile], FName); + + #if defined (DOS) + { + sprintf(RName, "BLCKFILE.%03d", (int)(NewFile + 1)); + } + #else + { + sprintf(RName, "tp%1dXXXXXX", NewFile + 1); + } + #endif + + L = strlen(RName); + if (ScratchDir != NULL) + L += strlen(ScratchDir) + 1; /* +1 for the slash delimeter */ + BlckFName[NewFile] = ALLOC_ARRAY(L + 1, char, "data set fname"); + if (ScratchDir != NULL) + { + strcpy(BlckFName[NewFile], ScratchDir); + #if defined DOS || defined MSWIN + { + strcat(BlckFName[NewFile], "\\"); + } + #else + { + strcat(BlckFName[NewFile], "/"); + } + #endif + } + else + BlckFName[NewFile][0] = '\0'; + + strcat(BlckFName[NewFile], RName); + CHECK(strlen(BlckFName[NewFile]) <= L); + + #if defined MSWIN + { + _mktemp(BlckFName[NewFile]); + } + #elif defined UNIXX + { + /* + * POSIX compiant behavior is to make + * sure umask is set correctly first. + */ + mode_t OrigUmask = umask(0022); /* ...should produce rw------- */ + int FileDesc = mkstemp(BlckFName[NewFile]); + if (FileDesc != -1) + close(FileDesc); + umask(OrigUmask); + } + #endif + + #if defined MAKEARCHIVE + if (DebugLevel[NewFile]) + { + PRINT2("Scratch File #%d: %s\n", NewFile + 1, BlckFName[NewFile]); + PRINT2("Dest File #%d: %s\n", NewFile + 1, DestFName[NewFile]); + } + #endif + + IsWritingNative[NewFile] = !DoWriteForeign; + + #if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ + #endif + + HeadFile[NewFile] = OpenFileStream(DestFName[NewFile], "wb", IsWritingNative[NewFile]); + BlckFile[NewFile] = OpenFileStream(BlckFName[NewFile], "wb", IsWritingNative[NewFile]); + + if (BlckFile[NewFile] == NULL) + { + #if defined MAKEARCHIVE + PRINT0("Err: (TECINI112) Cannot open scratch file for output.\n"); + PRINT0(" Check permissions in scratch directory.\n"); + #endif + NumErrs[NewFile]++; + return (-1); + } + if (HeadFile[NewFile] == NULL) + { + #if defined MAKEARCHIVE + PRINT0("Err: (TECINI112) Cannot open plot file. Check permissions.\n"); + #endif + NumErrs[NewFile]++; + return (-1); + } + + writeBinaryVersionNumber(*HeadFile[NewFile], + TecplotBinaryFileVersion); + WriteBinaryMagic(HeadFile[NewFile]); + + /* Write file type */ + if (*FileType >= FULLFILE && *FileType <= SOLUTIONFILE) + FileTypes[NewFile] = *FileType; + else + { + #if defined MAKEARCHIVE + PRINT0("Err: (TECINI112) Bad filetype argument. Check documentation.\n"); + #endif + NumErrs[NewFile]++; + return (-1); + } + + CHECK(TecplotBinaryFileVersion == 112); + if (!WriteBinaryInt32(HeadFile[NewFile], (LgIndex_t)FileTypes[NewFile])) + { + WriteErr("TECINI112"); + return (-1); + } + + if (!DumpDatafileString(HeadFile[NewFile], + Title, + TRUE)) + { + WriteErr("TECINI112"); + return (-1); + } + + NumVars[NewFile] = 0; + CPtr = Variables; + + + /* + * Three possible variable name separators are accepted with the following + * precidence: newline, comma, and space. + */ + { + char terminator; + + GET_BEST_TERMINATOR_CHAR(CPtr, terminator); + while (*CPtr) + { + /* strip leading spaces */ + while (*CPtr && *CPtr == ' ') + CPtr++; + + if (*CPtr) + { + NumVars[NewFile]++; + /* skip to terminating character */ + while (*CPtr && *CPtr != terminator) + CPtr++; + /* skip past terminating character */ + if (*CPtr) + CPtr++; + } + } + } + +#if 0 + /* A grid file can have no variables in it as long as there is a connectivity list */ + if (NumVars[NewFile] == 0 && FileTypes[NewFile] != GRIDFILE) + { + #if defined MAKEARCHIVE + PRINT0("Err: (TECINI110) No variable names were defined.\n"); + #endif + NumErrs[NewFile]++; + return (-1); + } +#endif + + #if defined MAKEARCHIVE + if (DebugLevel[NewFile]) + PRINT1("NumVars=%d\n", NumVars[NewFile]); + #endif + /* make sure var-sized arrays are big enough for all vars */ + try + { + VarMinValue[NewFile].resize(NumVars[NewFile]); + VarMaxValue[NewFile].resize(NumVars[NewFile]); + NumRunningVarValues[NewFile].resize(NumVars[NewFile]); + IsSharedVar[NewFile].resize(NumVars[NewFile]); + IsPassiveVar[NewFile].resize(NumVars[NewFile]); + IsCellCentered[NewFile].resize(NumVars[NewFile]); + } + catch (std::bad_alloc const&) + { + #if defined MAKEARCHIVE + PRINT0("Err: (TECINI112) Memory allocation error.\n"); + #endif + NumErrs[NewFile]++; + return (-1); + } + + if (!WriteBinaryInt32(HeadFile[NewFile], (LgIndex_t)NumVars[NewFile])) + { + WriteErr("TECINI110"); + return (-1); + } + + CPtr = Variables; + { + char terminator; + char TString[MaxChrsVarName+1]; + int I; + + GET_BEST_TERMINATOR_CHAR(CPtr, terminator); + while (*CPtr) + { + /* skip leading space characters */ + while (*CPtr && *CPtr == ' ') + CPtr++; + if (*CPtr) + { + I = 0; + /* skip to terminator */ + while (*CPtr && *CPtr != terminator) + { + TString[I++] = *CPtr++; + } + /* skip past terminator */ + if (*CPtr) + CPtr++; + + /* strip trailing spaces */ + I--; + while (I >= 0 && TString[I] == ' ') + I--; + + TString[I+1] = '\0'; + + if (!DumpDatafileString(HeadFile[NewFile], TString, TRUE)) + { + WriteErr("TECINI110"); + return (-1); + } + } + } + } + + IsOpen[NewFile] = 1; + + if (*VIsDouble) + FieldDataType = FieldDataType_Double; + else + FieldDataType = FieldDataType_Float; + + return (0); +} + +INTEGER4 LIBCALL TECINI111(char *Title, + char *Variables, + char *FName, + char *ScratchDir, + INTEGER4 *FileType, + INTEGER4 *Debug, + INTEGER4 *VIsDouble) +{ + return TECINI112(Title, + Variables, + FName, + ScratchDir, + FileType, + Debug, + VIsDouble); +} + +INTEGER4 LIBCALL TECINI110(char *Title, + char *Variables, + char *FName, + char *ScratchDir, + INTEGER4 *Debug, + INTEGER4 *VIsDouble) +{ + INTEGER4 FType = FULLFILE; + + TecXXXZoneNum = 0; + return TECINI112(Title, + Variables, + FName, + ScratchDir, + &FType, + Debug, + VIsDouble); +} + +INTEGER4 LIBCALL TECINI100(char *Title, + char *Variables, + char *FName, + char *ScratchDir, + INTEGER4 *Debug, + INTEGER4 *VIsDouble) +{ + INTEGER4 FType = FULLFILE; + + TecXXXZoneNum = 0; + return TECINI112(Title, + Variables, + FName, + ScratchDir, + &FType, + Debug, + VIsDouble); +} + +INTEGER4 LIBCALL TECINI(char *Title, + char *Variables, + char *FName, + char *ScratchDir, + INTEGER4 *Debug, + INTEGER4 *VIsDouble) +{ + INTEGER4 FType = FULLFILE; + + TecXXXZoneNum = 0; + return TECINI112(Title, + Variables, + FName, + ScratchDir, + &FType, + Debug, + VIsDouble); +} + +#if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */ +LIBFUNCTION INTEGER4 LIBCALL tecini112_(char *Title, + char *Variables, + char *FName, + char *ScratchDir, + INTEGER4 *FileType, + INTEGER4 *Debug, + INTEGER4 *VIsDouble) +{ + return TECINI112(Title, Variables, FName, ScratchDir, FileType, Debug, VIsDouble); +} + +LIBFUNCTION INTEGER4 LIBCALL tecini111_(char *Title, + char *Variables, + char *FName, + char *ScratchDir, + INTEGER4 *FileType, + INTEGER4 *Debug, + INTEGER4 *VIsDouble) +{ + return TECINI112(Title, Variables, FName, ScratchDir, FileType, Debug, VIsDouble); +} + +LIBFUNCTION INTEGER4 LIBCALL tecini110_(char *Title, + char *Variables, + char *FName, + char *ScratchDir, + INTEGER4 *Debug, + INTEGER4 *VIsDouble) +{ + INTEGER4 FType = FULLFILE; + return TECINI112(Title, Variables, FName, ScratchDir, &FType, Debug, VIsDouble); +} + +LIBFUNCTION INTEGER4 LIBCALL tecini100_(char *Title, + char *Variables, + char *FName, + char *ScratchDir, + INTEGER4 *Debug, + INTEGER4 *VIsDouble) +{ + INTEGER4 FType = FULLFILE; + return TECINI112(Title, Variables, FName, ScratchDir, &FType, Debug, VIsDouble); +} + +LIBFUNCTION INTEGER4 LIBCALL tecini_(char *Title, + char *Variables, + char *FName, + char *ScratchDir, + INTEGER4 *Debug, + INTEGER4 *VIsDouble) +{ + INTEGER4 FType = FULLFILE; + return TECINI112(Title, + Variables, + FName, + ScratchDir, + &FType, + Debug, + VIsDouble); +} +#endif + + +static int CheckData(const char *routine_name) +{ + + if (NumDataValuesToWrite[CurFile] != NumDataValuesWritten[CurFile]) + { + #if defined MAKEARCHIVE + PRINT2("Err: (%s) Wrong number of data values in file %d:\n", routine_name, CurFile + 1); + PRINT2(" %d data values for Zone %d were processed,\n", NumDataValuesWritten[CurFile], CurZone[CurFile] + 1); + PRINT1(" %d data values were expected.\n", NumDataValuesToWrite[CurFile]); + #endif + NumErrs[CurFile]++; + return (-1); + } + return (0); +} + +static int CheckFile(const char *routine_name) +{ + if ((CurFile == -1) || (!IsOpen[CurFile])) + { + #if defined MAKEARCHIVE + PRINT2("Err: (%s) Attempt to use invalid file (%d).\n", + routine_name, CurFile + 1); + #endif + return (-1); + } + return (0); +} + +/** + * Advances CurVar[CurFile] to the next non-shared active variable. TECDATXXX + * clients should not supply values for shared or passive variables. + */ +static void AdvanceToNextVarWithValues(void) +{ + /* search for the next variable with values */ + do + { + CurVar[CurFile]++; + } + while (CurVar[CurFile] < NumVars[CurFile] && + (IsSharedVar[CurFile][CurVar[CurFile]] || + IsPassiveVar[CurFile][CurVar[CurFile]])); +} + +/** + * TECZNEXXX + */ +INTEGER4 LIBCALL TECZNE112(char *ZnTitle, + INTEGER4 *ZnType, + INTEGER4 *IMxOrNumPts, + INTEGER4 *JMxOrNumElements, + INTEGER4 *KMxOrNumFaces, + INTEGER4 *ICellMx, + INTEGER4 *JCellMx, + INTEGER4 *KCellMx, + double *SolutionTime, + INTEGER4 *StrandID, + INTEGER4 *ParentZone, + INTEGER4 *IsBlk, + INTEGER4 *NumFaceConn, + INTEGER4 *FNMode, + INTEGER4 *NumFaceNodes, + INTEGER4 *NumFaceBndryFaces, + INTEGER4 *NumFaceBndryConns, + INTEGER4 *PassiveVarList, + INTEGER4 *ValueLocation, + INTEGER4 *ShareVarFromZone, + INTEGER4 *ShareConnectivityFromZone) +{ + int I; + int IsOk = 1; + + if (CheckFile("TECZNE112") < 0) + return (-1); + + if (CurZone[CurFile] > -1) + { + if (CheckData("TECZNE112") < 0) + return (-1); + } + + if (NumVars[CurFile] == 0) + { + WriteErr("TECZNE112"); + #if defined MAKEARCHIVE + PRINT1("Err: (TECZNE112) Cannot write out zones if numvars is equal to zero (file %d).\n", + CurFile + 1); + #endif + return (-1); + } + + if (CurZone[CurFile] > MaxNumZonesOrVars - 2) /* -1 based */ + { + WriteErr("TECZNE112"); + #if defined MAKEARCHIVE + PRINT2("Err: (TECZNE112) Exceeded max number of zones (%d) in file %d.\n", + MaxNumZonesOrVars, CurFile + 1); + #endif + return (-1); + } + + if (*StrandID < -1) + { + #if defined MAKEARCHIVE + PRINT2("Err: (TECZNE112) Invalid StrandID supplied for file %d, zone %d.\n", + CurFile + 1, CurZone[CurFile] + 1 + 1); + #endif + return (-1); + } + + if (*ParentZone < 0) + { + #if defined MAKEARCHIVE + PRINT2("Err: (TECZNE112) Invalid ParentZone supplied for file %d, zone %d.\n", + CurFile + 1, CurZone[CurFile] + 1 + 1); + #endif + return (-1); + } + + /* + * This is a temporary error. Point format should no longer be written to the file + * and should instead be converted to block format before being written. Since the + * conversion has not yet been implemented, it is an error to use point data. + * TODO (JN): Remove this error when point to block conversion has been implemented. + */ + if (*IsBlk != 1) + { + #if defined MAKEARCHIVE + PRINT2("Err: (TECZNE112) Point data is not currently allowed. " + " Please use block format for file %d, zone %d.\n", + CurFile + 1, CurZone[CurFile] + 1 + 1); + #endif + return (-1); + } + + NumDataValuesWritten[CurFile] = 0; + NumOrderedCCDataValuesWritten[CurFile] = 0; + CurZone[CurFile]++; + + /* Resize zone-dimensioned arrays (CurZone[] is 0-based) */ + try + { + MinMaxOffset[CurFile].resize(CurZone[CurFile] + 1); + TotalNumFaceNodes[CurFile].resize(CurZone[CurFile] + 1); + NumFaceConnections[CurFile].resize(CurZone[CurFile] + 1); + FaceNeighborsOrMapWritten[CurFile].resize(CurZone[CurFile] + 1); + NumConnectivityNodes[CurFile].resize(CurZone[CurFile] + 1); + ConnectivityWritten[CurFile].resize(CurZone[CurFile] + 1); + } + catch (std::bad_alloc const&) + { + #if defined MAKEARCHIVE + PRINT0("Err: (TECZNE112) Memory allocation error.\n"); + #endif + NumErrs[CurFile]++; + return (-1); + } + + ZoneType[CurFile] = *ZnType; + IMax[CurFile] = *IMxOrNumPts; + JMax[CurFile] = *JMxOrNumElements; + KMax[CurFile] = *KMxOrNumFaces; + ICellMax[CurFile] = *ICellMx; + JCellMax[CurFile] = *JCellMx; + KCellMax[CurFile] = *KCellMx; + /* Set the flags that connectivity, face neighbors or face map hasn't been written for the zone yet. */ + FaceNeighborsOrMapWritten[CurFile][CurZone[CurFile]] = FALSE; + ConnectivityWritten[CurFile][CurZone[CurFile]] = FALSE; + + if (ZoneType[CurFile] == ZoneType_FEPolygon || + ZoneType[CurFile] == ZoneType_FEPolyhedron) + { + NumFaceConnections[CurFile][CurZone[CurFile]] = 0; /* ...not used for polytope data */ + FaceNeighborMode[CurFile] = 0; /* ...not used for polytope data */ + NumConnectivityNodes[CurFile][CurZone[CurFile]] = 0; /* ...not used for polytope data */ + + IsBlock[CurFile] = TRUE; /* ...polytope data is always block */ + TotalNumFaceNodes[CurFile][CurZone[CurFile]] = *NumFaceNodes; + TotalNumFaceBndryFaces[CurFile] = *NumFaceBndryFaces; + TotalNumFaceBndryConns[CurFile] = *NumFaceBndryConns; + } + else /* ...classic data */ + { + IsBlock[CurFile] = *IsBlk; + NumFaceConnections[CurFile][CurZone[CurFile]] = *NumFaceConn; + FaceNeighborMode[CurFile] = *FNMode; + + TotalNumFaceNodes[CurFile][CurZone[CurFile]] = 0; /* ...not used for classic data */ + TotalNumFaceBndryFaces[CurFile] = 0; /* ...not used for classic data */ + TotalNumFaceBndryConns[CurFile] = 0; /* ...not used for classic data */ + } + + WriteBinaryReal(HeadFile[CurFile], + (double)ZoneMarker, + FieldDataType_Float); + if (!DumpDatafileString(HeadFile[CurFile], + ZnTitle, + TRUE)) + { + WriteErr("TECZNE112"); + return (-1); + } + + if ((ShareVarFromZone && *ShareConnectivityFromZone) && + CurZone[CurFile] == 0) + { + /* can't have a duplist if there's nothing to duplicate */ + IsOk = 0; + } + + if (IsOk == 0) + { + #if defined MAKEARCHIVE + PRINT1("Err: (TECZNE112) Bad zone format for file %d.\n", CurFile + 1); + #endif + NumErrs[CurFile]++; + return (-1); + } + + switch (ZoneType[CurFile]) + { + case ORDERED: + NumIndices[CurFile] = 0; + break; + case FELINESEG: + NumIndices[CurFile] = 2; + break; + case FETRIANGLE: + NumIndices[CurFile] = 3; + break; + case FEQUADRILATERAL: + NumIndices[CurFile] = 4; + break; + case FETETRAHEDRON: + NumIndices[CurFile] = 4; + break; + case FEBRICK: + NumIndices[CurFile] = 8; + break; + } + + /* ...not used for poly or ordered data and don't count sharing or solution files. */ + if (ZoneType[CurFile] != ZoneType_FEPolygon && + ZoneType[CurFile] != ZoneType_FEPolyhedron && + *ShareConnectivityFromZone == 0 && + FileTypes[CurFile] != SOLUTIONFILE) + NumConnectivityNodes[CurFile][CurZone[CurFile]] = NumIndices[CurFile] * JMax[CurFile]; + + /* + * We do not check any return values until the end. If these calls fail, + * WriteFieldDataType below should fail as well. + */ + WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)(*ParentZone) - 1); /* ...ParentZone is zero based for binary file */ + WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)(*StrandID) - 1); /* ...StrandID is zero based for binary file */ + WriteBinaryReal(HeadFile[CurFile], *SolutionTime, FieldDataType_Double); + WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t) - 1); /* No Zone Color Assignment */ + WriteBinaryInt32(HeadFile[CurFile], ZoneType[CurFile]); + + NumDataValuesToWrite[CurFile] = 0; + for (I = 0; I < NumVars[CurFile]; I++) + { + IsSharedVar[CurFile][I] = (ShareVarFromZone != NULL && ShareVarFromZone[I] != 0); /* ...shared? */ + IsPassiveVar[CurFile][I] = (PassiveVarList != NULL && PassiveVarList[I] == 1); /* ...passive? */ + } + + WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)(ValueLocation != NULL ? 1 : 0)); /* ...are var locations specified? */ + if (ValueLocation) + { + for (I = 0; I < NumVars[CurFile]; I++) + { + int VIndex; + LgIndex_t NumNodes; + LgIndex_t NumCells; + + if (ZoneType[CurFile] == ORDERED) + { + NumNodes = IMax[CurFile] * JMax[CurFile] * KMax[CurFile]; + NumCells = (MAX(IMax[CurFile] - 1, 1) * + MAX(JMax[CurFile] - 1, 1) * + MAX(KMax[CurFile] - 1, 1)); + } + else + { + NumNodes = IMax[CurFile]; + NumCells = JMax[CurFile]; + } + + if (IsSharedVar[CurFile][I]) + VIndex = ShareVarFromZone[I] - 1; + else + VIndex = I; + + if (VIndex == 0) + NumRunningVarValues[CurFile][I] = 0; + else + NumRunningVarValues[CurFile][VIndex] = NumRunningVarValues[CurFile][VIndex-1]; + + IsCellCentered[CurFile][VIndex] = (ValueLocation[I] == ValueLocation_CellCentered); + if (ValueLocation[I] == ValueLocation_CellCentered) + { + WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)1); + if (!IsSharedVar[CurFile][I] && !IsPassiveVar[CurFile][I]) + { + NumDataValuesToWrite[CurFile] += NumCells; + NumRunningVarValues[CurFile][VIndex] += NumCells; + } + } + else if (ValueLocation[I] == ValueLocation_Nodal) + { + WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)0); + if (!IsSharedVar[CurFile][I] && !IsPassiveVar[CurFile][I]) + { + NumDataValuesToWrite[CurFile] += NumNodes; + NumRunningVarValues[CurFile][VIndex] += NumNodes; + } + } + else + { + #if defined MAKEARCHIVE + PRINT2("Err: (TECZNE112) Bad zone value location for file %d, variable %d.\n", CurFile + 1, I + 1); + #endif + NumErrs[CurFile]++; + return(-1); + } + } + } + else + { + LgIndex_t NumNodes; + if (ZoneType[CurFile] == ORDERED) + { + NumNodes = IMax[CurFile] * JMax[CurFile] * KMax[CurFile]; + } + else + { + NumNodes = IMax[CurFile]; + } + + for (I = 0; I < NumVars[CurFile]; I++) + { + int VIndex; + if (IsSharedVar[CurFile][I]) + VIndex = ShareVarFromZone[I] - 1; + else + VIndex = I; + + if (VIndex == 0) + NumRunningVarValues[CurFile][I] = 0; + else + NumRunningVarValues[CurFile][VIndex] = NumRunningVarValues[CurFile][VIndex-1]; + + IsCellCentered[CurFile][VIndex] = FALSE; + if (!IsSharedVar[CurFile][I] && !IsPassiveVar[CurFile][I]) + { + NumDataValuesToWrite[CurFile] += NumNodes; + NumRunningVarValues[CurFile][VIndex] += NumNodes; + } + } + } + + /* + * As of binary version 108 Tecplot introduced + * the ability to output its auto-generated face + * neighbor array in its raw form. For now + * TecIO will always decline to perform this + * step and instead fall back to the delivering + * one neighbor at a time. + */ + WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)0); /* IsRawFNAvailable */ + + WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)NumFaceConnections[CurFile][CurZone[CurFile]]); + if (NumFaceConnections[CurFile][CurZone[CurFile]] > 0) + { + WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)FaceNeighborMode[CurFile]); + if (ZoneType[CurFile] != ORDERED) + WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)0); /* FEFaceNeighborsComplete */ + } + + WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)IMax[CurFile]); + if (ZoneType[CurFile] == FEPOLYGON || + ZoneType[CurFile] == FEPOLYHEDRON) + { + WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)KMax[CurFile]); + + /* + * As of binary version 111 these items moved from the data section to + * the header. + */ + WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)TotalNumFaceNodes[CurFile][CurZone[CurFile]]); + if (TotalNumFaceBndryFaces[CurFile] > 0) + { + /* Each boundary face must have >= 1 boundary connection. */ + if (TotalNumFaceBndryConns[CurFile] < TotalNumFaceBndryFaces[CurFile]) + { + #if defined MAKEARCHIVE + PRINT1("Err: (TECZNE112) There must be at least 1 boundary connection for each boundary face in zone %d.\n", + CurZone[CurFile] + 1); + PRINT2(" %d boundary faces and %d boundary connections were specified.\n", + TotalNumFaceBndryFaces[CurFile], TotalNumFaceBndryConns[CurFile]); + #endif + NumErrs[CurFile]++; + return(-1); + } + + /* + * As a convenience for the ASCII format, TecUtil, and TECIO layers if any + * boundary connections exists we automatically add a no-neighboring + * connection as the first item so that they can user 0 for no-neighboring + * element in the element list regardless if they have boundary connections + * or not. + */ + WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)TotalNumFaceBndryFaces[CurFile] + 1); /* ...add a boundary face for no neighboring element as a convenience */ + } + else + WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)TotalNumFaceBndryFaces[CurFile]); + WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)TotalNumFaceBndryConns[CurFile]); + } + WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)JMax[CurFile]); + + if (ZoneType[CurFile] == ORDERED) + { + WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)KMax[CurFile]); + } + else + { + WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)ICellMax[CurFile]); + WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)JCellMax[CurFile]); + WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)KCellMax[CurFile]); + } + + /* + * Aux data. This has to be over-written by the aux data writing routine. + * Because it currently at the end of the header section we don't need to + * keep track of the position for seeking back to it. + */ + WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)0); + + WriteBinaryReal(BlckFile[CurFile], + (double)ZoneMarker, + FieldDataType_Float); + + for (I = 0; I < NumVars[CurFile]; I++) + { + if (!WriteFieldDataType(BlckFile[CurFile], + (FieldDataType_e)FieldDataType, + TRUE)) + { + WriteErr("TECZNE112"); + return (-1); + } + } + + /* Passive variable identification */ + if (PassiveVarList) + { + WriteBinaryInt32(BlckFile[CurFile], 1); + for (I = 0; I < NumVars[CurFile]; I++) + WriteBinaryInt32(BlckFile[CurFile], PassiveVarList[I]); + } + else + WriteBinaryInt32(BlckFile[CurFile], 0); + + /* get the CurVar[CurFile] on the first active variable */ + CurVar[CurFile] = -1; + AdvanceToNextVarWithValues(); + + /* Variable & Connectivity Sharing */ + if (ShareVarFromZone) + { + WriteBinaryInt32(BlckFile[CurFile], 1); + for (I = 0; I < NumVars[CurFile]; I++) + WriteBinaryInt32(BlckFile[CurFile], ShareVarFromZone[I] - 1); + } + else + WriteBinaryInt32(BlckFile[CurFile], 0); + WriteBinaryInt32(BlckFile[CurFile], *ShareConnectivityFromZone - 1); + + /* + * Create place holders or the variable min/max value. We will come back + * later after writing the data portion with the real min/max values. In the + * mean time, keep track of the starting point so we can seek back to this + * place. + */ + MinMaxOffset[CurFile][CurZone[CurFile]] = (FileOffset_t)TP_FTELL(BlckFile[CurFile]->File); + + for (I = 0; I < NumVars[CurFile]; I++) + { + /* initialize to unset values */ + VarMinValue[CurFile][I] = LARGEDOUBLE; + VarMaxValue[CurFile][I] = -LARGEDOUBLE; + + if (!IsSharedVar[CurFile][I] && !IsPassiveVar[CurFile][I]) + { + WriteBinaryReal(BlckFile[CurFile], 0.0, FieldDataType_Double); + WriteBinaryReal(BlckFile[CurFile], 0.0, FieldDataType_Double); + } + } + + #if defined MAKEARCHIVE + if (DebugLevel[CurFile]) + { + PRINT1("Writing Zone %d:\n", CurZone[CurFile] + 1); + PRINT1(" Title = %s\n", ZnTitle); + PRINT1(" Type = %s\n", ZoneTypes[ZoneType[CurFile]]); + PRINT1(" IMax = %d\n", IMax[CurFile]); + PRINT1(" JMax = %d\n", JMax[CurFile]); + PRINT1(" KMax = %d\n", KMax[CurFile]); + if (ShareVarFromZone) + { + char DupList[1024] = ""; + + for (I = 0; I < NumVars[CurFile]; I++) + { + if (I > 0) + strcat(DupList, ","); + sprintf(&DupList[strlen(DupList)], "%d", ShareVarFromZone[I]); + } + PRINT1(" DupList = %s\n", DupList); + } + } + #endif + + return (0); +} + +INTEGER4 LIBCALL TECZNE111(char *ZnTitle, + INTEGER4 *ZnType, + INTEGER4 *IMxOrNumPts, + INTEGER4 *JMxOrNumElements, + INTEGER4 *KMxOrNumFaces, + INTEGER4 *ICellMx, + INTEGER4 *JCellMx, + INTEGER4 *KCellMx, + double *SolutionTime, + INTEGER4 *StrandID, + INTEGER4 *ParentZone, + INTEGER4 *IsBlk, + INTEGER4 *NumFaceConn, + INTEGER4 *FNMode, + INTEGER4 *NumFaceNodes, + INTEGER4 *NumFaceBndryFaces, + INTEGER4 *NumFaceBndryConns, + INTEGER4 *PassiveVarList, + INTEGER4 *ValueLocation, + INTEGER4 *ShareVarFromZone, + INTEGER4 *ShareConnectivityFromZone) +{ + return TECZNE112(ZnTitle, + ZnType, + IMxOrNumPts, + JMxOrNumElements, + KMxOrNumFaces, + ICellMx, + JCellMx, + KCellMx, + SolutionTime, + StrandID, + ParentZone, + IsBlk, + NumFaceConn, + FNMode, + NumFaceNodes, + NumFaceBndryFaces, + NumFaceBndryConns, + PassiveVarList, + ValueLocation, + ShareVarFromZone, + ShareConnectivityFromZone); +} + +INTEGER4 LIBCALL TECZNE110(char *ZnTitle, + INTEGER4 *ZnType, + INTEGER4 *IMxOrNumPts, + INTEGER4 *JMxOrNumElements, + INTEGER4 *KMx, + INTEGER4 *ICellMx, + INTEGER4 *JCellMx, + INTEGER4 *KCellMx, + double *SolutionTime, + INTEGER4 *StrandID, + INTEGER4 *ParentZone, + INTEGER4 *IsBlk, + INTEGER4 *NumFaceConn, + INTEGER4 *FNMode, + INTEGER4 *PassiveVarList, + INTEGER4 *ValueLocation, + INTEGER4 *ShareVarFromZone, + INTEGER4 *ShareConnectivityFromZone) +{ + INTEGER4 NumFaceNodes = 0; + INTEGER4 NumFaceBndryFaces = 0; + INTEGER4 NumFaceBndryConns = 0; + + return TECZNE112(ZnTitle, + ZnType, + IMxOrNumPts, + JMxOrNumElements, + KMx, + ICellMx, + JCellMx, + KCellMx, + SolutionTime, + StrandID, + ParentZone, + IsBlk, + NumFaceConn, + FNMode, + &NumFaceNodes, + &NumFaceBndryFaces, + &NumFaceBndryConns, + PassiveVarList, + ValueLocation, + ShareVarFromZone, + ShareConnectivityFromZone); +} + +INTEGER4 LIBCALL TECZNE100(char *ZnTitle, + INTEGER4 *ZnType, + INTEGER4 *IMxOrNumPts, + INTEGER4 *JMxOrNumElements, + INTEGER4 *KMx, + INTEGER4 *ICellMx, + INTEGER4 *JCellMx, + INTEGER4 *KCellMx, + INTEGER4 *IsBlk, + INTEGER4 *NumFaceConn, + INTEGER4 *FNMode, + INTEGER4 *ValueLocation, + INTEGER4 *ShareVarFromZone, + INTEGER4 *ShareConnectivityFromZone) +{ + double SolutionTime = 0.0; + INTEGER4 StrandID = STRAND_ID_STATIC + 1; /* TECXXX is ones based for StrandID */ + INTEGER4 ParentZone = BAD_SET_VALUE + 1; /* TECXXX is ones based for ParentZone */ + INTEGER4 NumFaceNodes = 0; + INTEGER4 NumFaceBndryFaces = 0; + INTEGER4 NumFaceBndryConns = 0; + + return TECZNE112(ZnTitle, + ZnType, + IMxOrNumPts, + JMxOrNumElements, + KMx, + ICellMx, + JCellMx, + KCellMx, + &SolutionTime, + &StrandID, + &ParentZone, + IsBlk, + NumFaceConn, + FNMode, + &NumFaceNodes, + &NumFaceBndryFaces, + &NumFaceBndryConns, + NULL, /* PassiveVarList */ + ValueLocation, + ShareVarFromZone, + ShareConnectivityFromZone); +} + +#if !defined INDEX_16_BIT // not supported in this test-only mode +INTEGER4 LIBCALL TECZNE(char *ZoneTitle, + INTEGER4 *IMx, + INTEGER4 *JMx, + INTEGER4 *KMx, + char *ZFormat, + char *DupList) +{ + + LgIndex_t ZoneType; + LgIndex_t IsBlock; + LgIndex_t *ShareVarFromZone = NULL; + LgIndex_t ShareConnectivityFromZone; + LgIndex_t Result = 0; + + + if (ZFormat == NULL) + Result = -1; + else if (!strcmp(ZFormat, "BLOCK")) + { + IsBlock = 1; + ZoneType = ZoneType_Ordered; + } + else if (!strcmp(ZFormat, "FEBLOCK")) + { + IsBlock = 1; + switch (*KMx) + { + /* + * From preplot.c: + * + * ZoneType 0=ORDERED,1=FELINESEG,2=FETRIANGLE, + * 3=FEQUADRILATERAL,4=FETETRAHEDRON,5=FEBRICK + */ + case 0: /* Triangular. */ + ZoneType = 2; + break; + case 1: /* Quadrilateral */ + ZoneType = 3; + break; + case 2: /* Tetrahedral */ + ZoneType = 4; + break; + case 3: /* Brick. */ + ZoneType = 5; + break; + } + } + else if (!strcmp(ZFormat, "POINT")) + { + IsBlock = 0; + ZoneType = ZoneType_Ordered; + } + else if (!strcmp(ZFormat, "FEPOINT")) + { + IsBlock = 0; + switch (*KMx) + { + case 0: /* Triangular. */ + ZoneType = 2; + break; + case 1: /* Quadrilateral */ + ZoneType = 3; + break; + case 2: /* Tetrahedral */ + ZoneType = 4; + break; + case 3: /* Brick. */ + ZoneType = 5; + break; + } + } + else + Result = -1; + + ShareConnectivityFromZone = 0; + + + if (Result == 0 && + DupList && + !ParseDupList(&ShareVarFromZone, &ShareConnectivityFromZone, DupList)) + { + Result = -1; + } + + /*Result = TECZNE((char *)ZoneTitle, IMx, JMx, KMx, (char *)ZFormat,(char*)DupList);*/ + if (Result == 0) + { + INTEGER4 ICellMx = 0; + INTEGER4 JCellMx = 0; + INTEGER4 KCellMx = 0; + INTEGER4 NumFaceConnections = 0; + INTEGER4 FaceNeighborMode = FaceNeighborMode_LocalOneToOne; + double SolutionTime = 0.0; + INTEGER4 StrandID = STRAND_ID_STATIC + 1; /* TECXXX is ones based for StrandID */ + INTEGER4 ParentZone = BAD_SET_VALUE + 1; /* TECXXX is ones based for ParentZone */ + INTEGER4 NumFaceNodes = 0; + INTEGER4 NumFaceBndryFaces = 0; + INTEGER4 NumFaceBndryConns = 0; + + Result = TECZNE112((char *)ZoneTitle, + &ZoneType, + IMx, + JMx, + KMx, + &ICellMx, + &JCellMx, + &KCellMx, + &SolutionTime, + &StrandID, + &ParentZone, + &IsBlock, + &NumFaceConnections, + &FaceNeighborMode, + &NumFaceNodes, + &NumFaceBndryFaces, + &NumFaceBndryConns, + NULL, /* PassiveVarList */ + NULL, /* ValueLocation */ + DupList ? ShareVarFromZone : NULL, + &ShareConnectivityFromZone); + TecXXXZoneNum++; + } + + if (ShareVarFromZone) + FREE_ARRAY(ShareVarFromZone, "Variable sharing list"); + + return (INTEGER4) Result; +} +#endif // INDEX_16_BIT -- not supported in this test-only mode + +#if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */ +LIBFUNCTION INTEGER4 LIBCALL teczne112_(char *ZoneTitle, + INTEGER4 *ZnType, + INTEGER4 *IMxOrNumPts, + INTEGER4 *JMxOrNumElements, + INTEGER4 *KMx, + INTEGER4 *ICellMx, + INTEGER4 *JCellMx, + INTEGER4 *KCellMx, + double *SolutionTime, + INTEGER4 *StrandID, + INTEGER4 *ParentZone, + INTEGER4 *IsBlk, + INTEGER4 *NumFaceConn, + INTEGER4 *FNMode, + INTEGER4 *NumFaceNodes, + INTEGER4 *NumFaceBndryFaces, + INTEGER4 *NumFaceBndryConns, + INTEGER4 *PassiveVarList, + INTEGER4 *ValueLocation, + INTEGER4 *ShareVarFromZone, + INTEGER4 *ShareConnectivityFromZone) +{ + return TECZNE112(ZoneTitle, + ZnType, + IMxOrNumPts, + JMxOrNumElements, + KMx, + ICellMx, + JCellMx, + KCellMx, + SolutionTime, + StrandID, + ParentZone, + IsBlk, + NumFaceConn, + FNMode, + NumFaceNodes, + NumFaceBndryFaces, + NumFaceBndryConns, + PassiveVarList, + ValueLocation, + ShareVarFromZone, + ShareConnectivityFromZone); +} + +LIBFUNCTION INTEGER4 LIBCALL teczne111_(char *ZoneTitle, + INTEGER4 *ZnType, + INTEGER4 *IMxOrNumPts, + INTEGER4 *JMxOrNumElements, + INTEGER4 *KMx, + INTEGER4 *ICellMx, + INTEGER4 *JCellMx, + INTEGER4 *KCellMx, + double *SolutionTime, + INTEGER4 *StrandID, + INTEGER4 *ParentZone, + INTEGER4 *IsBlk, + INTEGER4 *NumFaceConn, + INTEGER4 *FNMode, + INTEGER4 *NumFaceNodes, + INTEGER4 *NumFaceBndryFaces, + INTEGER4 *NumFaceBndryConns, + INTEGER4 *PassiveVarList, + INTEGER4 *ValueLocation, + INTEGER4 *ShareVarFromZone, + INTEGER4 *ShareConnectivityFromZone) +{ + return TECZNE112(ZoneTitle, + ZnType, + IMxOrNumPts, + JMxOrNumElements, + KMx, + ICellMx, + JCellMx, + KCellMx, + SolutionTime, + StrandID, + ParentZone, + IsBlk, + NumFaceConn, + FNMode, + NumFaceNodes, + NumFaceBndryFaces, + NumFaceBndryConns, + PassiveVarList, + ValueLocation, + ShareVarFromZone, + ShareConnectivityFromZone); +} + +LIBFUNCTION INTEGER4 LIBCALL teczne110_(char *ZoneTitle, + INTEGER4 *ZnType, + INTEGER4 *IMxOrNumPts, + INTEGER4 *JMxOrNumElements, + INTEGER4 *KMx, + INTEGER4 *ICellMx, + INTEGER4 *JCellMx, + INTEGER4 *KCellMx, + double *SolutionTime, + INTEGER4 *StrandID, + INTEGER4 *ParentZone, + INTEGER4 *IsBlk, + INTEGER4 *NumFaceConn, + INTEGER4 *FNMode, + INTEGER4 *PassiveVarList, + INTEGER4 *ValueLocation, + INTEGER4 *ShareVarFromZone, + INTEGER4 *ShareConnectivityFromZone) +{ + INTEGER4 NumFaceNodes = 0; + INTEGER4 NumFaceBndryFaces = 0; + INTEGER4 NumFaceBndryConns = 0; + + return TECZNE112(ZoneTitle, + ZnType, + IMxOrNumPts, + JMxOrNumElements, + KMx, + ICellMx, + JCellMx, + KCellMx, + SolutionTime, + StrandID, + ParentZone, + IsBlk, + NumFaceConn, + FNMode, + &NumFaceNodes, + &NumFaceBndryFaces, + &NumFaceBndryConns, + PassiveVarList, + ValueLocation, + ShareVarFromZone, + ShareConnectivityFromZone); +} + +LIBFUNCTION INTEGER4 LIBCALL teczne100_(char *ZoneTitle, + INTEGER4 *ZnType, + INTEGER4 *IMxOrNumPts, + INTEGER4 *JMxOrNumElements, + INTEGER4 *KMx, + INTEGER4 *ICellMx, + INTEGER4 *JCellMx, + INTEGER4 *KCellMx, + INTEGER4 *IsBlk, + INTEGER4 *NumFaceConn, + INTEGER4 *FNMode, + INTEGER4 *ValueLocation, + INTEGER4 *ShareVarFromZone, + INTEGER4 *ShareConnectivityFromZone) +{ + return TECZNE100(ZoneTitle, + ZnType, + IMxOrNumPts, + JMxOrNumElements, + KMx, + ICellMx, + JCellMx, + KCellMx, + IsBlk, + NumFaceConn, + FNMode, + ValueLocation, + ShareVarFromZone, + ShareConnectivityFromZone); +} + +LIBFUNCTION INTEGER4 LIBCALL teczne_(char *ZoneTitle, + INTEGER4 *IMx, + INTEGER4 *JMx, + INTEGER4 *KMx, + char *ZFormat, + char *DupList) +{ + return TECZNE(ZoneTitle, + IMx, + JMx, + KMx, + ZFormat, + DupList); +} +#endif + +/** + * Rewrite the var min/max place holders which currently have zero in them. + */ +static void RewritePendingMinMaxValues(void) +{ + FileOffset_t CurrentOffset = (FileOffset_t)TP_FTELL(BlckFile[CurFile]->File); + + TP_FSEEK(BlckFile[CurFile]->File, MinMaxOffset[CurFile][CurZone[CurFile]], SEEK_SET); + int I; + for (I = 0; I < NumVars[CurFile]; I++) + { + if (!IsSharedVar[CurFile][I] && !IsPassiveVar[CurFile][I]) + { + WriteBinaryReal(BlckFile[CurFile], VarMinValue[CurFile][I], FieldDataType_Double); + WriteBinaryReal(BlckFile[CurFile], VarMaxValue[CurFile][I], FieldDataType_Double); + } + } + + /* return the original position */ + TP_FSEEK(BlckFile[CurFile]->File, CurrentOffset, SEEK_SET); +} + +/** + * TECDATXXX + */ +INTEGER4 LIBCALL TECDAT112(INTEGER4 *N, + void *Data, + INTEGER4 *IsDouble) +{ + LgIndex_t I; + double *dptr = (double *)Data; + float *fptr = (float *)Data; + + if (CheckFile("TECDAT112") < 0) + return (-1); + + #if defined MAKEARCHIVE + if (DebugLevel[CurFile] && (*N > 1)) + PRINT2("Writing %d values to file %d.\n", *N, CurFile + 1); + #endif + + for (I = 0; I < *N; I++) + { + double Value = (*IsDouble == 1 ? dptr[I] : fptr[I]); + + /* keep track of var min/max */ + if (Value < VarMinValue[CurFile][CurVar[CurFile]]) + VarMinValue[CurFile][CurVar[CurFile]] = Value; + if (Value > VarMaxValue[CurFile][CurVar[CurFile]]) + VarMaxValue[CurFile][CurVar[CurFile]] = Value; + + if (!WriteBinaryReal(BlckFile[CurFile], Value, (FieldDataType_e)FieldDataType)) + { + WriteErr("TECDAT112"); + return (-1); + } + + /* + * As of version 103 Tecplot writes binary data files so that the ordered + * cell centered field data includes the ghost cells. This makes it much + * easier for Tecplot to map the data when reading by simply writing out + * field data's as a block. As of version 104 the ghost cells of the + * slowest moving index are not included. + */ + if (IsCellCentered[CurFile][CurVar[CurFile]] && ZoneType[CurFile] == ORDERED) + { + CHECK(IsBlock[CurFile]); /* ...ordered CC data must be block format */ + LgIndex_t PIndex = (NumOrderedCCDataValuesWritten[CurFile]); + LgIndex_t FinalIMax = MAX(IMax[CurFile] - 1, 1); + LgIndex_t FinalJMax = MAX(JMax[CurFile] - 1, 1); + LgIndex_t FinalKMax = MAX(KMax[CurFile] - 1, 1); + LgIndex_t IIndex = (PIndex % IMax[CurFile]); + LgIndex_t JIndex = ((PIndex % (IMax[CurFile] * JMax[CurFile])) / IMax[CurFile]); + LgIndex_t KIndex = (PIndex / (IMax[CurFile] * JMax[CurFile])); + LgIndex_t IMaxAdjust = 0; + LgIndex_t JMaxAdjust = 0; + LgIndex_t KMaxAdjust = 0; + if (KMax[CurFile] > 1) + KMaxAdjust = 1; /* ...K is slowest */ + else if (JMax[CurFile] > 1) + JMaxAdjust = 1; /* ...J is slowest */ + else if (IMax[CurFile] > 1) + IMaxAdjust = 1; /* ...I is slowest */ + + if (IIndex + 1 == FinalIMax && FinalIMax < IMax[CurFile] - IMaxAdjust) + { + NumOrderedCCDataValuesWritten[CurFile]++; + if (!WriteBinaryReal(BlckFile[CurFile], 0.0, (FieldDataType_e)FieldDataType)) + { + WriteErr("TECDAT112"); + return (-1); + } + } + if (IIndex + 1 == FinalIMax && + (JIndex + 1 == FinalJMax && FinalJMax < JMax[CurFile] - JMaxAdjust)) + { + LgIndex_t II; + for (II = 1; II <= IMax[CurFile] - IMaxAdjust; II++) + { + NumOrderedCCDataValuesWritten[CurFile]++; + if (!WriteBinaryReal(BlckFile[CurFile], 0.0, (FieldDataType_e)FieldDataType)) + { + WriteErr("TECDAT112"); + return (-1); + } + } + } + if (IIndex + 1 == FinalIMax && + JIndex + 1 == FinalJMax && + (KIndex + 1 == FinalKMax && FinalKMax < KMax[CurFile] - KMaxAdjust)) + { + LgIndex_t JJ, II; + for (JJ = 1; JJ <= JMax[CurFile] - JMaxAdjust; JJ++) + for (II = 1; II <= IMax[CurFile] - IMaxAdjust; II++) + { + NumOrderedCCDataValuesWritten[CurFile]++; + if (!WriteBinaryReal(BlckFile[CurFile], 0.0, (FieldDataType_e)FieldDataType)) + { + WriteErr("TECDAT112"); + return (-1); + } + } + } + + /* increment for the original cell value */ + NumOrderedCCDataValuesWritten[CurFile]++; + } + + /* update the number of data points written */ + NumDataValuesWritten[CurFile]++; + + if (IsBlock[CurFile]) + { + /* for block format update the variable when all values have been given */ + if (NumRunningVarValues[CurFile][CurVar[CurFile]] == NumDataValuesWritten[CurFile]) + { + AdvanceToNextVarWithValues(); /* ...move on to the next variable */ + if (CurVar[CurFile] < NumVars[CurFile] && + IsCellCentered[CurFile][CurVar[CurFile]] && + ZoneType[CurFile] == ORDERED) + NumOrderedCCDataValuesWritten[CurFile] = 0; /* reset for next CC variable */ + } + } + else + { + /* for point format update the variable after each value */ + AdvanceToNextVarWithValues(); + if (CurVar[CurFile] >= NumVars[CurFile]) + { + /* reset to the first active variable */ + CurVar[CurFile] = -1; + AdvanceToNextVarWithValues(); + } + } + + #if defined MAKEARCHIVE + if (DebugLevel[CurFile] > 1) + PRINT2("%d %G\n", NumDataValuesWritten[CurFile] + I + 1, Value); + #endif + } + + /* + * If this is the last call to TECDAT112, + * then we may have to set the 'repeat adjacency list' + * flag in the file. + */ + if (HasFECONNECT[CurFile] && + + /* (essentialy this is CheckData() but we don't want to print + an error message) */ + (NumDataValuesToWrite[CurFile] == NumDataValuesWritten[CurFile])) + { + if (!WriteBinaryInt32(BlckFile[CurFile], (LgIndex_t)1)) + { + WriteErr("TECDAT112"); + return (-1); + } + } + + /* re-write min/max values when all data has been delivered */ + if (NumDataValuesToWrite[CurFile] == NumDataValuesWritten[CurFile]) + RewritePendingMinMaxValues(); + + return (0); +} + +INTEGER4 LIBCALL TECDAT111(INTEGER4 *N, + void *Data, + INTEGER4 *IsDouble) +{ + return TECDAT112(N, + Data, + IsDouble); +} + +INTEGER4 LIBCALL TECDAT110(INTEGER4 *N, + void *FieldData, + INTEGER4 *IsDouble) +{ + return TECDAT112(N, + FieldData, + IsDouble); +} + +INTEGER4 LIBCALL TECDAT100(INTEGER4 *N, + void *FieldData, + INTEGER4 *IsDouble) +{ + return TECDAT112(N, + FieldData, + IsDouble); +} + +INTEGER4 LIBCALL TECDAT(INTEGER4 *N, + void *FieldData, + INTEGER4 *IsDouble) +{ + return TECDAT112(N, + FieldData, + IsDouble); +} + +#if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */ +LIBFUNCTION INTEGER4 LIBCALL tecdat112_(INTEGER4 *N, + void *Data, + INTEGER4 *IsDouble) +{ + return TECDAT112(N, Data, IsDouble); +} + +LIBFUNCTION INTEGER4 LIBCALL tecdat111_(INTEGER4 *N, + void *Data, + INTEGER4 *IsDouble) +{ + return TECDAT112(N, Data, IsDouble); +} + +LIBFUNCTION INTEGER4 LIBCALL tecdat110_(INTEGER4 *N, + void *Data, + INTEGER4 *IsDouble) +{ + return TECDAT112(N, Data, IsDouble); +} + +LIBFUNCTION INTEGER4 LIBCALL tecdat100_(INTEGER4 *N, + void *Data, + INTEGER4 *IsDouble) +{ + return TECDAT112(N, Data, IsDouble); +} + +LIBFUNCTION INTEGER4 LIBCALL tecdat_(INTEGER4 *N, + void *FieldData, + INTEGER4 *IsDouble) +{ + return TECDAT112(N, + FieldData, + IsDouble); +} +#endif + +/** + * TECNODXXX + */ +INTEGER4 LIBCALL TECNOD112(INTEGER4 *NData) +{ + LgIndex_t L = NumConnectivityNodes[CurFile][CurZone[CurFile]]; + LgIndex_t I; + + ConnectivityWritten[CurFile][CurZone[CurFile]] = TRUE; + + if (CheckFile("TECNOD112") < 0) + return (-1); + + if (ZoneType[CurFile] == FEPOLYGON || + ZoneType[CurFile] == FEPOLYHEDRON) + { + /* Wrong way to specify connectivity for polygons and polyhedrons */ + #if defined MAKEARCHIVE + PRINT0("Err: (TECNOD112) Cannot call TECNOD112 for polygonal or polyhedral zones.\n"); + #endif + NumErrs[CurFile]++; + return (-1); + } + + if (HasFECONNECT[CurFile]) + { + /* + * The connectivity list is duplicated, + * so we shouldn't be calling TECNOD112() + */ + return (-1); + } + + if (FileTypes[CurFile] == SOLUTIONFILE) + { + #if defined MAKEARCHIVE + PRINT0("Err: (TECNOD112) Cannot call TECNOD112 if file type is SOLUTIONFILE.\n"); + #endif + NumErrs[CurFile]++; + return (-1); + } + + if (ZoneType[CurFile] == ORDERED) + { + #if defined MAKEARCHIVE + PRINT0("Err: (TECNOD112) Cannot call TECNOD110 if zone type is ORDERED.\n"); + #endif + NumErrs[CurFile]++; + return (-1); + } + + if (CheckData("TECNOD112") < 0) + return (-1); + + for (I = 0; I < L; I++) + { + if ((NData[I] > IMax[CurFile]) || + (NData[I] < 1)) + { + #if defined MAKEARCHIVE + PRINT1("Err: (TECNOD112) Invalid node map value at position %d:\n", I); + PRINT2(" node map value = %d, max value = %d.\n", NData[I], IMax[CurFile]); + #endif + NumErrs[CurFile]++; + return (-1); + } + /* + * As of version 103 Tecplot assumes that node maps are zero based + * instead of ones based. Since we have to maintain the contract we + * subtract 1 for the caller. + */ + if (!WriteBinaryInt32(BlckFile[CurFile], NData[I] - 1)) /* zero based */ + { + WriteErr("TECNOD112"); + return (-1); + } + } + return (0); +} + +INTEGER4 LIBCALL TECNOD111(INTEGER4 *NData) +{ + return TECNOD112(NData); +} + +INTEGER4 LIBCALL TECNOD110(INTEGER4 *NData) +{ + return TECNOD112(NData); +} + +INTEGER4 LIBCALL TECNOD100(INTEGER4 *NData) +{ + return TECNOD112(NData); +} + +INTEGER4 LIBCALL TECNOD(INTEGER4 *NData) +{ + return TECNOD112(NData); +} + +#if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */ +LIBFUNCTION INTEGER4 LIBCALL tecnod112_(INTEGER4 *NData) +{ + return TECNOD112(NData); +} + +LIBFUNCTION INTEGER4 LIBCALL tecnod111_(INTEGER4 *NData) +{ + return TECNOD112(NData); +} + +LIBFUNCTION INTEGER4 LIBCALL tecnod110_(INTEGER4 *NData) +{ + return TECNOD112(NData); +} + +LIBFUNCTION INTEGER4 LIBCALL tecnod100_(INTEGER4 *NData) +{ + return TECNOD112(NData); +} + +LIBFUNCTION INTEGER4 LIBCALL tecnod_(INTEGER4 *NData) +{ + return TECNOD112(NData); +} +#endif + +/** + * TECENDXXX + */ +INTEGER4 LIBCALL TECEND112(void) +{ + int RetVal = 0; + + /** + * Validate that all zone data was given for the file since there are no + * more chances to give it. Note that solution files don't define the + * connectivity again. + */ + if (FileTypes[CurFile] != SOLUTIONFILE) + { + for (int ZoneIndex = 0; (RetVal == 0) && (ZoneIndex <= CurZone[CurFile]); ZoneIndex++) + { + if (((NumConnectivityNodes[CurFile][ZoneIndex] > 0) && + (ConnectivityWritten[CurFile][ZoneIndex] == FALSE))) + { + #if defined MAKEARCHIVE + PRINT1("Err: (TECEND112) File %d is being closed without writing connectivity data.\n", CurFile + 1); + PRINT1(" Zone %d was defined with a Classic FE zone type but TECNOD112() was not called.\n", ZoneIndex + 1); + #endif + NumErrs[CurFile]++; + RetVal = -1; + } + if (((NumFaceConnections[CurFile][ZoneIndex] > 0) && + (FaceNeighborsOrMapWritten[CurFile][ZoneIndex] == FALSE))) + { + #if defined MAKEARCHIVE + PRINT1("Err: (TECEND112) File %d is being closed without writing face neighbor data.\n", CurFile + 1); + PRINT2(" %d connections were specified for zone %d but TECFACE112() was not called.\n", + NumFaceConnections[CurFile][ZoneIndex], ZoneIndex + 1); + #endif + NumErrs[CurFile]++; + RetVal = -1; + } + else if (((TotalNumFaceNodes[CurFile][ZoneIndex] > 0) && + (FaceNeighborsOrMapWritten[CurFile][ZoneIndex] == FALSE))) + { + #if defined MAKEARCHIVE + PRINT1("Err: (TECEND112) File %d is being closed without writing face map data.\n", CurFile + 1); + PRINT2(" %d face nodes were specified for zone %d but TECPOLY112() was not called.\n", + TotalNumFaceNodes[CurFile][ZoneIndex], ZoneIndex + 1); + #endif + NumErrs[CurFile]++; + RetVal = -1; + } + } + } + + if (RetVal == 0) + { + if (CheckFile("TECEND112") < 0) + RetVal = -1; + } + + if (RetVal == 0) + { + if (CheckData("TECEND112") < 0) + RetVal = -1; + } + + if (RetVal == 0) + if (!WriteBinaryReal(HeadFile[CurFile], EndHeaderMarker, FieldDataType_Float)) + { + WriteErr("TECEND112"); + RetVal = -1; + } + + CloseFileStream(&BlckFile[CurFile]); + + if (RetVal == 0) + { + BlckFile[CurFile] = OpenFileStream(BlckFName[CurFile], "rb", IsWritingNative[CurFile]); + + /* Append data from BlckFile to HeadFile... */ + char buffer[BYTES_PER_CHUNK]; + size_t bytesRead = 0; + while ((RetVal == 0) && + (feof(BlckFile[CurFile]->File) == 0)) + { + bytesRead = fread((void*)buffer, 1, BYTES_PER_CHUNK, BlckFile[CurFile]->File); + if (ferror(BlckFile[CurFile]->File) == 0) + { + if (bytesRead != fwrite((void*)buffer, 1, bytesRead, HeadFile[CurFile]->File)) + { + /* do not call WriteErr, use custom message instead */ + #if defined MAKEARCHIVE + PRINT1("Err: (TECEND112) Write failure during repack on file %d.\n", CurFile + 1); + #endif + NumErrs[CurFile]++; + RetVal = -1; + } + } + else + { + /* do not call WriteErr, use custom message instead */ + #if defined MAKEARCHIVE + PRINT1("Err: (TECEND112) Write failure during repack on file %d.\n", CurFile + 1); + #endif + NumErrs[CurFile]++; + RetVal = -1; + } + } + CloseFileStream(&BlckFile[CurFile]); + } + + TP_UNLINK(BlckFName[CurFile]); + + CloseFileStream(&HeadFile[CurFile]); + + #if defined MAKEARCHIVE + if (DebugLevel[CurFile]) + { + PRINT1("File %d closed.\n", CurFile + 1); + if (NumErrs[CurFile]) + { + PRINT0("********************************************\n"); + PRINT1(" %d Errors occurred on this file\n", NumErrs[CurFile]); + PRINT0("********************************************\n"); + } + } + #endif + + NumErrs[CurFile] = 0; + IsOpen[CurFile] = 0; + if (DestFName[CurFile]) + FREE_ARRAY(DestFName[CurFile], "data set fname"); + if (BlckFName[CurFile]) + FREE_ARRAY(BlckFName[CurFile], "data set fname"); + BlckFName[CurFile] = NULL; + DestFName[CurFile] = NULL; + + /* reset arrays sized by number of variables */ + VarMinValue[CurFile].clear(); + VarMaxValue[CurFile].clear(); + NumRunningVarValues[CurFile].clear(); + IsSharedVar[CurFile].clear(); + IsPassiveVar[CurFile].clear(); + IsCellCentered[CurFile].clear(); + + /* reset arrays sized by number of zones */ + MinMaxOffset[CurFile].clear(); + TotalNumFaceNodes[CurFile].clear(); + NumFaceConnections[CurFile].clear(); + FaceNeighborsOrMapWritten[CurFile].clear(); + NumConnectivityNodes[CurFile].clear(); + ConnectivityWritten[CurFile].clear(); + + CurFile = 0; + while ((CurFile < MaxNumFiles) && !IsOpen[CurFile]) + CurFile++; + + if (CurFile == MaxNumFiles) + CurFile = -1; + + return RetVal; +} + +INTEGER4 LIBCALL TECEND111(void) +{ + return TECEND112(); +} + +INTEGER4 LIBCALL TECEND110(void) +{ + return TECEND112(); +} + +INTEGER4 LIBCALL TECEND100(void) +{ + return TECEND112(); +} + +INTEGER4 LIBCALL TECEND(void) +{ + return TECEND112(); +} + +#if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */ +LIBFUNCTION INTEGER4 LIBCALL tecend112_(void) +{ + return TECEND112(); +} + +LIBFUNCTION INTEGER4 LIBCALL tecend111_(void) +{ + return TECEND112(); +} + +LIBFUNCTION INTEGER4 LIBCALL tecend110_(void) +{ + return TECEND112(); +} + +LIBFUNCTION INTEGER4 LIBCALL tecend100_(void) +{ + return TECEND112(); +} + +LIBFUNCTION INTEGER4 LIBCALL tecend_(void) +{ + return TECEND112(); +} +#endif + + + + +static void GetNextLabel(const char **CPtr, + char *NextLabel) +{ + int N = 0; + char *NPtr = NextLabel; + *NPtr = '\0'; + /* Find label start */ + while ((**CPtr) && (**CPtr != '"')) + (*CPtr)++; + if (**CPtr) + (*CPtr)++; + while ((N < 60) && (**CPtr) && (**CPtr != '"')) + { + if (**CPtr == '\\') + { + (*CPtr)++; + } + *NPtr++ = **CPtr; + N++; + (*CPtr)++; + } + if (**CPtr) + (*CPtr)++; + *NPtr = '\0'; +} + + +/** + * TECLABXXX + */ +INTEGER4 LIBCALL TECLAB112(char *S) +{ + const char *CPtr = (const char *)S; + LgIndex_t N = 0; + char Label[60]; + + if (CheckFile("TECLAB112") < 0) + return (-1); + + #if defined MAKEARCHIVE + if (DebugLevel[CurFile]) + PRINT0("\nInserting Custom Labels:\n"); + #endif + + do + { + GetNextLabel(&CPtr, Label); + if (*Label) + N++; + } + while (*Label); + + if (N == 0) + { + #if defined MAKEARCHIVE + PRINT1("Err: (TECLAB112) Invalid custom label string: %s\n", + (S ? S : " ")); + #endif + NumErrs[CurFile]++; + return (-1); + } + + WriteBinaryReal(HeadFile[CurFile], CustomLabelMarker, FieldDataType_Float); + if (!WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)N)) + { + WriteErr("TECLAB112"); + return (-1); + } + + CPtr = (const char *)S; + do + { + GetNextLabel(&CPtr, Label); + if (*Label) + { + if (!DumpDatafileString(HeadFile[CurFile], Label, TRUE)) + { + WriteErr("TECLAB112"); + return (-1); + } + #if defined MAKEARCHIVE + if (DebugLevel[CurFile]) + printf(" %s\n", Label); + #endif + } + } + while (*Label); + + return (0); +} + +INTEGER4 LIBCALL TECLAB111(char *S) +{ + return TECLAB112(S); +} + +INTEGER4 LIBCALL TECLAB110(char *S) +{ + return TECLAB112(S); +} + +INTEGER4 LIBCALL TECLAB100(char *S) +{ + return TECLAB112(S); +} + +INTEGER4 LIBCALL TECLAB(char *S) +{ + return TECLAB112(S); +} + +#if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */ +LIBFUNCTION INTEGER4 LIBCALL teclab112_(char *S) +{ + return TECLAB112(S); +} + +LIBFUNCTION INTEGER4 LIBCALL teclab111_(char *S) +{ + return TECLAB112(S); +} + +LIBFUNCTION INTEGER4 LIBCALL teclab110_(char *S) +{ + return TECLAB112(S); +} + +LIBFUNCTION INTEGER4 LIBCALL teclab100_(char *S) +{ + return TECLAB112(S); +} + +LIBFUNCTION INTEGER4 LIBCALL teclab_(char *S) +{ + return TECLAB112(S); +} +#endif + + +/** + * TECUSRXXX + */ +INTEGER4 LIBCALL TECUSR112(char *S) +{ + if (CheckFile("TECUSR112") < 0) + return (-1); + + #if defined MAKEARCHIVE + if (DebugLevel[CurFile]) + PRINT1("\nInserting UserRec: %s\n", S); + #endif + + if ((S == NULL) || (*S == '\0')) + { + #if defined MAKEARCHIVE + PRINT0("Err: (TECUSR112) Invalid TECUSR110 string\n"); + #endif + NumErrs[CurFile]++; + return (-1); + } + + WriteBinaryReal(HeadFile[CurFile], UserRecMarker, FieldDataType_Float); + if (!DumpDatafileString(HeadFile[CurFile], S, TRUE)) + { + #if defined MAKEARCHIVE + if (DebugLevel[CurFile]) + printf("Err: (TECUSR112) Write failure for file %d\n", CurFile + 1); + #endif + NumErrs[CurFile]++; + return (-1); + } + return (0); +} + +INTEGER4 LIBCALL TECUSR111(char *S) +{ + return TECUSR112(S); +} + +INTEGER4 LIBCALL TECUSR110(char *S) +{ + return TECUSR112(S); +} + +INTEGER4 LIBCALL TECUSR100(char *S) +{ + return TECUSR112(S); +} + +INTEGER4 LIBCALL TECUSR(char *S) +{ + return TECUSR112(S); +} + +#if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */ +LIBFUNCTION INTEGER4 LIBCALL tecusr112_(char *S) +{ + return TECUSR112(S); +} + +LIBFUNCTION INTEGER4 LIBCALL tecusr111_(char *S) +{ + return TECUSR112(S); +} + +LIBFUNCTION INTEGER4 LIBCALL tecusr110_(char *S) +{ + return TECUSR112(S); +} + +LIBFUNCTION INTEGER4 LIBCALL tecusr100_(char *S) +{ + return TECUSR112(S); +} + +LIBFUNCTION INTEGER4 LIBCALL tecusr_(char *S) +{ + return TECUSR112(S); +} +#endif + +#if 0 // NOT_CURRENTLY_USED +static int WriteGeomDataBlock(float *Data, + LgIndex_t NumPts) +{ + LgIndex_t I; + + for (I = 0; I < NumPts; I++) + { + if (!WriteBinaryReal(HeadFile[CurFile], Data[I], FieldDataType_Float)) + { + return (-1); + } + } + return (0); +} + + +static void ShowDebugColor(LgIndex_t Color) +{ + #if defined MAKEARCHIVE + switch (Color) + { + case 0 : PRINT0("BLACK\n"); break; + case 1 : PRINT0("RED\n"); break; + case 2 : PRINT0("GREEN\n"); break; + case 3 : PRINT0("BLUE\n"); break; + case 4 : PRINT0("CYAN\n"); break; + case 5 : PRINT0("YELLOW\n"); break; + case 6 : PRINT0("PURPLE\n"); break; + case 7 : PRINT0("WHITE\n"); break; + case 8 : + case 9 : + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: PRINT1("CUSTOM%1d\n", Color-7); break; + default : PRINT0("INVALID\n"); + } + #endif +} +#endif /* NOT_CURRENTLY_USED */ + + +/** + * TECGEOXXX + */ +INTEGER4 LIBCALL TECGEO112(double *XOrThetaPos, + double *YOrRPos, + double *ZPos, + INTEGER4 *PosCoordMode, /* 0=Grid, 1=Frame, 3=Grid3D */ + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *Color, + INTEGER4 *FillColor, + INTEGER4 *IsFilled, + INTEGER4 *GeomType, + INTEGER4 *LinePattern, + double *PatternLength, + double *LineThickness, + INTEGER4 *NumEllipsePts, + INTEGER4 *ArrowheadStyle, + INTEGER4 *ArrowheadAttachment, + double *ArrowheadSize, + double *ArrowheadAngle, + INTEGER4 *Scope, + INTEGER4 *Clipping, + INTEGER4 *NumSegments, + INTEGER4 *NumSegPts, + float *XOrThetaGeomData, + float *YOrRGeomData, + float *ZGeomData, + char *mfc) +{ + int I, RetVal; + int RawDataSize = 0; + double Fract; + + Geom_s Geom; + + if (CheckFile("TECGEO112") < 0) + return (-1); + + Geom.PositionCoordSys = (CoordSys_e) * PosCoordMode; + if (Geom.PositionCoordSys == CoordSys_Frame) + Fract = 0.01; + else + Fract = 1.0; + + Geom.AnchorPos.Generic.V1 = (*XOrThetaPos) * Fract; + Geom.AnchorPos.Generic.V2 = (*YOrRPos) * Fract; + Geom.AnchorPos.Generic.V3 = (*ZPos) * Fract; + Geom.AttachToZone = *AttachToZone != 0; + Geom.Zone = *Zone - 1; + Geom.BColor = (ColorIndex_t) * Color; + Geom.FillBColor = (ColorIndex_t) * FillColor; + Geom.IsFilled = *IsFilled; + Geom.GeomType = (GeomType_e) * GeomType; + Geom.LinePattern = (LinePattern_e) * LinePattern; + Geom.PatternLength = *PatternLength / 100.0; + Geom.LineThickness = *LineThickness / 100.0; + Geom.NumEllipsePts = *NumEllipsePts; + Geom.ArrowheadStyle = (ArrowheadStyle_e) * ArrowheadStyle; + Geom.ArrowheadAttachment = (ArrowheadAttachment_e) * ArrowheadAttachment; + Geom.ArrowheadSize = *ArrowheadSize / 100.0; + Geom.ArrowheadAngle = *ArrowheadAngle / DEGPERRADIANS; + Geom.Scope = (Scope_e) * Scope; + Geom.DrawOrder = DrawOrder_AfterData; + Geom.Clipping = (Clipping_e) * Clipping; + Geom.NumSegments = *NumSegments; + Geom.MacroFunctionCommand = mfc; + Geom.ImageFileName = NULL; + Geom.ImageNumber = 0; + Geom.MaintainAspectRatio = TRUE; + Geom.PixelAspectRatio = 1.0; + Geom.ImageResizeFilter = ImageResizeFilter_Texture; + + if (Geom.GeomType == GeomType_LineSegs3D) + { + Geom.GeomType = GeomType_LineSegs; + Geom.PositionCoordSys = CoordSys_Grid3D; + } + + #if defined MAKEARCHIVE + if (DebugLevel[CurFile]) + PRINT0("\nInserting Geometry\n"); + #endif + + switch (Geom.GeomType) + { + case GeomType_LineSegs : + { + int I; + RawDataSize = 0; + for (I = 0; I < *NumSegments; I++) + { + Geom.NumSegPts[I] = NumSegPts[I]; + RawDataSize += NumSegPts[I]; + } + } break; + case GeomType_Rectangle : + case GeomType_Square : + case GeomType_Circle : + case GeomType_Ellipse : + { + RawDataSize = 1; + } break; + case GeomType_Image : + { + CHECK(FALSE); /* Images not allowed in data files. */ + } break; + default : + { + CHECK(FALSE); + } break; + } + + Geom.DataType = FieldDataType_Float; + Geom.GeomData.Generic.V1Base = AllocScratchNodalFieldDataPtr(RawDataSize, FieldDataType_Float, TRUE); + Geom.GeomData.Generic.V2Base = AllocScratchNodalFieldDataPtr(RawDataSize, FieldDataType_Float, TRUE); + Geom.GeomData.Generic.V3Base = AllocScratchNodalFieldDataPtr(RawDataSize, FieldDataType_Float, TRUE); + + for (I = 0; I < RawDataSize; I++) + { + SetFieldValue(Geom.GeomData.Generic.V1Base, I, (double)XOrThetaGeomData[I]*Fract); + SetFieldValue(Geom.GeomData.Generic.V2Base, I, (double)YOrRGeomData[I]*Fract); + SetFieldValue(Geom.GeomData.Generic.V3Base, I, (double)ZGeomData[I]*Fract); + } + + if (DumpGeometry(HeadFile[CurFile], &Geom, TRUE, FALSE)) + RetVal = 0; + else + RetVal = -1; + + DeallocScratchNodalFieldDataPtr(&Geom.GeomData.Generic.V1Base); + DeallocScratchNodalFieldDataPtr(&Geom.GeomData.Generic.V2Base); + DeallocScratchNodalFieldDataPtr(&Geom.GeomData.Generic.V3Base); + + return RetVal; +} + +INTEGER4 LIBCALL TECGEO111(double *XOrThetaPos, + double *YOrRPos, + double *ZPos, + INTEGER4 *PosCoordMode, /* 0=Grid, 1=Frame, 3=Grid3D */ + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *Color, + INTEGER4 *FillColor, + INTEGER4 *IsFilled, + INTEGER4 *GeomType, + INTEGER4 *LinePattern, + double *PatternLength, + double *LineThickness, + INTEGER4 *NumEllipsePts, + INTEGER4 *ArrowheadStyle, + INTEGER4 *ArrowheadAttachment, + double *ArrowheadSize, + double *ArrowheadAngle, + INTEGER4 *Scope, + INTEGER4 *Clipping, + INTEGER4 *NumSegments, + INTEGER4 *NumSegPts, + float *XOrThetaGeomData, + float *YOrRGeomData, + float *ZGeomData, + char *mfc) +{ + return TECGEO112(XOrThetaPos, + YOrRPos, + ZPos, + PosCoordMode, + AttachToZone, + Zone, + Color, + FillColor, + IsFilled, + GeomType, + LinePattern, + PatternLength, + LineThickness, + NumEllipsePts, + ArrowheadStyle, + ArrowheadAttachment, + ArrowheadSize, + ArrowheadAngle, + Scope, + Clipping, + NumSegments, + NumSegPts, + XOrThetaGeomData, + YOrRGeomData, + ZGeomData, + mfc); +} + +INTEGER4 LIBCALL TECGEO110(double *XOrThetaPos, + double *YOrRPos, + double *ZPos, + INTEGER4 *PosCoordMode, /* 0=Grid, 1=Frame, 3=Grid3D */ + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *Color, + INTEGER4 *FillColor, + INTEGER4 *IsFilled, + INTEGER4 *GeomType, + INTEGER4 *LinePattern, + double *PatternLength, + double *LineThickness, + INTEGER4 *NumEllipsePts, + INTEGER4 *ArrowheadStyle, + INTEGER4 *ArrowheadAttachment, + double *ArrowheadSize, + double *ArrowheadAngle, + INTEGER4 *Scope, + INTEGER4 *Clipping, + INTEGER4 *NumSegments, + INTEGER4 *NumSegPts, + float *XOrThetaGeomData, + float *YOrRGeomData, + float *ZGeomData, + char *mfc) +{ + return TECGEO112(XOrThetaPos, + YOrRPos, + ZPos, + PosCoordMode, + AttachToZone, + Zone, + Color, + FillColor, + IsFilled, + GeomType, + LinePattern, + PatternLength, + LineThickness, + NumEllipsePts, + ArrowheadStyle, + ArrowheadAttachment, + ArrowheadSize, + ArrowheadAngle, + Scope, + Clipping, + NumSegments, + NumSegPts, + XOrThetaGeomData, + YOrRGeomData, + ZGeomData, + mfc); +} + +INTEGER4 LIBCALL TECGEO100(double *XOrThetaPos, + double *YOrRPos, + double *ZPos, + INTEGER4 *PosCoordMode, /* 0=Grid, 1=Frame, 3=Grid3D */ + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *Color, + INTEGER4 *FillColor, + INTEGER4 *IsFilled, + INTEGER4 *GeomType, + INTEGER4 *LinePattern, + double *PatternLength, + double *LineThickness, + INTEGER4 *NumEllipsePts, + INTEGER4 *ArrowheadStyle, + INTEGER4 *ArrowheadAttachment, + double *ArrowheadSize, + double *ArrowheadAngle, + INTEGER4 *Scope, + INTEGER4 *Clipping, + INTEGER4 *NumSegments, + INTEGER4 *NumSegPts, + float *XOrThetaGeomData, + float *YOrRGeomData, + float *ZGeomData, + char *mfc) +{ + return TECGEO112(XOrThetaPos, + YOrRPos, + ZPos, + PosCoordMode, + AttachToZone, + Zone, + Color, + FillColor, + IsFilled, + GeomType, + LinePattern, + PatternLength, + LineThickness, + NumEllipsePts, + ArrowheadStyle, + ArrowheadAttachment, + ArrowheadSize, + ArrowheadAngle, + Scope, + Clipping, + NumSegments, + NumSegPts, + XOrThetaGeomData, + YOrRGeomData, + ZGeomData, + mfc); +} + +INTEGER4 LIBCALL TECGEO(double *XPos, + double *YPos, + double *ZPos, + INTEGER4 *PosCoordMode, + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *Color, + INTEGER4 *FillColor, + INTEGER4 *IsFilled, + INTEGER4 *GeomType, + INTEGER4 *LinePattern, + double *PatternLength, + double *LineThickness, + INTEGER4 *NumEllipsePts, + INTEGER4 *ArrowheadStyle, + INTEGER4 *ArrowheadAttachment, + double *ArrowheadSize, + double *ArrowheadAngle, + INTEGER4 *Scope, + INTEGER4 *NumSegments, + INTEGER4 *NumSegPts, + float *XGeomData, + float *YGeomData, + float *ZGeomData, + char *mfc) +{ + int Clipping = (int)Clipping_ClipToViewport; + return TECGEO112(XPos, + YPos, + ZPos, + PosCoordMode, + AttachToZone, + Zone, + Color, + FillColor, + IsFilled, + GeomType, + LinePattern, + PatternLength, + LineThickness, + NumEllipsePts, + ArrowheadStyle, + ArrowheadAttachment, + ArrowheadSize, + ArrowheadAngle, + Scope, + &Clipping, + NumSegments, + NumSegPts, + XGeomData, + YGeomData, + ZGeomData, + mfc); +} + +#if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */ +LIBFUNCTION INTEGER4 LIBCALL tecgeo112_(double *XPos, + double *YPos, + double *ZPos, + INTEGER4 *PosCoordMode, + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *Color, + INTEGER4 *FillColor, + INTEGER4 *IsFilled, + INTEGER4 *GeomType, + INTEGER4 *LinePattern, + double *PatternLength, + double *LineThickness, + INTEGER4 *NumEllipsePts, + INTEGER4 *ArrowheadStyle, + INTEGER4 *ArrowheadAttachment, + double *ArrowheadSize, + double *ArrowheadAngle, + INTEGER4 *Scope, + INTEGER4 *Clipping, + INTEGER4 *NumSegments, + INTEGER4 *NumSegPts, + float *XGeomData, + float *YGeomData, + float *ZGeomData, + char *mfc) +{ + return TECGEO112(XPos, + YPos, + ZPos, + PosCoordMode, + AttachToZone, + Zone, + Color, + FillColor, + IsFilled, + GeomType, + LinePattern, + PatternLength, + LineThickness, + NumEllipsePts, + ArrowheadStyle, + ArrowheadAttachment, + ArrowheadSize, + ArrowheadAngle, + Scope, + Clipping, + NumSegments, + NumSegPts, + XGeomData, + YGeomData, + ZGeomData, + mfc); +} + +LIBFUNCTION INTEGER4 LIBCALL tecgeo111_(double *XPos, + double *YPos, + double *ZPos, + INTEGER4 *PosCoordMode, + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *Color, + INTEGER4 *FillColor, + INTEGER4 *IsFilled, + INTEGER4 *GeomType, + INTEGER4 *LinePattern, + double *PatternLength, + double *LineThickness, + INTEGER4 *NumEllipsePts, + INTEGER4 *ArrowheadStyle, + INTEGER4 *ArrowheadAttachment, + double *ArrowheadSize, + double *ArrowheadAngle, + INTEGER4 *Scope, + INTEGER4 *Clipping, + INTEGER4 *NumSegments, + INTEGER4 *NumSegPts, + float *XGeomData, + float *YGeomData, + float *ZGeomData, + char *mfc) +{ + return TECGEO112(XPos, + YPos, + ZPos, + PosCoordMode, + AttachToZone, + Zone, + Color, + FillColor, + IsFilled, + GeomType, + LinePattern, + PatternLength, + LineThickness, + NumEllipsePts, + ArrowheadStyle, + ArrowheadAttachment, + ArrowheadSize, + ArrowheadAngle, + Scope, + Clipping, + NumSegments, + NumSegPts, + XGeomData, + YGeomData, + ZGeomData, + mfc); +} + +LIBFUNCTION INTEGER4 LIBCALL tecgeo110_(double *XPos, + double *YPos, + double *ZPos, + INTEGER4 *PosCoordMode, + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *Color, + INTEGER4 *FillColor, + INTEGER4 *IsFilled, + INTEGER4 *GeomType, + INTEGER4 *LinePattern, + double *PatternLength, + double *LineThickness, + INTEGER4 *NumEllipsePts, + INTEGER4 *ArrowheadStyle, + INTEGER4 *ArrowheadAttachment, + double *ArrowheadSize, + double *ArrowheadAngle, + INTEGER4 *Scope, + INTEGER4 *Clipping, + INTEGER4 *NumSegments, + INTEGER4 *NumSegPts, + float *XGeomData, + float *YGeomData, + float *ZGeomData, + char *mfc) +{ + return TECGEO112(XPos, + YPos, + ZPos, + PosCoordMode, + AttachToZone, + Zone, + Color, + FillColor, + IsFilled, + GeomType, + LinePattern, + PatternLength, + LineThickness, + NumEllipsePts, + ArrowheadStyle, + ArrowheadAttachment, + ArrowheadSize, + ArrowheadAngle, + Scope, + Clipping, + NumSegments, + NumSegPts, + XGeomData, + YGeomData, + ZGeomData, + mfc); +} + +LIBFUNCTION INTEGER4 LIBCALL tecgeo100_(double *XPos, + double *YPos, + double *ZPos, + INTEGER4 *PosCoordMode, + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *Color, + INTEGER4 *FillColor, + INTEGER4 *IsFilled, + INTEGER4 *GeomType, + INTEGER4 *LinePattern, + double *PatternLength, + double *LineThickness, + INTEGER4 *NumEllipsePts, + INTEGER4 *ArrowheadStyle, + INTEGER4 *ArrowheadAttachment, + double *ArrowheadSize, + double *ArrowheadAngle, + INTEGER4 *Scope, + INTEGER4 *Clipping, + INTEGER4 *NumSegments, + INTEGER4 *NumSegPts, + float *XGeomData, + float *YGeomData, + float *ZGeomData, + char *mfc) +{ + return TECGEO112(XPos, + YPos, + ZPos, + PosCoordMode, + AttachToZone, + Zone, + Color, + FillColor, + IsFilled, + GeomType, + LinePattern, + PatternLength, + LineThickness, + NumEllipsePts, + ArrowheadStyle, + ArrowheadAttachment, + ArrowheadSize, + ArrowheadAngle, + Scope, + Clipping, + NumSegments, + NumSegPts, + XGeomData, + YGeomData, + ZGeomData, + mfc); +} + +LIBFUNCTION INTEGER4 LIBCALL tecgeo_(double *XPos, + double *YPos, + double *ZPos, + INTEGER4 *PosCoordMode, + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *Color, + INTEGER4 *FillColor, + INTEGER4 *IsFilled, + INTEGER4 *GeomType, + INTEGER4 *LinePattern, + double *PatternLength, + double *LineThickness, + INTEGER4 *NumEllipsePts, + INTEGER4 *ArrowheadStyle, + INTEGER4 *ArrowheadAttachment, + double *ArrowheadSize, + double *ArrowheadAngle, + INTEGER4 *Scope, + INTEGER4 *NumSegments, + INTEGER4 *NumSegPts, + float *XGeomData, + float *YGeomData, + float *ZGeomData, + char *mfc) +{ + return TECGEO(XPos, + YPos, + ZPos, + PosCoordMode, + AttachToZone, + Zone, + Color, + FillColor, + IsFilled, + GeomType, + LinePattern, + PatternLength, + LineThickness, + NumEllipsePts, + ArrowheadStyle, + ArrowheadAttachment, + ArrowheadSize, + ArrowheadAngle, + Scope, + NumSegments, + NumSegPts, + XGeomData, + YGeomData, + ZGeomData, + mfc); +} +#endif + +/** + * TECTXTXXX + */ +INTEGER4 LIBCALL TECTXT112(double *XOrThetaPos, + double *YOrRPos, + double *ZOrUnusedPos, + INTEGER4 *PosCoordMode, + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *BFont, + INTEGER4 *FontHeightUnits, + double *FontHeight, + INTEGER4 *BoxType, + double *BoxMargin, + double *BoxLineThickness, + INTEGER4 *BoxColor, + INTEGER4 *BoxFillColor, + double *Angle, + INTEGER4 *Anchor, + double *LineSpacing, + INTEGER4 *TextColor, + INTEGER4 *Scope, + INTEGER4 *Clipping, + char *String, + char *mfc) +{ + int RetVal; + Text_s Text; + double Fract; + if (CheckFile("TECTXT112") < 0) + return (-1); + + Text.PositionCoordSys = (CoordSys_e) * PosCoordMode; + if (Text.PositionCoordSys == CoordSys_Frame) + Fract = 0.01; + else + Fract = 1.0; + + Text.AnchorPos.Generic.V1 = (*XOrThetaPos) * Fract; + Text.AnchorPos.Generic.V2 = (*YOrRPos) * Fract; + Text.AnchorPos.Generic.V3 = (*ZOrUnusedPos) * Fract; + Text.AttachToZone = *AttachToZone != 0; + Text.Zone = *Zone - 1; + Text.BColor = (ColorIndex_t) * TextColor; + Text.TextShape.Font = (Font_e) * BFont; + Text.TextShape.SizeUnits = (Units_e) * FontHeightUnits; + if (Text.TextShape.SizeUnits == Units_Frame) + Text.TextShape.Height = (*FontHeight) / 100.0; + else + Text.TextShape.Height = *FontHeight; + Text.Box.BoxType = (TextBox_e) * BoxType; + Text.Box.Margin = *BoxMargin / 100.0; + Text.Box.LineThickness = *BoxLineThickness / 100.0; + Text.Box.BColor = (ColorIndex_t) * BoxColor; + Text.Box.FillBColor = (ColorIndex_t) * BoxFillColor; + Text.Anchor = (TextAnchor_e) * Anchor; + Text.LineSpacing = *LineSpacing; + Text.Angle = *Angle / DEGPERRADIANS; + Text.Scope = (Scope_e) * Scope; + Text.Text = String; + Text.MacroFunctionCommand = mfc; + Text.Clipping = (Clipping_e) * Clipping; + + #if defined MAKEARCHIVE + if (DebugLevel[CurFile]) + PRINT1("\nInserting Text: %s\n", String); + #endif + + if (DumpText(HeadFile[CurFile], &Text, TRUE, FALSE)) + RetVal = 0; + else + RetVal = -1; + + return RetVal; +} + +INTEGER4 LIBCALL TECTXT111(double *XOrThetaPos, + double *YOrRPos, + double *ZOrUnusedPos, + INTEGER4 *PosCoordMode, + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *BFont, + INTEGER4 *FontHeightUnits, + double *FontHeight, + INTEGER4 *BoxType, + double *BoxMargin, + double *BoxLineThickness, + INTEGER4 *BoxColor, + INTEGER4 *BoxFillColor, + double *Angle, + INTEGER4 *Anchor, + double *LineSpacing, + INTEGER4 *TextColor, + INTEGER4 *Scope, + INTEGER4 *Clipping, + char *String, + char *mfc) +{ + return TECTXT112(XOrThetaPos, + YOrRPos, + ZOrUnusedPos, + PosCoordMode, + AttachToZone, + Zone, + BFont, + FontHeightUnits, + FontHeight, + BoxType, + BoxMargin, + BoxLineThickness, + BoxColor, + BoxFillColor, + Angle, + Anchor, + LineSpacing, + TextColor, + Scope, + Clipping, + String, + mfc); +} + +INTEGER4 LIBCALL TECTXT110(double *XOrThetaPos, + double *YOrRPos, + double *ZOrUnusedPos, + INTEGER4 *PosCoordMode, + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *BFont, + INTEGER4 *FontHeightUnits, + double *FontHeight, + INTEGER4 *BoxType, + double *BoxMargin, + double *BoxLineThickness, + INTEGER4 *BoxColor, + INTEGER4 *BoxFillColor, + double *Angle, + INTEGER4 *Anchor, + double *LineSpacing, + INTEGER4 *TextColor, + INTEGER4 *Scope, + INTEGER4 *Clipping, + char *String, + char *mfc) +{ + return TECTXT112(XOrThetaPos, + YOrRPos, + ZOrUnusedPos, + PosCoordMode, + AttachToZone, + Zone, + BFont, + FontHeightUnits, + FontHeight, + BoxType, + BoxMargin, + BoxLineThickness, + BoxColor, + BoxFillColor, + Angle, + Anchor, + LineSpacing, + TextColor, + Scope, + Clipping, + String, + mfc); +} + +INTEGER4 LIBCALL TECTXT100(double *XOrThetaPos, + double *YOrRPos, + double *ZOrUnusedPos, + INTEGER4 *PosCoordMode, + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *BFont, + INTEGER4 *FontHeightUnits, + double *FontHeight, + INTEGER4 *BoxType, + double *BoxMargin, + double *BoxLineThickness, + INTEGER4 *BoxColor, + INTEGER4 *BoxFillColor, + double *Angle, + INTEGER4 *Anchor, + double *LineSpacing, + INTEGER4 *TextColor, + INTEGER4 *Scope, + INTEGER4 *Clipping, + char *String, + char *mfc) +{ + return TECTXT112(XOrThetaPos, + YOrRPos, + ZOrUnusedPos, + PosCoordMode, + AttachToZone, + Zone, + BFont, + FontHeightUnits, + FontHeight, + BoxType, + BoxMargin, + BoxLineThickness, + BoxColor, + BoxFillColor, + Angle, + Anchor, + LineSpacing, + TextColor, + Scope, + Clipping, + String, + mfc); +} + +INTEGER4 LIBCALL TECTXT(double *XPos, + double *YPos, + INTEGER4 *PosCoordMode, + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *BFont, + INTEGER4 *FontHeightUnits, + double *FontHeight, + INTEGER4 *BoxType, + double *BoxMargin, + double *BoxLineThickness, + INTEGER4 *BoxColor, + INTEGER4 *BoxFillColor, + double *Angle, + INTEGER4 *Anchor, + double *LineSpacing, + INTEGER4 *TextColor, + INTEGER4 *Scope, + char *Text, + char *mfc) +{ + double ZPos = 0.0; + int Clipping = (int)Clipping_ClipToViewport; + return TECTXT112(XPos, + YPos, + &ZPos, + PosCoordMode, + AttachToZone, + Zone, + BFont, + FontHeightUnits, + FontHeight, + BoxType, + BoxMargin, + BoxLineThickness, + BoxColor, + BoxFillColor, + Angle, + Anchor, + LineSpacing, + TextColor, + Scope, + &Clipping, + Text, + mfc); +} + +#if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */ +LIBFUNCTION INTEGER4 LIBCALL tectxt112_(double *XOrThetaPos, + double *YOrRPos, + double *ZOrUnusedPos, + INTEGER4 *PosCoordMode, + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *BFont, + INTEGER4 *FontHeightUnits, + double *FontHeight, + INTEGER4 *BoxType, + double *BoxMargin, + double *BoxLineThickness, + INTEGER4 *BoxColor, + INTEGER4 *BoxFillColor, + double *Angle, + INTEGER4 *Anchor, + double *LineSpacing, + INTEGER4 *TextColor, + INTEGER4 *Scope, + INTEGER4 *Clipping, + char *String, + char *mfc) +{ + return TECTXT112(XOrThetaPos, + YOrRPos, + ZOrUnusedPos, + PosCoordMode, + AttachToZone, + Zone, + BFont, + FontHeightUnits, + FontHeight, + BoxType, + BoxMargin, + BoxLineThickness, + BoxColor, + BoxFillColor, + Angle, + Anchor, + LineSpacing, + TextColor, + Scope, + Clipping, + String, + mfc); +} + +LIBFUNCTION INTEGER4 LIBCALL tectxt111_(double *XOrThetaPos, + double *YOrRPos, + double *ZOrUnusedPos, + INTEGER4 *PosCoordMode, + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *BFont, + INTEGER4 *FontHeightUnits, + double *FontHeight, + INTEGER4 *BoxType, + double *BoxMargin, + double *BoxLineThickness, + INTEGER4 *BoxColor, + INTEGER4 *BoxFillColor, + double *Angle, + INTEGER4 *Anchor, + double *LineSpacing, + INTEGER4 *TextColor, + INTEGER4 *Scope, + INTEGER4 *Clipping, + char *String, + char *mfc) +{ + return TECTXT112(XOrThetaPos, + YOrRPos, + ZOrUnusedPos, + PosCoordMode, + AttachToZone, + Zone, + BFont, + FontHeightUnits, + FontHeight, + BoxType, + BoxMargin, + BoxLineThickness, + BoxColor, + BoxFillColor, + Angle, + Anchor, + LineSpacing, + TextColor, + Scope, + Clipping, + String, + mfc); +} + +LIBFUNCTION INTEGER4 LIBCALL tectxt110_(double *XOrThetaPos, + double *YOrRPos, + double *ZOrUnusedPos, + INTEGER4 *PosCoordMode, + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *BFont, + INTEGER4 *FontHeightUnits, + double *FontHeight, + INTEGER4 *BoxType, + double *BoxMargin, + double *BoxLineThickness, + INTEGER4 *BoxColor, + INTEGER4 *BoxFillColor, + double *Angle, + INTEGER4 *Anchor, + double *LineSpacing, + INTEGER4 *TextColor, + INTEGER4 *Scope, + INTEGER4 *Clipping, + char *String, + char *mfc) +{ + return TECTXT112(XOrThetaPos, + YOrRPos, + ZOrUnusedPos, + PosCoordMode, + AttachToZone, + Zone, + BFont, + FontHeightUnits, + FontHeight, + BoxType, + BoxMargin, + BoxLineThickness, + BoxColor, + BoxFillColor, + Angle, + Anchor, + LineSpacing, + TextColor, + Scope, + Clipping, + String, + mfc); +} + +LIBFUNCTION INTEGER4 LIBCALL tectxt100_(double *XOrThetaPos, + double *YOrRPos, + double *ZOrUnusedPos, + INTEGER4 *PosCoordMode, + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *BFont, + INTEGER4 *FontHeightUnits, + double *FontHeight, + INTEGER4 *BoxType, + double *BoxMargin, + double *BoxLineThickness, + INTEGER4 *BoxColor, + INTEGER4 *BoxFillColor, + double *Angle, + INTEGER4 *Anchor, + double *LineSpacing, + INTEGER4 *TextColor, + INTEGER4 *Scope, + INTEGER4 *Clipping, + char *String, + char *mfc) +{ + return TECTXT112(XOrThetaPos, + YOrRPos, + ZOrUnusedPos, + PosCoordMode, + AttachToZone, + Zone, + BFont, + FontHeightUnits, + FontHeight, + BoxType, + BoxMargin, + BoxLineThickness, + BoxColor, + BoxFillColor, + Angle, + Anchor, + LineSpacing, + TextColor, + Scope, + Clipping, + String, + mfc); +} + +LIBFUNCTION INTEGER4 LIBCALL tectxt_(double *XPos, + double *YPos, + INTEGER4 *PosCoordMode, + INTEGER4 *AttachToZone, + INTEGER4 *Zone, + INTEGER4 *BFont, + INTEGER4 *FontHeightUnits, + double *FontHeight, + INTEGER4 *BoxType, + double *BoxMargin, + double *BoxLineThickness, + INTEGER4 *BoxColor, + INTEGER4 *BoxFillColor, + double *Angle, + INTEGER4 *Anchor, + double *LineSpacing, + INTEGER4 *TextColor, + INTEGER4 *Scope, + char *Text, + char *mfc) +{ + return TECTXT(XPos, + YPos, + PosCoordMode, + AttachToZone, + Zone, + BFont, + FontHeightUnits, + FontHeight, + BoxType, + BoxMargin, + BoxLineThickness, + BoxColor, + BoxFillColor, + Angle, + Anchor, + LineSpacing, + TextColor, + Scope, + Text, + mfc); +} +#endif + + +/** + * TECFILXXX + */ +INTEGER4 LIBCALL TECFIL112(INTEGER4 *F) +{ + if ((*F < 1) || (*F > MaxNumFiles)) + { + #if defined MAKEARCHIVE + PRINT1("Err: (TECFIL112) Invalid file number requested (%d). File not changed.\n", *F); + #endif + return (-1); + } + + if (!IsOpen[*F-1]) + { + #if defined MAKEARCHIVE + int I; + PRINT1("Err: (TECFIL112) file %d is not open. File not changed.\n", *F); + PRINT0("\n\nFile states are:\n"); + for (I = 0; I < MaxNumFiles; I++) + PRINT2("file %d, IsOpen=%d\n", I + 1, IsOpen[I]); + PRINT1("Current File is: %d\n", CurFile + 1); + #endif + return (-1); + } + CurFile = *F - 1; + #if defined MAKEARCHIVE + if (DebugLevel[CurFile]) + { + PRINT1("Switching to file #%d\n\n", CurFile + 1); + PRINT0("Current State is:\n"); + PRINT1(" Debug = %d\n", DebugLevel[CurFile]); + PRINT1(" NumVars = %d\n", NumVars[CurFile]); + PRINT1(" DestFName = %s\n", DestFName[CurFile]); + PRINT1(" BlckFName = %s\n", BlckFName[CurFile]); + PRINT1(" ZoneType = %s\n", ZoneTypes[ZoneType[CurFile]]); + + if (ZoneType[CurFile] == ORDERED) + { + PRINT1(" IMax = %d\n", IMax[CurFile]); + PRINT1(" JMax = %d\n", JMax[CurFile]); + PRINT1(" KMax = %d\n", KMax[CurFile]); + } + else + { + PRINT1(" NumPoints = %d\n", IMax[CurFile]); + PRINT1(" NumElmnts = %d\n", JMax[CurFile]); + } + PRINT1(" NumDataValuesWritten = %d\n", NumDataValuesWritten[CurFile]); + PRINT1(" CurZone = %d\n", CurZone[CurFile] + 1); + } + #endif /* MAKEARCHIVE */ + return (0); +} + +INTEGER4 LIBCALL TECFIL111(INTEGER4 *F) +{ + return TECFIL112(F); +} + +INTEGER4 LIBCALL TECFIL110(INTEGER4 *F) +{ + return TECFIL112(F); +} + +INTEGER4 LIBCALL TECFIL100(INTEGER4 *F) +{ + return TECFIL112(F); +} + +INTEGER4 LIBCALL TECFIL(INTEGER4 *F) +{ + return TECFIL112(F); +} + +#if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */ +LIBFUNCTION INTEGER4 LIBCALL tecfil112_(INTEGER4 *F) +{ + return TECFIL112(F); +} + +LIBFUNCTION INTEGER4 LIBCALL tecfil111_(INTEGER4 *F) +{ + return TECFIL112(F); +} + +LIBFUNCTION INTEGER4 LIBCALL tecfil110_(INTEGER4 *F) +{ + return TECFIL112(F); +} + +LIBFUNCTION INTEGER4 LIBCALL tecfil100_(INTEGER4 *F) +{ + return TECFIL112(F); +} + +LIBFUNCTION INTEGER4 LIBCALL tecfil_(INTEGER4 *F) +{ + return TECFIL112(F); +} +#endif + +/** + * TECFOREIGNXXX + */ +void LIBCALL TECFOREIGN112(INTEGER4 *OutputForeignByteOrder) +{ + REQUIRE(VALID_REF(OutputForeignByteOrder)); + + DoWriteForeign = (*OutputForeignByteOrder != 0); +} + +void LIBCALL TECFOREIGN111(INTEGER4 *OutputForeignByteOrder) +{ + TECFOREIGN112(OutputForeignByteOrder); +} + +void LIBCALL TECFOREIGN110(INTEGER4 *OutputForeignByteOrder) +{ + TECFOREIGN112(OutputForeignByteOrder); +} + +void LIBCALL TECFOREIGN100(INTEGER4 *OutputForeignByteOrder) +{ + TECFOREIGN112(OutputForeignByteOrder); +} + +#if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */ +LIBFUNCTION void LIBCALL tecforeign112_(INTEGER4 *OutputForeignByteOrder) +{ + TECFOREIGN112(OutputForeignByteOrder); +} + +LIBFUNCTION void LIBCALL tecforeign111_(INTEGER4 *OutputForeignByteOrder) +{ + TECFOREIGN112(OutputForeignByteOrder); +} + +LIBFUNCTION void LIBCALL tecforeign110_(INTEGER4 *OutputForeignByteOrder) +{ + TECFOREIGN112(OutputForeignByteOrder); +} + +LIBFUNCTION void LIBCALL tecforeign100_(INTEGER4 *OutputForeignByteOrder) +{ + TECFOREIGN112(OutputForeignByteOrder); +} +#endif + +#if defined MAKEARCHIVE + +/** + * A valid auxiliary data name character must begin with a '_' or alpha + * character and may be followed by one or more '_', '.', alpha or digit + * characters. + */ +static Boolean_t AuxDataIsValidNameChar(char Char, + Boolean_t IsLeadChar) +{ + Boolean_t IsValidNameChar; + + REQUIRE(0 <= Char && "Char <= 127"); + REQUIRE(VALID_BOOLEAN(IsLeadChar)); + + IsValidNameChar = (Char == '_' || + isalpha(Char)); + if (!IsLeadChar) + IsValidNameChar = (IsValidNameChar || + Char == '.' || + isdigit(Char)); + + ENSURE(VALID_BOOLEAN(IsValidNameChar)); + return IsValidNameChar; +} + +/** + * Indicates if the auxiliary data name is valid. A valid auxiliary data name + * must begin with a '_' or alpha character and may be followed by one or + * more '_', '.', alpha or digit characters. + */ +static Boolean_t AuxDataIsValidName(const char *Name) +{ + Boolean_t IsValidName; + const char *NPtr; + REQUIRE(VALID_REF(Name)); + + for (NPtr = Name, IsValidName = AuxDataIsValidNameChar(*NPtr, TRUE); + IsValidName && *NPtr != '\0'; + NPtr++) + { + IsValidName = AuxDataIsValidNameChar(*NPtr, FALSE); + } + + ENSURE(VALID_BOOLEAN(IsValidName)); + return IsValidName; +} + +#endif /* MAKEARCHIVE */ + +/** + * TECAUXSTRXXX + */ +LIBFUNCTION INTEGER4 LIBCALL TECAUXSTR112(char *Name, + char *Value) +{ + if (CheckFile("TECAUXSTR112") < 0) + return (-1); + + #if defined MAKEARCHIVE + if (DebugLevel[CurFile]) + PRINT2("\nInserting data set aux data: '%s' = '%s'\n", Name, Value); + #endif + + if ((Name == NULL) || !AuxDataIsValidName(Name)) + { + #if defined MAKEARCHIVE + PRINT0("Err: (TECAUXSTR112) Invalid Name string\n"); + #endif + NumErrs[CurFile]++; + return (-1); + } + + if ((Value == NULL) || (*Value == '\0')) + { + #if defined MAKEARCHIVE + if (DebugLevel[CurFile]) + PRINT0("Err: (TECAUXSTR112) Invalid Value string\n"); + #endif + NumErrs[CurFile]++; + return (-1); + } + + /* + * Because the auxiliary data is at the end of the header section we don't + * need to seek back to it. + */ + if (!WriteBinaryReal(HeadFile[CurFile], DataSetAuxMarker, FieldDataType_Float) || + !DumpDatafileString(HeadFile[CurFile], Name, TRUE /* WriteBinary */) || + !WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)AuxDataType_String) || + !DumpDatafileString(HeadFile[CurFile], (const char *)Value, TRUE /* WriteBinary */)) + { + #if defined MAKEARCHIVE + if (DebugLevel[CurFile]) + printf("Err: (TECAUXSTR112) Write failure for file %d\n", CurFile + 1); + #endif + NumErrs[CurFile]++; + return (-1); + } + return (0); +} + +LIBFUNCTION INTEGER4 LIBCALL TECAUXSTR111(char *Name, + char *Value) +{ + return TECAUXSTR112(Name, Value); +} + +LIBFUNCTION INTEGER4 LIBCALL TECAUXSTR110(char *Name, + char *Value) +{ + return TECAUXSTR112(Name, Value); +} + +LIBFUNCTION INTEGER4 LIBCALL TECAUXSTR100(char *Name, + char *Value) +{ + return TECAUXSTR112(Name, Value); +} + +#if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */ +LIBFUNCTION INTEGER4 LIBCALL tecauxstr112_(char *Name, + char *Value) +{ + return TECAUXSTR112(Name, Value); +} + +LIBFUNCTION INTEGER4 LIBCALL tecauxstr111_(char *Name, + char *Value) +{ + return TECAUXSTR112(Name, Value); +} + +LIBFUNCTION INTEGER4 LIBCALL tecauxstr110_(char *Name, + char *Value) +{ + return TECAUXSTR112(Name, Value); +} + +LIBFUNCTION INTEGER4 LIBCALL tecauxstr100_(char *Name, + char *Value) +{ + return TECAUXSTR112(Name, Value); +} +#endif + + +/** + * TECZAUXSTRXXX + */ +LIBFUNCTION INTEGER4 LIBCALL TECZAUXSTR112(char *Name, + char *Value) +{ + if (CheckFile("TECZAUXSTR112") < 0) + return (-1); + + if (CurZone[CurFile] == -1) + { + #if defined MAKEARCHIVE + PRINT0("Err: (TECZAUXSTR112) Must call TECZNE112 prior to TECZAUXSTR112\n"); + #endif + NumErrs[CurFile]++; + return (-1); + } + + + #if defined MAKEARCHIVE + if (DebugLevel[CurFile]) + PRINT2("\nInserting zone aux data: '%s' = '%s'\n", Name, Value); + #endif + + if ((Name == NULL) || !AuxDataIsValidName(Name)) + { + #if defined MAKEARCHIVE + PRINT0("Err: (TECZAUXSTR112) Invalid Name string\n"); + #endif + NumErrs[CurFile]++; + return (-1); + } + + if ((Value == NULL) || (*Value == '\0')) + { + #if defined MAKEARCHIVE + if (DebugLevel[CurFile]) + PRINT0("Err: (TECZAUXSTR112) Invalid Value string\n"); + #endif + NumErrs[CurFile]++; + return (-1); + } + + /* + * Have to back over the 0 already written, then write another one afterward. + */ + if (TP_FSEEK(HeadFile[CurFile]->File, -4, SEEK_CUR) || + !WriteBinaryInt32(HeadFile[CurFile], 1) || + !DumpDatafileString(HeadFile[CurFile], Name, TRUE /* WriteBinary */) || + !WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)AuxDataType_String) || + !DumpDatafileString(HeadFile[CurFile], (const char *)Value, TRUE /* WriteBinary */) || + !WriteBinaryInt32(HeadFile[CurFile], 0)) + { + #if defined MAKEARCHIVE + if (DebugLevel[CurFile]) + printf("Err: (TECZAUXSTR112) Write failure for file %d\n", CurFile + 1); + #endif + NumErrs[CurFile]++; + return (-1); + } + + return (0); +} + +LIBFUNCTION INTEGER4 LIBCALL TECZAUXSTR111(char *Name, + char *Value) +{ + return TECZAUXSTR112(Name, Value); +} + +LIBFUNCTION INTEGER4 LIBCALL TECZAUXSTR110(char *Name, + char *Value) +{ + return TECZAUXSTR112(Name, Value); +} + +LIBFUNCTION INTEGER4 LIBCALL TECZAUXSTR100(char *Name, + char *Value) +{ + return TECZAUXSTR112(Name, Value); +} + +#if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */ +LIBFUNCTION INTEGER4 LIBCALL teczauxstr112_(char *Name, + char *Value) +{ + return TECZAUXSTR112(Name, Value); +} + +LIBFUNCTION INTEGER4 LIBCALL teczauxstr111_(char *Name, + char *Value) +{ + return TECZAUXSTR112(Name, Value); +} + +LIBFUNCTION INTEGER4 LIBCALL teczauxstr110_(char *Name, + char *Value) +{ + return TECZAUXSTR112(Name, Value); +} + +LIBFUNCTION INTEGER4 LIBCALL teczauxstr100_(char *Name, + char *Value) +{ + return TECZAUXSTR112(Name, Value); +} +#endif + + +/** + * TECVAUXSTRXXX + */ +LIBFUNCTION INTEGER4 LIBCALL TECVAUXSTR112(INTEGER4 *Var, + char *Name, + char *Value) +{ + if (CheckFile("TECVAUXSTR112") < 0) + return (-1); + + #if defined MAKEARCHIVE + if (DebugLevel[CurFile]) + PRINT2("\nInserting variable aux data: '%s' = '%s'\n", Name, Value); + #endif + + if ((Name == NULL) || !AuxDataIsValidName(Name)) + { + #if defined MAKEARCHIVE + PRINT0("Err: (TECVAUXSTR112) Invalid Name string\n"); + #endif + NumErrs[CurFile]++; + return (-1); + } + + if ((Value == NULL) || (*Value == '\0')) + { + #if defined MAKEARCHIVE + if (DebugLevel[CurFile]) + PRINT0("Err: (TECVAUXSTR112) Invalid Value string\n"); + #endif + NumErrs[CurFile]++; + return (-1); + } + + if (!WriteBinaryReal(HeadFile[CurFile], VarAuxMarker, FieldDataType_Float) || + !WriteBinaryInt32(HeadFile[CurFile], *Var - 1) || + !DumpDatafileString(HeadFile[CurFile], Name, TRUE /* WriteBinary */) || + !WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)AuxDataType_String) || + !DumpDatafileString(HeadFile[CurFile], (const char *)Value, TRUE /* WriteBinary */)) + { + #if defined MAKEARCHIVE + if (DebugLevel[CurFile]) + printf("Err: (TECVAUXSTR112) Write failure for file %d\n", CurFile + 1); + #endif + NumErrs[CurFile]++; + return (-1); + } + + return (0); +} + +LIBFUNCTION INTEGER4 LIBCALL TECVAUXSTR111(INTEGER4 *Var, + char *Name, + char *Value) +{ + return TECVAUXSTR112(Var, Name, Value); +} + +LIBFUNCTION INTEGER4 LIBCALL TECVAUXSTR110(INTEGER4 *Var, + char *Name, + char *Value) +{ + return TECVAUXSTR112(Var, Name, Value); +} + +LIBFUNCTION INTEGER4 LIBCALL TECVAUXSTR100(INTEGER4 *Var, + char *Name, + char *Value) +{ + return TECVAUXSTR112(Var, Name, Value); +} + +#if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */ +LIBFUNCTION INTEGER4 LIBCALL tecvauxstr112_(INTEGER4 *Var, + char *Name, + char *Value) +{ + return TECVAUXSTR112(Var, Name, Value); +} + +LIBFUNCTION INTEGER4 LIBCALL tecvauxstr111_(INTEGER4 *Var, + char *Name, + char *Value) +{ + return TECVAUXSTR112(Var, Name, Value); +} + +LIBFUNCTION INTEGER4 LIBCALL tecvauxstr110_(INTEGER4 *Var, + char *Name, + char *Value) +{ + return TECVAUXSTR112(Var, Name, Value); +} + +LIBFUNCTION INTEGER4 LIBCALL tecvauxstr100_(INTEGER4 *Var, + char *Name, + char *Value) +{ + return TECVAUXSTR112(Var, Name, Value); +} +#endif + + +/** + * TECFACEXXX + */ +LIBFUNCTION INTEGER4 LIBCALL TECFACE112(INTEGER4 *FaceConnections) +{ + INTEGER4 i, *Ptr; + + /* Mark that the face neighbors have been written for the zone even if it fails so as not to add extra error messages. */ + FaceNeighborsOrMapWritten[CurFile][CurZone[CurFile]] = TRUE; + + if (CheckFile("TECFACE112") < 0) + return (-1); + + if (ZoneType[CurFile] == FEPOLYGON || + ZoneType[CurFile] == FEPOLYHEDRON) + { + /* Wrong way to specify face neighbors for polygons and polyhedrons */ + #if defined MAKEARCHIVE + PRINT0("Err: (TECFACE112) Cannot call TECFACE112 for polygonal or polyhedral zones.\n"); + #endif + NumErrs[CurFile]++; + return (-1); + } + + if (FileTypes[CurFile] == SOLUTIONFILE) + { + #if defined MAKEARCHIVE + PRINT0("Err: (TECFACE112) Cannot call TECFACE112 if the file type is SOLUTIONFILE.\n"); + #endif + NumErrs[CurFile]++; + return (-1); + } + + #if defined MAKEARCHIVE + if (DebugLevel[CurFile]) + PRINT0("\nInserting face neighbor data\n"); + #endif + + if (FaceConnections == NULL) + { + #if defined MAKEARCHIVE + PRINT0("Err: (TECFACE112) Invalid array\n"); + #endif + NumErrs[CurFile]++; + return (-1); + } + + /* + * Face neighbor connection have the following format for both + * binary: + * + * LOCALONETOONE 3 cz,fz,cz + * LOCALONETOMANY nz+4 cz,fz,oz,nz,cz1,cz2,...,czn + * GLOBALONETOONE 4 cz,fz,ZZ,CZ + * GLOBALONETOMANY 2*nz+4 cz,fz,oz,nz,ZZ1,CZ1,ZZ2,CZ2,...,ZZn,CZn + * + * Where: + * cz = cell in current zone + * fz = face of cell in current zone + * oz = face obsuration flag (only applies to one-to-many): + * 0 = face partially obscured + * 1 = face entirely obscured + * nz = number of cell or zone/cell associations (only applies to one-to-many) + * ZZ = remote Zone + * CZ = cell in remote zone + * + * NOTE: + * As of version 103 Tecplot assumes that face neighbors are zero based + * instead of ones based. Since we have to maintain the contract we + * subtract 1 for the caller. + */ + Ptr = FaceConnections; + i = 0; + while (i < NumFaceConnections[CurFile][CurZone[CurFile]]) + { + INTEGER4 n; + INTEGER4 NumNum = 0; + + switch (FaceNeighborMode[CurFile]) + { + case FaceNeighborMode_LocalOneToOne: + NumNum = 3; + i++; + break; + case FaceNeighborMode_LocalOneToMany: + NumNum = 4 + Ptr[3]; + i += Ptr[3]; + break; + case FaceNeighborMode_GlobalOneToOne: + NumNum = 4; + i++; + break; + case FaceNeighborMode_GlobalOneToMany: + NumNum = 4 + 2 * Ptr[3]; + i += Ptr[3]; + break; + default: + CHECK(FALSE); + break; + } + + n = 0; + if (FaceNeighborMode[CurFile] == FaceNeighborMode_LocalOneToMany || + FaceNeighborMode[CurFile] == FaceNeighborMode_GlobalOneToMany) + { + /* + * Write cz,fz,oz,nz: we do this by hand because the oz and nz values + * are not zero based values. + */ + if (!WriteBinaryInt32(BlckFile[CurFile], Ptr[n++] - 1) || /* zero based as of version 103 */ + !WriteBinaryInt32(BlckFile[CurFile], Ptr[n++] - 1) || /* zero based as of version 103 */ + !WriteBinaryInt32(BlckFile[CurFile], Ptr[n++]) || /* ones based */ + !WriteBinaryInt32(BlckFile[CurFile], Ptr[n++])) /* ones based */ + { + #if defined MAKEARCHIVE + if (DebugLevel[CurFile]) + printf("Err: (TECFACE112) Write failure for file %d\n", CurFile + 1); + #endif + NumErrs[CurFile]++; + return (-1); + } + + } + /* starting from where we left off, output the remaining values */ + for (; n < NumNum; n++) + if (!WriteBinaryInt32(BlckFile[CurFile], Ptr[n] - 1)) /* zero based as of version 103 */ + { + #if defined MAKEARCHIVE + if (DebugLevel[CurFile]) + printf("Err: (TECFACE112) Write failure for file %d\n", CurFile + 1); + #endif + NumErrs[CurFile]++; + return (-1); + } + Ptr += NumNum; + } + + return (0); +} + +LIBFUNCTION INTEGER4 LIBCALL TECFACE111(INTEGER4 *FaceConnections) +{ + return TECFACE112(FaceConnections); +} + +LIBFUNCTION INTEGER4 LIBCALL TECFACE110(INTEGER4 *FaceConnections) +{ + return TECFACE112(FaceConnections); +} + +LIBFUNCTION INTEGER4 LIBCALL TECFACE100(INTEGER4 *FaceConnections) +{ + return TECFACE112(FaceConnections); +} + +#if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */ +LIBFUNCTION INTEGER4 LIBCALL tecface112_(INTEGER4 *FaceConnections) +{ + return TECFACE112(FaceConnections); +} + +LIBFUNCTION INTEGER4 LIBCALL tecface111_(INTEGER4 *FaceConnections) +{ + return TECFACE112(FaceConnections); +} + +LIBFUNCTION INTEGER4 LIBCALL tecface110_(INTEGER4 *FaceConnections) +{ + return TECFACE112(FaceConnections); +} + +LIBFUNCTION INTEGER4 LIBCALL tecface100_(INTEGER4 *FaceConnections) +{ + return TECFACE112(FaceConnections); +} +#endif + + +/** + * TECPOLYXXX + */ +LIBFUNCTION INTEGER4 LIBCALL TECPOLY112(INTEGER4 *FaceNodeCounts, + INTEGER4 *FaceNodes, + INTEGER4 *FaceLeftElems, + INTEGER4 *FaceRightElems, + INTEGER4 *FaceBndryConnectionCounts, + INTEGER4 *FaceBndryConnectionElems, + INTEGER4 *FaceBndryConnectionZones) +{ + INTEGER4 NumFaces = KMax[CurFile]; + INTEGER4 Result = 0; + LgIndex_t Index; + LgIndex_t MinNeighborValue = TECIO_NO_NEIGHBORING_ELEM; + + /* Mark that the face map has been written for the zone even if it fails so as not to add extra error messages. */ + FaceNeighborsOrMapWritten[CurFile][CurZone[CurFile]] = TRUE; + + if (NumFaces == 0 || + (ZoneType[CurFile] != FEPOLYGON && + ZoneType[CurFile] != FEPOLYHEDRON)) + { + #if defined MAKEARCHIVE + PRINT0("Err: (TECPOLY112) The zone type must be FEPOLYGON or FEPOLYHEDRON and have NumFaces (KMax) > 0.\n"); + PRINT1(" NumFaces = %d\n", NumFaces); + #endif + NumErrs[CurFile]++; + return (-1); + } + + if (ZoneType[CurFile] == FEPOLYHEDRON) /* FEPOLYGON doesn't need TotalNumFaceNodes since this is 2*NumFaces */ + { + if (TotalNumFaceNodes[CurFile][CurZone[CurFile]] <= 0) + { + #if defined MAKEARCHIVE + PRINT0("Err: (TECPOLY112) TotalNumFaceNodes MUST be specified for polyhedral zones.\n"); + PRINT1(" TotalNumFaceNodes = %d\n", TotalNumFaceNodes[CurFile][CurZone[CurFile]]); + #endif + NumErrs[CurFile]++; + return (-1); + } + } + else + { + if (TotalNumFaceNodes[CurFile][CurZone[CurFile]] != (2 * NumFaces)) + { + #if defined MAKEARCHIVE + PRINT0("Err: (TECPOLY112) TotalNumFaceNodes is specified for the polygonal zone but is not equal to 2 * NumFaces.\n"); + PRINT2(" TotalNumFaceNodes = %d. If specified, it must be 2 * %d.", TotalNumFaceNodes[CurFile][CurZone[CurFile]], NumFaces); + #endif + NumErrs[CurFile]++; + return (-1); + } + } + + if ((TotalNumFaceBndryFaces[CurFile] > 0 && + TotalNumFaceBndryConns[CurFile] > 0) || + (TotalNumFaceBndryFaces[CurFile] == 0 && + TotalNumFaceBndryConns[CurFile] == 0)) + { + if (TotalNumFaceBndryFaces[CurFile] > 0) + MinNeighborValue = -TotalNumFaceBndryFaces[CurFile]; + } + else + { + #if defined MAKEARCHIVE + PRINT0("Err: (TECPOLY112) TotalNumFaceBndryFaces and TotalNumFaceBndryConns must both be 0 or both be > 0.\n"); + PRINT2(" TotalNumFaceBndryFaces = %d, TotalNumFaceBndryConns = %d\n", TotalNumFaceBndryFaces[CurFile], TotalNumFaceBndryConns[CurFile]); + #endif + NumErrs[CurFile]++; + return (-1); + } + + /* Write the facenodesoffsets array from the facenodecounts array. */ + if (Result == 0) + { + if (ZoneType[CurFile] == FEPOLYHEDRON) /* FEPOLYGON doesn't need to specify facenodesoffsets */ + { + Int32_t FaceNodeSum = 0; + if (!WriteBinaryInt32(BlckFile[CurFile], 0)) + Result = -1; + for (Index = 0; (Result == 0) && (Index < NumFaces); Index++) + { + FaceNodeSum += FaceNodeCounts[Index]; + if (FaceNodeCounts[Index] < 3) + { + #if defined MAKEARCHIVE + PRINT1("Err: (TECPOLY112) Invalid face node count value at face %d. There must be at least 3 nodes in a face.\n", Index + 1); + PRINT1(" Face node count value = %d.\n", FaceNodeCounts[Index]); + #endif + NumErrs[CurFile]++; + return (-1); + } + else if (FaceNodeSum > TotalNumFaceNodes[CurFile][CurZone[CurFile]]) + { + #if defined MAKEARCHIVE + PRINT1("Err: (TECPOLY112) The running face node count exceeds the TotalNumFaceNodes (%d) specified.\n", TotalNumFaceNodes[CurFile][CurZone[CurFile]]); + PRINT1(" Face node count value = %d.\n", FaceNodeCounts[Index]); + #endif + NumErrs[CurFile]++; + return (-1); + } + else if (!WriteBinaryInt32(BlckFile[CurFile], FaceNodeSum)) + Result = -1; + } + } + } + + /* Write the facenodes array but convert 1-based to 0-based. */ + for (Index = 0; (Result == 0) && (Index < TotalNumFaceNodes[CurFile][CurZone[CurFile]]); Index++) + { + if (FaceNodes[Index] < 1 || + FaceNodes[Index] > IMax[CurFile]) + { + #if defined MAKEARCHIVE + PRINT1("Err: (TECPOLY112) Invalid face node value at node %d:\n", Index + 1); + PRINT2(" face node value = %d, valid values are are 1 to %d (inclusive).\n", FaceNodes[Index], IMax[CurFile]); + #endif + NumErrs[CurFile]++; + return (-1); + } + else if (!WriteBinaryInt32(BlckFile[CurFile], FaceNodes[Index] - 1)) + Result = -1; + } + + /* Write the left elements array but convert 1-based to 0-based. */ + for (Index = 0; (Result == 0) && (Index < NumFaces); Index++) + { + if (FaceLeftElems[Index] < MinNeighborValue || + FaceLeftElems[Index] > JMax[CurFile]) + { + #if defined MAKEARCHIVE + PRINT1("Err: (TECPOLY112) Invalid left neighbor value at face %d:\n", Index); + PRINT2(" left neighbor value = %d, min value = %d,", FaceLeftElems[Index], MinNeighborValue); + PRINT1(" max value = %d.\n", JMax[CurFile]); + #endif + NumErrs[CurFile]++; + return (-1); + } + else if (!WriteBinaryInt32(BlckFile[CurFile], FaceLeftElems[Index] - 1)) + Result = -1; + } + /* Write the right elements array but convert 1-based to 0-based. */ + for (Index = 0; (Result == 0) && (Index < NumFaces); Index++) + { + if (FaceRightElems[Index] < MinNeighborValue || + FaceRightElems[Index] > JMax[CurFile]) + { + #if defined MAKEARCHIVE + PRINT1("Err: (TECPOLY112) Invalid right neighbor value at face %d:\n", Index); + PRINT2(" right neighbor value = %d, min value = %d,", FaceRightElems[Index], MinNeighborValue); + PRINT1(" max value = %d.\n", JMax[CurFile]); + #endif + NumErrs[CurFile]++; + return (-1); + } + else if (!WriteBinaryInt32(BlckFile[CurFile], FaceRightElems[Index] - 1)) + Result = -1; + + if (Result == 0 && + (FaceLeftElems[Index] == TECIO_NO_NEIGHBORING_ELEM && + FaceRightElems[Index] == TECIO_NO_NEIGHBORING_ELEM)) + { + #if defined MAKEARCHIVE + PRINT1("Err: (TECPOLY112) Both left and right neighbors are set to no neighboring element at face %d.\n", Index); + #endif + NumErrs[CurFile]++; + return (-1); + } + } + + /* Write the boundary arrays. */ + if (Result == 0 && TotalNumFaceBndryFaces[CurFile] > 0) + { + /* Write the boundaryconnectionoffsets array from the boundaryconnectioncounts array. */ + + /* + * As a convenience for the ASCII format, TecUtil, and TECIO layers if any + * boundary connections exists we automatically add a no-neighboring + * connection as the first item so that they can user 0 for no-neighboring + * element in the element list regardless if they have boundary connections + * or not. + * + * The first 2 offsets are always 0 so that -1 in the left/right element + * arrays always indicates "no neighboring element". + */ + if (!(WriteBinaryInt32(BlckFile[CurFile], 0) && + WriteBinaryInt32(BlckFile[CurFile], 0))) + Result = -1; + + Int32_t BndryConnCount = 0; + for (Index = 0; (Result == 0) && (Index < TotalNumFaceBndryFaces[CurFile]); Index++) + { + BndryConnCount += FaceBndryConnectionCounts[Index]; + if (FaceBndryConnectionCounts[Index] < 0 || + BndryConnCount > TotalNumFaceBndryConns[CurFile]) + { + #if defined MAKEARCHIVE + PRINT1("Err: (TECPOLY112) Invalid boundary connection count at boundary face %d:\n", Index + 1); + PRINT1(" boundary connection count = %d.\n", FaceBndryConnectionCounts[Index]); + #endif + NumErrs[CurFile]++; + return (-1); + } + else if (!WriteBinaryInt32(BlckFile[CurFile], BndryConnCount)) + Result = -1; + } + if (BndryConnCount != TotalNumFaceBndryConns[CurFile]) + { + #if defined MAKEARCHIVE + PRINT0("Err: (TECPOLY112) Invalid number of boundary connections:\n"); + PRINT2(" number of boundary connections written = %d, total number of boundary connections = %d.", + BndryConnCount, TotalNumFaceBndryConns[CurFile]); + #endif + NumErrs[CurFile]++; + return (-1); + } + + /* Write the boundary connection elements but convert 1-based to 0-based. */ + BndryConnCount = 0; + for (Index = 0; (Result == 0) && (Index < TotalNumFaceBndryFaces[CurFile]); Index++) + { + for (LgIndex_t BIndex = 0; (Result == 0) && (BIndex < FaceBndryConnectionCounts[Index]); BIndex++) + { + if (BIndex > 0 && + FaceBndryConnectionElems[BndryConnCount] == TECIO_NO_NEIGHBORING_ELEM) + { + #if defined MAKEARCHIVE + PRINT1("Err: (TECPOLY112) Partially obscured faces must specify no neighboring element first. See boundary connections for face %d.\n", Index + 1); + #endif + NumErrs[CurFile]++; + return (-1); + } + if (FaceBndryConnectionElems[BndryConnCount] < TECIO_NO_NEIGHBORING_ELEM) + { + #if defined MAKEARCHIVE + PRINT1("Err: (TECPOLY112) Invalid boundary element value at boundary connections for face %d:\n", Index + 1); + #endif + NumErrs[CurFile]++; + return (-1); + } + if (FaceBndryConnectionElems[BndryConnCount] == TECIO_NO_NEIGHBORING_ELEM && + FaceBndryConnectionZones[BndryConnCount] != TECIO_NO_NEIGHBORING_ZONE) + { + #if defined MAKEARCHIVE + PRINT1("Err: (TECPOLY112) Invalid boundary element/zone pair at boundary connections for face %d:\n", Index + 1); + PRINT0(" Boundary elements specified as no neighboring element must also specify no neighboring zone.\n"); + #endif + NumErrs[CurFile]++; + return (-1); + } + else if (!WriteBinaryInt32(BlckFile[CurFile], FaceBndryConnectionElems[BndryConnCount] - 1)) + Result = -1; + BndryConnCount++; + } + } + + /* Write the boundary connection zones but convert 1-based to 0-based. */ + BndryConnCount = 0; + for (Index = 0; (Result == 0) && (Index < TotalNumFaceBndryFaces[CurFile]); Index++) + { + for (LgIndex_t BIndex = 0; (Result == 0) && (BIndex < FaceBndryConnectionCounts[Index]); BIndex++) + { + if (FaceBndryConnectionZones[BndryConnCount] < TECIO_NO_NEIGHBORING_ZONE) + { + #if defined MAKEARCHIVE + PRINT1("Err: (TECPOLY112) Invalid boundary zone value at boundary connections for face %d:\n", Index + 1); + #endif + NumErrs[CurFile]++; + return (-1); + } + else if (!WriteBinaryInt32(BlckFile[CurFile], FaceBndryConnectionZones[BndryConnCount] - 1)) + Result = -1; + BndryConnCount++; + } + } + } + if (Result != 0) + { + Result = -1; + WriteErr("TECPOLY112"); + } + + return Result; +} + +#if !defined INDEX_16_BIT // not supported in this test-only mode +LIBFUNCTION INTEGER4 LIBCALL TECPOLY111(INTEGER4 *FaceNodeCounts, + INTEGER4 *FaceNodes, + INTEGER4 *FaceLeftElems, + INTEGER4 *FaceRightElems, + INTEGER4 *FaceBndryConnectionCounts, + INTEGER4 *FaceBndryConnectionElems, + INTEGER2 *FaceBndryConnectionZones) +{ + INTEGER4 Result = 0; + EntIndex_t *FBCZones = NULL; + + if (TotalNumFaceBndryConns[CurFile] > 0) + { + ALLOC_ARRAY(TotalNumFaceBndryConns[CurFile], EntIndex_t, "32-bit FaceBndryConnectionZones"); + + if (FBCZones != NULL) + { + for (LgIndex_t ZoneI = 0; ZoneI < TotalNumFaceBndryFaces[CurFile]; ZoneI++) + FBCZones[ZoneI] = (EntIndex_t)FaceBndryConnectionZones[ZoneI]; + } + else + { + #if defined MAKEARCHIVE + PRINT0("Err: (TECPOLY111) Out of memory allocating temporary data.\n"); + #endif + NumErrs[CurFile]++; + return (-1); + } + } + + Result = TECPOLY112(FaceNodeCounts, + FaceNodes, + FaceLeftElems, + FaceRightElems, + FaceBndryConnectionCounts, + FaceBndryConnectionElems, + FBCZones); + + if (FBCZones != NULL) + FREE_ARRAY(FBCZones, "32-bit FaceBndryConnectionZones"); + + return Result; +} +#endif // INDEX_16_BIT -- not supported in this test-only mode + +#if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */ +LIBFUNCTION INTEGER4 LIBCALL tecpoly112_(INTEGER4 *FaceNodeCounts, + INTEGER4 *FaceNodes, + INTEGER4 *FaceLeftElems, + INTEGER4 *FaceRightElems, + INTEGER4 *FaceBndryConnectionOffsets, + INTEGER4 *FaceBndryConnectionElems, + INTEGER4 *FaceBndryConnectionZones) +{ + return TECPOLY112(FaceNodeCounts, + FaceNodes, + FaceLeftElems, + FaceRightElems, + FaceBndryConnectionOffsets, + FaceBndryConnectionElems, + FaceBndryConnectionZones); +} + +LIBFUNCTION INTEGER4 LIBCALL tecpoly111_(INTEGER4 *FaceNodeCounts, + INTEGER4 *FaceNodes, + INTEGER4 *FaceLeftElems, + INTEGER4 *FaceRightElems, + INTEGER4 *FaceBndryConnectionOffsets, + INTEGER4 *FaceBndryConnectionElems, + INTEGER2 *FaceBndryConnectionZones) +{ + return TECPOLY111(FaceNodeCounts, + FaceNodes, + FaceLeftElems, + FaceRightElems, + FaceBndryConnectionOffsets, + FaceBndryConnectionElems, + FaceBndryConnectionZones); +} +#endif + +#if defined TECPLOTKERNEL +/* CORE SOURCE CODE REMOVED */ +#endif diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio2009.zip b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio2009.zip new file mode 100644 index 0000000000000000000000000000000000000000..cf5c035ce90eb3b71fd8fdc94d874a6cf1b5abbf Binary files /dev/null and b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio2009.zip differ diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/CMakeLists.txt b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/CMakeLists.txt index 93dc9f702ef6899b14de013b222db6a32848f22a..701b09d359b1b7c14779d436ea0bf87d9ff571d8 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/CMakeLists.txt +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/CMakeLists.txt @@ -18,6 +18,7 @@ LINK_DIRECTORIES( ) INCLUDE_DIRECTORIES( + $ENV{WM_PROJECT_DIR}/src/OSspecific/$ENV{WM_OSTYPE} $ENV{WM_PROJECT_DIR}/src/OpenFOAM/lnInclude $ENV{WM_PROJECT_DIR}/src/finiteVolume/lnInclude ${PROJECT_SOURCE_DIR}/../vtkPV3Foam diff --git a/applications/utilities/preProcessing/changeDictionary/changeDictionary.C b/applications/utilities/preProcessing/changeDictionary/changeDictionary.C index b580a27e7132ffbd283cba03e18ba16a3676ab67..083107efb941126c93d447101baf8c057d60804a 100644 --- a/applications/utilities/preProcessing/changeDictionary/changeDictionary.C +++ b/applications/utilities/preProcessing/changeDictionary/changeDictionary.C @@ -29,7 +29,7 @@ Description type in the field and polyMesh/boundary files. Reads dictionaries (fields) and entries to change from a dictionary. - E.g. to make the \em movingWall a \em fixedValue for @em p but all other + E.g. to make the \em movingWall a \em fixedValue for \em p but all other \em Walls a zeroGradient boundary condition, the \c system/changeDictionaryDict would contain the following: \verbatim diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C index b0d3d83ec02638c43d00d11a491d3a1a8462b73d..6d83d1836324e3ee2516c9059dadd826f83c52be 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C +++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -36,6 +36,7 @@ Description #include "Time.H" #include "surfaceFeatures.H" #include "featureEdgeMesh.H" +#include "extendedFeatureEdgeMesh.H" #include "treeBoundBox.H" #include "meshTools.H" #include "OFstream.H" @@ -298,20 +299,46 @@ int main(int argc, char *argv[]) // Extracting and writing a featureEdgeMesh - Pout<< nl << "Writing featureEdgeMesh to constant/featureEdgeMesh." - << endl; - - featureEdgeMesh feMesh + extendedFeatureEdgeMesh feMesh ( newSet, runTime, surfFileName.lessExt().name() + ".featureEdgeMesh" ); + Info<< nl << "Writing extendedFeatureEdgeMesh to " << feMesh.objectPath() + << endl; + + feMesh.writeObj(surfFileName.lessExt().name()); feMesh.write(); + + // Write a featureEdgeMesh for backwards compatibility + { + featureEdgeMesh bfeMesh + ( + IOobject + ( + surfFileName.lessExt().name() + ".eMesh", // name + runTime.constant(), // instance + "triSurface", + runTime, // registry + IOobject::NO_READ, + IOobject::AUTO_WRITE, + false + ), + feMesh.points(), + feMesh.edges() + ); + + Info<< nl << "Writing featureEdgeMesh to " + << bfeMesh.objectPath() << endl; + + bfeMesh.regIOobject::write(); + } + Info<< "End\n" << endl; return 0; diff --git a/bin/engridFoam b/bin/engridFoam index 076f34ddee0663a48f9f50f47df0270940561fa1..6384c365e2ce62987fe316db2285dfca3cde2e0b 100755 --- a/bin/engridFoam +++ b/bin/engridFoam @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -30,6 +30,7 @@ # #------------------------------------------------------------------------------ usage() { + exec 1>&2 while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat<<USAGE diff --git a/bin/findEmptyMake b/bin/findEmptyMake new file mode 100755 index 0000000000000000000000000000000000000000..37125c97e7c39535fb3d8fbb89acaa9165d27f17 --- /dev/null +++ b/bin/findEmptyMake @@ -0,0 +1,82 @@ +#!/bin/sh +#------------------------------------------------------------------------------ +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | +# \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. +# \\/ M anipulation | +#------------------------------------------------------------------------------- +# License +# This file is part of OpenFOAM. +# +# OpenFOAM is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. +# +# Script +# findEmptyMake +# +# Description +# Usage: findEmptyMake [dir1 .. dirN] +# +# Find Make/ directories without a 'files' or 'options' file. +# This can occur when a directory has been moved. +#------------------------------------------------------------------------------ +usage() { + exec 1>&2 + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + cat<<USAGE +Usage: ${0##*/} [OPTION] [dir1 .. dirN] + +Find Make/ directories without a 'files' or 'options' file. +This can occur when a directory has been moved. + +USAGE + exit 1 +} + +# parse options +while [ "$#" -gt 0 ] +do + case "$1" in + -h | -help) + usage + ;; + -*) + usage "unknown option: '$*'" + ;; + *) + break + ;; + esac +done + +# default is the current directory +[ "$#" -gt 0 ] || set -- . + +for checkDir +do + if [ -d "$checkDir" ] + then + echo "searching: $checkDir" 1>&2 + else + echo "skipping non-dir: $checkDir" 1>&2 + continue + fi + + find $checkDir -depth -name Make -type d -print | while read makeDir + do + [ -r "$makeDir/files" -a -r "$makeDir/options" ] || echo "$makeDir" + done + +done +# ----------------------------------------------------------------------------- diff --git a/bin/finddep b/bin/finddep index 331983cba17d2fdc7c178d03761de23ed9fab152..0ef6401f4c3f05434f5906106ab5f597a8c6c7f9 100755 --- a/bin/finddep +++ b/bin/finddep @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -30,9 +30,9 @@ # #------------------------------------------------------------------------------ usage() { + exec 1>&2 while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat<<USAGE - Usage: ${0##*/} <file1> ... <fileN> * find all .dep files referring to any of <file1> ... <fileN> diff --git a/bin/foamClearPolyMesh b/bin/foamClearPolyMesh index 312e39f3053f036826a5fbe94bb73556c3ad0d4f..1d6d8a3df18f92e7c3d45390c4373f223c1f5fb9 100755 --- a/bin/foamClearPolyMesh +++ b/bin/foamClearPolyMesh @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -31,8 +31,9 @@ # #------------------------------------------------------------------------------ usage() { - while [ "$#" -ge 1 ]; do echo "$1" 1>&2; shift; done - cat <<USAGE 1>&2 + exec 1>&2 + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + cat <<USAGE Usage: ${0##*/} [OPTION] options: diff --git a/bin/foamCopySettings b/bin/foamCopySettings index 9e1969c96bd3c48886194760309882e9e1650996..58ad7a264b16cd10ad1bff07143b66f7e4675ad3 100755 --- a/bin/foamCopySettings +++ b/bin/foamCopySettings @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -40,8 +40,9 @@ Script=${0##*/} #------------------------------------------------------------------------------ usage() { - while [ "$#" -ge 1 ]; do echo "$1" 1>&2; shift; done - cat <<USAGE 1>&2 + exec 1>&2 + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + cat <<USAGE Usage: $Script srcDir dstDir diff --git a/bin/foamEndJob b/bin/foamEndJob index 0ff09715604810e3cdf0e4b27d22b401244c503d..dc2d92fdc1f2265bc1e409be2c6148dd9eb74f32 100755 --- a/bin/foamEndJob +++ b/bin/foamEndJob @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -38,6 +38,7 @@ Script=${0##*/} usage() { + exec 1>&2 while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat<<USAGE Usage: $Script [OPTION] <pid> diff --git a/bin/foamEtcFile b/bin/foamEtcFile index 5bae566b55a1509d8f2f65048882fe0b7af41f7b..20b5be0fedf56828b9adb63e91e37c187874a090 100755 --- a/bin/foamEtcFile +++ b/bin/foamEtcFile @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -33,10 +33,10 @@ # personal settings to site-wide settings. # # For example, within the user ~/.OpenFOAM/<VER>/prefs.sh: -# @verbatim +# \code # foamPrefs=`$WM_PROJECT_DIR/bin/foamEtcFile -m go prefs.sh` \ # && _foamSource $foamPrefs -# @endverbatim +# \endcode # #------------------------------------------------------------------------------- usage() { diff --git a/bin/foamExec b/bin/foamExec index 47a2428ccd7466be73bc1e9fd6e6f33b9f4b329c..26ad311349634023a0c9c17ddbfed2dc057f3f1b 100755 --- a/bin/foamExec +++ b/bin/foamExec @@ -39,6 +39,7 @@ # foamEtcFile #------------------------------------------------------------------------------ usage() { + exec 1>&2 while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat<<USAGE diff --git a/bin/foamJob b/bin/foamJob index 649d16d82968e2a8ea0d4c6b5037b54785597af3..06d56b9f06d4aa96276ddef244c4b85ccf0a5b2e 100755 --- a/bin/foamJob +++ b/bin/foamJob @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -29,6 +29,7 @@ # #------------------------------------------------------------------------------ usage() { + exec 1>&2 while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat<<USAGE diff --git a/bin/foamLog b/bin/foamLog index 5658e1af6546f8d6140e44cd7906e1d3c040e88a..b5ca4900b0caa6fe9ea851e2463db9f5c524c44d 100755 --- a/bin/foamLog +++ b/bin/foamLog @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -35,6 +35,7 @@ Script=${0##*/} toolsDir=${0%/*}/tools usage() { + exec 1>&2 while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat <<USAGE diff --git a/bin/foamNew b/bin/foamNew index 1267d3bb9da78f060661d7a2f98d964f977b2d06..48d689936012631551dde042c2bf5dd42c142151 100755 --- a/bin/foamNew +++ b/bin/foamNew @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -30,6 +30,7 @@ # #------------------------------------------------------------------------------ usage() { + exec 1>&2 while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat<<USAGE Usage: ${0##*/} <type> {args} diff --git a/bin/foamNewCase b/bin/foamNewCase index 52cd516bb695f44160f40c1398667ba6d4a7a049..fda86b4bddaafabeca9c4ffa3dd6d3e7396cf6e7 100755 --- a/bin/foamNewCase +++ b/bin/foamNewCase @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -37,6 +37,7 @@ templateDir="appTemplates" #------------------------------------------------------------------------------ usage() { + exec 1>&2 while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat<<USAGE diff --git a/bin/foamPack b/bin/foamPack index 3faa48cfdf3e8388e201a3fdb997d67535741648..19bc8f327b15a3902b99d2f7bef10b3bbe90e58e 100755 --- a/bin/foamPack +++ b/bin/foamPack @@ -33,12 +33,13 @@ packDir=$WM_PROJECT-$WM_PROJECT_VERSION toolsDir="${0%/*}/tools" # this script is located in the tools/ parent dir usage() { - while [ $# -gt 0 ]; do echo "$1" 1>&2; shift; done -cat <<USAGE 1>&2 + exec 1>&2 + while [ "$#" -gt 0 ]; do echo "$1"; shift; done +cat <<USAGE Usage: ${0##*/} [OPTION] options: - -o <dir> specify alternative output directory - -nogit bypass using 'git archive' + -o, -output <dir> specify alternative output directory + -nogit bypass using 'git archive' * Pack and compress OpenFOAM directory for release @@ -46,7 +47,7 @@ USAGE exit 1 } -unset prefix outputDir nogit +unset outputDir nogit # parse options while [ "$#" -gt 0 ] do diff --git a/bin/foamPackBin b/bin/foamPackBin index 2cd739b81827a42c46575beea2bc08de1cc188d1..36614ab781c5620fc28d65c7d33c9c348397f10e 100755 --- a/bin/foamPackBin +++ b/bin/foamPackBin @@ -46,7 +46,7 @@ case "${0##*/}" in ;; *) # regular - codeBase="OpenFOAM ThirdParty" + codeBase="OpenFOAM" packDir=$WM_PROJECT-$WM_PROJECT_VERSION listBinDirs=$toolsDir/foamListBinDirs ;; @@ -54,11 +54,15 @@ esac usage() { - while [ $# -gt 0 ]; do echo "$1" 1>&2; shift; done -cat <<USAGE 1>&2 + exec 1>&2 + while [ "$#" -gt 0 ]; do echo "$1"; shift; done +cat <<USAGE Usage: ${0##*/} [OPTION] <archOptions> + ${0##*/} [OPTION] -current options: - -o <dir> specify alternative output directory + -b, -bzip2 use bzip2 instead of gzip compression + -c, -current use current value of \$WM_OPTIONS + -o, -output <dir> specify alternative output directory * Pack and compress binary version of $codeBase for release @@ -70,7 +74,9 @@ USAGE } -unset prefix outputDir +unset archOptions outputDir +packExt=tgz + # parse options while [ "$#" -gt 0 ] do @@ -78,6 +84,14 @@ do -h | -help) usage ;; + -b | -bzip2) + packExt=tbz + shift + ;; + -c | -current) # use $WM_OPTIONS - eg, 'linux64GccDPOpt' + archOptions="$WM_OPTIONS" + shift + ;; -o | -output) [ "$#" -ge 2 ] || usage "'$1' option requires an argument" outputDir=${2%%/} @@ -92,14 +106,17 @@ do esac done -[ $# -eq 1 ] || usage "Error: specify architecture" +if [ -n "$archOptions" ] +then + [ $# -eq 0 ] || usage "Error: cannot specify both -current and architecture" +else + archOptions="$1" + [ $# -eq 1 ] || usage "Error: specify architecture" +fi -# same as $WM_OPTIONS - eg, 'linux64GccDPOpt' -archOptions="$1" #------------------------------------------------------------------------------ timeStamp=$(date +%Y-%m-%d) -packExt=tgz packBase=${packDir}.${archOptions}_${timeStamp} # add optional output directory @@ -126,11 +143,20 @@ else exit 1 fi +# bzip2 or gzip compression +case "$packFile" in +*tbz) + tarOpt=cpjf + ;; +*) + tarOpt=cpzf + ;; +esac # Clean up on Ctrl-C trap 'rm -f $packFile 2>/dev/null' INT -tar cpzf $packFile $dirList +tar $tarOpt $packFile $dirList if [ $? -eq 0 ] then echo "Finished packing file $packFile" 1>&2 diff --git a/bin/foamPackDeps b/bin/foamPackDeps new file mode 100755 index 0000000000000000000000000000000000000000..0f4d040fffd1fc724aceed81bab91bf6abb6fa1b --- /dev/null +++ b/bin/foamPackDeps @@ -0,0 +1,156 @@ +#!/bin/sh +#------------------------------------------------------------------------------ +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | +# \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. +# \\/ M anipulation | +#------------------------------------------------------------------------------- +# License +# This file is part of OpenFOAM. +# +# OpenFOAM is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. +# +# Script +# foamPackDeps [OPTION] +# +# Description +# Pack and compress *.dep files from OpenFOAM +# +# Script +# foamPackDeps [OPTION] +# +# Description +# Pack and compress *.dep files from OpenFOAM ThirdParty +# +#------------------------------------------------------------------------------ +toolsDir="${0%/*}/tools" # this script is located in the tools/ parent dir + +case "${0##*/}" in +*ThirdParty*) + # for ThirdParty + codeBase="OpenFOAM ThirdParty" + packDir=ThirdParty-$WM_PROJECT_VERSION + ;; +*) + # regular + codeBase="OpenFOAM" + packDir=$WM_PROJECT-$WM_PROJECT_VERSION + ;; +esac + + +usage() { + exec 1>&2 + while [ "$#" -gt 0 ]; do echo "$1"; shift; done +cat <<USAGE +Usage: ${0##*/} [OPTION] +options: + -b, -bzip2 use bzip2 instead of gzip compression + -c, -current for compatibility - currently ignored + -o, -output <dir> specify alternative output directory + +* Pack and compress *.dep files from $codeBase + +USAGE + exit 1 +} + + +unset archOptions outputDir +packExt=tgz + +# parse options +while [ "$#" -gt 0 ] +do + case "$1" in + -h | -help) + usage + ;; + -b | -bzip2) + packExt=tbz + shift + ;; + -c | -current) # use $WM_OPTIONS - eg, 'linux64GccDPOpt' + archOptions="$WM_OPTIONS" + shift + ;; + -o | -output) + [ "$#" -ge 2 ] || usage "'$1' option requires an argument" + outputDir=${2%%/} + shift 2 + ;; + -*) + usage "unknown option: '$*'" + ;; + *) + break + ;; + esac +done + +# check for essential directories +[ -d $packDir ] || { + echo "Error: directory $packDir does not exist" 1>&2 + exit 1 +} + + +#------------------------------------------------------------------------------ +timeStamp=$(date +%Y-%m-%d) +packBase=${packDir}.deps_${timeStamp} + +# add optional output directory +[ -d "$outputDir" ] && packBase="$outputDir/$packBase" +packFile=$packBase.$packExt + +# avoid overwriting old pack file +if [ -f $packFile ] +then + echo "Error: $packFile already exists" 1>&2 + exit 1 +fi + +cat <<INFO 1>&2 +------------------------------------------------------------------------------- +Packing *.dep files into $packFile + +INFO + + +# bzip2 or gzip compression +case "$packFile" in +*tbz) + tarOpt=cpjf + ;; +*) + tarOpt=cpzf + ;; +esac + + +# Clean up on Ctrl-C +trap 'rm -f $packFile 2>/dev/null' INT + +find -H $packDir -name '*.dep' -type f -print | tar $tarOpt $packFile -T - + +if [ $? -eq 0 ] +then + echo "Finished packing *.dep files into $packFile" 1>&2 +else + echo "Error: failure packing *.dep files into $packFile" 1>&2 + rm -f $packFile 2>/dev/null +fi + +#------------------------------------------------------------------------------ diff --git a/bin/foamPackDoxygen b/bin/foamPackDoxygen index c9337e972f4ce3a9262087f42d5e5947eb397670..e78cbcced611dfc3329f0e841406ea162441ef6d 100755 --- a/bin/foamPackDoxygen +++ b/bin/foamPackDoxygen @@ -33,12 +33,14 @@ packDir=$WM_PROJECT-$WM_PROJECT_VERSION htmlDir=doc/Doxygen/html usage() { - while [ $# -gt 0 ]; do echo "$1" 1>&2; shift; done -cat <<USAGE 1>&2 + exec 1>&2 + while [ "$#" -gt 0 ]; do echo "$1"; shift; done +cat <<USAGE Usage: ${0##*/} [OPTION] options: - -prefix <dir> use alternative prefix - -o <dir> specify alternative output directory + -b, -bzip2 use bzip2 instead of gzip compression + -o, -output <dir> specify alternative output directory + -prefix <dir> use alternative prefix * Pack and compress the OpenFOAM doxygen html for release @@ -46,7 +48,10 @@ USAGE exit 1 } + unset prefix outputDir +packExt=tgz + # parse options while [ "$#" -gt 0 ] do @@ -54,16 +59,20 @@ do -h | -help) usage ;; - -prefix | --prefix) - [ "$#" -ge 2 ] || usage "'$1' option requires an argument" - prefix=${2%%/} - shift 2 + -b | -bzip2) + packExt=tbz + shift ;; -o | -output) [ "$#" -ge 2 ] || usage "'$1' option requires an argument" outputDir=${2%%/} shift 2 ;; + -prefix | --prefix) + [ "$#" -ge 2 ] || usage "'$1' option requires an argument" + prefix=${2%%/} + shift 2 + ;; -*) usage "unknown option: '$*'" ;; @@ -87,7 +96,6 @@ then fi #------------------------------------------------------------------------------ -packExt=tgz packName=${packDir}_Doxygen # add optional output directory @@ -107,22 +115,32 @@ Packing doxygen html into $packFile INFO +# bzip2 or gzip compression +case "$packFile" in +*tbz) + tarOpt=cpjf + ;; +*) + tarOpt=cpzf + ;; +esac + # Clean up on Ctrl-C trap 'rm -f $packFile 2>/dev/null' INT if [ -n "$prefix" ] then # requires GNU tar - tar cpzf $packFile --transform="s@^@$prefix/@" $htmlDir + tar $tarOpt $packFile --transform="s@^@$prefix/@" $htmlDir else - tar cpzf $packFile $packDir/$htmlDir + tar $tarOpt $packFile $packDir/$htmlDir fi if [ $? -eq 0 ] then - echo "Finished packing doxygen html into file $packFile" 1>&2 + echo "Finished packing doxygen html into $packFile" 1>&2 else - echo "Error: failure packing doxygen html file $packFile" 1>&2 + echo "Error: failure packing doxygen html into $packFile" 1>&2 rm -f $packFile 2>/dev/null fi diff --git a/bin/foamPackMake b/bin/foamPackMake new file mode 100755 index 0000000000000000000000000000000000000000..c4b6841301876d07a63f3da0c14bb795741108b7 --- /dev/null +++ b/bin/foamPackMake @@ -0,0 +1,164 @@ +#!/bin/sh +#------------------------------------------------------------------------------ +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | +# \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. +# \\/ M anipulation | +#------------------------------------------------------------------------------- +# License +# This file is part of OpenFOAM. +# +# OpenFOAM is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. +# +# Script +# foamPackMake [OPTION] <archOptions> +# +# Description +# Pack and compress OpenFOAM Make/<archOptions> directories +# +# Script +# foamPackThirdPartyMake [OPTION] <archOptions> +# +# Description +# Pack and compress OpenFOAM ThirdParty Make/<archOptions> directories +# +#------------------------------------------------------------------------------ +toolsDir="${0%/*}/tools" # this script is located in the tools/ parent dir + +case "${0##*/}" in +*ThirdParty*) + # for ThirdParty + codeBase="OpenFOAM ThirdParty" + packDir=ThirdParty-$WM_PROJECT_VERSION + ;; +*) + # regular + codeBase="OpenFOAM" + packDir=$WM_PROJECT-$WM_PROJECT_VERSION + ;; +esac + + +usage() { + exec 1>&2 + while [ "$#" -gt 0 ]; do echo "$1"; shift; done +cat <<USAGE +Usage: ${0##*/} [OPTION] <archOptions> + ${0##*/} [OPTION] -current +options: + -b, -bzip2 use bzip2 instead of gzip compression + -c, -current use current value of \$WM_OPTIONS + -o, -output <dir> specify alternative output directory + +* Pack and compress $codeBase Make/<archOptions> directories + + The value of 'archOptions' normally corresponds to \$WM_OPTIONS + The current value of \$WM_OPTIONS = $WM_OPTIONS + +USAGE + exit 1 +} + + +unset archOptions outputDir +packExt=tgz + +# parse options +while [ "$#" -gt 0 ] +do + case "$1" in + -h | -help) + usage + ;; + -b | -bzip2) + packExt=tbz + shift + ;; + -c | -current) # use $WM_OPTIONS - eg, 'linux64GccDPOpt' + archOptions="$WM_OPTIONS" + shift + ;; + -o | -output) + [ "$#" -ge 2 ] || usage "'$1' option requires an argument" + outputDir=${2%%/} + shift 2 + ;; + -*) + usage "unknown option: '$*'" + ;; + *) + break + ;; + esac +done + +if [ -n "$archOptions" ] +then + [ $# -eq 0 ] || usage "Error: cannot specify both -current and architecture" +else + archOptions="$1" + [ $# -eq 1 ] || usage "Error: specify architecture" +fi + + +#------------------------------------------------------------------------------ +timeStamp=$(date +%Y-%m-%d) +packBase=${packDir}.Make-${archOptions}_${timeStamp} + +# add optional output directory +[ -d "$outputDir" ] && packBase="$outputDir/$packBase" +packFile=$packBase.$packExt + +# avoid overwriting old pack file +if [ -f $packFile ] +then + echo "Error: $packFile already exists" 1>&2 + exit 1 +fi + +cat <<INFO 1>&2 +------------------------------------------------------------------------------- +Pack and compress Make/$archOptions* directories into $packFile + +INFO + + +# bzip2 or gzip compression +case "$packFile" in +*tbz) + tarOpt=cpjf + ;; +*) + tarOpt=cpzf + ;; +esac + + +# Clean up on Ctrl-C +trap 'rm -f $packFile 2>/dev/null' INT + +find -H $packDir -depth -name Make -type d -print | \ + xargs -i find '{}' -depth -name "$archOptions*" -type d -print | \ + tar $tarOpt $packFile -T - + +if [ $? -eq 0 ] +then + echo "Finished packing Make/$archOptions directories into $packFile" 1>&2 +else + echo "Error: failure packing Make/$archOptions directories into $packFile" 1>&2 + rm -f $packFile 2>/dev/null +fi + +#------------------------------------------------------------------------------ diff --git a/bin/foamPackThirdParty b/bin/foamPackThirdParty index 37625b42cd36548c1ee26d149e813de8caa5d6ed..bb7c0f6d78080ee987a7c8f221803c317a80c361 100755 --- a/bin/foamPackThirdParty +++ b/bin/foamPackThirdParty @@ -33,8 +33,9 @@ packDir=ThirdParty-$WM_PROJECT_VERSION toolsDir="${0%/*}/tools" # this script is located in the tools/ parent dir usage() { - while [ $# -gt 0 ]; do echo "$1" 1>&2; shift; done -cat <<USAGE 1>&2 + exec 1>&2 + while [ "$#" -gt 0 ]; do echo "$1"; shift; done +cat <<USAGE Usage: ${0##*/} [OPTION] options: -o <dir> specify alternative output directory diff --git a/bin/foamPackThirdPartyDeps b/bin/foamPackThirdPartyDeps new file mode 120000 index 0000000000000000000000000000000000000000..331c2569c84fd13f944c2329435940c5136ccd3d --- /dev/null +++ b/bin/foamPackThirdPartyDeps @@ -0,0 +1 @@ +foamPackDeps \ No newline at end of file diff --git a/bin/foamPackThirdPartyMake b/bin/foamPackThirdPartyMake new file mode 120000 index 0000000000000000000000000000000000000000..56bc81cf73a9548e7621a26df85d6d8af9d9d3a2 --- /dev/null +++ b/bin/foamPackThirdPartyMake @@ -0,0 +1 @@ +foamPackMake \ No newline at end of file diff --git a/bin/foamUpdateCaseFileHeader b/bin/foamUpdateCaseFileHeader index 92d856f749c13a1ad9fe01ee291c626fe3802d06..afc32cf151d99f9d950a3829d2fcfe1e98229118 100755 --- a/bin/foamUpdateCaseFileHeader +++ b/bin/foamUpdateCaseFileHeader @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -33,6 +33,7 @@ # #------------------------------------------------------------------------------ usage() { + exec 1>&2 while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat<<USAGE diff --git a/bin/paraFoam b/bin/paraFoam index 1d4b1ba0a3bc3a4778689affe32eeba7f4a9dde1..ee13790c01d74f902d5e2c15dd7ebee39909203e 100755 --- a/bin/paraFoam +++ b/bin/paraFoam @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -33,6 +33,7 @@ # undefined behaviour #------------------------------------------------------------------------------ usage() { + exec 1>&2 while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat<<USAGE diff --git a/bin/rmdepall b/bin/rmdepall index 69e0c29475d77b67f0576debd6b802c869feffef..39e4b7a21c3c61ed0825b680d29decf8da7d7201 100755 --- a/bin/rmdepall +++ b/bin/rmdepall @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -29,8 +29,9 @@ # Remove all .dep files or remove .dep files referring to <file> #------------------------------------------------------------------------------ usage() { + exec 1>&2 while [ "$#" -ge 1 ]; do echo "$1"; shift; done - cat<<USAGE 1>&2 + cat<<USAGE Usage: ${0##*/} [file] Remove all .dep files or remove .dep files referring to <file> diff --git a/bin/rmdepold b/bin/rmdepold index 01197eb04fa10069dd7a863028546ac262a50e53..bb83bbd9b6b06063ba00748d38536531778b8c3b 100755 --- a/bin/rmdepold +++ b/bin/rmdepold @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -34,8 +34,9 @@ # - optionally remove empty directories #------------------------------------------------------------------------------ usage() { + exec 1>&2 while [ "$#" -ge 1 ]; do echo "$1"; shift; done - cat<<USAGE 1>&2 + cat<<USAGE Usage: ${0##*/} [OPTION] [dir1 .. dirN] options: -rmdir find and remove empty directories (recursively) diff --git a/bin/tools/foamConfigurePaths b/bin/tools/foamConfigurePaths index c0b32f5327618cc0f40855eaae5d9cd098b7c121..4cc15532c6f533f445ecc07efa3aeb6b9c227fc6 100644 --- a/bin/tools/foamConfigurePaths +++ b/bin/tools/foamConfigurePaths @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -30,6 +30,7 @@ # #------------------------------------------------------------------------------ usage() { + exec 1>&2 while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat<<USAGE diff --git a/bin/tools/foamListBinDirs b/bin/tools/foamListBinDirs index 336bd91cdef8abe88f7c0271e92c8bb511a8c069..da2f4d4a374544aa061af01072b3a6bc18bc8d70 100755 --- a/bin/tools/foamListBinDirs +++ b/bin/tools/foamListBinDirs @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -23,7 +23,7 @@ # along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. # # Script -# foamListBinDirs <directory> <archOptions> +# foamListBinDirs <directory> [archOptions] # # Description # Lists directories containing binary files of OpenFOAM @@ -33,9 +33,9 @@ #------------------------------------------------------------------------------ toolsDir="${0%/*}" # this script is already located in the tools/ directory -[ $# -eq 2 ] || { +[ $# -eq 1 -o $# -eq 2 ] || { cat <<USAGE 1>&2 -Usage : ${0##*/} <packDir> <archOptions> +Usage : ${0##*/} <packDir> [archOptions] * Lists directories containing binary files for OpenFOAM @@ -49,8 +49,13 @@ USAGE #------------------------------------------------------------------------------ packDir="$1" -# same as $WM_OPTIONS - eg, 'linux64GccDPOpt' -archOptions="$2" +# default to same as $WM_OPTIONS - eg, 'linux64GccDPOpt' +archOptions="${2:-$WM_OPTIONS}" + +[ -n "$archOptions" ] || { + echo "Error: no archOptions specified" 1>&2 + exit 1 +} # base arch (w/o precision, optimization, etc) # same as "$WM_ARCH$WM_COMPILER" @@ -65,42 +70,18 @@ arch3264=$(echo "$archOS" | sed -e 's@64@-64@') #------------------------------------------------------------------------------ - # check for essential directories -[ -d $packDir ] || { - echo "Error: directory $packDir does not exist" 1>&2 - exit 1 -} - - -# -# check places for libraries - same as $FOAM_LIBBIN -# this has moved around a bit in the recent past -# -[ -d $packDir/lib/$archOptions ] || \ -[ -d $packDir/platforms/$archOptions/lib ] || { -cat <<LIB_CHECK 1>&2 -Error: no directory for libraries exists: - $packDir/lib/$archOptions - $packDir/platforms/$archOptions/lib -LIB_CHECK - exit 1 -} - -# -# check places for executables - same as $FOAM_APPBIN -# this has moved around a bit in the recent past -# -[ -d $packDir/applications/bin/$archOptions ] || \ -[ -d $packDir/platforms/$archOptions/bin ] || { -cat <<BIN_CHECK 1>&2 -Error: no directory for executables exists: - $packDir/platforms/$archOptions/bin - $packDir/applications/bin/$archOptions -BIN_CHECK - exit 1 -} - +for dir in \ + $packDir \ + $packDir/platforms/$archOptions/bin \ + $packDir/platforms/$archOptions/lib \ + ; +do + [ -d $dir ] || { + echo "Error: directory $dir does not exist" 1>&2 + exit 1 + } +done #------------------------------------------------------------------------------ # list of directories @@ -108,13 +89,11 @@ dirList=$( for dir in \ $packDir/platforms/$archOptions/bin \ $packDir/platforms/$archOptions/lib \ - $packDir/wmake/bin/$archCompiler \ - $packDir/wmake/bin/$archOS \ + $packDir/wmake/platforms/$archCompiler \ + $packDir/wmake/platforms/$archOS \ $packDir/wmake/rules/General \ $packDir/wmake/rules/$archCompiler \ $packDir/wmake/rules/$archOS \ - $packDir/applications/bin/$archOptions \ - $packDir/lib/$archOptions \ ; do [ -d $dir ] && echo $dir diff --git a/bin/tools/foamListSourceFiles b/bin/tools/foamListSourceFiles index a8d4d59091f1fd75f1b9e4b7c186292d78f39911..ef6c166e4ccf1e369ad5c67aae37d91890bca657 100755 --- a/bin/tools/foamListSourceFiles +++ b/bin/tools/foamListSourceFiles @@ -46,7 +46,7 @@ USAGE packDir=$(echo "$1" | sed -e 's@//*@/@g' -e 's@/$@@') # check for essential directories -[ -d $packDir ] || { +[ -d "$packDir" ] || { echo "Error: directory $packDir does not exist" 1>&2 exit 1 } @@ -71,16 +71,15 @@ find -H $packDir \ -a ! -name "*.tar" \ -a ! -name "*.tar.gz" \ -a ! -name "*.tgz" \ + -a ! -name "*.tar.bz2" \ + -a ! -name "*.tbz" \ -a ! -name "core" \ -a ! -name "core.[1-9]*" \ -a ! -name "libccmio*" \ | sed \ - -e "\@$packDir/lib/@d" \ -e '\@/\.git/@d' \ -e '\@/\.tags/@d' \ -e '\@/README\.org@d' \ - -e '\@/bin/[^/]*/@{ \@/bin/tools/@!d }' \ - -e '\@/lib/@d' \ -e '\@/platforms/@d' \ -e '\@/t/@d' \ -e '\@/Make[.A-Za-z]*/[^/]*/@d' \ diff --git a/bin/tools/foamListThirdPartyBinDirs b/bin/tools/foamListThirdPartyBinDirs index 872049628e203e49bfa23034ab654ddc40e483fa..c97fefede75e2364ab4d7d099f0a1a14c6178b87 100755 --- a/bin/tools/foamListThirdPartyBinDirs +++ b/bin/tools/foamListThirdPartyBinDirs @@ -23,7 +23,7 @@ # along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. # # Script -# foamListThirdPartyBinDirs <directory> <archOptions> +# foamListThirdPartyBinDirs <directory> [archOptions] # # Description # Lists directories containing binary files for OpenFOAM ThirdParty @@ -33,9 +33,9 @@ #------------------------------------------------------------------------------ toolsDir="${0%/*}" # this script is already located in the tools/ directory -[ $# -eq 2 ] || { +[ $# -eq 1 -o $# -eq 2 ] || { cat <<USAGE 1>&2 -Usage : ${0##*/} <packDir> <archOptions> +Usage : ${0##*/} <packDir> [archOptions] * List directories containing binary files for OpenFOAM ThirdParty @@ -49,8 +49,13 @@ USAGE #------------------------------------------------------------------------------ packDir="$1" -# same as $WM_OPTIONS - eg, 'linux64GccDPOpt' -archOptions="$2" +# default to same as $WM_OPTIONS - eg, 'linux64GccDPOpt' +archOptions="${2:-$WM_OPTIONS}" + +[ -n "$archOptions" ] || { + echo "Error: no archOptions specified" 1>&2 + exit 1 +} # base arch (w/o precision, optimization, etc) # same as "$WM_ARCH$WM_COMPILER" @@ -66,7 +71,10 @@ arch3264=$(echo "$archOS" | sed -e 's@64@-64@') #------------------------------------------------------------------------------ # check for essential directories -for dir in $packDir $packDir/platforms/$archOptions/lib +for dir in \ + $packDir \ + $packDir/platforms/$archOptions/lib \ + ; do [ -d $dir ] || { echo "Error: directory $dir does not exist" 1>&2 diff --git a/bin/tools/foamPackSource b/bin/tools/foamPackSource index 55a7b3bbee07b760ba1e5f8c0aba38befb3c960a..83fe64391f47d67db39fa11e52fe0f61a47b4543 100755 --- a/bin/tools/foamPackSource +++ b/bin/tools/foamPackSource @@ -78,15 +78,25 @@ INFO wc $tmpFile | awk '{print "Packing",$1,"files - this could take some time ..."}' 1>&2 +# bzip2 or gzip compression +case "$packFile" in +*tbz) + tarOpt=cpjf + ;; +*) + tarOpt=cpzf + ;; +esac + # Clean up on Ctrl-C trap 'rm -f $packFile $tmpFile 2>/dev/null' INT -tar cpzf $packFile --files-from $tmpFile +tar $tarOpt $packFile --files-from $tmpFile if [ $? -eq 0 ] then - echo "Finished packing $packDir into file $packFile" 1>&2 + echo "Finished packing $packDir into $packFile" 1>&2 else - echo "Error: failure packing $packDir into file $packFile" 1>&2 + echo "Error: failure packing $packDir into $packFile" 1>&2 rm -f $packFile 2>/dev/null fi diff --git a/bin/tools/org-batch b/bin/tools/org-batch index ae97370dbd08b104647a3e4358c56370ca2dfa67..c5d8ac60c20417aecbbee445f28df4e3eb8f082e 100755 --- a/bin/tools/org-batch +++ b/bin/tools/org-batch @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -32,10 +32,11 @@ Script=${0##*/} usage() { + exec 1>&2 while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat<<USAGE -Usage: ${0##*/} [OPTIONS] file1 [.. fileN] +Usage: $Script [OPTIONS] file1 [.. fileN] options: -html create html (default) -latex create LaTeX diff --git a/bin/tools/pre-commit-hook b/bin/tools/pre-commit-hook index d44edba275e1336e5aeeeeaabee4bb930e4f46b8..44518f083710a51d95c17a1c2a3fefd6efadfd12 100755 --- a/bin/tools/pre-commit-hook +++ b/bin/tools/pre-commit-hook @@ -148,7 +148,7 @@ checkIllegalCode() do case "$f" in # exclude potential makefiles - (wmake/[Mm]akefile* | wmake/rules/*) + (*[Mm]akefile* | wmake/rules/*) ;; (*) # parse line numbers from grep output: diff --git a/bin/tools/pre-receive-hook b/bin/tools/pre-receive-hook index cf4dcb42be6bc0f55b9573cc233b492cfa179499..641185cf131ae7ab70e852479c05354173b83f93 100755 --- a/bin/tools/pre-receive-hook +++ b/bin/tools/pre-receive-hook @@ -111,7 +111,7 @@ checkIllegalCode() do case "$f" in # exclude potential makefiles - (wmake/[Mm]akefile* | wmake/rules/*) + (*[Mm]akefile* | wmake/rules/*) ;; (*) # parse line numbers from grep output: diff --git a/bin/touchdep b/bin/touchdep index cfc8cebc20b39b00fccdcb9a6b2c4fb9f271efc1..5ef6f9a7157cd4a6280b351bcbe42e4970a96bba 100755 --- a/bin/touchdep +++ b/bin/touchdep @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -28,25 +28,72 @@ # Description # touch all .dep files #------------------------------------------------------------------------------ +usage() { + exec 1>&2 + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + cat<<USAGE -# default is pwd -if [ "$#" -eq 0 ] -then - set -- . -elif [ "$1" = "-h" -o "$1" = "-help" ] -then - echo "Usage: ${0##*/} [dir1] .. [dirN]" - echo " touch all .dep files" +Usage: ${0##*/} [OPTION] [dir1] .. [dirN] +options: + -make limit selection to 'Make/\$WM_OPTIONS*' (Make/$WM_OPTIONS*) + -help print the usage + +Find and touch all .dep files in the specified directories. +Uses the cwd by default if no directories are specified. + +Current value of WM_OPTIONS=$WM_OPTIONS + + +NOTE The '-make' is a future feature. +This is currently no separation of .dep files by platforms. + +USAGE exit 1 -fi +} + + +unset restrictOpt + +# parse options +while [ "$#" -gt 0 ] +do + case "$1" in + -h | -help) + usage + ;; + -m | -make) + [ -n "$WM_OPTIONS" ] || usage "Error: -make option only valid when \$WM_OPTIONS is set" + restrictOpt=true + shift + ;; + -*) + usage "unknown option: '$*'" + ;; + *) + break + ;; + esac +done + +# no directories specified: default is pwd +[ "$#" -gt 0 ] || set -- . for i do if [ -d "$i" ] then - echo "touching all .dep files: $i" - find $i -name '*.dep' -print | xargs -t touch + if [ "$restrictOpt" = true ] + then + echo "touching all .dep files under Make/$WM_OPTIONS* : $i" + find $i -depth -name Make -type d -print | \ + xargs -i find '{}' -depth -name "$WM_OPTIONS*" -type d -print | \ + xargs -i find '{}' -name '*.dep' -type f -print | \ + xargs -t touch + else + echo "touching all .dep files: $i" + find $i -name '*.dep' -type f -print | xargs -t touch + fi else echo "no directory: $i" fi diff --git a/bin/toucho b/bin/toucho index aa14d49d2de0e93ec4627954fcc112bb4fb5c73d..ea4233780ae76451b6930a4245b1bbc8fa279367 100755 --- a/bin/toucho +++ b/bin/toucho @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -28,27 +28,71 @@ # Description # touch all .o files #------------------------------------------------------------------------------ +usage() { + exec 1>&2 + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + cat<<USAGE -# default is pwd -if [ "$#" -eq 0 ] -then - set -- . -elif [ "$1" = "-h" -o "$1" = "-help" ] -then - echo "Usage: ${0##*/} [dir1] .. [dirN]" - echo " touch all .o files" +Usage: ${0##*/} [OPTION] [dir1] .. [dirN] +options: + -make limit selection to 'Make/\$WM_OPTIONS*' + -help print the usage + +Find and touch all .o files in the specified directories. +Uses the cwd by default if no directories are specified. + +Current value of WM_OPTIONS=$WM_OPTIONS + +USAGE exit 1 -fi +} + + +unset restrictOpt + +# parse options +while [ "$#" -gt 0 ] +do + case "$1" in + -h | -help) + usage + ;; + -m | -make) + [ -n "$WM_OPTIONS" ] || usage "Error: -make option only valid when \$WM_OPTIONS is set" + restrictOpt=true + shift + ;; + -*) + usage "unknown option: '$*'" + ;; + *) + break + ;; + esac +done +# no directories specified: default is pwd +[ "$#" -gt 0 ] || set -- . + for i do if [ -d "$i" ] then - echo "touching all .o files: $i" - find $i -name '*.o' -print | xargs -t touch + if [ "$restrictOpt" = true ] + then + echo "touching all .o files under Make/$WM_OPTIONS* : $i" + find $i -depth -name Make -type d -print | \ + xargs -i find '{}' -depth -name "$WM_OPTIONS*" -type d -print | \ + xargs -i find '{}' -name '*.o' -type f -print | \ + xargs -t touch + else + echo "touching all .o files: $i" + find $i -name '*.o' -type f -print | xargs -t touch + fi else echo "no directory: $i" fi done + #------------------------------------------------------------------------------ diff --git a/etc/apps/paraview3/bashrc-EXAMPLE b/etc/apps/paraview3/bashrc-EXAMPLE new file mode 100644 index 0000000000000000000000000000000000000000..8db47a9ec7190cbc7072c60e1b42b0ec529c4ab0 --- /dev/null +++ b/etc/apps/paraview3/bashrc-EXAMPLE @@ -0,0 +1,46 @@ +#----------------------------------*-sh-*-------------------------------------- +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | +# \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. +# \\/ M anipulation | +#------------------------------------------------------------------------------ +# License +# This file is part of OpenFOAM. +# +# OpenFOAM is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. +# +# File +# paraview3/bashrc-EXAMPLE +# +# Description +# Example of chaining to the standard paraview3/bashrc with a +# different ParaView_VERSION +# +# Note +# This file could be copied to a user or site location, but should never +# replace the default shipped version as this will cause an infinite loop +# +#------------------------------------------------------------------------------ + +# +# Use other (shipped) bashrc with a different ParaView_VERSION +# + +foamFile=$($WM_PROJECT_DIR/bin/foamEtcFile -mode o apps/paraview3/bashrc 2>/dev/null) +[ $? -eq 0 ] && . $foamFile ParaView_VERSION=3.9.0 + +unset foamFile + +# ----------------------------------------------------------------------------- diff --git a/etc/bashrc b/etc/bashrc index 95c83e82f8012185453f70e92842fea3138756a8..310d5fe00db375ca20d3ae7a59833c3b3be484f9 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -122,12 +122,12 @@ export WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION # Source files, possibly with some verbosity _foamSource() { - while [ $# -ge 1 ] - do - [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1" - . $1 - shift - done + while [ $# -ge 1 ] + do + [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1" + . $1 + shift + done } # Evaluate command-line parameters diff --git a/etc/settings.csh b/etc/settings.csh index a9c7db71183c38369c344fa32af94b2ff6953aba..607d00d3a374f24f9aba8b71ee652e0a55f5d05f 100644 --- a/etc/settings.csh +++ b/etc/settings.csh @@ -228,7 +228,7 @@ endif # boost and CGAL # ~~~~~~~~~~~~~~ -set boost_version=boost_1_42_0 +set boost_version=boost_1_45_0 set cgal_version=CGAL-3.7 setenv BOOST_ARCH_PATH $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$boost_version diff --git a/etc/settings.sh b/etc/settings.sh index 728b197720f14a9f1eb5b7ac576051860c5e0c91..a20742b5fa3dc8cf3838df33e04907d04d87e7a6 100644 --- a/etc/settings.sh +++ b/etc/settings.sh @@ -247,7 +247,7 @@ fi # boost and CGAL # ~~~~~~~~~~~~~~ -boost_version=boost_1_42_0 +boost_version=boost_1_45_0 cgal_version=CGAL-3.7 export BOOST_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$boost_version diff --git a/src/Allwmake b/src/Allwmake index 00bbf8e5e6e91459e1c6913012629a2963c7247a..e9a922ab36908a53859c3a596cf47b4f6e7d423d 100755 --- a/src/Allwmake +++ b/src/Allwmake @@ -39,6 +39,7 @@ parallel/decompose/AllwmakeLnInclude dummyThirdParty/Allwmake $* wmake $makeOption lagrangian/basic +wmake $makeOption lagrangian/distributionModels wmake $makeOption finiteVolume wmake $makeOption genericPatchFields @@ -64,8 +65,6 @@ lagrangian/Allwmake $* postProcessing/Allwmake $* mesh/Allwmake $* -wmake $makeOption errorEstimation - fvAgglomerationMethods/Allwmake $* wmake $makeOption fvMotionSolver diff --git a/src/OSspecific/POSIX/regExp.H b/src/OSspecific/POSIX/regExp.H index 7144d5723ffe08fd3eabd6ca67f8ed374806bb37..9106264ac8197d610e9caf1dfd47e98e6725d941 100644 --- a/src/OSspecific/POSIX/regExp.H +++ b/src/OSspecific/POSIX/regExp.H @@ -29,7 +29,7 @@ Description SeeAlso The manpage regex(7) for more information about POSIX regular expressions. - These differ somewhat from \c Perl and @c sed regular expressions. + These differ somewhat from \c Perl and \c sed regular expressions. SourceFiles regExp.C diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index bf4c345becf9ab4a208b55a0cdd25cd5cfb8bb51..ba3c157b106d4549fe5e3d6029353c7ca945351d 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -66,6 +66,7 @@ primitives/functions/DataEntry/makeDataEntries.C primitives/functions/DataEntry/polynomial/polynomial.C primitives/functions/DataEntry/polynomial/polynomialIO.C +primitives/functions/Polynomial/polynomialFunction.C strings = primitives/strings $(strings)/string/string.C @@ -164,11 +165,16 @@ $(functionEntries)/includeIfPresentEntry/includeIfPresentEntry.C $(functionEntries)/inputModeEntry/inputModeEntry.C $(functionEntries)/removeEntry/removeEntry.C -calcEntry = $(functionEntries)/calcEntry -$(calcEntry)/calcEntryParser.atg -$(calcEntry)/calcEntryInternal.C -$(calcEntry)/calcEntry.C - +/* + * Requires customized coco-cpp + * could be dropped or activated in the future + */ +/* + calcEntry = $(functionEntries)/calcEntry + $(calcEntry)/calcEntryParser.atg + $(calcEntry)/calcEntryInternal.C + $(calcEntry)/calcEntry.C +*/ IOdictionary = db/IOobjects/IOdictionary $(IOdictionary)/IOdictionary.C diff --git a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.C b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.C index 2f1b3383f5ed6c030c2c1a2070dee72cc6743586..0954a23a7e638342677e042dab5839fc3f405c5e 100644 --- a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.C +++ b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -137,7 +137,7 @@ Foam::IOdictionary::IOdictionary(const IOobject& io) } // Everyone check or just master - bool masterOnly = + bool masterOnly = regIOobject::fileModificationChecking == timeStampMaster || regIOobject::fileModificationChecking == inotifyMaster; @@ -195,7 +195,7 @@ Foam::IOdictionary::IOdictionary(const IOobject& io, const dictionary& dict) } // Everyone check or just master - bool masterOnly = + bool masterOnly = regIOobject::fileModificationChecking == timeStampMaster || regIOobject::fileModificationChecking == inotifyMaster; @@ -239,6 +239,18 @@ Foam::IOdictionary::IOdictionary(const IOobject& io, const dictionary& dict) } +Foam::IOdictionary::IOdictionary(const IOobject& io, Istream& is) +: + regIOobject(io) +{ + dictionary::name() = IOobject::objectPath(); + // Note that we do construct the dictionary null and read in afterwards + // so that if there is some fancy massaging due to a functionEntry in + // the dictionary at least the type information is already complete. + is >> *this; +} + + // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * // Foam::IOdictionary::~IOdictionary() diff --git a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.H b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.H index cb66efd46f1469a97351c4b35c8f6fbe35f5f6fd..581d9bec728218a85c90fe8435b3c80691f7493e 100644 --- a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.H +++ b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -75,6 +75,9 @@ public: //- Construct given an IOobject and dictionary IOdictionary(const IOobject&, const dictionary&); + //- Construct given an IOobject and Istream + IOdictionary(const IOobject&, Istream&); + //- Destructor virtual ~IOdictionary(); diff --git a/src/OpenFOAM/db/dictionary/dictionary.C b/src/OpenFOAM/db/dictionary/dictionary.C index 7539f6d7de413349058c1d817b4e78f5a72aa18e..46795873da4864f333ed3ecc4da07b018a71b019 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.C +++ b/src/OpenFOAM/db/dictionary/dictionary.C @@ -486,14 +486,29 @@ Foam::dictionary& Foam::dictionary::subDict(const word& keyword) Foam::dictionary Foam::dictionary::subOrEmptyDict ( - const word& keyword + const word& keyword, + const bool mustRead ) const { const entry* entryPtr = lookupEntryPtr(keyword, false, true); if (entryPtr == NULL) { - return dictionary(*this, dictionary(name() + "::" + keyword)); + if (mustRead) + { + FatalIOErrorIn + ( + "dictionary::subOrEmptyDict(const word& keyword, const bool)", + *this + ) << "keyword " << keyword << " is undefined in dictionary " + << name() + << exit(FatalIOError); + return entryPtr->dict(); + } + else + { + return dictionary(*this, dictionary(name() + "::" + keyword)); + } } else { @@ -741,13 +756,14 @@ bool Foam::dictionary::changeKeyword if (iter()->keyword().isPattern()) { - FatalErrorIn + FatalIOErrorIn ( - "dictionary::changeKeyword(const word&, const word&, bool)" + "dictionary::changeKeyword(const word&, const word&, bool)", + *this ) << "Old keyword "<< oldKeyword << " is a pattern." << "Pattern replacement not yet implemented." - << exit(FatalError); + << exit(FatalIOError); } @@ -781,9 +797,10 @@ bool Foam::dictionary::changeKeyword } else { - WarningIn + IOWarningIn ( - "dictionary::changeKeyword(const word&, const word&, bool)" + "dictionary::changeKeyword(const word&, const word&, bool)", + *this ) << "cannot rename keyword "<< oldKeyword << " to existing keyword " << newKeyword << " in dictionary " << name() << endl; @@ -815,9 +832,9 @@ bool Foam::dictionary::merge(const dictionary& dict) // Check for assignment to self if (this == &dict) { - FatalErrorIn("dictionary::merge(const dictionary&)") + FatalIOErrorIn("dictionary::merge(const dictionary&)", *this) << "attempted merge to self for dictionary " << name() - << abort(FatalError); + << abort(FatalIOError); } bool changed = false; @@ -896,9 +913,9 @@ void Foam::dictionary::operator=(const dictionary& rhs) // Check for assignment to self if (this == &rhs) { - FatalErrorIn("dictionary::operator=(const dictionary&)") + FatalIOErrorIn("dictionary::operator=(const dictionary&)", *this) << "attempted assignment to self for dictionary " << name() - << abort(FatalError); + << abort(FatalIOError); } name() = rhs.name(); @@ -919,9 +936,9 @@ void Foam::dictionary::operator+=(const dictionary& rhs) // Check for assignment to self if (this == &rhs) { - FatalErrorIn("dictionary::operator+=(const dictionary&)") + FatalIOErrorIn("dictionary::operator+=(const dictionary&)", *this) << "attempted addition assignment to self for dictionary " << name() - << abort(FatalError); + << abort(FatalIOError); } forAllConstIter(IDLList<entry>, rhs, iter) @@ -936,9 +953,9 @@ void Foam::dictionary::operator|=(const dictionary& rhs) // Check for assignment to self if (this == &rhs) { - FatalErrorIn("dictionary::operator|=(const dictionary&)") + FatalIOErrorIn("dictionary::operator|=(const dictionary&)", *this) << "attempted assignment to self for dictionary " << name() - << abort(FatalError); + << abort(FatalIOError); } forAllConstIter(IDLList<entry>, rhs, iter) @@ -956,9 +973,9 @@ void Foam::dictionary::operator<<=(const dictionary& rhs) // Check for assignment to self if (this == &rhs) { - FatalErrorIn("dictionary::operator<<=(const dictionary&)") + FatalIOErrorIn("dictionary::operator<<=(const dictionary&)", *this) << "attempted assignment to self for dictionary " << name() - << abort(FatalError); + << abort(FatalIOError); } forAllConstIter(IDLList<entry>, rhs, iter) diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H index ebd0dc9ea197d8c9d4c8f9a11d44657e0e072c00..f1196852bf163e4d3d261ca4f86db034fcea6c01 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.H +++ b/src/OpenFOAM/db/dictionary/dictionary.H @@ -239,7 +239,7 @@ public: //- Destructor - ~dictionary(); + virtual ~dictionary(); // Member functions @@ -368,7 +368,11 @@ public: //- Find and return a sub-dictionary as a copy, or // return an empty dictionary if the sub-dictionary does not exist - dictionary subOrEmptyDict(const word&) const; + dictionary subOrEmptyDict + ( + const word&, + const bool mustRead = false + ) const; //- Return the table of contents wordList toc() const; diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeIfPresentEntry/includeIfPresentEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/includeIfPresentEntry/includeIfPresentEntry.H index 98df647af714d5fec67ef1871e88c738c0730209..f723f5ee98f2a23adb2627267a4d89004e66622c 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/includeIfPresentEntry/includeIfPresentEntry.H +++ b/src/OpenFOAM/db/dictionary/functionEntries/includeIfPresentEntry/includeIfPresentEntry.H @@ -27,7 +27,7 @@ Class Description Specify a file to include if it exists. Expects a single string to follow. - The \c \#includeIfPresent directive is similar to the @c \#include + The \c \#includeIfPresent directive is similar to the \c \#include directive, but does not generate an error if the file does not exist. See Also diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C index ee411f7e15528d67b64a257d9a13aa6939aefb0c..cecce00eae259f2703fb706aa1713160ff7ac6ea 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -95,17 +95,22 @@ Foam::tmp > Foam::GeometricField<Type, PatchField, GeoMesh>::readField(Istream& is) { - if (is.version() < 2.0) - { - FatalIOErrorIn + return readField + ( + IOdictionary ( - "GeometricField<Type, PatchField, GeoMesh>::readField(Istream&)", + IOobject + ( + this->name(), + this->time().timeName(), + this->db(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), is - ) << "IO versions < 2.0 are not supported." - << exit(FatalIOError); - } - - return readField(dictionary(is)); + ) + ); } @@ -384,45 +389,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField } -template<class Type, template<class> class PatchField, class GeoMesh> -Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField -( - const IOobject& io, - const Mesh& mesh, - Istream& is -) -: - DimensionedField<Type, GeoMesh>(io, mesh, dimless, false), - timeIndex_(this->time().timeIndex()), - field0Ptr_(NULL), - fieldPrevIterPtr_(NULL), - boundaryField_(*this, readField(is)) -{ - // Check compatibility between field and mesh - - if (this->size() != GeoMesh::size(this->mesh())) - { - FatalIOErrorIn - ( - "GeometricField<Type, PatchField, GeoMesh>::GeometricField" - "(const IOobject&, const Mesh&, Istream&)", - is - ) << " number of field elements = " << this->size() - << " number of mesh elements = " << GeoMesh::size(this->mesh()) - << exit(FatalIOError); - } - - readOldTimeIfPresent(); - - if (debug) - { - Info<< "Finishing read-construct of " - "GeometricField<Type, PatchField, GeoMesh>" - << endl << this->info() << endl; - } -} - - template<class Type, template<class> class PatchField, class GeoMesh> Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField ( diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H index d276ebfcae9c0853fcda890721ab310e637e6bea..9c04299593690ccb433cb16be9909934239c2fe4 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -325,14 +325,6 @@ public: const Mesh& ); - //- Construct and read from given stream - GeometricField - ( - const IOobject&, - const Mesh&, - Istream& - ); - //- Construct from dictionary GeometricField ( diff --git a/src/OpenFOAM/global/foamDoc.H b/src/OpenFOAM/global/foamDoc.H index c44819062d14510092a3e819d0bb6b38fd6f1d5d..04af83ae1b48011ab625f6a43fbec961ffebee02 100644 --- a/src/OpenFOAM/global/foamDoc.H +++ b/src/OpenFOAM/global/foamDoc.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -21,9 +21,9 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. -@mainpage OpenFOAM®: open source CFD +\mainpage OpenFOAM®: open source CFD -@section about About OpenFOAM +\section about About OpenFOAM OpenFOAM is a free, open source CFD software package produced by a commercial company, @@ -35,7 +35,7 @@ License heat transfer, to solid dynamics and electromagnetics. <a href="http://www.openfoam.com/features">More ...</a> -@section users Our commitment to the users +\section users Our commitment to the users OpenFOAM comes with full commercial support from OpenCFD, including <a href="http://www.openfoam.com/support/software.php"> @@ -48,7 +48,7 @@ License These activities fund the development, maintenance and release of OpenFOAM to make it an extremely viable commercial open source product. -@section opensource Our commitment to open source +\section opensource Our commitment to open source OpenCFD is committed to open source software, continually developing and maintaining OpenFOAM under the diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C index e26c665c639a7c84c063010968a4eb5070296d81..897e290b43fe0fc7a63d678a380d00f9bfc01206 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C @@ -550,11 +550,12 @@ Foam::label Foam::polyBoundaryMesh::whichPatch(const label faceIndex) const Foam::labelHashSet Foam::polyBoundaryMesh::patchSet ( - const wordList& patchNames + const wordReList& patchNames, + const bool warnNotFound ) const { - wordList allPatchNames = names(); - labelHashSet ps(size()); + const wordList allPatchNames(this->names()); + labelHashSet ids(size()); forAll(patchNames, i) { @@ -562,20 +563,23 @@ Foam::labelHashSet Foam::polyBoundaryMesh::patchSet // of all patch names for matches labelList patchIDs = findStrings(patchNames[i], allPatchNames); - if (patchIDs.empty()) + if (patchIDs.empty() && warnNotFound) { - WarningIn("polyBoundaryMesh::patchSet(const wordList&)") - << "Cannot find any patch names matching " << patchNames[i] + WarningIn + ( + "polyBoundaryMesh::patchSet" + "(const wordReList&, const bool) const" + ) << "Cannot find any patch names matching " << patchNames[i] << endl; } forAll(patchIDs, j) { - ps.insert(patchIDs[j]); + ids.insert(patchIDs[j]); } } - return ps; + return ids; } diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H index 0e94bb89b3cb426f034fdce8c4fb613192fdeccd..39fb527368572d8ff4ab8b861d5833af4776a242 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H @@ -38,6 +38,7 @@ SourceFiles #include "polyPatchList.H" #include "regIOobject.H" #include "labelPair.H" +#include "wordReList.H" #include "HashSet.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -166,9 +167,13 @@ public: //- Per boundary face label the patch index const labelList& patchID() const; - //- Return the set of patch IDs corresponding to the given list of names - // Wild cards are expanded. - labelHashSet patchSet(const wordList&) const; + //- Return the set of patch IDs corresponding to the given names + // By default warns if given names are not found. + labelHashSet patchSet + ( + const wordReList& patchNames, + const bool warnNotFound = true + ) const; //- Check whether all procs have all patches and in same order. Return // true if in error. diff --git a/src/OpenFOAM/primitives/functions/DataEntry/Constant/Constant.C b/src/OpenFOAM/primitives/functions/DataEntry/Constant/Constant.C index 6eeafc583ba968f151193dac0200f52b97049070..4aac7b1aa967dff3f5a5a4a7211307327a689b0e 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/Constant/Constant.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/Constant/Constant.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/OpenFOAM/primitives/functions/DataEntry/Constant/Constant.H b/src/OpenFOAM/primitives/functions/DataEntry/Constant/Constant.H index c1d00b118ad1d7caa959ba9a5d7b97542cd5bc14..3002d3b336935f465cf078c0217f8a830c580ddf 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/Constant/Constant.H +++ b/src/OpenFOAM/primitives/functions/DataEntry/Constant/Constant.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/OpenFOAM/primitives/functions/DataEntry/Constant/ConstantIO.C b/src/OpenFOAM/primitives/functions/DataEntry/Constant/ConstantIO.C index eca4a677a2644867ebf52f9bc8425c20afb31259..1d65ef2d9f0cb1142b3ff785cc31a8716dec3477 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/Constant/ConstantIO.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/Constant/ConstantIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntry.C b/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntry.C index 825d8c840031eae079a6229143223c3e66f39699..590dd7c99ae05539e5bf3fdd75e780553eee5d9b 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntry.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntry.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntry.H b/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntry.H index 405b8889a40b5f2f3a4159e3aad878bcafbeecf0..2107e7b2ec1de0fdada241cfffcba5933a64771c 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntry.H +++ b/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntry.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntryIO.C b/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntryIO.C index 99a781a937cc0aab79d10343e7681a48b449c763..cc7ad439c7c9c9da8ed66d8a24c13e9e4c234d0a 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntryIO.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntryIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntryNew.C b/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntryNew.C index fac7d6c4defc0af3922bf126e22b07e0cf04508e..3f8f75fc0cd53fa46a863c4915f1ad3e10deba3c 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntryNew.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntryNew.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/OpenFOAM/primitives/functions/DataEntry/Table/Table.C b/src/OpenFOAM/primitives/functions/DataEntry/Table/Table.C index 71212250ffb1a06fdd7d3d5406c4e7145ca0fe62..54852a5d35052ed54a07c4a242afde95d478c8b8 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/Table/Table.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/Table/Table.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/OpenFOAM/primitives/functions/DataEntry/Table/Table.H b/src/OpenFOAM/primitives/functions/DataEntry/Table/Table.H index 6f7c10e1e0ee78154f6a8ab7599502fa2826749a..35ec60d0befa33dcaf0c1a92f12cef52dad0e08c 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/Table/Table.H +++ b/src/OpenFOAM/primitives/functions/DataEntry/Table/Table.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/OpenFOAM/primitives/functions/DataEntry/Table/TableIO.C b/src/OpenFOAM/primitives/functions/DataEntry/Table/TableIO.C index b312469b6bb81fa5fb7df6f060b772868697a31b..33416011af1041fffa46bd894076ebbb9d2993d6 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/Table/TableIO.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/Table/TableIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/OpenFOAM/primitives/functions/DataEntry/makeDataEntries.C b/src/OpenFOAM/primitives/functions/DataEntry/makeDataEntries.C index 114658753acc4b8a0ea9f870e9a3151b19240876..203f5a1b9e8b346887be441076dff1b66fd729bc 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/makeDataEntries.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/makeDataEntries.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.C b/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.C index 7f9ae731f6bec8c6616e3213346855c17f6e5735..3c642de2d3ab4e335db50eabfc769c4b0262a25e 100644 --- a/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.C +++ b/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.C @@ -41,6 +41,18 @@ Foam::Polynomial<PolySize>::Polynomial() } +template<int PolySize> +Foam::Polynomial<PolySize>::Polynomial +( + const Polynomial<PolySize>& poly +) +: + VectorSpace<Polynomial<PolySize>, scalar, PolySize>(poly), + logActive_(poly.logActive_), + logCoeff_(poly.logCoeff_) +{} + + template<int PolySize> Foam::Polynomial<PolySize>::Polynomial(const scalar coeffs[PolySize]) : @@ -68,7 +80,7 @@ Foam::Polynomial<PolySize>::Polynomial(const UList<scalar>& coeffs) ( "Polynomial<PolySize>::Polynomial(const UList<scalar>&)" ) << "Size mismatch: Needed " << PolySize - << " but got " << coeffs.size() + << " but given " << coeffs.size() << nl << exit(FatalError); } @@ -79,6 +91,39 @@ Foam::Polynomial<PolySize>::Polynomial(const UList<scalar>& coeffs) } +// template<int PolySize> +// Foam::Polynomial<PolySize>::Polynomial(const polynomialFunction& poly) +// : +// VectorSpace<Polynomial<PolySize>, scalar, PolySize>(), +// logActive_(poly.logActive()), +// logCoeff_(poly.logCoeff()) +// { +// if (poly.size() != PolySize) +// { +// FatalErrorIn +// ( +// "Polynomial<PolySize>::Polynomial(const polynomialFunction&)" +// ) << "Size mismatch: Needed " << PolySize +// << " but given " << poly.size() +// << nl << exit(FatalError); +// } +// +// for (int i = 0; i < PolySize; ++i) +// { +// this->v_[i] = poly[i]; +// } +// } + + +template<int PolySize> +Foam::Polynomial<PolySize>::Polynomial(Istream& is) +: + VectorSpace<Polynomial<PolySize>, scalar, PolySize>(is), + logActive_(false), + logCoeff_(0.0) +{} + + template<int PolySize> Foam::Polynomial<PolySize>::Polynomial(const word& name, Istream& is) : @@ -111,38 +156,17 @@ Foam::Polynomial<PolySize>::Polynomial(const word& name, Istream& is) } -template<int PolySize> -Foam::Polynomial<PolySize>::Polynomial(Istream& is) -: - VectorSpace<Polynomial<PolySize>, scalar, PolySize>(is), - logActive_(false), - logCoeff_(0.0) -{} - - -template<int PolySize> -Foam::Polynomial<PolySize>::Polynomial -( - const Polynomial<PolySize>& poly -) -: - VectorSpace<Polynomial<PolySize>, scalar, PolySize>(poly), - logActive_(poly.logActive_), - logCoeff_(poly.logCoeff_) -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<int PolySize> -bool& Foam::Polynomial<PolySize>::logActive() +bool Foam::Polynomial<PolySize>::logActive() const { return logActive_; } template<int PolySize> -Foam::scalar& Foam::Polynomial<PolySize>::logCoeff() +Foam::scalar Foam::Polynomial<PolySize>::logCoeff() const { return logCoeff_; } @@ -151,27 +175,27 @@ Foam::scalar& Foam::Polynomial<PolySize>::logCoeff() template<int PolySize> Foam::scalar Foam::Polynomial<PolySize>::value(const scalar x) const { - scalar y = this->v_[0]; + scalar val = this->v_[0]; // avoid costly pow() in calculation scalar powX = x; for (label i=1; i<PolySize; ++i) { - y += this->v_[i]*powX; + val += this->v_[i]*powX; powX *= x; } if (logActive_) { - y += logCoeff_*log(x); + val += logCoeff_*log(x); } - return y; + return val; } template<int PolySize> -Foam::scalar Foam::Polynomial<PolySize>::integrateLimits +Foam::scalar Foam::Polynomial<PolySize>::integrate ( const scalar x1, const scalar x2 @@ -181,7 +205,7 @@ Foam::scalar Foam::Polynomial<PolySize>::integrateLimits { FatalErrorIn ( - "scalar Polynomial<PolySize>::integrateLimits" + "scalar Polynomial<PolySize>::integrate" "(" "const scalar, " "const scalar" @@ -190,22 +214,33 @@ Foam::scalar Foam::Polynomial<PolySize>::integrateLimits << nl << abort(FatalError); } - intPolyType poly = this->integrate(); - return poly.value(x2) - poly.value(x1); + // avoid costly pow() in calculation + scalar powX1 = x1; + scalar powX2 = x2; + + scalar val = this->v_[0]*(powX2 - powX1); + for (label i=1; i<PolySize; ++i) + { + val += this->v_[i]/(i + 1) * (powX2 - powX1); + powX1 *= x1; + powX2 *= x2; + } + + return val; } template<int PolySize> typename Foam::Polynomial<PolySize>::intPolyType -Foam::Polynomial<PolySize>::integrate(const scalar intConstant) +Foam::Polynomial<PolySize>::integral(const scalar intConstant) const { intPolyType newCoeffs; newCoeffs[0] = intConstant; forAll(*this, i) { - newCoeffs[i + 1] = this->v_[i]/(i + 1); + newCoeffs[i+1] = this->v_[i]/(i + 1); } return newCoeffs; @@ -214,14 +249,14 @@ Foam::Polynomial<PolySize>::integrate(const scalar intConstant) template<int PolySize> typename Foam::Polynomial<PolySize>::polyType -Foam::Polynomial<PolySize>::integrateMinus1(const scalar intConstant) +Foam::Polynomial<PolySize>::integralMinus1(const scalar intConstant) const { polyType newCoeffs; if (this->v_[0] > VSMALL) { - newCoeffs.logActive() = true; - newCoeffs.logCoeff() = this->v_[0]; + newCoeffs.logActive_ = true; + newCoeffs.logCoeff_ = this->v_[0]; } newCoeffs[0] = intConstant; diff --git a/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.H b/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.H index 06511b0003edb911e9c7965964f2227f487d352a..5dfa271c8de66b762e98d0d0c480d5193c452e62 100644 --- a/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.H +++ b/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.H @@ -29,14 +29,14 @@ Description poly = logCoeff*log(x) + sum(coeff_[i]*x^i) - where 0 \<= i \<= n + where 0 \<= i \<= N - integer powers, starting at zero - value(x) to evaluate the poly for a given value - integrate(x1, x2) between two scalar values - - integrate() to return a new, intergated coeff polynomial + - integral() to return a new, integral coeff polynomial - increases the size (order) - - integrateMinus1() to return a new, integrated coeff polynomial where + - integralMinus1() to return a new, integral coeff polynomial where the base poly starts at order -1 SourceFiles @@ -85,10 +85,10 @@ class Polynomial // Private data - //- Include the log term? - only activated using integrateMinus1() + //- Include the log term? - only activated using integralMinus1() bool logActive_; - //- Log coefficient - only activated using integrateMinus1() + //- Log coefficient - only activated using integralMinus1() scalar logCoeff_; @@ -104,6 +104,9 @@ public: //- Construct null, with all coefficients = 0.0 Polynomial(); + //- Copy constructor + Polynomial(const Polynomial&); + //- Construct from C-array of coefficients explicit Polynomial(const scalar coeffs[PolySize]); @@ -111,24 +114,21 @@ public: explicit Polynomial(const UList<scalar>& coeffs); //- Construct from Istream - Polynomial(Istream& is); + Polynomial(Istream&); //- Construct from name and Istream - Polynomial(const word& name, Istream& is); - - //- Copy constructor - Polynomial(const Polynomial& poly); + Polynomial(const word& name, Istream&); // Member Functions // Access - //- Return access to the log term active flag - bool& logActive(); + //- Return true if the log term is active + bool logActive() const; - //- Return access to the log coefficient - scalar& logCoeff(); + //- Return the log coefficient + scalar logCoeff() const; // Evaluation @@ -136,16 +136,17 @@ public: //- Return polynomial value scalar value(const scalar x) const; - //- Return integrated polynomial coefficients - // argument becomes zeroth element (constant of integration) - intPolyType integrate(const scalar intConstant = 0.0); + //- Integrate between two values + scalar integrate(const scalar x1, const scalar x2) const; - //- Return integrated polynomial coefficients when lowest order - // is -1. Argument added to zeroth element - polyType integrateMinus1(const scalar intConstant = 0.0); - //- Integrate between two values - scalar integrateLimits(const scalar x1, const scalar x2) const; + //- Return integral coefficients. + // Argument becomes zeroth element (constant of integration) + intPolyType integral(const scalar intConstant = 0.0) const; + + //- Return integral coefficients when lowest order is -1. + // Argument becomes zeroth element (constant of integration) + polyType integralMinus1(const scalar intConstant = 0.0) const; //- Ostream Operator diff --git a/src/OpenFOAM/primitives/functions/Polynomial/polynomialFunction.C b/src/OpenFOAM/primitives/functions/Polynomial/polynomialFunction.C new file mode 100644 index 0000000000000000000000000000000000000000..44e82ac26d68051888b2714e8c47d92cc25e422d --- /dev/null +++ b/src/OpenFOAM/primitives/functions/Polynomial/polynomialFunction.C @@ -0,0 +1,415 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "polynomialFunction.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(polynomialFunction, 0); +} + + +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + + +Foam::polynomialFunction Foam::polynomialFunction::cloneIntegral +( + const polynomialFunction& poly, + const scalar intConstant +) +{ + polynomialFunction newPoly(poly.size()+1); + + newPoly[0] = intConstant; + forAll(poly, i) + { + newPoly[i+1] = poly[i]/(i + 1); + } + + return newPoly; +} + + +Foam::polynomialFunction Foam::polynomialFunction::cloneIntegralMinus1 +( + const polynomialFunction& poly, + const scalar intConstant +) +{ + polynomialFunction newPoly(poly.size()+1); + + if (poly[0] > VSMALL) + { + newPoly.logActive_ = true; + newPoly.logCoeff_ = poly[0]; + } + + newPoly[0] = intConstant; + for (label i=1; i < poly.size(); ++i) + { + newPoly[i] = poly[i]/i; + } + + return newPoly; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::polynomialFunction::polynomialFunction(const label order) +: + scalarList(order, 0.0), + logActive_(false), + logCoeff_(0.0) +{ + if (this->empty()) + { + FatalErrorIn + ( + "polynomialFunction::polynomialFunction(const label order)" + ) << "polynomialFunction coefficients are invalid (empty)" + << nl << exit(FatalError); + } +} + + +Foam::polynomialFunction::polynomialFunction(const polynomialFunction& poly) +: + scalarList(poly), + logActive_(poly.logActive_), + logCoeff_(poly.logCoeff_) +{} + + +Foam::polynomialFunction::polynomialFunction(const UList<scalar>& coeffs) +: + scalarList(coeffs), + logActive_(false), + logCoeff_(0.0) +{ + if (this->empty()) + { + FatalErrorIn + ( + "polynomialFunction::polynomialFunction(const UList<scalar>&)" + ) << "polynomialFunction coefficients are invalid (empty)" + << nl << exit(FatalError); + } +} + + +Foam::polynomialFunction::polynomialFunction(Istream& is) +: + scalarList(is), + logActive_(false), + logCoeff_(0.0) +{ + if (this->empty()) + { + FatalErrorIn + ( + "polynomialFunction::polynomialFunction(Istream&)" + ) << "polynomialFunction coefficients are invalid (empty)" + << nl << exit(FatalError); + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::polynomialFunction::~polynomialFunction() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::polynomialFunction::logActive() const +{ + return logActive_; +} + + +Foam::scalar Foam::polynomialFunction::logCoeff() const +{ + return logCoeff_; +} + + +Foam::scalar Foam::polynomialFunction::value(const scalar x) const +{ + const scalarList& coeffs = *this; + scalar val = coeffs[0]; + + // avoid costly pow() in calculation + scalar powX = x; + for (label i=1; i<coeffs.size(); ++i) + { + val += coeffs[i]*powX; + powX *= x; + } + + if (logActive_) + { + val += this->logCoeff_*log(x); + } + + return val; +} + + +Foam::scalar Foam::polynomialFunction::integrate +( + const scalar x1, + const scalar x2 +) const +{ + const scalarList& coeffs = *this; + + if (logActive_) + { + FatalErrorIn + ( + "scalar polynomialFunction::integrate" + "(" + "const scalar, " + "const scalar" + ") const" + ) << "Cannot integrate polynomial with logarithmic coefficients" + << nl << abort(FatalError); + } + + // avoid costly pow() in calculation + scalar powX1 = x1; + scalar powX2 = x2; + + scalar val = coeffs[0]*(powX2 - powX1); + for (label i=1; i<coeffs.size(); ++i) + { + val += coeffs[i]/(i + 1)*(powX2 - powX1); + powX1 *= x1; + powX2 *= x2; + } + + return val; +} + + +Foam::polynomialFunction +Foam::polynomialFunction::integral(const scalar intConstant) const +{ + return cloneIntegral(*this, intConstant); +} + + +Foam::polynomialFunction +Foam::polynomialFunction::integralMinus1(const scalar intConstant) const +{ + return cloneIntegralMinus1(*this, intConstant); +} + + +// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * // + +Foam::polynomialFunction& +Foam::polynomialFunction::operator+=(const polynomialFunction& poly) +{ + scalarList& coeffs = *this; + + if (coeffs.size() > poly.size()) + { + forAll(poly, i) + { + coeffs[i] += poly[i]; + } + } + else + { + coeffs.setSize(poly.size(), 0.0); + + forAll(coeffs, i) + { + coeffs[i] += poly[i]; + } + } + + return *this; +} + + +Foam::polynomialFunction& +Foam::polynomialFunction::operator-=(const polynomialFunction& poly) +{ + scalarList& coeffs = *this; + + if (coeffs.size() > poly.size()) + { + forAll(poly, i) + { + coeffs[i] -= poly[i]; + } + } + else + { + coeffs.setSize(poly.size(), 0.0); + + forAll(coeffs, i) + { + coeffs[i] -= poly[i]; + } + } + + return *this; +} + + +Foam::polynomialFunction& +Foam::polynomialFunction::operator*=(const scalar s) +{ + scalarList& coeffs = *this; + forAll(coeffs, i) + { + coeffs[i] *= s; + } + + return *this; +} + + +Foam::polynomialFunction& +Foam::polynomialFunction::operator/=(const scalar s) +{ + scalarList& coeffs = *this; + forAll(coeffs, i) + { + coeffs[i] /= s; + } + + return *this; +} + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +Foam::Ostream& Foam::operator<<(Ostream& os, const polynomialFunction& poly) +{ + // output like VectorSpace + os << token::BEGIN_LIST; + + if (!poly.empty()) + { + for (int i=0; i<poly.size()-1; i++) + { + os << poly[i] << token::SPACE; + } + os << poly.last(); + } + os << token::END_LIST; + + + // Check state of Ostream + os.check("operator<<(Ostream&, const polynomialFunction&)"); + + return os; +} + + +// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // + +Foam::polynomialFunction +Foam::operator+ +( + const polynomialFunction& p1, + const polynomialFunction& p2 +) +{ + polynomialFunction poly(p1); + return poly += p2; +} + + +Foam::polynomialFunction +Foam::operator- +( + const polynomialFunction& p1, + const polynomialFunction& p2 +) +{ + polynomialFunction poly(p1); + return poly -= p2; +} + + +Foam::polynomialFunction +Foam::operator* +( + const scalar s, + const polynomialFunction& p +) +{ + polynomialFunction poly(p); + return poly *= s; +} + + +Foam::polynomialFunction +Foam::operator/ +( + const scalar s, + const polynomialFunction& p +) +{ + polynomialFunction poly(p); + return poly /= s; +} + + +Foam::polynomialFunction +Foam::operator* +( + const polynomialFunction& p, + const scalar s +) +{ + polynomialFunction poly(p); + return poly *= s; +} + + +Foam::polynomialFunction +Foam::operator/ +( + const polynomialFunction& p, + const scalar s +) +{ + polynomialFunction poly(p); + return poly /= s; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/Polynomial/polynomialFunction.H b/src/OpenFOAM/primitives/functions/Polynomial/polynomialFunction.H new file mode 100644 index 0000000000000000000000000000000000000000..b9ce2c7d0901f333cbfb8f154f144409c1af8b7e --- /dev/null +++ b/src/OpenFOAM/primitives/functions/Polynomial/polynomialFunction.H @@ -0,0 +1,246 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::polynomialFunction + +Description + Polynomial function representation + + poly = logCoeff*log(x) + sum(coeff_[i]*x^i) + + where 0 \<= i \<= N + + - integer powers, starting at zero + - value(x) to evaluate the poly for a given value + - integrate(x1, x2) between two scalar values + - integral() to return a new, integral coeff polynomial + - increases the size (order) + - integralMinus1() to return a new, integral coeff polynomial where + the base poly starts at order -1 + +SeeAlso + Foam::Polynomial for a templated implementation + +SourceFiles + polynomialFunction.C + +\*---------------------------------------------------------------------------*/ + +#ifndef polynomialFunction_H +#define polynomialFunction_H + +#include "scalarList.H" +#include "Ostream.H" +#include "runTimeSelectionTables.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class polynomialFunction; + +// Forward declaration of friend functions +Ostream& operator<<(Ostream&, const polynomialFunction&); + + +/*---------------------------------------------------------------------------*\ + Class polynomialFunction Declaration +\*---------------------------------------------------------------------------*/ + +class polynomialFunction +: + private scalarList +{ + // Private data + + //- Include the log term? - only activated using integralMinus1() + bool logActive_; + + //- Log coefficient - only activated using integralMinus1() + scalar logCoeff_; + + + // Private Member Functions + + //- Return integral coefficients. + // Argument becomes zeroth element (constant of integration) + static polynomialFunction cloneIntegral + ( + const polynomialFunction&, + const scalar intConstant = 0.0 + ); + + //- Return integral coefficients when lowest order is -1. + // Argument becomes zeroth element (constant of integration) + static polynomialFunction cloneIntegralMinus1 + ( + const polynomialFunction&, + const scalar intConstant = 0.0 + ); + + + //- Disallow default bitwise assignment + void operator=(const polynomialFunction&); + + + +public: + + //- Runtime type information + TypeName("polynomialFunction"); + + + // Constructors + + //- Construct a particular size, with all coefficients = 0.0 + explicit polynomialFunction(const label); + + //- Copy constructor + polynomialFunction(const polynomialFunction&); + + //- Construct from a list of coefficients + explicit polynomialFunction(const UList<scalar>& coeffs); + + //- Construct from Istream + polynomialFunction(Istream&); + + + //- Destructor + virtual ~polynomialFunction(); + + + // Member Functions + + //- Return the number of coefficients + using scalarList::size; + + //- Return coefficient + using scalarList::operator[]; + + + // Access + + + //- Return true if the log term is active + bool logActive() const; + + //- Return the log coefficient + scalar logCoeff() const; + + + // Evaluation + + //- Return polynomial value + scalar value(const scalar x) const; + + //- Integrate between two values + scalar integrate(const scalar x1, const scalar x2) const; + + + //- Return integral coefficients. + // Argument becomes zeroth element (constant of integration) + polynomialFunction integral + ( + const scalar intConstant = 0.0 + ) const; + + //- Return integral coefficients when lowest order is -1. + // Argument becomes zeroth element (constant of integration) + polynomialFunction integralMinus1 + ( + const scalar intConstant = 0.0 + ) const; + + + // Member Operators + + polynomialFunction& operator+=(const polynomialFunction&); + polynomialFunction& operator-=(const polynomialFunction&); + + polynomialFunction& operator*=(const scalar); + polynomialFunction& operator/=(const scalar); + + + //- Ostream Operator + friend Ostream& operator<<(Ostream&, const polynomialFunction&); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // + +polynomialFunction operator+ +( + const polynomialFunction&, + const polynomialFunction& +); + + +polynomialFunction operator- +( + const polynomialFunction&, + const polynomialFunction& +); + + +polynomialFunction operator* +( + const scalar, + const polynomialFunction& +); + + +polynomialFunction operator/ +( + const scalar, + const polynomialFunction& +); + + +polynomialFunction operator* +( + const polynomialFunction&, + const scalar +); + + +polynomialFunction operator/ +( + const polynomialFunction&, + const scalar +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/conversion/meshWriter/meshWriter.H b/src/conversion/meshWriter/meshWriter.H index 4aace111bc0c149dce07ca737b3bbe5678c7a9ab..431b565be27604cff7aeecbb35df0c225a9ef084 100644 --- a/src/conversion/meshWriter/meshWriter.H +++ b/src/conversion/meshWriter/meshWriter.H @@ -35,7 +35,7 @@ Description write OpenFOAM meshes and/or results to another CFD format - currently just STAR-CD -@par Files +\par Files "constant/boundaryRegion" is an IOMap<dictionary> that contains the boundary type and names. eg, diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C index 0a906aa7bcfd22bdd707f8bca9afbf5c16f3b452..f8f7ab41b0052a056d4bf2956dc0a7ab93452e59 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C @@ -43,75 +43,6 @@ defineTypeNameAndDebug(Foam::addPatchCellLayer, 0); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -// Calculate global faces per pp edge. -Foam::labelListList Foam::addPatchCellLayer::calcGlobalEdgeFaces -( - const polyMesh& mesh, - const globalIndex& globalFaces, - const indirectPrimitivePatch& pp, - const labelList& meshEdges -) -{ - //// Determine coupled edges just so we don't have to have storage - //// for all non-coupled edges. - // - //PackedBoolList isCoupledEdge(mesh.nEdges()); - // - //const polyBoundaryMesh& patches = mesh.boundaryMesh(); - // - //forAll(patches, patchI) - //{ - // const polyPatch& pp = patches[patchI]; - // - // if (pp.coupled()) - // { - // const labelList& meshEdges = pp.meshEdges(); - // - // forAll(meshEdges, i) - // { - // isCoupledEdge.set(meshEdges[i], 1); - // } - // } - //} - - // From mesh edge to global face labels. Sized only for pp edges. - labelListList globalEdgeFaces(mesh.nEdges()); - - const labelListList& edgeFaces = pp.edgeFaces(); - - forAll(edgeFaces, edgeI) - { - label meshEdgeI = meshEdges[edgeI]; - - //if (isCoupledEdge.get(meshEdgeI) == 1) - { - const labelList& eFaces = edgeFaces[edgeI]; - - // Store face and processor as unique tag. - labelList& globalEFaces = globalEdgeFaces[meshEdgeI]; - globalEFaces.setSize(eFaces.size()); - forAll(eFaces, i) - { - globalEFaces[i] = - globalFaces.toGlobal(pp.addressing()[eFaces[i]]); - } - } - } - - // Synchronise across coupled edges. - syncTools::syncEdgeList - ( - mesh, - globalEdgeFaces, - uniqueEqOp(), - labelList() // null value - ); - - // Extract pp part - return labelListList(UIndirectList<labelList>(globalEdgeFaces, meshEdges)); -} - - Foam::label Foam::addPatchCellLayer::nbrFace ( const labelListList& edgeFaces, @@ -316,12 +247,12 @@ Foam::labelPair Foam::addPatchCellLayer::getEdgeString Foam::label Foam::addPatchCellLayer::addSideFace ( const indirectPrimitivePatch& pp, - const labelList& patchID, // prestored patch per pp face const labelListList& addedCells, // per pp face the new extruded cell const face& newFace, + const label newPatchID, + const label ownFaceI, // pp face that provides owner const label nbrFaceI, - const label patchEdgeI, // edge to add to const label meshEdgeI, // corresponding mesh edge const label layerI, // layer const label numEdgeFaces, // number of layers for edge @@ -329,8 +260,9 @@ Foam::label Foam::addPatchCellLayer::addSideFace polyTopoChange& meshMod ) const { - // Edge to 'inflate' from + // Face or edge to 'inflate' from label inflateEdgeI = -1; + label inflateFaceI = -1; // Check mesh faces using edge if (addToMesh_) @@ -346,8 +278,6 @@ Foam::label Foam::addPatchCellLayer::addSideFace } } - // Get my mesh face and its zone. - label meshFaceI = pp.addressing()[ownFaceI]; // Zone info comes from any side patch face. Otherwise -1 since we // don't know what to put it in - inherit from the extruded faces? label zoneI = -1; //mesh_.faceZones().whichZone(meshFaceI); @@ -358,14 +288,15 @@ Foam::label Foam::addPatchCellLayer::addSideFace // Is patch edge external edge of indirectPrimitivePatch? if (nbrFaceI == -1) { - // External edge so external face. Patch id is obtained from - // any other patch connected to edge. + // External edge so external face. const polyBoundaryMesh& patches = mesh_.boundaryMesh(); // Loop over all faces connected to edge to inflate and - // see if any boundary face (but not meshFaceI) - label otherPatchID = patchID[ownFaceI]; + // see if we can find a face that is otherPatchID + + // Get my mesh face and its zone. + label meshFaceI = pp.addressing()[ownFaceI]; forAll(meshFaces, k) { @@ -373,11 +304,14 @@ Foam::label Foam::addPatchCellLayer::addSideFace if ( - faceI != meshFaceI - && !mesh_.isInternalFace(faceI) + (faceI != meshFaceI) + && (patches.whichPatch(faceI) == newPatchID) ) { - otherPatchID = patches.whichPatch(faceI); + // Found the patch face. Use it to inflate from + inflateEdgeI = -1; + inflateFaceI = faceI; + zoneI = mesh_.faceZones().whichZone(faceI); if (zoneI != -1) { @@ -414,7 +348,7 @@ Foam::label Foam::addPatchCellLayer::addSideFace //Pout<< "Added boundary face:" << newFace // << " own:" << addedCells[ownFaceI][layerOwn] - // << " patch:" << otherPatchID + // << " patch:" << newPatchID // << endl; addedFaceI = meshMod.setAction @@ -426,9 +360,9 @@ Foam::label Foam::addPatchCellLayer::addSideFace -1, // neighbour -1, // master point inflateEdgeI, // master edge - -1, // master face + inflateFaceI, // master face false, // flux flip - otherPatchID, // patch for face + newPatchID, // patch for face zoneI, // zone for face flip // face zone flip ) @@ -510,6 +444,51 @@ Foam::label Foam::addPatchCellLayer::addSideFace } +Foam::label Foam::addPatchCellLayer::findProcPatch +( + const polyMesh& mesh, + const label nbrProcID +) +{ + const polyBoundaryMesh& patches = mesh.boundaryMesh(); + + forAll(mesh.globalData().processorPatches(), i) + { + label patchI = mesh.globalData().processorPatches()[i]; + + if + ( + refCast<const processorPolyPatch>(patches[patchI]).neighbProcNo() + == nbrProcID + ) + { + return patchI; + } + } + return -1; +} + + +void Foam::addPatchCellLayer::setFaceProps +( + const polyMesh& mesh, + const label faceI, + + label& patchI, + label& zoneI, + bool& zoneFlip +) +{ + patchI = mesh.boundaryMesh().whichPatch(faceI); + zoneI = mesh.faceZones().whichZone(faceI); + if (zoneI != -1) + { + label index = mesh.faceZones()[zoneI].whichFace(faceI); + zoneFlip = mesh.faceZones()[zoneI].flipMap()[index]; + } +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // Construct from mesh @@ -561,10 +540,251 @@ Foam::labelListList Foam::addPatchCellLayer::addedCells() const } +// Calculate global faces per pp edge. +Foam::labelListList Foam::addPatchCellLayer::globalEdgeFaces +( + const polyMesh& mesh, + const globalIndex& globalFaces, + const indirectPrimitivePatch& pp +) +{ + // Precalculate mesh edges for pp.edges. + const labelList meshEdges(pp.meshEdges(mesh.edges(), mesh.pointEdges())); + + // From mesh edge to global face labels. Non-empty sublists only for + // pp edges. + labelListList globalEdgeFaces(mesh.nEdges()); + + const labelListList& edgeFaces = pp.edgeFaces(); + + forAll(edgeFaces, edgeI) + { + label meshEdgeI = meshEdges[edgeI]; + + const labelList& eFaces = edgeFaces[edgeI]; + + // Store face and processor as unique tag. + labelList& globalEFaces = globalEdgeFaces[meshEdgeI]; + globalEFaces.setSize(eFaces.size()); + forAll(eFaces, i) + { + globalEFaces[i] = globalFaces.toGlobal(pp.addressing()[eFaces[i]]); + } + } + + // Synchronise across coupled edges. + syncTools::syncEdgeList + ( + mesh, + globalEdgeFaces, + uniqueEqOp(), + labelList() // null value + ); + + // Extract pp part + return labelListList(UIndirectList<labelList>(globalEdgeFaces, meshEdges)); +} + + +void Foam::addPatchCellLayer::calcSidePatch +( + const polyMesh& mesh, + const globalIndex& globalFaces, + const labelListList& globalEdgeFaces, + const indirectPrimitivePatch& pp, + + labelList& sidePatchID, + label& nPatches, + Map<label>& nbrProcToPatch, + Map<label>& patchToNbrProc +) +{ + const polyBoundaryMesh& patches = mesh.boundaryMesh(); + + // Precalculate mesh edges for pp.edges. + const labelList meshEdges(pp.meshEdges(mesh.edges(), mesh.pointEdges())); + + sidePatchID.setSize(pp.nEdges()); + sidePatchID = -1; + + // These also get determined but not (yet) exported: + // - whether face is created from other face or edge + // - what zone&orientation face should have + + labelList inflateEdgeI(pp.nEdges(), -1); + labelList inflateFaceI(pp.nEdges(), -1); + labelList sideZoneID(pp.nEdges(), -1); + boolList sideFlip(pp.nEdges(), false); + + nPatches = patches.size(); + + forAll(globalEdgeFaces, edgeI) + { + const labelList& eGlobalFaces = globalEdgeFaces[edgeI]; + if + ( + eGlobalFaces.size() == 2 + && pp.edgeFaces()[edgeI].size() == 1 + ) + { + // Locally but not globally a boundary edge. Hence a coupled + // edge. Find the patch to use if on different + // processors. + + label f0 = eGlobalFaces[0]; + label f1 = eGlobalFaces[1]; + + label otherProcI = -1; + if (globalFaces.isLocal(f0) && !globalFaces.isLocal(f1)) + { + otherProcI = globalFaces.whichProcID(f1); + } + else if (!globalFaces.isLocal(f0) && globalFaces.isLocal(f1)) + { + otherProcI = globalFaces.whichProcID(f0); + } + + + if (otherProcI != -1) + { + sidePatchID[edgeI] = findProcPatch(mesh, otherProcI); + if (sidePatchID[edgeI] == -1) + { + // Cannot find a patch to processor. See if already + // marked for addition + if (nbrProcToPatch.found(otherProcI)) + { + sidePatchID[edgeI] = nbrProcToPatch[otherProcI]; + } + else + { + sidePatchID[edgeI] = nPatches; + nbrProcToPatch.insert(otherProcI, nPatches); + patchToNbrProc.insert(nPatches, otherProcI); + nPatches++; + } + } + } + } + } + + + + // Determine face properties for all other boundary edges + // ------------------------------------------------------ + + const labelListList& edgeFaces = pp.edgeFaces(); + forAll(edgeFaces, edgeI) + { + if (edgeFaces[edgeI].size() == 1 && sidePatchID[edgeI] == -1) + { + // Proper, uncoupled patch edge. + + label myFaceI = pp.addressing()[edgeFaces[edgeI][0]]; + + // Pick up any boundary face on this edge and use its properties + label meshEdgeI = meshEdges[edgeI]; + const labelList& meshFaces = mesh.edgeFaces()[meshEdgeI]; + + forAll(meshFaces, k) + { + label faceI = meshFaces[k]; + + if (faceI != myFaceI && !mesh.isInternalFace(faceI)) + { + setFaceProps + ( + mesh, + faceI, + + sidePatchID[edgeI], + sideZoneID[edgeI], + sideFlip[edgeI] + ); + inflateFaceI[edgeI] = faceI; + inflateEdgeI[edgeI] = -1; + + break; + } + } + } + } + + + + // Now hopefully every boundary edge has a side patch. Check + forAll(edgeFaces, edgeI) + { + if (edgeFaces[edgeI].size() == 1 && sidePatchID[edgeI] == -1) + { + const edge& e = pp.edges()[edgeI]; + FatalErrorIn("addPatchCellLayer::calcSidePatch(..)") + << "Have no sidePatchID for edge " << edgeI << " points " + << pp.points()[pp.meshPoints()[e[0]]] + << pp.points()[pp.meshPoints()[e[1]]] + << abort(FatalError); + } + } + + + + // Now we have sidepatch see if we have patchface or edge to inflate + // from. + forAll(edgeFaces, edgeI) + { + if (edgeFaces[edgeI].size() == 1 && inflateFaceI[edgeI] == -1) + { + // 1. Do we have a boundary face to inflate from + + label myFaceI = pp.addressing()[edgeFaces[edgeI][0]]; + + // Pick up any boundary face on this edge and use its properties + label meshEdgeI = meshEdges[edgeI]; + const labelList& meshFaces = mesh.edgeFaces()[meshEdgeI]; + + forAll(meshFaces, k) + { + label faceI = meshFaces[k]; + + if (faceI != myFaceI) + { + if (mesh.isInternalFace(faceI)) + { + inflateEdgeI[edgeI] = meshEdgeI; + } + else + { + if (patches.whichPatch(faceI) == sidePatchID[edgeI]) + { + setFaceProps + ( + mesh, + faceI, + + sidePatchID[edgeI], + sideZoneID[edgeI], + sideFlip[edgeI] + ); + inflateFaceI[edgeI] = faceI; + inflateEdgeI[edgeI] = -1; + + break; + } + } + } + } + } + } +} + + void Foam::addPatchCellLayer::setRefinement ( + const globalIndex& globalFaces, + const labelListList& globalEdgeFaces, const scalarField& expansionRatio, const indirectPrimitivePatch& pp, + const labelList& sidePatchID, const labelList& exposedPatchID, const labelList& nFaceLayers, const labelList& nPointLayers, @@ -575,7 +795,7 @@ void Foam::addPatchCellLayer::setRefinement if (debug) { Pout<< "addPatchCellLayer::setRefinement : Adding up to " - << max(nPointLayers) + << gMax(nPointLayers) << " layers of cells to indirectPrimitivePatch with " << pp.nPoints() << " points" << endl; } @@ -788,8 +1008,6 @@ void Foam::addPatchCellLayer::setRefinement label meshEdgeI = meshEdges[edgeI]; - // Mesh faces using edge - // Mesh faces using edge const labelList& meshFaces = mesh_.edgeFaces(meshEdgeI, ef); @@ -1213,22 +1431,6 @@ void Foam::addPatchCellLayer::setRefinement } - // Global indices engine - const globalIndex globalFaces(mesh_.nFaces()); - - // Get for all pp edgeFaces a unique faceID - labelListList globalEdgeFaces - ( - calcGlobalEdgeFaces - ( - mesh_, - globalFaces, - pp, - meshEdges - ) - ); - - // Mark off which edges have been extruded boolList doneEdge(pp.nEdges(), false); @@ -1474,16 +1676,17 @@ void Foam::addPatchCellLayer::setRefinement addSideFace ( pp, - patchID, addedCells, - newFace, + + newFace, // vertices of new face + sidePatchID[startEdgeI],// -1 or patch for face + patchFaceI, nbrFaceI, - startEdgeI, // edge to inflate from - meshEdgeI, // corresponding mesh edge - i, - numEdgeSideFaces, - meshFaces, + meshEdgeI, // (mesh) edge to inflate + i, // layer + numEdgeSideFaces, // num layers + meshFaces, // edgeFaces meshMod ); } diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H index 4835ac68e39ef79ba61246ea7893e81f10ee3b24..2458de9fa45324aabf7252fa6fd9e3f17396263f 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H @@ -181,16 +181,6 @@ class addPatchCellLayer // Private Member Functions - //- Per patch edge the pp faces (in global indices) using it. Uses - // uniqueEqOp() to remove duplicates. - labelListList calcGlobalEdgeFaces - ( - const polyMesh& mesh, - const globalIndex& globalFaces, - const indirectPrimitivePatch& pp, - const labelList& meshEdges - ); - //- Get the face on the other side of the edge. static label nbrFace ( @@ -226,12 +216,13 @@ class addPatchCellLayer label addSideFace ( const indirectPrimitivePatch&, - const labelList& patchID, const labelListList& addedCells, + const face& newFace, + const label newPatchID, + const label ownFaceI, const label nbrFaceI, - const label patchEdgeI, const label meshEdgeI, const label layerI, const label numEdgeFaces, @@ -239,6 +230,18 @@ class addPatchCellLayer polyTopoChange& ) const; + //- Find patch to neighbouring processor + static label findProcPatch(const polyMesh&, const label nbrProcID); + + //- Extract properties from mesh face + static void setFaceProps + ( + const polyMesh&, + const label, + label&, + label&, + bool& + ); //- Disallow default bitwise copy construct addPatchCellLayer(const addPatchCellLayer&); @@ -256,7 +259,7 @@ public: // Constructors //- Construct from mesh. - addPatchCellLayer(const polyMesh& mesh, const bool addToMesh = true); + addPatchCellLayer(const polyMesh&, const bool addToMesh = true); // Member Functions @@ -291,6 +294,33 @@ public: // Edit + //- Per patch edge the pp faces (in global indices) using it. Uses + // uniqueEqOp() to remove duplicates. + static labelListList globalEdgeFaces + ( + const polyMesh&, + const globalIndex& globalFaces, + const indirectPrimitivePatch& pp + ); + + //- Boundary edges get extruded into boundary faces. Determine patch + // for these faces. This might be a to-be-created processor patch + // (patchI >= mesh.boundaryMesh().size()) in which case the + // nbrProcToPatch, patchToNbrProc give the correspondence. nPatches + // is the new number of patches. + static void calcSidePatch + ( + const polyMesh&, + const globalIndex& globalFaces, + const labelListList& globalEdgeFaces, + const indirectPrimitivePatch& pp, + + labelList& sidePatchID, + label& nPatches, + Map<label>& nbrProcToPatch, + Map<label>& patchToNbrProc + ); + //- Play commands into polyTopoChange to create layers on top // of indirectPrimitivePatch (have to be outside faces). // Gets displacement per patch point. @@ -313,8 +343,11 @@ public: // (instead of e.g. from patch faces) void setRefinement ( + const globalIndex& globalFaces, + const labelListList& globalEdgeFaces, const scalarField& expansionRatio, const indirectPrimitivePatch& pp, + const labelList& sidePatchID, const labelList& exposedPatchID, const labelList& nFaceLayers, const labelList& nPointLayers, @@ -326,20 +359,26 @@ public: //- Add with constant expansion ratio and same nLayers everywhere void setRefinement ( + const globalIndex& globalFaces, + const labelListList& globalEdgeFaces, const label nLayers, const indirectPrimitivePatch& pp, + const labelList& sidePatchID, const vectorField& overallDisplacement, polyTopoChange& meshMod ) { setRefinement ( - scalarField(pp.nPoints(), 1.0), // expansion ration + globalFaces, + globalEdgeFaces, + scalarField(pp.nPoints(), 1.0), // expansion ration pp, + sidePatchID, labelList(0), - labelList(pp.size(), nLayers), - labelList(pp.nPoints(), nLayers), - overallDisplacement / nLayers, + labelList(pp.size(), nLayers), // nFaceLayers + labelList(pp.nPoints(), nLayers), // nPointLayers + overallDisplacement / nLayers, // firstLayerDisp meshMod ); } diff --git a/src/edgeMesh/Make/files b/src/edgeMesh/Make/files index cdad2399991b81b82fda8df34d4d62a796a1363b..52f985de8cd7745f26ff798972dd1ba0fcc7ce5b 100644 --- a/src/edgeMesh/Make/files +++ b/src/edgeMesh/Make/files @@ -20,7 +20,10 @@ $(edgeFormats)/starcd/STARCDedgeFormatRunTime.C $(edgeFormats)/vtk/VTKedgeFormat.C $(edgeFormats)/vtk/VTKedgeFormatRunTime.C +extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.C + featureEdgeMesh/featureEdgeMesh.C + LIB = $(FOAM_LIBBIN)/libedgeMesh diff --git a/src/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.C b/src/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.C new file mode 100644 index 0000000000000000000000000000000000000000..c4f536e2092d725db61f84b03a368b1c5ac68a1c --- /dev/null +++ b/src/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.C @@ -0,0 +1,1028 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "extendedFeatureEdgeMesh.H" +#include "triSurface.H" +#include "Random.H" +#include "Time.H" +#include "meshTools.H" +#include "linePointRef.H" +#include "ListListOps.H" +#include "OFstream.H" +#include "IFstream.H" +#include "unitConversion.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(Foam::extendedFeatureEdgeMesh, 0); + +Foam::scalar Foam::extendedFeatureEdgeMesh::cosNormalAngleTol_ = + Foam::cos(degToRad(0.1)); + + +Foam::label Foam::extendedFeatureEdgeMesh::convexStart_ = 0; + + +Foam::label Foam::extendedFeatureEdgeMesh::externalStart_ = 0; + + +Foam::label Foam::extendedFeatureEdgeMesh::nPointTypes = 4; + + +Foam::label Foam::extendedFeatureEdgeMesh::nEdgeTypes = 5; + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh(const IOobject& io) +: + regIOobject(io), + edgeMesh(pointField(0), edgeList(0)), + concaveStart_(0), + mixedStart_(0), + nonFeatureStart_(0), + internalStart_(0), + flatStart_(0), + openStart_(0), + multipleStart_(0), + normals_(0), + edgeDirections_(0), + edgeNormals_(0), + featurePointNormals_(0), + regionEdges_(0), + edgeTree_(), + edgeTreesByType_() +{ + if + ( + io.readOpt() == IOobject::MUST_READ + || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED + || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) + ) + { + if (readOpt() == IOobject::MUST_READ_IF_MODIFIED) + { + WarningIn + ( + "extendedFeatureEdgeMesh::extendedFeatureEdgeMesh" + "(const IOobject&)" + ) << "Specified IOobject::MUST_READ_IF_MODIFIED but class" + << " does not support automatic rereading." + << endl; + } + + Istream& is = readStream(typeName); + + is >> *this + >> concaveStart_ + >> mixedStart_ + >> nonFeatureStart_ + >> internalStart_ + >> flatStart_ + >> openStart_ + >> multipleStart_ + >> normals_ + >> edgeNormals_ + >> featurePointNormals_ + >> regionEdges_; + + close(); + + { + // Calculate edgeDirections + + const edgeList& eds(edges()); + + const pointField& pts(points()); + + edgeDirections_.setSize(eds.size()); + + forAll(eds, eI) + { + edgeDirections_[eI] = eds[eI].vec(pts); + } + + edgeDirections_ /= mag(edgeDirections_); + } + } + + if (debug) + { + Pout<< "extendedFeatureEdgeMesh::extendedFeatureEdgeMesh :" + << " constructed from IOobject :" + << " points:" << points().size() + << " edges:" << edges().size() + << endl; + } +} + + +Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh +( + const IOobject& io, + const extendedFeatureEdgeMesh& fem +) +: + regIOobject(io), + edgeMesh(fem), + concaveStart_(fem.concaveStart()), + mixedStart_(fem.mixedStart()), + nonFeatureStart_(fem.nonFeatureStart()), + internalStart_(fem.internalStart()), + flatStart_(fem.flatStart()), + openStart_(fem.openStart()), + multipleStart_(fem.multipleStart()), + normals_(fem.normals()), + edgeDirections_(fem.edgeDirections()), + edgeNormals_(fem.edgeNormals()), + featurePointNormals_(fem.featurePointNormals()), + regionEdges_(fem.regionEdges()), + edgeTree_(), + edgeTreesByType_() +{} + + +Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh +( + const IOobject& io, + const Xfer<pointField>& pointLst, + const Xfer<edgeList>& edgeLst +) +: + regIOobject(io), + edgeMesh(pointLst, edgeLst), + concaveStart_(0), + mixedStart_(0), + nonFeatureStart_(0), + internalStart_(0), + flatStart_(0), + openStart_(0), + multipleStart_(0), + normals_(0), + edgeDirections_(0), + edgeNormals_(0), + featurePointNormals_(0), + regionEdges_(0), + edgeTree_(), + edgeTreesByType_() +{} + + +Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh +( + const surfaceFeatures& sFeat, + const objectRegistry& obr, + const fileName& sFeatFileName +) +: + regIOobject + ( + IOobject + ( + sFeatFileName, + obr.time().constant(), + "extendedFeatureEdgeMesh", + obr, + IOobject::NO_READ, + IOobject::NO_WRITE + ) + ), + edgeMesh(pointField(0), edgeList(0)), + concaveStart_(-1), + mixedStart_(-1), + nonFeatureStart_(-1), + internalStart_(-1), + flatStart_(-1), + openStart_(-1), + multipleStart_(-1), + normals_(0), + edgeDirections_(0), + edgeNormals_(0), + featurePointNormals_(0), + regionEdges_(0), + edgeTree_(), + edgeTreesByType_() +{ + // Extract and reorder the data from surfaceFeatures + + // References to the surfaceFeatures data + const triSurface& surf(sFeat.surface()); + const pointField& sFeatLocalPts(surf.localPoints()); + const edgeList& sFeatEds(surf.edges()); + + // Filling the extendedFeatureEdgeMesh with the raw geometrical data. + + label nFeatEds = sFeat.featureEdges().size(); + + DynamicList<point> tmpPts; + edgeList eds(nFeatEds); + DynamicList<vector> norms; + vectorField edgeDirections(nFeatEds); + labelListList edgeNormals(nFeatEds); + DynamicList<label> regionEdges; + + // Mapping between old and new indices, there is entry in the map for each + // of sFeatLocalPts, -1 means that this point hasn't been used (yet), >= 0 + // corresponds to the index + labelList pointMap(sFeatLocalPts.size(), -1); + + // Noting when the normal of a face has been used so not to duplicate + labelList faceMap(surf.size(), -1); + + // Collecting the status of edge for subsequent sorting + List<edgeStatus> edStatus(nFeatEds, NONE); + + forAll(sFeat.featurePoints(), i) + { + label sFPI = sFeat.featurePoints()[i]; + + tmpPts.append(sFeatLocalPts[sFPI]); + + pointMap[sFPI] = tmpPts.size() - 1; + } + + // All feature points have been added + nonFeatureStart_ = tmpPts.size(); + + forAll(sFeat.featureEdges(), i) + { + label sFEI = sFeat.featureEdges()[i]; + + const edge& fE(sFeatEds[sFEI]); + + // Check to see if the points have been already used + if (pointMap[fE.start()] == -1) + { + tmpPts.append(sFeatLocalPts[fE.start()]); + + pointMap[fE.start()] = tmpPts.size() - 1; + } + + eds[i].start() = pointMap[fE.start()]; + + if (pointMap[fE.end()] == -1) + { + tmpPts.append(sFeatLocalPts[fE.end()]); + + pointMap[fE.end()] = tmpPts.size() - 1; + } + + eds[i].end() = pointMap[fE.end()]; + + // Pick up the faces adjacent to the feature edge + const labelList& eFaces = surf.edgeFaces()[sFEI]; + + edgeNormals[i].setSize(eFaces.size()); + + forAll(eFaces, j) + { + label eFI = eFaces[j]; + + // Check to see if the points have been already used + if (faceMap[eFI] == -1) + { + norms.append(surf.faceNormals()[eFI]); + + faceMap[eFI] = norms.size() - 1; + } + + edgeNormals[i][j] = faceMap[eFI]; + } + + vector fC0tofC1(vector::zero); + + if (eFaces.size() == 2) + { + fC0tofC1 = + surf[eFaces[1]].centre(surf.points()) + - surf[eFaces[0]].centre(surf.points()); + } + + edStatus[i] = classifyEdge(norms, edgeNormals[i], fC0tofC1); + + edgeDirections[i] = fE.vec(sFeatLocalPts); + + if (i < sFeat.nRegionEdges()) + { + regionEdges.append(i); + } + } + + // Reorder the edges by classification + + List<DynamicList<label> > allEds(nEdgeTypes); + + DynamicList<label>& externalEds(allEds[0]); + DynamicList<label>& internalEds(allEds[1]); + DynamicList<label>& flatEds(allEds[2]); + DynamicList<label>& openEds(allEds[3]); + DynamicList<label>& multipleEds(allEds[4]); + + forAll(eds, i) + { + edgeStatus eStat = edStatus[i]; + + if (eStat == EXTERNAL) + { + externalEds.append(i); + } + else if (eStat == INTERNAL) + { + internalEds.append(i); + } + else if (eStat == FLAT) + { + flatEds.append(i); + } + else if (eStat == OPEN) + { + openEds.append(i); + } + else if (eStat == MULTIPLE) + { + multipleEds.append(i); + } + else if (eStat == NONE) + { + FatalErrorIn + ( + "Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh" + "(" + " const surfaceFeatures& sFeat," + " const objectRegistry& obr," + " const fileName& sFeatFileName" + ")" + ) + << nl << "classifyEdge returned NONE on edge " + << eds[i] + << ". There is a problem with definition of this edge." + << nl << abort(FatalError); + } + } + + internalStart_ = externalEds.size(); + flatStart_ = internalStart_ + internalEds.size(); + openStart_ = flatStart_ + flatEds.size(); + multipleStart_ = openStart_ + openEds.size(); + + labelList edMap + ( + ListListOps::combine<labelList> + ( + allEds, + accessOp<labelList>() + ) + ); + + edMap = invert(edMap.size(), edMap); + + inplaceReorder(edMap, eds); + inplaceReorder(edMap, edStatus); + inplaceReorder(edMap, edgeDirections); + inplaceReorder(edMap, edgeNormals); + inplaceRenumber(edMap, regionEdges); + + pointField pts(tmpPts); + + // Initialise the edgeMesh + edgeMesh::operator=(edgeMesh(pts, eds)); + + // Initialise sorted edge related data + edgeDirections_ = edgeDirections/mag(edgeDirections); + edgeNormals_ = edgeNormals; + regionEdges_ = regionEdges; + + // Normals are all now found and indirectly addressed, can also be stored + normals_ = vectorField(norms); + + // Reorder the feature points by classification + + List<DynamicList<label> > allPts(3); + + DynamicList<label>& convexPts(allPts[0]); + DynamicList<label>& concavePts(allPts[1]); + DynamicList<label>& mixedPts(allPts[2]); + + for (label i = 0; i < nonFeatureStart_; i++) + { + pointStatus ptStatus = classifyFeaturePoint(i); + + if (ptStatus == CONVEX) + { + convexPts.append(i); + } + else if (ptStatus == CONCAVE) + { + concavePts.append(i); + } + else if (ptStatus == MIXED) + { + mixedPts.append(i); + } + else if (ptStatus == NONFEATURE) + { + FatalErrorIn + ( + "Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh" + "(" + " const surfaceFeatures& sFeat," + " const objectRegistry& obr," + " const fileName& sFeatFileName" + ")" + ) + << nl << "classifyFeaturePoint returned NONFEATURE on point at " + << points()[i] + << ". There is a problem with definition of this feature point." + << nl << abort(FatalError); + } + } + + concaveStart_ = convexPts.size(); + mixedStart_ = concaveStart_ + concavePts.size(); + + labelList ftPtMap + ( + ListListOps::combine<labelList> + ( + allPts, + accessOp<labelList>() + ) + ); + + ftPtMap = invert(ftPtMap.size(), ftPtMap); + + // Creating the ptMap from the ftPtMap with identity values up to the size + // of pts to create an oldToNew map for inplaceReorder + + labelList ptMap(identity(pts.size())); + + forAll(ftPtMap, i) + { + ptMap[i] = ftPtMap[i]; + } + + inplaceReorder(ptMap, pts); + + forAll(eds, i) + { + inplaceRenumber(ptMap, eds[i]); + } + + // Reinitialise the edgeMesh with sorted feature points and + // renumbered edges + edgeMesh::operator=(edgeMesh(pts, eds)); + + // Generate the featurePointNormals + + labelListList featurePointNormals(nonFeatureStart_); + + for (label i = 0; i < nonFeatureStart_; i++) + { + DynamicList<label> tmpFtPtNorms; + + const labelList& ptEds = pointEdges()[i]; + + forAll(ptEds, j) + { + const labelList& ptEdNorms(edgeNormals[ptEds[j]]); + + forAll(ptEdNorms, k) + { + if (findIndex(tmpFtPtNorms, ptEdNorms[k]) == -1) + { + bool addNormal = true; + + // Check that the normal direction is unique at this feature + forAll(tmpFtPtNorms, q) + { + if + ( + (normals_[ptEdNorms[k]] & normals_[tmpFtPtNorms[q]]) + > cosNormalAngleTol_ + ) + { + // Parallel to an existing normal, do not add + addNormal = false; + + break; + } + } + + if (addNormal) + { + tmpFtPtNorms.append(ptEdNorms[k]); + } + } + } + } + + featurePointNormals[i] = tmpFtPtNorms; + } + + featurePointNormals_ = featurePointNormals; +} + + +Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh +( + const IOobject& io, + const pointField& pts, + const edgeList& eds, + label concaveStart, + label mixedStart, + label nonFeatureStart, + label internalStart, + label flatStart, + label openStart, + label multipleStart, + const vectorField& normals, + const vectorField& edgeDirections, + const labelListList& edgeNormals, + const labelListList& featurePointNormals, + const labelList& regionEdges +) +: + regIOobject(io), + edgeMesh(pts, eds), + concaveStart_(concaveStart), + mixedStart_(mixedStart), + nonFeatureStart_(nonFeatureStart), + internalStart_(internalStart), + flatStart_(flatStart), + openStart_(openStart), + multipleStart_(multipleStart), + normals_(normals), + edgeDirections_(edgeDirections), + edgeNormals_(edgeNormals), + featurePointNormals_(featurePointNormals), + regionEdges_(regionEdges), + edgeTree_(), + edgeTreesByType_() +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::extendedFeatureEdgeMesh::~extendedFeatureEdgeMesh() +{} + + +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +Foam::extendedFeatureEdgeMesh::pointStatus +Foam::extendedFeatureEdgeMesh::classifyFeaturePoint +( + label ptI +) const +{ + labelList ptEds(pointEdges()[ptI]); + + label nPtEds = ptEds.size(); + label nExternal = 0; + label nInternal = 0; + + if (nPtEds == 0) + { + // There are no edges attached to the point, this is a problem + return NONFEATURE; + } + + forAll(ptEds, i) + { + edgeStatus edStat = getEdgeStatus(ptEds[i]); + + if (edStat == EXTERNAL) + { + nExternal++; + } + else if (edStat == INTERNAL) + { + nInternal++; + } + } + + if (nExternal == nPtEds) + { + return CONVEX; + } + else if (nInternal == nPtEds) + { + return CONCAVE; + } + else + { + return MIXED; + } +} + + +Foam::extendedFeatureEdgeMesh::edgeStatus +Foam::extendedFeatureEdgeMesh::classifyEdge +( + const List<vector>& norms, + const labelList& edNorms, + const vector& fC0tofC1 +) const +{ + label nEdNorms = edNorms.size(); + + if (nEdNorms == 1) + { + return OPEN; + } + else if (nEdNorms == 2) + { + const vector n0(norms[edNorms[0]]); + const vector n1(norms[edNorms[1]]); + + if ((n0 & n1) > cosNormalAngleTol_) + { + return FLAT; + } + else if ((fC0tofC1 & n0) > 0.0) + { + return INTERNAL; + } + else + { + return EXTERNAL; + } + } + else if (nEdNorms > 2) + { + return MULTIPLE; + } + else + { + // There is a problem - the edge has no normals + return NONE; + } +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void Foam::extendedFeatureEdgeMesh::nearestFeatureEdge +( + const point& sample, + scalar searchDistSqr, + pointIndexHit& info +) const +{ + info = edgeTree().findNearest + ( + sample, + searchDistSqr + ); +} + + +void Foam::extendedFeatureEdgeMesh::nearestFeatureEdge +( + const pointField& samples, + const scalarField& searchDistSqr, + List<pointIndexHit>& info +) const +{ + info.setSize(samples.size()); + + forAll(samples, i) + { + nearestFeatureEdge + ( + samples[i], + searchDistSqr[i], + info[i] + ); + } +} + + +void Foam::extendedFeatureEdgeMesh::nearestFeatureEdgeByType +( + const point& sample, + const scalarField& searchDistSqr, + List<pointIndexHit>& info +) const +{ + const PtrList<indexedOctree<treeDataEdge> >& edgeTrees = edgeTreesByType(); + + info.setSize(edgeTrees.size()); + + labelList sliceStarts(edgeTrees.size()); + + sliceStarts[0] = externalStart_; + sliceStarts[1] = internalStart_; + sliceStarts[2] = flatStart_; + sliceStarts[3] = openStart_; + sliceStarts[4] = multipleStart_; + + forAll(edgeTrees, i) + { + info[i] = edgeTrees[i].findNearest + ( + sample, + searchDistSqr[i] + ); + + // The index returned by the indexedOctree is local to the slice of + // edges it was supplied with, return the index to the value in the + // complete edge list + + info[i].setIndex(info[i].index() + sliceStarts[i]); + } +} + + +const Foam::indexedOctree<Foam::treeDataEdge>& +Foam::extendedFeatureEdgeMesh::edgeTree() const +{ + if (edgeTree_.empty()) + { + Random rndGen(17301893); + + // Slightly extended bb. Slightly off-centred just so on symmetric + // geometry there are less face/edge aligned items. + treeBoundBox bb + ( + treeBoundBox(points()).extend(rndGen, 1E-4) + ); + + bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + + labelList allEdges(identity(edges().size())); + + edgeTree_.reset + ( + new indexedOctree<treeDataEdge> + ( + treeDataEdge + ( + false, // cachebb + edges(), // edges + points(), // points + allEdges // selected edges + ), + bb, // bb + 8, // maxLevel + 10, // leafsize + 3.0 // duplicity + ) + ); + } + + return edgeTree_(); +} + + +const Foam::PtrList<Foam::indexedOctree<Foam::treeDataEdge> >& +Foam::extendedFeatureEdgeMesh::edgeTreesByType() const +{ + if (edgeTreesByType_.size() == 0) + { + edgeTreesByType_.setSize(nEdgeTypes); + + Random rndGen(872141); + + // Slightly extended bb. Slightly off-centred just so on symmetric + // geometry there are less face/edge aligned items. + treeBoundBox bb + ( + treeBoundBox(points()).extend(rndGen, 1E-4) + ); + + bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + + labelListList sliceEdges(nEdgeTypes); + + // External edges + sliceEdges[0] = + identity(internalStart_ - externalStart_) + externalStart_; + + // Internal edges + sliceEdges[1] = identity(flatStart_ - internalStart_) + internalStart_; + + // Flat edges + sliceEdges[2] = identity(openStart_ - flatStart_) + flatStart_; + + // Open edges + sliceEdges[3] = identity(multipleStart_ - openStart_) + openStart_; + + // Multiple edges + sliceEdges[4] = + identity(edges().size() - multipleStart_) + multipleStart_; + + forAll(edgeTreesByType_, i) + { + edgeTreesByType_.set + ( + i, + new indexedOctree<treeDataEdge> + ( + treeDataEdge + ( + false, // cachebb + edges(), // edges + points(), // points + sliceEdges[i] // selected edges + ), + bb, // bb + 8, // maxLevel + 10, // leafsize + 3.0 // duplicity + ) + ); + } + } + + return edgeTreesByType_; +} + + +void Foam::extendedFeatureEdgeMesh::writeObj +( + const fileName& prefix +) const +{ + Pout<< nl << "Writing extendedFeatureEdgeMesh components to " << prefix + << endl; + + label verti = 0; + + edgeMesh::write(prefix + "_edgeMesh.obj"); + + OFstream convexFtPtStr(prefix + "_convexFeaturePts.obj"); + Pout<< "Writing convex feature points to " << convexFtPtStr.name() << endl; + + for(label i = 0; i < concaveStart_; i++) + { + meshTools::writeOBJ(convexFtPtStr, points()[i]); + } + + OFstream concaveFtPtStr(prefix + "_concaveFeaturePts.obj"); + Pout<< "Writing concave feature points to " + << concaveFtPtStr.name() << endl; + + for(label i = concaveStart_; i < mixedStart_; i++) + { + meshTools::writeOBJ(concaveFtPtStr, points()[i]); + } + + OFstream mixedFtPtStr(prefix + "_mixedFeaturePts.obj"); + Pout<< "Writing mixed feature points to " << mixedFtPtStr.name() << endl; + + for(label i = mixedStart_; i < nonFeatureStart_; i++) + { + meshTools::writeOBJ(mixedFtPtStr, points()[i]); + } + + OFstream mixedFtPtStructureStr(prefix + "_mixedFeaturePtsStructure.obj"); + Pout<< "Writing mixed feature point structure to " + << mixedFtPtStructureStr.name() << endl; + + verti = 0; + for(label i = mixedStart_; i < nonFeatureStart_; i++) + { + const labelList& ptEds = pointEdges()[i]; + + forAll(ptEds, j) + { + const edge& e = edges()[ptEds[j]]; + + meshTools::writeOBJ(mixedFtPtStructureStr, points()[e[0]]); verti++; + meshTools::writeOBJ(mixedFtPtStructureStr, points()[e[1]]); verti++; + mixedFtPtStructureStr << "l " << verti-1 << ' ' << verti << endl; + } + } + + OFstream externalStr(prefix + "_externalEdges.obj"); + Pout<< "Writing external edges to " << externalStr.name() << endl; + + verti = 0; + for (label i = externalStart_; i < internalStart_; i++) + { + const edge& e = edges()[i]; + + meshTools::writeOBJ(externalStr, points()[e[0]]); verti++; + meshTools::writeOBJ(externalStr, points()[e[1]]); verti++; + externalStr << "l " << verti-1 << ' ' << verti << endl; + } + + OFstream internalStr(prefix + "_internalEdges.obj"); + Pout<< "Writing internal edges to " << internalStr.name() << endl; + + verti = 0; + for (label i = internalStart_; i < flatStart_; i++) + { + const edge& e = edges()[i]; + + meshTools::writeOBJ(internalStr, points()[e[0]]); verti++; + meshTools::writeOBJ(internalStr, points()[e[1]]); verti++; + internalStr << "l " << verti-1 << ' ' << verti << endl; + } + + OFstream flatStr(prefix + "_flatEdges.obj"); + Pout<< "Writing flat edges to " << flatStr.name() << endl; + + verti = 0; + for (label i = flatStart_; i < openStart_; i++) + { + const edge& e = edges()[i]; + + meshTools::writeOBJ(flatStr, points()[e[0]]); verti++; + meshTools::writeOBJ(flatStr, points()[e[1]]); verti++; + flatStr << "l " << verti-1 << ' ' << verti << endl; + } + + OFstream openStr(prefix + "_openEdges.obj"); + Pout<< "Writing open edges to " << openStr.name() << endl; + + verti = 0; + for (label i = openStart_; i < multipleStart_; i++) + { + const edge& e = edges()[i]; + + meshTools::writeOBJ(openStr, points()[e[0]]); verti++; + meshTools::writeOBJ(openStr, points()[e[1]]); verti++; + openStr << "l " << verti-1 << ' ' << verti << endl; + } + + OFstream multipleStr(prefix + "_multipleEdges.obj"); + Pout<< "Writing multiple edges to " << multipleStr.name() << endl; + + verti = 0; + for (label i = multipleStart_; i < edges().size(); i++) + { + const edge& e = edges()[i]; + + meshTools::writeOBJ(multipleStr, points()[e[0]]); verti++; + meshTools::writeOBJ(multipleStr, points()[e[1]]); verti++; + multipleStr << "l " << verti-1 << ' ' << verti << endl; + } + + OFstream regionStr(prefix + "_regionEdges.obj"); + Pout<< "Writing region edges to " << regionStr.name() << endl; + + verti = 0; + forAll(regionEdges_, i) + { + const edge& e = edges()[regionEdges_[i]]; + + meshTools::writeOBJ(regionStr, points()[e[0]]); verti++; + meshTools::writeOBJ(regionStr, points()[e[1]]); verti++; + regionStr << "l " << verti-1 << ' ' << verti << endl; + } +} + + +bool Foam::extendedFeatureEdgeMesh::writeData(Ostream& os) const +{ + os << "// points, edges, concaveStart, mixedStart, nonFeatureStart, " << nl + << "// internalStart, flatStart, openStart, multipleStart, " << nl + << "// normals, edgeNormals, featurePointNormals, regionEdges" << nl + << endl; + + os << points() << nl + << edges() << nl + << concaveStart_ << token::SPACE + << mixedStart_ << token::SPACE + << nonFeatureStart_ << token::SPACE + << internalStart_ << token::SPACE + << flatStart_ << token::SPACE + << openStart_ << token::SPACE + << multipleStart_ << nl + << normals_ << nl + << edgeNormals_ << nl + << featurePointNormals_ << nl + << regionEdges_ + << endl; + + return os.good(); +} + + +// ************************************************************************* // diff --git a/src/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.H b/src/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.H new file mode 100644 index 0000000000000000000000000000000000000000..f1e85867d4530412fe49df70e4ebb519796a5e81 --- /dev/null +++ b/src/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.H @@ -0,0 +1,377 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::extendedFeatureEdgeMesh + +Description + + Description of feature edges and points. + + Feature points are a sorted subset at the start of the overall points list: + 0 .. concaveStart_-1 : convex points (w.r.t normals) + concaveStart_-1 .. mixedStart_-1 : concave points + mixedStart_ .. nonFeatureStart_ : mixed internal/external points + nonFeatureStart_ .. size-1 : non-feature points + + Feature edges are the edgeList of the edgeMesh and are sorted: + 0 .. internalStart_-1 : external edges (convex w.r.t normals) + internalStart_ .. flatStart_-1 : internal edges (concave) + flatStart_ .. openStart_-1 : flat edges (neither concave or convex) + can arise from region interfaces on + flat surfaces + openStart_ .. multipleStart_-1 : open edges (e.g. from baffle surfaces) + multipleStart_ .. size-1 : multiply connected edges + + The edge direction and feature edge and feature point adjacent normals + are stored. + +SourceFiles + extendedFeatureEdgeMeshI.H + extendedFeatureEdgeMesh.C + +\*---------------------------------------------------------------------------*/ + +#ifndef extendedFeatureEdgeMesh_H +#define extendedFeatureEdgeMesh_H + +#include "edgeMesh.H" +#include "surfaceFeatures.H" +#include "objectRegistry.H" +#include "IOdictionary.H" +#include "indexedOctree.H" +#include "treeDataEdge.H" +#include "pointIndexHit.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class extendedFeatureEdgeMesh Declaration +\*---------------------------------------------------------------------------*/ + +class extendedFeatureEdgeMesh +: + public regIOobject, + public edgeMesh +{ + +public: + + //- Runtime type information + TypeName("extendedFeatureEdgeMesh"); + + enum pointStatus + { + CONVEX, // Fully convex point (w.r.t normals) + CONCAVE, // Fully concave point + MIXED, // A point surrounded by both convex and concave edges + NONFEATURE // Not a feature point + }; + + enum edgeStatus + { + EXTERNAL, // "Convex" edge + INTERNAL, // "Concave" edge + FLAT, // Neither concave or convex, on a flat surface + OPEN, // i.e. only connected to one face + MULTIPLE, // Multiply connected (connected to more than two faces) + NONE // Not a classified feature edge (consistency with + // surfaceFeatures) + }; + +private: + + // Static data + + //- Angular closeness tolerance for treating normals as the same + static scalar cosNormalAngleTol_; + + //- Index of the start of the convex feature points - static as 0 + static label convexStart_; + + //- Index of the start of the external feature edges - static as 0 + static label externalStart_; + + + // Private data + + //- Index of the start of the concave feature points + label concaveStart_; + + //- Index of the start of the mixed type feature points + label mixedStart_; + + //- Index of the start of the non-feature points + label nonFeatureStart_; + + //- Index of the start of the internal feature edges + label internalStart_; + + //- Index of the start of the flat feature edges + label flatStart_; + + //- Index of the start of the open feature edges + label openStart_; + + //- Index of the start of the multiply-connected feature edges + label multipleStart_; + + //- Normals of the features, to be referred to by index by both feature + // points and edges, unsorted + vectorField normals_; + + //- Flat and open edges require the direction of the edge + vectorField edgeDirections_; + + //- Indices of the normals that are adjacent to the feature edges + labelListList edgeNormals_; + + //- Indices of the normals that are adjacent to the feature points + labelListList featurePointNormals_; + + //- Feature edges which are on the boundary between regions + labelList regionEdges_; + + //- Search tree for all edges + mutable autoPtr<indexedOctree<treeDataEdge> > edgeTree_; + + //- Individual search trees for each type of edge + mutable PtrList<indexedOctree<treeDataEdge> > edgeTreesByType_; + + + // Private Member Functions + + //- Classify the type of feature point. Requires valid stored member + // data for edges and normals. + pointStatus classifyFeaturePoint(label ptI) const; + + //- Classify the type of feature edge. Requires face centre 0 to face + // centre 1 vector to distinguish internal from external + edgeStatus classifyEdge + ( + const List<vector>& norms, + const labelList& edNorms, + const vector& fC0tofC1 + ) const; + + +public: + + // Static data + + //- Number of possible point types (i.e. number of slices) + static label nPointTypes; + + //- Number of possible feature edge types (i.e. number of slices) + static label nEdgeTypes; + + // Constructors + + //- Construct (read) given an IOobject + extendedFeatureEdgeMesh(const IOobject&); + + //- Construct as copy + explicit extendedFeatureEdgeMesh + ( + const IOobject&, + const extendedFeatureEdgeMesh& + ); + + //- Construct by transferring components (points, edges) + extendedFeatureEdgeMesh + ( + const IOobject&, + const Xfer<pointField>&, + const Xfer<edgeList>& + ); + + //- Construct (read) given surfaceFeatures, an objectRegistry and a + // fileName to write to. Extracts, classifies and reorders the data + // from surfaceFeatures. + extendedFeatureEdgeMesh + ( + const surfaceFeatures& sFeat, + const objectRegistry& obr, + const fileName& sFeatFileName + ); + + //- Construct from all components + extendedFeatureEdgeMesh + ( + const IOobject& io, + const pointField& pts, + const edgeList& eds, + label concaveStart, + label mixedStart, + label nonFeatureStart, + label internalStart, + label flatStart, + label openStart, + label multipleStart, + const vectorField& normals, + const vectorField& edgeDirections, + const labelListList& edgeNormals, + const labelListList& featurePointNormals, + const labelList& regionEdges + ); + + + //- Destructor + ~extendedFeatureEdgeMesh(); + + + // Member Functions + + // Find + + //- Find nearest surface edge for the sample point. + void nearestFeatureEdge + ( + const point& sample, + scalar searchDistSqr, + pointIndexHit& info + ) const; + + //- Find nearest surface edge for each sample point. + void nearestFeatureEdge + ( + const pointField& samples, + const scalarField& searchDistSqr, + List<pointIndexHit>& info + ) const; + + //- Find the nearest point on each type of feature edge + void nearestFeatureEdgeByType + ( + const point& sample, + const scalarField& searchDistSqr, + List<pointIndexHit>& info + ) const; + + // Access + + //- Return the index of the start of the convex feature points + inline label convexStart() const; + + //- Return the index of the start of the concave feature points + inline label concaveStart() const; + + //- Return the index of the start of the mixed type feature points + inline label mixedStart() const; + + //- Return the index of the start of the non-feature points + inline label nonFeatureStart() const; + + //- Return the index of the start of the external feature edges + inline label externalStart() const; + + //- Return the index of the start of the internal feature edges + inline label internalStart() const; + + //- Return the index of the start of the flat feature edges + inline label flatStart() const; + + //- Return the index of the start of the open feature edges + inline label openStart() const; + + //- Return the index of the start of the multiply-connected feature + // edges + inline label multipleStart() const; + + //- Return whether or not the point index is a feature point + inline bool featurePoint(label ptI) const; + + //- Return the normals of the surfaces adjacent to the feature edges + // and points + inline const vectorField& normals() const; + + //- Return the edgeDirection vectors + inline const vectorField& edgeDirections() const; + + //- Return the direction of edgeI, pointing away from ptI + inline vector edgeDirection(label edgeI, label ptI) const; + + //- Return the indices of the normals that are adjacent to the + // feature edges + inline const labelListList& edgeNormals() const; + + //- Return the normal vectors for a given set of normal indices + inline vectorField edgeNormals(const labelList& edgeNormIs) const; + + //- Return the normal vectors for a given edge + inline vectorField edgeNormals(label edgeI) const; + + //- Return the indices of the normals that are adjacent to the + // feature points + inline const labelListList& featurePointNormals() const; + + //- Return the normal vectors for a given feature point + inline vectorField featurePointNormals(label ptI) const; + + //- Return the feature edges which are on the boundary between + // regions + inline const labelList& regionEdges() const; + + //- Return the pointStatus of a specified point + inline pointStatus getPointStatus(label ptI) const; + + //- Return the edgeStatus of a specified edge + inline edgeStatus getEdgeStatus(label edgeI) const; + + //- Demand driven construction of octree for boundary edges + const indexedOctree<treeDataEdge>& edgeTree() const; + + //- Demand driven construction of octree for boundary edges by type + const PtrList<indexedOctree<treeDataEdge> >& + edgeTreesByType() const; + + + // Write + + //- Write all components of the extendedFeatureEdgeMesh as obj files + void writeObj(const fileName& prefix) const; + + //- Give precedence to the regIOobject write + using regIOobject::write; + + //- WriteData function required for regIOobject write operation + virtual bool writeData(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "extendedFeatureEdgeMeshI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/edgeMesh/featureEdgeMesh/featureEdgeMeshI.H b/src/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMeshI.H similarity index 66% rename from src/edgeMesh/featureEdgeMesh/featureEdgeMeshI.H rename to src/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMeshI.H index 6aac568b03cffc3dd8ffd2ca4bf3c634ed14a1b7..4feb72e6867bad53f7867a7d238d8dffe7b06b7f 100644 --- a/src/edgeMesh/featureEdgeMesh/featureEdgeMeshI.H +++ b/src/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMeshI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,78 +25,79 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -inline Foam::label Foam::featureEdgeMesh::convexStart() const +inline Foam::label Foam::extendedFeatureEdgeMesh::convexStart() const { return convexStart_; } -inline Foam::label Foam::featureEdgeMesh::concaveStart() const +inline Foam::label Foam::extendedFeatureEdgeMesh::concaveStart() const { return concaveStart_; } -inline Foam::label Foam::featureEdgeMesh::mixedStart() const +inline Foam::label Foam::extendedFeatureEdgeMesh::mixedStart() const { return mixedStart_; } -inline Foam::label Foam::featureEdgeMesh::nonFeatureStart() const +inline Foam::label Foam::extendedFeatureEdgeMesh::nonFeatureStart() const { return nonFeatureStart_; } -inline Foam::label Foam::featureEdgeMesh::externalStart() const +inline Foam::label Foam::extendedFeatureEdgeMesh::externalStart() const { return externalStart_; } -inline Foam::label Foam::featureEdgeMesh::internalStart() const +inline Foam::label Foam::extendedFeatureEdgeMesh::internalStart() const { return internalStart_; } -inline Foam::label Foam::featureEdgeMesh::flatStart() const +inline Foam::label Foam::extendedFeatureEdgeMesh::flatStart() const { return flatStart_; } -inline Foam::label Foam::featureEdgeMesh::openStart() const +inline Foam::label Foam::extendedFeatureEdgeMesh::openStart() const { return openStart_; } -inline Foam::label Foam::featureEdgeMesh::multipleStart() const +inline Foam::label Foam::extendedFeatureEdgeMesh::multipleStart() const { return multipleStart_; } -inline bool Foam::featureEdgeMesh::featurePoint(label ptI) const +inline bool Foam::extendedFeatureEdgeMesh::featurePoint(label ptI) const { return ptI < nonFeatureStart_; } -inline const Foam::vectorField& Foam::featureEdgeMesh::normals() const +inline const Foam::vectorField& Foam::extendedFeatureEdgeMesh::normals() const { return normals_; } -inline const Foam::vectorField& Foam::featureEdgeMesh::edgeDirections() const +inline const Foam::vectorField& Foam::extendedFeatureEdgeMesh::edgeDirections() +const { return edgeDirections_; } -inline Foam::vector Foam::featureEdgeMesh::edgeDirection +inline Foam::vector Foam::extendedFeatureEdgeMesh::edgeDirection ( label edgeI, label ptI @@ -114,7 +115,7 @@ inline Foam::vector Foam::featureEdgeMesh::edgeDirection } else { - FatalErrorIn("Foam::featureEdgeMesh::edgedirection") + FatalErrorIn("Foam::extendedFeatureEdgeMesh::edgedirection") << "Requested ptI " << ptI << " is not a point on the requested " << "edgeI " << edgeI << ". edgeI start and end: " << e.start() << " " << e.end() @@ -125,13 +126,14 @@ inline Foam::vector Foam::featureEdgeMesh::edgeDirection } -inline const Foam::labelListList& Foam::featureEdgeMesh::edgeNormals() const +inline const Foam::labelListList& Foam::extendedFeatureEdgeMesh::edgeNormals() +const { return edgeNormals_; } -inline Foam::vectorField Foam::featureEdgeMesh::edgeNormals +inline Foam::vectorField Foam::extendedFeatureEdgeMesh::edgeNormals ( const labelList& edgeNormIs ) const @@ -147,27 +149,28 @@ inline Foam::vectorField Foam::featureEdgeMesh::edgeNormals } -inline Foam::vectorField Foam::featureEdgeMesh::edgeNormals(label edgeI) const +inline Foam::vectorField Foam::extendedFeatureEdgeMesh::edgeNormals(label edgeI) +const { return edgeNormals(edgeNormals_[edgeI]); } inline const Foam::labelListList& -Foam::featureEdgeMesh::featurePointNormals() const +Foam::extendedFeatureEdgeMesh::featurePointNormals() const { return featurePointNormals_; } -inline Foam::vectorField Foam::featureEdgeMesh::featurePointNormals +inline Foam::vectorField Foam::extendedFeatureEdgeMesh::featurePointNormals ( label ptI ) const { if (!featurePoint(ptI)) { - WarningIn("vectorField featureEdgeMesh::featurePointNormals") + WarningIn("vectorField extendedFeatureEdgeMesh::featurePointNormals") << "Requesting the normals of a non-feature point. " << "Returned zero length vectorField." << endl; @@ -188,13 +191,14 @@ inline Foam::vectorField Foam::featureEdgeMesh::featurePointNormals } -inline const Foam::labelList& Foam::featureEdgeMesh::regionEdges() const +inline const Foam::labelList& Foam::extendedFeatureEdgeMesh::regionEdges() const { return regionEdges_; } -inline Foam::featureEdgeMesh::pointStatus Foam::featureEdgeMesh::getPointStatus +inline Foam::extendedFeatureEdgeMesh::pointStatus +Foam::extendedFeatureEdgeMesh::getPointStatus ( label ptI ) const @@ -218,7 +222,8 @@ inline Foam::featureEdgeMesh::pointStatus Foam::featureEdgeMesh::getPointStatus } -inline Foam::featureEdgeMesh::edgeStatus Foam::featureEdgeMesh::getEdgeStatus +inline Foam::extendedFeatureEdgeMesh::edgeStatus +Foam::extendedFeatureEdgeMesh::getEdgeStatus ( label edgeI ) const diff --git a/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.C b/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.C index 78ee016cfd7be0c4be6beec6177d12b5660f346a..5b3cea13f43a93b1376578454820c011f06d1ff9 100644 --- a/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.C +++ b/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,34 +24,15 @@ License \*---------------------------------------------------------------------------*/ #include "featureEdgeMesh.H" -#include "triSurface.H" -#include "Random.H" -#include "Time.H" -#include "meshTools.H" -#include "linePointRef.H" -#include "ListListOps.H" -#include "OFstream.H" -#include "IFstream.H" -#include "unitConversion.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -defineTypeNameAndDebug(Foam::featureEdgeMesh, 0); - -Foam::scalar Foam::featureEdgeMesh::cosNormalAngleTol_ = - Foam::cos(degToRad(0.1)); - - -Foam::label Foam::featureEdgeMesh::convexStart_ = 0; - - -Foam::label Foam::featureEdgeMesh::externalStart_ = 0; - - -Foam::label Foam::featureEdgeMesh::nPointTypes = 4; +namespace Foam +{ +defineTypeNameAndDebug(featureEdgeMesh, 0); -Foam::label Foam::featureEdgeMesh::nEdgeTypes = 5; +} // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -59,21 +40,7 @@ Foam::label Foam::featureEdgeMesh::nEdgeTypes = 5; Foam::featureEdgeMesh::featureEdgeMesh(const IOobject& io) : regIOobject(io), - edgeMesh(pointField(0), edgeList(0)), - concaveStart_(0), - mixedStart_(0), - nonFeatureStart_(0), - internalStart_(0), - flatStart_(0), - openStart_(0), - multipleStart_(0), - normals_(0), - edgeDirections_(0), - edgeNormals_(0), - featurePointNormals_(0), - regionEdges_(0), - edgeTree_(), - edgeTreesByType_() + edgeMesh(pointField(0), edgeList(0)) { if ( @@ -82,47 +49,8 @@ Foam::featureEdgeMesh::featureEdgeMesh(const IOobject& io) || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) ) { - if (readOpt() == IOobject::MUST_READ_IF_MODIFIED) - { - WarningIn("featureEdgeMesh::featureEdgeMesh(const IOobject&)") - << "Specified IOobject::MUST_READ_IF_MODIFIED but class" - << " does not support automatic rereading." - << endl; - } - - Istream& is = readStream(typeName); - - is >> *this - >> concaveStart_ - >> mixedStart_ - >> nonFeatureStart_ - >> internalStart_ - >> flatStart_ - >> openStart_ - >> multipleStart_ - >> normals_ - >> edgeNormals_ - >> featurePointNormals_ - >> regionEdges_; - + readStream(typeName) >> *this; close(); - - { - // Calculate edgeDirections - - const edgeList& eds(edges()); - - const pointField& pts(points()); - - edgeDirections_.setSize(eds.size()); - - forAll(eds, eI) - { - edgeDirections_[eI] = eds[eI].vec(pts); - } - - edgeDirections_ /= mag(edgeDirections_); - } } if (debug) @@ -136,884 +64,43 @@ Foam::featureEdgeMesh::featureEdgeMesh(const IOobject& io) } +//- Construct from components Foam::featureEdgeMesh::featureEdgeMesh ( const IOobject& io, - const featureEdgeMesh& fem + const pointField& points, + const edgeList& edges ) : regIOobject(io), - edgeMesh(fem), - concaveStart_(fem.concaveStart()), - mixedStart_(fem.mixedStart()), - nonFeatureStart_(fem.nonFeatureStart()), - internalStart_(fem.internalStart()), - flatStart_(fem.flatStart()), - openStart_(fem.openStart()), - multipleStart_(fem.multipleStart()), - normals_(fem.normals()), - edgeDirections_(fem.edgeDirections()), - edgeNormals_(fem.edgeNormals()), - featurePointNormals_(fem.featurePointNormals()), - regionEdges_(fem.regionEdges()), - edgeTree_(), - edgeTreesByType_() + edgeMesh(points, edges) {} +// Construct as copy Foam::featureEdgeMesh::featureEdgeMesh ( const IOobject& io, - const Xfer<pointField>& pointLst, - const Xfer<edgeList>& edgeLst -) -: - regIOobject(io), - edgeMesh(pointLst, edgeLst), - concaveStart_(0), - mixedStart_(0), - nonFeatureStart_(0), - internalStart_(0), - flatStart_(0), - openStart_(0), - multipleStart_(0), - normals_(0), - edgeDirections_(0), - edgeNormals_(0), - featurePointNormals_(0), - regionEdges_(0), - edgeTree_(), - edgeTreesByType_() -{} - - -Foam::featureEdgeMesh::featureEdgeMesh -( - const surfaceFeatures& sFeat, - const objectRegistry& obr, - const fileName& sFeatFileName -) -: - regIOobject - ( - IOobject - ( - sFeatFileName, - obr.time().constant(), - "featureEdgeMesh", - obr, - IOobject::NO_READ, - IOobject::NO_WRITE - ) - ), - edgeMesh(pointField(0), edgeList(0)), - concaveStart_(-1), - mixedStart_(-1), - nonFeatureStart_(-1), - internalStart_(-1), - flatStart_(-1), - openStart_(-1), - multipleStart_(-1), - normals_(0), - edgeDirections_(0), - edgeNormals_(0), - featurePointNormals_(0), - regionEdges_(0), - edgeTree_(), - edgeTreesByType_() -{ - // Extract and reorder the data from surfaceFeatures - - // References to the surfaceFeatures data - const triSurface& surf(sFeat.surface()); - const pointField& sFeatLocalPts(surf.localPoints()); - const edgeList& sFeatEds(surf.edges()); - - // Filling the featureEdgeMesh with the raw geometrical data. - - label nFeatEds = sFeat.featureEdges().size(); - - DynamicList<point> tmpPts; - edgeList eds(nFeatEds); - DynamicList<vector> norms; - vectorField edgeDirections(nFeatEds); - labelListList edgeNormals(nFeatEds); - DynamicList<label> regionEdges; - - // Mapping between old and new indices, there is entry in the map for each - // of sFeatLocalPts, -1 means that this point hasn't been used (yet), >= 0 - // corresponds to the index - labelList pointMap(sFeatLocalPts.size(), -1); - - // Noting when the normal of a face has been used so not to duplicate - labelList faceMap(surf.size(), -1); - - // Collecting the status of edge for subsequent sorting - List<edgeStatus> edStatus(nFeatEds, NONE); - - forAll(sFeat.featurePoints(), i) - { - label sFPI = sFeat.featurePoints()[i]; - - tmpPts.append(sFeatLocalPts[sFPI]); - - pointMap[sFPI] = tmpPts.size() - 1; - } - - // All feature points have been added - nonFeatureStart_ = tmpPts.size(); - - forAll(sFeat.featureEdges(), i) - { - label sFEI = sFeat.featureEdges()[i]; - - const edge& fE(sFeatEds[sFEI]); - - // Check to see if the points have been already used - if (pointMap[fE.start()] == -1) - { - tmpPts.append(sFeatLocalPts[fE.start()]); - - pointMap[fE.start()] = tmpPts.size() - 1; - } - - eds[i].start() = pointMap[fE.start()]; - - if (pointMap[fE.end()] == -1) - { - tmpPts.append(sFeatLocalPts[fE.end()]); - - pointMap[fE.end()] = tmpPts.size() - 1; - } - - eds[i].end() = pointMap[fE.end()]; - - // Pick up the faces adjacent to the feature edge - const labelList& eFaces = surf.edgeFaces()[sFEI]; - - edgeNormals[i].setSize(eFaces.size()); - - forAll(eFaces, j) - { - label eFI = eFaces[j]; - - // Check to see if the points have been already used - if (faceMap[eFI] == -1) - { - norms.append(surf.faceNormals()[eFI]); - - faceMap[eFI] = norms.size() - 1; - } - - edgeNormals[i][j] = faceMap[eFI]; - } - - vector fC0tofC1(vector::zero); - - if (eFaces.size() == 2) - { - fC0tofC1 = - surf[eFaces[1]].centre(surf.points()) - - surf[eFaces[0]].centre(surf.points()); - } - - edStatus[i] = classifyEdge(norms, edgeNormals[i], fC0tofC1); - - edgeDirections[i] = fE.vec(sFeatLocalPts); - - if (i < sFeat.nRegionEdges()) - { - regionEdges.append(i); - } - } - - // Reorder the edges by classification - - List<DynamicList<label> > allEds(nEdgeTypes); - - DynamicList<label>& externalEds(allEds[0]); - DynamicList<label>& internalEds(allEds[1]); - DynamicList<label>& flatEds(allEds[2]); - DynamicList<label>& openEds(allEds[3]); - DynamicList<label>& multipleEds(allEds[4]); - - forAll(eds, i) - { - edgeStatus eStat = edStatus[i]; - - if (eStat == EXTERNAL) - { - externalEds.append(i); - } - else if (eStat == INTERNAL) - { - internalEds.append(i); - } - else if (eStat == FLAT) - { - flatEds.append(i); - } - else if (eStat == OPEN) - { - openEds.append(i); - } - else if (eStat == MULTIPLE) - { - multipleEds.append(i); - } - else if (eStat == NONE) - { - FatalErrorIn - ( - "Foam::featureEdgeMesh::featureEdgeMesh" - "(" - " const surfaceFeatures& sFeat," - " const objectRegistry& obr," - " const fileName& sFeatFileName" - ")" - ) - << nl << "classifyEdge returned NONE on edge " - << eds[i] - << ". There is a problem with definition of this edge." - << nl << abort(FatalError); - } - } - - internalStart_ = externalEds.size(); - flatStart_ = internalStart_ + internalEds.size(); - openStart_ = flatStart_ + flatEds.size(); - multipleStart_ = openStart_ + openEds.size(); - - labelList edMap - ( - ListListOps::combine<labelList> - ( - allEds, - accessOp<labelList>() - ) - ); - - edMap = invert(edMap.size(), edMap); - - inplaceReorder(edMap, eds); - inplaceReorder(edMap, edStatus); - inplaceReorder(edMap, edgeDirections); - inplaceReorder(edMap, edgeNormals); - inplaceRenumber(edMap, regionEdges); - - pointField pts(tmpPts); - - // Initialise the edgeMesh - edgeMesh::operator=(edgeMesh(pts, eds)); - - // Initialise sorted edge related data - edgeDirections_ = edgeDirections/mag(edgeDirections); - edgeNormals_ = edgeNormals; - regionEdges_ = regionEdges; - - // Normals are all now found and indirectly addressed, can also be stored - normals_ = vectorField(norms); - - // Reorder the feature points by classification - - List<DynamicList<label> > allPts(3); - - DynamicList<label>& convexPts(allPts[0]); - DynamicList<label>& concavePts(allPts[1]); - DynamicList<label>& mixedPts(allPts[2]); - - for (label i = 0; i < nonFeatureStart_; i++) - { - pointStatus ptStatus = classifyFeaturePoint(i); - - if (ptStatus == CONVEX) - { - convexPts.append(i); - } - else if (ptStatus == CONCAVE) - { - concavePts.append(i); - } - else if (ptStatus == MIXED) - { - mixedPts.append(i); - } - else if (ptStatus == NONFEATURE) - { - FatalErrorIn - ( - "Foam::featureEdgeMesh::featureEdgeMesh" - "(" - " const surfaceFeatures& sFeat," - " const objectRegistry& obr," - " const fileName& sFeatFileName" - ")" - ) - << nl << "classifyFeaturePoint returned NONFEATURE on point at " - << points()[i] - << ". There is a problem with definition of this feature point." - << nl << abort(FatalError); - } - } - - concaveStart_ = convexPts.size(); - mixedStart_ = concaveStart_ + concavePts.size(); - - labelList ftPtMap - ( - ListListOps::combine<labelList> - ( - allPts, - accessOp<labelList>() - ) - ); - - ftPtMap = invert(ftPtMap.size(), ftPtMap); - - // Creating the ptMap from the ftPtMap with identity values up to the size - // of pts to create an oldToNew map for inplaceReorder - - labelList ptMap(identity(pts.size())); - - forAll(ftPtMap, i) - { - ptMap[i] = ftPtMap[i]; - } - - inplaceReorder(ptMap, pts); - - forAll(eds, i) - { - inplaceRenumber(ptMap, eds[i]); - } - - // Reinitialise the edgeMesh with sorted feature points and - // renumbered edges - edgeMesh::operator=(edgeMesh(pts, eds)); - - // Generate the featurePointNormals - - labelListList featurePointNormals(nonFeatureStart_); - - for (label i = 0; i < nonFeatureStart_; i++) - { - DynamicList<label> tmpFtPtNorms; - - const labelList& ptEds = pointEdges()[i]; - - forAll(ptEds, j) - { - const labelList& ptEdNorms(edgeNormals[ptEds[j]]); - - forAll(ptEdNorms, k) - { - if (findIndex(tmpFtPtNorms, ptEdNorms[k]) == -1) - { - bool addNormal = true; - - // Check that the normal direction is unique at this feature - forAll(tmpFtPtNorms, q) - { - if - ( - (normals_[ptEdNorms[k]] & normals_[tmpFtPtNorms[q]]) - > cosNormalAngleTol_ - ) - { - // Parallel to an existing normal, do not add - addNormal = false; - - break; - } - } - - if (addNormal) - { - tmpFtPtNorms.append(ptEdNorms[k]); - } - } - } - } - - featurePointNormals[i] = tmpFtPtNorms; - } - - featurePointNormals_ = featurePointNormals; -} - - -Foam::featureEdgeMesh::featureEdgeMesh -( - const IOobject& io, - const pointField& pts, - const edgeList& eds, - label concaveStart, - label mixedStart, - label nonFeatureStart, - label internalStart, - label flatStart, - label openStart, - label multipleStart, - const vectorField& normals, - const vectorField& edgeDirections, - const labelListList& edgeNormals, - const labelListList& featurePointNormals, - const labelList& regionEdges + const featureEdgeMesh& em ) : regIOobject(io), - edgeMesh(pts, eds), - concaveStart_(concaveStart), - mixedStart_(mixedStart), - nonFeatureStart_(nonFeatureStart), - internalStart_(internalStart), - flatStart_(flatStart), - openStart_(openStart), - multipleStart_(multipleStart), - normals_(normals), - edgeDirections_(edgeDirections), - edgeNormals_(edgeNormals), - featurePointNormals_(featurePointNormals), - regionEdges_(regionEdges), - edgeTree_(), - edgeTreesByType_() -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::featureEdgeMesh::~featureEdgeMesh() + edgeMesh(em) {} -// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::featureEdgeMesh::pointStatus Foam::featureEdgeMesh::classifyFeaturePoint -( - label ptI -) const +bool Foam::featureEdgeMesh::readData(Istream& is) { - labelList ptEds(pointEdges()[ptI]); - - label nPtEds = ptEds.size(); - label nExternal = 0; - label nInternal = 0; - - if (nPtEds == 0) - { - // There are no edges attached to the point, this is a problem - return NONFEATURE; - } - - forAll(ptEds, i) - { - edgeStatus edStat = getEdgeStatus(ptEds[i]); - - if (edStat == EXTERNAL) - { - nExternal++; - } - else if (edStat == INTERNAL) - { - nInternal++; - } - } - - if (nExternal == nPtEds) - { - return CONVEX; - } - else if (nInternal == nPtEds) - { - return CONCAVE; - } - else - { - return MIXED; - } -} - - -Foam::featureEdgeMesh::edgeStatus Foam::featureEdgeMesh::classifyEdge -( - const List<vector>& norms, - const labelList& edNorms, - const vector& fC0tofC1 -) const -{ - label nEdNorms = edNorms.size(); - - if (nEdNorms == 1) - { - return OPEN; - } - else if (nEdNorms == 2) - { - const vector n0(norms[edNorms[0]]); - const vector n1(norms[edNorms[1]]); - - if ((n0 & n1) > cosNormalAngleTol_) - { - return FLAT; - } - else if ((fC0tofC1 & n0) > 0.0) - { - return INTERNAL; - } - else - { - return EXTERNAL; - } - } - else if (nEdNorms > 2) - { - return MULTIPLE; - } - else - { - // There is a problem - the edge has no normals - return NONE; - } -} - - -// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // - -void Foam::featureEdgeMesh::nearestFeatureEdge -( - const point& sample, - scalar searchDistSqr, - pointIndexHit& info -) const -{ - info = edgeTree().findNearest - ( - sample, - searchDistSqr - ); -} - - -void Foam::featureEdgeMesh::nearestFeatureEdge -( - const pointField& samples, - const scalarField& searchDistSqr, - List<pointIndexHit>& info -) const -{ - info.setSize(samples.size()); - - forAll(samples, i) - { - nearestFeatureEdge - ( - samples[i], - searchDistSqr[i], - info[i] - ); - } -} - - -void Foam::featureEdgeMesh::nearestFeatureEdgeByType -( - const point& sample, - const scalarField& searchDistSqr, - List<pointIndexHit>& info -) const -{ - const PtrList<indexedOctree<treeDataEdge> >& edgeTrees = edgeTreesByType(); - - info.setSize(edgeTrees.size()); - - labelList sliceStarts(edgeTrees.size()); - - sliceStarts[0] = externalStart_; - sliceStarts[1] = internalStart_; - sliceStarts[2] = flatStart_; - sliceStarts[3] = openStart_; - sliceStarts[4] = multipleStart_; - - forAll(edgeTrees, i) - { - info[i] = edgeTrees[i].findNearest - ( - sample, - searchDistSqr[i] - ); - - // The index returned by the indexedOctree is local to the slice of - // edges it was supplied with, return the index to the value in the - // complete edge list - - info[i].setIndex(info[i].index() + sliceStarts[i]); - } -} - - -const Foam::indexedOctree<Foam::treeDataEdge>& -Foam::featureEdgeMesh::edgeTree() const -{ - if (edgeTree_.empty()) - { - Random rndGen(17301893); - - // Slightly extended bb. Slightly off-centred just so on symmetric - // geometry there are less face/edge aligned items. - treeBoundBox bb - ( - treeBoundBox(points()).extend(rndGen, 1E-4) - ); - - bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - - labelList allEdges(identity(edges().size())); - - edgeTree_.reset - ( - new indexedOctree<treeDataEdge> - ( - treeDataEdge - ( - false, // cachebb - edges(), // edges - points(), // points - allEdges // selected edges - ), - bb, // bb - 8, // maxLevel - 10, // leafsize - 3.0 // duplicity - ) - ); - } - - return edgeTree_(); -} - - -const Foam::PtrList<Foam::indexedOctree<Foam::treeDataEdge> >& -Foam::featureEdgeMesh::edgeTreesByType() const -{ - if (edgeTreesByType_.size() == 0) - { - edgeTreesByType_.setSize(nEdgeTypes); - - Random rndGen(872141); - - // Slightly extended bb. Slightly off-centred just so on symmetric - // geometry there are less face/edge aligned items. - treeBoundBox bb - ( - treeBoundBox(points()).extend(rndGen, 1E-4) - ); - - bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - - labelListList sliceEdges(nEdgeTypes); - - // External edges - sliceEdges[0] = - identity(internalStart_ - externalStart_) + externalStart_; - - // Internal edges - sliceEdges[1] = identity(flatStart_ - internalStart_) + internalStart_; - - // Flat edges - sliceEdges[2] = identity(openStart_ - flatStart_) + flatStart_; - - // Open edges - sliceEdges[3] = identity(multipleStart_ - openStart_) + openStart_; - - // Multiple edges - sliceEdges[4] = - identity(edges().size() - multipleStart_) + multipleStart_; - - forAll(edgeTreesByType_, i) - { - edgeTreesByType_.set - ( - i, - new indexedOctree<treeDataEdge> - ( - treeDataEdge - ( - false, // cachebb - edges(), // edges - points(), // points - sliceEdges[i] // selected edges - ), - bb, // bb - 8, // maxLevel - 10, // leafsize - 3.0 // duplicity - ) - ); - } - } - - return edgeTreesByType_; -} - - -void Foam::featureEdgeMesh::writeObj -( - const fileName& prefix -) const -{ - Pout<< nl << "Writing featureEdgeMesh components to " << prefix << endl; - - label verti = 0; - - edgeMesh::write(prefix + "_edgeMesh.obj"); - - OFstream convexFtPtStr(prefix + "_convexFeaturePts.obj"); - Pout<< "Writing convex feature points to " << convexFtPtStr.name() << endl; - - for(label i = 0; i < concaveStart_; i++) - { - meshTools::writeOBJ(convexFtPtStr, points()[i]); - } - - OFstream concaveFtPtStr(prefix + "_concaveFeaturePts.obj"); - Pout<< "Writing concave feature points to " - << concaveFtPtStr.name() << endl; - - for(label i = concaveStart_; i < mixedStart_; i++) - { - meshTools::writeOBJ(concaveFtPtStr, points()[i]); - } - - OFstream mixedFtPtStr(prefix + "_mixedFeaturePts.obj"); - Pout<< "Writing mixed feature points to " << mixedFtPtStr.name() << endl; - - for(label i = mixedStart_; i < nonFeatureStart_; i++) - { - meshTools::writeOBJ(mixedFtPtStr, points()[i]); - } - - OFstream mixedFtPtStructureStr(prefix + "_mixedFeaturePtsStructure.obj"); - Pout<< "Writing mixed feature point structure to " - << mixedFtPtStructureStr.name() << endl; - - verti = 0; - for(label i = mixedStart_; i < nonFeatureStart_; i++) - { - const labelList& ptEds = pointEdges()[i]; - - forAll(ptEds, j) - { - const edge& e = edges()[ptEds[j]]; - - meshTools::writeOBJ(mixedFtPtStructureStr, points()[e[0]]); verti++; - meshTools::writeOBJ(mixedFtPtStructureStr, points()[e[1]]); verti++; - mixedFtPtStructureStr << "l " << verti-1 << ' ' << verti << endl; - } - } - - OFstream externalStr(prefix + "_externalEdges.obj"); - Pout<< "Writing external edges to " << externalStr.name() << endl; - - verti = 0; - for (label i = externalStart_; i < internalStart_; i++) - { - const edge& e = edges()[i]; - - meshTools::writeOBJ(externalStr, points()[e[0]]); verti++; - meshTools::writeOBJ(externalStr, points()[e[1]]); verti++; - externalStr << "l " << verti-1 << ' ' << verti << endl; - } - - OFstream internalStr(prefix + "_internalEdges.obj"); - Pout<< "Writing internal edges to " << internalStr.name() << endl; - - verti = 0; - for (label i = internalStart_; i < flatStart_; i++) - { - const edge& e = edges()[i]; - - meshTools::writeOBJ(internalStr, points()[e[0]]); verti++; - meshTools::writeOBJ(internalStr, points()[e[1]]); verti++; - internalStr << "l " << verti-1 << ' ' << verti << endl; - } - - OFstream flatStr(prefix + "_flatEdges.obj"); - Pout<< "Writing flat edges to " << flatStr.name() << endl; - - verti = 0; - for (label i = flatStart_; i < openStart_; i++) - { - const edge& e = edges()[i]; - - meshTools::writeOBJ(flatStr, points()[e[0]]); verti++; - meshTools::writeOBJ(flatStr, points()[e[1]]); verti++; - flatStr << "l " << verti-1 << ' ' << verti << endl; - } - - OFstream openStr(prefix + "_openEdges.obj"); - Pout<< "Writing open edges to " << openStr.name() << endl; - - verti = 0; - for (label i = openStart_; i < multipleStart_; i++) - { - const edge& e = edges()[i]; - - meshTools::writeOBJ(openStr, points()[e[0]]); verti++; - meshTools::writeOBJ(openStr, points()[e[1]]); verti++; - openStr << "l " << verti-1 << ' ' << verti << endl; - } - - OFstream multipleStr(prefix + "_multipleEdges.obj"); - Pout<< "Writing multiple edges to " << multipleStr.name() << endl; - - verti = 0; - for (label i = multipleStart_; i < edges().size(); i++) - { - const edge& e = edges()[i]; - - meshTools::writeOBJ(multipleStr, points()[e[0]]); verti++; - meshTools::writeOBJ(multipleStr, points()[e[1]]); verti++; - multipleStr << "l " << verti-1 << ' ' << verti << endl; - } - - OFstream regionStr(prefix + "_regionEdges.obj"); - Pout<< "Writing region edges to " << regionStr.name() << endl; - - verti = 0; - forAll(regionEdges_, i) - { - const edge& e = edges()[regionEdges_[i]]; - - meshTools::writeOBJ(regionStr, points()[e[0]]); verti++; - meshTools::writeOBJ(regionStr, points()[e[1]]); verti++; - regionStr << "l " << verti-1 << ' ' << verti << endl; - } + is >> *this; + return !is.bad(); } bool Foam::featureEdgeMesh::writeData(Ostream& os) const { - os << "// points, edges, concaveStart, mixedStart, nonFeatureStart, " << nl - << "// internalStart, flatStart, openStart, multipleStart, " << nl - << "// normals, edgeNormals, featurePointNormals, regionEdges" << nl - << endl; - - os << points() << nl - << edges() << nl - << concaveStart_ << token::SPACE - << mixedStart_ << token::SPACE - << nonFeatureStart_ << token::SPACE - << internalStart_ << token::SPACE - << flatStart_ << token::SPACE - << openStart_ << token::SPACE - << multipleStart_ << nl - << normals_ << nl - << edgeNormals_ << nl - << featurePointNormals_ << nl - << regionEdges_ - << endl; + os << *this; return os.good(); } diff --git a/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.H b/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.H index 4e1e360fa5f9c127940f73ba2e9c031f6cb3e62a..9e7982a7c6f8cd320f1fe56e160afa0c38d820b1 100644 --- a/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.H +++ b/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,27 +25,12 @@ Class Foam::featureEdgeMesh Description + edgeMesh + IO. - Feature points are a sorted subset at the start of the overall points list: - 0 .. concaveStart_-1 : convex points (w.r.t normals) - concaveStart_-1 .. mixedStart_-1 : concave points - mixedStart_ .. nonFeatureStart_ : mixed internal/external points - nonFeatureStart_ .. size-1 : non-feature points - - Feature edges are the edgeList of the edgeMesh and are sorted: - 0 .. internalStart_-1 : external edges (convex w.r.t normals) - internalStart_ .. flatStart_-1 : internal edges (concave) - flatStart_ .. openStart_-1 : flat edges (neither concave or convex) - can arise from region interfaces on - flat surfaces - openStart_ .. multipleStart_-1 : open edges (e.g. from baffle surfaces) - multipleStart_ .. size-1 : multiply connected edges - - The edge direction and feature edge and feature point adjacent normals - are stored. + See also extendedFeatureEdgeMesh type which stores additional classification + of features. SourceFiles - featureEdgeMeshI.H featureEdgeMesh.C \*---------------------------------------------------------------------------*/ @@ -54,12 +39,7 @@ SourceFiles #define featureEdgeMesh_H #include "edgeMesh.H" -#include "surfaceFeatures.H" -#include "objectRegistry.H" -#include "IOdictionary.H" -#include "indexedOctree.H" -#include "treeDataEdge.H" -#include "pointIndexHit.H" +#include "regIOobject.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -67,7 +47,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class featureEdgeMesh Declaration + Class featureEdgeMesh Declaration \*---------------------------------------------------------------------------*/ class featureEdgeMesh @@ -78,281 +58,31 @@ class featureEdgeMesh public: - //- Runtime type information TypeName("featureEdgeMesh"); - enum pointStatus - { - CONVEX, // Fully convex point (w.r.t normals) - CONCAVE, // Fully concave point - MIXED, // A point surrounded by both convex and concave edges - NONFEATURE // Not a feature point - }; - - enum edgeStatus - { - EXTERNAL, // "Convex" edge - INTERNAL, // "Concave" edge - FLAT, // Neither concave or convex, on a flat surface - OPEN, // i.e. only connected to one face - MULTIPLE, // Multiply connected (connected to more than two faces) - NONE // Not a classified feature edge (consistency with - // surfaceFeatures) - }; - -private: - - // Static data - - //- Angular closeness tolerance for treating normals as the same - static scalar cosNormalAngleTol_; - - //- Index of the start of the convex feature points - static as 0 - static label convexStart_; - - //- Index of the start of the external feature edges - static as 0 - static label externalStart_; - - - // Private data - - //- Index of the start of the concave feature points - label concaveStart_; - - //- Index of the start of the mixed type feature points - label mixedStart_; - - //- Index of the start of the non-feature points - label nonFeatureStart_; - - //- Index of the start of the internal feature edges - label internalStart_; - - //- Index of the start of the flat feature edges - label flatStart_; - - //- Index of the start of the open feature edges - label openStart_; - - //- Index of the start of the multiply-connected feature edges - label multipleStart_; - - //- Normals of the features, to be referred to by index by both feature - // points and edges, unsorted - vectorField normals_; - - //- Flat and open edges require the direction of the edge - vectorField edgeDirections_; - - //- Indices of the normals that are adjacent to the feature edges - labelListList edgeNormals_; - - //- Indices of the normals that are adjacent to the feature points - labelListList featurePointNormals_; - - //- Feature edges which are on the boundary between regions - labelList regionEdges_; - - //- Search tree for all edges - mutable autoPtr<indexedOctree<treeDataEdge> > edgeTree_; - - //- Individual search trees for each type of edge - mutable PtrList<indexedOctree<treeDataEdge> > edgeTreesByType_; - - - // Private Member Functions - - //- Classify the type of feature point. Requires valid stored member - // data for edges and normals. - pointStatus classifyFeaturePoint(label ptI) const; - - //- Classify the type of feature edge. Requires face centre 0 to face - // centre 1 vector to distinguish internal from external - edgeStatus classifyEdge - ( - const List<vector>& norms, - const labelList& edNorms, - const vector& fC0tofC1 - ) const; - - -public: - - // Static data - - //- Number of possible point types (i.e. number of slices) - static label nPointTypes; - - //- Number of possible feature edge types (i.e. number of slices) - static label nEdgeTypes; // Constructors //- Construct (read) given an IOobject featureEdgeMesh(const IOobject&); - //- Construct as copy - explicit featureEdgeMesh(const IOobject&, const featureEdgeMesh&); - - //- Construct by transferring components (points, edges) + //- Construct from featureEdgeMesh data featureEdgeMesh ( const IOobject&, - const Xfer<pointField>&, - const Xfer<edgeList>& - ); - - //- Construct (read) given surfaceFeatures, an objectRegistry and a - // fileName to write to. Extracts, classifies and reorders the data - // from surfaceFeatures. - featureEdgeMesh - ( - const surfaceFeatures& sFeat, - const objectRegistry& obr, - const fileName& sFeatFileName + const pointField&, + const edgeList& ); - //- Construct from all components - featureEdgeMesh - ( - const IOobject& io, - const pointField& pts, - const edgeList& eds, - label concaveStart, - label mixedStart, - label nonFeatureStart, - label internalStart, - label flatStart, - label openStart, - label multipleStart, - const vectorField& normals, - const vectorField& edgeDirections, - const labelListList& edgeNormals, - const labelListList& featurePointNormals, - const labelList& regionEdges - ); - - - //- Destructor - ~featureEdgeMesh(); - - - // Member Functions - - // Find - - //- Find nearest surface edge for the sample point. - void nearestFeatureEdge - ( - const point& sample, - scalar searchDistSqr, - pointIndexHit& info - ) const; - - //- Find nearest surface edge for each sample point. - void nearestFeatureEdge - ( - const pointField& samples, - const scalarField& searchDistSqr, - List<pointIndexHit>& info - ) const; - - //- Find the nearest point on each type of feature edge - void nearestFeatureEdgeByType - ( - const point& sample, - const scalarField& searchDistSqr, - List<pointIndexHit>& info - ) const; - - // Access - - //- Return the index of the start of the convex feature points - inline label convexStart() const; - - //- Return the index of the start of the concave feature points - inline label concaveStart() const; - - //- Return the index of the start of the mixed type feature points - inline label mixedStart() const; - - //- Return the index of the start of the non-feature points - inline label nonFeatureStart() const; - - //- Return the index of the start of the external feature edges - inline label externalStart() const; - - //- Return the index of the start of the internal feature edges - inline label internalStart() const; - - //- Return the index of the start of the flat feature edges - inline label flatStart() const; - - //- Return the index of the start of the open feature edges - inline label openStart() const; - - //- Return the index of the start of the multiply-connected feature - // edges - inline label multipleStart() const; - - //- Return whether or not the point index is a feature point - inline bool featurePoint(label ptI) const; - - //- Return the normals of the surfaces adjacent to the feature edges - // and points - inline const vectorField& normals() const; - - //- Return the edgeDirection vectors - inline const vectorField& edgeDirections() const; - - //- Return the direction of edgeI, pointing away from ptI - inline vector edgeDirection(label edgeI, label ptI) const; - - //- Return the indices of the normals that are adjacent to the - // feature edges - inline const labelListList& edgeNormals() const; - - //- Return the normal vectors for a given set of normal indices - inline vectorField edgeNormals(const labelList& edgeNormIs) const; - - //- Return the normal vectors for a given edge - inline vectorField edgeNormals(label edgeI) const; - - //- Return the indices of the normals that are adjacent to the - // feature points - inline const labelListList& featurePointNormals() const; - - //- Return the normal vectors for a given feature point - inline vectorField featurePointNormals(label ptI) const; - - //- Return the feature edges which are on the boundary between - // regions - inline const labelList& regionEdges() const; - - //- Return the pointStatus of a specified point - inline pointStatus getPointStatus(label ptI) const; - - //- Return the edgeStatus of a specified edge - inline edgeStatus getEdgeStatus(label edgeI) const; - - //- Demand driven construction of octree for boundary edges - const indexedOctree<treeDataEdge>& edgeTree() const; - - //- Demand driven construction of octree for boundary edges by type - const PtrList<indexedOctree<treeDataEdge> >& - edgeTreesByType() const; - - - // Write + //- Construct as copy + featureEdgeMesh(const IOobject&, const featureEdgeMesh&); - //- Write all components of the featureEdgeMesh as obj files - void writeObj(const fileName& prefix) const; - //- Give precedence to the regIOobject write - using regIOobject::write; + //- ReadData function required for regIOobject read operation + virtual bool readData(Istream&); - //- WriteData function required for regIOobject write operation - virtual bool writeData(Ostream&) const; + //- WriteData function required for regIOobject write operation + virtual bool writeData(Ostream&) const; }; @@ -362,10 +92,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#include "featureEdgeMeshI.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/errorEstimation/Make/files b/src/errorEstimation/Make/files deleted file mode 100644 index ccfc723de08aaeeb9f26c079e891597d217965cb..0000000000000000000000000000000000000000 --- a/src/errorEstimation/Make/files +++ /dev/null @@ -1,9 +0,0 @@ -errorDrivenRefinement = errorDrivenRefinement -errorEstimate = errorEstimate -evaluateError = evaluateError - -$(evaluateError)/evaluateError.C -$(errorDrivenRefinement)/errorDrivenRefinement.C - -LIB = $(FOAM_LIBBIN)/liberrorEstimation - diff --git a/src/errorEstimation/Make/options b/src/errorEstimation/Make/options deleted file mode 100644 index a3458eaa3d0128ff57370fa3dcb78e65177594ed..0000000000000000000000000000000000000000 --- a/src/errorEstimation/Make/options +++ /dev/null @@ -1,9 +0,0 @@ -EXE_INC = \ - -I$(LIB_SRC)/finiteVolume/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude \ - -I$(LIB_SRC)/dynamicMesh/lnInclude - -LIB_LIBS = \ - -lfiniteVolume \ - -lmeshTools \ - -ldynamicMesh diff --git a/src/errorEstimation/errorDrivenRefinement/errorDrivenRefinement.C b/src/errorEstimation/errorDrivenRefinement/errorDrivenRefinement.C deleted file mode 100644 index fdc72e509efd9f94085785bdd5a138e82386f424..0000000000000000000000000000000000000000 --- a/src/errorEstimation/errorDrivenRefinement/errorDrivenRefinement.C +++ /dev/null @@ -1,277 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "errorDrivenRefinement.H" -#include "polyTopoChanger.H" -#include "polyMesh.H" -#include "primitiveMesh.H" -#include "polyTopoChange.H" -#include "addToRunTimeSelectionTable.H" -#include "volFields.H" -#include "surfaceFields.H" -#include "evaluateError.H" -#include "fvc.H" -#include "mapPolyMesh.H" -#include "topoCellLooper.H" -#include "cellCuts.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(errorDrivenRefinement, 0); - addToRunTimeSelectionTable - ( - polyMeshModifier, - errorDrivenRefinement, - dictionary - ); -} - - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -// Construct from dictionary -Foam::errorDrivenRefinement::errorDrivenRefinement -( - const word& name, - const dictionary& dict, - const label index, - const polyTopoChanger& mme -) -: - polyMeshModifier(name, index, mme, false), - refinementEngine_(topoChanger().mesh(), true), - errorField_(dict.lookup("errorField")) -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::errorDrivenRefinement::~errorDrivenRefinement() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - - -bool Foam::errorDrivenRefinement::changeTopology() const -{ - const Time& runTime = topoChanger().mesh().time(); - - if (runTime.foundObject<volVectorField>(errorField_)) - { - if (debug) - { - Info<< "errorDrivenRefinement::changeTopology() : triggering topo" - << " change since found errorField " - << errorField_ << endl; - } - - return true; - } - else - { - if (debug) - { - Info<< "errorDrivenRefinement::changeTopology() : no topo" - << " change request from me since no errorField " - << errorField_ << endl; - } - - return false; - } -} - - -void Foam::errorDrivenRefinement::setRefinement(polyTopoChange& ref) const -{ - // Insert the coarsen/refinement instructions into the topological change - - if (debug) - { - Info<< "errorDrivenRefinement::setRefinement(polyTopoChange& ref)" - << endl; - } - - const polyMesh& mesh = topoChanger().mesh(); - - const Time& runTime = mesh.time(); - - if (debug) - { - Info<< "Looking up vector field with name " << errorField_ << endl; - } - const volVectorField& resError = - runTime.lookupObject<volVectorField>(errorField_); - - const volScalarField magResError(Foam::mag(resError)); - - scalar min = Foam::min(magResError).value(); - scalar max = Foam::max(magResError).value(); - scalar avg = Foam::average(magResError).value(); - - if (debug) - { - Info<< "Writing magResError" << endl; - magResError.write(); - - Info<< "min:" << min << " max:" << max << " avg:" << avg << endl; - } - - // Get faces to remove and cells to refine based on error - evaluateError refPattern - ( - magResError, // Error on cells - resError, // Error vector on cells - fvc::interpolate(magResError), // Error on faces - refinementEngine_.getSplitFaces() // Current live split faces - ); - - - // Insert mesh refinement into polyTopoChange: - // - remove split faces - // - refine cells - - // Give 'hint' of faces to remove to cell splitter. - const labelList& candidates = refPattern.unsplitFaces(); - ////Hack:no unsplitting - //labelList candidates; - - labelList removedFaces(refinementEngine_.removeSplitFaces(candidates, ref)); - - // Now success will be for every candidates whether face has been removed. - // Protect cells using face from refinement. - - // List of protected cells - boolList markedCell(mesh.nCells(), false); - - forAll(removedFaces, i) - { - label faceI = removedFaces[i]; - - markedCell[mesh.faceOwner()[faceI]] = true; - - if (mesh.isInternalFace(faceI)) - { - markedCell[mesh.faceNeighbour()[faceI]] = true; - } - } - - // Repack list of cells to refine. - List<refineCell> refCells = refPattern.refCells(); - - label newRefCellI = 0; - - forAll(refCells, refCellI) - { - label cellI = refCells[refCellI].cellNo(); - - if (!markedCell[cellI] && (newRefCellI != refCellI)) - { - refCells[newRefCellI++] = refCells[refCellI]; - } - } - - if (debug) - { - Info<< "errorDrivenRefinement : shrinking refCells from " - << refCells.size() - << " to " << newRefCellI << endl; - } - - refCells.setSize(newRefCellI); - - // Determine cut pattern using topological cell walker - topoCellLooper cellWalker(mesh); - - cellCuts cuts(mesh, cellWalker, refCells); - - // Do actual splitting - refinementEngine_.setRefinement(cuts, ref); -} - - -// Has the responsability of moving my newly introduced points onto the right -// place. This is since the whole mesh might e.g. have been moved by another -// meshmodifier. So using preMotionPoints is hack for if I am only meshModifier. -// Good solution: -// - remember new point label of introduced point and vertices -// of edge it is created from (in setRefinement) -// - in here reposition point at correct position between current vertex -// position of edge endpoints. -void Foam::errorDrivenRefinement::modifyMotionPoints -( - pointField& motionPoints -) const -{ - if (debug) - { - Info<< "errorDrivenRefinement::modifyMotionPoints(*pointField&)" - << endl; - } -} - - -void Foam::errorDrivenRefinement::updateMesh(const mapPolyMesh& morphMap) -{ - // Mesh has changed topologically. Update local topological data - if (debug) - { - Info<< "errorDrivenRefinement::updateMesh" - << "(const mapPolyMesh& morphMap)" << endl; - } - refinementEngine_.updateMesh(morphMap); -} - - -void Foam::errorDrivenRefinement::write(Ostream& os) const -{ - os << nl << type() << nl; -} - - -void Foam::errorDrivenRefinement::writeDict(Ostream& os) const -{ - os << nl << name() << nl << token::BEGIN_BLOCK << nl - << " type " << type() - << token::END_STATEMENT << nl - << token::END_BLOCK << endl; -} - - -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // - - -// ************************************************************************* // diff --git a/src/errorEstimation/errorDrivenRefinement/errorDrivenRefinement.H b/src/errorEstimation/errorDrivenRefinement/errorDrivenRefinement.H deleted file mode 100644 index cdc8f53943a2d3d3c9c32476dca343558cac696e..0000000000000000000000000000000000000000 --- a/src/errorEstimation/errorDrivenRefinement/errorDrivenRefinement.H +++ /dev/null @@ -1,136 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -Class - Foam::errorDrivenRefinement - -Description - Refines and coarsens based on error estimate. - -SourceFiles - errorDrivenRefinement.C - -\*---------------------------------------------------------------------------*/ - -#ifndef errorDrivenRefinement_H -#define errorDrivenRefinement_H - -#include "polyMeshModifier.H" -#include "undoableMeshCutter.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// Forward declaration of classes - -/*---------------------------------------------------------------------------*\ - Class errorDrivenRefinement Declaration -\*---------------------------------------------------------------------------*/ - -class errorDrivenRefinement -: - public polyMeshModifier -{ - // Private data - - //- Refinement/coarsening engine - mutable undoableMeshCutter refinementEngine_; - - //- Name of volVectorField which contains error. - word errorField_; - - - // Private Member Functions - - //- Disallow default bitwise copy construct - errorDrivenRefinement(const errorDrivenRefinement&); - - //- Disallow default bitwise assignment - void operator=(const errorDrivenRefinement&); - - -public: - - //- Runtime type information - TypeName("errorDrivenRefinement"); - - - // Constructors - - //- Construct from dictionary - errorDrivenRefinement - ( - const word& name, - const dictionary& dict, - const label index, - const polyTopoChanger& mme - ); - - - //- Destructor - virtual ~errorDrivenRefinement(); - - - // Member Functions - - //- Check for topology change - virtual bool changeTopology() const; - - //- Insert the layer addition/removal instructions - // into the topological change - virtual void setRefinement(polyTopoChange&) const; - - //- Modify motion points to comply with the topological change - virtual void modifyMotionPoints(pointField& motionPoints) const; - - //- Force recalculation of locally stored data on topological change - virtual void updateMesh(const mapPolyMesh&); - - //- Write - virtual void write(Ostream&) const; - - //- Write dictionary - virtual void writeDict(Ostream&) const; - - - // Access - - //- Underlying mesh modifier - const undoableMeshCutter& refinementEngine() const - { - return refinementEngine_; - } -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/errorEstimation/errorEstimate/errorEstimate.C b/src/errorEstimation/errorEstimate/errorEstimate.C deleted file mode 100644 index d233c5d5260f320e4d173945016cdb8309cbcaca..0000000000000000000000000000000000000000 --- a/src/errorEstimation/errorEstimate/errorEstimate.C +++ /dev/null @@ -1,1163 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "errorEstimate.H" -#include "zeroGradientFvPatchField.H" -#include "fixedValueFvPatchField.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -template<class Type> -Foam::wordList Foam::errorEstimate<Type>::errorBCTypes() const -{ - // Make the boundary condition type list - // Default types get over-ridden anyway - wordList ebct - ( - psi_.boundaryField().size(), - zeroGradientFvPatchField<Type>::typeName - ); - - forAll(psi_.boundaryField(), patchI) - { - if (psi_.boundaryField()[patchI].fixesValue()) - { - ebct[patchI] = fixedValueFvPatchField<Type>::typeName; - } - } - - return ebct; -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -// Construct from components -template<class Type> -Foam::errorEstimate<Type>::errorEstimate -( - const GeometricField<Type, fvPatchField, volMesh>& psi, - const dimensionSet& ds, - const Field<Type>& res, - const scalarField& norm -) -: - psi_(psi), - dimensions_(ds), - residual_(res), - normFactor_(norm) -{} - - -// Construct as copy -template<class Type> -Foam::errorEstimate<Type>::errorEstimate(const Foam::errorEstimate<Type>& ee) -: - refCount(), - psi_(ee.psi_), - dimensions_(ee.dimensions_), - residual_(ee.residual_), - normFactor_(ee.normFactor_) -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -template<class Type> -Foam::errorEstimate<Type>::~errorEstimate() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template<class Type> -Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> > -Foam::errorEstimate<Type>::residual() const -{ - tmp<GeometricField<Type, fvPatchField, volMesh> > tres - ( - new GeometricField<Type, fvPatchField, volMesh> - ( - IOobject - ( - "residual" + psi_.name(), - psi_.mesh().time().timeName(), - psi_.db(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - psi_.mesh(), - psi_.dimensions()/dimTime, - errorBCTypes() - ) - ); - - GeometricField<Type, fvPatchField, volMesh>& res = tres(); - - res.internalField() = residual_; - res.boundaryField() == pTraits<Type>::zero; - - res.correctBoundaryConditions(); - - return tres; -} - - -template<class Type> -Foam::tmp<Foam::volScalarField> Foam::errorEstimate<Type>::normFactor() const -{ - tmp<volScalarField> tnormFactor - ( - new volScalarField - ( - IOobject - ( - "normFactor" + psi_.name(), - psi_.mesh().time().timeName(), - psi_.db(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - psi_.mesh(), - dimless/dimTime, - errorBCTypes() - ) - ); - - volScalarField& normFactor = tnormFactor(); - - normFactor.internalField() = normFactor_; - normFactor.boundaryField() == pTraits<Type>::zero; - - normFactor.correctBoundaryConditions(); - - return tnormFactor; -} - -template<class Type> -Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> > -Foam::errorEstimate<Type>::error() const -{ - tmp<GeometricField<Type, fvPatchField, volMesh> > tresError - ( - new GeometricField<Type, fvPatchField, volMesh> - ( - IOobject - ( - "resError" + psi_.name(), - psi_.mesh().time().timeName(), - psi_.db(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - psi_.mesh(), - psi_.dimensions(), - errorBCTypes() - ) - ); - - GeometricField<Type, fvPatchField, volMesh>& resError = tresError(); - - resError.internalField() = residual_/normFactor_; - resError.boundaryField() == pTraits<Type>::zero; - - resError.correctBoundaryConditions(); - - return tresError; -} - -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // - -template<class Type> -void Foam::errorEstimate<Type>::operator=(const Foam::errorEstimate<Type>& rhs) -{ - // Check for assignment to self - if (this == &rhs) - { - FatalErrorIn - ( - "errorEstimate<Type>::operator=(const Foam::errorEstimate<Type>&)" - ) << "Attempted assignment to self" - << abort(FatalError); - } - - if (&psi_ != &(rhs.psi_)) - { - FatalErrorIn - ( - "errorEstimate<Type>::operator=(const errorEstimate<Type>&)" - ) << "different fields" - << abort(FatalError); - } - - residual_ = rhs.residual_; - normFactor_ = rhs.normFactor_; -} - - -template<class Type> -void Foam::errorEstimate<Type>::operator=(const tmp<errorEstimate<Type> >& teev) -{ - operator=(teev()); - teev.clear(); -} - - -template<class Type> -void Foam::errorEstimate<Type>::negate() -{ - residual_.negate(); -} - - -template<class Type> -void Foam::errorEstimate<Type>::operator+=(const errorEstimate<Type>& eev) -{ - checkMethod(*this, eev, "+="); - - dimensions_ += eev.dimensions_; - - residual_ += eev.residual_; - normFactor_ += eev.normFactor_; -} - - -template<class Type> -void Foam::errorEstimate<Type>::operator+= -( - const tmp<errorEstimate<Type> >& teev -) -{ - operator+=(teev()); - teev.clear(); -} - - -template<class Type> -void Foam::errorEstimate<Type>::operator-=(const errorEstimate<Type>& eev) -{ - checkMethod(*this, eev, "+="); - - dimensions_ -= eev.dimensions_; - residual_ -= eev.residual_; - normFactor_ += eev.normFactor_; -} - - -template<class Type> -void Foam::errorEstimate<Type>::operator-= -( - const tmp<errorEstimate<Type> >& teev -) -{ - operator-=(teev()); - teev.clear(); -} - - -template<class Type> -void Foam::errorEstimate<Type>::operator+= -( - const GeometricField<Type, fvPatchField, volMesh>& su -) -{ - checkMethod(*this, su, "+="); - residual_ -= su.internalField(); -} - - -template<class Type> -void Foam::errorEstimate<Type>::operator+= -( - const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu -) -{ - operator+=(tsu()); - tsu.clear(); -} - - -template<class Type> -void Foam::errorEstimate<Type>::operator-= -( - const GeometricField<Type, fvPatchField, volMesh>& su -) -{ - checkMethod(*this, su, "-="); - residual_ += su.internalField(); -} - - -template<class Type> -void Foam::errorEstimate<Type>::operator-= -( - const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu -) -{ - operator-=(tsu()); - tsu.clear(); -} - - -template<class Type> -void Foam::errorEstimate<Type>::operator+= -( - const dimensioned<Type>& su -) -{ - residual_ -= su; -} - - -template<class Type> -void Foam::errorEstimate<Type>::operator-= -( - const dimensioned<Type>& su -) -{ - residual_ += su; -} - - -template<class Type> -void Foam::errorEstimate<Type>::operator*= -( - const volScalarField& vsf -) -{ - dimensions_ *= vsf.dimensions(); - residual_ *= vsf.internalField(); - normFactor_ *= vsf.internalField(); -} - - -template<class Type> -void Foam::errorEstimate<Type>::operator*= -( - const tmp<volScalarField>& tvsf -) -{ - operator*=(tvsf()); - tvsf.clear(); -} - - -template<class Type> -void Foam::errorEstimate<Type>::operator*= -( - const dimensioned<scalar>& ds -) -{ - dimensions_ *= ds.dimensions(); - residual_ *= ds.value(); - normFactor_ *= ds.value(); -} - - -// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // - -template<class Type> -void Foam::checkMethod -( - const errorEstimate<Type>& ee1, - const errorEstimate<Type>& ee2, - const char* op -) -{ - if (&ee1.psi() != &ee2.psi()) - { - FatalErrorIn - ( - "checkMethod(const errorEstimate<Type>&, " - "const errorEstimate<Type>&)" - ) << "incompatible fields for operation " - << endl << " " - << "[" << ee1.psi().name() << "] " - << op - << " [" << ee2.psi().name() << "]" - << abort(FatalError); - } - - if (dimensionSet::debug && ee1.dimensions() != ee2.dimensions()) - { - FatalErrorIn - ( - "checkMethod(const errorEstimate<Type>&, " - "const errorEstimate<Type>&)" - ) << "incompatible dimensions for operation " - << endl << " " - << "[" << ee1.psi().name() << ee1.dimensions()/dimVolume << " ] " - << op - << " [" << ee2.psi().name() << ee2.dimensions()/dimVolume << " ]" - << abort(FatalError); - } -} - - -template<class Type> -void Foam::checkMethod -( - const errorEstimate<Type>& ee, - const GeometricField<Type, fvPatchField, volMesh>& vf, - const char* op -) -{ - if (dimensionSet::debug && ee.dimensions()/dimVolume != vf.dimensions()) - { - FatalErrorIn - ( - "checkMethod(const errorEstimate<Type>&, " - "const GeometricField<Type, fvPatchField, volMesh>&)" - ) << "incompatible dimensions for operation " - << endl << " " - << "[" << ee.psi().name() << ee.dimensions()/dimVolume << " ] " - << op - << " [" << vf.name() << vf.dimensions() << " ]" - << abort(FatalError); - } -} - - -template<class Type> -void Foam::checkMethod -( - const errorEstimate<Type>& ee, - const dimensioned<Type>& dt, - const char* op -) -{ - if (dimensionSet::debug && ee.dimensions()/dimVolume != dt.dimensions()) - { - FatalErrorIn - ( - "checkMethod(const errorEstimate<Type>&, const dimensioned<Type>&)" - ) << "incompatible dimensions for operation " - << endl << " " - << "[" << ee.psi().name() << ee.dimensions()/dimVolume << " ] " - << op - << " [" << dt.name() << dt.dimensions() << " ]" - << abort(FatalError); - } -} - - -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // - -namespace Foam -{ - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const errorEstimate<Type>& A, - const errorEstimate<Type>& B -) -{ - checkMethod(A, B, "+"); - tmp<errorEstimate<Type> > tC(new errorEstimate<Type>(A)); - tC() += B; - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const tmp<errorEstimate<Type> >& tA, - const errorEstimate<Type>& B -) -{ - checkMethod(tA(), B, "+"); - tmp<errorEstimate<Type> > tC(tA.ptr()); - tC() += B; - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const errorEstimate<Type>& A, - const tmp<errorEstimate<Type> >& tB -) -{ - checkMethod(A, tB(), "+"); - tmp<errorEstimate<Type> > tC(tB.ptr()); - tC() += A; - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const tmp<errorEstimate<Type> >& tA, - const tmp<errorEstimate<Type> >& tB -) -{ - checkMethod(tA(), tB(), "+"); - tmp<errorEstimate<Type> > tC(tA.ptr()); - tC() += tB(); - tB.clear(); - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const errorEstimate<Type>& A -) -{ - tmp<errorEstimate<Type> > tC(new errorEstimate<Type>(A)); - tC().negate(); - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const tmp<errorEstimate<Type> >& tA -) -{ - tmp<errorEstimate<Type> > tC(tA.ptr()); - tC().negate(); - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const errorEstimate<Type>& A, - const errorEstimate<Type>& B -) -{ - checkMethod(A, B, "-"); - tmp<errorEstimate<Type> > tC(new errorEstimate<Type>(A)); - tC() -= B; - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const tmp<errorEstimate<Type> >& tA, - const errorEstimate<Type>& B -) -{ - checkMethod(tA(), B, "-"); - tmp<errorEstimate<Type> > tC(tA.ptr()); - tC() -= B; - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const errorEstimate<Type>& A, - const tmp<errorEstimate<Type> >& tB -) -{ - checkMethod(A, tB(), "-"); - tmp<errorEstimate<Type> > tC(tB.ptr()); - tC() -= A; - tC().negate(); - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const tmp<errorEstimate<Type> >& tA, - const tmp<errorEstimate<Type> >& tB -) -{ - checkMethod(tA(), tB(), "-"); - tmp<errorEstimate<Type> > tC(tA.ptr()); - tC() -= tB(); - tB.clear(); - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator== -( - const errorEstimate<Type>& A, - const errorEstimate<Type>& B -) -{ - checkMethod(A, B, "=="); - return (A - B); -} - - -template<class Type> -tmp<errorEstimate<Type> > operator== -( - const tmp<errorEstimate<Type> >& tA, - const errorEstimate<Type>& B -) -{ - checkMethod(tA(), B, "=="); - return (tA - B); -} - - -template<class Type> -tmp<errorEstimate<Type> > operator== -( - const errorEstimate<Type>& A, - const tmp<errorEstimate<Type> >& tB -) -{ - checkMethod(A, tB(), "=="); - return (A - tB); -} - - -template<class Type> -tmp<errorEstimate<Type> > operator== -( - const tmp<errorEstimate<Type> >& tA, - const tmp<errorEstimate<Type> >& tB -) -{ - checkMethod(tA(), tB(), "=="); - return (tA - tB); -} - - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const errorEstimate<Type>& A, - const GeometricField<Type, fvPatchField, volMesh>& su -) -{ - checkMethod(A, su, "+"); - tmp<errorEstimate<Type> > tC(new errorEstimate<Type>(A)); - tC().res() -= su.internalField(); - return tC; -} - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const tmp<errorEstimate<Type> >& tA, - const GeometricField<Type, fvPatchField, volMesh>& su -) -{ - checkMethod(tA(), su, "+"); - tmp<errorEstimate<Type> > tC(tA.ptr()); - tC().res() -= su.internalField(); - return tC; -} - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const errorEstimate<Type>& A, - const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu -) -{ - checkMethod(A, tsu(), "+"); - tmp<errorEstimate<Type> > tC(new errorEstimate<Type>(A)); - tC().res() -= tsu().internalField(); - tsu.clear(); - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const tmp<errorEstimate<Type> >& tA, - const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu -) -{ - checkMethod(tA(), tsu(), "+"); - tmp<errorEstimate<Type> > tC(tA.ptr()); - tC().res() -= tsu().internalField(); - tsu.clear(); - return tC; -} - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const GeometricField<Type, fvPatchField, volMesh>& su, - const errorEstimate<Type>& A -) -{ - checkMethod(A, su, "+"); - tmp<errorEstimate<Type> > tC(new errorEstimate<Type>(A)); - tC().res() -= su.internalField(); - return tC; -} - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const GeometricField<Type, fvPatchField, volMesh>& su, - const tmp<errorEstimate<Type> >& tA -) -{ - checkMethod(tA(), su, "+"); - tmp<errorEstimate<Type> > tC(tA.ptr()); - tC().res() -= su.internalField(); - return tC; -} - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu, - const errorEstimate<Type>& A -) -{ - checkMethod(A, tsu(), "+"); - tmp<errorEstimate<Type> > tC(new errorEstimate<Type>(A)); - tC().res() -= tsu().internalField(); - tsu.clear(); - return tC; -} - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu, - const tmp<errorEstimate<Type> >& tA -) -{ - checkMethod(tA(), tsu(), "+"); - tmp<errorEstimate<Type> > tC(tA.ptr()); - tC().res() -= tsu().internalField(); - tsu.clear(); - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const errorEstimate<Type>& A, - const GeometricField<Type, fvPatchField, volMesh>& su -) -{ - checkMethod(A, su, "-"); - tmp<errorEstimate<Type> > tC(new errorEstimate<Type>(A)); - tC().res() += su.internalField(); - return tC; -} - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const tmp<errorEstimate<Type> >& tA, - const GeometricField<Type, fvPatchField, volMesh>& su -) -{ - checkMethod(tA(), su, "-"); - tmp<errorEstimate<Type> > tC(tA.ptr()); - tC().res() += su.internalField(); - return tC; -} - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const errorEstimate<Type>& A, - const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu -) -{ - checkMethod(A, tsu(), "-"); - tmp<errorEstimate<Type> > tC(new errorEstimate<Type>(A)); - tC().res() += tsu().internalField(); - tsu.clear(); - return tC; -} - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const tmp<errorEstimate<Type> >& tA, - const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu -) -{ - checkMethod(tA(), tsu(), "-"); - tmp<errorEstimate<Type> > tC(tA.ptr()); - tC().res() += tsu().internalField(); - tsu.clear(); - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const GeometricField<Type, fvPatchField, volMesh>& su, - const errorEstimate<Type>& A -) -{ - checkMethod(A, su, "-"); - tmp<errorEstimate<Type> > tC(new errorEstimate<Type>(A)); - tC().negate(); - tC().res() -= su.internalField(); - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const GeometricField<Type, fvPatchField, volMesh>& su, - const tmp<errorEstimate<Type> >& tA -) -{ - checkMethod(tA(), su, "-"); - tmp<errorEstimate<Type> > tC(tA.ptr()); - tC().negate(); - tC().res() -= su.internalField(); - return tC; -} - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu, - const errorEstimate<Type>& A -) -{ - checkMethod(A, tsu(), "-"); - tmp<errorEstimate<Type> > tC(new errorEstimate<Type>(A)); - tC().negate(); - tC().res() -= tsu().internalField(); - tsu.clear(); - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu, - const tmp<errorEstimate<Type> >& tA -) -{ - checkMethod(tA(), tsu(), "-"); - tmp<errorEstimate<Type> > tC(tA.ptr()); - tC().negate(); - tC().res() -= tsu().internalField(); - tsu.clear(); - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const errorEstimate<Type>& A, - const dimensioned<Type>& su -) -{ - checkMethod(A, su, "+"); - tmp<errorEstimate<Type> > tC(new errorEstimate<Type>(A)); - tC().res() -= su.value(); - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const tmp<errorEstimate<Type> >& tA, - const dimensioned<Type>& su -) -{ - checkMethod(tA(), su, "+"); - tmp<errorEstimate<Type> > tC(tA.ptr()); - tC().res() -= su.value(); - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const dimensioned<Type>& su, - const errorEstimate<Type>& A -) -{ - checkMethod(A, su, "+"); - tmp<errorEstimate<Type> > tC(new errorEstimate<Type>(A)); - tC().res() -= su.value(); - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const dimensioned<Type>& su, - const tmp<errorEstimate<Type> >& tA -) -{ - checkMethod(tA(), su, "+"); - tmp<errorEstimate<Type> > tC(tA.ptr()); - tC().res() -= su.value(); - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const errorEstimate<Type>& A, - const dimensioned<Type>& su -) -{ - checkMethod(A, su, "-"); - tmp<errorEstimate<Type> > tC(new errorEstimate<Type>(A)); - tC().res() += su.value(); - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const tmp<errorEstimate<Type> >& tA, - const dimensioned<Type>& su -) -{ - checkMethod(tA(), su, "-"); - tmp<errorEstimate<Type> > tC(tA.ptr()); - tC().res() += su.value(); - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const dimensioned<Type>& su, - const errorEstimate<Type>& A -) -{ - checkMethod(A, su, "-"); - tmp<errorEstimate<Type> > tC(new errorEstimate<Type>(A)); - tC().negate(); - tC().res() -= su.value(); - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const dimensioned<Type>& su, - const tmp<errorEstimate<Type> >& tA -) -{ - checkMethod(tA(), su, "-"); - tmp<errorEstimate<Type> > tC(tA.ptr()); - tC().negate(); - tC().res() -= su.value(); - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator== -( - const errorEstimate<Type>& A, - const GeometricField<Type, fvPatchField, volMesh>& su -) -{ - checkMethod(A, su, "=="); - tmp<errorEstimate<Type> > tC(new errorEstimate<Type>(A)); - tC().res() += su.internalField(); - return tC; -} - -template<class Type> -tmp<errorEstimate<Type> > operator== -( - const tmp<errorEstimate<Type> >& tA, - const GeometricField<Type, fvPatchField, volMesh>& su -) -{ - checkMethod(tA(), su, "=="); - tmp<errorEstimate<Type> > tC(tA.ptr()); - tC().res() += su.internalField(); - return tC; -} - -template<class Type> -tmp<errorEstimate<Type> > operator== -( - const errorEstimate<Type>& A, - const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu -) -{ - checkMethod(A, tsu(), "=="); - tmp<errorEstimate<Type> > tC(new errorEstimate<Type>(A)); - tC().res() += tsu().internalField(); - tsu.clear(); - return tC; -} - -template<class Type> -tmp<errorEstimate<Type> > operator== -( - const tmp<errorEstimate<Type> >& tA, - const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu -) -{ - checkMethod(tA(), tsu(), "=="); - tmp<errorEstimate<Type> > tC(tA.ptr()); - tC().res() += tsu().internalField(); - tsu.clear(); - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator== -( - const errorEstimate<Type>& A, - const dimensioned<Type>& su -) -{ - checkMethod(A, su, "=="); - tmp<errorEstimate<Type> > tC(new errorEstimate<Type>(A)); - tC().res() += su.value(); - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator== -( - const tmp<errorEstimate<Type> >& tA, - const dimensioned<Type>& su -) -{ - checkMethod(tA(), su, "=="); - tmp<errorEstimate<Type> > tC(tA.ptr()); - tC().res() += su.value(); - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator* -( - const volScalarField& vsf, - const errorEstimate<Type>& A -) -{ - tmp<errorEstimate<Type> > tC(new errorEstimate<Type>(A)); - tC() *= vsf; - return tC; -} - -template<class Type> -tmp<errorEstimate<Type> > operator* -( - const tmp<volScalarField>& tvsf, - const errorEstimate<Type>& A -) -{ - tmp<errorEstimate<Type> > tC(new errorEstimate<Type>(A)); - tC() *= tvsf; - return tC; -} - -template<class Type> -tmp<errorEstimate<Type> > operator* -( - const volScalarField& vsf, - const tmp<errorEstimate<Type> >& tA -) -{ - tmp<errorEstimate<Type> > tC(tA.ptr()); - tC() *= vsf; - return tC; -} - -template<class Type> -tmp<errorEstimate<Type> > operator* -( - const tmp<volScalarField>& tvsf, - const tmp<errorEstimate<Type> >& tA -) -{ - tmp<errorEstimate<Type> > tC(tA.ptr()); - tC() *= tvsf; - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator* -( - const dimensioned<scalar>& ds, - const errorEstimate<Type>& A -) -{ - tmp<errorEstimate<Type> > tC(new errorEstimate<Type>(A)); - tC() *= ds; - return tC; -} - - -template<class Type> -tmp<errorEstimate<Type> > operator* -( - const dimensioned<scalar>& ds, - const tmp<errorEstimate<Type> >& tA -) -{ - tmp<errorEstimate<Type> > tC(tA.ptr()); - tC() *= ds; - return tC; -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// ************************************************************************* // diff --git a/src/errorEstimation/errorEstimate/errorEstimate.H b/src/errorEstimation/errorEstimate/errorEstimate.H deleted file mode 100644 index f41a99f257ddeb45bd39893c5b5e35c34bb93323..0000000000000000000000000000000000000000 --- a/src/errorEstimation/errorEstimate/errorEstimate.H +++ /dev/null @@ -1,542 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -Class - Foam::errorEstimate - -Description - Residual error estimation - -SourceFiles - errorEstimate.C - -\*---------------------------------------------------------------------------*/ - -#ifndef errorEstimate_H -#define errorEstimate_H - -#include "volFields.H" -#include "surfaceFields.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class errorEstimate Declaration -\*---------------------------------------------------------------------------*/ - -template<class Type> -class errorEstimate -: - public refCount -{ - // Private data - - // Reference to GeometricField<Type, fvPatchField, volMesh> - const GeometricField<Type, fvPatchField, volMesh>& psi_; - - //- Dimension set - dimensionSet dimensions_; - - //- Cell residual pointer - Field<Type> residual_; - - //- Normalisation factor - scalarField normFactor_; - - - // Private Member Functions - - //- Return boundary condition types for the error field - wordList errorBCTypes() const; - -public: - - // Static data members - - ClassName("errorEstimate"); - - - // Constructors - - //- Construct from components - errorEstimate - ( - const GeometricField<Type, fvPatchField, volMesh>& psi, - const dimensionSet& ds, - const Field<Type>& res, - const scalarField& norm - ); - - //- Construct as copy - errorEstimate(const errorEstimate<Type>&); - - - //- Destructor - ~errorEstimate(); - - - // Member Functions - - // Access - - //- Return field - const GeometricField<Type, fvPatchField, volMesh>& psi() const - { - return psi_; - } - - //- Return residual dimensions - const dimensionSet& dimensions() const - { - return dimensions_; - } - - // Raw residual (for calculus) - - Field<Type>& res() - { - return residual_; - } - - const Field<Type>& res() const - { - return residual_; - } - - - // Error Estimate - - //- Cell residual (volume intensive) - tmp<GeometricField<Type, fvPatchField, volMesh> > residual() const; - - //- Normalisation factor - tmp<volScalarField> normFactor() const; - - //- Error estimate - tmp<GeometricField<Type, fvPatchField, volMesh> > error() const; - - - // Member Operators - - void operator=(const errorEstimate<Type>&); - void operator=(const tmp<errorEstimate<Type> >&); - - void negate(); - - void operator+=(const errorEstimate<Type>&); - void operator+=(const tmp<errorEstimate<Type> >&); - - void operator-=(const errorEstimate<Type>&); - void operator-=(const tmp<errorEstimate<Type> >&); - - void operator+=(const GeometricField<Type,fvPatchField,volMesh>&); - void operator+=(const tmp<GeometricField<Type,fvPatchField,volMesh> >&); - - void operator-=(const GeometricField<Type,fvPatchField,volMesh>&); - void operator-=(const tmp<GeometricField<Type,fvPatchField,volMesh> >&); - - void operator+=(const dimensioned<Type>&); - void operator-=(const dimensioned<Type>&); - - void operator*=(const volScalarField&); - void operator*=(const tmp<volScalarField>&); - - void operator*=(const dimensioned<scalar>&); - - - // Friend Functions - - // Friend Operators -}; - - -// * * * * * * * * * * * * * * * Global functions * * * * * * * * * * * * * // - -template<class Type> -void checkMethod -( - const errorEstimate<Type>&, - const errorEstimate<Type>&, - const char* -); - -template<class Type> -void checkMethod -( - const errorEstimate<Type>&, - const GeometricField<Type, fvPatchField, volMesh>&, - const char* -); - -template<class Type> -void checkMethod -( - const errorEstimate<Type>&, - const dimensioned<Type>&, - const char* -); - - -// * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * // - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const errorEstimate<Type>& -); - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const tmp<errorEstimate<Type> >& -); - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const errorEstimate<Type>&, - const errorEstimate<Type>& -); - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const tmp<errorEstimate<Type> >&, - const errorEstimate<Type>& -); - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const errorEstimate<Type>&, - const tmp<errorEstimate<Type> >& -); - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const tmp<errorEstimate<Type> >&, - const tmp<errorEstimate<Type> >& -); - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const errorEstimate<Type>&, - const errorEstimate<Type>& -); - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const tmp<errorEstimate<Type> >&, - const errorEstimate<Type>& -); - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const errorEstimate<Type>&, - const tmp<errorEstimate<Type> >& -); - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const tmp<errorEstimate<Type> >&, - const tmp<errorEstimate<Type> >& -); - -template<class Type> -tmp<errorEstimate<Type> > operator== -( - const errorEstimate<Type>&, - const errorEstimate<Type>& -); - -template<class Type> -tmp<errorEstimate<Type> > operator== -( - const tmp<errorEstimate<Type> >&, - const errorEstimate<Type>& -); - -template<class Type> -tmp<errorEstimate<Type> > operator== -( - const errorEstimate<Type>&, - const tmp<errorEstimate<Type> >& -); - -template<class Type> -tmp<errorEstimate<Type> > operator== -( - const tmp<errorEstimate<Type> >&, - const tmp<errorEstimate<Type> >& -); - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const errorEstimate<Type>&, - const GeometricField<Type, fvPatchField, volMesh>& -); - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const tmp<errorEstimate<Type> >&, - const GeometricField<Type, fvPatchField, volMesh>& -); - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const errorEstimate<Type>&, - const tmp<GeometricField<Type, fvPatchField, volMesh> >& -); - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const tmp<errorEstimate<Type> >&, - const tmp<GeometricField<Type, fvPatchField, volMesh> >& -); - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const GeometricField<Type, fvPatchField, volMesh>&, - const errorEstimate<Type>& -); - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const GeometricField<Type, fvPatchField, volMesh>&, - const tmp<errorEstimate<Type> >& -); - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const tmp<GeometricField<Type, fvPatchField, volMesh> >&, - const errorEstimate<Type>& -); - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const tmp<GeometricField<Type, fvPatchField, volMesh> >&, - const tmp<errorEstimate<Type> >& -); - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const errorEstimate<Type>&, - const GeometricField<Type, fvPatchField, volMesh>& -); - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const tmp<errorEstimate<Type> >&, - const GeometricField<Type, fvPatchField, volMesh>& -); - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const errorEstimate<Type>&, - const tmp<GeometricField<Type, fvPatchField, volMesh> >& -); - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const tmp<errorEstimate<Type> >&, - const tmp<GeometricField<Type, fvPatchField, volMesh> >& -); - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const GeometricField<Type, fvPatchField, volMesh>&, - const errorEstimate<Type>& -); - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const GeometricField<Type, fvPatchField, volMesh>&, - const tmp<errorEstimate<Type> >& -); - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const tmp<GeometricField<Type, fvPatchField, volMesh> >&, - const errorEstimate<Type>& -); - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const tmp<GeometricField<Type, fvPatchField, volMesh> >&, - const tmp<errorEstimate<Type> >& -); - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const tmp<errorEstimate<Type> >&, - const dimensioned<Type>& -); - -template<class Type> -tmp<errorEstimate<Type> > operator+ -( - const dimensioned<Type>&, - const tmp<errorEstimate<Type> >& -); - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const tmp<errorEstimate<Type> >&, - const dimensioned<Type>& -); - -template<class Type> -tmp<errorEstimate<Type> > operator- -( - const dimensioned<Type>&, - const tmp<errorEstimate<Type> >& -); - -template<class Type> -tmp<errorEstimate<Type> > operator== -( - const errorEstimate<Type>&, - const GeometricField<Type, fvPatchField, volMesh>& -); - -template<class Type> -tmp<errorEstimate<Type> > operator== -( - const tmp<errorEstimate<Type> >&, - const GeometricField<Type, fvPatchField, volMesh>& -); - -template<class Type> -tmp<errorEstimate<Type> > operator== -( - const errorEstimate<Type>&, - const tmp<GeometricField<Type, fvPatchField, volMesh> >& -); - -template<class Type> -tmp<errorEstimate<Type> > operator== -( - const tmp<errorEstimate<Type> >&, - const tmp<GeometricField<Type, fvPatchField, volMesh> >& -); - -template<class Type> -tmp<errorEstimate<Type> > operator== -( - const errorEstimate<Type>&, - const dimensioned<Type>& -); - -template<class Type> -tmp<errorEstimate<Type> > operator== -( - const tmp<errorEstimate<Type> >&, - const dimensioned<Type>& -); - - -template<class Type> -tmp<errorEstimate<Type> > operator* -( - const volScalarField&, - const errorEstimate<Type>& -); - -template<class Type> -tmp<errorEstimate<Type> > operator* -( - const volScalarField&, - const tmp<errorEstimate<Type> >& -); - -template<class Type> -tmp<errorEstimate<Type> > operator* -( - const tmp<volScalarField>&, - const errorEstimate<Type>& -); - -template<class Type> -tmp<errorEstimate<Type> > operator* -( - const tmp<volScalarField>&, - const tmp<errorEstimate<Type> >& -); - - -template<class Type> -tmp<errorEstimate<Type> > operator* -( - const dimensioned<scalar>&, - const errorEstimate<Type>& -); - -template<class Type> -tmp<errorEstimate<Type> > operator* -( - const dimensioned<scalar>&, - const tmp<errorEstimate<Type> >& -); - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifdef NoRepository -# include "errorEstimate.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/errorEstimation/errorEstimate/resErrorDiv.C b/src/errorEstimation/errorEstimate/resErrorDiv.C deleted file mode 100644 index 1a8bf71c35341d2ed6f8ebb3b77dbdb11b779659..0000000000000000000000000000000000000000 --- a/src/errorEstimation/errorEstimate/resErrorDiv.C +++ /dev/null @@ -1,168 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "resErrorDiv.H" -#include "fvc.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace resError -{ - -template<class Type> -tmp<errorEstimate<Type> > -div -( - const surfaceScalarField& flux, - const GeometricField<Type, fvPatchField, volMesh>& vf -) -{ - const fvMesh& mesh = vf.mesh(); - - const scalarField& vols = mesh.V(); - const surfaceVectorField& faceCentres = mesh.Cf(); - const volVectorField& cellCentres = mesh.C(); - const fvPatchList& patches = mesh.boundary(); - const labelUList& owner = mesh.owner(); - const labelUList& neighbour = mesh.neighbour(); - - Field<Type> res(vols.size(), pTraits<Type>::zero); - scalarField aNorm(vols.size(), 0.0); - - // Get sign of flux - const surfaceScalarField signF(pos(flux)); - - // Calculate gradient of the solution - GeometricField - < - typename outerProduct<vector, Type>::type, fvPatchField, volMesh - > - gradVf(fvc::grad(vf)); - - // Internal faces - forAll(owner, faceI) - { - // Calculate the centre of the face - const vector& curFaceCentre = faceCentres[faceI]; - - // Owner - vector ownD = curFaceCentre - cellCentres[owner[faceI]]; - - // Subtract convection - res[owner[faceI]] -= - ( - vf[owner[faceI]] - + (ownD & gradVf[owner[faceI]]) - )*flux[faceI]; - - aNorm[owner[faceI]] += signF[faceI]*flux[faceI]; - - // Neighbour - vector neiD = curFaceCentre - cellCentres[neighbour[faceI]]; - - // Subtract convection - res[neighbour[faceI]] += - ( - vf[neighbour[faceI]] - + (neiD & gradVf[neighbour[faceI]]) - )*flux[faceI]; - - aNorm[neighbour[faceI]] -= (1.0 - signF[faceI])*flux[faceI]; - } - - forAll(patches, patchI) - { - const vectorField& patchFaceCentres = - faceCentres.boundaryField()[patchI]; - - const scalarField& patchFlux = flux.boundaryField()[patchI]; - const scalarField& patchSignFlux = signF.boundaryField()[patchI]; - - const labelList& fCells = patches[patchI].faceCells(); - - forAll(fCells, faceI) - { - vector d = - patchFaceCentres[faceI] - cellCentres[fCells[faceI]]; - - // Subtract convection - res[fCells[faceI]] -= - ( - vf[fCells[faceI]] - + (d & gradVf[fCells[faceI]]) - )*patchFlux[faceI]; - - aNorm[fCells[faceI]] += patchSignFlux[faceI]*patchFlux[faceI]; - } - } - - res /= vols; - aNorm /= vols; - - return tmp<errorEstimate<Type> > - ( - new errorEstimate<Type> - ( - vf, - flux.dimensions()*vf.dimensions(), - res, - aNorm - ) - ); -} - - -template<class Type> -tmp<errorEstimate<Type> > -div -( - const tmp<surfaceScalarField>& tflux, - const GeometricField<Type, fvPatchField, volMesh>& vf -) -{ - tmp<errorEstimate<Type> > Div(resError::div(tflux(), vf)); - tflux.clear(); - return Div; -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace resError - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// ************************************************************************* // - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - diff --git a/src/errorEstimation/errorEstimate/resErrorDiv.H b/src/errorEstimation/errorEstimate/resErrorDiv.H deleted file mode 100644 index 67645a97265ad8aef94c0633b9138c7273c973fa..0000000000000000000000000000000000000000 --- a/src/errorEstimation/errorEstimate/resErrorDiv.H +++ /dev/null @@ -1,80 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -InNamespace - Foam::resError - -Description - Residual error estimate for the fv convection operators. - -SourceFiles - resErrorDiv.C - -\*---------------------------------------------------------------------------*/ - -#ifndef resErrorDiv_H -#define resErrorDiv_H - -#include "errorEstimate.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -namespace resError -{ - // Divergence terms - - template<class Type> - tmp<errorEstimate<Type> > div - ( - const surfaceScalarField&, - const GeometricField<Type, fvPatchField, volMesh>& - ); - - template<class Type> - tmp<errorEstimate<Type> > div - ( - const tmp<surfaceScalarField>&, - const GeometricField<Type, fvPatchField, volMesh>& - ); - -} // End namespace resError - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifdef NoRepository -# include "resErrorDiv.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/errorEstimation/errorEstimate/resErrorLaplacian.C b/src/errorEstimation/errorEstimate/resErrorLaplacian.C deleted file mode 100644 index f0469851ebff28de82d99533777607b3bb2c23a7..0000000000000000000000000000000000000000 --- a/src/errorEstimation/errorEstimate/resErrorLaplacian.C +++ /dev/null @@ -1,292 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "resErrorLaplacian.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace resError -{ - -template<class Type> -tmp<errorEstimate<Type> > -laplacian -( - const GeometricField<Type, fvPatchField, volMesh>& vf -) -{ - surfaceScalarField Gamma - ( - IOobject - ( - "gamma", - vf.time().constant(), - vf.db(), - IOobject::NO_READ - ), - vf.mesh(), - dimensionedScalar("1", dimless, 1.0) - ); - - return resError::laplacian(Gamma, vf); -} - - -template<class Type> -tmp<errorEstimate<Type> > -laplacian -( - const dimensionedScalar& gamma, - const GeometricField<Type, fvPatchField, volMesh>& vf -) -{ - surfaceScalarField Gamma - ( - IOobject - ( - gamma.name(), - vf.time().timeName(), - vf.db(), - IOobject::NO_READ - ), - vf.mesh(), - gamma - ); - - return resError::laplacian(Gamma, vf); -} - - -template<class Type> -tmp<errorEstimate<Type> > -laplacian -( - const volScalarField& gamma, - const GeometricField<Type, fvPatchField, volMesh>& vf -) -{ - return resError::laplacian(fvc::interpolate(gamma), vf); -} - - -template<class Type> -tmp<errorEstimate<Type> > -laplacian -( - const tmp<volScalarField>& tgamma, - const GeometricField<Type, fvPatchField, volMesh>& vf -) -{ - tmp<errorEstimate<Type> > Laplacian(resError::laplacian(tgamma(), vf)); - tgamma.clear(); - return Laplacian; -} - - -template<class Type> -tmp<errorEstimate<Type> > -laplacian -( - const surfaceScalarField& gamma, - const GeometricField<Type, fvPatchField, volMesh>& vf -) -{ - const fvMesh& mesh = vf.mesh(); - - const scalarField& vols = mesh.V(); - const surfaceVectorField& Sf = mesh.Sf(); - const surfaceScalarField magSf(mesh.magSf()); - const fvPatchList& patches = mesh.boundary(); - const labelUList& owner = mesh.owner(); - const labelUList& neighbour = mesh.neighbour(); - - const surfaceScalarField& delta = - mesh.surfaceInterpolation::deltaCoeffs(); - - Field<Type> res(vols.size(), pTraits<Type>::zero); - scalarField aNorm(vols.size(), 0.0); - - // Calculate gradient of the solution - GeometricField - < - typename outerProduct<vector, Type>::type, fvPatchField, volMesh - > - gradVf(fvc::grad(vf)); - - // Internal faces - forAll(owner, faceI) - { - // Owner - - // Subtract diffusion - res[owner[faceI]] -= - gamma[faceI]*(Sf[faceI] & gradVf[owner[faceI]]); - - aNorm[owner[faceI]] += delta[faceI]*gamma[faceI]*magSf[faceI]; - - // Neighbour - - // Subtract diffusion - res[neighbour[faceI]] += - gamma[faceI]*(Sf[faceI] & gradVf[neighbour[faceI]]); - - aNorm[neighbour[faceI]] += delta[faceI]*gamma[faceI]*magSf[faceI]; - - } - - forAll(patches, patchI) - { - const vectorField& patchSf = Sf.boundaryField()[patchI]; - const scalarField& patchMagSf = magSf.boundaryField()[patchI]; - const scalarField& patchGamma = gamma.boundaryField()[patchI]; - const scalarField& patchDelta = delta.boundaryField()[patchI]; - - const labelList& fCells = patches[patchI].faceCells(); - - forAll(fCells, faceI) - { - // Subtract diffusion - res[fCells[faceI]] -= - patchGamma[faceI]* - ( - patchSf[faceI] & gradVf[fCells[faceI]] - ); - - aNorm[fCells[faceI]] += - patchDelta[faceI]*patchGamma[faceI]*patchMagSf[faceI]; - } - } - - res /= vols; - aNorm /= vols; - - return tmp<errorEstimate<Type> > - ( - new errorEstimate<Type> - ( - vf, - delta.dimensions()*gamma.dimensions()*magSf.dimensions() - *vf.dimensions(), - res, - aNorm - ) - ); -} - -template<class Type> -tmp<errorEstimate<Type> > -laplacian -( - const tmp<surfaceScalarField>& tgamma, - const GeometricField<Type, fvPatchField, volMesh>& vf -) -{ - tmp<errorEstimate<Type> > tresError(resError::laplacian(tgamma(), vf)); - tgamma.clear(); - return tresError; -} - - -template<class Type> -tmp<errorEstimate<Type> > -laplacian -( - const volTensorField& gamma, - const GeometricField<Type, fvPatchField, volMesh>& vf -) -{ - const fvMesh& mesh = vf.mesh(); - - return resError::laplacian - ( - (mesh.Sf() & fvc::interpolate(gamma) & mesh.Sf()) - /sqr(mesh.magSf()), - vf - ); -} - -template<class Type> -tmp<errorEstimate<Type> > -laplacian -( - const tmp<volTensorField>& tgamma, - const GeometricField<Type, fvPatchField, volMesh>& vf -) -{ - tmp<errorEstimate<Type> > Laplacian = resError::laplacian(tgamma(), vf); - tgamma.clear(); - return Laplacian; -} - - -template<class Type> -tmp<errorEstimate<Type> > -laplacian -( - const surfaceTensorField& gamma, - const GeometricField<Type, fvPatchField, volMesh>& vf -) -{ - const fvMesh& mesh = vf.mesh(); - - return resError::laplacian - ( - (mesh.Sf() & gamma & mesh.Sf())/sqr(mesh.magSf()), - vf - ); -} - -template<class Type> -tmp<errorEstimate<Type> > -laplacian -( - const tmp<surfaceTensorField>& tgamma, - const GeometricField<Type, fvPatchField, volMesh>& vf -) -{ - tmp<errorEstimate<Type> > Laplacian = resError::laplacian(tgamma(), vf); - tgamma.clear(); - return Laplacian; -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace resError - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// ************************************************************************* // - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - diff --git a/src/errorEstimation/errorEstimate/resErrorLaplacian.H b/src/errorEstimation/errorEstimate/resErrorLaplacian.H deleted file mode 100644 index ff60246f7ed4e14387dfc0b4e6506a7b01f34bf8..0000000000000000000000000000000000000000 --- a/src/errorEstimation/errorEstimate/resErrorLaplacian.H +++ /dev/null @@ -1,134 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -InNamespace - Foam::resError - -Description - Residual error estimate for the fv laplacian operators - -SourceFiles - resErrorLaplacian.C - -\*---------------------------------------------------------------------------*/ - -#ifndef resErrorLaplacian_H -#define resErrorLaplacian_H - -#include "errorEstimate.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -namespace resError -{ - // Laplacian terms - - template<class Type> - tmp<errorEstimate<Type> > laplacian - ( - const GeometricField<Type, fvPatchField, volMesh>& - ); - - template<class Type> - tmp<errorEstimate<Type> > laplacian - ( - const dimensionedScalar&, - const GeometricField<Type, fvPatchField, volMesh>& - ); - - template<class Type> - tmp<errorEstimate<Type> > laplacian - ( - const volScalarField&, - const GeometricField<Type, fvPatchField, volMesh>& - ); - - template<class Type> - tmp<errorEstimate<Type> > laplacian - ( - const tmp<volScalarField>&, - const GeometricField<Type, fvPatchField, volMesh>& - ); - - template<class Type> - tmp<errorEstimate<Type> > laplacian - ( - const surfaceScalarField&, - const GeometricField<Type, fvPatchField, volMesh>& - ); - - template<class Type> - tmp<errorEstimate<Type> > laplacian - ( - const tmp<surfaceScalarField>&, - const GeometricField<Type, fvPatchField, volMesh>& - ); - - template<class Type> - tmp<errorEstimate<Type> > laplacian - ( - const volTensorField&, - const GeometricField<Type, fvPatchField, volMesh>& - ); - - template<class Type> - tmp<errorEstimate<Type> > laplacian - ( - const tmp<volTensorField>&, - const GeometricField<Type, fvPatchField, volMesh>& - ); - - template<class Type> - tmp<errorEstimate<Type> > laplacian - ( - const surfaceTensorField&, - const GeometricField<Type, fvPatchField, volMesh>& - ); - - template<class Type> - tmp<errorEstimate<Type> > laplacian - ( - const tmp<surfaceTensorField>&, - const GeometricField<Type, fvPatchField, volMesh>& - ); -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifdef NoRepository -# include "resErrorLaplacian.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/errorEstimation/errorEstimate/resErrorSup.C b/src/errorEstimation/errorEstimate/resErrorSup.C deleted file mode 100644 index 033821c78d51b31fa033a2b9abbf70562172c692..0000000000000000000000000000000000000000 --- a/src/errorEstimation/errorEstimate/resErrorSup.C +++ /dev/null @@ -1,130 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "resErrorSup.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace resError -{ - -template<class Type> -tmp<errorEstimate<Type> > -Sp -( - const volScalarField& sp, - GeometricField<Type, fvPatchField, volMesh>& vf -) -{ - return tmp<errorEstimate<Type> > - ( - new errorEstimate<Type> - ( - vf, - sp.dimensions()*vf.dimensions(), - sp.internalField()*vf.internalField(), - scalarField(vf.internalField().size(), 0) - ) - ); -} - -template<class Type> -tmp<errorEstimate<Type> > -Sp -( - const tmp<volScalarField>& tsp, - GeometricField<Type, fvPatchField, volMesh>& vf -) -{ - tmp<errorEstimate<Type> > tee = resError::Sp(tsp(), vf); - tsp.clear(); - return tee; -} - - -template<class Type> -tmp<errorEstimate<Type> > -Sp -( - const dimensionedScalar& sp, - GeometricField<Type, fvPatchField, volMesh>& vf -) -{ - return tmp<errorEstimate<Type> > - ( - new errorEstimate<Type> - ( - vf, - sp.dimensions()*vf.dimensions(), - sp.value()*vf.internalField(), - scalarField(vf.internalField().size(), 0) - ) - ); -} - - -template<class Type> -tmp<errorEstimate<Type> > -SuSp -( - const volScalarField& sp, - GeometricField<Type, fvPatchField, volMesh>& vf -) -{ - return Sp(sp, vf); -} - -template<class Type> -tmp<errorEstimate<Type> > -SuSp -( - const tmp<volScalarField>& tsp, - GeometricField<Type, fvPatchField, volMesh>& vf -) -{ - tmp<errorEstimate<Type> > tee = resError::SuSp(tsp(), vf); - tsp.clear(); - return tee; -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace resError - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// ************************************************************************* // - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - diff --git a/src/errorEstimation/errorEstimate/resErrorSup.H b/src/errorEstimation/errorEstimate/resErrorSup.H deleted file mode 100644 index 2f38382e994a75eccfe5016b2aa5a35d6b3c9918..0000000000000000000000000000000000000000 --- a/src/errorEstimation/errorEstimate/resErrorSup.H +++ /dev/null @@ -1,106 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -InNamespace - Foam::resError - -Description - Residual error estimate for the fv source operators - -SourceFiles - resErrorSup.C - -\*---------------------------------------------------------------------------*/ - -#ifndef resErrorSup_H -#define resErrorSup_H - -#include "errorEstimate.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - - -namespace resError -{ - // Implicit source - - template<class Type> - tmp<errorEstimate<Type> > Sp - ( - const volScalarField&, - const GeometricField<Type, fvPatchField, volMesh>& - ); - - template<class Type> - tmp<errorEstimate<Type> > Sp - ( - const tmp<volScalarField>&, - const GeometricField<Type, fvPatchField, volMesh>& - ); - - - template<class Type> - tmp<errorEstimate<Type> > Sp - ( - const dimensionedScalar&, - const GeometricField<Type, fvPatchField, volMesh>& - ); - - - // Implicit/Explicit source depending on sign of coefficient - - template<class Type> - tmp<errorEstimate<Type> > SuSp - ( - const volScalarField&, - const GeometricField<Type, fvPatchField, volMesh>& - ); - - template<class Type> - tmp<errorEstimate<Type> > SuSp - ( - const tmp<volScalarField>&, - const GeometricField<Type, fvPatchField, volMesh>& - ); - -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifdef NoRepository -# include "resErrorSup.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/errorEstimation/evaluateError/evaluateError.C b/src/errorEstimation/evaluateError/evaluateError.C deleted file mode 100644 index 703118988a250ccf1b20c16567c538331fefe0c1..0000000000000000000000000000000000000000 --- a/src/errorEstimation/evaluateError/evaluateError.C +++ /dev/null @@ -1,164 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "evaluateError.H" -#include "volFields.H" -#include "surfaceFields.H" -#include "refineCell.H" - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -// Construct null -Foam::evaluateError::evaluateError() -: - unsplitFaces_(), - refCells_() -{} - - -// Construct from components -Foam::evaluateError::evaluateError -( - const volScalarField& cellError, - const volVectorField& gradTheta, - const surfaceScalarField& faceError, - const labelList& candidateFaces -) -: - unsplitFaces_(candidateFaces.size()), - refCells_() -{ - const polyMesh& mesh = cellError.mesh(); - - // picks up the error field and the gradient of the variable - // and appends lists of cells to refine/unrefine based on the width of - // standard deviation of the error distribution - - // calculate the average error - scalar avgError = cellError.average().value(); - - scalar squareError = sqr(cellError)().average().value(); - scalar deviation = sqrt(squareError - sqr(avgError)); - - Info<< "avgError:" << avgError - << " squareError:" << squareError - << " deviation:" << deviation - << endl; - - scalar ref = avgError + deviation; - scalar unref = avgError - deviation; - - Info<< "evaluateError : refinement criterion : " << ref << endl - << " unrefinement criterion : " << unref << endl; - - // Coarsen mesh first. - // Find out set of candidateFaces where error is above crit. - - // Construct to filter unrefinement pattern -// removeFaces faceRemover(mesh); - - // Keep track of unrefinement pattern. - boolList markedFace(mesh.nFaces(), false); - - label unsplitFaceI = 0; - - // Subset candidate faces and update refinement pattern interference pattern - forAll(candidateFaces, candidateFaceI) - { - label faceI = candidateFaces[candidateFaceI]; - - if (markedFace[faceI]) - { - Info<< "evaluateError : protected candidate face:" << faceI - << endl; - } - else - { -// if (faceError[faceI] < unref) - if (unsplitFaceI < (candidateFaces.size()/2 + 1)) - { - unsplitFaces_[unsplitFaceI++] = faceI; - -// faceRemover.markAffectedFaces(faceI, markedFace); - } - } - } - - unsplitFaces_.setSize(unsplitFaceI); - - // Now we have: - // -unsplitFaces_: all the faces that will be removed - // -markedFace : all the faces affected by this removal. - // From markedFace protect the cells using them. - - boolList markedCells(mesh.nCells(), false); - -// forAll(markedFace, faceI) -// { -// if (markedFace[faceI]) -// { -// markedCells[mesh.faceOwner()[faceI]] = true; -// -// if (mesh.isInternalFace(faceI)) -// { -// markedCells[mesh.faceNeighbour()[faceI]] = true; -// } -// } -// } - - // Select the cells that need to be split. - // Two pass: count first, select later. - - label refCellI = 0; - - forAll(cellError, cellI) - { - if ((cellError[cellI] > ref) && !markedCells[cellI]) - { - refCellI++; - } - } - - refCells_.setSize(refCellI); - - refCellI = 0; - - forAll(cellError, cellI) - { - if ((cellError[cellI] > ref) && !markedCells[cellI]) - { - refCells_[refCellI++] = refineCell(cellI, gradTheta[cellI]); - } - } - - Info<< "evaluateError : selected " << unsplitFaces_.size() - << " faces out of " << candidateFaces.size() << " for removal" << endl; - Info<< "evaluateError : selected " << refCells_.size() - << " cells out of " << cellError.size() << " for refinement" << endl; -} - - -// ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/adjustPhi/adjustPhi.C b/src/finiteVolume/cfdTools/general/adjustPhi/adjustPhi.C index 1bfeda1018580efb4c4b1e7565f41899f6a9b3f0..e497c361b23f6e6a63a0268b87e6407ffee60fcf 100644 --- a/src/finiteVolume/cfdTools/general/adjustPhi/adjustPhi.C +++ b/src/finiteVolume/cfdTools/general/adjustPhi/adjustPhi.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -40,7 +40,8 @@ bool Foam::adjustPhi { if (p.needReference()) { - p.boundaryField().updateCoeffs(); + // p coefficients should not be updated here + // p.boundaryField().updateCoeffs(); scalar massIn = 0.0; scalar fixedMassOut = 0.0; diff --git a/src/fvMotionSolver/motionDiffusivity/inverseDistance/inverseDistanceDiffusivity.C b/src/fvMotionSolver/motionDiffusivity/inverseDistance/inverseDistanceDiffusivity.C index 0cc744e7dd0f6ce6291b184b5cc05a7c2564ea2d..bbaae54007d396acaa61d7b03ad7f13704ac339f 100644 --- a/src/fvMotionSolver/motionDiffusivity/inverseDistance/inverseDistanceDiffusivity.C +++ b/src/fvMotionSolver/motionDiffusivity/inverseDistance/inverseDistanceDiffusivity.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/fvMotionSolver/motionDiffusivity/inverseDistance/inverseDistanceDiffusivity.H b/src/fvMotionSolver/motionDiffusivity/inverseDistance/inverseDistanceDiffusivity.H index 5e1025d1f73d2c8f3d447ba5d080be507dd54630..dc88204bd689809e6f4c3fbaeb317f5794815387 100644 --- a/src/fvMotionSolver/motionDiffusivity/inverseDistance/inverseDistanceDiffusivity.H +++ b/src/fvMotionSolver/motionDiffusivity/inverseDistance/inverseDistanceDiffusivity.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -36,6 +36,7 @@ SourceFiles #define inverseDistanceDiffusivity_H #include "uniformDiffusivity.H" +#include "wordReList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -43,7 +44,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class inverseDistanceDiffusivity Declaration + Class inverseDistanceDiffusivity Declaration \*---------------------------------------------------------------------------*/ class inverseDistanceDiffusivity @@ -53,9 +54,8 @@ class inverseDistanceDiffusivity // Private data //- Patches selected to base the distance on - // These can contain regular expressions and the actual patch names - // will be searched for. - wordList patchNames_; + // These can contain patch names or regular expressions to search for. + wordReList patchNames_; // Private Member Functions diff --git a/src/errorEstimation/errorEstimate/resError.H b/src/lagrangian/coalCombustion/coalParcel/makeCoalParcelForces.C similarity index 81% rename from src/errorEstimation/errorEstimate/resError.H rename to src/lagrangian/coalCombustion/coalParcel/makeCoalParcelForces.C index 3632de5324d00005d2c2efb3e3b9f09343ef2199..57c6806a62d50e63ee1bc26364e3b1359e4e44e4 100644 --- a/src/errorEstimation/errorEstimate/resError.H +++ b/src/lagrangian/coalCombustion/coalParcel/makeCoalParcelForces.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -21,23 +21,20 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. -Namespace - Foam::resError - -Description - Namespace for residual error estimate operators. - \*---------------------------------------------------------------------------*/ -#ifndef resError_H -#define resError_H +#include "coalParcel.H" -#include "resErrorDiv.H" -#include "resErrorLaplacian.H" -#include "resErrorSup.H" +// Using thermodynamic variant +#include "makeThermoParcelForces.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#endif +namespace Foam +{ + // Kinematic sub-models + makeThermoParcelForces(coalParcel); +}; + // ************************************************************************* // diff --git a/src/lagrangian/coalCombustion/coalParcel/makeCoalParcelSubmodels.C b/src/lagrangian/coalCombustion/coalParcel/makeCoalParcelSubmodels.C index 2bbd6777a2fe2f46b24926cfe618af98a1df3b01..66612e2e12146b56dd0827c60ab7cac0f8e9405f 100644 --- a/src/lagrangian/coalCombustion/coalParcel/makeCoalParcelSubmodels.C +++ b/src/lagrangian/coalCombustion/coalParcel/makeCoalParcelSubmodels.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -26,8 +26,8 @@ License #include "coalParcel.H" // Kinematic +#include "makeThermoParcelForces.H" // thermo variant #include "makeParcelDispersionModels.H" -#include "makeParcelDragModels.H" #include "makeReactingMultiphaseParcelInjectionModels.H" // MP variant #include "makeParcelCollisionModels.H" #include "makeParcelPatchInteractionModels.H" @@ -52,8 +52,8 @@ License namespace Foam { // Kinematic sub-models + makeThermoParcelForces(coalParcel); makeParcelDispersionModels(coalParcel); - makeParcelDragModels(coalParcel); makeReactingMultiphaseParcelInjectionModels(coalParcel); makeParcelCollisionModels(coalParcel); makeParcelPatchInteractionModels(coalParcel); diff --git a/src/lagrangian/intermediate/IntegrationScheme/Analytical/Analytical.C b/src/lagrangian/intermediate/IntegrationScheme/Analytical/Analytical.C index d7cd0687302cbaa65a5298fee5bc9475afc793a5..fb237b0d043b781b22ab361b2ad87304a722371a 100644 --- a/src/lagrangian/intermediate/IntegrationScheme/Analytical/Analytical.C +++ b/src/lagrangian/intermediate/IntegrationScheme/Analytical/Analytical.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/IntegrationScheme/Analytical/Analytical.H b/src/lagrangian/intermediate/IntegrationScheme/Analytical/Analytical.H index 50d4e50a81636bc9c9ddb8551dc3716d305dc99b..d84e44bbbabcd3af27cd2862e03020d1370dfeb4 100644 --- a/src/lagrangian/intermediate/IntegrationScheme/Analytical/Analytical.H +++ b/src/lagrangian/intermediate/IntegrationScheme/Analytical/Analytical.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/IntegrationScheme/Euler/Euler.C b/src/lagrangian/intermediate/IntegrationScheme/Euler/Euler.C index ecf0afcd344935b21af4b14226d025b6f7f19570..8e7e1aea2bb8f097f371cdc2b148f9dd0dff9c45 100644 --- a/src/lagrangian/intermediate/IntegrationScheme/Euler/Euler.C +++ b/src/lagrangian/intermediate/IntegrationScheme/Euler/Euler.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/IntegrationScheme/Euler/Euler.H b/src/lagrangian/intermediate/IntegrationScheme/Euler/Euler.H index 8731a1180795237eb473b4d3bc6df6de0a6e45f8..1140713b13a3609537318473172dc7b9953ddecd 100644 --- a/src/lagrangian/intermediate/IntegrationScheme/Euler/Euler.H +++ b/src/lagrangian/intermediate/IntegrationScheme/Euler/Euler.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/IntegrationScheme/IntegrationScheme/IntegrationScheme.C b/src/lagrangian/intermediate/IntegrationScheme/IntegrationScheme/IntegrationScheme.C index a0bc74ad3341de2ad154e6e0dd0475d729c6cb59..a91e45d90e4d3647172501554131a44963cf9d5c 100644 --- a/src/lagrangian/intermediate/IntegrationScheme/IntegrationScheme/IntegrationScheme.C +++ b/src/lagrangian/intermediate/IntegrationScheme/IntegrationScheme/IntegrationScheme.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/IntegrationScheme/IntegrationScheme/IntegrationScheme.H b/src/lagrangian/intermediate/IntegrationScheme/IntegrationScheme/IntegrationScheme.H index 1a4070c3ecb852a3bf9bb09052b721723befec74..1cefd5ef5971730405bc7c97a29f7b233133f439 100644 --- a/src/lagrangian/intermediate/IntegrationScheme/IntegrationScheme/IntegrationScheme.H +++ b/src/lagrangian/intermediate/IntegrationScheme/IntegrationScheme/IntegrationScheme.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/IntegrationScheme/IntegrationScheme/IntegrationSchemeNew.C b/src/lagrangian/intermediate/IntegrationScheme/IntegrationScheme/IntegrationSchemeNew.C index 0773e1d418d807024ea017c44b386ad02267475a..121ad0cf9d5b92c29ec3494d19e247e6760c3e85 100644 --- a/src/lagrangian/intermediate/IntegrationScheme/IntegrationScheme/IntegrationSchemeNew.C +++ b/src/lagrangian/intermediate/IntegrationScheme/IntegrationScheme/IntegrationSchemeNew.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/IntegrationScheme/IntegrationScheme/IntegrationSchemesFwd.H b/src/lagrangian/intermediate/IntegrationScheme/IntegrationScheme/IntegrationSchemesFwd.H index c0e0b7ed04ea906fd18e69058b644cce0912832e..d6638b127e3169ce44c5bc7c0d24b830ac983cc9 100644 --- a/src/lagrangian/intermediate/IntegrationScheme/IntegrationScheme/IntegrationSchemesFwd.H +++ b/src/lagrangian/intermediate/IntegrationScheme/IntegrationScheme/IntegrationSchemesFwd.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/IntegrationScheme/makeIntegrationSchemes.C b/src/lagrangian/intermediate/IntegrationScheme/makeIntegrationSchemes.C index 28f828460f05ef3d662f27d0c97924bac4549a78..c31058f237992c54025277f8f8960d75a1dabb97 100644 --- a/src/lagrangian/intermediate/IntegrationScheme/makeIntegrationSchemes.C +++ b/src/lagrangian/intermediate/IntegrationScheme/makeIntegrationSchemes.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/Make/files b/src/lagrangian/intermediate/Make/files index 63fa90db0d1b6862dbfa403e0f81128cf8690e6d..2a1ea126f0a9d5b62c9393c4360218dcc77201e9 100644 --- a/src/lagrangian/intermediate/Make/files +++ b/src/lagrangian/intermediate/Make/files @@ -78,10 +78,6 @@ $(REACTINGMPINJECTION)/ReactingMultiphaseLookupTableInjection/reactingMultiphase IntegrationScheme/makeIntegrationSchemes.C -/* particle forces */ -particleForces/particleForces.C - - /* phase properties */ phaseProperties/phaseProperties/phaseProperties.C phaseProperties/phaseProperties/phasePropertiesIO.C diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C index fc589f538808e79a52dbb1606aa8ad804c7c0bb9..d48136443d0f5d1e5df02c8d104147e017023a94 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -30,7 +30,6 @@ License #include "CollisionModel.H" #include "DispersionModel.H" -#include "DragModel.H" #include "InjectionModel.H" #include "PatchInteractionModel.H" #include "PostProcessingModel.H" @@ -209,15 +208,6 @@ void Foam::KinematicCloud<ParcelType>::setModels() ).ptr() ); - dragModel_.reset - ( - DragModel<KinematicCloud<ParcelType> >::New - ( - subModelProperties_, - *this - ).ptr() - ); - injectionModel_.reset ( InjectionModel<KinematicCloud<ParcelType> >::New @@ -306,7 +296,7 @@ void Foam::KinematicCloud<ParcelType>::preEvolve() Info<< "\nSolving cloud " << this->name() << endl; this->dispersion().cacheFields(true); - forces_.cacheFields(true, solution_.interpolationSchemes()); + forces_.cacheFields(true); updateCellOccupancy(); } @@ -390,7 +380,7 @@ void Foam::KinematicCloud<ParcelType>::evolveCloud } else { -// this->surfaceFilm().injectStreadyState(td); +// this->surfaceFilm().injectSteadyState(td); this->injection().injectSteadyState(td, solution_.deltaT()); @@ -473,7 +463,7 @@ void Foam::KinematicCloud<ParcelType>::postEvolve() } this->dispersion().cacheFields(false); - forces_.cacheFields(false, solution_.interpolationSchemes()); + forces_.cacheFields(false); this->postProcessing().post(); @@ -488,14 +478,15 @@ void Foam::KinematicCloud<ParcelType>::cloudReset(KinematicCloud<ParcelType>& c) rndGen_ = c.rndGen_; - collisionModel_ = c.collisionModel_->clone(); - dispersionModel_= c.dispersionModel_->clone(); - dragModel_ = c.dragModel_->clone(); - injectionModel_ = c.injectionModel_->clone(); - patchInteractionModel_ = c.patchInteractionModel_->clone(); - postProcessingModel_ = c.postProcessingModel_->clone(); + forces_.transfer(c.forces_); + + collisionModel_.reset(c.collisionModel_.ptr()); + dispersionModel_.reset(c.dispersionModel_.ptr()); + injectionModel_.reset(c.injectionModel_.ptr()); + patchInteractionModel_.reset(c.patchInteractionModel_.ptr()); + postProcessingModel_.reset(c.postProcessingModel_.ptr()); - UIntegrator_ = c.UIntegrator_->clone(); + UIntegrator_.reset(c.UIntegrator_.ptr()); } @@ -529,7 +520,10 @@ Foam::KinematicCloud<ParcelType>::KinematicCloud ), solution_(mesh_, particleProperties_.subDict("solution")), constProps_(particleProperties_, solution_.active()), - subModelProperties_(particleProperties_.subOrEmptyDict("subModels")), + subModelProperties_ + ( + particleProperties_.subOrEmptyDict("subModels", solution_.active()) + ), rndGen_ ( label(0), @@ -540,10 +534,19 @@ Foam::KinematicCloud<ParcelType>::KinematicCloud U_(U), mu_(mu), g_(g), - forces_(mesh_, particleProperties_, g_.value(), solution_.active()), + forces_ + ( + *this, + mesh_, + subModelProperties_.subOrEmptyDict + ( + "particleForces", + solution_.active() + ), + solution_.active() + ), collisionModel_(NULL), dispersionModel_(NULL), - dragModel_(NULL), injectionModel_(NULL), patchInteractionModel_(NULL), postProcessingModel_(NULL), @@ -606,7 +609,7 @@ Foam::KinematicCloud<ParcelType>::KinematicCloud const word& name ) : - Cloud<ParcelType>(c.mesh(), name, c), + Cloud<ParcelType>(c.mesh_, name, c), kinematicCloud(), cloudCopyPtr_(NULL), mesh_(c.mesh_), @@ -623,7 +626,6 @@ Foam::KinematicCloud<ParcelType>::KinematicCloud forces_(c.forces_), collisionModel_(c.collisionModel_->clone()), dispersionModel_(c.dispersionModel_->clone()), - dragModel_(c.dragModel_->clone()), injectionModel_(c.injectionModel_->clone()), patchInteractionModel_(c.patchInteractionModel_->clone()), postProcessingModel_(c.postProcessingModel_->clone()), @@ -661,7 +663,6 @@ Foam::KinematicCloud<ParcelType>::KinematicCloud c.UCoeff_() ) ) - {} @@ -698,10 +699,9 @@ Foam::KinematicCloud<ParcelType>::KinematicCloud U_(c.U_), mu_(c.mu_), g_(c.g_), - forces_(mesh), + forces_(*this, mesh), collisionModel_(NULL), dispersionModel_(NULL), - dragModel_(NULL), injectionModel_(NULL), patchInteractionModel_(NULL), postProcessingModel_(NULL), @@ -830,8 +830,10 @@ void Foam::KinematicCloud<ParcelType>::info() const << linearKineticEnergy << nl << " Rotational kinetic energy = " << rotationalKineticEnergy << nl; + this->injection().info(Info); this->surfaceFilm().info(Info); + this->patchInteraction().info(Info); } diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H index b1020c1e205b53eac74b9d8d515a545084433e87..50e8d182aa3abf0589996a8be935e08bea987341 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,10 +29,14 @@ Description - holds a 'cloudSolution' class that stores all relevant solution info + - particle forces + - buoyancy + - drag + - pressure gradient + - sub-models: - Collision model - Dispersion model - - Drag model - Injection model - Patch interaction model - Post-processing model @@ -55,7 +59,6 @@ SourceFiles #include "fvMesh.H" #include "volFields.H" #include "fvMatrices.H" -#include "particleForces.H" #include "IntegrationSchemesFwd.H" @@ -72,9 +75,6 @@ class CollisionModel; template<class CloudType> class DispersionModel; -template<class CloudType> -class DragModel; - template<class CloudType> class InjectionModel; @@ -98,6 +98,14 @@ class KinematicCloud public Cloud<ParcelType>, public kinematicCloud { +public: + + //- Type of parcel the cloud was instantiated for + typedef ParcelType parcelType; + + +private: + // Private data //- Cloud copy pointer @@ -316,7 +324,7 @@ protected: //- Optional particle forces - particleForces forces_; + typename ParcelType::forceType forces_; // References to the cloud sub-models @@ -329,9 +337,6 @@ protected: autoPtr<DispersionModel<KinematicCloud<ParcelType> > > dispersionModel_; - //- Drag transfer model - autoPtr<DragModel<KinematicCloud<ParcelType> > > dragModel_; - //- Injector model autoPtr<InjectionModel<KinematicCloud<ParcelType> > > injectionModel_; @@ -450,10 +455,6 @@ public: virtual ~KinematicCloud(); - //- Type of parcel the cloud was instantiated for - typedef ParcelType parcelType; - - // Member Functions // Access @@ -521,7 +522,7 @@ public: //- Optional particle forces - inline const particleForces& forces() const; + inline const typename ParcelType::forceType& forces() const; // Sub-models @@ -542,10 +543,6 @@ public: inline DispersionModel<KinematicCloud<ParcelType> >& dispersion(); - //- Return const-access to the drag model - inline const DragModel<KinematicCloud<ParcelType> >& - drag() const; - //- Return const access to the injection model inline const InjectionModel<KinematicCloud<ParcelType> >& injection() const; @@ -558,6 +555,10 @@ public: inline const PatchInteractionModel<KinematicCloud<ParcelType> >& patchInteraction() const; + //- Return reference to the patch interaction model + inline PatchInteractionModel<KinematicCloud<ParcelType> >& + patchInteraction(); + //- Return reference to post-processing model inline PostProcessingModel<KinematicCloud<ParcelType> >& postProcessing(); diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H index 457e39abaea74035ca1a49833280c4461eba3dd4..4c710fa797be98039fb4f54133792df801dcecc4 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -257,7 +257,7 @@ Foam::KinematicCloud<ParcelType>::g() const template<class ParcelType> -inline const Foam::particleForces& +inline const typename ParcelType::forceType& Foam::KinematicCloud<ParcelType>::forces() const { return forces_; @@ -296,14 +296,6 @@ Foam::KinematicCloud<ParcelType>::dispersion() } -template<class ParcelType> -inline const Foam::DragModel<Foam::KinematicCloud<ParcelType> >& -Foam::KinematicCloud<ParcelType>::drag() const -{ - return dragModel_; -} - - template<class ParcelType> inline const Foam::InjectionModel<Foam::KinematicCloud<ParcelType> >& Foam::KinematicCloud<ParcelType>::injection() const @@ -320,6 +312,14 @@ Foam::KinematicCloud<ParcelType>::patchInteraction() const } +template<class ParcelType> +inline Foam::PatchInteractionModel<Foam::KinematicCloud<ParcelType> >& +Foam::KinematicCloud<ParcelType>::patchInteraction() +{ + return patchInteractionModel_(); +} + + template<class ParcelType> inline Foam::InjectionModel<Foam::KinematicCloud<ParcelType> >& Foam::KinematicCloud<ParcelType>::injection() diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C index a8bb92cb5a8dc0575f555087b9bb9416b8b4f3ff..fdbf5247814bd026c1a83bbff754f457a94490d2 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -85,8 +85,8 @@ void Foam::ReactingCloud<ParcelType>::cloudReset(ReactingCloud<ParcelType>& c) { ThermoCloud<ParcelType>::cloudReset(c); - compositionModel_ = c.compositionModel_->clone(); - phaseChangeModel_ = c.phaseChangeModel_->clone(); + compositionModel_.reset(c.compositionModel_.ptr()); + phaseChangeModel_.reset(c.phaseChangeModel_.ptr()); dMassPhaseChange_ = c.dMassPhaseChange_; } diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.H b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.H index 1ffbff55de7039ad45ec669fc79974183ecc2fe5..9db309ff096963bb2d6076d1abaa8ca1b64c9431 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.H +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloudI.H b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloudI.H index 5fb203910dd1246b4c466d69d18cd02e02f6a2ff..9d32a24134fe33d4e05d1c7699a1f825cfc7bde4 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloudI.H +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloudI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C b/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C index 06dc0c339be8d383ff4de05e75ad55420c80b564..7cd42b7355c001061dd6bebe2c5f42a3954498b8 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C @@ -61,8 +61,8 @@ void Foam::ReactingMultiphaseCloud<ParcelType>::cloudReset { ReactingCloud<ParcelType>::cloudReset(c); - devolatilisationModel_ = c.devolatilisationModel_->clone(); - surfaceReactionModel_ = c.surfaceReactionModel_->clone(); + devolatilisationModel_.reset(c.devolatilisationModel_.ptr()); + surfaceReactionModel_.reset(c.surfaceReactionModel_.ptr()); dMassDevolatilisation_ = c.dMassDevolatilisation_; dMassSurfaceReaction_ = c.dMassSurfaceReaction_; diff --git a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C index ae26e7999dc90174e77fc45ff1789bd58509c369..1bd69843b7fbd56ef8082e3a55e75f530244ac92 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -60,8 +60,8 @@ void Foam::ThermoCloud<ParcelType>::cloudReset(ThermoCloud<ParcelType>& c) { KinematicCloud<ParcelType>::cloudReset(c); - heatTransferModel_ = c.heatTransferModel_->clone(); - TIntegrator_ = c.TIntegrator_->clone(); + heatTransferModel_.reset(c.heatTransferModel_.ptr()); + TIntegrator_.reset(c.TIntegrator_.ptr()); radiation_ = c.radiation_; } diff --git a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.H b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.H index b2dc16dd672a0868abb27df73e206b2e455bafa9..a9daf9c22d8b480167386b628fa74ce1eb3e8c83 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.H +++ b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudI.H b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudI.H index 7b0dcac9dfed3cdfabc1f8422fbfb2d543dc915d..f0d08a8216fc0b70c3a2bf28cf4d71a59f19e979 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudI.H +++ b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/clouds/baseClasses/kinematicCloud/kinematicCloud.C b/src/lagrangian/intermediate/clouds/baseClasses/kinematicCloud/kinematicCloud.C index c5d142e1b5a078c5038e14117b5bf49c0d7aa9de..be818774f59d9260f663a419d5f42c7b06eaae89 100644 --- a/src/lagrangian/intermediate/clouds/baseClasses/kinematicCloud/kinematicCloud.C +++ b/src/lagrangian/intermediate/clouds/baseClasses/kinematicCloud/kinematicCloud.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/clouds/baseClasses/kinematicCloud/kinematicCloud.H b/src/lagrangian/intermediate/clouds/baseClasses/kinematicCloud/kinematicCloud.H index 6422dc8dc9f6cc4500ea5e0209684b195562bfa3..688018db7249bbbe3db51bdfe542db7c9c605154 100644 --- a/src/lagrangian/intermediate/clouds/baseClasses/kinematicCloud/kinematicCloud.H +++ b/src/lagrangian/intermediate/clouds/baseClasses/kinematicCloud/kinematicCloud.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/clouds/baseClasses/reactingCloud/reactingCloud.C b/src/lagrangian/intermediate/clouds/baseClasses/reactingCloud/reactingCloud.C index a5931f029d510d88b225b86e4ab864aac0bda304..e6654070ae579c5333a7ffad97cc8bad78b10774 100644 --- a/src/lagrangian/intermediate/clouds/baseClasses/reactingCloud/reactingCloud.C +++ b/src/lagrangian/intermediate/clouds/baseClasses/reactingCloud/reactingCloud.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/clouds/baseClasses/reactingCloud/reactingCloud.H b/src/lagrangian/intermediate/clouds/baseClasses/reactingCloud/reactingCloud.H index 74374cde9878c79307f4b37bef43c051fcc01bf2..de6e8e0e4e1c50387b5979016e92a7183552e36c 100644 --- a/src/lagrangian/intermediate/clouds/baseClasses/reactingCloud/reactingCloud.H +++ b/src/lagrangian/intermediate/clouds/baseClasses/reactingCloud/reactingCloud.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/clouds/baseClasses/thermoCloud/thermoCloud.C b/src/lagrangian/intermediate/clouds/baseClasses/thermoCloud/thermoCloud.C index ff11e19ce0c750f7f2183a562711a3354f09021b..4ad84c2ef97bd83f1821168caf2d1b91f74a44ed 100644 --- a/src/lagrangian/intermediate/clouds/baseClasses/thermoCloud/thermoCloud.C +++ b/src/lagrangian/intermediate/clouds/baseClasses/thermoCloud/thermoCloud.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/clouds/baseClasses/thermoCloud/thermoCloud.H b/src/lagrangian/intermediate/clouds/baseClasses/thermoCloud/thermoCloud.H index 26a5d361c290c7f2bb345e1b108406b058f16eb4..7b85edc90f14f905541c2a185983df21a89ca690 100644 --- a/src/lagrangian/intermediate/clouds/baseClasses/thermoCloud/thermoCloud.H +++ b/src/lagrangian/intermediate/clouds/baseClasses/thermoCloud/thermoCloud.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/clouds/derived/basicKinematicCloud/basicKinematicCloud.H b/src/lagrangian/intermediate/clouds/derived/basicKinematicCloud/basicKinematicCloud.H index f8b68f60f6537f5d5e00a3dd6c69bca7e1ed03c3..7770dbb68d008a5513de4ce983a24455893be413 100644 --- a/src/lagrangian/intermediate/clouds/derived/basicKinematicCloud/basicKinematicCloud.H +++ b/src/lagrangian/intermediate/clouds/derived/basicKinematicCloud/basicKinematicCloud.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/clouds/derived/basicReactingCloud/basicReactingCloud.H b/src/lagrangian/intermediate/clouds/derived/basicReactingCloud/basicReactingCloud.H index 9a0f448b4817ba414a8f28b53b32d9a2843de4b5..b93b0eda05ec5ce62e41f05d8b2c2cb22666f9a3 100644 --- a/src/lagrangian/intermediate/clouds/derived/basicReactingCloud/basicReactingCloud.H +++ b/src/lagrangian/intermediate/clouds/derived/basicReactingCloud/basicReactingCloud.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/clouds/derived/basicThermoCloud/basicThermoCloud.H b/src/lagrangian/intermediate/clouds/derived/basicThermoCloud/basicThermoCloud.H index d1c1cd7cce73774657d49833e2cc1b413e1cb13e..df00dc82cb6d8f037ddc1c05c3f59042f66f1045 100644 --- a/src/lagrangian/intermediate/clouds/derived/basicThermoCloud/basicThermoCloud.H +++ b/src/lagrangian/intermediate/clouds/derived/basicThermoCloud/basicThermoCloud.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C index c2310d345395dd7b02ba74bdc79d6bcb8788914d..1fe4aa29d017debe72cc64b51818c433dae8ef6c 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -42,16 +42,19 @@ void Foam::KinematicParcel<ParcelType>::setCellValues if (rhoc_ < td.cloud().constProps().rhoMin()) { - WarningIn - ( - "void Foam::KinematicParcel<ParcelType>::setCellValues" - "(" - "TrackData&, " - "const scalar, " - "const label" - ")" - ) << "Limiting observed density in cell " << cellI << " to " - << td.cloud().constProps().rhoMin() << nl << endl; + if (debug) + { + WarningIn + ( + "void Foam::KinematicParcel<ParcelType>::setCellValues" + "(" + "TrackData&, " + "const scalar, " + "const label" + ")" + ) << "Limiting observed density in cell " << cellI << " to " + << td.cloud().constProps().rhoMin() << nl << endl; + } rhoc_ = td.cloud().constProps().rhoMin(); } @@ -176,46 +179,21 @@ const Foam::vector Foam::KinematicParcel<ParcelType>::calcVelocity scalar& Cud ) const { - const polyMesh& mesh = this->cloud().pMesh(); - - // Momentum transfer coefficient - const scalar utc = td.cloud().drag().utc(Re, d, mu) + ROOTVSMALL; - - tetIndices tetIs = this->currentTetIndices(); + const typename ParcelType::forceType& forces = td.cloud().forces(); // Momentum source due to particle forces - const vector Fcp = mass*td.cloud().forces().calcCoupled - ( - this->position(), - tetIs, - dt, - rhoc_, - rho, - Uc_, - U, - d - ); - - const vector Fncp = mass*td.cloud().forces().calcNonCoupled - ( - this->position(), - tetIs, - dt, - rhoc_, - rho, - Uc_, - U, - d - ); + const ParcelType& p = static_cast<const ParcelType&>(*this); + const forceSuSp Fcp = forces.calcCoupled(p, dt, mass, Re, mu); + const forceSuSp Fncp = forces.calcNonCoupled(p, dt, mass, Re, mu); + const forceSuSp Feff = Fcp + Fncp; // New particle velocity //~~~~~~~~~~~~~~~~~~~~~~ // Update velocity - treat as 3-D - const scalar As = this->areaS(d); - const vector ap = Uc_ + (Fcp + Fncp + Su)/(utc*As); - const scalar bp = 6.0*utc/(rho*d); + const vector ap = Uc_ + (Feff.Su() + Su)/(Feff.Sp() + ROOTVSMALL); + const scalar bp = Feff.Sp()/mass; Cud = bp; @@ -224,9 +202,10 @@ const Foam::vector Foam::KinematicParcel<ParcelType>::calcVelocity vector Unew = Ures.value(); - dUTrans += dt*(utc*As*(Ures.average() - Uc_) - Fcp); + dUTrans += dt*(Feff.Sp()*(Ures.average() - Uc_) - Fcp.Su()); // Apply correction to velocity and dUTrans for reduced-D cases + const polyMesh& mesh = this->cloud().pMesh(); meshTools::constrainDirection(mesh, mesh.solutionD(), Unew); meshTools::constrainDirection(mesh, mesh.solutionD(), dUTrans); diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H index 003e07ee4609e4c60f548b532d941207bb74e13a..838c8bf9d6a8a75026ddf15bf92866f397ddbcc7 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -56,6 +56,8 @@ SourceFiles #include "labelFieldIOField.H" #include "vectorFieldIOField.H" +#include "ParticleForceList.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -88,6 +90,10 @@ class KinematicParcel { public: + //- Type of force to be used by this parcel type + typedef ParticleForceList<KinematicCloud<ParcelType> > forceType; + + //- Class to hold kinematic particle constant properties class constantProperties { @@ -456,6 +462,15 @@ public: //- Return const access to turbulent velocity fluctuation inline const vector& UTurb() const; + //- Return const access to carrier density [kg/m3] + inline scalar rhoc() const; + + //- Return const access to carrier velocity [m/s] + inline const vector& Uc() const; + + //- Return const access to carrier viscosity [Pa.s] + inline scalar muc() const; + //- Return const access to the collision records inline const collisionRecordList& collisionRecords() const; diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelI.H b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelI.H index bdf143cbe59f27d8e38a8ce6634f70e1f8c7c3d0..c4cd31b5d3ad15be6127e100f5ec69d19aeac508 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelI.H +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -409,6 +409,27 @@ inline const Foam::vector& Foam::KinematicParcel<ParcelType>::UTurb() const } +template <class ParcelType> +inline Foam::scalar Foam::KinematicParcel<ParcelType>::rhoc() const +{ + return rhoc_; +} + + +template <class ParcelType> +inline const Foam::vector& Foam::KinematicParcel<ParcelType>::Uc() const +{ + return Uc_; +} + + +template <class ParcelType> +inline Foam::scalar Foam::KinematicParcel<ParcelType>::muc() const +{ + return muc_; +} + + template<class ParcelType> inline bool& Foam::KinematicParcel<ParcelType>::active() { diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelIO.C b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelIO.C index a443be57ccac50ec41f85a6058912d5fb19de466..b2b4dd822def66dc6cbda4b25fcb0af774398a0e 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelIO.C +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.C b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.C index 968b1cedf656eb26871d3ce0adc528ca30f8ace0..c8e625b9196ce136b66d0a2f22f235f16f3504d0 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.C +++ b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.H b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.H index 3b1769bb404f3bb49589e84e896ed38c6dc34487..c6caeaa2bd194c866cb14d6723968b1e72cb3914 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcelI.H b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcelI.H index e94168189270d56b1ed31ebd21dcc02f0ab76742..beee35182037ed1ffc146200718f91591ca10712 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcelI.H +++ b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcelI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcelIO.C b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcelIO.C index 5ed5fad18575f349f30e034cfd86b51c80812583..cea90982383875b88f72bb8e16e5ff9c408fca43 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcelIO.C +++ b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcelIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.C b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.C index 153ac45fa62c484e888abcc010cb05db9b42e50d..06b6f45cd4da877e98a46e0232bc72040b783193 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.C +++ b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.H b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.H index e455c1773e5ce041b4f03c4068b7da7982b0da59..ff74006c10bc074a17438e9230acb70e7d3a14dc 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -344,6 +344,12 @@ public: //- Return the parcel sensible enthalpy inline scalar hs() const; + //- Return const access to carrier temperature + inline scalar Tc() const; + + //- Return const access to carrier specific heat capacity + inline scalar Cpc() const; + // Edit diff --git a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelI.H b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelI.H index ada4b93a102104d2d8148003926e139862eb0f4f..8a7d37d9caafd2cd8a49ed9607212537bfc36954 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelI.H +++ b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -321,6 +321,20 @@ inline Foam::scalar Foam::ThermoParcel<ParcelType>::hs() const } +template<class ParcelType> +inline Foam::scalar Foam::ThermoParcel<ParcelType>::Tc() const +{ + return Tc_; +} + + +template<class ParcelType> +inline Foam::scalar Foam::ThermoParcel<ParcelType>::Cpc() const +{ + return Cpc_; +} + + template<class ParcelType> inline Foam::scalar& Foam::ThermoParcel<ParcelType>::T() { diff --git a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelIO.C b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelIO.C index 8ee98bf04b4fc887ab5ad1cc5f246a3b1c9ce8f9..d052abebae2a33233c0ee73035f0bf8a425015ae 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelIO.C +++ b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/parcels/derived/basicKinematicParcel/basicKinematicParcel.C b/src/lagrangian/intermediate/parcels/derived/basicKinematicParcel/basicKinematicParcel.C index 08354f921d5556d5eccf7da35bad95de8bfb34ed..b24d5b8cf3a230465a80d2ffbb32b7c836ace540 100644 --- a/src/lagrangian/intermediate/parcels/derived/basicKinematicParcel/basicKinematicParcel.C +++ b/src/lagrangian/intermediate/parcels/derived/basicKinematicParcel/basicKinematicParcel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/parcels/derived/basicKinematicParcel/basicKinematicParcel.H b/src/lagrangian/intermediate/parcels/derived/basicKinematicParcel/basicKinematicParcel.H index 0b1ee82718d57d034be86af1858ecbebc2ebcfd0..38c1a2fbf780336d809f6d0c794a02ed713bd8b2 100644 --- a/src/lagrangian/intermediate/parcels/derived/basicKinematicParcel/basicKinematicParcel.H +++ b/src/lagrangian/intermediate/parcels/derived/basicKinematicParcel/basicKinematicParcel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/parcels/derived/basicKinematicParcel/defineBasicKinematicParcel.C b/src/lagrangian/intermediate/parcels/derived/basicKinematicParcel/defineBasicKinematicParcel.C index 6690d560719a73950158f61e00c493324ab00620..6fbffda440f4ac592d836f324d415eb152f65660 100644 --- a/src/lagrangian/intermediate/parcels/derived/basicKinematicParcel/defineBasicKinematicParcel.C +++ b/src/lagrangian/intermediate/parcels/derived/basicKinematicParcel/defineBasicKinematicParcel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/parcels/derived/basicKinematicParcel/makeBasicKinematicParcelSubmodels.C b/src/lagrangian/intermediate/parcels/derived/basicKinematicParcel/makeBasicKinematicParcelSubmodels.C index 27c54abfd29b80a0d69128a61387a8033d223c28..c869ceeac0180472f343abb57502dfaa511a8b50 100644 --- a/src/lagrangian/intermediate/parcels/derived/basicKinematicParcel/makeBasicKinematicParcelSubmodels.C +++ b/src/lagrangian/intermediate/parcels/derived/basicKinematicParcel/makeBasicKinematicParcelSubmodels.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -26,8 +26,8 @@ License #include "basicKinematicParcel.H" // Kinematic +#include "makeParcelForces.H" #include "makeParcelDispersionModels.H" -#include "makeParcelDragModels.H" #include "makeParcelInjectionModels.H" #include "makeParcelCollisionModels.H" #include "makeParcelPatchInteractionModels.H" @@ -39,8 +39,8 @@ License namespace Foam { // Kinematic sub-models + makeParcelForces(basicKinematicParcel); makeParcelDispersionModels(basicKinematicParcel); - makeParcelDragModels(basicKinematicParcel); makeParcelInjectionModels(basicKinematicParcel); makeParcelCollisionModels(basicKinematicParcel); makeParcelPatchInteractionModels(basicKinematicParcel); diff --git a/src/lagrangian/intermediate/parcels/derived/basicReactingMultiphaseParcel/makeBasicReactingMultiphaseParcelSubmodels.C b/src/lagrangian/intermediate/parcels/derived/basicReactingMultiphaseParcel/makeBasicReactingMultiphaseParcelSubmodels.C index fa38f8a5e2f6e5a47089dd36e1fe5e7ba0caeac3..d7c2c700543ddbf326c241f07df61cacd0c5d8a3 100644 --- a/src/lagrangian/intermediate/parcels/derived/basicReactingMultiphaseParcel/makeBasicReactingMultiphaseParcelSubmodels.C +++ b/src/lagrangian/intermediate/parcels/derived/basicReactingMultiphaseParcel/makeBasicReactingMultiphaseParcelSubmodels.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -26,8 +26,8 @@ License #include "basicReactingMultiphaseParcel.H" // Kinematic +#include "makeThermoParcelForces.H" // thermo variant #include "makeParcelDispersionModels.H" -#include "makeParcelDragModels.H" #include "makeReactingMultiphaseParcelInjectionModels.H" // MP variant #include "makeParcelCollisionModels.H" #include "makeParcelPatchInteractionModels.H" @@ -50,8 +50,8 @@ License namespace Foam { // Kinematic sub-models + makeThermoParcelForces(basicReactingMultiphaseParcel); makeParcelDispersionModels(basicReactingMultiphaseParcel); - makeParcelDragModels(basicReactingMultiphaseParcel); makeReactingMultiphaseParcelInjectionModels(basicReactingMultiphaseParcel); makeParcelCollisionModels(basicReactingMultiphaseParcel); makeParcelPatchInteractionModels(basicReactingMultiphaseParcel); diff --git a/src/lagrangian/intermediate/parcels/derived/basicReactingParcel/basicReactingParcel.C b/src/lagrangian/intermediate/parcels/derived/basicReactingParcel/basicReactingParcel.C index e0e92c019dfe33543b250d2ed34c4023b1e4a0ec..d5b6285842600197368ab88b6c7e0200e6a033fa 100644 --- a/src/lagrangian/intermediate/parcels/derived/basicReactingParcel/basicReactingParcel.C +++ b/src/lagrangian/intermediate/parcels/derived/basicReactingParcel/basicReactingParcel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/parcels/derived/basicReactingParcel/basicReactingParcel.H b/src/lagrangian/intermediate/parcels/derived/basicReactingParcel/basicReactingParcel.H index fdf25bf369c18b20059c15d9d36e64b5a1b8b20e..3302aa5150698c4be6c957f2ef37d888ace4a3b4 100644 --- a/src/lagrangian/intermediate/parcels/derived/basicReactingParcel/basicReactingParcel.H +++ b/src/lagrangian/intermediate/parcels/derived/basicReactingParcel/basicReactingParcel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/parcels/derived/basicReactingParcel/defineBasicReactingParcel.C b/src/lagrangian/intermediate/parcels/derived/basicReactingParcel/defineBasicReactingParcel.C index dabe1f9c455fdd1331b90e323ff3658ddf0d4d81..98bab313c4a81c2c4a91fba0bed5e1b89d89093d 100644 --- a/src/lagrangian/intermediate/parcels/derived/basicReactingParcel/defineBasicReactingParcel.C +++ b/src/lagrangian/intermediate/parcels/derived/basicReactingParcel/defineBasicReactingParcel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/parcels/derived/basicReactingParcel/makeBasicReactingParcelSubmodels.C b/src/lagrangian/intermediate/parcels/derived/basicReactingParcel/makeBasicReactingParcelSubmodels.C index b1e3978011513b76fb13b016a2dca49df7e8f55a..cad82ff4c49a68f0cca293f87be320ac467a000b 100644 --- a/src/lagrangian/intermediate/parcels/derived/basicReactingParcel/makeBasicReactingParcelSubmodels.C +++ b/src/lagrangian/intermediate/parcels/derived/basicReactingParcel/makeBasicReactingParcelSubmodels.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -26,8 +26,8 @@ License #include "basicReactingParcel.H" // Kinematic +#include "makeThermoParcelForces.H" // thermo variant #include "makeParcelDispersionModels.H" -#include "makeParcelDragModels.H" #include "makeReactingParcelInjectionModels.H" // Reacting variant #include "makeParcelCollisionModels.H" #include "makeParcelPatchInteractionModels.H" @@ -46,8 +46,8 @@ License namespace Foam { // Kinematic sub-models + makeThermoParcelForces(basicReactingParcel); makeParcelDispersionModels(basicReactingParcel); - makeParcelDragModels(basicReactingParcel); makeReactingParcelInjectionModels(basicReactingParcel); makeParcelCollisionModels(basicReactingParcel); makeParcelPatchInteractionModels(basicReactingParcel); diff --git a/src/lagrangian/intermediate/parcels/derived/basicThermoParcel/basicThermoParcel.C b/src/lagrangian/intermediate/parcels/derived/basicThermoParcel/basicThermoParcel.C index a8b739141a4194df3cba1231dbd7c5186587ae24..2c26932342c5d9bc19e6d9ea131190e1f0757503 100644 --- a/src/lagrangian/intermediate/parcels/derived/basicThermoParcel/basicThermoParcel.C +++ b/src/lagrangian/intermediate/parcels/derived/basicThermoParcel/basicThermoParcel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/parcels/derived/basicThermoParcel/basicThermoParcel.H b/src/lagrangian/intermediate/parcels/derived/basicThermoParcel/basicThermoParcel.H index 1d8c9e5cc7b30bbaf708be23960ab37c1f9edf49..f48a1b32565effbb14f5efe98082b557248db98c 100644 --- a/src/lagrangian/intermediate/parcels/derived/basicThermoParcel/basicThermoParcel.H +++ b/src/lagrangian/intermediate/parcels/derived/basicThermoParcel/basicThermoParcel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/parcels/derived/basicThermoParcel/makeBasicThermoParcelSubmodels.C b/src/lagrangian/intermediate/parcels/derived/basicThermoParcel/makeBasicThermoParcelSubmodels.C index 289e6d38cd0bbb391c85eae4accb1ef5529082f4..91a2c975d40e75bbcf42063d8c5e837832d97148 100644 --- a/src/lagrangian/intermediate/parcels/derived/basicThermoParcel/makeBasicThermoParcelSubmodels.C +++ b/src/lagrangian/intermediate/parcels/derived/basicThermoParcel/makeBasicThermoParcelSubmodels.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -26,8 +26,8 @@ License #include "basicThermoParcel.H" // Kinematic +#include "makeThermoParcelForces.H" // thermo variant #include "makeParcelDispersionModels.H" -#include "makeParcelDragModels.H" #include "makeParcelInjectionModels.H" #include "makeParcelCollisionModels.H" #include "makeParcelPatchInteractionModels.H" @@ -42,8 +42,8 @@ License namespace Foam { // Kinematic sub-models + makeThermoParcelForces(basicThermoParcel); makeParcelDispersionModels(basicThermoParcel); - makeParcelDragModels(basicThermoParcel); makeParcelInjectionModels(basicThermoParcel); makeParcelCollisionModels(basicThermoParcel); makeParcelPatchInteractionModels(basicThermoParcel); diff --git a/src/lagrangian/intermediate/parcels/include/makeParcelForces.H b/src/lagrangian/intermediate/parcels/include/makeParcelForces.H new file mode 100644 index 0000000000000000000000000000000000000000..bc04078abdd886b46a1223d783108eae590b1e0f --- /dev/null +++ b/src/lagrangian/intermediate/parcels/include/makeParcelForces.H @@ -0,0 +1,89 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#ifndef makeParcelForces_H +#define makeParcelForces_H + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "KinematicCloud.H" + +#include "SphereDragForce.H" +#include "NonSphereDragForce.H" + +#include "GravityForce.H" +#include "ParamagneticForce.H" +#include "PressureGradientForce.H" +#include "SRFForce.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#define makeParcelForces(ParcelType) \ + \ + makeParticleForceModel(KinematicCloud<ParcelType>); \ + \ + makeParticleForceModelType \ + ( \ + SphereDragForce, \ + KinematicCloud, \ + ParcelType \ + ); \ + makeParticleForceModelType \ + ( \ + NonSphereDragForce, \ + KinematicCloud, \ + ParcelType \ + ); \ + makeParticleForceModelType \ + ( \ + GravityForce, \ + KinematicCloud, \ + ParcelType \ + ); \ + makeParticleForceModelType \ + ( \ + ParamagneticForce, \ + KinematicCloud, \ + ParcelType \ + ); \ + makeParticleForceModelType \ + ( \ + PressureGradientForce, \ + KinematicCloud, \ + ParcelType \ + ); \ + makeParticleForceModelType \ + ( \ + SRFForce, \ + KinematicCloud, \ + ParcelType \ + ); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/parcels/include/makeThermoParcelForces.H b/src/lagrangian/intermediate/parcels/include/makeThermoParcelForces.H new file mode 100644 index 0000000000000000000000000000000000000000..a39f748559cd1389758d1a189dae662d7c70ef9b --- /dev/null +++ b/src/lagrangian/intermediate/parcels/include/makeThermoParcelForces.H @@ -0,0 +1,96 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#ifndef makeThermoParcelForces_H +#define makeThermoParcelForces_H + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "KinematicCloud.H" + +#include "SphereDragForce.H" +#include "NonSphereDragForce.H" + +#include "BrownianMotionForce.H" +#include "GravityForce.H" +#include "ParamagneticForce.H" +#include "PressureGradientForce.H" +#include "SRFForce.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#define makeThermoParcelForces(ParcelType) \ + \ + makeParticleForceModel(KinematicCloud<ParcelType>); \ + \ + makeParticleForceModelType \ + ( \ + SphereDragForce, \ + KinematicCloud, \ + ParcelType \ + ); \ + makeParticleForceModelType \ + ( \ + NonSphereDragForce, \ + KinematicCloud, \ + ParcelType \ + ); \ + makeParticleForceModelType \ + ( \ + BrownianMotionForce, \ + KinematicCloud, \ + ParcelType \ + ); \ + makeParticleForceModelType \ + ( \ + GravityForce, \ + KinematicCloud, \ + ParcelType \ + ); \ + makeParticleForceModelType \ + ( \ + ParamagneticForce, \ + KinematicCloud, \ + ParcelType \ + ); \ + makeParticleForceModelType \ + ( \ + PressureGradientForce, \ + KinematicCloud, \ + ParcelType \ + ); \ + makeParticleForceModelType \ + ( \ + SRFForce, \ + KinematicCloud, \ + ParcelType \ + ); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/particleForces/particleForces.C b/src/lagrangian/intermediate/particleForces/particleForces.C deleted file mode 100644 index 124b21c2e19b28d0df32552cb51891e9c5df5e75..0000000000000000000000000000000000000000 --- a/src/lagrangian/intermediate/particleForces/particleForces.C +++ /dev/null @@ -1,362 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "particleForces.H" -#include "fvMesh.H" -#include "volFields.H" -#include "fvcGrad.H" -#include "mathematicalConstants.H" -#include "electromagneticConstants.H" -#include "SRFModel.H" - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -void Foam::particleForces::deleteFields() -{ - if (gradUPtr_) - { - delete gradUPtr_; - gradUPtr_ = NULL; - } - - if (HdotGradHInterPtr_) - { - delete HdotGradHInterPtr_; - HdotGradHInterPtr_ = NULL; - } -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::particleForces::particleForces(const fvMesh& mesh) -: - mesh_(mesh), - dict_(dictionary::null), - g_(vector::zero), - gradUPtr_(NULL), - HdotGradHInterPtr_(NULL), - gravity_(false), - virtualMass_(false), - Cvm_(0.0), - pressureGradient_(false), - paramagnetic_(false), - magneticSusceptibility_(0.0), - refFrame_(rfInertial), - UName_("undefined_UName"), - HdotGradHName_("undefined_HdotGradHName") -{} - - -Foam::particleForces::particleForces -( - const fvMesh& mesh, - const dictionary& dict, - const vector& g, - const bool readFields -) -: - mesh_(mesh), - dict_(dict.subOrEmptyDict("particleForces")), - g_(g), - gradUPtr_(NULL), - HdotGradHInterPtr_(NULL), - gravity_(false), - virtualMass_(false), - Cvm_(0.0), - pressureGradient_(false), - paramagnetic_(false), - magneticSusceptibility_(0.0), - refFrame_(rfInertial), - UName_(dict_.lookupOrDefault<word>("UName", "U")), - HdotGradHName_(dict_.lookupOrDefault<word>("HdotGradHName", "HdotGradH")) -{ - if (readFields) - { - dict_.lookup("gravity") >> gravity_; - dict_.lookup("virtualMass") >> virtualMass_; - dict_.lookup("pressureGradient") >> pressureGradient_; - dict_.lookup("paramagnetic") >> paramagnetic_; - - if (virtualMass_) - { - dict_.lookup("Cvm") >> Cvm_; - } - - if (paramagnetic_) - { - dict_.lookup("magneticSusceptibility") >> magneticSusceptibility_; - } - } - - if (dict_.found("referenceFrame")) - { - word rf(dict_.lookup("referenceFrame")); - - if (rf == "SRF") - { - refFrame_ = rfSRF; - } - else if (rf != "inertial") - { - FatalErrorIn - ( - "Foam::particleForces::particleForces" - "(" - "const fvMesh&, " - "const dictionary&, " - "const vector&, " - "const bool" - ")" - ) - << "Unknown referenceFrame, options are inertial and SRF." - << abort(FatalError); - } - } -} - - -Foam::particleForces::particleForces(const particleForces& f) -: - mesh_(f.mesh_), - dict_(f.dict_), - g_(f.g_), - gradUPtr_(f.gradUPtr_), - HdotGradHInterPtr_(f.HdotGradHInterPtr_), - gravity_(f.gravity_), - virtualMass_(f.virtualMass_), - Cvm_(f.Cvm_), - pressureGradient_(f.pressureGradient_), - paramagnetic_(f.paramagnetic_), - magneticSusceptibility_(f.magneticSusceptibility_), - refFrame_(f.refFrame_), - UName_(f.UName_), - HdotGradHName_(f.HdotGradHName_) -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::particleForces::~particleForces() -{ - deleteFields(); -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -const Foam::dictionary& Foam::particleForces::dict() const -{ - return dict_; -} - - -const Foam::vector& Foam::particleForces::g() const -{ - return g_; -} - - -Foam::Switch Foam::particleForces::gravity() const -{ - return gravity_; -} - - -Foam::Switch Foam::particleForces::virtualMass() const -{ - return virtualMass_; -} - - -Foam::scalar Foam::particleForces::Cvm() const -{ - return Cvm_; -} - - -Foam::Switch Foam::particleForces::pressureGradient() const -{ - return pressureGradient_; -} - - -Foam::Switch Foam::particleForces::paramagnetic() const -{ - return paramagnetic_; -} - - -Foam::scalar Foam::particleForces::magneticSusceptibility() const -{ - return magneticSusceptibility_; -} - - -const Foam::word& Foam::particleForces::UName() const -{ - return UName_; -} - - -const Foam::word& Foam::particleForces::HdotGradHName() const -{ - return HdotGradHName_; -} - - -void Foam::particleForces::cacheFields -( - const bool store, - const dictionary& interpolationSchemes -) -{ - if (store) - { - if (pressureGradient_) - { - const volVectorField& U = - mesh_.lookupObject<volVectorField>(UName_); - - gradUPtr_ = fvc::grad(U).ptr(); - } - - if (paramagnetic_) - { - const volVectorField& HdotGradH = - mesh_.lookupObject<volVectorField>(HdotGradHName_); - - HdotGradHInterPtr_ = interpolation<vector>::New - ( - interpolationSchemes, - HdotGradH - ).ptr(); - } - } - else - { - deleteFields(); - } -} - - -Foam::vector Foam::particleForces::calcCoupled -( - const vector& position, - const tetIndices& tetIs, - const scalar dt, - const scalar rhoc, - const scalar rho, - const vector& Uc, - const vector& U, - const scalar d -) const -{ - vector accelTot = vector::zero; - - // Virtual mass force - if (virtualMass_) - { - notImplemented - ( - "Foam::particleForces::calcCoupled(...) - virtual mass force" - ); -// accelTot += Cvm_*rhoc/rho*d(Uc - U)/dt; - } - - // Pressure gradient force - if (pressureGradient_) - { - const volTensorField& gradU = *gradUPtr_; - accelTot += rhoc/rho*(U & gradU[tetIs.cell()]); - } - - return accelTot; -} - - -Foam::vector Foam::particleForces::calcNonCoupled -( - const vector& position, - const tetIndices& tetIs, - const scalar dt, - const scalar rhoc, - const scalar rho, - const vector& Uc, - const vector& U, - const scalar d -) const -{ - vector accelTot = vector::zero; - - // Gravity force - if (gravity_) - { - accelTot += g_*(1.0 - rhoc/rho); - } - - // Magnetic field force - - if (paramagnetic_) - { - const interpolation<vector>& HdotGradHInter = *HdotGradHInterPtr_; - - accelTot += - 3.0*constant::electromagnetic::mu0.value()/rho - *magneticSusceptibility_/(magneticSusceptibility_ + 3) - *HdotGradHInter.interpolate(position, tetIs); - - // force is: - - // 4.0 - // *constant::mathematical::pi - // *constant::electromagnetic::mu0.value() - // *pow3(d/2) - // *magneticSusceptibility_/(magneticSusceptibility_ + 3) - // *HdotGradH[cellI]; - - // which is divided by mass (pi*d^3*rho/6) to produce - // acceleration - } - - if (refFrame_ == rfSRF) - { - const SRF::SRFModel& srf = - mesh_.lookupObject<SRF::SRFModel>("SRFProperties"); - - const vector& omega = srf.omega().value(); - const vector& axis = srf.axis(); - - vector r = position - axis*(axis & position); - - // Coriolis and centrifugal acceleration terms - accelTot += 2*(U ^ omega) + (omega ^ (r ^ omega)); - } - - return accelTot; -} - - -// ************************************************************************* // diff --git a/src/lagrangian/intermediate/particleForces/particleForces.H b/src/lagrangian/intermediate/particleForces/particleForces.H deleted file mode 100644 index 0f655be004ee6cfbad89af08db7e441bdedeaf0e..0000000000000000000000000000000000000000 --- a/src/lagrangian/intermediate/particleForces/particleForces.H +++ /dev/null @@ -1,229 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -Class - Foam::particleForces - -Description - Provides a mechanism to calculate particle forces - Note: forces are force per unit mass (accelerations) - -SourceFiles - particleForces.C - -\*---------------------------------------------------------------------------*/ - -#ifndef particleForces_H -#define particleForces_H - -#include "dictionary.H" -#include "Switch.H" -#include "vector.H" -#include "volFieldsFwd.H" -#include "interpolation.H" -#include "tetIndices.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// Forward class declarations -class fvMesh; - -/*---------------------------------------------------------------------------*\ - Class particleForces Declaration -\*---------------------------------------------------------------------------*/ - -class particleForces -{ - // Private data - - //- Reference frame type - enum refFrame - { - rfInertial, - rfSRF - }; - - //- Reference to the mesh database - const fvMesh& mesh_; - - //- The particleForces dictionary - const dictionary dict_; - - //- Gravity - const vector g_; - - //- Velocity gradient field - const volTensorField* gradUPtr_; - - //- HdotGradH interpolator - const interpolation<vector>* HdotGradHInterPtr_; - - - // Forces to include in particle motion evaluation - - //- Gravity - Switch gravity_; - - //- Virtual mass - Switch virtualMass_; - - //- Virtual mass force coefficient - scalar Cvm_; - - //- Pressure gradient - Switch pressureGradient_; - - //- Paramagnetic force - Switch paramagnetic_; - - //- Magnetic susceptibility of particle - scalar magneticSusceptibility_; - - //- Reference frame accelerations - refFrame refFrame_; - - - // Additional info - - //- Name of velocity field - default = "U" - const word UName_; - - //- Name of paramagnetic field strength field - default = - // "HdotGradH" - const word HdotGradHName_; - - - // Private Member Functions - - //- Delete cached carrier fields - void deleteFields(); - - -public: - - // Constructors - - //- Construct null from mesh reference - particleForces(const fvMesh& mesh); - - //- Construct from mesh, dictionary and gravity - particleForces - ( - const fvMesh& mesh, - const dictionary& dict, - const vector& g, - const bool readFields = true - ); - - //- Construct copy - particleForces(const particleForces& f); - - - //- Destructor - ~particleForces(); - - - // Member Functions - - // Access - - //- Return the particleForces dictionary - const dictionary& dict() const; - - //- Return the gravity vector - const vector& g() const; - - //- Return gravity force activate switch - Switch gravity() const; - - //- Return virtual mass force activate switch - Switch virtualMass() const; - - //- Return virtual mass force coefficient - scalar Cvm() const; - - //- Return pressure gradient force activate switch - Switch pressureGradient() const; - - //- Return name of velocity field - const word& UName() const; - - //- Return paramagnetic force activate switch - Switch paramagnetic() const; - - //- Return magnetic susceptibility - scalar magneticSusceptibility() const; - - //- Return name of paramagnetic field strength field - const word& HdotGradHName() const; - - - // Evaluation - - //- Cache carrier fields - void cacheFields - ( - const bool store, - const dictionary& interpolationSchemes - ); - - //- Calculate action/reaction forces between carrier and particles - vector calcCoupled - ( - const vector& position, - const tetIndices& tetIs, - const scalar dt, - const scalar rhoc, - const scalar rho, - const vector& Uc, - const vector& U, - const scalar d - ) const; - - //- Calculate external forces applied to the particles - vector calcNonCoupled - ( - const vector& position, - const tetIndices& tetIs, - const scalar dt, - const scalar rhoc, - const scalar rho, - const vector& Uc, - const vector& U, - const scalar d - ) const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/ForceTypes/ParticleForceList/ParticleForceList.C b/src/lagrangian/intermediate/submodels/ForceTypes/ParticleForceList/ParticleForceList.C new file mode 100644 index 0000000000000000000000000000000000000000..452ef6690d321b8375d5a087b61cc8d46109571a --- /dev/null +++ b/src/lagrangian/intermediate/submodels/ForceTypes/ParticleForceList/ParticleForceList.C @@ -0,0 +1,158 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "ParticleForceList.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class CloudType> +Foam::ParticleForceList<CloudType>::ParticleForceList +( + CloudType& owner, + const fvMesh& mesh +) +: + PtrList<ParticleForce<CloudType> >(), + owner_(owner), + mesh_(mesh), + dict_(dictionary::null) +{} + + +template<class CloudType> +Foam::ParticleForceList<CloudType>::ParticleForceList +( + CloudType& owner, + const fvMesh& mesh, + const dictionary& dict, + const bool readFields +) +: + PtrList<ParticleForce<CloudType> >(), + owner_(owner), + mesh_(mesh), + dict_(dict) +{ + if (readFields) + { + const wordList activeForces(dict.lookup("activeForces")); + + wordHashSet models; + models.insert(activeForces); + + Info<< "Constructing particle forces" << endl; + if (models.size() > 0) + { + this->setSize(models.size()); + + label i = 0; + forAllConstIter(wordHashSet, models, iter) + { + const word& model = iter.key(); + set(i, ParticleForce<CloudType>::New(owner, mesh, dict, model)); + i++; + } + } + else + { + Info<< " none" << endl; + } + } +} + + +template<class CloudType> +Foam::ParticleForceList<CloudType>::ParticleForceList +( + const ParticleForceList& pf +) +: + PtrList<ParticleForce<CloudType> >(pf), + owner_(pf.owner_), + mesh_(pf.mesh_), + dict_(pf.dict_) +{} + + +// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * // + +template<class CloudType> +Foam::ParticleForceList<CloudType>::~ParticleForceList() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class CloudType> +void Foam::ParticleForceList<CloudType>::cacheFields(const bool store) +{ + forAll(*this, i) + { + this->operator[](i).cacheFields(store); + } +} + + +template<class CloudType> +Foam::forceSuSp Foam::ParticleForceList<CloudType>::calcCoupled +( + const typename CloudType::parcelType& p, + const scalar dt, + const scalar mass, + const scalar Re, + const scalar muc +) const +{ + forceSuSp value(vector::zero, 0.0); + forAll(*this, i) + { + value += this->operator[](i).calcCoupled(p, dt, mass, Re, muc); + } + + return value; +} + + +template<class CloudType> +Foam::forceSuSp Foam::ParticleForceList<CloudType>::calcNonCoupled +( + const typename CloudType::parcelType& p, + const scalar dt, + const scalar mass, + const scalar Re, + const scalar muc +) const +{ + forceSuSp value(vector::zero, 0.0); + forAll(*this, i) + { + value += this->operator[](i).calcNonCoupled(p, dt, mass, Re, muc); + } + + return value; +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/ForceTypes/ParticleForceList/ParticleForceList.H b/src/lagrangian/intermediate/submodels/ForceTypes/ParticleForceList/ParticleForceList.H new file mode 100644 index 0000000000000000000000000000000000000000..0542216427670bee29b838e51451d451cc273d0a --- /dev/null +++ b/src/lagrangian/intermediate/submodels/ForceTypes/ParticleForceList/ParticleForceList.H @@ -0,0 +1,152 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::ParticleForceList + +Description + List of particle forces + +SourceFiles + ParticleForceListI.H + ParticleForceList.C + +\*---------------------------------------------------------------------------*/ + +#ifndef ParticleForceList_H +#define ParticleForceList_H + +#include "ParticleForce.H" +#include "forceSuSp.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class ParticleForceList Declaration +\*---------------------------------------------------------------------------*/ + +template<class CloudType> +class ParticleForceList +: + public PtrList<ParticleForce<CloudType> > +{ + // Private data + + //- Reference to the owner cloud + CloudType& owner_; + + //- Reference to the mesh database + const fvMesh& mesh_; + + //- Forces dictionary + const dictionary dict_; + + +public: + + // Constructors + + //- Null constructor + ParticleForceList(CloudType& owner, const fvMesh& mesh); + + //- Construct from mesh + ParticleForceList + ( + CloudType& owner, + const fvMesh& mesh, + const dictionary& dict, + const bool readFields + ); + + //- Construct copy + ParticleForceList(const ParticleForceList& pfl); + + + //- Destructor + virtual ~ParticleForceList(); + + + // Member Functions + + // Access + + //- Return const access to the cloud owner + inline const CloudType& owner() const; + + //- Return refernce to the cloud owner + inline CloudType& owner(); + + //- Return the mesh database + inline const fvMesh& mesh() const; + + //- Return the forces dictionary + inline const dictionary& dict() const; + + + // Evaluation + + //- Cache fields + virtual void cacheFields(const bool store); + + //- Calculate the coupled force + virtual forceSuSp calcCoupled + ( + const typename CloudType::parcelType& p, + const scalar dt, + const scalar mass, + const scalar Re, + const scalar muc + ) const; + + //- Calculate the non-coupled force + virtual forceSuSp calcNonCoupled + ( + const typename CloudType::parcelType& p, + const scalar dt, + const scalar mass, + const scalar Re, + const scalar muc + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "ParticleForceListI.H" + +#ifdef NoRepository + #include "ParticleForceList.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/parcels/include/makeParcelDragModels.H b/src/lagrangian/intermediate/submodels/ForceTypes/ParticleForceList/ParticleForceListI.H similarity index 57% rename from src/lagrangian/intermediate/parcels/include/makeParcelDragModels.H rename to src/lagrangian/intermediate/submodels/ForceTypes/ParticleForceList/ParticleForceListI.H index d849b7833e84c934b443c85b38370902d8f82164..e358dbc3d33b313c5e99a741188aaf43a499d12e 100644 --- a/src/lagrangian/intermediate/parcels/include/makeParcelDragModels.H +++ b/src/lagrangian/intermediate/submodels/ForceTypes/ParticleForceList/ParticleForceListI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,30 +23,34 @@ License \*---------------------------------------------------------------------------*/ -#ifndef makeParcelDragModels_H -#define makeParcelDragModels_H - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#include "KinematicCloud.H" +template<class CloudType> +inline const CloudType& Foam::ParticleForceList<CloudType>::owner() const +{ + return owner_; +} -#include "NoDrag.H" -#include "NonSphereDrag.H" -#include "SphereDrag.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +template<class CloudType> +inline CloudType& Foam::ParticleForceList<CloudType>::owner() +{ + return owner_; +} -#define makeParcelDragModels(ParcelType) \ - \ - makeDragModel(KinematicCloud<ParcelType>); \ - \ - makeDragModelType(NoDrag, KinematicCloud, ParcelType); \ - makeDragModelType(NonSphereDrag, KinematicCloud, ParcelType); \ - makeDragModelType(SphereDrag, KinematicCloud, ParcelType); +template<class CloudType> +inline const Foam::fvMesh& Foam::ParticleForceList<CloudType>::mesh() const +{ + return mesh_; +} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#endif +template<class CloudType> +inline const Foam::dictionary& Foam::ParticleForceList<CloudType>::dict() const +{ + return dict_; +} + // ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/DispersionModel/DispersionModel.C b/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/DispersionModel/DispersionModel.C index 3b09e6c6bfc53590de1fa8f18b02ed6819d33c41..6dd5c123e3ccca4861e16b12f831f13ce23ae5a1 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/DispersionModel/DispersionModel.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/DispersionModel/DispersionModel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/DispersionModel/DispersionModel.H b/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/DispersionModel/DispersionModel.H index f2d968d51ab099eae8fa168368ddb8d4d35dd081..d5b80000c34456461b139288b1bb2a9758829705 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/DispersionModel/DispersionModel.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/DispersionModel/DispersionModel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/DispersionModel/DispersionModelNew.C b/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/DispersionModel/DispersionModelNew.C index 898a1954869ecb627b302209902ee2414fcca728..75e1b5c9f687cfc75ffd10b3b8f0c0500a807057 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/DispersionModel/DispersionModelNew.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/DispersionModel/DispersionModelNew.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/DispersionRASModel/DispersionRASModel.C b/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/DispersionRASModel/DispersionRASModel.C index 745dc5d2818db9e3592393e5b4b0a6c049f38bc7..5473886f5db15959a721d5fea6ac36df2f4f4929 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/DispersionRASModel/DispersionRASModel.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/DispersionRASModel/DispersionRASModel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/DispersionRASModel/DispersionRASModel.H b/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/DispersionRASModel/DispersionRASModel.H index 0e0f1aef8816cd418ba8b7fdb11aef759476082b..2f337915dd30799b1d32ff8c7b346ab37d3375c5 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/DispersionRASModel/DispersionRASModel.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/DispersionRASModel/DispersionRASModel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/GradientDispersionRAS/GradientDispersionRAS.C b/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/GradientDispersionRAS/GradientDispersionRAS.C index 013a5c5c4fe2846e903284be5a4f044da226e343..d2657adaad266de87e945b0df031c6ea7f20d472 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/GradientDispersionRAS/GradientDispersionRAS.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/GradientDispersionRAS/GradientDispersionRAS.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/GradientDispersionRAS/GradientDispersionRAS.H b/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/GradientDispersionRAS/GradientDispersionRAS.H index 9f63babd87a2fc89e1ca5e75291f82d14cc52fa3..4b741bb41fe6b74aa05cdb6007a1d9b583ce2db2 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/GradientDispersionRAS/GradientDispersionRAS.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/GradientDispersionRAS/GradientDispersionRAS.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/NoDispersion/NoDispersion.C b/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/NoDispersion/NoDispersion.C index d72d4a1c7fbadaa63db8889edff2bb62f5f2c0df..11629331e6f5b0bfa47617d8d128f5654455f1d7 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/NoDispersion/NoDispersion.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/NoDispersion/NoDispersion.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/NoDispersion/NoDispersion.H b/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/NoDispersion/NoDispersion.H index 959bdfbd85c4d305441e293d3991f19a9f4d08fe..55659ff40ef9f2d59f7b86f809c528e5a6a5d977 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/NoDispersion/NoDispersion.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/NoDispersion/NoDispersion.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/StochasticDispersionRAS/StochasticDispersionRAS.C b/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/StochasticDispersionRAS/StochasticDispersionRAS.C index 0f98090718a8f41dbdc47d8df491365ac43cad6e..9b710da3f23d7dc05af4ec23a46bb7f1dd45a3ca 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/StochasticDispersionRAS/StochasticDispersionRAS.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/StochasticDispersionRAS/StochasticDispersionRAS.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/StochasticDispersionRAS/StochasticDispersionRAS.H b/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/StochasticDispersionRAS/StochasticDispersionRAS.H index 0c78efa3b1e2798db746b49c9edfe2ea8c5e4283..5ac6cdb1a5722c4a94dd5b2185633556128cef5b 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/StochasticDispersionRAS/StochasticDispersionRAS.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/StochasticDispersionRAS/StochasticDispersionRAS.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/Kinematic/DragModel/DragModel/DragModel.H b/src/lagrangian/intermediate/submodels/Kinematic/DragModel/DragModel/DragModel.H deleted file mode 100644 index f52111545d3c95a3acaf9755c082a58534b40807..0000000000000000000000000000000000000000 --- a/src/lagrangian/intermediate/submodels/Kinematic/DragModel/DragModel/DragModel.H +++ /dev/null @@ -1,157 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -Class - Foam::DragModel - -Description - Templated drag model class - -SourceFiles - DragModel.C - DragModelNew.C - -\*---------------------------------------------------------------------------*/ - -#ifndef DragModel_H -#define DragModel_H - -#include "IOdictionary.H" -#include "autoPtr.H" -#include "runTimeSelectionTables.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class DragModel Declaration -\*---------------------------------------------------------------------------*/ - -template<class CloudType> -class DragModel -: - public SubModelBase<CloudType> -{ -public: - - //- Runtime type information - TypeName("DragModel"); - - //- Declare runtime constructor selection table - declareRunTimeSelectionTable - ( - autoPtr, - DragModel, - dictionary, - ( - const dictionary& dict, - CloudType& owner - ), - (dict, owner) - ); - - - // Constructors - - //- Construct null from owner - DragModel(CloudType& owner); - - //- Construct from components - DragModel - ( - const dictionary& dict, - CloudType& owner, - const word& type - ); - - //- Construct copy - DragModel(const DragModel<CloudType>& dm); - - //- Construct and return a clone - virtual autoPtr<DragModel<CloudType> > clone() const - { - return autoPtr<DragModel<CloudType> > - ( - new DragModel<CloudType>(*this) - ); - } - - - //- Destructor - virtual ~DragModel(); - - - //- Selector - static autoPtr<DragModel<CloudType> > New - ( - const dictionary& dict, - CloudType& cloud - ); - - - // Member Functions - - //- Return drag coefficient - virtual scalar Cd(const scalar Re) const; - - //- Return momentum transfer coefficient - // Drag force per unit particle surface area = utc(U - Up) - scalar utc(const scalar Re, const scalar d, const scalar mu) const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#define makeDragModel(CloudType) \ - \ - defineNamedTemplateTypeNameAndDebug(DragModel<CloudType>, 0); \ - \ - defineTemplateRunTimeSelectionTable(DragModel<CloudType>, dictionary); - - -#define makeDragModelType(SS, CloudType, ParcelType) \ - \ - defineNamedTemplateTypeNameAndDebug(SS<CloudType<ParcelType> >, 0); \ - \ - DragModel<CloudType<ParcelType> >:: \ - adddictionaryConstructorToTable<SS<CloudType<ParcelType> > > \ - add##SS##CloudType##ParcelType##ConstructorToTable_; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifdef NoRepository -# include "DragModel.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.C index 3879f09fb8cc8a7ba8937126133fdedf753cef3c..adfdd991a248fe0cb59a5950f1a172bcccd5419d 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.H b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.H index 1b883632bf0b6a7ed8fc8b72d45257ccf17a48bc..3bbf913d5c977cd2abb0b5971c0cf6e0bb46ae81 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModelI.H b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModelI.H index 6489a84cf7a99b5883f33feede5cb0c22eb00c4e..c94520925feeb56402f59c0bbfa904a3ad58bc49 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModelI.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModelI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModelNew.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModelNew.C index 9027f6e9995d177defcf22fbd73a7b6d4e0a350c..189704dca3a984b7df133f7fe8a4822897d88808 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModelNew.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModelNew.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ManualInjection/ManualInjection.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ManualInjection/ManualInjection.C index f5255106fdf3659c5d44e395f426165a71e512d2..daf844e77089ccda05b7c64857b4e2a5aaae0856 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ManualInjection/ManualInjection.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ManualInjection/ManualInjection.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ManualInjection/ManualInjection.H b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ManualInjection/ManualInjection.H index 4bfeaaf7a1192eb6ffd1a0766987728914f89b5f..c741179e1d6608d6b122b828f26ee5c32a5efb85 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ManualInjection/ManualInjection.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ManualInjection/ManualInjection.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/NoInjection/NoInjection.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/NoInjection/NoInjection.C index e3d4929c750dadd66da1469dc50ac60f9cfc4225..9bb6a21cee429af0466e5a95fea57ce6eae923f5 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/NoInjection/NoInjection.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/NoInjection/NoInjection.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/NoInjection/NoInjection.H b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/NoInjection/NoInjection.H index 88a3fcc7de6933179108b04320a00ac58a0f63c9..f736f31ad1a9591388e90f5fd0fd981b0a81ec0a 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/NoInjection/NoInjection.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/NoInjection/NoInjection.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/Kinematic/DragModel/NonSphereDrag/NonSphereDrag.C b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/DragForce/NonSphereDrag/NonSphereDragForce.C similarity index 64% rename from src/lagrangian/intermediate/submodels/Kinematic/DragModel/NonSphereDrag/NonSphereDrag.C rename to src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/DragForce/NonSphereDrag/NonSphereDragForce.C index 822592e2aa177456387d83c3bcd66ecd41c25807..5ee4d8c0b63590c58222b8a790a7be589e9fd333 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/DragModel/NonSphereDrag/NonSphereDrag.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/DragForce/NonSphereDrag/NonSphereDragForce.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,19 +23,30 @@ License \*---------------------------------------------------------------------------*/ -#include "NonSphereDrag.H" +#include "NonSphereDragForce.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template<class CloudType> +Foam::scalar Foam::NonSphereDragForce<CloudType>::Cd(const scalar Re) const +{ + return 24.0/Re*(1.0 + a_*pow(Re, b_)) + Re*c_/(Re + d_); +} + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class CloudType> -Foam::NonSphereDrag<CloudType>::NonSphereDrag +Foam::NonSphereDragForce<CloudType>::NonSphereDragForce ( + CloudType& owner, + const fvMesh& mesh, const dictionary& dict, - CloudType& owner + const word& forceType ) : - DragModel<CloudType>(dict, owner, typeName), - phi_(readScalar(this->coeffDict().lookup("phi"))), + ParticleForce<CloudType>(owner, mesh, dict, forceType), + phi_(readScalar(this->coeffs().lookup("phi"))), a_(exp(2.3288 - 6.4581*phi_ + 2.4486*sqr(phi_))), b_(0.0964 + 0.5565*phi_), c_(exp(4.9050 - 13.8944*phi_ + 18.4222*sqr(phi_) - 10.2599*pow3(phi_))), @@ -58,33 +69,45 @@ Foam::NonSphereDrag<CloudType>::NonSphereDrag template<class CloudType> -Foam::NonSphereDrag<CloudType>::NonSphereDrag +Foam::NonSphereDragForce<CloudType>::NonSphereDragForce ( - const NonSphereDrag<CloudType>& dm + const NonSphereDragForce<CloudType>& df ) : - DragModel<CloudType>(dm), - phi_(dm.phi_), - a_(dm.a_), - b_(dm.b_), - c_(dm.c_), - d_(dm.d_) + ParticleForce<CloudType>(df), + phi_(df.phi_), + a_(df.a_), + b_(df.b_), + c_(df.c_), + d_(df.d_) {} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // template<class CloudType> -Foam::NonSphereDrag<CloudType>::~NonSphereDrag() +Foam::NonSphereDragForce<CloudType>::~NonSphereDragForce() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class CloudType> -Foam::scalar Foam::NonSphereDrag<CloudType>::Cd(const scalar Re) const +Foam::forceSuSp Foam::NonSphereDragForce<CloudType>::calcNonCoupled +( + const typename CloudType::parcelType& p, + const scalar dt, + const scalar mass, + const scalar Re, + const scalar muc +) const { - return 24.0/(Re + ROOTVSMALL)*(1.0 + a_*pow(Re, b_)) + Re*c_/(Re + d_); + forceSuSp value(vector::zero, 0.0); + + const scalar ReCorr = max(Re, 1e-6); + value.Sp() = mass*0.75*muc*Cd(ReCorr)*ReCorr/(p.rho()*sqr(p.d())); + + return value; } diff --git a/src/lagrangian/intermediate/submodels/Kinematic/DragModel/NonSphereDrag/NonSphereDrag.H b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/DragForce/NonSphereDrag/NonSphereDragForce.H similarity index 74% rename from src/lagrangian/intermediate/submodels/Kinematic/DragModel/NonSphereDrag/NonSphereDrag.H rename to src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/DragForce/NonSphereDrag/NonSphereDragForce.H index 1d6fc02b002f02d8f2f58694b9374c53bfaf3fc9..ce886f133b26214b7cc4fe9deec996182d907a4e 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/DragModel/NonSphereDrag/NonSphereDrag.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/DragForce/NonSphereDrag/NonSphereDragForce.H @@ -57,31 +57,28 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef NonSphereDrag_H -#define NonSphereDrag_H +#ifndef NonSphereDragForce_H +#define NonSphereDragForce_H -#include "DragModel.H" +#include "ParticleForce.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { /*---------------------------------------------------------------------------*\ - Class NonSphereDrag Declaration + Class NonSphereDragForce Declaration \*---------------------------------------------------------------------------*/ template<class CloudType> -class NonSphereDrag +class NonSphereDragForce : - public DragModel<CloudType> + public ParticleForce<CloudType> { protected: // Protected Data - //- Flag to indicate `Simple model' - bool simpleModel_; - //- Ratio of surface of sphere having same volume as particle to // actual surface area of particle (0 < phi <= 1) scalar phi_; @@ -98,38 +95,59 @@ protected: scalar d_; + // Private Member Functions + + //- Drag coefficient + scalar Cd(const scalar Re) const; + + public: //- Runtime type information - TypeName("NonSphereDrag"); + TypeName("nonSphereDrag"); // Constructors - //- Construct from dictionary - NonSphereDrag(const dictionary& dict, CloudType& owner); + //- Construct from mesh + NonSphereDragForce + ( + CloudType& owner, + const fvMesh& mesh, + const dictionary& dict, + const word& forceType + ); //- Construct copy - NonSphereDrag(const NonSphereDrag<CloudType>& dm); + NonSphereDragForce(const NonSphereDragForce<CloudType>& df); //- Construct and return a clone - virtual autoPtr<DragModel<CloudType> > clone() const + virtual autoPtr<ParticleForce<CloudType> > clone() const { - return autoPtr<DragModel<CloudType> > + return autoPtr<ParticleForce<CloudType> > ( - new NonSphereDrag<CloudType>(*this) + new NonSphereDragForce<CloudType>(*this) ); } //- Destructor - virtual ~NonSphereDrag(); + virtual ~NonSphereDragForce(); // Member Functions - //- Return drag coefficient - scalar Cd(const scalar Re) const; + // Evaluation + + //- Calculate the non-coupled force + virtual forceSuSp calcNonCoupled + ( + const typename CloudType::parcelType& p, + const scalar dt, + const scalar mass, + const scalar Re, + const scalar muc + ) const; }; @@ -140,7 +158,7 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #ifdef NoRepository -# include "NonSphereDrag.C" +# include "NonSphereDragForce.C" #endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/DragModel/DragModel/DragModel.C b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/DragForce/SphereDrag/SphereDragForce.C similarity index 61% rename from src/lagrangian/intermediate/submodels/Kinematic/DragModel/DragModel/DragModel.C rename to src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/DragForce/SphereDrag/SphereDragForce.C index 9be9e23bb39f27480814380369fd93559b5f0c44..da37d5131b54584daa2488085dd589d88e8e374d 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/DragModel/DragModel/DragModel.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/DragForce/SphereDrag/SphereDragForce.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,73 +23,75 @@ License \*---------------------------------------------------------------------------*/ -#include "DragModel.H" +#include "SphereDragForce.H" -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // template<class CloudType> -Foam::DragModel<CloudType>::DragModel(CloudType& owner) -: - SubModelBase<CloudType>(owner) -{} +Foam::scalar Foam::SphereDragForce<CloudType>::Cd(const scalar Re) const +{ + if (Re > 1000.0) + { + return 0.424; + } + else + { + return 24.0/Re*(1.0 + 1.0/6.0*pow(Re, 2.0/3.0)); + } +} +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + template<class CloudType> -Foam::DragModel<CloudType>::DragModel +Foam::SphereDragForce<CloudType>::SphereDragForce ( - const dictionary& dict, CloudType& owner, - const word& type + const fvMesh& mesh, + const dictionary& dict, + const word& forceType ) : - SubModelBase<CloudType>(owner, dict, type) + ParticleForce<CloudType>(owner, mesh, dict) {} template<class CloudType> -Foam::DragModel<CloudType>::DragModel(const DragModel<CloudType>& dm) +Foam::SphereDragForce<CloudType>::SphereDragForce +( + const SphereDragForce<CloudType>& df +) : - SubModelBase<CloudType>(dm) + ParticleForce<CloudType>(df) {} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // template<class CloudType> -Foam::DragModel<CloudType>::~DragModel() +Foam::SphereDragForce<CloudType>::~SphereDragForce() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class CloudType> -Foam::scalar Foam::DragModel<CloudType>::Cd(const scalar) const -{ - notImplemented - ( - "Foam::scalar Foam::DragModel<CloudType>::Cd(const scalar) const" - ); - return 0.0; -} - - -template<class CloudType> -Foam::scalar Foam::DragModel<CloudType>::utc +Foam::forceSuSp Foam::SphereDragForce<CloudType>::calcNonCoupled ( + const typename CloudType::parcelType& p, + const scalar dt, + const scalar mass, const scalar Re, - const scalar d, - const scalar mu + const scalar muc ) const { - const scalar Cd = this->Cd(Re); - - return Cd*Re/d*mu/8.0; -} + forceSuSp value(vector::zero, 0.0); + const scalar ReCorr = max(Re, 1e-6); + value.Sp() = mass*0.75*muc*Cd(ReCorr)*ReCorr/(p.rho()*sqr(p.d())); -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + return value; +} -#include "DragModelNew.C" // ************************************************************************* // - diff --git a/src/lagrangian/intermediate/submodels/Kinematic/DragModel/SphereDrag/SphereDrag.H b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/DragForce/SphereDrag/SphereDragForce.H similarity index 63% rename from src/lagrangian/intermediate/submodels/Kinematic/DragModel/SphereDrag/SphereDrag.H rename to src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/DragForce/SphereDrag/SphereDragForce.H index 643d421e09298c9b66579526a199fbc64a2c4dfc..f9e2cca78e1be95fe11c2404f166e43a0a3f2d5f 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/DragModel/SphereDrag/SphereDrag.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/DragForce/SphereDrag/SphereDragForce.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -22,63 +22,84 @@ License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. Class - Foam::SphereDrag + Foam::SphereDragForce Description Drag model based on assumption of solid spheres \*---------------------------------------------------------------------------*/ -#ifndef SphereDrag_H -#define SphereDrag_H +#ifndef SphereDragForce_H +#define SphereDragForce_H -#include "DragModel.H" +#include "ParticleForce.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { /*---------------------------------------------------------------------------*\ - Class SphereDrag Declaration + Class SphereDragForce Declaration \*---------------------------------------------------------------------------*/ template<class CloudType> -class SphereDrag +class SphereDragForce : - public DragModel<CloudType> + public ParticleForce<CloudType> { + // Private Member Functions + + //- Drag coefficient + scalar Cd(const scalar Re) const; + + public: //- Runtime type information - TypeName("SphereDrag"); + TypeName("sphereDrag"); // Constructors - //- Construct from dictionary - SphereDrag(const dictionary& dict, CloudType& owner); + //- Construct from mesh + SphereDragForce + ( + CloudType& owner, + const fvMesh& mesh, + const dictionary& dict, + const word& forceType + ); //- Construct copy - SphereDrag(const SphereDrag<CloudType>& dm); + SphereDragForce(const SphereDragForce<CloudType>& df); //- Construct and return a clone - virtual autoPtr<DragModel<CloudType> > clone() const + virtual autoPtr<ParticleForce<CloudType> > clone() const { - return autoPtr<DragModel<CloudType> > + return autoPtr<ParticleForce<CloudType> > ( - new SphereDrag<CloudType>(*this) + new SphereDragForce<CloudType>(*this) ); } //- Destructor - virtual ~SphereDrag(); + virtual ~SphereDragForce(); // Member Functions - //- Return drag coefficient - scalar Cd(const scalar Re) const; + // Evaluation + + //- Calculate the non-coupled force + virtual forceSuSp calcNonCoupled + ( + const typename CloudType::parcelType& p, + const scalar dt, + const scalar mass, + const scalar Re, + const scalar muc + ) const; }; @@ -89,7 +110,7 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #ifdef NoRepository -# include "SphereDrag.C" +# include "SphereDragForce.C" #endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/DragModel/SphereDrag/SphereDrag.C b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Gravity/GravityForce.C similarity index 63% rename from src/lagrangian/intermediate/submodels/Kinematic/DragModel/SphereDrag/SphereDrag.C rename to src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Gravity/GravityForce.C index 7d0c0727cfb53fdec7adebd8c86a0a7d8f278dbc..6af29abb1b26af3fe15483f7ba8fc5b877f70ac1 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/DragModel/SphereDrag/SphereDrag.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Gravity/GravityForce.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,55 +23,56 @@ License \*---------------------------------------------------------------------------*/ -#include "SphereDrag.H" +#include "GravityForce.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class CloudType> -Foam::SphereDrag<CloudType>::SphereDrag +Foam::GravityForce<CloudType>::GravityForce ( - const dictionary&, - CloudType& owner + CloudType& owner, + const fvMesh& mesh, + const dictionary& dict, + const word& forceType ) : - DragModel<CloudType>(owner) + ParticleForce<CloudType>(owner, mesh, dict), + g_(owner.g().value()) {} template<class CloudType> -Foam::SphereDrag<CloudType>::SphereDrag(const SphereDrag<CloudType>& dm) +Foam::GravityForce<CloudType>::GravityForce(const GravityForce& gf) : - DragModel<CloudType>(dm) + ParticleForce<CloudType>(gf), + g_(gf.g_) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * // template<class CloudType> -Foam::SphereDrag<CloudType>::~SphereDrag() +Foam::GravityForce<CloudType>::~GravityForce() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class CloudType> -Foam::scalar Foam::SphereDrag<CloudType>::Cd(const scalar Re) const +Foam::forceSuSp Foam::GravityForce<CloudType>::calcNonCoupled +( + const typename CloudType::parcelType& p, + const scalar dt, + const scalar mass, + const scalar Re, + const scalar muc +) const { - scalar Cd; - if (Re < SMALL) - { - Cd = GREAT; - } - else if (Re > 1000.0) - { - Cd = 0.424; - } - else - { - Cd = 24.0/Re*(1.0 + 1.0/6.0*pow(Re, 2.0/3.0)); - } - - return Cd; + forceSuSp value(vector::zero, 0.0); + + value.Su() = mass*g_*(1.0 - p.rhoc()/p.rho()); + + return value; } diff --git a/src/errorEstimation/evaluateError/evaluateError.H b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Gravity/GravityForce.H similarity index 51% rename from src/errorEstimation/evaluateError/evaluateError.H rename to src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Gravity/GravityForce.H index 2a96e884ea8ad07abbb62ee0ac77bb257d927ca2..a215d0ef668da5cd6d092d2353e311cbf79510eb 100644 --- a/src/errorEstimation/evaluateError/evaluateError.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Gravity/GravityForce.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -22,86 +22,97 @@ License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. Class - Foam::evaluateError + Foam::GravityForce Description - Foam::evaluateError + Calculates particle gravity force SourceFiles - evaluateError.C + GravityForceI.H + GravityForce.C \*---------------------------------------------------------------------------*/ -#ifndef evaluateError_H -#define evaluateError_H - -#include "labelList.H" -#include "volFieldsFwd.H" -#include "surfaceFieldsFwd.H" +#ifndef GravityForce_H +#define GravityForce_H +#include "ParticleForce.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -// Forward declaration of classes -class refineCell; +class fvMesh; /*---------------------------------------------------------------------------*\ - Class evaluateError Declaration + Class GravityForce Declaration \*---------------------------------------------------------------------------*/ -class evaluateError +template<class CloudType> +class GravityForce +: + public ParticleForce<CloudType> { // Private data - // splitFaces to remove. - labelList unsplitFaces_; - - // cells to refine. - List<refineCell> refCells_; - - - // Private Member Functions + //- Reference to the acceleration due to gravity + const vector& g_; public: - // Constructors + //- Runtime type information + TypeName("gravity"); - //- Construct null - evaluateError(); + // Constructors - //- Construct from error value, error direction. Determine faces to - // remove (out of candidate faces) and cells to refine (all cells): - // - // remove all faces where the (face)error is less than - // average - standard deviation - // refine all cells where the (cell)error is more than - // average + standard deviation. gradTheta is used to determine - // direction to refine in. - evaluateError + //- Construct from mesh + GravityForce ( - const volScalarField& cellError, - const volVectorField& gradTheta, - const surfaceScalarField& faceError, - const labelList& candidateFaces + CloudType& owner, + const fvMesh& mesh, + const dictionary& dict, + const word& forceType ); + //- Construct copy + GravityForce(const GravityForce& gf); - // Member Functions - - const labelList& unsplitFaces() const + //- Construct and return a clone + virtual autoPtr<ParticleForce<CloudType> > clone() const { - return unsplitFaces_; + return autoPtr<ParticleForce<CloudType> > + ( + new GravityForce<CloudType>(*this) + ); } - const List<refineCell>& refCells() const - { - return refCells_; - } + + //- Destructor + virtual ~GravityForce(); + + + // Member Functions + + // Access + + //- Return the the acceleration due to gravity + inline const vector& g() const; + + + // Evaluation + + //- Calculate the non-coupled force + virtual forceSuSp calcNonCoupled + ( + const typename CloudType::parcelType& p, + const scalar dt, + const scalar mass, + const scalar Re, + const scalar muc + ) const; }; @@ -111,6 +122,14 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#include "GravityForceI.H" + +#ifdef NoRepository + #include "GravityForce.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + #endif // ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Gravity/GravityForceI.H b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Gravity/GravityForceI.H new file mode 100644 index 0000000000000000000000000000000000000000..b34b82a669a4e65a17a4f95984f8a4f71c9cebe1 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Gravity/GravityForceI.H @@ -0,0 +1,35 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class CloudType> +inline const Foam::vector& Foam::GravityForce<CloudType>::g() const +{ + return g_; +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Paramagnetic/ParamagneticForce.C b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Paramagnetic/ParamagneticForce.C new file mode 100644 index 0000000000000000000000000000000000000000..24e294e0399862545fe57bdb1460e0f5431c18bf --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Paramagnetic/ParamagneticForce.C @@ -0,0 +1,120 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "ParamagneticForce.H" +#include "demandDrivenData.H" +#include "electromagneticConstants.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class CloudType> +Foam::ParamagneticForce<CloudType>::ParamagneticForce +( + CloudType& owner, + const fvMesh& mesh, + const dictionary& dict, + const word& forceType +) +: + ParticleForce<CloudType>(owner, mesh, dict, forceType), + HdotGradHName_ + ( + this->coeffs().template lookupOrDefault<word>("HdotGradH", "HdotGradH") + ), + HdotGradHInterpPtr_(NULL), + magneticSusceptibility_ + ( + readScalar(this->coeffs().lookup("magneticSusceptibility")) + ) +{} + + +template<class CloudType> +Foam::ParamagneticForce<CloudType>::ParamagneticForce +( + const ParamagneticForce& pf +) +: + ParticleForce<CloudType>(pf), + HdotGradHName_(pf.HdotGradHName_), + HdotGradHInterpPtr_(pf.HdotGradHInterpPtr_), + magneticSusceptibility_(pf.magneticSusceptibility_) +{} + + +// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * // + +template<class CloudType> +Foam::ParamagneticForce<CloudType>::~ParamagneticForce() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class CloudType> +void Foam::ParamagneticForce<CloudType>::cacheFields(const bool store) +{ + if (store) + { + const volVectorField& HdotGradH = + this->mesh().template lookupObject<volVectorField>(HdotGradHName_); + + HdotGradHInterpPtr_ = interpolation<vector>::New + ( + this->owner().solution().interpolationSchemes(), + HdotGradH + ).ptr(); + } + else + { + deleteDemandDrivenData(HdotGradHInterpPtr_); + } +} + + +template<class CloudType> +Foam::forceSuSp Foam::ParamagneticForce<CloudType>::calcNonCoupled +( + const typename CloudType::parcelType& p, + const scalar dt, + const scalar mass, + const scalar Re, + const scalar muc +) const +{ + forceSuSp value(vector::zero, 0.0); + + const interpolation<vector>& HdotGradHInterp = *HdotGradHInterpPtr_; + + value.Su()= + mass*3.0*constant::electromagnetic::mu0.value()/p.rho() + *magneticSusceptibility_/(magneticSusceptibility_ + 3) + *HdotGradHInterp.interpolate(p.position(), p.currentTetIndices()); + + return value; +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Paramagnetic/ParamagneticForce.H b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Paramagnetic/ParamagneticForce.H new file mode 100644 index 0000000000000000000000000000000000000000..f849556f2e8a6ee8b565d9ebb03203fec74bfa35 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Paramagnetic/ParamagneticForce.H @@ -0,0 +1,148 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::ParamagneticForce + +Description + Calculates particle paramagnetic (magnetic field) force + +SourceFiles + ParamagneticForceI.H + ParamagneticForce.C + +\*---------------------------------------------------------------------------*/ + +#ifndef ParamagneticForce_H +#define ParamagneticForce_H + +#include "ParticleForce.H" +#include "interpolation.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +class fvMesh; + +/*---------------------------------------------------------------------------*\ + Class ParamagneticForce Declaration +\*---------------------------------------------------------------------------*/ + +template<class CloudType> +class ParamagneticForce +: + public ParticleForce<CloudType> +{ + // Private data + + //- Name of paramagnetic field strength field - default = "HdotGradH" + const word HdotGradHName_; + + //- HdotGradH interpolator + const interpolation<vector>* HdotGradHInterpPtr_; + + //- Magnetic susceptibility of particle + const scalar magneticSusceptibility_; + + +public: + + //- Runtime type information + TypeName("paramagnetic"); + + + // Constructors + + //- Construct from mesh + ParamagneticForce + ( + CloudType& owner, + const fvMesh& mesh, + const dictionary& dict, + const word& forceType + ); + + //- Construct copy + ParamagneticForce(const ParamagneticForce& gf); + + //- Construct and return a clone + virtual autoPtr<ParticleForce<CloudType> > clone() const + { + return autoPtr<ParticleForce<CloudType> > + ( + new ParamagneticForce<CloudType>(*this) + ); + } + + + //- Destructor + virtual ~ParamagneticForce(); + + + // Member Functions + + // Access + + //- Return the name of paramagnetic field strength field + const word& HdotGradHName() const; + + //- Return the magnetic susceptibility of particle + scalar magneticSusceptibility() const; + + + // Evaluation + + //- Cache fields + virtual void cacheFields(const bool store); + + //- Calculate the non-coupled force + virtual forceSuSp calcNonCoupled + ( + const typename CloudType::parcelType& p, + const scalar dt, + const scalar mass, + const scalar Re, + const scalar muc + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "ParamagneticForceI.H" + +#ifdef NoRepository + #include "ParamagneticForce.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Paramagnetic/ParamagneticForceI.H b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Paramagnetic/ParamagneticForceI.H new file mode 100644 index 0000000000000000000000000000000000000000..34be6491bb3ac006bcad4719addaaa3de2c76be9 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Paramagnetic/ParamagneticForceI.H @@ -0,0 +1,44 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class CloudType> +inline const Foam::word& +Foam::ParamagneticForce<CloudType>::HdotGradHName() const +{ + return HdotGradHName_; +} + + +template<class CloudType> +inline Foam::scalar +Foam::ParamagneticForce<CloudType>::magneticSusceptibility() const +{ + return magneticSusceptibility_; +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/ParticleForce/ParticleForce.C b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/ParticleForce/ParticleForce.C new file mode 100644 index 0000000000000000000000000000000000000000..6b6f53aca3c04a0e28bdddcf71a236dec5e0b485 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/ParticleForce/ParticleForce.C @@ -0,0 +1,125 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "ParticleForce.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class CloudType> +Foam::ParticleForce<CloudType>::ParticleForce +( + CloudType& owner, + const fvMesh& mesh, + const dictionary& dict +) +: + owner_(owner), + mesh_(mesh), + dict_(dict), + coeffs_(dictionary::null) +{} + + +template<class CloudType> +Foam::ParticleForce<CloudType>::ParticleForce +( + CloudType& owner, + const fvMesh& mesh, + const dictionary& dict, + const word& forceType +) +: + owner_(owner), + mesh_(mesh), + dict_(dict), + coeffs_(dict.subOrEmptyDict(forceType + "Coeffs")) +{} + + +template<class CloudType> +Foam::ParticleForce<CloudType>::ParticleForce(const ParticleForce& pf) +: + owner_(pf.owner_), + mesh_(pf.mesh_), + dict_(pf.dict_), + coeffs_(pf.coeffs_) +{} + + +// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * // + +template<class CloudType> +Foam::ParticleForce<CloudType>::~ParticleForce() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class CloudType> +void Foam::ParticleForce<CloudType>::cacheFields(const bool store) +{} + + +template<class CloudType> +Foam::forceSuSp Foam::ParticleForce<CloudType>::calcCoupled +( + const typename CloudType::parcelType&, + const scalar dt, + const scalar mass, + const scalar Re, + const scalar muc +) const +{ + forceSuSp value; + value.Su() = vector::zero; + value.Sp() = 0.0; + + return value; +} + + +template<class CloudType> +Foam::forceSuSp Foam::ParticleForce<CloudType>::calcNonCoupled +( + const typename CloudType::parcelType&, + const scalar dt, + const scalar mass, + const scalar Re, + const scalar muc +) const +{ + forceSuSp value; + value.Su() = vector::zero; + value.Sp() = 0.0; + + return value; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "ParticleForceNew.C" + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/ParticleForce/ParticleForce.H b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/ParticleForce/ParticleForce.H new file mode 100644 index 0000000000000000000000000000000000000000..e06646ca03b412ded87d9e8702a8f51969832855 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/ParticleForce/ParticleForce.H @@ -0,0 +1,223 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::ParticleForce + +Description + Abstract base class for particle forces + +SourceFiles + ParticleForceI.H + ParticleForce.C + ParticleForceNew.C + +\*---------------------------------------------------------------------------*/ + +#ifndef ParticleForce_H +#define ParticleForce_H + +#include "dictionary.H" +#include "forceSuSp.H" +#include "fvMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class ParticleForce Declaration +\*---------------------------------------------------------------------------*/ + +template<class CloudType> +class ParticleForce +{ + // Private data + + //- Reference to the owner cloud + CloudType& owner_; + + //- Reference to the mesh database + const fvMesh& mesh_; + + //- Forces dictionary + const dictionary dict_; + + //- Force coefficients dictaionary + const dictionary coeffs_; + + +public: + + //- Runtime type information + TypeName("particleForce"); + + //- Declare runtime constructor selection table + declareRunTimeSelectionTable + ( + autoPtr, + ParticleForce, + dictionary, + ( + CloudType& owner, + const fvMesh& mesh, + const dictionary& dict, + const word& forceType + ), + (owner, mesh, dict, forceType) + ); + + + //- Convenience typedef for return type + typedef VectorSpace<Vector<vector>, vector, 2> returnType; + + + // Constructors + + //- Construct null + ParticleForce + ( + CloudType& owner, + const fvMesh& mesh, + const dictionary& dict + ); + + //- Construct from mesh + ParticleForce + ( + CloudType& owner, + const fvMesh& mesh, + const dictionary& dict, + const word& forceType + ); + + //- Construct copy + ParticleForce(const ParticleForce& pf); + + //- Construct and return a clone + virtual autoPtr<ParticleForce<CloudType> > clone() const + { + return autoPtr<ParticleForce<CloudType> > + ( + new ParticleForce<CloudType>(*this) + ); + } + + + //- Destructor + virtual ~ParticleForce(); + + + //- Selector + static autoPtr<ParticleForce<CloudType> > New + ( + CloudType& owner, + const fvMesh& mesh, + const dictionary& dict, + const word& forceType + ); + + + // Member Functions + + // Access + + //- Return const access to the cloud owner + inline const CloudType& owner() const; + + //- Return refernce to the cloud owner + inline CloudType& owner(); + + //- Return the mesh database + inline const fvMesh& mesh() const; + + //- Return the forces dictionary + inline const dictionary& dict() const; + + //- Return the force coefficients dictionary + inline const dictionary& coeffs() const; + + + // Evaluation + + //- Cache fields + virtual void cacheFields(const bool store); + + //- Calculate the coupled force + virtual forceSuSp calcCoupled + ( + const typename CloudType::parcelType& p, + const scalar dt, + const scalar mass, + const scalar Re, + const scalar muc + ) const; + + //- Calculate the non-coupled force + virtual forceSuSp calcNonCoupled + ( + const typename CloudType::parcelType& p, + const scalar dt, + const scalar mass, + const scalar Re, + const scalar muc + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "ParticleForceI.H" + +#ifdef NoRepository + #include "ParticleForce.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#define makeParticleForceModel(CloudType) \ + \ + defineNamedTemplateTypeNameAndDebug(ParticleForce<CloudType>, 0); \ + defineTemplateRunTimeSelectionTable(ParticleForce<CloudType>, dictionary); + + +#define makeParticleForceModelType(SS, CloudType, ParcelType) \ + \ + defineNamedTemplateTypeNameAndDebug(SS<CloudType<ParcelType> >, 0); \ + \ + ParticleForce<CloudType<ParcelType> >:: \ + adddictionaryConstructorToTable<SS<CloudType<ParcelType> > > \ + add##SS##CloudType##ParcelType##ConstructorToTable_; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/DragModel/NoDrag/NoDrag.C b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/ParticleForce/ParticleForceI.H similarity index 65% rename from src/lagrangian/intermediate/submodels/Kinematic/DragModel/NoDrag/NoDrag.C rename to src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/ParticleForce/ParticleForceI.H index be46f9946a9a3e8c99e8a698b1df677165810a12..24aa098e59f2395b90b9f71251cbac36ada9a166 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/DragModel/NoDrag/NoDrag.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/ParticleForce/ParticleForceI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,44 +23,40 @@ License \*---------------------------------------------------------------------------*/ -#include "NoDrag.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template<class CloudType> -Foam::NoDrag<CloudType>::NoDrag(const dictionary& dict, CloudType& owner) -: - DragModel<CloudType>(owner) -{} +inline const CloudType& Foam::ParticleForce<CloudType>::owner() const +{ + return owner_; +} template<class CloudType> -Foam::NoDrag<CloudType>::NoDrag(const NoDrag<CloudType>& dm) -: - DragModel<CloudType>(dm.owner_) -{} - +inline CloudType& Foam::ParticleForce<CloudType>::owner() +{ + return owner_; +} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // template<class CloudType> -Foam::NoDrag<CloudType>::~NoDrag() -{} - +inline const Foam::fvMesh& Foam::ParticleForce<CloudType>::mesh() const +{ + return mesh_; +} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class CloudType> -bool Foam::NoDrag<CloudType>::active() const +inline const Foam::dictionary& Foam::ParticleForce<CloudType>::dict() const { - return false; + return dict_; } template<class CloudType> -Foam::scalar Foam::NoDrag<CloudType>::Cd(const scalar) const +inline const Foam::dictionary& Foam::ParticleForce<CloudType>::coeffs() const { - return 0.0; + return coeffs_; } diff --git a/src/lagrangian/intermediate/submodels/Kinematic/DragModel/DragModel/DragModelNew.C b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/ParticleForce/ParticleForceNew.C similarity index 61% rename from src/lagrangian/intermediate/submodels/Kinematic/DragModel/DragModel/DragModelNew.C rename to src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/ParticleForce/ParticleForceNew.C index 054c0bd8057166301a35f364e9add1edd2c56b45..9c282054c9a52da6f9ec68a8392cdd4363f9d235 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/DragModel/DragModel/DragModelNew.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/ParticleForce/ParticleForceNew.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,41 +23,55 @@ License \*---------------------------------------------------------------------------*/ -#include "DragModel.H" +#include "ParticleForce.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class CloudType> -Foam::autoPtr<Foam::DragModel<CloudType> > Foam::DragModel<CloudType>::New +Foam::autoPtr<Foam::ParticleForce<CloudType> > +Foam::ParticleForce<CloudType>::New ( + CloudType& owner, + const fvMesh& mesh, const dictionary& dict, - CloudType& owner + const word& forceType ) { - const word modelType(dict.lookup("DragModel")); - - Info<< "Selecting DragModel " << modelType << endl; + Info<< " Selecting particle force " << forceType << endl; typename dictionaryConstructorTable::iterator cstrIter = - dictionaryConstructorTablePtr_->find(modelType); + dictionaryConstructorTablePtr_->find(forceType); if (cstrIter == dictionaryConstructorTablePtr_->end()) { FatalErrorIn ( - "DragModel<CloudType>::New" + "ParticleForce<CloudType>::New" "(" - "const dictionary&," - "CloudType&" + "CloudType&, " + "const fvMesh&, " + "const dictionary&, " + "const word&" ")" - ) << "Unknown DragModel type " - << modelType << nl << nl - << "Valid DragModel types are:" << nl + ) << "Unknown particle force type " + << forceType + << ", constructor not in hash table" << nl << nl + << " Valid particle force types are:" << nl << dictionaryConstructorTablePtr_->sortedToc() << exit(FatalError); } - return autoPtr<DragModel<CloudType> >(cstrIter()(dict, owner)); + return autoPtr<ParticleForce<CloudType> > + ( + cstrIter() + ( + owner, + mesh, + dict, + forceType + ) + ); + } diff --git a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/PressureGradient/PressureGradientForce.C b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/PressureGradient/PressureGradientForce.C new file mode 100644 index 0000000000000000000000000000000000000000..a113b44e13e7a3c48e12536ace8cc4b2b4d3d968 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/PressureGradient/PressureGradientForce.C @@ -0,0 +1,106 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "PressureGradientForce.H" +#include "fvcGrad.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class CloudType> +Foam::PressureGradientForce<CloudType>::PressureGradientForce +( + CloudType& owner, + const fvMesh& mesh, + const dictionary& dict, + const word& forceType +) +: + ParticleForce<CloudType>(owner, mesh, dict, forceType), + UName_(this->coeffs().lookup("U")), + gradUPtr_(NULL) +{} + + +template<class CloudType> +Foam::PressureGradientForce<CloudType>::PressureGradientForce +( + const PressureGradientForce& pgf +) +: + ParticleForce<CloudType>(pgf), + UName_(pgf.UName_), + gradUPtr_(NULL) +{} + + +// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * // + +template<class CloudType> +Foam::PressureGradientForce<CloudType>::~PressureGradientForce() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class CloudType> +void Foam::PressureGradientForce<CloudType>::cacheFields(const bool store) +{ + if (store) + { + const volVectorField& U = this->mesh().template + lookupObject<volVectorField>(UName_); + gradUPtr_ = fvc::grad(U).ptr(); + } + else + { + if (gradUPtr_) + { + delete gradUPtr_; + gradUPtr_ = NULL; + } + } +} + + +template<class CloudType> +Foam::forceSuSp Foam::PressureGradientForce<CloudType>::calcCoupled +( + const typename CloudType::parcelType& p, + const scalar dt, + const scalar mass, + const scalar Re, + const scalar muc +) const +{ + forceSuSp value(vector::zero, 0.0); + + const volTensorField& gradU = *gradUPtr_; + value.Su() = mass*p.rhoc()/p.rho()*(p.U() & gradU[p.cell()]); + + return value; +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/PressureGradient/PressureGradientForce.H b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/PressureGradient/PressureGradientForce.H new file mode 100644 index 0000000000000000000000000000000000000000..4e1f08cc98dd13891c65e95cc073b15fcc516db3 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/PressureGradient/PressureGradientForce.H @@ -0,0 +1,140 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::PressureGradientForce + +Description + Calculates particle pressure gradient force + +SourceFiles + PressureGradientForceI.H + PressureGradientForce.C + +\*---------------------------------------------------------------------------*/ + +#ifndef PressureGradientForce_H +#define PressureGradientForce_H + +#include "ParticleForce.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class PressureGradientForce Declaration +\*---------------------------------------------------------------------------*/ + +template<class CloudType> +class PressureGradientForce +: + public ParticleForce<CloudType> +{ + // Private data + + //- Name of velocity field + const word UName_; + + //- Velocity gradient field + const volTensorField* gradUPtr_; + + +public: + + //- Runtime type information + TypeName("pressureGradient"); + + + // Constructors + + //- Construct from mesh + PressureGradientForce + ( + CloudType& owner, + const fvMesh& mesh, + const dictionary& dict, + const word& forceType + ); + + //- Construct copy + PressureGradientForce(const PressureGradientForce& pgf); + + //- Construct and return a clone + virtual autoPtr<ParticleForce<CloudType> > clone() const + { + return autoPtr<ParticleForce<CloudType> > + ( + new PressureGradientForce<CloudType>(*this) + ); + } + + + //- Destructor + virtual ~PressureGradientForce(); + + + // Member Functions + + // Access + + //- Return const access to the velocity gradient field + inline const volTensorField& gradU() const; + + + // Evaluation + + //- Cache fields + virtual void cacheFields(const bool store); + + //- Calculate the non-coupled force + virtual forceSuSp calcCoupled + ( + const typename CloudType::parcelType& p, + const scalar dt, + const scalar mass, + const scalar Re, + const scalar muc + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "PressureGradientForceI.H" + +#ifdef NoRepository + #include "PressureGradientForce.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/PressureGradient/PressureGradientForceI.H b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/PressureGradient/PressureGradientForceI.H new file mode 100644 index 0000000000000000000000000000000000000000..ac81740903e83b634e1351b58cf739abfd843a4b --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/PressureGradient/PressureGradientForceI.H @@ -0,0 +1,49 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class CloudType> +const Foam::volTensorField& Foam::PressureGradientForce<CloudType>::gradU() +const +{ + if (gradUPtr_) + { + return *gradUPtr_; + } + else + { + FatalErrorIn + ( + "const volTensorField& PressureGradientForce<CloudType>::gradU()" + "const" + ) << "gradU field not allocated" << abort(FatalError); + + return reinterpret_cast<const volTensorField>(0); + } +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/SRF/SRFForce.C b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/SRF/SRFForce.C new file mode 100644 index 0000000000000000000000000000000000000000..2f9ca986b4b6bdc267e73376424e507f23323e25 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/SRF/SRFForce.C @@ -0,0 +1,106 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "SRFForce.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class CloudType> +Foam::SRFForce<CloudType>::SRFForce +( + CloudType& owner, + const fvMesh& mesh, + const dictionary& dict, + const word& forceType +) +: + ParticleForce<CloudType>(owner, mesh, dict), + srfPtr_(NULL) +{} + + +template<class CloudType> +Foam::SRFForce<CloudType>::SRFForce +( + const SRFForce& srff +) +: + ParticleForce<CloudType>(srff), + srfPtr_(NULL) +{} + + +// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * // + +template<class CloudType> +Foam::SRFForce<CloudType>::~SRFForce() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class CloudType> +void Foam::SRFForce<CloudType>::cacheFields(const bool store) +{ + if (store) + { + const typename SRF::SRFModel& model = this->mesh().template + lookupObject<SRF::SRFModel>("SRFProperties"); + srfPtr_ = &model; + } + else + { + srfPtr_ = NULL; + } +} + + +template<class CloudType> +Foam::forceSuSp Foam::SRFForce<CloudType>::calcNonCoupled +( + const typename CloudType::parcelType& p, + const scalar dt, + const scalar mass, + const scalar Re, + const scalar muc +) const +{ + forceSuSp value(vector::zero, 0.0); + + const typename SRF::SRFModel& srf = *srfPtr_; + + const vector& omega = srf.omega().value(); + const vector& axis = srf.axis(); + + const vector r = p.position() - axis*(axis & p.position()); + + // Coriolis and centrifugal acceleration terms + value.Su() = mass*2.0*(p.U() ^ omega) + (omega ^ (r ^ omega)); + + return value; +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/DragModel/NoDrag/NoDrag.H b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/SRF/SRFForce.H similarity index 59% rename from src/lagrangian/intermediate/submodels/Kinematic/DragModel/NoDrag/NoDrag.H rename to src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/SRF/SRFForce.H index 742bb0d3018eb9ab927a51cd43bc04ef9a4d212e..2e646a37d70e0fd18978065d2485a61b2bb16057 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/DragModel/NoDrag/NoDrag.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/SRF/SRFForce.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -22,66 +22,95 @@ License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. Class - Foam::NoDrag + Foam::SRFForce Description - Dummy drag model for 'none' + Calculates particle SRF reference frame force + +SourceFiles + SRFForceI.H + SRFForce.C \*---------------------------------------------------------------------------*/ -#ifndef NoDrag_H -#define NoDrag_H +#ifndef SRFForce_H +#define SRFForce_H -#include "DragModel.H" +#include "ParticleForce.H" +#include "SRFModel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { + +class fvMesh; + /*---------------------------------------------------------------------------*\ - Class NoDrag Declaration + Class SRFForce Declaration \*---------------------------------------------------------------------------*/ template<class CloudType> -class NoDrag +class SRFForce : - public DragModel<CloudType> + public ParticleForce<CloudType> { + // Private data + + //- Pointer to the SRF model + const typename SRF::SRFModel* srfPtr_; + + public: //- Runtime type information - TypeName("none"); + TypeName("SRF"); // Constructors - //- Construct from dictionary - NoDrag(const dictionary&, CloudType&); + //- Construct from mesh + SRFForce + ( + CloudType& owner, + const fvMesh& mesh, + const dictionary& dict, + const word& forceType + ); //- Construct copy - NoDrag(const NoDrag<CloudType>& dm); + SRFForce(const SRFForce& srff); //- Construct and return a clone - virtual autoPtr<DragModel<CloudType> > clone() const + virtual autoPtr<ParticleForce<CloudType> > clone() const { - return autoPtr<DragModel<CloudType> > + return autoPtr<ParticleForce<CloudType> > ( - new NoDrag<CloudType>(*this) + new ParticleForce<CloudType>(*this) ); } //- Destructor - virtual ~NoDrag(); + virtual ~SRFForce(); // Member Functions - //- Flag to indicate whether model activates drag model - bool active() const; + // Evaluation - //- Return drag coefficient - scalar Cd(const scalar) const; + //- Cache fields + virtual void cacheFields(const bool store); + + //- Calculate the non-coupled force + virtual forceSuSp calcNonCoupled + ( + const typename CloudType::parcelType& p, + const scalar dt, + const scalar mass, + const scalar Re, + const scalar muc + ) const; }; @@ -92,7 +121,7 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #ifdef NoRepository -# include "NoDrag.C" + #include "SRFForce.C" #endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/forceSuSp/forceSuSp.H b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/forceSuSp/forceSuSp.H new file mode 100644 index 0000000000000000000000000000000000000000..7bf439fa03d6b43ec3dfe6cb268af37f5e3cd0d9 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/forceSuSp/forceSuSp.H @@ -0,0 +1,143 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::forceSuSp + +Description + Helper container for force Su and Sp terms. + + F = Sp(U - Up) + Su + + Explicit contribution, Su specified as a force + Implicit coefficient, Sp specified as force/velocity + +SourceFiles + forceSuSpI.H + +\*---------------------------------------------------------------------------*/ + +#ifndef forceSuSp_H +#define forceSuSp_H + +#include "Tuple2.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of friend functions +class forceSuSp; +inline forceSuSp operator+(const forceSuSp& susp1, const forceSuSp& susp2); +inline forceSuSp operator*(const forceSuSp& susp, const scalar s); + +/*---------------------------------------------------------------------------*\ + Class forceSuSp Declaration +\*---------------------------------------------------------------------------*/ + +class forceSuSp +: + public Tuple2<vector, scalar> +{ + +public: + + // Constructors + + //- Construct null + inline forceSuSp(); + + //- Construct given Tuple2 + inline forceSuSp(const Tuple2<vector, scalar>& susp); + + //- Construct given two components + inline forceSuSp(const vector& Su, const scalar Sp); + + //- Construct from Istream + inline forceSuSp(Istream&); + + + // Member Functions + + // Access + + //- Return const access to the explicit contribution [kg.m/s2] + inline const vector& Su() const; + + //- Return const access to the implicit coefficient [kg/s] + inline scalar Sp() const; + + + // Edit + + //- Return reference to the explicit contribution + inline vector& Su(); + + //- Return reference to the implicit coefficient + inline scalar& Sp(); + + + // Operators + + //- Assignment + inline void operator=(const forceSuSp& susp); + + //- Addition + inline void operator+=(const forceSuSp& susp); + + //- Subtraction + inline void operator-=(const forceSuSp& susp); + + + // Friend operators + + //- Addition + friend inline forceSuSp operator* + ( + const forceSuSp& susp1, + const forceSuSp& susp2 + ); + + //- Multiplication + friend inline forceSuSp operator* + ( + const scalar s, + const forceSuSp& susp + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "forceSuSpI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/forceSuSp/forceSuSpI.H b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/forceSuSp/forceSuSpI.H new file mode 100644 index 0000000000000000000000000000000000000000..2b945cfb19d528ad9f78509bca689d78027c5438 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/forceSuSp/forceSuSpI.H @@ -0,0 +1,129 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * // + +inline Foam::forceSuSp::forceSuSp() +{} + + +inline Foam::forceSuSp::forceSuSp +( + const Tuple2<vector, scalar>& fs +) +: + Tuple2<vector, scalar>(fs) +{} + + +inline Foam::forceSuSp::forceSuSp(const vector& Su, const scalar Sp) +{ + first() = Su; + second() = Sp; +} + + +inline Foam::forceSuSp::forceSuSp(Istream& is) +: + Tuple2<vector, scalar>(is) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +inline const Foam::vector& Foam::forceSuSp::Su() const +{ + return first(); +} + + +inline Foam::scalar Foam::forceSuSp::Sp() const +{ + return second(); +} + + +inline Foam::vector& Foam::forceSuSp::Su() +{ + return first(); +} + + +inline Foam::scalar& Foam::forceSuSp::Sp() +{ + return second(); +} + + +// * * * * * * * * * * * * * * * Operators * * * * * * * * * * * * * * * * * // + +inline void Foam::forceSuSp::operator=(const forceSuSp& susp) +{ + first() = susp.first(); + second() = susp.second(); +} + + +inline void Foam::forceSuSp::operator+=(const forceSuSp& susp) +{ + first() += susp.first(); + second() += susp.second(); +} + + +inline void Foam::forceSuSp::operator-=(const forceSuSp& susp) +{ + first() -= susp.first(); + second() -= susp.second(); +} + + +// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // + +inline Foam::forceSuSp Foam::operator+ +( + const forceSuSp& susp1, + const forceSuSp& susp2 +) +{ + return forceSuSp + ( + susp1.first() + susp2.first(), + susp1.second() + susp2.second() + ); +} + + +inline Foam::forceSuSp Foam::operator* +( + const scalar s, + const forceSuSp& susp +) +{ + return forceSuSp(susp.first()*s, susp.second()*s); +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C index 7348c146c76f53723e46e8f3ba7e7d08ee85b75f..465dd9b04f3ccf2194d569751c9499c759b34e80 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -45,6 +45,67 @@ Foam::label Foam::LocalInteraction<CloudType>::applyToPatch } +template<class CloudType> +void Foam::LocalInteraction<CloudType>::readProps() +{ + IOobject propsDictHeader + ( + "localInteractionProperties", + this->owner().db().time().timeName(), + "uniform"/cloud::prefix/this->owner().name(), + this->owner().db(), + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ); + + if (propsDictHeader.headerOk()) + { + const IOdictionary propsDict(propsDictHeader); + + propsDict.readIfPresent("nEscape", nEscape0_); + propsDict.readIfPresent("massEscape", massEscape0_); + propsDict.readIfPresent("nStick", nStick0_); + propsDict.readIfPresent("massStick", massStick0_); + } +} + + +template<class CloudType> +void Foam::LocalInteraction<CloudType>::writeProps +( + const labelList& nEscape, + const scalarList& massEscape, + const labelList& nStick, + const scalarList& massStick +) const +{ + if (this->owner().db().time().outputTime()) + { + IOdictionary propsDict + ( + IOobject + ( + "localInteractionProperties", + this->owner().db().time().timeName(), + "uniform"/cloud::prefix/this->owner().name(), + this->owner().db(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ) + ); + + propsDict.add("nEscape", nEscape); + propsDict.add("massEscape", massEscape); + propsDict.add("nStick", nStick); + propsDict.add("massStick", massStick); + + propsDict.regIOobject::write(); + } +} + + // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // template<class CloudType> @@ -56,7 +117,15 @@ Foam::LocalInteraction<CloudType>::LocalInteraction : PatchInteractionModel<CloudType>(dict, cloud, typeName), patchData_(this->coeffDict().lookup("patches")), - patchIds_(patchData_.size()) + patchIds_(patchData_.size()), + nEscape0_(patchData_.size(), 0), + massEscape0_(patchData_.size(), 0.0), + nStick0_(patchData_.size(), 0), + massStick0_(patchData_.size(), 0.0), + nEscape_(patchData_.size(), 0), + massEscape_(patchData_.size(), 0.0), + nStick_(patchData_.size(), 0), + massStick_(patchData_.size(), 0.0) { const polyMesh& mesh = cloud.mesh(); const polyBoundaryMesh& bMesh = mesh.boundaryMesh(); @@ -115,6 +184,8 @@ Foam::LocalInteraction<CloudType>::LocalInteraction << nl << exit(FatalError); } } + + readProps(); } @@ -126,7 +197,15 @@ Foam::LocalInteraction<CloudType>::LocalInteraction : PatchInteractionModel<CloudType>(pim), patchData_(pim.patchData_), - patchIds_(pim.patchIds_) + patchIds_(pim.patchIds_), + nEscape0_(pim.nEscape0_), + massEscape0_(pim.massEscape0_), + nStick0_(pim.nStick0_), + massStick0_(pim.massStick0_), + nEscape_(pim.nEscape_), + massEscape_(pim.massEscape_), + nStick_(pim.nStick_), + massStick_(pim.massStick_) {} @@ -147,7 +226,7 @@ bool Foam::LocalInteraction<CloudType>::correct bool& keepParticle, const scalar trackFraction, const tetIndices& tetIs -) const +) { vector& U = p.U(); @@ -170,6 +249,8 @@ bool Foam::LocalInteraction<CloudType>::correct keepParticle = false; active = false; U = vector::zero; + nEscape_[patchI]++; + massEscape_[patchI] += p.mass()*p.nParticle(); break; } case PatchInteractionModel<CloudType>::itStick: @@ -177,6 +258,8 @@ bool Foam::LocalInteraction<CloudType>::correct keepParticle = true; active = false; U = vector::zero; + nStick_[patchI]++; + massStick_[patchI] += p.mass()*p.nParticle(); break; } case PatchInteractionModel<CloudType>::itRebound: @@ -235,4 +318,38 @@ bool Foam::LocalInteraction<CloudType>::correct } +template<class CloudType> +void Foam::LocalInteraction<CloudType>::info(Ostream& os) const +{ + labelList npe(nEscape_); + Pstream::listCombineGather(npe, plusEqOp<label>()); + npe = npe + nEscape0_; + + scalarList mpe(massEscape_); + Pstream::listCombineGather(mpe, plusEqOp<scalar>()); + mpe = mpe + massEscape0_; + + labelList nps(nStick_); + Pstream::listCombineGather(nps, plusEqOp<label>()); + nps = nps + nStick0_; + + scalarList mps(massStick_); + Pstream::listCombineGather(mps, plusEqOp<scalar>()); + mps = mps + massStick0_; + + + forAll(patchData_, i) + { + os << " Parcel fate (number, mass) : patch " + << patchData_[i].patchName() << nl + << " - escape = " << npe[i] + << ", " << mpe[i] << nl + << " - stick = " << nps[i] + << ", " << mps[i] << nl; + } + + writeProps(npe, mpe, nps, mps); +} + + // ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.H b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.H index 5fe6d719ef128315ef20f6dac4d92ed61baba9cd..7360b66f16ee0245f2c46244748c0310b7c34d0f 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -57,11 +57,52 @@ class LocalInteraction List<label> patchIds_; + // Counters for initial particle fates + + //- Number of parcels escaped + List<label> nEscape0_; + + //- Mass of parcels escaped + List<scalar> massEscape0_; + + //- Number of parcels stuck to patches + List<label> nStick0_; + + //- Mass of parcels stuck to patches + List<scalar> massStick0_; + + + // Counters for particle fates + + //- Number of parcels escaped + List<label> nEscape_; + + //- Mass of parcels escaped + List<scalar> massEscape_; + + //- Number of parcels stuck to patches + List<label> nStick_; + + //- Mass of parcels stuck to patches + List<scalar> massStick_; + + // Private Member Functions //- Returns local patchI if patch is in patchIds_ list label applyToPatch(const label globalPatchI) const; + //- Read interaction properties from file + void readProps(); + + //- Write interaction properties to file + void writeProps + ( + const labelList& nEscape, + const scalarList& massEscape, + const labelList& nStick, + const scalarList& massStick + ) const; public: @@ -103,7 +144,13 @@ public: bool& keepParticle, const scalar trackFraction, const tetIndices& tetIs - ) const; + ); + + + // I-O + + //- Write patch interaction info to stream + virtual void info(Ostream& os) const; }; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/NoInteraction/NoInteraction.C b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/NoInteraction/NoInteraction.C index 96fb215886fed4263af5ec853659b3d30d9f93e6..6eb7c6afaa025a23ab6aa0757afee64c775d7d8c 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/NoInteraction/NoInteraction.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/NoInteraction/NoInteraction.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -72,7 +72,7 @@ bool Foam::NoInteraction<CloudType>::correct bool&, const scalar, const tetIndices& -) const +) { notImplemented ( diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/NoInteraction/NoInteraction.H b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/NoInteraction/NoInteraction.H index b686bad474597f1d5c0356523ce9682701053b00..f12409dae0da0e1ea52fdd6e4705e7d8992e3992 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/NoInteraction/NoInteraction.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/NoInteraction/NoInteraction.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -90,7 +90,7 @@ public: bool& keepParticle, const scalar trackFraction, const tetIndices& tetIs - ) const; + ); }; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/PatchInteractionModel/PatchInteractionModel.C b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/PatchInteractionModel/PatchInteractionModel.C index fd04066e1f19b0fae888a48b731e6a4f1af62610..5d0c848594bda963ffd24e802118636b8255dc31 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/PatchInteractionModel/PatchInteractionModel.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/PatchInteractionModel/PatchInteractionModel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -163,7 +163,7 @@ bool Foam::PatchInteractionModel<CloudType>::correct bool&, const scalar, const tetIndices& -) const +) { notImplemented ( @@ -331,6 +331,13 @@ void Foam::PatchInteractionModel<CloudType>::patchData } +template<class CloudType> +void Foam::PatchInteractionModel<CloudType>::info(Ostream& os) const +{ + // do nothing +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #include "PatchInteractionModelNew.C" diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/PatchInteractionModel/PatchInteractionModel.H b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/PatchInteractionModel/PatchInteractionModel.H index daa3d1e6638019112c32b99d531dac76bf0d9363..45e36a68d364243c07517b4280dfa5a5ecdfa164 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/PatchInteractionModel/PatchInteractionModel.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/PatchInteractionModel/PatchInteractionModel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -162,7 +162,7 @@ public: bool& keepParticle, const scalar trackFraction, const tetIndices& tetIs - ) const; + ); //- Calculate the patch normal and velocity to interact with, // accounting for patch motion if required. @@ -175,6 +175,12 @@ public: vector& normal, vector& Up ) const; + + + // I-O + + //- Write patch interaction info to stream + virtual void info(Ostream& os) const; }; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/Rebound/Rebound.C b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/Rebound/Rebound.C index be60656329865fe0dbd16a56aaa5b21b3c2dacf5..fed11d9c123162fe828cd0eb61aa8c5301990321 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/Rebound/Rebound.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/Rebound/Rebound.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -64,7 +64,7 @@ bool Foam::Rebound<CloudType>::correct bool& keepParticle, const scalar trackFraction, const tetIndices& tetIs -) const +) { vector& U = p.U(); diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/Rebound/Rebound.H b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/Rebound/Rebound.H index 8d0d1a3f5916e79992b370036c69e82f5d6d9c68..a79ea75824aa5c085a5687b7eac657a0b1db3c76 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/Rebound/Rebound.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/Rebound/Rebound.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -92,7 +92,7 @@ public: bool& keepParticle, const scalar trackFraction, const tetIndices& tetIs - ) const; + ); }; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/StandardWallInteraction/StandardWallInteraction.C b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/StandardWallInteraction/StandardWallInteraction.C index be68d2f017868760cc7d6c4ff6eb9e32fb06a33b..dd89d289270a4a51d3fe51abd3df488d8286770b 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/StandardWallInteraction/StandardWallInteraction.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/StandardWallInteraction/StandardWallInteraction.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -106,7 +106,7 @@ bool Foam::StandardWallInteraction<CloudType>::correct bool& keepParticle, const scalar trackFraction, const tetIndices& tetIs -) const +) { vector& U = p.U(); diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/StandardWallInteraction/StandardWallInteraction.H b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/StandardWallInteraction/StandardWallInteraction.H index 4a6ed569b22a50a25007992c7a843dcc1feeb324..60421a08c7aa5eea16bc5b22ccbbb5d452880ddb 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/StandardWallInteraction/StandardWallInteraction.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/StandardWallInteraction/StandardWallInteraction.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -113,7 +113,7 @@ public: bool& keepParticle, const scalar trackFraction, const tetIndices& tetIs - ) const; + ); }; diff --git a/src/lagrangian/intermediate/submodels/ReactingMultiphase/SurfaceReactionModel/NoSurfaceReaction/NoSurfaceReaction.C b/src/lagrangian/intermediate/submodels/ReactingMultiphase/SurfaceReactionModel/NoSurfaceReaction/NoSurfaceReaction.C index 15cb57956a8ba72d3e3cf1b44e859c3d192745c6..53008a165f8d46c471bc348c1a595fb27e67c099 100644 --- a/src/lagrangian/intermediate/submodels/ReactingMultiphase/SurfaceReactionModel/NoSurfaceReaction/NoSurfaceReaction.C +++ b/src/lagrangian/intermediate/submodels/ReactingMultiphase/SurfaceReactionModel/NoSurfaceReaction/NoSurfaceReaction.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/ReactingMultiphase/SurfaceReactionModel/NoSurfaceReaction/NoSurfaceReaction.H b/src/lagrangian/intermediate/submodels/ReactingMultiphase/SurfaceReactionModel/NoSurfaceReaction/NoSurfaceReaction.H index 36fc9d6283a3c432ba93348175df9c7a2345d32d..073387f7e6d49a3dda39e50db0472af6866f3643 100644 --- a/src/lagrangian/intermediate/submodels/ReactingMultiphase/SurfaceReactionModel/NoSurfaceReaction/NoSurfaceReaction.H +++ b/src/lagrangian/intermediate/submodels/ReactingMultiphase/SurfaceReactionModel/NoSurfaceReaction/NoSurfaceReaction.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/ReactingMultiphase/SurfaceReactionModel/SurfaceReactionModel/SurfaceReactionModel.C b/src/lagrangian/intermediate/submodels/ReactingMultiphase/SurfaceReactionModel/SurfaceReactionModel/SurfaceReactionModel.C index a9b902be9c2478f1de3f91ea79243d735b82f469..adfcd0cbfb60e914fbeb2a781245d9bd36232940 100644 --- a/src/lagrangian/intermediate/submodels/ReactingMultiphase/SurfaceReactionModel/SurfaceReactionModel/SurfaceReactionModel.C +++ b/src/lagrangian/intermediate/submodels/ReactingMultiphase/SurfaceReactionModel/SurfaceReactionModel/SurfaceReactionModel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/ReactingMultiphase/SurfaceReactionModel/SurfaceReactionModel/SurfaceReactionModel.H b/src/lagrangian/intermediate/submodels/ReactingMultiphase/SurfaceReactionModel/SurfaceReactionModel/SurfaceReactionModel.H index 263dc1d7b04c23b7c4223b26f54c95a43e98617c..ff60f44a5aefb001efcc9e3db2558d0a603730f8 100644 --- a/src/lagrangian/intermediate/submodels/ReactingMultiphase/SurfaceReactionModel/SurfaceReactionModel/SurfaceReactionModel.H +++ b/src/lagrangian/intermediate/submodels/ReactingMultiphase/SurfaceReactionModel/SurfaceReactionModel/SurfaceReactionModel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/ReactingMultiphase/SurfaceReactionModel/SurfaceReactionModel/SurfaceReactionModelNew.C b/src/lagrangian/intermediate/submodels/ReactingMultiphase/SurfaceReactionModel/SurfaceReactionModel/SurfaceReactionModelNew.C index 07984335a2a0418b08d90ccb09f56243b97cea25..3369cf5b08e99b99ccccdd3f2e08017c765a8592 100644 --- a/src/lagrangian/intermediate/submodels/ReactingMultiphase/SurfaceReactionModel/SurfaceReactionModel/SurfaceReactionModelNew.C +++ b/src/lagrangian/intermediate/submodels/ReactingMultiphase/SurfaceReactionModel/SurfaceReactionModel/SurfaceReactionModelNew.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/HeatTransferModel/HeatTransferModel.C b/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/HeatTransferModel/HeatTransferModel.C index 0e10c66eb7d1b40c6ff5095aa01a6f5bc1d27f6e..2c1def8fb9e4d6997089012a7686e27dead226ed 100644 --- a/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/HeatTransferModel/HeatTransferModel.C +++ b/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/HeatTransferModel/HeatTransferModel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/HeatTransferModel/HeatTransferModel.H b/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/HeatTransferModel/HeatTransferModel.H index f19aee9c662eb5bb45d7d235b60ab546813cb879..2e670c662375f124afa236ea6aa95199beed3b6c 100644 --- a/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/HeatTransferModel/HeatTransferModel.H +++ b/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/HeatTransferModel/HeatTransferModel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/HeatTransferModel/HeatTransferModelNew.C b/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/HeatTransferModel/HeatTransferModelNew.C index 22f8ae1f9af8428c96da164fe8918baa2bebd5f9..bcb6c2e4f2b235b2b320f761730d19a4a882eaf3 100644 --- a/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/HeatTransferModel/HeatTransferModelNew.C +++ b/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/HeatTransferModel/HeatTransferModelNew.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/NoHeatTransfer/NoHeatTransfer.C b/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/NoHeatTransfer/NoHeatTransfer.C index 97a6bee750463f2424a8a226e8b9413d292f0e05..afd198f30cbb7325c146902fecf1601211cf7b10 100644 --- a/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/NoHeatTransfer/NoHeatTransfer.C +++ b/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/NoHeatTransfer/NoHeatTransfer.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/NoHeatTransfer/NoHeatTransfer.H b/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/NoHeatTransfer/NoHeatTransfer.H index 4fb7dfce02af898f7f87863032b4a061843288e8..a7a274dbee1c220a6e592246b2575842b4020f69 100644 --- a/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/NoHeatTransfer/NoHeatTransfer.H +++ b/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/NoHeatTransfer/NoHeatTransfer.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/RanzMarshall/RanzMarshall.C b/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/RanzMarshall/RanzMarshall.C index 9caccdfde3ab74ed0820b68e5ba2ae98ece0a403..69f2a4c64afa878e152e182e587959b945d60953 100644 --- a/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/RanzMarshall/RanzMarshall.C +++ b/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/RanzMarshall/RanzMarshall.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/RanzMarshall/RanzMarshall.H b/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/RanzMarshall/RanzMarshall.H index bed0575ee1ee55a8ad56bd59023da53c5621408e..d7550afd264b40db71cba5d0a800558de2df8174 100644 --- a/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/RanzMarshall/RanzMarshall.H +++ b/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/RanzMarshall/RanzMarshall.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/Thermodynamic/ParticleForces/BrownianMotion/BrownianMotionForce.C b/src/lagrangian/intermediate/submodels/Thermodynamic/ParticleForces/BrownianMotion/BrownianMotionForce.C new file mode 100644 index 0000000000000000000000000000000000000000..5d2c759b9413147abd896c90e713e5b24446b250 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Thermodynamic/ParticleForces/BrownianMotion/BrownianMotionForce.C @@ -0,0 +1,209 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "BrownianMotionForce.H" +#include "mathematicalConstants.H" +#include "demandDrivenData.H" + +using namespace Foam::constant; + +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +template<class CloudType> +Foam::scalar Foam::BrownianMotionForce<CloudType>::erfInv(const scalar y) const +{ + const scalar a = 0.147; + scalar k = 2.0/(mathematical::pi*a) + 0.5*log(1.0 - y*y); + scalar h = log(1.0 - y*y)/a; + scalar x = sqrt(-k + sqrt(k*k - h)); + + if (y < 0.0) + { + return -x; + } + else + { + return x; + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class CloudType> +Foam::BrownianMotionForce<CloudType>::BrownianMotionForce +( + CloudType& owner, + const fvMesh& mesh, + const dictionary& dict, + const word& forceType +) +: + ParticleForce<CloudType>(owner, mesh, dict, forceType), + rndGen_(owner.rndGen()), + lambda_(readScalar(this->coeffs().lookup("lambda"))), + turbulence_(readBool(this->coeffs().lookup("turbulence"))), + turbulenceModelPtr_(NULL), + kPtr_(NULL), + ownK_(false) +{ + if (turbulence_) + { + HashTable<const compressible::turbulenceModel*> models = + this->mesh().objectRegistry::lookupClass + < + compressible::turbulenceModel + >(); + + if (models.size() == 1) + { + turbulenceModelPtr_ = models.begin()(); + } + else + { + FatalErrorIn + ( + "Foam::BrownianMotionForce<CloudType>::BrownianMotionForce" + "(" + "CloudType&, " + "const fvMesh&, " + "const dictionary&" + ")" + ) << "Unable to find a valid turbulence model in mesh database" + << exit(FatalError); + } + } +} + + +template<class CloudType> +Foam::BrownianMotionForce<CloudType>::BrownianMotionForce +( + const BrownianMotionForce& bmf +) +: + ParticleForce<CloudType>(bmf), + rndGen_(bmf.rndGen_), + lambda_(bmf.lambda_), + turbulence_(bmf.turbulence_), + turbulenceModelPtr_(NULL), + kPtr_(NULL), + ownK_(false) +{} + + +// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * // + +template<class CloudType> +Foam::BrownianMotionForce<CloudType>::~BrownianMotionForce() +{ + turbulenceModelPtr_ = NULL; +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class CloudType> +void Foam::BrownianMotionForce<CloudType>::cacheFields(const bool store) +{ + if (turbulence_) + { + if (store) + { + tmp<volScalarField> tk = turbulenceModelPtr_->k(); + if (tk.isTmp()) + { + kPtr_ = tk.ptr(); + ownK_ = true; + } + else + { + kPtr_ = tk.operator->(); + ownK_ = false; + } + } + else + { + if (ownK_ && kPtr_) + { + deleteDemandDrivenData(kPtr_); + ownK_ = false; + } + } + } +} + + +template<class CloudType> +Foam::forceSuSp Foam::BrownianMotionForce<CloudType>::calcCoupled +( + const typename CloudType::parcelType& p, + const scalar dt, + const scalar mass, + const scalar Re, + const scalar muc +) const +{ + forceSuSp value(vector::zero, 0.0); + + const scalar dp = p.d(); + const scalar Tc = p.Tc(); + + const scalar eta = rndGen_.sample01<scalar>(); + const scalar alpha = 2.0*lambda_/dp; + const scalar cc = 1.0 + alpha*(1.257 + 0.4*exp(-1.1/alpha)); + + const scalar sigma = physicoChemical::sigma.value(); + + scalar f = 0.0; + if (turbulence_) + { + const label cellI = p.cell(); + const volScalarField& k = *kPtr_; + const scalar kc = k[cellI]; + const scalar Dp = sigma*Tc*cc/(3*mathematical::pi*muc*dp); + f = eta/mass*sqrt(2.0*sqr(kc)*sqr(Tc)/(Dp*dt)); + } + else + { + const scalar rhoRatio = p.rho()/p.rhoc(); + const scalar s0 = + 216*muc*sigma*Tc/(sqr(mathematical::pi)*pow5(dp)*(rhoRatio)*cc); + f = eta*sqrt(mathematical::pi*s0/dt); + } + + const scalar sqrt2 = sqrt(2.0); + for (label i = 0; i < 3; i++) + { + const scalar x = rndGen_.sample01<scalar>(); + const scalar eta = sqrt2*erfInv(2*x - 1.0); + value.Su()[i] = mass*f*eta; + } + + return value; +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Thermodynamic/ParticleForces/BrownianMotion/BrownianMotionForce.H b/src/lagrangian/intermediate/submodels/Thermodynamic/ParticleForces/BrownianMotion/BrownianMotionForce.H new file mode 100644 index 0000000000000000000000000000000000000000..03fed149c972dfd7e1725f4b041fe154249c68be --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Thermodynamic/ParticleForces/BrownianMotion/BrownianMotionForce.H @@ -0,0 +1,162 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::BrownianMotionForce + +Description + Calculates particle Brownian motion force + +SourceFiles + BrownianMotionForceI.H + BrownianMotionForce.C + +\*---------------------------------------------------------------------------*/ + +#ifndef BrownianMotionForce_H +#define BrownianMotionForce_H + +#include "ParticleForce.H" +#include "cachedRandom.H" +#include "turbulenceModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class BrownianMotionForce Declaration +\*---------------------------------------------------------------------------*/ + +template<class CloudType> +class BrownianMotionForce +: + public ParticleForce<CloudType> +{ + // Private data + + //- Reference to the cloud random number generator + cachedRandom& rndGen_; + + //- Molecular free path length [m] + const scalar lambda_; + + //- Turbulence flag + bool turbulence_; + + //- Reference to a compressible turbulence model + const compressible::turbulenceModel* turbulenceModelPtr_; + + //- Pointer to the turbulence kinetic energy field + const volScalarField* kPtr_; + + //- Flag that indicates ownership of turbulence k field + bool ownK_; + + + // Private Member Functions + + //- Inverse erf for Gaussian distribution + scalar erfInv(const scalar y) const; + + +public: + + //- Runtime type information + TypeName("BrownianMotion"); + + + // Constructors + + //- Construct from mesh + BrownianMotionForce + ( + CloudType& owner, + const fvMesh& mesh, + const dictionary& dict, + const word& forceType + ); + + //- Construct copy + BrownianMotionForce(const BrownianMotionForce& bmf); + + //- Construct and return a clone + virtual autoPtr<ParticleForce<CloudType> > clone() const + { + return autoPtr<ParticleForce<CloudType> > + ( + new BrownianMotionForce<CloudType>(*this) + ); + } + + + //- Destructor + virtual ~BrownianMotionForce(); + + + // Member Functions + + // Access + + //- Return const access to the molecular free path length [m] + inline scalar lambda() const; + + //- Return const access to the turbulence flag + inline bool turbulence() const; + + + // Evaluation + + //- Cache fields + virtual void cacheFields(const bool store); + + //- Calculate the non-coupled force + virtual forceSuSp calcCoupled + ( + const typename CloudType::parcelType& p, + const scalar dt, + const scalar mass, + const scalar Re, + const scalar muc + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "BrownianMotionForceI.H" + +#ifdef NoRepository + #include "BrownianMotionForce.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Thermodynamic/ParticleForces/BrownianMotion/BrownianMotionForceI.H b/src/lagrangian/intermediate/submodels/Thermodynamic/ParticleForces/BrownianMotion/BrownianMotionForceI.H new file mode 100644 index 0000000000000000000000000000000000000000..8bc3da87eb2d9ac9679f6e063e7e06dbff4c8bfb --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Thermodynamic/ParticleForces/BrownianMotion/BrownianMotionForceI.H @@ -0,0 +1,42 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class CloudType> +inline Foam::scalar Foam::BrownianMotionForce<CloudType>::lambda() const +{ + return lambda_; +} + + +template<class CloudType> +inline bool Foam::BrownianMotionForce<CloudType>::turbulence() const +{ + return turbulence_; +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.C b/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.C index 31a30878083cbfb6673ea090caf26d7ff4429b92..8efb70bacfe69a3da19ed9c942d6098d9cc00999 100644 --- a/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.C +++ b/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.H b/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.H index 34da1ebc0cd2e77615829edf55c72d0549c87885..33b681cf6a536e48bdcccae740eac0ac27167ad8 100644 --- a/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.H +++ b/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.C b/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.C index 58bbf5aa1dc0fb27d52833e3c5c2eddef2df82f2..4c8ce3a10e1c991b8df555378b013e77ee793eae 100644 --- a/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.C +++ b/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.H b/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.H index 21bd0558f79780bad72589929f642de75e42e3ad..c33dfed8dfada74ffb0227bd5974a6f10d03a177 100644 --- a/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.H +++ b/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C index 46d4ae134313aeea7bca212527f51394aa7dca98..164da09c5ba883db5d31735b984da0db95173908 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -45,6 +45,7 @@ Description #include "layerParameters.H" #include "combineFaces.H" #include "IOmanip.H" +#include "globalIndex.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -888,68 +889,6 @@ void Foam::autoLayerDriver::handleNonManifolds Info<< "Outside of local patch is multiply connected across edges or" << " points at " << nNonManif << " points." << endl; - - const labelList& meshPoints = pp.meshPoints(); - - - // 2. Parallel check - // For now disable extrusion at any shared edges. - const labelHashSet sharedEdgeSet(mesh.globalData().sharedEdgeLabels()); - - forAll(pp.edges(), edgeI) - { - if (sharedEdgeSet.found(meshEdges[edgeI])) - { - const edge& e = mesh.edges()[meshEdges[edgeI]]; - - Pout<< "Disabling extrusion at edge " - << mesh.points()[e[0]] << mesh.points()[e[1]] - << " since it is non-manifold across coupled patches." - << endl; - - nonManifoldPoints.insert(e[0]); - nonManifoldPoints.insert(e[1]); - } - } - - // 3b. extrusion can produce multiple faces between 2 cells - // across processor boundary - // This occurs when a coupled face shares more than 1 edge with a - // non-coupled boundary face. - // This is now correctly handled by addPatchCellLayer in that it - // extrudes a single face from the stringed up edges. - - - nNonManif = returnReduce(nonManifoldPoints.size(), sumOp<label>()); - - if (nNonManif > 0) - { - Info<< "Outside of patches is multiply connected across edges or" - << " points at " << nNonManif << " points." << nl - << "Writing " << nNonManif - << " points where this happens to pointSet " - << nonManifoldPoints.name() << nl - << "and setting layer thickness to zero on these points." - << endl; - - nonManifoldPoints.instance() = mesh.time().timeName(); - nonManifoldPoints.write(); - - forAll(meshPoints, patchPointI) - { - if (nonManifoldPoints.found(meshPoints[patchPointI])) - { - unmarkExtrusion - ( - patchPointI, - patchDisp, - patchNLayers, - extrudeStatus - ); - } - } - } - Info<< "Set displacement to zero for all " << nNonManif << " non-manifold points" << endl; } @@ -1348,7 +1287,6 @@ void Foam::autoLayerDriver::setNumLayers } -// Grow no-extrusion layer void Foam::autoLayerDriver::growNoExtrusion ( const indirectPrimitivePatch& pp, @@ -1439,6 +1377,103 @@ void Foam::autoLayerDriver::growNoExtrusion } +void Foam::autoLayerDriver::determineSidePatches +( + const globalIndex& globalFaces, + const labelListList& edgeGlobalFaces, + const indirectPrimitivePatch& pp, + + labelList& sidePatchID +) +{ + // Sometimes edges-to-be-extruded are on more than 2 processors. + // Work out which 2 hold the faces to be extruded and thus which procpatch + // the side-face should be in. As an additional complication this might + // mean that 2 procesors that were only edge-connected now suddenly need + // to become face-connected i.e. have a processor patch between them. + + fvMesh& mesh = meshRefiner_.mesh(); + + // Determine sidePatchID. Any additional processor boundary gets added to + // patchToNbrProc,nbrProcToPatch and nPatches gets set to the new number + // of patches. + label nPatches; + Map<label> nbrProcToPatch; + Map<label> patchToNbrProc; + addPatchCellLayer::calcSidePatch + ( + mesh, + globalFaces, + edgeGlobalFaces, + pp, + + sidePatchID, + nPatches, + nbrProcToPatch, + patchToNbrProc + ); + + label nOldPatches = mesh.boundaryMesh().size(); + label nAdded = returnReduce(nPatches-nOldPatches, sumOp<label>()); + Info<< nl << "Adding in total " << nAdded/2 << " inter-processor patches to" + << " handle extrusion of non-manifold processor boundaries." + << endl; + + if (nAdded > 0) + { + // We might not add patches in same order as in patchToNbrProc + // so prepare to renumber sidePatchID + Map<label> wantedToAddedPatch; + + for (label patchI = nOldPatches; patchI < nPatches; patchI++) + { + label nbrProcI = patchToNbrProc[patchI]; + word name = + "procBoundary" + + Foam::name(Pstream::myProcNo()) + + "to" + + Foam::name(nbrProcI); + + dictionary patchDict; + patchDict.add("type", processorPolyPatch::typeName); + patchDict.add("myProcNo", Pstream::myProcNo()); + patchDict.add("neighbProcNo", nbrProcI); + patchDict.add("nFaces", 0); + patchDict.add("startFace", mesh.nFaces()); + + Pout<< "Adding patch " << patchI + << " name:" << name + << " between " << Pstream::myProcNo() + << " and " << nbrProcI + << endl; + + label procPatchI = meshRefiner_.appendPatch + ( + mesh, + mesh.boundaryMesh().size(), // new patch index + name, + patchDict + ); + wantedToAddedPatch.insert(patchI, procPatchI); + } + + // Renumber sidePatchID + forAll(sidePatchID, i) + { + label patchI = sidePatchID[i]; + Map<label>::const_iterator fnd = wantedToAddedPatch.find(patchI); + if (fnd != wantedToAddedPatch.end()) + { + sidePatchID[i] = fnd(); + } + } + + mesh.clearOut(); + const_cast<polyBoundaryMesh&>(mesh.boundaryMesh()).updateMesh(); + } +} + + void Foam::autoLayerDriver::calculateLayerThickness ( const indirectPrimitivePatch& pp, @@ -2553,6 +2588,37 @@ void Foam::autoLayerDriver::addLayers ) ); + + // Global face indices engine + const globalIndex globalFaces(mesh.nFaces()); + + // Determine extrudePatch.edgeFaces in global numbering (so across + // coupled patches). This is used only to string up edges between coupled + // faces (all edges between same (global)face indices get extruded). + labelListList edgeGlobalFaces + ( + addPatchCellLayer::globalEdgeFaces + ( + mesh, + globalFaces, + pp + ) + ); + + // Determine patches for extruded boundary edges. Calculates if any + // additional processor patches need to be constructed. + + labelList sidePatchID; + determineSidePatches + ( + globalFaces, + edgeGlobalFaces, + pp, + + sidePatchID + ); + + // Construct iterative mesh mover. Info<< "Constructing mesh displacer ..." << endl; @@ -3038,8 +3104,12 @@ void Foam::autoLayerDriver::addLayers // Not add layer if patchDisp is zero. addLayer.setRefinement ( + globalFaces, + edgeGlobalFaces, + invExpansionRatio, pp(), + sidePatchID, // boundary patch for extruded boundary edges labelList(0), // exposed patchIDs, not used for adding layers nPatchFaceLayers, // layers per face nPatchPointLayers, // layers per point diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H index c96e304983ead0e5d07a31a06141a386e85bbe4f..fd5a1f3aa881b53130ad551a6ae93dc1ee1756e5 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -243,6 +243,16 @@ class autoLayerDriver List<extrudeMode>& extrudeStatus ) const; + //- See what patches boundaryedges should be extruded into + void determineSidePatches + ( + const globalIndex& globalFaces, + const labelListList& edgeGlobalFaces, + const indirectPrimitivePatch& pp, + + labelList& sidePatchID + ); + //- Calculate pointwise wanted and minimum thickness. // thickness: wanted thickness // minthickness: when to give up and not extrude diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C index 8a749cd60b6369d7a298c6d6df8f1d0ab779a18d..de0ba875879649100d882eb19b51a17b16695b34 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C @@ -1549,60 +1549,28 @@ void Foam::meshRefinement::checkCoupledFaceZones(const polyMesh& mesh) } -// Adds patch if not yet there. Returns patchID. -Foam::label Foam::meshRefinement::addPatch +Foam::label Foam::meshRefinement::appendPatch ( fvMesh& mesh, + const label insertPatchI, const word& patchName, - const dictionary& patchInfo + const dictionary& patchDict ) { - polyBoundaryMesh& polyPatches = - const_cast<polyBoundaryMesh&>(mesh.boundaryMesh()); - - const label patchI = polyPatches.findPatchID(patchName); - if (patchI != -1) - { - // Already there - return patchI; - } - - - label insertPatchI = polyPatches.size(); - label startFaceI = mesh.nFaces(); - - forAll(polyPatches, patchI) - { - const polyPatch& pp = polyPatches[patchI]; - - if (isA<processorPolyPatch>(pp)) - { - insertPatchI = patchI; - startFaceI = pp.start(); - break; - } - } - - - // Below is all quite a hack. Feel free to change once there is a better - // mechanism to insert and reorder patches. - // Clear local fields and e.g. polyMesh parallelInfo. mesh.clearOut(); - label sz = polyPatches.size(); - + polyBoundaryMesh& polyPatches = + const_cast<polyBoundaryMesh&>(mesh.boundaryMesh()); fvBoundaryMesh& fvPatches = const_cast<fvBoundaryMesh&>(mesh.boundary()); - dictionary patchDict(patchInfo); - patchDict.set("nFaces", 0); - patchDict.set("startFace", startFaceI); + label patchI = polyPatches.size(); // Add polyPatch at the end - polyPatches.setSize(sz+1); + polyPatches.setSize(patchI+1); polyPatches.set ( - sz, + patchI, polyPatch::New ( patchName, @@ -1611,13 +1579,13 @@ Foam::label Foam::meshRefinement::addPatch polyPatches ) ); - fvPatches.setSize(sz+1); + fvPatches.setSize(patchI+1); fvPatches.set ( - sz, + patchI, fvPatch::New ( - polyPatches[sz], // point to newly added polyPatch + polyPatches[patchI], // point to newly added polyPatch mesh.boundary() ) ); @@ -1675,21 +1643,69 @@ Foam::label Foam::meshRefinement::addPatch mesh, calculatedFvPatchField<tensor>::typeName ); + return patchI; +} + + +// Adds patch if not yet there. Returns patchID. +Foam::label Foam::meshRefinement::addPatch +( + fvMesh& mesh, + const word& patchName, + const dictionary& patchInfo +) +{ + polyBoundaryMesh& polyPatches = + const_cast<polyBoundaryMesh&>(mesh.boundaryMesh()); + fvBoundaryMesh& fvPatches = const_cast<fvBoundaryMesh&>(mesh.boundary()); + + const label patchI = polyPatches.findPatchID(patchName); + if (patchI != -1) + { + // Already there + return patchI; + } + + + label insertPatchI = polyPatches.size(); + label startFaceI = mesh.nFaces(); + + forAll(polyPatches, patchI) + { + const polyPatch& pp = polyPatches[patchI]; + + if (isA<processorPolyPatch>(pp)) + { + insertPatchI = patchI; + startFaceI = pp.start(); + break; + } + } + + dictionary patchDict(patchInfo); + patchDict.set("nFaces", 0); + patchDict.set("startFace", startFaceI); + + // Below is all quite a hack. Feel free to change once there is a better + // mechanism to insert and reorder patches. + + label addedPatchI = appendPatch(mesh, insertPatchI, patchName, patchDict); + // Create reordering list // patches before insert position stay as is - labelList oldToNew(sz+1); + labelList oldToNew(addedPatchI+1); for (label i = 0; i < insertPatchI; i++) { oldToNew[i] = i; } // patches after insert position move one up - for (label i = insertPatchI; i < sz; i++) + for (label i = insertPatchI; i < addedPatchI; i++) { oldToNew[i] = i+1; } // appended patch gets moved to insert position - oldToNew[sz] = insertPatchI; + oldToNew[addedPatchI] = insertPatchI; // Shuffle into place polyPatches.reorder(oldToNew); diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H index 7337161bb750dbe941bef9bf87aa6bbe208b1d0b..5a1d8ff821194ff719021b7ce5d32834ab1250ca 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -747,8 +747,17 @@ public: // Other topo changes + //- Helper:append patch to end of mesh. + static label appendPatch + ( + fvMesh&, + const label insertPatchI, + const word&, + const dictionary& + ); + //- Helper:add patch to mesh. Update all registered fields. - // Use addMeshedPatch to add patches originating from surfaces. + // Used by addMeshedPatch to add patches originating from surfaces. static label addPatch(fvMesh&, const word& name, const dictionary&); //- Add patch originating from meshing. Update meshedPatches_. diff --git a/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C b/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C index 18e5bf01b46c5fcf98957f628394df0523b3b6c6..b9e2d4d3e077e0eec1eccf78296ca3b06dd24a31 100644 --- a/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C +++ b/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -1007,6 +1007,82 @@ void Foam::refinementSurfaces::findNearestRegion } +void Foam::refinementSurfaces::findNearestRegion +( + const labelList& surfacesToTest, + const pointField& samples, + const scalarField& nearestDistSqr, + labelList& hitSurface, + List<pointIndexHit>& hitInfo, + labelList& hitRegion, + vectorField& hitNormal +) const +{ + labelList geometries(UIndirectList<label>(surfaces_, surfacesToTest)); + + // Do the tests. Note that findNearest returns index in geometries. + searchableSurfacesQueries::findNearest + ( + allGeometry_, + geometries, + samples, + nearestDistSqr, + hitSurface, + hitInfo + ); + + // Rework the hitSurface to be surface (i.e. index into surfaces_) + forAll(hitSurface, pointI) + { + if (hitSurface[pointI] != -1) + { + hitSurface[pointI] = surfacesToTest[hitSurface[pointI]]; + } + } + + // Collect the region + hitRegion.setSize(hitSurface.size()); + hitRegion = -1; + hitNormal.setSize(hitSurface.size()); + hitNormal = vector::zero; + + forAll(surfacesToTest, i) + { + label surfI = surfacesToTest[i]; + + // Collect hits for surfI + const labelList localIndices(findIndices(hitSurface, surfI)); + + List<pointIndexHit> localHits + ( + UIndirectList<pointIndexHit> + ( + hitInfo, + localIndices + ) + ); + + // Region + labelList localRegion; + allGeometry_[surfaces_[surfI]].getRegion(localHits, localRegion); + + forAll(localIndices, i) + { + hitRegion[localIndices[i]] = localRegion[i]; + } + + // Normal + vectorField localNormal; + allGeometry_[surfaces_[surfI]].getNormal(localHits, localNormal); + + forAll(localIndices, i) + { + hitNormal[localIndices[i]] = localNormal[i]; + } + } +} + + //// Find intersection with max of edge. Return -1 or the surface //// with the highest maxLevel above currentLevel //Foam::label Foam::refinementSurfaces::findHighestIntersection diff --git a/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.H b/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.H index dc243f316fb0ece4db4443cc624c18a5d72cac66..a7728b90824eca7117541159f8e7f1c5587df046 100644 --- a/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.H +++ b/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -327,6 +327,19 @@ public: labelList& hitRegion ) const; + //- Find nearest point on surfaces. Return surface, region and + // normal on surface (so not global surface) + void findNearestRegion + ( + const labelList& surfacesToTest, + const pointField& samples, + const scalarField& nearestDistSqr, + labelList& hitSurface, + List<pointIndexHit>& hitInfo, + labelList& hitRegion, + vectorField& hitNormal + ) const; + //- Detect if a point is 'inside' (closed) surfaces. // Returns -1 if not, returns first surface it is. void findInside diff --git a/src/meshTools/cellDist/cellDistFuncs.C b/src/meshTools/cellDist/cellDistFuncs.C index 493ee6b6668d96d4bfefdd824d1505b35a7ed247..123ea628d84998c08f19568efd701a0d5784f967 100644 --- a/src/meshTools/cellDist/cellDistFuncs.C +++ b/src/meshTools/cellDist/cellDistFuncs.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -28,14 +28,9 @@ License #include "wallPolyPatch.H" #include "polyBoundaryMesh.H" -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -defineTypeNameAndDebug(cellDistFuncs, 0); - -} +defineTypeNameAndDebug(Foam::cellDistFuncs, 0); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -61,7 +56,6 @@ Foam::label Foam::cellDistFuncs::findIndex // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct from mesh Foam::cellDistFuncs::cellDistFuncs(const polyMesh& mesh) : mesh_(mesh) @@ -70,36 +64,12 @@ Foam::cellDistFuncs::cellDistFuncs(const polyMesh& mesh) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -// Get patch ids of named patches Foam::labelHashSet Foam::cellDistFuncs::getPatchIDs ( - const wordList& patchNames + const wordReList& patchNames ) const { - const polyBoundaryMesh& bMesh = mesh().boundaryMesh(); - - // Construct Set of patchNames for easy checking if included - HashSet<word> patchNamesHash(patchNames.size()); - - forAll(patchNames, patchI) - { - patchNamesHash.insert(patchNames[patchI]); - } - - // Loop over all patches and check if patch name in hashset - - labelHashSet patchIDs(bMesh.size()); - - forAll(bMesh, patchI) - { - const polyPatch& patch = bMesh[patchI]; - - if (patchNamesHash.found(patch.name())) - { - patchIDs.insert(patchI); - } - } - return patchIDs; + return mesh().boundaryMesh().patchSet(patchNames, false); } @@ -252,8 +222,10 @@ Foam::label Foam::cellDistFuncs::getPointNeighbours // size of largest patch (out of supplied subset of patches) -Foam::label Foam::cellDistFuncs::maxPatchSize(const labelHashSet& patchIDs) - const +Foam::label Foam::cellDistFuncs::maxPatchSize +( + const labelHashSet& patchIDs +) const { label maxSize = 0; @@ -271,8 +243,11 @@ Foam::label Foam::cellDistFuncs::maxPatchSize(const labelHashSet& patchIDs) // sum of patch sizes (out of supplied subset of patches) -Foam::label Foam::cellDistFuncs::sumPatchSize(const labelHashSet& patchIDs) - const +Foam::label Foam::cellDistFuncs::sumPatchSize +( + const labelHashSet& patchIDs +) +const { label sum = 0; diff --git a/src/meshTools/cellDist/cellDistFuncs.H b/src/meshTools/cellDist/cellDistFuncs.H index 7392e18f2d5faa022c6fe1742a5255dbad94bd95..3ef0c5e6e8890da3f138e5871d5db1130c7fc20f 100644 --- a/src/meshTools/cellDist/cellDistFuncs.H +++ b/src/meshTools/cellDist/cellDistFuncs.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -39,7 +39,7 @@ SourceFiles #include "scalarField.H" #include "HashSet.H" #include "Map.H" -#include "wordList.H" +#include "wordReList.H" #include "scalarField.H" #include "point.H" #include "primitivePatch.H" @@ -98,8 +98,8 @@ public: return mesh_; } - //- Get patchIDs of named patches - labelHashSet getPatchIDs(const wordList&) const; + //- Return the set of patch IDs corresponding to the given names + labelHashSet getPatchIDs(const wordReList& patchNames) const; //- Get patchIDs of/derived off certain type (e.g. 'processorPolyPatch') // Uses isA, not isType diff --git a/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.H b/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.H index f7a44de396ef4f58bac47f32c1fff070a7f1f673..8ae67e952cddda5e55de5ad07de6b107bed962a1 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.H +++ b/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.H @@ -32,7 +32,7 @@ Description or (e3/e1). Any nonorthogonality will be absorbed into the second vector. For convenience, the dictionary constructor forms allow a few shortcuts: - - if the \c type is not otherwise specified, the type @c axes + - if the \c type is not otherwise specified, the type \c axes is implicit - if an axes specification (eg, e3/e1) is used, the coordinateRotation sub-dictionary can be dropped. diff --git a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C index 291530963909ba870f0c58f2a18de3714abf3773..1cfb22887b7c795b97956e4b1336a75eaab9a84c 100644 --- a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C +++ b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C @@ -398,7 +398,15 @@ void Foam::decompositionMethod::calcCellCells // Create global cell numbers // ~~~~~~~~~~~~~~~~~~~~~~~~~~ - label nAgglom = max(agglom)+1; + label nAgglom; + if (agglom.size()) + { + nAgglom = max(agglom)+1; + } + else + { + nAgglom = 0; + } globalIndex globalAgglom(nAgglom); const labelList& faceOwner = mesh.faceOwner(); diff --git a/src/parallel/decompose/decompositionMethods/simpleGeomDecomp/simpleGeomDecomp.C b/src/parallel/decompose/decompositionMethods/simpleGeomDecomp/simpleGeomDecomp.C index 9f5ff83436a0337cbc865a7eb8f499a77b33865d..4ce8706dea087ca9abea6eea014f425def63ce77 100644 --- a/src/parallel/decompose/decompositionMethods/simpleGeomDecomp/simpleGeomDecomp.C +++ b/src/parallel/decompose/decompositionMethods/simpleGeomDecomp/simpleGeomDecomp.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -26,6 +26,7 @@ License #include "simpleGeomDecomp.H" #include "addToRunTimeSelectionTable.H" #include "SortableList.H" +#include "globalIndex.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -53,7 +54,7 @@ void Foam::simpleGeomDecomp::assignToProcessorGroup ( labelList& processorGroup, const label nProcGroup -) +) const { label jump = processorGroup.size()/nProcGroup; label jumpb = jump + 1; @@ -90,7 +91,7 @@ void Foam::simpleGeomDecomp::assignToProcessorGroup const labelList& indices, const scalarField& weights, const scalar summedWeights -) +) const { // This routine gets the sorted points. // Easiest to explain with an example. @@ -126,7 +127,10 @@ void Foam::simpleGeomDecomp::assignToProcessorGroup } -Foam::labelList Foam::simpleGeomDecomp::decompose(const pointField& points) +Foam::labelList Foam::simpleGeomDecomp::decomposeOneProc +( + const pointField& points +) const { // construct a list for the final result labelList finalDecomp(points.size()); @@ -195,11 +199,11 @@ Foam::labelList Foam::simpleGeomDecomp::decompose(const pointField& points) } -Foam::labelList Foam::simpleGeomDecomp::decompose +Foam::labelList Foam::simpleGeomDecomp::decomposeOneProc ( const pointField& points, const scalarField& weights -) +) const { // construct a list for the final result labelList finalDecomp(points.size()); @@ -300,4 +304,162 @@ Foam::simpleGeomDecomp::simpleGeomDecomp(const dictionary& decompositionDict) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +Foam::labelList Foam::simpleGeomDecomp::decompose +( + const pointField& points +) +{ + if (!Pstream::parRun()) + { + return decomposeOneProc(points); + } + else + { + globalIndex globalNumbers(points.size()); + + // Collect all points on master + if (Pstream::master()) + { + pointField allPoints(globalNumbers.size()); + + label nTotalPoints = 0; + // Master first + SubField<point>(allPoints, points.size()).assign(points); + nTotalPoints += points.size(); + + // Add slaves + for (int slave=1; slave<Pstream::nProcs(); slave++) + { + IPstream fromSlave(Pstream::scheduled, slave); + pointField nbrPoints(fromSlave); + SubField<point> + ( + allPoints, + nbrPoints.size(), + nTotalPoints + ).assign(nbrPoints); + nTotalPoints += nbrPoints.size(); + } + + // Decompose + labelList finalDecomp(decomposeOneProc(allPoints)); + + // Send back + for (int slave=1; slave<Pstream::nProcs(); slave++) + { + OPstream toSlave(Pstream::scheduled, slave); + toSlave << SubField<label> + ( + finalDecomp, + globalNumbers.localSize(slave), + globalNumbers.offset(slave) + ); + } + // Get my own part + finalDecomp.setSize(points.size()); + + return finalDecomp; + } + else + { + // Send my points + { + OPstream toMaster(Pstream::scheduled, Pstream::masterNo()); + toMaster<< points; + } + + // Receive back decomposition + IPstream fromMaster(Pstream::scheduled, Pstream::masterNo()); + labelList finalDecomp(fromMaster); + + return finalDecomp; + } + } +} + + +Foam::labelList Foam::simpleGeomDecomp::decompose +( + const pointField& points, + const scalarField& weights +) +{ + if (!Pstream::parRun()) + { + return decomposeOneProc(points, weights); + } + else + { + globalIndex globalNumbers(points.size()); + + // Collect all points on master + if (Pstream::master()) + { + pointField allPoints(globalNumbers.size()); + scalarField allWeights(allPoints.size()); + + label nTotalPoints = 0; + // Master first + SubField<point>(allPoints, points.size()).assign(points); + SubField<scalar>(allWeights, points.size()).assign(weights); + nTotalPoints += points.size(); + + // Add slaves + for (int slave=1; slave<Pstream::nProcs(); slave++) + { + IPstream fromSlave(Pstream::scheduled, slave); + pointField nbrPoints(fromSlave); + scalarField nbrWeights(fromSlave); + SubField<point> + ( + allPoints, + nbrPoints.size(), + nTotalPoints + ).assign(nbrPoints); + SubField<scalar> + ( + allWeights, + nbrWeights.size(), + nTotalPoints + ).assign(nbrWeights); + nTotalPoints += nbrPoints.size(); + } + + // Decompose + labelList finalDecomp(decomposeOneProc(allPoints, allWeights)); + + // Send back + for (int slave=1; slave<Pstream::nProcs(); slave++) + { + OPstream toSlave(Pstream::scheduled, slave); + toSlave << SubField<label> + ( + finalDecomp, + globalNumbers.localSize(slave), + globalNumbers.offset(slave) + ); + } + // Get my own part + finalDecomp.setSize(points.size()); + + return finalDecomp; + } + else + { + // Send my points + { + OPstream toMaster(Pstream::scheduled, Pstream::masterNo()); + toMaster<< points << weights; + } + + // Receive back decomposition + IPstream fromMaster(Pstream::scheduled, Pstream::masterNo()); + labelList finalDecomp(fromMaster); + + return finalDecomp; + } + } +} + + // ************************************************************************* // diff --git a/src/parallel/decompose/decompositionMethods/simpleGeomDecomp/simpleGeomDecomp.H b/src/parallel/decompose/decompositionMethods/simpleGeomDecomp/simpleGeomDecomp.H index d14b05abdee2be99964cd1995f4bb7b3a0ca63af..c829f4f9bf2ab71687ee0e754c392afd000909d8 100644 --- a/src/parallel/decompose/decompositionMethods/simpleGeomDecomp/simpleGeomDecomp.H +++ b/src/parallel/decompose/decompositionMethods/simpleGeomDecomp/simpleGeomDecomp.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -49,7 +49,7 @@ class simpleGeomDecomp { // Private Member Functions - void assignToProcessorGroup(labelList& processorGroup, const label); + void assignToProcessorGroup(labelList&, const label) const; void assignToProcessorGroup ( @@ -58,7 +58,15 @@ class simpleGeomDecomp const labelList& indices, const scalarField& weights, const scalar summedWeights - ); + ) const; + + labelList decomposeOneProc(const pointField& points) const; + + labelList decomposeOneProc + ( + const pointField& points, + const scalarField& weights + ) const; //- Disallow default bitwise copy construct and assignment void operator=(const simpleGeomDecomp&); @@ -86,9 +94,9 @@ public: virtual bool parallelAware() const { - // simpleDecomp does not attempt to do anything across proc - // boundaries - return false; + // simpleDecomp sends all points to the master which does + // the decomposition. + return true; } virtual labelList decompose(const pointField&); diff --git a/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.C b/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.C index 228fa5ad326e99c5693f79f5dd8ad22ea1c7b948..2774396e4f27365160286211ab030deb01704706 100644 --- a/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.C +++ b/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -87,8 +87,7 @@ void Foam::nearWallFields::read(const dictionary& dict) const fvMesh& mesh = refCast<const fvMesh>(obr_); dict.lookup("fields") >> fieldSet_; - patchSet_ = - mesh.boundaryMesh().patchSet(wordList(dict.lookup("patches"))); + patchSet_ = mesh.boundaryMesh().patchSet(dict.lookup("patches")); distance_ = readScalar(dict.lookup("distance")); diff --git a/src/postProcessing/functionObjects/forces/forces/forces.C b/src/postProcessing/functionObjects/forces/forces/forces.C index 412794795b2f22189c68b08ae51678f739b3701a..aacc6b1947e55185f973c41e49b688a6a831449c 100644 --- a/src/postProcessing/functionObjects/forces/forces/forces.C +++ b/src/postProcessing/functionObjects/forces/forces/forces.C @@ -229,8 +229,7 @@ void Foam::forces::read(const dictionary& dict) const fvMesh& mesh = refCast<const fvMesh>(obr_); - patchSet_ = - mesh.boundaryMesh().patchSet(wordList(dict.lookup("patches"))); + patchSet_ = mesh.boundaryMesh().patchSet(dict.lookup("patches")); if (directForceDensity_) { diff --git a/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.H b/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.H index e4e3af67e6bd4e6082b683b096e3bca26ab12dc5..6ff54c775f98640647c4c76416be4db116cc5893 100644 --- a/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.H @@ -96,7 +96,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -110,7 +110,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -124,7 +124,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -138,7 +138,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -152,7 +152,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, diff --git a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.H b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.H index 628c178d4e6f5b7db109af0d2faeee32530a8ccf..ca42fa8f08a68ba5d76f431472ab99c362dacdc9 100644 --- a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.H @@ -117,7 +117,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -131,7 +131,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -145,7 +145,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -159,7 +159,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -173,7 +173,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, diff --git a/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.H b/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.H index ce19c21455acb7364db57c1ae82a601067716f3a..7912a65acfcb718edb510f7894eff9b20e0afa1c 100644 --- a/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.H @@ -107,7 +107,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -121,7 +121,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -135,7 +135,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -149,7 +149,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -163,7 +163,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, diff --git a/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.H b/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.H index 5ec4d1ac3054b20973eb04d235cb29b21035e39f..c08b0eee5e9d997afefe91c1f89987e60779b688 100644 --- a/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.H @@ -128,7 +128,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -142,7 +142,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -156,7 +156,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -170,7 +170,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -184,7 +184,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, diff --git a/src/sampling/sampledSurface/writers/starcd/starcdSurfaceWriter.H b/src/sampling/sampledSurface/writers/starcd/starcdSurfaceWriter.H index 36d6d4a464ddb72fccdb641bd74de77b653fb2cc..5e212b394a3c9760298b684cb4cb08a3a1052cb0 100644 --- a/src/sampling/sampledSurface/writers/starcd/starcdSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/starcd/starcdSurfaceWriter.H @@ -129,7 +129,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -143,7 +143,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -157,7 +157,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, diff --git a/src/sampling/sampledSurface/writers/surfaceWriter.H b/src/sampling/sampledSurface/writers/surfaceWriter.H index be265178499d6905c47b45409f1963841106c9ce..f9d05871649d96f74c993756eb4308387a5d31c1 100644 --- a/src/sampling/sampledSurface/writers/surfaceWriter.H +++ b/src/sampling/sampledSurface/writers/surfaceWriter.H @@ -119,7 +119,7 @@ public: //- Write single surface geometry to file. virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -132,7 +132,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -147,7 +147,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -162,7 +162,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -177,7 +177,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -192,7 +192,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, diff --git a/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.H b/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.H index 322159094b7ff918e376888b6bb4891cc6b76d4e..75af4a347e90af2af09f5c213fbe1d8d6c0bfa67 100644 --- a/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.H @@ -105,7 +105,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -119,7 +119,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -133,7 +133,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -147,7 +147,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -161,7 +161,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // <root>/<case>/surface/TIME + const fileName& outputDir, // <case>/surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, diff --git a/src/surfMesh/surfaceFormats/ofs/OFSsurfaceFormat.H b/src/surfMesh/surfaceFormats/ofs/OFSsurfaceFormat.H index cad33330cc4e86d91d617760b08074f2d0a0a082..39b16546234aa564bbbae4a5205eeb43e82fb9ff 100644 --- a/src/surfMesh/surfaceFormats/ofs/OFSsurfaceFormat.H +++ b/src/surfMesh/surfaceFormats/ofs/OFSsurfaceFormat.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -28,7 +28,7 @@ Description Provide a means of reading/writing the single-file OpenFOAM surface format. Note - This class provides more methods than the regular surface format interface.x + This class provides more methods than the regular surface format interface. SourceFiles OFSsurfaceFormat.C diff --git a/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatASCII.L b/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatASCII.L index 5ba136329733dcc09065e007808ebad689a7a850..6145df61ca850823e17c6b3944c75b5c8c95444d 100644 --- a/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatASCII.L +++ b/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatASCII.L @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -36,7 +36,7 @@ License using namespace Foam; // Dummy yyFlexLexer::yylex() to keep the linker happy. It is not called -//! @cond dummy +//! \cond dummy int yyFlexLexer::yylex() { FatalErrorIn("yyFlexLexer::yylex()") @@ -44,12 +44,12 @@ int yyFlexLexer::yylex() << abort(FatalError); return 0; } -//! @endcond +//! \endcond // Dummy yywrap to keep yylex happy at compile time. // It is called by yylex but is not used as the mechanism to change file. // See <<EOF>> -//! @cond dummy +//! \cond dummy #if YY_FLEX_SUBMINOR_VERSION < 34 extern "C" int yywrap() #else @@ -58,7 +58,7 @@ int yyFlexLexer::yywrap() { return 1; } -//! @endcond +//! \endcond //- A lexer for parsing STL ASCII files. diff --git a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L index 58987ae82e95625cf134ef0aa3006b6269f2972e..9cdded54d930ff7db2596feac2dd01bc3b95bda9 100644 --- a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L +++ b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -38,7 +38,7 @@ License int Foam::chemkinReader::yyBufSize = YY_BUF_SIZE; // Dummy yyFlexLexer::yylex() to keep the linker happy. It is not called -//! @cond dummy +//! \cond dummy int yyFlexLexer::yylex() { FatalErrorIn("yyFlexLexer::yylex()") @@ -47,13 +47,13 @@ int yyFlexLexer::yylex() return 0; } -//! @endcond +//! \endcond // Dummy yywrap to keep yylex happy at compile time. // It is called by yylex but is not used as the mechanism to change file. // See <<EOF>> -//! @cond dummy +//! \cond dummy #if YY_FLEX_SUBMINOR_VERSION < 34 extern "C" int yywrap() #else @@ -62,7 +62,7 @@ int yyFlexLexer::yywrap() { return 1; } -//! @endcond +//! \endcond Foam::string foamSpecieString(const char* YYText) diff --git a/src/thermophysicalModels/specie/thermo/hPolynomial/hPolynomialThermo.C b/src/thermophysicalModels/specie/thermo/hPolynomial/hPolynomialThermo.C index 15269f6ce2c7c625819006e7dbff30f6ccf1665d..c86db56ae7ffa2c8d03d9a7ec38af2728679ea92 100644 --- a/src/thermophysicalModels/specie/thermo/hPolynomial/hPolynomialThermo.C +++ b/src/thermophysicalModels/specie/thermo/hPolynomial/hPolynomialThermo.C @@ -45,8 +45,8 @@ Foam::hPolynomialThermo<EquationOfState, PolySize>::hPolynomialThermo Sf_ *= this->W(); CpCoeffs_ *= this->W(); - hCoeffs_ = CpCoeffs_.integrate(); - sCoeffs_ = CpCoeffs_.integrateMinus1(); + hCoeffs_ = CpCoeffs_.integral(); + sCoeffs_ = CpCoeffs_.integralMinus1(); // Offset h poly so that it is relative to the enthalpy at Tstd hCoeffs_[0] += Hf_ - hCoeffs_.value(specie::Tstd); @@ -73,8 +73,8 @@ Foam::hPolynomialThermo<EquationOfState, PolySize>::hPolynomialThermo Sf_ *= this->W(); CpCoeffs_ *= this->W(); - hCoeffs_ = CpCoeffs_.integrate(); - sCoeffs_ = CpCoeffs_.integrateMinus1(); + hCoeffs_ = CpCoeffs_.integral(); + sCoeffs_ = CpCoeffs_.integralMinus1(); // Offset h poly so that it is relative to the enthalpy at Tstd hCoeffs_[0] += Hf_ - hCoeffs_.value(specie::Tstd); diff --git a/src/triSurface/triSurface/interfaces/STL/readSTLASCII.L b/src/triSurface/triSurface/interfaces/STL/readSTLASCII.L index 9cb9f1d3d190db2237667d896c684f3e8ae07904..20c63997c7b97cd732508dd81c54b9e286aa69dc 100644 --- a/src/triSurface/triSurface/interfaces/STL/readSTLASCII.L +++ b/src/triSurface/triSurface/interfaces/STL/readSTLASCII.L @@ -39,7 +39,7 @@ License using namespace Foam; // Dummy yyFlexLexer::yylex() to keep the linker happy. It is not called -//! @cond dummy +//! \cond dummy int yyFlexLexer::yylex() { FatalErrorIn("yyFlexLexer::yylex()") @@ -47,12 +47,12 @@ int yyFlexLexer::yylex() << abort(FatalError); return 0; } -//! @endcond +//! \endcond // Dummy yywrap to keep yylex happy at compile time. // It is called by yylex but is not used as the mechanism to change file. // See <<EOF>> -//! @cond dummy +//! \cond dummy #if YY_FLEX_SUBMINOR_VERSION < 34 extern "C" int yywrap() #else @@ -61,7 +61,7 @@ int yyFlexLexer::yywrap() { return 1; } -//! @endcond +//! \endcond class STLLexer diff --git a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/coalCloud1Properties b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/coalCloud1Properties index cd5f1054015aadcef898cff90df72cb035243ae7..c3fb62ce4aa86c8be4e24cd5252809d7016b02d4 100644 --- a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/coalCloud1Properties +++ b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/coalCloud1Properties @@ -88,19 +88,18 @@ constantProperties constantVolume true; } -particleForces -{ - gravity on; - virtualMass off; - pressureGradient off; - paramagnetic off; -} - subModels { - InjectionModel ManualInjection; + particleForces + { + activeForces + ( + sphereDrag + gravity + ); + } - DragModel SphereDrag; + InjectionModel ManualInjection; DispersionModel StochasticDispersionRAS; diff --git a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/limestoneCloud1Properties b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/limestoneCloud1Properties index 699ce6d46bec35da59157182e49ae7c625dd54af..cdec67c7f1d6fc65930cd757738586c814f90f50 100644 --- a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/limestoneCloud1Properties +++ b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/limestoneCloud1Properties @@ -72,19 +72,18 @@ constantProperties Pr 0.7; } -particleForces -{ - gravity on; - virtualMass off; - pressureGradient off; - paramagnetic off; -} - subModels { - InjectionModel ManualInjection; + particleForces + { + activeForces + ( + sphereDrag + gravity + ); + } - DragModel SphereDrag; + InjectionModel ManualInjection; DispersionModel StochasticDispersionRAS; diff --git a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/Allrun b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/Allrun index cbb64d4d0752a37d5c46112a800b437d8e681d8e..5929021b719cc35149559c82cf346271c22c6128 100755 --- a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/Allrun +++ b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/Allrun @@ -16,11 +16,16 @@ setSet -batch system/sets.setSet > log.setSet1 2>&1 setsToZones -noFlipMap > log.setsToZones 2>&1 # create the first cyclic - lhs of porous zone -unset FOAM_SETNAN +# Note that we don't know what value to give these patches-out-of-nothing so +# - use binary writing to avoid 'nan' +# - use setFields to set values +unset FOAM_SIGFPE createBaffles cycLeft '(cycLeft_half0 cycLeft_half1)' -overwrite > log.createBaffles1 2>&1 # create the second cyclic - rhs of porous zone createBaffles cycRight '(cycRight_half0 cycRight_half1)' -overwrite > log.createBaffles2 2>&1 +# Initialise newly created patchFields to 0 +changeDictionary runApplication $application diff --git a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/reactingCloud1Properties b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/reactingCloud1Properties index 599aa8567d0930d09a5a950c1c6d3b847949c5f6..3da7874bf9e591aa3afe6ad2d4ee58a255e11ba7 100644 --- a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/reactingCloud1Properties +++ b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/reactingCloud1Properties @@ -87,19 +87,18 @@ constantProperties constantVolume false; } -particleForces -{ - gravity on; - virtualMass off; - pressureGradient off; - paramagnetic off; -} - subModels { - InjectionModel ReactingMultiphaseLookupTableInjection; + particleForces + { + activeForces + ( + sphereDrag + gravity + ); + } - DragModel SphereDrag; + InjectionModel ReactingMultiphaseLookupTableInjection; DispersionModel none; diff --git a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/system/changeDictionaryDict b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/system/changeDictionaryDict new file mode 100644 index 0000000000000000000000000000000000000000..0f9c594877873d95345bf97aa2cdf6baac37f583 --- /dev/null +++ b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/system/changeDictionaryDict @@ -0,0 +1,197 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.7.1 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object changeDictionaryDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dictionaryReplacement +{ + alphat + { + boundaryField + { + cycLeft + { + type cyclic; + value uniform 0; + } + cycRight + { + type cyclic; + value uniform 0; + } + } + } + epsilon + { + boundaryField + { + cycLeft + { + type cyclic; + value uniform 0; + } + cycRight + { + type cyclic; + value uniform 0; + } + } + } + G + { + boundaryField + { + cycLeft + { + type cyclic; + value uniform 0; + } + cycRight + { + type cyclic; + value uniform 0; + } + } + } + H2O + { + boundaryField + { + cycLeft + { + type cyclic; + value uniform 0; + } + cycRight + { + type cyclic; + value uniform 0; + } + } + } + k + { + boundaryField + { + cycLeft + { + type cyclic; + value uniform 0; + } + cycRight + { + type cyclic; + value uniform 0; + } + } + } + mut + { + boundaryField + { + cycLeft + { + type cyclic; + value uniform 0; + } + cycRight + { + type cyclic; + value uniform 0; + } + } + } + N2 + { + boundaryField + { + cycLeft + { + type cyclic; + value uniform 0; + } + cycRight + { + type cyclic; + value uniform 0; + } + } + } + O2 + { + boundaryField + { + cycLeft + { + type cyclic; + value uniform 0; + } + cycRight + { + type cyclic; + value uniform 0; + } + } + } + p + { + boundaryField + { + cycLeft + { + type cyclic; + value uniform 0; + } + cycRight + { + type cyclic; + value uniform 0; + } + } + } + T + { + boundaryField + { + cycLeft + { + type cyclic; + value uniform 0; + } + cycRight + { + type cyclic; + value uniform 0; + } + } + } + U + { + boundaryField + { + cycLeft + { + type cyclic; + value uniform (0 0 0); + } + cycRight + { + type cyclic; + value uniform (0 0 0); + } + } + } +} + +// ************************************************************************* // diff --git a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/system/controlDict b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/system/controlDict index 6190c66a0722fedd86b6b711d2df393480c11013..a1620b8346b19abc53af89248b5e818586d893a0 100644 --- a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/system/controlDict +++ b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/system/controlDict @@ -33,7 +33,7 @@ writeInterval 0.1; purgeWrite 0; -writeFormat ascii; +writeFormat binary; writePrecision 10; diff --git a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/parcelInBox/constant/reactingCloud1Properties b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/parcelInBox/constant/reactingCloud1Properties index 60b93e7d13cfce997e0838e53425955154a6af6a..644a5dacd59778d90c5377d27cab065fd64275c7 100644 --- a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/parcelInBox/constant/reactingCloud1Properties +++ b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/parcelInBox/constant/reactingCloud1Properties @@ -87,19 +87,18 @@ constantProperties constantVolume false; } -particleForces -{ - gravity on; - virtualMass off; - pressureGradient off; - paramagnetic off; -} - subModels { - InjectionModel ManualInjection; + particleForces + { + activeForces + ( + sphereDrag + gravity + ); + } - DragModel SphereDrag; + InjectionModel ManualInjection; DispersionModel none; @@ -132,7 +131,7 @@ subModels U0 (0 0 0); sizeDistribution { - pdfType uniform; + distributionModelType uniform; uniformDistribution { minValue 100e-06; diff --git a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/verticalChannel/constant/reactingCloud1Properties b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/verticalChannel/constant/reactingCloud1Properties index e28b21992b5297e596939d684d4b83ebf4d79997..be83c13df0c2976f5ecc2b753ecf16001ff7dc31 100644 --- a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/verticalChannel/constant/reactingCloud1Properties +++ b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/verticalChannel/constant/reactingCloud1Properties @@ -87,19 +87,18 @@ constantProperties constantVolume false; } -particleForces -{ - gravity on; - virtualMass off; - pressureGradient off; - paramagnetic off; -} - subModels { - InjectionModel PatchInjection; + particleForces + { + activeForces + ( + sphereDrag + gravity + ); + } - DragModel SphereDrag; + InjectionModel PatchInjection; DispersionModel StochasticDispersionRAS; @@ -135,7 +134,7 @@ subModels flowRateProfile constant 1; sizeDistribution { - pdfType general; + distributionModelType general; generalDistribution { distribution diff --git a/tutorials/lagrangian/reactingParcelFoam/evaporationTest/constant/reactingCloud1Properties b/tutorials/lagrangian/reactingParcelFoam/evaporationTest/constant/reactingCloud1Properties index 823e4111abd34bc55bfe1733f5fadb680990668f..313f51e9be31fd066b984ca62b75f4a7ed2a8f30 100644 --- a/tutorials/lagrangian/reactingParcelFoam/evaporationTest/constant/reactingCloud1Properties +++ b/tutorials/lagrangian/reactingParcelFoam/evaporationTest/constant/reactingCloud1Properties @@ -84,19 +84,18 @@ constantProperties constantVolume false; } -particleForces -{ - gravity off; - virtualMass off; - pressureGradient off; - paramagnetic off; -} - subModels { - InjectionModel ManualInjection; + particleForces + { + activeForces + ( + sphereDrag + gravity + ); + } - DragModel SphereDrag; + InjectionModel ManualInjection; DispersionModel none; diff --git a/tutorials/lagrangian/rhoPisoTwinParcelFoam/simplifiedSiwek/constant/kinematicCloud1Properties b/tutorials/lagrangian/rhoPisoTwinParcelFoam/simplifiedSiwek/constant/kinematicCloud1Properties index 4896ab3e80903ff5cb64a237f04745c741f815f8..eb5945f5d2fb9958d8f7cd8cbe82727c632d1710 100644 --- a/tutorials/lagrangian/rhoPisoTwinParcelFoam/simplifiedSiwek/constant/kinematicCloud1Properties +++ b/tutorials/lagrangian/rhoPisoTwinParcelFoam/simplifiedSiwek/constant/kinematicCloud1Properties @@ -56,19 +56,18 @@ constantProperties poissonsRatio 0.35; } -particleForces -{ - gravity on; - virtualMass off; - pressureGradient off; - paramagnetic off; -} - subModels { - InjectionModel ManualInjection; + particleForces + { + activeForces + ( + sphereDrag + gravity + ); + } - DragModel SphereDrag; + InjectionModel ManualInjection; DispersionModel StochasticDispersionRAS; diff --git a/tutorials/lagrangian/rhoPisoTwinParcelFoam/simplifiedSiwek/constant/thermoCloud1Properties b/tutorials/lagrangian/rhoPisoTwinParcelFoam/simplifiedSiwek/constant/thermoCloud1Properties index 451e2419c729370b176395e9327d6242fdf6daf2..713b1977a652b16ab0f96283ea07b725cab2d7ad 100644 --- a/tutorials/lagrangian/rhoPisoTwinParcelFoam/simplifiedSiwek/constant/thermoCloud1Properties +++ b/tutorials/lagrangian/rhoPisoTwinParcelFoam/simplifiedSiwek/constant/thermoCloud1Properties @@ -71,19 +71,18 @@ constantProperties Pr 0.7; } -particleForces -{ - gravity on; - virtualMass off; - pressureGradient off; - paramagnetic off; -} - subModels { - InjectionModel ManualInjection; + particleForces + { + activeForces + ( + sphereDrag + gravity + ); + } - DragModel SphereDrag; + InjectionModel ManualInjection; DispersionModel StochasticDispersionRAS; diff --git a/tutorials/lagrangian/steadyReactingParcelFoam/counterFlowFlame2D/constant/reactingCloud1Properties b/tutorials/lagrangian/steadyReactingParcelFoam/counterFlowFlame2D/constant/reactingCloud1Properties index 95c7bb4f9ee537d99cf3beeb2caefe3cb7d3811c..be708f1baf4e5cdf8fc124e96a836d6c3e4cb8d1 100644 --- a/tutorials/lagrangian/steadyReactingParcelFoam/counterFlowFlame2D/constant/reactingCloud1Properties +++ b/tutorials/lagrangian/steadyReactingParcelFoam/counterFlowFlame2D/constant/reactingCloud1Properties @@ -18,81 +18,6 @@ FoamFile solution { active no; - - integrationSchemes - { - U Euler; - T Analytical; - } -} - - -constantProperties -{ - parcelTypeId 1; - - rhoMin 1e-15; - minParticleMass 1e-15; - TMin 200; - pMin 1000; - minParticleMass 1e-15; - - rho0 1400; - T0 313; - Cp0 1680; - - youngsModulus 2e9; - poissonsRatio 0.35; - - epsilon0 0.8; - f0 0.3; - - Tvap 400; - Tbp 400; - Pr 0.7; - LDevol 0; - hRetentionCoeff 1; - - constantVolume true; -} - - -particleForces -{ - gravity off; - virtualMass off; - pressureGradient off; - paramagnetic off; -} - - -subModels -{ - InjectionModel none; - - CollisionModel none; - - DragModel none; - - DispersionModel none; - - PatchInteractionModel none; - - HeatTransferModel none; - - CompositionModel none; - - PhaseChangeModel none; - - DevolatilisationModel none; - - SurfaceReactionModel none; - - PostProcessingModel none; - - SurfaceFilmModel none; - - radiation off; } diff --git a/tutorials/lagrangian/steadyReactingParcelFoam/verticalChannel/constant/reactingCloud1Properties b/tutorials/lagrangian/steadyReactingParcelFoam/verticalChannel/constant/reactingCloud1Properties index 1201e969082907e32bc35501f706157b215e6e3f..45a6113ef38e3a736f9e8bd03eede4e71a62c55c 100644 --- a/tutorials/lagrangian/steadyReactingParcelFoam/verticalChannel/constant/reactingCloud1Properties +++ b/tutorials/lagrangian/steadyReactingParcelFoam/verticalChannel/constant/reactingCloud1Properties @@ -22,6 +22,7 @@ solution transient no; // yes; calcFrequency 10; maxTrackTime 5.0; + maxCo 0.3; coupled true; cellValueSourceCorrection off; @@ -97,20 +98,18 @@ constantProperties } -particleForces -{ - gravity on; - virtualMass off; - pressureGradient off; - paramagnetic off; -} - - subModels { - InjectionModel PatchInjection; + particleForces + { + activeForces + ( + sphereDrag + gravity + ); + } - DragModel SphereDrag; + InjectionModel PatchInjection; DispersionModel StochasticDispersionRAS; @@ -146,7 +145,7 @@ subModels flowRateProfile constant 1; sizeDistribution { - pdfType general; + distributionModelType general; generalDistribution { distribution diff --git a/wmake/Makefile b/wmake/Makefile index 72fd3ed087c5582c789520701fd72ab35895f9b8..168710ce196756a73da878c3208cbb78bb181eef 100644 --- a/wmake/Makefile +++ b/wmake/Makefile @@ -106,7 +106,7 @@ SEXE = a.out GENERAL_RULES = $(WM_DIR)/rules/General RULES = $(WM_DIR)/rules/$(WM_ARCH)$(WM_COMPILER) -BIN = $(WM_DIR)/bin/$(WM_ARCH)$(WM_COMPILER) +WMAKE_BIN = $(WM_DIR)/platforms/$(WM_ARCH)$(WM_COMPILER) include $(GENERAL_RULES)/general include $(RULES)/general diff --git a/wmake/makeWmake b/wmake/makeWmake index bd2a7cae1930f6517a895937d193cba93485358a..3185c8090988767129daf24215d625c4b38d0f9a 100755 --- a/wmake/makeWmake +++ b/wmake/makeWmake @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -26,13 +26,40 @@ # makeWmake # # Description -# Script to build all the system-specific parts of wmake +# Build platform-specific parts of wmake # #------------------------------------------------------------------------------ +usage() { + exec 1>&2 + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + cat<<USAGE +usage: ${0##*/} -# run from this directory only -cd ${0%/*} || exit 1 + Build platform-specific parts of wmake -( cd src && make $@ ) +USAGE + exit 1 +} + +case "$1" in +-h | -help) + usage + ;; +esac + + +echo ======================================== +echo Build platform-specific parts of wmake +echo +( + set -x + cd ${0%/*}/src && make $@ + # or simply: make -C ${0%/*}/src $@ +) +echo +echo ======================================== +echo Done building wmake +echo ======================================== +echo #------------------------------------------------------------------------------ diff --git a/wmake/rules/General/sourceToDep b/wmake/rules/General/sourceToDep index 14e95d6eb10f76656947ff023fc6b67c13ab585c..329e7f409dc0dd8adcfa63432f7f2c2f1a0d5f98 100644 --- a/wmake/rules/General/sourceToDep +++ b/wmake/rules/General/sourceToDep @@ -1,6 +1,6 @@ .SUFFIXES: .c .cc .cxx .cpp .C .F .f .dep -MKDEP = $(BIN)/wmkdep -I$(*D) $(LIB_HEADER_DIRS) +MKDEP = $(WMAKE_BIN)/wmkdep -I$(*D) $(LIB_HEADER_DIRS) .c.dep: $(MAKE_DEP) diff --git a/wmake/scripts/makeFiles b/wmake/scripts/makeFiles index 7e6104a5e746bab17c7bfd81e367f9eb0d0e11f6..0fb1b2c1ee0e807f5e96c7a4870ceca6d8d3d03f 100755 --- a/wmake/scripts/makeFiles +++ b/wmake/scripts/makeFiles @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -38,7 +38,7 @@ then exit 1 fi -dirToString=$WM_DIR/bin/$WM_ARCH$WM_COMPILER/dirToString +dirToString=$WM_DIR/platforms/$WM_ARCH$WM_COMPILER/dirToString [ -d Make ] || mkdir Make rm -f Make/files diff --git a/wmake/src/Makefile b/wmake/src/Makefile index a8332de09ec0756e2e9bd9b617cf68588d82daed..7c257b24b71ede610c8b6005f9144416743cdcc6 100644 --- a/wmake/src/Makefile +++ b/wmake/src/Makefile @@ -2,7 +2,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -49,7 +49,7 @@ SHELL = /bin/sh GENERAL_RULES = $(WM_DIR)/rules/General RULES = $(WM_DIR)/rules/$(WM_ARCH)$(WM_COMPILER) -BIN = $(WM_DIR)/bin/$(WM_ARCH)$(WM_COMPILER) +WMAKE_BIN = $(WM_DIR)/platforms/$(WM_ARCH)$(WM_COMPILER) include $(RULES)/general include $(RULES)/$(WM_LINK_LANGUAGE) @@ -59,31 +59,31 @@ include $(RULES)/$(WM_LINK_LANGUAGE) # targets #------------------------------------------------------------------------------ -all: $(BIN)/dirToString $(BIN)/wmkdep $(BIN)/wmkdepend +all: $(WMAKE_BIN)/dirToString $(WMAKE_BIN)/wmkdep $(WMAKE_BIN)/wmkdepend clean: - rm -f $(BIN)/dirToString $(BIN)/wmkdep $(BIN)/wmkdepend 2>/dev/null + rm -f $(WMAKE_BIN)/* 2>/dev/null -$(BIN)/dirToString: dirToString.c - @mkdir -p $(BIN) - $(cc) $(cFLAGS) dirToString.c -o $(BIN)/dirToString +$(WMAKE_BIN)/dirToString: dirToString.c + @mkdir -p $(WMAKE_BIN) + $(cc) $(cFLAGS) dirToString.c -o $(WMAKE_BIN)/dirToString -$(BIN)/wmkdep: wmkdep.l - @mkdir -p $(BIN) +$(WMAKE_BIN)/wmkdep: wmkdep.l + @mkdir -p $(WMAKE_BIN) flex wmkdep.l - $(cc) $(cFLAGS) lex.yy.c -o $(BIN)/wmkdep + $(cc) $(cFLAGS) lex.yy.c -o $(WMAKE_BIN)/wmkdep @rm -f lex.yy.c 2>/dev/null # for bootstrapping - use generated files directly (instead of from .atg file) -$(BIN)/wmkdepend: wmkdepend.cpp \ +$(WMAKE_BIN)/wmkdepend: wmkdepend.cpp \ wmkdependParser.cpp wmkdependScanner.cpp \ wmkdependParser.h wmkdependScanner.h - @mkdir -p $(BIN) + @mkdir -p $(WMAKE_BIN) $(CC) $(c++FLAGS) \ wmkdepend.cpp wmkdependParser.cpp wmkdependScanner.cpp \ - -o $(BIN)/wmkdepend + -o $(WMAKE_BIN)/wmkdepend #------------------------------------------------------------------------------ diff --git a/wmake/wcleanAll b/wmake/wcleanAll index 70ed7395037bdd957063faca1f20195fe241ab40..641cc84fcaee70aa291865b9a4c1f482ee9cd706 100755 --- a/wmake/wcleanAll +++ b/wmake/wcleanAll @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -30,33 +30,44 @@ # directories of all machines and delete them. # #------------------------------------------------------------------------------ -if [ "$1" = "-h" -o "$1" = "-help" ] -then - echo "Usage: ${0##*/}" - echo - echo " Remove all object files and *.dep files" - exit 1 -fi +usage() { + exec 1>&2 + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + cat<<USAGE +usage: ${0##*/} + + Remove all object files and *.dep files -[ -d bin -a -d src ] || { - echo "${0##*/}: not in the project top level directory" +USAGE exit 1 } -for dir in lib bin applications/bin +# parse options +while [ "$#" -gt 0 ] do - echo "Removing non-tools directories from $dir/" - if [ -d $dir ] - then - find $dir -mindepth 1 -type d \! -name tools | xargs rm -rf - fi + case "$1" in + -h | -help) + usage + ;; + *) + usage "unknown option/argument: '$*'" + ;; + esac done +[ -d bin -a -d src ] || usage "not in the project top level directory" + + +echo "Removing platforms/ subdirectores" +rm -rf platforms/* + echo "Removing *.dep files" find . -name '*.dep' -exec rm {} \; echo "Cleaning Make subdirectories" -find `find . -depth \( -name "Make.[A-Za-z]*" -o -name Make \) -type d -print` -depth \( -type d ! -name "*Make.[A-Za-z]*" ! -name "*Make" \) -exec rm -rf {} \; +find . -depth \( -name Make -o -name "Make.[A-Za-z]*" \) -type d -print | \ + xargs -i find '{}' -mindepth 1 -maxdepth 1 -type d -print | \ + xargs rm -rf echo "Removing lnInclude and intermediate directories" find . -depth -type d \( -name lnInclude -o -name ii_files -o -name Templates.DB \) -exec rm -rf {} \; diff --git a/wmake/wcleanMachine b/wmake/wcleanMachine index be3dc8ced073631ed70b52481d3e7489fc3b7cec..a3509833e8d563e079deac1aa515b5612d4a3708 100755 --- a/wmake/wcleanMachine +++ b/wmake/wcleanMachine @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -33,6 +33,7 @@ # #------------------------------------------------------------------------------ usage() { + exec 1>&2 while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat<<USAGE usage: ${0##*/} machineType [... machineTypeN] @@ -40,32 +41,39 @@ usage: ${0##*/} machineType [... machineTypeN] Searches the directories below the current directory for the object file directories of the specified machine type(s) and deletes them +Note: +can also use '-current' for the current value of \$WM_OPTIONS + USAGE exit 1 } + # needs some machine types ... or provide immediate help if [ "$#" -lt 1 -o "$1" = "-h" -o "$1" = "-help" ] then usage fi -[ -d lib -a -d src ] || usage "not in the project top level directory" - +[ -d bin -a -d src ] || usage "not in the project top level directory" for machType do - echo "Cleaning machine type: $machType" + if [ "$machType" = "-current" ] + then + machType="$WM_OPTIONS" + echo "Using current = $machType" + [ -n "$machType" ] || continue + fi - find `find . -depth \( -name "Make.[A-Za-z]*" -o -name Make \) -type d -print` \ - -depth \( -type d -name "*$machType" -o -name "*$machType$WM_MPLIB" \) -exec rm -r {} \; + echo "Cleaning machine type: $machType" - # find . -depth -type d \( -name ii_files -o -name Templates.DB \) -exec rm -rf {} \; + find . -depth \( -name Make -o -name "Make.[A-Za-z]*" \) -type d -print | \ + xargs -i find '{}' -mindepth 1 -maxdepth 1 \ + \( -type d -name "*$machType" -o -name "*$machType$WM_MPLIB" \) -print | + xargs rm -rf - for dir in lib/$machType bin/$machType applications/bin/$machType - do - [ -d $dir ] && rm -rf $dir - done + rm -rf platforms/$machType done diff --git a/wmake/wmake b/wmake/wmake index 54ee5696e85dff8fa814740bb5c9c6c01ea60a9c..37a17eca798a6d927dc668006abf63759ee16bf6 100755 --- a/wmake/wmake +++ b/wmake/wmake @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -32,6 +32,7 @@ Script=${0##*/} usage() { + exec 1>&2 while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat<<USAGE diff --git a/wmake/wmakePrintBuild b/wmake/wmakePrintBuild index 3812bece3e9e2cfbf9bc26d4d8dc85ba52a81104..5461601d4f0ab8976713a13b7e7133e1819e02fb 100755 --- a/wmake/wmakePrintBuild +++ b/wmake/wmakePrintBuild @@ -29,6 +29,9 @@ # Print the version used when building the project # #------------------------------------------------------------------------------ +# persistent build tag +build="$WM_PROJECT_DIR/.build" + usage() { exec 1>&2 @@ -41,6 +44,7 @@ options: -major report \$WM_PROJECT_VERSION only and exit -update update \$WM_PROJECT_DIR/.build from the git information -pkg TAG specify packager/release tag ('none' marks an empty packager) + -short report short version information (ie, without pkg tag) -version VER specify an alternative version Print the version used when building the project, in this order of precedence: @@ -53,7 +57,7 @@ USAGE } #------------------------------------------------------------------------------ -unset checkOnly update package version oldPackage oldVersion +unset checkOnly update package version shortOpt # parse options while [ "$#" -gt 0 ] @@ -76,10 +80,14 @@ do ;; -pkg | -package) [ "$#" -ge 2 ] || usage "'$1' option requires an argument" - # mark empty as 'none', disallow '!' and spaces in string - package=$(echo "${2:-none}" | sed -e 's/!//g' -e 's/ //g') + # mark empty as 'none', disallow '!' in string + package=$(echo "${2:-none}" | sed -e 's/!//g') shift 2 ;; + -short) + shortOpt=true + shift + ;; -v | -version) [ "$#" -ge 2 ] || usage "'$1' option requires an argument" version="$2" @@ -94,18 +102,18 @@ done #------------------------------------------------------------------------------ # -# persistent build tag -# -build="$WM_PROJECT_DIR/.build" - # retrieve old values from the $WM_PROJECT_DIR/.build cache, stored as # version [packager] -set -- $(tail -1 $build 2>/dev/null) - -oldVersion="$1"; shift -oldPackage="$@" -[ "${oldPackage:-none}" = none ] && unset oldPackage - +# +unset oldPackage oldVersion +getOldValues() +{ + set -- $(tail -1 $build 2>/dev/null) + oldVersion="$1" + [ "$#" -gt 0 ] && shift + oldPackage="$@" + [ "${oldPackage:-none}" = none ] && unset oldPackage +} # # printTag - output the build tag @@ -148,6 +156,14 @@ else fi +# retrieve old values +getOldValues + +if [ "$shortOpt" = true ] +then + unset package oldPackage +fi + # # update persistent build tag if possible # @@ -162,6 +178,14 @@ then fi fi +# cat<< DEBUG 1>&2 +# Debug information +# version='$version' +# package='$package' +# oldVersion='$oldVersion' +# oldPackage='$oldPackage' +# DEBUG + # check git vs. persistent build tag if [ -n "$checkOnly" ]