1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "ensightSurfaceWriter.H"
29 #include "OSspecific.H"
31 #include "ensightPartFaces.H"
33 #include "makeSurfaceWriterMethods.H"
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
39 makeSurfaceWriterType(ensightSurfaceWriter);
40 addToRunTimeSelectionTable(surfaceWriter, ensightSurfaceWriter, wordDict);
44 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
47 void Foam::ensightSurfaceWriter::writeTemplate
49 const fileName& outputDir,
50 const fileName& surfaceName,
51 const pointField& points,
52 const faceList& faces,
53 const word& fieldName,
54 const Field<Type>& values,
55 const bool isNodeValues,
59 if (!isDir(outputDir/fieldName))
61 mkDir(outputDir/fieldName);
64 // const scalar timeValue = Foam::name(this->mesh().time().timeValue());
65 const scalar timeValue = 0.0;
67 OFstream osCase(outputDir/fieldName/surfaceName + ".case");
70 outputDir/fieldName/surfaceName + ".000.mesh",
75 outputDir/fieldName/surfaceName + ".000." + fieldName,
81 Info<< "Writing case file to " << osCase.name() << endl;
86 << "type: ensight gold" << nl
89 << "model: 1 " << osGeom.name().name() << nl
92 << pTraits<Type>::typeName << " per "
93 << word(isNodeValues ? "node:" : "element:") << setw(10) << 1
95 << " " << surfaceName.c_str() << ".***." << fieldName << nl
98 << "time set: 1" << nl
99 << "number of steps: 1" << nl
100 << "filename start number: 0" << nl
101 << "filename increment: 1" << nl
102 << "time values:" << nl
106 ensightPartFaces ensPart(0, osGeom.name().name(), points, faces, true);
110 osField.writeKeyword(pTraits<Type>::typeName);
111 ensPart.writeField(osField, values, isNodeValues);
115 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
117 Foam::ensightSurfaceWriter::ensightSurfaceWriter()
120 writeFormat_(IOstream::ASCII)
124 Foam::ensightSurfaceWriter::ensightSurfaceWriter(const dictionary& options)
127 writeFormat_(IOstream::ASCII)
129 // choose ascii or binary format
130 if (options.found("format"))
132 writeFormat_ = IOstream::formatEnum(options.lookup("format"));
137 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
139 Foam::ensightSurfaceWriter::~ensightSurfaceWriter()
143 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
145 void Foam::ensightSurfaceWriter::write
147 const fileName& outputDir,
148 const fileName& surfaceName,
149 const pointField& points,
150 const faceList& faces,
154 if (!isDir(outputDir))
159 // const scalar timeValue = Foam::name(this->mesh().time().timeValue());
160 const scalar timeValue = 0.0;
162 OFstream osCase(outputDir/surfaceName + ".case");
163 ensightGeoFile osGeom
165 outputDir/surfaceName + ".000.mesh",
171 Info<< "Writing case file to " << osCase.name() << endl;
176 << "type: ensight gold" << nl
179 << "model: 1 " << osGeom.name().name() << nl
182 << "time set: 1" << nl
183 << "number of steps: 1" << nl
184 << "filename start number: 0" << nl
185 << "filename increment: 1" << nl
186 << "time values:" << nl
190 ensightPartFaces ensPart(0, osGeom.name().name(), points, faces, true);
195 // create write methods
196 defineSurfaceWriterWriteFields(Foam::ensightSurfaceWriter);
199 // ************************************************************************* //